private function displayDetails(Model_Articles $article) { if (empty($article)) { $this->response->error('L\'article demandé est introuvable.', 404); return; } $author = $article->load('author'); $isPublished = $article->prop('is_published'); $canReadUnpublished = $this->_currentUser->hasPermission(Model_Groups::PERM_READ_UNPUBLISHED_ARTICLES); if (!$isPublished && !$canReadUnpublished && !$this->_currentUser->equals($author)) { $this->response->error('L\'article demandé n\'est pas ou plus publié.', 403); return; } $canonical_url = $article->getUrl(); $og_article = ['publisher' => \Eliya\Config('main')->FACEBOOK['PAGE_URL'], 'category' => $article->load('category')->prop('name'), 'modified_time' => $article->prop('date_last_update'), 'published_time' => $article->prop('date_publication')]; Library_Facebook::setMetaOG(['og' => ['title' => $article->prop('title'), 'description' => $article->prop('introduction'), 'site_name' => \Eliya\Config('main')->SITE_NAME, 'url' => $canonical_url, 'image' => $article->getMainPictureURL(), 'type' => Library_Facebook::TYPE_ARTICLE, 'locale' => Library_Facebook::LOCALE_FR_FR], 'fb' => ['app_id' => \Eliya\Config('main')->FACEBOOK['APP_ID']], 'article' => $og_article]); \Eliya\Tpl::set('page_title', $article->prop('title')); \Eliya\Tpl::set('page_description', $article->prop('introduction')); \Eliya\Tpl::set('canonical_url', $canonical_url); $category = $article->prop('category'); $twitterDefaultText = $article->prop('title'); if ($category !== null) { $twitterDefaultText = $category->prop('name') . ' - ' . $twitterDefaultText; } $templateShareLinks = \Eliya\Tpl::get('articles/share_links', ['url' => $article->getUrl(), 'twitterDefaultText' => $twitterDefaultText]); $this->response->set(\Eliya\Tpl::get('articles/article', ['article' => $article, 'category' => $category, 'templateShareLinks' => $templateShareLinks])); }
protected static function _getConfig() { if (self::$assets_config === null) { try { self::$assets_config = \Eliya\Config('assets'); } catch (Exception $e) { self::$assets_config = false; } } }
public static function hash($string) { return sha1($string . Eliya\Config('main')->SALT); }
<!-- Scripts for Facebook and Twitter --> <div id="fb-root"></div> <script async src="//connect.facebook.net/fr_FR/sdk.js#xfbml=1&version=v2.4&appId=<?php echo \Eliya\Config('main')->FACEBOOK['APP_ID']; ?> "></script> <script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script> <script id="articleData" type="application/json"><?php echo $view->article->toJSON(); ?> </script> <script src="<?php echo Library_Assets::get('js/angular/articles/read.js'); ?> "></script> <main ng-app="readArticleModule" ng-controller="readArticleController as readCtrl"> <header style="background-image: url(<?php echo $view->article->getMainPictureURL(); ?> );"> <h1><?php echo $view->article->prop('title'); ?> </h1> </header> <aside class="article-infos"> <?php if ($view->category !== null) { ?>
<?php // Require framework core require_once '../../system/Core.class.php'; // Init core \Eliya\Core::init(); // Init DB require_once '../vendors/EntityPHP/src/EntityPHP.php'; $sql = \Eliya\Config('main')->SQL; \EntityPHP\Core::connectToDB($sql['HOST'], $sql['USER'], $sql['PASSWORD'], $sql['DATABASE']); // Include all models files \Eliya\Core::requireDirContent('../models'); // Generate the dabatase based on our models \EntityPHP\Core::generateDatabase(); Model_Categories::add(new Model_Categories('Billet d\'humeur')); Model_Categories::add(new Model_Categories('Quoi d\'neuf Mario ?')); Model_Categories::add(new Model_Categories('Analyse de personnage')); Model_Categories::add(new Model_Categories('L\'entreprise Nintendo')); Model_Categories::add(new Model_Categories('Découverte de jeu')); Model_Categories::add(new Model_Categories('Anthologie musicale')); Model_Categories::add(new Model_Categories('Produits dérivés')); Model_Groups::add(new Model_Groups(['group_name' => 'Anonymes', 'can_manage_categories' => 0, 'can_manage_users' => 0, 'can_write_articles' => 0, 'can_edit_other_articles' => 0, 'can_publish_other_articles' => 0, 'can_read_unpublished_articles' => 0])); $group_redactors = Model_Groups::add(new Model_Groups(['group_name' => 'Rédacteurs', 'can_manage_categories' => 0, 'can_manage_users' => 0, 'can_write_articles' => 1, 'can_edit_other_articles' => 0, 'can_publish_other_articles' => 0, 'can_read_unpublished_articles' => 0])); Model_Groups::add(new Model_Groups(['group_name' => 'Rédacteurs en chef', 'can_manage_categories' => 1, 'can_manage_users' => 0, 'can_write_articles' => 1, 'can_edit_other_articles' => 0, 'can_publish_other_articles' => 1, 'can_read_unpublished_articles' => 1])); $group_admin = Model_Groups::add(new Model_Groups(['group_name' => 'Admins', 'can_manage_categories' => 1, 'can_manage_users' => 1, 'can_write_articles' => 1, 'can_edit_other_articles' => 1, 'can_publish_other_articles' => 1, 'can_read_unpublished_articles' => 1]));
require_once 'system/Core.class.php'; //Init core \Eliya\Core::init(); // Set session time (24H) session_set_cookie_params(86400); ini_set('session.gc_maxlifetime', 86400); //Activate the session session_start(); //Init DB require_once 'application/vendors/EntityPHP/src/EntityPHP.php'; $sql = \Eliya\Config('main')->SQL; //Handle received request $request = new \Eliya\Request($_SERVER['REQUEST_URI']); $current_url = $request->getProtocol() . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; define('BASE_URL', $request->getBaseURL()); define('STATIC_URL', \Eliya\Config('main')->STATIC_URL); define('PUBLIC_FOLDER_PATH', __DIR__ . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR); if (substr($current_url, -1) !== '/') { $current_url .= '/'; } $page_description = 'Un site réalisé par des fans pour les fans de Nintendo. '; $page_description .= 'Retrouvez des articles en rapport avec Nintendo, que ce soit sur '; $page_description .= 'l\'actualité, des découvertes de jeux ou des dossiers sur divers sujets.'; \Eliya\Tpl::set(['page_title' => 'Le Chomp Enchainé', 'page_description' => $page_description, 'base_url' => BASE_URL, 'static_url' => STATIC_URL, 'current_url' => $current_url]); $response = $request->response(); try { if (!empty($sql)) { \EntityPHP\Core::connectToDB($sql['HOST'], $sql['USER'], $sql['PASSWORD'], $sql['DATABASE']); } else { throw new Exception('Impossible de se connecter à la base de données'); }