/** * Saves the page selection */ protected function OnSuccess() { $allParams = array(); foreach ($this->oblParams as $param) { $allParams[$param] = $this->Value($param); } $optParams = $this->serializer->LinesToArray($this->Value('OptionalParameters')); foreach ($optParams as $name => $value) { if (!isset($allParams[$name])) { $allParams[$name] = $value; } } $this->SetJSFieldValue('#' . $this->prefix . 'Params', $this->serializer->ArrayToLines($allParams)); $this->SetJSFieldValue('#' . $this->prefix . 'Page', $this->page->GetID()); $this->SetJSFieldValue('#' . $this->prefix . 'Fragment', $this->Value('Fragment')); $this->SetJSHtml('#' . $this->prefix . 'Url', FrontendRouter::PageUrl($this->page, $allParams, $this->Value('Fragment'))); $this->CloseModal(); }
/** * Creates a new page url selector * @param string $prefix The prefix * @param string $label The selector label * @param PageUrl $pageUrl The pre-selected page url */ function __construct($prefix, $label = '', PageUrl $pageUrl = null) { $this->disabledPageIDs = array(); $this->prefix = $prefix; $this->label = $label; $this->site = null; $this->pageField = Input::Hidden($prefix . 'Page'); $this->paramsField = Input::Hidden($prefix . 'Params'); $this->fragmentField = Input::Hidden($prefix . 'Fragment'); $this->serializer = new ArrayLinesSerializer(); if ($pageUrl && $pageUrl->Exists()) { $this->url = FrontendRouter::Url($pageUrl); $this->pageField->SetValue($pageUrl->GetPage()->GetID()); $list = new PageParamListProvider($pageUrl); $this->paramsField->SetValue($this->serializer->ArrayToLines($list->ToArray())); $this->fragmentField->SetValue($pageUrl->GetFragment()); } }