You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

418 lines
19 KiB

  1. <!-- Global configuration -->
  2. <script language="javascript">
  3. var explainURL = "<?php h(url("collection.explainQuery"));?>";
  4. var currentURL = "<?php h($_SERVER["REQUEST_URI"]); ?>";
  5. var currentDb = "<?php h($db);?>";
  6. var currentCollection = "<?php h($collection); ?>";
  7. var currentFormat = "<?php h(x("format")); ?>";
  8. var currentRecordsCount = <?php echo $recordsCount;?>;
  9. var currentFields = new Array();
  10. <?php foreach ($nativeFields as $field): if($field == "_id") {continue;} ?>
  11. currentFields.push("<?php h(addslashes($field));?>");
  12. <?php endforeach;?>
  13. </script>
  14. <!-- Import resources -->
  15. <script language="javascript" src="js/collection.js?v=<?php h(filemtime("js/collection.js")) ?>"></script>
  16. <script language="javascript" src="js/jquery-ui-1.8.4.custom.min.js"></script>
  17. <link rel="stylesheet" href="<?php render_theme_path() ?>/css/collection.css" media="all"/>
  18. <link rel="stylesheet" href="<?php render_theme_path() ?>/css/jquery-ui-1.8.4.smoothness.css" media="all"/>
  19. <a name="page_top"></a>
  20. <!-- Navigation & Menu -->
  21. <h3><?php render_navigation($db, $collection, false);?></h3>
  22. <div class="operation">
  23. <strong><?php hm("query"); ?></strong>[<a href="<?php h($arrayLink);?>" <?php if(x("format")=="array"):?>style="text-decoration:underline"<?php endif;?>>Array</a>|<a href="<?php h($jsonLink); ?>" <?php if(x("format")!="array"):?>style="text-decoration:underline"<?php endif;?>>JSON</a></a>] | <?php if ($_logQuery): ?><a href="#" onclick="showQueryHistory();return false;">History</a> | <?php endif;?>
  24. <a href="<?php h($_SERVER["REQUEST_URI"]);?>"><?php hm("refresh"); ?></a> |
  25. <?php render_collection_menu($db, $collection) ?>
  26. </div>
  27. <!-- Query box -->
  28. <div class="query">
  29. <form method="get" id="query_form">
  30. <input type="hidden" name="db" value="<?php h_escape($db);?>"/>
  31. <input type="hidden" name="collection" value="<?php h_escape($collection);?>"/>
  32. <input type="hidden" name="action" value="<?php h_escape(x("action"));?>"/>
  33. <input type="hidden" name="format" value="<?php h_escape(x("format")); ?>"/>
  34. <table>
  35. <tr>
  36. <td valign="top">
  37. <textarea name="criteria" rows="5" cols="70" style="height:100px"><?php h(x("criteria"));?></textarea><br/>
  38. <div id="newobjInput" <?php if (x("command") !="modify"):?>style="display:none"<?php endif;?>>
  39. New Object(see <a href="http://www.mongodb.org/display/DOCS/Updating" target="_blank">Updating</a> operators):<br/>
  40. <textarea name="newobj" rows="5" cols="70"><?php h(x("newobj"));?></textarea>
  41. </div>
  42. </td>
  43. <td valign="top" class="field_orders">
  44. <!-- fields will be used in sorting -->
  45. <p><input type="text" name="field[]" value="<?php h_escape(rock_array_get(x("field"),0));?>" /> <select name="order[]"><option value="asc" <?php if (rock_array_get(x("order"),0)=="asc"):?>selected="selected"<?php endif;?>>ASC</option><option value="desc" <?php if (rock_array_get(x("order"),0)=="desc"):?>selected="selected"<?php endif;?>>DESC</option></select></p>
  46. <p><input type="text" name="field[]" value="<?php h_escape(rock_array_get(x("field"),1));?>" /> <select name="order[]"><option value="asc" <?php if (rock_array_get(x("order"),1)=="asc"):?>selected="selected"<?php endif;?>>ASC</option><option value="desc" <?php if (rock_array_get(x("order"),1)=="desc"):?>selected="selected"<?php endif;?>>DESC</option></select></p>
  47. <p><input type="text" name="field[]" value="<?php h_escape(rock_array_get(x("field"),2));?>" /> <select name="order[]"><option value="asc" <?php if (rock_array_get(x("order"),2)=="asc"):?>selected="selected"<?php endif;?>>ASC</option><option value="desc" <?php if (rock_array_get(x("order"),2)=="desc"):?>selected="selected"<?php endif;?>>DESC</option></select></p>
  48. <p><input type="text" name="field[]" value="<?php h_escape(rock_array_get(x("field"),3));?>" /> <select name="order[]"><option value="asc" <?php if (rock_array_get(x("order"),3)=="asc"):?>selected="selected"<?php endif;?>>ASC</option><option value="desc" <?php if (rock_array_get(x("order"),3)=="desc"):?>selected="selected"<?php endif;?>>DESC</option></select> </p>
  49. </td>
  50. </tr>
  51. <tr>
  52. <td colspan="2">
  53. <!-- query fields and hints -->
  54. <span id="fieldsAndHints" <?php if (x("command") !="findAll"):?>style="display:none"<?php endif;?>>
  55. <?php if(!empty($nativeFields)):?>
  56. <a href="#" onclick="showQueryFields(this);return false;" title="Choose fields to display">Fields(<span id="query_fields_count"><?php h(count($queryFields));?></span>) <span style="font-size:11px">▼</span></a> |
  57. <a href="#" onclick="showQueryHints(this);return false;" title="Choose indexes will be used in query">Hints(<span id="query_hints_count"><?php h(count($queryHints));?></span>) <span style="font-size:11px">▼</span></a> |
  58. <?php endif; ?>
  59. </span>
  60. <!-- end query fields and hints -->
  61. <label id="limitLabel" <?php if (x("command") !="findAll"):?>style="display:none"<?php endif;?>><?php hm("limit"); ?>:<input type="text" name="limit" size="5" value="<?php h(xi("limit"));?>"/> |</label>
  62. <span id="pageSetLabel" <?php if (x("command") !="findAll"):?>style="display:none"<?php endif;?>>
  63. <select name="pagesize" title="<?php hm("rows_per_page"); ?>">
  64. <?php foreach (array(10, 15, 20, 30, 50, 100, 200) as $pagesize):?>
  65. <option value="<?php h($pagesize);?>" <?php if(x("pagesize")==$pagesize):?>selected="selected"<?php endif;?>>Rows:<?php h($pagesize);?></option>
  66. <?php endforeach;?>
  67. </select> |</span>
  68. <?php hm("action"); ?>:
  69. <select name="command" onchange="changeCommand(this)">
  70. <option value="findAll" <?php if(x("command")=="findAll"):?>selected="selected"<?php endif;?>>findAll</option>
  71. <option value="remove" <?php if(x("command")=="remove"):?>selected="selected"<?php endif;?>>remove</option>
  72. <option value="modify" <?php if(x("command")=="modify"):?>selected="selected"<?php endif;?>>modify</option>
  73. </select>
  74. </td>
  75. </tr>
  76. <tr>
  77. <td colspan="2">
  78. <input type="submit" value="<?php hm("submit_query"); ?>"/>
  79. <input type="button" value="<?php hm("explain"); ?>" onclick="explainQuery(this.form)" />
  80. <input type="button" value="<?php hm("clear_conditions"); ?>" onclick="window.location='<?php h(url("collection.index", array( "db"=>$db, "collection" => $collection, "format" => xn("format") ))); ?>'"/>
  81. [<a href="http://rockmongo.com/wiki/queryExamples?lang=en_us" target="_blank">Query Examples</a>]
  82. <?php if(isset($cost)):?>Cost <?php h(round($cost, 6));?>s<?php endif;?>
  83. <?php if(isset($message)):?><p class="error"><?php h($message);?></p><?php endif;?></td>
  84. </tr>
  85. </table>
  86. <!-- float divs (for fields and hints) -->
  87. <div id="query_fields_list" class="fieldsmenu">
  88. <div align="right" style="padding-right:10px;background:#999"><a href="#" onclick="closeQueryFields();return false;" title="Click to close"><img src="<?php render_theme_path() ?>/images/accept.png" width="14"/></a></div>
  89. <ul>
  90. <?php foreach ($nativeFields as $field): if($field == "_id") {continue;} ?>
  91. <li><label>
  92. <input type="checkbox" name="query_fields[]" value="<?php h($field); ?>"
  93. <?php if(in_array($field,$queryFields)||$field=="_id"): ?>checked="checked"<?php endif;?>
  94. <?php if($field=="_id"): ?>disabled="disabled"<?php endif?>
  95. /> <?php h($field); ?></label></li>
  96. <?php endforeach; ?>
  97. </ul>
  98. </div>
  99. <div id="query_hints_list" class="fieldsmenu">
  100. <div align="right" style="padding-right:10px;background:#999"><a href="#" onclick="closeQueryHints();return false;" title="Click to close"><img src="<?php render_theme_path() ?>/images/accept.png" width="14"/></a></div>
  101. <ul>
  102. <?php foreach ($indexFields as $index => $field):?>
  103. <li title="<?php h(htmlspecialchars($field["keystring"])); ?>"><label><input type="checkbox" name="query_hints[<?php h($index); ?>]" value="<?php h($field["name"]); ?>" <?php if(in_array($field["name"],$queryHints)): ?>checked="checked"<?php endif;?> class="query_hints" /> <?php h($field["name"]); ?></label></li>
  104. <?php endforeach; ?>
  105. </ul>
  106. </div>
  107. <!-- end float divs -->
  108. </form>
  109. </div>
  110. <!-- Records in collection -->
  111. <div id="records">
  112. <?php if(!isset($page) || $page->total() == 0):?>
  113. <?php if (x("command") != "findAll"):?>
  114. <p><?php if (isset($count)): h($count);?> rows may be affected.<?php endif;?></p>
  115. <?php else:?>
  116. <p>No records is found.</p>
  117. <?php endif;?>
  118. <?php else: ?>
  119. <p class="page"><?php h($page); ?> (<?php h(min($page->total(), $page->offset()+$page->size()));?>/<?php h($page->total());?>)</p>
  120. <!-- list all records -->
  121. <?php foreach ($rows as $index => $row):?>
  122. <div style="border:2px #ccc solid;margin-bottom:5px;" onmouseover="showOperationButtons('<?php h($index);?>')" onmouseout="hideOperationButtons('<?php h($index);?>')" class="record" <?php if(MCollection::isFile($row)): ?>r-is-file="yes" r-file-name="<?php h($row["filename"]) ?>"<?php endif; ?>>
  123. <table width="100%" border="0" id="object_<?php h($index);?>">
  124. <tr>
  125. <td valign="top" width="50">#<?php echo $page->total() - $page->offset() - $index; ?></td>
  126. <td valign="top">
  127. <!-- operations on record -->
  128. <div class="operation" id="operate_<?php h($index);?>">
  129. <!-- you can modify row only when _id is not empty -->
  130. <?php if($row["can_modify"]):?>
  131. <a href="<?php echo url("collection.modifyRow", array(
  132. "db" => $db,
  133. "collection" => $collection,
  134. "id" => rock_id_string($row["_id"]),
  135. "uri" => $_SERVER["REQUEST_URI"]
  136. )); ?>"><?php hm("update"); ?></a> |
  137. <?php endif; ?>
  138. <?php if($row["can_delete"]): ?>
  139. <a href="<?php echo url("collection.deleteRow", array(
  140. "db" => $db,
  141. "collection" => $collection,
  142. "id" => rock_id_string($row["_id"]),
  143. "uri" => $_SERVER["REQUEST_URI"]
  144. ));
  145. ?>" onclick="return window.confirm('Are you sure to delete the row #<?php echo $page->total() - $page->offset() - $index; ?>?');"><?php hm("delete"); ?></a> |
  146. <?php else: ?>
  147. <a href="#" class="disabled" onclick="return false;"><?php echo hm("delete"); ?></a> |
  148. <?php endif; ?>
  149. <?php if ($row["can_add_field"]): ?>
  150. <a href="#" onclick="fieldOpNew(null,'<?php h(rock_id_string($row["_id"])); ?>','',<?php h($index); ?>);return false;"><?php echo hm("new_field"); ?></a> |
  151. <?php else: ?>
  152. <a href="#" class="disabled" onclick="return false;"><?php echo hm("new_field"); ?></a> |
  153. <?php endif; ?>
  154. <?php if ($row["can_duplicate"]): ?>
  155. <a href="<?php h(url("collection.createRow", array(
  156. "db" => $db,
  157. "collection" => $collection,
  158. "id" => rock_id_string($row["_id"]),
  159. "uri" => $_SERVER["REQUEST_URI"]
  160. ))); ?>"><?php hm("duplicate"); ?></a> |
  161. <?php endif; ?>
  162. <?php if ($row["can_refresh"]): ?>
  163. <a href="#" onclick="refreshRecord('<?php h(rock_id_string($row["_id"])) ?>',<?php h($index); ?>);return false;"><?php hm("refresh"); ?></a> |
  164. <?php endif; ?>
  165. <!-- render operation menu -->
  166. <?php render_doc_menu($db, $collection, isset($row["_id"]) ? rock_id_string($row["_id"]) : 0, $index) ?>
  167. <!-- for gridfs -->
  168. <?php if(MCollection::isFile($row)):?>
  169. | GridFS: <a href="<?php
  170. h(url("collection.downloadFile", array(
  171. "db" => $db,
  172. "collection" => $collection,
  173. "id" => rock_id_string($row["_id"]),
  174. )));
  175. ?>">Download</a> <a href="<?php
  176. $criteria = null;
  177. if ($this->last_format == "json") {
  178. $criteria = '{
  179. "files_id": ' . (($row["_id"] instanceof MongoId) ? "ObjectId(\"" . addslashes($row["_id"]->__toString()) . "\")" : "\"" . addslashes($row["_id"]) . "\"") . '
  180. }';
  181. }
  182. else {
  183. $criteria = 'array(
  184. "files_id" => ' . (($row["_id"] instanceof MongoId) ? "new MongoId(\"" . addslashes($row["_id"]->__toString()) . "\")" : "\"" . addslashes($row["_id"]) . "\"") . '
  185. )';
  186. }
  187. h(url("collection.index", array(
  188. "db" => $db,
  189. "collection" => MCollection::chunksCollection($collection),
  190. "criteria" => $criteria)));
  191. ?>">Chunks</a>
  192. <?php endif;?>
  193. </div>
  194. <!-- display record -->
  195. <div id="text_<?php h($index);?>" style="max-height:150px;overflow-y:hidden;width:99%;" ondblclick="expandText('<?php h($index);?>');" class="record_row" record_id="<?php if(isset($row["_id"])){h(rock_id_string($row["_id"]));} ?>" record_index="<?php h($index); ?>">
  196. <?php h($row["data"]); ?>
  197. </div>
  198. <!-- switch to text so we can copy it easieer -->
  199. <div id="field_<?php h($index);?>" style="display:none;max-height:150px;overflow-y:auto"><textarea rows="7" cols="60" ondblclick="this.select()" title="Double click to select all"><?php h($row["text"]);?></textarea></div>
  200. <div align="right" style="margin-top:-14px"><a href="#page_top">TOP</a></div>
  201. </td>
  202. </tr>
  203. </table>
  204. </div>
  205. <?php endforeach; ?>
  206. <p class="page"><?php h($page); ?></p>
  207. <?php endif;?>
  208. </div>
  209. <!-- field menu -->
  210. <div id="field_menu">
  211. <a href="#" onclick="fieldOpUpdate(this);return false;" class="field_op_update">Update</a>
  212. <a href="#" onclick="fieldOpQuery(this);return false;" class="field_op_query">Query</a>
  213. <a href="#" onclick="fieldOpSort(this, 'asc');return false;" class="field_op_sort">SortASC</a>
  214. <a href="#" onclick="fieldOpSort(this, 'desc');return false;" class="field_op_sort">SortDESC</a>
  215. <span>------</span>
  216. <a href="#" onclick="fieldOpRename(this);return false;" class="field_op_rename">Rename</a>
  217. <a href="#" onclick="fieldOpRemove(this);return false;" class="field_op_remove">Remove</a>
  218. <a href="#" onclick="fieldOpClear(this);return false;" class="field_op_clear">Clear</a>
  219. <?php if($canAddField): ?>
  220. <span>------</span>
  221. <a href="#" onclick="fieldOpNew(this);return false;" class="field_op_new">New</a>
  222. <?php endif; ?>
  223. <span>------</span>
  224. <a href="#" onclick="fieldOpIndexes(this);return false;" class="field_op_indexes">Indexes</a>
  225. <span class="field_op_hide_show_seperator">------</span>
  226. <a href="#" onclick="fieldOpHide(this);return false;" class="field_op_hide">Hide</a>
  227. <a href="#" onclick="fieldOpShow(this);return false;" class="field_op_show">Show</a>
  228. </div>
  229. <!-- dialogs goes below -->
  230. <div id="field_dialog_remove" style="display:none">
  231. Are you sure to remove field "<span class="dialog_field"></span>"?
  232. </div>
  233. <div id="field_dialog_clear" style="display:none">
  234. Are you sure to set field "<span class="dialog_field"></span>" to NULL?
  235. </div>
  236. <div id="field_dialog_rename" style="display:none">
  237. <table>
  238. <tr>
  239. <td>New Name:</td>
  240. <td><input type="text" name="newname" value="" size="22"/></td>
  241. </tr>
  242. <tr>
  243. <td>Keep exists:</td>
  244. <td><label><input type="checkbox" name="keep" value="1" checked="checked"/></label></td>
  245. </tr>
  246. </table>
  247. </div>
  248. <!-- create new field -->
  249. <div id="field_dialog_new" style="display:none">
  250. <table>
  251. <tr>
  252. <td>Field name:</td>
  253. <td><input type="text" name="newname" size="22"/></td>
  254. </tr>
  255. <tr>
  256. <td nowrap>Keep exists:</td>
  257. <td><label><input type="checkbox" name="keep" value="1" checked="checked"/></label></td>
  258. </tr>
  259. <tr>
  260. <td>Data Type:</td>
  261. <td><?php render_select_data_types("data_type", "string"); ?> <select name="format" onchange="switchDataFormat('#field_dialog_new textarea[name=\'mixed_value\']',this)" style="display:none">
  262. <option value="array" <?php if($last_format=="array"): ?>selected="selected"<?php endif; ?>>Array</option>
  263. <option value="json" <?php if($last_format=="json"): ?>selected="selected"<?php endif; ?>>JSON</option>
  264. </select></td>
  265. </tr>
  266. <tr class="value">
  267. <td valign="top">Value:</td>
  268. <td><textarea name="value" rows="10" cols="50"></textarea></td>
  269. </tr>
  270. <tr class="bool_value">
  271. <td valign="top">Value:</td>
  272. <td><select name="bool_value"><option value="true">True</option><option value="false">False</option></select></td>
  273. </tr>
  274. <tr class="integer_value">
  275. <td valign="top">Value:</td>
  276. <td><input type="text" name="integer_value"/></td>
  277. </tr>
  278. <tr class="long_value">
  279. <td valign="top">Value:</td>
  280. <td><input type="text" name="long_value"/></td>
  281. </tr>
  282. <tr class="double_value">
  283. <td valign="top">Value:</td>
  284. <td><input type="text" name="double_value"/></td>
  285. </tr>
  286. <tr class="mixed_value">
  287. <td valign="top">Value:</td>
  288. <td><textarea name="mixed_value" rows="10" cols="50"><?php if($last_format=="array"): ?>array(
  289. )<?php else: ?>{
  290. }<?php endif; ?></textarea><br/> * An array or object</td>
  291. </tr>
  292. </table>
  293. </div>
  294. <!-- update field data -->
  295. <div id="field_dialog_update" style="display:none">
  296. <table>
  297. <tr>
  298. <td>Field name:</td>
  299. <td><input type="text" name="newname" size="22" disabled="disabled"/></td>
  300. </tr>
  301. <tr>
  302. <td>Data Type:</td>
  303. <td><?php render_select_data_types("data_type", "integer"); ?> <select name="format" onchange="switchDataFormat('#field_dialog_update textarea[name=\'mixed_value\']',this)" style="display:none">
  304. <option value="array" <?php if($last_format=="array"): ?>selected="selected"<?php endif; ?>>Array</option>
  305. <option value="json" <?php if($last_format=="json"): ?>selected="selected"<?php endif; ?>>JSON</option>
  306. </select></td>
  307. </tr>
  308. <tr class="value">
  309. <td valign="top">Value:</td>
  310. <td><textarea name="value" rows="10" cols="50"></textarea></td>
  311. </tr>
  312. <tr class="bool_value">
  313. <td valign="top">Value:</td>
  314. <td><select name="bool_value"><option value="true">True</option><option value="false">False</option></select></td>
  315. </tr>
  316. <tr class="integer_value">
  317. <td valign="top">Value:</td>
  318. <td><input type="text" name="integer_value"/></td>
  319. </tr>
  320. <tr class="long_value">
  321. <td valign="top">Value:</td>
  322. <td><input type="text" name="long_value"/></td>
  323. </tr>
  324. <tr class="double_value">
  325. <td valign="top">Value:</td>
  326. <td><input type="text" name="double_value"/></td>
  327. </tr>
  328. <tr class="mixed_value">
  329. <td valign="top">Value:</td>
  330. <td><textarea name="mixed_value" rows="10" cols="50"><?php if($last_format=="array"): ?>array(
  331. )<?php else: ?>{
  332. }<?php endif; ?></textarea><br/> * An array or object</td>
  333. </tr>
  334. </table>
  335. </div>
  336. <!-- Query field dialog -->
  337. <div id="field_dialog_query" style="display:none">
  338. <table>
  339. <tr>
  340. <td valign="top">Criteria <select name="format" onchange="switchDataFormat('#field_dialog_query textarea[name=\'field_criteria\']',this)">
  341. <option value="array" <?php if($last_format=="array"): ?>selected="selected"<?php endif; ?>>Array</option>
  342. <option value="json" <?php if($last_format=="json"): ?>selected="selected"<?php endif; ?>>JSON</option>
  343. </select></td>
  344. </tr>
  345. <tr>
  346. <td>
  347. <textarea name="field_criteria" rows="10" cols="50"></textarea>
  348. </td>
  349. </tr>
  350. </table>
  351. </div>
  352. <!-- Field related indexes dialog -->
  353. <div id="field_dialog_indexes" style="display:none">
  354. <table bgcolor="#cccccc" width="400" cellpadding="2" cellspacing="1" class="indexes_table">
  355. <tr>
  356. <td colspan="2">Indexes contains <span class="dialog_field"></span></td>
  357. </tr>
  358. <tbody class="indexes"></tbody>
  359. </table>
  360. <br/>
  361. <table bgcolor="#cccccc" width="400" cellpadding="2" cellspacing="1">
  362. <tr>
  363. <td colspan="2">Create new Index</td>
  364. </tr>
  365. <tr bgcolor="#ffffff">
  366. <td width="100">Name</td>
  367. <td><input type="text" name="name"/></td>
  368. </tr>
  369. <tr bgcolor="#ffffff">
  370. <td valign="top">Fields</td>
  371. <td><input type="text" name="field[]" class="first_field"/> <select name="order[]"><option value="asc">ASC</option><option value="desc">DESC</option></select> <input type="button" value="+" onclick="addNewField()"/><div id="fields"></div></td>
  372. </tr>
  373. <tr bgcolor="#ffffff">
  374. <td>Unique?</td>
  375. <td><input type="checkbox" name="is_unique" value="1" onclick="clickUniqueKey(this)"/></td>
  376. </tr>
  377. <tr id="duplicate_tr" style="display:none" bgcolor="#ffffff">
  378. <td>Remove duplicates?</td>
  379. <td><input type="checkbox" name="drop_duplicate" value="1"/></td>
  380. </tr>
  381. </table>
  382. </div>
  383. <!-- Show query history dialog -->
  384. <div id="field_dialog_history" style="display:none">
  385. </div>