PageRenderTime 39ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/modules/comment/comment.Show.php

https://github.com/KenBoyer/CompactCMS
PHP | 177 lines | 116 code | 26 blank | 35 comment | 8 complexity | d771aa44b7b9c0bb54e845ba935b376a MD5 | raw file
  1. <?php
  2. /* ************************************************************
  3. Copyright (C) 2008 - 2010 by Xander Groesbeek (CompactCMS.nl)
  4. Revision: CompactCMS - v 1.4.2
  5. This file is part of CompactCMS.
  6. CompactCMS is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. CompactCMS 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. A reference to the original author of CompactCMS and its copyright
  15. should be clearly visible AT ALL TIMES for the user of the back-
  16. end. You are NOT allowed to remove any references to the original
  17. author, communicating the product to be your own, without written
  18. permission of the original copyright owner.
  19. You should have received a copy of the GNU General Public License
  20. along with CompactCMS. If not, see <http://www.gnu.org/licenses/>.
  21. > Contact me for any inquiries.
  22. > E: Xander@CompactCMS.nl
  23. > W: http://community.CompactCMS.nl/forum
  24. ************************************************************ */
  25. /* make sure no-one can run anything here if they didn't arrive through 'proper channels' */
  26. if(!defined("COMPACTCMS_CODE")) { die('Illegal entry point!'); } /*MARKER*/
  27. // Set Captcha value
  28. $_SESSION['ccms_captcha'] = mt_rand('123456','987654');
  29. // Load comment preferences
  30. $pagename = getGETparam4Filename('page');
  31. $is_printing = ($ccms['printing'] == 'Y');
  32. $pagerow = $db->SelectSingleRow($cfg['db_prefix'].'pages', array('urlpage' => MySQL::SQLValue($pagename,MySQL::SQLVALUE_TEXT)));
  33. if ($db->ErrorNumber() != 0) $db->Kill();
  34. $page_id = $pagerow->page_id;
  35. if (empty($page_id) || empty($pagename))
  36. {
  37. die($ccms['lang']['system']['error_forged'] . ' (' . __FILE__ . ', ' . __LINE__ . ')' );
  38. }
  39. // code requires mootools: make sure we load it!
  40. tmpl_set_autoprio($ccms['JS.required_files'], $cfg['rootdir'] . 'lib/includes/js/mootools-core.js');
  41. tmpl_set_autoprio($ccms['JS.required_files'], $cfg['rootdir'] . 'lib/includes/js/mootools-more.js');
  42. // now register our own JS and make sure it ends up AFTER the mootools stuff has been loaded:
  43. tmpl_set_autoprio($ccms['JS.required_files'], $cfg['rootdir'] . 'lib/modules/comment/resources/script.js');
  44. tmpl_set_autoprio($ccms['CSS.required_files'], $cfg['rootdir'] . 'lib/modules/comment/resources/style.css > media="screen" title="comments"');
  45. // window.addEvent("domready", function() {
  46. $cmtdir = $cfg['rootdir'] . 'lib/modules/comment';
  47. $ccms['JS.done'][] = <<<EOT42
  48. window.addEvent(
  49. 'domready',
  50. function()
  51. {
  52. var req=new Request.HTML(
  53. {
  54. useSpinner:true,
  55. method:'get',
  56. url:'$cmtdir/comment.Process.php?action=show-comments&page_id=$page_id',
  57. update:$('comments'),
  58. onRequest:function(){},
  59. onFailure:function(){},
  60. onSuccess:function(){ajaxLinks();}
  61. }).send();
  62. function ajaxLinks()
  63. {
  64. $$('.pagination a').each(
  65. function(ele)
  66. {
  67. ele.addEvent(
  68. 'click',
  69. function(e)
  70. {
  71. e=new Event(e).stop();
  72. var alink=ele.getProperty('href');
  73. var qrypos = alink.indexOf('?');
  74. var url='$cmtdir/comment.Process.php'+alink.substr(qrypos);
  75. var ajaxLink=new Request.HTML(
  76. {
  77. useSpinner:true,
  78. method:'get',
  79. url:url,
  80. onRequest:function(){},
  81. onSuccess:function()
  82. {
  83. new Fx.Scroll(document.body, {'duration':'long'}).toElement('comments');
  84. ajaxLinks();
  85. },
  86. onFailure:function(){},
  87. update:$('comments')
  88. }).send(); /* .get(url) didn't work all of a sudden in last edit; send() with method get() /does/ work */
  89. });
  90. });
  91. }
  92. });
  93. EOT42;
  94. ?>
  95. <div id="comments">
  96. <!--spinner-->
  97. </div>
  98. <?php
  99. if (!$is_printing)
  100. {
  101. ?>
  102. <div id="preview-display" style="display:none;">
  103. <h2><?php echo $ccms['lang']['guestbook']['preview']; ?></h2>
  104. <?php
  105. if ($cfg['enable_gravatar'])
  106. {
  107. ?>
  108. <div id="preview-avatar"></div>
  109. <?php
  110. }
  111. ?>
  112. <div id="preview-name"></div>
  113. <div id="preview-comment"></div>
  114. <div id="preview-rating"></div>
  115. </div>
  116. <fieldset id="comment-field" style="clear:both;">
  117. <legend><a href="" class="toggle"><?php echo $ccms['lang']['guestbook']['add']; ?></a></legend>
  118. <form action="" id="commentForm" method="post" accept-charset="utf-8">
  119. <div id="toggle-field">
  120. <label for="name"><?php echo $ccms['lang']['guestbook']['name']; ?>*</label><input type="text" name="name" id="name" value="" class="text required" /><br/>
  121. <label for="email"><?php echo $ccms['lang']['guestbook']['email']; ?>*</label><input type="text" name="email" id="email" value="" class="text required validate-email" /><br/>
  122. <label for="website"><?php echo $ccms['lang']['guestbook']['website']; ?></label><input type="text" name="website" id="website" value="" class="text validate-url" /><br/>
  123. <label for="comment"><?php echo $ccms['lang']['guestbook']['comments']; ?>*</label>
  124. <textarea name="comment" id="comment" class="text minLength:10" style="height:80px; width: 100%;"></textarea><br/>
  125. <label for="rating"><?php echo $ccms['lang']['guestbook']['rating']; ?></label>
  126. <select name="rating" id="rating" size="1">
  127. <option value="1">1 *</option>
  128. <option value="2">2 **</option>
  129. <option value="3" selected="selected">3 ***</option>
  130. <option value="4">4 ****</option>
  131. <option value="5">5 *****</option>
  132. </select><br/>
  133. <p><?php echo $ccms['lang']['guestbook']['verinstr']; ?> <span style="font-weight:bold;color: #f00;"><?php echo $_SESSION['ccms_captcha']; ?></span>.</p>
  134. <label for="verification"><?php echo $ccms['lang']['guestbook']['verify']; ?></label><input type="input" name="verification" style="width:50px;" maxlength="6" value="" id="verification" class="required validate-match matchInput:'captcha_check' matchName:'captcha' text"/>
  135. <input type="hidden" name="captcha_check" value="<?php echo $_SESSION['ccms_captcha']; ?>" id="captcha_check" />
  136. <input type="hidden" name="page_id" value="<?php echo $page_id; ?>" id="page_id" />
  137. <p style="margin-bottom:20px;text-align:center;">
  138. <button name="submit_gb" type="submit"><?php echo $ccms['lang']['guestbook']['add']; ?></button>
  139. </p>
  140. </div>
  141. </form>
  142. </fieldset>
  143. <?php
  144. }
  145. ?>