| <?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"); |
| |
| class Downloads extends CompareController { |
| |
| private $releaseTitle = ""; |
| |
| private $show_friends_promo = FALSE; |
| |
| protected $warning = ''; |
| |
| private $download_rows = ''; |
| |
| private $download_standard = ''; |
| |
| private $layout = 'default-download'; |
| |
| private $ads = array(); |
| |
| public function __construct($App) { |
| //@todo: $App should be stored in it's own property. |
| parent::__construct($App); |
| $this->getAds(); |
| |
| } |
| |
| public function downloadOutput() { |
| if(empty($this->download_rows)) { |
| $this->buildDownload(); |
| } |
| $html = '<div id="download-packages-container">'; |
| $html .= '<div class="clearfix header-row background-charcoal"><div class="col-xs-16"> |
| <h2>...or download an Eclipse Package</h2></div><div class="col-xs-8"></div></div>'; |
| $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 promotedDownloadIBM($ad = array()) { |
| if (empty($ad)) { |
| return FALSE; |
| } |
| |
| $impression = new CampaignImpression($ad['campaign'], $_SERVER['REQUEST_URI'], @gethostbyaddr($_SERVER['REMOTE_ADDR'])); |
| $impression->recordImpression(); |
| |
| ob_start(); |
| ?> |
| <div class="package-row clearfix promo"> |
| <div class="row vertical-align-min-md"> |
| <div class="col-xs-3 icon"> |
| <!-- iframe/script/href/image tag --> |
| <script src="<?php print $ad['script_url'];?>"></script> |
| <noscript> |
| <a href="<?php print $ad['iframe_link'];?>" target="_blank"> |
| <img src="<?php print $ad['iframe_img_url'];?>" width=32 height=32 alt="Click Here" border=0> |
| </a> |
| </noscript> |
| </div> |
| <div class="col-sm-13 text xs-sm-text-center"> |
| <h3> |
| <a href="<?php print $ad['img_link'];?>" target="_blank"><?php print $ad['title'];?> |
| <img src="<?php print $ad['img_url'];?>" width=1 height=1 alt=" " border=0> |
| </a> |
| </h3> |
| <p><?php print $ad['description'];?></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-sm-15 downloadLink-content"> |
| <div class="text-center"> |
| <p> |
| <a class="orange" href="<?php print $ad['img_link'];?>" target="_blank"> |
| <i class="fa fa-star"></i><br/>Promoted<br/>Download</a><br/></p> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| <?php |
| return ob_get_clean(); |
| } |
| |
| private function promotedDownload($ad = array(), $zebra) { |
| if(empty($ad)){ |
| return FALSE; |
| } |
| |
| $impression = new CampaignImpression($ad['campaign'], $_SERVER['REQUEST_URI'], @gethostbyaddr($_SERVER['REMOTE_ADDR'])); |
| $impression->recordImpression(); |
| |
| ob_start(); |
| ?> |
| <div class="package-row clearfix <?php if ($zebra) { print 'zebra'; }?> promo"> |
| <div class="row vertical-align-min-md"> |
| <div class="col-sm-3 icon"><img src="<?php print $ad['image'];?>" width="42" height="42" alt="<?php print $ad['title'];?>"/></div> |
| <div class="col-sm-13 text xs-sm-text-center"> |
| <h3 class="title"> |
| <a class="promo-title" href="//eclipse.org/go/<?php print $ad['campaign'];?>" title="<?php print $ad['title'];?>"><?php print $ad['title'];?></a> |
| </h3> |
| <p><?php print $ad['description'];?></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-sm-15 downloadLink-content"> |
| <div class="text-center"> |
| <p> |
| <a class="orange" href="//eclipse.org/go/<?php print $ad['campaign'];?>" title="<?php print $ad['title'];?>"> |
| <span class="text-center"><i class="fa fa-star"></i></span><br/>Promoted<br/>Download |
| </a> |
| </p> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| <?php |
| return ob_get_clean(); |
| } |
| |
| private function getAds() { |
| |
| $this->ads['actuate'] = array( |
| 'campaign' => 'PROMO_DOWNLOAD_ACTUATE', |
| 'image' => '/downloads/images/ftype-logo-metallic-icon.png', |
| 'title' => 'BIRT iHub F-Type | Free Commercial-Grade BIRT Server', |
| 'description' => 'Take your BIRT applications to the next level with instant interactivity, enterprise-class security, easy api-based embedding, live Excel export...', |
| ); |
| |
| $this->ads['actuate_b'] = array( |
| 'campaign' => 'PROMO_DOWNLOAD_ACTUATE_B', |
| 'image' => '/downloads/images/ftype-logo-metallic-icon.png', |
| 'title' => 'Free Enterprise-Grade BIRT Report Server (Not a Trial)', |
| 'description' => 'Instantly enhance your BIRT reports and web applications with interactive viewing, flexible scheduling, native Excel export, and more...', |
| ); |
| |
| $this->ads['actuate_c'] = array( |
| 'campaign' => 'PROMO_DOWNLOAD_ACTUATE_C', |
| 'image' => '/downloads/images/ftype-logo-metallic-icon.png', |
| 'title' => 'Enterprise-Class BIRT Report Server (Free, Not a Trial)', |
| 'description' => 'Instantly enhance your Eclipse BIRT reports with interactive, real-time analytics that can be seamlessly embedded into web and mobile apps.', |
| ); |
| |
| $this->ads['springsource'] = array( |
| 'campaign' => 'PROMO_DOWNLOAD_SPRINGSOURCE', |
| 'image' => '/downloads/images/springsource32x32.png', |
| 'title' => 'Spring Tool Suite', |
| 'description' => 'Complete IDE for enterprise Java, Spring, Groovy, Grails and the Cloud.', |
| ); |
| |
| $this->ads['eucalyptus'] = array( |
| 'campaign' => 'PROMO_DOWNLOAD_EUCALYPTUS', |
| 'image' => '/downloads/images/eucalyptus32x32.gif', |
| 'title' => 'Eucalyptus 3.3 for Dev/Test in the Cloud', |
| 'description' => 'Cost-effective dev and test on your own AWS-compatible private cloud. Scalable production workloads on AWS.', |
| ); |
| |
| $this->ads['eucalyptus_2'] = array( |
| 'campaign' => 'PROMO_DOWNLOAD_EUCALYPTUS_2', |
| 'image' => '/downloads/images/eucalyptus32x32.gif', |
| 'title' => 'Eucalyptus 3.3 with Auto Scaling, Elastic Load Balancing, and Cloud Watch', |
| 'description' => 'Cost-effective dev and test on your own AWS-compatible private cloud. Scalable production workloads on AWS.', |
| ); |
| |
| $this->ads['xored'] = array( |
| 'campaign' => 'PROMO_DOWNLOAD_XORED', |
| 'image' => '/downloads/images/xored-q7-32x32.png', |
| 'title' => 'Xored Q7 UI Testing Tools for RCP', |
| 'description' => 'GUI test automation in the same order of magnitude as manual testing.', |
| ); |
| |
| $this->ads['jrebel'] = array( |
| 'campaign' => 'PROMO_DOWNLOAD_JREBEL', |
| 'image' => '/downloads/images/JRebel-42x42-dark.png', |
| 'title' => 'JRebel for Eclipse IDE', |
| 'description' => 'See Java Code Changes Instantly. Save Time. Reduce Stress. Finish Projects Faster!', |
| ); |
| |
| $this->ads['ibm_a'] = array( |
| 'campaign' => 'PROMO_DOWNLOAD_IBM', |
| 'image' => '/downloads/images/bluemix-logo-32x-promoted-download.png', |
| 'title' => 'Eclipse Plugin for IBM Bluemix', |
| 'description' => 'With Eclipse + Bluemix simply Press Save. Code deployed. Ready to Debug. Repeat. Sign up to begin building today!', |
| 'script_url' => '//bs.serving-sys.com/BurstingPipe/adServer.bs?cn=rsb&c=28&pli=15916523&PluID=0&w=32&h=32&ord=[timestamp]', |
| 'iframe_link' => '//bs.serving-sys.com/BurstingPipe/adServer.bs?cn=brd&FlightID=15916523&Page=&PluID=0&Pos=1161966504', |
| 'iframe_img_url'=>'//bs.serving-sys.com/BurstingPipe/adServer.bs?cn=bsr&FlightID=15916523&Page=&PluID=0&Pos=1161966504', |
| 'img_link'=>'//bs.serving-sys.com/BurstingPipe/adServer.bs?cn=tf&c=20&mc=click&pli=15933609&PluID=0&ord=[timestamp]', |
| ); |
| |
| $this->ads['ibm_b'] = array( |
| 'campaign' => 'PROMO_DOWNLOAD_IBM_B', |
| 'image' => '/downloads/images/bluemix-logo-32x-promoted-download.png', |
| 'title' => 'Deploy your app to IBM Bluemix', |
| 'description' => "Love Eclipse? Want to move to Cloud? Bluemix + Eclipse make it easy. Sign up to begin building today!", |
| 'script_url' => '//bs.serving-sys.com/BurstingPipe/adServer.bs?cn=rsb&c=28&pli=15916518&PluID=0&w=32&h=32&ord=[timestamp]', |
| 'iframe_link' => '//bs.serving-sys.com/BurstingPipe/adServer.bs?cn=brd&FlightID=15916518&Page=&PluID=0&Pos=197075889', |
| 'iframe_img_url'=>'//bs.serving-sys.com/BurstingPipe/adServer.bs?cn=bsr&FlightID=15916518&Page=&PluID=0&Pos=197075889', |
| 'img_link'=>'//bs.serving-sys.com/BurstingPipe/adServer.bs?cn=tf&c=20&mc=click&pli=15933611&PluID=0&ord=[timestamp]', |
| ); |
| |
| $this->ads['ibm_c'] = array( |
| 'campaign' => 'PROMO_DOWNLOAD_IBM_C', |
| 'image' => '/downloads/images/bluemix-logo-32x-promoted-download.png', |
| 'title' => 'Run your Apps on the Cloud', |
| 'description' => "Want Eclipse in the cloud? IBM Bluemix makes it easy. Sign up to begin building today!", |
| 'script_url' => '//bs.serving-sys.com/BurstingPipe/adServer.bs?cn=rsb&c=28&pli=15916521&PluID=0&w=32&h=32&ord=[timestamp]', |
| 'iframe_link' => '//bs.serving-sys.com/BurstingPipe/adServer.bs?cn=brd&FlightID=15916521&Page=&PluID=0&Pos=616231926', |
| 'iframe_img_url'=>'//bs.serving-sys.com/BurstingPipe/adServer.bs?cn=bsr&FlightID=15916521&Page=&PluID=0&Pos=616231926', |
| 'img_link'=>'//bs.serving-sys.com/BurstingPipe/adServer.bs?cn=tf&c=20&mc=click&pli=15933613&PluID=0&ord=[timestamp]', |
| ); |
| |
| } |
| |
| private function getFeaturedRow($package, $display, $zebra, $new = FALSE) { |
| // Create releative url's. |
| $package['downloadurl'] = substr($package['downloadurl'], strpos($package['downloadurl'], "download.php?")); |
| $package['downloadurl64'] = substr($package['downloadurl64'], strpos($package['downloadurl64'], "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 buildDownload() { |
| $zebra = TRUE; |
| $count = 1; |
| $random = (!isset($_GET['preview'])) ? rand(1, 120) : $_GET['preview']; |
| |
| if(empty($this->packages)){ |
| $this->prepareDownloads(); |
| } |
| |
| foreach ($this->packages as $value => $package) { |
| if ($count == 2 && (($random >= 1 && $random <= 30) || $random == 'jrebel')) { |
| $promo = $this->promotedDownload($this->ads['jrebel'], $zebra); |
| $this->download_rows .= $promo; |
| $zebra = !$zebra; |
| } |
| elseif ($count == 2 && (($random >= 31 && $random <= 60) || $random == 'springsource')) { |
| $promo = $this->promotedDownload($this->ads['springsource'], $zebra); |
| $this->download_rows .= $promo; |
| $zebra = !$zebra; |
| } |
| |
| // 3 IBM slots for 2 spaces |
| elseif ($count == 2 && (($random >= 61 && $random <= 80) || $random == 'ibm_a')) { |
| $promo = $this->promotedDownloadIBM($this->ads['ibm_a'], 'promo'); |
| $this->download_rows .= $promo; |
| } |
| elseif ($count == 2 && (($random >= 81 && $random <= 100) || $random == 'ibm_b')) { |
| $promo = $this->promotedDownloadIBM($this->ads['ibm_b'], 'promo'); |
| $this->download_rows .= $promo; |
| } |
| elseif ($count == 2 && (($random >= 101 && $random <= 120) || $random == 'ibm_c')) { |
| $promo = $this->promotedDownloadIBM($this->ads['ibm_c'], 'promo'); |
| $this->download_rows .= $promo; |
| } |
| |
| $this->download_rows .= $this->getFeaturedRow($package, $this->display, $zebra); |
| |
| $count ++; |
| $zebra = !$zebra; |
| } |
| } |
| } |