本文整理汇总了PHP中content_tag函数的典型用法代码示例。如果您正苦于以下问题:PHP content_tag函数的具体用法?PHP content_tag怎么用?PHP content_tag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了content_tag函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: form_error
function form_error($param, $options = array(), $catalogue = 'messages')
{
$param_for_sf = str_replace(array('[', ']'), array('{', '}'), $param);
$param = str_replace(array('{', '}'), array('[', ']'), $param);
$options = _parse_attributes($options);
$request = sfContext::getInstance()->getRequest();
$style = $request->hasError($param_for_sf) ? '' : 'display:none;';
$options['style'] = $style . (isset($options['style']) ? $options['style'] : '');
if (!isset($options['class'])) {
$options['class'] = sfConfig::get('sf_validation_error_class', 'form_error');
}
if (!isset($options['id'])) {
$options['id'] = sfConfig::get('sf_validation_error_id_prefix', 'error_for_') . get_id_from_name($param);
}
$prefix = sfConfig::get('sf_validation_error_prefix', '');
if (isset($options['prefix'])) {
$prefix = $options['prefix'];
unset($options['prefix']);
}
$suffix = sfConfig::get('sf_validation_error_suffix', '');
if (isset($options['suffix'])) {
$suffix = $options['suffix'];
unset($options['suffix']);
}
$error = $request->getError($param_for_sf, $catalogue);
return content_tag('div', $prefix . $error . $suffix, $options) . "\n";
}
示例2: __toString
public function __toString()
{
$name = $this->getPropertyValue('namePattern');
$id = $this->getPropertyValue('namePattern');
$imageHTML = tag('img', array('src' => theme_path('images/callout-left.png'), 'title' => 'Click here to edit', 'alt' => 'Edit', 'class' => 'callout dialogInvoker'));
$placeholderGetters = $this->getPropertyValue('placeholderGetters');
$id = $this->generateAttributeValue($placeholderGetters, $this->getPropertyValue('idPattern'));
$name = $this->generateAttributeValue($placeholderGetters, $this->getPropertyValue('namePattern'));
$comments = $this->getValue();
$commentExtract = '';
$allComments = '';
// show last comment only
if (count($comments) > 0) {
foreach ($comments as $comment) {
$created = new DateTime($comment->getCreated());
$createdAt = set_datepicker_date_format($created->format('Y-m-d')) . ' ' . $created->format('H:i');
$formatComment = $createdAt . ' ' . $comment->getCreatedByName() . "\n\n" . $comment->getComments();
$allComments = $formatComment . "\n\n" . $allComments;
}
$lastComment = $comments->getLast();
$commentExtract = $this->trimComment($lastComment->getComments());
}
$commentContainerHTML = content_tag('span', $commentExtract, array('id' => $this->generateAttributeValue($placeholderGetters, 'commentContainer-{id}')));
$hiddenFieldHTML = tag('input', array('type' => 'hidden', 'id' => $id, 'name' => $name, 'value' => $allComments));
$commentHTML = content_tag('span', $commentContainerHTML . $imageHTML . $hiddenFieldHTML, array('class' => 'commentContainerLong'));
if ($this->isHiddenOnCallback()) {
return ' ';
}
return $commentHTML . $this->getHiddenFieldHTML();
}
示例3: link_to
function link_to($anchor, $path, $options = array(), $out = true)
{
if (empty($options['href'])) {
$options['href'] = $path;
}
return content_tag('a', $anchor, $options, $out);
}
示例4: __toString
public function __toString()
{
$leaveInfo = $this->getValue();
$elementKey = $this->getPropertyValue('elementKey');
$leaveInfoArray = explode("_", $leaveInfo);
$leaveTaken = count($leaveInfoArray) > $elementKey ? $leaveInfoArray[$elementKey] : '0.00';
$linkable = $this->getPropertyValue('linkable', false);
if ($linkable) {
if ($linkable instanceof sfOutputEscaperArrayDecorator || is_array($linkable)) {
list($method, $params) = $linkable;
$linkable = call_user_func_array(array($this->dataObject, $method), $params->getRawValue());
$employeeId = $this->dataObject->getEmployeeId();
} else {
$linkable = $this->getValue('linkable');
$employeeId = $this->getValue('placeholderGetters');
$employeeId = $employeeId['emp_number'];
}
}
if ($linkable) {
$placeholderGetters = $this->getPropertyValue('placeholderGetters');
$urlPattern = $this->getPropertyValue('urlPattern');
if ($employeeId == $this->getValue('loggedUserId')) {
$urlPattern = $this->getPropertyValue('altUrlPattern');
}
$url = $urlPattern;
foreach ($placeholderGetters as $placeholder => $getter) {
$placeholderValue = is_array($this->dataObject) ? $this->dataObject[$getter] : $this->dataObject->{$getter}();
$url = preg_replace("/\\{{$placeholder}\\}/", $placeholderValue, $url);
}
$linkAttributes = array('href' => $url);
return content_tag('a', $leaveTaken, $linkAttributes) . $this->getHiddenFieldHTML();
} else {
return $leaveTaken;
}
}
示例5: my_options_for_select
function my_options_for_select($options = array(), $selected = '', $disabled = '', $html_options = array())
{
$html_options = _parse_attributes($html_options);
if (is_array($selected)) {
$selected = array_map('strval', array_values($selected));
}
if (is_array($disabled)) {
$disabled = array_map('strval', array_values($disabled));
}
$html = '';
if ($value = _get_option($html_options, 'include_custom')) {
$html .= content_tag('option', $value, array('value' => '')) . "\n";
} else {
if (_get_option($html_options, 'include_blank')) {
$html .= content_tag('option', '', array('value' => '')) . "\n";
}
}
foreach ($options as $key => $value) {
if (is_array($value)) {
$html .= content_tag('optgroup', my_options_for_select($value, $selected, $disabled, $html_options), array('label' => $key)) . "\n";
} else {
$option_options = array('value' => $key);
if (is_array($selected) && in_array(strval($key), $selected, true) || strval($key) == strval($selected)) {
$option_options['selected'] = 'selected';
}
if (is_array($disabled) && in_array(strval($key), $disabled, true) || strval($key) == strval($disabled)) {
$option_options['disabled'] = 'disabled';
}
$html .= content_tag('option', $value, $option_options) . "\n";
}
}
return $html;
}
示例6: __toString
public function __toString()
{
$linkable = $this->getPropertyValue('linkable', true);
if ($linkable instanceof sfOutputEscaperArrayDecorator || is_array($linkable)) {
list($method, $params) = $linkable;
$linkable = call_user_func_array(array($this->dataObject, $method), $params->getRawValue());
}
if ($linkable) {
$placeholderGetters = $this->getPropertyValue('placeholderGetters');
$urlPattern = $this->getPropertyValue('urlPattern');
$url = $urlPattern;
foreach ($placeholderGetters as $placeholder => $getter) {
$placeholderValue = is_array($this->dataObject) ? $this->dataObject[$getter] : $this->dataObject->{$getter}();
$url = preg_replace("/\\{{$placeholder}\\}/", $placeholderValue, $url);
}
if (preg_match('/^index.php/', $url)) {
sfProjectConfiguration::getActive()->loadHelpers('Url');
$url = public_path($url, true);
}
$linkAttributes = array('href' => $url);
if ($this->hasProperty('labelGetter')) {
$label = $this->getValue('labelGetter');
} else {
$label = $this->getPropertyValue('label', 'Undefined');
}
return content_tag('a', $label, $linkAttributes) . $this->getHiddenFieldHTML();
} else {
return $this->toValue() . $this->getHiddenFieldHTML();
}
}
示例7: depp_prioritiser
/**
* Return the HTML code for an unordered list showing opinions that can be voted (no AJAX)
* If the user has already voted, then a message appears
*
* @param BaseObject $object Propel object instance to vote
* @param string $message a message string to be displayed in the voting-message block
* @param array $options Array of HTML options to apply on the HTML list
* @return string
**/
function depp_prioritiser($object, $message = '', $options = array())
{
if (is_null($object)) {
sfLogger::getInstance()->debug('A NULL object cannot be prioritised');
return '';
}
$user_id = sfContext::getInstance()->getUser()->getId();
try {
$options = _parse_attributes($options);
if (!isset($options['id'])) {
$options = array_merge($options, array('id' => 'prioritising-items'));
}
$object_id = $object->getPrioritisableReferenceKey();
$list_content = '';
$object_priority = is_null($object->getPriorityValue()) ? 1 : $object->getPriorityValue();
for ($i = $object->allowsNullPriority() ? 0 : 1; $i <= $object->getMaxPriority(); $i++) {
if ($object_priority == $i) {
if ($object->getPriorityLastUser() != 0) {
$label = sprintf('Priorità impostata da user_id:%d il %s alle %s', $object->getPriorityLastUser(), $object->getPriorityLastUpdate('d/m/Y'), $object->getPriorityLastUpdate('h:i'));
} else {
$label = 'Priorità di default';
}
$list_content .= content_tag('li', content_tag('span', $i, array('title' => $label)), array('class' => 'current'));
} else {
$label = sprintf(__('Set priority to %d'), $i);
$list_content .= content_tag('li', link_to($i, sprintf('deppPrioritising/prioritise?object_id=%d&object_model=%s&priority=%d', $object->getId(), get_class($object), $i), array('title' => $label, 'post' => true)));
}
}
return content_tag('ul', $list_content, $options) . content_tag('div', $message, array('id' => 'priority-message'));
} catch (Exception $e) {
sfLogger::getInstance()->err('Exception catched from deppPrioritising helper: ' . $e->getMessage());
}
}
示例8: lw_link
function lw_link($name = '', $internal_uri = '', $options = array())
{
list($lw_options, $html_options) = _lwSplitOptions(_parse_attributes($options));
if (isset($lw_options['lwAddResources'])) {
$lw_options['lwAddResources'] ? _lwAddResources() : null;
unset($lw_options['lwAddResources']);
} else {
_lwAddResources();
}
if (isset($lw_options['lw_class'])) {
$lw_class = $lw_options['lw_class'];
unset($lw_options['lw_class']);
} else {
$lw_class = 'lightwindow';
}
if (isset($html_options['class'])) {
$html_options['class'] .= ' ' . $lw_class;
} else {
$html_options['class'] = $lw_class;
}
if (!empty($lw_options)) {
$params = array();
foreach ($lw_options as $option => $value) {
$params[] = 'lightwindow_' . $option . '=' . $value;
}
$html_options['params'] = implode(',', $params);
}
if ($internal_uri[0] == '#') {
$html_options['href'] = $internal_uri;
return content_tag('a', $name, $html_options);
}
return link_to($name, $internal_uri, $html_options);
}
示例9: writeRow
function writeRow($list, $keyOr = null)
{
?>
<ul>
<?php
foreach ($list as $key => $val) {
$id = str_replace(array('/', '.'), '', $keyOr . $val);
?>
<li>
<?php
if (is_array($val)) {
echo $key;
writeRow($val, $key . '/');
} else {
?>
<input type="checkbox" name="list[]" value="<?php
echo $keyOr . $val;
?>
" id="<?php
echo $id;
?>
">
<?php
echo content_tag('label', basename($val), array('for' => $id));
?>
<?php
}
?>
</li>
<?php
}
?>
</ul>
<?php
}
示例10: __toString
public function __toString()
{
$defaultOption = $this->getPropertyValue('defaultOption');
$options = $this->getPropertyValue('options', $defaultOption);
if ($options instanceof sfOutputEscaperArrayDecorator || is_array($options)) {
list($object, $method, $params) = $options;
$object = $object instanceof sfOutputEscaperObjectDecorator ? $object->getRawValue() : $object;
$params = $params instanceof sfOutputEscaperArrayDecorator ? $params->getRawValue() : $params;
foreach ($params as $key => $value) {
if ($value === ohrmListConfigurationFactory::RECORD) {
$params[$key] = $this->dataObject;
}
}
$options = call_user_func_array(array($object, $method), $params);
}
if ($this->getPropertyValue('hideIfEmpty', false) && empty($options)) {
return ' ';
}
if ($this->isHiddenOnCallback()) {
return ' ';
}
$optionsHTML = content_tag('option', __($defaultOption['label']), array('value' => $defaultOption['value'])) . "\n";
foreach ($options as $value => $label) {
$optionsHTML .= content_tag('option', __($label), array('value' => $value)) . "\n";
}
$placeholderGetters = $this->getPropertyValue('placeholderGetters');
$id = $this->generateAttributeValue($placeholderGetters, $this->getPropertyValue('idPattern'));
$name = $this->generateAttributeValue($placeholderGetters, $this->getPropertyValue('namePattern'));
$class = $this->generateAttributeValue($placeholderGetters, $this->getPropertyValue('classPattern'));
if ($this->getPropertyValue('hideIfEmpty', false) && empty($options)) {
return ' ';
}
$html = content_tag('select', $optionsHTML, array('id' => $id, 'name' => $name, 'class' => $class));
return $html . $this->getHiddenFieldHTML();
}
示例11: link_to_star
function link_to_star($object, $options = array())
{
$user = sfContext::getInstance()->getUser();
if ($user->isAuthenticated()) {
$response = sfContext::getInstance()->getResponse();
$has_jquery = sfConfig::get('app_sfPropelActAsStarredBehaviorPlugin_has_jquery');
if (!$has_jquery) {
$response->addJavascript('/sfPropelActAsStarredBehaviorPlugin/js/jquery-1.2.2.pack');
}
$response->addJavascript('/sfPropelActAsStarredBehaviorPlugin/js/sf_star');
$is_starred = $object->isStarred() ? 'sf_star_on' : 'sf_star_off';
$options = _parse_attributes($options);
if (isset($options['class'])) {
$options['class'] .= ' sf_star ' . $is_starred;
} else {
$options['class'] = 'sf_star ' . $is_starred;
}
$type = sfConfig::get('app_sfPropelActAsStarredBehaviorPlugin_content_type', null);
if (!$type || $type == 'image') {
$content = $object->isStarred() ? image_tag(sfConfig::get('app_sfPropelActAsStarredBehaviorPlugin_image_on', '/sfPropelActAsStarredBehaviorPlugin/images/star_on.gif')) : image_tag(sfConfig::get('app_sfPropelActAsStarredBehaviorPlugin_image_off', '/sfPropelActAsStarredBehaviorPlugin/images/star_off.gif'));
} elseif (isset($options['txt_on']) && isset($options['txt_off'])) {
$content = $object->isStarred() ? $options['txt_off'] : $options['txt_on'];
} else {
$content = $object->isStarred() ? sfConfig::get('app_sfPropelActAsStarredBehaviorPlugin_content_on') : sfConfig::get('app_sfPropelActAsStarredBehaviorPlugin_content_off');
}
$model = get_class($object);
$id = $object->getPrimaryKey();
return link_to($content, 'sfStar/starit?model=' . $model . '&id=' . $id, $options);
// return content_tag('span',link_to($image,'sfStar/starit?model='.$model.'&id='.$id,'class=sf_star'));
} else {
return content_tag('span', '');
}
}
示例12: getHtml
public function getHtml()
{
$navigationHtml = '';
$navigationHtml .= tag('input', array('type' => 'button', 'value' => 'Back', 'id' => 'ohrmFormNavigatorButton_Back', 'class' => 'plainbtn'));
$navigationHtml = content_tag('div', $navigationHtml, array('style' => 'margin: 4px;'));
return $navigationHtml . $this->decoratedForm->getHtml();
}
示例13: depp_omnibus_selector
/**
* Return the HTML code for an unordered list showing opinions that can be voted (no AJAX)
* If the user has already voted, then a message appears
*
* @param BaseObject $object Propel object instance to vote
* @param string $message a message string to be displayed in the voting-message block
* @param array $options Array of HTML options to apply on the HTML list
* @return string
**/
function depp_omnibus_selector($object, $message = '', $options = array())
{
if (is_null($object)) {
sfLogger::getInstance()->debug('A NULL object cannot be flagged as Omnibus');
return '';
}
$user_id = sfContext::getInstance()->getUser()->getId();
try {
$options = _parse_attributes($options);
if (!isset($options['id'])) {
$options = array_merge($options, array('id' => 'omnibus-flag'));
}
$object_is_omnibus = $object->getIsOmnibus();
$object_will_be_omnibus = !$object_is_omnibus;
$selector = '';
if ($object_is_omnibus) {
$status = "Questo atto è Omnibus";
$label = "Marcalo come non-Omnibus";
} else {
$status = "Questo atto non è Omnibus";
$label = "Marcalo come Omnibus";
}
$selector .= link_to($label, sprintf('atto/setOmnibusStatus?id=%d&status=%d', $object->getId(), $object_will_be_omnibus), array('post' => true));
return content_tag('div', $status) . content_tag('div', $selector, $options);
} catch (Exception $e) {
sfLogger::getInstance()->err('Exception catched from deppOmnibus helper: ' . $e->getMessage());
}
}
示例14: __toString
public function __toString()
{
$linkable = $this->getPropertyValue('linkable', true);
if ($linkable instanceof sfOutputEscaperArrayDecorator || is_array($linkable)) {
list($method, $params) = $linkable;
$linkable = call_user_func_array(array($this->dataObject, $method), $params->getRawValue());
$employeeId = $this->dataObject->getEmployeeId();
} else {
$linkable = $this->getValue('linkable');
$employeeId = $this->getValue('hiddenFieldValueGetter');
}
if ($linkable) {
$placeholderGetters = $this->getPropertyValue('placeholderGetters');
$urlPattern = $this->getPropertyValue('urlPattern');
if ($employeeId == $this->getValue('loggedUserId')) {
$urlPattern = $this->getPropertyValue('altUrlPattern');
}
$url = $urlPattern;
foreach ($placeholderGetters as $placeholder => $getter) {
$placeholderValue = is_array($this->dataObject) ? $this->dataObject[$getter] : $this->dataObject->{$getter}();
$url = preg_replace("/\\{{$placeholder}\\}/", $placeholderValue, $url);
}
$linkAttributes = array('href' => $url);
$employeeName = $this->getValue('labelGetter');
if ($this->getValue('terminatedEmployee')) {
$employeeName .= ' (' . __('Past Employee') . ')';
}
return content_tag('a', $employeeName, $linkAttributes) . $this->getHiddenFieldHTML();
} else {
return $this->toValue();
}
}
示例15: render
public function render($name, $value = null, $attributes = array(), $errors = array())
{
$response = sfContext::getInstance()->getResponse();
$response->addStylesheet('/sfExtraWidgetsPlugin/css/autocompleter.css');
$autocompleteDiv = content_tag('div', '', array('id' => $this->generateId($name) . '_autocomplete', 'class' => 'autocomplete'));
$autocompleteJs = javascript_tag("\n function ac_update_" . $this->generateId($name) . "(text, li)\n {\n \$('" . $this->generateId($name) . "').value = li.id;\n }\n \n new Ajax.Autocompleter(\n '" . $this->generateId($name) . "',\n '" . $this->generateId($name) . '_autocomplete' . "',\n '" . url_for($this->getOption('url')) . "',\n {\n paramName: '" . $this->getOption('param') . "',\n indicator: 'indicator-" . $this->generateId($name) . "',\n minChars: " . $this->getOption('min_chars') . ",\n afterUpdateElement: ac_update_" . $this->generateId($name) . "\n });");
return parent::render($name, $value, $attributes, $errors) . '<span id="indicator-' . $this->generateId($name) . '" style="display: none;"> <img src="/sfExtraWidgetsPlugin/img/ajax-loader.gif" align="absmiddle" alt="Loading" /></span>' . $autocompleteDiv . $autocompleteJs;
}