本文整理汇总了PHP中JView::getErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP JView::getErrors方法的具体用法?PHP JView::getErrors怎么用?PHP JView::getErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JView
的用法示例。
在下文中一共展示了JView::getErrors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareAjaxResponse
/**
* Prepare an xml file content holding
* a standard record for returning result
* of an ajax request
*
* @param JView $view the view handling the request
*/
public static function prepareAjaxResponse($view)
{
// use Joomla wml object
jimport('joomla.utilities.simplexml');
// create a root node
$xml = new JSimpleXMLElement('item', array('id' => 'shajax-response'));
// add children : status, message, message code, task
$status =& $xml->addChild('status');
$message =& $xml->addChild('message');
$messagecode =& $xml->addChild('messagecode');
$taskexecuted =& $xml->addChild('taskexecuted');
// set default values
$status->setData('_');
$message->setData('_');
$messagecode->setData('_');
$taskexecuted->setData('_');
// set their respective values
$vErrors = $view->getErrors();
if (empty($vErrors)) {
// retrieve messagecode and task
if (empty($view->messagecode)) {
$view->assign('messagecode', 'COM_SH404SEF_OPERATION_COMPLETED');
}
if (empty($view->taskexecuted)) {
$view->assign('taskexecuted', '');
}
// either a success or a redirect
if (empty($view->redirectTo)) {
// no error
$status->setData('success');
$msg = empty($view->message) ? JText16::_('COM_SH404SEF_OPERATION_COMPLETED') : $view->message;
$message->setData('<ul>' . $msg . '</ul>');
$messagecode->setData($view->messagecode);
} else {
$status->setData('redirect');
$glue = strpos($view->redirectTo, '?') === false ? '?' : '&';
$message->setData($view->redirectTo . $glue . 'sh404sefMsg=' . $view->messagecode);
}
$taskexecuted->setData($view->taskexecuted);
} else {
$status->setData('failure');
$messageTxt = '';
foreach ($vErrors as $error) {
$messageTxt .= '<li>' . $error . '</li>';
}
$message->setData('<ul>' . $messageTxt . '</ul>');
}
// output resulting text, no need for a layout file I think
$output = '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
$output .= $xml->toString();
return $output;
}