Advertisement
Guest User

Untitled

a guest
Dec 25th, 2013
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.30 KB | None | 0 0
  1. <?php
  2.  public function ProfileController_Stars_Create($Sender, $UserReference = '', $Username = '', $Page = '', $UserID = '')
  3.                 {
  4.         $Sender->EditMode(FALSE);
  5.        
  6.       // Tell the ProfileController what tab to load
  7.         $Sender->GetUserInfo($UserReference, $Username, $UserID);
  8.       $Sender->_SetBreadcrumbs(T('Stars'), '/profile/stars');
  9.       $MyView = $this->GetView('profile.php');
  10.       $Sender->SetTabView(T('Stars'), $MyView); //$Sender->SetTabView('Stars', 'Profile', $MyView, 'Vanilla');
  11.         $Sender->CountCommentsPerPage = C('Vanilla.Comments.PerPage', 30);
  12.      
  13.       list($Offset, $Limit) = OffsetLimit($Page, Gdn::Config('Vanilla.Discussions.PerPage', 30));
  14.      
  15.       $Trans = Gdn::SQL()
  16.               ->Select('st.InsertUserID,st.Amount,st.Date,st.DiscussionID,st.CommentID')
  17.               ->From('StarsTrans st')
  18.               ->Where('ReceiveUserID',$Sender->User->UserID)
  19.               ->OrderBy('st.Date', 'dsc')
  20.               ->Limit($Limit, $Offset)
  21.               ->Get();
  22.       $Transcount = Gdn::SQL()
  23.               ->Where('ReceiveUserID',$Sender->User->UserID)
  24.               ->GetCount('StarsTrans', $Trans);
  25.       $Transcount = $Transcount; //+ $Offset + 1;
  26.       $Sender->SetData('Transactions', $Trans);
  27.       $Sender->SetData('TransCount',$Transcount);
  28.      
  29.       // Build a pager
  30.      /* $PagerFactory = new Gdn_PagerFactory();
  31.       $Sender->Pager = $PagerFactory->GetPager('MorePager', $Sender);
  32.       $Sender->Pager->MoreCode = T('More Ratings');
  33.       $Sender->Pager->LessCode = T('Newer Ratings');
  34.       $Sender->Pager->ClientID = 'Pager';
  35.       $Sender->Pager->Configure(
  36.          $Offset,
  37.          $Limit,
  38.          $Transcount,
  39.          UserUrl($Sender->User, '', 'stars').'/{Page}'
  40.       );
  41.      
  42.       // Deliver JSON data if necessary
  43.       if ($Sender->DeliveryType() != DELIVERY_TYPE_ALL && $Offset > 0) {
  44.          $Sender->SetJson('LessRow', $Sender->Pager->ToString('less'));
  45.          $Sender->SetJson('MoreRow', $Sender->Pager->ToString('more'));
  46.          $Sender->View = $MyView;
  47.       }
  48.       */
  49.       // Set the HandlerType back to normal on the profilecontroller so that it fetches it's own views
  50.       $Sender->HandlerType = HANDLER_TYPE_NORMAL;
  51.      
  52.       // Do not show discussion options
  53.       $Sender->ShowOptions = FALSE;
  54.      
  55.       if ($Sender->Head) {
  56.          // These pages offer only duplicate content to search engines and are a bit slow.
  57.          $Sender->Head->AddTag('meta', array('name' => 'robots', 'content' => 'noindex,noarchive'));
  58.       }
  59.       $ProfileView = $Sender->FetchViewLocation('index', 'ProfileController', 'dashboard');
  60.       // Render the ProfileController
  61.       $Sender->Render($ProfileView);
  62.         }
  63. ?>
  64. Profile.php :
  65. <?php
  66. echo '<h2 class="H">'.T('Ratings').'</h2>';
  67. $PagerOptions = array('Wrapper' => '<span class="PagerNub">&#160;</span><div %1$s>%2$s</div>', 'RecordCount' => $this->Data('TransCount'), 'CurrentRecords' => $this->Data('Transactions')->NumRows());
  68. //if ($this->Data('_PagerUrl'))
  69.   // $PagerOptions['Url'] = $this->Data('_PagerUrl');
  70. echo '<div class="PageControls Top">';
  71.    PagerModule::Write($PagerOptions);
  72.    echo '</div>';
  73. $Trans = $this->Data('Transactions');
  74.  
  75. if ($this->Data('TransCount') <= 0) {
  76.    echo Wrap(T("This user has not made any discussions yet."), 'div', array('Class' => 'Empty'));
  77. }
  78. else {
  79.     $List = array();
  80. foreach($Trans as $Tran)
  81.     $List[] = $Tran->InsertUserID;
  82. $UserModel = new UserModel();
  83. $Names = $UserModel->GetIDs($List);
  84. Anchor()
  85. ?>
  86. <table class="RatingTable">
  87.     <thead>
  88.         <tr>
  89.             <td class="RateHeading"><? echo T('User') ?> </td>
  90.             <td class="RateHeading"><? echo T('Amount') ?> </td>
  91.                         <td class="RateHeading"><? echo T('Date') ?> </td>
  92.         </tr>
  93.         <tr>
  94.     </thead>
  95.     <tbody>
  96.         <? foreach($Trans as $Tran): ?>
  97.         <tr>
  98.             <td class="RateTD"> <? echo Anchor($Names[$Tran->InsertUserID][Name],"/profile/".$Tran->InsertUserID.'/'.$Names[$Tran->InsertUserID][Name],"RateLink"); ?> </td>
  99.             <td class="RateTD"> <? echo $Tran->Amount; ?> </td>
  100.                         <td class="RateTD"> <?  if ($Tran->CommentID != NULL)
  101.                                                     echo Anchor($Tran->Date,'/discussion/comment/'.$Tran->CommentID.'/#Comment_'.$Tran->CommentID);
  102.                                                     else
  103.                                                     echo Anchor($Tran->Date,'/discussion/'.$Tran->DiscussionID); ?> </td>
  104.         </tr>
  105.         <? endforeach ?>
  106.     </tbody>
  107. </table>
  108. <?php
  109. }
  110. /*foreach ($Trans as $Tran)
  111. {
  112.     decho($Tran);
  113. }*/
  114.  //echo($this->Pager);
  115.  //decho($this->Data('TransCount'));this->Data('TransCount'), 'CurrentRecords' => $this->Data('Transactions')->NumRows());
  116. //if ($this->Data('_PagerUrl'))
  117.   // $PagerOptions['Url'] = $this->Data('_PagerUrl');
  118. echo '<div class="PageControls Top">';
  119.    PagerModule::Write($PagerOptions);
  120.    echo '</div>';
  121. $Trans = $this->Data('Transactions');
  122.  
  123. if ($this->Data('TransCount') <= 0) {
  124.    echo Wrap(T("This user has not made any discussions yet."), 'div', array('Class' => 'Empty'));
  125. }
  126. else {
  127.     $List = array();
  128. foreach($Trans as $Tran)
  129.     $List[] = $Tran->InsertUserID;
  130. $UserModel = new UserModel();
  131. $Names = $UserModel->GetIDs($List);
  132. Anchor()
  133. ?>
  134. <table class="RatingTable">
  135.     <thead>
  136.         <tr>
  137.             <td class="RateHeading"><? echo T('User') ?> </td>
  138.             <td class="RateHeading"><? echo T('Amount') ?> </td>
  139.                         <td class="RateHeading"><? echo T('Date') ?> </td>
  140.         </tr>
  141.         <tr>
  142.     </thead>
  143.     <tbody>
  144.         <? foreach($Trans as $Tran): ?>
  145.         <tr>
  146.             <td class="RateTD"> <? echo Anchor($Names[$Tran->InsertUserID][Name],"/profile/".$Tran->InsertUserID.'/'.$Names[$Tran->InsertUserID][Name],"RateLink"); ?> </td>
  147.             <td class="RateTD"> <? echo $Tran->Amount; ?> </td>
  148.                         <td class="RateTD"> <?  if ($Tran->CommentID != NULL)
  149.                                                     echo Anchor($Tran->Date,'/discussion/comment/'.$Tran->CommentID.'/#Comment_'.$Tran->CommentID);
  150.                                                     else
  151.                                                     echo Anchor($Tran->Date,'/discussion/'.$Tran->DiscussionID); ?> </td>
  152.         </tr>
  153.         <? endforeach ?>
  154.     </tbody>
  155. </table>
  156. <?php
  157. }
  158. /*foreach ($Trans as $Tran)
  159. {
  160.     decho($Tran);
  161. }*/
  162.  //echo($this->Pager);
  163.  //decho($this->Data('TransCount'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement