本文整理匯總了PHP中Asset函數的典型用法代碼示例。如果您正苦於以下問題:PHP Asset函數的具體用法?PHP Asset怎麽用?PHP Asset使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Asset函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: showImage
function showImage($path)
{
if (strpos($path, "http") === 0) {
return $path;
}
return Asset('public/image/') . '/' . $path;
}
示例2: AvailableThemes
/**
* Looks through the themes directory for valid themes and returns them as
* an associative array of "Theme Name" => "Theme Info Array". It also adds
* a "Folder" definition to the Theme Info Array for each.
*/
public function AvailableThemes()
{
if (!is_array($this->_AvailableThemes)) {
$ThemeInfo = array();
$ThemeFolders = Gdn_FileSystem::Folders(PATH_THEMES);
$ThemeAboutFiles = Gdn_FileSystem::FindAll(PATH_THEMES, 'about.php', $ThemeFolders);
// Include them all right here and fill the theme info array
$ThemeCount = is_array($ThemeAboutFiles) ? count($ThemeAboutFiles) : 0;
for ($i = 0; $i < $ThemeCount; ++$i) {
include $ThemeAboutFiles[$i];
// Define the folder name for the newly added item
foreach ($ThemeInfo as $ThemeName => $Info) {
if (array_key_exists('Folder', $ThemeInfo[$ThemeName]) === FALSE) {
$Folder = substr($ThemeAboutFiles[$i], strlen(PATH_THEMES));
if (substr($Folder, 0, 1) == DS) {
$Folder = substr($Folder, 1);
}
$Folder = substr($Folder, 0, strpos($Folder, DS));
$ThemeInfo[$ThemeName]['Folder'] = $Folder;
// Add the screenshot.
$ScreenshotPath = SafeGlob(PATH_THEMES . "/{$Folder}/screenshot.*", array('gif', 'jpg', 'png'));
if (count($ScreenshotPath) > 0) {
$ScreenshotPath = $ScreenshotPath[0];
$ThemeInfo[$ThemeName]['ScreenshotUrl'] = Asset(str_replace(PATH_ROOT, '', $ScreenshotPath));
}
}
}
}
$this->_AvailableThemes = $ThemeInfo;
}
return $this->_AvailableThemes;
}
示例3: htmlMenu
public function htmlMenu($menus = array(), $lft = 0, $rgt = null, $deep = 0)
{
global $treeMenu;
if ($lft == 0 && $rgt == null && $deep == 0) {
$treeMenu .= '<ul>';
}
foreach ($menus as $key => $val) {
if ($val['lft'] > $lft && ($val['rgt'] < $rgt || is_null($rgt)) && $val['deep'] == $deep + 1) {
unset($menus[$key]);
$treeMenu .= '<li>';
$treeMenu .= $val['name'] . ' ----------------------------------------------' . '<a href="' . Asset('admin/category/del/') . '/' . $val['id'] . '"> <button type="button" class="btn btn-default btn-sm"><i class="glyphicon glyphicon-trash"></i></button> </a>' . '<a href="' . Asset('admin/category/update/') . '/' . $val['id'] . '"> <button type="button" class="btn btn-default btn-sm"><i class="glyphicon glyphicon-edit"></i></button> </a>';
if ($val['rgt'] != $val['lft'] + 1) {
$treeMenu .= '<ul>';
}
$this->htmlMenu($menus, $val['lft'], $val['rgt'], $val['deep']);
if ($val['rgt'] != $val['lft'] + 1) {
$treeMenu .= '</ul>';
}
$treeMenu .= '</li>';
}
}
if ($lft == 0 && is_null($rgt) && $deep == 0) {
$treeMenu .= '</ul>';
}
return $treeMenu;
}
示例4: _GetButton
private function _GetButton()
{
$ImgSrc = Asset('/plugins/GoogleSignIn/design/google-icon.png');
$ImgAlt = T('Sign In with Google');
$SigninHref = $this->_AuthorizeHref();
$PopupSigninHref = $this->_AuthorizeHref(TRUE);
return "<a id=\"GoogleAuth\" href=\"{$SigninHref}\" class=\"PopupWindow\" title=\"{$ImgAlt}\" popupHref=\"{$PopupSigninHref}\" popupHeight=\"400\" popupWidth=\"800\" ><img src=\"{$ImgSrc}\" alt=\"{$ImgAlt}\" /></a>";
}
示例5: imageBook
/**
* Show full url of book image.
* @param [string] $name
* @return [string] full link to image
*/
function imageBook($url)
{
if (File::exists(base_path() . '/public/resourcebook/' . $url)) {
return Asset('resourcebook/' . $url);
} else {
return Asset('resourcebook/question-mark.png');
}
}
示例6: Img
/**
* Returns an img tag.
*/
function Img($Image, $Attributes = '', $WithDomain = FALSE)
{
if ($Attributes == '') {
$Attributes = array();
}
if (substr($Image, 0, 7) != 'http://' && $Image != '') {
$Image = Asset($Image, $WithDomain);
}
return '<img src="' . $Image . '"' . Attribute($Attributes) . ' />';
}
示例7: Base_Render_Before
/**
* Add our script and css to every page.
*
* @param $Sender
*/
public function Base_Render_Before($Sender)
{
if (!C("Plugins.Vanoogle.CSE")) {
return;
}
// Normally one would use ->AddJsFile or ->Head->AddScript, but these insert a version arg in the url that makes the google api barf.
$Sender->Head->AddTag('script', array('src' => Asset('https://www.google.com/jsapi', FALSE, FALSE), 'type' => 'text/javascript', 'id' => C("Plugins.Vanoogle.CSE")));
$Sender->AddCssFile('vanoogle.css', 'plugins/Vanoogle');
$Sender->AddJsFile('vanoogle.js', 'plugins/Vanoogle');
}
示例8: __construct
/**
* Setup some variables for instance.
*/
public function __construct()
{
parent::__construct();
$this->mediaCache = null;
$this->mediaCacheExpire = 60 * 60 * 6;
$this->AssetPath = Asset('/plugins/editor');
$this->pluginInfo = Gdn::pluginManager()->getPluginInfo('editor', Gdn_PluginManager::ACCESS_PLUGINNAME);
$this->ForceWysiwyg = c('Plugins.editor.ForceWysiwyg', false);
// Check for additional formats
$this->EventArguments['formats'] =& $this->Formats;
$this->fireEvent('GetFormats');
}
示例9: userPhotoDefaultUrl
/**
*
*
* @param $User
* @return string
*/
function userPhotoDefaultUrl($User)
{
$Email = val('Email', $User);
$Https = Gdn::request()->scheme() == 'https';
$Protocol = $Https ? 'https://secure.' : 'http://www.';
$Url = $Protocol . 'gravatar.com/avatar.php?' . 'gravatar_id=' . md5(strtolower($Email)) . '&size=' . c('Garden.Thumbnail.Width', 50);
if (c('Plugins.Gravatar.UseVanillicon', true)) {
$Url .= '&default=' . urlencode(Gdn::request()->scheme() . '://vanillicon.com/' . md5($Email) . '.png');
} else {
$Url .= '&default=' . urlencode(Asset(c('Plugins.Gravatar.DefaultAvatar', c('Garden.DefaultAvatar', 'plugins/Gravatar/default.png')), true));
}
return $Url;
}
示例10: UserPhotoDefaultUrl
function UserPhotoDefaultUrl($User)
{
$Email = GetValue('Email', $User);
$HTTPS = GetValue('HTTPS', $_SERVER, '');
$Protocol = strlen($HTTPS) || GetValue('SERVER_PORT', $_SERVER) == 443 ? 'https://secure.' : 'http://www.';
$Url = $Protocol . 'gravatar.com/avatar.php?' . 'gravatar_id=' . md5(strtolower($Email)) . '&size=' . C('Garden.Thumbnail.Width', 50);
if (C('Plugins.Gravatar.UseVanillicon', FALSE)) {
$Url .= '&default=' . urlencode(Asset('http://vanillicon.com/' . md5($User->Name) . '.png'));
} else {
$Url .= '&default=' . urlencode(Asset(C('Plugins.Gravatar.DefaultAvatar', 'plugins/Gravatar/default.gif'), TRUE));
}
return $Url;
}
示例11: ProfileController_AfterAddSideMenu_Handler
public function ProfileController_AfterAddSideMenu_Handler($Sender, $Args)
{
if (!$Sender->User->Photo) {
$Email = GetValue('Email', $Sender->User);
$Protocol = Gdn::Request()->Scheme() == 'https' ? 'https://secure.' : 'http://www.';
$Url = $Protocol . 'gravatar.com/avatar.php?' . 'gravatar_id=' . md5(strtolower($Email)) . '&size=' . C('Garden.Profile.MaxWidth', 200);
if (C('Plugins.Gravatar.UseVanillicon', TRUE)) {
$Url .= '&default=' . urlencode(Gdn::Request()->Scheme() . '://vanillicon.com/' . md5($Email) . '_200.png');
} else {
$Url .= '&default=' . urlencode(Asset(C('Plugins.Gravatar.DefaultAvatar', 'plugins/Gravatar/default_250.png'), TRUE));
}
$Sender->User->Photo = $Url;
}
}
示例12: UserBuilder
/**
* Override the default UserBuilder function with one that switches the photo
* out with a gravatar url if the photo is empty.
*/
function UserBuilder($Object, $UserPrefix = '')
{
$User = new stdClass();
$UserID = $UserPrefix . 'UserID';
$Name = $UserPrefix . 'Name';
$Photo = $UserPrefix . 'Photo';
$Email = $UserPrefix . 'Email';
$User->UserID = $Object->{$UserID};
$User->Name = $Object->{$Name};
$User->Photo = property_exists($Object, $Photo) ? $Object->{$Photo} : '';
if ($User->Photo == '' && property_exists($Object, $Email)) {
$User->Photo = 'http://www.gravatar.com/avatar.php?' . 'gravatar_id=' . md5(strtolower($Object->{$Email})) . '&default=' . urlencode(Asset(Gdn::Config('Plugins.Gravatar.DefaultAvatar', 'plugins/Gravatar/default.gif'), TRUE)) . '&size=' . Gdn::Config('Garden.Thumbnail.Width', 40);
}
return $User;
}
示例13: UserBuilder
/**
* Override the default UserBuilder function with one that switches the photo
* out with a gravatar url if the photo is empty.
*/
function UserBuilder($Object, $UserPrefix = '')
{
$User = new stdClass();
$UserID = $UserPrefix . 'UserID';
$Name = $UserPrefix . 'Name';
$Photo = $UserPrefix . 'Photo';
$Email = $UserPrefix . 'Email';
$User->UserID = $Object->{$UserID};
$User->Name = $Object->{$Name};
$User->Photo = property_exists($Object, $Photo) ? $Object->{$Photo} : '';
$Protocol = strlen($_SERVER['HTTPS']) > 0 || $_SERVER['SERVER_PORT'] == 443 ? 'https://secure.' : 'http://www.';
if ($User->Photo == '' && property_exists($Object, $Email)) {
$User->Photo = $Protocol . 'gravatar.com/avatar.php?' . 'gravatar_id=' . md5(strtolower($Object->{$Email})) . '&default=' . urlencode(Asset(Gdn::Config('Plugins.Gravatar.DefaultAvatar', 'plugins/Gravatar/default.gif'), TRUE)) . '&size=' . Gdn::Config('Garden.Thumbnail.Width', 40);
}
return $User;
}
示例14: getTutorials
/**
* Get all tutorials, or a specific one.
*/
function getTutorials($TutorialCode = '')
{
// Define all Tutorials
$Tutorials = array(array('Code' => 'introduction', 'Name' => 'Introduction to Vanilla', 'Description' => 'This video gives you a brief overview of the Vanilla administrative dashboard and the forum itself.', 'VideoID' => '31043422'), array('Code' => 'using-the-forum', 'Name' => 'Using the Forum', 'Description' => 'Learn how to start, announce, close, edit and delete discussions and comments.', 'VideoID' => '31502992'), array('Code' => 'private-conversations', 'Name' => 'Private Conversations', 'Description' => 'Learn how to start new private conversations and add people to them.', 'VideoID' => '31498383'), array('Code' => 'user-profiles', 'Name' => 'User Profiles', 'Description' => 'Learn how to use and manage your user profile. ', 'VideoID' => '31499266'), array('Code' => 'appearance', 'Name' => 'Changing the appearance of your forum', 'Description' => 'This tutorial takes you through the "Appearance" section of the Vanilla Forums administrative dashboard.', 'VideoID' => '31089641'), array('Code' => 'roles-and-permissions', 'Name' => 'Managing Roles and Permissions in Vanilla', 'Description' => 'This tutorial walks you through how to create new roles and how to use permissions.', 'VideoID' => '31091056'), array('Code' => 'users', 'Name' => 'Finding & Managing Users', 'Description' => 'This tutorial shows you how to search for and manage users.', 'VideoID' => '31094514'), array('Code' => 'category-management-and-advanced-settings', 'Name' => 'Category Management & Advanced Settings', 'Description' => 'Learn how to add, edit, and manage categories. Also learn about advanced forum settings.', 'VideoID' => '31492046'), array('Code' => 'user-registration', 'Name' => 'User Registration', 'Description' => 'Learn to control how new users get into your community.', 'VideoID' => '31493119'));
// Default Thumbnails
$Thumbnail = Asset('applications/dashboard/design/images/help-tn-200.jpg');
$LargeThumbnail = Asset('applications/dashboard/design/images/help-tn-640.jpg');
for ($i = 0; $i < count($Tutorials); $i++) {
$Tutorials[$i]['Thumbnail'] = $Thumbnail;
$Tutorials[$i]['LargeThumbnail'] = $LargeThumbnail;
}
if ($TutorialCode != '') {
$Keys = consolidateArrayValuesByKey($Tutorials, 'Code');
$Index = array_search($TutorialCode, $Keys);
if ($Index === FALSE) {
return FALSE;
}
// Not found!
// Found it, so define it's thumbnail location
$Tutorial = val($Index, $Tutorials);
$VideoID = val('VideoID', $Tutorial);
try {
$videoInfo = json_decode(file_get_contents("http://vimeo.com/api/v2/video/{$Tutorial['VideoID']}.json"));
if ($videoInfo && ($vimeo = array_shift($videoInfo))) {
$Tutorial['Thumbnail'] = str_replace('http://', '//', val('thumbnail_medium', $vimeo));
$Tutorial['LargeThumbnail'] = str_replace('http://', '//', val('thumbnail_large', $vimeo));
}
} catch (Exception $Ex) {
// Do nothing
}
return $Tutorial;
} else {
// Loop through each tutorial populating the thumbnail image location
try {
foreach ($Tutorials as $Key => &$Tutorial) {
$videoInfo = json_decode(file_get_contents("http://vimeo.com/api/v2/video/{$Tutorial['VideoID']}.json"));
if ($videoInfo && ($vimeo = array_shift($videoInfo))) {
$Tutorial['Thumbnail'] = str_replace('http://', '//', val('thumbnail_medium', $vimeo));
$Tutorial['LargeThumbnail'] = str_replace('http://', '//', val('thumbnail_large', $vimeo));
}
}
} catch (Exception $Ex) {
// Do nothing
}
return $Tutorials;
}
}
示例15: writeConnection
function writeConnection($Row)
{
$c = Gdn::controller();
$Connected = val('Connected', $Row);
?>
<li id="<?php
echo "Provider_{$Row['ProviderKey']}";
?>
" class="Item">
<div class="Connection-Header">
<span class="IconWrap">
<?php
echo img(val('Icon', $Row, Asset('/applications/dashboard/design/images/connection-64.png')));
?>
</span>
<span class="Connection-Name">
<?php
echo val('Name', $Row, t('Unknown'));
if ($Connected) {
echo ' <span class="Gloss Connected">';
if ($Photo = valr('Profile.Photo', $Row)) {
echo ' ' . Img($Photo, array('class' => 'ProfilePhoto ProfilePhotoSmall'));
}
echo ' ' . htmlspecialchars(GetValueR('Profile.Name', $Row)) . '</span>';
}
?>
</span>
<span class="Connection-Connect">
<?php
echo ConnectButton($Row);
?>
</span>
</div>
<!-- <div class="Connection-Body">
<?php
// if (Debug()) {
// decho(val($Row['ProviderKey'], $c->User->Attributes), 'Attributes');
// }
?>
</div>-->
</li>
<?php
}