[SPIP] v3.2.1-->v3.2.3
[lhc/web/www.git] / www / plugins-dist / medias / lib / getid3 / write.apetag.php
index d6044b2..7fc507c 100644 (file)
@@ -1,11 +1,11 @@
 <?php
+
 /////////////////////////////////////////////////////////////////
 /// getID3() by James Heinrich <info@getid3.org>               //
-//  available at http://getid3.sourceforge.net                 //
-//            or http://www.getid3.org                         //
-//          also https://github.com/JamesHeinrich/getID3       //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details                             //
+//  available at https://github.com/JamesHeinrich/getID3       //
+//            or https://www.getid3.org                        //
+//            or http://getid3.sourceforge.net                 //
+//  see readme.txt for more details                            //
 /////////////////////////////////////////////////////////////////
 //                                                             //
 // write.apetag.php                                            //
@@ -19,17 +19,43 @@ getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.apetag.php', __FILE
 
 class getid3_write_apetag
 {
-
+       /**
+        * @var string
+        */
        public $filename;
+
+       /**
+        * @var array
+        */
        public $tag_data;
-       public $always_preserve_replaygain = true;    // ReplayGain / MP3gain tags will be copied from old tag even if not passed in data
-       public $warnings                   = array(); // any non-critical errors will be stored here
-       public $errors                     = array(); // any critical errors will be stored here
+
+       /**
+        * ReplayGain / MP3gain tags will be copied from old tag even if not passed in data.
+        *
+        * @var bool
+        */
+       public $always_preserve_replaygain = true;
+
+       /**
+        * Any non-critical errors will be stored here.
+        *
+        * @var array
+        */
+       public $warnings                   = array();
+
+       /**
+        * Any critical errors will be stored here.
+        *
+        * @var array
+        */
+       public $errors                     = array();
 
        public function __construct() {
-               return true;
        }
 
+       /**
+        * @return bool
+        */
        public function WriteAPEtag() {
                // NOTE: All data passed to this function must be UTF-8 format
 
@@ -57,7 +83,7 @@ class getid3_write_apetag
                }
 
                if ($APEtag = $this->GenerateAPEtag()) {
-                       if (is_writable($this->filename) && is_file($this->filename) && ($fp = fopen($this->filename, 'a+b'))) {
+                       if (getID3::is_writable($this->filename) && is_file($this->filename) && ($fp = fopen($this->filename, 'a+b'))) {
                                $oldignoreuserabort = ignore_user_abort(true);
                                flock($fp, LOCK_EX);
 
@@ -92,11 +118,14 @@ class getid3_write_apetag
                return false;
        }
 
+       /**
+        * @return bool
+        */
        public function DeleteAPEtag() {
                $getID3 = new getID3;
                $ThisFileInfo = $getID3->analyze($this->filename);
                if (isset($ThisFileInfo['ape']['tag_offset_start']) && isset($ThisFileInfo['ape']['tag_offset_end'])) {
-                       if (is_writable($this->filename) && is_file($this->filename) && ($fp = fopen($this->filename, 'a+b'))) {
+                       if (getID3::is_writable($this->filename) && is_file($this->filename) && ($fp = fopen($this->filename, 'a+b'))) {
 
                                flock($fp, LOCK_EX);
                                $oldignoreuserabort = ignore_user_abort(true);
@@ -125,7 +154,9 @@ class getid3_write_apetag
                return true;
        }
 
-
+       /**
+        * @return string|false
+        */
        public function GenerateAPEtag() {
                // NOTE: All data passed to this function must be UTF-8 format
 
@@ -160,6 +191,12 @@ class getid3_write_apetag
                return $this->GenerateAPEtagHeaderFooter($items, true).implode('', $items).$this->GenerateAPEtagHeaderFooter($items, false);
        }
 
+       /**
+        * @param array $items
+        * @param bool  $isheader
+        *
+        * @return string
+        */
        public function GenerateAPEtagHeaderFooter(&$items, $isheader=false) {
                $tagdatalength = 0;
                foreach ($items as $itemdata) {
@@ -176,6 +213,15 @@ class getid3_write_apetag
                return $APEheader;
        }
 
+       /**
+        * @param bool $header
+        * @param bool $footer
+        * @param bool $isheader
+        * @param int  $encodingid
+        * @param bool $readonly
+        *
+        * @return string
+        */
        public function GenerateAPEtagFlags($header=true, $footer=true, $isheader=false, $encodingid=0, $readonly=false) {
                $APEtagFlags = array_fill(0, 4, 0);
                if ($header) {
@@ -201,6 +247,11 @@ class getid3_write_apetag
                return chr($APEtagFlags[3]).chr($APEtagFlags[2]).chr($APEtagFlags[1]).chr($APEtagFlags[0]);
        }
 
+       /**
+        * @param string $itemkey
+        *
+        * @return string
+        */
        public function CleanAPEtagItemKey($itemkey) {
                $itemkey = preg_replace("#[^\x20-\x7E]#i", '', $itemkey);