Migrate hooks to H4 (Request #8954).
authorJan Schneider <jan@horde.org>
Thu, 8 Apr 2010 08:28:39 +0000 (10:28 +0200)
committerJan Schneider <jan@horde.org>
Thu, 8 Apr 2010 08:29:08 +0000 (10:29 +0200)
mnemo/config/hooks.php.dist
mnemo/notes/index.php
mnemo/templates/memo/memo.inc
mnemo/templates/view/memo.inc

index d2eb43e..99f637d 100644 (file)
@@ -1,26 +1,39 @@
 <?php
 /**
- * Example hooks for Mnemo
+ * Mnemo Hooks configuration file.
  *
- * $Horde: mnemo/config/hooks.php.dist,v 1.1 2008/11/26 21:21:02 chuck Exp $
+ * THE HOOKS PROVIDED IN THIS FILE ARE EXAMPLES ONLY.  DO NOT ENABLE THEM
+ * BLINDLY IF YOU DO NOT KNOW WHAT YOU ARE DOING.  YOU HAVE TO CUSTOMIZE THEM
+ * TO MATCH YOUR SPECIFIC NEEDS AND SYSTEM ENVIRONMENT.
+ *
+ * For more information please see the horde/config/hooks.php.dist file.
+ *
+ * $Id$
  */
 
-// if (!function_exists('_mnemo_hook_format_description')) {
-//     function _mnemo_hook_format_description($text)
-//     {
-//         $text = preg_replace('/#(\d+)/', '<a href="http://bugs.horde.org/ticket/\1">\0</a>', $text);
-//         $text = preg_replace('/(bug|ticket|request|enhancement|issue):\s*#?(\d+)/i', '<a href="http://bugs.horde.org/ticket/\1">\0</a>', $text);
+class Mnemo_Hooks
+{
+    /**
+     * TODO
+     */
+//    function format_description($text)
+//    {
+//        $text = preg_replace('/#(\d+)/', '<a href="http://bugs.horde.org/ticket/\1">\0</a>', $text);
+//        $text = preg_replace('/(bug|ticket|request|enhancement|issue):\s*#?(\d+)/i', '<a href="http://bugs.horde.org/ticket/\1">\0</a>', $text);
 //
-//         $text = preg_replace_callback('/\[\[note: ?(.*)\]\]/i', create_function('$m', 'return \'<a href="/horde/mnemo/notes/?q=\' . urlencode($m[1]) . \'">\' . htmlspecialchars($m[0]) . \'</a>\';'), $text);
-//         $text = preg_replace_callback('/\[\[task: ?(.*)\]\]/i', create_function('$m', 'return \'<a href="/horde/nag/tasks/?q=\' . urlencode($m[1]) . \'">\' . htmlspecialchars($m[0]) . \'</a>\';'), $text);
+//        $text = preg_replace_callback('/\[\[note: ?(.*)\]\]/i', create_function('$m', 'return \'<a href="/horde/mnemo/notes/?q=\' . urlencode($m[1]) . \'">\' . htmlspecialchars($m[0]) . \'</a>\';'), $text);
+//        $text = preg_replace_callback('/\[\[task: ?(.*)\]\]/i', create_function('$m', 'return \'<a href="/horde/nag/tasks/?q=\' . urlencode($m[1]) . \'">\' . htmlspecialchars($m[0]) . \'</a>\';'), $text);
 //
-//         return $text;
-//     }
-// }
+//        return $text;
+//    }
+
+
+    /**
+     * TODO
+     */
+//    function description_help()
+//    {
+//        return '<p>To create a link to a bug, use #123 where 123 is the bug number. To create a link to another task, use [[task: name]], where name is the beginning of the task name. To create a link to a note, use [[note: title]] where title is the beginning of the note title.</p>';
+//    }
 
-// if (!function_exists('_mnemo_hook_description_help')) {
-//     function _mnemo_hook_description_help()
-//     {
-//         return '<p>To create a link to a bug, use #123 where 123 is the bug number. To create a link to a task, use [[task: name]], where name is the beginning of the task name. To create a link to another note, use [[note: title]] where title is the beginning of the note title.</p>';
-//     }
-// }
+}
index 3b1987d..934c750 100644 (file)
@@ -8,7 +8,9 @@
  * did not receive this file, see http://www.horde.org/licenses/asl.php.
  */
 
-require_once dirname(__FILE__) . '/../lib/base.php';
+@define('MNEMO_BASE', dirname(dirname(__FILE__)));
+require_once MNEMO_BASE . '/lib/Application.php';
+Horde_Registry::appInit('mnemo');
 
 $search = Horde_Util::getGet('q');
 if (!$search) {
index 016da66..c9fa292 100644 (file)
@@ -52,7 +52,7 @@ if ($memo_id):
 <?php endif; ?>
  <p><?php echo Horde::label('memo_body', _("Note _Text")) ?>&nbsp;(<?php printf(_("%s characters"), '<span id="charcount">' . Horde_String::length(str_replace(array("\r", "\n"), '', $memo_body)) . '</span>') ?>):</p>
  <textarea name="memo_body" id="memo_body" class="fixed" rows="20" onchange="updateCharCount()" onclick="updateCharCount()" onkeypress="setTimeout('updateCharCount()', 1)"><?php echo htmlspecialchars($memo_body) ?></textarea>
- <?php try { echo Horde::callHook('_mnemo_hook_description_help', array(), 'mnemo', ''); } catch (Horde_Exception_HookNotSet $e) {} ?>
+ <?php try { echo Horde::callHook('description_help', array(), 'mnemo', ''); } catch (Horde_Exception_HookNotSet $e) {} ?>
 
  <p>
   <input type="submit" class="button" value="<?php echo _("Save") ?>" onclick="return checkCategory();" />
index fe31b2a..e439cd2 100644 (file)
@@ -56,7 +56,7 @@ if (!$print_view) {
    </div>
 <?php else: ?>
    <div class="noteBody">
-    <?php $body = Horde_Text_Filter::filter($memo['body'], 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO, 'class' => null)); try { $body = Horde::callHook('_mnemo_hook_format_description', array($body), 'mnemo', $body); } catch (Horde_Exception_HookNotSet $e) {} echo $body; ?>
+    <?php $body = Horde_Text_Filter::filter($memo['body'], 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO, 'class' => null)); try { $body = Horde::callHook('format_description', array($body), 'mnemo', $body); } catch (Horde_Exception_HookNotSet $e) {} echo $body; ?>
    </div>
 <?php endif; ?>
   </td>