getValue());
$folder = '';
$res = '
No Images
';
if(isset($params['title']))
{
$title = $params['title'];
unset($params['title']);
}
if(!isset($params['folder']))
{
return sprintf('Error: The value of slot %s in incorrect. The image has no source', $slot->getName());
}
$folder = $params['folder'];
$images = array();
$images_path = sfConfig::get('sf_upload_dir').DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$folder;
if(!is_dir($images_path))
{
return sprintf('Error: The value of slot %s in incorrect. Wrong folder', $slot->getName());
}
$files = sfFinder::type('file')->maxdepth(0)->prune('.*')->discard('.*')->relative()->in($images_path);
sort($files);
$infos = array();
foreach ($files as $file)
{
$ext = substr($file, strpos($file, '.') - strlen($file) + 1);
if ($this->isImage($ext))
{
$images[] = array(
'thumbnail' => 'http://'.$_SERVER['HTTP_HOST'].'/uploads/assets/images/'.$folder.'/thumbnail/'.$file,
'image' => 'http://'.$_SERVER['HTTP_HOST'].'/uploads/assets/images/'.$folder.'/'.$file,
'options' => array('title' => $title)
);
}
}
$link_options = array(
'title' => 'Lightbox',
'slidename' => 'lightbox',
);
if(count($images))
{
$res = ''.light_slideshow($images, $link_options, true).'
';
}
if(isset($title))
{
return ''.$title.'
'.$res;
}
else
{
return $res;
}
}
public function getSlotEditor($slot)
{
$folder_path= sfConfig::get('sf_upload_dir').DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'images';
$folders = sfFinder::type('directory')->maxdepth(0)->prune('.*')->discard('thumbnail')->relative()->in($folder_path);
foreach($folders as $folder)
$folder_options[$folder] = $folder;
$params = sfYaml::load($slot->getValue());
return '';
}
private function getControlFor($name, $label, $params)
{
sfLoader::loadHelpers(array('Form', 'Tag', 'I18N'));
return content_tag('div', label_for($name, __($label)).input_tag($name, isset($params[$name]) ? $params[$name] : ''), array('class' => 'image_slot_form', ));
}
public function getSlotValueFromRequest($request)
{
$params = array();
$params['title'] = $request->getParameter('title');
$params['folder'] = $request->getParameter('folder');
return sfYaml::dump($params);
}
}