Browse Source

Merging fixes and enhancements into trunk.

Revision: [2448]
removing tabs in last commit

Revision: [2447]
Adding fix for limit in all associations

Revision: [2446]
Added fix for Ticket #569

Revision: [2443]
Adding fix for Ticket #592.

Revision: [2437]
Adding fix for Model::findNeighbours().
Was returning all associations and fields. Now recursive is set to 0 and only returns the prev and next keys array

Example $this->Category->findNeighbours(null, 'Category.id', 4);

Will return,

Array
(
    [prev] => Array
        (
            [Category] => Array
                (
                    [id] => 3
                )

        )

    [next] => Array
        (
            [Category] => Array
                (
                    [id] => 5
                )

        )

)

Revision: [2432]
Removed the DS constant from the plugin var when it is set in Dispatcher.
Added "$this->plugin.DS." constant in files where needed after change above.
Added fix for Ticket #577.

Revision: [2428]
Added fix for HtmlHelper::checkbox() it ignored the value provided as a parameter
Fix for Ticket #605.
Fix for Ticket #607.


git-svn-id: https://svn.cakephp.org/repo/trunk/cake@2449 3807eeeb-6ff5-0310-8944-8be069107fe0
phpnut 20 years ago
parent
commit
c899c085f5

+ 1 - 1
VERSION.txt

@@ -6,4 +6,4 @@
 // +---------------------------------------------------------------------------------------------------+ //
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-1.0.0.2427
+1.0.0.2449

+ 1 - 1
cake/dispatcher.php

@@ -128,7 +128,7 @@ class Dispatcher extends Object
                      $oldAction = $params['action'];
                      $params = $this->_restructureParams($params);
                      $plugin = Inflector::underscore($ctrlName);
-                     $this->plugin = $plugin.DS;
+                     $this->plugin = $plugin;
                      loadPluginModels($plugin);
                      $this->base = $this->base.'/'.Inflector::underscore($ctrlName);
                      if(empty($params['controller']) || !class_exists($pluginClass))

+ 2 - 2
cake/libs/controller/component.php

@@ -91,9 +91,9 @@ class Component extends Object
             {
                 $componentFn = Inflector::underscore($component).'.php';
 
-                if(file_exists(APP.'plugins'.DS.$this->controller->plugin.'controllers'.DS.'components'.DS.$componentFn))
+                if(file_exists(APP.'plugins'.DS.$this->controller->plugin.DS.'controllers'.DS.'components'.DS.$componentFn))
                 {
-                    $componentFn = APP.'plugins'.DS.$this->controller->plugin.'controllers'.DS.'components'.DS.$componentFn;
+                    $componentFn = APP.'plugins'.DS.$this->controller->plugin.DS.'controllers'.DS.'components'.DS.$componentFn;
                 }
                 else if(file_exists(COMPONENTS.$componentFn))
                 {

+ 6 - 0
cake/libs/controller/controller.php

@@ -286,10 +286,13 @@ class Controller extends Object
                 if($this->persistModel === true)
                 {
                     $this->_persist($this->modelClass, true,  $model);
+                    $registry = ClassRegistry::getInstance();
+                    $this->_persist($this->modelClass.'registry', true,  $registry->_objects, 'registry');
                 }
             }
             else
             {
+                $this->_persist($this->modelClass.'registry', true, $object, 'registry');
                 $this->_persist($this->modelClass, true, $object);
                 $this->modelNames[] = $this->modelClass;
                 return true;
@@ -324,10 +327,13 @@ class Controller extends Object
                         if($this->persistModel === true)
                         {
                             $this->_persist($modelClass, true,  $model);
+                            $registry = ClassRegistry::getInstance();
+                            $this->_persist($modelClass.'registry', true,  $registry->_objects, 'registry');
                         }
                     }
                     else
                     {
+                        $this->_persist($modelClass.'registry', true, $object, 'registry');
                         $this->_persist($modelClass, true, $object);
                         $this->modelNames[] = $modelClass;
                         return true;

+ 22 - 2
cake/libs/model/datasources/dbo_source.php

@@ -359,6 +359,8 @@ class DboSource extends DataSource
  */
     function create(&$model, $fields = null, $values = null)
     {
+        $fieldInsert = array();
+        $valueInsert = array();
         if ($fields == null)
         {
             unset($fields, $values);
@@ -374,7 +376,15 @@ class DboSource extends DataSource
         $count = 0;
         foreach ($values as $value)
         {
-        	$valueInsert[] = $this->value($value, $model->getColumnType($fields[$count]));
+            $set = $this->value($value, $model->getColumnType($fields[$count]));
+            if($set === "''")
+            {
+                unset($fieldInsert[$count]);
+            }
+            else
+            {
+                $valueInsert[] = $set;
+            }
             $count++;
         }
 
@@ -852,6 +862,12 @@ class DboSource extends DataSource
                     }
                     $sql .= $this->conditions($conditions);
                     $sql .= $this->order($assocData['order']);
+
+                    if (isset($assocData['limit']))
+                    {
+                        $sql .= $this->limit($assocData['limit']);
+                    }
+
                 }
                 return $sql;
             break;
@@ -873,6 +889,10 @@ class DboSource extends DataSource
 
                     $sql .= $this->conditions($assocData['conditions']);
                     $sql .= $this->order($assocData['order']);
+                    if (isset($assocData['limit']))
+                    {
+                        $sql .= $this->limit($assocData['limit']);
+                    }
                 }
                 return $sql;
             break;
@@ -1324,4 +1344,4 @@ class DboSource extends DataSource
         }
     }
 }
