Example #1
0
 /**
  * Returns an instance of class (singleton pattern implementation).
  *
  * @return BOL_TextFormatService
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Example #2
0
 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);
 }
Example #3
0
 public function initJs()
 {
     $js = UTIL_JsGenerator::newInstance();
     $code = BOL_TextFormatService::getInstance()->addVideoCodeParam($this->oembed["html"], "autoplay", 1);
     $code = BOL_TextFormatService::getInstance()->addVideoCodeParam($code, "play", 1);
     $js->addScript('$(".ow_oembed_video_cover", "#" + {$uniqId}).click(function() { ' . '$(".two_column", "#" + {$uniqId}).addClass("ow_video_playing"); ' . '$(".attachment_left", "#" + {$uniqId}).html({$embed});' . 'OW.trigger("base.comment_video_play", {});' . 'return false; });', array("uniqId" => $this->uniqId, "embed" => $code));
     OW::getDocument()->addOnloadScript($js);
 }
Example #4
0
 public function __construct($entityType, $entityId, $displayType, $pluginKey, $ownerId, $commentCountOnPage, $id, $cmpContextId, $formName)
 {
     parent::__construct();
     $language = OW::getLanguage();
     //comment form init
     $form = new Form($formName);
     $textArea = new Textarea('commentText');
     $form->addElement($textArea);
     $entityTypeField = new HiddenField('entityType');
     $form->addElement($entityTypeField);
     $entityIdField = new HiddenField('entityId');
     $form->addElement($entityIdField);
     $displayTypeField = new HiddenField('displayType');
     $form->addElement($displayTypeField);
     $pluginKeyField = new HiddenField('pluginKey');
     $form->addElement($pluginKeyField);
     $ownerIdField = new HiddenField('ownerId');
     $form->addElement($ownerIdField);
     $attch = new HiddenField('attch');
     $form->addElement($attch);
     $cid = new HiddenField('cid');
     $form->addElement($cid);
     $commentsOnPageField = new HiddenField('commentCountOnPage');
     $form->addElement($commentsOnPageField);
     $submit = new Submit('comment-submit');
     $submit->setValue($language->text('base', 'comment_add_submit_label'));
     $form->addElement($submit);
     $form->getElement('entityType')->setValue($entityType);
     $form->getElement('entityId')->setValue($entityId);
     $form->getElement('displayType')->setValue($displayType);
     $form->getElement('pluginKey')->setValue($pluginKey);
     $form->getElement('ownerId')->setValue($ownerId);
     $form->getElement('cid')->setValue($id);
     $form->getElement('commentCountOnPage')->setValue($commentCountOnPage);
     $form->setAjax(true);
     $form->setAction(OW::getRouter()->urlFor('BASE_CTRL_Comments', 'addComment'));
     $form->bindJsFunction(Form::BIND_SUBMIT, "function(){ \$('#comments-" . $id . " .comments-preloader').show();}");
     $form->bindJsFunction(Form::BIND_SUCCESS, "function(){ \$('#comments-" . $id . " .comments-preloader').hide();}");
     $this->addForm($form);
     if (BOL_TextFormatService::getInstance()->isCommentsRichMediaAllowed()) {
         $attachmentCmp = new BASE_CLASS_Attachment($id);
         $this->addComponent('attachment', $attachmentCmp);
     }
     OW::getDocument()->addOnloadScript("owCommentCmps['{$id}'].initForm('" . $form->getElement('commentText')->getId() . "', '" . $form->getElement('attch')->getId() . "');");
     $this->assign('form', true);
     $this->assign('id', $id);
     if (OW::getUser()->isAuthenticated()) {
         $currentUserInfo = BOL_AvatarService::getInstance()->getDataForUserAvatars(array(OW::getUser()->getId()));
         $this->assign('currentUserInfo', $currentUserInfo[OW::getUser()->getId()]);
     }
 }
Example #5
0
 public function addComment()
 {
     $errorMessage = false;
     $isMobile = !empty($_POST['isMobile']) && (bool) $_POST['isMobile'];
     $params = $this->getParamsObject();
     if (empty($_POST['commentText']) && empty($_POST['attachmentInfo']) && empty($_POST['oembedInfo'])) {
         $errorMessage = OW::getLanguage()->text('base', 'comment_required_validator_message');
     } else {
         if (!OW::getUser()->isAuthorized($params->getPluginKey(), 'add_comment')) {
             $status = BOL_AuthorizationService::getInstance()->getActionStatus($params->getPluginKey(), 'add_comment');
             $errorMessage = $status['msg'];
         } else {
             if (BOL_UserService::getInstance()->isBlocked(OW::getUser()->getId(), $params->getOwnerId())) {
                 $errorMessage = OW::getLanguage()->text('base', 'user_block_message');
             }
         }
     }
     if ($errorMessage) {
         exit(json_encode(array('error' => $errorMessage)));
     }
     $commentText = empty($_POST['commentText']) ? '' : trim($_POST['commentText']);
     $attachment = null;
     if (BOL_TextFormatService::getInstance()->isCommentsRichMediaAllowed() && !$isMobile) {
         if (!empty($_POST['attachmentInfo'])) {
             $tempArr = json_decode($_POST['attachmentInfo'], true);
             OW::getEventManager()->call('base.attachment_save_image', array('uid' => $tempArr['uid'], 'pluginKey' => $tempArr['pluginKey']));
             $tempArr['href'] = $tempArr['url'];
             $tempArr['type'] = 'photo';
             $attachment = json_encode($tempArr);
         } else {
             if (!empty($_POST['oembedInfo'])) {
                 $tempArr = json_decode($_POST['oembedInfo'], true);
                 // add some actions
                 $attachment = json_encode($tempArr);
             }
         }
     }
     $comment = $this->commentService->addComment($params->getEntityType(), $params->getEntityId(), $params->getPluginKey(), OW::getUser()->getId(), $commentText, $attachment);
     // trigger event comment add
     $event = new OW_Event('base_add_comment', array('entityType' => $params->getEntityType(), 'entityId' => $params->getEntityId(), 'userId' => OW::getUser()->getId(), 'commentId' => $comment->getId(), 'pluginKey' => $params->getPluginKey(), 'attachment' => json_decode($attachment, true)));
     OW::getEventManager()->trigger($event);
     BOL_AuthorizationService::getInstance()->trackAction($params->getPluginKey(), 'add_comment');
     if ($isMobile) {
         $commentListCmp = new BASE_MCMP_CommentsList($params, $_POST['cid']);
     } else {
         $commentListCmp = new BASE_CMP_CommentsList($params, $_POST['cid']);
     }
     exit(json_encode(array('newAttachUid' => $this->commentService->generateAttachmentUid($params->getEntityType(), $params->getEntityId()), 'entityType' => $params->getEntityType(), 'entityId' => $params->getEntityId(), 'commentList' => $commentListCmp->render(), 'onloadScript' => OW::getDocument()->getOnloadScript(), 'commentCount' => $this->commentService->findCommentCount($params->getEntityType(), $params->getEntityId()))));
 }
Example #6
0
 public function onBeforeRender()
 {
     parent::onBeforeRender();
     $uniqId = uniqid("vf-");
     $this->assign("uniqId", $uniqId);
     $defaults = array("image" => null, "iconClass" => null, "title" => '', "description" => '', "status" => null, "url" => null, "embed" => '');
     $tplVars = array_merge($defaults, $this->vars);
     $tplVars["url"] = $this->getUrl($tplVars["url"]);
     $tplVars['blankImg'] = OW::getThemeManager()->getCurrentTheme()->getStaticUrl() . 'mobile/images/1px.png';
     $this->assign('vars', $tplVars);
     if ($tplVars['embed']) {
         $js = UTIL_JsGenerator::newInstance();
         $code = BOL_TextFormatService::getInstance()->addVideoCodeParam($tplVars['embed'], "autoplay", 1);
         $code = BOL_TextFormatService::getInstance()->addVideoCodeParam($code, "play", 1);
         $js->addScript('$(".ow_oembed_video_cover", "#" + {$uniqId}).click(function() { ' . '$("#" + {$uniqId}).addClass("ow_video_playing"); ' . '$(".ow_newsfeed_item_picture", "#" + {$uniqId}).html({$embed});' . 'return false; });', array("uniqId" => $uniqId, "embed" => $code));
         OW::getDocument()->addOnloadScript($js);
     }
 }
Example #7
0
 /**
  * Default action
  */
 public function index()
 {
     $language = OW::getLanguage();
     $clipService = VIDEO_BOL_ClipService::getInstance();
     $userId = OW::getUser()->getId();
     if (!OW::getUser()->isAuthorized('video', 'add')) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     $eventParams = array('pluginKey' => 'video', 'action' => 'add_video');
     $credits = OW::getEventManager()->call('usercredits.check_balance', $eventParams);
     if ($credits === false) {
         $this->assign('auth_msg', OW::getEventManager()->call('usercredits.error_message', $eventParams));
     } else {
         if (!($clipService->findUserClipsCount($userId) <= $clipService->getUserQuotaConfig())) {
             $this->assign('auth_msg', $language->text('video', 'quota_exceeded', array('limit' => $clipService->getUserQuotaConfig())));
         } else {
             $this->assign('auth_msg', null);
             $videoAddForm = new videoAddForm();
             $this->addForm($videoAddForm);
             if (OW::getRequest()->isPost() && $videoAddForm->isValid($_POST)) {
                 $values = $videoAddForm->getValues();
                 $code = $clipService->validateClipCode($values['code']);
                 if (!BOL_TextFormatService::getInstance()->isCodeResourceValid($code)) {
                     OW::getFeedback()->warning($language->text('video', 'resource_not_allowed'));
                     $this->redirect();
                 }
                 $res = $videoAddForm->process();
                 OW::getFeedback()->info($language->text('video', 'clip_added'));
                 $this->redirect(OW::getRouter()->urlForRoute('view_clip', array('id' => $res['id'])));
             }
         }
     }
     if (!OW::getRequest()->isAjax()) {
         OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'video', 'video');
     }
     OW::getDocument()->setHeading($language->text('video', 'page_title_add_video'));
     OW::getDocument()->setHeadingIconClass('ow_ic_video');
     OW::getDocument()->setTitle($language->text('video', 'meta_title_video_add'));
     OW::getDocument()->setDescription($language->text('video', 'meta_description_video_add'));
 }
Example #8
0
 public function import()
 {
     if (!OW::getRequest()->isPost()) {
         throw new Redirect404Exception();
     }
     $spVideoAddForm = new spVideoAddForm();
     if ($spVideoAddForm->isValid($_POST)) {
         $language = OW::getLanguage();
         $values = $spVideoAddForm->getValues();
         $code = VIDEO_BOL_ClipService::getInstance()->validateClipCode($values['code']);
         if (!BOL_TextFormatService::getInstance()->isCodeResourceValid($code)) {
             OW::getFeedback()->warning($language->text('video', 'resource_not_allowed'));
             $this->redirect(OW::getRouter()->urlFor('VIDEO_CTRL_Add', 'index'));
         }
         $res = $spVideoAddForm->process();
         OW::getFeedback()->info($language->text('video', 'clip_added'));
         $this->redirect(OW::getRouter()->urlForRoute('view_clip', array('id' => $res['id'])));
     } else {
         $this->redirect(OW::getRouter()->urlFor('VIDEO_CTRL_Add', 'index'));
     }
 }
Example #9
0
 public function statusUpdate()
 {
     if (empty($_POST['status']) && empty($_POST['attachment'])) {
         echo json_encode(array("error" => OW::getLanguage()->text('base', 'form_validate_common_error_message')));
         exit;
     }
     if (!OW::getUser()->isAuthenticated()) {
         echo json_encode(false);
         exit;
     }
     $oembed = null;
     $attachId = null;
     $status = empty($_POST['status']) ? '' : strip_tags($_POST['status']);
     $content = array();
     if (!empty($_POST['attachment'])) {
         $content = json_decode($_POST['attachment'], true);
         if (!empty($content)) {
             if ($content['type'] == 'photo' && !empty($content['uid'])) {
                 $attachmentData = OW::getEventManager()->call('base.attachment_save_image', array("pluginKey" => "newsfeed", 'uid' => $content['uid']));
                 $content['url'] = $content['href'] = $attachmentData["url"];
                 $attachId = $content['uid'];
             }
             if ($content['type'] == 'video') {
                 $content['html'] = BOL_TextFormatService::getInstance()->validateVideoCode($content['html']);
             }
         }
     }
     $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)) {
         if (!empty($attachId)) {
             BOL_AttachmentService::getInstance()->deleteAttachmentByBundle("newsfeed", $attachId);
         }
         $item = empty($data["entityType"]) || empty($data["entityId"]) ? null : array("entityType" => $data["entityType"], "entityId" => $data["entityId"]);
         echo json_encode(array("item" => $item, "message" => empty($data["message"]) ? null : $data["message"], "error" => empty($data["error"]) ? null : $data["error"]));
         exit;
     }
     $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" => $attachId));
     echo json_encode(array("item" => $out));
     exit;
 }
Example #10
0
 public function __construct($entityType, $entityId, $displayType, $pluginKey, $ownerId, $commentCountOnPage, $id, $cmpContextId, $formName)
 {
     parent::__construct();
     $language = OW::getLanguage();
     //comment form init
     $form = new Form($formName);
     $textArea = new Textarea('commentText');
     $form->addElement($textArea);
     $entityTypeField = new HiddenField('entityType');
     $form->addElement($entityTypeField);
     $entityIdField = new HiddenField('entityId');
     $form->addElement($entityIdField);
     $displayTypeField = new HiddenField('displayType');
     $form->addElement($displayTypeField);
     $pluginKeyField = new HiddenField('pluginKey');
     $form->addElement($pluginKeyField);
     $ownerIdField = new HiddenField('ownerId');
     $form->addElement($ownerIdField);
     $attch = new HiddenField('attch');
     $form->addElement($attch);
     $cid = new HiddenField('cid');
     $form->addElement($cid);
     $commentsOnPageField = new HiddenField('commentCountOnPage');
     $form->addElement($commentsOnPageField);
     $submit = new Submit('comment-submit');
     $submit->setValue($language->text('base', 'comment_add_submit_label'));
     $form->addElement($submit);
     $form->getElement('entityType')->setValue($entityType);
     $form->getElement('entityId')->setValue($entityId);
     $form->getElement('displayType')->setValue($displayType);
     $form->getElement('pluginKey')->setValue($pluginKey);
     $form->getElement('ownerId')->setValue($ownerId);
     $form->getElement('commentCountOnPage')->setValue($commentCountOnPage);
     $form->setAjax(true);
     $form->setAction(OW::getRouter()->urlFor('BASE_CTRL_Comments', 'addComment'));
     $form->bindJsFunction(Form::BIND_SUBMIT, "function(){ \$('#comments-" . $id . " .comments-preloader').show();}");
     $form->bindJsFunction(Form::BIND_SUCCESS, "function(){ \$('#comments-" . $id . " .comments-preloader').hide();}");
     $this->addForm($form);
     $attachmentsId = null;
     if (BOL_TextFormatService::getInstance()->isCommentsRichMediaAllowed()) {
         $attachmentsId = $this->initAttachments();
         $attControlUniq = uniqid('attpControl');
         $js = UTIL_JsGenerator::newInstance()->newObject(array('ATTP.CORE.ObjectRegistry', $attControlUniq), 'ATTP.AttachmentsControl', array($cmpContextId, array('attachmentId' => $attachmentsId, 'attachmentInputId' => $attch->getId(), 'inputId' => $textArea->getId(), 'formName' => $form->getName())));
         ATTACHMENTS_Plugin::getInstance()->addJs($js);
     }
     OW::getDocument()->addOnloadScript("owCommentCmps['{$id}'].initForm('" . $form->getElement('commentText')->getId() . "', '" . $form->getElement('attch')->getId() . "');");
     OW::getDocument()->addOnloadScript(UTIL_JsGenerator::composeJsString('
         owForms[{$formName}].bind("success", function(data) {
             var attachId = {$attcachmentId};
             if ( attachId && ATTP.CORE.ObjectRegistry[attachId] )
             {
                 ATTP.CORE.ObjectRegistry[attachId].reset();
             }
         });
     ', array('formName' => $form->getName(), 'attcachmentId' => $attachmentsId)));
     $this->assign('form', true);
     $this->assign('id', $id);
     if (OW::getUser()->isAuthenticated()) {
         $currentUserInfo = BOL_AvatarService::getInstance()->getDataForUserAvatars(array(OW::getUser()->getId()));
         $this->assign('currentUserInfo', $currentUserInfo[OW::getUser()->getId()]);
     }
 }
Example #11
0
 private function processButtons($buttons)
 {
     $keysToUnset = array();
     if (in_array(BOL_TextFormatService::WS_BTN_HTML, $buttons) && !$this->service->isCustomHtmlAllowed()) {
         $keysToUnset[] = array_search(BOL_TextFormatService::WS_BTN_HTML, $buttons);
     }
     if (!$this->service->isRichMediaAllowed()) {
         if (in_array(BOL_TextFormatService::WS_BTN_VIDEO, $buttons)) {
             $keysToUnset[] = array_search(BOL_TextFormatService::WS_BTN_VIDEO, $buttons);
         }
         if (in_array(BOL_TextFormatService::WS_BTN_IMAGE, $buttons)) {
             $keysToUnset[] = array_search(BOL_TextFormatService::WS_BTN_IMAGE, $buttons);
         }
     }
     foreach ($keysToUnset as $key) {
         if (!empty($buttons[$key])) {
             unset($buttons[$key]);
         }
     }
     return array_values($buttons);
 }
Example #12
0
 protected function prepare()
 {
     parent::prepare();
     if ($this->content['html']) {
         $js = UTIL_JsGenerator::newInstance();
         $code = BOL_TextFormatService::getInstance()->addVideoCodeParam($this->content['html'], "autoplay", 1);
         $code = BOL_TextFormatService::getInstance()->addVideoCodeParam($code, "play", 1);
         $js->addScript('$("[data-action=play]", "#" + {$uniqId}).click(function(e) { ' . 'e.preventDefault(); e.stopPropagation();' . '$(".ow_newsfeed_oembed_atch", "#" + {$uniqId}).addClass("ow_video_playing"); ' . '$(".ow_newsfeed_item_picture", "#" + {$uniqId}).html({$embed});' . 'return false; });', array("uniqId" => $this->uniqId, "embed" => $code));
         OW::getDocument()->addOnloadScript($js);
     }
 }
Example #13
0
 public function initForm()
 {
     $jsParams = array('entityType' => $this->params->getEntityType(), 'entityId' => $this->params->getEntityId(), 'pluginKey' => $this->params->getPluginKey(), 'contextId' => $this->cmpContextId, 'userAuthorized' => $this->isAuthorized, 'customId' => $this->params->getCustomId());
     if ($this->isAuthorized) {
         OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'jquery.autosize.js');
         $taId = 'cta' . $this->id;
         $attchId = 'attch' . $this->id;
         $attchUid = BOL_CommentService::getInstance()->generateAttachmentUid($this->params->getEntityType(), $this->params->getEntityId());
         $jsParams['ownerId'] = $this->params->getOwnerId();
         $jsParams['cCount'] = isset($this->batchData['countOnPage']) ? $this->batchData['countOnPage'] : $this->params->getCommentCountOnPage();
         $jsParams['initialCount'] = $this->params->getInitialCommentsCount();
         $jsParams['loadMoreCount'] = $this->params->getLoadMoreCount();
         $jsParams['countOnPage'] = $this->params->getCommentCountOnPage();
         $jsParams['uid'] = $this->id;
         $jsParams['addUrl'] = OW::getRouter()->urlFor('BASE_CTRL_Comments', 'addComment');
         $jsParams['displayType'] = $this->params->getDisplayType();
         $jsParams['textAreaId'] = $taId;
         $jsParams['attchId'] = $attchId;
         $jsParams['attchUid'] = $attchUid;
         $jsParams['enableSubmit'] = true;
         $jsParams['mediaAllowed'] = BOL_TextFormatService::getInstance()->isCommentsRichMediaAllowed();
         $jsParams['labels'] = array('emptyCommentMsg' => OW::getLanguage()->text('base', 'empty_comment_error_msg'), 'disabledSubmit' => OW::getLanguage()->text('base', 'submit_disabled_error_msg'), 'attachmentLoading' => OW::getLanguage()->text('base', 'submit_attachment_not_loaded'));
         if (!empty($this->staticData['currentUserInfo'])) {
             $userInfoToAssign = $this->staticData['currentUserInfo'];
         } else {
             $currentUserInfo = BOL_AvatarService::getInstance()->getDataForUserAvatars(array(OW::getUser()->getId()));
             $userInfoToAssign = $currentUserInfo[OW::getUser()->getId()];
         }
         $buttonContId = 'bCcont' . $this->id;
         if (BOL_TextFormatService::getInstance()->isCommentsRichMediaAllowed()) {
             $this->addComponent('attch', new BASE_CLASS_Attachment($this->params->getPluginKey(), $attchUid, $buttonContId));
         }
         $this->assign('buttonContId', $buttonContId);
         $this->assign('currentUserInfo', $userInfoToAssign);
         $this->assign('formCmp', true);
         $this->assign('taId', $taId);
         $this->assign('attchId', $attchId);
     }
     OW::getDocument()->addOnloadScript("new OwComments(" . json_encode($jsParams) . ");");
     $this->assign('displayType', $this->params->getDisplayType());
     // add comment list cmp
     $this->addComponent('commentList', new BASE_CMP_CommentsList($this->params, $this->id));
 }
 /**
  * Adds video clip
  *
  * @return boolean
  */
 public function process()
 {
     $language = OW::getLanguage();
     $data = $_POST['data'];
     $resp = array('result' => FALSE);
     $ids = array();
     foreach ($data as $key => $values) {
         $code = VIDEO_BOL_ClipService::getInstance()->validateClipCode($values["code"]);
         if (!BOL_TextFormatService::getInstance()->isCodeResourceValid($code)) {
             return array('result' => false, 'msg' => $language->text('video', 'resource_not_allowed'));
         }
         $clipId = $this->addClip($values);
         if ($clipId) {
             array_push($ids, $clipId);
         }
     }
     if (count($ids) > 1) {
         $resp['msg'] = $language->text('spvideolite', 'clips_added');
     } else {
         $resp['msg'] = $language->text('video', 'clip_added');
     }
     if (count($ids)) {
         $resp['result'] = TRUE;
         $resp['id'] = $ids;
         return $resp;
     }
     return false;
 }
Example #15
0
 /**
  * @return Jevix
  */
 private static function getJevix($tagList = null, $attrList = null, $blackListMode = false, $mediaSrcValidate = true)
 {
     if (self::$jevix === null) {
         require_once OW_DIR_LIB . 'jevix' . DS . 'jevix.class.php';
         self::$jevix = new Jevix();
     }
     $tagRules = array();
     $commonAttrs = array();
     if (!empty($tagList)) {
         foreach ($tagList as $tag) {
             $tagRules[$tag] = array(Jevix::TR_TAG_LIST => true);
         }
     }
     if ($attrList !== null) {
         foreach ($attrList as $attr) {
             if (strstr($attr, '.')) {
                 $parts = explode('.', $attr);
                 $tag = trim($parts[0]);
                 $param = trim($parts[1]);
                 if (!strlen($tag) || !strlen($attr)) {
                     continue;
                 }
                 if ($tag === '*') {
                     $commonAttrs[] = $param;
                     continue;
                 }
                 if (!isset($tagRules[$tag])) {
                     $tagRules[$tag] = array(Jevix::TR_TAG_LIST => true);
                 }
                 if (!isset($tagRules[$tag][Jevix::TR_PARAM_ALLOWED])) {
                     $tagRules[$tag][Jevix::TR_PARAM_ALLOWED] = array();
                 }
                 $tagRules[$tag][Jevix::TR_PARAM_ALLOWED][$param] = true;
             } else {
                 $commonAttrs[] = trim($attr);
             }
         }
     }
     $shortTags = array('img', 'br', 'input', 'embed', 'param', 'hr', 'link', 'meta', 'base', 'col');
     foreach ($shortTags as $shortTag) {
         if (!isset($tagRules[$shortTag])) {
             $tagRules[$shortTag] = array();
         }
         $tagRules[$shortTag][Jevix::TR_TAG_SHORT] = true;
     }
     $cutWithContent = array('script', 'embed', 'object', 'style');
     foreach ($cutWithContent as $cutTag) {
         if (!isset($tagRules[$cutTag])) {
             $tagRules[$cutTag] = array();
         }
         $tagRules[$cutTag][Jevix::TR_TAG_CUT] = true;
     }
     self::$jevix->blackListMode = $blackListMode;
     self::$jevix->commonTagParamRules = $commonAttrs;
     self::$jevix->tagsRules = $tagRules;
     self::$jevix->mediaSrcValidate = $mediaSrcValidate;
     self::$jevix->mediaValidSrc = BOL_TextFormatService::getInstance()->getMediaResourceList();
     return self::$jevix;
 }
Example #16
0
 public function statusUpdate()
 {
     if (empty($_POST['status']) && empty($_POST['attachment'])) {
         echo json_encode(false);
         exit;
     }
     if (!OW::getUser()->isAuthenticated()) {
         echo json_encode(false);
         exit;
     }
     $oembed = null;
     $attachId = null;
     $status = empty($_POST['status']) ? '' : strip_tags($_POST['status']);
     $content = array();
     if (!empty($_POST['attachment'])) {
         $content = json_decode($_POST['attachment'], true);
         if (!empty($content)) {
             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($status);
     $out = NEWSFEED_BOL_Service::getInstance()->addStatus(OW::getUser()->getId(), $_POST['feedType'], $_POST['feedId'], $_POST['visibility'], $status, array("content" => $content, "attachmentId" => $attachId));
     echo json_encode($out);
     exit;
 }
Example #17
0
 /**
  * Default action
  */
 public function index()
 {
     $language = OW::getLanguage();
     $clipService = VWVC_BOL_ClipService::getInstance();
     $userId = OW::getUser()->getId();
     if (!OW::getUser()->isAuthorized('vwvc', 'add')) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     // member list
     $config = OW::getConfig();
     $member = $config->getValue('vwvc', 'member');
     $memberList = $config->getValue('vwvc', 'member_list');
     $eventParams = array('pluginKey' => 'vwvc', 'action' => 'add_vwvc');
     $credits = OW::getEventManager()->call('usercredits.check_balance', $eventParams);
     if ($credits === false) {
         $this->assign('auth_msg', OW::getEventManager()->call('usercredits.error_message', $eventParams));
     } elseif ($member == 'member' && $memberList != '') {
         $userService = BOL_UserService::getInstance();
         $user = $userService->findUserById(OW::getUser()->getId());
         $username = $user->getUsername();
         $member = explode(",", $memberList);
         if (trim($memberList) != '') {
             $found = 0;
             foreach ($member as $key => $val) {
                 if ($username == trim($val)) {
                     $found = 1;
                     $this->assign('auth_msg', null);
                     $vwvcAddForm = new vwvcAddForm();
                     $this->addForm($vwvcAddForm);
                     $userId = OW::getUser()->getId();
                     if (OW::getRequest()->isPost() && $vwvcAddForm->isValid($_POST)) {
                         $values = $vwvcAddForm->getValues();
                         $code = $clipService->validateClipCode($values['code']);
                         if (!BOL_TextFormatService::getInstance()->isCodeResourceValid($code)) {
                             OW::getFeedback()->warning($language->text('vwvc', 'resource_not_allowed'));
                             $this->redirect();
                         }
                         $res = $vwvcAddForm->process();
                         OW::getFeedback()->info($language->text('vwvc', 'clip_added'));
                         $this->redirect(OW::getRouter()->urlForRoute('vwview_clip', array('id' => $res['id'])));
                     }
                 }
             }
             if ($found === 0) {
                 $this->assign('auth_msg', $language->text('vwvc', 'adding_denied'));
             }
         }
     } else {
         $this->assign('auth_msg', null);
         $vwvcAddForm = new vwvcAddForm();
         $this->addForm($vwvcAddForm);
         $userId = OW::getUser()->getId();
         if (OW::getRequest()->isPost() && $vwvcAddForm->isValid($_POST)) {
             $values = $vwvcAddForm->getValues();
             $code = $clipService->validateClipCode($values['code']);
             if (!BOL_TextFormatService::getInstance()->isCodeResourceValid($code)) {
                 OW::getFeedback()->warning($language->text('vwvc', 'resource_not_allowed'));
                 $this->redirect();
             }
             $res = $vwvcAddForm->process();
             OW::getFeedback()->info($language->text('vwvc', 'clip_added'));
             $this->redirect(OW::getRouter()->urlForRoute('vwview_clip', array('id' => $res['id'])));
         }
     }
     if (!OW::getRequest()->isAjax()) {
         OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'vwvc', 'vwvc');
     }
     OW::getDocument()->setHeading($language->text('vwvc', 'page_title_add_vwvc'));
     OW::getDocument()->setHeadingIconClass('ow_ic_vwvc');
     OW::getDocument()->setTitle($language->text('vwvc', 'meta_title_vwvc_add'));
 }
 /**
  * Validate clip code integrity
  *
  * @param string $code
  * @param null $provider
  * @return string
  */
 public function validateClipCode($code, $provider = null)
 {
     $textService = BOL_TextFormatService::getInstance();
     $code = UTIL_HtmlTag::stripJs($code);
     $code = UTIL_HtmlTag::stripTags($code, $textService->getVideoParamList('tags'), $textService->getVideoParamList('attrs'));
     $objStart = '<object';
     $objEnd = '</object>';
     $objEndS = '/>';
     $posObjStart = stripos($code, $objStart);
     $posObjEnd = stripos($code, $objEnd);
     $posObjEnd = $posObjEnd ? $posObjEnd : stripos($code, $objEndS);
     if ($posObjStart !== false && $posObjEnd !== false) {
         $posObjEnd += strlen($objEnd);
         return substr($code, $posObjStart, $posObjEnd - $posObjStart);
     } else {
         $embStart = '<embed';
         $embEnd = '</embed>';
         $embEndS = '/>';
         $posEmbStart = stripos($code, $embStart);
         $posEmbEnd = stripos($code, $embEnd) ? stripos($code, $embEnd) : stripos($code, $embEndS);
         if ($posEmbStart !== false && $posEmbEnd !== false) {
             $posEmbEnd += strlen($embEnd);
             return substr($code, $posEmbStart, $posEmbEnd - $posEmbStart);
         } else {
             $frmStart = '<iframe ';
             $frmEnd = '</iframe>';
             $posFrmStart = stripos($code, $frmStart);
             $posFrmEnd = stripos($code, $frmEnd);
             if ($posFrmStart !== false && $posFrmEnd !== false) {
                 $posFrmEnd += strlen($frmEnd);
                 $code = substr($code, $posFrmStart, $posFrmEnd - $posFrmStart);
                 preg_match('/src=(["\'])(.*?)\\1/', $code, $match);
                 if (!empty($match[2])) {
                     $src = $match[2];
                     if (mb_substr($src, 0, 2) == '//') {
                         $src = 'http:' . $src;
                     }
                     $urlArr = parse_url($src);
                     $parts = explode('.', $urlArr['host']);
                     if (count($parts) < 2) {
                         return '';
                     }
                     $d1 = array_pop($parts);
                     $d2 = array_pop($parts);
                     $host = $d2 . '.' . $d1;
                     $resourceList = BOL_TextFormatService::getInstance()->getMediaResourceList();
                     if (!in_array($host, $resourceList) && !in_array($urlArr['host'], $resourceList)) {
                         return '';
                     }
                 }
                 return $code;
             } else {
                 return '';
             }
         }
     }
 }
Example #19
0
 public function prepareMessageList(array $list)
 {
     if (empty($list)) {
         return array();
     }
     $result = array();
     foreach ($list as $message) {
         $_message = $message;
         $_message['mode'] = $message['mode'] == 'chat' ? self::MODE_CHAT : self::MODE_MAIL;
         $_message['recipientRead'] = !empty($message['recipientRead']);
         $_message['isSystem'] = !empty($message['isSystem']) && is_array($message['text']);
         if ($_message['isSystem']) {
             if (!empty($message['text']['eventName'])) {
                 if (OW::getPluginManager()->isPluginActive('winks')) {
                     switch ($message['text']['eventName']) {
                         case 'authorizationPromoted':
                             $_message['isSystem'] = false;
                             $_message['text'] = strip_tags($message['text']['text']);
                             break;
                         case 'renderWink':
                             if ($message['senderId'] == OW::getUser()->getId()) {
                                 $_message['text'] = strip_tags(OW::getLanguage()->text('winks', 'accept_wink_msg'));
                             } else {
                                 $_message['text'] = BOL_UserService::getInstance()->getDisplayName($message['senderId']) . ' ' . OW::getLanguage()->text('winks', 'wink_back_message');
                             }
                             $tmpMessage = MAILBOX_BOL_ConversationService::getInstance()->getMessage($message['id']);
                             $json = json_decode($tmpMessage->text, true);
                             if (!empty($json['params']['winkBackEnabled'])) {
                                 $_message['systemType'] = $message['text']['eventName'];
                             } else {
                                 $_message['systemType'] = 'winkIsSent';
                             }
                             break;
                         case 'renderWinkBack':
                             if ($message['senderId'] == OW::getUser()->getId()) {
                                 $_message['text'] = strip_tags(OW::getLanguage()->text('winks', 'winked_back_msg'));
                             } else {
                                 $_message['text'] = BOL_UserService::getInstance()->getDisplayName($message['senderId']) . ' ' . OW::getLanguage()->text('winks', 'wink_back_message_owner');
                             }
                             $tmpMessage = MAILBOX_BOL_ConversationService::getInstance()->getMessage($message['id']);
                             $json = json_decode($tmpMessage->text, true);
                             if (!empty($json['params']['winkBackEnabled'])) {
                                 $_message['systemType'] = $message['text']['eventName'];
                             }
                             break;
                         default:
                             $_message['text'] = strip_tags($message['text']['text']);
                             break;
                     }
                 } else {
                     $_message['text'] = strip_tags($message['text']['text']);
                 }
             } elseif (!empty($message['text']['text'])) {
                 $_message['systemType'] = 'simple';
                 $_message['text'] = strip_tags($message['text']['text']);
             }
         } else {
             $_message['text'] = strip_tags(BOL_TextFormatService::getInstance()->processWsForOutput($message['text'], array('buttons' => array(BOL_TextFormatService::WS_BTN_BOLD, BOL_TextFormatService::WS_BTN_ITALIC))), '<b><i><br><br/><p>');
         }
         //            $_message['senderAvatarUrl'] = strcasecmp($message['senderAvatarUrl'], $defaultAvatar) === 0 ? null : $message['senderAvatarUrl'];
         //            $_message['recipientAvatarUrl'] = strcasecmp($message['recipientAvatarUrl'], $defaultAvatar) === 0 ? null : $message['recipientAvatarUrl'];
         $result[] = $_message;
     }
     return $result;
 }
Example #20
0
 public function addComment()
 {
     $errorMessage = false;
     $isMobile = !empty($_POST['isMobile']) && (bool) $_POST['isMobile'];
     $params = $this->getParamsObject();
     if (empty($_POST['commentText']) && empty($_POST['attch'])) {
         $errorMessage = OW::getLanguage()->text('base', 'comment_required_validator_message');
     } else {
         if (!empty($_POST['commentText'])) {
             $commentText = $_POST['commentText'];
         } else {
             $commentText = '';
         }
     }
     if (!OW::getUser()->isAuthorized($params->getPluginKey(), 'add_comment')) {
         $errorMessage = OW::getLanguage()->text('base', 'comment_add_auth_error');
     } else {
         if (BOL_UserService::getInstance()->isBlocked(OW::getUser()->getId(), $params->getOwnerId())) {
             $errorMessage = OW::getLanguage()->text('base', 'user_block_message');
         } else {
             $eventParams = array('pluginKey' => $params->getPluginKey(), 'action' => 'add_comment');
             $credits = OW::getEventManager()->call('usercredits.check_balance', $eventParams);
             if ($credits === false) {
                 $errorMessage = OW::getEventManager()->call('usercredits.error_message', $eventParams);
             }
         }
     }
     if ($errorMessage) {
         exit(json_encode(array('error' => $errorMessage)));
     }
     if (BOL_TextFormatService::getInstance()->isCommentsRichMediaAllowed() && !$isMobile) {
         $attachment = empty($_POST['attch']) ? null : $_POST['attch'];
         if ($attachment !== null) {
             $tempArr = json_decode($attachment, true);
             if (!empty($tempArr['type'])) {
                 if ($tempArr['type'] == 'photo' && isset($tempArr['genId'])) {
                     $tempArr['url'] = $tempArr['href'] = OW::getEventManager()->call('base.attachment_save_image', array('genId' => $tempArr['genId']));
                     unset($tempArr['uid']);
                 } else {
                     if ($tempArr['type'] == 'video') {
                         $tempArr['html'] = BOL_TextFormatService::getInstance()->validateVideoCode($tempArr['html']);
                     }
                 }
                 $attachment = json_encode($tempArr);
             } else {
                 $attachment = null;
             }
         }
     } else {
         $attachment = null;
     }
     $comment = $this->commentService->addComment($params->getEntityType(), $params->getEntityId(), $params->getPluginKey(), OW::getUser()->getId(), $commentText, $attachment);
     // trigger event comment add
     $event = new OW_Event('base_add_comment', array('entityType' => $params->getEntityType(), 'entityId' => $params->getEntityId(), 'userId' => OW::getUser()->getId(), 'commentId' => $comment->getId(), 'pluginKey' => $params->getPluginKey(), 'attachment' => json_decode($attachment, true)));
     OW::getEventManager()->trigger($event);
     if ($credits === true) {
         OW::getEventManager()->call('usercredits.track_action', $eventParams);
     }
     if ($isMobile) {
         $commentListCmp = new BASE_MCMP_CommentsList($params, $_POST['cid']);
     } else {
         $commentListCmp = new BASE_CMP_CommentsList($params, $_POST['cid']);
     }
     exit(json_encode(array('entityType' => $params->getEntityType(), 'entityId' => $params->getEntityId(), 'commentList' => $commentListCmp->render(), 'onloadScript' => OW::getDocument()->getOnloadScript())));
 }