From 21d806cd5466991b4790c5e6b37a40ae35f1eecb Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sun, 28 Sep 2014 14:44:17 +0200 Subject: improve some scrutinizer issues different types unused vars PHPDocs --- inc/media.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'inc/media.php') diff --git a/inc/media.php b/inc/media.php index 9022858e1..5190862d7 100644 --- a/inc/media.php +++ b/inc/media.php @@ -582,6 +582,12 @@ function media_notify($id,$file,$mime,$old_rev=false){ /** * List all files in a given Media namespace + * + * @param string $ns namespace + * @param null|int $auth permission level + * @param string $jump + * @param bool $fullscreenview + * @param bool|string $sort sorting, false skips sorting */ function media_filelist($ns,$auth=null,$jump='',$fullscreenview=false,$sort=false){ global $conf; -- cgit v1.2.3 From e0c26282a603881e8d2f839d94c28dbbfc57d71b Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Mon, 29 Sep 2014 03:34:17 +0200 Subject: scrutinizer documentations issues --- inc/media.php | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 98 insertions(+), 10 deletions(-) (limited to 'inc/media.php') diff --git a/inc/media.php b/inc/media.php index 9022858e1..2b802a0ae 100644 --- a/inc/media.php +++ b/inc/media.php @@ -41,6 +41,11 @@ function media_filesinuse($data,$id){ * * @author Andreas Gohr * @author Kate Arzamastseva + * + * @param string $id media id + * @param int $auth permission level + * @param array $data + * @return bool */ function media_metasave($id,$auth,$data){ if($auth < AUTH_UPLOAD) return false; @@ -113,6 +118,10 @@ function media_ispublic($id){ * * @author Andreas Gohr * @author Kate Arzamastseva + * + * @param string $id media id + * @param int $auth permission level + * @return bool */ function media_metaform($id,$auth){ global $lang; @@ -175,6 +184,9 @@ function media_metaform($id,$auth){ * Convenience function to check if a media file is still in use * * @author Michael Klier + * + * @param string $id media id + * @return array|bool */ function media_inuse($id) { global $conf; @@ -367,9 +379,18 @@ function copy_uploaded_file($from, $to){ * $data[2] id: the future directory id of the uploaded file * $data[3] imime: the mimetype of the uploaded file * $data[4] overwrite: if an existing file is going to be overwritten + * $data[5] move: * * @triggers MEDIA_UPLOAD_FINISH */ +/** + * @param array $file + * @param string $id + * @param bool $ow + * @param int $auth permission level + * @param string $move function name + * @return array|mixed + */ function media_save($file, $id, $ow, $auth, $move) { if($auth < AUTH_UPLOAD) { return array("You don't have permissions to upload files.", -1); @@ -817,8 +838,13 @@ function media_tab_search($ns,$auth=null) { * Prints tab that displays mediafile details * * @author Kate Arzamastseva + * + * @param string $image media id + * @param string $ns + * @param null|int $auth permission level + * @param string|int $rev */ -function media_tab_view($image, $ns, $auth=null, $rev=false) { +function media_tab_view($image, $ns, $auth=null, $rev='') { global $lang; if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); @@ -837,6 +863,10 @@ function media_tab_view($image, $ns, $auth=null, $rev=false) { * Prints tab that displays form for editing mediafile metadata * * @author Kate Arzamastseva + * + * @param string $image media id + * @param string $ns + * @param null|int $auth permission level */ function media_tab_edit($image, $ns, $auth=null) { if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); @@ -851,6 +881,10 @@ function media_tab_edit($image, $ns, $auth=null) { * Prints tab that displays mediafile revisions * * @author Kate Arzamastseva + * + * @param string $image media id + * @param string $ns + * @param null|int $auth permission level */ function media_tab_history($image, $ns, $auth=null) { global $lang; @@ -875,7 +909,7 @@ function media_tab_history($image, $ns, $auth=null) { * Prints mediafile details * * @param string $image media id - * @param $auth + * @param int $auth permission level * @param int|bool $rev * @param JpegMeta|bool $meta * @author Kate Arzamastseva @@ -912,8 +946,12 @@ function media_preview($image, $auth, $rev=false, $meta=false) { * Prints mediafile action buttons * * @author Kate Arzamastseva + * + * @param string $image media id + * @param int $auth permission level + * @param string|int $rev revision timestamp, or empty string */ -function media_preview_buttons($image, $auth, $rev=false) { +function media_preview_buttons($image, $auth, $rev='') { global $lang, $conf; echo '
    '.NL; @@ -962,7 +1000,7 @@ function media_preview_buttons($image, $auth, $rev=false) { * * @author Kate Arzamastseva * @param string $image - * @param int $rev + * @param int|string $rev * @param JpegMeta $meta * @param int $size * @return array @@ -986,9 +1024,10 @@ function media_image_preview_size($image, $rev, $meta, $size = 500) { * Returns the requested EXIF/IPTC tag from the image meta * * @author Kate Arzamastseva - * @param array $tags + * + * @param array $tags * @param JpegMeta $meta - * @param string $alt + * @param string $alt * @return string */ function media_getTag($tags,$meta,$alt=''){ @@ -1002,6 +1041,7 @@ function media_getTag($tags,$meta,$alt=''){ * Returns mediafile tags * * @author Kate Arzamastseva + * * @param JpegMeta $meta * @return array */ @@ -1033,7 +1073,13 @@ function media_file_tags($meta) { * * @author Kate Arzamastseva */ -function media_details($image, $auth, $rev=false, $meta=false) { +/** + * @param string $image image id + * @param int $auth permission level + * @param string|int $rev revision timestamp, or empty string + * @param bool|JpegMeta $meta image object, or create one if false + */ +function media_details($image, $auth, $rev='', $meta=false) { global $lang; if (!$meta) $meta = new JpegMeta(mediaFN($image, $rev)); @@ -1057,6 +1103,13 @@ function media_details($image, $auth, $rev=false, $meta=false) { * * @author Kate Arzamastseva */ +/** + * @param string $image image id + * @param string $ns + * @param int $auth permission level + * @param bool $fromajax + * @return void|bool|string + */ function media_diff($image, $ns, $auth, $fromajax = false) { global $conf; global $INPUT; @@ -1135,6 +1188,13 @@ function _media_file_diff($data) { * Shows difference between two revisions of image * * @author Kate Arzamastseva + * + * @param string $image + * @param string|int $l_rev revision timestamp, or empty string + * @param string|int $r_rev revision timestamp, or empty string + * @param string $ns + * @param int $auth permission level + * @param bool $fromajax */ function media_file_diff($image, $l_rev, $r_rev, $ns, $auth, $fromajax){ global $lang; @@ -1256,8 +1316,8 @@ function media_file_diff($image, $l_rev, $r_rev, $ns, $auth, $fromajax){ * * @author Kate Arzamastseva * @param string $image - * @param int $l_rev - * @param int $r_rev + * @param int $l_rev revision timestamp, or empty string + * @param int $r_rev revision timestamp, or empty string * @param array $l_size * @param array $r_size * @param string $type @@ -1325,6 +1385,12 @@ function media_restore($image, $rev, $auth){ * @author Andreas Gohr * @author Kate Arzamastseva * @triggers MEDIA_SEARCH + * + * @param string $query + * @param string $ns + * @param null|int $auth + * @param bool $fullscreen + * @param string $sort */ function media_searchlist($query,$ns,$auth=null,$fullscreen=false,$sort='natural'){ global $conf; @@ -1375,10 +1441,14 @@ function media_searchlist($query,$ns,$auth=null,$fullscreen=false,$sort='natural /** * Formats and prints one file in the list + * + * @param array $item + * @param int $auth permission level + * @param string $jump item id + * @param bool $display_namespace */ function media_printfile($item,$auth,$jump,$display_namespace=false){ global $lang; - global $conf; // Prepare zebra coloring // I always wanted to use this variable name :-D @@ -1472,6 +1542,11 @@ function media_printicon($filename, $size=''){ * Formats and prints one file in the list in the thumbnails view * * @author Kate Arzamastseva + * + * @param array $item + * @param int $auth + * @param bool|string $jump + * @param bool $display_namespace */ function media_printfile_thumbs($item,$auth,$jump=false,$display_namespace=false){ @@ -1519,6 +1594,9 @@ function media_printfile_thumbs($item,$auth,$jump=false,$display_namespace=false /** * Prints a thumbnail and metainfo + * + * @param array $item + * @param bool $fullscreen */ function media_printimgdetail($item, $fullscreen=false){ // prepare thumbnail @@ -1621,6 +1699,10 @@ function media_managerURL($params=false, $amp='&', $abs=false, $params_array * * @author Andreas Gohr * @author Kate Arzamastseva + * + * @param string $ns + * @param int $auth permission level + * @param bool $fullscreen */ function media_uploadform($ns, $auth, $fullscreen = false){ global $lang; @@ -1708,6 +1790,10 @@ function media_getuploadsize(){ * * @author Tobias Sarnowski * @author Kate Arzamastseva + * + * @param string $ns + * @param string $query + * @param bool $fullscreen */ function media_searchform($ns,$query='',$fullscreen=false){ global $lang; @@ -1735,6 +1821,8 @@ function media_searchform($ns,$query='',$fullscreen=false){ * Build a tree outline of available media namespaces * * @author Andreas Gohr + * + * @param string $ns */ function media_nstree($ns){ global $conf; -- cgit v1.2.3 From 59bc3b48fdffb76ee65a4b630be3ffa1f6c20c80 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Mon, 29 Sep 2014 21:45:27 +0200 Subject: more scrutinizer issue improvements --- inc/media.php | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'inc/media.php') diff --git a/inc/media.php b/inc/media.php index 2b802a0ae..7770d3cc9 100644 --- a/inc/media.php +++ b/inc/media.php @@ -231,6 +231,7 @@ function media_delete($id,$auth){ $file = mediaFN($id); // trigger an event - MEDIA_DELETE_FILE + $data = array(); $data['id'] = $id; $data['name'] = utf8_basename($file); $data['path'] = $file; @@ -439,6 +440,7 @@ function media_save($file, $id, $ow, $auth, $move) { } // prepare event data + $data = array(); $data[0] = $file['name']; $data[1] = $fn; $data[2] = $id; @@ -910,11 +912,11 @@ function media_tab_history($image, $ns, $auth=null) { * * @param string $image media id * @param int $auth permission level - * @param int|bool $rev + * @param int|string $rev revision timestamp or empty string * @param JpegMeta|bool $meta * @author Kate Arzamastseva */ -function media_preview($image, $auth, $rev=false, $meta=false) { +function media_preview($image, $auth, $rev='', $meta=false) { $size = media_image_preview_size($image, $rev, $meta); @@ -999,11 +1001,11 @@ function media_preview_buttons($image, $auth, $rev='') { * Returns image width and height for mediamanager preview panel * * @author Kate Arzamastseva - * @param string $image - * @param int|string $rev - * @param JpegMeta $meta - * @param int $size - * @return array + * @param string $image + * @param int|string $rev + * @param JpegMeta|bool $meta + * @param int $size + * @return array|bool */ function media_image_preview_size($image, $rev, $meta, $size = 500) { if (!preg_match("/\.(jpe?g|gif|png)$/", $image) || !file_exists(mediaFN($image, $rev))) return false; @@ -1158,6 +1160,7 @@ function media_diff($image, $ns, $auth, $fromajax = false) { } // prepare event data + $data = array(); $data[0] = $image; $data[1] = $l_rev; $data[2] = $r_rev; @@ -1397,13 +1400,12 @@ function media_searchlist($query,$ns,$auth=null,$fullscreen=false,$sort='natural global $lang; $ns = cleanID($ns); - + $evdata = array( + 'ns' => $ns, + 'data' => array(), + 'query' => $query + ); if ($query) { - $evdata = array( - 'ns' => $ns, - 'data' => array(), - 'query' => $query - ); $evt = new Doku_Event('MEDIA_SEARCH', $evdata); if ($evt->advise_before()) { $dir = utf8_encodeFN(str_replace(':','/',$evdata['ns'])); @@ -2169,6 +2171,7 @@ function media_resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h,$ofs_x= } // create an image of the given filetype + $image = false; if ($ext == 'jpg' || $ext == 'jpeg'){ if(!function_exists("imagecreatefromjpeg")) return false; $image = @imagecreatefromjpeg($from); @@ -2182,6 +2185,7 @@ function media_resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h,$ofs_x= } if(!$image) return false; + $newimg = false; if(($conf['gdlib']>1) && function_exists("imagecreatetruecolor") && $ext != 'gif'){ $newimg = @imagecreatetruecolor ($to_w, $to_h); } @@ -2266,14 +2270,14 @@ function media_resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h,$ofs_x= function media_alternativefiles($src, $exts){ $files = array(); - list($srcExt, $srcMime) = mimetype($src); + list($srcExt, /* $srcMime */) = mimetype($src); $filebase = substr($src, 0, -1 * (strlen($srcExt)+1)); foreach($exts as $ext) { $fileid = $filebase.'.'.$ext; $file = mediaFN($fileid); if(file_exists($file)) { - list($fileExt, $fileMime) = mimetype($file); + list(/* $fileExt */, $fileMime) = mimetype($file); $files[$fileMime] = $fileid; } } -- cgit v1.2.3 From 42ea7f447f39fbc2f79eaaec31f8c10ede59c5d0 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Wed, 1 Oct 2014 11:30:27 +0200 Subject: Many PHPDocs, some unused and dyn declared vars many PHPDocs some unused variables some dynamically declared variables declared --- inc/media.php | 264 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 186 insertions(+), 78 deletions(-) (limited to 'inc/media.php') diff --git a/inc/media.php b/inc/media.php index 7770d3cc9..4ad67369d 100644 --- a/inc/media.php +++ b/inc/media.php @@ -16,6 +16,9 @@ if(!defined('NL')) define('NL',"\n"); * their CSS tags except pagenames won't be links. * * @author Matthias Grimm + * + * @param array $data + * @param string $id */ function media_filesinuse($data,$id){ global $lang; @@ -45,7 +48,7 @@ function media_filesinuse($data,$id){ * @param string $id media id * @param int $auth permission level * @param array $data - * @return bool + * @return false|string */ function media_metasave($id,$auth,$data){ if($auth < AUTH_UPLOAD) return false; @@ -91,6 +94,7 @@ function media_metasave($id,$auth,$data){ * check if a media is external source * * @author Gerrit Uitslag + * * @param string $id the media ID or URL * @return bool */ @@ -103,6 +107,7 @@ function media_isexternal($id){ * Check if a media item is public (eg, external URL or readable by @ALL) * * @author Andreas Gohr + * * @param string $id the media ID or URL * @return bool */ @@ -214,6 +219,7 @@ define('DOKU_MEDIA_EMPTY_NS', 8); * If configured, checks for media references before deletion * * @author Andreas Gohr + * * @param string $id media id * @param int $auth no longer used * @return int One of: 0, @@ -266,9 +272,9 @@ function media_delete($id,$auth){ /** * Handle file uploads via XMLHttpRequest * - * @param string $ns target namespace - * @param int $auth current auth check result - * @return mixed false on error, id of the new file on success + * @param string $ns target namespace + * @param int $auth current auth check result + * @return false|string false on error, id of the new file on success */ function media_upload_xhr($ns,$auth){ if(!checkSecurityToken()) return false; @@ -311,10 +317,11 @@ function media_upload_xhr($ns,$auth){ * * @author Andreas Gohr * @author Michael Klier - * @param string $ns target namespace - * @param int $auth current auth check result - * @param bool|array $file $_FILES member, $_FILES['upload'] if false - * @return mixed false on error, id of the new file on success + * + * @param string $ns target namespace + * @param int $auth current auth check result + * @param bool|array $file $_FILES member, $_FILES['upload'] if false + * @return false|string false on error, id of the new file on success */ function media_upload($ns,$auth,$file=false){ if(!checkSecurityToken()) return false; @@ -358,6 +365,7 @@ function media_upload($ns,$auth,$file=false){ * Using copy, makes sure any setgid bits on the media directory are honored * * @see move_uploaded_file() + * * @param string $from * @param string $to * @return bool @@ -383,14 +391,13 @@ function copy_uploaded_file($from, $to){ * $data[5] move: * * @triggers MEDIA_UPLOAD_FINISH - */ -/** - * @param array $file + * + * @param array $file * @param string $id - * @param bool $ow - * @param int $auth permission level + * @param bool $ow overwrite? + * @param int $auth permission level * @param string $move function name - * @return array|mixed + * @return false|array|string */ function media_save($file, $id, $ow, $auth, $move) { if($auth < AUTH_UPLOAD) { @@ -453,8 +460,12 @@ function media_save($file, $id, $ow, $auth, $move) { } /** - * Callback adapter for media_upload_finish() + * Callback adapter for media_upload_finish() triggered by MEDIA_UPLOAD_FINISH + * * @author Michael Klier + * + * @param array $data event data + * @return false|array|string */ function _media_upload_action($data) { // fixme do further sanity tests of given data? @@ -471,6 +482,14 @@ function _media_upload_action($data) { * @author Andreas Gohr * @author Michael Klier * @author Kate Arzamastseva + * + * @param string $fn_tmp + * @param string $fn + * @param string $id media id + * @param string $imime mime type + * @param bool $overwrite overwrite existing? + * @param string $move function name + * @return array|string */ function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite, $move = 'move_uploaded_file') { global $conf; @@ -514,6 +533,7 @@ function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite, $move = 'mov * directory * * @author Kate Arzamastseva + * * @param string $id * @return int - revision date */ @@ -557,6 +577,10 @@ function media_saveOldRevision($id){ * @author Andreas Gohr * @link http://www.splitbrain.org/blog/2007-02/12-internet_explorer_facilitates_cross_site_scripting * @fixme check all 26 magic IE filetypes here? + * + * @param string $file path to file + * @param string $mime mimetype + * @return int */ function media_contentcheck($file,$mime){ global $conf; @@ -566,14 +590,14 @@ function media_contentcheck($file,$mime){ $bytes = fread($fh, 256); fclose($fh); if(preg_match('/<(script|a|img|html|body|iframe)[\s>]/i',$bytes)){ - return -3; + return -3; //XSS: possibly malicious content } } } if(substr($mime,0,6) == 'image/'){ $info = @getimagesize($file); if($mime == 'image/gif' && $info[2] != 1){ - return -1; + return -1; // uploaded content did not match the file extension }elseif($mime == 'image/jpeg' && $info[2] != 2){ return -1; }elseif($mime == 'image/png' && $info[2] != 3){ @@ -584,7 +608,7 @@ function media_contentcheck($file,$mime){ global $TEXT; $TEXT = io_readFile($file); if(checkwordblock()){ - return -2; + return -2; //blocked by the spam blacklist } } return 0; @@ -594,6 +618,12 @@ function media_contentcheck($file,$mime){ * Send a notify mail on uploads * * @author Andreas Gohr + * + * @param string $id media id + * @param string $file path to file + * @param string $mime mime type + * @param bool|int $old_rev revision timestamp or false + * @return bool */ function media_notify($id,$file,$mime,$old_rev=false){ global $conf; @@ -605,6 +635,12 @@ function media_notify($id,$file,$mime,$old_rev=false){ /** * List all files in a given Media namespace + * + * @param string $ns + * @param null|int $auth permission level + * @param string $jump id + * @param bool $fullscreenview + * @param bool|string $sort sorting order */ function media_filelist($ns,$auth=null,$jump='',$fullscreenview=false,$sort=false){ global $conf; @@ -747,6 +783,7 @@ function media_tab_files_options(){ * Returns type of sorting for the list of files in media manager * * @author Kate Arzamastseva + * * @return string - sort type */ function _media_get_sort_type() { @@ -757,6 +794,7 @@ function _media_get_sort_type() { * Returns type of listing for the list of files in media manager * * @author Kate Arzamastseva + * * @return string - list type */ function _media_get_list_type() { @@ -788,6 +826,10 @@ function _media_get_display_param($param, $values) { * Prints tab that displays a list of all files * * @author Kate Arzamastseva + * + * @param string $ns + * @param null|int $auth permission level + * @param string $jump item id */ function media_tab_files($ns,$auth=null,$jump='') { global $lang; @@ -804,6 +846,10 @@ function media_tab_files($ns,$auth=null,$jump='') { * Prints tab that displays uploading form * * @author Kate Arzamastseva + * + * @param string $ns + * @param null|int $auth permission level + * @param string $jump item id */ function media_tab_upload($ns,$auth=null,$jump='') { global $lang; @@ -821,6 +867,9 @@ function media_tab_upload($ns,$auth=null,$jump='') { * Prints tab that displays search form * * @author Kate Arzamastseva + * + * @param string $ns + * @param null|int $auth permission level */ function media_tab_search($ns,$auth=null) { global $INPUT; @@ -843,8 +892,8 @@ function media_tab_search($ns,$auth=null) { * * @param string $image media id * @param string $ns - * @param null|int $auth permission level - * @param string|int $rev + * @param null|int $auth permission level + * @param string|int $rev revision timestamp or empty string */ function media_tab_view($image, $ns, $auth=null, $rev='') { global $lang; @@ -910,10 +959,11 @@ function media_tab_history($image, $ns, $auth=null) { /** * Prints mediafile details * - * @param string $image media id - * @param int $auth permission level - * @param int|string $rev revision timestamp or empty string - * @param JpegMeta|bool $meta + * @param string $image media id + * @param int $auth permission level + * @param int|string $rev revision timestamp or empty string + * @param JpegMeta|bool $meta + * * @author Kate Arzamastseva */ function media_preview($image, $auth, $rev='', $meta=false) { @@ -950,8 +1000,8 @@ function media_preview($image, $auth, $rev='', $meta=false) { * @author Kate Arzamastseva * * @param string $image media id - * @param int $auth permission level - * @param string|int $rev revision timestamp, or empty string + * @param int $auth permission level + * @param string|int $rev revision timestamp, or empty string */ function media_preview_buttons($image, $auth, $rev='') { global $lang, $conf; @@ -1003,9 +1053,9 @@ function media_preview_buttons($image, $auth, $rev='') { * @author Kate Arzamastseva * @param string $image * @param int|string $rev - * @param JpegMeta|bool $meta + * @param JpegMeta|bool $meta * @param int $size - * @return array|bool + * @return array|false */ function media_image_preview_size($image, $rev, $meta, $size = 500) { if (!preg_match("/\.(jpe?g|gif|png)$/", $image) || !file_exists(mediaFN($image, $rev))) return false; @@ -1027,9 +1077,9 @@ function media_image_preview_size($image, $rev, $meta, $size = 500) { * * @author Kate Arzamastseva * - * @param array $tags + * @param array $tags array with tags, first existing is returned * @param JpegMeta $meta - * @param string $alt + * @param string $alt alternative value * @return string */ function media_getTag($tags,$meta,$alt=''){ @@ -1045,7 +1095,7 @@ function media_getTag($tags,$meta,$alt=''){ * @author Kate Arzamastseva * * @param JpegMeta $meta - * @return array + * @return array list of tags of the mediafile */ function media_file_tags($meta) { // load the field descriptions @@ -1074,8 +1124,7 @@ function media_file_tags($meta) { * Prints mediafile tags * * @author Kate Arzamastseva - */ -/** + * * @param string $image image id * @param int $auth permission level * @param string|int $rev revision timestamp, or empty string @@ -1104,13 +1153,12 @@ function media_details($image, $auth, $rev='', $meta=false) { * Shows difference between two revisions of file * * @author Kate Arzamastseva - */ -/** + * * @param string $image image id * @param string $ns * @param int $auth permission level * @param bool $fromajax - * @return void|bool|string + * @return false|null|string */ function media_diff($image, $ns, $auth, $fromajax = false) { global $conf; @@ -1170,14 +1218,13 @@ function media_diff($image, $ns, $auth, $fromajax = false) { // trigger event return trigger_event('MEDIA_DIFF', $data, '_media_file_diff', true); - } /** * Callback for media file diff * - * @param $data - * @return bool|void + * @param array $data event data + * @return false|null */ function _media_file_diff($data) { if(is_array($data) && count($data)===6) { @@ -1318,11 +1365,12 @@ function media_file_diff($image, $l_rev, $r_rev, $ns, $auth, $fromajax){ * and slider * * @author Kate Arzamastseva - * @param string $image - * @param int $l_rev revision timestamp, or empty string - * @param int $r_rev revision timestamp, or empty string - * @param array $l_size - * @param array $r_size + * + * @param string $image image id + * @param int $l_rev revision timestamp, or empty string + * @param int $r_rev revision timestamp, or empty string + * @param array $l_size array with width and height + * @param array $r_size array with width and height * @param string $type */ function media_image_diff($image, $l_rev, $r_rev, $l_size, $r_size, $type) { @@ -1355,10 +1403,11 @@ function media_image_diff($image, $l_rev, $r_rev, $l_size, $r_size, $type) { /** * Restores an old revision of a media file * - * @param string $image - * @param int $rev - * @param int $auth + * @param string $image media id + * @param int $rev revision timestamp or empty string + * @param int $auth * @return string - file's id + * * @author Kate Arzamastseva */ function media_restore($image, $rev, $auth){ @@ -1444,10 +1493,10 @@ function media_searchlist($query,$ns,$auth=null,$fullscreen=false,$sort='natural /** * Formats and prints one file in the list * - * @param array $item - * @param int $auth permission level - * @param string $jump item id - * @param bool $display_namespace + * @param array $item + * @param int $auth permission level + * @param string $jump item id + * @param bool $display_namespace */ function media_printfile($item,$auth,$jump,$display_namespace=false){ global $lang; @@ -1524,9 +1573,9 @@ function media_printfile($item,$auth,$jump,$display_namespace=false){ /** * Display a media icon * - * @param $filename - * @param string $size the size subfolder, if not specified 16x16 is used - * @return string + * @param string $filename media id + * @param string $size the size subfolder, if not specified 16x16 is used + * @return string html */ function media_printicon($filename, $size=''){ list($ext) = mimetype(mediaFN($filename),false); @@ -1546,8 +1595,8 @@ function media_printicon($filename, $size=''){ * @author Kate Arzamastseva * * @param array $item - * @param int $auth - * @param bool|string $jump + * @param int $auth permission level + * @param bool|string $jump item id * @param bool $display_namespace */ function media_printfile_thumbs($item,$auth,$jump=false,$display_namespace=false){ @@ -1598,7 +1647,7 @@ function media_printfile_thumbs($item,$auth,$jump=false,$display_namespace=false * Prints a thumbnail and metainfo * * @param array $item - * @param bool $fullscreen + * @param bool $fullscreen */ function media_printimgdetail($item, $fullscreen=false){ // prepare thumbnail @@ -1662,15 +1711,15 @@ function media_printimgdetail($item, $fullscreen=false){ } /** - * Build link based on the current, adding/rewriting - * parameters + * Build link based on the current, adding/rewriting parameters * * @author Kate Arzamastseva + * * @param array|bool $params - * @param string $amp - separator - * @param bool $abs - * @param bool $params_array - * @return string|array - link + * @param string $amp separator + * @param bool $abs absolute url? + * @param bool $params_array return the parmeters array? + * @return string|array - link or link parameters */ function media_managerURL($params=false, $amp='&', $abs=false, $params_array=false) { global $ID; @@ -1703,8 +1752,8 @@ function media_managerURL($params=false, $amp='&', $abs=false, $params_array * @author Kate Arzamastseva * * @param string $ns - * @param int $auth permission level - * @param bool $fullscreen + * @param int $auth permission level + * @param bool $fullscreen */ function media_uploadform($ns, $auth, $fullscreen = false){ global $lang; @@ -1873,6 +1922,9 @@ function media_nstree($ns){ * Prints a media namespace tree item * * @author Andreas Gohr + * + * @param array $item + * @return string html */ function media_nstree_item($item){ global $INPUT; @@ -1896,6 +1948,9 @@ function media_nstree_item($item){ * Prints a media namespace tree item opener * * @author Andreas Gohr + * + * @param array $item + * @return string html */ function media_nstree_li($item){ $class='media level'.$item['level']; @@ -1917,6 +1972,12 @@ function media_nstree_li($item){ * Resizes the given image to the given size * * @author Andreas Gohr + * + * @param string $file filename, path to file + * @param string $ext extension + * @param int $w desired width + * @param int $h desired height + * @return string path to resized or original size if failed */ function media_resize_image($file, $ext, $w, $h=0){ global $conf; @@ -1937,9 +1998,10 @@ function media_resize_image($file, $ext, $w, $h=0){ $local = getCacheName($file,'.media.'.$w.'x'.$h.'.'.$ext); $mtime = @filemtime($local); // 0 if not exists - if( $mtime > filemtime($file) || - media_resize_imageIM($ext,$file,$info[0],$info[1],$local,$w,$h) || - media_resize_imageGD($ext,$file,$info[0],$info[1],$local,$w,$h) ){ + if($mtime > filemtime($file) || + media_resize_imageIM($ext, $file, $info[0], $info[1], $local, $w, $h) || + media_resize_imageGD($ext, $file, $info[0], $info[1], $local, $w, $h) + ) { if(!empty($conf['fperm'])) @chmod($local, $conf['fperm']); return $local; } @@ -1955,6 +2017,12 @@ function media_resize_image($file, $ext, $w, $h=0){ * image because most pics are more interesting in that area (rule of thirds) * * @author Andreas Gohr + * + * @param string $file filename, path to file + * @param string $ext extension + * @param int $w desired width + * @param int $h desired height + * @return string path to resized or original size if failed */ function media_crop_image($file, $ext, $w, $h=0){ global $conf; @@ -2019,7 +2087,7 @@ function media_crop_image($file, $ext, $w, $h=0){ * @param string $id id of the image * @param int $w resize/crop width * @param int $h resize/crop height - * @return string + * @return string token or empty string if no token required */ function media_get_token($id,$w,$h){ // token is only required for modified images @@ -2042,6 +2110,11 @@ function media_get_token($id,$w,$h){ * * @author Andreas Gohr * @author Pavel Vitis + * + * @param string $url + * @param string $ext extension + * @param int $cache cachetime in seconds + * @return false|string path to cached file */ function media_get_from_URL($url,$ext,$cache){ global $conf; @@ -2054,12 +2127,12 @@ function media_get_from_URL($url,$ext,$cache){ $mtime = @filemtime($local); // 0 if not exists //decide if download needed: - if( ($mtime == 0) || // cache does not exist - ($cache != -1 && $mtime < time()-$cache) // 'recache' and cache has expired - ){ - if(media_image_download($url,$local)){ + if(($mtime == 0) || // cache does not exist + ($cache != -1 && $mtime < time() - $cache) // 'recache' and cache has expired + ) { + if(media_image_download($url, $local)) { return $local; - }else{ + } else { return false; } } @@ -2075,6 +2148,10 @@ function media_get_from_URL($url,$ext,$cache){ * Download image files * * @author Andreas Gohr + * + * @param string $url + * @param string $file path to file in which to put the downloaded content + * @return bool */ function media_image_download($url,$file){ global $conf; @@ -2110,6 +2187,15 @@ function media_image_download($url,$file){ * * @author Pavel Vitis * @author Andreas Gohr + * + * @param string $ext extension + * @param string $from filename path to file + * @param int $from_w original width + * @param int $from_h original height + * @param string $to path to resized file + * @param int $to_w desired width + * @param int $to_h desired height + * @return bool */ function media_resize_imageIM($ext,$from,$from_w,$from_h,$to,$to_w,$to_h){ global $conf; @@ -2134,6 +2220,17 @@ function media_resize_imageIM($ext,$from,$from_w,$from_h,$to,$to_w,$to_h){ * crop images using external ImageMagick convert program * * @author Andreas Gohr + * + * @param string $ext extension + * @param string $from filename path to file + * @param int $from_w original width + * @param int $from_h original height + * @param string $to path to resized file + * @param int $to_w desired width + * @param int $to_h desired height + * @param int $ofs_x offset of crop centre + * @param int $ofs_y offset of crop centre + * @return bool */ function media_crop_imageIM($ext,$from,$from_w,$from_h,$to,$to_w,$to_h,$ofs_x,$ofs_y){ global $conf; @@ -2159,6 +2256,17 @@ function media_crop_imageIM($ext,$from,$from_w,$from_h,$to,$to_w,$to_h,$ofs_x,$o * * @author Andreas Gohr * @author Sebastian Wienecke + * + * @param string $ext extension + * @param string $from filename path to file + * @param int $from_w original width + * @param int $from_h original height + * @param string $to path to resized file + * @param int $to_w desired width + * @param int $to_h desired height + * @param int $ofs_x offset of crop centre + * @param int $ofs_y offset of crop centre + * @return bool */ function media_resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h,$ofs_x=0,$ofs_y=0){ global $conf; @@ -2261,9 +2369,9 @@ function media_resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h,$ofs_x= * Return other media files with the same base name * but different extensions. * - * @param string $src - ID of media file - * @param array $exts - alternative extensions to find other files for - * @return array - mime type => file ID + * @param string $src - ID of media file + * @param string[] $exts - alternative extensions to find other files for + * @return array - array(mime type => file ID) * * @author Anika Henke */ @@ -2288,7 +2396,7 @@ function media_alternativefiles($src, $exts){ * Check if video/audio is supported to be embedded. * * @param string $mime - mimetype of media file - * @param string $type - type of media files to check ('video', 'audio', or none) + * @param string $type - type of media files to check ('video', 'audio', or null for all) * @return boolean * * @author Anika Henke -- cgit v1.2.3 From 52a281e8549d1a9269ce7ced1336a567086962c5 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Wed, 10 Dec 2014 12:49:43 +0100 Subject: Some PHPDocs media and admin plugin --- inc/media.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'inc/media.php') diff --git a/inc/media.php b/inc/media.php index c77f3f952..09bfc99ac 100644 --- a/inc/media.php +++ b/inc/media.php @@ -383,20 +383,20 @@ function copy_uploaded_file($from, $to){ * (The triggered event is preventable.) * * Event data: - * $data[0] fn_tmp: the temporary file name (read from $_FILES) - * $data[1] fn: the file name of the uploaded file - * $data[2] id: the future directory id of the uploaded file - * $data[3] imime: the mimetype of the uploaded file + * $data[0] fn_tmp: the temporary file name (read from $_FILES) + * $data[1] fn: the file name of the uploaded file + * $data[2] id: the future directory id of the uploaded file + * $data[3] imime: the mimetype of the uploaded file * $data[4] overwrite: if an existing file is going to be overwritten - * $data[5] move: + * $data[5] move: name of function that performs move/copy/.. * * @triggers MEDIA_UPLOAD_FINISH * * @param array $file - * @param string $id + * @param string $id media id * @param bool $ow overwrite? * @param int $auth permission level - * @param string $move function name + * @param string $move name of functions that performs move/copy/.. * @return false|array|string */ function media_save($file, $id, $ow, $auth, $move) { -- cgit v1.2.3