libraries/tbs/plugins/tbs_plugin_opentbs.php
function TbsLoadSubFileAsTemplate($SubFileLst) {

		if (!is_array($SubFileLst)) $SubFileLst = array($SubFileLst);

		$ok = true;
		$TBS = false;

		foreach ($SubFileLst as $SubFile) {

			$idx = $this->FileGetIdx($SubFile);
			if ($idx===false) {
				$ok = $this->RaiseError('Cannot load "'.$SubFile.'". The file is not found in the archive "'.$this->ArchFile.'".');
			} elseif ($idx!==$this->TbsCurrIdx) {
				// Save the current loaded subfile if any
				$this->TbsStorePark();
				// Load the subfile
				if (!is_string($SubFile)) $SubFile = $this->TbsGetFileName($idx);
				$this->TbsStoreLoad($idx, $SubFile);
				if ($this->LastReadNotStored) {
					// Loaded for the first time
					if ($TBS===false) {
						$this->TbsSwitchMode(true); // Configuration which prevents from other plug-ins when calling LoadTemplate()
						$MergeAutoFields = $this->TbsMergeAutoFields();
						$TBS =& $this->TBS;
					}
					if ($this->LastReadComp<=0) { // the contents is not compressed
						if ($this->ExtInfo!==false) {
							$i = $this->ExtInfo;
							$e = $this->ExtEquiv;
							if (isset($i['rpl_what'])) {
								// auto replace strings in the loaded file
								$TBS->Source = str_replace($i['rpl_what'], $i['rpl_with'], $TBS->Source);
							}
							if (($e==='odt') && $TBS->OtbsClearWriter) {
								$this->OpenDoc_CleanRsID($TBS->Source);
							}
							if (($e==='ods') && $TBS->OtbsMsExcelCompatibility) {
								$this->OpenDoc_MsExcelCompatibility($TBS->Source);
							}
							if ($e==='docx') {
								if ($TBS->OtbsSpacePreserve) $this->MsWord_CleanSpacePreserve($TBS->Source);
								if ($TBS->OtbsClearMsWord) $this->MsWord_Clean($TBS->Source);
							}
							if (($e==='pptx') && $TBS->OtbsClearMsPowerpoint) {
								$this->MsPowerpoint_Clean($TBS->Source);
							}
							if (($e==='xlsx') && $TBS->OtbsMsExcelConsistent) {
								$this->MsExcel_DeleteFormulaResults($TBS->Source);
								$this->MsExcel_ConvertToRelative($TBS->Source);
							}
						}
						// apply default TBS behaviors on the uncompressed content: other plug-ins + [onload] fields
						if ($MergeAutoFields) $TBS->LoadTemplate(null,'+');
					}
				}
			}

		}

		if ($TBS!==false) $this->TbsSwitchMode(false); // Reactivate default configuration
		
		return $ok;
		
	}
function TbsLoadSubFileAsTemplate($SubFileLst) {

		if (!is_array($SubFileLst)) $SubFileLst = array($SubFileLst);

		$ok = true;
		$TBS = false;

		foreach ($SubFileLst as $SubFile) {

			$idx = $this->FileGetIdx($SubFile);
			if ($idx===false) {
				$ok = $this->RaiseError('Cannot load "'.$SubFile.'". The file is not found in the archive "'.$this->ArchFile.'".');
			} elseif ($idx!==$this->TbsCurrIdx) {
				// Save the current loaded subfile if any
				$this->TbsStorePark();
				// Load the subfile
				if (!is_string($SubFile)) $SubFile = $this->TbsGetFileName($idx);
				$this->TbsStoreLoad($idx, $SubFile);
				if ($this->LastReadNotStored) {
					// Loaded for the first time
					if ($TBS===false) {
						$this->TbsSwitchMode(true); // Configuration which prevents from other plug-ins when calling LoadTemplate()
						$MergeAutoFields = $this->TbsMergeAutoFields();
						$TBS =& $this->TBS;
					}
					if ($this->LastReadComp<=0) { // the contents is not compressed
						if ($this->ExtInfo!==false) {
							$i = $this->ExtInfo;
							$e = $this->ExtEquiv;
							if (isset($i['rpl_what'])) {
								// auto replace strings in the loaded file
								$TBS->Source = str_replace($i['rpl_what'], $i['rpl_with'], $TBS->Source);
							}
							if (($e==='odt') && $TBS->OtbsClearWriter) {
								$this->OpenDoc_CleanRsID($TBS->Source);
							}
							if (($e==='ods') && $TBS->OtbsMsExcelCompatibility) {
								$this->OpenDoc_MsExcelCompatibility($TBS->Source);
							}
							if ($e==='docx') {
								if ($TBS->OtbsSpacePreserve) $this->MsWord_CleanSpacePreserve($TBS->Source);
								if ($TBS->OtbsClearMsWord) $this->MsWord_Clean($TBS->Source);
							}
							if (($e==='pptx') && $TBS->OtbsClearMsPowerpoint) {
								$this->MsPowerpoint_Clean($TBS->Source);
							}
							if (($e==='xlsx') && $TBS->OtbsMsExcelConsistent) {
								$this->MsExcel_DeleteFormulaResults($TBS->Source);
								$this->MsExcel_ConvertToRelative($TBS->Source);
							}
						}
						// apply default TBS behaviors on the uncompressed content: other plug-ins + [onload] fields
						if ($MergeAutoFields) $TBS->LoadTemplate(null,'+');
					}
				}
			}

		}

		if ($TBS!==false) $this->TbsSwitchMode(false); // Reactivate default configuration
		
		return $ok;
		
	}
Load one or several sub-files of the archive as the current template.
If a sub-template is loaded for the first time, then automatic merges and clean-up are performed.
Return true if the file is correctly loaded.
@param $SubFileLst Can be an index or a name or a file, or an array of such values.