当前位置: 首页>>代码示例>>PHP>>正文


PHP Translation::model方法代码示例

本文整理汇总了PHP中Translation::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Translation::model方法的具体用法?PHP Translation::model怎么用?PHP Translation::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Translation的用法示例。


在下文中一共展示了Translation::model方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: showLangModal

 public function showLangModal()
 {
     $language = Yii::app()->params['language'];
     $this->beginWidget('bootstrap.widgets.TbModal', array('id' => $this->modalId, 'htmlOptions' => array('style' => 'margin-top:-200px;', 'backdrop' => 'static')));
     echo "<div class=\"modal-header\">\n                <h4 style=\"width:30%;display: inline-block;\">翻译</h4> \n                <span id='" . $this->modalId . "message' style=\"margin-left:30px;color:red;\"></span>\n            </div>";
     echo "<div id='" . $this->modalId . "ModalBody' class=\"modal-body\" style=\"text-align:center\">";
     $tableName = $this->model->tableName();
     $attribute = $this->attribute;
     echo CHtml::hiddenField('tableName', $tableName);
     echo CHtml::hiddenField('attribute', $attribute);
     $pk = $this->model->primaryKey;
     echo CHtml::activeHiddenField($this->model, $this->model->pk, array('name' => 'pk'));
     $result = Translation::model()->find('model=:tableName and pk=:pk and attribute=:attribute', array(':tableName' => $tableName, ':pk' => $pk, ':attribute' => $attribute));
     $data = json_decode($result->data);
     foreach ($language as $key => $value) {
         if (strtolower($key) == 'zh_cn') {
             continue;
         }
         echo "<div><span style='width:80px !important;display: inline-block;'>" . $value . '</span>' . CHtml::textField($key, $data->{$key}) . "</div>";
     }
     echo "</div>";
     echo "<div class=\"modal-footer\" style=\"text-align: center;\">";
     $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'button', 'type' => 'info', 'label' => '保存', 'htmlOptions' => array('id' => $this->modalId . 'save')));
     echo "&nbsp;";
     $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'button', 'label' => '取消', 'htmlOptions' => array("data-dismiss" => "modal", 'id' => $this->modalId . 'back')));
     echo "</div>";
     $this->endWidget();
 }
开发者ID:GsHatRed,项目名称:Yiitest,代码行数:28,代码来源:TTranslate.php

示例2: run

 public function run()
 {
     if (Yii::app()->request->getPost('table')) {
         $table = Yii::app()->request->getPost('table');
     } else {
         $table = 'location';
     }
     if (Yii::app()->request->getPost('lan_id')) {
         $lan_id = Yii::app()->request->getPost('lan_id');
     } else {
         $lan_id = 2;
         //en
     }
     $dbmodel = ucfirst($table);
     $row = $dbmodel::model()->selectAll();
     $translateRow = Translation::model()->select($table, $row['subject'][0], $lan_id);
     foreach ($row as $k => $r) {
         $row[$k]['translate'] = isset($translateRow[$k]) ? $translateRow[$k]['translate'] : '';
         $row[$k]['translate_id'] = isset($translateRow[$k]) ? $translateRow[$k]['id'] : '';
     }
     echo CJSON::encode($this->controller->renderPartial('translationUser', array('row' => $row, 'table' => $table, 'column' => $row['subject'][0], 'lan_id' => $lan_id), true, true));
     Yii::app()->end();
 }
开发者ID:vasia-ostapchuk,项目名称:source,代码行数:23,代码来源:ViewTranslateAction.php

示例3: actionTranslations

 public function actionTranslations($id, $book_id)
 {
     $user = $this->loadUser($id);
     $book = Book::model()->with("membership")->findByPk((int) $book_id);
     if (!$book) {
         throw new CHttpException(404, "Перевода не существует. Вероятно, он удалён.");
     }
     if (!$book->can("read")) {
         throw new CHttpException(403, "Вы не можете просматривать версии перевода в этом проекте. " . $book->getWhoCanDoIt("read", false));
     }
     if (!$book->can("trread")) {
         throw new CHttpException(403, "Вы не можете просматривать версии перевода в этом проекте. " . $book->getWhoCanDoIt("trread", false));
     }
     $translations = new CActiveDataProvider(Translation::model()->userbook($user->id, $book->id)->with("orig.chap"), array("criteria" => array("order" => "t.cdate desc"), "pagination" => array("pageSize" => 20)));
     $this->side_view = array("profile_side" => array("user" => $user, "userinfo" => $user->userinfo));
     $this->render("translations", array("user" => $user, "book" => $book, "translations" => $translations));
 }
