1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class PrettyPhoto extends Object |
|
|
|
|
4
|
|
|
{ |
5
|
|
|
private static $themes = array("dark_rounded", "dark_square", "facebook", "light_rounded", "light_square"); |
|
|
|
|
6
|
|
|
|
7
|
|
|
private static $theme = ""; |
|
|
|
|
8
|
|
|
|
9
|
|
|
private static $more_config = array("social_tools" => false); |
|
|
|
|
10
|
|
|
|
11
|
|
|
private static $selector = "body"; |
|
|
|
|
12
|
|
|
|
13
|
|
|
public static function include_code() |
14
|
|
|
{ |
15
|
|
|
if (Director::is_ajax()) { |
16
|
|
|
self::block(); |
17
|
|
|
} else { |
18
|
|
|
Requirements::javascript(THIRDPARTY_DIR."/jquery/jquery.js"); |
19
|
|
|
Requirements::javascript('prettyphoto/javascript/jquery.prettyPhoto.js'); |
20
|
|
|
Requirements::css('prettyphoto/css/prettyPhoto.css'); |
21
|
|
|
|
22
|
|
|
$config = ''; |
23
|
|
|
$theme = Config::inst()->get("PrettyPhoto", "theme"); |
24
|
|
|
$moreConfigArray = Config::inst()->get("PrettyPhoto", "more_config"); |
25
|
|
|
foreach ($moreConfigArray as $key => $value) { |
|
|
|
|
26
|
|
|
if ($value === false) { |
27
|
|
|
$value = "false"; |
28
|
|
|
} elseif ($value === true) { |
29
|
|
|
$value = "true"; |
30
|
|
|
} elseif ($value === intval($value)) { |
|
|
|
|
31
|
|
|
//$value = $value; |
|
|
|
|
32
|
|
|
} else { |
33
|
|
|
$value = " '$value' "; |
34
|
|
|
} |
35
|
|
|
$moreConfigArray[$key] = "$key: $value"; |
36
|
|
|
} |
37
|
|
|
if ($theme) { |
38
|
|
|
$config .= "theme: '".$theme."'"; |
39
|
|
|
} |
40
|
|
|
if ($config && count($moreConfigArray)) { |
41
|
|
|
$config .= ", "; |
42
|
|
|
} |
43
|
|
|
if (count($moreConfigArray)) { |
44
|
|
|
$config .= implode(",", $moreConfigArray); |
45
|
|
|
} |
46
|
|
|
Requirements::customScript('PrettyPhotoInitConfigs = {'.$config.'}; jQuery(document).ready(function(){PrettyPhotoLoader.load("'.Config::inst()->get("PrettyPhoto", "selector").'")});', "prettyPhotoCustomScript"); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public static function block() |
51
|
|
|
{ |
52
|
|
|
Requirements::block('prettyphoto/javascript/jquery.prettyPhoto.js'); |
53
|
|
|
Requirements::block('prettyphoto/css/prettyPhoto.css'); |
54
|
|
|
Requirements::block("prettyPhotoCustomScript"); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.