PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/campsite/src/plugins/poll/smarty_camp_plugins/block.pollanswer_ajax.php

https://github.com/joechrysler/Campsite
PHP | 62 lines | 27 code | 11 blank | 24 comment | 6 complexity | 845cca8e578873c301df5a2fd12671e2 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, LGPL-2.1, Apache-2.0
  1. <?php
  2. /**
  3. * Campsite customized Smarty plugin
  4. * @package Campsite
  5. */
  6. /**
  7. * Campsite pollanswer_ajax block plugin
  8. *
  9. * Type: block
  10. * Name: pollanswer_ajax
  11. * Purpose: Provides ajax code for an poll answer
  12. *
  13. * @param string
  14. * $p_params
  15. * @param string
  16. * $p_smarty
  17. * @param string
  18. * $p_content
  19. *
  20. * @return
  21. *
  22. */
  23. function smarty_block_pollanswer_ajax($p_params, $p_content, &$p_smarty, &$p_repeat)
  24. {
  25. require_once $p_smarty->_get_plugin_filepath('shared','escape_special_chars');
  26. // gets the context variable
  27. $campsite = $p_smarty->get_template_vars('campsite');
  28. $html = '';
  29. // the value for this rating
  30. if (settype($p_params['value'], 'integer') && $p_params['value'] != 0) {
  31. $value = $p_params['value'];
  32. } else {
  33. $value = 1;
  34. }
  35. $poll_nr = $campsite->poll->number;
  36. $language_id = $campsite->poll->language_id;
  37. $answer_nr = $campsite->pollanswer->number;
  38. $id = "f_pollanswer_{$poll_nr}_{$language_id}_{$answer_nr}_{$value}";
  39. // store the allowed values to session for verifying the voting action
  40. $_SESSION['camp_poll_maxvote'][$poll_nr][$language_id][$answer_nr][$value] = true;
  41. if (isset($p_content)) {
  42. if ($campsite->poll->is_votable) {
  43. $html .= "<span onClick=\"$('{$id}').checked=true; poll_{$campsite->poll->identifier}_vote()\" style=\"cursor: pointer\" >\n";
  44. }
  45. $html .= "<input type=\"radio\" id=\"{$id}\" name=\"f_pollanswer_{$answer_nr}\" value=\"{$value}\" style=\"display: none\" />\n";
  46. $html .= $p_content;
  47. $html .= "</span>\n";
  48. }
  49. return $html;
  50. } // fn smarty_block_poll_form
  51. ?>