コード例 #1
0
 /**
  * Returns all the page types that exist in this Symphony install.
  * There are 6 default system page types, and new types can be added
  * by Developers via the Page Editor.
  *
  * @since Symphony 2.3 introduced the JSON type.
  * @return array
  *  An array of strings of the page types used in this Symphony
  *  install. At the minimum, this will be an array with the values
  * 'index', 'XML', 'JSON', 'admin', '404' and '403'.
  */
 public static function fetchAvailablePageTypes()
 {
     $system_types = array('index', 'XML', 'JSON', 'admin', '404', '403');
     $types = PageManager::fetchPageTypes();
     return !empty($types) ? General::array_remove_duplicates(array_merge($system_types, $types)) : $system_types;
 }
コード例 #2
0
 /**
  * Given a page ID, return it's type from `tbl_pages`
  *
  * @deprecated This function will be removed in Symphony 2.4. Use
  * `PageManager::fetchPageTypes` instead.
  * @param integer $page_id
  *  The page ID to find it's type
  * @return array
  *  An array of types that this page is set as
  */
 public static function fetchPageTypes($page_id)
 {
     return PageManager::fetchPageTypes($page_id);
 }
コード例 #3
0
 /**
  * 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);
 }
コード例 #4
0
 public function __viewEdit()
 {
     $this->setPageType('form');
     $fields = array("title" => null, "handle" => null, "parent" => null, "params" => null, "type" => null, "data_sources" => null);
     $existing = $fields;
     $nesting = Symphony::Configuration()->get('pages_table_nest_children', 'symphony') == 'yes';
     // Verify page exists:
     if ($this->_context[0] == 'edit') {
         if (!($page_id = (int) $this->_context[1])) {
             redirect(SYMPHONY_URL . '/blueprints/pages/');
         }
         $existing = PageManager::fetchPageByID($page_id);
         if (!$existing) {
             Administration::instance()->errorPageNotFound();
         } else {
             $existing['type'] = PageManager::fetchPageTypes($page_id);
         }
     }
     // Status message:
     if (isset($this->_context[2])) {
         $flag = $this->_context[2];
         $link_suffix = '';
         if (isset($_REQUEST['parent']) && is_numeric($_REQUEST['parent'])) {
             $link_suffix = "?parent=" . $_REQUEST['parent'];
         } else {
             if ($nesting == true && isset($existing) && !is_null($existing['parent'])) {
                 $link_suffix = '?parent=' . $existing['parent'];
             }
         }
         switch ($flag) {
             case 'saved':
                 $this->pageAlert(__('Page updated at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/blueprints/pages/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/blueprints/pages/" accesskey="a">' . __('View all Pages') . '</a>', Alert::SUCCESS);
                 break;
             case 'created':
                 $this->pageAlert(__('Page created at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/blueprints/pages/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/blueprints/pages/" accesskey="a">' . __('View all Pages') . '</a>', Alert::SUCCESS);
         }
     }
     // Find values:
     if (isset($_POST['fields'])) {
         $fields = $_POST['fields'];
     } elseif ($this->_context[0] == 'edit') {
         $fields = $existing;
         if (!is_null($fields['type'])) {
             $fields['type'] = implode(', ', $fields['type']);
         }
         $fields['data_sources'] = preg_split('/,/i', $fields['data_sources'], -1, PREG_SPLIT_NO_EMPTY);
         $fields['events'] = preg_split('/,/i', $fields['events'], -1, PREG_SPLIT_NO_EMPTY);
     } elseif (isset($_REQUEST['parent']) && is_numeric($_REQUEST['parent'])) {
         $fields['parent'] = $_REQUEST['parent'];
     }
     $title = $fields['title'];
     if (trim($title) == '') {
         $title = $existing['title'];
     }
     $this->setTitle(__($title ? '%1$s &ndash; %2$s &ndash; %3$s' : '%2$s &ndash; %3$s', array($title, __('Pages'), __('Symphony'))));
     $page_id = isset($page_id) ? $page_id : null;
     if (!empty($title)) {
         $template_name = $fields['handle'];
         $page_url = URL . '/' . PageManager::resolvePagePath($page_id) . '/';
         if ($existing['parent']) {
             $parents = PageManager::resolvePagePath($existing['parent']);
             $template_name = PageManager::createFilePath($parents, $fields['handle']);
         }
         $this->appendSubheading($title, array(Widget::Anchor(__('View Page'), $page_url, __('View Page on Frontend'), 'button', NULL, array('target' => '_blank', 'accesskey' => 'v')), Widget::Anchor(__('Edit Page Template'), SYMPHONY_URL . '/blueprints/pages/template/' . $template_name, __('Edit Page Template'), 'button', NULL, array('accesskey' => 't'))));
     } else {
         $this->appendSubheading(!empty($title) ? $title : __('Untitled'));
     }
     if (isset($page_id)) {
         $this->insertBreadcrumbsUsingPageIdentifier($page_id, false);
     } else {
         $_GET['parent'] = isset($_GET['parent']) ? $_GET['parent'] : null;
         $this->insertBreadcrumbsUsingPageIdentifier((int) $_GET['parent'], true);
     }
     // Title --------------------------------------------------------------
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('class', 'settings');
     $fieldset->appendChild(new XMLElement('legend', __('Page Settings')));
     $label = Widget::Label(__('Title'));
     $label->appendChild(Widget::Input('fields[title]', General::sanitize($fields['title'])));
     if (isset($this->_errors['title'])) {
         $label = Widget::Error($label, $this->_errors['title']);
     }
     $fieldset->appendChild($label);
     // Handle -------------------------------------------------------------
     $group = new XMLElement('div');
     $group->setAttribute('class', 'two columns');
     $column = new XMLElement('div');
     $column->setAttribute('class', 'column');
     $label = Widget::Label(__('URL Handle'));
     $label->appendChild(Widget::Input('fields[handle]', $fields['handle']));
     if (isset($this->_errors['handle'])) {
         $label = Widget::Error($label, $this->_errors['handle']);
     }
     $column->appendChild($label);
     // Parent ---------------------------------------------------------
     $label = Widget::Label(__('Parent Page'));
     $where = array(sprintf('id != %d', $page_id));
     $pages = PageManager::fetch(false, array('id'), $where, 'title ASC');
     $options = array(array('', false, '/'));
     if (!empty($pages)) {
         if (!function_exists('__compare_pages')) {
             function __compare_pages($a, $b)
             {
                 return strnatcasecmp($a[2], $b[2]);
             }
         }
         foreach ($pages as $page) {
             $options[] = array($page['id'], $fields['parent'] == $page['id'], '/' . PageManager::resolvePagePath($page['id']));
         }
         usort($options, '__compare_pages');
     }
     $label->appendChild(Widget::Select('fields[parent]', $options));
     $column->appendChild($label);
     $group->appendChild($column);
     // Parameters ---------------------------------------------------------
     $column = new XMLElement('div');
     $column->setAttribute('class', 'column');
     $label = Widget::Label(__('URL Parameters'));
     $label->appendChild(Widget::Input('fields[params]', $fields['params'], 'text', array('placeholder' => 'param1/param2')));
     $column->appendChild($label);
     // Type -----------------------------------------------------------
     $label = Widget::Label(__('Page Type'));
     $label->appendChild(Widget::Input('fields[type]', $fields['type']));
     if (isset($this->_errors['type'])) {
         $label = Widget::Error($label, $this->_errors['type']);
     }
     $column->appendChild($label);
     $tags = new XMLElement('ul');
     $tags->setAttribute('class', 'tags');
     $types = PageManager::fetchAvailablePageTypes();
     foreach ($types as $type) {
         $tags->appendChild(new XMLElement('li', $type));
     }
     $column->appendChild($tags);
     $group->appendChild($column);
     $fieldset->appendChild($group);
     $this->Form->appendChild($fieldset);
     // Events -------------------------------------------------------------
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('class', 'settings');
     $fieldset->appendChild(new XMLElement('legend', __('Page Resources')));
     $group = new XMLElement('div');
     $group->setAttribute('class', 'two columns');
     $label = Widget::Label(__('Events'));
     $label->setAttribute('class', 'column');
     $events = ResourceManager::fetch(RESOURCE_TYPE_EVENT, array(), array(), 'name ASC');
     $options = array();
     if (is_array($events) && !empty($events)) {
         if (!isset($fields['events'])) {
             $fields['events'] = array();
         }
         foreach ($events as $name => $about) {
             $options[] = array($name, in_array($name, $fields['events']), $about['name']);
         }
     }
     $label->appendChild(Widget::Select('fields[events][]', $options, array('multiple' => 'multiple')));
     $group->appendChild($label);
     // Data Sources -------------------------------------------------------
     $label = Widget::Label(__('Data Sources'));
     $label->setAttribute('class', 'column');
     $datasources = ResourceManager::fetch(RESOURCE_TYPE_DS, array(), array(), 'name ASC');
     $options = array();
     if (is_array($datasources) && !empty($datasources)) {
         if (!isset($fields['data_sources'])) {
             $fields['data_sources'] = array();
         }
         foreach ($datasources as $name => $about) {
             $options[] = array($name, in_array($name, $fields['data_sources']), $about['name']);
         }
     }
     $label->appendChild(Widget::Select('fields[data_sources][]', $options, array('multiple' => 'multiple')));
     $group->appendChild($label);
     $fieldset->appendChild($group);
     $this->Form->appendChild($fieldset);
     // Controls -----------------------------------------------------------
     /**
      * After all Page related Fields have been added to the DOM, just before the
      * actions.
      *
      * @delegate AppendPageContent
      * @param string $context
      *  '/blueprints/pages/'
      * @param XMLElement $form
      * @param array $fields
      * @param array $errors
      */
     Symphony::ExtensionManager()->notifyMembers('AppendPageContent', '/blueprints/pages/', array('form' => &$this->Form, 'fields' => &$fields, 'errors' => $this->_errors));
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $div->appendChild(Widget::Input('action[save]', $this->_context[0] == 'edit' ? __('Save Changes') : __('Create Page'), 'submit', array('accesskey' => 's')));
     if ($this->_context[0] == 'edit') {
         $button = new XMLElement('button', __('Delete'));
         $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'button confirm delete', 'title' => __('Delete this page'), 'accesskey' => 'd', 'data-message' => __('Are you sure you want to delete this page?')));
         $div->appendChild($button);
     }
     $this->Form->appendChild($div);
     if (isset($_REQUEST['parent']) && is_numeric($_REQUEST['parent'])) {
         $this->Form->appendChild(new XMLElement('input', NULL, array('type' => 'hidden', 'name' => 'parent', 'value' => $_REQUEST['parent'])));
     }
 }
