-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPluginUtils.php
63 lines (51 loc) · 2.24 KB
/
PluginUtils.php
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
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of utils
*
* @author leny
*/
class PluginUtils {
static public function slugify($text) {
// replace all non letters or digits by -
$text = preg_replace('/\W+/', '-', $text);
// trim and lowercase
$text = strtolower(trim($text, '-'));
return $text;
}
static public function light_image($thumb_url, $image_url, $image_link_options = array(), $thumb_options = array() )
{
//make lightbox effect
$thumb_tag = image_tag($thumb_url, $thumb_options);
$image_link_options['class'] = isset($image_link_options['class']) ? $image_link_options['class']." lightbox" : 'lightbox';
echo link_to($thumb_tag, $image_url, $image_link_options);
}
static public function light_image_activate()
{
if (!sfContext::hasInstance()) return;
//add resources
$response = sfContext::getInstance()->getResponse();
//check if jqueryreloaded plugin is activated
if (sfConfig::has('sf_jquery_web_dir') && sfConfig::has('sf_jquery_core'))
$response->addJavascript(sfConfig::get('sf_jquery_web_dir'). '/js/'.sfConfig::get('sf_jquery_core'));
else
throw new Exception("Theres is no JqueryReloaded plugin !");
//JQuery Lightbox specific
$response->addJavascript(sfConfig::get("app_sf_jquery_lightbox_js_dir").'jquery.lightbox-0.5.js');
$response->addStylesheet(sfConfig::get("app_sf_jquery_lightbox_css_dir").'jquery.lightbox-0.5.css');
$code = "$(function() {
$('a.lightbox').lightBox({
imageLoading: '".sfConfig::get('app_sf_jquery_lightbox_imageLoading')."',
imageBtnClose: '".sfConfig::get('app_sf_jquery_lightbox_imageBtnClose')."',
imageBtnPrev: '".sfConfig::get('app_sf_jquery_lightbox_imageBtnPrev')."',
imageBtnNext: '".sfConfig::get('app_sf_jquery_lightbox_imageBtnNext')."',
imageBlank: '".sfConfig::get('app_sf_jquery_lightbox_imageBlank')."',
txtImage: '".sfConfig::get('app_sf_jquery_lightbox_txtImage')."',
txtOf: '".sfConfig::get('app_sf_jquery_lightbox_txtOf')."' });
});";
echo javascript_tag($code);
}
}