<?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';
  
/**
 * Change all viewers screen
 *
 * @package Showkase
 */
class AllViewersScreen extends Screen
{
   
    /**
     * Constructor
     *
     * @access public
     * @return void
     * @param string content for html title tag
     * @param string body id
     */
    public function __construct($htmlTitle, $bodyId='', $bodyClass='')
    {
        parent::__construct($htmlTitle, $bodyId, $bodyClass);
        $bb = new SiteButtonbar();
        $this->subNavHtml = $bb->getHtml();
    }
   
  
    /**
     * get html for images screen
     * Note that some class names are significant for manager.js
     *
     * @access public
     * @return string html
     * @param string gallery reference number
     * @param array image data
     */
    public function getContentHtml($context)
    {
        $viewers = '';
        foreach ($context['pageTypes'] as $type=>$pageTypeData) {
            if (isset($pageTypeData['exposed']) && strtolower($pageTypeData['exposed']) == 'false') continue;
            $viewerName = empty($pageTypeData['versionString'])
                ? $pageTypeData['shortName']
                : $pageTypeData['versionString'];
            $viewers .= '
            <tr>
                <td>'.$viewerName.'</td>
                <td class="commit"><a href="index.php?cmd=allviewers&type='.$type.'&token='.$context['token'].'" onclick="return window.confirm('."'Change all galleries to ".$context['pageTypes'][$type]['name']."?')".'">Change</a></td>
            </tr>';
        }
        $html = <<<EOD
        <div class="subhead">
          <div class="hgroup">
            <h2><a href="#" class="popper"  title="Change Viewers" data-content="Change all viewers in your web site. This may take a few seconds if you have a lot of galleries.">Change All Viewers</a></h2>
          </div>
          <ul class="buttons">
            <li><button type="button" onclick="window.location='index.php';" class="btn btn-danger">Cancel</button></li>
          </ul>
        </div>
        <table class="showkase-actions">
          <thead>
            <tr>
              <th colspan="2">Change all galleries to:</th>
            </tr>
          </thead>
          <tbody>
            {$viewers}
          </tbody>
        </table>
EOD;
        return $html;
    }
}