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


PHP PageManager::fetch方法代码示例

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


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

示例1: view

 public function view()
 {
     $params = array('{$today}', '{$current-time}', '{$this-year}', '{$this-month}', '{$this-day}', '{$timezone}', '{$website-name}', '{$page-title}', '{$root}', '{$workspace}', '{$root-page}', '{$current-page}', '{$current-page-id}', '{$current-path}', '{$current-query-string}', '{$current-url}', '{$cookie-username}', '{$cookie-pass}', '{$page-types}', '{$upload-limit}');
     // Get page parameters
     $pages = PageManager::fetch(true, array('params'));
     foreach ($pages as $key => $pageparams) {
         if (empty($pageparams['params'])) {
             continue;
         }
         $pageparams = explode('/', $pageparams['params']);
         foreach ($pageparams as $pageparam) {
             $param = '{$' . $pageparam . '}';
             if (!in_array($param, $params)) {
                 $params[] = $param;
             }
         }
     }
     // Get Data Sources output parameters
     $datasources = DatasourceManager::listAll();
     foreach ($datasources as $datasource) {
         $current = DatasourceManager::create($datasource['handle'], array(), false);
         $prefix = '{$ds-' . Lang::createHandle($datasource['name']) . '.';
         $suffix = '}';
         // Get parameters
         if (is_array($current->dsParamPARAMOUTPUT)) {
             foreach ($current->dsParamPARAMOUTPUT as $id => $param) {
                 $params[] = $prefix . $param . $suffix;
             }
         }
     }
     sort($params);
     $this->_Result = json_encode($params);
 }
开发者ID:davjand,项目名称:codecept-symphonycms-db,代码行数:33,代码来源:content.ajaxparameters.php

示例2: __buildPageXML

 public function __buildPageXML($page, $page_types, $qf)
 {
     $lang_code = FLang::getLangCode();
     $oPage = new XMLElement('page');
     $oPage->setAttribute('handle', $page['handle']);
     $oPage->setAttribute('id', $page['id']);
     // keep current first
     $oPage->appendChild(new XMLElement('item', General::sanitize($page['plh_t-' . $lang_code]), array('lang' => $lang_code, 'handle' => $page['plh_h-' . $lang_code])));
     // add others
     foreach (FLang::getLangs() as $lc) {
         if ($lang_code != $lc) {
             $oPage->appendChild(new XMLElement('item', General::sanitize($page['plh_t-' . $lc]), array('lang' => $lc, 'handle' => $page['plh_h-' . $lc])));
         }
     }
     if (in_array($page['id'], array_keys($page_types))) {
         $xTypes = new XMLElement('types');
         foreach ($page_types[$page['id']] as $type) {
             $xTypes->appendChild(new XMLElement('type', $type));
         }
         $oPage->appendChild($xTypes);
     }
     if ($page['children'] != '0') {
         if ($children = PageManager::fetch(false, array($qf . 'id, handle, title'), array(sprintf('`parent` = %d', $page['id'])))) {
             foreach ($children as $c) {
                 $oPage->appendChild($this->__buildPageXML($c, $page_types, $qf));
             }
         }
     }
     return $oPage;
 }
开发者ID:siimsoni,项目名称:page_lhandles,代码行数:30,代码来源:class.datasource.MultilingualNavigation.php

示例3: grab

 public function grab(&$param_pool = null)
 {
     $result = new XMLElement('plh-page');
     $langs = FLang::getLangs();
     $fields = array('id', 'handle', 'parent');
     foreach ($langs as $lc) {
         $fields[] = "`plh_t-{$lc}`";
         $fields[] = "`plh_h-{$lc}`";
     }
     $pages = array();
     foreach (PageManager::fetch(null, $fields) as $page) {
         $pages[$page['id']] = $page;
     }
     $this->appendPage($pages, $this->_env['param']['current-page-id'], $langs, $result);
     return $result;
 }
开发者ID:siimsoni,项目名称:page_lhandles,代码行数:16,代码来源:data.plh_page.php

示例4: __getPageParams

 private function __getPageParams()
 {
     $params = array();
     $pages = PageManager::fetch(true, array('params'));
     foreach ($pages as $key => $pageparams) {
         if (empty($pageparams['params'])) {
             continue;
         }
         $pageparams = explode('/', $pageparams['params']);
         foreach ($pageparams as $pageparam) {
             $param = sprintf($this->template, $pageparam);
             if (!in_array($param, $params)) {
                 $params[] = $param;
             }
         }
     }
     return $params;
 }
开发者ID:valery,项目名称:symphony-2,代码行数:18,代码来源:content.ajaxparameters.php

