Beispiel #1
0
 public static function addLang($lang_id)
 {
     $vars = VarModel::all();
     foreach ($vars as $item) {
         $var_lang = new VarLangModel();
         $var_lang->lang_id = $lang_id;
         $var_lang->var_key = $item->key;
         $var_lang->save();
     }
 }
Beispiel #2
0
 public static function uniqKey($key, $str)
 {
     if ($key) {
         $key = urigen($key);
     } else {
         $key = urigen($str);
     }
     $count = VarModel::where("key", "like", "{$key}%")->count();
     if ($count) {
         return $key . '-' . $count;
     } else {
         return $key;
     }
 }
Beispiel #3
0
 public static function getParents($key)
 {
     $list = array();
     while ($key) {
         $item = VarModel::prepareQuery()->where('key', $key)->first();
         if ($item) {
             $list[] = $item;
             $key = $item->parent_key;
         } else {
             $key = '';
         }
     }
     return $list;
 }
Beispiel #4
0
 /**
  * Load Vars
  */
 protected static function loadVars()
 {
     $vars = \VarModel::prepareQuery()->select(\VarModel::getField('key'), \VarLangModel::getField('value'))->get();
     $tmpv = array();
     foreach ($vars as $var) {
         $tmpv[$var->key] = $var->value;
     }
     static::$vars = $tmpv;
 }
Beispiel #5
0
 public function getExportjson()
 {
     $buffer = [];
     $vars = VarModel::all();
     $except = [9, 12, 14, 16, 18, 20, 23, 38, 36, 40, 42, 53];
     foreach ($vars as $var) {
         if (in_array($var->id, $except) == FALSE) {
             $langs = VarLangModel::where('var_key', $var->key)->get();
             foreach ($langs as $vlang) {
                 $buffer[] = ['id' => $vlang->id, 'value' => $vlang->value, 'vid' => $var->id, 'key' => $var->key, 'parent_key' => $var->parent_key, 'lang_id' => $vlang->lang_id];
             }
         }
     }
     header('Content-Encoding: UTF-8');
     header('Content-type: application/json; charset=UTF-8');
     return $buffer;
 }