public function actionUpdate($id)
 {
     $model = new SettingsForm();
     if (isset($_POST['SettingsForm'])) {
         $model->attributes = $_POST['SettingsForm'];
         if ($model->validate() && $model->save()) {
             $this->redirect(array('index'));
         }
     } else {
         $model->loadDataFromStore($id);
     }
     $directories = glob(Yii::getPathOfAlias('webroot.themes') . "/*", GLOB_ONLYDIR);
     $themes = array();
     foreach ($directories as $directory) {
         $themes[] = basename($directory);
     }
     $layouts = CHtml::listData(Layout::model()->findAll(), 'layout_id', 'name');
     $countries = CHtml::listData(Country::model()->findAll(), 'country_id', 'name');
     $zones = CHtml::listData(Zone::model()->findAllByAttributes(array('country_id' => $model->country)), 'zone_id', 'name');
     $languages = CHtml::listData(Language::model()->findAll(), 'language_id', 'name');
     $currencies = CHtml::listData(Currency::model()->findAll(), 'currency_id', 'title');
     $yesNoOptions = array(0 => Yii::t('settings', 'No'), 1 => Yii::t('settings', 'Yes'));
     $lengthClasses = CHtml::listData(LengthClassDescription::model()->findAll(), 'length_class_id', 'title');
     $weightClasses = CHtml::listData(WeightClassDescription::model()->findAll(), 'weight_class_id', 'title');
     $taxesOptions = array("" => Yii::t("settings", "--- None ---"), "shipping" => Yii::t("settings", "Shipping Address"), "payment" => Yii::t("settings", "Payment Address"));
     $customerGroups = CHtml::listData(CustomerGroupDescription::model()->findAll(), 'customer_group_id', 'name');
     $informations = array_merge(array(0 => Yii::t("settings", "--- None ---")), CHtml::listData(InformationDescription::model()->findAll(), 'information_id', 'title'));
     // TODO: localisation
     $orderStatuses = CHtml::listData(OrderStatus::model()->findAllByAttributes(array('language_id' => 1)), 'order_status_id', 'name');
     // TODO: localisation
     $returnStatuses = CHtml::listData(ReturnStatus::model()->findAllByAttributes(array('language_id' => 1)), 'return_status_id', 'name');
     $mailProtocols = array("mail" => Yii::t("settings", "Mail"), "smtp" => Yii::t("settings", "SMTP"));
     $this->render('update', array('model' => $model, 'themes' => $themes, 'layouts' => $layouts, 'countries' => $countries, 'zones' => $zones, 'languages' => $languages, 'currencies' => $currencies, 'yesNoOptions' => $yesNoOptions, 'lengthClasses' => $lengthClasses, 'weightClasses' => $weightClasses, 'taxesOptions' => $taxesOptions, 'customerGroups' => $customerGroups, 'informations' => $informations, 'orderStatuses' => $orderStatuses, 'returnStatuses' => $returnStatuses, 'mailProtocols' => $mailProtocols));
 }
Beispiel #2
0
 public function beginRequest(CEvent $event)
 {
     if (isset(Yii::app()->session['preferred_language'])) {
         $language = Yii::app()->session['preferred_language'];
     } else {
         $language = Yii::app()->request->getPreferredLanguage();
     }
     if ($language == 'sl_si') {
         $language = 'sl';
     }
     // echo $language, "<br />";
     $user = User::model()->find('id=:id', array(':id' => Yii::app()->user->id));
     // load locale / language / timezone
     if ($user != null && isset($user->profile->language_id)) {
         $languageObject = Language::model()->find('id=:id', array(':id' => $user->profile->language_id));
         if ($languageObject != null) {
             $language = $languageObject->short;
         }
     }
     $timezone = 'Europe/Ljubljana';
     if ($user != null && isset($user->profile->timezone) && $user->profile->timezone != '') {
         $timezone = $user->profile->timezone;
     }
     Yii::app()->language = $language;
     Yii::app()->localtime->Locale = $language;
     Yii::app()->localtime->TimeZone = $timezone;
     // routing default controller based on domain
     $sender = $event->sender;
     if ($_SERVER['HTTP_HOST'] == 'boberadmin.comcode.si' || $_SERVER['HTTP_HOST'] == 'backend.bober') {
         // default controller
     } else {
         // tekmovalni url
         $sender->defaultController = 'startCompetition';
     }
 }
 public function renderContent()
 {
     Yii::app()->clientScript->registerCssFile($this->assets . '/css/flags.css');
     $langs = Language::model()->findAll(array('order' => "id='ru' DESC"));
     if (count($langs) > 1) {
         $this->render('LanguageSwitcherAdmin', array('langs' => $langs));
     }
 }
