Example #1
0
 public static function set_current_page_infos($menu_page_slug)
 {
     if ($menu_page_slug == 'apm_browse_pages_menu') {
         self::$current_page = 'browse';
     }
     self::$current_page = apply_filters('apm_bo_context_current_page', self::$current_page, $menu_page_slug);
 }
Example #2
0
 public static function get_page_show_in_tree_link($page_id = 0)
 {
     $show_in_tree_link = '';
     if (empty($page_id)) {
         global $post;
         if (!empty($post->post_type) && $post->post_type == 'page') {
             $page_id = $post->ID;
         }
     }
     if (!empty($page_id)) {
         if (!current_user_can('edit_pages', $page_id)) {
             return '';
         }
         $page_apm_id = self::get_page_apm_id($page_id);
         if (!empty($page_apm_id)) {
             $show_in_tree_link = ApmBoContext::get_reach_node_url($page_apm_id);
         }
     }
     return $show_in_tree_link;
 }
 /**
  * Loads the "All pages" template 
  */
 public static function bo_panel_template()
 {
     ApmBoContext::set_current_page_infos($_GET['page']);
     $template_file = dirname(__FILE__) . "/templates/" . ApmOptions::get_option('panel_page_template_name') . "/browse.php";
     if (file_exists($template_file)) {
         require_once dirname(__FILE__) . '/lib/custom_columns.php';
         require_once $template_file;
     } else {
         self::show_error(__('Template not found', ApmConfig::i18n_domain) . ' : [' . $template_file . ']');
     }
 }
Example #4
0
 public static function handle_actions()
 {
     //Check nonce:
     if (!empty($_REQUEST['apm_options_action']) && !wp_verify_nonce($_REQUEST['_wpnonce'], self::save_options_nonce)) {
         wp_die(__("Could not save plugin settings : security check failed.", ApmConfig::i18n_domain));
         exit;
     }
     $redirect_url = self::get_base_url(true);
     if (!empty($_GET['apm_options_action'])) {
         //Bugfix "Headers already sent" on action in Pages > Settings > Plugin data management for some configs.
         //TODO : see if we can identify more precisely what is causing this to find a more targeted fix.
         $buffer = ob_get_clean();
         switch ($_GET['apm_options_action']) {
             case 'delete_all_data':
                 ApmTreeData::delete_database_data(false);
                 wp_redirect(add_query_arg(array('apm_options_msg' => 2), $redirect_url));
                 exit;
                 break;
             case 'delete_options':
                 ApmOptions::delete_database_data();
                 wp_redirect(add_query_arg(array('apm_options_msg' => 3), $redirect_url));
                 exit;
                 break;
             case 'delete_folding_infos':
                 ApmTreeState::delete_all();
                 wp_redirect(add_query_arg(array('apm_options_msg' => 4), $redirect_url));
                 exit;
                 break;
             case 'restore_page':
                 if (!empty($_GET['wp_id'])) {
                     //Check if the page is still lost :
                     $lost_pages = self::get_lost_pages();
                     if (array_key_exists($_GET['wp_id'], $lost_pages)) {
                         $tree = new ApmTreeData();
                         $tree->load_last_tree();
                         $apm_id = $tree->add_new_node('insert_child', ApmTreeData::root_id, 'page', $_GET['wp_id']);
                         self::$feedback['msg'] = sprintf(__('The page "%s" has been successful restored to the end of the tree', ApmConfig::i18n_domain), $lost_pages[$_GET['wp_id']]->post_title);
                         if (!empty($_GET['redirect_to_page_in_tree'])) {
                             wp_redirect(ApmBoContext::get_reach_node_url($apm_id));
                             exit;
                         }
                     } else {
                         self::$feedback['type'] = 'error';
                         self::$feedback['msg'] = sprintf(__('The page to restore (wp_id = %s) is not in lost pages.', ApmConfig::i18n_domain), $_GET['wp_id']);
                     }
                 }
                 break;
             case 'reset_tree_from_wp_pages':
                 //Restore apm tree from WP pages tree
                 $tree = new ApmTreeData();
                 $tree->reset_tree_and_data();
                 wp_redirect(add_query_arg(array('apm_options_msg' => 5), $redirect_url));
                 exit;
                 break;
             case 'apm_tree_to_wp_pages_tree':
                 $tree = new ApmTreeData();
                 $tree->load_last_tree();
                 $tree->synchronize_tree_with_wp_entities();
                 wp_redirect(add_query_arg(array('apm_options_msg' => 6), $redirect_url));
                 exit;
                 break;
         }
         //Bugfix "Headers already sent" on action in Pages > Settings > Plugin data management for some configs.
         //TODO : see if we can identify more precisely what is causing this to find a more targeted fix.
         echo $buffer;
         do_action('apm_options_handle_get_action', $_GET['apm_options_action'], $redirect_url);
     } elseif (!empty($_POST['apm_options_action'])) {
         switch ($_POST['apm_options_action']) {
             case 'save_admin_options':
                 self::save_options($_POST);
                 self::$feedback['msg'] = __('Admin options saved successfuly', ApmConfig::i18n_domain);
                 break;
         }
         do_action('apm_options_handle_post_action', $_POST['apm_options_action'], $redirect_url);
     }
 }
			<?php 
            /*
             	//Native edit page panel displays nothing if there's no page templates in current theme. Let's do the same.
            	<p id="apm_page_attributes_template"><span><?php _e('No Page Template found in current theme directory!') ?></span></p> 
            */
            ?>
		<?php 
        }
        ?>
		
		<div id="apm_page_attributes_reach">
			<?php 
        if (!empty($page_apm_id)) {
            ?>
				<a class="button" href="<?php 
            echo ApmBoContext::get_reach_node_url($page_apm_id);
            ?>
"><?php 
            _e("Where is it ?", ApmConfig::i18n_domain);
            ?>
</a>
			<?php 
        }
        ?>
		</div>
		
		<div id="apm_page_attributes_family_nav">
			<?php 
        $link = !empty($page_tree_positions->parent) ? get_edit_post_link($page_tree_positions->parent) : '';
        ?>
			<div class="apm_page_attributes_nav_button_wrapper">
