* @co-author Robert Lemke */ require_once (PATH_t3lib."class.t3lib_page.php"); require_once (PATH_t3lib."class.t3lib_tstemplate.php"); require_once (PATH_t3lib."class.t3lib_tsparser_ext.php"); class tx_rlmptmplselector_addfilestosel { var $dir = "templatePathMain"; var $branch = 'main.'; /** * Manipulating the input array, $params, adding new selectorbox items. */ function main(&$params,&$pObj) { // GETTING configuration from the object tree (thanks to Ingmar Schlecht!) if(isset($params["row"]["t3ver_oid"])) { if((intval($params["row"]["uid"]) != intval($params["row"]["t3ver_oid"])) && (intval($params["row"]["t3ver_oid"]) != 0)) $thePageId = $params["row"]["t3ver_oid"]; // offline versioned page else $thePageId = $params["row"]["uid"]; // Non versioned page or online versioned page } else { $thePageId = $params["row"]["uid"]; } $template = t3lib_div::makeInstance("t3lib_tsparser_ext"); // Defined global here! $template->tt_track = 0; // Do not log time-performance information $template->init(); $sys_page = t3lib_div::makeInstance("t3lib_pageSelect"); $rootLine = $sys_page->getRootLine($thePageId); $template->runThroughTemplates($rootLine,$template_uid); // This generates the constants/config + hierarchy info for the template. $template->generateConfig(); // GETTING configuration for the extension: $confArray = unserialize($GLOBALS["TYPO3_CONF_VARS"]["EXT"]["extConf"]["rlmp_tmplselector"]); // Use external HTML template files: if ($confArray['templateMode']=='file') { // Finding value for the path containing the template files $readPath = t3lib_div::getFileAbsFileName($template->setup["plugin."]["tx_rlmptmplselector_pi1."][$this->dir]); // If that direcotry is valid, is a directory then select files in it: if (@is_dir($readPath)) { //getting all HTML files in the directory: $template_files = t3lib_div::getFilesInDir ($readPath,'html,htm',1,1); // Start up the HTML parser: $parseHTML = t3lib_div::makeInstance ('t3lib_parseHTML'); // Traverse that array: foreach ($template_files as $htmlFilePath) { // Reset vars: $selectorBoxItem_title=''; $selectorBoxItem_icon=''; // Reading the content of the template document ... $content = t3lib_div::getUrl ($htmlFilePath); // ... and extracting the content of the title-tags: $parts = $parseHTML->splitIntoBlock('title',$content); $titleTagContent = $parseHTML->removeFirstAndLastTag($parts[1]); // Setting the item label: $selectorBoxItem_title = trim ($titleTagContent.' ('.basename($htmlFilePath).')'); // Trying to look up an image icon for the template $fI = t3lib_div::split_fileref($htmlFilePath); $testImageFilename=$readPath.$fI['filebody'].'.gif'; if (@is_file($testImageFilename)) { $selectorBoxItem_icon = '../'.substr ($testImageFilename,strlen(PATH_site)); } // Finally add the new item: $params["items"][] = Array( $selectorBoxItem_title, basename ($htmlFilePath), $selectorBoxItem_icon ); } } } // Don't use external files - do it the TS way instead if ($confArray['templateMode']=='ts') { // Finding value for the path containing the template files $readPath = t3lib_div::getFileAbsFileName('uploads/tf/'); $tmplObjects = $template->setup["plugin."]["tx_rlmptmplselector_pi1."]["templateObjects."][$this->branch]; // Traverse template objects if (is_array ($tmplObjects)) { reset ($tmplObjects); while ($tmplObject = each ($tmplObjects)) { $k = $tmplObject["key"]; $v = $tmplObject["value"]; if ($v == 'TEMPLATE') { if (is_array ($tmplObjects[$k.'.']['tx_rlmptmplselector.'])) { $selectorBoxItem_title=$tmplObjects[$k.'.']['tx_rlmptmplselector.']['title']; unset ($selectorBoxItem_icon); $fI = t3lib_div::split_fileref(trim ($tmplObjects[$k.'.']['tx_rlmptmplselector.']['imagefile'])); $testImageFilename=$readPath.$fI['filebody'].'.gif'; if (@is_file($testImageFilename)) { $selectorBoxItem_icon = '../'.substr ($testImageFilename,strlen(PATH_site)); } $params["items"][] = Array( $selectorBoxItem_title, $k, $selectorBoxItem_icon ); } } } } } } } class tx_rlmptmplselector_addfilestosel_ca extends tx_rlmptmplselector_addfilestosel { var $dir = "templatePathSub"; var $branch = 'sub.'; } if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/rlmp_tmplselector/class.tx_rlmptmplselector_addfilestosel.php"]) { include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/rlmp_tmplselector/class.tx_rlmptmplselector_addfilestosel.php"]); } ?>