本文整理汇总了PHP中FieldManager::fetchHandleFromID方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldManager::fetchHandleFromID方法的具体用法?PHP FieldManager::fetchHandleFromID怎么用?PHP FieldManager::fetchHandleFromID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FieldManager
的用法示例。
在下文中一共展示了FieldManager::fetchHandleFromID方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildElementOptions
/**
* Build element options.
*
* @param array $association
* Association data
* @param array $settings
* Data Source settings
* @param number $section_id
* Section ID
* @return array
* Element options
*/
private function buildElementOptions($association, $settings, $section_id)
{
$elements = array();
$label = FieldManager::fetchHandleFromID($association['child_section_field_id']);
$fields = FieldManager::fetch(null, $association['parent_section_id']);
if (is_array($fields) || $fields instanceof Traversable) {
foreach ($fields as $field) {
$modes = $field->fetchIncludableElements();
foreach ($modes as $mode) {
$value = $association['parent_section_id'] . '|#|' . $association['parent_section_field_id'] . '|#|' . $label . '|#|' . $mode;
$selected = false;
if ($section_id == $settings['section_id'] && isset($settings[$label])) {
if (in_array($mode, $settings[$label]['elements'])) {
$selected = true;
}
}
$elements[] = array($value, $selected, $mode);
}
}
}
return array('label' => $label, 'data-label' => $section_id, 'options' => $elements);
}
示例2: execute
public function execute(array &$param_pool)
{
$result = new XMLElement($this->dsParamROOTELEMENT);
$this->_param_pool = $param_pool;
$where = NULL;
$joins = NULL;
$group = false;
include_once TOOLKIT . '/class.entrymanager.php';
if (!($section = SectionManager::fetch((int) $this->getSource()))) {
$about = $this->about();
trigger_error(__('The section associated with the data source %s could not be found.', array('<code>' . $about['name'] . '</code>')), E_USER_ERROR);
}
$sectioninfo = new XMLElement('section', General::sanitize($section->get('name')), array('id' => $section->get('id'), 'handle' => $section->get('handle')));
if ($this->_force_empty_result == true) {
$this->_force_empty_result = false;
//this is so the section info element doesn't disappear.
$result = $this->emptyXMLSet();
$result->prependChild($sectioninfo);
return;
}
if (is_array($this->dsParamINCLUDEDELEMENTS)) {
$include_pagination_element = in_array('system:pagination', $this->dsParamINCLUDEDELEMENTS);
} else {
$this->dsParamINCLUDEDELEMENTS = array();
}
if (isset($this->dsParamPARAMOUTPUT) && !is_array($this->dsParamPARAMOUTPUT)) {
$this->dsParamPARAMOUTPUT = array($this->dsParamPARAMOUTPUT);
}
$this->_can_process_system_parameters = $this->canProcessSystemParameters();
if (!isset($this->dsParamPAGINATERESULTS)) {
$this->dsParamPAGINATERESULTS = 'yes';
}
// Process Filters
$this->processFilters($where, $joins, $group);
// Process Sorting
if ($this->dsParamSORT == 'system:id') {
EntryManager::setFetchSorting('id', $this->dsParamORDER);
} else {
if ($this->dsParamSORT == 'system:date') {
EntryManager::setFetchSorting('date', $this->dsParamORDER);
} else {
EntryManager::setFetchSorting(FieldManager::fetchFieldIDFromElementName($this->dsParamSORT, $this->getSource()), $this->dsParamORDER);
}
}
// combine `INCLUDEDELEMENTS`, `PARAMOUTPUT` and `GROUP` into an
// array of field handles to optimise the `EntryManager` queries
$datasource_schema = $this->dsParamINCLUDEDELEMENTS;
if (is_array($this->dsParamPARAMOUTPUT)) {
$datasource_schema = array_merge($datasource_schema, $this->dsParamPARAMOUTPUT);
}
if ($this->dsParamGROUP) {
$datasource_schema[] = FieldManager::fetchHandleFromID($this->dsParamGROUP);
}
$entries = EntryManager::fetchByPage($this->dsParamPAGINATERESULTS == 'yes' && $this->dsParamSTARTPAGE > 0 ? $this->dsParamSTARTPAGE : 1, $this->getSource(), $this->dsParamPAGINATERESULTS == 'yes' && $this->dsParamLIMIT >= 0 ? $this->dsParamLIMIT : NULL, $where, $joins, $group, !$include_pagination_element ? true : false, true, array_unique($datasource_schema));
/**
* Immediately after building entries allow modification of the Data Source entry list
*
* @delegate DataSourceEntriesBuilt
* @param string $context
* '/frontend/'
* @param Datasource $datasource
* @param array $entries
* @param array $filters
*/
Symphony::ExtensionManager()->notifyMembers('DataSourceEntriesBuilt', '/frontend/', array('datasource' => &$this, 'entries' => &$entries, 'filters' => $this->dsParamFILTERS));
if (($entries['total-entries'] <= 0 || $include_pagination_element === true) && (!is_array($entries['records']) || empty($entries['records'])) || $this->dsParamSTARTPAGE == '0') {
if ($this->dsParamREDIRECTONEMPTY == 'yes') {
throw new FrontendPageNotFoundException();
}
$this->_force_empty_result = false;
$result = $this->emptyXMLSet();
$result->prependChild($sectioninfo);
if ($include_pagination_element) {
$pagination_element = General::buildPaginationElement();
if ($pagination_element instanceof XMLElement && $result instanceof XMLElement) {
$result->prependChild($pagination_element);
}
}
} else {
if (!$this->_param_output_only) {
$result->appendChild($sectioninfo);
if ($include_pagination_element) {
$t = $this->dsParamPAGINATERESULTS == 'yes' && isset($this->dsParamLIMIT) && $this->dsParamLIMIT >= 0 ? $this->dsParamLIMIT : $entries['total-entries'];
$pagination_element = General::buildPaginationElement($entries['total-entries'], $entries['total-pages'], $t, $this->dsParamPAGINATERESULTS == 'yes' && $this->dsParamSTARTPAGE > 0 ? $this->dsParamSTARTPAGE : 1);
if ($pagination_element instanceof XMLElement && $result instanceof XMLElement) {
$result->prependChild($pagination_element);
}
}
}
// If this datasource has a Limit greater than 0 or the Limit is not set
if (!isset($this->dsParamLIMIT) || $this->dsParamLIMIT > 0) {
if (!isset($this->dsParamASSOCIATEDENTRYCOUNTS) || $this->dsParamASSOCIATEDENTRYCOUNTS == 'yes') {
$this->_associated_sections = $section->fetchAssociatedSections();
}
// If the datasource require's GROUPING
if (isset($this->dsParamGROUP)) {
self::$_fieldPool[$this->dsParamGROUP] =& FieldManager::fetch($this->dsParamGROUP);
$groups = self::$_fieldPool[$this->dsParamGROUP]->groupRecords($entries['records']);
foreach ($groups as $element => $group) {
foreach ($group as $g) {
//.........这里部分代码省略.........
示例3: __viewEdit
//.........这里部分代码省略.........
if ($new == false) {
/*
TODO add POST values to XML
*/
$group = RecipientgroupManager::create($this->_context[1]);
if (is_object($group)) {
$entry = new XMLElement('entry');
$properties = $group->getProperties();
$about = $group->about();
$title = $about['name'];
General::array_to_xml($entry, $about);
$source = new XMLElement('source', $properties['source']);
$entry->appendChild($source);
// Section Only
if (is_numeric($properties['source'])) {
$fields = new XMLElement('fields');
$email = new XMLElement('email', $properties['email']);
$fields->appendChild($email);
$name = new XMLElement('name');
General::array_to_xml($name, $properties['name']);
$fields->appendChild($name);
$entry->appendChild($fields);
}
// Hack to make sure filter data is preserved in the UI when there is an error in the form.
// For next versions: always do the local/user differentiation in php, rather than xslt.
// This will make the xslt cleaner and easier to understand and debug.
if (!empty($_POST['fields'])) {
$properties['filters'] = $_POST['fields']['filter'][0];
}
if (!empty($properties['filters'])) {
$filters = new XMLElement('filters');
foreach ($properties['filters'] as $filter => $val) {
// Section and Author
if ($filter == 'id') {
$title = new XMLElement('h4', 'System ID');
$label = Widget::Label(__('Value'));
$label->appendChild(Widget::Input('fields[filter][' . $properties['source'] . '][id]', General::sanitize($val)));
$filter_entry = new XMLElement('entry', NULL, array('id' => 'id', 'data-type' => 'id'));
$filter_entry->appendChild($title);
$filter_entry->appendChild($label);
$filters->appendChild($filter_entry);
}
if ($filter == 'system:date') {
$title = new XMLElement('h4', 'System Date');
$label = Widget::Label(__('Value'));
$label->appendChild(Widget::Input('fields[filter][' . $properties['source'] . '][system:date]', General::sanitize($val)));
$filter_entry = new XMLElement('entry', NULL, array('id' => 'id', 'data-type' => 'system:date'));
$filter_entry->appendChild($title);
$filter_entry->appendChild($label);
$filters->appendChild($filter_entry);
}
// Section Only
if (is_numeric($properties['source'])) {
$section = SectionManager::fetch($properties['source']);
if (is_object($section)) {
$section_fields = $section->fetchFields();
foreach ($section_fields as $field) {
$field_ids[] = $field->get('id');
}
// only add filters to the duplicator if the field id
// belongs to the current section
if (is_numeric($filter) && in_array($filter, $field_ids)) {
$filter_obj = FieldManager::fetch($filter);
if (is_object($filter_obj)) {
$filter_entry = new XMLElement('entry', NULL, array('id' => $filter, 'data-type' => FieldManager::fetchHandleFromID($filter)));
$filter_obj->displayDatasourceFilterPanel($filter_entry, $val, $errors, is_numeric($properties['source']) ? $properties['source'] : 1);
$filters->appendChild($filter_entry);
}
}
}
}
// Author only
if ($properties['source'] == 'authors') {
$filter_names = array('username' => 'Username', 'first_name' => 'First Name', 'last_name' => 'Last Name', 'email' => 'Email Address', 'user_type' => 'User Type');
if (in_array($filter, array_keys($filter_names))) {
$title = new XMLElement('h4', $filter_names[$filter]);
$label = Widget::Label(__('Value'));
$label->appendChild(Widget::Input('fields[filter][' . $properties['source'] . '][username]', General::sanitize($val)));
$filter_entry = new XMLElement('entry', NULL, array('id' => 'id', 'data-type' => 'username'));
$filter_entry->appendChild($title);
$filter_entry->appendChild($label);
$filters->appendChild($filter_entry);
}
}
}
$entry->appendChild($filters);
$title = $about['name'];
}
if ($properties['source'] == 'static_recipients') {
$entry->appendChild(new XMLElement('static_recipients', '<![CDATA[' . $group->recipients . ']]>'));
}
$recipientgroups->appendChild($entry);
$this->_XML->appendChild($recipientgroups);
} else {
Administration::instance()->errorPageNotFound();
}
}
$this->insertBreadcrumbs($breadcrumbs);
$this->appendSubheading($title);
}
示例4: getFilterString
/**
* If the entry is being prepopulated, we may want to filter other views by this entry's
* value. This function will create that filter query string.
*
* @since Symphony 2.5.2
* @return string
*/
public function getFilterString()
{
$filter_querystring = '';
if (isset($_REQUEST['prepopulate'])) {
foreach ($_REQUEST['prepopulate'] as $field_id => $value) {
$handle = FieldManager::fetchHandleFromID($field_id);
$filter_querystring .= sprintf("filter[%s]=%s&", $handle, rawurldecode($value));
}
$filter_querystring = trim($filter_querystring, '&');
}
// This is to prevent the value being interpreted as an additional GET
// parameter. eg. filter[cat]=Minx&June, would come through as:
// $_GET['cat'] = Minx
// $_GET['June'] = ''
$filter_querystring = preg_replace("/&\$/", '', $filter_querystring);
return $filter_querystring ? '?' . $filter_querystring : null;
}
示例5: dataSourcePreExecute
public function dataSourcePreExecute($context)
{
// clear preexisting output
$context['xml'] = null;
// check if language preconditions are met
if (self::$languages && self::$language !== self::$languages[0]) {
$filters = $context['datasource']->dsParamFILTERS;
$section = $context['datasource']->getSource();
// check if datasource has filters
if (is_array($filters)) {
// swap filters to current language fields
foreach ($filters as $field_id => $filter) {
$field_handle = FieldManager::fetchHandleFromID($field_id);
// check if field handle is multilingual
if (preg_match('/-' . self::$languages[0] . '$/', $field_handle)) {
// get current language field handle
$field2_handle = preg_replace('/-' . self::$languages[0] . '$/', '-' . self::$language, $field_handle);
// check if current language field exists
if ($field2_id = FieldManager::fetchFieldIDFromElementName($field2_handle, $section)) {
// remove default field from filters
unset($filters[$field_id]);
// add current language field to filters
$filters[$field2_id] = $filter;
}
}
}
// backup default filters
$context['datasource']->dsDefaultFILTERS = $context['datasource']->dsParamFILTERS;
// save current language filters
$context['datasource']->dsParamFILTERS = $filters;
}
}
}
示例6: __viewEdit
public function __viewEdit()
{
if (!($section_id = SectionManager::fetchIDFromHandle($this->_context['section_handle']))) {
Administration::instance()->throwCustomError(__('The Section, %s, could not be found.', array('<code>' . $this->_context['section_handle'] . '</code>')), __('Unknown Section'), Page::HTTP_STATUS_NOT_FOUND);
}
$section = SectionManager::fetch($section_id);
$entry_id = intval($this->_context['entry_id']);
$base = '/publish/' . $this->_context['section_handle'] . '/';
$new_link = $base . 'new/';
$filter_link = $base;
EntryManager::setFetchSorting('id', 'DESC');
if (!($existingEntry = EntryManager::fetch($entry_id))) {
Administration::instance()->throwCustomError(__('Unknown Entry'), __('The Entry, %s, could not be found.', array($entry_id)), Page::HTTP_STATUS_NOT_FOUND);
}
$existingEntry = $existingEntry[0];
// If there is post data floating around, due to errors, create an entry object
if (isset($_POST['fields'])) {
$fields = $_POST['fields'];
$entry = EntryManager::create();
$entry->set('id', $entry_id);
$entry->set('author_id', $existingEntry->get('author_id'));
$entry->set('section_id', $existingEntry->get('section_id'));
$entry->set('creation_date', $existingEntry->get('creation_date'));
$entry->set('modification_date', $existingEntry->get('modification_date'));
$entry->setDataFromPost($fields, $errors, true);
} else {
$entry = $existingEntry;
$fields = array();
if (!$section) {
$section = SectionManager::fetch($entry->get('section_id'));
}
}
/**
* Just prior to rendering of an Entry edit form.
*
* @delegate EntryPreRender
* @param string $context
* '/publish/edit/'
* @param Section $section
* @param Entry $entry
* @param array $fields
*/
Symphony::ExtensionManager()->notifyMembers('EntryPreRender', '/publish/edit/', array('section' => $section, 'entry' => &$entry, 'fields' => $fields));
// Iterate over the `prepopulate` parameters to build a URL
// to remember this state for Create New, View all Entries and
// Breadcrumb links. If `prepopulate` doesn't exist, this will
// just use the standard pages (ie. no filtering)
if (isset($_REQUEST['prepopulate'])) {
$new_link .= '?';
$filter_link .= '?';
foreach ($_REQUEST['prepopulate'] as $field_id => $value) {
$new_link .= "prepopulate[{$field_id}]={$value}&";
$field_name = FieldManager::fetchHandleFromID($field_id);
$filter_link .= "filter[{$field_name}]={$value}&";
}
$new_link = preg_replace("/&\$/", '', $new_link);
$filter_link = preg_replace("/&\$/", '', $filter_link);
}
if (isset($this->_context['flag'])) {
// These flags are only relevant if there are no errors
if (empty($this->_errors)) {
switch ($this->_context['flag']) {
case 'saved':
$this->pageAlert(__('Entry updated at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . $new_link . '" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . $filter_link . '" accesskey="a">' . __('View all Entries') . '</a>', Alert::SUCCESS);
break;
case 'created':
$this->pageAlert(__('Entry created at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . $new_link . '" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . $filter_link . '" accesskey="a">' . __('View all Entries') . '</a>', Alert::SUCCESS);
break;
}
}
}
// Determine the page title
$field_id = Symphony::Database()->fetchVar('id', 0, "SELECT `id` FROM `tbl_fields` WHERE `parent_section` = '" . $section->get('id') . "' ORDER BY `sortorder` LIMIT 1");
if (!is_null($field_id)) {
$field = FieldManager::fetch($field_id);
}
if ($field) {
$title = trim(strip_tags($field->prepareTableValue($existingEntry->getData($field->get('id')), NULL, $entry_id)));
} else {
$title = '';
}
if (trim($title) == '') {
$title = __('Untitled');
}
// Check if there is a field to prepopulate
if (isset($_REQUEST['prepopulate'])) {
foreach ($_REQUEST['prepopulate'] as $field_id => $value) {
$this->Form->prependChild(Widget::Input("prepopulate[{$field_id}]", rawurlencode($value), 'hidden'));
}
}
$this->setPageType('form');
$this->Form->setAttribute('enctype', 'multipart/form-data');
$this->Form->setAttribute('class', 'two columns');
$this->setTitle(__('%1$s – %2$s – %3$s', array($title, $section->get('name'), __('Symphony'))));
// Only show the Edit Section button if the Author is a developer. #938 ^BA
if (Administration::instance()->Author->isDeveloper()) {
$this->appendSubheading($title, Widget::Anchor(__('Edit Section'), SYMPHONY_URL . '/blueprints/sections/edit/' . $section_id . '/', __('Edit Section Configuration'), 'button'));
} else {
$this->appendSubheading($title);
}
//.........这里部分代码省略.........