Exemplo n.º 1
0
 /**
  * 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>';
 }
 /**
  * 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;
 }
Exemplo n.º 3
0
 /**
  * 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;
 }
 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'] . '&#215;' . $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();
 }
Exemplo n.º 5
0
/**
 * 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 <*****@*****.**>
 * @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;
}
Exemplo n.º 6
0
 /**
  * Render the flash player
  */
 function render($mode, &$R, $data)
 {
     if ($mode != 'xhtml') {
         return false;
     }
     if (is_null($data)) {
         return false;
     }
     if ($data['align'] == 0) {
         $align = 'none';
     }
     if ($data['align'] == 1) {
         $align = 'right';
     }
     if ($data['align'] == 2) {
         $align = 'left';
     }
     if ($data['align'] == 3) {
         $align = 'center';
     }
     if ($data['title']) {
         $title = ' title="' . hsc($data['title']) . '"';
     }
     if (is_a($R, 'renderer_plugin_dw2pdf')) {
         // Output for PDF renderer
         $R->doc .= '<div class="vshare__' . $align . '"
                          width="' . $data['width'] . '"
                          height="' . $data['height'] . '">';
         $R->doc .= '<a href="' . $data['url'] . '" class="vshare">';
         $R->doc .= '<img src="' . DOKU_BASE . 'lib/plugins/vshare/video.png" />';
         $R->doc .= '</a>';
         $R->doc .= '<br />';
         $R->doc .= '<a href="' . $data['url'] . '" class="vshare">';
         $R->doc .= $data['title'] ? hsc($data['title']) : 'Video';
         $R->doc .= '</a>';
         $R->doc .= '</div>';
     } else {
         // Normal output
         if ($data['type'] == 'flash') {
             // embed flash
             $R->doc .= '<div class="vshare__' . $align . '"' . $title . '>';
             $R->doc .= html_flashobject($data['url'], $data['width'], $data['height'], $data['vars'], $data['vars']);
             $R->doc .= '</div>';
         } else {
             // embed iframe
             $R->doc .= '<iframe ';
             $R->doc .= buildAttributes(array('src' => $data['url'], 'height' => $data['height'], 'width' => $data['width'], 'class' => 'vshare__' . $align, 'allowfullscreen' => '', 'frameborder' => 0, 'scrolling' => 'no'));
             $R->doc .= '>' . hsc($data['title']) . '</iframe>';
         }
     }
 }
Exemplo n.º 7
0
 /**
  * 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 <*****@*****.**>
  */
 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;
 }
Exemplo n.º 8
0
 /**
  * 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>';
 }
Exemplo n.º 9
0
/**
 * 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;
}
Exemplo n.º 10
0
 /**
  * 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;
 }
Exemplo n.º 11
0
/**
 * 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>';
}
Exemplo n.º 12
0
/**
 * Adds a checkbox for minor edits for logged in users
 *
 * @author Andrea Gohr <*****@*****.**>
 */
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>';
}
Exemplo n.º 13
0
 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;
 }
