This commit is contained in:
messerbill 2013-12-18 16:48:17 +01:00
parent 3c0d87dbce
commit b2977ef8dd
2 changed files with 22 additions and 4 deletions

View File

@ -37,6 +37,12 @@ class img {
throw new \SYSTEM\LOG\ERROR("No matching Cat '" . $cat . "' found.");}
return move_uploaded_file($contents, self::$imgfolders[$cat][0].$id);
}
public static function delete($cat, $id) {
if (!array_key_exists($cat, self::$imgfolders)) {
throw new \SYSTEM\LOG\ERROR("No matching Cat '" . $cat . "' found.");}
return unlink(self::$imgfolders[$cat][0].$id);
}
private static function getFolder($folder, $mask) {
$files = array();

View File

@ -2,11 +2,22 @@
namespace SYSTEM\SAI;
class saimod_sys_img extends \SYSTEM\SAI\SaiModule {
public static function sai_mod__SYSTEM_SAI_saimod_sys_img_action_delete($cat,$id){
if(!\SYSTEM\IMG\img::delete($cat, $id)){
throw new \SYSTEM\LOG\ERROR("delete problem");}
return \SYSTEM\LOG\JsonResult::ok();
}
public static function sai_mod__SYSTEM_SAI_saimod_sys_img_action_rename($cat,$id,$newid){
return \SYSTEM\LOG\JsonResult::ok();
}
public static function sai_mod__SYSTEM_SAI_saimod_sys_img_action_upload($cat){
if(!\SYSTEM\IMG\img::put($cat, basename($_FILES['datei']['name']) , $_FILES['datei']['tmp_name'])){
throw new \SYSTEM\LOG\ERROR("upload problem");}
throw new \SYSTEM\LOG\ERROR("upload finished sucessful");
return \SYSTEM\LOG\JsonResult::ok();
}
public static function sai_mod__SYSTEM_SAI_saimod_sys_img(){
//tt
@ -18,12 +29,12 @@ class saimod_sys_img extends \SYSTEM\SAI\SaiModule {
$result .= '<form action="'.\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_BASEURL).'sai_mod=.SYSTEM.SAI.saimod_sys_img&action=upload&cat='.$name.'" method="post" enctype="multipart/form-data">';
$result .= '<input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
<input type="file" name="datei"><br>
<input type="submit" class="btn" value="Hochladen">';
<input type="submit" class="btn" value="Add">';
$result .= "</form>";
foreach($cat as $img){
//$result .= '<img src="api.php?call=img&cat='.$name.'&id='.$img.'" alt="" />';
$result .= '<li><a href="api.php?call=img&cat='.$name.'&id='.$img.'">'.$img.'</a></li>';
$result .= '<input type="button" class="btn-danger imgdelbtn" style="margin: 1px;" value="Delete" cat="'.$name.'" id="'.$img.'"><input type="submit" class="btn-warning imgrnbtn" style="margin: 1px; margin-right: 3px;" value="Rename" cat="'.$name.'" id="'.$img.'"><a href="api.php?call=img&cat='.$name.'&id='.$img.'">'.$img.'</a><br>';
}
}
return $result;
@ -34,5 +45,6 @@ class saimod_sys_img extends \SYSTEM\SAI\SaiModule {
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function sai_mod__SYSTEM_SAI_saimod_sys_img_flag_css(){}
public static function sai_mod__SYSTEM_SAI_saimod_sys_img_flag_js(){}
public static function sai_mod__SYSTEM_SAI_saimod_sys_img_flag_js(){return \SYSTEM\LOG\JsonResult::toString(
array( \SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_img/sai_sys_img.js')));}
}