Photos now show up in feed (locally anywyay.) need cleanup/federation
This commit is contained in:
parent
50b12e5820
commit
58d98a4c2b
|
@ -44,16 +44,16 @@ class GNUsocialPhotosPlugin extends Plugin
|
||||||
case 'PhotosAction':
|
case 'PhotosAction':
|
||||||
include_once $dir . '/lib/photolib.php';
|
include_once $dir . '/lib/photolib.php';
|
||||||
include_once $dir . '/actions/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
|
include_once $dir . '/actions/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
|
||||||
return false;
|
break;
|
||||||
case 'PhotouploadAction':
|
case 'PhotouploadAction':
|
||||||
include_once $dir . '/lib/photolib.php';
|
include_once $dir . '/lib/photolib.php';
|
||||||
include_once $dir . '/classes/gnusocialphoto.php';
|
|
||||||
include_once $dir . '/actions/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
|
include_once $dir . '/actions/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
|
||||||
return false;
|
break;
|
||||||
default:
|
default:
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
include_once $dir . '/classes/gnusocialphoto.php';
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ class GNUsocialPhotosPlugin extends Plugin
|
||||||
{
|
{
|
||||||
$schema = Schema::get();
|
$schema = Schema::get();
|
||||||
$schema->ensureTable('GNUsocialPhoto',
|
$schema->ensureTable('GNUsocialPhoto',
|
||||||
array(new ColumnDef('object_id', 'integer', null, false, 'PRI', true, null, null, true),
|
array(new ColumnDef('notice_id', 'integer', null, false, null, true, null, null, true),
|
||||||
new ColumnDef('path', 'varchar(150)', null, false),
|
new ColumnDef('path', 'varchar(150)', null, false),
|
||||||
new ColumnDef('thumb_path', 'varchar(156)', null, false), // 156 = 150 + strlen('thumb.')
|
new ColumnDef('thumb_path', 'varchar(156)', null, false), // 156 = 150 + strlen('thumb.')
|
||||||
new ColumnDef('owner_id', 'int(11)', null, false)));
|
new ColumnDef('owner_id', 'int(11)', null, false)));
|
||||||
|
@ -74,4 +74,29 @@ class GNUsocialPhotosPlugin extends Plugin
|
||||||
common_log(LOG_INFO, "init'd!");
|
common_log(LOG_INFO, "init'd!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* function onStartActivityDefaultObjectType(&$notice, &$xs, &$type)
|
||||||
|
{
|
||||||
|
$photo = GNUsocialPhoto::staticGet('notice_id', $notice->id);
|
||||||
|
if($photo) {
|
||||||
|
$type = ActivityObject::PHOTO;
|
||||||
|
}
|
||||||
|
} */
|
||||||
|
|
||||||
|
function onStartShowNoticeItem($action)
|
||||||
|
{
|
||||||
|
common_log(LOG_INFO, 'StartShowNoticeItem: ' . $action->notice->id);
|
||||||
|
$photo = GNUsocialPhoto::staticGet('notice_id', $action->notice->id);
|
||||||
|
if($photo) {
|
||||||
|
common_log(LOG_INFO, 'is photo.');
|
||||||
|
$action->out->elementStart('a', array('href' => 'http://' . common_config('site', 'server') . $photo->path));
|
||||||
|
$action->out->element('img', array('src' => 'http://' . common_config('site', 'server') . $photo->thumb_path));
|
||||||
|
$action->out->elementEnd('a');
|
||||||
|
$action->showNoticeInfo();
|
||||||
|
$action->showNoticeOptions();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
common_log(LOG_INFO, 'not photo');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,14 @@ class PhotouploadAction extends Action
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showForm($msg, $success=false)
|
||||||
|
{
|
||||||
|
$this->msg = $msg;
|
||||||
|
$this->success = $success;
|
||||||
|
|
||||||
|
// $this->showPage();
|
||||||
|
}
|
||||||
|
|
||||||
function uploadPhoto()
|
function uploadPhoto()
|
||||||
{
|
{
|
||||||
common_log(LOG_INFO, 'Is this function even getting called?');
|
common_log(LOG_INFO, 'Is this function even getting called?');
|
||||||
|
@ -123,15 +131,13 @@ class PhotouploadAction extends Action
|
||||||
|
|
||||||
common_log(LOG_INFO, 'upload path : ' . $imagefile->filepath);
|
common_log(LOG_INFO, 'upload path : ' . $imagefile->filepath);
|
||||||
|
|
||||||
$filename = $cur->nickname . '-' . common_timestamp() . sha1_file($imagefile->filepath) . '.' . image_type_to_extension($imagefile->type);
|
$filename = $cur->nickname . '-' . common_timestamp() . sha1_file($imagefile->filepath) . image_type_to_extension($imagefile->type);
|
||||||
move_uploaded_file($imagefile->filepath, INSTALLDIR . '/file/' . $filename);
|
move_uploaded_file($imagefile->filepath, INSTALLDIR . '/file/' . $filename);
|
||||||
photo_make_thumbnail($filename);
|
photo_make_thumbnail($filename);
|
||||||
$photo = new GNUsocialPhoto();
|
$path = '/file/' . $filename;
|
||||||
$photo->path = '/file/' . $filename;
|
$thumb_path = '/file/thumb.' . $filename;
|
||||||
$photo->thumb_path = '/file/thumb.' . $filename;
|
$profile_id = $cur->id;
|
||||||
$photo->owner_id = $cur->id;
|
GNUsocialPhoto::saveNew($profile_id, $thumb_path, $path, 'web');
|
||||||
$photo->object_id = 'DEFAULT';
|
|
||||||
$photo->insert();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
||||||
class GNUsocialPhoto extends Memcached_DataObject
|
class GNUsocialPhoto extends Memcached_DataObject
|
||||||
{
|
{
|
||||||
public $__table = 'GNUsocialPhoto';
|
public $__table = 'GNUsocialPhoto';
|
||||||
public $object_id; // integer
|
public $noitce_id; // integer
|
||||||
public $path; // varchar(150)
|
public $path; // varchar(150)
|
||||||
public $thumb_path; // varchar(156)
|
public $thumb_path; // varchar(156)
|
||||||
public $owner_id; // int(11) (user who posted the photo)
|
public $owner_id; // int(11) (user who posted the photo)
|
||||||
|
@ -58,9 +58,51 @@ class GNUsocialPhoto extends Memcached_DataObject
|
||||||
|
|
||||||
function table()
|
function table()
|
||||||
{
|
{
|
||||||
return array('object_id' => DB_DATAOBJECT_INT,
|
return array('notice_id' => DB_DATAOBJECT_INT,
|
||||||
'path' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'path' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
||||||
'thumb_path' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'thumb_path' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
||||||
'owner_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL);
|
'owner_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function keys()
|
||||||
|
{
|
||||||
|
return array_keys($this->keyTypes());
|
||||||
|
}
|
||||||
|
|
||||||
|
function keyTypes()
|
||||||
|
{
|
||||||
|
return array('notice_id' => 'K');
|
||||||
|
}
|
||||||
|
|
||||||
|
function sequenceKey()
|
||||||
|
{
|
||||||
|
return array(false, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveNew($profile_id, $thumb_path, $path, $source)
|
||||||
|
{
|
||||||
|
$photo = new GNUsocialPhoto();
|
||||||
|
$photo->thumb_path = $thumb_path;
|
||||||
|
$photo->path = $path;
|
||||||
|
$photo->owner_id = $profile_id;
|
||||||
|
|
||||||
|
$notice = Notice::saveNew($profile_id, 'http://' . common_config('site', 'server') . $path, $source);
|
||||||
|
$photo->notice_id = $notice->id;
|
||||||
|
$photo_id = $photo->insert();
|
||||||
|
if (!$photo_id) {
|
||||||
|
common_log_db_error($photo, 'INSERT', __FILE__);
|
||||||
|
throw new ServerException(_m('Problem Saving Photo.'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
function asActivityNoun($element)
|
||||||
|
{
|
||||||
|
$object = new ActivityObject();
|
||||||
|
|
||||||
|
$object->type = ActivityObject::PHOTO;
|
||||||
|
$object->title = "";
|
||||||
|
$object->thumbnail = 'http://' . common_config('site', 'server') . $this->thumb_path;
|
||||||
|
$object->largerImage = 'http://' . common_config('site', 'server') . $this->path;
|
||||||
|
return $object;
|
||||||
|
} */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user