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

/web/ca/library/list.php

http://webgloo.googlecode.com/
PHP | 279 lines | 177 code | 85 blank | 17 comment | 7 complexity | 81e57636e6b74e4bfbad4f2377d97c6d MD5 | raw file
  1. <?php
  2. include 'gloo.inc';
  3. require_once ($_SERVER['GLOO_INC_DIR'].'class_loader.inc' );
  4. require_once ($_SERVER['GLOO_INC_DIR'].'session.inc' );
  5. require_once ($_SERVER['GLOO_INC_DIR'].'error.inc' );
  6. include($location->GLOO_PAGE_HEADER);
  7. //security check
  8. if(!$context->isAdminGUI()) {
  9. header('location: '.url::base().'/ca/login.php');
  10. exit ;
  11. }
  12. $context->addCACrumb();
  13. $context->addCrumb('Media Library', $_SERVER['REQUEST_URI']);
  14. //search token
  15. $token = NULL ;
  16. if(!empty($_GET['token'])) {
  17. //search token
  18. $token = $_GET['token'];
  19. $token = Gloo_Form_Handler::getSecureHtml($token);
  20. }
  21. $orgId = $context->getOrgId();
  22. $documentDao = new Gloo_Dao_Document();
  23. $pageNo = 1 ;
  24. if(array_key_exists('page',$_GET)) {
  25. $pageNo = $_GET['page'];
  26. }
  27. //start: pagination stuff
  28. $allRecordsCount = $documentDao->getRecordsCount($orgId,$token);
  29. $paginator = new Gloo_UI_Paginator($pageNo,$allRecordsCount,12);
  30. $docs = $documentDao->getRecords($orgId,$paginator,$token);
  31. //end: pagination stuff
  32. //ca/library/list.php
  33. $glooBackURI = $context->getReturnPageURI();
  34. ?>
  35. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  36. <html><head><title> <?php echo url::organizationName() ; ?> </title>
  37. <?php
  38. include($location->GLOO_META_TAGS);
  39. echo $glooWeb->loadCss(url::YUI_GRID_CSS) ;
  40. echo $glooWeb->loadCss(url::css('main.css'));
  41. ?>
  42. </head>
  43. <body>
  44. <?php include($location->GLOO_TOP_BAR) ?>
  45. <div id="custom-doc" class="yui-t2">
  46. <div class="content_top_bg">
  47. <div>
  48. <div></div>
  49. </div>
  50. </div>
  51. <div class="content_left_border">
  52. <div id="hd" role="banner">
  53. <div id="header">
  54. <?php include($location->CA_HEADER_FILE) ?>
  55. </div> <!-- header -->
  56. </div>
  57. <div id="bd" role="main">
  58. <div id="yui-main">
  59. <div class="yui-b">
  60. <div class="yui-g">
  61. <div id="content">
  62. <br>
  63. <p class="help-text">
  64. You can upload documents, spreadhseets, shockwave, zip files etc.
  65. inside the library. After uploading the documents you can
  66. get links and embed code to use them in your other posts.
  67. </p>
  68. <div class="button_marg">
  69. <a href="/ca/library/add.php"><img src="/art/minimal/images/add-library.png" alt="library add image" title="Add to library"/></a>
  70. </div>
  71. <div class="box_top_bg">
  72. <div> <div> </div> </div>
  73. </div>
  74. <div class="type1-container">
  75. <form name="page_search_form" action="<?php echo url::base() ?>/ca/library/frm/search.php" method="POST">
  76. &nbsp;
  77. <input name="token" class="input_bg" value="<?php echo $token ;?>" size="40"/>
  78. <div class="button">
  79. <div>
  80. <input type="submit" name="search" value="Search" />
  81. </div>
  82. </div>
  83. &nbsp;
  84. <a href="/ca/library/list.php">show all?</a>
  85. <div style="clear:both;"></div>
  86. </form>
  87. </div> <!-- search form -->
  88. <div class="box_bottom_bg">
  89. <div> <div> </div> </div>
  90. </div>
  91. <br>
  92. <?php
  93. $count = 0 ;
  94. foreach($docs as $doc) {
  95. $count++;
  96. $class = "row1" ;
  97. if($count %2 == 0) {
  98. $class = "row2" ;
  99. }
  100. $docURI = url::amazonS3URI($doc['s3_bucket'], $doc['s3_key']);
  101. //docId+ mime + s3_bucket + s3_key + title
  102. $result = Gloo_Document_Mime::query($doc['mime']);
  103. $docIconURI = $result['iconURI'];
  104. $srcImageIcon = '<img src="'.$docIconURI.'" alt="icon" align="left" />' ;
  105. if($result['type'] == Gloo_Document_Mime::IMAGE) {
  106. $srcImageIcon = '<img src="'.$docURI.'" alt="image" width="140" />' ;
  107. }
  108. $linkURI = '<img src="/art/minimal/images/link.gif" alt="link" />&nbsp;<a href="" class="open-link" id="'.$doc['id'].'">Link</a>';
  109. $deleteURI = url::link('/ca/library/delete.php', array('doc_id' => $doc['id'], 'page' => $pageNo));
  110. $deleteURI = '<a href="'.$deleteURI.'">Delete</a>';
  111. ?>
  112. <div>
  113. <div class="dashed-bottom-container">
  114. <strong> <label><?php echo $doc['title'] ; ?> </label> </strong>
  115. <br> <br>
  116. <?php echo $srcImageIcon ; ?> <br>
  117. <a href="<?php echo $docURI; ?>" >Download</a> &nbsp;
  118. (~<?php echo Gloo_Util::convertBytesIntoKB($doc['size']); ?>KB)&nbsp;
  119. <?php echo $linkURI; ?> &nbsp;
  120. <?php echo $deleteURI; ?> &nbsp;
  121. </div>
  122. </div>
  123. <?php
  124. } //:docs loop
  125. //paginate using $_GET and no SEO URI
  126. $ignore= array('page');
  127. echo $paginator->render($_GET,$ignore);
  128. ?>
  129. </div> <!-- content -->
  130. <script type="text/javascript">
  131. var libCopyPaste = {
  132. init: function() {
  133. $("a.open-link").click(function(event){
  134. event.preventDefault();
  135. var docId = $(this).attr("id");
  136. libCopyPaste.link(docId);
  137. });
  138. },
  139. link: function(docId) {
  140. //update dialog box with a spinner image html
  141. //change width etc. ca-dialog is part of admin toolbar
  142. $("#ca-dialog").html('<img src="/art/common/images/ajax_loader.gif" alt="spinner" />');
  143. $('#ca-dialog').dialog('option', 'title', 'Document Link');
  144. $('#ca-dialog').dialog('option', 'width', 510);
  145. $('#ca-dialog').dialog('option', 'position', '[350,100]');
  146. $('#ca-dialog').dialog('option', 'modal', false);
  147. $('#ca-dialog').dialog('option', 'buttons', { "Close": function() { $(this).dialog("close"); } });
  148. $("#ca-dialog").dialog("open");
  149. var dataObj = new Object();
  150. dataObj.doc_id = docId;
  151. //alert(docId);
  152. //ajax call start
  153. $.ajax({
  154. url: '<?php echo url::base() ;?>' + '/data/library/link.php',
  155. type: 'POST',
  156. dataType: 'html',
  157. data : dataObj,
  158. timeout: 9000,
  159. error: function(XMLHttpRequest, textStatus){
  160. // The script /data/library/link.php returns embed code
  161. // for a document id. This embed code is textStatus, we want
  162. // to update ca dialog box with this embed code. The embed code
  163. //template is /templates/document/link.tmpl
  164. $("#ca-dialog").html(textStatus);
  165. },
  166. success: function(html){
  167. $("#ca-dialog").html(html);
  168. }
  169. });
  170. //ajax call end
  171. }
  172. }
  173. $(document).ready(function(){
  174. libCopyPaste.init();
  175. });
  176. </script>
  177. </div>
  178. </div> <!-- block1 -->
  179. </div> <!-- yui-main -->
  180. <div class="yui-b">
  181. </div> <!-- block2 -->
  182. </div> <!-- bd -->
  183. </div> <!-- content-left-border -->
  184. <div class="content_bottom_bg">
  185. <div>
  186. <div> </div>
  187. </div>
  188. </div>
  189. </div> <!-- custom-doc -->
  190. <div id="ft" role="contentinfo">
  191. <?php include($location->GLOO_PAGE_FOOTER); ?>
  192. </div>
  193. </body>
  194. </html>