qa-widget-ask-box.php 2.02 KB
Newer Older
Scott committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
<?php
/*
	Question2Answer by Gideon Greenspan and contributors
	http://www.question2answer.org/

	Description: Widget module class for ask a question box


	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 2
	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.

	More about this license: http://www.question2answer.org/license.php
*/

Scott committed
22 23 24 25 26 27
class qa_ask_box
{
	public function allow_template($template)
	{
		$allowed = array(
			'activity', 'categories', 'custom', 'feedback', 'qa', 'questions',
Scott committed
28
			'hot', 'search', 'tag', 'tags', 'unanswered',
Scott committed
29 30 31
		);
		return in_array($template, $allowed);
	}
Scott committed
32

Scott committed
33 34 35 36
	public function allow_region($region)
	{
		return in_array($region, array('main', 'side', 'full'));
	}
Scott committed
37

Scott committed
38 39 40
	public function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
	{
		if (isset($qa_content['categoryids']))
Scott committed
41
			$params = array('cat' => end($qa_content['categoryids']));
Scott committed
42
		else
Scott committed
43 44
			$params = null;

Scott committed
45 46 47 48 49
?>
<div class="qa-ask-box">
	<form method="post" action="<?php echo qa_path_html('ask', $params); ?>">
		<table class="qa-form-tall-table" style="width:100%">
			<tr style="vertical-align:middle;">
Scott committed
50
				<td class="qa-form-tall-label" style="width: 1px; padding:8px; white-space:nowrap; <?php echo ($region=='side') ? 'padding-bottom:0;' : 'text-align:right;'?>">
Scott committed
51 52
					<?php echo strtr(qa_lang_html('question/ask_title'), array(' ' => '&nbsp;'))?>:
				</td>
Scott committed
53
<?php if ($region=='side') : ?>
Scott committed
54 55
			</tr>
			<tr>
Scott committed
56
<?php endif; ?>
Scott committed
57
				<td class="qa-form-tall-data" style="padding:8px;">
Scott committed
58 59 60 61 62 63 64 65 66
					<input name="title" type="text" class="qa-form-tall-text" style="width:95%;">
				</td>
			</tr>
		</table>
		<input type="hidden" name="doask1" value="1">
	</form>
</div>
<?php
	}
Scott committed
67
}