[Phpcms-plugins-cvs] betablogger4phpcms bb-script.php,NONE,1.1 bb-edit.php,NONE,1.1 atom.php,NONE,1.
Brought to you by:
mjahn
From: Martin J. <mj...@us...> - 2004-12-08 17:18:24
|
Update of /cvsroot/phpcms-plugins/betablogger4phpcms In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32349 Added Files: bb-script.php bb-edit.php atom.php bb-tools.php bb-conf.php js_gallery.php bb-archive.php bb-tpl.php textile.php bb-script.tpl bb-edit.tpl .cvsignore Log Message: initial import --- NEW FILE: .cvsignore --- edit.js edit.php gui.txt index.php log.txt main.inc pingback.php project.index readme.html release rss.php settings.inc settings.txt spam-4.4.0.tar.gz trackback.php .htaccess .project .docs* --- NEW FILE: bb-archive.php --- <?php /** * Betablogger4phpCMS - a news system for phpCMS * * Archive script * <ul> * <li><b>year~=2004</b> shows all the entries from 2004</li> * <li><b>month~=11</b> shows all the entries from novembers</li> * <li><b>day~=23</b> shows all the entries from 23rd days of a month</li> * </ul> * * <b>License</b> * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @author Martin Jahn <mj...@us...> * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @copyright Copyright (c) 2004, Martin Jahn * @version $Id: bb-archive.php,v 1.1 2004/12/08 17:18:14 mjahn Exp $ * @package betablogger4phpCMS */ /* * $Log: bb-archive.php,v $ * Revision 1.1 2004/12/08 17:18:14 mjahn * initial import * */ include_once (dirname (__FILE__).'/bb-tpl.php'); include_once (dirname (__FILE__).'/bb-tools.php'); if (!class_exists ('betablogger4phpcms')) { /** * * @author Martin Jahn <mj...@us...> * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @copyright Copyright (c) 2004, Martin Jahn * @version $Id: bb-archive.php,v 1.1 2004/12/08 17:18:14 mjahn Exp $ **/ class betablogger4phpcms { /** * define some helpful functions for some display-modes * you can modify the layout in the functions */ /** * prints out a formatted entry * * @param string entry **/ function BBdisplayEntry ($entry, $tpl_prefix = '') { $entry = $this->__customizing ($entry, $tpl_prefix.'entry'); foreach (get_object_vars ($entry) as $id=>$value) { $this->TPL->setFieldValue ('entry.'.$id, $value); } $this->TPL->setFieldValue ('entry.permalink', $entry->get_permalink()); $this->TPL->setFieldValue ('entry.num.comment', $entry->num("comment")); $this->TPL->setFieldValue ('entry.num.backlink', $entry->num("backlink")); echo $this->TPL->process ($tpl_prefix.'entry'); } /** * prints out a formatted message **/ function BBdisplayNoentryMessage () { echo $this->TPL->process ('noentry'); } /** * prints out a formatted comment * * @param string entry **/ function BBprocessCommentForm ($entry) { // Process submitted comment: $error = ""; if (!isset($_POST["entry_id"])) { return; } $comment = new comment; $comment->name = stripslashes ($_POST["name"]); $comment->email = stripslashes ($_POST["email"]); $comment->comment = stripslashes ($_POST["comment"]); $comment->entry_id = $_POST["entry_id"]; if (!$comment->name) { $error = "Bitte einen Namen eingeben"; } elseif (!$comment->comment) { $error = "Bitte das Formular ausf�llen."; } else { $this->blog->save ($comment); // redirect to a save page header ('Location: '.$this->blog->redirecturl); } return $error; } /** * prints out a formatted comment * * @param string entry **/ function BBdisplayComments ($entry, $error = '') { $this->TPL->setFieldValue ('comment.error', $error); echo $this->TPL->process ('comments'); $comments = $entry->get("comment", "", 0, "desc"); // empty query, unlimited number if (!$comments) { echo $this->TPL->process ('nocomment'); } foreach ($comments as $comment) { $comment = $this->__customizing ($comment, 'comment'); foreach (get_object_vars ($comment) as $id=>$value) { //echo $id.'='.$value.'<br />'; $this->TPL->setFieldValue ('comment.'.$id, $value); } $this->TPL->setFieldValue ('comment.gravatar', ''); if ($this->gravatar == 1 && isset ($comment->email) && trim ($comment->email) != '') { $this->TPL->setFieldValue ('gravatar.uri', $this->gravataruri.md5($comment->email)); $this->TPL->setFieldValue ('comment.gravatar', $this->TPL->process ('gravatar')); } echo $this->TPL->process ('comment'); } } /** * prints out a formatted commentform * * @param string entry **/ function BBdisplayCommentForm ($entry) { $this->TPL->setFieldValue ('commentform.action', $entry->get_permalink()); foreach (get_object_vars ($entry) as $id=>$value) { $this->TPL->setFieldValue ('entry.'.$id, $value); } $this->TPL->setFieldValue ('entry.permalink', $entry->get_permalink()); $this->TPL->setFieldValue ('entry.date', date("d.m.Y u\m H:i", $entry->date)); echo $this->TPL->process ('commentform'); } /** * prints out a formatted backtrackentry * * @param string entry **/ function BBdisplayTrackback ($entry) { $backlinks = $entry->get ('backlink'); if (!$backlinks) { $this->TPL->process ('notrackback'); } else { $o = ''; foreach ($backlinks as $link) { $link = $this->__customizing ($link, 'backlink'); if ($link->site) { $link->title = $link->site.': '.$link->title; } elseif (!$link->title) { $link->title = $link->url; } foreach (get_object_vars ($link) as $id=>$value) { $this->TPL->setFieldValue ('link.'.$id, $value); } $this->TPL->setFieldValue ('link.date', date("d.m.Y u\m H:i", $link->date)); if ($link->excerpt) { $this->TPL->setFieldValue ('link.excerpt', strip_tags ($link->excerpt)); } $o .= $this->TPL->process ('trackback'); } // end of links $this->TPL->setFieldValue ('trackback.list', $o); echo $this->TPL->process ('trackbacks'); } } /** * prints out a single field-value * * @param string entry * @param string fieldname **/ function BBdisplayField ($entry, $fieldname) { /* check if the wanted fieldvalue is available and if so print it out */ if (isset ($entry->{$fieldname})) { echo $entry->{$fieldname}; } } /** * prints out a navigation for paging the entries * * @param int start * @param int max */ function BBdisplayNavigation ($start, $max) { $this->TPL->setFieldValue ('navigation.start', $start + 1); $this->TPL->setFieldValue ('navigation.count', $max + 1); $this->TPL->setFieldValue ('navigation.ende', $start + $this->display_count > $max ? $max + 1 : $start + $this->display_count); $this->TPL->setFieldValue ('navigation.prevlink', '?&start='.($start - $this->display_count < 0 ? 0 : $start + 1 - $this->display_count)); $this->TPL->setFieldValue ('navigation.nextlink', '?&start='.($start + 1 + $this->display_count)); echo $this->TPL->process ('navigation.pre'); if ($start > 0) { echo $this->TPL->process ('navigation.prev'); } echo $this->TPL->process ('navigation.between'); if ($start + $this->display_count < $max + 1) { echo $this->TPL->process ('navigation.next'); } echo $this->TPL->process ('navigation.past'); } /** * prints out a single field-value * * @param string entry * @param string fieldname **/ function BBdisplayTrackbackLink ($entry) { /* display ping-data */ echo $entry->get_ping_data('xhtml'); } /** * constructor in PHP4-syntax * @param Blog $blog the blog we should use for work */ function betablogger4phpcms (&$blog) { return $this->__construct ($blog); } /** * the main function of this class */ function run () { // load entries from blog $entries = $this->blog->get("entry", $_GET); /** * set the URL to redirect to after critical operations (like saving * a comment or similar) * @see http://www.php-mag.net/itr/online_artikel/psecom,id,637,nodeid,114.html (in english) */ if (isset ($entries [0])) { $this->blog->redirecturl = $entries [0]->get_permalink (); } else { $this->blog->redirecturl = $_SERVER ['PHP_SELF']; } // load template file $this->TPL = new bbTPL (dirname (__FILE__).'/'.$this->tplfile); if (isset ($_GET [$this->showvalue])) { // display single fieldvalue // check if the wanted fieldvalue is available and if so print it out if (count ($entries) > 0) { $this->BBdisplayField ($entries [0], $_GET[$this->showvalue]); } // unset the GET-variable (this is necessary) // otherwise all other scripts, that are included in the same contentfile // have the same value in $_GET unset ($_GET [$this->showvalue]); } elseif (isset ($_GET [$this->trackbackvalue])) { // display the trackback code // only one entry available if (count ($entries) == 1) { $this->BBdisplayTrackbackLink ($entries [0]); } // unset the GET-variable (this is necessary) // otherwise all other scripts, that are included in the same contentfile // have the same value in $_GET unset ($_GET [$this->trackbackvalue]); } elseif (isset ($_GET [$this->edit])) { // editmode /** * include the file with the editor for the blog **/ include (dirname (__FILE__).'/bb-edit.php'); $edit =& new bbedit4phpcms ($this->blog); $edit->run (); // unset the GET-variable (this is necessary) // otherwise all other scripts, that are included in the same contentfile // have the same value in $_GET unset ($_GET [$this->edit]); } else { // display normal entry // no entries available if (!$entries) { $this->BBdisplayNoentryMessage (); } // display single entry if (count ($entries) == 1) { $entry =& $entries [0]; // if title-field is empty go on with next entry if (trim ($entry->title) == '') { continue; } // if body-field is empty go on with next entry if (trim ($entry->body) == '') { continue; } // display the entry $this->BBdisplayEntry ($entry, 'single'); // display the comments $this->BBdisplayComments ($entry, $this->BBprocessCommentForm ($entry)); // display the form for new comments $this->BBdisplayCommentForm ($entry); // display the backtracks $this->BBdisplayTrackback ($entry); } // display multiple entries if (count ($entries) > 1) { $index = array_keys ($entries); $index = $this->__sortEntries ($entries, $index); $start = 0; if (isset ($_GET ['start']) && is_numeric ($_GET ['start'])) { if ($start < count ($index) - 1) { $start = (int) $_GET ['start'] - 1; } if ($start < 0) { $start = 0; } if ($start > count ($index) - 1) { $start = count ($index) - 1; } } // walk through all entries for ($i = $start; $i < count ($index) && $i < $start + $this->display_count; $i++) { // does the index-id exist if (!isset ($index [$i]) || trim ($index [$i]) == '') { continue; } $entry = $entries [$index [$i]]; // if title-field is empty go on with next entry if (trim ($entry->title) == '') { continue; } // if body-field is empty go on with next entry if (trim ($entry->body) == '') { continue; } // display the entry $this->BBdisplayEntry ($entry); } if ($start > 0 || $start + $this->display_count < count ($index)) { $this->BBdisplayNavigation ($start, count ($index) - 1); } } } } function __sortEntries ($entries, $index) { // no sort-order defined if (trim ($this->sort_entries_by_field) == '') { return $index; } // no indexfile available if (!file_exists ($this->blog->data_dir.'/entry/'.$this->sort_entries_by_field.'/index')) { return $index; } // predefine some variables $indexes = array (); $j = 0; // create a hash with the relation between entries and their array position for ($i = 0; $i < count ($entries); $i++) { // relation entry->id <=> position in $entries $indexes [$entries [$i]->id] = $i; } // get the indexfile as array $indexfile = file ($this->blog->data_dir.'/entry/'.$this->sort_entries_by_field.'/index'); // sort the index-array rsort ($indexfile); //echo '<pre>$indexfile :';print_r ($indexfile);echo '</pre>'; // extract the entry-ids out of the index-array for ($i = 0; $i < count ($indexfile); $i++) { $indexfile [$i] = trim ($indexfile [$i]); if (strpos ($indexfile [$i], ' ') === false) { //echo $i.' failed <br />'; continue; } $id = trim (strrchr (trim ($indexfile [$i]), ' ')); if (!isset ($indexes [$id])) { continue; } //echo $id.' = '.$indexfile [$i].'<br />'; $index [$j] = $indexes [$id]; $j++; } //echo '<pre>$index : ';print_r ($index);echo '</pre>'; return $index; } /** * this function lets all the customizing functions work on the given * argument * * @param mixed entry the entry with the fields to give to the * userfunctions as parameter * @return mixed the result of the customizing action */ function __customizing ($entry, $type) { if (!isset ($this->extra) || !is_array ($this->extra)) { return $entry; } if (!isset ($this->extra [$type])) { return $entry; } echo '<!--'; foreach ($this->extra [$type] as $id=>$functions) { echo 'customizing '.$type.' field '.$id.' with '.$functions.'<br />'; if (!isset ($entry->{$id})) { continue; } if ($id == 'date') { $entry->{$id.'_custom'} = call_user_func ($functions, $entry->{$id}); } else { $entry->{$id} = call_user_func ($functions, $entry->{$id}); } } echo '-->'; return $entry; } /** * this function lets all the validating functions work on the given * argument * * @param mixed entry the entry with the fields to give to the * userfunctions as parameter * @return mixed the result of the validating action */ function __validating ($entry, $type) { return $entry; } /** * constructor in PHP5-syntax * @param Blog $blog the blog we should use for work */ function __construct (&$blog) { $this->blog =& $blog; $showconf = 'BB_SCRIPT_CONF'; include (dirname (__FILE__).'/bb-conf.php'); $showconf = ''; return true; } } } error_reporting (E_ALL); /** * load _one_ instance of betablogger4phpcms in the global namespace and call it from there, * if it already exists there. this saves memory, because only on instance is needed for one * single page, regardless of the times you call bb_script in your contentfile. **/ if (!isset ($GLOBALS ['BB_instance'])) { /** * include the class-definitions of betablogger **/ include_once (dirname (__FILE__).'/main.inc'); $GLOBALS ['BB_instance'] =& new betablogger4phpcms ($blog); } $GLOBALS ['BB_instance']->run (); ?> --- NEW FILE: bb-edit.tpl --- {editor} <form action="/neues/edit.de.htm?edit=&" method="post" id="editform"> <input type="hidden" name="edit" value="1" /> <input type="hidden" name="select_num" value="{editor.select_num}" /> <input type="hidden" name="select_show" value="{editor.select_show}" /> <input type="hidden" name="select_query" value="{editor.select_query}" /> <input type="hidden" name="item_id" value="0"> <fieldset> <legend>Artikel auswählen</legend> <label> <span>Eintrag auswählen :</span> <select name="item_id" size="{editor.selector.size}" id="selectfield" onchange="this.form.submit()" /> <option id="newitem" value="0" selected>Neuer Eintrag{entries} </select> </label><label title="Einträge durchsuchen"> <span>Suchen</span> <input type="text" name="select_query" value="" onchange="this.form.submit()" /> </label> </fieldset> <div class="center"> <label class="horizontal"><span class="hidden">Vorschau</span><input type="submit" name="action" value="Preview" /></label> <label class="horizontal"><span class="hidden">Eintrag abspeichern</span><input type="submit" name="action" value="Save" /></label> <label class="horizontal"><span class="hidden">speichern als </span> <select name="save_as" size="1" class="horizontal">{editor.save_as}</select> </label> </div> <div id="entryform"> {entry.fields} </div> <div id="commentform"> {entry.comment} </div> <div id="trackbackform"> {entry.trackback} </div> <div id="pingbackform"> {entry.pingback} </div> {entry.selector} <option value="{entry.id}">{entry.id}…</option> {field.text} <label> <span>{field.label}</span> <input type="text" name="{field.name}" value="{field.value}" /> </label> {field.textarea} <label> <span><span class="hidden">{field.label}</span></span> <textarea rows="10" cols="40" name="{field.name}">{field.value}</textarea> </label> {field.hidden} <input type="hidden" name="{field.name}" value="{field.value}" /> {field.submit} <label> <span><span class="hidden">{field.label}</span></span> <input type="submit" name="{field.name}" value="{field.value}" /> </label> {entry.entry} {comment.entry} {trackback.entry} {pingback.entry} --- NEW FILE: textile.php --- <?php /* This is Textile A Humane Web Text Generator Version 1.0 21 Feb, 2003 Copyright (c) 2003, Dean Allen, www.textism.com All rights reserved. _______ LICENSE Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name Textile nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. _____________ USING TEXTILE Block modifier syntax: Header: hn. Paragraphs beginning with 'hn. ' (where n is 1-6) are wrapped in header tags. Example: <h1>Text</h1> Header with CSS class: hn(class). Paragraphs beginning with 'hn(class). ' receive a CSS class attribute. Example: <h1 class="class">Text</h1> Paragraph: p. (applied by default) Paragraphs beginning with 'p. ' are wrapped in paragraph tags. Example: <p>Text</p> Paragraph with CSS class: p(class). Paragraphs beginning with 'p(class). ' receive a CSS class attribute. Example: <p class="class">Text</p> Blockquote: bq. Paragraphs beginning with 'bq. ' are wrapped in block quote tags. Example: <blockquote>Text</blockquote> Blockquote with citation: bq(citeurl). Paragraphs beginning with 'bq(citeurl). ' recieve a citation attribute. Example: <blockquote cite="citeurl">Text</blockquote> Numeric list: # Consecutive paragraphs beginning with # are wrapped in ordered list tags. Example: <ol><li>ordered list</li></ol> Bulleted list: * Consecutive paragraphs beginning with * are wrapped in unordered list tags. Example: <ul><li>unordered list</li></ul> Phrase modifier syntax: _emphasis_ <em>emphasis</em> __italic__ <i>italic</i> *strong* <strong>strong</strong> **bold** <b>bold</b> ??citation?? <cite>citation</cite> -deleted text- <del>deleted</del> +inserted text+ <ins>inserted</ins> ^superscript^ <sup>superscript</sup> ~subscript~ <sub>subscript</sub> @code@ <code>computer code</code> ==notextile== leave text alone (do not format) "linktext":url <a href="url">linktext</a> "linktext(title)":url <a href="url" title="title">linktext</a> !imageurl! <img src="imageurl"> !imageurl(alt text)! <img src="imageurl" alt="alt text" /> !imageurl!:linkurl <a href="linkurl"><img src="imageurl" /></a> ABC(Always Be Closing) <acronym title="Always Be Closing">ABC</acronym> */ function textile($text) { ### Basic global changes $text = stripslashes($text); # turn any incoming ampersands into a dummy character for now. # This uses a negative lookahead for alphanumerics followed by a semicolon, # implying an incoming html entity, to be skipped $text = preg_replace("/&(?![#a-zA-Z0-9]+;)/","x%x%",$text); # entify everything if (function_exists('mb_encode_numericentity')) { $text = encode_high($text); } else { $text = htmlentities($text,ENT_NOQUOTES); } # unentify angle brackets and ampersands $text = str_replace(array(">", "<", "&"), array(">", "<", "&"), $text); # zap carriage returns $text = str_replace("\r\n", "\n", $text); # zap tabs $text = str_replace("\t", "", $text); $text = preg_split("/\n/",$text); foreach($text as $line){ $line = trim($line); $lineout[] = $line; } $text = implode("\n",$lineout); # clean up loose white space on empty lines $text = preg_replace('/^\s*$/mU',"",$text); ### Find and replace quick tags # double equal signs mean <notextile> $text = preg_replace('/(^|\s)==(.*)==([^[:alnum:]]{0,2})(\s|$)?/mU','$1<notextile>$2</notextile>$3$4',$text); # image qtag $text = preg_replace('/!([^\s\(=]+)\s?(?:\(([^\)]+)\))?!(\s)?/mU','<img src="$1" alt="$2" border="0" />$3',$text); # image with hyperlink $text = preg_replace('/(<img.+ \/>):(\S+)(\s)/U','<a href="$2">$1</a>$3',$text); # hyperlink qtag $text = preg_replace( '/ ([\s[{(]|[[:punct:]])? # 1 optional space or brackets before " # starting " ([^"\(]+) # 2 text of link \s? # opt space (?:\(([^\(]*)\))? # 3 opt title attribute in parenths ": # dividing ": (\S+) # 4 suppose this is the url (\/?) # 5 opt trailing slash ([^[:alnum:]\/;]|[1-9^]*) # 6 opt punctuation after the url (\s|$) # 7 either white space or end of string /xU', '$1<a href="$4$5" title="$3">$2</a>$6$7',$text); # arrange qtag delineators and replacements in an array $qtags = array( '\*\*'=>'b', '\*'=>'strong', '\?\?'=>'cite', '-'=>'del', '\+'=>'ins', '~'=>'sub', '@'=>'code'); # loop through the array, replacing qtags with html foreach($qtags as $f=>$r){ $text = preg_replace( '/(^|\s|>)'.$f.'\b(.+)\b([[:punct:]]*)'.$f.'([[:punct:]]{0,2})(\s|$)?/mU', '$1<'.$r.'>$2$3</'.$r.'>$4$5', $text); } # some weird bs with underscores and \b word boundaries, # so we'll do those on their own $text = preg_replace('/(^|\s)__(.*)__([[:punct:]]{0,2})(\s|$)?/mU','$1<i>$2</i>$3$4',$text); $text = preg_replace('/(^|\s)_(.*)_([[:punct:]]{0,2})(\s|$)?/mU','$1<em>$2</em>$3$4',$text); $text = preg_replace('/\^(.*)\^/mU','<sup>$1</sup>',$text); ### Find and replace typographic chars and special tags # small problem with double quotes at the end of a string $text = preg_replace('/"$/',"\" ", $text); # NB: all these will wreak havoc inside <html> tags $glyph_search = array( '/([^\s[{(>])?\'(?(1)|(?=\s|s\b))/', # single closing '/\'/', # single opening '/([^\s[{(])?"(?(1)|(?=\s))/', # double closing '/"/', # double opening '/\b( )?\.{3}/', # ellipsis '/\b([A-Z][A-Z0-9]{2,})\b(?:[(]([^)]*)[)])/', # 3+ uppercase acronym '/(^|[^"][>\s])([A-Z][A-Z0-9 ]{2,})([^<a-z0-9]|$)/', # 3+ uppercase caps '/\s?--\s?/', # em dash '/\s-\s/', # en dash '/(\d+) ?x ?(\d+)/', # dimension sign '/\b ?[([]TM[])]/i', # trademark '/\b ?[([]R[])]/i', # registered '/\b ?[([]C[])]/i'); # copyright $glyph_replace = array( '$1’$2', # single closing '‘', # single opening '$1”', # double closing '“', # double opening '$1…', # ellipsis '<acronym title="$2">$1</acronym>', # 3+ uppercase acronym '$1<span class="caps">$2</span>$3', # 3+ uppercase caps '—', # em dash ' – ', # en dash '$1×$2', # dimension sign '™', # trademark '®', # registered '©'); # copyright # set toggle for turning off replacements between <code> or <pre> $codepre = false; # if there is no html, do a simple search and replace if(!preg_match("/<.*>/",$text)){ $text = preg_replace($glyph_search,$glyph_replace,$text); } else { # else split the text into an array at <.*> $text = preg_split("/(<.*>)/U",$text,-1,PREG_SPLIT_DELIM_CAPTURE); foreach($text as $line){ # matches are off if we're between <code>, <pre> etc. if(preg_match('/<(code|pre|kbd|notextile)>/i',$line)){$codepre = true; } if(preg_match('/<\/(code|pre|kbd|notextile)>/i',$line)){$codepre = false; } if(!preg_match("/<.*>/",$line) && $codepre == false){ $line = preg_replace($glyph_search,$glyph_replace,$line); } # convert htmlspecial if between <code> if ($codepre == true){ $line = htmlspecialchars($line,ENT_NOQUOTES,"UTF-8"); $line = str_replace("<pre>","<pre>",$line); $line = str_replace("<code>","<code>",$line); } # each line gets pushed to a new array $glyph_out[] = $line; } # $text is now the new array, cast to a string $text = implode('',$glyph_out); } ### Block level formatting # deal with forced breaks; this is going to be a problem between # <pre> tags, but we'll clean them later $text = preg_replace("/(\S)(_*)([[:punct:]]*) *\n([^#*\s])/", "$1$2$3<br />$4", $text); # might be a problem with lists $text = str_replace("l><br />", "l>\n", $text); # split the text into an array by newlines $text = preg_split("/\n/",$text); array_push($text," "); $list = ''; $pre = false; $block_find = array( '/^\s?\*\s(.*)/', # bulleted list * '/^\s?#\s(.*)/', # numeric list # '/^bq\. (.*)/', # blockquote bq. '/^h(\d)\(([[:alnum:]]+)\)\.\s(.*)/', # header hn(class). w/ css class '/^h(\d)\. (.*)/', # plain header hn. '/^p\(([[:alnum:]]+)\)\.\s(.*)/', # para p(class). w/ css class '/^p\. (.*)/i', # plain paragraph '/^([^\t ]+.*)/i' # remaining plain paragraph ); $block_replace = array( "\t<liu>$1</liu>$2", "\t<lio>$1</lio>$2", "\t<blockquote>$1</blockquote>$2", "\t<h$1 class=\"$2\">$3</h$1>$4", "\t<h$1>$2</h$1>$3", "\t<p class=\"$1\">$2</p>$3", "\t<p>$1</p>", "\t<p>$1</p>$2" ); # loop through lines foreach($text as $line){ #make sure the line isn't blank if (!preg_match('/^$/',$line)) { # matches are off if we're between <pre> or <code> tags if(preg_match('/<pre>/i',$line)){$pre = true; } # deal with block replacements first, then see if we're in a list if ($pre == false){ $line = preg_replace($block_find,$block_replace,$line); } # kill any br tags that slipped in earlier if ($pre == true){ $line = str_replace("<br />","\n",$line); } # matches back on after </pre> if(preg_match('/<\/pre>/i',$line)){$pre = false; } # at the beginning of a list, $line switches to a value if ($list == '' && preg_match('/^\t<li/',$line)){ $line = preg_replace('/^(\t<li)(o|u)/',"\n<$2l>\n$1$2",$line); $list = $line{2}; # at the end of a list, $line switches to empty } else if ($list != '' && !preg_match('/^\t<li'.$list.'/',$line)){ $line = preg_replace('/^(.*)$/',"</".$list."l>\n$1",$line); $list = ''; } } # push each line to a new array once it's processed $block_out[] = $line; } $text = implode("\n",$block_out); #clean up <notextile> $text = preg_replace('/<\/?notextile>/', "",$text); # clean up liu and lio $text = preg_replace('/<(\/?)li(u|o)>/', "<$1li>",$text); # turn the temp char back to an ampersand entity $text = str_replace("x%x%","&",$text); # Newline linebreaks, just for markup tidiness $text = str_replace("<br />","<br />\n",$text); return $text; } function callback_url($text,$title='',$url) { $out = 'a href="'.$url.'"'; $out.=($title!='')?' title="'.$title.'"':''; $out.='>$text</a>'; return $out; } function textile_popup_help($name,$helpvar,$windowW,$windowH) { $out = $name; $out .= ' <a target="_blank" href="txp_help.php?item='.$helpvar.'"'; $out .= ' onclick="window.open(this.href, \'popupwindow\', \'width='.$windowW.',height='.$windowH.',scrollbars,resizable\'); return false;" style="color:blue;background-color:#ddd">?</a><br />'; print $out; } function encode_high($text) { $cmap = cmap(); return mb_encode_numericentity($text, $cmap, "UTF-8"); } function decode_high($text) { $cmap = cmap(); return mb_decode_numericentity($text, $cmap, "UTF-8"); } function cmap() { $f = 0xffff; $cmap = array(160, 255, 0, $f, 402, 402, 0, $f, 913, 929, 0, $f, 931, 937, 0, $f, 945, 969, 0, $f, 977, 978, 0, $f, 982, 982, 0, $f, 8226, 8226, 0, $f, 8230, 8230, 0, $f, 8242, 8243, 0, $f, 8254, 8254, 0, $f, 8260, 8260, 0, $f, 8465, 8465, 0, $f, 8472, 8472, 0, $f, 8476, 8476, 0, $f, 8482, 8482, 0, $f, 8501, 8501, 0, $f, 8592, 8596, 0, $f, 8629, 8629, 0, $f, 8656, 8660, 0, $f, 8704, 8704, 0, $f, 8706, 8707, 0, $f, 8709, 8709, 0, $f, 8711, 8713, 0, $f, 8715, 8715, 0, $f, 8719, 8719, 0, $f, 8721, 8722, 0, $f, 8727, 8727, 0, $f, 8730, 8730, 0, $f, 8733, 8734, 0, $f, 8736, 8736, 0, $f, 8743, 8747, 0, $f, 8756, 8756, 0, $f, 8764, 8764, 0, $f, 8773, 8773, 0, $f, 8776, 8776, 0, $f, 8800, 8801, 0, $f, 8804, 8805, 0, $f, 8834, 8836, 0, $f, 8838, 8839, 0, $f, 8853, 8853, 0, $f, 8855, 8855, 0, $f, 8869, 8869, 0, $f, 8901, 8901, 0, $f, 8968, 8971, 0, $f, 9001, 9002, 0, $f, 9674, 9674, 0, $f, 9824, 9824, 0, $f, 9827, 9827, 0, $f, 9829, 9830, 0, $f, 338, 339, 0, $f, 352, 353, 0, $f, 376, 376, 0, $f, 710, 710, 0, $f, 732, 732, 0, $f, 8194, 8195, 0, $f, 8201, 8201, 0, $f, 8204, 8207, 0, $f, 8211, 8212, 0, $f, 8216, 8218, 0, $f, 8218, 8218, 0, $f, 8220, 8222, 0, $f, 8224, 8225, 0, $f, 8240, 8240, 0, $f, 8249, 8250, 0, $f, 8364, 8364, 0, $f); return $cmap; } ?> --- NEW FILE: bb-script.tpl --- {entry} <h2>{entry.title}</h2> <div class="entry">{entry.body} <ul class="horizontal trenner center small clear"> <li>Veröffentlicht am <a href="{entry.permalink}">{entry.date_custom}</a></li> <li>Autor: {entry.name}</li> <li><a href="{entry.permalink}#comments">Kommentare ({entry.num.comment}) </a></li> <li><a href="{entry.permalink}#links">Backlinks ({entry.num.backlink}) </a></li> </ul> </div> {singleentry} <h2>{entry.title}</h2> <div class="entry">{entry.body} <ul class="horizontal trenner center small clear"> <li>Veröffentlicht am <a href="{entry.permalink}">{entry.date_custom}</a></li> <li>Autor: {entry.name}</li> <li><a href="{entry.permalink}#comments">Kommentare ({entry.num.comment}) </a></li> <li><a href="{entry.permalink}#links">Backlinks ({entry.num.backlink}) </a></li> </ul> </div> {navigation.pre} </div> <div class="content center"> {navigation.prev} <a href="{navigation.prevlink}" class="left">Zurück</a> {navigation.between} {navigation.next} <a href="{navigation.nextlink}" class="right">Weiter</a> {navigation.past} Zeige Einträge {navigation.start} - {navigation.ende} von {navigation.count} {comments} <h3>Kommentare</h3>{comments.error} {comment} <div id="c{comment.id}" class="comment">{comment.gravatar} <p>{comment.comment}</p> <br class="clearboth" /> <p class="entryfooter"> Eingetragen von {comment.name} am <a href="#c{comment.id}">{comment.date_custom}</a> </p> </div> {nocomment} <p>Keine Kommentare vorhanden</p> {gravatar} <img src="{gravatar.uri}" alt="*" title="Gravatar" class="gravatar" /> {trackbacks} <h3 id="links">Backlinks</h3> <p>Die folgenden Seiten zitieren diesen Artikel:</p> <ul>{trackback.list}</ul> {notrackback} <h3 id="links">Backlinks</h3> <p>Keine Backlinks vorhanden.</p> {trackback} <li> <a href="{link.url}">{link.title}</a> ({link.date_custom})<br />{link.excerpt} </li> {commentform} <h3>Kommentar schreiben</h3> <form action="{commentform.action}" method="post" id="commentform"> <p> <script src="/js/livePreview.js" type="text/javascript"></script> <input type="hidden" name="entry_id" value="{entry.id}" /> <label> <span>Name :</span> <input type="text" name="name" class="text" /> </label> <label> <span>Email :</span> <input type="text" name="email" class="text" /> </label> <label> <span>Kommentar :<br /><span class="small" style="width:98%;">(Mit Textile geht vieles leichter!)</span></span> <textarea name="comment" id="message" onkeyup="reloadPreviewDiv()" rows="8" cols="50"></textarea> </label> <label> <span><span class="hidden">Kommentar eintragen</span> </span> <input type="submit" name="submit-comment" value="Kommentar eintragen" class="submit" /> </label> </p> </form> <script type="text/javascript"> <!-- document.write ("<h2>Live Preview!</h2>\n<div id=\"previewcomment\"></div>\n"); --> </script> {noentry} Keine Nachrichten vorhanden --- NEW FILE: bb-tools.php --- <?php /** * Betablogger4phpCMS - a news system for phpCMS * * Toolbox * * <b>License</b> * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @author Martin Jahn <mj...@us...> * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @copyright Copyright (c) 2004, Martin Jahn * @version $Id: bb-tools.php,v 1.1 2004/12/08 17:18:14 mjahn Exp $ * @package betablogger4phpCMS */ /* * $Log: bb-tools.php,v $ * Revision 1.1 2004/12/08 17:18:14 mjahn * initial import * */ if (!function_exists ('bbcode')) { function bbcode($string) { $string = preg_replace("#\[b\](.*?)\[/b\]#i","<b>\\1</b>",$string); $string = preg_replace("#\[i\](.*?)\[/i\]#i","<i>\\1</i>",$string); // $string = preg_replace("#\[code\](<br>)?(.*?)(<br>)?\[/code\]#i","<pre>\\2</pre>",$string); $string = preg_replace("#\[img\]http://([^]]+)\[/img\]#i",'<img src="http://\\1" border="0">',$string); $string = preg_replace("#\[url\](\w+)://([^]]+)\[/url\]#i",'<a href="\\1://\\2" target="_blank">\\1://\\2</a>',$string); $string = preg_replace("#\[url=(\w+)://([^]]+)\](.*?)\[/url\]#i",'<a href="\\1://\\2" target="_blank">\\3</a>',$string); $string = preg_replace("#\[email\]([\w~.]+?@[\w~.]+?)\[/email\]#i",'<a href="mailto:\\1">\\1</a>',$string); return $string; } } if (!function_exists ('xmlentities')) { function xmlentities($string, $quote_style=ENT_COMPAT) { $trans = get_html_translation_table(HTML_ENTITIES, $quote_style); foreach ($trans as $key => $value) $trans[$key] = '&#'.ord($key).';'; return strtr($string, $trans); } } if (!function_exists ('mydate')) { function mydate ($date) { $timeDiff = 1; if (gmdate("Ymd", $date) == gmdate("Ymd", time()+0)) { $prefix = "Heute, "; } elseif (gmdate("Ymd", $date) == gmdate("Ymd", time()-86400)) { $prefix = "Gestern, "; } elseif (gmdate("Ymd", $date) == gmdate("Ymd", time()-172800)) { $prefix = "Vorgestern, "; } else { $prefix = ""; } return $prefix.deutsches_datum("c, %d. C %Y", $date+$timeDiff, true); } } if (!function_exists ('deutsches_datum')) { function deutsches_datum($format, $timestamp, $short = false) { $wochentage = $short ? array("So","Mo","Di","Mi","Do","Fr","Sa") : array("Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"); $monate = array("Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"); $wochentag = $wochentage[date("w", $timestamp)]; $monat = xmlentities($monate[date("n", $timestamp)-1]); $datum = strftime ($format, $timestamp); $datum = str_replace("c", $wochentag, $datum); $datum = str_replace("C", $monat, $datum); return $datum; } } if (!function_exists ('get_items_in_range')) { function get_items_in_range($type, $start_day, $end_day) { $result = array(); $start_stamp = strtotime($start_day); $end_stamp = strtotime($end_day); while ($start_stamp <= $end_stamp) { $day = date('Y-m-d', $end_stamp); $entries_for_day = $GLOBALS['blog']->get($type, "date~=$day", 0); $result = array_merge($result, $entries_for_day); $end_stamp -= 24*60*60; } return $result; } } if (!function_exists ('shorten_text')) { function shorten_text ($content) { $words = substr_count($content, ' '); if ($words >= 20) { $first = array_slice(explode(' ', $content), 0, 20); return join(' ', $first).'... <a href="{entry.permalink}">weiterlesen</a>'; } return $content; } } if (!function_exists ('textile') && file_exists (dirname (__FILE__).'/textile.php')) { include_once (dirname (__FILE__).'/textile.php'); } if (!function_exists ('email_validate')) { function validate_email ($text) { return true; } } ?> --- NEW FILE: bb-conf.php --- <?php /** * Betablogger4phpCMS - a news system for phpCMS * * Configuration script * * <b>License</b> * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @author Martin Jahn <mj...@us...> * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @copyright Copyright (c) 2004, Martin Jahn * @version $Id: bb-conf.php,v 1.1 2004/12/08 17:18:14 mjahn Exp $ * @package betablogger4phpCMS */ /* * $Log: bb-conf.php,v $ * Revision 1.1 2004/12/08 17:18:14 mjahn * initial import * */ /** * configuration-data for bb-script.php */ if (isset ($showconf) && $showconf == 'BB_SCRIPT_CONF') { /** * @var string path to the template file * * define it relative to the directory, where _this_ file lays */ $this->tplfile = 'bb-script.tpl'; /** * Set this to 1 if you want the gravatar-plugin to work. * See {@link http://gravatar.com} for details * @var integer **/ $this->gravatar = 1; /** * @var string set the url for the gravatar-service, the email-id is * added automatically */ $this->gravataruri = 'http://www.gravatar.com/avatar.php?size=40&amp;rating=R&gravatar_id='; /** * use MAIL2CRYPT if you use this script together with phpCMS * * the encoding of the email only works, if<ul> * <li>MAIL2CRYPT is activated by phpCMS</li> * <li>AND this variable is set to 1</li> * </ul> * @var integer **/ $this->usemail2crypt = 1; /** * @var string sort the entries by the field 'date' */ $this->sort_entries_by_field = 'date'; /** * @var string how man entries should be displayed in the overview on * one page? */ $this->display_count = 4; /**#@+ * customization of the displayed entries * * Take care of the field date. The customized version will be copied * into date_custom. The other fields are regulrly replaced with the * customized values. So you only have to rebuild your templatefile if * you use {entry.date} (use {entry.date_custom}) * * You can define for every field in every type of entry (i.e. comment, * entry, trackback...) a custom function. This function must have one param * (the text) and must return the changed text. * * The function must exist in the global namespace (i.e. you can define them * in bb-tools.php */ $this->extra ['entry'] ['date'] = 'mydate'; $this->extra ['entry'] ['body'] = 'textile'; $this->extra ['draft'] ['date'] = 'mydate'; $this->extra ['comment'] ['date'] = 'mydate'; $this->extra ['backlink'] ['date'] = 'mydate'; $this->extra ['singleentry'] ['date'] = 'mydate'; $this->extra ['singleentry'] ['body'] = 'textile'; /**#@-*/ /**#@+ * validation of commententries * * You can define one validation function for every comment-value you want * (i.e. email-address or for detecting spam-attacs). * * The function must accept one string parameter and must return true, if * the value is valid and false if invalid */ $this->validate ['comment'] ['email'] = 'validate_email'; $this->validate ['comment'] ['ip'] = 'validate_ip'; /**#@-*/ /**#@+ * CAUTION: These is an expert setting - edit only if you know, what you do ;-) **/ $this->trackbackvalue = 'trackbacklink'; $this->showvalue = 'showvalue'; $this->edit = 'edit'; /**#@-*/ } /** * configuration-data for bb-edit.php */ if (isset ($showconf) && $showconf == 'BB_EDIT_CONF') { /** * @var string class of the submenu, where we take the topics from * normally you want to categorize your news. This structure can be * taken from the phpcms-menu */ $this->menu_class = 'kreischa.info.news'; /** * @var string name of the menu-field * * This field will be taken as name for the categories from the menu in * my case I use the MNAME- field of my submenu **/ $this->menu_token = 'MNAME_'.$_GET ['lang']; /** * @var int how deep should we recurse the menu-array? * * 0 displays nothing * 1 displays the entries of submenu $menu_class * 2 displays the entries of submenu $menu_class and next submenu-level * 3 ... */ $this->menu_recursive = 1; /** * @var array contains the menu-clases that never should be displayed */ $this->menu_exclude = array ('kreischa.info.news.archiv', 'kreischa.info.sitemap'); /** * @var string separator for concatening the menu-tokens */ $this->menu_separator = '/'; /** * @var string description URI of the file with the editor-script inside * * This file will be called if we saved or deleted an entry, so that the * user can reload the page without any danger for the datas. */ $this->redirectURL = $this->blog->url.'/edit.de.htm'; } ?> --- NEW FILE: bb-edit.php --- <?php /** * Betablogger4phpCMS - a news system for phpCMS * * This script is part of betablogger4phpcms. It handles the editing of news-entries. * * <b>License</b> * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @author Martin Jahn <mj...@us...> * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @copyright Copyright (c) 2004, Martin Jahn * @version $Id: bb-edit.php,v 1.1 2004/12/08 17:18:14 mjahn Exp $ * @package betablogger4phpCMS */ /* * $Log: bb-edit.php,v $ * Revision 1.1 2004/12/08 17:18:14 mjahn * initial import * */ if (!class_exists ('bbedit4phpcms')) { class bbedit4phpcms { /** * This function creates the permalink before the submitted formdata is * saved */ function createPermalink () { if (isset ($_REQUEST ['item_title'])) { $_REQUEST ['item_permatitle'] = str_replace (array ('ä', 'Ã', 'ö', 'Ã', 'ü', 'Ã', 'Ã'), array ('ae', 'Ae', 'oe', 'Oe', 'ue', 'Ue', 'ss'), $_REQUEST ['item_title']); $_REQUEST ['item_permatitle'] = preg_replace ('/[^\/\w]+/im', '-', $_REQUEST ['item_permatitle']); $_REQUEST ['item_permatitle'] = preg_replace ('/[-]+/im', '-', $_REQUEST ['item_permatitle']); } if (isset ($_REQUEST ['item_menu'])) { $_REQUEST ['item_topic'] = $_REQUEST ['item_menu']; } } /** * renders the line with the submit-buttons **/ function displaySubmit () { echo '<label class="horizontal"><span class="hidden">Vorschau</span><input type="submit" name="action" value="Preview" /></label>'."\n"; echo '<label class="horizontal"><span class="hidden">Eintrag abspeichern</span><input type="submit" name="action" value="Save" /></label>'."\n"; $options = ''; foreach ($this->blog->items as $type) { if ($type != $_REQUEST['edit_type'] && !array_diff($this->blog->fields [$_REQUEST ['edit_type']], $this->blog->fields [$type])) { $options .= '<option value="as_'.$type.'">as '.$type.'</option>'."\n"; continue; } } if ($options != '') { echo '<label class="horizontal"><span class="hidden">speichern als </span>'."\n"; echo '<select name="save_as" size="1" class="horizontal">'."\n"; echo '<option value="as_'.$_REQUEST ['edit_type'].'" selected="selected">as '.$_REQUEST ['edit_type'].'</option>'."\n"; echo $options."\n"; echo '</select>'."\n"; echo '</label>'."\n"; } if (isset($this->blog->validate_doctype) && $this->blog->validate_doctype) { echo '<label class="horizontal"><input type="checkbox" name="validate">validate</label> '; } echo '<label class="horizontal"><input type="checkbox" name="sendpings" checked="checked">Pingback</label>'; if ($_REQUEST['action'] != 'Preview') { echo ' <label class="horizontal"><span class="hidden">Eintrag löschen </span><input type="submit" name="action" value="Delete" /></label>'; } else { echo '<label class="horizontal"><span class="hidden">Eintrag ändern </span><input type="submit" name="action" value="Edit" /></label>'; } } /** * processes the submitted data from the editform **/ function processEditform () { // process forms: $this->createPermalink (); $message = ''; $ping_urls = array(); if ($_REQUEST['action']) { $item = new $_REQUEST['edit_type']; foreach ($this->blog->fields[$_REQUEST['edit_type']] as $field) { if (isset($_REQUEST["item_$field"])) { $item->$field = $_REQUEST["item_$field"]; } } $item->id = $_REQUEST['item_id']; if (isset($item->date)) { $item->date = strtotime($item->date); } if ($_REQUEST['action'] == 'Save') { $_REQUEST['item_id'] = $this->blog->save($item); $this->_updateIndexes (); $message .= "{$_REQUEST['edit_type']} saved.<br>\n"; if (in_array($item->type, preg_split("/\s*,\s*/", $this->blog->ping_items))) { $ping_permalink = $item->get_permalink(); $ping_title = isset($this->blog->tb_sendfield[$_REQUEST['edit_type']]['title'])? $item->{$this->blog->tb_sendfield[$_REQUEST['edit_type']]['title']} : ''; $ping_excerpt = isset($this->blog->tb_sendfield[$_REQUEST['edit_type']]['excerpt'])? substr($item->{$this->blog->tb_sendfield[$_REQUEST['edit_type']]['excerpt']}, 0, 256) : ''; foreach ($this->blog->fields[$_REQUEST['edit_type']] as $field) { // parse $value for links and lookup url for ping/trackback support if (!preg_match_all("/<[^>]+href\s*=\s*[\"']?\s*(http:[^\"'>\s]+)\s*[\"']?[^>]*>/i", stripslashes ($item->$field), $matches, PREG_PATTERN_ORDER)) { continue; } $ping_urls = array_merge ($ping_urls, $matches[1]); } } header ('Location: '.$this->redirectURL); //this->redirecturl.'&edit_type=entry&item_id='.$_REQUEST ['item_id']);; } elseif ($_REQUEST['action'] == 'Delete') { $this->blog->delete ($item); $this->_updateIndexes (); $_REQUEST['item_id'] = 0; $message .= "{$_REQUEST['edit_type']} deleted.<br>\n"; foreach ($this->blog->fields [$_REQUEST ['edit_type']] as $field) { if (isset($_REQUEST["item_$field"])) { unset($_REQUEST["item_$field"]); } } header ('Location: '.$this->redirectURL); // header ('Location: '.$this->redirecturl); } } if ($message) print "$message<br>\n"; if (!$_REQUEST['item_id'] || $_REQUEST['action'] == 'Preview' || $_REQUEST['action'] == 'Edit') { $item = new $_REQUEST['edit_type']; foreach ($this->blog->fields[$_REQUEST['edit_type']] as $field) { $item->$field = ''; if (isset ($_REQUEST["item_$field"])) { $item->$field = $_REQUEST["item_$field"]; } elseif (isset ($this->blog->default_value [$_REQUEST ['edit_type']] [$field])) { $item->$field = $this->blog->default_value [$_REQUEST ['edit_type']] [$field]; } } if (!isset ($item->date) || trim ($item->date) == '') { $item->date = time(); } else { $item->date = strtotime($item->date); } $item->id = $_REQUEST['item_id']; } else { $item = $this->blog->get_by_id($_REQUEST['edit_type'], $_REQUEST['item_id']); } // send pings, if there are any ping-URLs in the entry-body if ($_REQUEST['action'] == 'Save') { if (isset($_REQUEST['validate'])) { $this->_validate($this->blog, $item); echo "<br>\n"; flush(); } $this->blog_name = ''; if (isset ($this->blog->blog_name)) { $this->blog_name = $this->blog->blog_name; } if (isset($_REQUEST['sendpings']) && $ping_urls) { print "<b>Processing Pings...</b><br>\n"; foreach ($ping_urls as $url) { $this->_ping($url, $ping_permalink, $ping_title, $ping_excerpt, $this->blog_name); } print "<br>\n"; flush(); } if (isset($_REQUEST['sendpings']) && isset($this->blog->ping_bloglists) && $this->blog->ping_bloglists) { $this->_ping_lists($this->blog_name); print "<br>\n"; flush(); } } return $item; } /** * main function for displaying the editform **/ function displayEditform ($item) { if ($_REQUEST['action'] == 'Preview') { echo '<dl>'; foreach ($this->blog->fields [$_REQUEST ['edit_type']] as $field) { $value = ($field == 'date') ? date ("Y-m-d H:i", $item->$field) : $item->$field ; echo '<dt>'.$field.'</dt><dd>'.$value.'</dd>'; } echo '</dl>'; } // get the fieldnames for the textarea-fields $textarea_fields = array(); if (isset ($this->blog->textarea_fields [$_REQUEST ['edit_type']])) { $textarea_fields = preg_split ("/\s*,\s*/", $this->blog->textarea_fields [$_REQUEST ['edit_type']]); } // get the fieldnames for the hidden-fields $hidden_fields = array (); if (isset ($this->blog->hidden_fields [$_REQUEST ['edit_type']])) { $hidden_fields = preg_split("/\s*,\s*/", $this->blog->hidden_fields [$_REQUEST ['edit_type']]); } echo '<fieldset> <legend>'.($_REQUEST['item_id'] ? "Editiere {$_REQUEST['edit_type']} {$_REQUEST['item_id']}" : "Neuer {$_REQUEST['edit_type']}").'</legend> '; $values = array (); $this->_recurseMenu ($this->menu_class, $values, $this->menu_recursive); echo '<label><span>Kategorie auswählen: </span> <select name="item_menu">'."\n"; for ($i = 0; $i < count ($values); $i++) { echo '<option value="'.$values [$i].'">'.$values [$i].'</option>'."\n"; } echo '</select>'."\n".'</label>'."\n"; // walk through the fields-array and print the editform foreach ($this->blog->fields[$_REQUEST['edit_type']] as $field) { // field is a date -> format it as date if ($field == 'date') $item->$field = date("Y-m-d H:i", $item->$field); // field is a textarea-field if (in_array($field, $textarea_fields)) { echo '<label><span>'.$field.' :</span>'; echo '<textarea name="item_'.$field.'" rows="18" cols="70">'."\n".htmlspecialchars ($item->$field)."</textarea></label>"."\n"; continue; } // field is a hidden-field if (in_array($field, $hidden_fields)) { print '<input type="hidden" name="item_'.$field.'" value="'.htmlspecialchars ($item->$field, ENT_QUOTES).'" />'."\n"; continue; } // field is a text-field print '<label><span>'.$field.' :</span>'; print '<input type="text" name="item_'.$field.'" value="'.htmlspecialchars($item->$field, ENT_QUOTES).'" /></label>'."\n"; } if (isset($this->blog->edit_script[$_REQUEST['edit_type']])) { echo "<script type='text/javascript'>\n{$this->blog->edit_script[$_REQUEST['edit_type']]}\n</script>\n"; } echo '</fieldset>'; return $item; } /** * displays the selector for the entries */ function displayEntrySelector () { echo '<fieldset> <legend>Artikel auswählen</legend> <label> <span>Eintrag auswählen :</span> <select name="item_id" size="10" id="selectfield" onchange="this.form.submit()" /> <option id="newitem" value="0"'.($_REQUEST ['item_id']==0 ? ' selected' : '').'">Neuer '.$_REQUEST['edit_type']."\n"; $items = $this->blog->get($_REQUEST['edit_type'], $_REQUEST['select_query'], $_REQUEST['select_num']); foreach ($items as $it) { $a = $it->$_REQUEST ['select_show']; if (strlen ($a) > 41) { $a = htmlspecialchars (substr ($a, 0, 40)).'…'; } else { $a = htmlspecialchars ($a); } $option = $_REQUEST['select_show'] == 'date' ? date("Y-m-d H:i", $it->date) : $a; echo '<option value="'.$it->id.'"'.($_REQUEST['item_id']==$it->id ? ' selected' : '').'">'.$option.'</option>'."\n"; } echo ' </select> </label>'; /* echo '<label> <span>Anzahl Einträge anzeigen</span> <select name="select_num" size="1" onchange="this.form.submit()"> <option value="20"'.($_REQUEST ['select_num']==20 ? ' selected' : '').'>die letzten 20</option> <option value="50"'.($_REQUEST ['select_num']==50 ? ' selected' : '').'>die letzten 50</option> <option value="200"'.($_REQUEST ['select_num']==200 ? ' selected' : '').'>die letzten 200</option> <option value="0"'.($_REQUEST ['select_num']==0 ? ' selected' : '').'>alle</option> </select> </label> <label> <span>Feld anzeigen</span> <select name="select_show" size="1" onchange="this.form.submit()">'; foreach ($this->blog->fields[$_REQUEST['edit_type']] as $field) { echo '<option value="'.$field.'"'.($_REQUEST ['select_show'] == $field ? ' selected' : '').'">'.$field.'</option>'."\n"; } echo' </select> </label>';*/ echo '<label title="Einträge durchsuchen"> <span>Suchen</span> <input type="text" size="15" name="select_query" value="'.$_REQUEST ['select_query'].'" onchange="this.form.submit()" /> </label> </fieldset>'; } /** * displays the dependent items that are corrsspondending to the current * entry */ function displayDependent ($item) { if ($_REQUEST['item_id'] && isset($this->blog->dependencies[$_REQUEST['edit_type']])) { print '<h3>Abhängige Teile</h3>'."\n"; print "<div class='editdiv'>\n"; foreach ($this->blog->dependencies[$_REQUEST['edit_type']] as $dep_type) { print "<div class='dependent'>\n<table>"; $deps = $_REQUEST['item_id'] ? $item->get($dep_type,'',0) : array(); foreach ($deps as $dep) { print '<tr><td>'.$dep_type.'</td1>' . "<td>".date("Y-m-d H:i", $dep->date)."</td>" . "<td>".strip_tags(substr($dep->{$this->blog->fields[$dep_type][0]}, 0, 25))."</td>" . '<td><a href="?edit=1&edit_type='.$dep_type.'&item_id='.$dep->id.'">Edit</a></td>'."\n" . '<td><a href="?edit=1&edit_type='.$dep_type.'&item_id='.$dep->id.'&action=Delete">Delete</a></td></tr>'."\n"; } print "<tr><td colspan='5'><a href='edit.php?edit_type=$dep_type&item_id=0&item_{$_REQUEST['edit_type']}_id={$_REQUEST['item_id']}'>Add new $dep_type</a></td></tr>\n"; print "</table>\n"; print "</div>\n"; } print "</div>\n"; print "</div>\n"; } } /** * main actor function of this class */ function run () { $_REQUEST['the'] = 'entries'; $title = "Edit Entries"; if (!isset($_REQUEST['edit_type'])) { $_REQUEST['edit_type'] = $this->blog->edit_default; } if (!isset($_REQUEST['item_id'])) { $_REQUEST['item_id'] = 0; } if (!isset($_REQUEST['action'])) { $_REQUEST['action'] = ''; } if (!isset($_REQUEST['select_show'])) { $_REQUEST['select_show'] = 'title'; } if (!isset($_REQUEST['select_num'])) { $_REQUEST['select_num'] = 20; } if (!isset($_REQUEST['select_query'])) { $_REQUEST['select_query'] = ''; } if ($_REQUEST['action'] == 'Save' && isset($_REQUEST['save_as'])) { if (substr($_REQUEST['save_as'], 3) != $_REQUEST['edit_type']) { // save under a new type: $_REQUEST['item_id'] = 0; } $_REQUEST['edit_type'] = substr($_REQUEST['save_as'], 3); } echo ' <form action="'.$_SERVER ['PHP_SELF'].'?edit=&" method="post" id="editform"> <input type="hidden" name="edit" value="1" /> <input type="hidden" name="select_num" value="'.$_REQUEST ['select_num'].'" /> <input type="hidden" name="select_show" value="'.$_REQUEST ['select_show'].'" /> <input type="hidden" name="select_query" value="'.$_REQUEST ['select_query'].'" /> <input type="hidden" name="item_id" value="'.$_REQUEST['item_id'].'">'; $this->displayEntrySelector (); $this->displaySubmit (); $item = $this->processEditform (); $this->displayEditform ($item); // $this->displaySubmit (); echo '</form>'; $this->displayDependent ($item); } /** * constructor method */ function bbedit4phpcms (&$blog) { $this->blog =& $blog; $showconf = 'BB_EDIT_CONF'; include (dirname (__FILE__).'/bb-conf.php'); $showconf = ''; } /** * helper method for remote document calls * @param string url the URL of the remote document */ function _http_request ($url, $post_request='', $follow_redirects=true) { $u = parse_url ($url); if (!isset ($u ['path']) || !$u ['path']) { $u['path'] = '/'; } if (isset ($u ['query'])) { $u['path'] .= '?'.$u["query"]; } if (!isset ($u ['port'])) { $u['port'] = 80; } $str = fsockopen ($u ['host'], $u ['port'], &$errno, &$errstr, 20); if (... [truncated message content] |