public static function getByHandle($akHandle) { $ak = CacheLocal::getEntry('file_attribute_key_by_handle', $akHandle); if (is_object($ak)) { return $ak; } else { if ($ak == -1) { return false; } } $ak = -1; $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 = self::getByID($akID); } 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); $ak = static::add($at, $args); } } CacheLocal::set('file_attribute_key_by_handle', $akHandle, $ak); if ($ak === -1) { return false; } return $ak; }
* Setup file cache directories. Has to come after we define services * because we use the file service. * ---------------------------------------------------------------------------- */ $cms->setupFilesystem(); /** * ---------------------------------------------------------------------------- * Registries for theme paths, assets, routes and file types. * ---------------------------------------------------------------------------- */ $asset_list = AssetList::getInstance(); $asset_list->registerMultiple($config->get('app.assets', array())); $asset_list->registerGroupMultiple($config->get('app.asset_groups', array())); Route::registerMultiple($config->get('app.routes')); Route::setThemesByRoutes($config->get('app.theme_paths', array())); $type_list = TypeList::getInstance(); $type_list->defineMultiple($config->get('app.file_types', array())); $type_list->defineImporterAttributeMultiple($config->get('app.importer_attributes', array())); /** * ---------------------------------------------------------------------------- * If we are running through the command line, we don't proceed any further * ---------------------------------------------------------------------------- */ if ($cms->isRunThroughCommandLineInterface()) { return $cms; } /** * ---------------------------------------------------------------------------- * If not through CLI, load up the application/bootstrap/app.php */ include DIR_APPLICATION . '/bootstrap/app.php';
/** * @param \Illuminate\Config\Repository $config */ private function initializeFileTypes(Repository $config) { $type_list = TypeList::getInstance(); $type_list->defineMultiple($config->get('app.file_types', array())); $type_list->defineImporterAttributeMultiple($config->get('app.importer_attributes', array())); }
<th width="10%" valign="middle" class="center theader"> <input type="checkbox" id="check-all-incoming"/> </th> <th width="20%" valign="middle" class="center theader"></th> <th width="45%" valign="middle" class="theader"><?php echo t('Filename'); ?> </th> <th width="25%" valign="middle" class="center theader"><?php echo t('Size'); ?> </th> </tr> <?php foreach ($incoming_contents as $i => $file) { $ft = \Concrete\Core\File\Type\TypeList::getType($file['basename']); ?> <tr> <td width="10%" style="vertical-align: middle" class="center"> <?php if ($fh->extension($file['basename'])) { ?> <input type="checkbox" name="send_file<?php echo $i; ?> " class="ccm-file-select-incoming" value="<?php echo $file['basename']; ?> " /> <?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($rescanThumbnails = true) { $fh = Core::make('helper/file'); $ext = $fh->getExtension($this->fvFilename); $ftl = FileTypeList::getType($ext); $db = Database::get(); $fsr = $this->getFileResource(); if (!$fsr->isFile()) { return Importer::E_FILE_INVALID; } $size = $fsr->getSize(); $this->fvExtension = $ext; $this->fvType = $ftl->getGenericType(); if ($this->fvTitle === null) { $this->fvTitle = $this->getFilename(); } $this->fvSize = $size; if (is_object($ftl)) { if ($ftl->getCustomImporter() != false) { $this->fvGenericType = $ftl->getGenericType(); $cl = $ftl->getCustomInspector(); $cl->inspect($this); } } if ($rescanThumbnails) { $this->rescanThumbnails(); } $this->save(); $f = $this->getFile(); $f->reindex(); }
/** * 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(); $fsr = $this->getFileResource(); if (!$fsr->isFile()) { return Importer::E_FILE_INVALID; } $size = $fsr->getSize(); $title = $firstRun ? $this->getFilename() : $this->getTitle(); $this->fvExtension = $ext; $this->fvType = $ftl->getGenericType(); $this->fvTitle = $title; $this->fvSize = $size; if (is_object($ftl)) { if ($ftl->getCustomImporter() != false) { $this->fvGenericType = $ftl->getGenericType(); $cl = $ftl->getCustomInspector(); $cl->inspect($this); } } $this->save(); $f = $this->getFile(); $f->reindex(); }