public function sort(&$sort, &$order, $params)
 {
     if (is_null($sort) || $sort == 'name') {
         $sort = 'name';
         return AuthorManager::fetch("first_name {$order},  last_name", $order);
     }
     return AuthorManager::fetch($sort, $order);
 }
Example #2
0
 public function sort(&$sort, &$order, $params)
 {
     if (is_null($sort) || $sort == 'name') {
         return AuthorManager::fetch("first_name {$order},  last_name", $order);
     } else {
         $sort = General::sanitize($sort);
     }
     return AuthorManager::fetch($sort, $order);
 }
 function __viewIndex()
 {
     $this->setPageType('table');
     $this->setTitle(__('%1$s – %2$s', array(__('Symphony'), __('Authors'))));
     if (Administration::instance()->Author->isDeveloper()) {
         $this->appendSubheading(__('Authors'), Widget::Anchor(__('Add an Author'), $this->_Parent->getCurrentPageURL() . 'new/', __('Add a new author'), 'create button'));
     } else {
         $this->appendSubheading(__('Authors'));
     }
     $authors = AuthorManager::fetch();
     $aTableHead = array(array(__('Name'), 'col'), array(__('Email Address'), 'col'), array(__('Last Seen'), 'col'));
     $aTableBody = array();
     if (!is_array($authors) || empty($authors)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd'));
     } else {
         $bOdd = true;
         foreach ($authors as $a) {
             if (intval($a->get('superuser')) == 1) {
                 $group = 'admin';
             } else {
                 $group = 'author';
             }
             ## Setup each cell
             if (Administration::instance()->Author->isDeveloper() || Administration::instance()->Author->get('id') == $a->get('id')) {
                 $td1 = Widget::TableData(Widget::Anchor($a->getFullName(), $this->_Parent->getCurrentPageURL() . 'edit/' . $a->get('id') . '/', $a->get('username'), $group));
             } else {
                 $td1 = Widget::TableData($a->getFullName(), 'inactive');
             }
             $td2 = Widget::TableData(Widget::Anchor($a->get('email'), 'mailto:' . $a->get('email'), 'Email this author'));
             if ($a->get('last_seen') != NULL) {
                 $td3 = Widget::TableData(DateTimeObj::get(__SYM_DATETIME_FORMAT__, strtotime($a->get('last_seen'))));
             } else {
                 $td3 = Widget::TableData('Unknown', 'inactive');
             }
             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
             $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3), $bOdd ? 'odd' : NULL);
             $bOdd = !$bOdd;
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody));
     $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')));
         $tableActions->appendChild(Widget::Select('with-selected', $options));
         $tableActions->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));
         $this->Form->appendChild($tableActions);
     }
 }
 /**
  * I absolutely stole this next bit! Thank you craig zheng (craig@symphony-cms.com) :)
  * 	via the Tracker extension
  */
 public function appendPreferences($context)
 {
     include_once TOOLKIT . '/class.authormanager.php';
     include_once TOOLKIT . '/class.sectionmanager.php';
     // Fieldset and layout
     $group = new XMLElement('fieldset');
     $group->setAttribute('class', 'settings');
     $group->appendChild(new XMLElement('legend', __('Mass Upload Utility')));
     $div = new XMLElement('div');
     $div->setAttribute('class', 'group double');
     // Excluded Sections
     $label = Widget::Label(__('Excluded Sections'));
     $options = array();
     $sections = SectionManager::fetch();
     $excluded_sections = explode(',', Symphony::Configuration()->get('excluded-sections', 'massuploadutility'));
     if (!empty($sections) && is_array($sections)) {
         foreach ($sections as $section) {
             $selected = in_array($section->get('id'), $excluded_sections) ? TRUE : FALSE;
             $options[] = array($section->get('id'), $selected, $section->get('name'));
         }
     }
     $input = Widget::Select('settings[massuploadutility][excluded-sections][]', $options, array('multiple' => 'multiple'));
     $label->appendChild($input);
     $div->appendChild($label);
     // Excluded Users
     $label = Widget::Label(__('Excluded Users'));
     $options = array();
     $am = new AuthorManager(Administration::instance());
     $authors = $am->fetch();
     $excluded_authors = explode(',', Symphony::Configuration()->get('excluded-users', 'massuploadutility'));
     if (!empty($authors) && is_array($authors)) {
         foreach ($authors as $author) {
             $selected = in_array($author->get('id'), $excluded_authors) ? TRUE : FALSE;
             $options[] = array($author->get('id'), $selected, $author->getFullName());
         }
     }
     $input = Widget::Select('settings[massuploadutility][excluded-users][]', $options, array('multiple' => 'multiple'));
     $label->appendChild($input);
     $div->appendChild($label);
     $group->appendChild($div);
     $context['wrapper']->appendChild($group);
 }
