示例#1
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'];
 }