Skip to content
Browse files

Make compatible with more setups (rewrite, PHP4, other templates).

  • Loading branch information...
1 parent cbc3cee commit 85a03255f70b8ca8d24721d8e993ac07fff81252 @adrianheine adrianheine committed Oct 21, 2009
Showing with 32 additions and 24 deletions.
  1. +7 −0 TPL_EXAMPLE.txt
  2. +4 −3 action.php
  3. +4 −3 log.php
  4. +8 −9 script.js
  5. +9 −9 style.css
View
7 TPL_EXAMPLE.txt
@@ -0,0 +1,7 @@
+<?php
+if(isset($_SERVER['REMOTE_USER'])) {
+ global $lang;
+ $lang['btn_recommend'] = 'Recommend';
+ echo html_btn('recommend',$ID,null,array('do' => 'recommend', 'id' => $ID));
+}
+?>
View
7 action.php
@@ -8,14 +8,14 @@ function getInfo(){
return confToHash(dirname(__FILE__).'/INFO.txt');
}
- function register($controller) {
+ function register(&$controller) {
foreach (array('ACTION_ACT_PREPROCESS', 'AJAX_CALL_UNKNOWN',
'TPL_ACT_UNKNOWN') as $event) {
$controller->register_hook($event, 'BEFORE', $this, '_handle');
}
}
- function _handle($event, $param) {
+ function _handle(&$event, $param) {
if (!in_array($event->data, array('recommend', 'plugin_recommend')) ||
!isset($_SERVER['REMOTE_USER'])) {
return;
@@ -57,7 +57,8 @@ function _show_form() {
} else {
global $ID;
if (!isset($ID)) {
- throw new Exception('Unknown page');
+ msg('Unknown page', -1);
+ return;
}
$id = $ID;
}
View
7 log.php
@@ -19,9 +19,10 @@ function getEntries() {
}
function writeEntry($page, $sender, $receiver) {
- file_put_contents($this->path, date('r') . ': ' .
- "${sender}” recommended “${page}” to “${receiver}”.\n",
- FILE_APPEND);
+ $logfile = fopen($this->path, 'a');
+ fwrite($logfile, date('r') . ': ' .
+ "${sender}” recommended “${page}” to “${receiver}”.\n");
+ fclose($logfile);
}
}
View
17 script.js
@@ -46,7 +46,7 @@ function recommend_box(content) {
return;
}
div.innerHTML = content;
- getElementsByClass('stylehead', document, 'div')[0].appendChild(div);
+ document.body.appendChild(div);
return div;
}
@@ -56,15 +56,14 @@ function recommend_handle() {
return;
}
if (this.responseStatus[0] === 204) {
- recommend_box('');
- return;
- }
-
- var box = recommend_box(this.response);
- box.getElementsByTagName('label')[0].focus();
- change_form_handler(box.getElementsByTagName('form'),
- function (form) {return sack_form(form, recommend_handle); });
+ var box = recommend_box('<form id="recommend_plugin" accept-charset="utf-8" method="post" action="?do=recommend"><div class="no"><fieldset><legend>Finished</legend<p>Thanks for recommending our site.</p><input type="submit" class="button" value="Cancel" name="do[cancel]"/></fieldset></div></form>');
+ } else {
+ var box = recommend_box(this.response);
+ box.getElementsByTagName('label')[0].focus();
+ change_form_handler(box.getElementsByTagName('form'),
+ function (form) {return sack_form(form, recommend_handle); });
+ }
var inputs = box.getElementsByTagName('input');
inputs[inputs.length - 1].onclick = function() {recommend_box(''); return false;};
}
View
18 style.css
@@ -11,47 +11,47 @@
background: white;
}
-div.dokuwiki div.recommend_plugin {
+div.recommend_plugin {
width: 50%;
text-align: center;
font-size: 120%;
padding: 2em;
}
-div.dokuwiki form#recommend_plugin {
+form#recommend_plugin {
width: 100%;
text-align: center;
}
-div.dokuwiki form#recommend_plugin p {
+form#recommend_plugin p {
font-size: 90%;
text-align: left;
}
-div.dokuwiki form#recommend_plugin fieldset {
+form#recommend_plugin fieldset {
width: 90%;
}
-div.dokuwiki form#recommend_plugin label {
+form#recommend_plugin label {
display: block;
overflow: auto;
margin: 5px;
}
-div.dokuwiki form#recommend_plugin label span {
+form#recommend_plugin label span {
width: 48%;
text-align: right;
display: block;
float: left;
}
-div.dokuwiki form#recommend_plugin label input {
+form#recommend_plugin label input {
float: left;
margin-left: 5px;
}
-div.dokuwiki form#recommend_plugin label textarea.edit,
-div.dokuwiki form#recommend_plugin label input.edit {
+form#recommend_plugin label textarea.edit,
+form#recommend_plugin label input.edit {
width: 48%;
display: block;
float: left;

0 comments on commit 85a0325

Please sign in to comment.
Something went wrong with that request. Please try again.