mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-12 20:49:50 +00:00
adding pagination and sorting to scaffold. refactoring plugin views and redirects, updating default layout
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4279 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
6c528ffa00
commit
dc366d046d
8 changed files with 589 additions and 337 deletions
|
@ -1,281 +1,321 @@
|
|||
*{
|
||||
* {
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
/* General Style Info */
|
||||
body{
|
||||
font-family:"frutiger linotype","lucida grande",helvetica,arial,sans-serif;
|
||||
text-align:center;
|
||||
color:#333;
|
||||
font-size: 76%;
|
||||
body {
|
||||
background-color: #2C6877;
|
||||
color: #fff;
|
||||
font-family: "frutiger linotype", "lucida grande", "helvetica", "arial", sans-serif;
|
||||
font-size: 76%;
|
||||
}
|
||||
|
||||
a{
|
||||
color:#003d4c;
|
||||
text-decoration:underline;
|
||||
a {
|
||||
background-color: #fff;
|
||||
color: #003d4c;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
a:hover{
|
||||
color:#003d4c;
|
||||
text-decoration:none;
|
||||
a:hover {
|
||||
background-color: #fff;
|
||||
color: #003d4c;
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
a img{
|
||||
border:none;
|
||||
a img {
|
||||
border:none;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4{
|
||||
font-weight:normal;
|
||||
}
|
||||
|
||||
h1{
|
||||
color: #003d4c;
|
||||
margin:0.3em 0;
|
||||
font-size: 180%;
|
||||
}
|
||||
|
||||
h2{
|
||||
color:#c6c65b;
|
||||
padding-top: 1em;
|
||||
margin:0.3em 0;
|
||||
font-size: 180%;
|
||||
}
|
||||
|
||||
h3{
|
||||
color:#c6c65b;
|
||||
padding-top:2em;
|
||||
font-size: 140%;
|
||||
}
|
||||
|
||||
h4{
|
||||
color:#c6c65b;
|
||||
padding-top:0.5em;
|
||||
font-weight:normal;
|
||||
}
|
||||
|
||||
em {
|
||||
font-size: 12px;
|
||||
font-size: 12px;
|
||||
}
|
||||
h1, h2, h3, h4 {
|
||||
background-color: #fff;
|
||||
font-weight:normal;
|
||||
}
|
||||
h1 {
|
||||
color: #003d4c;
|
||||
font-size: 180%;
|
||||
margin: 0.3em 0;
|
||||
}
|
||||
h2 {
|
||||
color: #2C6877;
|
||||
font-size: 180%;
|
||||
margin: 0.3em 0;
|
||||
padding-top: 1em;
|
||||
}
|
||||
h3 {
|
||||
color: #c6c65b;
|
||||
font-size: 140%;
|
||||
padding-top: 2em;
|
||||
}
|
||||
h4 {
|
||||
color: #c6c65b;
|
||||
font-weight: normal;
|
||||
padding-top: 0.5em;
|
||||
}
|
||||
|
||||
ul, li {
|
||||
margin: 0 12px;
|
||||
margin: 0 12px;
|
||||
}
|
||||
|
||||
/* Layout */
|
||||
#container{
|
||||
text-align:left;
|
||||
#container {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#header{
|
||||
margin-top: 1em;
|
||||
padding: 4px 20px;
|
||||
background-color: #2C6877;
|
||||
padding: 10px 20px 0 20px;
|
||||
}
|
||||
#header h1 {
|
||||
color: #ffffff;
|
||||
background: url('../img/cake.icon.png') no-repeat;
|
||||
padding: 5px 50px;
|
||||
height: 60px;
|
||||
}
|
||||
#header h1 a {
|
||||
color: #ffffff;
|
||||
background: #2C6877;
|
||||
text-decoration: none;
|
||||
}
|
||||
#header h1 a:hover {
|
||||
color: #ffffff;
|
||||
background: #003d4c;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#content{
|
||||
clear:both;
|
||||
padding: 0px 40px 10px 40px;
|
||||
background-color: #fff;
|
||||
color: #333;
|
||||
background-color: #fff;
|
||||
clear: both;
|
||||
color: #333;
|
||||
padding: 0px 40px 40px 40px;
|
||||
overflow: auto;
|
||||
}
|
||||
#footer {
|
||||
clear: both;
|
||||
padding: 6px 10px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#footer{
|
||||
clear:both;
|
||||
padding: 6px 10px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* tables */
|
||||
/* Tables */
|
||||
table {
|
||||
clear:both;
|
||||
width: 100%;
|
||||
border-top: 1px solid #ccc;
|
||||
border-left: 1px solid #ccc;
|
||||
border-bottom: 1px solid #ccc;
|
||||
color:#333;
|
||||
background-color: #fff;
|
||||
margin-bottom: 10px;
|
||||
background-color: #fff;
|
||||
border-top: 1px solid #ccc;
|
||||
border-left: 1px solid #ccc;
|
||||
border-bottom: 1px solid #ccc;
|
||||
clear: both;
|
||||
color: #333;
|
||||
margin-bottom: 10px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
th {
|
||||
background-color: #f2f2f2;
|
||||
border-top: 1px solid #fff;
|
||||
border-left: 1px solid #fff;
|
||||
border-right: 1px solid #bbb;
|
||||
border-bottom: 1px solid #bbb;
|
||||
text-align: center;
|
||||
padding:1px 4px;
|
||||
background-color: #f2f2f2;
|
||||
border-top: 1px solid #fff;
|
||||
border-left: 1px solid #fff;
|
||||
border-right: 1px solid #bbb;
|
||||
border-bottom: 1px solid #bbb;
|
||||
padding: 1px 4px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
table tr td {
|
||||
border-right: 1px solid #ddd;
|
||||
padding:4px 4px;
|
||||
vertical-align:top;
|
||||
text-align: center;
|
||||
border-right: 1px solid #ddd;
|
||||
padding: 4px 4px;
|
||||
text-align: center;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
table tr.altrow td {
|
||||
background: #f4f4f4;
|
||||
background: #f4f4f4;
|
||||
}
|
||||
td a{
|
||||
padding: 0 4px;
|
||||
td.actions {
|
||||
white-space: nowrap;
|
||||
}
|
||||
td.actions a {
|
||||
padding: 0 6px;
|
||||
}
|
||||
|
||||
#cakeSqlLog td {
|
||||
text-align: left;
|
||||
padding: 4px 8px;
|
||||
background: #fff;
|
||||
border-bottom: 2px solid #ccc;
|
||||
background: #fff;
|
||||
border-bottom: 2px solid #ccc;
|
||||
padding: 4px 8px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* scaffold show */
|
||||
/* Paging */
|
||||
div.paging {
|
||||
color: #ccc;
|
||||
}
|
||||
div.paging div.disabled {
|
||||
color: #ddd;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
/* Scaffold View */
|
||||
dl {
|
||||
line-height:2em;
|
||||
margin:0em 1em;
|
||||
float:left;
|
||||
width: 70%;
|
||||
line-height: 2em;
|
||||
margin: 0em 0em;
|
||||
width: 50%;
|
||||
}
|
||||
dl .altrow {
|
||||
background: #f4f4f4;
|
||||
}
|
||||
|
||||
dt {
|
||||
font-weight: bold;
|
||||
vertical-align:top;
|
||||
font-weight: bold;
|
||||
padding-left: 4px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
dd {
|
||||
margin-left:10em;
|
||||
margin-top:-2em;
|
||||
vertical-align:top;
|
||||
margin-left: 10em;
|
||||
margin-top: -2em;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
div.related {
|
||||
clear:both;
|
||||
display:block;
|
||||
}
|
||||
|
||||
/* forms */
|
||||
/* Forms */
|
||||
form {
|
||||
margin-top: 0em;
|
||||
padding: 0;
|
||||
float: left;
|
||||
width: 70%;
|
||||
margin-top: 0;
|
||||
margin-right: 20px;
|
||||
padding: 0;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
form div{
|
||||
vertical-align: text-top;
|
||||
margin-left: 1em;
|
||||
margin-bottom:2em;
|
||||
form div {
|
||||
border: 1px solid #ddd;
|
||||
clear: both;
|
||||
margin-bottom: 1em;
|
||||
padding: .8em 2em 1em 1.4em;
|
||||
vertical-align: text-top;
|
||||
}
|
||||
|
||||
form div.date{
|
||||
margin-left: 0em;
|
||||
form div.required {
|
||||
color: #333;
|
||||
background: #f2f2f2;
|
||||
font-weight: bold;
|
||||
}
|
||||
form div.optional, form div.input {
|
||||
background: #f6f6f6;
|
||||
color: #444;
|
||||
}
|
||||
form div.submit {
|
||||
border: 0;
|
||||
clear: both;
|
||||
margin-top: 10px;
|
||||
margin-left: 140px;
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
float:left;
|
||||
width: 140px;
|
||||
font-size: 14px;
|
||||
padding-right: 20px;
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
input[type=checkbox] {
|
||||
float: left;
|
||||
clear: left;
|
||||
margin: 2px 6px 7px 2px;
|
||||
}
|
||||
|
||||
input, textarea {
|
||||
clear: both;
|
||||
display:block;
|
||||
font-size: 14px;
|
||||
font-family: inherit;
|
||||
clear: both;
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
select {
|
||||
clear: both;
|
||||
vertical-align: text-bottom;
|
||||
font-size: 14px;
|
||||
font-family: inherit;
|
||||
clear: both;
|
||||
font-size: 14px;
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
select[multiple=multiple] {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
option {
|
||||
font-size: 14px;
|
||||
font-family: inherit;
|
||||
padding: 0 0.3em;
|
||||
font-size: 14px;
|
||||
padding: 0 0.3em;
|
||||
}
|
||||
input[type=checkbox] {
|
||||
clear: left;
|
||||
float: left;
|
||||
margin: 2px 6px 7px 2px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
input[type=submit] {
|
||||
display: inline;
|
||||
vertical-align: bottom;
|
||||
display: inline;
|
||||
padding: 0 .4em;
|
||||
width: auto;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
form .required, form .optional, form .input{
|
||||
clear:both;
|
||||
padding: 10px;
|
||||
margin-bottom:10px;
|
||||
min-height:15px;
|
||||
/* Notices and Errors */
|
||||
div.message, p.error, div.error-message {
|
||||
color: #900;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
margin: 8px 0px;
|
||||
}
|
||||
div.error-message {
|
||||
clear: both;
|
||||
}
|
||||
div.error em {
|
||||
font-size: 18px;
|
||||
color: #003d4c;
|
||||
}
|
||||
span.notice {
|
||||
background-color: #c6c65b;
|
||||
color: #fff;
|
||||
display: block;
|
||||
font-size: 16px;
|
||||
padding: 0.5em;
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
.required{
|
||||
color:#333;
|
||||
font-weight:bold;
|
||||
background: #f2f2f2;
|
||||
/* Actions */
|
||||
div.actions {
|
||||
position: absolute;
|
||||
top: 75px;
|
||||
left: 23px;
|
||||
text-align: left;
|
||||
}
|
||||
div.actions ul {
|
||||
margin: 0;
|
||||
padding: 2px 6px;
|
||||
list-style-type: none;
|
||||
display: inline;
|
||||
}
|
||||
div.actions li {
|
||||
display: inline;
|
||||
list-style-type: none;
|
||||
margin: 1px 0px 4px 0px;
|
||||
padding: 2px 6px;
|
||||
}
|
||||
div.actions ul li a{
|
||||
background:#2C6877;
|
||||
color: #fff;
|
||||
padding: 2px 6px;
|
||||
text-decoration: none;
|
||||
}
|
||||
div.actions ul li a:hover {
|
||||
background:#fff;
|
||||
color: #2C6877;
|
||||
}
|
||||
|
||||
.optional, .input {
|
||||
color:#444;
|
||||
background: #f8f8f8;
|
||||
/* Related */
|
||||
div.related {
|
||||
clear: both;
|
||||
display: block;
|
||||
}
|
||||
div.related div.actions {
|
||||
position: relative;
|
||||
top: 4px;
|
||||
left: 0;
|
||||
text-align: left;
|
||||
}
|
||||
div.related div.actions ul {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
div.related div.actions li {
|
||||
list-style-type: none;
|
||||
margin: 0 0 4px 0px;
|
||||
padding: 0;
|
||||
}
|
||||
div.related div.actions ul li a{
|
||||
background:#fff;
|
||||
color: #2C6877;
|
||||
padding: 0;
|
||||
text-decoration: underline;
|
||||
}
|
||||
div.related div.actions ul li a:hover {
|
||||
background:#fff;
|
||||
color: #2C6877;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.submit {
|
||||
clear: both;
|
||||
margin-top: 10px;
|
||||
margin-left: 140px;
|
||||
}
|
||||
|
||||
/* notices and errors */
|
||||
#flashMessage, .error, .error-message {
|
||||
color:#900;
|
||||
font-size: 16px;
|
||||
margin: 8px 0px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.error em {
|
||||
font-size: 18px;
|
||||
color: #003d4c;
|
||||
}
|
||||
|
||||
.notice {
|
||||
color: #656565;
|
||||
font-size: 14px;
|
||||
background-color: #f4f4f4;
|
||||
padding: 0.5em;
|
||||
margin: 1em 0;
|
||||
display:block;
|
||||
}
|
||||
|
||||
.tip {
|
||||
color: #656565;
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
/* action links */
|
||||
ul.actions {
|
||||
float: left;
|
||||
margin: 0px 20px;
|
||||
}
|
||||
|
||||
ul.actions li {
|
||||
margin: 4px 0;
|
||||
list-style-type: circle;
|
||||
}
|
||||
|
||||
|
||||
/* others */
|
||||
/* Other */
|
||||
pre {
|
||||
padding: 1em;
|
||||
padding: 1em;
|
||||
}
|
BIN
app/webroot/img/cake.icon.png
Normal file
BIN
app/webroot/img/cake.icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
|
@ -45,41 +45,104 @@ class Scaffold extends Object {
|
|||
*/
|
||||
var $controller = null;
|
||||
/**
|
||||
* Name of controller to scaffold
|
||||
* Name of the controller to scaffold
|
||||
*
|
||||
* @var string
|
||||
* @var string Name of controller
|
||||
* @access public
|
||||
*/
|
||||
var $name = null;
|
||||
var $name = null;
|
||||
/**
|
||||
* Name of view to render
|
||||
* Action to be performed.
|
||||
*
|
||||
* @var string
|
||||
* @var string Name of action
|
||||
* @access public
|
||||
*/
|
||||
var $action = null;
|
||||
/**
|
||||
* Class name of model
|
||||
*
|
||||
* @var unknown_type
|
||||
*/
|
||||
var $modelClass = null;
|
||||
/**
|
||||
* Registry key of model
|
||||
* Name of current model this view context is attached to
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $modelKey = null;
|
||||
var $model = null;
|
||||
|
||||
/**
|
||||
* View path for scaffolded controller
|
||||
* Path to View.
|
||||
*
|
||||
* @var string Path to View
|
||||
*/
|
||||
var $viewPath;
|
||||
/**
|
||||
* Path parts for creating links in views.
|
||||
*
|
||||
* @var string Base URL
|
||||
* @access public
|
||||
*/
|
||||
var $base = null;
|
||||
|
||||
/**
|
||||
* Name of layout to use with this View.
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $layout = 'default';
|
||||
/**
|
||||
* Array of parameter data
|
||||
*
|
||||
* @var array Parameter data
|
||||
*/
|
||||
var $params;
|
||||
/**
|
||||
* File extension. Defaults to Cake's template ".ctp".
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $ext = '.ctp';
|
||||
|
||||
/**
|
||||
* Sub-directory for this view file.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $viewPath = null;
|
||||
var $subDir = null;
|
||||
|
||||
/**
|
||||
* Plugin name. A Plugin is a sub-application. New in Cake RC4.
|
||||
*
|
||||
* @link http://wiki.cakephp.org/docs:plugins
|
||||
* @var string
|
||||
*/
|
||||
var $plugin = null;
|
||||
|
||||
/**
|
||||
* Controller URL-generation data
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
var $namedArgs = null;
|
||||
|
||||
/**
|
||||
* Controller URL-generation data
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $argSeparator = null;
|
||||
|
||||
/**
|
||||
* List of variables to collect from the associated controller
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
var $__passedVars = array('action', 'base', 'webroot', 'layout', 'name', 'viewPath', 'ext', 'params', 'data', 'webservices', 'plugin', 'namedArgs', 'argSeparator', 'cacheAction');
|
||||
|
||||
/**
|
||||
* Title HTML element for current scaffolded view
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $scaffoldTitle = null;
|
||||
|
||||
/**
|
||||
* Construct and set up given controller with given parameters.
|
||||
*
|
||||
|
@ -88,8 +151,16 @@ class Scaffold extends Object {
|
|||
*/
|
||||
function __construct(&$controller, $params) {
|
||||
$this->controller = &$controller;
|
||||
$this->name = $controller->name;
|
||||
$this->action = $controller->action;
|
||||
|
||||
$count = count($this->__passedVars);
|
||||
for ($j = 0; $j < $count; $j++) {
|
||||
$var = $this->__passedVars[$j];
|
||||
$this->{$var} = $controller->{$var};
|
||||
}
|
||||
$this->redirect = '/' . $this->viewPath;
|
||||
if(!is_null($this->plugin)) {
|
||||
$this->redirect = '/' . $this->plugin . '/' . $this->viewPath;
|
||||
}
|
||||
|
||||
if (!in_array('Form', $this->controller->helpers)) {
|
||||
$this->controller->helpers[] = 'Form';
|
||||
|
@ -110,7 +181,6 @@ class Scaffold extends Object {
|
|||
return $this->cakeError('missingModel', array(array('className' => $this->modelClass, 'webroot' => '', 'base' => $controller->base)));
|
||||
}
|
||||
$this->ScaffoldModel =& $this->controller->{$this->modelClass};
|
||||
$this->viewPath = Inflector::underscore($this->name);
|
||||
$this->scaffoldTitle = Inflector::humanize($this->viewPath);
|
||||
$this->scaffoldActions = $controller->scaffold;
|
||||
$this->controller->pageTitle= __('Scaffold :: ', true) . Inflector::humanize($this->action) . ' :: ' . $this->scaffoldTitle;
|
||||
|
@ -124,7 +194,6 @@ class Scaffold extends Object {
|
|||
$this->controller->set('humanSingularName', Inflector::humanize($this->modelKey));
|
||||
$this->controller->set('humanPluralName', Inflector::humanize($this->viewPath));
|
||||
$alias = null;
|
||||
|
||||
if(!empty($this->ScaffoldModel->alias)) {
|
||||
$alias = array_combine(array_keys($this->ScaffoldModel->alias), array_keys($this->ScaffoldModel->alias));
|
||||
}
|
||||
|
@ -134,7 +203,7 @@ class Scaffold extends Object {
|
|||
$this->__scaffold($params);
|
||||
}
|
||||
/**
|
||||
* Renders a view view of scaffolded Model.
|
||||
* Renders a view action of scaffolded model.
|
||||
*
|
||||
* @param array $params
|
||||
* @return A rendered view of a row from Models database table
|
||||
|
@ -148,7 +217,7 @@ class Scaffold extends Object {
|
|||
} elseif (isset($this->controller->Session) && $this->controller->Session->valid != false) {
|
||||
|
||||
$this->controller->Session->setFlash(sprintf(__("No id set for %s::view()", true), Inflector::humanize($this->modelKey)));
|
||||
$this->controller->redirect('/' . Inflector::underscore($this->controller->viewPath));
|
||||
$this->controller->redirect($this->redirect);
|
||||
} else {
|
||||
return $this->controller->flash(sprintf(__("No id set for %s::view()", true), Inflector::humanize($this->modelKey)),
|
||||
'/' . Inflector::underscore($this->controller->viewPath));
|
||||
|
@ -156,7 +225,9 @@ class Scaffold extends Object {
|
|||
$this->controller->data = $this->ScaffoldModel->read();
|
||||
$this->controller->set('data', $this->controller->data);
|
||||
$this->controller->set('fieldNames', $this->controller->generateFieldNames($this->controller->data, false));
|
||||
|
||||
|
||||
$this->controller->render($this->action, $this->layout, $this->__getViewFileName($this->action));
|
||||
/*
|
||||
if (file_exists(APP . 'views' . DS . $this->viewPath . DS . 'scaffold.view.thtml')) {
|
||||
return $this->controller->render($this->action, '',
|
||||
APP . 'views' . DS . $this->viewPath . DS . 'scaffold.view.thtml');
|
||||
|
@ -166,14 +237,14 @@ class Scaffold extends Object {
|
|||
} else {
|
||||
return $this->controller->render($this->action, '',
|
||||
LIBS . 'view' . DS . 'templates' . DS . 'scaffolds' . DS . 'view.thtml');
|
||||
}
|
||||
}*/
|
||||
|
||||
} elseif ($this->controller->_scaffoldError('view') === false) {
|
||||
return $this->__scaffoldError();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Renders List view of scaffolded Model.
|
||||
* Renders index action of scaffolded model.
|
||||
*
|
||||
* @param array $params
|
||||
* @return A rendered view listing rows from Models database table
|
||||
|
@ -184,8 +255,10 @@ class Scaffold extends Object {
|
|||
|
||||
$this->controller->set('fieldNames', $this->controller->generateFieldNames(null, false));
|
||||
$this->ScaffoldModel->recursive = 0;
|
||||
$this->controller->set('data', $this->ScaffoldModel->findAll(null, null, $this->modelClass.'.'.$this->ScaffoldModel->primaryKey.' DESC'));
|
||||
|
||||
$this->controller->set('data', $this->controller->paginate());
|
||||
|
||||
$this->controller->render($this->action, $this->layout, $this->__getViewFileName($this->action));
|
||||
/*
|
||||
if (file_exists(APP . 'views' . DS . $this->viewPath . DS . 'scaffold.index.thtml')) {
|
||||
return $this->controller->render($this->action, '',
|
||||
APP . 'views' . DS . $this->viewPath . DS . 'scaffold.index.thtml');
|
||||
|
@ -195,7 +268,7 @@ class Scaffold extends Object {
|
|||
} else {
|
||||
return $this->controller->render($this->action, '',
|
||||
LIBS . 'view' . DS . 'templates' . DS . 'scaffolds' . DS . 'index.thtml');
|
||||
}
|
||||
}*/
|
||||
|
||||
} elseif ($this->controller->_scaffoldError('index') === false) {
|
||||
return $this->__scaffoldError();
|
||||
|
@ -203,7 +276,7 @@ class Scaffold extends Object {
|
|||
}
|
||||
|
||||
/**
|
||||
* Renders an Add or Edit view for scaffolded Model.
|
||||
* Renders an add or edit action for scaffolded model.
|
||||
*
|
||||
* @param array $params
|
||||
* @param string $params add or edit
|
||||
|
@ -211,16 +284,18 @@ class Scaffold extends Object {
|
|||
* @access private
|
||||
*/
|
||||
function __scaffoldForm($action = 'edit') {
|
||||
$this->controller->render($action, $this->layout, $this->__getViewFileName('edit'));
|
||||
/*
|
||||
if (file_exists(APP . 'views' . DS . $this->viewPath . DS . 'scaffold.' . $action . '.thtml')) {
|
||||
return $this->controller->render($action, '', APP . 'views' . DS . $this->viewPath . DS . 'scaffold.' . $action . '.thtml');
|
||||
} elseif(file_exists(APP . 'views' . DS . 'scaffold' . DS . 'scaffold.' . $action . '.thtml')) {
|
||||
return $this->controller->render($action, '', APP . 'views' . DS . 'scaffold' . DS . 'scaffold.' . $action . '.thtml');
|
||||
} else {
|
||||
return $this->controller->render($action, '', LIBS . 'view' . DS . 'templates' . DS . 'scaffolds' . DS . 'edit.thtml');
|
||||
}
|
||||
}*/
|
||||
}
|
||||
/**
|
||||
* Saves or updates a model.
|
||||
* Saves or updates the scaffolded model.
|
||||
*
|
||||
* @param array $params
|
||||
* @param string $type create or update
|
||||
|
@ -250,7 +325,7 @@ class Scaffold extends Object {
|
|||
$this->ScaffoldModel->id = $params['pass'][0];
|
||||
} elseif (isset($this->controller->Session) && $this->controller->Session->valid != false) {
|
||||
$this->controller->Session->setFlash(sprintf(__("No id set for %s::edit()", true), Inflector::humanize($this->modelKey)));
|
||||
$this->controller->redirect('/' . Inflector::underscore($this->controller->viewPath));
|
||||
$this->controller->redirect($this->redirect);
|
||||
} else {
|
||||
return $this->controller->flash(sprintf(__("No id set for %s::edit()", true), Inflector::humanize($this->modelKey)),
|
||||
'/' . Inflector::underscore($this->controller->viewPath));
|
||||
|
@ -275,8 +350,7 @@ class Scaffold extends Object {
|
|||
if ($this->controller->_afterScaffoldSave($action)) {
|
||||
if (isset($this->controller->Session) && $this->controller->Session->valid != false) {
|
||||
$this->controller->Session->setFlash(sprintf(__('The %1$s has been %2$s', true), Inflector::humanize($this->modelClass), $success));
|
||||
|
||||
$this->controller->redirect('/' . $this->viewPath);
|
||||
$this->controller->redirect($this->redirect);
|
||||
} else {
|
||||
return $this->controller->flash(sprintf(__('The %1$s has been %2$s', true), Inflector::humanize($this->modelClass), $success), '/' . $this->viewPath);
|
||||
}
|
||||
|
@ -291,14 +365,15 @@ class Scaffold extends Object {
|
|||
$this->controller->set('data', $this->controller->data);
|
||||
$this->controller->set('fieldNames', $this->controller->generateFieldNames($this->__rebuild($this->controller->data)));
|
||||
$this->controller->validateErrors($this->ScaffoldModel);
|
||||
|
||||
/*
|
||||
if (file_exists(APP . 'views' . DS . $this->viewPath . DS . 'scaffolds' . DS . 'scaffold.' . $viewFileName . '.thtml')) {
|
||||
return $this->controller->render($viewFileName, '', APP . 'views' . DS . $this->viewPath . DS . 'scaffolds' . DS . 'scaffold.' . $viewFileName . '.thtml');
|
||||
} elseif(file_exists(APP . 'views' . DS . 'scaffold' . DS . 'scaffold.' . $viewFileName . '.thtml')) {
|
||||
return $this->controller->render($viewFileName, '', APP . 'views' . DS . 'scaffold' . DS . 'scaffold.' . $viewFileName . '.thtml');
|
||||
} else {
|
||||
return $this->controller->render($viewFileName, '', LIBS . 'view' . DS . 'templates' . DS . 'scaffolds' . DS . 'edit.thtml');
|
||||
}
|
||||
}*/
|
||||
$this->controller->render($viewFileName, $this->layout, $this->__getViewFileName($viewFileName));
|
||||
}
|
||||
} else if($this->controller->_scaffoldError($action) === false) {
|
||||
return $this->__scaffoldError();
|
||||
|
@ -318,7 +393,7 @@ class Scaffold extends Object {
|
|||
$id = $params['pass'][0];
|
||||
} elseif (isset($this->controller->Session) && $this->controller->Session->valid != false) {
|
||||
$this->controller->Session->setFlash(sprintf(__("No id set for %s::delete()", true), Inflector::humanize($this->modelKey)));
|
||||
$this->controller->redirect('/' . Inflector::underscore($this->controller->viewPath));
|
||||
$this->controller->redirect($this->redirect);
|
||||
} else {
|
||||
return $this->controller->flash(sprintf(__("No id set for %s::delete()", true), Inflector::humanize($this->modelKey)),
|
||||
'/' . Inflector::underscore($this->controller->viewPath));
|
||||
|
@ -327,14 +402,14 @@ class Scaffold extends Object {
|
|||
if ($this->ScaffoldModel->del($id)) {
|
||||
if (isset($this->controller->Session) && $this->controller->Session->valid != false) {
|
||||
$this->controller->Session->setFlash(sprintf(__('The %1$s with id: %2$d has been deleted.', true), Inflector::humanize($this->modelClass), $id));
|
||||
$this->controller->redirect('/' . $this->viewPath);
|
||||
$this->controller->redirect($this->redirect);
|
||||
} else {
|
||||
return $this->controller->flash(sprintf(__('The %1$s with id: %2$d has been deleted.', true), Inflector::humanize($this->modelClass), $id), '/' . $this->viewPath);
|
||||
}
|
||||
} else {
|
||||
if (isset($this->controller->Session) && $this->controller->Session->valid != false) {
|
||||
$this->controller->Session->setFlash(sprintf(__('There was an error deleting the %1$s with id: %2$d', true), Inflector::humanize($this->modelClass), $id));
|
||||
$this->controller->redirect('/' . $this->viewPath);
|
||||
$this->controller->redirect($this->redirect);
|
||||
} else {
|
||||
return $this->controller->flash(sprintf(__('There was an error deleting the %1$s with id: %2$d', true), Inflector::humanize($this->modelClass), $id), '/' . $this->viewPath);
|
||||
}
|
||||
|
@ -349,15 +424,15 @@ class Scaffold extends Object {
|
|||
*
|
||||
* @return error
|
||||
*/
|
||||
function __scaffoldError() {
|
||||
function __scaffoldError() {
|
||||
if (file_exists(APP . 'views' . DS . $this->viewPath . DS . 'scaffolds' . DS. 'scaffold.error.thtml')) {
|
||||
return $this->controller->render($this->action, '',
|
||||
return $this->controller->render($this->action, $this->layout,
|
||||
APP . 'views' . DS . $this->viewPath . DS . 'scaffolds' . DS . 'scaffold.error.thtml');
|
||||
} elseif (file_exists(APP . 'views' . DS . 'scaffold' . DS . 'scaffold.error.thtml')) {
|
||||
return $this->controller->render($this->action, '',
|
||||
return $this->controller->render($this->action, $this->layout,
|
||||
APP . 'views' . DS . 'scaffold' . DS . 'scaffold.error.thtml');
|
||||
} else {
|
||||
return $this->controller->render($this->action, '',
|
||||
return $this->controller->render($this->action, $this->layout,
|
||||
LIBS . 'view' . DS . 'templates' . DS . 'errors' . DS . 'scaffold_error.thtml');
|
||||
}
|
||||
}
|
||||
|
@ -445,5 +520,54 @@ class Scaffold extends Object {
|
|||
return $this->cakeError('missingDatabase', array(array('webroot' => $this->controller->webroot)));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns scaffold view filename of given action's template file (.ctp) as a string.
|
||||
*
|
||||
* @param string $action Controller action to find template filename for
|
||||
* @return string Template filename
|
||||
* @access private
|
||||
*/
|
||||
function __getViewFileName($action) {
|
||||
$action = Inflector::underscore($action);
|
||||
$scaffoldAction = 'scaffold.'.$action;
|
||||
$paths = Configure::getInstance();
|
||||
|
||||
if (!is_null($this->webservices)) {
|
||||
$type = strtolower($this->webservices) . DS;
|
||||
} else {
|
||||
$type = null;
|
||||
}
|
||||
|
||||
if (!is_null($this->plugin)) {
|
||||
|
||||
if (file_exists(APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $scaffoldAction . $this->ext)) {
|
||||
return APP . 'views' . DS . 'plugins' . DS . 'scaffold'. DS . $this->subDir . $type . $action . $this->ext;
|
||||
} elseif (file_exists(APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $scaffoldAction . $this->ext)) {
|
||||
return APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $action . $this->ext;
|
||||
} elseif (file_exists(APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $scaffoldAction . $this->ext)) {
|
||||
return APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $scaffoldAction . $this->ext;
|
||||
} elseif (file_exists(APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $scaffoldAction . '.thtml')) {
|
||||
return APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $scaffoldAction . '.thtml';
|
||||
} elseif (file_exists(APP . 'views' . DS . 'plugins' . DS . 'scaffold'. DS . $this->subDir . $type . $scaffoldAction . '.thtml')) {
|
||||
return APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $scaffoldAction . '.thtml';
|
||||
} elseif (file_exists(APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $scaffoldAction . '.thtml')) {
|
||||
return APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $scaffoldAction . '.thtml';
|
||||
}
|
||||
}
|
||||
|
||||
foreach($paths->viewPaths as $path) {
|
||||
if (file_exists($path . $this->viewPath . DS . $this->subDir . $type . $scaffoldAction . $this->ext)) {
|
||||
return $path . $this->viewPath . DS . $this->subDir . $type . $scaffoldAction . $this->ext;
|
||||
} elseif (file_exists($path . $this->viewPath . DS . 'scaffold' . DS . $this->subDir . $type . $scaffoldAction . $this->ext)) {
|
||||
return $path . $this->viewPath . DS . $this->subDir . $type . $scaffoldAction . $this->ext;
|
||||
} elseif (file_exists($path . $this->viewPath . DS . $this->subDir . $type . $scaffoldAction . '.thtml')) {
|
||||
return $path . $this->viewPath . DS . $this->subDir . $type . $action . '.thtml';
|
||||
} elseif (file_exists($path . $this->viewPath . DS . 'scaffold' . DS . $this->subDir . $type . $scaffoldAction . '.thtml')) {
|
||||
return $path . $this->viewPath . DS . $this->subDir . $type . $scaffoldAction . '.thtml';
|
||||
}
|
||||
}
|
||||
|
||||
return LIBS . 'view' . DS . 'templates' . DS . 'scaffolds' . DS . $action . '.thtml';
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -27,31 +27,39 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>CakePHP : <?php echo $title_for_layout;?></title>
|
||||
<?php echo $html->charset(); ?>
|
||||
<title>
|
||||
CakePHP: the PHP Rapid Development Framework:
|
||||
<?php echo $title_for_layout;?>
|
||||
</title>
|
||||
|
||||
<?php echo $html->charset();?>
|
||||
|
||||
<link rel="icon" href="<?php echo $this->webroot . 'favicon.ico';?>" type="image/x-icon" />
|
||||
<link rel="shortcut icon" href="<?php echo $this->webroot . 'favicon.ico';?>" type="image/x-icon" />
|
||||
<?php echo $html->css('cake.generic');?>
|
||||
<link rel="icon" href="<?php echo $this->webroot;?>favicon.ico" type="image/x-icon" />
|
||||
<link rel="shortcut icon" href="<?php echo $this->webroot;?>favicon.ico" type="image/x-icon" />
|
||||
<?php echo $html->css('cake.generic');?>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="header">
|
||||
<h1><?php __('CakePHP Rapid Development'); ?></h1>
|
||||
<h1><?php echo $html->link('CakePHP: the PHP Rapid Development Framework', 'http://cakephp.org');?></h1>
|
||||
</div>
|
||||
<div id="content">
|
||||
<?php if ($session->check('Message.flash'))
|
||||
{
|
||||
<?php
|
||||
if($session->check('Message.flash')):
|
||||
$session->flash();
|
||||
}
|
||||
echo $content_for_layout;
|
||||
endif;
|
||||
?>
|
||||
|
||||
<?php echo $content_for_layout;?>
|
||||
|
||||
</div>
|
||||
<div id="footer">
|
||||
|
||||
<a href="http://www.cakephp.org/" target="_new">
|
||||
<?php echo $html->image('cake.power.png', array('alt'=>"CakePHP : Rapid Development Framework", 'border'=>"0"));?>
|
||||
</a>
|
||||
<?php echo $html->link(
|
||||
$html->image('cake.power.png', array('alt'=>"CakePHP: the PHP Rapid Development Framework", 'border'=>"0")),
|
||||
'http://www.cakephp.org/',
|
||||
array('target'=>'_new'), null, false
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo $cakeDebug?>
|
||||
|
|
|
@ -24,14 +24,55 @@
|
|||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
?>
|
||||
<p class="notice"><?php echo sprintf(__('Your database configuration file is %s.', true), file_exists(CONFIGS.'database.php') ? __('present', true) . $filePresent = ' ' : __('not present', true));?></p>
|
||||
<?php if (!empty($filePresent)):?>
|
||||
<?php uses('model' . DS . 'connection_manager'); $db = ConnectionManager::getInstance(); ?>
|
||||
<?php $connected = $db->getDataSource('default'); ?>
|
||||
<p class="notice"><?php echo sprintf(__('Cake %s connect to the database.', true), $connected->isConnected() ? __('is able to', true) : __('is not able to', true));?></p>
|
||||
<br />
|
||||
<p>
|
||||
<span class="notice">
|
||||
<?php
|
||||
__('Your /app/tmp directory is ');
|
||||
if(is_writable(TMP)):
|
||||
__('writable.');
|
||||
else:
|
||||
__('NOT writable.');
|
||||
endif;
|
||||
?>
|
||||
</span>
|
||||
</p>
|
||||
<p>
|
||||
<span class="notice">
|
||||
<?php
|
||||
__('Your database configuration file is ');
|
||||
$filePresent = null;
|
||||
if(file_exists(CONFIGS.'database.php')):
|
||||
__('present.');
|
||||
$filePresent = true;
|
||||
else:
|
||||
__('NOT present.');
|
||||
echo '<br/>';
|
||||
__('Rename /app/config/database.php.default to /app/config/database.php');
|
||||
endif;
|
||||
?>
|
||||
</span>
|
||||
</p>
|
||||
<?php
|
||||
if (!empty($filePresent)):
|
||||
uses('model' . DS . 'connection_manager');
|
||||
$db = ConnectionManager::getInstance();
|
||||
$connected = $db->getDataSource('default');
|
||||
?>
|
||||
<p>
|
||||
<span class="notice">
|
||||
<?php
|
||||
__('Cake');
|
||||
if($connected->isConnected()):
|
||||
__(' is able to ');
|
||||
else:
|
||||
__(' is NOT able to ');
|
||||
endif;
|
||||
__('connect to the database.');
|
||||
?>
|
||||
</span>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<h2><?php __('CakePHP release information is on CakeForge'); ?></h2>
|
||||
<h2><?php echo sprintf(__('Release Notes for CakePHP %s.', true), Configure::version()); ?></h2>
|
||||
<a href="https://trac.cakephp.org/wiki/notes/1.2.x.x"><?php __('Read the release notes and get the latest version'); ?> </a>
|
||||
<h2><?php __('Editing this Page'); ?></h2>
|
||||
<p>
|
||||
|
@ -40,6 +81,12 @@
|
|||
<a href="http://manual.cakephp.org/"><?php __('See the views section of the manual for more info.'); ?> </a><br />
|
||||
<?php __('You can also add some CSS styles for your pages at: app/webroot/css/.'); ?>
|
||||
</p>
|
||||
<h2><?php __('Getting Started'); ?></h2>
|
||||
<p>
|
||||
<a href="http://manual.cakephp.org/appendix/blog_tutorial"><?php __('The 15 min Blog Tutorial'); ?></a><br />
|
||||
<a href="http://hades.phparch.com/ceres/public/article/index.php/art::cakephp::overview"><?php __('Overview of CakePHP'); ?></a><br />
|
||||
<a href="http://www.sitepoint.com/article/application-development-cakephp"><?php __('Your First Bite'); ?></a>
|
||||
</p>
|
||||
<h2><?php __('More about Cake'); ?></h2>
|
||||
<p>
|
||||
<?php __('CakePHP is a rapid development framework for PHP which uses commonly known design patterns like Active Record, Association Data Mapping, Front Controller and MVC.'); ?>
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
$modelObj =& ClassRegistry::getObject($modelKey);
|
||||
?>
|
||||
<h2><?php echo $formName.' '.$humanSingularName;?></h2>
|
||||
<?php
|
||||
|
@ -31,7 +30,8 @@ echo $form->create($modelClass);
|
|||
echo $form->inputs($fieldNames);
|
||||
echo $form->submit(__('Save', true)); ?>
|
||||
</form>
|
||||
<ul class='actions'>
|
||||
<div class='actions'>
|
||||
<ul>
|
||||
<?php
|
||||
if($formName == 'Edit') {
|
||||
echo "<li>".$html->link(__('Delete ', true).$humanSingularName, array('action' => 'delete', $data[$modelClass][$primaryKey]), null, 'Are you sure you want to delete '.$data[$modelClass][$displayField])."</li>";
|
||||
|
@ -45,4 +45,5 @@ if($formName == 'Edit') {
|
|||
}
|
||||
}
|
||||
}?>
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
|
@ -27,15 +27,22 @@
|
|||
<h2>List <?php echo $humanPluralName;?></h2>
|
||||
<?php
|
||||
$modelObj =& ClassRegistry::getObject($modelKey);
|
||||
if(!empty($modelObj->alias)) {
|
||||
$alias = array_combine(array_keys($modelObj->alias), array_keys($modelObj->alias));
|
||||
}
|
||||
?>
|
||||
<p><?php
|
||||
echo $paginator->counter(array(
|
||||
'format' => 'Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%'
|
||||
));
|
||||
?></p>
|
||||
<table class="scaffold" cellpadding="0" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php foreach ($fieldNames as $fieldName) {?>
|
||||
<th><?php echo $fieldName['label'];?></th>
|
||||
<?php foreach ($fieldNames as $fieldName) { ?>
|
||||
<th>
|
||||
<?php
|
||||
$tag = explode('/', $fieldName['tagName']);
|
||||
echo $paginator->sort($tag[1]);
|
||||
?>
|
||||
</th>
|
||||
<?php }?>
|
||||
<th><?php __('Actions'); ?></th>
|
||||
</tr>
|
||||
|
@ -48,7 +55,7 @@ if(is_array($data)) {
|
|||
if($i++ % 2 == 0) {
|
||||
echo '<tr>';
|
||||
} else {
|
||||
echo '<tr class="altrow"">';
|
||||
echo '<tr class="altrow">';
|
||||
}
|
||||
foreach($fieldNames as $field => $value) {
|
||||
?>
|
||||
|
@ -76,12 +83,21 @@ if(is_array($data)) {
|
|||
<?php echo $html->link(__('Edit', true), array('action' => 'edit', $id)) ?>
|
||||
<?php echo $html->link(__('Delete', true), array('action' => 'delete', $id), null, sprintf(__("Are you sure you want to delete id %s?", true), $id)) ?>
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}?>
|
||||
</tbody>
|
||||
</table>
|
||||
<ul class="actions">
|
||||
<li><?php echo $html->link(__('New ', true).$humanSingularName, array('action' => 'add')); ?></li>
|
||||
</ul>
|
||||
<div class="paging">
|
||||
<?php echo $paginator->prev('<< previous', array(), null, array('class'=>'disabled'));?>
|
||||
|
|
||||
<?php echo $paginator->next('next >>', array(), null, array('class'=>'disabled'));?>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<li>
|
||||
<?php echo $html->link(__('New ', true).$humanSingularName, array('action' => 'add')); ?>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
|
@ -26,16 +26,18 @@
|
|||
?>
|
||||
<?php
|
||||
$modelObj =& ClassRegistry::getObject($modelKey);
|
||||
if(!empty($modelObj->alias)) {
|
||||
$alias = array_combine(array_keys($modelObj->alias), array_keys($modelObj->alias));
|
||||
}?>
|
||||
<h1>View <?php echo sprintf(__("View %s", true), $humanSingularName)?>
|
||||
|
||||
</h1>
|
||||
?>
|
||||
<h2><?php echo sprintf(__("View %s", true), $humanSingularName)?></h2>
|
||||
<dl>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach($fieldNames as $field => $value) {
|
||||
echo "<dt>".$value['label']."</dt>";
|
||||
if($i++ % 2 == 0) {
|
||||
$class = 'class="altrow"';
|
||||
} else {
|
||||
$class = null;
|
||||
}
|
||||
echo "<dt {$class}>".$value['label']."</dt>";
|
||||
if(isset($value['foreignKey'])) {
|
||||
$otherControllerName = $value['controller'];
|
||||
$otherControllerPath = Inflector::underscore($value['controller']);
|
||||
|
@ -43,21 +45,22 @@ foreach($fieldNames as $field => $value) {
|
|||
$othereDisplayField = $otherModelObj->getDisplayField();
|
||||
$displayText = $data[$alias[$value['model']]][$othereDisplayField];
|
||||
if(!empty($data[$modelClass][$field]) && (!empty($displayText))) {
|
||||
echo "<dd>".$html->link($displayText, $path . $otherControllerPath.'/view/'
|
||||
echo "<dd {$class}>".$html->link($displayText, $path . $otherControllerPath.'/view/'
|
||||
.$data[$modelClass][$field] )."</dd>";
|
||||
} else {
|
||||
echo "<dd> </dd>";
|
||||
echo "<dd {$class}> </dd>";
|
||||
}
|
||||
} else {
|
||||
if( !empty($data[$modelClass][$field])) {
|
||||
echo "<dd>".$data[$modelClass][$field]."</dd>";
|
||||
echo "<dd {$class}>".$data[$modelClass][$field]."</dd>";
|
||||
} else {
|
||||
echo "<dd> </dd>";
|
||||
echo "<dd {$class}> </dd>";
|
||||
}
|
||||
}
|
||||
}?>
|
||||
</dl>
|
||||
<ul class='actions'>
|
||||
<div class='actions'>
|
||||
<ul>
|
||||
<?php
|
||||
echo '<li>' . $html->link(sprintf(__("Edit %s", true), $humanSingularName), array('action' => 'edit', $data[$modelClass][$modelObj->primaryKey])) . '</li>';
|
||||
echo '<li>' . $html->link(sprintf(__("Delete %s", true), $humanSingularName), array('action' => 'delete', $data[$modelClass][$modelObj->primaryKey]), null, sprintf(__("Are you sure you want to delete id %s?", true), $data[$modelClass][$modelObj->primaryKey])) . '</li>';
|
||||
|
@ -67,43 +70,55 @@ echo '<li>' . $html->link(sprintf(__("New %s", true), $humanSingularName), array
|
|||
foreach($fieldNames as $field => $value) {
|
||||
if(isset($value['foreignKey'])) {
|
||||
echo "<li>".$html->link(sprintf(__("List %s", true), Inflector::humanize($value['controller'])), array('controller' => $value['controller'], 'action' => 'index')) . '</li>';
|
||||
echo "<li>".$html->link(sprintf(__("Add %s", true), Inflector::humanize($value['controller'])), $path . $value['controller'] ."/add/")."</li>";
|
||||
echo "<li>".$html->link(sprintf(__("Add %s", true), Inflector::humanize($value['controller'])), array('controller' => $value['controller'], 'action'=>'add'))."</li>";
|
||||
}
|
||||
}?>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<!--hasOne relationships -->
|
||||
<?php
|
||||
$j = 0;
|
||||
foreach ($modelObj->hasOne as $associationNameName => $relation) {
|
||||
$otherModelKey = Inflector::underscore($relation['className']);
|
||||
$otherModelObj =& ClassRegistry::getObject($otherModelKey);
|
||||
$otherControllerPath = Inflector::pluralize($otherModelKey);
|
||||
$new = true;
|
||||
echo "<div class='related'><H2>".sprintf(__("Related %s", true), Inflector::humanize($associationNameName))."</H2>";
|
||||
echo "<dl>";
|
||||
if(isset($data[$associationNameName]) && is_array($data[$associationNameName])) {
|
||||
if($j++ % 2 == 0) {
|
||||
$class = 'class="altrow"';
|
||||
} else {
|
||||
$class = null;
|
||||
}
|
||||
echo "<div class=\"related\">";
|
||||
echo "<h3>".sprintf(__("Related %s", true), Inflector::humanize($associationNameName))."</h3>";
|
||||
if(!empty($data[$associationNameName])) {
|
||||
echo "<dl>";
|
||||
foreach($data[$associationNameName] as $field => $value) {
|
||||
if(isset($value)) {
|
||||
echo "<dt>".Inflector::humanize($field)."</dt>";
|
||||
echo "<dt {$class}>".Inflector::humanize($field)."</dt>";
|
||||
if(!empty($value)) {
|
||||
echo "<dd>".$value."</dd>";
|
||||
echo "<dd {$class}>".$value."</dd>";
|
||||
} else {
|
||||
echo "<dd> </dd>";
|
||||
echo "<dd {$class}> </dd>";
|
||||
}
|
||||
$new = null;
|
||||
}
|
||||
}
|
||||
echo "</dl>";
|
||||
if($new == null) {
|
||||
echo "<ul class='actions'><li>".$html->link(sprintf(__("Edit %s", true), Inflector::humanize($associationNameName)), $path . $otherControllerPath."/edit/{$data[$associationNameName][$otherModelObj->primaryKey]}")."</li></ul></div>";
|
||||
} else {
|
||||
echo "<ul class='actions'><li>".$html->link(sprintf(__("New %s", true), Inflector::humanize($associationNameName)), $path . $otherControllerPath."/add/{$data[$associationNameName][$otherModelObj->primaryKey]}")."</li></ul></div>";
|
||||
}
|
||||
}
|
||||
echo "<div class=\"actions\">";
|
||||
echo "<ul>";
|
||||
if($new == null) {
|
||||
echo "<li>".$html->link(sprintf(__("Edit %s", true), Inflector::humanize($associationNameName)), array('controller'=> $otherControllerPath, 'action'=>'edit', $data[$associationNameName][$otherModelObj->primaryKey]))."</li>";
|
||||
} else {
|
||||
echo "<li>".$html->link(sprintf(__("New %s", true), Inflector::humanize($associationNameName)), array('controller'=> $otherControllerPath, 'action'=>'add'))."</li>";
|
||||
}
|
||||
echo "</ul>";
|
||||
echo "</div>";
|
||||
echo "</div>";
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- HAS MANY AND HASANDBELONGSTOMANY -->
|
||||
<!--hasMany and hasAndBelongsToMany relationships -->
|
||||
<?php
|
||||
$relations = array_merge($modelObj->hasMany, $modelObj->hasAndBelongsToMany);
|
||||
foreach($relations as $associationName => $relation) {
|
||||
|
@ -114,9 +129,10 @@ foreach($relations as $associationName => $relation) {
|
|||
|
||||
$otherModelName = $relation['className'];
|
||||
|
||||
echo "<div class='related'><h2>".sprintf(__("Related %s", true), Inflector::humanize($otherControllerPath))."</h2>";
|
||||
echo "<div class=\"related\">";
|
||||
echo "<h3>".sprintf(__("Related %s", true), Inflector::humanize($otherControllerPath))."</h3>";
|
||||
if(isset($data[$associationName][0]) && is_array($data[$associationName])) {?>
|
||||
<table class="inav" cellspacing="0">
|
||||
<table cellspacing="0">
|
||||
<tr>
|
||||
<?php
|
||||
$bFound = false;
|
||||
|
@ -134,24 +150,24 @@ foreach($relations as $associationName => $relation) {
|
|||
foreach($row as $column => $value) {
|
||||
echo "<td>".$value."</td>";
|
||||
}
|
||||
if (isset($otherModelObj->{$associationName})) {?>
|
||||
<td class="listactions"><?php echo $html->link(__('View', true), $path . $otherControllerPath . "/view/{$row[$otherModelObj->primaryKey]}/")?>
|
||||
<?php echo $html->link(__('Edit', true), $path . $otherControllerPath . "/edit/{$row[$otherModelObj->primaryKey]}/")?>
|
||||
<?php echo $html->link(__('Delete', true), $path . $otherControllerPath . "/delete/{$row[$otherModelObj->primaryKey]}/", null, sprintf(__("Are you sure you want to delete id %s?", true), $row[$otherModelObj->primaryKey]))?>
|
||||
|
||||
?>
|
||||
<td class="actions">
|
||||
<?php echo $html->link(__('View', true), array('controller'=> $otherControllerPath, 'action'=>'view', $row[$otherModelObj->primaryKey]))?>
|
||||
<?php echo $html->link(__('Edit', true), array('controller'=> $otherControllerPath, 'action'=>'edit', $row[$otherModelObj->primaryKey]))?>
|
||||
<?php echo $html->link(__('Delete', true), array('controller'=> $otherControllerPath, 'action'=>'delete', $row[$otherModelObj->primaryKey]), null, sprintf(__("Are you sure you want to delete id %s?", true), $row[$otherModelObj->primaryKey]))?>
|
||||
</td>
|
||||
<?php
|
||||
} else {?>
|
||||
<td class="listactions"><?php echo $html->link(__('View', true), $path . $otherControllerPath . "/view/{$row[$otherModelObj->primaryKey]}/")?>
|
||||
<?php echo $html->link(__('Edit', true), $path . $otherControllerPath . "/edit/{$row[$otherModelObj->primaryKey]}/")?>
|
||||
<?php echo $html->link(__('Delete', true), $path . $otherControllerPath . "/delete/{$row[$otherModelObj->primaryKey]}/", null, sprintf(__("Are you sure you want to delete id %s?", true), $row[$otherModelObj->primaryKey]))?>
|
||||
</td>
|
||||
<?php
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
}?>
|
||||
</table>
|
||||
<ul class="actions">
|
||||
<?php echo "<li>".$html->link(__('New ', true).Inflector::humanize($associationName), $path . $otherControllerPath . '/add') . '</li>'; ?>
|
||||
</ul></div>
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<?php echo "<li>".$html->link(__('New ', true).Inflector::humanize($associationName), array('controller'=> $otherControllerPath, 'action'=>'add')) . '</li>'; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<?php }?>
|
Loading…
Add table
Reference in a new issue