diff --git a/e107_admin/image.php b/e107_admin/image.php index 2e17e94a9..c91b8908b 100644 --- a/e107_admin/image.php +++ b/e107_admin/image.php @@ -53,6 +53,12 @@ class media_admin extends e_admin_dispatcher 'ui' => 'media_form_ui', 'uipath' => null ), + 'dialog' => array( + 'controller' => 'media_admin_ui', + 'path' => null, + 'ui' => 'media_form_ui', + 'uipath' => null + ), 'cat' => array( 'controller' => 'media_cat_ui', 'path' => null, @@ -197,7 +203,19 @@ class media_form_ui extends e_admin_form_ui asort($this->cats);*/ } - + function options() + { + //return print_a($_GET,true); + $tagid = $_GET['tagid']; + $path = $this->getController()->getListModel()->get('media_url'); + $preview = basename($path); + + + $text .= ""; + // $text .= "SELECT"; + // $text .= "\n\n"; + return $text; + } @@ -336,6 +354,27 @@ class media_admin_ui extends e_admin_ui { $this->updateSettings(); } + + if($this->getQuery('mode') == 'dialog') + { + $cat = $_GET['for']; + $this->listQry = "SELECT m.*,u.user_id,u.user_name FROM #core_media AS m LEFT JOIN #user AS u ON m.media_author = u.user_id WHERE media_category = '".$cat."' "; // without any Order or Limit. + + unset($this->fields['checkboxes']); + $this->fields['options']['type'] = 'method'; + $this->fields['media_userclass']['nolist'] = true; + $this->fields['media_dimentions']['nolist'] = true; + $this->fields['media_description']['nolist'] = true; + $this->fields['media_type']['nolist'] = true; + + foreach($this->fields as $k=>$v) + { + $this->fields[$k]['filter'] = false; + } + } + + + if($this->getQuery('iframe')) { @@ -397,15 +436,26 @@ class media_admin_ui extends e_admin_ui function dialogPage() // Popup dialogPage for Image Selection. { + $cat = $this->getQuery('for'); + $file = (substr($cat,-5) == "_file") ? TRUE : FALSE; + + if($file) + { + + echo $this->getUI()->getList(); + return; + } + + // $this->getModel()->setAction('create'); // $this->getUI()->getController()->getRequest()->setAction('create'); //$this->setAction('create');; if($_POST['etrigger_submit']) { - $data = $this->beforeCreate($_POST); - e107::getDb()->db_Insert('core_media',$data); // Replace with Generic (needs parm sent) + // $data = $this->beforeCreate($_POST); + // e107::getDb()->db_Insert('core_media',$data); // Replace with Generic (needs parm sent) } echo $this->imageSelectUpload(); } @@ -467,8 +517,8 @@ class media_admin_ui extends e_admin_ui $this->fields['media_url']['noedit'] = TRUE; $this->fields['media_userclass']['noedit'] = TRUE; - // $text .= $this->uploadPage(); // To test upload script with plupload - $text .= $this->CreatePage(); // comment me out to test plupload + $text .= $this->uploadPage(); // To test upload script with plupload + // $text .= $this->CreatePage(); // comment me out to test plupload $text .= " "; diff --git a/e107_admin/update_routines.php b/e107_admin/update_routines.php index bca842d6d..7ba0fb11d 100644 --- a/e107_admin/update_routines.php +++ b/e107_admin/update_routines.php @@ -1119,6 +1119,36 @@ function update_706_to_800($type='') $med->import('download_thumb',e_FILE.'downloadthumbs'); } + $dl_files = $fl->get_files(e_DOWNLOAD, "","standard",5); + $public_files = $fl->get_files(e_FILE.'public'); + + if((count($dl_files) || count($public_files)) && !$sql->db_Select_gen("SELECT * FROM `#core_media` WHERE `media_category` = 'download_file' ")) + { + if ($just_check) return update_needed('Import Download and Public Files into Media Manager'); + // check for file-types; + if (is_readable(e_ADMIN.'filetypes.php')) + { + $a_types = strtolower(trim(file_get_contents(e_ADMIN.'filetypes.php'))); + $srch = array("png","jpg","jpeg","gif"); + $a_types = str_replace($srch,"",$a_types); // filter-out images. + + } else + { + $a_types = 'zip, gz, pdf'; + } + + $a_types = explode(',', $a_types); + foreach ($a_types as $f_type) { + $allowed_types[] = trim(str_replace('.', '', $f_type)); + } + + $fmask = '[a-zA-z0-9_-]+\.('.implode('|',$allowed_types).')$'; + $med->import('download_file',e_DOWNLOAD, $fmask); + $med->import('_common_file',e_FILE.'public', $fmask); + } + + + $count = $sql->db_Select_gen("SELECT * FROM `#core_media_cat` WHERE media_cat_owner='_icon' "); diff --git a/e107_files/jslib/core/admin.jquery.js b/e107_files/jslib/core/admin.jquery.js index 0e0c4002a..194ff0749 100644 --- a/e107_files/jslib/core/admin.jquery.js +++ b/e107_files/jslib/core/admin.jquery.js @@ -61,7 +61,7 @@ $(document).ready(function() $("a.e-dialog").colorbox({ iframe:true, width:"60%", - height:"65%", + height:"70%", speed:100 }); @@ -352,7 +352,7 @@ $(document).ready(function() var opt = linkid.split('-'); if(area == 'remove') - { alert(area); + { // alert(area); var remove = linkid; areaList = ''; $('#check-' + opt[1]).show('fast'); diff --git a/e107_files/jslib/core/mediaManager.js b/e107_files/jslib/core/mediaManager.js index e6c339813..f065feb47 100644 --- a/e107_files/jslib/core/mediaManager.js +++ b/e107_files/jslib/core/mediaManager.js @@ -98,7 +98,7 @@ $(document).ready(function() $(".e-media-select").live("click", function(){ - // console.log(this); + console.log(this); @@ -111,7 +111,9 @@ $(document).ready(function() $(this).closest("img").addClass("active"); $('#' + target, window.top.document).attr('value',path); // set new value - $('#' + target + "_prev", window.top.document).attr('src',preview); // set new value + $('img#' + target + "_prev", window.top.document).attr('src',preview); // set new value + $('div#' + target + "_prev", window.top.document).html(preview); // set new value + $('span#' + target + "_prev", window.top.document).html(preview); // set new value $('#src').attr('value',src); // working old $('#preview').attr('src',preview); // working old diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 138480ea5..66d9bc3e8 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -144,21 +144,31 @@ class e_form return $ret; } - // FIXME - Dialog JS no more working, investigate - public function mediaUrl($category = '', $label = '', $tagid='', $bbcode='') + /** + * Internal Function used by imagepicker and filepicker + */ + private function mediaUrl($category = '', $label = '', $tagid='', $extras='') { + $cat = ($category) ? '&for='.$category : ""; if(!$label) $label = ' Upload an image or file'; if($tagid) $cat .= '&tagid='.$tagid; + + parse_str($extras); + if($bbcode) $cat .= '&bbcode=1'; + + if(!$mode) $mode = 'main'; + if(!$action) $action = 'dialog'; + // $tabs // TODO - option to choose which tabs to display. //TODO Parse selection data back to parent form. - $url = e_ADMIN_ABS."image.php?mode=main&action=dialog".$cat; + $url = e_ADMIN_ABS."image.php?mode={$mode}&action={$action}".$cat; $url .= "&iframe=1"; - $ret = "".$label.""; + $ret = "".$label.""; // $footer = "
Save
"; $footer = ''; @@ -262,88 +272,46 @@ class e_form // $ret .= $this->text($name,$default); // to be hidden eventually. return $ret; - - // ---------------- OLD DROPDOWN METHOD BELOW ----------------------------- - - $tp = e107::getParser(); - $sql = e107::getDb(); - + + + + // ---------------- + + } + + + + + + function filepicker($name, $default, $label = '', $sc_parameters = '') + { + $tp = e107::getParser(); + $name_id = $this->name2id($name); if(is_string($sc_parameters)) { if(strpos($sc_parameters, '=') === false) $sc_parameters = 'media='.$sc_parameters; parse_str($sc_parameters, $sc_parameters); } - $qry = "SELECT * FROM `#core_media` WHERE media_userclass IN (".USERCLASS_LIST.") "; + $cat = $tp->toDB($sc_parameters['media']); + $default = ($default) ? $default : "Choose a file"; + $label = "".$default.""; + - // Old Method - $qry .= vartrue($sc_parameters['media']) ? " AND (`media_category` = '".$tp->toDB($sc_parameters['media'])."' OR `media_category` = '_common' )" : " AND `media_category` = '_common' "; + $ret .= $this->mediaUrl($cat, $label,$name_id,"mode=dialog&action=list"); + $ret .= ""; + + return $ret; + - // New Method - /* - if(vartrue($sc_parameters['owner']) && vartrue($sc_parameters['cat'])) - { - - - - - $qry = "SELECT * FROM `#core_media` WHERE media_userclass IN (".USERCLASS_LIST.") "; - $qry .= " AND (`media_owner` = '".$tp->toDB($sc_parameters['owner'])."' AND `media_category` = '".$tp->toDB($sc_parameters['cat'])."' ) OR `media_owner` = '_common' "; - } */ - - - $qry .= "ORDER BY media_name"; - - - if($sql->db_Select_gen($qry)) - { - while($row = $sql->db_Fetch()) - { - $opts[$row['media_category']][$row['media_url']] = $row['media_name']. " (".$row['media_dimensions'].") "; - } - - asort($opts); - - $hide = $default_url = ''; - $default_thumb = $default; - if($default) - { - if('{' != $default[0]) - { - // convert to sc path - $default_thumb = $tp->createConstants($default, 'nice'); - $default = $tp->createConstants($default, 'mix'); - } - $default_url = $tp->replaceConstants($default, 'abs'); - } - else - { - $default = $default_url = e_IMAGE_ABS."generic/blank.gif"; - $hide = ' style="display: none;"'; - } - - if(is_string($sc_parameters)) parse_str($sc_parameters, $sc_parameters); - $name_id = $this->name2id($name); - $width = intval(vartrue($sc_parameters['width'], 150)); - $onchange = "onchange=\"replaceSC('imagepreview={$name}|{$width}',this.form,'{$name_id}_prev'); \""; - - $ret = $this->selectbox($name, $opts, $default, array('default'=>' ', 'other' => $onchange)); - $ret .= "
"; - $ret .= ""; - - $thpath = isset($sc_parameters['nothumb']) || $hide ? $default : $tp->thumbUrl($default_thumb, 'w='.$width, true); - $ret .= "{$default_url}"; - $ret .= "
\n"; - - return $ret; - } - // ---------------- - } + + + /** - * Date field with popup calendar + * Date field with popup calendar // NEW in 0.8/2.0 * $options allowed keys: * - time: show time, default is true * - others: ???, default is false @@ -356,6 +324,12 @@ class e_form */ function datepicker($name, $datestamp = false, $options = array()) { + + + + + // DHTML Calendar is deprecated in 2.0. + $cal = new DHTML_Calendar(true); $cal_options['showsTime'] = varset($options['time'], true); $cal_options['showOthers'] = varset($options['others'], false); @@ -1537,6 +1511,14 @@ class e_form case 'image': //TODO - thumb, js tooltip... if($value) { + + if(!preg_match("/[a-zA-z0-9_-]+\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF)$/",$value)) + { + $value = "{e_IMAGE}filemanager/zip_32.png"; + $src = $tp->replaceConstants(vartrue($parms['pre']).$value, 'abs'); + return ''.$alt.''; + } + if(vartrue($parms['thumb'])) { $src = $tp->replaceConstants(vartrue($parms['pre']).$value, 'abs'); diff --git a/e107_handlers/media_class.php b/e107_handlers/media_class.php index 36b82067b..83261172f 100644 --- a/e107_handlers/media_class.php +++ b/e107_handlers/media_class.php @@ -67,8 +67,8 @@ class e_media if(!count($img_array)){ return $this;} - //print_a($img_array); - //return; + // print_a($img_array); + // return; foreach($img_array as $f) { @@ -79,15 +79,15 @@ class e_media 'media_description' => '', 'media_category' => $cat, 'media_datestamp' => $f['modified'], - 'media_url' => $fullpath, + 'media_url' => $fullpath, 'media_userclass' => 0, - 'media_name' => $f['fname'], - 'media_author' => USERID, - 'media_size' => $f['fsize'], + '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'] + 'media_usedby' => '', + 'media_tags' => '', + 'media_type' => $f['mime'] ); if(!$sql->db_Select('core_media','media_url',"media_url = '".$fullpath."' LIMIT 1")) @@ -429,6 +429,7 @@ class e_media $limit = ($option['limit']) ? $option['limit'] : 20; $newfrm = $frm + $limit; $bbcode = ($option['bbcode']) ? $option['bbcode'] : null; + if($category !='_icon') { diff --git a/e107_plugins/download/includes/admin.php b/e107_plugins/download/includes/admin.php index c420086b4..5ddcca02a 100644 --- a/e107_plugins/download/includes/admin.php +++ b/e107_plugins/download/includes/admin.php @@ -620,7 +620,7 @@ $columnInfo = array( $text = "
-