本文整理汇总了PHP中Phrase类的典型用法代码示例。如果您正苦于以下问题:PHP Phrase类的具体用法?PHP Phrase怎么用?PHP Phrase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Phrase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_default
public static function get_default($phrase, $filter)
{
$default = Phrase::factory()->where("phrase", $phrase)->where("filter", $filter)->where_related_language(Language::get_default())->get();
if (!$default->exists()) {
$default->phrase = $default->translation = $phrase;
$default->filter = $filter;
$default->save(array(Language::get_default()));
}
return $default;
}
示例2: phrase
public function phrase($phrase, $filter)
{
$tr = $this->get_translation($phrase, $filter);
//var_dump($tr);
//die;
if ($tr) {
return $tr;
} else {
//save for curr. language
if ($this->language->id != Language::get_default()->id) {
$newphr = Phrase::factory()->where('phrase', $phrase)->where_related_language($this->language)->limit(1)->get();
$newphr->phrase = $phrase;
$newphr->filter = $filter;
$newphr->save($this->language);
}
//return default
return Phrase::get_default($phrase, $filter)->translation;
}
/* $phrase_obj = Phrase::factory()
->where("phrase", $phrase)
->where("filter", $filter)
->where_related_language($this->language)
->get();
if ($phrase_obj->exists())
{
if (trim($phrase_obj->translation) != "")
return $phrase_obj->translation;
else
return Phrase::get_default($phrase, $filter)->translation;
}
else
{
//save for curr. language
if ($this->language->id != Language::get_default()->id)
{
$newphr = new Phrase();
$newphr->phrase = $phrase;
$newphr->filter = $filter;
$newphr->save($this->language);
}
//return default
return Phrase::get_default($phrase, $filter)->translation;
}//*/
}
示例3: actionIndex
/**
* Lists all models.
*/
public function actionIndex()
{
$setting = ArticleSetting::model()->findByPk(1, array('select' => 'meta_description, meta_keyword'));
if (isset($_GET['category']) && $_GET['category'] != '') {
$title = ArticleCategory::model()->findByPk($_GET['category']);
}
$criteria = new CDbCriteria();
$criteria->condition = 'publish = :publish AND published_date <= curdate()';
$criteria->params = array(':publish' => 1);
$criteria->order = 'published_date DESC';
if (isset($_GET['category']) && $_GET['category'] != '') {
$criteria->compare('cat_id', $_GET['category']);
}
$dataProvider = new CActiveDataProvider('Articles', array('criteria' => $criteria, 'pagination' => array('pageSize' => 10)));
$this->pageTitle = 'Articles';
$this->pageDescription = isset($_GET['category']) && $_GET['category'] != '' ? Phrase::trans($title->name, 2) : $setting->meta_description;
$this->pageMeta = isset($_GET['category']) && $_GET['category'] != '' ? Phrase::trans($title->desc, 2) : $setting->meta_keyword;
$this->render('front_index', array('dataProvider' => $dataProvider));
}
示例4: actionDefault
/**
* 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 actionDefault($id)
{
$model = $this->loadModel($id);
if (Yii::app()->request->isPostRequest) {
// we only allow deletion via POST request
if (isset($id)) {
//change value active or publish
$model->defaults = 1;
if ($model->update()) {
echo CJSON::encode(array('type' => 5, 'get' => Yii::app()->controller->createUrl('manage'), 'id' => 'partial-levels', 'msg' => '<div class="errorSummary success"><strong>' . Phrase::trans(16007, 1) . '</strong></div>'));
}
}
} else {
$this->dialogDetail = true;
$this->dialogGroundUrl = Yii::app()->controller->createUrl('manage');
$this->dialogWidth = 350;
$this->pageTitle = Yii::t('phrase', 'Default');
$this->pageDescription = '';
$this->pageMeta = '';
$this->render('admin_default', array('model' => $model));
}
}
示例5: actionGet
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionGet()
{
$model = new UserForgot();
// Uncomment the following line if AJAX validation is needed
$this->performAjaxValidation($model);
if (isset($_POST['UserForgot'])) {
$model->attributes = $_POST['UserForgot'];
$model->scenario = 'get';
$jsonError = CActiveForm::validate($model);
if (strlen($jsonError) > 2) {
echo $jsonError;
} else {
if (isset($_GET['enablesave']) && $_GET['enablesave'] == 1) {
if ($model->save()) {
echo CJSON::encode(array('type' => 5, 'get' => Yii::app()->controller->createUrl('get', array('name' => urlencode($model->user->displayname), 'email' => $model->user->email))));
} else {
print_r($model->getErrors());
}
}
}
Yii::app()->end();
}
if (isset($_GET['name']) && isset($_GET['email'])) {
if (isset($_GET['type']) && $_GET['type'] == 'success') {
$desc = Phrase::trans(16191, 1);
} else {
$desc = Phrase::trans(16187, 1, array($_GET['name'], $_GET['email']));
}
} else {
$desc = Phrase::trans(16185, 1);
}
$this->dialogDetail = true;
$this->dialogGroundUrl = Yii::app()->createUrl('site/index');
$this->pageTitle = Phrase::trans(16184, 1);
$this->pageDescription = $desc;
$this->pageMeta = '';
$this->render('front_get', array('model' => $model));
}
示例6: array
<?php
/**
* User Forgot (user-forgot)
* @var $this ForgotController
* @var $model UserForgot
* @var $form CActiveForm
*
* @author Putra Sudaryanto <putra@sudaryanto.id>
* @copyright Copyright (c) 2012 Ommu Platform (ommu.co)
* @link https://github.com/oMMu/Ommu-Users
* @contact (+62)856-299-4114
*
*/
$this->breadcrumbs = array('User Forgots' => array('manage'), 'Create');
if (isset($_GET['name']) && isset($_GET['email'])) {
if (isset($_GET['type']) && $_GET['type'] == 'success') {
echo '<a class="button" href="' . Yii::app()->createUrl('site/login') . '" title="' . Phrase::trans(1006, 2) . '">' . Phrase::trans(1006, 2) . '</a>';
}
} else {
echo $this->renderPartial('_form', array('model' => $model));
}
示例7:
<?php
if ($model->media != '') {
$images = Yii::app()->request->baseUrl . '/public/page/' . $model->media;
} else {
$images = Yii::app()->request->baseUrl . '/public/page/page_default.png';
}
?>
<div class="clearfix">
<div class="sep">
<img src="<?php
echo Utility::getTimThumb($images, 300, 300, 1);
?>
" alt="<?php
echo Phrase::trans($model->name, 2);
?>
">
<?php
echo Phrase::trans($model->quote, 2);
?>
</div>
<div class="sep"><?php
echo Phrase::trans($model->name, 2) != Utility::hardDecode(Phrase::trans($model->desc, 2)) ? Utility::cleanImageContent(Phrase::trans($model->desc, 2)) : '';
?>
</div>
</div>
示例8: beforeValidate
/**
* before validate attributes
*/
protected function beforeValidate()
{
$module = strtolower(Yii::app()->controller->module->id);
$controller = strtolower(Yii::app()->controller->id);
if (parent::beforeValidate()) {
if ($this->email != '') {
$model = UserInviteQueue::model()->findByAttributes(array('email' => strtolower($this->email)), array('select' => 'queue_id, member_id, invite'));
if ($model == null) {
// email belum masuk daftar invite
$invite = new UserInviteQueue();
$invite->email = $this->email;
if ($invite->save()) {
$this->queue_id = $invite->queue_id;
}
} else {
// email sudah dalam daftar invite
if ($module != null && $module == 'users' && $controller == 'invite') {
if ($model->member_id != 0) {
// email sudah menjadi member
$this->addError('email', Phrase::trans(16213, 1));
} else {
// email belum menjadi member
$invite = self::model()->with('queue')->find(array('select' => 'invite_id', 'condition' => 'queue.email = :email AND t.user_id = :user', 'params' => array(':email' => strtolower($this->email), ':user' => Yii::app()->user->id)));
if ($invite == null) {
$this->queue_id = $model->queue_id;
} else {
// email sudah invite sebelumnya
$this->addError('email', Phrase::trans(16212, 1));
}
}
}
}
}
if ($this->isNewRecord) {
$this->user_id = Yii::app()->user->id;
$this->code = self::getUniqueCode();
$this->invite_ip = $_SERVER['REMOTE_ADDR'];
}
}
return true;
}
示例9: attributeLabels
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array('id' => Phrase::trans(26080, 1), 'article_id' => Phrase::trans(26000, 1), 'tag_id' => Phrase::trans(26080, 1), 'article_search' => Phrase::trans(26000, 1), 'tag_search' => Phrase::trans(26080, 1), 'creation_date' => Phrase::trans(26069, 1), 'creation_search' => 'Creation');
}
示例10: approveEditsByContributor
public static function approveEditsByContributor($repositoryID, $languageID, $contributorID)
{
$edits = self::getPendingEditsByRepositoryLanguageAndUser($repositoryID, $languageID, $contributorID);
foreach ($edits as $edit) {
$previousPhraseData = Database::getPhrase($repositoryID, $languageID, $edit['phraseKey']);
if (empty($previousPhraseData)) {
$phraseObject = Phrase::create(0, $edit['phraseKey'], $edit['payload'], 0, true);
} else {
$phraseObject = Phrase::create(0, $edit['phraseKey'], $previousPhraseData['payload'], 0);
}
$phraseObject->setPhraseValue($edit['phraseSubKey'], $edit['suggestedValue']);
self::updatePhrase($repositoryID, $languageID, $edit['phraseKey'], $phraseObject->getPayload());
self::updateContributor($repositoryID, $edit['userID']);
self::deleteEdit($edit['id']);
}
Authentication::setCachedLanguageProgress($repositoryID, NULL);
// unset cached version of this repository's progress
}
示例11: array
<?php
/**
* Banners (banners)
* @var $this AdminController
* @var $model Banners
*
* @author Putra Sudaryanto <putra@sudaryanto.id>
* @copyright Copyright (c) 2014 Ommu Platform (ommu.co)
* @link https://github.com/oMMu/Ommu-Banner
* @contect (+62)856-299-4114
*
*/
$this->breadcrumbs = array('Banners' => array('manage'), $model->title);
?>
<div class="box">
<?php
$this->widget('application.components.system.FDetailView', array('data' => $model, 'attributes' => array(array('name' => 'cat_id', 'value' => Phrase::trans($model->category_relation->name, 2)), 'title', array('name' => 'url', 'value' => CHtml::link($model->url, $model->url, array('target' => '_blank')), 'type' => 'raw'), array('name' => 'url', 'value' => CHtml::link($model->media, Yii::app()->request->baseUrl . '/public/banner/' . $model->media, array('target' => '_blank')), 'type' => 'raw'), array('name' => 'published_date', 'value' => Utility::dateFormat($model->published_date)), array('name' => 'expired_date', 'value' => Utility::dateFormat($model->expired_date)), 'view', 'click', array('name' => 'creation_date', 'value' => Utility::dateFormat($model->creation_date, true)), array('name' => 'creation_id', 'value' => $model->creation_relation->displayname), array('name' => 'modified_date', 'value' => Utility::dateFormat($model->modified_date, true)), array('name' => 'modified_id', 'value' => $model->modified_relation->displayname), array('name' => 'publish', 'value' => $model->publish == 1 ? Chtml::image(Yii::app()->theme->baseUrl . '/images/icons/publish.png') : Chtml::image(Yii::app()->theme->baseUrl . '/images/icons/unpublish.png'), 'type' => 'raw'))));
?>
</div>
示例12: foreach
<?php
if ($model != null) {
?>
<ul>
<?php
echo '<li><a href="' . Yii::app()->controller->createUrl('index') . '" title="' . Yii::t('phrase', 'All') . '">' . Yii::t('phrase', 'All') . '</a></li>';
foreach ($model as $key => $val) {
echo '<li><a href="' . Yii::app()->controller->createUrl('index', array('cat' => $val->cat_id, 't' => Utility::getUrlTitle(Phrase::trans($val->name, 2)))) . '" title="' . Phrase::trans($val->name, 2) . '">' . Phrase::trans($val->name, 2) . '</a></li>';
}
?>
</ul>
<?php
}
示例13: array
$model->title = Phrase::trans($model->name, 2);
echo $form->textField($model, 'title', array('maxlength' => 32, 'class' => 'span-7'));
?>
<?php
echo $form->error($model, 'title');
?>
</div>
</div>
<div class="clearfix">
<?php
echo $form->labelEx($model, 'description');
?>
<div class="desc">
<?php
$model->description = Phrase::trans($model->desc, 2);
echo $form->textArea($model, 'description', array('rows' => 6, 'cols' => 50, 'class' => 'span-9 smaller'));
?>
<?php
echo $form->error($model, 'description');
?>
</div>
</div>
<div class="clearfix publish">
<?php
echo $form->labelEx($model, 'defaults');
?>
<div class="desc">
<?php
echo $form->checkBox($model, 'defaults');
示例14: array
<div class="clearfix message">
<div class="desc">
<?php
echo $form->textArea($model, 'message', array('rows' => 6, 'cols' => 50));
?>
<?php
echo $form->error($model, 'message');
?>
</div>
</div>
<div class="submit clearfix">
<label> </label>
<div class="desc">
<?php
echo CHtml::submitButton($model->isNewRecord ? Phrase::trans(328, 0) : Phrase::trans(328, 0), array('onclick' => 'setEnableSave()'));
?>
</div>
</div>
</fieldset>
<?php
$this->endWidget();
?>
</div>
<?php
}
?>
<?php
//end.Contact Form
?>
示例15: sortUntranslatedFirstCompare
/**
* Comparator for phrases so that empty phrases are shown first
*
* @param Phrase $a
* @param Phrase $b
* @return int 1 if $a is less complete then $b, 0 if both are equally complete, and -1 otherwise
*/
public static function sortUntranslatedFirstCompare($a, $b)
{
$aCompletenessData = $a->getCompleteness();
$aCompleteness = $aCompletenessData[0] / $aCompletenessData[1];
$bCompletenessData = $b->getCompleteness();
$bCompleteness = $bCompletenessData[0] / $bCompletenessData[1];
if ($aCompleteness == $bCompleteness) {
$res = 0;
return $res;
} else {
$res = $aCompleteness > $bCompleteness ? 1 : -1;
return $res;
}
}