当前位置: 首页>>代码示例>>PHP>>正文


PHP QQN::NarroSuggestionVote方法代码示例

本文整理汇总了PHP中QQN::NarroSuggestionVote方法的典型用法代码示例。如果您正苦于以下问题:PHP QQN::NarroSuggestionVote方法的具体用法?PHP QQN::NarroSuggestionVote怎么用?PHP QQN::NarroSuggestionVote使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QQN的用法示例。


在下文中一共展示了QQN::NarroSuggestionVote方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Form_Create

 protected function Form_Create()
 {
     parent::Form_Create();
     // Instantiate the Meta DataGrid
     $this->dtgNarroSuggestionVotes = new NarroSuggestionVoteDataGrid($this);
     // Style the DataGrid (if desired)
     $this->dtgNarroSuggestionVotes->CssClass = 'datagrid';
     $this->dtgNarroSuggestionVotes->AlternateRowStyle->CssClass = 'alternate';
     // Add Pagination (if desired)
     $this->dtgNarroSuggestionVotes->Paginator = new QPaginator($this->dtgNarroSuggestionVotes);
     $this->dtgNarroSuggestionVotes->ItemsPerPage = __FORM_DRAFTS_FORM_LIST_ITEMS_PER_PAGE__;
     // Use the MetaDataGrid functionality to add Columns for this datagrid
     // Create an Edit Column
     $strEditPageUrl = __VIRTUAL_DIRECTORY__ . __FORM_DRAFTS__ . '/narro_suggestion_vote_edit.php';
     $this->dtgNarroSuggestionVotes->MetaAddEditLinkColumn($strEditPageUrl, 'Edit', 'Edit');
     // Create the Other Columns (note that you can use strings for narro_suggestion_vote's properties, or you
     // can traverse down QQN::narro_suggestion_vote() to display fields that are down the hierarchy)
     $this->dtgNarroSuggestionVotes->MetaAddColumn(QQN::NarroSuggestionVote()->Suggestion);
     $this->dtgNarroSuggestionVotes->MetaAddColumn(QQN::NarroSuggestionVote()->Context);
     $this->dtgNarroSuggestionVotes->MetaAddColumn(QQN::NarroSuggestionVote()->User);
     $this->dtgNarroSuggestionVotes->MetaAddColumn('VoteValue');
     $this->dtgNarroSuggestionVotes->MetaAddColumn('Created');
     $this->dtgNarroSuggestionVotes->MetaAddColumn('Modified');
 }
开发者ID:Jobava,项目名称:narro,代码行数:24,代码来源:NarroSuggestionVoteListFormBase.class.php

示例2: btnVote_Click

 public function btnVote_Click($strFormId, $strControlId, $strParameter)
 {
     if (!QApplication::HasPermissionForThisLang('Can vote', $this->objContextInfo->Context->ProjectId)) {
         return false;
     }
     $objNarroSuggestionVote = NarroSuggestionVote::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroSuggestionVote()->ContextId, $this->objContextInfo->ContextId), QQ::Equal(QQN::NarroSuggestionVote()->SuggestionId, $strParameter), QQ::Equal(QQN::NarroSuggestionVote()->UserId, QApplication::GetUserId())));
     if (!$objNarroSuggestionVote) {
         $objNarroSuggestionVote = new NarroSuggestionVote();
         $objNarroSuggestionVote->SuggestionId = $strParameter;
         $objNarroSuggestionVote->ContextId = $this->objContextInfo->ContextId;
         $objNarroSuggestionVote->UserId = QApplication::GetUserId();
         $objNarroSuggestionVote->Created = QDateTime::Now();
     }
     if (strpos($strControlId, 'votdn') === 0) {
         $objNarroSuggestionVote->VoteValue = -1;
     } else {
         $objNarroSuggestionVote->VoteValue = 1;
     }
     $objNarroSuggestionVote->Modified = QDateTime::Now();
     $objNarroSuggestionVote->Save();
     $this->objContextInfo->Modified = QDateTime::Now();
     $this->objContextInfo->Save();
     if ($this->ParentControl->ParentControl->chkRefresh->Checked && $strControlId != $this->btnKeepUntranslated->ControlId) {
         $this->ParentControl->ParentControl->btnSearch_Click();
     }
     $this->lblText->Warning = t('Thank you for your vote. You can change it anytime by voting another suggestion.');
 }
