/** * 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(); }
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; }
/** * 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)); }
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; }
/** * 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; }
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); }
/** * 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); }
/** * 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; $this->pageMeta = ''; $this->render('front_unsubscribe', array('model' => $model, 'renderError' => $renderError, 'launch' => 2)); }
/** * 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); } } }
/** * 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); } }
/** * 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(); }
/** * 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)); }
/** * 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); } }
/** * 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; }
/** * 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)); } }
/** * Meta description and keyword generate */ protected function beforeRender($view) { $model = OmmuSettings::model()->findByPk(1, array('select' => 'site_title, site_keywords, site_description')); if (!Yii::app()->request->isAjaxRequest) { if (parent::beforeRender($view)) { // Ommu custom description and keyword if (!empty($this->pageDescription)) { $description = $this->pageDescription; } else { $description = $model->site_description; } Yii::app()->clientScript->registerMetaTag(Utility::hardDecode($description), 'description'); if (!empty($this->pageMeta)) { $keywords = $model->site_keywords . ',' . $this->pageMeta; } else { $keywords = $model->site_keywords; } Yii::app()->clientScript->registerMetaTag(Utility::hardDecode($keywords), 'keywords'); /** * Facebook open graph and all custom metatags * @title * @description * @image */ // title Yii::app()->meta->googlePlusTags['name'] = Yii::app()->meta->facebookTags['og:title'] = Yii::app()->meta->twitterTags['twitter:title'] = CHtml::encode($this->pageTitle) . ' | ' . $model->site_title; // description Yii::app()->meta->googlePlusTags['description'] = Yii::app()->meta->facebookTags['og:description'] = Yii::app()->meta->twitterTags['twitter:description'] = ucfirst(strtolower($description)); // image if (!empty($this->pageImage)) { Yii::app()->meta->facebookTags['og:image'] = Yii::app()->meta->googlePlusTags['image'] = Yii::app()->meta->twitterTags['twitter:image:src'] = Utility::getProtocol() . '://' . Yii::app()->request->serverName . $this->pageImage; } // language $this->lang = Utility::getLanguage(); Yii::app()->setLanguage($this->lang); } } else { $this->pageDescription = $this->pageDescription != '' ? ucfirst(strtolower($this->pageDescription)) : $model->site_description; $this->pageMeta = $this->pageMeta != '' ? $model->site_keywords . ', ' . $this->pageMeta : $model->site_keywords; } $this->pageTitle = $this->pageTitle != '' ? $this->pageTitle : 'Titlenya Lupa..'; return true; }
/** * Initialize * * load some custom components here, for example * theme, url manager, or config from database Alhamdulillah :) */ public function init() { /** * set default themes */ $theme = $this->getDefaultTheme(); if (isset($_GET['theme'])) { $theme = trim($_GET['theme']); } Yii::app()->theme = $theme; /** * controllerMap */ $themePath = Yii::getPathOfAlias('webroot.themes.' . $theme) . DS . $theme . '.yaml'; $arrayThemeSpyc = Spyc::YAMLLoad($themePath); $controllerSpyc = $arrayThemeSpyc['controller']; if (!empty($controllerSpyc)) { foreach ($controllerSpyc as $key => $val) { $controllerMap[$key] = 'webroot.themes.' . $theme . '.controllers.' . $val; } Yii::app()->controllerMap = $controllerMap; } /** * set url manager */ $rules = array('' => 'site/index', '<action:(login|logout)>' => 'site/<action>', '<id:\\d+>-<t:[\\w\\-]+>-<a:[\\w\\-]+>' => 'page/view', '<id:\\d+>-<t:[\\w\\-]+>' => 'page/view', '<module:\\w+>/<controller:\\w+>/<t:[\\w\\-]+>-<id:\\d+>-<category:\\d+>' => '<module>/<controller>/index', '<module:\\w+>/<controller:\\w+>/<t:[\\w\\-]+>-<category:\\d+>' => '<module>/<controller>/index', '<module:\\w+>/<controller:\\w+>/<t:[\\w\\-]+>-<id:\\d+>' => '<module>/<controller>/index', '<module:\\w+>/<controller:\\w+>/<id:\\d+>' => '<module>/<controller>/index', '<module:\\w+>/<controller:\\w+>' => '<module>/<controller>/index', '<module:\\w+>/<controller:\\w+>/view/<t:[\\w\\-]+>-<id:\\d+>-<photo:\\d+>' => '<module>/<controller>/view', '<module:\\w+>/<controller:\\w+>/view/<t:[\\w\\-]+>-<id:\\d+>' => '<module>/<controller>/view', '<module:\\w+>/<controller:\\w+>/<action:\\w+>/<t:[\\w\\-]+>-<id:\\d+>' => '<module>/<controller>/<action>', '<module:\\w+>/<controller:\\w+>/<action:\\w+>/<id:\\d+>' => '<module>/<controller>/<action>', '<module:\\w+>/<controller:\\w+>/<action:\\w+>' => '<module>/<controller>/<action>', '<module:\\w+>/<controller:\\w+>' => '<module>/<controller>', '<controller:\\w+>/<t:[\\w\\-]+>-<id:\\d+>-<category:\\d+>' => '<controller>/index', '<controller:\\w+>/<t:[\\w\\-]+>-<category:\\d+>' => '<controller>/index', '<controller:\\w+>/<t:[\\w\\-]+>-<id:\\d+>' => '<controller>/index', '<controller:\\w+>/<id:\\d+>' => '<controller>/index', '<controller:\\w+>' => '<controller>/index', '<controller:\\w+>/view/<t:[\\w\\-]+>-<id:\\d+>-<photo:\\d+>' => '<controller>/view', '<controller:\\w+>/view/<t:[\\w\\-]+>-<id:\\d+>' => '<controller>/view', '<controller:\\w+>/<action:\\w+>/<t:[\\w\\-]+>-<id:\\d+>' => '<controller>/<action>', '<controller:\\w+>/<action:\\w+>/<id:\\d+>' => '<controller>/<action>', '<controller:\\w+>/<action:\\w+>' => '<controller>/<action>', '<controller:\\w+>' => '<controller>'); /** * Set default controller for homepage, it can be controller, action or module * example: * controller: 'site' * controller from module: 'pose/site/index'. */ $default = OmmuPlugins::model()->findByAttributes(array('defaults' => 1), array('select' => 'folder')); if ($default == null || $default->folder == '-' || $default->actived == '2') { $rules[''] = 'site/index'; } else { $url = $default->folder != '-' ? $default->folder : 'site/index'; Yii::app()->defaultController = trim($url); $rules[''] = trim($url); } /** * Split rules into 2 part and then insert url from tabel between them. * and then merge all array back to $rules. */ $module = OmmuPlugins::model()->findAll(array('select' => 'folder', 'condition' => 'actived != 0')); $moduleRules = array(); $sliceRules = $this->getRulePos($rules); if ($module !== null) { foreach ($module as $key => $val) { $moduleRules[$val->folder] = $val->folder; } } $rules = array_merge($sliceRules['before'], $moduleRules, $sliceRules['after']); Yii::app()->setComponents(array('urlManager' => array('urlFormat' => 'path', 'showScriptName' => false, 'rules' => $rules))); Yii::setPathOfAlias('modules', Yii::app()->basePath . DIRECTORY_SEPARATOR . 'modules'); /** * Registers meta tags declared * google discoverability * google plus * facebook opengraph * twitter */ $meta = OmmuMeta::model()->findByPk(1); $images = $meta->meta_image != '' ? $meta->meta_image : 'meta_default.png'; $metaImages = Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->request->baseUrl . '/public/' . $images; // Google Discoverability mata tags $point = explode(',', $meta->office_location); // Facebook mata tags $arrayFacebookGlobal = array('og:type' => $meta->facebook_type == 1 ? 'profile' : 'website', 'og:title' => 'MY_WEBSITE_NAME', 'og:description' => 'MY_WEBSITE_DESCRIPTION', 'og:image' => $metaImages); if ($meta->facebook_sitename != '') { $arrayFacebookGlobal['og:site_name'] = $meta->facebook_sitename; } if ($meta->facebook_see_also != '') { $arrayFacebookGlobal['og:see_also'] = $meta->facebook_see_also; } if ($meta->facebook_admins != '') { $arrayFacebookGlobal['fb:admins'] = $meta->facebook_admins; } if ($meta->facebook_type == 1) { $arrayFacebook = array('profile:first_name' => $meta->facebook_profile_firstname, 'profile:last_name' => $meta->facebook_profile_lastname, 'profile:username' => $meta->facebook_profile_username); } else { $arrayFacebook = array(); } // Twitter mata tags if ($meta->twitter_card == 1) { $cardType = 'summary'; $arrayTwitter = array(); } else { if ($meta->twitter_card == 2) { $cardType = 'summary_large_image'; $arrayTwitter = array(); } else { if ($meta->twitter_card == 3) { $cardType = 'photo'; $arrayTwitter = array('twitter:image:width' => $meta->twitter_photo_width, 'twitter:image:height' => $meta->twitter_photo_height); } else { $cardType = 'app'; if ($meta->twitter_country != '') { $arrayTwitter['twitter:app:country'] = $meta->twitter_country; } if ($meta->twitter_iphone_name != '') { $arrayTwitter['twitter:app:name:iphone'] = $meta->twitter_iphone_name; } if ($meta->twitter_iphone_id != '') { $arrayTwitter['twitter:app:id:iphone'] = $meta->twitter_iphone_id; } if ($meta->twitter_iphone_url != '') { $arrayTwitter['twitter:app:url:iphone'] = $meta->twitter_iphone_url; } if ($meta->twitter_ipad_name != '') { $arrayTwitter['twitter:app:name:ipad'] = $meta->twitter_ipad_name; } if ($meta->twitter_ipad_id != '') { $arrayTwitter['twitter:app:id:ipad'] = $meta->twitter_ipad_id; } if ($meta->twitter_ipad_url != '') { $arrayTwitter['twitter:app:url:ipad'] = $meta->twitter_ipad_url; } if ($meta->twitter_googleplay_name != '') { $arrayTwitter['twitter:app:name:googleplay'] = $meta->twitter_googleplay_name; } if ($meta->twitter_googleplay_id != '') { $arrayTwitter['twitter:app:id:googleplay'] = $meta->twitter_googleplay_id; } if ($meta->twitter_googleplay_url != '') { $arrayTwitter['twitter:app:url:googleplay'] = $meta->twitter_googleplay_url; } if (empty($arrayTwitter)) { $arrayTwitter = array(); } } } } $arrayTwitterGlobal = array('twitter:card' => $cardType, 'twitter:site' => $meta->twitter_site, 'twitter:title' => 'MY_WEBSITE_NAME', 'twitter:description' => 'MY_WEBSITE_DESCRIPTION', 'twitter:image' => $metaImages); if (in_array($meta->twitter_card, array(2))) { $arrayTwitterGlobal['twitter:creator'] = $meta->twitter_creator; } if ($meta->meta_image_alt != '' && in_array($meta->meta_image_alt, array(1, 2))) { $arrayTwitterGlobal['twitter:image:alt'] = $meta->meta_image_alt; } /** * Registe Meta Tags */ Yii::app()->setComponents(array('meta' => array('class' => 'application.components.plugin.MetaTags', 'googleOwnerTags' => array('place:location:latitude' => $point[0], 'place:location:longitude' => $point[1], 'business:contact_data:street_address' => $meta->office_place . ', ' . $meta->office_village . ', ' . $meta->office_district, 'business:contact_data:country_name' => $meta->view_meta->country, 'business:contact_data:locality' => $meta->view_meta->city, 'business:contact_data:region' => $meta->office_district, 'business:contact_data:postal_code' => $meta->office_zipcode, 'business:contact_data:email' => $meta->office_email, 'business:contact_data:phone_number' => $meta->office_phone, 'business:contact_data:fax_number' => $meta->office_fax, 'business:contact_data:website' => $meta->office_website), 'googlePlusTags' => array('name' => 'MY_WEBSITE_NAME', 'description' => 'MY_WEBSITE_DESCRIPTION', 'image' => $metaImages), 'facebookTags' => CMap::mergeArray($arrayFacebookGlobal, $arrayFacebook), 'twitterTags' => CMap::mergeArray($arrayTwitterGlobal, $arrayTwitter)))); }
$dialogWidth = !empty($this->dialogWidth) ? $this->dialogFixed == false ? $this->dialogWidth . 'px' : '600px' : '900px'; } else { if ($this->dialogDetail == true) { $dialogWidth = !empty($this->dialogWidth) ? $this->dialogFixed == false ? $this->dialogWidth . 'px' : '600px' : '700px'; } else { $dialogWidth = ''; } } $display = $this->dialogDetail == true && !Yii::app()->request->isAjaxRequest ? 'style="display: block;"' : ''; /** * = pushState condition */ $title = CHtml::encode($this->pageTitle) . ' | ' . $setting->site_title; $description = $this->pageDescription; $keywords = $this->pageMeta; $urlAddress = Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->request->requestUri; $apps = $this->dialogDetail == true ? $this->dialogFixed == false ? 'apps' : 'module' : ''; $main = false; if ($module == null && $currentAction == 'site/index') { $main = true; } if (Yii::app()->request->isAjaxRequest && !isset($_GET['ajax'])) { if (Yii::app()->session['theme_active'] != Yii::app()->theme->name) { $return = array('redirect' => $urlAddress); } else { $page = $this->contentOther == true ? 1 : 0; $dialog = $this->dialogDetail == true ? empty($this->dialogWidth) ? 1 : 2 : 0; // 0 = static, 1 = dialog, 2 = notifier $header = ''; if ($this->contentOther == true) { $render = array('content' => $content, 'other' => $this->contentAttribute);