开发者ID:norayr,项目名称:notabenoid,代码行数:17,代码来源:UsersController.php

示例4: getTranslationFromWordOnSomeLng

 public static function getTranslationFromWordOnSomeLng($str, $toLng)
 {
     /* @var $lng TranslationLng */
     /* @var $word Translation */
     /* @var $neededWord Translation */
     $ret = "";
     $neededWord = null;
     $allWords = Translation::model()->findAll();
     foreach ($allWords as $word) {
         foreach (Constants::GetLngArray() as $lngIndex => $lng) {
             $strWord = $word->getWordByLng($lng);
             if ($str == $strWord) {
                 $neededWord = $word;
             }
         }
     }
     if ($neededWord != null) {
         $ret = $neededWord->getWordByLng($toLng);
     } else {
         $ret = $str;
     }
     return $ret;
 }
开发者ID:ruslankus,项目名称:inlux-transfer,代码行数:23,代码来源:Translation.php

示例5: actionTr_rm

 public function actionTr_rm($book_id, $chap_id, $orig_id)
 {
     $chap = $this->loadChapter($book_id, $chap_id);
     $user = Yii::app()->user;
     /** @var Translation $tr  */
     $tr = Translation::model()->findByPk((int) $_POST["tr_id"], array("condition" => "chap_id = :chap_id AND book_id = :book_id", "params" => array(":chap_id" => $chap->id, ":book_id" => $chap->book_id)));
     if (!$tr) {
         throw new CHttpException(404, "Этот вариант перевода уже удалили.");
     }
     $tr->chap = $chap;
     if ($tr->user_id != $user->id && $chap->book->membership->status != GroupMember::MODERATOR) {
         throw new CHttpException(403, "Только модераторы могут удалять чужие переводы.");
     }
     if ($tr->delete()) {
         $chap->setModified();
     }
     echo json_encode(array("status" => "ok", "tr_id" => $tr->id, "n_vars" => $chap->n_vars, "d_vars" => $chap->d_vars, "n_verses" => $chap->n_verses));
 }
开发者ID:norayr,项目名称:notabenoid,代码行数:18,代码来源:OrigController.php

示例6: actionRating_explain

 /**
  * Отдаёт список проголосовавших за вариант перевода $_GET["id"] в JSON
  * @param $book_id
  * @param $chap_id
  * @throws CHttpException
  */
 public function actionRating_explain($book_id, $chap_id)
 {
     $chap = $this->loadChapter($book_id, $chap_id);
     /** @var Translation $tr */
     $tr = Translation::model()->with("marks.user")->findByPk((int) $_GET["id"]);
     if (!$tr) {
         throw new CHttpException(404, "Версия перевода удалена.");
     }
     // Проверяем, верны ли показания в translate.rating и translate.n_votes, раз уж мы всё равно загрузили все оценки
     $n_votes = count($tr->marks);
     $rating = 0;
     foreach ($tr->marks as $mark) {
         $rating += $mark->mark;
     }
     // Autofix: translate.rating, translate.n_votes
     if ($n_votes != $tr->n_votes || $rating != $tr->rating) {
         $tr->n_votes = $n_votes;
         $tr->rating = $rating;
         $tr->save(false, array("rating", "n_votes"));
     }
     $json = array();
     foreach (array_reverse($tr->marks) as $mark) {
         $json[] = array("id" => $mark->user->id, "login" => $mark->user->login, "mark" => $mark->mark);
     }
     echo json_encode($json);
 }
开发者ID:norayr,项目名称:notabenoid,代码行数:32,代码来源:ChapterController.php

示例7: actionTransdel

 public function actionTransdel()
 {
     /* @var $word Translation */
     //get id from request
     $id = Yii::app()->request->getParam('id', null);
     //get word by id
     $word = Translation::model()->findByPk($id);
     //if not found - redirect to index
     if ($word == null) {
         $this->redirect($this->createUrl('/admin/panel/index'));
     }
     //delete
     $word->deleteLng();
     $word->delete();
     //redirect to list
     $this->redirect($this->createUrl('/admin/panel/translations'));
 }
开发者ID:ruslankus,项目名称:inlux-transfer,代码行数:17,代码来源:PanelController.php


注:本文中的Translation::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。