Пример #1
0
 /**
  * Builds header menu with left and right items
  *
  * @param  Phalcon_View $view
  * @return string
  */
 public static function getMenu($view)
 {
     $auth = Phalcon_Session::get('auth');
     if ($auth) {
         self::$_headerMenu['pull-right']['session'] = array('caption' => 'Log Out', 'action' => 'end');
     } else {
         unset(self::$_headerMenu['pull-left']['invoices']);
     }
     echo '<div class="nav-collapse">';
     $controllerName = $view->getControllerName();
     foreach (self::$_headerMenu as $position => $menu) {
         echo '<ul class="nav ', $position, '">';
         foreach ($menu as $controller => $option) {
             if ($controllerName == $controller) {
                 echo '<li class="active">';
             } else {
                 echo '<li>';
             }
             echo Phalcon_Tag::linkTo($controller . '/' . $option['action'], $option['caption']);
             echo '</li>';
         }
         echo '</ul>';
     }
     echo '</div>';
 }
Пример #2
0
 public function beforeDispatch()
 {
     if (!Phalcon_Session::get('auth')) {
         Flash::error('You don\'t have access to this module', 'alert alert-error');
         $this->_forward('index/index');
     }
 }
Пример #3
0
 /**
  * Edit the active user profile
  *
  */
 public function profileAction()
 {
     //Get session info
     $auth = Session::get('auth');
     //Query the active user
     $user = Users::findFirst($auth['id']);
     if ($user == false) {
         $this->_forward('index/index');
     }
     if (!$this->request->isPost()) {
         Tag::setDefault('name', $user->name);
         Tag::setDefault('email', $user->email);
     } else {
         $name = $this->request->getPost('name', 'string');
         $email = $this->request->getPost('email', 'email');
         $name = strip_tags($name);
         $user->name = $name;
         $user->email = $email;
         if ($user->save() == false) {
             foreach ($user->getMessages() as $message) {
                 Flash::error((string) $message, 'alert alert-error');
             }
         } else {
             Flash::success('Your profile information was updated successfully', 'alert alert-success');
         }
     }
 }
Пример #4
0
 public static function disclaimer($translate)
 {
     if (!Phalcon_Session::get('disclaimer')) {
         echo '<div class="alert alert-info">
         <a class="close" data-dismiss="alert" href="#">×</a>
         ', $translate->_('disclaimer', array('framework' => '<a href="http://phalconphp.com">Phalcon PHP Framework</a>', 'official' => '<a href="https://www.php.net">' . $translate['accessOf'] . '</a>')), '        
         </div>';
         Phalcon_Session::set('disclaimer', true);
     }
 }
Пример #5
0
 public function indexAction()
 {
     $language = Phalcon_Session::get('language');
     $news = News::find(array("language='{$language}'", "limit" => 5, "order" => "published desc"));
     if (count($news) === 0) {
         $news = News::find(array("language='en'", "limit" => 5, "order" => "published desc"));
     }
     //Query the last 5 news
     $this->view->setVar("news", $news);
 }
Пример #6
0
 protected function _getTransPath()
 {
     $translationPath = '../app/messages/';
     $language = Phalcon_Session::get("language");
     if (!$language) {
         Phalcon_Session::set("language", "en");
     }
     if ($language === 'es' || $language === 'en') {
         return $translationPath . $language;
     } else {
         return $translationPath . 'en';
     }
 }