Zum Inhalt springen

Bekomme de_alticles Exension nicht zum Laufen

Erstellt am 30. Mai 2004 · 10 Antworten · letzte Antwort am 17. Juni 2004

Tags: Frage

johanness ·

Hallo,

hab die Extension de_articles installiert.
Habe jetzt auch schon 2 Artikel-Textdateien und eine Section "Artikel" angelegt. Aber wie bekomme ich die Artikel jetzt abgezeigt? Wenn ich "neuer Artikel" mache, kann ich den schon anlegen, finde ihn aber nicht im Pagetree!

rolli ·
johanness schrieb

Hallo,

hab die Extension de_articles installiert.
Habe jetzt auch schon 2 Artikel-Textdateien und eine Section "Artikel" angelegt. Aber wie bekomme ich die Artikel jetzt abgezeigt? Wenn ich "neuer Artikel" mache, kann ich den schon anlegen, finde ihn aber nicht im Pagetree!

Hallo,
ich kann Dir leider keine direkte Hilfe geben. Hatte Extension de_articles mal vor einiger Zeit "am laufen" gehabt.
Schau mal nicht direkt im Seitenbaum sondern unter dem List-Modul.
Vieleicht kommst Du ja so weiter.

MFG
rolli

johanness ·

Ja, da sind Aritkel in der deslbigen Rubrik enthalten. aber ich kann diese jedoch trotzdem nicht einbinden! wie geht das?
Danke!

CharoGarcia ·

Hast du auf der Seite welche die Artikel anzeigen soll dein contentelement (Articles) angelegt und als Startingpoint den Sysfolder ausgewählt in welchem die Artikel liegen?
Und bei CODE "browse" oder "complete" eingetragen?

johanness ·

Vielen Dank für die Bemühungen. Ich habz inzwischen geschafft.

Aber eins weiß ich noch nicht:
Wie kann ich den Text, den ich im ConstantEditor als Anriß anzeigen lassen kann, auf Absätze (nicht auf Buchstabenanzahl!!) einstellen. Momentan habe ich 0 Zeichen eingestellt, denn es sieht sehr dumm aus, wenn die Wörter immer abgeschnitte werden.[/b]

CharoGarcia ·

Dafür gibt es soweit ich weiß keine Lösung die schon in der Extention wäre! Da muss man entweder mit leben oder selbst versuchen in der Extention rumzuschreiben....

Spontan fällt mir da ein das man den String von hinten nach dem ersten Leerzeichen durchsucht und dann entsprechend den rest nach dem leerzeichen nicht mehr mit anzeigt

//Letzte buchstaben entfernen
      for($k=strlen($auszug)-1;$k>=0;$k--){
      if($auszug[$k]==" ")break;}
      $auszug = substr($auszug,0,$k);

Zur erklärung:
In der for schleife wird rückwärts zeichen für zeichen durchsucht ob ein leerzeichen vorkommt, falls ja wird die schleife mit "break" beendet. Da die variable K in jedem schleifendurchlauf die zahl des buchstaben im string repräsentiert sagt einem die variable k wenn ein leerzeichen gefunden wurde das wievielte zeichen von vorne es war.

Damit kann man dann mit substr den string vom ersten buchstaben (0) bis zum leerzeichen (k) ausgeben lassen.

Ich hab das noch nicht ausprobiert also eventuell muss da noch was geändert werden aber das Prinzip funktioniert!!

Bleibt nur noch die richtige Stelle in der Extention zu finden wo man das reinschreiben kann 😉

Viel Spass dabei 8-)

Regards

PS: Falls du es hinbekommen hast kannst ja mal schreiben!

johanness ·

Danke, das Script ist sehr logisch 😉 Dann kann ich je theoretisch als String, nach dem gesucht werden soll angeben ". " dann habe ich einen ganzen Satz. Ich werde mir mal die richtige Stelle aus der Extension suchen, wo das hinmuss (kenn sie jetzt eh schon gut, weil ich ja schon rumgebastelt habe mit dem anderen Problem). Falls es nicht klappt komme ich wieder...

Vielen Dank für all die Mühe!
MfG, Johannes

CharoGarcia ·

So ich hab das grad mal bei mir ausprobiert weil das ja doch netter aussieht wenn da nicht die buchstaben abgeschnitten werden!

und so funktionierts
Das hier finden

$excerpt = substr($excerpt,0,$this->conf['enableExcerpts']);

und mit

               $excerpt = substr($excerpt,0,$this->conf['enableExcerpts']);

                //Letzte buchstaben entfernen 
                for($k=strlen($excerpt)-1;$k>=0;$k--){ 
                if($excerpt[$k]==" ")break;} 
                $excerpt = substr($excerpt,0,$k);

ersetzen!

Nebenbei interssiert mich was du sonst noch so verändert hast vielleicht wär ja was für mich dabei 😉

Regards 8-)

CharoGarcia ·

Ja wäre echt nett wenn du den Code mal schicken könntest dann kann ich dir vielleicht auch sagen wo du das reinhaust damit er hinten die buchstaben nicht mehr abhackt!

Welche version der extention nutzt du? Ich benutze Version 0.2.0....

PS: Ich kann frühestens Montag wieder antworten..°!

Regards 8-)

johanness ·

Ok, dann hier mein Code. Das Script von dir ist zwar eingebaut (richtig!?) aber läuft nicht... (Die originalen Zeilen habe ich auskommentier und hingeschrieben, dass Johannes Scherg was eingefügt hat - aber nicht immer!) Ich verwende Version 0.2.1.

<?php
/***************************************************************
*  Copyright notice
*  
*  (c) 2003 Carlos Chiari (ccho@dimension-e.net)
*  All rights reserved
*
*  This script is part of the Typo3 project. The Typo3 project 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.
* 
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
* 
*  This script 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.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/** 
 * Plugin 'Articles' for the 'de_articles' extension.
 *
 * @author	Carlos Chiari <ccho@dimension-e.net>
 */

