public function __construct()
 {
     /*
      * Sets $loginStatus result of the authorization check.
      **/
     $this->loginStatus = LoginStatus::getLoginStatus();
     $this->registry = Registry::getInstance();
     $request = $this->registry->getObject('request');
     /*
      * Contains $_POST
      * */
     $this->post_data = $request->getPostData();
 }
Example #2
0
 /**
  * API Controller Constructor
  * @param Registry $registry the registry
  * @param boolean $directCall
  * @return void
  */
 public function __construct(Registry $registry, $directCall = true)
 {
     $this->registry = $registry;
     $apiController = $registry->getObject('url')->getURLBit(1);
     $this->delegateControl($apiController);
 }
Example #3
0
 public function loadAdminController(Registry $registry, $controller)
 {
     $adminControllers = array();
     $queryStr = "SELECT * FROM controllers_admin WHERE active = 1";
     $registry->getObject('db')->execute($queryStr);
     while ($adctrl = $registry->getObject('db')->getRows()) {
         $adminControllers[] = $adctrl['controller'];
     }
     if (isset($controller) && is_string($controller) && in_array($controller, $adminControllers)) {
         require_once 'protected/admin/controllers/' . ucfirst($controller) . 'Controller.php';
         $controllerInc = ucfirst($controller) . 'Controller';
         $controller = new $controllerInc($registry);
         return $controller;
     } else {
         $registry->redirectTo();
     }
 }
Example #4
0
$controller = $registry->getObject('url')->getURLBit(0);
if ($controller != 'api') {
    $registry->getObject('authenticate')->checkForAuthentication();
}
// store settings in our registry
$settingsSQL = "SELECT `key`, `value` FROM settings";
$registry->getObject('db')->executeQuery($settingsSQL);
while ($setting = $registry->getObject('db')->getRows()) {
    $registry->storeSetting($setting['value'], $setting['key']);
}
$registry->getObject('template')->getPage()->addTag('siteurl', $registry->getSetting('siteurl'));
$registry->getObject('template')->buildFromTemplates('header.tpl.php', 'main.tpl.php', 'footer.tpl.php');
$controllers = array();
$controllersSQL = "SELECT * FROM controllers WHERE active=1";
$registry->getObject('db')->executeQuery($controllersSQL);
while ($cttrlr = $registry->getObject('db')->getRows()) {
    $controllers[] = $cttrlr['controller'];
}
if ($registry->getObject('authenticate')->isLoggedIn() && $controller != 'api') {
    $registry->getObject('template')->addTemplateBit('userbar', 'userbar_loggedin.tpl.php');
    $registry->getObject('template')->getPage()->addTag('username', $registry->getObject('authenticate')->getUser()->getUsername());
} elseif ($controller != 'api') {
    $registry->getObject('template')->addTemplateBit('userbar', 'userbar.tpl.php');
}
if (in_array($controller, $controllers)) {
    require_once FRAMEWORK_PATH . 'controllers/' . $controller . '/controller.php';
    $controllerInc = $controller . 'controller';
    $controller = new $controllerInc($registry, true);
} else {
    // default controller, or pass control to CMS type system?
}
$registry->getObject('template')->parseOutput();
Example #5
0
    $registry->getObject('template')->username = $registry->getObject('session')->get('firstName');
    $registry->getObject('template')->loggedIn = $registry->getModel('authenticate')->isLoggedIn();
}
// loads list of categories for sidebar menu
// limits display on 12 categories randomly ordered
$registry->getObject('template')->sidebarCategories = $registry->getModel('categories')->categoriesForSidebar();
// loads list of authors for sidebar menu
// limit display on 12 authors randomly ordered
$registry->getObject('template')->sidebarAuthors = $registry->getModel('authors')->authorsForSidebar();
// loads 4 new released products for main header slider
$registry->getObject('template')->newProducts = $registry->getModel('products')->selectNewReleases();
// loads list of categories for making SEO URL with hyphens
$categories = $registry->getModel('categories')->selectCategoriesForUrl();
$registry->getObject('template')->urlCategories = $registry->getObject('url')->makeUrlFromData($categories, 'category');
// loads list of authors for making SEO URL with hyphens
$authors = $registry->getModel('authors')->selectAuthorsForUrl();
$registry->getObject('template')->urlAuthors = $registry->getObject('url')->makeUrlFromData($authors, 'authorName');
// loads list of products for making SEO URL with hyphens
$products = $registry->getModel('products')->selectProductsForUrl();
$registry->getObject('template')->urlProducts = $registry->getObject('url')->makeUrlFromMultipleData($products, ['book_id', 'title']);
// checking if flash messages exists
$registry->getObject('template')->flashMessage = $registry->getObject('session')->checkFlashMessage('message');
$registry->getObject('template')->rateMessage = $registry->getObject('session')->checkFlashMessage('rate');
$registry->getObject('template')->reviewMessage = $registry->getObject('session')->checkFlashMessage('review');
$registry->getObject('template')->voucherNotice = $registry->getObject('session')->checkFlashMessage('voucherNotice');
$registry->getObject('template')->reviewHelpful = $registry->getObject('session')->checkFlashMessage('reviewHelpful');
// dealing with small basket in the header
if ($registry->getModel('basket')->isChecked() == false) {
    $registry->getModel('basket')->checkBasket();
}
if ($registry->getModel('basket')->isEmpty() == false) {
    $registry->getObject('template')->itemsNumber = $registry->getModel('basket')->getNumProducts();
Example #6
0
 $registry->setObject('authentication', 'authenticate');
 $registry->setObject('urlProcessor', 'url');
 $registry->getObject('url')->getURLData();
 //Settings
 include 'config.php';
 //create a database connection
 $registry->getObject('db')->newConnection($configs['db_host_sn'], $configs['db_user_sn'], $configs['db_pass_sn'], $configs['db_name_sn']);
 // store settings in our registry
 $settingsSQL = "SELECT `key`, `value` FROM settings";
 $registry->getObject('db')->executeQuery($settingsSQL);
 while ($setting = $registry->getObject('db')->getRows()) {
     $registry->setSetting($setting['value'], $setting['key']);
 }
 //var_dump(session_status());
 //header('location: /geoboxx/social2/index.php');
 //Check if logged in
 $registry->getObject('authenticate')->checkForAuthentication();
 //The homepage for the network
 $registry->getObject('template')->getPage()->addTag('sitename', $registry->getSetting('sitename'));
 $registry->getObject('template')->getPage()->addTag('baseurl', $registry->getSetting('baseurl'));
 $registry->getObject('template')->getPage()->addTag('siteurl', $registry->getSetting('siteurl'));
 $registry->getObject('template')->buildFromTemplate('header.php', 'main.php', 'footer.php');
 $controllers = array();
 $controllerSQL = "SELECT * FROM controllers WHERE active=1";
 $registry->getObject('db')->executeQuery($controllerSQL);
 while ($control = $registry->getObject('db')->getRows()) {
     $controllers[] = $control['controller'];
 }
 $controller = $registry->getObject('url')->getURLBit(0);
 if (in_array($controller, $controllers)) {
     control($controller, $registry);
Example #7
0
<?php

session_start();
DEFINE("FRAMEWORK_PATH", dirname(__FILE__) . "/");
require 'registry/registry.class.php';
$registry = new Registry();
// setup our core registry objects
$registry->createAndStoreObject('template', 'template');
$registry->createAndStoreObject('mysqldb', 'db');
//$registry->createAndStoreObject( 'authenticate', 'authenticate' );
$registry->createAndStoreObject('urlprocessor', 'url');
// database settings
include FRAMEWORK_PATH . 'config.php';
// create a database connection
$registry->getObject('db')->newConnection($configs['db_host_sn'], $configs['db_user_sn'], $configs['db_pass_sn'], $configs['db_name_sn']);
// store settings in our registry
$settingsSQL = "SELECT `key`, `value` FROM settings";
$registry->getObject('db')->executeQuery($settingsSQL);
while ($setting = $registry->getObject('db')->getRows()) {
    $registry->storeSetting($setting['value'], $setting['key']);
}
// process authentication
// coming in chapter 3
/**
 * Once we have some template files, we can build a default template
$registry->getObject('template')->buildFromTemplates('header.tpl.php', 'main.tpl.php', 'footer.tpl.php');

$registry->getObject('template')->parseOutput();
print $registry->getObject('template')->getPage()->getContentToPrint();
*/