public function __viewIndex()
 {
     $this->setPageType('table');
     $this->setTitle(__('%1$s – %2$s', array(__('Utilities'), __('Symphony'))));
     $this->appendSubheading(__('Utilities'), Widget::Anchor(__('Create New'), SYMPHONY_URL . '/blueprints/utilities/new/', __('Create a new utility'), 'create button'));
     $utilities = General::listStructure(UTILITIES, array('xsl'), false, 'asc', UTILITIES);
     $utilities = $utilities['filelist'];
     $aTableHead = array(array(__('Name'), 'col'));
     $aTableBody = array();
     if (!is_array($utilities) || empty($utilities)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd'));
     } else {
         foreach ($utilities as $u) {
             $name = Widget::TableData(Widget::Anchor($u, SYMPHONY_URL . '/blueprints/utilities/edit/' . str_replace('.xsl', '', $u) . '/'));
             $name->appendChild(Widget::Input('items[' . $u . ']', null, 'checkbox'));
             $aTableBody[] = Widget::TableRow(array($name));
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'selectable');
     $this->Form->appendChild($table);
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm'));
     $tableActions->appendChild(Widget::Apply($options));
     $this->Form->appendChild($tableActions);
 }
 public function __viewIndex()
 {
     $this->setPageType('table');
     $this->setTitle(__('%1$s – %2$s', array(__('Sections'), __('Symphony'))));
     $this->appendSubheading(__('Sections'), Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . 'new/', __('Create a section'), 'create button', NULL, array('accesskey' => 'c')));
     $sections = SectionManager::fetch(NULL, 'ASC', 'sortorder');
     $aTableHead = array(array(__('Name'), 'col'), array(__('Entries'), 'col'), array(__('Navigation Group'), 'col'));
     $aTableBody = array();
     if (!is_array($sections) || empty($sections)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd'));
     } else {
         foreach ($sections as $s) {
             $entry_count = EntryManager::fetchCount($s->get('id'));
             // Setup each cell
             $td1 = Widget::TableData(Widget::Anchor($s->get('name'), Administration::instance()->getCurrentPageURL() . 'edit/' . $s->get('id') . '/', NULL, 'content'));
             $td2 = Widget::TableData(Widget::Anchor("{$entry_count}", SYMPHONY_URL . '/publish/' . $s->get('handle') . '/'));
             $td3 = Widget::TableData($s->get('navigation_group'));
             $td3->appendChild(Widget::Input('items[' . $s->get('id') . ']', 'on', 'checkbox'));
             // Add a row to the body array, assigning each cell to the row
             $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3));
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'orderable selectable');
     $this->Form->appendChild($table);
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm', null, array('data-message' => __('Are you sure you want to delete the selected sections?'))), array('delete-entries', false, __('Delete Entries'), 'confirm', null, array('data-message' => __('Are you sure you want to delete all entries in the selected sections?'))));
     if (is_array($sections) && !empty($sections)) {
         $index = 3;
         $options[$index] = array('label' => __('Set navigation group'), 'options' => array());
         $groups = array();
         foreach ($sections as $s) {
             if (in_array($s->get('navigation_group'), $groups)) {
                 continue;
             }
             $groups[] = $s->get('navigation_group');
             $value = 'set-navigation-group-' . urlencode($s->get('navigation_group'));
             $options[$index]['options'][] = array($value, false, $s->get('navigation_group'));
         }
     }
     /**
      * Allows an extension to modify the existing options for this page's
      * With Selected menu. If the `$options` parameter is an empty array,
      * the 'With Selected' menu will not be rendered.
      *
      * @delegate AddCustomActions
      * @since Symphony 2.3.2
      * @param string $context
      * '/blueprints/sections/'
      * @param array $options
      *  An array of arrays, where each child array represents an option
      *  in the With Selected menu. Options should follow the same format
      *  expected by `Widget::__SelectBuildOption`. Passed by reference.
      */
     Symphony::ExtensionManager()->notifyMembers('AddCustomActions', '/blueprints/sections/', array('options' => &$options));
     if (!empty($options)) {
         $tableActions->appendChild(Widget::Apply($options));
         $this->Form->appendChild($tableActions);
     }
 }
 public function __viewIndex()
 {
     $this->setPageType('table');
     $this->setTitle(__('%1$s – %2$s', array(__('Symphony'), __('RestEngine Settings'))));
     $this->appendSubheading(__('RestEngine API Resources'), Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . 'new/', __('Associate a Symphony page with a REST API section'), 'create button', NULL, array('accesskey' => 'c')));
     $pageMapping = RestResourceManager::fetch();
     //$pageMapping = array();
     $TableHead = array(array(__('Page'), 'col'), array(__('Resource Base URL'), 'col'), array(__('Section'), 'col'), array(__('Unique ID Field'), 'col'), array(__('Unique ID URL Parameter'), 'col'), array(__('Format URL Parameter'), 'col'));
     $TableBody = array();
     if (!is_array($pageMapping) || empty($pageMapping)) {
         $TableBody = array(Widget::TableRow(array(Widget::TableData(__('There are currently no RestEngine API pages. Click Crete New above to add one.'), 'inactive', NULL, count($TableHead)))));
     } else {
         foreach ($pageMapping as $page) {
             $pageTd = Widget::TableData(Widget::Anchor($page->get('page_title'), Administration::instance()->getCurrentPageURL() . 'edit/' . $page->get('id') . '/', null, 'content'));
             $resourceURL = Widget::TableData(Widget::Anchor($page->get('page_uri'), $page->get('page_uri'), null));
             $sectionTd = Widget::TableData($page->get('section_name'));
             $fieldTd = Widget::TableData($page->get('field_name'));
             $uidParamTd = Widget::TableData($page->get('uid_parameter'));
             $formatParamTd = Widget::TableData($page->get('format_parameter'));
             $TableBody[] = Widget::TableRow(array($pageTd, $resourceURL, $sectionTd, $fieldTd, $uidParamTd, $formatParamTd));
         }
     }
     $table = Widget::Table(Widget::TableHead($TableHead), NULL, Widget::TableBody($TableBody), 'selectable');
     $this->Form->appendChild($table);
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = array(0 => array(null, false, __('With Selected...')), 1 => array('delete', false, __('Delete'), 'confirm'));
     $tableActions->appendChild(Widget::Apply($options));
     $this->Form->appendChild($tableActions);
 }
 public function __viewIndex()
 {
     $this->setPageType('table');
     $this->setTitle(__('%1$s – %2$s', array(__('Authors'), __('Symphony'))));
     if (Administration::instance()->Author->isDeveloper()) {
         $this->appendSubheading(__('Authors'), Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . 'new/', __('Create a new author'), 'create button', NULL, array('accesskey' => 'c')));
     } else {
         $this->appendSubheading(__('Authors'));
     }
     Sortable::initialize($this, $authors, $sort, $order);
     $columns = array(array('label' => __('Name'), 'sortable' => true, 'handle' => 'name'), array('label' => __('Email Address'), 'sortable' => true, 'handle' => 'email'), array('label' => __('Last Seen'), 'sortable' => true, 'handle' => 'last_seen'));
     if (Administration::instance()->Author->isDeveloper()) {
         $columns = array_merge($columns, array(array('label' => __('User Type'), 'sortable' => true, 'handle' => 'user_type'), array('label' => __('Language'), 'sortable' => true, 'handle' => 'language')));
     }
     $aTableHead = Sortable::buildTableHeaders($columns, $sort, $order, isset($_REQUEST['filter']) ? '&filter=' . $_REQUEST['filter'] : '');
     $aTableBody = array();
     if (!is_array($authors) || empty($authors)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd'));
     } else {
         foreach ($authors as $a) {
             // Setup each cell
             if (Administration::instance()->Author->isDeveloper() || Administration::instance()->Author->get('id') == $a->get('id')) {
                 $td1 = Widget::TableData(Widget::Anchor($a->getFullName(), Administration::instance()->getCurrentPageURL() . 'edit/' . $a->get('id') . '/', $a->get('username'), 'author'));
             } else {
                 $td1 = Widget::TableData($a->getFullName(), 'inactive');
             }
             $td2 = Widget::TableData(Widget::Anchor($a->get('email'), 'mailto:' . $a->get('email'), __('Email this author')));
             if (!is_null($a->get('last_seen'))) {
                 $td3 = Widget::TableData(DateTimeObj::format($a->get('last_seen'), __SYM_DATETIME_FORMAT__));
             } else {
                 $td3 = Widget::TableData(__('Unknown'), 'inactive');
             }
             $td4 = Widget::TableData($a->isDeveloper() ? __("Developer") : __("Author"));
             $languages = Lang::getAvailableLanguages();
             $td5 = Widget::TableData($a->get("language") == NULL ? __("System Default") : $languages[$a->get("language")]);
             if (Administration::instance()->Author->isDeveloper()) {
                 if ($a->get('id') != Administration::instance()->Author->get('id')) {
                     $td3->appendChild(Widget::Input('items[' . $a->get('id') . ']', NULL, 'checkbox'));
                 }
             }
             // Add a row to the body array, assigning each cell to the row
             if (Administration::instance()->Author->isDeveloper()) {
                 $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3, $td4, $td5));
             } else {
                 $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3));
             }
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'selectable');
     $this->Form->appendChild($table);
     if (Administration::instance()->Author->isDeveloper()) {
         $tableActions = new XMLElement('div');
         $tableActions->setAttribute('class', 'actions');
         $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm', null, array('data-message' => __('Are you sure you want to delete the selected authors?'))));
         $tableActions->appendChild(Widget::Apply($options));
         $this->Form->appendChild($tableActions);
     }
 }
 /**
  * Utility method that generates the 'action' panel
  */
 public static function buildActions($hasData, array $additionalActions = null)
 {
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     if ($hasData == true) {
         $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm'));
         if ($additionalActions != null) {
             array_push($options, $additionalActions);
         }
         $tableActions->appendChild(Widget::Apply($options));
     }
     return $tableActions;
 }
 public function view()
 {
     parent::view(FALSE);
     if (isset($this->mode)) {
         $section = $this->mode;
         header('Content-Type: application/json');
         echo file_get_contents(WORKSPACE . '/elasticsearch/mappings/' . $section . '.json');
         die;
     }
     $this->addScriptToHead(URL . '/extensions/elasticsearch/assets/elasticsearch.mappings.js', 101);
     $this->addStylesheetToHead(URL . '/extensions/elasticsearch/assets/elasticsearch.mappings.css', 'screen', 102);
     $this->setPageType('table');
     $this->setTitle(__('Symphony') . ' – ' . __('ElasticSearch') . ' – ' . __('Mappings'));
     $this->appendSubheading(__('Mappings'));
     $types = ElasticSearch::getAllTypes();
     $tableHead = array();
     $tableBody = array();
     $tableHead[] = array(__('Section'), 'col');
     $tableHead[] = array(__('Mapped Fields'), 'col');
     $tableHead[] = array(__('Mapping JSON'), 'col');
     $tableHead[] = array(__('Entries'), 'col');
     if (!is_array($types) or empty($types)) {
         $tableBody = array(Widget::TableRow(array(Widget::TableData(__('None Found.'), 'inactive', null, count($tableHead)))));
     } else {
         foreach ($types as $type) {
             $col_name = Widget::TableData($type->section->get('name'));
             $col_name->appendChild(Widget::Input('items[' . $type->section->get('handle') . ']', NULL, 'checkbox'));
             $col_fields = Widget::TableData(implode(', ', $type->fields));
             $col_json = Widget::TableData(sprintf('<a href="%s">%s.json</a>', $type->section->get('handle'), $type->section->get('handle')));
             if ($type->type) {
                 $count = $type->type->count();
                 $col_count = Widget::TableData('<span id="reindex-' . $type->section->get('handle') . '">' . (string) $count . ' ' . ($count == 1 ? 'entry' : 'entries') . '</span>', $count_class . ' count-column');
             } else {
                 $col_count = Widget::TableData('Rebuild mapping before continuing', $count_class . ' count-column inactive');
             }
             $attributes = array('data-handle' => $type->section->get('handle'));
             if (in_array($type->section->get('handle'), $this->reindex) && $type->type) {
                 $attributes['data-reindex'] = 'yes';
             }
             $tableBody[] = Widget::TableRow(array($col_name, $col_fields, $col_json, $col_count), NULL, NULL, NULL, $attributes);
         }
     }
     $table = Widget::Table(Widget::TableHead($tableHead), null, Widget::TableBody($tableBody), 'selectable');
     $this->Form->appendChild($table);
     $actions = new XMLElement('div');
     $actions->setAttribute('class', 'actions');
     $options = array(array(null, false, __('With Selected...')), array('reindex', false, __('Reindex Entries')), array('rebuild', false, __('Rebuild Mapping')), array('delete', false, __('Delete Mapping')));
     $actions->appendChild(Widget::Apply($options));
     $this->Form->appendChild($actions);
 }
