本文整理汇总了PHP中JError::raiseWarning方法的典型用法代码示例。如果您正苦于以下问题:PHP JError::raiseWarning方法的具体用法?PHP JError::raiseWarning怎么用?PHP JError::raiseWarning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JError
的用法示例。
在下文中一共展示了JError::raiseWarning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: featured
/**
* Method to toggle the featured setting of a list of articles.
*
* @return void
* @since 1.6
*/
function featured()
{
// Check for request forgeries
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// Initialise variables.
$user = JFactory::getUser();
$ids = JRequest::getVar('cid', array(), '', 'array');
$values = array('featured' => 1, 'unfeatured' => 0);
$task = $this->getTask();
$value = JArrayHelper::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]);
JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
}
}
if (empty($ids)) {
JError::raiseWarning(500, JText::_('JERROR_NO_ITEMS_SELECTED'));
} else {
// Get the model.
$model = $this->getModel();
// Publish the items.
if (!$model->featured($ids, $value)) {
JError::raiseWarning(500, $model->getError());
}
}
$this->setRedirect('index.php?option=com_content&view=articles');
}
示例2: display
/**
* Generates a list of JSON items.
*
* @return void
*/
public function display($tpl = null)
{
$model = $this->getModel();
$this->item = $this->get('Item');
$this->component = $model->getState($model->getName() . '.component');
$this->section = $model->getState($model->getName() . '.section');
$this->asset_id = $model->getState($model->getName() . '.asset_id');
$this->project_id = $model->getState($model->getName() . '.project_id');
$this->inherit = $model->getState($model->getName() . '.inherit');
if (!$this->asset_id && $this->inherit) {
$this->asset_id = $this->getComponentProjectAssetId($this->component, $this->project_id);
}
$this->rules = $this->getAssetRules();
$this->public_groups = array('1', JComponentHelper::getParams('com_users')->get('guest_usergroup', 1));
$user = JFactory::getUser();
if (!$user->authorise('core.admin', $this->component) && !$user->authorise('core.manage', $this->component)) {
JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
return false;
}
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseWarning(500, implode("\n", $errors));
return false;
}
parent::display($tpl);
}
示例3: display
/**
* Method to display a view.
*
* @param boolean If true, the view output will be cached
* @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
* @since 1.5
*/
public function display($cachable = false, $urlparams = false)
{
require_once JPATH_COMPONENT . '/helpers/users.php';
// Load the submenu.
UsersHelper::addSubmenu(JRequest::getCmd('view', 'users'));
$view = JRequest::getCmd('view', 'users');
$layout = JRequest::getCmd('layout', 'default');
$id = JRequest::getInt('id');
if (!$this->canView($view)) {
JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
return;
}
// Check for edit form.
if ($view == 'user' && $layout == 'edit' && !$this->checkEditId('com_users.edit.user', $id)) {
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_users&view=users', false));
return false;
} elseif ($view == 'group' && $layout == 'edit' && !$this->checkEditId('com_users.edit.group', $id)) {
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_users&view=groups', false));
return false;
} elseif ($view == 'level' && $layout == 'edit' && !$this->checkEditId('com_users.edit.level', $id)) {
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_users&view=levels', false));
return false;
}
return parent::display();
}
示例4: akeebaACLCheck
/**
* Do our custom ACL checks for the back-end views
*
* @return boolean
*/
private function akeebaACLCheck()
{
// Get the view
$view = $this->input->getCmd('view', '');
// Fetch the privilege to check, or use the default (akeeba.configure)
// privilege.
if (array_key_exists($view, self::$viewACLMap)) {
$privilege = self::$viewACLMap[$view];
} else {
$privilege = 'akeeba.configure';
}
// If an empty privileve is defined do not do any ACL check
if (empty($privilege)) {
return true;
}
// Throw an error if we are not allowed access to the view
if (!JFactory::getUser()->authorise($privilege, 'com_akeeba')) {
$this->setRedirect('index.php?option=com_akeeba&view=cpanel');
JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
$this->redirect();
return false;
} else {
return true;
}
}
示例5: save
function save()
{
$data = JRequest::getVar('jform', array(), 'post', 'NONE', 4);
$id = (int) $data['id'];
if (empty($id)) {
if (!igGeneralHelper::authorise('core.igalleryfront.create')) {
return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
}
} else {
if (!igGeneralHelper::authorise('core.igalleryfront.edit', $id)) {
return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
}
}
$model = $this->getModel();
$msg = '';
if (!$model->save($data)) {
JError::raise(2, 500, $model->getError());
} else {
$msg = JText::_('SUCCESSFULLY_SAVED');
}
switch ($this->task) {
case 'apply':
$url = 'index.php?option=com_igallery&view=icategory&id=' . $id;
break;
case 'save':
$url = 'index.php?option=com_igallery&view=categories';
}
$this->setRedirect(JRoute::_($url, false), $msg);
}
示例6: load
/**
* Loads the entire menu table into memory.
*
* @return boolean True on success, false on failure
*
* @since 1.5
*/
public function load()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select('m.id, m.menutype, m.title, m.alias, m.note, m.path AS route, m.link, m.type, m.level, m.language')->select($db->quoteName('m.browserNav') . ', m.access, m.params, m.home, m.img, m.template_style_id, m.component_id, m.parent_id')->select('e.element as component')->from('#__menu AS m')->join('LEFT', '#__extensions AS e ON m.component_id = e.extension_id')->where('m.published = 1')->where('m.parent_id > 0')->where('m.client_id = 0')->order('m.lft');
// Set the query
$db->setQuery($query);
try {
$this->_items = $db->loadObjectList('id');
} catch (RuntimeException $e) {
JError::raiseWarning(500, JText::sprintf('JERROR_LOADING_MENUS', $e->getMessage()));
return false;
}
foreach ($this->_items as &$item) {
// Get parent information.
$parent_tree = array();
if (isset($this->_items[$item->parent_id])) {
$parent_tree = $this->_items[$item->parent_id]->tree;
}
// Create tree.
$parent_tree[] = $item->id;
$item->tree = $parent_tree;
// Create the query array.
$url = str_replace('index.php?', '', $item->link);
$url = str_replace('&', '&', $url);
parse_str($url, $item->query);
}
return true;
}
示例7: __construct
/**
* Constructor
*
* @access protected
*/
function __construct()
{
$isLoaded = JPluginHelper::importPlugin('authentication');
if (!$isLoaded) {
JError::raiseWarning('SOME_ERROR_CODE', JText::_('JAuthentication::__construct: Could not load authentication libraries.'));
}
}
示例8: getOptions
/**
* Method to get the field options.
*
* @return array The field option objects.
* @since 1.6
*/
public function getOptions()
{
// Initialize variables.
$options = array();
/*
* SQL query:
*
* SELECT DISTINCT (school) AS value, school AS text
* FROM #__osbitusers
* ORDER BY school
*/
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('DISTINCT (school) AS value, school AS text');
$query->from('#__osbitusers');
$query->order('school');
// Get the options.
$db->setQuery($query);
$options = $db->loadObjectList();
// Check for a database error.
if ($db->getErrorNum()) {
JError::raiseWarning(500, $db->getErrorMsg());
}
return $options;
}
示例9: save
function save()
{
$productfieldgroup = JTable::getInstance('productFieldGroup', 'jshop');
$post = JRequest::get("post");
JPluginHelper::importPlugin('jshoppingadmin');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onBeforeSaveProductFieldGroup', array(&$post));
if (!$productfieldgroup->bind($post)) {
JError::raiseWarning("", _JSHOP_ERROR_BIND);
$this->setRedirect("index.php?option=com_jshopping&controller=productfieldgroups");
return 0;
}
if (!$id) {
$productfieldgroup->ordering = null;
$productfieldgroup->ordering = $productfieldgroup->getNextOrder();
}
if (!$productfieldgroup->store()) {
JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
$this->setRedirect("index.php?option=com_jshopping&controller=productfieldgroups");
return 0;
}
$dispatcher->trigger('onAfterSaveProductFieldGroup', array(&$productfieldgroup));
if ($this->getTask() == 'apply') {
$this->setRedirect("index.php?option=com_jshopping&controller=productfieldgroups&task=edit&id=" . $productfieldgroup->id);
} else {
$this->setRedirect("index.php?option=com_jshopping&controller=productfieldgroups");
}
}
示例10: display
/**
* @param null $tpl
*
* @return bool
* @throws Exception
*/
function display($tpl = null)
{
$this->state = $this->get('State');
$this->params = $this->state->get('params');
$this->item = $this->get('Item');
$this->items = $this->get('Items');
$this->sitemapItems = $this->get('SitemapItems');
$this->extensions = $this->get('Extensions');
$input = JFactory::getApplication()->input;
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseWarning(500, implode("\n", $errors));
return false;
}
$app = JFactory::getApplication();
$app->clearHeaders();
$app->setHeader('Content-Type', 'application/xml; charset=UTF-8');
$app->sendHeaders();
$this->displayer = new XmapDisplayerXml($this->item, $this->items, $this->extensions);
$this->displayer->displayAsNews($input->getBool('news'));
$this->displayer->displayAsImages($input->getBool('images'));
$this->displayer->displayAsVideos($input->getBool('videos'));
$this->displayer->displayAsMobile($input->getBool('mobile'));
$this->displayer->setSitemapItems($this->sitemapItems);
parent::display($tpl);
$this->getModel()->hit($this->displayer->getCount());
$app->close();
}
示例11: level
/**
* Displays a list of the available access view levels
*
* @param string The form field name.
* @param string The name of the selected section.
* @param string Additional attributes to add to the select field.
* @param mixed True to add "All Sections" option or and array of options
* @param string The form field id
*
* @return string The required HTML for the SELECT tag.
*/
public static function level($name, $selected, $attribs = '', $params = true, $id = false)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('a.id AS value, a.title AS text');
$query->from('#__viewlevels AS a');
$query->group('a.id');
$query->order('a.ordering ASC');
$query->order($query->qn('title') . ' ASC');
// Get the options.
$db->setQuery($query);
$options = $db->loadObjectList();
// Check for a database error.
if ($db->getErrorNum()) {
JError::raiseWarning(500, $db->getErrorMsg());
return null;
}
// If params is an array, push these options to the array
if (is_array($params)) {
$options = array_merge($params, $options);
} elseif ($params) {
array_unshift($options, JHtml::_('select.option', '', JText::_('JOPTION_ACCESS_SHOW_ALL_LEVELS')));
}
return JHtml::_('select.genericlist', $options, $name, array('list.attr' => $attribs, 'list.select' => $selected, 'id' => $id));
}
示例12: copy
public function copy()
{
// Check for request forgeries
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$cid = $this->input->post->get('cid', array(), 'array');
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tagmeta/tables');
$table =& JTable::getInstance('Rule', 'TagMetaTable');
$n = count($cid);
if ($n > 0) {
$i = 0;
foreach ($cid as $id) {
if ($table->load((int) $id)) {
$table->id = 0;
$table->url = JText::_('COM_TAGMETA_COPY_OF') . $table->url;
$table->ordering = 0;
$table->published = false;
$table->checked_out = false;
if ($table->store()) {
$i++;
} else {
JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_TAGMETA_COPY_ERROR_SAVING', $id, $table->getError()), 'error');
}
} else {
JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_TAGMETA_COPY_ERROR_LOADING', $id, $table->getError()), 'error');
}
}
} else {
return JError::raiseWarning(500, JText::_('COM_TAGMETA_COPY_ERROR_NO_SELECTION'));
}
$this->setMessage(JText::sprintf('COM_TAGMETA_COPY_OK', $i));
$this->setRedirect('index.php?option=com_tagmeta&view=rules');
}
示例13: __construct
} else {
require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_languages' . DS . 'helpers' . DS . 'jsonresponse.php';
}
/**
* Content controller class.
*/
class J2XMLControllerCategories extends JControllerAbstract
{
function __construct($default = array())
{
parent::__construct();
}
public function display($cachable = false, $urlparams = false)
{
JRequest::setVar('view', 'categories');
parent::display($cachable, $urlparams);
}
function send()
{
if (!JSession::checkToken('request')) {
// Check for a valid token. If invalid, send a 403 with the error message.
JError::raiseWarning(403, JText::_('JINVALID_TOKEN'));
echo version_compare(JPlatform::RELEASE, '12', 'ge') ? new JResponseJson() : new JJsonResponse();
return;
}
$cid = JRequest::getVar('cid', array(0), null, 'array');
$sid = JRequest::getVar('w_id', null, null, 'int');
示例14: save
function save()
{
$mainframe = JFactory::getApplication();
$id = JRequest::getInt("id");
$deliveryTimes = JSFactory::getTable('deliveryTimes', 'jshop');
$post = JRequest::get("post");
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onBeforeSaveDeliveryTime', array(&$post));
if (!$deliveryTimes->bind($post)) {
JError::raiseWarning("", _JSHOP_ERROR_BIND);
$this->setRedirect("index.php?option=com_jshopping&controller=deliverytimes");
return 0;
}
if (!$deliveryTimes->store()) {
JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
$this->setRedirect("index.php?option=com_jshopping&controller=deliverytimes");
return 0;
}
$dispatcher->trigger('onAfterSaveDeliveryTime', array(&$deliveryTimes));
if ($this->getTask() == 'apply') {
$this->setRedirect("index.php?option=com_jshopping&controller=deliverytimes&task=edit&id=" . $deliveryTimes->id);
} else {
$this->setRedirect("index.php?option=com_jshopping&controller=deliverytimes");
}
}
示例15: getPositions
static function getPositions($clientId)
{
jimport('joomla.filesystem.folder');
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('DISTINCT(position)');
$query->from('#__modules');
$query->where($db->quoteName('client_id') . ' = ' . (int) $clientId);
$query->order('position');
$db->setQuery($query);
$positions = $db->loadColumn();
$positions = is_array($positions) ? $positions : array();
if ($error = $db->getErrorMsg()) {
JError::raiseWarning(500, $error);
return;
}
// Build the list
$options = array();
foreach ($positions as $position) {
if (!$position) {
$options[] = JHtml::_('select.option', 'none', ':: ' . JText::_('JNONE') . ' ::');
} else {
$options[] = JHtml::_('select.option', $position, $position);
}
}
return $options;
}