/** * Installation Step 8: Finished! */ public function finished() { $this->checkPiwikIsNotInstalled(); $view = new View('@Installation/finished', $this->getInstallationSteps(), __FUNCTION__); $form = new FormDefaultSettings(); /** * Triggered on initialization of the form to customize default Piwik settings (at the end of the installation process). * * @param \Piwik\Plugins\Installation\FormDefaultSettings $form */ Piwik::postEvent('Installation.defaultSettingsForm.init', array($form)); $form->addElement('submit', 'submit', array('value' => Piwik::translate('General_ContinueToPiwik') . ' »', 'class' => 'btn btn-lg')); if ($form->validate()) { try { /** * Triggered on submission of the form to customize default Piwik settings (at the end of the installation process). * * @param \Piwik\Plugins\Installation\FormDefaultSettings $form */ Piwik::postEvent('Installation.defaultSettingsForm.submit', array($form)); $this->markInstallationAsCompleted(); Url::redirectToUrl('index.php'); } catch (Exception $e) { $view->errorMessage = $e->getMessage(); } } $view->addForm($form); $view->showNextStep = false; $output = $view->render(); return $output; }
/** * Installation Step 6: Configure first web-site */ public function firstWebsiteSetup() { $this->checkPiwikIsNotInstalled(); $this->initObjectsToCallAPI(); if (count(APISitesManager::getInstance()->getAllSitesId()) > 0) { // if there is a already a website, skip this step and trackingCode step $this->redirectToNextStep('trackingCode'); } $view = new View('@Installation/firstWebsiteSetup', $this->getInstallationSteps(), __FUNCTION__); $form = new FormFirstWebsiteSetup(); if ($form->validate()) { $name = Common::unsanitizeInputValue($form->getSubmitValue('siteName')); $url = Common::unsanitizeInputValue($form->getSubmitValue('url')); $ecommerce = (int) $form->getSubmitValue('ecommerce'); try { $result = APISitesManager::getInstance()->addSite($name, $url, $ecommerce); $params = array('site_idSite' => $result, 'site_name' => urlencode($name)); $this->addTrustedHosts($url); $this->redirectToNextStep(__FUNCTION__, $params); } catch (Exception $e) { $view->errorMessage = $e->getMessage(); } } // Display previous step success message, when current step form was not submitted yet if (count($form->getErrorMessages()) == 0) { $view->displayGeneralSetupSuccess = true; } $view->addForm($form); return $view->render(); }
/** * Installation Step 7: Configure first web-site */ public function firstWebsiteSetup() { $this->checkPreviousStepIsValid(__FUNCTION__); $view = new View('@Installation/firstWebsiteSetup', $this->getInstallationSteps(), __FUNCTION__); $this->skipThisStep(__FUNCTION__); $form = new FormFirstWebsiteSetup(); if (!isset($this->session->generalSetupSuccessMessage)) { $view->displayGeneralSetupSuccess = true; $this->session->generalSetupSuccessMessage = true; } $this->initObjectsToCallAPI(); if ($form->validate()) { $name = Common::unsanitizeInputValue($form->getSubmitValue('siteName')); $url = Common::unsanitizeInputValue($form->getSubmitValue('url')); $ecommerce = (int) $form->getSubmitValue('ecommerce'); $request = new Request("\n\t\t\t\t\t\t\tmethod=SitesManager.addSite\n\t\t\t\t\t\t\t&siteName={$name}\n\t\t\t\t\t\t\t&urls={$url}\n\t\t\t\t\t\t\t&ecommerce={$ecommerce}\n\t\t\t\t\t\t\t&format=original\n\t\t\t\t\t\t"); try { $result = $request->process(); $this->session->site_idSite = $result; $this->session->site_name = $name; $this->session->site_url = $url; $this->redirectToNextStep(__FUNCTION__); } catch (Exception $e) { $view->errorMessage = $e->getMessage(); } } $view->addForm($form); return $view->render(); }