/**
  * Retrieve user preferences
  *
  * @access	private
  */
 private function get_prefs()
 {
     try {
         $to_read['table'] = 'setting';
         $to_read['columns'] = array('SETTING_ID');
         $to_read['condition_columns'][':t'] = 'setting_type';
         $to_read['condition_select_types'][':t'] = '=';
         $to_read['condition_values'][':t'] = 'user_' . VSession::user_id();
         $to_read['value_types'][':t'] = 'str';
         $pref = $this->_db->read($to_read);
         $this->_prefs = new Setting($pref[0]['SETTING_ID']);
         $this->_prefs->_data = json_decode($this->_prefs->_data, true);
     } catch (Exception $e) {
         $this->_action_msg = ActionMessages::custom_wrong($e->getMessage());
     }
 }
 /**
  * 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();
     }
 }
 /**
  * Class constructor
  *
  * @access	public
  * @param	integer [$id] Element id
  */
 public function __construct($id)
 {
     if (empty($id)) {
         throw new Exception('Element id missing');
     }
     parent::__construct();
     $this->_id = $id;
     $this->get_content();
     $this->_comment = new Comment();
     if (VSession::visitor_name(false) && VSession::visitor_email(false)) {
         $this->_comment->_name = VSession::visitor_name();
         $this->_comment->_email = VSession::visitor_email();
     }
     $this->question();
     if (VGet::respond_to()) {
         $this->_comment->_content = '@' . VGet::respond_to();
     }
     if (VPost::submit_comment(false)) {
         $this->create();
     }
 }
 /**
  * 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;
             }
         }
     }
 }
 /**
  * Retrieve user preferences
  *
  * @access	private
  */
 private function get_prefs()
 {
     try {
         $to_read['table'] = 'setting';
         $to_read['columns'] = array('SETTING_ID');
         $to_read['condition_columns'][':t'] = 'setting_type';
         $to_read['condition_select_types'][':t'] = '=';
         $to_read['condition_values'][':t'] = 'user_' . VSession::user_id();
         $to_read['value_types'][':t'] = 'str';
         $pref = $this->_db->read($to_read);
         if (empty($pref)) {
             $this->_prefs = new Setting();
             $this->_prefs->_name = 'User preferences for "' . VSession::username() . '"';
             $this->_prefs->_type = 'user_' . VSession::user_id();
             $this->_prefs->_data = json_encode(array('last_visit' => date('Y-m-d H:i:s'), 'timeline' => array(array('title' => 'Lynxpress Demo', 'url' => 'http://demo.lynxpress.org/'))));
             $this->_prefs->create();
         } else {
             $this->_prefs = new Setting($pref[0]['SETTING_ID']);
         }
         $this->_prefs->_data = json_decode($this->_prefs->_data, true);
     } catch (Exception $e) {
         $this->_action_msg = ActionMessages::custom_wrong($e->getMessage());
     }
 }
 /**
  * Display page content
  *
  * @access	public
  */
 public function display_content()
 {
     Html::header_authors(VGet::author());
     if (!empty($this->_content)) {
         if (!VSession::html5()) {
             echo '<ul id="authors">';
         }
         foreach ($this->_content as $user) {
             Html::author($user->_publicname, $user->_email, $user->_website, $user->_msn, $user->_twitter, $user->_facebook, $user->_google, $user->_avatar, $user->_bio);
         }
         if (!VSession::html5()) {
             echo '</ul>';
         }
     } else {
         Html::no_content('Wanted user doesn\'t exist');
     }
 }
 /**
  * Display page content
  *
  * @access	public
  */
 public function display_content()
 {
     if (!empty($this->_content)) {
         Html::header_links();
         if (!VSession::html5()) {
             echo '<ul id="links">';
         }
         foreach ($this->_content as $link) {
             Html::related_link($link->_name, $link->_link, $link->_rss_link, $link->_notes, $link->_priority);
         }
         if (!Vsession::html5()) {
             echo '</ul>';
         }
     } else {
         Html::header_links();
         if (!VSession::html5()) {
             echo '<ul id="links">';
         }
         Html::no_content('There\'s no link registered yet.');
         if (!Vsession::html5()) {
             echo '</ul>';
         }
     }
 }
 /**
  * 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 an error message what says there's no result for the search
  *
  * @access	private
  */
 private function display_error()
 {
     if (!empty($this->_search)) {
         $msg = $this->_search;
     } elseif (!empty($this->_by_date)) {
         $msg = date('M Y', strtotime($this->_by_date));
     } elseif (!empty($this->_tag)) {
         $msg = $this->_tag;
     } elseif (!empty($this->_cat)) {
         try {
             $cat = new Category($this->_cat);
             $msg = ucwords($cat->_name);
         } catch (Exception $e) {
             header('Location: 404.php');
         }
     }
     if (!VSession::html5()) {
         echo '<ul id="listing_articles">';
     }
     Html::no_content('No results founded for "' . $msg . '"');
     if (!VSession::html5()) {
         echo '</ul>';
     }
 }
 /**
  * Method to display a related link
  *
  * @static
  * @access	public
  * @param	string [$name] Link name
  * @param	string [$link] Link url
  * @param	string [$rss_link] Link RSS url
  * @param	string [$notes] Link notes
  * @param	integer [$priority] Link priority level
  */
 public static function related_link($name, $link, $rss_link, $notes, $priority)
 {
     if (VSession::html5()) {
         echo '<section class="link">' . '<h3>' . $name . '</h3>' . '<details open>' . '<summary>Website links</summary>' . '<p>' . 'Website: <a href="' . $link . '">' . $link . '</a><br/>' . 'Feed: <a href="' . $rss_link . '">' . $rss_link . '</a>' . '</p>' . '</details>' . '<section class="description">' . nl2br($notes) . '</section>' . '</section>';
     } else {
         echo '<li class="link">' . '<h3>' . $name . '</h3>' . '<p class="details">' . 'Website: <a href="' . $link . '">' . $link . '</a><br/>' . 'Feed: <a href="' . $rss_link . '">' . $rss_link . '</a>' . '</p>' . '<p class="description">' . nl2br($notes) . '</p>' . '</li>';
     }
 }
 /**
  * Display page content
  *
  * @access	public
  */
 public function display_content()
 {
     if (VGet::cat()) {
         $add = $this->_menu[VGet::cat()];
     } else {
         $add = null;
     }
     Html::header_videos($add);
     if (!empty($this->_content)) {
         Html::html5('o', 'id="videos">');
         if (!VSession::html5()) {
             echo '<ul>';
         }
         foreach ($this->_content as $video) {
             Html::video($video->_name, $video->_author_publicname, $video->_permalink, $video->_embed_code, nl2br($video->_description), $video->_date);
         }
         if (!VSession::html5()) {
             echo '</ul>';
         }
         Html::html5('c');
     } else {
         if (!VSession::html5()) {
             echo '<ul>';
         }
         Html::no_content('There\'s no videos right now.');
         if (!VSession::html5()) {
             echo '</ul>';
         }
     }
 }
 /**
  * Log an action into database, logs are viewed by administrator in the dashboard
  *
  * @static
  * @access	public
  * @param	string [$msg] Action message to log
  */
 public static function monitor_activity($msg)
 {
     $db =& Database::load();
     $to_create['table'] = 'activity';
     $to_create['columns'] = array(':id' => 'USER_ID', ':data' => 'data', ':date' => 'date');
     $to_create['values'] = array(':id' => VSession::user_id(), ':data' => $msg, ':date' => date('Y-m-d H:i:s'));
     $to_create['types'] = array(':id' => 'int', ':data' => 'str', ':date' => 'str');
     $db->create($to_create);
 }
					
					<?php 
