From: garvinhicking Date: Wed, 9 Aug 2006 07:28:41 +0000 (+0000) Subject: Fix more entry sorting X-Git-Tag: 1.1~147 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=fd6d541eb248a3f1a82c8ee457364b08805000b9;p=s9y.git Fix more entry sorting --- diff --git a/deployment/serendipity_editor.js b/deployment/serendipity_editor.js index 12713f3..acac0b2 100644 --- a/deployment/serendipity_editor.js +++ b/deployment/serendipity_editor.js @@ -72,7 +72,7 @@ function wrapSelectionWithLink(txtarea) { document.getElementById && getMozSelection(txtarea) == "") { var my_desc = prompt("Enter Description", ''); } - + var my_title = prompt("Enter title/tooltip:", ""); html_title = ""; @@ -142,7 +142,7 @@ function serendipity_insLink (area) { area.focus(); return; } - + html_title = ""; if (my_title != "") { html_title = ' title="' + my_title + '"'; @@ -155,7 +155,9 @@ function serendipity_insLink (area) { function serendipity_imageSelector_addToElement (str, el) { document.getElementById(el).value = str; - document.getElementById(el).focus(); + if (document.getElementById(el).type != 'hidden' && document.getElementById(el).focus) { + document.getElementById(el).focus(); + } if (document.getElementById(el).onchange) { document.getElementById(el).onchange(); } @@ -183,7 +185,7 @@ function serendipity_imageSelector_done(textarea) var src = ''; var f = document.forms['serendipity[selForm]'].elements; - if (f['serendipity[linkThumbnail]'][0].checked == true) { + if (f['serendipity[linkThumbnail]'] && f['serendipity[linkThumbnail]'][0].checked == true) { img = f['thumbName'].value; imgWidth = f['imgThumbWidth'].value; imgHeight = f['imgThumbHeight'].value; @@ -193,10 +195,30 @@ function serendipity_imageSelector_done(textarea) imgHeight = f['imgHeight'].value; } - if (f['serendipity[filename_only]'] && f['serendipity[filename_only]'].value == 'true') { - self.opener.serendipity_imageSelector_addToElement(img, f['serendipity[htmltarget]'].value); - self.close(); - return true; + if (f['serendipity[filename_only]']) { + if (f['serendipity[htmltarget]']) { + starget = f['serendipity[htmltarget]'].value; + } else { + starget = 'serendipity[' + textarea + ']'; + } + + if (f['serendipity[filename_only]'].value == 'true') { + parent.self.opener.serendipity_imageSelector_addToElement(img, f['serendipity[htmltarget]'].value); + parent.self.close(); + return true; + } else if (f['serendipity[filename_only]'].value == 'id') { + parent.self.opener.serendipity_imageSelector_addToElement(f['imgID'].value, starget); + parent.self.close(); + return true; + } else if (f['serendipity[filename_only]'].value == 'thumb') { + parent.self.opener.serendipity_imageSelector_addToElement(f['thumbName'].value, starget); + parent.self.close(); + return true; + } else if (f['serendipity[filename_only]'].value == 'big') { + parent.self.opener.serendipity_imageSelector_addToElement(f['imgName'].value, starget); + parent.self.close(); + return true; + } } if (document.getElementById('serendipity_imagecomment').value != '') { @@ -205,31 +227,53 @@ function serendipity_imageSelector_done(textarea) styled = true; } + imgID = 0; + if (f['imgID']) { + imgID = f['imgID'].value; + } + baseURL = ''; + if (f['baseURL']) { + baseURL = f['baseURL'].value; + } + floating = 'center'; - if (XHTML11) { - if (f['serendipity[align]'][0].checked == true) { - img = "\"\""; - } else if (f['serendipity[align]'][1].checked == true) { - img = "\"\""; - floating = 'left'; - } else if (f['serendipity[align]'][2].checked == true) { - img = "\"\""; - floating = 'right'; - } - } else { - if (f['serendipity[align]'][0].checked == true) { - img = ""; - } else if (f['serendipity[align]'][1].checked == true) { - img = ""; - floating = 'left'; - } else if (f['serendipity[align]'][2].checked == true) { - img = ""; - floating = 'right'; - } + if (f['serendipity[align]'][0].checked == true) { + img = "\"\""; + } else if (f['serendipity[align]'][1].checked == true) { + img = "\"\""; + floating = 'left'; + } else if (f['serendipity[align]'][2].checked == true) { + img = "\"\""; + floating = 'right'; } if (f['serendipity[isLink]'][1].checked == true) { - insert = "" + img + ""; + if (f['serendipity[target]'].selectedIndex) { + targetval = f['serendipity[target]'].options[f['serendipity[target]'].selectedIndex].value; + } else { + targetval = ''; + } + + prepend = ''; + ilink = f['serendipity[url]'].value; + if (!targetval || targetval == 'none') { + itarget = ''; + } else if (targetval == 'js') { + itarget = ' onclick="F1 = window.open(\'' + f['serendipity[url]'].value + '\',\'Zoom\',\'' + + 'height=' + (parseInt(f['imgHeight'].value) + 15) + ',' + + 'width=' + (parseInt(f['imgWidth'].value) + 15) + ',' + + 'top=' + (screen.height - f['imgHeight'].value) /2 + ',' + + 'left=' + (screen.width - f['imgWidth'].value) /2 + ',' + + 'toolbar=no,menubar=no,location=no,resize=1,resizable=1,scrollbars=yes\'); return false;"'; + } else if (targetval == '_blank') { + itarget = ' target="_blank"'; + } else if (targetval == 'plugin') { + itarget = ' id="s9yisphref' + imgID + '" onclick="javascript:this.href = this.href + \'&serendipity[from]=\' + self.location.href;"'; + prepend = ''; + ilink = baseURL + 'serendipity_admin_image_selector.php?serendipity[step]=showItem&serendipity[image]=' + imgID; + } + + insert = prepend + "" + img + ""; } else { insert = img; } @@ -244,14 +288,15 @@ function serendipity_imageSelector_done(textarea) block = insert; } - if (self.opener.editorref) { - self.opener.editorref.surroundHTML(block, ''); + if (typeof(parent.self.opener.htmlarea_editors) != 'undefined' && typeof(parent.self.opener.htmlarea_editors[textarea] != 'undefined')) { + parent.self.opener.htmlarea_editors[textarea].surroundHTML(block, ''); + } else if (parent.self.opener.editorref) { + parent.self.opener.editorref.surroundHTML(block, ''); } else { - - self.opener.serendipity_imageSelector_addToBody(block, textarea); + parent.self.opener.serendipity_imageSelector_addToBody(block, textarea); } - self.close(); + parent.self.close(); } // --> diff --git a/docs/NEWS b/docs/NEWS index b87a6cd..8089099 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -243,6 +243,10 @@ Version 1.1-alpha5() Version 1.0.1 () ------------------------------------------------------------------------ + * Fix problem on newer Firefox versions, where insertion of images + in the WYSIWYG editor did not work. It might be necessary to + purge your browsers cache for this to properly work. (Jay Bertrandt) + * Fix utf8 iconv conversion failing on some older PHP setups. Thanks to Matthias Leisi! diff --git a/include/admin/images.inc.php b/include/admin/images.inc.php index d8d56d9..51e56fa 100644 --- a/include/admin/images.inc.php +++ b/include/admin/images.inc.php @@ -11,20 +11,57 @@ if (!serendipity_checkPermission('adminImages')) { } switch ($serendipity['GET']['adminAction']) { + case 'imgedit': + echo '
' . PREFERENCE_USE_JS_WARNING . '
'; + + if (!isset($serendipity['eyecandy']) || serendipity_db_bool($serendipity['eyecandy'])) { + } else { + return true; + } + + include(S9Y_INCLUDE_PATH . "include/functions_images_crop.inc.php"); + $media['is_imgedit'] = true; + $media['css_imgedit'] = serendipity_getTemplateFile('admin/imgedit.css'); + + if (isset($serendipity['GET']['fid'])) { + $file = serendipity_fetchImageFromDatabase($serendipity['GET']['fid']); + if (!is_array($file) || !serendipity_checkPermission('adminImagesDelete') || (!serendipity_checkPermission('adminImagesMaintainOthers') && $file['authorid'] != '0' && $file['authorid'] != $serendipity['authorid'])) { + return; + } + + $fullfile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $file['path'] . $file['name'] . '.' . $file['extension']; + $httpfile = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] . '.' . $file['extension']; + + $img = new imgedit($fullfile, $httpfile); + + // Set the filenames used for the cropping areas. Width/Height are automagically detected. Orientation is either horizontal or vertical. + $img->setArea('imgedit_area.gif', 'h'); + $img->setArea('imgedit_varea.gif', 'v'); + + // Let the IMGEditor do its magic. It will parse its results straightly into a template variable array. + $img->main(); + $serendipity['smarty']->assign('imgedit', $img->imgedit_smarty); + serendipity_smarty_fetch('IMGEDIT', $img->output_template); + } + break; + case 'sync': if (!serendipity_checkPermission('adminImagesSync')) { break; } - @set_time_limit(0); + + if (function_exists('set_time_limit')) { + @set_time_limit(0); + } @ignore_user_abort(); - echo '

' . SYNCING . '


'; + echo '

' . SYNCING . '


'; flush(); $i = serendipity_syncThumbs(); printf(SYNC_DONE, $i); - echo '

' . RESIZING . '


'; + echo '

' . RESIZING . '


'; flush(); $i = serendipity_generateThumbs(); @@ -44,7 +81,7 @@ switch ($serendipity['GET']['adminAction']) { case 'delete': $file = serendipity_fetchImageFromDatabase($serendipity['GET']['fid']); - if (!serendipity_checkPermission('adminImagesDelete') || (!serendipity_checkPermission('adminImagesMaintainOthers') && $file['authorid'] != '0' && $file['authorid'] != $serendipity['authorid'])) { + if (!is_array($file) || !serendipity_checkPermission('adminImagesDelete') || (!serendipity_checkPermission('adminImagesMaintainOthers') && $file['authorid'] != '0' && $file['authorid'] != $serendipity['authorid'])) { return; } @@ -52,11 +89,11 @@ switch ($serendipity['GET']['adminAction']) { $serendipity['adminFile'] = 'serendipity_admin.php'; } $abortLoc = $serendipity['serendipityHTTPPath'] . $serendipity['adminFile'] . '?serendipity[adminModule]=images'; - $newLoc = $abortLoc . '&serendipity[adminAction]=DoDelete&serendipity[fid]=' . $serendipity['GET']['fid'] . '&' . serendipity_setFormToken('url'); + $newLoc = $abortLoc . '&serendipity[adminAction]=DoDelete&serendipity[fid]=' . (int)$serendipity['GET']['fid'] . '&' . serendipity_setFormToken('url'); - printf(ABOUT_TO_DELETE_FILE, $file['name'] .'.'. $file['extension']); + printf('
' . ABOUT_TO_DELETE_FILE . '
', $file['name'] .'.'. $file['extension']); ?> -
+
           @@ -67,84 +104,66 @@ switch ($serendipity['GET']['adminAction']) { break; case 'rename': + $serendipity['GET']['fid'] = (int)$serendipity['GET']['fid']; $file = serendipity_fetchImageFromDatabase($serendipity['GET']['fid']); $serendipity['GET']['newname'] = serendipity_uploadSecure($serendipity['GET']['newname'], true); - if (!serendipity_checkFormToken() || !serendipity_checkPermission('adminImagesDelete') || (!serendipity_checkPermission('adminImagesMaintainOthers') && $file['authorid'] != '0' && $file['authorid'] != $serendipity['authorid'])) { - return; - } - - if (serendipity_isActiveFile(basename($serendipity['GET']['newname']))) { - printf(ERROR_FILE_FORBIDDEN, $serendipity['GET']['newname']); + if (!is_array($file) || !serendipity_checkFormToken() || !serendipity_checkPermission('adminImagesDelete') || (!serendipity_checkPermission('adminImagesMaintainOthers') && $file['authorid'] != '0' && $file['authorid'] != $serendipity['authorid'])) { return; } - if ($file['hotlink']) { - serendipity_updateImageInDatabase(array('name' => $serendipity['GET']['newname']), $serendipity['GET']['fid']); - } else { - $newfile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $file['path'] . $serendipity['GET']['newname'] . '.' . $file['extension']; - $oldfile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $file['path'] . $file['name'] . '.'. $file['extension']; - if ($serendipity['GET']['newname'] != '' && file_exists($oldfile) && !file_exists($newfile)) { - $renameValues = array(array( - 'from' => $oldfile, - 'to' => $newfile, - 'thumb' => $serendipity['thumbSuffix'], - 'fthumb' => $file['thumbnail_name'] - )); - - serendipity_plugin_api::hook_event('backend_media_rename', $renameValues); - - // Rename file - rename($renameValues[0]['from'], $renameValues[0]['to']); - - foreach($renameValues as $renameData) { - // Rename thumbnail - rename($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $file['path'] . $file['name'] . (!empty($renameData['fthumb']) ? '.' . $renameData['fthumb'] : '') . '.' . $file['extension'], - $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $file['path'] . $serendipity['GET']['newname'] . '.' . $renameData['thumb'] . '.' . $file['extension']); - } - - serendipity_updateImageInDatabase(array('thumbnail_name' => $renameValues[0]['thumb'], 'name' => $serendipity['GET']['newname']), $serendipity['GET']['fid']); - - // Forward user to overview (we don't want the user's back button to rename things again) - } else { - if (!file_exists($oldfile)) { - echo ERROR_FILE_NOT_EXISTS; - } elseif (file_exists($newfile)) { - echo ERROR_FILE_EXISTS; - } else { - echo ERROR_SOMETHING; - } + if (!serendipity_moveMediaDirectory(null, $serendipity['GET']['newname'], 'file', $serendipity['GET']['fid'], $file)) { ?>
$serendipity['GET']['fid'])); + serendipity_showPropertyForm($new_media); + break; + case 'add': if (!serendipity_checkFormToken() || !serendipity_checkPermission('adminImagesAdd')) { return; } + if ($serendipity['POST']['adminSubAction'] == 'properties') { + $properties = serendipity_parsePropertyForm(); + $image_id = $properties['image_id']; + $created_thumbnail = true; +?> + + + - +


sendRequest()) || $req->getResponseCode() != '200') { - printf(REMOTE_FILE_NOT_FOUND, $serendipity['POST']['imageurl']); - } else { - // Fetch file - $fContent = $req->getResponseBody(); + echo '(' . $target . ') ' . ERROR_FILE_EXISTS_ALREADY . '
'; + $realname = serendipity_imageAppend($tfile, $target, $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $serendipity['POST']['target_directory'][$tindex]); + } - if ($serendipity['POST']['imageimporttype'] == 'hotlink') { - $tempfile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . '/hotlink_' . time(); - $fp = fopen($tempfile, 'w'); - fwrite($fp, $fContent); - fclose($fp); + require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; + $options = array(); + serendipity_plugin_api::hook_event('backend_http_request', $options, 'image'); + serendipity_request_start(); + $req = &new HTTP_Request($serendipity['POST']['imageurl'], $options); + // Try to get the URL - $image_id = @serendipity_insertHotlinkedImageInDatabase($tfile, $serendipity['POST']['imageurl'], $authorid, null, $tempfile); - printf(HOTLINK_DONE. '
', $serendipity['POST']['imageurl'], $tfile); - serendipity_plugin_api::hook_event('backend_image_addHotlink', $tempfile); - } else { - $fp = fopen($target, 'w'); - fwrite($fp, $fContent); - fclose($fp); + if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') { + printf(REMOTE_FILE_NOT_FOUND, $serendipity['POST']['imageurl']); + } else { + // Fetch file + $fContent = $req->getResponseBody(); + + if ($serendipity['POST']['imageimporttype'] == 'hotlink') { + $tempfile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . '/hotlink_' . time(); + $fp = fopen($tempfile, 'w'); + fwrite($fp, $fContent); + fclose($fp); + + $image_id = @serendipity_insertHotlinkedImageInDatabase($tfile, $serendipity['POST']['imageurl'], $authorid, null, $tempfile); + printf(HOTLINK_DONE. '
', $serendipity['POST']['imageurl'], $tfile); + serendipity_plugin_api::hook_event('backend_image_addHotlink', $tempfile); + } else { + $fp = fopen($target, 'w'); + fwrite($fp, $fContent); + fclose($fp); - printf(FILE_FETCHED . '
', $serendipity['POST']['imageurl'], $tfile); + printf(FILE_FETCHED . '
', $serendipity['POST']['imageurl'], $tfile); + if (serendipity_checkMediaSize($target)) { $thumbs = array(array( 'thumbSize' => $serendipity['thumbSize'], 'thumb' => $serendipity['thumbSuffix'] @@ -215,10 +239,16 @@ switch ($serendipity['GET']['adminAction']) { } // Insert into database - $image_id = serendipity_insertImageInDatabase($tfile, $serendipity['POST']['target_directory'][$tindex], $authorid); + $image_id = serendipity_insertImageInDatabase($tfile, $serendipity['POST']['target_directory'][$tindex], $authorid, null, $realname); serendipity_plugin_api::hook_event('backend_image_add', $target); + $new_media[] = array( + 'image_id' => $image_id, + 'target' => $target, + 'created_thumbnail' => $created_thumbnail + ); } } + serendipity_request_end(); } } else { if (!is_array($serendipity['POST']['target_filename'])) { @@ -248,38 +278,57 @@ switch ($serendipity['GET']['adminAction']) { $serendipity['POST']['target_directory'][$idx] = serendipity_uploadSecure($serendipity['POST']['target_directory'][$idx], true, true); $target = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $serendipity['POST']['target_directory'][$idx] . $tfile; + $realname = $tfile; if (file_exists($target)) { - echo '(' . $target . ') ' . ERROR_FILE_EXISTS_ALREADY; - echo '
'; - } else { - // Accept file - if (is_uploaded_file($uploadtmp) && move_uploaded_file($uploadtmp, $target)) { - printf(FILE_UPLOADED . '
', $uploadfile, $target); - @umask(0000); - @chmod($target, 0664); + echo '(' . $target . ') ' . ERROR_FILE_EXISTS_ALREADY . '
'; + $realname = serendipity_imageAppend($tfile, $target, $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $serendipity['POST']['target_directory'][$idx]); + } - $thumbs = array(array( - 'thumbSize' => $serendipity['thumbSize'], - 'thumb' => $serendipity['thumbSuffix'] - )); - serendipity_plugin_api::hook_event('backend_media_makethumb', $thumbs); + // Accept file + if (is_uploaded_file($uploadtmp) && serendipity_checkMediaSize($uploadtmp) && move_uploaded_file($uploadtmp, $target)) { + printf(FILE_UPLOADED . '
', $uploadfile, $target); + @umask(0000); + @chmod($target, 0664); - foreach($thumbs as $thumb) { - // Create thumbnail - if ( $created_thumbnail = serendipity_makeThumbnail($tfile, $serendipity['POST']['target_directory'][$idx], $thumb['thumbSize'], $thumb['thumb']) ) { - echo THUMB_CREATED_DONE . '
'; - } - } + $thumbs = array(array( + 'thumbSize' => $serendipity['thumbSize'], + 'thumb' => $serendipity['thumbSuffix'] + )); + serendipity_plugin_api::hook_event('backend_media_makethumb', $thumbs); - // Insert into database - $image_id = serendipity_insertImageInDatabase($tfile, $serendipity['POST']['target_directory'][$idx], $authorid); - serendipity_plugin_api::hook_event('backend_image_add', $target); - } else { - echo ERROR_UNKNOWN_NOUPLOAD . '
'; + foreach($thumbs as $thumb) { + // Create thumbnail + if ( $created_thumbnail = serendipity_makeThumbnail($tfile, $serendipity['POST']['target_directory'][$idx], $thumb['thumbSize'], $thumb['thumb']) ) { + echo THUMB_CREATED_DONE . '
'; + } } + + // Insert into database + $image_id = serendipity_insertImageInDatabase($tfile, $serendipity['POST']['target_directory'][$idx], $authorid, null, $realname); + serendipity_plugin_api::hook_event('backend_image_add', $target); + $new_media[] = array( + 'image_id' => $image_id, + 'target' => $target, + 'created_thumbnail' => $created_thumbnail + ); + } else { + echo ERROR_UNKNOWN_NOUPLOAD . '
'; } } } + + if (isset($_REQUEST['go_properties'])) { + serendipity_showPropertyForm($new_media); + } else { + $hidden = array( + 'author' => $serendipity['serendipityUser'], + 'authorid' => $serendipity['authorid'] + ); + + foreach($new_media AS $nm) { + serendipity_insertMediaProperty('base_hidden', '', $nm['image_id'], $hidden); + } + } break; @@ -302,22 +351,104 @@ switch ($serendipity['GET']['adminAction']) { break; + case 'directoryEdit': + if (!serendipity_checkPermission('adminImagesDirectories')) { + return; + } + + $use_dir = serendipity_uploadSecure($serendipity['GET']['dir']); + $checkpath = array( + array( + 'relpath' => $use_dir + ) + ); + + if (!serendipity_directoryACL($checkpath, 'write')) { + return; + } + + if (!empty($serendipity['POST']['save'])) { + $newDir = serendipity_uploadSecure($serendipity['POST']['newDir']); + $oldDir = serendipity_uploadSecure($serendipity['POST']['oldDir']); + + if ($oldDir != $newDir) { + serendipity_moveMediaDirectory($oldDir, $newDir); + $use_dir = $newDir; + } + serendipity_ACLGrant(0, 'directory', 'read', $serendipity['POST']['read_authors'], $use_dir); + serendipity_ACLGrant(0, 'directory', 'write', $serendipity['POST']['write_authors'], $use_dir); + echo '
' . sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '
'; + } + + $groups = serendipity_getAllGroups(); + $read_groups = serendipity_ACLGet(0, 'directory', 'read', $use_dir); + $write_groups = serendipity_ACLGet(0, 'directory', 'write', $use_dir); +?> + +
+
+ + + + + + + + + + + + + + + + + +
+ +
+ +
+
+
+
+ +
+ + + -
- +
+


-
+ - + @@ -326,8 +457,8 @@ switch ($serendipity['GET']['adminAction']) {

-
- +
+
@@ -340,13 +471,30 @@ switch ($serendipity['GET']['adminAction']) { } $new_dir = serendipity_uploadSecure($serendipity['POST']['parent'] . '/' . $serendipity['POST']['name'], true); - $new_dir = str_replace('..', '', $new_dir); + $new_dir = str_replace(array('..', '//'), array('', '/'), $new_dir); /* TODO: check if directory already exist */ if (@mkdir($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $new_dir)) { printf(DIRECTORY_CREATED, $serendipity['POST']['name']); @umask(0000); @chmod($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $new_dir, 0777); + + // Apply parent ACL to new child. + $array_parent_read = serendipity_ACLGet(0, 'directory', 'read', $serendipity['POST']['parent']); + $array_parent_write = serendipity_ACLGet(0, 'directory', 'write', $serendipity['POST']['parent']); + if (!is_array($array_parent_read) || count($array_parent_read) < 1) { + $parent_read = array(0); + } else { + $parent_read = array_keys($array_parent_read); + } + if (!is_array($array_parent_write) || count($array_parent_write) < 1) { + $parent_write = array(0); + } else { + $parent_write = array_keys($array_parent_write); + } + + serendipity_ACLGrant(0, 'directory', 'read', $parent_read, $new_dir . '/'); + serendipity_ACLGrant(0, 'directory', 'write', $parent_write, $new_dir . '/'); } else { printf(DIRECTORY_WRITE_ERROR, $new_dir); } @@ -357,12 +505,23 @@ switch ($serendipity['GET']['adminAction']) { if (!serendipity_checkPermission('adminImagesDirectories')) { return; } + + $folders = serendipity_traversePath( + $serendipity['serendipityPath'] . $serendipity['uploadPath'], + '', + true, + NULL, + 1, + NULL, + 'write' + ); + usort($folders, 'serendipity_sortPath'); ?> -
- +
+


- +
@@ -373,8 +532,8 @@ switch ($serendipity['GET']['adminAction']) { @@ -390,23 +549,33 @@ switch ($serendipity['GET']['adminAction']) { return; } + $folders = serendipity_traversePath( + $serendipity['serendipityPath'] . $serendipity['uploadPath'], + '', + true, + NULL, + 1, + NULL, + 'write' + ); + usort($folders, 'serendipity_sortPath'); ?> +

- -
-
+
- + - + - + +
<?php echo DELETE ?><?php echo EDIT ?><?php echo DELETE ?>

-
+
- - - + $folders = serendipity_traversePath( + $serendipity['serendipityPath'] . $serendipity['uploadPath'], + '', + true, + NULL, + 1, + NULL, + 'write' + ); + usort($folders, 'serendipity_sortPath'); - -
- - - - - $imgsel_val) { - echo ' ' . "\n"; + $form_hidden .= ' ' . "\n"; } } -?> - - - - - - - - - - - - - -
- -
- -
- - -
- - - - - - - - - - - - - - - - - - - -

-
-
-
- -
-
- - - - - -
- - -
-
-
- - serendipity_setFormToken(), + 'form_hidden' => $form_hidden, + 'folders' => $folders, + 'only_path' => $serendipity['GET']['only_path'], + 'max_file_size' => $serendipity['maxFileSize'], + 'maxImgHeight' => $serendipity['maxImgHeight'], + 'maxImgWidth' => $serendipity['maxImgWidth'], + ); + $serendipity['smarty']->assign('media', $mediaFiles); + $serendipity['smarty']->display(serendipity_getTemplateFile('admin/media_upload.tpl', 'serendipityPath')); break; case 'rotateCW': $file = serendipity_fetchImageFromDatabase($serendipity['GET']['fid']); - if (!serendipity_checkPermission('adminImagesDelete') || (!serendipity_checkPermission('adminImagesMaintainOthers') && $file['authorid'] != '0' && $file['authorid'] != $serendipity['authorid'])) { + if (!is_array($file) || !serendipity_checkPermission('adminImagesDelete') || (!serendipity_checkPermission('adminImagesMaintainOthers') && $file['authorid'] != '0' && $file['authorid'] != $serendipity['authorid'])) { return; } + if (empty($serendipity['adminFile_redirect'])) { + $serendipity['adminFile_redirect'] = htmlspecialchars($_SERVER['HTTP_REFERER']); + } + if (serendipity_rotateImg($serendipity['GET']['fid'], -90)) { ?> - + - + ', $file['path'] . $file['name'] .'.'. $file['extension'], - $serendipity['GET']['width'], - $serendipity['GET']['height'] + (int)$serendipity['GET']['width'], + (int)$serendipity['GET']['height'] ); echo serendipity_scaleImg($serendipity['GET']['fid'], $serendipity['GET']['width'], $serendipity['GET']['height']) . '
'; @@ -735,16 +679,16 @@ switch ($serendipity['GET']['adminAction']) { // Forward user to overview (we don't want the user's back button to rename things again) ?> - + @@ -816,8 +760,7 @@ switch ($serendipity['GET']['adminAction']) { } } //--> - - +
-
action="" method="post" ="serendipityEntry" style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px"> + action="" method="post" id="serendipityEntry" style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px"> @@ -525,7 +532,7 @@ function serendipity_emit_htmlarea_code($item, $jsname, $spawnMulti = false) { config = editor.config; config.registerButton('image_selector', '', 'htmlarea/images/ed_s9yimage.gif', false, function(editor, id) { - window.open('serendipity_admin_image_selector.php?serendipity[textarea]=', 'ImageSel', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1'); + window.open('serendipity_admin_image_selector.php?serendipity[textarea]=', 'ImageSel', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1'); editorref = editor; } ); diff --git a/serendipity_editor.js b/serendipity_editor.js index 12713f3..acac0b2 100644 --- a/serendipity_editor.js +++ b/serendipity_editor.js @@ -72,7 +72,7 @@ function wrapSelectionWithLink(txtarea) { document.getElementById && getMozSelection(txtarea) == "") { var my_desc = prompt("Enter Description", ''); } - + var my_title = prompt("Enter title/tooltip:", ""); html_title = ""; @@ -142,7 +142,7 @@ function serendipity_insLink (area) { area.focus(); return; } - + html_title = ""; if (my_title != "") { html_title = ' title="' + my_title + '"'; @@ -155,7 +155,9 @@ function serendipity_insLink (area) { function serendipity_imageSelector_addToElement (str, el) { document.getElementById(el).value = str; - document.getElementById(el).focus(); + if (document.getElementById(el).type != 'hidden' && document.getElementById(el).focus) { + document.getElementById(el).focus(); + } if (document.getElementById(el).onchange) { document.getElementById(el).onchange(); } @@ -183,7 +185,7 @@ function serendipity_imageSelector_done(textarea) var src = ''; var f = document.forms['serendipity[selForm]'].elements; - if (f['serendipity[linkThumbnail]'][0].checked == true) { + if (f['serendipity[linkThumbnail]'] && f['serendipity[linkThumbnail]'][0].checked == true) { img = f['thumbName'].value; imgWidth = f['imgThumbWidth'].value; imgHeight = f['imgThumbHeight'].value; @@ -193,10 +195,30 @@ function serendipity_imageSelector_done(textarea) imgHeight = f['imgHeight'].value; } - if (f['serendipity[filename_only]'] && f['serendipity[filename_only]'].value == 'true') { - self.opener.serendipity_imageSelector_addToElement(img, f['serendipity[htmltarget]'].value); - self.close(); - return true; + if (f['serendipity[filename_only]']) { + if (f['serendipity[htmltarget]']) { + starget = f['serendipity[htmltarget]'].value; + } else { + starget = 'serendipity[' + textarea + ']'; + } + + if (f['serendipity[filename_only]'].value == 'true') { + parent.self.opener.serendipity_imageSelector_addToElement(img, f['serendipity[htmltarget]'].value); + parent.self.close(); + return true; + } else if (f['serendipity[filename_only]'].value == 'id') { + parent.self.opener.serendipity_imageSelector_addToElement(f['imgID'].value, starget); + parent.self.close(); + return true; + } else if (f['serendipity[filename_only]'].value == 'thumb') { + parent.self.opener.serendipity_imageSelector_addToElement(f['thumbName'].value, starget); + parent.self.close(); + return true; + } else if (f['serendipity[filename_only]'].value == 'big') { + parent.self.opener.serendipity_imageSelector_addToElement(f['imgName'].value, starget); + parent.self.close(); + return true; + } } if (document.getElementById('serendipity_imagecomment').value != '') { @@ -205,31 +227,53 @@ function serendipity_imageSelector_done(textarea) styled = true; } + imgID = 0; + if (f['imgID']) { + imgID = f['imgID'].value; + } + baseURL = ''; + if (f['baseURL']) { + baseURL = f['baseURL'].value; + } + floating = 'center'; - if (XHTML11) { - if (f['serendipity[align]'][0].checked == true) { - img = "\"\""; - } else if (f['serendipity[align]'][1].checked == true) { - img = "\"\""; - floating = 'left'; - } else if (f['serendipity[align]'][2].checked == true) { - img = "\"\""; - floating = 'right'; - } - } else { - if (f['serendipity[align]'][0].checked == true) { - img = ""; - } else if (f['serendipity[align]'][1].checked == true) { - img = ""; - floating = 'left'; - } else if (f['serendipity[align]'][2].checked == true) { - img = ""; - floating = 'right'; - } + if (f['serendipity[align]'][0].checked == true) { + img = "\"\""; + } else if (f['serendipity[align]'][1].checked == true) { + img = "\"\""; + floating = 'left'; + } else if (f['serendipity[align]'][2].checked == true) { + img = "\"\""; + floating = 'right'; } if (f['serendipity[isLink]'][1].checked == true) { - insert = "" + img + ""; + if (f['serendipity[target]'].selectedIndex) { + targetval = f['serendipity[target]'].options[f['serendipity[target]'].selectedIndex].value; + } else { + targetval = ''; + } + + prepend = ''; + ilink = f['serendipity[url]'].value; + if (!targetval || targetval == 'none') { + itarget = ''; + } else if (targetval == 'js') { + itarget = ' onclick="F1 = window.open(\'' + f['serendipity[url]'].value + '\',\'Zoom\',\'' + + 'height=' + (parseInt(f['imgHeight'].value) + 15) + ',' + + 'width=' + (parseInt(f['imgWidth'].value) + 15) + ',' + + 'top=' + (screen.height - f['imgHeight'].value) /2 + ',' + + 'left=' + (screen.width - f['imgWidth'].value) /2 + ',' + + 'toolbar=no,menubar=no,location=no,resize=1,resizable=1,scrollbars=yes\'); return false;"'; + } else if (targetval == '_blank') { + itarget = ' target="_blank"'; + } else if (targetval == 'plugin') { + itarget = ' id="s9yisphref' + imgID + '" onclick="javascript:this.href = this.href + \'&serendipity[from]=\' + self.location.href;"'; + prepend = ''; + ilink = baseURL + 'serendipity_admin_image_selector.php?serendipity[step]=showItem&serendipity[image]=' + imgID; + } + + insert = prepend + "" + img + ""; } else { insert = img; } @@ -244,14 +288,15 @@ function serendipity_imageSelector_done(textarea) block = insert; } - if (self.opener.editorref) { - self.opener.editorref.surroundHTML(block, ''); + if (typeof(parent.self.opener.htmlarea_editors) != 'undefined' && typeof(parent.self.opener.htmlarea_editors[textarea] != 'undefined')) { + parent.self.opener.htmlarea_editors[textarea].surroundHTML(block, ''); + } else if (parent.self.opener.editorref) { + parent.self.opener.editorref.surroundHTML(block, ''); } else { - - self.opener.serendipity_imageSelector_addToBody(block, textarea); + parent.self.opener.serendipity_imageSelector_addToBody(block, textarea); } - self.close(); + parent.self.close(); } // -->