本文整理汇总了PHP中Spoon类的典型用法代码示例。如果您正苦于以下问题:PHP Spoon类的具体用法?PHP Spoon怎么用?PHP Spoon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Spoon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
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));
}
示例2: loadData
/**
* Load the data
*/
private function loadData()
{
// get the current page id
$pageId = Spoon::get('page')->getId();
$navigation = FrontendNavigation::getNavigation();
$pageInfo = FrontendNavigation::getPageInfo($pageId);
$this->navigation = array();
if (isset($navigation['page'][$pageInfo['parent_id']])) {
$pages = $navigation['page'][$pageInfo['parent_id']];
// store
$pagesPrev = $pages;
$pagesNext = $pages;
// check for current id
foreach ($pagesNext as $key => $value) {
if ((int) $key != (int) $pageId) {
// go to next pointer in array
next($pagesNext);
next($pagesPrev);
} else {
break;
}
}
// get previous page
$this->navigation['previous'] = prev($pagesPrev);
// get next page
$this->navigation['next'] = next($pagesNext);
// get parent page
$this->navigation['parent'] = FrontendNavigation::getPageInfo($pageInfo['parent_id']);
}
}
示例3: defineForkConstants
/**
* This will disappear in time in favour of container-driven parameters.
* @deprecated
*/
public function defineForkConstants()
{
$container = $this->getContainer();
Spoon::setDebug($container->getParameter('kernel.debug'));
Spoon::setDebugEmail($container->getParameter('fork.debug_email'));
Spoon::setDebugMessage($container->getParameter('fork.debug_message'));
Spoon::setCharset($container->getParameter('kernel.charset'));
/**
* @deprecated SPOON_* constants are deprecated in favor of Spoon::set*().
* Will be removed in the next major release.
*/
defined('SPOON_DEBUG') || define('SPOON_DEBUG', $container->getParameter('kernel.debug'));
defined('SPOON_DEBUG_EMAIL') || define('SPOON_DEBUG_EMAIL', $container->getParameter('fork.debug_email'));
defined('SPOON_DEBUG_MESSAGE') || define('SPOON_DEBUG_MESSAGE', $container->getParameter('fork.debug_message'));
defined('SPOON_CHARSET') || define('SPOON_CHARSET', $container->getParameter('kernel.charset'));
defined('PATH_WWW') || define('PATH_WWW', $container->getParameter('site.path_www'));
defined('PATH_LIBRARY') || define('PATH_LIBRARY', $container->getParameter('site.path_library'));
defined('SITE_DEFAULT_LANGUAGE') || define('SITE_DEFAULT_LANGUAGE', $container->getParameter('site.default_language'));
defined('SITE_DEFAULT_TITLE') || define('SITE_DEFAULT_TITLE', $container->getParameter('site.default_title'));
defined('SITE_MULTILANGUAGE') || define('SITE_MULTILANGUAGE', $container->getParameter('site.multilanguage'));
defined('SITE_DOMAIN') || define('SITE_DOMAIN', $container->getParameter('site.domain'));
defined('SITE_PROTOCOL') || define('SITE_PROTOCOL', $container->getParameter('site.protocol'));
defined('SITE_URL') || define('SITE_URL', SITE_PROTOCOL . '://' . SITE_DOMAIN);
defined('FORK_VERSION') || define('FORK_VERSION', $container->getParameter('fork.version'));
defined('ACTION_GROUP_TAG') || define('ACTION_GROUP_TAG', $container->getParameter('action.group_tag'));
defined('ACTION_RIGHTS_LEVEL') || define('ACTION_RIGHTS_LEVEL', $container->getParameter('action.rights_level'));
}
示例4: loadData
/**
* Load the data
*/
private function loadData()
{
// get the current page id
$pageId = Spoon::get('page')->getId();
// fetch the items
$this->items = FrontendPagesModel::getSubpages($pageId);
}
示例5: getCM
/**
* 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');
}
示例6: set
/**
* Stores a value in a cookie, by default the cookie will expire in one day.
*
* @param string $key A name for the cookie.
* @param mixed $value The value to be stored. Keep in mind that they will be serialized.
* @param int[optional] $time The number of seconds that this cookie will be available, 30 days is the default.
* @param string[optional] $path The path on the server in which the cookie will be availabe. Use / for the entire domain, /foo if you just want it to be available in /foo.
* @param string[optional] $domain The domain that the cookie is available on. Use .example.com to make it available on all subdomains of example.com.
* @param bool[optional] $secure Should the cookie be transmitted over a HTTPS-connection? If true, make sure you use a secure connection, otherwise the cookie won't be set.
* @param bool[optional] $httpOnly Should the cookie only be available through HTTP-protocol? If true, the cookie can't be accessed by Javascript, ...
* @return bool If set with succes, returns true otherwise false.
*/
public static function set($key, $value, $time = 2592000, $path = '/', $domain = null, $secure = null, $httpOnly = true)
{
// redefine
$key = (string) $key;
$value = serialize($value);
$time = time() + (int) $time;
$path = (string) $path;
$httpOnly = (bool) $httpOnly;
// when the domain isn't passed and the url-object is available we can set the cookies for all subdomains
if ($domain === null && Spoon::exists('url')) {
$domain = '.' . Spoon::get('url')->getDomain();
}
// when the secure-parameter isn't set
if ($secure === null) {
/*
detect if we are using HTTPS, this wil only work in Apache, if you are using nginx you should add the
code below into your config:
ssl on;
fastcgi_param HTTPS on;
for lighttpd you should add:
setenv.add-environment = ("HTTPS" => "on")
*/
$secure = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on';
}
// set cookie
$cookie = setcookie($key, $value, $time, $path, $domain, $secure, $httpOnly);
// problem occured
return $cookie === false ? false : true;
}
示例7: __construct
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');
}
示例8: __construct
public function __construct()
{
// add to registry
Spoon::set('url', $this);
$this->setQueryString($_SERVER['REQUEST_URI']);
$this->setHost($_SERVER['HTTP_HOST']);
$this->processQueryString();
}
示例9: testSet
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'));
}
示例10: __construct
/**
* 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();
}
示例11: __construct
/**
* You have to specify the action and module so we know what to do with this instance
*
* @param string $action The action to load.
* @param string $module The module to load.
*/
public function __construct($action, $module)
{
// grab stuff from the reference and store them in this object (for later/easy use)
$this->tpl = Spoon::get('template');
$this->setModule($module);
$this->setAction($action);
$this->loadConfig();
// is the requested action possible? If not we throw an exception. We don't redirect because that could trigger a redirect loop
if (!in_array($this->getAction(), $this->config->getPossibleActions())) {
throw new BackendException('This is an invalid action (' . $this->getAction() . ').');
}
}
示例12: __construct
/**
* Check if all required settings have been set
*
* @param string $module The module.
*/
public function __construct($module)
{
parent::__construct($module);
$this->loadEngineFiles();
$url = Spoon::exists('url') ? Spoon::get('url') : null;
// do the client ID check if we're not in the settings page
if ($url != null && !in_array($url->getAction(), array('settings', 'import_groups', 'link_account', 'load_client_info'))) {
$this->checkForAccount();
$this->checkForClientID();
$this->checkForGroups();
}
}
示例13: __construct
/**
* @param string $name Name of the form.
* @param string[optional] $action The action (URL) whereto the form will be submitted, if not provided it will be autogenerated.
* @param string[optional] $method The method to use when submiting the form, default is POST.
* @param string[optional] $hash The id of the anchor to append to the action-URL.
* @param bool[optional] $useToken Should we automagically add a formtoken?
*/
public function __construct($name, $action = null, $method = 'post', $hash = null, $useToken = true)
{
$this->URL = Spoon::get('url');
$this->header = Spoon::get('header');
$name = (string) $name;
$hash = $hash !== null ? (string) $hash : null;
$useToken = (bool) $useToken;
// build the action if it wasn't provided
$action = $action === null ? '/' . $this->URL->getQueryString() : (string) $action;
// call the real form-class
parent::__construct($name, $action, $method, $useToken);
// add default classes
$this->setParameter('id', $name);
$this->setParameter('class', 'forkForms submitWithLink');
}
示例14: __construct
/**
* 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);
}
示例15: __construct
/**
* 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']);
}
}