Esempio n. 1
0
 public function loadHome($page)
 {
     $page_properies = \PostProperty::getPostProperties($page->id);
     if (in_array('show_file_page', $page_properies)) {
         $data = array();
         $data['acte'] = ActeLocaleModel::join(Files::getTableName(), Files::getField('module_id'), '=', ActeLocaleModel::getField('id'))->where(Files::getField('module_name'), 'actelocale')->select(ActeLocaleModel::getField("*"), Files::getField('path'))->orderBy('date_upload', 'desc')->take(2)->get();
         echo Template::moduleView($this->module_name, 'views.sidebar-acte', $data)->render();
     }
 }
Esempio n. 2
0
 public static function getPostProperties($id)
 {
     if (isset(static::$properties[$id])) {
         return static::$properties[$id];
     }
     $list = PostPropertyRel::join(PostProperty::getTableName(), PostProperty::getField('id'), '=', PostPropertyRel::getField('post_property_id'))->where(PostPropertyRel::getField('post_id'), $id)->remember(SettingsModel::one('cachelife'))->get();
     $names = array();
     foreach ($list as $item) {
         $names[] = $item->key;
     }
     static::$properties[$id] = $names;
     return $names;
 }
Esempio n. 3
0
 /**
  * @param $postId
  * @param bool $assoc
  * @return \PostProperty[] | null
  */
 public static function getPostProperties($postId, $assoc = true)
 {
     /** @var \PostProperty[] $properties */
     $properties = (array) PostProperty::select()->where('`post_id` = :post_id')->setParameter(':post_id', $postId, \PDO::PARAM_INT)->orderBy('ordering')->execute();
     if (empty($properties)) {
         return $properties;
     }
     if (!$assoc) {
         return $properties;
     }
     $p = array();
     foreach ($properties as $property) {
         $p[$property->getProperty()] = $property;
     }
     return $p;
 }
Esempio n. 4
0
 /**
  * Save page changes
  * @return type
  */
 public function postSave()
 {
     User::onlyHas("page-edit");
     $page_id = Input::get('id');
     $page = Input::get('page');
     $page_lang = Input::get('lang');
     $post = Post::find($page_id);
     if ($post && $page) {
         $post->created_at = $page['created_at'];
         $post->updated_at = date('Y-m-d G:i:s');
         if (User::has('page-move')) {
             if ($page['parent'] != $page_id) {
                 $post->parent = $page['parent'];
             }
         }
         $post->clone_id = $page['clone_id'];
         $post->redirect_to = $page['redirect_to'];
         $post->view_mod = $page['view_mod'];
         $post->general_node = isset($page['general_node']) ? 1 : 0;
         $post->is_home_page = isset($page['is_home_page']) ? 1 : 0;
         $post->have_socials = isset($page['have_socials']) ? 1 : 0;
         $post->have_comments = isset($page['have_comments']) ? 1 : 0;
         if ($post->is_home_page) {
             DB::table(Post::getTableName())->where('is_home_page', 1)->where(Post::getField('id'), '<>', $page_id)->update(array('is_home_page' => 0));
         }
         $post->save();
     }
     if ($page_lang) {
         foreach ($page_lang as $page_lang_id => $page_lang) {
             $post_lang = PostLang::find($page_lang_id);
             $post_lang->title = $page_lang['title'];
             $post_lang->text = $page_lang['text'];
             $post_lang->enabled = isset($page_lang['enabled']) && $page_lang ? 1 : 0;
             if ($page_lang['uri']) {
                 $post_lang->uri = PostLang::uniqURI($page_lang_id, $page_lang['uri']);
             } else {
                 $post_lang->uri = PostLang::uniqURI($page_lang_id, $page_lang['title']);
             }
             $post_lang->save();
         }
     }
     if ($page) {
         $properties = Input::get('properties');
         PostPropertyRel::where('post_id', $page_id)->delete();
         if (is_array($properties)) {
             foreach ($properties as $property) {
                 $prop = PostProperty::find($property);
                 if ($prop) {
                     if ($prop->is_unique) {
                         PostPropertyRel::where('post_property_id', $prop->id)->delete();
                     }
                     $newproperty = new PostPropertyRel();
                     $newproperty->post_id = $page_id;
                     $newproperty->post_property_id = $property;
                     $newproperty->save();
                 }
             }
         }
     }
     if (isset($post->clone_id) && $post->clone_id) {
         $this->clonePageLangData($post->clone_id, $post->id);
     }
     $clones = Post::where('clone_id', $post->id)->get();
     foreach ($clones as $clone) {
         $this->clonePageLangData($post->id, $clone->id);
     }
     Log::info("Edit page #{$page_id}");
     return array();
 }
