本文整理汇总了PHP中JUDirectoryHelper::hasMultiRating方法的典型用法代码示例。如果您正苦于以下问题:PHP JUDirectoryHelper::hasMultiRating方法的具体用法?PHP JUDirectoryHelper::hasMultiRating怎么用?PHP JUDirectoryHelper::hasMultiRating使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUDirectoryHelper
的用法示例。
在下文中一共展示了JUDirectoryHelper::hasMultiRating方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
public function display($tpl = null)
{
if (!JUDirectoryHelper::hasMultiRating()) {
JError::raiseError(500, JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
return false;
}
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode('<br />', $errors));
return false;
}
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->script = $this->get('Script');
$this->canDo = JUDirectoryHelper::getActions('com_judirectory');
$this->addToolBar();
parent::display($tpl);
$this->setDocument();
}
示例2: getOptions
protected function getOptions()
{
$options = array();
foreach ($this->element->children() as $option) {
if ($option->getName() != 'option') {
continue;
}
$disabled = $option['disabled'] == 'true';
if (!$disabled && $option['value'] == 'bycriteria' && !JUDirectoryHelper::hasMultiRating()) {
$disabled = true;
}
$tmp = JHtml::_('select.option', (string) $option['value'], JText::alt(trim((string) $option), preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)), 'value', 'text', (string) $disabled);
$tmp->class = (string) $option['class'];
$tmp->onclick = (string) $option['onclick'];
$options[] = $tmp;
}
reset($options);
return $options;
}
示例3: multiRating
public function multiRating()
{
JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
$app = JFactory::getApplication();
$data = $app->input->getArray($_POST);
$listingId = $data['listing_id'];
$params = JUDirectoryHelper::getParams(null, $listingId);
$canRateListing = JUDirectoryFrontHelperPermission::canRateListing($listingId);
JUDirectoryHelper::obCleanData();
if (!$canRateListing) {
echo JText::_('COM_JUDIRECTORY_YOU_CAN_NOT_VOTE_ON_THIS_LISTING');
exit;
}
if (!JUDirectoryHelper::hasMultiRating()) {
echo JText::_('COM_JUDIRECTORY_MULTI_RATING_HAS_BEEN_DISABLED_PLEASE_CONTACT_ADMINISTRATOR');
exit;
}
$inputCookie = $app->input->cookie;
$ratingInterval = $params->get('rating_interval', 86400);
$user = JFactory::getUser();
$timeNow = JFactory::getDate()->toSql();
$timeNowStamp = strtotime($timeNow);
if ($user->get('guest')) {
$lastTimeRated = $inputCookie->get('judir-listing-rated-' . $listingId, null);
if ($lastTimeRated != null) {
if ($timeNowStamp > $lastTimeRated) {
if ($timeNowStamp - $lastTimeRated < $ratingInterval) {
echo JText::_('COM_JUDIRECTORY_YOU_ARE_ALREADY_VOTED_ON_THIS_LISTING');
exit;
}
}
}
} else {
$lastTimeRated = JUDirectoryFrontHelperRating::getLastTimeVoteListingOfUser($user->id, $listingId);
if (!$lastTimeRated) {
$lastTimeRated = 0;
}
$lastTimeRated = strtotime($lastTimeRated);
if ($lastTimeRated > 0) {
if ($timeNowStamp > $lastTimeRated) {
if ($timeNowStamp - $lastTimeRated < $ratingInterval) {
echo JText::_('COM_JUDIRECTORY_YOU_ARE_ALREADY_VOTED_ON_THIS_LISTING');
exit;
}
}
}
}
$dataValid = array();
$mainCatId = JUDirectoryFrontHelperCategory::getMainCategoryId($listingId);
$criteriaArray = JUDirectoryFrontHelperCriteria::getCriteriasByCatId($mainCatId);
$postCriteria = $data['criteria'];
if (count($criteriaArray) > 0) {
foreach ($criteriaArray as $key => $criteria) {
if ($criteria->required) {
if (isset($postCriteria[$criteria->id]) && $postCriteria[$criteria->id] > 0 && $postCriteria[$criteria->id] <= 10) {
$criteria->value = $postCriteria[$criteria->id];
} else {
echo JText::_('Invalid Field ' . $criteria->title);
exit;
}
} else {
if (isset($postCriteria[$criteria->id]) && $postCriteria[$criteria->id] > 0 && $postCriteria[$criteria->id] <= 10) {
$criteria->value = $postCriteria[$criteria->id];
} else {
unset($criteriaArray[$key]);
}
}
}
} else {
echo JText::_('COM_JUDIRECTORY_VOTING_FAILED_PLEASE_CONTACT_ADMINISTRATOR');
exit;
}
$model = $this->getModel();
JUDirectoryHelper::obCleanData();
if ($model->saveRating($dataValid, $listingId, $criteriaArray)) {
echo JText::_('COM_JUDIRECTORY_THANK_YOU_FOR_VOTING');
} else {
echo JText::_('COM_JUDIRECTORY_VOTING_FAILED_PLEASE_CONTACT_ADMINISTRATOR');
}
exit;
}
示例4:
?>
/administrator/components/com_judirectory/assets/img/icon/criteria.png" />
<span><?php
echo JText::_('COM_JUDIRECTORY_DASHBOARD_CRITERIAS');
?>
</span>
</a>
</div>
</div>
</div>
<?php
}
?>
<?php
if (JUDirectoryHelper::checkGroupPermission(null, "criteriagroups") && JUDirectoryHelper::hasMultiRating()) {
?>
<div class="cpanel">
<div class="icon-wrapper">
<div class="icon">
<a href="<?php
echo JRoute::_('index.php?option=com_judirectory&view=criteriagroups');
?>
">
<img alt="<?php
echo JText::_('COM_JUDIRECTORY_DASHBOARD_CRITERIA_GROUPS');
?>
" src="<?php
echo JUri::root(true);
?>
/administrator/components/com_judirectory/assets/img/icon/criteria-group.png" />
示例5:
<a href="<?php
echo JRoute::_('index.php?option=com_judirectory&task=fieldgroup.edit&id=' . $item->fieldgroup_id);
?>
">
<?php
echo $item->field_group_title;
?>
</a>
<?php
} else {
echo $item->field_group_title;
}
?>
</td>
<?php
if (JUDirectoryHelper::hasMultiRating()) {
?>
<td>
<?php
if ($item->selected_criteriagroup > 0) {
?>
<a href="<?php
echo JRoute::_('index.php?option=com_judirectory&task=criteriagroup.edit&id=' . $item->selected_criteriagroup);
?>
">
<?php
echo $item->selected_criteriagroup_title;
?>
</a>
<?php
} else {
示例6: getOutput
public function getOutput($options = array())
{
if (!$this->isPublished()) {
return "";
}
$options = new JRegistry($options);
$this->initMultipleRatingField();
$this->loadDefaultAssets();
if ($this->listing->cat_id) {
$this->criteriaGroupId = JUDirectoryFrontHelperCriteria::getCriteriaGroupIdByCategoryId($this->listing->cat_id);
}
if (JUDirectoryHelper::hasMultiRating()) {
if ($this->criteriaGroupId) {
$this->criteriaObjectList = JUDirectoryFrontHelperCriteria::getCriteriasByCatId($this->listing->cat_id);
}
}
$this->selectedStar = round($this->listing->rating * $this->totalStars / 10, 2);
if ($this->isDetailsView($options)) {
$this->canRateListing = JUDirectoryFrontHelperPermission::canRateListing($this->listing_id);
$document = JFactory::getDocument();
$document->addStyleSheet(JUri::root(true) . "/components/com_judirectory/assets/css/jquery.rating.css");
$document->addScript(JUri::root(true) . "/components/com_judirectory/assets/js/jquery.MetaData.js");
$document->addScript(JUri::root(true) . "/components/com_judirectory/assets/js/jquery.rating.js");
$singleRatingScript = '
jQuery(document).ready(function ($) {
$(".judir-single-rating").rating({
callback: function (value) {
var str = $(this).attr("name");
var patt = /^judir-listing-rating-result-(.*)$/i;
var result = str.match(patt);
var listingId = result[1];
var ratingValue = $(this).val();
var objectListing = {};
var token = $("#judir-single-rating-token").attr("name");
objectListing.listing_id = listingId;
objectListing.ratingValue = ratingValue;
if ($.isNumeric(listingId) && (ratingValue > 0 && ratingValue <= 10)) {
$.ajax({
type: "POST",
url : "index.php?option=com_judirectory&task=listing.singleRating&" + token + "=1",
data: objectListing
}).done(function (msg) {
alert(msg);
});
}
}
});
});';
if ($this->canRateListing) {
$document->addScriptDeclaration($singleRatingScript);
}
}
if (is_object($this->multiRating)) {
return $this->multiRating->getOutput($options);
} else {
$this->setVariable('options', $options);
$this->setVariable('className', __CLASS__);
return $this->fetch('output.php', __CLASS__);
}
}
示例7: defined
<?php
/**
* ------------------------------------------------------------------------
* JUDirectory for Joomla 2.5, 3.x
* ------------------------------------------------------------------------
*
* @copyright Copyright (C) 2010-2015 JoomUltra Co., Ltd. All Rights Reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author JoomUltra Co., Ltd
* @website http://www.joomultra.com
* @----------------------------------------------------------------------@
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
if (JUDirectoryHelper::hasMultiRating() && isset($this->item->fields['rating']) && $this->item->fields['rating']->canView()) {
echo $this->item->fields['rating']->getDisplayPrefixText() . ' ' . $this->item->fields['rating']->getOutput(array("view" => "details", "template" => $this->template, "type" => "multi_rating")) . ' ' . $this->item->fields['rating']->getDisplaySuffixText();
}
示例8: canRateListing
public static function canRateListing($listingId)
{
$listingObject = JUDirectoryHelper::getListingById($listingId);
if (!is_object($listingObject)) {
return false;
}
$params = JUDirectoryHelper::getParams(null, $listingId);
if (!$params->get('enable_listing_rate', 1)) {
return false;
}
$userCanViewListing = JUDirectoryFrontHelperPermission::userCanDoListing($listingId, true);
if (!$userCanViewListing) {
return false;
}
$ratingField = new JUDirectoryFieldCore_rating();
if (!$ratingField->canView()) {
return false;
}
$user = JFactory::getUser();
$criteriaGroupId = JUDirectoryFrontHelperCriteria::getCriteriaGroupIdByCategoryId($listingObject->cat_id);
if ($criteriaGroupId == 0 || !JUDirectoryHelper::hasMultiRating()) {
$assetName = 'com_judirectory.category.' . $listingObject->cat_id;
if ($user->authorise('judir.single.rate', $assetName)) {
if ($user->authorise('judir.single.rate.many_times', $assetName)) {
return true;
} else {
if ($user->get('guest')) {
$session = JFactory::getSession();
if (!$session->has('judir-listing-rated-' . $listingId)) {
return true;
}
} else {
$totalVoteTimes = JUDirectoryFrontHelperRating::getTotalListingVotesOfUser($user->id, $listingId);
if ($totalVoteTimes == 0) {
return true;
}
}
}
}
} else {
$assetName = 'com_judirectory.criteriagroup.' . $criteriaGroupId;
if ($user->authorise('judir.criteria.rate', $assetName)) {
if ($user->authorise('judir.criteria.rate.many_times', $assetName)) {
return true;
} else {
if ($user->get('guest')) {
$session = JFactory::getSession();
if (!$session->has('judir-listing-rated-' . $listingId)) {
return true;
}
} else {
$totalVoteTimes = JUDirectoryFrontHelperRating::getTotalListingVotesOfUser($user->id, $listingId);
if ($totalVoteTimes == 0) {
return true;
}
}
}
}
}
return false;
}
示例9: copyListings
//.........这里部分代码省略.........
$query->select("field.*");
$query->from("#__judirectory_fields AS field");
$query->select("plg.folder");
$query->join("", "#__judirectory_plugins AS plg ON field.plugin_id = plg.id");
if ($copy_extra_fields && $ori_fieldgroup_id) {
$query->where("field.group_id IN (1, {$ori_fieldgroup_id})");
} else {
$query->where("field.group_id = 1");
}
$query->order('field.group_id, field.ordering');
$db->setQuery($query);
$fields = $db->loadObjectList();
foreach ($fields as $field) {
$fieldObj = JUDirectoryFrontHelperField::getField($field, $listing_id);
$fieldObj->onCopy($newListingId, $fieldsData);
}
if (in_array('copy_related_listings', $copy_option_arr)) {
$query = "INSERT INTO `#__judirectory_listings_relations` (listing_id, listing_id_related, ordering) SELECT {$newListingId}, listing_id_related, ordering FROM `#__judirectory_listings_relations` WHERE listing_id = {$listing_id}";
$db->setQuery($query);
$db->execute();
}
if (in_array('copy_rates', $copy_option_arr)) {
$ratingMapping = array();
$query = "SELECT * FROM #__judirectory_rating WHERE listing_id = {$listing_id}";
$db->setQuery($query);
$ratings = $db->loadObjectList();
if (count($ratings)) {
$criteriagroup_id = JUDirectoryHelper::getCriteriaGroupIdByListingId($listing_id);
foreach ($ratings as $rating) {
$oldRatingId = $rating->id;
$rating->id = 0;
$rating->listing_id = $newListingId;
if ($db->insertObject('#__judirectory_rating', $rating, 'id')) {
if (JUDirectoryHelper::hasMultiRating() && $criteriagroup_id && $criteriagroup_id == $catTable->criteriagroup_id) {
JUDirectoryMultiRating::copyCriteriaValue($rating->id, $oldRatingId);
}
$ratingMapping[$oldRatingId] = $rating->id;
}
}
}
}
if (in_array('copy_comments', $copy_option_arr)) {
$query = "SELECT id FROM #__judirectory_comments WHERE listing_id=" . $listing_id . " AND parent_id = 1";
$db->setQuery($query);
$commentIds = $db->loadColumn();
$commentMapping = array();
while (!empty($commentIds)) {
$commentId = array_shift($commentIds);
$query = "SELECT id FROM #__judirectory_comments WHERE listing_id=" . $listing_id . " AND parent_id = {$commentId}";
$db->setQuery($query);
$_commentIds = $db->loadColumn();
foreach ($_commentIds as $_commentId) {
if (!in_array($_commentId, $commentIds)) {
array_push($commentIds, $_commentId);
}
}
$commentTable->load($commentId, true);
$commentTable->id = 0;
$commentTable->listing_id = $newListingId;
$commentTable->parent_id = isset($commentMapping[$commentTable->parent_id]) ? $commentMapping[$commentTable->parent_id] : 0;
if (in_array('copy_rates', $copy_option_arr)) {
$commentTable->rating_id = isset($ratingMapping[$commentTable->rating_id]) ? $ratingMapping[$commentTable->rating_id] : 0;
}
$commentTable->store();
$new_comment_id = $commentTable->id;
$commentMapping[$commentId] = $new_comment_id;
示例10: saveComment
public function saveComment($postData = array())
{
$user = JFactory::getUser();
$nowDate = JFactory::getDate()->toSql();
$title = htmlspecialchars($postData['title']);
$comment = htmlspecialchars($postData['comment'], ENT_NOQUOTES);
if ($user->get('guest')) {
$guestName = strip_tags($postData['guest_name']);
$guestEmail = strip_tags($postData['guest_email']);
} else {
$guestName = '';
$guestEmail = '';
}
$website = isset($postData['website']) ? strip_tags($postData['website']) : '';
$listingId = (int) $postData['listing_id'];
$params = JUDirectoryHelper::getParams(null, $listingId);
$totalVotes = 0;
$helpfulVotes = 0;
$ipAddress = JUDirectoryFrontHelper::getIpAddress();
$parentId = (int) $postData['parent_id'];
$rootComment = JUDirectoryFrontHelperComment::getRootComment();
if ($parentId == $rootComment->id) {
$approved = JUDirectoryFrontHelperPermission::canAutoApprovalComment($listingId);
$level = 1;
if ($params->get('filter_comment_language', 0)) {
$language = $postData['comment_language'];
} else {
$language = '*';
}
} else {
$approved = JUDirectoryFrontHelperPermission::canAutoApprovalReplyComment($listingId);
$parentComment = $this->getCommentObject($parentId);
$level = $parentComment->level + 1;
$language = '*';
}
if ($approved) {
$approved = 1;
$published = 1;
} else {
$approved = 0;
$published = 0;
}
$dataComment = array('title' => $title, 'comment' => $comment, 'user_id' => $user->id, 'guest_name' => $guestName, 'guest_email' => $guestEmail, 'website' => $website, 'listing_id' => $listingId, 'created' => $nowDate, 'total_votes' => $totalVotes, 'helpful_votes' => $helpfulVotes, 'ip_address' => $ipAddress, 'approved' => $approved, 'published' => $published, 'parent_id' => $parentId, 'level' => $level, 'language' => $language);
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_judirectory/tables');
$commentTable = JTable::getInstance('Comment', 'JUDirectoryTable');
$commentTable->setLocation($postData['parent_id'], 'last-child');
$commentTable->bind($dataComment);
if (!$commentTable->check() || !$commentTable->store()) {
$this->setError($commentTable->getError());
return false;
}
$canRateListing = JUDirectoryFrontHelperPermission::canRateListing($listingId);
if ($canRateListing && $params->get('enable_listing_rate_in_comment_form', 1) && $commentTable->parent_id == $rootComment->id) {
$postData['approved'] = $approved;
$criteriaArray = array();
if (isset($postData['criteria_array'])) {
if (JUDirectoryHelper::hasMultiRating()) {
$criteriaArray = $postData['criteria_array'];
$saveRating = $this->saveRating($postData, $listingId, $criteriaArray, $commentTable->id);
}
} else {
if (isset($postData['ratingValue'])) {
$saveRating = $this->saveRating($postData, $listingId, $criteriaArray, $commentTable->id);
}
}
if (!$saveRating) {
$this->setError(JText::_('COM_JUDIRECTORY_SAVE_RATING_FAILED'));
return false;
}
}
if (JUDIRPROVERSION && isset($postData['subscribe']) && $postData['subscribe']) {
$subscriptionData = array();
$subscriptionData['user_id'] = $user->id;
$subscriptionData['type'] = 'comment';
$subscriptionData['comment_id'] = $commentTable->id;
$subscriptionData['name'] = $user->id == 0 ? $guestName : $user->username;
$subscriptionData['email'] = $user->id == 0 ? $guestEmail : $user->email;
$subscriptionData['item_id'] = $commentTable->id;
$subscriptionData['ip_address'] = $ipAddress;
$subscriptionData['created'] = $nowDate;
$subscriptionData['published'] = $user->id == 0 && $params->get('activate_subscription_by_email', 1) ? 0 : 1;
require_once JPATH_SITE . '/components/com_judirectory/models/subscribe.php';
JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_judirectory/models');
$subscribeModel = JModelLegacy::getInstance('Subscribe', 'JUDirectoryModel');
if (!$subscribeModel->add($subscriptionData)) {
$this->setError(JText::_('COM_JUDIRECTORY_SUBSCRIBE_FAILED'));
return false;
}
}
if ($commentTable->parent_id == $rootComment->id) {
JUDirectoryFrontHelperMail::sendEmailByEvent('comment.create', $commentTable->id);
$logData = array('item_id' => $commentTable->id, 'listing_id' => $listingId, 'user_id' => $user->id, 'event' => 'comment.create');
$commentSubmitType = 'create';
} else {
JUDirectoryFrontHelperMail::sendEmailByEvent('comment.reply', $commentTable->id);
$logData = array('user_id' => $user->id, 'event' => 'comment.reply', 'item_id' => $commentTable->id, 'listing_id' => $listingId, 'value' => 0, 'reference' => $commentTable->parent_id);
$commentSubmitType = 'reply';
}
JUDirectoryFrontHelperLog::addLog($logData);
$dispatcher = JDispatcher::getInstance();
//.........这里部分代码省略.........