本文整理汇总了PHP中buildAttributes函数的典型用法代码示例。如果您正苦于以下问题:PHP buildAttributes函数的具体用法?PHP buildAttributes怎么用?PHP buildAttributes使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了buildAttributes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mainElementHTML
/**
* The HTML representation of this element
*
* @return string
*/
protected function mainElementHTML()
{
if ($this->useInput) {
$this->prefillInput();
}
return '<textarea ' . buildAttributes($this->attrs()) . '>' . formText($this->val()) . '</textarea>';
}
示例2: toHTML
/**
* The HTML representation of this element
*
* @return string
*/
public function toHTML()
{
$html = '<fieldset ' . buildAttributes($this->attrs()) . '>';
$legend = $this->val();
if ($legend) {
$html .= DOKU_LF . '<legend>' . hsc($legend) . '</legend>';
}
return $html;
}
示例3: render
/**
* Create output
*/
function render($format, &$renderer, $data)
{
if ($format != 'xhtml') {
return true;
}
$command = $data['command'];
$graph = $data['graph'];
$from = $data['from'];
$to = $data['to'];
/** @var $table helper_plugin_statdisplay_table */
if (!$graph) {
$table = plugin_load('helper', 'statdisplay_table');
$table->table($renderer, $command, $from, $to);
} else {
$img = array('src' => DOKU_BASE . 'lib/plugins/statdisplay/graph.php?graph=' . rawurlencode($command) . '&f=' . $from . '&t=' . $to, 'class' => 'media');
$renderer->doc .= '<img ' . buildAttributes($img) . '/>';
}
return true;
}
示例4: handle_output
function handle_output(&$event, $param)
{
if ($event->data['do'] != 'imageshack') {
return;
}
global $lang;
echo '<h1 id="media__ns">' . $this->getLang('name') . '</h1>';
echo '<p>' . $this->getLang('intro') . '</p>';
echo '<form action="' . DOKU_BASE . 'lib/exe/mediamanager.php" method="post" enctype="multipart/form-data">';
echo '<input type="hidden" name="do" value="imageshack" />';
echo '<input type="file" name="imageshack_file" />';
echo '<input type="submit" value="' . $lang['btn_upload'] . '" class="button" />';
echo '</form>';
// output the uploads stored in the current session
if (is_array($_SESSION['imageshack'])) {
$files = array_reverse($_SESSION['imageshack']);
$twibble = 1;
foreach ($files as $item) {
$twibble *= -1;
$zebra = $twibble == -1 ? 'odd' : 'even';
list($ext, $mime, $dl) = mimetype($item['name']);
$class = preg_replace('/[^_\\-a-z0-9]+/i', '_', $ext);
$class = 'select mediafile mf_' . $class;
echo '<div class="' . $zebra . '">' . NL;
echo '<a name="h_' . $item['link'] . '" class="' . $class . '">' . hsc($item['name']) . '</a> ';
echo '<span class="info">(' . $item['width'] . '×' . $item['height'] . ' ' . filesize_h($item['size']) . ')</span>' . NL;
echo ' <a href="' . $item['adlink'] . '" target="_blank"><img src="' . DOKU_BASE . 'lib/images/magnifier.png" ' . 'alt="' . $lang['mediaview'] . '" title="' . $lang['mediaview'] . '" class="btn" /></a>' . NL;
echo '<div class="example" id="ex_' . str_replace(':', '_', $item['link']) . '">';
echo $lang['mediausage'] . ' <code>{{' . hsc($item['link']) . '}}</code>';
echo '</div>';
if ($item['width'] > 120 || $item['height'] > 100) {
$w = 120;
$h = 100;
} else {
$w = $item['width'];
$h = $item['height'];
}
$src = ml($item['link'], array('w' => $w, 'h' => $h));
$p = array();
$p['width'] = $w;
$p['height'] = $h;
$p['alt'] = $item['name'];
$p['class'] = 'thumb';
$att = buildAttributes($p);
// output
echo '<div class="detail">';
echo '<div class="thumb">';
echo '<a name="d_' . $item['link'] . '" class="select">';
echo '<img src="' . $src . '" ' . $att . ' />';
echo '</a>';
echo '</div>';
echo '</div>';
echo '<div class="clearer"></div>' . NL;
echo '</div>' . NL;
}
}
$event->preventDefault();
}
示例5: html_flashobject
/**
* Embed a flash object in HTML
*
* This will create the needed HTML to embed a flash movie in a cross browser
* compatble way using valid XHTML
*
* The parameters $params, $flashvars and $atts need to be associative arrays.
* No escaping needs to be done for them. The alternative content *has* to be
* escaped because it is used as is. If no alternative content is given
* $lang['noflash'] is used.
*
* @author Andreas Gohr <andi@splitbrain.org>
* @link http://latrine.dgx.cz/how-to-correctly-insert-a-flash-into-xhtml
*
* @param string $swf - the SWF movie to embed
* @param int $width - width of the flash movie in pixels
* @param int $height - height of the flash movie in pixels
* @param array $params - additional parameters (<param>)
* @param array $flashvars - parameters to be passed in the flashvar parameter
* @param array $atts - additional attributes for the <object> tag
* @param string $alt - alternative content (is NOT automatically escaped!)
* @returns string - the XHTML markup
*/
function html_flashobject($swf, $width, $height, $params = null, $flashvars = null, $atts = null, $alt = '')
{
global $lang;
$out = '';
// prepare the object attributes
if (is_null($atts)) {
$atts = array();
}
$atts['width'] = (int) $width;
$atts['height'] = (int) $height;
if (!$atts['width']) {
$atts['width'] = 425;
}
if (!$atts['height']) {
$atts['height'] = 350;
}
// add object attributes for standard compliant browsers
$std = $atts;
$std['type'] = 'application/x-shockwave-flash';
$std['data'] = $swf;
// add object attributes for IE
$ie = $atts;
$ie['classid'] = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
// open object (with conditional comments)
$out .= '<!--[if !IE]> -->' . NL;
$out .= '<object ' . buildAttributes($std) . '>' . NL;
$out .= '<!-- <![endif]-->' . NL;
$out .= '<!--[if IE]>' . NL;
$out .= '<object ' . buildAttributes($ie) . '>' . NL;
$out .= ' <param name="movie" value="' . hsc($swf) . '" />' . NL;
$out .= '<!--><!-- -->' . NL;
// print params
if (is_array($params)) {
foreach ($params as $key => $val) {
$out .= ' <param name="' . hsc($key) . '" value="' . hsc($val) . '" />' . NL;
}
}
// add flashvars
if (is_array($flashvars)) {
$out .= ' <param name="FlashVars" value="' . buildURLparams($flashvars) . '" />' . NL;
}
// alternative content
if ($alt) {
$out .= $alt . NL;
} else {
$out .= $lang['noflash'] . NL;
}
// finish
$out .= '</object>' . NL;
$out .= '<!-- <![endif]-->' . NL;
return $out;
}
示例6: getForm
/**
* Return the assembled HTML for the form.
*
* Each element in the form will be passed to a function named
* 'form_$type'. The function should return the HTML to be printed.
*
* @author Tom N Harris <tnharris@whoopdedo.org>
*/
function getForm()
{
global $lang;
$form = '';
$this->params['accept-charset'] = $lang['encoding'];
$form .= '<form ' . buildAttributes($this->params, false) . '><div class="no">' . DOKU_LF;
if (!empty($this->_hidden)) {
foreach ($this->_hidden as $name => $value) {
$form .= form_hidden(array('name' => $name, 'value' => $value));
}
}
foreach ($this->_content as $element) {
if (is_array($element)) {
$elem_type = $element['_elem'];
if (function_exists('form_' . $elem_type)) {
$form .= call_user_func('form_' . $elem_type, $element) . DOKU_LF;
}
} else {
$form .= $element;
}
}
if ($this->_infieldset) {
$form .= form_closefieldset() . DOKU_LF;
}
$form .= '</div></form>' . DOKU_LF;
return $form;
}
示例7: _list
/**
* List recent edits matching the given filter
*/
function _list($filter)
{
global $conf;
global $lang;
echo '<hr /><br />';
echo '<form action="" method="post"><div class="no">';
echo '<input type="hidden" name="filter" value="' . hsc($filter) . '" />';
formSecurityToken();
$recents = getRecents(0, $this->max_lines);
echo '<ul>';
$cnt = 0;
foreach ($recents as $recent) {
if ($filter) {
if (strpos(rawWiki($recent['id']), $filter) === false) {
continue;
}
}
$cnt++;
$date = strftime($conf['dformat'], $recent['date']);
echo $recent['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT ? '<li class="minor">' : '<li>';
echo '<div class="li">';
echo '<input type="checkbox" name="revert[]" value="' . hsc($recent['id']) . '" checked="checked" id="revert__' . $cnt . '" />';
echo '<label for="revert__' . $cnt . '">' . $date . '</label> ';
echo '<a href="' . wl($recent['id'], "do=diff") . '">';
$p = array();
$p['src'] = DOKU_BASE . 'lib/images/diff.png';
$p['width'] = 15;
$p['height'] = 11;
$p['title'] = $lang['diff'];
$p['alt'] = $lang['diff'];
$att = buildAttributes($p);
echo "<img {$att} />";
echo '</a> ';
echo '<a href="' . wl($recent['id'], "do=revisions") . '">';
$p = array();
$p['src'] = DOKU_BASE . 'lib/images/history.png';
$p['width'] = 12;
$p['height'] = 14;
$p['title'] = $lang['btn_revs'];
$p['alt'] = $lang['btn_revs'];
$att = buildAttributes($p);
echo "<img {$att} />";
echo '</a> ';
echo html_wikilink(':' . $recent['id'], useHeading('navigation') ? NULL : $recent['id']);
echo ' – ' . htmlspecialchars($recent['sum']);
echo ' <span class="user">';
echo $recent['user'] . ' ' . $recent['ip'];
echo '</span>';
echo '</div>';
echo '</li>';
@set_time_limit(10);
flush();
}
echo '</ul>';
echo '<p>';
echo '<input type="submit" class="button" value="' . $this->getLang('revert') . '" /> ';
printf($this->getLang('note2'), hsc($filter));
echo '</p>';
echo '</div></form>';
}
示例8: tpl_indexerWebBug
/**
* This function inserts a 1x1 pixel gif which in reality
* is the indexer function.
*
* Should be called somewhere at the very end of the main.php
* template
*/
function tpl_indexerWebBug()
{
global $ID;
global $INFO;
if (!$INFO['exists']) {
return false;
}
if (isHiddenPage($ID)) {
return false;
}
//no need to index hidden pages
$p = array();
$p['src'] = DOKU_BASE . 'lib/exe/indexer.php?id=' . rawurlencode($ID) . '&' . time();
$p['width'] = 1;
$p['height'] = 1;
$p['alt'] = '';
$att = buildAttributes($p);
print "<img {$att} />";
return true;
}
示例9: _image
/**
* Defines how a thumbnail should look like
*/
function _image(&$img, $data)
{
global $ID;
// calculate thumbnail size
if (!$data['crop']) {
$w = (int) $this->_meta($img, 'width');
$h = (int) $this->_meta($img, 'height');
if ($w && $h) {
$dim = array();
if ($w > $data['tw'] || $h > $data['th']) {
$ratio = $this->_ratio($img, $data['tw'], $data['th']);
$w = floor($w * $ratio);
$h = floor($h * $ratio);
$dim = array('w' => $w, 'h' => $h);
}
} else {
$data['crop'] = true;
// no size info -> always crop
}
}
if ($data['crop']) {
$w = $data['tw'];
$h = $data['th'];
$dim = array('w' => $w, 'h' => $h);
}
//prepare img attributes
$i = array();
$i['width'] = $w;
$i['height'] = $h;
$i['border'] = 0;
$i['alt'] = $this->_meta($img, 'title');
$i['class'] = 'tn';
$iatt = buildAttributes($i);
$src = ml($img['id'], $dim);
// prepare lightbox dimensions
$w_lightbox = (int) $this->_meta($img, 'width');
$h_lightbox = (int) $this->_meta($img, 'height');
$dim_lightbox = array();
if ($w_lightbox > $data['iw'] || $h_lightbox > $data['ih']) {
$ratio = $this->_ratio($img, $data['iw'], $data['ih']);
$w_lightbox = floor($w_lightbox * $ratio);
$h_lightbox = floor($h_lightbox * $ratio);
$dim_lightbox = array('w' => $w_lightbox, 'h' => $h_lightbox);
}
//prepare link attributes
$a = array();
$a['title'] = $this->_meta($img, 'title');
$a['data-caption'] = trim(str_replace("\n", ' ', $this->_meta($img, 'desc')));
if (!$a['data-caption']) {
unset($a['data-caption']);
}
if ($data['lightbox']) {
$href = ml($img['id'], $dim_lightbox);
$a['class'] = "lightbox JSnocheck";
$a['rel'] = 'lightbox[gal-' . substr(md5($ID), 4) . ']';
//unique ID for the gallery
} elseif ($img['detail'] && !$data['direct']) {
$href = $img['detail'];
} else {
$href = ml($img['id'], array('id' => $ID), $data['direct']);
}
$aatt = buildAttributes($a);
// prepare output
$ret = '';
$ret .= '<a href="' . $href . '" ' . $aatt . '>';
$ret .= '<img src="' . $src . '" ' . $iatt . ' />';
$ret .= '</a>';
return $ret;
}
示例10: media_printimgdetail
/**
* Prints a thumbnail and metainfos
*/
function media_printimgdetail($item)
{
// prepare thumbnail
$w = (int) $item['meta']->getField('File.Width');
$h = (int) $item['meta']->getField('File.Height');
if ($w > 120 || $h > 120) {
$ratio = $item['meta']->getResizeRatio(120);
$w = floor($w * $ratio);
$h = floor($h * $ratio);
}
$src = ml($item['id'], array('w' => $w, 'h' => $h));
$p = array();
$p['width'] = $w;
$p['height'] = $h;
$p['alt'] = $item['id'];
$p['class'] = 'thumb';
$att = buildAttributes($p);
// output
echo '<div class="detail">';
echo '<div class="thumb">';
echo '<a name="d_:' . $item['id'] . '" class="select">';
echo '<img src="' . $src . '" ' . $att . ' />';
echo '</a>';
echo '</div>';
// read EXIF/IPTC data
$t = $item['meta']->getField(array('IPTC.Headline', 'xmp.dc:title'));
$d = $item['meta']->getField(array('IPTC.Caption', 'EXIF.UserComment', 'EXIF.TIFFImageDescription', 'EXIF.TIFFUserComment'));
if (utf8_strlen($d) > 250) {
$d = utf8_substr($d, 0, 250) . '...';
}
$k = $item['meta']->getField(array('IPTC.Keywords', 'IPTC.Category', 'xmp.dc:subject'));
// print EXIF/IPTC data
if ($t || $d || $k) {
echo '<p>';
if ($t) {
echo '<strong>' . htmlspecialchars($t) . '</strong><br />';
}
if ($d) {
echo htmlspecialchars($d) . '<br />';
}
if ($t) {
echo '<em>' . htmlspecialchars($k) . '</em>';
}
echo '</p>';
}
echo '</div>';
}
示例11: html_minoredit
/**
* Adds a checkbox for minor edits for logged in users
*
* @author Andrea Gohr <andi@splitbrain.org>
*/
function html_minoredit()
{
global $conf;
global $lang;
// minor edits are for logged in users only
if (!$conf['useacl'] || !$_SERVER['REMOTE_USER']) {
return;
}
$p = array();
$p['name'] = 'minor';
$p['type'] = 'checkbox';
$p['id'] = 'minoredit';
$p['tabindex'] = 3;
$p['value'] = '1';
if (!empty($_REQUEST['minor'])) {
$p['checked'] = 'checked';
}
$att = buildAttributes($p);
print '<span class="nowrap">';
print "<input {$att} />";
print '<label for="minoredit">';
print $lang['minoredit'];
print '</label>';
print '</span>';
}
示例12: render
function render($format, Doku_Renderer $renderer, $data)
{
if ($format != 'xhtml') {
return false;
}
$attr = array('src' => ml($data['id'], array('w' => $data['width'], 'h' => $data['height']), true, '&'), 'width' => $data['width'], 'height' => $data['height'], 'class' => 'svgpureinsert media' . $data['align'], 'frameborder' => 0, 'title' => $data['title']);
$renderer->doc .= '<iframe ' . buildAttributes($attr) . '></iframe>';
return true;
}
示例13: _audio
/**
* Embed audio in HTML
*
* @author Anika Henke <anika@selfthinker.org>
*
* @param string $src - ID of audio to embed
* @param array $atts - additional attributes for the <audio> tag
* @return string
*/
function _audio($src, $atts = null)
{
// prepare alternative formats
$extensions = array('ogg', 'mp3', 'wav');
$alternatives = media_alternativefiles($src, $extensions);
$out = '';
// open audio tag
$out .= '<audio ' . buildAttributes($atts) . ' controls="controls">' . NL;
$fallback = '';
// output source for each alternative audio format
foreach ($alternatives as $mime => $file) {
$url = ml($file, array('cache' => $cache), true, '&');
$title = $atts['title'] ? $atts['title'] : $this->_xmlEntities(utf8_basename(noNS($file)));
$out .= '<source src="' . hsc($url) . '" type="' . $mime . '" />' . NL;
// alternative content (just a link to the file)
$fallback .= $this->internalmedia($file, $title, NULL, NULL, NULL, $cache = NULL, $linking = 'linkonly', $return = true);
}
// finish
$out .= $fallback;
$out .= '</audio>' . NL;
return $out;
}
示例14: _image
//.........这里部分代码省略.........
}
if ($data['crop']) {
$w = $data['tw'];
$h = $data['th'];
$dim = array('w' => $w, 'h' => $h);
}
//prepare img attributes
$i = array();
$i['width'] = $w;
$i['height'] = $h;
$i['border'] = 0;
if ($this->_meta($img, 'title')) {
$i['alt'] = $this->_meta($img, 'title');
} else {
$i['alt'] = end(explode(":", $img['id']));
}
$i['longdesc'] = str_replace("\n", ' ', $this->_meta($img, 'desc'));
if (!$i['longdesc']) {
unset($i['longdesc']);
}
$i['class'] = 'tn';
// get exif and gps info
$orientation = $img['meta']->getField("Orientation");
if ($conf['syslog']) {
syslog(LOG_WARNING, '[gallery:syntax.php] orientation: ' . $orientation);
}
switch ($orientation) {
case 6:
if ($i['width'] > $i['height']) {
// swap width and height if the image is going to be rotated vertically
if ($conf['syslog']) {
syslog(LOG_WARNING, 'swap width and height as the image is going to be rotated vertically');
}
$old_width = $i['width'];
$i['width'] = $i['height'];
$i['height'] = $old_width;
}
break;
case 8:
if ($i['width'] > $i['height']) {
// swap width and height if the image is going to be rotated vertically
if ($conf['syslog']) {
syslog(LOG_WARNING, 'swap width and height as the image is going to be rotated vertically');
}
$old_width = $i['width'];
$i['width'] = $i['height'];
$i['height'] = $old_width;
}
break;
}
require_once DOKU_INC . 'lib/plugins/colorbox/JpegMetaGPS.php';
$jpeg = new JpegMetaGPS(mediaFN($img['id']));
if ($jpeg !== false) {
$info = $jpeg->getShortExifInfo();
$gpslink = $jpeg->getGPSInfo();
if ($info) {
$i['exif'] = implode(';', array_map(function ($v, $k) {
if ($v) {
return strtolower($k) . ':' . $v . '';
}
}, $info, array_keys($info)));
}
if ($gpslink) {
$i['map'] = $gpslink;
}
$i['token'] = media_get_token($img['id'], "1360", "0");
}
$iatt = buildAttributes($i);
$src = ml($img['id'], $dim);
// prepare lightbox dimensions
$w_lightbox = (int) $this->_meta($img, 'width');
$h_lightbox = (int) $this->_meta($img, 'height');
$dim_lightbox = array();
if ($w_lightbox > $data['iw'] || $h_lightbox > $data['ih']) {
$ratio = $this->_ratio($img, $data['iw'], $data['ih']);
$w_lightbox = floor($w_lightbox * $ratio);
$h_lightbox = floor($h_lightbox * $ratio);
$dim_lightbox = array('w' => $w_lightbox, 'h' => $h_lightbox);
}
//prepare link attributes
$a = array();
$a['title'] = $this->_meta($img, 'title');
if ($data['lightbox']) {
$href = ml($img['id'], $dim_lightbox);
$a['class'] = "lightbox JSnocheck";
$a['rel'] = 'lightbox[gal-' . substr(md5($ID), 4) . ']';
//unique ID for the gallery
} elseif ($img['detail'] && !$data['direct']) {
$href = $img['detail'];
} else {
$href = ml($img['id'], array('id' => $ID), $data['direct']);
}
$aatt = buildAttributes($a);
// prepare output
$ret = '';
$ret .= '<a href="' . $href . '" ' . $aatt . '>';
$ret .= '<img src="' . $src . '" ' . $iatt . ' />';
$ret .= '</a>';
return $ret;
}
示例15: renderOptions
/**
* @return string
*/
protected function renderOptions()
{
$html = '';
foreach ($this->options as $key => $val) {
$selected = $key == $this->value ? ' selected="selected"' : '';
$attrs = '';
if (!empty($val['attrs']) && is_array($val['attrs'])) {
$attrs = buildAttributes($val['attrs']);
}
$html .= '<option' . $selected . ' value="' . hsc($key) . '" ' . $attrs . '>' . hsc($val['label']) . '</option>';
}
return $html;
}