/**
* Returns TRUE if the template is being used in an Issue or Section.
* @return boolean
*/
public static function InUse($p_templateName)
{
global $Campsite;
global $g_ado_db;
$p_templateName = ltrim($p_templateName, '/');
$queryStr = "SELECT * FROM Templates WHERE Name = '{$p_templateName}'";
$row = $g_ado_db->GetRow($queryStr);
if (!$row) {
return false;
}
$id = $row['Id'];
$queryStr = "SELECT COUNT(*) FROM Issues " . " WHERE IssueTplId = " . $id . " OR SectionTplId = " . $id . " OR ArticleTplId = " . $id;
$numMatches = $g_ado_db->GetOne($queryStr);
if ($numMatches > 0) {
return true;
}
$queryStr = "SELECT COUNT(*) FROM Sections " . " WHERE SectionTplId = " . $id . " OR ArticleTplId = " . $id;
$numMatches = $g_ado_db->GetOne($queryStr);
if ($numMatches > 0) {
return true;
}
$tplFindObj = new FileTextSearch();
$tplFindObj->setExtensions(array('tpl', 'css'));
$tplFindObj->setSearchKey($p_templateName);
$result = $tplFindObj->findReplace($Campsite['TEMPLATE_DIRECTORY']);
if (is_array($result) && sizeof($result) > 0) {
return $result[0];
}
if (pathinfo($p_templateName, PATHINFO_EXTENSION) == 'tpl') {
$p_templateName = ' ' . $p_templateName;
}
$tplFindObj->setSearchKey($p_templateName);
$result = $tplFindObj->findReplace($Campsite['TEMPLATE_DIRECTORY']);
if (is_array($result) && sizeof($result) > 0) {
return $result[0];
}
if ($tplFindObj->m_totalFound > 0) {
return true;
}
return false;
}