Changeset 18

Show
Ignore:
Timestamp:
12/06/05 12:05:10 (7 years ago)
Author:
fabien
Message:

day 7 modifications

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/frontend/config/routing.yml

    r14 r18  
    77  url:   /index/:page 
    88  param: { module: question, action: list } 
     9 
     10recent_questions: 
     11  url:   /recent 
     12  param: { module: question, action: recent } 
    913 
    1014# answers 
  • trunk/frontend/config/view.yml

    r8 r18  
    44 
    55  metas: 
    6     title:        symfony project 
     6    title:        askeet! ask questions, find answers 
    77    robots:       index, follow 
    8     description:  symfony project 
    9     keywords:     symfony, project 
     8    description:  askeet!, a symfony project built in 24 hours 
     9    keywords:     symfony, project, askeet, php5, question, answer 
    1010    language:     en 
    1111 
     
    1717  layout:         layout 
    1818 
    19   slots:          {} 
     19  slots: 
     20    sidebar:      [sidebar, default] 
  • trunk/frontend/modules/question/actions/actions.class.php

    r14 r18  
    2323    $this->answer_pager = AnswerPeer::getPager($this->question->getId(), $this->getRequestParameter('page', 1)); 
    2424  } 
     25 
     26  public function executeRecent() 
     27  { 
     28    $this->question_pager = QuestionPeer::getRecentPager($this->getRequestParameter('page', 1)); 
     29  } 
    2530} 
    2631 
  • trunk/frontend/modules/question/templates/showSuccess.php

    r14 r18  
    1111</div> 
    1212 
    13 <div id="answers"> 
    14 <?php foreach ($answer_pager->getResults() as $answer): ?> 
    15   <div> 
    16     <?php echo $answer->getRelevancyUpPercent() ?>% UP <?php echo $answer->getRelevancyDownPercent() ?> % DOWN 
    17     posted by <?php echo $answer->getUser() ?> 
    18     on <?php echo format_date($answer->getCreatedAt(), 'p') ?> 
    19     <div> 
    20       <?php echo $answer->getBody() ?> 
    21     </div> 
    22   </div> 
    23 <?php endforeach ?> 
    24 </div> 
     13<?php include_partial('answer/list', array('answer_pager' => $answer_pager)) ?> 
    2514 
    2615<?php if ($answer_pager->haveToPaginate()): ?> 
  • trunk/frontend/modules/user/actions/actions.class.php

    r16 r18  
    1111class userActions extends sfActions 
    1212{ 
    13   /** 
    14    * Executes index action 
    15    * 
    16    */ 
     13  public function executeListInterestedBy() 
     14  { 
     15    $this->question = QuestionPeer::retrieveByPk($this->getRequestParameter('id')); 
     16    $this->forward404Unless($this->question instanceof Question); 
     17 
     18    $this->interested_users = $this->question->getAllInterestedUsers(); 
     19  } 
     20 
     21  public function executeShow() 
     22  { 
     23    $this->subscriber = UserPeer::retrieveByPk($this->getRequestParameter('id', $this->getUser()->getSubscriberId())); 
     24    $this->forward404Unless($this->subscriber); 
     25 
     26    $this->interests = $this->subscriber->getInterestsJoinQuestion(); 
     27    $this->answers   = $this->subscriber->getAnswersJoinQuestion(); 
     28    $this->questions = $this->subscriber->getQuestions(); 
     29  } 
     30 
    1731  public function executeLogin() 
    1832  { 
  • trunk/frontend/templates/layout.php

    r14 r18  
    3636 
    3737    <div id="content_bar"> 
    38       <!-- Nothing for the moment --
     38      <?php echo $sidebar ?
    3939      <div class="verticalalign"></div> 
    4040    </div> 
  • trunk/lib/model/AnswerPeer.php

    r14 r18  
    3434    return $pager; 
    3535  } 
     36 
     37  public static function getRecentPager($page) 
     38  { 
     39    $pager = new sfPager('Answer', APP_PAGER_HOMEPAGE_MAX); 
     40    $c = new Criteria(); 
     41    $c->addDescendingOrderByColumn(self::CREATED_AT); 
     42    $pager->setCriteria($c); 
     43    $pager->setPage($page); 
     44    $pager->setPeerMethod('doSelectJoinUser'); 
     45    $pager->init(); 
     46 
     47    return $pager; 
     48  } 
    3649} 
    3750 
  • trunk/lib/model/Question.php

    r12 r18  
    2323    $this->setStrippedTitle(myTools::stripText($v)); 
    2424  } 
     25 
     26  public function getAllInterestedUsers() 
     27  {    
     28    $c = new Criteria(); 
     29    $c->addJoin(UserPeer::ID, InterestPeer::USER_ID, Criteria::LEFT_JOIN); 
     30    $c->add(InterestPeer::QUESTION_ID, $this->getId()); 
     31 
     32    return UserPeer::doSelect($c); 
     33  } 
    2534} 
    2635 
  • trunk/lib/model/QuestionPeer.php

    r14 r18  
    4343    return $pager; 
    4444  } 
     45 
     46  public static function getRecentPager($page) 
     47  { 
     48    $pager = new sfPager('Question', APP_PAGER_HOMEPAGE_MAX); 
     49    $c = new Criteria(); 
     50    $c->addDescendingOrderByColumn(self::CREATED_AT); 
     51    $pager->setCriteria($c); 
     52    $pager->setPage($page); 
     53    $pager->setPeerMethod('doSelectJoinUser'); 
     54    $pager->init(); 
     55 
     56    return $pager; 
     57  } 
    4558} 
    4659