Beispiel #1
0
 public function __construct($_repository_name = null)
 {
     $this->repository_name = $_repository_name === null ? \lib\router::get_repository_name() : $_repository_name;
     $include_path = $this->manifest_get_file_list();
     foreach ($include_path as $key => $manifest_file) {
         $this->manifest_include_file($manifest_file);
     }
 }
Beispiel #2
0
 /**
  * [__construct description]
  */
 public function __construct()
 {
     parent::__construct();
     if (MyAccount && SubDomain == null) {
         if (AccountService === Domain) {
             $domain = null;
         } else {
             $domain = AccountService . MainTld;
         }
         $param = $this->url('param');
         if ($param) {
             $param = '?' . $param;
         }
         switch ($this->module()) {
             case 'signin':
             case 'login':
                 $this->redirector()->set_domain($domain)->set_url(MyAccount . '/login' . $param)->redirect();
                 break;
             case 'signup':
             case 'register':
                 $this->redirector()->set_domain($domain)->set_url(MyAccount . '/signup' . $param)->redirect();
                 break;
             case 'signout':
             case 'logout':
                 // if(Domain !== MainService)
                 // $this->redirector()->set_domain(MainService.'.'.Tld)->set_url('logout')->redirect();
                 $this->redirector()->set_domain()->set_url(MyAccount . '/logout' . $param)->redirect();
                 break;
                 // case 'favicon.ico':
                 // 	$this->redirector()->set_domain()->set_url('static/images/favicon.png')->redirect();
                 // 	break;
         }
     }
     $myrep = router::get_repository_name();
     // running template base module for homepage
     if (\lib\router::get_storage('CMS') && $myrep === 'content' && method_exists($this, 's_template_finder') && get_class($this) === 'content\\home\\controller') {
         $this->s_template_finder();
     }
     $this->pagnation_config();
     $this->save_ref();
 }
Beispiel #3
0
 /**
  * return
  * @param  string $_loc  location
  * @param  string $_type type of permission needed
  * @return [type]        [description]
  */
 public static function access($_content = null, $_loc = null, $_type = null, $_block = null)
 {
     $myStatus = null;
     $su = null;
     // if user is superviser then set su to true
     // permission id 1 is supervisior of system
     if (isset($_SESSION['user']['permission']) && $_SESSION['user']['permission'] === "1") {
         $su = true;
         $suStatus = self::permListFill('su');
     }
     // if programmer not set content, give it automatically from address
     if ($_content === 'all') {
         $myStatus = [];
         if ($su) {
             foreach ($suStatus as $key => $value) {
                 if (isset($value['enable'])) {
                     $myStatus[$key] = $value['enable'];
                 }
             }
         } elseif (isset($_SESSION['permission'])) {
             foreach ($_SESSION['permission'] as $key => $value) {
                 if (isset($value['enable'])) {
                     $myStatus[$key] = $value['enable'];
                 }
             }
         }
         return $myStatus;
     } elseif (!$_content) {
         $_content = \lib\router::get_repository_name();
         if ($_content !== "content") {
             $_content = substr($_content, strpos($_content, '_') + 1);
         }
     }
     if (!isset($suStatus[$_content]) || !isset($suStatus[$_content]['modules'])) {
         $su = false;
     }
     // if user want specefic location
     if ($_loc == 'all') {
         if ($su) {
             $myStatus = $suStatus[$_content]['modules'];
         } elseif (isset($_SESSION['permission'][$_content]['modules'])) {
             $myStatus = $_SESSION['permission'][$_content]['modules'];
         }
     } elseif ($_loc) {
         if ($_type) {
             if ($su) {
                 if (isset($suStatus[$_content]['modules'][$_loc][$_type])) {
                     $myStatus = $suStatus[$_content]['modules'][$_loc][$_type];
                 }
             } elseif (isset($_SESSION['permission'][$_content]['modules'][$_loc][$_type])) {
                 $myStatus = $_SESSION['permission'][$_content]['modules'][$_loc][$_type];
             }
         } else {
             if ($su) {
                 $myStatus = $suStatus[$_content]['modules'][$_loc];
             } elseif (isset($_SESSION['permission'][$_content]['modules'][$_loc])) {
                 $myStatus = $_SESSION['permission'][$_content]['modules'][$_loc];
             }
         }
     } else {
         if ($su) {
             $myStatus = $suStatus[$_content]['enable'];
         } elseif (isset($_SESSION['permission'][$_content]['enable'])) {
             $myStatus = $_SESSION['permission'][$_content]['enable'];
         }
     }
     if (!$myStatus) {
         if ($_block === "notify" && $_type && $_loc) {
             $msg = null;
             switch ($_type) {
                 case 'view':
                     $msg = "You can't view this part of system";
                     break;
                 case 'add':
                     $msg = T_("You can't add new") . ' ' . T_($_loc);
                     break;
                 case 'edit':
                     $msg = T_("You can't edit") . ' ' . T_($_loc);
                     break;
                 case 'delete':
                     $msg = T_("You can't delete") . ' ' . T_($_loc);
                     break;
                 default:
                     $msg = "You can't access to this part of system";
                     break;
             }
             $msg = $msg . "<br/> " . T_("Because of your permission");
             \lib\debug::error(T_($msg));
             // exit();
         } elseif ($_block) {
             \lib\error::access(T_("You can't access to this page!"));
         } else {
             // do nothing!
         }
     }
     return $myStatus;
 }
