Exemplo n.º 1
0
 public function view()
 {
     $fs = FileSet::getByID($this->fsID);
     $fileList = new FileList();
     $fileList->filterBySet($fs);
     $fileList->filterByType(FileType::T_IMAGE);
     $fileList->sortByFileSetDisplayOrder();
     $images = $fileList->get(1000, 0);
     $this->set('images', $images);
     $this->set('picture', $this->getPicture());
 }
Exemplo n.º 2
0
 private function _prepare($fs)
 {
     $fl = new FileList();
     $fl->filterByExtension("js");
     $fl->filterBySet($fs);
     $files = $fl->get();
     $setFiles = array();
     foreach ($files as $f) {
         $fv = $f->getRecentVersion();
         $fn = $fv->getFileName();
         $this->_exists[$fn] = $f;
     }
 }
Exemplo n.º 3
0
 public function getMootoolsPluginFiles($fs)
 {
     Loader::model('file_set');
     Loader::model('file_list');
     //		$u = new User();
     $fl = new FileList();
     $fl->filterByMootoolsPlugin(true);
     $fl->filterByExtension("js");
     //		$fl->filter('u.uID', $u->getUserID(), '=');
     $fl->sortByAttributeKey("ak_" . MOOTOOLS_PLUGIN_DISPLAY_ORDER);
     $fl->filterBySet($fs);
     $files = $fl->get();
     return $files;
 }
Exemplo n.º 4
0
	function loadFileSet(){
		if (intval($this->fsID) < 1) {
			return false;
		}
        Loader::helper('concrete/file');
		Loader::model('file_attributes');
		Loader::library('file/types');
		Loader::model('file_list');
		Loader::model('file_set');
		
		$ak = FileAttributeKey::getByHandle('height');

		$fs = FileSet::getByID($this->fsID);
		$fileList = new FileList();		
		$fileList->filterBySet($fs);
		$fileList->filterByType(FileType::T_IMAGE);	
		$fileList->sortByFileSetDisplayOrder();
		
		$files = $fileList->get(1000,0);
		
		
		$image = array();
		$image['duration'] = $this->duration;
		$image['fadeDuration'] = $this->fadeDuration;
		$image['groupSet'] = 0;
		$image['url'] = '';
		$images = array();
		$maxHeight = 0;
		foreach ($files as $f) {
			$fp = new Permissions($f);
			if(!$fp->canViewFile()) { continue; }
			$image['fID'] 			= $f->getFileID();
			$image['fileName'] 		= $f->getFileName();
			$image['fullFilePath'] 	= $f->getPath();
			$image['url']			= $f->getRelativePath();
			
			// find the max height of all the images so slideshow doesn't bounce around while rotating
			$vo = $f->getAttributeValueObject($ak);
			if (is_object($vo)) {
				$image['imgHeight'] = $vo->getValue('height');
			}
			if ($maxHeight == 0 || $image['imgHeight'] > $maxHeight) {
				$maxHeight = $image['imgHeight'];
			}
			$images[] = $image;
		}
		$this->images = $images;
	
	}
 public static function getUnsortedPermittedFilesetImages($fsID)
 {
     Loader::model('file_set');
     Loader::model('file_list');
     $fsHasDisplayOrder = version_compare(APP_VERSION, '5.4.1', '>=');
     $fs = FileSet::getByID($fsID);
     $fl = new FileList();
     $fl->filterBySet($fs);
     $fl->filterByType(FileType::T_IMAGE);
     if ($fsHasDisplayOrder) {
         $fl->sortByFileSetDisplayOrder();
     }
     $all_files = $fl->get();
     $permitted_files = array();
     foreach ($all_files as $f) {
         $fp = new Permissions($f);
         if ($fp->canRead()) {
             $permitted_files[] = $f;
         }
     }
     return $permitted_files;
 }