Beispiel #4
0
 /**
  * Renseigne les valeurs par défaut pour un texte rattaché à une page donnée
  * @param int    $pageId
  * @param string $defaultName
  * @param string $defaultTitle
  * @param string $defaultContent
  */
 public function initForPage($pageId, $defaultName, $defaultTitle, $defaultContent = ' ')
 {
     $this->web_page_id = $pageId;
     $this->language_id = Language::model()->findByAttributes(array('code' => 'fr'))->id;
     $this->name = $defaultName;
     $this->title = $defaultTitle;
     $this->content = $defaultContent;
 }
Beispiel #5
0
 public function selectLanId($name)
 {
     $criteria = new CDbCriteria();
     $criteria->select = 'id';
     $criteria->condition = 'name=:name';
     $criteria->params = array(':name' => $name);
     return Language::model()->find($criteria);
 }
Beispiel #6
0
 public function actionIndex()
 {
     $criteria = new CDbCriteria();
     $criteria->select = '*';
     $criteria->order = 'name ASC';
     $this->allRec = Language::model()->findAll($criteria);
     $this->render('index');
 }
Beispiel #7
0
 public static function getList()
 {
     $languages = Yii::app()->cache->get('languages');
     if (!$languages) {
         $languages = ArrayHelper::extract(Language::model()->findAll(), 'id', 'name');
         Yii::app()->cache->set('languages', $languages);
     }
     return $languages;
 }
 function beforeAction($action)
 {
     $language = Yii::app()->session['language_frontend'];
     if (isset($language)) {
         Yii::app()->language = $language;
     } else {
         Yii::app()->language = Language::model()->find('`default`=1')->code;
         Yii::app()->session['language_frontend'] = Yii::app()->language;
     }
     return parent::beforeAction($action);
 }
 public function actionDelete($ids)
 {
     $ids = explode(',', $ids);
     if (count($ids) > 0) {
         foreach ($ids as $id) {
             $language = Language::model()->findByPk($id);
             $language->delete();
         }
     }
     $this->redirect(array('index'));
 }
 public function run()
 {
     if (isset($_GET['Language'])) {
         $languageId = $_GET['Language']['id'];
         $preferredLanguage = \Language::model()->findByPk($languageId);
         if ($preferredLanguage && $preferredLanguage->enabled) {
             /** @var \myWebUser $webUser */
             $webUser = \Yii::app()->user;
             $webUser->setLanguageCode($preferredLanguage->code);
         }
         $this->controller->redirect(\Yii::app()->request->getUrlReferrer());
     }
 }
Beispiel #11
0
 /**
  * @test
  */
 public function create()
 {
     $model = new Language();
     $model->attributes = array('code' => 'test', 'name' => 'test');
     $this->assertFalse($model->save());
     $model = new Language();
     $model->attributes = array('code' => 'te', 'name' => 'test');
     $this->assertTrue($model->save());
     $model = new Language();
     $model->attributes = array('code' => 'test', 'name' => 'aaa');
     $this->assertFalse($model->save());
     $exception = null;
     $model = new Language();
     $model->attributes = array('name' => 'aaa');
     $this->assertFalse($model->save());
     $this->assertInstanceOf('Language', Language::model());
 }