Example #5
0
 /**
  * Overload the Symphony::login function to bypass some code that
  * forces use of the Administration class (which of course is not
  * available in Shell). Hopefully this is fixed in the core Symphony code
  *
  */
 public static function login($username, $password, $isHash = false)
 {
     $username = self::Database()->cleanValue($username);
     $password = self::Database()->cleanValue($password);
     if (strlen(trim($username)) > 0 && strlen(trim($password)) > 0) {
         $author = \AuthorManager::fetch('id', 'ASC', 1, null, sprintf("\n                `username` = '%s'\n                ", $username));
         if (!empty($author) && \Cryptography::compare($password, current($author)->get('password'), $isHash)) {
             self::$Author = current($author);
             // Only migrate hashes if there is no update available as the update might change the tbl_authors table.
             if (\Cryptography::requiresMigration(self::$Author->get('password'))) {
                 throw new ShellException('User details require updating. Please login to the admin interface.');
             }
             self::$Cookie->set('username', $username);
             self::$Cookie->set('pass', self::$Author->get('password'));
             self::Database()->update(array('last_seen' => \DateTimeObj::get('Y-m-d H:i:s')), 'tbl_authors', sprintf(" `id` = %d", self::$Author->get('id')));
             return true;
         }
     }
     return false;
 }
 public static function get()
 {
     $url_parts = REST_API::getRequestURI();
     $author_url = $url_parts[0];
     $response = new XMLElement('response');
     if (isset($author_url)) {
         if (is_numeric($author_url)) {
             $author = AuthorManager::fetchByID($author_url);
         } else {
             $author = AuthorManager::fetchByUsername($author_url);
         }
         if (!$author) {
             REST_API::sendError('Author not found.', 404);
         }
         $response->appendChild(self::__buildAuthorXML($author));
     } else {
         $authors = AuthorManager::fetch();
         foreach ($authors as $author) {
             $response->appendChild(self::__buildAuthorXML($author));
         }
     }
     REST_API::sendOutput($response);
 }
Example #7
0
 public function getExampleFormMarkup()
 {
     $authors = AuthorManager::fetch();
     $options = array();
     foreach ($authors as $a) {
         $options[] = array($a->get('id'), null, $a->getFullName());
     }
     $fieldname = 'fields[' . $this->get('element_name') . ']';
     if ($this->get('allow_multiple_selection') === 'yes') {
         $fieldname .= '[]';
     }
     $attr = array();
     if ($this->get('allow_multiple_selection') === 'yes') {
         $attr['multiple'] = 'multiple';
     }
     $label = Widget::Label($this->get('label'));
     $label->appendChild(Widget::Select($fieldname, $options, $attr));
     return $label;
 }
