Changeset 1923

Show
Ignore:
Timestamp:
02/05/2008 08:49:08 AM (10 months ago)
Author:
Shadowhand
Message:

Added comments for Forge and Form_Input (other files don't need comments, they are all extensions), and set properties.

Location:
trunk/modules/forge
Files:
14 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/forge/controllers/forge_demo.php

    • Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
  • trunk/modules/forge/i18n/en_US/forge.php

    • Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
  • trunk/modules/forge/libraries/Forge.php

    • Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
    r1917 r1923  
    11<?php defined('SYSPATH') or die('No direct script access.'); 
    2  
     2/** 
     3 * FORGE (FORm GEneration) library. 
     4 * 
     5 * $Id$ 
     6 * 
     7 * @package    Forge 
     8 * @author     Kohana Team 
     9 * @copyright  (c) 2007-2008 Kohana Team 
     10 * @license    http://kohanaphp.com/license.html 
     11 */ 
    312class Forge_Core { 
    413 
     
    2332        public $newline_char = "\n"; 
    2433 
     34        /** 
     35         * Form constructor. Sets the form action, title, method, and attributes. 
     36         * 
     37         * @return  void 
     38         */ 
    2539        public function __construct($action = '', $title = '', $method = NULL, $attr = array()) 
    2640        { 
     
    4256        } 
    4357 
     58        /** 
     59         * Magic __get method. Returns the specified form element. 
     60         * 
     61         * @param   string   unique input name 
     62         * @return  object 
     63         */ 
    4464        public function __get($key) 
    4565        { 
     
    5474        } 
    5575 
     76        /** 
     77         * Magic __call method. Creates a new form element object. 
     78         * 
     79         * @throws  Kohana_Exception 
     80         * @param   string   input type 
     81         * @param   string   input name 
     82         * @return  object 
     83         */ 
    5684        public function __call($method, $args) 
    5785        { 
     
    96124        } 
    97125 
     126        /** 
     127         * Set a form attribute. This method is chainable. 
     128         * 
     129         * @param   string|array  attribute name, or an array of attributes 
     130         * @param   string        attribute value 
     131         * @return  object 
     132         */ 
     133        public function set_attr($key, $val = NULL) 
     134        { 
     135                if (is_array($key)) 
     136                { 
     137                        // Merge the new attributes with the old ones 
     138                        $this->attr = array_merge($this->attr, $key); 
     139                } 
     140                else 
     141                { 
     142                        // Set the new attribute 
     143                        $this->attr[$key] = $val; 
     144                } 
     145 
     146                return $this; 
     147        } 
     148 
     149        /** 
     150         * Validates the form by running each inputs validation rules. 
     151         * 
     152         * @return  bool 
     153         */ 
    98154        public function validate() 
    99155        { 
     
    110166        } 
    111167 
     168        /** 
     169         * Returns the form as an array of input names and values. 
     170         * 
     171         * @return  array 
     172         */ 
    112173        public function as_array() 
    113174        { 
     
    124185        } 
    125186 
     187        /** 
     188         * Changes the error message format. Your message formatting must 
     189         * contain a {message} placeholder. 
     190         * 
     191         * @throws  Kohana_Exception 
     192         * @param   string   new message format 
     193         * @return  void 
     194         */ 
    126195        public function error_format($string = '') 
    127196        { 
  • trunk/modules/forge/libraries/Form_Checkbox.php

    • Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
    r1594 r1923  
    11<?php defined('SYSPATH') or die('No direct script access.'); 
    2  
     2/** 
     3 * FORGE checkbox input library. 
     4 * 
     5 * $Id$ 
     6 * 
     7 * @package    Forge 
     8 * @author     Kohana Team 
     9 * @copyright  (c) 2007-2008 Kohana Team 
     10 * @license    http://kohanaphp.com/license.html 
     11 */ 
    312class Form_Checkbox_Core extends Form_Input { 
    413 
     
    2231 
    2332                return parent::__get($key); 
    24         } 
    25  
    26         public function label($val = NULL) 
    27         { 
    28                 if ($val === NULL) 
    29                 { 
    30                         return ''; 
    31                 } 
    32                 else 
    33                 { 
    34                         $this->data['label'] = ($val === TRUE) ? ucwords(inflector::humanize($this->name)) : $val; 
    35                         return $this; 
    36                 } 
    3733        } 
    3834 
  • trunk/modules/forge/libraries/Form_Checklist.php

    • Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
    r1594 r1923  
    11<?php defined('SYSPATH') or die('No direct script access.'); 
    2  
     2/** 
     3 * FORGE checklist input library. 
     4 * 
     5 * $Id$ 
     6 * 
     7 * @package    Forge 
     8 * @author     Kohana Team 
     9 * @copyright  (c) 2007-2008 Kohana Team 
     10 * @license    http://kohanaphp.com/license.html 
     11 */ 
    312class Form_Checklist_Core extends Form_Input { 
    413 
  • trunk/modules/forge/libraries/Form_Dateselect.php

    • Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
    r1594 r1923  
    11<?php defined('SYSPATH') or die('No direct script access.'); 
    2  
     2/** 
     3 * FORGE dateselect input library. 
     4 * 
     5 * $Id$ 
     6 * 
     7 * @package    Forge 
     8 * @author     Kohana Team 
     9 * @copyright  (c) 2007-2008 Kohana Team 
     10 * @license    http://kohanaphp.com/license.html 
     11 */ 
    312class Form_Dateselect_Core extends Form_Input { 
    413 
  • trunk/modules/forge/libraries/Form_Dropdown.php

    • Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
    r1595 r1923  
    11<?php defined('SYSPATH') or die('No direct script access.'); 
    2  
     2/** 
     3 * FORGE dropdown input library. 
     4 * 
     5 * $Id$ 
     6 * 
     7 * @package    Forge 
     8 * @author     Kohana Team 
     9 * @copyright  (c) 2007-2008 Kohana Team 
     10 * @license    http://kohanaphp.com/license.html 
     11 */ 
    312class Form_Dropdown_Core extends Form_Input { 
    413 
  • trunk/modules/forge/libraries/Form_Group.php

    • Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
    r1710 r1923  
    11<?php defined('SYSPATH') or die('No direct script access.'); 
    2  
     2/** 
     3 * FORGE group library. 
     4 * 
     5 * $Id$ 
     6 * 
     7 * @package    Forge 
     8 * @author     Kohana Team 
     9 * @copyright  (c) 2007-2008 Kohana Team 
     10 * @license    http://kohanaphp.com/license.html 
     11 */ 
    312class Form_Group_Core extends Forge { 
    413 
  • trunk/modules/forge/libraries/Form_Hidden.php

    • Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
    r1522 r1923  
    11<?php defined('SYSPATH') or die('No direct script access.'); 
    2  
     2/** 
     3 * FORGE hidden input library. 
     4 * 
     5 * $Id$ 
     6 * 
     7 * @package    Forge 
     8 * @author     Kohana Team 
     9 * @copyright  (c) 2007-2008 Kohana Team 
     10 * @license    http://kohanaphp.com/license.html 
     11 */ 
    312class Form_Hidden_Core extends Form_Input { 
    413 
  • trunk/modules/forge/libraries/Form_Input.php

    • Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
    r1917 r1923  
    11<?php defined('SYSPATH') or die('No direct script access.'); 
    2  
     2/** 
     3 * FORGE base input library. 
     4 * 
     5 * $Id$ 
     6 * 
     7 * @package    Forge 
     8 * @author     Kohana Team 
     9 * @copyright  (c) 2007-2008 Kohana Team 
     10 * @license    http://kohanaphp.com/license.html 
     11 */ 
    312class Form_Input_Core { 
    413 
     
    2938        protected $error_messages = array(); 
    3039 
     40        /** 
     41         * Sets the input element name. 
     42         */ 
    3143        public function __construct($name) 
    3244        { 
     
    3446        } 
    3547 
     48        /** 
     49         * Sets form attributes, or return rules. 
     50         */ 
    3651        public function __call($method, $args) 
    3752        { 
     
    7085        } 
    7186 
     87        /** 
     88         * Returns form attributes. 
     89         * 
     90         * @param   string  attribute name 
     91         * @return  string 
     92         */ 
    7293        public function __get($key) 
    7394        { 
     
    7899        } 
    79100 
     101        /** 
     102         * Sets a form element that this element must match the value of. 
     103         * 
     104         * @chainable 
     105         * @param   object  another Forge input 
     106         * @return  object 
     107         */ 
    80108        public function matches($input) 
    81109        { 
     
    88116        } 
    89117 
     118        /** 
     119         * Sets a callback method as a rule for this input. 
     120         * 
     121         * @chainable 
     122         * @param   callback 
     123         * @return  object 
     124         */ 
    90125        public function callback($callback) 
    91126        { 
     
    98133        } 
    99134 
     135        /** 
     136         * Sets or returns the input label. 
     137         * 
     138         * @chainable 
     139         * @param   string   label to set 
     140         * @return  string|object 
     141         */ 
    100142        public function label($val = NULL) 
    101143        { 
     
    115157        } 
    116158 
     159        /** 
     160         * Set or return the error message. 
     161         * 
     162         * @chainable 
     163         * @param   string  error message 
     164         * @return  strong|object 
     165         */ 
    117166        public function message($val = NULL) 
    118167        { 
     
    129178        } 
    130179 
     180        /** 
     181         * Runs validation and returns the element HTML. 
     182         * 
     183         * @return  string 
     184         */ 
    131185        public function html() 
    132186        { 
     
    137191        } 
    138192 
     193        /** 
     194         * Returns the form input HTML. 
     195         * 
     196         * @return  string 
     197         */ 
    139198        protected function html_element() 
    140199        { 
     
    147206        } 
    148207 
     208        /** 
     209         * Replace, remove, or append rules. 
     210         * 
     211         * @param   array   rules to change 
     212         * @param   string  action to use: replace, remove, append 
     213         */ 
    149214        protected function add_rules( array $rules, $action) 
    150215        { 
     
    183248        } 
    184249 
     250        /** 
     251         * Add an error to the input. 
     252         * 
     253         * @chainable 
     254         * @return object 
     255         */ 
    185256        public function add_error($key, $val) 
    186257        { 
     
    193264        } 
    194265 
     266        /** 
     267         * Set or return the error messages. 
     268         * 
     269         * @chainable 
     270         * @param   string|array  failed validation function, or an array of messages 
     271         * @param   string        error message 
     272         * @return  object|array 
     273         */ 
    195274        public function error_messages($func = NULL, $message = NULL) 
    196275        { 
     
    281360        } 
    282361 
     362        /** 
     363         * Get the global input value. 
     364         * 
     365         * @return  string|bool 
     366         */ 
    283367        protected function input_value() 
    284368        { 
     
    297381        } 
    298382 
     383        /** 
     384         * Load the value of the input, if form data is present. 
     385         * 
     386         * @return  void 
     387         */ 
    299388        protected function load_value() 
    300389        { 
     
    315404        } 
    316405 
     406        /** 
     407         * Validate this input based on the set rules. 
     408         * 
     409         * @return  bool 
     410         */ 
    317411        public function validate() 
    318412        { 
     
    424518        } 
    425519 
     520        /** 
     521         * Validate required. 
     522         */ 
    426523        protected function rule_required() 
    427524        { 
     
    432529        } 
    433530 
     531        /** 
     532         * Validate length. 
     533         */ 
    434534        protected function rule_length($min, $max = NULL) 
    435535        { 
  • trunk/modules/forge/libraries/Form_Password.php

    • Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
    r1522 r1923  
    11<?php defined('SYSPATH') or die('No direct script access.'); 
    2  
     2/** 
     3 * FORGE password input library. 
     4 * 
     5 * $Id$ 
     6 * 
     7 * @package    Forge 
     8 * @author     Kohana Team 
     9 * @copyright  (c) 2007-2008 Kohana Team 
     10 * @license    http://kohanaphp.com/license.html 
     11 */ 
    312class Form_Password_Core extends Form_Input { 
    413 
  • trunk/modules/forge/libraries/Form_Submit.php

    • Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
    r1522 r1923  
    11<?php defined('SYSPATH') or die('No direct script access.'); 
    2  
     2/** 
     3 * FORGE submit input library. 
     4 * 
     5 * $Id$ 
     6 * 
     7 * @package    Forge 
     8 * @author     Kohana Team 
     9 * @copyright  (c) 2007-2008 Kohana Team 
     10 * @license    http://kohanaphp.com/license.html 
     11 */ 
    312class Form_Submit_Core extends Form_Input { 
    413 
  • trunk/modules/forge/libraries/Form_Textarea.php

    • Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
    r1522 r1923  
    11<?php defined('SYSPATH') or die('No direct script access.'); 
    2  
     2/** 
     3 * FORGE textarea input library. 
     4 * 
     5 * $Id$ 
     6 * 
     7 * @package    Forge 
     8 * @author     Kohana Team 
     9 * @copyright  (c) 2007-2008 Kohana Team 
     10 * @license    http://kohanaphp.com/license.html 
     11 */ 
    312class Form_Textarea_Core extends Form_Input { 
    413 
  • trunk/modules/forge/libraries/Form_Upload.php

    • Property copyright changed from Copyright (c) 2007 Kohana Team to Copyright (c) 2007-2008 Kohana Team
    r1658 r1923  
    11<?php defined('SYSPATH') or die('No direct script access.'); 
    2  
     2/** 
     3 * FORGE upload input library. 
     4 * 
     5 * $Id$ 
     6 * 
     7 * @package    Forge 
     8 * @author     Kohana Team 
     9 * @copyright  (c) 2007-2008 Kohana Team 
     10 * @license    http://kohanaphp.com/license.html 
     11 */ 
    312class Form_Upload_Core extends Form_Input { 
    413 
     
    4251        } 
    4352 
     53        /** 
     54         * Sets the upload directory. 
     55         * 
     56         * @param   string   upload directory 
     57         * @return  void 
     58         */ 
    4459        public function directory($dir = NULL) 
    4560        {