Ejemplo n.º 1
0
 public function __construct()
 {
     WiseChatContainer::load('model/WiseChatMessage');
     WiseChatContainer::load('dao/criteria/WiseChatMessagesCriteria');
     $this->usersDAO = WiseChatContainer::get('dao/user/WiseChatUsersDAO');
     $this->channelsDAO = WiseChatContainer::get('dao/WiseChatChannelsDAO');
     $this->channelUsersDAO = WiseChatContainer::get('dao/WiseChatChannelUsersDAO');
     $this->table = WiseChatInstaller::getMessagesTable();
 }
Ejemplo n.º 2
0
 public function __construct()
 {
     WiseChatContainer::load('model/WiseChatBan');
     $this->options = WiseChatOptions::getInstance();
     $this->bansDAO = WiseChatContainer::getLazy('dao/WiseChatBansDAO');
     $this->messagesDAO = WiseChatContainer::getLazy('dao/WiseChatMessagesDAO');
     $this->channelUsersDAO = WiseChatContainer::getLazy('dao/WiseChatChannelUsersDAO');
     $this->usersDAO = WiseChatContainer::getLazy('dao/user/WiseChatUsersDAO');
 }
Ejemplo n.º 3
0
 public function __construct()
 {
     WiseChatContainer::load('model/WiseChatChannel');
     $this->options = WiseChatOptions::getInstance();
     $this->channelsDAO = WiseChatContainer::get('dao/WiseChatChannelsDAO');
     $this->usersDAO = WiseChatContainer::get('dao/user/WiseChatUsersDAO');
     $this->channelUsersDAO = WiseChatContainer::get('dao/WiseChatChannelUsersDAO');
     $this->userService = WiseChatContainer::get('services/user/WiseChatUserService');
     $this->authentication = WiseChatContainer::getLazy('services/user/WiseChatAuthentication');
     $this->authorization = WiseChatContainer::getLazy('services/user/WiseChatAuthorization');
 }
Ejemplo n.º 4
0
 public function __construct()
 {
     $this->options = WiseChatOptions::getInstance();
     $this->messagesService = WiseChatContainer::get('services/WiseChatMessagesService');
     $this->usersDAO = WiseChatContainer::get('dao/user/WiseChatUsersDAO');
     $this->channelUsersDAO = WiseChatContainer::get('dao/WiseChatChannelUsersDAO');
     $this->authentication = WiseChatContainer::getLazy('services/user/WiseChatAuthentication');
     WiseChatContainer::load('WiseChatThemes');
     WiseChatContainer::load('rendering/WiseChatTemplater');
     $this->templater = new WiseChatTemplater($this->options->getPluginBaseDir());
 }
Ejemplo n.º 5
0
 /**
  * Tokenizes command and returns command resolver.
  *
  * @param WiseChatChannel $channel Name of the channel
  * @param string $command The command
  *
  * @return WiseChatAbstractCommand
  */
 private function getCommandResolver($channel, $command)
 {
     try {
         $commandClassName = $this->getClassNameFromCommand($command);
         WiseChatContainer::load("commands/{$commandClassName}");
         $tokens = $this->getTokenizedCommand($command);
         array_shift($tokens);
         return new $commandClassName($channel, $tokens);
     } catch (Exception $e) {
         return null;
     }
 }
