Thread: [Phpcms-plugins-cvs] autodescgen autodescgen.php,1.1.1.1,1.2
Brought to you by:
mjahn
From: Martin J. <mj...@us...> - 2005-02-01 13:53:27
|
Update of /cvsroot/phpcms-plugins/autodescgen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5415 Modified Files: autodescgen.php Log Message: made some changes for perfect use with masterPlugin4phpCMS Index: autodescgen.php =================================================================== RCS file: /cvsroot/phpcms-plugins/autodescgen/autodescgen.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- autodescgen.php 22 Apr 2004 08:05:01 -0000 1.1.1.1 +++ autodescgen.php 1 Feb 2005 13:53:17 -0000 1.2 @@ -1,36 +1,63 @@ <?php /** - * @author Martin Jahn <ma...@ma...> - * @license GPL - * @version 0.1 - * - * Installationsanleitung für autodescgen.php Version 0.1 - * (Vielen Dank an Lumi01 für die Hilfe :-)) - * - * Die Datei autodescgen.php kann man in das Pluginverzeichnis von phpCMS - * \parser\plugs\autodescgen\ kopieren. + * <b>Installtion instructions (en)</b> + * + * The file autodescgen.php must be copied into the phpCMS-plugin-directory + * (i.e. /parser/plugs/) + * + * You can place the call for the plugin into the contentfile (for us only + * in this contentfile) or into the template-file (for use in all contentfiles). + * {PLUGIN FILE="<PLUGINDIR>/autodescgen.php" TYPE="STATIC"} + * + * You must place the tag AUTOGENERATEDDESC where you want the output of the + * plugin placed. + * + * <b>Installationsanleitung (de)</b> * - * Aufruf des Plugins wahlweise über das Template oder die Contentdatei durch - * Einfügen der folgenden Zeile: - * {PLUGIN FILE="<PLUGINDIR>/autodescgen/autodescgen.php" TYPE="STATIC"} - * wobei <PLUGINDIR> den korrekten Pfad zum Pluginverzeichnis enthalten muß. + * Die Datei autodescgen.php wird in das Pluginverzeichnis von phpCMS + * (z.B. /parser/plugs/) kopieren. * - * TIPP: Der Pfad zum Pluginverzeichnis kann in der Projektdatei mit der Variablen - * PLUGINDIR := ... angegeben werden. + * Der Aufruf des Plugins erfolgt wahlweise über das Template oder die + * Contentdatei durch Einfügen der folgenden Zeile: + * {PLUGIN FILE="<PlUGINDIR>/autodescgen.php" TYPE="STATIC"} wobei + * <PLUGINDIR> den korrekten Pfad zum Pluginverzeichnis darsteltl. * - * Notwendige Konfiguration in der Parserverwaltung: - * - der Menüpunkt "PAX TAGS berücksichtigen" muss aktiviert sein - * Im Template muss dort, wo die Ausgabe von autodescgen.php erscheinen soll das Tag - * AUTOGENERATEDDESC - * eingefügt werden. Zum Beispiel so: - * <meta name="description" content="AUTOGENERATEDDESC"> + * Im Template muss dort, wo die Ausgabe von autodescgen.php erscheinen soll das + * Tag AUTOGENERATEDDESC eingefügt werden. Zum Beispiel so: + * <meta name="description" content="AUTOGENERATEDDESC"> + * + * TIPP: Der Pfad zum Pluginverzeichnis kann in der Projektdatei mit der + * Variablen PLUGINDIR := ... angegeben werden. + * + * <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. * - * Alternativ ist es auch möglich den Aufruf des Plugins direkt in das Meta-Tag einzufügen. - * Dann muss aber im Plugin die Variable $usePAXtags = 'OFF' gesetzt werden. Außerdem kann - * in diesem Fall auch PAX TAGS berücksichtigen abgeschaltet werden, falls es nicht - * anderweitig benötigt wird. + * 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) 2005, Martin Jahn + * @version $Id$ + * @package project_name + */ + +/* +* $Log$ +* Revision 1.2 2005/02/01 13:53:17 mjahn +* made some changes for perfect use with masterPlugin4phpCMS +* +*/ if (isset($DEFAULTS->EDIT)) { /** @@ -39,11 +66,20 @@ return; } +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); +} +} + header('X-Plugin-Powered: 1'); -$ProcessFields = array('KOLUMNE', 'CONTENT1', 'CONTENT2', 'CONTENT', 'FOOTER'); +$ProcessFields = array('KOLUMNE', 'CONTENT1', 'CONTENT2', 'CONTENT', 'FOOTER', 'CONTENT_1', 'CONTENT_2'); $MaxDescSize = 250; // <-- maximum size of the string, that is examined -$default_text = 'Programmieren Topreferer Vor Zurück Prev Next Webdesign PHP Galerie phpCMS' ; // <-- Default-Text if empty content +$default_text = 'Programmieren Topreferer Vor Zur�ck Prev Next Webdesign PHP Galerie phpCMS' ; // <-- Default-Text if empty content $usePAXtags = 'ON' ; // <-- '1' if you want to use the '$PAXtag' tag below, and if 'PAX Tags' is turned ON in the GUI. $PAXtag = 'AUTOGENERATEDDESC'; // <-- tag that should be replaced by the keywords @@ -53,20 +89,8 @@ * Otherwise the tags will be replaced after the work of this plugin was done. * The result is, that you have HTML-Tags in the description-tag (not standard-conform) **/ -$IgnoreTags = array(''); - -/*------------------------------------------------*/ -// time mesurement for keyword generation -/*------------------------------------------------*/ -/*if(!function_exists(global_getmicrotime)) { - function global_getmicrotime() { - list($usec, $sec) = explode(" ",microtime()); - return ((float)$usec + (float)$sec); - } -} +$IgnoreTags = array(' '); -$time_start = global_getmicrotime(); -*/ $finalbuffer = ''; reset($ProcessFields); @@ -77,40 +101,36 @@ } $finalbuffer = str_replace("\n", ' ', $finalbuffer); -/* -$fh = fopen (dirname(__FILE__).'/test.log','w'); -fwrite($fh,$finalbuffer); -fclose($fh); -*/ -$finalbuffer = trim($finalbuffer); -$finalbuffer = preg_replace ("'<phpcms:ignore[^>]*?".">.*?</phpcms:ignore>'si", "", $finalbuffer); -/** -* remove unwanted Tags -**/ -$ReplaceTags = array_fill(0, count((array) $IgnoreTags), ''); +// get body content +if (preg_match('/<body[^>]*>(.*?)<\/body[^>]*>/im', $finalbuffer, $erg)) { + $finalbuffer = $erg [1]; +} + +// get the content +$finalbuffer = preg_replace ('/(<\!-- PHPCMS_NOINDEX(.*?)\/PHPCMS_NOINDEX -->)/im', '', $finalbuffer); + +// remove unwanted Tags +$ReplaceTags = array_fill(0, count((array) $IgnoreTags), ''); $finalbuffer = str_replace((array) $IgnoreTags, (array) $ReplaceTags, $finalbuffer); + +// strip any HTML and PHP-tags $finalbuffer = strip_tags($finalbuffer); -$finalbuffer = htmlentities($finalbuffer); + +// remove(double)-spaces +$finalbuffer = preg_replace("/(\s[\s]+)/im", " ", $finalbuffer); + +// trim finalbuffer to maximal length +$finalbuffer = trim($finalbuffer); $finalbuffer = substr($finalbuffer,0,$MaxDescSize); $end = strrpos($finalbuffer, ' '); $finalbuffer = substr($finalbuffer, 0, $end).' ...'; -$finalbuffer = str_replace("\n", '', $finalbuffer); if(strlen(trim($finalbuffer)) == 0) { $finalbuffer = $default_text; } -// remove(double)-spaces -$finalbuffer = str_replace(" ", " ", $finalbuffer); $output = $finalbuffer; -//$time_needed = sprintf("%01.4f", global_getmicrotime() - $time_start); - -if(strtoupper($DEFAULTS->PAXTAGS) == 'ON' AND strtoupper($usePAXtags) == 'ON') { - $Tags[]= array($PAXtag,htmlentities($output)); -} else { - // If you do not use PAX tags, put the {PLUGIN} call right where you want the meta tags to appear: - print($output); -} +$Tags[]= array($PAXtag,$output); ?> |