示例#1
0
文件: Lithium.php 项目: maxwroc/PHP
 /**
  * Set up class properties etc.
  */
 private function Setup()
 {
     // place for additional sets
     // e.g. $this->aConfig[ section_key ][ value_key ] = value
     $sAppConfigIni = DOCROOT . $this->oConfig->getValue(sprintf('applications.%s.config_file', $this->oRouter->getApplicationName()));
     $this->oConfig->loadIniFile($sAppConfigIni);
     $this->sLogsDirectory = $this->getConfig('General.Logs_directory', DOCROOT . 'logs/');
     $this->sLogsDirectory .= date('Y-m-d') . '/';
     // set main framework path
     $this->addPath('Lithium');
     // set application path received from config file
     if ($sAppPath = $this->getConfig('General.App_path')) {
         $this->addPath($sAppPath);
         Loader::addPath(DOCROOT . $sAppPath);
     }
     // add path for external classes
     Loader::addPath(DOCROOT);
     // set language
     if ($sLanguage = $this->getConfig('Locale.Language')) {
         $this->sLanguage = $sLanguage;
     }
     Core_Model::setLithium($this);
     Core_Module::setLithium($this);
     Database_Driver::setLithium($this);
     // initialize router
     $this->oRouter->init();
     View::setRouter($this->oRouter);
     Module_Sorter::setRouter($this->oRouter);
     Module_Pagination::setRouter($this->oRouter);
 }
示例#2
0
文件: Catering.php 项目: maxwroc/PHP
 public function init()
 {
     $this->oAuth = new Module_Auth();
     if ($iSessionTimeout = $this->oLithium->getConfig('General.Session_timeout')) {
         $this->oAuth->setTimeout($iSessionTimeout);
     }
     // load xajax lib
     Loader::loadClass('Library_Xajax', 'LXajax');
     $this->oXajax = new LXajax();
     // if xajax call end executing rest of code
     if ($this->isAjaxCall()) {
         parent::init();
         return;
     }
     // sprawdzanie czy uzytkownik niezalogowany
     if (!$this->oAuth->isLoggedIn()) {
         // przed wywolaniem konstruktora rodzica ustawiamy sciezke do layoutu
         View::setDefaultTemplateDir('ciao_new/');
         parent::init();
         // wiadomosc powitalna
         $this->mTemplate->aWelcomeMessage = array('sDinnersFullName' => '', 'sText' => $this->getLang('catering.welcome_text_not_loggedin'));
         $aMenu['Menu uzytkownika']['login'] = array('sTarget' => '/user/login/', 'sText' => $this->getLang('user.login'));
         //			$aMenu[ 'Menu uzytkownika' ][] = array();
         //
         $aMenu['Menu uzytkownika']['register'] = array('sTarget' => '/user/register/', 'sText' => $this->getLang('user.register'));
     } else {
         // logged in
         $this->oCurrentUser = $this->oAuth->getLoggedInUser();
         if (!empty($this->aRolesAllowed) && !in_array($this->oCurrentUser->get('role_id')->name, $this->aRolesAllowed)) {
             $this->redirect('/');
             echo ' ';
         }
         if (is_null($sLayout = $this->oCurrentUser->propertie('template'))) {
             $iLayoutId = (int) $this->oCurrentUser->layout_id;
             if ($iLayoutId != 0) {
                 $oLayout = new Model_Layout($iLayoutId);
                 $aLayout = $oLayout->getRow();
                 $this->oCurrentUser->propertie('template', $aLayout['path']);
             } else {
                 $this->oCurrentUser->propertie('template', '');
             }
         }
         View::setDefaultTemplateDir($this->oCurrentUser->propertie('template'));
         parent::init();
         //dodajemy info o posilku na dzis
         $this->showOrdersForToday();
         $this->mTemplate->header_username = $this->getLang('catering.header_username', $this->oCurrentUser->name);
         $aMenu['Menu uzytkownika'][] = array('sTarget' => '/', 'sText' => 'Strona glowna');
         $aMenu['Menu uzytkownika'][] = array();
         $aMenu['Menu uzytkownika'][] = array('sTarget' => '/catering/enrol/', 'sText' => $this->getLang('catering.enrol'));
         $aMenu['Menu uzytkownika'][] = array();
         $aMenu['Menu uzytkownika'][] = array('sTarget' => '/user/settings/', 'sText' => 'Ustawienia');
         $aMenu['Menu uzytkownika'][] = array();
         $aMenu['Menu uzytkownika']['login'] = array('sTarget' => '/user/logout/', 'sText' => $this->getLang('user.logout'));
         $this->sRole = $this->oCurrentUser->get('role_id')->name;
         switch ($this->sRole) {
             case 'admin':
                 $sTitle = $this->getLang('account.administration');
                 $aMenu[$sTitle][] = array('sTarget' => '/account/', 'sText' => $this->getLang('account.settings'));
                 $aMenu[$sTitle][] = array();
                 $aMenu[$sTitle][] = array('sTarget' => '/account/user/', 'sText' => $this->getLang('account.add_user'));
                 $aMenu[$sTitle][] = array();
                 $aMenu[$sTitle][] = array('sTarget' => '/account/users/', 'sText' => $this->getLang('account.user_list'));
             case 'moderator':
                 $sTitle = $this->getLang('account.dinners_menu');
                 $aMenu[$sTitle][] = array('sTarget' => '/account/types/', 'sText' => 'Typy skladnikow');
                 $aMenu[$sTitle][] = array();
                 $aMenu[$sTitle][] = array('sTarget' => '/account/course/', 'sText' => 'Dodaj skladnik');
                 $aMenu[$sTitle][] = array();
                 $aMenu[$sTitle][] = array('sTarget' => '/account/courses/', 'sText' => 'Lista skladnikow');
                 $aMenu[$sTitle][] = array();
                 $aMenu[$sTitle][] = array('sTarget' => '/account/meals/', 'sText' => 'Dania');
                 $aMenu[$sTitle][] = array();
                 $aMenu[$sTitle][] = array('sTarget' => '/account/orders/', 'sText' => 'Edycja zamowien');
                 $sTitle = $this->getLang('account.summary_menu');
                 $aMenu[$sTitle][] = array('sTarget' => '/account/summary/users/', 'sText' => 'Kosztow na dzien');
                 $aMenu[$sTitle][] = array();
                 $aMenu[$sTitle][] = array('sTarget' => '/account/summary/', 'sText' => 'Zamowienia');
                 break;
         }
     }
     // set images for sorter
     Module_Sorter::setImageUrl('arrow-sort-up.gif', Module_Sorter::SORT_ASC);
     Module_Sorter::setImageUrl('arrow-sort-down.gif', Module_Sorter::SORT_DESC);
     $this->mTemplate->aMeta = array();
     $this->mTemplate->title = 'Catering';
     $this->mTemplate->menu = $aMenu;
 }
