@@ -167,15 +167,18 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | if ($audio->get('language') !== null) { |
| 169 | 169 | $audioLanguage = $audio->get('language'); |
| 170 | - if (\is_array($audioLanguage)) { // If we have an array |
|
| 171 | - foreach ($audioLanguage as $language) { // search through the list |
|
| 170 | + if (\is_array($audioLanguage)) { |
|
| 171 | +// If we have an array |
|
| 172 | + foreach ($audioLanguage as $language) { |
|
| 173 | +// search through the list |
|
| 172 | 174 | if (\strlen($language) === 2) { |
| 173 | 175 | $audioLanguage = $language; // and use the first two letter code. |
| 174 | 176 | break; |
| 175 | 177 | } |
| 176 | 178 | } |
| 177 | 179 | |
| 178 | - if (\is_array($audioLanguage)) { // If it is still an array... |
|
| 180 | + if (\is_array($audioLanguage)) { |
|
| 181 | +// If it is still an array... |
|
| 179 | 182 | $audioLanguage = \implode(', ', $audioLanguage); // collapse it. |
| 180 | 183 | } |
| 181 | 184 | } |
@@ -304,7 +307,7 @@ discard block |
||
| 304 | 307 | $overallbitrate = $track['Overall_bit_rate']; |
| 305 | 308 | } |
| 306 | 309 | if (isset($track['Unique_ID'])) { |
| 307 | - if(preg_match('/\(0x(?P<hash>[0-9a-f]{32})\)/i', $track['Unique_ID'], $matches)){ |
|
| 310 | + if(preg_match('/\(0x(?P<hash>[0-9a-f]{32})\)/i', $track['Unique_ID'], $matches)) { |
|
| 308 | 311 | $uniqueid = $matches['hash']; |
| 309 | 312 | $this->addUID($releaseID, $uniqueid); |
| 310 | 313 | } |
@@ -6,9 +6,13 @@ |
||
| 6 | 6 | |
| 7 | 7 | class CountriesTest extends \lithium\test\Unit |
| 8 | 8 | { |
| 9 | - public function setUp() {} |
|
| 9 | + public function setUp() |
|
| 10 | + { |
|
| 11 | +} |
|
| 10 | 12 | |
| 11 | - public function tearDown() {} |
|
| 13 | + public function tearDown() |
|
| 14 | + { |
|
| 15 | +} |
|
| 12 | 16 | |
| 13 | 17 | |
| 14 | 18 | } |
@@ -6,15 +6,29 @@ |
||
| 6 | 6 | |
| 7 | 7 | class CountriesControllerTest extends \lithium\test\Unit |
| 8 | 8 | { |
| 9 | - public function setUp() {} |
|
| 9 | + public function setUp() |
|
| 10 | + { |
|
| 11 | +} |
|
| 10 | 12 | |
| 11 | - public function tearDown() {} |
|
| 13 | + public function tearDown() |
|
| 14 | + { |
|
| 15 | +} |
|
| 12 | 16 | |
| 13 | - public function testIndex() {} |
|
| 14 | - public function testView() {} |
|
| 15 | - public function testAdd() {} |
|
| 16 | - public function testEdit() {} |
|
| 17 | - public function testDelete() {} |
|
| 17 | + public function testIndex() |
|
| 18 | + { |
|
| 19 | +} |
|
| 20 | + public function testView() |
|
| 21 | + { |
|
| 22 | +} |
|
| 23 | + public function testAdd() |
|
| 24 | + { |
|
| 25 | +} |
|
| 26 | + public function testEdit() |
|
| 27 | + { |
|
| 28 | +} |
|
| 29 | + public function testDelete() |
|
| 30 | + { |
|
| 31 | +} |
|
| 18 | 32 | } |
| 19 | 33 | |
| 20 | 34 | ?> |
@@ -7,17 +7,20 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | class CountriesController extends \lithium\action\Controller |
| 9 | 9 | { |
| 10 | - public function index() { |
|
| 10 | + public function index() |
|
| 11 | + { |
|
| 11 | 12 | $countries = Countries::all(); |
| 12 | 13 | return compact('countries'); |
| 13 | 14 | } |
| 14 | 15 | |
| 15 | - public function view() { |
|
| 16 | + public function view() |
|
| 17 | + { |
|
| 16 | 18 | $country = Countries::first($this->request->id); |
| 17 | 19 | return compact('country'); |
| 18 | 20 | } |
| 19 | 21 | |
| 20 | - public function add() { |
|
| 22 | + public function add() |
|
| 23 | + { |
|
| 21 | 24 | $country = Countries::create(); |
| 22 | 25 | |
| 23 | 26 | if (($this->request->data) && $country->save($this->request->data)) { |
@@ -26,7 +29,8 @@ discard block |
||
| 26 | 29 | return compact('country'); |
| 27 | 30 | } |
| 28 | 31 | |
| 29 | - public function edit() { |
|
| 32 | + public function edit() |
|
| 33 | + { |
|
| 30 | 34 | $country = Countries::find($this->request->id); |
| 31 | 35 | |
| 32 | 36 | if (!$country) { |
@@ -38,7 +42,8 @@ discard block |
||
| 38 | 42 | return compact('country'); |
| 39 | 43 | } |
| 40 | 44 | |
| 41 | - public function delete() { |
|
| 45 | + public function delete() |
|
| 46 | + { |
|
| 42 | 47 | if (!$this->request->is('post') && !$this->request->is('delete')) { |
| 43 | 48 | $msg = "Countries::delete can only be called with http:post or http:delete."; |
| 44 | 49 | throw new DispatchException($msg); |
@@ -23,19 +23,23 @@ discard block |
||
| 23 | 23 | use lithium\action\DispatchException; |
| 24 | 24 | |
| 25 | 25 | |
| 26 | -class VideosController extends \lithium\action\Controller { |
|
| 26 | +class VideosController extends \lithium\action\Controller |
|
| 27 | +{ |
|
| 27 | 28 | |
| 28 | - public function index() { |
|
| 29 | + public function index() |
|
| 30 | + { |
|
| 29 | 31 | $videos = Videos::all(); |
| 30 | 32 | return compact('videos'); |
| 31 | 33 | } |
| 32 | 34 | |
| 33 | - public function view() { |
|
| 35 | + public function view() |
|
| 36 | + { |
|
| 34 | 37 | $video = Videos::first($this->request->id); |
| 35 | 38 | return compact('video'); |
| 36 | 39 | } |
| 37 | 40 | |
| 38 | - public function add() { |
|
| 41 | + public function add() |
|
| 42 | + { |
|
| 39 | 43 | $video = Videos::create(); |
| 40 | 44 | |
| 41 | 45 | if ($this->request->data && $video->save($this->request->data)) { |
@@ -44,7 +48,8 @@ discard block |
||
| 44 | 48 | return compact('video'); |
| 45 | 49 | } |
| 46 | 50 | |
| 47 | - public function edit() { |
|
| 51 | + public function edit() |
|
| 52 | + { |
|
| 48 | 53 | $video = Videos::find($this->request->id); |
| 49 | 54 | |
| 50 | 55 | if (!$video) { |
@@ -56,7 +61,8 @@ discard block |
||
| 56 | 61 | return compact('video'); |
| 57 | 62 | } |
| 58 | 63 | |
| 59 | - public function delete() { |
|
| 64 | + public function delete() |
|
| 65 | + { |
|
| 60 | 66 | if (!$this->request->is('post') && !$this->request->is('delete')) { |
| 61 | 67 | $msg = 'Videos::delete can only be called with http:post or http:delete.'; |
| 62 | 68 | throw new DispatchException($msg); |
@@ -246,8 +246,7 @@ discard block |
||
| 246 | 246 | { |
| 247 | 247 | $this->xml->startElement('categories'); |
| 248 | 248 | |
| 249 | - foreach ($this->server['categories'] AS $p) |
|
| 250 | - { |
|
| 249 | + foreach ($this->server['categories'] AS $p) { |
|
| 251 | 250 | $this->xml->startElement('category'); |
| 252 | 251 | $this->xml->writeAttribute('id', $p['id']); |
| 253 | 252 | $this->xml->writeAttribute('name', html_entity_decode($p['title'])); |
@@ -255,8 +254,7 @@ discard block |
||
| 255 | 254 | $this->xml->writeAttribute('description', html_entity_decode($p['description'])); |
| 256 | 255 | } |
| 257 | 256 | |
| 258 | - foreach($p['subcatlist'] AS $c) |
|
| 259 | - { |
|
| 257 | + foreach($p['subcatlist'] AS $c) { |
|
| 260 | 258 | $this->xml->startElement('subcat'); |
| 261 | 259 | $this->xml->writeAttribute('id', $c['id']); |
| 262 | 260 | $this->xml->writeAttribute('name', html_entity_decode($c['title'])); |
@@ -981,8 +981,7 @@ |
||
| 981 | 981 | $iterator = 0; |
| 982 | 982 | |
| 983 | 983 | // Loop over strings of headers. |
| 984 | - foreach ($data as $key => &$header) |
|
| 985 | - { |
|
| 984 | + foreach ($data as $key => &$header) { |
|
| 986 | 985 | // Split the individual headers by tab. |
| 987 | 986 | $header = explode("\t", $header); |
| 988 | 987 | |
@@ -109,15 +109,16 @@ discard block |
||
| 109 | 109 | $sql = 'LOAD DATA ' . $local . 'INFILE "%s" IGNORE INTO TABLE `%s` FIELDS TERMINATED BY "\t" ' . |
| 110 | 110 | $enclosedby . ' LINES TERMINATED BY "\r\n" IGNORE 1 LINES (%s)'; |
| 111 | 111 | foreach ($files as $file) { |
| 112 | - if ($show === true) |
|
| 113 | - { |
|
| 112 | + if ($show === true) { |
|
| 114 | 113 | echo "File: $file\n"; |
| 115 | 114 | } |
| 116 | 115 | |
| 117 | 116 | $fileTarget = '/tmp/' . pathinfo($file, PATHINFO_BASENAME); |
| 118 | - if (\copy($file, $fileTarget)) // Copy to a directory accessible to all (for mysql user) |
|
| 117 | + if (\copy($file, $fileTarget)) { |
|
| 118 | + // Copy to a directory accessible to all (for mysql user) |
|
| 119 | 119 | { |
| 120 | 120 | $file = $fileTarget; |
| 121 | + } |
|
| 121 | 122 | \chmod($file, 0775); |
| 122 | 123 | } else { |
| 123 | 124 | echo 'Failed to copy file: ' . $file . '</br>' . \PHP_EOL; |
@@ -125,28 +126,23 @@ discard block |
||
| 125 | 126 | } |
| 126 | 127 | |
| 127 | 128 | if (is_readable($file)) { |
| 128 | - if (preg_match($options['regex'], $file, $matches)) |
|
| 129 | - { |
|
| 129 | + if (preg_match($options['regex'], $file, $matches)) { |
|
| 130 | 130 | $table = $matches['table']; |
| 131 | 131 | // Get the first line of the file which holds the columns used. |
| 132 | 132 | $handle = @fopen($file, 'r'); |
| 133 | - if (is_resource($handle)) |
|
| 134 | - { |
|
| 133 | + if (is_resource($handle)) { |
|
| 135 | 134 | $line = fgets($handle); |
| 136 | 135 | fclose($handle); |
| 137 | - if ($line === false) |
|
| 138 | - { |
|
| 136 | + if ($line === false) { |
|
| 139 | 137 | echo "FAILED reading first line of '$file'\n"; |
| 140 | 138 | continue; |
| 141 | 139 | } |
| 142 | 140 | $fields = trim($line); |
| 143 | 141 | |
| 144 | - if ($show === true) |
|
| 145 | - { |
|
| 142 | + if ($show === true) { |
|
| 146 | 143 | echo "Inserting data into table: '$table'\n"; |
| 147 | 144 | } |
| 148 | - if (Misc::isWin()) |
|
| 149 | - { |
|
| 145 | + if (Misc::isWin()) { |
|
| 150 | 146 | $file = str_replace("\\", '\/', $file); |
| 151 | 147 | } |
| 152 | 148 | $this->pdo->exec(sprintf($sql, $file, $table, $fields)); |
@@ -775,8 +775,10 @@ discard block |
||
| 775 | 775 | //get attributes from all namespaces |
| 776 | 776 | foreach ($xml->attributes($namespace) as $attributeName => $attribute) { |
| 777 | 777 | //replace characters in attribute name |
| 778 | - if ($options['keySearch']) $attributeName = |
|
| 778 | + if ($options['keySearch']) { |
|
| 779 | + $attributeName = |
|
| 779 | 780 | str_replace($options['keySearch'], $options['keyReplace'], $attributeName); |
| 781 | + } |
|
| 780 | 782 | $attributeKey = $options['attributePrefix'] |
| 781 | 783 | . ($prefix ? $prefix . $options['namespaceSeparator'] : '') |
| 782 | 784 | . $attributeName; |
@@ -790,10 +792,14 @@ discard block |
||
| 790 | 792 | $childProperties = current($childArray); |
| 791 | 793 | |
| 792 | 794 | //replace characters in tag name |
| 793 | - if ($options['keySearch']) $childTagName = |
|
| 795 | + if ($options['keySearch']) { |
|
| 796 | + $childTagName = |
|
| 794 | 797 | str_replace($options['keySearch'], $options['keyReplace'], $childTagName); |
| 798 | + } |
|
| 795 | 799 | //add namespace prefix, if any |
| 796 | - if ($prefix) $childTagName = $prefix . $options['namespaceSeparator'] . $childTagName; |
|
| 800 | + if ($prefix) { |
|
| 801 | + $childTagName = $prefix . $options['namespaceSeparator'] . $childTagName; |
|
| 802 | + } |
|
| 797 | 803 | |
| 798 | 804 | if (!isset($tagsArray[$childTagName])) { |
| 799 | 805 | //only entry with this key |
@@ -817,7 +823,9 @@ discard block |
||
| 817 | 823 | //get text content of node |
| 818 | 824 | $textContentArray = array(); |
| 819 | 825 | $plainText = trim((string)$xml); |
| 820 | - if ($plainText !== '') $textContentArray[$options['textContent']] = $plainText; |
|
| 826 | + if ($plainText !== '') { |
|
| 827 | + $textContentArray[$options['textContent']] = $plainText; |
|
| 828 | + } |
|
| 821 | 829 | |
| 822 | 830 | //stick it all together |
| 823 | 831 | $propertiesArray = !$options['autoText'] || $attributesArray || $tagsArray || ($plainText === '') |