We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9757
    • 82 Posts
    I’m using e2g 1.4.0-beta4 and I’ve got this error when there are no files in the main (root) folder:

    Warning: array_diff() [function.array-diff]: Argument #1 is not an array in /home/user/domains/domain.net/public_html/assets/modules/easy2/classes/e2g.module.class.php  on line 1012
    
    Warning: natsort() [function.natsort]: The argument should be an array in /home/user/domains/domain.net/public_html/assets/modules/easy2/classes/e2g.module.class.php on line 1013


    When I upload at least 1 file everything is fine.

    There is a similar problem, when I create a folder and enter it:
    Warning: natsort() [function.natsort]: The argument should be an array in /home/user/domains/domain.net/public_html/assets/modules/easy2/classes/e2g.module.class.php  on line 876


    This one is showing even if I upload some files to that folder.

    I’ve made a quite simple fix that works for me, but I didn’t tested it well:

    From line 874 in e2g.module.class.php"
    // Dir list
    $dirs = glob('../'.$gdir.'*', GLOB_ONLYDIR);
    if(is_array($dirs)){
    	natsort($dirs);
    }
    


    and from line 1014:
    $getdir = glob('../'.$gdir.'*.*');
    if(is_array($getdir)){
    	$files = array_diff($getdir, $excludefiles);
    	natsort($files);
    }
    


    BTW. I’m making a polish translation for e2g, I’ll send it quite soon.

    What do you think about implementing SWFUpload?

    I really wanna thank you for this module smiley I think it has a great potential!
      • 11055 ☆ A M B ☆
      • 3,112 Posts
      Quote from: fixedmachine at May 01, 2010, 11:16 PM

      I’m using e2g 1.4.0-beta4 and I’ve got this error when there are no files in the main (root) folder:
      Warning: array_diff() [function.array-diff]: Argument #1 is not an array in /home/user/domains/domain.net/public_html/assets/modules/easy2/classes/e2g.module.class.php  on line 1012
      Warning: natsort() [function.natsort]: The argument should be an array in /home/user/domains/domain.net/public_html/assets/modules/easy2/classes/e2g.module.class.php on line 1013

      When I upload at least 1 file everything is fine.
      There is a similar problem, when I create a folder and enter it:
      Warning: natsort() [function.natsort]: The argument should be an array in /home/user/domains/domain.net/public_html/assets/modules/easy2/classes/e2g.module.class.php  on line 876

      This one is showing even if I upload some files to that folder.
      Yeah...
      I got similar reports, too. But since I didn’t get it in my Windows box, I always forgot. I’ll try to use your methods below, and I’ll see more reports coming.

      Quote from: fixedmachine at May 01, 2010, 11:16 PM

      I’ve made a quite simple fix that works for me, but I didn’t tested it well:
      From line 874 in e2g.module.class.php"
      // Dir list
      $dirs = glob('../'.$gdir.'*', GLOB_ONLYDIR);
      if(is_array($dirs)){
      	natsort($dirs);
      }
      

      and from line 1014:
      $getdir = glob('../'.$gdir.'*.*');
      if(is_array($getdir)){
      	$files = array_diff($getdir, $excludefiles);
      	natsort($files);
      }
      

      These should work.

      How about this ?
      <?php // highligthing
      // Dir list
      $dirs = @glob('../'.$gdir.'*', GLOB_ONLYDIR);
      if(is_array($dirs)) natsort($dirs);
      

      And this:
      <?php // highligthing
      $files = array_diff(@glob('../'.$gdir.'*.*'), $excludefiles);
      if(is_array($files)) natsort($files);
      


      Quote from: fixedmachine at May 01, 2010, 11:16 PM

      BTW. I’m making a polish translation for e2g, I’ll send it quite soon.
      Thx. laugh
      You can post that into the issue list on the google code, so it can be downloaded directly if I haven’t released the revision version.
      Install language and the module one. wink

      Quote from: fixedmachine at May 01, 2010, 11:16 PM

      What do you think about implementing SWFUpload?
      I’ll try.
      Quote from: fixedmachine at May 01, 2010, 11:16 PM

      I really wanna thank you for this module smiley I think it has a great potential!
      Thx to the predecessors. laugh
        Rico
        Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
        MODx is great, but knowing how to use it well makes it perfect!

        www.virtudraft.com

        Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

        Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

        Maintainter/contributor of Babel

        Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
        • 11055 ☆ A M B ☆
        • 3,112 Posts
        Quote from: mconsidine at Apr 30, 2010, 01:24 PM

        I’m looking forward to the new additions. Any thoughts on how hard it would be to add the area tagging ability that is outlined (using a bit of Javascript) here :

        http://blog.neillh.com.au/2010/03/29/photo-tagging-version-2/

        I had gotten it to work with MaxiGallery but haven’t gone further with it (ie. to make the tags accessible by other MODx snippets for categorization, etc.)

        MattC
        I read these (also your snippet).
        I wonder where I should put this option.
          Rico
          Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
          MODx is great, but knowing how to use it well makes it perfect!

          www.virtudraft.com

          Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

          Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

          Maintainter/contributor of Babel

          Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
          • 18913
          • 654 Posts
          Hi goldsky,
          First off, thanks again for all your work and for adding the smooth gallery effects. The sliding transition works well.

          On the image tagging : I’m not sure where to add this either. I started hacking around the code a bit to see what I could do and didn’t make much progress. It’s almost like it should be enabled only during the viewing of a single image. What I had done with MaxiGallery was
          - add the javascript calls to the top of a document template
          - created three snippets : phototagging_function, phototagging_form and phototagging_form2
          Noting that none of the code below is polished or working as intended :
          The code for the "function" snippet was
          <?php
          global $modx;
          	
          	//Function to sanitize values received from the form. Prevents SQL injection
          	function clean($str) {
          		$str = @trim($str);
          		if(get_magic_quotes_gpc()) {
          			$str = stripslashes($str);
          		}
          		return $str; //$modx->db->escape($str);
          	}
          	if($_POST['tag']) {
          		//Sanitize the POST values
          		$title = clean($_POST['title']);
          		$x1 = $_POST['x1'];
          		$y1 = $_POST['y1'];
          		$w = $_POST['w'];
          		$h = $_POST['h'];
                          $pic = $_GET['pic'];
          
          		//Insert tag into database. I am capturing more data than needed from a previous version but this could be useful oneday.
          		$qry = " INSERT INTO phototags (rec_id, title, x1, y1, x2, y2, width, height,pic) " .
          		" VALUES('', '".$title."', '".$x1."', '".$y1."', '".$_POST['x2']."', '".$_POST['y2']."', '".$w."', '".$h."', '".$pic."') "; 
          		$result=$modx->db->query($qry);  //MattC
          	} elseif($_GET['delete']) {
          		//Sanitize the POST values
          		$rec_id = clean($_GET['rec_id']);
          		$qry = " DELETE FROM phototags where rec_id = $rec_id ";  //MattC
          		$result=$modx->db->query($qry);  //MattC
          	}
          return;
          ?>

          The code for the "form" function was :
          <?php
          $pic = $_GET['pic'];
          $output = '';
          
          $output .= '<div class="start-tagging">Click here to start tagging</div><!-- class start tagging -->';
          $output .= '<div class="finish-tagging hide">Click here to cancel tagging</div><!-- class finish tagging -->';
          $output .= '<div class="image">';
          $output .= '  <div id="title_container" class="hide">';
          $output .= '	<form method="post" action="[~[*id*]~]?pic=' . $pic . '" >';
          $output .= '		<!-- Grab the X/Y/Width/Height -->';
          $output .= '		<input type="hidden" name="x1" id="x1" value="' . $x1 . '" />';
          $output .= '		<input type="hidden" name="y1" id="y1" value="' . $y1 . '" />';
          $output .= '		<input type="hidden" name="x2" id="x2" value="' . $x2 . '" />';
          $output .= '		<input type="hidden" name="y2" id="y2" value="' . $y2 . '" />';
          $output .= '		<input type="hidden" name="w" id="w" value="' . $w . '" />';
          $output .= '		<input type="hidden" name="h" id="h" value="' . $h . '" />';
          $output .= '		<input type="hidden" name="pic" id="pic" value="' . $pic . '" />';
          $output .= '		<label for="title">Tag text</label><br />';
          $output .= '		<input type="text" id="title" name="title" size="30" value="" maxlength="55" /><br />';
          $output .= '		<input type="hidden" name="tag" value="true" />';
          $output .= '		<input type="submit" value="Submit" class="" />';
          $output .= '	</form>';
          $output .= '  </div><!-- id title container -->';
          
          return $output;
          ?>


          And the code for the "form2" snippet was
          <?php
          global $x1, $y1, $x2, $y2, $w, $h;
          
          $pic = $_GET['pic'];
          
          $output = '';
          
          $list_tags = array();
          
          $qry = " SELECT rec_id, title, x1, y1, x2, y2, width, height FROM phototags WHERE pic=".$pic;
          
          $results=$modx->db->query($qry) or die("Error retrieving record: " . mysql_error());
          while ($row=$modx->db->getRow($results)) 
          {
            extract ($row);
            $name = str_replace(' ', '-', $title);
            $list_tags[] = array('rec_id' => $rec_id, 'title' => $title);
          
            $output .= 	'<!-- Style for the tagged area -->';
            $output .= 	'<style type="text/css">';
            $output .= 	'	.map a.'.$name.' { border:1px solid #000; top:'.$y1.'px; left:'.$x1.'px; width:'.$width.'px; height:'.$height.'px; }';
            $output .= 	'	.map a:hover.'.$name.' { border:3px solid #fff; }';
            $output .= 	'</style>';
            $output .= 	'<!-- Tags displayed as a list -->';
            $output .= 	'<ul class="map">';
            $output .= 	'	<li><a class="'.$name.'"><span><b>'.$title.'</b></span></a></li>';
            $output .= 	'</ul>';
          }
          
          $output .= '</div><!-- class image -->';
          //$output .= $qry.'<br />';
          //$output .= 'Pic = '.$pic.' Rec id = '.$rec_id.' x1 = '.$x1.' w = '.$w.'<br />'; 
          $output .= '<p>In this photo:';
          
          foreach ($list_tags as $value)
          {
              $output .= "<a href='" . str_replace(' ', '-',$value['title']) . "'>" . $value['title'] . "</a> (<a href='[~[*id*]~]&pic=".$pic."&delete=true&rec_id=" . $value['rec_id'] . "'>Delete</a>)  ";
          }
          
          $output .= '</p>';
          
          return $output;
          ?>


          The "function" code went just after the opening body tag in the document template. The "form" snippets were called in the template used by Maxigallery to display an image (the first one was called just after the opening "picture" tag and the last called just before the closing "picture" div tag). Where I ran into problems was in the positioning of the boxes relative to the placement of the image, which could change based on styling. Also, the "z-index" settings had to be adjusted relative to the CSS I was testing with, in order to get the text box for the area tag to be accessible.

          In trying to adapt that to your code, I thought I could place it in a gallery template. But it looks like the code just gets offered up rather than parsed. So I added "$modx->runSnippet" commands to append the output but still did not get it work. Not having a very good idea of how your code is set up, I didn’t go any further.

          I guess the issue is that the tagging ability *ought* to be available in any of the effects selected, but I don’t know how for example it would work in a popup/lightbox view. Also, it might be too problematic to try to figure out how to get it to work with the different gallery implementations.

          If you’ve got any suggestions, I’m willing to try them out and report back.

          Thanks again!
          Matt
            • 11055 ☆ A M B ☆
            • 3,112 Posts
            I’m about to add a new parameter: &landingpage (just like AJAXSEARCH’s term), to escape the image hyperlink to a web-page, not into iframe.
            Perhaps you can use it over there.
              Rico
              Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
              MODx is great, but knowing how to use it well makes it perfect!

              www.virtudraft.com

              Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

              Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

              Maintainter/contributor of Babel

              Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
              • 6848
              • 52 Posts
              Hi,
              I saw you simplified the directory thumbnail creation, which is not bad,
              but this leads to the fact that nested galleries (folders) are not shown if the parent doesn’t have an image inside.
              Which is also not so problematic, but in some cases doesn’t look good with many folders and single image

              So I uncommented the code you have put form one of my posts and did slight modifications to the code in dirs thumbs part:
                              // SUBDIRS & THUMBS FOR SUBDIRS
                              $query = 'SELECT DISTINCT d.* '
                                      . 'FROM '.$modx->db->config['table_prefix'].'easy2_dirs AS d '
                                      . 'LEFT JOIN '.$modx->db->config['table_prefix'].'easy2_files AS f '
                                      . 'ON d.cat_id = f.dir_id '
                                      . 'WHERE d.parent_id = ' . $single_gid . ' '
                                      . 'AND d.cat_visible = 1 '
              //                        . 'AND (SELECT COUNT(*) '
              //                                .'FROM '.$modx->db->config['table_prefix'].'easy2_files AS f '
              //                                .'WHERE f.dir_id = d.cat_id '
              //                                .')<>0 '
                                      . 'ORDER BY ' . $cat_orderby . ' ' . $cat_order . ' '
                                      . 'LIMIT ' . ( $gpn * $limit ) . ', ' . $limit // goldsky -- limit the subdirs per page
                                      ;
                              //echo $query;
                              $dirquery = mysql_query($query);
                              if (!$dirquery) die('179 '.mysql_error());
                              $dir_num_rows += mysql_num_rows($dirquery);
              
                              $i = 0;
                              while ($l = mysql_fetch_array($dirquery, MYSQL_ASSOC)) {
              
                                  // search image for subdir
                                  $l1=$this->_get_folder_img($l['cat_id']);
                                  // if there is an empty folder, or invalid content
                                  if (!$l1) {
                                      $dir_num_rows-=1;
                                      $dir_count-=1 //this is not in the attached snippet, I saw it later
                                      // Aren't the 2 lines above needed independent on the way the thumb is fetched?
                                      continue;
                                  }
                                  $l['count'] = $l1['count']; 
                                  // What is the purpose of the above line? Looks to me like started code for future showing of number of images in a folder?
                                  // I would not implement such a feature, because with subfolders it is not clear what to show
              


              (find attached the modified snippet)

              I didn’t test extensively the code (specially for the $dir_num_rows behavior) but up to now didn’t see problem with it.
              And I don’t have any performance problems with this modification.

              If you think the code is OK it is probably more functional this way than to require an image in each folder?
                • 6848
                • 52 Posts
                Small defect, related to the usage of rich text editor.
                With the default thumbnail template:
                ...title="[+easy2:title+] - [+easy2:description+]" ...

                and (I think) default configuration of tinymce the result is something like that:
                ...title="Image Title - <p>Image Description</p>" ...


                This result is not shown correctly in most of the presentation libraries (with their default configuration) used.

                I would think to:

                1. Forget about the usage of tinymce for description. This is probably simplest, but not the best, because in some cases one may need formated description
                2. Cleanup the title tag per library used
                3. Add to the help some explanation about the results. This is probably the best option.


                  • 11055 ☆ A M B ☆
                  • 3,112 Posts
                  @ddim
                  Thank you so much for your more reports.

                  The SQL is to pass over an empty folder (really empty).
                  <?php // highligthing
                  // These all are about pagination counting. See more code below them on pagination part.
                  $dir_num_rows-=1;
                  $dir_count-=1
                  

                  If you change this, you’ll get awkward result in the calculation, especially around line 324.
                  <?php // highligthing
                  $total_count = $dir_count+$file_count;
                  

                  And don’t forget that there is also this parameter: &showonly (images|folders).
                  The pagination must also calculate this.
                  Try to die(’182 ’.$dir_num_rows); at line 182, while you’re having an empty folder.

                  <?php // highligthing
                  $l['count'] = $l1['count']; 
                  

                  Remember, all the $l (particularly in the looping image retrieval) arrays are the _filler feeder.
                  <?php // highligthing
                  $this->_filler($this->_dir_tpl($cl_cfg), $l)
                  

                  About the count, it feeds the directory template as a placeholder, which you’ll find its purpose in the directory.htm template:
                  <!-- ([+easy2:count+])-->
                  

                  Now you know its purpose, I bet you’ll create more placeholders brutally. laugh

                  Start to think these most important two points first on investigating the SQL code:
                  1. thumbnail image
                  2. pagination

                  BUT,
                  I got your idea, of nesting folders, which the parent has no image inside but the child does.
                  Even more, the child does not, but the grand-grand-grand child does (let’s think about the categorization folders, eg: species)
                  The challenge is how we should grab the folder’s thumbnail.
                  This should be done by a recursive function.
                  I’ll try something, or you can just tell me if you have any better idea.

                  Wow...
                  This become more perfect. laugh

                  About RTE,
                  I agree. I’m dropping it.
                    Rico
                    Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
                    MODx is great, but knowing how to use it well makes it perfect!

                    www.virtudraft.com

                    Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

                    Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

                    Maintainter/contributor of Babel

                    Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
                    • 6848
                    • 52 Posts
                    @goldsky
                    Hi,

                    This construct in _get_folder_img function:
                            $q1 =  'SELECT F.* '
                                    . 'FROM '. $modx->db->config['table_prefix'].'easy2_files F '
                                    . 'WHERE F.dir_id in (SELECT A.cat_id FROM '
                                    . $modx->db->config['table_prefix'].'easy2_dirs A, '
                                    . $modx->db->config['table_prefix'].'easy2_dirs B '
                                    . 'WHERE (B.cat_id=' . $gid . ' '
                                    . 'AND A.cat_left >= B.cat_left '
                                    . 'AND A.cat_right <= B.cat_right '
                                    . 'AND A.cat_level >= B.cat_level '
                                    . 'AND A.cat_visible = 1) '
                                    . 'ORDER BY A.cat_level ASC ) '
                                    . 'ORDER BY F.id DESC '
                                    . 'LIMIT 1 '
                            ;
                            $res = mysql_query($q1);
                            $result = mysql_fetch_array($res, MYSQL_ASSOC);
                    

                    Will return a record with image for a folder if there is an image inside the folder, its child or any level of grand child.
                    The SQL is fast. I tested some months ago on a gallery with more than 100 folders and more than 2000 images (it vas version 1.3x of the gallery)

                    I agree, that reduction of $dir_num_rows and $dir_count based on the returned or not image might introduce interesting results smiley. The question is how to modify the code:
                                    $query = 'SELECT DISTINCT d.* '
                                            . 'FROM '.$modx->db->config['table_prefix'].'easy2_dirs AS d '
                                            . 'LEFT JOIN '.$modx->db->config['table_prefix'].'easy2_files AS f '
                                            . 'ON d.cat_id = f.dir_id '
                                            . 'WHERE d.parent_id = ' . $single_gid . ' '
                                            . 'AND d.cat_visible = 1 '
                                            . 'AND (SELECT COUNT(*) '
                                                    .'FROM '.$modx->db->config['table_prefix'].'easy2_files AS f '
                                                    .'WHERE f.dir_id = d.cat_id '
                                                    .')<>0 '
                                            . 'ORDER BY ' . $cat_orderby . ' ' . $cat_order . ' '
                                            . 'LIMIT ' . ( $gpn * $limit ) . ', ' . $limit // goldsky -- limit the subdirs per page
                                            ;
                    
                    


                    In the part:

                                            . 'AND (SELECT COUNT(*) '
                                                    .'FROM '.$modx->db->config['table_prefix'].'easy2_files AS f '
                                                    .'WHERE f.dir_id = d.cat_id '
                                                    .')<>0 '
                    


                    I will think about it.

                      • 6848
                      • 52 Posts
                      @goldsky

                      I think the attached snippet fixes the issue with nested folders without images in the parent and getting folder image from children.
                      The changes are in $dir_count query, in $dir_num_rows query and in _get_folder_img query.

                      I tested it with a gallery with 120 folders and more than 2000 images and the performance is acceptable
                      $dir_count needs approx 0.3 sec
                      $dir_num_rows without limit needs approx 1 sec
                      $dir_num_rows with limit 12 needs less than 0.01 sec
                      12 calls to _get_folder_img (limit of 12 per page) need 0.1 sec

                      With this gallery I cannot test with empty folders, nested folders and so on, so this test I did with small gallery and didn’t find problems.
                      But it definitely needs more testing.