本文整理汇总了PHP中e107::getMedia方法的典型用法代码示例。如果您正苦于以下问题:PHP e107::getMedia方法的具体用法?PHP e107::getMedia怎么用?PHP e107::getMedia使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类e107
的用法示例。
在下文中一共展示了e107::getMedia方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sc_sitebutton
function sc_sitebutton($parm = null)
{
if ($_POST['sitebutton'] && $_POST['ajax_used']) {
$path = e107::getParser()->replaceConstants($_POST['sitebutton']);
} else {
$path = strstr(SITEBUTTON, 'http:') ? SITEBUTTON : e_IMAGE . SITEBUTTON;
}
if ($parm['type'] == 'email' || $parm == 'email') {
$h = !empty($parm['h']) ? $parm['h'] : 100;
$path = e107::getConfig()->get('sitebutton');
$realPath = e107::getParser()->replaceConstants($path);
if (defined('e_MEDIA') && is_writeable(e_MEDIA . "temp/") && ($resized = e107::getMedia()->resizeImage($path, e_MEDIA . "temp/" . basename($realPath), 'h=' . $h))) {
$path = e107::getParser()->createConstants($resized);
}
}
if (!empty($path)) {
return '<a href="' . SITEURL . '" class="sitebutton"><img src="' . $path . '" alt="' . SITENAME . '" /></a>';
}
}
示例2: showImages
function showImages($cat)
{
$mes = e107::getMessage();
$tp = e107::getParser();
$template = e107::getTemplate('gallery');
$sc = e107::getScBatch('gallery', TRUE);
$sc->total = e107::getMedia()->countImages($cat);
$sc->amount = 12;
// TODO Add Pref. amount per page.
$sc->curCat = $cat;
$sc->from = $_GET['frm'] ? intval($_GET['frm']) : 0;
$list = e107::getMedia()->getImages($cat, $sc->from, $sc->amount);
$catname = $tp->toHtml($this->catList[$cat]['media_cat_title'], false, 'defs');
$inner = "";
foreach ($list as $row) {
$sc->setVars($row);
$inner .= $tp->parseTemplate($template['LIST_ITEM'], TRUE);
}
$text = $tp->parseTemplate($template['LIST_START'], TRUE);
$text .= $inner;
$text .= $tp->parseTemplate($template['LIST_END'], TRUE);
e107::getRender()->tablerender("Gallery :: " . $catname, $mes->render() . $text);
}
示例3: showImages
function showImages($cat)
{
$mes = e107::getMessage();
$tp = e107::getParser();
$template = e107::getTemplate('gallery');
$template = array_change_key_case($template);
$sc = e107::getScBatch('gallery', TRUE);
if (defset('BOOTSTRAP') === true || defset('BOOTSTRAP') === 2) {
$template['list_start'] = str_replace('row', 'row-fluid', $template['list_start']);
}
$sc->total = e107::getMedia()->countImages($cat);
$sc->amount = 12;
// TODO Add Pref. amount per page.
$sc->curCat = $cat;
$sc->from = $_GET['frm'] ? intval($_GET['frm']) : 0;
$list = e107::getMedia()->getImages($cat, $sc->from, $sc->amount);
$catname = $tp->toHtml($this->catList[$cat]['media_cat_title'], false, 'defs');
$inner = "";
foreach ($list as $row) {
$sc->setVars($row);
$inner .= $tp->parseTemplate($template['list_item'], TRUE, $sc);
}
$text = $tp->parseTemplate($template['list_start'], TRUE, $sc);
$text .= $inner;
$text .= $tp->parseTemplate($template['list_end'], TRUE, $sc);
e107::getRender()->tablerender(LAN_PLUGIN_GALLERY_TITLE, $mes->render() . $text);
}
示例4: PreImage_Select
function PreImage_Select($formid = 'preimage_selector')
{
global $bbcode_imagedir;
$med = e107::getMedia();
$text = "<!-- Start of PreImage selector -->";
$text .= $med->imageSelect($bbcode_imagedir, $formid);
return $text;
}
示例5: getPath
function getPath($mime)
{
return e107::getMedia()->getPath($mime);
/*
$mes = e107::getMessage();
list($pmime,$tmp) = explode('/',$mime);
if(!vartrue($this->mimePaths[$pmime]))
{
$text = str_replace('[x]',$mime,IMALAN_111);
$mes->add($text, E_MESSAGE_ERROR);
return FALSE;
}
$dir = $this->mimePaths[$pmime].date("Y-m");
if(!is_dir($dir))
{
if(!mkdir($dir, 0755))
{
$text = str_replace('[x]',$dir,IMALAN_112);
$mes->add($text, E_MESSAGE_ERROR);
return FALSE;
};
}
return $dir;*/
}
示例6: processUploadUrl
function processUploadUrl($import = false, $cat = '_common')
{
$fl = e107::getFile();
$mes = e107::getMessage();
if (vartrue($_POST['upload_remote_url'])) {
$fileName = basename($_POST['upload_url']);
if (strpos($fileName, '?') !== false) {
list($fileName, $bla) = explode("?", $fileName);
}
if (!$fl->getRemoteFile($_POST['upload_url'], $fileName, 'import')) {
$mes->addError("There was a problem grabbing the file");
} elseif ($import == true) {
$result = e107::getMedia()->importFile($fileName, $cat);
}
}
}
示例7: init
function init()
{
$effects = array('scrollHorz' => 'slide left', 'scrollVert' => 'slide down', 'fade' => 'fade');
$this->prefs['slideshow_effect']['writeParms'] = $effects;
$this->prefs['slideshow_effect']['readParms'] = $effects;
//
// $transitions = array('sinoidal'=>'sinoidal','spring'=>'spring');
// $this->prefs['slideshow_transition']['writeParms'] = $transitions;
// $this->prefs['slideshow_transition']['readParms'] = $transitions;
$categories = e107::getMedia()->getCategories('gallery');
$cats = array();
foreach ($categories as $k => $var) {
$id = preg_replace("/[^0-9]/", '', $k);
$cats[$id] = $var['media_cat_title'];
}
$this->prefs['slideshow_category']['writeParms'] = $cats;
$this->prefs['slideshow_category']['readParms'] = $cats;
$mes = e107::getMessage();
$message = "<b>Gallery</b> is active. Simply import and assign images to the gallery categories using the <a href='" . e_ADMIN . "image.php'>Media Manager</a>";
$mes->addInfo($message);
}
示例8: loadSubmitted
function loadSubmitted($id)
{
$sql = e107::getDb();
$tp = e107::getParser();
if ($sql->select("submitnews", "*", "submitnews_id=" . intval($id))) {
$row = $sql->fetch();
$data['news_title'] = $tp->dataFilter($row['submitnews_title']);
$data['news_body'] = $row['submitnews_item'];
$data['news_category'] = intval($row['submitnews_category']);
$data['news_body'] .= "\n[[b]" . NWSLAN_49 . " {$row['submitnews_name']}[/b]]";
$thumbs = array();
if ($row['submitnews_file']) {
$files = explode(",", $row['submitnews_file']);
foreach ($files as $f) {
if ($bbpath = e107::getMedia()->importFile($f, 'news')) {
$thumbs[] = $bbpath;
// $data['news_body'] .= "\n\n[img]".$bbpath."[/img]";
}
}
}
$data['news_thumbnail'] = implode(",", $thumbs);
$data['submitted_id'] = $id;
foreach ($data as $k => $v) {
$this->getModel()->setData($k, $v);
// Override Table data.
}
}
}
示例9: sc_gallery_slides
/**
* All possible parameters
* {GALLERY_SLIDES=4|limit=16&template=MY_SLIDESHOW_SLIDE_ITEM}
* first parameter is always number of slides, default is 3
* limit - (optional) total limit of pcitures to be shown
* template - (optional) template - name of template to be used for parsing the slideshow item
*/
function sc_gallery_slides($parm)
{
$tp = e107::getParser();
$this->slideMode = TRUE;
$parms = eHelper::scDualParams($parm);
$amount = $parms[1] ? intval($parms[1]) : 3;
// vartrue(e107::getPlugPref('gallery','slideshow_perslide'),3);
$parms = $parms[2];
$limit = (int) vartrue($parms['limit'], 16);
$list = e107::getMedia()->getImages('gallery_' . $this->sliderCat . '|gallery_image_' . $this->sliderCat, 0, $limit);
$tmpl = e107::getTemplate('gallery', 'gallery');
$tmpl = array_change_key_case($tmpl);
// change template key to lowercase (BC fix)
$tmpl_key = vartrue($parms['template'], 'slideshow_slide_item');
$item_template = $tmpl[$tmpl_key];
// e107::getTemplate('gallery','gallery', vartrue($parms['template'], 'SLIDESHOW_SLIDE_ITEM'));
$catList = e107::getMedia()->getCategories('gallery');
$cat = $catList['gallery_' . $this->sliderCat];
$count = 1;
foreach ($list as $row) {
$this->setVars($row)->addVars($cat);
$inner .= $count == 1 ? "\n\n<!-- SLIDE " . $count . " -->\n<div class='slide' id='gallery-item-" . $this->slideCount . "'>\n" : "";
$inner .= "\n\t" . $tp->parseTemplate($item_template, TRUE) . "\n";
$inner .= $count == $amount ? "\n</div>\n\n" : "";
if ($count == $amount) {
$count = 1;
$this->slideCount++;
} else {
$count++;
}
}
$inner .= $count != 1 ? "</div><!-- END SLIDES -->" : "";
return $inner;
}
示例10: loadSubmitted
function loadSubmitted($id)
{
$sql = e107::getDb();
$tp = e107::getParser();
if ($sql->db_Select("submitnews", "*", "submitnews_id=" . intval($id), TRUE)) {
//list($id, $submitnews_name, $submitnews_email, $_POST['news_title'], $submitnews_category, $_POST['news_body'], $submitnews_datestamp, $submitnews_ip, $submitnews_auth, $submitnews_file) = $sql->db_Fetch();
$row = $sql->db_Fetch();
$_POST['news_title'] = $row['submitnews_title'];
$_POST['news_body'] = $row['submitnews_item'];
$_POST['cat_id'] = $row['submitnews_category'];
if (defsettrue('e_WYSIWYG')) {
if (substr($_POST['news_body'], -7, 7) == '[/html]') {
$_POST['news_body'] = substr($_POST['news_body'], 0, -7);
}
if (substr($_POST['news_body'], 0, 6) == '[html]') {
$_POST['news_body'] = substr($_POST['news_body'], 6);
}
$_POST['news_body'] .= "<br /><b>" . NWSLAN_49 . " {$row['submitnews_name']}</b>";
$_POST['news_body'] .= $row['submitnews_file'] ? "<br /><br /><img src='{e_NEWSIMAGE}{$row['submitnews_file']}' class='f-right' />" : '';
} else {
$_POST['news_body'] .= "\n[[b]" . NWSLAN_49 . " {$row['submitnews_name']}[/b]]";
if ($row['submitnews_file']) {
$files = explode(",", $row['submitnews_file']);
foreach ($files as $f) {
if ($bbpath = e107::getMedia()->importFile($f, 'news')) {
$_POST['news_body'] .= "\n\n[img]" . $bbpath . "[/img]";
}
}
}
}
$_POST['data'] = $tp->dataFilter($_POST['data']);
// Filter any nasties
$_POST['news_title'] = $tp->dataFilter($_POST['news_title']);
}
}
示例11: saveImages
/** Download and Import remote images and update body text with local relative-links. eg. {e_MEDIA}
* @param returns text-body with remote links replaced with local ones for the images downloaded.
*/
function saveImages($body, $cat = 'news')
{
$mes = e107::getMessage();
$med = e107::getMedia();
$tp = e107::getParser();
$search = array();
$replace = array();
// echo htmlentities($body);
preg_match_all("/(((http:\\/\\/www)|(http:\\/\\/)|(www))[-a-zA-Z0-9@:%_\\+.~#?&\\/\\/=]+)\\.(jpg|jpeg|gif|png|svg)/im", $body, $matches);
$fl = e107::getFile();
if (is_array($matches[0])) {
$relPath = 'images/' . md5($this->feedUrl);
if (!is_dir(e_MEDIA . $relPath)) {
mkdir(e_MEDIA . $relPath, '0755');
}
foreach ($matches[0] as $link) {
if (file_exists($relPath . "/" . $filename)) {
continue;
}
$filename = basename($link);
$fl->getRemoteFile($link, $relPath . "/" . $filename);
$search[] = $link;
$replace[] = $tp->createConstants(e_MEDIA . $relPath . "/" . $filename, 1);
}
}
if (count($search)) {
$med->import($cat, e_MEDIA . $relPath);
}
return str_replace($search, $replace, $body);
}
示例12: mediaSelectUpload
function mediaSelectUpload($type = 'image')
{
$frm = e107::getForm();
$bbcodeMode = $this->getQuery('bbcode') == 'img' ? 'bbcode=img' : FALSE;
$text = "\n\t\t\t<div class='admintabs' id='tab-container'>\n\t\t\t<ul class='e-tabs' id='core-emote-tabs'>\n\t\t\t\t<li id='tab-select'><a href='#core-media-select'>Choose from Library</a></li>\n\t\t\t\t<li id='tab-upload'><a href='#core-media-upload'>Upload a File</a></li>";
if ($bbcodeMode) {
$text .= "<li id='tab-style'><a href='#core-media-style'>Appearance</a></li>\n";
}
if ($_GET['from']) {
$bbcodeMode .= "&from=" . intval($_GET['from']);
}
$text .= "\n\t\t\t</ul>\n\t\t\t<fieldset id='core-media-select'>\n\t\t\t<legend>Library</legend>\n\t\t\t<table class='table adminform'>\n\t\t\t<tbody><tr><td>\n\t\t\t";
$tag = $bbcodeMode ? "" : $this->getQuery('tagid');
if ($type == 'file') {
$this->perPage = 0;
$this->getTreeModel()->setParam('db_query', $this->_modifyListQry(false, false, false, false, $this->listQry))->load();
$text .= $this->getUI()->getList();
} else {
$text .= e107::getMedia()->mediaSelect($this->getQuery('for'), $this->getQuery('tagid'), $bbcodeMode);
// eg. news, news-thumbnail
}
$text .= "\n\t\t\t</td></tr>\n\t\t\t</tbody></table>\n\t\t\t</fieldset>\n\t\t\t\n\t\t\t<fieldset id='core-media-upload'>\n\t\t\t<legend>Upload</legend>";
$this->fields['media_category']['readonly'] = TRUE;
$this->fields['media_url']['noedit'] = TRUE;
$this->fields['media_userclass']['noedit'] = TRUE;
$text .= $this->uploadPage();
// To test upload script with plupload
// $text .= $this->CreatePage(); // comment me out to test plupload
$text .= "\t\n\t\t\t</fieldset>";
/* In BBCODE-Mode this dialog rerturns an [img] bbcode to the 'tagid' container with the appropriate parms generated.
* eg. [img style=float:left;margin-right:3px]{e_MEDIA_IMAGE}someimage.jpg[/img]
* Then the dialog may be used as a bbcode img popup and within TinyMce also.
*
*/
if ($bbcodeMode) {
$text .= "<fieldset id='core-media-style'>\n\t\t\t\t<legend>Appearance</legend>\n\t\t\t\t<table class='table adminform'>\n\t\t\t\t<colgroup>\n\t\t\t\t\t<col class='col-label' />\n\t\t\t\t\t<col class='col-control' />\n\t\t\t\t</colgroup>\n\t\t\t\t<tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Dimensions: </td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t<input type='text' class='e-media-attribute' id='width' name='width' size='4' style='width:50px' value='' /> px\n\t\t\t\t\t\t X <input type='text' class='e-media-attribute' id='height' name='height' size='4' style='width:50px' value='' /> px\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Text flow: </td>\n\t\t\t\t\t\t<td>" . $frm->selectbox('float', array('default' => 'Default', 'left' => 'Right', 'right' => "Left")) . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Margin-Left: </td>\n\t\t\t\t\t\t<td><input class='e-media-attribute' type='text' id='margin-left' name='margin_left' value='' /></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Margin-Right: </td>\n\t\t\t\t\t\t<td><input class='e-media-attribute' type='text' id='margin-right' name='margin_right' value='' /></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Margin-Top: </td>\n\t\t\t\t\t\t<td><input class='e-media-attribute' type='text' id='margin-top' name='margin_top' value='' /></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Margin-Bottom: </td>\n\t\t\t\t\t\t<td><input class='e-media-attribute' type='text' id='margin-bottom' name='margin_bottom' value='' /></td>\n\t\t\t\t\t</tr>\n\t\t\n\t\t\t</tbody></table>\n\t\t\t<table><tr><td>Preview<br /></td></tr>\n\t\t\t<tr><td style='text-align:center'>\n\t\t\t<img id='preview' src='" . e_IMAGE_ABS . "generic/blank.gif' style='border:1px solid silver; min-width:220px; min-height:180px;' />\n\t\t\t\n\t\t\t</td></tr></table>\n\t\t\t</fieldset>";
}
$text .= "</div>";
// For BBCODE mode. //TODO image-float.
if ($bbcodeMode) {
$text .= "<div style='text-align:right;padding:5px'>\n\t\t\t\n\t\t\t<button type='submit' class='btn btn-success submit e-dialog-save e-dialog-close' data-target='" . $this->getQuery('tagid') . "' name='save_image' value='Save it' >\n\t\t\t<span>Save</span>\n\t\t\t</button>\n\t\t\t<button type='submit' class='btn submit e-dialog-close' name='cancel_image' value='Cancel' >\n\t\t\t<span>Cancel</span>\n\t\t\t</button>\n\t\t\t</div>";
// TODO to eventually be hidden.
$text .= "bbcode: <input title='bbcode' type='text' readonly='readonly' style='border:0px; width:700px' id='bbcode_holder' name='bbcode_holder' value='' />\n\t\t\t<input title='html' type='hidden' style='width:800px' id='html_holder' name='html_holder' value='' />\n\t\t\t<input title='src' type='hidden' style='width:600px' id='src' name='src' value='' />\n\t\t\t<input title='path' type='hidden' style='width:600px' id='path' name='path' value='' />\t\t\t\t\n\t\t\t";
}
return $text;
}
示例13: saveImages
/** Download and Import remote images and update body text with local relative-links. eg. {e_MEDIA}
* @param returns text-body with remote links replaced with local ones for the images downloaded.
*/
function saveImages($body, $cat = 'news')
{
$mes = e107::getMessage();
$med = e107::getMedia();
$tp = e107::getParser();
$search = array();
$replace = array();
$fl = e107::getFile();
$result = $tp->getTags($body, 'img');
if ($result) {
$relPath = 'images/' . substr(md5($this->feedUrl), 0, 10);
if (!is_dir(e_MEDIA . $relPath)) {
mkdir(e_MEDIA . $relPath, '0755');
}
foreach ($result['img'] as $att) {
$filename = basename($att['src']);
if (file_exists(e_MEDIA . $relPath . "/" . $filename)) {
continue;
}
$fl->getRemoteFile($att['src'], $relPath . "/" . $filename, 'media');
if (filesize(e_MEDIA . $relPath . "/" . $filename) > 0) {
$search[] = $att['src'];
$replace[] = $tp->createConstants(e_MEDIA . $relPath . "/" . $filename, 1);
}
}
} else {
$mes->addDebug("No Images Found: " . print_a($result, true));
}
if (count($search)) {
$mes->addDebug("Found: " . print_a($search, true));
$mes->addDebug("Replaced: " . print_a($replace, true));
$med->import($cat, e_MEDIA . $relPath);
}
return str_replace($search, $replace, $body);
// echo htmlentities($body);
preg_match_all("/(((http:\\/\\/www)|(http:\\/\\/)|(www))[-a-zA-Z0-9@:%_\\+.~#?&\\/\\/=]+)\\.(jpg|jpeg|gif|png|svg)/im", $body, $matches);
$fl = e107::getFile();
if (is_array($matches[0])) {
$relPath = 'images/' . substr(md5($this->feedUrl), 0, 10);
if (!is_dir(e_MEDIA . $relPath)) {
mkdir(e_MEDIA . $relPath, '0755');
}
foreach ($matches[0] as $link) {
$filename = basename($link);
if (file_exists($relPath . "/" . $filename)) {
continue;
}
$fl->getRemoteFile($link, $relPath . "/" . $filename, 'media');
$search[] = $link;
$replace[] = $tp->createConstants(e_MEDIA . $relPath . "/" . $filename, 1);
}
}
if (count($search)) {
$med->import($cat, e_MEDIA . $relPath);
}
return str_replace($search, $replace, $body);
}
示例14: liboptions
function liboptions($arr, $prefix = '', $sel = '')
{
$buf = "";
$array = e107::getMedia()->getCategories();
foreach ($array as $value => $text) {
$selected = $value == $_POST['lib'] ? "selected='selected'" : "";
$buf .= "<option value='" . $value . "' {$selected}>" . $text . '</option>' . "\n";
}
return $buf;
// $buf = '';
// foreach($arr as $lib)
// {
// $buf .= '<option value="'.$lib['value'].'"'.(($lib['value'] == $sel)?' selected="selected"':'').'>'.$prefix.$lib['text'].'</option>'."\n";
// }
// return $buf;
}
示例15: processUploadUrl
function processUploadUrl($import = false, $cat = '_common')
{
$fl = e107::getFile();
$mes = e107::getMessage();
if (vartrue($_POST['upload_remote_url'])) {
$fileName = basename($_POST['upload_url']);
if (strpos($fileName, '?') !== false) {
list($fileName, $bla) = explode("?", $fileName);
}
// remove script extensions.
if (substr($fileName, -4) == ".php" || substr($fileName, -4) == ".htm" || substr($fileName, -5) == ".html" || substr($fileName, -4) == ".asp") {
$fileName = empty($_POST['upload_caption']) ? str_replace(array(".php", ".html", ".asp", ".htm"), '', $fileName) . "_" . time() : eHelper::dasherize(strtolower($_POST['upload_caption']));
}
if (!$fl->getRemoteFile($_POST['upload_url'], $fileName, 'import')) {
$mes->addError("There was a problem grabbing the file");
} elseif ($import == true) {
$data = array('media_caption' => e107::getParser()->filter($_POST['upload_caption'], 'str'));
$result = e107::getMedia()->importFile($fileName, $cat, null, $data);
}
}
}