Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Hawk Wang committed Dec 2, 2014
1 parent 64f7de3 commit 735c757
Show file tree
Hide file tree
Showing 21 changed files with 493 additions and 98 deletions.
Binary file modified language/lang-dump-02-12-14-2.zip
Binary file not shown.
3 changes: 3 additions & 0 deletions zhaole365/ow_pluginfiles/base/lang_2.php
Original file line number Diff line number Diff line change
Expand Up @@ -2431,6 +2431,8 @@
'newsfeed+auth_action_label_allow_status_update' => '允许状态更新',
'newsfeed+auth_group_label' => '最新动态',
'newsfeed+comment_btn_label' => '评论',
'newsfeed+content_group_label' => '信息流',
'newsfeed+content_status_label' => '状态更新',
'newsfeed+customization_changed' => '设置已保存',
'newsfeed+customization_not_changed' => '配置没有更新',
'newsfeed+delete_feed_item_label' => '删除该发布信息',
Expand Down Expand Up @@ -2463,6 +2465,7 @@
'newsfeed+privacy_action_view_my_feed' => '查看我发布的信息',
'newsfeed+save_customization_btn_label' => '保存',
'newsfeed+settings_updated' => '更新设置',
'newsfeed+status_add_string' => '更新了他们的状态',
'newsfeed+status_btn_label' => '发布',
'newsfeed+status_field_invintation' => '聊一聊…',
'newsfeed+string_users_and_delim' => '',
Expand Down
22 changes: 22 additions & 0 deletions zhaole365/ow_plugins/newsfeed/bol/action_feed_dao.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,26 @@ public function deleteByActivityIds( $activityIds )

$this->deleteByExample($example);
}

public function findByActivityIds( $activityIds )
{
if ( empty($activityIds) )
{
return array();
}

$example = new OW_Example();
$example->andFieldInArray('activityId', $activityIds);

return $this->findListByExample($example);
}

public function findByFeed( $feedType, $feedId )
{
$example = new OW_Example();
$example->andFieldEqual('feedType', $feedType);
$example->andFieldEqual('feedId', $feedId);

return $this->findListByExample($example);
}
}
7 changes: 1 addition & 6 deletions zhaole365/ow_plugins/newsfeed/bol/activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,5 @@ class NEWSFEED_BOL_Activity extends OW_Entity
*
* @var string
*/
public $status;

public function __construct()
{
$this->status = NEWSFEED_BOL_Service::ACTION_STATUS_ACTIVE;
}
public $status = NEWSFEED_BOL_Service::ACTION_STATUS_ACTIVE;
}
2 changes: 1 addition & 1 deletion zhaole365/ow_plugins/newsfeed/bol/activity_dao.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public function saveOrUpdate( NEWSFEED_BOL_Activity $activity )
{
$activity->id = $dto->id;
}

$this->save($activity);
}

Expand Down
29 changes: 28 additions & 1 deletion zhaole365/ow_plugins/newsfeed/bol/service.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class NEWSFEED_BOL_Service
self::SYSTEM_ACTIVITY_CREATE,
self::SYSTEM_ACTIVITY_SUBSCRIBE
);

const EVENT_BEFORE_ACTION_DELETE = "feed.before_action_delete";
const EVENT_AFTER_ACTION_ADD = "feed.after_action_add";

private static $classInstance;

Expand Down Expand Up @@ -175,6 +178,13 @@ public function removeAction( $entityType, $entityId )
{
return;
}

$event = new OW_Event(self::EVENT_BEFORE_ACTION_DELETE, array(
"actionId" => $dto->id,
"entityType" => $dto->entityType,
"entityId" => $dto->entityId
));
OW::getEventManager()->trigger($event);

$this->likeDao->deleteByEntity($dto->entityType, $dto->entityId);
$this->actionDao->delete($dto);
Expand Down Expand Up @@ -260,7 +270,22 @@ public function deleteActivityFromFeed( $activityId, $feedType, $feedId )
{
$this->actionFeedDao->deleteByFeedAndActivityId($feedType, $feedId, $activityId);
}


public function findFeedListByActivityids( $activityIds )
{
$list = $this->actionFeedDao->findByActivityIds($activityIds);
$out = array();
foreach ( $list as $af )
{
$out[$af->activityId] = isset($out[$af->activityId])
? $out[$af->activityId] : array();

$out[$af->activityId][] = $af;
}

return $out;
}

/**
*
* @param string $activityType
Expand Down Expand Up @@ -379,6 +404,8 @@ public function testActivityKey( $key, $testKey, $all = false )
/**
* Find activity by special key
*
* [activityType].[activityId]:[entityType].[entityId]:[userId]
*
* @param $activityKey
* @return array
*/
Expand Down
11 changes: 11 additions & 0 deletions zhaole365/ow_plugins/newsfeed/classes/action.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class NEWSFEED_CLASS_Action
private $properties = array();
private $createActivity, $lastActivity;
private $creatorIdList = array();
private $feeds = array();