示例5: __buildPageXML

 public function __buildPageXML($page, $page_types)
 {
     $oPage = new XMLElement('page');
     $oPage->setAttribute('handle', $page['handle']);
     $oPage->setAttribute('id', $page['id']);
     $oPage->appendChild(new XMLElement('name', General::sanitize($page['title'])));
     if (in_array($page['id'], array_keys($page_types))) {
         $xTypes = new XMLElement('types');
         foreach ($page_types[$page['id']] as $type) {
             $xTypes->appendChild(new XMLElement('type', $type));
         }
         $oPage->appendChild($xTypes);
     }
     if ($page['children'] != '0') {
         if ($children = PageManager::fetch(false, array('id, handle, title'), array(sprintf('`parent` = %d', $page['id'])))) {
             foreach ($children as $c) {
                 $oPage->appendChild($this->__buildPageXML($c, $page_types));
             }
         }
     }
     return $oPage;
 }
开发者ID:bauhouse,项目名称:Piano-Sonata,代码行数:22,代码来源:class.datasource.navigation.php

示例6: buildTree

 private function buildTree($parent = null, $indent = 0)
 {
     if ($parent == null) {
         $results = PageManager::fetch(true, array(), array('`parent` IS NULL'), '`sortorder` ASC');
     } else {
         $results = PageManager::fetch(true, array(), array('`parent` = ' . $parent), '`sortorder` ASC');
     }
     $tree = array();
     foreach ($results as $result) {
         // Check if the page should be shown:
         if (!in_array('ck_hide', $result['type'])) {
             $prefix = '';
             $info = array('handle' => $result['handle'], 'path' => $result['path']);
             if ($result['path'] == null) {
                 $info['url'] = '/' . $result['handle'] . '/';
                 $info['title'] = $result['title'];
             } else {
                 $info['url'] = '/' . $result['path'] . '/' . $result['handle'] . '/';
                 for ($i = 0; $i < $indent; $i++) {
                     $prefix .= ' ';
                     // Please note: this might look like an empty space (nbsp) but it's an em space (emsp).
                     // This was necessary because &nbsp; kept showing as plain text in the dropdown.
                 }
                 $info['title'] = $prefix . ' › ' . General::sanitize($result['title']);
             }
             $tree[] = $info;
             // Check if there are templates for this page:
             $tree = array_merge($tree, $this->checkTemplates($result['id'], $prefix . ' '));
             // also an emsp
             // Get the children:
             $children = $this->buildTree($result['id'], $indent + 1);
             // Join arrays:
             $tree = array_merge($tree, $children);
         }
     }
     return $tree;
 }
开发者ID:TwistedInteractive,项目名称:ckeditor,代码行数:37,代码来源:content.pages.php