include_once(PATH_t3lib."class.t3lib_div.php");
require_once(PATH_tslib."class.tslib_pibase.php");

class tx_dearticles_pi1 extends tslib_pibase {
	var $prefixId = "tx_dearticles_pi1";		// Same as class name
	var $scriptRelPath = "pi1/class.tx_dearticles_pi1.php";	// Path to this script relative to the extension dir.
	var $extKey = "de_articles";	// The extension key.
	
	
	# Original class variables
	var $conf;
  	var $command;
  	var $MainTable;
  	var $CategoryTable;
  	
	
	/**
	 * The extension 0.1.0 is intended to allow four distinct -case insensitive- CODE usages, at the Plugin CType page content
	 * 1. SingleView
	 * 2. Browse
	 * 3. Search
	 * 4. Complete
	 * 5. Debug -> temporal until "Stable" status is reached
	 */
	function main($content,$conf)	{
		
		$this->conf = $conf;
		$this->command = ($this->cObj->data['select_key'] !='')?strtolower($this->cObj->data['select_key']):strtolower($conf['CMD']);
		$this->MainTable = 'tx_dearticles_records';
		$this->CategoryTable = 'tx_dearticles_category';
		
		switch((string)$this->command)	{
			case "debug":
			
			echo "<h2>Debug Information</h2><h4>$conf:</h4>";
			t3lib_div::debug($conf);
			#print_r($conf);
			echo "<hr><h4>$this->cObj->currentRecord:</h4>";
			t3lib_div::debug($this->cObj->currentRecord);
			echo "<hr><h4>$this->cObj->data:</h4>";
			t3lib_div::debug($this->cObj->data);
			#print_r($this->cObj->data);
			echo "<hr><h4>$this->internal:</h4>";
			t3lib_div::debug($this->internal);
			#print_r($this->internal);
			echo "<hr>";
			
			case "singleview":
			$this->jumpUid = $this->conf['singleRedirect'];
			if (strstr($this->cObj->currentRecord,"tt_content"))	{
					$this->conf["pidList"] = $this->cObj->data["pages"];
					$this->conf["recursive"] = $this->cObj->data["recursive"];
				}
			$query = $this->pi_list_query($this->MainTable,0,"","","","ORDER BY `sorting` ASC");
	 		$res = mysql(TYPO3_db,$query);
	 		echo mysql_error();
	 		if (!mysql_num_rows($res)) return false;

		 	$item = mysql_fetch_assoc($res);  //Gets the first article on the list.
		 	$getVar = $item['uid'];
			$this->internal["currentTable"]=$this->MainTable;
			$this->internal["currentRow"]=$item;	
			if ($this->command == 'debug') {
				echo "<hr><h4>".$query."</h4>";
				echo "<hr><h4>$this->internal:</h4>";
				t3lib_div::debug($this->internal);
			}
			
			return 	$this->singleView($content,$this->conf);
		
			break;
			
			
			case "browse":
			case "search":
			case "complete":
			$this->jumpUid = $this->conf['singleRedirect'];
			if($this->command=="search") $this->jumpUid = $this->conf['searchRedirect'];
				if (strstr($this->cObj->currentRecord,"tt_content"))	{
					$this->conf["pidList"] = $this->cObj->data["pages"];
					$this->conf["recursive"] = $this->cObj->data["recursive"];
				}
				return $this->listView($content,$this->conf);
			break;
			default : 
				return "<hr color=red><h3><font color=red>Error!</font></h3>This extension uses the following commands at the CODE field of the pagecontent <b>(case insensitive)</b>:<br><ul><li>SingleView<li>Browse<li>Complete<li>Search</ul><hr color=red>";
			break;
		}

	}

	 
		
	/**
	 * function singleView: Main feature of the extension
	 * 
	 */
	 
