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


PHP EntryManager::setFetchSortingDirection方法代码示例

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


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

示例1: getLastEntryID

 /**
  * Get the ID of the last entry. Last == sorting by the field from Section index
  *
  * @param $section
  * @see LSE::getSection()
  *
  * @return int|null
  */
 public static function getLastEntryID($section = null)
 {
     if (!($s = self::getSection($section))) {
         return null;
     }
     EntryManager::setFetchSortingDirection('DESC');
     $entry = EntryManager::fetch(null, $s->get('id'), 1);
     if (!is_array($entry) || empty($entry)) {
         return null;
     }
     $entry = current($entry);
     $id = (int) $entry->get('id');
     return $id;
 }
开发者ID:rc1,项目名称:WebAppsWithCmsStartHere,代码行数:22,代码来源:class.LSE.php

示例2: sort

 public function sort(&$sort, &$order, $params)
 {
     $section = $params['current-section'];
     // If `?unsort` is appended to the URL, then sorting information are reverted
     // to their defaults
     if ($params['unsort']) {
         $section->setSortingField($section->getDefaultSortingField(), false);
         $section->setSortingOrder('asc');
         redirect(Administration::instance()->getCurrentPageURL());
     }
     // By default, sorting information are retrieved from
     // the filesystem and stored inside the `Configuration` object
     if (is_null($sort) && is_null($order)) {
         $sort = $section->getSortingField();
         $order = $section->getSortingOrder();
         // Sorting by ID requires saving sort data to the `EntryManager`
         // object for subsequent use
         if ($sort == 'id') {
             EntryManager::setFetchSortingField('id');
             EntryManager::setFetchSortingDirection($order);
         }
     } else {
         // Ensure that this field is infact sortable, otherwise
         // fallback to IDs
         if (($field = FieldManager::fetch($sort)) instanceof Field && !$field->isSortable()) {
             $sort = $section->getDefaultSortingField();
         }
         // If the sort order or direction differs from what is saved,
         // update the config file and reload the page
         if ($sort != $section->getSortingField() || $order != $section->getSortingOrder()) {
             $section->setSortingField($sort, false);
             $section->setSortingOrder($order);
             redirect(Administration::instance()->getCurrentPageURL() . $params['filters']);
         }
     }
 }
开发者ID:nickdunn,项目名称:elasticsearch-surfin-shakespeare,代码行数:36,代码来源:content.publish.php

示例3: __viewIndex

 public function __viewIndex()
 {
     $sectionManager = new SectionManager($this->_Parent);
     if (!($section_id = $sectionManager->fetchIDFromHandle($this->_context['section_handle']))) {
         Administration::instance()->customError(__('Unknown Section'), __('The Section you are looking, <code>%s</code> for could not be found.', array($this->_context['section_handle'])));
     }
     $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);
     $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  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 =& $entryManager->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
         }
     }
     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(Administration::instance()->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(Administration::instance()->getCurrentPageURL());
     }
     $this->Form->setAttribute('action', Administration::instance()->getCurrentPageURL() . '?pg=' . $current_page . ($filter ? "&amp;filter={$field_handle}:{$filter_value}" : ''));
     $this->appendSubheading($section->get('name'), Widget::Anchor(__('Create New'), Administration::instance()->getCurrentPageURL() . 'new/' . ($filter ? '?prepopulate[' . $filter . ']=' . $filter_value : ''), __('Create a new entry'), 'create button', NULL, array('accesskey' => 'c')));
     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 = Administration::instance()->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 = Administration::instance()->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', array('id' => 'field-' . $column->get('id'), 'class' => 'field-' . $column->get('type')));
             } else {
                 $aTableHead[] = array($label, 'col', array('id' => 'field-' . $column->get('id'), 'class' => 'field-' . $column->get('type')));
             }
         }
     } else {
         $aTableHead[] = array(__('ID'), 'col');
     }
     $child_sections = array();
     $associated_sections = $section->fetchAssociatedSections(true);
     if (is_array($associated_sections) && !empty($associated_sections)) {
         foreach ($associated_sections as $key => $as) {
             $child_sections[$key] = $sectionManager->fetch($as['child_section_id']);
             $aTableHead[] = array($child_sections[$key]->get('name'), 'col');
         }
     }
     /**
      * Allows the creation of custom entries tablecolumns. Called
      * after all the Section Visible columns have been added  as well
      * as the Section Associations
      *
      * @delegate AddCustomPublishColumn
      * @since Symphony 2.2
      * @param string $context
      * '/publish/'
      * @param array $tableHead
      * An array of the current columns, passed by reference
      * @param integer $section_id
      * The current Section ID
      */
     Symphony::ExtensionManager()->notifyMembers('AddCustomPublishColumn', '/publish/', array('tableHead' => &$aTableHead, 'section_id' => $section->get('id')));
     ## Table Body
     $aTableBody = array();
     if (!is_array($entries['records']) || empty($entries['records'])) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd'));
//.........这里部分代码省略.........
开发者ID:ahwayakchih,项目名称:symphony-2,代码行数:101,代码来源:content.publish.php

示例4: SectionManager

 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) {
//.........这里部分代码省略.........
开发者ID:klaftertief,项目名称:sym-forum,代码行数:101,代码来源:content.publish.php

示例5: getLastPosition

 private function getLastPosition()
 {
     $em = new EntryManager($this->_Parent);
     $em->setFetchSortingDirection('DESC');
     $entry = $em->fetch(NULL, $this->_section->get('id'), 1);
     if (is_array($entry) && !empty($entry)) {
         $entry = end($entry);
         return $entry->get('id');
     }
 }
开发者ID:knupska,项目名称:static_section,代码行数:10,代码来源:extension.driver.php


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