Пример #1
0
 protected function initContent()
 {
     $browserInfo = $this->getContext()->getBrowserInfo();
     $conf = $this->getContext()->getConf();
     $request = $this->getContext()->getRequest();
     $uaItem = $browserInfo->getSwarmUaItem();
     $runToken = null;
     if ($conf->client->requireRunToken) {
         $runToken = $request->getVal("run_token");
         if (!$runToken) {
             throw new SwarmException("This swarm has restricted access to join the swarm.");
         }
     }
     $this->setTitle("Test runner");
     $this->displayPageTitle = false;
     $this->displayNavBar = false;
     $this->useContainerCssClass = true;
     if ($browserInfo->getSwarmUaItem()->id === "PS3") {
         $this->bodyScripts[] = swarmpath("js/base64encoder.js");
     }
     $this->bodyScripts[] = swarmpath("js/run.js?" . time());
     $client = null;
     // Try to get the client id from the cookie.
     $clientId = $this->getClientIdFromCookie();
     if (isset($clientId)) {
         // If client id is present then try to reuse it.
         // This might throw an exception if client id doesn't exist on the database, the user agent doesn't match or the ip address doesn't match the database record.
         try {
             $client = Client::newFromContext($this->getContext(), $runToken, $clientId, true);
         } catch (Exception $e) {
         }
     }
     // $client is not set if restoring client id failed or cookie is not present.
     if (!isset($client)) {
         $client = Client::newFromContext($this->getContext(), $runToken);
         $clientId = $client->getClientRow()->id;
         $this->saveClientIdInCookie($clientId);
     }
     $html = '<script>' . 'SWARM.client_id = ' . json_encode($clientId) . ';' . 'SWARM.run_token = ' . json_encode($runToken) . ';' . 'SWARM.decode_html = ' . json_encode(isMaple()) . ';' . '</script>';
     $html .= '<div class="row">' . '<div class="span2">' . '<div class="well pagination-centered thumbnail">' . '<img src="' . swarmpath("img/{$uaItem->displayicon}.sm.png") . '" class="swarm-browsericon ' . '" alt="' . htmlspecialchars($uaItem->displaytitle) . '" title="' . htmlspecialchars($uaItem->displaytitle) . '">' . '<span class="label">' . htmlspecialchars($uaItem->displaytitle) . '</span>' . '<br/>' . '<span class="label label-info" id="deviceName"></span>' . '</div>' . '</div>' . '<div class="span7">' . '<h2>' . htmlspecialchars($client->getUserRow()->name) . '</h2>' . '<p><strong>Status:</strong> <span id="msg"></span></p>' . '</div>' . '</div>' . '<div id="iframes"></div>' . '<div class="well">' . '<h3>History</h3>' . '<ul id="history"></ul>' . '</div>';
     return $html;
 }
Пример #2
0
function swarmpath($rel, $options = array())
{
    global $swarmContext;
    // Only normalize the contextpath once
    static $path;
    if (is_null($path)) {
        // Add trailing slash if it's missing
        $path = $swarmContext->getConf()->web->contextpath;
        if (substr($path, -1) !== '/') {
            $path = "{$path}/";
        }
        // Make sure path starts absolute.
        // Either with protocol https?://domain, relative-protocol //domain
        // or starting at domain root with a slash.
        if (substr($path, 0, 6) !== 'http:/' && substr($path, 0, 6) !== 'https:' && $path[0] !== '/') {
            $path = "/{$path}";
        }
        // Update it (just in case it's used elsewhere)
        $swarmContext->getConf()->web->contextpath = $path;
    }
    // Options
    $options = (array) $options;
    if (in_array('fullurl', $options)) {
        $prefix = $swarmContext->getConf()->web->server . $path;
    } else {
        $prefix = $path;
    }
    // Just in case, strip the leading slash
    // from the requested path (check length, becuase may be an empty string,
    // avoid PHP E_NOTICE for undefined [0], which could JSON output to be interrupted)
    if (strlen($rel) > 0 && $rel[0] === '/') {
        $rel = substr($rel, 1);
    }
    $result = $prefix . $rel;
    if (isMaple()) {
        $result = getRelativePath(getCurrentRequestPath(), $result);
    }
    return $result;
}
Пример #3
0
    /**
     * Small messages
     */
    public function outputMini($title, $message = null)
    {
        ?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
	<meta charset="UTF-8">
	<title><?php 
        echo htmlspecialchars($title . ' - ' . $this->getContext()->getConf()->web->title);
        ?>
</title>
	<link rel="stylesheet" href="<?php 
        echo isMaple() ? swarmpath('css/bootstrapsamsung.css') : swarmpath('css/bootstrap.min.css');
        ?>
">
	<link rel="stylesheet" href="<?php 
        echo isMaple() ? swarmpath('css/testswarmsamsung.css') : swarmpath('css/testswarm.css');
        ?>
">
</head>
<body>
<div class="hero-unit">
	<h1><?php 
        echo htmlspecialchars($title);
        ?>
</h1>
<?php 
        if ($message) {
            ?>
	<p><?php 
            echo htmlspecialchars($message);
            ?>
</p>
<?php 
        }
        ?>
</div>
</body>
</html>
<?php 
    }