Exemplo n.º 1
0
 public function initJs($delegate)
 {
     $js = UTIL_JsGenerator::newInstance();
     $js->newObject(array('ATTP.CORE.ObjectRegistry', $this->uniqId), 'ATTP.Attachment', array($this->uniqId, $delegate, $this->type));
     $this->initJs = $js->generateJs();
     return $this->uniqId;
 }
Exemplo n.º 2
0
 public function initJs($delegate)
 {
     $js = UTIL_JsGenerator::newInstance();
     $js->newObject(array('ATTP.CORE.ObjectRegistry', $this->uniqId), 'ATTP.Attachment', array($this->uniqId, $delegate));
     ATTACHMENTS_Plugin::getInstance()->addJs($js);
     return $this->uniqId;
 }
Exemplo n.º 3
0
 public function initJs()
 {
     parent::initJs();
     $js = UTIL_JsGenerator::newInstance();
     $js->addScript('OW.Invitation = new OW_Invitation({$key}, {$params});', array('key' => $this->getKey(), 'params' => array('rsp' => OW::getRouter()->urlFor('BASE_CTRL_Invitation', 'ajax'))));
     OW::getDocument()->addOnloadScript($js);
 }
Exemplo n.º 4
0
 public function onCollectButtons(BASE_CLASS_EventCollector $event)
 {
     $params = $event->getParams();
     if ($params["entityType"] != HINT_BOL_Service::ENTITY_TYPE_USER) {
         return;
     }
     $userId = $params["entityId"];
     $uniqId = uniqid("hint-af-");
     if (!OW::getUser()->isAuthenticated() || OW::getUser()->getId() == $userId) {
         return;
     }
     $isFollowing = OW::getEventManager()->call("feed.is_follow", array("feedType" => "user", "feedId" => $userId, "userId" => OW::getUser()->getId()));
     $label = $isFollowing ? OW::getLanguage()->text('newsfeed', 'unfollow_button') : OW::getLanguage()->text('newsfeed', 'follow_button');
     $toggleLabel = !$isFollowing ? OW::getLanguage()->text('newsfeed', 'unfollow_button') : OW::getLanguage()->text('newsfeed', 'follow_button');
     $command = $isFollowing ? "newsfeed.unfollow" : "newsfeed.follow";
     $js = UTIL_JsGenerator::newInstance();
     $js->jQueryEvent('#' . $uniqId, 'click', '
         var self = $(this), command = self.data("command");
         HINT.UTILS.toggleText(this, e.data.l1, e.data.l2);
         self.data("command", command == "newsfeed.follow" ? "newsfeed.unfollow" : "newsfeed.follow");
         HINT.UTILS.query(command, e.data.params); return false;', array('e'), array("l1" => $label, "l2" => $toggleLabel, "params" => array("userId" => $userId)));
     OW::getDocument()->addOnloadScript($js);
     $button = array("key" => "follow", "label" => $label, "attrs" => array("id" => $uniqId, "data-command" => $command));
     $event->add($button);
 }
Exemplo n.º 5
0
 /**
  * @return Constructor.
  */
 public function __construct($groupId)
 {
     parent::__construct();
     $service = GROUPS_BOL_Service::getInstance();
     $groupDto = $service->findGroupById($groupId);
     $group = array('title' => htmlspecialchars($groupDto->title), 'description' => $groupDto->description, 'time' => $groupDto->timeStamp, 'imgUrl' => empty($groupDto->imageHash) ? false : $service->getGroupImageUrl($groupDto), 'url' => OW::getRouter()->urlForRoute('groups-view', array('groupId' => $groupDto->id)), "id" => $groupDto->id);
     $imageUrl = empty($groupDto->imageHash) ? '' : $service->getGroupImageUrl($groupDto);
     OW::getDocument()->addMetaInfo('image', $imageUrl, 'itemprop');
     OW::getDocument()->addMetaInfo('og:image', $imageUrl, 'property');
     $createDate = UTIL_DateTime::formatDate($groupDto->timeStamp);
     $adminName = BOL_UserService::getInstance()->getDisplayName($groupDto->userId);
     $adminUrl = BOL_UserService::getInstance()->getUserUrl($groupDto->userId);
     $js = UTIL_JsGenerator::newInstance()->jQueryEvent('#groups_toolbar_flag', 'click', UTIL_JsGenerator::composeJsString('OW.flagContent({$entity}, {$id}, {$title}, {$href}, "groups+flags", {$ownerId});', array('entity' => GROUPS_BOL_Service::WIDGET_PANEL_NAME, 'id' => $groupDto->id, 'title' => $group['title'], 'href' => $group['url'], 'ownerId' => $groupDto->userId)));
     OW::getDocument()->addOnloadScript($js, 1001);
     $toolbar = array(array('label' => OW::getLanguage()->text('groups', 'widget_brief_info_create_date', array('date' => $createDate))), array('label' => OW::getLanguage()->text('groups', 'widget_brief_info_admin', array('name' => $adminName, 'url' => $adminUrl))));
     if ($service->isCurrentUserCanEdit($groupDto)) {
         $toolbar[] = array('label' => OW::getLanguage()->text('groups', 'edit_btn_label'), 'href' => OW::getRouter()->urlForRoute('groups-edit', array('groupId' => $groupId)));
     }
     if (OW::getUser()->isAuthenticated() && OW::getUser()->getId() != $groupDto->userId) {
         $toolbar[] = array('label' => OW::getLanguage()->text('base', 'flag'), 'href' => 'javascript://', 'id' => 'groups_toolbar_flag');
     }
     $event = new BASE_CLASS_EventCollector('groups.on_toolbar_collect', array('groupId' => $groupId));
     OW::getEventManager()->trigger($event);
     foreach ($event->getData() as $item) {
         $toolbar[] = $item;
     }
     $this->assign('toolbar', $toolbar);
     $this->assign('group', $group);
 }
Exemplo n.º 6
0
 protected function initJs()
 {
     $js = UTIL_JsGenerator::newInstance();
     $js->addScript('OW.Console.addItem(new OW_ConsoleDropdownClick({$uniqId}, {$contentIniqId}), {$key});', array('uniqId' => $this->consoleItem->getUniqId(), 'key' => $this->getKey(), 'contentIniqId' => $this->consoleItem->getContentUniqId()));
     OW::getDocument()->addOnloadScript($js);
     return $this->consoleItem->getUniqId();
 }
Exemplo n.º 7
0
 public function initJs($delegate)
 {
     $js = UTIL_JsGenerator::newInstance();
     $js->newObject(array('CORE.ObjectRegistry', $this->uniqId), 'ATTACHMENTS.Attachment', array($this->uniqId, $delegate));
     OW::getDocument()->addOnloadScript($js);
     return $this->uniqId;
 }
Exemplo n.º 8
0
 public function initJs($delegate)
 {
     $data = array();
     $data = array('delegate' => $delegate, 'rsp' => OW::getRouter()->urlFor('EQUESTIONS_CTRL_Attachments', 'rsp'));
     $js = UTIL_JsGenerator::newInstance()->newObject(array('CORE.ObjectRegistry', $this->uniqId), 'ATTACHMENTS.LinkPanel', array($this->uniqId, $data));
     OW::getDocument()->addOnloadScript($js);
 }
Exemplo n.º 9
0
 public function initJs()
 {
     $js = UTIL_JsGenerator::newInstance();
     $js->newObject(array('OW_AttachmentItemColletction', $this->uniqId), 'OW_Attachment', array($this->uniqId, $this->oembed));
     OW::getDocument()->addOnloadScript($js);
     return $this->uniqId;
 }
Exemplo n.º 10
0
    public function __construct($feedAutoId, $feedType, $feedId, $actionVisibility = null)
    {
        parent::__construct();
        $form = new NEWSFEED_StatusForm($feedAutoId, $feedType, $feedId, $actionVisibility);
        $this->addForm($form);
        $uniqId = uniqid('statusUpdate');
        $attachmentId = $this->initAttachments();
        $attachmentInputId = $form->getElement('attachment')->getId();
        $inputId = $form->getElement('status')->getId();
        $this->assign('uniqId', $uniqId);
        $js = UTIL_JsGenerator::newInstance()->newObject(array('ATTP.CORE.ObjectRegistry', $uniqId), 'ATTP.AttachmentsControl', array($uniqId, array('attachmentId' => $attachmentId, 'attachmentInputId' => $attachmentInputId, 'inputId' => $inputId, 'formName' => $form->getName())));
        ATTACHMENTS_Plugin::getInstance()->addJs($js);
        $js = 'owForms[{$form}].bind("success", function(data){
                    if ( !data || data.error )
                    {
                        return;
                    }

                    if ( ATTP.CORE.ObjectRegistry[{$attachId}] )
                    {
                        ATTP.CORE.ObjectRegistry[{$attachId}].reset();
                    }
                });
                owForms[{$form}].reset = false;';
        $js = UTIL_JsGenerator::composeJsString($js, array('form' => $form->getName(), 'attachId' => $attachmentId));
        OW::getDocument()->addOnloadScript($js);
    }
