public static function get_navigation_indexed_by_components_slugs($post_id, $only_nav_items_options = false) { $navigation_indexed_by_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)) { $component = WpakComponentsStorage::get_component($post_id, $nav_item->component_id); if (WpakComponentsTypes::component_type_exists($component->type)) { $navigation_indexed_by_components[$component->slug] = $only_nav_items_options ? $nav_item->options : $nav_item; } } } } return $navigation_indexed_by_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; }
private static function get_component_row($post_id, $i, $component_id, WpakComponent $component) { $alternate_class = $i % 2 ? '' : 'alternate'; $error_class = ''; $label = WpakComponentsTypes::get_label($component->type); // // 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'; $label = __('Component type doesn\'t exist, this component won\'t be included into the app', WpAppKit::i18n_domain); } ob_start(); ?> <tr class="component-row <?php echo $alternate_class . $error_class; ?> " id="component-row-<?php echo $component_id; ?> "> <td> <?php echo $component->label; ?> <div class="row-actions"> <span class="inline hide-if-no-js"><a class="editinline" href="#" data-edit-id="<?php echo $component_id; ?> "><?php _e('Edit', WpAppKit::i18n_domain); ?> </a> | </span> <span class="trash"><a class="submitdelete delete_component" href="#" data-post-id="<?php echo $post_id; ?> " data-id="<?php echo $component_id; ?> "><?php _e('Delete', WpAppKit::i18n_domain); ?> </a></span> </div> </td> <td><?php echo $component->slug; ?> </td> <td><?php echo $label; ?> </td> <td> <?php $options = WpakComponentsTypes::get_options_to_display($component); ?> <?php foreach ($options as $option) { ?> <?php echo $option['label']; ?> : <?php echo $option['value']; ?> <br/> <?php } ?> </td> </tr> <tr class="edit-component-wrapper" id="edit-component-wrapper-<?php echo $component_id; ?> " style="display:none" <?php echo $alternate_class; ?> > <td colspan="4"> <?php self::echo_component_form($post_id, $component); ?> </td> </tr> <?php $component_row_html = ob_get_contents(); ob_end_clean(); return $component_row_html; }