コード例 #5
0
 /**
  * This function attempts to resolve the given page in to it's Symphony page. If no
  * page is given, it is assumed the 'index' is being requested. Before a page row is
  * returned, it is checked to see that if it has the 'admin' type, that the requesting
  * user is authenticated as a Symphony author. If they are not, the Symphony 403
  * page is returned (whether that be set as a user defined page using the page type
  * of 403, or just returning the Default Symphony 403 error page). Any URL parameters
  * set on the page are added to the `$env` variable before the function returns an
  * associative array of page details such as Title, Content Type etc.
  *
  * @uses FrontendPrePageResolve
  * @see __isSchemaValid()
  * @param string $page
  * The URL of the current page that is being Rendered as returned by `getCurrentPage()`.
  * If no URL is provided, Symphony assumes the Page with the type 'index' is being
  * requested.
  * @throws SymphonyErrorPage
  * @return array
  *  An associative array of page details
  */
 public function resolvePage($page = null)
 {
     if ($page) {
         $this->_page = $page;
     }
     $row = null;
     /**
      * Before page resolve. Allows manipulation of page without redirection
      * @delegate FrontendPrePageResolve
      * @param string $context
      * '/frontend/'
      * @param mixed $row
      * @param FrontendPage $page
      *  An instance of this FrontendPage
      */
     Symphony::ExtensionManager()->notifyMembers('FrontendPrePageResolve', '/frontend/', array('row' => &$row, 'page' => &$this->_page));
     // Default to the index page if no page has been specified
     if ((!$this->_page || $this->_page == '//') && is_null($row)) {
         $row = PageManager::fetchPageByType('index');
         // Not the index page (or at least not on first impression)
     } elseif (is_null($row)) {
         $page_extra_bits = array();
         $pathArr = preg_split('/\\//', trim($this->_page, '/'), -1, PREG_SPLIT_NO_EMPTY);
         $handle = array_pop($pathArr);
         do {
             $path = implode('/', $pathArr);
             if ($row = PageManager::resolvePageByPath($handle, $path)) {
                 $pathArr[] = $handle;
                 break 1;
             } else {
                 $page_extra_bits[] = $handle;
             }
         } while ($handle = array_pop($pathArr));
         // If the `$pathArr` is empty, that means a page hasn't resolved for
         // the given `$page`, however in some cases the index page may allow
         // parameters, so we'll check.
         if (empty($pathArr)) {
             // If the index page does not handle parameters, then return false
             // (which will give up the 404), otherwise treat the `$page` as
             // parameters of the index. RE: #1351
             $index = PageManager::fetchPageByType('index');
             if (!$this->__isSchemaValid($index['params'], $page_extra_bits)) {
                 return false;
             } else {
                 $row = $index;
             }
             // Page resolved, check the schema (are the parameters valid?)
         } elseif (!$this->__isSchemaValid($row['params'], $page_extra_bits)) {
             return false;
         }
     }
     // Process the extra URL params
     $url_params = preg_split('/\\//', $row['params'], -1, PREG_SPLIT_NO_EMPTY);
     foreach ($url_params as $var) {
         $this->_env['url'][$var] = null;
     }
     if (isset($page_extra_bits)) {
         if (!empty($page_extra_bits)) {
             $page_extra_bits = array_reverse($page_extra_bits);
         }
         for ($i = 0, $ii = count($page_extra_bits); $i < $ii; $i++) {
             $this->_env['url'][$url_params[$i]] = str_replace(' ', '+', $page_extra_bits[$i]);
         }
     }
     if (!is_array($row) || empty($row)) {
         return false;
     }
     $row['type'] = PageManager::fetchPageTypes($row['id']);
     // Make sure the user has permission to access this page
     if (!$this->is_logged_in && in_array('admin', $row['type'])) {
         $row = PageManager::fetchPageByType('403');
         if (empty($row)) {
             Frontend::instance()->throwCustomError(__('Please login to view this page.') . ' <a href="' . SYMPHONY_URL . '/login/">' . __('Take me to the login page') . '</a>.', __('Forbidden'), Page::HTTP_STATUS_FORBIDDEN);
         }
         $row['type'] = PageManager::fetchPageTypes($row['id']);
     }
     $row['filelocation'] = PageManager::resolvePageFileLocation($row['path'], $row['handle']);
     return $row;
 }
