예제 #1
0
 function queryEnd($query)
 {
     if (!$this->config['enabled'] || !$this->config['trace_queries']) {
         return;
     }
     ConsolePlugin::Log('Query End', 'no-important', '-');
 }
예제 #2
0
 private function handleGenericError($message, $file, $line, $type)
 {
     if ($this->plugin->isEnabled('Console')) {
         ConsolePlugin::Log($message, $type, null, $type != 'notice', $type == 'notice' ? 4 : 5);
         if ($type == 'error') {
             $this->plugin->Console->finalize();
         }
     } elseif (AppConfig::DEBUG_MODE) {
         $this->show("{$message} ({$file} on line {$line})");
     } else {
         $this->log("{$message} ({$file} on line {$line})", E_ERROR);
     }
 }
예제 #3
0
 /**
  * Creates the cache directory when the init command is used.
  * Needs the console plugin
  *
  * @param array $args
  */
 public static function onConsoleInit($args)
 {
     foreach (Atomik::path(self::$config['dir'], true) as $directory) {
     	/* creates cache directory */
     	ConsolePlugin::mkdir($directory, 1);
     	
     	/* sets permissions to 777 */
     	ConsolePlugin::println('Setting permissions', 2);
     	if (!@chmod($directory, 0777)) {
     		ConsolePlugin::fail();
     	}
     	ConsolePlugin::success();
     }
 }
예제 #4
0
function Console($content, $type = 'info', $context = null, $add_backtrace = false)
{
    ConsolePlugin::Log($content, $type, $context, $add_backtrace, 2);
}
예제 #5
0
    /**
     * Plugin starts
     *
     * @param array $config
     */
    public static function start($config)
    {
    	self::$config = array_merge(self::$config, $config);

		// automatic connection
		if (self::$config['dsn'] !== false) {
			$dsn = self::$config['dsn'];
			$username = self::$config['username'];
			$password = self::$config['password'];
			
			$instance = Atomik_Db::createInstance('default', $dsn, $username, $password);
			$instance->setTablePrefix(self::$config['table_prefix']);
			$instance->enableQueryCache(self::$config['query_cache']);
			$instance->enableResultCache(self::$config['result_cache']);
		}
		
		// adds models directories to php's include path
		$includes = explode(PATH_SEPARATOR, get_include_path());
		foreach (Atomik::path(self::$config['model_dirs'], true) as $dir) {
			if (!in_array($dir, $includes)) {
				array_unshift($includes, $dir);
			}
		}
		set_include_path(implode(PATH_SEPARATOR, $includes));
		
		// registers the db selector namespace
		Atomik::registerSelector('db', array('DbPlugin', 'selector'));
		
		if (Atomik::isPluginLoaded('Console')) {
			ConsolePlugin::register('db-create', array('DbPlugin', 'dbCreateCommand'));
			ConsolePlugin::register('db-create-sql', array('DbPlugin', 'dbCreateSqlCommand'));
		}
    }