Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
ckimage.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Image browser from CKeditor
8  *
9  * @author Anakeen
10  * @version $Id: fckimage.php,v 1.5 2007/12/04 16:04:52 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
17 include_once "FDL/Lib.Dir.php";
18 /**
19  * Image browser from CKeditor
20  * @param Action &$action current action
21  *
22  */
23 function ckimage(Action & $action)
24 {
25  $err = "";
26 
27  $usage = new ActionUsage($action);
28  /* Internal numFunc */
29  $numFunc = $usage->addRequiredParameter("CKEditorFuncNum", "CKEditorFuncNum");
30 
31  $startpage = intval($usage->addOptionalParameter("page", "pageNumber", array() , "0"));
32  $key = $usage->addOptionalParameter("key", "key", array() , "");
33 
34  $usage->setStrictMode(false);
35 
36  $usage->verify();
37 
38  $slice = 28;
39  $dbaccess = $action->dbaccess;
40 
41  if ($startpage == 0) $start = 0;
42  else $start = ($startpage * $slice + 1);
43  $sqlfilters = array();
44  if ($key) $sqlfilters[] = "svalues ~* '" . pg_escape_string($key) . "'";
45  $limg = internalGetDocCollection($dbaccess, 0, $start, $slice, $sqlfilters, $action->user->id, "TABLE", "IMAGE");
46  $wimg = createDoc($dbaccess, "IMAGE", false);
47  $oaimg = $wimg->getAttribute("img_file");
48  foreach ($limg as $k => $img) {
49  $wimg->id = $img["id"];
50  $limg[$k]["imgsrc"] = $wimg->GetHtmlValue($oaimg, $img["img_file"]);
51  $limg[$k]["imgcachesrc"] = str_replace("cache=no", "", $limg[$k]["imgsrc"]);
52  if (preg_match("/^file/", $limg[$k]["imgsrc"], $vids)) {
53  $limg[$k]["imgcachesrc"] = $limg[$k]["imgsrc"] . "&width=100";
54  }
55  $limg[$k]['title'] = htmlspecialchars($limg[$k]['title'], ENT_QUOTES);
56  $limg[$k]['imgcachesrc'] = htmlspecialchars($limg[$k]['imgcachesrc'], ENT_QUOTES);
57  }
58 
59  $action->lay->eSet("key", $key);
60  if (($startpage == 0) && (count($limg) < $slice)) {
61  $action->lay->set("morepages", false);
62  } else {
63 
64  $action->lay->set("morepages", true);
65  $action->lay->set("hppage", true);
66  if ($startpage > 0) $action->lay->set("ppage", $startpage - 1);
67  else $action->lay->set("hppage", false);
68  $action->lay->set("cpage", $startpage + 1);
69  if ($slice == count($limg)) $action->lay->set("npage", $startpage + 1);
70  else $action->lay->set("npage", 0);
71  }
72 
73  $action->lay->setBlockData("IMAGES", $limg);
74  $action->lay->set("NOIMAGES", (count($limg) == 0));
75  $action->lay->set("FUNCNUM", urlencode($numFunc));
76 }
global $action
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
Verify arguments for action function.
internalGetDocCollection($dbaccess, $dirid, $start="0", $slice="ALL", $sqlfilters=array(), $userid=1, $qtype="LIST", $fromid="", $distinct=false, $orderby="title", $latest=true, $trash="", &$debug=null, $folderRecursiveLevel=2, $join= '',\SearchDoc &$searchDoc=null)
Definition: Lib.Dir.php:428
$dbaccess
Definition: checkVault.php:17
if($file) if($subject==""&&$file) if($subject=="") $err
$usage
ckimage(Action &$action)
Definition: ckimage.php:23
← centre documentaire © anakeen