Beispiel #4
0
 /**
  * return
  * @param  string $_loc  location
  * @param  string $_type type of permission needed
  * @return [type]        [description]
  */
 public function access($_content = null, $_loc = null, $_type = null, $_block = null)
 {
     $myStatus = null;
     // if programmer not set content, give it automatically from address
     if ($_content === 'all') {
         $myStatus = [];
         if (isset($_SESSION['permission'])) {
             foreach ($_SESSION['permission'] as $key => $value) {
                 if (isset($value['enable'])) {
                     $myStatus[$key] = $value['enable'];
                 }
             }
         }
         return $myStatus;
     } elseif (!$_content) {
         $_content = router::get_repository_name();
         $_content = substr($_content, strpos($_content, '_') + 1);
     }
     // if user want specefic location
     if ($_loc == 'all') {
         if (isset($_SESSION['permission'][$_content]['modules'])) {
             $myStatus = $_SESSION['permission'][$_content]['modules'];
         }
     } elseif ($_loc) {
         if ($_type) {
             if (isset($_SESSION['permission'][$_content]['modules'][$_loc][$_type])) {
                 $myStatus = $_SESSION['permission'][$_content]['modules'][$_loc][$_type];
             }
         } else {
             if (isset($_SESSION['permission'][$_content]['modules'][$_loc])) {
                 $myStatus = $_SESSION['permission'][$_content]['modules'][$_loc];
             }
         }
     } else {
         if (isset($_SESSION['permission'][$_content]['enable'])) {
             $myStatus = $_SESSION['permission'][$_content]['enable'];
         }
     }
     if (!$myStatus) {
         if ($_block === "notify" && $_type && $_loc) {
             $msg = null;
             switch ($_type) {
                 case 'view':
                     $msg = "You can't view this part of system";
                     break;
                 case 'add':
                     $msg = T_("you can't add new") . ' ' . T_($_loc);
                     break;
                 case 'edit':
                     $msg = T_("you can't edit") . ' ' . T_($_loc);
                     break;
                 case 'delete':
                     $msg = T_("you can't delete") . ' ' . T_($_loc);
                     break;
                 default:
                     $msg = "you can't access to this part of system";
                     break;
             }
             $msg = $msg . "<br/>" . T_(" Because of your permission");
             \lib\debug::error(T_($msg));
             $this->model()->_processor(object(array("force_json" => true, "force_stop" => true)));
         } elseif ($_block) {
             \lib\error::access(T_("you can't access to this page!"));
         }
     }
     return $myStatus;
 }