示例7: appendPresets

 /**
  * Append presets
  * @param $context
  */
 public function appendPresets($context)
 {
     Symphony::Engine()->Page->addScriptToHead(URL . '/extensions/ckeditor/assets/preferences.js', 4676);
     $wrapper = $context['wrapper'];
     $fieldset = new XMLElement('fieldset', '', array('class' => 'settings'));
     $fieldset->appendChild(new XMLElement('legend', __('CKEditor File Browser')));
     $sectionManager = new SectionManager($this);
     $sections = $sectionManager->fetch();
     // Check which sections are allowed:
     $data = Symphony::Configuration()->get('sections', 'ckeditor');
     $checkedSections = $data != false ? explode(',', $data) : array();
     // If there are no sections found:
     if ($sections) {
         $options = array();
         foreach ($sections as $section) {
             $options[] = array($section->get('id'), in_array($section->get('id'), $checkedSections), $section->get('name'));
         }
         $label = Widget::Label(__('Permitted sections for the file browser:'));
         $label->appendChild(Widget::Select('ckeditor_sections[]', $options, array('multiple' => 'multiple')));
         $fieldset->appendChild($label);
     }
     // Link templates for CKEditor:
     $sections = SectionManager::fetch();
     $dbpages = PageManager::fetch();
     $pages = array();
     // Filter out the ck_hide:
     foreach ($dbpages as $page) {
         $types = PageManager::fetchPageTypes($page['id']);
         if (!in_array('ck_hide', $types)) {
             $pages[] = $page;
         }
     }
     // Adjust page title:
     foreach ($pages as &$_page) {
         $p = $_page;
         $title = $_page['title'];
         while (!is_null($p['parent'])) {
             $p = PageManager::fetch(false, array(), array('id' => $p['parent']));
             $title = $p['title'] . ' : ' . $title;
         }
         $_page['title'] = $title;
     }
     // Sort the array:
     $titles = array();
     foreach ($pages as $key => $row) {
         $titles[$key] = strtolower($row['title']);
     }
     array_multisort($titles, SORT_ASC, $pages);
     $this->sections = array();
     foreach ($sections as $s) {
         $a = array('id' => $s->get('id'), 'name' => $s->get('name'), 'fields' => array());
         $fields = FieldManager::fetch(null, $s->get('id'));
         foreach ($fields as $field) {
             // For now, only allow fields of the type 'input' to be used as a handle:
             if ($field->get('type') == 'input') {
                 $a['fields'][] = array('id' => $field->get('id'), 'label' => $field->get('label'), 'element_name' => $field->get('element_name'));
             }
         }
         $this->sections[] = $a;
     }
     $fieldset->appendChild(new XMLElement('p', __('Link templates:'), array('class' => 'label')));
     $ol = new XMLElement('ol');
     $ol->setAttribute('class', 'ckeditor-duplicator');
     $templates = Symphony::Database()->fetch('SELECT * FROM `tbl_ckeditor_link_templates`;');
     if (!is_array($pages)) {
         $pages = array($pages);
     }
     foreach ($pages as $page) {
         foreach ($templates as $template) {
             if ($template['page_id'] != $page['id']) {
                 continue;
             }
             $duplicator = $this->__buildDuplicatorItem($page, $template);
             $ol->appendChild($duplicator);
         }
         $duplicator = $this->__buildDuplicatorItem($page, NULL);
         $ol->appendChild($duplicator);
     }
     $fieldset->appendChild($ol);
     // Plugin presets:
     $fieldset->appendChild(new XMLElement('p', __('Plugin presets:'), array('class' => 'label')));
     $ol = new XMLElement('ol');
     $ol->setAttribute('class', 'ckeditor-duplicator');
     // Create template:
     $template = new XMLElement('li', null, array('class' => 'template'));
     $template->appendChild(new XMLElement('header', '<h3>' . __('New Preset') . '</h3>'));
     $template->appendChild(Widget::Label(__('Name'), Widget::Input('ckeditor_presets[-1][name]')));
     $template->appendChild(Widget::Label(__('Toolbar'), Widget::Textarea('ckeditor_presets[-1][toolbar]', 5, 50)));
     $template->appendChild(Widget::Label(__('Plugins'), Widget::Textarea('ckeditor_presets[-1][plugins]', 5, 50)));
     $template->appendChild(Widget::Label(__('%s Enable resizing', array(Widget::Input('ckeditor_presets[-1][resize]', 'yes', 'checkbox')->generate()))));
     $template->appendChild(Widget::Label(__('%s Show outline blocks', array(Widget::Input('ckeditor_presets[-1][outline]', 'yes', 'checkbox')->generate()))));
     $ol->appendChild($template);
     // Append all the fields:
     $presets = Symphony::Database()->fetch('SELECT * FROM `tbl_ckeditor_presets');
     $index = 0;
     foreach ($presets as $preset) {
//.........这里部分代码省略.........
开发者ID:TwistedInteractive,项目名称:ckeditor,代码行数:101,代码来源:extension.driver.php

示例8: __formAction


//.........这里部分代码省略.........
             Symphony::ExtensionManager()->notifyMembers('AppendEventFilterDocumentation', '/blueprints/events/' . $rootelement . '/', array('selected' => $filters, 'documentation' => &$doc_parts));
             $documentation = join(PHP_EOL, array_map(create_function('$x', 'return rtrim($x->generate(true, 4));'), $doc_parts));
             $documentation = str_replace('\'', '\\\'', $documentation);
             $eventShell = str_replace('<!-- CLASS EXTENDS -->', $extends, $eventShell);
             $eventShell = str_replace('<!-- DOCUMENTATION -->', General::tabsToSpaces($documentation, 4), $eventShell);
         }
         $eventShell = str_replace('<!-- ROOT ELEMENT -->', $rootelement, $eventShell);
         $eventShell = str_replace('<!-- CLASS NAME -->', $classname, $eventShell);
         $eventShell = str_replace('<!-- SOURCE -->', $source, $eventShell);
         // Remove left over placeholders
         $eventShell = preg_replace(array('/<!--[\\w ]++-->/'), '', $eventShell);
         if ($this->_context[0] == 'new') {
             /**
              * Prior to creating an Event, the file path where it will be written to
              * is provided and well as the contents of that file.
              *
              * @delegate EventsPreCreate
              * @since Symphony 2.2
              * @param string $context
              * '/blueprints/events/'
              * @param string $file
              *  The path to the Event file
              * @param string $contents
              *  The contents for this Event as a string passed by reference
              * @param array $filters
              *  An array of the filters attached to this event
              */
             Symphony::ExtensionManager()->notifyMembers('EventPreCreate', '/blueprints/events/', array('file' => $file, 'contents' => &$eventShell, 'filters' => $filters));
         } else {
             /**
              * Prior to editing an Event, the file path where it will be written to
              * is provided and well as the contents of that file.
              *
              * @delegate EventPreEdit
              * @since Symphony 2.2
              * @param string $context
              * '/blueprints/events/'
              * @param string $file
              *  The path to the Event file
              * @param string $contents
              *  The contents for this Event as a string passed by reference
              * @param array $filters
              *  An array of the filters attached to this event
              */
             Symphony::ExtensionManager()->notifyMembers('EventPreEdit', '/blueprints/events/', array('file' => $file, 'contents' => &$eventShell, 'filters' => $filters));
         }
         // Write the file
         if (!is_writable(dirname($file)) || !($write = General::writeFile($file, $eventShell, Symphony::Configuration()->get('write_mode', 'file')))) {
             $this->pageAlert(__('Failed to write Event to disk.') . ' ' . __('Please check permissions on %s.', array('<code>/workspace/events</code>')), Alert::ERROR);
             // Write successful
         } else {
             if (function_exists('opcache_invalidate')) {
                 opcache_invalidate($file, true);
             }
             // Attach this event to pages
             $connections = $fields['connections'];
             ResourceManager::setPages(RESOURCE_TYPE_EVENT, is_null($existing_handle) ? $classname : $existing_handle, $connections);
             if ($queueForDeletion) {
                 General::deleteFile($queueForDeletion);
                 $pages = PageManager::fetch(false, array('events', 'id'), array("\n                        `events` REGEXP '[[:<:]]" . $existing_handle . "[[:>:]]'\n                    "));
                 if (is_array($pages) && !empty($pages)) {
                     foreach ($pages as $page) {
                         $page['events'] = preg_replace('/\\b' . $existing_handle . '\\b/i', $classname, $page['events']);
                         PageManager::edit($page['id'], $page);
                     }
                 }
             }
             if ($this->_context[0] == 'new') {
                 /**
                  * After creating the Event, the path to the Event file is provided
                  *
                  * @delegate EventPostCreate
                  * @since Symphony 2.2
                  * @param string $context
                  * '/blueprints/events/'
                  * @param string $file
                  *  The path to the Event file
                  */
                 Symphony::ExtensionManager()->notifyMembers('EventPostCreate', '/blueprints/events/', array('file' => $file));
             } else {
                 /**
                  * After editing the Event, the path to the Event file is provided
                  *
                  * @delegate EventPostEdit
                  * @since Symphony 2.2
                  * @param string $context
                  * '/blueprints/events/'
                  * @param string $file
                  *  The path to the Event file
                  * @param string $previous_file
                  *  The path of the previous Event file in the case where an Event may
                  *  have been renamed. To get the handle from this value, see
                  *  `EventManager::__getHandleFromFilename`
                  */
                 Symphony::ExtensionManager()->notifyMembers('EventPostEdit', '/blueprints/events/', array('file' => $file, 'previous_file' => $queueForDeletion ? $queueForDeletion : null));
             }
             redirect(SYMPHONY_URL . '/blueprints/events/edit/' . $classname . '/' . ($this->_context[0] == 'new' ? 'created' : 'saved') . '/');
         }
     }
 }
