Skip to content

Commit

Permalink
updating configs add and edit views and removing cache the cake way
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmatic69 committed Feb 6, 2010
1 parent d92816f commit fef51f7
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 108 deletions.
28 changes: 4 additions & 24 deletions infinitas/management/models/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function customOptionCheck($data){
* @return array all the config options set to the correct type
*/
function getConfig() {
$configs = Cache::read('core_configs', 'core');
$configs = Cache::read('configs', 'core');
if ($configs !== false) {
return $configs;
}
Expand Down Expand Up @@ -180,7 +180,7 @@ function getConfig() {
} // switch
}

Cache::write('core_configs', $configs, 'core');
Cache::write('configs', $configs, 'core');

return $configs;
}
Expand All @@ -204,37 +204,17 @@ function getInstallSetupConfigs(){
);
}

function beforeFind($queryData) {
parent::beforeFind($queryData);
return true;
}

function afterSave($created) {
parent::afterSave($created);

$this->__clearCache();
Cache::delete('configs', 'core');
return true;
}

function afterDelete() {
parent::afterDelete();

$this->__clearCache();
return true;
}

/**
* delete cache.
*
* This deletes the cache after something is changed.
*
* @return
*/
function __clearCache() {
if (is_file(CACHE . 'core' . DS . 'core_configs')) {
unlink(CACHE . 'core' . DS . 'core_configs');
}

Cache::delete('configs', 'core');
return true;
}
}
Expand Down
53 changes: 36 additions & 17 deletions infinitas/management/views/configs/admin_add.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,40 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/

echo $this->Core->adminOtherHead( $this );
echo $this->Form->create( 'Config' );
echo $this->Form->input( 'id' );
echo $this->Form->input( 'key' );
echo $this->Form->input( 'value' );
echo $this->Form->input(
'type',
array(
'value' => $types,
'type' => 'select',
'selected' => isset($this->data['Config']['type']) ? $this->data['Config']['type'] : ''
)
);
echo $this->Form->input( 'options', array( 'class' => 'title' ) );
echo $this->Form->input( 'core' );
echo $this->Core->wysiwyg( 'Config.description' );
echo $this->Form->end( 'Save Configuration' );
echo $this->Form->create( 'Config' );
$massActions = $this->Core->massActionButtons(
array(
'save',
)
);
echo $this->Core->adminOtherHead( $this, $massActions );
echo $this->Design->niceBox();
?>
<div class="data">
<?php
echo $this->Form->input( 'id' );
echo $this->Form->input( 'key' );
echo $this->Form->input( 'value' );
echo $this->Form->input(
'type',
array(
'value' => $types,
'type' => 'select',
'selected' => isset($this->data['Config']['type']) ? $this->data['Config']['type'] : ''
)
);
echo $this->Form->input( 'options', array( 'class' => 'title' ) );
echo $this->Form->input( 'core' );
?>
</div>
<div class="config">
<?php
echo $this->Design->niceBox();
echo $this->Core->wysiwyg( 'Config.description' );
echo $this->Design->niceBoxEnd();
?>
</div>
<?php
echo $this->Design->niceBoxEnd();
echo $this->Form->end();
?>
124 changes: 57 additions & 67 deletions infinitas/management/views/configs/admin_edit.ctp
Original file line number Diff line number Diff line change
@@ -1,68 +1,58 @@
<?php
/**
* Management Config admin edit post.
*
* this page is for admin to manage the setup of 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( 'Config', array( 'action' => 'edit' ) );
echo $this->Form->input( 'id' );
echo $this->Form->input( 'key', array( 'readonly' => true ) );

echo $this->Form->hidden( 'type' );

switch( $this->data['Config']['type'] )
{
case 'bool':
$_label = explode( '.', $this->data['Config']['key'] );
$label = ( isset( $_label[1] ) ? $_label[1] : $_label[0] );
$this->data['Config']['value'] = ( $this->data['Config']['value'] == 'true' ) ? '1' : '0';
echo $this->Form->input(
'value',
array(
'type' => 'checkbox',
'label' => Inflector::humanize( $label )
)
);
break;

case 'dropdown':
$_options = explode( ',', $this->data['Config']['options'] );
foreach( $_options as $o )
{
$options[$o] = $o;
}
echo $this->Form->input(
'value',
array(
'type' => 'select',
'options' => $options,
'selected' => $this->data['Config']['value']
)
);
break;

case 'integer':
case 'string':
echo $this->Form->input( 'value' );
break;
} // switch

//echo $this->Form->input( 'options' );
echo $this->Form->input( 'core', array( 'disabled' => true ) );
echo $this->Core->wysiwyg( 'Config.description' );
echo $this->Form->end( 'Save Configuration' );
<?php
/**
* Management Modules admin edit post.
*
* this page is for admin to manage the menu items 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.menuItems.admin_add
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/


echo $this->Form->create( 'MenuItem' );
$massActions = $this->Core->massActionButtons(
array(
'save',
)
);
echo $this->Core->adminOtherHead( $this, $massActions );
echo $this->Design->niceBox();
?>
<div class="data">
<?php
echo $this->Form->input( 'id' );
echo $this->Form->input( 'name' );
echo $this->Form->input( 'link', array('label' => __('External Link', true)) );
echo $this->Form->input( 'prefix' );
echo $this->Form->input( 'plugin' );
echo $this->Form->input( 'controller' );
echo $this->Form->input( 'action' );
echo $this->Form->input( 'params', array('type' => 'textarea') );
?>
</div>
<div class="config">
<?php
echo $this->Design->niceBox();
echo $this->Form->input( 'active' );
echo $this->Form->input( 'group_id' );
echo $this->Form->input( 'menu_id' );
echo $this->Form->input( 'parent_id' );
echo $this->Form->input( 'force_backend' );
echo $this->Form->input( 'force_frontend' );
echo $this->Form->input( 'class', array('type' => 'textarea', 'style' => 'width:50%;') );
echo $this->Design->niceBoxEnd();
?>
</div>
<?php
echo $this->Design->niceBoxEnd();
echo $this->Form->end();
?>
15 changes: 15 additions & 0 deletions webroot/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ a:hover {text-decoration: underline}
float: right;
}

.configs .data{
width:40%;
}
.configs .config{
width:59%;
}
.configs textarea{
width:95%;
clear:both;
}

/**
Main Content styles
*/
Expand All @@ -87,6 +98,10 @@ a:hover {text-decoration: underline}
float:right;
}

.error-message{
color:#ff0000;
}


/* table container */
div.table {
Expand Down

0 comments on commit fef51f7

Please sign in to comment.