/** * Get all pages from pages field as array * @param \DataContainer $dc * * @return array The pages */ public function getPages(\DataContainer $dc) { $arrOptions = array(); if (!$dc->activeRecord && !is_array($dc->activeRecord->pages)) { return $arrOptions; } $arrPages = deserialize($dc->activeRecord->pages, true); $arrOrder = deserialize($dc->activeRecord->orderPages, true); $objPages = \PageModel::findMultipleByIds($arrPages, array('order' => 'FIELD(id,' . implode(",", $arrOrder) . ')')); if ($objPages === null) { return $arrOptions; } while ($objPages->next()) { $arrOptions[$objPages->id] = $arrValues[$objPages->id] = $objPages->title . ' (' . $objPages->alias . \Config::get('urlSuffix') . ')'; } return $arrOptions; }
/** * Generate the widget and return it as string * * @return string */ public function generate() { $arrSet = array(); $arrValues = array(); $blnHasOrder = $this->orderField != '' && is_array($this->{$this->orderField}); if (!empty($this->varValue)) { $objPages = \PageModel::findMultipleByIds((array) $this->varValue); if ($objPages !== null) { while ($objPages->next()) { $arrSet[] = $objPages->id; $arrValues[$objPages->id] = \Image::getHtml($this->getPageStatusIcon($objPages)) . ' ' . $objPages->title . ' (' . $objPages->alias . \Config::get('urlSuffix') . ')'; } } // Apply a custom sort order if ($blnHasOrder) { $arrNew = array(); foreach ($this->{$this->orderField} as $i) { if (isset($arrValues[$i])) { $arrNew[$i] = $arrValues[$i]; unset($arrValues[$i]); } } if (!empty($arrValues)) { foreach ($arrValues as $k => $v) { $arrNew[$k] = $v; } } $arrValues = $arrNew; unset($arrNew); } } // Load the fonts for the drag hint (see #4838) \Config::set('loadGoogleFonts', true); $return = '<input type="hidden" name="' . $this->strName . '" id="ctrl_' . $this->strId . '" value="' . implode(',', $arrSet) . '">' . ($blnHasOrder ? ' <input type="hidden" name="' . $this->strOrderName . '" id="ctrl_' . $this->strOrderId . '" value="' . $this->{$this->orderField} . '">' : '') . ' <div class="selector_container">' . ($blnHasOrder && count($arrValues) > 1 ? ' <p class="sort_hint">' . $GLOBALS['TL_LANG']['MSC']['dragItemsHint'] . '</p>' : '') . ' <ul id="sort_' . $this->strId . '" class="' . ($blnHasOrder ? 'sortable' : '') . '">'; foreach ($arrValues as $k => $v) { $return .= '<li data-id="' . $k . '">' . $v . '</li>'; } $return .= '</ul> <p><a href="contao/page.php?do=' . \Input::get('do') . '&table=' . $this->strTable . '&field=' . $this->strField . '&act=show&id=' . $this->activeRecord->id . '&value=' . implode(',', $arrSet) . '&rt=' . REQUEST_TOKEN . '" class="tl_submit" onclick="Backend.getScrollOffset();Backend.openModalSelector({\'width\':768,\'title\':\'' . specialchars($GLOBALS['TL_LANG']['MSC']['pagepicker']) . '\',\'url\':this.href,\'id\':\'' . $this->strId . '\'});return false">' . $GLOBALS['TL_LANG']['MSC']['changeSelection'] . '</a></p>' . ($blnHasOrder ? ' <script>Backend.makeMultiSrcSortable("sort_' . $this->strId . '", "ctrl_' . $this->strOrderId . '")</script>' : '') . ' </div>'; if (!\Environment::get('isAjaxRequest')) { $return = '<div>' . $return . '</div>'; } return $return; }
/** * Find jumpTo page for current category scope * * @param \Isotope\Model\Product\Standard $objProduct * * @return \PageModel */ protected function findJumpToPage($objProduct) { global $objPage; global $objIsotopeListPage; $productCategories = $objProduct->getCategories(true); $arrCategories = array(); if ($this->iso_category_scope != 'current_category' && $this->iso_category_scope != '' && $objPage->alias != 'index') { $arrCategories = array_intersect($productCategories, $this->findCategories()); } // If our current category scope does not match with any product category, // use the first allowed product category in the current root page if (empty($arrCategories)) { $arrCategories = $productCategories; } $arrCategories = Frontend::getPagesInCurrentRoot($arrCategories, \FrontendUser::getInstance()); if (!empty($arrCategories) && ($objCategories = \PageModel::findMultipleByIds($arrCategories)) !== null) { $blnMoreThanOne = $objCategories->count() > 1; foreach ($objCategories as $objCategory) { if ($objCategory->alias == 'index' && $blnMoreThanOne) { continue; } return $objCategory; } } return $objIsotopeListPage ?: $objPage; }
/** * Find images for given page * @param \PageModel * @return array */ protected static function findForPage(\PageModel $objPage, $blnInherit = true) { if (!isset(static::$arrImages[$objPage->id])) { static::$arrImages[$objPage->id] = false; $arrImages = static::parsePage($objPage); if (!empty($arrImages)) { static::$arrImages[$objPage->id] = array('images' => $arrImages, 'inherited' => false); } else { $objPage->loadDetails(); $objTrails = \PageModel::findMultipleByIds(array_reverse($objPage->trail)); if (null !== $objTrails) { foreach ($objTrails as $objTrail) { $arrImages = static::parsePage($objTrail); if (!empty($arrImages)) { static::$arrImages[$objPage->id] = array('images' => $arrImages, 'inherited' => true); break; } } } } } if (static::$arrImages[$objPage->id] === false || !$blnInherit && static::$arrImages[$objPage->id]['inherited']) { return null; } return static::$arrImages[$objPage->id]['images']; }