/**
 * Dwoo {display_default_name} function plugin
 *
 * Type:     function<br>
 * Date:     2012-06-11<br>
 * Purpose:  Escape output of display_default_name for use in templates
 * @version  1.0
 */
function Dwoo_Plugin_display_default_name(Dwoo $dwoo, $user)
{
    if (!$user) {
        return '';
    }
    return hsc(display_default_name($user));
}
/**
 * Print the breadcrumbs trace with Bootstrap class
 *
 * @author Nicolas GERARD
 *
 * @param string $sep Separator between entries
 * @return bool
 */
function tpl_breadcrumbs_bootstrap($sep = '๏ฟฝ')
{
    global $conf;
    global $lang;
    //check if enabled
    if (!$conf['breadcrumbs']) {
        return false;
    }
    $crumbs = array_reverse(breadcrumbs());
    //setup crumb trace
    $last = count($crumbs);
    $i = 0;
    echo '<ol class="breadcrumb">' . PHP_EOL;
    foreach ($crumbs as $id => $name) {
        $i++;
        if ($i == $last) {
            print '<li class="active">';
        } else {
            print '<li>';
        }
        if ($i == 1) {
            // Try to get the template custom breadcrumb
            $breadCrumb = tpl_getLang('breadcrumb');
            if ($breadCrumb == '') {
                // If not present for the language, get the default one
                $breadCrumb = $lang['breadcrumb'];
            }
            echo $breadCrumb . ': ';
        }
        tpl_link(wl($id), hsc($name), 'title="' . $id . '"');
        print '</li>' . PHP_EOL;
    }
    echo '</ol>' . PHP_EOL;
    return true;
}
function pieform_element_rolepermissions(Pieform $form, $element)
{
    /*{{{*/
    $value = $form->get_value($element);
    $roles = group_get_role_info($element['group']);
    $permissions = array_keys(get_object_vars($value['member']));
    $result = '<table class="editpermissions"><tbody>';
    $result .= '<tr><th>' . get_string('Role', 'group') . '</th>';
    foreach ($permissions as $p) {
        $result .= '<th>' . get_string('filepermission.' . $p, 'artefact.file') . '</th>';
    }
    $result .= '</tr>';
    $prefix = $form->get_name() . '_' . $element['name'] . '_p';
    foreach ($roles as $r) {
        $result .= '<tr>';
        $result .= '<td>' . hsc($r->display) . '</td>';
        foreach ($permissions as $p) {
            $inputname = $prefix . '_' . $r->name . '_' . $p;
            $result .= '<td><input type="checkbox" class="permission" name="' . hsc($inputname) . '"';
            if ($r->name == 'admin') {
                $result .= ' checked disabled';
            } else {
                if ($value[$r->name]->{$p}) {
                    $result .= ' checked';
                }
            }
            $result .= '/></td>';
        }
        $result .= '</tr>';
    }
    $result .= '</tbody></table>';
    return $result;
}
 /**
  * Build a nice email from the submitted data and send it
  */
 function run($data, $thanks, $argv)
 {
     global $ID;
     // get recipient address(es)
     $to = join(',', $argv);
     $sub = sprintf($this->getLang('mailsubject'), $ID);
     $txt = sprintf($this->getLang('mailintro') . "\n\n\n", dformat());
     foreach ($data as $opt) {
         $value = $opt->getParam('value');
         $label = $opt->getParam('label');
         switch ($opt->getFieldType()) {
             case 'fieldset':
                 $txt .= "\n====== " . hsc($label) . " ======\n\n";
                 break;
             default:
                 if ($value === null || $label === null) {
                     break;
                 }
                 $txt .= $label . "\n";
                 $txt .= "\t\t{$value}\n";
         }
     }
     global $conf;
     if (!mail_send($to, $sub, $txt, $conf['mailfrom'])) {
         throw new Exception($this->getLang('e_mail'));
     }
     return $thanks;
 }
 function render($mode, Doku_Renderer $renderer, $data)
 {
     if (empty($data)) {
         return false;
     }
     if ($mode == 'xhtml') {
         /** @var Doku_Renderer_xhtml $renderer */
         list($state, $match, $attributes) = $data;
         switch ($state) {
             case DOKU_LEXER_ENTER:
                 $placement = $attributes['placement'];
                 $title = $attributes['title'];
                 $html = $attributes['html'];
                 if ($html) {
                     $title = hsc(p_render('xhtml', p_get_instructions($title), $info));
                 }
                 $markup = sprintf('<span class="bs-wrap bs-wrap-tooltip" data-toggle="tooltip" data-html="%s" data-placement="%s" title="%s" style="border-bottom:1px dotted">', $html, $placement, $title);
                 $renderer->doc .= $markup;
                 return true;
             case DOKU_LEXER_EXIT:
                 $renderer->doc .= '</span>';
                 return true;
         }
         return true;
     }
     return false;
 }
