/**
  * Singleton pattern. Get the instance of the latest created object or create a new one. 
  * @return CBehovsboboxen The instance of this class.
  */
 public static function Instance()
 {
     if (self::$instance == null) {
         self::$instance = new CBehovsboboxen();
     }
     return self::$instance;
 }
 /**
  * Set the title of the page.
  *
  * @param $value string to be set as title.
  */
 public function SetTitle($value)
 {
     $append = CBehovsboboxen::Instance()->config['title_append'];
     $separator = CBehovsboboxen::Instance()->config['title_separator'];
     if ($append) {
         $value .= "{$separator}{$append}";
     }
     return $this->SetVariable('title', $value);
 }
Example #3
0
 /**
  * Constructor
  *
  * @param string name of the element.
  * @param array attributes to set to the element. Default is an empty array.
  */
 public function __construct($name, $attributes = array())
 {
     $this->attributes = $attributes;
     $this['name'] = $name;
     $this['key'] = $name;
     $this['name'] = isset($this['name']) ? $this['name'] : $name;
     if (is_callable('CBehovsboboxen::Instance()')) {
         $this->characterEncoding = CBehovsboboxen::Instance()->config['character_encoding'];
     } else {
         $this->characterEncoding = 'UTF-8';
     }
 }
Example #4
0
/**
 *
 * Simplified translation with datastored list (CMTranslate)
 */
function t($str, $args = array())
{
    $trans = $str;
    if (CBehovsboboxen::Instance()->config['language'] == 'sv_SE') {
        $texts = CBehovsboboxen::Instance()->GetTranslations();
        foreach ($texts as $key => $val) {
            if (trim($texts[$key]['eng']) == trim($str)) {
                $trans = trim($texts[$key]['swe']);
                break;
            }
        }
    }
    return $trans;
}
Example #5
0
 /**
  * Constructor, can be instantiated by sending in the $bbb reference.
  */
 protected function __construct($bbb = null)
 {
     if (!$bbb) {
         $bbb = CBehovsboboxen::Instance();
     }
     $this->bbb =& $bbb;
     $this->config =& $bbb->config;
     $this->request =& $bbb->request;
     $this->data =& $bbb->data;
     $this->db =& $bbb->db;
     $this->views =& $bbb->views;
     $this->session =& $bbb->session;
     $this->user =& $bbb->user;
     $this->temperatures =& $bbb->temperatures;
     $this->textfiles =& $bbb->textfiles;
     $this->translate =& $bbb->translate;
 }
Example #6
0
/**
 * Prepend the static_url to url, static_url is the url to a cookie-less domain for assets like 
 * img, css and js-files.
 *
 * @param $url string the url-part to prepend.
 * @return string the absolute url.
 */
function static_url($url)
{
    return CBehovsboboxen::Instance()->PrependUrl('static_url', $url);
}
Example #7
0
 /**
  * Create password.
  *
  * @param $plain string the password plain text to use as base.
  * @param $algorithm string stating what algorithm to use, plain, md5, md5salt, sha1, sha1salt. 
  * defaults to the settings of site/config.php.
  * @returns array with 'salt' and 'password'.
  */
 public function CreatePassword($plain, $algorithm = null)
 {
     $password = array('algorithm' => $algorithm ? $algorithm : CBehovsboboxen::Instance()->config['hashing_algorithm'], 'salt' => null);
     switch ($password['algorithm']) {
         case 'sha1salt':
             $password['salt'] = sha1(microtime());
             $password['password'] = sha1($password['salt'] . $plain);
             break;
         case 'md5salt':
             $password['salt'] = md5(microtime());
             $password['password'] = md5($password['salt'] . $plain);
             break;
         case 'sha1':
             $password['password'] = sha1($plain);
             break;
         case 'md5':
             $password['password'] = md5($plain);
             break;
         case 'plain':
             $password['password'] = $plain;
             break;
         default:
             throw new Exception('Unknown hashing algorithm');
     }
     return $password;
 }
Example #8
0
<?php

/**
 * All requests routed through here. This is an overview of what actaully happens during
 * a request.
 *
 * @package BehovsboboxenCore
 */
// ---------------------------------------------------------------------------------------
//
// PHASE: INIT
//
define('BEHOVSBOBOXEN_INSTALL_PATH', dirname(__FILE__));
define('BEHOVSBOBOXEN_APPLICATION_PATH', BEHOVSBOBOXEN_INSTALL_PATH . '/application');
require BEHOVSBOBOXEN_INSTALL_PATH . '/src/bootstrap.php';
$bbb = CBehovsboboxen::Instance()->Init();
/* ---------------------------------------------------------------------------------------
//
// PHASE: FRONTCONTROLLER ROUTE
*/
CBehovsboboxen::Instance()->FrontControllerRoute();
/*---------------------------------------------------------------------------------------
//
// PHASE: THEME ENGINE RENDER
*/
CBehovsboboxen::Instance()->ThemeEngineRender();