Beispiel #12
0
 /**
  *
  */
 public function init()
 {
     parent::init();
     // On règle le langage de l'application selon les indications du navigateur
     /** @var \myWebUser $webUser */
     $webUser = \Yii::app()->user;
     if (!($code = $webUser->getLanguageCode())) {
         $code = \Yii::app()->request->preferredLanguage;
     }
     if (!($preferredLanguage = \Language::findByCode($code))) {
         $preferredLanguage = \Language::findByCode(\Yii::app()->language);
     }
     $webUser->setLanguageCode($preferredLanguage->code);
     // On actualise le langage de l'application car c'est cette variable de configuration qui est lue
     // par Yii::t()
     \Yii::app()->language = $preferredLanguage->code;
     // Chargement de la liste des langues disponibles
     /** @noinspection PhpUndefinedMethodInspection */
     $this->languages = \Language::model()->enabled()->alpha()->findAll();
 }
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     if (isset($_GET['idLanguage'])) {
         $idLanguage = $_GET['idLanguage'];
     }
     if (!isset($idLanguage)) {
         $defaultLanguage = Language::model()->findByAttributes(array('code' => Yii::app()->params['defaultLanguage']));
         $idLanguage = $defaultLanguage->getPrimaryKey();
     }
     $categories = Category::model()->findAllByAttributes(array('id_language' => $idLanguage, 'is_active' => 1));
     $arrLectures = array();
     foreach ($categories as $category) {
         $criteria = new CDbCriteria();
         $criteria->order = 'created_date DESC';
         $criteria->addCondition(array(sprintf('id_category = %d', $category->getPrimaryKey()), 'is_active= 1'));
         $criteria->limit = Yii::app()->params['numberOfLecturePerCategoryInIndexPage'];
         $arrLectures[$category->getPrimaryKey()] = Lecture::model()->findAll($criteria);
     }
     $this->render('index', array('categories' => $categories, 'arrLectures' => $arrLectures));
 }
 function beforeAction($action)
 {
     $userId = Yii::app()->user->getId();
     if (User::model()->checkStatusUser($userId) == false) {
         session_unset();
         if (Yii::app()->user->isGuest) {
             Yii::app()->user->setFlash('Failure1', Yii::t('Login', 'User has been inactived or deleted by Admin'));
             $this->redirect(array('/site/login'));
         }
     }
     $language = Yii::app()->session['language'];
     if (isset($language)) {
         Yii::app()->language = $language;
     } else {
         Yii::app()->language = Language::model()->find('`default`=1')->code;
         Yii::app()->session['language'] = Yii::app()->language;
     }
     $listRoles = Yii::app()->AuthManager->getRoles(Yii::app()->user->id);
     if (array_key_exists('super user', $listRoles)) {
         return parent::beforeAction($action);
     }
     if (!Yii::app()->user->checkAccess('manager')) {
         throw new CHttpException(403, 'You are not authorized to performer.');
     }
     $controller = strtolower(Yii::app()->getController()->getId());
     $nameaction = strtolower($action->id);
     if (strtolower($controller) == 'personal') {
         return parent::beforeAction($action);
     }
     if ($controller != 'default' && $action != 'errorauth') {
         if (!Yii::app()->user->checkAccess($controller . '.' . $nameaction)) {
             $this->redirect(array('/' . backend . '/Default/ErrorAuth'));
         }
     }
     return parent::beforeAction($action);
 }
Beispiel #15
0
 public static function convertLanguage($id)
 {
     $model = Language::model()->findByPk($id);
     if ($model) {
         return $model->lang_desc;
     }
     return '';
 }
?>
    </div>
    <div class="field">
        <?php 
echo $form->label($model, 'family');
?>
        <?php 
echo $form->dropDownList($model, 'family', $states[$model->gender], array('fcselect' => true));
?>
        <?php 
echo $form->error($model, 'family');
?>
    </div>
    <div class="field">
        <?php 
echo $form->labelEx($model, 'languages');
?>
        <?php 
echo $form->checkBoxList($model, 'languages', CHtml::listData(Language::model()->findAll(), 'id', 'title'), array('container' => 'span class="checkBoxList" fcselect'));
?>
        <?php 
echo $form->error($model, 'languages');
?>
    </div>
    <div class="hr">&nbsp;</div>
    <div class="field buttons">
        <?php 
echo CHtml::submitButton(Yii::t('site', 'Сохранить'), array('class' => 'blue'));
?>
    </div>
