diff --git a/workflow/engine/controllers/admin.php b/workflow/engine/controllers/admin.php index 3631b7356..76686bdaf 100644 --- a/workflow/engine/controllers/admin.php +++ b/workflow/engine/controllers/admin.php @@ -100,7 +100,6 @@ class Admin extends Controller * getting email configuration * @autor Alvaro */ - public function emails() { global $RBAC; @@ -110,4 +109,38 @@ class Admin extends Controller //render content G::RenderPage('publish', 'extJs'); } + + /** + * getting default list + * @param string $httpData->PRO_UID (opional) + */ + public function pmLogo($httpData) + { + global $RBAC; + $RBAC->requirePermissions('PM_SETUP_ADVANCE'); + + G::LoadClass('configuration'); + $c = new Configurations(); + $configPage = $c->getConfiguration('additionalTablesList', 'pageSize', '', $_SESSION['USER_LOGGED']); + $Config['pageSize'] = isset($configPage['pageSize']) ? $configPage['pageSize'] : 20; + + $this->includeExtJS('admin/pmLogo'); + $this->setView('admin/pmLogo'); + + //assigning js variables + $this->setJSVar('FORMATS', $c->getFormats()); + $this->setJSVar('CONFIG', $Config); + $this->setJSVar('PRO_UID', isset($_GET['PRO_UID'])? $_GET['PRO_UID'] : false); + + if (isset($_SESSION['_cache_pmtables'])) { + unset($_SESSION['_cache_pmtables']); + } + + if (isset($_SESSION['ADD_TAB_UID'])) { + unset($_SESSION['ADD_TAB_UID']); + } + //render content + G::RenderPage('publish', 'extJs'); + } + } diff --git a/workflow/engine/controllers/adminProxy.php b/workflow/engine/controllers/adminProxy.php index da23e821b..bb0bd624e 100644 --- a/workflow/engine/controllers/adminProxy.php +++ b/workflow/engine/controllers/adminProxy.php @@ -551,4 +551,516 @@ class adminProxy extends HttpProxyController $this->success = (count($fields) > 0); $this->data = $fields; } + + /** + * get List Image + * @param type $httpData + */ + public function getListImage($httpData) + { + G::LoadClass('replacementLogo'); + $uplogo = PATH_TPL . 'setup' . PATH_SEP . 'uplogo.html'; + $width = "100%"; + $upload = new replacementLogo(); + $aPhotoSelect = $upload->getNameLogo($_SESSION['USER_LOGGED']); + $sPhotoSelect = trim($aPhotoSelect['DEFAULT_LOGO_NAME']); + $check = ''; + $ainfoSite = explode("/",$_SERVER["REQUEST_URI"]); + $dir = PATH_DATA . "sites" . PATH_SEP . str_replace("sys", "", $ainfoSite[1]) . PATH_SEP . "files/logos"; + G::mk_dir ( $dir ); + $i = 0; + $images = array(); + /** if we have at least one image it's load */ + if (file_exists($dir)) { + if ($handle = opendir($dir)) { + while (false !== ($file = readdir($handle))) { + if (($file != ".") && ($file != "..")) { + $extention = explode(".", $file); + $aImageProp = getimagesize($dir . '/' . $file, $info); + $sfileExtention = strtoupper($extention[count($extention)-1]); + + if( in_array($sfileExtention, array('JPG', 'JPEG', 'PNG', 'GIF') ) ) { + + $check = (!strcmp($file, $sPhotoSelect)) ? '/images/toadd.png' : '/images/delete.png'; + $onclick = (strcmp($file, $sPhotoSelect)) ? "onclick ='deleteLogo(\" $file \");return false;'" : ''; + + if ($i == 0) { + $i++; + } + $i++; + $images[] = array( + 'name' => $file, + 'size' => '0', + 'lastmod' => '32', + 'url' => "../adminProxy/showLogoFile?id=".base64_encode($file), + 'thumb_url' => "../adminProxy/showLogoFile?id=".base64_encode($file) + ); + } + } + } + closedir($handle); + } + } + $o = array('images' => $images); + echo json_encode($o); + exit(); + } + /** + * Change Name logo + * @param type $snameLogo + * @return type $snameLogo + */ + function changeNamelogo($snameLogo) + { + $snameLogo = preg_replace("/[áàâãª]/", "a", $snameLogo); + $snameLogo = preg_replace("/[ÁÀÂÃ]/", "A", $snameLogo); + $snameLogo = preg_replace("/[ÍÌÎ]/", "I", $snameLogo); + $snameLogo = preg_replace("/[íìî]/", "i", $snameLogo); + $snameLogo = preg_replace("/[éèê]/", "e", $snameLogo); + $snameLogo = preg_replace("/[ÉÈÊ]/", "E", $snameLogo); + $snameLogo = preg_replace("/[óòôõº]/", "o", $snameLogo); + $snameLogo = preg_replace("/[ÓÒÔÕ]/", "O", $snameLogo); + $snameLogo = preg_replace("/[úùû]/", "u", $snameLogo); + $snameLogo = preg_replace("/[ÚÙÛ]/", "U", $snameLogo); + $snameLogo = str_replace( "ç", "c", $snameLogo); + $snameLogo = str_replace( "Ç", "C", $snameLogo); + $snameLogo = str_replace( "[ñ]", "n", $snameLogo); + $snameLogo = str_replace( "[Ñ]", "N", $snameLogo); + return ($snameLogo); + } + /** + * Create Thumb + * @param type $img_file + * @param type $ori_path + * @param type $thumb_path + * @param type $img_type + */ + function createThumb($img_file, $ori_path, $thumb_path, $img_type) + { + $path = $ori_path; + $img = $path.$img_file; + switch ($img_type) { + case "image/jpeg": + $img_src = @imagecreatefromjpeg($img); + break; + case "image/pjpeg": + $img_src = @imagecreatefromjpeg($img); + break; + case "image/png": + $img_src = @imagecreatefrompng($img); + break; + case "image/x-png": + $img_src = @imagecreatefrompng($img); + break; + case "image/gif": + $img_src = @imagecreatefromgif($img); + break; + } + $img_width = imagesx($img_src); + $img_height = imagesy($img_src); + $square_size = 100; + // check width, height, or square + if ($img_width == $img_height) { + // square + $tmp_width = $square_size; + $tmp_height = $square_size; + } else if ($img_height < $img_width) { + // wide + $tmp_height = $square_size; + $tmp_width = intval(($img_width / $img_height) * $square_size); + if ($tmp_width % 2 != 0) { + $tmp_width++; + } + } else if ($img_height > $img_width) { + $tmp_width = $square_size; + $tmp_height = intval(($img_height / $img_width) * $square_size); + if (($tmp_height % 2) != 0) { + $tmp_height++; + } + } + $img_new = imagecreatetruecolor($tmp_width, $tmp_height); + imagecopyresampled($img_new, $img_src, 0, 0, 0, 0, + $tmp_width, $tmp_height, $img_width, $img_height); + + // create temporary thumbnail and locate on the server + $thumb = $thumb_path."thumb_".$img_file; + switch ($img_type) { + case "image/jpeg": + imagejpeg($img_new, $thumb); + break; + case "image/pjpeg": + imagejpeg($img_new, $thumb); + break; + case "image/png": + imagepng($img_new, $thumb); + break; + case "image/x-png": + imagepng($img_new, $thumb); + break; + case "image/gif": + imagegif($img_new, $thumb); + break; + } + + // get tmp_image + switch ($img_type) { + case "image/jpeg": + $img_thumb_square = imagecreatefromjpeg($thumb); + break; + case "image/pjpeg": + $img_thumb_square = imagecreatefromjpeg($thumb); + break; + case "image/png": + $img_thumb_square = imagecreatefrompng($thumb); + break; + case "image/x-png": + $img_thumb_square = imagecreatefrompng($thumb); + break; + case "image/gif": + $img_thumb_square = imagecreatefromgif($thumb); + break; + } + + $thumb_width = imagesx($img_thumb_square); + $thumb_height = imagesy($img_thumb_square); + + if ($thumb_height < $thumb_width) { + // wide + $x_src = ($thumb_width - $square_size) / 2; + $y_src = 0; + $img_final = imagecreatetruecolor($square_size, $square_size); + imagecopy($img_final, $img_thumb_square, 0, 0, + $x_src, $y_src, $square_size, $square_size); + } + else if ($thumb_height > $thumb_width) { + // landscape + $x_src = 0; + $y_src = ($thumb_height - $square_size) / 2; + $img_final = imagecreatetruecolor($square_size, $square_size); + imagecopy($img_final, $img_thumb_square, 0, 0, + $x_src, $y_src, $square_size, $square_size); + } + else { + $img_final = imagecreatetruecolor($square_size, $square_size); + imagecopy($img_final, $img_thumb_square, 0, 0, + 0, 0, $square_size, $square_size); + } + + switch ($img_type) { + case "image/jpeg": + @imagejpeg($img_final, $thumb); + break; + case "image/pjpeg": + @imagejpeg($img_final, $thumb); + break; + case "image/png": + @imagepng($img_final, $thumb); + break; + case "image/x-png": + @imagepng($img_final, $thumb); + break; + case "image/gif": + @imagegif($img_final, $thumb); + break; + } + } + + /** + * Upload Image + * @global type $_FILES + */ + function uploadImage() + { + //!dataSystem + $ainfoSite = explode("/", $_SERVER["REQUEST_URI"]); + $dir = PATH_DATA."sites".PATH_SEP.str_replace("sys","",$ainfoSite[1]).PATH_SEP."files/logos"; + global $_FILES; + + //| 0-> non fail + //| 1-> fail in de type of the image + //| 2-> fail in de size of the image + //| 3-> fail in de myme of the image + $failed = 0; + //!dataSystem + + $ori_dir = $dir . '/img/ori/'; + $thumb_dir = $dir . '/img/thumbs/'; + + $allowedType = array( + 'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png' + ); + $allowedTypeArray['index' . base64_encode('image/jpg')] = IMAGETYPE_JPEG; + $allowedTypeArray['index' . base64_encode('image/jpeg')] = IMAGETYPE_JPEG; + $allowedTypeArray['index' . base64_encode('image/pjpeg')] = IMAGETYPE_JPEG; + $allowedTypeArray['index' . base64_encode('image/gif')] = IMAGETYPE_GIF; + $allowedTypeArray['index' . base64_encode('image/png')] = IMAGETYPE_PNG; + $allowedTypeArray['index' . base64_encode('image/x-png')] = IMAGETYPE_PNG; + + $uploaded = 0; + $failed = 0; + + if (in_array($_FILES['img']['type'], $allowedType)) { + // max upload file is 500 KB + if ($_FILES['img']['size'] <= 500000) { + + $formf = $_FILES['img']; + $namefile = $formf['name']; + $typefile = $formf['type']; + $errorfile = $formf['error']; + $tpnfile = $formf['tmp_name']; + $aMessage1 = array(); + $fileName = trim(str_replace(' ', '_', $namefile)); + $fileName = self::changeNamelogo($fileName); + G::uploadFile( $tpnfile, $dir . '/', 'tmp' . $fileName ); + + try { + $typeMime = exif_imagetype($dir . '/'. 'tmp'.$fileName); + if ($typeMime == $allowedTypeArray['index' . base64_encode($_FILES['img']['type'])]) { + $error = false; + try { + list($imageWidth, $imageHeight, $imageType) = @getimagesize($dir . '/' . 'tmp' . $fileName); + G::resizeImage($dir . '/tmp' . $fileName, $imageWidth, 49, $dir . '/' . $fileName); + } + catch (Exception $e) { + $error = $e->getMessage(); + } + $uploaded++; + } + else { + $failed = "3"; + } + unlink ($dir . '/tmp' . $fileName); + } + catch (Exception $e) { + $failed = "3"; + } + + } + else { + $failed = "2"; + } + } + else if ($_FILES['img']['type'] != '') { + $failed = "1"; + } + + echo '{success: true, failed: ' . $failed . ', uploaded: ' . $uploaded . ', type: "' . $_FILES['img']['type'] . '"}'; + exit(); + } + + /** + * Get Name Current Logo + * @return type + */ + function getNameCurrentLogo() + { + G::LoadClass('replacementLogo'); + $upload = new replacementLogo(); + $aPhotoSelect = $upload->getNameLogo($_SESSION['USER_LOGGED']); + $sPhotoSelect = trim($aPhotoSelect['DEFAULT_LOGO_NAME']); + return $sPhotoSelect; + } + + /** + * compare Name Current Logo + * @param type $selectLogo + * @return type int value + */ + function isCurrentLogo() + { + $arrayImg = explode(";", $_POST['selectLogo']); + foreach ($arrayImg as $imgname) { + if ($imgname != "") { + if( strcmp($imgname, self::getNameCurrentLogo()) == 0 ) { + echo '{success: true}'; + exit(); + } + } + } + echo '{success: false}'; + exit(); + } + + /** + * + * Delete Image from the list + * @param + * @return string '{success: true | false}' + */ + function deleteImage() + { + //!dataSystem + $ainfoSite = explode("/", $_SERVER["REQUEST_URI"]); + $dir = PATH_DATA . "sites" . PATH_SEP . str_replace("sys", "", $ainfoSite[1]) . PATH_SEP . "files/logos"; + global $_FILES; + //!dataSystem + + $dir = $dir; + $dir_thumbs = $dir; + + $arrayImg = explode(";", $_POST['images']); + foreach ($arrayImg as $imgname) { + if ($imgname != "") { + if( strcmp($imgname, self::getNameCurrentLogo()) != 0 ) { + if(file_exists($dir . '/' . $imgname)) { + unlink ($dir . '/' . $imgname); + } + if(file_exists($dir . '/tmp' . $imgname)) { + unlink ($dir . '/tmp' . $imgname); + } + } + else { + echo '{success: false}'; + exit(); + } + } + } + echo '{success: true}'; + exit(); + } + + /** + * Replacement Logo + * @global type $_REQUEST + * @global type $RBAC + */ + function replacementLogo() + { + global $_REQUEST; + $sfunction = $_REQUEST['nameFunction']; + $_GET['NAMELOGO'] = $_REQUEST['NAMELOGO']; + + try {//ini_set('display_errors','1'); + global $RBAC; + switch ($RBAC->userCanAccess('PM_LOGIN')) { + case -2: + G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels'); + G::header('location: ../login/login'); + die; + break; + case -1: + G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); + G::header('location: ../login/login'); + die; + break; + } + + switch ($sfunction) { + case 'replacementLogo': + $snameLogo = urldecode($_GET['NAMELOGO']); + $snameLogo = trim($snameLogo); + $snameLogo = self::changeNamelogo($snameLogo); + G::loadClass('configuration'); + $oConf = new Configurations; + $aConf = Array( + 'WORKSPACE_LOGO_NAME' => SYS_SYS, + 'DEFAULT_LOGO_NAME' => $snameLogo + ); + + $oConf->aConfig = $aConf; + $oConf->saveConfig('USER_LOGO_REPLACEMENT', '', '', ''); + + G::SendTemporalMessage('ID_REPLACED_LOGO', 'tmp-info', 'labels'); + break; + case 'restoreLogo': + $snameLogo = $_GET['NAMELOGO']; + G::loadClass('configuration'); + $oConf = new Configurations; + $aConf = Array( + 'WORKSPACE_LOGO_NAME' => '', + 'DEFAULT_LOGO_NAME' => '' + ); + + $oConf->aConfig = $aConf; + $oConf->saveConfig('USER_LOGO_REPLACEMENT', '', '', ''); + + G::SendTemporalMessage('ID_REPLACED_LOGO', 'tmp-info', 'labels'); + break; + } + } + catch (Exception $oException) { + die($oException->getMessage()); + } + exit(); + } + + /** + * Show Logo + * @param type $imagen + */ + function showLogo($imagen) + { + $info = @getimagesize($imagen); + $fp = fopen($imagen, "rb"); + if ($info && $fp) { + header("Content-type: {$info['mime']}"); + fpassthru($fp); + exit; + } + else { + throw new Exception("Image format not valid"); + } + } + + /** + * Copy More Logos + * @param type $dir + * @param type $newDir + */ + function cpyMoreLogos($dir,$newDir) + { + if (file_exists($dir)) { + if (($handle = opendir($dir))) { + while (false !== ($file = readdir($handle))) { + if (($file != ".") && ($file != "..")) { + $extention = explode(".", $file); + $aImageProp = getimagesize($dir . '/' . $file, $info); + $sfileExtention = strtoupper($extention[count($extention)-1]); + if ( in_array($sfileExtention, array('JPG', 'JPEG', 'PNG', 'GIF') ) ) { + + $dir1 = $dir . PATH_SEP . $file; + $dir2 = $newDir . PATH_SEP . $file; + copy($dir1, $dir2); + } + } + } + closedir($handle); + } + } + } + + /** + * Show Logo File + */ + function showLogoFile() + { + $_GET['id'] = $_REQUEST['id']; + + $base64Id = base64_decode($_GET['id']); + $ainfoSite = explode("/", $_SERVER["REQUEST_URI"]); + $dir = PATH_DATA . "sites" . PATH_SEP.str_replace("sys", "", $ainfoSite[1]).PATH_SEP."files/logos"; + $imagen = $dir . PATH_SEP . $base64Id; + + if (is_file($imagen)) { + self::showLogo($imagen); + } + else { + $newDir = PATH_DATA . "sites" . PATH_SEP.str_replace("sys", "", $ainfoSite[1]).PATH_SEP."files/logos"; + $dir = PATH_HOME . "public_html/files/logos"; + + if (!is_dir($newDir)) { + G::mk_dir($newDir); + } + //this function does copy all logos from public_html/files/logos to /shared/site/yourSite/files/logos + //cpyMoreLogos($dir,$newDir); + $newDir .= PATH_SEP.$base64Id; + $dir .= PATH_SEP.$base64Id; + copy($dir,$newDir); + self::showLogo($newDir); + die; + } + die; + exit(); + } + } diff --git a/workflow/engine/menus/setup.php b/workflow/engine/menus/setup.php index eb3bb9daf..6858ab061 100755 --- a/workflow/engine/menus/setup.php +++ b/workflow/engine/menus/setup.php @@ -27,7 +27,8 @@ global $RBAC; if ($RBAC->userCanAccess('PM_SETUP') == 1 ) { //settings options - $G_TMP_MENU->AddIdRawOption('LOGO', 'uplogo', G::LoadTranslation('ID_LOGO'), 'icon-pmlogo.png', '', 'settings'); + // $G_TMP_MENU->AddIdRawOption('LOGO', 'uplogo', G::LoadTranslation('ID_LOGO'), 'icon-pmlogo.png', '', 'settings'); + $G_TMP_MENU->AddIdRawOption('LOGO', '../admin/pmLogo', G::LoadTranslation('ID_LOGO'), 'icon-pmlogo.png','', 'settings'); $G_TMP_MENU->AddIdRawOption('EMAILS','../admin/emails', G::LoadTranslation('ID_EMAIL'), 'icon-email-settings1.png', '', 'settings'); $G_TMP_MENU->AddIdRawOption('CALENDAR', 'calendarList', G::LoadTranslation('ID_CALENDAR'), 'icon-calendar.png', '', 'settings' ); //if ($RBAC->userCanAccess('PM_SETUP_ADVANCE') == 1) diff --git a/workflow/engine/templates/admin/pmLogo.html b/workflow/engine/templates/admin/pmLogo.html new file mode 100644 index 000000000..97c29e19e --- /dev/null +++ b/workflow/engine/templates/admin/pmLogo.html @@ -0,0 +1,109 @@ + + DataView + + + +
+
+ +
+
+ + diff --git a/workflow/engine/templates/admin/pmLogo.js b/workflow/engine/templates/admin/pmLogo.js new file mode 100644 index 000000000..bfdd66f74 --- /dev/null +++ b/workflow/engine/templates/admin/pmLogo.js @@ -0,0 +1,316 @@ +Ext.onReady(function() { + var store = new Ext.data.JsonStore({ + proxy : new Ext.data.HttpProxy({ + url : '../adminProxy/getListImage', method: 'POST' + }), + root : 'images', + fields : [ + 'name', 'url', + {name : 'size', type : 'float'}, + {name : 'lastmod', type : 'date', dateFormat: 'timestamp'}, + 'thumb_url' + ] + }); + store.load(); + + var tpl = new Ext.XTemplate( + '' + ); + var tplDetail = new Ext.XTemplate( + '
', + '', + '
', + 'Image Name:', + '{name}', + 'view original
', + '
', + '
' + ); + var tbar = new Ext.Toolbar(); + tbar.add({ + text : _('ID_APPLY'), + icon : '/images/ext/default/accept.png', + id : 'tbarAply', + disabled: true, + handler : function() { + var records = datav.getSelectedRecords(); + if (records.length != 0) { + if(records.length == 1) { + + var myMask = new Ext.LoadMask(Ext.getBody(), {msg:_('ID_LOADING')}); + myMask.show(); + + var imageName = records[0].data.name; + Ext.Ajax.request({ + url : '../adminProxy/replacementLogo', + method : 'post', + params : {nameFunction: 'replacementLogo', NAMELOGO:imageName}, + success : function() { + window.parent.window.parent.location.href = window.parent.window.parent.window.location.href + } + }); + } + else { + PMExt.notify('Notice', _('ID_YOU_ARE_NOT_CAN_SELECT_PHOTO')); + } + } + else { + PMExt.notify('Notice', _('ID_SELECT_AN_IMAGE')); + } + } + }); + + tbar.add({ + text : _('ID_DELETE'), + icon : '/images/delete-16x16.gif', + id : 'tbarDelete', + disabled: true, + handler : function() { + var records = datav.getSelectedRecords(); + var isCurrentLogo = false; + if (records.length != 0) { + if (records.length == 1) { + var imgName = ''; + for (var i = 0; i < records.length; i++) { + imgName = imgName + records[i].data.name + ';'; + } + Ext.Ajax.request({ + url : '../adminProxy/isCurrentLogo', + method : 'post', + params : { selectLogo : imgName }, + success : function(response) { + store.load(); + oResponse = Ext.decode( response.responseText ); + if (oResponse.success == true) { + Ext.Msg.alert(_('ID_LOGO'), _('ID_SELECTED_IMAGE_IS_LOGO')); + isCurrentLogo = true; + } + } + }); + if(isCurrentLogo == false) { + Ext.Msg.show({ + title : _('ID_LOGO'), + msg : _('ID_DELETE_SELECTED_LOGO'), + buttons: Ext.Msg.YESNO, + fn : function(btn) { + if(btn == 'yes') { + Ext.Ajax.request({ + url : '../adminProxy/deleteImage', + method : 'post', + params : {images : imgName}, + success : function(response) { + store.load(); + oResponse = Ext.decode( response.responseText ); + if (oResponse.success == true) { + PMExt.notify('Notice', _('ID_SELECTED_IMAGE_DELETED')); + } + else { + PMExt.notify('Notice', _('ID_SELECTED_IMAGE_IS_LOGO')); + } + } + }); + + } + }, + animEl : 'elId', + icon : Ext.MessageBox.QUESTION + }); + } + } + else { + PMExt.notify('Notice', _('ID_YOU_ARE_NOT_CAN_SELECT_PHOTO')); + } + } + else { + PMExt.notify('Notice', _('ID_SELECT_AN_IMAGE')); + } + } + }); + + tbar.add({ + text : _('ID_RESTORE_DEFAULT'), + icon : '/images/icon-pmlogo-15x15.png', + handler : function() { + var records = datav.getSelectedRecords(); + var myMask = new Ext.LoadMask(Ext.getBody(), {msg : _('ID_LOADING')}); + myMask.show(); + var imageName = 'name'; + Ext.Ajax.request({ + url : '../adminProxy/replacementLogo', + method : 'post', + params : {nameFunction: 'restoreLogo', NAMELOGO:imageName}, + success : function() { + window.parent.window.parent.location.href = window.parent.window.parent.window.location.href; + } + }); + } + }); + + tbar.add('-', { + text : _('ID_UPLOAD'), + iconCls : 'silk-add', + icon : '/images/import.gif', + handler : function(){ + uploadWin.show(); + } + }) + + var datav = new Ext.DataView({ + autoScroll : true, + store : store, + tpl : tpl, + autoHeight : false, + height : 800, + multiSelect : true, + overClass : 'x-view-over', + itemSelector: 'div.thumb-wrap', + emptyText : _('ID_NO_IMAGES_TO_DISPLAY'), + + listeners : { + selectionchange : { + fn : function(dv,nodes){ + var l = nodes.length; + var s = l != 1 ? 's' : ''; + panelLeft.setTitle(_('PHOTO_GALLERY') + '(' + l + ' ' + _('ID_IMAGE') + s + ' ' + _('ID_SELECTED') + ')'); + if (nodes.length > 0) { + Ext.getCmp('tbarAply').enable(); + Ext.getCmp('tbarDelete').enable(); + } + else { + Ext.getCmp('tbarAply').disable(); + Ext.getCmp('tbarDelete').disable(); + } + + } + } +// , +// click : { +// fn : function() { +// } +// } + + } + }) + + var panelLeft = new Ext.Panel({ + region : 'center', + id : 'images-view', + frame : true, + width : 520, + autoHeight : true, + layout : 'auto', + title : _('PHOTO_GALLERY') + '(0 ' + _('ID_IMAGES_SELECTED') + ')', + items : [tbar, datav] + }); + + + var panelRightTop = new Ext.FormPanel({ + title : _('ID_UPLOAD_IMAGE'), + width : 270, + labelAlign : 'right', + fileUpload : true, + frame : true, + defaults : { + anchor : '90%', + allowBlank : false, + msgTarget : 'side' + }, + items: + [ + { + xtype : 'fileuploadfield', + emptyText : '', + fieldLabel : _('ID_IMAGE'), + buttonText : _('ID_SELECT_FILE'), + name : 'img' + } + ], + buttons : + [ + { + text : _('ID_UPLOAD'), + handler : function() { + panelRightTop.getForm().submit({ + url : '../adminProxy/uploadImage', + waitMsg : _('ID_LOADING'), + success : function(form, o) { + obj = Ext.util.JSON.decode(o.response.responseText); + if (obj.failed == '0' && obj.uploaded != '0') { + PMExt.notify(_('ID_SUCCESS'), _('ID_YOUR_IMAGE_HAS_BEEN_SUCCESSFULLY')); + } + else { + var messageError = ""; + if (obj.failed == "1") { + //| 1-> Fail in the type of the image + messageError = _('ID_ERROR_UPLOADING_IMAGE_TYPE'); + } + else if(obj.failed == "2") { + //| 2-> Fail in the size of the image + messageError = _('ID_UPLOADING_IMAGE_WRONG_SIZE'); + } + else if(obj.failed == "3") { + //| 3-> fail in de mime of the image + messageError = _('ID_ERROR_UPLOADING_IMAGE_TYPE'); + } + + PMExt.notify(_('ID_SUCCESS'), messageError); + } + panelRightTop.getForm().reset(); + store.load(); + uploadWin.hide(); + } + }); + } + }, + { + text : _('ID_CANCEL'), + handler : function() { + uploadWin.hide(); + } + } + ] + }); + + uploadWin = new Ext.Window({ + title : '', + id : 'uploadWin', + layout : 'fit', + width : 420, + height : 140, + modal : false, + autoScroll : true, + closeAction : 'hide', + maximizable : false, + items : [panelRightTop] + }); + + var panelRightBottom = new Ext.Panel({ + region : 'east', + title : _('IMAGE_DETAIL'), + frame : true, + width : 200, + height : 255, + split : true, + collapsible : true, + collapseMode : 'mini', + margins : '0 0 0 0', + id : 'panelDetail', + tpl : tplDetail + }); + + var viewport = new Ext.Viewport({ + layout : 'border', + autoScroll : false, + items : [ panelLeft ] + }); +});