/** * Get widget content * * @return string|boolean */ public function getContent() { if (false === ($pageUrl = $this->getView()->pageUrl('shopping-cart'))) { return false; } return $this->getView()->partial('payment/widget/init-shopping-cart-info', ['csrf_token' => ApplicationCsrfUtility::getToken()]); }
/** * Get widget content * * @return string|boolean */ public function getContent() { if (UserIdentityService::isGuest()) { return false; } $userId = UserIdentityService::getCurrentUserIdentity()['user_id']; // process post actions if ($this->getRequest()->isPost() && ApplicationCsrfUtility::isTokenValid($this->getRequest()->getPost('csrf'))) { $action = $this->getRequest()->getPost('action'); if ($action) { switch ($action) { case 'delete_membership': $this->deleteMembership($this->getRequest()->getPost('id', -1)); break; default: } } } // get a pagination page number $pageParamName = 'page_' . $this->widgetConnectionId; $page = $this->getView()->applicationRoute()->getQueryParam($pageParamName, 1); $wrapperId = 'purchased-memberships-wrapper'; $count = (int) $this->getWidgetSetting('membership_user_list_items_count'); // get data list $dataList = $this->getView()->partial('partial/data-list', ['filter_form' => false, 'ajax' => ['wrapper_id' => $wrapperId, 'widget_connection' => $this->widgetConnectionId, 'widget_position' => $this->widgetPosition], 'paginator' => $this->getModel()->getUserMembershipConnections($userId, $page, $count), 'paginator_order_list_show' => false, 'paginator_order_list' => [], 'paginator_per_page_show' => false, 'paginator_page_query' => $pageParamName, 'unit' => 'membership/partial/_membership-user-unit', 'unit_params' => ['items_width_medium' => $this->getWidgetSetting('membership_user_list_item_width_medium'), 'items_width_small' => $this->getWidgetSetting('membership_user_list_item_width_small'), 'items_width_extra_small' => $this->getWidgetSetting('membership_user_list_item_width_extra_small')], 'uniform_height' => '#' . $wrapperId . ' .membership-info', 'per_page' => $count]); if ($this->getRequest()->isXmlHttpRequest()) { return $dataList; } return $this->getView()->partial('membership/widget/membership-user', ['csrf_token' => ApplicationCsrfUtility::getToken(), 'widget_url' => $this->getWidgetConnectionUrl(), 'membership_wrapper' => $wrapperId, 'data' => $dataList]); }
/** * Get widget content * * @return string|boolean */ public function getContent() { $disableRating = !AclService::checkPermission('pages_use_rating') || $this->getModel()->isPageRated($this->pageId, $this->getPageSlug()); // process actions if ($this->getRequest()->isPost() && ApplicationCsrf::isTokenValid($this->getRequest()->getPost('csrf'))) { if (false !== ($action = $this->getRequest()->getPost('widget_action', false)) && $this->getRequest()->isXmlHttpRequest()) { switch ($action) { case 'add_rating': return $this->getView()->json($this->addPageRating($disableRating)); default: } } } // get current page's rating info $pageRating = $this->getModel()->getPageRatingInfo($this->pageId, $this->getPageSlug()); $currentRating = $pageRating ? $this->processRatingValue($pageRating['total_rating'] / $pageRating['total_count']) : 0; return $this->getView()->partial('page/widget/rating', ['csrf' => ApplicationCsrf::getToken(), 'rating' => $currentRating, 'widget_url' => $this->getWidgetConnectionUrl(), 'big_rating' => $this->getWidgetSetting('page_rating_size') == 'big_rating', 'step_rating' => (double) $this->getWidgetSetting('page_rating_min_step'), 'disable_rating' => $disableRating]); }
/** * Get widget content * * @return string|boolean */ public function getContent() { if (AclService::checkPermission('comment_view', false)) { // is approve allowing $allowApprove = AclService::checkPermission('comment_approve', false); // process actions if (false !== ($action = $this->getRequest()->getQuery('widget_action', false)) && $this->getRequest()->isXmlHttpRequest()) { switch ($action) { case 'get_comments': // get the comment info $lastCommentId = $this->getRequest()->getQuery('widget_last_comment', -1); $commentInfo = $this->getModel()->getCommentModel()->getCommentInfo($lastCommentId, $this->pageId, $this->getPageSlug()); if ($commentInfo) { $leftComments = $this->getModel()->getCommentsCount($allowApprove, $this->pageId, $this->getPageSlug(), $commentInfo[$this->getModel()->getCommentModel()->getRightKey()]); return $this->getView()->json(['show_paginator' => $leftComments - (int) $this->getWidgetSetting('comment_per_page') > 0, 'comments' => $this->getCommentsList($allowApprove, false, $commentInfo[$this->getModel()->getCommentModel()->getRightKey()], true)]); } break; case 'add_comment': // validate and add a new comment if ($this->getRequest()->isPost()) { return $this->getView()->json($this->getAddCommentForm($allowApprove)); } break; case 'get_form': return $this->getView()->json($this->getCommentForm($allowApprove, $this->getRequest()->getQuery('widget_comment_id', null))); case 'edit_comment': // validate and edit the comment if ($this->getRequest()->isPost()) { return $this->getView()->json($this->getEditCommentForm($allowApprove, $this->getRequest()->getQuery('widget_comment_id', -1))); } break; case 'approve_comment': if ($this->getRequest()->isPost() && ApplicationCsrfUtility::isTokenValid($this->getRequest()->getPost('csrf'))) { return $this->getView()->json($this->approveComment($this->getRequest()->getQuery('widget_comment_id', -1))); } break; case 'disapprove_comment': if ($this->getRequest()->isPost() && ApplicationCsrfUtility::isTokenValid($this->getRequest()->getPost('csrf'))) { return $this->getView()->json($this->disapproveComment($this->getRequest()->getQuery('widget_comment_id', -1))); } break; case 'delete_comment': if ($this->getRequest()->isPost() && ApplicationCsrfUtility::isTokenValid($this->getRequest()->getPost('csrf'))) { return $this->getView()->json($this->deleteComment($this->getRequest()->getQuery('widget_comment_id', -1))); } break; case 'spam_comment': if ($this->getRequest()->isPost() && ApplicationCsrfUtility::isTokenValid($this->getRequest()->getPost('csrf'))) { return $this->getView()->json($this->spamComment($this->getRequest()->getQuery('widget_comment_id', -1))); } break; } } return $this->getView()->partial('comment/widget/comments-list', ['csrf_token' => ApplicationCsrfUtility::getToken(), 'base_url' => $this->getWidgetConnectionUrl(), 'comment_form' => AclService::checkPermission('comment_add', false) ? $this->getCommentForm()['form'] : null, 'comments' => $this->getCommentsList($allowApprove), 'show_paginator' => $this->getModel()->getCommentsCount($allowApprove, $this->pageId, $this->getPageSlug()) > (int) $this->getWidgetSetting('comment_per_page')]); } return false; }
/** * Get token * * @param boolean $regenerate * @return string */ public function getToken($regenerate = false) { return ApplicationCsrfUtility::getToken($regenerate); }
/** * Get widget content * * @return string|boolean */ public function getContent() { if (null != ($questionId = $this->getWidgetSetting('poll_question'))) { // get a question info if (null != ($questionInfo = $this->getModel()->getQuestionInfo($questionId))) { // get list of answers $answers = $this->getModel()->getAnswers($questionId); $isVotingDisabled = $this->getModel()->isAnswerVoteExist($questionId) || !AclService::checkPermission('polls_make_votes', false); if (count($answers) > 1) { // process post actions if ($this->getRequest()->isPost() && ApplicationCsrf::isTokenValid($this->getRequest()->getPost('csrf'))) { if (false !== ($action = $this->getRequest()->getPost('widget_action', false)) && $this->getRequest()->isXmlHttpRequest()) { switch ($action) { case 'make_vote': if (false !== ($answerId = $this->getRequest()->getPost('answer_id', false)) && !$isVotingDisabled) { if (true === ($result = $this->getModel()->addAnswerVote($questionId, $answerId))) { // increase acl track AclService::checkPermission('polls_make_votes'); } } return $this->getView()->json(['data' => $this->getPollResult($questionId, $answers)]); default: } } } // process get actions if (false !== ($action = $this->getRequest()->getQuery('widget_action', false)) && $this->getRequest()->isXmlHttpRequest()) { switch ($action) { case 'get_answers': return $this->getView()->json(['data' => $this->getPollAnswers($answers, $isVotingDisabled)]); case 'get_results': default: return $this->getView()->json(['data' => $this->getPollResult($questionId, $answers)]); } } return $this->getView()->partial('poll/widget/poll-init', ['csrf' => ApplicationCsrf::getToken(), 'widget_url' => $this->getWidgetConnectionUrl(), 'connection_id' => $this->widgetConnectionId, 'question_info' => $questionInfo, 'answers' => $this->getPollAnswers($answers, $isVotingDisabled)]); } } } return false; }