diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-05-18 00:31:03 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-05-18 00:31:03 +0000 |
commit | 2cf9b95f5fd702156d2b74b23f924459b2f5784e (patch) | |
tree | affbebaeddd1a8e0ce82e9e690e57bd343f7659f | |
parent | 59b0e40f65b2ab7ed4f6fd8ce96f039ba7d579bc (diff) |
Remove Forge files that we don't use
-rw-r--r-- | modules/forge/controllers/forge_demo.php | 83 | ||||
-rw-r--r-- | modules/forge/models/user_edit.php | 132 | ||||
-rw-r--r-- | modules/forge/views/forge_template.php | 69 |
3 files changed, 0 insertions, 284 deletions
diff --git a/modules/forge/controllers/forge_demo.php b/modules/forge/controllers/forge_demo.php deleted file mode 100644 index 0fdedd97..00000000 --- a/modules/forge/controllers/forge_demo.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php -/** - * Forge module demo controller. This controller should NOT be used in production. - * It is for demonstration purposes only! - * - * $Id$ - * - * @package Forge - * @author Kohana Team - * @copyright (c) 2007-2008 Kohana Team - * @license http://kohanaphp.com/license.html - */ -class Forge_demo_Controller extends Controller { - - // Do not allow to run in production - const ALLOW_PRODUCTION = FALSE; - - public function index() - { - $profiler = new Profiler; - - $foods = array - ( - 'tacos' => array('tacos', FALSE), - 'burgers' => array('burgers', FALSE), - 'spaghetti' => array('spaghetti (checked)', TRUE), - 'cookies' => array('cookies (checked)', TRUE), - ); - - $form = new Forge(NULL, 'New User'); - - // Create each input, following this format: - // - // type($name)->attr(..)->attr(..); - // - $form->hidden('hideme')->value('hiddenz!'); - $form->input('email')->label(TRUE)->rules('required|valid_email'); - $form->input('username')->label(TRUE)->rules('required|length[5,32]'); - $form->password('password')->label(TRUE)->rules('required|length[5,32]'); - $form->password('confirm')->label(TRUE)->matches($form->password); - $form->checkbox('remember')->label('Remember Me'); - $form->checklist('foods')->label('Favorite Foods')->options($foods)->rules('required'); - $form->dropdown('state')->label('Home State')->options(locale_US::states())->rules('required'); - $form->dateselect('birthday')->label(TRUE)->minutes(15)->years(1950, date('Y')); - $form->submit('save')->value('Save'); - - if ($form->validate()) - { - echo Kohana::debug($form->as_array()); - } - - echo $form->render(); - - // Using a custom template: - // echo $form->render('custom_view', TRUE); - // Inside the view access the inputs using $input_id->render(), ->label() etc - // - // To get the errors use $input_id_errors. - // Set the error format with $form->error_format('<div>{message}</div>'); - // Defaults to <p class="error">{message}</p> - // - // Examples: - // echo $username->render(); echo $password_errors; - } - - public function upload() - { - $profiler = new Profiler; - - $form = new Forge; - $form->input('hello')->label(TRUE); - $form->upload('file', TRUE)->label(TRUE)->rules('required|size[200KB]|allow[jpg,png,gif]'); - $form->submit('upload')->value('Upload'); - - if ($form->validate()) - { - echo Kohana::debug($form->as_array()); - } - - echo $form->render(); - } - -} // End Forge Demo Controller diff --git a/modules/forge/models/user_edit.php b/modules/forge/models/user_edit.php deleted file mode 100644 index c8cf9594..00000000 --- a/modules/forge/models/user_edit.php +++ /dev/null @@ -1,132 +0,0 @@ -<?php - -class User_Edit_Model extends User_Model { - - // Overload the class - protected $class = 'user'; - - // Forge instance - protected $form; - - public function __construct($action, $title, $id = FALSE) - { - // Load the user - parent::__construct($id); - - // Create the form - $this->form = new Forge($action, $title); - - $this->form->input('username')->label(TRUE)->rules('required|length[5,32]')->value($this->object->username); - $this->form->input('email')->label(TRUE)->rules('required|length[5,127]|valid_email')->value($this->object->email); - $this->form->password('password')->label(TRUE)->rules('length[5,64]'); - $this->form->password('confirm')->label(TRUE)->matches($this->form->password); - - // Make sure that the username does not already exist - $this->form->username->callback(array($this, 'is_existing_user')); - - if ($this->object->id == 0) - { - // Password fields are required for new users - $this->form->password->rules('+required'); - } - - // // Find all roles - // $roles = new Role_Model; - // $roles = $roles->find(ALL); - // - // $options = array(); - // foreach ($roles as $role) - // { - // // Add each role to the options - // $options[$role->name] = isset($this->roles[$role->id]); - // } - // - // // Create a checklist of roles - // $this->form->checklist('roles')->options($options)->label(TRUE); - - // Add the save button - $this->form->submit('Save'); - } - - public function is_existing_user($input) - { - if ($this->object->username == $input->value) - return TRUE; - - if (self::$db->count_records($this->table, array('username' => $input->value)) > 0) - { - $input->add_error(__FUNCTION__, 'The username <strong>'.$input->value.'</strong> is already in use.'); - return FALSE; - } - - return TRUE; - } - - public function save() - { - if ($this->form->validate() AND $data = $this->form->as_array()) - { - if (empty($data['password'])) - { - // Remove the empty password so it's not reset - unset($data['password'], $data['confirm']); - } - - // Need to set this before saving - $new_user = ($this->object->id == 0); - - // Remove the roles from data - isset($data['roles']) and $roles = arr::remove('roles', $data); - - foreach ($data as $field => $val) - { - // Set object data from the form - $this->$field = $val; - } - - if ($status = parent::save()) - { - // if ($new_user) - // { - // foreach ($roles as $role) - // { - // // Add the user roles - // $this->add_role($role); - // } - // } - // else - // { - // foreach (array_diff($this->roles, $roles) as $role) - // { - // // Remove roles that were deactivated - // $this->remove_role($role); - // } - // - // foreach (array_diff($roles, $this->roles) as $role) - // { - // // Add new roles - // $this->add_role($role); - // } - // } - } - - // Return the save status - return $status; - } - - return FALSE; - } - - public function render() - { - // Proxy to form html - return $this->form->render(); - } - - public function __toString() - { - // Proxy to form html - return $this->form->render(); - } - -} // End User Edit Model
\ No newline at end of file diff --git a/modules/forge/views/forge_template.php b/modules/forge/views/forge_template.php deleted file mode 100644 index d71b16f7..00000000 --- a/modules/forge/views/forge_template.php +++ /dev/null @@ -1,69 +0,0 @@ -<?php echo $open; ?> -<table class="<?php echo $class ?>"> -<?php if ($title != ''): ?> -<caption><?php echo $title ?></caption> -<?php endif ?> -<?php -foreach ($inputs as $input): - -$sub_inputs = array(); -if ($input->type == 'group'): - $sub_inputs = $input->inputs; - -?> -<tr> -<th colspan="2"><?php echo $input->label() ?></th> -</tr> -<?php - - if ($message = $input->message()): - -?> -<tr> -<td colspan="2"><p class="group_message"><?php echo $message ?></p></td> -</tr> -<?php - - endif; - -else: - $sub_inputs = array($input); -endif; - -foreach ($sub_inputs as $input): - -?> -<tr> -<th><?php echo $input->label() ?></th> -<td> -<?php - -echo $input->render(); - -if ($message = $input->message()): - -?> -<p class="message"><?php echo $message ?></p> -<?php - -endif; - -foreach ($input->error_messages() as $error): - -?> -<p class="error"><?php echo $error ?></p> -<?php - -endforeach; - -?> -</td> -</tr> -<?php - -endforeach; - -endforeach; -?> -</table> -<?php echo $close ?>
\ No newline at end of file |