To participate you must create an account on apostrophenow.org. If you have already done so, click Login.

Changeset 4473

Show
Ignore:
Timestamp:
01/16/12 15:33:21 (4 months ago)
Author:
tboutell
Message:

Reusable slideshows now have a rich text "blurb" field as well as a label. The blurb field is displayed in the normal view if the 'slideshowBlurb' option is true. This hasn't been styled yet

Location:
plugins/apostropheExtraSlotsPlugin/trunk
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • plugins/apostropheExtraSlotsPlugin/trunk/config/apostropheExtraSlotsPluginConfiguration.class.php

    r4379 r4473  
    2727      $migrate->sql(array('CREATE TABLE a_reusable_slot (id BIGINT AUTO_INCREMENT, label VARCHAR(100) NOT NULL, type VARCHAR(100) NOT NULL, page_id BIGINT NOT NULL, area_name TEXT NOT NULL, permid BIGINT NOT NULL, PRIMARY KEY(id)) ENGINE = INNODB DEFAULT CHARSET=utf8;')); 
    2828    } 
     29    if (!$migrate->columnExists('a_reusable_slot', 'blurb')) 
     30    { 
     31      $migrate->sql(array('ALTER TABLE a_reusable_slot ADD COLUMN blurb LONGTEXT')); 
     32    } 
    2933  } 
    3034} 
  • plugins/apostropheExtraSlotsPlugin/trunk/config/doctrine/schema.yml

    r4468 r4473  
    280280      type: string(100) 
    281281      notnull: true 
     282    blurb: 
     283      type: clob 
    282284    type:  
    283285      type: string(100) 
  • plugins/apostropheExtraSlotsPlugin/trunk/lib/form/aReusableSlideshowSlotEditForm.class.php

    r4400 r4473  
    5555    // See validateCallback 
    5656    $this->setValidator('label', new sfValidatorPass(array('required' => false))); 
     57     
     58    // The rest of the options passed become attributes of the widget 
     59    $this->setWidget('blurb', new aWidgetFormRichTextarea()); 
     60    $this->setValidator('blurb', new sfValidatorHtml(array('required' => false))); 
     61     
    5762    $page = aTools::getCurrentPage(); 
    5863    $reusableSlots = Doctrine::getTable('aReusableSlot')->createQuery('r')->where('r.type = ? AND r.id <> ? AND r.page_id <> ?', array($this->slot->type, $this->aReusableSlot ? $this->aReusableSlot->id : 0, $page ? $page->id : 0))->orderBy('r.label')->fetchArray(); 
     
    7984    $this->validatorSchema->setPostValidator(new sfValidatorCallback(array('callback' => array($this, 'validateCallback')))); 
    8085     
    81     // Ensures unique IDs throughout the page. Hyphen between slot and form to please our CSS 
    82     $this->widgetSchema->setNameFormat('slot-form-' . $this->id . '[%s]'); 
     86    // There are problems with AJAX plus FCK plus Symfony forms. FCK insists on making the name and ID 
     87    // the same and brackets are not valid in IDs which can lead to problems in strict settings 
     88    // like AJAX in IE. Work around this by not attempting to use brackets here 
     89    $this->widgetSchema->setNameFormat('slot-form-' . $this->id . '-%s'); 
     90  
    8391     
    8492    // You don't have to use our form formatter, but it makes things nice 
  • plugins/apostropheExtraSlotsPlugin/trunk/modules/aReusableSlideshowSlot/actions/actions.class.php

    r4403 r4473  
    2626    $aReusableSlot = Doctrine::getTable('aReusableSlot')->findOneBySlot($this->pageid, $this->name, $this->permid); 
    2727     
    28     $value = $this->getRequestParameter('slot-form-' . $this->id); 
     28    // Work around FCK's incompatibility with AJAX and bracketed field names 
     29    // (it insists on making the ID bracketed too which won't work for AJAX) 
     30     
     31    // Don't forget, there's a CSRF field out there too. We need to grep through 
     32    // the submitted fields and get all of the relevant ones, reinventing what 
     33    // PHP's bracket syntax would do for us if FCK were compatible with it 
     34     
     35    $values = $request->getParameterHolder()->getAll(); 
     36    $value = array(); 
     37    foreach ($values as $k => $v) 
     38    { 
     39      if (preg_match('/^slot-form-' . $this->id . '-(.*)$/', $k, $matches)) 
     40      { 
     41        $value[$matches[1]] = $v; 
     42      } 
     43    } 
     44     
    2945    if ($value) 
    3046    { 
     
    4460          } 
    4561          $aReusableSlot->label = $this->form->getValue('label'); 
     62          $aReusableSlot->blurb = $this->form->getValue('blurb'); 
    4663          $aReusableSlot->save(); 
    4764           
     
    5370          unset($values['reuse']); 
    5471          $values['label'] = $this->form->getValue('label'); 
     72          $values['blurb'] = $this->form->getValue('blurb'); 
    5573          $this->slot->setArrayValue($values); 
    5674          return $this->editSave(); 
  • plugins/apostropheExtraSlotsPlugin/trunk/modules/aReusableSlideshowSlot/actions/components.class.php

    r4421 r4473  
    2020    parent::executeNormalView(); 
    2121    $values = $this->slot->getArrayValue(); 
    22     if (isset($this->options['slideshowLabel'])) 
     22    $labelActive = isset($this->options['slideshowLabel']) && $this->options['slideshowLabel']; 
     23    $blurbActive = isset($this->options['slideshowBlurb']) && $this->options['slideshowBlurb']; 
     24    if ($labelActive || $blurbActive) 
    2325    { 
    2426      if (isset($values['reuse']['id'])) 
     
    2931          error_log("Offending id is " . $values['reuse']['id']); 
    3032          $this->label = 'Error'; 
     33          $this->blurb = 'Error'; 
    3134        } 
    3235        else 
    3336        { 
    3437          $this->label = $aReusableSlot->label; 
     38          $this->blurb = $aReusableSlot->blurb; 
    3539        } 
    3640      } 
     
    3842      { 
    3943        $this->label = isset($values['label']) ? $values['label'] : null; 
     44        $this->blurb = isset($values['blurb']) ? $values['blurb'] : null; 
    4045      } 
    4146    } 
    42     else 
     47    if (!$labelActive) 
    4348    { 
    4449      $this->label = null; 
    4550    } 
     51    if (!$blurbActive) 
     52    { 
     53      $this->blurb = null; 
     54    } 
     55     
    4656    $this->reusing = isset($values['reuse']); 
    4757  } 
  • plugins/apostropheExtraSlotsPlugin/trunk/modules/aReusableSlideshowSlot/templates/_editView.php

    r4382 r4473  
    1111 
    1212<div class="a-form-row a-label-or-reuse-row <?php echo $formName ?>_label_or_reuse"> 
    13   <input type="radio" class="a-label-or-reuse a-js-label-or-reuse" name="<?php echo $formName ?>[label_or_reuse]" value="label" <?php echo $isLabel ?>/> Label for Reuse 
     13  <input type="radio" class="a-label-or-reuse a-js-label-or-reuse" name="<?php echo $formName ?>-label_or_reuse" value="label" <?php echo $isLabel ?>/> Label for Reuse 
    1414</div> 
    1515 
     
    1818</div> 
    1919 
     20<div class="a-form-indent">  
     21  <?php echo $form['blurb']->renderRow(array('class' => 'a-js-label')) ?> 
     22</div> 
     23 
    2024<div class="a-form-row a-reuse-section <?php echo $formName ?>_label_or_reuse"> 
    21   <input type="radio" class="a-label-or-reuse a-js-label-or-reuse" name="<?php echo $formName ?>[label_or_reuse]" value="reuse" <?php echo $isReuse ?>/> Reuse Another Slideshow 
     25  <input type="radio" class="a-label-or-reuse a-js-label-or-reuse" name="<?php echo $formName ?>-label_or_reuse" value="reuse" <?php echo $isReuse ?>/> Reuse Another Slideshow 
    2226</div> 
    2327 
  • plugins/apostropheExtraSlotsPlugin/trunk/modules/aReusableSlideshowSlot/templates/_normalView.php

    r4382 r4473  
    1111  $slot = isset($slot) ? $sf_data->getRaw('slot') : null; 
    1212  $slug = isset($slug) ? $sf_data->getRaw('slug') : null; 
     13  $blurb = isset($blurb) ? $sf_data->getRaw('blurb') : null; 
    1314?> 
    1415<?php use_helper('a') ?> 
     
    6465<?php // This is the same label that is displayed when selecting a slideshow to reuse. ?> 
    6566<?php // Using it this way as well helps promote reuse ?> 
    66 <?php if ($label): ?> 
     67<?php if (strlen($label)): ?> 
    6768  <h4><?php echo $label ?></h4> 
    6869<?php endif ?> 
     70<?php if (strlen($blurb)): ?> 
     71  <div class="a-slideshow-blurb"><?php echo $blurb ?></div> 
     72<?php endif ?>