本文整理汇总了PHP中OOMedia::getMediaByFileName方法的典型用法代码示例。如果您正苦于以下问题:PHP OOMedia::getMediaByFileName方法的具体用法?PHP OOMedia::getMediaByFileName怎么用?PHP OOMedia::getMediaByFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OOMedia
的用法示例。
在下文中一共展示了OOMedia::getMediaByFileName方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fire
/**
* Execute the search for the given SearchCommand
*
* @param SearchCommand $search
* @return SearchResult
*/
public function fire(SearchCommand $search)
{
$search_result = new SearchResult();
$fields = array('filename', 'title');
$s = \rex_sql::factory();
$s->setQuery('SELECT * FROM ' . Watson::getTable('file') . ' LIMIT 0');
$fieldnames = $s->getFieldnames();
foreach ($fieldnames as $fieldname) {
if (substr($fieldname, 0, 4) == 'med_') {
$fields[] = $fieldname;
}
}
$sql_query = ' SELECT filename,
title
FROM ' . Watson::getTable('file') . '
WHERE ' . $search->getSqlWhere($fields) . '
ORDER BY filename';
$results = $this->getDatabaseResults($sql_query);
if (count($results)) {
foreach ($results as $result) {
$title = $result['title'] != '' ? ' (' . Watson::translate('watson_media_title') . ': ' . $result['title'] . ')' : '';
$entry = new SearchResultEntry();
$entry->setValue($result['filename']);
$entry->setDescription(Watson::translate('watson_open_media') . $title);
$entry->setIcon('icon_media.png');
$entry->setUrl('javascript:newPoolWindow(\'' . Watson::getUrl(array('page' => 'mediapool', 'subpage' => 'detail', 'file_name' => $result['filename'])) . '\')');
$m = \OOMedia::getMediaByFileName($result['filename']);
if ($m instanceof \OOMedia) {
if ($m->isImage()) {
$entry->setQuickLookUrl(Watson::getUrl(array('rex_img_type' => 'rex_mediapool_maximized', 'rex_img_file' => $result['filename'])));
}
}
$search_result->addEntry($entry);
}
}
return $search_result;
}
示例2: getMediaByName
/**
* @access public
*/
function getMediaByName($filename)
{
return OOMedia::getMediaByFileName($filename);
}
示例3: rex_deleteCacheMedia
rex_deleteCacheMedia($file_name);
} else {
$warning = $I18N->msg('pool_selectedmedia_error');
}
}
} else {
$warning = $I18N->msg('pool_selectedmedia_error');
}
}
if ($PERMALL && $media_method == 'delete_selectedmedia') {
$selectedmedia = rex_post("selectedmedia", "array");
if (count($selectedmedia) != 0) {
$warning = array();
$info = array();
foreach ($selectedmedia as $file_name) {
$media = OOMedia::getMediaByFileName($file_name);
if ($media) {
if ($PERMALL || $REX['USER']->hasPerm('media[' . $media->getCategoryId() . ']')) {
$uses = $media->isInUse();
if ($uses === false) {
if ($media->delete() !== FALSE) {
$info[] = $I18N->msg('pool_file_deleted');
} else {
$warning[] = $I18N->msg('pool_file_delete_error_1', $file_name);
}
$subpage = "";
} else {
$tmp = '<strong>' . $I18N->msg('pool_file_delete_error_1', $file_name) . ' ' . $I18N->msg('pool_file_delete_error_2') . '</strong><br />';
foreach ($uses as $use) {
$tmp .= '<br />' . $use;
}
示例4: getMedia
/**
* @access public
*/
function getMedia()
{
global $REX;
if ($this->_files === null) {
$this->_files = array();
$id = $this->getId();
$list_path = $REX['INCLUDE_PATH'] . '/generated/files/' . $id . '.mlist';
if (!file_exists($list_path)) {
require_once $REX['INCLUDE_PATH'] . '/functions/function_rex_generate.inc.php';
rex_generateMediaList($id);
}
if (file_exists($list_path)) {
require_once $list_path;
if (isset($REX['MEDIA']['MEDIA_CAT_ID'][$id]) && is_array($REX['MEDIA']['MEDIA_CAT_ID'][$id])) {
foreach ($REX['MEDIA']['MEDIA_CAT_ID'][$id] as $filename) {
$this->_files[] =& OOMedia::getMediaByFileName($filename);
}
}
}
}
return $this->_files;
}
示例5: getImagesHTML
public static function getImagesHTML()
{
global $REX;
$return = [];
/**
* prepare images from MetaInfo
*/
if (self::$curArticle->getValue('art_open_graph_images')) {
$images = explode(',', self::$curArticle->getValue('art_open_graph_images'));
foreach ($images as $image) {
$ogImage = new Image();
$image = \OOMedia::getMediaByFileName($image);
if (false && \rex_addon::isActivated('seo42')) {
$ogImage->setUrl(\seo42::getMediaUrl($image));
} else {
$ogImage->setUrl($REX['SERVER'] . $REX['MEDIA_DIR'] . '/' . $image->getFileName());
}
$ogImage->setType($image->getType());
$ogImage->setWidth($image->getWidth());
$ogImage->setHeigt($image->getHeight());
self::addImage($ogImage);
}
}
/** @var Image $image */
foreach (self::$images as $image) {
$return[] = '<meta property="og:image" content="' . $image->getUrl() . '">';
if ($image->getSecureUrl() || $REX['ADDON']['open_graph']['settings']['https']) {
if (!$image->getSecureUrl()) {
if (strpos($image->getUrl(), $REX['SERVER']) == 0) {
$image->setSecureUrl(str_replace('http://', 'https://', $image->getUrl()));
}
}
if ($image->getSecureUrl()) {
$return[] = '<meta property="og:image:secure_url" content="' . $image->getSecureUrl() . '">';
}
}
if ($image->getWidth()) {
$return[] = '<meta property="og:image:width" content="' . $image->getWidth() . '">';
}
if ($image->getHeigt()) {
$return[] = '<meta property="og:image:height" content="' . $image->getHeigt() . '">';
}
if ($image->getType()) {
$return[] = '<meta property="og:image:type" content="' . $image->getType() . '">';
}
}
return implode("\n\t", $return) . "\n\t";
}
示例6: getFileMedia
function getFileMedia()
{
return OOMedia::getMediaByFileName($this->_file);
}
示例7: delete
/**
* @access public
* @return Returns <code>true</code> on success or <code>false</code> on error
*/
function delete($filename = null)
{
global $REX;
if ($filename != null) {
$OOMed = OOMedia::getMediaByFileName($filename);
if ($OOMed) {
return $OOMed->delete();
}
} else {
$qry = 'DELETE FROM ' . $this->_getTableName() . ' WHERE file_id = ' . $this->getId() . ' LIMIT 1';
$sql = new rex_sql();
$sql->setQuery($qry);
if ($this->fileExists()) {
unlink($REX['MEDIAFOLDER'] . DIRECTORY_SEPARATOR . $this->getFileName());
}
return $sql->getError();
}
return false;
}
示例8:
/**
* @access public
* @see #getMediaByFileName
*/
function &searchMediaByFileName($name)
{
return OOMedia::getMediaByFileName($name);
}
示例9: getFileMedia
/**
* Accessor Method:
* returns the name of the article
* @deprecated 17.09.2007
*/
function getFileMedia()
{
return OOMedia::getMediaByFileName($this->getValue('art_file'));
}
示例10: getImageTag
public static function getImageTag($imageFile, $imageType = '', $width = 0, $height = 0)
{
$media = OOMedia::getMediaByFileName($imageFile);
// make sure media object is valid
if (OOMedia::isValid($media)) {
$mediaWidth = $media->getWidth();
$mediaHeight = $media->getHeight();
$altAttribute = $media->getTitle();
} else {
$mediaWidth = '';
$mediaHeight = '';
$altAttribute = '';
}
// image width
if ($width == 0) {
$imgWidth = $mediaWidth;
} else {
$imgWidth = $width;
}
// image height
if ($height == 0) {
$imgHeight = $mediaHeight;
} else {
$imgHeight = $height;
}
// get url
if ($imageType == '') {
$url = self::getMediaFile($imageFile);
} else {
$url = self::getImageManagerFile($imageFile, $imageType);
}
return '<img src="' . $url . '" width="' . $imgWidth . '" height="' . $imgHeight . '" alt="' . $altAttribute . '" />';
}
示例11: syncData
public static function syncData()
{
global $REX, $I18N;
// error reporting
if (HR4YOU_SYNC_DEBUG_MODE) {
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
} else {
ini_set('display_startup_errors', 0);
ini_set('display_errors', 0);
error_reporting(0);
}
// necessary stuff so mediapool function can work properly in frontend
$REX['USER'] = new rex_fe_user();
$I18N = rex_create_lang($REX['LANG']);
include_once $REX['INCLUDE_PATH'] . '/functions/function_rex_generate.inc.php';
include_once $REX['INCLUDE_PATH'] . '/functions/function_rex_mediapool.inc.php';
// init logger
$logFile = HR4YOU_SYNC_LOG_FILE_PATH;
$log = KLogger::instance($logFile, KLogger::INFO);
$phpLogErrors = ini_get('log_errors');
$phperrorLog = ini_get('error_log');
ini_set('log_errors', 1);
ini_set('error_log', $log->getLogFilePath());
$log->logInfo('======================================== START HR4YOU SYNC ========================================');
$context = stream_context_create(array('http' => array('header' => 'Accept: application/xml')));
$xmlUrl = $REX['ADDON']['hr4you_sync']['settings']['xml_url'];
$defaultClangId = $REX['ADDON']['hr4you_sync']['settings']['default_clang_id'];
$defaultArticleId = $REX['ADDON']['hr4you_sync']['settings']['default_article_id'];
$defaultMediaCategoryId = $REX['ADDON']['hr4you_sync']['settings']['default_media_category_id'];
$defaultJobCategoryId = $REX['ADDON']['hr4you_sync']['settings']['default_job_category_id'];
$xmlString = file_get_contents($xmlUrl, false, $context);
$jobs = new SimpleXMLElement($xmlString);
// remove all previously synced jobs and media files
$log->logInfo('>> [INF] remove all previously synced jobs and media files');
$sql = rex_sql::factory();
$sql->setDebug(HR4YOU_SYNC_DEBUG_MODE);
rex_hr4you_sync_utils::logQuery($log, $sql, "SELECT * FROM `" . $REX['TABLE_PREFIX'] . "d2u_stellenmarkt_stellen` WHERE hr4you_jobid > 0 ORDER BY stellen_id ASC");
for ($i = 0; $i < $sql->getRows(); $i++) {
$sql2 = rex_sql::factory();
$sql2->setDebug(HR4YOU_SYNC_DEBUG_MODE);
rex_hr4you_sync_utils::logQuery($log, $sql2, 'DELETE FROM `' . $REX['TABLE_PREFIX'] . 'd2u_stellenmarkt_stellen` WHERE stellen_id = ' . $sql->getValue('stellen_id'));
rex_hr4you_sync_utils::logQuery($log, $sql2, 'DELETE FROM `' . $REX['TABLE_PREFIX'] . 'd2u_stellenmarkt_stellen_lang` WHERE stellen_id = ' . $sql->getValue('stellen_id'));
// delete media
$log->logInfo('>> [INF] delete media: ' . $sql->getValue('bild'));
$media = OOMedia::getMediaByFileName($sql->getValue('bild'));
if (is_object($media)) {
$mediaInUse = $media->isInUse();
if ($mediaInUse === false) {
if ($media->delete() !== false) {
// success
$log->logInfo('>> [INF] media deleted');
} else {
// failed
$log->logError('>> [ERR] media not deleted');
}
} else {
$log->logInfo('>> [INF] media not deleted because still in use');
}
} else {
$log->logInfo('>> [INF] media does not exist anymore');
}
$sql->next();
}
// add jobs
$log->logInfo('>> [INF] add jobs');
foreach ($jobs->entry as $job) {
$sql = rex_sql::factory();
$sql->setDebug(HR4YOU_SYNC_DEBUG_MODE);
rex_hr4you_sync_utils::logQuery($log, $sql, "SELECT * FROM `" . $REX['TABLE_PREFIX'] . "d2u_stellenmarkt_stellen` WHERE hr4you_jobid = " . $job->jobid);
if ($sql->getRows() < 1) {
// for safety reasons: only addon new job if it does not already exist
// copy media file
$log->logInfo('>> [INF] copy media file');
$pathInfo = pathinfo($job->kopfgrafik_url);
$originalFile = $pathInfo['basename'];
$originalFileWithPath = $REX['MEDIAFOLDER'] . DIRECTORY_SEPARATOR . $originalFile;
$mediaFile = self::rex_mediapool_filename_nosubindex($pathInfo['basename'], false);
$mediaFileWithPath = $REX['MEDIAFOLDER'] . DIRECTORY_SEPARATOR . $mediaFile;
if (!file_exists($mediaFileWithPath)) {
if (copy($job->kopfgrafik_url, $mediaFileWithPath)) {
$log->logInfo('>> [INF] media file sucessfully copied because it does not exist');
}
if (chmod($mediaFileWithPath, $REX['FILEPERM'])) {
$log->logInfo('>> [INF] media file chmod to: ' . $REX['FILEPERM']);
}
$mpSyncReturn = rex_mediapool_syncFile($mediaFile, $defaultMediaCategoryId, $job->kopfgrafik_name);
$log->logInfo('>> [INF] media file synced width return value: ', $mpSyncReturn);
} else {
$log->logInfo('>> [INF] media file already exists');
}
// retrieve id of contact by email address
$log->logInfo('>> [INF] retrieve id of contact by email address');
$sql2 = rex_sql::factory();
$sql2->setDebug(HR4YOU_SYNC_DEBUG_MODE);
rex_hr4you_sync_utils::logQuery($log, $sql2, "SELECT kontakt_id FROM `" . $REX['TABLE_PREFIX'] . "d2u_stellenmarkt_kontakt` WHERE email LIKE '" . $job->ap_email . "'");
if ($sql2->getRows() > 0) {
//contact found
$contactId = $sql2->getValue('kontakt_id');
//.........这里部分代码省略.........
示例12: htmlspecialchars
<?php
$file = htmlspecialchars(rex_request('file', 'string'));
if ($file) {
$ooPic = OOMedia::getMediaByFileName($file);
if (is_object($ooPic)) {
print_r($ooPic);
}
}
示例13: getMediaById
/**
* @access public
* @deprecated 20.02.2010
* Stattdessen getMediaByFileName() nutzen
*/
function getMediaById($id)
{
global $REX;
$id = (int) $id;
if ($id == 0) {
return null;
}
$sql = rex_sql::factory();
// $sql->debugsql = true;
$sql->setQuery('SELECT filename FROM ' . OOMedia::_getTableName() . ' WHERE file_id=' . $id);
if ($sql->getRows() == 1) {
return OOMedia::getMediaByFileName($sql->getValue('filename'));
}
return NULL;
}
示例14: handleUpload
/**
* Returns array('success'=>true) or array('error'=>'error message')
*/
function handleUpload($uploadDirectory, $replaceOldFile = FALSE)
{
global $REX;
if (!is_writable($uploadDirectory)) {
return array('error' => "Fehler: Upload-Verzeichnis hat keine Schreibrechte.");
}
if (!$this->file) {
return array('error' => 'Fehler: Es wurden keine Dateien hochgeladen.');
}
$size = $this->file->getSize();
if ($size == 0) {
return array('error' => 'Fehler: Die Datei ist leer');
}
if ($size > $this->sizeLimit) {
return array('error' => 'Fehler: Die Datei ist zu groß');
}
$pathinfo = pathinfo($this->file->getName());
$filename = $pathinfo['filename'];
//$filename = md5(uniqid());
if (!isset($pathinfo['extension'])) {
$pathinfo['extension'] = '';
}
$ext = $pathinfo['extension'];
if ($this->allowedExtensions && in_array(strtolower($ext), $this->allowedExtensions)) {
$these = implode(', ', $this->allowedExtensions);
return array('error' => 'Fehler: Die Datei hat eine ungültige Endung, verboten sind: ' . $these . '.');
}
if (!$replaceOldFile) {
$final_name = rex_mediapool_filename($filename . '.' . $ext);
}
if ($this->file->save($uploadDirectory . $final_name)) {
rex_mediapool_syncFile($final_name, rex_get('mediaCat', 'int'), '');
rex_set_session('media[rex_file_category]', rex_get('mediaCat', 'int'));
return array('success' => true, 'filename' => '' . $final_name . '', 'mediaCatId' => rex_get('mediaCat', 'int'), 'fileId' => OOMedia::getMediaByFileName($final_name)->getId(), 'originalname' => '' . $filename . '.' . $ext . '', 'timestamp' => time());
} else {
return array('error' => 'Die Datei konnte nicht gespeichert werden.' . 'Der Upload wurde abgebrochen, oder es handelt sich um einen internen Fehler');
}
}