PageRenderTime 39ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/qa-include/plugins/qa-widget-ask-box.php

http://github.com/q2a/question2answer
PHP | 67 lines | 44 code | 4 blank | 19 comment | 4 complexity | 4c02d6ca9a26b3cc036cb3a87b34e715 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /*
  3. Question2Answer by Gideon Greenspan and contributors
  4. http://www.question2answer.org/
  5. Description: Widget module class for ask a question box
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. More about this license: http://www.question2answer.org/license.php
  15. */
  16. class qa_ask_box
  17. {
  18. public function allow_template($template)
  19. {
  20. $allowed = array(
  21. 'activity', 'categories', 'custom', 'feedback', 'qa', 'questions',
  22. 'hot', 'search', 'tag', 'tags', 'unanswered',
  23. );
  24. return in_array($template, $allowed);
  25. }
  26. public function allow_region($region)
  27. {
  28. return in_array($region, array('main', 'side', 'full'));
  29. }
  30. public function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
  31. {
  32. if (isset($qa_content['categoryids']))
  33. $params = array('cat' => end($qa_content['categoryids']));
  34. else
  35. $params = null;
  36. ?>
  37. <div class="qa-ask-box">
  38. <form method="post" action="<?php echo qa_path_html('ask', $params); ?>">
  39. <table class="qa-form-tall-table" style="width:100%">
  40. <tr style="vertical-align:middle;">
  41. <td class="qa-form-tall-label" style="width: 1px; padding:8px; white-space:nowrap; <?php echo ($region == 'side') ? 'padding-bottom:0;' : 'text-align:right;'?>">
  42. <?php echo strtr(qa_lang_html('question/ask_title'), array(' ' => '&nbsp;'))?>:
  43. </td>
  44. <?php if ($region == 'side') : ?>
  45. </tr>
  46. <tr>
  47. <?php endif; ?>
  48. <td class="qa-form-tall-data" style="padding:8px;">
  49. <input name="title" type="text" class="qa-form-tall-text" style="width:95%;">
  50. </td>
  51. </tr>
  52. </table>
  53. <input type="hidden" name="doask1" value="1">
  54. </form>
  55. </div>
  56. <?php
  57. }
  58. }