/web/ca/library/list.php
PHP | 279 lines | 177 code | 85 blank | 17 comment | 7 complexity | 81e57636e6b74e4bfbad4f2377d97c6d MD5 | raw file
- <?php
-
- include 'gloo.inc';
- require_once ($_SERVER['GLOO_INC_DIR'].'class_loader.inc' );
- require_once ($_SERVER['GLOO_INC_DIR'].'session.inc' );
- require_once ($_SERVER['GLOO_INC_DIR'].'error.inc' );
-
- include($location->GLOO_PAGE_HEADER);
- //security check
- if(!$context->isAdminGUI()) {
- header('location: '.url::base().'/ca/login.php');
- exit ;
- }
-
-
- $context->addCACrumb();
- $context->addCrumb('Media Library', $_SERVER['REQUEST_URI']);
- //search token
- $token = NULL ;
- if(!empty($_GET['token'])) {
- //search token
- $token = $_GET['token'];
- $token = Gloo_Form_Handler::getSecureHtml($token);
- }
-
- $orgId = $context->getOrgId();
- $documentDao = new Gloo_Dao_Document();
-
-
- $pageNo = 1 ;
- if(array_key_exists('page',$_GET)) {
- $pageNo = $_GET['page'];
- }
-
- //start: pagination stuff
- $allRecordsCount = $documentDao->getRecordsCount($orgId,$token);
- $paginator = new Gloo_UI_Paginator($pageNo,$allRecordsCount,12);
- $docs = $documentDao->getRecords($orgId,$paginator,$token);
- //end: pagination stuff
-
- //ca/library/list.php
- $glooBackURI = $context->getReturnPageURI();
-
-
- ?>
-
-
-
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html><head><title> <?php echo url::organizationName() ; ?> </title>
-
- <?php
- include($location->GLOO_META_TAGS);
- echo $glooWeb->loadCss(url::YUI_GRID_CSS) ;
- echo $glooWeb->loadCss(url::css('main.css'));
-
- ?>
-
-
-
- </head>
- <body>
- <?php include($location->GLOO_TOP_BAR) ?>
-
- <div id="custom-doc" class="yui-t2">
- <div class="content_top_bg">
- <div>
- <div></div>
- </div>
-
- </div>
- <div class="content_left_border">
- <div id="hd" role="banner">
- <div id="header">
- <?php include($location->CA_HEADER_FILE) ?>
- </div> <!-- header -->
- </div>
- <div id="bd" role="main">
- <div id="yui-main">
- <div class="yui-b">
- <div class="yui-g">
-
- <div id="content">
-
- <br>
-
-
- <p class="help-text">
- You can upload documents, spreadhseets, shockwave, zip files etc.
- inside the library. After uploading the documents you can
- get links and embed code to use them in your other posts.
-
-
- </p>
-
- <div class="button_marg">
- <a href="/ca/library/add.php"><img src="/art/minimal/images/add-library.png" alt="library add image" title="Add to library"/></a>
-
- </div>
-
- <div class="box_top_bg">
- <div> <div> </div> </div>
- </div>
-
- <div class="type1-container">
-
- <form name="page_search_form" action="<?php echo url::base() ?>/ca/library/frm/search.php" method="POST">
-
- <input name="token" class="input_bg" value="<?php echo $token ;?>" size="40"/>
-
- <div class="button">
- <div>
- <input type="submit" name="search" value="Search" />
- </div>
- </div>
-
-
- <a href="/ca/library/list.php">show all?</a>
-
- <div style="clear:both;"></div>
-
- </form>
- </div> <!-- search form -->
-
- <div class="box_bottom_bg">
- <div> <div> </div> </div>
- </div>
- <br>
-
- <?php
- $count = 0 ;
- foreach($docs as $doc) {
- $count++;
- $class = "row1" ;
- if($count %2 == 0) {
- $class = "row2" ;
- }
- $docURI = url::amazonS3URI($doc['s3_bucket'], $doc['s3_key']);
- //docId+ mime + s3_bucket + s3_key + title
- $result = Gloo_Document_Mime::query($doc['mime']);
- $docIconURI = $result['iconURI'];
-
-
- $srcImageIcon = '<img src="'.$docIconURI.'" alt="icon" align="left" />' ;
- if($result['type'] == Gloo_Document_Mime::IMAGE) {
- $srcImageIcon = '<img src="'.$docURI.'" alt="image" width="140" />' ;
- }
-
- $linkURI = '<img src="/art/minimal/images/link.gif" alt="link" /> <a href="" class="open-link" id="'.$doc['id'].'">Link</a>';
- $deleteURI = url::link('/ca/library/delete.php', array('doc_id' => $doc['id'], 'page' => $pageNo));
- $deleteURI = '<a href="'.$deleteURI.'">Delete</a>';
-
- ?>
-
- <div>
-
- <div class="dashed-bottom-container">
- <strong> <label><?php echo $doc['title'] ; ?> </label> </strong>
- <br> <br>
-
- <?php echo $srcImageIcon ; ?> <br>
-
- <a href="<?php echo $docURI; ?>" >Download</a>
- (~<?php echo Gloo_Util::convertBytesIntoKB($doc['size']); ?>KB)
- <?php echo $linkURI; ?>
- <?php echo $deleteURI; ?>
- </div>
-
-
- </div>
-
- <?php
-
- } //:docs loop
- //paginate using $_GET and no SEO URI
- $ignore= array('page');
- echo $paginator->render($_GET,$ignore);
-
- ?>
-
-
- </div> <!-- content -->
-
- <script type="text/javascript">
-
-
- var libCopyPaste = {
- init: function() {
-
- $("a.open-link").click(function(event){
- event.preventDefault();
- var docId = $(this).attr("id");
- libCopyPaste.link(docId);
- });
-
- },
-
- link: function(docId) {
- //update dialog box with a spinner image html
- //change width etc. ca-dialog is part of admin toolbar
- $("#ca-dialog").html('<img src="/art/common/images/ajax_loader.gif" alt="spinner" />');
- $('#ca-dialog').dialog('option', 'title', 'Document Link');
- $('#ca-dialog').dialog('option', 'width', 510);
- $('#ca-dialog').dialog('option', 'position', '[350,100]');
- $('#ca-dialog').dialog('option', 'modal', false);
- $('#ca-dialog').dialog('option', 'buttons', { "Close": function() { $(this).dialog("close"); } });
-
- $("#ca-dialog").dialog("open");
-
- var dataObj = new Object();
- dataObj.doc_id = docId;
-
- //alert(docId);
- //ajax call start
- $.ajax({
- url: '<?php echo url::base() ;?>' + '/data/library/link.php',
- type: 'POST',
- dataType: 'html',
- data : dataObj,
- timeout: 9000,
-
- error: function(XMLHttpRequest, textStatus){
- // The script /data/library/link.php returns embed code
- // for a document id. This embed code is textStatus, we want
- // to update ca dialog box with this embed code. The embed code
- //template is /templates/document/link.tmpl
- $("#ca-dialog").html(textStatus);
-
- },
- success: function(html){
- $("#ca-dialog").html(html);
-
- }
- });
- //ajax call end
- }
-
- }
-
-
- $(document).ready(function(){
- libCopyPaste.init();
-
- });
-
-
-
- </script>
-
-
- </div>
- </div> <!-- block1 -->
- </div> <!-- yui-main -->
-
- <div class="yui-b">
-
- </div> <!-- block2 -->
-
- </div> <!-- bd -->
- </div> <!-- content-left-border -->
-
- <div class="content_bottom_bg">
- <div>
- <div> </div>
- </div>
-
- </div>
-
-
- </div> <!-- custom-doc -->
-
- <div id="ft" role="contentinfo">
- <?php include($location->GLOO_PAGE_FOOTER); ?>
- </div>
- </body>
- </html>
-
-
-