/** * op_activity_body_filter * * @param Activity $activity * @param boolean $is_auto_link * @return string */ function op_activity_body_filter($activity, $is_auto_link = true) { $body = $activity->getBody(); if ($activity->getTemplate()) { $config = $activity->getTable()->getTemplateConfig(); if (!isset($config[$activity->getTemplate()])) { return ''; } $params = array(); foreach ($activity->getTemplateParam() as $key => $value) { $params[$key] = $value; } $body = __($config[$activity->getTemplate()], $params); $event = sfContext::getInstance()->getEventDispatcher()->filter(new sfEvent(null, 'op_activity.template.filter_body'), $body); $body = $event->getReturnValue(); } $event = sfContext::getInstance()->getEventDispatcher()->filter(new sfEvent(null, 'op_activity.filter_body'), $body); $body = $event->getReturnValue(); if (false === strpos($body, '<a') && $activity->getUri()) { return link_to($body, $activity->getUri()); } if ($is_auto_link) { if ('mobile_frontend' === sfConfig::get('sf_app')) { return op_auto_link_text_for_mobile($body); } return op_auto_link_text($body); } return $body; }
function op_api_diary($diary) { if ($diary) { $body = preg_replace(array('/<op:.*?>/', '/<\\/op:.*?>/'), '', $diary->getBody()); $body = preg_replace('/http.:\\/\\/maps\\.google\\.co[[:graph:]]*/', '', $body); $bodyShort = op_truncate($body, 60); $body = op_auto_link_text($body); return array('id' => $diary->getId(), 'member' => op_api_member($diary->getMember()), 'title' => $diary->getTitle(), 'body' => nl2br(op_api_diary_convert_emoji($body)), 'body_short' => nl2br(op_api_diary_convert_emoji($bodyShort)), 'public_flag' => $diary->getPublicFlag(), 'ago' => op_format_activity_time(strtotime($diary->getCreatedAt())), 'created_at' => $diary->getCreatedAt()); } }
public function getListJson($controller, $contents) { sfContext::getInstance()->getConfiguration()->loadHelpers(array('Helper', 'Tag', 'Escaping', 'opUtil')); $result = array(); foreach ($contents as $content) { $data = array('number' => $content->number, 'member_url' => $controller->genUrl('@obj_member_profile?id=' . $content->member_id), 'member_name' => $content->Member->name, 'command' => $content->command, 'body' => $content->body, 'created_at' => $content->created_at); foreach ($data as &$d) { $d = sfOutputEscaper::escape(sfConfig::get('sf_escaping_method'), $d); } $data['body'] = op_auto_link_text($data['body']); $result[] = $data; } return json_encode($result); }
function op_api_message($messageList, $member, $useIsReadFlag = false) { $message = $messageList->getSendMessageData(); $body = preg_replace(array('/<op:.*?>/', '/<\\/op:.*?>/'), '', $message->getBody()); $body = preg_replace('/http.:\\/\\/maps\\.google\\.co[[:graph:]]*/', '', $body); $body = op_auto_link_text($body); $imagePath = null; $imageTag = null; $image = $message->getMessageFile(); if (0 < count($image)) { $imageTag = image_tag_sf_image($image[0]->getFile(), array('size' => '76x76')); $imagePath = sf_image_path($image[0]->getFile()); } $data = array('id' => $message->getId(), 'member' => op_api_member($member), 'subject' => $message->getSubject(), 'body' => nl2br($body), 'summary' => op_truncate(op_decoration($body, true), 25, '...'), 'image_path' => $imagePath, 'image_tag' => $imageTag, 'created_at' => $message->getCreatedAt(), 'formatted_date' => get_formatted_date($message->getCreatedAt())); if ($useIsReadFlag) { $data['is_read'] = $messageList->isSelf() ? (bool) $messageList->getIsRead() : null; } return $data; }
<?php foreach ($chatlist as $chat) { ?> <dt> <span class="number"><?php echo $chat->number; ?> </span>: <?php echo link_to($chat->Member->name, '@obj_member_profile?id=' . $chat->member_id, array('popup' => true)); ?> <?php echo $chat->created_at; ?> </dt> <dd class="<?php echo $chat->command; ?> "> <?php echo op_auto_link_text(op_decoration(nl2br($chat->body))); ?> </dd> <?php }
if ($pager->getNbResults()) { ?> <div class="comments"> <?php foreach ($pager->getResults() as $comment) { ?> <div class="comment" style="padding: 1px 0px 4px 0px; border-bottom: 1px solid #b3ceef;"> <div class="body"> <?php echo op_link_to_member($comment->getMemberId()); ?> <?php echo op_auto_link_text($comment->body); ?> <div class="info"> <small style="color: rgb(85, 85, 85);"><?php echo op_format_activity_time(strtotime($comment->getCreatedAt())); ?> </small> </div> <?php if ($authorId === $sf_user->getMemberId() || $comment->member_id === $sf_user->getMemberId()) { ?> <div class="operation"> <small> <?php
//------------------------------------------------------------ $t->diag('op_link_to_member()'); $t->is(op_link_to_member(1), link_to('A', '@obj_member_profile?id=1'), 'link to member 1'); $t->is(op_link_to_member(1, array(), '@obj_friend_unlink'), link_to('A', '@obj_friend_unlink?id=1'), 'link to unlink member 1'); $t->is(op_link_to_member(1, array('link_target' => 'tetetete'), '@obj_member_profile'), link_to('tetetete', '@obj_member_profile?id=1'), 'link to member 1 (free text)'); $member2 = Doctrine::getTable('Member')->find(2); $t->is(op_link_to_member($member2), link_to($member2->getName(), 'obj_member_profile', $member2), 'set Member object'); $t->is(op_link_to_member(9999), '-', 'set undefine member'); $t->is(op_link_to_member(null), '-', 'set null member'); Doctrine::getTable('SnsConfig')->set('nickname_of_member_who_does_not_have_credentials', 'I am a pen.'); $t->is(op_link_to_member(null), 'I am a pen.', 'set nickname_of_member_who_does_not_have_credentials original setting'); //------------------------------------------------------------ $t->diag('op_auto_link_text()'); $t->is(op_auto_link_text('http://example.com/'), '<a href="http://example.com/" target="_blank">http://example.com/</a>'); $t->is(op_auto_link_text('https://example.com/'), '<a href="https://example.com/" target="_blank">https://example.com/</a>', 'protocol'); $t->is(op_auto_link_text('http://sub.example.com/'), '<a href="http://sub.example.com/" target="_blank">http://sub.example.com/</a>', 'subdomain'); $t->is(op_auto_link_text('http://example.com/hoge'), '<a href="http://example.com/hoge" target="_blank">http://example.com/hoge</a>', 'path'); $t->is(op_auto_link_text('http://example.com:8080/'), '<a href="http://example.com:8080/" target="_blank">http://example.com:8080/</a>', 'port'); $t->is(op_auto_link_text('http://example.com/#foo'), '<a href="http://example.com/#foo" target="_blank">http://example.com/#foo</a>', 'anchor'); $t->is(op_auto_link_text('http://example.com/?foo=1&bar=0'), '<a href="http://example.com/?foo=1&bar=0" target="_blank">http://example.com/?foo=1&bar=0</a>', 'query'); $t->is(op_auto_link_text('https://sub.example.com:8080/hoge?foo=1&bar=0#foo'), '<a href="https://sub.example.com:8080/hoge?foo=1&bar=0#foo" target="_blank">https://sub.example.com:8080/hoge?foo=1&bar=0#foo</a>'); $t->is(op_auto_link_text('http://example.com'), '<a href="http://example.com" target="_blank">http://example.com</a>'); $t->is(op_auto_link_text('www.example.com'), '<a href="http://www.example.com" target="_blank">www.example.com</a>'); // see https://trac.openpne.jp/ticket/3553 $t->is(op_auto_link_text('http://example.com/#comment:1'), '<a href="http://example.com/#comment:1" target="_blank">http://example.com/#comment:1</a>'); // see https://redmine.openpne.jp/issues/3289 $t->is(op_auto_link_text('http://example.com/テキスト'), '<a href="http://example.com/" target="_blank">http://example.com/</a>テキスト'); $t->is(op_auto_link_text('http://example.com/hogeテキスト'), '<a href="http://example.com/hoge" target="_blank">http://example.com/hoge</a>テキスト'); $t->is(op_auto_link_text('http://example.comテキスト'), '<a href="http://example.com" target="_blank">http://example.com</a>テキスト'); $t->is(op_auto_link_text('http://example.com:8080/'), '<a href="http://example.com:" target="_blank">http://example.com:</a>8080/'); // http://example.com:/ is valid URI.
function _op_url_cmd($matches) { $url = $matches[2] . $matches[3]; $cmd = ''; if ($matches[2] == 'www.') { $cmd .= 'www.'; $url = 'http://www.' . $url; } if (preg_match('/([a-zA-Z0-9\\-.]+)\\/?(?:[a-zA-Z0-9_\\-\\/.,:;\\~\\?@&=+$%#!()])*/', $matches[3], $pmatch)) { $cmd .= $pmatch[1]; } $file = $cmd . '.js'; $path = './cmd/' . $file; if (preg_match('/<a/', $matches[1]) || !is_readable($path)) { return op_auto_link_text($matches[0]); } sfContext::getInstance()->getResponse()->addJavascript('util'); $googlemapsUrl = url_for('@google_maps'); $public_path = _compute_public_path($file, 'cmd', 'js'); $result = <<<EOD <script type="text/javascript" src="{$public_path}"></script> <script type="text/javascript"> <!-- url2cmd('{$url}', '{$googlemapsUrl}'); //--> </script> EOD; return $result . $matches[4]; }
$ageValue .= ' (' . __('Only Open to %my_friend%', array('%my_friend%' => $op_term['my_friend']->titleize()->pluralize())) . ')'; } $list[__('Age')] = $ageValue; } foreach ($member->getProfiles(true) as $profile) { $caption = $profile->getProfile()->getCaption(); if ($profile->getProfile()->isPreset()) { $presetConfig = $profile->getProfile()->getPresetConfig(); $caption = __($presetConfig['Caption']); } $profileValue = (string) $profile; if ('' === $profileValue) { continue; } if ('textarea' == $profile->getFormType()) { $profileValue = op_auto_link_text(nl2br($profileValue)); } if ($profile->getProfile()->isPreset()) { if ('country_select' === $profile->getFormType()) { $profileValue = $culture->getCountry($profileValue); } elseif ('op_preset_birthday' === $profile->getName()) { $profileValue = op_format_date($profileValue, 'XShortDateJa'); } $profileValue = __($profileValue); } if ($member->getId() == $sf_user->getMemberId()) { if ($profile->getPublicFlag() == ProfileTable::PUBLIC_FLAG_FRIEND) { $profileValue .= ' (' . __('Only Open to %my_friend%', array('%my_friend%' => $op_term['my_friend']->titleize()->pluralize())) . ')'; } elseif ($profile->getPublicFlag() == ProfileTable::PUBLIC_FLAG_WEB && $profile->Profile->is_public_web) { $profileValue .= ' (' . __('All Users on the Web') . ')'; }
function op_activity_linkification($body, $options = array()) { $body = op_auto_link_text($body); return preg_replace_callback('/(@+)([-._0-9A-Za-z]+)/', 'op_activity_linkification_callback', $body); }
<?php include_customizes('menu', 'top'); ?> <hr color="<?php echo $op_color["core_color_11"]; ?> " size="3"> </td></tr> <?php $list = array(__('%community% Name') => $community->getName(), __('Community Category', array(), 'form_community') => $community->getCommunityCategory(), __('Date Created') => op_format_date($community->getCreatedAt(), 'D'), __('Administrator') => link_to($community_admin->getName(), 'member/profile?id=' . $community_admin->getId()), __('Count of Members') => $community->countCommunityMembers()); foreach ($community->getConfigs() as $key => $config) { $list[__($key, array(), 'form_community')] = $config; } $list[__('Register poricy', array(), 'form_community')] = __($sf_data->getRaw('community')->getRegisterPoricy()); $list[__('Description', array(), 'form_community')] = op_auto_link_text(nl2br($community->getConfig('description'))); foreach ($list as $key => $value) { ?> <font color="<?php echo $op_color["core_color_19"]; ?> "><?php echo $key; ?> :</font><br> <?php echo $value; ?> <br> <?php }
?> <br> </td> </tr> <tr> <td colspan="2"> <font color="<?php echo $op_color["core_color_19"]; ?> "><?php echo __('Description'); ?> :</font><br> <?php echo op_auto_link_text(nl2br(mb_substr($community->getConfig('description'), 0, 54))); ?> <br> </td> <tr> <td align="right" colspan="2"> <font color="<?php echo $op_color["core_color_20"]; ?> ">⇒</font><?php echo link_to(__('More'), 'community/detail?id=' . $community->getId()); ?> <br> </td> </tr>
end_slot(); ?> <?php $list = array(__('%community% Name', array('%community%' => $op_term['community']->titleize())) => $community->getName(), __('%community% Category', array('%community%' => $op_term['community']->titleize())) => $community->getCommunityCategory(), __('Date Created') => op_format_date($community->getCreatedAt(), 'D'), __('Administrator') => link_to($communityAdmin->getName(), '@member_profile?id=' . $communityAdmin->getId())); $subAdminCaption = ''; foreach ($communitySubAdmins as $m) { $subAdminCaption .= "<li>" . link_to($m->getName(), '@member_profile?id=' . $m->getId()) . "</li>\n"; } if ($subAdminCaption) { $list[__('Sub Administrator')] = '<ul>' . $subAdminCaption . '</ul>'; } $list[__('Count of Members')] = $community->countCommunityMembers(); foreach ($community->getConfigs() as $key => $config) { if ('Description' === $key) { $list[__('%community% Description', array('%community%' => $op_term['community']->titleize()), 'form_community')] = op_auto_link_text(nl2br($community->getConfig('description'))); } else { $list[__($key, array(), 'form_community')] = $config; } } $list[__('Register poricy', array(), 'form_community')] = __($community->getRawValue()->getRegisterPoricy()); $options = array('title' => __('%community%', array('%community%' => $op_term['community']->titleize())), 'list' => $list); op_include_parts('listBox', 'communityHome', $options); ?> <ul> <?php if ($isEditCommunity) { ?> <li><?php echo link_to(__('Edit this %community%'), 'community/edit?id=' . $community->getId());
function op_api_diary_comment($comment) { if ($comment) { $images = array(); if ($comment->getHasImages()) { foreach ($comment->getDiaryCommentImages() as $image) { $images[] = op_api_diary_image($image); } } return array('id' => $comment->getId(), 'diary_id' => $comment->getDiaryId(), 'number' => $comment->getNumber(), 'member' => op_api_member($comment->getMember()), 'body' => nl2br(op_auto_link_text($comment->getBody())), 'ago' => op_format_activity_time(strtotime($comment->getCreatedAt())), 'created_at' => $comment->getCreatedAt(), 'images' => $images); } }
} else { echo image_tag($images[$i]->getUri(), array('width' => 76, 'height' => 76)); } } ?> <br /> <?php } echo link_to($activity->getMember()->getName(), '@obj_member_profile?id=' . $activity->getMemberId()); ?> <?php if ($activity->getUri()) { echo link_to($activity->getBody(), $activity->getUri()); } else { echo op_auto_link_text($activity->getBody()); } ?> <div class="info"> <span class="time"><?php echo op_format_activity_time(strtotime($activity->getCreatedAt())); if ($activity->getSource()) { ?> from <?php echo link_to_if($activity->getSourceUri(), $activity->getSource(), $activity->getSourceUri()); } ?> </span> <?php if ($activity->getPublicFlag() != ActivityDataTable::PUBLIC_FLAG_SNS) { ?>
<?php foreach ($chatlist as $chat) { ?> <dt> <span class="number"><?php echo $chat->number; ?> </span>: <?php echo link_to($chat->Member->name, '@obj_member_profile?id=' . $chat->member_id, array('popup' => true)); ?> <?php echo $chat->created_at; ?> </dt> <dd class="<?php echo $chat->command; ?> "> <?php echo op_auto_link_text($chat->body); ?> </dd> <?php }