Development

Changeset 12431

You must first sign up to be able to contribute.

Changeset 12431

Show
Ignore:
Timestamp:
10/30/08 11:16:51 (6 years ago)
Author:
fabien
Message:

[new_admin] added the new admin gen (not finished yet, WIP)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfPropelPlugin/branches/new_admin/data/generator/sfPropelCrud/default/parts/createAction.php

    r11475 r12431  
    66 
    77<?php endif; ?> 
    8     $this->form = new <?php echo $this->getFormClassName() ?>(); 
     8    $this->form = new <?php echo $this->getModelClass().'Form' ?>(); 
    99 
    1010    $this->processForm($request, $this->form); 
  • plugins/sfPropelPlugin/branches/new_admin/data/generator/sfPropelCrud/default/parts/deleteAction.php

    r11795 r12431  
    44    $this->getRoute()->getObject()->delete(); 
    55<?php else: ?> 
    6     $this->forward404Unless($<?php echo $this->getSingularName() ?> = <?php echo $this->getPeerClassName() ?>::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForAction(43, '$request->getParameter') ?>), sprintf('Object <?php echo $this->getSingularName() ?> does not exist (%s).', <?php echo $this->getRetrieveByPkParamsForAction(43, '$request->getParameter') ?>)); 
     6    $this->forward404Unless($<?php echo $this->getSingularName() ?> = <?php echo constant($this->getModelClass().'::PEER') ?>::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForAction(43) ?>), sprintf('Object <?php echo $this->getSingularName() ?> does not exist (%s).', <?php echo $this->getRetrieveByPkParamsForAction(43) ?>)); 
    77    $<?php echo $this->getSingularName() ?>->delete(); 
    88<?php endif; ?> 
  • plugins/sfPropelPlugin/branches/new_admin/data/generator/sfPropelCrud/default/parts/editAction.php

    r11795 r12431  
    22  { 
    33<?php if (isset($this->params['with_propel_route']) && $this->params['with_propel_route']): ?> 
    4     $this->form = new <?php echo $this->getFormClassName() ?>($this->getRoute()->getObject()); 
     4    $this->form = new <?php echo $this->getModelClass().'Form' ?>($this->getRoute()->getObject()); 
    55<?php else: ?> 
    6     $this->forward404Unless($<?php echo $this->getSingularName() ?> = <?php echo $this->getPeerClassName() ?>::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForAction(43, '$request->getParameter') ?>), sprintf('Object <?php echo $this->getSingularName() ?> does not exist (%s).', <?php echo $this->getRetrieveByPkParamsForAction(43, '$request->getParameter') ?>)); 
    7     $this->form = new <?php echo $this->getFormClassName() ?>($<?php echo $this->getSingularName() ?>); 
     6    $this->forward404Unless($<?php echo $this->getSingularName() ?> = <?php echo constant($this->getModelClass().'::PEER') ?>::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForAction(43) ?>), sprintf('Object <?php echo $this->getSingularName() ?> does not exist (%s).', <?php echo $this->getRetrieveByPkParamsForAction(43) ?>)); 
     7    $this->form = new <?php echo $this->getModelClass().'Form' ?>($<?php echo $this->getSingularName() ?>); 
    88<?php endif; ?> 
    99  } 
  • plugins/sfPropelPlugin/branches/new_admin/data/generator/sfPropelCrud/default/parts/indexAction.php

    r11795 r12431  
    44    $this-><?php echo $this->getPluralName() ?> = $this->getRoute()->getObjects(); 
    55<?php else: ?> 
    6     $this-><?php echo $this->getPluralName() ?> = <?php echo $this->getPeerClassName() ?>::doSelect(new Criteria()); 
     6    $this-><?php echo $this->getPluralName() ?> = <?php echo constant($this->getModelClass().'::PEER') ?>::doSelect(new Criteria()); 
    77<?php endif; ?> 
    88  } 
  • plugins/sfPropelPlugin/branches/new_admin/data/generator/sfPropelCrud/default/parts/newAction.php

    r11475 r12431  
    11  public function executeNew($request) 
    22  { 
    3     $this->form = new <?php echo $this->getFormClassName() ?>(); 
     3    $this->form = new <?php echo $this->getModelClass().'Form' ?>(); 
    44  } 
  • plugins/sfPropelPlugin/branches/new_admin/data/generator/sfPropelCrud/default/parts/showAction.php

    r11795 r12431  
    44    $this-><?php echo $this->getSingularName() ?> = $this->getRoute()->getObject(); 
    55<?php else: ?> 
    6     $this-><?php echo $this->getSingularName() ?> = <?php echo $this->getPeerClassName() ?>::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForAction(49, '$request->getParameter') ?>); 
     6    $this-><?php echo $this->getSingularName() ?> = <?php echo constant($this->getModelClass().'::PEER') ?>::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForAction(49) ?>); 
    77    $this->forward404Unless($this-><?php echo $this->getSingularName() ?>); 
    88<?php endif; ?> 
  • plugins/sfPropelPlugin/branches/new_admin/data/generator/sfPropelCrud/default/parts/updateAction.php

    r11795 r12431  
    22  { 
    33<?php if (isset($this->params['with_propel_route']) && $this->params['with_propel_route']): ?> 
    4     $this->form = new <?php echo $this->getFormClassName() ?>($this->getRoute()->getObject()); 
     4    $this->form = new <?php echo $this->getModelClass().'Form' ?>($this->getRoute()->getObject()); 
    55<?php else: ?> 
    66    $this->forward404Unless($request->isMethod('post') || $request->isMethod('put')); 
    7     $this->forward404Unless($<?php echo $this->getSingularName() ?> = <?php echo $this->getPeerClassName() ?>::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForAction(43, '$request->getParameter') ?>), sprintf('Object <?php echo $this->getSingularName() ?> does not exist (%s).', <?php echo $this->getRetrieveByPkParamsForAction(43, '$request->getParameter') ?>)); 
    8     $this->form = new <?php echo $this->getFormClassName() ?>($<?php echo $this->getSingularName() ?>); 
     7    $this->forward404Unless($<?php echo $this->getSingularName() ?> = <?php echo constant($this->getModelClass().'::PEER') ?>::retrieveByPk(<?php echo $this->getRetrieveByPkParamsForAction(43) ?>), sprintf('Object <?php echo $this->getSingularName() ?> does not exist (%s).', <?php echo $this->getRetrieveByPkParamsForAction(43) ?>)); 
     8    $this->form = new <?php echo $this->getModelClass().'Form' ?>($<?php echo $this->getSingularName() ?>); 
    99<?php endif; ?> 
    1010 
  • plugins/sfPropelPlugin/branches/new_admin/data/generator/sfPropelCrud/default/skeleton/config/generator.yml

    r6884 r12431  
    11generator: 
    2   class:              sfPropelCrudGenerator 
     2  class: sfPropelGenerator 
    33  param: 
    4     model_class:      ##MODEL_CLASS## 
    5     theme:            default 
    6  
    74##CONFIG## 
  • plugins/sfPropelPlugin/branches/new_admin/data/generator/sfPropelCrud/default/template/templates/_form.php

    r12240 r12431  
     1[?php include_stylesheets_for_form($form) ?] 
     2[?php include_javascripts_for_form($form) ?] 
     3 
    14<?php $form = $this->getFormObject() ?> 
    25<?php if (isset($this->params['route_prefix']) && $this->params['route_prefix']): ?> 
     
    1215      <tr> 
    1316        <td colspan="2"> 
     17          [?php echo $form->renderHiddenFields() ?] 
    1418<?php if (isset($this->params['route_prefix']) && $this->params['route_prefix']): ?> 
    1519          &nbsp;<a href="[?php echo url_for('<?php echo $this->getUrlForAction('list') ?>') ?]">Cancel</a> 
     
    3337<?php else: ?> 
    3438      [?php echo $form->renderGlobalErrors() ?] 
    35 <?php foreach ($form->getWidgetSchema()->getPositions() as $i => $name): ?> 
    36 <?php if ($form[$name]->isHidden()) continue ?> 
     39<?php foreach ($form as $name => $field): if ($field->isHidden()) continue ?> 
    3740      <tr> 
    3841        <th>[?php echo $form['<?php echo $name ?>']->renderLabel() ?]</th> 
     
    4043          [?php echo $form['<?php echo $name ?>']->renderError() ?] 
    4144          [?php echo $form['<?php echo $name ?>'] ?] 
    42 <?php $i == $this->getLastNonHiddenField() and print $this->getHiddenFieldsAsString() ?> 
    4345        </td> 
    4446      </tr> 
  • plugins/sfPropelPlugin/branches/new_admin/lib/task/sfPropelGenerateModuleTask.class.php

    r12267 r12431  
    8181 
    8282    $this->constants = array( 
    83       'PROJECT_NAME' => isset($properties['symfony']['name']) ? $properties['symfony']['name'] : 'symfony', 
    84       'APP_NAME'     => $arguments['application'], 
    85       'MODULE_NAME'  => $arguments['module'], 
    86       'MODEL_CLASS'  => $arguments['model'], 
    87       'AUTHOR_NAME'  => isset($properties['symfony']['author']) ? $properties['symfony']['author'] : 'Your name here', 
     83      'PROJECT_NAME'   => isset($properties['symfony']['name']) ? $properties['symfony']['name'] : 'symfony', 
     84      'APP_NAME'       => $arguments['application'], 
     85      'MODULE_NAME'    => $arguments['module'], 
     86      'UC_MODULE_NAME' => ucfirst($arguments['module']), 
     87      'MODEL_CLASS'    => $arguments['model'], 
     88      'AUTHOR_NAME'    => isset($properties['symfony']['author']) ? $properties['symfony']['author'] : 'Your name here', 
    8889    ); 
    89      
     90 
    9091    $method = $options['generate-in-cache'] ? 'executeInit' : 'executeGenerate'; 
    9192 
     
    9899    $tmpDir = sfConfig::get('sf_cache_dir').DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.md5(uniqid(rand(), true)); 
    99100    $generatorManager = new sfGeneratorManager($this->configuration, $tmpDir); 
    100     $generatorManager->generate('sfPropelCrudGenerator', array( 
     101    $generatorManager->generate('sfPropelGenerator', array( 
    101102      'model_class'           => $arguments['model'], 
    102103      'moduleName'            => $arguments['module'], 
     
    145146    $finder = sfFinder::type('any')->discard('.sf'); 
    146147    $dirs = $this->configuration->getGeneratorSkeletonDirs('sfPropelCrud', $options['theme']); 
     148 
    147149    foreach ($dirs as $dir) 
    148150    { 
     
    154156    } 
    155157 
     158    // move configuration file 
     159    if (file_exists($config = $moduleDir.'/lib/configuration.php')) 
     160    { 
     161      if (file_exists($target = $moduleDir.'/lib/'.$arguments['module'].'GeneratorConfiguration.class.php')) 
     162      { 
     163        $this->getFilesystem()->remove($config); 
     164      } 
     165      else 
     166      { 
     167        $this->getFilesystem()->rename($config, $target); 
     168      } 
     169    } 
     170 
     171    // move helper file 
     172    if (file_exists($config = $moduleDir.'/lib/helper.php')) 
     173    { 
     174      if (file_exists($target = $moduleDir.'/lib/'.$arguments['module'].'GeneratorHelper.class.php')) 
     175      { 
     176        $this->getFilesystem()->remove($config); 
     177      } 
     178      else 
     179      { 
     180        $this->getFilesystem()->rename($config, $target); 
     181      } 
     182    } 
     183 
    156184    // create basic test 
    157185    $this->getFilesystem()->copy(sfConfig::get('sf_symfony_lib_dir').DIRECTORY_SEPARATOR.'task'.DIRECTORY_SEPARATOR.'generator'.DIRECTORY_SEPARATOR.'skeleton'.DIRECTORY_SEPARATOR.'module'.DIRECTORY_SEPARATOR.'test'.DIRECTORY_SEPARATOR.'actionsTest.php', sfConfig::get('sf_test_dir').DIRECTORY_SEPARATOR.'functional'.DIRECTORY_SEPARATOR.$arguments['application'].DIRECTORY_SEPARATOR.$arguments['module'].'ActionsTest.php'); 
     
    162190    // customize php and yml files 
    163191    $finder = sfFinder::type('file')->name('*.php', '*.yml'); 
    164     $this->constants['CONFIG'] = sprintf("    non_verbose_templates: %s\n    with_show:             %s\n    singular:             %s\n    plural:             %s\n    route_prefix:             %s\n    with_propel_route:             %s", 
     192    $this->constants['CONFIG'] = sprintf(<<<EOF 
     193    model_class:           %s 
     194    theme:                 %s 
     195    non_verbose_templates: %s 
     196    with_show:             %s 
     197    singular:              %s 
     198    plural:                %s 
     199    route_prefix:          %s 
     200    with_propel_route:     %s 
     201EOF 
     202    , 
     203      $arguments['model'], 
     204      $options['theme'], 
    165205      $options['non-verbose-templates'] ? 'true' : 'false', 
    166206      $options['with-show'] ? 'true' : 'false', 
    167       $options['singular'] ? $options['singular'] : 'null', 
    168       $options['plural'] ? $options['plural'] : 'null', 
    169       $options['route-prefix'] ? $options['route-prefix'] : 'null', 
     207      $options['singular'] ? $options['singular'] : '~', 
     208      $options['plural'] ? $options['plural'] : '~', 
     209      $options['route-prefix'] ? $options['route-prefix'] : '~', 
    170210      $options['with-propel-route'] ? $options['with-propel-route'] : 'false' 
    171211    );