public function setDataValue( $name, $value )
{
Expand Down Expand Up @@ -111,6 +112,16 @@ public function getCreatorIdList()
{
return $this->creatorIdList;
}

public function setFeedList( $feedList )
{
$this->feeds = $feedList;
}

public function getFeedList()
{
return $this->feeds;
}

public function getUpdateTime()
{
Expand Down
215 changes: 215 additions & 0 deletions zhaole365/ow_plugins/newsfeed/classes/content_provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
<?php

class NEWSFEED_CLASS_ContentProvider
{
const ENTITY_TYPE_USER_STATUS = "user-status";

/**
* Singleton instance.
*
* @var NEWSFEED_CLASS_ContentProvider
*/
private static $classInstance;

/**
* Returns an instance of class (singleton pattern implementation).
*
* @return NEWSFEED_CLASS_ContentProvider
*/
public static function getInstance()
{
if ( self::$classInstance === null )
{
self::$classInstance = new self();
}

return self::$classInstance;
}

/**
*
* @var NEWSFEED)BOL_Service
*/
private $service;

private function __construct()
{
$this->service = NEWSFEED_BOL_Service::getInstance();
}

public function onCollectTypes( BASE_CLASS_EventCollector $event )
{
$event->add(array(
"pluginKey" => "newsfeed",
"group" => "newsfeed",
"groupLabel" => OW::getLanguage()->text("newsfeed", "content_group_label"),
"entityType" => self::ENTITY_TYPE_USER_STATUS,
"entityLabel" => OW::getLanguage()->text("newsfeed", "content_status_label"),
"moderation" => array(BOL_ContentService::MODERATION_TOOL_FLAG)
));
}

public function onGetInfo( OW_Event $event )
{
$params = $event->getParams();

if ( $params["entityType"] != self::ENTITY_TYPE_USER_STATUS )
{
return;
}

$out = array();
foreach ( $params["entityIds"] as $entityId )
{
$entity = $this->service->findAction($params["entityType"], $entityId);
$data = json_decode($entity->data, true);

$cActivities = $this->service->findActivity( NEWSFEED_BOL_Service::SYSTEM_ACTIVITY_CREATE . ':' . $entity->id);
$cActivity = reset($cActivities);

$userId = null;
$timeStamp = null;

/* @var $cActivity NEWSFEED_BOL_Activity */
if ( !empty($cActivity) )
{
$userId = $cActivity->userId;
$timeStamp = $cActivity->timeStamp;
}

$info = array();

$info["id"] = $entityId;
$info["userId"] = $userId;
$info["timeStamp"] = $timeStamp;

$content = empty($data["content"]) ? null : $data["content"];

if ( $content === null )
{
$info["text"] = $data["data"]["status"];
}
else if ($content["format"] == "text")
{
$info["text"] = $content["vars"]["status"];
}
else
{
$info["title"] = $content["vars"]["title"];
$info["description"] = $content["vars"]["description"];
$info["url"] = $content["vars"]["url"];

if ( !empty($content["vars"]["status"]) )
{
$info["text"] = $content["vars"]["status"];
}

if ( !empty($content["vars"]["embed"]) )
{
$info["html"] = $content["vars"]["embed"];
}

$info["image"] = array();

if ( !empty($content["vars"]["thumbnail"]) )
{
$info["image"]["thumbnail"] = $content["vars"]["thumbnail"];
}

if ( !empty($content["vars"]["image"]) )
{
$info["image"]["view"] = $content["vars"]["image"];
}
}

$out[$entityId] = $info;
}

$event->setData($out);

return $out;
}

public function onUpdateInfo( OW_Event $event )
{
$params = $event->getParams();
$data = $event->getData();

$entityType = $params["entityType"];

foreach ( $data as $entityId => $info )
{
$status = $info["status"] == BOL_ContentService::STATUS_ACTIVE
? NEWSFEED_BOL_Service::ACTION_STATUS_ACTIVE
: NEWSFEED_BOL_Service::ACTION_STATUS_INACTIVE;

$cActivities = $this->service->findActivity(NEWSFEED_BOL_Service::SYSTEM_ACTIVITY_CREATE . ':' . $entityType . '.' . $entityId);

foreach ( $cActivities as $activity )
{
$activity->status = $status;
$this->service->saveActivity($activity);
}
}
}

public function onDelete( OW_Event $event )
{
$params = $event->getParams();

if ( $params["entityType"] != self::ENTITY_TYPE_USER_STATUS )
{
return;
}

foreach ( $params["entityIds"] as $entityId )
{
$this->service->removeAction($params["entityType"], $entityId);
}
}

// Video events

public function onBeforeActionDelete( OW_Event $event )
{
$params = $event->getParams();

if ( $params["entityType"] != self::ENTITY_TYPE_USER_STATUS )
{
return;
}

OW::getEventManager()->trigger(new OW_Event(BOL_ContentService::EVENT_BEFORE_DELETE, array(
"entityType" => $params["entityType"],
"entityId" => $params["entityType"]
)));
}

public function onAfterActionAdd( OW_Event $event )
{
$params = $event->getParams();

if ( $params["entityType"] != self::ENTITY_TYPE_USER_STATUS )
{
return;
}

OW::getEventManager()->trigger(new OW_Event(BOL_ContentService::EVENT_AFTER_ADD, array(
"entityType" => $params["entityType"],
"entityId" => $params["entityId"]
), array(
"string" => array("key" => "newsfeed+status_add_string")
)));
}

public function init()
{
OW::getEventManager()->bind(NEWSFEED_BOL_Service::EVENT_BEFORE_ACTION_DELETE, array($this, "onBeforeActionDelete"));
OW::getEventManager()->bind(NEWSFEED_BOL_Service::EVENT_AFTER_ACTION_ADD, array($this, "onAfterActionAdd"));

OW::getEventManager()->bind(BOL_ContentService::EVENT_COLLECT_TYPES, array($this, "onCollectTypes"));
OW::getEventManager()->bind(BOL_ContentService::EVENT_GET_INFO, array($this, "onGetInfo"));
OW::getEventManager()->bind(BOL_ContentService::EVENT_UPDATE_INFO, array($this, "onUpdateInfo"));
OW::getEventManager()->bind(BOL_ContentService::EVENT_DELETE, array($this, "onDelete"));
}
}
Loading

0 comments on commit 735c757

Please sign in to comment.