本文整理汇总了PHP中JObject::message方法的典型用法代码示例。如果您正苦于以下问题:PHP JObject::message方法的具体用法?PHP JObject::message怎么用?PHP JObject::message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JObject
的用法示例。
在下文中一共展示了JObject::message方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: comment
function comment()
{
$mainframe = JFactory::getApplication();
jimport('joomla.mail.helper');
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
$params = K2HelperUtilities::getParams('com_k2');
$user = JFactory::getUser();
$config = JFactory::getConfig();
JLoader::register('Services_JSON', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'lib' . DS . 'JSON.php');
$json = new Services_JSON();
$response = new JObject();
//Get item
$item = JTable::getInstance('K2Item', 'Table');
$item->load(JRequest::getInt('itemID'));
//Get category
$category = JTable::getInstance('K2Category', 'Table');
$category->load($item->catid);
//Access check
if (K2_JVERSION != '15') {
if (!in_array($item->access, $user->getAuthorisedViewLevels()) || !in_array($category->access, $user->getAuthorisedViewLevels())) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
} else {
if ($item->access > $user->get('aid', 0) || $category->access > $user->get('aid', 0)) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
}
//Published check
if (!$item->published || $item->trash) {
JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
}
if (!$category->published || $category->trash) {
JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
}
//Check permissions
if ($params->get('comments') == '2' && $user->id > 0 && K2HelperPermissions::canAddComment($item->catid) || $params->get('comments') == '1') {
$row = JTable::getInstance('K2Comment', 'Table');
if (!$row->bind(JRequest::get('post'))) {
$response->message($row->getError());
echo $json->encode($response);
$mainframe->close();
}
$row->commentText = JRequest::getString('commentText', '', 'default');
$row->commentText = strip_tags($row->commentText);
//Strip a tags since all urls will be converted to links automatically on runtime.
//Additionaly strip tables to avoid layout issues.
//Also strip all attributes except src, alt and title.
//$filter = new JFilterInput(array('a', 'table'), array('src', 'alt', 'title'), 1);
//$row->commentText = $filter->clean( $row->commentText );
//Clean vars
$filter = JFilterInput::getInstance();
$row->userName = $filter->clean($row->userName, 'username');
if ($row->commentURL && preg_match('/^((http|https|ftp):\\/\\/)?[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,6}((:[0-9]{1,5})?\\/.*)?$/i', $row->commentURL)) {
$url = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $row->commentURL);
$url = str_replace(';//', '://', $url);
if ($url != '') {
$url = !strstr($url, '://') ? 'http://' . $url : $url;
$url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url);
$row->commentURL = $url;
}
} else {
$row->commentURL = '';
}
$datenow = JFactory::getDate();
$row->commentDate = K2_JVERSION == '15' ? $datenow->toMySQL() : $datenow->toSql();
if (!$user->guest) {
$row->userID = $user->id;
$row->commentEmail = $user->email;
$row->userName = $user->name;
}
$userName = trim($row->userName);
$commentEmail = trim($row->commentEmail);
$commentText = trim($row->commentText);
$commentURL = trim($row->commentURL);
if (empty($userName) || $userName == JText::_('K2_ENTER_YOUR_NAME') || empty($commentText) || $commentText == JText::_('K2_ENTER_YOUR_MESSAGE_HERE') || empty($commentEmail) || $commentEmail == JText::_('K2_ENTER_YOUR_EMAIL_ADDRESS')) {
$response->message = JText::_('K2_YOU_NEED_TO_FILL_IN_ALL_REQUIRED_FIELDS');
echo $json->encode($response);
$mainframe->close();
}
if (!JMailHelper::isEmailAddress($commentEmail)) {
$response->message = JText::_('K2_INVALID_EMAIL_ADDRESS');
echo $json->encode($response);
$mainframe->close();
}
if ($user->guest) {
$db = JFactory::getDBO();
$query = "SELECT COUNT(*) FROM #__users WHERE name=" . $db->Quote($userName) . " OR email=" . $db->Quote($commentEmail);
$db->setQuery($query);
$result = $db->loadresult();
if ($result > 0) {
$response->message = JText::_('K2_THE_NAME_OR_EMAIL_ADDRESS_YOU_TYPED_IS_ALREADY_IN_USE');
echo $json->encode($response);
$mainframe->close();
}
}
// Google reCAPTCHA
if ($params->get('antispam') == 'recaptcha' || $params->get('antispam') == 'both') {
if ($user->guest || $params->get('recaptchaForRegistered', 1)) {
if (!function_exists('_recaptcha_qsencode')) {
require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'lib' . DS . 'recaptchalib.php';
//.........这里部分代码省略.........