Exemplo n.º 1
0
function op_api_activity($activity)
{
    use_helper('opActivity');
    $viewMemberId = sfContext::getInstance()->getUser()->getMemberId();
    $member = $activity->getMember();
    $images = array();
    foreach ($activity->getImages() as $activityImage) {
        $images[] = array('small_size' => op_activity_image_uri($activityImage, array('size' => '48x48'), true), 'full_size' => op_activity_image_uri($activityImage, array(), true));
    }
    return array('id' => $activity->getId(), 'member' => op_api_member($member), 'body' => $activity->getBody(), 'body_html' => op_activity_linkification(nl2br(op_api_force_escape($activity->getBody()))), 'uri' => $activity->getUri(), 'source' => $activity->getSource(), 'source_uri' => $activity->getSourceUri(), 'image_uris' => $images, 'created_at' => date('r', strtotime($activity->getCreatedAt())));
}
Exemplo n.º 2
0
$t->is(op_activity_body_filter($activity5), '<a href="/index.php/">http://www.openpne.jp</a>', 'op_activity_body_filter() returns linked text by uri of ActivityData');
sfConfig::set('sf_app', 'mobile_frontend');
$t->is(op_activity_body_filter($activity4), '<a href="http://sns.example.com/proxy?url=http%3A%2F%2Fwww.openpne.jp">http://www.openpne.jp</a>', 'op_activity_body_filter() returns autolinked text');
function test_filter(sfEvent $event, $value)
{
    return '';
}
sfContext::getInstance()->getEventDispatcher()->connect('op_activity.filter_body', 'test_filter');
$t->is(op_activity_body_filter($activity1), '', 'op_activity_body_filter() returns ""');
$t->diag('op_activity_image_uri() [file_id]');
$activityImage = new ActivityImage();
$activityImage->File->fromArray(array('name' => 'ac_hogehoge_png', 'type' => 'image/png'));
$t->is(op_activity_image_uri($activityImage), '/cache/img/png/w_h/ac_hogehoge_png.png');
$t->is(op_activity_image_uri($activityImage, array('size' => '48x48')), '/cache/img/png/w48_h48/ac_hogehoge_png.png');
$t->is(op_activity_image_uri($activityImage, array(), true), 'http://sns.example.com/cache/img/png/w_h/ac_hogehoge_png.png');
$t->diag('op_activity_image_uri() [uri]');
$activityImage = new ActivityImage();
$activityImage->fromArray(array('uri' => 'http://example.com/images/hogehoge.png', 'mimetype' => 'image/png'));
$t->is(op_activity_image_uri($activityImage), 'http://example.com/images/hogehoge.png');
$t->is(op_activity_image_uri($activityImage, array('size' => '48x48')), 'http://example.com/images/hogehoge.png');
$t->is(op_activity_image_uri($activityImage, array(), true), 'http://example.com/images/hogehoge.png');
$t->diag('op_activity_image_tag() [file_id]');
$activityImage = new ActivityImage();
$activityImage->File->fromArray(array('name' => 'ac_hogehoge_png', 'type' => 'image/png'));
$t->is(op_activity_image_tag($activityImage), '<img alt="" src="/cache/img/png/w_h/ac_hogehoge_png.png" />');
$t->is(op_activity_image_tag($activityImage, array('size' => '48x48')), '<img alt="" src="/cache/img/png/w48_h48/ac_hogehoge_png.png" />');
$t->diag('op_activity_image_tag() [uri]');
$activityImage = new ActivityImage();
$activityImage->fromArray(array('uri' => 'http://example.com/images/hogehoge.png', 'mimetype' => 'image/png'));
$t->is(op_activity_image_tag($activityImage), '<img src="http://example.com/images/hogehoge.png" />');
$t->is(op_activity_image_tag($activityImage, array('size' => '48x48')), '<img src="http://example.com/images/hogehoge.png" height="48" width="48" />');