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(__('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()
 {
     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);
     }
 }
Пример #4
0
 public function prepareTableValue($data, XMLElement $link = null, $entry_id = null)
 {
     $sectionManager = new SectionManager(Symphony::Engine());
     $section = $sectionManager->fetch($this->get('linked_section_id'));
     $entryManager = new EntryManager(Symphony::Engine());
     $fieldManager = new FieldManager(Symphony::Engine());
     $linked = $fieldManager->fetch($this->get('linked_field_id'));
     $custom_link = null;
     $more_link = null;
     // Not setup correctly:
     if (!$section instanceof Section or !$linked) {
         return parent::prepareTableValue(array(), $link, $entry_id);
     }
     if (!empty($data['linked_entry_id'])) {
         $field = current($section->fetchVisibleColumns());
         $data = $this->prepareData($data);
         if (!is_null($field) && $data['linked_entry_id']) {
             if ($this->get('column_mode') != 'count') {
                 if ($this->get('column_mode') == 'last-item') {
                     $data['linked_entry_id'] = array_reverse($data['linked_entry_id']);
                 }
                 $entries = $entryManager->fetch(current($data['linked_entry_id']), $this->get('linked_section_id'), 1);
                 if (is_array($entries) and !empty($entries)) {
                     $entry = current($entries);
                     $value = $field->prepareTableValue($entry->getData($field->get('id')), new XMLElement('span'));
                     $custom_link = new XMLElement('a');
                     $custom_link->setAttribute('href', sprintf('%s/symphony/publish/%s/edit/%s/', URL, $section->get('handle'), $entry->get('id')));
                     if ($value instanceof XMLElement) {
                         $value = $value->generate();
                     }
                     $custom_link->setValue(strip_tags($value));
                     $more_link = new XMLElement('a');
                     $more_link->setValue(__('more →'));
                     $more_link->setAttribute('href', sprintf('%s/symphony/publish/%s/?filter=%s:%s', URL, $section->get('handle'), $linked->get('element_name'), $entry_id));
                 }
             } else {
                 $joins = null;
                 $where = null;
                 $linked->buildDSRetrivalSQL(array($entry_id), $joins, $where, false);
                 $count = $entryManager->fetchCount($this->get('linked_section_id'), $where, $joins);
                 if ($count > 0) {
                     $custom_link = new XMLElement('a');
                     $custom_link->setValue($count . __(' →'));
                     $custom_link->setAttribute('href', sprintf('%s/symphony/publish/%s/?filter=%s:%s', URL, $section->get('handle'), $linked->get('element_name'), $entry_id));
                 }
             }
         }
     }
     if (is_null($custom_link)) {
         $custom_link = new XMLElement('a');
         $custom_link->setValue(__('0 →'));
         $custom_link->setAttribute('href', sprintf('%s/symphony/publish/%s/?filter=%s:%s', URL, $section->get('handle'), $linked->get('element_name'), $entry_id));
         if ($this->get('column_mode') != 'count') {
             $more_link = $custom_link;
             $more_link->setValue(__('more →'));
             $custom_link = new XMLElement('span');
             $custom_link->setAttribute('class', 'inactive');
             $custom_link->setValue(__('None'));
         }
     }
     if ($link) {
         $link->setValue($custom_link->getValue());
         return $link->generate();
     }
     if ($this->get('column_mode') != 'count') {
         $wrapper = new XMLElement('span');
         $wrapper->setValue(sprintf('%s, %s', $custom_link->generate(), $more_link->generate()));
         return $wrapper;
     }
     return $custom_link;
 }
Пример #5
0
 public function render_panel($context)
 {
     $config = $context['config'];
     switch ($context['type']) {
         case 'datasource_to_table':
             $ds = DatasourceManager::create($config['datasource'], NULL, false);
             if (!$ds) {
                 $context['panel']->appendChild(new XMLElement('div', __('The Data Source with the name <code>%s</code> could not be found.', array($config['datasource']))));
                 return;
             }
             $param_pool = array();
             $xml = $ds->grab($param_pool);
             if (!$xml) {
                 return;
             }
             $xml = $xml->generate();
             require_once TOOLKIT . '/class.xsltprocess.php';
             $proc = new XsltProcess();
             $data = $proc->process($xml, file_get_contents(EXTENSIONS . '/dashboard/lib/datasource-to-table.xsl'));
             $context['panel']->appendChild(new XMLElement('div', $data));
             break;
         case 'rss_reader':
             require_once TOOLKIT . '/class.gateway.php';
             require_once CORE . '/class.cacheable.php';
             $cache_id = md5('rss_reader_cache' . $config['url']);
             $cache = new Cacheable(Administration::instance()->Database());
             $data = $cache->check($cache_id);
             if (!$data) {
                 $ch = new Gateway();
                 $ch->init();
                 $ch->setopt('URL', $config['url']);
                 $ch->setopt('TIMEOUT', 6);
                 $new_data = $ch->exec();
                 $writeToCache = true;
                 if ((int) $config['cache'] > 0) {
                     $cache->write($cache_id, $new_data, $config['cache']);
                 }
                 $xml = $new_data;
                 if (empty($xml) && $data) {
                     $xml = $data['data'];
                 }
             } else {
                 $xml = $data['data'];
             }
             if (!$xml) {
                 $xml = '<error>' . __('Error: could not retrieve panel XML feed.') . '</error>';
             }
             require_once TOOLKIT . '/class.xsltprocess.php';
             $proc = new XsltProcess();
             $data = $proc->process($xml, file_get_contents(EXTENSIONS . '/dashboard/lib/rss-reader.xsl'), array('show' => $config['show']));
             $context['panel']->appendChild(new XMLElement('div', $data));
             break;
         case 'html_block':
             require_once TOOLKIT . '/class.gateway.php';
             require_once CORE . '/class.cacheable.php';
             $cache_id = md5('html_block_' . $config['url']);
             $cache = new Cacheable(Administration::instance()->Database());
             $data = $cache->check($cache_id);
             if (!$data) {
                 $ch = new Gateway();
                 $ch->init();
                 $ch->setopt('URL', $config['url']);
                 $ch->setopt('TIMEOUT', 6);
                 $new_data = $ch->exec();
                 $writeToCache = true;
                 if ((int) $config['cache'] > 0) {
                     $cache->write($cache_id, $new_data, $config['cache']);
                 }
                 $html = $new_data;
                 if (empty($html) && $data) {
                     $html = $data['data'];
                 }
             } else {
                 $html = $data['data'];
             }
             if (!$html) {
                 $html = '<p class="invalid">' . __('Error: could not retrieve panel HTML.') . '</p>';
             }
             $context['panel']->appendChild(new XMLElement('div', $html));
             break;
         case 'symphony_overview':
             $container = new XMLElement('div');
             $dl = new XMLElement('dl');
             $dl->appendChild(new XMLElement('dt', __('Website Name')));
             $dl->appendChild(new XMLElement('dd', Symphony::Configuration()->get('sitename', 'general')));
             $current_version = Symphony::Configuration()->get('version', 'symphony');
             require_once TOOLKIT . '/class.gateway.php';
             $ch = new Gateway();
             $ch->init();
             $ch->setopt('URL', 'https://api.github.com/repos/symphonycms/symphony-2/tags');
             $ch->setopt('TIMEOUT', $timeout);
             $repo_tags = $ch->exec();
             // tags request found
             if (is_array($repo_tags)) {
                 $repo_tags = json_decode($repo_tags);
                 $tags = array();
                 foreach ($repo_tags as $tag) {
                     // remove tags that contain strings
                     if (preg_match('/[a-zA]/i', $tag->name)) {
                         continue;
                     }
                     $tags[] = $tag->name;
                 }
                 natsort($tags);
                 rsort($tags);
                 $latest_version = reset($tags);
             } else {
                 $latest_version = $current_version;
             }
             $needs_update = version_compare($latest_version, $current_version, '>');
             $dl->appendChild(new XMLElement('dt', __('Version')));
             $dl->appendChild(new XMLElement('dd', $current_version . ($needs_update ? ' (<a href="http://getsymphony.com/download/releases/version/' . $latest_version . '/">' . __('Latest is %s', array($latest_version)) . "</a>)" : '')));
             $container->appendChild(new XMLElement('h4', __('Configuration')));
             $container->appendChild($dl);
             $entries = 0;
             foreach (SectionManager::fetch() as $section) {
                 $entries += EntryManager::fetchCount($section->get('id'));
             }
             $dl = new XMLElement('dl');
             $dl->appendChild(new XMLElement('dt', __('Sections')));
             $dl->appendChild(new XMLElement('dd', (string) count(SectionManager::fetch())));
             $dl->appendChild(new XMLElement('dt', __('Entries')));
             $dl->appendChild(new XMLElement('dd', (string) $entries));
             $dl->appendChild(new XMLElement('dt', __('Data Sources')));
             $dl->appendChild(new XMLElement('dd', (string) count(DatasourceManager::listAll())));
             $dl->appendChild(new XMLElement('dt', __('Events')));
             $dl->appendChild(new XMLElement('dd', (string) count(EventManager::listAll())));
             $dl->appendChild(new XMLElement('dt', __('Pages')));
             $dl->appendChild(new XMLElement('dd', (string) count(PageManager::fetch())));
             $container->appendChild(new XMLElement('h4', __('Statistics')));
             $container->appendChild($dl);
             $context['panel']->appendChild($container);
             break;
         case 'markdown_text':
             $formatter = TextformatterManager::create($config['formatter']);
             $html = $formatter->run($config['text']);
             $context['panel']->appendChild(new XMLElement('div', $html));
             break;
     }
 }
Пример #6
0
 private function __exportPage()
 {
     // Load the drivers:
     $drivers = $this->getDrivers();
     // Get the fields of this section:
     $sectionID = $_REQUEST['section-export'];
     $sm = new SectionManager($this);
     $em = new EntryManager($this);
     $section = $sm->fetch($sectionID);
     $fileName = $section->get('handle') . '_' . date('Y-m-d') . '.csv';
     $fields = $section->fetchFields();
     $headers = array();
     foreach ($fields as $field) {
         $headers[] = '"' . str_replace('"', '""', $field->get('label')) . '"';
     }
     header('Content-type: text/csv');
     header('Content-Disposition: attachment; filename="' . $fileName . '"');
     // Show the headers:
     echo implode(';', $headers) . "\n";
     /*
      * Enable filtering!
      * Use the same filtering as with publish indexes (ie: ?filter=[field]:value)
      */
     $filter = $filter_value = $where = $joins = NULL;
     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  FROM `tbl_fields` AS `f`, `tbl_sections` AS `s`\n\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  AND f.`element_name` = '{$field_name}'\n\t\t\t\t\t\t\t\t\t\t  AND `s`.`handle` = '" . $section->get('handle') . "' LIMIT 1");
             $field = FieldManager::fetch($filter);
             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($filter_value), $joins, $where, false);
                 $filter_value = rawurlencode($filter_value);
             }
         }
         if (!is_null($where)) {
             $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
         }
     }
     /*
      * End
      */
     // Show the content:
     $total = $em->fetchCount($sectionID, $where, $joins);
     for ($offset = 0; $offset < $total; $offset += 100) {
         $entries = $em->fetch(null, $sectionID, 100, $offset, $where, $joins);
         foreach ($entries as $entry) {
             $line = array();
             foreach ($fields as $field) {
                 $data = $entry->getData($field->get('id'));
                 $type = $field->get('type');
                 if (isset($drivers[$type])) {
                     $drivers[$type]->setField($field);
                     $value = $drivers[$type]->export($data, $entry->get('id'));
                 } else {
                     $drivers['default']->setField($field);
                     $value = $drivers['default']->export($data, $entry->get('id'));
                 }
                 $line[] = '"' . str_replace('"', '""', trim($value)) . '"';
             }
             echo implode(';', $line) . "\r\n";
         }
     }
     die;
 }