Esempio n. 5
0
 public static function homeView($data)
 {
     $data['page']->text = \WebAPL\Shortcodes::execute($data['page']->text);
     $data['page']['background'] = Files::getfile('page_bg', $data['page']->id);
     $data['sub_pages'] = Post::subPosts($data['page']->id, 2);
     foreach ($data['sub_pages'] as &$item) {
         $item['image_icon_big'] = Files::getfile('page_icon_big', $item->id);
     }
     $data['page_properies'] = PostProperty::getPostProperties($data['page']->id);
     if (in_array('show_news', $data['page_properies'])) {
         $data['home_posts'] = Post::findHomePosts('newsList');
     }
     if (in_array('show_ads', $data['page_properies'])) {
         $data['home_ads'] = Post::findHomePosts('adsList');
     }
     if (in_array('show_block_page', $data['page_properies'])) {
         $selected_page = PostProperty::postWithProperty('is_selected_page');
         if ($selected_page) {
             $data['home_page'] = $selected_page;
             $data['home_page']['childrens'] = Post::findWithParent($selected_page->id);
         }
     }
     return View::make('sections.pages.home')->with($data);
 }
Esempio n. 6
0
 public static function findWithParent($parent_id)
 {
     $query = Post::prepareQuery();
     $list = $query->where(array('parent' => $parent_id))->orderBy('ord_num', 'asc')->where(PostLang::getField('enabled'), 1)->get();
     foreach ($list as &$item) {
         $item['url'] = Post::getFullURI($item['id']);
         $item['properties'] = PostProperty::getPostProperties($item['id']);
     }
     return $list;
 }
Esempio n. 7
0
 public function topropr($property)
 {
     $post = PostProperty::postWithProperty($property);
     if ($post) {
         $uri = Post::getFullURI($post->id, true);
         return Redirect::to($uri);
     } else {
         throw new Exception("Post not found #{$property}");
     }
 }
Esempio n. 8
0
 public static function loadGeneralResources()
 {
     $data = array('general_pages' => Post::findGeneral(), 'buttom_pages' => PostProperty::postsWithProperty('button_site', 3), 'favicon' => Files::getfile('website_favicon', 1), 'alert_post' => Post::findAlertPost());
     Template::setMetaMultiple(array('og:type' => 'page', 'og:image' => Files::extract('website_logo_' . WebAPL\Language::ext(), 1, 'path'), 'og:site_name' => SettingsModel::one('sitename')));
     View::share($data);
 }
Esempio n. 9
0
    if (Config::get('app.debug') === true) {
        return null;
    }
    $page_property = false;
    $ecode = $exception->getCode();
    $pageCode = in_array($ecode, [404]) ? $ecode : $code;
    if ($pageCode == 404) {
        $page_property = 'error_404';
    } elseif ($pageCode >= 500) {
        $page_property = 'error_404';
    } else {
        $page_property = 'error_404';
    }
    if ($page_property) {
        Post::$taxonomy = 1;
        $page = PostProperty::postWithProperty('error_404');
        if ($page) {
            $uri = Post::getFullURI($page->id, false);
            $contents = App::make('PageController')->route($uri);
            return Response::make($contents, $pageCode);
        }
    }
    //return "Undefined error!";
});
$APLExtensions = array('Modules', 'Shortcodes', 'Template', 'Language', 'ExtensionController');
Event::listen('APL.core.load', function () use($APLExtensions) {
    ClassLoader::addDirectories(base_path() . '/vendor/lgsp/webapl/');
    foreach ($APLExtensions as $Extension) {
        if (!ClassLoader::load($Extension)) {
            throw new Exception("'{$Extension}' load failed!");
        }
Esempio n. 10
0
 protected function _afterDelete()
 {
     parent::_afterDelete();
     \PostImages::write()->delete(PostImages::getTableName())->where('`post_id`=:post_id')->setParameter(':post_id', $this->getId(), \PDO::PARAM_INT)->execute();
     \PostCustomFields::write()->delete(PostCustomFields::getTableName())->where('`post_id`=:post_id')->setParameter(':post_id', $this->getId(), \PDO::PARAM_INT)->execute();
     \PostAttachments::write()->delete(PostAttachments::getTableName())->where('`post_id`=:post_id')->setParameter(':post_id', $this->getId(), \PDO::PARAM_INT)->execute();
     \PostProperty::write()->delete(PostProperty::getTableName())->where('`post_id`=:post_id')->setParameter(':post_id', $this->getId(), \PDO::PARAM_INT)->execute();
 }