当前位置: 首页>>代码示例>>PHP>>正文


PHP Spoon::exists方法代码示例

本文整理汇总了PHP中Spoon::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Spoon::exists方法的具体用法?PHP Spoon::exists怎么用?PHP Spoon::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Spoon的用法示例。


在下文中一共展示了Spoon::exists方法的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;
 }
开发者ID:nickmancol,项目名称:forkcms-rhcloud,代码行数:42,代码来源:cookie.php

示例2: 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');
 }
开发者ID:nickmancol,项目名称:forkcms-rhcloud,代码行数:33,代码来源:helper.php

示例3: 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'));
 }
开发者ID:jeroendesloovere,项目名称:library,代码行数:9,代码来源:SpoonTest.php

示例4: __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();
     }
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:17,代码来源:config.php

示例5: __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();
     }
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:24,代码来源:config.php

示例6: __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');
 }
开发者ID:nickmancol,项目名称:forkcms-rhcloud,代码行数:26,代码来源:form.php

示例7: __construct

 /**
  * 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();
 }
开发者ID:richsage,项目名称:forkcms,代码行数:25,代码来源:template.php

示例8: __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();
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:30,代码来源:meta.php

示例9: 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');
 }
开发者ID:WouterSioen,项目名称:fork-cms-module-mailmotor,代码行数:29,代码来源:Helper.php

示例10: parseLabels

 /**
  * Assign the labels
  */
 private function parseLabels()
 {
     // grab the current module
     if (Spoon::exists('url')) {
         $currentModule = Spoon::get('url')->getModule();
     } elseif (isset($_GET['module']) && $_GET['module'] != '') {
         $currentModule = (string) $_GET['module'];
     } else {
         $currentModule = 'core';
     }
     // init vars
     $realErrors = array();
     $realLabels = array();
     $realMessages = array();
     // get all errors
     $errors = BackendLanguage::getErrors();
     // get all labels
     $labels = BackendLanguage::getLabels();
     // get all messages
     $messages = BackendLanguage::getMessages();
     // set the begin state
     $realErrors = $errors['core'];
     $realLabels = $labels['core'];
     $realMessages = $messages['core'];
     // loop all errors, label, messages and add them again, but prefixed with Core. So we can decide in the
     // template to use the core-value instead of the one set by the module
     foreach ($errors['core'] as $key => $value) {
         $realErrors['Core' . $key] = $value;
     }
     foreach ($labels['core'] as $key => $value) {
         $realLabels['Core' . $key] = $value;
     }
     foreach ($messages['core'] as $key => $value) {
         $realMessages['Core' . $key] = $value;
     }
     // are there errors for the current module?
     if (isset($errors[$currentModule])) {
         // loop the module-specific errors and reset them in the array with values we will use
         foreach ($errors[$currentModule] as $key => $value) {
             $realErrors[$key] = $value;
         }
     }
     // are there labels for the current module?
     if (isset($labels[$currentModule])) {
         // loop the module-specific labels and reset them in the array with values we will use
         foreach ($labels[$currentModule] as $key => $value) {
             $realLabels[$key] = $value;
         }
     }
     // are there messages for the current module?
     if (isset($messages[$currentModule])) {
         // loop the module-specific errors and reset them in the array with values we will use
         foreach ($messages[$currentModule] as $key => $value) {
             $realMessages[$key] = $value;
         }
     }
     // execute addslashes on the values for the locale, will be used in JS
     if ($this->addSlashes) {
         foreach ($realErrors as &$value) {
             $value = addslashes($value);
         }
         foreach ($realLabels as &$value) {
             $value = addslashes($value);
         }
         foreach ($realMessages as &$value) {
             $value = addslashes($value);
         }
     }
     // sort the arrays (just to make it look beautifull)
     ksort($realErrors);
     ksort($realLabels);
     ksort($realMessages);
     // assign errors
     $this->assignArray($realErrors, 'err');
     // assign labels
     $this->assignArray($realLabels, 'lbl');
     // assign messages
     $this->assignArray($realMessages, 'msg');
 }
开发者ID:nickmancol,项目名称:forkcms-rhcloud,代码行数:82,代码来源:template.php

示例11: getMessage

 /**
  * Get a message from the language-file
  *
  * @param string $key The key to get.
  * @param string[optional] $module The module wherin we should search.
  * @return string
  */
 public static function getMessage($key, $module = null)
 {
     if ($module === null) {
         if (Spoon::exists('url')) {
             $module = Spoon::get('url')->getModule();
         } elseif (isset($_GET['module']) && $_GET['module'] != '') {
             $module = (string) $_GET['module'];
         } else {
             $module = 'core';
         }
     }
     $key = SpoonFilter::toCamelCase((string) $key);
     $module = (string) $module;
     // check if the message exists
     if (isset(self::$msg[$module][$key])) {
         return self::$msg[$module][$key];
     }
     // check if the message exists in the core
     if (isset(self::$msg['core'][$key])) {
         return self::$msg['core'][$key];
     }
     // otherwise return the key in label-format
     return '{$msg' . SpoonFilter::toCamelCase($module) . $key . '}';
 }
开发者ID:nickmancol,项目名称:forkcms-rhcloud,代码行数:31,代码来源:language.php

