Development

Changeset 16337

You must first sign up to be able to contribute.

Changeset 16337

Show
Ignore:
Timestamp:
03/16/09 16:44:34 (4 years ago)
Author:
lombardot
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/spyFormBuilderInterface2Plugin/config/spy_form_actions.yml

    r16333 r16337  
    11all: 
    22  actions: 
     3    actions: 
     4      store_propel: 
     5        generateYml: 
     6          title: Générate the YML 
     7          img: /sf/sf_admin/images/default_icon.png 
    38    post: 
    49      send_mail: 
     
    4449              options: 
    4550                default: propel 
     51            table_name: 
     52              name: Name of The table 
     53              type: sfWidgetFormInput 
     54              attributes: 
     55                size: 30 
  • plugins/spyFormBuilderInterface2Plugin/config/spy_form_widgets.yml

    r16321 r16337  
    55        name: Text Field 
    66        type: sfWidgetFormInput 
     7        storage: 
     8          type: varchar 
     9          size: 255 
     10          index: index 
    711        params: 
    812          attributes: 
  • plugins/spyFormBuilderInterface2Plugin/lib/action/spyActionStoreInPropel.php

    r16333 r16337  
    1111     
    1212  } 
     13   
     14  public static function generateYml(){ 
     15    require_once(sfContext::getInstance()->getConfigCache()->checkConfig('config/spy_form_widgets.yml')); 
     16    $yml=array(); 
     17    $sf_request=sfContext::getInstance()->getRequest(); 
     18    $action=SpyFormBuilderActionPeer::retrieveByPK($sf_request->getParameter('id')); 
     19     
     20    $form=$action->getSpyFormBuilder(); 
     21    $fields=$form->getSpyFormBuilderFieldss(); 
     22    $db=$action->getParameter('dbname','propel'); 
     23    $table=$action->getParameter('table_name',str_replace(' ','_',$form->getName())); 
     24    $yml[$db]=array($table=>array()); 
     25    $yml_table=&$yml[$db][$table]; 
     26    $yml_table['id']='~'; 
     27    foreach($fields as $field){ 
     28      $yml_table[$field->getName()]=self::getYmlForField($field); 
     29    } 
     30     
     31    $o='<h1>'.sfContext::getInstance()->getI18N()->__('Generate the YML').'</h1>'; 
     32    $o.='Recopiez le code ci dessous dans le schema.yml et executer propel:build-all-diff <br/>'; 
     33    $o.= '<textarea cols="100" rows="20">'; 
     34    $o.= sfYaml::dump($yml,3); 
     35    $o.= '</textarea>'; 
     36    return $o; 
     37  } 
     38   
     39  protected static function getYmlForField(SpyFormBuilderFields $field){ 
     40     
     41    $fields=sfConfig::get('sfw_widgets_fields'); 
     42    if(array_key_exists($field->getWidgetType(),$fields)){ 
     43      if(array_key_exists('storage',$fields[$field->getWidgetType()])){ 
     44        return $fields[$field->getWidgetType()]['storage']; 
     45      } 
     46    } 
     47    return array('type'=>'longvarchar'); 
     48  } 
    1349} 
    1450?> 
  • plugins/spyFormBuilderInterface2Plugin/lib/model/SpyFormBuilderAction.php

    r16321 r16337  
    11<?php 
     2require_once(sfContext::getInstance()->getConfigCache()->checkConfig('config/spy_form_actions.yml')); 
    23 
    34class SpyFormBuilderAction extends BaseSpyFormBuilderAction 
    45{ 
    56  public function getActions(){ 
    6     return ''; 
     7     
     8    $request = sfContext::getInstance()->getRequest(); 
     9      $root = $request->getRelativeUrlRoot(); 
     10 
     11    $all_actions=sfConfig::get('sfa_actions_actions'); 
     12    if(!array_key_exists($this->getActionType(),$all_actions)) 
     13      return ''; 
     14    foreach($all_actions[$this->getActionType()] as $aname=>$action){ 
     15       
     16      echo '<a href="'.sfContext::getInstance()->getController()->genUrl('spyFormBuilderInterfaceActions/action',false).'/do/'.$aname.'/id/'.$this->getId().'" title="'.$action['title'].'"><img src="'.$root.'/'.$action['img'].'" alt="'.$action['title'].'" /></a>'; 
     17    } 
    718  } 
    819  public function getActionParams(){ 
    920    return unserialize(parent::getActionParams()); 
     21  } 
     22   
     23  public function getParameter($name,$default=null){ 
     24    $params=$this->getActionParams(); 
     25    if(array_key_exists($name,$params)) 
     26      return $params[$name]; 
     27    return $default; 
    1028  } 
    1129  public function save(PropelPDO $con=null){ 
  • plugins/spyFormBuilderInterface2Plugin/lib/model/SpyFormBuilderFields.php

    r16321 r16337  
    1212  public function getWidgetParams(){ 
    1313    return unserialize(parent::getWidgetParams()); 
     14  } 
     15  public function getParameter($name,$default=null){ 
     16    $params=$this->getWidgetParams(); 
     17    if(array_key_exists($name,$params)) 
     18      return $params[$name]; 
     19    return $default; 
    1420  } 
    1521  public function insertAtLastPos(){ 
  • plugins/spyFormBuilderInterface2Plugin/lib/model/SpyFormBuilderValidators.php

    r16321 r16337  
    1818      return unserialize(parent::getValidatorParams()); 
    1919    return array(); 
     20  } 
     21  public function getParameter($name,$default=null){ 
     22    $params=$this->getValidatorParams(); 
     23    if(array_key_exists($name,$params)) 
     24      return $params[$name]; 
     25    return $default; 
    2026  } 
    2127  public function insertAtLastPos(){ 
  • plugins/spyFormBuilderInterface2Plugin/modules/spyFormBuilderInterfaceActions/actions/actions.class.php

    r16321 r16337  
    8484    $this->redirect('spyFormBuilderInterface/edit?id='.$this->getRequestParameter('form_id')); 
    8585  } 
     86   
     87  /* 
     88   * Execute an advanced action for one form Action 
     89   */ 
     90  public function executeAction($request){ 
     91    $this->forward404Unless($request->getParameter('do')); 
     92    $this->forward404Unless($request->getParameter('id')); 
     93    $this->action=SpyFormBuilderActionPeer::retrieveByPK($this->getRequestParameter('id')); 
     94    $this->forward404Unless($this->action); 
     95    $actions=sfConfig::get('sfa_actions_post'); 
     96    $this->class=$actions[$this->action->getActionType()]['type']; 
     97    $this->do=$request->getParameter('do'); 
     98  } 
    8699}