本文整理汇总了PHP中p类的典型用法代码示例。如果您正苦于以下问题:PHP p类的具体用法?PHP p怎么用?PHP p使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了p类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
开发者ID:hiwilson,项目名称:gallery3,代码行数:26,代码来源:comment_rss.php
示例2: _send_reset
private function _send_reset()
{
$form = $this->_reset_form();
$valid = $form->validate();
if ($valid) {
$user = ORM::factory("user")->where("name", $form->reset->inputs["name"]->value)->find();
if (!$user->loaded || empty($user->email)) {
$form->reset->inputs["name"]->add_error("no_email", 1);
$valid = false;
}
}
if ($valid) {
$user->hash = md5(rand());
$user->save();
$message = new View("reset_password.html");
$message->confirm_url = url::abs_site("password/do_reset?key={$user->hash}");
$message->user = $user;
Sendmail::factory()->to($user->email)->subject(t("Password Reset Request"))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=iso-8859-1")->message($message->render())->send();
log::success("user", t("Password reset email sent for user %name", array("name" => p::clean($user->name))));
} else {
// Don't include the username here until you're sure that it's XSS safe
log::warning("user", "Password reset email requested for bogus user");
}
message::success(t("Password reset email sent"));
print json_encode(array("result" => "success"));
}
开发者ID:hiwilson,项目名称:gallery3,代码行数:26,代码来源:password.php
示例3: _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_photo->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_photo->filename->value)->count_records()) {
$form->edit_photo->filename->add_error("conflict", 1);
$valid = false;
}
}
}
if ($valid) {
$photo->title = $form->edit_photo->title->value;
$photo->description = $form->edit_photo->description->value;
$photo->rename($form->edit_photo->filename->value);
$photo->save();
module::event("photo_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" => p::clean($photo->title))));
print json_encode(array("result" => "success", "location" => url::site("photos/{$photo->id}")));
} else {
print json_encode(array("result" => "error", "form" => $form->__toString()));
}
}
开发者ID:hiwilson,项目名称:gallery3,代码行数:31,代码来源:photos.php
示例4: header
function header($item_id)
{
$item = ORM::factory("item", $item_id);
access::required("view", $item);
access::required("edit", $item);
print json_encode(array("title" => p::clean($item->title), "description" => empty($item->description) ? "" : p::clean($item->description)));
}
开发者ID:krgeek,项目名称:gallery3,代码行数:7,代码来源:organize.php
示例5: save
public function save($module_name, $var_name)
{
access::verify_csrf();
module::set_var($module_name, $var_name, Input::instance()->post("value"));
message::success(t("Saved value for %var (%module_name)", array("var" => p::clean($var_name), "module_name" => $module_name)));
print json_encode(array("result" => "success"));
}
开发者ID:hiwilson,项目名称:gallery3,代码行数:7,代码来源:admin_advanced_settings.php
示例6: 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());
}
}
开发者ID:hiwilson,项目名称:gallery3,代码行数:33,代码来源:exif_task.php
示例7: available_feeds
static function available_feeds($item, $tag)
{
$feeds["comment/newest"] = t("All new comments");
if ($item) {
$feeds["comment/item/{$item->id}"] = t("Comments on %title", array("title" => p::clean($item->title)));
}
return $feeds;
}
开发者ID:ascseb,项目名称:gallery3,代码行数:8,代码来源:comment_rss.php
示例8: available_feeds
static function available_feeds($item, $tag) {
if ($tag) {
$feeds["tag/tag/{$tag->id}"] =
t("Tag feed for %tag_name", array("tag_name" => p::clean($tag->name)));
return $feeds;
}
return array();
}
开发者ID:HelixiR,项目名称:gallery3,代码行数:8,代码来源:tag_rss.php
示例9: ps
public function ps()
{
var_dump($this);
echo '<br/>';
echo 'c:p:ps<br/>';
p::s();
echo 'from parent<br/>';
parent::s();
echo 'this->pd()<br/>';
$this->pd();
}
开发者ID:nicelxm,项目名称:about_php,代码行数:11,代码来源:this.php
示例10: remove_path
public function remove_path()
{
access::verify_csrf();
$path = $this->input->get("path");
$paths = unserialize(module::get_var("server_add", "authorized_paths"));
if (isset($paths[$path])) {
unset($paths[$path]);
message::success(t("Removed path %path", array("path" => p::clean($path))));
module::set_var("server_add", "authorized_paths", serialize($paths));
server_add::check_config($paths);
}
url::redirect("admin/server_add");
}
开发者ID:hiwilson,项目名称:gallery3,代码行数:13,代码来源:admin_server_add.php
示例11: 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);
}
开发者ID:hiwilson,项目名称:gallery3,代码行数:54,代码来源:gallery_task.php
示例12: index
public function index()
{
access::verify_csrf();
$user = user::active();
user::logout();
log::info("user", t("User %name logged out", array("name" => p::clean($user->name))), html::anchor("user/{$user->id}", p::clean($user->name)));
if ($this->input->get("continue")) {
$item = url::get_item_from_uri($this->input->get("continue"));
if (access::can("view", $item)) {
url::redirect($this->input->get("continue"));
} else {
url::redirect("");
}
}
}
开发者ID:hiwilson,项目名称:gallery3,代码行数:15,代码来源:logout.php
示例13: index
public function index()
{
//access::verify_csrf();
$user = user::active();
user::logout();
log::info("user", t("User %name logged out", array("name" => p::clean($user->name))), html::anchor("user/{$user->id}", p::clean($user->name)));
if ($continue_url = $this->input->get("continue")) {
$item = url::get_item_from_uri($continue_url);
if (access::can("view", $item)) {
// Don't use url::redirect() because it'll call url::site() and munge the continue url.
header("Location: {$continue_url}");
} else {
url::redirect("albums/1");
}
}
}
开发者ID:jasonhight,项目名称:gallery3,代码行数:16,代码来源:logout.php
示例14: 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)));
}
开发者ID:hiwilson,项目名称:gallery3,代码行数:18,代码来源:search.php
示例15: 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;
}
开发者ID:hiwilson,项目名称:gallery3,代码行数:20,代码来源:digibug.php
示例16: _auth
private function _auth($url)
{
$form = user::get_login_form($url);
$valid = $form->validate();
if ($valid) {
$user = ORM::factory("user")->where("name", $form->login->inputs["name"]->value)->find();
if (!$user->loaded || !user::is_correct_password($user, $form->login->password->value)) {
log::warning("user", t("Failed login for %name", array("name" => p::clean($form->login->inputs["name"]->value))));
$form->login->inputs["name"]->add_error("invalid_login", 1);
$valid = false;
}
}
if ($valid) {
user::login($user);
log::info("user", t("User %name logged in", array("name" => p::clean($user->name))));
}
// Either way, regenerate the session id to avoid session trapping
Session::instance()->regenerate();
return array($valid, $form);
}
开发者ID:hiwilson,项目名称:gallery3,代码行数:20,代码来源:login.php
示例17: 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;
}
}
开发者ID:jhilden,项目名称:gallery3,代码行数:22,代码来源:gallery_rss.php
示例18: 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);
开发者ID:hiwilson,项目名称:gallery3,代码行数:31,代码来源:item_deleted.html.php
示例19:
" class="gThumbnail"
alt="photo" src="<?php
echo $child->thumb_url();
?>
"
width="<?php
echo $child->thumb_width;
?>
"
height="<?php
echo $child->thumb_height;
?>
" />
</a>
<h2><?php
echo p::purify($child->title);
?>
</h2>
<?php
echo $theme->thumb_bottom($child);
?>
<ul class="gMetadata">
<?php
echo $theme->thumb_info($child);
?>
</ul>
</li>
<? endforeach ?>
</ul>
<?php
echo $theme->dynamic_bottom();
开发者ID:hiwilson,项目名称:gallery3,代码行数:31,代码来源:dynamic.html.php
示例20: 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)));
}
开发者ID:hiwilson,项目名称:gallery3,代码行数:30,代码来源:g2_import.php
注:本文中的p类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论