本文整理汇总了PHP中photo类的典型用法代码示例。如果您正苦于以下问题:PHP photo类的具体用法?PHP photo怎么用?PHP photo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了photo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: removeimage
function removeimage($id)
{
$sql = "delete from `rentorhire_images` where photo_id='" . $id . "'";
$result = $this->mysql->query($sql);
$ph = new photo();
$ph->deletePhoto($id);
}
开发者ID:sknlim,项目名称:classified-2,代码行数:7,代码来源:rentorhire.class.php
示例2: slideshow
public function slideshow()
{
expHistory::set('viewable', $this->params);
$where = $this->aggregateWhereClause();
$order = 'rank';
$s = new photo();
$slides = $s->find('all', $where, $order);
assign_to_template(array('slides' => $slides));
}
开发者ID:notzen,项目名称:exponent-cms,代码行数:9,代码来源:photosController.php
示例3: _create_random_item
private static function _create_random_item($root = null, $rand = null)
{
$root = $root ? $root : ORM::factory("item", 1);
$rand = $rand ? $rand : rand();
$item = photo::create($root, MODPATH . "gallery/tests/test.jpg", "{$rand}.jpg", $rand, $rand);
return $item;
}
开发者ID:ChrisRut,项目名称:gallery3,代码行数:7,代码来源:Item_Model_Test.php
示例4: create
/**
* 注册内部管理账户
*
* @access public
* @param string phoneNum 手机号
* @param string password 登陆密码md5
* @return array
*/
public function create()
{
#参数检查
$this->params = $this->require_params(array('phoneNum', 'password'));
$this->params['nickname'] = F::request('nickname', '');
$this->params['project'] = F::request('project', '');
$this->params['project'] = str_replace(',', ',', $this->params['project']);
if (!FValidator::phone($this->params['phoneNum'])) {
throw new Exception('手机号格式非法', 100);
}
#检查手机是否已经注册
$userId = $this->userModel->getUserIdByUsername($this->params['phoneNum']);
if (!$userId) {
#生成一个新的账户
$userId = $this->userModel->create($this->params['phoneNum'], $this->params['password'], self::ADMIN_ACCOUNT);
} else {
#更新账户密码信息
$updateResult = $this->userModel->updatePassword($userId, $this->params['password']);
}
#保存图片信息
$filePath = 'avatar/' . $userId . '_' . md5_file($_FILES['photo']['tmp_name']) . '.' . end(explode('.', $_FILES['photo']['name']));
$this->photoTool->copyImageWithSize($_FILES['photo']['tmp_name'], self::IMG_PATH_BASE . $filePath, 60, 60);
$this->params['photo'] = $filePath;
#更新用户昵称
$this->userModel->updateUserProfile($userId, $this->params['nickname'], $filePath);
#授权相关项目授权
$this->userModel->getProjectAuth($userId, explode(',', $this->params['project']));
#跳转回user_add页面
header('location:http://' . $_SERVER['HTTP_HOST'] . '/' . self::CRM_ADMIN_BASE . 'user_add.php');
}
开发者ID:NASH-WORK,项目名称:NASH-CRM,代码行数:38,代码来源:user_controller.php
示例5: add_photo
public function add_photo($id)
{
$album = ORM::factory("item", $id);
access::required("view", $album);
access::required("add", $album);
access::verify_csrf();
$file_validation = new Validation($_FILES);
$file_validation->add_rules("Filedata", "upload::valid", "upload::type[gif,jpg,png,flv,mp4]");
if ($file_validation->validate()) {
// SimpleUploader.swf does not yet call /start directly, so simulate it here for now.
if (!batch::in_progress()) {
batch::start();
}
$temp_filename = upload::save("Filedata");
try {
$name = substr(basename($temp_filename), 10);
// Skip unique identifier Kohana adds
$title = item::convert_filename_to_title($name);
$path_info = pathinfo($temp_filename);
if (array_key_exists("extension", $path_info) && in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) {
$movie = movie::create($album, $temp_filename, $name, $title);
log::success("content", t("Added a movie"), html::anchor("movies/{$movie->id}", t("view movie")));
} else {
$photo = photo::create($album, $temp_filename, $name, $title);
log::success("content", t("Added a photo"), html::anchor("photos/{$photo->id}", t("view photo")));
}
} catch (Exception $e) {
unlink($temp_filename);
throw $e;
}
unlink($temp_filename);
}
print "File Received";
}
开发者ID:krgeek,项目名称:gallery3,代码行数:34,代码来源:simple_uploader.php
示例6: form_edit
public function form_edit($photo_id)
{
$photo = ORM::factory("item", $photo_id);
access::required("view", $photo);
access::required("edit", $photo);
print photo::get_edit_form($photo);
}
开发者ID:JasonWiki,项目名称:docs,代码行数:7,代码来源:photos.php
示例7: exif_extract_test
public function exif_extract_test()
{
$rand = rand();
$root = ORM::factory("item", 1);
$photo = photo::create($root, MODPATH . "exif/tests/data/image.jpg", "{$rand}.jpg", $rand, $rand);
$expected = array(array("caption" => "Camera Maker", "value" => "Pentax Corporation"), array("caption" => "Camera Model", "value" => "PENTAX K10D"), array("caption" => "Aperture", "value" => "f/2.8"), array("caption" => "Color Space", "value" => "Uncalibrated"), array("caption" => "Exposure Value", "value" => "4294.67 EV"), array("caption" => "Exposure Program", "value" => "Program"), array("caption" => "Exposure Time", "value" => "1/60 sec"), array("caption" => "Flash", "value" => "No Flash"), array("caption" => "Focal Length", "value" => "50 mm"), array("caption" => "ISO", "value" => "6553700"), array("caption" => "Metering Mode", "value" => "Multi-Segment"), array("caption" => "Date/Time", "value" => "2008:03:17 17:41:25"), array("caption" => "Copyright", "value" => "(C) 2008 - T. Almdal"), array("caption" => "Orientation", "value" => "1: Normal (0 deg)"), array("caption" => "Resolution Unit", "value" => "Inch"), array("caption" => "X Resolution", "value" => "240 dots per ResolutionUnit"), array("caption" => "Y Resolution", "value" => "240 dots per ResolutionUnit"), array("caption" => "Brightness Value", "value" => "0"), array("caption" => "Scene Type", "value" => "0"), array("caption" => "Subject Distance", "value" => "0"));
$this->assert_equal($expected, exif::get($photo));
}
开发者ID:hiwilson,项目名称:gallery3,代码行数:8,代码来源:Exif_Test.php
示例8: saveProfile
function saveProfile($verify)
{
$sim = new simulator();
$handle = fopen("php://stdin", "r");
$pic = new photo();
$clr = new color();
echo "Enter Header Picture";
$this->temp = $pic->returnPhoto($verify);
$size = count($this->temp);
for ($x = 0; $x <= $size - 1; $x++) {
echo $x . " " . $this->temp[$x] . "\n";
}
echo "Press Number to add photo";
$pho = fgets($handle);
$photo = "Header Picture: " . $this->temp[1];
echo "Enter Profile Picture";
for ($x = 0; $x <= $size - 1; $x++) {
echo $x . " " . $this->temp[$x] . "\n";
}
$ppho = fgets($handle);
$pPhoto = "Profile Picture:" . $this->temp[1];
echo "Enter Full Name";
$full_name = fgets($handle);
echo "Enter Bio";
$bio = fgets($handle);
echo "Enter Location";
$location = fgets($handle);
echo "Enter Website";
$website = fgets($handle);
echo "Enter DOB ";
$dob = fgets($handle);
echo "Enter Theme Color";
$clrs = $clr->returnColors();
for ($x = 0; $x <= $size - 1; $x++) {
echo $x . " " . $clrs[$x] . "\n";
}
$t = fgets($handle);
$theme_color = $clrs[1];
$myfile = fopen("{$verify}" . "profile", "w") or die("Unable to open file!");
fwrite($myfile, $photo . "\n" . $pPhoto . "\n" . $full_name . $bio . $location . $website . $dob . $theme_color);
echo "Profile Made";
$sim->followUp($verify);
}
开发者ID:shahmeerarshad,项目名称:Boot_Camp,代码行数:43,代码来源:profile.php
示例9: get_file_metadata_with_valid_extension_but_illegal_file_contents_test
public function get_file_metadata_with_valid_extension_but_illegal_file_contents_test()
{
copy(MODPATH . "gallery/tests/Photo_Helper_Test.php", TMPPATH . "test_php_with_jpg_extension.jpg");
try {
$metadata = photo::get_file_metadata(TMPPATH . "test_php_with_jpg_extension.jpg");
$this->assert_true(false, "Shouldn't get here");
} catch (Exception $e) {
// pass
}
unlink(TMPPATH . "test_php_with_jpg_extension.jpg");
}
开发者ID:HarriLu,项目名称:gallery3,代码行数:11,代码来源:Photo_Helper_Test.php
示例10: add_from_server
static function add_from_server($task)
{
$context = unserialize($task->context);
try {
$paths = array_keys(unserialize(module::get_var("server_add", "authorized_paths")));
$path = $paths[$context["next_path"]];
if (!empty($context["files"][$path])) {
$file = $context["files"][$path][$context["position"]];
$parent = ORM::factory("item", $file["parent_id"]);
access::required("server_add", $parent);
access::required("add", $parent);
if (!$parent->is_album()) {
throw new Exception("@todo BAD_ALBUM");
}
$name = $file["name"];
if ($file["type"] == "album") {
$album = ORM::factory("item")->where("name", $name)->where("parent_id", $parent->id)->find();
if (!$album->loaded) {
$album = album::create($parent, $name, $name, null, user::active()->id);
}
// Now that we have a new album. Go through the remaining files to import and change the
// parent_id of any file that has the same relative path as this album's path.
$album_path = "{$file['path']}/{$name}";
for ($idx = $context["position"] + 1; $idx < count($context["files"][$path]); $idx++) {
if (strpos($context["files"][$path][$idx]["path"], $album_path) === 0) {
$context["files"][$path][$idx]["parent_id"] = $album->id;
}
}
} else {
$extension = strtolower(substr(strrchr($name, '.'), 1));
$source_path = "{$path}{$file['path']}/{$name}";
if (in_array($extension, array("flv", "mp4"))) {
$movie = movie::create($parent, $source_path, $name, $name, null, user::active()->id);
} else {
$photo = photo::create($parent, $source_path, $name, $name, null, user::active()->id);
}
}
$context["counter"]++;
if (++$context["position"] >= count($context["files"][$path])) {
$context["next_path"]++;
$context["position"] = 0;
}
} else {
$context["next_path"]++;
}
} catch (Exception $e) {
$context["errors"][$path] = $e->getMessage();
}
$task->context = serialize($context);
$task->state = "success";
$task->percent_complete = $context["counter"] / (double) $context["total"] * 100;
$task->done = $context["counter"] == (double) $context["total"];
}
开发者ID:xafr,项目名称:gallery3,代码行数:53,代码来源:server_add_task.php
示例11: tweetInput
function tweetInput($verify)
{
$pic = new photo();
$twt = new tweet();
$dbh = new dbHandler();
$handle = fopen("php://stdin", "r");
echo "Write your Tweet\n ";
$tweet = fgets($handle);
$text = " Tweet: " . $tweet;
echo "Write Location";
$loc = fgets($handle);
$location = "Location: " . $loc;
echo "Enter Photo\n";
$this->pic_array = $pic->returnPhoto($verify);
$size = count($this->pic_array);
for ($x = 0; $x <= $size - 1; $x++) {
echo $x . " " . $this->pic_array[$x] . "\n";
}
$pho = fgets($handle);
$photo = "Picture: " . $this->pic_array[1];
$twt->post_tweet($verify, $text, $location, $photo);
}
开发者ID:shahmeerarshad,项目名称:Boot_Camp,代码行数:22,代码来源:simulator.php
示例12: setup
public function setup()
{
$this->_server = $_SERVER;
$root = ORM::factory("item", 1);
$this->_album = album::create($root, rand(), "test album");
access::deny(identity::everybody(), "view_full", $this->_album);
access::deny(identity::registered_users(), "view_full", $this->_album);
$rand = rand();
$this->_item = photo::create($this->_album, MODPATH . "gallery/tests/test.jpg", "{$rand}.jpg", $rand, $rand);
$this->_proxy = ORM::factory("digibug_proxy");
$this->_proxy->uuid = md5(rand());
$this->_proxy->item_id = $this->_item->id;
$this->_proxy->save();
}
开发者ID:viosca,项目名称:gallery3,代码行数:14,代码来源:Digibug_Controller_Test.php
示例13: item_before_create
static function item_before_create($item)
{
$max_size = module::get_var("max_size", "max_size", 600);
if ($item->is_photo()) {
list($width, $height, $mime_type) = photo::get_file_metadata($item->data_file);
if ($width > $max_size || $height > $max_size) {
$tempnam = tempnam(TMPPATH, "size");
$tmpfile = $tempnam . "." . pathinfo($item->data_file, PATHINFO_EXTENSION);
gallery_graphics::resize($item->data_file, $tmpfile, array("width" => $max_size, "height" => $max_size, "master" => Image::AUTO));
rename($tmpfile, $item->data_file);
unlink($tempnam);
}
}
}
开发者ID:Retroguy,项目名称:gallery3-contrib,代码行数:14,代码来源:max_size_event.php
示例14: add_photo
public function add_photo($id)
{
$album = ORM::factory("item", $id);
access::required("view", $album);
access::required("add", $album);
access::verify_csrf();
$file_validation = new Validation($_FILES);
$file_validation->add_rules("Filedata", "upload::valid", "upload::required", "upload::type[gif,jpg,jpeg,png,flv,mp4]");
if ($file_validation->validate()) {
// SimpleUploader.swf does not yet call /start directly, so simulate it here for now.
if (!batch::in_progress()) {
batch::start();
}
$temp_filename = upload::save("Filedata");
try {
$name = substr(basename($temp_filename), 10);
// Skip unique identifier Kohana adds
$title = item::convert_filename_to_title($name);
$path_info = @pathinfo($temp_filename);
if (array_key_exists("extension", $path_info) && in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) {
$item = movie::create($album, $temp_filename, $name, $title);
log::success("content", t("Added a movie"), html::anchor("movies/{$item->id}", t("view movie")));
} else {
$item = photo::create($album, $temp_filename, $name, $title);
log::success("content", t("Added a photo"), html::anchor("photos/{$item->id}", t("view photo")));
}
// We currently have no way of showing errors if validation fails, so only call our event
// handlers if validation passes.
$form = $this->_get_add_form($album);
if ($form->validate()) {
module::event("add_photos_form_completed", $item, $form);
}
} catch (Exception $e) {
Kohana_Log::add("alert", $e->__toString());
if (file_exists($temp_filename)) {
unlink($temp_filename);
}
header("HTTP/1.1 500 Internal Server Error");
print "ERROR: " . $e->getMessage();
return;
}
unlink($temp_filename);
print "FILEID: {$item->id}";
} else {
header("HTTP/1.1 400 Bad Request");
print "ERROR: " . t("Invalid Upload");
}
}
开发者ID:viosca,项目名称:gallery3,代码行数:48,代码来源:simple_uploader.php
示例15: change_photo_no_csrf_fails_test
public function change_photo_no_csrf_fails_test()
{
$controller = new Photos_Controller();
$root = ORM::factory("item", 1);
$this->_photo = photo::create($root, MODPATH . "gallery/tests/test.jpg", "test", "test", "test");
$_POST["name"] = "new name";
$_POST["title"] = "new title";
$_POST["description"] = "new description";
access::allow(group::everybody(), "edit", $root);
try {
$controller->_update($this->_photo);
$this->assert_true(false, "This should fail");
} catch (Exception $e) {
// pass
}
}
开发者ID:krgeek,项目名称:gallery3,代码行数:16,代码来源:Photos_Controller_Test.php
示例16: generate_album_cover_from_png_test
public function generate_album_cover_from_png_test()
{
$input_file = MODPATH . "gallery/tests/test.jpg";
$output_file = TMPPATH . test::random_name() . ".png";
gallery_graphics::resize($input_file, $output_file, null, null);
$album = test::random_album();
$photo = test::random_photo_unsaved($album);
$photo->set_data_file($output_file);
$photo->name = "album_cover_from_png.png";
$photo->save();
$album->reload();
// Check that the image was correctly resized and converted to jpg
$this->assert_equal(array(200, 150, "image/jpeg", "jpg"), photo::get_file_metadata($album->thumb_path()));
// Check that the items table got updated
$this->assert_equal(array(200, 150), array($album->thumb_width, $album->thumb_height));
// Check that the image is not marked dirty
$this->assert_equal(0, $album->thumb_dirty);
}
开发者ID:HarriLu,项目名称:gallery3,代码行数:18,代码来源:Graphics_Helper_Test.php
示例17: t
echo $item->url();
?>
">
<?php
if ($item->has_thumb()) {
?>
<img src="<?php
echo $item->thumb_url();
?>
"
alt="<?php
echo html::purify($item->title)->for_html_attr();
?>
"
<?php
echo photo::img_dimensions($item->thumb_width, $item->thumb_height, 75);
?>
/>
<?php
} else {
?>
<?php
echo t("No thumbnail");
?>
<?php
}
?>
</a>
</div>
</div>
<p><?php
开发者ID:estebandito,项目名称:gallery3,代码行数:31,代码来源:admin_comments.html.php
示例18: resize_jpg_to_png_without_options_test
public function resize_jpg_to_png_without_options_test()
{
// Input is a 1024x768 jpg, output is png without options - should not attempt resize
$input_file = MODPATH . "gallery/tests/test.jpg";
$output_file = TMPPATH . test::random_name() . ".png";
gallery_graphics::resize($input_file, $output_file, null, null);
// Output is converted from input without resize
$this->assert_equal(array(1024, 768, "image/png", "png"), photo::get_file_metadata($output_file));
}
开发者ID:HarriLu,项目名称:gallery3,代码行数:9,代码来源:Gallery_Graphics_Helper_Test.php
示例19: header
} else {
header("Location: ../views/signinPage.php?message=" . urlencode("Login again!"));
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php
require_once "engine.php";
require_once "../models/user.php";
require_once "../models/photo.php";
require_once "../models/album.php";
require_once "../models/DataAccessHelper.php";
echo $includes;
$imgsrc = array();
$rs = photo::getImageusername($temp['username']);
foreach ($rs as $row) {
$imgsrc[] = 'data:image/jpg;base64,' . base64_encode($row['imageFile']);
}
?>
<title>
PhotoShare
</title>
</head>
<script>
</script>
<body>
<?php
echo $navbar;
开发者ID:annjanu,项目名称:PhotoShare,代码行数:31,代码来源:allalbums.php
示例20: import_item
/**
* Import a single photo or movie.
*/
static function import_item(&$queue)
{
$g2_item_id = array_shift($queue);
if (self::map($g2_item_id)) {
return t("Item with id: %id already imported, skipping", array("id" => $g2_item_id));
}
try {
self::$current_g2_item = $g2_item = g2(GalleryCoreApi::loadEntitiesById($g2_item_id));
$g2_path = g2($g2_item->fetchPath());
} catch (Exception $e) {
return t("Failed to import Gallery 2 item with id: %id\n%exception", array("id" => $g2_item_id, "exception" => $e->__toString()));
}
$parent = ORM::factory("item", self::map($g2_item->getParentId()));
$g2_type = $g2_item->getEntityType();
$corrupt = 0;
if (!file_exists($g2_path)) {
// If the Gallery 2 source image isn't available, this operation is going to fail. That can
// happen in cases where there's corruption in the source Gallery 2. In that case, fall
// back on using a broken image. It's important that we import *something* otherwise
// anything that refers to this item in Gallery 2 will have a dangling pointer in Gallery 3
//
// Note that this will change movies to be photos, if there's a broken movie. Hopefully
// this case is rare enough that we don't need to take any heroic action here.
g2_import::log(t("%path missing in import; replacing it with a placeholder", array("path" => $g2_path)));
$g2_path = MODPATH . "g2_import/data/broken-image.gif";
$g2_type = "GalleryPhotoItem";
$corrupt = 1;
}
$message = array();
switch ($g2_type) {
case "GalleryPhotoItem":
if (!in_array($g2_item->getMimeType(), array("image/jpeg", "image/gif", "image/png"))) {
Kohana::log("alert", "{$g2_path} is an unsupported image type; using a placeholder gif");
$message[] = t("'%path' is an unsupported image type, using a placeholder", array("path" => $g2_path));
$g2_path = MODPATH . "g2_import/data/broken-image.gif";
$corrupt = 1;
}
try {
$item = photo::create($parent, $g2_path, $g2_item->getPathComponent(), self::_decode_html_special_chars($g2_item->getTitle()), self::_decode_html_special_chars(self::extract_description($g2_item)), self::map($g2_item->getOwnerId()));
} catch (Exception $e) {
Kohana::log("alert", "Corrupt image {$g2_path}\n" . $e->__toString());
$message[] = t("Corrupt image '%path'", array("path" => $g2_path));
$message[] = $e->__toString();
$corrupt = 1;
}
break;
case "GalleryMovieItem":
// @todo we should transcode other types into FLV
if (in_array($g2_item->getMimeType(), array("video/mp4", "video/x-flv"))) {
try {
$item = movie::create($parent, $g2_path, $g2_item->getPathComponent(), self::_decode_html_special_chars($g2_item->getTitle()), self::_decode_html_special_chars(self::extract_description($g2_item)), self::map($g2_item->getOwnerId()));
} catch (Exception $e) {
Kohana::log("alert", "Corrupt movie {$g2_path}\n" . $e->__toString());
$message[] = t("Corrupt movie '%path'", array("path" => $g2_path));
$message[] = $e->__toString();
$corrupt = 1;
}
} else {
Kohana::log("alert", "{$g2_path} is an unsupported movie type");
$message[] = t("'%path' is an unsupported movie type", array("path" => $g2_path));
$corrupt = 1;
}
break;
default:
// Ignore
break;
}
if (!empty($item)) {
self::import_keywords_as_tags($g2_item->getKeywords(), $item);
}
if (isset($item)) {
self::set_map($g2_item_id, $item->id);
$item->view_count = g2(GalleryCoreApi::fetchItemViewCount($g2_item_id));
$item->save();
}
if ($corrupt) {
$url_generator = $GLOBALS["gallery"]->getUrlGenerator();
// @todo we need a more persistent warning
$g2_item_url = $url_generator->generateUrl(array("itemId" => $g2_item->getId()));
// Why oh why did I ever approve the session id placeholder idea in G2?
$g2_item_url = str_replace('&g2_GALLERYSID=TMP_SESSION_ID_DI_NOISSES_PMT', '', $g2_item_url);
if (!empty($item)) {
$message[] = t("<a href=\"%g2_url\">%title</a> from Gallery 2 could not be processed; " . "(imported as <a href=\"%g3_url\">%title</a>)", array("g2_url" => $g2_item_url, "g3_url" => $item->url(), "title" => $g2_item->getTitle()));
} else {
$message[] = t("<a href=\"%g2_url\">%title</a> from Gallery 2 could not be processed", array("g2_url" => $g2_item_url, "title" => $g2_item->getTitle()));
}
}
self::$current_g2_item = null;
return $message;
}
开发者ID:hiwilson,项目名称:gallery3,代码行数:93,代码来源:g2_import.php
注:本文中的photo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论