Ejemplo n.º 6
0
 /**
  * Returns geo details about the IP address.
  *
  * @param string $ipAddress
  *
  * @return WiseChatGeoDetails
  */
 public function getGeoDetails($ipAddress)
 {
     if (!function_exists('curl_init') || strlen($ipAddress) == 0 || $ipAddress == '127.0.0.1' || $ipAddress == '::1') {
         return null;
     }
     WiseChatContainer::load('model/WiseChatGeoDetails');
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curl, CURLOPT_URL, 'http://www.geoplugin.net/json.gp?ip=' . urlencode($ipAddress));
     $data = curl_exec($curl);
     curl_close($curl);
     $rawData = json_decode($data);
     if ($rawData !== null && property_exists($rawData, 'geoplugin_status') && $rawData->geoplugin_status > 0) {
         $details = new WiseChatGeoDetails();
         if (property_exists($rawData, 'geoplugin_city')) {
             $details->setCity($rawData->geoplugin_city);
         }
         if (property_exists($rawData, 'geoplugin_regionCode')) {
             $details->setRegionCode($rawData->geoplugin_regionCode);
         }
         if (property_exists($rawData, 'geoplugin_countryCode')) {
             $details->setCountryCode($rawData->geoplugin_countryCode);
         }
         if (property_exists($rawData, 'geoplugin_countryName')) {
             $details->setCountry($rawData->geoplugin_countryName);
         }
         if (property_exists($rawData, 'geoplugin_continentCode')) {
             $details->setContinentCode($rawData->geoplugin_continentCode);
         }
         if (property_exists($rawData, 'geoplugin_latitude')) {
             $details->setLatitude($rawData->geoplugin_latitude);
         }
         if (property_exists($rawData, 'geoplugin_longitude')) {
             $details->setLongitude($rawData->geoplugin_longitude);
         }
         if (property_exists($rawData, 'geoplugin_regionName')) {
             $details->setRegion($rawData->geoplugin_regionName);
         }
         if (property_exists($rawData, 'geoplugin_currencyCode')) {
             $details->setCurrencyCode($rawData->geoplugin_currencyCode);
         }
         return $details;
     }
     return null;
 }
Ejemplo n.º 7
0
 public function __construct()
 {
     $this->options = WiseChatOptions::getInstance();
     $this->usersDAO = WiseChatContainer::get('dao/user/WiseChatUsersDAO');
     $this->userSettingsDAO = WiseChatContainer::get('dao/user/WiseChatUserSettingsDAO');
     $this->channelUsersDAO = WiseChatContainer::get('dao/WiseChatChannelUsersDAO');
     $this->actionsDAO = WiseChatContainer::get('dao/WiseChatActionsDAO');
     $this->renderer = WiseChatContainer::get('rendering/WiseChatRenderer');
     $this->cssRenderer = WiseChatContainer::get('rendering/WiseChatCssRenderer');
     $this->bansService = WiseChatContainer::get('services/WiseChatBansService');
     $this->userService = WiseChatContainer::get('services/user/WiseChatUserService');
     $this->messagesService = WiseChatContainer::get('services/WiseChatMessagesService');
     $this->service = WiseChatContainer::get('services/WiseChatService');
     $this->attachmentsService = WiseChatContainer::get('services/WiseChatAttachmentsService');
     $this->authentication = WiseChatContainer::getLazy('services/user/WiseChatAuthentication');
     WiseChatContainer::load('WiseChatCrypt');
     WiseChatContainer::load('WiseChatThemes');
     WiseChatContainer::load('rendering/WiseChatTemplater');
     $this->userService->initMaintenance();
     $this->shortCodeOptions = array();
 }
Ejemplo n.º 8
0
<?php