示例12: getCM

 /**
  * 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');
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:27,代码来源:helper.php

示例13: setSortingOptions

 /**
  * Sets all the default settings needed when attempting to use sorting
  */
 private function setSortingOptions()
 {
     // default URL
     if (Spoon::exists('url')) {
         $this->setURL(BackendModel::createURLForAction(null, null, null, array('offset' => '[offset]', 'order' => '[order]', 'sort' => '[sort]'), false));
     }
     // sorting labels
     $this->setSortingLabels(BL::lbl('SortAscending'), BL::lbl('SortedAscending'), BL::lbl('SortDescending'), BL::lbl('SortedDescending'));
 }
开发者ID:nickmancol,项目名称:forkcms-rhcloud,代码行数:12,代码来源:datagrid.php

示例14: getMessage

 /**
  * Get a message from the language-file
  *
  * @return	string
  * @param	string $key					The key to get.
  * @param	string[optional] $module	The module wherin we should search.
  */
 public static function getMessage($key, $module = null)
 {
     // do we know the module
     if ($module === null) {
         if (Spoon::exists('url')) {
             $module = Spoon::get('url')->getModule();
         } elseif (isset($_GET['module']) && $_GET['module'] != '') {
             $module = (string) $_GET['module'];
         } else {
             $module = 'core';
         }
     }
     // redefine
     $key = (string) $key;
     $module = (string) $module;
     // if the error exists return it,
     if (isset(self::$msg[$module][$key])) {
         return self::$msg[$module][$key];
     }
     // if it exists in the core-errors
     if (isset(self::$msg['core'][$key])) {
         return self::$msg['core'][$key];
     }
     // otherwise return the key in label-format
     return '{$msg' . SpoonFilter::toCamelCase($module) . $key . '}';
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:33,代码来源:language.php

示例15: parseField

 /**
  * Parse a field and return the HTML.
  *
  * @return	string
  * @param	array $field	Field data.
  */
 public static function parseField(array $field)
 {
     // got a field
     if (!empty($field)) {
         // init
         $frm = new BackendForm('tmp', '');
         $tpl = Spoon::exists('template') ? Spoon::get('template') : new BackendTemplate();
         $fieldHTML = '';
         $fieldName = 'field' . $field['id'];
         $values = isset($field['settings']['values']) ? $field['settings']['values'] : null;
         $defaultValues = isset($field['settings']['default_values']) ? $field['settings']['default_values'] : null;
         /**
          * Create form and parse to HTML
          */
         // dropdown
         if ($field['type'] == 'dropdown') {
             // get index of selected item
             $defaultIndex = array_search($defaultValues, $values, true);
             if ($defaultIndex === false) {
                 $defaultIndex = null;
             }
             // create element
             $ddm = $frm->addDropdown($fieldName, $values, $defaultIndex);
             // empty default element
             $ddm->setDefaultElement('');
             // get content
             $fieldHTML = $ddm->parse();
         } elseif ($field['type'] == 'radiobutton') {
             // rebuild values
             foreach ($values as $value) {
                 $newValues[] = array('label' => $value, 'value' => $value);
             }
             // create element
             $rbt = $frm->addRadiobutton($fieldName, $newValues, $defaultValues);
             // get content
             $fieldHTML = $rbt->parse();
         } elseif ($field['type'] == 'checkbox') {
             // rebuild values
             foreach ($values as $value) {
                 $newValues[] = array('label' => $value, 'value' => $value);
             }
             // create element
             $chk = $frm->addMultiCheckbox($fieldName, $newValues, $defaultValues);
             // get content
             $fieldHTML = $chk->parse();
         } elseif ($field['type'] == 'textbox') {
             // create element
             $txt = $frm->addText($fieldName, $defaultValues);
             $txt->setAttribute('disabled', 'disabled');
             // get content
             $fieldHTML = $txt->parse();
         } elseif ($field['type'] == 'textarea') {
             // create element
             $txt = $frm->addTextarea($fieldName, $defaultValues);
             $txt->setAttribute('cols', 30);
             $txt->setAttribute('disabled', 'disabled');
             // get content
             $fieldHTML = $txt->parse();
         } elseif ($field['type'] == 'heading') {
             $fieldHTML = '<h3>' . $values . '</h3>';
         } elseif ($field['type'] == 'paragraph') {
             $fieldHTML = $values;
         }
         /**
          * Parse the field into the template
          */
         // init
         $tpl->assign('plaintext', false);
         $tpl->assign('simple', false);
         $tpl->assign('multiple', false);
         $tpl->assign('id', $field['id']);
         $tpl->assign('required', isset($field['validations']['required']));
         // plaintext items
         if ($field['type'] == 'heading' || $field['type'] == 'paragraph') {
             // assign
             $tpl->assign('content', $fieldHTML);
             $tpl->assign('plaintext', true);
         } elseif ($field['type'] == 'checkbox' || $field['type'] == 'radiobutton') {
             // name (prefixed by type)
             $name = $field['type'] == 'checkbox' ? 'chk' . ucfirst($fieldName) : 'rbt' . ucfirst($fieldName);
             // rebuild so the html is stored in a general name (and not rbtName)
             foreach ($fieldHTML as &$item) {
                 $item['field'] = $item[$name];
             }
             // show multiple
             $tpl->assign('label', $field['settings']['label']);
             $tpl->assign('items', $fieldHTML);
             $tpl->assign('multiple', true);
         } else {
             // assign
             $tpl->assign('label', $field['settings']['label']);
             $tpl->assign('field', $fieldHTML);
             $tpl->assign('simple', true);
         }
//.........这里部分代码省略.........
开发者ID:netconstructor,项目名称:forkcms,代码行数:101,代码来源:model.php


注:本文中的Spoon::exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。