/home/coolpkct/www/websites/cake3.cool.rocks/admin/classes/importscreen.php
<?php
/**
 * Part of Showkase web site management package
 *
 * @package Showkase
 * @author Jack Hardie {@link http://www.jhardie.com}
 * @copyright Copyright (c) 2012, SimpleViewer Inc.
 */
defined('SK_ACCESS')||die('<h1>403: Forbidden</h1>');
require_once 'classes'.DIRECTORY_SEPARATOR.'sitebuttonbar.php';
 
/**
 * Repair screen
 *
 * @package Showkase
 */
class ImportScreen extends Screen
{
  /**
   * @var string overrides some of head content in Screen
   */
  protected $customHeadHtml = '
  <script>
      $(function() {
          $("#selectall").on("click", function(event){
            $("input.selectimport").prop("checked", this.checked);
          });
      });
  </script>
';

 /**
   * Constructs Screen
   *
   * @access public
   * @return void
   * @param string content for html title tag
   * @param string body id
   */
   public function __construct($htmlTitle, $bodyId='', $bodyClass='allpages')
   {
     parent::__construct($htmlTitle, $bodyId, $bodyClass);
     $bb = new SiteButtonbar();
     $this->subNavHtml = $bb->getHtml();
   }


  /**
  * Returns list of pages as html table
  * @access public
  * @return string html table
  * @param array context
  */
  function getContentHtml($context)
  {
    $importable = $context['message'];
    if (!empty($context['scanData'])) {
        $importable = '
    <table class="showkase-actions">
      <tr>
        <th>Folder name</th>
        <th>Type</th>
        <th>Import</th>
      </tr>
';
    foreach ($context['scanData'] as $key=>$dir) {
        $importable .= '
      <tr>
        <td>'.$dir['name'].'</td>
        <td>'.$dir['type'].'</td>
        <td><input type="checkbox" name="import['.$key.']" class="selectimport"></td>
      </tr>';
    }
    $importable .= '
      <tr>
        <td>Select all</td>
        <td>&nbsp;</td>
        <td><input type="checkbox" name="selectall" id="selectall"></td>
    </table>
';
    }

    $html = <<<EOD
  <form action = "index.php?cmd=import" method="post">
    <div class="subhead">
      <div class="hgroup">
        <h2>Import Galleries and Showkase Pages</h2>
      </div>
      <ul class="buttons">
        <li><button type="button" onclick="window.location='index.php';" class="btn btn-danger">Cancel</button></li>
        <li>
          <input type="hidden" name="token" value="{$context['token']}" >
          <input type="hidden" name="importsubmitted" value="true" >
          <button type="submit" class="btn btn-success formbutton" >Import</button>
        </li>
      </ul>
    </div>
    <div class="prompt"> 
      <p class="prompt">Enter a path from the web root starting with / or a relative path from the content folder.</p>
      <p class="prompt">Click the Scan button.</p>
      <p class="prompt">Select the folders to import and click the Import button.</p>
      <p class="prompt">Folder names that are unsuitable for a web url will be cleaned-up automatically.</p>
    </div>
    <fieldset>
      <div class="clearfix">
        <div class="input">
          <label for="form-importpath" class="" title="">Import path</label>
          <input type="text" class="text" name="importPath" id="form-importpath" tabindex="2" value="{$context['importPath']}" />
          <input type="submit" name="pathsubmit" value="Scan" class="btn btn-primary">
        </div>
      </div>   
    </fieldset>
    {$importable}
  </form>
EOD;
    return $html;
  }
}