|
From: <luc...@us...> - 2014-02-18 19:47:25
|
Revision: 12324
http://sourceforge.net/p/xoops/svn/12324
Author: luciorota
Date: 2014-02-18 19:47:18 +0000 (Tue, 18 Feb 2014)
Log Message:
-----------
experiment: added formAjaxImageManager element and use it instead of xoops popup image manager
Modified Paths:
--------------
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/imagemanager.php
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/modules/system/templates/system_imagemanager.html
Added Paths:
-----------
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/class/xoopsform/formajaximagemanager.css
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/class/xoopsform/formajaximagemanager.php
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/language/english/formajaximagemanager.php
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/sampleform.inc.php
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.JavaScript-Canvas-to-Blob-master/
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.JavaScript-Canvas-to-Blob-master/js/
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.JavaScript-Canvas-to-Blob-master/js/canvas-to-blob.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.JavaScript-Canvas-to-Blob-master/js/canvas-to-blob.min.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.JavaScript-Load-Image-master/
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.JavaScript-Load-Image-master/css/
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.JavaScript-Load-Image-master/css/demo.css
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.JavaScript-Load-Image-master/css/vendor/
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.JavaScript-Load-Image-master/css/vendor/Jcrop.gif
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.JavaScript-Load-Image-master/css/vendor/jquery.Jcrop.css
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.JavaScript-Load-Image-master/js/
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.JavaScript-Load-Image-master/js/demo.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.JavaScript-Load-Image-master/js/load-image-exif-map.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.JavaScript-Load-Image-master/js/load-image-exif.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.JavaScript-Load-Image-master/js/load-image-ios.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.JavaScript-Load-Image-master/js/load-image-meta.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.JavaScript-Load-Image-master/js/load-image-orientation.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.JavaScript-Load-Image-master/js/load-image.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.JavaScript-Load-Image-master/js/load-image.min.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.JavaScript-Load-Image-master/js/vendor/
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.JavaScript-Load-Image-master/js/vendor/jquery.Jcrop.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.ThickBox/
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.ThickBox/loadingAnimation.gif
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.ThickBox/thickbox-compressed.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.ThickBox/thickbox.css
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.ThickBox/thickbox.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.ajaxloader/
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.ajaxloader/jquery.ajaxloader.css
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.ajaxloader/jquery.ajaxloader.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.ajaxloader/spinner.gif
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/cors/
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/cors/postmessage.html
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/cors/result.html
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/css/
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/css/demo-ie8.css
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/css/demo.css
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/css/jquery.fileupload-noscript.css
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/css/jquery.fileupload-ui-noscript.css
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/css/jquery.fileupload-ui.css
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/css/jquery.fileupload.css
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/css/style.css
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/img/
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/img/loading.gif
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/img/progressbar.gif
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/js/
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/js/app.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/js/cors/
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/js/cors/jquery.postmessage-transport.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/js/cors/jquery.xdr-transport.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/js/jquery.fileupload-angular.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/js/jquery.fileupload-audio.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/js/jquery.fileupload-image.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/js/jquery.fileupload-jquery-ui.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/js/jquery.fileupload-process.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/js/jquery.fileupload-ui.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/js/jquery.fileupload-validate.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/js/jquery.fileupload-video.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/js/jquery.fileupload.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/js/jquery.iframe-transport.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/js/main.js
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/js/vendor/
XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/xoops_lib/Frameworks/jquery.jQuery-File-Upload-master/js/vendor/jquery.ui.widget.js
Added: XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/class/xoopsform/formajaximagemanager.css
===================================================================
--- XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/class/xoopsform/formajaximagemanager.css (rev 0)
+++ XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/class/xoopsform/formajaximagemanager.css 2014-02-18 19:47:18 UTC (rev 12324)
@@ -0,0 +1,120 @@
+/* main containers */
+.faim-formajaximagemenager_container {
+ position: relative;
+ width: 100%;
+ height: 444px;
+ overflow-x: hidden;
+ overflow-y: auto;
+ position: relative;
+ background-color: #FFFFFF;
+ margin: 0px;
+ border: none;
+ padding: 0px;
+
+}
+.faim-formajaximagemenager_list_imgcat_container,
+.faim-formajaximagemenager_edit_image_container,
+.faim-formajaximagemenager_edit_imgcat_container {
+ position: relative;
+ width: 100%;
+ height: 480px;
+}
+
+.faim-formajaximagemenager_container .inner5 {
+ margin: 5px;
+}
+
+/* messages */
+.faim-formajaximagemenager_confirmMsg {
+ margin-top: 0px !important;
+ margin-bottom: 0px !important;
+}
+
+/* images thumbs */
+.faim-thumb {
+ background-color: #FFFFFF;
+ border-color: #CCCCCC #AAAAAA #AAAAAA #CCCCCC;
+ border-style: solid;
+ border-width: 1px;
+ border-radius: 4px;
+ height: 200px;
+ margin: 5px;
+ padding: 5px;
+ position: relative;
+ width: 140px;
+}
+
+.faim-thumb img {
+ border: 0 none;
+}
+
+
+.faim-thumbimg {
+ position: relative;
+ width:140px;
+ height: 140px;
+ padding: 0px;
+ border: none;
+ background: #CCCCCC no-repeat center top;
+}
+
+.faim-actions {
+ position: absolute;
+ width:140px;
+ bottom: 0px;
+ height: 26px;
+ padding: 0px;
+ border: none;
+ background: transparent;
+}
+
+.faim-informations {
+ line-height: 1em;
+ font-weight: bold;
+ width:140px;
+ background: transparent;
+}
+
+.faim-selects {
+ position: absolute;
+ bottom: 0px;
+ width:140px;
+ height: 22px;
+ padding: 0px;
+ border: none;
+ background: transparent;
+}
+
+.faim-actions button img,
+.faim-actions a img,
+.faim-actions span img,
+.faim-actions img,
+.faim-thumbimg img {
+ cursor: pointer;
+ width: 16px;
+ height: 16px;
+ margin: 0px;
+ padding: 0px;
+}
+
+.faim-selects img {
+ cursor: pointer;
+ width: 21px;
+ height: 22px;
+ margin: 0px;
+ padding: 0px;
+}
+
+.faim-actions .tooltip {
+ width: 16px;
+ height: 16px;
+ margin: 0px;
+ padding: 0px;
+}
+
+.faim-selects .tooltip {
+ width: 22px;
+ height: 22px;
+ margin: 0px;
+ padding: 0px;
+}
\ No newline at end of file
Added: XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/class/xoopsform/formajaximagemanager.php
===================================================================
--- XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/class/xoopsform/formajaximagemanager.php (rev 0)
+++ XoopsCore/branches/2.5.x/2.5.7_luciorota/htdocs/class/xoopsform/formajaximagemanager.php 2014-02-18 19:47:18 UTC (rev 12324)
@@ -0,0 +1,1957 @@
+<?php
+/**
+ * XoopsFormAjaxImagemanager component class file
+ *
+ * You may not change or alter any portion of this comment or credits
+ * of supporting developers from this source code or any supporting source code
+ * which is considered copyrighted (c) material of the original comment or credit authors.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
+ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
+ * @package kernel
+ * @subpackage form
+ * @since 2.5.7
+ * @author lucio <luc...@gm...>
+ * @version $Id:$
+ */
+error_reporting(0);
+include_once dirname(dirname(dirname(__FILE__))) . '/mainfile.php';
+defined('XOOPS_ROOT_PATH') or die('Restricted access');
+$GLOBALS['xoopsLogger']->activated = false;
+
+//include_once dirname(dirname(__FILE__)) . '/include/common.php';
+
+define("FORMAJAXIMAGEMANAGER_FILENAME", basename(__FILE__));
+define("FORMAJAXIMAGEMANAGER_PATH", dirname(__FILE__));
+define("FORMAJAXIMAGEMANAGER_URL", XOOPS_URL . "/class/xoopsform/" . FORMAJAXIMAGEMANAGER_FILENAME);
+define("FORMAJAXIMAGEMANAGER_JS_URL", XOOPS_URL . "/class/xoopsform");
+define("FORMAJAXIMAGEMANAGER_CSS_URL", XOOPS_URL . "/class/xoopsform");
+xoops_loadLanguage('formajaximagemanager');
+
+$module_handler = xoops_gethandler('module');
+$systemModule = $module_handler->getByDirname('system');
+$systemModuleId = $systemModule->id;
+$userGroups = (is_object($GLOBALS['xoopsUser'])) ? $GLOBALS['xoopsUser']->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
+$userIsAdmin = (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin($systemModuleId));
+
+$imgcat_handler = xoops_gethandler('imagecategory');
+$image_handler = xoops_gethandler('image');
+$imgcatObjperm_handler = xoops_gethandler('groupperm');
+
+
+
+$op = isset($_POST['op']) ? (string)$_POST['op'] : '';
+//$op = XoopsRequest::getString('op', '', 'POST');
+switch ($op) {
+ default :
+ // NOP
+ break;
+
+ case "getImgcats" :
+ $name = isset($_REQUEST['name']) ? (string)$_REQUEST['name'] : '';
+ //$name = XoopsRequest::getString('name');
+ $imgcat_id = isset($_REQUEST['imgcat_id']) ? (int)$_REQUEST['imgcat_id'] : 0;
+ //$imgcat_id = XoopsRequest::getInt('imgcat_id', 0);
+
+
+ $criteria = new CriteriaCompo();
+ if ($userIsAdmin) {
+ $imgcatReadListArray = array_keys($imgcat_handler->getList($userGroups, 'imgcat_read'));
+ $imgcatWriteListArray = array_keys($imgcat_handler->getList($userGroups, 'imgcat_write'));
+ } else {
+ $imgcatReadListArray = array_keys($imgcat_handler->getList($userGroups, 'imgcat_read', true));
+ $imgcatWriteListArray = array_keys($imgcat_handler->getList($userGroups, 'imgcat_write', true));
+ $criteria->add(new Criteria('imgcat_display', true));
+ }
+ if ($imgcat_handler->getCount($criteria) == 0) {
+ // ERROR: no imgcats
+ // generate ajax return
+ $ret = array();
+ $ret['data'] = null;
+ $ret['error'] = false;
+ $ret['message'] = _FAIM_ERROR_NO_IMGCATS;
+ $ret['html'] = _FAIM_ERROR_NO_IMGCATS;
+ $ret['javascript'] = '// NOP';
+ echo json_encode($ret);
+ exit();
+ }
+ $criteria->setSort('imgcat_weight');
+ $criteria->setOrder('ASC');
+ $imgcatsObj = $imgcat_handler->getObjects($criteria, true);
+
+ $imgcatsArray = array();
+ foreach($imgcatsObj as $imgcat_id => $imgcatObj) {
+ $imgcat = array();
+ $imgcat['var']= $imgcatObj->toArray();
+ if ($userIsAdmin) {
+ $imgcat['perm']['edit'] = true;
+ $imgcat['perm']['delete'] = true;
+ $imgcat['perm']['img_read'] = true;
+ $imgcat['perm']['img_write'] = true;
+ $imgcat['perm']['img_delete'] = true;
+ } else {
+ $imgcat['perm']['edit'] = false;
+ $imgcat['perm']['delete'] = false;
+ $imgcat['perm']['img_read'] = in_array($imgcat_id, $imgcatReadListArray);
+ $imgcat['perm']['img_write'] = in_array($imgcat_id, $imgcatWriteListArray);
+ $imgcat['perm']['img_delete'] = false; // IN PROGRESS
+ }
+ $imgcatsArray[$imgcat_id] = $imgcat;
+ unset($imgcat);
+ }
+
+ $data['imgcats'] = $imgcatsArray;
+ $data['xoopsUser']['isAdmin'] = (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin($systemModuleId));
+ // Generate ajax return
+ $ret = array();
+ $ret['data'] = $data;
+ $ret['error'] = false;
+ $ret['message'] = '';
+ $ret['html'] = '';
+ $ret['javascript'] = '// NOP';
+ echo json_encode($ret);
+ exit();
+ break;
+
+ case "getImgcatPermissions" :
+ $name = isset($_REQUEST['name']) ? (string)$_REQUEST['name'] : '';
+ //$name = XoopsRequest::getString('name');
+ $imgcat_id = isset($_REQUEST['imgcat_id']) ? (int)$_REQUEST['imgcat_id'] : 0;
+ //$imgcat_id = XoopsRequest::getInt('imgcat_id', 0);
+
+ // get imgcat/imgcats
+ $criteria = new CriteriaCompo();
+ if ($imgcat_id != 0) {
+ $criteria->add(new Criteria('imgcat_id', $imgcat_id));
+ }
+ if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin($systemModuleId)) {
+ $imgcatReadListArray = array_keys($imgcat_handler->getList($userGroups, 'imgcat_read'));
+ $imgcatWriteListArray = array_keys($imgcat_handler->getList($userGroups, 'imgcat_write'));
+ } else {
+ $imgcatReadListArray = array_keys($imgcat_handler->getList($userGroups, 'imgcat_read', true));
+ $imgcatWriteListArray = array_keys($imgcat_handler->getList($userGroups, 'imgcat_write', true));
+ $criteria->add(new Criteria('imgcat_display', true));
+ }
+ if ($imgcat_handler->getCount($criteria) == 0) {
+ // ERROR: no imgcats
+ // generate ajax return
+ $ret = array();
+ $ret['data'] = null;
+ $ret['error'] = false;
+ $ret['message'] = _FAIM_ERROR_NO_IMGCATS;
+ $ret['html'] = _FAIM_ERROR_NO_IMGCATS;
+ $ret['javascript'] = '// NOP';
+ echo json_encode($ret);
+ exit();
+ }
+ $criteria->setSort('imgcat_weight');
+ $criteria->setOrder('ASC');
+ $imgcatsObj = $imgcat_handler->getObjects($criteria, true);
+
+ $imgcatsArray = array();
+ foreach($imgcatsObj as $imgcat_id => $imgcatObj) {
+ $imgcat = array();
+ $imgcat['var']= $imgcatObj->toArray();
+ if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin($systemModuleId)) {
+ $imgcat['perm']['edit'] = true;
+ $imgcat['perm']['delete'] = true;
+ $imgcat['perm']['img_read'] = true;
+ $imgcat['perm']['img_write'] = true;
+ $imgcat['perm']['img_delete'] = true;
+ } else {
+ $imgcat['perm']['edit'] = false;
+ $imgcat['perm']['delete'] = false;
+ $imgcat['perm']['img_read'] = in_array($imgcat_id, $imgcatReadListArray);
+ $imgcat['perm']['img_write'] = in_array($imgcat_id, $imgcatWriteListArray);
+ $imgcat['perm']['img_delete'] = false; // IN PROGRESS
+ }
+ $imgcatsArray[$imgcat_id] = $imgcat;
+ unset($imgcat);
+ }
+ $data['imgcats'] = $imgcatsArray;
+ $data['xoopsUser']['isAdmin'] = (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin($systemModuleId));
+ // generate ajax return
+ $ret = array();
+ $ret['data'] = $data;
+ $ret['error'] = false;
+ $ret['message'] = '';
+ $ret['html'] = '';
+ $ret['javascript'] = '// NOP';
+ echo json_encode($ret);
+ exit();
+ break;
+
+ case "getImgcatImagesList" :
+ // get imgcat_id
+ $imgcat_id = isset($_REQUEST['imgcat_id']) ? (int)$_REQUEST['imgcat_id'] : 0;
+ //$imgcat_id = XoopsRequest::getInt('imgcat_id');
+ // get imgcat object
+ $imgcatObj = $imgcat_handler->get($imgcat_id);
+ // check imgcat object
+ if (!is_object($imgcatObj)) {
+ // ERROR
+ // generate ajax return
+ $ret = array();
+ $ret['data'] = null;
+ $ret['error'] = true;
+ $ret['message'] = _FAIM_ERROR_NO_IMGCAT;
+ $ret['html'] = _FAIM_ERROR_NO_IMGCAT;
+ $ret['javascript'] = '// NOP';
+ echo json_encode($ret);
+ exit();
+ }
+ // check user read permissions
+ $imgcatperm_handler =& xoops_gethandler('groupperm');
+ if (!$imgcatperm_handler->checkRight('imgcat_read', $imgcat_id, $userGroups)) {
+ // ERROR: no read permissions
+ // generate ajax return
+ $ret = array();
+ $ret['data'] = null;
+ $ret['error'] = true;
+ $ret['message'] = _FAIM_ERROR_NO_IMGCAT_VIEW;
+ $ret['html'] = _FAIM_ERROR_NO_IMGCAT_VIEW;
+ $ret['javascript'] = '// NOP';
+ echo json_encode($ret);
+ exit();
+ }
+ // get images objects
+ $criteria = new Criteria('imgcat_id', $imgcat_id);
+ $criteria->setSort('image_weight');
+ $criteria->setOrder('ASC');
+ $imagesObjs = $image_handler->getObjects($criteria, false, false);
+ foreach ($imagesObjs as $imageObj) {
+ $image['image_id'] = $imageObj->getVar('image_id');
+ $image['image_name'] = $imageObj->getVar('image_name');
+ $image['image_url'] = XOOPS_URL . '/uploads/' . $imageObj->getVar('image_name');
+ $image['image_path'] = XOOPS_UPLOAD_PATH . '/' . $imageObj->getVar('image_name');
+ $imagesize = getimagesize($image['image_path']);
+ $image['image_width'] = $imagesize[0];
+ $image['image_height'] = $imagesize[1];
+ $image['image_mime'] = $imagesize['mime'];
+ $image['image_nicename'] = $imageObj->getVar('image_nicename');
+ $image['image_mimetype'] = $imageObj->getVar('image_mimetype');
+ $image['image_created'] = $imageObj->getVar('image_created');
+ $image['image_display'] = $imageObj->getVar('image_display');
+ $image['image_weight'] = $imageObj->getVar('image_weight');
+ $image['image_body'] = $imageObj->getVar('image_body');
+ $image['imgcat_id'] = $imageObj->getVar('imgcat_id');
+ $imagesArray[] = $image;
+ unset($image);
+ }
+ // get read/write permissions
+ $perm['img_read'] = true;
+ $perm['img_write'] = $imgcatperm_handler->checkRight('imgcat_write', $imgcat_id, $userGroups);
+ // generate ajax return
+ $ret = array();
+ $ret['data']['images'] = $imagesArray;
+ $ret['data']['perm'] = $perm;
+ $ret['error'] = false;
+ $ret['message'] = '';
+ $ret['html'] = 'ok';
+ $ret['javascript'] = '// NOP';
+ echo json_encode($ret);
+ break;
+
+
+// Images operations
+ case 'getImageForm' :
+
+ $name = isset($_REQUEST['name']) ? (string)$_REQUEST['name'] : '';
+ //$name = XoopsRequest::getString('name');
+ // get image_id
+ $image_id = isset($_REQUEST['image_id']) ? (int)$_REQUEST['image_id'] : 0;
+ //$image_id = XoopsRequest::getInt('image_id', 0);
+ // get image object
+ if ($image_id <= 0) {
+ $imageObj = $image_handler->create();
+ $imgcat_id = isset($_REQUEST['imgcat_id']) ? (int)$_REQUEST['imgcat_id'] : 0;
+ //$imgcat_id = XoopsRequest::getInt('imgcat_id', 0);
+ $title = _FAIM_ADD_IMAGE;
+ } else {
+ $imageObj = $image_handler->get($image_id);
+ $imgcat_id = $imageObj->getVar('imgcat_id');
+ $title = _FAIM_EDIT_IMAGE;
+ }
+ // check image object
+ if (!is_object($imageObj)) {
+ // ERROR
+ // generate ajax return
+ $ret = array();
+ $ret['data'] = null;
+ $ret['error'] = true;
+ $ret['message'] = _FAIM_ERROR_NO_IMAGE_OBJECT;
+ $ret['html'] = _FAIM_ERROR_NO_IMAGE_OBJECT;
+ $ret['javascript'] = '// NOP';
+ echo json_encode($ret);
+ exit();
+ }
+ // get imgcat object
+ $imgcatObj = $imgcat_handler->get($imgcat_id);
+ // create image form
+ include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
+ $form = new XoopsSimpleForm( $title, 'image_form', 'formajaximagemanager.php', 'post', true );
+ $form->setExtra('enctype="multipart/form-data"');
+ $form->addElement(new XoopsFormText( _IMAGENAME, $name . '_image_nicename', 50, 255, $imageObj->getVar('image_nicename')), true );
+ $select = new XoopsFormSelect( _IMAGECAT, $name . '_image_imgcat_id', $imgcat_id);
+ if ($userIsAdmin) {
+ $categoriesListArray = $imgcat_handler->getList($userGroups, 'imgcat_write');
+ } else {
+ $categoriesListArray = $imgcat_handler->getList($userGroups, 'imgcat_write', true);
+ }
+ $select->addOptionArray($categoriesListArray);
+ $form->addElement($select, true);
+ if (!$imageObj->isNew()) {
+ $form->addElement(new XoopsFormLabel(_IMAGEFILE, "<img src='" . XOOPS_URL . "/image.php?id=" . $image_id . "&width=140&height=140' />"));
+ } else {
+ $form->addElement(new XoopsFormFile(_IMAGEFILE, $name . '_image_file', $imgcatObj->getVar('imgcat_maxsize')), true);
+ }
+ $form->addElement(new XoopsFormText( _IMGWEIGHT, $name . '_image_weight', 3, 4, $imageObj->getVar('image_weight') ) );
+ $form->addElement(new XoopsFormRadioYN( _IMGDISPLAY, $name . '_image_display', $imageObj->getVar('image_display'), _YES, _NO) );
+ if (!$imageObj->isNew()) {
+ $form->addElement(new XoopsFormHidden($name . '_op', 'submitUpdateImageForm'));
+ } else {
+ $form->addElement(new XoopsFormHidden($name . '_op', 'submitNewImageForm'));
+ }
+ $form->addElement(new XoopsFormHidden($name . '_image_id', $image_id));
+ $form->addElement(new XoopsFormHidden($name . '_imgcat_id', $imgcat_id));
+ $form->addElement(new XoopsFormButton('', $name . '_submit_image_button', _SUBMIT, 'button'));
+ // render edit image form
+ $html = '';
+ $html .= "<div id='" . $name . "_edit_image_form'>";
+ $html .= "<b>" . $form->getTitle() . "</b>\n";
+ $html .= "<br />\n";
+ foreach ($form->getElements() as $ele) {
+ if (!$ele->isHidden()) {
+ $caption = $ele->getCaption();
+ if (!empty($caption)) {
+ $html .= "<strong>" . $ele->getCaption() . "</strong><br />\n";
+ }
+ $html .= $ele->render() . "<br />\n";
+ } else {
+ $html .= $ele->render() . "\n";
+ }
+ }
+ $html .= "</div>";
+ // generate ajax return
+ $ret = array();
+ $ret['data'] = null;
+ $ret['error'] = false;
+ $ret['message'] = '';
+ $ret['html'] = $html;
+ $ret['javascript'] = '// NOP';
+ echo json_encode($ret);
+ break;
+
+ case 'submitNewImageForm' :
+ $name = isset($_REQUEST['name']) ? (string)$_REQUEST['name'] : '';
+ //$name = XoopsRequest::getString('name');
+ $filename = basename($_FILES[$name . '_image_file']['name']);
+ //$filetype = basename($_FILES[$name . '_image_file']['type']);
+ //$filesize = basename($_FILES[$name . '_image_file']['size']);
+ $image_nicename = !empty($_POST['image_nicename']) ? trim($_POST['image_nicename']) : $filename;
+ $image_weight = isset($_POST['image_weight']) ? $_POST['image_weight'] : 0;
+ $image_display = isset($_POST['image_display']) ? $_POST['image_display'] : true;
+ // get imgcat_id
+ $imgcat_id = isset($_REQUEST['imgcat_id']) ? (int)$_REQUEST['imgcat_id'] : 0;
+ //$imgcat_id = XoopsRequest::getInt('imgcat_id');
+ // get imgcat object
+ $imgcatObj = $imgcat_handler->get($imgcat_id);
+ // check imgcat object
+ if (!is_object($imgcatObj)) {
+ // ERROR
+ // Generate ajax return
+ $ret = array();
+ $ret['data'] = null;
+ $ret['error'] = true;
+ $ret['message'] = _FAIM_ERROR_NO_IMGCAT;
+ $ret['html'] = _FAIM_ERROR_NO_IMGCAT;
+ $ret['javascript'] = '// NOP';
+ echo json_encode($ret);
+ exit();
+ }
+ // check user write permissions
+ $imgcatperm_handler =& xoops_gethandler('groupperm');
+ if (!$imgcatperm_handler->checkRight('imgcat_write', $imgcat_id, $userGroups)) {
+ // ERROR: non write permissions
+ // Generate ajax return
+ $ret = array();
+ $ret['data'] = null;
+ $ret['error'] = true;
+ $ret['message'] = _FAIM_ERROR_NO_IMGCAT_SUBMIT;
+ $ret['html'] = _FAIM_ERROR_NO_IMGCAT_SUBMIT;
+ $ret['javascript'] = '// NOP';
+ echo json_encode($ret);
+ exit();
+ }
+ // upload image file and update db
+ $error = false;
+ include_once XOOPS_ROOT_PATH . '/class/uploader.php';
+ $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png'), $imgcatObj->getVar('imgcat_maxsize'), $imgcatObj->getVar('imgcat_maxwidth'), $imgcatObj->getVar('imgcat_maxheight'));
+ $uploader->setPrefix('img');
+ if ($uploader->fetchMedia($name . '_image_file')) {
+ if (!$uploader->upload()) {
+ $error = implode("<br />", $uploader->getErrors(false));
+ } else {
+ // create image object
+ $imageObj = $image_hand...
[truncated message content] |