I do not use rss features of the gallery plugin so - could be broken with following changes.
Pijoter.
diff --git a/script.js b/script.js
index 21c90d6..e35026b 100644
--- a/script.js
+++ b/script.js
@@ -49,7 +49,7 @@
*
* If you don't like that behavior, set this variable to 0.
*/
-var lightboxForEveryImg = 0;
+var lightboxForEveryImg = 1;
function WindowSize()
{ // window size object
@@ -162,7 +162,7 @@ LightBox.prototype = {
anchor.getAttribute("class").match("media") &&
anchor.firstChild.nodeName.toLowerCase().match("img") &&
anchor.getAttribute("href") &&
- anchor.getAttribute("href").match("lib/exe/fetch.php|_media/")) ){
+ anchor.getAttribute("href").match("lib/exe/fetch.php|_media/|_detail/")) ){
// okay add lightbox
}else{
continue;
@@ -171,14 +171,15 @@ LightBox.prototype = {
// initialize item
self._imgs[num] = {src:anchor.getAttribute("href"),w:-1,h:-1,title:'',caption:'',cls:anchor.className};
- if (anchor.getAttribute("title"))
- self._imgs[num].title = anchor.getAttribute("title");
- else if (anchor.firstChild && anchor.firstChild.getAttribute && anchor.firstChild.getAttribute("title"))
+ if (anchor.firstChild && anchor.firstChild.getAttribute && anchor.firstChild.getAttribute("title"))
self._imgs[num].title = anchor.firstChild.getAttribute("title");
+ else if (anchor.getAttribute("title"))
+ self._imgs[num].title = anchor.getAttribute("title");
if (anchor.firstChild && anchor.firstChild.getAttribute &&
anchor.firstChild.getAttribute("longdesc")) {
self._imgs[num].caption = anchor.firstChild.getAttribute("longdesc");
}
+ if(lightboxForEveryImg) self._imgs[num].src = anchor.getAttribute("href").replace("_detail/","_media/");
anchor.onclick = self._genOpener(num); // set closure to onclick event
}
var body = d.getElementsByTagName("body")[0];
diff --git a/style.css b/style.css
index dff7a3a..2a142b6 100644
--- a/style.css
+++ b/style.css
@@ -14,9 +14,9 @@ div.dokuwiki div.gallery {
margin-bottom: 1em;
}
-/*div.dokuwiki div.gallery div {
+div.dokuwiki div.gallery div {
float: left;
-}*/
+}
div.dokuwiki div.gallery img.tn {
margin: 9px;
@@ -30,13 +30,17 @@ div.dokuwiki div.gallery_left {
}
div.dokuwiki div.gallery div {
- float: left;
+ /*float: left;*/
}
div.dokuwiki div.gallery_right {
float: right;
}
+div.dokuwiki div.gallery_normal {
+ /*width: 90%;*/
+}
+
div.dokuwiki div.gallery_center {
margin-left: auto;
margin-right: auto;
diff --git a/syntax.php b/syntax.php
index 181aca2..d6ae078 100644
--- a/syntax.php
+++ b/syntax.php
@@ -42,7 +42,7 @@ class syntax_plugin_gallery extends DokuWiki_Syntax_Plugin {
* Connect pattern to lexer
*/
function connectTo($mode) {
- $this->Lexer->addSpecialPattern('\{\{gallery>[^}]*\}\}',$mode,'plugin_gallery');
+ $this->Lexer->addSpecialPattern('\{\{(?:galeria|gallery)>[^}]*\}\}',$mode,'plugin_gallery');
}
/**
@@ -50,95 +50,102 @@ class syntax_plugin_gallery extends DokuWiki_Syntax_Plugin {
*/
function handle($match, $state, $pos, &$handler){
global $ID;
- $match = substr($match,10,-2); //strip markup from start and end
-
- $data = array();
-
- $data['galid'] = substr(md5($match),0,4);
-
- // alignment
- $data['align'] = 0;
- if(substr($match,0,1) == ' ') $data['align'] += 1;
- if(substr($match,-1,1) == ' ') $data['align'] += 2;
-
- // extract params
- list($ns,$params) = explode('?',$match,2);
- $ns = trim($ns);
-
- // namespace (including resolving relatives)
- if(!preg_match('/^https?:\/\//i',$ns)){
- $data['ns'] = resolve_id(getNS($ID),$ns);
- }else{
- $data['ns'] = $ns;
- }
-
- // set the defaults
- $data['tw'] = $this->getConf('thumbnail_width');
- $data['th'] = $this->getConf('thumbnail_height');
- $data['iw'] = $this->getConf('image_width');
- $data['ih'] = $this->getConf('image_height');
- $data['cols'] = $this->getConf('cols');
- $data['filter'] = '';
- $data['lightbox'] = false;
- $data['direct'] = false;
- $data['showname'] = false;
- $data['showtitle'] = false;
- $data['reverse'] = false;
- $data['random'] = false;
- $data['cache'] = true;
- $data['crop'] = false;
- $data['recursive']= true;
- $data['sort'] = $this->getConf('sort');
- $data['limit'] = 0;
- $data['offset'] = 0;
- $data['paginate'] = 0;
-
- // parse additional options
- $params = $this->getConf('options').','.$params;
- $params = preg_replace('/[,&\?]+/',' ',$params);
- $params = explode(' ',$params);
- foreach($params as $param){
- if($param === '') continue;
- if($param == 'titlesort'){
- $data['sort'] = 'title';
- }elseif($param == 'datesort'){
- $data['sort'] = 'date';
- }elseif($param == 'modsort'){
- $data['sort'] = 'mod';
- }elseif(preg_match('/^=(\d+)$/',$param,$match)){
- $data['limit'] = $match[1];
- }elseif(preg_match('/^\+(\d+)$/',$param,$match)){
- $data['offset'] = $match[1];
- }elseif(is_numeric($param)){
- $data['cols'] = (int) $param;
- }elseif(preg_match('/^~(\d+)$/',$param,$match)){
- $data['paginate'] = $match[1];
- }elseif(preg_match('/^(\d+)([xX])(\d+)$/',$param,$match)){
- if($match[2] == 'X'){
- $data['iw'] = $match[1];
- $data['ih'] = $match[3];
- }else{
- $data['tw'] = $match[1];
- $data['th'] = $match[3];
- }
- }elseif(strpos($param,'*') !== false){
- $param = preg_quote($param,'/');
- $param = '/^'.str_replace('\\*','.*?',$param).'$/';
- $data['filter'] = $param;
+ $match = substr($match,strpos($match,'>')+1,-2); //strip markup from start and end
+ $items = preg_split('/[\n]/', trim($match));
+
+ $containter = array();
+ foreach ($items as $item) {
+ $data = array();
+ $data['galid'] = substr(md5($item),0,4);
+
+ // alignment
+ $data['align'] = 0;
+ if(substr($match,0,1) == ' ') $data['align'] += 1;
+ if(substr($match,-1,1) == ' ') $data['align'] += 2;
+
+ // extract params
+ list($ns,$params) = explode('?',$item,2);
+ $data['op'] = ($ns[0] != '-')? 'merge' : 'diff';
+ $ns = ($ns[0] == '-' || $ns[0] == '+')? substr($ns,1) : trim($ns);
+ list($ns,$title) = explode('|',$ns,2);
+ $data['title'] = $title;
+
+ // namespace (including resolving relatives)
+ if(!preg_match('/^https?:\/\//i',$ns)){
+ $data['ns'] = resolve_id(getNS($ID),$ns);
}else{
- if(substr($param,0,2) == 'no'){
- $data[substr($param,2)] = false;
+ $data['ns'] = $ns;
+ }
+
+ // set the defaults
+ $data['tw'] = $this->getConf('thumbnail_width');
+ $data['th'] = $this->getConf('thumbnail_height');
+ $data['iw'] = $this->getConf('image_width');
+ $data['ih'] = $this->getConf('image_height');
+ $data['cols'] = $this->getConf('cols');
+ $data['filter'] = '';
+ $data['lightbox'] = false;
+ $data['direct'] = false;
+ $data['showname'] = false;
+ $data['showtitle'] = false;
+ $data['reverse'] = false;
+ $data['random'] = false;
+ $data['cache'] = true;
+ $data['crop'] = false;
+ $data['recursive']= true;
+ $data['sort'] = $this->getConf('sort');
+ $data['limit'] = 0;
+ $data['offset'] = 0;
+ $data['paginate'] = 4;
+
+ // parse additional options
+ $params = $this->getConf('options').','.$params;
+ $params = preg_replace('/[,&\?]+/',' ',$params);
+ $params = explode(' ',$params);
+ foreach($params as $param){
+ if($param === '') continue;
+ if($param == 'titlesort'){
+ $data['sort'] = 'title';
+ }elseif($param == 'datesort'){
+ $data['sort'] = 'date';
+ }elseif($param == 'modsort'){
+ $data['sort'] = 'mod';
+ }elseif(preg_match('/^=(\d+)$/',$param,$match)){
+ $data['limit'] = $match[1];
+ }elseif(preg_match('/^\+(\d+)$/',$param,$match)){
+ $data['offset'] = $match[1];
+ }elseif(is_numeric($param)){
+ $data['cols'] = (int) $param;
+ }elseif(preg_match('/^~(\d+)$/',$param,$match)){
+ $data['paginate'] = $match[1];
+ }elseif(preg_match('/^(\d+)([xX])(\d+)$/',$param,$match)){
+ if($match[2] == 'X'){
+ $data['iw'] = $match[1];
+ $data['ih'] = $match[3];
+ }else{
+ $data['tw'] = $match[1];
+ $data['th'] = $match[3];
+ }
+ }elseif(strpos($param,'*') !== false){
+ $param = preg_quote($param,'/');
+ $param = '/^'.str_replace('\\*','.*?',$param).'$/';
+ $data['filter'] = $param;
}else{
- $data[$param] = true;
+ if(substr($param,0,2) == 'no'){
+ $data[substr($param,2)] = false;
+ }else{
+ $data[$param] = true;
+ }
}
}
- }
- // implicit direct linking?
- if($data['lightbox']) $data['direct'] = true;
+ // implicit direct linking?
+ if($data['lightbox']) $data['direct'] = true;
+ //XXX if (count($items)>1) $data['sort'] = 'unsorted';
-
- return $data;
+ $containter[] = $data;
+ }
+ return $containter;
}
/**
@@ -236,7 +243,8 @@ class syntax_plugin_gallery extends DokuWiki_Syntax_Plugin {
'isimg' => preg_match('/\.(jpe?g|gif|png)$/',$dir),
'file' => basename($dir),
'mtime' => filemtime($conf['mediadir'].'/'.$dir),
- 'meta' => new JpegMeta($conf['mediadir'].'/'.$dir)
+ 'meta' => new JpegMeta($conf['mediadir'].'/'.$dir),
+ 'title' => $data['title']
);
$data['_single'] = true;
}else{
@@ -322,12 +330,25 @@ class syntax_plugin_gallery extends DokuWiki_Syntax_Plugin {
/**
* Does the gallery formatting
*/
+ function _filescomp($a,$b) {return strcmp($a['id'],$b['id']);}
function _gallery($data){
global $conf;
global $lang;
$ret = '';
- $files = $this->_findimages($data);
+ $files = array();
+ foreach ($data as $item) {
+ $f = $this->_findimages($item);
+ if ($item['op'] == 'merge') {
+ // pozbadz sie duplikatow
+ $intersect = array_uintersect($files,$f,array($this,'_filescomp'));
+ if (count($intersect)) $f = array_udiff($f,$intersect,array($this,'_filescomp'));
+ $files = array_merge($files,$f);
+ }
+ else {
+ $files = array_udiff($files,$f,array($this,'_filescomp'));
+ }
+ }
//anything found?
if(!count($files)){
@@ -335,6 +356,8 @@ class syntax_plugin_gallery extends DokuWiki_Syntax_Plugin {
return $ret;
}
+ $data = $data[0];
+
// prepare alignment
$align = '';
$xalign = '';
@@ -351,8 +374,8 @@ class syntax_plugin_gallery extends DokuWiki_Syntax_Plugin {
$xalign = ' align="center"';
}
if(!$data['_single']){
- if(!$align) $align = ' gallery_center'; // center galleries on default
- if(!$xalign) $xalign = ' align="center"';
+ if(!$align) $align = ' gallery_normal'; // left align galleries on default
+ if(!$xalign) $xalign = ' align="left"';
}
$page = 0;
@@ -435,9 +458,10 @@ class syntax_plugin_gallery extends DokuWiki_Syntax_Plugin {
}else{ // format as div sequence
$i = 0;
$close_pg = false;
+ $count_pg = ((int) $data['paginate'])? (count($files) / (int) $data['paginate']) : 1;
foreach($files as $img){
- if($data['paginate'] && ($i % $data['paginate'] == 0)){
+ if($data['paginate'] && ($count_pg > 1) && ($i % $data['paginate'] == 0)){
$ret .= '<div class="gallery_page gallery__'.$data['galid'].'" id="gallery__'.$data['galid'].'_'.(++$page).'">';
$close_pg = true;
}
@@ -450,7 +474,7 @@ class syntax_plugin_gallery extends DokuWiki_Syntax_Plugin {
$i++;
- if($data['paginate'] && ($i % $data['paginate'] == 0)){
+ if($data['paginate'] && ($count_pg > 1) && ($i % $data['paginate'] == 0)){
$ret .= '</div>';
$close_pg = false;
}
@@ -527,7 +551,7 @@ class syntax_plugin_gallery extends DokuWiki_Syntax_Plugin {
//prepare link attributes
$a = array();
- $a['title'] = $this->_meta($img,'title');
+ $a['title'] = ($img['title'] == '')? $this->_meta($img,'title') : $img['title'];
if($data['lightbox']){
$href = ml($img['id'],$dim_lightbox);
$a['class'] = "lightbox JSnocheck";