本文整理汇总了PHP中SpoonFile::getInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP SpoonFile::getInfo方法的具体用法?PHP SpoonFile::getInfo怎么用?PHP SpoonFile::getInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpoonFile
的用法示例。
在下文中一共展示了SpoonFile::getInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cleanupCache
/**
* Cleanup cache files
*/
private function cleanupCache()
{
$files = SpoonFile::getList($this->cachePath);
foreach ($files as $file) {
$fileinfo = SpoonFile::getInfo($this->cachePath . '/' . $file);
// delete file if more than 1 week old
if ($fileinfo['modification_date'] < strtotime('-1 week')) {
SpoonFile::delete($this->cachePath . '/' . $file);
}
}
}
示例2: cleanupCache
/**
* Cleanup cache files
*
* @return void
*/
private function cleanupCache()
{
// get cache files
$files = SpoonFile::getList($this->cachePath);
// loop items
foreach ($files as $file) {
// get info
$fileinfo = SpoonFile::getInfo($this->cachePath . '/' . $file);
// file is more than one week old
if ($fileinfo['modification_date'] < strtotime('-1 week')) {
// delete file
SpoonFile::delete($this->cachePath . '/' . $file);
}
}
}
示例3: processXMLAsPost
/**
* Process the XML and treat it as a blogpost
*
* @param SimpleXMLElement $xml The XML to process.
* @return bool
*/
private function processXMLAsPost(SimpleXMLElement $xml)
{
// init var
$postID = substr((string) $xml->id, mb_strpos((string) $xml->id, 'post-') + 5);
// validate
if ($postID == '') {
return false;
}
if ((string) $xml->title == '') {
return false;
}
// build item
$item['id'] = (int) BackendBlogModel::getMaximumId() + 1;
$item['user_id'] = BackendAuthentication::getUser()->getUserId();
$item['hidden'] = 'N';
$item['allow_comments'] = 'Y';
$item['num_comments'] = 0;
$item['status'] = 'active';
$item['language'] = BL::getWorkingLanguage();
$item['publish_on'] = BackendModel::getUTCDate(null, strtotime((string) $xml->published));
$item['created_on'] = BackendModel::getUTCDate(null, strtotime((string) $xml->published));
$item['edited_on'] = BackendModel::getUTCDate(null, strtotime((string) $xml->updated));
$item['category_id'] = 1;
$item['title'] = (string) $xml->title;
$item['text'] = (string) $xml->content;
// set drafts hidden
if (strtotime((string) $xml->published) > time()) {
$item['hidden'] = 'Y';
$item['status'] = 'draft';
}
// build meta
$meta = array();
$meta['keywords'] = $item['title'];
$meta['keywords_overwrite'] = 'N';
$meta['description'] = $item['title'];
$meta['description_overwrite'] = 'N';
$meta['title'] = $item['title'];
$meta['title_overwrite'] = 'N';
$meta['url'] = BackendBlogModel::getURL($item['title']);
$meta['url_overwrite'] = 'N';
// replace fucked up links
$item['text'] = preg_replace('|<a(.*)onblur="(.*)"(.*)>|Ui', '<a$1$3>', $item['text']);
// fix images
$item['text'] = preg_replace('|<img(.*)border="(.*)"(.*)>|Ui', '<img$1$3>', $item['text']);
// remove inline styles
$item['text'] = preg_replace('|<(.*)style="(.*)"(.*)>|Ui', '<$1$3>', $item['text']);
// whitespace
$item['text'] = preg_replace('|\\s{2,}|', ' ', $item['text']);
// cleanup
$search = array('<br /><br />', '<div><br /></div>', '<div>', '</div>', '<i>', '</i>', '<b>', '</b>', '<p><object', '</object></p>', '<p><p>', '</p></p>', '...');
$replace = array('</p><p>', '</p><p>', '', '', '<em>', '</em>', '<strong>', '</strong>', '<object', '</object>', '<p>', '</p>', '…');
// cleanup
$item['text'] = '<p>' . str_replace($search, $replace, SpoonFilter::htmlentitiesDecode($item['text'])) . '</p>';
// get images
$matches = array();
preg_match_all('/<img.*src="(.*)".*\\/>/Ui', $item['text'], $matches);
// any images?
if (isset($matches[1]) && !empty($matches[1])) {
// init var
$imagesPath = FRONTEND_FILES_PATH . '/userfiles/images/blog';
$imagesURL = FRONTEND_FILES_URL . '/userfiles/images/blog';
// create dir if needed
if (!SpoonDirectory::exists($imagesPath)) {
SpoonDirectory::create($imagesPath);
}
// loop matches
foreach ($matches[1] as $key => $file) {
// get file info
$fileInfo = SpoonFile::getInfo($file);
// init var
$destinationFile = $item['id'] . '_' . $fileInfo['basename'];
try {
// download
SpoonFile::download($file, $imagesPath . '/' . $destinationFile);
// replace the old URL with the new one
$item['text'] = str_replace($file, $imagesURL . '/' . $destinationFile, $item['text']);
} catch (Exception $e) {
// ignore
}
}
}
// get links
$matches = array();
preg_match_all('/<a.*href="(.*)".*\\/>/Ui', $item['text'], $matches);
// any images?
if (isset($matches[1]) && !empty($matches[1])) {
// loop matches
foreach ($matches[1] as $key => $file) {
// get new link
$replaceWith = self::download($file, $item['id']);
// should we replace?
if ($replaceWith !== false) {
// replace the old URL with the new one
$item['text'] = str_replace($file, $replaceWith, $item['text']);
//.........这里部分代码省略.........