/** * */ public function listLanguageLinks() { $page = Digitalus_Builder::getPage(); $currentLanguage = $page->getLanguage(); $availableLanguages = $page->getAvailableLanguages(); $xhtml = $this->view->getTranslation('You are reading this page in') . ' ' . $this->view->getTranslation(Digitalus_Language::getFullName($currentLanguage)) . '.'; if (is_array($availableLanguages)) { $languageLinks = array(); $uri = new Digitalus_Uri(); $base = $uri->toString(); foreach ($availableLanguages as $locale => $name) { if (!empty($locale) && $locale != $currentLanguage) { $url = $base . '/p/language/' . $locale; $languageLinks[] = '<a href="' . $url . '">' . $this->view->getTranslation($name) . '</a>'; } } if (is_array($languageLinks) && count($languageLinks) > 0) { foreach ($languageLinks as $language) { $languageLinksTranslated[] = $this->view->getTranslation($language); } $xhtml .= ' ' . $this->view->getTranslation('This page is also translated into') . ' ' . implode(', ', $languageLinks); } } return '<p>' . $xhtml . '</p>'; }
public static function getLanguage() { $uri = new Digitalus_Uri(); $params = $uri->getParams(); if (isset($params['language']) && !empty($params['language'])) { $currentLang = $params['language']; } else { $session = self::getSession(); $key = self::LANGUAGE_KEY; $currentLang = $session->{$key}; if (empty($currentLang)) { $siteSettings = new Model_SiteSettings(); $currentLang = $siteSettings->get('default_language'); if (empty($currentLang)) { $config = Zend_Registry::get('config'); $currentLang = $config->language->defaultLocale; } if (empty($currentLang)) { $locale = new Zend_Locale(); $currentLang = $locale->getLanguage(); } } } self::setLanguage($currentLang); return $currentLang; }
public function appendUriParams() { $uri = new Digitalus_Uri(); $params = $uri->getParams(); if (is_array($params)) { $this->_page->setParams($params); } }
public function RenderBlock($path) { $mdlPage = new Model_Page(); $uriObj = new Digitalus_Uri($path); $pointer = $mdlPage->fetchPointer($uriObj->toArray()); $pageObj = $mdlPage->open($pointer, $mdlPage->getDefaultVersion()); $namespace = $pageObj->page->namespace . '_' . $pointer; return $this->view->RenderContentTemplate($pageObj->page->content_template, $pageObj->content, $namespace); }
public static function getCurrentPageName($onlyLast = true) { $uri = new Digitalus_Uri(); $uriString = $uri->toString(); if (true === $onlyLast) { return Digitalus_Toolbox_String::getSelfFromPath($uriString); } return Digitalus_Toolbox_String::stripLeading('/', $uriString); }
protected function _setActive($item = null) { if (empty($item)) { $item = $this->getItem(); } $uri = new Digitalus_Uri(); $uriString = strtolower($uri->toString()); if (strtolower(Digitalus_Toolbox_Page::getCurrentPageName()) == strtolower($item->name) || empty($uriString) && strtolower(Digitalus_Toolbox_Page::getHomePageName($item)) == strtolower(Digitalus_Toolbox_Page::getUrl($item))) { $active = true; } else { $active = false; } $this->setActive($active); }
protected function _getAction($moduleParts) { // Check whether uri params are given and set the action respectively $uri = new Digitalus_Uri(); $uriParams = $uri->getParams(); $name = strtolower($moduleParts[0]); if (isset($uriParams['a']) && !empty($uriParams['a'])) { $action = $uriParams['a']; } if (isset($action) && !empty($action) && '' != $action && $this->_actionExists($name, $action)) { return $action; } return $moduleParts[1]; }
public function showAction() { $show = $this->moduleData->show; $page = Digitalus_Builder::getPage(); $params = $page->getParams(); if (!isset($params['slide']) || $params['slide'] == null) { $index = 1; } else { $index = $params['slide']; } $mdlSlide = new Slideshow_Slide(); $slide = $mdlSlide->getSlideByShow($show, $index); $count = $mdlSlide->countSlidesInShow($show); $pageLinks = new stdClass(); if ($index == 1) { $pageLinks->first = null; $pageLinks->previous = null; } else { $pageLinks->first = Digitalus_Uri::get(false, false, array('slide' => 1)); $pageLinks->previous = Digitalus_Uri::get(false, false, array('slide' => $index - 1)); } if ($index < $count && $count > 1) { $pageLinks->next = Digitalus_Uri::get(false, false, array('slide' => $index + 1)); $pageLinks->last = Digitalus_Uri::get(false, false, array('slide' => $count)); } else { $pageLinks->next = null; $pageLinks->last = null; } $this->view->pageLinks = $pageLinks; $this->view->slide = $slide; $this->view->index = $index; $this->view->count = $count; $this->view->slides = $mdlSlide->getSlides($show); }
/** * Login action * * if the form has not been submitted this renders the login form * if it has then it validates the data * if it is sound then it runs the Digitalus_Auth_Adapter function * to authorise the request * on success it redirects to the admin home page * * @return void */ public function loginAction() { $form = new Admin_Form_Login(); $form->setAction($this->baseUrl . '/admin/auth/login'); if ($this->_request->isPost() && $form->isValid($_POST)) { $uri = Digitalus_Filter_Post::get('uri'); $username = Digitalus_Filter_Post::get('adminUsername'); $password = Digitalus_Filter_Post::get('adminPassword'); $auth = new Digitalus_Auth($username, $password); $result = $auth->authenticate(); if ($result) { if ($uri == '' || $uri == 'admin/auth/login') { $uri = 'admin'; } $this->_redirect($uri); } else { $e = new Digitalus_View_Error(); $e->add($this->view->getTranslation('The username or password you entered was not correct.')); } $this->view->uri = $uri; } else { $this->view->uri = Digitalus_Uri::get(); } $this->view->form = $form; }
public static function loadPage($uri = null, $buildStack = null, Digitalus_Page $page = null, Zend_View $view = null, $persist = null) { // fetch the builder stack from config $config = Zend_Registry::get('config'); if ($buildStack == null) { $buildStack = $config->builder->stack; } // set whether to persist this page as the current page if ($persist === null) { if (strtolower($config->builder->persistPage) == 'true') { $persist = true; } else { $persist = false; } } $pathToBuildStack = self::PATH_TO_BUILDERS . '/' . $buildStack; //load the builder stack $stack = simplexml_load_file($pathToBuildStack); // get the uri $uri = new Digitalus_Uri($uri); $uriArray = $uri->toArray(); //create the page if one is not passed if ($page == null) { $page = new Digitalus_Page($uriArray); } if ($view != null) { $page->setView($view); } // actions is a stack of all of the builder action files $actions = array(); foreach ($stack as $action) { $attributes = $action->attributes(); $className = self::BASE_CLASSNAME . (string) $attributes['class']; $methodName = (string) $attributes['method']; if (isset($actions[$className])) { $class = $actions[$className]; } else { $class = new $className($page, $attributes, $persist); $actions[$className] = $class; } $class->{$methodName}($attributes); } return $page; }
public function __construct($options = null) { parent::__construct($options); $view = $this->getView(); $this->setAction($view->getBaseUrl() . Digitalus_Uri::get())->setAttrib('id', 'searchForm'); $submitSearchForm = $this->createElement('hidden', 'submitSearchForm', array('value' => 1)); $keywords = $this->createElement('text', 'keywords', array('required' => true, 'label' => $view->getTranslation('Keywords'), 'attribs' => array('size' => 50), 'validators' => array(array('NotEmpty', true)), 'errorMessages' => array($view->getTranslation('Please provide a keyword to search for!')))); $submit = $this->createElement('submit', 'submit', array('label' => $view->getTranslation('Search'), 'attribs' => array('class' => 'submit'))); $this->addElement($submitSearchForm)->addElement($keywords)->addElement($submit)->addDisplayGroup(array('form_instance', 'submitSearchForm', 'keywords', 'submit'), 'guestbookGroup', array('legend' => $view->getTranslation('Search Site'))); }
/** * if there is a redirector set for the current page this will return * the path and response code * * @return stdClass object */ public function getCurrentRedirector() { $uri = $_SERVER['REQUEST_URI']; if ($newPath = $this->get($uri)) { $response = new stdClass(); if ($newPath->response_code > 0) { $response->responseCode = intval($newPath->response_code); } if (Zend_Uri::check($newPath->response)) { //this is a valid http uri. return as a string to redirect $response->path = $newPath->response; return $response; } else { //this is not a valid http uri. return as an array to find the page $uriObj = new Digitalus_Uri(); $response->path = $uriObj->toArray($newPath->response); return $response; } } }
public function pageExists(Digitalus_Uri $uri) { if ($this->_fetchPointer($uri->toArray(), 0) || $uri == null) { return true; } else { return false; } }
/** * The public challenge action for getting a new password * * @return void */ public function changepasswordAction() { $uri = new Digitalus_Uri(); $uriParams = $uri->getParams(); if (!isset($uriParams['u']) || !isset($uriParams['c'])) { $this->_error; } else { $userName = $uriParams['u']; $challengeId = $uriParams['c']; $mdlChallenge = new Login_Challenge(); if (!$mdlChallenge->isValid($challengeId, $userName)) { $this->_error = $this->view->getTranslation('Error: No valid challenge was found. Please try again!'); } else { $changePasswordForm = new User_Form(); $uri = $this->baseUrl . '/' . Digitalus_Toolbox_Page::getCurrentPageName() . '/p/a/changepassword/u/' . $userName . '/c/' . $challengeId; $changePasswordForm->setAction($uri); $changePasswordForm->getElement('name')->addValidators(array(array('UsernameExists', true))); $changePasswordForm->onlyChangepasswordActionElements(array('legend' => 'Change Password')); if ($this->_request->isPost() && $changePasswordForm->isValid($_POST)) { $password = Digitalus_Filter_Post::get('password'); $passwordConfirm = Digitalus_Filter_Post::get('password_confirm'); $mdlUser = new Model_User(); if (!$mdlUser->updatePassword($userName, $password, true, $passwordConfirm)) { $this->_error = $this->view->getTranslation("Error: Your password hasn't been updated!"); } else { $mdlChallenge->invalidate($challengeId); $this->_message = $this->view->getTranslation('Your password has been updated successfully!'); } } else { $this->_message = $this->view->getTranslation('Please type in Your user name and Your new password.'); $this->view->form = $changePasswordForm; } } } $this->view->error = $this->_error; $this->view->message = $this->_message; }
public static function get($relative = true, $stripParams = true, $addParams = null) { $uri = new Digitalus_Uri(); if ($relative) { $uriString = $uri->getRelative(); } else { $uriString = $uri->getAbsolute(); } $params = array(); if ($stripParams == false) { $params = $uri->getParams(); } if (is_array($addParams)) { foreach ($addParams as $k => $v) { $params[$k] = $v; } } $paramsString = null; if (is_array($params)) { foreach ($params as $k => $v) { $paramsString .= '/' . $k . '/' . $v; } } if ($paramsString != null) { $uriString .= '/p' . $paramsString; } return $uriString; }