diff --git a/e107_admin/image.php b/e107_admin/image.php index 39befd813..4387bf228 100644 --- a/e107_admin/image.php +++ b/e107_admin/image.php @@ -9,9 +9,9 @@ * Image Administration Area * * $Source: /cvs_backup/e107_0.8/e107_admin/image.php,v $ - * $Revision: 1.42 $ - * $Date: 2009-12-13 21:52:30 $ - * $Author: e107steved $ + * $Revision: 1.43 $ + * $Date: 2009-12-15 11:51:01 $ + * $Author: e107coders $ * */ require_once("../class2.php"); @@ -182,7 +182,7 @@ class media_form_ui extends e_admin_form_ui if($mode == 'read') { - return $this->cats[$curVal].' (custom!)'; + return $this->cats[$curVal]; } if($mode == 'batch') // Custom Batch List for release_type diff --git a/e107_admin/sql/core_sql.php b/e107_admin/sql/core_sql.php index 1934f4573..3da536612 100644 --- a/e107_admin/sql/core_sql.php +++ b/e107_admin/sql/core_sql.php @@ -9,9 +9,9 @@ * Core SQL * * $Source: /cvs_backup/e107_0.8/e107_admin/sql/core_sql.php,v $ - * $Revision: 1.44 $ - * $Date: 2009-12-10 21:26:53 $ - * $Author: e107steved $ + * $Revision: 1.45 $ + * $Date: 2009-12-15 11:51:02 $ + * $Author: e107coders $ */ header("location:../index.php"); @@ -148,7 +148,8 @@ CREATE TABLE core_media_cat ( media_cat_title text NOT NULL, media_cat_diz text NOT NULL, media_cat_class int(3) unsigned default '0', - PRIMARY KEY (media_cat_id) + PRIMARY KEY (media_cat_id), + UNIQUE KEY media_cat_nick (media_cat_nick) ) TYPE=MyISAM; diff --git a/e107_admin/update_routines.php b/e107_admin/update_routines.php index c73115629..f8412c05f 100644 --- a/e107_admin/update_routines.php +++ b/e107_admin/update_routines.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/update_routines.php,v $ -| $Revision: 1.71 $ -| $Date: 2009-12-15 11:05:16 $ +| $Revision: 1.72 $ +| $Date: 2009-12-15 11:51:02 $ | $Author: e107coders $ +----------------------------------------------------------------------------+ */ @@ -828,71 +828,28 @@ function update_706_to_800($type='') //-- Media-manger import -------------------------------------------------- - - $fl = e107::getFile(); - $fl->setFileInfo('all'); - $newspost_img = $fl->get_files(e_IMAGE.'newspost_images','','',2); - $custom_img = $fl->get_files(e_IMAGE.'custom','','',2); - $mes = e107::getMessage(); - - foreach($newspost_img as $f) + $count = $sql->db_Select('core_media_cat'); + if($count < 5) { - $insert = array( - 'media_caption' => $f['fname'], - 'media_description' =>'', - 'media_category' =>'news', - 'media_datestamp' => $f['modified'], - 'media_url' => '{e_IMAGE}newspost_images/'.$f['fname'], - 'media_userclass' => 0, - 'media_name' => $f['fname'], - 'media_author' => USERID, - 'media_size' => $f['fsize'], - 'media_dimensions' => $f['img-width']." x ".$f['img-height'], - 'media_usedby' => '', - 'media_tags' => '', - 'media_type' => $f['mime'] - ); + $query = "INSERT INTO `".MPREFIX."core_media_cat` (`media_cat_id`, `media_cat_nick`, `media_cat_title`, `media_cat_diz`, `media_cat_class`) VALUES + (1, '_common', '(Common Area)', 'Media in this category will be available in all areas of admin. ', 253), + (2, 'news', 'News', 'Will be available in the news area. ', 253), + (3, 'page', 'Custom Pages', 'Will be available in the custom pages area of admin. ', 253), + (4, 'download', 'Download Images', '', 253), + (5, 'downloadthumb', 'Download Thumbnails', '', 253);"; - if(!$sql->db_Select('core_media','media_url',"media_url = '{e_IMAGE}newspost_images/".$f['fname']."' LIMIT 1")) - { - if($sql->db_Insert("core_media",$insert)) - { - $mes->add("Importing Media: ".$f['fname'], E_MESSAGE_SUCCESS); - } - } + mysql_query($query); } - foreach($custom_img as $f) - { - $insert = array( - 'media_caption' => $f['fname'], - 'media_description' => '', - 'media_category' => 'page', - 'media_datestamp' => $f['modified'], - 'media_url' => '{e_IMAGE}custom/'.$f['fname'], - 'media_userclass' => 0, - 'media_name' => $f['fname'], - 'media_author' => USERID, - 'media_size' => $f['fsize'], - 'media_dimensions' => $f['img-width']." x ".$f['img-height'], - 'media_usedby' => '', - 'media_tags' => '', - 'media_type' => $f['mime'] - ); + core_media_import('news',e_IMAGE.'newspost_images'); + core_media_import('page',e_IMAGE.'custom'); + core_media_import('download',e_FILE.'downloadimages'); + core_media_import('downloadthumb',e_IMAGE.'downloadthumbs'); - if(!$sql->db_Select('core_media','media_url',"media_url = '{e_IMAGE}custom/".$f['fname']."' LIMIT 1")) - { - if($sql->db_Insert("core_media",$insert)) - { - $mes->add("Importing Media: ".$f['fname'], E_MESSAGE_SUCCESS); - } - } - } + // Any others should be done manually via Media Manager batch-import. // ------------------------------------------------------------------ - - if ($do_save) { @@ -908,6 +865,49 @@ function update_706_to_800($type='') return $just_check; } +function core_media_import($cat,$epath) +{ + if(!vartrue($cat)){ return;} + + $fl = e107::getFile(); + $tp = e107::getParser(); + $sql = e107::getDb(); + $mes = e107::getMessage(); + + $fl->setFileInfo('all'); + $img_array = $fl->get_files($epath,'','',2); + + if(!count($img_array)){ return;} + + foreach($img_array as $f) + { + $fullpath = $tp->createConstants($f['path'].$f['fname'],1); + + $insert = array( + 'media_caption' => $f['fname'], + 'media_description' => '', + 'media_category' => $cat, + 'media_datestamp' => $f['modified'], + 'media_url' => $fullpath, + 'media_userclass' => 0, + 'media_name' => $f['fname'], + 'media_author' => USERID, + 'media_size' => $f['fsize'], + 'media_dimensions' => $f['img-width']." x ".$f['img-height'], + 'media_usedby' => '', + 'media_tags' => '', + 'media_type' => $f['mime'] + ); + + if(!$sql->db_Select('core_media','media_url',"media_url = '".$fullpath."' LIMIT 1")) + { + if($sql->db_Insert("core_media",$insert)) + { + $mes->add("Importing Media: ".$f['fname'], E_MESSAGE_SUCCESS); + } + } + } +} function update_70x_to_706($type='')