本文整理汇总了PHP中LocalFile::getURL方法的典型用法代码示例。如果您正苦于以下问题:PHP LocalFile::getURL方法的具体用法?PHP LocalFile::getURL怎么用?PHP LocalFile::getURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LocalFile
的用法示例。
在下文中一共展示了LocalFile::getURL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveSettings
public function saveSettings($settings, $cityId = null)
{
global $wgCityId, $wgUser;
$cityId = empty($cityId) ? $wgCityId : $cityId;
// Verify wordmark length ( CONN-116 )
if (!empty($settings['wordmark-text'])) {
$settings['wordmark-text'] = trim($settings['wordmark-text']);
}
if (empty($settings['wordmark-text'])) {
// Do not save wordmark if its empty.
unset($settings['wordmark-text']);
} else {
if (mb_strlen($settings['wordmark-text']) > 50) {
$settings['wordmark-text'] = mb_substr($settings['wordmark-text'], 0, 50);
}
}
if (isset($settings['favicon-image-name']) && strpos($settings['favicon-image-name'], 'Temp_file_') === 0) {
$temp_file = new LocalFile(Title::newFromText($settings['favicon-image-name'], 6), RepoGroup::singleton()->getLocalRepo());
$file = new LocalFile(Title::newFromText(self::FaviconImageName, 6), RepoGroup::singleton()->getLocalRepo());
$file->upload($temp_file->getPath(), '', '');
$temp_file->delete('');
Wikia::invalidateFavicon();
$settings['favicon-image-url'] = $file->getURL();
$settings['favicon-image-name'] = $file->getName();
$file->repo->forceMaster();
$history = $file->getHistory(1);
if (count($history) == 1) {
$oldFaviconFile = array('url' => $history[0]->getURL(), 'name' => $history[0]->getArchiveName());
}
}
if (isset($settings['wordmark-image-name']) && strpos($settings['wordmark-image-name'], 'Temp_file_') === 0) {
$temp_file = new LocalFile(Title::newFromText($settings['wordmark-image-name'], 6), RepoGroup::singleton()->getLocalRepo());
$file = new LocalFile(Title::newFromText(self::WordmarkImageName, 6), RepoGroup::singleton()->getLocalRepo());
$file->upload($temp_file->getPath(), '', '');
$temp_file->delete('');
$settings['wordmark-image-url'] = $file->getURL();
$settings['wordmark-image-name'] = $file->getName();
$file->repo->forceMaster();
$history = $file->getHistory(1);
if (count($history) == 1) {
$oldFile = array('url' => $history[0]->getURL(), 'name' => $history[0]->getArchiveName());
}
}
if (isset($settings['background-image-name']) && strpos($settings['background-image-name'], 'Temp_file_') === 0) {
$temp_file = new LocalFile(Title::newFromText($settings['background-image-name'], 6), RepoGroup::singleton()->getLocalRepo());
$file = new LocalFile(Title::newFromText(self::BackgroundImageName, 6), RepoGroup::singleton()->getLocalRepo());
$file->upload($temp_file->getPath(), '', '');
$temp_file->delete('');
$settings['background-image'] = $file->getURL();
$settings['background-image-name'] = $file->getName();
$settings['background-image-width'] = $file->getWidth();
$settings['background-image-height'] = $file->getHeight();
$imageServing = new ImageServing(null, 120, array("w" => "120", "h" => "65"));
$settings['user-background-image'] = $file->getURL();
$settings['user-background-image-thumb'] = wfReplaceImageServer($file->getThumbUrl($imageServing->getCut($file->getWidth(), $file->getHeight(), "origin") . "-" . $file->getName()));
$file->repo->forceMaster();
$history = $file->getHistory(1);
if (count($history) == 1) {
$oldBackgroundFile = array('url' => $history[0]->getURL(), 'name' => $history[0]->getArchiveName());
}
}
$reason = wfMsg('themedesigner-reason', $wgUser->getName());
// update history
if (!empty($GLOBALS[self::WikiFactoryHistory])) {
$history = $GLOBALS[self::WikiFactoryHistory];
$lastItem = end($history);
$revisionId = intval($lastItem['revision']) + 1;
} else {
$history = array();
$revisionId = 1;
}
// #140758 - Jakub
// validation
// default color values
foreach (ThemeDesignerHelper::getColorVars() as $sColorVar => $sDefaultValue) {
if (!isset($settings[$sColorVar]) || !ThemeDesignerHelper::isValidColor($settings[$sColorVar])) {
$settings[$sColorVar] = $sDefaultValue;
}
}
// update WF variable with current theme settings
WikiFactory::setVarByName(self::WikiFactorySettings, $cityId, $settings, $reason);
// add entry
$history[] = array('settings' => $settings, 'author' => $wgUser->getName(), 'timestamp' => wfTimestampNow(), 'revision' => $revisionId);
// limit history size to last 10 changes
$history = array_slice($history, -self::HistoryItemsLimit);
if (count($history) > 1) {
for ($i = 0; $i < count($history) - 1; $i++) {
if (isset($oldFaviconFile) && isset($history[$i]['settings']['favicon-image-name'])) {
if ($history[$i]['settings']['favicon-image-name'] == self::FaviconImageName) {
$history[$i]['settings']['favicon-image-name'] = $oldFaviconFile['name'];
$history[$i]['settings']['favicon-image-url'] = $oldFaviconFile['url'];
}
}
if (isset($oldFile) && isset($history[$i]['settings']['wordmark-image-name'])) {
if ($history[$i]['settings']['wordmark-image-name'] == self::WordmarkImageName) {
$history[$i]['settings']['wordmark-image-name'] = $oldFile['name'];
$history[$i]['settings']['wordmark-image-url'] = $oldFile['url'];
}
}
if (isset($oldBackgroundFile) && isset($history[$i]['settings']['background-image-name'])) {
//.........这里部分代码省略.........