PageRenderTime 51ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/manager/actions/search.static.php

https://github.com/good-web-master/modx.evo.custom
PHP | 147 lines | 134 code | 11 blank | 2 comment | 15 complexity | 3db63387982d040151db8f9bbc6b163d MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0, GPL-2.0, MIT, BSD-3-Clause
  1. <?php
  2. if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the MODx Content Manager instead of accessing this file directly.");
  3. unset($_SESSION['itemname']); // clear this, because it's only set for logging purposes
  4. ?>
  5. <h1><?php echo $_lang['search_criteria']; ?></h1>
  6. <div class="sectionBody">
  7. <form action="index.php?a=71" method="post" name="searchform">
  8. <table width="100%" border="0">
  9. <tr>
  10. <td width="120"><?php echo $_lang['search_criteria_id']; ?></td>
  11. <td width="20">&nbsp;</td>
  12. <td width="120"><input name="searchid" type="text" /></td>
  13. <td><?php echo $_lang['search_criteria_id_msg']; ?></td>
  14. </tr>
  15. <tr>
  16. <td><?php echo $_lang['search_criteria_title']; ?></td>
  17. <td>&nbsp;</td>
  18. <td><input name="pagetitle" type="text" /></td>
  19. <td><?php echo $_lang['search_criteria_title_msg']; ?></td>
  20. </tr>
  21. <tr>
  22. <td><?php echo $_lang['search_criteria_longtitle']; ?></td>
  23. <td>&nbsp;</td>
  24. <td><input name="longtitle" type="text" /></td>
  25. <td><?php echo $_lang['search_criteria_longtitle_msg']; ?></td>
  26. </tr>
  27. <tr>
  28. <td><?php echo $_lang['search_criteria_content']; ?></td>
  29. <td>&nbsp;</td>
  30. <td><input name="content" type="text" /></td>
  31. <td><?php echo $_lang['search_criteria_content_msg']; ?></td>
  32. </tr>
  33. <tr>
  34. <td colspan="4">
  35. <ul class="actionButtons">
  36. <li><a href="#" onclick="document.searchform.submitok.click();"><img src="<?php echo $_style["icons_save"] ?>" /> <?php echo $_lang['search'] ?></a></li>
  37. <li><a href="index.php?a=2"><img src="<?php echo $_style["icons_cancel"] ?>" /> <?php echo $_lang['cancel'] ?></a></li>
  38. </ul>
  39. </td>
  40. </tr>
  41. </table>
  42. <input type="submit" value="Search" name="submitok" style="display:none" />
  43. </form>
  44. </div>
  45. <?php
  46. if(isset($_REQUEST['submitok'])) {
  47. $searchid = !empty($_REQUEST['searchid']) ? intval($_REQUEST['searchid']) : 0;
  48. $searchtitle = htmlentities($_POST['pagetitle'], ENT_QUOTES, $modx_manager_charset);
  49. $searchcontent = $modx->db->escape($_REQUEST['content']);
  50. $searchlongtitle = $modx->db->escape($_REQUEST['longtitle']);
  51. $sqladd .= $searchid!="" ? " AND $dbase.`".$table_prefix."site_content`.id='$searchid' " : "" ;
  52. $sqladd .= $searchtitle!="" ? " AND $dbase.`".$table_prefix."site_content`.pagetitle LIKE '%$searchtitle%' " : "" ;
  53. $sqladd .= $searchlongtitle!="" ? " AND $dbase.`".$table_prefix."site_content`.longtitle LIKE '%$searchlongtitle%' " : "" ;
  54. $sqladd .= $searchcontent!="" ? " AND $dbase.`".$table_prefix."site_content`.content LIKE '%$searchcontent%' " : "" ;
  55. $sql = "SELECT id, contenttype, pagetitle, description, deleted, published, isfolder, type FROM $dbase.`".$table_prefix."site_content` where 1=1 ".$sqladd." ORDER BY id;";
  56. $rs = $modx->db->query($sql);
  57. $limit = $modx->db->getRecordCount($rs);
  58. ?>
  59. <div class="sectionHeader"><?php echo $_lang['search_results']; ?></div><div class="sectionBody">
  60. <?php
  61. if($limit<1) {
  62. echo $_lang['search_empty'];
  63. } else {
  64. printf('<p>'.$_lang['search_results_returned_msg'].'</p>', $limit);
  65. ?>
  66. <script type="text/javascript" src="media/script/tablesort.js"></script>
  67. <table border="0" cellpadding="2" cellspacing="0" class="sortabletable sortable-onload-2 rowstyle-even" id="table-1" width="90%">
  68. <thead>
  69. <tr bgcolor="#CCCCCC">
  70. <th width="20"></th>
  71. <th class="sortable"><b><?php echo $_lang['search_results_returned_id']; ?></b></th>
  72. <th class="sortable"><b><?php echo $_lang['search_results_returned_title']; ?></b></th>
  73. <th class="sortable"><b><?php echo $_lang['search_results_returned_desc']; ?></b></th>
  74. <th width="20"></th>
  75. </tr>
  76. </thead>
  77. <tbody>
  78. <?php
  79. // icons by content type
  80. $icons = array(
  81. 'application/rss+xml' => $_style["tree_page_rss"],
  82. 'application/pdf' => $_style["tree_page_pdf"],
  83. 'application/vnd.ms-word' => $_style["tree_page_word"],
  84. 'application/vnd.ms-excel' => $_style["tree_page_excel"],
  85. 'text/css' => $_style["tree_page_css"],
  86. 'text/html' => $_style["tree_page_html"],
  87. 'text/plain' => $_style["tree_page"],
  88. 'text/xml' => $_style["tree_page_xml"],
  89. 'text/javascript' => $_style["tree_page_js"],
  90. 'image/gif' => $_style["tree_page_gif"],
  91. 'image/jpg' => $_style["tree_page_jpg"],
  92. 'image/png' => $_style["tree_page_png"]
  93. );
  94. for ($i = 0; $i < $limit; $i++) {
  95. $logentry = $modx->db->getRow($rs);
  96. // figure out the icon for the document...
  97. $icon = "";
  98. if ($logentry['type']=='reference') {
  99. $icon .= $_style["tree_linkgo"];
  100. } elseif ($logentry['isfolder'] == 0) {
  101. $icon .= isset($icons[$logentry['contenttype']]) ? $icons[$logentry['contenttype']] : $_style["tree_page_html"];
  102. } else {
  103. $icon .= $_style['tree_folder'];
  104. }
  105. $tdClass = "";
  106. if($logentry['published'] == 0) {
  107. $tdClass .= ' class="unpublishedNode"';
  108. }
  109. if($logentry['deleted'] == 1) {
  110. $tdClass .= ' class="deletedNode"';
  111. }
  112. ?>
  113. <tr>
  114. <td align="center"><a href="index.php?a=3&id=<?php echo $logentry['id']; ?>" title="<?php echo $_lang['search_view_docdata']; ?>"><img src="<?php echo $_style['icons_resource_overview']; ?>" width="16" height="16" /></a></td>
  115. <td><?php echo $logentry['id']; ?></td>
  116. <?php if (function_exists('mb_strlen') && function_exists('mb_substr')) {?>
  117. <td<?php echo $tdClass; ?>><?php echo mb_strlen($logentry['pagetitle'], $modx_manager_charset)>20 ? mb_substr($logentry['pagetitle'], 0, 20, $modx_manager_charset)."..." : $logentry['pagetitle'] ; ?></td>
  118. <td<?php echo $tdClass; ?>><?php echo mb_strlen($logentry['description'], $modx_manager_charset)>35 ? mb_substr($logentry['description'], 0, 35, $modx_manager_charset)."..." : $logentry['description'] ; ?></td>
  119. <?php } else { ?>
  120. <td<?php echo $tdClass; ?>><?php echo strlen($logentry['pagetitle'])>20 ? substr($logentry['pagetitle'], 0, 20)."..." : $logentry['pagetitle'] ; ?></td>
  121. <td<?php echo $tdClass; ?>><?php echo strlen($logentry['description'])>35 ? substr($logentry['description'], 0, 35)."..." : $logentry['description'] ; ?></td>
  122. <?php } ?>
  123. <td align="center"><img src="<?php echo $icon; ?>" /></td>
  124. </tr>
  125. <?php
  126. }
  127. ?>
  128. </tbody>
  129. </table>
  130. <?php
  131. }
  132. ?>
  133. </div>
  134. <?php
  135. }
  136. ?>