本文整理汇总了PHP中Notify::warning方法的典型用法代码示例。如果您正苦于以下问题:PHP Notify::warning方法的具体用法?PHP Notify::warning怎么用?PHP Notify::warning使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notify
的用法示例。
在下文中一共展示了Notify::warning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
/**
* Removes an item
*/
function delete()
{
// Check for request forgeries
Session::checkToken() or exit(Lang::txt('JINVALID_TOKEN'));
// Initialise variables.
$ids = Request::getVar('cid', array(), '', 'array');
// Access checks.
foreach ($ids as $i => $id) {
if (!User::authorise('core.delete', 'com_content.article.' . (int) $id)) {
// Prune items that you can't delete.
unset($ids[$i]);
Notify::warning(Lang::txt('JERROR_CORE_DELETE_NOT_PERMITTED'));
}
}
if (empty($ids)) {
Notify::error(Lang::txt('JERROR_NO_ITEMS_SELECTED'));
} else {
// Get the model.
$model = $this->getModel();
// Remove the items.
if (!$model->featured($ids, 0)) {
throw new Exception($model->getError(), 500);
}
}
$this->setRedirect('index.php?option=com_content&view=featured');
}
示例2: delete
/**
* Method to delete rows.
*
* @param array An array of item ids.
*
* @return boolean Returns true on success, false on failure.
*/
public function delete(&$pks)
{
// Initialise variables.
$pks = (array) $pks;
$table = $this->getTable();
// Iterate the items to delete each one.
foreach ($pks as $i => $pk) {
if ($table->load($pk)) {
// Access checks.
if (!User::authorise('core.delete', 'com_templates')) {
throw new Exception(Lang::txt('JERROR_CORE_DELETE_NOT_PERMITTED'));
}
// You should not delete a default style
if ($table->home != '0') {
Notify::warning(Lang::txt('COM_TEMPLATES_STYLE_CANNOT_DELETE_DEFAULT_STYLE'));
return false;
}
if (!$table->delete($pk)) {
$this->setError($table->getError());
return false;
}
} else {
$this->setError($table->getError());
return false;
}
}
// Clean cache
$this->cleanCache();
return true;
}
示例3: featured
/**
* Method to toggle the featured setting of a list of articles.
*
* @return void
* @since 1.6
*/
function featured()
{
// Check for request forgeries
Session::checkToken() or exit(Lang::txt('JINVALID_TOKEN'));
// Initialise variables.
$ids = Request::getVar('cid', array(), '', 'array');
$values = array('featured' => 1, 'unfeatured' => 0);
$task = $this->getTask();
$value = \Hubzero\Utility\Arr::getValue($values, $task, 0, 'int');
// Access checks.
foreach ($ids as $i => $id) {
if (!$user->authorise('core.edit.state', 'com_content.article.' . (int) $id)) {
// Prune items that you can't change.
unset($ids[$i]);
Notify::warning(Lang::txt('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
}
}
if (empty($ids)) {
Notify::error(Lang::txt('JERROR_NO_ITEMS_SELECTED'));
} else {
// Get the model.
$model = $this->getModel();
// Publish the items.
if (!$model->featured($ids, $value)) {
throw new Exception($model->getError(), 500);
}
}
$this->setRedirect('index.php?option=com_content&view=articles');
}
示例4: onContentBeforeDelete
/**
* Don't allow categories to be deleted if they contain items or subcategories with items
*
* @param string $context The context for the content passed to the plugin.
* @param object $data The data relating to the content that was deleted.
* @return boolean
*/
public function onContentBeforeDelete($context, $data)
{
// Skip plugin if we are deleting something other than categories
if ($context != 'com_categories.category') {
return true;
}
// Check if this function is enabled.
if (!$this->params->def('check_categories', 1)) {
return true;
}
$extension = Request::getString('extension');
// Default to true if not a core extension
$result = true;
$tableInfo = array('com_content' => array('table_name' => '#__content'), 'com_newsfeeds' => array('table_name' => '#__newsfeeds'));
// Now check to see if this is a known core extension
if (isset($tableInfo[$extension])) {
// Get table name for known core extensions
$table = $tableInfo[$extension]['table_name'];
// See if this category has any content items
$count = $this->_countItemsInCategory($table, $data->get('id'));
// Return false if db error
if ($count === false) {
$result = false;
} else {
// Show error if items are found in the category
if ($count > 0) {
$msg = Lang::txt('COM_CATEGORIES_DELETE_NOT_ALLOWED', $data->get('title')) . Lang::txts('COM_CATEGORIES_N_ITEMS_ASSIGNED', $count);
Notify::warning(403, $msg);
$result = false;
}
// Check for items in any child categories (if it is a leaf, there are no child categories)
if (!$data->isLeaf()) {
$count = $this->_countItemsInChildren($table, $data->get('id'), $data);
if ($count === false) {
$result = false;
} elseif ($count > 0) {
$msg = Lang::txt('COM_CATEGORIES_DELETE_NOT_ALLOWED', $data->get('title')) . Lang::txts('COM_CATEGORIES_HAS_SUBCATEGORY_ITEMS', $count);
Notify::warning(403, $msg);
$result = false;
}
}
}
return $result;
}
}
示例5: display
/**
* Display the view
*/
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->preview = Component::params('com_templates')->get('template_positions_display');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
App::abort(500, implode("\n", $errors));
return false;
}
// Check if there are no matching items
if (!count($this->items)) {
Notify::warning(Lang::txt('COM_TEMPLATES_MSG_MANAGE_NO_STYLES'));
}
$this->addToolbar();
parent::display($tpl);
}
示例6: display
/**
* Display the view
*/
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
throw new Exception(implode("\n", $errors), 500, E_ERROR);
return false;
}
// Check if there are no matching items
if (!count($this->items)) {
Notify::warning(Lang::txt('COM_MODULES_MSG_MANAGE_NO_MODULES'));
}
$this->addToolbar();
// Include the component HTML helpers.
Html::addIncludePath(JPATH_COMPONENT . '/helpers/html');
parent::display($tpl);
}
示例7: getForm
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
* @return JForm A JForm object on success, false on failure
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Codemirror or Editor None should be enabled
$db = App::get('db');
$query = $db->getQuery(true);
$query->select('COUNT(*)');
$query->from('#__extensions as a');
$query->where('(a.name =' . $db->quote('plg_editors_codemirror') . ' AND a.enabled = 1) OR (a.name =' . $db->quote('plg_editors_none') . ' AND a.enabled = 1)');
$db->setQuery($query);
$state = $db->loadResult();
if ((int) $state < 1) {
Notify::warning(Lang::txt('COM_TEMPLATES_ERROR_EDITOR_DISABLED'));
}
// Get the form.
$form = $this->loadForm('com_templates.source', 'source', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
示例8: save
/**
* Method to save a user's profile data.
*
* @return void
* @since 1.6
*/
public function save()
{
// Check for request forgeries.
Session::checkToken() or exit(Lang::txt('JINVALID_TOKEN'));
// Initialise variables.
$app = JFactory::getApplication();
$model = $this->getModel('Profile', 'UsersModel');
$user = User::getRoot();
$userId = (int) $user->get('id');
// Get the user data.
$data = Request::getVar('jform', array(), 'post', 'array');
// Force the ID to this user.
$data['id'] = $userId;
// Validate the posted data.
$form = $model->getForm();
if (!$form) {
App::abort(500, $model->getError());
return false;
}
// Validate the posted data.
$data = $model->validate($form, $data);
// Check for errors.
if ($data === false) {
// Get the validation messages.
$errors = $model->getErrors();
// Push up to three validation messages out to the user.
for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) {
if ($errors[$i] instanceof Exception) {
Notify::warning($errors[$i]->getMessage());
} else {
Notify::warning($errors[$i]);
}
}
// Save the data in the session.
$app->setUserState('com_users.edit.profile.data', $data);
// Redirect back to the edit screen.
$userId = (int) User::setState('com_users.edit.profile.id');
$this->setRedirect(Route::url('index.php?option=com_users&view=profile&layout=edit&user_id=' . $userId, false));
return false;
}
// Attempt to save the data.
$return = $model->save($data);
// Check for errors.
if ($return === false) {
// Save the data in the session.
User::setState('com_users.edit.profile.data', $data);
// Redirect back to the edit screen.
$userId = (int) User::getState('com_users.edit.profile.id');
$this->setMessage(Lang::txt('COM_USERS_PROFILE_SAVE_FAILED', $model->getError()), 'warning');
$this->setRedirect(Route::url('index.php?option=com_users&view=profile&layout=edit&user_id=' . $userId, false));
return false;
}
// Redirect the user and adjust session state based on the chosen task.
switch ($this->getTask()) {
case 'apply':
// Check out the profile.
User::setState('com_users.edit.profile.id', $return);
$model->checkout($return);
// Redirect back to the edit screen.
$this->setMessage(Lang::txt('COM_USERS_PROFILE_SAVE_SUCCESS'));
$this->setRedirect(Route::url(($redirect = User::getState('com_users.edit.profile.redirect')) ? $redirect : 'index.php?option=com_users&view=profile&layout=edit&hidemainmenu=1', false));
break;
default:
// Check in the profile.
$userId = (int) User::getState('com_users.edit.profile.id');
if ($userId) {
$model->checkin($userId);
}
// Clear the profile id from the session.
User::setState('com_users.edit.profile.id', null);
// Redirect to the list screen.
$this->setMessage(Lang::txt('COM_USERS_PROFILE_SAVE_SUCCESS'));
$this->setRedirect(Route::url(($redirect = User::getState('com_users.edit.profile.redirect')) ? $redirect : 'index.php?option=com_users&view=profile&user_id=' . $return, false));
break;
}
// Flush the data from the session.
User::setState('com_users.edit.profile.data', null);
}
示例9: do_comment_construct
function do_comment_construct()
{
$config = Config::get();
$speak = Config::speak();
if ($config->page_type === 'article') {
$comment_id = 'comment-%d';
// Your comment ID
$comment_form_id = 'comment-form';
// Your comment form ID
$article = isset($config->article->path) ? $config->article : false;
$G = array('data' => array('article' => Mecha::A($article), 'comment_id' => $comment_id, 'comment_form_id' => $comment_form_id));
if ($article !== false && ($request = Request::post())) {
if ($task = File::exist(SHIELD . DS . $config->shield . DS . 'workers' . DS . 'task.comment.php')) {
require $task;
// Custom comment constructor
} else {
// Check token
Guardian::checkToken($request['token'], $article->url . '#' . $comment_form_id);
$extension = $config->comments->moderation && !Guardian::happy() ? '.hold' : '.txt';
// Check name
if (trim($request['name']) === "") {
Notify::error(Config::speak('notify_error_empty_field', $speak->name));
}
// Check email
if (trim($request['email']) !== "") {
if (!Guardian::check($request['email'], '->email')) {
Notify::error($speak->notify_invalid_email);
} else {
// Disallow passenger(s) from entering your email address in the comment email field
if (!Guardian::happy() && $request['email'] === $config->author->email) {
Notify::warning(Config::speak('notify_warning_forbidden_input', array('<em>' . $request['email'] . '</em>', strtolower($speak->email))));
}
}
} else {
Notify::error(Config::speak('notify_error_empty_field', $speak->email));
}
// Check URL
if (trim($request['url']) !== "" && !Guardian::check($request['url'], '->url')) {
Notify::error($speak->notify_invalid_url);
}
// Check message
if (trim($request['message']) === "") {
Notify::error(Config::speak('notify_error_empty_field', $speak->message));
}
// Check challenge
if (!Guardian::checkMath($request['math'])) {
Notify::error($speak->notify_invalid_math_answer);
}
// Check name length
if (Guardian::check($request['name'], '->too_long', 100)) {
Notify::error(Config::speak('notify_error_too_long', $speak->name));
}
// Check email length
if (Guardian::check($request['email'], '->too_long', 100)) {
Notify::error(Config::speak('notify_error_too_long', $speak->email));
}
// Check URL length
if (Guardian::check($request['url'], '->too_long', 100)) {
Notify::error(Config::speak('notify_error_too_long', $speak->url));
}
// Check message length
if (Guardian::check($request['message'], '->too_long', 1700)) {
Notify::error(Config::speak('notify_error_too_long', $speak->message));
}
// Check for spam keyword(s) in comment
$fucking_words = explode(',', $config->keywords_spam);
foreach ($fucking_words as $spam) {
if ($fuck = trim($spam)) {
if ($request['email'] === $fuck || strpos(strtolower($request['message']), strtolower($fuck)) !== false) {
Notify::warning($speak->notify_warning_intruder_detected . ' <strong class="text-error pull-right">' . $fuck . '</strong>');
break;
}
}
}
if (!Notify::errors()) {
$post = Date::slug($article->time);
$id = (int) time();
$parent = Request::post('parent');
$P = array('data' => $request);
$P['data']['id'] = $id;
$name = strip_tags($request['name']);
$email = Text::parse($request['email'], '->broken_entity');
$url = isset($request['url']) && trim($request['url']) !== "" ? $request['url'] : false;
$parser = strip_tags(Request::post('content_type', $config->html_parser->active));
$message = Text::parse($request['message'], '->text', WISE_CELL . '<img>', false);
$field = Request::post('fields', array());
include File::D(__DIR__, 2) . DS . 'task.fields.php';
// Temporarily disallow image(s) in comment to prevent XSS
$message = preg_replace('#<img(\\s[^<>]*?)>#i', '<img$1>', $message);
Page::header(array('Name' => $name, 'Email' => $email, 'URL' => $url, 'Status' => Guardian::happy() ? 1 : 2, 'Content Type' => $parser, 'Fields' => !empty($field) ? Text::parse($field, '->encoded_json') : false))->content($message)->saveTo(COMMENT . DS . $post . '_' . Date::slug($id) . '_' . ($parent ? Date::slug($parent) : '0000-00-00-00-00-00') . $extension);
Notify::success(Config::speak('notify_success_submitted', $speak->comment));
if ($extension === '.hold') {
Notify::info($speak->notify_info_comment_moderation);
}
Weapon::fire(array('on_comment_update', 'on_comment_construct'), array($G, $P));
Guardian::kick($config->url_current . $config->ur_query . (!Guardian::happy() && $config->comments->moderation ? '#' . $comment_form_id : '#' . sprintf($comment_id, Date::format($id, 'U'))));
} else {
Guardian::kick($config->url_current . $config->url_query . '#' . $comment_form_id);
}
}
//.........这里部分代码省略.........
示例10: processAction
/**
* Process import selections
*
* @return void
*/
private function processAction()
{
// Check if they're logged in
if (User::isGuest()) {
return $this->loginAction();
}
if (!$this->params->get('access-manage')) {
throw new Exception(Lang::txt('PLG_MEMBERS_CITATIONS_NOT_AUTHORIZED'), 403);
}
Request::checkToken();
$cites_require_attention = $this->importer->readRequiresAttention();
$cites_require_no_attention = $this->importer->readRequiresNoAttention();
// action for citations needing attention
$citations_action_attention = Request::getVar('citation_action_attention', array());
// action for citations needing no attention
$citations_action_no_attention = Request::getVar('citation_action_no_attention', array());
// check to make sure we have citations
if (!$cites_require_attention && !$cites_require_no_attention) {
App::redirect(Route::url($this->member->getLink() . '&active=' . $this->_name . '&action=import'), Lang::txt('PLG_MEMBERS_CITATIONS_IMPORT_MISSING_FILE_CONTINUE'), 'error');
return;
}
// vars
$allow_tags = "yes";
$allow_badges = "yes";
$this->importer->set('user', User::get('id'));
$this->importer->setTags($allow_tags == 'yes');
$this->importer->setBadges($allow_badges == 'yes');
$this->importer->set('scope_id', $this->member->get('uidNumber'));
$this->importer->set('scope', 'member');
// Process
$results = $this->importer->process($citations_action_attention, $citations_action_no_attention);
// success message a redirect
Notify::success(Lang::txt('PLG_MEMBERS_CITATIONS_IMPORT_RESULTS_SAVED', count($results['saved'])), 'plg_citations');
// if we have citations not getting saved
if (count($results['not_saved']) > 0) {
Notify::warning(Lang::txt('PLG_MEMBERS_CITATIONS_IMPORT_RESULTS_NOT_SAVED', count($results['not_saved'])), 'plg_citations');
}
if (count($results['error']) > 0) {
Notify::error(Lang::txt('PLG_MEMBERS_CITATIONS_IMPORT_RESULTS_SAVE_ERROR', count($results['error'])), 'plg_citations');
}
//get the session object
$session = App::get('session');
//ids of sessions saved and not saved
$session->set('citations_saved', $results['saved']);
$session->set('citations_not_saved', $results['not_saved']);
$session->set('citations_error', $results['error']);
//delete the temp files that hold citation data
$this->importer->cleanup(true);
//redirect
App::redirect(Route::url($this->member->getLink() . '&active=' . $this->_name . '&action=saved'));
}
示例11: approve
/**
* Method to approve user records.
*
* @param array &$pks The ids of the items to approve.
*
* @return boolean True on success.
*/
function approve(&$pks)
{
// Check if I am a Super Admin
$iAmSuperAdmin = User::authorise('core.admin');
$table = $this->getTable();
$pks = (array) $pks;
// Access checks.
foreach ($pks as $i => $pk) {
if ($table->load($pk)) {
$old = $table->getProperties();
$allow = User::authorise('core.edit.state', 'com_users');
// Don't allow non-super-admin to delete a super admin
$allow = !$iAmSuperAdmin && JAccess::check($pk, 'core.admin') ? false : $allow;
if ($allow) {
$table->approved = 1;
// Allow an exception to be thrown.
try {
if (!$table->check()) {
$this->setError($table->getError());
return false;
}
// Trigger the onUserBeforeSave event.
$result = Event::trigger('user.onUserBeforeSave', array($old, false, $table->getProperties()));
if (in_array(false, $result, true)) {
// Plugin will have to raise it's own error or throw an exception.
return false;
}
// Store the table.
if (!$table->store()) {
$this->setError($table->getError());
return false;
}
// Fire the onAftereStoreUser event
Event::trigger('user.onUserAfterSave', array($table->getProperties(), false, true, null));
} catch (Exception $e) {
$this->setError($e->getMessage());
return false;
}
} else {
// Prune items that you can't change.
unset($pks[$i]);
Notify::warning(Lang::txt('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
}
}
}
return true;
}
示例12: copy
/**
* Method to check if new template name already exists
*
* @return boolean true if name is not used, false otherwise
* @since 2.5
*/
public function copy()
{
if ($template = $this->getTemplate()) {
$client = JApplicationHelper::getClientInfo($template->client_id);
$fromPath = Filesystem::cleanPath($client->path . '/templates/' . $template->element . '/');
// Delete new folder if it exists
$toPath = $this->getState('to_path');
if (Filesystem::exists($toPath)) {
if (!Filesystem::deleteDirectory($toPath)) {
Notify::warning(Lang::txt('COM_TEMPLATES_ERROR_COULD_NOT_WRITE'));
return false;
}
}
// Copy all files from $fromName template to $newName folder
if (!Filesystem::copyDirectory($fromPath, $toPath) || !$this->fixTemplateName()) {
return false;
}
return true;
} else {
Notify::warning(Lang::txt('COM_TEMPLATES_ERROR_INVALID_FROM_NAME'));
return false;
}
}
示例13: removeTask
/**
* Remove an entry
*
* @return void
*/
public function removeTask()
{
// Incoming
$step = Request::getInt('step', 1);
$step = !$step ? 1 : $step;
// What step are we on?
switch ($step) {
case 1:
Request::setVar('hidemainmenu', 1);
// Incoming
$id = Request::getVar('id', array(0));
if (!is_array($id) && !empty($id)) {
$id = array($id);
}
$this->view->ogId = $id;
// Set any errors
if ($this->getError()) {
$this->view->setError($this->getError());
}
// Output the HTML
$this->view->display();
break;
case 2:
// Check for request forgeries
Request::checkToken() or jexit('Invalid Token');
// Incoming
$ogIds = Request::getVar('ogId', 0);
//print_r($ogIds); die;
// Make sure we have ID(s) to work with
if (empty($ogIds)) {
App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=dispaly', false), Lang::txt('COM_STOREFRONT_NO_ID'), 'error');
return;
}
$delete = Request::getVar('delete', 0);
$msg = "Delete canceled";
$type = 'error';
if ($delete) {
// Do the delete
$obj = new Archive();
$warnings = array();
foreach ($ogIds as $ogId) {
// Delete option group
try {
$optionGroup = new OptionGroup($ogId);
$optionGroup->delete();
// see if there are any warnings to display
if ($optionGroupWarnings = $optionGroup->getMessages()) {
foreach ($optionGroupWarnings as $optionGroupWarning) {
if (!in_array($optionGroupWarning, $warnings)) {
$warnings[] = $optionGroupWarning;
}
}
}
} catch (\Exception $e) {
App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=dispaly', false), $e->getMessage(), $type);
return;
}
}
$msg = "Option group(s) deleted";
$type = 'message';
}
// Set the redirect
App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=dispaly', false), $msg, $type);
if ($warnings) {
foreach ($warnings as $warning) {
\Notify::warning($warning);
}
}
break;
}
}
示例14: function
* -----------
*/
Route::accept($config->manager->slug . '/menu/kill/key:(:any)', function ($key = false) use($config, $speak) {
if (!Guardian::happy(1)) {
Shield::abort();
}
$menus = Get::state_menu(null, array(), false);
if (!isset($menus[$key])) {
Shield::abort();
// Menu not found!
}
Config::set(array('page_title' => $speak->deleting . ': ' . $speak->menu . $config->title_separator . $config->manager->title, 'cargo' => 'kill.menu.php'));
$G = array('data' => $menus);
$G['data']['key'] = $key;
if ($request = Request::post()) {
$request = Filter::apply('request:__menu', $request, $key);
Guardian::checkToken($request['token']);
unset($menus[$key]);
// delete ...
ksort($menus);
$P = array('data' => $menus);
$P['data']['key'] = $key;
File::serialize($menus)->saveTo(STATE . DS . 'menu.txt', 0600);
Notify::success(Config::speak('notify_success_deleted', $speak->menu));
Weapon::fire(array('on_menu_update', 'on_menu_destruct'), array($G, $P));
Guardian::kick($config->manager->slug . '/menu');
} else {
Notify::warning(Config::speak('notify_confirm_delete_', '<code>Menu::' . $key . '()</code>'));
}
Shield::lot(array('segment' => 'menu', 'id' => $key, 'file' => Mecha::O($menus[$key])))->attach('manager');
});
示例15: removeTask
/**
* Remove one or more entries
*
* @return void
*/
public function removeTask()
{
// Check for request forgeries
Request::checkToken();
$ids = Request::getVar('id', array());
$ids = !is_array($ids) ? array($ids) : $ids;
// Make sure we have an ID
if (empty($ids)) {
Notify::warning(Lang::txt('COM_GROUPS_ERROR_NO_ITEMS_SELECTED'));
return $this->cancelTask();
}
$i = 0;
foreach ($ids as $id) {
// Remove the entry
$model = Role::oneOrFail(intval($id));
if (!$model->destroy()) {
Notify::error($model->getError());
continue;
}
$i++;
}
if ($i) {
Notify::success(Lang::txt('COM_GROUPS_ROLE_REMOVED'));
}
$this->cancelTask();
}