	function singleView($content,$conf){
	  global  $HTTP_GET_VARS;
		$this->conf=$conf;
		$this->pi_setPiVarDefaults();  
		$this->pi_loadLL();			
		$config = $this->internal["currentRow"]; // Get the article record information.	
		
		$file = "uploads/tx_dearticles/".$config["file"];
  		$ClassWrap = Array(
  		     'title'  => array("wrap"=>'<P '.$this->pi_classParam("singleViewField-title").'>|</P>'),
			 'mehr' => array("wrap"=>'<P '.$this->pi_classParam("singleViewField-content").'>|</P>'),  // added by Johannes Scherg
  		     'author' => array("wrap"=>'<font '.$this->pi_classParam("singleViewField-author").'>|</font>'),
  		     'sections' => array("wrap"=>'<P '.$this->pi_classParam("singleViewField-sections").'>|</P>'),
  		     'caption' => array("wrap"=>'<P '.$this->pi_classParam("singleViewField-caption").'>|</P>'),
  		     'menu' => array("wrap"=>'<P '.$this->pi_classParam("singleViewField-menu").'>|</P>'),
  		     'content' => array("wrap"=>'<P '.$this->pi_classParam("singleViewField-content").'>|</P>'),
  		     );

  		$menuText=array("1","2","3","4","5","6","7","8","9");
  		
  		//Split Article File into paragraphs and process them
  		
  		/*Version 0.1.6 and after:
  		
  		  Este método de determinar los párrafos esta en revisión
  		  para permitir establecer otros delimitadores de párrafos...
  		  
  		  Especialmente el array_filter "trim" y "strlen"...
  		 */

  		  
  		  
  		$tFile = file($file);
  		array_walk($tFile,array($this,"trimParagraphs"));
  		$tFile = array_filter($tFile,"trim");
  		$tFile = array_filter($tFile,"strlen");

  		if ($this->piVars['sword']) {
      	 $kw = 	$this->piVars['sword'];
  		 $tFile = $this->markSword($kw,$tFile);
  		}
  		
  		
  		//Set the Header before setting $docConfig, in case we have to eliminate it.
  		if(!$config["title"]) {  //user has not set a header at the article record.
      	$header = array_shift($tFile);//we take the first paragraph as the header
      	} else {
      	($config["title"] == trim($tFile[0])) ?  $header = array_shift($tFile) : $header = $config["title"]; //Anyway, if the first paragraph is the same as the item header, we take it off
      	}
      	
      	
		if ($header){  //NEW: Article Title will be set as page Title.
			$GLOBALS["TSFE"]->indexedDocTitle=$header;  			// This sets the title of the page for use in indexed search results
			$GLOBALS["TSFE"]->altPageTitle = $header;
		}
		
      	if ($this->piVars['sword']) {
      	 $kw = 	$this->piVars['sword'];
  		 $header = $this->markSword($kw,$header);
  		}
  		
  		
  		$header = $this->cObj->stdWrap($header,$ClassWrap['title']);
      	
        #t3lib_div::debug($config);
        #echo "TARGET=".$GLOBALS["TSFE"]->intTarget;


	  //Configure $docConfig variables
 		if(!$config["optional_sections"]){   //If "sections' details" haven't been set
      	$docConfig["secc_length"] = (!$config["sections"]) ? 5 : ceil(count($tFile)/$config["sections"]); //we set secc_length = 5 by default, overriden if sections is set.
      	$docConfig["sections"] = (!$config["sections"]) ?  ceil(count($tFile)/5) : $config["sections"];  //we get the number of sections the article should be divided into.
      	} else {  //Otherwise...
      	$docConfig["secc_length"] = $this->getArray($config["optional_sections"]); //secc_length is an array as specified by user
      	if(array_sum($docConfig["secc_length"])!=count($tFile)) { //If user has a wrong sum of paragraphs, we fix it here
         $docConfig["secc_length"][0] += (count($tFile)-array_sum($docConfig["secc_length"]));
         }
      	$docConfig["sections"] = count($docConfig["secc_length"]);
      	}
  		if(isset($config["images"])) {
     	$docConfig["imagenes"] = $this->getArray($config["images"]);
  		}
 		 if(isset($config["caption"])){
     	$docConfig["captions"] = $this->getArray($config["caption"]);
  		}
  		$docConfig["images_width"] = $config["images_width"];
  		$docConfig["renderP"] = (!t3lib_div::GPvar('renderP'))? 0: t3lib_div::GPvar('renderP');

		if ($this->command == 'debug') {
				echo "<hr><h4>$docConfig:</h4>";
				t3lib_div::debug($docConfig);
			}
	  /*Version 0.1.6 and after:
  		
  		  Este método de elaborar los párrafos esta en revisión
  		  para permitir establecer otros delimitadores de párrafos...
      */
      
	  //Build $docParts 
	    
  		$temp = 0;
  		for($i=0;$i<$docConfig["sections"];$i++){
      	$y = (is_array($docConfig["secc_length"])) ? $docConfig["secc_length"][$i] : $docConfig["secc_length"]; //Is secc_length of a fixed size or variable?
      	$docParts[$i]=array_slice($tFile,$temp,$y);
      	$temp += $y;
  		}

	  //Build IMAGE codes
		$y = count($docConfig["imagenes"]);
	  	for($i=0; $i<$y; $i++) {
      	$tempImg["image."]["file"] = "uploads/tx_dearticles/".$docConfig["imagenes"][$i];
      	$tempImg["image."]["file."] = Array(
      	       "width" => $docConfig["images_width"],
      	       "width." => array (
      	       		"if" => "1",
      	       		"if." => array (
      	       			"isTrue.field" => "images_width",
      	       			),
      	       	    ),
      	       );      // Here we are working with the stdWrap functions of typoscript. The same applies to $CodeWrap, above.
      	       
		$tempImg["caption"] = $docConfig["captions"][$i];
      	
      	
      	if ($this->piVars['sword']) {
      	 $kw = 	$this->piVars['sword'];
  		 $tempImg['caption'] = $this->markSword($kw,$tempImg['caption']);
  		}

      	$tempImg['caption'] = $this->cObj->stdWrap($tempImg['caption'],$ClassWrap['caption']);
      	
      	if ($this->command == 'debug') {
				echo "<hr><h4>$tempImg:</h4>";
				t3lib_div::debug($tempImg);
			}
      	
      	$imgCodes[$i] = $this->cObj->IMAGE($tempImg["image."]);
      	$imgCodes[$i] = $this->wrapTableElement($imgCodes[$i]);
      	$imgCodes[$i] .= $this->wrapTableElement($tempImg["caption"]);
      	$imgCodes[$i] = $this->wrapTableElement($imgCodes[$i],"table","width=1 align=right");
		
      	if ($this->command == 'debug') {
				echo "<hr><h4>$imgCodes:</h4>";
				t3lib_div::debug($imgCodes);
			}
		}
     	

    //Build MENU
   	  $menu = '';
   	  
   	  //append http_get  variables
	  $thisUrl = $GLOBALS["TSFE"]->absRefPrefix.'index.php?id='.$GLOBALS["TSFE"]->id;
	  if ($this->conf['typeNum']) $thisUrl.='&type='.$this->conf['typeNum'];
	  if ($HTTP_GET_VARS['tx_dearticles_pi1']['showUid']) $thisUrl.='&tx_dearticles_pi1[showUid]='.$HTTP_GET_VARS['tx_dearticles_pi1']['showUid'];
	  if($HTTP_GET_VARS['tx_dearticles_pi1']['sword']) $thisUrl.='&tx_dearticles_pi1[sword]='.$HTTP_GET_VARS['tx_dearticles_pi1']['sword'];
  	  if($HTTP_GET_VARS['tx_dearticles_pi1']['backUrl']) $thisUrl.='&tx_dearticles_pi1[backUrl]='.urlencode($HTTP_GET_VARS['tx_dearticles_pi1']['backUrl']);
	  if($HTTP_GET_VARS['cHash']) $thisUrl.='&cHash='.$HTTP_GET_VARS['cHash'];
	  
	  
	  for($i=0;$i<$docConfig["sections"];$i++){
		     $menu .= ($i!=$docConfig["renderP"])?  "<A href='".$thisUrl."&renderP=".$i."&no_cache=1' target=".$GLOBALS["TSFE"]->intTarget."><b>".$menuText[$i]."</b></A>" : $menuText[$i];
      		$menu .= ($i+1<$docConfig["sections"]) ? " | " : "";
  		}
  		
	  $y = $docConfig["renderP"]+1;
	  $menu .= ($y!=$docConfig["sections"]) ? " | <A href='".$thisUrl."&renderP=".$y."&no_cache=1' target=".$GLOBALS["TSFE"]->intTarget."><b> >></b></A>" : "";
	  $menu = $this->cObj->stdWrap($menu,$ClassWrap['menu']);



	  //Build the page
	  // This code is called to be upgraded and streamlined.
	  // It will just build the section needed depending on the renderP variable.
	  // Also, here we will put the option to have the whole article outputed for printing needs.
	
	  $parts = $this->pi_getLL("part");
	  for($i=0; $i<$docConfig["sections"]; $i++){
	    $sectionSubheader[$i] = $this->cObj->stdWrap($config["author"],$ClassWrap['author']);
	     if ($docConfig["sections"] >=2){ //NEW. 
	    $sectionSubheader[$i] .= $this->cObj->stdWrap($parts[$i]." ".$this->pi_getLL("partName"),$ClassWrap['sections']);
	     }
	    $sectionOutput[$i] = "";
	    
	    //Here we use our own wrapTableElement function. But this can change in a future release, using standard typo3 cTable or oTable content types.
	    $sectionOutput[$i] .= $this->wrapTableElement($header,"tr","colspan=2");
	    $sectionOutput[$i] .= $this->wrapTableElement($sectionSubheader[$i],"tr","colspan=2");
	    if ($docConfig["sections"] >=2){ //NEW. Added feature for next version...
	    $sectionOutput[$i] .= $this->wrapTableElement($menu,"tr","colspan=2");
	    }
	    $sectionOutput[$i] .= $this->wrapTableElement("&nbsp");
	    #array_walk($docParts[$i],array($this,"addContentWrap"),$ClassWrap['content']); // Eliminated. The wrap is rather added in next step:
	    array_walk($docParts[$i],array($this,"addPTag"));
	    $docParts[$i] = implode(" ",$docParts[$i]);
	    $docParts[$i] = $imgCodes[$i].$docParts[$i];
	    $sectionOutput[$i] .= $this->wrapTableElement($docParts[$i],"td","width=".$this->conf['tableWidth']." valign=top");
	    $sectionOutput[$i] .= $this->wrapTableElement("&nbsp");
	     if ($docConfig["sections"] >=2){ //NEW. Added feature for next version...
	    $sectionOutput[$i] .= $this->wrapTableElement($menu,"tr","colspan=2");
	     }
	    $sectionOutput[$i] .= $this->wrapTableElement('&nbsp;',"tr","colspan=2");
	    $sectionOutput[$i] .= $this->wrapTableElement('&nbsp;',"tr","colspan=2");
	    if ($this->command != 'singleview'){
	    $sectionOutput[$i] .= $this->wrapTableElement("<a href='?".urldecode($HTTP_GET_VARS['tx_dearticles_pi1']['backUrl'])."'><p class='tx-dearticles-pi1-singleViewField-menu'>".$this->pi_getLL('Back')."</p></a>","tr","colspan=2");
	    }
	    //$sectionOutput[$i] .= $this->wrapTableElement($imgCodes[$i],"td","valign=top");
	    $sectionOutput[$i] = $this->wrapTableElement($sectionOutput[$i],"table");
	    }
	  $thisPart = $sectionOutput[$docConfig["renderP"]]; //Which section do we output?

	  #t3lib_div::debug($sectionOutput);	
  	//Publish
	  $content = $thisPart;

	  $content.=$this->pi_getEditPanel();

  return $content;
}

function markSword($sword,&$tFile){
	$kw=split("[ ,]",$sword);
	if($this->conf['swordWrap']) {
		$sWrap = $this->getArray($this->conf['swordWrap']);
		while((list(,$val)=each($kw)))	{
			$val=trim($val);
			if ($val != ''){
				if(is_array($tFile)) {
					##$tFile = str_replace($val,$sWrap[0].$val.$sWrap[1],$tFile); Substituted... str_replace is not case insensitive...
					$count = count($tFile);
					$y = 0;
					while ($y <=$count) {
						$res[] = $this->highlight($tFile[$y],$val,$sWrap);
						$y++;
					}
					$tFile = $res;
				} else {
					$tFile = $this->highlight($tFile,$val,$sWrap);
				}
			}
		}
	}
	return $tFile;
}
  
