Skip to content

Commit

Permalink
Make compatible with more setups (rewrite, PHP4, other templates).
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianheine committed Oct 21, 2009
1 parent cbc3cee commit 85a0325
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 24 deletions.
7 changes: 7 additions & 0 deletions 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));
}
?>
7 changes: 4 additions & 3 deletions action.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 4 additions & 3 deletions log.php
Expand Up @@ -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);
}
}

Expand Down
17 changes: 8 additions & 9 deletions script.js
Expand Up @@ -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;
}

Expand All @@ -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;};
}
Expand Down
18 changes: 9 additions & 9 deletions style.css
Expand Up @@ -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;
Expand Down

0 comments on commit 85a0325

Please sign in to comment.