FileTextSearch::setSearchKey PHP Method

setSearchKey() public method

Sets the pattern and case sensitivity.
public setSearchKey ( string $p_searchKey, integer $p_caseSensitive )
$p_searchKey string
$p_caseSensitive integer
    public function setSearchKey($p_searchKey, $p_caseSensitive = 0)
    {
        $this->m_searchKey = $p_searchKey;
        if ($p_caseSensitive == 1) {
            $this->m_caseSensitive = 1;
        }
    }

Usage Example

Example #1
0
 /**
  * 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;
 }
All Usage Examples Of FileTextSearch::setSearchKey