/** * Session constructor * * Check if cookie or session variables exists to retrieve directly informations * * Otherwise it calls get_browser method * * @access public */ public function __construct() { session_start(); $this->_db =& Database::load(); if (VCookie::lynxpress()) { $array = json_decode(stripslashes(VCookie::lynxpress()), true); $_SESSION['html5'] = $array['html5']; $_SESSION['renderer'] = $array['renderer']; $this->_html5 = VSession::html5(); $this->_renderer = VSession::renderer(); } elseif (!VSession::html5() && !VSession::renderer()) { $this->get_browser(); $_SESSION['html5'] = $this->_html5; $_SESSION['renderer'] = $this->_renderer; setcookie('lynxpress', json_encode(array('html5' => $this->_html5, 'renderer' => $this->_renderer)), time() + 365 * 24 * 60 * 60); } else { $this->_html5 = VSession::html5(); $this->_renderer = VSession::renderer(); } }
/** * Determine cache filename * * @access private */ private function build_url() { if (self::ACTIVATED === false) { return false; } if (VSession::renderer() == 'mobile') { $this->_url .= 'mobile'; } elseif (VSession::html5()) { $this->_url .= 'html5'; } else { $this->_url .= 'html'; } $this->_url .= '-ctl-' . VGet::ctl(); if (VGet::ctl() == 'albums' && VGet::album() && !VGet::comments()) { $this->_url .= '-album-' . VGet::album(); } elseif (VGet::ctl() == 'search') { foreach (VGet::all() as $key => $value) { if ($key != 'ctl') { $this->_url .= '-' . $key . '-' . $value; } } } }
/** * Display comments about an album * * @access private */ private function display_comments() { Html::header_albums($this->_album->_name . ' > Comments'); Html::album_details($this->_album->_id, $this->_album->_author_name, $this->_album->_date, nl2br($this->_album->_description), $this->_album->_name, WS_URL . '?ctl=' . $this->_pid . '&album=' . $this->_album->_id); echo '<br/><span id="go_back_album"><a href="' . PATH . '?ctl=' . $this->_pid . '&album=' . VGet::album() . '">Go Back</a></span>'; if (VSession::renderer() != 'mobile') { //create comment section if ($this->_album->_allow_comment == 'open') { $c = new Comments($this->_album->_id); $c->display_content(); } else { Html::comment_closed(); } } }
/** * Display a specific post * * @access private */ private function display_news() { if (!empty($this->_content)) { $cats = explode(',', $this->_content[0]->_category); try { foreach ($cats as &$cat) { $id = $cat; $infos = new Category($id); $cat = Helper\Posts::make_category_link($id, $infos->_name); } } catch (Exception $e) { @error_log($e->getMessage() . ' file: ' . __FILE__ . '; line: ' . __LINE__, 1, WS_EMAIL); } $content = nl2br($this->_content[0]->_content); $tags = explode(',', $this->_content[0]->_tags); foreach ($tags as &$tag) { $tag = Helper\Posts::make_tag_link($tag); } $link = WS_URL . '?ctl=posts&news=' . $this->_content[0]->_title; Html::html5('o', 'id="news_alone">'); Html::article_alone($this->_content[0]->_title, $this->_content[0]->_date, $this->_content[0]->_author_name, $cats, $content, $tags, $link, $this->_content[0]->_updated, $this->_content[0]->_update_author_name); if (VSession::renderer() != 'mobile') { //create comment section if ($this->_content[0]->_allow_comment == 'open') { $c = new Comments($this->_content[0]->_id); $c->display_content(); } else { Html::comment_closed(); } } Html::html5('c'); } }
/** * Display the posts listing * * @access private */ private function display_listing() { if (!VSession::html5()) { echo '<ul id="listing_articles">'; } if (!empty($this->_content)) { foreach ($this->_content as $article) { $crop_length = Helper\Posts::crop_length($article->_content); $cats = explode(',', $article->_category); try { foreach ($cats as &$cat) { $id = $cat; $infos = new Category($id); $cat = Helper\Posts::make_category_link($id, $infos->_name); } } catch (Exception $e) { @error_log($e->getMessage() . ' file: ' . __FILE__ . '; line: ' . __LINE__, 1, WS_EMAIL); } $content = nl2br(substr($article->_content, 0, $crop_length)); Html::listing_article($article->_title, $article->_permalink, $cats, $article->_date, $article->_author_name, $content); } } if (!VSession::html5()) { echo '</ul>'; } if (VSession::renderer() != 'mobile' && !empty($this->_content)) { Html::navigation($this->_page, $this->_nb_pages, parent::link_navigation()); } }
/** * Display additional informations about an album * * @static * @access public * @param integer [$id] Album id * @param string [$author] Album author public name * @param string [$date] Album creation date * @param string [$description] Album description * @param string [$title] Album title * @param string [$link] Album permalink */ public static function album_details($id, $author, $date, $description, $title, $link) { if (VSession::renderer() != 'mobile') { if (VSession::html5() && VSession::renderer() != 'gecko') { echo '<details id="album_details" open>' . '<summary>Created by ' . $author . ' the <time datetime="' . date(DATE_ATOM, strtotime($date)) . '" pubdate>' . date('M d, Y @ H:i', strtotime($date)) . '</time></summary>' . '<p>' . $description . '</p>' . '<span id="view_comments"><a href="' . PATH . '?ctl=albums&album=' . $id . '&comments=view">View Comments</a></span><br/><br/>' . '</details>'; } else { echo '<div id="album_details">' . 'Created by ' . $author . ' the ' . date('M d, Y @ H:i', strtotime($date)) . '<p>' . $description . '</p>' . '<span id="view_comments"><a href="' . PATH . '?ctl=albums&album=' . $id . '&comments=view">View Comments</a></span><br/><br/>' . '</div>'; } Social::share($title, $link); } }