From 98f03b57e3bb6185cbbb815a71d254e28df79912 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva <pshns@ukr.net> Date: Wed, 29 Jun 2011 17:04:16 +0300 Subject: [PATCH] media upload fix --- inc/media.php | 20 ++++++++++++-------- inc/template.php | 14 +++++++++----- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/inc/media.php b/inc/media.php index d90a13c81..cba89b995 100644 --- a/inc/media.php +++ b/inc/media.php @@ -242,7 +242,7 @@ function media_upload($ns,$auth){ global $lang; // get file and id - $id = $_POST['id']; + $id = $_POST['mediaid']; $file = $_FILES['upload']; if(empty($id)) $id = $file['name']; @@ -572,25 +572,25 @@ function media_tabs_files($selected=false){ * @author Kate Arzamastseva <pshns@ukr.net> * @param string $selected - opened tab */ -function media_tabs_details($selected=false){ +function media_tabs_details($image, $selected=false){ global $lang; echo '<div class="mediamanager-tabs" id="id-mediamanager-tabs-detail">'; - $tab = '<a href="'.media_managerURL(array('tab_details' => 'view')). + $tab = '<a href="'.media_managerURL(array('tab_details' => 'view', 'image' => $image)). '" rel=".mediamanager-tab-view"'; if (!empty($selected) && $selected == 'view') $class = 'view selected'; else $class = 'view'; $tab .= ' class="'.$class.'" >'.$lang['media_viewtab'].'</a>'; echo $tab; - $tab = '<a href="'.media_managerURL(array('tab_details' => 'edit')). + $tab = '<a href="'.media_managerURL(array('tab_details' => 'edit', 'image' => $image)). '" rel=".mediamanager-tab-edit"'; if (!empty($selected) && $selected == 'edit') $class = 'edit selected'; else $class = 'edit'; $tab .= ' class="'.$class.'" >'.$lang['media_edittab'].'</a>'; echo $tab; - $tab = '<a href="'.media_managerURL(array('tab_details' => 'history')). + $tab = '<a href="'.media_managerURL(array('tab_details' => 'history', 'image' => $image)). '" rel=".mediamanager-tab-history"'; if (!empty($selected) && $selected == 'history') $class = 'history selected'; else $class = 'history'; @@ -1231,8 +1231,12 @@ function media_uploadform($ns, $auth, $fullscreen = false){ // The default HTML upload form $params = array('id' => 'dw__upload', 'enctype' => 'multipart/form-data'); - if (!$fullscreen) $params['action'] = DOKU_BASE.'lib/exe/mediamanager.php'; - else $params['action'] = media_managerURL(array('tab_files' => 'files')); + if (!$fullscreen) { + $params['action'] = DOKU_BASE.'lib/exe/mediamanager.php'; + } else { + $params['action'] = media_managerURL(array('tab_files' => 'files', + 'tab_details' => 'view')); + } $form = new Doku_Form($params); if (!$fullscreen) $form->addElement('<div class="upload">' . $lang['mediaupload'] . '</div>'); @@ -1242,7 +1246,7 @@ function media_uploadform($ns, $auth, $fullscreen = false){ $form->addElement(form_makeFileField('upload', $lang['txt_upload'].':', 'upload__file')); $form->addElement(form_makeCloseTag('p')); $form->addElement(form_makeOpenTag('p')); - $form->addElement(form_makeTextField('id', $id, $lang['txt_filename'].':', 'upload__name')); + $form->addElement(form_makeTextField('mediaid', noNS($id), $lang['txt_filename'].':', 'upload__name')); $form->addElement(form_makeButton('submit', '', $lang['btn_upload'])); $form->addElement(form_makeCloseTag('p')); diff --git a/inc/template.php b/inc/template.php index 4226c0e52..e3d716c25 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1159,17 +1159,17 @@ function tpl_fileList(){ * * @author Kate Arzamastseva <pshns@ukr.net> */ -function tpl_fileDetails(){ +function tpl_fileDetails($image){ global $AUTH; global $NS; - if ($_REQUEST['image']) $image = cleanID($_REQUEST['image']); - if (!isset($image) || isset($NS) && getNS($image) != $NS) return ''; + if (!$image || !file_exists(mediaFN($image))) return ''; + if (isset($NS) && getNS($image) != $NS) return ''; $opened_tab = $_REQUEST['tab_details']; if (!$opened_tab) $opened_tab = 'view'; if ($_REQUEST['edit']) $opened_tab = 'edit'; - media_tabs_details($opened_tab); + media_tabs_details($image, $opened_tab); if ($opened_tab == 'view') media_tab_view($image, $NS, $AUTH); if ($opened_tab == 'edit') media_tab_edit($image, $NS, $AUTH); @@ -1423,6 +1423,10 @@ function tpl_media() { $fullscreen = true; require_once(DOKU_INC.'lib/exe/mediamanager.php'); + if ($_REQUEST['image']) $image = cleanID($_REQUEST['image']); + if (isset($IMG)) $image = $IMG; + if (isset($JUMPTO)) $image = $JUMPTO; + echo '<div class="mediamanager" id="id-mediamanager">'; echo '<div class="mediamanager-slider" id="id-mediamanager-layout">'; echo '<div id="id-mediamanager-layout-namespaces" class="layout" style="width: 25%;">'; @@ -1442,7 +1446,7 @@ function tpl_media() { tpl_fileList(); echo '</div>'; echo '<div id="id-mediamanager-layout-detail" class="layout" style="width: 30%;">'; - tpl_fileDetails(); + tpl_fileDetails($image); echo '</div>'; echo '<div class="clearer"></div>'; echo '</div>'; -- GitLab