本文整理汇总了PHP中JError::isError方法的典型用法代码示例。如果您正苦于以下问题:PHP JError::isError方法的具体用法?PHP JError::isError怎么用?PHP JError::isError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JError
的用法示例。
在下文中一共展示了JError::isError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOptions
/**
* Method to get the field options.
*
* @return array The field option objects.
* @since 1.6
*/
protected function getOptions()
{
// Initialise variables.
$app = JFactory::getApplication();
// Detect the native language.
$native = JLanguageHelper::detectLanguage();
if (empty($native)) {
$native = 'en-GB';
}
// Get a forced language if it exists.
$forced = $app->getLocalise();
if (!empty($forced['language'])) {
$native = $forced['language'];
}
// If a language is already set in the session, use this instead
$session = JFactory::getSession()->get('setup.options', array());
if (!empty($session['language'])) {
$native = $session['language'];
}
// Get the list of available languages.
$options = JLanguageHelper::createLanguageList($native);
if (!$options || JError::isError($options)) {
$options = array();
}
// Set the default value from the native language.
$this->value = $native;
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
示例2: onBeforeDispatcherDispatch
public function onBeforeDispatcherDispatch(KEvent $event)
{
$application = JFactory::getApplication();
if ($application->getName() != 'site') {
return;
}
//var_dump($_SERVER); exit();
// check if SSO header is set
$personnumber = KRequest::get('server.HTTP_P_SSO_IDENTIFIER', 'alnum');
if (empty($personnumber) || !preg_match('/P\\d+/is', $personnumber)) {
// TODO set proper http response
throw new KException('Access not allowed');
}
// check if user is already logged in
$user = JFactory::getUser();
// make sure personnumber is still the same
if (!$user->guest && $user->username != $personnumber) {
$application->logout();
$application->redirect(KRequest::url());
}
if ($user->guest) {
$credentials = array('username' => $personnumber, 'password' => $personnumber);
$result = $application->login($credentials, array());
if (JError::isError($result)) {
// TODO set proper http response
throw new KException($result->getError());
} else {
$application->redirect('index.php');
}
}
}
示例3: display
public function display($cachable = false, $urlparams = false)
{
// Get the view name from the query string
$viewName = JRequest::getVar("view", "playground");
// Get the view
$view = $this->getView($viewName);
// Get the joomleague model
$jl = $this->getModel("joomleague", "JoomleagueModel");
$jl->set("_name", "joomleague");
if (!JError::isError($jl)) {
$view->setModel($jl);
}
// Get the playground model
$pg = $this->getModel("playground", "JoomleagueModel");
$pg->set("_name", "playground");
if (!JError::isError($pg)) {
$view->setModel($pg);
}
// Get the countries model
$cn = $this->getModel("countries", "JoomleagueModel");
$cn->set("_name", "countries");
if (!JError::isError($cn)) {
$view->setModel($cn);
}
// Get the Google map model
$gm = $this->getModel("googlemap", "JoomleagueModel");
$gm->set("_name", "googlemap");
if (!JError::isError($gm)) {
$view->setModel($gm);
}
$this->showprojectheading();
$view->display();
$this->showbackbutton();
$this->showfooter();
}
示例4: display
/**
* Display the view
*/
function display()
{
$document = JFactory::getDocument();
$viewName = str_replace('FabrikControllerVisualization', '', get_class($this));
if ($viewName == '') {
// if we are using a url like http://localhost/fabrik3.0.x/index.php?option=com_fabrik&view=visualization&id=6
// then we need to ascertain which viz to use
$viewName = $this->getViewName();
}
$viewType = $document->getType();
// Set the default view name from the Request
$view = $this->getView($viewName, $viewType);
// Push a model into the view
$model = $this->getModel($viewName);
if (!JError::isError($model)) {
$view->setModel($model, true);
}
// Display the view
$view->assign('error', $this->getError());
// f3 cache with raw view gives error
if (in_array(JRequest::getCmd('format'), array('raw', 'csv'))) {
$view->display();
} else {
$post = JRequest::get('post');
//build unique cache id on url, post and user id
$user = JFactory::getUser();
$cacheid = serialize(array(JRequest::getURI(), $post, $user->get('id'), get_class($view), 'display', $this->cacheId));
$cache = JFactory::getCache('com_fabrik', 'view');
$cache->get($view, 'display', $cacheid);
}
}
示例5: display
function display()
{
// Get the view name from the query string
$viewName = JRequest::getVar("view", "matchreport");
// Get the view
$view =& $this->getView($viewName);
// Get the joomleague model
$jl = $this->getModel("joomleague", "JoomleagueModel");
$jl->set("_name", "joomleague");
if (!JError::isError($jl)) {
$view->setModel($jl);
}
// Get the joomleague model
$sr = $this->getModel("matchreport", "JoomleagueModel");
$sr->set("_name", "matchreport");
if (!JError::isError($sr)) {
$view->setModel($sr);
}
$this->showprojectheading();
if (JRequest::getInt('mid', 0) == 0) {
$view->showreports();
} else {
$view->display();
}
$this->showbackbutton();
$this->showfooter();
}
示例6: save
function save()
{
if (!igGeneralHelper::authorise('core.admin')) {
return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
}
$app = JFactory::getApplication();
$data = JRequest::getVar('jform', array(), 'post', 'NONE', 4);
$id = (int) $data['id'];
if (empty($id[0])) {
if (!igGeneralHelper::authorise('core.create')) {
return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
}
} else {
if (!igGeneralHelper::authorise('core.edit')) {
return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
}
}
if (strlen($_FILES['jform']['name']['watermark_filename']) > 2) {
$fileName = $_FILES['jform']['name']['watermark_filename'];
$tmpPath = $_FILES['jform']['tmp_name']['watermark_filename'];
$uploadError = $_FILES['jform']['error']['watermark_filename'];
if (!($uploadedFile = igUploadHelper::upload_file($fileName, $tmpPath, $uploadError, IG_WATERMARK_PATH, true))) {
return false;
}
$data['watermark_filename'] = $uploadedFile;
}
$model = $this->getModel();
$form = $model->getForm($data, false);
if (!$form) {
$app->enqueueMessage($model->getError(), 'error');
return false;
}
$validData = $model->validate($form, $data);
if ($validData === false) {
$errors = $model->getErrors();
for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) {
if (JError::isError($errors[$i])) {
$app->enqueueMessage($errors[$i]->getMessage(), 'warning');
} else {
$app->enqueueMessage($errors[$i], 'warning');
}
}
$this->setRedirect('index.php?option=com_igallery&view=profile&id=' . $id, false);
return false;
}
if (!$model->save($validData)) {
JError::raise(2, 500, $model->getError());
$msg = '';
} else {
$msg = JText::_('SUCCESSFULLY_SAVED');
}
switch ($this->task) {
case 'apply':
$url = 'index.php?option=com_igallery&view=profile&id=' . $id;
break;
case 'save':
$url = 'index.php?option=com_igallery&view=profiles';
}
$this->setRedirect($url, $msg);
}
示例7: save
/**
* Save a comment.
*
* @access public
* @return void
* @since 1.0
*/
function save()
{
// check for request forgeries.
JRequest::checkToken();
// get posted form variables.
$values = JRequest::getVar('jxform', array(), 'post', 'array');
$post = JRequest::get('post', JREQUEST_ALLOWHTML);
// handle the post body
$body = $post['jxform']['body'];
// make sure that html special characters are encoded in code tags
function codeEscape($matches)
{
return htmlspecialchars($matches[0]);
}
$body = preg_replace_callback('/\\[code=(.+?)\\](.+?)\\[\\/code\\]/is', 'codeEscape', $body);
// if html is not enabled, then lets filter it out
$config =& JComponentHelper::getParams('com_comments');
if (!$config->get('enable_html', 0)) {
$body = strip_tags($body);
}
// reset the body field in the posted values array
$values['body'] = $body;
// get the id of the item out of the session.
$session =& JFactory::getSession();
$id = (int) $session->get('comments.comment.id');
$values['id'] = $id;
// Get the comment model and set the post request in its state.
$model =& $this->getModel('comment');
$model->setState('request', JRequest::get('post'));
// get the items to moderate from the request
$c_id = JRequest::getVar('moderate', array(), '', 'array');
// moderate the items if set
if (is_array($c_id) and !empty($c_id)) {
// split out the keys and values for the request array so that we can clean them
$keys = array_keys($c_id);
$vals = array_values($c_id);
// clean the keys and values from the request array using JArrayHelper
jimport('joomla.utilities.arrayhelper');
JArrayHelper::toInteger($keys);
JArrayHelper::toInteger($vals);
// re-initialize the array and build it with cleaned data
$c_id = array();
for ($i = 0, $n = count($keys); $i < $n; $i++) {
$cid[$keys[$i]] = $vals[$i];
}
// moderate the items.
$model->moderate($c_id);
}
// save the comment and check for an error state
$result = $model->save($values);
$msg = JError::isError($result) ? $result->message : 'COMMENTS_SAVED';
// redirect to the appropriate place based on the task
if ($this->_task == 'apply') {
$this->setRedirect(JRoute::_('index.php?option=com_comments&view=comment&layout=edit', false), JText::_($msg));
} else {
$session->set('comments.comment.id', null);
$model->checkin($id);
$this->setRedirect(JRoute::_('index.php?option=com_comments&view=comments', false), JText::_($msg));
}
}
示例8: display
/**
* Display the view
*/
function display($model = null)
{
//menu links use fabriklayout parameters rather than layout
$flayout = JRequest::getVar('fabriklayout');
if ($flayout != '') {
JRequest::setVar('layout', $flayout);
}
$document =& JFactory::getDocument();
$viewName = JRequest::getVar('view', 'table', 'default', 'cmd');
$modelName = $viewName;
$layout = JRequest::getWord('layout', 'default');
$viewType = $document->getType();
// Set the default view name from the Request
$view =& $this->getView($viewName, $viewType);
$view->setLayout($layout);
// Push a model into the view
if (is_null($model)) {
$model =& $this->getModel($modelName);
}
if (!JError::isError($model) && is_object($model)) {
$view->setModel($model, true);
}
// Display the view
$view->assign('error', $this->getError());
$post = JRequest::get('post');
if ($model->getParams()->get('list_disable_caching', '0') !== '1') {
//build unique cache id on url, post and user id
$user =& JFactory::getUser();
$cacheid = serialize(array(JRequest::getURI(), $post, $user->get('id'), get_class($view), 'display', $this->cacheId));
$cache =& JFactory::getCache('com_fabrik', 'view');
$cache->get($view, 'display', $cacheid);
} else {
$view->display();
}
}
示例9: display
/**
* display the template
*
* @param sting $tpl
*/
function display($tpl = null)
{
FabrikHelperHTML::framework();
$element = JRequest::getVar('element');
$elementid = JRequest::getVar('elid');
$pluginManager = JModel::getInstance('Pluginmanager', 'FabrikFEModel');
$className = JRequest::getVar('plugin');
$plugin = $pluginManager->getPlugIn($className, 'element');
if (JError::isError($plugin)) {
JError::handleMessage($plugin);
return;
}
$plugin->setId($elementid);
$data = array();
$repeatCounter = 0;
$groupModel = $plugin->getGroup();
$srcs = array();
$plugin->formJavascriptClass($srcs);
echo "srcs = ";
print_r($srcs);
FabrikHelperHTML::script($srcs, true);
$html = '<script>';
$html .= $plugin->elementJavascript($repeatCounter);
$html .= '</script>';
$html .= $plugin->_getElement($data, $repeatCounter, $groupModel);
echo $html;
}
示例10: validate
/**
* Validate the data
*
* @return boolean true if data is valid, false otherwise
*/
protected function validate()
{
$app = JFactory::getApplication();
$model = $this->getModel();
$data = JRequest::getVar('jform', array(), 'post', 'array');
$form = $model->getForm($data, false);
$validData = $model->validate($form, $data);
$recordId = JRequest::getInt('id');
if ($validData === 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 (JError::isError($errors[$i])) {
$app->enqueueMessage($errors[$i]->getMessage(), 'warning');
} else {
$app->enqueueMessage($errors[$i], 'warning');
}
}
// Save the data in the session.
if (isset($data[0])) {
$app->setUserState($context . '.data', $data);
}
// Redirect back to the edit screen.
$this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, 'id'), false));
return false;
}
return true;
}
示例11: display
function display()
{
// Get the view name from the query string
$viewName = JRequest::getVar("view", "predictionranking");
// Get the view
$view =& $this->getView($viewName);
// Get the joomleague model
$jl = $this->getModel("joomleague", "JoomleagueModel");
$jl->set("_name", "joomleague");
if (!JError::isError($jl)) {
$view->setModel($jl);
}
// Get the joomleague model
$sr = $this->getModel('prediction', 'JoomleagueModel');
$sr->set('_name', 'prediction');
if (!JError::isError($sr)) {
$view->setModel($sr);
}
// Get the joomleague model
$jl = $this->getModel('project', 'JoomleagueModel');
$jl->set('_name', 'project');
if (!JError::isError($jl)) {
$view->setModel($jl);
}
$this->showprojectheading();
$view->display();
$this->showbackbutton();
$this->showfooter();
}
示例12: getForm
/**
* Method to get the row form.
*
* @return mixed JForm object on success, false on failure.
*/
public function getForm()
{
// Initialise variables.
$app = JFactory::getApplication();
// Get the form.
jimport('joomla.form.form');
JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
$form = JForm::getInstance('com_localise.languages', 'languages', array('control' => 'filters', 'event' => 'onPrepareForm'));
// Check for an error.
if (JError::isError($form)) {
$this->setError($form->getMessage());
return false;
}
// Check the session for previously entered form data.
$data = $app->getUserState('com_localise.select', array());
// Bind the form data if present.
if (!empty($data)) {
$form->bind(array('select' => $data));
}
// Check the session for previously entered form data.
$data = $app->getUserState('com_localise.languages.search', array());
// Bind the form data if present.
if (!empty($data)) {
$form->bind(array('search' => $data));
}
return $form;
}
示例13: chartdata
function chartdata()
{
// Get the view name from the query string
$viewName = JRequest::getVar("view", "stats");
// Get the view
$view =& $this->getView($viewName);
// Get the joomleague model
$jl = $this->getModel("joomleague", "JoomleagueModel");
$jl->set("_name", "joomleague");
if (!JError::isError($jl)) {
$view->setModel($jl);
}
// Get the joomleague model
$sr = $this->getModel("stats", "JoomleagueModel");
$sr->set("_name", "stats");
if (!JError::isError($sr)) {
$view->setModel($sr);
}
// Get the joomleague model
$sr = $this->getModel("eventsranking", "JoomleagueModel");
$sr->set("_name", "eventsranking");
if (!JError::isError($sr)) {
$view->setModel($sr);
}
$view->setLayout("chartdata");
$view->display();
}
示例14: setUpBeforeClass
public static function setUpBeforeClass()
{
jimport('joomla.database.database');
jimport('joomla.database.table');
// Load the config if available.
@ include_once JPATH_TESTS . '/config.php';
if (class_exists('JTestConfig')) {
$config = new JTestConfig;
}
if (!is_object(self :: $dbo)) {
$options = array (
'driver' => isset ($config) ? $config->dbtype : 'mysql',
'host' => isset ($config) ? $config->host : '127.0.0.1',
'user' => isset ($config) ? $config->user : 'utuser',
'password' => isset ($config) ? $config->password : 'ut1234',
'database' => isset ($config) ? $config->db : 'joomla_ut',
'prefix' => isset ($config) ? $config->dbprefix : 'jos_'
);
self :: $dbo = JDatabase :: getInstance($options);
if (JError :: isError(self :: $dbo)) {
//ignore errors
define('DB_NOT_AVAILABLE', true);
}
}
self :: $database = JFactory :: $database;
JFactory :: $database = self :: $dbo;
}
示例15: display
public function display()
{
$document =& JFactory::getDocument();
/* @var $document JDocument */
$viewType = $document->getType();
// Get layout value
$viewLayout = JRequest::getVar('layout', 'default');
// Get view value
$viewName = JRequest::getVar('view', 'Twitter');
// Get view
$view = $this->getView($viewName, $viewType, "View");
// Get model
$model = $this->getModel($viewName, "Model");
if (!JError::isError($model)) {
// Set model to view
$view->setModel($model, true);
}
// Set layout into view
$view->setLayout($viewLayout);
try {
// Display view
$view->display();
} catch (Exception $e) {
$itpSecurity = new ItpSecurity($e);
$itpSecurity->AlertMe();
JError::raiseError(500, JText::_('ITP_ERROR_SYSTEM'));
jexit(JText::_('ITP_ERROR_SYSTEM'));
}
}