Example #1
0
 function formatChangeLog($file)
 {
     $clog = pl_entities(file_get_contents($file));
     $clog = preg_replace('/===+\\s*/', '</pre><hr /><pre>', $clog);
     // url catch only (not all wiki syntax)
     $clog = preg_replace(array('/((?:https?|ftp):\\/\\/(?:\\.*,*[\\w@~%$£µ&i#\\-+=_\\/\\?;])*)/ui', '/(\\s|^)www\\.((?:\\.*,*[\\w@~%$£µ&i#\\-+=_\\/\\?;])*)/iu', '/(?:mailto:)?([a-z0-9.\\-+_]+@([\\-.+_]?[a-z0-9])+)/i'), array('<a href="\\0">\\0</a>', '\\1<a href="http://www.\\2">www.\\2</a>', '<a href="mailto:\\0">\\0</a>'), $clog);
     $clog = preg_replace('!(#[0-9]+(,[0-9]+)*)!e', 'bugize("\\1")', $clog);
     $clog = preg_replace('!vim:.*$!', '', $clog);
     return preg_replace("!(<hr />(\\s|\n)*)?<pre>(\\s|\n)*</pre>((\\s|\n)*<hr />)?!m", "", "<pre>{$clog}</pre>");
 }
Example #2
0
function smarty_function_profile($params, $smarty)
{
    $params = new PlDict($params);
    $with_promo = $params->b('promo', false) || $params->b('cat', false);
    $with_sex = $params->b('sex', true);
    $with_link = $params->b('link', true);
    $with_dir = $params->b('directory', true);
    $with_groupperms = $params->b('groupperms', true);
    $raw = $params->b('raw', false);
    $user = $params->v('user');
    $profile = $params->v('profile');
    if (is_int($user) || ctype_digit($user)) {
        $user = User::getWithUID($user);
    }
    if ($with_dir) {
        $name = pl_entities($user->directoryName());
    } else {
        $name = pl_entities($user->fullName());
    }
    if ($with_promo) {
        $promo = $user->category();
        if ($promo) {
            $name .= ' (' . pl_entities($promo) . ')';
        }
    }
    if ($raw) {
        return $name;
    }
    if ($with_sex && $user->isFemale()) {
        $name = '&bull;' . $name;
    }
    if ($with_link) {
        if (is_null($profile)) {
            $profile = $user->profile();
        }
        if ($profile) {
            $name = '<a href="profile/' . $profile->hrid() . '" class="popup2">' . $name . '</a>';
        }
    }
    if ($profile && $profile->isDead()) {
        $name .= ' &dagger;';
    } else {
        if ($user->lost) {
            $name .= ' <a href="https://www.polytechnique.org/marketing/broken/' . $user->hruid . '"><img src="images/icons/error.gif" alt="Patte cassée" /></a>';
        }
    }
    if ($with_groupperms && $user instanceof User && $user->group_perms == 'admin' && !empty($name)) {
        $name = '<strong>' . $name . '</strong>';
    }
    return $name;
}
Example #3
0
 public function toHtml($hash = null, $login = null)
 {
     $title = "<h2 class='xorg_nl'><a id='art{$this->aid}'></a>" . pl_entities($this->title()) . '</h2>';
     $body = MiniWiki::WikiToHTML($this->body);
     $app = MiniWiki::WikiToHTML($this->append);
     $art = "{$title}\n";
     $art .= "<div class='art'>\n{$body}\n";
     if ($app) {
         $art .= "<div class='app'>{$app}</div>";
     }
     $art .= "</div>\n";
     if (!is_null($hash) && !is_null($login)) {
         $art = str_replace('%HASH%', "{$hash}/{$login}", $art);
     } else {
         $art = str_replace('%HASH%', '', $art);
     }
     return $art;
 }
function smarty_function_display_address($param, $smarty)
{
    $adr = $param['adr'];
    $txtad = $adr->text;
    if (!$txtad) {
        $txthtml = '';
        if ($adr->phones() && count($adr->phones())) {
            require_once 'function.display_phones.php';
            $txthtml .= smarty_function_display_phones(array('tels' => $adr->phones()), $smarty);
        } elseif (isset($param['phones']) && count($param['phones'])) {
            require_once 'function.display_phones.php';
            $txthtml .= smarty_function_display_phones(array('tels' => $param['phones']), $smarty);
        }
        if (!isset($param['nodiv']) && $txthtml != '' && isset($param['pos'])) {
            $txthtml = '<div class="adresse" style="float: ' . $param['pos'] . '">' . $txthtml . '</div>';
        }
        return $txthtml;
    }
    $lines = explode("\n", $txtad);
    $idt = array_shift($lines);
    $restore = true;
    if (!display_address_isIdentity($param['for'], $idt)) {
        array_unshift($lines, $idt);
        $idt = $param['for'];
        $restore = false;
    }
    $txthtml = "";
    $map = "<a href=\"http://maps.google.fr/?q=" . urlencode(implode(", ", $lines) . " ({$idt})") . "\"><img src=\"images/icons/map.gif\" alt=\"Google Maps\" title=\"Carte\"/></a>";
    if ($adr->flags->hasflag('mail')) {
        $mail = '&nbsp;<img src="images/icons/email_open.gif" alt="Adresse courier" title="On peut lui envoyer du courier à cette adresse." />';
    } else {
        $mail = '';
    }
    $comment = "";
    if ($adr->comment != "") {
        $commentHtml = str_replace(array('&', '"'), array('&amp;', '&quot;'), $adr->comment);
        $commentJs = str_replace(array('\\', '\''), array('\\\\', '\\\''), $commentHtml);
        $comment = "<img style=\"margin-left: 5px;\" src=\"images/icons/comments.gif\"" . " onmouseover=\"return overlib('" . $commentJs . "',WIDTH,250);\"" . " onmouseout=\"nd();\"" . " alt=\"Commentaire\" title=\"" . $commentHtml . "\"/>";
    }
    if ($restore) {
        array_unshift($lines, $idt);
    }
    if ($param['titre']) {
        if ($param['titre_div']) {
            $txthtml .= '<div class="titre">' . pl_entity_decode($param['titre']) . '&nbsp;' . $map . $mail . $comment . "</div>\n";
        } else {
            $txthtml .= '<em>' . pl_entity_decode($param['titre']) . '&nbsp;</em>' . $map . $mail . $comment . "<br />\n";
        }
    }
    foreach ($lines as $line) {
        $txthtml .= "<strong>" . pl_entities($line) . "</strong><br/>\n";
    }
    if ($adr->phones() != null) {
        require_once 'function.display_phones.php';
        $txthtml .= smarty_function_display_phones(array('tels' => $adr->phones()), $smarty);
    } else {
        if (isset($param['phones']) && count($param['phones'])) {
            require_once 'function.display_phones.php';
            $txthtml .= smarty_function_display_phones(array('tels' => $param['phones']), $smarty);
        }
    }
    if (!$param['nodiv']) {
        $pos = $param['pos'] ? " style='float: " . $param['pos'] . "'" : '';
        $txthtml = "<div class='adresse' {$pos}>\n" . $txthtml . "</div>\n";
    }
    return $txthtml;
}