</div>
Beispiel #17
0
<?php 
$this->breadcrumbs[] = Yii::t('crud', 'Films');
Yii::app()->clientScript->registerScript('search', "\n    \$('.search-button').click(function(){\n        \$('.search-form').toggle();\n        return false;\n    });\n    \$('.search-form form').submit(function(){\n        \$.fn.yiiGridView.update(\n            'film-grid',\n            {data: \$(this).serialize()}\n        );\n        return false;\n    });\n    ");
?>

<?php 
$this->widget("TbBreadcrumbs", array("links" => $this->breadcrumbs));
?>
<h1>
    
    <?php 
echo Yii::t('crud', 'Films');
?>
    <small><?php 
echo Yii::t('crud', 'Manage');
?>
</small>
    
</h1>

<?php 
$this->renderPartial("_toolbar", array("model" => $model));
?>



<?php 
$this->widget('TbGridView', array('id' => 'film-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'template' => '{pager}{items}{pager}{summary}', 'pager' => array('class' => 'TbPager', 'displayFirstAndLast' => true), 'columns' => array(array('class' => 'CLinkColumn', 'header' => '', 'labelExpression' => '$data->itemLabel', 'urlExpression' => 'Yii::app()->controller->createUrl("view", array("film_id" => $data["film_id"]))'), array('class' => 'editable.EditableColumn', 'name' => 'film_id', 'editable' => array('url' => $this->createUrl('/sakila/slim/film/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'title', 'editable' => array('url' => $this->createUrl('/sakila/slim/film/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'release_year', 'editable' => array('url' => $this->createUrl('/sakila/slim/film/editableSaver'))), array('name' => 'language_id', 'value' => 'CHtml::value($data,\'language.itemLabel\')', 'filter' => CHtml::listData(Language::model()->findAll(array('limit' => 1000)), 'language_id', 'itemLabel')), array('name' => 'original_language_id', 'value' => 'CHtml::value($data,\'originalLanguage.itemLabel\')', 'filter' => CHtml::listData(Language::model()->findAll(array('limit' => 1000)), 'language_id', 'itemLabel')), array('class' => 'editable.EditableColumn', 'name' => 'rental_duration', 'editable' => array('url' => $this->createUrl('/sakila/slim/film/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'rental_rate', 'editable' => array('url' => $this->createUrl('/sakila/slim/film/editableSaver'))), array('class' => 'TbButtonColumn', 'viewButtonUrl' => 'Yii::app()->controller->createUrl("view", array("film_id" => $data->film_id))', 'updateButtonUrl' => 'Yii::app()->controller->createUrl("update", array("film_id" => $data->film_id))', 'deleteButtonUrl' => 'Yii::app()->controller->createUrl("delete", array("film_id" => $data->film_id))'))));
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $langerror = 'vn';
     $activetab = 0;
     $dataId = $model->url;
     $urlType = $model->url_type;
     $model->fake_url = Yii::app()->extraFunctions->getRelativeUrl($urlType, $dataId);
     $modelMenuLanguage = new MenuLanguage('update');
     //fake model menu language
     $listMenutype = MenuType::model()->findAll('status=1 ORDER BY ordering ASC');
     $listMenuLanguage = MenuLanguage::model()->getListMenuLanguage($this->getLanguageCode(), $model->id, '0,1,2');
     $listLanguage = Language::model()->listLanguage();
     $attributeInTab = $this->convertMenuLanguageToArray($listLanguage, $model->id);
     // store records  of menu_language to array
     if (isset($_POST['Menu']) && isset($_POST['MenuLanguage'])) {
         if (!empty($_POST['Menu']['fake_url'])) {
             if ($_POST['Menu']['url_type'] != 'category' && $_POST['Menu']['url_type'] != 'post') {
                 $_POST['Menu']['url_type'] = $_POST['Menu']['fake_url'];
                 $_POST['Menu']['url'] = 1;
             }
         } else {
             $_POST['Menu']['url_type'] = NULL;
             $_POST['Menu']['url'] = NULL;
         }
         $model->attributes = $_POST['Menu'];
         //            $model->url = str_replace(PHP_EOL, '', $model->url);;
         $postMenuLanguage = $_POST['MenuLanguage'];
         $this->validateMenuLanguage($listLanguage, $postMenuLanguage, $modelMenuLanguage, $errorMessage, $attributeInTab);
         if (empty($postMenuLanguage)) {
             Yii::app()->user->setFlash('error', Yii::t('menu', 'Name, Description cannot be blank.'));
         }
         if (($errorString = $this->convertErrorMessageToString($errorMessage)) !== FALSE) {
             Yii::app()->user->setFlash('error', $errorString);
             if (strpos($errorString, 'Vietnamese') == FALSE && strpos($errorString, 'English') != FALSE) {
                 $langerror = 'en';
             }
         }
         if ($model->validate() && empty($errorMessage) && !empty($postMenuLanguage)) {
             $transaction = Yii::app()->db->beginTransaction();
             try {
                 $parent = Menu::model()->findByPK($model->parent_id);
                 if ($parent !== NULL && $parent->menu_type != 0) {
                     $model->menu_type = $parent->menu_type;
                 }
                 if ($model->saveNode()) {
                     Menu::model()->updateAll(array('menu_type' => $model->menu_type, 'status' => $model->status), 'lft BETWEEN ' . $model->lft . ' AND ' . $model->rgt);
                     foreach ($postMenuLanguage as $index => $attribute) {
                         $modelMenuLanguage = MenuLanguage::model()->find('menu_id=:id AND language_id=:language', array(':id' => $model->id, ':language' => $attribute['language_id']));
                         $modelMenuLanguage->name = $attribute['name'];
                         $modelMenuLanguage->description = str_replace(PHP_EOL, '', $attribute['description']);
                         if (!$modelMenuLanguage->save()) {
                             Yii::app()->user->setFlash('error', Yii::t('menu', 'Update menu language failed. Please try it later.'));
                             $transaction->rollback();
                         }
                     }
                     $this->resetTree();
                     $transaction->commit();
                     Yii::app()->user->setFlash('success', Yii::t('menu', 'Update menu successfully.'));
                     $this->redirect(array('/' . backend . '/menu/admin'));
                 }
             } catch (Exception $ex) {
                 $transaction->rollback();
                 Yii::app()->user->setFlash('error', Yii::t('menu', 'Update menu failed. Please try it later.'));
             }
         }
     }
     if ($langerror == 'en') {
         $activetab = 1;
     }
     $this->render(strtolower($this->action->id), array('model' => $model, 'modelMenuLanguage' => $modelMenuLanguage, 'listMenutype' => $listMenutype, 'listLanguage' => $listLanguage, 'listMenuLanguage' => $listMenuLanguage, 'attributeInTab' => $attributeInTab, 'listParentMenutype' => json_encode($listMenuLanguage['menu_type']), 'activetab' => $activetab));
 }
 public function actionUpdate($id)
 {
     $lang = $this->getLanguageCode();
     //dùng để lấy danh sách category theo ngon ngữ đả chọn
     $errorArray = NULL;
     if (!isset($_SESSION['filemanager'])) {
         $_SESSION['filemanager'] = true;
     }
     $_SESSION['currentFolder'] = 'post/';
     //tạo array để hiện thị trên dropDownList category
     $listCategory_Array = CategoryLanguage::model()->getListCategoryWithLanguage($lang);
     unset($listCategory_Array[1]);
     //load model post
     $model = $this->loadModel($id);
     //get danh sách ngôn ngữ trong csdl
     $modellanguage = Language::model()->findAll();
     //tạo ra danh sách 1 mảng để hiển thị có dạng
     /* các dữ liệu lấy ra từ trong csdl tương ứng với postid đả có
         $arr=array(
         'vn'=>array(
         'title'=>'gia tri',
         'intro_text'=>'gia tri',
         'full_text'=>'gia tri',
         )
         'en'=>array(
         'title'=>'gia tri',
         'intro_text'=>'gia tri',
         'full_text'=>'gia tri',
         )
         );
        */
     $PostLanguage = array();
     foreach ($modellanguage as $value) {
         $tempArray = PostLanguage::model()->getPostLanguageWithLangCode($value['code'], $model->id);
         if ($tempArray != NULL) {
             $PostLanguage[$value['code']] = $tempArray;
         }
     }
     if (Yii::app()->request->getPost('Post') && Yii::app()->request->getPost('Postlanguage')) {
         $Post = Yii::app()->request->getPost('Post');
         $Post['start_date'] = Yii::app()->extraFunctions->setFormatDate($Post['start_date']);
         $Post['end_date'] = Yii::app()->extraFunctions->setFormatDate($Post['end_date']);
         $model->attributes = $Post;
         $model->meta_key = $Post['meta_key'];
         $model->meta_desc = $Post['meta_desc'];
         $model->modified_date = date('Y-m-d H:i:s');
         if ($model->start_date == '') {
             $model->start_date = date('Y-m-d H:i:s');
         }
         $model->modified_by = Yii::app()->user->id;
         //cắt chuỗi lấy tên ảnh
         $thumbnailArray = explode('/', $Post['thumbnail']);
         //            $model->thumbnail = $thumbnailArray[count($thumbnailArray) - 1];
         $thumbnail_text = '';
         if (count($thumbnailArray) > 3) {
             for ($i = 3; $i < count($thumbnailArray) - 1; $i++) {
                 $thumbnail_text = $thumbnail_text . $thumbnailArray[$i] . '/';
             }
         }
         $thumbnail_text = $thumbnail_text . $thumbnailArray[count($thumbnailArray) - 1];
         $model->thumbnail = $thumbnail_text;
         $model->post_params = CJSON::encode($_POST['Post']['post_params']);
         $model->featured = $Post['featured'];
         $transaction = Yii::app()->db->beginTransaction();
         try {
             $PostLanguage = Yii::app()->request->getPost('Postlanguage');
             if ($model->validate()) {
                 if ($model->save()) {
                     //save thành công vào table Post
                     //kiểm tra save vào table post_language
                     $this->checkPostlanguage($PostLanguage, $errorArray);
                     if ($errorArray != null) {
                         throw new Exception('error');
                         //tạo ra 1 thông báo lỗi để $transaction phía trên rollback lại
                     } else {
                         if (count($PostLanguage) == 0) {
                             Yii::app()->user->setFlash('Failure', Yii::t('post', 'title,intro_text,full_text cannot be blank.'));
                             $transaction->rollback();
                         } else {
                             //nếu $errorArray==null tức là ko có lỗi
                             //phần này sẽ có các trường hợp như sau
                             //người dùng sửa dữ liệu tại 1 trường
                             //người dùng xóa đi hết dữ liệu tại 3 trường title,intro_text,full_text =>trường hợp này phải xóa luôn trong table post_language
                             //người dùng thêm 1 hoặc nhiều ngôn ngữ mới vào
                             //do đó ta sẽ tiến hành xóa đi hết tất cả các dữ liệu trong table post_language và sau đó cập nhật lại
                             //sau khi thực hiện hàm checkPostlanguage phía trên ta đả có dc list danh sách ngôn ngũ mà người dùng nhập
                             //ta tiến hành cập nhật lại từ list này
                             //xoa hết dữ liệu đả có với post_id=$model->id
                             $postl = new PostLanguage();
                             $postl->deleteAll("post_id=:id", array(':id' => $model->id));
                             //tiến hành cập nhật lại
                             foreach ($PostLanguage as $value) {
                                 $modelpostlanguage = new PostLanguage();
                                 $languageid = Language::model()->find('code=:lang', array(':lang' => $value['code']))->id;
                                 $modelpostlanguage->post_id = $model->id;
                                 //save post success, get post_id
                                 $modelpostlanguage->language_id = $languageid;
                                 $modelpostlanguage->title = $value['title'];
                                 $modelpostlanguage->intro_text = $value['intro_text'];
                                 $modelpostlanguage->full_text = $value['full_text'];
                                 $modelpostlanguage->save();
                             }
                             $transaction->commit();
                             Yii::app()->user->setFlash('Success', Yii::t('post', 'Update Success Post with id :') . $model->id);
                             //Xóa cache redis
                             // $this->deleteCacheRedis('post:' . $model->category_id);
                             $this->redirect(array('/' . backend . '/post/admin/id/' . $model->category_id));
                         }
                     }
                 }
             }
         } catch (Exception $e) {
             Yii::app()->user->setFlash('Failure', Yii::t('post', 'Update failure'));
             $transaction->rollback();
         }
     }
     $this->render('update', array('model' => $model, 'modellanguage' => $modellanguage, 'modelpostlanguage' => $PostLanguage, 'listCategory_Array' => $listCategory_Array, 'errorArray' => $errorArray));
 }
Beispiel #20
0
 public function GetLanguageIdList()
 {
     $modelData = Language::model()->search(true);
     $list = array();
     foreach ($modelData->getData() as $language) {
         $language['name'] = $language->name;
         $list[] = $language;
     }
     return $list;
 }
 /**
  * Returns the static model of the specified AR class.
  * Please note that you should have this exact method in all your CActiveRecord descendants!
  * @param string $className active record class name.
  * @return WLanguage the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
Beispiel #22
0
 /**
  * @return boolean|array CActiveRecord[]
  */
 public function getUnusedLanguages()
 {
     $usedLanguages = array();
     foreach ($this->getLanguages() as $lang) {
         $usedLanguages[] = $lang->id;
     }
     /** @noinspection PhpUndefinedMethodInspection */
     $availableLanguages = count($usedLanguages) ? Language::model()->enabled()->findAll(array('condition' => 'id NOT IN (' . implode(',', $usedLanguages) . ')')) : Language::model()->enabled()->findAll();
     return $availableLanguages;
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Language::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('app', 'The requested page does not exist.'));
     }
     return $model;
 }
Beispiel #24
0
?>
/stylesheet/intro.css" media="screen" />
        <script type="text/javascript" src="<?php 
echo Yii::app()->request->baseUrl;
?>
/js/imageflow.packed.js"></script>
    <body>
        <div id="logo">
            <img src="<?php 
echo Yii::app()->request->baseUrl;
?>
/img/logo.png" />
        </div>
        <div id="flip" class="imageflow">  
            <?php 
foreach (Language::model()->findAll() as $lang) {
    ?>
                <img src="<?php 
    echo $lang->avatar;
    ?>
" idLanguage="<?php 
    echo $lang->getPrimaryKey();
    ?>
"/>
            <?php 
}
?>
        </div>
        <div id="intro">
            <img src="<?php 
echo Yii::app()->request->baseUrl;
 /**
  * @return string
  */
 public function primaryLang()
 {
     $default_language = Language::model()->find(array('condition' => 't.default = 1 AND t.status=1'));
     return $default_language->id;
 }
Beispiel #26
0
$this->breadcrumbs = array(Yii::t('flexiblearn', 'Manage lessons') => array('lesson/admin'));
?>

<h1><?php 
echo Yii::t('flexiblearn', 'Manage lessons');
?>
</h1>
<br />
<div class="form-element">
    <?php 
echo CHtml::label(Yii::t('flexiblearn', 'Language'), '');
?>
    <?php 
$arrDataLanguages = array($this->createUrl('lesson/admin') => '');
$languages = Language::model()->findAll();
foreach ($languages as $language) {
    $url = $this->createUrl('lesson/admin', array('language_id' => $language->getPrimaryKey()));
    $arrDataLanguages[$url] = $language->name;
}
$idLanguage = Yii::app()->request->getQuery('language_id');
if ($idLanguage) {
    $url = $this->createUrl('lesson/admin', array('language_id' => $idLanguage));
} else {
    $url = $this->createUrl('lesson/admin');
}
echo CHtml::dropDownList('language_id', $url, $arrDataLanguages);
?>
</div>
<br />
<div class="form-element">
Beispiel #27
0
        <?php 
echo $form->labelEx($model, 'language_id', array('style' => 'padding-right:23px', 'class' => 'control-label col-lg-2'));
?>
        <div class="col-lg-10">
            <?php 
$listLanguage = Language::model()->listLanguage();
echo '<ul class="form-control customDropdownMenu">';
$i = 0;
foreach ($listLanguage as $key => $value) {
    if ($i === 0) {
        if ($model->isNewRecord) {
            echo $form->hiddenField($model, 'language_id', array('value' => $key));
            echo '<li id="listBox' . $i . '">';
            echo $value;
        } else {
            $currentLanguage = Language::model()->getAvailableLanguage($model->language_id);
            echo $form->hiddenField($model, 'language_id', array('value' => $model->language_id));
            echo '<li id="listBox' . $i . '">';
            if ($currentLanguage !== FALSE) {
                echo $currentLanguage;
            }
        }
        echo '</li>';
        echo '<ul class="form-control">';
    }
    echo '<li>';
    echo CHtml::hiddenField('language_id', $key);
    echo $value;
    echo '</li>';
    $i++;
}
 public function actionUpload()
 {
     parent::actionUpload();
     $folder = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->request->baseUrl . '/upload/';
     // folder for uploaded files
     $file = $folder . basename($_FILES['uploadfile']['name']);
     if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
         $row = 0;
         if (($handle = fopen($file, "r")) !== FALSE) {
             while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                 if ($row > 0) {
                     $model = Catalogsys::model()->findByPk((int) $data[0]);
                     if ($model === null) {
                         $model = new Catalogsys();
                     }
                     $model->catalogsysid = (int) $data[0];
                     $language = Language::model()->findbyattributes(array('languagename' => $data[1]));
                     if ($language !== null) {
                         $model->languageid = $language->languageid;
                     }
                     $model->catalogname = $data[2];
                     $model->catalogval = $data[3];
                     $model->recordstatus = (int) $data[4];
                     try {
                         if (!$model->save()) {
                             $this->messages = $this->messages . Catalogsys::model()->getcatalog(' upload error at ' . $data[0]);
                         }
                     } catch (Exception $e) {
                         $this->messages = $this->messages . $e->getMessage();
                     }
                 }
                 $row++;
             }
         } else {
             $this->messages = $this->messages . ' memory or harddisk full';
         }
         fclose($handle);
     } else {
         $this->messages = $this->messages . ' check your directory permission';
     }
     if ($this->messages == '') {
         $this->messages = 'success';
     }
     echo $this->messages;
 }
Beispiel #29
0
	<div class="row">
		<?php 
echo $form->label($model, 'language_id');
?>
		<?php 
echo $form->dropDownList($model, 'language_id', GxHtml::listDataEx(Language::model()->findAllAttributes(null, true)), array('prompt' => 'All'));
?>
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'original_language_id');
?>
		<?php 
echo $form->dropDownList($model, 'original_language_id', GxHtml::listDataEx(Language::model()->findAllAttributes(null, true)), array('prompt' => 'All'));
?>
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'rental_duration');
?>
		<?php 
