set() public static méthode

public static set ( $key, $value )
Exemple #1
0
 /**
  * @param string $id
  * @param core_libs $this
  */
 function set($id, $lib = null)
 {
     if ($lib && is_object($lib) && !$lib instanceof Closure) {
         $this->_resolved($id, $lib);
     }
     return parent::set($id, $lib);
 }
 public function __construct($controller, $action)
 {
     if (isset($_POST['log_out_btn'])) {
         $this->logOut();
         header('Location: ' . SITE_DIR);
         exit;
     }
     if (isset($_POST['login_btn'])) {
         if ($this->auth($_POST['email'], md5($_POST['password']), $_POST['remember'])) {
             header('Location: ' . SITE_DIR);
         } else {
             $this->render('error', true);
         }
     }
     registry::set('log', array());
     $this->controller_name = $controller;
     $this->check_auth = $this->checkAuth();
     if ($this->check_auth) {
         //            $this->sidebar();
     }
     $this->action_name = $action . ($this->check_auth ? '_na' : '');
     $config = [];
     foreach ($this->model('asanatt_system_config')->getAll() as $v) {
         $config[$v['config_key']] = $v['config_value'];
     }
     registry::set('config', $config);
 }
 public function index()
 {
     $dates = $this->dates();
     $users = [];
     foreach ($this->model('asanatt_user_mapping')->getAll() as $user) {
         $users[$user['id']] = $user;
     }
     registry::set('users', $users);
     $date_range = [];
     for ($i = strtotime($dates['date_from']); $i <= strtotime($dates['date_to']); $i = $i + 3600 * 24) {
         $date_range[] = date('Y-m-d', $i);
     }
     $this->render('date_from', $dates['date_from']);
     $this->render('date_to', $dates['date_to']);
     $this->render('dates', $date_range);
     $this->render('users_list', $this->model('asanatt_user_mapping')->getAll('user_name'));
     if (empty($_POST['user'])) {
         $this->render('users', $this->model('asanatt_user_mapping')->getAll('user_name'));
     } else {
         $this->render('users', $this->model('asanatt_user_mapping')->getByField('id', $_POST['user'], true));
     }
     $this->render('late', $this->model('asanatt_excel_time')->getLateEmployees($dates));
     $this->render('absent', $this->model('asanatt_excel_time')->getAbsentEmployees($dates));
     $this->render('early', $this->model('asanatt_excel_time')->getEarlyFinished($dates));
     $this->render('less_worked', $this->model('asanatt_excel_time')->getLessWorked($dates));
     $this->render('overtime', $this->model('asanatt_excel_time')->getOvertime($dates));
     $this->view('summary' . DS . 'index');
 }
 protected function render($key, $value)
 {
     $common_vars = registry::get('common_vars');
     if (!$common_vars) {
         $common_vars = [];
     }
     $common_vars[$key] = $value;
     registry::set('common_vars', $common_vars);
 }
Exemple #5
0
 /**
  * @param string $key
  * @return string
  */
 protected function getConfig($key)
 {
     if (!$key) {
         return false;
     }
     if (!($value = registry::get('config')[$key])) {
         $config = registry::get('config');
         $config[$key] = $this->model('system_config')->getByField('config_key', $key)['config_value'];
         registry::remove('config');
         registry::set('config', $key);
         return $config[$key];
     } else {
         return $value;
     }
 }
Exemple #6
0
 /**
  * @param string $model
  * @param null/string $table
  * @param null/string $db
  * @param null/string $user
  * @param null/string $password
  * @return model
  */
 protected function model($model, $table = null, $db = null, $user = null, $password = null)
 {
     $models = registry::get('models');
     if (!($m = $models[$model][$table])) {
         $model_file = ROOT_DIR . 'models' . DS . $model . '_model.php';
         if (file_exists($model_file)) {
             $model_class = $model . '_model';
             $m = new $model_class($table ? $table : $model, $db, $user, $password);
         } else {
             $m = new default_model($model);
         }
         $models[$model][$table] = $m;
         registry::remove('models');
         registry::set('models', $models);
     }
     return $m;
 }
