Beispiel #1
0
 public function onBeforeRender()
 {
     parent::onBeforeRender();
     $uniqId = uniqid('questionAdd');
     $this->assign('uniqId', $uniqId);
     $config = OW::getConfig()->getValues(EQUESTIONS_Plugin::PLUGIN_KEY);
     $this->assign('configs', $config);
     $form = $this->initForm();
     $this->addForm($form);
     EQUESTIONS_Plugin::getInstance()->addStatic();
     $attachmentsId = null;
     if ($config['attachments']) {
         $types = array();
         if ($config['attachments_image']) {
             $types[] = 'image';
         }
         if ($config['attachments_video']) {
             $types[] = 'video';
         }
         if ($config['attachments_link']) {
             $types[] = 'link';
         }
         $attachments = new EQUESTIONS_CMP_Attachments($types);
         $attachments->initJs();
         $this->addComponent('attachments', $attachments);
         $attachmentsId = $attachments->getUniqId();
     }
     $js = UTIL_JsGenerator::newInstance()->newObject('questionsAdd', 'QUESTIONS_QuestionAdd', array($uniqId, $form->getName(), array('maxQuestionLength' => 500, 'minQuestionLength' => 3, 'maxAnswerLength' => 150), $attachmentsId));
     OW::getDocument()->addOnloadScript($js);
 }
Beispiel #2
0
 /**
  * Returns class instance
  *
  * @return EQUESTIONS_Plugin
  */
 public static function getInstance()
 {
     if (null === self::$classInstance) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Beispiel #3
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);
 }
Beispiel #4
0
 public function __construct($startStamp, $userId, $count)
 {
     parent::__construct();
     $this->userId = $userId;
     $this->uniqId = uniqid('questionList');
     $this->startStamp = (int) $startStamp;
     $this->count = $count;
     $this->service = EQUESTIONS_BOL_FeedService::getInstance();
     $template = OW::getPluginManager()->getPlugin('equestions')->getCmpViewDir() . 'feed.html';
     $this->setTemplate($template);
     $this->order = $this->service->getDefaultOrder();
     $this->feedType = self::FEED_ALL;
     EQUESTIONS_Plugin::getInstance()->addStatic();
 }
Beispiel #5
0
 public function onInviteRender(OW_Event $event)
 {
     $params = $event->getParams();
     if (!in_array($params['entityType'], array('questions-answer', 'questions-post'))) {
         return;
     }
     EQUESTIONS_Plugin::getInstance()->addStatic(true);
     $data = $params['data'];
     $questionSettings = $data['questionSettings'];
     $uniqId = $data['uniqId'];
     $data['url'] = 'javascript:(function() { QUESTIONS.openQuestion({
         questionId: ' . $questionSettings['questionId'] . ',
         relationId: ' . $questionSettings['relationId'] . ',
         userContext: ' . json_encode($questionSettings['userContext']) . '
     }); return void(0); })()';
     $event->setData($data);
     $js = UTIL_JsGenerator::newInstance();
     $js->jQueryEvent("." . $uniqId, 'click', 'QUESTIONS.openQuestion(e.data.questionSettings); return false;', array('e'), array('questionSettings' => $questionSettings));
     OW::getDocument()->addOnloadScript($js->generateJs());
 }
Beispiel #6
0
<?php

/**
 * Copyright (c) 2012, Sergey Kambalin
 * All rights reserved.
 * ATTENTION: This commercial software is intended for use with Oxwall Free Community Software http://www.oxwall.org/
 * and is licensed under Oxwall Store Commercial License.
 * Full text of this license can be found at http://www.oxwall.org/store/oscl
 */
require_once dirname(__FILE__) . DS . 'plugin.php';
EQUESTIONS_Plugin::getInstance()->install();
Beispiel #7
0
<?php

/**
 * Copyright (c) 2012, Sergey Kambalin
 * All rights reserved.
 * ATTENTION: This commercial software is intended for use with Oxwall Free Community Software http://www.oxwall.org/
 * and is licensed under Oxwall Store Commercial License.
 * Full text of this license can be found at http://www.oxwall.org/store/oscl
 */