Пример #7
0
 public static function run(SymQLQuery $query, $output = SymQL::RETURN_XML)
 {
     self::getQueryCount();
     // stores all config locally so that the same SymQL instance can be used for mutliple queries
     $section = NULL;
     $section_fields = array();
     $where = NULL;
     $joins = NULL;
     $entry_ids = array();
     // get a section's ID if it was specified by its handle
     if (!is_numeric($query->section)) {
         $query->section = SectionManager::fetchIDFromHandle($query->section);
     }
     // get the section
     $section = SectionManager::fetch($query->section);
     if (!$section instanceof Section) {
         throw new Exception(sprintf("%s: section '%s' does not not exist", __CLASS__, $query->section));
     }
     // cache the section's fields
     $fields = $section->fetchFields();
     self::$_debug['queries']['Resolve section and fields'] = self::getQueryCount();
     // cache list of field objects in this section (id => object)
     foreach ($fields as $field) {
         $section_fields[] = $field->get('id');
     }
     $section_fields = self::indexFieldsByID($section_fields, $fields, TRUE);
     // resolve list of fields from SELECT statement
     if ($query->fields == '*') {
         foreach ($fields as $field) {
             $select_fields[] = $field->get('element_name');
         }
     } else {
         $select_fields = $query->fields;
     }
     $select_fields = self::indexFieldsByID($select_fields, $fields);
     // resolve list of fields from WHERE statements (filters)
     $filters = array();
     if (is_array($query->filters)) {
         foreach ($query->filters as $i => $filter) {
             $field = self::indexFieldsByID($filter['field'], $fields);
             if ($field) {
                 $filters[$i][reset(array_keys($field))]['value'] = $filter['value'];
                 $filters[$i][reset(array_keys($field))]['type'] = $filter['type'];
             }
         }
     }
     // resolve sort field
     if (in_array($query->sort_field, self::$_reserved_fields)) {
         $handle_exploded = explode(':', $query->sort_field);
         if (count($handle_exploded) == 2) {
             EntryManager::setFetchSorting(end($handle_exploded), $query->sort_direction);
         }
     } else {
         $sort_field = self::indexFieldsByID($query->sort_field, $fields);
         $sort_field = $section_fields[reset(array_keys($sort_field))];
         if ($sort_field && $sort_field->isSortable()) {
             EntryManager::setFetchSorting($sort_field->get('id'), $query->sort_direction);
         }
     }
     $where = NULL;
     $joins = NULL;
     foreach ($filters as $filter) {
         $field_id = reset(array_keys($filter));
         $filter = reset($filter);
         if ($field_id == 'system:id') {
             $entry_ids[] = (int) $filter['value'];
             continue;
         }
         // get the cached field object
         $field = $section_fields[$field_id];
         if (!$field) {
             throw new Exception(sprintf("%s: field '%s' does not not exist", __CLASS__, $field_id));
         }
         if (!$field->canFilter() || !method_exists($field, 'buildDSRetrievalSQL')) {
             throw new Exception(sprintf("%s: field '%s' can not be used as a filter", __CLASS__, $field_id));
         }
         // local
         $_where = NULL;
         $_joins = NULL;
         $filter_type = FALSE === strpos($filter['value'], '+') ? self::DS_FILTER_OR : self::DS_FILTER_AND;
         $value = preg_split('/' . ($filter_type == self::DS_FILTER_AND ? '\\+' : ',') . '\\s*/', $filter['value'], -1, PREG_SPLIT_NO_EMPTY);
         $value = array_map('trim', $value);
         // Get the WHERE and JOIN from the field
         $where_before = $_where;
         $field->buildDSRetrievalSQL(array($filter['value']), $_joins, $_where, $filter_type == self::DS_FILTER_AND ? TRUE : FALSE);
         // HACK: if this is an OR statement, strip the first AND from the returned SQL
         // and replace with OR. This is quite brittle, but the only way I could think of
         if ($filter['type'] == SymQL::DS_FILTER_OR) {
             // get the most recent SQL added
             $_where_after = substr($_where, strlen($_where_before), strlen($where));
             // replace leading AND with OR
             $_where_after = preg_replace('/^AND/', 'OR', trim($_where_after));
             // re-append
             $_where = $_where_before . ' ' . $_where_after;
         }
         $joins .= $_joins;
         $where .= $_where;
     }
     // resolve the SELECT type and fetch entries
     if (reset(array_keys($select_fields)) == 'system:count') {
         $select_type = SymQL::SELECT_COUNT;
         $fetch_result = (int) EntryManager::fetchCount($section->get('id'), $where, $joins);
     } else {
         if (count($entry_ids) > 0) {
             $select_type = SymQL::SELECT_ENTRY_ID;
             $fetch_result = EntryManager::fetch($entry_ids, $section->get('id'), NULL, NULL, NULL, NULL, FALSE, TRUE, array_values($select_fields));
         } else {
             $select_type = SymQL::SELECT_ENTRIES;
             $fetch_result = EntryManager::fetchByPage($query->page, $section->get('id'), $query->per_page, $where, $joins, FALSE, FALSE, TRUE, array_values($select_fields));
         }
     }
     self::$_debug['sql']['joins'] = $joins;
     self::$_debug['sql']['where'] = $where;
     self::$_debug['queries']['Fetch entries'] = self::getQueryCount();
     // section metadata
     $section_metadata = array('name' => $section->get('name'), 'id' => $section->get('id'), 'handle' => $section->get('handle'));
     // build pagination metadata
     if ($select_type == SymQL::SELECT_ENTRIES) {
         $pagination = array('total-entries' => (int) $fetch_result['total-entries'], 'total-pages' => (int) $fetch_result['total-pages'], 'per-page' => (int) $fetch_result['limit'], 'current-page' => (int) $query->page);
     }
     // find the array of entries returned from EntryManager fetch
     $entries = array();
     switch ($select_type) {
         case SymQL::SELECT_ENTRY_ID:
             $entries = $fetch_result;
             break;
         case SymQL::SELECT_ENTRIES:
             $entries = $fetch_result['records'];
             break;
         case SymQL::SELECT_COUNT:
             $count = $fetch_result;
             break;
     }
     // set up result container depending on return type
     switch ($output) {
         case SymQL::RETURN_ARRAY:
         case SymQL::RETURN_RAW_COLUMNS:
         case SymQL::RETURN_ENTRY_OBJECTS:
             $result = array();
             $result['section'] = $section_metadata;
             if ($pagination) {
                 $result['pagination'] = $pagination;
             }
             break;
         case SymQL::RETURN_XML:
             $result = new XMLElement($query->root_element ? $query->root_element : 'symql');
             $result->appendChild(new XMLElement('section', $section_metadata['name'], array('id' => $section_metadata['id'], 'handle' => $section_metadata['handle'])));
             if ($pagination) {
                 $result->appendChild(General::buildPaginationElement($pagination['total-entries'], $pagination['total-pages'], $pagination['per-page'], $pagination['current-page']));
             }
             break;
     }
     // append returned entries to results container
     if ($select_type == SymQL::SELECT_ENTRY_ID || $select_type == SymQL::SELECT_ENTRIES) {
         foreach ($entries as $entry) {
             switch ($output) {
                 case SymQL::RETURN_RAW_COLUMNS:
                     $fields = array();
                     foreach ($entry->getData() as $field_id => $values) {
                         $field = $section_fields[$field_id];
                         $fields[$field->get('element_name')] = $values;
                     }
                     $result['entries'][$entry->get('id')] = $fields;
                     break;
                 case SymQL::RETURN_ENTRY_OBJECTS:
                     $result['entries'][$entry->get('id')] = $entry;
                     break;
                 case SymQL::RETURN_XML:
                 case SymQL::RETURN_ARRAY:
                     $xml_entry = new XMLElement('entry');
                     $xml_entry->setAttribute('id', $entry->get('id'));
                     foreach ($entry->getData() as $field_id => $values) {
                         $field = $section_fields[$field_id];
                         $handle = $field->get('element_name');
                         $handle_exploded = explode(':', $select_fields[$field_id]);
                         if (count($handle_exploded) == 2) {
                             $mode = end($handle_exploded);
                         }
                         $field->appendFormattedElement($xml_entry, $values, $encode, $mode);
                     }
                     if ($output == SymQL::RETURN_ARRAY) {
                         $result['entries'][] = XMLToArray::convert($xml_entry->generate());
                     } else {
                         $result->appendChild($xml_entry);
                     }
                     break;
             }
         }
     } elseif ($select_type == SymQL::SELECT_COUNT) {
         switch ($output) {
             case SymQL::RETURN_ARRAY:
             case SymQL::RETURN_RAW_COLUMNS:
             case SymQL::RETURN_ENTRY_OBJECTS:
                 $result['count'] = $count;
                 break;
             case SymQL::RETURN_XML:
                 $xml_entry = new XMLElement('count', $count);
                 $result->appendChild($xml_entry);
                 break;
         }
     }
     self::$_debug['queries']['Total'] = Symphony::Database()->queryCount() - self::$_base_querycount;
     // reset for the next query
     EntryManager::setFetchSorting(NULL, NULL);
     self::$_base_querycount = NULL;
     self::$_cumulative_querycount = NULL;
     return $result;
 }
 public function grab(array &$param_pool = NULL)
 {
     $result = new XMLElement($this->dsParamROOTELEMENT);
     $result->setAttribute('type', 'section-schema');
     // retrieve this section
     $section_id = SectionManager::fetchIDFromHandle($this->dsParamSECTION);
     $section = SectionManager::fetch($section_id);
     $result->setAttribute('id', $section_id);
     $result->setAttribute('handle', $section->get('handle'));
     $entry_count = EntryManager::fetchCount($section_id);
     $result->setAttribute('total-entries', $entry_count);
     // instantiate a dummy entry to instantiate fields and default values
     $entry = EntryManager::create();
     $entry->set('section_id', $section_id);
     $section_fields = $section->fetchFields();
     // for each field in the section
     foreach ($section_fields as $section_field) {
         $field = $section_field->get();
         // Skip fields that have not been selected:
         if (!in_array($field['element_name'], $this->dsParamFIELDS)) {
             continue;
         }
         $f = new XMLElement($field['element_name']);
         $f->setAttribute('required', $field['required']);
         foreach ($field as $key => $value) {
             // Core attributes, these are common to all fields
             if (in_array($key, array('id', 'type', 'required', 'label', 'location', 'show_column', 'sortorder'))) {
                 $f->setattribute(Lang::createHandle($key), General::sanitize($value));
             }
             /*
             	Other properties are output as element nodes. Here we filter those we
             	definitely don't want. Fields can have any number of properties, so it
             	makes sense to filter out those we don't want rather than explicitly
             	choose the ones we do.
             */
             if (!in_array($key, array('id', 'type', 'required', 'label', 'show_column', 'sortorder', 'element_name', 'parent_section', 'location', 'field_id', 'related_field_id', 'static_options', 'dynamic_options', 'pre_populate_source', 'limit', 'allow_author_change'))) {
                 if (strlen($value) > 0) {
                     $f->appendChild(new XMLElement(Lang::createHandle($key), General::sanitize($value)));
                 }
             }
         }
         // Allow a field to define its own schema XML:
         if (method_exists($section_field, 'appendFieldSchema')) {
             $section_field->appendFieldSchema($f);
             $result->appendChild($f);
             continue;
         }
         // check that we can safely inspect output of displayPublishPanel (some custom fields do not work)
         if (in_array($field['type'], self::$_incompatible_publishpanel)) {
             continue;
         }
         // grab the HTML used in the Publish entry form
         $html = new XMLElement('html');
         $section_field->displayPublishPanel($html);
         $dom = new DomDocument();
         $dom->loadXML($html->generate());
         $xpath = new DomXPath($dom);
         $options = new XMLElement('options');
         // find optgroup elements (primarily in Selectbox Link fields)
         foreach ($xpath->query("//*[name()='optgroup']") as $optgroup) {
             $optgroup_element = new XMLElement('optgroup');
             $optgroup_element->setAttribute('label', $optgroup->getAttribute('label'));
             // append child options of this group
             foreach ($optgroup->getElementsByTagName('option') as $option) {
                 $this->__appendOption($option, $optgroup_element, $field);
             }
             $options->appendChild($optgroup_element);
         }
         // find options that aren't children of groups, and list items (primarily for Taglists)
         foreach ($xpath->query("//*[name()='option' and not(parent::optgroup)] | //*[name()='li']") as $option) {
             $this->__appendOption($option, $options, $field);
         }
         if ($options->getNumberOfChildren() > 0) {
             $f->appendChild($options);
         }
         /*
         	When an input has a value and is a direct child of the label, we presume we may need
         	its value (e.g. a pre-populated Date, Order Entries etc.)
         */
         $single_input_value = $xpath->query("//label/input[@value!='']")->item(0);
         if ($single_input_value) {
             $f->appendChild(new XMLElement('initial-value', $single_input_value->getAttribute('value')));
         }
         $result->appendChild($f);
     }
     return $result;
 }
        } else {
            $value = $filter;
        }
        if (!isset($fieldPool[$field_id]) || !is_object($fieldPool[$field_id])) {
            $fieldPool[$field_id] =& $entryManager->fieldManager->fetch($field_id);
        }
        if ($field_id != 'id' && !$fieldPool[$field_id] instanceof Field) {
            throw new Exception(__('Error creating field object with id %1$d, for filtering in data source "%2$s". Check this field exists.', array($field_id, $this->dsParamROOTELEMENT)));
        }
        if ($field_id == 'id') {
            $where = " AND `e`.id IN ('" . @implode("', '", $value) . "') ";
        } else {
            if (!$fieldPool[$field_id]->buildDSRetrivalSQL($value, $joins, $where, $filter_type == DS_FILTER_AND ? true : false)) {
                $this->_force_empty_result = true;
                return;
            }
            if (!$group) {
                $group = $fieldPool[$field_id]->requiresSQLGrouping();
            }
        }
    }
}
if ($this->dsParamSORT == 'system:id') {
    $entryManager->setFetchSorting('id', $this->dsParamORDER);
} elseif ($this->dsParamSORT == 'system:date') {
    $entryManager->setFetchSorting('date', $this->dsParamORDER);
} else {
    $entryManager->setFetchSorting($entryManager->fieldManager->fetchFieldIDFromElementName($this->dsParamSORT, $this->getSource()), $this->dsParamORDER);
}
$count = $entryManager->fetchCount($this->getSource(), $where, $joins);
$result->setValue($count);