Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00040 require_once(PATH_tslib."class.tslib_pibase.php"); 00041 00042 class tx_ttboard extends tslib_pibase { 00043 var $cObj; // The backReference to the mother cObj object set at call time 00044 00045 var $enableFields =""; // The enablefields of the tt_board table. 00046 var $dontParseContent=0; 00047 var $treeIcons=array( 00048 "joinBottom"=>"\\-", 00049 "join"=>"|-", 00050 "line"=>"| ", 00051 "blank"=>" ", 00052 "thread"=>"+", 00053 "end"=>"-" 00054 ); 00055 var $searchFieldList="author,email,subject,message"; 00056 00057 var $emoticons = 1; 00058 var $emoticonsPath = "media/emoticons/"; 00059 var $emoticonsTag = '<img src="{}" valign="bottom" hspace=4>'; 00060 var $emoticonsSubst=array( 00061 ":-)" => "smile.gif", 00062 ";-)" => "wink.gif", 00063 ":-D" => "veryhappy.gif", 00064 ":-(" => "sad.gif" 00065 ); 00066 00067 var $alternativeLayouts=""; 00068 var $allowCaching=""; 00069 var $conf=array(); 00070 var $config=array(); 00071 var $tt_board_uid=""; 00072 var $pid=""; 00073 var $orig_templateCode=""; 00074 var $typolink_conf=array(); 00075 var $local_cObj=""; 00076 00077 00081 function main_board($content,$conf) { 00082 // ************************************* 00083 // *** getting configuration values: 00084 // ************************************* 00085 $this->conf = $conf; 00086 $this->tt_board_uid = intval(t3lib_div::_GP("tt_board_uid")); 00087 00088 $this->alternativeLayouts = intval($this->conf["alternatingLayouts"])>0 ? intval($this->conf["alternatingLayouts"]) : 2; 00089 00090 // pid_list is the pid/list of pids from where to fetch the board items. 00091 $this->config["pid_list"] = trim($this->cObj->stdWrap($this->conf["pid_list"],$this->conf["pid_list."])); 00092 $this->config["pid_list"] = $this->config["pid_list"] ? implode(t3lib_div::intExplode(",",$this->config["pid_list"]),",") : $GLOBALS["TSFE"]->id; 00093 list($pid) = explode(",",$this->config["pid_list"]); 00094 $this->pid = $pid; 00095 00096 // "CODE" decides what is rendered: 00097 $this->config["code"] = $this->cObj->stdWrap($this->conf["code"],$this->conf["code."]); 00098 $this->allowCaching = $this->conf["allowCaching"]?1:0; 00099 00100 // If the current record should be displayed. 00101 $this->config["displayCurrentRecord"] = $this->conf["displayCurrentRecord"]; 00102 if ($this->config["displayCurrentRecord"]) { 00103 $this->config["code"]="FORUM"; 00104 $this->tt_board_uid=$this->cObj->data["uid"]; 00105 } 00106 00107 // debug($this->config["code"]); 00108 // template is read. 00109 $this->orig_templateCode = $this->cObj->fileResource($this->conf["templateFile"]); 00110 00111 00112 // globally substituted markers, fonts and colors. 00113 $splitMark = md5(microtime()); 00114 $globalMarkerArray=array(); 00115 list($globalMarkerArray["###GW1B###"],$globalMarkerArray["###GW1E###"]) = explode($splitMark,$this->cObj->stdWrap($splitMark,$conf["wrap1."])); 00116 list($globalMarkerArray["###GW2B###"],$globalMarkerArray["###GW2E###"]) = explode($splitMark,$this->cObj->stdWrap($splitMark,$conf["wrap2."])); 00117 list($globalMarkerArray["###GW3B###"],$globalMarkerArray["###GW3E###"]) = explode($splitMark,$this->cObj->stdWrap($splitMark,$conf["wrap3."])); 00118 $globalMarkerArray["###GC1###"] = $this->cObj->stdWrap($conf["color1"],$conf["color1."]); 00119 $globalMarkerArray["###GC2###"] = $this->cObj->stdWrap($conf["color2"],$conf["color2."]); 00120 $globalMarkerArray["###GC3###"] = $this->cObj->stdWrap($conf["color3"],$conf["color3."]); 00121 $globalMarkerArray["###GC4###"] = $this->cObj->stdWrap($conf["color4"],$conf["color4."]); 00122 00123 // Substitute Global Marker Array 00124 $this->orig_templateCode= $this->cObj->substituteMarkerArray($this->orig_templateCode, $globalMarkerArray); 00125 00126 00127 // TypoLink. 00128 $this->typolink_conf = $this->conf["typolink."]; 00129 $this->typolink_conf["parameter."]["current"] = 1; 00130 $this->typolink_conf["additionalParams"] = $this->cObj->stdWrap($this->typolink_conf["additionalParams"],$this->typolink_conf["additionalParams."]); 00131 unset($this->typolink_conf["additionalParams."]); 00132 00133 00134 00135 // ************************************* 00136 // *** doing the things...: 00137 // ************************************* 00138 00139 $this->enableFields = $this->cObj->enableFields("tt_board"); 00140 $this->dontParseContent = $this->conf["dontParseContent"]; 00141 00142 $this->local_cObj =t3lib_div::makeInstance("tslib_cObj"); // Local cObj. 00143 00144 $codes=t3lib_div::trimExplode(",", $this->config["code"]?$this->config["code"]:$this->conf["defaultCode"],1); 00145 if (!count($codes)) $codes=array(""); 00146 while(list(,$theCode)=each($codes)) { 00147 $theCode = (string)strtoupper(trim($theCode)); 00148 switch($theCode) { 00149 case "LIST_CATEGORIES": 00150 case "LIST_FORUMS": 00151 $content.= $this->forum_list($theCode); 00152 break; 00153 case "POSTFORM": 00154 case "POSTFORM_REPLY": 00155 case "POSTFORM_THREAD": 00156 $content.= $this->forum_postform($theCode); 00157 break; 00158 case "FORUM": 00159 case "THREAD_TREE": 00160 $content.= $this->forum_forum($theCode); 00161 break; 00162 default: 00163 $langKey = strtoupper($GLOBALS["TSFE"]->config["config"]["language"]); 00164 $helpTemplate = $this->cObj->fileResource("EXT:tt_board/pi/board_help.tmpl"); 00165 00166 // Get language version 00167 $helpTemplate_lang=""; 00168 if ($langKey) {$helpTemplate_lang = $this->cObj->getSubpart($helpTemplate,"###TEMPLATE_".$langKey."###");} 00169 $helpTemplate = $helpTemplate_lang ? $helpTemplate_lang : $this->cObj->getSubpart($helpTemplate,"###TEMPLATE_DEFAULT###"); 00170 00171 // Markers and substitution: 00172 $markerArray["###CODE###"] = $theCode; 00173 $content.=$this->cObj->substituteMarkerArray($helpTemplate,$markerArray); 00174 break; 00175 } // Switch 00176 } 00177 return $content; 00178 } 00179 00183 function forum_list($theCode) { 00184 if (!$this->tt_board_uid) { 00185 $forumlist=0; // set to true if this is a list of forums and not categories + forums 00186 if ($theCode=="LIST_CATEGORIES") { 00187 // Config if categories are listed. 00188 $lConf= $this->conf["list_categories."]; 00189 } else { 00190 $forumlist=1; 00191 // Config if forums are listed. 00192 $lConf= $this->conf["list_forums."]; 00193 $lConf["noForums"] = 0; 00194 } 00195 $GLOBALS["TSFE"]->set_cache_timeout_default($lConf["cache_timeout"] ? intval($lConf["cache_timeout"]) : 60*5); 00196 $templateCode = $this->local_cObj->getSubpart($this->orig_templateCode, "###TEMPLATE_OVERVIEW###"); 00197 00198 if ($templateCode) { 00199 // Getting the specific parts of the template 00200 $categoryHeader=$this->getLayouts($templateCode,$this->alternativeLayouts,"CATEGORY"); 00201 $forumHeader=$this->getLayouts($templateCode,$this->alternativeLayouts,"FORUM"); 00202 $postHeader=$this->getLayouts($templateCode,$this->alternativeLayouts,"POST"); 00203 $subpartContent=""; 00204 00205 // Getting categories 00206 $categories = $this->getPagesInPage($this->config["pid_list"]); 00207 reset($categories); 00208 $c_cat=0; 00209 while(list(,$catData)=each($categories)) { 00210 // Getting forums in category 00211 if ($forumlist) { 00212 $forums = $categories; 00213 } else { 00214 $forums = $this->getPagesInPage($catData["uid"]); 00215 } 00216 if (!$forumlist && count($categoryHeader)) { 00217 // Rendering category 00218 $out=$categoryHeader[$c_cat%count($categoryHeader)]; 00219 $c_cat++; 00220 00221 00222 $this->local_cObj->start($catData); 00223 00224 // Clear 00225 $markerArray=array(); 00226 $wrappedSubpartContentArray=array(); 00227 00228 // Markers 00229 $markerArray["###CATEGORY_TITLE###"]=$this->local_cObj->stdWrap($this->formatStr($catData["title"]), $lConf["title_stdWrap."]); 00230 $markerArray["###CATEGORY_DESCRIPTION###"]=$this->local_cObj->stdWrap($this->formatStr($catData["subtitle"]), $lConf["subtitle_stdWrap."]); 00231 $markerArray["###CATEGORY_FORUMNUMBER###"]=$this->local_cObj->stdWrap(count($forums), $lConf["count_stdWrap."]); 00232 00233 // Link to the category (wrap) 00234 $this->local_cObj->setCurrentVal($catData["uid"]); 00235 $wrappedSubpartContentArray["###LINK###"]=$this->local_cObj->typolinkWrap($this->typolink_conf); 00236 00237 // Substitute 00238 $subpartContent.=$this->local_cObj->substituteMarkerArrayCached($out,$markerArray,array(),$wrappedSubpartContentArray); 00239 } 00240 if (count($forumHeader) && !$lConf["noForums"]) { 00241 // Rendering forums 00242 reset($forums); 00243 $c_forum=0; 00244 while(list(,$forumData)=each($forums)) { 00245 $out=$forumHeader[$c_forum%count($forumHeader)]; 00246 $c_forum++; 00247 00248 $this->local_cObj->start($forumData); 00249 00250 // Clear 00251 $markerArray=array(); 00252 $wrappedSubpartContentArray=array(); 00253 00254 // Markers 00255 $markerArray["###FORUM_TITLE###"]=$this->local_cObj->stdWrap($this->formatStr($forumData["title"]), $lConf["forum_title_stdWrap."]); 00256 $markerArray["###FORUM_DESCRIPTION###"]=$this->local_cObj->stdWrap($this->formatStr($forumData["subtitle"]), $lConf["forum_description_stdWrap."]); 00257 $markerArray["###FORUM_POSTS###"]=$this->local_cObj->stdWrap($this->getNumPosts($forumData["uid"]), $lConf["forum_posts_stdWrap."]); 00258 $markerArray["###FORUM_THREADS###"]=$this->local_cObj->stdWrap($this->getNumThreads($forumData["uid"]), $lConf["forum_threads_stdWrap."]); 00259 00260 // Link to the forum (wrap) 00261 $this->local_cObj->setCurrentVal($forumData["uid"]); 00262 $wrappedSubpartContentArray["###LINK###"]=$this->local_cObj->typolinkWrap($this->typolink_conf); 00263 00264 00265 // LAST POST: 00266 $lastPostInfo = $this->getLastPost($forumData["uid"]); 00267 $this->local_cObj->start($lastPostInfo); 00268 if ($lastPostInfo) { 00269 $markerArray["###LAST_POST_AUTHOR###"] = $this->local_cObj->stdWrap($this->formatStr($lastPostInfo["author"]), $lConf["last_post_author_stdWrap."]); 00270 $markerArray["###LAST_POST_DATE###"] = $this->local_cObj->stdWrap($this->recentDate($lastPostInfo),$this->conf["date_stdWrap."]); 00271 $markerArray["###LAST_POST_TIME###"] = $this->local_cObj->stdWrap($this->recentDate($lastPostInfo),$this->conf["time_stdWrap."]); 00272 $markerArray["###LAST_POST_AGE###"] = $this->local_cObj->stdWrap($this->recentDate($lastPostInfo),$this->conf["age_stdWrap."]); 00273 } else { 00274 $markerArray["###LAST_POST_AUTHOR###"] = ""; 00275 $markerArray["###LAST_POST_DATE###"] = ""; 00276 $markerArray["###LAST_POST_TIME###"] = ""; 00277 $markerArray["###LAST_POST_AGE###"] = ""; 00278 } 00279 00280 // Link to the last post 00281 $this->local_cObj->setCurrentVal($lastPostInfo["pid"]); 00282 $temp_conf=$this->typolink_conf; 00283 $temp_conf["additionalParams"].= "&tt_board_uid=".$lastPostInfo["uid"]; 00284 $temp_conf["useCacheHash"]=$this->allowCaching; 00285 $temp_conf["no_cache"]=!$this->allowCaching; 00286 $wrappedSubpartContentArray["###LINK_LAST_POST###"]=$this->local_cObj->typolinkWrap($temp_conf); 00287 00288 // Add result 00289 $subpartContent.=$this->local_cObj->substituteMarkerArrayCached($out,$markerArray,array(),$wrappedSubpartContentArray); 00290 00291 // Rendering the most recent posts 00292 if (count($postHeader) && $lConf["numberOfRecentPosts"]) { 00293 $recentPosts = $this->getMostRecentPosts($forumData["uid"],intval($lConf["numberOfRecentPosts"])); 00294 reset($recentPosts); 00295 $c_post=0; 00296 while(list(,$recentPost)=each($recentPosts)) { 00297 $out=$postHeader[$c_post%count($postHeader)]; 00298 $c_post++; 00299 $this->local_cObj->start($recentPost); 00300 00301 // Clear: 00302 $markerArray=array(); 00303 $wrappedSubpartContentArray=array(); 00304 00305 // markers: 00306 $markerArray["###POST_TITLE###"] = $this->local_cObj->stdWrap($this->formatStr($recentPost["subject"]), $lConf["post_title_stdWrap."]); 00307 $markerArray["###POST_CONTENT###"] = $this->substituteEmoticons($this->local_cObj->stdWrap($this->formatStr($recentPost["message"]), $lConf["post_content_stdWrap."])); 00308 $markerArray["###POST_REPLIES###"] = $this->local_cObj->stdWrap($this->getNumReplies($recentPost["pid"],$recentPost["uid"]), $lConf["post_replies_stdWrap."]); 00309 $markerArray["###POST_AUTHOR###"] = $this->local_cObj->stdWrap($this->formatStr($recentPost["author"]), $lConf["post_author_stdWrap."]); 00310 $markerArray["###POST_DATE###"] = $this->local_cObj->stdWrap($this->recentDate($recentPost),$this->conf["date_stdWrap."]); 00311 $markerArray["###POST_TIME###"] = $this->local_cObj->stdWrap($this->recentDate($recentPost),$this->conf["time_stdWrap."]); 00312 $markerArray["###POST_AGE###"] = $this->local_cObj->stdWrap($this->recentDate($recentPost),$this->conf["age_stdWrap."]); 00313 00314 // Link to the post: 00315 $this->local_cObj->setCurrentVal($recentPost["pid"]); 00316 $temp_conf=$this->typolink_conf; 00317 $temp_conf["additionalParams"].= "&tt_board_uid=".$recentPost["uid"]; 00318 $temp_conf["useCacheHash"]=$this->allowCaching; 00319 $temp_conf["no_cache"]=!$this->allowCaching; 00320 $wrappedSubpartContentArray["###LINK###"]=$this->local_cObj->typolinkWrap($temp_conf); 00321 $subpartContent.=$this->local_cObj->substituteMarkerArrayCached($out,$markerArray,array(),$wrappedSubpartContentArray); 00322 // add result 00323 #$subpartContent.=$out; // 250902 00324 } 00325 } 00326 } 00327 } 00328 if ($forumlist) { 00329 break; 00330 } 00331 } 00332 // Substitution: 00333 $content.= $this->local_cObj->substituteSubpart($templateCode,"###CONTENT###",$subpartContent) ; 00334 } else { 00335 $content = $this->outMessage("No template code for ###TEMPLATE_OVERVIEW###"); 00336 } 00337 } 00338 return $content; 00339 } 00340 00344 function forum_postform($theCode) { 00345 $parent=0; // This is the parent item for the form. If this ends up being is set, then the form is a reply and not a new post. 00346 $nofity=array(); 00347 // Find parent, if any 00348 if ($this->tt_board_uid) { 00349 if ($this->conf["tree"]) { 00350 $parent=$this->tt_board_uid; 00351 } else { 00352 $parentR = $this->getRootParent($this->tt_board_uid); 00353 $parent = $parentR["uid"]; 00354 } 00355 00356 $rootParent = $this->getRootParent($parent); 00357 $wholeThread = $this->getSingleThread($rootParent["uid"],1); 00358 reset($wholeThread); 00359 while(list(,$recordP)=each($wholeThread)) { 00360 if ($recordP["notify_me"] && $recordP["email"]) { 00361 $notify[md5(trim(strtolower($recordP["email"])))] = trim($recordP["email"]); 00362 } 00363 } 00364 } 00365 00366 // Get the render-code 00367 $lConf = $this->conf["postform."]; 00368 $modEmail = $this->conf["moderatorEmail"]; 00369 if (!$parent && isset($this->conf["postform_newThread."])) { 00370 $lConf = $this->conf["postform_newThread."] ? $this->conf["postform_newThread."] : $lConf; // Special form for newThread posts... 00371 $modEmail = $this->conf["moderatorEmail_newThread"] ? $this->conf["moderatorEmail_newThread"] : $modEmail; 00372 } 00373 if ($modEmail) { 00374 $modEmail = explode(",", $modEmail); 00375 while(list(,$modEmail_s)=each($modEmail)) { 00376 $notify[md5(trim(strtolower($modEmail_s)))] = trim($modEmail_s); 00377 } 00378 } 00379 //debug($notify); 00380 if ($theCode=="POSTFORM" || ($theCode=="POSTFORM_REPLY" && $parent) || ($theCode=="POSTFORM_THREAD" && !$parent)) { 00381 $lConf["dataArray."]["9999."] = array( 00382 "type" => "*data[tt_board][NEW][parent]=hidden", 00383 "value" => $parent 00384 ); 00385 $lConf["dataArray."]["9998."] = array( 00386 "type" => "*data[tt_board][NEW][pid]=hidden", 00387 "value" => $this->pid 00388 ); 00389 $lConf["dataArray."]["9997."] = array( 00390 "type" => "tt_board_uid=hidden", 00391 "value" => $parent 00392 ); 00393 if (count($notify)) { 00394 $lConf["dataArray."]["9997."] = array( 00395 "type" => "notify_me=hidden", 00396 "value" => htmlspecialchars(implode($notify,",")) 00397 ); 00398 } 00399 // debug($lConf); 00400 $content.=$this->local_cObj->FORM($lConf); 00401 } 00402 return $content; 00403 } 00404 00408 function forum_forum($theCode) { 00409 if ($this->conf["iconCode"]) { 00410 $this->treeIcons["joinBottom"] = $this->local_cObj->stdWrap($this->conf["iconCode."]["joinBottom"],$this->conf["iconCode."]["joinBottom."]); 00411 $this->treeIcons["join"] = $this->local_cObj->stdWrap($this->conf["iconCode."]["join"],$this->conf["iconCode."]["join."]); 00412 $this->treeIcons["line"] = $this->local_cObj->stdWrap($this->conf["iconCode."]["line"],$this->conf["iconCode."]["line."]); 00413 $this->treeIcons["blank"] = $this->local_cObj->stdWrap($this->conf["iconCode."]["blank"],$this->conf["iconCode."]["blank."]); 00414 $this->treeIcons["thread"] = $this->local_cObj->stdWrap($this->conf["iconCode."]["thread"],$this->conf["iconCode."]["thread."]); 00415 $this->treeIcons["end"] = $this->local_cObj->stdWrap($this->conf["iconCode."]["end"],$this->conf["iconCode."]["end."]); 00416 } 00417 00418 if ($this->tt_board_uid && $theCode!="THREAD_TREE") { 00419 if (!$this->allowCaching) $GLOBALS["TSFE"]->set_no_cache(); // MUST set no_cache as this displays single items and not a whole page.... 00420 $lConf= $this->conf["view_thread."]; 00421 $templateCode = $this->local_cObj->getSubpart($this->orig_templateCode, "###TEMPLATE_THREAD###"); 00422 00423 if ($templateCode) { 00424 $rootParent = $this->getRootParent($this->tt_board_uid); 00425 $wholeThread = $this->getSingleThread($rootParent["uid"],1); 00426 00427 if ($lConf["single"]) { 00428 reset($wholeThread); 00429 while(list(,$recentP)=each($wholeThread)) { 00430 if ($recentP["uid"]==$this->tt_board_uid) { 00431 $recentPosts[]=$recentP; 00432 break; 00433 } 00434 } 00435 } else { 00436 $recentPosts = $wholeThread; 00437 } 00438 $nextThread = $this->getThreadRoot($this->config["pid_list"],$rootParent); 00439 $prevThread = $this->getThreadRoot($this->config["pid_list"],$rootParent,"prev"); 00440 00441 $subpartContent=""; 00442 00443 // Clear 00444 $markerArray=array(); 00445 $wrappedSubpartContentArray=array(); 00446 00447 00448 // Getting the specific parts of the template 00449 $markerArray["###FORUM_TITLE###"] = $this->local_cObj->stdWrap($GLOBALS["TSFE"]->page["title"],$lConf["forum_title_stdWrap."]); 00450 00451 // Link back to forum 00452 $this->local_cObj->setCurrentVal($this->pid); 00453 $wrappedSubpartContentArray["###LINK_BACK_TO_FORUM###"]=$this->local_cObj->typolinkWrap($this->typolink_conf); 00454 00455 // Link to next thread 00456 $this->local_cObj->setCurrentVal($this->pid); 00457 $temp_conf=$this->typolink_conf; 00458 if (is_array($nextThread)) { 00459 $temp_conf["additionalParams"].= "&tt_board_uid=".$nextThread["uid"]; 00460 $temp_conf["useCacheHash"]=$this->allowCaching; 00461 $temp_conf["no_cache"]=!$this->allowCaching; 00462 } 00463 $wrappedSubpartContentArray["###LINK_NEXT_THREAD###"]=$this->local_cObj->typolinkWrap($temp_conf); 00464 00465 // Link to prev thread 00466 $this->local_cObj->setCurrentVal($this->pid); 00467 $temp_conf=$this->typolink_conf; 00468 if (is_array($prevThread)) { 00469 $temp_conf["additionalParams"].= "&tt_board_uid=".$prevThread["uid"]; 00470 $temp_conf["useCacheHash"]=$this->allowCaching; 00471 $temp_conf["no_cache"]=!$this->allowCaching; 00472 } 00473 $wrappedSubpartContentArray["###LINK_PREV_THREAD###"]=$this->local_cObj->typolinkWrap($temp_conf); 00474 00475 // Link to first !! 00476 $this->local_cObj->setCurrentVal($this->pid); 00477 $temp_conf=$this->typolink_conf; 00478 $temp_conf["additionalParams"].= "&tt_board_uid=".$rootParent["uid"]; 00479 $temp_conf["useCacheHash"]=$this->allowCaching; 00480 $temp_conf["no_cache"]=!$this->allowCaching; 00481 $wrappedSubpartContentArray["###LINK_FIRST_POST###"]=$this->local_cObj->typolinkWrap($temp_conf); 00482 00483 // Substitute: 00484 $templateCode=$this->local_cObj->substituteMarkerArrayCached($templateCode,$markerArray,array(),$wrappedSubpartContentArray); 00485 00486 // Getting subpart for items: 00487 $postHeader=$this->getLayouts($templateCode,$this->alternativeLayouts,"POST"); 00488 00489 reset($recentPosts); 00490 $c_post=0; 00491 $indexedTitle=""; 00492 while(list(,$recentPost)=each($recentPosts)) { 00493 $out=$postHeader[$c_post%count($postHeader)]; 00494 $c_post++; 00495 if (!$indexedTitle && trim($recentPost["subject"])) $indexedTitle=trim($recentPost["subject"]); 00496 00497 // Clear 00498 $markerArray=array(); 00499 $wrappedSubpartContentArray=array(); 00500 00501 $this->local_cObj->start($recentPost); 00502 00503 // Markers 00504 $markerArray["###POST_THREAD_CODE###"] = $this->local_cObj->stdWrap($recentPost["treeIcons"], $lConf["post_thread_code_stdWrap."]); 00505 $markerArray["###POST_TITLE###"] = $this->local_cObj->stdWrap($this->formatStr($recentPost["subject"]), $lConf["post_title_stdWrap."]); 00506 $markerArray["###POST_CONTENT###"] = $this->substituteEmoticons($this->local_cObj->stdWrap($this->formatStr($recentPost["message"]), $lConf["post_content_stdWrap."])); 00507 $markerArray["###POST_REPLIES###"] = $this->local_cObj->stdWrap($this->getNumReplies($recentPost["pid"],$recentPost["uid"]), $lConf["post_replies_stdWrap."]); 00508 $markerArray["###POST_AUTHOR###"] = $this->local_cObj->stdWrap($this->formatStr($recentPost["author"]), $lConf["post_author_stdWrap."]); 00509 $markerArray["###POST_AUTHOR_EMAIL###"] = $recentPost["email"]; 00510 $markerArray["###POST_DATE###"] = $this->local_cObj->stdWrap($this->recentDate($recentPost),$this->conf["date_stdWrap."]); 00511 $markerArray["###POST_TIME###"] = $this->local_cObj->stdWrap($this->recentDate($recentPost),$this->conf["time_stdWrap."]); 00512 $markerArray["###POST_AGE###"] = $this->local_cObj->stdWrap($this->recentDate($recentPost),$this->conf["age_stdWrap."]); 00513 00514 // Link to the post 00515 $this->local_cObj->setCurrentVal($recentPost["pid"]); 00516 $temp_conf=$this->typolink_conf; 00517 $temp_conf["additionalParams"].= "&tt_board_uid=".$recentPost["uid"]; 00518 $temp_conf["useCacheHash"]=$this->allowCaching; 00519 $temp_conf["no_cache"]=!$this->allowCaching; 00520 $wrappedSubpartContentArray["###LINK###"]=$this->local_cObj->typolinkWrap($temp_conf); 00521 00522 // Link to next thread 00523 $this->local_cObj->setCurrentVal($recentPost["pid"]); 00524 $temp_conf=$this->typolink_conf; 00525 $temp_conf["additionalParams"].= "&tt_board_uid=".($recentPost["nextUid"]?$recentPost["nextUid"]:$nextThread["uid"]); 00526 $temp_conf["useCacheHash"]=$this->allowCaching; 00527 $temp_conf["no_cache"]=!$this->allowCaching; 00528 $wrappedSubpartContentArray["###LINK_NEXT_POST###"]=$this->local_cObj->typolinkWrap($temp_conf); 00529 00530 // Link to prev thread 00531 $this->local_cObj->setCurrentVal($recentPost["pid"]); 00532 $temp_conf=$this->typolink_conf; 00533 $temp_conf["additionalParams"].= "&tt_board_uid=".($recentPost["prevUid"]?$recentPost["prevUid"]:$prevThread["uid"]); 00534 $temp_conf["useCacheHash"]=$this->allowCaching; 00535 $temp_conf["no_cache"]=!$this->allowCaching; 00536 $wrappedSubpartContentArray["###LINK_PREV_POST###"]=$this->local_cObj->typolinkWrap($temp_conf); 00537 00538 // Substitute: 00539 $subpartContent.=$this->local_cObj->substituteMarkerArrayCached($out,$markerArray,array(),$wrappedSubpartContentArray); 00540 } 00541 $GLOBALS["TSFE"]->indexedDocTitle = $indexedTitle; 00542 // Substitution: 00543 $content.= $this->local_cObj->substituteSubpart($templateCode,"###CONTENT###",$subpartContent); 00544 } else { 00545 debug("No template code for "); 00546 } 00547 } else { 00548 $continue = true; 00549 if ($theCode=="THREAD_TREE") { 00550 if (!$this->tt_board_uid) {$continue = false;} 00551 $lConf= $this->conf["thread_tree."]; 00552 } else { 00553 $lConf= $this->conf["list_threads."]; 00554 } 00555 if($continue){ 00556 $templateCode = $this->local_cObj->getSubpart($this->orig_templateCode, "###TEMPLATE_FORUM###"); 00557 00558 if ($templateCode) { 00559 // Getting the specific parts of the template 00560 $templateCode = $this->local_cObj->substituteMarker($templateCode,"###FORUM_TITLE###",$this->local_cObj->stdWrap($GLOBALS["TSFE"]->page["title"],$lConf["forum_title_stdWrap."])); 00561 $postHeader=$this->getLayouts($templateCode,$this->alternativeLayouts,"POST"); 00562 // Template code used if tt_board_uid matches... 00563 $postHeader_active = $this->getLayouts($templateCode,1,"POST_ACTIVE"); 00564 00565 $subpartContent=""; 00566 00567 if ($theCode=="THREAD_TREE") { 00568 $rootParent = $this->getRootParent($this->tt_board_uid); 00569 $recentPosts = $this->getSingleThread($rootParent["uid"],1); 00570 } else { 00571 $recentPosts = $this->getThreads($this->config["pid_list"],$this->conf["tree"], $lConf["thread_limit"]?$lConf["thread_limit"]:"50", t3lib_div::_GP("tt_board_sword")); 00572 } 00573 reset($recentPosts); 00574 $c_post=0; 00575 while(list(,$recentPost)=each($recentPosts)) { 00576 $GLOBALS["TT"]->push("/Post/"); 00577 $out=$postHeader[$c_post%count($postHeader)]; 00578 if ($recentPost["uid"]==$this->tt_board_uid && $postHeader_active[0]) { 00579 $out = $postHeader_active[0]; 00580 } 00581 $c_post++; 00582 00583 $this->local_cObj->start($recentPost); 00584 00585 // Clear 00586 $markerArray=array(); 00587 $wrappedSubpartContentArray=array(); 00588 00589 // Markers 00590 $GLOBALS["TT"]->push("/postMarkers/"); 00591 $markerArray["###POST_THREAD_CODE###"] = $this->local_cObj->stdWrap($recentPost["treeIcons"], $lConf["post_thread_code_stdWrap."]); 00592 $markerArray["###POST_TITLE###"] = $this->local_cObj->stdWrap($this->formatStr($recentPost["subject"]), $lConf["post_title_stdWrap."]); 00593 $markerArray["###POST_CONTENT###"] = $this->substituteEmoticons($this->local_cObj->stdWrap($this->formatStr($recentPost["message"]), $lConf["post_content_stdWrap."])); 00594 $markerArray["###POST_REPLIES###"] = $this->local_cObj->stdWrap($this->getNumReplies($recentPost["pid"],$recentPost["uid"]), $lConf["post_replies_stdWrap."]); 00595 $markerArray["###POST_AUTHOR###"] = $this->local_cObj->stdWrap($this->formatStr($recentPost["author"]), $lConf["post_author_stdWrap."]); 00596 $markerArray["###POST_DATE###"] = $this->local_cObj->stdWrap($this->recentDate($recentPost),$this->conf["date_stdWrap."]); 00597 $markerArray["###POST_TIME###"] = $this->local_cObj->stdWrap($this->recentDate($recentPost),$this->conf["time_stdWrap."]); 00598 $markerArray["###POST_AGE###"] = $this->local_cObj->stdWrap($this->recentDate($recentPost),$this->conf["age_stdWrap."]); 00599 00600 // Link to the post 00601 $this->local_cObj->setCurrentVal($recentPost["pid"]); 00602 $temp_conf=$this->typolink_conf; 00603 $temp_conf["additionalParams"].= "&tt_board_uid=".$recentPost["uid"]; 00604 $temp_conf["useCacheHash"]=$this->allowCaching; 00605 $temp_conf["no_cache"]=!$this->allowCaching; 00606 $wrappedSubpartContentArray["###LINK###"]=$this->local_cObj->typolinkWrap($temp_conf); 00607 $GLOBALS["TT"]->pull(); 00608 00609 // Last post processing: 00610 $GLOBALS["TT"]->push("/last post info/"); 00611 $lastPostInfo = $this->getLastPostInThread($recentPost["pid"],$recentPost["uid"]); 00612 $GLOBALS["TT"]->pull(); 00613 if (!$lastPostInfo) $lastPostInfo=$recentPost; 00614 00615 $this->local_cObj->start($lastPostInfo); 00616 00617 $GLOBALS["TT"]->push("/lastPostMarkers/"); 00618 $markerArray["###LAST_POST_DATE###"]=$this->local_cObj->stdWrap($this->recentDate($lastPostInfo),$this->conf["date_stdWrap."]); 00619 $markerArray["###LAST_POST_TIME###"]=$this->local_cObj->stdWrap($this->recentDate($lastPostInfo),$this->conf["time_stdWrap."]); 00620 $markerArray["###LAST_POST_AGE###"]=$this->local_cObj->stdWrap($this->recentDate($lastPostInfo),$this->conf["age_stdWrap."]); 00621 $markerArray["###LAST_POST_AUTHOR###"]=$this->local_cObj->stdWrap($this->formatStr($lastPostInfo["author"]), $lConf["last_post_author_stdWrap."]); 00622 00623 // Link to the last post 00624 $this->local_cObj->setCurrentVal($lastPostInfo["pid"]); 00625 $temp_conf=$this->typolink_conf; 00626 $temp_conf["additionalParams"].= "&tt_board_uid=".$lastPostInfo["uid"]; 00627 $temp_conf["useCacheHash"]=$this->allowCaching; 00628 $temp_conf["no_cache"]=!$this->allowCaching; 00629 $wrappedSubpartContentArray["###LINK_LAST_POST###"]=$this->local_cObj->typolinkWrap($temp_conf); 00630 $GLOBALS["TT"]->pull(); 00631 00632 // Substitute: 00633 $subpartContent.=$this->local_cObj->substituteMarkerArrayCached($out,$markerArray,array(),$wrappedSubpartContentArray); 00634 $GLOBALS["TT"]->pull(); 00635 } 00636 // Substitution: 00637 $markerArray=array(); 00638 $subpartContentArray=array(); 00639 // Fill in array 00640 $markerArray["###SEARCH_WORD###"]=$GLOBALS["TSFE"]->no_cache ? t3lib_div::_GP("tt_board_sword") : ""; // Setting search words in field if cache is disabled. 00641 // Set FORM_URL 00642 $this->local_cObj->setCurrentVal($GLOBALS["TSFE"]->id); 00643 $temp_conf=$this->typolink_conf; 00644 $temp_conf["no_cache"]=1; 00645 $markerArray["###FORM_URL###"]=$this->local_cObj->typoLink_URL($temp_conf); 00646 00647 // Substitute CONTENT-subpart 00648 $subpartContentArray["###CONTENT###"]=$subpartContent; 00649 $content.= $this->local_cObj->substituteMarkerArrayCached($templateCode,$markerArray,$subpartContentArray); 00650 } else { 00651 debug("No template code for "); 00652 } 00653 } 00654 } 00655 return $content; 00656 } 00657 00661 function getRecordTree($theRows,$parent,$pid,$treeIcons="") { 00662 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_board', 'pid='.intval($pid).' AND parent='.intval($parent).$this->enableFields, '', $this->orderBy()); 00663 $c = 0; 00664 $rc = $GLOBALS['TYPO3_DB']->sql_num_rows($res); 00665 00666 $theRows[count($theRows)-1]["treeIcons"].= $rc ? $this->treeIcons["thread"] : $this->treeIcons["end"]; 00667 00668 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00669 $c++; 00670 $row["treeIcons"] = $treeIcons.($rc==$c ? $this->treeIcons["joinBottom"] : $this->treeIcons["join"]); 00671 // prev/next item: 00672 $theRows[count($theRows)-1]["nextUid"] = $row["uid"]; 00673 $row["prevUid"] = $theRows[count($theRows)-1]["uid"]; 00674 00675 $theRows[] = $row; 00676 // get the branch 00677 $theRows = $this->getRecordTree($theRows,$row["uid"],$row["pid"],$treeIcons.($rc==$c ? $this->treeIcons["blank"] : $this->treeIcons["line"])); 00678 } 00679 return $theRows; 00680 } 00681 00688 function getPagesInPage($pid_list) { 00689 $thePids = t3lib_div::intExplode(",",$pid_list); 00690 $theMenu = array(); 00691 while(list(,$p_uid)=each($thePids)) { 00692 $theMenu = array_merge($theMenu, $GLOBALS["TSFE"]->sys_page->getMenu($p_uid)); 00693 } 00694 // Exclude pages not of doktype "Standard" or "Advanced" 00695 reset($theMenu); 00696 while(list($key,$data)=each($theMenu)) { 00697 if (!t3lib_div::inList($GLOBALS["TYPO3_CONF_VARS"]["FE"]["content_doktypes"],$data["doktype"])) {unset($theMenu[$key]);} // All pages including pages 'not in menu' 00698 } 00699 return $theMenu; 00700 } 00701 00705 function getNumPosts($pid) { 00706 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'tt_board', 'pid IN ('.$pid.')'.$this->enableFields); 00707 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res); 00708 return $row[0]; 00709 } 00710 00714 function getNumThreads($pid) { 00715 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'tt_board', 'pid IN ('.$pid.') AND parent=0'.$this->enableFields); 00716 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res); 00717 return $row[0]; 00718 } 00719 00723 function getNumReplies($pid,$uid) { 00724 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'tt_board', 'pid IN ('.$pid.') AND parent='.intval($uid).$this->enableFields); 00725 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res); 00726 return $row[0]; 00727 } 00728 00732 function getLastPost($pid) { 00733 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_board', 'pid IN ('.$pid.')'.$this->enableFields, '', $this->orderBy('DESC'), '1'); 00734 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); 00735 return $row; 00736 } 00737 00741 function getLastPostInThread($pid,$uid) { 00742 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_board', 'pid IN ('.$pid.') AND parent='.$uid.$this->enableFields, '', $this->orderBy('DESC'), '1'); 00743 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); 00744 return $row; 00745 } 00746 00752 function getMostRecentPosts($pid,$number) { 00753 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_board', 'pid IN ('.$pid.')'.$this->enableFields, '', $this->orderBy('DESC'), $number); 00754 $out = array(); 00755 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00756 $out[] = $row; 00757 } 00758 return $out; 00759 } 00760 00764 function getThreads($pid,$decend=0,$limit=100,$searchWord) { 00765 $out=array(); 00766 if ($searchWord) { 00767 $where = $this->cObj->searchWhere($searchWord, $this->searchFieldList, 'tt_board'); 00768 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_board', 'pid IN ('.$pid.') '.$where.$this->enableFields, '', $this->orderBy('DESC'), intval($limit)); 00769 $set = array(); 00770 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00771 $rootRow = $this->getRootParent($row["uid"]); 00772 if (is_array($rootRow) && !isset($set[$rootRow["uid"]])) { 00773 $set[$rootRow["uid"]] = 1; 00774 $out[] = $rootRow; 00775 if ($decend) { 00776 $out = $this->getRecordTree($out,$rootRow["uid"],$rootRow["pid"]); 00777 } 00778 } 00779 } 00780 } else { 00781 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_board', 'pid IN ('.$pid.') AND parent=0'.$this->enableFields, '', $this->orderBy('DESC'), intval($limit)); 00782 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00783 $out[] = $row; 00784 if ($decend) { 00785 $out = $this->getRecordTree($out,$row["uid"],$row["pid"]); 00786 } 00787 } 00788 } 00789 return $out; 00790 } 00791 00795 function getSingleThread($uid,$decend=0) { 00796 $hash = md5($uid."|".$decend); 00797 if ($this->cache_thread[$hash]) {return $this->cache_thread[$hash]; debug("!");} 00798 00799 $out=array(); 00800 if ($uid) { 00801 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_board', 'uid='.$uid.$this->enableFields); 00802 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00803 $out[] = $row; 00804 if ($decend) { 00805 $out = $this->getRecordTree($out,$row["uid"],$row["pid"]); 00806 } 00807 } 00808 } 00809 return $out; 00810 } 00811 00815 function getRootParent($uid,$limit=20) { 00816 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_board', 'uid='.$uid.$this->enableFields); 00817 if($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00818 if ($limit>0) { 00819 if ($row["parent"]) { 00820 return $this->getRootParent($row["parent"],$limit-1); 00821 } else { 00822 return $row; 00823 } 00824 } 00825 } 00826 } 00827 00831 function getThreadRoot($pid,$rootParent,$type="next") { 00832 $datePart = ' AND crdate'.($type!='next'?'>':'<').intval($rootParent['crdate']); 00833 00834 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_board', 'pid IN ('.$pid.') AND parent=0'.$datePart.$this->enableFields, '', $this->orderBy($type!='next'?'':'DESC')); 00835 return $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); 00836 } 00837 00841 function formatStr($str) { 00842 if (!$this->dontParseContent) { 00843 return nl2br(htmlspecialchars($str)); 00844 } else { 00845 return $str; 00846 } 00847 } 00848 00852 function substituteEmoticons($str) { 00853 if ($this->emoticons) { 00854 reset($this->emoticonsSubst); 00855 while(list($source,$dest)=each($this->emoticonsSubst)) { 00856 $str = str_replace($source, str_replace("{}", $this->emoticonsPath.$dest, $this->emoticonsTag), $str); 00857 } 00858 } 00859 return $str; 00860 } 00861 00865 function getLayouts($templateCode,$alternativeLayouts,$marker) { 00866 $out=array(); 00867 for($a=0;$a<$alternativeLayouts;$a++) { 00868 $m= "###".$marker.($a?"_".$a:"")."###"; 00869 if(strstr($templateCode,$m)) { 00870 $out[]=$GLOBALS["TSFE"]->cObj->getSubpart($templateCode, $m); 00871 } else { 00872 break; 00873 } 00874 } 00875 return $out; 00876 } 00877 00881 function outMessage($string,$content="") { 00882 $msg= ' 00883 <HR> 00884 <h3>'.$string.'</h3> 00885 '.$content.' 00886 <HR> 00887 '; 00888 00889 return $msg; 00890 } 00891 00895 function orderBy($desc="") { 00896 return 'crdate '.$desc; 00897 } 00898 00902 function recentDate($rec) { 00903 return $rec["crdate"]; 00904 } 00905 } 00906 00907 00908 00909 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/tt_board/pi/class.tx_ttboard.php"]) { 00910 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/tt_board/pi/class.tx_ttboard.php"]); 00911 } 00912 00913 ?>