コード例 #1
0
 public function actionEdit()
 {
     $message = "";
     $lang = CatLang::fetchAll();
     if (!empty($_POST["trans"])) {
         for ($n = 0; $n < sizeof($lang); $n++) {
             $trans = $_POST["trans"][$n];
             if ($trans["id"] > 0 || $trans["translation"]) {
                 if ($trans["id"] > 0) {
                     $model = I18nTranslate::fetch($trans->id);
                 } else {
                     $model = new I18nTranslate();
                 }
                 $model->setAttributesFromArray($trans);
                 $model->i18n_id = $this->id;
                 if (!$model->save()) {
                     print_r($model->getErrors());
                 }
             }
         }
     }
     $list = array();
     if (!empty($this->id)) {
         $item = I18n::fetch($this->id);
         $list = I18nTranslate::fetchAll(DBQueryParamsClass::CreateParams()->setConditions("i18n_id=:id")->setParams(array(":id" => $item->id))->setLimit(-1)->setCache(0));
     } else {
         $item = new I18n();
     }
     $this->render('edit', array('form' => $item, 'list' => $list, 'lang' => $lang, 'message' => $message));
 }
コード例 #2
0
 /**
  * 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 actionDelete()
 {
     if ($this->id > 0) {
         $item = I18n::fetch($this->id);
         if ($item->id > 0) {
             $item->delete();
             $itemTranslate = I18nTranslate::fetch($this->id);
             $itemTranslate->delete();
             $this->redirect(SiteHelper::createUrl("/console/variable"));
         }
     }
     $this->redirect(SiteHelper::createUrl("/console/variable"));
 }