Skip to content

Commit

Permalink
fix views
Browse files Browse the repository at this point in the history
  • Loading branch information
skie committed Sep 16, 2011
1 parent 9345b08 commit abd3abe
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 40 deletions.
3 changes: 2 additions & 1 deletion Controller/CategoriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

App::import('Model', 'Categories.Category');
App::uses('Category', 'Categories.Model');
App::uses('CategoriesAppController', 'Categories.Controller');

/**
* Categories controller
Expand Down
1 change: 1 addition & 0 deletions Model/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

App::uses('CategoriesAppModel', 'Categories.Model');
/**
* Category model
*
Expand Down
4 changes: 2 additions & 2 deletions View/categories/admin_add.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
?>
<?php echo $this->Form->create('Category');?>
<fieldset>
<legend><?php __d('categories', 'Add Category');?></legend>
<legend><?php echo __d('categories', 'Add Category');?></legend>
<?php
echo $this->Form->input('category_id', array('empty' => true));
echo $this->Form->input('name');
echo $this->Form->input('description');
?>
</fieldset>
<?php echo $this->Form->end(__d('categories', 'Submit', true));?>
<?php echo $this->Form->end(__d('categories', 'Submit'));?>
4 changes: 2 additions & 2 deletions View/categories/admin_edit.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
?>
<?php echo $this->Form->create('Category');?>
<fieldset>
<legend><?php __d('categories', 'Edit Category');?></legend>
<legend><?php echo __d('categories', 'Edit Category');?></legend>
<?php
echo $this->Form->input('id');
echo $this->Form->input('category_id', array('empty' => true));
echo $this->Form->input('name');
echo $this->Form->input('description');
?>
</fieldset>
<?php echo $this->Form->end(__d('categories', 'Submit', true));?>
<?php echo $this->Form->end(__d('categories', 'Submit'));?>
10 changes: 5 additions & 5 deletions View/categories/admin_index.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
?>
<h2><?php __d('categories', 'Categories');?></h2>
<h2><?php echo __d('categories', 'Categories');?></h2>
<p>
<?php
echo $this->Paginator->counter(array(
'format' => __d('categories', 'Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
'format' => __d('categories', 'Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%')
));
?></p>
<table cellpadding="0" cellspacing="0">
Expand Down Expand Up @@ -50,9 +50,9 @@ foreach ($categories as $category):
<?php echo $category['Category']['created']; ?>
</td>
<td class="actions">
<?php echo $this->Html->link(__d('categories', 'View', true), array('action'=>'view', $category['Category']['id'])); ?>
<?php echo $this->Html->link(__d('categories', 'Edit', true), array('action'=>'edit', $category['Category']['id'])); ?>
<?php echo $this->Html->link(__d('categories', 'Delete', true), array('action'=>'delete', $category['Category']['id']), null, sprintf(__d('categories', 'Are you sure you want to delete # %s?', true), $category['Category']['id'])); ?>
<?php echo $this->Html->link(__d('categories', 'View'), array('action'=>'view', $category['Category']['id'])); ?>
<?php echo $this->Html->link(__d('categories', 'Edit'), array('action'=>'edit', $category['Category']['id'])); ?>
<?php echo $this->Html->link(__d('categories', 'Delete'), array('action'=>'delete', $category['Category']['id']), null, sprintf(__d('categories', 'Are you sure you want to delete # %s?'), $category['Category']['id'])); ?>
</td>
</tr>
<?php endforeach; ?>
Expand Down
16 changes: 8 additions & 8 deletions View/categories/admin_tree.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
?>
<h2><?php __d('categories', 'Categories');?></h2>
<h2><?php echo __d('categories', 'Categories');?></h2>
<?php
$this->Html->script(
array(
Expand All @@ -32,23 +32,23 @@
<p class="error-message">
<?php
echo String::insert(
__d('categories', 'No categories were added yet. :add-a-new-one now!', true),
array('add-a-new-one' => $this->Html->link(__d('categories', 'Add a new one', true), array('action' => 'add'))));
__d('categories', 'No categories were added yet. :add-a-new-one now!'),
array('add-a-new-one' => $this->Html->link(__d('categories', 'Add a new one'), array('action' => 'add'))));
?>
</p>
<?php else :
echo $this->Tree->generate($categories, array('element' => 'categories/tree_item', 'class' => 'categorytree', 'id' => 'categorytree'));
endif; ?>
<ul class="actions">
<li><?php echo $this->Html->link(__d('categories', 'Add category', true), array('action' => 'add')); ?></li>
<li><?php echo $this->Html->link(__d('categories', 'Add category'), array('action' => 'add')); ?></li>
</ul>
</div>

<div id="placeholder"></div>

<ul id="actions-list" class="contextMenu">
<li class="view"><?php echo $this->Html->link(__d('categories', 'View', true), array('action' => 'view', 'admin' => true)); ?></li>
<li class="add separator"><?php echo $this->Html->link(__d('categories', 'Add a child', true), array('action' => 'add')); ?></li>
<li class="edit"><?php echo $this->Html->link(__d('categories', 'Edit', true), array('action' => 'edit')); ?></li>
<li class="delete separator"><?php echo $this->Html->link(__d('categories', 'Delete', true), array('action' => 'delete')); ?></li>
<li class="view"><?php echo $this->Html->link(__d('categories', 'View'), array('action' => 'view', 'admin' => true)); ?></li>
<li class="add separator"><?php echo $this->Html->link(__d('categories', 'Add a child'), array('action' => 'add')); ?></li>
<li class="edit"><?php echo $this->Html->link(__d('categories', 'Edit'), array('action' => 'edit')); ?></li>
<li class="delete separator"><?php echo $this->Html->link(__d('categories', 'Delete'), array('action' => 'delete')); ?></li>
</ul>
20 changes: 10 additions & 10 deletions View/categories/admin_view.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
?>
<h2><?php __d('categories', 'Category');?></h2>
<h2><?php echo __d('categories', 'Category');?></h2>
<dl><?php $i = 0; $class = ' class="altrow"';?>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __d('categories', 'Parent Category'); ?></dt>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php echo __d('categories', 'Parent Category'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $this->Html->link($category['ParentCategory']['name'], array('controller'=> 'categories', 'action'=>'view', $category['ParentCategory']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __d('categories', 'User'); ?></dt>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php echo __d('categories', 'User'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $this->Html->link($category['User']['id'], array('controller'=> 'users', 'action'=>'view', $category['User']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __d('categories', 'Name'); ?></dt>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php echo __d('categories', 'Name'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $category['Category']['name']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __d('categories', 'Description'); ?></dt>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php echo __d('categories', 'Description'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $category['Category']['description']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __d('categories', 'Created'); ?></dt>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php echo __d('categories', 'Created'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $category['Category']['created']; ?>
&nbsp;
Expand All @@ -40,9 +40,9 @@
</div>
<div class="actions">
<ul>
<li><?php echo $this->Html->link(__d('categories', 'Edit Category', true), array('action'=>'edit', $category['Category']['id'])); ?> </li>
<li><?php echo $this->Html->link(__d('categories', 'Delete Category', true), array('action'=>'delete', $category['Category']['id']), null, sprintf(__d('categories', 'Are you sure you want to delete # %s?', true), $category['Category']['id'])); ?> </li>
<li><?php echo $this->Html->link(__d('categories', 'List Categories', true), array('action'=>'index')); ?> </li>
<li><?php echo $this->Html->link(__d('categories', 'New Category', true), array('action'=>'add')); ?> </li>
<li><?php echo $this->Html->link(__d('categories', 'Edit Category'), array('action'=>'edit', $category['Category']['id'])); ?> </li>
<li><?php echo $this->Html->link(__d('categories', 'Delete Category'), array('action'=>'delete', $category['Category']['id']), null, sprintf(__d('categories', 'Are you sure you want to delete # %s?'), $category['Category']['id'])); ?> </li>
<li><?php echo $this->Html->link(__d('categories', 'List Categories'), array('action'=>'index')); ?> </li>
<li><?php echo $this->Html->link(__d('categories', 'New Category'), array('action'=>'add')); ?> </li>
</ul>
</div>
10 changes: 5 additions & 5 deletions View/categories/index.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
?>
<h2><?php __d('categories', 'Categories');?></h2>
<h2><?php echo __d('categories', 'Categories');?></h2>
<p>
<?php
echo $this->Paginator->counter(array(
'format' => __d('categories', 'Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
'format' => __d('categories', 'Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%')
));
?></p>
<table cellpadding="0" cellspacing="0">
Expand Down Expand Up @@ -50,9 +50,9 @@ foreach ($categories as $category):
<?php echo $category['Category']['created']; ?>
</td>
<td class="actions">
<?php echo $this->Html->link(__d('categories', 'View', true), array('action'=>'view', $category['Category']['id'])); ?>
<?php echo $this->Html->link(__d('categories', 'Edit', true), array('action'=>'edit', $category['Category']['id'])); ?>
<?php echo $this->Html->link(__d('categories', 'Delete', true), array('action'=>'delete', $category['Category']['id']), null, sprintf(__d('categories', 'Are you sure you want to delete # %s?', true), $category['Category']['id'])); ?>
<?php echo $this->Html->link(__d('categories', 'View'), array('action'=>'view', $category['Category']['id'])); ?>
<?php echo $this->Html->link(__d('categories', 'Edit'), array('action'=>'edit', $category['Category']['id'])); ?>
<?php echo $this->Html->link(__d('categories', 'Delete'), array('action'=>'delete', $category['Category']['id']), null, sprintf(__d('categories', 'Are you sure you want to delete # %s?'), $category['Category']['id'])); ?>
</td>
</tr>
<?php endforeach; ?>
Expand Down
14 changes: 7 additions & 7 deletions View/categories/view.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
?>
<h2><?php __d('categories', 'Category');?></h2>
<h2><?php echo __d('categories', 'Category');?></h2>
<dl><?php $i = 0; $class = ' class="altrow"';?>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __d('categories', 'Parent Category'); ?></dt>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php echo __d('categories', 'Parent Category'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $this->Html->link($category['ParentCategory']['name'], array('controller'=> 'categories', 'action'=>'view', $category['ParentCategory']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __d('categories', 'User'); ?></dt>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php echo __d('categories', 'User'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $this->Html->link($category['User']['id'], array('controller'=> 'users', 'action'=>'view', $category['User']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __d('categories', 'Name'); ?></dt>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php echo __d('categories', 'Name'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $category['Category']['name']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __d('categories', 'Description'); ?></dt>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php echo __d('categories', 'Description'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $category['Category']['description']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __d('categories', 'Created'); ?></dt>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php echo __d('categories', 'Created'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $category['Category']['created']; ?>
&nbsp;
Expand All @@ -40,6 +40,6 @@
</div>
<div class="actions">
<ul>
<li><?php echo $this->Html->link(__d('categories', 'List Categories', true), array('action'=>'index')); ?> </li>
<li><?php echo $this->Html->link(__d('categories', 'List Categories'), array('action'=>'index')); ?> </li>
</ul>
</div>
93 changes: 93 additions & 0 deletions config/Migration/001_initialize_categories_schema.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php
/**
* Copyright 2010, Cake Development Corporation (http://cakedc.com)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2010, Cake Development Corporation (http://cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

/**
* CakePHP Categories Plugin
*
* @package categories
* @subpackage categories.config.migrations
*/
class Caa9bc72d1cc4476fbccp1e4beba7b4jk extends CakeMigration {
/**
* Dependency array. Define what minimum version required for other part of db schema
*
* Migration defined like 'app.31' or 'plugin.PluginName.12'
*
* @var array $dependendOf
*/
public $dependendOf = array();

/**
* Migration array
*
* @var array $migration
*/
public $migration = array(
'up' => array(
'create_table' => array(
'categories' => array(
'id' => array('type'=>'string', 'null' => false, 'default' => NULL, 'length' => 36, 'key' => 'primary'),
'category_id' => array('type'=>'string', 'null' => true, 'default' => NULL, 'length' => 36),
'foreign_key' => array('type'=>'string', 'null' => true, 'default' => NULL, 'length' => 36),
'model' => array('type'=>'string', 'null' => true, 'default' => NULL),
'record_count' => array('type'=>'integer', 'null' => true, 'default' => 0),
'user_id' => array('type'=>'string', 'null' => false, 'default' => NULL, 'length' => 36, 'key' => 'index'),
'lft' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'rght' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'name' => array('type'=>'string', 'null' => false, 'default' => NULL),
'slug' => array('type'=>'string', 'null' => false, 'default' => NULL),
'description' => array('type'=>'text', 'null' => true, 'default' => NULL),
'created' => array('type'=>'datetime', 'null' => true, 'default' => NULL),
'modified' => array('type'=>'datetime', 'null' => true, 'default' => NULL),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => 1),
//'UNIQUE_USER_CATEGORY' => array('column' => array('user_id', 'name'), 'unique' => 1)
)
),
'categorized' => array(
'id' => array('type'=>'string', 'null' => false, 'default' => NULL, 'length' => 36, 'key' => 'primary'),
'category_id' => array('type'=>'string', 'null' => true, 'default' => NULL, 'length' => 36),
'foreign_key' => array('type'=>'string', 'null' => true, 'default' => NULL, 'length' => 36),
'model' => array('type'=>'string', 'null' => false, 'default' => NULL),
'record_count' => array('type'=>'integer', 'null' => true, 'default' => 0),
'created' => array('type'=>'datetime', 'null' => true, 'default' => NULL),
'modified' => array('type'=>'datetime', 'null' => true, 'default' => NULL),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => 1),
'UNIQUE_CATEGORY_CONTENT' => array('column' => array('category_id', 'foreign_key', 'model'), 'unique' => 1)
)
)
),
),
'down' => array(
'drop_table' => array(
'categories', 'categorized'),
)
);
/**
* before migration callback
*
* @param string $direction, up or down direction of migration process
*/
public function before($direction) {
return true;
}

/**
* after migration callback
*
* @param string $direction, up or down direction of migration process
*/
public function after($direction) {
return true;
}

}

0 comments on commit abd3abe

Please sign in to comment.