-?>
+?>

+ 7 - 5
cake/libs/model/model_php4.php

@@ -1367,8 +1367,8 @@ class Model extends Object
         {
             $conditions = $conditions.' AND ';
         }
-        @list($prev) = Model::findAll($conditions. $field . ' < ' . $db->value($value), $field, $field . ' DESC', 1);
-        @list($next) = Model::findAll($conditions. $field . ' > ' . $db->value($value), $field, $field . ' ASC', 1);
+        @list($prev) = Model::findAll($conditions. $field . ' < ' . $db->value($value), $field, $field . ' DESC', 1, null, 0);
+        @list($next) = Model::findAll($conditions. $field . ' > ' . $db->value($value), $field, $field . ' ASC', 1, null, 0);
 
         if (!isset($prev))
         {
@@ -1489,10 +1489,10 @@ class Model extends Object
     }
 
 /**
- * Returns a resultset array with specified fields from database matching given conditions. Method can be used to generate option lists for SELECT elements.
+ * Returns a resultset array with specified fields from database matching given conditions.
+ * Method can be used to generate option lists for SELECT elements.
  *
  * @param mixed $conditions SQL conditions as a string or as an array('field'=>'value',...)
- * @param mixed $fields Either a single string of a field name, or an array of field names
  * @param string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC")
  * @param int $limit SQL LIMIT clause, for calculating items per page
  * @param string $keyPath A string path to the key, i.e. "{n}.Post.id"
@@ -1505,7 +1505,9 @@ class Model extends Object
         if ($keyPath == null && $valuePath == null)
         {
             $fields = array($this->primaryKey, $this->displayField);
-        } else {
+        }
+        else
+        {
             $fields = '*';
         }
         $result = $this->findAll($conditions, $fields, $order, $limit, 1, 0);

+ 5 - 4
cake/libs/model/model_php5.php

@@ -1363,8 +1363,8 @@ class Model extends Object
         {
             $conditions = $conditions.' AND ';
         }
-        @list($prev) = Model::findAll($conditions. $field . ' < ' . $db->value($value), $field, $field . ' DESC', 1);
-        @list($next) = Model::findAll($conditions. $field . ' > ' . $db->value($value), $field, $field . ' ASC', 1);
+        @list($prev) = Model::findAll($conditions. $field . ' < ' . $db->value($value), $field, $field . ' DESC', 1, null, 0);
+        @list($next) = Model::findAll($conditions. $field . ' > ' . $db->value($value), $field, $field . ' ASC', 1, null, 0);
 
         if (!isset($prev))
         {
@@ -1488,7 +1488,6 @@ class Model extends Object
  * Returns a resultset array with specified fields from database matching given conditions. Method can be used to generate option lists for SELECT elements.
  *
  * @param mixed $conditions SQL conditions as a string or as an array('field'=>'value',...)
- * @param mixed $fields Either a single string of a field name, or an array of field names
  * @param string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC")
  * @param int $limit SQL LIMIT clause, for calculating items per page
  * @param string $keyPath A string path to the key, i.e. "{n}.Post.id"
@@ -1501,7 +1500,9 @@ class Model extends Object
         if ($keyPath == null && $valuePath == null)
         {
             $fields = array($this->primaryKey, $this->displayField);
-        } else {
+        }
+        else
+        {
             $fields = '*';
         }
         $result = $this->findAll($conditions, $fields, $order, $limit, 1, 0);

+ 19 - 5
cake/libs/object.php

@@ -185,7 +185,7 @@ class Object
  * @access public
  * @todo add examples to manual
  */
