本文整理汇总了PHP中html::purify方法的典型用法代码示例。如果您正苦于以下问题:PHP html::purify方法的具体用法?PHP html::purify怎么用?PHP html::purify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类html
的用法示例。
在下文中一共展示了html::purify方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: purify_test
public function purify_test()
{
$safe_string = html::purify("hello <p >world</p>");
$expected = method_exists("purifier", "purify") ? "hello <p>world</p>" : "hello <p >world</p>";
$this->assert_equal($expected, $safe_string->unescaped());
$this->assert_true($safe_string instanceof SafeString);
}
示例2: 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" => html::purify($item->title)));
} else {
$msg = t("Deleted photo <b>%title</b>", array("title" => html::purify($item->title)));
}
$parent = $item->parent();
if ($item->is_album()) {
// Album delete will trigger deletes for all children. Do this in a batch so that we can be
// smart about notifications, album cover updates, etc.
batch::start();
$item->delete();
batch::stop();
} else {
$item->delete();
}
message::success($msg);
$from_id = Input::instance()->get("from_id");
if (Input::instance()->get("page_type") == "collection" && $from_id != $id) {
json::reply(array("result" => "success", "reload" => 1));
} else {
json::reply(array("result" => "success", "location" => $parent->url()));
}
}
示例3: save
public function save()
{
access::verify_csrf();
$form = $this->_get_edit_form_admin();
if ($form->validate()) {
module::set_var("gallery", "page_size", $form->edit_theme->page_size->value);
$thumb_size = $form->edit_theme->thumb_size->value;
if (module::get_var("gallery", "thumb_size") != $thumb_size) {
graphics::remove_rule("gallery", "thumb", "gallery_graphics::resize");
graphics::add_rule("gallery", "thumb", "gallery_graphics::resize", array("width" => $thumb_size, "height" => $thumb_size, "master" => Image::AUTO), 100);
module::set_var("gallery", "thumb_size", $thumb_size);
}
$resize_size = $form->edit_theme->resize_size->value;
if (module::get_var("gallery", "resize_size") != $resize_size) {
graphics::remove_rule("gallery", "resize", "gallery_graphics::resize");
graphics::add_rule("gallery", "resize", "gallery_graphics::resize", array("width" => $resize_size, "height" => $resize_size, "master" => Image::AUTO), 100);
module::set_var("gallery", "resize_size", $resize_size);
}
module::set_var("gallery", "show_credits", $form->edit_theme->show_credits->value);
// Sanitize values that get placed directly in HTML output by theme.
module::set_var("gallery", "header_text", html::purify($form->edit_theme->header_text->value));
module::set_var("gallery", "footer_text", html::purify($form->edit_theme->footer_text->value));
module::set_var("gallery", "favicon_url", html::purify($form->edit_theme->favicon_url->value));
module::set_var("gallery", "apple_touch_icon_url", html::purify($form->edit_theme->apple_touch_icon_url->value));
module::event("theme_edit_form_completed", $form);
message::success(t("Updated theme details"));
url::redirect("admin/theme_options");
} else {
$view = new Admin_View("admin.html");
$view->content = new View("admin_theme_options.html");
$view->content->form = $form;
print $view;
}
}
示例4: _update
/**
* @see REST_Controller::_update($resource)
*/
public function _update($photo)
{
access::verify_csrf();
access::required("view", $photo);
access::required("edit", $photo);
$form = photo::get_edit_form($photo);
if ($valid = $form->validate()) {
if ($form->edit_item->filename->value != $photo->name) {
// Make sure that there's not a conflict
if (Database::instance()->from("items")->where("parent_id", $photo->parent_id)->where("id <>", $photo->id)->where("name", $form->edit_item->filename->value)->count_records()) {
$form->edit_item->filename->add_error("conflict", 1);
$valid = false;
}
}
}
if ($valid) {
$photo->title = $form->edit_item->title->value;
$photo->description = $form->edit_item->description->value;
$photo->rename($form->edit_item->filename->value);
$photo->save();
module::event("item_edit_form_completed", $photo, $form);
log::success("content", "Updated photo", "<a href=\"photos/{$photo->id}\">view</a>");
message::success(t("Saved photo %photo_title", array("photo_title" => html::purify($photo->title))));
print json_encode(array("result" => "success"));
} else {
print json_encode(array("result" => "error", "form" => $form->__toString()));
}
}
示例5: show
public function show($page_name)
{
// Display the page specified by $page_name, or a 404 error if it doesn't exist.
// Run a database search to look up the page.
$existing_page = ORM::factory("px_static_page")->where("name", "=", $page_name)->find_all();
// If it doesn't exist, display a 404 error.
if (count($existing_page) == 0) {
throw new Kohana_404_Exception();
}
// Set up breadcrumbs.
$breadcrumbs = array();
$root = item::root();
$breadcrumbs[] = Breadcrumb::instance($root->title, $root->url())->set_first();
$breadcrumbs[] = Breadcrumb::instance(t($existing_page[0]->title), url::site("pages_xtra/show/{$page_name}"))->set_last();
// Display the page.
$template = new Theme_View("page.html", "other", "Pages");
$template->set_global(array("breadcrumbs" => $breadcrumbs));
// Call database variables into page header (off-page content).
$site_title = module::get_var("pages_xtra", "site_title");
// Next line can be used as alternative to the following line
// $template->page_title = t("Gallery :: ") . t($existing_page[0]->title);
$template->page_title = t($existing_page[0]->title) . t(" :: {$site_title}");
$template->page_tags = $existing_page[0]->tags;
$page_tags = trim(nl2br(html::purify($existing_page[0]->tags)));
$template->page_description = $existing_page[0]->description;
$page_description = trim(nl2br(html::purify($existing_page[0]->description)));
// Set a new View and call database variables into page (on-page content).
$template->content = new View("pages_xtra_display.html");
$template->content->title = $existing_page[0]->title;
$template->content->body = $existing_page[0]->html_code;
print $template;
}
示例6: feed
static function feed($feed_id, $offset, $limit, $id)
{
$feed = new stdClass();
switch ($feed_id) {
case "latest":
$feed->items = ORM::factory("item")->viewable()->where("type", "<>", "album")->order_by("created", "DESC")->find_all($limit, $offset);
$all_items = ORM::factory("item")->viewable()->where("type", "<>", "album")->order_by("created", "DESC");
$feed->max_pages = ceil($all_items->find_all()->count() / $limit);
$feed->title = t("%site_title - Recent updates", array("site_title" => item::root()->title));
$feed->description = t("Recent updates");
return $feed;
case "album":
$item = ORM::factory("item", $id);
access::required("view", $item);
$feed->items = $item->viewable()->descendants($limit, $offset, array(array("type", "=", "photo")));
$feed->max_pages = ceil($item->viewable()->descendants_count(array(array("type", "=", "photo"))) / $limit);
if ($item->id == item::root()->id) {
$feed->title = html::purify($item->title);
} else {
$feed->title = t("%site_title - %item_title", array("site_title" => item::root()->title, "item_title" => $item->title));
}
$feed->description = nl2br(html::purify($item->description));
return $feed;
}
}
示例7: rebuild_dirty_images
/**
* Task that rebuilds all dirty images.
* @param Task_Model the task
*/
static function rebuild_dirty_images($task)
{
$errors = array();
try {
$result = graphics::find_dirty_images_query()->select("id")->execute();
$total_count = $task->get("total_count", $result->count());
$mode = $task->get("mode", "init");
if ($mode == "init") {
$task->set("total_count", $total_count);
$task->set("mode", "process");
batch::start();
}
$completed = $task->get("completed", 0);
$ignored = $task->get("ignored", array());
$i = 0;
foreach ($result as $row) {
if (array_key_exists($row->id, $ignored)) {
continue;
}
$item = ORM::factory("item", $row->id);
if ($item->loaded()) {
try {
graphics::generate($item);
$completed++;
$errors[] = t("Successfully rebuilt images for '%title'", array("title" => html::purify($item->title)));
} catch (Exception $e) {
$errors[] = t("Unable to rebuild images for '%title'", array("title" => html::purify($item->title)));
$errors[] = (string) $e;
$ignored[$item->id] = 1;
}
}
if (++$i == 2) {
break;
}
}
$task->status = t2("Updated: 1 image. Total: %total_count.", "Updated: %count images. Total: %total_count.", $completed, array("total_count" => $total_count));
if ($completed < $total_count) {
$task->percent_complete = (int) (100 * ($completed + count($ignored)) / $total_count);
} else {
$task->percent_complete = 100;
}
$task->set("completed", $completed);
$task->set("ignored", $ignored);
if ($task->percent_complete == 100) {
$task->done = true;
$task->state = "success";
batch::stop();
site_status::clear("graphics_dirty");
}
} catch (Exception $e) {
Kohana_Log::add("error", (string) $e);
$task->done = true;
$task->state = "error";
$task->status = $e->getMessage();
$errors[] = (string) $e;
}
if ($errors) {
$task->log($errors);
}
}
示例8: unstar
/**
* Allows the given item to be displayed again.
*
* @param int $id the item id
*/
public function unstar($id)
{
$item = model_cache::get("item", $id);
$msg = t("Un-starred <b>%title</b> item", array("title" => html::purify($item->title)));
$this->_check_star_permissions($item);
star::unstar($item);
message::success($msg);
json::reply(array("result" => "success", "reload" => 1));
}
示例9: show
/**
* Allows the given item to be displayed again.
*
* @param int $id the item id
*/
public function show($id)
{
$item = model_cache::get("item", $id);
$msg = t("Displayed <b>%title</b> item", array("title" => html::purify($item->title)));
$this->_check_hide_permissions($item);
hide::show($item);
message::success($msg);
json::reply(array("result" => "success", "reload" => 1));
}
示例10: label
public function label($val = NULL)
{
if ($val === NULL) {
if ($label = $this->data['label']) {
return html::purify($this->data['label']);
}
} else {
$this->data['label'] = $val === TRUE ? ucwords(inflector::humanize($this->data['name'])) : $val;
return $this;
}
}
示例11: rebuild_dirty_images
/**
* Task that rebuilds all dirty images.
* @param Task_Model the task
*/
static function rebuild_dirty_images($task)
{
$errors = 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) {
try {
graphics::generate($item);
$ignored[$item->id] = 1;
$errors[] = t("Successfully rebuilt images for '%title'", array("title" => html::purify($item->title)));
} catch (Exception $e) {
$errors[] = t("Unable to rebuild images for '%title'", array("title" => html::purify($item->title)));
$errors[] = $e->__toString();
}
}
$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();
$errors[] = $e->__toString();
}
if ($errors) {
$task->log($errors);
}
}
示例12: send
public function send($id)
{
access::verify_csrf();
$user = identity::lookup_user($id);
$form = user_profile::get_contact_form($user);
if ($form->validate()) {
Sendmail::factory()->to($user->email)->subject(html::clean($form->message->subject->value))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=iso-8859-1")->reply_to($form->message->reply_to->value)->message(html::purify($form->message->message->value))->send();
message::success(t("Sent message to %user_name", array("user_name" => $user->display_name())));
print json_encode(array("result" => "success"));
} else {
print json_encode(array("result" => "error", "form" => (string) $form));
}
}
示例13: watch
function watch($id)
{
access::verify_csrf();
$item = ORM::factory("item", $id);
access::required("view", $item);
if (notification::is_watching($item)) {
notification::remove_watch($item);
message::success(sprintf(t("You are no longer watching %s"), html::purify($item->title)));
} else {
notification::add_watch($item);
message::success(sprintf(t("You are now watching %s"), html::purify($item->title)));
}
url::redirect($item->abs_url());
}
示例14: site_menu
static function site_menu($menu, $theme)
{
// Add menu options for Adding / Removing / Using passwords to the menu.
// If this page doesn't belong to an item, don't display the menu.
if (!$theme->item()) {
return;
}
$item = $theme->item();
// If there isn't currently a password stored in the cookie,
// then display the enter password link.
if (cookie::get("g3_albumpassword") == "") {
$menu->append(Menu::factory("dialog")->id("albumpassword_login")->css_id("g-album-password-login")->url(url::site("albumpassword/login"))->label(t("Unlock albums")));
} else {
// If a password has been entered already
// display the log out link, and links to the protected albums
$menu->append(Menu::factory("submenu")->id("albumpassword_protected")->css_id("g-album-password-protected")->label(t("Protected albums")));
$menu->get("albumpassword_protected")->append(Menu::factory("link")->id("albumpassword_logout")->css_id("g-album-password-logout")->url(url::site("albumpassword/logout"))->label(t("Clear password")));
$existing_password = "";
if (cookie::get("g3_albumpassword_id") != "") {
$existing_password = ORM::factory("items_albumpassword")->where("password", "=", cookie::get("g3_albumpassword"))->where("id", "=", cookie::get("g3_albumpassword_id"))->find_all();
} else {
$existing_password = ORM::factory("items_albumpassword")->where("password", "=", cookie::get("g3_albumpassword"))->find_all();
}
if (count($existing_password) > 0) {
$counter = 0;
while ($counter < count($existing_password)) {
$item_album = ORM::factory("item")->where("id", "=", $existing_password[$counter]->album_id)->find();
$menu->get("albumpassword_protected")->append(Menu::factory("link")->id("albumpassword_album" . $counter)->label(html::purify($item_album->title))->css_id("g-album-password-album" . $counter)->url(url::abs_site("{$item_album->type}s/{$item_album->id}")));
$counter++;
}
}
}
// If this is an album without a password, display a link for assigning one.
// If this is an album with a password, display a link to remove it.
if ($item->is_album()) {
if (access::can("view", $item) && access::can("edit", $item)) {
$existing_password = ORM::factory("items_albumpassword")->where("album_id", "=", $item->id)->find_all();
if (count($existing_password) > 0) {
$menu->get("options_menu")->append(Menu::factory("link")->id("albumpassword_remove")->label(t("Remove password"))->css_id("g-album-password-remove")->url(url::site("albumpassword/remove/" . $item->id)));
} elseif ($item->id != 1) {
$passworded_subitems = ORM::factory("item", $item->id)->and_open()->join("albumpassword_idcaches", "items.id", "albumpassword_idcaches.item_id", "LEFT OUTER")->where("albumpassword_idcaches.item_id", "IS NOT", NULL)->close()->descendants();
$existing_cacheditem = ORM::factory("albumpassword_idcache")->where("item_id", "=", $item->id)->order_by("cache_id")->find_all();
if (count($existing_cacheditem) == 0 && count($passworded_subitems) == 0) {
$menu->get("options_menu")->append(Menu::factory("dialog")->id("albumpassword_assign")->label(t("Assign password"))->css_id("g-album-password-assign")->url(url::site("albumpassword/assign/" . $item->id)));
}
}
}
}
}
示例15: send
public function send($id)
{
access::verify_csrf();
$user = identity::lookup_user($id);
if (!$this->_can_view_profile_pages($user)) {
throw new Kohana_404_Exception();
}
$form = user_profile::get_contact_form($user);
if ($form->validate()) {
Sendmail::factory()->to($user->email)->subject(html::clean($form->message->subject->value))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=UTF-8")->reply_to($form->message->reply_to->value)->message(html::purify($form->message->message->value))->send();
message::success(t("Sent message to %user_name", array("user_name" => $user->display_name())));
json::reply(array("result" => "success"));
} else {
json::reply(array("result" => "error", "html" => (string) $form));
}
}