echo $form->textField($model, 'rental_duration');
?>
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'rental_rate');
Beispiel #30
0
 public function FillQuestionResource($QuestionModel, $fileData, $fileName, $path, $file_type, $type, $start_up, $language_code, &$CurrentResources)
 {
     $language = Language::model()->find("short=:short", array(':short' => $language_code));
     if ($language == null) {
         throw new CHttpException(405, Yii::t('app', 'Language code is not exists'));
     }
     $questionResource = QuestionResource::model()->find('question_id=:question_id and language_id=:language_id and path=:path and filename=:filename', array(':question_id' => $QuestionModel->id, ':language_id' => $language->id, ':path' => $path, ':filename' => $fileName));
     if ($questionResource == null) {
         $questionResource = new QuestionResource();
         $questionResource->question_id = $QuestionModel->id;
         $questionResource->language_id = $language->id;
         $questionResource->filename = $fileName;
         $questionResource->path = $path;
     }
     $questionResource->data = $fileData;
     $questionResource->file_type = $file_type;
     $questionResource->type = $type;
     $questionResource->start_up = $start_up;
     if ($questionResource->save()) {
         //Saved OK
         $CurrentResources[$questionResource->id] = true;
     } else {
         throw new CHttpException(405, Yii::t('app', 'Save question resource failed'));
     }
 }