Example #6
0
 function handle($match, $state, $pos, &$handler)
 {
     $width = 320;
     $height = 240;
     $params['scaling'] = '"fit"';
     $params['autoPlay'] = 'false';
     $params['urlEncoding'] = 'true';
     list($url, $attr) = explode(" ", hsc(trim(substr($match, 13, -2))), 2);
     foreach (explode(" ", $attr) as $param) {
         if (preg_match('/(\\d+),(\\d+)/', $param, $res)) {
             $width = intval($res[1]);
             $height = intval($res[2]);
         } else {
             if (preg_match('/([^:]+):(.*)$/', $param, $res)) {
                 $params[strtolower(substr($res[1], 0, 1)) . substr($res[1], 1)] = '"' . $res[2] . '"';
             } else {
                 if (preg_match('/no(\\w+)/', $param, $res)) {
                     $params[strtolower(substr($res[1], 0, 1)) . substr($res[1], 1)] = 'false';
                 } else {
                     if (preg_match('/(\\w+)/', $param, $res)) {
                         $params[strtolower(substr($res[1], 0, 1)) . substr($res[1], 1)] = 'true';
                     }
                 }
             }
         }
     }
     if (strpos($url, '://') === false) {
         $url = ml($url);
     }
     return array('url' => $url, 'width' => $width, 'height' => $height, 'fid' => uniqid(), 'attr' => $params);
 }
Example #7
0
 public function create_preview()
 {
     $width = $this->get_preview_width();
     $height = $this->get_preview_height();
     $id = uniqid('lid');
     $layout = "<svg xmlns=http://www.w3.org/2000/svg role='img' width='{$width}' height='{$height}' aria-labelledby='title{$id} desc{$id}'>";
     if (!empty($this->text)) {
         $layout .= "<title id='title{$id}' >" . get_string('layoutpreviewimage', 'view') . "</title>";
         $layout .= "<desc id='desc{$id}'>" . hsc($this->text) . "</desc>";
     }
     $x = 0;
     $y = 0;
     $col_height = $this->get_preview_column_height();
     $class = true;
     foreach ($this->layout as $key => $row) {
         $style = 'layout' . (int) $class;
         $columns = explode(',', $row);
         foreach ($columns as $column) {
             $col_width = $this->get_percentage_column_width(count($columns), $column);
             $layout .= "<rect x='" . number_format($x, 2, '.', '') . "' y='" . number_format($y, 2, '.', '') . "' width='" . number_format($col_width, 2, '.', '') . "' height='" . number_format($col_height, 2, '.', '') . "' class='{$style}'/>";
             $x += $col_width + self::$spacer;
             // increment x val for next col
         }
         $x = 0;
         $y += $col_height + self::$spacer;
         // increment y val for next row
         $class = !$class;
     }
     $layout .= '</svg>';
     return $layout;
 }