开发者ID:Jobava,项目名称:narro,代码行数:27,代码来源:NarroContextInfoEditor.class.php

示例3: CountByContextId

 /**
  * Count NarroSuggestionVotes
  * by ContextId Index(es)
  * @param integer $intContextId
  * @return int
  */
 public static function CountByContextId($intContextId)
 {
     // Call NarroSuggestionVote::QueryCount to perform the CountByContextId query
     return NarroSuggestionVote::QueryCount(QQ::Equal(QQN::NarroSuggestionVote()->ContextId, $intContextId));
 }
开发者ID:Jobava,项目名称:narro,代码行数:11,代码来源:NarroSuggestionVoteGen.class.php

示例4: __get

 public function __get($strName)
 {
     switch ($strName) {
         case 'Votes':
             $mixResult = NarroSuggestionVote::QuerySingle(QQ::Equal(QQN::NarroSuggestionVote()->SuggestionId, $this->SuggestionId), array(QQ::Sum(QQN::NarroSuggestionVote()->VoteValue, 'votes'), QQ::GroupBy(QQN::NarroSuggestionVote()->SuggestionId)));
             if ($mixResult instanceof NarroSuggestionVote) {
                 return $mixResult->GetVirtualAttribute('votes');
             } else {
                 return 0;
             }
         default:
             try {
                 return parent::__get($strName);
                 break;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
开发者ID:Jobava,项目名称:narro,代码行数:20,代码来源:NarroSuggestion.class.php

示例5: ResolveContentItem

 /**
  * Used internally by the Meta-based Add Column tools.
  *
  * Given a QQNode or a Text String, this will return a NarroSuggestionVote-based QQNode.
  * It will also verify that it is a proper NarroSuggestionVote-based QQNode, and will throw an exception otherwise.
  *
  * @param mixed $mixContent
  * @return QQNode
  */
 protected function ResolveContentItem($mixContent)
 {
     if ($mixContent instanceof QQNode) {
         if (!$mixContent->_ParentNode) {
             throw new QCallerException('Content QQNode cannot be a Top Level Node');
         }
         if ($mixContent->_RootTableName == 'narro_suggestion_vote') {
             if ($mixContent instanceof QQReverseReferenceNode && !$mixContent->_PropertyName) {
                 throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
             }
             $objCurrentNode = $mixContent;
             while ($objCurrentNode = $objCurrentNode->_ParentNode) {
                 if (!$objCurrentNode instanceof QQNode) {
                     throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
                 }
                 if ($objCurrentNode instanceof QQReverseReferenceNode && !$objCurrentNode->_PropertyName) {
                     throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
                 }
             }
             return $mixContent;
         } else {
             throw new QCallerException('Content QQNode has a root table of "' . $mixContent->_RootTableName . '". Must be a root of "narro_suggestion_vote".');
         }
     } else {
         if (is_string($mixContent)) {
             switch ($mixContent) {
                 case 'SuggestionId':
                     return QQN::NarroSuggestionVote()->SuggestionId;
                 case 'Suggestion':
                     return QQN::NarroSuggestionVote()->Suggestion;
                 case 'ContextId':
                     return QQN::NarroSuggestionVote()->ContextId;
                 case 'Context':
                     return QQN::NarroSuggestionVote()->Context;
                 case 'UserId':
                     return QQN::NarroSuggestionVote()->UserId;
                 case 'User':
                     return QQN::NarroSuggestionVote()->User;
                 case 'VoteValue':
                     return QQN::NarroSuggestionVote()->VoteValue;
                 case 'Created':
                     return QQN::NarroSuggestionVote()->Created;
                 case 'Modified':
                     return QQN::NarroSuggestionVote()->Modified;
                 default:
                     throw new QCallerException('Simple Property not found in NarroSuggestionVoteDataGrid content: ' . $mixContent);
             }
         } else {
             if ($mixContent instanceof QQAssociationNode) {
                 throw new QCallerException('Content QQNode cannot go through any "To Many" association nodes.');
             } else {
                 throw new QCallerException('Invalid Content type');
             }
         }
     }
 }
开发者ID:Jobava,项目名称:narro,代码行数:65,代码来源:NarroSuggestionVoteDataGridGen.class.php

示例6: dtgVotes_Create

 protected function dtgVotes_Create()
 {
     $dtgVotes = new NarroSuggestionVoteDataGrid($this->tabActivity);
     $dtgVotes->SetCustomStyle('padding', '5px');
     $dtgVotes->Title = sprintf(t('Votes added by <b>%s</b>'), $this->objUser->RealName);
     $colSuggestion = $dtgVotes->MetaAddColumn(QQN::NarroSuggestionVote()->Suggestion->SuggestionValue);
     $colSuggestion->Name = t('Translation');
     $colSuggestion->Html = '<?= $_CONTROL->colSuggestion_Render($_ITEM); ?>';
     $colSuggestion->HtmlEntities = false;
     $colVote = $dtgVotes->MetaAddColumn(QQN::NarroSuggestionVote()->VoteValue);
     $colVote->Name = t('Vote');
     $colVote->Html = '<?= $_ITEM->VoteValue; ?>';
     $colCreated = $dtgVotes->MetaAddColumn(QQN::NarroSuggestionVote()->Created);
     $colCreated->Name = t('Added');
     $colCreated->FilterType = QFilterType::None;
     $colCreated->Html = '<?= $_CONTROL->colCreated_Render($_ITEM); ?>';
     $colCreated->HtmlEntities = false;
     $colCreated->Wrap = false;
     // Datagrid Paginator
     $dtgVotes->Paginator = new QPaginator($dtgVotes);
     $dtgVotes->ItemsPerPage = QApplication::$User->GetPreferenceValueByName('Items per page');
     // Specify Whether or Not to Refresh using Ajax
     $dtgVotes->UseAjax = true;
     $dtgVotes->SortColumnIndex = 2;
     $dtgVotes->SortDirection = true;
     $dtgVotes->AdditionalClauses = array(QQ::Expand(QQN::NarroSuggestionVote()->Suggestion));
     $dtgVotes->AdditionalConditions = QQ::Equal(QQN::NarroSuggestionVote()->UserId, $this->objUser->UserId);
     $dtgVotes->btnFilter_Click($this->Form->FormId, $dtgVotes->FilterButton->ControlId, '');
 }
开发者ID:Jobava,项目名称:narro,代码行数:29,代码来源:NarroUserSuggestionsPanel.class.php

示例7: GetUserSuggestion

 /**
  * Get the suggestion made by a specified user
  *
  * @param integer $intContextId
  * @param integer $intTextId
  * @param integer $intUserId
  * @return NarroSuggestion
  */
 public function GetUserSuggestion($intContextId, $intTextId, $intUserId)
 {
     $arrSuggestion = NarroSuggestion::QueryArray(QQ::AndCondition(QQ::Equal(QQN::NarroSuggestion()->UserId, $intUserId), QQ::Equal(QQN::NarroSuggestion()->TextId, $intTextId), QQ::Equal(QQN::NarroSuggestion()->LanguageId, $this->objTargetLanguage->LanguageId)));
     if (count($arrSuggestion) == 1) {
         return $arrSuggestion[0];
     } elseif (count($arrSuggestion) > 1) {
         /**
          * if there are more suggestions for a user, get the one that he has voted for
          */
         $objSuggestionVote = NarroSuggestionVote::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroSuggestionVote()->UserId, $intUserId), QQ::Equal(QQN::NarroSuggestionVote()->ContextId, $intContextId), QQ::Equal(QQN::NarroSuggestionVote()->Context->NarroContextInfoAsContext->LanguageId, $this->objTargetLanguage->LanguageId)));
         if ($objSuggestionVote) {
             return NarroSuggestion::Load($objSuggestionVote->SuggestionId);
         } else {
             /**
              * the user has more suggestions but has voted none
              */
             return false;
         }
     } else {
         /**
          * The user has no suggestions for this text
          */
         return false;
     }
 }
开发者ID:Jobava,项目名称:narro,代码行数:33,代码来源:NarroFileImporter.class.php


注:本文中的QQN::NarroSuggestionVote方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。