开发者ID:valery,项目名称:symphony-2,代码行数:101,代码来源:content.blueprintsevents.php

示例9: detach

 /**
  * Given a resource type, a handle and a page, this function detaches
  * the given handle (which represents either a datasource or event) to that page.
  *
  * @param integer $type
  *  The resource type, either `RESOURCE_TYPE_EVENT` or `RESOURCE_TYPE_DS`
  * @param string $r_handle
  *  The handle of the resource.
  * @param integer $page_id
  *  The ID of the page.
  */
 public static function detach($type, $r_handle, $page_id)
 {
     $col = self::getColumnFromType($type);
     $pages = PageManager::fetch(false, array($col), array(sprintf('`id` = %d', $page_id)));
     if (is_array($pages) && count($pages) == 1) {
         $result = $pages[0][$col];
         $values = explode(',', $result);
         $idx = array_search($r_handle, $values, false);
         if ($idx !== false) {
             array_splice($values, $idx, 1);
             $result = implode(',', $values);
             return PageManager::edit($page_id, array($col => MySQL::cleanValue($result)));
         }
     }
     return false;
 }
开发者ID:bauhouse,项目名称:Piano-Sonata,代码行数:27,代码来源:class.resourcemanager.php

示例10: appendPresets

 /**
  * Append presets
  * @param $context
  */
 public function appendPresets($context)
 {
     Symphony::Engine()->Page->addScriptToHead(URL . '/extensions/ckeditor/assets/preferences.js', 4676);
     $wrapper = $context['wrapper'];
     $fieldset = new XMLElement('fieldset', '', array('class' => 'settings'));
     $fieldset->appendChild(new XMLElement('legend', __('CKEditor File Browser')));
     $sectionManager = new SectionManager($this);
     $sections = $sectionManager->fetch();
     // Check which sections are allowed:
     $data = Symphony::Configuration()->get('sections', 'ckeditor');
     $checkedSections = $data != false ? explode(',', $data) : array();
     // If there are no sections found:
     if ($sections) {
         $options = array();
         foreach ($sections as $section) {
             $options[] = array($section->get('id'), in_array($section->get('id'), $checkedSections), $section->get('name'));
         }
         $label = Widget::Label(__('Permitted sections for the file browser:'));
         $label->appendChild(Widget::Select('ckeditor_sections[]', $options, array('multiple' => 'multiple')));
         $fieldset->appendChild($label);
     }
     // Link templates for CKEditor:
     $sections = SectionManager::fetch();
     $dbpages = PageManager::fetch();
     $pages = array();
     // Filter out the ck_hide:
     foreach ($dbpages as $page) {
         $types = PageManager::fetchPageTypes($page['id']);
         if (!in_array('ck_hide', $types)) {
             $pages[] = $page;
         }
     }
     // Adjust page title:
     foreach ($pages as &$_page) {
         $p = $_page;
         $title = $_page['title'];
         while (!is_null($p['parent'])) {
             $p = PageManager::fetch(false, array(), array('id' => $p['parent']));
             $title = $p['title'] . ' : ' . $title;
         }
         $_page['title'] = $title;
     }
     // Sort the array:
     $titles = array();
     foreach ($pages as $key => $row) {
         $titles[$key] = strtolower($row['title']);
     }
     array_multisort($titles, SORT_ASC, $pages);
     $this->sections = array();
     foreach ($sections as $s) {
         $a = array('id' => $s->get('id'), 'name' => $s->get('name'), 'fields' => array());
         $fields = FieldManager::fetch(null, $s->get('id'));
         foreach ($fields as $field) {
             // For now, only allow fields of the type 'input' to be used as a handle:
             if ($field->get('type') == 'input') {
                 $a['fields'][] = array('id' => $field->get('id'), 'label' => $field->get('label'), 'element_name' => $field->get('element_name'));
             }
         }
         $this->sections[] = $a;
     }
     $fieldset->appendChild(new XMLElement('p', __('Link templates:'), array('class' => 'label')));
     $ol = new XMLElement('ol');
     $ol->setAttribute('class', 'ckeditor-duplicator');
     $templates = Symphony::Database()->fetch('SELECT * FROM `tbl_ckeditor_link_templates`;');
     if (!is_array($pages)) {
         $pages = array($pages);
     }
     foreach ($pages as $page) {
         foreach ($templates as $template) {
             if ($template['page_id'] != $page['id']) {
                 continue;
             }
             $duplicator = $this->__buildDuplicatorItem($page, $template);
             $ol->appendChild($duplicator);
         }
         $duplicator = $this->__buildDuplicatorItem($page, NULL);
         $ol->appendChild($duplicator);
     }
     $fieldset->appendChild($ol);
     $wrapper->appendChild($fieldset);
 }
