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


PHP Section::loadFromHandle方法代码示例

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


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

示例1: load

 /**
  * Perform initial checks and load requested view
  *
  * @param string $url
  *  URL path of requested view
  */
 public function load($url = null)
 {
     // Check for login
     Controller::instance()->isLoggedIn();
     if (!Controller::instance()->isLoggedIn()) {
         $this->parseURL('/login');
     } else {
         try {
             if (is_null($url)) {
                 // Get user's default section
                 $section_handle = Controller::instance()->User->default_section;
                 // If the section exists, load publish view
                 try {
                     $section = Section::loadFromHandle($section_handle);
                     $this->parseURL('/publish/' . $section_handle);
                 } catch (Exception $e) {
                     $this->parseURL('/blueprints/sections/');
                 }
             } else {
                 $this->parseURL($url);
             }
             // TODO: Fix this
             if (!$this instanceof AdministrationView) {
                 throw new Exception('View not found');
             }
         } catch (Exception $e) {
             throw $e;
             //catch the exception
             print 'Sorry could not load ' . $url;
         }
     }
 }
开发者ID:symphonycms,项目名称:symphony-3,代码行数:38,代码来源:class.administrationview.php

示例2: __construct

 public function __construct()
 {
     $this->view = Controller::instance()->View;
     $this->document = $this->view->document;
     $this->url = Controller::instance()->url;
     // Probably a neater way to store and fetch the section handle
     $this->section = Section::loadFromHandle($this->view->params[0]);
     $this->setTitle();
 }
开发者ID:symphonycms,项目名称:symphony-3,代码行数:9,代码来源:publish.driver.php

示例3: prepareDestinationColumnValue

 public function prepareDestinationColumnValue()
 {
     $section = Section::loadFromHandle($this->_parameters->section);
     if ($section instanceof Section) {
         return Widget::TableData(Widget::Anchor($section->name, ADMIN_URL . '/blueprints/sections/edit/' . $section->handle . '/', array('title' => $section->handle)));
     } else {
         return Widget::TableData(__('None'), array('class' => 'inactive'));
     }
 }
开发者ID:symphonycms,项目名称:symphony-3,代码行数:9,代码来源:class.event.php

示例4: __actionIndex

 function __actionIndex()
 {
     $checked = is_array($_POST['items']) ? array_keys($_POST['items']) : null;
     $callback = Administration::instance()->getPageCallback();
     if (is_array($checked) && !empty($checked)) {
         switch ($_POST['with-selected']) {
             case 'delete':
                 ###
                 # Delegate: Delete
                 # Description: Prior to deletion of entries. Array of Entries is provided.
                 #              The array can be manipulated
                 Extension::notify('Delete', '/publish/', array('entry_id' => &$checked));
                 foreach ($checked as $entry_id) {
                     Entry::delete($entry_id);
                 }
                 redirect($_SERVER['REQUEST_URI']);
             default:
                 ## TODO: Add delegate
                 //	I've add this in a 2.0.8 commit, look for it //brendan
                 list($option, $field_handle, $value) = explode('::', $_POST['with-selected'], 3);
                 if ($option == 'toggle') {
                     // TO DO: This is a funky way to access a field via its handle. Might need to rethink this
                     $section = Section::loadFromHandle($callback['context']['section_handle']);
                     foreach ($section->fields as $f) {
                         if ($f->{'element-name'} == $field_handle) {
                             $field = $f;
                             break;
                         }
                     }
                     if ($field instanceof Field) {
                         foreach ($checked as $entry_id) {
                             $entry = Entry::loadFromID($entry_id);
                             $entry->data()->{$field_handle} = $field->processData($value, $entry);
                             $this->errors->flush();
                             Entry::save($entry, $this->errors);
                         }
                     }
                     redirect($_SERVER['REQUEST_URI']);
                 }
                 break;
         }
     }
 }
开发者ID:pointybeard,项目名称:symphony-3,代码行数:43,代码来源:content.publish.php