Example #8
0
 /**
  * This function determines whether an there is a currently logged in
  * Author for Symphony by using the `$Cookie`'s username
  * and password. If an Author is found, they will be logged in, otherwise
  * the `$Cookie` will be destroyed.
  *
  * @see core.Cookie#expire()
  */
 public function isLoggedIn()
 {
     // Ensures that we're in the real world.. Also reduces three queries from database
     // We must return true otherwise exceptions are not shown
     if (is_null(self::$_instance)) {
         return true;
     }
     if ($this->Author) {
         return true;
     } else {
         $username = self::Database()->cleanValue($this->Cookie->get('username'));
         $password = self::Database()->cleanValue($this->Cookie->get('pass'));
         if (strlen(trim($username)) > 0 && strlen(trim($password)) > 0) {
             $author = AuthorManager::fetch('id', 'ASC', 1, null, sprintf("\n\t\t\t\t\t\t\t`username` = '%s'\n\t\t\t\t\t\t", $username));
             if (!empty($author) && Cryptography::compare($password, current($author)->get('password'), true)) {
                 $this->Author = current($author);
                 self::Database()->update(array('last_seen' => DateTimeObj::get('Y-m-d H:i:s')), 'tbl_authors', sprintf(" `id` = %d", $this->Author->get('id')));
                 // Only set custom author language in the backend
                 if (class_exists('Administration')) {
                     Lang::set($this->Author->get('language'));
                 }
                 return true;
             }
         }
         $this->Cookie->expire();
         return false;
     }
 }
