From 7adf8590f6f2c43d317ade50e7c54817ba9ef111 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 3 Dec 2016 20:47:26 -0800 Subject: [PATCH] Fixes media-manager upload issue when no limit found. legacyPath option added to imagepicker() --- e107_admin/image.php | 7 ++++- e107_admin/newspost.php | 12 ++++---- e107_admin/prefs.php | 2 +- e107_handlers/form_handler.php | 50 +++++++++++++++++++++++++++++---- e107_web/js/plupload/upload.php | 2 +- 5 files changed, 59 insertions(+), 14 deletions(-) diff --git a/e107_admin/image.php b/e107_admin/image.php index 2971d6bf4..c4056cff9 100644 --- a/e107_admin/image.php +++ b/e107_admin/image.php @@ -1095,7 +1095,12 @@ class media_admin_ui extends e_admin_ui // if 'for' has no value, files are placed in /temp and not added to the db. - $maxFileSize = e107::pref('core', 'upload_maxfilesize','20M'); + $maxFileSize = e107::pref('core', 'upload_maxfilesize'); + + if(empty($maxFileSize)) + { + $maxFileSize = "20M"; + } $text = "

".IMALAN_145."

"; $text .= '
diff --git a/e107_admin/newspost.php b/e107_admin/newspost.php index ce907a865..0d0c8a4b4 100644 --- a/e107_admin/newspost.php +++ b/e107_admin/newspost.php @@ -433,7 +433,7 @@ class news_admin_ui extends e_admin_ui protected $fields = array( 'checkboxes' => array('title' => '', 'type' => null, 'width' => '3%', 'thclass' => 'center first', 'class' => 'center', 'nosort' => true, 'toggle' => 'news_selected', 'forced' => TRUE), 'news_id' => array('title' => LAN_ID, 'type' => 'text', 'width' => '5%', 'thclass' => 'center', 'class' => 'center', 'nosort' => false, 'readParms'=>'link=sef&target=blank'), - 'news_thumbnail' => array('title' => NWSLAN_67, 'type' => 'method', 'width' => '110px', 'thclass' => 'center', 'class' => "center", 'nosort' => false, 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60','readonly'=>false), + 'news_thumbnail' => array('title' => NWSLAN_67, 'type' => 'method', 'width' => '110px', 'thclass' => 'center', 'class' => "center", 'nosort' => false, 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60', 'readonly'=>false), 'news_title' => array('title' => LAN_TITLE, 'type' => 'text', 'tab'=>0, 'writeParms'=> array('required'=> 1, 'size'=>'block-level'), 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), 'news_summary' => array('title' => LAN_SUMMARY, 'type' => 'text', 'tab'=>0, 'writeParms'=>'size=block-level', 'width' => 'auto', 'thclass' => 'left', 'class' => 'left', 'nosort' => false), 'news_body' => array('title' => "", 'type' => 'method', 'tab'=>0, 'nolist'=>true, 'writeParms'=>'nolabel=1','data'=>'str', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), @@ -1629,11 +1629,11 @@ class news_form_ui extends e_admin_form_ui } } - $text = $frm->imagepicker('news_thumbnail[0]', varset($thumbTmp[0]), varset($paths[0]),'media=news&video=1'); - $text .= $frm->imagepicker('news_thumbnail[1]', varset($thumbTmp[1]), varset($paths[1]),'media=news&video=1'); - $text .= $frm->imagepicker('news_thumbnail[2]', varset($thumbTmp[2]), varset($paths[2]),'media=news&video=1'); - $text .= $frm->imagepicker('news_thumbnail[3]', varset($thumbTmp[3]), varset($paths[3]),'media=news&video=1'); - $text .= $frm->imagepicker('news_thumbnail[4]', varset($thumbTmp[4]), varset($paths[4]),'media=news&video=1'); + $text = $frm->imagepicker('news_thumbnail[0]', varset($thumbTmp[0]), varset($paths[0]),'media=news&video=1&legacyPath={e_IMAGE}newspost_images'); + $text .= $frm->imagepicker('news_thumbnail[1]', varset($thumbTmp[1]), varset($paths[1]),'media=news&video=1&legacyPath={e_IMAGE}newspost_images'); + $text .= $frm->imagepicker('news_thumbnail[2]', varset($thumbTmp[2]), varset($paths[2]),'media=news&video=1&legacyPath={e_IMAGE}newspost_images'); + $text .= $frm->imagepicker('news_thumbnail[3]', varset($thumbTmp[3]), varset($paths[3]),'media=news&video=1&legacyPath={e_IMAGE}newspost_images'); + $text .= $frm->imagepicker('news_thumbnail[4]', varset($thumbTmp[4]), varset($paths[4]),'media=news&video=1&legacyPath={e_IMAGE}newspost_images'); // $text .= "
Insert image/video into designated area of template.
"; return $text; diff --git a/e107_admin/prefs.php b/e107_admin/prefs.php index 7f0220f0a..636df5918 100644 --- a/e107_admin/prefs.php +++ b/e107_admin/prefs.php @@ -370,7 +370,7 @@ if(!empty($pref['sitebutton']) && strpos($pref['sitebutton'],'{')===false && fil -$text .= $frm->imagepicker('sitebutton',$pref['sitebutton'],'','help='.PRFLAN_225); +$text .= $frm->imagepicker('sitebutton',$pref['sitebutton'],'','help='.PRFLAN_225); //todo use 'LegacyPath' option instead of code above. $text .= " diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 0d8e2e27f..c54f8d274 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -1098,7 +1098,8 @@ class e_form { $sc_parameters['media'] = '_common'; } - + + $default_thumb = $default; $class = ''; @@ -1112,14 +1113,25 @@ class e_form } else { - if('{' != $default[0]) + if('{' != $default[0]) // legacy path or one without {} { - // convert to sc path - $default_thumb = $tp->createConstants($default, 'nice'); - $default = $tp->createConstants($default, 'mix'); + list($default_thumb,$default) = $this->imagepickerDefault($default, $sc_parameters); } + $default_url = $tp->replaceConstants($default, 'abs'); } + + + $debugInfo = " +
+			default-thumb: ".$default_thumb."
+			defautlt:   ".$default."
+			default-url: ".$default_url."
+			
"; + + // e107::getDebug()->log($debugInfo); + + $blank = FALSE; @@ -1198,7 +1210,35 @@ class e_form } + private function imagepickerDefault($path, $parms=array()) + { + $tp = e107::getParser(); + if(!empty($parms['legacyPath'])) // look in a specific path. + { + $legacyDefault = rtrim($parms['legacyPath'],'/')."/".$path; + $legacyRel = $tp->replaceConstants($legacyDefault); + + if(is_readable($legacyRel)) + { + return array($legacyDefault, $legacyDefault); + } + else + { + // e107::getDebug()->log("Legacy Default:".$legacyDefault); + // e107::getDebug()->log("wasnt found:".$legacyRel); + } + + } + + $path = str_replace('e_MEDIA_IMAGE/','{e_MEDIA_IMAGE}',$path); + + $default_thumb = $tp->createConstants($path, 'nice'); + $default = $tp->createConstants($path, 'mix'); + + return array($default_thumb, $default); + + } /** diff --git a/e107_web/js/plupload/upload.php b/e107_web/js/plupload/upload.php index a6800359e..59fc9c50c 100644 --- a/e107_web/js/plupload/upload.php +++ b/e107_web/js/plupload/upload.php @@ -118,7 +118,7 @@ if($out) { // Read binary input stream and append it to temp file - $tmpName = e107::getParser()->filter($_FILES['file']['tmp_name'],'w'); + $tmpName = e107::getParser()->filter($_FILES['file']['tmp_name'],'str'); $in = fopen($tmpName, "rb"); if($in)