Exemplo 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();
     }
 }
Exemplo n.º 2
0
 public function _corridor()
 {
     if (method_exists($this, 'corridor')) {
         $this->corridor();
     }
     if (!$this->method) {
         $this->method = 'get';
     }
     $processor_arg = false;
     if (isset($this->model_api_processor)) {
         $name = $this->model_api_processor->method;
         $args = $this->model_api_processor->args;
         $api_callback = call_user_func_array(array($this->model(), $name), array($args));
         $this->api_callback = $api_callback;
     }
     if (saloos::is_json_accept()) {
         $this->display = false;
     }
     if (!\lib\router::get_storage('api') && $this->method == 'get' && $this->display) {
         $this->view();
         if (isset($this->view_api_processor)) {
             $name = $this->view_api_processor->method;
             $args = $this->view_api_processor->args;
             if (isset($this->api_callback)) {
                 $args->api_callback = $api_callback;
             }
             call_user_func_array(array($this->view(), $name), array($args));
         }
         if ($this->display) {
             $this->view()->corridor();
         }
     } elseif (router::get_storage('api') || !$this->display) {
         $mycallback = isset($this->api_callback) ? $this->api_callback : null;
         debug::msg('callback', $mycallback);
         $processor_arg = object(array('force_json' => true));
     }
     if ($this->model) {
         $this->model()->_processor($processor_arg);
     }
 }
Exemplo n.º 3
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'];
 }
Exemplo n.º 4
0
 public function pagnation_error()
 {
     if (!\lib\saloos::is_ajax()) {
         header("HTTP/1.1 404 NOT FOUND");
     }
 }
Exemplo n.º 5
0
 /**
  * [_processor description]
  * @param  boolean $options [description]
  * @return [type]           [description]
  */
 public function _processor($options = false)
 {
     if (is_array($options)) {
         $options = (object) $options;
     }
     $force_json = gettype($options) == 'object' && isset($options->force_json) && $options->force_json ? true : false;
     $force_stop = gettype($options) == 'object' && isset($options->force_stop) && $options->force_stop ? true : false;
     $not_redirect = gettype($options) == 'object' && isset($options->not_redirect) && $options->not_redirect ? true : false;
     if ($not_redirect) {
         $this->controller()->redirector = false;
     }
     if (\saloos::is_json_accept() || $force_json) {
         header('Content-Type: application/json');
         if (isset($this->controller()->redirector) && $this->controller()->redirector) {
             $_SESSION['debug'][md5(strtok($this->redirector()->redirect(true), '?'))] = debug::compile();
             debug::msg("redirect", $this->redirector()->redirect(true));
         }
         echo debug::compile(true);
     } elseif (!\lib\router::get_storage('api') && strtolower($_SERVER['REQUEST_METHOD']) == "post") {
         $this->redirector();
     }
     if (isset($this->controller()->redirector) && $this->controller()->redirector && !\saloos::is_json_accept()) {
         $_SESSION['debug'][md5(strtok($this->redirector()->redirect(true), '?'))] = debug::compile();
         $this->redirector()->redirect();
     }
     if ($force_stop) {
         exit;
     }
 }