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


PHP PageManager::fetchNextSortOrder方法代码示例

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


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

示例1: __actionEdit

 public function __actionEdit()
 {
     if ($this->_context[0] != 'new' && !($page_id = (int) $this->_context[1])) {
         redirect(SYMPHONY_URL . '/blueprints/pages/');
     }
     $parent_link_suffix = NULL;
     if (isset($_REQUEST['parent']) && is_numeric($_REQUEST['parent'])) {
         $parent_link_suffix = '?parent=' . $_REQUEST['parent'];
     }
     if (@array_key_exists('delete', $_POST['action'])) {
         $this->__actionDelete($page_id, SYMPHONY_URL . '/blueprints/pages/' . $parent_link_suffix);
     }
     if (@array_key_exists('save', $_POST['action'])) {
         $fields = $_POST['fields'];
         $this->_errors = array();
         $autogenerated_handle = false;
         if (!isset($fields['title']) || trim($fields['title']) == '') {
             $this->_errors['title'] = __('This is a required field');
         }
         if (trim($fields['type']) != '' && preg_match('/(index|404|403)/i', $fields['type'])) {
             $types = preg_split('/\\s*,\\s*/', strtolower($fields['type']), -1, PREG_SPLIT_NO_EMPTY);
             if (in_array('index', $types) && PageManager::hasPageTypeBeenUsed($page_id, 'index')) {
                 $this->_errors['type'] = __('An index type page already exists.');
             } elseif (in_array('404', $types) && PageManager::hasPageTypeBeenUsed($page_id, '404')) {
                 $this->_errors['type'] = __('A 404 type page already exists.');
             } elseif (in_array('403', $types) && PageManager::hasPageTypeBeenUsed($page_id, '403')) {
                 $this->_errors['type'] = __('A 403 type page already exists.');
             }
         }
         if (trim($fields['handle']) == '') {
             $fields['handle'] = $fields['title'];
             $autogenerated_handle = true;
         }
         $fields['handle'] = PageManager::createHandle($fields['handle']);
         if (empty($fields['handle']) && !isset($this->_errors['title'])) {
             $this->_errors['handle'] = __('Please ensure handle contains at least one Latin-based character.');
         }
         /**
          * Just after the Symphony validation has run, allows Developers
          * to run custom validation logic on a Page
          *
          * @delegate PagePostValidate
          * @since Symphony 2.2
          * @param string $context
          * '/blueprints/pages/'
          * @param array $fields
          *  The `$_POST['fields']` array. This should be read-only and not changed
          *  through this delegate.
          * @param array $errors
          *  An associative array of errors, with the key matching a key in the
          *  `$fields` array, and the value being the string of the error. `$errors`
          *  is passed by reference.
          */
         Symphony::ExtensionManager()->notifyMembers('PagePostValidate', '/blueprints/pages/', array('fields' => $fields, 'errors' => &$errors));
         if (empty($this->_errors)) {
             $autogenerated_handle = false;
             if ($fields['params']) {
                 $fields['params'] = trim(preg_replace('@\\/{2,}@', '/', $fields['params']), '/');
             }
             // Clean up type list
             $types = preg_split('/\\s*,\\s*/', $fields['type'], -1, PREG_SPLIT_NO_EMPTY);
             $types = @array_map('trim', $types);
             unset($fields['type']);
             $fields['parent'] = $fields['parent'] != __('None') ? $fields['parent'] : null;
             $fields['data_sources'] = is_array($fields['data_sources']) ? implode(',', $fields['data_sources']) : NULL;
             $fields['events'] = is_array($fields['events']) ? implode(',', $fields['events']) : NULL;
             $fields['path'] = null;
             if ($fields['parent']) {
                 $fields['path'] = PageManager::resolvePagePath((int) $fields['parent']);
             }
             // Check for duplicates:
             $current = PageManager::fetchPageByID($page_id);
             if (empty($current)) {
                 $fields['sortorder'] = PageManager::fetchNextSortOrder();
             }
             $where = array();
             if (!empty($current)) {
                 $where[] = "p.id != {$page_id}";
             }
             $where[] = "p.handle = '" . $fields['handle'] . "'";
             $where[] = is_null($fields['path']) ? "p.path IS NULL" : "p.path = '" . $fields['path'] . "'";
             $duplicate = PageManager::fetch(false, array('*'), $where);
             // If duplicate
             if (!empty($duplicate)) {
                 if ($autogenerated_handle) {
                     $this->_errors['title'] = __('A page with that title already exists');
                 } else {
                     $this->_errors['handle'] = __('A page with that handle already exists');
                 }
             } else {
                 // New page?
                 if (empty($current)) {
                     $file_created = PageManager::createPageFiles($fields['path'], $fields['handle']);
                 } else {
                     $file_created = PageManager::createPageFiles($fields['path'], $fields['handle'], $current['path'], $current['handle']);
                 }
                 // If the file wasn't created, it's usually permissions related
                 if (!$file_created) {
                     $redirect = null;
                     return $this->pageAlert(__('Page Template could not be written to disk.') . ' ' . __('Please check permissions on %s.', array('<code>/workspace/pages</code>')), Alert::ERROR);
//.........这里部分代码省略.........
开发者ID:davjand,项目名称:codecept-symphonycms-db,代码行数:101,代码来源:content.blueprintspages.php


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