<tr>
<td><?php echo NAME; ?></td>
<td><input type="text" name="serendipity[cat][name]" value="<?php echo isset($this_cat['category_name']) ? htmlspecialchars($this_cat['category_name']) : ''; ?>" /></td>
- <td rowspan="5" align="center" valign="middle" width="200" style="border: 1px solid #ccc"><img src="<?php echo isset($this_cat['category_icon']) ? $this_cat['category_icon'] : '' ?>" id="imagepreview" <?php echo empty($this_cat['category_icon']) ? 'style="display: none"' : '' ?>></td>
+ <td rowspan="5" align="center" valign="middle" width="200" style="border: 1px solid #ccc"><img src="<?php echo isset($this_cat['category_icon']) ? $this_cat['category_icon'] : '' ?>" id="imagepreview" <?php echo empty($this_cat['category_icon']) ? 'style="display: none"' : '' ?> /></td>
</tr>
<tr>
'a.realname' => AUTHOR,
'category_name' => CATEGORY,
'last_modified' => LAST_UPDATED,
- 'title' => TITLE);
+ 'title' => TITLE,
+ 'id' => 'ID');
$per_page = array('12', '16', '50', '100');
return;
}
- $abortLoc = $serendipity['serendipityHTTPPath'] . 'serendipity_admin.php?serendipity[adminModule]=images';
+ if (!isset($serendipity['adminFile'])) {
+ $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');
printf(ABOUT_TO_DELETE_FILE, $file['name'] .'.'. $file['extension']);
$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($oldfile, $newfile);
+ 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']);
+ }
- // Rename thumbnail
- rename($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $file['path'] . $file['name'] . (!empty($file['thumbnail_name']) ? '.' . $file['thumbnail_name'] : '') . '.' . $file['extension'],
- $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $file['path'] . $serendipity['GET']['newname'] . '.' . $serendipity['thumbSuffix'] . '.' . $file['extension']);
+ serendipity_updateImageInDatabase(array('thumbnail_name' => $renameValues[0]['thumb'], 'name' => $serendipity['GET']['newname']), $serendipity['GET']['fid']);
- serendipity_updateImageInDatabase(array('thumbnail_name' => $serendipity['thumbSuffix'], '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)) {
printf(FILE_FETCHED . '<br />', $serendipity['POST']['imageurl'], $tfile);
- // Create thumbnail
- if ( $created_thumbnail = serendipity_makeThumbnail($tfile, $serendipity['POST']['target_directory'][$tindex]) ) {
- echo THUMB_CREATED_DONE . '<br />';
+ $thumbs = array(array(
+ 'thumbSize' => $serendipity['thumbSize'],
+ 'thumb' => $serendipity['thumbSuffix']
+ ));
+ serendipity_plugin_api::hook_event('backend_media_makethumb', $thumbs);
+
+ foreach($thumbs as $thumb) {
+ // Create thumbnail
+ if ( $created_thumbnail = serendipity_makeThumbnail($tfile, $serendipity['POST']['target_directory'][$tindex], $thumb['thumbSize'], $thumb['thumb']) ) {
+ echo THUMB_CREATED_DONE . '<br />';
+ }
}
+
// Insert into database
$image_id = serendipity_insertImageInDatabase($tfile, $serendipity['POST']['target_directory'][$tindex], $authorid);
serendipity_plugin_api::hook_event('backend_image_add', $target);
@umask(0000);
@chmod($target, 0664);
- // Create thumbnail
- if ( $created_thumbnail = serendipity_makeThumbnail($tfile, $serendipity['POST']['target_directory'][$idx]) ) {
- echo THUMB_CREATED_DONE . '<br />';
+ $thumbs = array(array(
+ 'thumbSize' => $serendipity['thumbSize'],
+ 'thumb' => $serendipity['thumbSuffix']
+ ));
+ serendipity_plugin_api::hook_event('backend_media_makethumb', $thumbs);
+
+ 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 . '<br />';
+ }
}
+
// Insert into database
$image_id = serendipity_insertImageInDatabase($tfile, $serendipity['POST']['target_directory'][$idx], $authorid);
serendipity_plugin_api::hook_event('backend_image_add', $target);
<?php
+ if (!isset($serendipity['thumbPerPage'])) {
+ $serendipity['thumbPerPage'] = 2;
+ }
serendipity_displayImageList(
isset($serendipity['GET']['page']) ? $serendipity['GET']['page'] : 1,
- 2,
+ $serendipity['thumbPerPage'],
true
);
return $this->inputFields;
}
+ function toTime($string) {
+ $ts = strtotime($string);
+ $this->debug('Calling strtotime(' . $string . ') = ' . $ts);
+ if ($ts <= 1) {
+ // Match strings like: "11/16/2005 00:14:53 PM"
+ if (preg_match('@([01][0-9])/([0-3][0-9])/([0-9]{4}) ([0-2][0-9]):([0-5][0-9]):([0-5][0-9]) (P|A)M@i', $string, $match)) {
+ if ($match[7] == 'P') {
+ // Post mediam, add 12 hours.
+ $match[4] = $match[4] + 12;
+ }
+
+ $ts = mktime($match[4], $match[5], $match[6], $match[1], $match[2], $match[3]);
+ $this->debug('Matched string date format: ' . $ts);
+ }
+ }
+
+ if ($ts <= 1) {
+ $ts = time();
+ }
+
+ return $ts;
+ }
+
function doEntryWork(&$mt_entry, &$tasks){
global $serendipity;
$entry['allow_comments'] = ($data == '1') ? 'true' : 'false';
break;
case 'DATE':
- $entry['timestamp'] = strtotime($data);
- if ($entry['timestamp'] == 0) {
- $entry['timestamp'] = time();
- }
+ $entry['timestamp'] = $this->totime($data);
break;
case 's9y_body':
break;
case 'DATE':
- $comment['timestamp'] = strtotime($data);
- if ($comment['timestamp'] == 0) {
- $comment['timestamp'] = time();
- }
+ $comment['timestamp'] = $this->toTime($data);
break;
case 'REPLY':
$tline = trim($line);
$this->debug("Continuing inspecting next line: $line");
}
- if (preg_match('/^([A-Z\s]+):/', $line, $matches)) {
+ if (preg_match('/^--------/', $line)) {
+ $this->debug('Next line is new element. End marker found. Parsing full entry.');
+ $entries[] = $this->doEntryWork($entry, $tasks);
+ $entry = array();
+ $el = "";
+ $c_el = "";
+ $skip = false;
+ $is_comment = false;
+ $is_trackback = false;
+ } elseif (preg_match('/^([A-Z\s]+):/', $line, $matches)) {
$this->debug("Match result: $matches[1]");
if ($matches[1] == 'COMMENT') {
$this->debug("Marking COMMENT.");
if ( !is_int($r = serendipity_updertEntry($entry)) ) {
echo '<div class="serendipityAdminMsgError">' . $r . '</div>';
} else {
+ $this->debug('Saved entry ' . $r . ' (' . $entry['title'] . ')');
$entry['id'] = $r;
foreach((array)$comments AS $comment) {
$comment['entry_id'] = $r;
*/
function serendipity_deleteImage($id) {
global $serendipity;
+ $dThumb = array();
+
$file = serendipity_fetchImageFromDatabase($id);
$dFile = $file['path'] . $file['name'] . '.' . $file['extension'];
- $dThumb = $file['path'] . $file['name'] . (!empty($file['thumbnail_name']) ? '.' . $file['thumbnail_name'] : '') . '.' . $file['extension'];
+
+ $dThumb = array(array(
+ 'fthumb' => $file['thumbnail_name']
+ ));
if (!serendipity_checkPermission('adminImagesDelete')) {
return;
printf(DELETE_FILE_FAIL . '<br />', $dFile);
}
- if (@unlink($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $dThumb)) {
- printf(DELETE_THUMBNAIL . '<br />', $dThumb);
+ serendipity_plugin_api::hook_event('backend_media_delete', $dThumb);
+ foreach($dThumb as $thumb) {
+ $dfnThumb = $file['path'] . $file['name'] . (!empty($dThumb['fthumb']) ? '.' . $dThumb['fthumb'] : '') . '.' . $file['extension'];
+ $dfThumb = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $dfnThumb;
+
+ if (@unlink($dfThumb)) {
+ printf(DELETE_THUMBNAIL . '<br />', $dfnThumb);
+ }
}
} else {
printf(FILE_NOT_FOUND . '<br />', $dFile);
* @access public
* @param string The input image filename
* @param string The directory to the image file
- * @param array The target size of the thumbnail (2-dimensional array width,height)
+ * @param string The target size of the thumbnail (2-dimensional array width,height)
+ * @param string Name of the thumbnail
* @return array The result size of the thumbnail
*/
-function serendipity_makeThumbnail($file, $directory = '', $size = false) {
+function serendipity_makeThumbnail($file, $directory = '', $size = false, $thumbname = false) {
global $serendipity;
if ($size === false) {
$size = $serendipity['thumbSize'];
}
+
+ if ($thumbname === false) {
+ $thumbname = $serendipity['thumbSuffix'];
+ }
$t = serendipity_parseFileName($file);
$f = $t[0];
$infile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $directory . $file;
- $outfile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $directory . $f . '.' . $serendipity['thumbSuffix'] . '.' . $suf;
+ $outfile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $directory . $f . '.' . $thumbname . '.' . $suf;
$fdim = @serendipity_getimagesize($infile, '', $suf);
if (isset($fdim['noimage'])) {
$thumbHeight = $thumbsize[1];
$imgsrc = $file['imgsrc'];
}
- $file['finishJSFunction'] = 'serendipity_imageSelector_done(\'' . $serendipity['GET']['textarea'] . '\')';
+ $file['finishJSFunction'] = 'serendipity_imageSelector_done(\'' . htmlspecialchars($serendipity['GET']['textarea']) . '\')';
serendipity_plugin_api::hook_event('frontend_image_selector', $file);
?>
<img align="right" src="<?php echo $imgsrc; ?>">
<input type="hidden" name="imgThumbHeight" value="<?php echo $thumbHeight; ?>" />
<input type="hidden" name="imgWidth" value="<?php echo $dimWidth; ?>" />
<input type="hidden" name="imgHeight" value="<?php echo $dimHeight; ?>" />
+ <input type="hidden" name="imgID" value="<?php echo (int)$serendipity['GET']['image']; ?>" />
<input type="hidden" name="imgName" value="<?php echo $imgName; ?>" />
<input type="hidden" name="thumbName" value="<?php echo $thumbName; ?>" />
<input type="hidden" name="hotlink" value="<?php echo $file['hotlink']; ?>" />
<br />
<?php
+ if (!isset($serendipity['thumbPerPage2'])) {
+ $serendipity['thumbPerPage2'] = 3;
+ }
+
serendipity_displayImageList(
isset($serendipity['GET']['page']) ? $serendipity['GET']['page'] : 1,
- 3,
+ $serendipity['thumbPerPage2'],
false,
'?serendipity[step]=1' . $add_url . '&serendipity[textarea]='. $serendipity['GET']['textarea'],
true