本文整理汇总了PHP中UTIL_HtmlTag::autoLink方法的典型用法代码示例。如果您正苦于以下问题:PHP UTIL_HtmlTag::autoLink方法的具体用法?PHP UTIL_HtmlTag::autoLink怎么用?PHP UTIL_HtmlTag::autoLink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UTIL_HtmlTag
的用法示例。
在下文中一共展示了UTIL_HtmlTag::autoLink方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(BASE_CLASS_WidgetParameter $param)
{
parent::__construct();
$userId = $param->additionalParamList['entityId'];
if (isset($param->customParamList['content'])) {
$content = $param->customParamList['content'];
} else {
$settings = BOL_ComponentEntityService::getInstance()->findSettingList($param->widgetDetails->uniqName, $userId, array('content'));
$content = empty($settings['content']) ? null : $settings['content'];
}
if ($param->additionalParamList['entityId'] == OW::getUser()->getId()) {
$this->assign('ownerMode', true);
$this->assign('noContent', $content === null);
$this->addForm(new AboutMeForm($param->widgetDetails->uniqName, $content));
} else {
if (empty($content)) {
$this->setVisible(false);
return;
}
$this->assign('ownerMode', false);
$content = htmlspecialchars($content);
$content = UTIL_HtmlTag::autoLink($content);
$this->assign('contentText', $content);
}
}
示例2: beforeContentAdd
public function beforeContentAdd(OW_Event $event)
{
$params = $event->getParams();
$data = $event->getData();
if (!empty($data)) {
return;
}
if (empty($params["status"]) && empty($params["data"])) {
$event->setData(false);
return;
}
$attachId = null;
$content = array();
if (!empty($params["data"])) {
$content = $params["data"];
if ($content['type'] == 'photo' && !empty($content['genId'])) {
$content['url'] = $content['href'] = OW::getEventManager()->call('base.attachment_save_image', array('genId' => $content['genId']));
$attachId = $content['genId'];
}
if ($content['type'] == 'video') {
$content['html'] = BOL_TextFormatService::getInstance()->validateVideoCode($content['html']);
}
}
$status = UTIL_HtmlTag::autoLink($params["status"]);
$out = NEWSFEED_BOL_Service::getInstance()->addStatus(OW::getUser()->getId(), $params['feedType'], $params['feedId'], $params['visibility'], $status, array("content" => $content, "attachmentId" => $attachId));
$event->setData($out);
}
示例3: addAllGroupFeed
public function addAllGroupFeed()
{
if (OW::getConfig()->getValue('grouprss', 'disablePosting') == '1') {
return;
}
$commentService = BOL_CommentService::getInstance();
$newsfeedService = NEWSFEED_BOL_Service::getInstance();
$router = OW::getRouter();
$displayText = OW::getLanguage()->text('grouprss', 'feed_display_text');
$location = OW::getConfig()->getValue('grouprss', 'postLocation');
include_once 'autoloader.php';
$allFeeds = $this->feeddao->findAll();
foreach ($allFeeds as $feed) {
$simplefeed = new SimplePie();
$simplefeed->set_feed_url($feed->feedUrl);
$simplefeed->set_stupidly_fast(true);
$simplefeed->enable_cache(false);
$simplefeed->init();
$simplefeed->handle_content_type();
$items = $simplefeed->get_items(0, $feed->feedCount);
foreach ($items as $item) {
$content = UTIL_HtmlTag::autoLink($item->get_content());
if ($location == 'wall' && !$this->isDuplicateComment($feed->groupId, $content)) {
$commentService->addComment('groups_wal', $feed->groupId, 'groups', $feed->userId, $content);
}
if (trim($location) == 'newsfeed' && !$this->isDuplicateFeed($feed->groupId, $content)) {
$statusObject = $newsfeedService->saveStatus('groups', (int) $feed->groupId, $content);
$content = UTIL_HtmlTag::autoLink($content);
$action = new NEWSFEED_BOL_Action();
$action->entityId = $statusObject->id;
$action->entityType = "groups-status";
$action->pluginKey = "newsfeed";
$data = array("string" => $content, "content" => "[ph:attachment]", "view" => array("iconClass" => "ow_ic_comment"), "attachment" => array("oembed" => null, "url" => null, "attachId" => null), "data" => array("userId" => $feed->userId), "actionDto" => null, "context" => array("label" => $displayText, "url" => $router->urlForRoute('groups-view', array('groupId' => $feed->groupId))));
$action->data = json_encode($data);
$actionObject = $newsfeedService->saveAction($action);
$activity = new NEWSFEED_BOL_Activity();
$activity->activityType = NEWSFEED_BOL_Service::SYSTEM_ACTIVITY_CREATE;
$activity->activityId = $feed->userId;
$activity->actionId = $actionObject->id;
$activity->privacy = NEWSFEED_BOL_Service::PRIVACY_EVERYBODY;
$activity->userId = $feed->userId;
$activity->visibility = NEWSFEED_BOL_Service::VISIBILITY_FULL;
$activity->timeStamp = time();
$activity->data = json_encode(array());
$activityObject = $newsfeedService->saveActivity($activity);
$newsfeedService->addActivityToFeed($activity, 'groups', $feed->groupId);
}
}
$simplefeed->__destruct();
unset($feed);
}
}
示例4: addComment
/**
* @return BOL_Comment
*/
public function addComment($entityType, $entityId, $pluginKey, $userId, $message, $attachment = null)
{
$commentEntity = $this->commentEntityDao->findByEntityTypeAndEntityId($entityType, $entityId);
if ($commentEntity === null) {
$commentEntity = new BOL_CommentEntity();
$commentEntity->setEntityType(trim($entityType));
$commentEntity->setEntityId((int) $entityId);
$commentEntity->setPluginKey($pluginKey);
$this->commentEntityDao->save($commentEntity);
}
//$message = UTIL_HtmlTag::stripTags($message, $this->configs[self::CONFIG_ALLOWED_TAGS], $this->configs[self::CONFIG_ALLOWED_ATTRS]);
//$message = UTIL_HtmlTag::stripJs($message);
//$message = UTIL_HtmlTag::stripTags($message, array('frame', 'style'), array(), true);
if ($attachment !== null && strlen($message) == 0) {
$message = '';
} else {
$message = UTIL_HtmlTag::autoLink(nl2br(htmlspecialchars($message)));
}
$comment = new BOL_Comment();
$comment->setCommentEntityId($commentEntity->getId());
$comment->setMessage(trim($message));
$comment->setUserId($userId);
$comment->setCreateStamp(time());
if ($attachment !== null) {
$comment->setAttachment($attachment);
}
$this->commentDao->save($comment);
return $comment;
}
示例5: statusUpdate
public function statusUpdate()
{
if (empty($_POST['status']) && empty($_FILES['attachment']["tmp_name"])) {
$this->echoOut($_POST['feedAutoId'], array("error" => OW::getLanguage()->text('base', 'form_validate_common_error_message')));
}
if (!OW::getUser()->isAuthenticated()) {
$this->echoOut($_POST['feedAutoId'], array("error" => "You need to sign in to post."));
}
$status = empty($_POST['status']) ? '' : strip_tags($_POST['status']);
$content = array();
if (!empty($_FILES['attachment']["tmp_name"])) {
try {
$attachment = BOL_AttachmentService::getInstance()->processPhotoAttachment("newsfeed", $_FILES['attachment']);
} catch (InvalidArgumentException $ex) {
$this->echoOut($_POST['feedAutoId'], array("error" => $ex->getMessage()));
}
$content = array("type" => "photo", "url" => $attachment["url"]);
}
$userId = OW::getUser()->getId();
$event = new OW_Event("feed.before_content_add", array("feedType" => $_POST['feedType'], "feedId" => $_POST['feedId'], "visibility" => $_POST['visibility'], "userId" => $userId, "status" => $status, "type" => empty($content["type"]) ? "text" : $content["type"], "data" => $content));
OW::getEventManager()->trigger($event);
$data = $event->getData();
if (!empty($data)) {
$item = empty($data["entityType"]) || empty($data["entityId"]) ? null : array("entityType" => $data["entityType"], "entityId" => $data["entityId"]);
$this->echoOut($_POST['feedAutoId'], array("item" => $item, "message" => empty($data["message"]) ? null : $data["message"], "error" => empty($data["error"]) ? null : $data["error"]));
}
$status = UTIL_HtmlTag::autoLink($status);
$out = NEWSFEED_BOL_Service::getInstance()->addStatus(OW::getUser()->getId(), $_POST['feedType'], $_POST['feedId'], $_POST['visibility'], $status, array("content" => $content, "attachmentId" => $attachment["uid"]));
$this->echoOut($_POST['feedAutoId'], array("item" => $out));
}
示例6: getUserViewQuestions
//.........这里部分代码省略.........
if (!empty($questionData[$userId][$question['name']])) {
switch ($question['presentation']) {
case BOL_QuestionService::QUESTION_PRESENTATION_CHECKBOX:
if ((int) $questionData[$userId][$question['name']] === 1) {
$questionData[$userId][$question['name']] = OW::getLanguage()->text('base', 'yes');
} else {
unset($questionArray[$sectionKey][$questionKey]);
}
break;
case BOL_QuestionService::QUESTION_PRESENTATION_DATE:
$format = OW::getConfig()->getValue('base', 'date_field_format');
$value = 0;
switch ($question['type']) {
case BOL_QuestionService::QUESTION_VALUE_TYPE_DATETIME:
$date = UTIL_DateTime::parseDate($questionData[$userId][$question['name']], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
if (isset($date)) {
$format = OW::getConfig()->getValue('base', 'date_field_format');
$value = mktime(0, 0, 0, $date['month'], $date['day'], $date['year']);
}
break;
case BOL_QuestionService::QUESTION_VALUE_TYPE_SELECT:
$value = (int) $questionData[$userId][$question['name']];
break;
}
if ($format === 'dmy') {
$questionData[$userId][$question['name']] = date("d/m/Y", $value);
} else {
$questionData[$userId][$question['name']] = date("m/d/Y", $value);
}
break;
case BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE:
$date = UTIL_DateTime::parseDate($questionData[$userId][$question['name']], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$questionData[$userId][$question['name']] = UTIL_DateTime::formatBirthdate($date['year'], $date['month'], $date['day']);
break;
case BOL_QuestionService::QUESTION_PRESENTATION_AGE:
$date = UTIL_DateTime::parseDate($questionData[$userId][$question['name']], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$questionData[$userId][$question['name']] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']) . " " . $language->text('base', 'questions_age_year_old');
break;
case BOL_QuestionService::QUESTION_PRESENTATION_RANGE:
$range = explode('-', $questionData[$userId][$question['name']]);
$questionData[$userId][$question['name']] = $language->text('base', 'form_element_from') . " " . $range[0] . " " . $language->text('base', 'form_element_to') . " " . $range[1];
break;
case BOL_QuestionService::QUESTION_PRESENTATION_SELECT:
case BOL_QuestionService::QUESTION_PRESENTATION_RADIO:
case BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX:
$value = "";
$multicheckboxValue = (int) $questionData[$userId][$question['name']];
$parentName = $question['name'];
if (!empty($question['parent'])) {
$parent = BOL_QuestionService::getInstance()->findQuestionByName($question['parent']);
if (!empty($parent)) {
$parentName = $parent->name;
}
}
$questionValues = BOL_QuestionService::getInstance()->findQuestionValues($parentName);
$value = array();
foreach ($questionValues as $val) {
/* @var $val BOL_QuestionValue */
if ((int) $val->value & $multicheckboxValue) {
/* if ( strlen($value) > 0 )
{
$value .= ', ';
}
$value .= $language->text('base', 'questions_question_' . $parentName . '_value_' . ($val->value)); */
$value[$val->value] = BOL_QuestionService::getInstance()->getQuestionValueLang($val->questionName, $val->value);
}
}
if (!empty($value)) {
$questionData[$userId][$question['name']] = $value;
} else {
unset($questionArray[$sectionKey][$questionKey]);
}
break;
case BOL_QuestionService::QUESTION_PRESENTATION_URL:
case BOL_QuestionService::QUESTION_PRESENTATION_TEXT:
case BOL_QuestionService::QUESTION_PRESENTATION_TEXTAREA:
if (!is_string($questionData[$userId][$question['name']])) {
break;
}
$value = trim($questionData[$userId][$question['name']]);
if (strlen($value) > 0) {
$questionData[$userId][$question['name']] = UTIL_HtmlTag::autoLink(nl2br($value));
} else {
unset($questionArray[$sectionKey]);
}
break;
default:
unset($questionArray[$sectionKey][$questionKey]);
}
} else {
unset($questionArray[$sectionKey][$questionKey]);
}
}
if (isset($questionArray[$sectionKey]) && count($questionArray[$sectionKey]) === 0) {
unset($questionArray[$sectionKey]);
}
}
return array('questions' => $questionArray, 'data' => $questionData, 'labels' => $questionLabelList);
}
示例7: renderQuestion
private function renderQuestion($userId, $questionName)
{
$language = OW::getLanguage();
$questionData = BOL_QuestionService::getInstance()->getQuestionData(array($userId), array($questionName));
if (!isset($questionData[$userId][$questionName])) {
return null;
}
$question = BOL_QuestionService::getInstance()->findQuestionByName($questionName);
switch ($question->presentation) {
/*case BOL_QuestionService::QUESTION_PRESENTATION_CHECKBOX:
if ( (int) $questionData[$userId][$question->name] === 1 )
{
$questionData[$userId][$question['name']] = $language->text('base', 'questions_checkbox_value_true');
}
else
{
$questionData[$userId][$question['name']] = $language->text('base', 'questions_checkbox_value_false');
}
break;*/
case BOL_QuestionService::QUESTION_PRESENTATION_DATE:
$format = OW::getConfig()->getValue('base', 'date_field_format');
$value = 0;
switch ($question->type) {
case BOL_QuestionService::QUESTION_VALUE_TYPE_DATETIME:
$date = UTIL_DateTime::parseDate($questionData[$userId][$question->name], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
if (isset($date)) {
$format = OW::getConfig()->getValue('base', 'date_field_format');
$value = mktime(0, 0, 0, $date['month'], $date['day'], $date['year']);
}
break;
case BOL_QuestionService::QUESTION_VALUE_TYPE_SELECT:
$value = (int) $questionData[$userId][$question->name];
break;
}
if ($format === 'dmy') {
$questionData[$userId][$question->name] = date("d/m/Y", $value);
} else {
$questionData[$userId][$question->name] = date("m/d/Y", $value);
}
break;
case BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE:
$date = UTIL_DateTime::parseDate($questionData[$userId][$question->name], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$questionData[$userId][$question->name] = UTIL_DateTime::formatBirthdate($date['year'], $date['month'], $date['day']);
break;
case BOL_QuestionService::QUESTION_PRESENTATION_AGE:
$date = UTIL_DateTime::parseDate($questionData[$userId][$question->name], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
$questionData[$userId][$question->name] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']) . " " . $language->text('base', 'questions_age_year_old');
break;
case BOL_QuestionService::QUESTION_PRESENTATION_RANGE:
$range = explode('-', $questionData[$userId][$question->name]);
$questionData[$userId][$question->name] = $language->text('base', 'form_element_from') . " " . $range[0] . " " . $language->text('base', 'form_element_to') . " " . $range[1];
break;
case BOL_QuestionService::QUESTION_PRESENTATION_SELECT:
case BOL_QuestionService::QUESTION_PRESENTATION_RADIO:
case BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX:
$value = "";
$multicheckboxValue = (int) $questionData[$userId][$question->name];
$questionValues = BOL_QuestionService::getInstance()->findQuestionValues($question->name);
foreach ($questionValues as $val) {
/* @var $val BOL_QuestionValue */
if ((int) $val->value & $multicheckboxValue) {
if (strlen($value) > 0) {
$value .= ', ';
}
$value .= $language->text('base', 'questions_question_' . $question->name . '_value_' . $val->value);
}
}
if (strlen($value) > 0) {
$questionData[$userId][$question->name] = $value;
}
break;
case BOL_QuestionService::QUESTION_PRESENTATION_URL:
case BOL_QuestionService::QUESTION_PRESENTATION_TEXT:
case BOL_QuestionService::QUESTION_PRESENTATION_TEXTAREA:
// googlemap_location shortcut
if ($question->name == "googlemap_location" && !empty($questionData[$userId][$question->name]) && is_array($questionData[$userId][$question->name])) {
$mapData = $questionData[$userId][$question->name];
$value = trim($mapData["address"]);
} else {
$value = trim($questionData[$userId][$question->name]);
}
if (strlen($value) > 0) {
$questionData[$userId][$question->name] = UTIL_HtmlTag::autoLink(nl2br($value));
}
break;
default:
$questionData[$userId][$question->name] = null;
}
return $questionData[$userId][$question->name];
}
示例8: splitLongMessages
public function splitLongMessages($string)
{
return $string;
$split_length = 100;
$delimiter = ' ';
$string_array = explode(' ', $string);
foreach ($string_array as $id => $word) {
if (mb_strlen(trim($word)) > $split_length) {
$originalWord = $word;
$autoLinked = UTIL_HtmlTag::autoLink(trim($word));
if (strlen($autoLinked) != strlen(trim($originalWord))) {
// $str = mb_substr($originalWord, $split_length);
// $str = $this->splitLongMessages($str);
$string_array[$id] = $originalWord;
// '<a href="'.$originalWord.'" target="_blank">'.mb_substr($originalWord, 7, $split_length) . $delimiter . $str."</a>";
} else {
$str = mb_substr($word, $split_length);
$str = $this->splitLongMessages($str);
$string_array[$id] = mb_substr($word, 0, $split_length) . $delimiter . $str;
}
}
}
return implode(' ', $string_array);
}
示例9: statusUpdate
public function statusUpdate()
{
if (empty($_POST['status']) && empty($_FILES['attachment']["tmp_name"])) {
$this->echoOut($_POST['feedAutoId'], array("error" => OW::getLanguage()->text('base', 'form_validate_common_error_message')));
}
if (!OW::getUser()->isAuthenticated()) {
$this->echoOut($_POST['feedAutoId'], array("error" => "You need to sign in to post."));
}
$status = empty($_POST['status']) ? '' : strip_tags($_POST['status']);
$content = array();
if (!empty($_FILES['attachment']["tmp_name"])) {
try {
$attachment = BOL_AttachmentService::getInstance()->processPhotoAttachment($_FILES['attachment']);
} catch (InvalidArgumentException $ex) {
$this->echoOut($_POST['feedAutoId'], array("error" => $ex->getMessage()));
}
$content = array("type" => "photo", "url" => $attachment["url"]);
}
$status = UTIL_HtmlTag::autoLink($status);
$out = NEWSFEED_BOL_Service::getInstance()->addStatus(OW::getUser()->getId(), $_POST['feedType'], $_POST['feedId'], $_POST['visibility'], $status, array("content" => $content, "attachmentId" => $attachment["genId"]));
$this->echoOut($_POST['feedAutoId'], $out);
}
示例10: __construct
public function __construct(array $params)
{
parent::__construct();
$id = $params['videoId'];
$this->clipService = VIDEO_BOL_ClipService::getInstance();
$clip = $this->clipService->findClipById($id);
if (!$clip) {
throw new Redirect404Exception();
}
$contentOwner = (int) $this->clipService->findClipOwner($id);
$language = OW_Language::getInstance();
$description = $clip->description;
$clip->description = UTIL_HtmlTag::autoLink($clip->description);
$this->assign('clip', $clip);
$is_featured = VIDEO_BOL_ClipFeaturedService::getInstance()->isFeatured($clip->id);
$this->assign('featured', $is_featured);
// is moderator
$modPermissions = OW::getUser()->isAuthorized('video');
$this->assign('moderatorMode', $modPermissions);
$userId = OW::getUser()->getId();
$ownerMode = $contentOwner == $userId;
$this->assign('ownerMode', $ownerMode);
if (!$ownerMode && !OW::getUser()->isAuthorized('video', 'view') && !$modPermissions) {
$this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
return;
}
$this->assign('auth_msg', null);
// permissions check
if (!$ownerMode && !$modPermissions) {
$privacyParams = array('action' => 'video_view_video', 'ownerId' => $contentOwner, 'viewerId' => $userId);
$event = new OW_Event('privacy_check_permission', $privacyParams);
OW::getEventManager()->trigger($event);
}
$cmtParams = new BASE_CommentsParams('video', 'video_comments');
$cmtParams->setEntityId($id);
$cmtParams->setOwnerId($contentOwner);
$cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST);
$videoCmts = new BASE_CMP_Comments($cmtParams);
$this->addComponent('comments', $videoCmts);
$videoRates = new BASE_CMP_Rate('video', 'video_rates', $id, $contentOwner);
$this->addComponent('rate', $videoRates);
$videoTags = new BASE_CMP_EntityTagCloud('video');
$videoTags->setEntityId($id);
$videoTags->setRouteName('view_tagged_list');
$this->addComponent('tags', $videoTags);
$this->assign('canEdit', false);
$this->assign('canReport', false);
$this->assign('canMakeFeature', false);
OW::getLanguage()->addKeyForJs('video', 'tb_edit_clip');
OW::getLanguage()->addKeyForJs('video', 'confirm_delete');
OW::getLanguage()->addKeyForJs('video', 'mark_featured');
OW::getLanguage()->addKeyForJs('video', 'remove_from_featured');
OW::getLanguage()->addKeyForJs('base', 'approve');
OW::getLanguage()->addKeyForJs('base', 'disapprove');
$toolbar = array();
$toolbarEvent = new BASE_CLASS_EventCollector('video.collect_video_toolbar_items', array('clipId' => $clip->id, 'clipDto' => $clip));
OW::getEventManager()->trigger($toolbarEvent);
foreach ($toolbarEvent->getData() as $toolbarItem) {
array_push($toolbar, $toolbarItem);
}
if (OW::getUser()->isAuthenticated() && !$ownerMode) {
array_push($toolbar, array('href' => 'javascript://', 'id' => 'btn-video-flag', 'label' => $language->text('base', 'flag')));
$this->assign('canReport', true);
}
if ($ownerMode || $modPermissions) {
array_push($toolbar, array('href' => OW::getRouter()->urlForRoute('edit_clip', array('id' => $clip->id)), 'label' => $language->text('base', 'edit')));
array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-delete', 'label' => $language->text('base', 'delete')));
$this->assign('canEdit', true);
}
if ($modPermissions) {
if ($is_featured) {
array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-mark-featured', 'rel' => 'remove_from_featured', 'label' => $language->text('video', 'remove_from_featured')));
$this->assign('isFeature', true);
} else {
array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-mark-featured', 'rel' => 'mark_featured', 'label' => $language->text('video', 'mark_featured')));
$this->assign('isFeature', false);
}
$this->assign('canMakeFeature', true);
/*
if ( $clip->status == 'approved' )
{
array_push($toolbar, array(
'href' => 'javascript://',
'id' => 'clip-set-approval-staus',
'rel' => 'disapprove',
'label' => $language->text('base', 'disapprove')
));
}
else
{
array_push($toolbar, array(
'href' => 'javascript://',
'id' => 'clip-set-approval-staus',
'rel' => 'approve',
'label' => $language->text('base', 'approve')
));
}
*/
}
$this->assign('toolbar', $toolbar);
//.........这里部分代码省略.........
示例11: smarty_modifier_autolink
/**
* Smarty date modifier.
*
* @author Kambalin Sergey <greyexpert@gmail.com>
* @package ow.ow_smarty.plugin
* @since 1.0
*/
function smarty_modifier_autolink($string)
{
return UTIL_HtmlTag::autoLink($string);
}
示例12: addQuestion
public function addQuestion()
{
if (!OW::getRequest()->isAjax()) {
throw new Redirect404Exception();
}
if (!OW::getUser()->isAuthenticated()) {
echo json_encode(false);
exit;
}
if (empty($_POST['question'])) {
echo json_encode(false);
exit;
}
$question = empty($_POST['question']) ? '' : strip_tags($_POST['question']);
$question = UTIL_HtmlTag::autoLink($question);
$answers = empty($_POST['answers']) ? array() : array_filter($_POST['answers'], 'trim');
$allowAddOprions = !empty($_POST['allowAddOprions']);
$userId = OW::getUser()->getId();
$questionDto = $this->service->addQuestion($userId, $question, array('allowAddOprions' => $allowAddOprions));
foreach ($answers as $ans) {
$this->service->addOption($questionDto->id, $userId, $ans);
}
$event = new OW_Event('feed.action', array('entityType' => QUESTIONS_BOL_Service::ENTITY_TYPE, 'entityId' => $questionDto->id, 'pluginKey' => 'questions', 'userId' => $userId, 'visibility' => 15));
OW::getEventManager()->trigger($event);
$activityList = QUESTIONS_BOL_FeedService::getInstance()->findMainActivity(time(), array($questionDto->id), array(0, 6));
$cmp = new QUESTIONS_CMP_FeedItem($questionDto, reset($activityList[$questionDto->id]), $activityList[$questionDto->id]);
$html = $cmp->render();
$script = OW::getDocument()->getOnloadScript();
echo json_encode(array('markup' => array('html' => $html, 'script' => $script, 'position' => 'prepend')));
exit;
}
示例13: view
public function view($params)
{
$event = $this->getEventForParams($params);
$cmpId = UTIL_HtmlTag::generateAutoId('cmp');
$this->assign('contId', $cmpId);
$language = OW::getLanguage();
if (!OW::getUser()->isAuthorized('eventx', 'view_event') && $event->getUserId() != OW::getUser()->getId()) {
$this->assign('authErrorText', OW::getLanguage()->text('eventx', 'event_view_permission_error_message'));
return;
}
// guest gan't view private events
if ((int) $event->getWhoCanView() === EVENTX_BOL_EventService::CAN_VIEW_INVITATION_ONLY && !OW::getUser()->isAuthenticated()) {
$this->redirect(OW::getRouter()->urlForRoute('eventx.private_event', array('eventId' => $event->getId())));
}
$eventInvite = $this->eventService->findEventInvite($event->getId(), OW::getUser()->getId());
$eventUser = $this->eventService->findEventUser($event->getId(), OW::getUser()->getId());
// check if user can view event
if ((int) $event->getWhoCanView() === EVENTX_BOL_EventService::CAN_VIEW_INVITATION_ONLY && $eventUser === null && $eventInvite === null && !OW::getUser()->isAuthorized('eventx')) {
$this->redirect(OW::getRouter()->urlForRoute('eventx.private_event', array('eventId' => $event->getId())));
}
$modPermissions = OW::getUser()->isAuthorized('eventx');
$ownerMode = $event->getUserId() == OW::getUser()->getId();
$whoCanDeleteEvent = explode(",", OW::getConfig()->getValue('eventx', 'eventDelete'));
$toolbar = array();
if (OW::getUser()->isAuthenticated()) {
array_push($toolbar, array('href' => 'javascript://', 'id' => 'btn-eventx-flag', 'label' => OW::getLanguage()->text('base', 'flag')));
}
if ($ownerMode || $modPermissions) {
array_push($toolbar, array('href' => OW::getRouter()->urlForRoute('eventx.edit', array('eventId' => $event->getId())), 'label' => OW::getLanguage()->text('eventx', 'edit_button_label')));
}
if ($modPermissions) {
if ($event->status == 'approved') {
array_push($toolbar, array('href' => 'javascript://', 'id' => 'eventx-set-approval-staus', 'rel' => 'disapprove', 'label' => $language->text('base', 'disapprove')));
} else {
array_push($toolbar, array('href' => 'javascript://', 'id' => 'eventx-set-approval-staus', 'rel' => 'approve', 'label' => $language->text('base', 'approve')));
}
}
$canDelete = FALSE;
if ($ownerMode && in_array(3, $whoCanDeleteEvent)) {
$canDelete = TRUE;
}
if (OW::getUser()->isAuthorized('eventx') && in_array(2, $whoCanDeleteEvent)) {
$canDelete = TRUE;
}
if (OW::getUser()->isAdmin() && in_array(1, $whoCanDeleteEvent)) {
$canDelete = TRUE;
}
if ($canDelete) {
array_push($toolbar, array('href' => 'javascript://', 'id' => 'eventx-delete', 'label' => OW::getLanguage()->text('eventx', 'delete_button_label')));
}
$this->assign('toolbar', $toolbar);
OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'eventx', 'main_menu_item');
$this->setPageHeading($event->getTitle());
$this->setPageTitle(OW::getLanguage()->text('eventx', 'event_view_page_heading', array('event_title' => $event->getTitle())));
$this->setPageHeadingIconClass('ow_ic_calendar');
OW::getDocument()->setDescription(UTIL_String::truncate(strip_tags($event->getDescription()), 200, '...'));
$maxInvites = $event->getMaxInvites();
$currentInvites = $this->eventService->findEventUsersCount($event->getId(), EVENTX_BOL_EventService::USER_STATUS_YES);
$isFullyBooked = $currentInvites >= $maxInvites && $maxInvites > 0;
$infoArray = array('id' => $event->getId(), 'image' => $event->getImage() ? $this->eventService->generateImageUrl($event->getImage(), false) : null, 'date' => $this->eventService->formatSimpleDate($event->getStartTimeStamp(), $event->getStartTimeDisable()), 'endDate' => $event->getEndTimeStamp() === null || !$event->getEndDateFlag() ? null : $this->eventService->formatSimpleDate($event->getEndTimeDisable() ? strtotime("-1 day", $event->getEndTimeStamp()) : $event->getEndTimeStamp(), $event->getEndTimeDisable()), 'location' => $event->getLocation(), 'desc' => UTIL_HtmlTag::autoLink($event->getDescription()), 'title' => $event->getTitle(), 'maxInvites' => $maxInvites, 'currentInvites' => $currentInvites, 'availableInvites' => $maxInvites - $currentInvites, 'creatorName' => BOL_UserService::getInstance()->getDisplayName($event->getUserId()), 'creatorLink' => BOL_UserService::getInstance()->getUserUrl($event->getUserId()));
$this->assign('info', $infoArray);
// event attend form
if (OW::getUser()->isAuthenticated() && $event->getEndTimeStamp() > time()) {
if ($eventUser !== null) {
$this->assign('currentStatus', OW::getLanguage()->text('eventx', 'user_status_label_' . $eventUser->getStatus()));
}
$this->addForm(new AttendForm($event->getId(), $cmpId));
$onloadJs = "\n var \$context = \$('#" . $cmpId . "');";
$onloadJs .= " \$('#event_attend_yes_btn').click(\n function(){\n \$('input[name=attend_status]', \$context).val(" . EVENTX_BOL_EventService::USER_STATUS_YES . ");\n }\n );\n \n \$('#event_attend_maybe_btn').click(\n function(){\n \$('input[name=attend_status]', \$context).val(" . EVENTX_BOL_EventService::USER_STATUS_MAYBE . ");\n }\n );\n \$('#event_attend_no_btn').click(\n function(){\n \$('input[name=attend_status]', \$context).val(" . EVENTX_BOL_EventService::USER_STATUS_NO . ");\n }\n );\n\n \$('.current_status a', \$context).click(\n function(){\n \$('.attend_buttons .buttons', \$context).fadeIn(500);\n }\n );\n ";
OW::getDocument()->addOnloadScript($onloadJs);
} else {
$this->assign('no_attend_form', true);
}
if ($event->getEndTimeStamp() > time() && ((int) $event->getUserId() === OW::getUser()->getId() || (int) $event->getWhoCanInvite() === EVENTX_BOL_EventService::CAN_INVITE_PARTICIPANT && $eventUser !== null)) {
$params = array($event->id);
$this->assign('inviteLink', true);
OW::getDocument()->addOnloadScript("\n var eventFloatBox;\n \$('#inviteLink', \$('#" . $cmpId . "')).click(\n function(){\n eventFloatBox = OW.ajaxFloatBox('EVENTX_CMP_InviteUserListSelect', " . json_encode($params) . ", {width:600, height:400, iconClass: 'ow_ic_user', title: '" . OW::getLanguage()->text('eventx', 'friends_invite_button_label') . "'});\n }\n );\n OW.bind('base.avatar_user_list_select',\n function(list){\n eventFloatBox.close();\n \$.ajax({\n type: 'POST',\n url: " . json_encode(OW::getRouter()->urlFor('EVENTX_CTRL_Base', 'inviteResponder')) . ",\n data: 'eventId=" . json_encode($event->getId()) . "&userIdList='+JSON.stringify(list),\n dataType: 'json',\n success : function(data){\n if( data.messageType == 'error' ){\n OW.error(data.message);\n }\n else{\n OW.info(data.message);\n }\n },\n error : function( XMLHttpRequest, textStatus, errorThrown ){\n OW.error(textStatus);\n }\n });\n }\n );\n ");
}
$cmntParams = new BASE_CommentsParams('eventx', 'eventx');
$cmntParams->setEntityId($event->getId());
$cmntParams->setOwnerId($event->getUserId());
$this->addComponent('comments', new BASE_CMP_Comments($cmntParams));
$this->addComponent('userListCmp', new EVENTX_CMP_EventUsers($event->getId()));
$tagCloud = new BASE_CMP_EntityTagCloud('eventx');
$tagCloud->setEntityId($event->id);
$tagCloud->setRouteName('eventx_view_tagged_list');
$this->addComponent('tagCloud', $tagCloud);
OW::getDocument()->addScript(OW::getPluginManager()->getPlugin("eventx")->getStaticJsUrl() . 'eventx.js');
OW::getDocument()->addScript("http://maps.google.com/maps/api/js?sensor=false");
OW::getDocument()->addScript(OW::getPluginManager()->getPlugin("eventx")->getStaticJsUrl() . 'jquery.gmap.min.js');
$objParams = array('ajaxResponder' => $this->ajaxResponder, 'id' => $event->getId(), 'txtDelConfirm' => $language->text('eventx', 'confirm_delete'), 'txtApprove' => $language->text('base', 'approve'), 'txtDisapprove' => $language->text('base', 'disapprove'));
$script = "\$(document).ready(function(){\n var item = new eventxItem( " . json_encode($objParams) . ");\n });";
OW::getDocument()->addOnloadScript($script);
$js = UTIL_JsGenerator::newInstance()->jQueryEvent('#btn-eventx-flag', 'click', 'OW.flagContent(e.data.entity, e.data.id, e.data.title, e.data.href, "eventx+flags");', array('e'), array('entity' => 'eventx_event', 'id' => $event->getId(), 'title' => $event->getTitle(), 'href' => OW::getRouter()->urlForRoute('eventx.view', array('eventId' => $event->getId()))));
OW::getDocument()->addOnloadScript($js, 1001);
$categoryList = $this->eventService->getItemCategories($event->id);
$i = 0;
$categoryUrlList = array();
foreach ($categoryList as $category) {
$catName = $this->eventService->getCategoryName($category->categoryId);
//.........这里部分代码省略.........
示例14: view
/**
* Video view action
*
* @param array $params
* @throws Redirect404Exception
*/
public function view(array $params)
{
if (!isset($params['id']) || !($id = (int) $params['id'])) {
throw new Redirect404Exception();
}
$clip = $this->clipService->findClipById($id);
if (!$clip) {
throw new Redirect404Exception();
}
$userId = OW::getUser()->getId();
$contentOwner = (int) $this->clipService->findClipOwner($id);
$ownerMode = $contentOwner == $userId;
// is moderator
$modPermissions = OW::getUser()->isAuthorized('video');
if ($clip->status != "approved" && !($modPermissions || $ownerMode)) {
throw new Redirect403Exception();
}
$language = OW_Language::getInstance();
$description = $clip->description;
$clip->description = UTIL_HtmlTag::autoLink($clip->description);
$this->assign('clip', $clip);
$is_featured = VIDEO_BOL_ClipFeaturedService::getInstance()->isFeatured($clip->id);
$this->assign('featured', $is_featured);
$this->assign('moderatorMode', $modPermissions);
$this->assign('ownerMode', $ownerMode);
if (!$ownerMode && !OW::getUser()->isAuthorized('video', 'view') && !$modPermissions) {
$error = BOL_AuthorizationService::getInstance()->getActionStatus('video', 'view');
throw new AuthorizationException($error['msg']);
}
// permissions check
if (!$ownerMode && !$modPermissions) {
$privacyParams = array('action' => 'video_view_video', 'ownerId' => $contentOwner, 'viewerId' => $userId);
$event = new OW_Event('privacy_check_permission', $privacyParams);
OW::getEventManager()->trigger($event);
}
$cmtParams = new BASE_CommentsParams('video', 'video_comments');
$cmtParams->setEntityId($id);
$cmtParams->setOwnerId($contentOwner);
$cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST);
$cmtParams->setAddComment($clip->status == "approved");
$videoCmts = new BASE_CMP_Comments($cmtParams);
$this->addComponent('comments', $videoCmts);
if ($clip->status == "approved") {
$videoRates = new BASE_CMP_Rate('video', 'video_rates', $id, $contentOwner);
$this->addComponent('rate', $videoRates);
}
$videoTags = new BASE_CMP_EntityTagCloud('video');
$videoTags->setEntityId($id);
$videoTags->setRouteName('view_tagged_list');
$this->addComponent('tags', $videoTags);
$username = BOL_UserService::getInstance()->getUserName($clip->userId);
$this->assign('username', $username);
$displayName = BOL_UserService::getInstance()->getDisplayName($clip->userId);
$this->assign('displayName', $displayName);
OW::getDocument()->addScript($this->pluginJsUrl . 'video.js');
$objParams = array('ajaxResponder' => $this->ajaxResponder, 'clipId' => $id, 'txtDelConfirm' => OW::getLanguage()->text('video', 'confirm_delete'), 'txtMarkFeatured' => OW::getLanguage()->text('video', 'mark_featured'), 'txtRemoveFromFeatured' => OW::getLanguage()->text('video', 'remove_from_featured'), 'txtApprove' => OW::getLanguage()->text('base', 'approve'), 'txtDisapprove' => OW::getLanguage()->text('base', 'disapprove'));
$script = "\$(document).ready(function(){\n var clip = new videoClip( " . json_encode($objParams) . ");\n }); ";
OW::getDocument()->addOnloadScript($script);
$pendingApprovalString = "";
if ($clip->status != "approved") {
$pendingApprovalString = '<span class="ow_remark ow_small">(' . OW::getLanguage()->text("base", "pending_approval") . ')</span>';
}
OW::getDocument()->setHeading($clip->title . " " . $pendingApprovalString);
OW::getDocument()->setHeadingIconClass('ow_ic_video');
$toolbar = array();
$toolbarEvent = new BASE_CLASS_EventCollector('video.collect_video_toolbar_items', array('clipId' => $clip->id, 'clipDto' => $clip));
OW::getEventManager()->trigger($toolbarEvent);
foreach ($toolbarEvent->getData() as $toolbarItem) {
array_push($toolbar, $toolbarItem);
}
if ($clip->status == "approved" && OW::getUser()->isAuthenticated() && !$ownerMode) {
array_push($toolbar, array('href' => 'javascript://', 'id' => 'btn-video-flag', 'label' => $language->text('base', 'flag')));
}
if ($ownerMode || $modPermissions) {
array_push($toolbar, array('href' => OW::getRouter()->urlForRoute('edit_clip', array('id' => $clip->id)), 'label' => $language->text('base', 'edit')));
array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-delete', 'label' => $language->text('base', 'delete')));
}
if ($modPermissions) {
if ($is_featured) {
array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-mark-featured', 'rel' => 'remove_from_featured', 'label' => $language->text('video', 'remove_from_featured')));
} else {
array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-mark-featured', 'rel' => 'mark_featured', 'label' => $language->text('video', 'mark_featured')));
}
if ($clip->status != 'approved') {
array_push($toolbar, array('href' => OW::getRouter()->urlFor(__CLASS__, "approve", array("clipId" => $clip->id)), 'label' => $language->text('base', 'approve'), "class" => "ow_green"));
}
}
$this->assign('toolbar', $toolbar);
$js = UTIL_JsGenerator::newInstance()->jQueryEvent('#btn-video-flag', 'click', 'OW.flagContent(e.data.entity, e.data.id);', array('e'), array('entity' => VIDEO_BOL_ClipService::ENTITY_TYPE, 'id' => $clip->id));
OW::getDocument()->addOnloadScript($js, 1001);
OW::getDocument()->setTitle($language->text('video', 'meta_title_video_view', array('title' => $clip->title)));
$tagsArr = BOL_TagService::getInstance()->findEntityTags($clip->id, 'video');
$labels = array();
foreach ($tagsArr as $t) {
//.........这里部分代码省略.........
示例15: conversation
//.........这里部分代码省略.........
$conversationArray['userId'] = $conversation->interlocutorId;
if ($lastMessages->initiatorMessageId > $lastMessages->interlocutorMessageId) {
$conversationArray['isOpponentLastMessage'] = true;
}
break;
default:
throw new Redirect403Exception();
}
$avatarList = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($conversationArray['userId'], $conversationArray['opponentId']));
$displayNames = $userService->getDisplayNamesForList(array($userId, $conversationArray['opponentId']));
$conversationArray['opponentDisplayName'] = $displayNames[$conversationArray['opponentId']];
$conversationArray['userDisplayName'] = $displayNames[$conversationArray['userId']];
$userNames = $userService->getDisplayNamesForList(array($conversationArray['userId'], $conversationArray['opponentId']));
$conversationArray['opponentName'] = $userNames[$conversationArray['opponentId']];
$conversationArray['userName'] = $userNames[$conversationArray['userId']];
$conversationArray['opponentUrl'] = $userService->getUserUrl($conversationArray['opponentId'], $conversationArray['opponentName']);
$conversationArray['userUrl'] = $userService->getUserUrl($conversationArray['userId'], $conversationArray['userName']);
$messages = $conversationService->getConversationMessagesList($conversationId);
$messageList = array();
$messageIdList = array();
$trackConvView = false;
foreach ($messages as $value) {
$messageIdList[] = $value->id;
$message = array();
$message['id'] = $value->id;
$message['senderId'] = $value->senderId;
$message['recipientId'] = $value->recipientId;
$message['recipientRead'] = $value->recipientRead;
$message['senderDisplayName'] = $value->senderId == $userId ? $conversationArray['userDisplayName'] : $conversationArray['opponentDisplayName'];
$message['senderName'] = $value->senderId == $userId ? $conversationArray['userName'] : $conversationArray['opponentName'];
$message['senderUrl'] = $userService->getUserUrl($value->senderId, $message['senderName']);
$message['timeStamp'] = UTIL_DateTime::formatDate((int) $value->timeStamp);
$message['toolbar'] = array();
$isReadable = false;
if ($value->senderId == $userId || $message['recipientRead']) {
$isReadable = true;
} else {
if (OW::getUser()->isAuthorized('mailbox', 'read_message')) {
// check credits
$eventParams = array('pluginKey' => 'mailbox', 'action' => 'read_message');
$credits = OW::getEventManager()->call('usercredits.check_balance', $eventParams);
if ($credits === false) {
$creditsMsg = OW::getEventManager()->call('usercredits.error_message', $eventParams);
$message['content'] = '<span class="error">' . $creditsMsg . '</span>';
} else {
$conversationService->markMessageRead($value->id);
$isReadable = true;
$trackConvView = true;
}
} else {
$message['content'] = '<span class="error">' . $language->text('mailbox', 'read_permission_denied') . '</span>';
}
}
if ($isReadable) {
$message['content'] = UTIL_HtmlTag::autoLink($value->text);
//TODO: Insert text formatter
$event = new OW_Event('mailbox.message_render', array('conversationId' => $conversationId, 'messageId' => $message['id'], 'senderId' => $message['senderId'], 'recipientId' => $message['recipientId']), array('short' => '', 'full' => $message['content']));
OW::getEventManager()->trigger($event);
$eventData = $event->getData();
$message['content'] = $eventData['full'];
}
$message['isReadableMessage'] = $isReadable;
$messageList[] = $message;
}
if ($trackConvView) {
if (isset($credits) && $credits === true) {
$eventParams = array('pluginKey' => 'mailbox', 'action' => 'read_message', 'extra' => array('layer_check' => true, 'senderId' => $conversationArray['userId'], 'recipientId' => $conversationArray['opponentId']));
OW::getEventManager()->call('usercredits.track_action', $eventParams);
}
// message read event triggered
$event = new OW_Event('mailbox.message_read', array('conversationId' => $conversationId, 'userId' => $userId));
OW::getEventManager()->trigger($event);
}
$attachments = $conversationService->findAttachmentsByMessageIdList($messageIdList);
$attachmentList = array();
foreach ($attachments as $attachment) {
$ext = UTIL_File::getExtension($attachment->fileName);
$attachmentPath = $conversationService->getAttachmentFilePath($attachment->id, $attachment->hash, $ext);
$list = array();
$list['id'] = $attachment->id;
$list['messageId'] = $attachment->messageId;
$list['downloadUrl'] = OW::getStorage()->getFileUrl($attachmentPath);
$list['fileName'] = $attachment->fileName;
$list['fileSize'] = $attachment->fileSize;
$attachmentList[$attachment->messageId][$attachment->id] = $list;
}
$this->assign('attachmentList', $attachmentList);
$this->assign('messageList', $messageList);
$this->assign('conversation', $conversationArray);
$this->assign('writeMessage', OW::getUser()->isAuthorized('mailbox', 'send_message'));
$this->assign('avatars', $avatarList);
$configs = OW::getConfig()->getValues('mailbox');
$this->assign('enableAttachments', !empty($configs['enable_attachments']));
//include js
$deleteConfirmMessage = $language->text('mailbox', 'delete_confirm_message');
$onLoadJs = " \$(document).ready(function(){\n\t\t\t\t\t\tvar conversation = new mailboxConversation( " . json_encode(array('responderUrl' => $this->responderUrl, 'deleteConfirmMessage' => $deleteConfirmMessage)) . " );\n\t\t\t\t\t}); ";
OW::getDocument()->addOnloadScript($onLoadJs);
OW::getDocument()->addScript($this->jsDirUrl . "mailbox.js");
OW::getDocument()->setTitle($language->text('mailbox', 'conversation_meta_tilte', array('conversation_title' => $conversation->subject)));
}