本文整理汇总了PHP中Fox::getDirectoryPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Fox::getDirectoryPath方法的具体用法?PHP Fox::getDirectoryPath怎么用?PHP Fox::getDirectoryPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fox
的用法示例。
在下文中一共展示了Fox::getDirectoryPath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: traverseDirFiles
/**
* Traverses Files and Directories inside given path Recursively
* @param $path to traverse
*/
public function traverseDirFiles($path)
{
$dir = opendir($path);
$files = array();
$f = array();
$skip = array(Fox::getDirectoryPath() . DS . "var", Fox::getDirectoryPath() . DS . "library" . DS . "Zend", Fox::getExtensionDirectoryPath(), Fox::getDirectoryPath() . DS . "theme" . DS . "installer", APPLICATION_PATH . DS . "views" . DS . "installer");
while ($ft = readdir($dir)) {
if (in_array($ft, array(".", "..")) || in_array($path . DS . $ft, $skip)) {
continue;
}
$f[] = $ft;
}
sort($f);
foreach ($f as $file) {
if (filetype($path . DS . $file) != "dir") {
$files[] = $file;
} else {
$this->traverseDirFiles($path . DS . $file);
}
}
foreach ($files as $f) {
$this->processFiles($path, $f);
}
closedir($dir);
}
示例2: uninstallPackage
/**
* Uninstall package
*
* @param string $key valid package key
*/
public function uninstallPackage($key)
{
$config = $this->getConfig();
if (!file_exists($config->getInstalledPkgPath() . DS . $key . '.xml')) {
throw new Exception("Installation not found.");
}
$this->setStatus(Fox_Extensionmanager_Model_Package_Status::UNINSTALLING);
$packageXml = $config->getInstalledPkgPath() . DS . $key . '.xml';
$document = new Uni_Data_XDOMDocument();
$document->load($packageXml);
/*removing package files*/
$xpath = new DomXpath($document);
foreach ($xpath->query('//item[@rel="file"]') as $file) {
$filePath = Fox::getDirectoryPath() . $file->getAttribute("path");
if (file_exists($filePath) && !is_dir($filePath)) {
try {
@unlink($filePath);
} catch (Exception $e) {
}
}
}
/*listing directories to remove*/
$dirs = array();
foreach ($xpath->query('//item[@rel="dir"]') as $file) {
$dirPath = Fox::getDirectoryPath() . $file->getAttribute("path");
if (file_exists($dirPath) && is_dir($dirPath)) {
try {
$dirs[] = $dirPath;
} catch (Exception $e) {
}
}
}
/*removing empty directories in $dir list*/
if ($dirs) {
$dirs = array_reverse($dirs);
foreach ($dirs as $dir) {
@rmdir($dir);
}
}
/*removing package from installed directory*/
@unlink($packageXml);
$this->clearCache();
$this->setStatus(Fox_Extensionmanager_Model_Package_Status::UNINSTALLED);
}
示例3: getSiteXml
/**
* Get Xml of site directories/files
*
* @param bool $cache if true gets xml from cache otherwise regenerates
* @return string xml string
*/
public function getSiteXml($cache = true)
{
$xml = '';
$conf = $this->getConfig()->getConfiguration();
$cachePath = Fox::getExtensionDirectoryPath() . DS . $conf->extensionmanager->dir_name . DS . $conf->extensionmanager->cache;
if (!file_exists($cachePath)) {
@mkdir($cachePath, 0777, true);
}
$fileName = $cachePath . DS . $conf->extensionmanager->cache_file;
if ($cache && file_exists($fileName)) {
$xml = file_get_contents($fileName);
} else {
$path = Fox::getDirectoryPath();
$Obj = new Fox_Extensionmanager_Model_Generate_DirectoryToXml($path);
$Obj->traverseDirFiles($path);
$Obj->setArray($Obj->arr);
if (!($xml = $Obj->saveArrayToXml())) {
throw new Exception("Unable to load content tree data.");
}
$dom = $Obj->getXMLDom();
$dom->save($fileName);
@chmod($fileName, 0777);
}
return trim(preg_replace('/<\\?xml.*\\?>/', '', $xml, 1));
}