示例5: __form

 public function __form(Entry $existing = NULL)
 {
     $callback = Administration::instance()->getPageCallback();
     $section = Section::loadFromHandle($callback['context']['section_handle']);
     // Check that a layout and fields exist
     if (isset($section->fields)) {
         $this->alerts()->append(__('It looks like you\'re trying to create an entry. Perhaps you want fields first? <a href="%s">Click here to create some.</a>', array(ADMIN_URL . '/blueprints/sections/edit/' . $section->handle . '/')), AlertStack::ERROR);
     }
     $this->Form->setAttribute('enctype', 'multipart/form-data');
     $this->setTitle(__('%1$s &ndash; %2$s', array(__('Symphony'), $section->name)));
     $subheading = __('New Entry');
     if (!is_null($existing) && $existing instanceof Entry) {
         if (is_null($this->entry) || !$this->entry instanceof Entry) {
             $this->entry = $existing;
         }
         // Grab the first field in the section
         $first_field = $section->fields[0];
         $field_data = (object) array();
         if (!is_null($existing->data()->{$first_field->{'element-name'}})) {
             $field_data = $existing->data()->{$first_field->{'element-name'}};
         }
         $subheading = $first_field->prepareTableValue($field_data);
     }
     if (is_null($this->entry) || !$this->entry instanceof Entry) {
         $this->entry = new Entry();
     }
     $this->entry->section = $callback['context']['section_handle'];
     $this->appendSubheading($subheading);
     $this->entry->findDefaultFieldData();
     $this->Form->appendChild(Widget::Input('MAX_FILE_SIZE', Symphony::Configuration()->core()->symphony->{'maximum-upload-size'}, 'hidden'));
     // Check if there is a field to prepopulate
     if (isset($_REQUEST['prepopulate']) && strlen(trim($_REQUEST['prepopulate'])) > 0) {
         $field_handle = key($_REQUEST['prepopulate']);
         $value = stripslashes(rawurldecode($_REQUEST['prepopulate'][$field_handle]));
         $prepopulate_filter = "?prepopulate[{$field_handle}]=" . rawurlencode($value);
         $this->Form->setAttribute('action', Administration::instance()->getCurrentPageURL() . $prepopulate_filter);
         if (is_null($existing)) {
             $this->entry->data()->{$field_handle}->value = $value;
         }
     }
     // Status message:
     if (isset($callback['flag']) and !is_null($callback['flag'])) {
         switch ($callback['flag']) {
             case 'saved':
                 $this->alerts()->append(__('Entry updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Entries</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/publish/' . $callback['context']['section_handle'] . '/new/' . $prepopulate_filter, ADMIN_URL . '/publish/' . $callback['context']['section_handle'] . '/')), AlertStack::SUCCESS);
                 break;
             case 'created':
                 $this->alerts()->append(__('Entry created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Entries</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/publish/' . $callback['context']['section_handle'] . '/new/' . $prepopulate_filter, ADMIN_URL . '/publish/' . $callback['context']['section_handle'] . '/')), AlertStack::SUCCESS);
                 break;
         }
     }
     // Load all the fields for this section
     $section_fields = array();
     foreach ($section->fields as $index => $field) {
         $section_fields[$field->{'element-name'}] = $field;
     }
     $layout = new Layout();
     if (is_array($section->layout) && !empty($section->layout)) {
         foreach ($section->layout as $data) {
             $column = $layout->createColumn($data->size);
             foreach ($data->fieldsets as $data) {
                 $fieldset = $this->createElement('fieldset');
                 if (isset($data->collapsed) && $data->collapsed == 'yes') {
                     $fieldset->setAttribute('class', 'collapsed');
                 }
                 if (isset($data->name) && strlen(trim($data->name)) > 0) {
                     $fieldset->appendChild($this->createElement('h3', $data->name));
                 }
                 foreach ($data->fields as $handle) {
                     $field = $section_fields[$handle];
                     if (!$field instanceof Field) {
                         continue;
                     }
                     $div = $this->createElement('div', NULL, array('class' => trim(sprintf('field field-%s %s %s', $field->handle(), $this->__calculateWidth($field->width), $field->required == 'yes' ? 'required' : ''))));
                     $field->displayPublishPanel($div, isset($this->errors->{$field->{'element-name'}}) ? $this->errors->{$field->{'element-name'}} : new MessageStack(), $this->entry, $this->entry->data()->{$field->{'element-name'}});
                     $fieldset->appendChild($div);
                 }
                 $column->appendChild($fieldset);
             }
             $layout->appendTo($this->Form);
         }
     } else {
         $this->alerts()->append(__('You haven\'t set any section layout rules. <a href="%s">Click here to define a layout.</a>', array(ADMIN_URL . '/blueprints/sections/layout/' . $section->handle . '/')), AlertStack::ERROR);
         $column = $layout->createColumn(Layout::LARGE);
         $fieldset = $this->createElement('fieldset');
         $header = $this->createElement('h3', __('Untitled'));
         $fieldset->appendChild($header);
         if (is_array($section->fields)) {
             foreach ($section->fields as $field) {
                 $div = $this->createElement('div', NULL, array('class' => trim(sprintf('field field-%s %s %s', $field->handle(), $this->__calculateWidth($field->width), $field->required == 'yes' ? 'required' : 'optional'))));
                 $field->displayPublishPanel($div, isset($this->errors->{$field->{'element-name'}}) ? $this->errors->{$field->{'element-name'}} : new MessageStack(), $this->entry, $this->entry->data()->{$field->{'element-name'}});
                 $fieldset->appendChild($div);
             }
         }
         $column->appendChild($fieldset);
         $layout->appendTo($this->Form);
     }
     $div = $this->createElement('div');
     $div->setAttribute('class', 'actions');
     $div->appendChild(Widget::Submit('action[save]', $existing ? __('Save Changes') : __('Create Entry'), array('accesskey' => 's')));
