本文整理汇总了PHP中Utility::getProtocol方法的典型用法代码示例。如果您正苦于以下问题:PHP Utility::getProtocol方法的具体用法?PHP Utility::getProtocol怎么用?PHP Utility::getProtocol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utility
的用法示例。
在下文中一共展示了Utility::getProtocol方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndexing
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndexing()
{
ini_set('max_execution_time', 0);
ob_start();
$index = new Zend_Search_Lucene(Yii::getPathOfAlias($this->_indexFilesPath), true);
$criteria = new CDbCriteria();
$criteria->compare('t.publish', 1);
$criteria->order = 'album_id DESC';
//$criteria->limit = 10;
$model = Albums::model()->findAll($criteria);
foreach ($model as $key => $item) {
if ($item->media_id != 0) {
$images = Yii::app()->request->baseUrl . '/public/album/' . $item->album_id . '/' . $item->cover->media;
} else {
$images = '';
}
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('id', CHtml::encode($item->album_id), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('media', CHtml::encode($images), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('title', CHtml::encode($item->title), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('body', CHtml::encode(Utility::hardDecode(Utility::softDecode($item->body))), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('url', CHtml::encode(Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('album/site/view', array('id' => $item->album_id, 't' => Utility::getUrlTitle($item->title)))), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('date', CHtml::encode(Utility::dateFormat($item->creation_date, true) . ' WIB'), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('creation', CHtml::encode($item->user->displayname), 'utf-8'));
$index->addDocument($doc);
}
echo 'Album Lucene index created';
$index->commit();
$this->redirect(Yii::app()->createUrl('article/search/indexing'));
ob_end_flush();
}
示例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: 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));
}
示例4: 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;
}
示例5: diagnostics
/**
* Gets diagnostic information for debugging.
*
* @return array
*/
public function diagnostics()
{
$utilityObj = new Utility();
$diagnostics = array();
if (is_writable($this->root)) {
$diagnostics[] = $utilityObj->diagnosticLine(true, 'File system is writable.');
} else {
$diagnostics[] = $utilityObj->diagnosticLine(false, 'File system is NOT writable.');
}
$ch = curl_init(sprintf('%s://%s/', trim($utilityObj->getProtocol(false)), $this->host));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
$resultCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($resultCode == '403') {
$diagnostics[] = $utilityObj->diagnosticLine(true, 'Photo path correctly returns 403.');
} else {
$diagnostics[] = $utilityObj->diagnosticLine(false, sprintf('Photo path returns %d instead of 403.', $resultCode));
}
return $diagnostics;
}
示例6: 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);
}
示例7: actionOffice
/**
* Lists all models.
*/
public function actionOffice()
{
$this->layout = false;
$model = OmmuMeta::model()->findAll(array());
$setting = OmmuSettings::model()->findByPk(1, array('select' => 'site_title'));
$return = array();
$return['maps'] = array('icon' => Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->request->baseUrl . '/public/marker_default.png', 'width' => 42, 'height' => 48);
$i = 0;
foreach ($model as $val) {
$i++;
$point = explode(',', $val->office_location);
$return['data'][] = array('id' => $i, 'lat' => $point[0], 'lng' => $point[1], 'name' => $val->office_name != '' ? $val->office_name : $setting->site_title, 'address' => $val->office_place . '. ' . $val->office_village . ', ' . $val->office_district . ', ' . $val->view_meta->city . ', ' . $val->view_meta->province . ', ' . $val->view_meta->country . ', ' . $val->office_zipcode);
}
echo CJSON::encode($return);
}
示例8: actionUnsubscribe
/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'admin' page.
* @param integer $id the ID of the model to be deleted
*/
public function actionUnsubscribe()
{
/**
* example get link
* http://localhost/_product/nirwasita_hijab/support/newsletter/unsubscribe/email/putra.sudaryanto@gmail.com/secret/uvijijxykmabhiijdehinofgtuuvbcGH
* secret = salt[Users]
* email = email[Users]
*/
$renderError = 0;
if (isset($_GET['success']) || (isset($_GET['email']) || isset($_GET['secret']))) {
if (isset($_GET['success'])) {
if (isset($_GET['date'])) {
$title = Phrase::trans(23116, 1);
$desc = Phrase::trans(23118, 1, array($_GET['success'], Utility::dateFormat($_GET['date'])));
} else {
$title = Phrase::trans(23119, 1);
$desc = Phrase::trans(23120, 1, array($_GET['success']));
}
} else {
if (isset($_GET['email']) || isset($_GET['secret'])) {
$newsletter = UserNewsletter::model()->findByAttributes(array('email' => $_GET['email']), array('select' => 'id, user_id, email, subscribe, subscribe_date, unsubscribe_date'));
if ($newsletter != null) {
if ($newsletter->user_id != 0) {
$secret = Users::model()->findByAttributes(array('salt' => $_GET['secret']), array('select' => 'email'));
$guest = $secret != null && $secret->email == $newsletter->email ? 1 : 0;
} else {
$guest = md5($newsletter->email . $newsletter->subscribe_date) == $_GET['secret'] ? 1 : 0;
}
if ($guest == 1) {
if ($newsletter->subscribe == 1) {
$newsletter->subscribe = 0;
if ($newsletter->update()) {
$title = Phrase::trans(23116, 1);
$desc = Phrase::trans(23117, 1, array($newsletter->email));
}
} else {
$title = Phrase::trans(23116, 1);
$desc = Phrase::trans(23118, 1, array($newsletter->email, Utility::dateFormat($newsletter->unsubscribe_date)));
}
} else {
$renderError = 1;
$title = Phrase::trans(23113, 1);
$desc = Phrase::trans(23115, 1, array($newsletter->email));
}
} else {
$renderError = 1;
$title = Phrase::trans(23113, 1);
$desc = Phrase::trans(23114, 1);
}
}
}
} else {
$model = new UserNewsletter();
// Uncomment the following line if AJAX validation is needed
$this->performAjaxValidation($model);
if (isset($_POST['UserNewsletter'])) {
$model->attributes = $_POST['UserNewsletter'];
$jsonError = CActiveForm::validate($model);
if (strlen($jsonError) > 2) {
echo $jsonError;
} else {
if (isset($_GET['enablesave']) && $_GET['enablesave'] == 1) {
if ($model->validate()) {
if ($model->subscribe == 1) {
if ($model->user_id != 0) {
$email = $model->user->email;
$displayname = $model->user->displayname;
$secret = $model->user->salt;
} else {
$email = $displayname = $model->email;
$secret = md5($email . $model->subscribe_date);
}
// Send Email to Member
$ticket = Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('support/newsletter/unsubscribe', array('email' => $email, 'secret' => $secret));
SupportMailSetting::sendEmail($email, $displayname, 'Unsubscribe Ticket', $ticket, 1);
$url = Yii::app()->controller->createUrl('unsubscribe', array('success' => $email));
} else {
$url = Yii::app()->controller->createUrl('unsubscribe', array('success' => $model->email, 'date' => $model->unsubscribe_date));
}
echo CJSON::encode(array('type' => 5, 'get' => $url));
} else {
print_r($model->getErrors());
}
}
}
Yii::app()->end();
}
$title = Phrase::trans(23111, 1);
$desc = Phrase::trans(23112, 1);
}
$this->dialogDetail = true;
$this->dialogGroundUrl = Yii::app()->createUrl('site/index');
$this->dialogFixed = true;
$this->pageTitle = $title;
$this->pageDescription = $desc;
//.........这里部分代码省略.........
示例9: afterSave
/**
* After save attributes
*/
protected function afterSave()
{
parent::afterSave();
$controller = strtolower(Yii::app()->controller->id);
$currentAction = strtolower(Yii::app()->controller->id . '/' . Yii::app()->controller->action->id);
// Generate Verification Code
if ($this->verified == 0) {
$verify = new UserVerify();
$verify->user_id = $this->user_id;
$verify->save();
}
if ($this->isNewRecord) {
$setting = OmmuSettings::model()->findByPk(1, array('select' => 'site_type, signup_welcome, signup_adminemail'));
if ($setting->site_type == 1) {
$invite = UserInviteQueue::model()->findByAttributes(array('email' => strtolower($this->email)), array('select' => 'queue_id, member_id, reference_id'));
if ($invite != null && $invite->member_id == 0) {
$invite->member_id = $this->user_id;
if ($this->referenceId != '') {
$invite->reference_id = $this->referenceId;
}
$invite->update();
}
}
// Send Welcome Email
if ($setting->signup_welcome == 1) {
$welcome_search = array('{$baseURL}', '{$index}', '{$displayname}');
$welcome_replace = array(Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->request->baseUrl, Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('site/index'), $this->displayname);
$welcome_template = 'user_welcome';
$welcome_title = 'Welcome to SSO-GTP by BPAD Yogyakarta';
$welcome_message = file_get_contents(YiiBase::getPathOfAlias('webroot.externals.users.template') . '/' . $welcome_template . '.php');
$welcome_ireplace = str_ireplace($welcome_search, $welcome_replace, $welcome_message);
SupportMailSetting::sendEmail($this->email, $this->displayname, $welcome_title, $welcome_ireplace, 1);
}
// Send Account Information
$account_search = array('{$baseURL}', '{$login}', '{$displayname}', '{$email}', '{$password}');
$account_replace = array(Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->request->baseUrl, Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('site/login'), $this->displayname, $this->email, $this->newPassword);
$account_template = 'user_welcome_account';
$account_title = 'SSO-GTP Account (' . $this->displayname . ')';
$account_message = file_get_contents(YiiBase::getPathOfAlias('webroot.externals.users.template') . '/' . $account_template . '.php');
$account_ireplace = str_ireplace($account_search, $account_replace, $account_message);
SupportMailSetting::sendEmail($this->email, $this->displayname, $account_title, $account_ireplace, 1);
// Send New Account to Email Administrator
if ($setting->signup_adminemail == 1) {
SupportMailSetting::sendEmail($this->email, $this->displayname, 'New Member', 'informasi member terbaru', 0);
}
} else {
// Send Account Information
//if($this->enabled == 1) {}
if ($controller == 'password') {
$account_search = array('{$baseURL}', '{$login}', '{$displayname}', '{$email}', '{$password}');
$account_replace = array(Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->request->baseUrl, Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('site/login'), $this->displayname, $this->email, $this->newPassword);
$account_template = 'user_forgot_new_password';
$account_title = 'Your password changed';
$account_message = file_get_contents(YiiBase::getPathOfAlias('webroot.externals.users.template') . '/' . $account_template . '.php');
$account_ireplace = str_ireplace($account_search, $account_replace, $account_message);
SupportMailSetting::sendEmail($this->email, $this->displayname, $account_title, $account_ireplace, 1);
}
if ($controller == 'verify') {
SupportMailSetting::sendEmail($this->email, $this->displayname, 'Verify Email Success', 'Verify Email Success', 1);
}
}
}
示例10: afterSave
/**
* After save attributes
*/
protected function afterSave()
{
parent::afterSave();
if ($this->isNewRecord) {
// Send Email to Member
$verify_search = array('{$baseURL}', '{$verify}', '{$displayname}');
$verify_replace = array(Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->request->baseUrl, Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('users/verify/code', array('key' => $this->code, 'secret' => $this->user->salt)), $this->user->displayname);
$verify_template = 'user_verify_email';
$verify_title = 'Please verify your SSO-GTP account';
$verify_message = file_get_contents(YiiBase::getPathOfAlias('webroot.externals.users.template') . '/' . $verify_template . '.php');
$verify_ireplace = str_ireplace($verify_search, $verify_replace, $verify_message);
SupportMailSetting::sendEmail($this->user->email, $this->user->displayname, $verify_title, $verify_ireplace, 1);
}
}
示例11: actionIndexing
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndexing()
{
ini_set('max_execution_time', 0);
ob_start();
$index = new Zend_Search_Lucene(Yii::getPathOfAlias($this->_indexFilesPath), true);
$criteria = new CDbCriteria();
$now = new CDbExpression("NOW()");
$criteria->compare('t.publish', 1);
$criteria->compare('date(published_date) <', $now);
$criteria->order = 'article_id DESC';
//$criteria->limit = 10;
$model = Articles::model()->findAll($criteria);
foreach ($model as $key => $item) {
if ($item->media_id != 0) {
$images = Yii::app()->request->baseUrl . '/public/article/' . $item->article_id . '/' . $item->cover->media;
} else {
$images = '';
}
if (in_array($item->cat_id, array(2, 3, 5, 6, 7, 18))) {
$url = Yii::app()->createUrl('article/news/site/view', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
} else {
if (in_array($item->cat_id, array(9))) {
$url = Yii::app()->createUrl('article/site/view', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
} else {
if (in_array($item->cat_id, array(10, 15, 16))) {
$url = Yii::app()->createUrl('article/archive/site/view', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
} else {
if (in_array($item->cat_id, array(23, 24, 25))) {
$url = Yii::app()->createUrl('article/newspaper/site/view', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
} else {
if (in_array($item->cat_id, array(13, 14, 20, 21))) {
$url = Yii::app()->createUrl('article/regulation/site/download', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
} else {
if (in_array($item->cat_id, array(19))) {
$url = Yii::app()->createUrl('article/announcement/site/download', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
}
}
}
}
}
}
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('id', CHtml::encode($item->article_id), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Keyword('category', CHtml::encode(Phrase::trans($item->cat->name, 2)), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('media', CHtml::encode($images), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('title', CHtml::encode($item->title), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('body', CHtml::encode(Utility::hardDecode(Utility::softDecode($item->body))), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('url', CHtml::encode(Utility::getProtocol() . '://' . Yii::app()->request->serverName . $url), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('date', CHtml::encode(Utility::dateFormat($item->published_date, true) . ' WIB'), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('creation', CHtml::encode($item->user->displayname), 'utf-8'));
$index->addDocument($doc);
}
echo 'Artkel Lucene index created';
$index->commit();
$this->redirect(Yii::app()->createUrl('video/search/indexing'));
ob_end_flush();
}
示例12: 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));
}
示例13: afterSave
/**
* After save attributes
*/
protected function afterSave()
{
parent::afterSave();
if ($this->isNewRecord) {
// Send Email to Member
$forgot_search = array('{$baseURL}', '{$forgot}', '{$displayname}');
$forgot_replace = array(Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->request->baseUrl, Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('users/password/verify', array('key' => $this->code, 'secret' => $this->user->salt)), $this->user->displayname);
$forgot_template = 'user_forgot_password';
$forgot_title = 'SSO-GTP Password Assistance';
$forgot_message = file_get_contents(YiiBase::getPathOfAlias('webroot.externals.users.template') . '/' . $forgot_template . '.php');
$forgot_ireplace = str_ireplace($forgot_search, $forgot_replace, $forgot_message);
SupportMailSetting::sendEmail($this->user->email, $this->user->displayname, $forgot_title, $forgot_ireplace, 1);
}
}
示例14: searchIndexing
/**
* Albums get information
*/
public function searchIndexing($index)
{
Yii::import('application.modules.album.models.*');
$criteria = new CDbCriteria();
$criteria->compare('t.publish', 1);
$criteria->order = 'album_id DESC';
//$criteria->limit = 10;
$model = Albums::model()->findAll($criteria);
foreach ($model as $key => $item) {
if ($item->media_id != 0) {
$images = Yii::app()->request->baseUrl . '/public/album/' . $item->album_id . '/' . $item->cover->media;
} else {
$images = '';
}
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('id', CHtml::encode($item->album_id), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('media', CHtml::encode($images), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('title', CHtml::encode($item->title), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('body', CHtml::encode(Utility::hardDecode(Utility::softDecode($item->body))), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('url', CHtml::encode(Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('album/site/view', array('id' => $item->album_id, 't' => Utility::getUrlTitle($item->title)))), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('date', CHtml::encode(Utility::dateFormat($item->creation_date, true) . ' WIB'), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('creation', CHtml::encode($item->user->displayname), 'utf-8'));
$index->addDocument($doc);
}
return true;
}
示例15: getShareUrl
/**
* User get information
*/
public static function getShareUrl($id, $t = null)
{
if ($t != null && $t != '' && $t != '-') {
return Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->controller->createUrl('site/view', array('id' => $id, 't' => Utility::getUrlTitle($t)));
} else {
return Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->controller->createUrl('site/view', array('id' => $id));
}
}