Esempio n. 1
0
 /**
  * Get SEO options
  * 
  * @static
  * @access public
  * @return array
  */
 public static function getOption()
 {
     $registry = Zend_Registry::getInstance();
     $option = Dot_Settings::getOptionVariables($registry->requestModule, 'seo');
     //remove the 'option' xml atribute
     $option->__unset('option');
     $option->__set('canonicalUrl', Dot_Route::createCanonicalUrl());
     return $option;
 }
Esempio n. 2
0
 /**
  * Create the pagination, based on how many data
  * @access public
  * @param array $page
  * @return string
  */
 protected function paginator($page)
 {
     // get route again here, because ajax may have change it
     //$route = Zend_Registry::get('route');
     $request = Zend_Registry::get('request');
     $this->setFile('page_file', 'paginator.tpl');
     $this->setVar('TOTAL_RECORDS', $page->totalItemCount);
     $this->setVar('TOTAL_PAGES', $page->pageCount);
     $this->setBlock('page_file', 'first', 'first_row');
     $this->setBlock('page_file', 'last', 'last_row');
     $this->setBlock('page_file', 'current_page', 'current_row');
     $this->setBlock('page_file', 'other_page', 'other_row');
     $this->setBlock('page_file', 'pages', 'pages_row');
     if (array_key_exists('page', $request)) {
         unset($request['page']);
     }
     $link = Dot_Route::createCanonicalUrl() . 'page/';
     if ($page->current != 1) {
         $this->setVar('FIRST_LINK', $link . "1");
         $this->parse('first_row', 'first', true);
     } else {
         $this->parse('first_row', '');
     }
     if ($page->current != $page->last && $page->last > $page->current) {
         $this->setVar('LAST_LINK', $link . $page->last);
         $this->parse('last_row', 'last', true);
     } else {
         $this->parse('last_row', '');
     }
     foreach ($page->pagesInRange as $val) {
         $this->setVar('PAGE_NUMBER', $val);
         $this->parse('other_row', '');
         $this->parse('current_row', '');
         if ($val == $page->current) {
             $this->parse('current_row', 'current_page', true);
         } else {
             $this->setVar('PAGE_LINK', $link . $val);
             $this->parse('other_row', 'other_page', true);
         }
         $this->parse('pages_row', 'pages', true);
     }
     $this->parse('PAGINATION', 'page_file');
 }
Esempio n. 3
0
 /**
  * Check permission based on the ACL roles
  * Set wanted url if user is not logged
  * @todo extension to check user level
  * @access public
  * @param string $who - who is checking the identity
  * @return bool
  */
 public function checkIdentity($who)
 {
     $role = 'guest';
     if ($this->hasIdentity()) {
         $user = $this->getIdentity();
         if (is_object($user)) {
             $role = $user->role;
         }
     }
     $config = Zend_Registry::get('configuration');
     $session = Zend_Registry::get('session');
     if (!$this->acl->isAllowed($role)) {
         //register wanted url
         if (!isset($session->wantUrl)) {
             $session->wantUrl = Dot_Route::createCanonicalUrl();
         }
         $option = Zend_Registry::get('option');
         if (isset($option->warningMessage->userPermission)) {
             $session->message['txt'] = $option->warningMessage->userPermission;
             $session->message['type'] = 'warning';
         }
         //create login url	to which will be redirect
         switch ($who) {
             case 'admin':
                 $loginUrl = $config->website->params->url . '/admin/admin/login';
                 break;
             default:
                 $loginUrl = $config->website->params->url . '/' . $who . '/login';
                 break;
         }
         header('Location: ' . $loginUrl);
         exit;
     }
     //if user is allowed, redirect him to wanted url
     if ($role == 'admin' && isset($session->wantUrl)) {
         $wantUrl = $session->wantUrl;
         unset($session->wantUrl);
         header('Location: ' . $wantUrl);
         exit;
     }
     return true;
 }