本文整理汇总了PHP中Pluf_esc函数的典型用法代码示例。如果您正苦于以下问题:PHP Pluf_esc函数的具体用法?PHP Pluf_esc怎么用?PHP Pluf_esc使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Pluf_esc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: feedFragment
public function feedFragment($request)
{
$review = $this->get_patch()->get_review();
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view', array($request->project->shortname, $review->id));
$title = sprintf(__('%s: Updated review %d - %s'), Pluf_esc($request->project->name), $review->id, Pluf_esc($review->summary));
$url .= '#ic' . $this->id;
$date = Pluf_Date::gmDateToGmString($this->creation_dtime);
$context = new Pluf_Template_Context_Request($request, array('url' => $url, 'author' => $this->get_submitter(), 'title' => $title, 'c' => $this, 'review' => $review, 'date' => $date));
$tmpl = new Pluf_Template('idf/review/feedfragment.xml');
return $tmpl->render($context);
}
示例2: callbackWikiPage
function callbackWikiPage($m)
{
$sql = new Pluf_SQL('project=%s AND title=%s', array($this->project->id, $m[2]));
$pages = Pluf::factory('IDF_WikiPage')->getList(array('filter' => $sql->gen()));
if ($pages->count() != 1 and $this->request->rights['hasWikiAccess'] and !$this->request->user->isAnonymous()) {
return '<img style="vertical-align: text-bottom;" alt=" " src="' . Pluf::f('url_media') . '/idf/img/add.png" /><a href="' . Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::create', array($this->project->shortname), array('name' => $m[2])) . '" title="' . __('Create this documentation page') . '">' . $m[1] . '</a>';
}
if (!$this->request->rights['hasWikiAccess'] or $pages->count() == 0) {
return $m[1];
}
return '<a href="' . Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::view', array($this->project->shortname, $pages[0]->title)) . '" title="' . Pluf_esc($pages[0]->summary) . '">' . $m[1] . '</a>';
}
示例3: highLight
/**
* Returns a HTML snippet with a line-by-line pre-rendered table
* for the given source content
*
* @param array file information as returned by getMimeType or getMimeTypeFromContent
* @param string the content of the file
* @return string
*/
public static function highLight($fileinfo, $content)
{
$pretty = '';
if (self::isSupportedExtension($fileinfo[2])) {
$pretty = ' prettyprint';
}
$table = array();
$i = 1;
foreach (preg_split("/\r\n|\r|\n/", $content) as $line) {
$table[] = '<tr class="c-line"><td class="code-lc" id="L' . $i . '"><a href="#L' . $i . '">' . $i . '</a></td>' . '<td class="code mono' . $pretty . '">' . IDF_Diff::padLine(Pluf_esc($line)) . '</td></tr>';
$i++;
}
return Pluf_Template::markSafe(implode("\n", $table));
}
示例4: __construct
function __construct($request)
{
$content = '';
try {
$context = new Pluf_Template_Context(array('query' => $request->query));
$tmpl = new Pluf_Template('404.html');
$content = $tmpl->render($context);
$mimetype = null;
} catch (Exception $e) {
$mimetype = 'text/plain';
$content = sprintf('The requested URL %s was not found on this server.' . "\n" . 'Please check the URL and try again.' . "\n\n" . '404 - Not Found', Pluf_esc($request->query));
}
parent::__construct($content, $mimetype);
$this->status_code = 404;
}
示例5: __construct
function __construct($request)
{
$content = '';
try {
$context = new Pluf_Template_Context(array('query' => $request->query));
$tmpl = new Pluf_Template('503.html');
$content = $tmpl->render($context);
$mimetype = null;
} catch (Exception $e) {
$mimetype = 'text/plain';
$content = sprintf('The requested URL %s is not available at the moment.' . "\n" . 'Please try again later.' . "\n\n" . '503 - Service Unavailable', Pluf_esc($request->query));
}
parent::__construct($content, $mimetype);
$this->status_code = 503;
$this->headers['Retry-After'] = 300;
// retry after 5 minutes
}
示例6: start
/**
* We need the user object and the request.
*
* If the user object is null (for example a non associated
* commit), we can use the $text value for an alternative display.
*
* @param Pluf_User
* @param Pluf_HTTP_Request
* @param string Alternate text ('')
*/
function start($user, $request, $text = '', $echo = true)
{
if ($user == null) {
$out = strlen($text) ? strip_tags($text) : __('Anonymous');
} else {
if (!$user->isAnonymous() and $user->id == $request->user->id) {
$utext = __('Me');
$url = Pluf_HTTP_URL_urlForView('idf_dashboard');
} else {
$utext = Pluf_esc($user);
$url = Pluf_HTTP_URL_urlForView('IDF_Views_User::view', array($user->login));
}
$out = sprintf('<a href="%s" class="username">%s</a>', $url, $utext);
}
if ($echo) {
echo $out;
} else {
return $out;
}
}
示例7: checkBadLogins
/**
* From the input, find the bad logins.
*
* @throws Pluf_Form_Invalid exception when bad logins are found
* @param string Comma, new line delimited list of logins
* @return string Comma, new line delimited list of logins
*/
public static function checkBadLogins($logins)
{
$bad = array();
foreach (preg_split("/\r\n|\r|\n|\\,/", $logins, -1, PREG_SPLIT_NO_EMPTY) as $login) {
$sql = new Pluf_SQL('login=%s', array(trim($login)));
try {
$user = Pluf::factory('Pluf_User')->getOne(array('filter' => $sql->gen()));
if (null == $user) {
$bad[] = $login;
}
} catch (Exception $e) {
$bad[] = $login;
}
}
$n = count($bad);
if ($n) {
$badlogins = Pluf_esc(implode(', ', $bad));
throw new Pluf_Form_Invalid(sprintf(_n('The following login is invalid: %s.', 'The following login are invalids: %s.', $n), $badlogins));
}
return $logins;
}
示例8: save
/**
* Save the model in the database.
*
* @param bool Commit in the database or not. If not, the object
* is returned but not saved in the database.
* @return Object Model with data set from the form.
*/
function save($commit = true)
{
if (!$this->isValid()) {
throw new Exception(__('Cannot save the model from an invalid form.'));
}
unset($this->cleaned_data['password2']);
$update_pass = false;
if (strlen($this->cleaned_data['password']) == 0) {
unset($this->cleaned_data['password']);
} else {
$update_pass = true;
}
$old_email = $this->user->email;
$new_email = $this->cleaned_data['email'];
unset($this->cleaned_data['email']);
if ($old_email != $new_email) {
$cr = new Pluf_Crypt(md5(Pluf::f('secret_key')));
$encrypted = trim($cr->encrypt($new_email . ':' . $this->user->id . ':' . time()), '~');
$key = substr(md5(Pluf::f('secret_key') . $encrypted), 0, 2) . $encrypted;
$url = Pluf::f('url_base') . Pluf_HTTP_URL_urlForView('IDF_Views_User::changeEmailDo', array($key), array(), false);
$urlik = Pluf::f('url_base') . Pluf_HTTP_URL_urlForView('IDF_Views_User::changeEmailInputKey', array(), array(), false);
$context = new Pluf_Template_Context(array('key' => Pluf_Template::markSafe($key), 'url' => Pluf_Template::markSafe($url), 'urlik' => Pluf_Template::markSafe($urlik), 'email' => $new_email, 'user' => $this->user));
$tmpl = new Pluf_Template('idf/user/changeemail-email.txt');
$text_email = $tmpl->render($context);
$email = new Pluf_Mail(Pluf::f('from_email'), $new_email, __('Confirm your new email address.'));
$email->addTextMessage($text_email);
$email->sendMail();
$this->user->setMessage(sprintf(__('A validation email has been sent to "%s" to validate the email address change.'), Pluf_esc($new_email)));
}
$this->user->setFromFormData($this->cleaned_data);
// Add key as needed.
if ('' !== $this->cleaned_data['ssh_key']) {
$key = new IDF_Key();
$key->user = $this->user;
$key->content = $this->cleaned_data['ssh_key'];
if ($commit) {
$key->create();
}
}
if ($commit) {
$this->user->update();
if ($update_pass) {
/**
* [signal]
*
* Pluf_User::passwordUpdated
*
* [sender]
*
* IDF_Form_UserAccount
*
* [description]
*
* This signal is sent when the user updated his
* password from his account page.
*
* [parameters]
*
* array('user' => $user)
*
*/
$params = array('user' => $this->user);
Pluf_Signal::send('Pluf_User::passwordUpdated', 'IDF_Form_UserAccount', $params);
}
}
return $this->user;
}
示例9: renderCompared
public function renderCompared($chunks, $filename)
{
$fileinfo = IDF_FileUtil::getMimeType($filename);
$pretty = '';
if (IDF_FileUtil::isSupportedExtension($fileinfo[2])) {
$pretty = ' prettyprint';
}
$out = '';
$cc = 1;
$i = 0;
foreach ($chunks as $chunk) {
foreach ($chunk as $line) {
$line1 = ' ';
$line2 = ' ';
$line[2] = strlen($line[2]) ? self::padLine(Pluf_esc($line[2])) : ' ';
if ($line[0] and $line[1]) {
$class = 'diff-c';
$line1 = $line2 = $line[2];
} elseif ($line[0]) {
$class = 'diff-r';
$line1 = $line[2];
} else {
$class = 'diff-a';
$line2 = $line[2];
}
$out .= sprintf('<tr class="diff-line"><td class="diff-lc">%s</td><td class="%s mono%s"><code>%s</code></td><td class="diff-lc">%s</td><td class="%s mono%s"><code>%s</code></td></tr>' . "\n", $line[0], $class, $pretty, $line1, $line[1], $class, $pretty, $line2);
}
if (count($chunks) > $cc) {
$out .= '<tr class="diff-next"><td>...</td><td> </td><td>...</td><td> </td></tr>' . "\n";
}
$cc++;
$i++;
}
return Pluf_Template::markSafe($out);
}
示例10: Pluf_HTTP_Response_ServerErrorDebug_Pretty
//.........这里部分代码省略.........
<a href=\'#\' onclick="return sectionToggle(\'tb_switch\',\'tb_list\')">
<span id="tb_switch">▶</span></a></h2>
<ul id="tb_list" class="traceback">';
$frames = $e->getTrace();
foreach ($frames as $frame_id => $frame) {
if (!isset($frame['file'])) {
$frame['file'] = 'No File';
$frame['line'] = '0';
}
$out .= '<li class="frame">' . $sub($frame) . '
[' . $o($frame['file']) . ', line ' . $o($frame['line']) . ']';
if (isset($frame['args']) && count($frame['args']) > 0) {
$params = $parms($frame);
$out .= '
<div class="commands">
<a href=\'#\' onclick="return varToggle(this, \'' . $o($frame_id) . '\',\'v\')"><span>▶</span> Args</a>
</div>
<table class="vars" id="v' . $o($frame_id) . '">
<thead>
<tr>
<th>Arg</th>
<th>Name</th>
<th>Value</th>
</tr>
</thead>
<tbody>';
foreach ($frame['args'] as $k => $v) {
$name = (isset($params[$k]) and isset($params[$k]->name)) ? '$' . $params[$k]->name : '?';
$out .= '
<tr>
<td>' . $o($k) . '</td>
<td>' . $o($name) . '</td>
<td class="code">
<pre>' . Pluf_esc(print_r($v, true)) . '</pre>
</td>
</tr>';
}
$out .= '</tbody></table>';
}
if (is_readable($frame['file'])) {
$out .= '
<div class="commands">
<a href=\'#\' onclick="return varToggle(this, \'' . $o($frame_id) . '\',\'c\')"><span>▶</span> Src</a>
</div>
<div class="context" id="c' . $o($frame_id) . '">';
$lines = $src2lines($frame['file']);
$start = $frame['line'] < 5 ? 0 : $frame['line'] - 5;
$end = $start + 10;
$out2 = '';
foreach ($lines as $k => $line) {
if ($k > $end) {
break;
}
$line = trim(strip_tags($line));
if ($k < $start && isset($frames[$frame_id + 1]["function"]) && preg_match('/function( )*' . preg_quote($frames[$frame_id + 1]["function"]) . '/', $line)) {
$start = $k;
}
if ($k >= $start) {
if ($k != $frame['line']) {
$out2 .= '<li><code>' . $clean($line) . '</code></li>' . "\n";
} else {
$out2 .= '<li class="current-line"><code>' . $clean($line) . '</code></li>' . "\n";
}
}
}
$out .= "<ol start=\"{$start}\">\n" . $out2 . "</ol>\n";
示例11: makeBreadCrumb
public static function makeBreadCrumb($project, $commit, $file, $sep = '/')
{
$elts = explode('/', $file);
$out = array();
$stack = '';
$i = 0;
foreach ($elts as $elt) {
$stack .= $i == 0 ? rawurlencode($elt) : '/' . rawurlencode($elt);
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::tree', array($project->shortname, $commit, $stack));
$out[] = '<a href="' . $url . '">' . Pluf_esc($elt) . '</a>';
$i++;
}
return '<span class="breadcrumb">' . implode('<span class="sep">' . $sep . '</span>', $out) . '</span>';
}
示例12: changeEmailDo
public function changeEmailDo($request, $match)
{
$key = $match[1];
$url = Pluf_HTTP_URL_urlForView('IDF_Views_User::changeEmailInputKey');
try {
list($email, $id, $time) = IDF_Form_UserChangeEmail::validateKey($key);
} catch (Pluf_Form_Invalid $e) {
return new Pluf_HTTP_Response_Redirect($url);
}
if ($id != $request->user->id) {
return new Pluf_HTTP_Response_Redirect($url);
}
// Now we have a change link coming from the right user.
$request->user->email = $email;
$request->user->update();
$request->user->setMessage(sprintf(__('Your new email address "%s" has been validated. Thank you!'), Pluf_esc($email)));
$url = Pluf_HTTP_URL_urlForView('IDF_Views_User::myAccount');
return new Pluf_HTTP_Response_Redirect($url);
}
示例13: feedFragment
public function feedFragment($request)
{
$issue = $this->get_issue();
$url = Pluf::f('url_base') . Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view', array($request->project->shortname, $issue->id));
$title = sprintf(__('%s: Comment on issue %d - %s'), Pluf_esc($request->project->name), $issue->id, Pluf_esc($issue->summary));
$url .= '#ic' . $this->id;
$date = Pluf_Date::gmDateToGmString($this->creation_dtime);
$context = new Pluf_Template_Context_Request($request, array('url' => $url, 'author' => $issue->get_submitter(), 'title' => $title, 'c' => $this, 'issue' => $issue, 'date' => $date));
$tmpl = new Pluf_Template('idf/issues/feedfragment.xml');
return $tmpl->render($context);
}
示例14: linkReview
/**
* Generate the link to a review.
*
* @param IDF_Review Review.
* @param string Name of the link.
* @return string Linked review.
*/
public function linkReview($review, $title, $anchor = '')
{
$ic = in_array($review->status, $this->project->getTagIdsByStatus('closed')) ? 'issue-c' : 'issue-o';
return '<a href="' . Pluf_HTTP_URL_urlForView('IDF_Views_Review::view', array($this->project->shortname, $review->id)) . $anchor . '" class="' . $ic . '" title="' . Pluf_esc($review->summary) . '">' . Pluf_esc($title) . '</a>';
}
示例15: timelineFragment
/**
* Returns an HTML fragment used to display this issue in the
* timeline.
*
* The request object is given to be able to check the rights and
* as such create links to other items etc. You can consider that
* if displayed, you can create a link to it.
*
* @param Pluf_HTTP_Request
* @return Pluf_Template_SafeString
*/
public function timelineFragment($request)
{
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view', array($request->project->shortname, $this->id));
$out = '<tr class="log"><td><a href="' . $url . '">' . Pluf_esc(Pluf_Template_dateAgo($this->creation_dtime, 'without')) . '</a></td><td>';
$stag = new IDF_Template_ShowUser();
$user = $stag->start($this->get_submitter(), $request, '', false);
$ic = in_array($this->status, $request->project->getTagIdsByStatus('closed')) ? 'issue-c' : 'issue-o';
$out .= sprintf(__('<a href="%1$s" class="%2$s" title="View issue">Issue %3$d</a>, %4$s'), $url, $ic, $this->id, Pluf_esc($this->summary)) . '</td>';
$out .= "\n" . '<tr class="extra"><td colspan="2">
<div class="helptext right">' . sprintf(__('Creation of <a href="%s" class="%s">issue %d</a>, by %s'), $url, $ic, $this->id, $user) . '</div></td></tr>';
return Pluf_Template::markSafe($out);
}