Beispiel #1
0
 protected function __construct($moduleName, $defaults = array())
 {
     $this->name = $moduleName;
     $this->path = $this->isMain() ? AC_PATH_APP : AC_PATH_MODULES . $moduleName . _DS;
     if (!is_dir($this->path)) {
         Ac::log()->fatal($this->path, "Module not found at given path", __FILE__, __LINE__);
     }
     $this->defaults = $defaults;
     $this->setConfig(null, array_merge($defaults, $this->config(null, array())));
     if (is_dir($this->path . "classes")) {
         $files = ac_dir_files($this->path . "classes");
         $this->hasAutoload = count($files) > 1;
     }
     if (is_dir($this->path . "templates")) {
         $this->hasTemplates = true;
     }
     if (is_readable($this->path . "functions.php")) {
         include_once $this->path . "functions.php";
     }
     $theme = $this->config("theme", null);
     if (!empty($theme) && is_dir($this->templatesPath() . $theme)) {
         $this->isMultiTheme = true;
         $this->currentTheme = $theme;
     }
     Ac::trigger('AC_Module_on_create', $this);
     Ac::trigger('AC_Module_on_create_' . $this->name, $this);
 }
Beispiel #2
0
 /**
  *
  * @param string $from Table name
  * @param string $where
  * @param string $limit
  * @return bool
  */
 public function delete($from, $where = null, $limit = null)
 {
     list($_this, $from, $where, $limit) = Ac::trigger(__CLASS__ . "_before_" . __FUNCTION__, array($this, $from, $where, $limit));
     if (!empty($where)) {
         $where = "WHERE ({$where})";
     }
     if (!empty($limit)) {
         $limit = "LIMIT " . $limit;
     }
     $this->exec("DELETE FROM `{$from}` {$where} {$limit}");
     $result = $this->lastRowCount > 0;
     Ac::trigger(__CLASS__ . "_on_" . __FUNCTION__, array($this, $from, $where, $limit, $result));
     return $result;
 }
Beispiel #3
0
 public function call()
 {
     Ac::trigger(__CLASS__ . "_before_" . __FUNCTION__, $this);
     $klass = $this->controller;
     $fn = $this->action;
     $result = null;
     if ($fn == "__index") {
         $validate_fn = "validate_index";
     } elseif ($fn == "__handle") {
         $validate_fn = "validate_handle";
     } else {
         $validate_fn = str_replace("action_", "validate_", $this->action);
     }
     $this->controllerInstance = new $klass();
     $is_valid = false;
     if (!is_callable(array($this->controllerInstance, $fn))) {
         $fn = "__handle";
     }
     if (method_exists($klass, $validate_fn)) {
         if ($this->controllerInstance->{$validate_fn}($this->action)) {
             $is_valid = true;
             $result = $this->controllerInstance->{$fn}();
         } else {
             $result = $this->controllerInstance->__handle();
         }
     } else {
         if ($this->controllerInstance->__validate($this->action)) {
             $is_valid = true;
             $result = $this->controllerInstance->{$fn}();
         } else {
             $result = $this->controllerInstance->__handle();
         }
     }
     $result = Ac::trigger(__CLASS__ . "_on_" . __FUNCTION__, $result);
     return $result;
 }
Beispiel #4
0
 public function getConfig()
 {
     if (empty($this->config)) {
         $this->config = Ac::trigger("AcImportConfig", array_merge(array("modules.config" => array(), "modules.autoload" => array(), "http.default_format" => "html", "views.class" => "Ac_View", "router.default_controller" => "index", "router.on_index" => "error", "log.enabled" => true, "log.class" => "Ac_Log_File", "cache.enabled" => false, "cache.class" => "Ac_Storage_Cache_File", "cache.path" => AC_PATH_APP . "cache" . _DS, "key.names" => array(), "server.default_mimetype" => "text/html", "server.default_charset" => "UTF-8", "server.locale" => "en_US.UTF8", "server.timezone" => "UTC", "server.memory_limit" => "180M", "server.max_execution_time" => 60, "server.max_input_time" => -1, "server.post_max_size" => "24M", "server.upload_max_file_size" => "16M", "server.display_errors" => true, "server.error_reporting" => -1, "server.error_log_file" => AC_PATH_LOGS . 'php_errors.log', "session.sessid_lifetime" => 180, "session.cookie_path" => preg_replace('/\\/index\\.php.*/', '/', $_SERVER["SCRIPT_NAME"]), "session.cookie_secure" => isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on", "session.cookie_lifetime" => 0, "session.gc_maxlifetime" => 1440, "session.cache_expire" => 180, "session.cache_limiter" => "nocache"), include AC_PATH_APP . "config.php"));
     }
     return $this->config;
 }