Inheritance: extends Model
Exemplo n.º 1
0
 public static function log($str)
 {
     $n = new LangModel();
     $n->lang_id = $str;
     $n->lang_ts = leap_mysqldate();
     $n->save();
 }
Exemplo n.º 2
0
 protected static function actionDefault()
 {
     if ($_GET['lang']) {
         $lang = new LangModel($_GET['lang']);
         if ($lang->getId()) {
             App::currentLang($_GET['lang']);
         }
     }
     if ($_SERVER['HTTP_REFERER']) {
         self::redirect($_SERVER['HTTP_REFERER']);
     } else {
         self::redirect('/');
     }
 }
Exemplo n.º 3
0
 public static function t($str, $return = 1)
 {
     //disini bisa ditambah fungsi insert ke DB sehingga bs tau apa aja yang harus di replace !!
     global $_lang;
     //@include ("lang/".strtolower($_SESSION['lang']).".php");
     //pr($_lang);
     //
     //save ke db utk spy mudah di benarkan translationsnya
     \LangModel::log($str);
     /*global $db;
             $q = "INSERT INTO core__lang_logger SET lang_id = '$str',lang_ts = now()";
             $db->query($q, 0);
     */
     if (isset($_lang[$str])) {
         if ($return) {
             return $_lang[$str];
         } else {
             echo $_lang[$str];
         }
     } else {
         $new = $str;
         // baru supaya mudah dicari variablenya
         // $new = ucwords(str_replace("_"," ",$str));
         if ($return) {
             return "{$new}";
         } else {
             echo "{$new}";
         }
     }
 }
Exemplo n.º 4
0
 protected static function boot()
 {
     parent::boot();
     static::deleting(function ($ArticleModel) {
         // before delete() method call this
         $ArticleModel->contents()->detach($ArticleModel->id);
         // do the rest of the cleanup...
     });
 }
 function saveIt()
 {
     //        pr($_POST);
     $lm = new LangModel();
     $arr = $lm->getOrderBy('lang_id ASC');
     //pr($arr);
     global $activeLang;
     //pr($activeLang);
     $satulang = array();
     //        foreach($activeLang as $ll){
     //            $_lang = array();
     //            include("lang/" . strtolower($ll) . ".php");
     //            $satulang[$ll] = $_lang;
     //        }
     foreach ($arr as $val) {
         foreach ($activeLang as $ll) {
             $name = base64_encode($ll . "_" . $val->lang_id);
             $satulang[$ll][$val->lang_id] = $_POST[$name];
         }
     }
     foreach ($activeLang as $ll) {
         $txt = "<?php" . PHP_EOL;
         $myfile = fopen("lang/" . strtolower($ll) . ".php", "w+") or die("Unable to open file!");
         foreach ($satulang[$ll] as $id => $value) {
             if ($value != "") {
                 $txt .= '$_lang["' . $id . '"] = "' . $value . '";' . PHP_EOL;
             }
         }
         //$txt = "John Doe\n";
         //fwrite($myfile, $txt);
         //$txt = "Jane Doe\n";
         fwrite($myfile, $txt);
         fclose($myfile);
     }
     echo Lang::t('Success');
 }