예제 #1
0
 function run()
 {
     $site_pages = $this->_get_site_page_data();
     if ($site_pages) {
         $ta = new TableAdmin();
         $ta->init_view_no_db(array('page_url' => 'URL', 'created_by' => 'Created By Username', 'author' => 'Author', 'last_edited_by' => 'Last Edited Username', 'last_modified' => 'Last Modified'), true);
         $ta->set_data_from_array($site_pages);
         $ta->set_show_actions_first_cell(false);
         $ta->set_show_actions_last_cell(false);
         $ta->set_fields_that_allow_sorting(array('last_modified'));
         $ta->set_fields_to_entity_convert(array('created_by', 'author', 'last_edited_by', 'last_modified'));
         $ta->run();
     } elseif (!$this->_get_validated_site_id()) {
         echo '<p>You can only use this module in the context of a Reason site to which you have proper access privileges.</p>';
     } else {
         echo '<p>The site does not have any valid pages.</p>';
     }
 }
예제 #2
0
$page_types_no_pages = array_diff(array_values($rpt->get_page_type_names()), array_keys($data_pages));
foreach ($page_types_no_pages as $page_type_no_page) {
    $data_pages[$page_type_no_page]['page_type'] = $page_type_no_page;
    $pt = @$rpt->get_page_type($page_type_no_page);
    $data_pages[$page_type_no_page]['location'] = is_object($pt) ? $pt->get_location() : "";
    $data_pages[$page_type_no_page]['url'] = '';
    $data_pages[$page_type_no_page]['count'] = 0;
}
// let's sort our data set
$sort_field = isset($_GET['table_sort_field']) && check_against_array($_GET['table_sort_field'], array('page_type', 'count', 'url', 'location')) ? $_GET['table_sort_field'] : 'count';
$sort_order = isset($_GET['table_sort_order']) && check_against_array($_GET['table_sort_order'], array('desc', 'asc')) ? $_GET['table_sort_order'] : 'desc';
// do our manual sorting
$sort_func = "_sort_" . $sort_field . "_" . $sort_order;
uasort($data_pages, $sort_func);
$table_admin = new TableAdmin();
$table_admin->set_show_actions_first_cell(false);
$table_admin->set_fields_to_entity_convert(array('count', 'page_type', 'location'));
$table_admin->init_from_array($data_pages, true);
$table_admin->run();
echo '</body>';
echo '</html>';
function _sort_count_desc($a, $b)
{
    if ($a['count'] == $b['count']) {
        return 0;
    }
    return $a['count'] > $b['count'] ? -1 : 1;
}
function _sort_count_asc($a, $b)
{
    if ($a['count'] == $b['count']) {