require_once dirname(__FILE__) . DS . 'plugin.php';
EQUESTIONS_Plugin::getInstance()->deactivate();
Beispiel #8
0
 public function onBeforeRender()
 {
     if (!empty($this->attachment)) {
         if ($this->expandedView) {
             $this->attachment['onclick'] = null;
         } else {
             $this->attachment['onclick'] = 'QUESTIONS_AnswerListCollection.' . $this->uniqId . '.openQuestion(); return false;';
             if ($this->attachment['type'] != 'link') {
                 $this->attachment['href'] = $this->questionUrl;
             }
         }
         $attachCmp = new EQUESTIONS_CMP_Attachment($this->attachment, $this->expandedView);
         $this->addComponent('attachment', $attachCmp);
     }
     if (!$this->doNotLoadStatic) {
         EQUESTIONS_Plugin::getInstance()->addStatic();
     }
     if ($this->editable === null) {
         $this->editable = $this->service->isCurrentUserCanInteract($this->question) && $this->service->isCurrentUserCanAnswer($this->question);
     }
     $tmp = $this->service->findOptionListAndAnswerCountList($this->question->id, $this->startStamp, $this->userContext, $this->limit);
     $optionsDtoList = $tmp['optionList'];
     $countList = $tmp['countList'];
     $userContext = null;
     if (is_array($this->userContext)) {
         $userContext = $this->userContext;
         $userContext[] = $this->userId;
         $userContext = array_unique($userContext);
     }
     $totalAnswerCount = $this->totalAnswerCount == null ? $this->service->findTotalAnswersCount($this->question->id) : $this->totalAnswerCount;
     $answerCount = $this->poll ? $totalAnswerCount : $this->service->findMaxAnswersCount($this->question->id);
     $optionList = new EQUESTIONS_CMP_OptionList($optionsDtoList, $this->uniqId, $this->userId);
     $optionList->setAnswerCount($answerCount);
     $optionList->setEditable($this->editable);
     $optionList->setIsPoll($this->poll);
     $optionList->setUsersContext($userContext);
     $optionList->setEditMode($this->editMode);
     $options = $optionList->initOption($countList);
     $shareData = array('userId' => $this->userId, 'ownerId' => $this->question->userId, 'editable' => $this->editable, 'editMode' => $this->editMode, 'questionId' => $this->question->id, 'totalAnswers' => $answerCount, 'poll' => $this->poll, 'uniqId' => $this->uniqId, 'userContext' => $userContext, 'displayedCount' => count($options), 'optionTotal' => $this->optionTotal, 'startStamp' => $this->startStamp, 'ignoreOptions' => array(), 'expandedView' => $this->expandedView, 'inPopupMode' => $this->inPopupMode, 'ownerMode' => $this->userId == $this->question->userId);
     $shareData['offset'] = $shareData['displayedCount'];
     $shareData['st']['displayedCount'] = $shareData['displayedCount'];
     $shareData['st']['optionTotal'] = $shareData['optionTotal'];
     $jsAccessor = 'questionAnswers';
     $js = UTIL_JsGenerator::newInstance();
     $js->equateVarables($jsAccessor, array('QUESTIONS_AnswerListCollection', $this->uniqId));
     $js->callFunction(array($jsAccessor, 'init'), array($this->uniqId, $options, $shareData, !$this->editable));
     $js->callFunction(array($jsAccessor, 'setResponder'), array(OW::getRouter()->urlFor('EQUESTIONS_CTRL_Questions', 'rsp')));
     $this->assign('viewMore', $this->viewMore);
     $this->assign('editMode', $this->editMode);
     if ($this->viewMore) {
         $js->callFunction(array($jsAccessor, 'initViewMore'), array());
         $this->assign('viewMoreUrl', $this->questionUrl);
     }
     $addNewAvaliable = $this->editable && !$this->poll;
     $this->assign('addNew', $addNewAvaliable);
     $this->assign('hideAddNew', !$this->isAddNewAvaliable());
     if ($addNewAvaliable) {
         $js->callFunction(array($jsAccessor, 'initAddNew'), array());
     }
     OW::getDocument()->addOnloadScript($js);
     $this->assign('uniqId', $this->uniqId);
     $this->addComponent('list', $optionList);
     OW::getLanguage()->addKeyForJs('equestions', 'option_not_empty_delete_warning');
     OW::getLanguage()->addKeyForJs('equestions', 'question_fb_title');
     OW::getLanguage()->addKeyForJs('equestions', 'users_fb_title');
 }
Beispiel #9
0
 public function onInviteRender(OW_Event $event)
 {
     $params = $event->getParams();
     if ($params['entityType'] != self::INVITATION_ASK) {
         return;
     }
     EQUESTIONS_Plugin::getInstance()->addStatic(true);
     $data = $params['data'];
     $questionSettings = $data['questionSettings'];
     $uniqId = $data['uniqId'];
     $notificationId = (int) $params['entityId'];
     $itemKey = $params['key'];
     $data['toolbar'] = array(array('label' => OW::getLanguage()->text('equestions', 'invitation_ignore_label'), 'id' => 'toolbar_ignore_' . $itemKey));
     $event->setData($data);
     $js = UTIL_JsGenerator::newInstance();
     $js->jQueryEvent("#" . $uniqId, 'click', 'QUESTIONS.openQuestion(e.data.questionSettings); return false;', array('e'), array('questionSettings' => $questionSettings));
     $jsData = array('notificationId' => $notificationId, 'itemKey' => $itemKey);
     $js->jQueryEvent("#toolbar_ignore_{$itemKey}", 'click', 'OW.Invitation.send("questions.ignore", e.data.notificationId).removeItem(e.data.itemKey);', array('e'), $jsData);
     OW::getDocument()->addOnloadScript($js->generateJs());
 }
Beispiel #10
0
 private function installNew()
 {
     EQUESTIONS_Plugin::getInstance()->completeInstall();
     EQUESTIONS_Plugin::getInstance()->fullActivate();
 }
Beispiel #11
0
<?php

/**
 * Copyright (c) 2012, Sergey Kambalin
 * All rights reserved.
 * ATTENTION: This commercial software is intended for use with Oxwall Free Community Software http://www.oxwall.org/
 * and is licensed under Oxwall Store Commercial License.
 * Full text of this license can be found at http://www.oxwall.org/store/oscl
 */
require_once dirname(__FILE__) . DS . 'plugin.php';
EQUESTIONS_Plugin::getInstance()->init();