public function __construct() { parent::__construct(); // set tracking cookie FrontendModel::getVisitorId(); // add reference Spoon::set('page', $this); // get pageId for requested URL $this->pageId = FrontendNavigation::getPageId(implode('/', $this->URL->getPages())); // set headers if this is a 404 page if ($this->pageId == 404) { $this->statusCode = 404; } // create breadcrumb instance $this->breadcrumb = new FrontendBreadcrumb(); // create header instance $this->header = new FrontendHeader(); // new footer instance $this->footer = new FrontendFooter(); // get pagecontent $this->getPageContent(); // process page $this->processPage(); // execute all extras linked to the page $this->processExtras(); // store statistics $this->storeStatistics(); // display $this->display(); // trigger event FrontendModel::triggerEvent('core', 'after_page_processed', array('id' => $this->getId(), 'record' => $this->getRecord(), 'statusCode' => $this->getStatusCode(), 'sessionId' => SpoonSession::getSessionId(), 'visitorId' => FrontendModel::getVisitorId(), 'SESSION' => $_SESSION, 'COOKIE' => $_COOKIE, 'GET' => $_GET, 'POST' => $_POST, 'SERVER' => $_SERVER)); }
/** * Returns the CampaignMonitor object * * @param int[optional] $listId The default list id to use. * @return CampaignMonitor */ public static function getCM($listId = null) { // campaignmonitor reference exists if (!Spoon::exists('campaignmonitor')) { // check if the CampaignMonitor class exists if (!SpoonFile::exists(PATH_LIBRARY . '/external/campaignmonitor.php')) { // the class doesn't exist, so throw an exception throw new SpoonFileException('The CampaignMonitor wrapper class is not found. Please locate and place it in /library/external'); } // require CampaignMonitor class require_once 'external/campaignmonitor.php'; // set login data $url = FrontendModel::getModuleSetting('mailmotor', 'cm_url'); $username = FrontendModel::getModuleSetting('mailmotor', 'cm_username'); $password = FrontendModel::getModuleSetting('mailmotor', 'cm_password'); // init CampaignMonitor object $cm = new CampaignMonitor($url, $username, $password, 5, self::getClientId()); // set CampaignMonitor object reference Spoon::set('campaignmonitor', $cm); // get the default list ID $listId = !empty($listId) ? $listId : self::getDefaultListID(); // set the default list ID $cm->setListId($listId); } // return the CampaignMonitor object return Spoon::get('campaignmonitor'); }
public function __construct() { // add to registry Spoon::set('url', $this); $this->setQueryString($_SERVER['REQUEST_URI']); $this->setHost($_SERVER['HTTP_HOST']); $this->processQueryString(); }
public function __construct() { // store in reference so we can access it from everywhere Spoon::set('header', $this); // grab from the reference $this->URL = Spoon::get('url'); $this->tpl = Spoon::get('template'); }
public function testSet() { // set value $value = array('Davy Hellemans', 'Tijs Verkoyen', 'Dave Lens', 'Matthias Mullie'); $this->assertEquals(Spoon::set('salad_fingers', $value), $value); // get rid of value Spoon::set('salad_fingers'); $this->assertFalse(Spoon::exists('salad_fingers')); }
/** * The constructor will store the instance in the reference, preset some settings and map the custom modifiers. * * @param bool[optional] $addToReference Should the instance be added into the reference. */ public function __construct($addToReference = true) { parent::__construct(); if ($addToReference) { Spoon::set('template', $this); } $this->setCacheDirectory(FRONTEND_CACHE_PATH . '/cached_templates'); $this->setCompileDirectory(FRONTEND_CACHE_PATH . '/compiled_templates'); $this->setForceCompile(SPOON_DEBUG); $this->mapCustomModifiers(); }
/** * Default constructor * * @return void */ public function __construct() { // add ourself to the reference so other classes can retrieve us Spoon::set('url', $this); // set query-string for later use $this->setQueryString($_SERVER['REQUEST_URI']); // set host for later use $this->setHost($_SERVER['HTTP_HOST']); // process URL $this->processQueryString(); }
/** * Default constructor * * @return void */ public function __construct() { // add ourself to the reference so other classes can retrieve us Spoon::set('url', $this); // if there is a trailing slash we permanent redirect to the page without slash if (mb_strlen($_SERVER['REQUEST_URI']) != 1 && mb_substr($_SERVER['REQUEST_URI'], -1) == '/') { SpoonHTTP::redirect(mb_substr($_SERVER['REQUEST_URI'], 0, -1), 301); } // set query-string for later use $this->setQueryString($_SERVER['REQUEST_URI']); // set host for later use $this->setHost($_SERVER['HTTP_HOST']); // process URL $this->processQueryString(); // set constant define('SELF', SITE_URL . '/' . $this->queryString); }
/** * Class constructor * The constructor will store the instance in the reference, preset some settings and map the custom modifiers. * * @return void * @param bool[optional] $addToReference Should the instance be added into the reference. */ public function __construct($addToReference = true) { // parent constructor parent::__construct(); // store in reference so we can access it from everywhere if ($addToReference) { Spoon::set('template', $this); } // set cache directory $this->setCacheDirectory(FRONTEND_CACHE_PATH . '/cached_templates'); // set compile directory $this->setCompileDirectory(FRONTEND_CACHE_PATH . '/compiled_templates'); // when debugging the template should be recompiled every time $this->setForceCompile(SPOON_DEBUG); // map custom modifiers $this->mapCustomModifiers(); }
/** * Default constructor * * @return void */ public function __construct() { // call parent parent::__construct(); // add into the reference Spoon::set('breadcrumb', $this); // get more information for the homepage $homeInfo = FrontendNavigation::getPageInfo(1); // add homepage as first item (with correct element) $this->addElement($homeInfo['navigation_title'], FrontendNavigation::getURL(1)); // get other pages $pages = $this->URL->getPages(); // init vars $items = array(); $errorURL = FrontendNavigation::getUrl(404); // loop pages while (!empty($pages)) { // init vars $URL = implode('/', $pages); $menuId = FrontendNavigation::getPageId($URL); $pageInfo = FrontendNavigation::getPageInfo($menuId); // do we know something about the page if ($pageInfo !== false && isset($pageInfo['navigation_title'])) { // only add pages that aren't direct actions if ($pageInfo['tree_type'] != 'direct_action') { // get URL $pageURL = FrontendNavigation::getUrl($menuId); // if this is the error-page, so we won't show an URL. if ($pageURL == $errorURL) { $pageURL = null; } // add to the items $items[] = array('title' => $pageInfo['navigation_title'], 'url' => $pageURL); } } // remove element array_pop($pages); } // reverse so everything is in place krsort($items); // loop and add elements foreach ($items as $row) { $this->addElement($row['title'], $row['url']); } }
/** * Default constructor * * @return void */ public function __construct() { // call the parent parent::__construct(); // store in reference Spoon::set('header', $this); // add some default CSS files $this->addCSS('/frontend/core/layout/css/jquery_ui/jquery_ui.css'); $this->addCSS('/frontend/core/layout/css/screen.css'); // debug stylesheet if (SPOON_DEBUG) { $this->addCSS('/frontend/core/layout/css/debug.css'); } // add default javascript-files $this->addJS('/frontend/core/js/jquery/jquery.js', false); $this->addJS('/frontend/core/js/jquery/jquery.ui.js', false); $this->addJS('/frontend/core/js/utils.js', true); $this->addJS('/frontend/core/js/frontend.js', false, true); }
/** * Initialize Facebook */ private function initializeFacebook() { // get settings $facebookApplicationId = FrontendModel::getModuleSetting('core', 'facebook_app_id'); $facebookApplicationSecret = FrontendModel::getModuleSetting('core', 'facebook_app_secret'); // needed data available? if ($facebookApplicationId != '' && $facebookApplicationSecret != '') { // require require_once 'external/facebook.php'; // create instance $facebook = new Facebook($facebookApplicationSecret, $facebookApplicationId); // get the cookie, this will set the access token. $facebook->getCookie(); // store in reference Spoon::set('facebook', $facebook); // trigger event FrontendModel::triggerEvent('core', 'after_facebook_initialization'); } }
public function __construct() { // store in reference so we can access it from everywhere Spoon::set('navigation', $this); // grab from the reference $this->URL = Spoon::get('url'); // check if navigation cache file exists if (!SpoonFile::exists(BACKEND_CACHE_PATH . '/navigation/navigation.php')) { $this->buildCache(); } $navigation = array(); // require navigation-file require_once BACKEND_CACHE_PATH . '/navigation/navigation.php'; // load it $this->navigation = (array) $navigation; // cleanup navigation (not needed for god user) if (!BackendAuthentication::getUser()->isGod()) { $this->navigation = $this->cleanup($this->navigation); } }
/** * The constructor will store the instance in the reference, preset some settings and map the custom modifiers. * * @param bool[optional] $addToReference Should the instance be added into the reference. */ public function __construct($addToReference = true) { parent::__construct(); // get URL instance if (Spoon::exists('url')) { $this->URL = Spoon::get('url'); } // store in reference so we can access it from everywhere if ($addToReference) { Spoon::set('template', $this); } // set cache directory $this->setCacheDirectory(BACKEND_CACHE_PATH . '/cached_templates'); // set compile directory $this->setCompileDirectory(BACKEND_CACHE_PATH . '/compiled_templates'); // when debugging, the template should be recompiled every time $this->setForceCompile(SPOON_DEBUG); // map custom modifiers $this->mapCustomModifiers(); // parse authentication levels $this->parseAuthentication(); }
/** * Returns the mailchimp object. * * @return mailchimp */ public static function getMC() { // mailchimp reference exists if (!\Spoon::exists('mailchimp')) { // check if the mailchimp class exists if (!\SpoonFile::exists(PATH_LIBRARY . '/external/mcapi.php')) { // the class doesn't exist, so throw an exception throw new \SpoonFileException(sprintf(FL::err('ClassDoesNotExist'), 'mailchimp')); } // require mailchimp class require_once PATH_LIBRARY . '/external/mcapi.php'; // set login data $key = FrontendModel::getModuleSetting('MailMotor', 'api_key'); if (empty($key)) { throw new \Exception('Mailmotor api_key is required.'); } // init mailchimp object $mc = new \MCAPI($key); // set mailchimp object reference \Spoon::set('mailchimp', $mc); } // return the CampaignMonitor object return \Spoon::get('mailchimp'); }
/** * Returns the CampaignMonitor object. * * @return CampaignMonitor */ public static function getCM() { // campaignmonitor reference exists if (!Spoon::exists('campaignmonitor')) { // check if the CampaignMonitor class exists if (!SpoonFile::exists(PATH_LIBRARY . '/external/campaignmonitor.php')) { // the class doesn't exist, so throw an exception throw new SpoonFileException(BL::err('ClassDoesNotExist', 'mailmotor')); } // require CampaignMonitor class require_once 'external/campaignmonitor.php'; // set login data $url = BackendModel::getModuleSetting('mailmotor', 'cm_url'); $username = BackendModel::getModuleSetting('mailmotor', 'cm_username'); $password = BackendModel::getModuleSetting('mailmotor', 'cm_password'); // init CampaignMonitor object $cm = new CampaignMonitor($url, $username, $password, 60, self::getClientId()); // set CampaignMonitor object reference Spoon::set('campaignmonitor', $cm); } return Spoon::get('campaignmonitor'); }
/** * Init database. */ public function initDatabase() { // get port $port = SpoonSession::exists('db_port') && SpoonSession::get('db_port') != '' ? SpoonSession::get('db_port') : 3306; // database instance $this->db = new SpoonDatabase('mysql', SpoonSession::get('db_hostname'), SpoonSession::get('db_username'), SpoonSession::get('db_password'), SpoonSession::get('db_database'), $port); // utf8 compliance & MySQL-timezone $this->db->execute('SET CHARACTER SET utf8, NAMES utf8, time_zone = "+0:00"'); // store Spoon::set('database', $this->db); }
public function __construct() { parent::__construct(); // store in reference Spoon::set('footer', $this); }
/** * Get (or create and get) a database-connection * @later split the write and read connection * * @param bool[optional] $write Do you want the write-connection or not? * @return SpoonDatabase */ public static function getDB($write = false) { $write = (bool) $write; // do we have a db-object ready? if (!Spoon::exists('database')) { // create instance $db = new SpoonDatabase(DB_TYPE, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_PORT); // utf8 compliance & MySQL-timezone $db->execute('SET CHARACTER SET utf8, NAMES utf8, time_zone = "+0:00"'); // store Spoon::set('database', $db); } // return db-object return Spoon::get('database'); }