Exemplo n.º 1
0
 /**
 * Authenticate and login a user.
 */
 public function Login()
 {
     $form = new CFormUserLogin($this);
     if ($form->Check() === false) {
         $this->AddMessage('notice', 'You must fill in acronym and password.');
         $this->RedirectToController('login');
     }
     $this->views->SetTitle('Login')->AddInclude(__DIR__ . '/login.tpl.php', array('login_form' => $form, 'allow_create_user' => Origin::Instance()->config['create_new_users'], 'create_user_url' => $this->CreateUrl(null, 'create')));
 }
Exemplo n.º 2
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;
     if (is_callable('Origin::Instance()')) {
         $this->characterEncoding = Origin::Instance()->config['character_encoding'];
     } else {
         $this->characterEncoding = 'UTF-8';
     }
 }
Exemplo n.º 3
0
 /**
  * Constructor, can be instantiated by sending in the $ly reference.
  */
 protected function __construct($Origo = null)
 {
     if (!$Origo) {
         $Origo = Origin::Instance();
     }
     $this->Origo =& $Origo;
     $this->config =& $Origo->config;
     $this->request =& $Origo->request;
     $this->data =& $Origo->data;
     $this->db =& $Origo->db;
     $this->views =& $Origo->views;
     $this->session =& $Origo->session;
     $this->user =& $Origo->user;
 }
Exemplo n.º 4
0
    /**
     * Create a method that shows the menu, same for all methods
     */
    private function Menu()
    {
        $Origo = Origin::Instance();
        $menu = array('index', 'index/index', 'developer', 'developer/index', 'developer/links', 'developer/display-object', 'guestbook');
        $html = null;
        foreach ($menu as $val) {
            $html .= "<li><a href='" . $this->request->CreateUrl($val) . "'>{$val}</a>";
        }
        $this->data['title'] = "Developer";
        $this->data['main'] = <<<EOD
\t<h1>The Developer Controller</h1>
\t<p>This is what you can do for now:</p>
\t<ul>
\t{$html}
\t</ul>
EOD;
    }
Exemplo n.º 5
0
function render_own($region = 'default', $nav = 'site/themes/lingon/meny.tpl.php')
{
    $Origo = Origin::Instance();
    $info = $Origo->config['menus']['lingon'];
    return Origin::Instance()->views->Render($region, $nav, $info);
}
Exemplo n.º 6
0
/**
* Helper, wrap html_entites with correct character encoding
*/
function htmlent($str, $flags = ENT_COMPAT)
{
    return htmlentities($str, $flags, Origin::Instance()->config['character_encoding']);
}
Exemplo n.º 7
0
/**
* Check if region has views. Accepts variable amount of arguments as regions.
*
* @param $region string the region to draw the content in.
*/
function region_has_content($region = 'default')
{
    return Origin::Instance()->views->RegionHasView(func_get_args());
}
Exemplo n.º 8
0
 /**
 * Callback to delete the content.
 */
 public function DoDelete($form, $content)
 {
     $content['id'] = $form['id']['value'];
     $content->Delete();
     Origin::Instance()->RedirectTo('content');
 }
Exemplo n.º 9
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 ? $algoritm : Origin::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;
 }
Exemplo n.º 10
0
<?php

/**
* All requests routed through here. This is an overview of what actaully happens during
* a request.
*
* @package LydiaCore
*/
// ---------------------------------------------------------------------------------------
//
// PHASE: BOOTSTRAP
//
define('LYDIA_INSTALL_PATH', dirname(__FILE__));
define('LYDIA_SITE_PATH', LYDIA_INSTALL_PATH . '/site');
require LYDIA_INSTALL_PATH . '/src/Origin/bootstrap.php';
$Origo = Origin::Instance();
$Origo->a = 1;
// ---------------------------------------------------------------------------------------
//
// PHASE: FRONTCONTROLLER ROUTE
//
$Origo->FrontControllerRoute();
// ---------------------------------------------------------------------------------------
//
// PHASE: THEME ENGINE RENDER
//
$Origo->ThemeEngineRender();