Example #1
0
 private static function process_object($data, $parent_name = '', $current_tree = '')
 {
     $fields = array();
     if ($data['name'] == '_versions') {
         $fields['version_id'] = array('type' => 'int', 'length' => 10, 'index' => 'primary');
         $fields['id'] = array('type' => 'int', 'length' => 10, 'index' => 'index');
         if ($parent_name) {
             $fields[$parent_name . '_id'] = array('type' => 'int', 'length' => 10, 'index' => 'index');
         }
     } else {
         $fields['id'] = array('type' => 'int', 'length' => 10, 'index' => 'primary');
         if ($parent_name && !isset($data['child'])) {
             $fields[$parent_name . '_id'] = array('type' => 'int', 'length' => 10, 'index' => 'index');
         }
     }
     if ($data->getName() == 'site') {
         $data = new SimpleXMLElement('<object path="site" name="site" stack="site">' . Config::site_fields() . '</object>');
         $fields['name'] = array('type' => 'varchar', 'length' => 150, 'default' => '');
         $fields['url'] = array('type' => 'varchar', 'length' => 150, 'default' => '');
         $language_codes = array_keys(languages());
         if ($countries = Config::countries()) {
             $language_codes = array_keys($countries);
         }
         if (count($language_codes) > 1) {
             foreach ($language_codes as $code) {
                 $fields['url_' . $code] = array('type' => 'varchar', 'length' => 150, 'default' => '');
             }
         }
         $fields['table_check_date'] = array('type' => 'int', 'length' => 10);
         $fields['routing_check_date'] = array('type' => 'int', 'length' => 10);
         $fields['structure_xml'] = array('type' => 'mediumtext');
         $fields['structure_xml_expanded'] = array('type' => 'mediumtext');
         $fields['routing'] = array('type' => 'text');
         $fields['live'] = array('type' => 'bool', 'default' => '0');
         $fields['piwik_id'] = array('type' => 'varchar', 'length' => 50, 'default' => '');
         $cmsdownloads = $data->addChild('files');
         $cmsdownloads->addAttribute('name', 'downloads');
         $cmsdownloads->addAttribute('sortable', 'true');
         $cmsimages = $data->addChild('images');
         $cmsimages->addAttribute('name', 'images');
         $cmsimages->addAttribute('sortable', 'true');
         $cmsvideos = $data->addChild('object');
         $cmsvideos->addAttribute('name', 'videos');
         $cmsvideos->addAttribute('sortable', 'true');
         $cmsvideo = $cmsvideos->addChild('video');
         $cmsvideo->addAttribute('name', 'video');
     }
     $attributes = $data->attributes();
     $children = $data->children();
     if (!isset($attributes['name'])) {
         return false;
     }
     if (isset($data['sortable']) && $data['sortable']) {
         $fields['_sort_order'] = array('type' => 'int', 'length' => 10, 'index' => 'index');
     }
     if (isset($data['recursive']) && $data['recursive']) {
         $fields['parent_id'] = array('type' => 'int', 'length' => 10, 'index' => 'index');
     }
     foreach ($children as $key => $child) {
         $fields = self::process_field($key, $child, $fields, $data, $current_tree);
     }
     self::modify_table($current_tree . $attributes['name'], $fields, $data);
 }