本文整理匯總了PHP中PublicFileManager::fileExists方法的典型用法代碼示例。如果您正苦於以下問題:PHP PublicFileManager::fileExists方法的具體用法?PHP PublicFileManager::fileExists怎麽用?PHP PublicFileManager::fileExists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PublicFileManager
的用法示例。
在下文中一共展示了PublicFileManager::fileExists方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: localizeArticleCoverImages
/**
* Localize article cover images.
* @return boolean True indicates success.
*/
function localizeArticleCoverImages()
{
$articleDao = DAORegistry::getDAO('ArticleDAO');
$publicFileManager = new PublicFileManager();
// remove strange old cover images with array values in the DB - from 3.alpha or 3.beta?
$articleDao->update('DELETE FROM submission_settings WHERE setting_name = \'coverImage\' AND setting_type = \'object\'');
// remove empty 3.0 cover images
$articleDao->update('DELETE FROM submission_settings WHERE setting_name = \'coverImage\' AND locale = \'\' AND setting_value = \'\'');
$articleDao->update('DELETE FROM submission_settings WHERE setting_name = \'coverImageAltText\' AND locale = \'\' AND setting_value = \'\'');
// get cover image duplicates, from 2.4.x and 3.0
$result = $articleDao->retrieve('SELECT DISTINCT ss1.submission_id, ss1.setting_value, s.context_id
FROM submission_settings ss1
LEFT JOIN submissions s ON (s.submission_id = ss1.submission_id)
JOIN submission_settings ss2 ON (ss2.submission_id = ss1.submission_id AND ss2.setting_name = \'coverImage\')
WHERE ss1.setting_name = \'fileName\'');
// remove the old 2.4.x cover images, for which a new cover image exists
while (!$result->EOF) {
$row = $result->GetRowAssoc(false);
$submissionId = $row['submission_id'];
$oldFileName = $row['setting_value'];
if ($publicFileManager->fileExists($publicFileManager->getContextFilesPath(ASSOC_TYPE_JOURNAL, $row['context_id']) . '/' . $oldFileName)) {
$publicFileManager->removeJournalFile($row['journal_id'], $oldFileName);
}
$articleDao->update('DELETE FROM submission_settings WHERE submission_id = ? AND setting_name = \'fileName\' AND setting_value = ?', array((int) $submissionId, $oldFileName));
$result->MoveNext();
}
$result->Close();
// retrieve names for unlocalized article cover images
$result = $articleDao->retrieve('SELECT ss.submission_id, ss.setting_value, j.journal_id, j.primary_locale
FROM submission_settings ss, submissions s, journals j
WHERE ss.setting_name = \'coverImage\' AND ss.locale = \'\'
AND s.submission_id = ss.submission_id AND j.journal_id = s.context_id');
// for all unlocalized article cover images
// rename (copy + remove) the cover images files in the public folder,
// considereing the locale (using the journal primary locale)
while (!$result->EOF) {
$row = $result->GetRowAssoc(false);
$oldFileName = $row['setting_value'];
$newFileName = str_replace('.', '_' . $row['primary_locale'] . '.', $oldFileName);
if ($publicFileManager->fileExists($publicFileManager->getContextFilesPath(ASSOC_TYPE_JOURNAL, $row['journal_id']) . '/' . $oldFileName)) {
$publicFileManager->copyJournalFile($row['journal_id'], $publicFileManager->getContextFilesPath(ASSOC_TYPE_JOURNAL, $row['journal_id']) . '/' . $oldFileName, $newFileName);
$publicFileManager->removeJournalFile($row['journal_id'], $oldFileName);
}
$result->MoveNext();
}
$result->Close();
$driver = $articleDao->getDriver();
switch ($driver) {
case 'mysql':
case 'mysqli':
// Update cover image names in the submission_settings table
$articleDao->update('UPDATE submission_settings ss, submissions s, journals j
SET ss.locale = j.primary_locale, ss.setting_value = CONCAT(LEFT( ss.setting_value, LOCATE(\'.\', ss.setting_value) - 1 ), \'_\', j.primary_locale, \'.\', SUBSTRING_INDEX(ss.setting_value,\'.\',-1))
WHERE ss.setting_name = \'coverImage\' AND ss.locale = \'\' AND s.submission_id = ss.submission_id AND j.journal_id = s.context_id');
// Update cover image alt texts in the submission_settings table
$articleDao->update('UPDATE submission_settings ss, submissions s, journals j
SET ss.locale = j.primary_locale
WHERE ss.setting_name = \'coverImageAltText\' AND ss.locale = \'\' AND s.submission_id = ss.submission_id AND j.journal_id = s.context_id');
break;
case 'postgres':
// Update cover image names in the submission_settings table
$articleDao->update('UPDATE submission_settings
SET locale = j.primary_locale, setting_value = REGEXP_REPLACE(submission_settings.setting_value, \'[\\.]\', CONCAT(\'_\', j.primary_locale, \'.\'))
FROM submissions s, journals j
WHERE submission_settings.setting_name = \'coverImage\' AND submission_settings.locale = \'\' AND s.submission_id = submission_settings.submission_id AND j.journal_id = s.context_id');
// Update cover image alt texts in the submission_settings table
$articleDao->update('UPDATE submission_settings
SET locale = j.primary_locale
FROM submissions s, journals j
WHERE submission_settings.setting_name = \'coverImageAltText\' AND submission_settings.locale = \'\' AND s.submission_id = submission_settings.submission_id AND j.journal_id = s.context_id');
break;
default:
fatalError('Unknown database type!');
}
$articleDao->flushCache();
return true;
}