Development

#3196 ([PATCH] sfSimpleCMSPlugin : sfSimpleCMSSlotImage does not unset params "legend" and "url")

You must first sign up to be able to contribute.

Ticket #3196 (new defect)

Opened 5 months ago

[PATCH] sfSimpleCMSPlugin : sfSimpleCMSSlotImage does not unset params "legend" and "url"

Reported by: onanga Assigned to: francois
Priority: major Milestone:
Component: sfSimpleCMSPlugin Version: 1.0.12
Keywords: slotEditor, slotImage, image slot, sfSimpleCMSHelper Cc:
Qualification: Unreviewed

Description

When inserting an image slot, it is possible to acknowledge a legend, url, src, width, height. Legend and url are not img tag attributes and when building a tag in sfSimpleCMSSlotImage->getSlotValue($slot), they are unset. The issue is that if you did not insert any value for legend and/or url, their value is null, isset($params['url']) and isset($params['legend']) will return false, and therefore those are not unset. That causes XHTML invalid code.

A workaround is to set legend and url params only if they were filled by user : in sfSimpleCMSPlugin/lib/slotType/sfSimpleCMSSlotImage.class.php, replace your current

public function getSlotValueFromRequest($request)
{
 ...
}

by

  public function getSlotValueFromRequest($request)
  {
    $params = array();
    $params['src'] = $request->getParameter('src');
    $params['width'] = $request->getParameter('width');
    $params['height'] = $request->getParameter('height');
    '''if($request->getParameter('legend'))'''
    {
      $params['legend'] = $request->getParameter('legend');
    }
    '''if($request->getParameter('url'))'''
    {
      $params['url'] = $request->getParameter('url');
    }
    
    return sfYaml::dump($params);
  }