public function get_index($lang_to = 'en')
 {
     //LOAD JS LIBS
     Asset::container('footer')->add('form', 'bundles/cms/js/jquery.form.js', 'jquery');
     Asset::container('footer')->add('translations', 'bundles/cms/js/sections/translations_list.js', 'cms');
     $this->layout->header_data = array('title' => LL('cms::title.translations', CMSLANG));
     $this->layout->top_data = array('search' => false);
     $langs = CmsPage::select_lang_translation();
     $my_lang = LANG;
     array_shift($langs);
     //GET DATA
     $data = CmsTranslation::where('lang_from', '=', $my_lang)->where('lang_to', '=', $lang_to)->order_by('word', 'asc')->get();
     $this->layout->content = View::make('cms::interface.pages.translation_list')->with('langs', $langs)->with('lang_from', $my_lang)->with('lang_to', $lang_to)->with('data', $data);
 }
 public function post_delete_translation()
 {
     $auth = Auth::check();
     if ($auth and is_numeric(AUTHORID)) {
         $id = Input::get('id');
         $trans = CmsTranslation::find($id);
         $trans->delete();
         $tid = $id;
         $response = 'success';
         $msg = LL('cms::ajax_resp.translation_delete_success', CMSLANG)->get();
     } else {
         $tid = null;
         $response = 'error';
         $msg = LL('cms::ajax_resp.translation_delete_error', CMSLANG)->get();
     }
     $data = array('auth' => $auth, 'id' => $tid, 'response' => $response, 'message' => $msg);
     return json_encode($data);
 }
 /**
  * TRANSLATION Marker - Shows a translated portion of text in current language
  *
  * [$TRANSLATION[{
  *	"key":"<text>",
  *	"style":"<lower | upper | capital | allcapital>",	=> OPTIONAL (default: lower)
  *	"to":"<lang code>"		=> OPTIONAL (default: settings.language)
  * }]]
  *
  * @param  array
  * @return string
  */
 public static function TRANSLATION($vars = array())
 {
     //Get variables from array $vars
     if (!empty($vars)) {
         extract($vars);
     }
     //Bind variables
     $_key = '';
     if (isset($key) and !empty($key)) {
         $_key = trim(str_replace('  ', ' ', $key));
     }
     $_style = '';
     if (isset($style) and !empty($style)) {
         $_style = $style;
     }
     $_to = SITE_LANG;
     if (isset($to) and !empty($to)) {
         $_to = $to;
     }
     //Get DB information
     if (!empty($_key)) {
         //CACHE DATA
         if (CACHE) {
             $trans = Cache::remember('trans_' . md5($_key) . '_' . $_to, function () use($_key, $_to) {
                 return CmsTranslation::where_lang_from(LANG)->where_lang_to($_to)->where_word($_key)->first();
             }, 1440);
         } else {
             $trans = CmsTranslation::where_lang_from(LANG)->where_lang_to($_to)->where_word($_key)->first();
         }
         //Load file lable and title
         if (!empty($trans)) {
             $value = $trans->value;
             return CmsUtility::string_style($value, $style = $_style);
         } else {
             return $_key;
         }
     } else {
         return $_key;
     }
     return $_key;
 }