本文整理汇总了PHP中sotf_Utils::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP sotf_Utils::delete方法的具体用法?PHP sotf_Utils::delete怎么用?PHP sotf_Utils::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sotf_Utils
的用法示例。
在下文中一共展示了sotf_Utils::delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importXBMF
/** static: import a programme from the given XBMF archive */
function importXBMF($fileName, $publish = false, $console = false)
{
global $db, $config, $permissions, $repository, $vocabularies;
$pathToFile = $config['xbmfInDir'] . '/';
// create temp folder with unique name
$folderName = uniqid("xbmf");
if (!mkdir($pathToFile . $folderName)) {
logError("Could not create dir for XBMF", $pathToFile . $folderName);
return false;
}
// untar contents of file to folder
$tar = new Archive_Tar($fileName, true);
// create archive handler
$tar->setErrorHandling(PEAR_ERROR_PRINT);
// enable error reporting
$result = $tar->extract($pathToFile . $folderName);
// untar contents
debug("untar result", $result);
//parse the xml file
$metaFile = $pathToFile . $folderName . "/XBMF/Metadata.xml";
if (!is_file($metaFile)) {
$metaFile = $pathToFile . $folderName . "/XBMF/metadata.xml";
if (!is_file($metaFile)) {
logError("no metadata file found in XBMF!", $folderName);
return false;
}
}
$myPack = new unpackXML($metaFile);
if (!$myPack->error) {
//if the file has been found
$metadata = $myPack->process();
}
if (!$metadata or $myPack->error) {
//errors during import - stop execution
sotf_Utils::delete($pathToFile . $folderName);
echo "<font color=#FF0000><b>The import of {$fileName} did not succeed!</b></font>";
logError("XML processing failed within this XBMF", $folderName);
return false;
//did not succeed
} else {
/*
echo "Came In: " . $myPack->encoding . "<br>";
echo "Went Out: " . $myPack->outencoding . "<br>";
echo "<pre>";
print_r($metadata);
echo "</pre>";
*/
dump($metadata, "METADATA");
debug("METADATA", $metadata);
}
$db->begin();
// Select station
$stId = trim($metadata['stationid']);
if (is_numeric($stId)) {
$stId = $newPrg->makeId($config['nodeId'], 'sotf_stations', (int) $stId);
}
$station =& $repository->getObject($stId);
if (!$station) {
logError("invalid stationid: " . $metadata['stationid']);
return false;
// by default I put the programme into the first station
//$stId = $db->getOne("SELECT id FROM sotf_stations ORDER BY id");
//$station = &$repository->getObject($stId);
}
// select/create programme entry
if ($metadata['identifier']) {
$prgId = sotf_Programme::getMapping($station->id, $metadata['identifier'], 'prg');
}
if ($prgId) {
// updating an exisiting programme
debug("updating existing programme", $prgId);
$newPrg = new sotf_Programme($prgId);
if ($station->id != $newPrg->get('station_id')) {
logError("station provided in metadata is different from the station saved previously!");
return false;
}
//$station = &$repository->getObject($newPrg->get('station_id'));
$updatingPrg = 1;
} else {
// a new programme
$newPrg = new sotf_Programme();
$track = $metadata['title'];
debug("create new programme with track", $track);
$newPrg->create($station->id, $track);
sotf_Programme::addMapping($station->id, $metadata['identifier'], 'prg', $newPrg->id);
}
$newPrg->set('foreign_id', $metadata['identifier']);
// select/create series
if ($metadata['series'] && $metadata['series']['id']) {
$seriesId = sotf_Programme::getMapping($station->id, $metadata['series']['id'], 'series');
if (!$seriesId) {
$series1 = new sotf_Series();
$series1->set('name', $metadata['series']['title']);
$series1->set('station_id', $station->id);
$series1->find();
if ($series1->exists()) {
$seriesId = $series1->id;
}
}
//.........这里部分代码省略.........
示例2: delete
/** static: recursively deletes all content from the directory and the dir itself. */
function delete($file)
{
if (file_exists($file)) {
chmod($file, 0777);
if (is_dir($file)) {
$handle = opendir($file);
while ($filename = readdir($handle)) {
if ($filename != "." && $filename != "..") {
sotf_Utils::delete($file . "/" . $filename);
}
}
closedir($handle);
if (!rmdir($file)) {
logError("Could not rmdir: {$file}");
return false;
}
} else {
if (!unlink($file)) {
logError("Could not unlink: {$file}");
return false;
}
}
}
return true;
}