示例#3
0
文件: Sorter.php 项目: maxwroc/PHP
 public static function setUriStrings($sUriSortOrder, $sUriSortReverse)
 {
     self::$sUriSortOrder = $sUriSortOrder;
     self::$sUriSortReverse = $sUriSortReverse;
 }
示例#4
0
文件: Account.php 项目: maxwroc/PHP
 public function coursesAction()
 {
     $this->mTemplate->sSectionTitle = $this->getLang('section_title_coursesadmin');
     $aList = array();
     // setup sorter
     $oSorter = new Module_Sorter(Model_Course::SORT_NAME);
     $oSorter->addSortOption(Model_Course::SORT_PRICE, Module_Sorter::SORT_DESC);
     $oSorter->addSortOption(Model_Course::SORT_TYPE);
     $oCourse = new Model_Course();
     $oCourse->setSorter($oSorter);
     $iItemsPerPage = 30;
     $oPagination = new Module_Pagination($iItemsPerPage, $oCourse->getRowsCount());
     $oPagination->setString(array('previous' => $this->getLang('catering.prev_f'), 'next' => $this->getLang('catering.next_f'), 'label' => $this->getLang('catering.page')));
     $aCourses = $oCourse->getCoursesForAccount($this->oCurrentUser->account_id, $oPagination->getOffset(), $iItemsPerPage);
     foreach ($aCourses as $aCourse) {
         $aList[] = array(array('sLink' => '/account/course/' . $aCourse['course_id'] . '/', 'sText' => $aCourse['name']), array('sText' => $aCourse['price']), array('sText' => $aCourse['type']));
     }
     $aData = array('aColumns' => array(array('text' => $this->getLang('course_name'), 'url' => $oSorter->getSortUrl(), 'img' => $oSorter->getSortDirectionImg()), array('text' => $this->getLang('course_price'), 'url' => $oSorter->getSortUrl(1), 'img' => $oSorter->getSortDirectionImg(1)), array('text' => $this->getLang('course_type'), 'url' => $oSorter->getSortUrl(2), 'img' => $oSorter->getSortDirectionImg(2))), 'aList' => $aList, 'mPagination' => View::factory('pagination', $oPagination->getViewData()));
     $this->mTemplate->content = View::factory('account/item_list', $aData)->render();
 }