	/*
	 * From php online manual anotations  
     */
  
  function highlight( $haystack, $words, $sWrap = array()){
  	if (is_array( $words))
  	foreach( $words as $word)
  	$haystack = preg_replace('|('.quotemeta($word).')|iU', $sWrap[0].'\1'.$sWrap[1], $haystack);
  	else
  	$haystack = preg_replace('|('.quotemeta($words).')|iU', $sWrap[0].'\1'.$sWrap[1], $haystack);
  	return $haystack;
  }
  

  function addPTag(&$val,$key){
           $val = "<p class='tx-dearticles-pi1-singleViewField-content'>".$val."</p>";
           return $val;
  }
/*
  function addContentWrap(&$val,$key,$wrap){
           $val = $this->cObj->stdWrap($val,$wrap);
           return $val;
  }
*/
  function wrapTableElement($content,$element="",$params1="",$params2=""){
           switch($element){
                  case "table":
                        $content = "<table $params1>".$content."</table>";
                  break;
                  case "tr":
                        $content = "<tr $params1><td $params2>".$content."</td></tr>";
                  break;
                  case "td":
                        $content ="<tr><td $params1>".$content."</td></tr>";
                  break;
                  default:
                        $content = "<tr><td $params1>".$content."</td></tr>";
                  break;
           }
           return $content;
  }