Exemplo n.º 11
0
 public function initJs($cacheList, $allCount)
 {
     $glob = array('rsp' => OW::getRouter()->urlFor('EQUESTIONS_CTRL_Common', 'rsp'), 'delegate' => $this->delegate);
     $data = array('entityId' => $this->entityId, 'ajaxMode' => count($cacheList) < $allCount, 'friendsMode' => $this->friendsMode);
     $js = UTIL_JsGenerator::newInstance()->newObject(array('CORE.ObjectRegistry', $this->uniqId), 'UI.UserSelector', array($this->uniqId, $data, $glob, $cacheList));
     OW::getDocument()->addOnloadScript($js);
 }
Exemplo n.º 12
0
 public function initJs($delegate)
 {
     $data = array();
     $data = array('delegate' => $delegate, 'rsp' => OW::getRouter()->urlFor('ATTACHMENTS_CTRL_Attachments', 'rsp'));
     $js = UTIL_JsGenerator::newInstance()->newObject(array('ATTP.CORE.ObjectRegistry', $this->uniqId), 'ATTP.LinkPanel', array($this->uniqId, $data));
     ATTACHMENTS_Plugin::getInstance()->addJs($js);
 }
Exemplo n.º 13
0
 /**
  * @param BASE_CLASS_EventCollector $event
  */
 public function onCollectButtons(BASE_CLASS_EventCollector $event)
 {
     $params = $event->getParams();
     if ($params["entityType"] != HINT_BOL_Service::ENTITY_TYPE_USER) {
         return;
     }
     $userId = $params["entityId"];
     if (!OW::getUser()->isAuthenticated() || $userId == OW::getUser()->getId() || !OW::getUser()->isAuthorized('ocsfavorites', 'add_to_favorites')) {
         return;
     }
     $service = OCSFAVORITES_BOL_Service::getInstance();
     $lang = OW::getLanguage();
     $isFavorite = $service->isFavorite(OW::getUser()->getId(), $userId);
     $uniqId = uniqid("hint-favorites-");
     if ($isFavorite) {
         $command = "favorites.remove";
         $label = $lang->text('ocsfavorites', 'remove_favorite_button');
     } else {
         $command = "favorites.add";
         $label = $lang->text('ocsfavorites', 'add_favorite_button');
     }
     $js = UTIL_JsGenerator::newInstance();
     $js->jQueryEvent('#' . $uniqId, 'click', '
         var self = $(this), command = self.data("command");
         HINT.UTILS.toggleText(this, e.data.l1, e.data.l2);
         self.data("command", command == "favorites.remove" ? "favorites.add" : "favorites.remove");
         HINT.UTILS.query(command, e.data.params); return false;', array('e'), array("l1" => $lang->text('ocsfavorites', 'add_favorite_button'), "l2" => $lang->text('ocsfavorites', 'remove_favorite_button'), "params" => array("userId" => $userId)));
     OW::getDocument()->addOnloadScript($js);
     $button = array("key" => "ocsfavorites", "label" => $label, "attrs" => array("id" => $uniqId, "data-command" => $command));
     $event->add($button);
 }
Exemplo n.º 14
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);
 }
