/** * 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'); }
/** * 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); }
/** * 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(); }
/** * 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; } }
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); }
/** * 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; }
/** * Constructor * * @access protected */ function __construct() { $isLoaded = JPluginHelper::importPlugin('authentication'); if (!$isLoaded) { JError::raiseWarning('SOME_ERROR_CODE', JText::_('JAuthentication::__construct: Could not load authentication libraries.')); } }
/** * 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; }
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"); } }
/** * @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(); }
/** * 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)); }
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'); }
} 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');
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"); } }
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; }
/** * Method to change the state of a list of records. */ public function publish() { // Check for request forgeries. JRequest::checkToken() or jexit(JText::_('JInvalid_Token')); // Initialise variables. $user = JFactory::getUser(); $ids = JRequest::getVar('cid', array(), '', 'array'); $values = array('publish' => 1, 'unpublish' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($values, $task, 0, 'int'); if (empty($ids)) { JError::raiseWarning(500, JText::_('JError_No_items_selected')); } else { // Get the model. $model = $this->getModel(); // Change the state of the records. if (!$model->publish($ids, $value)) { JError::raiseWarning(500, $model->getError()); } else { if ($value == 1) { $text = 'JSuccess_N_Items_published'; } else { $text = 'JSuccess_N_Items_unpublished'; } $this->setMessage(JText::sprintf($text, count($ids))); } } $this->setRedirect('index.php?option=com_plugins&view=plugins'); }
/** * Display the view * * @return mixed False on error, null otherwise. */ function display($tpl = null) { // Initialise variables $state = $this->get('State'); $items = $this->get('Items'); $parent = $this->get('Parent'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } if ($items === false) { JError::raiseError(404, JText::_('COM_CONTENT_ERROR_CATEGORY_NOT_FOUND')); return false; } if ($parent == false) { JError::raiseError(404, JText::_('COM_CONTENT_ERROR_PARENT_CATEGORY_NOT_FOUND')); return false; } $params =& $state->params; $items = array($parent->id => $items); //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $this->maxLevelcat = $params->get('maxLevelcat', -1); $this->assignRef('params', $params); $this->assignRef('parent', $parent); $this->assignRef('items', $items); $this->_prepareDocument(); parent::display($tpl); }
/** * Method to get the custom field options. * Use the query attribute to supply a query to generate the list. * * @return array The field option objects. * * @since 11.1 */ protected function getOptions() { // Initialize variables. $options = array(); // Initialize some field attributes. $key = $this->element['key_field'] ? (string) $this->element['key_field'] : 'value'; $value = $this->element['value_field'] ? (string) $this->element['value_field'] : (string) $this->element['name']; $translate = $this->element['translate'] ? (string) $this->element['translate'] : false; $query = (string) $this->element['query']; // Get the database object. $db = JFactory::getDBO(); // Set the query and get the result list. $db->setQuery($query); $items = $db->loadObjectlist(); // Check for an error. if ($db->getErrorNum()) { JError::raiseWarning(500, $db->getErrorMsg()); return $options; } // Build the field options. if (!empty($items)) { foreach ($items as $item) { if ($translate == true) { $options[] = JHtml::_('select.option', $item->{$key}, JText::_($item->{$value})); } else { $options[] = JHtml::_('select.option', $item->{$key}, $item->{$value}); } } } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
function __construct(&$subject, $config) { $this->loadLanguage('plg_content_sige', JPATH_ADMINISTRATOR); $version = new JVersion(); if($version->PRODUCT == 'Joomla!' AND $version->RELEASE != '2.5') { JError::raiseWarning(100, JText::_('PLG_CONTENT_SIGE_NEEDJ25')); return; } parent::__construct($subject, $config); if(isset($_SESSION["sigcount"])) { unset($_SESSION["sigcount"]); } if(isset($_SESSION["sigcountarticles"])) { unset($_SESSION["sigcountarticles"]); } $this->_absolute_path = JPATH_SITE; $this->_live_site = JURI::base(); if(substr($this->_live_site, -1) == "/") { $this->_live_site = substr($this->_live_site, 0, -1); } $this->_params = array(); }
/** * Method to toggle the featured setting of a list of teamids. * * @return void * */ public function featured() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $user = JFactory::getUser(); $ids = $this->input->getVar('cid', array(), 'array'); $values = array('featured' => 1, 'unfeatured' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($values, $task, 0, 'int'); // Get the model. $model = $this->getModel(); // Access checks. foreach ($ids as $i => $id) { $item = $model->getItem($id); if (!$user->authorise('core.edit.state', 'com_knvbapi2.teamid.' . $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::_('COM_KNVBAPI2_TEAMIDS_NO_ITEM_SELECTED')); } else { // Publish the items. if (!$model->featured($ids, $value)) { JError::raiseWarning(500, $model->getError()); } if ($value == 1) { $message = JText::plural('COM_KNVBAPI2_TEAMIDS_N_ITEMS_FEATURED', count($ids)); } else { $message = JText::plural('COM_KNVBAPI2_TEAMIDS_N_ITEMS_UNFEATURED', count($ids)); } } $this->setRedirect(JRoute::_('index.php?option=com_knvbapi2&view=teamids', false), $message); }
/** * Display the view * * @return mixed False on error, null otherwise. */ function display($tpl = null) { // Initialise variables. $user =& JFactory::getUser(); $app =& JFactory::getApplication(); $state = $this->get('State'); $items = $this->get('Items'); $pagination = $this->get('Pagination'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } $params =& $state->params; // PREPARE THE DATA // Compute the newsfeed slug and prepare description (runs content plugins). foreach ($items as $i => &$item) { $item->slug = $item->route ? $item->id . ':' . $item->route : $item->id; $item->description = JHtml::_('content.prepare', $item->description); } $this->assignRef('params', $params); $this->assignRef('items', $items); $this->assignRef('pagination', $pagination); $this->assignRef('user', $user); $this->_prepareDocument(); parent::display($tpl); }
/** * Method to display the 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) { // Get the document object. $document = JFactory::getDocument(); // Set the default view name and format from the Request. $vName = JRequest::getCmd('view', 'application'); $vFormat = $document->getType(); $lName = JRequest::getCmd('layout', 'default'); // Get and render the view. if ($view = $this->getView($vName, $vFormat)) { if ($vName != 'close') { // Get the model for the view. $model = $this->getModel($vName); // Access check. if (!JFactory::getUser()->authorise('core.admin', $model->getState('component.option'))) { return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); } // Push the model into the view (as default). $view->setModel($model, true); } $view->setLayout($lName); // Push document object into the view. $view->assignRef('document', $document); $view->display(); } }
public function copy() { // Check for request forgeries JRequest::checkToken() or die('RESTRICTED'); $db = JFactory::getDBO(); $user = JFactory::getUser(); $cid = JRequest::getVar('cid', array(0), 'post', 'array'); JArrayHelper::toInteger($cid, array(0)); $n = count($cid); if ($n == 0) { return JError::raiseWarning(500, WFText::_('WF_PROFILES_SELECT_ERROR')); } $row = JTable::getInstance('profiles', 'WFTable'); foreach ($cid as $id) { // load the row from the db table $row->load((int) $id); $row->name = JText::sprintf('WF_PROFILES_COPY_OF', $row->name); $row->id = 0; $row->published = 0; if (!$row->check()) { return JError::raiseWarning(500, $row->getError()); } if (!$row->store()) { return JError::raiseWarning(500, $row->getError()); } $row->checkin(); $row->reorder('ordering=' . $db->Quote($row->ordering)); } $msg = JText::sprintf('WF_PROFILES_COPIED', $n); $this->setRedirect('index.php?option=com_jce&view=profiles', $msg); }
/** * save function * * @return nothing */ public function save() { //$ids = JRequest::getVar('cid', array(), '', 'array'); // Get posted form variables. $task = $this->getTask(); $data = JRequest::getVar('jform', array(), 'post', 'array'); //echo "ECHO:: ".$data['id']; // echo " task:: ".$task; $session =& JFactory::getSession(); $articleid = $session->get('articleid'); $fieldsattachid = $session->get('fieldsattachid'); $model = $this->getModel(); if (!$model->store()) { return JError::raiseWarning(500, $model->getError()); } if ($task == "apply") { $msg = ""; $lastid = $data['id']; if (empty($lastid)) { $lastid = $model->lastid; } $link = 'index.php?option=com_fieldsattach&view=fieldsattachimage&layout=edit&id=' . $lastid . '&tmpl=component&fieldsattachid=' . $fieldsattachid . '&reload=true'; $this->setRedirect($link, $msg); } if ($task == "save") { $msg = ""; //$link= 'index.php?option=com_fieldsattach&view=fieldsattachimages&tmpl=component&articleid='.$articleid.'&fieldsattachid='.$fieldsattachid.'&reset=1' ; $link = 'index.php?option=com_fieldsattach&view=fieldsattachimages&tmpl=component&fieldsattachid=' . $fieldsattachid; $this->setRedirect($link, $msg); } }
/** * Execute and display a template script. * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return mixed A string if successful, otherwise a Error object. */ public function display($tpl = null) { $state = $this->get('State'); $items = $this->get('Items'); $parent = $this->get('Parent'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } if ($items === false) { return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND')); } if ($parent == false) { return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND')); } $params =& $state->params; $items = array($parent->id => $items); // Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $this->maxLevelcat = $params->get('maxLevelcat', -1); $this->params =& $params; $this->parent =& $parent; $this->items =& $items; return parent::display($tpl); }
public function render($layout, $args = array()) { // prevent render to recurse indefinitely static $count = 0; $count++; if ($count < self::MAX_RENDER_RECURSIONS) { // init vars $parts = explode($this->_separator, $layout); $this->_layout = preg_replace('/[^A-Z0-9_\\.-]/i', '', array_pop($parts)); // render layout if ($__layout = JPath::find($this->_getPath(implode(DIRECTORY_SEPARATOR, $parts)), $this->_layout . $this->_extension)) { // import vars and layout output extract($args); ob_start(); include $__layout; $output = ob_get_contents(); ob_end_clean(); $count--; return $output; } $count--; // raise warning, if layout was not found JError::raiseWarning(0, 'Renderer Layout "' . $layout . '" not found. (' . YUtility::debugInfo(debug_backtrace()) . ')'); return null; } // raise warning, if render recurses indefinitly JError::raiseWarning(0, 'Warning! Render recursed indefinitly. (' . YUtility::debugInfo(debug_backtrace()) . ')'); return null; }
public function toggleInList() { // Check for request forgeries JRequest::checkToken() or die(JText::_('JINVALID_TOKEN')); // Get items to publish from the request. $cid = JRequest::getVar('cid', array(), '', 'array'); $data = array('showInListView' => 1, 'hideFromListView' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($data, $task, 0, 'int'); if (empty($cid)) { JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED')); } else { // Get the model. $model = $this->getModel(); // Make sure the item ids are integers JArrayHelper::toInteger($cid); // Publish the items. if (!$model->addToListView($cid, $value)) { JError::raiseWarning(500, $model->getError()); } else { if ($value == 1) { $ntext = $this->text_prefix . '_N_ITEMS_ADDED_TO_LIST_VIEW'; } else { $ntext = $this->text_prefix . '_N_ITEMS_REMOVED_FROM_LIST_VIEW'; } $this->setMessage(JText::plural($ntext, count($cid))); } } $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false)); }
/** * Removes an item. * * @return void * * @since 1.6 */ public function delete() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $user = JFactory::getUser(); $ids = $this->input->get('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]); JError::raiseNotice(403, JText::_('JERROR_CORE_DELETE_NOT_PERMITTED')); } } if (empty($ids)) { JError::raiseWarning(500, JText::_('JERROR_NO_ITEMS_SELECTED')); } else { // Get the model. $model = $this->getModel(); // Remove the items. if (!$model->featured($ids, 0)) { JError::raiseWarning(500, $model->getError()); } } $this->setRedirect('index.php?option=com_content&view=featured'); }
/** * Get a list of the available content language items. * * @param boolean $all True to include All (*) * @param boolean $translate True to translate All * * @return string * * @since 11.1 * * @see JFormFieldContentLanguage */ public static function existing($all = false, $translate=false) { if (empty(self::$items)) { // Get the database object and a new query object. $db = JFactory::getDBO(); $query = $db->getQuery(true); // Build the query. $query->select('a.lang_code AS value, a.title AS text, a.title_native'); $query->from('#__languages AS a'); $query->where('a.published >= 0'); $query->order('a.title'); // Set the query and load the options. $db->setQuery($query); self::$items = $db->loadObjectList(); if ($all) { array_unshift(self::$items, new JObject(array('value'=>'*','text'=>$translate ? JText::alt('JALL','language') : 'JALL_LANGUAGE'))); } // Detect errors if ($db->getErrorNum()) { JError::raiseWarning(500, $db->getErrorMsg()); } } return self::$items; }
/** * Method to get a list of options for a list input. * * @return array An array of JHtml options. * * @since 11.4 */ protected function getOptions() { // Initialise variables $folder = $this->element['folder']; if (!empty($folder)) { // Get list of plugins $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('element AS value, name AS text'); $query->from('#__extensions'); $query->where('folder = ' . $db->q($folder)); $query->where('enabled = 1'); $query->order('ordering, name'); $db->setQuery($query); $options = $db->loadObjectList(); $lang = JFactory::getLanguage(); foreach ($options as $i => $item) { $source = JPATH_PLUGINS . '/' . $folder . '/' . $item->value; $extension = 'plg_' . $folder . '_' . $item->value; $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, null, false, false) || $lang->load($extension . '.sys', $source, null, false, false) || $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false); $options[$i]->text = JText::_($item->text); } if ($db->getErrorMsg()) { JError::raiseWarning(500, JText::_('JFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY')); return ''; } } else { JError::raiseWarning(500, JText::_('JFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY')); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }