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

Changeset 4470

Show
Ignore:
Timestamp:
01/13/12 16:44:07 (4 months ago)
Author:
tboutell
Message:

* Button slots have a new editLink option, which defaults to true. If you set it explicitly to false, the link field does not appear in the form. To make sensible use of this there must also be a 'link' option present specifying the URL that is forced for this button. This is nice for a logo slot that always links to /. Needed for PR

* Button slot edit forms default to the title and link that were passed in by the template now, if any, rather than being initially blank.

* The "You are still editing content. Are you sure you want to leave this page?" message is not displayed if the slot has the .a-no-unload-warning class. This allows for cases where we want to put a button that takes you to the media library inside an edit form. Which, normally, I would hate, but if the form is really trivial it's reasonable to do.

Location:
plugins/apostrophePlugin/branches/1.5
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • plugins/apostrophePlugin/branches/1.5/lib/action/BaseaButtonSlotActions.class.php

    r4118 r4470  
    2929      $this->slot->link('MediaItems', array($item->id)); 
    3030    } 
    31     $this->editSave(); 
     31    return $this->editSave(); 
    3232  } 
    3333 
     
    5757      } 
    5858    } 
    59                  
    60                 // Trim whitespace off the front & end of the URL to avoid failing validation on a perfectly acceptable URL 
    61                 $value['url'] = trim($value['url']);  
     59 
     60                if ($this->getOption('editLink', null) !== false) 
     61                { 
     62                // Trim whitespace off the front & end of the URL to avoid failing validation on a perfectly acceptable URL 
     63                $value['url'] = trim($value['url']);  
     64        } 
    6265 
    6366    $this->form = new aButtonForm($this->id, $this->options); 
     
    6568    if ($this->form->isValid()) 
    6669    { 
    67       $url = $this->form->getValue('url'); 
     70                if ($this->getOption('editLink', null) !== false) 
     71                { 
     72        $url = $this->form->getValue('url'); 
     73      } 
    6874      $value = $this->slot->getArrayValue(); 
    69       $value['url'] = $url; 
     75                if ($this->getOption('editLink', null) !== false) 
     76                { 
     77        $value['url'] = $url; 
     78      } 
    7079      $value['title'] = $this->form->getValue('title'); 
    7180      $value['description'] = $this->form->getValue('description'); 
  • plugins/apostrophePlugin/branches/1.5/lib/action/BaseaButtonSlotComponents.class.php

    r4203 r4470  
    8888        $this->form->setDefault('url', $value['url']);       
    8989      } 
     90      else 
     91      { 
     92        $this->form->setDefault('url', $this->getOption('link')); 
     93      } 
    9094      if (isset($value['title'])) 
    9195      { 
    9296        $this->form->setDefault('title', $value['title']);       
     97      } 
     98      else 
     99      { 
     100        // Careful, just plain true is a valid setting for this option 
     101        $title = $this->getOption('title'); 
     102        if (strlen($title) && ($title !== true)) 
     103        { 
     104          $this->form->setDefault('title', $title); 
     105        } 
    93106      } 
    94107      if (isset($value['description'])) 
  • plugins/apostrophePlugin/branches/1.5/lib/form/BaseaButtonForm.class.php

    r3508 r4470  
    6464      'title' => new sfWidgetFormInputText(array(), array('class' => 'aButtonSlot'))   
    6565    )); 
    66  
     66     
    6767    $this->setValidators(array( 
    6868      'description' => new sfValidatorHtml(array('required' => false, 'allowed_tags' => $this->allowedTags, 'allowed_attributes' => $this->allowedAttributes, 'allowed_styles' => $this->allowedStyles)), 
     
    7575      'title' => new sfValidatorString(array('required' => false))  
    7676    )); 
     77 
     78    $editLink = $this->consumeSlotOption('editLink'); 
     79    if ($editLink === false) 
     80    { 
     81      unset($this['url']); 
     82    } 
    7783 
    7884    // Ensures unique IDs throughout the page. Hyphen between slot and form to please our CSS 
  • plugins/apostrophePlugin/branches/1.5/modules/aButtonSlot/templates/_editView.php

    r4204 r4470  
    3434<?php endif ?> 
    3535 
    36 <div class="a-form-row link"> 
    37         <?php echo $form['url']->renderLabel('Link') ?> 
    38         <div class="a-form-field"> 
    39                 <?php echo $form['url']->render() ?> 
    40         </div> 
    41         <?php echo $form['url']->renderError() ?> 
    42 </div> 
     36<?php if ((!isset($options['editLink'])) || ($options['editLink'] !== false)): ?> 
     37  <div class="a-form-row link"> 
     38        <?php echo $form['url']->renderLabel('Link') ?> 
     39        <div class="a-form-field"> 
     40                <?php echo $form['url']->render() ?> 
     41        </div> 
     42        <?php echo $form['url']->renderError() ?> 
     43  </div> 
     44<?php endif ?> 
    4345 
    4446<?php if ($options['description']): ?> 
  • plugins/apostrophePlugin/branches/1.5/web/js/a.js

    r4466 r4470  
    931931                } 
    932932        }; 
    933  
     933         
    934934        this.afterAddingSlot = function(name) 
    935935        { 
     
    22882288      if ($('.a-slot.a-editing').length) 
    22892289      { 
    2290         return "You are still editing content. Any edits you have made will be lost if you do not save them first before leaving the page."; 
     2290        // Don't stop the user if all of the open slot edit forms have .a-no-unload-warning 
     2291        var stop = false; 
     2292        $('.a-slot.a-editing').each(function() { 
     2293          if (!$(this).hasClass('a-no-unload-warning')) 
     2294          { 
     2295            stop = true; 
     2296          } 
     2297        }); 
     2298        if (stop) 
     2299        { 
     2300          return "You are still editing content. Any edits you have made will be lost if you do not save them first before leaving the page."; 
     2301        } 
    22912302      } 
    22922303    });