Development

Changeset 10048

You must first sign up to be able to contribute.

Changeset 10048

Show
Ignore:
Timestamp:
07/01/08 21:07:16 (5 months ago)
Author:
pmacadden
Message:

new feature: _has_many_CLASS_PLURAL, creates a link to a many part of the relationship, created with foreign_class: key.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfAdvancedAdminGeneratorPlugin/branches/pmacadden/data/generator/sfAdvancedAdmin/default/template/actions/actions.class.php

    r10032 r10048  
    7171    $this->pager->init(); 
    7272<?php if ($fc = $this->getParameterValue('foreign_class', '')): ?> 
    73     $this-><?php echo $this->getSingularName() ?> = $this->get<?php echo $this->getClassName() ?>OrCreate(); 
     73    $this-><?php echo $this->getSingularName() ?> = new <?php echo $this->getClassName() ?>(); 
    7474    $this-><?php echo $this->getSingularName() ?>->set<?php echo sfInflector::camelize($fc) ?>($this->foreign_class); 
    7575<?php endif ?> 
     
    8989<?php if (null === $this->getParameterValue('create')): ?> 
    9090    return $this->forward('<?php echo $this->getModuleName() ?>', 'edit'); 
    91 <?php else: ?>     
     91<?php else: ?> 
    9292    $this-><?php echo $this->getSingularName() ?> = new <?php echo $this->getClassName() ?>(); 
    9393<?php if ($fc = $this->getParameterValue('foreign_class', '')): ?> 
     
    461461<?php if (!$multisort) :?> 
    462462      $this->getUser()->getAttributeHolder()->removeNamespace('sf_admin/<?php echo $this->getSingularName() ?>/sort'); 
    463 <?php endif; ?>       
     463<?php endif; ?> 
    464464 
    465465      $this->getUser()->setAttribute($sort, $type, 'sf_admin/<?php echo $this->getSingularName() ?>/sort'); 
     
    634634    return <?php var_export($this->getParameterValue('maps'))?>; 
    635635  } 
     636 
     637<?php if ($object_actions = $this->getParameterValue('list.object_actions')): ?> 
     638<?php foreach ($object_actions as $key => $value): ?> 
     639<?php if (substr($key, 0, 10) == '_has_many_'): ?> 
     640  public function executeList<?php echo sfInflector::camelize($has_many = substr($key, 10, -1)) ?>s() 
     641  { 
     642    $this->getUser()->setAttribute('<?php echo sfInflector::underscore($this->getClassName()) ?>', $this->get<?php echo $this->getClassName() ?>OrCreate()); 
     643    $this->forward('<?php echo strtolower($has_many) ?>', 'index'); 
     644  } 
     645 
     646<?php endif ?> 
     647<?php endforeach ?> 
     648<?php endif ?> 
    636649} 
  • plugins/sfAdvancedAdminGeneratorPlugin/branches/pmacadden/data/generator/sfAdvancedAdmin/default/template/templates/_list_td_actions.php

    r9939 r10048  
    44<?php foreach ($this->getParameterValue('list.object_actions') as $actionName => $params): ?> 
    55<?php if (isset($params['condition'])): ?> 
     6<?php if (substr($actionName, 0, 10) == '_has_many_'): ?> 
     7  [?php if ($<?php echo $this->getSingularName() ?>-><?php echo sfInflector::camelize($params['condition']) ?>()):  ?] 
     8    <?php echo $this->addCredentialCondition($this->getHasManyLinkTo(sfInflector::camelize(substr($actionName, 10)), $params, true), $params) ?> 
     9  [?php endif ?] 
     10<?php else: ?> 
    611  [?php if ($<?php echo $this->getSingularName() ?>-><?php echo sfInflector::camelize($params['condition']) ?>()):  ?] 
    712    <?php echo $this->addCredentialCondition($this->getLinkToAction($actionName, $params, true), $params) ?> 
    813  [?php endif ?] 
     14<?php endif ?> 
     15<?php else: ?> 
     16<?php if (substr($actionName, 0, 10) == '_has_many_'): ?> 
     17  <?php echo $this->addCredentialCondition($this->getHasManyLinkTo(sfInflector::camelize(substr($actionName, 10)), $params, true), $params) ?> 
    918<?php else: ?> 
    1019  <?php echo $this->addCredentialCondition($this->getLinkToAction($actionName, $params, true), $params) ?> 
     20<?php endif ?> 
    1121<?php endif ?> 
    1222<?php endforeach; ?> 
  • plugins/sfAdvancedAdminGeneratorPlugin/branches/pmacadden/lib/sfAdvancedAdminGenerator.class.php

    r10032 r10048  
    11<?php 
    22 
    3 /* 
    4  * This file is part of the symfony package. 
    5  * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 
    6  * 
    7  * For the full copyright and license information, please view the LICENSE 
    8  * file that was distributed with this source code. 
    9  */ 
    10  
    113/** 
    12  * Propel Admin generator. 
     4 * sfAdvancedAdmin generator. 
    135 * 
    146 * This class generates an admin module with propel. 
     
    168 * @package    symfony 
    179 * @subpackage generator 
    18  * @author     Fabien Potencier <fabien.potencier@symfony-project.com
    19  * @version    SVN: $Id: sfPropelAdminGenerator.class.php 3302 2007-01-18 13:42:46Z fabien $ 
     10 * @author     Patricio Mac Adden <pmacadden@desarrollo.cespi.unlp.edu.ar
     11 * @version    SVN 
    2012 */ 
    2113 
     
    119111    if ($actionName === '_show') { 
    120112      return preg_replace('/\/show_icon.png/', '/filter.png', $ret); 
    121     } 
    122     else { 
     113    } else { 
    123114      return $ret; 
    124115    } 
     116  } 
     117 
     118  public function getHasManyLinkTo($actionName, $params, $pk_link = false) 
     119  { 
     120    if (!isset($params['action'])) 
     121      $params['action'] = 'list'.sfInflector::camelize($actionName); 
     122    /* 
     123    if (!isset($params['icon'])) 
     124      $params['icon'] = sfConfig::get('sf_web_dir').'/sfAdvancedAdminGeneratorPlugin/images/has_many_icon.png'; 
     125    */ 
     126    $html = $this->getLinkToAction(sfInflector::camelize($actionName), $params, $pk_link); 
     127    return preg_replace('/\/default_icon.png/', '/list.png', $html); 
    125128  } 
    126129