_addPlaform('Mac OS X'); $this->_addPlaform('Windows'); $this->_addPlaform('Linux'); // Let's load the json feed to get the links for this release. $this->_loadJson($release); // Build the array containing all the download links $this->setDownloadLinks(); } public function setAllowToggle($bool = TRUE) { if (is_bool($bool)) { $this->allow_toggle = $bool; } } public function getAllowToggle() { return $this->allow_toggle; } /** * Add a link to the Eclipse Installer * * @param string $platform * @param string $url * @param string $text * @return boolean */ public function addlink($platform = '', $url = '', $text = '', $jre = FALSE) { if(!isset($this->platform[$this->_removeSpaces($platform)])) { return FALSE; } $link_classes = ""; $count = count($this->platform[$this->_removeSpaces($platform)]['links']); $platform_array = array( 'platform' => $platform, 'count' =>$count, 'link_classes' => "btn btn-warning margin-bottom-5", 'url' => $url, 'text' => $text, 'text_prefix' => 'Download', 'jre' => $jre ); $this->setPlatform($platform_array); } /** * Output of the Eclipse Installer HTML * * @return string */ public function output($version = NULL, $os = NULL) { $html = ""; $tpl = ""; $layout = $this->getInstallerLayout(); $os_client = $this->_getClientOS(); if (!empty($os)) { $os_client = $os; } if (!empty($layout)) { $installer_alert_text = $this->getInstallerAlertText(); switch ($layout) { case 'layout_a': $release_title = $this->getReleaseShortName(TRUE); $installer_links = $this->getInstallerArray($version, $os_client); $tpl = "views/view.installer-a.php"; break; case 'layout_b': $release_title = $this->getReleaseShortName(TRUE) . ' ' . $this->getReleaseType(); $download_count = $this->total_download_count; $installer_links = $this->getInstallerArray(); $tpl = "views/view.installer-b.php"; break; } ob_start(); include($tpl); $html = ob_get_clean(); } return $html; } /** * Return the installer alert text * * @return string */ function getInstallerAlertText() { $release_name = $this->getReleaseShortName(TRUE) . " " . $this->getReleaseType(); $download_links = $this->getDownloadLinks(); $platforms = array(); foreach ($download_links as $platform) { foreach ($platform['links'] as $link) { if ($link['jre'] === TRUE) { $platforms[] = str_replace(' ', ' ', $link['platform']); } } } if (empty($platforms)) { return ""; } $string_platforms = implode(', ', $platforms); $string_platforms = substr_replace($string_platforms, ' and', strrpos($string_platforms, ','), 1); return "The Eclipse Installer " . $release_name . " now includes a JRE for " . $string_platforms . "."; } /** * Returns the layout for the Installer * * @return string */ public function getInstallerLayout() { return $this->layout; } /** * Sets a specified layout for the Installer * * @param string $layout */ public function setInstallerLayout($layout = "") { if (filter_var($layout, FILTER_SANITIZE_STRING)) { $this->layout = $layout; } } /** * Returns the download link * * @return array */ public function getDownloadLinks() { return $this->download_links; } /** * Set the download link * * @param array $links */ public function setDownloadLinks() { $this->download_links = $this->getPlatform(); } /** * Set the release title * * @param string $title */ public function setReleaseTitle($title) { if (!empty($title)) { $this->release_title = $title; } } /** * Get the release title * * @return string */ public function getReleaseTitle() { return $this->release_title; } /** * Get the release short name * * @param bool $non_breaking_string * * @return string */ public function getReleaseShortName($non_breaking_string = FALSE) { if ($release_title = $this->getReleaseTitle()) { $release_title = explode('/', $release_title); $short_name = $release_title[0]; if ($non_breaking_string) { $short_name = str_replace('-', '‑', $short_name); } return $short_name; } return ""; } /** * Get the release type * * @return string */ public function getReleaseType() { if ($release_title = $this->getReleaseTitle()) { $release_title = explode('/', $release_title); return $release_title[1]; } return ""; } /** * Return a platform * * @return array */ public function getPlatform() { return $this->platform; } /** * Sets a specified platform * * @param array $platform */ public function setPlatform($platform = array()) { $this->platform[$this->_removeSpaces($platform['platform'])]['links'][] = $platform; } /** * Returns an array of links * * @param string $os * * @param string $version * * @return array */ public function getInstallerLinks($version = NULL, $os = NULL) { $os_client = $this->_getClientOS(); $accepted_os = array('windows','macosx','linux'); if (!empty($os) && in_array($os, $accepted_os)) { $os_client = $os; } $download_links = $this->getInstallerArray($version, $os_client); $links = array( 'links' => array(), ); if (!empty($download_links)) { foreach($download_links['links'] as $link) { $links['links'][] = $link['url']; } } return $links; } public function getInstallerInstructions(){ $class = 'collapse'; if (!$this->getAllowToggle()) { $class .= ' in'; } $html = '