Announcement

  •  » Extensions
  •  » Advanced Menu Manager improvements

#1 2014-09-25 16:10:59

JanisV
Member
2013-09-25
85

Advanced Menu Manager improvements

Hi,

I need a more perfect random picture block of Advanced Menu Manager. I want use a square images with a different height. So, here a patch for replace thumbnails images with square with width and height from 'Height of menu block' option:

Code:

amm_pip.class.inc.php
@@ -476,6 +476,12 @@
     $result = pwg_query($sql);
     if($result)
     {
+      $height = $this->config['amm_randompicture_height'];
+      if($height == 0)
+        $derivative_params = ImageStdParams::get_by_type(IMG_SQUARE);
+      else
+        $derivative_params = ImageStdParams::get_custom($height, $height, 1, $height, $height);
+
       while($row=pwg_db_fetch_assoc($result))
       {
         $row['section']='category';
@@ -486,7 +492,8 @@
         );

         $row['link']=make_picture_url($row);
-        $row['thumb']=DerivativeImage::thumb_url(array('id'=>$row['image_id'], 'path'=>$row['path']));
+        $infos = array('id'=>$row['image_id'], 'path'=>$row['path']);
+        $row['thumb']=DerivativeImage::url($derivative_params, $infos);

         $returned[]=$row;
       }

Will be greate if somebody add a 'Enable square' option into config and add this code to svn.

Offline

 

#2 2014-09-25 17:30:41

JanisV
Member
2013-09-25
85

Re: Advanced Menu Manager improvements

And patch for updated rotation script:

Code:

Index: amm_pip.class.inc.php
===================================================================
@@ -86,7 +86,7 @@
       )
     {
       GPCCore::addHeaderJS('jquery', 'themes/default/js/jquery.min.js');
-      GPCCore::addHeaderJS('amm.randomPictPublic', 'plugins/AMenuManager/js/amm_randomPictPublic.js', array('jquery'));
+//      GPCCore::addHeaderJS('amm.randomPictPublic', 'plugins/AMenuManager/js/amm_randomPictPublic.js', array('jquery'));

       $block->set_title(base64_decode($this->config['amm_randompicture_title'][$user['language']]));
       $block->template=dirname(__FILE__).'/menu_templates/menubar_randompic.tpl';

Index: menu_templates/menubar_randompic.js.tpl
===================================================================
@@ -19,5 +19,50 @@
     };
</script>
{/literal}
+
+<script type="text/javascript">
+$(function() {
+  $('#iamm_ill0').width({$data.blockHeight});
+  $('#iamm_ill0').height({$data.blockHeight});
+
+  var randomPict = randomPictOpt['pictures'];
+  if (randomPict.length > 1) {
+    $('#iamm_ill0 a').attr("href", randomPict[0]['link']);
+    $('#iamm_ill0 img').attr("src", randomPict[0]['thumb']);
+
+    var nextFaderPos = 1;
+    var duration = 400;
+    var pause = false;
+
+    $('#iamm_ill0 img').after('<img id="iammRPicImg">');
+    $('#iamm_ill0 img').eq(1).hide();
+    $('#iamm_ill0 img')[1].src = randomPict[1]['thumb'];
+    $('#iamm_ill0 img').css('position', 'absolute');
+
+    $('#iamm_ill0').hover(function() {
+        pause = true;
+    },function() {
+        pause = false;
+    });
+
+    function doRotate() {
+        if ($('#iamm_ill0 img')[1].complete) {
+            if(!pause) {
+                $('#iamm_ill0 img').first().fadeOut(duration, function() {
+                    nextFaderPos = (nextFaderPos + 1) % randomPict.length;
+                    $('#iamm_ill0 img')[1].src = randomPict[nextFaderPos]['thumb'];
+                });
+                $('#iamm_ill0 img').first().insertAfter($('#iamm_ill0 img').eq(1)); // swap
+                $('#iamm_ill0 img').first().fadeIn(duration);
+                setTimeout(function() {
+                  $('#iamm_ill0 a').attr("href", randomPict[nextFaderPos]['link']);
+                }, duration/3);
+            }
+        }
+    }
+
+    var rotate = setInterval(doRotate, {$data.delay});
+  }
+});
+</script>

