// 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. camp_html_goto_page("/$ADMIN/templates/?Path=".urlencode($f_path)); } } } else { camp_html_add_msg(getGS('A file or folder having the name $1 already exists','<b>'.$f_new_name.'</B>')); camp_html_goto_page("/$ADMIN/templates/"); } camp_html_add_msg(getGS('The template object $1 could not be renamed.','<b>'.$f_orig_name.'</B>')); camp_html_goto_page($backLink);
$tpl1 = $Campsite['TEMPLATE_DIRECTORY'].'/'.urldecode($f_path)."/$f_orig_name"; $fd = fopen($tpl1, "r"); $fileSize = filesize($tpl1); $contents = $fileSize > 0 ? fread($fd, $fileSize) : ''; fclose($fd); $tpl2_name = urldecode($f_path)."/$f_new_name"; $tpl2FullPath = $Campsite['TEMPLATE_DIRECTORY'].'/'.urldecode($f_path)."/$f_new_name"; $fd = fopen($tpl2FullPath, "w"); $bytes_written = fwrite($fd, $contents); fclose($fd); $ok = ( ($bytes_written !== false) || (strlen($contents) == 0) ); if ($ok) { $logtext = getGS('Template $1 was duplicated into $2', $tpl1_name, $tpl2_name); Log::Message($logtext, $g_user->getUserId(), 115); if (camp_is_text_file($tpl2FullPath) || camp_is_image_file($tpl2FullPath)) { // 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. camp_html_goto_page("/$ADMIN/templates/?Path=".urlencode($f_path)); } } } else { camp_html_add_msg(getGS('A file or folder having the name $1 already exists','<b>'.$f_new_name.'</B>')); camp_html_goto_page("/$ADMIN/templates/new_template.php?Path=".urlencode($f_path)); } camp_html_add_msg(getGS('The template $1 could not be created.','<b>'.$f_new_name.'</B>')); camp_html_goto_page($backLink);
} else { $tr_class = "list_row_odd"; } $color = !$color; print "\n\t\t<script>default_class[" . $counter ."] = \"" . $tr_class . "\";</script>"; if (camp_is_text_file($filename)) { if (empty($listbasedir) && ($filename == "home.tpl")) { print "\n\t\t<TR id=\"row_" . $counter . "\" style=\"background-color:#7dcd82;\" onmouseover=\"setPointer(this, " . $counter . ", 'over');\" onmouseout=\"setPointer(this, " . $counter . ", 'out');\" >"; } else { print "\n\t\t<TR id=\"row_" . $counter . "\" class=\"" . $tr_class . "\" onmouseover=\"setPointer(this, " . $counter . ", 'over');\" onmouseout=\"setPointer(this, " . $counter . ", 'out');\">"; } print "\n\t\t\t<TD><INPUT TYPE=\"checkbox\" VALUE=\""; if ($templateObj->exists()) { p($templateObj->getTemplateId()); } else { putGS("N/A"); } print "\" NAME=\"f_template_code[]\" ID=\"checkbox_" . $counter . "\" CLASS=\"input_checkbox\" onclick=\"checkboxClick(this, " . $counter . ");\" /></TD>"; print "\n\t\t\t<TD valign=\"center\"><IMG SRC='".$Campsite["ADMIN_IMAGE_BASE_URL"]."/generic.gif' BORDER='0'> <A HREF='/$ADMIN/templates/edit_template.php?f_path=" .urlencode($listbasedir)."&f_name=".urlencode($filename)."'>$filename</A></TD>"; } elseif (camp_is_image_file($filename)) { print "\n\t\t<TR id=\"row_" . $counter . "\" class=\"" . $tr_class . "\">"; print "\n\t\t\t<TD><INPUT TYPE=\"checkbox\" VALUE=\""; if ($templateObj->exists()) { p($templateObj->getTemplateId()); } else { putGS("N/A"); } print "\" NAME=\"f_template_code[]\" ID=\"checkbox_" . $counter . "\" CLASS=\"input_checkbox\" /></TD>"; print "\n\t\t\t<TD><IMG SRC='".$Campsite["ADMIN_IMAGE_BASE_URL"]."/image.png' BORDER='0'> <A HREF='/$ADMIN/templates/edit_template.php?f_path=" .urlencode($listbasedir)."&f_name=".urlencode($filename)."'>$filename</a></TD>"; } else { print "\n\t\t<TR $tr_class>"; print "\n\t\t\t<TD><INPUT TYPE=\"checkbox\" VALUE=\""; if ($templateObj->exists()) { p($templateObj->getTemplateId()); } else { putGS("N/A"); } print "\" NAME=\"f_template_code[]\" ID=\"checkbox_" . $counter . "\" CLASS=\"input_checkbox\" onclick=\"checkboxClick(this, " . $counter . ");\" /></TD>"; print "\n\t\t\t<TD><IMG SRC='".$Campsite["ADMIN_IMAGE_BASE_URL"]."/generic.gif' BORDER='0'> $filename</TD>"; } print "\n\t\t\t<td align=\"center\">"; if ($templateObj->exists()) { echo $templateObj->getTemplateId();