Пример #1
0
 public static function load($fieldsets)
 {
     $fields = array('fields' => array());
     $included_fields = array('fields' => array());
     $fieldset_names = array();
     if (!is_array($fieldsets)) {
         $fieldsets = array($fieldsets);
     }
     foreach ($fieldsets as $key => $name) {
         if (File::exists("_config/fieldsets/{$name}.yaml")) {
             $meta = self::fetch_fieldset($name);
             if (isset($meta['include'])) {
                 if (!is_array($meta['include'])) {
                     $meta['include'] = array($meta['include']);
                 }
                 foreach ($meta['include'] as $include_key => $include_name) {
                     $include = self::fetch_fieldset($include_name);
                     $included_fields['fields'] = array_merge($included_fields['fields'], $include['fields']);
                 }
             }
             // Merge it all together
             $fields['fields'] = array_merge($fields['fields'], $included_fields['fields']);
             if (is_array(array_get($meta, 'fields', array()))) {
                 $fields['fields'] = array_merge($fields['fields'], $meta['fields']);
             }
             $fieldset_names[] = $name;
         }
     }
     $set = new Statamic_Fieldset($fields);
     $set->set_name($fieldset_names);
     return $set;
 }
 private static function checkForDashes($fields)
 {
     foreach ($fields as $key => $val) {
         if (strpos($key, '-')) {
             throw new Exception('Field names may not contain dashes. Please use underscores.');
         }
         if (is_array($val) && isset($val['fields'])) {
             Statamic_Fieldset::checkForDashes($val['fields']);
         }
     }
 }
Пример #3
0
             $data['original_numeric'] = $numeric;
             $data['full_slug'] = $folder . "/" . $data['original_slug'];
         }
     }
 } else {
     if ($new) {
         if ($fieldset) {
             $fs = Statamic_Fieldset::load($fieldset);
             $fields_data = $fs->get_data();
             $data['fields'] = isset($fields_data['fields']) ? $fields_data['fields'] : array();
             $data['type'] = 'none';
             $data['fieldset'] = $fieldset;
         }
     } else {
         if (isset($data['_fieldset'])) {
             $fs = Statamic_Fieldset::load($data['_fieldset']);
             $fields_data = $fs->get_data();
             $data['fields'] = isset($fields_data['fields']) ? $fields_data['fields'] : array();
             $data['fieldset'] = $data['_fieldset'];
         }
         $data['type'] = 'none';
     }
     if (Slug::isDraft($page)) {
         $data['slug'] = substr($page, 2);
     } elseif (Slug::isHidden($page)) {
         $data['slug'] = substr($page, 1);
     } else {
         $data['slug'] = $page;
     }
     $data['original_slug'] = $page;
 }
Пример #4
0
             $data['full_slug'] = $folder . "/" . $data['original_slug'];
         }
     }
 } else {
     if ($new) {
         if ($fieldset) {
             $fs = Statamic_Fieldset::load($fieldset);
             $fields_data = $fs->get_data();
             $data['fields'] = isset($fields_data['fields']) ? $fields_data['fields'] : array();
             $data['type'] = 'none';
             $data['fieldset'] = $fieldset;
         }
     } else {
         $fieldset = array_get($data, '_fieldset', Config::get('default_fieldset'));
         if ($fieldset) {
             $fs = Statamic_Fieldset::load($fieldset);
             $fields_data = $fs->get_data();
             $data['fields'] = array_get($fields_data, 'fields', array());
             $data['fieldset'] = $fieldset;
         }
         $data['type'] = 'none';
     }
     if (Slug::isDraft($page)) {
         $data['slug'] = substr($page, 2);
     } elseif (Slug::isHidden($page)) {
         $data['slug'] = substr($page, 1);
     } else {
         $data['slug'] = $page;
     }
     $data['original_slug'] = $page;
 }
Пример #5
0
 /**
  * Create fieldsets
  *
  * @return void
  */
 private function createFieldsets()
 {
     $this->migration['fieldsets'] = Statamic_Fieldset::get_list();
 }