WiseChatContainer::load('rendering/filters/pre/WiseChatFilter');
class WiseChatFilterTest extends PHPUnit_Framework_TestCase
{
    private static $mbExtension = 'mbstring';
    /**
     * @dataProvider data
     */
    public function testPositive($input, $output)
    {
        WiseChatFilter::$words = array('balls');
        if (!extension_loaded(self::$mbExtension)) {
            $this->assertEquals($output, WiseChatFilter::filter($input));
        }
    }
    /**
     * @dataProvider dataNegative
     */
    public function testNegative($input, $output)
    {
        WiseChatFilter::$words = array('balls');
        if (!extension_loaded(self::$mbExtension)) {
            $this->assertEquals($output, WiseChatFilter::filter($input));
        }
    }
    /**
     * @dataProvider dataUnicode
     */
    public function testPositiveUnicode($input, $output)
    {
Ejemplo n.º 9
0
<?php

WiseChatContainer::load('WiseChatThemes');
/**
 * Wise Chat admin appearance settings tab class.
 *
 * @author Marcin Ławrowski <*****@*****.**>
 */
class WiseChatAppearanceTab extends WiseChatAbstractTab
{
    public function getFields()
    {
        return array(array('_section', 'Chat Window Appearance'), array('theme', 'Theme', 'selectCallback', 'string', '', WiseChatThemes::getAllThemes()), array('background_color_chat', 'Background Color', 'colorFieldCallback', 'string', ''), array('text_color_chat', 'Font Color', 'colorFieldCallback', 'string', ''), array('text_size_chat', 'Font Size', 'selectCallback', 'string', '', WiseChatAppearanceTab::getFontSizes()), array('chat_width', 'Width', 'stringFieldCallback', 'string', 'Allowed values: a number with or without an unit (px or %), default: 100%'), array('chat_height', 'Height', 'stringFieldCallback', 'string', 'Allowed values: a number with or without an unit (px or %), default: 200px'), array('_section', 'Messages List Appearance'), array('messages_limit', 'Messages Limit', 'stringFieldCallback', 'integer', 'Maximum number of messages loaded on start-up'), array('messages_order', 'Messages Order', 'selectCallback', 'string', 'Sorting order of the messages', WiseChatAppearanceTab::getSortingOrder()), array('_section', 'Message Appearance'), array('background_color', 'Background Color', 'colorFieldCallback', 'string', ''), array('text_color', 'Font Color', 'colorFieldCallback', 'string', ''), array('text_color_user', 'Username Font Color', 'colorFieldCallback', 'string', 'Font color of username text in messages sent by a non-logged in user'), array('text_color_logged_user', 'Username Font Color<br />(logged in user)', 'colorFieldCallback', 'string', 'Font color of username text in messages sent by a logged in user'), array('text_size', 'Font Size', 'selectCallback', 'string', '', WiseChatAppearanceTab::getFontSizes()), array('messages_time_mode', 'Message Time Mode', 'selectCallback', 'string', 'Format of the date and time displayed next to each message', WiseChatAppearanceTab::getTimeModes()), array('link_wp_user_name', 'Username Display Mode', 'selectCallback', 'string', '
			    Controls how username is displayed in each message:<br />
			    <strong>- Plain text:</strong> username is displayed as a plain text.<br />
                <strong>- Link to the page:</strong> username is displayed as a link. By default the link directs to the author\'s page. Only messages sent by WordPress users are taken into account. If you would like to link every user name provide a template for the link (see the option below).<br />
                <strong>- Link for @mentioning the user:</strong> username is displayed as a link that inserts <strong>"@UserName: "******"Collect User Statistics" option in General tab
                '), array('show_users_city_and_country', 'Show City And Country', 'booleanFieldCallback', 'boolean', '
                Shows city and country code next to each user on the list. City and country are obtained from IP address and this may not be successful sometimes.<br />
                <strong>Notice:</strong> In order to show cities and countries enable "Collect User Statistics" option in General tab
                '), array('users_list_width', 'Users List Width', 'stringFieldCallback', 'integer', 'Percentage width of the list of users. Empty field sets default value of 29%.'), array('background_color_users_list', 'Background Color', 'colorFieldCallback', 'string', 'Background color of the users list'), array('text_color_users_list', 'Font Color', 'colorFieldCallback', 'string', 'Font color of the texts inside the users list'), array('text_size_users_list', 'Font Size', 'selectCallback', 'string', 'Font size', WiseChatAppearanceTab::getFontSizes()), array('_section', 'Advanced Customization'), array('custom_styles', 'Custom CSS Styles', 'multilineFieldCallback', 'multilinestring', 'Custom CSS styles for the chat, valid CSS syntax is required.'));
    }
    public function getDefaultValues()
Ejemplo n.º 10
0
 public function __construct()
 {
     WiseChatContainer::load('model/WiseChatChannel');
     $this->options = WiseChatOptions::getInstance();
 }
<?php

WiseChatContainer::load('rendering/filters/post/WiseChatImagesPostFilter');
class WiseChatImagesPostFilterTest extends PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider data
     */
    public function testPositiveImages($input, $output)
    {
        $input = str_replace('"', '&quot;', $input);
        $postFilter = new WiseChatImagesPostFilter();
        $this->assertEquals($output, $postFilter->filter($input, true));
    }
    public function data()
    {
        return array(array('[img id="1" src="http://www.poznan.pl/sdsd.jpg" src-th="http://www.poznan.pl/sdsd-th.jpg" src-org="ORG"]', '<a href="http://www.poznan.pl/sdsd.jpg" target="_blank" data-lightbox="wise_chat" rel="lightbox[wise_chat]"><img src="http://www.poznan.pl/sdsd-th.jpg" class="wcImage" /></a>'), array('H: [img id="1" src="http://www.poznan.pl/sdsd.jpg?aaa=%20ss" src-th="http://www.poznan.pl/sdsd-th.jpg?bbb=%20ss" src-org="ORG"]', 'H: <a href="http://www.poznan.pl/sdsd.jpg?aaa=%20ss" target="_blank" data-lightbox="wise_chat" rel="lightbox[wise_chat]"><img src="http://www.poznan.pl/sdsd-th.jpg?bbb=%20ss" class="wcImage" /></a>'), array('H: [img id="1" src="http://www.poznan.pl/sdsd.jpg?aaa=%20ss" src-th="http://www.poznan.pl/sdsd-th.jpg?bbb=%20ss" src-org="ORG"] x [img id="1" src="http://www.poznan.pl/www.jpg?aaa=%20ss" src-th="http://www.poznan.pl/www-th.jpg?bbb=%20ss" src-org="ORG"]', 'H: <a href="http://www.poznan.pl/sdsd.jpg?aaa=%20ss" target="_blank" data-lightbox="wise_chat" rel="lightbox[wise_chat]"><img src="http://www.poznan.pl/sdsd-th.jpg?bbb=%20ss" class="wcImage" /></a> x <a href="http://www.poznan.pl/www.jpg?aaa=%20ss" target="_blank" data-lightbox="wise_chat" rel="lightbox[wise_chat]"><img src="http://www.poznan.pl/www-th.jpg?bbb=%20ss" class="wcImage" /></a>'));
    }
    /**
     * @dataProvider dataNoImagesButLinks
     */
    public function testPositiveNoImagesButLinks($input, $output)
    {
        $input = str_replace('"', '&quot;', $input);
        $postFilter = new WiseChatImagesPostFilter();
        $this->assertEquals($output, $postFilter->filter($input, false, true));
    }
    public function dataNoImagesButLinks()
    {
        return array(array('[img id="1" src="http://www.poznan.pl/sdsd.jpg" src-th="http://www.poznan.pl/sdsd-th.jpg" src-org="www.wroc.pl/org.jpg"]', '<a href="http://www.wroc.pl/org.jpg" target="_blank" rel="nofollow">www.wroc.pl/org.jpg</a>'), array('[img id="1" src="http://www.poznan.pl/sdsd.jpg" src-th="http://www.poznan.pl/sdsd-th.jpg" src-org="http://www.wroc.pl/org.jpg"]', '<a href="http://www.wroc.pl/org.jpg" target="_blank" rel="nofollow">http://www.wroc.pl/org.jpg</a>'), array('H: [img id="1" src="http://www.poznan.pl/sdsd.jpg" src-th="http://www.poznan.pl/sdsd-th.jpg" src-org="www.wroc.pl/org.jpg?q=pozna%C5%84+%22:)%22"]', 'H: <a href="http://www.wroc.pl/org.jpg?q=pozna%C5%84+%22:)%22" target="_blank" rel="nofollow">www.wroc.pl/org.jpg?q=poznań &quot;:)&quot;</a>'));
    }
Ejemplo n.º 12
0
<?php

WiseChatContainer::load('rendering/WiseChatTemplater');
class WiseChatTemplaterTest extends PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider data
     */
    public function testTemplater($template, $data, $output)
    {
        $templater = new WiseChatTemplater('');
        $templater->setTemplate($template);
        $actualOutput = $templater->render($data);
        $this->assertEquals($output, $actualOutput);
    }
    public function data()
    {
        return array(array("", array(), ""), array("{{ x }}", array('x' => 't1'), "t1"), array("{{ x }} a {{ y }}", array('x' => 't1', 'y' => 't2'), "t1 a t2"), array("{{x }} a {{    y \t}}", array('x' => 't1', 'y' => 't2'), "t1 a t2"), array("{{ x }} a {{ y }} b {{ x }}", array('x' => 't1', 'y' => 't2'), "t1 a t2 b t1"), array("{% if x %} c1 {% endif x %}", array('x' => true), "c1"), array("{% if x %} c1 {% endif x %}", array('x' => '1'), "c1"), array("{% if x %} c1 {% endif x %}", array('x' => ''), ""), array("{% if !x %} c1 {% endif x %}", array('x' => '1'), ""), array("{% if !x %} c1 {% endif x %}", array('x' => ''), "c1"), array("{% if x %} c1 {% endif x %}", array('x' => 12), "c1"), array("{% if x %} c1 {% endif x %}", array('x' => 0), ""), array("{% if !x %} c1 {% endif x %}", array('x' => 12), ""), array("{% if !x %} c1 {% endif x %}", array('x' => 0), "c1"), array("{% if x %} c1 {% endif x %}", array('x' => 12.43), "c1"), array("{% if x %} c1 {% endif x %}", array('x' => 0.0), ""), array("{% if !x %} c1 {% endif x %}", array('x' => 12.53), ""), array("{% if !x %} c1 {% endif x %}", array('x' => 0.0), "c1"), array("{% if x %} c1 {% endif x %}", array('x' => array(1, 2)), "c1"), array("{% if x %} c1 {% endif x %}", array('x' => array()), ""), array("{% if !x %} c1 {% endif x %}", array('x' => array(1, 2)), ""), array("{% if !x %} c1 {% endif x %}", array('x' => array()), "c1"), array("{% if !x %} c1 {% endif x %}", array('x' => null), "c1"), array("{%if    x%}c1{%endif x%}", array('x' => true), "c1"), array("{% if x %} c1 {% endif x %}", array('x' => false), ""), array("{% if x %} c1 {% endif x %} a {% if x %} c2 {% endif x %}", array('x' => true), "c1 a c2"), array("{% if x %} c1 {% endif x %} a {%if y%} c2 {%endif y%}", array('x' => true, 'y' => true), "c1 a c2"), array("{% if x %} c1 {% endif x %} a {%if y%} c2 {%endif y%} b {% if x %} c3 {% endif x %}", array('x' => true, 'y' => true), "c1 a c2 b c3"), array("{% if x %} c1 {%if y%} a {%endif y%} c2 {% endif x %} {%if y%} c3 {%endif y%}", array('x' => true, 'y' => true), "c1 a c2 c3"), array("{% if x %} c1\nc2\n\n{% endif x %}", array('x' => true), "c1\nc2"), array("1 {% if x %} a {{y}} {%if x %} b {% endif x %} c {% if z %} d {% endif z %} e {% endif x %} f", array('x' => true, 'y' => 'v', 'z' => false), "1 a v b c  e f"), array("{% if !x %} c1 {% endif x %}", array('x' => false), "c1"), array("{% if !x %} c1 {% endif x %} c2{%if x %} c3 {% endif x %}", array('x' => false), "c1 c2"), array("{% if !x %} c1{%if x %} c3 {% endif x %} {% endif x %} c2{%if x %} c3 {% endif x %}", array('x' => false), "c1 c2"), array("{% variable v %} c {% endvariable v %} {{v}}", array(), " c"), array("{%variable v%} c {%    endvariable v%} {{v}}", array(), " c"), array("{% variable v %} c1 {% if x %} c2 {% endif x %} {% endvariable v %} {{v}}", array('x' => true), " c1 c2"));
    }
}
Ejemplo n.º 13
0
 /**
  * Saves attachments in the Media Library and attaches them to the end of the message.
  *
  * @param WiseChatChannel $channel
  * @param array $attachments Array of attachments
  *
  * @return array Array consisting of the two elements: a shortcode representing the attachments and array of IDs of created attachments
  */
 private function saveAttachments($channel, $attachments)
 {
     if (!is_array($attachments) || count($attachments) === 0) {
         return array(null, array());
     }
     WiseChatContainer::load('rendering/filters/WiseChatShortcodeConstructor');
     $firstAttachment = $attachments[0];
     $data = $firstAttachment['data'];
     $data = substr($data, strpos($data, ",") + 1);
     $decodedData = base64_decode($data);
     $attachmentShortcode = null;
     $attachmentIds = array();
     if ($this->options->isOptionEnabled('enable_images_uploader') && $firstAttachment['type'] === 'image') {
         $image = $this->imagesService->saveImage($decodedData);
         if (is_array($image)) {
             $attachmentShortcode = ' ' . WiseChatShortcodeConstructor::getImageShortcode($image['id'], $image['image'], $image['image-th'], '_');
             $attachmentIds = array($image['id']);
         }
     }
     if ($this->options->isOptionEnabled('enable_attachments_uploader') && $firstAttachment['type'] === 'file') {
         $fileName = $firstAttachment['name'];
         $file = $this->attachmentsService->saveAttachment($fileName, $decodedData, $channel->getName());
         if (is_array($file)) {
             $attachmentShortcode = ' ' . WiseChatShortcodeConstructor::getAttachmentShortcode($file['id'], $file['file'], $fileName);
             $attachmentIds = array($file['id']);
         }
     }
     return array($attachmentShortcode, $attachmentIds);
 }
Ejemplo n.º 14
0
 public function __construct()
 {
     WiseChatContainer::load('model/WiseChatAction');
     $this->options = WiseChatOptions::getInstance();
     $this->table = WiseChatInstaller::getActionsTable();
 }
Ejemplo n.º 15
0
 /**
  * Constructor
  *
  * @return WiseChatLinksPreFilter
  */
 public function __construct()
 {
     $this->imagesService = WiseChatContainer::get('services/WiseChatImagesService');
     WiseChatContainer::load('rendering/filters/WiseChatShortcodeConstructor');
 }
Ejemplo n.º 16
0
 /**
  * @param string $userName
  *
  * @return WiseChatUser
  */
 private function createUserAndSave($userName)
 {
     WiseChatContainer::load('model/WiseChatUser');
     // construct username and user object:
     $user = new WiseChatUser();
     $user->setName($userName);
     $user->setSessionId($this->userSessionDAO->getSessionId());
     $user->setIp($this->getRemoteAddress());
     if ($this->options->isOptionEnabled('collect_user_stats', true)) {
         $this->fillWithGeoDetails($user);
     }
     // save user in DB and in the session:
     $this->usersDAO->save($user);
     $this->userSessionDAO->set(self::SESSION_KEY_USER_ID, $user->getId());
     return $user;
 }
Ejemplo n.º 17
0
 public function __construct()
 {
     $this->options = WiseChatOptions::getInstance();
     $this->authentication = WiseChatContainer::getLazy('services/user/WiseChatAuthentication');
     $this->userEvents = WiseChatContainer::getLazy('services/user/WiseChatUserEvents');
     $this->authorization = WiseChatContainer::getLazy('services/user/WiseChatAuthorization');
     $this->usersDAO = WiseChatContainer::getLazy('dao/user/WiseChatUsersDAO');
     $this->userSettingsDAO = WiseChatContainer::getLazy('dao/user/WiseChatUserSettingsDAO');
     $this->channelUsersDAO = WiseChatContainer::getLazy('dao/WiseChatChannelUsersDAO');
     $this->actions = WiseChatContainer::getLazy('services/user/WiseChatActions');
     $this->channelsDAO = WiseChatContainer::getLazy('dao/WiseChatChannelsDAO');
     $this->bansDAO = WiseChatContainer::getLazy('dao/WiseChatBansDAO');
     $this->renderer = WiseChatContainer::getLazy('rendering/WiseChatRenderer');
     $this->bansService = WiseChatContainer::getLazy('services/WiseChatBansService');
     $this->messagesService = WiseChatContainer::getLazy('services/WiseChatMessagesService');
     $this->userService = WiseChatContainer::getLazy('services/user/WiseChatUserService');
     $this->service = WiseChatContainer::getLazy('services/WiseChatService');
     WiseChatContainer::load('WiseChatCrypt');
 }
Ejemplo n.º 18
0
 /**
  * Refreshes username after setting a new one.
  *
  * @param WiseChatUser $user
  *
  * @return null
  */
 private function refreshNewUserName($user)
 {
     WiseChatContainer::load('dao/criteria/WiseChatMessagesCriteria');
     $this->refreshUserName($user);
     $this->messagesDAO->updateUserNameByCriteria($user->getName(), WiseChatMessagesCriteria::build()->setUserId($user->getId()));
     /** @var WiseChatRenderer $renderer */
     $renderer = WiseChatContainer::get('rendering/WiseChatRenderer');
     $criteria = new WiseChatMessagesCriteria();
     $criteria->setUserId($user->getId());
     $messages = $this->messagesDAO->getAllByCriteria($criteria);
     if (count($messages) > 0) {
         $messagesIds = array();
         $renderedUserName = null;
         foreach ($messages as $message) {
             $messagesIds[] = $message->getId();
             if ($renderedUserName === null) {
                 $renderedUserName = $renderer->getRenderedUserName($message);
             }
         }
         $this->actions->publishAction('replaceUserNameInMessages', array('renderedUserName' => $renderedUserName, 'messagesIds' => $messagesIds));
     }
 }
Ejemplo n.º 19
0
 public function __construct()
 {
     WiseChatContainer::load('admin/WiseChatAbstractTab');
 }
Ejemplo n.º 20
0
<?php

/*
	Plugin Name: Wise Chat
	Version: 2.1
	Plugin URI: http://kaine.pl/projects/wp-plugins/wise-chat/wise-chat-donate
	Description: Fully-featured chat plugin for WordPress. It requires no server, supports multiple channels, bad words filtering, themes, appearance settings, filters, bans and more.
	Author: Marcin Ławrowski
	Author URI: http://kaine.pl
*/
require_once dirname(__FILE__) . '/src/WiseChatContainer.php';
WiseChatContainer::load('WiseChatInstaller');
WiseChatContainer::load('WiseChatOptions');
if (is_admin()) {
    // installer:
    register_activation_hook(__FILE__, array('WiseChatInstaller', 'activate'));
    register_deactivation_hook(__FILE__, array('WiseChatInstaller', 'deactivate'));
    register_uninstall_hook(__FILE__, array('WiseChatInstaller', 'uninstall'));
    /** @var WiseChatSettings $settings */
    $settings = WiseChatContainer::get('WiseChatSettings');
    // initialize plugin settings page:
    $settings->initialize();
}
// register action that detects when WordPress user logs in / logs out:
function wise_chat_after_setup_theme_action()
{
    /** @var WiseChatUserService $userService */
    $userService = WiseChatContainer::get('services/user/WiseChatUserService');
    $userService->initMaintenance();
    $userService->switchUser();
}
<?php

WiseChatContainer::load('rendering/filters/pre/WiseChatLinksPreFilter');
WiseChatContainer::load('rendering/filters/WiseChatShortcodeConstructor');
WiseChatContainer::load('services/WiseChatImagesService');
WiseChatContainer::load('services/user/WiseChatActions');
WiseChatContainer::load('services/user/WiseChatAuthentication');
class WiseChatLinksPreFilterTest extends PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider dataNoImages
     */
    public function testPositiveNoImages($input, $output)
    {
        WiseChatContainer::replace('services/user/WiseChatActions', new WiseChatActionsStub());
        WiseChatContainer::replace('services/WiseChatImagesService', new WiseChatImagesServiceStub());
        WiseChatContainer::replace('services/user/WiseChatAuthentication', new WiseChatAuthenticationStub());
        $linksPreFilter = new WiseChatLinksPreFilter();
        $this->assertEquals($output, $linksPreFilter->filter($input, false));
    }
    public function dataNoImages()
    {
        return array(array("", ''), array("no links.", 'no links.'), array("no links &#^\$%%.54\$>\$#.4545", 'no links &#^$%%.54$>$#.4545'), array("test1 wp.pl test2", 'test1 [link src="wp.pl"] test2'), array("test1 wp.pl?oo=p test2", 'test1 [link src="wp.pl?oo=p"] test2'), array("test1 wp.pl?oo=p%27uop test2", 'test1 [link src="wp.pl?oo=p%27uop"] test2'), array("test1 wp.pl?oo=p%3Cuop test2", 'test1 [link src="wp.pl?oo=p%3Cuop"] test2'), array("test1 http://wp.pl test2", 'test1 [link src="http://wp.pl"] test2'), array("ftp://wp.pl", '[link src="ftp://wp.pl"]'), array("test1 http://wp.pl https://sdads.test2.pl", 'test1 [link src="http://wp.pl"] [link src="https://sdads.test2.pl"]'), array("test1 https://wp.pl/oo/ddd/r.html test2", 'test1 [link src="https://wp.pl/oo/ddd/r.html"] test2'), array("test1 https://wp.pl/oo/ddd/r.html?oo=ww test2", 'test1 [link src="https://wp.pl/oo/ddd/r.html?oo=ww"] test2'), array("test1 https://wp.pl/oo/ddd/r.html?oo=ww][ test2", 'test1 [link src="https://wp.pl/oo/ddd/r.html?oo=ww]["] test2'), array("test1 http://wp.pl?oop=sss&eee=qqq+333 test2", 'test1 [link src="http://wp.pl?oop=sss&eee=qqq+333"] test2'), array("test1 http://wp.pl?oop=sss&eee=q&lt;qq+333 test2", 'test1 [link src="http://wp.pl?oop=sss&eee=q&lt;qq+333"] test2'), array("test1 wp.pl onet.pl test2", 'test1 [link src="wp.pl"] [link src="onet.pl"] test2'), array("test1 wp.pl?op=ii'kkj onet.pl yxy wp.pl test2", 'test1 [link src="wp.pl?op=ii"]\'kkj [link src="onet.pl"] yxy [link src="wp.pl"] test2'), array("test1 wp.pl onet.pl yxy wp.pl uu http://onet.pl", 'test1 [link src="wp.pl"] [link src="onet.pl"] yxy [link src="wp.pl"] uu [link src="http://onet.pl"]'), array("hhhh.oooo.pl  dcdsc hhhh.oooo.pl http://hhhh.oooo.pl", '[link src="hhhh.oooo.pl"]  dcdsc [link src="hhhh.oooo.pl"] [link src="http://hhhh.oooo.pl"]'), array("https://www.google.pl/webhp?hl=pl#hl=pl&q=pozna%C5%84+%22:)%22 - the link", '[link src="https://www.google.pl/webhp?hl=pl#hl=pl&q=pozna%C5%84+%22:)%22"] - the link'), array("http://wp.pl?ss=the\"rest", '[link src="http://wp.pl?ss=the"]"rest'), array("http://wp.pl?ss=pozna%C5%84+%22:)%22'rest", '[link src="http://wp.pl?ss=pozna%C5%84+%22:)%22"]\'rest'), array("wp.pl?ss=pozna%C5%84+%22:)%22'rest", '[link src="wp.pl?ss=pozna%C5%84+%22:)%22"]\'rest'));
    }
    /**
     * @dataProvider dataWithImages
     */
    public function testPositiveWithImages($input, $output)
    {
        WiseChatContainer::replace('services/user/WiseChatActions', new WiseChatActionsStub());
        WiseChatContainer::replace('services/WiseChatImagesService', new WiseChatImagesServiceStub());