  function trimParagraphs(&$item,$key){
    $item = trim($item);
    return $item;
  }


  
  function getArray($string) {
       $string = preg_split("/,||/",$string); //explode("|",$string);
       $string = array_filter($string,"trim");
       return $string;
  }
	
	
	
	/**
	 * 
	 */
	function listView($content,$conf)	{
		global $HTTP_GET_VARS;
		$this->conf=$conf;		// Setting the TypoScript passed to this function in $this->conf
		$this->pi_setPiVarDefaults();
		$this->pi_loadLL();		// Loading the LOCAL_LANG values
		$lConf = $this->conf["listView."];	// Local settings for the listView function
		
		
		
		if ($this->piVars["showUid"])	{	// If a single element should be displayed:
			$this->internal["currentTable"] = $this->MainTable;
			$this->internal["currentRow"] = $this->pi_getRecord($this->MainTable,$this->piVars["showUid"]);
			
			$content = $this->singleView($content,$this->conf);
			return $content;
		} else {
				
			$items=array(
				"1"=> $this->pi_getLL("list_mode_1","Mode 1"),
				"2"=> $this->pi_getLL("list_mode_2","Mode 2"),
			);
			
			if (!isset($this->piVars["pointer"]))	$this->piVars["pointer"]=0;
			if (!isset($this->piVars["mode"]))	$this->piVars["mode"]=1;
	
				// Initializing the query parameters:
			$Where = '';
			$w = rawurldecode($HTTP_GET_VARS["tx_dearticles_pi1"]["where"]);
			if(!$w) {
			}elseif($this->comand!="search"){
			$this->command="complete";
			$Where = "AND ";
			$Where.=($this->piVars["mode"]==1)?"category=".$w:"author="".$w.""";				
			}	
			
			list($this->internal["orderBy"],$this->internal["descFlag"]) = explode(":",$this->piVars["sort"]);
			
			if($this->command=="complete" OR $this->command=="browse") {
				$this->internal["results_at_a_time"]=1000;
			}else {
				$this->internal["results_at_a_time"]=	t3lib_div::intInRange($lConf["results_at_a_time"],0,1000,3);
			}
			$this->internal["searchFieldList"]="title,author,caption";
			
			$this->internal["orderByList"]="uid,title,category,author";
			
			$orderBy = '';
			$groupBy = '';
			
			# Set the Order, for browsing criteria.
			switch (strtolower(($this->piVars["mode"]))) {
				case "2":
				$orderBy = "ORDER BY author";
				break;
				case "1":
				default:
				$orderBy = "ORDER BY category";				
				break;
				
					
			}
			$query = $this->pi_list_query($this->MainTable,1,$Where,'',$groupBy,$orderBy,"");	
			#echo "<hr>$query<hr>";
			$res = mysql(TYPO3_db,$query);
			if (mysql_error())	t3lib_div::debug(array(mysql_error(),$query));			
			
			list($this->internal["res_count"]) = mysql_fetch_row($res);
			$this->total_items = $this->internal["res_count"];
			$default = intval($this->total_items/$this->internal["results_at_a_time"]);
			$this->internal["maxPages"]=t3lib_div::intInRange($lConf["maxPages"],0,1000,$default);		// The maximum number of "pages" in the browse-box: "Page 1", "Page 2", etc.
			
			// Make listing query, pass query to MySQL:
			$query = $this->pi_list_query($this->MainTable,0,$Where,'',$groupBy,$orderBy,"");
			#echo "<hr>$query<hr>";
			$res = mysql(TYPO3_db,$query);

			if (mysql_error())	t3lib_div::debug(array(mysql_error(),$query));
				
			
			$this->internal["currentTable"] = $this->MainTable;
			// Put the whole list together:
			$fullTable="";	// Clear var;
			
				switch (strtolower($this->command)){

				case "search":				
				global $HTTP_GET_VARS;
				$this->piVars['sword']=$HTTP_GET_VARS['tx_dearticles_pi1']['sword'];
				#echo "piVars:".t3lib_div::debug($this->piVars);
				$fullTable.=$this->searchBox($content,$this->conf);//substituye a pi_list_searchBox()
				if(trim($this->piVars['sword'])){
				$fullTable.=($HTTP_GET_VARS['tx_dearticles_pi1']['sword'] != '')?$this->showSearchResult($res):'';				
				$fullTable.=($HTTP_GET_VARS['tx_dearticles_pi1']['sword'] != '')?$this->list_browseresults():'';
				}elseif ($this->piVars['sword']) {
					
					$fullTable .= $this->noResults();
				}
				break;
				
				case "browse":
				if(!$this->conf['disableSelectors']) {
				$fullTable.="<table><tr><td class='tx-dearticles-pi1-singleViewField-browseBy'>".$this->pi_getLL("browse_cat")."</td><td>".$this->list_modeSelector($items)."</td></tr></table>";												}
				$fullTable.=$this->makelist($res);
				break;
				case "complete":
				default:
				if(!$this->conf['disableSelectors']) {
				$fullTable.="<table><tr><td class='tx-dearticles-pi1-singleViewField-browseBy'>".$this->pi_getLL("browse_cat")."</td><td>".$this->list_modeSelector($items)."</td></tr></table>";
				}
				$fullTable.=$this->makelist($res);	
				$fullTable.=$this->list_browseresults();
				break;
				}
			return $fullTable;
		}
			
			
	}
	