Exemplo n.º 6
0
 public static function getPermittedFilesetImages($fsID, $use_file_props_for_title_and_caption = false)
 {
     Loader::model('file_set');
     Loader::model('file_list');
     $fsHasDisplayOrder = version_compare(APP_VERSION, '5.4.1', '>=');
     $fs = FileSet::getByID($fsID);
     $fl = new FileList();
     $fl->filterBySet($fs);
     $fl->filterByType(FileType::T_IMAGE);
     if ($fsHasDisplayOrder) {
         $fl->sortByFileSetDisplayOrder();
     }
     $all_files = $fl->get();
     $permitted_files = array();
     foreach ($all_files as $f) {
         $fp = new Permissions($f);
         if ($fp->canRead()) {
             $fv = $f->getRecentVersion();
             $permitted_files[$f->fID] = array('file' => $f, 'fID' => $f->fID, 'position' => $fsHasDisplayOrder ? $f->fsDisplayOrder : 0, 'title' => $use_file_props_for_title_and_caption ? $fv->getTitle() : '', 'caption' => $use_file_props_for_title_and_caption ? $fv->getDescription() : '');
         }
     }
     return $permitted_files;
 }
Exemplo n.º 7
0
 public function swapContent($options)
 {
     if ($this->validateClearSiteContents($options)) {
         Loader::model("page_list");
         Loader::model("file_list");
         Loader::model("stack/list");
         $pl = new PageList();
         $pages = $pl->get();
         foreach ($pages as $c) {
             $c->delete();
         }
         $fl = new FileList();
         $files = $fl->get();
         foreach ($files as $f) {
             $f->delete();
         }
         // clear stacks
         $sl = new StackList();
         foreach ($sl->get() as $c) {
             $c->delete();
         }
         $home = Page::getByID(HOME_CID);
         $blocks = $home->getBlocks();
         foreach ($blocks as $b) {
             $b->deleteBlock();
         }
         $pageTypes = CollectionType::getList();
         foreach ($pageTypes as $ct) {
             $ct->delete();
         }
         // now we add in any files that this package has
         if (is_dir($this->getPackagePath() . '/content_files')) {
             Loader::library('file/importer');
             $fh = new FileImporter();
             $contents = Loader::helper('file')->getDirectoryContents($this->getPackagePath() . '/content_files');
             foreach ($contents as $filename) {
                 $f = $fh->import($this->getPackagePath() . '/content_files/' . $filename, $filename);
             }
         }
         // now we parse the content.xml if it exists.
         Loader::library('content/importer');
         $ci = new ContentImporter();
         $ci->importContentFile($this->getPackagePath() . '/content.xml');
     }
 }
Exemplo n.º 8
0
 public function getIcons()
 {
     $f = Loader::helper('file');
     Loader::model('file_list');
     Loader::model('file_set');
     $fileList = new FileList();
     $fs = FileSet::getByName('Page Type Icons');
     if (!$fs) {
         return $f->getDirectoryContents(DIR_FILES_COLLECTION_TYPE_ICONS);
     } else {
         $fileList->filterBySet($fs);
         $icons = $fileList->get(100);
         if (!count($icons)) {
             $icons = $f->getDirectoryContents(DIR_FILES_COLLECTION_TYPE_ICONS);
         }
         return $icons;
     }
 }
Exemplo n.º 9
0
 static function getFilesetImages($fsID, $randomize = false)
 {
     Loader::model('file_set');
     Loader::model('file_list');
     $fs = FileSet::getByID($fsID);
     $fl = new FileList();
     $fl->filterBySet($fs);
     $fl->filterByType(FileType::T_IMAGE);
     $fl->setPermissionLevel('canRead');
     if ($randomize) {
         $fl->sortBy('RAND()', 'asc');
     } else {
         $fl->sortByFileSetDisplayOrder();
         //Requires 5.4.1 or higher: version_compare(APP_VERSION, '5.4.1', '>=');
     }
     $files = $fl->get();
     return $files;
 }
Exemplo n.º 10
0
    echo $form->hidden('fsID', $fs->getFileSetID());
    ?>
		</form>
	</div>
	
	<h1><span><?php 
    echo t('Files');
    ?>
