本文整理汇总了PHP中Flash::setNow方法的典型用法代码示例。如果您正苦于以下问题:PHP Flash::setNow方法的具体用法?PHP Flash::setNow怎么用?PHP Flash::setNow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Flash
的用法示例。
在下文中一共展示了Flash::setNow方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: settings
public function settings()
{
$errors = false;
if (get_request_method() == 'POST') {
$data = $_POST['settings'];
$settings = array();
$settings['filemanager_base'] = preg_replace('/\\s+/', '', $data['filemanager_base']);
$settings['filemanager_base'] = trim($settings['filemanager_base'], '/');
$settings['filemanager_view'] = isset($data['filemanager_view']) ? $data['filemanager_view'] : 'grid';
// image extensions
if (isset($data['filemanager_images'])) {
$settings['filemanager_images'] = serialize($data['filemanager_images']);
} else {
$errors[] = __("You need to select at least one image extension!");
}
$settings['filemanager_upload_size'] = !empty($data['filemanager_upload_size']) && is_numeric($data['filemanager_upload_size']) ? $data['filemanager_upload_size'] : '0';
$settings['filemanager_dateformat'] = !empty($data['filemanager_dateformat']) ? trim($data['filemanager_dateformat']) : 'd M Y H:i';
$booleans = array('filemanager_enabled', 'filemanager_browse_only', 'filemanager_upload_overwrite', 'filemanager_upload_images_only');
foreach ($booleans as $bool) {
$settings[$bool] = isset($data[$bool]) && $data[$bool] == 1 ? '1' : '0';
}
if (Plugin::setAllSettings($settings, 'ckeditor')) {
Flash::setNow('success', 'Settings were updated successfully');
} else {
$errors[] = __("There was a problem saving the settings.");
}
} else {
$settings = Plugin::getAllSettings('ckeditor');
}
if ($errors !== false) {
Flash::setNow('error', implode('<br/>', $errors));
}
$this->display('settings', array('settings' => $settings));
}
示例2: update_event
public function update_event()
{
if (!isset($_POST['save'])) {
Flash::set('error', __('Could not update this event!'));
} else {
use_helper('Kses');
/* Prepare the data */
$data = $_POST['event'];
if (isset($data['id'])) {
$data['id'] = kses(trim($data['id']), array());
}
$event = new CalendarEvent();
if (isset($data['id'])) {
$event->id = $data['id'];
$event->created_by_id = $data['created_by_id'];
}
$event->title = $data['title'];
$event->date_from = $data['date_from'];
$event->date_to = $data['date_to'];
$event->description = $data['description'];
/* Check data and, if correct, save to DB */
if ($event->checkData() && $event->save()) {
if (isset($data['id'])) {
Flash::set('success', __('The event has been updated.'));
} else {
Flash::set('success', __('A new event has been created.'));
}
redirect(get_url('plugin/calendar/events'));
} else {
Flash::setNow('error', __('There are errors in the form.'));
$this->display(CALENDAR_VIEWS . '/update', array('event' => $event));
}
}
}
示例3: process_update_post
private function process_update_post(CalendarEvent $old_event)
{
$updating = (bool) $old_event->getId();
if (isset($_POST['save']) && isset($_POST['event'])) {
$post_data = array_map('trim', $_POST['event']);
// validate the data and create error message
$errors = $this->validate_post_data($post_data);
if ($errors) {
Flash::setNow('error', 'There are errors in the form.');
return array('event' => $old_event, 'updating' => $updating, 'post_data' => $post_data, 'errors' => $errors);
}
// if we'are updating an event, some data should be added to $post_data
if ($updating) {
$post_data['id'] = $old_event->getId();
$post_data['created_by_id'] = $old_event->getAuthorID();
}
$updated_event = new CalendarEvent($post_data);
$saved = $updated_event->save();
if ($saved) {
Flash::set('success', $updating ? __('The event has been updated.') : __('A new event has been created.'));
redirect(get_url('plugin/' . CALENDAR_ID . '/events'));
} else {
Flash::setNow('error', __('Could not update this event!'));
return array('event' => $updated_event, 'updating' => $updating);
}
}
// if it's not POST, just return $old_event
return array('event' => $old_event, 'updating' => $updating);
}
示例4: settings
public function settings()
{
if (!$this->_isInternal()) {
page_not_found();
}
$settings = Plugin::getAllSettings('image');
if (!$settings) {
Flash::setNow('error', 'Image - ' . __('unable to retrieve plugin settings.'));
}
if (!isset($settings['path'])) {
$settings['path'] = '';
}
$this->display('image/views/settings', $settings);
}
示例5: _store
//.........这里部分代码省略.........
use_helper('Kses');
$data['title'] = kses(trim($data['title']), array());
}
// Create the page object to be manipulated and populate data
if ($action == 'add') {
$page = new Page($data);
} else {
$page = Record::findByIdFrom('Page', $id);
$page->setFromData($data);
}
// Upon errors, rebuild original page and return to screen with errors
if (false !== $errors) {
$tags = $_POST['page_tag'];
// Rebuild time fields
if (isset($page->created_on)) {
$page->created_on = $page->created_on . ' ' . $page->created_on_time;
}
if (isset($page->published_on)) {
$page->published_on = $page->published_on . ' ' . $page->published_on_time;
}
if (isset($page->valid_until)) {
$page->valid_until = $page->valid_until . ' ' . $page->valid_until_time;
}
// Rebuild parts
$part = $_POST['part'];
if (!empty($part)) {
$tmp = false;
foreach ($part as $key => $val) {
$tmp[$key] = (object) $val;
}
$part = $tmp;
}
// Set the errors to be displayed.
Flash::setNow('error', implode('<br/>', $errors));
// display things ...
$this->setLayout('backend');
$this->display('page/edit', array('action' => $action, 'csrf_token' => SecureToken::generateToken(BASE_URL . 'page/' . $action), 'page' => (object) $page, 'tags' => $tags, 'filters' => Filter::findAll(), 'behaviors' => Behavior::findAll(), 'page_parts' => (object) $part, 'layouts' => Record::findAllFrom('Layout')));
}
// Notify
if ($action == 'add') {
Observer::notify('page_add_before_save', $page);
} else {
Observer::notify('page_edit_before_save', $page);
}
// Time to actually save the page
// @todo rebuild this so parts are already set before save?
// @todo determine lazy init impact
if ($page->save()) {
// Get data for parts of this page
$data_parts = $_POST['part'];
Flash::set('post_parts_data', (object) $data_parts);
if ($action == 'edit') {
$old_parts = PagePart::findByPageId($id);
// check if all old page part are passed in POST
// if not ... we need to delete it!
foreach ($old_parts as $old_part) {
$not_in = true;
foreach ($data_parts as $part_id => $data) {
$data['name'] = trim($data['name']);
if ($old_part->name == $data['name']) {
$not_in = false;
// this will not really create a new page part because
// the id of the part is passed in $data
$part = new PagePart($data);
$part->page_id = $id;
Observer::notify('part_edit_before_save', $part);
示例6: defined
<?php
defined('IN_CMS') || exit;
$images = serialize(array('gif', 'jpg', 'jpeg', 'png'));
$settings = array('version' => '2.1.0', 'filemanager_enabled' => '1', 'filemanager_base' => 'public/images', 'filemanager_view' => 'grid', 'filemanager_images' => $images, 'filemanager_dateformat' => 'd M Y H:i', 'filemanager_browse_only' => '0', 'filemanager_upload_overwrite' => '0', 'filemanager_upload_images_only' => '0', 'filemanager_upload_size' => '0');
$old = Plugin::getAllSettings('ckeditor');
//Other ckeditor filter
if (isset($old['fileBrowserRootUri'])) {
$settings['filemanager_base'] = trim($old['fileBrowserRootUri'], '/');
} else {
if (isset($old['filemanager_base'])) {
$settings = $old;
$settings['version'] = '2.1.0';
}
}
// Remove all settings from db
Plugin::deleteAllSettings('ckeditor');
// Insert the new ones
if (Plugin::setAllSettings($settings, 'ckeditor')) {
Flash::setNow('success', __('CKEditor - plugin settings initialized.'));
}
if (!defined('USE_MOD_REWRITE') || !USE_MOD_REWRITE) {
Flash::set('info', __('FileManager will not ne ebabled if "MOD_REWRITE" is set to false'));
} else {
Flash::setNow('error', __('CKEditor - unable to store plugin settings!'));
}
示例7: settings_save
public function settings_save()
{
AuthUser::load();
if (!AuthUser::isLoggedIn()) {
redirect(get_url('login'));
} else {
if (!AuthUser::hasPermission('admin_edit')) {
Flash::set('error', __('You do not have permission to access the requested page!'));
redirect(get_url());
}
}
if (!isset($_POST['settings'])) {
Flash::set('error', 'File Manager - ' . __('form was not posted.'));
redirect(get_url('plugin/file_manager/settings'));
} else {
$settings = $_POST['settings'];
if ($settings['umask'] == 0) {
$settings['umask'] = 0;
} elseif (!preg_match('/^0?[0-7]{3}$/', $settings['umask'])) {
$settings['umask'] = 0;
}
if (strlen($settings['umask']) === 3) {
$settings['umask'] = '0' . $settings['umask'];
} elseif (strlen($settings['umask']) !== 4 && $settings['umask'] != 0) {
$settings['umask'] = 0;
}
if (!preg_match('/^0?[0-7]{3}$/', $settings['dirmode'])) {
$settings['dirmode'] = '0755';
}
if (strlen($settings['dirmode']) === 3) {
$settings['dirmode'] = '0' . $settings['dirmode'];
}
if (!preg_match('/^0?[0-7]{3}$/', $settings['filemode'])) {
$settings['filemode'] = '0755';
}
if (strlen($settings['filemode']) === 3) {
$settings['filemode'] = '0' . $settings['filemode'];
}
}
if (Plugin::setAllSettings($settings, 'file_manager')) {
Flash::setNow('success', 'File Manager - ' . __('plugin settings saved.'));
} else {
Flash::setNow('error', 'File Manager - ' . __('plugin settings not saved!'));
}
$this->display('file_manager/views/settings', array('settings' => $settings));
}
示例8: _store
//.........这里部分代码省略.........
// Create the page object to be manipulated and populate data
if ($action == 'add') {
$page = new Page($data);
} else {
$page = Record::findByIdFrom('Page', $id);
$page->setFromData($data);
}
// Upon errors, rebuild original page and return to screen with errors
if (false !== $errors || $error_fields !== false) {
$tags = $_POST['page_tag'];
// Rebuild time fields
if (isset($page->created_on) && isset($page->created_on_time)) {
$page->created_on = $page->created_on . ' ' . $page->created_on_time;
}
if (isset($page->published_on) && isset($page->published_on_time)) {
$page->published_on = $page->published_on . ' ' . $page->published_on_time;
}
if (isset($page->valid_until)) {
$page->valid_until = $page->valid_until . ' ' . $page->valid_until_time;
}
// Rebuild parts
$part = '';
if (!empty($_POST['part'])) {
$part = $_POST['part'];
$tmp = false;
foreach ($part as $key => $val) {
$tmp[$key] = (object) $val;
}
$part = $tmp;
}
// Set the errors to be displayed.
$err_msg = $errors != false ? implode('<br/>', $errors) : '';
$err_msg .= $error_fields != false ? '<br />Please specify these fields: ' . implode(', ', $error_fields) : '';
Flash::setNow('error', $err_msg);
//$settingdata = 'aaa';
// display things ...
$this->setLayout('backend');
$pagesettingobj = new stdClass();
foreach ($pagesetting as $name => $value) {
$pagesettingobj->{$name} = $value;
}
$this->display('page/edit', array('action' => $action, 'csrf_token' => SecureToken::generateToken(BASE_URL . 'page/' . $action), 'page' => (object) $page, 'pagesetting' => $pagesettingobj, 'tags' => $tags, 'filters' => Filter::findAll(), 'behaviors' => Behavior::findAll(), 'page_parts' => $part, 'layouts' => Record::findAllFrom('Layout')));
}
// Notify
if ($action == 'add') {
Observer::notify('page_add_before_save', $page);
} else {
Observer::notify('page_edit_before_save', $page);
}
// Time to actually save the page
// @todo rebuild this so parts are already set before save?
// @todo determine lazy init impact
$page->newwindow = !empty($data['newwindow']) ? '1' : '0';
if ($page->save()) {
// Get data for parts of this page
$data_parts = $_POST['part'];
Flash::set('post_parts_data', (object) $data_parts);
if ($action == 'edit') {
$old_parts = PagePart::findByPageId($id);
// check if all old page part are passed in POST
// if not ... we need to delete it!
foreach ($old_parts as $old_part) {
$not_in = true;
foreach ($data_parts as $part_id => $data) {
$data['name'] = trim($data['name']);
if ($old_part->name == $data['name']) {
示例9: _add
private function _add()
{
$data = $_POST['page'];
Flash::set('post_data', (object) $data);
if (empty($data['title'])) {
// Rebuilding original page
$part = $_POST['part'];
if (!empty($part)) {
$tmp = false;
foreach ($part as $key => $val) {
$tmp[$key] = (object) $val;
}
$part = $tmp;
}
$page = $_POST['page'];
if (!empty($page) && !array_key_exists('is_protected', $page)) {
$page = array_merge($page, array('is_protected' => 0));
}
$tags = $_POST['page_tag'];
//Flash::setNow('page', (object) $page);
//Flash::setNow('page_parts', (object) $part);
//Flash::setNow('page_tag', $tags);
Flash::setNow('error', __('You have to specify a title!'));
//redirect(get_url('page/add'));
// display things ...
$this->setLayout('backend');
$this->display('page/edit', array('action' => 'add', 'page' => (object) $page, 'tags' => $tags, 'filters' => Filter::findAll(), 'behaviors' => Behavior::findAll(), 'page_parts' => (object) $part, 'layouts' => Record::findAllFrom('Layout')));
}
/**
* Make sure the title doesn't contain HTML
*
* @todo Replace this by HTML Purifier?
*/
if (Setting::get('allow_html_title') == 'off') {
use_helper('Kses');
$data['title'] = kses(trim($data['title']), array());
}
$page = new Page($data);
// save page data
if ($page->save()) {
// get data from user
$data_parts = $_POST['part'];
Flash::set('post_parts_data', (object) $data_parts);
foreach ($data_parts as $data) {
$data['page_id'] = $page->id;
$data['name'] = trim($data['name']);
$page_part = new PagePart($data);
$page_part->save();
}
// save tags
$page->setTags($_POST['page_tag']['tags']);
Flash::set('success', __('Page has been saved!'));
} else {
Flash::set('error', __('Page has not been saved!'));
redirect(get_url('page/add'));
}
// save and quit or save and continue editing ?
if (isset($_POST['commit'])) {
redirect(get_url('page'));
} else {
redirect(get_url('page/edit/' . $page->id));
}
}
示例10: settings_save
public function settings_save()
{
AuthUser::load();
if (!AuthUser::isLoggedIn()) {
redirect(get_url('login'));
} else {
if (!AuthUser::hasPermission('admin_edit')) {
Flash::set('error', __('You do not have permission to access the requested page!'));
redirect(get_url());
}
}
if (!isset($_POST['settings'])) {
Flash::set('error', 'File Manager - ' . __('form was not posted.'));
redirect(get_url('plugin/shopping_cart/settings'));
} else {
$settings = $_POST['settings'];
// add implementation
}
if (Plugin::setAllSettings($settings, 'shopping_cart')) {
Flash::setNow('success', 'Shopping Cart - ' . __('plugin settings saved.'));
} else {
Flash::setNow('error', 'Shopping Cart - ' . __('plugin settings not saved!'));
}
$this->display('shopping_cart/views/settings', array('settings' => $settings));
}