/*
--------------------------------------------------------------------------------
::: ReadSpeaker webReader Plugin 2.0 :::
Originally written for MODx 096x/Evolution 1.0 by ANDREAS WETTAINEN (mrhaw)
http://4up2date.info/webreader
CHANGE LOG
2010-02-23 Changed lang variable http://modxcms.com/forums/index.php/topic,39039.0.html
--------------------------------------------------------------------------------
To install it:
| 1 | Create a new plugin and paste this code WITHOUT <?php opening and closing ?> tags
into the Plugin code text-box. Name it: webReader
| 2 | Navigate to Configuration Tab and copy/paste into the Plugin configuration
text-box: (NOT the ###...)
################################################################################
&wRtags=How to implement webReader;list;Tags,Automatic;Automatic
&exclude=Exclude Templates;string;Enter comma separated Template ID Numbers
&cid=CID;string;Enter your CID Key
&lng=Language;list;de_de,sv_se,en_us,en_uk,fr_fr,it_it,es_es,pt_pt,nl_nl;en_us
################################################################################
Now click somewhere outside it and you see:
How to implement webReader: Automatic
- Default: "Automatic" - this plugin will automatically add the Listen (play)
button (and javascript expanding <div>) just before your MODx Document-Object
tag: [*content*]/[*#content*] and read all what's in it. "Tags" - see number 4.
Exclude Templates: Enter comma separated Template ID Numbers
- Here you can set one or many Template ID's separated by a comma, of which templates you
want to exclude from using webReader. The ID Number is shown inside parenthesis next to
the name of the Template in the template listing.
CID: Enter your CID Key
- Register on http://webreader.readspeaker.com
Language: en_us
- Choose your language! Default: US English
| 3 | Navigate to System Events Tab and mark checkbox "OnParseDocument" (Under Template Service Events)
and SAVE!
| 4 | If you chose to use "Tags" (instead of "Automatic") - use these tags in your Template and code:
################################################################################
<wRbox> - Where the Listen (play) button (and javascript expanding <div>) should appear.
<wRstart> - Where to start read.
<wRstop> - Where to stop read.
################################################################################
Enjoy webReader! : )
--------------------------------------------------------------------------------
*/
$e= &$modx->Event;
$title = $modx->documentObject['alias'];
$page = str_replace("/", "", $_SERVER['REQUEST_URI']);
$url = $modx->config['site_url'] . $page;
$exclude2 = ",". $exclude .",";
$template = strpos($exclude2,",".$modx->documentObject['template'].",");
$alt['de_de']='Vorlesen mit webReader';
$alt['sv_se']='Läs med webReader';
$alt['en_us']='Listen with webreader';
$alt['en_uk']='Listen with webReader';
$alt['fr_fr']='Lis moi avec webReader';
$alt['it_it']='Ascolta con webReader';
$alt['es_es']='Escuchar con webReader';
$alt['pt_pt']='Ouvir com webReader';
$alt['nl_nl']='Lees voor met webReader';
$box = '<a href="http://wr.readspeaker.com/webreader/webreader.php?cid='. $cid .'&t=modx&title='. $title .'&url='. $url .'" onclick="readpage(this.href,1);return false;"><img src="http://media.readspeaker.com/images/webreader/listen_'. $lng .'.gif" style="border-style: none;" title="'. $alt[$lng] .'" alt="'. $alt[$lng] .'" /></a>
<div id="WR_1"></div>';
$start = '<!-- RSPEAK_START -->';
$stop = '<!-- RSPEAK_STOP -->';
switch ($e->name) {
case "OnParseDocument":
$output = &$modx->documentOutput;
if ($template === false && $wRtags == "Tags") {
$modx->regClientStartupScript('http://wr.readspeaker.com/webreader/webreader.js.php?cid='. $cid);
$output = str_replace("<wRbox>", $box, $output);
$output = str_replace("<wRstart>", $start, $output);
$output = str_replace("<wRstop>", $stop, $output);
return $output;
}
elseif ($template === false && $wRtags == "Automatic") {
$modx->regClientStartupScript('http://wr.readspeaker.com/webreader/webreader.js.php?cid='. $cid);
$output = str_replace("[*content*]", $box ."<br />". $start ."[*content*]". $stop, $output);
$output = str_replace("[*#content*]", $box ."<br />". $start ."[*#content*]". $stop, $output);
return $output;
}
else {
$output = str_replace("<wRbox>", "This Template is excluded from webReader in plugin config!", $output);
return $output;
}
break;
default:
return;
break;
}