public static function get_component_items($app_id, $component_slug, $items_ids, $args = array()) { $component_items = array(); if (WpakComponentsStorage::component_exists($app_id, $component_slug)) { $component = WpakComponentsStorage::get_component($app_id, $component_slug); $component_items_by_global = WpakComponentsTypes::get_component_items($component, $items_ids, $args); foreach ($component_items_by_global as $global => $items) { if (is_string($global)) { //to be sure that we did not forget to set a global as key $component_items['globals'][$global] = $items; } } } return $component_items; }
public static function get_navigation_components($post_id) { $components = array(); $navigation_items = self::get_navigation_items_raw($post_id); if (!empty($navigation_items)) { $navigation_items = self::order_items($navigation_items); foreach ($navigation_items as $nav_item_id => $nav_item) { if (WpakComponentsStorage::component_exists($post_id, $nav_item->component_id)) { $components[$nav_item->component_id] = WpakComponentsStorage::get_component($post_id, $nav_item->component_id); } } } return $components; }
private static function get_navigation_row($post_id, $i, $nav_item_id, $nav_item) { $error_class = ''; $alternate_class = $i % 2 ? '' : 'alternate'; $component = WpakComponentsStorage::get_component($post_id, $nav_item->component_id); // // Component type could be unknown if an addon's component has been added to the app and the addon isn't activated anymore // An addon could be seen as deactivated either if the corresponding plugin is deactivated, or if the corresponding checkbox is unchecked for the given app // if (!WpakComponentsTypes::component_type_exists($component->type)) { $error_class = ' error'; $error_message = __('Component type doesn\'t exist, this component won\'t be included into the app', WpAppKit::i18n_domain); } ob_start(); ?> <?php if (!empty($component)) { ?> <tr class="ui-state-default <?php echo $alternate_class . $error_class; ?> navigation-item navigation-item-component-<?php echo $nav_item->component_id; ?> " data-id="<?php echo $nav_item_id; ?> " id="navigation-item-row-<?php echo $nav_item_id; ?> "> <td> <span class="label"><?php echo $component->label; ?> </span> (<span class="slug"><?php echo $component->slug; ?> </span>) <input type="hidden" id="position-<?php echo $nav_item_id; ?> " name="positions[<?php echo $nav_item_id; ?> ]" value="<?php echo $nav_item->position; ?> " /> <div class="row-actions"> <span class="trash"><a class="submitdelete delete_navigation_item" href="#" data-post-id="<?php echo $post_id; ?> " data-id="<?php echo $nav_item_id; ?> "><?php _e('Delete', WpAppKit::i18n_domain); ?> </a></span> </div> </td> <td> <?php if (empty($error_message)) { ?> <?php $icon_value = $nav_item->options['icon_slug']; ?> <div id="nav-item-value-<?php echo $nav_item_id; ?> "> <span id="span-<?php echo $nav_item_id; ?> "><?php echo !empty($icon_value) ? $icon_value : __('none', WpAppKit::i18n_domain); ?> </span> <div class="row-actions"> <a href="#" class="change-icon-slug" data-id="<?php echo $nav_item_id; ?> "><?php _e('Edit icon', WpAppKit::i18n_domain); ?> </a> </div> </div> <div id="nav-item-input-<?php echo $nav_item_id; ?> " style="display:none" > <input type="text" id="icon-<?php echo $nav_item_id; ?> " class="menu-item-icon-input" data-id="<?php echo $nav_item_id; ?> " value="<?php echo $nav_item->options['icon_slug']; ?> "/> <a href="#" id="change-icon-slug-ok-<?php echo $nav_item_id; ?> " class="change-icon-slug-ok" data-id="<?php echo $nav_item_id; ?> " data-post-id="<?php echo $post_id; ?> " ><?php _e('Ok', WpAppKit::i18n_domain); ?> </a> <a href="#" class="change-icon-slug-cancel" data-id="<?php echo $nav_item_id; ?> "><?php _e('Cancel', WpAppKit::i18n_domain); ?> </a> </div> <?php } else { ?> <div id="nav-item-value-<?php echo $nav_item_id; ?> "> <span id="span-<?php echo $nav_item_id; ?> "><?php echo $error_message; ?> </span> </div> <?php } ?> </td> </tr> <?php } ?> <?php $navigation_row_html = ob_get_contents(); ob_end_clean(); return $navigation_row_html; }