Exemple #7
0
        if (!$_REQUEST['common']) {
            if (is_callable($controller->{$ajax_action}())) {
                $controller->{$ajax_action}();
            }
        } else {
            if (is_callable($common_controller->index_ajax())) {
                $controller->index_ajax();
            }
        }
    } elseif (method_exists($controller, 'catcher_ajax')) {
        if (!$_REQUEST['common']) {
            if (is_callable($controller->catcher_ajax())) {
                $controller->{$ajax_action}();
            }
        } else {
            if (is_callable($common_controller->catcher_ajax())) {
                $controller->catcher_ajax();
            }
        }
    }
}
$common_controller->index();
if (method_exists($controller, $action)) {
    registry::set('action', $action);
    $controller->{$action}();
} elseif (method_exists($controller, 'catcher')) {
    $controller->catcher(str_replace('_na', '', $action));
} else {
    $controller->default_action();
    registry::set('action', 'four_o_four');
}
Exemple #8
0
 /**
  * @param mixed $value
  */
 protected function log($value)
 {
     $log = registry::get('log');
     registry::remove('log');
     $log[] = print_r($value, 1);
     registry::set('log', $log);
 }
Exemple #9
0
 protected function api()
 {
     if (!($api = registry::get('asana_api'))) {
         $api = new api_class();
         registry::set('asana_api', $api);
     }
     return $api;
 }
Exemple #10
0
 function controller_before()
 {
     $menu = $this->go_deeper();
     registry::set('menu', $menu);
 }
Exemple #11
0
define("CONFIG_PATH", SITE_PATH . DIRSEP . "config");
define("CORE_PATH", SITE_PATH . DIRSEP . "core");
define("HOST", $_SERVER["HTTP_HOST"]);
define("DEBUG", 1);
# If this is set to 1, searching will far faster but less det
# -ailed. (Using mysql full text natural searching). This for
# if there are many articles.
define("QUICK_SEARCH", 0);
function __autoload($class_name)
{
    if (strtolower(substr($class_name, 0, 5)) == "model" && strtolower($class_name) != "model") {
        $class_path = SITE_PATH . "models";
        $class_name = substr($class_name, 5);
    } else {
        $class_path = CORE_PATH;
    }
    $filename = str_replace("_", DIRSEP, strtolower($class_name)) . '.php';
    if (file_exists($class_path . DIRSEP . $filename)) {
        include $class_path . DIRSEP . $filename;
    } else {
        die("Could not find " . $class_path . DIRSEP . $filename . "!\n");
        return false;
    }
}
# System happening
$registry = new registry();
# Load router
$router = new router($registry);
$registry->set('router', $router);
$router->set_path(SITE_PATH . 'controllers');
$router->delegate();
Exemple #12
0
} else {
    $controller = 'index';
    $action = 'index';
}
$route_parts[0] = $controller;
$route_parts[1] = $action;
registry::set('route_parts', $route_parts);
$class_name = $controller . '_controller';
if (!file_exists(ROOT_DIR . 'controllers' . DS . $class_name . '.php')) {
    $class_name = 'default_controller';
}
registry::set('controller', $class_name);
$controller = new $class_name($class_name, $action);
$common_controller = new common_controller($class_name, $action);
$common_controller->index();
if (isset($_REQUEST['ajax']) && $_REQUEST['common']) {
    $common_controller->ajax();
}
if (isset($_REQUEST['ajax']) && !$_REQUEST['common']) {
    $ajax_action = $action . '_ajax';
    if (is_callable($controller->{$ajax_action}())) {
        $controller->{$ajax_action}();
    }
}
if (method_exists($controller, $action)) {
    registry::set('action', $action);
    $controller->{$action}();
} else {
    $controller->not_found();
    registry::set('action', 'not_found');
}