Exemplo n.º 15
0
    public function addStatic($ajax = false)
    {
        if ($this->staticAdded) {
            return;
        }
        $staticUrl = OW::getPluginManager()->getPlugin(self::PLUGIN_KEY)->getStaticUrl();
        $scriptUrl = $staticUrl . 'equestions.js' . '?' . self::PLUGIN_VERSION;
        $styleUrl = $staticUrl . 'equestions.css' . '?' . self::PLUGIN_VERSION;
        $imagesUrl = OW::getThemeManager()->getThemeImagesUrl();
        $css = 'html body div .q_ic_preloader { background-image: url(' . $imagesUrl . 'ajax_preloader_button.gif) };';
        OW::getDocument()->addStyleDeclaration($css);
        if (!$ajax) {
            OW::getDocument()->addScript($scriptUrl);
            OW::getDocument()->addStyleSheet($styleUrl);
        } else {
            OW::getDocument()->addOnloadScript(UTIL_JsGenerator::composeJsString('
                if ( !window.QUESTIONS_Loaded )
                {

                    OW.addScriptFiles([{$scriptUrl}], function(){
                        if ( window.EQAjaxLoadCallbacksRun )
                        {
                            window.EQAjaxLoadCallbacksRun();
                        }
                    });
                    OW.addCssFile({$styleUrl});

                 }
            ', array('styleUrl' => $styleUrl, 'scriptUrl' => $scriptUrl)));
        }
        $messages = EQUESTIONS_CLASS_CreditsBridge::getInstance()->getAllPermissionMessages();
        $actions = EQUESTIONS_CLASS_CreditsBridge::getInstance()->getAllPermissions();
        $js = UTIL_JsGenerator::newInstance();
        $js->addScript(UTIL_JsGenerator::composeJsString('UTILS.Credits = new UTILS.CreditsConstructor({$actions}, {$messages}); ', array('messages' => $messages, 'actions' => $actions)));
        $friendMode = (bool) OW::getEventManager()->call('plugin.friends');
        $js->setVariable(array('QUESTIONS', 'friendMode'), $friendMode);
        if (!$ajax) {
            OW::getDocument()->addOnloadScript($js);
        } else {
            OW::getDocument()->addOnloadScript('window.EQAjaxLoadCallbackQueue = [];');
            OW::getDocument()->addOnloadScript('(function() {
                var loaded = function() {
                    ' . $js->generateJs() . '
                };

                if ( window.QUESTIONS_Loaded )
                    loaded.call();
                else
                    window.EQAjaxLoadCallbackQueue.push(loaded);
            })();');
        }
        OW::getLanguage()->addKeyForJs('equestions', 'selector_title_friends');
        OW::getLanguage()->addKeyForJs('equestions', 'selector_title_users');
        OW::getLanguage()->addKeyForJs('equestions', 'followers_fb_title');
        OW::getLanguage()->addKeyForJs('equestions', 'toolbar_unfollow_btn');
        OW::getLanguage()->addKeyForJs('equestions', 'toolbar_follow_btn');
        $this->staticAdded = true;
    }
Exemplo n.º 16
0
 public function initJs()
 {
     parent::initJs();
     $jsUrl = OW::getPluginManager()->getPlugin('friends')->getStaticJsUrl() . 'friend_request.js';
     OW::getDocument()->addScript($jsUrl);
     $js = UTIL_JsGenerator::newInstance();
     $js->addScript('OW.FriendRequest = new OW_FriendRequest({$key}, {$params});', array('key' => $this->getKey(), 'params' => array('rsp' => OW::getRouter()->urlFor('FRIENDS_CTRL_Action', 'ajax'))));
     OW::getDocument()->addOnloadScript($js);
 }
Exemplo n.º 17
0
 public function onBeforeRender()
 {
     parent::onBeforeRender();
     $this->initList();
     $js = UTIL_JsGenerator::newInstance();
     $js->jQueryEvent("#" . $this->uniqId . " .ca-dropdown-btn", "click", 'var dd = $(this).parents(".ca-dropdown-wrap:eq(0)").find(".ca-dropdown"); isVisible = dd.is(":visible"); ' . '$(".ca-dropdown:visible").hide(); ' . 'return isVisible ? (dd.hide(), true) : (dd.show(), false);');
     $js->addScript('$(document).on("click", function(e) { return $(e.target).is(".ca-dropdown, .ca-dropdown *") ? false : $(".ca-dropdown:visible").hide(), true; });');
     OW::getDocument()->addOnloadScript($js);
 }
Exemplo n.º 18
0
 public function initJs($delegate)
 {
     $data = array();
     $static = OW::getPluginManager()->getPlugin('attachments')->getStaticUrl();
     $webCam = array('swf' => $static . 'webcam/webcam.swf', 'sound' => $static . 'webcam/shutter.mp3', 'quality' => 100, 'uploader' => OW::getRouter()->urlFor('ATTACHMENTS_CTRL_Attachments', 'webcamHandler'));
     $data = array('delegate' => $delegate, 'rsp' => OW::getRouter()->urlFor('ATTACHMENTS_CTRL_Attachments', 'rsp'), 'uploader' => OW::getRouter()->urlFor('ATTACHMENTS_CTRL_Attachments', 'uploader'), 'webcam' => $webCam);
     $js = UTIL_JsGenerator::newInstance()->newObject(array('ATTP.CORE.ObjectRegistry', $this->uniqId), 'ATTP.ImagePanel', array($this->uniqId, $data));
     ATTACHMENTS_Plugin::getInstance()->addJs($js);
 }
Exemplo n.º 19
0
 public function initJs()
 {
     parent::initJs();
     $jsUrl = OW::getPluginManager()->getPlugin('mailbox')->getStaticJsUrl() . 'mailbox_console.js';
     OW::getDocument()->addScript($jsUrl);
     $js = UTIL_JsGenerator::newInstance();
     $js->addScript('OW.MailboxConsole = new OW_MailboxConsole({$key}, {$params});', array('key' => $this->getKey(), 'params' => array('issetMails' => (bool) MAILBOX_BOL_ConversationService::getInstance()->getInboxConversationList(OW::getUser()->getId(), 0, 1))));
     OW::getDocument()->addOnloadScript($js);
 }
Exemplo n.º 20
0
 public function initJs()
 {
     parent::initJs();
     $staticUrl = OW::getPluginManager()->getPlugin('notifications')->getStaticUrl();
     OW::getDocument()->addScript($staticUrl . 'notifications.js');
     $js = UTIL_JsGenerator::newInstance();
     $js->addScript('OW.Notification = new OW_Notification({$key});', array('key' => $this->getKey()));
     OW::getDocument()->addOnloadScript($js);
 }
Exemplo n.º 21
0
 private function initStatic()
 {
     $plugin = OW::getPluginManager()->getPlugin("snippets");
     $staticUrl = $plugin->getStaticUrl();
     OW::getDocument()->addScript($staticUrl . "script.js?" . $plugin->getDto()->build);
     OW::getDocument()->addStyleSheet($staticUrl . "style.css?" . $plugin->getDto()->build);
     $js = UTIL_JsGenerator::newInstance();
     $js->callFunction(array("SNIPPETS", "snippets"), array($this->uniqId));
     OW::getDocument()->addOnloadScript($js);
 }
Exemplo n.º 22
0
 public function __construct()
 {
     parent::__construct();
     static $count = 0;
     $count++;
     $uniqId = 'gtabs-' . $count;
     EQUESTIONS_Plugin::getInstance()->addStatic();
     $js = UTIL_JsGenerator::newInstance()->newObject('questionsTabs', 'QUESTIONS_Tabs', array($uniqId));
     OW::getDocument()->addOnloadScript($js);
     $this->assign('uniqId', $uniqId);
 }
Exemplo n.º 23
0
 public function onCollectProfileActionToolbarItem(BASE_CLASS_EventCollector $event)
 {
     $params = $event->getParams();
     if (empty($params['userId'])) {
         return;
     }
     if (!OW::getUser()->isAuthenticated()) {
         return;
     }
     $allowGrant = OW::getConfig()->getValue('usercredits', 'allow_grant_credits');
     if (!empty($allowGrant) || OW::getUser()->isAuthorized('usercredits')) {
         $userId = (int) $params['userId'];
         $linkId = 'gi' . rand(10, 1000000);
         $creditsService = USERCREDITS_BOL_CreditsService::getInstance();
         $balance = $creditsService->getCreditsBalance($userId);
         $resultArray = array();
         if (OW::getUser()->isAuthorized('usercredits')) {
             $resultArray[BASE_CMP_ProfileActionToolbar::DATA_KEY_ITEM_KEY] = 'usercredits.set_credits';
             $resultArray[BASE_CMP_ProfileActionToolbar::DATA_KEY_LINK_GROUP_KEY] = 'base.moderation';
             $resultArray[BASE_CMP_ProfileActionToolbar::DATA_KEY_LINK_GROUP_LABEL] = OW::getLanguage()->text('base', 'profile_toolbar_group_moderation');
             $resultArray[BASE_CMP_ProfileActionToolbar::DATA_KEY_LINK_ORDER] = 0;
             $label = OW::getLanguage()->text('usercredits', 'profile_toolbar_item_credits', array('credits' => $balance));
             $fbSettings = array("width" => 300, "title" => $label);
             $fbParams = array($userId, false);
             $js = UTIL_JsGenerator::newInstance()->jQueryEvent("#" . $linkId, "click", 'var self = $(this); OW.ajaxFloatBox("USERCREDITS_CMP_SetCredits", e.data.params , $.extend({}, e.data.settings, {scope: { btn: $(this), callBack: function(r) {
                     if (r.text) self.find(".usercredits_btn_label_text").text(r.text);
                  }}}));', array('e'), array("params" => $fbParams, "settings" => $fbSettings));
             $script = $js->generateJs();
         } else {
             if ($params['userId'] == OW::getUser()->getId()) {
                 return;
             }
             $resultArray[BASE_CMP_ProfileActionToolbar::DATA_KEY_ITEM_KEY] = 'usercredits.send_credits';
             $grantorBalance = $creditsService->getCreditsBalance(OW::getUser()->getId());
             $label = OW::getLanguage()->text('usercredits', 'profile_toolbar_grant');
             if ($grantorBalance) {
                 $script = '$("#' . $linkId . '").click(function(){
                 document.grantCreditsFloatBox = OW.ajaxFloatBox(
                     "USERCREDITS_CMP_GrantCredits",
                     { userId: ' . $userId . ' },
                     { width: 400, title: "' . $label . '" }
                 );
                 });';
             }
         }
         if (!empty($script)) {
             OW::getDocument()->addOnloadScript($script);
             $resultArray[BASE_CMP_ProfileActionToolbar::DATA_KEY_LABEL] = '<span class="usercredits_btn_label_text">' . $label . '</span>';
             $resultArray[BASE_CMP_ProfileActionToolbar::DATA_KEY_LINK_HREF] = 'javascript://';
             $resultArray[BASE_CMP_ProfileActionToolbar::DATA_KEY_LINK_ID] = $linkId;
             $event->add($resultArray);
         }
     }
 }
