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, 'level' => $content->level, '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);
             $d = OpenPNE_KtaiEmoji::convertEmoji($d);
         }
         $data['body'] = op_auto_link_text(op_decoration(nl2br($data['body'])));
         $result[] = $data;
     }
     return json_encode($result);
 }
Пример #2
0
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;
}
Пример #3
0
function op_api_diary($diary, $option = null)
{
    if ($diary) {
        //モデルクラス内でsns_termの値が取れずgetPublicFlagLabelでコケるため,緊急処置(see #3502, #3503)
        Doctrine::getTable('SnsTerm')->configure('ja_JP', 'pc_frontend');
        $data = array('id' => $diary->id, 'member' => op_api_member($diary->getMember()), 'title' => $diary->title, 'public_flag' => $diary->getPublicFlagLabel(), 'created_at' => $diary->created_at);
        if ('short' == $option) {
            $bodyShort = op_truncate(op_decoration($diary->body, true), 60);
            if (mb_strlen($diary->body) >= 60) {
                $bodyShort .= '&hellip;';
            }
            $data['body_short'] = op_api_diary_convert_emoji($bodyShort);
        } else {
            $body = op_auto_link_text(op_decoration($diary->body));
            $data['body'] = nl2br(op_api_diary_convert_emoji($body));
            $images = $diary->getDiaryImages();
            foreach ($images as $image) {
                $data['images'][] = op_api_diary_image($image);
            }
        }
        return $data;
    }
}
Пример #4
0
if ($diary->member_id === $sf_user->getMemberId()) {
    ?>
[<?php 
    echo link_to(__('Edit'), 'diary_edit', $diary);
    ?>
][<?php 
    echo link_to(__('Delete'), 'diary_delete_confirm', $diary);
    ?>
]
<?php 
}
?>
<br>

<?php 
echo op_decoration(nl2br($diary->body));
?>
<br>

<?php 
if ($diary->has_images) {
    foreach ($diary->getDiaryImages() as $image) {
        echo link_to(__('View Image'), sf_image_path($image->File, array('size' => '240x320', 'f' => 'jpg')));
        ?>
<br>
<?php 
    }
}
?>

(<?php 
Пример #5
0
<?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 
}
Пример #6
0
</td>
</tr><tr>
<th><?php 
        echo __('Title');
        ?>
</th><td><?php 
        echo op_diary_get_title_and_count($diary);
        echo op_diary_image_icon($diary);
        ?>
</td>
</tr><tr>
<th><?php 
        echo __('Body');
        ?>
</th><td><?php 
        echo op_truncate(op_decoration($diary->body, true), 36, '', 3);
        ?>
</td>
</tr><tr class="operation">
<th><?php 
        echo __('Created at');
        ?>
</th><td><span class="text"><?php 
        echo op_format_date($diary->created_at, 'XDateTimeJa');
        ?>
</span> <span class="moreInfo"><?php 
        echo link_to(__('View this diary'), 'diary_show', $diary);
        ?>
</span></td>
</tr></tbody></table></div></div>
<?php 
Пример #7
0
<?php

use_helper('opActivity');
?>

<?php 
echo op_link_to_member($activity->getMember());
?>
&nbsp;<?php 
echo op_auto_link_text_for_mobile(op_decoration(nl2br($activity->getBody())));
?>
<font color="<?php 
echo $op_color['core_color_19'];
?>
">[<?php 
echo op_format_activity_time(strtotime($activity->getCreatedAt()));
?>
]</font>
<?php 
if ($activity->getPublicFlag() !== ActivityDataTable::PUBLIC_FLAG_SNS) {
    ?>
<font color="<?php 
    echo $op_color['core_color_19'];
    ?>
">[<?php 
    echo $activity->getPublicFlagCaption();
    ?>
]</font>
<?php 
}
if (!isset($isOperation) || $isOperation) {
Пример #8
0
    echo date('Y-m-d (D)', strtotime($item['target_date']));
    ?>
</div>
<div class="kakiage_updated_at">(<?php 
    echo __('Updated at');
    ?>
: <?php 
    echo op_format_date($item['updated_at'], 'XDateTimeJa');
    ?>
)</div>
<div class="editLink"><?php 
    echo link_to(__('Edit'), '@kakiage_edit_date?' . strftime('year=%Y&month=%m&day=%d', strtotime($item['target_date'])));
    ?>
</div>
<div class="kakiage_body"><?php 
    echo op_url_cmd(op_decoration(nl2br($item['body'])));
    ?>
</div>
</div>
<?php 
}
?>

</div>

<div class="parts">
<?php 
echo link_to(__('Index'), '@kakiage_index');
?>
</div>
</div>
Пример #9
0
    foreach ($images as $image) {
        ?>
<li><a href="<?php 
        echo sf_image_path($image->File);
        ?>
" target="_blank"><?php 
        echo image_tag_sf_image($image->File, array('size' => '120x120'));
        ?>
</a></li>
<?php 
    }
    ?>
