本文整理汇总了PHP中REST::html_start方法的典型用法代码示例。如果您正苦于以下问题:PHP REST::html_start方法的具体用法?PHP REST::html_start怎么用?PHP REST::html_start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类REST
的用法示例。
在下文中一共展示了REST::html_start方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start
private function start()
{
if ($this->headers === null) {
$this->headers = array();
}
echo REST::html_start($this->title) . $this->html_form . <<<EOS
<h2>Contents</h2>
<table class="toc" id="directory_index"><tbody>
<tr><th class="delete"></th><th class="name">Name</th>
EOS;
foreach ($this->headers as $header) {
if (strtolower(substr($header, -4)) == 'html') {
$header = substr($header, 0, -4);
}
echo '<th class="' . preg_replace('/[^\\w\\d]+/', '', $header) . '">' . htmlspecialchars($header, ENT_QUOTES, 'UTF-8') . '</th>';
}
echo "</tr>\n";
$this->header_sent = true;
}
示例2: setHTML
/**
* Injects your own HTML generation functions instead of the default ones.
*
* Both parameters must be of PHP's pseudo type "callback". See PHP's
* documentation for details.
*
* @param $html_start callback Must point to a method with the same signature
* as self::html_start().
* @param $html_end callback Must point to a method with the same signature
* os self::html_end().
*/
public static function setHTML($html_start, $html_end)
{
self::$html_start = $html_start;
self::$html_end = $html_end;
}
示例3: sprintf
);
}
$bct = REST::best_content_type(array('text/html' => 1, 'application/xhtml+xml' => 1, 'text/plain' => 1), 'text/html');
if ($bct === 'text/plain') {
REST::header(array('Content-Type' => 'text/plain; charset=US-ASCII', 'Refresh' => '60; ' . $_SERVER['REQUEST_URI'], 'Cache-Control' => 'no-cache'));
if ($_SERVER['REQUEST_METHOD'] === 'HEAD') {
exit;
}
echo $tokens / $total;
exit;
}
REST::header(array('Content-Type' => REST::best_xhtml_type() . '; charset=UTF-8', 'Refresh' => '60; ' . $_SERVER['REQUEST_URI'], 'Cache-Control' => 'no-cache'));
if ($_SERVER['REQUEST_METHOD'] === 'HEAD') {
exit;
}
echo REST::html_start('Progress');
?>
<table class="progress"><tbody>
<tr>
<td style="width: <?php
echo $width * $tokens / $total;
?>
pt;" class="done">
<?php
if ($percentage >= 50) {
echo sprintf('%.1f%%', $percentage);
}
?>
</td>
<td style="width: <?php
echo $width - $width * $tokens / $total;
示例4: htmlentities
exit;
}
echo <<<EOS
TokenId: {$row[0]}
TokenName: {$row[1]}
TokenURL: {$tokenURL}
Timeout: {$row[2]}
Description: {$row[3]}
EOS;
exit;
}
REST::header(array('Content-Type' => $xhtmltype . '; charset=UTF-8', 'Cache-Control' => 'no-cache'));
if ($_SERVER['REQUEST_METHOD'] === 'HEAD') {
exit;
}
echo REST::html_start('Lock info');
?>
<h2>Lock info</h2>
<table class="lockinfo"><tbody>
<tr><th>TokenId:</th><td id="tokenId"><?php
echo htmlentities($row[0]);
?>
</td></tr>
<tr><th>TokenName:</th><td id="tokenName"><?php
echo htmlentities($row[1]);
?>
</td></tr>
<tr><th>TokenURL:</th><td id="tokenURL"><a href="<?php
echo htmlspecialchars($tokenURL, ENT_QUOTES, 'UTF-8');
?>
"><?php
示例5: ksort
}
ksort($handles);
$handles = array_keys($handles);
if ($p_max > 0) {
$handles = array_slice($handles, $p_page * $p_max, $p_max);
}
//... And print everything
$xhtml_type = REST::best_xhtml_type() . '; charset=UTF-8';
$content_type = REST::best_content_type(array($xhtml_type => 1.0, 'application/json' => 1.0), $xhtml_type);
REST::header(array('status' => REST::HTTP_OK, 'Content-Type' => $content_type));
// For a HEAD request, we can quit now:
if ($_SERVER['REQUEST_METHOD'] === 'HEAD') {
exit;
}
if ($content_type == $xhtml_type) {
echo REST::html_start('Searchresults');
echo <<<EOS
<table class="searchresults"><tbody><tr>
<th class="handle">Handle</th>
</tr>
EOS;
$num_rows = 0;
while ($search_stmt->fetch()) {
$num_rows++;
echo "<tr class=\"handle\"><td><a href=\"" . CP::PORTAL_URL . "{$handle}\">{$handle}</a></td></tr>";
}
if (!$num_rows) {
echo "<tr class=\"handle\"><td>No results found</td></tr>";
}
echo "</tbody></table>";
echo REST::html_end();
示例6: foreach
$content_type = REST::best_content_type(array($xhtml_type => 1.0, 'application/json' => 1.0, 'application/x-www-form-urlencoded' => 1.0, 'text/plain; charset=US-ASCII' => 0.5), $xhtml_type);
// When was this handle last modified?
$modified = 0;
foreach ($handle->timestamp as $idx => $timestamp) {
if ($timestamp > $modified) {
$modified = $timestamp;
}
}
REST::check_if_modified_since($modified);
REST::header(array('status' => REST::HTTP_OK, 'Content-Type' => $content_type, 'Modified' => REST::http_date($modified)));
// For a HEAD request, we can quit now:
if ($_SERVER['REQUEST_METHOD'] === 'HEAD') {
exit;
}
if ($content_type == $xhtml_type) {
echo REST::html_start('Metadata for handle ' . htmlspecialchars($handle->handle(), ENT_COMPAT, 'UTF-8'));
echo <<<EOS
<table class="handledata"><tbody><tr>
<th class="idx">idx</th>
<th class="type">type</th>
<th class="data">data</th>
<th class="data">refs</th>
<th class="modified">timestamp</th>
</tr>
EOS;
foreach ($handle->type as $idx => $type) {
if (strpos($type, 'HS_') === 0) {
continue;
}
echo '<tr><td class="idx">' . $idx . '</td><td class="type">' . htmlspecialchars($type, ENT_COMPAT, 'UTF-8') . '</td><td class="data">';
if ($type == 'URL' && REST::isValidURI($handle->data[$idx])) {
示例7: array
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Id: database_types.php 2459 2009-08-10 21:20:41Z pieterb $
**************************************************************************/
/**
* File documentation.
* @todo Implement retrieval of info about individual database types.
* @package Portal
*/
require_once 'include/global.php';
REST::require_method('GET', 'HEAD');
$path_info = Portal::path_info();
if (!empty($path_info[0])) {
$id = Portal_DB::databaseTypeIDByName($path_info[0]);
if (empty($id)) {
REST::fatal(REST::HTTP_NOT_FOUND);
}
REST::header(REST::best_xhtml_type() . '; charset="UTF-8"');
echo REST::html_start("Database type \"{$path_info[0]}\"") . Portal_DB::databaseTypeDescription($id) . REST::html_end();
exit;
}
$directory = RESTDir::factory();
foreach (Portal_DB::databaseTypeIDs() as $id) {
$directory->line(Portal_DB::databaseTypeName($id), array('Content-Type' => Portal_DB::databaseTypeContentType($id), 'Extension' => Portal_DB::databaseTypeExtension($id)));
}
$directory->end();
示例8: SUM
);
REST::fatal(REST::HTTP_ACCEPTED);
}
REST::require_method('GET', 'HEAD');
$result = Portal_MySQL::query(<<<EOS
SELECT SUM(`usage_seconds`),
DATE(`usage_timestamp`),
`usage_status`
FROM `Usage`
WHERE `user_id` = {$userid}
GROUP BY 3,2
ORDER BY 3,2 ASC;
EOS
);
REST::header(REST::best_xhtml_type() . '; charset="UTF-8"');
echo REST::html_start('Usage statistics') . <<<EOS
<!--<form action="stats" method="post">
token: <input type="text" name="token" value=""/>
seconds: <input type="text" name="seconds" value=""/>
<input type="submit"/>
</form>-->
<table class="usagestats"><tbody>
<tr>
<th class="date">Date</th>
<th class="walltime">Walltime</th>
<th class="status">Status</th>
</tr>
EOS;
$STATUS_STRING = array(0 => 'OK', 1 => 'Transient error', 2 => 'Fatal error');
while ($row = $result->fetch_row()) {
echo '<tr><td class="date">' . gmstrftime('%F', strtotime($row[1] . 'T00:00:00Z')) . '</td><td class="walltime">' . sprintf('%d:%02d:%02d', floor($row[0] / 3600), floor($row[0] % 3600 / 60), $row[0] % 60) . '</td><td class="status">' . $STATUS_STRING[$row[2]] . "</td></tr>\n";
示例9: show_message
/**
* Shows a message screen to the user.
* @param string $message HTML message
* @param string $status HTTP status
* @param string $redirect URL for automatic redirection
* @param string $location Location of the created URL
*/
public static function show_message($message, $status, $location)
{
REST::header(array('status' => $status, 'Content-Type' => REST::best_xhtml_type() . '; charset=UTF-8', 'Location' => REST::rel2url($location)));
echo REST::html_start('Redirect') . <<<EOS
<p>{$message}</p>
<script type="text/javascript"><![CDATA[
setTimeout(
'window.location.href = "{$location}";',
1000
);
]]></script>
EOS;
echo REST::html_end();
exit;
}
示例10: COUNT
SELECT `TV`.`tokenId`
FROM `TokenValues` AS `TV` NATURAL LEFT JOIN `Tokens` AS `T`
WHERE `T`.`tokenId` IS NULL;
EOS
);
Topos::real_query(<<<EOS
DELETE `TokenValues`
FROM `OrphanValues` NATURAL JOIN `TokenValues`;
EOS
);
Topos::real_query(<<<EOS
DROP TABLE `OrphanValues`;
EOS
);
REST::header(array('Content-Type' => REST::best_xhtml_type() . '; charset=UTF-8'));
echo REST::html_start('Pool');
echo '<p>Pool destroyed successfully.</p>';
echo REST::html_end();
exit;
}
REST::require_method('HEAD', 'GET');
// Fetch number of tokens
$query = <<<EOS
SELECT COUNT(`tokenId`), SUM(UNIX_TIMESTAMP() < `tokenLockTimeout`)
FROM `Pools` NATURAL JOIN `Tokens`
WHERE `poolName` = {$escPool};
EOS;
list($ntokens, $nlocks) = Topos::query($query)->fetch_row();
$form = <<<EOS
<h2>Forms</h2>
<h3>Delete</h3>
示例11:
*
* $Id$
**************************************************************************/
require_once 'include/global.php';
$escPool = Topos::escape_string($TOPOS_POOL);
// TODO: the DELETE handler was written by Evert, using a subquery. I'm used
// to doing this with a single JOIN query...
if ($_SERVER['REQUEST_METHOD'] === 'DELETE') {
Topos::real_query(<<<EOS
UPDATE `Tokens`
SET `tokenLockTimeout` = 0, `tokenLockUUID` = null
WHERE `poolId` = (SELECT `poolId` FROM `Pools` WHERE `Pools`.`poolName` = {$escPool});
EOS
);
REST::header(array('Content-Type' => REST::best_xhtml_type() . '; charset=UTF-8'));
echo REST::html_start('Locks');
echo '<p>Locks destroyed successfully.</p>';
echo REST::html_end();
exit;
}
REST::require_method('HEAD', 'GET');
$result = Topos::query(<<<EOS
SELECT `tokenId`, `tokenName`, `tokenLockUUID`,
`tokenLockTimeout` - UNIX_TIMESTAMP(), `tokenLockDescription`
FROM `Pools` NATURAL JOIN `Tokens`
WHERE `poolName` = {$escPool}
AND `tokenLockTimeout` > UNIX_TIMESTAMP()
ORDER BY 1;
EOS
);
$directory = RESTDir::factory();
示例12: address
if (!$mailresult) {
REST::fatal(REST::HTTP_INTERNAL_SERVER_ERROR, <<<EOS
Your registration was successful, but the email containing your password could not be sent.
The site administrator has been informed and will contact you as soon as possible.
EOS
);
}
$message = <<<EOS
<p>Registration successful.</p>
<p>An e-mail with password has been sent to
<a href="mailto:{$_GET['email']}">{$_GET['email']}</a>.</p>
EOS;
if ($referrer) {
$message .= <<<EOS
<p>Click here to continue:<br/>
<a href="{$referrer}">{$referrer}</a></p>
EOS;
}
REST::fatal(REST::HTTP_ACCEPTED, $message);
}
REST::header(REST::best_xhtml_type() . '; charset="UTF-8"');
echo REST::html_start('Register') . <<<EOS
<p>Fill in your e-mail address and display name below, and you'll recieve a password.</p>
<form action="register.php" method="get">
<input type="hidden" name="referrer" value="{$referrer}"/>
<input type="text" name="email" value=""/> E-mail address (invisible to other users)<br/>
<input type="text" name="name" value=""/> Display name (visible to other users if you share your databases)<br/>
<input type="submit" value="Request password"/>
</form>
EOS
. REST::html_end();
示例13: catch
try {
$query = <<<EOS
DELETE `Tokens`, `TokenValues`
FROM `Tokens` NATURAL JOIN `Pools` NATURAL JOIN `TokenValues`
WHERE `Tokens`.`tokenId` = {$TOPOS_TOKEN}
AND `poolName` = {$escPool};
EOS;
Topos::real_query($query);
$retries = 0;
} catch (Topos_Retry $e) {
$retries++;
}
}
if (Topos::mysqli()->affected_rows) {
REST::header(array('Content-Type' => REST::best_xhtml_type() . '; charset=UTF-8'));
echo REST::html_start('Token destroyed');
echo '<p>Token destroyed successfully.</p>';
echo REST::html_end();
exit;
} else {
REST::fatal(REST::HTTP_NOT_FOUND);
}
}
REST::require_method('HEAD', 'GET');
if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
REST::fatal(REST::HTTP_NOT_MODIFIED);
}
$query = <<<EOS
SELECT `tokenValue`, `tokenType`, `tokenCreated`, `tokenName`,
IF(`tokenLockTimeout` > UNIX_TIMESTAMP(),`tokenLockUUID`,NULL)
FROM `Pools` NATURAL JOIN `Tokens` NATURAL JOIN `TokenValues`