Example #9
0
 /**
  * Attempts to log an Author in given a username and password.
  * If the password is not hashed, it will be hashed using the sha1
  * algorithm. The username and password will be sanitized before
  * being used to query the Database. If an Author is found, they
  * will be logged in and the sanitized username and password (also hashed)
  * will be saved as values in the `$Cookie`.
  *
  * @see toolkit.Cryptography#hash()
  * @throws DatabaseException
  * @param string $username
  *  The Author's username. This will be sanitized before use.
  * @param string $password
  *  The Author's password. This will be sanitized and then hashed before use
  * @param boolean $isHash
  *  If the password provided is already hashed, setting this parameter to
  *  true will stop it becoming rehashed. By default it is false.
  * @return boolean
  *  True if the Author was logged in, false otherwise
  */
 public static function login($username, $password, $isHash = false)
 {
     $username = trim(self::Database()->cleanValue($username));
     $password = trim(self::Database()->cleanValue($password));
     if (strlen($username) > 0 && strlen($password) > 0) {
         $author = AuthorManager::fetch('id', 'ASC', 1, null, sprintf("`username` = '%s'", $username));
         if (!empty($author) && Cryptography::compare($password, current($author)->get('password'), $isHash)) {
             self::$Author = current($author);
             // Only migrate hashes if there is no update available as the update might change the tbl_authors table.
             if (self::isUpgradeAvailable() === false && Cryptography::requiresMigration(self::$Author->get('password'))) {
                 self::$Author->set('password', Cryptography::hash($password));
                 self::Database()->update(array('password' => self::$Author->get('password')), 'tbl_authors', sprintf(" `id` = %d", self::$Author->get('id')));
             }
             self::$Cookie->set('username', $username);
             self::$Cookie->set('pass', self::$Author->get('password'));
             self::Database()->update(array('last_seen' => DateTimeObj::get('Y-m-d H:i:s')), 'tbl_authors', sprintf(" `id` = %d", self::$Author->get('id')));
             // Only set custom author language in the backend
             if (class_exists('Administration', false)) {
                 Lang::set(self::$Author->get('language'));
             }
             return true;
         }
     }
     return false;
 }
 public function execute(array &$param_pool = null)
 {
     $author_ids = array();
     if (is_array($this->dsParamFILTERS) && !empty($this->dsParamFILTERS)) {
         foreach ($this->dsParamFILTERS as $field => $value) {
             if (!is_array($value) && trim($value) == '') {
                 continue;
             }
             $ret = $this->__processAuthorFilter($field, $value);
             if (empty($ret)) {
                 $author_ids = array();
                 break;
             }
             if (empty($author_ids)) {
                 $author_ids = $ret;
                 continue;
             }
             $author_ids = array_intersect($author_ids, $ret);
         }
         $authors = AuthorManager::fetchByID(array_values($author_ids));
     } else {
         $authors = AuthorManager::fetch($this->dsParamSORT, $this->dsParamORDER);
     }
     if ((!is_array($authors) || empty($authors)) && $this->dsParamREDIRECTONEMPTY == 'yes') {
         throw new FrontendPageNotFoundException();
     } elseif (!is_array($authors) || empty($authors)) {
         $result = $this->emptyXMLSet();
         return $result;
     } else {
         if (!$this->_param_output_only) {
             $result = new XMLElement($this->dsParamROOTELEMENT);
         }
         $singleParam = false;
         $key = 'ds-' . $this->dsParamROOTELEMENT;
         if (isset($this->dsParamPARAMOUTPUT)) {
             if (!is_array($this->dsParamPARAMOUTPUT)) {
                 $this->dsParamPARAMOUTPUT = array($this->dsParamPARAMOUTPUT);
             }
             $singleParam = count($this->dsParamPARAMOUTPUT) === 1;
         }
         foreach ($authors as $author) {
             if (isset($this->dsParamPARAMOUTPUT)) {
                 foreach ($this->dsParamPARAMOUTPUT as $param) {
                     // The new style of paramater is `ds-datasource-handle.field-handle`
                     $param_key = $key . '.' . str_replace(':', '-', $param);
                     if (!is_array($param_pool[$param_key])) {
                         $param_pool[$param_key] = array();
                     }
                     $param_pool[$param_key][] = $param === 'name' ? $author->getFullName() : $author->get($param);
                     if ($singleParam) {
                         if (!is_array($param_pool[$key])) {
                             $param_pool[$key] = array();
                         }
                         $param_pool[$key][] = $param === 'name' ? $author->getFullName() : $author->get($param);
                     }
                 }
             }
             if ($this->_param_output_only) {
                 continue;
             }
             $xAuthor = new XMLElement('author');
             $xAuthor->setAttributeArray(array('id' => $author->get('id'), 'user-type' => $author->get('user_type'), 'primary-account' => $author->get('primary')));
             // No included elements, so just create the Author XML
             if (!isset($this->dsParamINCLUDEDELEMENTS) || !is_array($this->dsParamINCLUDEDELEMENTS) || empty($this->dsParamINCLUDEDELEMENTS)) {
                 $result->appendChild($xAuthor);
             } else {
                 // Name
                 if (in_array('name', $this->dsParamINCLUDEDELEMENTS)) {
                     $xAuthor->appendChild(new XMLElement('name', $author->getFullName()));
                 }
                 // Username
                 if (in_array('username', $this->dsParamINCLUDEDELEMENTS)) {
                     $xAuthor->appendChild(new XMLElement('username', $author->get('username')));
                 }
                 // Email
                 if (in_array('email', $this->dsParamINCLUDEDELEMENTS)) {
                     $xAuthor->appendChild(new XMLElement('email', $author->get('email')));
                 }
                 // Author Token
                 if (in_array('author-token', $this->dsParamINCLUDEDELEMENTS) && $author->isTokenActive()) {
                     $xAuthor->appendChild(new XMLElement('author-token', $author->createAuthToken()));
                 }
                 // Default Area
                 if (in_array('default-area', $this->dsParamINCLUDEDELEMENTS) && !is_null($author->get('default_area'))) {
                     // Section
                     if ($section = SectionManager::fetch($author->get('default_area'))) {
                         $default_area = new XMLElement('default-area', $section->get('name'));
                         $default_area->setAttributeArray(array('id' => $section->get('id'), 'handle' => $section->get('handle'), 'type' => 'section'));
                         $xAuthor->appendChild($default_area);
                     } else {
                         $default_area = new XMLElement('default-area', $author->get('default_area'));
                         $default_area->setAttribute('type', 'page');
                         $xAuthor->appendChild($default_area);
                     }
                 }
                 $result->appendChild($xAuthor);
             }
         }
     }
     return $result;
 }
