1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 06:07:32 +02:00

Fixes #651 - Media-Manager - Uploaded file does not display in selection.

This commit is contained in:
Cameron
2015-02-07 11:57:28 -08:00
parent 8afe6edfea
commit 25b96411e0
4 changed files with 44 additions and 22 deletions

View File

@@ -136,7 +136,13 @@ class e_admin_log
/** /**
* Add a Save an event into the admin, rolloing or user log. * Add and Save an event into the admin, rolling or user log.
* @param string $event_title
* @param mixed $event_details
* @param integer $event_type [optional] Log level eg. E_LOG_INFORMATIVE, E_LOG_NOTICE, E_LOG_WARNING, E_LOG_FATAL
* @param string $event_code [optional] - eg. 'BOUNCE'
* @param integer $target [optional] LOG_TO_ADMIN, LOG_TO_AUDIT, LOG_TO_ROLLING
* @return e_admin_log
* *
* Alternative admin log entry point - compatible with legacy calls, and a bit simpler to use than the generic entry point. * Alternative admin log entry point - compatible with legacy calls, and a bit simpler to use than the generic entry point.
* ($eventcode has been added - give it a reference to identify the source module, such as 'NEWS_12' or 'ECAL_03') * ($eventcode has been added - give it a reference to identify the source module, such as 'NEWS_12' or 'ECAL_03')
@@ -148,12 +154,7 @@ class e_admin_log
* Typically the 'STRING' part of the name defines the area originating the log event, and the 'nn' is a numeric code * Typically the 'STRING' part of the name defines the area originating the log event, and the 'nn' is a numeric code
* This is stored as 'LAN_AL_STRING_NN', and must be defined in a language file which is loaded during log display. * This is stored as 'LAN_AL_STRING_NN', and must be defined in a language file which is loaded during log display.
* *
* @param string $event_title
* @param mixed $event_details
* @param integer $event_type [optional] Log level eg. E_LOG_INFORMATIVE, E_LOG_NOTICE, E_LOG_WARNING, E_LOG_FATAL
* @param string $event_code [optional] - eg. 'BOUNCE'
* @param integer $target [optional] LOG_TO_ADMIN, LOG_TO_AUDIT, LOG_TO_ROLLING
* @return e_admin_log
*/ */
public function add($event_title, $event_detail, $event_type = E_LOG_INFORMATIVE , $event_code = '', $target = LOG_TO_ADMIN ) public function add($event_title, $event_detail, $event_type = E_LOG_INFORMATIVE , $event_code = '', $target = LOG_TO_ADMIN )
{ {

View File

@@ -382,8 +382,10 @@ class e_file
$finfo['fname'] = basename($path_to_file); $finfo['fname'] = basename($path_to_file);
$finfo['path'] = dirname($path_to_file).'/'; $finfo['path'] = dirname($path_to_file).'/';
// $finfo['mime'] = vartrue($finfo['mime'],'application/'.$finfo['pathinfo']['extension']); if(empty($finfo['mime'])) // last resort.
{
$finfo['mime'] = 'application/'.$finfo['pathinfo']['extension'];
}

View File

@@ -23,7 +23,7 @@ class e_media
{ {
protected $imagelist = array(); protected $imagelist = array();
protected $logging = false; protected $logging = false;
protected $mimePaths = array( protected $mimePaths = array(
'text' => e_MEDIA_FILE, 'text' => e_MEDIA_FILE,
@@ -35,7 +35,14 @@ class e_media
'other' => e_MEDIA_FILE 'other' => e_MEDIA_FILE
); );
function __construct()
{
if(E107_DEBUG_LEVEL > 0)
{
$this->logging = true;
}
}
/** /**
* Import files from specified path into media database. * Import files from specified path into media database.
* @param string $cat Category nickname * @param string $cat Category nickname
@@ -115,10 +122,10 @@ class e_media
'media_type' => $f['mime'] 'media_type' => $f['mime']
); );
if(!$sql->db_Select('core_media','media_url',"media_url = '".$fullpath."' LIMIT 1")) if(!$sql->select('core_media','media_url',"media_url = '".$fullpath."' LIMIT 1"))
{ {
if($sql->db_Insert("core_media",$insert)) if($sql->insert("core_media",$insert))
{ {
$count++; $count++;
$mes->addDebug("Imported Media: ".$f['fname']); $mes->addDebug("Imported Media: ".$f['fname']);
@@ -172,7 +179,7 @@ class e_media
if(vartrue($cat)) if(vartrue($cat))
{ {
$status = ($sql->db_Delete('core_media',"media_cat = '".$cat."'")) ? TRUE : FALSE; $status = ($sql->delete('core_media',"media_cat = '".$cat."'")) ? TRUE : FALSE;
$mes->add("Removing Media in Category: ".$cat, E_MESSAGE_DEBUG); $mes->add("Removing Media in Category: ".$cat, E_MESSAGE_DEBUG);
return $status; return $status;
} }
@@ -197,7 +204,7 @@ class e_media
if(vartrue($epath)) if(vartrue($epath))
{ {
$path = $tp->createConstants($epath, 'rel'); $path = $tp->createConstants($epath, 'rel');
$status = ($sql->db_Delete('core_media',"media_url LIKE '".$path."%'".$qry)) ? TRUE : FALSE; $status = ($sql->delete('core_media',"media_url LIKE '".$path."%'".$qry)) ? TRUE : FALSE;
$message = ($type == 'image') ? "Removing Media with path: ".$path : "Removing Icons with path: ".$path; $message = ($type == 'image') ? "Removing Media with path: ".$path : "Removing Icons with path: ".$path;
$mes->add($message, E_MESSAGE_DEBUG); $mes->add($message, E_MESSAGE_DEBUG);
return $status; return $status;
@@ -221,8 +228,8 @@ class e_media
$path = $tp->createConstants($epath, 'rel'); $path = $tp->createConstants($epath, 'rel');
$status = ($sql->db_Select_gen("SELECT * FROM `#core_media` WHERE `media_url` LIKE '".$path."%' AND media_category REGEXP '_icon_16|_icon_32|_icon_48|_icon_64' ")) ? TRUE : FALSE; $status = ($sql->gen("SELECT * FROM `#core_media` WHERE `media_url` LIKE '".$path."%' AND media_category REGEXP '_icon_16|_icon_32|_icon_48|_icon_64' ")) ? TRUE : FALSE;
while ($row = $sql->db_Fetch()) while ($row = $sql->fetch())
{ {
$ret[] = $row['media_url']; $ret[] = $row['media_url'];
} }
@@ -248,7 +255,7 @@ class e_media
{ {
$data['media_cat_class'] = defset('e_UC_MEMBER', 253); $data['media_cat_class'] = defset('e_UC_MEMBER', 253);
} }
return e107::getDb()->db_Insert('core_media_cat', $data); return e107::getDb()->insert('core_media_cat', $data);
} }
@@ -322,13 +329,13 @@ class e_media
$sql = e107::getDb(); $sql = e107::getDb();
$sql->db_Select('core_media_cat',"media_cat_category", "media_cat_owner = '".$owner."' "); $sql->select('core_media_cat',"media_cat_category", "media_cat_owner = '".$owner."' ");
while($row = $sql->db_Fetch()) while($row = $sql->db_Fetch())
{ {
$categories[] = "'".$row['media_cat_category']."'"; $categories[] = "'".$row['media_cat_category']."'";
} }
if($sql->db_Delete('core_media_cat', "media_cat_owner = '".$owner."' ")) if($sql->delete('core_media_cat', "media_cat_owner = '".$owner."' "))
{ {
//TODO retrieve all category names for owner, and reset all media categories to _common. //TODO retrieve all category names for owner, and reset all media categories to _common.
return TRUE; return TRUE;
@@ -352,7 +359,7 @@ class e_media
$qry .= "ORDER BY media_cat_order"; $qry .= "ORDER BY media_cat_order";
e107::getDb()->gen($qry); e107::getDb()->gen($qry);
while($row = e107::getDb()->db_Fetch(MYSQL_ASSOC)) while($row = e107::getDb()->fetch(MYSQL_ASSOC))
{ {
$id = $row['media_cat_category']; $id = $row['media_cat_category'];
$ret[$id] = $row; $ret[$id] = $row;
@@ -1017,6 +1024,7 @@ class e_media
// Check it hasn't been imported already. // Check it hasn't been imported already.
if($newpath = $this->checkDupe($oldpath, $file)) if($newpath = $this->checkDupe($oldpath, $file))
{ {
$this->log("Line: ".__LINE__." Couldn't find the file: ".$oldpath);
return $newpath; return $newpath;
} }
$this->log("Line: ".__LINE__." Couldn't find the file: ".$oldpath); $this->log("Line: ".__LINE__." Couldn't find the file: ".$oldpath);
@@ -1049,7 +1057,7 @@ class e_media
$img_data['media_description'] = $new_data['media_description']; $img_data['media_description'] = $new_data['media_description'];
$img_data['media_userclass'] = '0'; $img_data['media_userclass'] = '0';
if($sql->db_Insert("core_media",$img_data)) if($sql->insert("core_media",$img_data))
{ {
$mes->add("Importing Media: ".$file, E_MESSAGE_SUCCESS); $mes->add("Importing Media: ".$file, E_MESSAGE_SUCCESS);
$this->log("Importing Media: ".$file." successful"); $this->log("Importing Media: ".$file." successful");

View File

@@ -140,12 +140,23 @@ if (!$chunks || $chunk == $chunks - 1) {
} }
// rename($targetDir.$fileName,e_MEDIA."images/2012-05/",$fileName); // rename($targetDir.$fileName,e_MEDIA."images/2012-05/",$fileName);
if($_GET['for'] !='') // leave in upload directory if no category given. if($_GET['for'] !='') // leave in upload directory if no category given.
{ {
$result = e107::getMedia()->importFile($fileName,$_GET['for']); $result = e107::getMedia()->importFile($fileName,$_GET['for']);
} }
$log = $_GET;
$log['filepath'] = $filePath;
$log['filename'] = $fileName;
$log['status'] = ($result) ? 'ok' : 'failed';
$type = ($result) ? E_LOG_INFORMATIVE : E_LOG_WARNING;
e107::getLog()->add('Media Upload', print_r($log,true), $type, MEDIA_01);
$array = array("jsonrpc"=>"2.0", "result"=>$result,"id"=>"id"); $array = array("jsonrpc"=>"2.0", "result"=>$result,"id"=>"id");
echo json_encode($array); echo json_encode($array);