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


PHP SectionManager::fetchChildAssociations方法代码示例

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


在下文中一共展示了SectionManager::fetchChildAssociations方法的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);
 }
开发者ID:rc1,项目名称:WebAppsWithCmsStartHere,代码行数:8,代码来源:content.blueprintssections.php

示例2: fetchChildAssociations

 /**
  * Returns any section associations this section has with other sections
  * linked using fields, and where this section is the parent 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 fetchChildAssociations($respect_visibility = false)
 {
     return SectionManager::fetchChildAssociations($this->get('id'), $respect_visibility);
 }
开发者ID:davjand,项目名称:codecept-symphonycms-db,代码行数:20,代码来源:class.section.php

示例3: 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;
//.........这里部分代码省略.........
开发者ID:rc1,项目名称:WebAppsWithCmsStartHere,代码行数:101,代码来源:content.publish.php

示例4: view

 /**
  *
  * Builds the content view
  */
 public function view()
 {
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         $this->_Result['status'] = Page::HTTP_STATUS_BAD_REQUEST;
         $this->_Result['error'] = __('This page accepts posts only');
         $this->setHttpStatus($this->_Result['status']);
         return;
     }
     // _context[0] => entry id to delete
     // _context[1] => fieldId
     // _context[2] => current entry id (parent of entry id to delete)
     if (!is_array($this->_context) || empty($this->_context)) {
         $this->_Result['error'] = __('Parameters not found');
         return;
     } else {
         if (count($this->_context) < self::NUMBER_OF_URL_PARAMETERS) {
             $this->_Result['error'] = __('Not enough parameters');
             return;
         } else {
             if (count($this->_context) > self::NUMBER_OF_URL_PARAMETERS) {
                 $this->_Result['error'] = __('Too many parameters');
                 return;
             }
         }
     }
     // Validate to delete entry ID
     $rawToDeleteEntryId = MySQL::cleanValue($this->_context[0]);
     $toDeleteEntryId = General::intval($rawToDeleteEntryId);
     if ($toDeleteEntryId < 1) {
         $this->_Result['error'] = __('No entry no found');
         return;
     }
     // Validate parent field exists
     $parentFieldId = General::intval(MySQL::cleanValue($this->_context[1]));
     if ($parentFieldId < 1) {
         $this->_Result['error'] = __('Parent id not valid');
         return;
     }
     $parentField = FieldManager::fetch($parentFieldId);
     if (!$parentField || empty($parentField)) {
         $this->_Result['error'] = __('Parent field not found');
         return;
     }
     // Validate parent entry ID
     $rawEntryId = MySQL::cleanValue($this->_context[2]);
     $entryId = General::intval($rawEntryId);
     if ($entryId < 1) {
         $this->_Result['error'] = sprintf(__('Parent entry id `%s` not valid'), $rawEntryId);
         return;
     }
     // Validate parent entry exists
     $entry = EntryManager::fetch($entryId);
     if ($entry == null || count($entry) != 1) {
         $this->_Result['error'] = __('Parent entry not found');
         return;
     }
     if (is_array($entry)) {
         $entry = $entry[0];
     }
     if ($entry->get('section_id') != $parentField->get('parent_section')) {
         $this->_Result['error'] = __('Field and entry do not belong together');
         return;
     }
     // Validate to delete entry exists
     $toDeleteEntry = EntryManager::fetch($toDeleteEntryId);
     if ($toDeleteEntry == null || count($toDeleteEntry) != 1) {
         $this->_Result['error'] = __('Entry not found');
         return;
     }
     if (is_array($toDeleteEntry)) {
         $toDeleteEntry = $toDeleteEntry[0];
     }
     // Validate entry is not linked anywhere else
     if (!isset($_REQUEST['no-assoc'])) {
         //$toDeleteSection = SectionManager::fetch($toDeleteEntry->get('section_id'));
         //$toDeleteAssoc = $toDeleteSection->fetchChildAssociations(false);
         $toDeleteAssoc = SectionManager::fetchChildAssociations($toDeleteEntry->get('section_id'), false);
         //var_dump($toDeleteAssoc);die;
         // TODO: find if the toDeleteEntry is linked or not.
         if (count($toDeleteAssoc) > 1) {
             $this->_Result['assoc'] = true;
             $this->_Result['error'] = __('Entry might be link elsewhere. Do you want to continue?');
             return;
         }
     }
     // Delete the entry
     if (!EntryManager::delete($toDeleteEntryId)) {
         $this->_Result['error'] = __('Could not delete the entry');
         return;
     }
     $this->_Result['entry-id'] = $entryId;
     $this->_Result['ok'] = true;
 }
开发者ID:hotdoy,项目名称:EDclock,代码行数:97,代码来源:content.delete.php


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