Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 include_once "HTML/Template/ITX.php";
00025 include_once "config.php";
00026
00027 $dir = getcwd();
00028 chdir("../../../../../");
00029 include_once "webservice/soap/include/inc.soap_functions.php";
00030 $mobs = getMobsOfObject($_GET["session_id"]."::".$_GET["client_id"], $_GET["obj_type"].":html", $_GET["obj_id"]);
00031 chdir($dir);
00032
00033 $preview = "";
00034 $arr_tinyMCE_image_files = array();
00035 $request_uri = urldecode(empty($_POST['request_uri'])?(empty($_GET['request_uri'])?'':$_GET['request_uri']):$_POST['request_uri']);
00036 $img = isset($_POST['imglist'])?$_POST['imglist']:'';
00037 $_root = $installpath;
00038 $errors = array();
00039
00040
00041 if (isset($_FILES['img_file']['size']) && $_FILES['img_file']['size']>0)
00042 {
00043 $dir = getcwd();
00044 chdir("../../../../../");
00045 include_once "webservice/soap/include/inc.soap_functions.php";
00046 $safefilename = preg_replace("/[^a-zA-z0-9_\.]/", "", $_FILES["img_file"]["name"]);
00047 $media_object = saveTempFileAsMediaObject($_GET["session_id"]."::".$_GET["client_id"], $safefilename, $_FILES["img_file"]["tmp_name"]);
00048 if (file_exists($iliasAbsolutePath.$iliasMobPath."mm_".$media_object->getId() . "/" . $media_object->getTitle()))
00049 {
00050
00051 $media_object->_saveUsage($media_object->getId(), $_GET["obj_type"].":html", $_GET["obj_id"]);
00052 }
00053 chdir($dir);
00054 $preview = $iliasHttpPath.$iliasMobPath."mm_".$media_object->getId() . "/" . $media_object->getTitle();
00055 $mobs[$media_object->getId()] = $media_object->getId();
00056 }
00057
00058 $tpl = new HTML_Template_ITX();
00059 $tpl->loadTemplatefile("tpl.imagemanager.html", TRUE, TRUE);
00060
00061
00062 if ($tinyMCE_img_delete_allowed && isset($_POST['lib_action'])
00063 && ($_POST['lib_action']=='delete') && !empty($img))
00064 {
00065 deleteImg();
00066 }
00067
00068 if ($tinyMCE_img_delete_allowed)
00069 {
00070 $tpl->touchBlock("delete_allowed");
00071 }
00072 outMobImages();
00073 outMobImageParams();
00074 $tpl->setVariable("REQUEST_URI", $_GET["request_uri"]);
00075 $tpl->setVariable("VALUE_REQUEST_URI", $request_uri);
00076 $tpl->setVariable("OBJ_ID", $_GET["obj_id"]);
00077 $tpl->setVariable("OBJ_TYPE", $_GET["obj_type"]);
00078 $tpl->setVariable("SESSION_ID", $_GET["session_id"]);
00079 $tpl->setVariable("CLIENT_ID", $_GET["client_id"]);
00080 $tpl->setVariable("VALUE_UPDATE", $_GET["update"]);
00081 if ($_GET["update"] == 1)
00082 {
00083 $tpl->setVariable("INSERT_COMMAND", "{\$lang_update}");
00084 }
00085 else
00086 {
00087 $tpl->setVariable("INSERT_COMMAND", "{\$lang_insert}");
00088 }
00089 $tpl->setVariable("URL_PREVIEW", $preview);
00090 $error_messages = "";
00091 if (!empty($errors))
00092 {
00093 $error_messages .= '<span class="error">';
00094 foreach ($errors as $err)
00095 {
00096 $error_messages .= $err . "<br />";
00097 }
00098 $error_messages .= "</span>";
00099 }
00100 $tpl->setVariable("ERROR_MESSAGES", $error_messages);
00101 $tpl->show();
00102
00103 function outMobImages()
00104 {
00105 global $mobs;
00106 global $iliasMobPath;
00107 global $iliasAbsolutePath;
00108 global $iliasHttpPath;
00109 global $tinyMCE_valid_imgs;
00110 global $tpl;
00111 global $errors;
00112 global $img;
00113 global $arr_tinyMCE_image_files;
00114
00115 $i = 0;
00116
00117 foreach ($mobs as $mob)
00118 {
00119 $mobdir = $iliasAbsolutePath.$iliasMobPath."mm_".$mob . "/";
00120 $d = @dir($mobdir);
00121 if ($d)
00122 {
00123 while (FALSE !== ($entry = $d->read()))
00124 {
00125 $ext = strtolower(substr(strrchr($entry,'.'), 1));
00126 if (is_file($mobdir.$entry) && in_array($ext, $tinyMCE_valid_imgs))
00127 {
00128 $arr_tinyMCE_image_files[$i]["file_name"] = $entry;
00129 $arr_tinyMCE_image_files[$i]["file_dir"] = $mobdir;
00130 $arr_tinyMCE_image_files[$i]["http_dir"] = $iliasHttpPath.$iliasMobPath."mm_".$mob . "/";
00131 $i++;
00132 }
00133 }
00134 $d->close();
00135 }
00136 else
00137 {
00138 $errors[] = '{$lang_ibrowser_errornodir}';
00139 }
00140 }
00141
00142 sort($arr_tinyMCE_image_files);
00143
00144 for ($k=0; $k<count($arr_tinyMCE_image_files); $k++)
00145 {
00146 $entry = $arr_tinyMCE_image_files[$k]["file_name"];
00147 $size = getimagesize($arr_tinyMCE_image_files[$k]["file_dir"].$entry);
00148 $fsize = filesize($arr_tinyMCE_image_files[$k]["file_dir"].$entry);
00149 $tpl->setCurrentBlock("imagefile");
00150 $tpl->setVariable("IMAGEFILE_VALUE", $arr_tinyMCE_image_files[$k]["http_dir"]);
00151 $tpl->setVariable("IMAGEFILE_TEXT", $entry);
00152 if ($entry == $img)
00153 {
00154 $tpl->setVariable("IMAGEFILE_SELECTED", " selected=\"selected\"");
00155 }
00156 $tpl->parseCurrentBlock();
00157 }
00158 }
00159
00160 function outMobImageParams()
00161 {
00162 global $arr_tinyMCE_image_files;
00163 global $tpl;
00164 for ($k=0; $k<count($arr_tinyMCE_image_files); $k++)
00165 {
00166 $tpl->setCurrentBlock("imageparams");
00167 $entry = $arr_tinyMCE_image_files[$k]["file_name"];
00168 $size = getimagesize($arr_tinyMCE_image_files[$k]["file_dir"].$entry);
00169 $fsize = filesize($arr_tinyMCE_image_files[$k]["file_dir"].$entry);
00170 $tpl->setVariable("IMG_WIDTH", $size[0]);
00171 $tpl->setVariable("IMG_HEIGHT", $size[1]);
00172 $tpl->setVariable("IMG_PATH", $arr_tinyMCE_image_files[$k]["http_dir"]);
00173 $tpl->setVariable("F_SIZE", filesize_h($fsize,2));
00174 $tpl->parseCurrentBlock();
00175 }
00176 }
00177
00178 function deleteImg()
00179 {
00180 }
00181
00182
00183
00184
00185
00186 function filesize_h($size, $dec = 1)
00187 {
00188 $sizes = array('byte(s)', 'kb', 'mb', 'gb');
00189 $count = count($sizes);
00190 $i = 0;
00191
00192 while ($size >= 1024 && ($i < $count - 1)) {
00193 $size /= 1024;
00194 $i++;
00195 }
00196
00197 return round($size, $dec) . ' ' . $sizes[$i];
00198 }
00199
00200 function liboptions($arr, $prefix = '', $sel = '')
00201 {
00202 $buf = '';
00203 foreach($arr as $lib) {
00204 $buf .= '<option value="'.$lib['value'].'"'.(($lib['value'] == $sel)?' selected':'').'>'.$prefix.$lib['text'].'</option>'."\n";
00205 }
00206 return $buf;
00207 }
00208
00209 ?>