findReplace() public method

searchDirFiles() wrapper function.
public findReplace ( string $p_path )
$p_path string
Beispiel #1
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 #2
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;
 }
Beispiel #3
0
			$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);
		}
	}
} // END perform the action