Example #11
0
 public function appendPreferences($context)
 {
     include_once TOOLKIT . '/class.authormanager.php';
     include_once TOOLKIT . '/class.sectionmanager.php';
     // Fieldset and layout
     $group = new XMLElement('fieldset');
     $group->setAttribute('class', 'settings');
     $group->appendChild(new XMLElement('legend', __('Tracker')));
     $div = new XMLElement('div');
     $div->setAttribute('class', 'group triple');
     // Excluded System Elements
     $label = Widget::Label(__('Excluded System Elements'));
     $options = array();
     $elements = array('authors' => __('Authors'), 'datasources' => __('Data Sources'), 'events' => __('Events'), 'pages' => __('Pages'), 'sections' => __('Sections'), 'utilities' => __('Utilities'), 'preferences' => __('Preferences'), 'extensions' => __('Extensions'), 'login' => __('Login/Logout'), 'password' => __('Password Reset'));
     $excluded_elements = explode(',', Symphony::Configuration()->get('excluded-system-elements', 'tracker'));
     foreach ($elements as $handle => $value) {
         $selected = in_array($handle, $excluded_elements) ? TRUE : FALSE;
         $options[] = array($handle, $selected, $value);
     }
     $input = Widget::Select('settings[tracker][excluded-system-elements][]', $options, array('multiple' => 'multiple'));
     $label->appendChild($input);
     $div->appendChild($label);
     // Excluded Sections
     $label = Widget::Label(__('Excluded Sections'));
     $options = array();
     $sm = new SectionManager(Administration::instance());
     $sections = $sm->fetch();
     $excluded_sections = explode(',', Symphony::Configuration()->get('excluded-sections', 'tracker'));
     if (!empty($sections) && is_array($sections)) {
         foreach ($sections as $section) {
             $selected = in_array($section->get('id'), $excluded_sections) ? TRUE : FALSE;
             $options[] = array($section->get('id'), $selected, $section->get('name'));
         }
     }
     $input = Widget::Select('settings[tracker][excluded-sections][]', $options, array('multiple' => 'multiple'));
     $label->appendChild($input);
     $div->appendChild($label);
     // Excluded Users
     $label = Widget::Label(__('Excluded Users'));
     $options = array();
     $am = new AuthorManager(Administration::instance());
     $authors = $am->fetch();
     $excluded_authors = explode(',', Symphony::Configuration()->get('excluded-users', 'tracker'));
     if (!empty($authors) && is_array($authors)) {
         foreach ($authors as $author) {
             $selected = in_array($author->get('id'), $excluded_authors) ? TRUE : FALSE;
             $options[] = array($author->get('id'), $selected, $author->getFullName());
         }
     }
     $input = Widget::Select('settings[tracker][excluded-users][]', $options, array('multiple' => 'multiple'));
     $label->appendChild($input);
     $div->appendChild($label);
     $group->appendChild($div);
     // notify url of tracker event
     $notify_url = Symphony::Configuration()->get('notify_url', 'tracker');
     $notify_label = Widget::Label(__('Send tracker event to URL'));
     $notify_label->appendChild(Widget::Input('settings[tracker][notify_url]', $notify_url, 'text'));
     $group->appendChild($notify_label);
     $context['wrapper']->appendChild($group);
 }