Exemplo n.º 24
0
 public function onBeforeRender()
 {
     parent::onBeforeRender();
     $options = array();
     $js = UTIL_JsGenerator::newInstance();
     $js->callFunction(array("UHEADER.GallerySwitcher", "init"), array($this->uniqId, $options));
     OW::getDocument()->addOnloadScript($js);
     $this->assign("uniqId", $this->uniqId);
     $this->assign("tabs", $this->getTabs());
     $this->assign("dimensions", $this->getDimensions());
 }
Exemplo n.º 25
0
 protected function initJs()
 {
     $js = UTIL_JsGenerator::newInstance();
     $js->addScript('OW.Console.addItem(new OW_ConsoleDropdownList({$uniqId}, {$contentIniqId}), {$key});', array('uniqId' => $this->consoleItem->getUniqId(), 'key' => $this->getKey(), 'contentIniqId' => $this->consoleItem->getContentUniqId()));
     OW::getDocument()->addOnloadScript($js);
     $this->list->initJs();
     $js = UTIL_JsGenerator::newInstance();
     $js->addScript('OW.MailboxConsole = new OW_MailboxConsole({$key}, {$params});', array('key' => $this->getKey(), 'params' => array('issetMails' => (bool) MAILBOX_BOL_ConversationService::getInstance()->getInboxConversationList(OW::getUser()->getId(), 0, 1))));
     OW::getDocument()->addOnloadScript($js);
     return $this->consoleItem->getUniqId();
 }
