Example #1
0
 /**
  * Downloads a package file to a specific directory
  *
  * @param   string  $url     The URL to download from
  * @param   string  $target  The directory to store the file
  *
  * @return  boolean True on success
  *
  * @since   2.5.4
  */
 protected function downloadPackage($url, $target)
 {
     JLoader::import('helpers.download', JPATH_COMPONENT_ADMINISTRATOR);
     JLog::add(JText::sprintf('COM_JOOMLAUPDATE_UPDATE_LOG_URL', $url), JLog::INFO, 'Update');
     $result = AdmintoolsHelperDownload::download($url, $target);
     if (!$result) {
         return false;
     } else {
         return basename($target);
     }
 }
Example #2
0
	/**
	 * Downloads a package file to a specific directory
	 *
	 * @param   string  $url     The URL to download from
	 * @param   string  $target  The directory to store the file
	 *
	 * @return  boolean True on success
	 *
	 * @since   2.5.4
	 */
	protected function downloadPackage($url, $target)
	{
		JLoader::import('helpers.download', JPATH_COMPONENT_ADMINISTRATOR);
		$result = AdmintoolsHelperDownload::download($url, $target);

		if (!$result)
		{
			return false;
		}
		else
		{
			return basename($target);
		}
	}
Example #3
0
 public static function video($item)
 {
     $result = array();
     $prop = 'text';
     if (!isset($item->{$prop})) {
         $prop = 'introtext';
     }
     if (preg_match_all('@<iframe\\s[^>]*src=[\\"|\']([^\\"\'\\>]+)[^>].*?</iframe>@ms', $item->{$prop}, $iframesrc) > 0) {
         if (isset($iframesrc[1])) {
             if (strpos($iframesrc[1][0], 'vimeo.com') !== false) {
                 $vid = str_replace(array('http:', 'https:', '//player.vimeo.com/video/'), '', $iframesrc[1][0]);
             } else {
                 $vid = str_replace(array('http:', 'https:', '//youtu.be/', '//www.youtube.com/embed/', '//youtube.googleapis.com/v/'), '', $iframesrc[1][0]);
             }
             //remove any parameter
             $vid = preg_replace('@(\\/|\\?).*@i', '', $vid);
             if (!empty($vid)) {
                 if (strpos($iframesrc[1][0], 'vimeo.com') !== false) {
                     require_once JPATH_ADMINISTRATOR . '/components/com_joomlaupdate/helpers/download.php';
                     $filepath = JPATH_SITE . '/cache/vimeo/' . $vid . '.json';
                     if (!is_file($filepath)) {
                         AdmintoolsHelperDownload::download("http://vimeo.com/api/v2/video/{$vid}.json", $filepath);
                     }
                     if (is_file($filepath)) {
                         $vimeojson = json_decode(@file_get_contents($filepath));
                         $result['src'] = $vimeojson[0]->thumbnail_large;
                     }
                 } else {
                     $result['src'] = 'http://img.youtube.com/vi/' . $vid . '/0.jpg';
                 }
                 $item->{$prop} = str_replace($iframesrc['0'], '', $item->{$prop});
             }
         }
     }
     return $result;
 }