qa-theme.php 5.51 KB
Newer Older
Gideon Greenspan committed
1 2 3 4 5
<?php


	class qa_html_theme extends qa_html_theme_base
	{	
Gideon Greenspan committed
6

Gideon Greenspan committed
7 8 9 10 11
		function head_script() // change style of WYSIWYG editor to match theme better
		{
			qa_html_theme_base::head_script();
			
			$this->output(
Gideon Greenspan committed
12
				'<script type="text/javascript">',
Gideon Greenspan committed
13 14
				"if (typeof qa_wysiwyg_editor_config == 'object')",
				"\tqa_wysiwyg_editor_config.skin='kama';",
Gideon Greenspan committed
15
				'</script>'
Gideon Greenspan committed
16 17 18 19 20 21 22 23
			);
		}
		
		function nav_user_search() // outputs login form if user not logged in
		{
			if (!qa_is_logged_in()) {
				$login=@$this->content['navigation']['user']['login'];
				
Gideon Greenspan committed
24
				if (isset($login) && !QA_FINAL_EXTERNAL_USERS) {
Gideon Greenspan committed
25 26 27
					$this->output(
						'<!--[Begin: login form]-->',				
						'<form id="qa-loginform" action="'.$login['url'].'" method="post">',
Gideon Greenspan committed
28
							'<input type="text" id="qa-userid" name="emailhandle" placeholder="'.trim(qa_lang_html(qa_opt('allow_login_email_only') ? 'users/email_label' : 'users/email_handle_label'), ':').'" />',
Gideon Greenspan committed
29
							'<input type="password" id="qa-password" name="password" placeholder="'.trim(qa_lang_html('users/password_label'), ':').'" />',
Gideon Greenspan committed
30 31
							'<div id="qa-rememberbox"><input type="checkbox" name="remember" id="qa-rememberme" value="1"/>',
							'<label for="qa-rememberme" id="qa-remember">'.qa_lang_html('users/remember').'</label></div>',
Gideon Greenspan committed
32
							'<input type="hidden" name="code" value="'.qa_html(qa_get_form_security_code('login')).'"/>',
Gideon Greenspan committed
33 34 35 36 37 38 39 40 41 42 43 44
							'<input type="submit" value="'.$login['label'].'" id="qa-login" name="dologin" />',
						'</form>',				
						'<!--[End: login form]-->'
					);
					
					unset($this->content['navigation']['user']['login']); // removes regular navigation link to log in page
				}
			}
			
			qa_html_theme_base::nav_user_search();
		}
		
Gideon Greenspan committed
45
		function logged_in() 
Gideon Greenspan committed
46
		{
Gideon Greenspan committed
47 48
			if (qa_is_logged_in()) // output user avatar to login bar
				$this->output(
Gideon Greenspan committed
49
					'<div class="qa-logged-in-avatar">',
Gideon Greenspan committed
50 51 52 53 54
					QA_FINAL_EXTERNAL_USERS
					? qa_get_external_avatar_html(qa_get_logged_in_userid(), 24, true)
					: qa_get_user_avatar_html(qa_get_logged_in_flags(), qa_get_logged_in_email(), qa_get_logged_in_handle(),
						qa_get_logged_in_user_field('avatarblobid'), qa_get_logged_in_user_field('avatarwidth'), qa_get_logged_in_user_field('avatarheight'),
						24, true),
Gideon Greenspan committed
55
            		'</div>'
Gideon Greenspan committed
56 57
            	);				
			
Gideon Greenspan committed
58 59
			qa_html_theme_base::logged_in();
			
Gideon Greenspan committed
60
			if (qa_is_logged_in()) { // adds points count after logged in username
Gideon Greenspan committed
61 62 63 64 65 66 67
				$userpoints=qa_get_logged_in_points();
				
				$pointshtml=($userpoints==1)
					? qa_lang_html_sub('main/1_point', '1', '1')
					: qa_lang_html_sub('main/x_points', qa_html(number_format($userpoints)));
						
				$this->output(
Gideon Greenspan committed
68
					'<span class="qa-logged-in-points">',
Gideon Greenspan committed
69
					'('.$pointshtml.')',
Gideon Greenspan committed
70
					'</span>'
Gideon Greenspan committed
71 72 73 74 75 76 77 78 79 80 81 82 83 84
				);
			}
		}
    
		function body_header() // adds login bar, user navigation and search at top of page in place of custom header content
		{
			$this->output('<div id="qa-login-bar"><div id="qa-login-group">');
			$this->nav_user_search();
            $this->output('</div></div>');
        }
		
		function header_custom() // allows modification of custom element shown inside header after logo
		{
			if (isset($this->content['body_header'])) {
Gideon Greenspan committed
85
				$this->output('<div class="header-banner">');
Gideon Greenspan committed
86
				$this->output_raw($this->content['body_header']);
Gideon Greenspan committed
87
				$this->output('</div>');
Gideon Greenspan committed
88 89 90
			}
		}
		
Gideon Greenspan committed
91
		function header() // removes user navigation and search from header and replaces with custom header content. Also opens new <div>s
Gideon Greenspan committed
92
		{	
Gideon Greenspan committed
93
			$this->output('<div class="qa-header">');
Gideon Greenspan committed
94 95 96 97 98
			
			$this->logo();						
			$this->header_clear();
			$this->header_custom();

Gideon Greenspan committed
99
			$this->output('</div> <!-- END qa-header -->', '');
Gideon Greenspan committed
100

Gideon Greenspan committed
101 102
			$this->output('<div class="qa-main-shadow">', '');
			$this->output('<div class="qa-main-wrapper">', '');
Gideon Greenspan committed
103 104 105 106
			$this->nav_main_sub();

		}
		
Gideon Greenspan committed
107 108 109 110 111 112
		function sidepanel() // removes sidebar for user profile pages
		{
			if ($this->template!='user')
				qa_html_theme_base::sidepanel();
		}
		
Gideon Greenspan committed
113
		function footer() // prevent display of regular footer content (see body_suffix()) and replace with closing new <div>s
Gideon Greenspan committed
114
		{
Gideon Greenspan committed
115 116
			$this->output('</div> <!-- END main-wrapper -->');
			$this->output('</div> <!-- END main-shadow -->');		
Gideon Greenspan committed
117 118 119 120 121 122 123 124 125
		}		
		
		function title() // add RSS feed icon after the page title
		{
			qa_html_theme_base::title();
			
			$feed=@$this->content['feed'];
			
			if (!empty($feed))
Gideon Greenspan committed
126
				$this->output('<a href="'.$feed['url'].'" title="'.@$feed['label'].'"><img src="'.$this->rooturl.'images/rss.jpg" alt="" width="16" height="16" border="0" class="qa-rss-icon"/></a>');
Gideon Greenspan committed
127 128 129 130
		}
		
		function q_item_stats($q_item) // add view count to question list
		{
Gideon Greenspan committed
131
			$this->output('<div class="qa-q-item-stats">');
Gideon Greenspan committed
132 133 134 135 136
			
			$this->voting($q_item);
			$this->a_count($q_item);
			qa_html_theme_base::view_count($q_item);

Gideon Greenspan committed
137
			$this->output('</div>');
Gideon Greenspan committed
138 139 140
		}
		
		function view_count($q_item) // prevent display of view count in the usual place
Gideon Greenspan committed
141 142 143
		{	
			if ($this->template=='question')
				qa_html_theme_base::view_count($q_item);
Gideon Greenspan committed
144 145 146 147 148 149
		}
		
		function body_suffix() // to replace standard Q2A footer
        {
			$this->output('<div class="qa-footer-bottom-group">');
			qa_html_theme_base::footer();
Gideon Greenspan committed
150
			$this->output('</div> <!-- END footer-bottom-group -->', '');
Gideon Greenspan committed
151 152 153 154 155
        }
		
		function attribution()
		{
			$this->output(
Gideon Greenspan committed
156
				'<div class="qa-attribution">',
Gideon Greenspan committed
157
				'&nbsp;| Snow Theme by <a href="http://www.q2amarket.com">Q2A Market</a>',
Gideon Greenspan committed
158
				'</div>'
Gideon Greenspan committed
159 160 161 162 163 164
			);

			qa_html_theme_base::attribution();
		}
		
	}
Gideon Greenspan committed
165

Gideon Greenspan committed
166 167 168 169

/*
	Omit PHP closing tag to help avoid accidental output
*/