Changeset 701

Show
Ignore:
Timestamp:
08/08/08 16:03:49 (4 months ago)
Author:
aarkerio
Message:

New validates

Location:
trunk/app
Files:
19 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/app_model.php

    r699 r701  
    8282 public function invalidate($field, $value = true)  
    8383 { 
    84      return parent::invalidate($field, __($value, true)); 
     84   return parent::invalidate($field, __($value, true)); 
    8585 } 
    8686} 
  • trunk/app/controllers/catglossaries_controller.php

    r700 r701  
    109109 } 
    110110 
    111 public function admin_edit($catglossary_id=null) 
    112 { 
    113  $this->layout    = 'admin'; 
     111 public function admin_edit($catglossary_id=null) 
     112 { 
     113  $this->layout    = 'admin'; 
    114114      
    115115  if ( empty( $this->data['Catglossary'] ) ):        
  • trunk/app/controllers/entries_controller.php

    r696 r701  
    123123   $this->layout = 'admin'; 
    124124 
    125    $this->set('subjects', Set::combine($this->Entry->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title")); 
    126        
    127     if ( !empty($this->data['Entry']) )   
    128     { 
     125   $this->set('subjects',Set::combine($this->Entry->Subject->find('all', array('order'=>'title')),"{n}.Subject.id","{n}.Subject.title")); 
     126       
     127   if ( !empty($this->data['Entry']) ): 
     128     
    129129        $this->Sanitize = new Sanitize; 
    130130       
     
    134134 
    135135        $this->data['Entry']['user_id'] = $this->Auth->user('id'); 
    136  
    137     $this->Entry->create(); 
    138136       
    139137        if ($this->Entry->save($this->data)):  
     
    146144           endif; 
    147145        endif; 
    148     } 
     146    endif; 
    149147 } 
    150148  
  • trunk/app/controllers/lessons_controller.php

    r697 r701  
    3131         
    3232    $this->layout      = $this->Edublog->layout($user_id); 
    33          
     33     
    3434    $this->Edublog->blog($user_id); // blogger elements 
    3535         
    36     $this->LessonTitle = __('Lesson', true); 
     36    $this->LessonTitle = $username .' '. __('Lessons', true); 
    3737         
    3838    $conditions        = array('Lesson.id'=>$id, 'Lesson.status'=>1); 
  • trunk/app/controllers/news_controller.php

    r696 r701  
    114114   
    115115  /*** ======ADMIN METHODS === *****/ 
    116    public function admin_listing($page=1)  
     116   public function admin_listing()  
    117117   { 
    118118      $this->pageTitle = 'News manager'; 
     
    147147    $this->set('themes', Set::combine($this->News->Theme->find('all', array('order'=>'theme')),"{n}.Theme.id","{n}.Theme.theme")); 
    148148     
    149     if (!empty($this->data["News"])) 
    150     { 
     149    if (!empty($this->data['News'])): 
    151150         $this->Sanitize = new Sanitize; 
    152151          
    153          $this->Sanitize->paranoid($this->data["News"]["title"]); 
    154           
    155          $this->Sanitize->paranoid($this->data["News"]["reference"]); 
    156  
    157          $this->Sanitize->html($this->data["News"]["body"]);  
    158          
    159          $this->data["News"]["user_id"] = $this->Auth->user('id'); 
     152         $this->Sanitize->paranoid($this->data['News']['title']); 
     153          
     154         $this->Sanitize->paranoid($this->data['News']['reference']); 
     155 
     156         $this->Sanitize->html($this->data['News']['body']);  
     157         
     158         $this->data['News']['user_id'] = $this->Auth->user('id'); 
    160159 
    161160     $this->News->create(); 
    162161          
    163      if ($this->News->save($this->data["News"])) 
    164          { 
    165              if ( $this->data["News"]["end"] == 1 ) 
    166              { 
    167                          $this->msgFlash('Story added!','/admin/news/listing'); 
    168              }  
    169              else  
    170              { 
    171                          $id = $this->News->getLastInsertID(); 
    172                          $this->msgFlash('Story added','/admin/news/edit/'.$id); 
    173              } 
    174          } 
    175     } 
    176  } 
    177   
    178  public function admin_edit($id=null) 
    179   { 
    180      $this->layout    = 'admin'; 
    181       
    182      if ( empty( $this->data["News"] ) ) 
    183      { 
    184          $this->News->id  = $id; 
    185           
    186          $this->data      = $this->News->read(); 
    187  
    188          $this->set('themes', Set::combine($this->News->Theme->find('all', array('order'=>'theme')),"{n}.Theme.id","{n}.Theme.theme")); 
    189      } 
    190      else 
    191      {    
     162     if ($this->News->save($this->data)): 
     163         if ( $this->data['News']['end'] == 1 ): 
     164                   $this->msgFlash(__('Data saved', true),'/admin/news/listing'); 
     165             else: 
     166                   $id = $this->News->getLastInsertID(); 
     167                   $this->msgFlash(__('Data saved', true),'/admin/news/edit/'.$id); 
     168             endif; 
     169     endif; 
     170    endif; 
     171 } 
     172  
     173 public function admin_edit($news_id=null) 
     174 { 
     175  $this->layout    = 'admin'; 
     176 
     177  $this->set('themes', Set::combine($this->News->Theme->find('all', array('order'=>'theme')),"{n}.Theme.id","{n}.Theme.theme")); 
     178  
     179  if ( empty($this->data['News']) ): 
     180         $this->data      = $this->News->read(null, $news_id); 
     181  else:    
    192182         $this->Sanitize = new Sanitize; 
    193           
     183   
    194184         $this->Sanitize->paranoid($this->data['News']['title']); 
    195185          
     
    198188         $this->Sanitize->html($this->data['News']['body']); 
    199189          
    200          if ($this->News->save($this->data['News'])) 
    201          {    
    202              if ( $this->data["News"]["end"] == 1 ) 
    203              { 
    204                     $this->msgFlash('Story saved', '/admin/news/listing'); 
    205              }  
    206              else  
    207              { 
    208                     $this->msgFlash('Story saved', '/admin/news/edit/'.$this->data["News"]["id"]); 
    209              } 
    210         } 
    211      } 
    212   } 
    213    
    214   public function admin_delete($id)  
     190         if ($this->News->save($this->data)): 
     191         if ( $this->data['News']['end'] == 1 ): 
     192                    $this->msgFlash(__('Data saved', true), '/admin/news/listing'); 
     193             else:  
     194                    $this->msgFlash(__('Data saved', true), '/admin/news/edit/'.$this->data['News']['id']); 
     195         endif; 
     196     endif; 
     197     endif; 
     198  } 
     199   
     200  public function admin_delete($news_id)  
    215201  {    
    216       if ( $this->News->del($id) ) 
    217       { 
    218             $this->msgFlash('New deleted', '/admin/news/listing'); 
    219       }  
    220       else  
    221       { 
    222             $this->flash('Database error!', '/admin/news/listing'); 
    223       } 
     202   if ( $this->News->del($news_id) ): 
     203         $this->msgFlash(__('Data removed', true), '/admin/news/listing/'); 
     204   endif;  
    224205  } 
    225206} 
  • trunk/app/locale/spa/LC_MESSAGES/default.po

    r699 r701  
    44msgid  "New item" 
    55msgstr "Nuevo término" 
     6 
     7msgid  "Title must be at least four characters long" 
     8msgstr "El título debe tener al menos cuatro letras" 
     9 
     10msgid  "Entry must be at least 8 characters long" 
     11msgstr "La entrada debe tener al menos ocho letras" 
    612 
    713msgid  "Message sent" 
     
    482488msgstr "Temas noticias" 
    483489 
     490msgid  "Theme" 
     491msgstr "Tema" 
     492 
     493msgid  "profile" 
     494msgstr "perfil" 
     495 
     496msgid  "Your URL format lucks incorrect" 
     497msgstr "El formato del URL parece incorrecto" 
     498 
     499msgid  "See comments" 
     500msgstr "Ver comentarios" 
     501 
    484502msgid  "Help" 
    485503msgstr "Ayuda" 
     
    491509msgstr "Examenes" 
    492510 
     511msgid  "Name" 
     512msgstr "Nombre" 
     513 
     514msgid  "eduBlog name" 
     515msgstr "Nombre del eduBlog" 
     516 
    493517msgid  "New Test" 
    494518msgstr "Nuevo examen" 
  • trunk/app/models/answer.php

    r365 r701  
    88class Answer extends AppModel { 
    99    
    10   public $belongsTo = array('Question' => 
     10 public $belongsTo = array('Question' => 
    1111                                    array('className'  => 'Question', 
    1212                                          'conditions' => '', 
     
    1616                          ); 
    1717  
    18   public $validate = array( 
    19                 'comment'  => VALID_NOT_EMPTY,  
    20                 'user_id'  => VALID_NOT_EMPTY, 
    21                 'entry_id' => VALID_NOT_EMPTY, 
    22                 'username' => VALID_NOT_EMPTY 
    23                    ); 
    24     
     18 
     19 public $validate = array( 
     20  'answer' => array( 
     21                    'rule'       => array('minLength', 2), 
     22                    'message'    => 'Answer must be at least two characters long', 
     23            'allowEmpty' => false, 
     24                    'required'   => true  
     25            ), 
     26  'correct' => array( 
     27             'rule'       => 'numeric', 
     28                     'allowEmpty' => false, 
     29                     'required'   => true  
     30             ), 
     31  'question_id' => array( 
     32             'rule'       => 'numeric', 
     33                     'allowEmpty' => false, 
     34                     'required'   => true  
     35             ), 
     36  'user_id' => array( 
     37             'rule'       => 'numeric', 
     38                     'allowEmpty' => false, 
     39                     'required'   => true  
     40             ) 
     41   ); 
    2542} 
    2643?> 
  • trunk/app/models/catglossary.php

    r282 r701  
    88class Catglossary extends AppModel 
    99{ 
    10     public $name    = 'Catglossary'; 
     10  public $name    = 'Catglossary'; 
    1111     
    12     public $belongsTo = array('User' => 
     12  public $belongsTo = array('User' => 
    1313                         array('className'      => 'User', 
    1414                               'conditions'     => null, 
     
    2020                         ); 
    2121     
    22     public $hasMany = array('Glossary' => 
     22 public $hasMany = array('Glossary' => 
    2323                array('className'   => 'Glossary', 
    24                                   'foreignKey'  => 'catglossary_id' 
     24                                  'foreignKey'  => 'catglossary_id', 
     25                                  'order'       => 'item' 
    2526                         ) 
    2627                  ); 
    2728 
    2829     
    29     public $validate = array( 
    30       'title' => VALID_NOT_EMPTY, 
    31         'description' => VALID_NOT_EMPTY, 
    32       'user_id' => VALID_NOT_EMPTY, 
    33       'status' => VALID_NOT_EMPTY 
     30 public $validate = array( 
     31  'title' => array( 
     32                    'rule'       => array('minLength', 8), 
     33                    'message'    => 'Title must be at least 8 characters long', 
     34            'allowEmpty' => false, 
     35                    'required'   => true  
     36            ), 
     37       
     38  'description' => array( 
     39                    'rule'       => array('minLength', 8), 
     40                    'message'    => 'Title must be at least 8 characters long', 
     41            'allowEmpty' => false, 
     42                    'required'   => true  
     43            ) 
    3444   ); 
    35      
    3645} 
    37  
    3846?> 
  • trunk/app/models/entry.php

    r593 r701  
    55{ 
    66     
    7     public $belongsTo = array('User' => 
     7 public $belongsTo = array('User' => 
    88                           array('className'  => 'User', 
    99                                 'conditions' => '', 
     
    1919                     ); 
    2020     
    21     public $hasMany = array('Comment' => 
     21 public $hasMany = array('Comment' => 
    2222                         array('className'     => 'Comment', 
    2323                               'conditions'    =>  null, 
     
    3030                         ) 
    3131                  ); 
    32      
    33     public $validate = array( 
    34       'title' => VALID_NOT_EMPTY,         //'/[a-z0-9\_\-]{3,}$/i', 
    35       'user_id' => VALID_NOT_EMPTY, 
    36       'body' => VALID_NOT_EMPTY, 
    37       'status' => VALID_NOT_EMPTY 
     32 
     33 public $validate = array( 
     34  'title' => array( 
     35                    'rule'       => array('minLength', 4), 
     36                    'message'    => 'Title must be at least four characters long', 
     37            'allowEmpty' => false, 
     38                    'required'   => true  
     39            ), 
     40       
     41  'body' => array( 
     42                    'rule'       => array('minLength', 8), 
     43                    'message'    => 'Entry must be at least 8 characters long', 
     44            'allowEmpty' => false, 
     45                    'required'   => true  
     46            ) 
    3847   ); 
    3948 
    40 public function getComments($blogger_id) 
    41 { 
    42   
     49 public function getComments($blogger_id) 
     50 { 
    4351  $conditions   = array('Entry.user_id'=>$blogger_id); 
    4452  $fields       = array('Entry.title', 'Entry.id'); 
  • trunk/app/models/lesson.php

    r632 r701  
    3737                 );   
    3838 
    39   public $validate = array( 
    40       'title' => VALID_NOT_EMPTY,         //'/[a-z0-9\_\-]{3,}$/i', 
    41       'body' => VALID_NOT_EMPTY, 
    42       'user_id' => VALID_NOT_EMPTY 
     39 public $validate = array( 
     40  'title' => array( 
     41                    'rule'       => array('minLength', 4), 
     42                    'message'    => 'Title must be at least four characters long', 
     43            'allowEmpty' => false, 
     44                    'required'   => true  
     45            ), 
     46       
     47  'body' => array( 
     48                    'rule'       => array('minLength', 8), 
     49                    'message'    => 'Entry must be at least 8 characters long', 
     50            'allowEmpty' => false, 
     51                    'required'   => true  
     52            ), 
     53  'user_id' => array( 
     54             'rule'       => 'numeric', 
     55                     'allowEmpty' => false, 
     56                     'required'   => true  
     57             ) 
    4358   ); 
    44 /* 
    45 public $validate = array( 
    46         'login' => array('alphanumeric' => array( 
    47                                                  'rule' => 'alphaNumeric', 
    48                                              'required' => true, 
    49                                                          'message' => 'Alphabets and numbers only' 
    50                                    ), 
    51                                 'between' => array( 
    52                                            'rule' => array('between', 5, 15), 
    53                                                                                'message' => 'Between 5 to 15 characters' 
    54                                            ) 
    55                                 ), 
    56                        'password' => array( 
    57                                    'rule' => array('minLength', '8'), 
    58                                                                'message' => 'Mimimum 8 characters long' 
    59                                    ), 
    60                        'email' => 'email', 
    61                        'born' => array( 
    62                                'rule' => 'date', 
    63                                'message' => 'Enter a valid date', 
    64                                                            'allowEmpty' => true 
    65                                ) 
    66                        ); */ 
    6759} 
    6860?> 
  • trunk/app/models/news.php

    r537 r701  
    3232                         ); 
    3333 
    34      public $validate = array( 
    35            'title' => VALID_NOT_EMPTY, 
    36            'user_id' => VALID_NOT_EMPTY, 
    37            'body' => VALID_NOT_EMPTY, 
    38            'status' => VALID_NOT_EMPTY 
    39      ); 
    40 /* 
    4134public $validate = array( 
    42         'login' => array('alphanumeric' => array( 
    43                                                  'rule' => 'alphaNumeric', 
    44                                              'required' => true, 
    45                                                          'message' => 'Alphabets and numbers only' 
    46                                    ), 
    47                                 'between' => array( 
    48                                            'rule' => array('between', 5, 15), 
    49                                                                                'message' => 'Between 5 to 15 characters' 
    50                                            ) 
    51                                 ), 
    52                        'password' => array( 
    53                                    'rule' => array('minLength', '8'), 
    54                                                                'message' => 'Mimimum 8 characters long' 
    55                                    ), 
    56                        'email' => 'email', 
    57                        'born' => array( 
    58                                'rule' => 'date', 
    59                                'message' => 'Enter a valid date', 
    60                                                            'allowEmpty' => true 
    61                                ) 
    62                        ); */  
     35  'title' => array( 
     36                   'rule'       => array('minLength', 4), 
     37                   'message'    => 'Title must be at least four characters long', 
     38           'allowEmpty' => false, 
     39                   'required'   => true  
     40          ), 
     41  'body'  => array( 
     42                   'rule'       => array('minLength', 8), 
     43                   'message'    => 'Entry must be at least 8 characters long', 
     44           'allowEmpty' => false, 
     45                   'required'   => true  
     46          ), 
     47   'reference' => array( 
     48             'rule' => 'url', 
     49                         'allowEmpty' => true, 
     50                         'required'   => false, 
     51                         'message'    => 'Your URL format lucks incorrect',  
     52   ), 
     53  'theme_id' => array( 
     54             'rule'       => 'numeric', 
     55                     'allowEmpty' => false, 
     56                     'required'   => true  
     57             ) 
     58  );  
    6359} 
    6460?> 
  • trunk/app/views/entries/admin_add.ctp

    r633 r701  
    1313  <?php  
    1414     echo $form->input('Entry.title', array('size' => 50, 'maxlength' => 50, 'label'=>__('Title', true))); 
    15      echo $form->error('Entry.title', 'Title is required.'); 
     15     echo $form->error('Entry.title'); 
    1616 ?> 
    1717  </td> 
     
    3131     echo $form->textarea('Entry.body', array('cols'=>80, 'rows'=>30));  
    3232     echo $fck->load('EntryBody', 'Karamelo');  
     33     echo $form->error('Entry.body'); 
    3334   ?> 
    3435  </td></tr> 
  • trunk/app/views/entries/admin_edit.ctp

    r679 r701  
    5151  <td> 
    5252  <?php  
    53       echo $form->label('Entry.end', 'Finish edition' ); 
     53      echo $form->label('Entry.end', __('Finish edition', true) ); 
    5454      echo $form->checkbox('Entry.end', array('value'=>1));  
    5555  ?> 
     
    6262  </tr> 
    6363</table> 
    64  
    6564</fieldset> 
  • trunk/app/views/glossaries/admin_edit.ctp

    r318 r701  
    1 <div> 
    21<?php  
    3     echo $html->addCrumb('Control Tools', '/admin/entries/start');  
    4     echo $html->addCrumb('Glossaries', '/admin/catglossaries/listing');  
    5     echo $html->getCrumbs(' / ');  
    6 ?> 
    7 </div> 
    8  
    9 <?php  
     2   echo $html->addCrumb('Control Panel', '/admin/entries/start');  
     3   echo $html->addCrumb(__('Glossaries', true), '/admin/catglossaries/listing');  
     4   echo $html->getCrumbs(' / ');  
     5     
    106   echo $form->create('Glossary');  
    117   echo $form->hidden('Glossary.id'); 
     
    139?> 
    1410<fieldset> 
    15   <legend>Edit Item</legend> 
     11  <legend><?php __('Edit item'); ?></legend> 
    1612  <?php  
    17     echo $form->input('Glossary.item', array("size" => 30, "maxlength" => 90)); 
     13    echo $form->input('Glossary.item', array('size' => 30, 'maxlength' => 90)); 
    1814    echo $form->error('Glossary.item', 'An item  is required.'); 
    1915      
    20     echo $form->label('Glossary.definition', 'Definition:'); 
    21     echo $form->textarea('Glossary.definition', array("cols" => 40, "rows" => 6)); 
     16    echo $form->label('Glossary.definition', __('Definition', true)); 
     17    echo $form->textarea('Glossary.definition', array('cols' => 40, 'rows' => 6)); 
    2218    echo $form->error('Glossary.definition', 'A category definition is required.'); 
    23   ?>