From ad1a942f195f3e0959a12e039d125bbd16436333 Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Sun, 22 Apr 2012 07:53:34 +0000 Subject: [PATCH] Small fixes to Media Manager. --- e107_admin/image.php | 101 +++++++++++++-------- e107_handlers/media_class.php | 2 +- e107_languages/English/admin/lan_admin.php | 1 + 3 files changed, 67 insertions(+), 37 deletions(-) diff --git a/e107_admin/image.php b/e107_admin/image.php index 0a55e15ac..0541795a3 100644 --- a/e107_admin/image.php +++ b/e107_admin/image.php @@ -116,7 +116,7 @@ class media_cat_ui extends e_admin_ui //'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'), 'media_cat_id' => array('title'=> LAN_ID, 'type' => 'number', 'width' =>'5%', 'forced'=> TRUE, 'readonly'=>TRUE), 'media_cat_image' => array('title'=> LAN_IMAGE, 'type' => 'image', 'data' => 'str', 'width' => '100px', 'thclass' => 'center', 'class'=>'center', 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60','readonly'=>FALSE, 'batch' => FALSE, 'filter'=>FALSE), - 'media_cat_owner' => array('title'=> "Owner", 'type' => 'dropdown', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE), + 'media_cat_owner' => array('title'=> "Owner", 'type' => 'dropdown', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE), 'media_cat_category' => array('title'=> LAN_CATEGORY, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>TRUE), 'media_cat_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE), 'media_cat_diz' => array('title'=> LAN_DESCRIPTION, 'type' => 'bbarea', 'width' => '30%', 'readParms' => 'expand=...&truncate=150&bb=1','readonly'=>FALSE), // Display name @@ -129,10 +129,12 @@ class media_cat_ui extends e_admin_ui { $this->fields['media_cat_owner']['writeParms'] = array( "_common" => "_common", - "news" => "news", + "_icon" => "_icon", + "news" => "news", "page" => "page", - "download" => "download", - "gallery" => "gallery" + "gallery" => "gallery", + "download" => "download" + ); $sql = e107::getDb(); @@ -334,6 +336,11 @@ class media_admin_ui extends e_admin_ui $this->batchImport(); } + if(varset($_POST['update_options'])) + { + $this->updateSettings(); + } + if($this->getQuery('iframe')) { $this->getResponse()->setIframeMod(); @@ -595,17 +602,21 @@ class media_admin_ui extends e_admin_ui foreach($files as $f) { - $text .= " - ".$frm->checkbox("batch_selected[$c]",$f['fname'])." + $text .= " + + + ".$frm->checkbox("batch_selected[".$c."]",$f['fname'])." ".$this->preview($f)." ".$f['fname']." - ".$frm->text('batch_import_name[$c]', $f['fname'])." - ".$frm->textarea('batch_import_diz[$c]', $_POST['batch_import_diz'][$c])." + ".$frm->text('batch_import_name['.$c.']', ($_POST['batch_import_name'][$c] ? $_POST['batch_import_name'][$c] : $f['fname']))." + ".$frm->textarea('batch_import_diz['.$c.']', $_POST['batch_import_diz'][$c])." ".$f['mime']." ".$f['fsize']." ".e107::getDateConvert()->convert_date($f['modified'])." ".$f['img-width']." x ".$f['img-height']." - "; + + + \n"; $c++; } @@ -726,6 +737,14 @@ class media_admin_ui extends e_admin_ui // continue; $f['fname'] = $file; + if(file_exists($newpath) || $sql->db_Select("core_media","media_url = '".$tp->createConstants($newpath,'rel')."' LIMIT 1") ) + { + $mes->addWarning($newpath." already exists and was ignored during import."); + continue; + } + + + if(rename($oldpath,$newpath)) { $insert = array( @@ -780,6 +799,43 @@ class media_admin_ui extends e_admin_ui if($id) return (isset($this->cats[$id]) ? $this->cats[$id] : 0); return $this->cats; } + + + /* + * UPDATE IMAGE OPTIONS - MAIN SCREEN + */ + function updateSettings() + { + global $pref,$admin_log,$tp; + + $mes = e107::getMessage(); + + $tmp = array(); + $tmp['image_post'] = intval($_POST['image_post']); + $tmp['resize_method'] = $tp->toDB($_POST['resize_method']); + $tmp['im_path'] = trim($tp->toDB($_POST['im_path'])); + $tmp['image_post_class'] = intval($_POST['image_post_class']); + $tmp['image_post_disabled_method'] = intval($_POST['image_post_disabled_method']); + $tmp['enable_png_image_fix'] = intval($_POST['enable_png_image_fix']); + + if($_POST['img_import_resize_w'] && $_POST['img_import_resize_h']) + { + $tmp['img_import_resize'] = intval($_POST['img_import_resize_w'])."x".intval($_POST['img_import_resize_h']); + } + + if ($admin_log->logArrayDiffs($tmp, $pref, 'IMALAN_04')) + { + save_prefs(); // Only save if changes + $mes->add(IMALAN_9, E_MESSAGE_SUCCESS); + } + else + { + $mes->add(IMALAN_20, E_MESSAGE_INFO); + } + } + + + } @@ -973,34 +1029,7 @@ if (isset($_POST['submit_avdelete_multi'])) } -/* - * UPDATE IMAGE OPTIONS - MAIN SCREEN - */ -if (isset($_POST['update_options'])) -{ - $tmp = array(); - $tmp['image_post'] = intval($_POST['image_post']); - $tmp['resize_method'] = $tp->toDB($_POST['resize_method']); - $tmp['im_path'] = trim($tp->toDB($_POST['im_path'])); - $tmp['image_post_class'] = intval($_POST['image_post_class']); - $tmp['image_post_disabled_method'] = intval($_POST['image_post_disabled_method']); - $tmp['enable_png_image_fix'] = intval($_POST['enable_png_image_fix']); - - if($_POST['img_import_resize_w'] && $_POST['img_import_resize_h']) - { - $tmp['img_import_resize'] = intval($_POST['img_import_resize_w'])."x".intval($_POST['img_import_resize_h']); - } - if ($admin_log->logArrayDiffs($tmp, $pref, 'IMALAN_04')) - { - save_prefs(); // Only save if changes - $emessage->add(IMALAN_9, E_MESSAGE_SUCCESS); - } - else - { - $emessage->add(IMALAN_20, E_MESSAGE_INFO); - } -} /* * SHOW AVATARS SCREEN diff --git a/e107_handlers/media_class.php b/e107_handlers/media_class.php index cc779afbe..37cc919c8 100644 --- a/e107_handlers/media_class.php +++ b/e107_handlers/media_class.php @@ -249,7 +249,7 @@ class e_media /** * Return an array of Images in a particular category */ - public function getImages($cat = '') + public function getImages($cat,$from='',$amount='') { if(!$cat) return; // TODO check the category is valid. diff --git a/e107_languages/English/admin/lan_admin.php b/e107_languages/English/admin/lan_admin.php index cde807a48..c95fc098c 100644 --- a/e107_languages/English/admin/lan_admin.php +++ b/e107_languages/English/admin/lan_admin.php @@ -322,6 +322,7 @@ define("LAN_EXECUTE","Execute"); define("LAN_SEFURL","SEF URL"); define("LAN_COPY","Copy"); define("LAN_KEYWORDS","Keywords"); +define("LAN_IMAGE","Image");