Merhaba,
Drupal CMS 'i için ufak bir eklenti hazırladım.
Drupal'in
image Gallery modülünü kullanarak siteye eklenen galerileri/resimleri bir
flash ara birimi olan
Plasmado ile izlemenize olanak tanıyor.
Örneğini
elastik üzerinden görebilirsiniz. Elastik,
Drupal ile yönetilen bir güncel sanat sitesidir ve güncel sanatçıların portfolyolarını içermekte.
Plasmado'yu, galerileri barındırdığım gallery/ dir'ine yerleştirdim. Glaerilere ait resimler de bu dir'in altıdnaki folder'larda. Ekte verdiğim scripti ise CronTab üzerinden belirli aralıklarla çalıştırmaktayım.
Drupal'de galerilerde eklenenleri belirtilen aralıklarla aynı database'de yer alan
Plasmado tablosuna eklemekte.
Plasmado'nun tablosunu eklemek için orjinal
SQL scripti yerine bunu kullanın, scriptte biraz değişiklik yaptım zira.
CREATE TABLE `plasmado` (
`id` bigint(20) NOT NULL auto_increment,
`parent_id` bigint(20) default '0',
`title` varchar(255) default NULL,
`src` varchar(255) default NULL,
`width` int(15) default '0',
`height` int(15) default '0',
`comments` varchar(255) default NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT;
Bu da converter scriptim:
<?PHP
// Drupal2Plasmado converter
// by Cem Gencer, obsesif@gmail.com
//
// Converts database of a Drupal-gallery into Plasmado table
// $termo needs to be changed, reflecting the vocabulary id of your image gallery.
// $sizzle should be a resolution, which YOUR gallery has enabled
// on line 71 i also sue a fixed path, so you need to experiment with it to fir your configuration
// or even remove the str_replace comamnd with a simple
// $file=$details[$sizzle]['fname'];
include_once("config.PHP");
$termo=5; // vocabulary id of the image-gallery
$sizzle="300x400";
$groupId=0;
function doSQL($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
mysql_query("TRUNCATE TABLE plasmado");
$sql1="SELECT * FROM term_hierarchy INNER JOIN term_data ON (term_hierarchy.tid = term_data.tid) WHERE (term_data.vid = 5) AND (term_hierarchy.parent = 0)";
$res1=mysql_query($sql1);
while ($row1=mysql_fetch_object($res1)) {
$sql2=sprintf("insert into plasmado values ('',0,%s,'','','','')",doSQL($row1->name,'text'));
echo($row1->name);
$result=mysql_query($sql2) or die(mysql_error());
}
echo("part1 done....<br>");
$sql3="SELECT * FROM term_hierarchy INNER JOIN term_data ON (term_hierarchy.tid = term_data.tid) WHERE (term_data.vid = 5) AND (term_hierarchy.parent <> 0)";
$res3=mysql_query($sql3);
while ($row3=mysql_fetch_object($res3)) {
$sql8="select * from term_data where tid=".$row3->parent;
$res8=mysql_query($sql8);
$row8=mysql_fetch_object($res8);
$sql4="select * from plasmado where title='".$row8->name."'";
$res4=mysql_query($sql4);
$row4=mysql_fetch_object($res4);
$sql9="insert into plasmado values ('',".$row4->id.",'".$row3->name."','','','','')";
$res9=mysql_query($sql9) or die(mysql_error());
}
echo("part2 done....<br>");
$sql5="SELECT * FROM image INNER JOIN node ON (image.nid = node.nid) INNER JOIN term_node ON (node.nid = term_node.nid) INNER JOIN term_data ON (term_node.tid = term_data.tid) WHERE (node.`type` = 'image') AND (node.`status` = 1) AND (node.`type` = 'image') AND (term_data.vid = 5) ORDER BY term_data.weight, term_data.name, node.nid";
$res5=mysql_query($sql5);
$cnt=1;
while ($row5=mysql_fetch_object($res5)) {
$sql6="select * from plasmado where title='".$row5->name."'";
$sub6=mysql_query($sql6);
$row6=mysql_fetch_object($sub6);
$groupId=$row6->id;
$name=$row5->title;
$details=unserialize($row5->image_list);
$file=str_replace("gallery/","",$details[$sizzle]['fname']);
$info=strip_tags($row6->body);
if(file_exists($file)){
list($width, $height)=getimagesize($file);
$sql7 = "insert into plasmado values ('',$groupId,'$name','$file',$width,$height,'$info')";
$res7 = mysql_query($sql7);
}
}
echo("part3 done....<br>");
?>