blob: 82626dea128f3c3aa3782ba8735d425c4bc98934 [file] [log] [blame]
<?php
/*******************************************************************************
* Copyright (c) 2013 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 $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">';
$html .= $this->download_rows;
$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() {
if(empty($this->download_standard)){
$this->buildDownload();
}
$html = '<div class="download-standard">';
$html .= $this->download_standard;
$html .= '</div>';
$html .= '<div class="row header-row background-charcoal"><div class="col-md-16"><h2>Package Solutions</h2></div><div class="col-md-8"><div class="btn btn-default float-right" id="filter-placeholder"></div></div></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 promotedDownload($ad = array(), $zebra) {
if(empty($ad)){
return FALSE;
}
$impression = new CampaignImpression($ad['campaign'], $_SERVER['REQUEST_URI'], @gethostbyaddr($_SERVER['REMOTE_ADDR']));
$impression->recordImpression();
if ($zebra === TRUE){
$zebra = 'zebra';
}
elseif ($zebra == 'promo') {
$zebra = 'promo';
}
ob_start();
?>
<div class="package-row row <?php if ($zebra) { print $zebra; }?>">
<div class="col-md-2 icon"><img src="<?php print $ad['image'];?>" width="42" height="42" alt="<?php print $ad['title'];?>"/></div>
<div class="col-md-15 text">
<h2 class="title">
<a class="promo-title" href="//eclipse.org/go/<?php print $ad['campaign'];?>" title="<?php print $ad['title'];?>"><?php print $ad['title'];?></a>
</h2>
<p><?php print $ad['description'];?></p>
</div>
<div class="col-md-7 download">
<div class="col-md-9 download-icon orange">
<i class="fa fa-download"></i>
</div>
<div class="col-md-15 download-link">
<a class="orange" href="//eclipse.org/go/<?php print $ad['campaign'];?>" title="<?php print $ad['title'];?>"><i class="fa fa-star"></i><br/>Promoted<br/>Download</a><br/>
</div>
</div>
</div>
<?php
return ob_get_clean();
}
private function getAds() {
$this->ads['actuate'] = array(
'campaign' => 'PROMO_DOWNLOAD_ACTUATE',
'image' => '/home/images/BIRT-Icon-32x32.gif',
'title' => 'Actuate BIRT iHub Evaluation Package',
'description' => 'Schedule, distribute &amp; secure BIRT output - plus dashboards, analytics and more.',
);
$this->ads['actuate_b'] = array(
'campaign' => 'PROMO_DOWNLOAD_ACTUATE_B',
'image' => '/downloads/images/birt-shield.png',
'title' => 'BIRT Commercial Grade Reporting Server :: iHub3 - New Release',
'description' => 'Deliver secure, visually engaging, personalized analytics to users at any scale.',
);
$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!',
);
}
private function getFeaturedRow($package, $display, $zebra) {
$full_body = trim(strip_tags($package->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);
$features = explode(',;', $package->features[0]);
$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();
?>
<div class="package-row row<?php if ($zebra) { print ' zebra'; }?>" data-Filter-packages="<?php print implode(', ', $feature);?>">
<div class="col-md-2 icon"><img src="<?php print $package['icon'];?>" width="42" height="42" alt="<?php print $package['name'];?>"/></div>
<div class="col-md-15 text">
<h2><a href="<?php print $package['url']?>" title="<?php print $full_body;?>"><?php print $package['name'];?></a><small>, <?php print $package['size'];?></small></h2>
<span class="download-counts">Downloaded <?php print number_format((int)$package['downloadCount']);?> Times</span><?php if (stripos($package['name'], 'standard') != 0 || stripos($package['name'], 'classic') != 0) {?>&nbsp; <a class="details" href="http://download.eclipse.org/eclipse/downloads/" title="Other Downloads">Other Downloads</a><?php }?>
<p><?php print $body;?></p>
</div>
<div class="col-md-7 download">
<div class="download-icon col-md-9">
<i class="fa fa-download orange"></i>
</div>
<div class="col-md-15 download-link">
<a href="<?php print $package['downloadurl'];?>" title="Download <?php print $package['name'];?> <?php print $display;?> 32 Bit"><?php print $display;?> 32 Bit</a><br/>
<?php if ($package['downloadurl64'] != "") {?>
<a href="<?php print $package['downloadurl64'];?>" title="Download <?php print $package['name'];?> <?php print $display;?> 64 Bit"><?php print $display;?> 64 Bit</a>
<?php } ?>
</div>
</div>
</div>
<?php
return ob_get_clean();
}
private function buildDownload() {
$zebra = TRUE;
$count = 1;
$random = (!isset($_GET['preview'])) ? rand(1, 83) : $_GET['preview'];
if(empty($this->packages)){
$this->prepareDownloads();
}
foreach ($this->packages as $value => $package) {
if ($count == 3 && (($random >= 1 && $random <= 10) || $random == 'actuate')) {
//actuate
$this->download_rows .= $this->promotedDownload($this->ads['actuate'], 'promo');
}
elseif ($count == 3 && (($random >= 11 && $random <= 20) || $random == 'actuate_b')) {
//actuate
$this->download_rows .= $this->promotedDownload($this->ads['actuate_b'], 'promo');
}
elseif($count == 3 && (($random >= 21 && $random <= 40) || $random == 'xored')) {
//xored
$this->download_rows .= $this->promotedDownload($this->ads['xored'], 'promo');
}
elseif($count == 3 && (($random >= 41 && $random <= 60) || $random == 'jrebel')) {
//jrebel
$this->download_rows .= $this->promotedDownload($this->ads['jrebel'], 'promo');
}
elseif($count == 3 && (($random >= 61 && $random <= 83) || $random == 'springsource')) {
//springsource
$this->download_rows .= $this->promotedDownload($this->ads['springsource'], 'promo');
}
if($package['icon'] == '/modeling/images/modeling_about.png') {
$package['icon'] = '/downloads/images/modeling.png';
}
if($package['icon'] == '/downloads/images/classic2.jpg') {
//$package['icon'] = 'http://www.eclipse.org/downloads/images/classic2.png';
//$package->body = chop(trim(strip_tags($package->body)), 'Click here to file a bug against Eclipse Platform.');
$this->download_standard = $this->getFeaturedRow($package, $this->display, FALSE);
}
else {
$this->download_rows .= $this->getFeaturedRow($package, $this->display, $zebra);
$count ++;
$zebra = !$zebra;
}
}
}
}