Example #8
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $configdata = $instance->get('configdata');
     if (!isset($configdata['appsid'])) {
         return;
     }
     $apps = self::make_apps_url($configdata['appsid']);
     $url = hsc($apps['url']);
     $type = hsc($apps['type']);
     $height = !empty($configdata['height']) ? intval($configdata['height']) : self::$default_height;
     if (isset($configdata['appsid']) && !empty($type)) {
         $smarty = smarty_core();
         $smarty->assign('url', $apps['url']);
         switch ($type) {
             case 'iframe':
                 // Google Docs (documents, presentations, spreadsheets, forms), Google Calendar, Google Maps
                 $smarty->assign('height', $height);
                 return $smarty->fetch('blocktype:googleapps:iframe.tpl');
             case 'spanicon':
                 // Google Docs collections (folder icon)
                 $smarty->assign('img', get_config('wwwroot') . 'blocktype/googleapps/images/folder_documents.png');
                 return $smarty->fetch('blocktype:googleapps:spanicon.tpl');
             case 'image':
                 // Google Docs drawing
                 $smarty->assign('height', $height);
                 return $smarty->fetch('blocktype:googleapps:image.tpl');
         }
     }
     return get_string('badurlerror', 'blocktype.googleapps', $url);
 }
Example #9
0
 /**
  * Build SEO title
  *
  * @param string $pageTitle Title of the current item/page/posts...
  */
 function title($pageTitle = null)
 {
     if (!is_object($this->controller)) {
         return;
     }
     if (!$pageTitle) {
         $pageTitle = $this->controller->pageTitle;
     }
     if (!$pageTitle) {
         $pageTitle = ucwords($this->controller->params['controller']);
     }
     $description = Configure::read('AppSettings.description');
     $nameAndDescription = hsc(Configure::read('AppSettings.site_name'));
     if ($description) {
         $description = hsc($description);
         $nameAndDescription = "{$nameAndDescription} - {$description}";
     }
     if ($this->controller->isHome) {
         $this->controller->pageTitle = $nameAndDescription;
     } else {
         $this->controller->pageTitle = "{$pageTitle} &bull; {$nameAndDescription}";
     }
     $this->controller->set('page_title_for_layout', $pageTitle);
     $this->controller->set('site_title_for_layout', $nameAndDescription);
 }
Example #10
0
 /**
  * form for slack invite
  *
  *
  */
 function slackinvite_signinform()
 {
     global $ID;
     $html = '';
     $params = array();
     $params['id'] = 'slackinvite_plugin_id';
     $params['action'] = wl($ID);
     $params['method'] = 'post';
     $params['enctype'] = 'multipart/form-data';
     $params['class'] = 'slackinvite_plugin';
     // Modification of the default dw HTML upload form
     $form = new Doku_Form($params);
     $form->startFieldset($this->getLang('signup'));
     $form->addHidden('source', hsc("slackinvite"));
     //add source of call, used in action to ignore anything not from this form
     $form->addElement(form_makeTextField('first_name', '', $this->getLang('first_name'), 'first__name'));
     $form->addElement(form_makeTextField('last_name', '', $this->getLang('last_name'), 'last__name'));
     $form->addElement(form_makeTextField('email', '', $this->getLang('email'), 'email'));
     $form->addElement(form_makeButton('submit', 'slacksignup', $this->getLang('btn_signup')));
     $form->endFieldset();
     $html .= '<div class="dokuwiki"><p>' . NL;
     //$html .= '<h3>TEAM43 Slack Sign Up</h3>';
     $html .= $form->getForm();
     $html .= '</p></div>' . NL;
     return $html;
 }
