本文整理汇总了PHP中Spoon::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Spoon::get方法的具体用法?PHP Spoon::get怎么用?PHP Spoon::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spoon
的用法示例。
在下文中一共展示了Spoon::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例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: 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);
}
示例4: 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');
}
示例5: __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');
}
示例6: __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();
}
}
示例7: __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() . ').');
}
}
示例8: __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');
}
示例9: __construct
/**
* Check if all required settings have been set
*
* @return void
* @param string $module The module.
*/
public function __construct($module)
{
// parent construct
parent::__construct($module);
// load additional engine files
$this->loadEngineFiles();
// get url object reference
$url = Spoon::exists('url') ? Spoon::get('url') : null;
// do the client ID check if we're not in the settings page
if ($url != null && $url->getAction() != 'settings' && $url->getAction() != 'import_groups' && strpos($url->getQueryString(), 'link_account') === false && strpos($url->getQueryString(), 'load_client_info') === false) {
// check for CM account
$this->checkForAccount();
// check for client ID
$this->checkForClientID();
// check for groups
$this->checkForGroups();
}
}
示例10: __construct
/**
* @param string[optional] $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 bool[optional] $useToken Should we automagically add a formtoken?
* @param bool[optional] $useGlobalError Should we automagically show a global error?
*/
public function __construct($name = null, $action = null, $method = 'post', $useToken = true, $useGlobalError = true)
{
if (Spoon::exists('url')) {
$this->URL = Spoon::get('url');
}
if (Spoon::exists('header')) {
$this->header = Spoon::get('header');
}
$this->useGlobalError = (bool) $useGlobalError;
// build a name if there wasn't one provided
$name = $name === null ? SpoonFilter::toCamelCase($this->URL->getModule() . '_' . $this->URL->getAction(), '_', true) : (string) $name;
// 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');
}
示例11: __construct
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);
}
}
示例12: __construct
/**
* Default constructor
*
* @return void
* @param BackendForm $form An instance of Backendform, the elements will be parsed in here.
* @param int[optional] $metaId The metaID to load.
* @param string[optional] $baseFieldName The field where the URL should be based on.
* @param bool[optional] $custom Add/show custom-meta.
*/
public function __construct(BackendForm $form, $metaId = null, $baseFieldName = 'title', $custom = false)
{
// check if URL is available from the referene
if (!Spoon::exists('url')) {
throw new BackendException('URL should be available in the reference.');
}
// get BackendURL instance
$this->URL = Spoon::get('url');
// should we use meta-custom
$this->custom = (bool) $custom;
// set form instance
$this->frm = $form;
// set base field name
$this->baseFieldName = (string) $baseFieldName;
// metaId was specified, so we should load the item
if ($metaId !== null) {
$this->loadMeta($metaId);
}
// load the form
$this->loadForm();
}
示例13: getMC
/**
* 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');
}
示例14: __construct
/**
* @param string $module The module to use.
* @param string $action The action to use.
* @param string[optional] $data The data that should be available.
*/
public function __construct($module, $action, $data = null)
{
// get objects from the reference so they are accessable
$this->tpl = new FrontendTemplate(false);
$this->header = Spoon::get('header');
$this->URL = Spoon::get('url');
// set properties
$this->setModule($module);
$this->setAction($action);
$this->setData($data);
}
示例15: parse
/**
* Parse the general profiles info into the template.
*/
public static function parse()
{
// get the template
$tpl = Spoon::get('template');
// logged in
if (FrontendProfilesAuthentication::isLoggedIn()) {
// get profile
$profile = FrontendProfilesAuthentication::getProfile();
// display name set?
if ($profile->getDisplayName() != '') {
$tpl->assign('profileDisplayName', $profile->getDisplayName());
} else {
$tpl->assign('profileDisplayName', $profile->getEmail());
}
// show logged in
$tpl->assign('isLoggedIn', true);
}
// ignore these url's in the querystring
$ignoreUrls = array(FrontendNavigation::getURLForBlock('profiles', 'login'), FrontendNavigation::getURLForBlock('profiles', 'register'), FrontendNavigation::getURLForBlock('profiles', 'forgot_password'));
// querystring
$queryString = isset($_GET['queryString']) ? SITE_URL . '/' . urldecode($_GET['queryString']) : SELF;
// check all ignore urls
foreach ($ignoreUrls as $url) {
// querystring contains a boeboe url
if (stripos($queryString, $url) !== false) {
$queryString = '';
break;
}
}
// no need to add this if its empty
$queryString = $queryString != '' ? '?queryString=' . urlencode($queryString) : '';
// useful urls
$tpl->assign('loginUrl', FrontendNavigation::getURLForBlock('profiles', 'login') . $queryString);
$tpl->assign('registerUrl', FrontendNavigation::getURLForBlock('profiles', 'register'));
$tpl->assign('forgotPasswordUrl', FrontendNavigation::getURLForBlock('profiles', 'forgot_password'));
}