Example #6
0
<?php

define('MAX_ADD_PAGES', 10);
// Define actions list
$filters_list = array('tree' => array('label' => __('All', ApmConfig::i18n_domain), 'current' => true, 'count' => 0), 'publish' => array('label' => __('Online', ApmConfig::i18n_domain), 'count' => 0), 'unpublish' => array('label' => __('Offline', ApmConfig::i18n_domain), 'count' => 0), 'recent' => array('label' => __('Recent Pages', ApmConfig::i18n_domain)));
//Hook that can be used by addons to add a navigation filter :
$filters_list = apply_filters('apm_panel_page_filters_nav', $filters_list);
$is_browse = ApmBoContext::get_current_page() == 'browse';
$total_actions = count($filters_list);
// Returns HTML for pagination
function get_template_pagination($position = 'top')
{
    $output = '  <div class="container-pagination pagination-' . $position . ' tablenav-pages">';
    $output .= '    <span class="pagination-total-items displaying-num">0</span>&nbsp;<span class="displaying-num">élément(s)</span>';
    $output .= '    &nbsp;&nbsp;&nbsp;<span class="displaying-num nb-selected-rows">0</span>&nbsp;<span class="displaying-num">sélectionné(s)</span>';
    $output .= '    <div class="pagination-wrapper">';
    $output .= '	   		&nbsp;<span class="pagination-first-page"><a href="#" class="first-page">&lt;&lt</a></span>';
    $output .= '    		&nbsp;<span class="pagination-preview"><a href="#" class="prev-page">&lt;</a></span>';
    $output .= '			<input class="current-page pagination-current-page" title="Page actuelle" type="text" name="paged" value="1" size="2">';
    $output .= '	   		&nbsp;' . __('on', ApmConfig::i18n_domain) . '&nbsp;';
    $output .= '    		<span class="pagination-total-pages"></span>';
    $output .= '    		&nbsp;<span class="pagination-next"><a class="next-page" href="#">&gt;</a></span>';
    $output .= '	   		&nbsp;<span class="pagination-last-page"><a class="last-page" href="#">&gt;&gt;</a></span>';
    $output .= '    </div>';
    $output .= '  </div>';
    return $output;
}
/**
 * Retrieves page date the same way it is retrieved in native panel :
 * see /wp-admin/includes/class-wp-posts-list-table.php
 */
Example #7
0
	    </div>
	</div>
</div>

<script>
jQuery().ready(function(){
	var $ = jQuery;

	$.apm_common.init();

	// Initialize tree by default
	<?php 
if ($is_browse) {
    ?>
		<?php 
    $node_to_go_to = ApmBoContext::get_requested_go_to_node('');
    if (!empty($node_to_go_to)) {
        $node_to_go_to = ",'','',{$node_to_go_to}";
    }
    ?>
		$.apm_common.switch_type('tree'<?php 
    echo $node_to_go_to;
    ?>
);
	<?php 
} else {
    ?>
		$.apm_common.switch_type('list', 'tagged');
	<?php 
}
?>