function amdy_tpl_breadcrumbs()
{
    global $lang;
    global $conf;
    //check if enabled
    if (!$conf['breadcrumbs']) {
        return false;
    }
    $crumbs = breadcrumbs();
    //setup crumb trace
    //render crumbs, highlight the last one
    print '<ul class="breadcrumb">';
    $last = count($crumbs);
    $i = 0;
    foreach ($crumbs as $id => $name) {
        $i++;
        echo '<li' . ($i == $last ? ' class="active"' : '') . '>';
        //echo '<a href="test.php">test</a>';
        echo '<a href="' . wl($id) . '" title="' . $id . '"' . '>' . hsc($name) . '</a>';
        if ($i != $last) {
            echo '<span class="divider">/</span>';
        }
        echo '</li>';
    }
    print '</ul>';
    return true;
}
Example #12
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $configdata = $instance->get('configdata');
     // this will make sure to unserialize it for us
     $configdata['viewid'] = $instance->get('view');
     // This can be either an image or profileicon. They both implement
     // render_self
     $result = '';
     if (isset($configdata['artefactid'])) {
         $image = $instance->get_artefact_instance($configdata['artefactid']);
         if ($image instanceof ArtefactTypeProfileIcon) {
             $src = get_config('wwwroot') . 'thumb.php?type=profileiconbyid&id=' . $configdata['artefactid'];
             $description = $image->get('title');
         } else {
             $src = get_config('wwwroot') . 'artefact/file/download.php?file=' . $configdata['artefactid'];
             $src .= '&view=' . $instance->get('view');
             $description = $image->get('description');
         }
         if (!empty($configdata['width'])) {
             $src .= '&maxwidth=' . $configdata['width'];
         }
         $result = '<div class="center"><div>';
         $result .= '<a href="' . get_config('wwwroot') . 'view/artefact.php?artefact=' . $configdata['artefactid'] . '&view=' . $instance->get('view') . '"><img src="' . hsc($src) . '" alt="' . hsc($description) . '"></a>';
         $result .= '</div>';
         $description = is_a($image, 'ArtefacttypeImage') ? $image->get('description') : $image->get('title');
         if (!empty($configdata['showdescription']) && $description) {
             $result .= '<p>' . hsc($description) . '</p>';
         }
         $result .= '</div>';
     }
     return $result;
 }
Example #13
0
 function handle_start(&$event, $param)
 {
     global $ID;
     global $ACT;
     global $INFO;
     if ($ACT != 'show') {
         return;
     }
     if (!$INFO['exists']) {
         return;
     }
     # don't try to read an article that doesn't exist
     $all = rtrim(rawWiki($ID));
     $inner = substr($all, 2, -2);
     if ($all == '[[' . $inner . ']]' and strpos($inner, '[[') === false and strpos($inner, ']]') === false) {
         if (!strpos($inner, '://') === false) {
             $url = $inner;
             # link is URL already
         } else {
             msg(sprintf('From: <a href="' . wl($ID, 'do=edit') . '">' . hsc($ID) . '</a>'));
             $url = html_wikilink($inner, $name = null, $search = '');
             $url = substr($url, strpos($url, '"') + 1);
             $url = substr($url, 0, strpos($url, '"'));
         }
         idx_addPage($ID);
         # ensure fulltext search indexing of referrer article - to put it on the backlink page of target article
         send_redirect($url);
     }
 }
    /**
     * Do the magic
     */
    function handle_start(&$event, $param)
    {
        global $conf;
        $bans = @file($conf['cachedir'] . '/ipbanplugin.txt');
        $client = clientIP(true);
        if (is_array($bans)) {
            foreach ($bans as $ban) {
                $fields = explode("\t", $ban);
                if ($fields[0] == $client) {
                    $text = $this->locale_xhtml('banned');
                    $text .= sprintf('<p>' . $this->getLang('banned') . '</p>', hsc($client), strftime($conf['dformat'], $fields[1]), hsc($fields[3]));
                    $title = $this->getLang('denied');
                    header("HTTP/1.0 403 Forbidden");
                    echo <<<EOT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title>{$title}</title></head>
<body style="font-family: Arial, sans-serif">
  <div style="width:60%; margin: auto; background-color: #fcc;
              border: 1px solid #faa; padding: 0.5em 1em;">
  {$text}
  </div>
</body>
</html>
EOT;
                    exit;
                }
            }
        }
    }
Example #15
0
function getDesignList($start, $count, $list, $i18nBy)
{
    global $legacyMode;
    // flush return value
    $return = "";
    // check for language URL
    global $langURL;
    // begin at the already-established start of the list and loop down
    for ($i = $start - 1; $i >= $start - $count; $i--) {
        $id = $list[$i][0];
        $designURL = $langURL . "/{$id}/";
        // prepend for translation pages
        $designName = hsc($list[$i][1]);
        $designerName = hsc($list[$i][2]);
        $designerURL = hsc($list[$i][3]);
        // kick in output buffering
        ob_start();
        // pull in the correct partial template for design listings
        if (isset($legacyMode)) {
            include $SERVER_ROOT . "tmpl-design-link-legacy.php";
        } else {
            include $SERVER_ROOT . "tmpl-design-link.php";
        }
        // dump and close buffering
        $buffer = ob_get_contents();
        ob_end_clean();
        // add the buffer to return string if we're still within range
        if ($i >= 0) {
            $return .= $buffer;
        }
    }
    // send back the generated design list
    return $return;
}
 /**
  * output appropriate html
  */
 function html()
 {
     global $config_cascade;
     echo $this->locale_xhtml('intro');
     echo '<form method="post" action="" class="whyspam">';
     echo '<fieldset>';
     echo '<legend>' . $this->getLang('paste') . '</legend>';
     echo '<textarea name="whyspam" class="edit"></textarea><br />';
     echo '<input type="submit" class="button" />';
     echo '</fieldset>';
     echo '</form>';
     $found = array();
     if ($_REQUEST['whyspam']) {
         foreach ($config_cascade['wordblock'] as $bla => $files) {
             foreach ($files as $file) {
                 $found = array_merge($found, $this->_checkit($file, $_REQUEST['whyspam']));
             }
         }
         echo '<div class="level2">';
         if (count($found)) {
             echo '<p>' . $this->getLang('found') . '</p>';
             echo '<ul>';
             foreach ($found as $f) {
                 echo '<li><div class="li">' . hsc($f[0]) . ':' . $f[1] . '<br /><code>' . hsc($f[2]) . '</code><br /><i>' . hsc($f[3]) . '</i></div></li>';
             }
             echo '</ul>';
         } else {
             echo '<p>' . $this->getLang('notfound') . '</p>';
         }
         echo '</div>';
     }
 }
Example #17
0
 /**
  * handle event
  */
 function handle_start(&$event, $param)
 {
     global $ID;
     global $ACT;
     if ($ACT != 'show') {
         return;
     }
     $redirects = confToHash($this->getsavedir() . '/shorturl.conf');
     if ($redirects[$ID]) {
         if (preg_match('/^https?:\\/\\//', $redirects[$ID])) {
             send_redirect($redirects[$ID]);
         } else {
             if ($this->getConf('showmsg')) {
                 msg(sprintf($this->getLang('redirected'), hsc($ID)));
             }
             send_redirect(wl($redirects[$ID], '', true));
         }
         exit;
     } else {
         if ($_GET['generateShortURL'] != "" && auth_quickaclcheck($ID) >= AUTH_READ) {
             $shorturl =& plugin_load('helper', 'shorturl');
             if ($shorturl) {
                 $shortID = $shorturl->autoGenerateShortUrl($ID);
             }
         }
     }
 }
/**
 * Dwoo {display_name} function plugin
 *
 * Type:     function<br>
 * Date:     June 22, 2006<br>
 * Purpose:  Display a user's name according to mahara rules
 * @author   Catalyst IT Ltd
 * @version  1.0
 */
