本文整理汇总了PHP中SpoonSession::get方法的典型用法代码示例。如果您正苦于以下问题:PHP SpoonSession::get方法的具体用法?PHP SpoonSession::get怎么用?PHP SpoonSession::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpoonSession
的用法示例。
在下文中一共展示了SpoonSession::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Execute the action
*/
public function execute()
{
// If step 1 isn't entered, redirect back to the first step of the wizard
$this->record = \SpoonSession::get('module');
if (!$this->record || !array_key_exists('title', $this->record)) {
$this->redirect(Model::createURLForAction('Add'));
}
// If there are no fields added, redirect back to the second step of the wizard
if (!array_key_exists('fields', $this->record) || empty($this->record['fields'])) {
$this->redirect(Model::createURLForAction('AddStep2'));
}
parent::execute();
// initialize some variables
$this->backendPath = BACKEND_MODULES_PATH . '/' . $this->record['camel_case_name'] . '/';
$this->frontendPath = FRONTEND_MODULES_PATH . '/' . $this->record['camel_case_name'] . '/';
$this->variables = (array) $this->record;
unset($this->variables['fields']);
$this->generateFolders();
$this->generateBaseFiles();
$this->generateInstallerFiles();
// Backend
$this->generateBackendFiles();
$this->generateBackendModel();
$this->generateBackendActions();
$this->generateBackendCategoryActions();
// Frontend
$this->generateFrontendFiles();
$this->generateFrontendModel();
$this->generateFrontendActions();
$this->generateFrontendCategoryActions();
$this->generateFrontendCategoryWidget();
$this->parse();
$this->display();
}
示例2: loadForm
/**
* Loads the form.
*/
private function loadForm()
{
// init var
$modules = array();
$checkedModules = SpoonSession::exists('modules') ? SpoonSession::get('modules') : array();
// loop required modules
foreach ($this->modules['required'] as $module) {
// add to the list
$modules[] = array('label' => SpoonFilter::toCamelCase($module), 'value' => $module, 'attributes' => array('disabled' => 'disabled'));
// update $_POST if needed
if (!isset($_POST['modules']) || !is_array($_POST['modules']) || !in_array($module, $_POST['modules'])) {
$_POST['modules'][] = $module;
}
}
// loop optional modules
foreach ($this->modules['optional'] as $module) {
// add to the list
$modules[] = array('label' => SpoonFilter::toCamelCase($module), 'value' => $module);
}
// add multi checkbox
$this->frm->addMultiCheckbox('modules', $modules, array_unique(array_merge($this->modules['required'], $checkedModules)));
// example data
$this->frm->addCheckbox('example_data', SpoonSession::exists('example_data') ? SpoonSession::get('example_data') : true);
// debug mode
$this->frm->addCheckbox('debug_mode', SpoonSession::exists('debug_mode') ? SpoonSession::get('debug_mode') : false);
// specific debug email address
$this->frm->addCheckbox('different_debug_email', SpoonSession::exists('different_debug_email') ? SpoonSession::get('different_debug_email') : false);
// specific debug email address text
$this->frm->addText('debug_email', SpoonSession::exists('debug_email') ? SpoonSession::get('debug_email') : '');
}
示例3: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// get parameters
$charset = $this->getContainer()->getParameter('kernel.charset');
$searchTerm = \SpoonFilter::getPostValue('term', null, '');
$term = $charset == 'utf-8' ? \SpoonFilter::htmlspecialchars($searchTerm) : \SpoonFilter::htmlentities($searchTerm);
// validate search term
if ($term == '') {
$this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
} else {
// previous search result
$previousTerm = \SpoonSession::exists('searchTerm') ? \SpoonSession::get('searchTerm') : '';
\SpoonSession::set('searchTerm', '');
// save this term?
if ($previousTerm != $term) {
// format data
$this->statistics = array();
$this->statistics['term'] = $term;
$this->statistics['language'] = LANGUAGE;
$this->statistics['time'] = FrontendModel::getUTCDate();
$this->statistics['data'] = serialize(array('server' => $_SERVER));
$this->statistics['num_results'] = FrontendSearchModel::getTotal($term);
// save data
FrontendSearchModel::save($this->statistics);
}
// save current search term in cookie
\SpoonSession::set('searchTerm', $term);
// output
$this->output(self::OK);
}
}
示例4: execute
/**
* Execute the action
*
* @return void
*/
public function execute()
{
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// get parameters
$term = SpoonFilter::getGetValue('term', null, '');
// validate
if ($term == '') {
$this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
}
// previous search result
$previousTerm = SpoonSession::exists('searchTerm') ? SpoonSession::get('searchTerm') : '';
SpoonSession::set('searchTerm', '');
// save this term?
if ($previousTerm != $term) {
// format data
$this->statistics = array();
$this->statistics['term'] = $term;
$this->statistics['language'] = FRONTEND_LANGUAGE;
$this->statistics['time'] = FrontendModel::getUTCDate();
$this->statistics['data'] = serialize(array('server' => $_SERVER));
$this->statistics['num_results'] = FrontendSearchModel::getTotal($term);
// save data
FrontendSearchModel::save($this->statistics);
}
// save current search term in cookie
SpoonSession::set('searchTerm', $term);
// output
$this->output(self::OK);
}
示例5: setDates
/**
* Set start and end timestamp needed to collect analytics data
*
* @return void
*/
private function setDates()
{
// process
BackendAnalyticsHelper::setDates();
// get timestamps from session and set
$this->startTimestamp = (int) SpoonSession::get('analytics_start_timestamp');
$this->endTimestamp = (int) SpoonSession::get('analytics_end_timestamp');
}
示例6: loadForm
/**
* Load the form
*/
protected function loadForm()
{
$this->record = \SpoonSession::get('module');
$this->frm = new Form('add');
$this->frm->addText('title', $this->record ? $this->record['title'] : null, null, 'inputText title', 'inputTextError title');
$this->frm->addTextArea('description', $this->record ? $this->record['description'] : null);
$this->frm->addText('author_name', $this->record ? $this->record['author_name'] : null);
$this->frm->addText('author_url', $this->record ? $this->record['author_url'] : null);
$this->frm->addText('author_email', $this->record ? $this->record['author_email'] : null);
}
示例7: loadForm
/**
* Loads the form.
*
* @return void
*/
private function loadForm()
{
// guess email
$host = $_SERVER['HTTP_HOST'];
$this->frm->addText('email', SpoonSession::exists('email') ? SpoonSession::get('email') : 'info@' . $host);
$this->frm->addPassword('password', SpoonSession::exists('password') ? SpoonSession::get('password') : null, null, 'inputPassword', 'inputPasswordError', true);
$this->frm->addPassword('confirm', SpoonSession::exists('confirm') ? SpoonSession::get('confirm') : null, null, 'inputPassword', 'inputPasswordError', true);
// disable autocomplete
$this->frm->getField('password')->setAttributes(array('autocomplete' => 'off'));
$this->frm->getField('confirm')->setAttributes(array('autocomplete' => 'off'));
}
示例8: checkToken
/**
* Check if the token is ok
*/
public function checkToken()
{
$fromSession = \SpoonSession::exists('csrf_token') ? \SpoonSession::get('csrf_token') : '';
$fromGet = \SpoonFilter::getGetValue('token', null, '');
if ($fromSession != '' && $fromGet != '' && $fromSession == $fromGet) {
return;
}
// clear the token
\SpoonSession::set('csrf_token', '');
$this->redirect(BackendModel::createURLForAction('Index', null, null, array('error' => 'csrf')));
}
示例9: execute
/**
* Execute the actions
*/
public function execute()
{
// If step 1 isn't entered, redirect back to the first step of the wizard
$this->record = \SpoonSession::get('module');
if (!$this->record || !array_key_exists('title', $this->record)) {
$this->redirect(Model::createURLForAction('add'));
}
parent::execute();
$this->loadDataGrid();
$this->parse();
$this->display();
}
示例10: loadForm
/**
* Loads the form.
*/
private function loadForm()
{
// seperate frontend/backend languages?
$this->frm->addCheckbox('same_interface_language', SpoonSession::exists('same_interface_language') ? SpoonSession::get('same_interface_language') : true);
// multiple or single language (frontend)
$this->frm->addRadiobutton('language_type', array(array('value' => 'multiple', 'label' => 'Multiple languages', 'variables' => array('multiple' => true)), array('value' => 'single', 'label' => 'Just one language', 'variables' => array('single' => true))), SpoonSession::exists('multiple_languages') && SpoonSession::get('multiple_languages') ? 'multiple' : 'single');
// multiple languages (frontend)
$this->frm->addMultiCheckbox('languages', array(array('value' => 'en', 'label' => 'English'), array('value' => 'cn', 'label' => 'Chinese'), array('value' => 'nl', 'label' => 'Dutch'), array('value' => 'fr', 'label' => 'French'), array('value' => 'de', 'label' => 'German'), array('value' => 'hu', 'label' => 'Hungarian'), array('value' => 'it', 'label' => 'Italian'), array('value' => 'ru', 'label' => 'Russian'), array('value' => 'es', 'label' => 'Spanish')), SpoonSession::exists('languages') ? SpoonSession::get('languages') : 'en');
// multiple languages (backend)
$this->frm->addMultiCheckbox('interface_languages', array(array('value' => 'en', 'label' => 'English'), array('value' => 'cn', 'label' => 'Chinese'), array('value' => 'nl', 'label' => 'Dutch'), array('value' => 'fr', 'label' => 'French'), array('value' => 'de', 'label' => 'German'), array('value' => 'hu', 'label' => 'Hungarian'), array('value' => 'it', 'label' => 'Italian'), array('value' => 'ru', 'label' => 'Russian'), array('value' => 'es', 'label' => 'Spanish')), SpoonSession::exists('interface_languages') ? SpoonSession::get('interface_languages') : 'en');
// single language (frontend)
$this->frm->addDropdown('language', array('en' => 'English', 'cn' => 'Chinese', 'nl' => 'Dutch', 'fr' => 'French', 'de' => 'German', 'hu' => 'Hungarian', 'it' => 'Italian', 'ru' => 'Russian', 'es' => 'Spanish'), SpoonSession::exists('default_language') ? SpoonSession::get('default_language') : 'en');
// default language (frontend)
$this->frm->addDropdown('default_language', array('en' => 'English', 'cn' => 'Chinese', 'nl' => 'Dutch', 'fr' => 'French', 'de' => 'German', 'hu' => 'Hungarian', 'it' => 'Italian', 'ru' => 'Russian', 'es' => 'Spanish'), SpoonSession::exists('default_language') ? SpoonSession::get('default_language') : 'en');
// default language (backend)
$this->frm->addDropdown('default_interface_language', array('en' => 'English', 'cn' => 'Chinese', 'nl' => 'Dutch', 'fr' => 'French', 'de' => 'German', 'hu' => 'Hungarian', 'it' => 'Italian', 'ru' => 'Russian', 'es' => 'Spanish'), SpoonSession::exists('default_interface_language') ? SpoonSession::get('default_interface_language') : 'en');
}
示例11: execute
/**
* Execute the actions
*/
public function execute()
{
// If step 1 isn't entered, redirect back to the first step of the wizard
$this->record = \SpoonSession::get('module');
if (!$this->record || !array_key_exists('title', $this->record)) {
$this->redirect(Model::createURLForAction('Add'));
}
// If there are no fields added, redirect back to the second step of the wizard
if (!array_key_exists('fields', $this->record) || empty($this->record['fields'])) {
$this->redirect(Model::createURLForAction('AddStep2'));
}
parent::execute();
$this->loadForm();
$this->validateForm();
$this->parse();
$this->display();
}
示例12: loadForm
/**
* Loads the form.
*/
private function loadForm()
{
// guess db & username
$host = $_SERVER['HTTP_HOST'];
$chunks = explode('.', $host);
// seems like windows can't handle localhost...
$dbHost = substr(PHP_OS, 0, 3) == 'WIN' ? '127.0.0.1' : 'localhost';
// remove tld
array_pop($chunks);
// create base
$base = implode('_', $chunks);
// create input fields
$this->frm->addText('hostname', SpoonSession::exists('db_hostname') ? SpoonSession::get('db_hostname') : $dbHost);
$this->frm->addText('port', SpoonSession::exists('db_port') ? SpoonSession::get('db_port') : 3306, 10);
$this->frm->addText('database', SpoonSession::exists('db_database') ? SpoonSession::get('db_database') : $base);
$this->frm->addText('username', SpoonSession::exists('db_username') ? SpoonSession::get('db_username') : $base);
$this->frm->addPassword('password', SpoonSession::exists('db_password') ? SpoonSession::get('db_password') : null);
}
示例13: execute
/**
* Execute the action
*/
public function execute()
{
// If step 1 isn't entered, redirect back to the first step of the wizard
$this->record = \SpoonSession::get('module');
if (!$this->record || !array_key_exists('title', $this->record)) {
$this->redirect(Model::createURLForAction('Add'));
}
// If there are no fields added, redirect back to the second step of the wizard
if (!array_key_exists('fields', $this->record) || empty($this->record['fields'])) {
$this->redirect(Model::createURLForAction('AddStep2') . '&error=non-existing');
}
// get parameters
$this->id = $this->getParameter('id', 'int');
// does the item exist
if ($this->id !== null && array_key_exists($this->id, $this->record['fields'])) {
unset($this->record['fields'][$this->id]);
\SpoonSession::set('module', $this->record);
$this->redirect(Model::createURLForAction('AddStep2') . '&report=deleted');
} else {
$this->redirect(Model::createURLForAction('AddStep2') . '&error=non-existing');
}
}
示例14: validateForm
/**
* Validate the form.
*/
private function validateForm()
{
// submitted
if ($this->frm->isSubmitted()) {
// does the key exists?
if (SpoonSession::exists('formbuilder_' . $this->item['id'])) {
// calculate difference
$diff = time() - (int) SpoonSession::get('formbuilder_' . $this->item['id']);
// calculate difference, it it isn't 10 seconds the we tell the user to slow down
if ($diff < 10 && $diff != 0) {
$this->frm->addError(FL::err('FormTimeout'));
}
}
// validate fields
foreach ($this->item['fields'] as $field) {
// fieldname
$fieldName = 'field' . $field['id'];
// skip
if ($field['type'] == 'submit' || $field['type'] == 'paragraph' || $field['type'] == 'heading') {
continue;
}
// loop other validations
foreach ($field['validations'] as $rule => $settings) {
// already has an error so skip
if ($this->frm->getField($fieldName)->getErrors() !== null) {
continue;
}
// required
if ($rule == 'required') {
$this->frm->getField($fieldName)->isFilled($settings['error_message']);
} elseif ($rule == 'email') {
// only check this if the field is filled, if the field is required it will be validated before
if ($this->frm->getField($fieldName)->isFilled()) {
$this->frm->getField($fieldName)->isEmail($settings['error_message']);
}
} elseif ($rule == 'numeric') {
// only check this if the field is filled, if the field is required it will be validated before
if ($this->frm->getField($fieldName)->isFilled()) {
$this->frm->getField($fieldName)->isNumeric($settings['error_message']);
}
}
}
}
// valid form
if ($this->frm->isCorrect()) {
// item
$data['form_id'] = $this->item['id'];
$data['session_id'] = SpoonSession::getSessionId();
$data['sent_on'] = FrontendModel::getUTCDate();
$data['data'] = serialize(array('server' => $_SERVER));
// insert data
$dataId = FrontendFormBuilderModel::insertData($data);
// init fields array
$fields = array();
// loop all fields
foreach ($this->item['fields'] as $field) {
// skip
if ($field['type'] == 'submit' || $field['type'] == 'paragraph' || $field['type'] == 'heading') {
continue;
}
// field data
$fieldData['data_id'] = $dataId;
$fieldData['label'] = $field['settings']['label'];
$fieldData['value'] = $this->frm->getField('field' . $field['id'])->getValue();
// prepare fields for email
if ($this->item['method'] == 'database_email') {
// add field for email
$emailFields[] = array('label' => $field['settings']['label'], 'value' => is_array($fieldData['value']) ? implode(',', $fieldData['value']) : nl2br($fieldData['value']));
}
// clean up
if (is_array($fieldData['value']) && empty($fieldData['value'])) {
$fieldData['value'] = null;
}
// serialize
if ($fieldData['value'] !== null) {
$fieldData['value'] = serialize($fieldData['value']);
}
// save fields data
$fields[] = $fieldData;
// insert
FrontendFormBuilderModel::insertDataField($fieldData);
}
// need to send mail
if ($this->item['method'] == 'database_email') {
// build variables
$variables['sentOn'] = time();
$variables['name'] = $this->item['name'];
$variables['fields'] = $emailFields;
// loop recipients
foreach ($this->item['email'] as $address) {
// add email
FrontendMailer::addEmail(sprintf(FL::getMessage('FormBuilderSubject'), $this->item['name']), FRONTEND_MODULES_PATH . '/form_builder/layout/templates/mails/form.tpl', $variables, $address, $this->item['name']);
}
}
// trigger event
FrontendModel::triggerEvent('form_builder', 'after_submission', array('form_id' => $this->item['id'], 'data_id' => $dataId, 'data' => $data, 'fields' => $fields, 'visitorId' => FrontendModel::getVisitorId()));
// store timestamp in session so we can block excesive usage
//.........这里部分代码省略.........
示例15: validateForm
/**
* Validate the form
*/
private function validateForm()
{
// get settings
$commentsAllowed = isset($this->settings['allow_comments']) && $this->settings['allow_comments'];
// comments aren't allowed so we don't have to validate
if (!$commentsAllowed) {
return false;
}
// is the form submitted
if ($this->frm->isSubmitted()) {
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// does the key exists?
if (SpoonSession::exists('blog_comment_' . $this->record['id'])) {
// calculate difference
$diff = time() - (int) SpoonSession::get('blog_comment_' . $this->record['id']);
// calculate difference, it it isn't 10 seconds the we tell the user to slow down
if ($diff < 10 && $diff != 0) {
$this->frm->getField('message')->addError(FL::err('CommentTimeout'));
}
}
// validate required fields
$this->frm->getField('author')->isFilled(FL::err('AuthorIsRequired'));
$this->frm->getField('email')->isEmail(FL::err('EmailIsRequired'));
$this->frm->getField('message')->isFilled(FL::err('MessageIsRequired'));
// validate optional fields
if ($this->frm->getField('website')->isFilled() && $this->frm->getField('website')->getValue() != 'http://') {
$this->frm->getField('website')->isURL(FL::err('InvalidURL'));
}
// no errors?
if ($this->frm->isCorrect()) {
// get module setting
$spamFilterEnabled = isset($this->settings['spamfilter']) && $this->settings['spamfilter'];
$moderationEnabled = isset($this->settings['moderation']) && $this->settings['moderation'];
// reformat data
$author = $this->frm->getField('author')->getValue();
$email = $this->frm->getField('email')->getValue();
$website = $this->frm->getField('website')->getValue();
if (trim($website) == '' || $website == 'http://') {
$website = null;
}
$text = $this->frm->getField('message')->getValue();
// build array
$comment['post_id'] = $this->record['id'];
$comment['language'] = FRONTEND_LANGUAGE;
$comment['created_on'] = FrontendModel::getUTCDate();
$comment['author'] = $author;
$comment['email'] = $email;
$comment['website'] = $website;
$comment['text'] = $text;
$comment['status'] = 'published';
$comment['data'] = serialize(array('server' => $_SERVER));
// get URL for article
$permaLink = FrontendNavigation::getURLForBlock('blog', 'detail') . '/' . $this->record['url'];
$redirectLink = $permaLink;
// is moderation enabled
if ($moderationEnabled) {
// if the commenter isn't moderated before alter the comment status so it will appear in the moderation queue
if (!FrontendBlogModel::isModerated($author, $email)) {
$comment['status'] = 'moderation';
}
}
// should we check if the item is spam
if ($spamFilterEnabled) {
// check for spam
$result = FrontendModel::isSpam($text, SITE_URL . $permaLink, $author, $email, $website);
// if the comment is spam alter the comment status so it will appear in the spam queue
if ($result) {
$comment['status'] = 'spam';
} elseif ($result == 'unknown') {
$comment['status'] = 'moderation';
}
}
// insert comment
$comment['id'] = FrontendBlogModel::insertComment($comment);
// trigger event
FrontendModel::triggerEvent('blog', 'after_add_comment', array('comment' => $comment));
// append a parameter to the URL so we can show moderation
if (strpos($redirectLink, '?') === false) {
if ($comment['status'] == 'moderation') {
$redirectLink .= '?comment=moderation#' . FL::act('Comment');
}
if ($comment['status'] == 'spam') {
$redirectLink .= '?comment=spam#' . FL::act('Comment');
}
if ($comment['status'] == 'published') {
$redirectLink .= '?comment=true#comment-' . $comment['id'];
}
} else {
if ($comment['status'] == 'moderation') {
$redirectLink .= '&comment=moderation#' . FL::act('Comment');
}
if ($comment['status'] == 'spam') {
$redirectLink .= '&comment=spam#' . FL::act('Comment');
}
if ($comment['status'] == 'published') {
$redirectLink .= '&comment=true#comment-' . $comment['id'];
//.........这里部分代码省略.........