Exemplo n.º 26
0
 public function initStatic()
 {
     $baseJs = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
     OW::getDocument()->addScript($baseJs . "jquery-ui.min.js");
     $plugin = OW::getPluginManager()->getPlugin("snippets");
     $staticUrl = $plugin->getStaticUrl();
     OW::getDocument()->addScript($staticUrl . "script.js?" . $plugin->getDto()->build);
     OW::getDocument()->addStyleSheet($staticUrl . "style.css?" . $plugin->getDto()->build);
     $js = UTIL_JsGenerator::newInstance();
     $js->callFunction(array("SNIPPETS", "settings"), array($this->uniqId));
     OW::getDocument()->addOnloadScript($js);
 }
Exemplo n.º 27
0
 public function __construct(BASE_CLASS_WidgetParameter $params)
 {
     parent::__construct();
     $goalId = $params->customParamList['goal'];
     $service = OCSFUNDRAISING_BOL_Service::getInstance();
     if ($goalId) {
         $goal = $service->getGoalById($goalId);
         if (!$goal) {
             $this->assign('error', OW::getLanguage()->text('ocsfundraising', 'goal_not_found'));
             return;
         }
         $goal['dto']->description = mb_substr($goal['dto']->description, 0, 250) . (mb_strlen($goal['dto']->description) > 250 ? '...' : '');
         $this->assign('goal', $goal);
     } else {
         $this->assign('goal', null);
         return;
     }
     $userIdList = array();
     $showTop = $params->customParamList['show_top'];
     if ($showTop) {
         $top = $service->getDonationList($goalId, 'top', 1, 3);
         if ($top) {
             foreach ($top as $d) {
                 if ($d['dto']->userId && !in_array($d['dto']->userId, $userIdList)) {
                     array_push($userIdList, $d['dto']->userId);
                 }
             }
         }
         $this->assign('top', $top);
     }
     $this->assign('showTop', $showTop);
     $showLatest = $params->customParamList['show_latest'];
     if ($showLatest) {
         $latest = $service->getDonationList($goalId, 'latest', 1, 3);
         if ($latest) {
             foreach ($latest as $d) {
                 if ($d['dto']->userId && !in_array($d['dto']->userId, $userIdList)) {
                     array_push($userIdList, $d['dto']->userId);
                 }
             }
         }
         $this->assign('latest', $latest);
     }
     $this->assign('showLatest', $showLatest);
     $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars($userIdList);
     $this->assign('avatars', $avatars);
     $this->assign('currency', BOL_BillingService::getInstance()->getActiveCurrency());
     $this->assign('donators', (int) $service->countGoalDonators($goalId));
     $image = $goal['dto']->image ? $service->generateImageUrl($goal['dto']->image, true) : null;
     $this->assign('image', $image);
     $js = UTIL_JsGenerator::newInstance()->jQueryEvent('.btn-donate-goal-' . $goal['dto']->id, 'click', 'document.location.href = e.data.href', array('e'), array('href' => OW::getRouter()->urlForRoute('ocsfundraising.donate', array('goalId' => $goal['dto']->id))))->jQueryEvent('.btn-details-goal-' . $goal['dto']->id, 'click', 'document.location.href = e.data.href', array('e'), array('href' => OW::getRouter()->urlForRoute('ocsfundraising.project', array('id' => $goal['dto']->id))));
     OW::getDocument()->addOnloadScript($js);
 }
