Commit 0bce2c06 by Scott

Merge branch 'pr/194' into dev

parents cd75b772 84129054
<?php
/*
Snow Theme for Question2Answer Package
Copyright (C) 2014 Q2A Market <http://www.q2amarket.com>
File: inc/qam-snow-theme.php
Version: Snow 1.4
Description: Snow theme core class
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
/**
* Snow theme loader class
*
* This class loads all required data for the Snow theme. This is written more
* for future use and to keep untouched <code>qa_html_theme_base</code>
*
* @package Snow
* @subpackage Loader
* @category Theme
* @since Snow 1.4
* @version 1.0
* @author Q2A Market <http://www.q2amarket.com>
* @copyright (c) 2014, Q2A Market
* @license http://www.gnu.org/copyleft/gpl.html
*/
class qam_snow_theme
{
/**
* @var array Holds the data
*/
private $data;
/**
* Snow instance
*
* @access public
* @since Snow 1.4
* @version 1.0
*
* @static $instance
*
* @uses qam_snow_theme::setup_globals() Setup require globals
* @uses qam_snow_theme::includes() Include require files
* @uses qam_snow_theme::heads() Setup <code><head></code> elements
* @uses qam_snow_theme::set_options() Setup dynamic options for Snow
* @uses qam_snow_theme::headers() Setup header elements
* @uses qam_snow_theme::footers() Setup footer elements
*
* @see qam_snow_theme()
* @return mixed all qam_snow_theme
*
* @author Q2A Market <http://www.q2amarket.com>
* @copyright (c) 2014, Q2A Market
* @license http://www.gnu.org/copyleft/gpl.html
*/
public static function instance()
{
// Store the instance locally to avoid private static replication
static $instance = null;
// Only run these methods if they haven't been run previously
if (null === $instance) {
$instance = new qam_snow_theme;
$instance->setup_globals();
$instance->includes();
// $instance->heads();
$instance->get_options();
$instance->headers();
// $instance->footers();
}
// Always return the instance
return $instance;
}
/**
* Class construct
*/
private function __construct()
{ /* Do nothing here */
}
/**
*
* @param type $key
* @return type
*/
public function __isset($key)
{
return isset($this->data[$key]);
}
/**
*
* @param type $key
* @return type
*/
public function __get($key)
{
return isset($this->data[$key]) ? $this->data[$key] : null;
}
/**
*
* @param type $key
* @param type $value
*/
public function __set($key, $value)
{
$this->data[$key] = $value;
}
/**
*
* @param type $key
*/
public function __unset($key)
{
if (isset($this->data[$key])) {
unset($this->data[$key]);
}
}
/**
*
* @param type $name
* @param type $args
* @return null
*/
public function __call($name = '', $args = array())
{
unset($name, $args);
return null;
}
/**
* Snow theme globals
*
* @access private
* @since Snow 1.4
* @version 1.0
*
* @author Q2A Market <www.q2amarket.com>
* @copyright (c) 2014, Q2A Market
* @license http://www.gnu.org/copyleft/gpl.html
*/
private function setup_globals()
{
$this->theme = qa_opt('site_theme');
$this->author = $this->qam_opt('snow_author', 'Q2A Market');
$this->author_url = $this->qam_opt('snow_author_url', 'http://www.q2amarket.com');
$this->version = $this->qam_opt('snow_version', '1.4-beta');
$this->snow_version = strtolower($this->theme . '-' . $this->version);
$this->opt_prefix = 'qam_snow_';
$this->js_dir = 'js/';
$this->css_dir = 'css/';
$this->img_url = 'images/';
$this->icon_url = $this->img_url . 'icons/';
}
/**
* Incldue require files
*
* @access private
* @since Snow 1.4
* @version 1.0
*
* @author Q2A Market <www.q2amarket.com>
* @copyright (c) 2014, Q2A Market
* @license http://www.gnu.org/copyleft/gpl.html
*/
private function includes()
{ //do nothing now
}
/**
* Get theme options for customization.
*
* @access private
* @since Snow 1.4
* @version 1.0
* @return array|mixed theme options value
*
* @author Q2A Market <http://www.q2amarket.com>
* @copyright (c) 2014, Q2A Market
* @license http://www.gnu.org/copyleft/gpl.html
*/
private function get_options()
{
$this->data['ask_search_box_color'] = $this->qam_opt('ask_search_box_color');
$this->data['welcome_widget_color'] = $this->qam_opt('welcome_widget_color');
$this->data['fixed_topbar'] = (($this->qam_opt('fixed_topbar')) ? 'fixed' : null);
$this->data['header_custom_content'] = $this->qam_opt('header_custom_content');
$this->data['footer_custom_content'] = $this->qam_opt('above_footer_custom_content');
return $this->data;
}
/**
* Get header items
*
* @access private
* @since Snow 1.4
* @version 1.0
* @return array|mixed various header items (e.g. user account, scripts)
*
* @author Q2A Market <http://www.q2amarket.com>
* @copyright (c) 2014, Q2A Market
* @license http://www.gnu.org/copyleft/gpl.html
*/
private function headers()
{
$this->data['headers'] = array(
'user_points' => $this->user_points(),
'ask_button' => $this->ask_button(),
);
return $this->data;
}
/**
* Get logged in user's points
*
* @access private
* @since Snow 1.4
* @version 1.0
* @return string|null LoggedIn user's total points, null for guest
*
* @author Q2A Market <http://www.q2amarket.com>
* @copyright (c) 2014, Q2A Market
* @license http://www.gnu.org/copyleft/gpl.html
*/
private function user_points()
{
if (qa_is_logged_in()) {
$userpoints = qa_get_logged_in_points();
$pointshtml = ($userpoints == 1) ? qa_lang_html_sub('main/1_point', '1', '1') : qa_html(number_format($userpoints));
$points = '<DIV CLASS="qam-logged-in-points">' . $pointshtml . '</DIV>';
return $points;
}
return null;
}
/**
* Custom ask button for medium and small screen
*
* @access private
* @since Snow 1.4
* @version 1.0
* @return string Ask button html markup
*
* @author Q2A Market <http://www.q2amarket.com>
* @copyright (c) 2014, Q2A Market
* @license http://www.gnu.org/copyleft/gpl.html
*/
private function ask_button()
{
$html = '<div class="qam-ask-search-box">';
$html .= '<div class="qam-ask-mobile"><a href="' . qa_path('ask', null, qa_path_to_root()) . '" class="' . $this->qam_opt('ask_search_box_color') . '">' . qa_lang_html('main/nav_ask') . '</a></div>';
$html .= '<div class="qam-search-mobile ' . $this->qam_opt('ask_search_box_color') . '" id="qam-search-mobile"></div>';
$html .= '</div>';
return $html;
}
}
/* ---------------------------------------------------------------------------- */
// create a function to instanciate the class
if (!function_exists('qam_snow_theme')) {
/**
* Return <code>qam_snow_theme</code> class instance
*
* @access public
* @since Snow 1.4
* @version 1.0
* @return array
*
* @author Q2A Market <http://www.q2amarket.com>
* @copyright (c) 2014, Q2A Market
* @license http://www.gnu.org/copyleft/gpl.html
*/
function qam_snow_theme()
{
return qam_snow_theme::instance();
}
}
// Declare global variable
if (class_exists('qam_snow_theme')) {
$GLOBALS['qam_snow'] = qam_snow_theme();
}
...@@ -34,43 +34,25 @@ ...@@ -34,43 +34,25 @@
*/ */
class qa_html_theme extends qa_html_theme_base class qa_html_theme extends qa_html_theme_base
{ {
/**
* @since Snow 1.4
* @param type $template
* @param type $content
* @param type $rooturl
* @param type $request
*/
public function __construct($template, $content, $rooturl, $request)
{
parent::__construct($template, $content, $rooturl, $request);
// theme subdirectories // theme subdirectories
$this->js_dir = 'js/'; private $js_dir = 'js';
$this->img_url = 'images/'; private $icon_url = 'images/icons';
$this->icon_url = $this->img_url . 'icons/';
/** private $fixed_topbar = false;
* Below condition only loads the require class if Q2A set private $welcome_widget_class = 'wet-asphalt';
* the Snow theme as site theme. private $ask_search_box_class = 'turquoise';
* If you change the theme name from `Snow` to anything, make sure to // Size of the user avatar in the navigation bar
* change in below condition private $nav_bar_avatar_size = 32;
*/
if (qa_opt('site_theme') === 'SnowFlat') {
require_once('inc/qam-snow-theme.php');
}
}
/** /**
* Adding aditional meta for responsive design * Adding aditional meta for responsive design
* *
* @since Snow 1.4 * @since Snow 1.4
* @global type $qam_snow
*/ */
public function head_metas() public function head_metas()
{ {
$this->output('<meta name="viewport" content="width=device-width, initial-scale=1"/>'); $this->output('<meta name="viewport" content="width=device-width, initial-scale=1"/>');
qa_html_theme_base::head_metas(); parent::head_metas();
} }
/** /**
...@@ -87,7 +69,7 @@ class qa_html_theme extends qa_html_theme_base ...@@ -87,7 +69,7 @@ class qa_html_theme extends qa_html_theme_base
// add Ubuntu font CSS file // add Ubuntu font CSS file
$this->content['css_src'][] = 'http://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic,700italic'; $this->content['css_src'][] = 'http://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic,700italic';
qa_html_theme_base::head_css(); parent::head_css();
// output some dynamic CSS inline // output some dynamic CSS inline
$this->head_inline_css(); $this->head_inline_css();
...@@ -100,24 +82,28 @@ class qa_html_theme extends qa_html_theme_base ...@@ -100,24 +82,28 @@ class qa_html_theme extends qa_html_theme_base
*/ */
public function head_script() public function head_script()
{ {
$jsUrl = $this->rooturl . $this->js_dir . 'snow-core.js?' . QA_VERSION; $jsUrl = $this->rooturl . $this->js_dir . '/snow-core.js?' . QA_VERSION;
$this->content['script'][] = '<script src="' . $jsUrl . '"></script>'; $this->content['script'][] = '<script src="' . $jsUrl . '"></script>';
qa_html_theme_base::head_script(); parent::head_script();
} }
/** /**
* Adding point count for logged in user * Adding point count for logged in user
* *
* @since Snow 1.4 * @since Snow 1.4
* @global array $qam_snow
*/ */
public function logged_in() public function logged_in()
{ {
global $qam_snow; parent::logged_in();
qa_html_theme_base::logged_in(); if (qa_is_logged_in()) {
$userpoints = qa_get_logged_in_points();
$this->output($qam_snow->headers['user_points']); $pointshtml = $userpoints == 1
? qa_lang_html_sub('main/1_point', '1', '1')
: qa_html(number_format($userpoints))
;
$this->output('<div class="qam-logged-in-points">' . $pointshtml . '</div>');
}
} }
/** /**
...@@ -128,58 +114,46 @@ class qa_html_theme extends qa_html_theme_base ...@@ -128,58 +114,46 @@ class qa_html_theme extends qa_html_theme_base
public function body() public function body()
{ {
if (qa_is_mobile_probably()) { if (qa_is_mobile_probably()) {
$this->output('<div id="qam-sidepanel-toggle"><i class="icon-left-open-big"></i></div>'); $this->output('<div id="qam-sidepanel-toggle"><i class="icon-left-open-big"></i></div>');
$this->output('<div id="qam-sidepanel-mobile">'); $this->output('<div id="qam-sidepanel-mobile">');
qa_html_theme_base::sidepanel(); parent::sidepanel();
$this->output('</div>'); $this->output('</div>');
} }
qa_html_theme_base::body(); parent::body();
} }
/** /**
* Adding body class dynamically * Adding body class dynamically. Override needed to add class on admin/approve-users page
*
* override to add class on admin/approve-users page
* *
* @since Snow 1.4 * @since Snow 1.4
* @return string body class
*/ */
public function body_tags() public function body_tags()
{ {
global $qam_snow;
$class = 'qa-template-' . qa_html($this->template); $class = 'qa-template-' . qa_html($this->template);
if (isset($this->content['categoryids'])) { if (isset($this->content['categoryids'])) {
foreach ($this->content['categoryids'] as $categoryid) foreach ($this->content['categoryids'] as $categoryid)
{
$class .= ' qa-category-' . qa_html($categoryid); $class .= ' qa-category-' . qa_html($categoryid);
} }
}
// add class if admin/appovoe-users page // add class if admin/appovoe-users page
if (($this->template === 'admin') && (qa_request_part(1) === 'approve')) { if ($this->template === 'admin' && qa_request_part(1) === 'approve')
$class .= ' qam-approve-users'; $class .= ' qam-approve-users';
}
if (isset($qam_snow->fixed_topbar)) if ($this->fixed_topbar)
$class .= ' qam-body-' . $qam_snow->fixed_topbar; $class .= ' qam-body-fixed';
$this->output('class="' . $class . ' qa-body-js-off"'); $this->output('class="' . $class . ' qa-body-js-off"');
} }
/** /**
* login form * Login form for user dropdown menu.
* *
* @since Snow 1.4 * @since Snow 1.4
* @global array $qam_snow
*/ */
public function nav_user_search() public function nav_user_search()
{ {
// outputs login form if user not logged in // outputs login form if user not logged in
global $qam_snow;
$this->output('<div class="qam-account-items-wrapper">'); $this->output('<div class="qam-account-items-wrapper">');
$this->qam_user_account(); $this->qam_user_account();
...@@ -190,7 +164,6 @@ class qa_html_theme extends qa_html_theme_base ...@@ -190,7 +164,6 @@ class qa_html_theme extends qa_html_theme_base
if (isset($this->content['navigation']['user']['login']) && !QA_FINAL_EXTERNAL_USERS) { if (isset($this->content['navigation']['user']['login']) && !QA_FINAL_EXTERNAL_USERS) {
$login = $this->content['navigation']['user']['login']; $login = $this->content['navigation']['user']['login'];
$this->output( $this->output(
'<!--[Begin: login form]-->',
'<form id="qa-loginform" action="' . $login['url'] . '" method="post">', '<form id="qa-loginform" action="' . $login['url'] . '" method="post">',
'<input type="text" id="qa-userid" name="emailhandle" placeholder="' . trim(qa_lang_html('users/email_handle_label'), ':') . '" />', '<input type="text" id="qa-userid" name="emailhandle" placeholder="' . trim(qa_lang_html('users/email_handle_label'), ':') . '" />',
'<input type="password" id="qa-password" name="password" placeholder="' . trim(qa_lang_html('users/password_label'), ':') . '" />', '<input type="password" id="qa-password" name="password" placeholder="' . trim(qa_lang_html('users/password_label'), ':') . '" />',
...@@ -198,11 +171,11 @@ class qa_html_theme extends qa_html_theme_base ...@@ -198,11 +171,11 @@ class qa_html_theme extends qa_html_theme_base
'<label for="qa-rememberme" id="qa-remember">' . qa_lang_html('users/remember') . '</label></div>', '<label for="qa-rememberme" id="qa-remember">' . qa_lang_html('users/remember') . '</label></div>',
'<input type="hidden" name="code" value="' . qa_html(qa_get_form_security_code('login')) . '" />', '<input type="hidden" name="code" value="' . qa_html(qa_get_form_security_code('login')) . '" />',
'<input type="submit" value="' . $login['label'] . '" id="qa-login" name="dologin" />', '<input type="submit" value="' . $login['label'] . '" id="qa-login" name="dologin" />',
'</form>', '</form>'
'<!--[End: login form]-->'
); );
unset($this->content['navigation']['user']['login']); // removes regular navigation link to log in page // remove regular navigation link to log in page
unset($this->content['navigation']['user']['login']);
} }
} }
...@@ -212,7 +185,7 @@ class qa_html_theme extends qa_html_theme_base ...@@ -212,7 +185,7 @@ class qa_html_theme extends qa_html_theme_base
} }
/** /**
* modifying markup for topbar * Modify markup for topbar.
* *
* @since Snow 1.4 * @since Snow 1.4
*/ */
...@@ -228,7 +201,7 @@ class qa_html_theme extends qa_html_theme_base ...@@ -228,7 +201,7 @@ class qa_html_theme extends qa_html_theme_base
} }
/** /**
* The method has been overridden to remove the '-' from the note for the category page (notes). * Remove the '-' from the note for the category page (notes).
* *
* @since Snow 1.4 * @since Snow 1.4
* @param type $navlink * @param type $navlink
...@@ -241,7 +214,6 @@ class qa_html_theme extends qa_html_theme_base ...@@ -241,7 +214,6 @@ class qa_html_theme extends qa_html_theme_base
$replace = array(' <', '> '); $replace = array(' <', '> ');
$navlink['note'] = str_replace($search, $replace, $navlink['note']); $navlink['note'] = str_replace($search, $replace, $navlink['note']);
} }
parent::nav_link($navlink, $class); parent::nav_link($navlink, $class);
} }
...@@ -284,15 +256,14 @@ class qa_html_theme extends qa_html_theme_base ...@@ -284,15 +256,14 @@ class qa_html_theme extends qa_html_theme_base
*/ */
public function header() public function header()
{ {
global $qam_snow; $class = $this->fixed_topbar ? ' fixed' : '';
$class = isset($qam_snow->fixed_topbar) ? ' ' . $qam_snow->fixed_topbar : '';
$this->output('<div id="qam-topbar" class="clearfix' . $class . '">'); $this->output('<div id="qam-topbar" class="clearfix' . $class . '">');
$this->nav_main_sub(); $this->nav_main_sub();
$this->output('</div><!-- END qam-topbar -->'); $this->output('</div> <!-- END qam-topbar -->');
$this->output($qam_snow->headers['ask_button']); $this->output($this->ask_button());
$this->qam_search('the-top', 'the-top-search'); $this->qam_search('the-top', 'the-top-search');
} }
...@@ -303,18 +274,14 @@ class qa_html_theme extends qa_html_theme_base ...@@ -303,18 +274,14 @@ class qa_html_theme extends qa_html_theme_base
*/ */
public function footer() public function footer()
{ {
// to replace standard Q2A footer
global $qam_snow;
$this->output($qam_snow->footer_custom_content);
$this->output('<div class="qam-footer-box">'); $this->output('<div class="qam-footer-box">');
$this->output('<div class="qam-footer-row">'); $this->output('<div class="qam-footer-row">');
$this->widgets('full', 'bottom'); $this->widgets('full', 'bottom');
$this->output('</div> <!-- END qam-footer-row -->'); $this->output('</div> <!-- END qam-footer-row -->');
qa_html_theme_base::footer(); parent::footer();
$this->output('</div> <!-- END qam-footer-box -->', ''); $this->output('</div> <!-- END qam-footer-box -->');
} }
/** /**
...@@ -325,7 +292,7 @@ class qa_html_theme extends qa_html_theme_base ...@@ -325,7 +292,7 @@ class qa_html_theme extends qa_html_theme_base
public function sidepanel() public function sidepanel()
{ {
// removes sidebar for user profile pages // removes sidebar for user profile pages
if (($this->template != 'user') && !qa_is_mobile_probably()) { if ($this->template != 'user' && !qa_is_mobile_probably()) {
$this->output('<div class="qa-sidepanel">'); $this->output('<div class="qa-sidepanel">');
$this->qam_search(); $this->qam_search();
$this->widgets('side', 'top'); $this->widgets('side', 'top');
...@@ -342,19 +309,16 @@ class qa_html_theme extends qa_html_theme_base ...@@ -342,19 +309,16 @@ class qa_html_theme extends qa_html_theme_base
} }
/** /**
* To provide various color option * Allow alternate sidebar color.
* *
* @since Snow 1.4 * @since Snow 1.4
* @global array $qam_snow
*/ */
public function sidebar() public function sidebar()
{ {
global $qam_snow;
if (isset($this->content['sidebar'])) { if (isset($this->content['sidebar'])) {
$sidebar = $this->content['sidebar']; $sidebar = $this->content['sidebar'];
if (!empty($sidebar)) { if (!empty($sidebar)) {
$this->output('<div class="qa-sidebar wet-asphalt ' . $qam_snow->welcome_widget_color . '">'); $this->output('<div class="qa-sidebar ' . $this->welcome_widget_class . '">');
$this->output_raw($sidebar); $this->output_raw($sidebar);
$this->output('</div>', ''); $this->output('</div>', '');
} }
...@@ -362,22 +326,29 @@ class qa_html_theme extends qa_html_theme_base ...@@ -362,22 +326,29 @@ class qa_html_theme extends qa_html_theme_base
} }
/** /**
* To add close icon * Add close icon
* *
* @since Snow 1.4 * @since Snow 1.4
* @param array $q_item * @param array $q_item
*/ */
public function q_item_title($q_item) public function q_item_title($q_item)
{ {
$closedText = qa_lang('main/closed');
$imgHtml = empty($q_item['closed'])
? ''
: '<img src="' . $this->rooturl . $this->icon_url . '/closed-q-list.png" class="qam-q-list-close-icon" alt="' . $closedText . '" title="' . $closedText . '" />';
$this->output( $this->output(
'<div class="qa-q-item-title">', '<div class="qa-q-item-title">',
// add closed note in title // add closed note in title
empty($q_item['closed']) ? '' : '<img src="' . $this->rooturl . $this->icon_url . '/closed-q-list.png" class="qam-q-list-close-icon" alt="question-closed" title="' . qa_lang('main/closed') . '" />', '<a href="' . $q_item['url'] . '">' . $q_item['title'] . '</a>', '</div>' $imgHtml,
'<a href="' . $q_item['url'] . '">' . $q_item['title'] . '</a>',
'</div>'
); );
} }
/** /**
* To add RSS feeds icon and closed icon for closed questions * Add RSS feeds icon and closed icon for closed questions
* *
* @since Snow 1.4 * @since Snow 1.4
*/ */
...@@ -396,29 +367,34 @@ class qa_html_theme extends qa_html_theme_base ...@@ -396,29 +367,34 @@ class qa_html_theme extends qa_html_theme_base
$url = isset($q_view['url']) ? $q_view['url'] : false; $url = isset($q_view['url']) ? $q_view['url'] : false;
// add closed image // add closed image
$closed = (!empty($q_view['closed']) ? $closedText = qa_lang('main/closed');
'<img src="' . $this->rooturl . $this->icon_url . '/closed-q-view.png" class="qam-q-view-close-icon" alt="question-closed" width="24" height="24" title="' . qa_lang('main/closed') . '" />' : null ); $imgHtml = empty($q_view['closed'])
? ''
: '<img src="' . $this->rooturl . $this->icon_url . '/closed-q-view.png" class="qam-q-view-close-icon" alt="' . $closedText . '" width="24" height="24" title="' . $closedText . '" />';
if (isset($this->content['title'])) { if (isset($this->content['title'])) {
$this->output( $this->output(
$closed, $url ? '<a href="' . $url . '">' : '', $this->content['title'], $url ? '</a>' : '' $imgHtml,
$url ? '<a href="' . $url . '">' : '',
$this->content['title'],
$url ? '</a>' : ''
); );
} }
} }
/** /**
* To add view counter * Add view counter to question list
* *
* @since Snow 1.4 * @since Snow 1.4
* @param array $q_item * @param array $q_item
*/ */
public function q_item_stats($q_item) public function q_item_stats($q_item)
{ // add view count to question list {
$this->output('<div class="qa-q-item-stats">'); $this->output('<div class="qa-q-item-stats">');
$this->voting($q_item); $this->voting($q_item);
$this->a_count($q_item); $this->a_count($q_item);
qa_html_theme_base::view_count($q_item); parent::view_count($q_item);
$this->output('</div>'); $this->output('</div>');
} }
...@@ -429,12 +405,10 @@ class qa_html_theme extends qa_html_theme_base ...@@ -429,12 +405,10 @@ class qa_html_theme extends qa_html_theme_base
* @since Snow 1.4 * @since Snow 1.4
* @param type $q_item * @param type $q_item
*/ */
public function view_count($q_item) public function view_count($q_item) {}
{ // Prevent display view counter on usual place
}
/** /**
* To add view counter * Add view counter to question view
* *
* @since Snow 1.4 * @since Snow 1.4
* @param type $q_view * @param type $q_view
...@@ -445,13 +419,13 @@ class qa_html_theme extends qa_html_theme_base ...@@ -445,13 +419,13 @@ class qa_html_theme extends qa_html_theme_base
$this->voting($q_view); $this->voting($q_view);
$this->a_count($q_view); $this->a_count($q_view);
qa_html_theme_base::view_count($q_view); parent::view_count($q_view);
$this->output('</div>'); $this->output('</div>');
} }
/** /**
* To modify user whometa, move to top * Modify user whometa, move to top
* *
* @since Snow 1.4 * @since Snow 1.4
* @param type $q_view * @param type $q_view
...@@ -485,7 +459,7 @@ class qa_html_theme extends qa_html_theme_base ...@@ -485,7 +459,7 @@ class qa_html_theme extends qa_html_theme_base
} }
/** /**
* To move user whometa to top in answer * Move user whometa to top in answer
* *
* @since Snow 1.4 * @since Snow 1.4
* @param type $a_item * @param type $a_item
...@@ -500,16 +474,21 @@ class qa_html_theme extends qa_html_theme_base ...@@ -500,16 +474,21 @@ class qa_html_theme extends qa_html_theme_base
$this->output('<form ' . $a_item['main_form_tags'] . '>'); // form for buttons on answer $this->output('<form ' . $a_item['main_form_tags'] . '>'); // form for buttons on answer
if ($a_item['hidden']) if ($a_item['hidden'])
$this->output('<div class="qa-a-item-hidden">'); $answerState = 'hidden';
elseif ($a_item['selected']) elseif ($a_item['selected'])
$this->output('<div class="qa-a-item-selected">'); $answerState = 'selected';
else
$answerState = null;
if (isset($answerState))
$this->output('<div class="qa-a-item-' . $answerState . '">');
$this->a_selection($a_item); $this->a_selection($a_item);
if (isset($a_item['error'])) if (isset($a_item['error']))
$this->error($a_item['error']); $this->error($a_item['error']);
$this->a_item_content($a_item); $this->a_item_content($a_item);
if ($a_item['hidden'] || $a_item['selected']) if (isset($answerState))
$this->output('</div>'); $this->output('</div>');
$this->a_item_buttons($a_item); $this->a_item_buttons($a_item);
...@@ -529,7 +508,7 @@ class qa_html_theme extends qa_html_theme_base ...@@ -529,7 +508,7 @@ class qa_html_theme extends qa_html_theme_base
} }
/** /**
* To move user whometa to top in comment * Move user whometa to top in comment
* *
* @since Snow 1.4 * @since Snow 1.4
* @param type $c_item * @param type $c_item
...@@ -558,7 +537,6 @@ class qa_html_theme extends qa_html_theme_base ...@@ -558,7 +537,6 @@ class qa_html_theme extends qa_html_theme_base
* I'd really appreciate you displaying this link on your Q2A site. Thank you - Jatin * I'd really appreciate you displaying this link on your Q2A site. Thank you - Jatin
* *
* @since Snow 1.4 * @since Snow 1.4
* @global array $qam_snow
*/ */
public function attribution() public function attribution()
{ {
...@@ -568,8 +546,7 @@ class qa_html_theme extends qa_html_theme_base ...@@ -568,8 +546,7 @@ class qa_html_theme extends qa_html_theme_base
'Snow Theme by <a href="http://www.q2amarket.com">Q2A Market</a>', 'Snow Theme by <a href="http://www.q2amarket.com">Q2A Market</a>',
'</div>' '</div>'
); );
parent::attribution();
qa_html_theme_base::attribution();
} }
/** /**
...@@ -581,16 +558,13 @@ class qa_html_theme extends qa_html_theme_base ...@@ -581,16 +558,13 @@ class qa_html_theme extends qa_html_theme_base
*/ */
private function qam_user_account() private function qam_user_account()
{ {
$avatarsize = 32;
// get logged-in user avatar
if (qa_is_logged_in()) { if (qa_is_logged_in()) {
// get logged-in user avatar
$handle = qa_get_logged_in_user_field('handle'); $handle = qa_get_logged_in_user_field('handle');
$toggleClass = 'qam-logged-in'; $toggleClass = 'qam-logged-in';
if (QA_FINAL_EXTERNAL_USERS) { if (QA_FINAL_EXTERNAL_USERS)
$tobar_avatar = qa_get_external_avatar_html( qa_get_logged_in_user_field('userid'), $avatarsize, true ); $tobar_avatar = qa_get_external_avatar_html(qa_get_logged_in_user_field('userid'), $this->nav_bar_avatar_size, true);
}
else { else {
$tobar_avatar = qa_get_user_avatar_html( $tobar_avatar = qa_get_user_avatar_html(
qa_get_logged_in_user_field('flags'), qa_get_logged_in_user_field('flags'),
...@@ -599,15 +573,15 @@ class qa_html_theme extends qa_html_theme_base ...@@ -599,15 +573,15 @@ class qa_html_theme extends qa_html_theme_base
qa_get_logged_in_user_field('avatarblobid'), qa_get_logged_in_user_field('avatarblobid'),
qa_get_logged_in_user_field('avatarwidth'), qa_get_logged_in_user_field('avatarwidth'),
qa_get_logged_in_user_field('avatarheight'), qa_get_logged_in_user_field('avatarheight'),
$avatarsize, $this->nav_bar_avatar_size,
false false
); );
} }
$auth_icon = strip_tags($tobar_avatar, '<img>'); $auth_icon = strip_tags($tobar_avatar, '<img>');
} }
// display login icon and label
else { else {
// display login icon and label
$handle = $this->content['navigation']['user']['login']['label']; $handle = $this->content['navigation']['user']['login']['label'];
$toggleClass = 'qam-logged-out'; $toggleClass = 'qam-logged-out';
$auth_icon = '<i class="icon-key qam-auth-key"></i>'; $auth_icon = '<i class="icon-key qam-auth-key"></i>';
...@@ -623,18 +597,16 @@ class qa_html_theme extends qa_html_theme_base ...@@ -623,18 +597,16 @@ class qa_html_theme extends qa_html_theme_base
} }
/** /**
* To add search-box wrapper with extra class for color scheme * Add search-box wrapper with extra class for color scheme
* *
* @since Snow 1.4 * @since Snow 1.4
* @version 1.0 * @version 1.0
*/ */
private function qam_search($addon_class = false, $ids = false) private function qam_search($addon_class = null, $ids = null)
{ {
$default_color = 'turquoise'; $id = isset($ids) ? ' id="' . $ids . '"' : '';
$id = (($ids) ? ' id="' . $ids . '"' : null);
$this->output('<div class="qam-search ' . $default_color . ' ' . $addon_class . '" ' . $id . ' >'); $this->output('<div class="qam-search ' . $this->ask_search_box_class . ' ' . $addon_class . '"' . $id . '>');
$this->search(); $this->search();
$this->output('</div>'); $this->output('</div>');
} }
...@@ -651,9 +623,8 @@ class qa_html_theme extends qa_html_theme_base ...@@ -651,9 +623,8 @@ class qa_html_theme extends qa_html_theme_base
{ {
$css = array('<style>'); $css = array('<style>');
if (!qa_is_logged_in()) { if (!qa_is_logged_in())
$css[] = '.qa-nav-user { margin: 0 !important; }'; $css[] = '.qa-nav-user { margin: 0 !important; }';
}
if (qa_request_part(1) !== qa_get_logged_in_handle()) { if (qa_request_part(1) !== qa_get_logged_in_handle()) {
$css[] = '@media (max-width: 979px) {'; $css[] = '@media (max-width: 979px) {';
...@@ -678,37 +649,25 @@ class qa_html_theme extends qa_html_theme_base ...@@ -678,37 +649,25 @@ class qa_html_theme extends qa_html_theme_base
} }
/** /**
* Question2Answer system icons info bar * Custom ask button for medium and small screen
* *
* @access private
* @since Snow 1.4 * @since Snow 1.4
* @return string Info icons HTML * @version 1.0
* @return string Ask button html markup
*/ */
private function icons_info() private function ask_button()
{ {
$icons = array( return
'answer', '<div class="qam-ask-search-box">' .
'comment', '<div class="qam-ask-mobile">' .
'hide', '<a href="' . qa_path('ask', null, qa_path_to_root()) . '" class="' . $this->ask_search_box_class . '">' .
'reshow', qa_lang_html('main/nav_ask') .
'close', '</a>' .
'reopen', '</div>' .
'flag', '<div class="qam-search-mobile ' . $this->ask_search_box_class . '" id="qam-search-mobile">' .
'unflag', '</div>' .
'edit', '</div>';
'delete',
'approve',
'reject',
'reply',
);
$icons_info = '<div class="qam-icons-info">';
foreach ($icons as $icon) {
$label = ucwords(qa_lang_html('question/' . $icon . '_button'));
$icons_info .= '<div class="qam-icon-item"><span class="' . $icon . '"></span> ' . $label . '</div>';
} }
$icons_info .= '</div> <!-- END qam-icons-info -->';
return $icons_info;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment