Example #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>';
     }
 }
 function get_display()
 {
     $i = 0;
     foreach ($this->options as $k => $val) {
         if (!isset($this->option_info[$k])) {
             trigger_error('Please set option_info for each option!');
             continue;
         }
         // build our checkbox
         //$store_key[$key] = "ture";
         $val = $this->option_info[$k]['values'];
         $id = $this->option_info[$k]['id'];
         $checkbox = '<input type="checkbox" id="' . $this->name . $i . '" name="' . $this->name . '[]" value="' . htmlspecialchars($k, ENT_QUOTES) . '"';
         if (in_array($k, $this->value)) {
             $checkbox .= ' checked="checked"';
         }
         //if ( $this->_is_current_value($k) ) $checkbox .= ' checked="checked"';
         //if ( $this->_is_disabled_option($k) ) $checkbox .= ' disabled="disabled"';
         $checkbox .= ' /> ' . $id;
         $e = new entity($id);
         $checkbox .= '<p class="name">Name: ' . $e->get_value('name') . '</p>';
         $owner = get_owner_site_id($id);
         if ($owner) {
             $site = new entity($owner);
             $checkbox .= '<p class="site">Site: ' . $site->get_value('name') . '</p>';
         } else {
             $checkbox .= '<p class="site">(No owner site)</p>';
         }
         $data[] = array('Find and Replace?' => $checkbox) + $val;
         $i++;
     }
     // data now contains the raw data needed for our table admin work;
     $entity_convert_fields = array_keys(reset($this->option_info));
     $ta = new TableAdmin();
     $ta->init_from_array($data);
     $ta->set_fields_that_allow_sorting(array());
     $ta->set_fields_to_entity_convert(array());
     // we are using html in our fields
     ob_start();
     $ta->run();
     $str = ob_get_contents();
     ob_end_clean();
     return $str;
 }
// lets add page_types that do not exist
$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)
{
<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::get('/', function () {
    return Redirect::to('/crud/classes');
});
TableAdmin::route(['classes', 'nationalities', 'riders']);
 /**
  * The way this is setup filename_frag and filename_real are not set for any admin view of a custom form ...
  */
 function init_admin_view()
 {
     $tt = new TableAdmin();
     $af =& $this->get_admin_form();
     $cf =& $this->get_custom_form();
     $db_conn = $af->get_db_conn() != '' ? $af->get_db_conn() : $cf->get_db_conn();
     $table_name = $af->get_table_name() != '' ? $af->get_table_name() : $cf->get_table_name();
     $tt->set_admin_form($af);
     $tt->set_privileges_from_admin_form();
     $tt->init($db_conn, $table_name);
     $this->set_table_admin($tt);
 }