Exemplo n.º 14
0
 /**
  * Embed audio in HTML
  *
  * @author Anika Henke <*****@*****.**>
  *
  * @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;
 }
Exemplo n.º 15
0
 /**
  * Defines how a thumbnail should look like
  */
 function _image(&$img, $data)
 {
     global $ID;
     global $conf;
     // calculate thumbnail size
     if (!$data['crop']) {
         $w = (int) $this->_meta($img, 'width');
         $h = (int) $this->_meta($img, 'height');
         if ($conf['syslog']) {
             syslog(LOG_WARNING, '[gallery:syntax.php] image file: ' . $conf['mediadir'] . utf8_encodeFN(str_replace(':', '/', $img['id'])) . $img['file'] . '. size: ' . $w . 'x' . $h);
         }
         if ($w && $h) {
             $dim = array();
             if ($w > $data['tw'] || $h > $data['th']) {
                 $fr = $w / $h;
                 if ($fr >= $data['tw'] / $data['th']) {
                     $w = $data['tw'];
                     $h = round($w / $fr);
                 } else {
                     $h = $data['th'];
                     $w = round($h * $fr);
                 }
                 $dim = array('w' => $w, 'h' => $h);
                 if ($conf['syslog']) {
                     syslog(LOG_WARNING, '[gallery:syntax.php] image file: ' . $conf['mediadir'] . utf8_encodeFN(str_replace(':', '/', $img['id'])) . $img['file'] . '. reize to: ' . $w . 'x' . $h);
                 }
             }
         } else {
             // this should not happen but if it does this usually means a corrupted image file therefore we want to log it
             syslog(LOG_WARNING, 'no size info found which is likely due to corrupted image file. force crop to ' . $data['tw'] . 'x' . $data['th'] . '. file: ' . $conf['mediadir'] . utf8_encodeFN(str_replace(':', '/', $img['id'])) . $img['file']);
             $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;
     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;
 }
Exemplo n.º 16
0
 /**
  * @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;
 }
Exemplo n.º 17
0
 /**
  * The HTML representation of this element
  *
  * @return string
  */
 public function toHTML()
 {
     return '<' . $this->val() . ' ' . buildAttributes($this->attrs()) . '>';
 }
Exemplo n.º 18
0
 /**
  * The HTML representation of this element wrapped in a label
  *
  * @return string
  */
 public function toHTML()
 {
     if ($this->label) {
         return '<label ' . buildAttributes($this->label->attrs()) . '>' . DOKU_LF . '<span>' . hsc($this->label->val()) . '</span>' . DOKU_LF . $this->mainElementHTML() . DOKU_LF . '</label>';
     } else {
         return $this->mainElementHTML();
     }
 }
Exemplo n.º 19
0
 /**
  * The HTML representation of the whole form
  *
  * @return string
  */
 public function toHTML()
 {
     $this->balanceFieldsets();
     $html = '<form ' . buildAttributes($this->attrs()) . '>';
     foreach ($this->hidden as $name => $value) {
         $html .= '<input type="hidden" name="' . $name . '" value="' . formText($value) . '" />';
     }
     foreach ($this->elements as $element) {
         $html .= $element->toHTML();
     }
     $html .= '</form>';
     return $html;
 }
Exemplo n.º 20
0
 /**
  * Create the HTML for the select it self
  *
  * @return string
  */
 protected function mainElementHTML()
 {
     if ($this->useInput) {
         $this->prefillInput();
     }
     $html = '<select ' . buildAttributes($this->attrs()) . '>';
     foreach ($this->options as $key => $val) {
         $selected = $key == $this->value ? ' selected="selected"' : '';
         $attrs = '';
         if (is_array($val['attrs'])) {
             array_walk($val['attrs'], function (&$aval, $akey) {
                 $aval = hsc($akey) . '="' . hsc($aval) . '"';
             });
             $attrs = join(' ', $val['attrs']);
         }
         $html .= '<option' . $selected . ' value="' . hsc($key) . '" ' . $attrs . '>' . hsc($val['label']) . '</option>';
     }
     $html .= '</select>';
     return $html;
 }
Exemplo n.º 21
0
 function render($mode, Doku_Renderer $R, $data)
 {
     if ($mode != 'xhtml') {
         return false;
     }
     if (!$data['url']) {
         $R->doc .= '<div class="iframe">' . hsc($data['alt']) . '</div>';
     } else {
         $opts = array('title' => $data['alt'], 'src' => $data['url'], 'style' => 'width:' . $data['width'] . '; height:' . $data['height']);
         if (!$data['border']) {
             $opts['frameborder'] = 0;
         }
         if (!$data['scroll']) {
             $opts['scrolling'] = 'no';
         }
         if ($data['align']) {
             $opts['align'] = $data['align'];
         }
         $params = buildAttributes($opts);
         $R->doc .= "<iframe {$params}>" . hsc($alt) . '</iframe>';
     }
     return true;
 }
Exemplo n.º 22
0
 /**
  * print the opening LI for a list item
  *
  * @param array $item
  * @return string
  */
 function html_li($item)
 {
     if ($item['id'] == '*') {
         $item['id'] = '';
     }
     $params = array();
     $params['class'] = ' type-' . $item['type'];
     if ($item['type'] == 'd') {
         $params['class'] .= ' ' . ($item['open'] ? 'open' : 'closed');
     }
     $params['data-name'] = noNS($item['id']);
     $params['data-id'] = $item['id'];
     $attr = buildAttributes($params);
     return "<li {$attr}>";
 }
Exemplo n.º 23
0
 /**
  * print the permission radio boxes
  *
  * @author  Frank Schubert <*****@*****.**>
  * @author  Andreas Gohr <*****@*****.**>
  */
 function _html_checkboxes($setperm, $ispage, $name)
 {
     global $lang;
     static $label = 0;
     //number labels
     $ret = '';
     if ($ispage && $setperm > AUTH_EDIT) {
         $perm = AUTH_EDIT;
     }
     foreach (array(AUTH_NONE, AUTH_READ, AUTH_EDIT, AUTH_CREATE, AUTH_UPLOAD, AUTH_DELETE) as $perm) {
         $label += 1;
         //general checkbox attributes
         $atts = array('type' => 'radio', 'id' => 'pbox' . $label, 'name' => $name, 'value' => $perm);
         //dynamic attributes
         if (!is_null($setperm) && $setperm == $perm) {
             $atts['checked'] = 'checked';
         }
         if ($ispage && $perm > AUTH_EDIT) {
             $atts['disabled'] = 'disabled';
             $class = ' class="disabled"';
         } else {
             $class = '';
         }
         //build code
         $ret .= '<label for="pbox' . $label . '"' . $class . '>';
         $ret .= '<input ' . buildAttributes($atts) . ' />&#160;';
         $ret .= $this->getLang('acl_perm' . $perm);
         $ret .= '</label>' . NL;
     }
     return $ret;
 }
Exemplo n.º 24
0
/**
 * Prints a thumbnail and metainfo
 */
function media_printimgdetail($item, $fullscreen = false)
{
    // prepare thumbnail
    $size = $fullscreen ? 90 : 120;
    $w = (int) $item['meta']->getField('File.Width');
    $h = (int) $item['meta']->getField('File.Height');
    if ($w > $size || $h > $size) {
        if (!$fullscreen) {
            $ratio = $item['meta']->getResizeRatio($size);
        } else {
            $ratio = $item['meta']->getResizeRatio($size, $size);
        }
        $w = floor($w * $ratio);
        $h = floor($h * $ratio);
    }
    $src = ml($item['id'], array('w' => $w, 'h' => $h, 't' => $item['mtime']));
    $p = array();
    if (!$fullscreen) {
        // In fullscreen mediamanager view, image resizing is done via CSS.
        $p['width'] = $w;
        $p['height'] = $h;
    }
    $p['alt'] = $item['id'];
    $att = buildAttributes($p);
    // output
    if ($fullscreen) {
        echo '<a id="l_:' . $item['id'] . '" class="image thumb" href="' . media_managerURL(array('image' => hsc($item['id']), 'ns' => getNS($item['id']), 'tab_details' => 'view')) . '">';
        echo '<img src="' . $src . '" ' . $att . ' />';
        echo '</a>';
    }
    if ($fullscreen) {
        return;
    }
    echo '<div class="detail">';
    echo '<div class="thumb">';
    echo '<a id="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>';
}
Exemplo n.º 25
0
/**
 * This function inserts a small gif which in reality is the indexer function.
 *
 * Should be called somewhere at the very end of the main.php
 * template
 *
 * @return bool
 */
function tpl_indexerWebBug()
{
    global $ID;
    $p = array();
    $p['src'] = DOKU_BASE . 'lib/exe/indexer.php?id=' . rawurlencode($ID) . '&' . time();
    $p['width'] = 2;
    //no more 1x1 px image because we live in times of ad blockers...
    $p['height'] = 1;
    $p['alt'] = '';
    $att = buildAttributes($p);
    print "<img {$att} />";
    return true;
}
 /**
  * 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['longdesc'] = str_replace("\n", ' ', $this->_meta($img, 'desc'));
     if (!$i['longdesc']) {
         unset($i['longdesc']);
     }
     $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');
     if ($data['lightbox']) {
         $href = ml($img['id'], $dim_lightbox);
         $a['class'] = "lightbox JSnocheck";
         $a['rel'] = "lightbox";
     } elseif ($data['fancybox']) {
         $href = ml($img['id'], $dim_lightbox);
         $a['class'] = "fancybox JSnocheck";
         $a['rel'] = "fancybox";
     } elseif ($data['fancyslideshow']) {
         $href = ml($img['id'], $dim_lightbox);
         $a['class'] = "fancyslideshow JSnocheck";
         $a['rel'] = "fancyslideshow";
     } elseif ($data['page']) {
         if (!$a['title'] || $data['page_useid']) {
             $new_id = cleanID(substr($img['id'], 0, -strlen(strrchr($img['id'], '.'))));
         } else {
             $new_id = cleanID($data['ns'] . ':' . substr($a['title'], 0, -strlen(strrchr($a['title'], '.'))));
         }
         $newpath = wikiFN($new_id);
         //if we have the trimnumbers on and there is not an existing page with the numbers
         if ($data['page_trimnumbers'] && !@file_exists($newpath)) {
             $new_id = preg_replace('/[0-9]+$/', '', $new_id);
             $newpath = wikiFN($new_id);
         }
         if (@file_exists($newpath) || auth_quickaclcheck($new_id) >= AUTH_EDIT) {
             $href = wl($new_id);
         }
     } elseif ($img['detail'] && !$data['direct']) {
         $href = $img['detail'];
     } else {
         $href = ml($img['id'], array('id' => $ID), $data['direct']);
     }
     $aatt = buildAttributes($a);
     // prepare output
     $ret = '';
     if (!$data['cyclepics']) {
         $ret .= '<a href="' . $href . '" ' . $aatt . '>';
     }
     $ret .= '<img src="' . $src . '" ' . $iatt . ' />';
     if (!$data['cyclepics']) {
         $ret .= '</a>';
     }
     return $ret;
 }
Exemplo n.º 27
0
 /**
  * Embed audio in HTML
  *
  * @author Anika Henke <*****@*****.**>
  *
  * @param string $src       - ID of audio to embed
  * @param array  $atts      - additional attributes for the <audio> tag
  * @return string
  */
 function _audio($src, $atts = array())
 {
     $files = array();
     $isExternal = media_isexternal($src);
     if ($isExternal) {
         // take direct source for external files
         list(, $srcMime) = mimetype($src);
         $files[$srcMime] = $src;
     } else {
         // prepare alternative formats
         $extensions = array('ogg', 'mp3', 'wav');
         $files = media_alternativefiles($src, $extensions);
     }
     $out = '';
     // open audio tag
     $out .= '<audio ' . buildAttributes($atts) . ' controls="controls">' . NL;
     $fallback = '';
     // output source for each alternative audio format
     foreach ($files as $mime => $file) {
         if ($isExternal) {
             $url = $file;
             $linkType = 'externalmedia';
         } else {
             $url = ml($file, '', true, '&');
             $linkType = 'internalmedia';
         }
         $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->{$linkType}($file, $title, null, null, null, $cache = null, $linking = 'linkonly', $return = true);
     }
     // finish
     $out .= $fallback;
     $out .= '</audio>' . NL;
     return $out;
 }
Exemplo n.º 28
0
 /**
  * Render the flash player
  */
 function render($mode, Doku_Renderer $R, $data)
 {
     if ($mode != 'xhtml') {
         return false;
     }
     if (is_null($data)) {
         return false;
     }
     if ($data['align'] == 0) {
         $align = 'none';
     }
     if ($data['align'] == 1) {
         $align = 'right';
     }
     if ($data['align'] == 2) {
         $align = 'left';
     }
     if ($data['align'] == 3) {
         $align = 'center';
     }
     if ($data['title']) {
         $title = ' title="' . hsc($data['title']) . '"';
     }
     if (is_a($R, 'renderer_plugin_dw2pdf')) {
         // Output for PDF renderer
         $R->doc .= '<div class="vshare__' . $align . '"
                          width="' . $data['width'] . '"
                          height="' . $data['height'] . '">';
         $R->doc .= '<a href="' . $data['url'] . '" class="vshare">';
         $R->doc .= '<img src="' . DOKU_BASE . 'lib/plugins/vshare/video.png" />';
         $R->doc .= '</a>';
         $R->doc .= '<br />';
         $R->doc .= '<a href="' . $data['url'] . '" class="vshare">';
         $R->doc .= $data['title'] ? hsc($data['title']) : 'Video';
         $R->doc .= '</a>';
         $R->doc .= '</div>';
     } else {
         // use redirector for HTTP embeds on SSL sites
         if (is_ssl() && substr($data['url'], 0, 7) == 'http://') {
             $data['url'] = DOKU_BASE . 'lib/plugins/vshare/redir.php' . '?url=' . rawurlencode($data['url']) . '&hash=' . md5(auth_cookiesalt() . 'vshare' . $data['url']);
         }
         // Normal output
         if ($data['type'] == 'flash') {
             // embed flash
             $R->doc .= '<div class="vshare__' . $align . '"' . $title . '>';
             $R->doc .= html_flashobject($data['url'], $data['width'], $data['height'], $data['vars'], $data['vars']);
             $R->doc .= '</div>';
         } else {
             // embed iframe
             $R->doc .= '<iframe ';
             $R->doc .= buildAttributes(array('src' => $data['url'], 'height' => $data['height'], 'width' => $data['width'], 'class' => 'vshare__' . $align, 'allowfullscreen' => '', 'frameborder' => 0, 'scrolling' => 'no'));
             $R->doc .= '>' . hsc($data['title']) . '</iframe>';
         }
     }
 }
Exemplo n.º 29
0
/**
 * form_listboxfield
 *
 * Print the HTML for a list box.
 *   _options : Array of (value,text,selected) for the list.
 *              Text can be omitted. Text and value are passed to formText()
 *   _class : class attribute used on the label tag
 *   _text  : Text to display before the menu. Not escaped.
 * Other attributes are passed to buildAttributes() for the input tag.
 *
 * @author  Tom N Harris <*****@*****.**>
 */
function form_listboxfield($attrs)
{
    $s = '<label';
    if ($attrs['_class']) {
        $s .= ' class="' . $attrs['_class'] . '"';
    }
    if (!empty($attrs['id'])) {
        $s .= ' for="' . $attrs['id'] . '"';
    }
    $s .= '><span>' . $attrs['_text'] . '</span> ';
    $s .= '<select ' . buildAttributes($attrs, true) . '>' . DOKU_LF;
    if (!empty($attrs['_options'])) {
        foreach ($attrs['_options'] as $opt) {
            @(list($value, $text, $select) = $opt);
            $p = '';
            if (is_null($text)) {
                $text = $value;
            }
            $p .= ' value="' . formText($value) . '"';
            if (!empty($select)) {
                $p .= ' selected="selected"';
            }
            $s .= '<option' . $p . '>' . formText($text) . '</option>';
        }
    } else {
        $s .= '<option></option>';
    }
    $s .= DOKU_LF . '</select></label>';
    if (preg_match('/(^| )block($| )/', $attrs['_class'])) {
        $s .= '<br />';
    }
    return $s;
}
Exemplo n.º 30
0
 /**
  * Create the HTML for the select it self
  *
  * @return string
  */
 protected function mainElementHTML()
 {
     if ($this->useInput) {
         $this->prefillInput();
     }
     $html = '<select ' . buildAttributes($this->attrs()) . '>';
     $html = array_reduce($this->optGroups, function ($html, OptGroup $optGroup) {
         return $html . $optGroup->toHTML();
     }, $html);
     $html .= '</select>';
     return $html;
 }