diff --git a/assets/css/chat/chat.css b/assets/css/chat/chat.css index dd3db49..d1cb45c 100644 --- a/assets/css/chat/chat.css +++ b/assets/css/chat/chat.css @@ -37,6 +37,12 @@ font-style: italic; margin-bottom: 0; } +.widget-chat-wrapper .widget-chat-messages .chat-message-date { + margin-left: 60px; + font-style: italic; + margin-bottom: 0; + font-size: 80%; +} .widget-chat-wrapper .widget-chat-messages::-webkit-scrollbar { width: 10px; background-color: transparent; @@ -59,4 +65,9 @@ } .widget-chat-wrapper .widget-chat-messages::-webkit-resizer { background-color: rgba(0,0,0,.1); +} +.widget-chat-wrapper .chat-info { + margin: 0; + border-radius: 0; + padding: 10px; } \ No newline at end of file diff --git a/chat/controllers/index.php b/chat/controllers/index.php index 7752874..b4902a9 100644 --- a/chat/controllers/index.php +++ b/chat/controllers/index.php @@ -63,6 +63,9 @@ class Index extends Zira\Controller { $message .= Zira\Helper::tag_open('p', array('class'=>'chat-message-text parse-content'.$mclass)).$micon; $message .= Zira\Content\Parse::bbcode(Zira\Helper::nl2br(Zira\Helper::html($row->content))); $message .= Zira\Helper::tag_close('p'); + $message .= Zira\Helper::tag_open('div', array('class'=>'chat-message-date')); + $message .= Zira\Helper::tag('span', null, array('class'=>'glyphicon glyphicon-time')).' '.(Zira\Helper::isCurrentDay(strtotime($row->date_created)) ? date('H:i', strtotime($row->date_created)) : date(Zira\Config::get('date_format'), strtotime($row->date_created))); + $message .= Zira\Helper::tag_close('div'); $message .= Zira\Helper::tag_close('div'); $response['messages'][]=$message; $response['last_id'] = $row->id; diff --git a/chat/forms/chat.php b/chat/forms/chat.php index a47ce3a..5d11925 100644 --- a/chat/forms/chat.php +++ b/chat/forms/chat.php @@ -42,6 +42,7 @@ class Chat extends Form $html .= $this->selectDropdown(Locale::t('Widget placeholder').'*','placeholder',$placeholders); } $html .= $this->input(Locale::t('Title').'*', 'title'); + $html .= $this->textarea(Locale::tm('Information message', 'chat'), 'info', array('rows'=>4)); $html .= $this->selectDropdown(Locale::tm('Visibility', 'chat'), 'visible_group', array_merge(array('0'=>Locale::tm('Visible for everybody', 'chat')), Zira\Models\Group::getArray())); $html .= $this->input(Locale::tm('Refresh timeout', 'chat').' ('.Locale::tm('sec.', 'chat').')'.'*', 'refresh_delay', array('placeholder'=>Locale::tm('in seconds', 'chat'))); $html .= $this->checkbox(Locale::tm('Check authentication', 'chat'), 'check_auth', null, false); @@ -57,6 +58,10 @@ class Chat extends Form $validator->registerNoTags('title', Locale::t('Invalid value "%s"',Locale::t('Title'))); $validator->registerUtf8('title', Locale::t('Invalid value "%s"',Locale::t('Title'))); + $validator->registerText('info', null, false, Locale::t('Invalid value "%s"',Locale::tm('Information message', 'chat'))); + $validator->registerNoTags('info', Locale::t('Invalid value "%s"',Locale::tm('Information message', 'chat'))); + $validator->registerUtf8('info', Locale::t('Invalid value "%s"',Locale::tm('Information message', 'chat'))); + $validator->registerNumber('refresh_delay', 1, null, true, Locale::t('Invalid value "%s"',Locale::tm('Refresh timeout', 'chat'))); $validator->registerCustom(array(get_class(), 'checkGroup'), 'visible_group', Locale::t('Invalid value "%s"',Locale::tm('Visibility', 'chat'))); diff --git a/chat/forms/settings.php b/chat/forms/settings.php index 7c7fa4b..42fe763 100644 --- a/chat/forms/settings.php +++ b/chat/forms/settings.php @@ -35,6 +35,7 @@ class Settings extends Form protected function _render() { $html = $this->open(); + $html .= $this->input(Locale::tm('Message retention period (in days)', 'chat').'*', 'chat_trash_time'); $html .= $this->checkbox(Locale::t('Always show CAPTCHA'), 'chat_captcha', null, false); $html .= $this->checkbox(Locale::t('Always show CAPTCHA for authorized users'), 'chat_captcha_users', null, false); $html .= $this->close(); @@ -45,6 +46,6 @@ class Settings extends Form { $validator = $this->getValidator(); - + $validator->registerNumber('chat_trash_time',0,null,true,Locale::t('Invalid value "%s"',Locale::tm('Message retention period (in days)', 'chat'))); } } \ No newline at end of file diff --git a/chat/install/chat.php b/chat/install/chat.php index 197d8c5..d184a66 100644 --- a/chat/install/chat.php +++ b/chat/install/chat.php @@ -21,6 +21,7 @@ class Chat extends Table { return array( 'id' => Field::primary(), 'title' => Field::string(true), + 'info' => Field::text(), 'check_auth' => Field::int(true, true, 0), 'visible_group' => Field::int(true, true, 0), 'refresh_delay' => Field::int(true, true, 0), diff --git a/chat/models/chats.php b/chat/models/chats.php index 28bd920..bf96e16 100644 --- a/chat/models/chats.php +++ b/chat/models/chats.php @@ -27,7 +27,14 @@ class Chats extends Dash\Models\Model { } else { $chat = new Chat\Models\Chat(); } + + $info = $form->getValue('info'); + $info = str_replace("\r",'',$info); + $info = str_replace("\n","\r\n",$info); + $info = Zira\Helper::utf8Entity(html_entity_decode($info)); + $chat->title = $form->getValue('title'); + $chat->info = $info; $chat->visible_group = (int)$form->getValue('visible_group'); $refresh_delay = (int)$form->getValue('refresh_delay'); $chat->refresh_delay = $refresh_delay ? $refresh_delay : Chat\Chat::DEFAULT_DELAY; diff --git a/chat/models/message.php b/chat/models/message.php index 6b9bbfe..3316c18 100644 --- a/chat/models/message.php +++ b/chat/models/message.php @@ -61,9 +61,12 @@ class Message extends Orm { } public static function cleanUp() { + $trash_days = intval(Zira\Config::get('chat_trash_time', floor(\Chat\Chat::TRASH_TIME / 86400))); + if ($trash_days <= 0) return; + $trash_time = $trash_days * 86400; self::getCollection() ->delete() - ->where('date_created','<',date('Y-m-d H:i:s', time()-\Chat\Chat::TRASH_TIME)) + ->where('date_created','<',date('Y-m-d H:i:s', time()-$trash_time)) ->execute(); } } \ No newline at end of file diff --git a/chat/models/settings.php b/chat/models/settings.php index a84a96d..a7d1a44 100644 --- a/chat/models/settings.php +++ b/chat/models/settings.php @@ -21,6 +21,7 @@ class Settings extends Dash\Models\Model { $form = new Chat\Forms\Settings(); if ($form->isValid()) { $options = array( + 'chat_trash_time'=>'int', 'chat_captcha'=>'int', 'chat_captcha_users'=>'int' ); diff --git a/chat/windows/settings.php b/chat/windows/settings.php index 6e11a44..f78b470 100644 --- a/chat/windows/settings.php +++ b/chat/windows/settings.php @@ -44,6 +44,7 @@ class Settings extends Dash\Windows\Window { $configs = Zira\Config::getArray(); $form = new \Chat\Forms\Settings(); + if (!array_key_exists('chat_trash_time', $configs)) $configs['chat_trash_time'] = floor(\Chat\Chat::TRASH_TIME / 86400); if (!array_key_exists('chat_captcha', $configs)) $configs['chat_captcha'] = 1; if (!array_key_exists('chat_captcha_users', $configs)) $configs['chat_captcha_users'] = 1; $form->setValues($configs); diff --git a/languages/ru/chat.php b/languages/ru/chat.php index 2614bed..e722cf9 100644 --- a/languages/ru/chat.php +++ b/languages/ru/chat.php @@ -25,5 +25,7 @@ return array( 'Incorrect message length' => 'Некорректная длина сообщения', 'Chat database cleaned up' => 'База чата почищена', 'Your message' => 'Ваше сообщение', - 'Chat settings' => 'Настройки чата' + 'Chat settings' => 'Настройки чата', + 'Information message' => 'Информационное сообщение', + 'Message retention period (in days)' => 'Срок хранения сообщений (в днях)' ); \ No newline at end of file diff --git a/themes/bulaksu/assets/css/main.css b/themes/bulaksu/assets/css/main.css index 42d1ffb..a6abf31 100644 --- a/themes/bulaksu/assets/css/main.css +++ b/themes/bulaksu/assets/css/main.css @@ -1,34 +1,34 @@ /* cyrillic-ext */ @font-face { - font-family: 'Roboto'; - font-style: normal; - font-weight: 400; - src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/ek4gzZ-GeXAPcSbHtCeQI_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); - unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; + font-family: 'Roboto'; + font-style: normal; + font-weight: 400; + src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/ek4gzZ-GeXAPcSbHtCeQI_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); + unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; } /* cyrillic */ @font-face { - font-family: 'Roboto'; - font-style: normal; - font-weight: 400; - src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/mErvLBYg_cXG3rLvUsKT_fesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); - unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; + font-family: 'Roboto'; + font-style: normal; + font-weight: 400; + src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/mErvLBYg_cXG3rLvUsKT_fesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); + unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; } /* latin-ext */ @font-face { - font-family: 'Roboto'; - font-style: normal; - font-weight: 400; - src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/Fcx7Wwv8OzT71A3E1XOAjvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); - unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; + font-family: 'Roboto'; + font-style: normal; + font-weight: 400; + src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/Fcx7Wwv8OzT71A3E1XOAjvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); + unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; } /* latin */ @font-face { - font-family: 'Roboto'; - font-style: normal; - font-weight: 400; - src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/CWB0XYA8bzo0kSThX0UTuA.woff2) format('woff2'); - unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215; + font-family: 'Roboto'; + font-style: normal; + font-weight: 400; + src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/CWB0XYA8bzo0kSThX0UTuA.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215; } /*@font-face { font-family: 'Roboto'; diff --git a/themes/dark/assets/css/main.css b/themes/dark/assets/css/main.css index c3aefc7..ad4e9d2 100644 --- a/themes/dark/assets/css/main.css +++ b/themes/dark/assets/css/main.css @@ -1,34 +1,34 @@ /* cyrillic-ext */ @font-face { - font-family: 'Roboto'; - font-style: normal; - font-weight: 400; - src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/ek4gzZ-GeXAPcSbHtCeQI_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); - unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; + font-family: 'Roboto'; + font-style: normal; + font-weight: 400; + src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/ek4gzZ-GeXAPcSbHtCeQI_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); + unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; } /* cyrillic */ @font-face { - font-family: 'Roboto'; - font-style: normal; - font-weight: 400; - src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/mErvLBYg_cXG3rLvUsKT_fesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); - unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; + font-family: 'Roboto'; + font-style: normal; + font-weight: 400; + src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/mErvLBYg_cXG3rLvUsKT_fesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); + unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; } /* latin-ext */ @font-face { - font-family: 'Roboto'; - font-style: normal; - font-weight: 400; - src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/Fcx7Wwv8OzT71A3E1XOAjvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); - unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; + font-family: 'Roboto'; + font-style: normal; + font-weight: 400; + src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/Fcx7Wwv8OzT71A3E1XOAjvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); + unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; } /* latin */ @font-face { - font-family: 'Roboto'; - font-style: normal; - font-weight: 400; - src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/CWB0XYA8bzo0kSThX0UTuA.woff2) format('woff2'); - unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215; + font-family: 'Roboto'; + font-style: normal; + font-weight: 400; + src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/CWB0XYA8bzo0kSThX0UTuA.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215; } /*@font-face { font-family: 'Roboto'; @@ -2289,6 +2289,14 @@ ul.vote-results li .vote-result { background: #646975; box-shadow: 0px 0px 4px #444554 inset; } +/** chat **/ +.widget-chat-wrapper .chat-info { + margin: 4px -9px 0px -9px; + border-radius: 3px; +} +.widget-chat-wrapper .widget-chat-messages { + margin: 8px 0px; +} .zira-autocomplete-wnd { background: #646975; border: 1px solid #4d515a; diff --git a/themes/default/assets/css/main.css b/themes/default/assets/css/main.css index f277e6e..d9adf94 100644 --- a/themes/default/assets/css/main.css +++ b/themes/default/assets/css/main.css @@ -1,34 +1,34 @@ /* cyrillic-ext */ @font-face { - font-family: 'Roboto'; - font-style: normal; - font-weight: 400; - src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/ek4gzZ-GeXAPcSbHtCeQI_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); - unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; + font-family: 'Roboto'; + font-style: normal; + font-weight: 400; + src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/ek4gzZ-GeXAPcSbHtCeQI_esZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); + unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; } /* cyrillic */ @font-face { - font-family: 'Roboto'; - font-style: normal; - font-weight: 400; - src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/mErvLBYg_cXG3rLvUsKT_fesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); - unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; + font-family: 'Roboto'; + font-style: normal; + font-weight: 400; + src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/mErvLBYg_cXG3rLvUsKT_fesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); + unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; } /* latin-ext */ @font-face { - font-family: 'Roboto'; - font-style: normal; - font-weight: 400; - src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/Fcx7Wwv8OzT71A3E1XOAjvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); - unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; + font-family: 'Roboto'; + font-style: normal; + font-weight: 400; + src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/Fcx7Wwv8OzT71A3E1XOAjvesZW2xOQ-xsNqO47m55DA.woff2) format('woff2'); + unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; } /* latin */ @font-face { - font-family: 'Roboto'; - font-style: normal; - font-weight: 400; - src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/CWB0XYA8bzo0kSThX0UTuA.woff2) format('woff2'); - unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215; + font-family: 'Roboto'; + font-style: normal; + font-weight: 400; + src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v15/CWB0XYA8bzo0kSThX0UTuA.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215; } /*@font-face { font-family: 'Roboto'; diff --git a/themes/default/chat/widget.php b/themes/default/chat/widget.php index 2a5d898..21c32ed 100644 --- a/themes/default/chat/widget.php +++ b/themes/default/chat/widget.php @@ -1,13 +1,18 @@
- -
- -
- -
- + +info): ?> +

+info))); ?> +

+ +
+ +
+ +
+
\ No newline at end of file diff --git a/update/v5/chat.php b/update/v5/chat.php new file mode 100644 index 0000000..10960d2 --- /dev/null +++ b/update/v5/chat.php @@ -0,0 +1,20 @@ +_table); + } + + public function getFieldsToAdd() { + return array( + 'info' => Field::text() + ); + } +} diff --git a/update/v5/index.php b/update/v5/index.php new file mode 100644 index 0000000..1ea35a5 --- /dev/null +++ b/update/v5/index.php @@ -0,0 +1,7 @@ +execute(); +Zira\Log::write('Updated chats table'); \ No newline at end of file diff --git a/zira/helper.php b/zira/helper.php index 4894a23..7ee31cd 100644 --- a/zira/helper.php +++ b/zira/helper.php @@ -183,6 +183,12 @@ class Helper { $url = str_ireplace('%2F', '/', $url); return $url; } + + public static function isCurrentDay($time) { + $day_str = date(Config::get('date_format'), $time); + $current_str = date(Config::get('date_format'), time()); + return $day_str == $current_str; + } public static function backtrace($return=false) { $backtrace = debug_backtrace();