public function actionUpdate($category = null, $message = null, $language = null)
 {
     $models = array();
     foreach (Yum::getAvailableLanguages() as $language) {
         $models[] = $this->loadModel($category, $message, $language);
     }
     if (isset($_POST['YumTranslation'])) {
         $category = $_POST['YumTranslation']['category'];
         $message = $_POST['YumTranslation']['message'];
         foreach ($_POST as $key => $translation) {
             if (substr($key, 0, 11) == 'translation') {
                 $lang = explode('_', $key);
                 if (isset($lang[1])) {
                     $lang = $lang[1];
                     foreach (Yum::getAvailableLanguages() as $language) {
                         if ($language == $lang) {
                             $model = YumTranslation::model()->find('category = :category and message = :message and language = :language ', array(':category' => $category, ':message' => $message, ':language' => $lang));
                             if (!$model) {
                                 $model = new YumTranslation();
                             }
                             if ($translation != '') {
                                 $model->message = $message;
                                 $model->category = $category;
                                 $model->translation = $translation;
                                 $model->language = $lang;
                                 $model->save();
                             }
                         }
                     }
                 }
             }
         }
         Yum::setFlash('Translations have been saved');
         $this->redirect(array('admin'));
     }
     $this->render('update', array('models' => $models));
 }
Ejemplo n.º 2
0
<?php

$this->breadcrumbs = array(Yum::t('Translation') => array('admin'), Yum::t('Manage'));
?>

<h1><?php 
echo Yum::t('Manage Translations');
?>
 </h1>

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'category-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'language', 'filter' => Yum::getAvailableLanguages()), array('name' => 'message', 'type' => 'raw'), array('name' => 'category', 'type' => 'raw'), array('name' => 'translation', 'type' => 'raw'), array('class' => 'CButtonColumn', 'template' => '{update}', 'updateButtonUrl' => 'Yii::app()->controller->createUrl("update", array(
							"message" => $data->message,
							"category" => $data->category,
							"language" => $data->language))'))));
?>

			<?php 
echo CHtml::link(Yum::t('Create new Translation'), array('create'));