Exemple #7
0
 public function view()
 {
     $this->setPageType('table');
     $this->setTitle('Symphony &ndash; Cron');
     $this->appendSubheading('Cron Tasks', [Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . 'new/', __('Create a cron task'), 'create button', null, ['accesskey' => 'c'])]);
     Extension_Cron::init();
     $iterator = new Lib\CronTaskIterator(realpath(MANIFEST . '/cron'), Symphony::Database());
     $aTableHead = [['Name', 'col'], ['Description', 'col'], ['Enabled', 'col'], ['Last Executed', 'col'], ['Next Execution', 'col'], ['Last Output', 'col']];
     $aTableBody = [];
     if ($iterator->count() == 0) {
         $aTableBody = [Widget::TableRow([Widget::TableData(__('None found.'), 'inactive', null, count($aTableHead))], 'odd')];
     } else {
         foreach ($iterator as $ii => $task) {
             $td1 = Widget::TableData(Widget::Anchor($task->name, sprintf('%sedit/%s/', Administration::instance()->getCurrentPageURL(), $task->filename)));
             $td1->appendChild(Widget::Label(__('Select Task %s', [$task->filename]), null, 'accessible', null, array('for' => 'task-' . $ii)));
             $td1->appendChild(Widget::Input('items[' . $task->filename . ']', 'on', 'checkbox', array('id' => 'task-' . $ii)));
             $td2 = Widget::TableData(is_null($task->description) ? 'None' : $task->description);
             if (is_null($task->description)) {
                 $td2->setAttribute('class', 'inactive');
             }
             $td3 = Widget::TableData($task->enabledReal() == true ? 'Yes' : 'No');
             if ($task->enabled == false) {
                 $td3->setAttribute('class', 'inactive');
             }
             $td4 = Widget::TableData(!is_null($task->getLastExecutionTimestamp()) ? DateTimeObj::get(__SYM_DATETIME_FORMAT__, $task->getLastExecutionTimestamp()) : 'Unknown');
             if (is_null($task->getLastExecutionTimestamp())) {
                 $td4->setAttribute('class', 'inactive');
             }
             $td5 = Widget::TableData(!is_null($task->nextExecution()) ? self::__minutesToHumanReadable(ceil($task->nextExecution() * (1 / 60))) : 'Unknown');
             if (is_null($task->nextExecution()) || $task->enabledReal() == false) {
                 $td5->setAttribute('class', 'inactive');
             }
             if (is_null($task->getLog())) {
                 $td6 = Widget::TableData('None', 'inactive');
             } else {
                 $td6 = Widget::TableData(Widget::Anchor('view', sprintf('%slog/%s/', Administration::instance()->getCurrentPageURL(), $task->filename)));
             }
             $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3, $td4, $td5, $td6));
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), null, Widget::TableBody($aTableBody), 'selectable', null, array('role' => 'directory', 'aria-labelledby' => 'symphony-subheading', 'data-interactive' => 'data-interactive'));
     $this->Form->appendChild($table);
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = [[null, false, __('With Selected...')], ['enable', false, __('Enable')], ['disable', false, __('Disable')], ['delete', false, __('Delete'), 'confirm', null, ['data-message' => __('Are you sure you want to delete the selected tasks?')]]];
     $tableActions->appendChild(Widget::Apply($options));
     $this->Form->appendChild($tableActions);
 }
 public function __viewIndex()
 {
     $this->setPageType('table');
     $this->setTitle(__('%1$s &ndash; %2$s', array(__('Sections'), __('Symphony'))));
     $this->appendSubheading(__('Sections'), Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . 'new/', __('Create a section'), 'create button', NULL, array('accesskey' => 'c')));
     $sections = SectionManager::fetch(NULL, 'ASC', 'sortorder');
     $aTableHead = array(array(__('Name'), 'col'), array(__('Entries'), 'col'), array(__('Navigation Group'), 'col'));
     $aTableBody = array();
     if (!is_array($sections) || empty($sections)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd'));
     } else {
         foreach ($sections as $s) {
             $entry_count = EntryManager::fetchCount($s->get('id'));
             // Setup each cell
             $td1 = Widget::TableData(Widget::Anchor($s->get('name'), Administration::instance()->getCurrentPageURL() . 'edit/' . $s->get('id') . '/', NULL, 'content'));
             $td2 = Widget::TableData(Widget::Anchor("{$entry_count}", SYMPHONY_URL . '/publish/' . $s->get('handle') . '/'));
             $td3 = Widget::TableData($s->get('navigation_group'));
             $td3->appendChild(Widget::Input('items[' . $s->get('id') . ']', 'on', 'checkbox'));
             // Add a row to the body array, assigning each cell to the row
             $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3));
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'orderable selectable');
     $this->Form->appendChild($table);
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm', null, array('data-message' => __('Are you sure you want to delete the selected sections?'))), array('delete-entries', false, __('Delete Entries'), 'confirm', null, array('data-message' => __('Are you sure you want to delete all entries in the selected sections?'))));
     if (is_array($sections) && !empty($sections)) {
         $index = 3;
         $options[$index] = array('label' => __('Set navigation group'), 'options' => array());
         $groups = array();
         foreach ($sections as $s) {
             if (in_array($s->get('navigation_group'), $groups)) {
                 continue;
             }
             $groups[] = $s->get('navigation_group');
             $value = 'set-navigation-group-' . urlencode($s->get('navigation_group'));
             $options[$index]['options'][] = array($value, false, $s->get('navigation_group'));
         }
     }
     $tableActions->appendChild(Widget::Apply($options));
     $this->Form->appendChild($tableActions);
 }
 public function __viewIndex()
 {
     // Set the page to display as a table:
     $this->setPageType('table');
     $this->appendSubheading(__('Author Roles'), Widget::Anchor(__('Create New'), $this->_uri . 'roles/new/', __('Create a new role'), 'create button'));
     // Set the table head:
     $tableHead = array(array(__('Role Name'), 'col'), array(__('Authors with this role'), 'col'));
     // Set the table body:
     $tableBody = array();
     // Fill the table with available roles:
     $roles = $this->_driver->getRoles();
     if (empty($roles)) {
         // No roles found, create an empty row:
         $tableBody = array(Widget::TableRow(array(Widget::TableData(__('None Found.'), 'inactive', null, count($tableHead)))));
     } else {
         foreach ($roles as $role) {
             $row = new XMLElement('tr');
             $td = new XMLElement('td', '<a href="' . $this->_url . 'roles/edit/' . $role['id'] . '/">' . $role['name'] . '</a>');
             $td->appendChild(Widget::Input('items[' . $role['id'] . ']', NULL, 'checkbox'));
             $row->appendChild($td);
             // Authors:
             $authors = $this->_driver->getAuthors($role['id']);
             if (empty($authors)) {
                 $row->appendChild(new XMLElement('td', '<em>none</em>'));
             } else {
                 $links = array();
                 foreach ($authors as $author) {
                     $links[] = '<a href="' . URL . '/symphony/system/authors/edit/' . $author['id'] . '/">' . $author['first_name'] . ' ' . $author['last_name'] . '</a>';
                 }
                 $row->appendChild(new XMLElement('td', implode(', ', $links)));
             }
             $tableBody[] = $row;
         }
     }
     // Create the table element:
     $table = Widget::Table(Widget::TableHead($tableHead), null, Widget::TableBody($tableBody), 'selectable');
     $this->Form->appendChild($table);
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = array(array(null, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm', null, array('data-message' => __('Are you sure you want to delete the selected roles?'))));
     $tableActions->appendChild(Widget::Apply($options));
     $this->Form->appendChild($tableActions);
 }
 public function view()
 {
     // Start building the page
     $this->setPageType('table');
     $this->setTitle(__('%1$s &ndash; %2$s', array(__('Symphony'), __('Documentation'))));
     $this->appendSubheading(__('Documentation'), Widget::Anchor(__('Create New'), URL . '/symphony/extension/documenter/new/', __('Create a new documentation item'), 'create button'));
     // Grab all the documentation items
     $docs = Symphony::Database()->fetch("\n\t\t\t\tSELECT\n\t\t\t\t\td.*\n\t\t\t\tFROM\n\t\t\t\t\t`tbl_documentation` AS d\n\t\t\t\tORDER BY\n\t\t\t\t\td.pages ASC\n\t\t\t");
     // Build the table
     $thead = array(array(__('Title'), 'col'), array(__('Pages'), 'col'));
     $tbody = array();
     // If there are no records, display default message
     if (!is_array($docs) or empty($docs)) {
         $tbody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', null, count($thead))), 'odd'));
     } else {
         $bOdd = true;
         foreach ($docs as $doc) {
             $doc_edit_url = URL . '/symphony/extension/documenter/edit/' . $doc['id'] . '/';
             $col_title = Widget::TableData(Widget::Anchor($doc['title'], $doc_edit_url));
             $col_title->appendChild(Widget::Input("items[{$doc['id']}]", null, 'checkbox'));
             $pages = $doc['pages'];
             $pages = explode(',', $pages);
             $pages = join(', ', $pages);
             $col_pages = Widget::TableData($pages);
             $tbody[] = Widget::TableRow(array($col_title, $col_pages), $bOdd ? 'odd' : NULL);
             $bOdd = !$bOdd;
         }
     }
     $table = Widget::Table(Widget::TableHead($thead), null, Widget::TableBody($tbody), null);
     $table->setAttribute('class', 'selectable');
     $this->Form->appendChild($table);
     $actions = new XMLElement('div');
     $actions->setAttribute('class', 'actions');
     $options = array(array(null, false, __('With Selected...')), array('delete', false, __('Delete')));
     $actions->appendChild(Widget::Apply($options));
     $this->Form->appendChild($actions);
 }
 public function view()
 {
     $this->setPageType('table');
     $this->setTitle(__('%1$s &ndash; %2$s', array(__('Templated Text Formatters'), __('Symphony'))));
     $this->appendSubheading(__('Templated Text Formatters'), Widget::Anchor(__('Create New'), URL . '/symphony/extension/templatedtextformatters/edit/', __('Create a new formatter'), 'create button', NULL, array('accesskey' => 'c')));
     $aTableHead = array(array(__('Name'), 'col'), array(__('Type'), 'col'), array(__('Description'), 'col'));
     $aTableBody = array();
     $formatters = $this->_driver->listAll();
     if (!is_array($formatters) || empty($formatters)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd'));
     } else {
         foreach ($formatters as $id => $data) {
             $formatter = TextformatterManager::create($id);
             $about = $formatter->about();
             $td1 = Widget::TableData(Widget::Anchor($about['name'], URL . "/symphony/extension/templatedtextformatters/edit/{$id}/", $about['name']));
             $td2 = Widget::TableData($about['templatedtextformatters-type']);
             $td3 = Widget::TableData(General::sanitize($about['description']));
             $td1->appendChild(Widget::Label(__('Select Text Formatter %s', array($about['name'])), null, 'accessible', null, array('for' => 'ttf-' . $id)));
             $td1->appendChild(Widget::Input('items[' . $id . ']', 'on', 'checkbox', array('id' => 'ttf-' . $id)));
             // Add a row to the body array, assigning each cell to the row
             $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3));
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'selectable', null, array('role' => 'directory', 'aria-labelledby' => 'symphony-subheading', 'data-interactive' => 'data-interactive'));
     $this->Form->appendChild($table);
     $version = new XMLElement('p', 'Symphony ' . Symphony::Configuration()->get('version', 'symphony'), array('id' => 'version'));
     $this->Form->appendChild($version);
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm', null, array('data-message' => __('Are you sure you want to delete the selected text formatters?'))));
     Symphony::ExtensionManager()->notifyMembers('AddCustomActions', '/templatedtextformatters/', array('options' => &$options));
     if (!empty($options)) {
         $div->appendChild(Widget::Apply($options));
         $this->Form->appendChild($div);
     }
 }
 /**
  * This function contains the minimal amount of logic for generating the
  * index table of a given `$resource_type`. The table has name, source, pages
  * release date and author columns. The values for these columns are determined
  * by the resource's `about()` method.
  *
  * As Datasources types can be installed using Providers, the Source column
  * can be overridden with a Datasource's `getSourceColumn` method (if it exists).
  *
  * @param integer $resource_type
  *  Either `RESOURCE_TYPE_EVENT` or `RESOURCE_TYPE_DATASOURCE`
  */
 public function __viewIndex($resource_type)
 {
     $manager = ResourceManager::getManagerFromType($resource_type);
     $this->setPageType('table');
     Sortable::initialize($this, $resources, $sort, $order, array('type' => $resource_type));
     $columns = array(array('label' => __('Name'), 'sortable' => true, 'handle' => 'name'), array('label' => __('Source'), 'sortable' => true, 'handle' => 'source'), array('label' => __('Pages'), 'sortable' => false), array('label' => __('Release Date'), 'sortable' => true, 'handle' => 'release-date'), array('label' => __('Author'), 'sortable' => true, 'handle' => 'author'));
     $aTableHead = Sortable::buildTableHeaders($columns, $sort, $order, isset($_REQUEST['filter']) ? '&amp;filter=' . $_REQUEST['filter'] : '');
     $aTableBody = array();
     if (!is_array($resources) || empty($resources)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd'));
     } else {
         foreach ($resources as $r) {
             // Resource name
             $action = isset($r['can_parse']) && $r['can_parse'] === true ? 'edit' : 'info';
             $name = Widget::TableData(Widget::Anchor($r['name'], SYMPHONY_URL . $_REQUEST['symphony-page'] . $action . '/' . $r['handle'] . '/', $r['handle']));
             // Resource type/source
             if (isset($r['source'], $r['source']['id'])) {
                 $section = Widget::TableData(Widget::Anchor($r['source']['name'], SYMPHONY_URL . '/blueprints/sections/edit/' . $r['source']['id'] . '/', $r['source']['handle']));
             } else {
                 if (isset($r['source']) && class_exists($r['source']['name']) && method_exists($r['source']['name'], 'getSourceColumn')) {
                     $class = call_user_func(array($manager, '__getClassName'), $r['handle']);
                     $section = Widget::TableData(call_user_func(array($class, 'getSourceColumn'), $r['handle']));
                 } else {
                     if (isset($r['source'], $r['source']['name'])) {
                         $section = Widget::TableData($r['source']['name']);
                     } else {
                         $section = Widget::TableData(__('Unknown'), 'inactive');
                     }
                 }
             }
             // Attached pages
             $pages = ResourceManager::getAttachedPages($resource_type, $r['handle']);
             $pagelinks = array();
             $i = 0;
             foreach ($pages as $p) {
                 ++$i;
                 $pagelinks[] = Widget::Anchor($p['title'], SYMPHONY_URL . '/blueprints/pages/edit/' . $p['id'] . '/')->generate() . (count($pages) > $i ? $i % 10 == 0 ? '<br />' : ', ' : '');
             }
             $pages = implode('', $pagelinks);
             if ($pages == '') {
                 $pagelinks = Widget::TableData(__('None'), 'inactive');
             } else {
                 $pagelinks = Widget::TableData($pages, 'pages');
             }
             // Release date
             $releasedate = Widget::TableData(Lang::localizeDate(DateTimeObj::format($r['release-date'], __SYM_DATETIME_FORMAT__)));
             // Authors
             $author = $r['author']['name'];
             if ($author) {
                 if (isset($r['author']['website'])) {
                     $author = Widget::Anchor($r['author']['name'], General::validateURL($r['author']['website']));
                 } else {
                     if (isset($r['author']['email'])) {
                         $author = Widget::Anchor($r['author']['name'], 'mailto:' . $r['author']['email']);
                     }
                 }
             }
             $author = Widget::TableData($author);
             $author->appendChild(Widget::Input('items[' . $r['handle'] . ']', null, 'checkbox'));
             $aTableBody[] = Widget::TableRow(array($name, $section, $pagelinks, $releasedate, $author));
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'selectable');
     $this->Form->appendChild($table);
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm'));
     $pages = $this->pagesFlatView();
     $group_attach = array('label' => __('Attach to Page'), 'options' => array());
     $group_detach = array('label' => __('Detach from Page'), 'options' => array());
     $group_attach['options'][] = array('attach-all-pages', false, __('All'));
     $group_detach['options'][] = array('detach-all-pages', false, __('All'));
     foreach ($pages as $p) {
         $group_attach['options'][] = array('attach-to-page-' . $p['id'], false, $p['title']);
         $group_detach['options'][] = array('detach-from-page-' . $p['id'], false, $p['title']);
     }
     $options[] = $group_attach;
     $options[] = $group_detach;
     /**
      * Allows an extension to modify the existing options for this page's
      * With Selected menu. If the `$options` parameter is an empty array,
      * the 'With Selected' menu will not be rendered.
      *
      * @delegate AddCustomActions
      * @since Symphony 2.3.2
      * @param string $context
      * '/blueprints/datasources/' or '/blueprints/events/'
      * @param array $options
      *  An array of arrays, where each child array represents an option
      *  in the With Selected menu. Options should follow the same format
      *  expected by `Widget::__SelectBuildOption`. Passed by reference.
      */
     Symphony::ExtensionManager()->notifyMembers('AddCustomActions', $_REQUEST['symphony-page'], array('options' => &$options));
     if (!empty($options)) {
         $tableActions->appendChild(Widget::Apply($options));
         $this->Form->appendChild($tableActions);
     }
 }
 public function __viewIndex()
 {
     if (!($section_id = SectionManager::fetchIDFromHandle($this->_context['section_handle']))) {
         Administration::instance()->throwCustomError(__('The Section, %s, could not be found.', array('<code>' . $this->_context['section_handle'] . '</code>')), __('Unknown Section'), Page::HTTP_STATUS_NOT_FOUND);
     } else {
         if (!is_writable(CONFIG)) {
             $this->pageAlert(__('The Symphony configuration file, %s, is not writable. The sort order cannot be modified.', array('<code>/manifest/config.php</code>')), Alert::NOTICE);
         }
     }
     $section = SectionManager::fetch($section_id);
     $this->setPageType('table');
     $this->setTitle(__('%1$s &ndash; %2$s', array($section->get('name'), __('Symphony'))));
     $filters = array();
     $filter_querystring = $prepopulate_querystring = $where = $joins = null;
     $current_page = isset($_REQUEST['pg']) && is_numeric($_REQUEST['pg']) ? max(1, intval($_REQUEST['pg'])) : 1;
     if (isset($_REQUEST['filter'])) {
         // legacy implementation, convert single filter to an array
         // split string in the form ?filter=handle:value
         if (!is_array($_REQUEST['filter'])) {
             list($field_handle, $filter_value) = explode(':', $_REQUEST['filter'], 2);
             $filters[$field_handle] = rawurldecode($filter_value);
         } else {
             $filters = $_REQUEST['filter'];
         }
         foreach ($filters as $handle => $value) {
             // Handle multiple values through filtering. RE: #2290
             if (is_array($value) && empty($value) || trim($value) == '') {
                 continue;
             }
             if (!is_array($value)) {
                 $filter_type = Datasource::determineFilterType($value);
                 $value = preg_split('/' . ($filter_type == Datasource::FILTER_AND ? '\\+' : '(?<!\\\\),') . '\\s*/', $value, -1, PREG_SPLIT_NO_EMPTY);
                 $value = array_map('trim', $value);
                 $value = array_map(array('Datasource', 'removeEscapedCommas'), $value);
             }
             // Handle date meta data #2003
             $handle = Symphony::Database()->cleanValue($handle);
             if (in_array($handle, array('system:creation-date', 'system:modification-date'))) {
                 $date_joins = '';
                 $date_where = '';
                 $date = new FieldDate();
                 $date->buildDSRetrievalSQL($value, $date_joins, $date_where, $filter_type == Datasource::FILTER_AND ? true : false);
                 // Replace the date field where with the `creation_date` or `modification_date`.
                 $date_where = preg_replace('/`t\\d+`.date/', $field_id !== 'system:modification-date' ? '`e`.creation_date_gmt' : '`e`.modification_date_gmt', $date_where);
                 $where .= $date_where;
             } else {
                 // Handle normal fields
                 $field_id = FieldManager::fetchFieldIDFromElementName($handle, $section->get('id'));
                 $field = FieldManager::fetch($field_id);
                 if ($field instanceof Field) {
                     $field->buildDSRetrievalSQL($value, $joins, $where, $filter_type == Datasource::FILTER_AND ? true : false);
                     $value = implode(',', $value);
                     $encoded_value = rawurlencode($value);
                     $filter_querystring .= sprintf("filter[%s]=%s&amp;", $handle, $encoded_value);
                     // Some fields require that prepopulation be done via ID. RE: #2331
                     if (!is_numeric($value) && method_exists($field, 'fetchIDfromValue')) {
                         $encoded_value = $field->fetchIDfromValue($value);
                     }
                     $prepopulate_querystring .= sprintf("prepopulate[%d]=%s&amp;", $field_id, $encoded_value);
                 } else {
                     unset($filters[$handle]);
                 }
             }
         }
         $filter_querystring = preg_replace("/&amp;\$/", '', $filter_querystring);
         $prepopulate_querystring = preg_replace("/&amp;\$/", '', $prepopulate_querystring);
     }
     Sortable::initialize($this, $entries, $sort, $order, array('current-section' => $section, 'filters' => $filter_querystring ? "&amp;" . $filter_querystring : '', 'unsort' => isset($_REQUEST['unsort'])));
     $this->Form->setAttribute('action', Administration::instance()->getCurrentPageURL() . '?pg=' . $current_page . ($filter_querystring ? "&amp;" . $filter_querystring : ''));
     // Build filtering interface
     $this->createFilteringInterface();
     $subheading_buttons = array(Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . 'new/' . ($prepopulate_querystring ? '?' . $prepopulate_querystring : ''), __('Create a new entry'), 'create button', null, array('accesskey' => 'c')));
     // Only show the Edit Section button if the Author is a developer. #938 ^BA
     if (Symphony::Author()->isDeveloper()) {
         array_unshift($subheading_buttons, Widget::Anchor(__('Edit Section'), SYMPHONY_URL . '/blueprints/sections/edit/' . $section_id . '/', __('Edit Section Configuration'), 'button'));
     }
     $this->appendSubheading($section->get('name'), $subheading_buttons);
     /**
      * Allows adjustments to be made to the SQL where and joins statements
      * before they are used to fetch the entries for the page
      *
      * @delegate AdjustPublishFiltering
      * @since Symphony 2.3.3
      * @param string $context
      * '/publish/'
      * @param integer $section_id
      * An array of the current columns, passed by reference
      * @param string $where
      * The current where statement, or null if not set
      * @param string $joins
      */
     Symphony::ExtensionManager()->notifyMembers('AdjustPublishFiltering', '/publish/', array('section-id' => $section_id, 'where' => &$where, 'joins' => &$joins));
     // Check that the filtered query fails that the filter is dropped and an
     // error is logged. #841 ^BA
     try {
         $entries = EntryManager::fetchByPage($current_page, $section_id, Symphony::Configuration()->get('pagination_maximum_rows', 'symphony'), $where, $joins, true);
     } catch (DatabaseException $ex) {
         $this->pageAlert(__('An error occurred while retrieving filtered entries. Showing all entries instead.'), Alert::ERROR);
         $filter_querystring = null;
         Symphony::Log()->pushToLog(sprintf('%s - %s%s%s', $section->get('name') . ' Publish Index', $ex->getMessage(), $ex->getFile() ? " in file " . $ex->getFile() : null, $ex->getLine() ? " on line " . $ex->getLine() : null), E_NOTICE, true);
         $entries = EntryManager::fetchByPage($current_page, $section_id, Symphony::Configuration()->get('pagination_maximum_rows', 'symphony'));
     }
     // Flag filtering
     if (isset($_REQUEST['filter'])) {
         $filter_stats = new XMLElement('p', '<span>– ' . __('%d of %d entries (filtered)', array($entries['total-entries'], EntryManager::fetchCount($section_id))) . '</span>', array('class' => 'inactive'));
     } else {
         $filter_stats = new XMLElement('p', '<span>– ' . __('%d entries', array($entries['total-entries'])) . '</span>', array('class' => 'inactive'));
     }
     $this->Breadcrumbs->appendChild($filter_stats);
     // Build table
     $visible_columns = $section->fetchVisibleColumns();
     $columns = array();
     if (is_array($visible_columns) && !empty($visible_columns)) {
         foreach ($visible_columns as $column) {
             $columns[] = array('label' => $column->get('label'), 'sortable' => $column->isSortable(), 'handle' => $column->get('id'), 'attrs' => array('id' => 'field-' . $column->get('id'), 'class' => 'field-' . $column->get('type')));
         }
     } else {
         $columns[] = array('label' => __('ID'), 'sortable' => true, 'handle' => 'id');
     }
     $aTableHead = Sortable::buildTableHeaders($columns, $sort, $order, $filter_querystring ? "&amp;" . $filter_querystring : '');
     $child_sections = array();
     $associated_sections = $section->fetchChildAssociations(true);
     if (is_array($associated_sections) && !empty($associated_sections)) {
         foreach ($associated_sections as $key => $as) {
             $child_sections[$key] = SectionManager::fetch($as['child_section_id']);
             $aTableHead[] = array($child_sections[$key]->get('name'), 'col');
         }
     }
     /**
      * Allows the creation of custom table columns for each entry. Called
      * after all the Section Visible columns have been added as well
      * as the Section Associations
      *
      * @delegate AddCustomPublishColumn
      * @since Symphony 2.2
      * @param string $context
      * '/publish/'
      * @param array $tableHead
      * An array of the current columns, passed by reference
      * @param integer $section_id
      * The current Section ID
      */
     Symphony::ExtensionManager()->notifyMembers('AddCustomPublishColumn', '/publish/', array('tableHead' => &$aTableHead, 'section_id' => $section->get('id')));
     // Table Body
     $aTableBody = array();
     if (!is_array($entries['records']) || empty($entries['records'])) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', null, count($aTableHead))), 'odd'));
     } else {
         $field_pool = array();
         if (is_array($visible_columns) && !empty($visible_columns)) {
             foreach ($visible_columns as $column) {
                 $field_pool[$column->get('id')] = $column;
             }
         }
         $link_column = array_reverse($visible_columns);
         $link_column = end($link_column);
         reset($visible_columns);
         foreach ($entries['records'] as $entry) {
             $tableData = array();
             // Setup each cell
             if (!is_array($visible_columns) || empty($visible_columns)) {
                 $tableData[] = Widget::TableData(Widget::Anchor($entry->get('id'), Administration::instance()->getCurrentPageURL() . 'edit/' . $entry->get('id') . '/'));
             } else {
                 $link = Widget::Anchor('', Administration::instance()->getCurrentPageURL() . 'edit/' . $entry->get('id') . '/' . ($filter_querystring ? '?' . $prepopulate_querystring : ''), $entry->get('id'), 'content');
                 foreach ($visible_columns as $position => $column) {
                     $data = $entry->getData($column->get('id'));
                     $field = $field_pool[$column->get('id')];
                     $value = $field->prepareTableValue($data, $column == $link_column ? $link : null, $entry->get('id'));
                     if (!is_object($value) && (strlen(trim($value)) == 0 || $value == __('None'))) {
                         $value = $position == 0 ? $link->generate() : __('None');
                     }
                     if ($value == __('None')) {
                         $tableData[] = Widget::TableData($value, 'inactive field-' . $column->get('type') . ' field-' . $column->get('id'));
                     } else {
                         $tableData[] = Widget::TableData($value, 'field-' . $column->get('type') . ' field-' . $column->get('id'));
                     }
                     unset($field);
                 }
             }
             if (is_array($child_sections) && !empty($child_sections)) {
                 foreach ($child_sections as $key => $as) {
                     $field = FieldManager::fetch((int) $associated_sections[$key]['child_section_field_id']);
                     $parent_section_field_id = (int) $associated_sections[$key]['parent_section_field_id'];
                     if (!is_null($parent_section_field_id)) {
                         $search_value = $field->fetchAssociatedEntrySearchValue($entry->getData($parent_section_field_id), $parent_section_field_id, $entry->get('id'));
                     } else {
                         $search_value = $entry->get('id');
                     }
                     if (!is_array($search_value)) {
                         $associated_entry_count = $field->fetchAssociatedEntryCount($search_value);
                         $tableData[] = Widget::TableData(Widget::Anchor(sprintf('%d &rarr;', max(0, intval($associated_entry_count))), sprintf('%s/publish/%s/?filter[%s]=%s', SYMPHONY_URL, $as->get('handle'), $field->get('element_name'), rawurlencode($search_value)), $entry->get('id'), 'content'));
                     }
                 }
             }
             /**
              * Allows Extensions to inject custom table data for each Entry
              * into the Publish Index
              *
              * @delegate AddCustomPublishColumnData
              * @since Symphony 2.2
              * @param string $context
              * '/publish/'
              * @param array $tableData
              *  An array of `Widget::TableData`, passed by reference
              * @param integer $section_id
              *  The current Section ID
              * @param Entry $entry_id
              *  The entry object, please note that this is by error and this will
              *  be removed in Symphony 2.4. The entry object is available in
              *  the 'entry' key as of Symphony 2.3.1.
              * @param Entry $entry
              *  The entry object for this row
              */
             Symphony::ExtensionManager()->notifyMembers('AddCustomPublishColumnData', '/publish/', array('tableData' => &$tableData, 'section_id' => $section->get('id'), 'entry_id' => $entry, 'entry' => $entry));
             $tableData[count($tableData) - 1]->appendChild(Widget::Label(__('Select Entry %d', array($entry->get('id'))), null, 'accessible', null, array('for' => 'entry-' . $entry->get('id'))));
             $tableData[count($tableData) - 1]->appendChild(Widget::Input('items[' . $entry->get('id') . ']', null, 'checkbox', array('id' => 'entry-' . $entry->get('id'))));
             // Add a row to the body array, assigning each cell to the row
             $aTableBody[] = Widget::TableRow($tableData, null, 'id-' . $entry->get('id'));
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), null, Widget::TableBody($aTableBody), 'selectable', null, array('role' => 'directory', 'aria-labelledby' => 'symphony-subheading', 'data-interactive' => 'data-interactive'));
     $this->Form->appendChild($table);
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = array(array(null, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm', null, array('data-message' => __('Are you sure you want to delete the selected entries?'))));
     $toggable_fields = $section->fetchToggleableFields();
     if (is_array($toggable_fields) && !empty($toggable_fields)) {
         $index = 2;
         foreach ($toggable_fields as $field) {
             $toggle_states = $field->getToggleStates();
             if (is_array($toggle_states)) {
                 $options[$index] = array('label' => __('Set %s', array($field->get('label'))), 'options' => array());
                 foreach ($toggle_states as $value => $state) {
                     $options[$index]['options'][] = array('toggle-' . $field->get('id') . '-' . $value, false, $state);
                 }
             }
             $index++;
         }
     }
     /**
      * Allows an extension to modify the existing options for this page's
      * With Selected menu. If the `$options` parameter is an empty array,
      * the 'With Selected' menu will not be rendered.
      *
      * @delegate AddCustomActions
      * @since Symphony 2.3.2
      * @param string $context
      * '/publish/'
      * @param array $options
      *  An array of arrays, where each child array represents an option
      *  in the With Selected menu. Options should follow the same format
      *  expected by `Widget::__SelectBuildOption`. Passed by reference.
      */
     Symphony::ExtensionManager()->notifyMembers('AddCustomActions', '/publish/', array('options' => &$options));
     if (!empty($options)) {
         $tableActions->appendChild(Widget::Apply($options));
         $this->Form->appendChild($tableActions);
     }
     if ($entries['total-pages'] > 1) {
         $ul = new XMLElement('ul');
         $ul->setAttribute('class', 'page');
         // First
         $li = new XMLElement('li');
         if ($current_page > 1) {
             $li->appendChild(Widget::Anchor(__('First'), Administration::instance()->getCurrentPageURL() . '?pg=1' . ($filter_querystring ? "&amp;" . $filter_querystring : '')));
         } else {
             $li->setValue(__('First'));
         }
         $ul->appendChild($li);
         // Previous
         $li = new XMLElement('li');
         if ($current_page > 1) {
             $li->appendChild(Widget::Anchor(__('&larr; Previous'), Administration::instance()->getCurrentPageURL() . '?pg=' . ($current_page - 1) . ($filter_querystring ? "&amp;" . $filter_querystring : '')));
         } else {
             $li->setValue(__('&larr; Previous'));
         }
         $ul->appendChild($li);
         // Summary
         $li = new XMLElement('li');
         $li->setAttribute('title', __('Viewing %1$s - %2$s of %3$s entries', array($entries['start'], $current_page != $entries['total-pages'] ? $current_page * Symphony::Configuration()->get('pagination_maximum_rows', 'symphony') : $entries['total-entries'], $entries['total-entries'])));
         $pgform = Widget::Form(Administration::instance()->getCurrentPageURL(), 'get', 'paginationform');
         $pgmax = max($current_page, $entries['total-pages']);
         $pgform->appendChild(Widget::Input('pg', null, 'text', array('data-active' => __('Go to page …'), 'data-inactive' => __('Page %1$s of %2$s', array((string) $current_page, $pgmax)), 'data-max' => $pgmax)));
         $li->appendChild($pgform);
         $ul->appendChild($li);
         // Next
         $li = new XMLElement('li');
         if ($current_page < $entries['total-pages']) {
             $li->appendChild(Widget::Anchor(__('Next &rarr;'), Administration::instance()->getCurrentPageURL() . '?pg=' . ($current_page + 1) . ($filter_querystring ? "&amp;" . $filter_querystring : '')));
         } else {
             $li->setValue(__('Next &rarr;'));
         }
         $ul->appendChild($li);
         // Last
         $li = new XMLElement('li');
         if ($current_page < $entries['total-pages']) {
             $li->appendChild(Widget::Anchor(__('Last'), Administration::instance()->getCurrentPageURL() . '?pg=' . $entries['total-pages'] . ($filter_querystring ? "&amp;" . $filter_querystring : '')));
         } else {
             $li->setValue(__('Last'));
         }
         $ul->appendChild($li);
         $this->Contents->appendChild($ul);
     }
 }
 public function __viewIndex()
 {
     $this->setPageType('table');
     $this->setTitle('Symphony &ndash; PayPal Payment Transactions');
     $this->appendSubheading('Logs');
     $this->addStylesheetToHead(URL . '/extensions/paypal_payments/assets/logs.css', 'screen', 81);
     $per_page = 20;
     $page = @(int) $_GET['pg'] > 1 ? (int) $_GET['pg'] : 1;
     $logs = $this->_driver->_get_logs_by_page($page, $per_page);
     $start = max(1, ($page - 1) * $per_page);
     $end = $start == 1 ? $per_page : $start + count($logs);
     $total = $this->_driver->_count_logs();
     $pages = ceil($total / $per_page);
     $sectionManager = new SectionManager(Administration::instance());
     $entryManager = new EntryManager(Administration::instance());
     $th = array(array('Invoice/Entry', 'col'), array('Date', 'col'), array('Payment Type', 'col'), array('Payment Status', 'col'), array('Name', 'col'), array('Email', 'col'), array('Address', 'col'), array('Currency', 'col'), array('Tax', 'col'), array('Gross', 'col'), array('Fee', 'col'), array('Transaction Type', 'col'), array('Transaction ID', 'col'));
     if (!is_array($logs) or empty($logs)) {
         $tb = array(Widget::TableRow(array(Widget::TableData(__('None Found.'), 'inactive', NULL, count($th)))));
     } else {
         foreach ($logs as $log) {
             $col = array();
             # Spit out $log_name vars
             extract($log, EXTR_PREFIX_ALL, 'log');
             # Get the entry/section data
             $entries = $entryManager->fetch($log_invoice, NULL, NULL, NULL, NULL, NULL, FALSE, TRUE);
             $entry = $entries[0];
             if (isset($entry)) {
                 $section_id = $entry->get('section_id');
                 $section = $sectionManager->fetch($section_id);
                 $column = array_shift($section->fetchFields());
                 $data = $entry->getData($column->get('id'));
                 # Build link to parent section
                 $link = SYMPHONY_URL . '/publish/' . $section->get('handle') . '/edit/' . $entry->get('id') . '/';
                 # Date
                 $col[] = Widget::TableData(Widget::Anchor(General::sanitize($log_invoice), $link));
             } else {
                 $col[] = Widget::TableData(General::sanitize($log_invoice));
             }
             $col[0]->appendChild(Widget::Input("items[{$log_id}]", NULL, 'checkbox'));
             if (!empty($log_payment_date)) {
                 $col[] = Widget::TableData(DateTimeObj::get(__SYM_DATETIME_FORMAT__, strtotime($log_payment_date)));
             } else {
                 $col[] = Widget::TableData('None', 'inactive');
             }
             if (!empty($log_payment_type)) {
                 $col[] = Widget::TableData(General::sanitize(ucwords($log_payment_type)));
             } else {
                 $col[] = Widget::TableData('None', 'inactive');
             }
             if (!empty($log_payment_status)) {
                 $col[] = Widget::TableData(General::sanitize($log_payment_status));
             } else {
                 $col[] = Widget::TableData('None', 'inactive');
             }
             if (!empty($log_first_name) && !empty($log_last_name)) {
                 $col[] = Widget::TableData(General::sanitize($log_first_name) . " " . General::sanitize($log_last_name));
             } else {
                 $col[] = Widget::TableData('None', 'inactive');
             }
             if (!empty($log_payer_email)) {
                 $col[] = Widget::TableData(General::sanitize($log_payer_email));
             } else {
                 $col[] = Widget::TableData('None', 'inactive');
             }
             if (!empty($log_address_street)) {
                 $col[] = Widget::TableData(General::sanitize($log_address_street));
             } else {
                 $col[] = Widget::TableData('None', 'inactive');
             }
             if (!empty($log_mc_currency)) {
                 $col[] = Widget::TableData(General::sanitize($log_mc_currency));
             } else {
                 $col[] = Widget::TableData('None', 'inactive');
             }
             if (!empty($log_tax)) {
                 $col[] = Widget::TableData(General::sanitize($log_tax));
             } else {
                 $col[] = Widget::TableData('None', 'inactive');
             }
             if (!empty($log_mc_gross)) {
                 $col[] = Widget::TableData(General::sanitize($log_mc_gross));
             } else {
                 $col[] = Widget::TableData('None', 'inactive');
             }
             if (!empty($log_mc_fee)) {
                 $col[] = Widget::TableData(General::sanitize($log_mc_fee));
             } else {
                 $col[] = Widget::TableData('None', 'inactive');
             }
             if (!empty($log_txn_type)) {
                 $col[] = Widget::TableData(General::sanitize($log_txn_type));
             } else {
                 $col[] = Widget::TableData('None', 'inactive');
             }
             if (!empty($log_txn_id)) {
                 $col[] = Widget::TableData(General::sanitize($log_txn_id));
             } else {
                 $col[] = Widget::TableData('None', 'inactive');
             }
             $tr = Widget::TableRow($col);
             if ($log_payment_status == 'Denied') {
                 $tr->setAttribute('class', 'denied');
             }
             $tb[] = $tr;
         }
     }
     $table = Widget::Table(Widget::TableHead($th), NULL, Widget::TableBody($tb), 'selectable');
     $this->Form->appendChild($table);
     $actions = new XMLElement('div');
     $actions->setAttribute('class', 'actions');
     $options = array(array(null, false, __('With Selected...')), array('delete', false, __('Delete')));
     $actions->appendChild(Widget::Apply($options));
     $this->Form->appendChild($actions);
     # Pagination:
     if ($pages > 1) {
         $ul = new XMLElement('ul');
         $ul->setAttribute('class', 'page');
         ## First
         $li = new XMLElement('li');
         if ($page > 1) {
             $li->appendChild(Widget::Anchor('First', Administration::instance()->getCurrentPageURL() . '?pg=1'));
         } else {
             $li->setValue('First');
         }
         $ul->appendChild($li);
         ## Previous
         $li = new XMLElement('li');
         if ($page > 1) {
             $li->appendChild(Widget::Anchor('&larr; Previous', Administration::instance()->getCurrentPageURL() . '?pg=' . ($page - 1)));
         } else {
             $li->setValue('&larr; Previous');
         }
         $ul->appendChild($li);
         ## Summary
         $li = new XMLElement('li', 'Page ' . $page . ' of ' . max($page, $pages));
         $li->setAttribute('title', 'Viewing ' . $start . ' - ' . $end . ' of ' . $total . ' entries');
         $ul->appendChild($li);
         ## Next
         $li = new XMLElement('li');
         if ($page < $pages) {
             $li->appendChild(Widget::Anchor('Next &rarr;', Administration::instance()->getCurrentPageURL() . '?pg=' . ($page + 1)));
         } else {
             $li->setValue('Next &rarr;');
         }
         $ul->appendChild($li);
         ## Last
         $li = new XMLElement('li');
         if ($page < $pages) {
             $li->appendChild(Widget::Anchor('Last', Administration::instance()->getCurrentPageURL() . '?pg=' . $pages));
         } else {
             $li->setValue('Last');
         }
         $ul->appendChild($li);
         $this->Form->appendChild($ul);
     }
 }
 public function __viewIndex()
 {
     $this->setPageType('table');
     $this->setTitle(__('Symphony') . ' &ndash; ' . __('XML Importers'));
     $this->appendSubheading(__('XML Importers'), Widget::Anchor(__('Create New'), "{$this->_uri}/importers/new/", __('Create a new XML Importer'), 'create button'));
     $tableHead = array();
     $tableBody = array();
     // Columns, with sorting:
     foreach ($this->_table_columns as $column => $values) {
         if ($values[1]) {
             if ($column == $this->_table_column) {
                 if ($this->_table_direction == 'desc') {
                     $direction = 'asc';
                     $label = 'ascending';
                 } else {
                     $direction = 'desc';
                     $label = 'descending';
                 }
             } else {
                 $direction = 'asc';
                 $label = 'ascending';
             }
             $link = $this->generateLink(array('sort' => $column, 'order' => $direction));
             $anchor = Widget::Anchor($values[0], $link, __("Sort by {$label} " . strtolower($values[0])));
             if ($column == $this->_table_column) {
                 $anchor->setAttribute('class', 'active');
             }
             $tableHead[] = array($anchor, 'col');
         } else {
             $tableHead[] = array($values[0], 'col');
         }
     }
     if (!is_array($this->_importers) or empty($this->_importers)) {
         $tableBody = array(Widget::TableRow(array(Widget::TableData(__('None Found.'), 'inactive', null, count($tableHead)))));
     } else {
         foreach ($this->_importers as $importer) {
             $col_name = Widget::TableData(Widget::Anchor($importer['about']['name'], "{$this->_uri}/importers/edit/{$importer['about']['handle']}/"));
             $col_name->appendChild(Widget::Input("items[{$importer['about']['handle']}]", null, 'checkbox'));
             $col_date = Widget::TableData(DateTimeObj::get(__SYM_DATETIME_FORMAT__, strtotime($importer['about']['updated'])));
             if (!empty($importer['source'])) {
                 $col_url = Widget::TableData(General::sanitize($importer['source']));
             } else {
                 $col_url = Widget::TableData(__('None'), 'inactive');
             }
             if (!empty($importer['included-elements'])) {
                 $col_elements = Widget::TableData(General::sanitize($importer['included-elements']));
             } else {
                 $col_elements = Widget::TableData(__('None'), 'inactive');
             }
             if (isset($importer['about']['email'])) {
                 $col_author = Widget::TableData(Widget::Anchor($importer['about']['author']['name'], 'mailto:' . $importer['about']['author']['email']));
             } else {
                 if (isset($importer['about']['author']['name'])) {
                     $col_author = Widget::TableData($importer['about']['author']['name']);
                 } else {
                     $col_author = Widget::TableData(__('None'), 'inactive');
                 }
             }
             $tableBody[] = Widget::TableRow(array($col_name, $col_url, $col_elements, $col_date, $col_author), null);
         }
     }
     $table = Widget::Table(Widget::TableHead($tableHead), null, Widget::TableBody($tableBody), 'selectable', null, array('role' => 'directory', 'aria-labelledby' => 'symphony-subheading', 'data-interactive' => 'data-interactive'));
     $this->Form->appendChild($table);
     $actions = new XMLElement('div');
     $actions->setAttribute('class', 'actions');
     $options = array(array(null, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm'), array('run', false, __('Run')));
     $actions->appendChild(Widget::Apply($options));
     $this->Form->appendChild($actions);
     // Pagination:
     if ($this->_pagination->pages > 1) {
         $ul = new XMLElement('ul');
         $ul->setAttribute('class', 'page');
         // First:
         $li = new XMLElement('li');
         $li->setValue(__('First'));
         if ($this->_pagination->page > 1) {
             $li->setValue(Widget::Anchor(__('First'), $this->generateLink(array('pg' => 1)))->generate());
         }
         $ul->appendChild($li);
         // Previous:
         $li = new XMLElement('li');
         $li->setValue(__('&larr; Previous'));
         if ($this->_pagination->page > 1) {
             $li->setValue(Widget::Anchor(__('&larr; Previous'), $this->generateLink(array('pg' => $this->_pagination->page - 1)))->generate());
         }
         $ul->appendChild($li);
         // Summary:
         $li = new XMLElement('li', __('Page %s of %s', array($this->_pagination->page, max($this->_pagination->page, $this->_pagination->pages))));
         $li->setAttribute('title', __('Viewing %s - %s of %s entries', array($this->_pagination->start, $this->_pagination->end, $this->_pagination->total)));
         $ul->appendChild($li);
         // Next:
         $li = new XMLElement('li');
         $li->setValue(__('Next &rarr;'));
         if ($this->_pagination->page < $this->_pagination->pages) {
             $li->setValue(Widget::Anchor(__('Next &rarr;'), $this->generateLink(array('pg' => $this->_pagination->page + 1)))->generate());
         }
         $ul->appendChild($li);
         // Last:
         $li = new XMLElement('li');
         $li->setValue(__('Last'));
         if ($this->_pagination->page < $this->_pagination->pages) {
             $li->setValue(Widget::Anchor(__('Last'), $this->generateLink(array('pg' => $this->_pagination->pages)))->generate());
         }
         $ul->appendChild($li);
         $this->Form->appendChild($ul);
     }
 }
 public function __viewIndex()
 {
     $this->setPageType('table');
     $this->setTitle(__('%1$s &ndash; %2$s', array(__('Pages'), __('Symphony'))));
     $nesting = Symphony::Configuration()->get('pages_table_nest_children', 'symphony') == 'yes';
     if ($nesting == true && isset($_GET['parent']) && is_numeric($_GET['parent'])) {
         $parent = PageManager::fetchPageByID((int) $_GET['parent'], array('title', 'id'));
     }
     $this->appendSubheading(isset($parent) ? $parent['title'] : __('Pages'), Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . 'new/' . ($nesting == true && isset($parent) ? "?parent={$parent['id']}" : NULL), __('Create a new page'), 'create button', NULL, array('accesskey' => 'c')));
     if (isset($parent)) {
         $this->insertBreadcrumbsUsingPageIdentifier($parent['id'], false);
     }
     $aTableHead = array(array(__('Title'), 'col'), array(__('Template'), 'col'), array('<abbr title="' . __('Universal Resource Locator') . '">' . __('URL') . '</abbr>', 'col'), array('<abbr title="' . __('Universal Resource Locator') . '">' . __('URL') . '</abbr> ' . __('Parameters'), 'col'), array(__('Type'), 'col'));
     $aTableBody = array();
     if ($nesting == true) {
         $aTableHead[] = array(__('Children'), 'col');
         $where = array('parent ' . (isset($parent) ? " = {$parent['id']} " : ' IS NULL '));
     } else {
         $where = array();
     }
     $pages = PageManager::fetch(true, array('*'), $where);
     if (!is_array($pages) or empty($pages)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', null, count($aTableHead))), 'odd'));
     } else {
         foreach ($pages as $page) {
             $class = array();
             $page_title = $nesting == true ? $page['title'] : PageManager::resolvePageTitle($page['id']);
             $page_url = URL . '/' . PageManager::resolvePagePath($page['id']) . '/';
             $page_edit_url = Administration::instance()->getCurrentPageURL() . 'edit/' . $page['id'] . '/';
             $page_template = PageManager::createFilePath($page['path'], $page['handle']);
             $page_template_url = Administration::instance()->getCurrentPageURL() . 'template/' . $page_template . '/';
             $col_title = Widget::TableData(Widget::Anchor($page_title, $page_edit_url, $page['handle']));
             $col_title->appendChild(Widget::Input("items[{$page['id']}]", null, 'checkbox'));
             $col_template = Widget::TableData(Widget::Anchor($page_template . '.xsl', $page_template_url));
             $col_url = Widget::TableData(Widget::Anchor($page_url, $page_url));
             if ($page['params']) {
                 $col_params = Widget::TableData(trim($page['params'], '/'));
             } else {
                 $col_params = Widget::TableData(__('None'), 'inactive');
             }
             if (!empty($page['type'])) {
                 $col_types = Widget::TableData(implode(', ', $page['type']));
             } else {
                 $col_types = Widget::TableData(__('None'), 'inactive');
             }
             if (in_array($page['id'], $this->_hilights)) {
                 $class[] = 'failed';
             }
             $columns = array($col_title, $col_template, $col_url, $col_params, $col_types);
             if ($nesting == true) {
                 if (PageManager::hasChildPages($page['id'])) {
                     $col_children = Widget::TableData(Widget::Anchor(PageManager::getChildPagesCount($page['id']) . ' &rarr;', SYMPHONY_URL . '/blueprints/pages/?parent=' . $page['id']));
                 } else {
                     $col_children = Widget::TableData(__('None'), 'inactive');
                 }
                 $columns[] = $col_children;
             }
             $aTableBody[] = Widget::TableRow($columns, implode(' ', $class));
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), null, Widget::TableBody($aTableBody), 'orderable selectable');
     $this->Form->appendChild($table);
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = array(array(null, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm', null, array('data-message' => __('Are you sure you want to delete the selected pages?'))));
     /**
      * Allows an extension to modify the existing options for this page's
      * With Selected menu. If the `$options` parameter is an empty array,
      * the 'With Selected' menu will not be rendered.
      *
      * @delegate AddCustomActions
      * @since Symphony 2.3.2
      * @param string $context
      * '/blueprints/pages/'
      * @param array $options
      *  An array of arrays, where each child array represents an option
      *  in the With Selected menu. Options should follow the same format
      *  expected by `Widget::__SelectBuildOption`. Passed by reference.
      */
     Symphony::ExtensionManager()->notifyMembers('AddCustomActions', '/blueprints/pages/', array('options' => &$options));
     if (!empty($options)) {
         $tableActions->appendChild(Widget::Apply($options));
         $this->Form->appendChild($tableActions);
     }
 }
 public function __viewIndex()
 {
     $this->setPageType('table');
     $this->setTitle(__('%1$s &ndash; %2$s', array(__('Extensions'), __('Symphony'))));
     $this->appendSubheading(__('Extensions'));
     $this->Form->setAttribute('action', SYMPHONY_URL . '/system/extensions/');
     Sortable::initialize($this, $extensions, $sort, $order);
     $columns = array(array('label' => __('Name'), 'sortable' => true, 'handle' => 'name'), array('label' => __('Version'), 'sortable' => false), array('label' => __('Status'), 'sortable' => false), array('label' => __('Links'), 'sortable' => false, 'handle' => 'links'), array('label' => __('Authors'), 'sortable' => true, 'handle' => 'author'));
     $aTableHead = Sortable::buildTableHeaders($columns, $sort, $order, isset($_REQUEST['filter']) ? '&amp;filter=' . $_REQUEST['filter'] : '');
     $aTableBody = array();
     if (!is_array($extensions) || empty($extensions)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', null, count($aTableHead))), 'odd'));
     } else {
         foreach ($extensions as $name => $about) {
             // Name
             $td1 = Widget::TableData($about['name']);
             $td1->appendChild(Widget::Label(__('Select %s Extension', array($about['name'])), null, 'accessible', null, array('for' => 'extension-' . $name)));
             $td1->appendChild(Widget::Input('items[' . $name . ']', 'on', 'checkbox', array('id' => 'extension-' . $name)));
             // Version
             $installed_version = Symphony::ExtensionManager()->fetchInstalledVersion($name);
             if (in_array(Extension::EXTENSION_NOT_INSTALLED, $about['status'])) {
                 $td2 = Widget::TableData($about['version']);
             } elseif (in_array(Extension::EXTENSION_REQUIRES_UPDATE, $about['status'])) {
                 $td2 = Widget::TableData($installed_version . '<i> → ' . $about['version'] . '</i>');
             } else {
                 $td2 = Widget::TableData($installed_version);
             }
             // Status
             $trClasses = array();
             $trStatus = '';
             $tdMessage = __('Status unavailable');
             if (in_array(Extension::EXTENSION_NOT_INSTALLED, $about['status'])) {
                 $tdMessage = __('Not installed');
                 $trClasses[] = 'inactive';
                 $trClasses[] = 'extension-can-install';
             }
             if (in_array(Extension::EXTENSION_DISABLED, $about['status'])) {
                 $tdMessage = __('Disabled');
                 $trStatus = 'status-notice';
             }
             if (in_array(Extension::EXTENSION_ENABLED, $about['status'])) {
                 $tdMessage = __('Enabled');
             }
             if (in_array(Extension::EXTENSION_REQUIRES_UPDATE, $about['status'])) {
                 $tdMessage = __('Update available');
                 $trClasses[] = 'extension-can-update';
                 $trStatus = 'status-ok';
             }
             if (in_array(Extension::EXTENSION_NOT_COMPATIBLE, $about['status'])) {
                 $tdMessage .= ', ' . __('requires Symphony %s', array($about['required_version']));
                 $trStatus = 'status-error';
             }
             $trClasses[] = $trStatus;
             $td3 = Widget::TableData($tdMessage);
             // Links
             $tdLinks = array();
             if ($about['github'] != '') {
                 $tdLinks['github'] = Widget::Anchor(__('GitHub'), General::validateURL($about['github']))->generate();
             }
             if ($about['discuss'] != '') {
                 $tdLinks['discuss'] = Widget::Anchor(__('Discuss'), General::validateURL($about['discuss']))->generate();
                 // Update links to point to our 'new' domain, RE: #1995
                 $tdLinks['discuss'] = str_replace('symphony-cms.com', 'getsymphony.com', $tdLinks['discuss']);
             }
             if ($about['homepage'] != '') {
                 $tdLinks['homepage'] = Widget::Anchor(__('Homepage'), General::validateURL($about['homepage']))->generate();
             }
             if ($about['wiki'] != '') {
                 $tdLinks['wiki'] = Widget::Anchor(__('Wiki'), General::validateURL($about['wiki']))->generate();
             }
             if ($about['issues'] != '') {
                 $tdLinks['issues'] = Widget::Anchor(__('Issues'), General::validateURL($about['issues']))->generate();
             }
             $td4 = Widget::TableData($tdLinks);
             // Authors
             $tdAuthors = array();
             if (!is_array($about['author'])) {
                 $about['author'] = array($about['author']);
             }
             foreach ($about['author'] as $author) {
                 if (isset($author['website'])) {
                     $tdAuthors[] = Widget::Anchor($author['name'], General::validateURL($author['website']))->generate();
                 } elseif (isset($author['github'])) {
                     $tdAuthors[] = Widget::Anchor($author['name'], General::validateURL('https://github.com/' . $author['github']))->generate();
                 } elseif (isset($author['email'])) {
                     $tdAuthors[] = Widget::Anchor($author['name'], 'mailto:' . $author['email'])->generate();
                 } else {
                     $tdAuthors[] = $author['name'];
                 }
             }
             $td5 = Widget::TableData($tdAuthors);
             // Create the table row
             $tr = Widget::TableRow(array($td1, $td2, $td3, $td4, $td5), implode(' ', $trClasses));
             // Add some attributes about the extension
             $tr->setAttribute('data-handle', $name);
             $tr->setAttribute('data-installed-version', $installed_version);
             $tr->setAttribute('data-meta-version', $about['version']);
             // Add a row to the body array, assigning each cell to the row
             $aTableBody[] = $tr;
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), null, Widget::TableBody($aTableBody), 'selectable', null, array('role' => 'directory', 'aria-labelledby' => 'symphony-subheading', 'data-interactive' => 'data-interactive'));
     $this->Form->appendChild($table);
     $version = new XMLElement('p', 'Symphony ' . Symphony::Configuration()->get('version', 'symphony'), array('id' => 'version'));
     $this->Form->appendChild($version);
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = array(array(null, false, __('With Selected...')), array('enable', false, __('Enable')), array('disable', false, __('Disable')), array('uninstall', false, __('Uninstall'), 'confirm', null, array('data-message' => __('Are you sure you want to uninstall the selected extensions?'))));
     /**
      * Allows an extension to modify the existing options for this page's
      * With Selected menu. If the `$options` parameter is an empty array,
      * the 'With Selected' menu will not be rendered.
      *
      * @delegate AddCustomActions
      * @since Symphony 2.3.2
      * @param string $context
      * '/system/extensions/'
      * @param array $options
      *  An array of arrays, where each child array represents an option
      *  in the With Selected menu. Options should follow the same format
      *  expected by `Widget::__SelectBuildOption`. Passed by reference.
      */
     Symphony::ExtensionManager()->notifyMembers('AddCustomActions', '/system/extensions/', array('options' => &$options));
     if (!empty($options)) {
         $tableActions->appendChild(Widget::Apply($options));
         $this->Form->appendChild($tableActions);
     }
 }
Exemple #18
0
    public function view()
    {
        // Start building the page
        $this->setPageType('index');
        $this->setTitle(__('%1$s &ndash; %2$s', array(__('Symphony'), __('Tracker Activity'))));
        // Add a button to clear all activity
        $clearform = new XMLElement('form');
        $clearform->setAttribute('method', 'post');
        $clearform->setAttribute('action', Symphony::Engine()->getCurrentPageURL());
        $button = new XMLElement('button', __('Clear All'));
        $button->setAttribute('class', 'tracker confirm');
        $button->setAttribute('title', __('Clear all Activity'));
        $button->setAttribute('name', 'action[clear-all]');
        $clearform->appendChild($button);
        $this->appendSubheading(__('Tracker Activity'), $clearform);
        // Build pagination, sorting, and limiting info
        $current_page = isset($_REQUEST['pg']) && is_numeric($_REQUEST['pg']) ? max(1, intval($_REQUEST['pg'])) : 1;
        $start = (max(1, $current_page) - 1) * Symphony::Configuration()->get('pagination_maximum_rows', 'symphony');
        $limit = Symphony::Configuration()->get('pagination_maximum_rows', 'symphony');
        // Build filter info
        $filters = array();
        if (isset($_REQUEST['filter'])) {
            list($column, $value) = explode(':', $_REQUEST['filter'], 2);
            $values = explode(',', $value);
            $filters[$column] = array();
            foreach ($values as $value) {
                $filters[$column][] = rawurldecode($value);
            }
        }
        // Fetch activity logs
        $logs = Tracker::fetchActivities($filters, $limit, $start);
        // Build the table
        $thead = array(array(__('Activity'), 'col'), array(__('Date'), 'col'), array(__('Time'), 'col'));
        $tbody = array();
        // If there are no logs, display default message
        if (!is_array($logs) or empty($logs)) {
            $tbody = array(Widget::TableRow(array(Widget::TableData(__('No data available.'), 'inactive', null, count($thead))), 'odd'));
        } else {
            $bOdd = true;
            foreach ($logs as $activity) {
                // Format the date and time
                $date = DateTimeObj::get(__SYM_DATE_FORMAT__, strtotime($activity['timestamp'] . ' GMT'));
                $time = DateTimeObj::get(__SYM_TIME_FORMAT__, strtotime($activity['timestamp'] . ' GMT'));
                $description = Tracker::getDescription($activity);
                // Assemble the columns
                $col_date = Widget::TableData($date);
                $col_time = Widget::TableData($time);
                $col_desc = Widget::TableData($description);
                $col_desc->appendChild(Widget::Input("items[{$activity['id']}]", null, 'checkbox'));
                // Insert the row
                if (!is_null($description)) {
                    $tbody[] = Widget::TableRow(array($col_desc, $col_date, $col_time), $bOdd ? 'odd' : NULL);
                    $bOdd = !$bOdd;
                }
            }
        }
        // Assemble the table
        $table = Widget::Table(Widget::TableHead($thead), null, Widget::TableBody($tbody), null);
        $table->setAttribute('class', 'selectable');
        $this->Form->appendChild($table);
        // Append table actions
        $options = array(array(null, false, __('With Selected...')), array('delete', false, __('Delete')));
        $tableActions = new XMLElement('div');
        $tableActions->setAttribute('class', 'actions');
        $tableActions->appendChild(Widget::Apply($options));
        $this->Form->appendChild($tableActions);
        // Append pagination
        $filter_sql = Tracker::buildFilterSQL($filters);
        $sql = '
				SELECT count(id) as `count`
				FROM `tbl_tracker_activity`' . $filter_sql;
        $per_page = Symphony::Configuration()->get('pagination_maximum_rows', 'symphony');
        $total_entries = Symphony::Database()->fetchVar('count', 0, $sql);
        $remaining_entries = max(0, $total_entries - ($start + $per_page));
        $total_pages = max(1, ceil($total_entries * (1 / $per_page)));
        $remaining_pages = max(0, $total - pages - $current_page);
        if ($total_pages > 1) {
            $ul = new XMLElement('ul');
            $ul->setAttribute('class', 'page');
            // First
            $li = new XMLElement('li');
            if ($current_page > 1) {
                $li->appendChild(Widget::Anchor(__('First'), Administration::instance()->getCurrentPageURL() . '?pg=1'));
            } else {
                $li->setValue(__('First'));
            }
            $ul->appendChild($li);
            // Previous
            $li = new XMLElement('li');
            if ($current_page > 1) {
                $li->appendChild(Widget::Anchor(__('&larr; Previous'), Administration::instance()->getCurrentPageURL() . '?pg=' . ($current_page - 1)));
            } else {
                $li->setValue(__('&larr; Previous'));
            }
            $ul->appendChild($li);
            // Summary
            $li = new XMLElement('li', __('Page %1$s of %2$s', array($current_page, max($current_page, $total_pages))));
            $li->setAttribute('title', __('Viewing %1$s - %2$s of %3$s entries', array($start, $current_page != $total_pages ? $current_page * Symphony::Configuration()->get('pagination_maximum_rows', 'symphony') : $total_entries, $total_entries)));
            $ul->appendChild($li);
            // Next
            $li = new XMLElement('li');
            if ($current_page < $total_pages) {
                $li->appendChild(Widget::Anchor(__('Next &rarr;'), Administration::instance()->getCurrentPageURL() . '?pg=' . ($current_page + 1)));
            } else {
                $li->setValue(__('Next &rarr;'));
            }
            $ul->appendChild($li);
            // Last
            $li = new XMLElement('li');
            if ($current_page < $total_pages) {
                $li->appendChild(Widget::Anchor(__('Last'), Administration::instance()->getCurrentPageURL() . '?pg=' . $total_pages));
            } else {
                $li->setValue(__('Last'));
            }
            $ul->appendChild($li);
            $this->Form->appendChild($ul);
        }
    }
 public function __viewIndex()
 {
     $this->setPageType('table');
     $this->setTitle(__('%1$s &ndash; %2$s', array(__('Extensions'), __('Symphony'))));
     $this->appendSubheading(__('Extensions'));
     $this->Form->setAttribute('action', SYMPHONY_URL . '/system/extensions/');
     Sortable::initialize($this, $extensions, $sort, $order);
     $columns = array(array('label' => __('Name'), 'sortable' => true, 'handle' => 'name'), array('label' => __('Installed Version'), 'sortable' => false), array('label' => __('Enabled'), 'sortable' => false), array('label' => __('Authors'), 'sortable' => true, 'handle' => 'author'));
     $aTableHead = Sortable::buildTableHeaders($columns, $sort, $order, isset($_REQUEST['filter']) ? '&amp;filter=' . $_REQUEST['filter'] : '');
     $aTableBody = array();
     if (!is_array($extensions) || empty($extensions)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd'));
     } else {
         foreach ($extensions as $name => $about) {
             $td1 = Widget::TableData($about['name']);
             $installed_version = Symphony::ExtensionManager()->fetchInstalledVersion($name);
             $td2 = Widget::TableData(is_null($installed_version) ? __('Not Installed') : $installed_version);
             // If the extension is using the new `extension.meta.xml` format, check the
             // compatibility of the extension. This won't prevent a user from installing
             // it, but it will let them know that it requires a version of Symphony greater
             // then what they have.
             if (in_array(EXTENSION_NOT_INSTALLED, $about['status'])) {
                 $td3 = Widget::TableData(__('Enable to install %s', array($about['version'])));
             }
             if (in_array(EXTENSION_NOT_COMPATIBLE, $about['status'])) {
                 $td3 = Widget::TableData(__('Requires Symphony %s', array($about['required_version'])));
             }
             if (in_array(EXTENSION_ENABLED, $about['status'])) {
                 $td3 = Widget::TableData(__('Yes'));
             }
             if (in_array(EXTENSION_REQUIRES_UPDATE, $about['status'])) {
                 if (in_array(EXTENSION_NOT_COMPATIBLE, $about['status'])) {
                     $td3 = Widget::TableData(__('New version %1$s, Requires Symphony %2$s', array($about['version'], $about['required_version'])));
                 } else {
                     $td3 = Widget::TableData(__('Enable to update to %s', array($about['version'])));
                 }
             }
             if (in_array(EXTENSION_DISABLED, $about['status'])) {
                 $td3 = Widget::TableData(__('Disabled'));
             }
             $td4 = Widget::TableData(NULL);
             if (isset($about['author'][0]) && is_array($about['author'][0])) {
                 $authors = '';
                 foreach ($about['author'] as $i => $author) {
                     if (isset($author['website'])) {
                         $link = Widget::Anchor($author['name'], General::validateURL($author['website']));
                     } else {
                         if (isset($author['email'])) {
                             $link = Widget::Anchor($author['name'], 'mailto:' . $author['email']);
                         } else {
                             $link = $author['name'];
                         }
                     }
                     $authors .= ($link instanceof XMLElement ? $link->generate() : $link) . ($i != count($about['author']) - 1 ? ", " : "");
                 }
                 $td4->setValue($authors);
             } else {
                 if (isset($about['author']['website'])) {
                     $link = Widget::Anchor($about['author']['name'], General::validateURL($about['author']['website']));
                 } else {
                     if (isset($about['author']['email'])) {
                         $link = Widget::Anchor($about['author']['name'], 'mailto:' . $about['author']['email']);
                     } else {
                         $link = $about['author']['name'];
                     }
                 }
                 $td4->setValue($link instanceof XMLElement ? $link->generate() : $link);
             }
             $td4->appendChild(Widget::Input('items[' . $name . ']', 'on', 'checkbox'));
             // Add a row to the body array, assigning each cell to the row
             $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3, $td4), in_array(EXTENSION_NOT_INSTALLED, $about['status']) ? 'inactive' : NULL);
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'selectable');
     $this->Form->appendChild($table);
     $version = new XMLElement('p', 'Symphony ' . Symphony::Configuration()->get('version', 'symphony'), array('id' => 'version'));
     $this->Form->appendChild($version);
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = array(array(NULL, false, __('With Selected...')), array('enable', false, __('Enable/Install')), array('disable', false, __('Disable')), array('uninstall', false, __('Uninstall'), 'confirm', null, array('data-message' => __('Are you sure you want to uninstall the selected extensions?'))));
     /**
      * Allows an extension to modify the existing options for this page's
      * With Selected menu. If the `$options` parameter is an empty array,
      * the 'With Selected' menu will not be rendered.
      *
      * @delegate AddCustomActions
      * @since Symphony 2.3.2
      * @param string $context
      * '/system/extensions/'
      * @param array $options
      *  An array of arrays, where each child array represents an option
      *  in the With Selected menu. Options should follow the same format
      *  expected by `Widget::__SelectBuildOption`. Passed by reference.
      */
     Symphony::ExtensionManager()->notifyMembers('AddCustomActions', '/system/extensions/', array('options' => &$options));
     if (!empty($options)) {
         $tableActions->appendChild(Widget::Apply($options));
         $this->Form->appendChild($tableActions);
     }
 }
 public function __viewIndex()
 {
     $this->setPageType('table');
     $this->setTitle(__('Symphony') . ' &ndash; ' . __('Search Indexes'));
     $this->appendSubheading(__('Indexes'));
     $this->Form->appendChild(new XMLElement('p', __('Configure how each of your sections are indexed. Choose which field text values to index, which entries to index, and the weighting of the section in search results.'), array('class' => 'intro')));
     $this->addElementToHead(new XMLElement('script', "Symphony.Context.add('search_index', " . json_encode(Symphony::Configuration()->get('search_index')) . ")", array('type' => 'text/javascript')), 99);
     $this->addStylesheetToHead(URL . '/extensions/search_index/assets/search_index.css', 'screen', 100);
     $this->addScriptToHead(URL . '/extensions/search_index/assets/search_index.js', 101);
     $tableHead = array();
     $tableBody = array();
     $tableHead[] = array(__('Section'), 'col');
     $tableHead[] = array(__('Fields'), 'col');
     $tableHead[] = array(__('Weighting'), 'col');
     $tableHead[] = array(__('Index Size'), 'col');
     if (!is_array($this->_sections) or empty($this->_sections)) {
         $tableBody = array(Widget::TableRow(array(Widget::TableData(__('None Found.'), 'inactive', null, count($tableHead)))));
     } else {
         $re_index = explode(',', $_GET['section']);
         foreach ($this->_sections as $section) {
             $index = NULL;
             if (isset($this->_indexes[$section->get('id')])) {
                 $index = $this->_indexes[$section->get('id')];
             }
             $col_name = Widget::TableData(Widget::Anchor($section->get('name'), "{$this->_uri}/indexes/edit/{$section->get('id')}/"));
             if ($index) {
                 $col_name->appendChild(Widget::Input("items[{$section->get('id')}]", null, 'checkbox'));
             }
             if ($index && isset($index['fields']) && count($index['fields'] > 0)) {
                 $section_fields = $section->fetchFields();
                 $fields = $this->_indexes[$section->get('id')]['fields'];
                 $fields_list = '';
                 foreach ($section_fields as $section_field) {
                     if (in_array($section_field->get('element_name'), array_values($fields))) {
                         $fields_list .= $section_field->get('label') . ', ';
                     }
                 }
                 $fields_list = trim($fields_list, ', ');
                 $col_fields = Widget::TableData($fields_list);
             } else {
                 $col_fields = Widget::TableData(__('None'), 'inactive');
             }
             if ($index) {
                 if ($index['weighting'] == '') {
                     $index['weighting'] = 2;
                 }
                 $col_weighting = Widget::TableData($this->_weightings[$index['weighting']]);
             } else {
                 $col_weighting = Widget::TableData(__('None'), 'inactive');
             }
             $count_data = null;
             $count_class = null;
             if (isset($_GET['section']) && in_array($section->get('id'), $re_index) && in_array($section->get('id'), array_keys($this->_indexes))) {
                 SearchIndex::deleteIndexBySection($section->get('id'));
                 $count_data = '<span class="to-re-index" id="section-' . $section->get('id') . '">' . __('Waiting to re-index...') . '</span>';
             } else {
                 if (isset($this->_indexes[$section->get('id')])) {
                     $count = Symphony::Database()->fetchCol('count', sprintf("SELECT COUNT(entry_id) as `count` FROM tbl_search_index WHERE `section_id`='%d'", $section->get('id')));
                     $count_data = $count[0] . ' ' . ((int) $count[0] == 1 ? __('entry') : __('entries'));
                 } else {
                     $count_data = __('No index');
                     $count_class = 'inactive';
                 }
             }
             $col_count = Widget::TableData($count_data, $count_class . ' count-column');
             $tableBody[] = Widget::TableRow(array($col_name, $col_fields, $col_weighting, $col_count), 'section-' . $section->get('id'));
         }
     }
     $table = Widget::Table(Widget::TableHead($tableHead), NULL, Widget::TableBody($tableBody), 'selectable', null, array('role' => 'directory', 'aria-labelledby' => 'symphony-subheading', 'data-interactive' => 'data-interactive'));
     $this->Form->appendChild($table);
     $actions = new XMLElement('div');
     $actions->setAttribute('class', 'actions');
     $options = array(array(null, false, __('With Selected...')), array('re-index', false, __('Re-index Entries')), array('delete', false, __('Delete')));
     $actions->appendChild(Widget::Apply($options));
     $this->Form->appendChild($actions);
 }
 public function __viewIndex()
 {
     $this->setPageType('table');
     $this->setTitle(__('Symphony') . ' &ndash; ' . __('Search Indexes'));
     $this->appendSubheading(__('Synonyms'), Widget::Anchor(__('Create New'), $this->_uri . '/synonyms/edit/', __('Create New Synonym'), 'button create'));
     $this->Form->appendChild(new XMLElement('p', __('Configure synonym expansion, so that common misspellings or variations of phrases can be normalised to a single phrase.'), array('class' => 'intro')));
     $this->addStylesheetToHead(URL . '/extensions/search_index/assets/search_index.css', 'screen', 100);
     $tableHead = array();
     $tableBody = array();
     $tableHead[] = array(__('Word'), 'col');
     $tableHead[] = array(__('Synonyms'), 'col');
     if (!is_array($this->_synonyms) or empty($this->_synonyms)) {
         $tableBody = array(Widget::TableRow(array(Widget::TableData(__('None Found.'), 'inactive', null, count($tableHead)))));
     } else {
         foreach ($this->_synonyms as $hash => $synonym) {
             $col_word = Widget::TableData(Widget::Anchor($synonym['word'], "{$this->_uri}/synonyms/edit/{$hash}/"));
             $col_word->appendChild(Widget::Input("items[{$hash}]", null, 'checkbox'));
             $col_synonyms = Widget::TableData($synonym['synonyms']);
             $tableBody[] = Widget::TableRow(array($col_word, $col_synonyms));
         }
     }
     $table = Widget::Table(Widget::TableHead($tableHead), NULL, Widget::TableBody($tableBody), 'selectable', null, array('role' => 'directory', 'aria-labelledby' => 'symphony-subheading', 'data-interactive' => 'data-interactive'));
     $this->Form->appendChild($table);
     $actions = new XMLElement('div');
     $actions->setAttribute('class', 'actions');
     $options = array(array(NULL, FALSE, __('With Selected...')), array('delete', FALSE, __('Delete')));
     $actions->appendChild(Widget::Apply($options));
     $this->Form->appendChild($actions);
 }
 public function __viewIndex()
 {
     $this->setPageType('table');
     $this->setTitle(__('%1$s &ndash; %2$s', array(__('Symphony'), __('Member Roles'))));
     if (!FieldManager::isFieldUsed(extension_Members::getFieldType('role'))) {
         $this->pageAlert(__('There are no Member: Role fields in this Symphony installation. <a href="%s">Add Member: Role field?</a>', array(SYMPHONY_URL . '/blueprints/sections/')), Alert::NOTICE);
     }
     $this->appendSubheading(__('Member Roles'), Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . 'new/', __('Create a Role'), 'create button', NULL, array('accesskey' => 'c')));
     $roles = RoleManager::fetch();
     // Find all possible member sections
     $config_sections = explode(',', extension_Members::getSetting('section'));
     $aTableHead = array(array(__('Name'), 'col'));
     $aTableBody = array();
     if (!is_array($roles) || empty($roles)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead)))));
     } else {
         if (empty($config_sections)) {
             $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('No Member sections exist in Symphony. <a href="%s">Create a Section?</a>', array(SYMPHONY_URL . '/blueprints/sections/')), 'inactive', NULL, count($aTableHead)))));
         } else {
             $hasRoles = FieldManager::isFieldUsed(extension_Members::getFieldType('role'));
             $roleFields = FieldManager::fetch(null, null, 'ASC', 'sortorder', extension_Members::getFieldType('role'));
             $with_selected_roles = array();
             $i = 0;
             foreach ($roles as $role) {
                 // Setup each cell
                 $td1 = Widget::TableData(Widget::Anchor($role->get('name'), Administration::instance()->getCurrentPageURL() . 'edit/' . $role->get('id') . '/', null, 'content'));
                 if ($role->get('id') != Role::PUBLIC_ROLE) {
                     $td1->appendChild(Widget::Input("items[{$role->get('id')}]", null, 'checkbox'));
                 }
                 // Get the number of members for this role, as long as it's not the Public Role.
                 if ($hasRoles && $role->get('id') != Role::PUBLIC_ROLE) {
                     $columns = array($td1);
                     foreach ($roleFields as $roleField) {
                         $section = SectionManager::fetch($roleField->get('parent_section'));
                         $member_count = Symphony::Database()->fetchVar('count', 0, sprintf("SELECT COUNT(*) AS `count` FROM `tbl_entries_data_%d` WHERE `role_id` = %d", $roleField->get('id'), $role->get('id')));
                         // If it's the first time we're looping over the available sections
                         // then change the table header, otherwise just ignore it as it's
                         // been done before
                         if ($i === 1) {
                             $aTableHead[] = array($section->get('name'), 'col');
                         }
                         $columns[] = Widget::TableData(Widget::Anchor("{$member_count}", SYMPHONY_URL . '/publish/' . $section->get('handle') . '/?filter=' . $roleField->get('element_name') . ':' . $role->get('id')));
                     }
                     $aTableBody[] = Widget::TableRow($columns);
                 } else {
                     if ($role->get('id') == Role::PUBLIC_ROLE) {
                         $td2 = Widget::TableData(__('This is the role assumed by the general public.'));
                     } else {
                         $td2 = Widget::TableData(__('None'), 'inactive');
                     }
                 }
                 // Add cells to a row
                 if ($i === 0) {
                     $aTableBody[] = Widget::TableRow(array($td1, $td2));
                 }
                 if ($hasRoles && $role->get('id') != Role::PUBLIC_ROLE) {
                     $with_selected_roles[] = array("move::" . $role->get('id'), false, $role->get('name'));
                 }
                 $i++;
             }
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'selectable');
     $this->Form->appendChild($table);
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = array(0 => array(null, false, __('With Selected...')), 2 => array('delete', false, __('Delete'), 'confirm'), 3 => array('delete-members', false, __('Delete Members'), 'confirm'));
     if (count($with_selected_roles) > 0) {
         $options[1] = array('label' => __('Move Members To'), 'options' => $with_selected_roles);
     }
     $tableActions->appendChild(Widget::Apply($options));
     $this->Form->appendChild($tableActions);
 }
 public function __viewIndex()
 {
     if (!($section_id = SectionManager::fetchIDFromHandle($this->_context['section_handle']))) {
         Administration::instance()->customError(__('Unknown Section'), __('The Section you are looking for, %s, could not be found.', array('<code>' . $this->_context['section_handle'] . '</code>')));
     }
     $section = SectionManager::fetch($section_id);
     $this->setPageType('table');
     $this->setTitle(__('%1$s &ndash; %2$s', array($section->get('name'), __('Symphony'))));
     $this->Form->setAttribute("class", $this->_context['section_handle']);
     $filters = array();
     $filter_querystring = $prepopulate_querystring = $where = $joins = NULL;
     $current_page = isset($_REQUEST['pg']) && is_numeric($_REQUEST['pg']) ? max(1, intval($_REQUEST['pg'])) : 1;
     if (isset($_REQUEST['filter'])) {
         // legacy implementation, convert single filter to an array
         // split string in the form ?filter=handle:value
         if (!is_array($_REQUEST['filter'])) {
             list($field_handle, $filter_value) = explode(':', $_REQUEST['filter'], 2);
             $filters[$field_handle] = rawurldecode($filter_value);
         } else {
             $filters = $_REQUEST['filter'];
         }
         foreach ($filters as $handle => $value) {
             $field_id = FieldManager::fetchFieldIDFromElementName(Symphony::Database()->cleanValue($handle), $section->get('id'));
             $field = FieldManager::fetch($field_id);
             if ($field instanceof Field) {
                 // For deprecated reasons, call the old, typo'd function name until the switch to the
                 // properly named buildDSRetrievalSQL function.
                 $field->buildDSRetrivalSQL(array($value), $joins, $where, false);
                 $filter_querystring .= sprintf("filter[%s]=%s&amp;", $handle, rawurlencode($value));
                 $prepopulate_querystring .= sprintf("prepopulate[%d]=%s&amp;", $field_id, rawurlencode($value));
             } else {
                 unset($filters[$handle]);
             }
         }
         $filter_querystring = preg_replace("/&amp;\$/", '', $filter_querystring);
         $prepopulate_querystring = preg_replace("/&amp;\$/", '', $prepopulate_querystring);
     }
     Sortable::initialize($this, $entries, $sort, $order, array('current-section' => $section, 'filters' => $filter_querystring ? "&amp;" . $filter_querystring : '', 'unsort' => isset($_REQUEST['unsort'])));
     $this->Form->setAttribute('action', Administration::instance()->getCurrentPageURL() . '?pg=' . $current_page . ($filter_querystring ? "&amp;" . $filter_querystring : ''));
     $subheading_buttons = array(Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . 'new/' . ($filter_querystring ? '?' . $prepopulate_querystring : ''), __('Create a new entry'), 'create button', NULL, array('accesskey' => 'c')));
     // Only show the Edit Section button if the Author is a developer. #938 ^BA
     if (Administration::instance()->Author->isDeveloper()) {
         array_unshift($subheading_buttons, Widget::Anchor(__('Edit Section'), SYMPHONY_URL . '/blueprints/sections/edit/' . $section_id, __('Edit Section Configuration'), 'button'));
     }
     $this->appendSubheading($section->get('name'), $subheading_buttons);
     // Check that the filtered query fails that the filter is dropped and an
     // error is logged. #841 ^BA
     try {
         $entries = EntryManager::fetchByPage($current_page, $section_id, Symphony::Configuration()->get('pagination_maximum_rows', 'symphony'), $where, $joins);
     } catch (DatabaseException $ex) {
         $this->pageAlert(__('An error occurred while retrieving filtered entries. Showing all entries instead.'), Alert::ERROR);
         $filter_querystring = null;
         Symphony::Log()->pushToLog(sprintf('%s - %s%s%s', $section->get('name') . ' Publish Index', $ex->getMessage(), $ex->getFile() ? " in file " . $ex->getFile() : null, $ex->getLine() ? " on line " . $ex->getLine() : null), E_NOTICE, true);
         $entries = EntryManager::fetchByPage($current_page, $section_id, Symphony::Configuration()->get('pagination_maximum_rows', 'symphony'));
     }
     $visible_columns = $section->fetchVisibleColumns();
     $columns = array();
     if (is_array($visible_columns) && !empty($visible_columns)) {
         foreach ($visible_columns as $column) {
             $columns[] = array('label' => $column->get('label'), 'sortable' => $column->isSortable(), 'handle' => $column->get('id'), 'attrs' => array('id' => 'field-' . $column->get('id'), 'class' => 'field-' . $column->get('type')));
         }
     } else {
         $columns[] = array('label' => __('ID'), 'sortable' => true, 'handle' => 'id');
     }
     $aTableHead = Sortable::buildTableHeaders($columns, $sort, $order, $filter_querystring ? "&amp;" . $filter_querystring : '');
     $child_sections = array();
     $associated_sections = $section->fetchAssociatedSections(true);
     if (is_array($associated_sections) && !empty($associated_sections)) {
         foreach ($associated_sections as $key => $as) {
             $child_sections[$key] = SectionManager::fetch($as['child_section_id']);
             $aTableHead[] = array($child_sections[$key]->get('name'), 'col');
         }
     }
     /**
      * Allows the creation of custom entries tablecolumns. Called
      * after all the Section Visible columns have been added  as well
      * as the Section Associations
      *
      * @delegate AddCustomPublishColumn
      * @since Symphony 2.2
      * @param string $context
      * '/publish/'
      * @param array $tableHead
      * An array of the current columns, passed by reference
      * @param integer $section_id
      * The current Section ID
      */
     Symphony::ExtensionManager()->notifyMembers('AddCustomPublishColumn', '/publish/', array('tableHead' => &$aTableHead, 'section_id' => $section->get('id')));
     // Table Body
     $aTableBody = array();
     if (!is_array($entries['records']) || empty($entries['records'])) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd'));
     } else {
         $field_pool = array();
         if (is_array($visible_columns) && !empty($visible_columns)) {
             foreach ($visible_columns as $column) {
                 $field_pool[$column->get('id')] = $column;
             }
         }
         $link_column = end(array_reverse($visible_columns));
         reset($visible_columns);
         foreach ($entries['records'] as $entry) {
             $tableData = array();
             // Setup each cell
             if (!is_array($visible_columns) || empty($visible_columns)) {
                 $tableData[] = Widget::TableData(Widget::Anchor($entry->get('id'), Administration::instance()->getCurrentPageURL() . 'edit/' . $entry->get('id') . '/'));
             } else {
                 $link = Widget::Anchor(__('None'), Administration::instance()->getCurrentPageURL() . 'edit/' . $entry->get('id') . '/', $entry->get('id'), 'content');
                 foreach ($visible_columns as $position => $column) {
                     $data = $entry->getData($column->get('id'));
                     $field = $field_pool[$column->get('id')];
                     $value = $field->prepareTableValue($data, $column == $link_column ? $link : null, $entry->get('id'));
                     if (!is_object($value) && (strlen(trim($value)) == 0 || $value == __('None'))) {
                         $value = $position == 0 ? $link->generate() : __('None');
                     }
                     if ($value == __('None')) {
                         $tableData[] = Widget::TableData($value, 'inactive field-' . $column->get('type') . ' field-' . $column->get('id'));
                     } else {
                         $tableData[] = Widget::TableData($value, 'field-' . $column->get('type') . ' field-' . $column->get('id'));
                     }
                     unset($field);
                 }
             }
             if (is_array($child_sections) && !empty($child_sections)) {
                 foreach ($child_sections as $key => $as) {
                     $field = FieldManager::fetch((int) $associated_sections[$key]['child_section_field_id']);
                     $parent_section_field_id = (int) $associated_sections[$key]['parent_section_field_id'];
                     if (!is_null($parent_section_field_id)) {
                         $search_value = $field->fetchAssociatedEntrySearchValue($entry->getData($parent_section_field_id), $parent_section_field_id, $entry->get('id'));
                     } else {
                         $search_value = $entry->get('id');
                     }
                     if (!is_array($search_value)) {
                         $associated_entry_count = $field->fetchAssociatedEntryCount($search_value);
                         $tableData[] = Widget::TableData(Widget::Anchor(sprintf('%d &rarr;', max(0, intval($associated_entry_count))), sprintf('%s/publish/%s/?filter=%s:%s', SYMPHONY_URL, $as->get('handle'), $field->get('element_name'), rawurlencode($search_value)), $entry->get('id'), 'content'));
                     }
                 }
             }
             /**
              * Allows Extensions to inject custom table data for each Entry
              * into the Publish Index
              *
              * @delegate AddCustomPublishColumnData
              * @since Symphony 2.2
              * @param string $context
              * '/publish/'
              * @param array $tableData
              *	An array of `Widget::TableData`, passed by reference
              * @param integer $section_id
              *	The current Section ID
              * @param integer $entry_id
              *	The Entry ID for this row
              */
             Symphony::ExtensionManager()->notifyMembers('AddCustomPublishColumnData', '/publish/', array('tableData' => &$tableData, 'section_id' => $section->get('id'), 'entry_id' => $entry));
             $tableData[count($tableData) - 1]->appendChild(Widget::Input('items[' . $entry->get('id') . ']', NULL, 'checkbox'));
             // Add a row to the body array, assigning each cell to the row
             $aTableBody[] = Widget::TableRow($tableData, NULL, 'id-' . $entry->get('id'));
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'selectable');
     $this->Form->appendChild($table);
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm', null, array('data-message' => __('Are you sure you want to delete the selected entries?'))));
     $toggable_fields = $section->fetchToggleableFields();
     if (is_array($toggable_fields) && !empty($toggable_fields)) {
         $index = 2;
         foreach ($toggable_fields as $field) {
             $options[$index] = array('label' => __('Set %s', array($field->get('label'))), 'options' => array());
             foreach ($field->getToggleStates() as $value => $state) {
                 $options[$index]['options'][] = array('toggle-' . $field->get('id') . '-' . $value, false, $state);
             }
             $index++;
         }
     }
     $tableActions->appendChild(Widget::Apply($options));
     $this->Form->appendChild($tableActions);
     if ($entries['total-pages'] > 1) {
         $ul = new XMLElement('ul');
         $ul->setAttribute('class', 'page');
         // First
         $li = new XMLElement('li');
         if ($current_page > 1) {
             $li->appendChild(Widget::Anchor(__('First'), Administration::instance()->getCurrentPageURL() . '?pg=1' . ($filter_querystring ? "&amp;" . $filter_querystring : '')));
         } else {
             $li->setValue(__('First'));
         }
         $ul->appendChild($li);
         // Previous
         $li = new XMLElement('li');
         if ($current_page > 1) {
             $li->appendChild(Widget::Anchor(__('&larr; Previous'), Administration::instance()->getCurrentPageURL() . '?pg=' . ($current_page - 1) . ($filter_querystring ? "&amp;" . $filter_querystring : '')));
         } else {
             $li->setValue(__('&larr; Previous'));
         }
         $ul->appendChild($li);
         // Summary
         $li = new XMLElement('li');
         $li->setAttribute('title', __('Viewing %1$s - %2$s of %3$s entries', array($entries['start'], $current_page != $entries['total-pages'] ? $current_page * Symphony::Configuration()->get('pagination_maximum_rows', 'symphony') : $entries['total-entries'], $entries['total-entries'])));
         $pgform = Widget::Form(Administration::instance()->getCurrentPageURL(), 'get', 'paginationform');
         $pgmax = max($current_page, $entries['total-pages']);
         $pgform->appendChild(Widget::Input('pg', NULL, 'text', array('data-active' => __('Go to page …'), 'data-inactive' => __('Page %1$s of %2$s', array((string) $current_page, $pgmax)), 'data-max' => $pgmax)));
         $li->appendChild($pgform);
         $ul->appendChild($li);
         // Next
         $li = new XMLElement('li');
         if ($current_page < $entries['total-pages']) {
             $li->appendChild(Widget::Anchor(__('Next &rarr;'), Administration::instance()->getCurrentPageURL() . '?pg=' . ($current_page + 1) . ($filter_querystring ? "&amp;" . $filter_querystring : '')));
         } else {
             $li->setValue(__('Next &rarr;'));
         }
         $ul->appendChild($li);
         // Last
         $li = new XMLElement('li');
         if ($current_page < $entries['total-pages']) {
             $li->appendChild(Widget::Anchor(__('Last'), Administration::instance()->getCurrentPageURL() . '?pg=' . $entries['total-pages'] . ($filter_querystring ? "&amp;" . $filter_querystring : '')));
         } else {
             $li->setValue(__('Last'));
         }
         $ul->appendChild($li);
         $this->Contents->appendChild($ul);
     }
 }
 /**
  * This function contains the minimal amount of logic for generating the
  * index table of a given `$resource_type`. The table has name, source, pages
  * release date and author columns. The values for these columns are determined
  * by the resource's `about()` method.
  *
  * As Datasources types can be installed using Providers, the Source column
  * can be overridden with a Datasource's `getSourceColumn` method (if it exists).
  *
  * @param integer $resource_type
  *  Either `RESOURCE_TYPE_EVENT` or `RESOURCE_TYPE_DATASOURCE`
  */
 public function __viewIndex($resource_type)
 {
     $manager = ResourceManager::getManagerFromType($resource_type);
     $this->setPageType('table');
     Sortable::initialize($this, $resources, $sort, $order, array('type' => $resource_type));
     $columns = array(array('label' => __('Name'), 'sortable' => true, 'handle' => 'name'), array('label' => __('Source'), 'sortable' => true, 'handle' => 'source'), array('label' => __('Pages'), 'sortable' => false), array('label' => __('Release Date'), 'sortable' => true, 'handle' => 'release-date'), array('label' => __('Author'), 'sortable' => true, 'handle' => 'author'));
     $aTableHead = Sortable::buildTableHeaders($columns, $sort, $order, isset($_REQUEST['filter']) ? '&amp;filter=' . $_REQUEST['filter'] : '');
     $aTableBody = array();
     if (!is_array($resources) || empty($resources)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd'));
     } else {
         foreach ($resources as $r) {
             // Resource name
             $action = $r['can_parse'] ? 'edit' : 'info';
             $name = Widget::TableData(Widget::Anchor($r['name'], SYMPHONY_URL . $_REQUEST['symphony-page'] . $action . '/' . $r['handle'] . '/', $r['handle']));
             // Resource type/source
             if (isset($r['source']['id'])) {
                 $section = Widget::TableData(Widget::Anchor($r['source']['name'], SYMPHONY_URL . '/blueprints/sections/edit/' . $r['source']['id'] . '/', $r['source']['handle']));
             } else {
                 if (class_exists($r['source']['name']) && method_exists($r['source']['name'], 'getSourceColumn')) {
                     $class = call_user_func(array($manager, '__getClassName'), $r['handle']);
                     $section = Widget::TableData(call_user_func(array($class, 'getSourceColumn'), $r['handle']));
                 } else {
                     if (isset($r['source']['name'])) {
                         $section = Widget::TableData($r['source']['name']);
                     } else {
                         $section = Widget::TableData(__('Unknown'), 'inactive');
                     }
                 }
             }
             // Attached pages
             $pages = ResourceManager::getAttachedPages($resource_type, $r['handle']);
             $pagelinks = array();
             $i = 0;
             foreach ($pages as $p) {
                 ++$i;
                 $pagelinks[] = Widget::Anchor($p['title'], SYMPHONY_URL . '/blueprints/pages/edit/' . $p['id'] . '/')->generate() . (count($pages) > $i ? $i % 10 == 0 ? '<br />' : ', ' : '');
             }
             $pages = implode('', $pagelinks);
             if ($pages == '') {
                 $pagelinks = Widget::TableData(__('None'), 'inactive');
             } else {
                 $pagelinks = Widget::TableData($pages, 'pages');
             }
             // Release date
             $releasedate = Widget::TableData(Lang::localizeDate(DateTimeObj::format($r['release-date'], __SYM_DATETIME_FORMAT__)));
             // Authors
             $author = $r['author']['name'];
             if (isset($r['author']['website'])) {
                 $author = Widget::Anchor($r['author']['name'], General::validateURL($r['author']['website']));
             } else {
                 if (isset($r['author']['email'])) {
                     $author = Widget::Anchor($r['author']['name'], 'mailto:' . $r['author']['email']);
                 }
             }
             $author = Widget::TableData($author);
             $author->appendChild(Widget::Input('items[' . $r['handle'] . ']', null, 'checkbox'));
             $aTableBody[] = Widget::TableRow(array($name, $section, $pagelinks, $releasedate, $author));
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'selectable');
     $this->Form->appendChild($table);
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm'));
     $pages = $this->pagesFlatView();
     $group_attach = array('label' => __('Attach to Page'), 'options' => array());
     $group_detach = array('label' => __('Detach from Page'), 'options' => array());
     $group_attach['options'][] = array('attach-all-pages', false, __('All'));
     $group_detach['options'][] = array('detach-all-pages', false, __('All'));
     foreach ($pages as $p) {
         $group_attach['options'][] = array('attach-to-page-' . $p['id'], false, $p['title']);
         $group_detach['options'][] = array('detach-from-page-' . $p['id'], false, $p['title']);
     }
     $options[] = $group_attach;
     $options[] = $group_detach;
     $tableActions->appendChild(Widget::Apply($options));
     $this->Form->appendChild($tableActions);
 }
 /**
  * This function contains the minimal amount of logic for generating the
  * index table of a given `$resource_type`. The table has name, source, pages
  * release date and author columns. The values for these columns are determined
  * by the resource's `about()` method.
  *
  * As Datasources types can be installed using Providers, the Source column
  * can be overridden with a Datasource's `getSourceColumn` method (if it exists).
  *
  * @param integer $resource_type
  *  Either `RESOURCE_TYPE_EVENT` or `RESOURCE_TYPE_DATASOURCE`
  * @throws InvalidArgumentException
  */
 public function __viewIndex($resource_type)
 {
     $manager = ResourceManager::getManagerFromType($resource_type);
     $friendly_resource = $resource_type === RESOURCE_TYPE_EVENT ? __('Event') : __('DataSource');
     $this->setPageType('table');
     Sortable::initialize($this, $resources, $sort, $order, array('type' => $resource_type));
     $columns = array(array('label' => __('Name'), 'sortable' => true, 'handle' => 'name'), array('label' => __('Source'), 'sortable' => true, 'handle' => 'source'), array('label' => __('Pages'), 'sortable' => false), array('label' => __('Author'), 'sortable' => true, 'handle' => 'author'));
     $aTableHead = Sortable::buildTableHeaders($columns, $sort, $order, isset($_REQUEST['filter']) ? '&amp;filter=' . $_REQUEST['filter'] : '');
     $aTableBody = array();
     if (!is_array($resources) || empty($resources)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', null, count($aTableHead))), 'odd'));
     } else {
         $context = Administration::instance()->getPageCallback();
         foreach ($resources as $r) {
             $action = 'edit';
             $status = null;
             $locked = null;
             // Locked resources
             if (isset($r['can_parse']) && $r['can_parse'] !== true) {
                 $action = 'info';
                 $status = 'status-notice';
                 $locked = array('data-status' => ' — ' . __('read only'));
             }
             // Resource name
             $action = isset($r['can_parse']) && $r['can_parse'] === true ? 'edit' : 'info';
             $name = Widget::TableData(Widget::Anchor($r['name'], SYMPHONY_URL . $context['pageroot'] . $action . '/' . $r['handle'] . '/', $r['handle'], 'resource-' . $action, null, $locked));
             $name->appendChild(Widget::Label(__('Select ' . $friendly_resource . ' %s', array($r['name'])), null, 'accessible', null, array('for' => 'resource-' . $r['handle'])));
             $name->appendChild(Widget::Input('items[' . $r['handle'] . ']', 'on', 'checkbox', array('id' => 'resource-' . $r['handle'])));
             // Resource type/source
             if (isset($r['source'], $r['source']['id'])) {
                 $section = Widget::TableData(Widget::Anchor($r['source']['name'], SYMPHONY_URL . '/blueprints/sections/edit/' . $r['source']['id'] . '/', $r['source']['handle']));
             } elseif (isset($r['source']) && class_exists($r['source']['name']) && method_exists($r['source']['name'], 'getSourceColumn')) {
                 $class = call_user_func(array($manager, '__getClassName'), $r['handle']);
                 $section = Widget::TableData(call_user_func(array($class, 'getSourceColumn'), $r['handle']));
             } elseif (isset($r['source'], $r['source']['name'])) {
                 $section = Widget::TableData($r['source']['name']);
             } else {
                 $section = Widget::TableData(__('Unknown'), 'inactive');
             }
             // Attached pages
             $pages = ResourceManager::getAttachedPages($resource_type, $r['handle']);
             $pagelinks = array();
             $i = 0;
             foreach ($pages as $p) {
                 ++$i;
                 $pagelinks[] = Widget::Anchor($p['title'], SYMPHONY_URL . '/blueprints/pages/edit/' . $p['id'] . '/')->generate() . (count($pages) > $i ? $i % 10 == 0 ? '<br />' : ', ' : '');
             }
             $pages = implode('', $pagelinks);
             if ($pages == '') {
                 $pagelinks = Widget::TableData(__('None'), 'inactive');
             } else {
                 $pagelinks = Widget::TableData($pages, 'pages');
             }
             // Authors
             $author = $r['author']['name'];
             if ($author) {
                 if (isset($r['author']['website'])) {
                     $author = Widget::Anchor($r['author']['name'], General::validateURL($r['author']['website']));
                 } elseif (isset($r['author']['email'])) {
                     $author = Widget::Anchor($r['author']['name'], 'mailto:' . $r['author']['email']);
                 }
             }
             $author = Widget::TableData($author);
             $aTableBody[] = Widget::TableRow(array($name, $section, $pagelinks, $author), $status);
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), null, Widget::TableBody($aTableBody), 'selectable', null, array('role' => 'directory', 'aria-labelledby' => 'symphony-subheading', 'data-interactive' => 'data-interactive'));
     $this->Form->appendChild($table);
     $version = new XMLElement('p', 'Symphony ' . Symphony::Configuration()->get('version', 'symphony'), array('id' => 'version'));
     $this->Form->appendChild($version);
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = array(array(null, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm'));
     $pages = $this->pagesFlatView();
     $group_attach = array('label' => __('Attach to Page'), 'options' => array());
     $group_detach = array('label' => __('Detach from Page'), 'options' => array());
     $group_attach['options'][] = array('attach-all-pages', false, __('All'));
     $group_detach['options'][] = array('detach-all-pages', false, __('All'));
     foreach ($pages as $p) {
         $group_attach['options'][] = array('attach-to-page-' . $p['id'], false, $p['title']);
         $group_detach['options'][] = array('detach-from-page-' . $p['id'], false, $p['title']);
     }
     $options[] = $group_attach;
     $options[] = $group_detach;
     /**
      * Allows an extension to modify the existing options for this page's
      * With Selected menu. If the `$options` parameter is an empty array,
      * the 'With Selected' menu will not be rendered.
      *
      * @delegate AddCustomActions
      * @since Symphony 2.3.2
      * @param string $context
      * '/blueprints/datasources/' or '/blueprints/events/'
      * @param array $options
      *  An array of arrays, where each child array represents an option
      *  in the With Selected menu. Options should follow the same format
      *  expected by `Widget::__SelectBuildOption`. Passed by reference.
      */
     Symphony::ExtensionManager()->notifyMembers('AddCustomActions', $context['pageroot'], array('options' => &$options));
     if (!empty($options)) {
         $tableActions->appendChild(Widget::Apply($options));
         $this->Form->appendChild($tableActions);
     }
 }
 public function __viewIndex()
 {
     $this->setPageType('table');
     $this->setTitle(__('%1$s &ndash; %2$s', array(__('Authors'), __('Symphony'))));
     if (Administration::instance()->Author->isDeveloper()) {
         $this->appendSubheading(__('Authors'), Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . 'new/', __('Create a new author'), 'create button', NULL, array('accesskey' => 'c')));
     } else {
         $this->appendSubheading(__('Authors'));
     }
     Sortable::initialize($this, $authors, $sort, $order);
     $columns = array(array('label' => __('Name'), 'sortable' => true, 'handle' => 'name'), array('label' => __('Email Address'), 'sortable' => true, 'handle' => 'email'), array('label' => __('Last Seen'), 'sortable' => true, 'handle' => 'last_seen'));
     if (Administration::instance()->Author->isDeveloper()) {
         $columns = array_merge($columns, array(array('label' => __('User Type'), 'sortable' => true, 'handle' => 'user_type'), array('label' => __('Language'), 'sortable' => true, 'handle' => 'language')));
     }
     $aTableHead = Sortable::buildTableHeaders($columns, $sort, $order, isset($_REQUEST['filter']) ? '&amp;filter=' . $_REQUEST['filter'] : '');
     $aTableBody = array();
     if (!is_array($authors) || empty($authors)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd'));
     } else {
         foreach ($authors as $a) {
             // Setup each cell
             if (Administration::instance()->Author->isDeveloper() || Administration::instance()->Author->get('id') == $a->get('id')) {
                 $td1 = Widget::TableData(Widget::Anchor($a->getFullName(), Administration::instance()->getCurrentPageURL() . 'edit/' . $a->get('id') . '/', $a->get('username'), 'author'));
             } else {
                 $td1 = Widget::TableData($a->getFullName(), 'inactive');
             }
             $td2 = Widget::TableData(Widget::Anchor($a->get('email'), 'mailto:' . $a->get('email'), __('Email this author')));
             if (!is_null($a->get('last_seen'))) {
                 $td3 = Widget::TableData(DateTimeObj::format($a->get('last_seen'), __SYM_DATETIME_FORMAT__));
             } else {
                 $td3 = Widget::TableData(__('Unknown'), 'inactive');
             }
             $td4 = Widget::TableData($a->isDeveloper() ? __("Developer") : __("Author"));
             $languages = Lang::getAvailableLanguages();
             $td5 = Widget::TableData($a->get("language") == NULL ? __("System Default") : $languages[$a->get("language")]);
             if (Administration::instance()->Author->isDeveloper()) {
                 if ($a->get('id') != Administration::instance()->Author->get('id')) {
                     $td3->appendChild(Widget::Input('items[' . $a->get('id') . ']', NULL, 'checkbox'));
                 }
             }
             // Add a row to the body array, assigning each cell to the row
             if (Administration::instance()->Author->isDeveloper()) {
                 $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3, $td4, $td5));
             } else {
                 $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3));
             }
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'selectable');
     $this->Form->appendChild($table);
     if (Administration::instance()->Author->isDeveloper()) {
         $tableActions = new XMLElement('div');
         $tableActions->setAttribute('class', 'actions');
         $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm', null, array('data-message' => __('Are you sure you want to delete the selected authors?'))));
         /**
          * Allows an extension to modify the existing options for this page's
          * With Selected menu. If the `$options` parameter is an empty array,
          * the 'With Selected' menu will not be rendered.
          *
          * @delegate AddCustomActions
          * @since Symphony 2.3.2
          * @param string $context
          * '/system/authors/'
          * @param array $options
          *  An array of arrays, where each child array represents an option
          *  in the With Selected menu. Options should follow the same format
          *  expected by `Widget::__SelectBuildOption`. Passed by reference.
          */
         Symphony::ExtensionManager()->notifyMembers('AddCustomActions', '/system/authors/', array('options' => &$options));
         if (!empty($options)) {
             $tableActions->appendChild(Widget::Apply($options));
             $this->Form->appendChild($tableActions);
         }
     }
 }