コード例 #6
0
 /**
  * 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) {
         $template = new XMLElement('li');
         $template->appendChild(new XMLElement('header', '<h3>' . $preset['name'] . '</h3>'));
         $template->appendChild(Widget::Label(__('Name'), Widget::Input('ckeditor_presets[' . $index . '][name]', $preset['name'])));
         $template->appendChild(Widget::Label(__('Toolbar'), Widget::Textarea('ckeditor_presets[' . $index . '][toolbar]', 5, 50, $preset['toolbar'])));
         $template->appendChild(Widget::Label(__('Plugins'), Widget::Textarea('ckeditor_presets[' . $index . '][plugins]', 5, 50, $preset['plugins'])));
         $template->appendChild(Widget::Label(__('%s Enable resizing', array(Widget::Input('ckeditor_presets[' . $index . '][resize]', '1', 'checkbox', $preset['resize'] == 1 ? array('checked' => 'checked') : null)->generate()))));
         $template->appendChild(Widget::Label(__('%s Show outline blocks', array(Widget::Input('ckeditor_presets[' . $index . '][outline]', '1', 'checkbox', $preset['outline'] == 1 ? array('checked' => 'checked') : null)->generate()))));
         $ol->appendChild($template);
         $index++;
     }
     $fieldset->appendChild($ol);
     // Styles:
     $fieldset->appendChild(new XMLElement('p', __('Styles: (one style per line: <code>h3.example { color: #f00; background: #0f0; }</code>) Class name is converted to name (h3.hello-world = Hello World).'), array('class' => 'label')));
     $textarea = Widget::Textarea('ckeditor[styles]', 5, 50, Symphony::Configuration()->get('styles', 'ckeditor'));
     $fieldset->appendChild($textarea);
     $wrapper->appendChild($fieldset);
 }
コード例 #7
0
 public function checkFrontendPagePermissions($context)
 {
     $isLoggedIn = false;
     $errors = array();
     $action = null;
     // Checks $_REQUEST to see if a Member Action has been requested,
     // member-action['login'] and member-action['logout']/?member-action=logout
     // are the only two supported at this stage.
     if (isset($_REQUEST['member-action']) && is_array($_REQUEST['member-action'])) {
         list($action) = array_keys($_REQUEST['member-action']);
     } else {
         if (isset($_REQUEST['member-action'])) {
             $action = $_REQUEST['member-action'];
         }
     }
     // Check to see a Member is already logged in.
     $isLoggedIn = $this->getMemberDriver()->isLoggedIn($errors);
     // Logout
     if (trim($action) == 'logout') {
         /**
          * Fired just before a member is logged out (and page redirection),
          * this delegate provides the current Member ID
          *
          * @delegate MembersPreLogout
          * @param string $context
          *  '/frontend/'
          * @param integer $member_id
          *  The Member ID of the member who is about to logged out
          */
         Symphony::ExtensionManager()->notifyMembers('MembersPreLogout', '/frontend/', array('member_id' => $this->getMemberDriver()->getMemberID()));
         $this->getMemberDriver()->logout();
         // If a redirect is provided, redirect to that, otherwise return the user
         // to the index of the site. Issue #51 & #121
         if (isset($_REQUEST['redirect'])) {
             redirect($_REQUEST['redirect']);
         }
         redirect(URL);
     } else {
         if (trim($action) == 'login' && !is_null($_POST['fields'])) {
             // If a Member is already logged in and another Login attempt is requested
             // log the Member out first before trying to login with new details.
             if ($isLoggedIn) {
                 $this->getMemberDriver()->logout();
             }
             if ($this->getMemberDriver()->login($_POST['fields'])) {
                 /**
                  * Fired just after a Member has successfully logged in, this delegate
                  * provides the current Member ID. This delegate is fired just before
                  * the page redirection (if it is provided)
                  *
                  * @delegate MembersPostLogin
                  * @param string $context
                  *  '/frontend/'
                  * @param integer $member_id
                  *  The Member ID of the member who just logged in.
                  * @param Entry $member
                  *  The Entry object of the logged in Member.
                  */
                 Symphony::ExtensionManager()->notifyMembers('MembersPostLogin', '/frontend/', array('member_id' => $this->getMemberDriver()->getMemberID(), 'member' => $this->getMemberDriver()->getMember()));
                 if (isset($_POST['redirect'])) {
                     redirect($_POST['redirect']);
                 }
             } else {
                 self::$_failed_login_attempt = true;
                 /**
                  * A failed Member login attempt
                  *
                  * @delegate MembersLoginFailure
                  * @param string $context
                  *  '/frontend/'
                  * @param string $username
                  *  The username of the Member who attempted to login.
                  */
                 Symphony::ExtensionManager()->notifyMembers('MembersLoginFailure', '/frontend/', array('username' => Symphony::Database()->cleanValue($_POST['fields'][extension_Members::getFieldHandle('identity')])));
             }
         }
     }
     $this->Member->initialiseMemberObject();
     $hasRoles = FieldManager::isFieldUsed(extension_Members::getFieldType('role'));
     if ($isLoggedIn && $this->getMemberDriver()->getMember() instanceof Entry) {
         $this->getMemberDriver()->updateSystemTimezoneOffset();
         if ($hasRoles) {
             $role_field = extension_Members::getField('role');
             if ($role_field) {
                 $role_data = $this->getMemberDriver()->getMember()->getData($role_field->get('id'));
             }
         }
     }
     // If there is no role field, or a Developer is logged in, return, as Developers
     // should be able to access every page. Handles Symphony 2.4 or Symphony 2.5
     $isDeveloper = method_exists(Symphony::Engine(), 'Author') ? Symphony::Engine()->Author() instanceof Author && Symphony::Engine()->Author()->isDeveloper() : Symphony::Engine()->Author instanceof Author && Symphony::Engine()->Author->isDeveloper();
     if (!$hasRoles || $isDeveloper) {
         return;
     }
     $role_id = $isLoggedIn ? $role_data['role_id'] : Role::PUBLIC_ROLE;
     $role = RoleManager::fetch($role_id);
     if ($role instanceof Role && !$role->canAccessPage((int) $context['page_data']['id'])) {
         // User has no access to this page, so look for a custom 403 page
         if ($row = PageManager::fetchPageByType('403')) {
             $row['type'] = PageManager::fetchPageTypes($row['id']);
             $row['filelocation'] = PageManager::resolvePageFileLocation($row['path'], $row['handle']);
             $context['page_data'] = $row;
             return;
         } else {
             // No custom 403, just throw default 403
             GenericExceptionHandler::$enabled = true;
             Frontend::instance()->throwCustomError(__('The page you have requested has restricted access permissions.'), __('Forbidden'), Page::HTTP_STATUS_FORBIDDEN);
         }
     }
 }
コード例 #8
0
 public static function isPagePrototype($page_id)
 {
     $page_types = PageManager::fetchPageTypes($page_id);
     return in_array('prototype', $page_types);
 }