/** * Bind the given JavaScript to the * view using Laravel event listeners * * @param $scope The scope to load */ public function putarticle($scope) { $lang = $this->app->getLocale(); $listo = false; try { $articles = Article::where("scope", "=", $scope)->where("lang", "=", $lang)->get(); if (count($articles)) { $listo = true; } else { $articles = Article::where("scope", "=", $scope)->get(); if (count($articles)) { $listo = true; //return $article->content . "<span class='label label-warning'>" . $article->lang . "</span>"; } else { $jsarray = $langfile; } } } catch (Exception $ex) { return $scope . " - Error:" . print_r($ex, true); } if ($listo) { if (count($articles) > 1) { $trans = []; foreach ($articles as $article) { $trans[$article->nickname] = $article->content; } $jsarray = json_encode($trans); } else { $jsarray = $article->content; } } $this->event->listen("composing: {$this->viewToBind}", function () use($jsarray, $scope) { echo "<script>window.{$this->basevar} = window.{$this->basevar} || {};{$this->basevar}.{$scope} = {$jsarray};</script>"; }); }
function get($nickname) { try { $article = Article::findArticle($nickname)->where("lang", "=", $this->lang)->first(); if (count($article)) { return $article->content; } else { $article = Article::findArticle($nickname)->first(); if (count($article)) { return $article->content . "<span class='label label-warning'>" . $article->lang . "</span>"; } else { return $nickname; } } } catch (Exception $ex) { return $nickname . "<pre class='label label-warning'>" . print_r($ex, true) . "</pre>"; } }