本文整理汇总了PHP中get_resource_path函数的典型用法代码示例。如果您正苦于以下问题:PHP get_resource_path函数的具体用法?PHP get_resource_path怎么用?PHP get_resource_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_resource_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mia_results
function mia_results($results){
global $date_fields,$dont_pull;
$getfields = sql_query("SELECT ref,title FROM resource_type_field");
$fieldnames = array();
for($g=0; $g<count($getfields); $g++){
$fieldnames[$getfields[$g]['ref']]=$getfields[$g]['title'];
}
for($i = 0; $i < count($results); $i++) {
$ref = $results[$i]['ref'];
if(isset($results[$i]['ref'])){
$query=sql_query("SELECT * FROM resource_data WHERE resource = $ref AND value != '' AND value!='NULL' AND value != ','");
for($q=0; $q<count($query); $q++){
if($query[$q]['value'] != "," && $query[$q]['value'] !="" && array_key_exists($query[$q]['resource_type_field'],$fieldnames)){
if(substr($query[$q]['value'],0,1)==","){
$results[$i][$fieldnames[$query[$q]['resource_type_field']]]=substr($query[$q]['value'],1);
}else{
$results[$i][$fieldnames[$query[$q]['resource_type_field']]]=$query[$q]['value'];
}
}
}
$access = get_resource_access($results[$i]);
$filepath = get_resource_path($results[$i]['ref'], TRUE, '', FALSE, $results[$i]['file_extension'], -1, 1, FALSE, '', -1);
$original_link = get_resource_path($results[$i]['ref'], FALSE, '', FALSE, $results[$i]['file_extension'], -1, 1, FALSE, '', -1);
if(file_exists($filepath)) {
$results[$i]['original_link'] = $original_link;
} else {
$results[$i]['original_link'] = 'No original link available.';
}
// Get the size of the original file:
/* $original_size = get_original_imagesize($results[$i]['ref'], $filepath, $results[$i]['file_extension']);
$original_size = formatfilesize($original_size[0]);
$original_size = str_replace(' ', ' ', $original_size);
$results[$i]['original_size'] = $original_size;*/
foreach($results[$i] as $k => $v){
if($v == "" || $v ==","){
unset($results[$i][$k]);
}
if($k == "created_by"){
$user = get_user($v);
$results[$i][$k]=$user["fullname"];
}
if(in_array($k,$date_fields)){
$unix = strtotime($v);
$datetime = date('y-m-d',$unix);
$results[$i][$k] = $datetime;
}
if($k == "resource_type" && is_numeric($v)){
$results[$i][$k]=get_resource_type_name($v);
}
//need to convert type to string here
if(in_array($k,$dont_pull)){
unset($results[$i][$k]);
}
}
}
// var_dump($results);exit();
return $results;
}
}
示例2: savetoelastic
function savetoelastic($ref){
global $baseurl, $pagename;
if($pagename != "upload2"){
//error_log($ref);
$results=array();
$results[] = get_resource_data($ref,false);
$resourcetype=get_resource_type_name($results[0]['resource_type']);
if($resourcetype != "Audio"){
$thethumb = $baseurl.str_replace("/var/www/include/..","",get_resource_path($ref,true,"thm",false,"jpg"));
if(!file_exists($thethumb)){
$thethumb = $results[0]["thumbnail"] = $baseurl."/gfx/no_preview/extension/".$results[0]['file_extension'].".png";
}
$results[0]["thumbnail"]=$thethumb;
}else{
$results[0]["thumbnail"] = $baseurl."/gfx/no_preview/extension/".$results[0]['file_extension'].".png";
}
if($resourcetype == "Audio"){
$results[0]["preview"]=$baseurl.str_replace("/var/www/include/..","",get_resource_path($ref, true, "", false, "mp3"));
}else if($resourcetype == "Video"){
$results[0]["preview"]=$baseurl.str_replace("/var/www/include/..","",get_resource_path($ref, true, "pre", false, "mp4"));
}
$results = mia_results($results);
$results=json_encode($results[0]);
$query = push_RStoElastic($resourcetype,$ref,$results);
if($query == false){
//failed to connect to elastic search
createcron($attempts=1, $ref);
}else{
// var_dump($query);exit();
}
return;
}
}
示例3: HookResourceconnectViewResourceactions_anonymous
function HookResourceconnectViewResourceactions_anonymous()
{
if (getval("resourceconnect_source", "") == "") {
return false;
}
# Not a ResourceConnect result set.
global $lang, $title_field, $ref, $baseurl, $search, $offset, $scramble_key, $language, $resource;
# Generate access key
$access_key = md5("resourceconnect" . $scramble_key);
# Formulate resource link (for collections bar)
$view_url = $baseurl . "/pages/view.php?ref=" . $ref . "&k=" . substr(md5($access_key . $ref), 0, 10) . "&language_set=" . urlencode($language) . "&resourceconnect_source=" . urlencode($baseurl);
# Add to collections link.
$url = getval("resourceconnect_source", "") . "/plugins/resourceconnect/pages/add_collection.php?nc=" . time();
$url .= "&title=" . urlencode(get_data_by_field($ref, $title_field));
$url .= "&url=" . urlencode($view_url);
# Add back URL
$url .= "&back=" . urlencode($baseurl . "/pages/view.php?" . $_SERVER["QUERY_STRING"]);
# Add images
if ($resource["has_image"] == 1) {
$url .= "&thumb=" . urlencode(get_resource_path($ref, false, "col", false, "jpg"));
} else {
$url .= "&thumb=" . urlencode($baseurl . "/gfx/" . get_nopreview_icon($resource["resource_type"], $resource["file_extension"], true));
}
?>
<li><a target="collections" href="<?php
echo $url;
?>
">> <?php
echo $lang["action-addtocollection"];
?>
</a></li>
<?php
}
示例4: HookFormat_chooserAllGetdownloadurl
function HookFormat_chooserAllGetdownloadurl($ref, $size, $ext, $page = 1, $alternative = -1)
{
global $baseurl_short;
$path = get_resource_path($ref, true, $size, false, $ext, -1, $page, $size == "scr" && checkperm("w") && $alternative == -1, '', $alternative);
if (file_exists($path)) {
return false;
}
return $baseurl_short . 'plugins/format_chooser/pages/convert.php?ref=' . $ref . '&size=' . $size . '&ext=' . $ext . '&page=' . $page . '&alt=' . $alternative;
}
示例5: getPreviewURLForType
function getPreviewURLForType($resource, $type, $alternative = -1)
{
global $use_watermark;
$path = get_resource_path($resource['ref'], true, $type, false, $resource["preview_extension"], -1, 1, $use_watermark, "", $alternative);
if (!file_exists($path)) {
return false;
}
return get_resource_path($resource['ref'], false, $type, false, $resource["preview_extension"], -1, 1, $use_watermark, "", $alternative);
}
示例6: HookEmbedvideoViewAfterresourceactions
function HookEmbedvideoViewAfterresourceactions()
{
global $embedvideo_resourcetype, $ffmpeg_preview_extension, $resource, $ref, $ffmpeg_preview_max_width, $ffmpeg_preview_max_height, $userfixedtheme, $baseurl, $lang;
if ($resource["resource_type"] != $embedvideo_resourcetype) {
return false;
}
# Not the right type.
?>
<?php
# FLV player - plays the FLV file created to preview video resources.
if (file_exists(get_resource_path($ref, true, "pre", false, $ffmpeg_preview_extension))) {
$flashpath = get_resource_path($ref, false, "pre", false, $ffmpeg_preview_extension, -1, 1, false, "", -1, false);
} else {
$flashpath = get_resource_path($ref, false, "", false, $ffmpeg_preview_extension, -1, 1, false, "", -1, false);
}
$flashpath = urlencode($flashpath);
$thumb = get_resource_path($ref, false, "pre", false, "jpg");
$thumb = urlencode($thumb);
# Choose a colour based on the theme.
# This is quite hacky, and ideally of course this would be CSS based, but the FLV player requires that the colour
# is passed as a parameter.
# The default is a neutral grey which should be acceptable for most user generated themes.
$theme = isset($userfixedtheme) && $userfixedtheme != "" ? $userfixedtheme : getval("colourcss", "greyblu");
$colour = "505050";
if ($theme == "greyblu") {
$colour = "446693";
}
?>
<li><a href="#" onClick="
if (document.getElementById('embedvideo').style.display=='block') {document.getElementById('embedvideo').style.display='none';} else {document.getElementById('embedvideo').style.display='block';}
if (document.getElementById('embedvideo2').style.display=='block') {document.getElementById('embedvideo2').style.display='none';} else {document.getElementById('embedvideo2').style.display='block';}
return false;">> <?php
echo $lang["embed"];
?>
</a></li>
<p id="embedvideo2" style="display:none;float:left;padding:10px 0 3px 0;"><?php
echo $lang["embed_help"];
?>
</p>
<textarea id="embedvideo" style="width:335px;height:200px;display:none;"><?php
if (!hook("replaceembedcode")) {
echo htmlspecialchars('
<object type="application/x-shockwave-flash" data="' . $baseurl . '/lib/flashplayer/player_flv_maxi.swf" width="' . $ffmpeg_preview_max_width . '" height="' . $ffmpeg_preview_max_height . '" class="Picture"><param name="allowFullScreen" value="true" /><param name="movie" value="' . $baseurl . '/lib/flashplayer/player_flv_maxi.swf" /><param name="FlashVars" value="flv=' . $flashpath . '&width=' . $ffmpeg_preview_max_width . '&height=' . $ffmpeg_preview_max_height . '&margin=0&buffer=10&showvolume=1&volume=200&showtime=1&autoplay=1&autoload=0&showfullscreen=1&showstop=1&playercolor=' . $colour . '&startimage=' . $thumb . '" /></object>
');
}
// end hook replaceembedcode
?>
</textarea>
<?php
return true;
}
示例7: HookResourceofthedayHomeReplaceslideshow
function HookResourceofthedayHomeReplaceslideshow()
{
include_once dirname(__FILE__) . "/../inc/rotd_functions.php";
global $baseurl, $view_title_field;
$rotd = get_resource_of_the_day();
if ($rotd === false) {
return false;
}
# No ROTD, return false to disable hook and display standard slide show.
# Get preview width
$sizes = get_image_sizes($rotd, true);
foreach ($sizes as $size) {
if ($size["id"] == "pre") {
$width = $size["width"];
break;
}
}
# Fetch title
$title = sql_value("select value from resource_data where resource='{$rotd}' and resource_type_field={$view_title_field}", "");
# Fetch caption
$caption = sql_value("select value from resource_data where resource='{$rotd}' and resource_type_field=18", "");
# Show resource!
$pre = get_resource_path($rotd, false, "pre", false, "jpg");
?>
<div class="HomePicturePanel RecordPanel" style="width: <?php
echo $width;
?>
px; padding-left: 3px;">
<a onClick="return CentralSpaceLoad(this,true);" href="<?php
echo $baseurl;
?>
/pages/view.php?ref=<?php
echo $rotd;
?>
"><img class="ImageBorder" style="margin-bottom: 10px;" src="<?php
echo $pre;
?>
" /></a>
<br />
<h2 ><?php
echo i18n_get_translated(htmlspecialchars($title));
?>
</h2>
<?php
echo $caption;
?>
</div>
<?php
return true;
}
示例8: HookImage_textPreviewPreviewimage
function HookImage_textPreviewPreviewimage()
{
global $ext, $resource, $image_text_restypes, $baseurl, $ref, $url, $use_watermark, $k, $alternative, $image_text_filetypes, $page;
# Return if not configured for this resource type, no image or using watermark
if (!in_array($resource['resource_type'], $image_text_restypes) || $resource["has_image"] != 1 || !in_array(strtoupper($ext), $image_text_filetypes) || $use_watermark) {
return false;
}
$path = get_resource_path($ref, true, "scr", false, $ext, -1, $page, "", "", $alternative);
if (!file_exists($path)) {
$size = "pre";
} else {
$size = "scr";
}
$url = $baseurl . "/pages/download.php" . "?ref=" . urlencode($ref) . "&size=" . urlencode($size) . "&ext=" . urlencode($ext) . "&k=" . urlencode($k) . "&alternative=" . urlencode($alternative) . "&noattach=true";
return false;
}
示例9: generate_transform_preview
function generate_transform_preview($ref){
global $storagedir;
global $imagemagick_path;
global $imversion;
if (!isset($imversion)){
$imversion = get_imagemagick_version();
}
$tmpdir = get_temp_dir();
// get imagemagick path
$command = get_utility_path("im-convert");
if ($command==false) {exit("Could not find ImageMagick 'convert' utility.");}
$orig_ext = sql_value("select file_extension value from resource where ref = '$ref'",'');
$originalpath= get_resource_path($ref,true,'',false,$orig_ext);
# Since this check is in get_temp_dir() omit: if(!is_dir($storagedir."/tmp")){mkdir($storagedir."/tmp",0777);}
if(!is_dir(get_temp_dir() . "/transform_plugin")){mkdir(get_temp_dir() . "/transform_plugin",0777);}
if ($imversion[0]<6 || ($imversion[0] == 6 && $imversion[1]<7) || ($imversion[0] == 6 && $imversion[1] == 7 && $imversion[2]<5)){
$colorspace1 = " -colorspace sRGB ";
$colorspace2 = " -colorspace RGB ";
} else {
$colorspace1 = " -colorspace RGB ";
$colorspace2 = " -colorspace sRGB ";
}
$command .= " \"$originalpath\" +matte -delete 1--1 -flatten $colorspace1 -geometry 450 $colorspace2 \"$tmpdir/transform_plugin/pre_$ref.jpg\"";
run_command($command);
// while we're here, clean up any old files still hanging around
$dp = opendir(get_temp_dir() . "/transform_plugin");
while ($file = readdir($dp)) {
if ($file <> '.' && $file <> '..'){
if ((filemtime(get_temp_dir() . "/transform_plugin/$file")) < (strtotime('-2 days'))) {
unlink(get_temp_dir() . "/transform_plugin/$file");
}
}
}
closedir($dp);
return true;
}
示例10: generate_transform_preview
function generate_transform_preview($ref)
{
global $storagedir;
global $imagemagick_path;
global $imversion;
if (!isset($imversion)) {
$imversion = get_imagemagick_version();
}
$tmpdir = get_temp_dir();
// get imagemagick path
$command = get_utility_path("im-convert");
if ($command == false) {
exit("Could not find ImageMagick 'convert' utility.");
}
$orig_ext = sql_value("select file_extension value from resource where ref = '{$ref}'", '');
$transformsourcepath = get_resource_path($ref, true, 'scr', false, 'jpg');
//use screen size if available to save time
if (!file_exists($transformsourcepath)) {
$transformsourcepath = get_resource_path($ref, true, '', false, $orig_ext);
}
# Since this check is in get_temp_dir() omit: if(!is_dir($storagedir."/tmp")){mkdir($storagedir."/tmp",0777);}
if (!is_dir(get_temp_dir() . "/transform_plugin")) {
mkdir(get_temp_dir() . "/transform_plugin", 0777);
}
if ($imversion[0] < 6 || $imversion[0] == 6 && $imversion[1] < 7 || $imversion[0] == 6 && $imversion[1] == 7 && $imversion[2] < 5) {
$colorspace1 = " -colorspace sRGB ";
$colorspace2 = " -colorspace RGB ";
} else {
$colorspace1 = " -colorspace RGB ";
$colorspace2 = " -colorspace sRGB ";
}
$command .= " \"{$transformsourcepath}\"[0] +matte -flatten {$colorspace1} -geometry 450 {$colorspace2} \"{$tmpdir}/transform_plugin/pre_{$ref}.jpg\"";
run_command($command);
// while we're here, clean up any old files still hanging around
$dp = opendir(get_temp_dir() . "/transform_plugin");
while ($file = readdir($dp)) {
if ($file != '.' && $file != '..') {
if (filemtime(get_temp_dir() . "/transform_plugin/{$file}") < strtotime('-2 days')) {
unlink(get_temp_dir() . "/transform_plugin/{$file}");
}
}
}
closedir($dp);
return true;
}
示例11: convertImage
/**
* Converts the file of the given resource to the new target file with the specified size. The
* target file format is determined from the suffix of the target file.
* The original colorspace of the image is retained. If $width and $height are zero, the image
* keeps its original size.
*/
function convertImage($resource, $page, $alternative, $target, $width, $height)
{
$command = get_utility_path("im-convert");
if (!$command) {
die("Could not find ImageMagick 'convert' utility.");
}
$originalPath = get_resource_path($resource['ref'], true, '', false, $resource['file_extension'], -1, $page, false, '', $alternative);
$command .= " \"{$originalPath}\"[0] -auto-orient";
if ($width != 0 && $height != 0) {
# Apply resize ('>' means: never enlarge)
$command .= " -resize \"{$width}";
if ($height > 0) {
$command .= "x{$height}";
}
$command .= '>"';
}
$command .= " \"{$target}\"";
run_command($command);
}
示例12: HookRemotedownloadAllGetdownloadurl
function HookRemotedownloadAllGetdownloadurl($ref, $size, $ext, $page = 1, $alternative = -1)
{
global $remotedownload_prepend, $remotedownload_append, $remotedownload_replace, $remotedownload_addquery;
global $storageurl;
$url = get_resource_path($ref, false, $size, false, $ext, -1, $page, $size == "scr" && checkperm("w") && $alternative == -1, "", $alternative);
if (!empty($remotedownload_prepend) && strpos($url, $storageurl) === 0) {
$storageurl_len = strlen($storageurl);
$url = substr($url, 0, $storageurl_len) . $remotedownload_prepend . substr($url, $storageurl_len);
}
if (!empty($remotedownload_append)) {
$url = $url . $remotedownload_append;
}
foreach ($remotedownload_replace as $replace) {
$url = str_replace($replace['match'], $replace['with'], $url);
}
foreach ($remotedownload_addquery as $query) {
$url = $url . (strpos($url, "?") !== FALSE ? "?" : "&") . $query;
}
return $url;
}
示例13: alt_from_resource
function alt_from_resource($source,$target,$name='',$delete=false){
// Copy a resource as an alt file of another resource
// alt is the source resource, $ref is the target resource that will get the new alternate
global $view_title_field;
$srcdata=get_resource_data($source);
$srcext = $srcdata['file_extension'];
$srcpath = get_resource_path($source,true,"",false,$srcext);
if ($name == ''){
$name = sql_value("select value from resource_data where resource_type_field = '$view_title_field' and resource = '$source'",'Untitled');
}
$description = '';
if (!file_exists($srcpath)){
echo "ERROR: File not found.";
return false;
} else {
$file_size = filesize_unlimited($srcpath);
$altid = add_alternative_file($target,$name,$description="",$file_name="",$file_extension="",$file_size,$alt_type='');
$newpath = get_resource_path($target,true,"",true,$srcext,-1,1,false,'',$altid);
copy($srcpath,$newpath);
# Preview creation for alternative files (enabled via config)
global $alternative_file_previews;
if ($alternative_file_previews){
create_previews($target,false,$srcext,false,false,$altid);
}
if ($delete){
// we are supposed to delete the original resource when we're done
# Not allowed to edit this resource? They shouldn't have been able to get here.
if ((!get_edit_access($source,$srcdata["archive"]))||checkperm('D')) {
exit ("Permission denied.");
} else {
delete_resource($source);
}
}
return true;
}
}
示例14: updateResource
public function updateResource()
{
$rid = $this->resourceId();
// resource does not exist - create it
if ($rid == 0) {
$rid = create_resource($this->type);
} else {
update_resource_type($rid, $this->type);
}
foreach ($this->fields as $k => $v) {
update_field($rid, $k, $v);
}
if (file_exists($this->filename)) {
$extension = explode(".", $this->filename);
if (count($extension) > 1) {
$extension = trim(strtolower($extension[count($extension) - 1]));
} else {
$extension = "";
}
$path = get_resource_path($rid, true, "", true, $extension);
copy($this->filename, $path);
create_previews($rid, false, $extension);
# add file extension
sql_query("update resource set file_extension='" . escapeString($extension) . "' where ref='" . escapeString($rid) . "'");
}
# add resource to collection (if the collection exists)
if ($this->collection != null) {
$col_ref = sql_value("select ref as value from collection where name='" . escapeString($this->collection) . "'", 0);
if (isset($col_ref)) {
add_resource_to_collection($rid, $col_ref);
}
}
# set access rights
if ($this->access != null) {
sql_query("update resource set access='" . escapeString($this->access) . "' where ref='" . escapeString($rid) . "'");
}
}
示例15: HookResourceofthedayHomeReplaceslideshow
function HookResourceofthedayHomeReplaceslideshow()
{
include_once dirname(__FILE__) . "/../inc/rotd_functions.php";
$rotd = get_resource_of_the_day();
if ($rotd === false) {
return false;
}
# No ROTD, return false to disable hook and display standard slide show.
# Fetch resource data
$resource = get_resource_data($rotd);
# Fetch title
$title = sql_value("select value from resource_data where resource='{$rotd}' and resource_type_field=8", "");
# Fetch caption
$caption = sql_value("select value from resource_data where resource='{$rotd}' and resource_type_field=18", "");
# Show resource!
$pre = get_resource_path($rotd, false, "pre", false, "jpg");
?>
<div class="HomePicturePanel RecordPanel" style="width:350px;padding-left:4px;">
<a href="view.php?ref=<?php
echo $rotd;
?>
"><img class="ImageBorder" style="margin-bottom: 10px;" src="<?php
echo $pre;
?>
" /></a>
<br />
<h2 ><?php
echo i18n_get_translated(htmlspecialchars($title));
?>
</h2>
<?php
echo $caption;
?>
</div>
<?php
return true;
}