Exemplo n.º 28
0
 public function onItemRender(OW_Event $event)
 {
     $params = $event->getParams();
     $data = $event->getData();
     if ($params['action']['entityType'] != 'avatar-change') {
         return;
     }
     $userId = $params['action']['userId'];
     $avatarId = $params['action']['entityId'];
     $avatar = UAVATARS_BOL_Service::getInstance()->findLastByAvatarId($avatarId);
     if ($avatar === null) {
         return;
     }
     $staticUrl = OW::getPluginManager()->getPlugin('uavatars')->getStaticUrl();
     OW::getDocument()->addStyleSheet($staticUrl . 'style.css');
     OW::getDocument()->addScript($staticUrl . 'script.js');
     $avatars = UAVATARS_BOL_Service::getInstance()->findByUserId($userId, array(0, 2));
     UAVATARS_CLASS_PhotoBridge::getInstance()->initPhotoFloatBox();
     $js = UTIL_JsGenerator::newInstance();
     if (count($avatars) == 1) {
         $avatarUrl = UAVATARS_BOL_Service::getInstance()->getAvatarUrl($avatars[0]);
         $imgUniqId = uniqid('uavatar_');
         $data['content'] = '<div class="ua-newsfeed-avatars-wrap">
             <a id="' . $imgUniqId . '" class="ua-newsfeed-avatar ua-newsfeed-current-avatar ow_border" href="javascript://">
                 <img src="' . $avatarUrl . '" />
             </a>
             </div>';
         if (UAVATARS_CLASS_PhotoBridge::getInstance()->isPhotoExists($avatars[0]->photoId)) {
             $js->jQueryEvent('#' . $imgUniqId, 'click', 'UAVATARS.setPhoto(event.data.photoId);', array('event'), array('photoId' => $avatars[0]->photoId));
         }
     } else {
         $currentAvatarUrl = UAVATARS_BOL_Service::getInstance()->getAvatarUrl($avatars[0]);
         $prevAvatarUrl = UAVATARS_BOL_Service::getInstance()->getAvatarUrl($avatars[1]);
         $currentUniqId = uniqid('uavatar_');
         $prevUniqId = uniqid('uavatar_');
         $data['content'] = '<div class="ua-newsfeed-avatars-wrap">
             <a id="' . $prevUniqId . '" class="ua-newsfeed-avatar ua-newsfeed-prev-avatar ow_border" href="javascript://">
                 <img src="' . $prevAvatarUrl . '" />
             </a>
             <a id="' . $currentUniqId . '" class="ua-newsfeed-avatar ua-newsfeed-current-avatar ow_border" href="javascript://">
                 <img src="' . $currentAvatarUrl . '" />
             </a>
             </div>';
         if (UAVATARS_CLASS_PhotoBridge::getInstance()->isPhotoExists($avatars[0]->photoId)) {
             $js->jQueryEvent('#' . $currentUniqId, 'click', 'UAVATARS.setPhoto(event.data.photoId);', array('event'), array('photoId' => $avatars[0]->photoId));
         }
         if (UAVATARS_CLASS_PhotoBridge::getInstance()->isPhotoExists($avatars[1]->photoId)) {
             $js->jQueryEvent('#' . $prevUniqId, 'click', 'UAVATARS.setPhoto(event.data.photoId);', array('event'), array('photoId' => $avatars[1]->photoId));
         }
     }
     OW::getDocument()->addOnloadScript($js);
     $event->setData($data);
 }