Beispiel #5
0
 public static function detect_language()
 {
     /**
      * set default language to storage for next use
      */
     // var_dump(\lib\utility\option::get('config', 'meta', 'defaultLanguage'));
     $default_lang = \lib\utility\option::get('config', 'meta', 'defaultLang');
     if ($default_lang) {
         router::set_storage('defaultLanguage', $default_lang);
     } else {
         router::set_storage('defaultLanguage', 'en_US');
     }
     // if current tld is ir or referrer from site with ir tld,
     // change language to fa_IR
     if (\lib\router::get_storage('language')) {
         $myLang = router::get_storage('language');
         switch (Tld) {
             case 'ir':
                 $myLang = "fa_IR";
                 break;
             default:
                 break;
         }
         if (defined('MainService') && Tld !== 'dev') {
             // for example redirect ermile.ir to ermile.com/fa
             $myLang = substr($myLang, 0, 2);
             $myredirect = new \lib\redirector();
             $myredirect->set_domain()->set_url($myLang)->redirect();
         } else {
             // else show in that domain with fa langusage
             router::set_storage('language', $myLang);
         }
     }
     /**
      * Localized Language, defaults to English.
      *
      * Change this to localize Saloos. A corresponding MO file for the chosen
      * language must be installed to content/languages. For example, install
      * fa_IR.mo to content/languages and set LANGUAGE to 'fa_IR' to enable Persian
      * language support.
      */
     router::set_storage('language', router::get_storage('defaultLanguage'));
     if (router::get_repository_name() === 'content') {
         // $mysub = router::get_sub_domain();
         $mysub = router::get_url(0);
         $myList = \lib\utility\option::languages();
         // check langlist with subdomain and if is equal set current language
         foreach ($myList as $key => $value) {
             $myLang = substr($key, 0, 2);
             if ($mysub === $myLang) {
                 if (router::get_storage('defaultLanguage') === $key) {
                     // redirect to homepage
                     $myredirect = new \lib\redirector();
                     $myredirect->set_domain()->set_url()->redirect();
                 } else {
                     router::set_storage('language', $key);
                     // update base url
                     router::$base .= '/' . router::get_url(0);
                     router::remove_url($myLang);
                 }
             }
         }
     } else {
         // change with get all times except on content or root,
         // because in root user must change language with subdomain
         if (isset($_GET["lang"])) {
             router::set_storage('language', $_GET["lang"]);
         } elseif (isset($_COOKIE["lang"])) {
             router::set_storage('language', $_COOKIE["lang"]);
         }
         // save language preference for future page requests
         setcookie('lang', router::get_storage('language'), time() + 30 * 24 * 60 * 60, '/', '.' . Service);
     }
     // check direction of language and set for rtl languages
     switch (router::get_storage('language')) {
         case 'fa_IR':
         case 'ar_SU':
             router::set_storage('direction', 'rtl');
             break;
         default:
             router::set_storage('direction', 'ltr');
             break;
     }
     return router::get_storage('language');
 }
Beispiel #6
0
 /**
  * [twig_function_breadcrumb description]
  * @return [type] [description]
  */
 public function twig_function_breadcrumb()
 {
     return new \Twig_SimpleFunction('breadcrumb', function ($_path = null, $_direct = null, $_homepage = true) {
         // if user dont pass a path give it from controller
         if (!$_path) {
             $myurl = $this->model()->breadcrumb();
             $_path = $this->url('breadcrumb');
         }
         $direct = null;
         if ($_direct === true) {
             $direct = "data-direct";
         }
         $currentUrl = null;
         $result = '';
         if ($_homepage || count($myurl)) {
             if (\lib\router::get_repository_name() === 'content') {
                 $result = '<a href="/" tabindex="-1" ' . $direct . '><i class="fa fa-home"></i> ' . T_('Homepage') . '</a>';
             } else {
                 $result = '<a href="/" tabindex="-1" ' . $direct . '><i class="fa fa-home"></i> ' . T_('Home') . '</a>';
             }
         }
         foreach ($myurl as $key => $part) {
             $currentUrl .= $_path[$key] . '/';
             $location = T_(ucfirst($part));
             if (end($myurl) === $part) {
                 $result .= "<a>{$location}</a>";
             } else {
                 $baseURL = $this->data->url->base;
                 $anchorUrl = trim($baseURL . $currentUrl, '/');
                 $result .= "<a href='{$anchorUrl}' tabindex='-1'>{$location}</a>";
             }
         }
         echo $result;
     });
 }