1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Shadogo |
---|
4 | Author: Binaryworld |
---|
5 | Author URI: http://binaryworld.hd.free.fr/ |
---|
6 | */ |
---|
7 | |
---|
8 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
9 | |
---|
10 | |
---|
11 | class ShadogoConfig { |
---|
12 | public static $CONFIG_NAME = 'shadogo'; |
---|
13 | |
---|
14 | private $_config = null; |
---|
15 | |
---|
16 | function __construct($config = null) { |
---|
17 | global $conf; |
---|
18 | if ($config == null) { |
---|
19 | if (isset($conf[self::$CONFIG_NAME])) |
---|
20 | $this->_config = unserialize($conf[self::$CONFIG_NAME]); |
---|
21 | } else { |
---|
22 | $this->_config = $config; |
---|
23 | } |
---|
24 | } |
---|
25 | |
---|
26 | public static function createDefaultConfiguration () { |
---|
27 | $config = array( |
---|
28 | // |
---|
29 | // global parameters |
---|
30 | // |
---|
31 | 'mediaFilePattern' => '/^(?<path>.*)\\/(?<file>[^\\/]*)_-_(?<media>flv|mp4|swf|mp3|webm)(?:_(?<width>\\d+)x(?<height>\\d+))?/i', |
---|
32 | // |
---|
33 | // overlaylib parameters |
---|
34 | // |
---|
35 | 'modalOverlayLib' => 'mediaboxAdvanced', |
---|
36 | 'modalOverlayTheme' => 'grey', |
---|
37 | 'favoritePicture' => true, |
---|
38 | 'hdPicture' => true, |
---|
39 | 'downloadPicture' => true, |
---|
40 | 'addToBasket' => true, |
---|
41 | // |
---|
42 | // content parameters |
---|
43 | // |
---|
44 | // Display the HD picture in shadowbox when the picture is clicked in the picture content page |
---|
45 | 'hdPictureInOverlay' => true, |
---|
46 | 'hdPicturePrefilterPattern' => '/href="javascript:phpWGOpenWindow.*"/i', |
---|
47 | 'hdPicturePrefilterReplacement' => 'href="{$high.U_HIGH}" rel="lightbox"', |
---|
48 | // Display media player in the piwigo default content page |
---|
49 | 'displayMediaPlayer' => true, |
---|
50 | // |
---|
51 | // sideshow |
---|
52 | // |
---|
53 | 'slideshowInOverlay' => true, |
---|
54 | 'slideshowPrefilterPattern' => '/(href="\\{\\$(?:U_SLIDESHOW|U_SLIDESHOW_START)\\}")([^>]*)(rel=".*")?/i', |
---|
55 | 'slideshowPrefilterReplacement' => '$1 rel="lightbox[diaporama 80% 80%]"$2', |
---|
56 | 'slideshowClosePattern' => '/href="\\{\\$U_SLIDESHOW_STOP\\}"([^>]*)/i', |
---|
57 | 'slideshowCloseReplacement' => 'href="#" onclick="parent.window.ShadogoOverlayWnd.close(); return false;"$1', |
---|
58 | // |
---|
59 | // Thumbnail |
---|
60 | 'thumbInOverlay' => true, |
---|
61 | 'thumbMediaPlayerIcon' => true, |
---|
62 | 'thumbContentIcon' => true, |
---|
63 | 'thumbContentLabel' => false, |
---|
64 | 'thumbContentInOverlay' => false, |
---|
65 | 'thumbButtonsTemplateSearch' => '{if isset($thumbnail.NAME)}{$thumbnail.NAME}{/if}', |
---|
66 | 'thumbHrefContentSearch' => 'href="{$thumbnail.URL}"' |
---|
67 | ); |
---|
68 | return $config; |
---|
69 | } |
---|
70 | |
---|
71 | public static function install() { |
---|
72 | global $conf; |
---|
73 | $c = self::createDefaultConfiguration(); |
---|
74 | |
---|
75 | if (!isset($conf[self::$CONFIG_NAME])) { |
---|
76 | $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) VALUES ("'. self::$CONFIG_NAME .'" , "'.pwg_db_real_escape_string(serialize($c)).'" , "Shadogo configuration");'; |
---|
77 | pwg_query($query); |
---|
78 | } |
---|
79 | } |
---|
80 | public static function uninstall() { |
---|
81 | // Clean DB |
---|
82 | $q = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE param="'. self::$CONFIG_NAME .'" LIMIT 1;'; |
---|
83 | pwg_query($q); |
---|
84 | // Clean global config |
---|
85 | if (isset($conf[self::$CONFIG_NAME])) |
---|
86 | unset($conf[self::$CONFIG_NAME]); |
---|
87 | } |
---|
88 | |
---|
89 | |
---|
90 | public function &__get($name) { |
---|
91 | return $this->_config[$name]; |
---|
92 | } |
---|
93 | public function get($name) { |
---|
94 | return $this->_config[$name]; |
---|
95 | } |
---|
96 | |
---|
97 | function &__set($name, $val) { |
---|
98 | $this->_config[$name] = $val; |
---|
99 | } |
---|
100 | public function set($name, $value) { |
---|
101 | $this->_config[$name] = $value; |
---|
102 | } |
---|
103 | |
---|
104 | public function commit() { |
---|
105 | conf_update_param(self::$CONFIG_NAME, pwg_db_real_escape_string(serialize($this->_config))); |
---|
106 | } |
---|
107 | |
---|
108 | public function assign(&$template) { |
---|
109 | $template->assign(self::$CONFIG_NAME, $this->_config); |
---|
110 | } |
---|
111 | } |
---|