Sunday, February 05, 2006

Classic Photo Gallery

Classic Photo Gallery represents equally that follows from the name, i.e. a classical photo gallery.

I have made some changes in files /usr/system/image_resize.inc.php and /usr/system/insert_qcimage.php. Now in parameter QC of a picture with an icon it is possible to specify in parameter resize not height and width but only width, and the height will be automatically selected. In a standard variant we should specify necessarily both height and width, in that case happens, that cut the most interesting part of the image.

Basically, all completely can be understood by looking example DDC and already created galleries. But it is possible to list that has been realized:
  • Creation of albums from admin area;
  • Addition of a photo from admin area;
  • Editing albums and a photo;
  • A paginal conclusion of albums and photos;
  • The opportunity of use the module of the comments working on virtual pages;
Download: classic_gallery.zip
For version: Sapid 1.2.3 RC3

Version with comments (the module and the extension of comments which work on virtual pages are included in archive besides gallery)

Download: classic_gallery+comments.zip
For version: Sapid 1.2.3 RC3

Thursday, February 02, 2006

Bug of sorting by date

One more bug, and in familiar place - in sorting. Binary-safe comparison of values has not coped with correct sorting according to a kind "21/01/2006".

How to struggle? If your purpose stands sorting by field DATE, instead of DATE_CREATE or ID, i.e. during addition of news you add news backdating or on the contrary, you need this cnahges.

So, we open/usr/system/common_extfunctions.inc.php (for the greater clearness in an example I use a standard file, instead of that I already corrected as it was described earlier in it blog). Further we find there such lines:

if(!defined("cmp_indexasc")) {
function cmp_indexasc($a, $b) {
global $sapi_obj;
$index = $sapi_obj->env["index"];
return strcmp($a[$index], $b[$index]);
}
define("cmp_indexasc", 1);
}

if(!defined("cmp_indexdesc")) {
function cmp_indexdesc($a, $b) {
global $sapi_obj;
$index = $sapi_obj->env["index"];
return strcmp($a[$index], $b[$index]);
}
define("cmp_indexdesc", 1);
}
By the way pay attention, here you can see one more bug which is obvious - and in case ASC sorting and in case DESC the same sorting is made. But now we will correct all this bugs. We replace this with the following:

if(!defined("cmp_indexasc")) {
function cmp_indexasc($a, $b) {
global $sapi_obj;
$index = $sapi_obj->env["index"];
if($index=='ID')
return ($a[$index] > $b[$index]) ? -1 : 1;
else if ($index=='DATE'){
$date_a=explode('/',$a[$index]);
$date_b=explode('/',$b[$index]);
$a_index=mktime (0,0,0,$date_a[1], $date_a[0], $date_a[2]);
$b_index=mktime (0,0,0, $date_b[1], $date_b[0], $date_b[2]);
return strcmp($a_index,$b_index);
}
else
return strcmp($a[$index], $b[$index]);
}
define("cmp_indexasc", 1);
}

if(!defined("cmp_indexdesc")) {
function cmp_indexdesc($a, $b) {
global $sapi_obj;
$index = $sapi_obj->env["index"];
if($index=='ID')
return ($a[$index] > $b[$index]) ? 1 : -1;
else if ($index=='DATE'){
$date_a=explode('/',$a[$index]);
$date_b=explode('/',$b[$index]);
$a_index=mktime (0,0,0, $date_a[1],$date_a[0], $date_a[2]);
$b_index=mktime (0,0,0, $date_b[1], $date_b[0], $date_b[2]);
return strcmp($b_index,$a_index);
}
else
return strcmp($b[$index],$a[$index]);
}
define("cmp_indexdesc", 1);
}
Download: common_extfunctions.inc.zip
For verion: Sapid 1.2.3 RC3

If someone will use it, please, tell me about results in comments.

Wednesday, February 01, 2006

get_comments - application for comments

The standard Sapid's module of comments doesn't work on virtual pages. Therefore, I also have made the following extension (and DDC which not strongly differs from the original) which allows to insert comments on virtual pages without any problems. It allows to create new sections, combining, for example, the standard module such as news and the module of comments to create blogs, etc.

I have actually made it for a long time ago, and now just simply put in order, something have corrected.

In archive are submitted following files:
  • /usr/extensions/get_comments.inc.php - the extension;
  • /usr/xml/fullcomments.xml - DDC which can be inserted into others DDC;
  • /mvc/controller/postmethod_analysis.inc.php - this file should be rewritten atop of standard. They differ very little, namely the redirect after addition of the comment on the same page (protection from refresh-flood), and still some insignificant things in section of addition comments.
Download: get_comments.zip
For version: SAPID 1.2.3 RC3
The note: Correct work only with mod_rewrite.