Sunday, August 13, 2006

get_mysql v0.9

get_mysql is an extension for using data from MySQL.

All needed information in Readme.

In archive you can find three examples:

• get_mysql_news.xml –news line;
• get_mysql_catalog.xml – catalog;
• get_mysql_search.xml – search for catalog.

Download: get_mysql.zip
For version: Sapid 1.2.3.06

Friday, March 24, 2006

Themes for admin area

It is dirty work, but someone should do it. At last I finished Sapid extension for changing decoration themes of admin area. It is not a beta, only alpha version yet. But it works. Even one theme was designed by me :) If someone interested in it, please, test it and tell me about your experience here in comments.

Download: themes.zip
For version: Sapid CMS 1.2.3.06

Friday, March 03, 2006

Bug with definition of GD. Attempt #2

I have decided to go by the simple way, but 100% correct. If function createimagetruecolor() exists it is determined as GD2 if is not - present GD. Actually, likely, only I still have GD, therefore I had problems with it.
In a file /usr/system/image_resize.inc.php instead of it (contents standard file /usr/system/image_resize.inc.php from Sapid 1.2.3.06):
function _sysB_chkgd2()
{
$rep=false;
if(isset($GLOBALS["gBGDVersion"])) {
$rep=$GLOBALS["gBGDVersion"];
} else {
if(function_exists("gd_info")) {
$gdver=gd_info();
$GLOBALS["gBGDVersion"]=$rep=preg_replace("/^(.*)(\d+?\.?\d+?\.?)(.*)$/", "\\2", $gdver["GD Version"]);
} else {
$arr=get_loaded_extensions();
if(in_array("gd", $arr) and $im=@imagecreatetruecolor(1,1)) {
imagedestroy($im);
$GLOBALS["gBGDVersion"]=$rep="2.0";
}elseif (in_array("gd", $arr) and $im=@imagecreate(1,1)){
imagedestroy($im);
$GLOBALS["gBGDVersion"]=$rep="1.6";
}
}
}
return $GLOBALS["gBGDVersion"];
}
Input next:
function _sysB_chkgd2()
{
$rep=false;
if(isset($GLOBALS["gBGDVersion"])) {
$rep=$GLOBALS["gBGDVersion"];
} else {
$arr=get_loaded_extensions();
if(in_array("gd", $arr) and function_exists(imagecreatetruecolor)) {
$GLOBALS["gBGDVersion"]=$rep="2.0";
}elseif (in_array("gd", $arr) and !function_exists(imagecreatetruecolor)){
$GLOBALS["gBGDVersion"]=$rep="1.6";
}
}
return $GLOBALS["gBGDVersion"];
}
It's all.

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.

Thursday, January 26, 2006

Bug of sorting numerical values

The bug consists in not correct comparison of two numerical values in sorting functions of a file /usr/system/common_extfunctions.inc.php. I.e., for example, we sort on ID, we have records with ID: 1,2,3,4,5,6,7,8,9,10,11 in database. After performance of sorting _ORDER (INDEX, ID, ASC) _ in application get_infochannel (or anyone similar) the result will be following: 1,10,11,2,3,4,5,6,7,8,9.

Here it is an example of what there was and on what I have changed it, I'll not explain, who knows - all easily will understand:
// What there was
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);
}

// On what we change
if(!defined("cmp_indexasc")) {
function cmp_indexasc($a, $b) {
global $sapi_obj;
$index = $sapi_obj->env["index"];
if(is_numeric($a[$index]))
return ($a[$index] > $b[$index]) ? -1 : 1;
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(is_numeric($a[$index]))
return ($a[$index] > $b[$index]) ? 1 : -1;
else
return strcmp($a[$index], $b[$index]);
}
define("cmp_indexdesc", 1);
}
Also I offer to download already corrected file if suddenly someone laziness to correct it by himself ;)

Download: common_extfunctions.inc.zip
For version: Sapid 1.2.3 RC3