Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions Console/Templates/twitterbootstrap/common_params.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* Copyright 2005-2010, Cake Development Corporation (http://cakedc.com)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2010, Cake Development Corporation (http://cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

$slugged = false;
$useAppTestCase = true;
$parentSlugged = false;
$additionalParams = '';
$parentIncluded = false;

if (!empty($this->params['noAppTestCase'])) {
$useAppTestCase = false;
}

if (!empty($this->params['property'])) {
$property = true;
}

if (!empty($this->params['parent'])) {
$parentIncluded = true;
$parentClass = Inflector::classify($this->params['parent']);
$parentIdDbVar = Inflector::underscore($parentClass . 'Id');
$parentIdVar = Inflector::variable($parentClass . 'Id');
$singularParentName = Inflector::variable($parentClass);
$singularHumanParentName = Inflector::humanize(Inflector::underscore(Inflector::singularize($parentClass)));
$additionalParams = ', $' . $parentIdVar;
if (!empty($this->params['parentSlug'])) {
$parentSlugged = true;
$parentSlugVar = Inflector::variable($parentClass . 'Slug');
$additionalParams = ', $' . $parentSlugVar;
}
}

if (!empty($this->params['slug'])) {
$slugged = true;
}

if (!empty($this->params['user'])) {
$userIncluded = true;
if (is_string($this->params['user'])) {
$userModel = $this->params['user'];
} else {
$userModel = 'User';
}
} else {
$userIncluded = false;
}


?>
95 changes: 95 additions & 0 deletions Console/Templates/twitterbootstrap/views/form.ctp
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php
/**
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package Cake.Console.Templates.default.views
* @since CakePHP(tm) v 1.2.0.5234
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
$pageTitle = sprintf('%s %s', Inflector::humanize($action), $singularHumanName);
?>
<?php echo "<?php\n".
"\$this->Meta->add('title', __('{$pageTitle}'));
"?>\n"; ?>
<?php echo "<?php echo \$this->element('TwitterBootstrap.breadcrumb'); ?>\n"; ?>
<?php echo "<?php\n".
"echo \$this->TwitterBootstrap->create('{$modelClass}', array(\n" .
"\t'class' => 'validate form-horizontal {$pluralVar}',\n" .
"\t'url' => array('action' => \$this->params['action']{$additionalParams}),\n" .
"\t));\n" .
"\t// this is done to setup the FormHelper insteance to the correct model\n" .
"\t\$this->Form->create('{$modelClass}');\n" .
(strpos($action, 'add') !== false ? '' :
"\t\$this->Form->hidden('id');\n"
) .
"\t?>\n"; ?>
<fieldset>
<h2><?php echo "<?php echo __('{$pageTitle}'); ?>"; ?></h2>
<?php
echo "\t\t<?php\n";
foreach ($fields as $field) {
if (strpos($action, 'add') !== false && $field == $primaryKey) {
continue;
} elseif (!in_array($field, array('id', 'created', 'modified', 'updated'))) {
echo "\t\techo \$this->TwitterBootstrap->input('{$field}', array(\n" .
"\t\t'label' => '" . Inflector::humanize($field) . "',\n" .
"\t\t'help_inline' => ''\n," .
"\t\t));\n";
}
}
if (!empty($associations['hasAndBelongsToMany'])) {
foreach ($associations['hasAndBelongsToMany'] as $assocName => $assocData) {
echo "\t\t?>\n" .
"\t\t<div class=\"control-group habtm\">\n" .
"\t\t\t<label class=\"control-label\">" . Inflector::humanize($field) . "</label>\n" .
"\t\t\t<div class=\"controls\">\n" .
"\t\t\t\t<?php echo \$this->Form->input('{$assocName}'); ?>\n";
"\t\t\t</div>\n" .
"\t\t</div>\n" .
"\t\t<?php\n";
}
}
echo "\t\t?>\n";
?>
</fieldset>
<div class="form-actions">
<button class="btn btn-primary btn-large" type="submit">Submit</button>
<?php echo "<?php echo \$this->Html->link('Cancel', \$this->here); ?>"; ?>
<div class="btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
Action
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><?php echo "<?php echo \$this->Html->link('<i class=\"icon-serach\"></i> ' . __('List {$pluralHumanName}'), array('action' => 'index'{$additionalParams}), array('escape' => false));?>";?></li>
<!-- dropdown menu links -->
<?php if (strpos($action, 'add') === false): ?>
<li><?php echo "<?php echo \$this->Html->link('<i class=\"icon-eye-open\"></i> ' . __('View'), array('action' => 'view', {$idKeyPK}), array('escape' => false)); ?>";?></li>
<li><?php echo "<?php echo \$this->Html->link('<i class=\"icon-trash\"></i> ' . __('Delete'), array('action' => 'delete', {$idKeyPK}), array('escape' => false)); ?>";?></li>
<?php endif; ?>
<?php
$done = array();
foreach ($associations as $type => $data) {
foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
echo "\t\t\t\t<li><?php echo \$this->Html->link('<i class=\"icon-search\"></i> ' .__('List " . Inflector::humanize($details['controller']) . "'), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
echo "\t\t\t\t<li><?php echo \$this->Html->link('<i class=\"icon-add\"></i> ' . __('New " . Inflector::humanize(Inflector::underscore($alias)) . "'), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
$done[] = $details['controller'];
}
}
}
?>
</ul>
</div>
</div>
</div>

92 changes: 92 additions & 0 deletions Console/Templates/twitterbootstrap/views/index.ctp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php
/**
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package Cake.Console.Templates.default.views
* @since CakePHP(tm) v 1.2.0.5234
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
?>
<?php echo "<?php echo \$this->element('TwitterBootstrap.breadcrumb'); ?>\n"; ?>
<div class="<?php echo $pluralVar; ?> index">
<h2><?php echo "<?php echo __('{$pluralHumanName}'); ?>"; ?></h2>
<table class="table table-bordered table-striped">
<tr>
<?php foreach ($fields as $field): ?>
<th><?php echo "<?php echo \$this->Paginator->sort('{$field}'); ?>"; ?></th>
<?php endforeach; ?>
<th class="actions"><?php echo "<?php echo __('Actions'); ?>"; ?></th>
</tr>
<?php
echo "<?php
foreach (\${$pluralVar} as \${$singularVar}): ?>\n";
echo "\t<tr>\n";
foreach ($fields as $field) {
$isKey = false;
if (!empty($associations['belongsTo'])) {
foreach ($associations['belongsTo'] as $alias => $details) {
if ($field === $details['foreignKey']) {
$isKey = true;
echo "\t\t<td>" .
"\n\t\t\t<strong>" .
"\n\t\t\t\t<?php echo \$this->Html->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller' => '{$details['controller']}', 'action' => 'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>" .
"\n\t\t\t</strong>" .
"\n\t\t</td>\n";
break;
}
}
}
if ($isKey !== true) {
// TODO: standardize different display types, eg: date
echo "\t\t<td><?php echo h(\${$singularVar}['{$modelClass}']['{$field}']); ?>&nbsp;</td>\n";
}
}
// actions as a drop down menu
echo "\t\t<td class=\"actions\">\n";
echo "\t\t\t<div class=\"btn-group\">\n";
echo "\t\t\t\t<a class=\"btn dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\">Action <span class=\"caret\"></span></a>\n";
echo "\t\t\t\t<ul class=\"dropdown-menu\">\n";
echo "\t\t\t\t\t<li><?php echo \$this->Html->link(__('View'), array('action' => 'view', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?></li>\n";
echo "\t\t\t\t\t<li><?php echo \$this->Html->link(__('Edit'), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?></li>\n";
echo "\t\t\t\t\t<li><?php echo \$this->Form->postLink(__('Delete'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?></li>\n";
echo "\t\t\t\t</ul>\n";
echo "\t\t\t</div>\n";
echo "\t\t</td>\n";
echo "\t</tr>\n";
echo "<?php endforeach; ?>\n";
?>
</table>
<?php echo "<?php echo \$this->element('TwitterBootstrap.pagination'); ?>\n"; ?>
</div>
<div class="end-of-page-actions">
<div class="btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
Action
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><?php echo "<?php echo \$this->Html->link(__('New " . $singularHumanName . "'), array('action' => 'add')); ?>"; ?></li>
<?php
$done = array();
foreach ($associations as $type => $data) {
foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
echo "\t\t\t<li><?php echo \$this->Html->link(__('List " . Inflector::humanize($details['controller']) . "'), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
echo "\t\t\t<li><?php echo \$this->Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "'), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
$done[] = $details['controller'];
}
}
}
?>
</ul>
</div>
</div>
146 changes: 146 additions & 0 deletions Console/Templates/twitterbootstrap/views/view.ctp
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<?php
/**
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package Cake.Console.Templates.default.views
* @since CakePHP(tm) v 1.2.0.5234
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
?>
<?php echo "<?php echo \$this->element('TwitterBootstrap.breadcrumb'); ?>\n"; ?>
<div class="<?php echo $pluralVar; ?> view">
<h2><?php echo "<?php echo __('{$singularHumanName}'); ?>"; ?></h2>
<dl>
<?php
foreach ($fields as $field) {
$isKey = false;
if (!empty($associations['belongsTo'])) {
foreach ($associations['belongsTo'] as $alias => $details) {
if ($field === $details['foreignKey']) {
$isKey = true;
echo "\t\t<dt><?php echo __('" . Inflector::humanize(Inflector::underscore($alias)) . "'); ?></dt>\n";
echo "\t\t<dd>\n\t\t\t<?php echo \$this->Html->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller' => '{$details['controller']}', 'action' => 'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t\t&nbsp;\n\t\t</dd>\n";
break;
}
}
}
if ($isKey !== true) {
echo "\t\t<dt><?php echo __('" . Inflector::humanize($field) . "'); ?></dt>\n";
echo "\t\t<dd>\n\t\t\t<?php echo h(\${$singularVar}['{$modelClass}']['{$field}']); ?>\n\t\t\t&nbsp;\n\t\t</dd>\n";
}
}
?>
</dl>
</div>
<div class="actions">
<h3><?php echo "<?php echo __('Actions'); ?>"; ?></h3>
<ul>
<?php
echo "\t\t<li><?php echo \$this->Html->link(__('Edit " . $singularHumanName ."'), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
echo "\t\t<li><?php echo \$this->Form->postLink(__('Delete " . $singularHumanName . "'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
echo "\t\t<li><?php echo \$this->Html->link(__('List " . $pluralHumanName . "'), array('action' => 'index')); ?> </li>\n";
echo "\t\t<li><?php echo \$this->Html->link(__('New " . $singularHumanName . "'), array('action' => 'add')); ?> </li>\n";

$done = array();
foreach ($associations as $type => $data) {
foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
echo "\t\t<li><?php echo \$this->Html->link(__('List " . Inflector::humanize($details['controller']) . "'), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
echo "\t\t<li><?php echo \$this->Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "'), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
$done[] = $details['controller'];
}
}
}
?>
</ul>
</div>
<?php
if (!empty($associations['hasOne'])) :
foreach ($associations['hasOne'] as $alias => $details): ?>
<div class="related">
<h3><?php echo "<?php echo __('Related " . Inflector::humanize($details['controller']) . "'); ?>"; ?></h3>
<?php echo "<?php if (!empty(\${$singularVar}['{$alias}'])): ?>\n"; ?>
<dl>
<?php
foreach ($details['fields'] as $field) {
echo "\t\t<dt><?php echo __('" . Inflector::humanize($field) . "'); ?></dt>\n";
echo "\t\t<dd>\n\t<?php echo \${$singularVar}['{$alias}']['{$field}']; ?>\n&nbsp;</dd>\n";
}
?>
</dl>
<?php echo "<?php endif; ?>\n"; ?>
<div class="end-of-page-actions">
<div class="btn-group">
<?php echo "<?php echo \$this->Html->link(__('Edit " . Inflector::humanize(Inflector::underscore($alias)) . "'), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$singularVar}['{$alias}']['{$details['primaryKey']}']), array('class' => 'btn btn-primary')); ?></li>\n"; ?>
</div>
</div>
</div>
<?php
endforeach;
endif;
if (empty($associations['hasMany'])) {
$associations['hasMany'] = array();
}
if (empty($associations['hasAndBelongsToMany'])) {
$associations['hasAndBelongsToMany'] = array();
}
$relations = array_merge($associations['hasMany'], $associations['hasAndBelongsToMany']);
$i = 0;
foreach ($relations as $alias => $details):
$otherSingularVar = Inflector::variable($alias);
$otherPluralHumanName = Inflector::humanize($details['controller']);
?>
<div class="related">
<h3><?php echo "<?php echo __('Related " . $otherPluralHumanName . "'); ?>"; ?></h3>
<?php echo "<?php if (!empty(\${$singularVar}['{$alias}'])): ?>\n"; ?>
<table class="table table-bordered table-striped">
<tr>
<?php
foreach ($details['fields'] as $field) {
echo "\t\t<th><?php echo __('" . Inflector::humanize($field) . "'); ?></th>\n";
}
?>
<th class="actions"><?php echo "<?php echo __('Actions'); ?>"; ?></th>
</tr>
<?php
echo "\t<?php
\$i = 0;
foreach (\${$singularVar}['{$alias}'] as \${$otherSingularVar}): ?>\n";
echo "\t\t<tr>\n";
foreach ($details['fields'] as $field) {
echo "\t\t\t<td><?php echo \${$otherSingularVar}['{$field}']; ?></td>\n";
}

echo "\t\t\t<td class=\"actions\">\n";
echo "\t\t\t\t<?php echo \$this->Html->link(__('View'), array('controller' => '{$details['controller']}', 'action' => 'view', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t\t<?php echo \$this->Html->link(__('Edit'), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t\t<?php echo \$this->Form->postLink(__('Delete'), array('controller' => '{$details['controller']}', 'action' => 'delete', \${$otherSingularVar}['{$details['primaryKey']}']), null, __('Are you sure you want to delete # %s?', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t</td>\n";
echo "\t\t</tr>\n";

echo "\t<?php endforeach; ?>\n";
?>
</table>
<?php echo "<?php endif; ?>\n\n"; ?>
<div class="end-of-page-actions">
<div class="btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
Action
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><?php echo "<?php echo \$this->Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "'), array('controller' => '{$details['controller']}', 'action' => 'add')); ?>"; ?> </li>
</ul>
</div>
</div>
</div><!--/.related-->
<?php endforeach; ?>
Loading