public function onCollectList(BASE_CLASS_EventCollector $event) { $language = OW::getLanguage(); $action = array('key' => self::ACTION_VIEW_TAGS, 'pluginKey' => $this->plugin->getKey(), 'label' => $language->text($this->plugin->getKey(), 'privacy_action_view_tags'), 'description' => '', 'defaultValue' => 'everybody'); $event->add($action); $action = array('key' => self::ACTION_TAG_MY_PHOTO, 'pluginKey' => $this->plugin->getKey(), 'label' => $language->text($this->plugin->getKey(), 'privacy_action_tag_my_photo'), 'description' => '', 'defaultValue' => 'everybody'); $event->add($action); }
/** * Class constructor */ public function __construct() { parent::__construct(); $this->plugin = OW::getPluginManager()->getPlugin('video'); $this->pluginJsUrl = $this->plugin->getStaticJsUrl(); $this->ajaxResponder = OW::getRouter()->urlFor('VIDEO_CTRL_Video', 'ajaxResponder'); $this->clipService = VIDEO_BOL_ClipService::getInstance(); }
/** * Class constructor */ public function __construct() { parent::__construct(); $this->plugin = OW::getPluginManager()->getPlugin('vwls'); $this->pluginJsUrl = $this->plugin->getStaticJsUrl(); $this->ajaxResponder = OW::getRouter()->urlFor('VWLS_CTRL_Vwls', 'ajaxResponder'); $this->clipService = VWLS_BOL_ClipService::getInstance(); $this->menu = $this->getMenu(); if (!OW::getRequest()->isAjax()) { OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'vwls', 'vwls'); } }
public function initStatic() { $staticUrl = $this->plugin->getStaticUrl(); OW::getDocument()->addStyleSheet($staticUrl . 'style.min.css'); OW::getDocument()->addScript($staticUrl . 'script.min.js'); $utils = array(); $utils['queryRsp'] = OW::getRouter()->urlFor('HINT_CTRL_Hint', 'query'); $js = UTIL_JsGenerator::newInstance()->callFunction(array('HINT.UTILS', 'init'), array($utils)); $hint = array(); $hint['rsp'] = OW::getRouter()->urlFor('HINT_CTRL_Hint', 'rsp'); $js->callFunction(array('HINT.Launcher', 'init'), array($hint, $this->getMaskList(), $this->getIgnoreSelectorsList())); OW::getDocument()->addOnloadScript($js); }
public function includeStaticFile($file) { $document = OW::getDocument(); $staticUrl = $this->plugin->getStaticUrl(); $ext = UTIL_File::getExtension($file); $file .= "?" . $this->plugin->getDto()->build; switch ($ext) { case "css": $document->addStyleSheet($staticUrl . $file); break; case "js": $document->addScript($staticUrl . $file); break; } }
public function onCollectActions(BASE_CLASS_EventCollector $e) { $e->add(array('section' => $this->plugin->getKey(), 'action' => self::ACTION_COMMENT, 'sectionIcon' => 'ow_ic_picture', 'sectionLabel' => OW::getLanguage()->text($this->plugin->getKey(), 'notifications_section_label'), 'description' => OW::getLanguage()->text($this->plugin->getKey(), 'notifications_setting_comment'), 'selected' => true)); if (UHEADER_CLASS_NewsfeedBridge::getInstance()->isActive()) { $e->add(array('section' => $this->plugin->getKey(), 'action' => self::ACTION_LIKE, 'sectionIcon' => 'ow_ic_picture', 'sectionLabel' => OW::getLanguage()->text($this->plugin->getKey(), 'notifications_section_label'), 'description' => OW::getLanguage()->text($this->plugin->getKey(), 'notifications_setting_like'), 'selected' => true)); } }
public function addBuiltInCovers($defaults = true) { $covers = array("forest.jpg", "bridge.jpg", "grass.jpg", "landscape.jpg", "sea.jpg", "sky.jpg", "feathers.jpg", "abstract-lines.jpg", "abstract-stripes.jpg", "line.jpg"); $defaultCovers = $defaults ? array("grass.jpg", "bridge.jpg", "forest.jpg") : array(); foreach ($covers as $fileName) { $filePath = $this->plugin->getRootDir() . "covers" . DS . $fileName; $this->addTemplate($filePath, null, in_array($fileName, $defaultCovers)); } }
public function onCollectActions(BASE_CLASS_EventCollector $e) { $sectionLabel = OW::getLanguage()->text('groups', 'email_notification_section_label'); $sectionIcon = 'ow_ic_files'; $e->add(array('section' => 'groups', 'action' => self::ACTION_COMMENT, 'sectionIcon' => $sectionIcon, 'sectionLabel' => $sectionLabel, 'description' => OW::getLanguage()->text($this->plugin->getKey(), 'notifications_setting_comment'), 'selected' => true)); $e->add(array('section' => 'groups', 'action' => self::ACTION_ADD, 'sectionIcon' => $sectionIcon, 'sectionLabel' => $sectionLabel, 'description' => OW::getLanguage()->text($this->plugin->getKey(), 'notifications_setting_add'), 'selected' => true)); if (GHEADER_CLASS_NewsfeedBridge::getInstance()->isActive()) { $e->add(array('section' => 'groups', 'action' => self::ACTION_LIKE, 'sectionIcon' => $sectionIcon, 'sectionLabel' => $sectionLabel, 'description' => OW::getLanguage()->text($this->plugin->getKey(), 'notifications_setting_like'), 'selected' => true)); } }
public function onGroupEdit(OW_Event $event) { $params = $event->getParams(); $groupId = (int) $params['groupId']; $cover = GHEADER_BOL_Service::getInstance()->findCoverByGroupId($groupId); if ($cover === null) { return; } $eventParams = array('pluginKey' => $this->plugin->getKey(), 'entityType' => GHEADER_CLASS_CommentsBridge::ENTITY_TYPE, 'entityId' => $cover->id); $event = new OW_Event('feed.action', $eventParams); OW::getEventManager()->trigger($event); }
public function pullPhoto($photoId) { if (!$this->isActive()) { return null; } $photo = PHOTO_BOL_PhotoService::getInstance()->findPhotoById($photoId); if (empty($photo)) { return null; } $source = PHOTO_BOL_PhotoService::getInstance()->getPhotoPath($photoId, $photo->hash); $pluginfilesDir = $this->plugin->getPluginFilesDir(); $dist = $pluginfilesDir . uniqid('tmp_') . '.jpg'; if (!OW::getStorage()->copyFileToLocalFS($source, $dist)) { return null; } return $dist; }
public function onLike(OW_Event $event) { $params = $event->getParams(); if ($params['entityType'] != UHEADER_CLASS_CommentsBridge::ENTITY_TYPE) { return; } $userId = $params['userId']; $coverId = $params['entityId']; $cover = UHEADER_BOL_Service::getInstance()->findCoverById($coverId); $string = null; if ($cover->userId == $userId) { $string = array("key" => 'uheader+activity_string_cover_like_self'); } else { $userName = BOL_UserService::getInstance()->getDisplayName($cover->userId); $userUrl = BOL_UserService::getInstance()->getUserUrl($cover->userId); $userEmbed = '<a href="' . $userUrl . '">' . $userName . '</a>'; $string = array("key" => 'uheader+activity_string_cover_like', "vars" => array('user' => $userEmbed)); } OW::getEventManager()->trigger(new OW_Event('feed.activity', array('activityType' => 'like', 'activityId' => $userId, 'entityId' => $params['entityId'], 'entityType' => $params['entityType'], 'userId' => $userId, 'pluginKey' => $this->plugin->getKey()), array('string' => $string))); }
public function onCollectList(BASE_CLASS_EventCollector $event) { $language = OW::getLanguage(); $action = array('key' => self::PRIVACY_ACTION, 'pluginKey' => $this->plugin->getKey(), 'label' => $language->text($this->plugin->getKey(), 'privacy_action_view_cover'), 'description' => '', 'defaultValue' => 'everybody'); $event->add($action); }
public function init() { OW::getAutoloader()->addPackagePointer("NEWSFEED_FORMAT", $this->plugin->getRootDir() . "formats" . DS); OW::getAutoloader()->addPackagePointer("NEWSFEED_MFORMAT", $this->plugin->getMobileDir() . "formats" . DS); OW::getEventManager()->bind(OW_EventManager::ON_PLUGINS_INIT, array($this, "collectFormats")); }
public function __construct($params) { parent::__construct($params); }
public function initPlugin(OW_Plugin $pluginObject) { $this->addPackagePointers($pluginObject->getDto()); $initDirPath = $pluginObject->getRootDir(); if (OW::getApplication()->getContext() == OW::CONTEXT_MOBILE) { $initDirPath = $pluginObject->getMobileDir(); } else { if (OW::getApplication()->getContext() == OW::CONTEXT_API) { $initDirPath = $pluginObject->getApiDir(); } } if (file_exists($initDirPath . 'init.php')) { OW::getEventManager()->trigger(new OW_Event("core.performance_test", array("key" => "plugin_init.start", "pluginKey" => $pluginObject->getKey()))); include $initDirPath . 'init.php'; OW::getEventManager()->trigger(new OW_Event("core.performance_test", array("key" => "plugin_init.end", "pluginKey" => $pluginObject->getKey()))); } }
/** * Adds platform predefined package pointers * * @param BOL_Plugin $pluginDto */ public function addPackagePointers(BOL_Plugin $pluginDto) { $plugin = new OW_Plugin($pluginDto); $upperedKey = mb_strtoupper($plugin->getKey()); $autoloader = OW::getAutoloader(); $predefinedPointers = array("CMP" => $plugin->getCmpDir(), "CTRL" => $plugin->getCtrlDir(), "BOL" => $plugin->getBolDir(), "CLASS" => $plugin->getClassesDir(), "MCMP" => $plugin->getMobileCmpDir(), "MCTRL" => $plugin->getMobileCtrlDir(), "MBOL" => $plugin->getMobileBolDir(), "MCLASS" => $plugin->getMobileClassesDir(), "ACTRL" => $plugin->getApiCtrlDir(), "ABOL" => $plugin->getApiBolDir(), "ACLASS" => $plugin->getApiClassesDir()); foreach ($predefinedPointers as $pointer => $dirPath) { $autoloader->addPackagePointer($upperedKey . "_" . $pointer, $dirPath); } }
private function getAlbumName() { $albumName = OW::getLanguage()->text($this->plugin->getKey(), 'default_photo_album_name'); return empty($albumName) ? $this->defaultPhotoAlbumName : $albumName; }
/** * Displays mailbox inbox page */ public function inbox() { $this->contentMenu->getElement('inbox')->setActive(true); $language = OW::getLanguage(); OW::getDocument()->setTitle($language->text('mailbox', 'inbox_meta_tilte')); $userId = OW::getUser()->getId(); if (!OW::getUser()->isAuthenticated() || $userId === null) { throw new AuthenticateException(); } $conversationService = MAILBOX_BOL_ConversationService::getInstance(); if (OW::getRequest()->isPost()) { if (!empty($_POST['conversation']) && is_array($_POST['conversation'])) { $conversationList = $_POST['conversation']; if (isset($_POST['mark_as_read'])) { $count = $conversationService->markRead($conversationList, $userId); OW::getFeedback()->info($language->text('mailbox', 'mark_read_message', array('count' => $count))); } else { if (isset($_POST['mark_as_unread'])) { $count = $conversationService->markUnread($conversationList, $userId); OW::getFeedback()->info($language->text('mailbox', 'mark_unread_message', array('count' => $count))); } else { if (isset($_POST['delete'])) { $count = $conversationService->deleteConversation($conversationList, $userId); OW::getFeedback()->info($language->text('mailbox', 'delete_message', array('count' => $count))); } } } } $this->redirect(OW::getRequest()->getRequestUri()); } //paging $recordsToPage = $this->recordsToPage; $record = array(); $recordsCount = (int) $conversationService->getInboxConversationCount($userId); $pageCount = (int) ceil($recordsCount / $recordsToPage); $page = 1; if ($recordsCount > $recordsToPage) { if (isset($_GET['page'])) { if ((int) $_GET['page'] < 1) { $this->redirect(OW::getRouter()->urlForRoute('mailbox_inbox') . '?page=' . 1); } $page = (int) $_GET['page']; } } if (empty($pageCount) || $pageCount < 1) { $pageCount = 1; } if ($page > $pageCount) { $this->redirect(OW::getRouter()->urlForRoute('mailbox_inbox') . '?page=' . $pageCount); } $paging = new BASE_CMP_Paging($page, $pageCount, $recordsToPage); $this->assign('paging', $paging->render()); $startRecord = (int) (($page - 1) * $recordsToPage); $record['new'] = (int) $conversationService->getNewInboxConversationCount($userId); $record['total'] = $recordsCount; $record['start'] = $startRecord + 1; $record['end'] = (int) $page * $recordsToPage <= $recordsCount ? (int) $page * $recordsToPage : $recordsCount; $this->assign('record', $record); //-- $conversations = $conversationService->getInboxConversationList($userId, $startRecord, $recordsToPage); $conversationList = array(); $opponentsId = array(); $conversationsId = array(); foreach ($conversations as $value) { $conversation = array(); $conversation['conversationId'] = $value['conversationId']; $conversation['userId'] = $userId; $conversation['recipientRead'] = $value['recipientRead']; $conversation['read'] = false; $conversation['url'] = $conversationService->getConversationUrl($conversation['conversationId']); $conversation['deleteUrl'] = OW::getRouter()->urlFor('MAILBOX_CTRL_Mailbox', 'deleteInbox', array("conversationId" => $conversation['conversationId'], "page" => $page)); switch ($userId) { case $value['initiatorId']: $conversation['opponentId'] = $value['interlocutorId']; $conversation['isOpponentLastMessage'] = false; if ($value['initiatorMessageId'] < $value['interlocutorMessageId']) { $conversation['isOpponentLastMessage'] = true; } if ((int) $value['read'] & MAILBOX_BOL_ConversationDao::READ_INITIATOR) { $conversation['read'] = true; } break; case $value['interlocutorId']: $conversation['opponentId'] = $value['initiatorId']; $conversation['isOpponentLastMessage'] = false; if ($value['initiatorMessageId'] > $value['interlocutorMessageId']) { $conversation['isOpponentLastMessage'] = true; } if ((int) $value['read'] & MAILBOX_BOL_ConversationDao::READ_INTERLOCUTOR) { $conversation['read'] = true; } break; } $conversation['timeStamp'] = UTIL_DateTime::formatDate((int) $value['timeStamp']); $conversation['subject'] = $value['subject']; $conversation['text'] = '<span class="error">' . OW::getLanguage()->text('mailbox', 'read_permission_denied') . '</span>'; 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 && !$conversation['recipientRead']) { $creditsMsg = OW::getEventManager()->call('usercredits.error_message', $eventParams); $conversation['text'] = '<span class="error">' . $creditsMsg . '</span>'; } else { $short = mb_strlen($value['text']) > 100 ? mb_substr($value['text'], 0, 100) . '...' : $value['text']; //TODO: $short = UTIL_HtmlTag::autoLink($short); $event = new OW_Event('mailbox.message_render', array('conversationId' => $conversation['conversationId'], 'messageId' => $value['id'], 'senderId' => $conversation['userId'], 'recipientId' => $conversation['opponentId']), array('short' => $short, 'full' => $value['text'])); OW::getEventManager()->trigger($event); $eventData = $event->getData(); $conversation['text'] = $eventData['short']; } } $conversationList[] = $conversation; $opponentsId[] = $conversation['opponentId']; $conversationsId[] = $conversation['conversationId']; } $opponentsId = array_unique($opponentsId); $conversationsId = array_unique($conversationsId); $opponentsAvatar = BOL_AvatarService::getInstance()->getDataForUserAvatars($opponentsId); $opponentsUrl = BOL_UserService::getInstance()->getUserUrlsForList($opponentsId); $opponentsDisplayNames = BOL_UserService::getInstance()->getDisplayNamesForList($opponentsId); $attachmentsCount = $conversationService->getAttachmentsCountByConversationList($conversationsId); $this->assign('attachments', $attachmentsCount); $this->assign('opponentsAvatar', $opponentsAvatar); $this->assign('opponentsUrl', $opponentsUrl); $this->assign('opponentsDisplayNames', $opponentsDisplayNames); $this->assign('conversationList', $conversationList); $deleteConfirmMessage = OW::getLanguage()->text('mailbox', 'delete_confirm_message'); //include js $onLoadJs = " \$( document ).ready( function(){\n\t\t\t\t\t\tvar inbox = new mailboxConversationList( " . json_encode(array('responderUrl' => $this->responderUrl, 'deleteConfirmMessage' => $deleteConfirmMessage)) . " );\n\t\t\t\t\t\tinbox.bindFunction();\n\t\t\t\t\t} ); "; OW::getDocument()->addOnloadScript($onLoadJs); OW::getDocument()->addScript($this->jsDirUrl . "mailbox.js"); }
/** * * @return PHOTO_BOL_Photo */ private function upload($userId, $path, $description, $tagData) { $pluginfilesDir = $this->plugin->getPluginFilesDir(); $source = $pluginfilesDir . uniqid('tmp_') . '.jpg'; if (!@OW::getStorage()->copyFileToLocalFS($path, $source)) { return null; } $photoService = PHOTO_BOL_PhotoService::getInstance(); $album = $this->getAlbum($userId); $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $userId, 'action' => 'photo_view_album')); $photo = new PHOTO_BOL_Photo(); $photo->description = htmlspecialchars($description); $photo->albumId = $album->id; $photo->addDatetime = time(); $photo->status = 'approved'; $photo->hasFullsize = true; $photo->privacy = mb_strlen($privacy) ? $privacy : 'everybody'; $photoService->addPhoto($photo); $config = OW::getConfig(); $width = $config->getValue('photo', 'main_image_width'); $height = $config->getValue('photo', 'main_image_height'); $previewWidth = $config->getValue('photo', 'preview_image_width'); $previewHeight = $config->getValue('photo', 'preview_image_height'); $tmpMainPath = $pluginfilesDir . 'main_' . $photo->id . '.jpg'; $tmpPreviewPath = $pluginfilesDir . 'preview_' . $photo->id . '.jpg'; $tmpOriginalPath = $pluginfilesDir . 'original_' . $photo->id . '.jpg'; try { $image = new UTIL_Image($source); $tagCoords = $this->getTagRealCoords($tagData, $image->getWidth(), $image->getHeight(), $previewWidth, $previewHeight); $mainPhoto = $image->resizeImage($width, $height)->saveImage($tmpMainPath); //Cropping tag if (!empty($tagCoords["crop"])) { $mainPhoto->cropImage($tagCoords["crop"]["left"], $tagCoords["crop"]["top"], $tagCoords["crop"]["width"], $tagCoords["crop"]["height"]); } if (!empty($tagCoords["resize"])) { $mainPhoto->resizeImage($tagCoords["resize"]["width"], $tagCoords["resize"]["height"], $tagCoords["resize"]["crop"]); } $mainPhoto->saveImage($tmpPreviewPath); if ($config->getValue('photo', 'store_fullsize') && $mainPhoto->imageResized()) { $originalImage = new UTIL_Image($source); $res = (int) $config->getValue('photo', 'fullsize_resolution'); $res = $res ? $res : 1024; $originalImage->resizeImage($res, $res)->saveImage($tmpOriginalPath); $photo->hasFullsize = true; } else { $photo->hasFullsize = false; $photoService->updatePhoto($photo); } } catch (WideImage_Exception $e) { @unlink($source); return null; } @unlink($source); $storage = OW::getStorage(); $mainPath = $photoService->getPhotoPath($photo->id, $photo->hash); $previewPath = $photoService->getPhotoPath($photo->id, $photo->hash, 'preview'); $originalPath = $photoService->getPhotoPath($photo->id, $photo->hash, 'original'); $storage->copyFile($tmpMainPath, $mainPath); @unlink($tmpMainPath); $storage->copyFile($tmpPreviewPath, $previewPath); @unlink($tmpPreviewPath); if ($photo->hasFullsize) { $storage->copyFile($tmpOriginalPath, $originalPath); @unlink($tmpOriginalPath); } return $photo; }
public function getCoverPath(UHEADER_BOL_CoverBase $cover) { return $this->plugin->getUserFilesDir() . $cover->file; }
/** * Uninstalls plugin * * @param string $pluginKey */ public function uninstall($pluginKey) { if (empty($pluginKey)) { throw new LogicException("Empty plugin key provided for uninstall"); } $pluginDto = $this->findPluginByKey(trim($pluginKey)); if ($pluginDto === null) { throw new LogicException("Invalid plugin key - `{$pluginKey}` provided for uninstall!"); } $plugin = new OW_Plugin($pluginDto); // trigger event OW::getEventManager()->trigger(new OW_Event(OW_EventManager::ON_BEFORE_PLUGIN_UNINSTALL, array("pluginKey" => $pluginDto->getKey()))); $this->includeScript($plugin->getRootDir() . BOL_PluginService::SCRIPT_DEACTIVATE); $this->includeScript($plugin->getRootDir() . BOL_PluginService::SCRIPT_UNINSTALL); // delete plugin work dirs $dirsToRemove = array($plugin->getPluginFilesDir(), $plugin->getUserFilesDir(), $plugin->getPublicStaticDir()); foreach ($dirsToRemove as $dir) { if (file_exists($dir)) { UTIL_File::removeDir($dir); } } // remove plugin configs OW::getConfig()->deletePluginConfigs($pluginDto->getKey()); // delete language prefix $prefixId = BOL_LanguageService::getInstance()->findPrefixId($pluginDto->getKey()); if (!empty($prefixId)) { BOL_LanguageService::getInstance()->deletePrefix($prefixId, true); } //delete authorization stuff BOL_AuthorizationService::getInstance()->deleteGroup($pluginDto->getKey()); // drop plugin tables $tables = OW::getDbo()->queryForColumnList("SHOW TABLES LIKE '" . str_replace('_', '\\_', OW_DB_PREFIX) . $pluginDto->getKey() . "\\_%'"); if (!empty($tables)) { $query = "DROP TABLE "; foreach ($tables as $table) { $query .= "`" . $table . "`,"; } $query = substr($query, 0, -1); OW::getDbo()->query($query); } //remove entry in DB $this->deletePluginById($pluginDto->getId()); $this->updatePluginListCache(); // trigger event OW::getEventManager()->trigger(new OW_Event(OW_EventManager::ON_AFTER_PLUGIN_UNINSTALL, array("pluginKey" => $pluginDto->getKey()))); }
protected function getViewDir() { return $this->plugin->getViewDir(); }