예제 #1
0
 /**
  * Returns class instance
  *
  * @return QUESTIONS_Plugin
  */
 public static function getInstance()
 {
     if (null === self::$classInstance) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
예제 #2
0
 public function __construct()
 {
     parent::__construct();
     static $count = 0;
     $count++;
     $uniqId = 'gtabs-' . $count;
     QUESTIONS_Plugin::getInstance()->addStatic();
     $js = UTIL_JsGenerator::newInstance()->newObject('questionsTabs', 'QUESTIONS_Tabs', array($uniqId));
     OW::getDocument()->addOnloadScript($js);
     $this->assign('uniqId', $uniqId);
 }
예제 #3
0
 public function onBeforeRender()
 {
     parent::onBeforeRender();
     $uniqId = uniqid('questionAdd');
     $this->assign('uniqId', $uniqId);
     $config = OW::getConfig()->getValues(QUESTIONS_Plugin::PLUGIN_KEY);
     $this->assign('configs', $config);
     $form = $this->initForm();
     $this->addForm($form);
     QUESTIONS_Plugin::getInstance()->addStatic();
     $js = UTIL_JsGenerator::newInstance()->newObject('questionsAdd', 'QUESTIONS_QuestionAdd', array($uniqId, $form->getName(), array('maxQuestionLength' => 500, 'minQuestionLength' => 3, 'maxAnswerLength' => 150)));
     OW::getDocument()->addOnloadScript($js);
 }
예제 #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 = QUESTIONS_BOL_FeedService::getInstance();
     $template = OW::getPluginManager()->getPlugin('questions')->getCmpViewDir() . 'feed.html';
     $this->setTemplate($template);
     $this->order = $this->service->getDefaultOrder();
     $this->feedType = self::FEED_ALL;
     QUESTIONS_Plugin::getInstance()->addStatic();
 }
 public function onInviteRender(OW_Event $event)
 {
     $params = $event->getParams();
     if (!in_array($params['entityType'], array('questions-answer', 'questions-post'))) {
         return;
     }
     QUESTIONS_Plugin::getInstance()->addStatic(true);
     $data = $params['data'];
     $questionSettings = $data['questionSettings'];
     $uniqId = $data['uniqId'];
     $questionSettings["url"] = OW::getRouter()->urlForRoute('questions-question', array('qid' => $questionSettings['questionId']));
     $data['url'] = 'javascript:(function() { QUESTIONS.openQuestion({
         questionId: ' . $questionSettings['questionId'] . ',
         relationId: ' . $questionSettings['relationId'] . ',
         userContext: ' . json_encode($questionSettings['userContext']) . ',
         "url": ' . json_encode($questionSettings["url"]) . '
     }); 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());
 }
예제 #6
0
<?php

/**
 * This software is intended for use with Oxwall Free Community Software http://www.oxwall.org/ and is
 * licensed under The BSD license.
 * ---
 * Copyright (c) 2012, Sergey Kambalin
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
 * following conditions are met:
 *
 *  - Redistributions of source code must retain the above copyright notice, this list of conditions and
 *  the following disclaimer.
 *
 *  - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
 *  the following disclaimer in the documentation and/or other materials provided with the distribution.
 *
 *  - Neither the name of the Oxwall Foundation nor the names of its contributors may be used to endorse or promote products
 *  derived from this software without specific prior written permission.
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
require_once dirname(__FILE__) . DS . 'plugin.php';
QUESTIONS_Plugin::getInstance()->install();
예제 #7
0
<?php

/**
 * This software is intended for use with Oxwall Free Community Software http://www.oxwall.org/ and is
 * licensed under The BSD license.
 * ---
 * Copyright (c) 2012, Sergey Kambalin
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
 * following conditions are met:
 *
 *  - Redistributions of source code must retain the above copyright notice, this list of conditions and
 *  the following disclaimer.
 *
 *  - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
 *  the following disclaimer in the documentation and/or other materials provided with the distribution.
 *
 *  - Neither the name of the Oxwall Foundation nor the names of its contributors may be used to endorse or promote products
 *  derived from this software without specific prior written permission.
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
require_once dirname(__FILE__) . DS . 'plugin.php';
QUESTIONS_Plugin::getInstance()->activate();
예제 #8
0
<?php

/**
 * This software is intended for use with Oxwall Free Community Software http://www.oxwall.org/ and is
 * licensed under The BSD license.
 * ---
 * Copyright (c) 2012, Sergey Kambalin
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
 * following conditions are met:
 *
 *  - Redistributions of source code must retain the above copyright notice, this list of conditions and
 *  the following disclaimer.
 *
 *  - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
 *  the following disclaimer in the documentation and/or other materials provided with the distribution.
 *
 *  - Neither the name of the Oxwall Foundation nor the names of its contributors may be used to endorse or promote products
 *  derived from this software without specific prior written permission.
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
require_once dirname(__FILE__) . DS . 'plugin.php';
QUESTIONS_Plugin::getInstance()->init();
예제 #9
0
 public function onBeforeRender()
 {
     if (!$this->doNotLoadStatic) {
         QUESTIONS_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 QUESTIONS_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, 'url' => $this->questionUrl);
     $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('QUESTIONS_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('questions', 'option_not_empty_delete_warning');
     OW::getLanguage()->addKeyForJs('questions', 'question_fb_title');
     OW::getLanguage()->addKeyForJs('questions', 'users_fb_title');
 }