本文整理汇总了PHP中Utility::getHost方法的典型用法代码示例。如果您正苦于以下问题:PHP Utility::getHost方法的具体用法?PHP Utility::getHost怎么用?PHP Utility::getHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utility
的用法示例。
在下文中一共展示了Utility::getHost方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAvatarFromEmail
/**
* Get an avatar given an email address
* See http://en.gravatar.com/site/implement/images/ and http://en.gravatar.com/site/implement/hash/
*
* @return string
*/
public function getAvatarFromEmail($size = 50, $email = null)
{
if ($email === null) {
$email = $this->session->get('email');
}
// TODO return standard avatar
if (empty($email)) {
return;
}
$user = $this->getUserByEmail($email);
if (isset($user['attrprofilePhoto']) && !empty($user['attrprofilePhoto'])) {
return $user['attrprofilePhoto'];
}
$utilityObj = new Utility();
if (empty($this->config->site->cdnPrefix)) {
$hostAndProtocol = sprintf('%s://%s', $utilityObj->getProtocol(false), $utilityObj->getHost(false));
} else {
$hostAndProtocol = sprintf('%s%s', $utilityObj->getProtocol(false), $this->config->site->cdnPrefix);
}
if (!$this->themeObj) {
$this->themeObj = getTheme();
}
$defaultUrl = sprintf('%s%s', $hostAndProtocol, $this->themeObj->asset('image', 'profile-default.png', false));
$hash = md5(strtolower(trim($email)));
return sprintf("http://www.gravatar.com/avatar/%s?s=%s&d=%s", $hash, $size, urlencode($defaultUrl));
}
示例2: renderHead
public function renderHead()
{
$page = $this->plugin->getData('page');
if ($page !== 'photos' && $page !== 'photo-detail' && $page !== 'albums') {
return;
}
$photo = null;
if ($page === 'photos') {
$photo = array_shift($this->plugin->getData('photos'));
} elseif ($page === 'photo-detail') {
$photo = $this->plugin->getData('photo');
} elseif ($page === 'albums') {
$albums = $this->plugin->getData('albums');
if (count($albums) > 0 && !empty($albums[0]['cover'])) {
$photo = $albums[0]['cover'];
}
}
if (empty($photo)) {
return;
}
$utility = new Utility();
$tags = '';
$title = $photo['title'] !== '' ? $photo['title'] : "{$photo['filenameOriginal']} on Trovebox";
$tags .= $this->addTag('twitter:card', 'photo');
$tags .= $this->addTag('twitter:site', '@openphoto');
$tags .= $this->addTag('twitter:url', sprintf('%s://%s%s', $utility->getProtocol(false), $utility->getHost(), $utility->getPath()));
$tags .= $this->addTag('twitter:title', $title);
$tags .= $this->addTag('twitter:description', 'Trovebox lets you keep all your photos from different services and mobile devices safe in one spot.');
$tags .= $this->addTag('twitter:image', $photo['pathBase']);
$tags .= $this->addTag('twitter:image:width', '1280');
return $tags;
}
示例3: renderHead
public function renderHead()
{
$userObj = new User();
$utilityObj = new Utility();
$page = $this->plugin->getData('page');
if ($page !== 'photos' && $page !== 'photo-detail' && $page !== 'albums') {
return;
}
$metaTags = '';
$username = $utilityObj->safe($userObj->getNameFromEmail($this->config->user->email), false);
if ($page === 'photos') {
$photos = array_slice($this->plugin->getData('photos'), 0, 4);
$filters = $this->plugin->getData('filters');
$metaTags .= $this->addTag('twitter:card', 'gallery');
$title = sprintf('%s\'s photos on @Trovebox', $username);
if (array_search('album', $filters) !== false) {
$album = $this->plugin->getData('album');
$title = sprintf('%s from %s on @Trovebox', $utilityObj->safe($album['name'], false), $username);
} elseif (array_search('tags', $filters) !== false) {
$tags = implode(',', $this->plugin->getData('tags'));
$title = sprintf('Photos tagged with %s from %s on @Trovebox', $utilityObj->safe($tags, false), $username);
}
$cnt = 0;
foreach ($photos as $photo) {
$metaTags .= $this->addTag(sprintf('twitter:image%d', $cnt++), $photo['pathBase']);
}
} elseif ($page === 'photo-detail') {
$photo = $this->plugin->getData('photo');
$photoTitle = $photo['title'] !== '' ? $utilityObj->safe($photo['title'], false) : $photo['filenameOriginal'];
$title = sprintf('%s from %s on @Trovebox', $photoTitle, $username);
$metaTags .= $this->addTag('twitter:card', 'photo');
$metaTags .= $this->addTag('twitter:image', $photo['pathBase']);
} elseif ($page === 'albums') {
$albums = $this->plugin->getData('albums');
if (count($albums) > 0 && !empty($albums[0]['cover'])) {
$photo = $albums[0]['cover'];
}
$title = sprintf('%s\'s albums on @Trovebox', $username);
$metaTags .= $this->addTag('twitter:card', 'photo');
$metaTags .= $this->addTag('twitter:image', $photo['pathBase']);
}
if (empty($photo)) {
return;
}
$metaTags .= $this->addTag('twitter:site', '@Trovebox');
$metaTags .= $this->addTag('twitter:url', sprintf('%s://%s%s', $utilityObj->getProtocol(false), $utilityObj->getHost(), $utilityObj->getPath()));
$metaTags .= $this->addTag('twitter:title', $title);
$metaTags .= $this->addTag('twitter:description', 'Trovebox lets you keep all your photos from different services and mobile devices safe in one spot.');
$metaTags .= $this->addTag('twitter:image:width', '1280');
return $metaTags;
}
示例4: uploadNotify
public function uploadNotify($token)
{
$shareTokenObj = new ShareToken();
$tokenArr = $shareTokenObj->get($token);
if (empty($tokenArr) || $tokenArr['type'] != 'upload') {
return $this->forbidden('No permissions with the passed in token', false);
}
$albumId = $tokenArr['data'];
$albumResp = $this->api->invoke(sprintf('/album/%s/view.json', $albumId), EpiRoute::httpGet, array('_GET' => array('token' => $token)));
if ($albumResp['code'] !== 200) {
return $this->error('Could not get album details', false);
}
$uploader = $count = null;
if (isset($_POST['uploader'])) {
$uploader = $_POST['uploader'];
}
if (isset($_POST['count'])) {
$count = $_POST['count'];
}
$utilityObj = new Utility();
$albumName = $albumResp['result']['name'];
$albumUrl = sprintf('%s://%s/photos/album-%s/token-%s/list??sortBy=dateUploaded,desc', $utilityObj->getProtocol(false), $utilityObj->getHost(false), $albumId, $token);
$tokenOwner = $tokenArr['actor'];
$emailer = new Emailer();
$emailer->setRecipients(array($tokenOwner));
if (!empty($albumName)) {
$emailer->setSubject(sprintf('Photos uploaded to %s', $albumName));
} else {
$emailer->setSubject('New photos were uploaded for you');
}
$markup = $this->theme->get('partials/upload-notify.php', array('albumId' => $albumId, 'albumName' => $albumName, 'albumUrl' => $albumUrl, 'uploader' => $uploader, 'count' => $count));
$emailer->setBody($markup);
$res = $emailer->send($markup);
return $this->success('Email probably sent', true);
}
示例5: Utility
<?php
$utilityObj = new Utility();
$configFile = sprintf('%s/configs/%s.ini', getConfig()->get('paths')->userdata, $utilityObj->getHost());
$currentConfigAsString = getConfig()->getString($configFile);
// this regex is covered in src/texts/libraries/models/UpgradeTest.php gh-1279
$updatedConfigAsString = preg_replace('/^name ?\\= ?"?.+"?$/m', 'name="fabrizio1.0"', $currentConfigAsString);
$status = getConfig()->write($configFile, $updatedConfigAsString);
return $status;
示例6: profile
/**
* Return profile information for the site and the viewer
* TODO: separate the viewer into a separate API and call it from here
* for backwards compatability
*
* @return string Standard JSON envelope
*/
public function profile()
{
$email = $this->user->getEmailAddress();
$user = $this->user->getUserRecord();
if (empty($user)) {
return $this->notFound('Could not load user profile');
}
$utilityObj = new Utility();
$photos = $this->api->invoke('/photos/list.json', EpiRoute::httpGet, array('_GET' => array('pageSize' => 1)));
$albums = $this->api->invoke('/albums/list.json', EpiRoute::httpGet, array('_GET' => array('pageSize' => 1)));
$tags = $this->api->invoke('/tags/list.json', EpiRoute::httpGet, array('_GET' => array('pageSize' => 1)));
$profile = array('id' => $utilityObj->getHost(), 'photoUrl' => $this->user->getAvatarFromEmail(100, $this->config->user->email), 'counts' => array('photos' => empty($photos['result']) ? 0 : $photos['result'][0]['totalRows'], 'albums' => empty($albums['result']) ? 0 : $albums['result'][0]['totalRows'], 'tags' => count($tags['result'])), 'name' => $this->user->getNameFromEmail($this->config->user->email));
if ($this->user->isAdmin()) {
$profile['email'] = $this->user->getEmailAddress();
$profile['counts']['storage'] = $this->user->getStorageUsed() * 1024;
// convert from kilobytes to bytes
$profile['counts']['storage_str'] = strval($this->user->getStorageUsed() * 1024);
// workaround for bug in ios json parser #1150
}
$profile['isOwner'] = $this->user->isAdmin();
// should we include the viewer?
if (isset($_GET['includeViewer']) && $_GET['includeViewer'] == '1') {
// check if the viewer == owner
// if so then we just copy the owner in
// else we have to build the viewer array
if ($this->user->isOwner()) {
$profile['viewer'] = $profile;
} else {
$viewer = null;
if ($email !== null) {
$viewer = $this->user->getUserByEmail($email);
}
if ($viewer !== null) {
$profile['viewer'] = array('id' => $viewer['id'], 'photoUrl' => $this->user->getAvatarFromEmail(100, $viewer['id']), 'name' => $this->user->getNameFromEmail($viewer['id']));
} else {
$profile['viewer'] = array('id' => null, 'photoUrl' => $this->user->getAvatarFromEmail(100, null), 'name' => User::displayNameDefault);
}
}
}
return $this->success('User profile', $profile);
}
示例7: getAvatarFromEmail
/**
* Get an avatar given an email address
* See http://en.gravatar.com/site/implement/images/ and http://en.gravatar.com/site/implement/hash/
*
* @return string
*/
public function getAvatarFromEmail($size = 50, $email = null)
{
if ($email === null) {
$email = $this->session->get('email');
}
// TODO return standard avatar
if (empty($email)) {
return;
}
$utilityObj = new Utility();
$protocol = $utilityObj->getProtocol(false);
if (empty($this->config->site->cdnPrefix)) {
$hostAndProtocol = sprintf('%s://%s', $protocol, $utilityObj->getHost(false));
} else {
$hostAndProtocol = sprintf('%s:%s', $protocol, $this->config->site->cdnPrefix);
}
if (!$this->themeObj) {
$this->themeObj = getTheme();
}
$defaultUrl = sprintf('%s%s', $hostAndProtocol, $this->themeObj->asset('image', 'profile-default.png', false));
$user = $this->getUserByEmail($email);
if (isset($user['attrprofilePhoto']) && !empty($user['attrprofilePhoto'])) {
return $user['attrprofilePhoto'];
}
// if gravatar support is disabled and no profile photo exists then we immediately return the default url
if ($this->config->site->useGravatar == 0) {
return $defaultUrl;
}
if ($protocol === 'https') {
$gravatarUrl = 'https://secure.gravatar.com/avatar/';
} else {
$gravatarUrl = 'http://www.gravatar.com/avatar/';
}
$hash = md5(strtolower(trim($email)));
return sprintf('%s%s?s=%s&d=%s', $gravatarUrl, $hash, $size, urlencode($defaultUrl));
}