本文整理汇总了PHP中getResource函数的典型用法代码示例。如果您正苦于以下问题:PHP getResource函数的具体用法?PHP getResource怎么用?PHP getResource使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getResource函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getCurrentURI
/**
* @return string the requested menu item URI
*/
function getCurrentURI()
{
$menu = getResource();
if (array_key_exists($_SERVER['REQUEST_URI'], $menu)) {
return $_SERVER['REQUEST_URI'];
} else {
foreach (array_keys(getResource()) as $href) {
if (preg_match("@^/rest{$href}@", $_SERVER['REQUEST_URI'])) {
return $href;
}
}
}
return key($menu);
}
开发者ID:svenolinho,项目名称:school-solution,代码行数:17,代码来源:rest.php
示例2: avatar
/**
* Return an image tag containing a member's avatar.
*
* @param array $member An array of the member's details. (email is required in this implementation.)
* @param string $avatarFormat The format of the member's avatar (as stored in the database - jpg|gif|png.)
* @param string $className CSS class names to apply to the avatar.
*/
function avatar($member = array(), $className = "")
{
$esoTalkDefault = getResource("core/skin/avatar.png", true);
if (empty($member["email"])) {
$url = $esoTalkDefault;
} else {
$default = C("plugin.Gravatar.default");
if (!$default or empty($member)) {
$default = $esoTalkDefault;
}
$protocol = C("esoTalk.https") ? "https" : "http";
$url = "{$protocol}://www.gravatar.com/avatar/" . md5(strtolower(trim($member["email"]))) . "?d=" . urlencode($default) . "&s=64";
}
return "<img src='{$url}' alt='' class='avatar {$className}'/>";
}
开发者ID:jackpothecary,项目名称:PolycodeSite,代码行数:22,代码来源:plugin.php
示例3: URL
?>
<a href='<?php
echo URL("admin/plugins/toggle/{$k}?token=" . ET::$session->token);
?>
' class='button toggle'><?php
echo $plugin["loaded"] ? "<i class='icon-check'></i> " . T("Enabled") : "<i class='icon-check-empty'></i> " . T("Enable");
?>
</a>
</span>
</div>
<?php
if (file_exists(PATH_PLUGINS . "/{$k}/icon.png")) {
?>
<img src='<?php
echo getResource("addons/plugins/{$k}/icon.png");
?>
' alt=''/><?php
}
?>
<strong><?php
echo $plugin["info"]["name"];
?>
</strong>
<small class='description'><?php
echo $plugin["info"]["description"];
?>
</small>
</li>
<?php
开发者ID:jackpothecary,项目名称:PolycodeSite,代码行数:31,代码来源:plugins.php
示例4: URL
?>
<a href='<?php
echo URL("admin/plugins/toggle/{$k}?token=" . ET::$session->token);
?>
' class='button toggle'><?php
echo $plugin["loaded"] ? "<span class='icon-tick'></span> " . T("Disable") : T("Enable");
?>
</a>
</span>
</div>
<?php
if (file_exists(PATH_PLUGINS . "/{$k}/icon.png")) {
?>
<img src='<?php
echo getResource("plugins/{$k}/icon.png");
?>
' alt=''/><?php
}
?>
<strong><?php
echo $plugin["info"]["name"];
?>
</strong>
<small class='version'><?php
echo $plugin["info"]["version"];
?>
</small>
<small class='description'><?php
echo $plugin["info"]["description"];
?>
开发者ID:nowaym,项目名称:esoTalk,代码行数:31,代码来源:plugins.php
示例5: FormatBotAutoReplies
function FormatBotAutoReplies($_chat, $_answers, $_alternate = true, $html = "", $single = "")
{
global $LZLANG, $GROUPS, $CONFIG;
$tth = ".";
$bind = " " . $LZLANG["client_or"] . " ";
if (!empty($GROUPS[$_chat->DesiredChatGroup]) && $GROUPS[$_chat->DesiredChatGroup]->IsHumanAvailable()) {
$resultpc = queryDB(false, "SELECT * FROM `" . DB_PREFIX . DATABASE_POSTS . "` WHERE `chat_id`='" . DBManager::RealEscape($_chat->ChatId) . "' AND `repost`=0 AND `receiver`='" . DBManager::RealEscape($this->SystemId) . "';");
if ($this->WelcomeManager && DBManager::GetRowCount($resultpc) >= $this->WelcomeManagerOfferHumanChatAfter) {
$tth = " " . $LZLANG["client_or"] . " <a class=\"lz_chat_human\" onclick=\"var _this = this;lz_chat_set_talk_to_human(true,true);this.className='';this.style.cursor='wait';setTimeout(function(){_this.style.cursor='default'; },3000);\">" . $LZLANG["client_talk_to_human"] . "</a>.";
$bind = ", ";
}
}
$lm = empty($CONFIG["gl_dtfbc"]) ? $bind . " <a class=\"lz_chat_mail\" onclick=\"lz_chat_require_leave_message();\">" . $LZLANG["client_leave_a_message"] . "</a>" : "";
if (count($_answers) == 0) {
return $LZLANG["client_bot_no_result_found"] . $lm . $tth;
} else {
if (count($_answers) > 0) {
$html .= $LZLANG["client_your_result"] . "<br>";
$html .= "<ul class=\"lz_chat_bot_resource\">";
foreach ($_answers as $qa) {
if (!empty($qa->ResourceId)) {
$res = getResource($qa->ResourceId);
$target = $qa->NewWindow ? "target=\"_blank\" " : "";
$html .= "<li>";
if ($res["type"] == 2) {
$html .= "<a class=\"lz_chat_link\" href=\"" . $res["value"] . "\" " . $target . ">" . $res["title"] . "</a>";
} else {
if ($res["type"] == 3 || $res["type"] == 4) {
$html .= "<a class=\"lz_chat_link\" href=\"" . LIVEZILLA_URL . "getfile.php?id=" . $res["id"] . "\" " . $target . ">" . $res["title"] . "</a>";
} else {
$html .= "<b>" . $res["title"] . "</b><br><br>" . str_replace("<a ", "<a " . $target, str_replace("<A", "<a", $res["value"]));
}
}
$html .= "</li>";
} else {
if (!empty($qa->Answer)) {
$single = $qa->Answer . "<br><br>";
break;
}
}
}
$html .= "</ul>";
}
}
if (!empty($single)) {
$html = $single;
}
return $html . ($_alternate ? $LZLANG["client_bot_result_found"] . $lm . $tth : "");
}
开发者ID:elderxavier,项目名称:SII9-CREATIVE-STUDIO,代码行数:49,代码来源:objects.global.users.inc.php
示例6: SEND_PHP_MAIL
private function SEND_PHP_MAIL($_receiver = "", $result = "")
{
if (strpos($_receiver, ",") !== false) {
$emails = explode(",", $_receiver);
foreach ($emails as $mail) {
if (!empty($mail)) {
$result = $this->SEND_PHP_MAIL(trim($mail), $result);
}
}
return $result;
}
$mailtext = $this->MailText;
$ehash = md5(date('r', time()));
$EOL = "\r\n";
if (empty($this->FakeSender)) {
$headers = "From: " . $this->Account->Email . $EOL;
} else {
$headers = "From: " . $this->FakeSender . $EOL;
}
$headers .= "Reply-To: " . $this->ReplyTo . $EOL;
$headers .= "Date: " . date("r") . $EOL;
$headers .= "MIME-Version: 1.0" . $EOL;
$headers .= "X-Mailer: LiveZilla.net/" . VERSION . $EOL;
if ($this->Attachments != null) {
$headers .= "Content-Type: multipart/mixed; boundary=\"" . $ehash . "\"" . $EOL . $EOL;
$headers .= "--" . $ehash . $EOL;
$headers .= "Content-Type: text/plain; charset=UTF-8; format=flowed" . $EOL;
$headers .= "Content-Transfer-Encoding: 8bit" . $EOL . $EOL;
$headers .= $mailtext . $EOL . $EOL;
$headers .= "--" . $ehash . $EOL;
foreach ($this->Attachments as $resId) {
$res = getResource($resId);
if ($res == null) {
continue;
}
$content = chunk_split(base64_encode(file_get_contents("./uploads/" . $res["value"])));
$headers .= "Content-Type: application/octet-stream; name=\"" . $res["title"] . "\"" . $EOL;
$headers .= "Content-Transfer-Encoding: base64" . $EOL;
$headers .= "Content-Disposition: attachment; filename=\"" . $res["title"] . "\"" . $EOL . $EOL;
$headers .= $content . $EOL . $EOL;
$headers .= "--" . $ehash . $EOL;
}
$mailtext = "";
$headers .= "--" . $ehash . "--" . $EOL;
} else {
$headers .= "Content-Type: text/plain; charset=UTF-8; format=flowed" . $EOL;
$headers .= "Content-Transfer-Encoding: 8bit" . $EOL . $EOL;
}
if (@mail($_receiver, $this->Subject, $mailtext, $headers)) {
return 1;
} else {
return "The email could not be sent using PHP mail(). Please try another Return Email Address or use SMTP.";
}
}
开发者ID:bgabor,项目名称:RenaniaOpencart,代码行数:54,代码来源:objects.mail.inc.php
示例7: URL
?>
<li><a href='<?php
echo URL("admin/appearance/uninstall/{$k}?token=" . ET::$session->token);
?>
'><i class='icon-remove'></i><?php
echo T("Uninstall");
?>
</a></li>
</ul>
<div class='preview'>
<?php
if (file_exists(PATH_SKINS . "/{$k}/preview.jpg")) {
?>
<img src='<?php
echo getResource("addons/skins/{$k}/preview.jpg");
?>
' alt='<?php
echo $k;
?>
'/>
<?php
} else {
?>
<span><?php
echo T("No preview");
?>
</span><?php
}
?>
</div>
开发者ID:ky0ncheng,项目名称:esotalk-for-sae,代码行数:31,代码来源:appearance.php
示例8: error_reporting
<?php
/* yadl_spaceid - Skip Stamping */
error_reporting(E_ALL);
function getResource($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$url = 'http://search.yahooapis.com/NewsSearchService/V1/newsSearch?appid=YahooDemo&language=en&output=php&' . getenv('QUERY_STRING');
//$response = file_get_contents($url);
$response = getResource($url);
if ($response === false) {
die('Request failed');
}
$resultSet = unserialize($response);
$resultSet = $resultSet['ResultSet'];
$list = '';
// HTML output
$headlines = array();
// track headlines to filter dupes
foreach ($resultSet['Result'] as $result) {
if (!isset($headlines[$result['Title']])) {
$headlines[$result['Title']] = true;
$list .= <<<END_OF_HTML
<li>
<a href="{$result['ClickUrl']}"><q>{$result['Title']}</q></a>
开发者ID:jrose111284,项目名称:TDD-JavaScript-Demo,代码行数:31,代码来源:news.php
示例9: define
/****************************************************************************************
* LiveZilla getfile.php
*
* Copyright 2014 LiveZilla GmbH
* All rights reserved.
* LiveZilla is a registered trademark.
*
* Improper changes to this file may cause critical errors.
***************************************************************************************/
define("IN_LIVEZILLA", true);
if (!defined("LIVEZILLA_PATH")) {
define("LIVEZILLA_PATH", "./");
}
require LIVEZILLA_PATH . "_definitions/definitions.inc.php";
require LIVEZILLA_PATH . "_definitions/definitions.protocol.inc.php";
require LIVEZILLA_PATH . "_lib/functions.global.inc.php";
require LIVEZILLA_PATH . "_lib/objects.global.users.inc.php";
require LIVEZILLA_PATH . "_definitions/definitions.dynamic.inc.php";
if (isset($_GET["id"]) && initDataProvider()) {
$id = $_GET["id"];
if (strpos($id, ".") === false && !isnull($res = getResource($id))) {
if (file_exists("./uploads/" . $res["value"]) && strpos($res["value"], "..") === false) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize("./uploads/" . $res["value"]));
header('Content-Disposition: attachment; filename=' . urlencode($res["title"]));
exit(file_get_contents("./uploads/" . $res["value"]));
}
}
}
header("HTTP/1.0 404 Not Found");
开发者ID:bgabor,项目名称:RenaniaOpencart,代码行数:31,代码来源:getfile.php
示例10: GetMatches
static function GetMatches($_list, $_question, $_language)
{
$answers = array();
foreach ($_list as $reply) {
if ($reply->SearchType != 5) {
$reply->Tags = str_replace(array("!", ".", "?", "=", ")", "(", "-", "_", ":", "#", "~", "?"), "", strtolower($reply->Tags));
}
if (!$reply->MatchesLanguage($_language)) {
continue;
}
$tags = explode(",", $reply->Tags);
$count = 0;
foreach ($tags as $tag) {
if ($reply->SearchType == 5) {
if (@preg_match($reply->Tags, $_question) === 1) {
$count++;
}
} else {
if ($reply->SearchType < 4 && strpos($_question, $tag) !== false || jokerCompare($tag, $_question)) {
$count++;
}
}
}
if ($reply->SearchType == 0 && $count == substr_count($reply->Tags, ",") + 1 || $reply->SearchType > 0 && $count >= $reply->SearchType || $reply->SearchType >= 4 && $count > 0) {
if (empty($reply->Answer)) {
if (getResource($reply->ResourceId) !== null) {
$answers[$count . "-" . count($answers)] = $reply;
}
} else {
$answers = array();
$answers[$count . "-" . count($answers)] = $reply;
break;
}
}
}
krsort($answers);
return $answers;
}
开发者ID:elderxavier,项目名称:SII9-CREATIVE-STUDIO,代码行数:38,代码来源:objects.global.inc.php
示例11: avatar
/**
* Return an image tag containing a member's avatar.
*
* @param int $memberId The member's ID.
* @param string $avatarFormat The format of the member's avatar (as stored in the database - jpg|gif|png.)
* @param string $className CSS class names to apply to the avatar.
*/
function avatar($memberId = 0, $avatarFormat = "", $className = "")
{
// Otherwise, construct the avatar path from the provided information.
if ($memberId and $avatarFormat) {
$file = "uploads/avatars/{$memberId}.{$avatarFormat}";
$url = getWebPath($file);
}
// If the user doesn't have an avatar, return the skin's default one.
if (!$avatarFormat) {
$url = getResource("skins/base/avatar.png");
}
return "<img src='{$url}' alt='' class='avatar {$className}'/>";
}
开发者ID:revskill,项目名称:esoTalk,代码行数:20,代码来源:functions.render.php
示例12: sanitizeHTML
<title><?php
echo sanitizeHTML($data["pageTitle"]);
?>
</title>
<?php
echo $data["head"];
?>
<link rel="icon" type="image/png" href="<?php
echo getResource("core/skin/favicon.png");
?>
"> +v<link rel="apple-touch-icon" href="<?php
echo getResource("core/skin/apple-touch-icon.png");
?>
">
<link rel="apple-touch-icon" href="<?php
echo getResource("core/skin/apple-touch-icon.png");
?>
">
</head>
<body class='<?php
echo $data["bodyClass"];
?>
'>
<?php
$this->trigger("pageStart");
?>
<div id='messages'>
<?php
foreach ($data["messages"] as $message) {
开发者ID:ky0ncheng,项目名称:esotalk-for-sae,代码行数:31,代码来源:default.master.php
示例13: URL
?>
<li><a href='<?php
echo URL("admin/appearance/uninstall/{$k}?token=" . ET::$session->token);
?>
'><?php
echo T("Uninstall");
?>
</a></li>
</ul>
<div class='preview'>
<?php
if (file_exists(PATH_SKINS . "/{$k}/preview.jpg")) {
?>
<img src='<?php
echo getResource("skins/{$k}/preview.jpg");
?>
' alt='<?php
echo $k;
?>
'/>
<?php
} else {
?>
<span><?php
echo T("No preview");
?>
</span><?php
}
?>
</div>
开发者ID:nowaym,项目名称:esoTalk,代码行数:31,代码来源:appearance.php
示例14: GetMatches
static function GetMatches($_list, $_question, $_language, $_chat, $_internal, $lmsi = false, $lmse = false, $lpi = null, $lpe = null)
{
$answers = array();
foreach ($_list as $reply) {
if ($_chat != null) {
$reply->Answer = $_chat->TextReplace($reply->Answer);
}
if ($_internal != null) {
$reply->Answer = $_internal->TextReplace($reply->Answer);
}
if ($reply->SearchType != 5) {
$reply->Tags = str_replace(array("!", ".", "?", "=", ")", "(", "-", "_", ":", "#", "~", "?"), "", strtolower($reply->Tags));
}
if (!$reply->MatchesLanguage($_language)) {
continue;
}
if (empty($_chat->AllocatedTime) && !$reply->Waiting) {
if (!($_internal != null && $_internal->IsBot)) {
continue;
}
}
$tags = explode(",", $reply->Tags);
$count = 0;
if (!empty($_chat)) {
if ($lmsi === false && ($reply->SendInactivityTimeInternal > -1 || $reply->SendInactivityTimeExternal > -1)) {
$lpi = Chat::GetLastPost($_chat->ChatId, true);
$lpe = Chat::GetLastPost($_chat->ChatId, false);
$lmsi = $lpi != null ? $lpi->Created : 0;
$lmse = $lpe != null ? $lpe->Created : 0;
}
$lm = max($lmsi, $lmse);
$lastMessageExternal = $lmse > $lmsi && !empty($lm);
$lastMessageInternal = $lmsi >= $lmse;
if (empty($lm)) {
$lm = $_chat->AllocatedTime;
}
if (!empty($lm)) {
if ($reply->SendInactivityTimeInternal > -1 && $lastMessageExternal && $lmsi > 0) {
if (time() - $lm > $reply->SendInactivityTimeInternal) {
$answers[$count . "-" . count($answers)] = $reply;
}
}
if ($reply->SendInactivityTimeExternal > -1 && $lastMessageInternal) {
if (time() - $lm > $reply->SendInactivityTimeExternal) {
if (!($lpi != null && $reply->Answer == $lpi->Text)) {
$answers[$count . "-" . count($answers)] = $reply;
}
}
}
if ($reply->CloseChat && !empty($_chat) && !empty($_internal)) {
if (count($answers) > 0 && isset($answers["0-0"]) && $answers["0-0"] == $reply) {
$_chat->InternalClose($_internal->SystemId);
}
}
}
}
if ($reply->SendInactivityTimeInternal == -1 && $reply->SendInactivityTimeExternal == -1) {
foreach ($tags as $tag) {
if ($reply->SearchType == 5) {
if (@preg_match($reply->Tags, $_question) === 1) {
$count++;
}
} else {
if ($reply->SearchType < 4 && strpos($_question, $tag) !== false || jokerCompare($tag, $_question)) {
$count++;
}
}
}
if ($reply->SearchType == 0 && $count == substr_count($reply->Tags, ",") + 1 || $reply->SearchType > 0 && $count >= $reply->SearchType || $reply->SearchType >= 4 && $count > 0) {
if (empty($reply->Answer)) {
if (getResource($reply->ResourceId) !== null) {
$answers[$count . "-" . count($answers)] = $reply;
}
} else {
$answers = array();
$answers[$count . "-" . count($answers)] = $reply;
break;
}
}
}
}
return $answers;
}
开发者ID:bgabor,项目名称:RenaniaOpencart,代码行数:83,代码来源:objects.global.inc.php
示例15: header
<?php
/* yadl_spaceid - Skip Stamping */
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Content-Type:text/xml");
$url = 'http://xml.weather.yahoo.com/forecastrss?' . getenv('QUERY_STRING');
function getResource($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$feed = getResource($url);
echo $feed;
开发者ID:jrose111284,项目名称:TDD-JavaScript-Demo,代码行数:22,代码来源:weather.php
示例16: getResource
<?php
echo $form->open();
?>
<div class='section'>
<ul class='form'>
<li>
<label>Default imageset</label>
<div class='checkboxGroup' id='gravatarDefaults'>
<label class='radio'><?php
echo $form->radio("default", "");
?>
<img src='<?php
echo getResource("skins/base/avatar.png");
?>
' class='avatar'> esoTalk default</label>
<label class='radio'><?php
echo $form->radio("default", "mm");
?>
<img src='http://www.gravatar.com/avatar/0?d=mm' class='avatar'> Mystery Man</label>
<label class='radio'><?php
echo $form->radio("default", "identicon");
?>
<img src='http://www.gravatar.com/avatar/0?d=identicon' class='avatar'> Identicon</label>
<label class='radio'><?php
echo $form->radio("default", "monsterid");
?>
<img src='http://www.gravatar.com/avatar/0?d=monsterid' class='avatar'> MonsterID</label>
<label class='radio'><?php
开发者ID:AlexandrST,项目名称:esoTalk,代码行数:31,代码来源:settings.php
示例17: avatar
/**
* Return an image tag containing a member's avatar.
*
* @param array $member An array of the member's details. (memberId is required in this implementation.)
* @param string $avatarFormat The format of the member's avatar (as stored in the database - jpg|gif|png.)
* @param string $className CSS class names to apply to the avatar.
*
* @package esoTalk
*/
function avatar($member = array(), $className = "")
{
$url = getResource("core/skin/avatar.png");
// Construct the avatar path from the provided information.
if (!empty($member["memberId"]) and !empty($member["avatarFormat"])) {
$file = "uploads/avatars/{$member["memberId"]}.{$member["avatarFormat"]}";
$url = getWebPath($file);
}
return "<img src='{$url}' alt='' class='avatar {$className}'/>";
}
开发者ID:AlexandrST,项目名称:esoTalk,代码行数:19,代码来源:functions.render.php
示例18: getResource
<html>
<head>
<title>Sveglie - Leila</title>
<?php
include "functions.php";
getResource();
?>
<link href="res/css/sveglie.css" rel="stylesheet" type="text/css">
<link href="bootstrap-3.3.5-dist/css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css">
<script src="res/js/jquery-2.2.0.min.js"></script>
<script src="bootstrap-3.3.5-dist/js/bootstrap-datetimepicker.min.js"></script>
</head>
<body>
<?php
getMenu();
?>
<div class="main">
<div style="position:relative; height:300px; width:100%; background:#8ce196;">
<article style="position:relative; margin:10 auto; " class="clock">
<div class="hours-container">
<div class="hours"></div>
</div>
<div class="minutes-container">
<div class="minutes"></div>
</div>
<div class="seconds-container">
<div class="seconds"></div>
</div>
</article>
</div>
开发者ID:progettoarp,项目名称:mobile-site,代码行数:31,代码来源:sveglie.php
示例19: Exception
throw new Exception('Invalid response');
}
return json_decode($data['content'], true);
// echo $data['content']; exit;
/* eval('?>' . $data['content'] . '<?'); */
// return $LANG;
}
function fill_en($en, &$dict)
{
foreach ($en as $k => $v) {
if (!isset($dict[$k])) {
$dict[$k] = $v;
}
}
}
$info = getResource('foodle', 'foodle');
// print_r($info); exit;
$base = dirname(dirname(__FILE__)) . '/dictionaries/';
$def_en = json_decode(file_get_contents($base . 'foodle.en.js'), true);
$langcodes = array('en');
foreach ($info['available_languages'] as $lang) {
if ($lang['code'] === 'en') {
continue;
}
echo 'Processing Language ' . $lang['name'] . "\n";
$trans = getTranslation('foodle', 'foodle', $lang['code']);
$transinfo = getTranslationInfo('foodle', 'foodle', $lang['code']);
if ($transinfo['untranslated_entities'] > $transinfo['translated_entities']) {
echo "Skipping language export, because too few translated terms.\n";
continue;
}
开发者ID:r4mp,项目名称:Foodle,代码行数:31,代码来源:dict-loadtrans.php
示例20: head
/**
* Generate all of the HTML to be outputted inside of the <head> tag.
*
* @return string The HTML to go inside <head>.
*/
public function head()
{
$head = "<!-- This page was generated by esoTalk (http://esotalk.org) -->\n";
// Add the canonical URL tag.
if (!empty($this->canonicalURL)) {
$head .= "<link rel='canonical' href='{$this->canonicalURL}'>\n";
}
// Add remote stylesheets.
if (!empty($this->cssFiles["remote"])) {
foreach ($this->cssFiles["remote"] as $url) {
$head .= "<link rel='stylesheet' href='{$url}'>\n";
}
}
unset($this->cssFiles["remote"]);
// Go through CSS stylesheets and aggregate them, then add appropriate tags to the header.
// Here we loop through "groups" of CSS files (usually "global" and "local".)
foreach ($this->cssFiles as $key => $files) {
// If CSS aggregation is enabled, and there's more than one file in this "group", proceed with aggregation.
if (count($files) > 1 and C("esoTalk.aggregateCSS") and !ET::$controller instanceof ETAdminController) {
$files = $this->aggregateFiles($files, "css");
} else {
foreach ($files as &$file) {
$file = PATH_ROOT . "/" . $file;
}
}
unset($file);
// For each of the files that we need to include in the page, add a <link> tag.
foreach ($files as $file) {
$head .= "<link rel='stylesheet' href='" . getResource($file) . "?" . @filemtime($file) . "'>\n";
}
}
// Output all necessary config variables and language definitions, as well as other variables.
$esoTalkJS = array("webPath" => ET::$webPath . ((C("esoTalk.urls.friendly") and !C("esoTalk.urls.rewrite")) ? "/index.php" : ""), "userId" => ET::$session->user ? (int) ET::$session->userId : false, "token" => ET::$session->token, "debug" => C("esoTalk.debug"), "language" => $this->jsLanguage) + (array) $this->jsData;
$head .= "<script>var ET=" . json_encode($esoTalkJS) . "</script>\n";
// Add remote JavaScript.
if (!empty($this->jsFiles["remote"])) {
foreach ($this->jsFiles["remote"] as $url) {
$head .= "<script src='{$url}'></script>\n";
}
}
unset($this->jsFiles["remote"]);
// Same thing as above, but with JavaScript!
foreach ($this->jsFiles as $files) {
// If JS aggregation is enabled, and there's more than one file in this "group", proceed with aggregation.
if (count($files) > 1 and C("esoTalk.aggregateJS") and !ET::$controller instanceof ETAdminController) {
$files = $this->aggregateFiles($files, "js");
} else {
foreach ($files as &$file) {
$file = PATH_ROOT . "/" . $file;
}
}
unset($file);
// For each of the files that we need to include in the page, add a <script> tag.
foreach ($files as $file) {
$head .= "<script src='" . getResource($file) . "?" . filemtime($file) . "'></script>\n";
}
}
// Finally, append the custom HTML string constructed via $this->addToHead().
$head .= $this->head;
$this->trigger("head", array(&$head));
return $head;
}
开发者ID:davchezt,项目名称:fireside,代码行数:67,代码来源:ETController.class.php
注:本文中的getResource函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论