| <?php |
| /******************************************************************************* |
| * Copyright (c) 2013, 2015 Eclipse Foundation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Christopher Guindon (Eclipse Foundation)- initial API and implementation |
| *******************************************************************************/ |
| |
| //if name of the file requested is the same as the current file, the script will exit directly. |
| if(basename(__FILE__) == basename($_SERVER['PHP_SELF'])){exit();} |
| require_once($_SERVER['DOCUMENT_ROOT'] . "/membership/promo/promos.php"); |
| require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/classes/ads/promotedDownloads.class.php"); |
| |
| class Downloads extends CompareController { |
| |
| private $App = NULL; |
| |
| private $releaseTitle = ""; |
| |
| private $show_friends_promo = FALSE; |
| |
| protected $warning = ''; |
| |
| private $download_rows = ''; |
| |
| private $download_standard = ''; |
| |
| private $layout = 'default-download'; |
| |
| public function __construct(App $App) { |
| parent::__construct($App); |
| $this->App = $App; |
| } |
| |
| public function downloadOutput() { |
| if(empty($this->download_rows)) { |
| $this->buildDownload(); |
| } |
| $html = '<div id="download-packages-container">'; |
| $html .= '<div id="download-packages">'; |
| $html .= $this->download_rows; |
| $html .= '</div>'; |
| $html .= '</div>'; |
| return $html; |
| } |
| |
| public function getWarning() { |
| if ($this->warning == '') { |
| return FALSE; |
| } |
| |
| return '<div class="row header-row pink">' . $this->warning . '</div>'; |
| } |
| |
| public function getSystemSelect() { |
| ob_start(); |
| ?> |
| |
| <select id="osSelect"> |
| <option <?php if ($this->os_display == 'win32') echo "selected"?> value="win32">Windows</option> |
| <option <?php if ($this->os_display == 'linux') echo "selected"?> value="linux">Linux</option> |
| <option <?php if ($this->os_display == 'macosx') echo "selected"?> value="macosx">Mac OS X (Cocoa)</option> |
| </select> |
| |
| <?php |
| return ob_get_clean(); |
| } |
| |
| public function standardOutput($Installer = NULL) { |
| if (!is_null($Installer)) { |
| $this->download_standard = $Installer->output(); |
| } |
| else if (empty($this->download_standard)) { |
| $this->buildDownload(); |
| } |
| |
| $html = '<div class="download-standard">'; |
| $html .= $this->download_standard; |
| $html .= '</div>'; |
| return $html; |
| } |
| |
| public function setReleaseTitle($title) { |
| $this->releaseTitle = $title; |
| } |
| |
| public function getReleaseName() { |
| return $this->release; |
| |
| } |
| |
| public function getReleaseTitle() { |
| return '<span id="descriptionText">' . $this->releaseTitle . '</span> for ' . $this->getSystemSelect(); |
| |
| } |
| |
| public function setFriendsEarlyAccess($show = FALSE) { |
| if($show == TRUE){ |
| $this->show_friends_promo = TRUE; |
| } |
| } |
| |
| public function getFriendsEarlyAccess() { |
| $html = '<div class="row" id="eclipse-friends"> |
| <a href="/donate/">Friends of Eclipse</a> - <span>Eclipse Luna is ready!</span> <a href="//friends.eclipse.org/luna.html" id="download-button">Download Now</a> |
| </div>'; |
| |
| return ($this->show_friends_promo) ? $html : ''; |
| } |
| |
| private function getFeaturedRow($package, $display, $zebra, $new = FALSE) { |
| // Create releative url's. |
| $package['downloadurl'] = substr($package['downloadurl'], strpos($package['downloadurl'], "/downloads/download.php?")); |
| $package['downloadurl64'] = substr($package['downloadurl64'], strpos($package['downloadurl64'], "/downloads/download.php?")); |
| |
| $body = $package->body; |
| $full_body = trim(strip_tags($body)); |
| $body = $full_body; |
| $full_body = htmlentities($full_body); |
| |
| $word_count = 21; |
| if(str_word_count($body) >= $word_count){ |
| $array_body = explode('.', $body); |
| $words = explode(" ", $array_body[0]); |
| $body = rtrim(implode(" ", array_splice($words, 0, $word_count)), ','); |
| if(str_word_count($body) == $word_count){ |
| $body .= '...'; |
| } |
| } |
| if(substr($body, -1) != '.'){ |
| $body .= '.'; |
| } |
| $body = htmlentities($body); |
| |
| $feature = $package->features[0]; |
| $features = explode(',;', $feature); |
| |
| $feature = array(); |
| foreach($this->features_accepted['item'] as $f){ |
| $data = explode(';', $f); |
| foreach($data as $d){ |
| if(in_array($d, $features)){ |
| $feat = $this->getReadableFeature($data[0]); |
| if(empty($feat)){ |
| continue; |
| } |
| $feature[] = $feat['name']; |
| } |
| } |
| } |
| ob_start(); |
| $download_count = $package['downloadCount']; |
| if ($download_count != 'N/A'){ |
| $download_count = number_format((int)$package['downloadCount']); |
| } |
| ?> |
| <div class="package-row clearfix<?php if ($zebra) { print ' zebra'; }?>" data-Filter-packages="<?php print implode(', ', $feature);?>"> |
| <div class="row vertical-align-min-md"> |
| <div class="col-sm-3 icon"> |
| <img src="<?php print $package['icon'];?>" width="42" height="42" alt="<?php print $package['name'];?>"/> |
| </div> |
| <div class="col-sm-13 text xs-sm-text-center"> |
| <h3> |
| <a href="http://www.eclipse.org<?php print $package['url']?>" title="<?php print $full_body;?>"> |
| <?php print $package['name'];?> |
| </a> |
| </h3> |
| |
| <?php if (stripos($package['name'], 'standard') != 0 || stripos($package['name'], 'classic') != 0) {?> |
| <a class="details" href="http://download.eclipse.org/eclipse/downloads/" title="Other Downloads"> |
| Other Downloads</a> |
| <?php }?> |
| |
| <ul class="list-inline"> |
| <li class="download-counts"><?php print $package['size'];?></li> |
| <li class="download-counts"><?php print $download_count;?> DOWNLOADS</li> |
| </ul> |
| <p><?php print $body;?></p> |
| </div> |
| <div class="col-sm-8 download"> |
| <div class="col-sm-9 downloadLink-icon"><i class="fa fa-download"></i></div> |
| <div class="col-xs-24 col-sm-15 downloadLink-content"> |
| <div class="text-center"> |
| <p class="margin-bottom"><?php print $display;?></p> |
| <ul class="list-inline"> |
| <?php if ($package['downloadurl'] != "") {?> |
| <li><a class="downloadLink" href="<?php print $package['downloadurl'];?>" title="Download">32 bit</a></li> |
| <li class="divider black"></li> |
| <?php } if ($package['downloadurl64'] != "") {?> |
| <li><a class="downloadLink" href="<?php print $package['downloadurl64'];?>" title="Download">64 bit</a></li> |
| <?php } ?> |
| </ul> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| <?php |
| return ob_get_clean(); |
| } |
| |
| private function printAd() { |
| $PromotedDownloads = New PromotedDownloads(); |
| ob_start(); |
| $html = $PromotedDownloads->output('layout_b'); |
| return ob_get_clean(); |
| } |
| |
| private function buildDownload() { |
| $count = 1; |
| |
| if(empty($this->packages)){ |
| $this->prepareDownloads(); |
| } |
| |
| foreach ($this->packages as $value => $package) { |
| |
| if ($count == 2) { |
| $this->download_rows .= $this->printAd(); |
| } |
| |
| $this->download_rows .= $this->getFeaturedRow($package, $this->display, $zebra); |
| |
| $count ++; |
| $zebra = !$zebra; |
| } |
| } |
| } |