</ul>
<?php 
}
echo op_url_cmd(op_decoration(nl2br($diary->body)));
?>
</div>
</dd>
</dl>
<?php 
if ($diary->member_id === $sf_user->getMemberId()) {
    ?>
<div class="operation">
<form action="<?php 
    echo url_for('diary_edit', $diary);
    ?>
">
<ul class="moreInfo button">
<li><input type="submit" class="input_submit" value="<?php 
    echo __('Edit this diary');
Пример #10
0
        ?>
<li><a href="<?php 
        ?>
<?php// echo sf_image_path($image->File) ?>" target="_blank"><?php 
        ?>
<?php// echo image_tag_sf_image($image->File, array('size' => '120x120')) ?></a></li>
<?php 
    }
    ?>
</ul>
<?php 
}
?>
<p class="text">
<?php 
echo op_url_cmd(op_decoration(nl2br($bbs->body)));
?>
</p>
</div>
</dd>
</dl>
<?php 
if ($bbs->member_id === $sf_user->getMemberId()) {
    ?>
<div class="operation">
<form action="<?php 
    echo url_for('bbs_edit', $bbs);
    ?>
">
<ul class="moreInfo button">
<li><input type="submit" class="input_submit" value="<?php 
Пример #11
0
if ($diary->member_id === $sf_user->getMemberId()) {
    ?>
[<?php 
    echo link_to(__('Edit'), 'diary_edit', $diary);
    ?>
][<?php 
    echo link_to(__('Delete'), 'diary_delete_confirm', $diary);
    ?>
]
<?php 
}
?>
<br>

<?php 
echo op_auto_link_text_for_mobile(op_decoration(nl2br($diary->body)));
?>
<br>

<?php 
if ($diary->has_images) {
    foreach ($diary->getDiaryImages() as $image) {
        echo link_to(__('View Image'), sf_image_path($image->File, array('size' => '240x320', 'f' => 'jpg')));
        ?>
<br>
<?php 
    }
}
?>

(<?php 
Пример #12
0
</td>
</tr><tr>
<th><?php 
        echo __('Title');
        ?>
</th><td><?php 
        echo op_bbs_get_title_and_count($bbs);
        echo op_bbs_image_icon($bbs);
        ?>
</td>
</tr><tr>
<th><?php 
        echo __('Body');
        ?>
</th><td><?php 
        echo op_truncate(op_decoration($bbs->body, true), 36, '', 3);
        ?>
</td>
</tr><tr class="operation">
<th><?php 
        echo __('Updated at');
        ?>
</th><td><span class="text"><?php 
        echo op_format_date($bbs->updated_at, 'XDateTimeJa');
        ?>
</span> <span class="moreInfo"><?php 
        echo link_to(__('View this bbs'), 'bbs_show', $bbs);
        ?>
</span></td>
</tr></tbody></table></div></div>
<?php 
<?php

include_once dirname(__FILE__) . '/../../bootstrap/unit.php';
sfContext::createInstance(ProjectConfiguration::getApplicationConfiguration('pc_frontend', 'test', true));
include_once sfConfig::get('sf_lib_dir') . '/vendor/symfony/lib/helper/HelperHelper.php';
use_helper('opUtil');
$t = new lime_test(10, new lime_output_color());
$base = sfConfig::get('op_base_url');
$t->comment('opWikifyDecorator::replaceWikiLink()');
$t->is(op_decoration('[[aaa]]'), '<a class="wikilink" target="_blank" href="http://example.com/wiki/aaa">aaa</a>', 'decorator converts a wikilink to an <a> tag');
$t->is(op_decoration('[[bbb|ccc]]'), '<a class="wikilink" target="_blank" href="http://example.com/wiki/bbb">ccc</a>');
$t->is(op_decoration('[[bbb|ccc|ddd]]'), '<a class="wikilink" target="_blank" href="http://example.com/wiki/bbb">ccc|ddd</a>');
$t->is(op_decoration('[[abc:def]]'), '<a class="wikilink" target="_blank" href="http://example.com/wiki/abc%3Adef">abc:def</a>');
$t->is(op_decoration('[[abc:def:ghi]]'), '<a class="wikilink" target="_blank" href="http://example.com/wiki/abc%3Adef%3Aghi">abc:def:ghi</a>');
$t->is(op_decoration('[[wp:メインページ]]'), '<a class="wikilink" target="_blank" href="http://ja.wikipedia.org/wiki/' . urlencode('メインページ') . '">wp:メインページ</a>');
$t->is(op_decoration('[[wp:メインページ|Wikipedia]]'), '<a class="wikilink" target="_blank" href="http://ja.wikipedia.org/wiki/' . urlencode('メインページ') . '">Wikipedia</a>');
$t->is(op_decoration('[[wp:MediaWiki:Common.css]]'), '<a class="wikilink" target="_blank" href="http://ja.wikipedia.org/wiki/MediaWiki%3ACommon.css">wp:MediaWiki:Common.css</a>');
$t->is(op_decoration('[[member:1]]'), '<a class="wikilink" href="' . $base . 'member/1">member:1</a>');
$t->is(op_decoration('[[member:1|OpenPNE君]]'), '<a class="wikilink" href="' . $base . 'member/1">OpenPNE君</a>');