/** * Make xml playlist file * * @return True */ function XMLPlaylistFile($rows, $filename) { $db =& JFactory::getDBO(); $c = hwd_vs_Config::get_instance(); jimport('joomla.filesystem.file'); $config = null; $config .= "<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\">\n"; $config .= "<title>hwdVideoShare Playlist</title>\n"; $config .= "<info>http:/xspf.org/xspf-v1.html</info>\n"; $config .= "<date>".date('Y-m-d H:i:s')."</date>\n"; $config .= "<trackList>\n"; $config .= "\n"; // print out playlist for ($i=0, $n=count($rows); $i < $n; $i++) { $row = $rows[$i]; $type = "video"; if (($row->video_type == "youtube.com" || ($row->video_type == "seyret" && substr($row->video_id, 0, 7) == "youtube")) && ($c->hwdvids_videoplayer_file == "jwflv" || $c->hwdvids_videoplayer_file == "jwflv_v5")) { $data = @explode(",", $row->video_id); if ($row->video_type == "seyret") { $YTID = $data[1]; } else { $YTID = $data[0]; } $location = "http://www.youtube.com/watch?v=".$YTID; $image = hwd_vs_tools::generatePlayerThumbnail($row); $type = "youtube"; } else { $locations = hwd_vs_tools::generateVideoLocations($row); $location = $locations['url']; $image = hwd_vs_tools::generatePlayerThumbnail($row); } if (empty($location)) continue; //$title = hwd_vs_tools::truncateText(strip_tags(hwdEncoding::UNXMLEntities($row->title)), 50); //$annotation = hwd_vs_tools::truncateText(strip_tags(hwdEncoding::UNXMLEntities($row->description)), 50); $title = strip_tags(hwdEncoding::UNXMLEntities($row->title)); $annotation = strip_tags(hwdEncoding::UNXMLEntities($row->description)); $image = urldecode($image); $config .= " <track>\n"; $config .= " <location><![CDATA[".$location."]]></location>\n"; $config .= " <image><![CDATA[".$image."]]></image>\n"; $config .= " <title><![CDATA[".$title."]]></title>\n"; $config .= " <annotation><![CDATA[".$annotation."]]></annotation>\n"; $config .= " <meta rel='type'>".$type."</meta>\n"; $config .= " </track>\n"; $config .= "\n"; } $config .= "</trackList>\n"; $config .= "</playlist>\n"; $configFile = JPATH_SITE.DS.'components'.DS.'com_hwdvideoshare'.DS.'xml'.DS.'xspf'.DS.$filename.'.xml'; if (!JFile::write($configFile, $config)) { return false; } return true; }
/** * Generates the array of information for a standard video list from parsed xml files * * @param array $rows the list from an xml file * @return $code the array prepared for Smarty template */ function generateVideoListFromXml( $rows, $thumbwidth=null, $hwdvs_itemid=null, $tooltip=null, $or_title_trunc=null, $or_descr_trunc=null, $onclick_js=null, $lightbox=false ) { global $hwdvsTemplateOverride; $c = hwd_vs_Config::get_instance(); if ($tooltip == 1 || $c->show_tooltip == "1") { $tooltip = 1; } else { $tooltip = 0; } $code = array(); $k = 0; if (isset($thumbwidth)) { $twidth = $thumbwidth; } else { $twidth = $c->thumbwidth; } $theight = $twidth*$c->tar_fb; if (isset($or_title_trunc) && !empty($or_title_trunc)) { $truntitle = $or_title_trunc; } else { $truntitle = $c->truntitle; } if (isset($or_descr_trunc) && !empty($or_descr_trunc)) { $trunvdesc = $or_descr_trunc; } else { $trunvdesc = $c->trunvdesc; } $class=null; $width=null; $height=null; for ($i=0, $n=count($rows); $i < $n; $i++) { $row = $rows[$i]; if (empty($rows[$i]["id"])) {$rows[$i]["id"] = null;} if (empty($rows[$i]["videotitle"])) {$rows[$i]["videotitle"] = null;} if (empty($rows[$i]["videocode"])) {$rows[$i]["videocode"] = null;} if (empty($rows[$i]["videotype"])) {$rows[$i]["videotype"] = null;} if (empty($rows[$i]["thumbnail"])) {$rows[$i]["thumbnail"] = null;} if (empty($rows[$i]["location"])) {$rows[$i]["location"] = null;} if (empty($rows[$i]["category"])) {$rows[$i]["category"] = null;} if (empty($rows[$i]["category_id"])) {$rows[$i]["category_id"] = null;} if (empty($rows[$i]["description"])) {$rows[$i]["description"] = null;} if (empty($rows[$i]["views"])) {$rows[$i]["views"] = null;} if (empty($rows[$i]["date"])) {$rows[$i]["date"] = null;} if (empty($rows[$i]["duration"])) {$rows[$i]["duration"] = null;} if (empty($rows[$i]["avatar"])) {$rows[$i]["avatar"] = null;} if (empty($rows[$i]["rating"])) {$rows[$i]["rating"] = null;} if (empty($rows[$i]["uploader"])) {$rows[$i]["uploader"] = null;} if (empty($rows[$i]["uploader_id"])) {$rows[$i]["uploader_id"] = null;} if (empty($rows[$i]["description"])) {$rows[$i]["description"] = null;} if (empty($rows[$i]["comments"])) {$rows[$i]["comments"]= "0";} if (empty($rows[$i]["tags"])) {$rows[$i]["tags"] = null;} $video_code = explode(",", $rows[$i]["videocode"]); if (!empty($video_code[1])) { $video_code[1] = urldecode($video_code[1]); $rows[$i]["videocode"] = implode(",", $video_code); } $tooltip_data[0] = $tooltip; $tooltip_data[1] = addslashes(strip_tags($rows[$i]["videotitle"])); $tooltip_data[2] = addslashes(hwd_vs_tools::truncateText(strip_tags($rows[$i]["description"]), $trunvdesc)); if ($hwdvsTemplateOverride['show_avatar'] == 1 && ($c->cbint == "1" || $c->cbint == "2" || $c->cbint == "3")) { $code[$i]->avatar = hwd_vs_tools::generateAvatar($rows[$i]["uploader_id"], $rows[$i]["avatar"], $k, $width, $height, $class); } if ($hwdvsTemplateOverride['show_title']) { $title = stripslashes($rows[$i]["videotitle"]); $title = hwdEncoding::charset_encode_utf_8($title); $code[$i]->title = hwd_vs_tools::generateVideoLink( $rows[$i]["id"], $title, $hwdvs_itemid, $onclick_js, $truntitle); } if ($hwdvsTemplateOverride['show_category']) { $code[$i]->category = hwd_vs_tools::generateCategoryLink($rows[$i]["category_id"], $rows[$i]["category"], $hwdvs_itemid); } if ($hwdvsTemplateOverride['show_description']) { $description = stripslashes($rows[$i]["description"]); $description = hwdEncoding::charset_encode_utf_8($description); $code[$i]->description = hwd_vs_tools::truncateText(strip_tags(hwdEncoding::UNXMLEntities($description)), $trunvdesc); } if ($hwdvsTemplateOverride['show_rating'] == 1 && $c->showrate == 1) { $code[$i]->rating = hwd_vs_tools::generateRatingImg($rows[$i]["rating"]); $code[$i]->showrating = 1; } if ($hwdvsTemplateOverride['show_thumbnail'] == 1) { $code[$i]->thumbnail = hwd_vs_tools::generateVideoThumbnailLink($rows[$i]["id"], $rows[$i]["videocode"], $rows[$i]["videotype"], $rows[$i]["thumbnail"], $k, $twidth, $theight, $class, null, $hwdvs_itemid, $onclick_js, $tooltip_data, $lightbox, $rows[$i]["duration"]); } if ($hwdvsTemplateOverride['show_views']) { $code[$i]->views = $rows[$i]["views"]; } if ($hwdvsTemplateOverride['show_comments']) { $code[$i]->comments = $rows[$i]["comments"]; } if ($hwdvsTemplateOverride['show_duration']) { $code[$i]->duration = $rows[$i]["duration"]; } if ($hwdvsTemplateOverride['show_uploader']) { $code[$i]->uploader = hwd_vs_tools::generateUserFromID($rows[$i]["uploader_id"], $rows[$i]["uploader"], $rows[$i]["uploader"]); } if ($hwdvsTemplateOverride['show_timesince']) { $code[$i]->timesince = hwd_vs_tools::generateTimeSinceUpload($rows[$i]["date"]); } if ($hwdvsTemplateOverride['show_upload_date']) { $code[$i]->upload_date = strftime("%l%P - %b %e, %Y", strtotime($rows[$i]["date"])); } if ($hwdvsTemplateOverride['show_tags']) { $code[$i]->tags = hwd_vs_tools::generateTagListString($rows[$i]["tags"]); } $code[$i]->k = $k; $k = 1 - $k; } if (!isset($code)) { $code = null; } return $code; }