RMCommon Utilities
Red México     EXM System     TemasWeb.com
[ class tree: RMCommon Utilities ] [ index: RMCommon Utilities ] [ all elements ]

Source for file xoopsimg.php

Documentation is available at xoopsimg.php

  1. <?php
  2. // $Id: xoopsimg.php 184 2007-12-22 01:58:57Z BitC3R0 $
  3. // --------------------------------------------------------------
  4. // XOOPS IMAGE - TinyMCE Plugin
  5. // Plugin para el manejo de imágenes XOOPS en TinyMCE
  6. // CopyRight © 2005 - 2006. Red México Soft
  7. // Autor: BitC3R0
  8. // http://www.redmexico.com.mx
  9. // http://www.xoopsmexico.net
  10. // --------------------------------------------
  11. // This program is free software; you can redistribute it and/or
  12. // modify it under the terms of the GNU General Public License as
  13. // published by the Free Software Foundation; either version 2 of
  14. // the License, or (at your option) any later version.
  15. //
  16. // This program is distributed in the hope that it will be useful,
  17. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. // GNU General Public License for more details.
  20. //
  21. // You should have received a copy of the GNU General Public
  22. // License along with this program; if not, write to the Free
  23. // Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. // MA 02111-1307 USA
  25. // --------------------------------------------------------------
  26. // @copyright: 2007 - 2008. BitC3R0. Red México Soft
  27. // @author: BitC3R0
  28.  
  29. $path str_replace("\\""/"__FILE__);
  30. $path str_replace("/rmcommon/tinymce/jscripts/tiny_mce/plugins/xoopsimg/xoopsimg.php"""$path);
  31.  
  32. function displayPage(){
  33.     global $tpl$plugPath;
  34.     
  35.     echo $tpl->fetch($plugPath "xoopsimg.html");
  36.     die();
  37. }
  38.  
  39. require $path '/mainfile.php';
  40. // include Smarty template engine and initialize it
  41. require_once XOOPS_ROOT_PATH '/class/theme.php';
  42. require_once XOOPS_ROOT_PATH '/class/theme_blocks.php';
  43.  
  44. $tpl new XoopsTpl();
  45. $db =$xoopsDB;
  46. $plugPath str_replace("xoopsimg.php","",__FILE__);
  47.  
  48.  
  49. $tpl->assign('xipage'XOOPS_URL.'/viewimg.php');
  50.  
  51.  
  52. // Cargamos las categor?as
  53. $result $db->query("SELECT id_cat FROM ".$db->prefix("images_category")." ORDER BY titulo");
  54. while (list($id$db->fetchRow($result)){
  55.     $catego new XoopsImagecategory($id);
  56.     $read false;
  57.     if ($xoopsUser){
  58.         $read $catego->canRead($xoopsUser->getGroups());
  59.         $write $catego->canWrite($xoopsUser->getGroups());
  60.     else {
  61.         $read $catego->canRead(XOOPS_GROUP_ANONYMOUS);
  62.         $write $catego->canWrite(XOOPS_GROUP_ANONYMOUS);
  63.     }
  64.     if ($read$tpl->append('categos'array('id'=>$catego->id()'title'=>$catego->title()));
  65.     if ($write$tpl->append('wcategos'array('id'=>$catego->id()'title'=>$catego->title()));
  66. }
  67.  
  68. // Seleccionamos las im?genes de la categor?as especificada
  69. foreach ($_GET as $k => $v){
  70.     $$k $v;
  71. }
  72.  
  73. if (!isset($cat|| $cat<=0displayPage();
  74.  
  75. $catego new XoopsImagecategory(intval($cat));
  76. if ($catego->isNew()) displayPage();
  77.  
  78. // Paginamos
  79. $limit = isset($_GET['limite']intval($_GET['limite']10;
  80. $limit $limit<=10 $limit;
  81. $tpl->assign('limite'$limit);
  82.  
  83. $sql "SELECT COUNT(*) FROM ".$db->prefix("images").($cat>" WHERE category='$cat''');
  84. list($num$db->fetchRow($db->query($sql));
  85.  
  86. $page = isset($_REQUEST['pag']intval($_REQUEST['pag']0;
  87. if ($page 0)$page -= 1}
  88. $tpages = (int)($num $limit);
  89. if ($page>$tpages$page $tpages;
  90. $start $page $limit;
  91. if($num $limit 0$tpages++;
  92. $pactual $page 1;
  93. if ($pactual>$tpages){
  94.     $rest $pactual $tpages;
  95.     $pactual $pactual $rest 1;
  96.     $start ($pactual 1$limit;
  97. }
  98.  
  99. $tpl->assign('pactual'$pactual);
  100. $tpl->assign('tpages'$tpages);
  101. $showmax $start $limit;
  102. $showmax $showmax $num $num $showmax;
  103.  
  104. if ($pactual 1){
  105.     if ($pactual>&& $tpages 11){
  106.         $tpl->append('pages'array('id'=>'primera''num'=>1));
  107.     }
  108.     $tpl->append('pages'array('id'=>'anterior''num'=>($pactual-1)));
  109. }
  110.  
  111. $pstart $pactual-4>$pactual-1;
  112. $pend ($pstart 8)<=$tpages ($pstart 8$tpages;
  113.  
  114. if ($pstart && $tpages>11){
  115.     $tpl->append('pages'array('id'=>3,'salto'=>1,'num'=>3));
  116. }
  117.  
  118. if ($tpages 0){
  119.     for ($i=$pstart;$i<=$pend;$i++){
  120.         $tpl->append('pages'array('id'=>$i,'num'=>$i));
  121.     }
  122. }
  123.  
  124. if ($pend $tpages-&& $tpages>11){
  125.     $tpl->append('pages'array('id'=>$tpages-3,'salto'=>2,'num'=>($tpages 3)));
  126. }
  127.  
  128. if ($pactual $tpages && $tpages 1){
  129.     $tpl->append('pages'array('id'=>'siguiente''num'=>($pactual+1)));
  130.     if ($pactual $tpages-&& $tpages 11){
  131.         $tpl->append('pages'array('id'=>'ultima''num'=>$tpages));
  132.     }
  133. }
  134.     
  135. $sql "SELECT * FROM ".$db->prefix("images").($cat>" WHERE category='$cat''')." ORDER BY fecha DESC LIMIT $start$limit";
  136. $result $db->queryF($sql);
  137.  
  138. if ($db->getRowsNum($result)<=0displayPage();
  139.  
  140. $caturl $catego->url();
  141. // Archivo despachador de im?genes
  142. $imgfile XOOPS_URL.'/image.php';
  143.  
  144. while ($row $db->fetchArray($result)){
  145.     if ($catego->thumbnails()){
  146.         $file $row['ondb'$imgfile.'?type=t&id='.$row['id_img'($catego->hotlink($imgfile.'?type=t&id='.$row['id_img'].'&p=1' $caturl '/ths/' $row['archivo']);
  147.         $bigfile $row['ondb'$imgfile.'?type=n&id='.$row['id_img'($catego->hotlink($imgfile.'?type=n&id='.$row['id_img'].'&p=1' $caturl '/' $row['archivo']);
  148.     else {
  149.         $file $row['ondb'$imgfile.'?type=n&id='.$row['id_img'($catego->hotlink($imgfile.'?type=n&id='.$row['id_img'].'&p=1' $caturl '/' $row['archivo']);
  150.         $bigfile $file;
  151.     }
  152.     $tpl->append('images'array('id'=>$row['id_img']'title'=>$row['titulo']
  153.             'file'=>$file'big'=>$bigfile'date'=>date($xoopsConfig['datestring']$row['fecha'])
  154.             'desc'=>$row['desc']!='' 0'filename'=>$row['archivo'],));
  155. }
  156.  
  157. $tpl->assign('catego'array('id'=>$catego->id()'title'=>$catego->title()'thumbnails'=>$catego->thumbnails(),
  158.             'url'=>$catego->url()'thw'=>$catego->thumbWidth()'thh'=>$catego->thumbHeight()
  159.             'imgw'=>$catego->imageWidth()'imgh'=>$catego->imageHeight(),'protect'=>$catego->hotlink()));
  160. $tpl->assign('cat'$cat);
  161.  
  162. $cols = isset($_GET['cols']intval($_GET['cols']3;
  163. $cols $cols<=$cols;
  164. $tpl->assign('cols'$cols);
  165.     
  166. // Mostramos las im?genes
  167.  
  168. ?>

Documentation generated by phpDocumentor 1.4.0a2

Copyright © 2007 - 2008 Red México.