Trunk, 0.7: Add patch [ 1597978 ] Missing tag rename for 0.7.2
authorMarcus Campbell <marcus.campbell@gmail.com>
Sat, 9 Dec 2006 06:43:03 +0000 (06:43 +0000)
committerMarcus Campbell <marcus.campbell@gmail.com>
Sat, 9 Dec 2006 06:43:03 +0000 (06:43 +0000)
tagrename.php [new file with mode: 0644]
templates/tagrename.tpl.php [new file with mode: 0644]

diff --git a/tagrename.php b/tagrename.php
new file mode 100644 (file)
index 0000000..0fd2f1a
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+/***************************************************************************
+Copyright (C) 2006 Scuttle project
+http://sourceforge.net/projects/scuttle/
+http://scuttle.org/
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+***************************************************************************/
+
+require_once('header.inc.php');
+$tagservice = & ServiceFactory :: getServiceInstance('TagService');
+$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
+$userservice = & ServiceFactory :: getServiceInstance('UserService');
+
+list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
+
+if ($_POST['confirm']) {
+       if (isset($_POST['old']) && (trim($_POST['old']) != ''))
+           $old = trim($_REQUEST['old']);
+       else
+           $old = NULL;
+
+       if (isset($_POST['new']) && (trim($_POST['new']) != ''))
+           $new = trim($_POST['new']);
+       else
+           $new = NULL;
+
+       if (is_null($old) || is_null($new)) {
+            $tplVars['error'] = T_('Failed to rename the tag');
+            $templateservice->loadTemplate('error.500.tpl', $tplVars);
+            exit();
+       } else {
+           // Rename the tag.
+           if($tagservice->renameTag($userservice->getCurrentUserId(), $old, $new, true)) {
+                    $tplVars['msg'] = T_('Tag renamed');
+                    $logged_on_user = $userservice->getCurrentUser();
+                    header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
+               } else {
+                    $tplVars['error'] = T_('Failed to rename the tag');
+                    $templateservice->loadTemplate('error.500.tpl', $tplVars);
+                    exit();
+               }
+       }
+} elseif ($_POST['cancel']) {
+    $logged_on_user = $userservice->getCurrentUser();
+    header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')] .'/'. $tags));
+}
+
+$tplVars['subtitle']    = T_('Rename Tag') .': '. $tag;
+$tplVars['formaction']  = $_SERVER['SCRIPT_NAME'] .'/'. $tag;
+$tplVars['referrer']    = $_SERVER['HTTP_REFERER'];
+$tplVars['old'] = $tag;
+$templateservice->loadTemplate('tagrename.tpl', $tplVars);
+?>
+                
diff --git a/templates/tagrename.tpl.php b/templates/tagrename.tpl.php
new file mode 100644 (file)
index 0000000..2e93fad
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+$this->includeTemplate($GLOBALS['top_include']);
+?>
+<script type="text/javascript">
+window.onload = function() {
+    document.getElementById("new").focus();
+}
+</script>
+<form action="<?= $formaction ?>" method="post">
+<table>
+<tr>
+    <th align="left"><?php echo T_('Old'); ?></th>
+    <td><input type="text" name="old" id="old" value="<?= $old ?>" /></td>
+    <td>&larr; <?php echo T_('Required'); ?></td>
+</tr>
+<tr>
+    <th align="left"><?php echo T_('New'); ?></th>
+    <td><input type="text" name="new" id="new" value="" /></td>
+    <td>&larr; <?php echo T_('Required'); ?></td>
+</tr>
+<tr>
+    <td></td>
+    <td>
+    <input type="submit" name="confirm" value="<?php echo T_('Rename'); ?>" />
+    <input type="submit" name="cancel" value="<?php echo T_('Cancel'); ?>" />
+    </td>
+    <td></td>
+</tr>
+
+</table>
+</p>
+
+<?php if (isset($referrer)): ?>
+<div><input type="hidden" name="referrer" value="<?php echo $referrer; ?>" /></div>
+<?php endif; ?>
+
+</form>
+
+<?php
+$this->includeTemplate($GLOBALS['bottom_include']); 
+?>
+                

Benjamin Mako Hill || Want to submit a patch?