Exemplo n.º 29
0
 public function index($params)
 {
     $document = OW::getDocument();
     $menu = UHEADER_CTRL_Admin::getMenu();
     $menu->getElement("gallery")->setActive(true);
     $this->addComponent("menu", $menu);
     $tplId = empty($params["tplId"]) ? null : $params["tplId"];
     $roleId = empty($_GET["role"]) ? null : $_GET["role"];
     UHEADER_CLASS_Plugin::getInstance()->includeStatic();
     UHEADER_CLASS_Plugin::getInstance()->includeStaticFile("admin.css");
     $uniqId = uniqid("uheader-cg-");
     if (empty($roleId) && !empty($tplId)) {
         $roles = $this->service->findRoleIdsByTemplateId($tplId);
         if (!empty($roles)) {
             $roleId = reset($roles);
         }
     }
     $roleIds = $roleId === null ? null : array($roleId);
     $list = $this->service->findTemplateList($roleIds);
     $tplList = array();
     foreach ($list as $template) {
         /*@var $template UHEADER_BOL_Template */
         $tplList[$template->id] = $this->getTplInfo($template);
     }
     $currentItem = $tplId === null || empty($tplList[$tplId]) ? reset($tplList) : $tplList[$tplId];
     $this->assign("list", $tplList);
     $this->assign("current", $currentItem);
     $this->assign("uploader", OW::getRouter()->urlFor(__CLASS__, "templateUploader"));
     $this->assign("uniqId", $uniqId);
     $config = array();
     $config['avatarSize'] = $this->config['avatar_big_size'];
     $config['coverHeight'] = $this->config["cover_height"];
     $config['previewHeight'] = self::ITEM_WIDTH / self::CANVAS_WIDTH * $config['coverHeight'];
     $this->assign("config", $config);
     $this->addComponent("contextToolbar", $this->getContextToolbar());
     $settings = array("rsp" => OW::getRouter()->urlFor(__CLASS__, "rsp"), "current" => $currentItem);
     $js = UTIL_JsGenerator::newInstance();
     $js->newObject(array("UHEADER", "activeGallery"), "UHEADER.AdminGallery", array($uniqId, $settings));
     $document->addOnloadScript($js);
     $roles = BOL_AuthorizationService::getInstance()->findNonGuestRoleList();
     $tplRoles = array();
     foreach ($roles as $role) {
         /* @var $role BOL_AuthorizationRole */
         $roleLabel = BOL_AuthorizationService::getInstance()->getRoleLabel($role->name);
         $tplRoles[] = array("id" => $role->id, "selected" => $roleId == $role->id, "label" => $roleLabel, "url" => OW::getRequest()->buildUrlQueryString(OW::getRouter()->urlForRoute("uheader-settings-gallery"), array("role" => $role->id)));
     }
     $this->assign("currentRoleId", $roleId);
     $this->assign("roleList", $tplRoles);
     $this->assign("allListUrl", OW::getRouter()->urlForRoute("uheader-settings-gallery"));
     $this->assign("previewWidth", self::ITEM_WIDTH);
     $this->initInfoLines();
     $this->assign("pluginUrl", UHEADER_CTRL_Admin::PLUGIN_STORE_URL);
 }
