Location: PHPKode > projects > phpCMS-Plugin: AutoDescGen > phpcms-plugin-autodescgen/autodescgen.php
<?php
if (isset($DEFAULTS->EDIT)) {
  /**
   * do nothing in EDIT-mode
   */
   return;
}
$ProcessFields        = array('KOLUMNE', 'CONTENT1', 'CONTENT2', 'CONTENT', 'FOOTER');
$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
$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

/*------------------------------------------------*/
// time mesurement for keyword generation
/*------------------------------------------------*/
if(!function_exists(global_getmicrotime)) {
  function global_getmicrotime() {
    list($usec, $sec) = explode(" ",microtime());
    return ((float)$usec + (float)$sec);
    }
}

$time_start = global_getmicrotime();

$finalbuffer = '';

reset($ProcessFields);
foreach ($ProcessFields as $field) {
  if (isset($PageContent->{$field})) {
    $finalbuffer .= trim(join(' ',$PageContent->{$field})).' ';
  }
}

$fh = fopen (dirname(__FILE__).'/test.log','w');
fwrite($fh,$finalbuffer);
fclose($fh);

$finalbuffer = trim($finalbuffer);
$finalbuffer = preg_replace ("'<phpcms:ignore[^>]*?".">.*?</phpcms:ignore>'si", "", $finalbuffer);
$finalbuffer = strip_tags($finalbuffer);
$finalbuffer = htmlentities($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);
}

?>
Return current item: phpCMS-Plugin: AutoDescGen