Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finishing up contacts manager with image uploading
- Loading branch information
1 parent
08fe51f
commit cae9d19
Showing
11 changed files
with
523 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
class ContactAppController extends AppController { | ||
|
||
var $helpers = array( | ||
'Filter.Filter' | ||
); | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
/** | ||
* Contacts controller | ||
* | ||
* Used for managing contacts at the company of the site | ||
* | ||
* Copyright (c) 2010 Carl Sutton ( dogmatic69 ) | ||
* | ||
* @filesource | ||
* @copyright Copyright (c) 2010 Carl Sutton ( dogmatic69 ) | ||
* @link http://www.infinitas-cms.org | ||
* @package contact | ||
* @subpackage contact.controllers.contacts | ||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License | ||
* @since 0.7a | ||
* | ||
* @author Carl Sutton ( dogmatic69 ) | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
*/ | ||
|
||
class ContactsController extends ContactAppController{ | ||
var $name = 'Contacts'; | ||
|
||
function admin_index(){ | ||
$this->Contact->recursive = 0; | ||
|
||
$contacts = $this->paginate( | ||
null, | ||
$this->Filter->filter | ||
); | ||
|
||
$filterOptions = $this->Filter->filterOptions; | ||
$filterOptions['fields'] = array( | ||
'name', | ||
'branch_id' => array(null => __('All branches', true)) + $this->Contact->Branch->find('list'), | ||
'active' => (array)Configure::read('CORE.active_options') | ||
); | ||
|
||
$this->set(compact('contacts','filterOptions')); | ||
} | ||
|
||
function admin_add(){ | ||
if (!empty($this->data)) { | ||
$this->Contact->create(); | ||
if ($this->Contact->save($this->data)) { | ||
$this->Session->setFlash('Your contact has been saved.'); | ||
$this->redirect(array('action' => 'index')); | ||
} | ||
} | ||
|
||
$branches = $this->Contact->Branch->find('list'); | ||
$this->set(compact('branches')); | ||
} | ||
|
||
function admin_edit($id = null){ | ||
if (!$id) { | ||
$this->Session->setFlash(__('That contact could not be found', true), true); | ||
$this->redirect($this->referer()); | ||
} | ||
|
||
if (!empty($this->data)) { | ||
if ($this->Contact->save($this->data)) { | ||
$this->Session->setFlash(__('Your contact has been saved.', true)); | ||
$this->redirect(array('action' => 'index')); | ||
} | ||
|
||
$this->Session->setFlash(__('Your contact could not be saved.', true)); | ||
} | ||
|
||
if ($id && empty($this->data)) { | ||
$this->data = $this->Contact->read(null, $id); | ||
} | ||
|
||
$branches = $this->Contact->Branch->find('list'); | ||
$this->set(compact('branches')); | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
/** | ||
* | ||
* | ||
*/ | ||
class Contact extends ContactAppModel{ | ||
var $name = 'Contact'; | ||
|
||
var $actsAs = array( | ||
'MeioUpload.MeioUpload' => array( | ||
'image' => array( | ||
'dir' => 'img{DS}content{DS}contact{DS}{ModelName}', | ||
'create_directory' => true, | ||
'allowed_mime' => array( | ||
'image/jpeg', | ||
'image/pjpeg', | ||
'image/png' | ||
), | ||
'allowed_ext' => array( | ||
'.jpg', | ||
'.jpeg', | ||
'.png' | ||
), | ||
|
||
) | ||
), | ||
'Libs.Sequence' => array( | ||
'group_fields' => array( | ||
'branch_id' | ||
) | ||
) | ||
); | ||
|
||
var $belongsTo = array( | ||
'Contact.Branch' | ||
); | ||
|
||
/** | ||
* Construct for validation. | ||
* | ||
* This is used to make the validation messages run through __() | ||
* | ||
* @param mixed $id | ||
* @param mixed $table | ||
* @param mixed $ds | ||
*/ | ||
function __construct($id = false, $table = null, $ds = null) { | ||
parent::__construct($id, $table, $ds); | ||
|
||
$this->validate = array( | ||
'first_name' => array( | ||
'notEmpty' => array( | ||
'rule' => 'notEmpty', | ||
'message' => __('Please enter the contacts first name', true) | ||
), | ||
), | ||
'last_name' => array( | ||
'notEmpty' => array( | ||
'rule' => 'notEmpty', | ||
'message' => __('Please enter the contacts last name', true) | ||
), | ||
), | ||
'phone' => array( | ||
'notEmpty' => array( | ||
'rule' => 'notEmpty', | ||
'message' => __('Please enter some text for the body', true) | ||
), | ||
'phone' => array( | ||
'rule' => 'phone', | ||
'message' => __('The number does not seem to be valid', true) | ||
) | ||
), | ||
'mobile' => array( | ||
'rule' => 'phone', | ||
'message' => __('Please enter a valid mobile number', true), | ||
'allowEmpty' => true | ||
), | ||
'branch_id' => array( | ||
'rule' => array('comparison', '>', 0), | ||
'message' => __('Please select a branch', true) | ||
) | ||
); | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,42 @@ | ||
<?php | ||
/** | ||
* Management Modules admin edit post. | ||
* | ||
* this page is for admin to manage the modules on the site | ||
* | ||
* Copyright (c) 2009 Carl Sutton ( dogmatic69 ) | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @filesource | ||
* @copyright Copyright (c) 2009 Carl Sutton ( dogmatic69 ) | ||
* @link http://infinitas-cms.org | ||
* @package management | ||
* @subpackage management.views.configs.admin_edit | ||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License | ||
*/ | ||
|
||
echo $this->Core->adminOtherHead( $this ); | ||
echo $this->Form->create( 'Module' ); | ||
?> | ||
<div style="width:50%; float:left;"> | ||
<?php | ||
echo $this->Form->input( 'id' ); | ||
echo $this->Form->input( 'name' ); | ||
echo $this->Form->input( 'module' ); | ||
echo $this->Form->input( 'theme_id' ); | ||
echo $this->Form->input( 'position_id' ); | ||
echo $this->Form->input( 'group_id' ); | ||
echo $this->Form->input( 'active' ); | ||
echo $this->Form->input( 'show_heading' ); | ||
echo $this->Form->input( 'core' ); | ||
echo $this->Form->input( 'author' ); | ||
echo $this->Form->input( 'url' ); | ||
echo $this->Form->input( 'update_url' ); | ||
echo $this->Form->input( 'licence' ); | ||
|
||
echo $this->Form->input( 'content', array('class' => 'title') ); | ||
echo $this->Form->input( 'config', array('class' => 'title') ); | ||
?> | ||
</div> | ||
<div style="width:50%; float:left;"> | ||
<?php | ||
echo $this->Form->input('Route'); | ||
?> | ||
</div> | ||
<div class="clr"> </div> | ||
<?php | ||
echo $this->Form->end( 'Save Module' ); | ||
<?php | ||
/** | ||
* Management Modules admin edit post. | ||
* | ||
* this page is for admin to manage the modules on the site | ||
* | ||
* Copyright (c) 2009 Carl Sutton ( dogmatic69 ) | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @filesource | ||
* @copyright Copyright (c) 2009 Carl Sutton ( dogmatic69 ) | ||
* @link http://infinitas-cms.org | ||
* @package management | ||
* @subpackage management.views.configs.admin_edit | ||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License | ||
*/ | ||
|
||
echo $this->Infinitas->adminOtherHead($this); | ||
echo $this->Form->create('Branch', array('type' => 'file')); | ||
?> | ||
<div style="width:50%; float:left;"> | ||
<?php | ||
echo $this->Form->input('id'); | ||
echo $this->Form->input('image', array('type' => 'file')); | ||
echo $this->Form->input('name'); | ||
echo $this->Form->input('phone'); | ||
echo $this->Form->input('fax'); | ||
echo $this->Form->input('address'); | ||
echo $this->Form->input('map'); | ||
echo $this->Form->input('active'); | ||
?> | ||
</div> | ||
<div style="width:50%; float:left;"> | ||
<?php | ||
?> | ||
</div> | ||
<div class="clr"> </div> | ||
<?php | ||
echo $this->Form->end( 'Save Module' ); | ||
?> |
Oops, something went wrong.