public function IsValid($p_value) { $template = new Template($p_value); return $template->exists(); }
$templateObj = new Template($templateName); if (!file_exists($filename)) { camp_html_display_error(getGS("Invalid template file $1" , $f_path."/$f_name"), $backLink); exit; } if (!is_writable($filename)) { camp_html_add_msg(camp_get_error_message(CAMP_ERROR_WRITE_FILE, $filename)); } $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); $imageExtensions = array("png", "jpg", "jpeg", "jpe", "gif"); $templateDisplayName = $f_name; if ($templateObj->exists()) { $templateDisplayName .= ' ('.getGS("Template ID:").' '.$templateObj->getTemplateId().')'; } $f_lifetime = (int)$templateObj->getCacheLifetime(); $crumbs = array(); $crumbs[] = array(getGS("Configure"), ""); $crumbs[] = array(getGS("Templates"), "/$ADMIN/templates/"); $crumbs = array_merge($crumbs, camp_template_path_crumbs($f_path)); $crumbs[] = array(getGS("Edit template").": $templateDisplayName", ""); echo camp_html_breadcrumbs($crumbs); include_once($GLOBALS['g_campsiteDir']."/$ADMIN_DIR/javascript_common.php"); camp_html_display_msgs();
/** * */ public function getTemplate($p_templateIdOrName = null) { if (!is_null($this->m_template)) { return $this->m_template->name; } if (!empty($p_templateIdOrName)) { $tplObj = new Template($p_templateIdOrName); if (!$tplObj->exists()) { return null; } $template = $tplObj->getName(); } elseif (is_null($this->m_errorCode)) { $template = CampSystem::GetTemplate($this->language->number, $this->publication->identifier, $this->issue->number, $this->section->number, $this->article->number); } else { return null; } return $template; } // fn getTemplate
if (!$isFile) { $deleted = rmdir($fileFullPath.$Name); if ($deleted) { $logtext = getGS('Directory $1 was deleted', mysql_real_escape_string($fileFullName)); Log::Message($logtext, $g_user->getUserId(), 112); camp_html_add_msg($logtext, "ok"); } else { camp_html_add_msg(camp_get_error_message(CAMP_ERROR_RMDIR, $fileFullPath)); } } else { $inUse = Template::InUse($fileFullName); if ($inUse === CAMP_ERROR_READ_FILE || $inUse === CAMP_ERROR_READ_DIR) { camp_html_add_msg(getGS("There are some files which can not be readed so Newscoop was not able to determine whether '$1' is in use or not. Please fix this, then try to delete the template again.", basename($fileFullName))); } elseif ($inUse == false) { $template = new Template($fileFullName); if ($template->exists() && $template->delete()) { // Clear compiled template require_once($GLOBALS['g_campsiteDir']."/template_engine/classes/CampTemplate.php"); CampTemplate::singleton()->clear_compiled_tpl($fileFullName); $logtext = getGS('Template object $1 was deleted', mysql_real_escape_string($fileFullName)); Log::Message($logtext, $g_user->getUserId(), 112); camp_html_add_msg($logtext, "ok"); } else { camp_html_add_msg(camp_get_error_message(CAMP_ERROR_DELETE_FILE, $fileFullName)); } } else { camp_html_add_msg(getGS("The template object $1 is in use and can not be deleted.", $fileFullName)); } }
/** * Sets the URI path and query values based on given parameters. * * @param array $p_params * An array of valid URL parameters * @param boolean $p_preview * If true, will keep the preview parameters in the URL * * @return void */ protected function buildURI(array &$p_params = array(), $p_preview = false) { if ($this->isValidCache()) { return; } $parameter = count($p_params) > 0 ? strtolower(array_shift($p_params)) : null; switch($parameter) { case 'language': case 'publication': $this->m_buildPath = $this->getURILanguage(); if ($p_preview) { $this->m_buildQueryArray = $this->getQueryArray(CampURI::$m_previewParameters); } else { $this->m_buildQueryArray = array(); } $p_params = array(); break; case 'issue': $this->m_buildPath = $this->getURIIssue(); if ($p_preview) { $this->m_buildQueryArray = $this->getQueryArray(CampURI::$m_previewParameters); } else { $this->m_buildQueryArray = array(); } $p_params = array(); break; case 'section': $this->m_buildPath = $this->getURISection(); if ($p_preview) { $this->m_buildQueryArray = $this->getQueryArray(CampURI::$m_previewParameters); } else { $this->m_buildQueryArray = array(); } $p_params = array(); break; case 'article': $this->m_buildPath = $this->getURIArticle(); if ($p_preview) { $this->m_buildQueryArray = $this->getQueryArray(CampURI::$m_previewParameters); } else { $this->m_buildQueryArray = array(); } $p_params = array(); break; case 'template': $option = isset($p_params[0]) ? array_shift($p_params) : null; $template = new Template($option); if (!is_null($option) && $template->exists()) { $this->m_buildQueryArray[CampRequest::TEMPLATE_ID] = $template->getTemplateId(); } break; default: if (!empty($parameter)) { array_unshift($p_params, $parameter); $count = count($p_params); parent::buildURI($p_params, $p_preview); if (count($p_params) == $count) { array_shift($p_params); } } } if (count($p_params) > 0) { $this->buildURI($p_params); } if (!is_null($this->m_language) && $this->m_language->defined() && is_null($this->m_buildPath)) { $this->m_buildPath = $this->m_config->getSetting('SUBDIR') . '/' . $this->m_language->code . '/'; if (!is_null($this->m_issue) && $this->m_issue->defined()) { $this->m_buildPath .= $this->m_issue->url_name . '/'; if (!is_null($this->m_section) && $this->m_section->defined()) { $this->m_buildPath .= $this->m_section->url_name . '/'; if (!is_null($this->m_article) && $this->m_article->defined()) { $this->m_buildPath = $this->getURIArticle(); } } } } if (is_null($this->m_buildQuery)) { $this->m_buildQuery = CampURI::QueryArrayToString($this->m_buildQueryArray); } $this->validateCache(true); } // fn buildURI
<?php include "config.php"; include "s_lib/UrlAmigavel.class.php"; include "s_lib/conexao.class.php"; include "s_lib/funcoes_basicas.php"; require_once "s_lib/raelgc/view/Template.php"; include "s_php/linguagem/textos.php"; define('URL_SITE', UrlAmigavel::url_padrao('http')); $tpl = new Template("s_html/index.html"); $base = new Conexao(); $lingua = ""; #DEFINE O CAMIHO DE URL PADRAO img,css,href etc {BASE} if ($tpl->exists('BASE')) { $tpl->BASE = URL_SITE; } #VERIFICA SE AS TEBELAS EXISTEM $tabelas = array('idiomas', 'sistema', 'usuarios', 'textos'); $verif_banco = true; foreach ($tabelas as $valor) { if ($base->verifica_tabela($valor) == false) { $verif_banco = false; } } if ($verif_banco == false) { die(header("Location: " . URL_SITE . "instalar/")); } #VERIFICA SE O IDIOMA EXISTE if (UrlAmigavel::campo_url()) { $lg = $base->seleciona('idiomas', array('status' => "1")); $db_idioma = array();
$templateObj = new Template($templateName); if ($color) { $tr_class = "list_row_even"; } 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>"; }
public static function GetURI($p_publicationId, $p_languageId, $p_issueNo = null, $p_sectionNo = null, $p_articleNo = null, $p_templateIdOrName = null) { $languageObj = new Language($p_languageId); if (!$languageObj->exists()) { return new PEAR_Error(getGS('Language does not exist.')); } $uri = $GLOBALS['Campsite']['SUBDIR'] . '/' . $languageObj->getCode() . '/'; if (!is_null($p_issueNo) && is_null($p_articleNo)) { $issueObj = new Issue($p_publicationId, $p_languageId, $p_issueNo); if (!$issueObj->exists()) { return new PEAR_Error(getGS('Issue does not exist.')); } $uri .= $issueObj->getUrlName() . '/'; } if (!is_null($p_sectionNo) && is_null($p_articleNo)) { $sectionObj = new Section($p_publicationId, $p_issueNo, $p_languageId, $p_sectionNo); if (!$sectionObj->exists()) { return new PEAR_Error(getGS('Section does not exist.')); } $uri .= $sectionObj->getUrlName() . '/'; } if (!is_null($p_articleNo)) { $articleObj = new Article($p_languageId, $p_articleNo); if (!$articleObj->exists()) { return new PEAR_Error(getGS('Article does not exist.')); } $issueObj = new Issue($p_publicationId, $p_languageId, $articleObj->getIssueNumber()); $sectionObj = new Section($p_publicationId, $articleObj->getIssueNumber(), $p_languageId, $articleObj->getSectionNumber()); $uri .= $issueObj->getUrlName() . '/'; $uri .= $sectionObj->getUrlName() . '/'; $uri .= $articleObj->getUrlName() . '/'; } if (!is_null($p_templateIdOrName)) { $templateObj = new Template($p_templateIdOrName); if (!$templateObj->exists()) { return new PEAR_Error(getGS('Template $1 no longer exists!'), $p_templateIdOrName); } $uri .= '?tpl=' . $templateObj->getTemplateId(); } return $uri; }