</span></h1>
	<div class="ccm-dashboard-inner">
		<?php 
    Loader::model("file_list");
    $fl = new FileList();
    $fl->filterBySet($fs);
    $fl->sortByFileSetDisplayOrder();
    $files = $fl->get();
    if (count($files) > 0) {
        ?>
		
		<form id="ccm-file-set-save-sort-order" method="post" action="<?php 
        echo $this->url('/dashboard/files/sets', 'save_sort_order');
        ?>
">
			<?php 
        echo $form->hidden('fsDisplayOrder', '');
        ?>
			<?php 
        echo $form->hidden('fsID', $fs->getFileSetID());
        ?>
		</form>
		
Exemplo n.º 11
0
 public static function exportArchive($archive)
 {
     $fl = new FileList();
     $files = $fl->get();
     $filestring = '';
     $fh = Loader::helper('file');
     $filenames = array();
     $filename = $fh->getTemporaryDirectory() . '/' . $archive . '.zip';
     if (count($files) > 0) {
         try {
             if (class_exists('ZipArchive', false)) {
                 $zip = new ZipArchive();
                 $res = $zip->open($filename, ZipArchive::CREATE);
                 if ($res === TRUE) {
                     foreach ($files as $f) {
                         $file = $f->getPath();
                         if (!in_array(basename($file), $filenames)) {
                             $filenames[] = basename($file);
                             $zip->addFile(addslashes($file), basename($file));
                         }
                     }
                     $zip->close();
                 } else {
                     throw new Exception(t('Could not open with ZipArchive::CREATE'));
                 }
             } else {
                 $filestring = "'" . addslashes($filename) . "' ";
                 foreach ($files as $f) {
                     $file = $f->getPath();
                     if (!in_array(basename($file), $filenames)) {
                         $filenames[] = basename($file);
                         $filestring .= "'" . addslashes($file) . "' ";
                     }
                 }
                 exec(DIR_FILES_BIN_ZIP . ' -j ' . $filestring);
             }
         } catch (Exception $e) {
             throw new Exception(t('Failed to create zip file as "%s": %s', $filename, $e->getMessage()));
         }
     }
 }
Exemplo n.º 12
0
 public static function exportArchive($archive)
 {
     $fl = new FileList();
     $files = $fl->get();
     $filestring = '';
     $fh = Loader::helper('file');
     $filenames = array();
     $filename = $fh->getTemporaryDirectory() . '/' . $archive . '.zip';
     if (count($files) > 0) {
         foreach ($files as $f) {
             if (!in_array(basename($f->getPath()), $filenames)) {
                 $filestring .= "'" . addslashes($f->getPath()) . "' ";
             }
             $filenames[] = basename($f->getPath());
         }
         exec(DIR_FILES_BIN_ZIP . ' -j \'' . addslashes($filename) . '\' ' . $filestring);
     }
 }
Exemplo n.º 13
0
<?php

$session->requireLoggedIn();
switch ($this->view) {
    case 'show':
        echo '<h1>Uploaded files</h1>';
        $files = new FileList(FILETYPE_PROCESS);
        $list = $files->get();
        foreach ($list as $row) {
            echo ahref('queue/status/' . $row['fileId'], $row['fileName']);
            $uploader = new User($row['uploaderId']);
            echo ', mime=' . $row['fileMime'] . ' uploaded ' . $row['timeUploaded'] . ' by ' . $uploader->render() . '<br/>';
        }
        echo '<h1>Converted files</h1>';
        $files = new FileList(FILETYPE_CLONE_CONVERTED);
        $list = $files->get();
        foreach ($list as $row) {
            echo ahref('queue/status/' . $row['fileId'], 'Details');
            $uploader = new User($row['uploaderId']);
            echo ', mime=' . $row['fileMime'] . ' created ' . $row['timeUploaded'] . ' by ' . $uploader->render() . '<br/>';
        }
        break;
    case 'new':
        function uploadSubmit($p)
        {
            // XhtmlForm:s upload handler har redan processat filen här
            $eventId = TaskQueue::addTask(TASK_UPLOAD, $p['f1']);
            if (!$eventId) {
                echo 'file upload handling failed';
                return false;
            }