function Dwoo_Plugin_display_name(Dwoo $dwoo, $user, $userto = null, $nameonly = false, $realname = false)
{
    if (!$user) {
        return '';
    }
    return hsc(display_name($user, $userto, $nameonly, $realname));
}
function white_breadcrumbs()
{
    global $lang;
    global $conf;
    //check if enabled
    if (!$conf['breadcrumbs']) {
        return false;
    }
    $crumbs = breadcrumbs();
    //setup crumb trace
    $crumbs_sep = ' <span class="bcsep">' . $sep . '</span> ';
    //render crumbs, highlight the last one
    print '<h3>' . $lang['breadcrumb'] . '</h3>';
    $last = count($crumbs);
    $i = 0;
    print '<ul>';
    foreach ($crumbs as $id => $name) {
        $i++;
        print '<li>';
        if ($i == $last) {
            print '<span class="curid">';
        }
        tpl_link(wl($id), hsc($name), 'class="breadcrumbs" title="' . $id . '"');
        if ($i == $last) {
            print '</span>';
        }
        print '</li>';
    }
    print '</ul>';
    return true;
}
Example #20
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $exporter;
     $configdata = $instance->get('configdata');
     $result = '';
     if (!empty($configdata['artefactid'])) {
         require_once get_config('docroot') . 'artefact/lib.php';
         $blog = $instance->get_artefact_instance($configdata['artefactid']);
         $configdata['hidetitle'] = true;
         $configdata['countcomments'] = true;
         $configdata['viewid'] = $instance->get('view');
         if ($instance->get_view()->is_submitted()) {
             // Don't display posts added after the submitted date.
             if ($submittedtime = $instance->get_view()->get('submittedtime')) {
                 $configdata['before'] = $submittedtime;
             }
         }
         $limit = isset($configdata['count']) ? intval($configdata['count']) : 5;
         $posts = ArtefactTypeBlogpost::get_posts($blog->get('id'), $limit, 0, $configdata);
         $template = 'artefact:blog:viewposts.tpl';
         if ($exporter) {
             $pagination = false;
         } else {
             $baseurl = $instance->get_view()->get_url();
             $baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'block=' . $instance->get('id');
             $pagination = array('baseurl' => $baseurl, 'id' => 'blogpost_pagination_' . $instance->get('id'), 'datatable' => 'postlist_' . $instance->get('id'), 'jsonscript' => 'artefact/blog/posts.json.php');
         }
         $configdata['blockid'] = $instance->get('id');
         $configdata['editing'] = $editing;
         ArtefactTypeBlogpost::render_posts($posts, $template, $configdata, $pagination);
         $smarty = smarty_core();
         if (isset($configdata['viewid'])) {
             $artefacturl = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $blog->get('id') . '&view=' . $configdata['viewid'];
             $smarty->assign('artefacttitle', '<a href="' . $artefacturl . '">' . hsc($blog->get('title')) . '</a>');
             if ($exporter && $posts['count'] > $limit) {
                 $posts['pagination'] = '<a href="' . $artefacturl . '">' . get_string('allposts', 'artefact.blog') . '</a>';
             }
         } else {
             $smarty->assign('artefacttitle', hsc($blog->get('title')));
         }
         // Only show the 'New entry' link for blogs that you can add an entry to
         $canaddpost = false;
         $institution = $blog->get('institution');
         $group = $blog->get('group');
         if (ArtefactTypeBlog::can_edit_blog($blog, $institution, $group)) {
             $canaddpost = true;
         }
         $smarty->assign('options', $configdata);
         $smarty->assign('description', $blog->get('description'));
         $smarty->assign('owner', $blog->get('owner'));
         $smarty->assign('tags', $blog->get('tags'));
         $smarty->assign('blockid', $instance->get('id'));
         $smarty->assign('editing', $editing);
         $smarty->assign('canaddpost', $canaddpost);
         $smarty->assign('blogid', $blog->get('id'));
         $smarty->assign('posts', $posts);
         $result = $smarty->fetch('artefact:blog:blog.tpl');
     }
     return $result;
 }
