Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
fckimage.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * Image browser from FCKeditor
9  *
10  * @author Anakeen 2007
11  * @version $Id: fckimage.php,v 1.5 2007/12/04 16:04:52 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage
15  */
16 /**
17  */
18 
19 include_once ("FDL/Lib.Dir.php");
20 /**
21  * Image browser from FCKeditor
22  * @param Action &$action current action
23  *
24  */
25 function fckimage(&$action)
26 {
27 
28  $startpage = intval(GetHttpVars("page", "0")); // page number
29  $key = GetHttpVars("key"); // key filter
30  $slice = 28;
31  $dbaccess = $action->GetParam("FREEDOM_DB");
32 
33  if ($startpage == 0) $start = 0;
34  else $start = ($startpage * $slice + 1);
35  $sqlfilters = array();
36  if ($key) $sqlfilters[] = "svalues ~* '" . pg_escape_string($key) . "'";
37  $limg = getChildDoc($dbaccess, 0, $start, $slice, $sqlfilters, $action->user->id, "TABLE", "IMAGE");
38  $wimg = createDoc($dbaccess, "IMAGE", false);
39  $oaimg = $wimg->getAttribute("img_file");
40 
41  foreach ($limg as $k => $img) {
42  $wimg->id = $img["id"];
43  $limg[$k]["imgsrc"] = $wimg->GetHtmlValue($oaimg, $img["img_file"]);
44  $limg[$k]["imgcachesrc"] = str_replace("cache=no", "", $limg[$k]["imgsrc"]);
45  if (preg_match("/vid=([0-9]+)/", $limg[$k]["imgsrc"], $vids)) {
46  $vid = $vids[1];
47  if ($vid > 0) $limg[$k]["imgcachesrc"] = $limg[$k]["imgsrc"] . "&width=100";
48  }
49  }
50 
51  $action->lay->set("key", $key);
52  if (($startpage == 0) && (count($limg) < $slice)) {
53  $action->lay->set("morepages", false);
54  } else {
55 
56  $action->lay->set("morepages", true);
57  $action->lay->set("hppage", true);
58  if ($startpage > 0) $action->lay->set("ppage", $startpage - 1);
59  else $action->lay->set("hppage", false);
60  $action->lay->set("cpage", $startpage + 1);
61  if ($slice == count($limg)) $action->lay->set("npage", $startpage + 1);
62  else $action->lay->set("npage", 0);
63  }
64 
65  $action->lay->setBlockData("IMAGES", $limg);
66  $action->lay->set("NOIMAGES", (count($limg) == 0));
67 }
68 ?>
← centre documentaire © anakeen - published under CC License - Dynacase