-    function _persist($name, $return = null, &$object)
+    function _persist($name, $return = null, &$object, $type = null)
     {
         $file = CACHE.'persistent'.DS.strtolower($name).'.php';
 
@@ -208,7 +208,7 @@ class Object
         }
         else
         {
-            $this->__openPersistent($name);
+            $this->__openPersistent($name, $type);
             return true;
         }
     }
@@ -238,12 +238,26 @@ class Object
  * @param string $name name of the class
  * @access private
  */
-    function __openPersistent($name)
+    function __openPersistent($name, $type = null)
     {
         $file = CACHE.'persistent'.DS.strtolower($name).'.php';
         include($file);
-        $vars = unserialize(${$name});
-        $this->{$name} = $vars['0'];
+        switch ($type)
+        {
+            case 'registry':
+                $vars = unserialize(${$name});
+                foreach ($vars['0'] as $key => $value)
+                {
+                    ClassRegistry::addObject($key, $value);
+                    unset($value);
+                }
+            break;
+            default:
+                $vars = unserialize(${$name});
+                $this->{$name} = $vars['0'];
+            break;
+
+        }
     }
 }
 

+ 11 - 4
cake/libs/view/helpers/cache.php

@@ -216,13 +216,20 @@ class CacheHelper extends Helper
             $cacheTime = $now + strtotime($timestamp);
         }
         $cache = convertSlash($this->here).'.php';
+
         $file = '<!--cachetime:'.$cacheTime.'-->
                  <?php