	/**
	 * function searchBox(): substitutes pi_list_searchBox()
	 */
	 function searchBox($content,$conf){
		$action = "index.php";
		$this->conf = $conf;
	 	if(!$this->conf['redirect']) {
	 		$this->conf['redirect'] = $GLOBALS['TSFE']->id;
	 	}

	 // Original Search box design, by typo3: Added the hidden field id 
	 	$sTables = '<form action="'.$action.'" method="GET"><input type="hidden" name="id" value="'.$this->conf['redirect'].'">
		<input type="text" name="'.$this->prefixId.'[sword]" value="'.$this->piVars["sword"].'"'.$this->pi_classParam("searchbox-sword").' size="15">&nbsp;';
	 	$submit = ($this->conf['submitImg'] == '')? '<input type="submit" value="'.htmlspecialchars($this->pi_getLL("pi_list_searchBox_search","Search")).'"'.$this->pi_classParam("searchbox-button").'>':'<A href="#"><IMG src="'.$this->conf['submitImg'].'" onClick="document.forms[0].submit();"></A>';
	 	$sTables .= $submit.'<input type="hidden" name="no_cache" value="1">';
	 	$sTables .= '</form>';
		return $sTables;	 	
	 	
	 }

	/*
	 *  function noResults()
	 */
	 function noResults(){
		$out ="<table width=100% border=0 cellspacing=0 cellpadding=0>";
	   	$out.="<tr><td>".$this->pi_getLL('NoResult')."</td></tr>";
		$out.="</table>";	
		return $out;	 		
	 }
	 
	 /**
	 * 
	 */
	function makelist($res)	{
		$items=Array();
		$cc = 1;
		$dd = 1;
		$total_res = mysql_num_rows($res);		
		$this->internal["currentRow"] = mysql_fetch_assoc(($res));
		$cat = (strtolower($this->piVars["mode"]) == '2')? $this->internal["currentRow"]["author"]:$this->getCategory($this->internal["currentRow"]["category"]);
		
		#if(!$cat) $cat =  return '<strong><font color="#FF0000">Category Error</font></strong>';	
		$prev_cat = $cat;
		
		$items[] = "<table width=100% border=0 cellspacing=0 cellpadding=0>";
  		while($cc <= $total_res) {// mientras la cuenta sea menor al total
		
			$items[] = "<tr><td class=tx-dearticles-pi1-singleViewField-listHeader>$cat</td>
    					<td>&nbsp;</td>
    					<td>&nbsp;</td>
  						</tr>";		
	
		while($prev_cat == $cat AND $cc <= $total_res)	{//mientras la categoría sea igual a la anterior
			$moreCat = (strtolower($this->piVars["mode"]) == '2')? $this->internal["currentRow"]["author"]:$this->internal["currentRow"]["category"];
			if ($dd <= $this->conf["partialResults"] OR $this->command=="complete") {
			$items[]=$this->makeListItem();
			}
			$this->internal["currentRow"] = mysql_fetch_assoc(($res));
			$cat = (strtolower($this->piVars["mode"]) == '2')? $this->internal["currentRow"]["author"]:$this->getCategory($this->internal["currentRow"]["category"]);
			$cc++;
			$dd++;
		}
		if ($dd > $this->conf["partialResults"] AND $this->command!="complete"){
			$tempUid = $GLOBALS["TSFE"]->id ;
			$GLOBALS["TSFE"]->id = $this->cObj->data["pid"];
			$href=$this->pi_linkTP_keepPIvars("<span  class='tx-dearticles-pi1-singleViewField-showMore'>".$this->pi_getLL("showMore")."</span>",array("pointer"=>$this->piVars["pointer"],"mode"=>$this->piVars["mode"],"where"=>$moreCat),0,1);
			$GLOBALS["TSFE"]->id = $tempUid;
			
			$items[] = "<tr><td colspan='2' align='right'>".$href."</td><td>&nbsp;</td></tr>";
		}
		$dd = 1;		
		$items[] = "<tr><td colspan='3'>&nbsp;</td></tr>";
		$prev_cat = $cat;
		}
		$items[]="</table>";	
		$out = '<DIV'.$this->pi_classParam("listrow").'>
			'.implode(chr(10),$items).'
			</DIV>';
		return $out;
	}
	 
	 
	
