Changeset 74

Show
Ignore:
Timestamp:
02/24/06 14:55:52 (3 years ago)
Author:
fabien
Message:

fixed pagination problems

Files:

Legend:

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

    r71 r74  
    11all: 
    2   default
     2  symfony
    33    class:          sfPropelDatabase 
    44    param: 
    5       datasource:   symfony 
    65      phptype:      mysql 
    76      hostspec:     localhost 
  • trunk/apps/frontend/config/settings.yml

    r71 r74  
    3333    i18n:                   on 
    3434 
     35    use_database:           on 
     36 
    3537#    default_module:         default 
    3638#    default_action:         index 
     
    6163#    url_format:             PATH 
    6264#     
    63 #    use_database:           off 
    6465# 
    6566#    use_security:           on 
  • trunk/apps/frontend/lib/helper/GlobalHelper.php

    r64 r74  
    2929 
    3030    // First and previous page 
    31     $navigation .= link_to(image_tag('first.gif', 'align=absmiddle'), $uri.'1'); 
    32     $navigation .= link_to(image_tag('previous.gif', 'align=absmiddle'), $uri.$pager->getPreviousPage()).' '; 
    33  
     31    if ($pager->getPage() != 1) 
     32    { 
     33      $navigation .= link_to(image_tag('first.gif', 'align=absmiddle'), $uri.'1'); 
     34      $navigation .= link_to(image_tag('previous.gif', 'align=absmiddle'), $uri.$pager->getPreviousPage()).' '; 
     35    } 
     36     
    3437    // Pages one by one 
    3538    $links = array(); 
     
    4144 
    4245    // Next and last page 
    43     $navigation .= ' '.link_to(image_tag('next.gif', 'align=absmiddle'), $uri.$pager->getNextPage()); 
    44     $navigation .= link_to(image_tag('last.gif', 'align=absmiddle'), $uri.$pager->getLastPage()); 
     46    if ($pager->getPage() != $pager->getCurrentMaxLink()) 
     47    { 
     48      $navigation .= ' '.link_to(image_tag('next.gif', 'align=absmiddle'), $uri.$pager->getNextPage()); 
     49      $navigation .= link_to(image_tag('last.gif', 'align=absmiddle'), $uri.$pager->getLastPage()); 
     50    } 
     51 
    4552  } 
    4653 
  • trunk/apps/frontend/modules/moderator/templates/reportedAnswersSuccess.php

    r64 r74  
    1919 
    2020<div id="question_pager" class="right"> 
    21   <?php echo pager_navigation($answer_pager, '@') ?> 
     21  <?php echo pager_navigation($answer_pager, 'moderator/reportedAnswers') ?> 
    2222</div> 
  • trunk/apps/frontend/modules/moderator/templates/reportedQuestionsSuccess.php

    r64 r74  
    1717 
    1818<div id="question_pager" class="right"> 
    19   <?php echo pager_navigation($question_pager, '@') ?> 
     19  <?php echo pager_navigation($question_pager, 'moderator/reportedQuestions') ?> 
    2020</div> 
  • trunk/lib/model/om/BaseAnswer.php

    r55 r74  
    608608 
    609609    /** 
     610     * Array of ValidationFailed objects. 
     611     * @var array ValidationFailed[] 
     612     */ 
     613    protected $validationFailures = array(); 
     614 
     615    /** 
     616     * Gets any ValidationFailed objects that resulted from last call to validate(). 
     617     * 
     618     * 
     619     * @return array ValidationFailed[] 
     620     * @see validate() 
     621     */ 
     622    public function getValidationFailures() 
     623    { 
     624        return $this->validationFailures; 
     625    } 
     626 
     627    /** 
    610628     * Validates the objects modified field values and all objects related to this table. 
    611629     * 
     
    614632     * 
    615633     * @param mixed $columns Column name or an array of column names. 
    616      * 
    617      * @return mixed <code>true</code> if all columns pass validation 
    618      *            or an array of <code>ValidationFailed</code> objects for columns that fail. 
     634     * @return boolean Whether all columns pass validation. 
    619635     * @see doValidate() 
     636     * @see getValidationFailures() 
    620637     */ 
    621638    public function validate($columns = null) 
    622639    { 
    623       if ($columns) { 
    624         return AnswerPeer::doValidate($this, $columns); 
    625       } 
    626         return $this->doValidate(); 
     640        $res = $this->doValidate($columns); 
     641        if ($res === true) { 
     642            $this->validationFailures = array(); 
     643            return true; 
     644        } else { 
     645            $this->validationFailures = $res; 
     646            return false; 
     647        } 
    627648    } 
    628649 
     
    634655     * an aggreagated array of ValidationFailed objects will be returned. 
    635656     * 
     657     * @param array $columns Array of column names to validate. 
    636658     * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise. 
    637659     */ 
    638     protected function doValidate(
     660    protected function doValidate($columns = null
    639661    { 
    640662        if (!$this->alreadyInValidation) { 
     
    651673 
    652674            if ($this->aQuestion !== null) { 
    653                 if (($retval = $this->aQuestion->validate()) !== true) { 
    654                     $failureMap = array_merge($failureMap, $retval); 
     675                if (!$this->aQuestion->validate($columns)) { 
     676                    $failureMap = array_merge($failureMap, $this->aQuestion->getValidationFailures()); 
    655677                } 
    656678            } 
    657679 
    658680            if ($this->aUser !== null) { 
    659                 if (($retval = $this->aUser->validate()) !== true) { 
    660                     $failureMap = array_merge($failureMap, $retval); 
     681                if (!$this->aUser->validate($columns)) { 
     682                    $failureMap = array_merge($failureMap, $this->aUser->getValidationFailures()); 
    661683                } 
    662684            } 
    663685 
    664686 
    665             if (($retval = AnswerPeer::doValidate($this)) !== true) { 
     687            if (($retval = AnswerPeer::doValidate($this, $columns)) !== true) { 
    666688                $failureMap = array_merge($failureMap, $retval); 
    667689            } 
     
    670692                if ($this->collRelevancys !== null) { 
    671693                    foreach($this->collRelevancys as $referrerFK) { 
    672                         if (($retval = $referrerFK->validate()) !== true) { 
    673                             $failureMap = array_merge($failureMap, $retval); 
     694                        if (!$referrerFK->validate($columns)) { 
     695                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); 
    674696                        } 
    675697                    } 
     
    678700                if ($this->collReportAnswers !== null) { 
    679701                    foreach($this->collReportAnswers as $referrerFK) { 
    680                         if (($retval = $referrerFK->validate()) !== true) { 
    681                             $failureMap = array_merge($failureMap, $retval); 
     702                        if (!$referrerFK->validate($columns)) { 
     703                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); 
    682704                        } 
    683705                    } 
     
    702724    public function getByName($name, $type = BasePeer::TYPE_PHPNAME) 
    703725    { 
    704         $names = AnswerPeer::getFieldNames($type); 
    705726        $pos = AnswerPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); 
    706727        return $this->getByPosition($pos); 
     
    789810    public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) 
    790811    { 
    791         $names = AnswerPeer::getFieldNames($type); 
    792         $pos = array_search($name, $names); 
     812        $pos = AnswerPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); 
    793813        return $this->setByPosition($pos, $value); 
    794814    } 
     
    961981 
    962982            foreach($this->getRelevancys() as $relObj) { 
    963                 $copyObj->addRelevancy($relObj->copy($deepCopy)); 
     983                if($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves 
     984                    $copyObj->addRelevancy($relObj->copy($deepCopy)); 
     985                } 
    964986            } 
    965987 
    966988            foreach($this->getReportAnswers() as $relObj) { 
    967                 $copyObj->addReportAnswer($relObj->copy($deepCopy)); 
     989                if($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves 
     990                    $copyObj->addReportAnswer($relObj->copy($deepCopy)); 
     991                } 
    968992            } 
    969993 
     
    11891213     * 
    11901214     * @param Criteria $criteria 
     1215     * @param boolean $distinct 
    11911216     * @param Connection $con 
    11921217     * @throws PropelException 
    11931218     */ 
    1194     public function countRelevancys($criteria = null, $con = null) 
     1219    public function countRelevancys($criteria = null, $distinct = false, $con = null) 
    11951220    { 
    11961221        // include the Peer class 
     
    12061231        $criteria->add(RelevancyPeer::ANSWER_ID, $this->getId()); 
    12071232 
    1208         return RelevancyPeer::doCount($criteria, $con); 
     1233        return RelevancyPeer::doCount($criteria, $distinct, $con); 
    12091234    } 
    12101235 
     
    13441369     * 
    13451370     * @param Criteria $criteria 
     1371     * @param boolean $distinct 
    13461372     * @param Connection $con 
    13471373     * @throws PropelException 
    13481374     */ 
    1349     public function countReportAnswers($criteria = null, $con = null) 
     1375    public function countReportAnswers($criteria = null, $distinct = false, $con = null) 
    13501376    { 
    13511377        // include the Peer class 
     
    13611387        $criteria->add(ReportAnswerPeer::ANSWER_ID, $this->getId()); 
    13621388 
    1363         return ReportAnswerPeer::doCount($criteria, $con); 
     1389        return ReportAnswerPeer::doCount($criteria, $distinct, $con); 
    13641390    } 
    13651391 
  • trunk/lib/model/om/BaseAnswerPeer.php

    r55 r74  
    104104     * @throws PropelException Any exceptions caught during processing will be 
    105105     *       rethrown wrapped into a PropelException. 
    106      * @todo Consider having template build the array rather than doing it at runtime
     106     * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this
    107107     */ 
    108108    public static function getPhpNameMap() 
     
    169169    public static function alias($alias, $column) 
    170170    { 
    171         return $alias . substr($column, strlen(AnswerPeer::TABLE_NAME)); 
     171        return str_replace(AnswerPeer::TABLE_NAME.'.', $alias.'.', $column); 
    172172    } 
    173173 
     
    10831083        } 
    10841084 
    1085         return BasePeer::doValidate(AnswerPeer::DATABASE_NAME, AnswerPeer::TABLE_NAME, $columns); 
     1085        $res =  BasePeer::doValidate(AnswerPeer::DATABASE_NAME, AnswerPeer::TABLE_NAME, $columns); 
     1086    if ($res !== true) { 
     1087        $request = sfContext::getInstance()->getRequest(); 
     1088        foreach ($res as $failed) { 
     1089            $col = AnswerPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME); 
     1090            $request->setError($col, $failed->getMessage()); 
     1091        } 
     1092    } 
     1093 
     1094    return $res; 
    10861095    } 
    10871096 
  • trunk/lib/model/om/BaseInterest.php

    r16 r74  
    350350 
    351351    /** 
     352     * Array of ValidationFailed objects. 
     353     * @var array ValidationFailed[] 
     354     */ 
     355    protected $validationFailures = array(); 
     356 
     357    /** 
     358     * Gets any ValidationFailed objects that resulted from last call to validate(). 
     359     * 
     360     * 
     361     * @return array ValidationFailed[] 
     362     * @see validate() 
     363     */ 
     364    public function getValidationFailures() 
     365    { 
     366        return $this->validationFailures; 
     367    } 
     368 
     369    /** 
    352370     * Validates the objects modified field values and all objects related to this table. 
    353371     * 
     
    356374     * 
    357375     * @param mixed $columns Column name or an array of column names. 
    358      * 
    359      * @return mixed <code>true</code> if all columns pass validation 
    360      *            or an array of <code>ValidationFailed</code> objects for columns that fail. 
     376     * @return boolean Whether all columns pass validation. 
    361377     * @see doValidate() 
     378     * @see getValidationFailures() 
    362379     */ 
    363380    public function validate($columns = null) 
    364381    { 
    365       if ($columns) { 
    366         return InterestPeer::doValidate($this, $columns); 
    367       } 
    368         return $this->doValidate(); 
     382        $res = $this->doValidate($columns); 
     383        if ($res === true) { 
     384            $this->validationFailures = array(); 
     385            return true; 
     386        } else { 
     387            $this->validationFailures = $res; 
     388            return false; 
     389        } 
    369390    } 
    370391 
     
    376397     * an aggreagated array of ValidationFailed objects will be returned. 
    377398     * 
     399     * @param array $columns Array of column names to validate. 
    378400     * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise. 
    379401     */ 
    380     protected function doValidate(
     402    protected function doValidate($columns = null
    381403    { 
    382404        if (!$this->alreadyInValidation) { 
     
    393415 
    394416            if ($this->aQuestion !== null) { 
    395                 if (($retval = $this->aQuestion->validate()) !== true) { 
    396                     $failureMap = array_merge($failureMap, $retval); 
     417                if (!$this->aQuestion->validate($columns)) { 
     418                    $failureMap = array_merge($failureMap, $this->aQuestion->getValidationFailures()); 
    397419                } 
    398420            } 
    399421 
    400422            if ($this->aUser !== null) { 
    401                 if (($retval = $this->aUser->validate()) !== true) { 
    402                     $failureMap = array_merge($failureMap, $retval); 
     423                if (!$this->aUser->validate($columns)) { 
     424                    $failureMap = array_merge($failureMap, $this->aUser->getValidationFailures()); 
    403425                } 
    404426            } 
    405427 
    406428 
    407             if (($retval = InterestPeer::doValidate($this)) !== true) { 
     429            if (($retval = InterestPeer::doValidate($this, $columns)) !== true) { 
    408430                $failureMap = array_merge($failureMap, $retval); 
    409431            } 
     
    428450    public function getByName($name, $type = BasePeer::TYPE_PHPNAME) 
    429451    { 
    430         $names = InterestPeer::getFieldNames($type); 
    431452        $pos = InterestPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); 
    432453        return $this->getByPosition($pos); 
     
    491512    public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) 
    492513    { 
    493         $names = InterestPeer::getFieldNames($type); 
    494         $pos = array_search($name, $names); 
     514        $pos = InterestPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); 
    495515        return $this->setByPosition($pos, $value); 
    496516    } 
  • trunk/lib/model/om/BaseInterestPeer.php

    r16 r74  
    8686     * @throws PropelException Any exceptions caught during processing will be 
    8787     *       rethrown wrapped into a PropelException. 
    88      * @todo Consider having template build the array rather than doing it at runtime
     88     * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this
    8989     */ 
    9090    public static function getPhpNameMap() 
     
    151151    public static function alias($alias, $column) 
    152152    { 
    153         return $alias . substr($column, strlen(InterestPeer::TABLE_NAME)); 
     153        return str_replace(InterestPeer::TABLE_NAME.'.', $alias.'.', $column); 
    154154    } 
    155155 
     
    10711071        } 
    10721072 
    1073         return BasePeer::doValidate(InterestPeer::DATABASE_NAME, InterestPeer::TABLE_NAME, $columns); 
     1073        $res =  BasePeer::doValidate(InterestPeer::DATABASE_NAME, InterestPeer::TABLE_NAME, $columns); 
     1074    if ($res !== true) { 
     1075        $request = sfContext::getInstance()->getRequest(); 
     1076        foreach ($res as $failed) { 
     1077            $col = InterestPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME); 
     1078            $request->setError($col, $failed->getMessage()); 
     1079        } 
     1080    } 
     1081 
     1082    return $res; 
    10741083    } 
    10751084 
  • trunk/lib/model/om/BaseQuestion.php

    r58 r74  
    717717 
    718718    /** 
     719     * Array of ValidationFailed objects. 
     720     * @var array ValidationFailed[] 
     721     */ 
     722    protected $validationFailures = array(); 
     723 
     724    /** 
     725     * Gets any ValidationFailed objects that resulted from last call to validate(). 
     726     * 
     727     * 
     728     * @return array ValidationFailed[] 
     729     * @see validate() 
     730     */ 
     731    public function getValidationFailures() 
     732    { 
     733        return $this->validationFailures; 
     734    } 
     735 
     736    /** 
    719737     * Validates the objects modified field values and all objects related to this table. 
    720738     * 
     
    723741     * 
    724742     * @param mixed $columns Column name or an array of column names. 
    725      * 
    726      * @return mixed <code>true</code> if all columns pass validation 
    727      *            or an array of <code>ValidationFailed</code> objects for columns that fail. 
     743     * @return boolean Whether all columns pass validation. 
    728744     * @see doValidate() 
     745     * @see getValidationFailures() 
    729746     */ 
    730747    public function validate($columns = null) 
    731748    { 
    732       if ($columns) { 
    733         return QuestionPeer::doValidate($this, $columns); 
    734       } 
    735         return $this->doValidate(); 
     749        $res = $this->doValidate($columns); 
     750        if ($res === true) { 
     751            $this->validationFailures = array(); 
     752            return true; 
     753        } else { 
     754            $this->validationFailures = $res; 
     755            return false; 
     756        } 
    736757    } 
    737758 
     
    743764     * an aggreagated array of ValidationFailed objects will be returned. 
    744765     * 
     766     * @param array $columns Array of column names to validate. 
    745767     * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise. 
    746768     */ 
    747     protected function doValidate(
     769    protected function doValidate($columns = null
    748770    { 
    749771        if (!$this->alreadyInValidation) { 
     
    760782 
    761783            if ($this->aUser !== null) { 
    762                 if (($retval = $this->aUser->validate()) !== true) { 
    763                     $failureMap = array_merge($failureMap, $retval); 
    764                 } 
    765             } 
    766  
    767  
    768             if (($retval = QuestionPeer::doValidate($this)) !== true) { 
     784                if (!$this->aUser->validate($columns)) { 
     785                    $failureMap = array_merge($failureMap, $this->aUser->getValidationFailures()); 
     786                } 
     787            } 
     788 
     789 
     790            if (($retval = QuestionPeer::doValidate($this, $columns)) !== true) { 
    769791                $failureMap = array_merge($failureMap, $retval); 
    770792            } 
     
    773795                if ($this->collAnswers !== null) { 
    774796                    foreach($this->collAnswers as $referrerFK) { 
    775                         if (($retval = $referrerFK->validate()) !== true) { 
    776                             $failureMap = array_merge($failureMap, $retval); 
     797                        if (!$referrerFK->validate($columns)) { 
     798                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); 
    777799                        } 
    778800                    } 
     
    781803                if ($this->collInterests !== null) { 
    782804                    foreach($this->collInterests as $referrerFK) { 
    783                         if (($retval = $referrerFK->validate()) !== true) { 
    784                             $failureMap = array_merge($failureMap, $retval); 
     805                        if (!$referrerFK->validate($columns)) { 
     806                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); 
    785807                        } 
    786808                    } 
     
    789811                if ($this->collQuestionTags !== null) { 
    790812                    foreach($this->collQuestionTags as $referrerFK) { 
    791                         if (($retval = $referrerFK->validate()) !== true) { 
    792                             $failureMap = array_merge($failureMap, $retval); 
     813                        if (!$referrerFK->validate($columns)) { 
     814                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); 
    793815                        } 
    794816                    } 
     
    797819                if ($this->collSearchIndexs !== null) { 
    798820                    foreach($this->collSearchIndexs as $referrerFK) { 
    799                         if (($retval = $referrerFK->validate()) !== true) { 
    800                             $failureMap = array_merge($failureMap, $retval); 
     821                        if (!$referrerFK->validate($columns)) { 
     822                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); 
    801823                        } 
    802824                    } 
     
    805827                if ($this->collReportQuestions !== null) { 
    806828                    foreach($this->collReportQuestions as $referrerFK) { 
    807                         if (($retval = $referrerFK->validate()) !== true) { 
    808                             $failureMap = array_merge($failureMap, $retval); 
     829                        if (!$referrerFK->validate($columns)) { 
     830                            $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); 
    809831                        } 
    810832                    } 
     
    829851    public function getByName($name, $type = BasePeer::TYPE_PHPNAME) 
    830852    { 
    831         $names = QuestionPeer::getFieldNames($type); 
    832853        $pos = QuestionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); 
    833854        return $this->getByPosition($pos); 
     
    920941    public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) 
    921942    { 
    922         $names = QuestionPeer::getFieldNames($type); 
    923         $pos = array_search($name, $names); 
     943        $pos = QuestionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); 
    924944        return $this->setByPosition($pos, $value); 
    925945    } 
     
    10991119 
    11001120            foreach($this->getAnswers() as $relObj) { 
    1101                 $copyObj->addAnswer($relObj->copy($deepCopy)); 
     1121                if($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves 
     1122                    $copyObj->addAnswer($relObj->copy($deepCopy)); 
     1123                } 
    11021124            } 
    11031125 
    11041126            foreach($this->getInterests() as $relObj) { 
    1105                 $copyObj->addInterest($relObj->copy($deepCopy)); 
     1127                if($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves 
     1128                    $copyObj->addInterest($relObj->copy($deepCopy)); 
     1129                } 
    11061130            } 
    11071131 
    11081132            foreach($this->getQuestionTags() as $relObj) { 
    1109                 $copyObj->addQuestionTag($relObj->copy($deepCopy)); 
     1133                if($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves 
     1134                    $copyObj->addQuestionTag($relObj->copy($deepCopy)); 
     1135                } 
    11101136            } 
    11111137 
    11121138            foreach($this->getSearchIndexs() as $relObj) { 
    1113                 $copyObj->addSearchIndex($relObj->copy($deepCopy)); 
     1139                if($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves 
     1140                    $copyObj->addSearchIndex($relObj->copy($deepCopy)); 
     1141                } 
    11141142            } 
    11151143 
    11161144            foreach($this->getReportQuestions() as $relObj) { 
    1117                 $copyObj->addReportQuestion($relObj->copy($deepCopy)); 
     1145                if($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves 
     1146                    $copyObj->addReportQuestion($relObj->copy($deepCopy)); 
     1147                } 
    11181148            } 
    11191149 
     
    12881318     * 
    12891319     * @param Criteria $criteria 
     1320     * @param boolean $distinct 
    12901321     * @param Connection $con 
    12911322     * @throws PropelException 
    12921323     */ 
    1293     public function countAnswers($criteria = null, $con = null) 
     1324    public function countAnswers($criteria = null, $distinct = false, $con = null) 
    12941325    { 
    12951326        // include the Peer class 
     
    13051336        $criteria->add(AnswerPeer::QUESTION_ID, $this->getId()); 
    13061337 
    1307         return AnswerPeer::doCount($criteria, $con); 
     1338        return AnswerPeer::doCount($criteria, $distinct, $con); 
    13081339    } 
    13091340 
     
    14431474     * 
    14441475     * @param Criteria $criteria 
     1476     * @param boolean $distinct 
    14451477     * @param Connection $con 
    14461478     * @throws PropelException 
    14471479     */ 
    1448     public function countInterests($criteria = null, $con = null) 
     1480    public function countInterests($criteria = null, $distinct = false, $con = null) 
    14491481    { 
    14501482        // include the Peer class 
     
    14601492        $criteria->add(InterestPeer::QUESTION_ID, $this->getId()); 
    14611493 
    1462         return InterestPeer::doCount($criteria, $con); 
     1494        return InterestPeer::doCount($criteria, $distinct, $con); 
    14631495    } 
    14641496 
     
    15981630     * 
    15991631     * @param Criteria $criteria 
     1632     * @param boolean $distinct 
    16001633     * @param Connection $con 
    16011634     * @throws PropelException 
    16021635     */ 
    1603     public function countQuestionTags($criteria = null, $con = null) 
     1636    public function countQuestionTags($criteria = null, $distinct = false, $con = null) 
    16041637    { 
    16051638        // include the Peer class 
     
    16151648        $criteria->add(QuestionTagPeer::QUESTION_ID, $this->getId()); 
    16161649 
    1617         return QuestionTagPeer::doCount($criteria, $con); 
     1650        return QuestionTagPeer::doCount($criteria, $distinct, $con); 
    16181651    } 
    16191652 
     
    17531786     * 
    17541787     * @param Criteria $criteria 
     1788     * @param boolean $distinct 
    17551789     * @param Connection $con 
    17561790     * @throws PropelException 
    17571791     */ 
    1758     public function countSearchIndexs($criteria = null, $con = null) 
     1792    public function countSearchIndexs($criteria = null, $distinct = false, $con = null) 
    17591793    { 
    17601794        // include the Peer class 
     
    17701804        $criteria->add(SearchIndexPeer::QUESTION_ID, $this->getId()); 
    17711805 
    1772         return SearchIndexPeer::doCount($criteria, $con); 
     1806        return SearchIndexPeer::doCount($criteria, $distinct, $con); 
    17731807    } 
    17741808 
     
    18591893     * 
    18601894     * @param Criteria $criteria 
     1895     * @param boolean $distinct 
    18611896     * @param Connection $con 
    18621897     * @throws PropelException 
    18631898     */ 
    1864     public function countReportQuestions($criteria = null, $con = null) 
     1899    public function countReportQuestions($criteria = null, $distinct = false, $con = null) 
    18651900    { 
    18661901        // include the Peer class 
     
    18761911        $criteria->add(ReportQuestionPeer::QUESTION_ID, $this->getId()); 
    18771912 
    1878         return ReportQuestionPeer::doCount($criteria, $con); 
     1913        return ReportQuestionPeer::doCount($criteria, $distinct, $con); 
    18791914    } 
    18801915 
  • trunk/lib/model/om/BaseQuestionPeer.php

    r55 r74  
    107107     * @throws PropelException Any exceptions caught during processing will be 
    108108     *       rethrown wrapped into a PropelException. 
    109      * @todo Consider having template build the array rather than doing it at runtime
     109     * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this
    110110     */ 
    111111    public static function getPhpNameMap() 
     
    172172    public static function alias($alias, $column) 
    173173    { 
    174         return $alias . substr($column, strlen(QuestionPeer::TABLE_NAME)); 
     174        return str_replace(QuestionPeer::TABLE_NAME.'.', $alias.'.', $column); 
    175175    } 
    176176 
     
    746746        } 
    747747 
    748         return BasePeer::doValidate(QuestionPeer::DATABASE_NAME, QuestionPeer::TABLE_NAME, $columns); 
     748        $res =  BasePeer::doValidate(QuestionPeer::DATABASE_NAME, QuestionPeer::TABLE_NAME, $columns); 
     749    if ($res !== true) { 
     750        $request = sfContext::getInstance()->getRequest(); 
     751        foreach ($res as $failed) { 
     752            $col = QuestionPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME); 
     753            $request->setError($col, $failed->getMessage()); 
     754        } 
     755    } 
     756 
     757    return $res; 
    749758    } 
    750759 
  • trunk/lib/model/om/BaseQuestionTag.php

    r55 r74  
    422422 
    423423    /** 
     424     * Array of ValidationFailed objects. 
     425     * @var array ValidationFailed[] 
     426     */ 
     427    protected $validationFailures = array(); 
     428 
     429    /** 
     430     * Gets any ValidationFailed objects that resulted from last call to validate(). 
     431     * 
     432     * 
     433     * @return array ValidationFailed[] 
     434     * @see validate() 
     435     */ 
     436    public function getValidationFailures() 
     437    { 
     438        return $this->validationFailures; 
     439    } 
     440 
     441    /** 
    424442     * Validates the objects modified field values and all objects related to this table. 
    425443     * 
     
    428446     * 
    429447     * @param mixed $columns Column name or an array of column names. 
    430      * 
    431      * @return mixed <code>true</code> if all columns pass validation 
    432      *            or an array of <code>ValidationFailed</code> objects for columns that fail. 
     448     * @return boolean Whether all columns pass validation. 
    433449     * @see doValidate() 
     450     * @see getValidationFailures() 
    434451     */ 
    435452    public function validate($columns = null) 
    436453    { 
    437       if ($columns) { 
    438         return QuestionTagPeer::doValidate($this, $columns); 
    439       } 
    440         return $this->doValidate(); 
     454        $res = $this->doValidate($columns); 
     455        if ($res === true) { 
     456            $this->validationFailures = array(); 
     457            return true; 
     458        } else { 
     459            $this->validationFailures = $res; 
     460            return false; 
     461        } 
    441462    } 
    442463 
     
    448469     * an aggreagated array of ValidationFailed objects will be returned. 
    449470     * 
     471     * @param array $columns Array of column names to validate. 
    450472     * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise. 
    451473     */ 
    452     protected function doValidate(
     474    protected function doValidate($columns = null
    453475    { 
    454476        if (!$this->alreadyInValidation) { 
     
    465487 
    466488            if ($this->aQuestion !== null) { 
    467                 if (($retval = $this->aQuestion->validate()) !== true) { 
    468                     $failureMap = array_merge($failureMap, $retval); 
     489                if (!$this->aQuestion->validate($columns)) { 
     490                    $failureMap = array_merge($failureMap, $this->aQuestion->getValidationFailures()); 
    469491                } 
    470492            } 
    471493 
    472494            if ($this->aUser !== null) { 
    473                 if (($retval = $this->aUser->validate()) !== true) { 
    474                     $failureMap = array_merge($failureMap, $retval); 
     495                if (!$this->aUser->validate($columns)) { 
     496                    $failureMap = array_merge($failureMap, $this->aUser->getValidationFailures()); 
    475497                } 
    476498            } 
    477499 
    478500 
    479             if (($retval = QuestionTagPeer::doValidate($this)) !== true) { 
     501            if (($retval = QuestionTagPeer::doValidate($this, $columns)) !== true) { 
    480502                $failureMap = array_merge($failureMap, $retval); 
    481503            } 
     
    500522    public function getByName($name, $type = BasePeer::TYPE_PHPNAME) 
    501523    { 
    502         $names = QuestionTagPeer::getFieldNames($type); 
    503524        $pos = QuestionTagPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); 
    504525        return $this->getByPosition($pos); 
     
    571592    public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) 
    572593    { 
    573         $names = QuestionTagPeer::getFieldNames($type); 
    574         $pos = array_search($name, $names); 
     594        $pos = QuestionTagPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); 
    575595        return $this->setByPosition($pos, $value); 
    576596    } 
  • trunk/lib/model/om/BaseQuestionTagPeer.php

    r55 r74  
    9292     * @throws PropelException Any exceptions caught during processing will be 
    9393     *       rethrown wrapped into a PropelException. 
    94      * @todo Consider having template build the array rather than doing it at runtime
     94     * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this
    9595     */ 
    9696    public static function getPhpNameMap() 
     
    157157    public static function alias($alias, $column) 
    158158    { 
    159         return $alias . substr($column, strlen(QuestionTagPeer::TABLE_NAME)); 
     159        return str_replace(QuestionTagPeer::TABLE_NAME.'.', $alias.'.', $column); 
    160160    } 
    161161 
     
    10861086        } 
    10871087 
    1088         return BasePeer::doValidate(QuestionTagPeer::DATABASE_NAME, QuestionTagPeer::TABLE_NAME, $columns); 
     1088        $res =  BasePeer::doValidate(QuestionTagPeer::DATABASE_NAME, QuestionTagPeer::TABLE_NAME, $columns); 
     1089    if ($res !== true) { 
     1090        $request = sfContext::getInstance()->getRequest(); 
     1091        foreach ($res as $failed) { 
     1092            $col = QuestionTagPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME); 
     1093            $request->setError($col, $failed->getMessage()); 
     1094