function media_file_infos(DmMedia $object) { $infos = array(__('Size') => dmOs::humanizeSize($object->get('size')), __('Type') => $object->get('mime'), __('Created at') => format_date($object->get('created_at'), 'f'), __('Updated at') => format_date($object->get('updated_at'), 'f'), __('Url') => $object->getFullWebPath()); if ($object->isImage()) { $infos = array_merge(array(__('Dimensions') => $object->getDimensions()), $infos); } return $infos; }
public function process(array $assets) { if (empty($assets)) { return array(); } $timer = dmDebug::timerOrNull('dmAssetCompressor::process(' . $this->type . ')'); $this->assets = $assets; $this->cachedAssets = array(); $this->cachedAssetsPaths = array(); $this->cdnAssets = array(); $this->preservedAssets = array(); $this->processedAssets = array(); $this->cacheKeys = array('all' => ''); $this->webDir = sfConfig::get('sf_web_dir'); $this->preProcess(); foreach ($this->assets as $webPath => $options) { if ($this->isOnFilesystem($webPath)) { if (!file_exists($this->webDir . $webPath)) { $this->log('Missing ' . $this->type . ' : ' . $this->webDir . $webPath); $this->cacheKeys['all'] .= $webPath; } elseif ($this->isCachable($webPath, $options)) { $mediaType = isset($options['media']) ? $options['media'] : 'all'; $options['media'] = $mediaType; $this->cachedAssets[$mediaType][$webPath] = $options; if (!isset($this->cacheKeys[$mediaType])) { $this->cacheKeys[$mediaType] = ''; } $this->cacheKeys[$mediaType] .= $webPath . filemtime($this->webDir . $webPath); } else { $this->preservedAssets[$webPath] = $options; } } else { $this->cdnAssets[$webPath] = $options; } } if (!empty($this->cachedAssets)) { $cachedAssetsPaths = array(); foreach ($this->cachedAssets as $mediaType => $cachedAssets) { $this->cacheKeys[$mediaType] = md5($this->processCacheKey($this->cacheKeys[$mediaType])); $cacheWebPath = '/cache/' . $this->type; $cacheDirPath = $this->webDir . $cacheWebPath; $cacheFilePath = $cacheDirPath . '/' . $this->cacheKeys[$mediaType] . '.' . $this->type; $this->filesystem->mkdir($cacheDirPath); if (!file_exists($cacheFilePath)) { $cacheContent = ''; foreach ($cachedAssets as $webPath => $options) { $cacheContent .= $this->processAssetContent(file_get_contents($this->webDir . $webPath), $webPath); $this->cachedAssetsPaths[$cacheWebPath . '/' . $this->cacheKeys[$mediaType] . '.' . $this->type] = $options; } $cacheContent = $this->processCacheContent($cacheContent); file_put_contents($cacheFilePath, $cacheContent); chmod($cacheFilePath, 0666); if ($this->options['gz_compression']) { file_put_contents($cacheFilePath . '.gz', gzencode($cacheContent)); chmod($cacheFilePath . '.gz', 0666); } $message = sprintf('%s : compressed %d assets ( %s )', get_class($this), count($cachedAssets), dmOs::humanizeSize($cacheFilePath)); $this->dispatcher->notify(new sfEvent($this, 'application.log', array($message, 'priority' => sfLogger::INFO))); } else { $this->cachedAssetsPaths[$cacheWebPath . '/' . $this->cacheKeys[$mediaType] . '.' . $this->type] = array('media' => $mediaType); } } $this->processedAssets = array_merge($this->cdnAssets, $this->cachedAssetsPaths, $this->preservedAssets); } else { $this->processedAssets = array_merge($this->cdnAssets, $this->preservedAssets); } $this->postProcess(); $timer && $timer->addTime(); return $this->processedAssets; }
public function describe() { return array('Documents' => $this->luceneIndex->numDocs(), 'Size' => dmOs::humanizeSize($this->getByteSize())); }
protected function renderValue($value) { switch ($this->getType()) { case self::TYPE_BOOL: $response = $value ? 'ON' : 'OFF'; break; case self::TYPE_BYTE: $response = dmOs::humanizeSize($this->realSize($value)); break; default: $response = $value ? $value : '-'; } return $response; }
<?php if (!$object || $object->isNew()) { return; } use_helper('I18N', 'Date', 'DmAdminMedia'); echo _open('div.dm_media_file'); echo _tag('h3.title.none', $object->getFile()); echo _open('div.clearfix'); echo _tag('div.view', $object->isImage() ? _media($object)->size(200, 200) : media_file_image_tag($object)); echo _tag('div.content', _tag('div.infos', definition_list(array(__('Size') => dmOs::humanizeSize($object->getSize()), __('Type') => $object->getType(), __('Created at') => format_date($object->get('created_at'), 'f'), __('Updated at') => format_date($object->get('created_at'), 'f'), __('Url') => $object->getFullWebPath()), '.clearfix.dm_little_dl'))); echo _close('div'); echo _close('div');
<?php use_helper('Date', 'DmMedia'); echo _open('div.dm_media_file'); echo _tag('h1.title.none', $file->file); echo _open('div.clearfix'); echo _tag('div.view', _link('/' . $file->getWebPath())->text($file->isImage() ? _media($file)->size(300, 300) : media_file_image_tag($file))->target('blank')->set('.fancybox')); echo _tag('div.content', _tag('div.infos', definition_list(array(__('Size') => dmOs::humanizeSize($file->size), __('Type') => $file->mime, __('Created at') => format_datetime($file->createdAt), __('Updated at') => format_datetime($file->updatedAt), __('Url') => $file->getFullWebPath()), '.clearfix') . _link($file->getFullWebPath())->text(__('Download'))->target('blank')->set('.block.s16.s16_download')) . get_partial('dmInterface/flash') . _tag('div.form', $form->render('.dm_form.list.little action=dmMediaLibrary/saveFile')) . _tag('div.actions.clearfix', _tag('a.close_dialog.button.fright', __('Close')) . _link('dmMediaLibrary/deleteFile?media_id=' . $file->id)->text(__('Delete'))->set('.button.red.dm_js_confirm.fleft')->title(__('Delete this file')) . (false && $file->isImage() ? _link('dmMediaLibrary/editImage?media_id=' . $file->id)->text(__('Edit image'))->set('.button.edit_image') : ''))); echo _close('div'); echo _close('div');