| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 
 |  
abstract class peanutItemForm extends BasepeanutItemForm
{
  protected function setupInheritance()
  {
    parent::setupInheritance();
 
    $user = self::getValidUser();
 
    $this->useFields(array(
      'title',
      'slug',
      'title_link',
      'content',
      'excerpt',
      'status',
      'icon',
      'author',
      'status',
      'menus_list',
      'url',
      'created_at',
      'album',
      'picture'
    ));
 
    /* ---------------------------------------------------------------------- */
 
    $this->widgetSchema['title'] = new sfWidgetFormHtml5InputText($options = array(), $attributes = array(
      'required'    => true,
      'placeholder' => sfContext::getInstance()->getI18N()->__('The item title')
    ));
 
    /* ---------------------------------------------------------------------- */
 
    $this->widgetSchema['slug'] = new sfWidgetFormHtml5InputText($options = array(), $attributes = array(
      'placeholder' => sfContext::getInstance()->getI18N()->__('the-item-slug')
    ));
 
    /* ---------------------------------------------------------------------- */
 
    $this->widgetSchema['title_link'] = new sfWidgetFormHtml5InputText($options = array(), $attributes = array(
      'placeholder' => sfContext::getInstance()->getI18N()->__('The link for title')
    ));
 
    /* ---------------------------------------------------------------------- */
 
    $this->widgetSchema['icon'] = new sfWidgetFormHtml5InputText($options = array(), $attributes = array(
      'placeholder' => sfContext::getInstance()->getI18N()->__('The item icon (select this icon : click to zoom)')
    ));
 
    /* ---------------------------------------------------------------------- */
 
    $this->widgetSchema['menus_list']  = new sfWidgetFormChoice(array(
      'choices' => $this->_getMenus($user),
      'multiple' => true
    ));
    $this->widgetSchema['menus_list']->setLabel('Menu');
 
    /* ---------------------------------------------------------------------- */
 
    $this->embedRelation('peanutSeo');
    $this->widgetSchema['peanutSeo']->setLabel('SEO');
 
    /* ---------------------------------------------------------------------- */
 
    $this->widgetSchema->setHelps(array(
      'title'         => 'The item title (required)',
      'title_link'    => 'The title display (used for SEO)',
      'slug'          => 'This field is automatically filled (not required)',
      'content'       => 'The item content (required)',
      'excerpt'       => 'The item excerpt (not required)',
      'author'        => 'The author item',
      'status'        => 'If you want to hide this entry for visitors',
      'menus_list'    => 'The menu where will appear this item',
      'url'           => 'The item url (must be an http / https url or relative url like /page.html )',
      'picture'       => 'The picture of the page',
      'icon'          => 'The item icon (select this icon : click to zoom)', 
      'album'         => 'The associated album',
      'created_at'    => 'Useful is you want to modify the date of the entry publication'
    ));
   }
 
   /* ----------------------------------------------------------------------- */
 
   protected function _getMenus(){
 
    $menus = Doctrine_Core::getTable('peanutMenu')->getMenus();
    $this->menus = $menus->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
 
    $men = '';
    foreach($this->menus as $menu){
 
      $espace = ($menu['level'] ==0) ? ' ' : str_repeat('     ', $menu['level']);
      $men[$menu['id']] = $espace . '- ' . $menu['name'];
    }
    return ($men == null) ? array() : $men;
  }
} | 
Partager