setReplacementKey() public method

Sets the replacement to replace pattern with.
public setReplacementKey ( string $p_replacementKey )
$p_replacementKey string
Beispiel #1
0
			$sql = "SELECT Id FROM TemplateTypes WHERE Name = 'nontpl'";
			$nonTplTypeId = $g_ado_db->GetOne($sql);
			// Move all the templates requested.
			foreach ($templates as $template) {
				if ($template->move($f_current_folder, $f_destination_folder)) {
					$searchKey = $template->getName();
					$replacementKey = ltrim($f_destination_folder
							. '/' . basename($template->getName()), '/');
					if ($template->getType() != $nonTplTypeId) {
						$searchKey = ' ' . $searchKey;
						$replacementKey = ' ' . $replacementKey;
					}
					$replaceObj = new FileTextSearch();
					$replaceObj->setExtensions(array('tpl','css'));
					$replaceObj->setSearchKey($searchKey);
					$replaceObj->setReplacementKey($replacementKey);
					$replaceObj->findReplace($Campsite['TEMPLATE_DIRECTORY']);
					Template::UpdateOnChange($template->getName(),
								 $f_destination_folder
								 . '/'
								 . basename($template->getName()));
				}
			}
			// Clear compiled templates
			require_once($GLOBALS['g_campsiteDir']."/template_engine/classes/CampTemplate.php");
			CampTemplate::singleton()->clear_compiled_tpl();

			camp_html_add_msg(getGS("Template(s) moved."), "ok");
			camp_html_goto_page($url);
		}
	}
Beispiel #2
0
 /**
  * Replace key in storage
  *
  * @param string $old
  * @param string $new
  * @param object $replaceEngine
  * @return void
  */
 private function replace($old, $new, $replaceEngine = null)
 {
     if (!isset($replaceEngine)) {
         $replaceEngine = new \FileTextSearch();
     }
     $replaceEngine->setExtensions(array('tpl', 'css'));
     $replaceEngine->setSearchKey($old);
     $replaceEngine->setReplacementKey($new);
     $replaceEngine->findReplace($this->root);
     $tpl1_name = $old;
     $tpl2_name = $new;
     if (pathinfo($old, PATHINFO_EXTENSION) == 'tpl') {
         $tpl1_name = ' ' . $old;
         $tpl2_name = ' ' . $new;
     }
     $replaceEngine->setSearchKey($tpl1_name);
     $replaceEngine->setReplacementKey($tpl2_name);
     $replaceEngine->findReplace($this->root);
 }
Beispiel #3
0
	$tpl2 = $Campsite['TEMPLATE_DIRECTORY'].'/'.$tpl2_name;
	if (rename($tpl1, $tpl2)) {
	        $relativeOldFilePath = ltrim($tpl1_name, '/');
		$relativeNewFilePath = ltrim($tpl2_name, '/');
		Template::UpdateOnChange($tpl1_name, $tpl2_name);
		// Clear compiled template
		require_once($GLOBALS['g_campsiteDir']."/template_engine/classes/CampTemplate.php");
		CampTemplate::singleton()->clear_compiled_tpl($relativeOldFilePath);
		$logtext = getGS('Template object $1 was renamed to $2', $tpl1_name, $tpl2_name);
		Log::Message($logtext, $g_user->getUserId(), 116);

		// Replace template name in other template files
		$replaceObj = new FileTextSearch();
		$replaceObj->setExtensions(array('tpl','css'));
		$replaceObj->setSearchKey($relativeOldFilePath);
		$replaceObj->setReplacementKey($relativeNewFilePath);
		$replaceObj->findReplace($Campsite['TEMPLATE_DIRECTORY']);
		if ($origExtension == 'tpl') {
			$tpl1_name = ' ' . $relativeOldFilePath;
			$tpl2_name = ' ' . $relativeNewFilePath;
		}
		$replaceObj->setSearchKey($tpl1_name);
		$replaceObj->setReplacementKey($tpl2_name);
		$replaceObj->findReplace($Campsite['TEMPLATE_DIRECTORY']);

		if (camp_is_text_file($tpl2) || camp_is_image_file($tpl2)) {
			// Go into edit mode.
			camp_html_goto_page("/$ADMIN/templates/edit_template.php"
				."?f_path=".urlencode($f_path)."&f_name=".urlencode($f_new_name));
		} else {
			// Go back to file list.