本文整理汇总了PHP中JUDownloadHelper::hasMultiRating方法的典型用法代码示例。如果您正苦于以下问题:PHP JUDownloadHelper::hasMultiRating方法的具体用法?PHP JUDownloadHelper::hasMultiRating怎么用?PHP JUDownloadHelper::hasMultiRating使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUDownloadHelper
的用法示例。
在下文中一共展示了JUDownloadHelper::hasMultiRating方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
public function display($tpl = null)
{
if (!JUDownloadHelper::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 = JUDownloadHelper::getActions('com_judownload');
$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' && !JUDownloadHelper::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:
<a href="<?php
echo JRoute::_('index.php?option=com_judownload&task=fieldgroup.edit&id=' . $item->fieldgroup_id);
?>
">
<?php
echo $item->field_group_title;
?>
</a>
<?php
} else {
echo $item->field_group_title;
}
?>
</td>
<?php
if (JUDownloadHelper::hasMultiRating()) {
?>
<td>
<?php
if ($item->selected_criteriagroup > 0) {
?>
<a href="<?php
echo JRoute::_('index.php?option=com_judownload&task=criteriagroup.edit&id=' . $item->selected_criteriagroup);
?>
">
<?php
echo $item->selected_criteriagroup_title;
?>
</a>
<?php
} else {
示例4:
?>
/administrator/components/com_judownload/assets/img/icon/criteria.png" />
<span><?php
echo JText::_('COM_JUDOWNLOAD_DASHBOARD_CRITERIAS');
?>
</span>
</a>
</div>
</div>
</div>
<?php
}
?>
<?php
if (JUDownloadHelper::checkGroupPermission(null, "criteriagroups") && JUDownloadHelper::hasMultiRating()) {
?>
<div class="cpanel">
<div class="icon-wrapper">
<div class="icon">
<a href="<?php
echo JRoute::_('index.php?option=com_judownload&view=criteriagroups');
?>
">
<img alt="<?php
echo JText::_('COM_JUDOWNLOAD_DASHBOARD_CRITERIA_GROUPS');
?>
" src="<?php
echo JUri::root(true);
?>
/administrator/components/com_judownload/assets/img/icon/criteria-group.png" />
示例5: getOutput
public function getOutput($options = array())
{
if (!$this->isPublished())
{
return "";
}
$options = new JRegistry($options);
$this->initMultipleRatingField();
$this->loadDefaultAssets();
if ($this->doc->cat_id)
{
$this->criteriaGroupId = JUDownloadFrontHelperCriteria::getCriteriaGroupIdByCategoryId($this->doc->cat_id);
}
if (JUDownloadHelper::hasMultiRating())
{
if ($this->criteriaGroupId)
{
$this->criteriaObjectList = JUDownloadFrontHelperCriteria::getCriteriasByCatId($this->doc->cat_id);
}
}
$this->selectedStar = round($this->doc->rating * $this->totalStars / 10, 2);
if ($this->isDetailsView($options))
{
$this->canRateDocument = JUDownloadFrontHelperPermission::canRateDocument($this->doc_id);
$document = JFactory::getDocument();
$document->addStyleSheet(JUri::root(true) . "/components/com_judownload/assets/css/jquery.rating.css");
$document->addScript(JUri::root(true) . "/components/com_judownload/assets/js/jquery.MetaData.js");
$document->addScript(JUri::root(true) . "/components/com_judownload/assets/js/jquery.rating.js");
$singleRatingScript = '
jQuery(document).ready(function ($) {
$(".judl-single-rating").rating({
callback: function (value) {
var str = $(this).attr("name");
var patt = /^judl-document-rating-result-(.*)$/i;
var result = str.match(patt);
var documentId = result[1];
var ratingValue = $(this).val();
var objectDocument = {};
var token = $("#judl-single-rating-token").attr("name");
objectDocument.doc_id = documentId;
objectDocument.ratingValue = ratingValue;
if ($.isNumeric(documentId) && (ratingValue > 0 && ratingValue <= 10)) {
$.ajax({
type: "POST",
url : "index.php?option=com_judownload&task=document.singleRating&" + token + "=1",
data: objectDocument
}).done(function (msg) {
alert(msg);
});
}
}
});
});';
if ($this->canRateDocument)
{
$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__);
}
}
示例6: copyDocuments
//.........这里部分代码省略.........
$query = "SELECT * FROM #__judownload_changelogs WHERE `doc_id` = {$doc_id}";
$db->setQuery($query);
$changelogs = $db->loadObjectList();
if ($changelogs) {
foreach ($changelogs as $changelog) {
$changelogTable->reset();
if ($changelogTable->bind($changelog) && $changelogTable->check()) {
$changelogTable->id = 0;
$changelogTable->doc_id = $newDocId;
$changelogTable->store();
} else {
continue;
}
}
}
}
if (in_array('copy_related_documents', $copy_option_arr)) {
$query = "INSERT INTO `#__judownload_documents_relations` (doc_id, doc_id_related, ordering) SELECT {$newDocId}, doc_id_related, ordering FROM `#__judownload_documents_relations` WHERE doc_id = {$doc_id}";
$db->setQuery($query);
$db->execute();
}
if (in_array('copy_rates', $copy_option_arr)) {
$ratingMapping = array();
$query = "SELECT * FROM #__judownload_rating WHERE doc_id = {$doc_id}";
$db->setQuery($query);
$ratings = $db->loadObjectList();
if (count($ratings)) {
$criteriagroup_id = JUDownloadHelper::getCriteriaGroupIdByDocId($doc_id);
foreach ($ratings as $rating) {
$oldRatingId = $rating->id;
$rating->id = 0;
$rating->doc_id = $newDocId;
if ($db->insertObject('#__judownload_rating', $rating, 'id')) {
if (JUDownloadHelper::hasMultiRating() && $criteriagroup_id && $criteriagroup_id == $catTable->criteriagroup_id) {
JUDownloadMultiRating::copyCriteriaValue($rating->id, $oldRatingId);
}
$ratingMapping[$oldRatingId] = $rating->id;
}
}
}
}
if (in_array('copy_comments', $copy_option_arr)) {
$query = "SELECT id FROM #__judownload_comments WHERE doc_id=" . $doc_id . " AND parent_id = 1";
$db->setQuery($query);
$commentIds = $db->loadColumn();
$commentMapping = array();
while (!empty($commentIds)) {
$commentId = array_shift($commentIds);
$query = "SELECT id FROM #__judownload_comments WHERE doc_id=" . $doc_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->doc_id = $newDocId;
$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;
示例7: defined
<?php
/**
* ------------------------------------------------------------------------
* JUDownload 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 (JUDownloadHelper::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: 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']) : '';
$docId = (int) $postData['doc_id'];
$params = JUDownloadHelper::getParams(null, $docId);
$totalVotes = 0;
$helpfulVotes = 0;
$ipAddress = JUDownloadFrontHelper::getIpAddress();
$parentId = (int) $postData['parent_id'];
$rootComment = JUDownloadFrontHelperComment::getRootComment();
if ($parentId == $rootComment->id)
{
$approved = JUDownloadFrontHelperPermission::canAutoApprovalComment($docId);
$level = 1;
if ($params->get('filter_comment_language', 0))
{
$language = $postData['comment_language'];
}
else
{
$language = '*';
}
}
else
{
$approved = JUDownloadFrontHelperPermission::canAutoApprovalReplyComment($docId);
$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,
'doc_id' => $docId, '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_judownload/tables');
$commentTable = JTable::getInstance('Comment', 'JUDownloadTable');
$commentTable->setLocation($postData['parent_id'], 'last-child');
$commentTable->bind($dataComment);
if (!$commentTable->check() || !$commentTable->store())
{
$this->setError($commentTable->getError());
return false;
}
$canRateDocument = JUDownloadFrontHelperPermission::canRateDocument($docId);
if ($canRateDocument && $params->get('enable_doc_rate_in_comment_form', 1) && ($commentTable->parent_id == $rootComment->id))
{
$postData['approved'] = $approved;
$criteriaArray = array();
if (isset($postData['criteria_array']))
{
if (JUDownloadHelper::hasMultiRating())
{
$criteriaArray = $postData['criteria_array'];
//.........这里部分代码省略.........
示例9: multiRating
public function multiRating()
{
JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
$app = JFactory::getApplication();
$data = $app->input->getArray($_POST);
$documentId = $data['doc_id'];
$params = JUDownloadHelper::getParams(null, $documentId);
$canRateDocument = JUDownloadFrontHelperPermission::canRateDocument($documentId);
JUDownloadHelper::obCleanData();
if (!$canRateDocument)
{
echo JText::_('COM_JUDOWNLOAD_YOU_CAN_NOT_VOTE_ON_THIS_DOCUMENT');
exit;
}
if (!JUDownloadHelper::hasMultiRating())
{
echo JText::_('COM_JUDOWNLOAD_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('judl-document-rated-' . $documentId, null);
if ($lastTimeRated != null)
{
if ($timeNowStamp > $lastTimeRated)
{
if ($timeNowStamp - $lastTimeRated < $ratingInterval)
{
echo JText::_('COM_JUDOWNLOAD_YOU_ARE_ALREADY_VOTED_ON_THIS_DOCUMENT');
exit;
}
}
}
}
else
{
$lastTimeRated = JUDownloadFrontHelperRating::getLastTimeVoteDocumentOfUser($user->id, $documentId);
if (!$lastTimeRated)
{
$lastTimeRated = 0;
}
$lastTimeRated = strtotime($lastTimeRated);
if ($lastTimeRated > 0)
{
if ($timeNowStamp > $lastTimeRated)
{
if ($timeNowStamp - $lastTimeRated < $ratingInterval)
{
echo JText::_('COM_JUDOWNLOAD_YOU_ARE_ALREADY_VOTED_ON_THIS_DOCUMENT');
exit;
}
}
}
}
$dataValid = array();
$mainCatId = JUDownloadFrontHelperCategory::getMainCategoryId($documentId);
$criteriaArray = JUDownloadFrontHelperCriteria::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];
//.........这里部分代码省略.........
示例10: canRateDocument
public static function canRateDocument($documentId)
{
$documentObject = JUDownloadHelper::getDocumentById($documentId);
if (!is_object($documentObject))
{
return false;
}
$params = JUDownloadHelper::getParams(null, $documentId);
if (!$params->get('enable_document_rate', 1))
{
return false;
}
$userCanViewDocument = JUDownloadFrontHelperPermission::userCanDoDocument($documentId, true);
if (!$userCanViewDocument)
{
return false;
}
$ratingField = new JUDownloadFieldCore_rating();
if (!$ratingField->canView())
{
return false;
}
$user = JFactory::getUser();
$criteriaGroupId = JUDownloadFrontHelperCriteria::getCriteriaGroupIdByCategoryId($documentObject->cat_id);
if ($criteriaGroupId == 0 || !JUDownloadHelper::hasMultiRating())
{
$assetName = 'com_judownload.category.' . $documentObject->cat_id;
if ($user->authorise('judl.single.rate', $assetName) || (JUDownloadFrontHelperPermission::canDownloadDocument($documentId) && $params->get('can_download_can_rate', 0)))
{
if ($user->authorise('judl.single.rate.many_times', $assetName))
{
return true;
}
else
{
if ($user->get('guest'))
{
$session = JFactory::getSession();
if (!$session->has('judl-document-rated-' . $documentId))
{
return true;
}
}
else
{
$totalVoteTimes = JUDownloadFrontHelperRating::getTotalDocumentVotesOfUser($user->id, $documentId);
if ($totalVoteTimes == 0)
{
return true;
}
}
}
}
}
else
{
$assetName = 'com_judownload.criteriagroup.' . $criteriaGroupId;
if ($user->authorise('judl.criteria.rate', $assetName) || (JUDownloadFrontHelperPermission::canDownloadDocument($documentId) && $params->get('can_download_can_rate', 0)))
{
if ($user->authorise('judl.criteria.rate.many_times', $assetName))
{
return true;
}
else
{
if ($user->get('guest'))
{
$session = JFactory::getSession();
if (!$session->has('judl-document-rated-' . $documentId))
{
return true;
}
}
else
{
$totalVoteTimes = JUDownloadFrontHelperRating::getTotalDocumentVotesOfUser($user->id, $documentId);
if ($totalVoteTimes == 0)
{
return true;
}
}
}
}
}
return false;
}