protected function loadFields()
 {
     if (!is_array($this->fields)) {
         $cache = Core::getObject('Core.Cache.CacheServer')->load('fields');
         $this->fields = $cache->getFields($this->getClassPath());
     }
 }
 public static function checkACL($gid, $right)
 {
     $cache = Core::getObject('Core.Cache.CacheServer');
     $p = $cache->load('permissions');
     $acl = $p->getPermissions($gid);
     if (isset($acl[$right])) {
         return $acl[$right] == 1;
     } else {
         Core::throwError('No permission with name "' . $right . '" found.', INTERNAL_NOTICE);
         return false;
     }
 }
 public function parse()
 {
     $__debug = Core::getObject('Core.System.Debug');
     $__debug->startClock($this->file);
     extract($this->vars, EXTR_SKIP);
     ob_start();
     include $this->file;
     $contents = ob_get_contents();
     ob_end_clean();
     $this->time = $__debug->stopClock($this->file);
     return $contents;
 }
/**
 * Loads the required classes automatically from ClassManager (only indexed classes).
 *
 * @param string Class Name
 */
function __autoload($className)
{
    if ($className === 'parent') {
        // Avoid calling parent when using callback function.
        // See: http://www.php.net/manual/de/function.call-user-func.php#106391
        return;
    }
    $classManager = Core::getObject('Core.System.ClassManager');
    if (Config::get('core.debug')) {
        Core::throwError("Autoloaded class with name '{$className}'", INTERNAL_DEBUG);
    }
    $file = $classManager->loadFile($className);
    if ($file == null) {
        Core::throwError('Class "{$className}" not found', INTERNAL_ERROR);
    }
}
 public function __construct($package = 'Cms')
 {
     parent::__construct($package);
     $cache = Core::getObject('Core.Cache.CacheServer');
     $cache->setSourceDir('Cms.Cache.Items');
     // URL => content for media-attribute
     $this->cssFiles = array(URI::build('client/styles/stylesheet.css') => 'all');
     // URL => content for type-attribute
     $cdn = Config::get('ui.jquery_cdn');
     $this->scriptFiles = array(URI::build($cdn ? $cdn : 'client/scripts/jquery/jquery.js') => 'text/javascript', URI::build('client/scripts/jquery/jquery.plugins.js') => 'text/javascript');
     // Html to be placed into the head tag of the page (at last)
     $this->headHtml = array();
     Session::getObject();
     // Init session
     $this->breadcrumb = new Breadcrumb();
     $this->breadcrumb->add(Config::get('general.title'), URI::frontPage());
 }
Ejemplo n.º 6
0
 protected function loadACL()
 {
     if ($this->acl === null) {
         $cache = Core::getObject('Core.Cache.CacheServer');
         $p = $cache->load('permissions');
         $this->acl = $p->getPermissions($this->getGroupId());
     }
 }
 /**
  * Checks whether a password is strong (true) enough or not (false).
  *
  * @param string $pw Password
  * @return boolean
  */
 public static function checkPassword($pw)
 {
     $pwo = Core::getObject('Core.Security.Password');
     $quality = $pwo->check($pw);
     $min_quality = Config::get('security.pwcheck');
     return $quality >= $min_quality;
 }
/**
 * Short form for Core::getObject().
 *
 * During implementation we tried several short forms and decided to take the last one:
 * <code>
 * Core::_(DB)->query("SQL");	// This is ugly
 * Core::DB()->query("SQL");	// Ok, but slow (see php manual)
 * Core::DB('query', "SQL");	// Alternative for the above
 * Core::$DB->query("SQL");		// Not possible in PHP 5.3 (__getStatic, __setStatic), maybe
 *								// introduced in PHP 6, then the best option!
 * Core(DB)->query("SQL");		// Short, fast, but not really oop. Seems to be the best one...
 * </code>
 *
 * @param	string|int	Stored name of object as string or constant (internally that's an int)
 * @return	Object		Stored object of a class
 * @see Core::getObject()
 */
function Core($objectConst) {
	return Core::getObject($objectConst);
}
 public function getPkName()
 {
     if ($this->pk == null) {
         list($table, ) = explode('.', $this->params['source']);
         $cache = Core::getObject('Core.Cache.CacheServer')->load('field_pk');
         $this->pk = $cache->getPk($table);
     }
     return $this->pk;
 }
 protected function invalidateCache()
 {
     $server = Core::getObject('Core.Cache.CacheServer');
     if ($server != null) {
         $cache = $server->load('fields');
         if ($cache != null) {
             $cache->delete();
         }
     }
 }
 /**
  * Destructs the ModuleObject.
  */
 public function __destruct()
 {
     Core::destruct();
     $debug = Core::getObject('Core.System.Debug');
     $debug->stopClock($this->module);
 }
Ejemplo n.º 12
0
 /**
  * Triggers an error message.
  *
  * The constants INTERNAL_ERROR (8), INTERNAL_WARNING (4), INTERNAL_NOTICE (2) and INTERNAL_DEBUG (0) can be used for the second parameter.
  * Default value for the second parameter is INTERNAL_WARNING (4).
  * INTERNAL_DEBUG does not throw any message to the user, it only adds the message to the log file.
  *
  * @param string Error message
  * @param int Error reporting level
  **/
 public static function throwError($error, $warning = INTERNAL_WARNING)
 {
     $line = __LINE__;
     $file = __FILE__;
     if (function_exists('debug_backtrace') == true) {
         $backtraceInfo = debug_backtrace();
         if (isset($backtraceInfo[0]) == true) {
             $file = $backtraceInfo[0]["file"];
             $line = $backtraceInfo[0]["line"];
         }
     }
     if ($warning == INTERNAL_ERROR) {
         $warning = E_USER_ERROR;
     } elseif ($warning == INTERNAL_NOTICE) {
         $warning = E_USER_NOTICE;
     } elseif ($warning == INTERNAL_DEBUG) {
     } else {
         $warning = E_USER_WARNING;
     }
     if ($warning != INTERNAL_DEBUG) {
         $errorHandler = Core::getObject('Core.System.ErrorHandling');
         $errorHandler->errorHandler($warning, $error, $file, $line);
     } else {
         $debug = Core::getObject('Core.System.Debug');
         $debug->add($error);
     }
 }
 /**
  * Deletes the index cache.
  *
  * @access	private
  */
 private function deleteIndex()
 {
     $cache = Core::getObject('Core.Cache.CacheServer');
     $classesCache = $cache->load('classes');
     $classesCache->delete();
 }
 public function getGroupId()
 {
     $cache = Core::getObject('Core.Cache.CacheServer');
     $p = $cache->load('permissions');
     return $p->getGuestID();
 }
 protected function overview()
 {
     foreach ($this->getPositions() as $p) {
         $cache = Core::getObject('Core.Cache.CacheServer')->load('fields');
         $tpl = Response::getObject()->appendTemplate("/Cms/admin/fields");
         $tpl->assign("data", $cache->getFields($p), false);
         $tpl->assign('baseUri', $this->getBaseURI());
         $tpl->output();
     }
 }
 /**
  * Writes a error message to the log file internals.log.
  *
  * @see Debug::add()
  * @param string Error that should be saved to the log file.
  */
 private function log($error)
 {
     if (Config::get('core.debug') == 1) {
         $debug = Core::getObject('Core.System.Debug');
         $debug->add($error);
     }
 }