public function __viewIndex() { $subsection = new SubsectionManager($this->_Parent); $content = $subsection->generate(null, intval($_GET['id']), intval($_GET['section']), intval($_GET['entry']) ? intval($_GET['entry']) : NULL, true); echo $content['html']; exit; }
/** * Used to fetch subsection items via an AJAX request. */ public function __viewIndex() { $subsection = new SubsectionManager(); // Set flags $flags = SubsectionManager::GETHTML; if (!isset($_GET['entry'])) { $flags |= SubsectionManager::GETALLITEMS; } // Get items $content = $subsection->generate(intval($_GET['id']), intval($_GET['section']), intval($_GET['entry']) ? intval($_GET['entry']) : NULL, 0, $flags); echo $content['html']; exit; }
/** * Displays publish panel in content area. * * @param XMLElement $wrapper * @param $data * @param $flagWithError * @param $fieldnamePrefix * @param $fieldnamePostfix */ function displayPublishPanel(&$wrapper, $data = NULL, $flagWithError = NULL, $fieldnamePrefix = NULL, $fieldnamePostfix = NULL) { $this->_engine->Page->addScriptToHead(URL . '/extensions/subsectionmanager/lib/draggable/symphony.draggable.js', 101, false); $this->_engine->Page->addScriptToHead(URL . '/extensions/subsectionmanager/lib/stage/symphony.stage.js', 101, false); $this->_engine->Page->addStylesheetToHead(URL . '/extensions/subsectionmanager/lib/stage/symphony.stage.css', 'screen', 103, false); $this->_engine->Page->addScriptToHead(URL . '/extensions/subsectionmanager/assets/symphony.subsectionmanager.js', 102, false); $this->_engine->Page->addStylesheetToHead(URL . '/extensions/subsectionmanager/assets/symphony.subsectionmanager.css', 'screen', 104, false); // Get Subsection $subsection = new SubsectionManager($this->_Parent); $content = $subsection->generate($data['relation_id'], $this->get('id'), $this->get('subsection_id'), NULL, false); // Prepare select options $options = $content['options']; if ($this->get('allow_multiple_selection') == 'no') { $options[] = array(-1, false, __('None Selected')); } if (!is_array($data['relation_id'])) { $data['relation_id'] = array($data['relation_id']); } // Setup field name $fieldname = 'fields' . $fieldnamePrefix . '[' . $this->get('element_name') . ']' . $fieldnamePostfix . '[]'; // Setup select $label = Widget::Label($this->get('label'), $links); $select = Widget::Select($fieldname, $options, $this->get('allow_multiple_selection') == 'yes' ? array('multiple' => 'multiple') : NULL); $label->appendChild($select); // Setup sorting $currentPageURL = Administration::instance()->getCurrentPageURL(); preg_match_all('/\\d+/', $currentPageURL, $entry_id, PREG_PATTERN_ORDER); $entry_id = $entry_id[0][count($entry_id[0]) - 1]; if ($entry_id) { $order = Administration::instance()->Database->fetchVar('order', 0, "SELECT `order`\n\t\t\t\t\tFROM `tbl_fields_subsectionmanager_sorting`\n\t\t\t\t\tWHERE `entry_id` = " . $entry_id . "\n\t\t\t\t\tAND `field_id` = " . $this->get('id') . "\n\t\t\t\t\tLIMIT 1"); } $input = Widget::Input('fields[sort_order][' . $this->get('id') . ']', $order, 'hidden'); $label->appendChild($input); // Setup relation id $input = Widget::Input('fields[subsection_id][' . $this->get('id') . ']', $this->get('subsection_id'), 'hidden'); $label->appendChild($input); $wrapper->appendChild($label); // Create stage $stage = new XMLElement('div', NULL, array('class' => 'stage preview')); $content['empty'] = '<li class="empty message"><span>' . __('There are no selected items') . '</span></li>'; $selected = new XMLElement('ul', $content['empty'] . $content['html'], array('class' => 'selection')); $stage->appendChild($selected); // Append item template $thumb = '<img src="' . URL . '/extensions/subsectionmanager/assets/images/new.gif" width="40" height="40" class="thumb" />'; $item = new XMLElement('li', $thumb . '<span>' . __('New item') . '<br /><em>' . __('Please fill out the form below.') . '</em></span><a class="destructor">' . __('Remove Item') . '</a>', array('class' => 'item template preview')); $selected->appendChild($item); // Append drawer template $subsection_handle = Administration::instance()->Database->fetchVar('handle', 0, "SELECT `handle`\n\t\t\t\tFROM `tbl_sections`\n\t\t\t\tWHERE `id` = '" . $this->get('subsection_id') . "'\n\t\t\t\tLIMIT 1"); $create_new = URL . '/symphony/publish/' . $subsection_handle . '/{$action}/{$id}'; $item = new XMLElement('li', '<iframe name="subsection-' . $this->get('element_name') . '" src="' . $create_new . '" frameborder="0"></iframe>', array('class' => 'drawer template')); $selected->appendChild($item); // Error handling if ($flagWithError != NULL) { $wrapper->appendChild(Widget::wrapFormElementWithError($stage, $flagWithError)); } else { $wrapper->appendChild($stage); } }
/** * @see http://symphony-cms.com/learn/api/2.3/toolkit/field/#prepareTableValue */ function prepareTableValue($data, XMLElement $link = null) { if (empty($data['relation_id'])) { return null; } // Single select if ($this->get('allow_multiple') == 0 || count($data['relation_id']) === 1) { $subsection = new SubsectionManager(); $content = $subsection->generate($this->get('id'), $this->get('subsection_id'), $data, $this->get('recursion_levels'), SubsectionManager::GETPREVIEW); // Link? if ($link) { $href = $link->getAttribute('href'); $item = '<a href="' . $href . '">' . $content['preview'] . '</a>'; } else { $item = $content['preview']; } return '<div class="subsectionmanager">' . $item . '</div>'; } else { $count = count($data['relation_id']); return parent::prepareTableValue(array('value' => $count > 1 ? $count . ' ' . __('items') : $count . ' ' . __('item')), $link); } }