示例#1
0
 public static function get_inherited_property($element_id, $property_id, $default = null)
 {
     //Check for normal property first.  Need this for recursion and for instances/states.
     if ($normal_property = self::get_property($element_id, $property_id)) {
         return $normal_property;
     }
     //Check for inherit location right away.
     $inherit_location = HeadwayElementAPI::get_inherit_location($element_id);
     //If inherit location does not exist, go straight to default.
     if (!$inherit_location) {
         return $default;
     } else {
         return self::get_inherited_property($inherit_location, $property_id, $default);
     }
 }
 public static function method_get_design_editor_elements()
 {
     $current_layout = headway_post('layout');
     $all_elements = HeadwayElementAPI::get_all_elements();
     $groups = HeadwayElementAPI::get_groups();
     $customized_element_data = HeadwayElementsData::get_all_elements(true);
     $elements = array();
     /* Assemble the arrays */
     foreach ($all_elements as $group_id => $main_elements) {
         $elements[$group_id] = array();
         /* Loop through main elements */
         foreach ($main_elements as $main_element_id => $main_element_settings) {
             /* Handle main element */
             $inherit_location = HeadwayElementAPI::get_element(HeadwayElementAPI::get_inherit_location($main_element_id));
             $elements[$group_id][$main_element_id] = array('selector' => $main_element_settings['selector'], 'id' => $main_element_settings['id'], 'name' => $main_element_settings['name'], 'description' => headway_get('description', $main_element_settings), 'properties' => $main_element_settings['properties'], 'group' => $group_id, 'groupName' => headway_get($group_id, $groups), 'states' => headway_get('states', $main_element_settings, array()), 'instances' => headway_get('instances', $main_element_settings, array()), 'inherit-location' => headway_get('id', $inherit_location), 'inherit-location-name' => headway_get('name', $inherit_location), 'disallow-nudging' => headway_get('disallow-nudging', $main_element_settings, false), 'indent-in-selector' => headway_get('indent-in-selector', $main_element_settings, false), 'customized' => isset($customized_element_data[$main_element_settings['id']]) ? true : false, 'children' => array());
             /* Loop through main element instances and add customized flag if necessary */
             foreach ($elements[$group_id][$main_element_id]['instances'] as $main_element_instance_id => $main_element_instance_settings) {
                 if (isset($customized_element_data[$main_element_settings['id']]['special-element-instance'][$main_element_instance_id])) {
                     $elements[$group_id][$main_element_id]['instances'][$main_element_instance_id]['customized'] = true;
                 }
             }
             /* Loop through element children */
             foreach (headway_get('children', $main_element_settings, array()) as $child_element_id => $child_element_settings) {
                 /* Handle child element */
                 $inherit_location = HeadwayElementAPI::get_element(HeadwayElementAPI::get_inherit_location($child_element_id));
                 $elements[$group_id][$main_element_id]['children'][$child_element_id] = array('selector' => $child_element_settings['selector'], 'id' => $child_element_settings['id'], 'name' => $child_element_settings['name'], 'description' => headway_get('description', $child_element_settings), 'properties' => $child_element_settings['properties'], 'group' => $group_id, 'groupName' => headway_get($group_id, $groups), 'parent' => $main_element_id, 'parentName' => headway_get('name', $main_element_settings), 'states' => headway_get('states', $child_element_settings, array()), 'instances' => headway_get('instances', $child_element_settings, array()), 'indent-in-selector' => headway_get('indent-in-selector', $child_element_settings, false), 'inherit-location' => headway_get('id', $inherit_location), 'inherit-location-name' => headway_get('name', $inherit_location), 'disallow-nudging' => headway_get('disallow-nudging', $child_element_settings, false), 'customized' => isset($customized_element_data[$child_element_settings['id']]) ? true : false);
                 /* Loop through sub element instances and add customized flag if necessary */
                 foreach ($elements[$group_id][$main_element_id]['children'][$child_element_id]['instances'] as $sub_element_instance_id => $sub_element_instance_settings) {
                     if (isset($customized_element_data[$child_element_settings['id']]['special-element-instance'][$sub_element_instance_id])) {
                         $elements[$group_id][$main_element_id]['children'][$child_element_id]['instances'][$sub_element_instance_id]['customized'] = true;
                     }
                 }
             }
         }
     }
     /* Spit it all out */
     self::json_encode($elements);
 }