/** * Gets the submitted locale. if the provided locale is not null, this will be used, else the * LocalizePanelForm will be checked. * @param string $locale * @return string Code of the submitted locale * @throws zibo\ZiboException when no locale is provided through an argument or the LocalizePanelForm */ private function getSubmittedLocale($locale) { if ($locale !== null) { return $locale; } $form = new LocalizePanelForm(); if ($form->isSubmitted()) { return $form->getLocaleCode(); } throw new ZiboException('No locale provided and the LocalizePanelForm is not submitted'); }
/** * Constructs a new localize panel view * @param boolean $enabled True to enable the localize form, false to disable it * @return null */ public function __construct($enabled = true) { parent::__construct(self::TEMPLATE); $form = new LocalizePanelForm(); if ($enabled) { $this->addJavascript(self::SCRIPT_LOCALIZE); $this->addInlineJavascript('ziboAdminInitializeLocalizePanel();'); } else { $form->setIsDisabled(true); } $this->set('form', $form); }