libraries/tbs/plugins/tbs_plugin_opentbs.php
function OpenXML_Rels_ReplaceTarget($RelsPath, $OldTarget, $NewTarget) {
	
		$idx = $this->FileGetIdx($RelsPath);
		if ($idx===false) $this->RaiseError("Cannot edit target in '$RelsPath' because the file is not found.");
		$txt = $this->TbsStoreGet($idx, 'Replace target in rels file');
		
		$att = 'Target="'.$OldTarget.'"';
		$loc = clsTbsXmlLoc::FindStartTagHavingAtt($txt, $att, 0);
		if ($loc) {
			if ($NewTarget === false) {
				$loc->Delete();
			} else {
				$loc->ReplaceAtt('Target',$NewTarget);
			}
			$this->TbsStorePut($idx, $txt);
			return true;
		} else {
			return false;
		}
	
	}
function OpenXML_Rels_ReplaceTarget($RelsPath, $OldTarget, $NewTarget) {
	
		$idx = $this->FileGetIdx($RelsPath);
		if ($idx===false) $this->RaiseError("Cannot edit target in '$RelsPath' because the file is not found.");
		$txt = $this->TbsStoreGet($idx, 'Replace target in rels file');
		
		$att = 'Target="'.$OldTarget.'"';
		$loc = clsTbsXmlLoc::FindStartTagHavingAtt($txt, $att, 0);
		if ($loc) {
			if ($NewTarget === false) {
				$loc->Delete();
			} else {
				$loc->ReplaceAtt('Target',$NewTarget);
			}
			$this->TbsStorePut($idx, $txt);
			return true;
		} else {
			return false;
		}
	
	}
function OpenXML_Rels_ReplaceTarget ( $ RelsPath , $ OldTarget , $ NewTarget ) { $ idx = $ this -> FileGetIdx ( $ RelsPath ) ; if ( $ idx === false ) $ this -> RaiseError ( "Cannot edit target in '$RelsPath' because the file is not found." ) ; $ txt = $ this -> TbsStoreGet ( $ idx , 'Replace target in rels file' ) ; $ att = 'Target="' . $ OldTarget . '"' ; $ loc = clsTbsXmlLoc :: FindStartTagHavingAtt ( $ txt , $ att , 0 ) ; if ( $ loc ) { if ( $ NewTarget === false ) { $ loc -> Delete ( ) ; } else { $ loc -> ReplaceAtt ( 'Target' , $ NewTarget ) ; } $ this -> TbsStorePut ( $ idx , $ txt ) ; return true ; } else { return false ; } }
Replace or delete a target in a Rels file.
The current function actually edit the Rels file.
Take car that there is another technic for listing and adding targets wish is working with a persistent object which is commit at the end of the merge..
@param {string} $RelsPath  The path of the Rels file.
@param {string} $OldTarget The target value to find.
@param {string|boolean} $NewTarget The new target value, or false to delete the relation ship element.
@return {boolean} True if the change is applied.
Replace or delete a target in a Rels file . The current function actually edit the Rels file . Take car that there is another technic for listing and adding targets wish is working with a persistent object which is commit at the end of the merge ..