本文整理汇总了PHP中SectionManager::fetchParentAssociations方法的典型用法代码示例。如果您正苦于以下问题:PHP SectionManager::fetchParentAssociations方法的具体用法?PHP SectionManager::fetchParentAssociations怎么用?PHP SectionManager::fetchParentAssociations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SectionManager
的用法示例。
在下文中一共展示了SectionManager::fetchParentAssociations方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
public function build(array $context = array())
{
$section_id = $context[1];
if (isset($section_id)) {
$context['associations'] = array('parent' => SectionManager::fetchParentAssociations($section_id), 'child' => SectionManager::fetchChildAssociations($section_id));
}
return parent::build($context);
}
示例2: buildEditor
/**
* Build interface to select association output to Data Source editor.
*
* @param mixed $context
* Delegate context including page object
*/
public function buildEditor($context)
{
$callback = Symphony::Engine()->getPageCallback();
if ($callback['driver'] == 'blueprintsdatasources' && !empty($callback['context'])) {
Administration::instance()->Page->addScriptToHead(URL . '/extensions/association_output/assets/associationoutput.datasources.js');
// Get existing associations
if ($callback['context'][0] === 'edit') {
$name = $callback['context'][1];
$datasource = DatasourceManager::create($name);
$settings = $datasource->dsParamINCLUDEDASSOCIATIONS;
$settings['section_id'] = $datasource->getSource();
}
// Build interface
$wrapper = $context['oPage']->Contents->getChildByName('form', 0);
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings association-output');
$fieldset->setAttribute('data-context', 'sections');
$fieldset->appendChild(new XMLElement('legend', __('Associated Content')));
// Build options
$options = array();
$sections = SectionManager::fetch();
foreach ($sections as $section) {
$section_id = $section->get('id');
$section_handle = $section->get('handle');
$associations = SectionManager::fetchParentAssociations($section_id);
if (!empty($associations)) {
foreach ($associations as $association) {
$options[] = $this->buildElementOptions($association, $settings, $section_id);
}
}
}
// Append field selection
$label = Widget::Label(__('Included Associations'));
$select = Widget::Select('fields[includedassociations][]', $options, array('multiple' => 'multiple'));
$label->appendChild($select);
$fieldset->appendChild($label);
$wrapper->appendChild($fieldset);
}
}
示例3: fetchParentAssociations
/**
* Returns any section associations this section has with other sections
* linked using fields, and where this section is the child in the association.
* Has an optional parameter, `$respect_visibility` that
* will only return associations that are deemed visible by a field that
* created the association. eg. An articles section may link to the authors
* section, but the field that links these sections has hidden this association
* so an Articles column will not appear on the Author's Publish Index
*
* @since Symphony 2.3.3
* @param boolean $respect_visibility
* Whether to return all the section associations regardless of if they
* are deemed visible or not. Defaults to false, which will return all
* associations.
* @return array
*/
public function fetchParentAssociations($respect_visibility = false)
{
return SectionManager::fetchParentAssociations($this->get('id'), $respect_visibility);
}
示例4: prepareAssociationsDrawer
/**
* Prepare a Drawer to visualize section associations
*
* @param Section $section The current Section object
* @throws InvalidArgumentException
* @throws Exception
*/
private function prepareAssociationsDrawer($section)
{
$entry_id = !is_null($this->_context['entry_id']) ? $this->_context['entry_id'] : null;
$show_entries = Symphony::Configuration()->get('association_maximum_rows', 'symphony');
if (is_null($entry_id) && !isset($_GET['prepopulate']) || is_null($show_entries) || $show_entries == 0) {
return;
}
$parent_associations = SectionManager::fetchParentAssociations($section->get('id'), true);
$child_associations = SectionManager::fetchChildAssociations($section->get('id'), true);
$content = null;
$drawer_position = 'vertical-right';
/**
* Prepare Associations Drawer from an Extension
*
* @since Symphony 2.3.3
* @delegate PrepareAssociationsDrawer
* @param string $context
* '/publish/'
* @param integer $entry_id
* The entry ID or null
* @param array $parent_associations
* Array of Sections
* @param array $child_associations
* Array of Sections
* @param string $drawer_position
* The position of the Drawer, defaults to `vertical-right`. Available
* values of `vertical-left, `vertical-right` and `horizontal`
*/
Symphony::ExtensionManager()->notifyMembers('PrepareAssociationsDrawer', '/publish/', array('entry_id' => $entry_id, 'parent_associations' => &$parent_associations, 'child_associations' => &$child_associations, 'content' => &$content, 'drawer-position' => &$drawer_position));
// If there are no associations, return now.
if ((is_null($parent_associations) || empty($parent_associations)) && (is_null($child_associations) || empty($child_associations))) {
return;
}
if (!$content instanceof XMLElement) {
$content = new XMLElement('div', null, array('class' => 'content'));
$content->setSelfClosingTag(false);
// Process Parent Associations
if (!is_null($parent_associations) && !empty($parent_associations)) {
foreach ($parent_associations as $as) {
if ($field = FieldManager::fetch($as['parent_section_field_id'])) {
if (isset($_GET['prepopulate'])) {
$prepopulate_field = key($_GET['prepopulate']);
}
// get associated entries if entry exists,
if ($entry_id) {
$entry_ids = $field->findParentRelatedEntries($as['child_section_field_id'], $entry_id);
// get prepopulated entry otherwise
} elseif (isset($_GET['prepopulate'])) {
$entry_ids = array(intval(current($_GET['prepopulate'])));
} else {
$entry_ids = array();
}
// Use $schema for perf reasons
$schema = array($field->get('element_name'));
$where = !empty($entry_ids) ? sprintf(' AND `e`.`id` IN (%s)', implode(', ', $entry_ids)) : null;
$entries = !empty($entry_ids) || isset($_GET['prepopulate']) && $field->get('id') === $prepopulate_field ? EntryManager::fetchByPage(1, $as['parent_section_id'], $show_entries, $where, null, false, false, true, $schema) : array();
$has_entries = !empty($entries) && $entries['total-entries'] != 0;
if ($has_entries) {
$element = new XMLElement('section', null, array('class' => 'association parent'));
$header = new XMLElement('header');
$header->appendChild(new XMLElement('p', __('Linked to %s in', array('<a class="association-section" href="' . SYMPHONY_URL . '/publish/' . $as['handle'] . '/">' . $as['name'] . '</a>'))));
$element->appendChild($header);
$ul = new XMLElement('ul', null, array('class' => 'association-links', 'data-section-id' => $as['child_section_id'], 'data-association-ids' => implode(', ', $entry_ids)));
foreach ($entries['records'] as $e) {
// let the field create the mark up
$li = $field->prepareAssociationsDrawerXMLElement($e, $as);
// add it to the unordered list
$ul->appendChild($li);
}
$element->appendChild($ul);
$content->appendChild($element);
}
}
}
}
// Process Child Associations
if (!is_null($child_associations) && !empty($child_associations)) {
foreach ($child_associations as $as) {
// Get the related section
$child_section = SectionManager::fetch($as['child_section_id']);
if (!$child_section instanceof Section) {
continue;
}
// Get the visible field instance (using the sorting field, this is more flexible than visibleColumns())
// Get the link field instance
$visible_field = current($child_section->fetchVisibleColumns());
$relation_field = FieldManager::fetch($as['child_section_field_id']);
// Get entries, using $schema for performance reasons.
$entry_ids = $relation_field->findRelatedEntries($entry_id, $as['parent_section_field_id']);
$schema = $visible_field ? array($visible_field->get('element_name')) : array();
$where = sprintf(' AND `e`.`id` IN (%s)', implode(', ', $entry_ids));
$entries = !empty($entry_ids) ? EntryManager::fetchByPage(1, $as['child_section_id'], $show_entries, $where, null, false, false, true, $schema) : array();
$has_entries = !empty($entries) && $entries['total-entries'] != 0;
//.........这里部分代码省略.........