Example #12
0
 function __viewIndex()
 {
     $sectionManager = new SectionManager($this->_Parent);
     if (!($section_id = $sectionManager->fetchIDFromHandle($this->_context['section_handle']))) {
         $this->_Parent->customError(E_USER_ERROR, __('Unknown Section'), __('The Section you are looking, <code>%s</code> for could not be found.', array($this->_context['section_handle'])), false, true);
     }
     $section = $sectionManager->fetch($section_id);
     $this->setPageType('table');
     $this->setTitle(__('%1$s &ndash; %2$s', array(__('Symphony'), $section->get('name'))));
     $this->Form->setAttribute("class", $this->_context['section_handle']);
     $entryManager = new EntryManager($this->_Parent);
     $authors = AuthorManager::fetch();
     $filter = $filter_value = $where = $joins = NULL;
     $current_page = isset($_REQUEST['pg']) && is_numeric($_REQUEST['pg']) ? max(1, intval($_REQUEST['pg'])) : 1;
     if (isset($_REQUEST['filter'])) {
         list($field_handle, $filter_value) = explode(':', $_REQUEST['filter'], 2);
         $field_names = explode(',', $field_handle);
         foreach ($field_names as $field_name) {
             $filter_value = rawurldecode($filter_value);
             $filter = Symphony::Database()->fetchVar('id', 0, "SELECT `f`.`id` \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   FROM `tbl_fields` AS `f`, `tbl_sections` AS `s` \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   WHERE `s`.`id` = `f`.`parent_section` \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   AND f.`element_name` = '{$field_name}' \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   AND `s`.`handle` = '" . $section->get('handle') . "' LIMIT 1");
             $field =& $entryManager->fieldManager->fetch($filter);
             if (is_object($field)) {
                 $field->buildDSRetrivalSQL(array($filter_value), $joins, $where, false);
                 $filter_value = rawurlencode($filter_value);
             }
         }
         if ($where != null) {
             $where = str_replace('AND', 'OR', $where);
             // multiple fields need to be OR
             $where = trim($where);
             $where = ' AND (' . substr($where, 2, strlen($where)) . ')';
             // replace leading OR with AND
         }
     }
     if (isset($_REQUEST['sort']) && is_numeric($_REQUEST['sort'])) {
         $sort = intval($_REQUEST['sort']);
         $order = $_REQUEST['order'] ? strtolower($_REQUEST['order']) : 'asc';
         if ($section->get('entry_order') != $sort || $section->get('entry_order_direction') != $order) {
             $sectionManager->edit($section->get('id'), array('entry_order' => $sort, 'entry_order_direction' => $order));
             redirect($this->_Parent->getCurrentPageURL() . ($filter ? "?filter={$field_handle}:{$filter_value}" : ''));
         }
     } elseif (isset($_REQUEST['unsort'])) {
         $sectionManager->edit($section->get('id'), array('entry_order' => NULL, 'entry_order_direction' => NULL));
         redirect($this->_Parent->getCurrentPageURL());
     }
     $this->Form->setAttribute('action', $this->_Parent->getCurrentPageURL() . '?pg=' . $current_page . ($filter ? "&amp;filter={$field_handle}:{$filter_value}" : ''));
     ## Remove the create button if there is a section link field, and no filtering set for it
     $section_links = $section->fetchFields('sectionlink');
     if (count($section_links) > 1 || !$filter && $section_links || is_object($section_links[0]) && $filter != $section_links[0]->get('id')) {
         $this->appendSubheading($section->get('name'));
     } else {
         $this->appendSubheading($section->get('name'), Widget::Anchor(__('Create New'), $this->_Parent->getCurrentPageURL() . 'new/' . ($filter ? '?prepopulate[' . $filter . ']=' . $filter_value : ''), __('Create a new entry'), 'create button'));
     }
     if (is_null($entryManager->getFetchSorting()->field) && is_null($entryManager->getFetchSorting()->direction)) {
         $entryManager->setFetchSortingDirection('DESC');
     }
     $entries = $entryManager->fetchByPage($current_page, $section_id, Symphony::Configuration()->get('pagination_maximum_rows', 'symphony'), $where, $joins);
     $aTableHead = array();
     $visible_columns = $section->fetchVisibleColumns();
     if (is_array($visible_columns) && !empty($visible_columns)) {
         foreach ($visible_columns as $column) {
             $label = $column->get('label');
             if ($column->isSortable()) {
                 if ($column->get('id') == $section->get('entry_order')) {
                     $link = $this->_Parent->getCurrentPageURL() . '?pg=' . $current_page . '&amp;sort=' . $column->get('id') . '&amp;order=' . ($section->get('entry_order_direction') == 'desc' ? 'asc' : 'desc') . ($filter ? "&amp;filter={$field_handle}:{$filter_value}" : '');
                     $anchor = Widget::Anchor($label, $link, __('Sort by %1$s %2$s', array($section->get('entry_order_direction') == 'desc' ? __('ascending') : __('descending'), strtolower($column->get('label')))), 'active');
                 } else {
                     $link = $this->_Parent->getCurrentPageURL() . '?pg=' . $current_page . '&amp;sort=' . $column->get('id') . '&amp;order=asc' . ($filter ? "&amp;filter={$field_handle}:{$filter_value}" : '');
                     $anchor = Widget::Anchor($label, $link, __('Sort by %1$s %2$s', array(__('ascending'), strtolower($column->get('label')))));
                 }
                 $aTableHead[] = array($anchor, 'col');
             } else {
                 $aTableHead[] = array($label, 'col');
             }
         }
     } else {
         $aTableHead[] = array(__('ID'), 'col');
     }
     $child_sections = NULL;
     $associated_sections = $section->fetchAssociatedSections();
     if (is_array($associated_sections) && !empty($associated_sections)) {
         $child_sections = array();
         foreach ($associated_sections as $key => $as) {
             $child_sections[$key] = $sectionManager->fetch($as['child_section_id']);
             $aTableHead[] = array($child_sections[$key]->get('name'), 'col');
         }
     }
     ## 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 {
         $bOdd = true;
         $field_pool = array();
         if (is_array($visible_columns) && !empty($visible_columns)) {
             foreach ($visible_columns as $column) {
                 $field_pool[$column->get('id')] = $column;
             }
         }
         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'), $this->_Parent->getCurrentPageURL() . 'edit/' . $entry->get('id') . '/'));
             } else {
                 $link = Widget::Anchor('None', $this->_Parent->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, $position == 0 ? $link : null, $entry->get('id'));
                     if (!is_object($value) && strlen(trim($value)) == 0) {
                         $value = $position == 0 ? $link->generate() : __('None');
                     }
                     if ($value == 'None') {
                         $tableData[] = Widget::TableData($value, 'inactive');
                     } else {
                         $tableData[] = Widget::TableData($value);
                     }
                     unset($field);
                 }
             }
             if (is_array($child_sections) && !empty($child_sections)) {
                 foreach ($child_sections as $key => $as) {
                     $field = $entryManager->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');
                     }
                     $associated_entry_count = $field->fetchAssociatedEntryCount($search_value);
                     $tableData[] = Widget::TableData(Widget::Anchor(sprintf('%d &rarr;', max(0, intval($associated_entry_count))), sprintf('%s/symphony/publish/%s/?filter=%s:%s', URL, $as->get('handle'), $field->get('element_name'), rawurlencode($search_value)), $entry->get('id'), 'content'));
                 }
             }
             $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, $bOdd ? 'odd' : NULL);
             $bOdd = !$bOdd;
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody));
     $this->Form->appendChild($table);
     $tableActions = new XMLElement('div');
     $tableActions->setAttribute('class', 'actions');
     $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete')));
     $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::Select('with-selected', $options));
     $tableActions->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));
     $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'), $this->_Parent->getCurrentPageURL() . '?pg=1' . ($filter ? "&amp;filter={$field_handle}:{$filter_value}" : '')));
         } else {
             $li->setValue(__('First'));
         }
         $ul->appendChild($li);
         ## Previous
         $li = new XMLElement('li');
         if ($current_page > 1) {
             $li->appendChild(Widget::Anchor(__('&larr; Previous'), $this->_Parent->getCurrentPageURL() . '?pg=' . ($current_page - 1) . ($filter ? "&amp;filter={$field_handle}:{$filter_value}" : '')));
         } 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, $entries['total-pages']))));
         $li->setAttribute('title', __('Viewing %1$s - %2$s of %3$s entries', array($entries['start'], min($entries['limit'], max(1, $entries['remaining-entries'])), $entries['total-entries'])));
         $ul->appendChild($li);
         ## Next
         $li = new XMLElement('li');
         if ($current_page < $entries['total-pages']) {
             $li->appendChild(Widget::Anchor(__('Next &rarr;'), $this->_Parent->getCurrentPageURL() . '?pg=' . ($current_page + 1) . ($filter ? "&amp;filter={$field_handle}:{$filter_value}" : '')));
         } else {
             $li->setValue(__('Next &rarr;'));
         }
         $ul->appendChild($li);
         ## Last
         $li = new XMLElement('li');
         if ($current_page < $entries['total-pages']) {
             $li->appendChild(Widget::Anchor(__('Last'), $this->_Parent->getCurrentPageURL() . '?pg=' . $entries['total-pages'] . ($filter ? "&amp;filter={$field_handle}:{$filter_value}" : '')));
         } else {
             $li->setValue(__('Last'));
         }
         $ul->appendChild($li);
         $this->Form->appendChild($ul);
     }
 }
            continue;
        }
        $ret = __processAuthorFilter($field, $value, Symphony::Database());
        if (empty($ret)) {
            $author_ids = array();
            break;
        }
        if (empty($author_ids)) {
            $author_ids = $ret;
            continue;
        }
        $author_ids = array_intersect($author_ids, $ret);
    }
    $authors = AuthorManager::fetchByID(array_values($author_ids), $this->dsParamSORT, $this->dsParamORDER, $this->dsParamLIMIT, max(0, $this->dsParamSTARTPAGE - 1) * $this->dsParamLIMIT);
} else {
    $authors = AuthorManager::fetch($this->dsParamSORT, $this->dsParamORDER, $this->dsParamLIMIT, max(0, $this->dsParamSTARTPAGE - 1) * $this->dsParamLIMIT);
}
if ((!is_array($authors) || empty($authors)) && $this->dsParamREDIRECTONEMPTY == 'yes') {
    throw new FrontendPageNotFoundException();
} else {
    if (!$this->_param_output_only) {
        $result = new XMLElement($this->dsParamROOTELEMENT);
    }
    foreach ($authors as $author) {
        if (isset($this->dsParamPARAMOUTPUT)) {
            $key = 'ds-' . $this->dsParamROOTELEMENT;
            if (!is_array($param_pool[$key])) {
                $param_pool[$key] = array();
            }
            $param_pool[$key][] = $this->dsParamPARAMOUTPUT == 'name' ? $author->getFullName() : $author->get($this->dsParamPARAMOUTPUT);
        }
 *
 * @version 1.7
 * @licence https://github.com/symphonycms/symphony-1.7/blob/master/LICENCE
 *
 ***/
$GLOBALS['pageTitle'] = "Authors";
if (isset($_GET['_f'])) {
    switch ($_GET['_f']) {
        case "complete":
            $Admin->pageAlert("selected-success", array("Author(s)", "deleted"));
            break;
    }
}
include_once TOOLKIT . "/class.authormanager.php";
$authorManager = new AuthorManager($Admin);
$authors = $authorManager->fetch();
$date = new SymDate($Admin->getConfigVar("time_zone", "region"), $Admin->getConfigVar("date_format", "region"));
$new_button = $Admin->authorIsSuper() ? '<a class="create button" href="' . $Admin->getCurrentPageURL() . 'new/" title="Add an author">Create New</a>' : "";
?>
	<form action="<?php 
print $Admin->getCurrentPageURL();
?>
" method="post">
		<h2><!-- PAGE TITLE --> <?php 
print $new_button;
?>
</h2>
		<table>
			<thead>
				<tr>
					<th scope="col">Name</th>
Example #15
0
            continue;
        }
        $ret = __processAuthorFilter($field, $value, Symphony::Database());
        if (empty($ret)) {
            $author_ids = array();
            break;
        }
        if (empty($author_ids)) {
            $author_ids = $ret;
            continue;
        }
        $author_ids = array_intersect($author_ids, $ret);
    }
    $authors = AuthorManager::fetchByID(array_values($author_ids), $this->dsParamSORT, $this->dsParamORDER);
} else {
    $authors = AuthorManager::fetch($this->dsParamSORT, $this->dsParamORDER);
}
if ((!is_array($authors) || empty($authors)) && $this->dsParamREDIRECTONEMPTY == 'yes') {
    throw new FrontendPageNotFoundException();
} else {
    if (!$this->_param_output_only) {
        $result = new XMLElement($this->dsParamROOTELEMENT);
    }
    foreach ($authors as $author) {
        if (isset($this->dsParamPARAMOUTPUT)) {
            $key = 'ds-' . $this->dsParamROOTELEMENT;
            if (!is_array($param_pool[$key])) {
                $param_pool[$key] = array();
            }
            $param_pool[$key][] = $this->dsParamPARAMOUTPUT == 'name' ? $author->getFullName() : $author->get($this->dsParamPARAMOUTPUT);
        }