/**
  * Display a searchable/sortable listing of documents
  */
 function viewListing()
 {
     global $modx;
     $this_page = $this->current . '?a=' . $this->a . '&id=' . $this->id;
     $tplparams = array();
     $parentId = isset($_GET['content_id']) ? intval($_GET['content_id']) : $this->config['docId'];
     // Get search filter values
     $filter = '';
     if (isset($_GET['query'])) {
         $search = $modx->db->escape($modx->stripTags($_GET['query']));
         $filter .= "WHERE (";
         $filter .= "c.pagetitle LIKE '%" . $search . "%' OR ";
         $filter .= "c.longtitle LIKE '%" . $search . "%' OR ";
         $filter .= "c.description LIKE '%" . $search . "%' OR ";
         $filter .= "c.introtext LIKE '%" . $search . "%' OR ";
         $filter .= "c.content LIKE '%" . $search . "%' OR ";
         $filter .= "c.alias LIKE '%" . $search . "%'";
         $filter .= ")";
         $header = $this->header($this->lang['search_results']);
     } else {
         $filter = "WHERE c.parent = '" . $parentId . "'";
         $header = $this->header();
     }
     $_GET['orderby'] = isset($_GET['orderby']) ? $_GET['orderby'] : 'c.menuindex';
     $_GET['orderdir'] = isset($_GET['orderdir']) ? $_GET['orderdir'] : 'ASC';
     // Check for number of records per page preferences and define global setting
     if (is_numeric($_GET['pageSize'])) {
         setcookie("pageSize", $_GET['pageSize'], time() + 3600000);
         $maxPageSize = $_GET['pageSize'];
     } else {
         if (is_numeric($_COOKIE['pageSize'])) {
             $maxPageSize = $_COOKIE['pageSize'];
         } else {
             $maxPageSize = 100;
         }
     }
     define('MAX_DISPLAY_RECORDS_NUM', $maxPageSize);
     $table = new MakeTable();
     // Instantiate a new instance of the MakeTable class
     // Get document count
     $query = "SELECT COUNT(c.id) FROM " . $modx->getFullTableName('site_content') . " AS c " . $filter;
     $numRecords = $modx->db->getValue($query);
     // Execute the main table query with MakeTable sorting and paging features
     $query = "SELECT c.id, c.pagetitle, c.longtitle, c.editedon, c.isfolder, COUNT(g.id) as photos FROM " . $modx->getFullTableName('site_content') . " AS c " . "LEFT JOIN " . $modx->getFullTableName($this->galleriesTable) . " AS g ON g.content_id = c.id " . $filter . " GROUP BY c.id" . $table->handleSorting() . $table->handlePaging();
     if ($ds = $modx->db->query($query)) {
         // If the query was successful, build our table array from the rows
         while ($row = $modx->db->getRow($ds)) {
             $documents[] = array('pagetitle' => '<a href="' . $this_page . '&action=view&content_id=' . $row['id'] . '" title="' . $this->lang['click_view_photos'] . '">' . $row['pagetitle'] . ' (' . $row['id'] . ')</a>', 'longtitle' => $row['longtitle'] != '' ? stripslashes($row['longtitle']) : '-', 'photos' => $row['photos'], 'editedon' => $row['editedon'] > 0 ? strftime('%m-%d-%Y', $row['editedon']) : '-');
         }
     }
     if (is_array($documents)) {
         // Create the table header definition with each header providing a link to sort by that field
         $documentTableHeader = array('pagetitle' => $table->prepareOrderByLink('c.pagetitle', $this->lang['title']), 'longtitle' => $table->prepareOrderByLink('c.longtitle', $this->lang['long_title']), 'photos' => $table->prepareOrderByLink('photos', $this->lang['N_photos']), 'editedon' => $table->prepareOrderByLink('c.editedon', $this->lang['last_edited']));
         $table->setActionFieldName('id');
         // Field passed in link urls
         // Table styling options
         $table->setTableClass('documentsTable');
         $table->setRowHeaderClass('headerRow');
         $table->setRowRegularClass('stdRow');
         $table->setRowAlternateClass('altRow');
         // Generate the paging navigation controls
         if ($numRecords > MAX_DISPLAY_RECORDS_NUM) {
             $table->createPagingNavigation($numRecords);
         }
         $table_html = $table->create($documents, $documentTableHeader);
         // Generate documents table
         $table_html = str_replace('[~~]?', $this_page . '&action=view&', $table_html);
         // Create page target
     } elseif (isset($_GET['query'])) {
         $table_html = '<p>' . $this->lang['no_docs_found'] . '</p>';
         // No records were found
     } else {
         $table_html = '<p class="first">' . $this->lang['no_children'] . '</p>';
     }
     $tplparams['table'] = $table_html;
     if (isset($_GET['query'])) {
         $tplparams['gallery'] = '';
     } else {
         $tplparams['gallery'] = $this->viewGallery();
     }
     $tpl = $this->processTemplate($this->listingTemplate, $tplparams);
     return $header . $tpl;
 }
 function get_backtrace($backtrace)
 {
     include_once 'extenders/maketable.class.php';
     $MakeTable = new MakeTable();
     $MakeTable->setTableClass('grid');
     $MakeTable->setRowRegularClass('gridItem');
     $MakeTable->setRowAlternateClass('gridAltItem');
     $table = array();
     $backtrace = array_reverse($backtrace);
     foreach ($backtrace as $key => $val) {
         $key++;
         if (substr($val['function'], 0, 11) === 'messageQuit') {
             break;
         } elseif (substr($val['function'], 0, 8) === 'phpError') {
             break;
         }
         $path = str_replace('\\', '/', $val['file']);
         if (strpos($path, MODX_BASE_PATH) === 0) {
             $path = substr($path, strlen(MODX_BASE_PATH));
         }
         switch ($val['type']) {
             case '->':
             case '::':
                 $functionName = $val['function'] = $val['class'] . $val['type'] . $val['function'];
                 break;
             default:
                 $functionName = $val['function'];
         }
         $tmp = 1;
         $args = array_pad(array(), count($val['args']), '$var');
         $args = implode(", ", $args);
         $modx = $this;
         $args = preg_replace_callback('/\\$var/', function () use($modx, &$tmp, $val) {
             $arg = $val['args'][$tmp - 1];
             switch (true) {
                 case is_null($arg):
                     $out = 'NULL';
                     break;
                 case is_numeric($arg):
                     $out = $arg;
                     break;
                 case is_scalar($arg):
                     $out = strlen($arg) > 20 ? 'string $var' . $tmp : "'" . $modx->htmlspecialchars(str_replace("'", "\\'", $arg)) . "'";
                     break;
                 case is_bool($arg):
                     $out = $arg ? 'TRUE' : 'FALSE';
                     break;
                 case is_array($arg):
                     $out = 'array $var' . $tmp;
                     break;
                 case is_object($arg):
                     $out = get_class($arg) . ' $var' . $tmp;
                     break;
                 default:
                     $out = '$var' . $tmp;
             }
             $tmp++;
             return $out;
         }, $args);
         $line = array("<strong>" . $functionName . "</strong>(" . $args . ")", $path . " on line " . $val['line']);
         $table[] = array(implode("<br />", $line));
     }
     return $MakeTable->create($table, array('Backtrace'));
 }
Example #3
0
<?php

require 'includes/header.php';
require 'classes/Autoloader.php';
?>

<h1 id="schoolH1">School Records</h1> <br><br>
<div id="schoolRecords">
<?php 
$fileName = 'schoolData.csv';
$mode = 'r';
$dictionary = new FileRead();
$dictionaryNames = $dictionary->fileRead('hd2013/varlist.csv', $mode);
$csvFile = new FileRead();
$records = $csvFile->fileRead($fileName, $mode, TRUE);
if (empty($_GET)) {
    echo MakeLinks::linkMaker($records, 'university', 'INSTNM');
} else {
    echo MakeTable::tableMaker($records[$_GET['university']]);
}
?>
</div>
<div id="recordResult">
	<h1>Select a School</h1>
</div>
<?php 
require 'includes/footer.php';