Update of /cvsroot/php-blog/serendipity/include/admin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23780/include/admin
Modified Files:
category.inc.php entries.inc.php images.inc.php
Log Message:
- Rewrite directories in terms of layout and a few core functions, fixed a few possible bugs
- Don't run imagick command after using gdlib to resize an image
- Replace old fake buttons with new and pretty fake buttons
Layout of directory overview is pending change
Index: category.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/admin/category.inc.php,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- category.inc.php 27 Jan 2005 10:54:19 -0000 1.12
+++ category.inc.php 3 Feb 2005 18:04:41 -0000 1.13
@@ -232,15 +232,7 @@
} ?>
<tr>
<td colspan="6" align="right">
- <noscript>
- <a href="?serendipity[adminModule]=category&serendipity[adminAction]=new"
- class="button"><?php echo CREATE_NEW_CAT ?></a>
- </noscript>
- <script type="text/javascript">
- <!--
- document.write('<input type="button" value="<?php echo CREATE_NEW_CAT ?>" onclick="location.href=\'?serendipity[adminModule]=category&serendipity[adminAction]=new\'" class="serendipityPrettyButton">');
- // -->
- </script>
+ <a href="?serendipity[adminModule]=category&serendipity[adminAction]=new" class="serendipityPrettyButton"><?php echo CREATE_NEW_CAT ?></a>
</td>
</tr>
</table>
Index: entries.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/admin/entries.inc.php,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- entries.inc.php 26 Jan 2005 14:14:04 -0000 1.18
+++ entries.inc.php 3 Feb 2005 18:04:41 -0000 1.19
@@ -373,10 +373,11 @@
printf(DELETE_SURE, $serendipity['GET']['id']);
?>
<br />
+<br />
<div>
- <a href="<?php echo $_SERVER["HTTP_REFERER"]; ?>" class="button"><?php echo NOT_REALLY; ?></a>
- <span style="width: 50px;"></span>
- <a href="<?php echo $newLoc; ?>" class="button"><?php echo DUMP_IT; ?></a>
+ <a href="<?php echo $_SERVER["HTTP_REFERER"]; ?>" class="serendipityPrettyButton"><?php echo NOT_REALLY; ?></a>
+ <?php echo str_repeat(' ', 10); ?>
+ <a href="<?php echo $newLoc; ?>" class="serendipityPrettyButton"><?php echo DUMP_IT; ?></a>
</div>
<?php
break;
Index: images.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/admin/images.inc.php,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- images.inc.php 27 Jan 2005 10:54:19 -0000 1.13
+++ images.inc.php 3 Feb 2005 18:04:42 -0000 1.14
@@ -44,18 +44,9 @@
?>
<form method="get" name="delete_image">
<div>
- <noscript>
- <a href="<?php echo $newLoc; ?>"
- class="button"><?php echo DUMP_IT ?></a>
+ <a href="<?php echo $newLoc; ?>" class="serendipityPrettyButton"><?php echo DUMP_IT ?></a>
- <a href="<?php echo $abortLoc; ?>"
- class="button"><?php echo ABORT_NOW ?></a>
- </noscript>
- <script type="text/javascript">
- <!--
- document.write('<input type="button" value="<?php echo DUMP_IT ?>" onclick="location.href=\'<?php echo $newLoc; ?>\'" /> <input type="button" value="<?php echo ABORT_NOW ?>" onclick="location.href=\'<?php echo $abortLoc; ?>\'" />');
- // -->
- </script>
+ <a href="<?php echo $abortLoc; ?>" class="serendipityPrettyButton"><?php echo ABORT_NOW ?></a>
</div>
</form>
<?php
@@ -63,7 +54,7 @@
case 'rename':
$file = serendipity_fetchImageFromDatabase($serendipity['GET']['fid']);
- serendipity_uploadSecure($serendipity['GET']['newname']);
+ $serendipity['GET']['newname'] = serendipity_uploadSecure($serendipity['GET']['newname']);
if ($serendipity['serendipityUserlevel'] < USERLEVEL_CHIEF && $file['authorid'] != '0' && $file['authorid'] != $serendipity['authorid']) {
return;
@@ -125,8 +116,8 @@
break;
}
- serendipity_uploadSecure($tfile);
- serendipity_uploadSecure($serendipity['POST']['target_directory'], true);
+ $tfile = serendipity_uploadSecure($tfile);
+ $serendipity['POST']['target_directory'] = serendipity_uploadSecure($serendipity['POST']['target_directory'], true);
$target = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $serendipity['POST']['target_directory'] . $tfile;
if (file_exists($target)) {
@@ -164,8 +155,8 @@
break;
}
- serendipity_uploadSecure($tfile);
- serendipity_uploadSecure($serendipity['POST']['target_directory'], true);
+ $tfile = serendipity_uploadSecure($tfile);
+ $serendipity['POST']['target_directory'] = serendipity_uploadSecure($serendipity['POST']['target_directory'], true);
$target = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $serendipity['POST']['target_directory'] . $tfile;
if (file_exists($target)) {
@@ -187,118 +178,136 @@
}
break;
- case 'directorySelect':
+
+ case 'directoryDoDelete':
if ($serendipity['serendipityUserlevel'] < USERLEVEL_CHIEF) {
return;
}
+ $new_dir = serendipity_uploadSecure($serendipity['GET']['dir'], true);
+ if (is_dir($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $new_dir)) {
+ if (!is_writable($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $new_dir)) {
+ printf(DIRECTORY_WRITE_ERROR, $new_dir);
+ } else {
+ // Directory exists and is writable. Now dive within subdirectories and kill 'em all.
+ serendipity_killPath($serendipity['serendipityPath'] . $serendipity['uploadPath'], $new_dir, (isset($serendipity['POST']['nuke']) ? true : false));
+ }
+ } else {
+ printf(ERROR_NO_DIRECTORY, $new_dir);
+ }
+
+ break;
+ case 'directoryDelete':
+ if ($serendipity['serendipityUserlevel'] < USERLEVEL_CHIEF) {
+ return;
+ }
?>
+
+ <strong><?php echo DELETE_DIRECTORY ?></strong><br />
+ <?php echo DELETE_DIRECTORY_DESC ?>
<br />
-<?php
- if (!empty($serendipity['POST']['directoryMode']) && !empty($serendipity['POST']['newDirectoryName'])) {
- serendipity_uploadSecure($serendipity['POST']['newDirectoryName'], true);
+ <br />
+ <form method="POST" action="?serendipity[adminModule]=images&serendipity[adminAction]=directoryDoDelete&serendipity[dir]=<?php echo $serendipity['GET']['dir'] ?>">
+ <table cellpadding="5">
+ <tr>
+ <td width="100"><strong><?php echo NAME ?></strong></td>
+ <td><?php echo basename($serendipity['GET']['dir']) ?></td>
+ </tr>
+ <tr>
+ <td colspan="2"><input type="checkbox" name="serendipity[nuke]" value="true" style="margin: 0"> <?php echo FORCE_DELETE ?></td>
+ </tr>
+ </table>
+ <br />
+ <br />
+ <div align="center">
+ <?php echo sprintf(CONFIRM_DELETE_DIRECTORY, $serendipity['GET']['dir']) ?><br />
+ <input name="SAVE" value="<?php echo NOT_REALLY ?>" class="serendipityPrettyButton" type="button"> <input name="SAVE" value="<?php echo DELETE_DIRECTORY ?>" class="serendipityPrettyButton" type="submit">
+ </div>
+ </form>
- $new_dir = $serendipity['uploadPath'] .
- $serendipity['POST']['newDirectoryName'];
+<?php
+ break;
- switch($serendipity['POST']['directoryMode']) {
- case 'create':
- if (@mkdir($serendipity['serendipityPath'] . $new_dir)) {
- printf(DIRECTORY_CREATED, $new_dir);
- @umask(0000);
- @chmod($serendipity['serendipityPath'] . $new_dir, 0777);
- } else {
- printf(DIRECTORY_WRITE_ERROR, $new_dir);
- }
- echo '<br /><hr />';
- break;
- case 'delete':
- $path = $serendipity['serendipityPath'] . $new_dir;
- if (is_dir($path)) {
- if (!is_writable($serendipity['serendipityPath'] . $serendipity['uploadPath'])) {
- printf(DIRECTORY_WRITE_ERROR, $new_dir);
- } else {
- // Directory exists and is writable. Now dive within subdirectories and kill 'em all.
- serendipity_killPath(
- $serendipity['serendipityPath'] . $serendipity['uploadPath'],
- $serendipity['POST']['newDirectoryName'],
- (isset($serendipity['POST']['forceDelete']) ? true : false)
- );
- }
- } else {
- printf(ERROR_NO_DIRECTORY, $new_dir);
- }
- echo '<br /><hr />';
- break;
- }
+ case 'directoryDoCreate':
+ if ($serendipity['serendipityUserlevel'] < USERLEVEL_CHIEF) {
+ return;
}
- $jscode = "document.getElementById('newDirectory').value = this.title; return false;";
-
- echo DIRECTORIES_AVAILABLE;
- echo '<br /><br /><a href="#" onclick="' . $jscode . '" title="/">' . PARENT_DIRECTORY . ' (' . $serendipity['uploadPath'] . ')</a>';
-
- serendipity_traversePath(
- $out,
- $serendipity['serendipityPath'] . $serendipity['uploadPath'],
- $jscode
- );
+ $new_dir = serendipity_uploadSecure($serendipity['POST']['parent'] . DIRECTORY_SEPARATOR . $serendipity['POST']['name'], true);
+ $new_dir = str_replace('..', '', $new_dir);
- echo $out;
-?>
- <script type="text/javascript">
- function verify_submit() {
- if (document.getElementById('mode_delete').checked) {
- warnmsg = '<?php echo CONFIRM_DELETE_DIRECTORY; ?>';
- warnmsg = warnmsg.replace('%s', document.getElementById('newDirectory').value);
- return confirm(warnmsg);
+ /* 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);
} else {
- return true;
+ printf(DIRECTORY_WRITE_ERROR, $new_dir);
}
- }
- </script>
- <form action="?" method="POST" id="directoryform" onsubmit="return verify_submit()">
- <div>
- <input type="hidden" name="serendipity[action]" value="admin" />
- <input type="hidden" name="serendipity[adminModule]" value="images" />
- <input type="hidden" name="serendipity[adminAction]" value="directorySelect" />
- </div>
- <table>
- <tr>
- <td>
- <input type="radio" name="serendipity[directoryMode]" value="create" id="mode_create" checked="checked" />
- <label for="mode_create"><?php echo NEW_DIRECTORY; ?></label>
- </td>
- <td rowspan="2"><input type="text" id="newDirectory" name="serendipity[newDirectoryName]" value="" /></td>
- </tr>
- <tr>
- <td>
- <input type="radio" name="serendipity[directoryMode]" value="delete" id="mode_delete" />
- <label for="mode_delete"><?php echo DELETE_DIRECTORY; ?></label>
- </td>
- </tr>
+ break;
- <tr>
- <td colspan="2">
-
- <input type="checkbox" name="serendipity[forceDelete]" value="true" id="forceDelete" />
- <label for="forceDelete"><?php echo FORCE_DELETE; ?></label>
- </td>
- </tr>
- <tr>
- <td> </td>
- <td><input type="submit" value="<?php echo GO; ?>"/></td>
- </tr>
- </table>
+ case 'directoryCreate':
+ if ($serendipity['serendipityUserlevel'] < USERLEVEL_CHIEF) {
+ return;
+ }
+?>
+ <strong><?php echo CREATE_DIRECTORY ?></strong><br />
+ <?php echo CREATE_DIRECTORY_DESC ?>
+ <br />
+ <br />
+ <form method="POST" action="?serendipity[adminModule]=images&serendipity[adminAction]=directoryDoCreate">
+ <table cellpadding="5">
+ <tr>
+ <td><?php echo NAME ?></td>
+ <td><input type="text" name="serendipity[name]" value="" /></td>
+ </tr>
+ <tr>
+ <td><?php echo PARENT_DIRECTORY ?></td>
+ <td><select name="serendipity[parent]">
+ <option value=""><?php echo BASE_DIRECTORY ?></option>
+ <?php foreach ( serendipity_traversePath($serendipity['serendipityPath'] . $serendipity['uploadPath']) as $folder ) { ?>
+ <option value="<?php echo $folder['relpath'] ?>"><?php echo str_repeat(' ', $folder['depth']*2) . ' '. $folder['name'] ?></option>
+ <?php } ?>
+ </select>
+ </td>
+ </tr>
+ </table>
+ <div><input name="SAVE" value="<?php echo CREATE_DIRECTORY ?>" class="serendipityPrettyButton" type="submit"></div>
</form>
<?php
break;
+ case 'directorySelect':
+ if ($serendipity['serendipityUserlevel'] < USERLEVEL_CHIEF) {
+ return;
+ }
+
+?>
+ <br />
+ <?php echo DIRECTORIES_AVAILABLE; ?>
+ <br />
+ <table border="0" cellspacing="0" cellpadding="4" width="100%">
+ <tr>
+ <td colspan="2"><strong><?php echo BASE_DIRECTORY ?></strong></td>
+ </tr>
+ <?php foreach ( serendipity_traversePath($serendipity['serendipityPath'] . $serendipity['uploadPath']) as $folder ) { ?>
+ <tr>
+ <td width="16"><a href="?serendipity[adminModule]=images&serendipity[adminAction]=directoryDelete&serendipity[dir]=<?php echo urlencode($folder['relpath']) ?>"><img src="<?php echo serendipity_getTemplateFile('admin/img/delete.png') ?>" alt="<?php echo DELETE ?>" border="0"></a></td>
+ <td style="padding-left: <?php echo $folder['depth']*10 ?>"><?php echo $folder['name'] ?></td>
+ </tr>
+ <?php } ?>
+ </table>
+ <br />
+ <div><a href="?serendipity[adminModule]=images&serendipity[adminAction]=directoryCreate" class="serendipityPrettyButton"><?php echo CREATE_NEW_DIRECTORY ?></a></div>
+
+<?php
+ break;
+
case 'addSelect':
?>
<?php echo ADD_MEDIA_BLAHBLAH; ?>
@@ -352,8 +361,10 @@
<td><?php echo STORE_IN_DIRECTORY; ?></td>
<td>
<select name="serendipity[target_directory]">
- <option value=""><?php echo PARENT_DIRECTORY; ?></option>
- <?php serendipity_traversePath($out, $serendipity['serendipityPath'] . $serendipity['uploadPath'], '', '', false, '', 2); echo $out; ?>
+ <option value=""><?php echo BASE_DIRECTORY; ?></option>
+ <?php foreach (serendipity_traversePath($serendipity['serendipityPath'] . $serendipity['uploadPath']) as $folder) { ?>
+ <option <?php echo ($serendipity['GET']['only_path'] == $folder['relpath']) ? 'selected="selected"' : '' ?> value="<?php echo $folder['relpath'] ?>"><?php echo str_repeat(' ', $folder['depth']*2) . ' '. $folder['name'] ?></option>
+ <?php } ?>
</select>
</td>
</tr>
|