开发者ID:renansantos,项目名称:ckeditor,代码行数:85,代码来源:extension.driver.php

示例11: __formAction


//.........这里部分代码省略.........
              * @param string $context
              * '/blueprints/datasources/'
              * @param string $file
              *  The path to the Datasource file
              * @param string $contents
              *  The contents for this Datasource as a string passed by reference
              * @param array $params
              *  An array of all the `$dsParam*` values
              * @param array $elements
              *  An array of all the elements included in this datasource
              * @param array $filters
              *  An associative array of all the filters for this datasource with the key
              *  being the `field_id` and the value the filter.
              * @param array $dependencies
              *  An array of dependencies that this datasource has
              */
             Symphony::ExtensionManager()->notifyMembers('DatasourcePreCreate', '/blueprints/datasources/', array('file' => $file, 'contents' => &$dsShell, 'params' => $params, 'elements' => $elements, 'filters' => $filters, 'dependencies' => $dependencies));
         } else {
             /**
              * Prior to editing a Datasource, the file path where it will be written to
              * is provided and well as the contents of that file.
              *
              * @delegate DatasourcePreEdit
              * @since Symphony 2.2
              * @param string $context
              * '/blueprints/datasources/'
              * @param string $file
              *  The path to the Datasource file
              * @param string $contents
              *  The contents for this Datasource as a string passed by reference
              * @param array $dependencies
              *  An array of dependencies that this datasource has
              * @param array $params
              *  An array of all the `$dsParam*` values
              * @param array $elements
              *  An array of all the elements included in this datasource
              * @param array $filters
              *  An associative array of all the filters for this datasource with the key
              *  being the `field_id` and the value the filter.
              */
             Symphony::ExtensionManager()->notifyMembers('DatasourcePreEdit', '/blueprints/datasources/', array('file' => $file, 'contents' => &$dsShell, 'dependencies' => $dependencies, 'params' => $params, 'elements' => $elements, 'filters' => $filters));
         }
         // Remove left over placeholders
         $dsShell = preg_replace(array('/<!--[\\w ]++-->/', '/(\\t+[\\r\\n]){2,}/', '/(\\r\\n){2,}/'), '$1', $dsShell);
         // Write the file
         if (!is_writable(dirname($file)) || !General::writeFile($file, $dsShell, Symphony::Configuration()->get('write_mode', 'file'), 'w', true)) {
             $this->pageAlert(__('Failed to write Data source to disk.') . ' ' . __('Please check permissions on %s.', array('<code>/workspace/data-sources</code>')), Alert::ERROR);
             // Write successful
         } else {
             if (function_exists('opcache_invalidate')) {
                 opcache_invalidate($file, true);
             }
             // Attach this datasources to pages
             $connections = $fields['connections'];
             ResourceManager::setPages(ResourceManager::RESOURCE_TYPE_DS, is_null($existing_handle) ? $classname : $existing_handle, $connections);
             // If the datasource has been updated and the name changed, then adjust all the existing pages that have the old datasource name
             if ($queueForDeletion) {
                 General::deleteFile($queueForDeletion);
                 // Update pages that use this DS
                 $pages = PageManager::fetch(false, array('data_sources', 'id'), array("\n                        `data_sources` REGEXP '[[:<:]]" . $existing_handle . "[[:>:]]'\n                    "));
                 if (is_array($pages) && !empty($pages)) {
                     foreach ($pages as $page) {
                         $page['data_sources'] = preg_replace('/\\b' . $existing_handle . '\\b/i', $classname, $page['data_sources']);
                         PageManager::edit($page['id'], $page);
                     }
                 }
             }
             if ($this->_context[0] == 'new') {
                 /**
                  * After creating the Datasource, the path to the Datasource file is provided
                  *
                  * @delegate DatasourcePostCreate
                  * @since Symphony 2.2
                  * @param string $context
                  * '/blueprints/datasources/'
                  * @param string $file
                  *  The path to the Datasource file
                  */
                 Symphony::ExtensionManager()->notifyMembers('DatasourcePostCreate', '/blueprints/datasources/', array('file' => $file));
             } else {
                 /**
                  * After editing the Datasource, the path to the Datasource file is provided
                  *
                  * @delegate DatasourcePostEdit
                  * @since Symphony 2.2
                  * @param string $context
                  * '/blueprints/datasources/'
                  * @param string $file
                  *  The path to the Datasource file
                  * @param string $previous_file
                  *  The path of the previous Datasource file in the case where a Datasource may
                  *  have been renamed. To get the handle from this value, see
                  *  `DatasourceManager::__getHandleFromFilename`
                  */
                 Symphony::ExtensionManager()->notifyMembers('DatasourcePostEdit', '/blueprints/datasources/', array('file' => $file, 'previous_file' => $queueForDeletion ? $queueForDeletion : null));
             }
             redirect(SYMPHONY_URL . '/blueprints/datasources/edit/' . $classname . '/' . ($this->_context[0] == 'new' ? 'created' : 'saved') . '/');
         }
     }
 }
