update eclipse.org-common

Signed-off-by: Christopher Guindon <chris.guindon@eclipse.org>
diff --git a/eclipse.org-common/classes/downloads/eclipseInstaller.php b/eclipse.org-common/classes/downloads/eclipseInstaller.php
new file mode 100644
index 0000000..6d3925c
--- /dev/null
+++ b/eclipse.org-common/classes/downloads/eclipseInstaller.php
@@ -0,0 +1,141 @@
+<?php
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 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();}
+
+class EclipseInstaller {
+
+  private $platform = array();
+
+  private $total_download_count = 0;
+
+  private $json_data = array();
+
+  /**
+   * Constructor
+   */
+  function EclipseInstaller($release = NULL) {
+    $this->_addPlaform('Mac OS X');
+    $this->_addPlaform('Windows');
+    $this->_addPlaform('Linux');
+
+    // Let's load the json feed to get the links
+    // for this release.
+    if (!is_null($release)) {
+      $this->_loadJson($release);
+    }
+  }
+
+  /**
+   * Add a link to the Eclipse Installer
+   *
+   * @param string $platform
+   * @param string $url
+   * @param string $text
+   * @return boolean
+   */
+  public function addlink($platform = '', $url = '', $text = '') {
+   if(!isset($this->platform[$this->_removeSpaces($platform)])) {
+     return FALSE;
+   }
+   $count = count($this->platform[$this->_removeSpaces($platform)]['links']);
+   $this->platform[$this->_removeSpaces($platform)]['links'][] = '<li class="download-link-' . $count . '"><a href="' . $url .'" title="' . $text . ' Download">' . $text .'</a></li>' . PHP_EOL;
+  }
+
+  /**
+   * Output of the Eclipse Installer HTML
+   *
+   * @return string
+   */
+  public function output() {
+    $html = "";
+    $platforms = $this->platform;
+    $download_count = $this->total_download_count;
+    if (!empty($platforms)) {
+      ob_start();
+      include("view/eclipseInstaller.php");
+      $html = ob_get_clean();
+    }
+    return $html;
+  }
+
+  /**
+   * Add links from json data feed.
+   */
+  private function _addLinksFromJson() {
+    $data = $this->json_data;
+
+    if (!empty($data['files']['mac64'])) {
+      $this->addlink('Mac OS X', $data['files']['mac64']['url'], '64 bit');
+    }
+
+    if (!empty($data['files']['win32'])) {
+      $this->addlink('Windows', $data['files']['win32']['url'], '32 bit');
+    }
+
+    if (!empty($data['files']['win64'])) {
+      $this->addlink('Windows', $data['files']['win64']['url'], '64 bit');
+    }
+
+    if (!empty($data['files']['linux32'])) {
+      $this->addlink('Linux', $data['files']['linux32']['url'], '32 bit');
+    }
+
+    if (!empty($data['files']['linux64'])) {
+      $this->addlink('Linux', $data['files']['linux64']['url'], '64 bit');
+    }
+  }
+
+  /**
+   * Add a platform to the Eclipse Installer
+   *
+   * @param string $label
+   */
+  private function _addPlaform($label = '') {
+   $safe_label = $this->_removeSpaces($label);
+    $this->platform[$safe_label] = array(
+      'label' => $label,
+      //'icon' => '<img src="/downloads/assets/public/images/icon-' . $safe_label . '.png"/>',
+      'icon' => '',
+      'links' => array(),
+    );
+  }
+
+  /**
+   * Remove all spaces from a string.
+   *
+   * @param string $str
+   */
+  private function _removeSpaces($str = '') {
+   return str_replace(' ', '', strtolower($str));
+  }
+
+  /**
+   * Load jSON data from file.
+   * @param unknown $release
+   */
+  private function _loadJson($release) {
+    $url = '/home/data/httpd/writable/community/eclipse_installer.json';
+    $json_data =  json_decode(file_get_contents($url), TRUE);
+    foreach ($json_data as $data) {
+      if (strtolower($data['release_title']) == strtolower($release)) {
+        $this->json_data = $data;
+        $this->_addLinksFromJson();
+        if (!empty($this->json_data['total_download_count'])) {
+          $this->total_download_count = $this->json_data['total_download_count'];
+        }
+        break;
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/eclipse.org-common/classes/downloads/view/eclipseInstaller.php b/eclipse.org-common/classes/downloads/view/eclipseInstaller.php
new file mode 100644
index 0000000..972a5ca
--- /dev/null
+++ b/eclipse.org-common/classes/downloads/view/eclipseInstaller.php
@@ -0,0 +1,62 @@
+<?php
+/*******************************************************************************
+ * Copyright (c) 2015, 2016 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']) || empty($platforms)){exit();}
+?>
+<div class="installer">
+  <div class="title">
+    <div class="row">
+      <div class="col-sm-6">
+        <img class="installer-logo" width="150" src="/downloads/assets/public/images/logo-installer.png" />
+      </div>
+      <div class="col-sm-18">
+        <h2>Try the Eclipse <span class="orange">Installer</span> <span class="label label-default label-new">NEW</span></h2>
+        <p>The easiest way to install and update your Eclipse Development Environment.</p>
+        <p class="padding-top-5">
+          <a class="btn btn-warning btn-sm" data-target="#collapseEinstaller" class="solstice-collapse orange" role="button" data-toggle="collapse" aria-expanded="false" aria-controls="collapseEinstaller">
+          Find out more <i class="fa fa-chevron-down"></i>
+          </a>
+        </p>
+      </div>
+    </div>
+  </div><!-- end of title -->
+  <div class="options">
+    <div class="clearfix">
+      <div class="col-sm-6 download-count-eclipse-installer">
+       <?php if (!empty($download_count)) :?>
+         <p><?php print number_format($download_count);?><br/>
+           Downloads
+         </p>
+      <?php endif;?>
+      </div>
+
+     <?php foreach ($platforms as $platform):?>
+       <div class="col-sm-6">
+         <div class="padding-bottom-5"></div>
+          <p><?php print $platform['icon'];?> <?php print $platform['label'];?></p>
+          <ul class="list-inline">
+            <li><i class="fa fa-download white"></i></li>
+            <?php print implode('', $platform['links']);?>
+          </ul>
+        </div>
+      <?php endforeach;?>
+    </div>
+  </div><!-- end of .options -->
+</div> <!-- end of .installer -->
+
+<div id="collapseEinstaller1">
+  <div class="collapse<?php if (isset($_GET['show_instructions'])) { print ' in';}?>" id="collapseEinstaller">
+    <div class="well">
+      <?php include('eclipseInstaller_instructions.php');?>
+    </div>
+  </div>
+</div>
\ No newline at end of file
diff --git a/eclipse.org-common/classes/downloads/view/eclipseInstaller_instructions.php b/eclipse.org-common/classes/downloads/view/eclipseInstaller_instructions.php
new file mode 100644
index 0000000..e16e816
--- /dev/null
+++ b/eclipse.org-common/classes/downloads/view/eclipseInstaller_instructions.php
@@ -0,0 +1,77 @@
+<?php
+/*******************************************************************************
+ * Copyright (c) 2015,2016 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://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Eric Poirier (Eclipse Foundation) - Initial implementation
+ *    Christopher Guindon (Eclipse Foundation)
+ *******************************************************************************/
+?>
+<p class="float-right padding-top-25">
+  <a class="btn btn-warning btn-sm" data-target="#collapseEinstaller" class="solstice-collapse orange" role="button" data-toggle="collapse" aria-expanded="false" aria-controls="collapseEinstaller">
+    <i class="fa fa-times"></i> Hide
+  </a>
+</p>
+<h1>5 Steps to Install Eclipse</h1>
+
+<p class="lead">For the Mars release, we are introducing a new Eclipse installer.
+This is a new and more efficient way to install Eclipse. It is a proper
+installer, so no more zip files, with a self extracting download that
+will lead you through the installation experience.  For those not into
+installers, we still have the packages and zip files available on our download pages.</p>
+<hr>
+<h2>1. Download the Eclipse Installer</h2>
+<?php if (!empty($platforms)) :?>
+  <div class="row orange-download-link">
+  <?php foreach ($platforms as $platform):?>
+    <div class="col-sm-8 padding-top-10 text-center">
+      <p><?php print $platform['label'];?></p>
+      <ul class="list-inline">
+        <li><i class="fa fa-download white"></i></li>
+        <?php print implode('', $platform['links']);?>
+      </ul>
+    </div>
+  <?php endforeach;?>
+  </div>
+<?php else:?>
+  <p>Download Eclipse Installer from <a href="/downloads">http://www.eclipse.org/downloads</a></p>
+<?php endif;?>
+<!--
+<img class="img-responsive" src="assets/public/images/installer-instructions-01.png" alt="Screenshot of Eclipse Installer's web page.">
+ -->
+<p>Eclipse is hosted on many mirrors around the world. Please select
+the one closest to you and start to download the Installer</p>
+<hr>
+<h2>2. Start the Eclipse Installer executable</h2>
+<p>For Windows users, after the Eclipse Installer executable has finished downloading it should be
+available in your download directory.  Start the Eclipse Installer executable.
+You may get a security warning to run this file. If the Eclipse Foundation is
+the Publisher, you are good to select Run.</p>
+<p>For Mac and Linux users, you will still need to unzip the download to create the Installer.
+Start the Installer once it is available.</p>
+<img class="img-responsive" src="assets/public/images/installer-instructions-02-b.png" alt="Screenshot of the Eclipse Installer executable.">
+<hr>
+<h2>3. Select the package to install</h2>
+<p>The new Eclipse Installer shows the packages available to Eclipse users.
+You can search for the package you want to install or scroll through the list.</p>
+<p>Select and click on the package you want to install.</p>
+<img class="img-responsive" src="assets/public/images/installer-instructions-03.png" alt="Screenshot of the Eclipse packages.">
+<hr>
+<h2>4. Select your installation folder</h2>
+<p>Specify the folder where you want Eclipse to be installed. The default folder will be in your User directory.</p>
+<p>Select the ‘Install’ button to begin the installation.</p>
+<img class="img-responsive" src="assets/public/images/installer-instructions-04.png" alt="Screenshot of the Install window.">
+<hr>
+<h2>5. Launch Eclipse</h2>
+<p>Once the installation is complete you can now launch Eclipse.
+The Eclipse Installer has done it's work. Happy coding.</p>
+<img class="img-responsive" src="assets/public/images/installer-instructions-05.png" alt="Screenshot of the Launch window.">
+<p class="text-right padding-top-25">
+  <a class="btn btn-warning btn-sm" data-target="#collapseEinstaller" class="solstice-collapse orange" role="button" data-toggle="collapse" aria-expanded="false" aria-controls="collapseEinstaller">
+    <i class="fa fa-times"></i> Hide
+  </a>
+</p>
\ No newline at end of file