当前位置: 首页>>代码示例>>PHP>>正文


PHP EntryManager::fetchCount方法代码示例

本文整理汇总了PHP中EntryManager::fetchCount方法的典型用法代码示例。如果您正苦于以下问题:PHP EntryManager::fetchCount方法的具体用法?PHP EntryManager::fetchCount怎么用?PHP EntryManager::fetchCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EntryManager的用法示例。


在下文中一共展示了EntryManager::fetchCount方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __viewIndex

 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);
     }
 }
开发者ID:davjand,项目名称:codecept-symphonycms-db,代码行数:60,代码来源:content.blueprintssections.php

示例2: __viewIndex

 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);
 }
开发者ID:nickdunn,项目名称:elasticsearch-surfin-shakespeare,代码行数:43,代码来源:content.blueprintssections.php

示例3: __viewIndex


//.........这里部分代码省略.........
     $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/'
开发者ID:rc1,项目名称:WebAppsWithCmsStartHere,代码行数:67,代码来源:content.publish.php

示例4: prepareTableValue

 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;
 }
开发者ID:symphonists,项目名称:bilinkfield,代码行数:71,代码来源:field.bilink.php

示例5: render_panel


//.........这里部分代码省略.........
                 }
             } 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;
     }
 }
开发者ID:korelogic,项目名称:dashboard,代码行数:101,代码来源:extension.driver.php

示例6: __exportPage

 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;
 }
开发者ID:michael-e,项目名称:importcsv,代码行数:72,代码来源:content.index.php

示例7: run


//.........这里部分代码省略.........
         // 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
开发者ID:symphonists,项目名称:symql,代码行数:67,代码来源:class.symql.php

示例8: grab

 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;
 }
开发者ID:symphonists,项目名称:section_schemas,代码行数:87,代码来源:datasource.section_schema.php

示例9: Exception

        } 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);
开发者ID:nickdunn,项目名称:entry_attribute_counts,代码行数:31,代码来源:datasource.section_count.php


注:本文中的EntryManager::fetchCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。