-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 777268a
Showing
9 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
timestamp Plugin for DokuWiki | ||
|
||
A plugin that adds a timestamp button to the edit toolbar | ||
|
||
All documentation for this plugin can be found at | ||
http://www.dokuwiki.org/plugin:timestamp | ||
|
||
If you install this plugin manually, make sure it is installed in | ||
lib/plugins/timestamp/ - if the folder is called different it | ||
will not work! | ||
|
||
Please refer to http://www.dokuwiki.org/plugins for additional info | ||
on how to install plugins in DokuWiki. | ||
|
||
---- | ||
Copyright (C) Trenton Ivey <Trenton.Ivey@gmail.com> | ||
|
||
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; version 2 of the License | ||
|
||
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. | ||
|
||
See the COPYING file in your DokuWiki folder for details |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/** | ||
* DokuWiki Plugin timestamp (Action Component) | ||
* | ||
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html | ||
* @author Trenton Ivey <Trenton.Ivey@gmail.com> | ||
*/ | ||
|
||
// must be run within Dokuwiki | ||
if(!defined('DOKU_INC')) die(); | ||
|
||
class action_plugin_timestamp_Timestamp extends DokuWiki_Action_Plugin { | ||
|
||
/** | ||
* Registers a callback function for a given event | ||
* | ||
* @param Doku_Event_Handler $controller DokuWiki's event controller object | ||
* @return void | ||
*/ | ||
public function register(Doku_Event_Handler &$controller) { | ||
|
||
$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'handle_toolbar_define'); | ||
$controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'handle_ajax_call_unknown'); | ||
|
||
} | ||
|
||
/** | ||
* Adds a toolbar button to insert timestamps | ||
* | ||
* @param Doku_Event $event event object by reference | ||
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this | ||
* handler was registered] | ||
* @return void | ||
*/ | ||
public function handle_toolbar_define(Doku_Event &$event, $param) { | ||
$event->data[] = array( | ||
'type' => 'timestamp', | ||
'title' => $this->getLang('tb_timestamp_button'), | ||
'icon' => '../../plugins/timestamp/timestamp.png', | ||
'key' => ':', | ||
'block' => false | ||
); | ||
} | ||
|
||
/** | ||
* Handles AJAX 'timestamp' request and returns the strftime formatted time | ||
* | ||
* @param Doku_Event $event event object by reference | ||
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this | ||
* handler was registered] | ||
* @return void | ||
*/ | ||
public function handle_ajax_call_unknown(Doku_Event &$event, $param) { | ||
// Make sure we are handleing the correct AJAX | ||
if ($event->data !== 'timestamp') { | ||
return; | ||
} | ||
// No other ajax call handlers are needed | ||
$event->stopPropagation(); | ||
$event->preventDefault(); | ||
// Set the content type | ||
header('Content-Type: text/plain'); | ||
// 'Return' the strftime formated time | ||
echo strftime($this->getConf('timestamp_format')); | ||
} | ||
} | ||
|
||
// vim:ts=4:sw=4:et: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
/** | ||
* Default settings for the timestamp plugin | ||
* | ||
* @author Trenton Ivey <Trenton.Ivey@gmail.com> | ||
*/ | ||
|
||
$conf['timestamp_format'] = '%Y%m%dT%H%M%S%z: '; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
/** | ||
* Options for the timestamp plugin | ||
* | ||
* @author Trenton Ivey <Trenton.Ivey@gmail.com> | ||
*/ | ||
|
||
|
||
$meta['timestamp_format'] = array('string'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
/** | ||
* English language file for timestamp plugin | ||
* | ||
* @author Trenton Ivey <Trenton.Ivey@gmail.com> | ||
*/ | ||
|
||
$lang['tb_timestamp_button'] = 'Insert a timestamp'; | ||
|
||
//Setup VIM: ex: et ts=4 : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
/** | ||
* english language file for timestamp plugin | ||
* | ||
* @author Trenton Ivey <Trenton.Ivey@gmail.com> | ||
*/ | ||
|
||
$lang['timestamp_format'] = 'Date format for the timestamp (see PHP\'s <a href="http://php.net/strftime">strftime</a> function)'; | ||
|
||
//Setup VIM: ex: et ts=4 : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
base timestamp | ||
author Trenton Ivey | ||
email Trenton.Ivey@gmail.com | ||
date 2013-12-31 | ||
name timestamp plugin | ||
desc A plugin that adds a timestamp button to the edit toolbar | ||
url http://www.dokuwiki.org/plugin:timestamp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
function addBtnActionTimestamp($btn, props, edid) { | ||
$btn.click(function() { | ||
jQuery.post( | ||
DOKU_BASE + 'lib/exe/ajax.php', | ||
{call: 'timestamp'}, | ||
function(data) { | ||
// Insert the timestamp | ||
insertAtCarret(edid,fixtxt(data)); | ||
// Close out of the picker and return | ||
pickerClose(); | ||
}, | ||
'text' | ||
); | ||
}); | ||
return 'timestamp'; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.