IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Symfony PHP Discussion :

Symfony 1.4 : sortable et column_aggregation sont sur un bateau


Sujet :

Symfony PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Étudiant
    Inscrit en
    Mai 2009
    Messages
    10
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2009
    Messages : 10
    Par défaut Symfony 1.4 : sortable et column_aggregation sont sur un bateau
    Bonjour à tous,

    J'ai un petit soucis sur un dév. Symfony 1.4 avec le ActAs Sortable et l’agrégation de colonnes.

    J'ai une table ITEM et 2 agrégations de colonnes pour d'autres tables (PAGE et LINK). Dans mon interface d'administration, les "pages" et les "liens" sont visibles. Je peux "promote" et "demote" sans problèmes chacun d'entre eux.

    Mais au moment de supprimer, au lieu de me faire :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    UPDATE peanut_item SET position = position - ? WHERE (position > ?) ORDER BY position - (1)
    il me fait :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    UPDATE peanut_item SET position = position - ? WHERE (position > ? AND (type = 'link')) ORDER BY position - (1, 17)
    Il ne met donc à jour que les positions des LINK ce qui provoque une erreur ...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicata du champ '18' pour la clef 'peanut_item_position_sortable_idx'
    ...puisque, d'une part, la position doit être unique et, d'autre part, qu'il essaye de mettre la position 18 a un "link" alors qu'elle est déjà occupé par une page...

    Je vous mets en fichier joint un screen de ma BDD ... J'essaye donc, pour l'exemple, de supprimer l'entrée 19 : "Qui sommes-nous ?"

    Quelqu'un a-t-il déjà eu des problèmes en couplant ces 2 propriétés... ? Quelqu'un peut m'aider ?

    Merci d'avance.
    Images attachées Images attachées  

  2. #2
    Membre averti
    Profil pro
    Étudiant
    Inscrit en
    Mai 2009
    Messages
    10
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2009
    Messages : 10
    Par défaut schema.org
    Je vous mets le schema pour plus de clarté... ou pas

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    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
    100
    101
    102
    103
    104
     
    peanutItem:
      actAs:
        Sortable: ~
        Timestampable: ~
        Sluggable:
          fields:      [title]
        Seoable:       ~
      columns:
        id:
          primary: true
          type: integer
          autoincrement: true
        type:
          type: string(255)  
          notnull: true     
        title:
          type: string(255)
          notnull: true
        title_link:
          type: string(255)
        icon:
          type: string(255)
        content:
          type: clob
        author:
          type: integer
          notnull: true
        status:
          type: enum
          values: [draft, publish]
          default: draft
      relations:
        mediaAlbum:
          local: album
          foreign: id
        sfGuardUser:
          local: author
          foreign: id
        Menus:
          class: peanutMenu
          refClass: peanutItemMenu
          local: item_id
          foreign: menu_id   
     
    peanutPage:
      inheritance:
        type: column_aggregation
        extends: peanutItem
        keyField: type
        keyValue: 'page'
      columns:
        excerpt:
          type: clob
        album:
          type: integer
        picture:
          type: string(255)
     
    peanutLink:
      inheritance:
        type: column_aggregation
        extends: peanutItem
        keyField: type
        keyValue: 'link'
      columns:
        url:
          type: string(255)
     
    peanutMenu:
      actAs:
        Sluggable:
          fields: [name]
        NestedSet:
          hasManyRoots: true
          rootColumnName: root_id
      columns:
        id:
          primary: true
          type: integer
          autoincrement: true
        name:
          type: string(255)
          notnull: true
     
    peanutItemMenu:
      columns:
        item_id:
          primary: true
          type: integer
        menu_id:
          primary: true
          type: integer
      relations:
        Menu:
          class: peanutMenu
          onDelete: CASCADE
          local: menu_id
          foreign: id
        Item:
          class: peanutItem
          onDelete: CASCADE
          local: item_id
          foreign: id

    Je vous mets aussi le lib/form correspondant :

    peanutItem
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    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;
      }
    }
    peanutLink
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    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
     
    class peanutLinkForm extends BasepeanutLinkForm
    {
      public function setup()
      {
        parent::setup();
     
        $user = self::getValidUser();
     
        $this->useFields(array(
          'title',
          'slug',
          'url',
          'title_link',
          'icon',
          'content',     
          'author',
          'status',
          'menus_list',
          'created_at'
        ));
     
        $this->widgetSchema['url'] = new sfWidgetFormHtml5InputText($options = array(), $attributes = array(
          'required'    => true,
          'placeholder' => 'http://www.mywebsite.com'        
        ));
     
        $this->validatorSchema['url'] = new sfValidatorUrl($options = array(
          'required'  => true
        ),$messages = array(
          'required'  => 'Fill this please'
        ));
     
        $this->widgetSchema['content'] = new sfWidgetFormTextarea($options = array(), $attributes = array(
          'placeholder' => sfContext::getInstance()->getI18N()->__('Simple description about my link')
        ));
     
        $this->widgetSchema['author'] = new sfWidgetFormChoice(array(
          'choices' => $this->_getUsers()
        ));
     
        if(!$this->isNew()) {
          $this->widgetSchema['created_at'] = new sfWidgetFormI18nDate(array(
            'culture' => $user->getCulture(),
          ));
        }
        else{ 
          unset($this['created_at']); 
        }
     
        $this->embedRelation('peanutSeo');
        $this->widgetSchema['peanutSeo']->setLabel('SEO');
      }
     
      /* ------------------------------------------------------------------------ */
     
      public function doBind(array $values)
      {
        $url = ($values['url'] );
     
        if(preg_match('#^https?://.+#', $url))
        {
          $this->validatorSchema['url'] = new sfValidatorUrl($options = array(
              'required'  => true
            ),$messages = array(
              'required'  => sfContext::getInstance()->getI18N()->__('Fill this please', null, 'peanutCorporate')
          ));
        }
        elseif(preg_match('#^/.+\.html$#', $url) || preg_match('#/#', $url))
        {
          $this->validatorSchema['url'] = new sfValidatorPass($options = array(
            'required'  => true
          ),$messages = array(
            'required'  => sfContext::getInstance()->getI18N()->__('Fill this please', null, 'peanutCorporate')
          ));
        }
     
        parent::doBind($values);
      }
     
      /* ------------------------------------------------------------------------ */
     
      protected function _getUsers()
      {
        $users = array();
        $choices = Doctrine::getTable('sfGuardUser')->getUsersWhereGroupIs('2')->execute();
     
        foreach($choices as $user)
        {
          $users[$user->getId()] = $user->getName();
        }
     
        return $users;
      }
     
    }
    peanutPage
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    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
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
     
    class peanutPageForm extends BasepeanutPageForm
    {
      public function setup()
      {
        parent::setup();
     
        $user = self::getValidUser();
     
        $this->useFields(array(
          'title',
          'slug',
          'title_link',
          'content',
          'excerpt',
          'icon',
          'status',
          'author',
          'menus_list',
          'created_at',
          'album',
          'picture'
        ));
     
        /* ---------------------------------------------------------------------- */
     
        $this->widgetSchema['content'] = new sfWidgetFormCKEditor(array('jsoptions'=>array(
          'customConfig'              => '/lib/ckeditor/config.js',
          'filebrowserBrowseUrl'      => '/lib/elfinder-1.1/elfinder.php.html',
          'filebrowserImageBrowseUrl' => '/lib/elfinder-1.1/elfinder.php.html'
        )));
     
        /* ---------------------------------------------------------------------- */
     
        $this->validatorSchema['content'] = new sfValidatorString($options = array(
          'required'  => true
        ),$messages = array(
          'required'  => 'Fill this please'
        ));
     
        /* ---------------------------------------------------------------------- */
     
        $this->widgetSchema['excerpt'] = new sfWidgetFormTextarea($options = array(), $attributes = array(
          'placeholder' => sfContext::getInstance()->getI18N()->__('Excerpt or aside for my content')
        ));
     
        /* ---------------------------------------------------------------------- */
     
        $this->widgetSchema['author'] = new sfWidgetFormChoice(array(
          'choices' => $this->_getUsers()
        ));
     
        /* ---------------------------------------------------------------------- */
     
        if(!$this->isNew()) {
          $this->widgetSchema['created_at'] = new sfWidgetFormI18nDate(array(
            'culture' => $user->getCulture(),
          ));
        }
        else{
          unset($this['created_at']);
        }
     
        /* ---------------------------------------------------------------------- */
     
        /* Récupération du root_id de l'album qui se nomme "pages" */
        $p = Doctrine::getTable('mediaAlbum')->getAlbumsRootId('pages')->fetchOne();
     
        $this->widgetSchema['album'] = new sfWidgetFormDoctrineChoice(array(
          'model'     => 'mediaAlbum',
          'add_empty' => true,
          'query'     => Doctrine::getTable('mediaAlbum')->getAlbumsByParent($p->getRootId())
        ));
     
        /* ---------------------------------------------------------------------- */
     
        $this->widgetSchema['picture'] = new sfWidgetFormInputFileEditable(array(
          'label' => 'Picture',
          'file_src' => '/uploads/items/' . $this->getObject()->getPicture(),
          'is_image' => true,
          'edit_mode' => !$this->isNew(),
          'template' => $this->_getImageUrl($this->getObject()->getPicture())
        ));
     
        $this->validatorSchema['picture'] = new sfValidatorFile(array(
          'required'   => false,
          'mime_types' => 'web_images',
          'path'       => sfConfig::get('sf_upload_dir').'/items',
          'validated_file_class' => 'peanutValidatedFile',
        ));
     
        $this->validatorSchema['picture_delete'] = new sfValidatorPass();
     
        /* ---------------------------------------------------------------------- */
     
        $this->embedRelation('peanutSeo');
        $this->widgetSchema['peanutSeo']->setLabel('SEO');  
     
        /* ---------------------------------------------------------------------- */
      }
     
      /* ------------------------------------------------------------------------ */
     
      protected function _getUsers()
      {
        $users = array();
        $choices = Doctrine::getTable('sfGuardUser')->getUsersWhereGroupIs('2')->execute();
     
        foreach($choices as $user)
        {
          $users[$user->getId()] = $user->getName();
        }
     
        return $users;
      }
     
      /* ------------------------------------------------------------------------ */
     
      protected function _getImageUrl($object) {
        $tpl = '%file% %input% %delete% %delete_label%';
     
        if('' == $object) {
          $tpl = '%input%';
        }
     
        return $tpl;
      }
     
    }
    Qu'est ce qui pourrait encore aider à m'aider ?

Discussions similaires

  1. Bali et Balo sont sur un bateau
    Par clairetj dans le forum Enigmes
    Réponses: 12
    Dernier message: 26/09/2013, 18h19
  2. Hibernate, Polymorphisme, et Select sont sur un bateau.
    Par andlio dans le forum Hibernate
    Réponses: 0
    Dernier message: 23/08/2011, 00h13
  3. Réponses: 5
    Dernier message: 24/04/2008, 07h54
  4. [Plugin Firefox] Parlez avec ceux qui sont sur le même site que vous en direct
    Par ®om dans le forum La taverne du Club : Humour et divers
    Réponses: 25
    Dernier message: 15/08/2006, 11h02
  5. Réponses: 1
    Dernier message: 07/04/2005, 13h31

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo