/**
  * Enter description here...
  *
  * @param string $path Path to the Zip File
  * @return string Preview of the Zip File
  */
 public function previewZip($path)
 {
     $files = $this->objZip->listArchiveFiles($path);
     if ($files == FALSE) {
         return 'Error: Could not process file';
     } else {
         // echo '<pre>';
         // print_r($files);
         // echo '</pre>';
         $path_parts = pathinfo($path);
         $table = $this->newObject('htmltable', 'htmlelements');
         $table->startHeaderRow();
         $table->addHeaderCell('&nbsp;');
         $table->addHeaderCell('Name of File');
         $table->addHeaderCell('File Size');
         $table->addHeaderCell('Status');
         $table->endHeaderRow();
         $filecount = 0;
         $foldercount = 0;
         $objFileSize = new formatfilesize();
         foreach ($files as $file) {
             if ($file['folder']) {
                 continue;
             }
             $table->startRow();
             $table->addCell('&nbsp;');
             $table->addCell($this->objFileIcons->getFileIcon($file['filename']) . ' ' . $file['filename']);
             $table->addCell($objFileSize->formatsize($file['size']));
             $table->addCell($file['status']);
             $table->endRow();
         }
         return $table->show();
     }
 }
Пример #2
0
 /**
  * Method to get a graph of file usage for a given path
  * @param string $path Path to get the graph for
  * @param boolean $includeFreeSpace Include a summary of space left
  * @return string
  */
 public function getQuotaGraph($path, $includeFreeSpace = TRUE)
 {
     $quota = $this->getQuota($path);
     if ($quota['quotausage'] > $quota['quota']) {
         $freeSpace = 0;
     } else {
         $freeSpace = $quota['quota'] - $quota['quotausage'];
     }
     if ($includeFreeSpace) {
         $objFileSize = new formatfilesize();
         $freeSpaceStr = $this->objLanguage->languageText('mod_filemanager_freespace', 'filemanager', 'Free Space') . ': ' . $objFileSize->formatsize($freeSpace);
     } else {
         $freeSpaceStr = '';
     }
     return $this->generateQuotaGraph($quota['quota'], $quota['quotausage']) . $freeSpaceStr;
 }
    /**
     * Short description for function
     *
     * Long description (if any) ...
     *
     * @param  array  $subFolders Parameter description (if any) ...
     * @param  array  $files      Parameter description (if any) ...
     * @return object Return description (if any) ...
     * @access public
     */
    function previewLongView($subFolders, $files, $symlinks, $restriction, $mode, $name, $forceRestriction = FALSE)
    {
        $objTable = $this->newObject('htmltable', 'htmlelements');
        $objFilePreview = $this->getObject('filepreview');
        $objFileSize = new formatfilesize();
        $objThumbnail = $this->getObject('thumbnails', 'filemanager');
        if ($this->viewType == strtolower('thumbnails')) {
            $objTable->cssId = $this->objLanguage->languageText('mod_filemanager_filemanagertableclass', 'filemanager', 'filemanagerTable');
            $this->objFileIcons->size = 'large';
        }
        $objIcon = $this->newObject('geticon', 'htmlelements');
        if ($this->editPermission) {
            if ($this->viewType != strtolower('thumbnails')) {
                $objTable->startHeaderRow();
                $objTable->addHeaderCell('&nbsp;', '20');
            }
        }
        if ($this->viewType != strtolower('thumbnails')) {
            $objTable->addHeaderCell('&nbsp;', '20');
            $objTable->addHeaderCell($this->objLanguage->languageText('word_name', 'system', 'Name'));
            $objTable->addHeaderCell($this->objLanguage->languageText('word_size', 'system', 'Size'), 60);
            $objTable->addHeaderCell('&nbsp;', '30');
        }
        // Set Restriction as empty if it is none
        if (count($restriction) == 1 && $restriction[0] == '') {
            $restriction = array();
        }
        $objTable->endHeaderRow();
        $hidden = 0;
        if (count($subFolders) == 0 && count($files) == 0 && count($symlinks) == 0) {
            $objTable->startRow();
            $objTable->addCell('<em>' . $this->objLanguage->languageText('mod_filemanager_nofilesorfolders', 'filemanager', 'No files or folders found') . '</em>', NULL, NULL, NULL, 'noRecordsMessage', 'colspan="5"');
            $objTable->endRow();
        } else {
            if (count($subFolders) > 0) {
                $folderIcon = $this->objFileIcons->getExtensionIcon('folder');
                foreach ($subFolders as $folder) {
                    $this->domDoc = new DOMDocument('utf-8');
                    $domElements['viewDiv'] = $this->domDoc->createElement('div');
                    $domElements['viewDiv']->setAttribute('class', 'fm_thumbnails');
                    $domElements['folderLink'] = $this->domDoc->createElement('a');
                    //The DOM icon folder
                    $domElements['folderIcon'] = $this->domDoc->createElement('img');
                    $domElements['folderIcon']->setAttribute('src', $this->objFileIcons->getIconSrc('folder'));
                    $domElements['folderIcon']->setAttribute('class', 'iconThumbnail');
                    $domElements['folderLink']->setAttribute('title', $this->objLanguage->languageText('mod_filemanager_clicktoopen', 'filemanager'));
                    $domElements['folderLink']->setAttribute('href', str_replace('amp;', '', $this->uri(array('action' => 'viewfolder', 'folder' => $folder['id'], 'view' => $this->viewType), $this->targetModule)));
                    $objTable->startRow();
                    if ($this->editPermission) {
                        $checkbox = new checkbox('files[]');
                        $checkbox->value = 'folder__' . $folder['id'];
                        $checkbox->cssId = htmlentities('input_files_' . basename($folder['folderpath']));
                        //The DOM folder checkbox
                        $domElements['folderCheckbox'] = $this->domDoc->createElement('input');
                        $domElements['folderCheckbox']->setAttribute('type', 'checkbox');
                        $domElements['folderCheckbox']->setAttribute('name', 'files[]');
                        $domElements['folderCheckbox']->setAttribute('id', htmlentities('input_files_' . basename($folder['folderpath'])));
                        $domElements['folderCheckbox']->setAttribute('value', 'folder__' . $folder['id']);
                        $domElements['folderCheckbox']->setAttribute('class', 'transparentbgnb');
                        //Delete confirm object
                        $delConfirm = $this->getObject('confirm', 'utilities');
                        //Setting the confirmation message
                        $delConfirm->setConfirm(NULL, str_replace('amp;', '', $this->uri(array('action' => 'deletefolder', 'id' => $folder['id'], 'module' => $this->targetModule))), $this->objLanguage->languageText('mod_filemanager_areyousuredeletefiles', 'filemanager'), NULL);
                        //The DOM delete link
                        $domElements['deleteconfirm'] = $this->domDoc->createElement('a');
                        $domElements['deleteconfirm']->appendChild($this->domDoc->createTextNode($this->objLanguage->languageText('word_delete', 'system')));
                        $domElements['deleteconfirm']->setAttribute('class', $this->objLanguage->languageText('mod_filemanager_buttonlinkclass', 'filemanager'));
                        $domElements['deleteconfirm']->setAttribute('href', $delConfirm->href);
                        $domElements['viewDiv']->appendChild($domElements['folderCheckbox']);
                        $domElements['viewDiv']->appendChild($domElements['deleteconfirm']);
                        $domElements['viewDiv']->appendChild($this->domDoc->createElement('br'));
                        if ($this->viewType != strtolower('thumbnails')) {
                            $objTable->addCell($checkbox->show());
                        }
                    }
                    //The value to appear when the mouse is over the link
                    $domElements['folderParagraph'] = $this->domDoc->createElement('p');
                    $domElements['folderParagraph']->setAttribute('class', 'folderdetails');
                    $domElements['folderParagraph']->appendChild($this->domDoc->createTextNode($this->objLanguage->languageText("phrase_foldername", "system") . ": " . substr(basename($folder['folderpath']), 0, 12)));
                    $domElements['folderParagraph']->appendChild($this->domDoc->createElement('br'));
                    $domElements['folderParagraph']->appendChild($this->domDoc->createTextNode($this->objLanguage->languageText("word_files", "system") . ": " . count($this->objFiles->getFolderFiles($folder['folderpath']))));
                    $domElements['folderParagraph']->appendChild($this->domDoc->createElement('br'));
                    $domElements['folderParagraph']->appendChild($this->domDoc->createTextNode($this->objLanguage->languageText("word_folders", "system") . ": " . count($this->objFolder->getSubFolders($folder['id']))));
                    //creating space between the link at the top and the string below
                    $domElements['viewDiv']->appendChild($this->domDoc->createElement('p'));
                    $domElements['folderLink']->appendChild($domElements['folderIcon']);
                    $domElements['folderLink']->appendChild($domElements['folderParagraph']);
                    $domElements['viewDiv']->appendChild($this->domDoc->createElement('br'));
                    $domElements['viewDiv']->appendChild($domElements['folderLink']);
                    if ($this->viewType != strtolower('thumbnails')) {
                        $objTable->addCell($folderIcon);
                    }
                    $folderLink = new link($this->uri(array('action' => 'viewfolder', 'folder' => $folder['id'], 'view' => $this->viewType), $this->targetModule));
                    $extTitle = '';
                    $accessVal = null;
                    if (key_exists("access", $folder)) {
                        $accessVal = $folder['access'];
                    }
                    if ($accessVal == 'private_all') {
                        $objIcon->setIcon('info');
                        $extTitle = $objIcon->show();
                        $domElements['folderParagraph']->appendChild($this->domDoc->createElement('br'));
                        $domElements['folderParagraph']->appendChild($this->domDoc->createTextNode($this->objLanguage->languageText('word_access', 'system') . ': '));
                        $domElements['folderParagraph']->appendChild($this->domDoc->createTextNode($folder['access']));
                    }
                    //TODO: make this a reusable function
                    //variables to store informatin partaining folder contants
                    $nmbrOfFiles = count($this->objFiles->getFolderFiles($folder['folderpath']));
                    $nmbrOfFolders = count($this->objFolder->getSubFolders($folder['id']));
                    //Assign the value to be displayed on the link's title depending on it's contents
                    if ($nmbrOfFiles == 0 && $nmbrOfFolders == 0) {
                        $titleString = $this->objLanguage->languageText("mod_filemanager_emptyfolderindicator", "filemanager");
                    } else {
                        $titleString = $this->objLanguage->languageText("mod_filemanager_contentsindicator", "filemanager");
                        $titleString = substr($titleString, 0, 9) . $nmbrOfFolders . substr($titleString, 8, 11) . $nmbrOfFiles . substr($titleString, 18, 12);
                    }
                    //End subfolder and files count
                    $folderLink->title = $titleString;
                    $folderLink->link = substr(basename($folder['folderpath']), 0, 70) . '...' . $extTitle;
                    if ($this->viewType == strtolower('thumbnails')) {
                        $objTable->addCell($this->domDoc->saveHTML($domElements['viewDiv']));
                    } else {
                        $objTable->addCell($folderLink->show());
                        $objTable->addCell('<em>' . $this->objLanguage->languageText('word_folder', 'system', 'Folder') . '</em>');
                        $objTable->endRow();
                    }
                }
            }
            if (is_array($symlinks)) {
                $files = array_merge($files, $symlinks);
            }
            if (count($files) > 0) {
                //var_dump($files);
                $fileSize = new formatfilesize();
                foreach ($files as $file) {
                    $this->domDoc = new DOMDocument('utf-8');
                    $domElements['viewDiv'] = $this->domDoc->createElement('div');
                    $domElements['viewDiv']->setAttribute('class', 'fm_thumbnails');
                    $visibility = null;
                    if (key_exists("visibility", $file)) {
                        $visibility = $file['visibility'];
                    } else {
                        $file['visibility'] = 'visible';
                    }
                    $showFile = true;
                    if ($visibility == 'hidden') {
                        if ($file['creatorid'] == $this->objUser->userid()) {
                            $showFile = true;
                        } else {
                            $showFile = false;
                        }
                    }
                    if (!$showFile) {
                        continue;
                    }
                    if (count($restriction) > 0) {
                        if (!in_array(strtolower($file['datatype']), $restriction)) {
                            $objTable->startRow('hidefile');
                            $hidden++;
                        } else {
                            $objTable->startRow();
                        }
                    } else {
                        $objTable->startRow();
                    }
                    if ($this->editPermission) {
                        $checkbox = new checkbox('files[]');
                        //DOM checkbox
                        $domElements['checkbox'] = $this->domDoc->createElement('input');
                        $domElements['checkbox']->setAttribute('type', 'checkbox');
                        $domElements['checkbox']->setAttribute('name', 'files[]');
                        //DOM link
                        $domElements['editLink'] = $this->domDoc->createElement('a');
                        $domElements['editLink']->setAttribute('title', $this->objLanguage->languageText('mod_filemanager_clicktoedit', 'filemanager'));
                        $domElements['editLink']->setAttribute('href', str_replace('amp;', '', $this->uri(array('action' => 'editfiledetails', 'id' => $file['id']), $this->targetModule)));
                        if (isset($file['symlinkid'])) {
                            $domElements['checkbox']->setAttribute('value', 'symlink_' . $file['symlinkid']);
                            $checkbox->value = 'symlink__' . $file['symlinkid'];
                        } else {
                            $checkbox->value = $file['id'];
                            $domElements['checkbox']->setAttribute('value', $file['id']);
                        }
                        $checkbox->cssId = htmlentities('input_files_' . $file['filename']);
                        if ($this->viewType != strtolower('thumbnails')) {
                            $objTable->addCell($checkbox->show());
                        } else {
                            $domElements['checkbox']->setAttribute('id', htmlentities('input_files_' . $file['filename']));
                            $domElements['viewDiv']->appendChild($domElements['checkbox']);
                            $domElements['editLink']->setAttribute('class', $this->objLanguage->languageText("mod_filemanager_buttonlinkclass", "filemanager"));
                            $domElements['editLink']->appendChild($this->domDoc->createTextNode(substr($this->objLanguage->languageText("word_edit", "system"), 0, 4)));
                            $domElements['viewDiv']->appendChild($domElements['editLink']);
                            //Add the line separator
                            $domElements['viewDiv']->appendChild($this->domDoc->createTextNode(' | '));
                        }
                    }
                    $label = new label($this->objFileIcons->getFileIcon($file['filename']), htmlentities('input_files_' . $file['filename']));
                    if ($this->viewType != strtolower('thumbnails')) {
                        $objTable->addCell($label->show());
                    }
                    if (isset($file['symlinkid'])) {
                        $fileLink = new link($this->uri(array('action' => 'symlink', 'id' => $file['symlinkid'])));
                        //The DOM file link
                        $domElements['fileLink'] = $this->domDoc->createElement('a');
                        $domElements['fileLink']->setAttribute('href', str_replace('amp;', '', $this->uri(array('action' => 'symlink', 'id' => $file['symlinkid']))));
                    } else {
                        $fileLink = new link($this->uri(array('action' => 'fileinfo', 'id' => $file['id']), $this->targetModule));
                        //The DOM file link
                        $domElements['fileLink'] = $this->domDoc->createElement('a');
                        $domElements['fileLink']->setAttribute('class', 'fileLink');
                        $domElements['fileLink']->setAttribute('href', str_replace('amp;', '', $this->uri(array('action' => 'fileinfo', 'id' => $file['id']), $this->targetModule)));
                    }
                    //The DOM image paragraph (to display image file information)
                    $domElements['imgParagraph'] = $this->domDoc->createElement('p');
                    $domElements['imgParagraph']->setAttribute('class', 'filedetails');
                    $linkTitle = '';
                    $access = null;
                    if (key_exists("access", $file)) {
                        $access = $file['access'];
                    } else {
                        $file['access'] = 'public';
                    }
                    $domElements['fileLink']->setAttribute('title', $this->objLanguage->languageText('mod_filemanager_clicktoviewinfo', 'filemanager'));
                    //The DOM download link
                    $domElements['downloadLink'] = $this->domDoc->createElement('a');
                    $domElements['downloadLink']->setAttribute('title', $this->objLanguage->languageText('mod_filemanager_clicktodownload', 'filemanager'));
                    $domElements['downloadLink']->setAttribute('href', $this->objCleanUrl->cleanUpUrl($this->objAltConfig->getcontentPath() . $file['path']));
                    $domElements['downloadLink']->appendChild($this->domDoc->createTextNode($this->objLanguage->languageText("word_download", "system")));
                    $domElements['downloadLink']->setAttribute('class', $this->objLanguage->languageText("mod_filemanager_buttonlinkclass", "filemanager"));
                    $domElements['viewDiv']->appendChild($domElements['downloadLink']);
                    //creating space between the links at the top and the string below
                    $domElements['viewDiv']->appendChild($this->domDoc->createElement('br'));
                    $filepath = $this->objAltConfig->getSiteRoot() . '/usrfiles/' . $file['path'];
                    $fileType = $this->getObject("fileparts", "files");
                    $domElements['detailsDiv'] = $this->domDoc->createElement('div');
                    $domElements['imgDiv'] = $this->domDoc->createElement('div');
                    $domElements['imgDiv']->setAttribute('class', 'imageDiv');
                    $domElements['imgParagraph']->appendChild($this->domDoc->createElement('br'));
                    $domElements['imgParagraph']->appendChild($this->domDoc->createTextNode($this->objLanguage->languageText("word_filename", "system") . ": " . substr($file['filename'], 0, 10)));
                    //new line
                    $domElements['imgParagraph']->appendChild($this->domDoc->createElement('br'));
                    $domElements['imgParagraph']->appendChild($this->domDoc->createtextNode($this->objLanguage->languageText("phrase_filesize", "system") . ": " . $objFileSize->formatsize($file['filesize'])));
                    //new line
                    $domElements['imgParagraph']->appendChild($this->domDoc->createElement('br'));
                    $domElements['imgParagraph']->appendChild($this->domDoc->createTextNode($this->objLanguage->languageText("phrase_filetype") . ": " . $fileType->getExtension($file['filename'])));
                    //new line
                    $domElements['imgParagraph']->appendChild($this->domDoc->createElement('br'));
                    $domElements['imgParagraph']->appendChild($this->domDoc->createTextNode($this->objLanguage->languageText("phrase_dateuploaded", "system") . ": " . $file['datecreated']));
                    if ($access == 'private_all') {
                        $domElements['imgParagraph']->appendChild($this->domDoc->createElement('br'));
                        $domElements['imgParagraph']->appendChild($this->domDoc->createTextNode(ucfirst($this->objLanguage->languageText('word_access', 'system')) . ': '));
                        $domElements['imgParagraph']->appendChild($this->domDoc->createTextNode($folder['access']));
                        $domElements['viewDiv']->setAttribute('id', $file['access']);
                        $objIcon->setIcon('info');
                        $linkTitle = basename($file['filename']) . $objIcon->show();
                    } else {
                        $linkTitle = basename($file['filename']);
                    }
                    // get image thumbnails
                    //The DOM image
                    $domElements['image'] = $this->domDoc->createElement('img');
                    if (ereg("image", $file['mimetype']) || ereg("video", $file['mimetype'])) {
                        $domElements['image']->setAttribute('src', str_replace('amp;', '', $objThumbnail->getThumbnail($file['id'], $file['filename'], $this->objCleanUrl->cleanUpUrl($this->objAltConfig->getcontentPath() . $file['path']), 'large')));
                        $domElements['image']->setAttribute('class', 'imgThumbnail');
                        $domElements['imgDiv']->appendChild($domElements['image']);
                        $domElements['detailsDiv']->appendChild($domElements['imgParagraph']);
                    }
                    //create audio/video player object
                    $objPlayer = "";
                    if (ereg("audio", $file['mimetype'])) {
                        $objPlayer = $objFilePreview->previewFile($file['id']);
                        $domElements['viewDiv']->appendChild($domElements['fileLink']);
                        $domElements['imgParagraph']->removeAttribute('class');
                        $domElements['detailsDiv']->appendChild($domElements['imgParagraph']);
                    }
                    //other formats
                    if (!ereg("audio", $file['mimetype']) && !ereg("image", $file['mimetype']) && !ereg("video", $file['mimetype'])) {
                        $domElements['image']->setAttribute('src', $this->objFileIcons->getIconSrc($file['datatype']));
                        $domElements['image']->setAttribute('class', 'iconThumbnail');
                        $domElements['image']->normalize();
                        $domElements['imgDiv']->appendChild($domElements['image']);
                        $domElements['detailsDiv']->appendChild($domElements['imgParagraph']);
                    }
                    $domElements['fileLink']->appendChild($domElements['detailsDiv']);
                    $domElements['fileLink']->appendChild($domElements['imgDiv']);
                    $domElements['viewDiv']->appendChild($domElements['fileLink']);
                    $fileLink->link = $linkTitle;
                    $folderAccessObj = $this->getObject("folderaccess");
                    $filepath = $this->objAltConfig->getSiteRoot() . '/usrfiles/' . $file['path'];
                    //// $filePreviewObj->previewFile($file['id']);
                    //$this->uri(array("action" => "downloadsecurefile", "path" => $file['path'], "filename" => $file['filename']));
                    // echo "rssult == ". $folderAccessObj->isFileAccessPrivate($file);
                    // die();
                    if ($folderAccessObj->isFileAccessPrivate($file)) {
                        $filepath = $this->objAltConfig->getSiteRoot() . "index.php?module=filemanager&action=file&id=" . $file['id'] . '&filename=' . $file['filename'];
                    }
                    $selectStr = '<a href=\'javascript:selectFile("' . $filepath . '");\'>' . basename($file['filename']) . '</a>';
                    $selectFileStr = '<a href=\'javascript:selectFileWindow("' . $name . '","' . $file['filename'] . '","' . $file['id'] . '");\'>' . basename($file['filename']) . '</a>';
                    $selectImageStr = '<a href=\'javascript:selectImageWindow("' . $name . '", "' . $filepath . '","' . $file['filename'] . '","' . $file['id'] . '");\'>' . basename($file['filename']) . '</a>';
                    if ($mode == 'fckimage' || $mode == 'fckflash' || $mode == 'fcklink') {
                        if ($this->viewType != strtolower('thumbnails')) {
                            $objTable->addCell($selectStr);
                        } else {
                            //Disable file preview
                            $domElements['fileLink']->removeAttribute('href');
                            //remove the title string as the option will not be possible
                            $domElements['fileLink']->removeAttribute('title');
                            //The DOM select string
                            $domElements['selectStr'] = $this->domDoc->createElement('a');
                            $domElements['selectStr']->appendChild($this->domDoc->createTextNode($this->objLanguage->languageText('word_select', 'system')));
                            $domElements['selectStr']->setAttribute('href', 'javascript:selectFile("' . $filepath . '");');
                            $domElements['selectStr']->setAttribute('class', $this->objLanguage->languageText('mod_filemanager_buttonlinkclass', 'filemanager'));
                            $domElements['viewDiv']->appendChild($domElements['selectStr']);
                            $objTable->addCell($this->domDoc->saveHTML($domElements['viewDiv']) . $objPlayer);
                        }
                    } else {
                        if ($mode == 'selectfilewindow') {
                            if ($this->viewType != strtolower('thumbnails')) {
                                $objTable->addCell($selectFileStr);
                            } else {
                                $domElements['fileLink']->removeAttribute('href');
                                //remove the title string as the option will not be possible
                                $domElements['fileLink']->removeAttribute('title');
                                //The DOM select file string
                                $domElements['selectFileStr'] = $this->domDoc->createElement('a');
                                $domElements['selectFileStr']->setAttribute('href', 'javascript:selectFileWindow("' . $name . '","' . $file['filename'] . '","' . $file['id'] . '");');
                                $domElements['selectFileStr']->appendChild($this->domDoc->createTextNode($this->objLanguage->languageText('word_select', 'system')));
                                $domElements['selectFileStr']->setAttribute('class', $this->objLanguage->languageText('mod_filemanager_buttonlinkclass', 'filemanager'));
                                $domElements['viewDiv']->appendChild($domElements['selectFileStr']);
                                $objTable->addCell($this->domDoc->saveHTML($domElements['viewDiv']) . $objPlayer);
                            }
                        } else {
                            if ($mode == 'selectimagewindow') {
                                if ($this->viewType != strtolower('thumbnails')) {
                                    $objTable->addCell($selectImageStr);
                                } else {
                                    $domElements['fileLink']->removeAttribute('href');
                                    //remove the title string as the option will not be possible
                                    $domElements['fileLink']->removeAttribute('title');
                                    //The DOM image select link
                                    $domElements['imageSelect'] = $this->domDoc->createElement('a');
                                    $domElements['imageSelect']->setAttribute('href', 'javascript:selectImageWindow("' . $name . '","' . $filepath . '","' . $file['filename'] . '","' . $file['id'] . '");');
                                    $domElements['imageSelect']->appendChild($this->domDoc->createTextNode($this->objLanguage->languageText('word_select', 'system')));
                                    $domElements['imageSelect']->setAttribute('class', $this->objLanguage->languageText('mod_filemanager_buttonlinkclass', 'filemanager'));
                                    $domElements['viewDiv']->appendChild($domElements['imageSelect']);
                                    $objTable->addCell($this->domDoc->saveHTML($domElements['viewDiv']) . $objPlayer);
                                }
                            } else {
                                if ($this->viewType == strtolower('thumbnails')) {
                                    //return the document with all available objects and elements
                                    $objTable->addCell($this->domDoc->saveHTML($domElements['viewDiv']) . $objPlayer);
                                } else {
                                    $objTable->addCell($fileLink->show());
                                }
                            }
                        }
                    }
                    if ($this->viewType != strtolower('thumbnails')) {
                        $objTable->addCell($fileSize->formatsize($file['filesize']));
                    } else {
                        $objTable->endRow();
                    }
                }
            }
        }
        if ($hidden > 0 && count($restriction) > 0) {
            $str = '';
            if ($this->viewType == strtolower('thumbnails')) {
                $str .= '<style type="text/css">
#filemanagerTable tr.hidefile {display:none;}
</style>';
            } else {
                $str .= '<style type="text/css">
 tr.hidefile {display:none;}
</style>';
            }
            $str .= $this->objLanguage->languageText('mod_filemanager_browsingfor', 'filemanager', 'Browsing for') . ': ';
            $comma = '';
            foreach ($restriction as $restrict) {
                $str .= $comma . $restrict;
                $comma = ', ';
            }
            if (!$forceRestriction) {
                if ($this->viewType == strtolower('thumbnails')) {
                    $str .= '<script type="text/javascript">
var onOrOff = "off";
function turnOnFiles(value)
{
    if (onOrOff == \'off\') {
        jQuery(\'#filemanagerTable tr.hidefile\').each(function (i) {
            this.style.display = \'inline-block\';
        });
        adjustLayout();
        onOrOff = "on";
    } else {
        jQuery(\'#filemanagerTable tr.hidefile\').each(function (i) {
            this.style.display = \'none\';
        });
        adjustLayout();
        onOrOff = "off";
    }
}
</script>';
                } else {
                    $str .= '<script type="text/javascript">
var onOrOff = "off";
function turnOnFiles(value)
{
    if (onOrOff == \'off\') {
        jQuery(\'tr.hidefile\').each(function (i) {
            this.style.display = \'table-row\';
        });
        adjustLayout();
        onOrOff = "on";
    } else {
        jQuery(\'tr.hidefile\').each(function (i) {
            this.style.display = \'none\';
        });
        adjustLayout();
        onOrOff = "off";
    }
}
</script>';
                }
                $str .= ' &nbsp; - ';
                $this->loadClass('checkbox', 'htmlelements');
                $this->loadClass('label', 'htmlelements');
                $checkbox = new checkbox('showall');
                $checkbox->extra = ' onclick="turnOnFiles();"';
                $label = new label($this->objLanguage->languageText('mod_filemanager_showallfiles', 'filemanager', 'Show All Files'), $checkbox->cssId);
                $str .= $checkbox->show() . $label->show();
            }
        } else {
            $str = '';
        }
        return $str . $objTable->show() . $this->getJavascriptFile('thumbnails.js', 'filemanager');
    }
Пример #4
0
<?php

if (count($results) == 0) {
    echo '<div class="noRecordsMessage">' . $this->objLanguage->languageText('mod_filemanager_noresultsquotasearch', 'filemanager', 'No results matching search criteria found') . '</div>';
} else {
    $this->loadClass('formatfilesize', 'files');
    $this->loadClass('link', 'htmlelements');
    $objFileSize = new formatfilesize();
    $objIcon = $this->newObject('geticon', 'htmlelements');
    $objIcon->setIcon('edit');
    $editIcon = $objIcon->show();
    if ($searchType == 'context') {
        $table = $this->newObject('htmltable', 'htmlelements');
        $table->startHeaderRow();
        $table->addHeaderCell(ucwords($this->objLanguage->code2Txt('mod_context_contextcode', 'context', NULL, '[-context-] Code')));
        $table->addHeaderCell(ucwords($this->objLanguage->code2Txt('mod_context_contexttitle', 'context', NULL, '[-context-] Title')));
        $table->addHeaderCell($this->objLanguage->languageText('mod_filemanager_usedefault', 'filemanager', 'Use default'), 100);
        $table->addHeaderCell($this->objLanguage->languageText('mod_filemanager_quota', 'filemanager', 'Quota'), 100);
        $table->addHeaderCell($this->objLanguage->languageText('mod_filemanager_usage', 'filemanager', 'Usage'), 100);
        $table->addHeaderCell($this->objLanguage->languageText('mod_filemanager_graph', 'filemanager', 'Graph'), 200);
        $table->addHeaderCell('&nbsp;', 50);
        $table->endHeaderRow();
        foreach ($results as $result) {
            $table->startRow();
            $table->addCell($result['contextcode']);
            $table->addCell($result['title']);
            $table->addCell($result['usedefault']);
            if ($result['usedefault'] == 'Y') {
                $quota = $defaultQuota;
            } else {
                $quota = $result['quota'];
Пример #5
0
if (count($files) == 0) {
    echo '<p>' . $this->objLanguage->languageText('mod_filemanager_nofilesuploaded', 'filemanager', 'No files uploaded') . '</p>';
} else {
    $this->appendArrayVar('headerParams', $this->getJavascriptFile('selectall.js', 'htmlelements'));
    $table = $this->newObject('htmltable', 'htmlelements');
    $table->cellpadding = '3';
    $table->startHeaderRow();
    $table->addHeaderCell('&nbsp;', 20);
    $table->addHeaderCell('&nbsp;', 20);
    $table->addHeaderCell($this->objLanguage->languageText('word_filename', 'filemanager', 'Filename'));
    $table->addHeaderCell($this->objLanguage->languageText('word_size', 'filemanager', 'Size'), '60', NULL, 'center', NULL);
    //$table->addHeaderCell('Description');
    //$table->addHeaderCell($this->objLanguage->languageText('phrase_dateuploaded', 'filemanager', 'Date Uploaded'), NULL, NULL, NULL, 'nowrap');
    $table->addHeaderCell('&nbsp;', 30);
    $table->endHeaderRow();
    $filesize = new formatfilesize();
    $objIcon->setIcon('download');
    $downloadIcon = $objIcon->show();
    $userfilespath = $this->objConfig->getcontentPath();
    foreach ($files as $file) {
        $link = new link($this->uri(array('action' => 'fileinfo', 'id' => $file['id'], 'type' => $file['category'], 'filename' => $file['filename'])));
        $link->link = htmlentities(str_replace('_', ' ', $file['filename']));
        $table->startRow();
        $checkbox = new checkbox('files[]');
        $checkbox->value = $file['id'];
        $checkbox->cssId = htmlentities('input_files_' . $file['filename']);
        $table->addCell($checkbox->show(), 20);
        $label = new label($objFileIcons->getFileIcon($file['filename']), htmlentities('input_files_' . $file['filename']));
        $table->addCell($label->show(), 20);
        $table->addCell($link->show());
        $table->addCell($filesize->formatsize($file['filesize']), '60', NULL, 'right', 'nowrap');
Пример #6
0
 /**
  * Method to get media information about a file
  * and return the result in table display format
  * @param  string $fileId Record Id of the File
  * @return string Information about the file in a table format
  */
 public function getFileMediaInfoTable($fileId)
 {
     $file = $this->getFileInfo($fileId);
     if ($file == FALSE) {
         return FALSE;
     }
     if (!array_key_exists('width', $file)) {
         return FALSE;
     }
     $objFileSize = new formatfilesize();
     $mediaInfoArray = array();
     if ($file['width'] != 0) {
         $mediaInfoArray['info_width'] = $file['width'] . ' px';
     }
     if ($file['height'] != 0) {
         $mediaInfoArray['info_height'] = $file['height'] . ' px';
     }
     if ($file['playtime'] != 0) {
         $seconds = $file['playtime'] % 60;
         $minutes = ($file['playtime'] - $seconds) / 60;
         if ($seconds < 10) {
             $seconds = '0' . $seconds;
         }
         if ($minutes > 59) {
             $hour = ($minutes - $minutes % 60) / 60;
             $minutes = $minutes % 60;
             $str = $hour . ':' . $minutes . ':' . $seconds;
         } else {
             $str = $minutes . ':' . $seconds;
         }
         $mediaInfoArray['info_playtime'] = $str;
     }
     if ($file['framerate'] != 0) {
         $mediaInfoArray['info_framerate'] = $file['framerate'];
     }
     if ($file['bitrate'] != 0) {
         $mediaInfoArray['info_bitrate'] = $objFileSize->formatsize($file['bitrate']);
     }
     if ($file['samplerate'] != 0) {
         $mediaInfoArray['info_samplerate'] = $objFileSize->formatsize($file['samplerate']);
     }
     if ($file['title'] != '') {
         $mediaInfoArray['info_title'] = $file['title'];
     }
     if ($file['artist'] != '') {
         $mediaInfoArray['info_artist'] = $file['artist'];
     }
     if ($file['year'] != '') {
         $mediaInfoArray['info_year'] = $file['year'];
     }
     if ($file['url'] != '') {
         $mediaInfoArray['info_url'] = $file['url'];
     }
     if (count($mediaInfoArray) < 1) {
         return FALSE;
     } else {
         $objTable = $this->newObject('htmltable', 'htmlelements');
         $objTable->startRow();
         $rowStarted = TRUE;
         $count = 0;
         foreach ($mediaInfoArray as $item => $value) {
             $objTable->addCell('<strong>' . $this->objLanguage->languageText('mod_filemanager_' . $item, 'filemanager') . '</strong>', '25%');
             $objTable->addCell($value, '25%');
             $count++;
             if ($count % 2 == 0) {
                 $objTable->endRow();
                 $rowStarted = FALSE;
                 if (count($mediaInfoArray) - $count != 0) {
                     $objTable->startRow();
                     $rowStarted = TRUE;
                 }
             }
         }
         if ($rowStarted) {
             if ($count % 2 == 1) {
                 $objTable->addCell('&nbsp;', '25%');
                 $objTable->addCell('&nbsp;', '25%');
             }
             $objTable->endRow();
         }
         return $objTable->show();
     }
 }
 /**
  * Method to show the interface for overwriting files
  */
 public function showUserOverwiteInterface()
 {
     $userId = $this->objUser->userId();
     $tempFiles = $this->objFile->getTemporaryFiles($userId);
     $form = new form('fixtempfiles', $this->uri(array('action' => 'fixtempfiles')));
     $divider = '';
     $splitter = '';
     $listItems = '';
     $submitButton = new button('submitform', 'Update Files');
     $submitButton->setToSubmit();
     $objHighlightLabels = $this->getObject('highlightlabels', 'htmlelements');
     $objHighlightLabels->show();
     $formatsize = new formatfilesize();
     foreach ($tempFiles as $file) {
         //$form->addToForm($divider);
         //$divider = '<hr size="1" width="70%" />';
         $listItems .= $splitter . $file['id'];
         $splitter = '|';
         // Rename Id of the button to keep them unique
         $submitButton->cssId = 'input_button_' . $file['id'];
         $originalFile = $this->objFile->getOriginalFile($file['filename'], $userId);
         $form->addToForm('<h2>' . $file['filename'] . '</h2>');
         $table = $this->newObject('htmltable', 'htmlelements');
         $table->startHeaderRow();
         $table->addHeaderCell('Info', '20%');
         $table->addHeaderCell('Old File', '40%');
         $table->addHeaderCell('New File', '40%');
         $table->endHeaderRow();
         if ($originalFile['category'] == 'images') {
             $oldThumbnail = $this->objFileEmbed->embed($this->objThumbnails->getThumbnail($originalFile['id'], $originalFile['filename']), 'image');
             $newThumbnail = $this->objFileEmbed->embed($this->objThumbnails->getThumbnail($file['id'], $file['filename']), 'image');
             // File Preview
             $table->startRow();
             $table->addCell('File Preview');
             $table->addCell($oldThumbnail);
             $table->addCell($newThumbnail);
             $table->endRow();
         } else {
             $oldThumbnail = 'gdsgsd';
             $newThumbnail = 'gdsgsd';
         }
         // File Size
         $table->startRow();
         $table->addCell('Size of File');
         $table->addCell($formatsize->formatsize($originalFile['filesize']));
         $table->addCell($formatsize->formatsize($file['filesize']));
         $table->endRow();
         // Date Uploaded
         $table->startRow();
         $table->addCell('Date Uploaded');
         $table->addCell($this->objFormatDateTime->formatDateOnly($originalFile['datecreated']) . ' at ' . $this->objFormatDateTime->formatTime($originalFile['timecreated']));
         $table->addCell($this->objFormatDateTime->formatDateOnly($file['datecreated']) . ' at ' . $this->objFormatDateTime->formatTime($file['timecreated']));
         $table->endRow();
         $form->addToForm($table->show());
         $form->addToForm('<h4>Options:</h4>');
         $radio = new radio($file['id']);
         $radio->setBreakSpace('<br />');
         $radio->addOption('ignore', 'Ignore this file for the time being');
         $radio->addOption('overwrite', 'Overwrite old file with new one');
         $radio->addOption('deletetemp', 'Delete the Temporary File');
         $extension = $this->objFileParts->getExtension($file['filename']);
         if (strlen($extension) == strlen($file['filename'])) {
             $filename = $file['filename'];
             $extension = '';
         } else {
             $filename = substr($file['filename'], 0, strlen($file['filename']) - strlen($extension) - 1);
             $extension = '.' . $extension;
         }
         $textinput = new textinput('rename__' . $file['id'], $filename);
         $textinput->size = 50;
         $extensioninput = new textinput('extension__' . $file['id'], $extension);
         $extensioninput->size = 5;
         $extensioninput->extra = ' readonly="true"';
         // Fix Up - Highlight Radio Button
         //$textinput->extra = ' onclick="document.getElementById(\'input_gen19Srv1Nme34_247ignore\').focus();"; ';
         //$radio->addOption('rename', 'Rename the temporary file to: ');
         $radio->setSelected('ignore');
         //$form->addToForm($radio->show().$textinput->show().$extensioninput->show());
         $form->addToForm($radio->show());
         $form->addToForm('<p align="center">' . $submitButton->show() . '</p>');
     }
     $hiddenInput = new hiddeninput('listitems', $listItems);
     $form->addToForm($hiddenInput->show());
     return $form->show();
 }
 /**
  * Method to process Error Upload Messages
  * @return string Confirmation message of error uploads
  */
 public function processOverwriteMessages()
 {
     if ($this->getParam('overwrite') == '') {
         $overwriteMessage = '';
     } else {
         $items = explode('__', $this->getParam('overwrite'));
         $overwriteMessage = '';
         $table = $this->newObject('htmltable', 'htmlelements');
         $table->startHeaderRow();
         $table->addHeaderCell('Filename');
         $table->addHeaderCell('File Size of Existing File', NULL, NULL, 'center');
         $table->addHeaderCell('File Size of New File', NULL, NULL, 'center');
         $table->addHeaderCell('Overwrite File?', NULL, NULL, 'center');
         $table->endHeaderRow();
         $actualItems = array();
         $formatsize = new formatfilesize();
         foreach ($items as $item) {
             // Get File Details
             $file = $this->objFiles->getFile($item);
             // Generate Path to File
             $tempFilePath = $this->objConfig->getcontentBasePath() . '/filemanager_tempfiles/' . $item;
             // Create Boolean Variable - does file exist
             if (file_exists($tempFilePath)) {
                 $tempFileExists = TRUE;
             } else {
                 $tempFileExists = FALSE;
             }
             // If no record
             if ($file == FALSE) {
                 // Delete temp file if it exists
                 if ($tempFileExists && is_file($tempFilePath)) {
                     unlink($tempFilePath);
                 }
             } else {
                 if ($file && $tempFileExists) {
                     // If Record and Temp File exists
                     // Add to Form for User to choose option
                     $actualItems[] = $item;
                     $table->startRow();
                     $table->addCell('<strong>' . $file['filename'] . '</strong>');
                     $table->addCell($formatsize->formatsize($file['filesize']), NULL, NULL, 'center');
                     $table->addCell($formatsize->formatsize(filesize($tempFilePath)), NULL, NULL, 'center');
                     $radio = new radio($item);
                     $radio->addOption('delete', ' No');
                     $radio->addOption('overwrite', ' Yes');
                     $radio->setSelected('delete');
                     $radio->setBreakSpace(' &nbsp; ');
                     $table->addCell($radio->show(), NULL, NULL, 'center');
                     $table->endRow();
                 }
             }
         }
         if (count($actualItems) > 0) {
             $form = new form('overwriteoptions', $this->uri(array('action' => 'fixtempfiles')));
             $form->addToForm($table->show());
             $list = '';
             $separator = '';
             foreach ($actualItems as $itemId) {
                 $list .= $separator . $itemId;
                 $separator = '__';
             }
             $hiddenInput = new hiddeninput('listitems', $list);
             $form->addToForm($hiddenInput->show());
             $overMsg = $this->objLanguage->languageText('mod_filemanager_overwriteconfirm', 'filemanager', 'Do you wish to overwrite?');
             $button = new button('submitform', $overMsg);
             $button->setToSubmit();
             $form->addToForm($button->show());
             $overwriteMessage = $form->show();
         }
     }
     return $overwriteMessage;
 }