Ejemplo n.º 1
0
 /**
  * constructor
  * @param boolean $object controller
  */
 public function __construct($object = false)
 {
     if (!$object) {
         return;
     }
     $this->controller = $object->controller;
     $this->data = new view\data();
     $this->data->url = object();
     $this->data->include = object();
     $this->data->global = object();
     $this->url = $this->data->url;
     $this->global = $this->data->global;
     $this->include = $this->data->include;
     // default data property
     $this->data->macro['forms'] = 'includes/macro/forms.html';
     $this->data->display['mvc'] = "includes/mvc/display.html";
     $this->data->display['main'] = "content/main/layout.html";
     $this->data->display['home'] = "content/home/display.html";
     $this->data->display['cp'] = "content_cp/home/layout.html";
     $this->data->display['account'] = "content_account/home/layout.html";
     $this->data->template['header'] = 'content/template/header.html';
     $this->data->template['sidebar'] = 'content/template/sidebar.html';
     $this->data->template['footer'] = 'content/template/footer.html';
     $this->data->saloos['version'] = \lib\saloos::getLastVersion();
     $this->data->saloos['lastUpdate'] = \lib\saloos::getLastUpdate();
     $this->data->saloos['langlist'] = ['fa_IR' => 'Persian - فارسی', 'en_US' => 'English', 'ar_SU' => 'Arabic - العربية'];
     $myurl = router::get_protocol() . '://' . router::get_domain() . $_SERVER['REQUEST_URI'];
     if (isset($_SERVER['HTTP_REFERER']) && isset($_SESSION['debug'][md5($_SERVER['HTTP_REFERER'])])) {
         $myurl = $_SERVER['HTTP_REFERER'];
     }
     if (isset($_SESSION['debug'][md5($myurl)])) {
         $this->data->debug = $_SESSION['debug'][md5($myurl)];
         // if(isset($_SESSION['debug'][md5($myurl)]['show']))
         unset($_SESSION['debug'][md5($myurl)]);
         // else
         // $_SESSION['debug'][md5($myurl)]['show'] = true;
     }
     if (method_exists($this, 'mvc_construct')) {
         $this->mvc_construct();
     }
 }
Ejemplo n.º 2
0
 public function config()
 {
     // $this->data->list             = $this->cpModlueList('all');
     $this->data->bodyclass = 'fixed unselectable';
     $this->include->css = false;
     $this->include->js = false;
     $this->include->fontawesome = true;
     $this->include->datatable = true;
     $this->include->chart = true;
     $this->include->introjs = true;
     $this->include->lightbox = true;
     $this->include->editor = true;
     $this->include->cp = true;
     $this->include->uploader = true;
     $this->global->js = array();
     $this->data->display['cp_posts'] = "content_cp/posts/layout.html";
     $this->data->saloos['version'] = \lib\saloos::getLastVersion();
     $this->data->saloos['lastUpdate'] = \lib\saloos::getLastUpdate();
     $this->data->saloos['langlist'] = ['fa_IR' => 'Persian - فارسی', 'en_US' => 'English', 'ar_SU' => 'Arabic - العربية'];
     $this->data->modules = $this->controller::$manifest['modules']->get_modules();
     // $this->global->js             = [$this->url->myStatic.'js/highcharts/highcharts.js'];
     // $this->data->page['desc']  = 'salam';
     $mymodule = $this->module();
     $this->data->page['desc'] = $this->controller::$manifest['modules']->get_modules($mymodule, "desc");
     $this->data->page['title'] = $this->controller::$manifest['modules']->get_modules($mymodule, "title");
     $this->data->page['haschild'] = $this->controller::$manifest['modules']->get_modules($mymodule, "childless") ? false : true;
     $this->data->page['title'] = T_(ucfirst(\lib\router::get_url(' ')));
     $this->data->cpModule = $this->cpModule();
     $this->data->dir['right'] = $this->global->direction == 'rtl' ? 'left' : 'right';
     $this->data->dir['left'] = $this->global->direction == 'rtl' ? 'right' : 'left';
     switch ($mymodule) {
         case 'visitors':
             if (\lib\utility\option::get('config', 'meta', 'logVisitors')) {
                 // create for chart
                 $type = \lib\utility::get('type');
                 $utype = \lib\utility::get('utype');
                 $stype = \lib\utility::get('stype');
                 $atype = \lib\utility::get('atype');
                 $this->data->chart_type = $type ? $type : 'column';
                 $this->data->chart_unique_type = $utype ? $utype : 'areaspline';
                 $this->data->chart_signup_type = $stype ? $stype : 'areaspline';
                 $this->data->chart_answered_type = $atype ? $atype : 'column';
                 // $this->data->visitors               = $this->model()->visitors();
                 // $this->data->visitors_unique        = $this->model()->visitors(true);
                 $this->data->visitors = \lib\utility\visitor::chart();
                 $this->data->visitors_unique = \lib\utility\visitor::chart(true);
                 // get period of signup from user
                 $this->data->period = \lib\utility::get('period');
                 switch ($this->data->period) {
                     case 'year':
                         $period = "%Y";
                         break;
                     case 'month':
                         $period = "%Y-%m";
                         break;
                     case 'week':
                         $period = "%Y " . T_('week') . "%V";
                         break;
                     case 'day':
                     default:
                         $period = "%Y-%m-%d";
                         break;
                 }
                 $this->data->signup = \lib\db\chart\users::signup($period);
                 if (class_exists('\\lib\\db\\chart\\polls')) {
                     $this->data->answered = \lib\db\chart\polls::answeredCount($period);
                 }
                 if ($this->data->visitors <= 1) {
                     $this->data->error = T_("Chart must be contain at least 2 column!");
                 }
             }
             break;
         case 'home':
             $this->data->countOf['posts'] = $this->model()->countOf('posts');
             $this->data->countOf['pages'] = $this->model()->countOf('pages');
             $this->data->countOf['attachments'] = $this->model()->countOf('attachments');
             $this->data->countOf['books'] = $this->model()->countOf('books');
             $this->data->countOf['tags'] = $this->model()->countOf('tags');
             $this->data->countOf['categories'] = $this->model()->countOf('categories');
             $this->data->countOf['users'] = $this->model()->countOf('users');
             $this->data->bodyclass .= ' unselectable';
             // check visitor is new or not
             $this->data->visitor_new = false;
             $ref = \lib\router::urlParser('referer', 'sub');
             if ($ref !== 'cp' && $ref !== null) {
                 $this->data->visitor_new = true;
             }
             if (\lib\utility\option::get('config', 'meta', 'logVisitors')) {
                 // create for chart
                 $this->data->chart_type = 'column';
                 $this->data->visitors = \lib\utility\visitor::chart();
                 $this->data->visitors_toppages = \lib\utility\visitor::top_pages(15);
                 if ($this->data->visitors <= 1) {
                     $this->data->error = T_("Chart must be contain at least 2 column!");
                 }
             }
             break;
         default:
             # code...
             break;
     }
     if ($this->data->page['haschild']) {
         // Check permission and if user can do this operation
         // allow to do it, else show related message in notify center
         $myResult = $this->access('cp', $mymodule, 'add');
         $this->data->page['haschild'] = $myResult ? true : false;
     }
     // $f = array_keys($this->controller::modules_hasnot('disable'));
     // $feature = [];
     // foreach ($f as $key => $value) {
     // 	$feature[$value] = true;
     // }
     // $this->data->site['title']  = T_('Control Panel'). ' - ' . $this->data->site['title'];
 }