Example #21
0
 /**
  * Main function to determine the avatar to use
  */
 function _getAvatarURL($user, &$title, &$size)
 {
     global $auth;
     if (!$size || !is_int($size)) {
         $size = $this->getConf('size');
     }
     // check first if a local image for the given user exists
     $userinfo = $auth->getUserData($user);
     if (is_array($userinfo)) {
         if ($userinfo['name'] && !$title) {
             $title = hsc($userinfo['name']);
         }
         $avatar = $this->getConf('namespace') . ':' . $user;
         $formats = array('.png', '.jpg', '.gif');
         foreach ($formats as $format) {
             $img = mediaFN($avatar . $format);
             if (!@file_exists($img)) {
                 continue;
             }
             $src = ml($avatar . $format, array('w' => $size, 'h' => $size));
             break;
         }
         if (!$src) {
             $mail = $userinfo['mail'];
         }
     } else {
         $mail = $user;
     }
     if (!$src) {
         $seed = md5($mail);
         if (function_exists('imagecreatetruecolor')) {
             // we take the monster ID as default
             $file = 'monsterid.php?seed=' . $seed . '&size=' . $size . '&.png';
         } else {
             // GDlib is not availble - resort to default images
             switch ($size) {
                 case 20:
                 case 40:
                 case 80:
                     $file = 'images/default_' . $size . '.png';
                     break;
                 default:
                     $file = 'images/default_120.png';
             }
         }
         $default = ml(DOKU_URL . '/lib/plugins/avatar/' . $file, 'cache=recache', true, '&', true);
         // do not pass invalid or empty emails to gravatar site...
         if (mail_isvalid($mail) && $size <= 80) {
             $src = ml('http://www.gravatar.com/avatar.php?' . 'gravatar_id=' . $seed . '&default=' . urlencode($default) . '&size=' . $size . '&rating=' . $this->getConf('rating') . '&.jpg', 'cache=recache');
             // show only default image if invalid or empty email given
         } else {
             $src = $default;
         }
     }
     if (!$title) {
         $title = obfuscate($mail);
     }
     return $src;
 }
Example #22
0
 /**
  * Validate field input
  *
  * @throws Exception when empty or wrong time format
  */
 protected function _validate()
 {
     parent::_validate();
     $value = $this->getParam('value');
     if (!is_null($value) && !preg_match('/^\\d{1,2}:\\d{2}(?::\\d{2})?$/', $value)) {
         throw new Exception(sprintf($this->getLang('e_time'), hsc($this->getParam('display'))));
     }
 }
 function _validate()
 {
     parent::_validate();
     $value = $this->getParam('value');
     if (!is_null($value) && !mail_isvalid($value)) {
         throw new Exception(sprintf($this->getLang('e_email'), hsc($this->getParam('label'))));
     }
 }
Example #24
0
 /**
  * Validate field value
  *
  * @throws Exception when not a number
  */
 protected function _validate()
 {
     $value = $this->getParam('value');
     if (!is_null($value) && !is_numeric($value)) {
         throw new Exception(sprintf($this->getLang('e_numeric'), hsc($this->getParam('display'))));
     }
     parent::_validate();
 }
Example #25
0
 /**
  * Use a text area for input
  *
  * @param string $name
  * @param string $rawvalue
  * @return string
  */
 public function valueEditor($name, $rawvalue)
 {
     $class = 'struct_' . strtolower($this->getClass());
     $name = hsc($name);
     $rawvalue = formText($rawvalue);
     $html = "<textarea name=\"{$name}\" class=\"{$class}\">{$rawvalue}</textarea>";
     return "{$html}";
 }
 function _validate()
 {
     parent::_validate();
     $value = $this->getParam('value');
     if (!is_null($value) && !preg_match('/^\\d{4}-\\d{2}-\\d{2}$/', $value)) {
         throw new Exception(sprintf($this->getLang('e_date'), hsc($this->getParam('label'))));
     }
 }
 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();
 }
 /**
  * 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;
 }
Example #29
0
 /**
  * Arguments:
  *  - cmd
  *  - page_tpl
  *  - page_tgt
  *
  * @param array $args The tokenized definition, only split at spaces
  */
 function initialize($args)
 {
     if (count($args) < 3) {
         msg(sprintf($this->getLang('e_missingargs'), hsc($args[0]), hsc($args[1])), -1);
         return;
     }
     // get standard arguments
     $this->opt = array_combine(array('cmd', 'page_tpl', 'page_tgt'), $args);
 }
 function _validate()
 {
     parent::_validate();
     global $auth;
     $value = $this->getParam('value');
     if (!is_null($value) && $auth->getUserData($value) === false) {
         throw new Exception(sprintf($this->getLang('e_user'), hsc($this->getParam('label'))));
     }
 }