Index: menu_templates/menubar_randompic.tpl
===================================================================
@@ -4,7 +4,7 @@
 <dd id="irandompicdd" class="randompicdd">
   <div id="irandompicinner" class="illustration">
     <div class="ammillustrationc">
-      <div id="iamm_ill0" class="ammillustration">
+      <div id="iamm_ill0" class="ammillustration" style="text-align: left;">
         <span id='iammRPicNameO' style='display:none;'></span>
         <span id='iammRPicCommentO' style='display:none;'></span>
         <a id='iammRPicLink' ><img id="iammRPicImg"/></a>

This enable lazy loading for random image block (picture name and comment not yet work), pause rotation when cursor under image.

Last edited by JanisV (2014-09-25 17:43:08)

Offline

 

#3 2014-10-13 16:37:57

JanisV
Member
2013-09-25
85

Re: Advanced Menu Manager improvements

One more improvements:

Code:

amm_pip.class.inc.php
@@ -476,9 +477,15 @@
     $result = pwg_query($sql);
     if($result)
     {
       while($row=pwg_db_fetch_assoc($result))
       {
-        $row['section']='category';
+        $row['section']='categories';
         $row['category']=array(
           'id' => $row['catid'],
           'name' => $row['name'],

This fix change change image link to image in album, not in set of all images. Useful for very large galleries.

Offline

 

#4 2014-10-13 19:56:19

flop25
Piwigo Team
2006-07-06
7036

Re: Advanced Menu Manager improvements

Hi
Pierrick could allow you to commit for that plugin then we add you as co author on the PEM


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#5 2014-10-13 21:19:29

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13526

Re: Advanced Menu Manager improvements

JanisV, now you have write access on http://piwigo.org/svn/extensions/AMenuManager

Offline

 

#6 2014-10-13 21:29:01

flop25
Piwigo Team
2006-07-06
7036

Re: Advanced Menu Manager improvements

and you're now co author of AMM :)


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#7 2014-10-13 21:44:28

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13526

Re: Advanced Menu Manager improvements

As often discussed with mistic and ddtddt, I don't think it's a good idea (for the long run) to maintain Advanced Menu Manager. We'd better create several simpler plugins (not based on plugin GPC) :

* Menu Random Photo
* Custom Menu
* Menu Links
(* Album to Menu Block)

+ core features to manage content of menus "Menus & Specials"

That would make the whole system much simpler to maintain (if code is simpler than AMenuManager)

Offline

 

#8 2014-10-13 22:49:10

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13526

Re: Advanced Menu Manager improvements

flop25 wrote:

and you're now co author of AMM :)

Not yet, first I request the authorization of grum :-)

Offline

 

#9 2014-10-14 09:54:07

JanisV
Member
2013-09-25
85

Re: Advanced Menu Manager improvements

plg wrote:

As often discussed with mistic and ddtddt, I don't think it's a good idea (for the long run) to maintain Advanced Menu Manager. We'd better create several simpler plugins (not based on plugin GPC) :

* Menu Random Photo
* Custom Menu
* Menu Links
(* Album to Menu Block)

+ core features to manage content of menus "Menus & Specials"

That would make the whole system much simpler to maintain (if code is simpler than AMenuManager)

Yes, I will move Menu Random Photo with my changes into separate plugin without extra features.

I'm not more need write access to AMM.

Offline

 

#10 2014-10-14 09:57:44

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13526

Re: Advanced Menu Manager improvements

OK, perfect. Make your code simple :-) If you study code of the random picture, you will see that I have implemented a cache to avoid to many SQL query with ORDER BY RAND() because it is very slow on big galleries.

Offline

 

#11 2014-10-14 16:00:44

JanisV
Member
2013-09-25
85

Re: Advanced Menu Manager improvements

All improvements implemented in [extension by JanisV] Menu Random Photo

Offline

 
  •  » Extensions
  •  » Advanced Menu Manager improvements

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2022 · Contact