本文整理汇总了PHP中p::purify方法的典型用法代码示例。如果您正苦于以下问题:PHP p::purify方法的具体用法?PHP p::purify怎么用?PHP p::purify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类p
的用法示例。
在下文中一共展示了p::purify方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: feed
static function feed($feed_id, $offset, $limit, $id)
{
if ($feed_id != "newest" && $feed_id != "item") {
return;
}
$comments = ORM::factory("comment")->where("state", "published")->orderby("created", "DESC");
$all_comments = ORM::factory("comment")->where("state", "published")->orderby("created", "DESC");
if ($feed_id == "item") {
$comments->where("item_id", $id);
$all_comments->where("item_id", $id);
}
if (!empty($comments)) {
$feed->view = "comment.mrss";
$comments = $comments->find_all($limit, $offset);
$feed->children = array();
foreach ($comments as $comment) {
$item = $comment->item();
$feed->children[] = new ArrayObject(array("pub_date" => date("D, d M Y H:i:s T", $comment->created), "text" => nl2br(p::purify($comment->text)), "thumb_url" => $item->thumb_url(), "thumb_height" => $item->thumb_height, "thumb_width" => $item->thumb_width, "item_uri" => url::abs_site("{$item->type}s/{$item->id}"), "title" => p::purify($item->title), "author" => p::clean($comment->author_name())), ArrayObject::ARRAY_AS_PROPS);
}
$feed->max_pages = ceil($all_comments->find_all()->count() / $limit);
$feed->title = htmlspecialchars(t("Recent Comments"));
$feed->uri = url::abs_site("albums/" . (empty($id) ? "1" : $id));
$feed->description = t("Recent Comments");
return $feed;
}
}
示例2: update_index
static function update_index($task)
{
try {
$completed = $task->get("completed", 0);
$start = microtime(true);
$message = array();
foreach (ORM::factory("item")->join("exif_records", "items.id", "exif_records.item_id", "left")->where("type", "photo")->open_paren()->where("exif_records.item_id", null)->orwhere("exif_records.dirty", 1)->close_paren()->find_all() as $item) {
if (microtime(true) - $start > 1.5) {
break;
}
$completed++;
exif::extract($item);
$message[] = t("Updated Exif meta data for '%title'", array("title" => p::purify($item->title)));
}
$task->log($message);
list($remaining, $total, $percent) = exif::stats();
$task->set("completed", $completed);
if ($remaining == 0 || !($remaining + $completed)) {
$task->done = true;
$task->state = "success";
site_status::clear("exif_index_out_of_date");
$task->percent_complete = 100;
} else {
$task->percent_complete = round(100 * $completed / ($remaining + $completed));
}
$task->status = t2("one record updated, index is %percent% up-to-date", "%count records updated, index is %percent% up-to-date", $completed, array("percent" => $percent));
} catch (Exception $e) {
$task->done = true;
$task->state = "error";
$task->status = $e->getMessage();
$task->log($e->__toString());
}
}
示例3: rebuild_dirty_images
/**
* Task that rebuilds all dirty images.
* @param Task_Model the task
*/
static function rebuild_dirty_images($task)
{
$message = array();
try {
$result = graphics::find_dirty_images_query();
$completed = $task->get("completed", 0);
$ignored = $task->get("ignored", array());
$remaining = $result->count() - count($ignored);
$i = 0;
foreach ($result as $row) {
if (array_key_exists($row->id, $ignored)) {
continue;
}
$item = ORM::factory("item", $row->id);
if ($item->loaded) {
$success = graphics::generate($item);
if (!$success) {
$ignored[$item->id] = 1;
$message[] = t("Unable to rebuild images for '%title'", array("title" => p::purify($item->title)));
} else {
$message[] = t("Successfully rebuilt images for '%title'", array("title" => p::purify($item->title)));
}
}
$completed++;
$remaining--;
if (++$i == 2) {
break;
}
}
$task->status = t2("Updated: 1 image. Total: %total_count.", "Updated: %count images. Total: %total_count.", $completed, array("total_count" => $remaining + $completed));
if ($completed + $remaining > 0) {
$task->percent_complete = (int) (100 * $completed / ($completed + $remaining));
} else {
$task->percent_complete = 100;
}
$task->set("completed", $completed);
$task->set("ignored", $ignored);
if ($remaining == 0) {
$task->done = true;
$task->state = "success";
site_status::clear("graphics_dirty");
}
} catch (Exception $e) {
$task->done = true;
$task->state = "error";
$task->status = $e->getMessage();
$message[] = $e->__toString();
}
$task->log($message);
}
示例4: update
static function update($item)
{
$data = array();
$record = ORM::factory("search_record")->where("item_id", $item->id)->find();
if (!$record->loaded) {
$record->item_id = $item->id;
}
foreach (module::active() as $module) {
$class_name = "{$module->name}_search";
if (method_exists($class_name, "item_index_data")) {
$data[] = call_user_func(array($class_name, "item_index_data"), $record->item());
}
}
$record->data = join(" ", $data);
$record->dirty = 0;
$record->save();
return t("Search index updated for '%title'", array("title" => p::purify($item->title)));
}
示例5: print_photo
public function print_photo($id)
{
access::verify_csrf();
$item = ORM::factory("item", $id);
access::required("view_full", $item);
if (access::group_can(group::everybody(), "view_full", $item)) {
$full_url = $item->file_url(true);
$thumb_url = $item->thumb_url(true);
} else {
$proxy = ORM::factory("digibug_proxy");
$proxy->uuid = md5(rand());
$proxy->item_id = $item->id;
$proxy->save();
$full_url = url::abs_site("digibug/print_proxy/full/{$proxy->uuid}");
$thumb_url = url::abs_site("digibug/print_proxy/thumb/{$proxy->uuid}");
}
$v = new View("digibug_form.html");
$v->order_parms = array("digibug_api_version" => "100", "company_id" => module::get_var("digibug", "company_id"), "event_id" => module::get_var("digibug", "event_id"), "cmd" => "addimg", "partner_code" => "69", "return_url" => url::abs_site("digibug/close_window"), "num_images" => "1", "image_1" => $full_url, "thumb_1" => $thumb_url, "image_height_1" => $item->height, "image_width_1" => $item->width, "thumb_height_1" => $item->thumb_height, "thumb_width_1" => $item->thumb_width, "title_1" => p::purify($item->title));
print $v;
}
示例6: feed
static function feed($feed_id, $offset, $limit, $id)
{
switch ($feed_id) {
case "latest":
$feed->children = ORM::factory("item")->viewable()->where("type !=", "album")->orderby("created", "DESC")->find_all($limit, $offset);
$all_children = ORM::factory("item")->viewable()->where("type !=", "album")->orderby("created", "DESC");
$feed->max_pages = ceil($all_children->find_all()->count() / $limit);
$feed->title = t("Recent Updates");
$feed->link = url::abs_site("albums/1");
$feed->description = t("Recent Updates");
return $feed;
case "album":
$item = ORM::factory("item", $id);
access::required("view", $item);
$feed->children = $item->viewable()->descendants($limit, $offset, array("type" => "photo"));
$feed->max_pages = ceil($item->viewable()->descendants_count(array("type" => "photo")) / $limit);
$feed->title = p::purify($item->title);
$feed->link = url::abs_site("albums/{$item->id}");
$feed->description = nl2br(p::purify($item->description));
return $feed;
}
}
示例7: delete
public function delete($id)
{
access::verify_csrf();
$item = model_cache::get("item", $id);
access::required("view", $item);
access::required("edit", $item);
if ($item->is_album()) {
$msg = t("Deleted album <b>%title</b>", array("title" => p::purify($item->title)));
} else {
$msg = t("Deleted photo <b>%title</b>", array("title" => p::purify($item->title)));
}
$parent = $item->parent();
$item->delete();
message::success($msg);
if (Input::instance()->get("page_type") == "album") {
print json_encode(array("result" => "success", "reload" => 1));
} else {
print json_encode(array("result" => "success", "location" => url::site("albums/{$parent->id}")));
}
}
示例8: function
}
download = function(){
// send request
$('<form action="<?php
echo url::site("admin/maintenance/save_log/{$task->id}?csrf={$csrf}");
?>
" method="post"></form>').
appendTo('body').submit().remove();
};
</script>
<div id="gTaskLogDialog">
<h1> <?php
echo $task->name;
?>
</h1>
<div class="gTaskLog">
<pre><?php
echo p::purify($task->get_log());
?>
</pre>
</div>
<button id="gCloseButton" class="ui-state-default ui-corner-all" onclick="dismiss()"><?php
echo t("Close");
?>
</button>
<button id="gSaveButton" class="ui-state-default ui-corner-all" onclick="download()"><?php
echo t("Save");
?>
</button>
</div>
示例9: if
<div id="gSiteMenu" style="display: none">
<?php
echo $theme->site_menu();
?>
</div>
<?php
echo $theme->header_bottom();
?>
<? if (!empty($parents)): ?>
<ul class="gBreadcrumbs">
<? foreach ($parents as $parent): ?>
<li>
<a href="<?php
echo url::site("albums/{$parent->id}?show={$item->id}");
?>
">
<?php
echo p::purify($parent->title);
?>
</a>
</li>
<? endforeach ?>
<li class="active"><?php
echo p::purify($item->title);
?>
</li>
</ul>
<? endif ?>
示例10: nl2br
<author><?php
echo p::clean($child->author);
?>
</author>
<guid isPermaLink="true"><?php
echo $child->item_uri;
?>
</guid>
<pubDate><?php
echo $child->pub_date;
?>
</pubDate>
<content:encoded>
<![CDATA[
<p><?php
echo nl2br(p::purify($child->text));
?>
</p>
<p>
<img alt="" src="<?php
echo $child->thumb_url;
?>
"
height="<?php
echo $child->thumb_height;
?>
" width="<?php
echo $child->thumb_width;
?>
" />
<br />
示例11: defined
<?php
defined("SYSPATH") or die("No direct script access.");
?>
<ul>
<? foreach ($comments as $i => $comment): ?>
<li class="<?php
echo $i % 2 == 0 ? "gEvenRow" : "gOddRow";
?>
">
<img src="<?php
echo $comment->author()->avatar_url(32, $theme->url("images/avatar.jpg", true));
?>
"
class="gAvatar"
alt="<?php
echo p::clean($comment->author_name());
?>
"
width="32"
height="32" />
<?php
echo gallery::date_time($comment->created);
?>
<?php
echo t('<a href="#">%author_name</a> said <em>%comment_text</em>', array("author_name" => p::clean($comment->author_name()), "comment_text" => text::limit_words(nl2br(p::purify($comment->text)), 50)));
?>
</li>
<? endforeach ?>
</ul>
示例12: t
<head>
<title><?php
echo p::clean($subject);
?>
</title>
</head>
<body>
<h2><?php
echo p::clean($subject);
?>
</h2>
<table>
<tr>
<td colspan="2">
<?php
echo t("To view the changed album %title use the link below.", array("title" => p::purify($item->parent()->title)));
?>
</td>
</tr>
<tr>
<td><?php
echo t("Url:");
?>
</td>
<td>
<a href="<?php
echo $item->parent()->url(array(), true);
?>
">
<?php
echo $item->parent()->url(array(), true);
示例13: organize_dialog_init
var csrf = "<?php
echo $csrf;
?>
";
var rearrangeUrl = "<?php
echo url::site("__URI__/__ITEM_ID____TASK_ID__?csrf={$csrf}");
?>
";
$("#doc3").ready(function() {
organize_dialog_init();
});
</script>
<fieldset style="display: none">
<legend><?php
echo t("Organize %name", array("name" => p::purify($item->title)));
?>
</legend>
</fieldset>
<div id="doc3" class="yui-t7">
<div id="bd">
<div class="yui-gf">
<div class="yui-u first">
<h3><?php
echo t("Albums");
?>
</h3>
</div>
<div id="gMessage" class="yui-u">
<div class="gInfo"><?php
echo t("Select one or more items to edit; drag and drop items to re-order or move between albums");
示例14: _show
/**
* Display an existing comment.
* @todo Set proper Content-Type in a central place (REST_Controller::dispatch?).
* @see REST_Controller::_show($resource)
*/
public function _show($comment)
{
$item = ORM::factory("item", $comment->item_id);
access::required("view", $item);
if ($comment->state != "published") {
return;
}
if (rest::output_format() == "json") {
print json_encode(array("result" => "success", "data" => array("id" => $comment->id, "author_name" => p::clean($comment->author_name()), "created" => $comment->created, "text" => nl2br(p::purify($comment->text)))));
} else {
$view = new Theme_View("comment.html", "fragment");
$view->comment = $comment;
print $view;
}
}
示例15: import_comment
/**
* Import a single comment.
*/
static function import_comment(&$queue)
{
$g2_comment_id = array_shift($queue);
try {
$g2_comment = g2(GalleryCoreApi::loadEntitiesById($g2_comment_id));
} catch (Exception $e) {
return t("Failed to import Gallery 2 comment with id: %id\\%exception", array("id" => $g2_comment_id, "exception" => $e->__toString()));
}
$text = $g2_comment->getSubject();
if ($text) {
$text .= " ";
}
$text .= $g2_comment->getComment();
// Just import the fields we know about. Do this outside of the comment API for now so that
// we don't trigger spam filtering events
$comment = ORM::factory("comment");
$comment->author_id = self::map($g2_comment->getCommenterId());
$comment->guest_name = $g2_comment->getAuthor();
$comment->item_id = self::map($g2_comment->getParentId());
$comment->text = self::_transform_bbcode($text);
$comment->state = "published";
$comment->server_http_host = $g2_comment->getHost();
$comment->created = $g2_comment->getDate();
$comment->save();
self::map($g2_comment->getId(), $comment->id);
return t("Imported comment '%comment' for item with id: %id", array("id" => $comment->item_id, "comment" => text::limit_words(nl2br(p::purify($comment->text)), 50)));
}