	function showSearchResult($res){
	    if ($this->conf["singleRedirect"] !='') {
	    $this->jumpUid = $this->conf["singleRedirect"];	    	
	    }
	    $pointer=$this->piVars["pointer"];
		$results_at_a_time = t3lib_div::intInRange($this->internal["results_at_a_time"],1,1000);
	
		// Search the fields
		// 
		while($record = mysql_fetch_assoc($res)){
	  	$fieldRes["record_".$record['uid']] = $record;	
		} // this is done in order to use the array_merge function, which requieres the key to be strings in order to override one key value with the new or incoming one.
		
		// We save the values, to clean the variables... and be able to restore them after
		$searchWords = $this->piVars["sword"];
		$thisPointer = $this->piVars["pointer"];
		$resultsAtATime = $this->internal["results_at_a_time"];
		$this->internal["results_at_a_time"] = 1000;
		$this->piVars["sword"] = '';
		$this->piVars["pointer"] = '';
		
		// Search the files
		// Will have to study the Indexed Search Engine extension to enable this extension to be parsed by that one.
		if ($searchWords)	{
		$query2 = $this->pi_list_query($this->MainTable,0,$Where,'',$groupBy,$orderBy,"");
		#echo "<hr>$query2<hr>";
		$res = mysql(TYPO3_db,$query2);
		if (mysql_error())	t3lib_div::debug(array(mysql_error(),$query2));					

		while($record = mysql_fetch_assoc($res)) {//revisa TODOS los artículos

			$testFile = file("uploads/tx_dearticles/".$record['file']);
			$count = count($testFile); //cuántos ítems tiene el array
			$y = 0;
			$true = 0; //falso inicialmente
			#t3lib_div::debug($testFile);
			while($true == 0 && $y <=$count) { //si sigue falso y aún no hemos acabado el array
			    
				$kw=split("[ ,]",$searchWords);
					while((list(,$val)=each($kw)))	{  
					
					$val=trim($val);
					if($val != ''){
					#echo "keyword:$val<br>";
					$true += is_int($this->strpos_case_insensitive($testFile[$y],$val));
					}
					}
					
					$y++;
				}
				if($true) {
				  $fileRes["record_".$record['uid']] = $record;	
				}
			}			
		}		
		$totalRes = array_merge($fieldRes,$fileRes);
		if(count($totalRes)<=0) return $this->noResults();
		#t3lib_div::debug($fileRes);
		
		#t3lib_div::debug($totalRes);
		
		$out = "<table width=100% border=0 cellspacing=0 cellpadding=0>";
		$cc = 1 + $pointer*$results_at_a_time;
		while(list($k,) = each($totalRes)){
			$this->internal["currentRow"] = $totalRes[$k]; 
			$out.="<tr><td class='tx-dearticles-pi1-singleViewField-listTitle'><b>$cc.</b>&nbsp;".$this->getFieldContent("title")."</td><tr>";
			if($this->conf['enableExcerpts']){
				$out.=$this->makeExcerpt($this->internal['currentRow']);
			}
		    $cc++;
		}
		$out.="</table>";
		
		$searchWords = $this->piVars["sword"];
		$thisPointer = $this->piVars["pointer"];
		$resultsAtATime = $this->internal["results_at_a_time"];
		$this->internal["results_at_a_time"] = $resultsAtATime;
		$this->internal['res_count'] = count($totalRes);
		$this->piVars["sword"] = $searchWords;
		$this->piVars["pointer"] = $thisPointer;
		return $out;
		
		
	}
	/*
	 *
	 */
	 
	 function strpos_case_insensitive ($haystack, $needle, $offset=0){
		$haystack = substr($haystack, $offset, strlen($haystack) );
		 $temp = stristr($haystack, $needle);
		 $pos = strlen($haystack) - strlen($temp);
		 If ($pos == strlen ($haystack) ) {
   			$pos = FALSE;
		 } else  {
		 $pos += $offset;
		 }	
		 return $pos;
	 }
	
	/**
	 * 
	 */
	function makeListItem()	{		
		$out = "<tr><td colspan='2' class='tx-dearticles-pi1-singleViewField-title' align='left'>".$this->getFieldContent("title")."</td></tr>";
		if($this->conf['enableExcerpts']){
		$out .= $this->makeExcerpt($this->internal['currentRow']);
		}
		return $out;
	}
	
	function makeExcerpt($record){
		//If Excerpts enabled:
		
		$excerpt = ''; //limpiamos la variable
		$tempFile = file ("uploads/tx_dearticles/".$record['file']);
		$tempExc = (!$record["title"])?$tempFile[1]:($record['title']==$tempFile[0])?$tempFile[1]:$tempFile[0];  //user has not set a header at the article record.
    	// Original:   $excerpt = substr($tempExc,0,$this->conf['enableExcerpts']);	
		// Inserted by Johannes Scherg, for getting holes sentenses
        $excerpt = substr($tempExc,0,$this->conf['enableExcerpts']);
        //Letzte buchstaben entfernen
        for($k=strlen($excerpt)-1;$k>=0;$k--) {
           if($excerpt[$k]==". ") break;
		}
        $excerpt = substr($excerpt,0,$k);
		//End of Johnanes' Code		
      	$out .= "<tr><td colspan='3'><p class='tx-dearticles-pi1-content'>".$excerpt."  ".$this->getFieldContent("mehr")."<br><br><br><br><br></p></td></tr>";
		
		return $out;
	}
	
	function getCategory($uid){
		$rendered_field = "title"; //what is the name of the field with the category name?
		$cat_query = "Select $rendered_field from ".$this->CategoryTable." where uid=".$uid." and deleted <> 1 and hidden <> 1";
		$query_result = mysql(TYPO3_db,$cat_query);
		$cat = @mysql_fetch_assoc($query_result);
		return $cat[$rendered_field];
		
	}
	
	
	

	/**
	 * [Put your description here]
	 */
	function getFieldContent($fN)	{
		global $HTTP_GET_VARS, $HTTP_SERVER_VARS;
		$this->piVars['sword'] = $HTTP_GET_VARS['tx_dearticles_pi1']['sword'];
		switch($fN) {
			case "uid":
				return $this->pi_list_linkSingle($this->internal["currentRow"][$fN],$this->internal["currentRow"]["uid"],1);	// The "1" means that the display of single items is CACHED! Set to zero to disable caching.
			break;
			case "title":
					// This will wrap the title in a link.
				return $this->pi_list_linkSingle($this->internal["currentRow"]["title"],$this->internal["currentRow"]["uid"],1,array('sword'=>$this->piVars['sword'],'backUrl'=>urlencode($HTTP_SERVER_VARS['QUERY_STRING'])));
			break;
			case "mehr":
			
				   // This will wrap the mehr in a link.
				return $this->pi_list_linkSingle("[mehr...]",$this->internal["currentRow"]["uid"],1,array('sword'=>$this->piVars['sword'],'backUrl'=>urlencode($HTTP_SERVER_VARS['QUERY_STRING'])));
			
			break;
			default:
				return $this->internal["currentRow"][$fN];
			break;
		}
	}
	
	
	