//.........这里部分代码省略.........
开发者ID:brendo,项目名称:symphony-3,代码行数:101,代码来源:content.publish.php

示例6: login

 protected function login(MessageStack $errors, Register $parameter_output, array $data)
 {
     $section = Section::loadFromHandle($this->parameters()->{'section'});
     $wheres = array();
     $joins = null;
     // Find fields:
     foreach ($section->fields as $field) {
         if ($field instanceof FieldMemberName) {
             $field_name = $field;
             $handle_name = $field->{'element-name'};
         } else {
             if ($field instanceof FieldMemberEmail) {
                 $field_email = $field;
                 $handle_email = $field->{'element-name'};
             } else {
                 if ($field instanceof FieldMemberPassword) {
                     $field_password = $field;
                     $handle_password = $field->{'element-name'};
                 }
             }
         }
     }
     if (!isset($field_email) or !isset($field_password)) {
         throw new Exception(__('Section does not contain required fields.'));
     }
     // Simulate data from cookie:
     if (empty($data) and $this->readSession()) {
         $session = $this->readSession();
         $fields = array($field_email->{'element-name'} => $session->email, $field_password->{'element-name'} => $session->login);
     } else {
         $this->deleteSession();
         $fields = $data['fields'];
     }
     // Apply default values:
     foreach ($this->parameters()->{'defaults'} as $name => $value) {
         if (!isset($fields[$name])) {
             $fields[$name] = $value;
         } else {
             if (is_string($fields[$name]) and $fields[$name] == '') {
                 $fields[$name] = $value;
             } else {
                 if (is_array($fields[$name]) and empty($fields[$name])) {
                     $fields[$name] = array($value);
                 }
             }
         }
     }
     // Apply override values:
     foreach ($this->parameters()->{'overrides'} as $name => $value) {
         if (is_array($fields[$name])) {
             $fields[$name] = array($value);
         } else {
             $fields[$name] = $value;
         }
     }
     // Find values:
     if (isset($field_name)) {
         $value_name = (isset($fields[$handle_name]) and strlen($fields[$handle_name]) > 0) ? $fields[$handle_name] : null;
     }
     if (isset($field_email)) {
         $value_email = (isset($fields[$handle_email]) and strlen($fields[$handle_email]) > 0) ? $fields[$handle_email] : null;
     }
     if (isset($field_password)) {
         $value_password = (isset($fields[$handle_password]) and strlen($fields[$handle_password]) > 0) ? $fields[$handle_password] : null;
     }
     if (is_null($value_email) and is_null($value_name) or is_null($value_password)) {
         throw new Exception(__('Missing login credentials.'));
     }
     // Build query:
     $where_password = array();
     $value_password = array('value' => $value_password, 'type' => 'is');
     $field_password->buildFilterQuery($value_password, $joins, $where_password, $parameter_output);
     if (isset($field_email) and !is_null($value_email)) {
         $where_email = $where_password;
         $value_email = array('value' => $value_email, 'type' => 'is');
         $field_email->buildFilterQuery($value_email, $joins, $where_email, $parameter_output);
         $wheres[] = '(' . implode("\nAND ", $where_email) . ')';
     }
     if (isset($field_name) and !is_null($value_name)) {
         $where_name = $where_password;
         $value_name = array('value' => $value_name, 'type' => 'is');
         $field_name->buildFilterQuery($value_name, $joins, $where_name, $parameter_output);
         $wheres[] = '(' . implode("\nAND ", $where_name) . ')';
     }
     array_unshift($wheres, null);
     $wheres = implode("\nOR ", $wheres);
     $query = "\nSELECT DISTINCT\n\te.*\nFROM\n\t`tbl_entries` AS e{$joins}\nWHERE\n\tFALSE{$wheres}\n\t\t\t";
     //echo '<pre>', htmlentities($query), '</pre>'; exit;
     // Find entry:
     $result = Symphony::Database()->query($query, array(), 'EntryResult');
     if (!$result->valid()) {
         throw new Exception(__('Invalid login credentials.'));
     }
     $entry = $result->current();
     $email = $entry->data()->{$handle_email}->value;
     $code = $entry->data()->{$handle_password}->code;
     $login = $this->driver->createToken($code, 'login');
     if ($this->parameters()->{'create-cookie'} == true) {
         $this->writeCookie($login, $email);
     }
//.........这里部分代码省略.........
开发者ID:symphonycms,项目名称:symphony-3,代码行数:101,代码来源:class.login-event.php

示例7: __loadExistingSection

 private static function __loadExistingSection($handle)
 {
     try {
         return Section::loadFromHandle($handle);
     } catch (SectionException $e) {
         switch ($e->getCode()) {
             case Section::ERROR_SECTION_NOT_FOUND:
                 throw new SymphonyErrorPage(__('The section you requested to edit does not exist.'), __('Section not found'), NULL, array('HTTP/1.0 404 Not Found'));
                 break;
             default:
             case Section::ERROR_FAILED_TO_LOAD:
                 throw new SymphonyErrorPage(__('The section you requested could not be loaded. Please check it is readable.'), __('Failed to load section'));
                 break;
         }
     } catch (Exception $e) {
         throw new SymphonyErrorPage(sprintf(__("An unknown error has occurred. %s"), $e->getMessage()), __('Unknown Error'), NULL, array('HTTP/1.0 500 Internal Server Error'));
     }
 }
开发者ID:brendo,项目名称:symphony-3,代码行数:18,代码来源:content.blueprintssections.php

示例8: processData

 public function processData($data, Entry $entry = null)
 {
     $result = array();
     if (!is_array($data)) {
         return $result;
     }
     foreach ($data as $key => $fields) {
         if (is_numeric($key)) {
             $joined = Entry::loadFromId($key);
             $section = Section::loadFromHandle($joined->section);
         } else {
             $section = Section::loadFromHandle($key);
             $result[$key] = array();
         }
         foreach ($fields as $field_handle => $value) {
             $field = $section->fetchFieldByHandle($field_handle);
             $result[$key][$field_handle] = $field->processData($value, $entry);
         }
         break;
     }
     return $result;
 }
开发者ID:symphonycms,项目名称:symphony-3,代码行数:22,代码来源:field.join.php

示例9: display

 public function display($page)
 {
     // Default headers. Can be overwritten later
     //self::$Headers->append('HTTP/1.0 200 OK');
     self::$Headers->append('Content-Type', 'text/html;charset=utf-8');
     self::$Headers->append('Expires', 'Mon, 12 Dec 1982 06:14:00 GMT');
     self::$Headers->append('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT');
     self::$Headers->append('Cache-Control', 'no-cache, must-revalidate, max-age=0');
     self::$Headers->append('Pragma', 'no-cache');
     $this->isLoggedIn();
     if (empty($page)) {
         if (!$this->isLoggedIn()) {
             $page = '/login';
         } else {
             $section_handle = $this->User->default_section;
             // Make sure section exists:
             try {
                 $section = Section::loadFromHandle($section_handle);
                 redirect(ADMIN_URL . "/publish/{$section_handle}/");
             } catch (Exception $e) {
                 redirect(ADMIN_URL . '/blueprints/sections/');
             }
         }
     }
     if (!($this->_callback = $this->getPageCallback($page))) {
         throw new AdministrationPageNotFoundException($page);
     }
     include_once (isset($this->_callback['driverlocation']) ? $this->_callback['driverlocation'] : CONTENT) . '/content.' . $this->_callback['driver'] . '.php';
     $this->Page = new $this->_callback['classname']();
     // Widget class needs a document in order to create elements
     Widget::init($this->Page);
     ####
     # Delegate: AdminPagePreBuild
     # Description: Immediately before building the admin page. Provided with the page and callback
     # Global: Yes
     Extension::notify('AdminPagePreBuild', '/administration/', array('page' => &$this->Page, 'callback' => &$this->_callback));
     if (!$this->isLoggedIn() && $this->_callback['driver'] != 'login') {
         if (is_callable(array($this->Page, 'handleFailedAuthorisation'))) {
             $this->Page->handleFailedAuthorisation();
         } else {
             include_once CONTENT . '/content.login.php';
             $this->Page = new contentLogin();
             $this->Page->build();
         }
     } else {
         $this->Page->build($this->_callback['context']);
     }
     ####
     # Delegate: AdminPagePreGenerate
     # Description: Immediately before generating the admin page. Provided with the page object
     # Global: Yes
     Extension::notify('AdminPagePreGenerate', '/administration/', array('page' => &$this->Page));
     $output = (string) $this->Page;
     ####
     # Delegate: AdminPagePostGenerate
     # Description: Immediately after generating the admin page. Provided with string containing page source
     # Global: Yes
     Extension::notify('AdminPagePostGenerate', '/administration/', array('output' => &$output));
     self::Headers()->render();
     return $output;
 }
开发者ID:brendo,项目名称:symphony-3,代码行数:61,代码来源:class.administration.php

示例10: prepareTableValue

 public function prepareTableValue($data, DOMElement $link = NULL)
 {
     if (!is_array($data) || empty($data)) {
         return parent::prepareTableValue(NULL, $link);
     }
     $result = Administration::instance()->Page->createDocumentFragment();
     foreach ($data as $index => $d) {
         try {
             $entry = Entry::loadFromID($d->relation_id);
             foreach ($this->{'related-fields'} as $key => $value) {
                 list($section_handle, $field_handle) = $value;
                 if ($section_handle != $entry->meta()->section) {
                     continue;
                 }
                 $section = Section::loadFromHandle($section_handle);
                 $field = $section->fetchFieldByHandle($field_handle);
                 $value = $field->prepareTableValue($entry->data()->{$field_handle});
                 // TODO: handle passing links
                 if ($index > 0) {
                     $result->appendChild(new DOMText(', '));
                 }
                 $result->appendChild(Widget::anchor($value, sprintf('%s/publish/%s/edit/%d/', ADMIN_URL, $section_handle, $entry->meta()->id)));
                 break;
             }
         } catch (Exception $e) {
         }
     }
     if (!$result->hasChildNodes()) {
         return parent::prepareTableValue(NULL, $link);
     }
     return $result;
 }
开发者ID:brendo,项目名称:symphony-3,代码行数:32,代码来源:field.link.php

示例11: render

    public function render(Register $ParameterOutput, $joins = NULL, array $where = array(), $filter_operation_type = self::FILTER_AND)
    {
        $execute = true;
        $result = new XMLDocument();
        $result->appendChild($result->createElement($this->parameters()->{'root-element'}));
        $root = $result->documentElement;
        //	Conditions
        //	If any one condtion returns true (that is, do not execute), the DS will not execute at all
        if (is_array($this->parameters()->conditions)) {
            foreach ($this->parameters()->conditions as $condition) {
                if (preg_match('/:/', $condition['parameter'])) {
                    $c = Datasource::replaceParametersInString($condition['parameter'], $ParameterOutput);
                } else {
                    $c = Datasource::resolveParameter($condition['parameter'], $ParameterOutput);
                }
                // Is Empty
                if ($condition['logic'] == 'empty' && (is_null($c) || strlen($c) == 0)) {
                    $execute = false;
                } elseif ($condition['logic'] == 'set' && !is_null($c)) {
                    $execute = false;
                }
                if ($execute !== true) {
                    return NULL;
                }
            }
        }
        // Grab the section
        try {
            $section = Section::loadFromHandle($this->parameters()->section);
        } catch (SectionException $e) {
        } catch (Exception $e) {
        }
        $pagination = (object) array('total-entries' => NULL, 'entries-per-page' => max(1, (int) self::replaceParametersInString($this->parameters()->limit, $ParameterOutput)), 'total-pages' => NULL, 'current-page' => max(1, (int) self::replaceParametersInString($this->parameters()->page, $ParameterOutput)));
        $pagination->{'record-start'} = max(0, ($pagination->{'current-page'} - 1) * $pagination->{'entries-per-page'});
        $order = $sort = NULL;
        //	Apply the Sorting & Direction
        if ($this->parameters()->{'sort-order'} == 'random') {
            $order = 'RAND()';
        } else {
            $sort = strtolower($this->parameters()->{'sort-order'}) == 'asc' ? 'ASC' : 'DESC';
            // System Field
            if (preg_match('/^system:/i', $this->parameters()->{'sort-field'})) {
                switch (preg_replace('/^system:/i', NULL, $this->parameters()->{'sort-field'})) {
                    case 'id':
                        $order = "e.id {$sort}";
                        break;
                    case 'creation-date':
                        $order = "e.creation_date {$sort}";
                        break;
                    case 'modification-date':
                        $order = "e.modification_date {$sort}";
                        break;
                }
            } else {
                $join = NULL;
                $sort_field = $section->fetchFieldByHandle($this->parameters()->{'sort-field'});
                if ($sort_field instanceof Field && $sort_field->isSortable() && method_exists($sort_field, "buildSortingQuery")) {
                    $sort_field->buildSortingQuery($join, $order);
                    $joins .= sprintf($join, $sort_field->section, $sort_field->{'element-name'});
                    $order = sprintf($order, $sort);
                }
            }
        }
        //	Process Datasource Filters for each of the Fields
        if (is_array($this->parameters()->filters) && !empty($this->parameters()->filters)) {
            foreach ($this->parameters()->filters as $k => $filter) {
                if ($filter['element-name'] == 'system:id') {
                    $filter_value = $this->prepareFilterValue($filter['value'], $ParameterOutput);
                    if (!is_array($filter_value)) {
                        continue;
                    }
                    $filter_value = array_map('intval', $filter_value);
                    if (empty($filter_value)) {
                        continue;
                    }
                    $where[] = sprintf("(e.id %s IN (%s))", $filter['type'] == 'is-not' ? 'NOT' : NULL, implode(',', $filter_value));
                } else {
                    $field = $section->fetchFieldByHandle($filter['element-name']);
                    if ($field instanceof Field) {
                        $field->buildFilterQuery($filter, $joins, $where, $ParameterOutput);
                    }
                }
            }
        }
        // Escape percent symbold:
        $where = array_map(create_function('$string', 'return str_replace(\'%\', \'%%\', $string);'), $where);
        $query = sprintf('SELECT DISTINCT SQL_CALC_FOUND_ROWS e.*
				FROM `tbl_entries` AS `e`
				%1$s
				WHERE `section` = "%2$s"
				%3$s
				ORDER BY %4$s
				LIMIT %5$d, %6$d', $joins, $section->handle, is_array($where) && !empty($where) ? 'AND (' . implode($filter_operation_type == self::FILTER_AND ? ' AND ' : ' OR ', $where) . ')' : NULL, $order, $pagination->{'record-start'}, $pagination->{'entries-per-page'});
        try {
            $entries = Symphony::Database()->query($query, array($section->handle, $section->{'publish-order-handle'}), 'EntryResult');
            if (isset($this->parameters()->{'append-pagination'}) && $this->parameters()->{'append-pagination'} === true) {
                $pagination->{'total-entries'} = (int) Symphony::Database()->query("SELECT FOUND_ROWS() AS `total`")->current()->total;
                $pagination->{'total-pages'} = (int) ceil($pagination->{'total-entries'} * (1 / $pagination->{'entries-per-page'}));
                // Pagination Element
                $root->appendChild(General::buildPaginationElement($result, $pagination->{'total-entries'}, $pagination->{'total-pages'}, $pagination->{'entries-per-page'}, $pagination->{'current-page'}));
//.........这里部分代码省略.........
开发者ID:brendo,项目名称:symphony-3,代码行数:101,代码来源:class.datasource.php

示例12: findDefaultFieldData

 public function findDefaultFieldData()
 {
     $section = Section::loadFromHandle($this->section);
     foreach ($section->fields as $field) {
         $element = $field->{'element-name'};
         if (isset($this->data()->{$element})) {
             continue;
         }
         $this->data()->{$element} = $field->processData(NULL, $this);
     }
 }
开发者ID:pointybeard,项目名称:symphony-3,代码行数:11,代码来源:class.entry.php

示例13: __actionDelete

 public function __actionDelete(array $sections, $redirect)
 {
     $success = true;
     $callback = Administration::instance()->getPageCallback();
     $current_page = $callback['pageroot'] . (isset($callback['context'][0]) && $callback['context'][0] != 'index' ? $callback['context'][0] . '/' : NULL);
     foreach ($sections as $handle) {
         try {
             Section::delete(Section::loadFromHandle($handle));
             ###
             # Delegate: SectionPostDelete
             Extension::notify('SectionPostDelete', $current_page, array('handle' => $handle));
         } catch (SectionException $e) {
             $success = false;
             $this->alerts()->append($e->getMessage(), AlertStack::ERROR, $e);
         } catch (Exception $e) {
             $success = false;
             $this->alerts()->append(__('An unknown error has occurred. <a class="more">Show trace information.</a>'), AlertStack::ERROR, $e);
         }
     }
     if ($success) {
         redirect($redirect);
     }
 }
开发者ID:plasticine,项目名称:symphony-3,代码行数:23,代码来源:content.blueprintssections.php

示例14: current

 public function current()
 {
     $record = parent::current();
     $entry = new Entry();
     foreach ($record as $key => $value) {
         $entry->{$key} = $value;
     }
     if (empty($this->data)) {
         return $entry;
     }
     // 	Load the section
     try {
         $section = Section::loadFromHandle($entry->section);
     } catch (SectionException $e) {
         throw new EntryException('Section specified, "' . $entry->section . '", in Entry object is invalid.');
     } catch (Exception $e) {
         throw new EntryException('The following error occurred: ' . $e->getMessage());
     }
     //	Loop over the section fields, and in they are in the desired schema, populate an entry_data
     //	array with the information. This doesn't respect fields allow_multiple setting though, although
     //	I don't even think that's a problem to be honest as that validation should be taking place at the
     //	entry creation level, not when it's being read.
     foreach ($section->fields as $field) {
         if (!empty($this->schema) && !in_array($field->{'element-name'}, $this->schema)) {
             continue;
         }
         $entry_data = array();
         foreach ($this->data[$field->{'element-name'}] as $key => $data) {
             if ($data->{$field->fetchDataKey()} != $entry->id) {
                 continue;
             }
             $entry_data[] = $data;
         }
         $entry->data()->{$field->{'element-name'}} = count($entry_data) == 1 ? current($entry_data) : $entry_data;
     }
     return $entry;
 }
开发者ID:symphonycms,项目名称:symphony-3,代码行数:37,代码来源:class.datasource.php

示例15: render

 public function render(Register $ParameterOutput)
 {
     $result = new XMLDocument();
     $root = $result->createElement($this->parameters()->{'root-element'});
     try {
         ##	User Filtering
         if (is_array($this->parameters()->filters) && !empty($this->parameters()->filters)) {
             $user_ids = NULL;
             $where_clauses = array();
             $query = "SELECT * FROM `tbl_users` WHERE 1 %s ORDER BY `id` ASC";
             foreach ($this->parameters()->filters as $field => $value) {
                 if (!is_array($value) && trim($value) == '') {
                     continue;
                 }
                 $value = self::replaceParametersInString($value, $ParameterOutput);
                 if (!is_array($value)) {
                     $value = preg_split('/,\\s*/', $value, -1, PREG_SPLIT_NO_EMPTY);
                     $value = array_map('trim', $value);
                 }
                 $where_clauses[] = sprintf("`%s` IN ('%s')", str_replace('-', '_', $field), implode(',', $value));
             }
             // Should the $where_clauses array be empty, it means there were no valid filters. I.E. they were all empty strings.
             // If that is the case, we still want Users to get returned, hence the "WHERE 1" part of the SQL to avoid errors.
             if (!empty($where_clauses)) {
                 $where_clauses = 'AND' . implode(' AND ', $where_clauses);
             } else {
                 $where_clauses = NULL;
             }
             $users = Symphony::Database()->query(sprintf($query, $where_clauses), array(), 'UserResult');
         } else {
             $users = new UserIterator();
         }
         if ($users->length() > 0) {
             $included_fields = $this->parameters()->{'included-elements'};
             foreach ($users as $user) {
                 $xUser = $result->createElement('user', null);
                 $xUser->setAttribute('id', $user->id);
                 foreach ($included_fields as $element) {
                     switch ($element) {
                         case 'name':
                             $xUser->appendChild($result->createElement('name', $user->getFullName()));
                             break;
                         case 'email-address':
                             $xUser->appendChild($result->createElement('email-address', $user->email));
                             break;
                         case 'username':
                             $xUser->appendChild($result->createElement('username', $user->username));
                             break;
                         case 'language':
                             if (!is_null($user->language)) {
                                 $xUser->appendChild($result->createElement('language', $user->language));
                             }
                             break;
                         case 'authentication-token':
                             if ($user->isTokenActive()) {
                                 $xUser->appendChild($result->createElement('authentication-token', $user->createAuthToken()));
                             }
                             break;
                         case 'default-section':
                             try {
                                 $section = Section::loadFromHandle($user->default_section);
                                 $default_section = $result->createElement('default-section', $section->name);
                                 $default_section->setAttribute('handle', $section->handle);
                                 $xUser->appendChild($default_section);
                             } catch (SectionException $error) {
                                 // Do nothing, section doesn't exist, but no need to error out about it..
                             }
                             break;
                         default:
                             break;
                     }
                 }
                 $root->appendChild($xUser);
             }
         } else {
             throw new DataSourceException("No records found.");
         }
     } catch (Exception $error) {
         $root->appendChild($result->createElement('error', General::sanitize($error->getMessage())));
     }
     $result->appendChild($root);
     return $result;
 }
开发者ID:brendo,项目名称:symphony-3,代码行数:83,代码来源:class.datasource.php


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