function getFile($fID) { Loader::model('file'); $mf = new File(); $file_obj = $mf->getByID($fID); $fileversion_obj = $file_obj->getVersion(); $bf = new LibraryFileBlockController; $ftype = FileTypeList::getType($fileversion_obj->getExtension()); $this->generictype = strtolower($ftype->getGenericTypeText($ftype->getGenericType())); $this->filename = $fileversion_obj->getFileName(); $this->type = $fileversion_obj->getType(); $this->url = $fileversion_obj->getURL(); $this->filepath = $fileversion_obj->getPath(); $this->relpath = $fileversion_obj->getRelativePath(); $this->origfilename = $fileversion_obj->getRelativePath(); $this->filesize = $fileversion_obj->getFullSize(); $len = strlen(REL_DIR_FILES_UPLOADED); $fh = Loader::helper('concrete/file'); $bf->bID = $fileversion_obj->getFileID(); $bf->generictype = $this->generictype; $bf->type = $this->type; $bf->url = $this->url; $bf->filepath = $this->filepath; $bf->relpath = $this->relpath; $bf->filename = substr($this->relpath, $len); // for backwards compatibility this must include the prefixes $bf->filesize = $this->filesize; return $bf; }
public static function getByHandle($akHandle) { $db = Loader::db(); $q = "SELECT ak.akID FROM AttributeKeys ak INNER JOIN AttributeKeyCategories akc ON ak.akCategoryID = akc.akCategoryID WHERE ak.akHandle = ? AND akc.akCategoryHandle = 'file'"; $akID = $db->GetOne($q, array($akHandle)); if ($akID > 0) { $ak = FileAttributeKey::getByID($akID); return $ak; } else { // else we check to see if it's listed in the initial registry $ia = FileTypeList::getImporterAttribute($akHandle); if (is_object($ia)) { // we create this attribute and return it. $at = AttributeType::getByHandle($ia->akType); $args = array( 'akHandle' => $akHandle, 'akName' => $ia->akName, 'akIsSearchable' => 1, 'akIsAutoCreated' => 1, 'akIsEditable' => $ia->akIsEditable ); return FileAttributeKey::add($at, $args); } } }
public function inspect($fv) { $path = $fv->getPath(); $ft = FileTypeList::getInstance(); $ft->defineImporterAttribute('lines', t('Lines of Code'), 'NUMBER', false); $at1 = FileAttributeKey::getByHandle('lines'); $fv->setAttribute($at1, trim(exec('/bin/cat \'' . $path . '\' | wc -l'))); }
/** * Can take an extension or a filename * Returns any registered information we have for the particular file type, based on its registration */ public static function getType($ext) { $ftl = FileTypeList::getInstance(); if (strpos($ext, '.') !== false) { // filename $h = Loader::helper('file'); $ext = $h->getExtension($ext); } $ext = strtolower($ext); if (is_object($ftl->types[$ext])) { return $ftl->types[$ext]; } else { $ft = new FileType(); // generic return $ft; } }
public static function getByHandle($akHandle) { $db = Loader::db(); $akID = $db->GetOne('select akID from AttributeKeys where akHandle = ?', array($akHandle)); if ($akID > 0) { $ak = FileAttributeKey::getByID($akID); return $ak; } else { // else we check to see if it's listed in the initial registry $ia = FileTypeList::getImporterAttribute($akHandle); if (is_object($ia)) { // we create this attribute and return it. $at = AttributeType::getByHandle($ia->akType); $args = array('akHandle' => $akHandle, 'akName' => $ia->akName, 'akIsSearchable' => 1, 'akIsAutoCreated' => 1, 'akIsEditable' => $ia->akIsEditable); return FileAttributeKey::add($at, $args); } } }
<table id="incoming_file_table" class="table table-bordered" width="100%" cellpadding="0" cellspacing="0"> <tr> <th width="10%" valign="middle" class="center theader"><input type="checkbox" id="check_all_imports" name="check_all_imports" onclick="ccm_alSelectMultipleIncomingFiles(this);" value="" /></td> <th width="20%" valign="middle" class="center theader"></td> <th width="45%" valign="middle" class="theader"><?php echo t('Filename'); ?> </td> <th width="25%" valign="middle" class="center theader"><?php echo t('Size'); ?> </td> </tr> <?php foreach ($incoming_contents as $filenum => $file_array) { $ft = FileTypeList::getType($file_array['name']); ?> <tr> <td width="10%" valign="middle" class="center"> <?php if ($fh->extension($file_array['name'])) { ?> <input type="checkbox" name="send_file<?php echo $filenum; ?> " class="ccm-file-select-incoming" value="<?php echo $file_array['name']; ?> " /> <?php }
/** * Responsible for taking a particular version of a file and rescanning all its attributes * This will run any type-based import routines, and store those attributes, generate thumbnails, * etc... */ public function refreshAttributes($firstRun = false) { $fh = Loader::helper('file'); $ext = $fh->getExtension($this->fvFilename); $ftl = FileTypeList::getType($ext); $db = Loader::db(); if (!file_exists($this->getPath())) { return File::F_ERROR_FILE_NOT_FOUND; } $size = filesize($this->getPath()); $title = ($firstRun) ? $this->getFilename() : $this->getTitle(); $db->Execute('update FileVersions set fvExtension = ?, fvType = ?, fvTitle = ?, fvSize = ? where fID = ? and fvID = ?', array($ext, $ftl->getGenericType(), $title, $size, $this->getFileID(), $this->getFileVersionID()) ); if (is_object($ftl)) { if ($ftl->getCustomImporter() != false) { Loader::library('file/inspector'); $db->Execute('update FileVersions set fvGenericType = ? where fID = ? and fvID = ?', array($ftl->getGenericType(), $this->getFileID(), $this->getFileVersionID()) ); // we have a custom library script that handles this stuff $cl = $ftl->getCustomInspector(); $cl->inspect($this); } } $this->refreshThumbnails(false); $f = $this->getFile(); $f->refreshCache(); $f->reindex(); }
<?php /** * Routes file types to importers, handlers. * File type icons provided by http://Jordan-Michael.com/ * @package Files * @author Andrew Embler <*****@*****.**> * @copyright Copyright (c) 2003-2009 Concrete5. (http://www.concrete5.org) * @license http://www.concrete5.org/license/ MIT License * */ defined('C5_EXECUTE') or die("Access Denied."); $ft = FileTypeList::getInstance(); $ft->define('jpg,jpeg,jpe', t('JPEG'), FileType::T_IMAGE, 'image', 'image', 'image'); $ft->define('gif', t('GIF'), FileType::T_IMAGE, 'image', 'image', 'image'); $ft->define('png', t('PNG'), FileType::T_IMAGE, 'image', 'image', 'image'); $ft->define('bmp', t('Windows Bitmap'), FileType::T_IMAGE, 'image'); $ft->define('tif,tiff', t('TIFF'), FileType::T_IMAGE, 'image'); $ft->define('htm,html', t('HTML'), FileType::T_IMAGE); $ft->define('swf', t('Flash'), FileType::T_IMAGE, 'image'); $ft->define('ico', t('Icon'), FileType::T_IMAGE); $ft->define('svg', t('SVG'), FileType::T_IMAGE); $ft->define('asf,wmv', t('Windows Video'), FileType::T_VIDEO, 'video', 'video'); $ft->define('mov,qt', t('Quicktime'), FileType::T_VIDEO, 'video', 'video'); $ft->define('avi', t('AVI'), FileType::T_VIDEO, 'video', 'video'); $ft->define('3gp', t('3GP'), FileType::T_VIDEO, 'video', 'video'); $ft->define('txt', t('Plain Text'), FileType::T_TEXT, false, 'text'); $ft->define('csv', t('CSV'), FileType::T_TEXT, false, 'text'); $ft->define('xml', t('XML'), FileType::T_TEXT); $ft->define('php', t('PHP'), FileType::T_TEXT); $ft->define('doc,docx', t('MS Word'), FileType::T_DOCUMENT);