-                    loadController(\''.$this->view->name.'\');
-                    $this->controller = new '.$this->view->name.'Controller();
-                    $this->helpers = unserialize(\''. serialize($this->view->helpers).'\');
+                    loadController(\''. $this->view->name .'\');
+                    $this->controller = new '. $this->view->name .'Controller();
+                    $this->helpers = unserialize(\''. serialize($this->view->helpers) .'\');
+                    $this->base =  \''. $this->view->base .'\';
                     $this->webroot = \''. $this->view->webroot.'\';
-                    $this->data  = unserialize(\''. serialize($this->view->data).'\');
+                    $this->here = \''. $this->view->here .'\';
+                    $this->params = unserialize(\''. serialize($this->view->params) .'\');
+                    $this->action = unserialize(\''. serialize($this->view->action) .'\');
+                    $this->data  = unserialize(\''. serialize($this->view->data) .'\');
+                    $this->themeWeb = \''. $this->view->themeWeb .'\';
+                    $this->plugin = \''. $this->view->plugin .'\';
                     $loadedHelpers =  array();
                     $loadedHelpers = $this->_loadHelpers($loadedHelpers, $this->helpers);
                     foreach(array_keys($loadedHelpers) as $helper)

+ 16 - 5
cake/libs/view/helpers/html.php

@@ -154,8 +154,7 @@ function url($url = null, $return = false)
         $base = $this->base;
         if($this->plugin != null)
         {
-            $match = str_replace(DS, '', $this->plugin);
-			$base = preg_replace('/'.$match.'/', '', $this->base);
+			$base = preg_replace('/'.$this->plugin.'/', '', $this->base);
 			$base = str_replace('//','', $base);
             $pos1 = strrpos($base, '/');
             $char = strlen($base) -1;
@@ -329,13 +328,25 @@ function url($url = null, $return = false)
  */
     function checkbox($fieldName, $title = null, $htmlAttributes = null, $return = false)
     {
-        $this->setFormTag($fieldName);
         $value = $this->tagValue($fieldName);
         $model = new $this->model;
         $db =& ConnectionManager::getDataSource($model->useDbConfig);
         $value = $db->boolean($value);
-        $value? $htmlAttributes['checked'] = 'checked': null;
-        $htmlAttributes['value'] = 1;
+
+        if($value === true || $value === 't')
+        {
+            $htmlAttributes['checked'] = 'checked';
+        }
+        else
+        {
+            $htmlAttributes['checked'] = null;
+        }
+
+        if(!isset($htmlAttributes['value']))
+        {
+            $htmlAttributes['value'] = 1;
+        }
+
         $output = $this->hidden($fieldName, array('value' => 0), true);
         $output .= sprintf($this->tags['checkbox'], $this->model, $this->field,
                 $this->_parseAttributes($htmlAttributes, null, '', ' '));

+ 13 - 5
cake/libs/view/templates/scaffolds/edit.thtml

@@ -28,6 +28,14 @@
 
 $modelName = ucwords(Inflector::singularize($this->name));
 $modelKey = $modelName;
+if(is_null($this->plugin))
+{
+    $path = '/';
+}
+else
+{
+    $path =  '/'.$this->plugin.'/';
+}
 
 ?>
 <h1><?php echo $type.' '.Inflector::humanize($modelName);?></h1>
@@ -35,11 +43,11 @@ $modelKey = $modelName;
 <?php
 if($type == 'Edit')
 {
-    echo $html->formTag('/'. Inflector::underscore($this->name) .'/update');
+    echo $html->formTag($path . Inflector::underscore($this->name) .'/update');
 }
 else
 {
-    echo $html->formTag('/'. Inflector::underscore($this->name).'/create');
+    echo $html->formTag($path. Inflector::underscore($this->name).'/create');
 }
 echo $form->generateFields( $fieldNames );
 echo $form->generateSubmitDiv( 'Save' )
@@ -49,16 +57,16 @@ echo $form->generateSubmitDiv( 'Save' )
 <?php
 if($type == 'Edit')
 {
-    echo "<li>".$html->link('Delete  '.Inflector::humanize($modelName), '/'.$this->viewPath.'/delete/'.$data[$modelKey][$this->controller->{$modelName}->primaryKey])."</li>";
+    echo "<li>".$html->link('Delete  '.Inflector::humanize($modelName), $path.$this->viewPath.'/delete/'.$data[$modelKey][$this->controller->{$modelName}->primaryKey])."</li>";
 }
-echo "<li>".$html->link('List  '.Inflector::humanize($modelName), '/'.$this->viewPath.'/index')."</li>";
+echo "<li>".$html->link('List  '.Inflector::humanize($modelName), $path.$this->viewPath.'/index')."</li>";
 if($type == 'Edit')
 {
     foreach($fieldNames as $field => $value)
     {
         if(isset($value['foreignKey']))
         {
-            echo "<li>".$html->link( "View ".Inflector::humanize($value['controller']), "/".Inflector::underscore($value['controller'])."/show/".$data[$modelKey][$field] )."</li>";
+            echo "<li>".$html->link( "View ".Inflector::humanize($value['controller']), $path.Inflector::underscore($value['controller'])."/show/".$data[$modelKey][$field] )."</li>";
         }
     }
 }

+ 13 - 5
cake/libs/view/templates/scaffolds/list.thtml

@@ -33,6 +33,14 @@ $model = ucwords(Inflector::singularize($this->name));
 $modelKey = $model;
 $humanName = Inflector::humanize($this->name);
 $humanSingularName = Inflector::singularize( $humanName );
+if(is_null($this->plugin))
+{
+    $path = '/';
+}
+else
+{
+    $path =  '/'.$this->plugin.'/';
+}
 if(!empty($this->controller->{$model}->alias))
 {
     foreach ($this->controller->{$model}->alias as $key => $value)
@@ -87,7 +95,7 @@ if(is_array($data))
                 {
                     $displayText = $row[$alias[$count]][$field];
                 }
-                echo $html->link( $displayText, "/".Inflector::underscore($otherControllerName)."/show/".$row[$modelKey][$field] );
+                echo $html->link( $displayText, $path.Inflector::underscore($otherControllerName)."/show/".$row[$modelKey][$field] );
                 $count++;
             }
             else
@@ -99,9 +107,9 @@ if(is_array($data))
 <?php
         }
 ?>
-        <td class="listactions"><?php echo $html->link('View',"/".$this->viewPath."/show/{$row[$modelKey][$this->controller->{$model}->primaryKey]}/")?>
-                                <?php echo $html->link('Edit',"/".$this->viewPath."/edit/{$row[$modelKey][$this->controller->{$model}->primaryKey]}/")?>
-                                <?php echo $html->link('Delete',"/".$this->viewPath."/delete/{$row[$modelKey][$this->controller->{$model}->primaryKey]}/")?>
+        <td class="listactions"><?php echo $html->link('View',$path.$this->viewPath."/show/{$row[$modelKey][$this->controller->{$model}->primaryKey]}/")?>
+                                <?php echo $html->link('Edit',$path.$this->viewPath."/edit/{$row[$modelKey][$this->controller->{$model}->primaryKey]}/")?>
+                                <?php echo $html->link('Delete',$path.$this->viewPath."/delete/{$row[$modelKey][$this->controller->{$model}->primaryKey]}/")?>
         </td>
         </tr>
 <?php
@@ -110,5 +118,5 @@ if(is_array($data))
 ?>
 </table>
 <ul class="actions">
-    <li><?php echo $html->link('New '.$humanSingularName, '/'.$this->viewPath.'/add'); ?></li>
+    <li><?php echo $html->link('New '.$humanSingularName, $path.$this->viewPath.'/add'); ?></li>
 </ul>

+ 10 - 2
cake/libs/view/templates/scaffolds/new.thtml

@@ -29,13 +29,21 @@
 <h1>New <?php echo Inflector::humanize($this->name)?></h1>
 
 <?php
-echo $html->formTag('/'. Inflector::underscore($this->name).'/create');
+if(is_null($this->plugin))
+{
+    $path = '/';
+}
+else
+{
+    $path =  '/'.$this->plugin.'/';
+}
+echo $html->formTag($path. Inflector::underscore($this->name).'/create');
 echo $form->generateFields( $fieldNames );
 echo $form->generateSubmitDiv( 'Add' )
 ?>
 </form>
 <ul class='actions'>
 <?php
-echo "<li>".$html->link('List  '.Inflector::humanize($this->name), '/'.$this->viewPath.'/index')."</li>";
+echo "<li>".$html->link('List  '.Inflector::humanize($this->name), $path.$this->viewPath.'/index')."</li>";
 ?>
 </ul>

+ 23 - 15
cake/libs/view/templates/scaffolds/show.thtml

@@ -31,6 +31,14 @@
 $modelName = ucwords(Inflector::singularize($this->name));
 $modelKey = Inflector::underscore($modelName);
 $objModel =& ClassRegistry::getObject($modelKey);
+if(is_null($this->plugin))
+{
+    $path = '/';
+}
+else
+{
+    $path =  '/'.$this->plugin.'/';
+}
 if(!empty($objModel->alias))
 {
     foreach ($objModel->alias as $key => $value)
@@ -57,7 +65,7 @@ foreach($fieldNames as $field => $value)
 
         if(!empty($data[$objModel->tableToModel[$objModel->table]][$field]) && (isset($displayText)))
         {
-            echo "<dd>".$html->link($displayText, '/'.Inflector::underscore($value['controller']).'/show/'
+            echo "<dd>".$html->link($displayText, $path.Inflector::underscore($value['controller']).'/show/'
                         .$data[$objModel->tableToModel[$objModel->table]][$field] )."</dd>";
         }
         else
@@ -83,16 +91,16 @@ foreach($fieldNames as $field => $value)
 </dl>
 <ul class='actions'>
 <?php
-echo "<li>".$html->link('Edit '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/edit/'.$data[$objModel->tableToModel[$objModel->table]][$this->controller->{$modelName}->primaryKey])."</li>";
-echo "<li>".$html->link('Delete  '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/delete/'.$data[$objModel->tableToModel[$objModel->table]][$this->controller->{$modelName}->primaryKey])."</li>";
-echo "<li>".$html->link('List  '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/index')."</li>";
-echo "<li>".$html->link('New  '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/add')."</li>";
+echo "<li>".$html->link('Edit '.Inflector::humanize($objModel->name), $path.$this->viewPath.'/edit/'.$data[$objModel->tableToModel[$objModel->table]][$this->controller->{$modelName}->primaryKey])."</li>";
+echo "<li>".$html->link('Delete  '.Inflector::humanize($objModel->name), $path.$this->viewPath.'/delete/'.$data[$objModel->tableToModel[$objModel->table]][$this->controller->{$modelName}->primaryKey])."</li>";
+echo "<li>".$html->link('List  '.Inflector::humanize($objModel->name), $path.$this->viewPath.'/index')."</li>";
+echo "<li>".$html->link('New  '.Inflector::humanize($objModel->name), $path.$this->viewPath.'/add')."</li>";
 
 foreach( $fieldNames as $field => $value )
 {
     if( isset( $value['foreignKey'] ) )
     {
-        echo "<li>".$html->link( "List ".Inflector::humanize($value['controller']), "/".Inflector::underscore($value['controller'])."/index/")."</li>";
+        echo "<li>".$html->link( "List ".Inflector::humanize($value['controller']), $path.Inflector::underscore($value['controller'])."/index/")."</li>";
     }
 }
 ?>
@@ -129,11 +137,11 @@ foreach ($objModel->hasOne as $association => $relation)
         echo "</dl>";
         if($new == null)
         {
-            echo "<ul class='actions'><li>".$html->link('Edit '.Inflector::humanize($association),"/".Inflector::underscore($controller)."/edit/{$data[$association][$objModel->{$model}->primaryKey]}")."</li></ul></div>";
+            echo "<ul class='actions'><li>".$html->link('Edit '.Inflector::humanize($association),$path.Inflector::underscore($controller)."/edit/{$data[$association][$objModel->{$model}->primaryKey]}")."</li></ul></div>";
         }
         else
         {
-            echo "<ul class='actions'><li>".$html->link('New '.Inflector::humanize($association),"/".Inflector::underscore($controller)."/add/{$data[$association][$objModel->{$model}->primaryKey]}")."</li></ul></div>";
+            echo "<ul class='actions'><li>".$html->link('New '.Inflector::humanize($association),$path.Inflector::underscore($controller)."/add/{$data[$association][$objModel->{$model}->primaryKey]}")."</li></ul></div>";
         }
     }
 }
@@ -175,11 +183,11 @@ foreach($relations as $association => $relation)
             if (isset($this->controller->{$modelName}->{$association}))
             {
 ?>
-                <td class="listactions"><?php echo $html->link('View',"/".Inflector::underscore($controller).
+                <td class="listactions"><?php echo $html->link('View',$path.Inflector::underscore($controller).
                                                                 "/show/{$row[$this->controller->{$modelName}->{$association}->primaryKey]}/")?>
-                                        <?php echo $html->link('Edit',"/".Inflector::underscore($controller).
+                                        <?php echo $html->link('Edit',$path.Inflector::underscore($controller).
                                                                 "/edit/{$row[$this->controller->{$modelName}->{$association}->primaryKey]}/")?>
-                                        <?php echo $html->link('Delete',"/".Inflector::underscore($controller).
+                                        <?php echo $html->link('Delete',$path.Inflector::underscore($controller).
                                                                 "/delete/{$row[$this->controller->{$modelName}->{$association}->primaryKey]}/")?>
                 </td>
 <?php
@@ -187,11 +195,11 @@ foreach($relations as $association => $relation)
             else
             {
 ?>
-                <td class="listactions"><?php echo $html->link('View',"/".Inflector::underscore($controller).
+                <td class="listactions"><?php echo $html->link('View',$path.Inflector::underscore($controller).
                                                                 "/show/{$row[$this->controller->{$modelName}->primaryKey]}/")?>
-                                        <?php echo $html->link('Edit',"/".Inflector::underscore($controller).
+                                        <?php echo $html->link('Edit',$path.Inflector::underscore($controller).
                                                                 "/edit/{$row[$this->controller->{$modelName}->primaryKey]}/")?>
-                                        <?php echo $html->link('Delete',"/".Inflector::underscore($controller).
+                                        <?php echo $html->link('Delete',$path.Inflector::underscore($controller).
                                                                 "/delete/{$row[$this->controller->{$modelName}->primaryKey]}/")?>
                 </td>
 <?php
@@ -203,7 +211,7 @@ foreach($relations as $association => $relation)
 </table>
 <ul class="actions">
 <?php
-    echo "<li>".$html->link('New '.Inflector::humanize($association),"/".Inflector::underscore($controller)."/add/")."</li>";
+    echo "<li>".$html->link('New '.Inflector::humanize($association),$path.Inflector::underscore($controller)."/add/")."</li>";
 ?>
 </ul></div>
 <?php

+ 7 - 7
cake/libs/view/view.php

@@ -398,9 +398,9 @@ class View extends Object
 
       if(!is_null($this->plugin))
       {
-          if(file_exists(APP.'plugins'.DS.$this->plugin.'views'.DS.'elements'.DS.$name.$this->ext))
+          if(file_exists(APP.'plugins'.DS.$this->plugin.DS.'views'.DS.'elements'.DS.$name.$this->ext))
           {
-                $fn =  APP.'plugins'.DS.$this->plugin.'views'.DS.'elements'.DS.$name.$this->ext;
+                $fn =  APP.'plugins'.DS.$this->plugin.DS.'views'.DS.'elements'.DS.$name.$this->ext;
                 $params = array_merge_recursive($params, $this->loaded);
                 return $this->_render($fn, array_merge($this->_viewVars, $params), false);
             }
@@ -590,9 +590,9 @@ class View extends Object
 
         if(isset($this->plugin) && !is_null($this->plugin))
         {
-            if(file_exists(APP.'plugins'.DS.$this->plugin.'views'.DS.'layouts'.DS.$this->layout.$this->ext))
+            if(file_exists(APP.'plugins'.DS.$this->plugin.DS.'views'.DS.'layouts'.DS.$this->layout.$this->ext))
             {
-                $layoutFileName =  APP.'plugins'.DS.$this->plugin.'views'.DS.'layouts'.DS.$this->layout.$this->ext;
+                $layoutFileName =  APP.'plugins'.DS.$this->plugin.DS.'views'.DS.'layouts'.DS.$this->layout.$this->ext;
                 return $layoutFileName;
             }
         }
@@ -709,9 +709,9 @@ class View extends Object
                 {
                     $helperFn = Inflector::underscore($helper).'.php';
 
-                    if(file_exists(APP.'plugins'.DS.$this->plugin.'views'.DS.'helpers'.DS.$helperFn))
+                    if(file_exists(APP.'plugins'.DS.$this->plugin.DS.'views'.DS.'helpers'.DS.$helperFn))
                     {
-                        $helperFn = APP.'plugins'.DS.$this->plugin.'views'.DS.'helpers'.DS.$helperFn;
+                        $helperFn = APP.'plugins'.DS.$this->plugin.DS.'views'.DS.'helpers'.DS.$helperFn;
                     }
                     else if(file_exists(HELPERS.$helperFn))
                     {
@@ -779,7 +779,7 @@ class View extends Object
  */
     function pluginView($action, $layout)
     {
-        $viewFileName = APP.'plugins'.DS.$this->plugin.'views'.DS.$this->viewPath.DS.$action.$this->ext;
+        $viewFileName = APP.'plugins'.DS.$this->plugin.DS.'views'.DS.$this->viewPath.DS.$action.$this->ext;
         if(file_exists($viewFileName))
         {
             $this->render($action, $layout, $viewFileName);