Пример #1
0
 public function handleResult()
 {
     foreach ($this->_results as $r) {
         $replace = $r[0];
         $key = $r[1];
         $value = $r[2];
         $o = \KSPM\LCMS\Model\Content::where('key', '=', $key)->first();
         if (!$o) {
             $o = \KSPM\LCMS\Model\Content::create(array('key' => $key, 'value' => $value));
         }
         $this->addTmplObj(array('origin' => $replace, 'value' => $o->value));
     }
 }
Пример #2
0
 public function showAction($key = false)
 {
     $key = $key ? $key : Route::current()->uri();
     if ($key == "/") {
         $key = config('laikacms.default.baseroute');
     }
     //if(\Cache::has($key)){
     //    return \Cache::get($key);
     // }
     $content = \KSPM\LCMS\Model\Page::where('slug', '=', $key)->first();
     if (!$content) {
         $content = \KSPM\LCMS\Model\Content::where('key', '=', 'error.pagecontent.notfound')->first();
     }
     $renderResult = \View::make('pages::show', array('content' => Compiler::init($content)->compile()))->render();
     ob_start();
     eval('$page=$content;$cmsprefix=_LCMS_PREFIX_; ?>' . $renderResult . '<?php ');
     return ob_get_clean();
 }
 public function registerBladeExtensions()
 {
     \Blade::extend(function ($view, $compiler) {
         $pattern = '/@content\\(\'(.*?)\'\\)(.*?)@endcontent/is';
         preg_match_all($pattern, $view, $result);
         if (is_array($result)) {
             for ($i = 0; count($result[1]) > $i; $i++) {
                 $replace = $result[0][$i];
                 $key = $result[1][$i];
                 $value = $result[2][$i];
                 if ($key && $value) {
                     $o = \KSPM\LCMS\Model\Content::where('key', '=', $key)->first();
                     if (!$o) {
                         $o = \KSPM\LCMS\Model\Content::create(array('key' => $key, 'value' => $value));
                     }
                     $o = "<?php echo \\KSPM\\LCMS\\Model\\Content::where('key', '=', '{$key}')->first()->value; ?>";
                     $view = str_replace($replace, $o, $view);
                 }
             }
         }
         $pattern = '/@editable_content\\(\'(.*?)\'\\)(.*?)@endeditable_content/is';
         preg_match_all($pattern, $view, $result);
         $cmswrapper = '<div class="laikacms-editable" data-id="%%%oid%%%">%%%php%%%</div>';
         if (is_array($result)) {
             for ($i = 0; count($result[1]) > $i; $i++) {
                 $replace = $result[0][$i];
                 $key = $result[1][$i];
                 $value = $result[2][$i];
                 if ($key && $value) {
                     $o = \KSPM\LCMS\Model\Content::where('key', '=', $key)->first();
                     if (!$o) {
                         $o = \KSPM\LCMS\Model\Content::create(array('key' => $key, 'value' => $value));
                     }
                     $o = "<?php \$c = \\KSPM\\LCMS\\Model\\Content::where('key', '=', '{$key}')->first()->value; echo str_replace('%%%oid%%%','{$o->id}', str_replace('%%%php%%%', \$c, '{$cmswrapper}')); ?>";
                     $view = str_replace($replace, $o, $view);
                 }
             }
         }
         return $view;
     });
 }
Пример #4
0
 public function createAction()
 {
     \KSPM\LCMS\Model\Content::updateOrCreate(['key' => $_POST['content']['key']], $_POST['content']);
     return json_encode(array('status' => true));
 }