		function list_modeSelector($items=array())	{
			// Making menu table:  -modeSelector-SCell classes no está definido- 
		$cells=array();
		reset($items);
		while(list($k,$v)=each($items))	{
			$cells[]='<td'.($this->piVars["mode"]==$k?$this->pi_classParam("modeSelector-SCell"):"").'><P>'.$this->pi_linkTP_keepPIvars($v,array("mode"=>$k,"where"=>""),$this->pi_isOnlyFields($this->pi_isOnlyFields)).'</P></td>';
		}
		
		$sTables = '<DIV'.$this->pi_classParam("modeSelector").'><table>
			<tr>'.implode("",$cells).'</tr>
		</table></DIV>';
		return $sTables;
	}
	
	
	
	
	/**
	 * [Put your description here]
	 */
	function getFieldHeader($fN)	{
		switch($fN) {
			case "title":
				return $this->pi_getLL("listFieldHeader_title","<em>title</em>");
			break;
			default:
				return $this->pi_getLL("listFieldHeader_".$fN,"[".$fN."]");
			break;
		}
	}
	
		/**
	 * substitutes pi_list_browseresults
	 *
	 */ 
	 
	 function list_browseresults($showResultCount=1)	{
	 	$preID = $GLOBALS["TSFE"]->id;
	 	
	 	switch ($this->command) {
	 		
	 		case "search":	
	 	    $GLOBALS["TSFE"]->id = $this->conf['redirect'];
	 	    break;
	 	    case "browse":
	 	    default:
	 	}
			// Initializing variables:
		$GLOBALS["first"] = (!$GLOBALS["first"])? 0:$GLOBALS["first"];
		$pointer=$this->piVars["pointer"];
		$count=$this->internal["res_count"]; 
		$results_at_a_time = t3lib_div::intInRange($this->internal["results_at_a_time"],1,1000);
		$totalPages = ceil($count/$results_at_a_time);
		$maxPages = t3lib_div::intInRange($this->internal["maxPages"],1,100);
		$max = t3lib_div::intInRange(ceil($count/$results_at_a_time),1,$maxPages);
		$pointer=intval($pointer);

	
		if ($pointer>$GLOBALS["first"]+$max-1){
			$GLOBALS["first"]++;
		}
		if ($pointer<$GLOBALS["first"]+$max-1){
			$GLOBALS["first"]--;
		}
		
		$first = ($GLOBALS["first"]>=0)?$GLOBALS["first"]: 0;

		$links=array();
		// Make browse-table/links:		
		if ($pointer>0)	{
			$linksPre='<td><p>'.$this->pi_linkTP_keepPIvars($this->pi_getLL("pi_list_browseresults_prev","< Previous"),array("pointer"=>($pointer-1?$pointer-1:"")),0).'</p></td>';
		} elseif ($this->pi_alwaysPrev)	{
			$linksPre='<td><p>'.$this->pi_getLL("pi_list_browseresults_prev","< Previous").'</p></td>';
		}
		for($a=0;$a<$totalPages;$a++)	{//browsebox-SCell no esta definido...
			$links[]='<td'.($pointer==$a?$this->pi_classParam("browsebox-SCell"):"").' nowrap><p>'.$this->pi_linkTP_keepPIvars(trim($this->pi_getLL("pi_list_browseresults_page","Page")." ".($a+1)),array("pointer"=>($a?$a:"")),$this->pi_isOnlyFields($this->pi_isOnlyFields)).'</p></td>';
		}
		if ($pointer<ceil($count/$results_at_a_time)-1)	{
			$linksPost='<td><p>'.$this->pi_linkTP_keepPIvars($this->pi_getLL("pi_list_browseresults_next","Next >"),array("pointer"=>$pointer+1)).'</p></td>';
		}

		$links=array_slice($links,$first,$max);
		$links=array_reverse($links);
		$links=array_merge($links,Array($linksPre));
		$links=array_reverse($links);
		
		$links=array_merge($links,Array($linksPost));
		$pR1 = $pointer*$results_at_a_time+1;
		$pR2 = $pointer*$results_at_a_time+$results_at_a_time; // la serie de estilos browsebox no esta definido....
		$sTables = '<DIV'.$this->pi_classParam("browsebox").'>'.
			($showResultCount ? '<P>'.sprintf(
				str_replace("###SPAN_BEGIN###","<span".$this->pi_classParam("browsebox-strong").">",$this->pi_getLL("pi_list_browseresults_displays","Displaying results ###SPAN_BEGIN###%s to %s</span> out of ###SPAN_BEGIN###%s</span>")),
				$pR1,
				min(array($this->internal["res_count"],$pR2)),
				$this->internal["res_count"]
				).'</P>':''
			).
		'<table>
			<tr>'.implode("",$links).'</tr>
		</table></DIV>';
		$GLOBALS["TSFE"]->id = $preID;
		return $sTables;
	}
	
	/**
	 * [Put your description here]
	 */
	function getFieldHeader_sortLink($fN)	{
		return $this->pi_linkTP_keepPIvars($this->getFieldHeader($fN),array("sort"=>$fN.":".($this->internal["descFlag"]?0:1)));
	}
}


if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/de_articles/pi1/class.tx_dearticles_pi1.php'])	{
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/de_articles/pi1/class.tx_dearticles_pi1.php']);
}

?>