| Conditions | 356 |
| Paths | > 20000 |
| Total Lines | 1799 |
| Code Lines | 940 |
| Lines | 932 |
| Ratio | 51.81 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 1086 | public function get_enclosures() |
||
| 1087 | { |
||
| 1088 | if (!isset($this->data['enclosures'])) |
||
| 1089 | { |
||
| 1090 | $this->data['enclosures'] = array(); |
||
| 1091 | |||
| 1092 | // Elements |
||
| 1093 | $captions_parent = null; |
||
| 1094 | $categories_parent = null; |
||
| 1095 | $copyrights_parent = null; |
||
| 1096 | $credits_parent = null; |
||
| 1097 | $description_parent = null; |
||
| 1098 | $duration_parent = null; |
||
| 1099 | $hashes_parent = null; |
||
| 1100 | $keywords_parent = null; |
||
| 1101 | $player_parent = null; |
||
| 1102 | $ratings_parent = null; |
||
| 1103 | $restrictions_parent = null; |
||
| 1104 | $thumbnails_parent = null; |
||
| 1105 | $title_parent = null; |
||
| 1106 | |||
| 1107 | // Let's do the channel and item-level ones first, and just re-use them if we need to. |
||
| 1108 | $parent = $this->get_feed(); |
||
| 1109 | |||
| 1110 | // CAPTIONS |
||
| 1111 | if ($captions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text')) |
||
| 1112 | { |
||
| 1113 | foreach ($captions as $caption) |
||
| 1114 | { |
||
| 1115 | $caption_type = null; |
||
| 1116 | $caption_lang = null; |
||
| 1117 | $caption_startTime = null; |
||
| 1118 | $caption_endTime = null; |
||
| 1119 | $caption_text = null; |
||
| 1120 | if (isset($caption['attribs']['']['type'])) |
||
| 1121 | { |
||
| 1122 | $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1123 | } |
||
| 1124 | if (isset($caption['attribs']['']['lang'])) |
||
| 1125 | { |
||
| 1126 | $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1127 | } |
||
| 1128 | if (isset($caption['attribs']['']['start'])) |
||
| 1129 | { |
||
| 1130 | $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1131 | } |
||
| 1132 | if (isset($caption['attribs']['']['end'])) |
||
| 1133 | { |
||
| 1134 | $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1135 | } |
||
| 1136 | if (isset($caption['data'])) |
||
| 1137 | { |
||
| 1138 | $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1139 | } |
||
| 1140 | $captions_parent[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text)); |
||
| 1141 | } |
||
| 1142 | } |
||
| 1143 | elseif ($captions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text')) |
||
| 1144 | { |
||
| 1145 | foreach ($captions as $caption) |
||
| 1146 | { |
||
| 1147 | $caption_type = null; |
||
| 1148 | $caption_lang = null; |
||
| 1149 | $caption_startTime = null; |
||
| 1150 | $caption_endTime = null; |
||
| 1151 | $caption_text = null; |
||
| 1152 | if (isset($caption['attribs']['']['type'])) |
||
| 1153 | { |
||
| 1154 | $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1155 | } |
||
| 1156 | if (isset($caption['attribs']['']['lang'])) |
||
| 1157 | { |
||
| 1158 | $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1159 | } |
||
| 1160 | if (isset($caption['attribs']['']['start'])) |
||
| 1161 | { |
||
| 1162 | $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1163 | } |
||
| 1164 | if (isset($caption['attribs']['']['end'])) |
||
| 1165 | { |
||
| 1166 | $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1167 | } |
||
| 1168 | if (isset($caption['data'])) |
||
| 1169 | { |
||
| 1170 | $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1171 | } |
||
| 1172 | $captions_parent[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text)); |
||
| 1173 | } |
||
| 1174 | } |
||
| 1175 | if (is_array($captions_parent)) |
||
| 1176 | { |
||
| 1177 | $captions_parent = array_values(array_unique($captions_parent)); |
||
| 1178 | } |
||
| 1179 | |||
| 1180 | // CATEGORIES |
||
| 1181 | foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category) |
||
| 1182 | { |
||
| 1183 | $term = null; |
||
| 1184 | $scheme = null; |
||
| 1185 | $label = null; |
||
| 1186 | if (isset($category['data'])) |
||
| 1187 | { |
||
| 1188 | $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1189 | } |
||
| 1190 | if (isset($category['attribs']['']['scheme'])) |
||
| 1191 | { |
||
| 1192 | $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1193 | } |
||
| 1194 | else |
||
| 1195 | { |
||
| 1196 | $scheme = 'http://search.yahoo.com/mrss/category_schema'; |
||
| 1197 | } |
||
| 1198 | if (isset($category['attribs']['']['label'])) |
||
| 1199 | { |
||
| 1200 | $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1201 | } |
||
| 1202 | $categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label)); |
||
| 1203 | } |
||
| 1204 | foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category) |
||
| 1205 | { |
||
| 1206 | $term = null; |
||
| 1207 | $scheme = null; |
||
| 1208 | $label = null; |
||
| 1209 | if (isset($category['data'])) |
||
| 1210 | { |
||
| 1211 | $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1212 | } |
||
| 1213 | if (isset($category['attribs']['']['scheme'])) |
||
| 1214 | { |
||
| 1215 | $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1216 | } |
||
| 1217 | else |
||
| 1218 | { |
||
| 1219 | $scheme = 'http://search.yahoo.com/mrss/category_schema'; |
||
| 1220 | } |
||
| 1221 | if (isset($category['attribs']['']['label'])) |
||
| 1222 | { |
||
| 1223 | $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1224 | } |
||
| 1225 | $categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label)); |
||
| 1226 | } |
||
| 1227 | foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'category') as $category) |
||
| 1228 | { |
||
| 1229 | $term = null; |
||
| 1230 | $scheme = 'http://www.itunes.com/dtds/podcast-1.0.dtd'; |
||
| 1231 | $label = null; |
||
| 1232 | if (isset($category['attribs']['']['text'])) |
||
| 1233 | { |
||
| 1234 | $label = $this->sanitize($category['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1235 | } |
||
| 1236 | $categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label)); |
||
| 1237 | |||
| 1238 | if (isset($category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'])) |
||
| 1239 | { |
||
| 1240 | foreach ((array) $category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'] as $subcategory) |
||
| 1241 | { |
||
| 1242 | if (isset($subcategory['attribs']['']['text'])) |
||
| 1243 | { |
||
| 1244 | $label = $this->sanitize($subcategory['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1245 | } |
||
| 1246 | $categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label)); |
||
| 1247 | } |
||
| 1248 | } |
||
| 1249 | } |
||
| 1250 | if (is_array($categories_parent)) |
||
| 1251 | { |
||
| 1252 | $categories_parent = array_values(array_unique($categories_parent)); |
||
| 1253 | } |
||
| 1254 | |||
| 1255 | // COPYRIGHT |
||
| 1256 | if ($copyright = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright')) |
||
| 1257 | { |
||
| 1258 | $copyright_url = null; |
||
| 1259 | $copyright_label = null; |
||
| 1260 | if (isset($copyright[0]['attribs']['']['url'])) |
||
| 1261 | { |
||
| 1262 | $copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1263 | } |
||
| 1264 | if (isset($copyright[0]['data'])) |
||
| 1265 | { |
||
| 1266 | $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1267 | } |
||
| 1268 | $copyrights_parent = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); |
||
| 1269 | } |
||
| 1270 | elseif ($copyright = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright')) |
||
| 1271 | { |
||
| 1272 | $copyright_url = null; |
||
| 1273 | $copyright_label = null; |
||
| 1274 | if (isset($copyright[0]['attribs']['']['url'])) |
||
| 1275 | { |
||
| 1276 | $copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1277 | } |
||
| 1278 | if (isset($copyright[0]['data'])) |
||
| 1279 | { |
||
| 1280 | $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1281 | } |
||
| 1282 | $copyrights_parent = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); |
||
| 1283 | } |
||
| 1284 | |||
| 1285 | // CREDITS |
||
| 1286 | if ($credits = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit')) |
||
| 1287 | { |
||
| 1288 | foreach ($credits as $credit) |
||
| 1289 | { |
||
| 1290 | $credit_role = null; |
||
| 1291 | $credit_scheme = null; |
||
| 1292 | $credit_name = null; |
||
| 1293 | if (isset($credit['attribs']['']['role'])) |
||
| 1294 | { |
||
| 1295 | $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1296 | } |
||
| 1297 | if (isset($credit['attribs']['']['scheme'])) |
||
| 1298 | { |
||
| 1299 | $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1300 | } |
||
| 1301 | else |
||
| 1302 | { |
||
| 1303 | $credit_scheme = 'urn:ebu'; |
||
| 1304 | } |
||
| 1305 | if (isset($credit['data'])) |
||
| 1306 | { |
||
| 1307 | $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1308 | } |
||
| 1309 | $credits_parent[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name)); |
||
| 1310 | } |
||
| 1311 | } |
||
| 1312 | elseif ($credits = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit')) |
||
| 1313 | { |
||
| 1314 | foreach ($credits as $credit) |
||
| 1315 | { |
||
| 1316 | $credit_role = null; |
||
| 1317 | $credit_scheme = null; |
||
| 1318 | $credit_name = null; |
||
| 1319 | if (isset($credit['attribs']['']['role'])) |
||
| 1320 | { |
||
| 1321 | $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1322 | } |
||
| 1323 | if (isset($credit['attribs']['']['scheme'])) |
||
| 1324 | { |
||
| 1325 | $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1326 | } |
||
| 1327 | else |
||
| 1328 | { |
||
| 1329 | $credit_scheme = 'urn:ebu'; |
||
| 1330 | } |
||
| 1331 | if (isset($credit['data'])) |
||
| 1332 | { |
||
| 1333 | $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1334 | } |
||
| 1335 | $credits_parent[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name)); |
||
| 1336 | } |
||
| 1337 | } |
||
| 1338 | if (is_array($credits_parent)) |
||
| 1339 | { |
||
| 1340 | $credits_parent = array_values(array_unique($credits_parent)); |
||
| 1341 | } |
||
| 1342 | |||
| 1343 | // DESCRIPTION |
||
| 1344 | if ($description_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description')) |
||
| 1345 | { |
||
| 1346 | if (isset($description_parent[0]['data'])) |
||
| 1347 | { |
||
| 1348 | $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1349 | } |
||
| 1350 | } |
||
| 1351 | elseif ($description_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description')) |
||
| 1352 | { |
||
| 1353 | if (isset($description_parent[0]['data'])) |
||
| 1354 | { |
||
| 1355 | $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1356 | } |
||
| 1357 | } |
||
| 1358 | |||
| 1359 | // DURATION |
||
| 1360 | if ($duration_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'duration')) |
||
| 1361 | { |
||
| 1362 | $seconds = null; |
||
| 1363 | $minutes = null; |
||
| 1364 | $hours = null; |
||
| 1365 | if (isset($duration_parent[0]['data'])) |
||
| 1366 | { |
||
| 1367 | $temp = explode(':', $this->sanitize($duration_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); |
||
| 1368 | if (sizeof($temp) > 0) |
||
| 1369 | { |
||
| 1370 | $seconds = (int) array_pop($temp); |
||
| 1371 | } |
||
| 1372 | if (sizeof($temp) > 0) |
||
| 1373 | { |
||
| 1374 | $minutes = (int) array_pop($temp); |
||
| 1375 | $seconds += $minutes * 60; |
||
| 1376 | } |
||
| 1377 | if (sizeof($temp) > 0) |
||
| 1378 | { |
||
| 1379 | $hours = (int) array_pop($temp); |
||
| 1380 | $seconds += $hours * 3600; |
||
| 1381 | } |
||
| 1382 | unset($temp); |
||
| 1383 | $duration_parent = $seconds; |
||
| 1384 | } |
||
| 1385 | } |
||
| 1386 | |||
| 1387 | // HASHES |
||
| 1388 | if ($hashes_iterator = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash')) |
||
| 1389 | { |
||
| 1390 | foreach ($hashes_iterator as $hash) |
||
| 1391 | { |
||
| 1392 | $value = null; |
||
| 1393 | $algo = null; |
||
| 1394 | if (isset($hash['data'])) |
||
| 1395 | { |
||
| 1396 | $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1397 | } |
||
| 1398 | if (isset($hash['attribs']['']['algo'])) |
||
| 1399 | { |
||
| 1400 | $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1401 | } |
||
| 1402 | else |
||
| 1403 | { |
||
| 1404 | $algo = 'md5'; |
||
| 1405 | } |
||
| 1406 | $hashes_parent[] = $algo.':'.$value; |
||
| 1407 | } |
||
| 1408 | } |
||
| 1409 | elseif ($hashes_iterator = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash')) |
||
| 1410 | { |
||
| 1411 | foreach ($hashes_iterator as $hash) |
||
| 1412 | { |
||
| 1413 | $value = null; |
||
| 1414 | $algo = null; |
||
| 1415 | if (isset($hash['data'])) |
||
| 1416 | { |
||
| 1417 | $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1418 | } |
||
| 1419 | if (isset($hash['attribs']['']['algo'])) |
||
| 1420 | { |
||
| 1421 | $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1422 | } |
||
| 1423 | else |
||
| 1424 | { |
||
| 1425 | $algo = 'md5'; |
||
| 1426 | } |
||
| 1427 | $hashes_parent[] = $algo.':'.$value; |
||
| 1428 | } |
||
| 1429 | } |
||
| 1430 | if (is_array($hashes_parent)) |
||
| 1431 | { |
||
| 1432 | $hashes_parent = array_values(array_unique($hashes_parent)); |
||
| 1433 | } |
||
| 1434 | |||
| 1435 | // KEYWORDS |
||
| 1436 | if ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords')) |
||
| 1437 | { |
||
| 1438 | if (isset($keywords[0]['data'])) |
||
| 1439 | { |
||
| 1440 | $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); |
||
| 1441 | foreach ($temp as $word) |
||
| 1442 | { |
||
| 1443 | $keywords_parent[] = trim($word); |
||
| 1444 | } |
||
| 1445 | } |
||
| 1446 | unset($temp); |
||
| 1447 | } |
||
| 1448 | elseif ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords')) |
||
| 1449 | { |
||
| 1450 | if (isset($keywords[0]['data'])) |
||
| 1451 | { |
||
| 1452 | $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); |
||
| 1453 | foreach ($temp as $word) |
||
| 1454 | { |
||
| 1455 | $keywords_parent[] = trim($word); |
||
| 1456 | } |
||
| 1457 | } |
||
| 1458 | unset($temp); |
||
| 1459 | } |
||
| 1460 | elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords')) |
||
| 1461 | { |
||
| 1462 | if (isset($keywords[0]['data'])) |
||
| 1463 | { |
||
| 1464 | $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); |
||
| 1465 | foreach ($temp as $word) |
||
| 1466 | { |
||
| 1467 | $keywords_parent[] = trim($word); |
||
| 1468 | } |
||
| 1469 | } |
||
| 1470 | unset($temp); |
||
| 1471 | } |
||
| 1472 | elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords')) |
||
| 1473 | { |
||
| 1474 | if (isset($keywords[0]['data'])) |
||
| 1475 | { |
||
| 1476 | $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); |
||
| 1477 | foreach ($temp as $word) |
||
| 1478 | { |
||
| 1479 | $keywords_parent[] = trim($word); |
||
| 1480 | } |
||
| 1481 | } |
||
| 1482 | unset($temp); |
||
| 1483 | } |
||
| 1484 | if (is_array($keywords_parent)) |
||
| 1485 | { |
||
| 1486 | $keywords_parent = array_values(array_unique($keywords_parent)); |
||
| 1487 | } |
||
| 1488 | |||
| 1489 | // PLAYER |
||
| 1490 | if ($player_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player')) |
||
| 1491 | { |
||
| 1492 | if (isset($player_parent[0]['attribs']['']['url'])) |
||
| 1493 | { |
||
| 1494 | $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
||
| 1495 | } |
||
| 1496 | } |
||
| 1497 | elseif ($player_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player')) |
||
| 1498 | { |
||
| 1499 | if (isset($player_parent[0]['attribs']['']['url'])) |
||
| 1500 | { |
||
| 1501 | $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
||
| 1502 | } |
||
| 1503 | } |
||
| 1504 | |||
| 1505 | // RATINGS |
||
| 1506 | if ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating')) |
||
| 1507 | { |
||
| 1508 | foreach ($ratings as $rating) |
||
| 1509 | { |
||
| 1510 | $rating_scheme = null; |
||
| 1511 | $rating_value = null; |
||
| 1512 | if (isset($rating['attribs']['']['scheme'])) |
||
| 1513 | { |
||
| 1514 | $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1515 | } |
||
| 1516 | else |
||
| 1517 | { |
||
| 1518 | $rating_scheme = 'urn:simple'; |
||
| 1519 | } |
||
| 1520 | if (isset($rating['data'])) |
||
| 1521 | { |
||
| 1522 | $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1523 | } |
||
| 1524 | $ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); |
||
| 1525 | } |
||
| 1526 | } |
||
| 1527 | elseif ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) |
||
| 1528 | { |
||
| 1529 | foreach ($ratings as $rating) |
||
| 1530 | { |
||
| 1531 | $rating_scheme = 'urn:itunes'; |
||
| 1532 | $rating_value = null; |
||
| 1533 | if (isset($rating['data'])) |
||
| 1534 | { |
||
| 1535 | $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1536 | } |
||
| 1537 | $ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); |
||
| 1538 | } |
||
| 1539 | } |
||
| 1540 | elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating')) |
||
| 1541 | { |
||
| 1542 | foreach ($ratings as $rating) |
||
| 1543 | { |
||
| 1544 | $rating_scheme = null; |
||
| 1545 | $rating_value = null; |
||
| 1546 | if (isset($rating['attribs']['']['scheme'])) |
||
| 1547 | { |
||
| 1548 | $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1549 | } |
||
| 1550 | else |
||
| 1551 | { |
||
| 1552 | $rating_scheme = 'urn:simple'; |
||
| 1553 | } |
||
| 1554 | if (isset($rating['data'])) |
||
| 1555 | { |
||
| 1556 | $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1557 | } |
||
| 1558 | $ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); |
||
| 1559 | } |
||
| 1560 | } |
||
| 1561 | elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) |
||
| 1562 | { |
||
| 1563 | foreach ($ratings as $rating) |
||
| 1564 | { |
||
| 1565 | $rating_scheme = 'urn:itunes'; |
||
| 1566 | $rating_value = null; |
||
| 1567 | if (isset($rating['data'])) |
||
| 1568 | { |
||
| 1569 | $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1570 | } |
||
| 1571 | $ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); |
||
| 1572 | } |
||
| 1573 | } |
||
| 1574 | if (is_array($ratings_parent)) |
||
| 1575 | { |
||
| 1576 | $ratings_parent = array_values(array_unique($ratings_parent)); |
||
| 1577 | } |
||
| 1578 | |||
| 1579 | // RESTRICTIONS |
||
| 1580 | if ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction')) |
||
| 1581 | { |
||
| 1582 | foreach ($restrictions as $restriction) |
||
| 1583 | { |
||
| 1584 | $restriction_relationship = null; |
||
| 1585 | $restriction_type = null; |
||
| 1586 | $restriction_value = null; |
||
| 1587 | if (isset($restriction['attribs']['']['relationship'])) |
||
| 1588 | { |
||
| 1589 | $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1590 | } |
||
| 1591 | if (isset($restriction['attribs']['']['type'])) |
||
| 1592 | { |
||
| 1593 | $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1594 | } |
||
| 1595 | if (isset($restriction['data'])) |
||
| 1596 | { |
||
| 1597 | $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1598 | } |
||
| 1599 | $restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); |
||
| 1600 | } |
||
| 1601 | } |
||
| 1602 | elseif ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) |
||
| 1603 | { |
||
| 1604 | foreach ($restrictions as $restriction) |
||
| 1605 | { |
||
| 1606 | $restriction_relationship = 'allow'; |
||
| 1607 | $restriction_type = null; |
||
| 1608 | $restriction_value = 'itunes'; |
||
| 1609 | if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') |
||
| 1610 | { |
||
| 1611 | $restriction_relationship = 'deny'; |
||
| 1612 | } |
||
| 1613 | $restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); |
||
| 1614 | } |
||
| 1615 | } |
||
| 1616 | elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction')) |
||
| 1617 | { |
||
| 1618 | foreach ($restrictions as $restriction) |
||
| 1619 | { |
||
| 1620 | $restriction_relationship = null; |
||
| 1621 | $restriction_type = null; |
||
| 1622 | $restriction_value = null; |
||
| 1623 | if (isset($restriction['attribs']['']['relationship'])) |
||
| 1624 | { |
||
| 1625 | $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1626 | } |
||
| 1627 | if (isset($restriction['attribs']['']['type'])) |
||
| 1628 | { |
||
| 1629 | $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1630 | } |
||
| 1631 | if (isset($restriction['data'])) |
||
| 1632 | { |
||
| 1633 | $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1634 | } |
||
| 1635 | $restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); |
||
| 1636 | } |
||
| 1637 | } |
||
| 1638 | elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) |
||
| 1639 | { |
||
| 1640 | foreach ($restrictions as $restriction) |
||
| 1641 | { |
||
| 1642 | $restriction_relationship = 'allow'; |
||
| 1643 | $restriction_type = null; |
||
| 1644 | $restriction_value = 'itunes'; |
||
| 1645 | if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') |
||
| 1646 | { |
||
| 1647 | $restriction_relationship = 'deny'; |
||
| 1648 | } |
||
| 1649 | $restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); |
||
| 1650 | } |
||
| 1651 | } |
||
| 1652 | if (is_array($restrictions_parent)) |
||
| 1653 | { |
||
| 1654 | $restrictions_parent = array_values(array_unique($restrictions_parent)); |
||
| 1655 | } |
||
| 1656 | else |
||
| 1657 | { |
||
| 1658 | $restrictions_parent = array(new SimplePie_Restriction('allow', null, 'default')); |
||
| 1659 | } |
||
| 1660 | |||
| 1661 | // THUMBNAILS |
||
| 1662 | if ($thumbnails = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail')) |
||
| 1663 | { |
||
| 1664 | foreach ($thumbnails as $thumbnail) |
||
| 1665 | { |
||
| 1666 | if (isset($thumbnail['attribs']['']['url'])) |
||
| 1667 | { |
||
| 1668 | $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
||
| 1669 | } |
||
| 1670 | } |
||
| 1671 | } |
||
| 1672 | elseif ($thumbnails = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail')) |
||
| 1673 | { |
||
| 1674 | foreach ($thumbnails as $thumbnail) |
||
| 1675 | { |
||
| 1676 | if (isset($thumbnail['attribs']['']['url'])) |
||
| 1677 | { |
||
| 1678 | $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
||
| 1679 | } |
||
| 1680 | } |
||
| 1681 | } |
||
| 1682 | |||
| 1683 | // TITLES |
||
| 1684 | if ($title_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title')) |
||
| 1685 | { |
||
| 1686 | if (isset($title_parent[0]['data'])) |
||
| 1687 | { |
||
| 1688 | $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1689 | } |
||
| 1690 | } |
||
| 1691 | elseif ($title_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title')) |
||
| 1692 | { |
||
| 1693 | if (isset($title_parent[0]['data'])) |
||
| 1694 | { |
||
| 1695 | $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1696 | } |
||
| 1697 | } |
||
| 1698 | |||
| 1699 | // Clear the memory |
||
| 1700 | unset($parent); |
||
| 1701 | |||
| 1702 | // Attributes |
||
| 1703 | $bitrate = null; |
||
| 1704 | $channels = null; |
||
| 1705 | $duration = null; |
||
| 1706 | $expression = null; |
||
| 1707 | $framerate = null; |
||
| 1708 | $height = null; |
||
| 1709 | $javascript = null; |
||
| 1710 | $lang = null; |
||
| 1711 | $length = null; |
||
| 1712 | $medium = null; |
||
| 1713 | $samplingrate = null; |
||
| 1714 | $type = null; |
||
| 1715 | $url = null; |
||
| 1716 | $width = null; |
||
| 1717 | |||
| 1718 | // Elements |
||
| 1719 | $captions = null; |
||
| 1720 | $categories = null; |
||
| 1721 | $copyrights = null; |
||
| 1722 | $credits = null; |
||
| 1723 | $description = null; |
||
| 1724 | $hashes = null; |
||
| 1725 | $keywords = null; |
||
| 1726 | $player = null; |
||
| 1727 | $ratings = null; |
||
| 1728 | $restrictions = null; |
||
| 1729 | $thumbnails = null; |
||
| 1730 | $title = null; |
||
| 1731 | |||
| 1732 | // If we have media:group tags, loop through them. |
||
| 1733 | foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group) |
||
| 1734 | { |
||
| 1735 | if(isset($group['child']) && isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'])) |
||
| 1736 | { |
||
| 1737 | // If we have media:content tags, loop through them. |
||
| 1738 | foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content) |
||
| 1739 | { |
||
| 1740 | if (isset($content['attribs']['']['url'])) |
||
| 1741 | { |
||
| 1742 | // Attributes |
||
| 1743 | $bitrate = null; |
||
| 1744 | $channels = null; |
||
| 1745 | $duration = null; |
||
| 1746 | $expression = null; |
||
| 1747 | $framerate = null; |
||
| 1748 | $height = null; |
||
| 1749 | $javascript = null; |
||
| 1750 | $lang = null; |
||
| 1751 | $length = null; |
||
| 1752 | $medium = null; |
||
| 1753 | $samplingrate = null; |
||
| 1754 | $type = null; |
||
| 1755 | $url = null; |
||
| 1756 | $width = null; |
||
| 1757 | |||
| 1758 | // Elements |
||
| 1759 | $captions = null; |
||
| 1760 | $categories = null; |
||
| 1761 | $copyrights = null; |
||
| 1762 | $credits = null; |
||
| 1763 | $description = null; |
||
| 1764 | $hashes = null; |
||
| 1765 | $keywords = null; |
||
| 1766 | $player = null; |
||
| 1767 | $ratings = null; |
||
| 1768 | $restrictions = null; |
||
| 1769 | $thumbnails = null; |
||
| 1770 | $title = null; |
||
| 1771 | |||
| 1772 | // Start checking the attributes of media:content |
||
| 1773 | if (isset($content['attribs']['']['bitrate'])) |
||
| 1774 | { |
||
| 1775 | $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1776 | } |
||
| 1777 | if (isset($content['attribs']['']['channels'])) |
||
| 1778 | { |
||
| 1779 | $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1780 | } |
||
| 1781 | if (isset($content['attribs']['']['duration'])) |
||
| 1782 | { |
||
| 1783 | $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1784 | } |
||
| 1785 | else |
||
| 1786 | { |
||
| 1787 | $duration = $duration_parent; |
||
| 1788 | } |
||
| 1789 | if (isset($content['attribs']['']['expression'])) |
||
| 1790 | { |
||
| 1791 | $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1792 | } |
||
| 1793 | if (isset($content['attribs']['']['framerate'])) |
||
| 1794 | { |
||
| 1795 | $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1796 | } |
||
| 1797 | if (isset($content['attribs']['']['height'])) |
||
| 1798 | { |
||
| 1799 | $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1800 | } |
||
| 1801 | if (isset($content['attribs']['']['lang'])) |
||
| 1802 | { |
||
| 1803 | $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1804 | } |
||
| 1805 | if (isset($content['attribs']['']['fileSize'])) |
||
| 1806 | { |
||
| 1807 | $length = ceil($content['attribs']['']['fileSize']); |
||
| 1808 | } |
||
| 1809 | if (isset($content['attribs']['']['medium'])) |
||
| 1810 | { |
||
| 1811 | $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1812 | } |
||
| 1813 | if (isset($content['attribs']['']['samplingrate'])) |
||
| 1814 | { |
||
| 1815 | $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1816 | } |
||
| 1817 | if (isset($content['attribs']['']['type'])) |
||
| 1818 | { |
||
| 1819 | $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1820 | } |
||
| 1821 | if (isset($content['attribs']['']['width'])) |
||
| 1822 | { |
||
| 1823 | $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1824 | } |
||
| 1825 | $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
||
| 1826 | |||
| 1827 | // Checking the other optional media: elements. Priority: media:content, media:group, item, channel |
||
| 1828 | |||
| 1829 | // CAPTIONS |
||
| 1830 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) |
||
| 1831 | { |
||
| 1832 | foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) |
||
| 1833 | { |
||
| 1834 | $caption_type = null; |
||
| 1835 | $caption_lang = null; |
||
| 1836 | $caption_startTime = null; |
||
| 1837 | $caption_endTime = null; |
||
| 1838 | $caption_text = null; |
||
| 1839 | if (isset($caption['attribs']['']['type'])) |
||
| 1840 | { |
||
| 1841 | $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1842 | } |
||
| 1843 | if (isset($caption['attribs']['']['lang'])) |
||
| 1844 | { |
||
| 1845 | $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1846 | } |
||
| 1847 | if (isset($caption['attribs']['']['start'])) |
||
| 1848 | { |
||
| 1849 | $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1850 | } |
||
| 1851 | if (isset($caption['attribs']['']['end'])) |
||
| 1852 | { |
||
| 1853 | $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1854 | } |
||
| 1855 | if (isset($caption['data'])) |
||
| 1856 | { |
||
| 1857 | $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1858 | } |
||
| 1859 | $captions[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text)); |
||
| 1860 | } |
||
| 1861 | if (is_array($captions)) |
||
| 1862 | { |
||
| 1863 | $captions = array_values(array_unique($captions)); |
||
| 1864 | } |
||
| 1865 | } |
||
| 1866 | elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) |
||
| 1867 | { |
||
| 1868 | foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) |
||
| 1869 | { |
||
| 1870 | $caption_type = null; |
||
| 1871 | $caption_lang = null; |
||
| 1872 | $caption_startTime = null; |
||
| 1873 | $caption_endTime = null; |
||
| 1874 | $caption_text = null; |
||
| 1875 | if (isset($caption['attribs']['']['type'])) |
||
| 1876 | { |
||
| 1877 | $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1878 | } |
||
| 1879 | if (isset($caption['attribs']['']['lang'])) |
||
| 1880 | { |
||
| 1881 | $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1882 | } |
||
| 1883 | if (isset($caption['attribs']['']['start'])) |
||
| 1884 | { |
||
| 1885 | $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1886 | } |
||
| 1887 | if (isset($caption['attribs']['']['end'])) |
||
| 1888 | { |
||
| 1889 | $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1890 | } |
||
| 1891 | if (isset($caption['data'])) |
||
| 1892 | { |
||
| 1893 | $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1894 | } |
||
| 1895 | $captions[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text)); |
||
| 1896 | } |
||
| 1897 | if (is_array($captions)) |
||
| 1898 | { |
||
| 1899 | $captions = array_values(array_unique($captions)); |
||
| 1900 | } |
||
| 1901 | } |
||
| 1902 | else |
||
| 1903 | { |
||
| 1904 | $captions = $captions_parent; |
||
| 1905 | } |
||
| 1906 | |||
| 1907 | // CATEGORIES |
||
| 1908 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) |
||
| 1909 | { |
||
| 1910 | foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) |
||
| 1911 | { |
||
| 1912 | $term = null; |
||
| 1913 | $scheme = null; |
||
| 1914 | $label = null; |
||
| 1915 | if (isset($category['data'])) |
||
| 1916 | { |
||
| 1917 | $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1918 | } |
||
| 1919 | if (isset($category['attribs']['']['scheme'])) |
||
| 1920 | { |
||
| 1921 | $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1922 | } |
||
| 1923 | else |
||
| 1924 | { |
||
| 1925 | $scheme = 'http://search.yahoo.com/mrss/category_schema'; |
||
| 1926 | } |
||
| 1927 | if (isset($category['attribs']['']['label'])) |
||
| 1928 | { |
||
| 1929 | $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1930 | } |
||
| 1931 | $categories[] = $this->registry->create('Category', array($term, $scheme, $label)); |
||
| 1932 | } |
||
| 1933 | } |
||
| 1934 | if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) |
||
| 1935 | { |
||
| 1936 | foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) |
||
| 1937 | { |
||
| 1938 | $term = null; |
||
| 1939 | $scheme = null; |
||
| 1940 | $label = null; |
||
| 1941 | if (isset($category['data'])) |
||
| 1942 | { |
||
| 1943 | $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1944 | } |
||
| 1945 | if (isset($category['attribs']['']['scheme'])) |
||
| 1946 | { |
||
| 1947 | $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1948 | } |
||
| 1949 | else |
||
| 1950 | { |
||
| 1951 | $scheme = 'http://search.yahoo.com/mrss/category_schema'; |
||
| 1952 | } |
||
| 1953 | if (isset($category['attribs']['']['label'])) |
||
| 1954 | { |
||
| 1955 | $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1956 | } |
||
| 1957 | $categories[] = $this->registry->create('Category', array($term, $scheme, $label)); |
||
| 1958 | } |
||
| 1959 | } |
||
| 1960 | if (is_array($categories) && is_array($categories_parent)) |
||
| 1961 | { |
||
| 1962 | $categories = array_values(array_unique(array_merge($categories, $categories_parent))); |
||
| 1963 | } |
||
| 1964 | elseif (is_array($categories)) |
||
| 1965 | { |
||
| 1966 | $categories = array_values(array_unique($categories)); |
||
| 1967 | } |
||
| 1968 | elseif (is_array($categories_parent)) |
||
| 1969 | { |
||
| 1970 | $categories = array_values(array_unique($categories_parent)); |
||
| 1971 | } |
||
| 1972 | |||
| 1973 | // COPYRIGHTS |
||
| 1974 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) |
||
| 1975 | { |
||
| 1976 | $copyright_url = null; |
||
| 1977 | $copyright_label = null; |
||
| 1978 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) |
||
| 1979 | { |
||
| 1980 | $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1981 | } |
||
| 1982 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) |
||
| 1983 | { |
||
| 1984 | $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1985 | } |
||
| 1986 | $copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); |
||
| 1987 | } |
||
| 1988 | elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) |
||
| 1989 | { |
||
| 1990 | $copyright_url = null; |
||
| 1991 | $copyright_label = null; |
||
| 1992 | if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) |
||
| 1993 | { |
||
| 1994 | $copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1995 | } |
||
| 1996 | if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) |
||
| 1997 | { |
||
| 1998 | $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 1999 | } |
||
| 2000 | $copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); |
||
| 2001 | } |
||
| 2002 | else |
||
| 2003 | { |
||
| 2004 | $copyrights = $copyrights_parent; |
||
| 2005 | } |
||
| 2006 | |||
| 2007 | // CREDITS |
||
| 2008 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) |
||
| 2009 | { |
||
| 2010 | foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) |
||
| 2011 | { |
||
| 2012 | $credit_role = null; |
||
| 2013 | $credit_scheme = null; |
||
| 2014 | $credit_name = null; |
||
| 2015 | if (isset($credit['attribs']['']['role'])) |
||
| 2016 | { |
||
| 2017 | $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2018 | } |
||
| 2019 | if (isset($credit['attribs']['']['scheme'])) |
||
| 2020 | { |
||
| 2021 | $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2022 | } |
||
| 2023 | else |
||
| 2024 | { |
||
| 2025 | $credit_scheme = 'urn:ebu'; |
||
| 2026 | } |
||
| 2027 | if (isset($credit['data'])) |
||
| 2028 | { |
||
| 2029 | $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2030 | } |
||
| 2031 | $credits[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name)); |
||
| 2032 | } |
||
| 2033 | if (is_array($credits)) |
||
| 2034 | { |
||
| 2035 | $credits = array_values(array_unique($credits)); |
||
| 2036 | } |
||
| 2037 | } |
||
| 2038 | elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) |
||
| 2039 | { |
||
| 2040 | foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) |
||
| 2041 | { |
||
| 2042 | $credit_role = null; |
||
| 2043 | $credit_scheme = null; |
||
| 2044 | $credit_name = null; |
||
| 2045 | if (isset($credit['attribs']['']['role'])) |
||
| 2046 | { |
||
| 2047 | $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2048 | } |
||
| 2049 | if (isset($credit['attribs']['']['scheme'])) |
||
| 2050 | { |
||
| 2051 | $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2052 | } |
||
| 2053 | else |
||
| 2054 | { |
||
| 2055 | $credit_scheme = 'urn:ebu'; |
||
| 2056 | } |
||
| 2057 | if (isset($credit['data'])) |
||
| 2058 | { |
||
| 2059 | $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2060 | } |
||
| 2061 | $credits[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name)); |
||
| 2062 | } |
||
| 2063 | if (is_array($credits)) |
||
| 2064 | { |
||
| 2065 | $credits = array_values(array_unique($credits)); |
||
| 2066 | } |
||
| 2067 | } |
||
| 2068 | else |
||
| 2069 | { |
||
| 2070 | $credits = $credits_parent; |
||
| 2071 | } |
||
| 2072 | |||
| 2073 | // DESCRIPTION |
||
| 2074 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) |
||
| 2075 | { |
||
| 2076 | $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2077 | } |
||
| 2078 | elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) |
||
| 2079 | { |
||
| 2080 | $description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2081 | } |
||
| 2082 | else |
||
| 2083 | { |
||
| 2084 | $description = $description_parent; |
||
| 2085 | } |
||
| 2086 | |||
| 2087 | // HASHES |
||
| 2088 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) |
||
| 2089 | { |
||
| 2090 | foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) |
||
| 2091 | { |
||
| 2092 | $value = null; |
||
| 2093 | $algo = null; |
||
| 2094 | if (isset($hash['data'])) |
||
| 2095 | { |
||
| 2096 | $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2097 | } |
||
| 2098 | if (isset($hash['attribs']['']['algo'])) |
||
| 2099 | { |
||
| 2100 | $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2101 | } |
||
| 2102 | else |
||
| 2103 | { |
||
| 2104 | $algo = 'md5'; |
||
| 2105 | } |
||
| 2106 | $hashes[] = $algo.':'.$value; |
||
| 2107 | } |
||
| 2108 | if (is_array($hashes)) |
||
| 2109 | { |
||
| 2110 | $hashes = array_values(array_unique($hashes)); |
||
| 2111 | } |
||
| 2112 | } |
||
| 2113 | elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) |
||
| 2114 | { |
||
| 2115 | foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) |
||
| 2116 | { |
||
| 2117 | $value = null; |
||
| 2118 | $algo = null; |
||
| 2119 | if (isset($hash['data'])) |
||
| 2120 | { |
||
| 2121 | $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2122 | } |
||
| 2123 | if (isset($hash['attribs']['']['algo'])) |
||
| 2124 | { |
||
| 2125 | $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2126 | } |
||
| 2127 | else |
||
| 2128 | { |
||
| 2129 | $algo = 'md5'; |
||
| 2130 | } |
||
| 2131 | $hashes[] = $algo.':'.$value; |
||
| 2132 | } |
||
| 2133 | if (is_array($hashes)) |
||
| 2134 | { |
||
| 2135 | $hashes = array_values(array_unique($hashes)); |
||
| 2136 | } |
||
| 2137 | } |
||
| 2138 | else |
||
| 2139 | { |
||
| 2140 | $hashes = $hashes_parent; |
||
| 2141 | } |
||
| 2142 | |||
| 2143 | // KEYWORDS |
||
| 2144 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) |
||
| 2145 | { |
||
| 2146 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) |
||
| 2147 | { |
||
| 2148 | $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); |
||
| 2149 | foreach ($temp as $word) |
||
| 2150 | { |
||
| 2151 | $keywords[] = trim($word); |
||
| 2152 | } |
||
| 2153 | unset($temp); |
||
| 2154 | } |
||
| 2155 | if (is_array($keywords)) |
||
| 2156 | { |
||
| 2157 | $keywords = array_values(array_unique($keywords)); |
||
| 2158 | } |
||
| 2159 | } |
||
| 2160 | elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) |
||
| 2161 | { |
||
| 2162 | if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) |
||
| 2163 | { |
||
| 2164 | $temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); |
||
| 2165 | foreach ($temp as $word) |
||
| 2166 | { |
||
| 2167 | $keywords[] = trim($word); |
||
| 2168 | } |
||
| 2169 | unset($temp); |
||
| 2170 | } |
||
| 2171 | if (is_array($keywords)) |
||
| 2172 | { |
||
| 2173 | $keywords = array_values(array_unique($keywords)); |
||
| 2174 | } |
||
| 2175 | } |
||
| 2176 | else |
||
| 2177 | { |
||
| 2178 | $keywords = $keywords_parent; |
||
| 2179 | } |
||
| 2180 | |||
| 2181 | // PLAYER |
||
| 2182 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) |
||
| 2183 | { |
||
| 2184 | $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
||
| 2185 | } |
||
| 2186 | elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) |
||
| 2187 | { |
||
| 2188 | $player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
||
| 2189 | } |
||
| 2190 | else |
||
| 2191 | { |
||
| 2192 | $player = $player_parent; |
||
| 2193 | } |
||
| 2194 | |||
| 2195 | // RATINGS |
||
| 2196 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) |
||
| 2197 | { |
||
| 2198 | foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) |
||
| 2199 | { |
||
| 2200 | $rating_scheme = null; |
||
| 2201 | $rating_value = null; |
||
| 2202 | if (isset($rating['attribs']['']['scheme'])) |
||
| 2203 | { |
||
| 2204 | $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2205 | } |
||
| 2206 | else |
||
| 2207 | { |
||
| 2208 | $rating_scheme = 'urn:simple'; |
||
| 2209 | } |
||
| 2210 | if (isset($rating['data'])) |
||
| 2211 | { |
||
| 2212 | $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2213 | } |
||
| 2214 | $ratings[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); |
||
| 2215 | } |
||
| 2216 | if (is_array($ratings)) |
||
| 2217 | { |
||
| 2218 | $ratings = array_values(array_unique($ratings)); |
||
| 2219 | } |
||
| 2220 | } |
||
| 2221 | elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) |
||
| 2222 | { |
||
| 2223 | foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) |
||
| 2224 | { |
||
| 2225 | $rating_scheme = null; |
||
| 2226 | $rating_value = null; |
||
| 2227 | if (isset($rating['attribs']['']['scheme'])) |
||
| 2228 | { |
||
| 2229 | $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2230 | } |
||
| 2231 | else |
||
| 2232 | { |
||
| 2233 | $rating_scheme = 'urn:simple'; |
||
| 2234 | } |
||
| 2235 | if (isset($rating['data'])) |
||
| 2236 | { |
||
| 2237 | $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2238 | } |
||
| 2239 | $ratings[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); |
||
| 2240 | } |
||
| 2241 | if (is_array($ratings)) |
||
| 2242 | { |
||
| 2243 | $ratings = array_values(array_unique($ratings)); |
||
| 2244 | } |
||
| 2245 | } |
||
| 2246 | else |
||
| 2247 | { |
||
| 2248 | $ratings = $ratings_parent; |
||
| 2249 | } |
||
| 2250 | |||
| 2251 | // RESTRICTIONS |
||
| 2252 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) |
||
| 2253 | { |
||
| 2254 | foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) |
||
| 2255 | { |
||
| 2256 | $restriction_relationship = null; |
||
| 2257 | $restriction_type = null; |
||
| 2258 | $restriction_value = null; |
||
| 2259 | if (isset($restriction['attribs']['']['relationship'])) |
||
| 2260 | { |
||
| 2261 | $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2262 | } |
||
| 2263 | if (isset($restriction['attribs']['']['type'])) |
||
| 2264 | { |
||
| 2265 | $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2266 | } |
||
| 2267 | if (isset($restriction['data'])) |
||
| 2268 | { |
||
| 2269 | $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2270 | } |
||
| 2271 | $restrictions[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); |
||
| 2272 | } |
||
| 2273 | if (is_array($restrictions)) |
||
| 2274 | { |
||
| 2275 | $restrictions = array_values(array_unique($restrictions)); |
||
| 2276 | } |
||
| 2277 | } |
||
| 2278 | elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) |
||
| 2279 | { |
||
| 2280 | foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) |
||
| 2281 | { |
||
| 2282 | $restriction_relationship = null; |
||
| 2283 | $restriction_type = null; |
||
| 2284 | $restriction_value = null; |
||
| 2285 | if (isset($restriction['attribs']['']['relationship'])) |
||
| 2286 | { |
||
| 2287 | $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2288 | } |
||
| 2289 | if (isset($restriction['attribs']['']['type'])) |
||
| 2290 | { |
||
| 2291 | $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2292 | } |
||
| 2293 | if (isset($restriction['data'])) |
||
| 2294 | { |
||
| 2295 | $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2296 | } |
||
| 2297 | $restrictions[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); |
||
| 2298 | } |
||
| 2299 | if (is_array($restrictions)) |
||
| 2300 | { |
||
| 2301 | $restrictions = array_values(array_unique($restrictions)); |
||
| 2302 | } |
||
| 2303 | } |
||
| 2304 | else |
||
| 2305 | { |
||
| 2306 | $restrictions = $restrictions_parent; |
||
| 2307 | } |
||
| 2308 | |||
| 2309 | // THUMBNAILS |
||
| 2310 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) |
||
| 2311 | { |
||
| 2312 | foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) |
||
| 2313 | { |
||
| 2314 | $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
||
| 2315 | } |
||
| 2316 | if (is_array($thumbnails)) |
||
| 2317 | { |
||
| 2318 | $thumbnails = array_values(array_unique($thumbnails)); |
||
| 2319 | } |
||
| 2320 | } |
||
| 2321 | elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) |
||
| 2322 | { |
||
| 2323 | foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) |
||
| 2324 | { |
||
| 2325 | $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
||
| 2326 | } |
||
| 2327 | if (is_array($thumbnails)) |
||
| 2328 | { |
||
| 2329 | $thumbnails = array_values(array_unique($thumbnails)); |
||
| 2330 | } |
||
| 2331 | } |
||
| 2332 | else |
||
| 2333 | { |
||
| 2334 | $thumbnails = $thumbnails_parent; |
||
| 2335 | } |
||
| 2336 | |||
| 2337 | // TITLES |
||
| 2338 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) |
||
| 2339 | { |
||
| 2340 | $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2341 | } |
||
| 2342 | elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) |
||
| 2343 | { |
||
| 2344 | $title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2345 | } |
||
| 2346 | else |
||
| 2347 | { |
||
| 2348 | $title = $title_parent; |
||
| 2349 | } |
||
| 2350 | |||
| 2351 | $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width)); |
||
| 2352 | } |
||
| 2353 | } |
||
| 2354 | } |
||
| 2355 | } |
||
| 2356 | |||
| 2357 | // If we have standalone media:content tags, loop through them. |
||
| 2358 | if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'])) |
||
| 2359 | { |
||
| 2360 | foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content) |
||
| 2361 | { |
||
| 2362 | if (isset($content['attribs']['']['url']) || isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) |
||
| 2363 | { |
||
| 2364 | // Attributes |
||
| 2365 | $bitrate = null; |
||
| 2366 | $channels = null; |
||
| 2367 | $duration = null; |
||
| 2368 | $expression = null; |
||
| 2369 | $framerate = null; |
||
| 2370 | $height = null; |
||
| 2371 | $javascript = null; |
||
| 2372 | $lang = null; |
||
| 2373 | $length = null; |
||
| 2374 | $medium = null; |
||
| 2375 | $samplingrate = null; |
||
| 2376 | $type = null; |
||
| 2377 | $url = null; |
||
| 2378 | $width = null; |
||
| 2379 | |||
| 2380 | // Elements |
||
| 2381 | $captions = null; |
||
| 2382 | $categories = null; |
||
| 2383 | $copyrights = null; |
||
| 2384 | $credits = null; |
||
| 2385 | $description = null; |
||
| 2386 | $hashes = null; |
||
| 2387 | $keywords = null; |
||
| 2388 | $player = null; |
||
| 2389 | $ratings = null; |
||
| 2390 | $restrictions = null; |
||
| 2391 | $thumbnails = null; |
||
| 2392 | $title = null; |
||
| 2393 | |||
| 2394 | // Start checking the attributes of media:content |
||
| 2395 | if (isset($content['attribs']['']['bitrate'])) |
||
| 2396 | { |
||
| 2397 | $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2398 | } |
||
| 2399 | if (isset($content['attribs']['']['channels'])) |
||
| 2400 | { |
||
| 2401 | $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2402 | } |
||
| 2403 | if (isset($content['attribs']['']['duration'])) |
||
| 2404 | { |
||
| 2405 | $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2406 | } |
||
| 2407 | else |
||
| 2408 | { |
||
| 2409 | $duration = $duration_parent; |
||
| 2410 | } |
||
| 2411 | if (isset($content['attribs']['']['expression'])) |
||
| 2412 | { |
||
| 2413 | $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2414 | } |
||
| 2415 | if (isset($content['attribs']['']['framerate'])) |
||
| 2416 | { |
||
| 2417 | $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2418 | } |
||
| 2419 | if (isset($content['attribs']['']['height'])) |
||
| 2420 | { |
||
| 2421 | $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2422 | } |
||
| 2423 | if (isset($content['attribs']['']['lang'])) |
||
| 2424 | { |
||
| 2425 | $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2426 | } |
||
| 2427 | if (isset($content['attribs']['']['fileSize'])) |
||
| 2428 | { |
||
| 2429 | $length = ceil($content['attribs']['']['fileSize']); |
||
| 2430 | } |
||
| 2431 | if (isset($content['attribs']['']['medium'])) |
||
| 2432 | { |
||
| 2433 | $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2434 | } |
||
| 2435 | if (isset($content['attribs']['']['samplingrate'])) |
||
| 2436 | { |
||
| 2437 | $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2438 | } |
||
| 2439 | if (isset($content['attribs']['']['type'])) |
||
| 2440 | { |
||
| 2441 | $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2442 | } |
||
| 2443 | if (isset($content['attribs']['']['width'])) |
||
| 2444 | { |
||
| 2445 | $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2446 | } |
||
| 2447 | if (isset($content['attribs']['']['url'])) |
||
| 2448 | { |
||
| 2449 | $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
||
| 2450 | } |
||
| 2451 | // Checking the other optional media: elements. Priority: media:content, media:group, item, channel |
||
| 2452 | |||
| 2453 | // CAPTIONS |
||
| 2454 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) |
||
| 2455 | { |
||
| 2456 | foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) |
||
| 2457 | { |
||
| 2458 | $caption_type = null; |
||
| 2459 | $caption_lang = null; |
||
| 2460 | $caption_startTime = null; |
||
| 2461 | $caption_endTime = null; |
||
| 2462 | $caption_text = null; |
||
| 2463 | if (isset($caption['attribs']['']['type'])) |
||
| 2464 | { |
||
| 2465 | $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2466 | } |
||
| 2467 | if (isset($caption['attribs']['']['lang'])) |
||
| 2468 | { |
||
| 2469 | $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2470 | } |
||
| 2471 | if (isset($caption['attribs']['']['start'])) |
||
| 2472 | { |
||
| 2473 | $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2474 | } |
||
| 2475 | if (isset($caption['attribs']['']['end'])) |
||
| 2476 | { |
||
| 2477 | $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2478 | } |
||
| 2479 | if (isset($caption['data'])) |
||
| 2480 | { |
||
| 2481 | $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2482 | } |
||
| 2483 | $captions[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text)); |
||
| 2484 | } |
||
| 2485 | if (is_array($captions)) |
||
| 2486 | { |
||
| 2487 | $captions = array_values(array_unique($captions)); |
||
| 2488 | } |
||
| 2489 | } |
||
| 2490 | else |
||
| 2491 | { |
||
| 2492 | $captions = $captions_parent; |
||
| 2493 | } |
||
| 2494 | |||
| 2495 | // CATEGORIES |
||
| 2496 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) |
||
| 2497 | { |
||
| 2498 | foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) |
||
| 2499 | { |
||
| 2500 | $term = null; |
||
| 2501 | $scheme = null; |
||
| 2502 | $label = null; |
||
| 2503 | if (isset($category['data'])) |
||
| 2504 | { |
||
| 2505 | $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2506 | } |
||
| 2507 | if (isset($category['attribs']['']['scheme'])) |
||
| 2508 | { |
||
| 2509 | $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2510 | } |
||
| 2511 | else |
||
| 2512 | { |
||
| 2513 | $scheme = 'http://search.yahoo.com/mrss/category_schema'; |
||
| 2514 | } |
||
| 2515 | if (isset($category['attribs']['']['label'])) |
||
| 2516 | { |
||
| 2517 | $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2518 | } |
||
| 2519 | $categories[] = $this->registry->create('Category', array($term, $scheme, $label)); |
||
| 2520 | } |
||
| 2521 | } |
||
| 2522 | if (is_array($categories) && is_array($categories_parent)) |
||
| 2523 | { |
||
| 2524 | $categories = array_values(array_unique(array_merge($categories, $categories_parent))); |
||
| 2525 | } |
||
| 2526 | elseif (is_array($categories)) |
||
| 2527 | { |
||
| 2528 | $categories = array_values(array_unique($categories)); |
||
| 2529 | } |
||
| 2530 | elseif (is_array($categories_parent)) |
||
| 2531 | { |
||
| 2532 | $categories = array_values(array_unique($categories_parent)); |
||
| 2533 | } |
||
| 2534 | else |
||
| 2535 | { |
||
| 2536 | $categories = null; |
||
| 2537 | } |
||
| 2538 | |||
| 2539 | // COPYRIGHTS |
||
| 2540 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) |
||
| 2541 | { |
||
| 2542 | $copyright_url = null; |
||
| 2543 | $copyright_label = null; |
||
| 2544 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) |
||
| 2545 | { |
||
| 2546 | $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2547 | } |
||
| 2548 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) |
||
| 2549 | { |
||
| 2550 | $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2551 | } |
||
| 2552 | $copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); |
||
| 2553 | } |
||
| 2554 | else |
||
| 2555 | { |
||
| 2556 | $copyrights = $copyrights_parent; |
||
| 2557 | } |
||
| 2558 | |||
| 2559 | // CREDITS |
||
| 2560 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) |
||
| 2561 | { |
||
| 2562 | foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) |
||
| 2563 | { |
||
| 2564 | $credit_role = null; |
||
| 2565 | $credit_scheme = null; |
||
| 2566 | $credit_name = null; |
||
| 2567 | if (isset($credit['attribs']['']['role'])) |
||
| 2568 | { |
||
| 2569 | $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2570 | } |
||
| 2571 | if (isset($credit['attribs']['']['scheme'])) |
||
| 2572 | { |
||
| 2573 | $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2574 | } |
||
| 2575 | else |
||
| 2576 | { |
||
| 2577 | $credit_scheme = 'urn:ebu'; |
||
| 2578 | } |
||
| 2579 | if (isset($credit['data'])) |
||
| 2580 | { |
||
| 2581 | $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2582 | } |
||
| 2583 | $credits[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name)); |
||
| 2584 | } |
||
| 2585 | if (is_array($credits)) |
||
| 2586 | { |
||
| 2587 | $credits = array_values(array_unique($credits)); |
||
| 2588 | } |
||
| 2589 | } |
||
| 2590 | else |
||
| 2591 | { |
||
| 2592 | $credits = $credits_parent; |
||
| 2593 | } |
||
| 2594 | |||
| 2595 | // DESCRIPTION |
||
| 2596 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) |
||
| 2597 | { |
||
| 2598 | $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2599 | } |
||
| 2600 | else |
||
| 2601 | { |
||
| 2602 | $description = $description_parent; |
||
| 2603 | } |
||
| 2604 | |||
| 2605 | // HASHES |
||
| 2606 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) |
||
| 2607 | { |
||
| 2608 | foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) |
||
| 2609 | { |
||
| 2610 | $value = null; |
||
| 2611 | $algo = null; |
||
| 2612 | if (isset($hash['data'])) |
||
| 2613 | { |
||
| 2614 | $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2615 | } |
||
| 2616 | if (isset($hash['attribs']['']['algo'])) |
||
| 2617 | { |
||
| 2618 | $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2619 | } |
||
| 2620 | else |
||
| 2621 | { |
||
| 2622 | $algo = 'md5'; |
||
| 2623 | } |
||
| 2624 | $hashes[] = $algo.':'.$value; |
||
| 2625 | } |
||
| 2626 | if (is_array($hashes)) |
||
| 2627 | { |
||
| 2628 | $hashes = array_values(array_unique($hashes)); |
||
| 2629 | } |
||
| 2630 | } |
||
| 2631 | else |
||
| 2632 | { |
||
| 2633 | $hashes = $hashes_parent; |
||
| 2634 | } |
||
| 2635 | |||
| 2636 | // KEYWORDS |
||
| 2637 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) |
||
| 2638 | { |
||
| 2639 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) |
||
| 2640 | { |
||
| 2641 | $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); |
||
| 2642 | foreach ($temp as $word) |
||
| 2643 | { |
||
| 2644 | $keywords[] = trim($word); |
||
| 2645 | } |
||
| 2646 | unset($temp); |
||
| 2647 | } |
||
| 2648 | if (is_array($keywords)) |
||
| 2649 | { |
||
| 2650 | $keywords = array_values(array_unique($keywords)); |
||
| 2651 | } |
||
| 2652 | } |
||
| 2653 | else |
||
| 2654 | { |
||
| 2655 | $keywords = $keywords_parent; |
||
| 2656 | } |
||
| 2657 | |||
| 2658 | // PLAYER |
||
| 2659 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) |
||
| 2660 | { |
||
| 2661 | $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
||
| 2662 | } |
||
| 2663 | else |
||
| 2664 | { |
||
| 2665 | $player = $player_parent; |
||
| 2666 | } |
||
| 2667 | |||
| 2668 | // RATINGS |
||
| 2669 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) |
||
| 2670 | { |
||
| 2671 | foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) |
||
| 2672 | { |
||
| 2673 | $rating_scheme = null; |
||
| 2674 | $rating_value = null; |
||
| 2675 | if (isset($rating['attribs']['']['scheme'])) |
||
| 2676 | { |
||
| 2677 | $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2678 | } |
||
| 2679 | else |
||
| 2680 | { |
||
| 2681 | $rating_scheme = 'urn:simple'; |
||
| 2682 | } |
||
| 2683 | if (isset($rating['data'])) |
||
| 2684 | { |
||
| 2685 | $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2686 | } |
||
| 2687 | $ratings[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); |
||
| 2688 | } |
||
| 2689 | if (is_array($ratings)) |
||
| 2690 | { |
||
| 2691 | $ratings = array_values(array_unique($ratings)); |
||
| 2692 | } |
||
| 2693 | } |
||
| 2694 | else |
||
| 2695 | { |
||
| 2696 | $ratings = $ratings_parent; |
||
| 2697 | } |
||
| 2698 | |||
| 2699 | // RESTRICTIONS |
||
| 2700 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) |
||
| 2701 | { |
||
| 2702 | foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) |
||
| 2703 | { |
||
| 2704 | $restriction_relationship = null; |
||
| 2705 | $restriction_type = null; |
||
| 2706 | $restriction_value = null; |
||
| 2707 | if (isset($restriction['attribs']['']['relationship'])) |
||
| 2708 | { |
||
| 2709 | $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2710 | } |
||
| 2711 | if (isset($restriction['attribs']['']['type'])) |
||
| 2712 | { |
||
| 2713 | $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2714 | } |
||
| 2715 | if (isset($restriction['data'])) |
||
| 2716 | { |
||
| 2717 | $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2718 | } |
||
| 2719 | $restrictions[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); |
||
| 2720 | } |
||
| 2721 | if (is_array($restrictions)) |
||
| 2722 | { |
||
| 2723 | $restrictions = array_values(array_unique($restrictions)); |
||
| 2724 | } |
||
| 2725 | } |
||
| 2726 | else |
||
| 2727 | { |
||
| 2728 | $restrictions = $restrictions_parent; |
||
| 2729 | } |
||
| 2730 | |||
| 2731 | // THUMBNAILS |
||
| 2732 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) |
||
| 2733 | { |
||
| 2734 | foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) |
||
| 2735 | { |
||
| 2736 | $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); |
||
| 2737 | } |
||
| 2738 | if (is_array($thumbnails)) |
||
| 2739 | { |
||
| 2740 | $thumbnails = array_values(array_unique($thumbnails)); |
||
| 2741 | } |
||
| 2742 | } |
||
| 2743 | else |
||
| 2744 | { |
||
| 2745 | $thumbnails = $thumbnails_parent; |
||
| 2746 | } |
||
| 2747 | |||
| 2748 | // TITLES |
||
| 2749 | if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) |
||
| 2750 | { |
||
| 2751 | $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2752 | } |
||
| 2753 | else |
||
| 2754 | { |
||
| 2755 | $title = $title_parent; |
||
| 2756 | } |
||
| 2757 | |||
| 2758 | $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width)); |
||
| 2759 | } |
||
| 2760 | } |
||
| 2761 | } |
||
| 2762 | |||
| 2763 | foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link) |
||
| 2764 | { |
||
| 2765 | if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') |
||
| 2766 | { |
||
| 2767 | // Attributes |
||
| 2768 | $bitrate = null; |
||
| 2769 | $channels = null; |
||
| 2770 | $duration = null; |
||
| 2771 | $expression = null; |
||
| 2772 | $framerate = null; |
||
| 2773 | $height = null; |
||
| 2774 | $javascript = null; |
||
| 2775 | $lang = null; |
||
| 2776 | $length = null; |
||
| 2777 | $medium = null; |
||
| 2778 | $samplingrate = null; |
||
| 2779 | $type = null; |
||
| 2780 | $url = null; |
||
| 2781 | $width = null; |
||
| 2782 | |||
| 2783 | $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); |
||
| 2784 | if (isset($link['attribs']['']['type'])) |
||
| 2785 | { |
||
| 2786 | $type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2787 | } |
||
| 2788 | if (isset($link['attribs']['']['length'])) |
||
| 2789 | { |
||
| 2790 | $length = ceil($link['attribs']['']['length']); |
||
| 2791 | } |
||
| 2792 | |||
| 2793 | // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor |
||
| 2794 | $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width)); |
||
| 2795 | } |
||
| 2796 | } |
||
| 2797 | |||
| 2798 | foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link) |
||
| 2799 | { |
||
| 2800 | if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') |
||
| 2801 | { |
||
| 2802 | // Attributes |
||
| 2803 | $bitrate = null; |
||
| 2804 | $channels = null; |
||
| 2805 | $duration = null; |
||
| 2806 | $expression = null; |
||
| 2807 | $framerate = null; |
||
| 2808 | $height = null; |
||
| 2809 | $javascript = null; |
||
| 2810 | $lang = null; |
||
| 2811 | $length = null; |
||
| 2812 | $medium = null; |
||
| 2813 | $samplingrate = null; |
||
| 2814 | $type = null; |
||
| 2815 | $url = null; |
||
| 2816 | $width = null; |
||
| 2817 | |||
| 2818 | $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); |
||
| 2819 | if (isset($link['attribs']['']['type'])) |
||
| 2820 | { |
||
| 2821 | $type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2822 | } |
||
| 2823 | if (isset($link['attribs']['']['length'])) |
||
| 2824 | { |
||
| 2825 | $length = ceil($link['attribs']['']['length']); |
||
| 2826 | } |
||
| 2827 | |||
| 2828 | // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor |
||
| 2829 | $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width)); |
||
| 2830 | } |
||
| 2831 | } |
||
| 2832 | |||
| 2833 | if ($enclosure = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'enclosure')) |
||
| 2834 | { |
||
| 2835 | if (isset($enclosure[0]['attribs']['']['url'])) |
||
| 2836 | { |
||
| 2837 | // Attributes |
||
| 2838 | $bitrate = null; |
||
| 2839 | $channels = null; |
||
| 2840 | $duration = null; |
||
| 2841 | $expression = null; |
||
| 2842 | $framerate = null; |
||
| 2843 | $height = null; |
||
| 2844 | $javascript = null; |
||
| 2845 | $lang = null; |
||
| 2846 | $length = null; |
||
| 2847 | $medium = null; |
||
| 2848 | $samplingrate = null; |
||
| 2849 | $type = null; |
||
| 2850 | $url = null; |
||
| 2851 | $width = null; |
||
| 2852 | |||
| 2853 | $url = $this->sanitize($enclosure[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($enclosure[0])); |
||
| 2854 | if (isset($enclosure[0]['attribs']['']['type'])) |
||
| 2855 | { |
||
| 2856 | $type = $this->sanitize($enclosure[0]['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); |
||
| 2857 | } |
||
| 2858 | if (isset($enclosure[0]['attribs']['']['length'])) |
||
| 2859 | { |
||
| 2860 | $length = ceil($enclosure[0]['attribs']['']['length']); |
||
| 2861 | } |
||
| 2862 | |||
| 2863 | // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor |
||
| 2864 | $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width)); |
||
| 2865 | } |
||
| 2866 | } |
||
| 2867 | |||
| 2868 | if (sizeof($this->data['enclosures']) === 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width)) |
||
| 2869 | { |
||
| 2870 | // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor |
||
| 2871 | $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width)); |
||
| 2872 | } |
||
| 2873 | |||
| 2874 | $this->data['enclosures'] = array_values(array_unique($this->data['enclosures'])); |
||
| 2875 | } |
||
| 2876 | if (!empty($this->data['enclosures'])) |
||
| 2877 | { |
||
| 2878 | return $this->data['enclosures']; |
||
| 2879 | } |
||
| 2880 | else |
||
| 2881 | { |
||
| 2882 | return null; |
||
| 2883 | } |
||
| 2884 | } |
||
| 2885 | |||
| 2965 |