本文整理汇总了PHP中wrap函数的典型用法代码示例。如果您正苦于以下问题:PHP wrap函数的具体用法?PHP wrap怎么用?PHP wrap使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wrap函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_nomobile_link
/**
*
*
* @param array $Params
* @param object $Smarty
* @return string
*/
function smarty_function_nomobile_link($Params, &$Smarty)
{
$Path = val('path', $Params, '', true);
$Text = val('text', $Params, '', true);
$Wrap = val('wrap', $Params, 'li');
return Gdn_Theme::link('profile/nomobile', val('text', $Params, t("Full Site")), val('format', $Params, wrap('<a href="%url" class="%class">%text</a>', $Wrap)));
}
示例2: toString
/**
* Build HTML.
*
* @return string HTML.
*/
public function toString()
{
if ($this->_UserData->numRows() == 0) {
return '';
}
$String = '';
ob_start();
?>
<div class="Box">
<?php
echo panelHeading(t('In this Discussion'));
?>
<ul class="PanelInfo">
<?php
foreach ($this->_UserData->Result() as $User) {
?>
<li>
<?php
echo anchor(wrap(wrap(Gdn_Format::date($User->DateLastActive, 'html')), 'span', array('class' => 'Aside')) . ' ' . wrap(wrap(val('Name', $User), 'span', array('class' => 'Username')), 'span'), userUrl($User));
?>
</li>
<?php
}
?>
</ul>
</div>
<?php
$String = ob_get_contents();
@ob_end_clean();
return $String;
}
示例3: SandboxedString
/** Wrap output value in SandboxString by reference
*
* @param mixed $value Value to wrap
* @param PHPSandbox $sandbox Sandbox instance of calling code
*
* @return mixed|SandboxedString Returns the wrapped value
*/
function &wrapByRef(&$value, $sandbox)
{
if (!$value instanceof SandboxedString && is_object($value) && method_exists($value, '__toString')) {
$strVal = $value->__toString();
if (is_callable($strVal)) {
$value = new SandboxedString($strVal, $sandbox);
}
} else {
if (is_array($value) && count($value)) {
//save current array pointer
$current_key = key($value);
foreach ($value as $key => &$_value) {
$value[$key] = wrap($_value, $sandbox);
}
//rewind array pointer
reset($value);
//advance array to saved array pointer
while (key($value) !== $current_key) {
next($value);
}
} else {
if (is_string($value) && is_callable($value)) {
$value = new SandboxedString($value, $sandbox);
}
}
}
return $value;
}
示例4: tutLink
function tutLink($TutorialCode, $WriteTitle = TRUE, $ThumbnailSize = 'medium', $noGrid = false)
{
$Tutorial = GetTutorials($TutorialCode);
if (!$Tutorial) {
return '';
}
$Thumbnail = $ThumbnailSize == 'medium' ? $Tutorial['Thumbnail'] : $Tutorial['LargeThumbnail'];
$noGrid = $noGrid ? 'no-grid' : '';
echo '<div class="video label-selector-item ' . $noGrid . '">';
echo '<div class="image-wrap">';
echo '<img src="' . $Thumbnail . '" alt="' . $Tutorial['Name'] . '" class = "video-img label-selector-image" />';
?>
<a class="overlay" href="<?php
echo url('/settings/tutorials/' . $Tutorial['Code']);
?>
">
<div class="buttons">
<div class="icon-wrapper"><?php
echo dashboardSymbol('play');
?>
</div>
</div>
<div class="selected"></div>
</a>
<?php
echo '</div>';
echo $WriteTitle ? wrap($Tutorial['Name'], 'div', ['class' => 'video-title title']) : '';
echo '</div>';
}
示例5: base_render_before
public function base_render_before($sender)
{
if ($sender->MasterView == 'admin') {
return;
}
//tell the browser this is a mobile style
$sender->Head->addTag('meta', array('name' => 'viewport', 'content' => "width=device-width,minimum-scale=1.0,maximum-scale=1.0"));
/*
$sender->InformMessage(
'This message will stay here until you dismiss it!',
array(
'CssClass' => 'Dismissable',
'DismissCallbackUrl' => '/plugin/dismissmessage/'
)
);
*/
$sender->Head->addTag('meta', array('name' => 'theme-color', 'content' => "#C08F00"));
// YOU CAN REMOVE FONT-AWESOME IN ONLINE-VERSION
$sender->Head->addTag('link', array('rel' => 'stylesheet', 'href' => "https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"));
//position of the panel
$sender->CssClass .= c('MinusBaseline.Panel.Left', false) ? ' PanelLeft' : ' PanelRight';
//add the hamburger menu
$sender->addAsset('Content', anchor('n', url('#'), 'Hamburger'), 'Hamburger');
//add the searchbox to the panel
//copied from library/vendors/SmartyPlugins/function.searchbox.php
$form = Gdn::factory('Form');
$form->InputPrefix = '';
$search = $form->open(array('action' => Url('/search'), 'method' => 'get')) . $form->textBox('Search', array('placeholder' => t('SearchBoxPlaceHolder', 'Search'))) . $form->button('Go', array('Name' => '')) . $form->close();
$sender->addAsset('Panel', wrap($search, 'div', array('class' => 'SiteSearch')), 'SearchBox');
//nomobile link to switch to the full site
$sender->addAsset('Foot', Gdn_Theme::link('/', t(' '), '<div class="LogoFoot"><a href="%url" class="%class">%text</a></div>'), 'LogoFoot');
//Add logo to button of site
$sender->addAsset('Foot', Gdn_Theme::link('profile/nomobile', t('Full Site'), '<div class="NoMobile"><a href="%url" class="%class">%text</a></div>'), 'NoMobile');
}
示例6: roleController_afterRolesInfo_handler
/**
*
*
* @param $Sender
*/
public function roleController_afterRolesInfo_handler($Sender)
{
if (!Gdn::session()->checkPermission('Garden.Settings.Manage')) {
return;
}
?>
<div class="row form-group">
<div class="label-wrap-wide">
<div class="label"><?php
echo t('Enable Private Communities');
?>
</div>
<div class="info"><?php
echo t('Once enabled, only members will see inside your community.');
?>
</div>
</div>
<div class="input-wrap-right">
<span id="private-community-toggle">
<?php
if (c('Garden.PrivateCommunity', false)) {
echo wrap(anchor('<div class="toggle-well"></div><div class="toggle-slider"></div>', 'settings/privatecommunity/on/' . Gdn::session()->TransientKey()), 'span', array('class' => "toggle-wrap toggle-wrap-on"));
} else {
echo wrap(anchor('<div class="toggle-well"></div><div class="toggle-slider"></div>', 'settings/privatecommunity/off/' . Gdn::session()->TransientKey()), 'span', array('class' => "toggle-wrap toggle-wrap-off"));
}
?>
</span>
</div>
</div>
<?php
}
示例7: smarty_function_signin_link
/**
*
*
* @param array $Params
* @param object $Smarty
* @return string
*/
function smarty_function_signin_link($Params, &$Smarty)
{
if (!Gdn::session()->isValid()) {
$Wrap = val('wrap', $Params, 'li');
return Gdn_Theme::link('signinout', val('text', $Params, ''), val('format', $Params, wrap('<a href="%url" rel="nofollow" class="%class">%text</a>', $Wrap)), $Params);
}
}
示例8: discussionController_beforeCommentDisplay_handler
public function discussionController_beforeCommentDisplay_handler($sender, $args)
{
// Find the previous comment.
if (!$this->previous) {
$this->previous = $args['Discussion'];
if ($sender->data('Page', 1) != 1) {
$this->previous = $sender->CommentModel->get($sender->DiscussionID, 1, $sender->Offset - 1)->firstRow();
}
}
// Calculate the date difference.
$date = new DateTime($args['Comment']->DateInserted);
$gap = $date->diff(new DateTime($this->previous->DateInserted))->days;
$this->previous = $args['Comment'];
if ($gap < c('TimeGap.MinDays', 7) - 1) {
return;
} elseif ($gap < 30) {
$gap = sprintf(t('%s days later'), (int) $gap);
$class = 'Days';
} elseif ($gap < 60) {
$gap = t('1 month later');
$class = 'Month';
} elseif ($gap < 365) {
$gap = sprintf(t('%s months later'), (int) ($gap / 30));
$class = 'Months';
} elseif ($gap < 720) {
$gap = t('1 year later');
$class = 'Year';
} else {
$gap = sprintf(t('%s years later'), (int) ($gap / 365));
$class = 'Years';
}
echo wrap($gap, 'li', ['class' => 'TimeGap ' . $class]);
}
示例9: testOptionHelpers
public function testOptionHelpers()
{
$this->assertInstanceOf(Option\Some::class, some($this->initialValue));
$this->assertInstanceOf(Option\None::class, none());
$this->assertInstanceOf(Option\Some::class, wrap($this->initialValue, $this->alternativeValue));
$this->assertInstanceOf(Option\None::class, wrap($this->initialValue, $this->initialValue));
}
示例10: smarty_function_custom_menu
/**
* A placeholder for future menu items.
*
* @param array $Params The parameters passed into the function.
* @param Smarty $Smarty The smarty object rendering the template.
* @return string
*/
function smarty_function_custom_menu($Params, &$Smarty)
{
$Controller = $Smarty->Controller;
if (is_object($Menu = val('Menu', $Controller))) {
$Format = val('format', $Params, wrap('<a href="%url" class="%class">%text</a>', val('wrap', $Params, 'li')));
$Result = '';
foreach ($Menu->Items as $Group) {
foreach ($Group as $Item) {
// Make sure the item is a custom item.
if (valr('Attributes.Standard', $Item)) {
continue;
}
// Make sure the user has permission for the item.
if ($Permission = val('Permission', $Item)) {
if (!Gdn::session()->checkPermission($Permission)) {
continue;
}
}
if (($Url = val('Url', $Item)) && ($Text = val('Text', $Item))) {
$Attributes = val('Attributes', $Item);
$Result .= Gdn_Theme::link($Url, $Text, $Format, $Attributes) . "\r\n";
}
}
}
return $Result;
}
return '';
}
示例11: smarty_function_dashboard_link
/**
*
*
* @param array $Params
* @param object $Smarty
* @return string
*/
function smarty_function_dashboard_link($Params, &$Smarty)
{
$Path = val('path', $Params, '', true);
$Text = val('text', $Params, '', true);
$Wrap = val('wrap', $Params, 'li');
return Gdn_Theme::link('dashboard', val('text', $Params, ''), val('format', $Params, wrap('<a href="%url" class="%class">%text</a>', $Wrap)));
}
示例12: discussionController_commentInfo_handler
/**
* Add numbering index to discussion's comments.
*
* @param DiscussionController $sender Sending controller instance.
* @param array $args Event arguments.
*/
public function discussionController_commentInfo_handler($sender, $args)
{
static $number = 2;
$offset = val('Offset', $sender, 0);
$commentNumber = $offset + $number;
echo wrap(anchor('#' . $commentNumber, commentUrl($args['Comment'])), 'span', ['Class' => 'MItem PostNumbering Num-' . $commentNumber]);
$number += 1;
}
示例13: testWrap
public function testWrap()
{
$timingFunction = wrap(function () {
return true;
});
$result = $timingFunction();
$this->assertTrue($result);
$this->assertTrue(is_float(collector()));
}
示例14: tutLink
function tutLink($TutorialCode, $WriteTitle = TRUE, $ThumbnailSize = 'medium')
{
$Tutorial = GetTutorials($TutorialCode);
if (!$Tutorial) {
return '';
}
$Thumbnail = $ThumbnailSize == 'medium' ? $Tutorial['Thumbnail'] : $Tutorial['LargeThumbnail'];
return anchor('<img src="' . $Thumbnail . '" alt="' . $Tutorial['Name'] . '" title="' . $Tutorial['Name'] . '" />' . ($WriteTitle ? wrap($Tutorial['Name']) : ''), 'settings/tutorials/' . $Tutorial['Code']);
}
示例15: writeHomepageOption
function writeHomepageOption($Title, $Url, $iconName, $Current, $Description = '')
{
$iconPath = 'applications/dashboard/design/images/' . $iconName . '.png';
$cssClass = '';
if ($Current == $Url) {
$cssClass = 'active';
}
$cssClass .= ' Choice';
echo wrap('<div class="image-wrap">' . img($iconPath, ['alt' => $Title, 'class' => 'label-selector-image']) . '<div class="overlay">' . '<div class="buttons">' . anchor(t('Select'), $Url, 'btn btn-overlay', ['title' => $Description, 'rel' => $Url]) . '</div>' . '<div class="selected">' . dashboardSymbol('checkmark') . '</div>' . '</div></div>' . '<div class="title">' . t($Title) . '</div>', 'div', array('class' => $cssClass . ' label-selector-item'));
}