photo editing
This commit is contained in:
parent
edff5b5289
commit
adce88e564
3
boot.php
3
boot.php
|
@ -498,3 +498,6 @@ function expand_acl($s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function sanitise_acl(&$item) {
|
||||||
|
$item = '<' . intval(notags(trim($item))) . '>';
|
||||||
|
}
|
||||||
|
|
|
@ -168,11 +168,12 @@ class Photo {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function store($uid, $cid, $rid, $filename, $album, $scale, $profile = 0) {
|
public function store($uid, $cid, $rid, $filename, $album, $scale,
|
||||||
|
$profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '') {
|
||||||
|
|
||||||
$r = q("INSERT INTO `photo`
|
$r = q("INSERT INTO `photo`
|
||||||
( `uid`, `contact-id`, `resource-id`, `created`, `edited`, `filename`, `album`, `height`, `width`, `data`, `scale`, `profile` )
|
( `uid`, `contact-id`, `resource-id`, `created`, `edited`, `filename`, `album`, `height`, `width`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
|
||||||
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d )",
|
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s' )",
|
||||||
intval($uid),
|
intval($uid),
|
||||||
intval($cid),
|
intval($cid),
|
||||||
dbesc($rid),
|
dbesc($rid),
|
||||||
|
@ -184,7 +185,11 @@ class Photo {
|
||||||
intval($this->width),
|
intval($this->width),
|
||||||
dbesc($this->imageString()),
|
dbesc($this->imageString()),
|
||||||
intval($scale),
|
intval($scale),
|
||||||
intval($profile)
|
intval($profile),
|
||||||
|
dbesc($allow_cid),
|
||||||
|
dbesc($allow_gid),
|
||||||
|
dbesc($deny_cid),
|
||||||
|
dbesc($deny_gid)
|
||||||
);
|
);
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function sanitise_acl(&$item) {
|
|
||||||
$item = '<' . intval(notags(trim($item))) . '>';
|
|
||||||
}
|
|
||||||
|
|
||||||
function item_post(&$a) {
|
function item_post(&$a) {
|
||||||
|
|
||||||
if((! local_user()) && (! remote_user()))
|
if((! local_user()) && (! remote_user()))
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once('Photo.php');
|
require_once('Photo.php');
|
||||||
|
require_once('view/acl_selectors.php');
|
||||||
|
|
||||||
function photos_init(&$a) {
|
function photos_init(&$a) {
|
||||||
|
|
||||||
|
@ -74,6 +75,35 @@ function photos_post(&$a) {
|
||||||
$album = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
|
$album = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$str_group_allow = '';
|
||||||
|
$group_allow = $_POST['group_allow'];
|
||||||
|
if(is_array($group_allow)) {
|
||||||
|
array_walk($group_allow,'sanitise_acl');
|
||||||
|
$str_group_allow = implode('',$group_allow);
|
||||||
|
}
|
||||||
|
|
||||||
|
$str_contact_allow = '';
|
||||||
|
$contact_allow = $_POST['contact_allow'];
|
||||||
|
if(is_array($contact_allow)) {
|
||||||
|
array_walk($contact_allow,'sanitise_acl');
|
||||||
|
$str_contact_allow = implode('',$contact_allow);
|
||||||
|
}
|
||||||
|
|
||||||
|
$str_group_deny = '';
|
||||||
|
$group_deny = $_POST['group_deny'];
|
||||||
|
if(is_array($group_deny)) {
|
||||||
|
array_walk($group_deny,'sanitise_acl');
|
||||||
|
$str_group_deny = implode('',$group_deny);
|
||||||
|
}
|
||||||
|
|
||||||
|
$str_contact_deny = '';
|
||||||
|
$contact_deny = $_POST['contact_deny'];
|
||||||
|
if(is_array($contact_deny)) {
|
||||||
|
array_walk($contact_deny,'sanitise_acl');
|
||||||
|
$str_contact_deny = implode('',$contact_deny);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$src = $_FILES['userfile']['tmp_name'];
|
$src = $_FILES['userfile']['tmp_name'];
|
||||||
$filename = basename($_FILES['userfile']['name']);
|
$filename = basename($_FILES['userfile']['name']);
|
||||||
$filesize = intval($_FILES['userfile']['size']);
|
$filesize = intval($_FILES['userfile']['size']);
|
||||||
|
@ -96,7 +126,7 @@ function photos_post(&$a) {
|
||||||
|
|
||||||
$photo_hash = hash('md5',uniqid(mt_rand(),true));
|
$photo_hash = hash('md5',uniqid(mt_rand(),true));
|
||||||
|
|
||||||
$r = $ph->store($_SESSION['uid'], 0, $photo_hash, $filename, $album, 0 );
|
$r = $ph->store($_SESSION['uid'], 0, $photo_hash, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
|
||||||
|
|
||||||
if(! $r) {
|
if(! $r) {
|
||||||
notice( t('Image upload failed.') . EOL );
|
notice( t('Image upload failed.') . EOL );
|
||||||
|
@ -105,13 +135,13 @@ function photos_post(&$a) {
|
||||||
|
|
||||||
if($width > 640 || $height > 640) {
|
if($width > 640 || $height > 640) {
|
||||||
$ph->scaleImage(640);
|
$ph->scaleImage(640);
|
||||||
$ph->store($_SESSION['uid'], 0, $photo_hash, $filename, $album, 1 );
|
$ph->store($_SESSION['uid'], 0, $photo_hash, $filename, $album, 1, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
|
||||||
$smallest = 1;
|
$smallest = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($width > 320 || $height > 320) {
|
if($width > 320 || $height > 320) {
|
||||||
$ph->scaleImage(320);
|
$ph->scaleImage(320);
|
||||||
$ph->store($_SESSION['uid'], 0, $photo_hash, $filename, $album, 2 );
|
$ph->store($_SESSION['uid'], 0, $photo_hash, $filename, $album, 2, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
|
||||||
$smallest = 2;
|
$smallest = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,6 +322,8 @@ function photos_content(&$a) {
|
||||||
'$existalbumtext' => t('or existing album name: '),
|
'$existalbumtext' => t('or existing album name: '),
|
||||||
'$filestext' => t('Select files to upload: '),
|
'$filestext' => t('Select files to upload: '),
|
||||||
'$albumselect' => $albumselect,
|
'$albumselect' => $albumselect,
|
||||||
|
'$permissions' => t('Permissions'),
|
||||||
|
'$aclselect' => populate_acl(),
|
||||||
'$archive' => $a->get_baseurl() . '/jumploader_z.jar',
|
'$archive' => $a->get_baseurl() . '/jumploader_z.jar',
|
||||||
'$nojava' => t('Use the following controls only if the Java uploader (above) fails to launch.'),
|
'$nojava' => t('Use the following controls only if the Java uploader (above) fails to launch.'),
|
||||||
'$uploadurl' => $a->get_baseurl() . '/photos',
|
'$uploadurl' => $a->get_baseurl() . '/photos',
|
||||||
|
@ -348,7 +380,7 @@ function photos_content(&$a) {
|
||||||
require_once('security.php');
|
require_once('security.php');
|
||||||
require_once('bbcode.php');
|
require_once('bbcode.php');
|
||||||
|
|
||||||
// fetch item containing image, then comments
|
// fetch image, item containing image, then comments
|
||||||
|
|
||||||
$ph = q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'
|
$ph = q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'
|
||||||
$sql_extra ORDER BY `scale` ASC ",
|
$sql_extra ORDER BY `scale` ASC ",
|
||||||
|
@ -421,9 +453,8 @@ function photos_content(&$a) {
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// require_once('view/acl_selectors.php');
|
|
||||||
|
|
||||||
$o .= '<div id="photo-caption" >' . $ph['desc'] . '</div>';
|
$o .= '<div id="photo-caption" >' . $ph[0]['desc'] . '</div>';
|
||||||
|
|
||||||
if(strlen($i1[0]['tag'])) {
|
if(strlen($i1[0]['tag'])) {
|
||||||
// parse tags and add links
|
// parse tags and add links
|
||||||
|
@ -431,6 +462,13 @@ function photos_content(&$a) {
|
||||||
$o .= '<div id="in-this-photo">' . $i1[0]['tag'] . '</div>';
|
$o .= '<div id="in-this-photo">' . $i1[0]['tag'] . '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($cmd == 'edit') {
|
||||||
|
$edit_tpl = file_get_contents('view/photo_edit.tpl');
|
||||||
|
$o .= replace_macros($edit_tpl, array(
|
||||||
|
'$id' => $ph[0]['id']
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
// pull out how many people like the photo
|
// pull out how many people like the photo
|
||||||
|
|
||||||
$cmnt_tpl = file_get_contents('view/comment_item.tpl');
|
$cmnt_tpl = file_get_contents('view/comment_item.tpl');
|
||||||
|
|
11
view/photo_edit.tpl
Normal file
11
view/photo_edit.tpl
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
<form action="photos" method="post" id="photo_edit_form" >
|
||||||
|
|
||||||
|
<label id="photo-edit-caption-label" for="photo-edit-caption">$capt_label</label>
|
||||||
|
<input type="text size="64" name="desc" value="$caption" />
|
||||||
|
|
||||||
|
<label id="photo-edit-tags-label" for="photo-edit-tags-textarea" >$tag_label</label>
|
||||||
|
<textarea name="tags" id="photo-edit-tags-textarea">$tags</textarea>
|
||||||
|
|
||||||
|
<input type="submit" name="submit" value="$submit" />
|
||||||
|
</form>
|
|
@ -13,6 +13,16 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="photos-upload-exist-end"></div>
|
<div id="photos-upload-exist-end"></div>
|
||||||
|
|
||||||
|
|
||||||
|
<div id="photos-upload-perms" class="photos-upload-perms" ><div id="photos-upload-perms-menu" onClick="openClose('photos-upload-permissions-wrapper');" />$permissions</div>
|
||||||
|
<div id="photos-upload-perms-end"></div>
|
||||||
|
|
||||||
|
<div id="photos-upload-permissions-wrapper" style="display: none;" >
|
||||||
|
|
||||||
|
$aclselect
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="photos-upload-select-files-text">$filestext</div>
|
<div id="photos-upload-select-files-text">$filestext</div>
|
||||||
|
|
||||||
<div id="photos_upload_applet_wrapper">
|
<div id="photos_upload_applet_wrapper">
|
||||||
|
|
|
@ -1309,3 +1309,20 @@ input#dfrn-url {
|
||||||
#profile-jot-banner-end {
|
#profile-jot-banner-end {
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#photos-upload-select-files-text {
|
||||||
|
margin-top: 15px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#photos-upload-perms-menu, #photos-upload-perms-menu:visited {
|
||||||
|
color: #8888FF;
|
||||||
|
text-decoration: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
#photos-upload-perms-menu:hover {
|
||||||
|
color: #0000FF;
|
||||||
|
text-decoration: underline;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue