';
- if($this->getConf('newsflash_link') == false) {
- $output .= ''.NL;
- }
- else {
- $output .= ''.NL;
- }
- $output .= '
'.NL;
-
- // 1. read news file (e.g. news:newsdata.txt)
- $oldrecord = rawWiki($targetpage);
-// $entries = explode("\n----\n\n",$oldrecord);
- $entries = explode("======",$oldrecord);
- foreach($entries as $entry) {
- // split news block into line items
- $temp_array = explode("\n * ",$entry);
- unset($temp_array[0]);
- $wysiwyg = false;
-
- // 2. create preview output
- // split line items into key and data
- $aFlag = false;
- $bFlag = false;
- foreach ($temp_array as $item) {
- list($key, $value) = split(":",trim($item),2);
- $tag_flag = false;
-
- if($key=='anchor') {
- $anchor = trim($value);
- }
- elseif(($key=='start') && strtotime(trim($value)) < time()) {
- $aFlag = true;
- $value = date($this->getConf('d_format'), strtotime($value));
- $news_date = '
('. $value ;
- }
- elseif(($key=='stop') && strtotime(trim($value)) > time()) {
- $bFlag = true;
- }
- elseif($key=='wysiwyg'){
- $wysiwyg = 1;
- }
- elseif($key=='text'){
- if($bFlag !== true) break;
- // replace media links
- $linkx = array();
- $pattern = '/\{\{.*?\}\}/i';
- $linkx = $this->replace_links($pattern, $value, 'medi');
-
- // replace hyperlinks
- $links = array();
- $pattern = '/\[\[.*?\]\]/i';
- $links = $this->replace_links($pattern, $value, 'url');
-
- // shrink the output according settings
- //$prvw_string = substr( preg_replace ('/\<.*?\>/', ' ', $value ) , 0, $preview_length );
- $check = explode(' ', $value);
- $i=0;
- $prvw_string ='';
- foreach($check as $a) {
- $prvw_string .= $a.' ';
- $i++;
- if($i>$preview_length) {break;}
- }
- if(count($check)-1>$preview_length) $prvw_string .= ' ...';
-
- // replace placeholder
- $links = $this->replace_placeholder($links, $prvw_string, 'url');
- $linkx = $this->replace_placeholder($linkx, $prvw_string, 'medi');
-
- if ($wysiwyg==false) $prvw_string = p_render('xhtml',p_get_instructions($prvw_string),$info);
- $preview_string = '' . $prvw_string .''. NL;
- }
- // head has to be before the link in the template !
- elseif($key=='head'){
- $news_head = $value;
- // add edit button to section edit the article if edit
- // permission is given to that current user for this ID
- if($current_usr["perm"]>1) {
- // detect start and stop of section
- $news_rawcontent = rawWiki($targetpage);
- $start= stripos($news_rawcontent,$value)-5;
- $tmp = explode("====== ",$news_rawcontent);
- foreach($tmp as $temps) {
- if(stripos($temps,$value)!==false) {
- $stop = strlen($temps)+$start+6;
- break;
- }
- }
- // assemble the pieces for the button and form.
- $url = wl($this->getConf('news_datafile'),'',true);
-
- $ank = '
- ';
- // add a delete button and $POST
- $ank .= '
-
';
- }
- else $ank='';
- }
- elseif($key=='link'){
- $prev_id++;
- $news_head = ''. $news_head .''.NL;
- // generate an overlap div with Thumbshot picture if link is provided by conf
- if($this->getConf('convert')) {
- if(is_string($response)) {
- msg($response,-1);
- }
- else {
- list($link,$image) = $response;
- $anID = explode("id=",$value);
- if($anID[1]) $theLink = DOKU_URL.'doku.php?id='.$anID[1];
- else $theLink = $value;
- $theLink = sprintf($this->getConf('convert'), $theLink);
- $news_head .= '
-
-
-
-
-
'.NL; // anchorid, pos, glidetime, revealbehavior
- $news_head .= ''.NL;
- }
- }
- }
- elseif($key=='author'){
- $news_date .= ', '. $value;
- }
- elseif(($key=='tags') && (isset($prefs[4]) !== false)) {
- $tags = explode(',',$value);
- foreach($tags as $tag) {
- if(($tag!==false) && (stripos($prefs[4],trim($tag))!==false)){
- $tag_flag = true;
- break;
- }
- }
- }
- }
- if(isset($prefs[4]) == false) $tag_flag = true;
- $news_date .= ')'.NL;
- if(($aFlag === true) && ($bFlag === true) && ($tag_flag === true)) {
- $output .= '
'.$news_head.$news_date.$preview_string.$ank.'
'.NL;
- $item_counter = $item_counter + 1;
- // stop if max number of items is reached
- if (isset($prefs[3]) && ($item_counter == $prefs[3])) {
- break; }
- }
- }
- if($item_counter==0)
- {
- $output .= '
'.$this->getLang('noNews').'
'.NL;
- }
- $output .= '