Exemplo n.º 30
0
 protected function getFeatures($data)
 {
     $configs = $this->sharedData['configs'];
     $feturesData = $this->getFeaturesData($data);
     $featureDefaults = array("uniqId" => uniqid("nf-feature-"), "class" => "", "active" => false, "count" => null, "error" => null, "url" => "javascript://", "hideButton" => false, "innerHtml" => null, "html" => null);
     $features = array();
     $js = UTIL_JsGenerator::newInstance();
     // Likes
     if (!empty($feturesData["system"]["likes"])) {
         $feature = $feturesData["system"]["likes"];
         $features["likes"] = array_merge($featureDefaults, array("uniqId" => uniqid("nf-feature-"), "class" => "owm_newsfeed_control_like", "active" => $feature["liked"], "count" => $feature["count"], "error" => $feature["error"], "url" => "javascript://"));
         $js->newObject("likeFeature", "NEWSFEED_MobileFeatureLikes", array($feature["entityType"], $feature["entityId"], $features["likes"]));
     }
     // Comments
     if (!empty($feturesData["system"]["comments"])) {
         $feature = $feturesData["system"]["comments"];
         $comments = array_merge($featureDefaults, array("uniqId" => uniqid("nf-feature-"), "class" => "owm_newsfeed_control_comment", "active" => false, "count" => $feature["count"], "url" => OW::getRequest()->buildUrlQueryString($this->itemPermalink, array(), "comments")));
         if ($this->displayType == NEWSFEED_MCMP_Feed::DISPLAY_TYPE_PAGE) {
             $comments["hideButton"] = true;
             $commentsParams = new BASE_CommentsParams($feature["authGroup"], $feature["entityType"]);
             $commentsParams->setEntityId($feature["entityId"]);
             $commentsParams->setCommentCountOnPage($configs['comments_count']);
             $commentsParams->setBatchData($feature["comments"]);
             //$commentsParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_PARTIAL_LIST_AND_MINI_IPC);
             $commentsParams->setOwnerId($data['action']['userId']);
             $commentsParams->setWrapInBox(false);
             if (!empty($feature['error'])) {
                 $commentsParams->setErrorMessage($feature['error']);
             }
             if (isset($feature['allow'])) {
                 $commentsParams->setAddComment($feature['allow']);
             }
             $commentCmp = new BASE_MCMP_Comments($commentsParams);
             $comments['html'] = $commentCmp->render();
         }
         $features[] = $comments;
     }
     $jsString = $js->generateJs();
     if (trim($jsString)) {
         OW::getDocument()->addOnloadScript($js);
     }
     foreach ($feturesData["custom"] as $customFeature) {
         $features[] = array_merge($featureDefaults, $customFeature);
     }
     $visibleCount = 0;
     foreach ($features as $f) {
         if (empty($f["hideButton"])) {
             $visibleCount++;
         }
     }
     return array("items" => $features, "buttonsCount" => $visibleCount);
 }