本文整理汇总了PHP中SpoonFilter类的典型用法代码示例。如果您正苦于以下问题:PHP SpoonFilter类的具体用法?PHP SpoonFilter怎么用?PHP SpoonFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SpoonFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Execute the action
*/
public function execute()
{
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// action to execute
$id = SpoonFilter::getGetValue('id', null, 0);
// no id's provided
if (empty($id) || !BackendMailmotorModel::existsMailing($id)) {
$this->redirect(BackendModel::createURLForAction('index') . '&error=mailing-does-not-exist');
} else {
// get the mailing and reset some fields
$mailing = BackendMailmotorModel::getMailing($id);
$mailing['status'] = 'concept';
$mailing['send_on'] = null;
$mailing['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
$mailing['edited_on'] = $mailing['created_on'];
$mailing['data'] = serialize($mailing['data']);
unset($mailing['recipients'], $mailing['id'], $mailing['cm_id'], $mailing['send_on_raw']);
// set groups
$groups = $mailing['groups'];
unset($mailing['groups']);
// create a new mailing based on the old one
$newId = BackendMailmotorModel::insertMailing($mailing);
// update groups for this mailing
BackendMailmotorModel::updateGroupsForMailing($newId, $groups);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_copy_mailing', array('item' => $mailing));
}
// redirect
$this->redirect(BackendModel::createURLForAction('index') . '&report=mailing-copied&var=' . $mailing['name']);
}
示例2: parse
/**
* Parse the form
*/
protected function parse()
{
parent::parse();
// prevent XSS
$filter = \SpoonFilter::arrayMapRecursive('htmlspecialchars', $this->filter);
$this->tpl->assign($filter);
}
示例3: parse
/**
* Parse the correct messages into the template
*/
protected function parse()
{
parent::parse();
// grab the error-type from the parameters
$errorType = $this->getParameter('type');
// set correct headers
switch ($errorType) {
case 'module-not-allowed':
case 'action-not-allowed':
SpoonHTTP::setHeadersByCode(403);
break;
case 'not-found':
SpoonHTTP::setHeadersByCode(404);
break;
}
// querystring provided?
if ($this->getParameter('querystring') !== null) {
// split into file and parameters
$chunks = explode('?', $this->getParameter('querystring'));
// get extension
$extension = SpoonFile::getExtension($chunks[0]);
// if the file has an extension it is a non-existing-file
if ($extension != '' && $extension != $chunks[0]) {
// set correct headers
SpoonHTTP::setHeadersByCode(404);
// give a nice error, so we can detect which file is missing
echo 'Requested file (' . htmlspecialchars($this->getParameter('querystring')) . ') not found.';
// stop script execution
exit;
}
}
// assign the correct message into the template
$this->tpl->assign('message', BL::err(SpoonFilter::toCamelCase(htmlspecialchars($errorType), '-')));
}
示例4: loadForm
/**
* Loads the settings form
*/
private function loadForm()
{
// init settings form
$this->frm = new BackendForm('settings');
// get current settings
$this->settings = BackendSearchModel::getModuleSettings();
// add field for pagination
$this->frm->addDropdown('overview_num_items', array_combine(range(1, 30), range(1, 30)), BackendModel::getModuleSetting($this->URL->getModule(), 'overview_num_items', 20));
$this->frm->addDropdown('autocomplete_num_items', array_combine(range(1, 30), range(1, 30)), BackendModel::getModuleSetting($this->URL->getModule(), 'autocomplete_num_items', 20));
$this->frm->addDropdown('autosuggest_num_items', array_combine(range(1, 30), range(1, 30)), BackendModel::getModuleSetting($this->URL->getModule(), 'autosuggest_num_items', 20));
// modules that, no matter what, can not be searched
$disallowedModules = array('search');
// loop modules
foreach (BackendModel::getModulesForDropDown() as $module => $label) {
// check if module is searchable
if (!in_array($module, $disallowedModules) && is_callable(array('Frontend' . SpoonFilter::toCamelCase($module) . 'Model', 'search'))) {
// add field to decide wether or not this module is searchable
$this->frm->addCheckbox('search_' . $module, isset($this->settings[$module]) ? $this->settings[$module]['searchable'] == 'Y' : false);
// add field to decide weight for this module
$this->frm->addText('search_' . $module . '_weight', isset($this->settings[$module]) ? $this->settings[$module]['weight'] : 1);
// field disabled?
if (!isset($this->settings[$module]) || $this->settings[$module]['searchable'] != 'Y') {
$this->frm->getField('search_' . $module . '_weight')->setAttribute('disabled', 'disabled');
$this->frm->getField('search_' . $module . '_weight')->setAttribute('class', 'inputText disabled');
}
// add to list of modules
$this->modules[] = array('module' => $module, 'id' => $this->frm->getField('search_' . $module)->getAttribute('id'), 'label' => $label, 'chk' => $this->frm->getField('search_' . $module)->parse(), 'txt' => $this->frm->getField('search_' . $module . '_weight')->parse(), 'txtError' => '');
}
}
}
示例5: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// get parameters
$formId = \SpoonFilter::getPostValue('form_id', null, '', 'int');
$newIdSequence = trim(\SpoonFilter::getPostValue('new_id_sequence', null, '', 'string'));
// invalid form id
if (!BackendFormBuilderModel::exists($formId)) {
$this->output(self::BAD_REQUEST, null, 'form does not exist');
} else {
// list id
$ids = (array) explode('|', rtrim($newIdSequence, '|'));
// loop id's and set new sequence
foreach ($ids as $i => $id) {
$id = (int) $id;
// get field
$field = BackendFormBuilderModel::getField($id);
// from this form and not a submit button
if (!empty($field) && $field['form_id'] == $formId && $field['type'] != 'submit') {
BackendFormBuilderModel::updateField($id, array('sequence' => $i + 1));
}
}
$this->output(self::OK, null, 'sequence updated');
}
}
示例6: execute
/**
* Execute the action
*/
public function execute()
{
// call parent, this will probably add some general CSS/JS or other required files
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);
$limit = (int) $this->get('fork.settings')->get('Search', 'autocomplete_num_items', 10);
// validate
if ($term == '') {
$this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
} else {
// get matches
$matches = FrontendSearchModel::getStartsWith($term, FRONTEND_LANGUAGE, $limit);
// get search url
$url = FrontendNavigation::getURLForBlock('Search');
// loop items and set search url
foreach ($matches as &$match) {
$match['url'] = $url . '?form=search&q=' . $match['term'];
}
// output
$this->output(self::OK, $matches);
}
}
示例7: execute
/**
* Execute the action
*
* @return void
*/
public function execute()
{
// get parameters
$this->id = $this->getParameter('id', 'int');
// does the item exist
if ($this->id !== null && BackendBlogModel::exists($this->id)) {
// call parent, this will probably add some general CSS/JS or other required files
parent::execute();
// set category id
$this->categoryId = SpoonFilter::getGetValue('category', null, null, 'int');
if ($this->categoryId == 0) {
$this->categoryId = null;
}
// get data
$this->record = (array) BackendBlogModel::get($this->id);
// delete item
BackendBlogModel::delete($this->id);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_delete', array('id' => $this->id));
// delete search indexes
if (is_callable(array('BackendSearchModel', 'removeIndex'))) {
BackendSearchModel::removeIndex($this->getModule(), $this->id);
}
// build redirect URL
$redirectUrl = BackendModel::createURLForAction('index') . '&report=deleted&var=' . urlencode($this->record['title']);
// append to redirect URL
if ($this->categoryId != null) {
$redirectUrl .= '&category=' . $this->categoryId;
}
// item was deleted, so redirect
$this->redirect($redirectUrl);
} else {
$this->redirect(BackendModel::createURLForAction('index') . '&error=non-existing');
}
}
示例8: 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);
}
}
示例9: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// action to execute
$action = SpoonFilter::getGetValue('action', array('delete', 'export'), '');
$this->groupId = SpoonFilter::getGetValue('group_id', null, '');
// no id's provided
if (!$action) {
$this->redirect(BackendModel::createURLForAction('addresses') . '&error=no-action-selected');
}
if (!isset($_GET['emails'])) {
$this->redirect(BackendModel::createURLForAction('addresses') . '&error=no-items-selected');
} else {
// redefine id's
$this->emails = (array) $_GET['emails'];
// evaluate $action, see what action was triggered
switch ($action) {
case 'delete':
$this->deleteAddresses();
break;
case 'export':
$this->exportAddresses();
break;
}
}
}
示例10: parse
/**
* Parse the data into the template
*/
private function parse()
{
// get vars
$title = \SpoonFilter::ucfirst(FL::msg('BlogAllComments'));
$link = SITE_URL . FrontendNavigation::getURLForBlock('Blog');
$detailLink = SITE_URL . FrontendNavigation::getURLForBlock('Blog', 'Detail');
$description = null;
// create new rss instance
$rss = new FrontendRSS($title, $link, $description);
// loop articles
foreach ($this->items as $item) {
// init vars
$title = $item['author'] . ' ' . FL::lbl('On') . ' ' . $item['post_title'];
$link = $detailLink . '/' . $item['post_url'] . '/#comment-' . $item['id'];
$description = $item['text'];
// create new instance
$rssItem = new FrontendRSSItem($title, $link, $description);
// set item properties
$rssItem->setPublicationDate($item['created_on']);
$rssItem->setAuthor($item['author']);
// add item
$rss->addItem($rssItem);
}
$rss->parse();
}
示例11: 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
$id = SpoonFilter::getPostValue('id', null, '', 'int');
$name = trim(SpoonFilter::getPostValue('value', null, '', 'string'));
// validate
if ($name == '') {
$this->output(self::BAD_REQUEST, null, 'no name provided');
}
// get existing id
$existingId = BackendMailmotorModel::getCampaignId($name);
// existing campaign
if ($existingId !== 0 && $id !== $existingId) {
$this->output(self::ERROR, array('id' => $existingId, 'error' => true), BL::err('CampaignExists', $this->getModule()));
}
// build array
$item = array();
$item['id'] = $id;
$item['name'] = $name;
$item['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
// get page
$rows = BackendMailmotorModel::updateCampaign($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'edited_campaign', array('item' => $item));
// output
if ($rows !== 0) {
$this->output(self::OK, array('id' => $id), BL::msg('CampaignEdited', $this->getModule()));
} else {
$this->output(self::ERROR, null, BL::err('CampaignNotEdited', $this->getModule()));
}
}
示例12: 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') : '');
}
示例13: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// get parameters
$mailingId = SpoonFilter::getPostValue('mailing_id', null, '', 'int');
$sendOnDate = SpoonFilter::getPostValue('send_on_date', null, BackendModel::getUTCDate('d/m/Y'));
$sendOnTime = SpoonFilter::getPostValue('send_on_time', null, BackendModel::getUTCDate('H:i'));
$messageDate = $sendOnDate;
// validate mailing ID
if ($mailingId == '') {
$this->output(self::BAD_REQUEST, null, 'Provide a valid mailing ID');
}
if ($sendOnDate == '' || $sendOnTime == '') {
$this->output(self::BAD_REQUEST, null, 'Provide a valid send date date provided');
}
// record is empty
if (!BackendMailmotorModel::existsMailing($mailingId)) {
$this->output(self::BAD_REQUEST, null, BL::err('MailingDoesNotExist', 'mailmotor'));
}
// reverse the date and make it a proper
$explodedDate = explode('/', $sendOnDate);
$sendOnDate = $explodedDate[2] . '-' . $explodedDate[1] . '-' . $explodedDate[0];
// calc full send timestamp
$sendTimestamp = strtotime($sendOnDate . ' ' . $sendOnTime);
// build data
$item['id'] = $mailingId;
$item['send_on'] = BackendModel::getUTCDate('Y-m-d H:i:s', $sendTimestamp);
$item['edited_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
// update mailing
BackendMailmotorModel::updateMailing($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_edit_mailing_step4', array('item' => $item));
// output
$this->output(self::OK, array('mailing_id' => $mailingId, 'timestamp' => $sendTimestamp), sprintf(BL::msg('SendOn', $this->getModule()), $messageDate, $sendOnTime));
}
示例14: __construct
public function __construct()
{
// define the Named Application
if (!defined('NAMED_APPLICATION')) {
define('NAMED_APPLICATION', 'backend');
}
// set the module
$this->setModule(SpoonFilter::getGetValue('module', null, ''));
// set the requested file
$this->setFile(SpoonFilter::getGetValue('file', null, ''));
// set the language
$this->setLanguage(SpoonFilter::getGetValue('language', array_keys(BackendLanguage::getWorkingLanguages()), SITE_DEFAULT_LANGUAGE));
// build the path
if ($this->module == 'core') {
$path = BACKEND_CORE_PATH . '/js/' . $this->getFile();
} else {
$path = BACKEND_MODULES_PATH . '/' . $this->getModule() . '/js/' . $this->getFile();
}
// set correct headers
SpoonHTTP::setHeaders('content-type: application/javascript');
// create a new template instance (this will handle all stuff for us)
$tpl = new BackendTemplate();
// enable addslashes on each locale
$tpl->setAddSlashes(true);
// display
$tpl->display($path, true);
}
示例15: parse
/**
* Parse the data into the template
*/
private function parse()
{
// form was sent?
if ($this->URL->getParameter('sent') == 'true') {
// show message
$this->tpl->assign('unsubscribeIsSuccess', true);
// hide form
$this->tpl->assign('unsubscribeHideForm', true);
}
// unsubscribe was issued for a specific group/address
if (SpoonFilter::isEmail($this->email) && FrontendMailmotorModel::existsGroup($this->group)) {
// unsubscribe the address from this group
if (FrontendMailmotorModel::unsubscribe($this->email, $this->group)) {
// hide form
$this->tpl->assign('unsubscribeHideForm', true);
// show message
$this->tpl->assign('unsubscribeIsSuccess', true);
} else {
// show message
$this->tpl->assign('unsubscribeHasError', true);
}
}
// parse the form
$this->frm->parse($this->tpl);
}