开发者ID:jurajkapsz,项目名称:symphony-2,代码行数:101,代码来源:content.blueprintsdatasources.php

示例12: __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

示例13: __formAction


//.........这里部分代码省略.........
                }
                $documentation_parts[] = self::processDocumentationCode($code);
                $documentation_parts[] = new XMLElement('p', __('When an error occurs during saving, due to either missing or invalid fields, the following XML will be returned') . ($multiple ? ' (<strong> ' . __('Notice that it is possible to get mixtures of success and failure messages when using the ‘Allow Multiple’ option') . '</strong>)' : NULL) . ':');
                if ($multiple) {
                    $code = new XMLElement($rootelement);
                    $entry = new XMLElement('entry', NULL, array('index' => '0', 'result' => 'error'));
                    $entry->appendChild(new XMLElement('message', __('Entry encountered errors when saving.')));
                    $entry->appendChild(new XMLElement('field-name', NULL, array('type' => 'invalid | missing')));
                    $code->appendChild($entry);
                    $entry = new XMLElement('entry', NULL, array('index' => '1', 'result' => 'success', 'type' => 'create | edit'));
                    $entry->appendChild(new XMLElement('message', __('Entry [created | edited] successfully.')));
                    $code->appendChild($entry);
                } else {
                    $code = new XMLElement($rootelement, NULL, array('result' => 'error'));
                    $code->appendChild(new XMLElement('message', __('Entry encountered errors when saving.')));
                    $code->appendChild(new XMLElement('field-name', NULL, array('type' => 'invalid | missing')));
                }
                $code->setValue('...', false);
                $documentation_parts[] = self::processDocumentationCode($code);
                if (is_array($filters) && !empty($filters)) {
                    $documentation_parts[] = new XMLElement('p', __('The following is an example of what is returned if any options return an error:'));
                    $code = new XMLElement($rootelement, NULL, array('result' => 'error'));
                    $code->appendChild(new XMLElement('message', __('Entry encountered errors when saving.')));
                    $code->appendChild(new XMLElement('filter', NULL, array('name' => 'admin-only', 'status' => 'failed')));
                    $code->appendChild(new XMLElement('filter', __('Recipient not found'), array('name' => 'send-email', 'status' => 'failed')));
                    $code->setValue('...', false);
                    $documentation_parts[] = self::processDocumentationCode($code);
                }
                $documentation_parts[] = new XMLElement('h3', __('Example Front-end Form Markup'));
                $documentation_parts[] = new XMLElement('p', __('This is an example of the form markup you can use on your frontend:'));
                $container = new XMLElement('form', NULL, array('method' => 'post', 'action' => '', 'enctype' => 'multipart/form-data'));
                $container->appendChild(Widget::Input('MAX_FILE_SIZE', (string) min(ini_size_to_bytes(ini_get('upload_max_filesize')), Symphony::Configuration()->get('max_upload_size', 'admin')), 'hidden'));
                if (is_numeric($fields['source'])) {
                    $section = SectionManager::fetch($fields['source']);
                    if ($section instanceof Section) {
                        $section_fields = $section->fetchFields();
                        if (is_array($section_fields) && !empty($section_fields)) {
                            foreach ($section_fields as $f) {
                                if ($f->getExampleFormMarkup() instanceof XMLElement) {
                                    $container->appendChild($f->getExampleFormMarkup());
                                }
                            }
                        }
                    }
                }
                $container->appendChild(Widget::Input('action[' . $rootelement . ']', __('Submit'), 'submit'));
                $code = $container->generate(true);
                $documentation_parts[] = self::processDocumentationCode($multiple ? str_replace('fields[', 'fields[0][', $code) : $code);
                $documentation_parts[] = new XMLElement('p', __('To edit an existing entry, include the entry ID value of the entry in the form. This is best as a hidden field like so:'));
                $documentation_parts[] = self::processDocumentationCode(Widget::Input('id' . ($multiple ? '[0]' : NULL), '23', 'hidden'));
                $documentation_parts[] = new XMLElement('p', __('To redirect to a different location upon a successful save, include the redirect location in the form. This is best as a hidden field like so, where the value is the URL to redirect to:'));
                $documentation_parts[] = self::processDocumentationCode(Widget::Input('redirect', URL . '/success/', 'hidden'));
                if (in_array('send-email', $filters)) {
                    $documentation_parts[] = new XMLElement('h3', __('Send Notification Email'));
                    $documentation_parts[] = new XMLElement('p', __('Upon the event successfully saving the entry, this option takes input from the form and send an email to the desired recipient.') . ' <strong>' . __('It currently does not work with ‘Allow Multiple’') . '</strong>. ' . __('The following are the recognised fields:'));
                    $documentation_parts[] = self::processDocumentationCode('send-email[sender-email] // ' . __('Optional') . PHP_EOL . 'send-email[sender-name] // ' . __('Optional') . PHP_EOL . 'send-email[reply-to-email] // ' . __('Optional') . PHP_EOL . 'send-email[reply-to-name] // ' . __('Optional') . PHP_EOL . 'send-email[subject]' . PHP_EOL . 'send-email[body]' . PHP_EOL . 'send-email[recipient] // ' . __('list of comma-separated author usernames.'));
                    $documentation_parts[] = new XMLElement('p', __('All of these fields can be set dynamically using the exact field name of another field in the form as shown below in the example form:'));
                    $documentation_parts[] = self::processDocumentationCode('<form action="" method="post">
		<fieldset>
			<label>' . __('Name') . ' <input type="text" name="fields[author]" value="" /></label>
			<label>' . __('Email') . ' <input type="text" name="fields[email]" value="" /></label>
			<label>' . __('Message') . ' <textarea name="fields[message]" rows="5" cols="21"></textarea></label>
			<input name="send-email[sender-email]" value="fields[email]" type="hidden" />
			<input name="send-email[sender-name]" value="fields[author]" type="hidden" />
			<input name="send-email[reply-to-email]" value="fields[email]" type="hidden" />
			<input name="send-email[reply-to-name]" value="fields[author]" type="hidden" />
开发者ID:hananils,项目名称:pompodium,代码行数:67,代码来源:content.blueprintsevents.php

示例14: fetchPageByTypes

 /**
  * Returns Pages that match the given `$types`. If no `$types` is provided
  * the function returns the result of `PageManager::fetch`.
  *
  * @param array $types
  *  An array of some of the available Page Types.
  * @param boolean $negate (optional)
  *  If true, the logic gets inversed to return Pages that don't match the given `$types`.
  * @return array|null
  *  An associative array of Page information with the key being the column
  *  name from `tbl_pages` and the value being the data. If multiple Pages
  *  are found, an array of Pages will be returned. If no Pages are found
  *  null is returned.
  */
 public static function fetchPageByTypes(array $types = array(), $andOperation = false, $negate = false)
 {
     if (empty($types)) {
         return PageManager::fetch();
     }
     $types = array_map(array('MySQL', 'cleanValue'), $types);
     // Build SQL parts depending on query parameters. There are four possibilities.
     // 1. Without negation and with OR filter
     if (!$andOperation && !$negate) {
         $join = "LEFT JOIN `tbl_pages_types` AS `pt` ON (p.id = pt.page_id)";
         $where = sprintf("\n\t\t\t\t\t\tAND `pt`.type IN ('%s')\n\t\t\t\t\t", implode("', '", $types));
     } elseif ($andOperation && !$negate) {
         $join = "";
         $where = "";
         foreach ($types as $index => $type) {
             $join .= " LEFT JOIN `tbl_pages_types` AS `pt_{$index}` ON (p.id = pt_{$index}.page_id)";
             $where .= " AND pt_{$index}.type = '" . $type . "'";
         }
     } elseif (!$andOperation && $negate) {
         $join = sprintf("\n\t\t\t\t\t\tLEFT JOIN `tbl_pages_types` AS `pt` ON (p.id = pt.page_id AND pt.type IN ('%s'))\n\t\t\t\t\t", implode("', '", $types));
         $where = "AND `pt`.type IS NULL";
     } elseif ($andOperation && $negate) {
         $join = "";
         $where = "AND (";
         foreach ($types as $index => $type) {
             $join .= sprintf("\n\t\t\t\t\t\t\tLEFT JOIN `tbl_pages_types` AS `pt_%s` ON (p.id = pt_%s.page_id AND pt_%s.type IN ('%s'))\n\t\t\t\t\t\t", $index, $index, $index, $type);
             $where .= ($index === 0 ? "" : " OR ") . "pt_{$index}.type IS NULL";
         }
         $where .= ")";
     }
     $pages = Symphony::Database()->fetch(sprintf("\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t`p`.*\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`tbl_pages` AS `p`\n\t\t\t\t\t%s\n\t\t\t\t\tWHERE 1\n\t\t\t\t\t\t%s\n\t\t\t\t", $join, $where));
     return count($pages) == 1 ? array_pop($pages) : $pages;
 }
开发者ID:klaftertief,项目名称:page_prototypes,代码行数:47,代码来源:class.pageprototypes.php

示例15: getChildPagesCount

 /**
  * This function will return the number of child pages for a given
  * `$page_id`. This is a recursive function and will return the absolute
  * count.
  *
  * @param integer $page_id
  *  The ID of the Page.
  * @return integer
  *  The number of child pages for the given `$page_id`
  */
 public static function getChildPagesCount($page_id = null)
 {
     if (is_null($page_id)) {
         return null;
     }
     $children = PageManager::fetch(false, array('id'), array(sprintf('parent = %d', $page_id)));
     $count = count($children);
     if ($count > 0) {
         foreach ($children as $c) {
             $count += self::getChildPagesCount($c['id']);
         }
     }
     return $count;
 }
开发者ID:nickdunn,项目名称:elasticsearch-surfin-shakespeare,代码行数:24,代码来源:class.pagemanager.php


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