$plugins = Helper::plugins_infos();
if (!empty($plugins)) {
    echo '<ul id="mplg">';
    foreach ($plugins as $plg) {
        echo '<li><a href="index.php?ns=' . $plg['namespace'] . '&ctl=' . $plg['entry_point'] . '">' . $plg['name'] . '</a></li>';
    }
    echo '</ul>';
}
?>
					
				</li>
				
				<?php 
if ($page->settings) {
    echo '<li>' . '<a href="index.php?ns=settings&ctl=manage">Settings</a>' . '<ul>' . '<li><a href="index.php?ns=categories&ctl=manage">Categories</a></li>' . '<li><a href="index.php?ns=posts&ctl=settingpage">Posts</a></li>' . '<li>' . '<a href="index.php?ns=users&ctl=manage">Users</a>' . '<ul>' . '<li><a href="index.php?ns=users&ctl=add">Add</a></li>' . '</ul>' . '</li>' . '<li><a href="index.php?ns=roles&ctl=manage">Roles</a></li>' . '<li><a href="index.php?ns=social&ctl=manage">Social Buttons</a></li>' . '<li><a href="index.php?ns=defaultpage&ctl=manage">Default Page</a></li>' . '<li>' . '<a href="index.php?ns=templates&ctl=manage">Templates</a>' . '<ul>' . '<li><a href="index.php?ns=templates&ctl=add">Add</a></li>' . '<li><a href="index.php?ns=templates&ctl=library">Library</a></li>' . '</ul>' . '</li>' . '<li>' . '<a href="index.php?ns=plugins&ctl=manage">Plugins</a>' . '<ul>' . '<li><a href="index.php?ns=plugins&ctl=add">Add</a></li>' . '<li><a href="index.php?ns=plugins&ctl=library">Library</a></li>' . '</ul>' . '</li>' . '<li>' . '<a href="index.php?ns=links&ctl=manage">Links</a>' . '<ul>' . '<li><a href="index.php?ns=links&ctl=add">Add</a></li>' . '</ul>' . '</li>' . '<li><a href="index.php?ns=activity&ctl=manage">Activity</a></li>' . '<li><a href="index.php?ns=update&ctl=manage">Update</a></li>' . '</ul>' . '<li>';
}
?>
				<li id="right">
					Hi <?php 
echo Session::username();
?>
 | 
					<a href="index.php?ns=session&ctl=logout">Logout</a>
				</li>
			</ul>
			
		</header>
		
		<section id="wrapper">