Browse Source

инициализация модуля - версия 1.0

master
root 8 years ago
parent
commit
ec0cdae0dc
  1. 186
      unicalendar/class.unicalendar.php
  2. 99
      unicalendar/css/eventCalendar.css
  3. 371
      unicalendar/css/eventCalendar_theme_responsive.css
  4. 4
      unicalendar/css/index.php
  5. 4
      unicalendar/images/index.php
  6. 4
      unicalendar/js/index.php
  7. 495
      unicalendar/js/jquery.eventCalendar.js
  8. 13
      unicalendar/js/jquery.eventCalendar.min.js
  9. 2856
      unicalendar/js/moment.js
  10. 4
      unicalendar/lang/index.php
  11. 4
      unicalendar/lang/ru.php
  12. 34
      unicalendar/lang/ru.txt
  13. 85
      unicalendar/module.php
  14. 43
      unicalendar/sql.php
  15. 279
      unicalendar/templates/admin_unicalendar_list.tpl
  16. 4
      unicalendar/templates/index.php
  17. 39
      unicalendar/templates/unicalendar.tpl
  18. 54
      unicalendar/uca.res.php

186
unicalendar/class.unicalendar.php

@ -0,0 +1,186 @@
<?php
/**
* Класс работы с календарями событий - модуля Unicalendar
*
* @autor Repellent
* @package AVE.cms
* @subpackage module_unicalendar
* @filesource
*/
class Unicalendar
{
/**
* ФУНКЦИИ ПУБЛИЧНОЙ ЧАСТИ
*/
/**
* Вывод календаря событий
* @param string $tpl_dir - путь к папке с шаблонами модуля
* @param int $id - идентификатор календаря
*/
function unicalendarShow($tpl_dir, $id)
{
global $AVE_DB, $AVE_Template;
$sql = $AVE_DB->Query("
SELECT *
FROM " . PREFIX . "_module_unicalendar
WHERE id = '" . $id . "'
");
$unicalendars = array();
while ($row = $sql->FetchAssocArray())
{
array_push($unicalendars, $row);
}
foreach ( $unicalendars as $k=>$v )
{
$uevents = $v['uca_events'];
$urubric_id = $v['uca_rubric_id'];
$udoc_id = $v['uca_doc_id'];
}
// Если выбрали вывести все документы из заданной рубрики - документы с Id=1 и Id=2 - выводиться не будут!
if ($uevents !='' && $uevents == '1'){
$sql = $AVE_DB->Query("
SELECT Id, document_alias, document_title, document_published, document_meta_description
FROM " . PREFIX . "_documents
WHERE rubric_id = '" . $urubric_id . "' AND Id > 2
");
$results = array();
while ($row = $sql->FetchAssocArray())
{
array_push($results, $row);
}
}
// Если выбрали вывести выбранные документы из заданной рубрики
if ($uevents !='' && $uevents == '2'){
$sql = $AVE_DB->Query("
SELECT Id, document_alias, document_title, document_published, document_meta_description
FROM " . PREFIX . "_documents
WHERE rubric_id = '" . $urubric_id . "' AND Id > 2 AND $udoc_id
");
$results = array();
while ($row = $sql->FetchAssocArray())
{
array_push($results, $row);
}
}
$AVE_Template->assign('unicalendars', $unicalendars);
$AVE_Template->assign('results', $results);
$AVE_Template->display($tpl_dir . 'unicalendar.tpl');
}
/**
* ФУНКЦИИ АДМИНИСТРАТИВНОЙ ЧАСТИ
*/
/**
* Вывод списка календарей
*
* @param string $tpl_dir - путь к папке с шаблонами модуля
*/
function unicalendarList($tpl_dir)
{
global $AVE_DB, $AVE_Template;
$unicalendars = array();
$limit = 20;
$start = get_current_page() * $limit - $limit;
$sql = $AVE_DB->Query("
SELECT SQL_CALC_FOUND_ROWS
u.*,
COUNT(u.id) AS uca_count
FROM
" . PREFIX . "_module_unicalendar AS u
GROUP BY u.id
ORDER BY u.id ASC
LIMIT " . $start . "," . $limit . "
");
$sql_num = $AVE_DB->Query("SELECT FOUND_ROWS()");
$num = $sql_num->GetCell();
while($row = $sql->FetchAssocArray())
{
array_push($unicalendars, $row);
}
if ($num > $limit)
{
$page_nav = "<li><a href=\"index.php?do=modules&action=modedit&mod=unicalendar&moduleaction=1&page={s}&amp;cp=" . SESSION . "\">{t}</a></li>";
$page_nav = get_pagination(ceil($num / $limit), 'page', $page_nav);
}
else
{
$page_nav = '';
}
$AVE_Template->assign('page_nav', $page_nav);
if (!empty($_REQUEST['alert']))
{
$AVE_Template->assign('alert', htmlspecialchars(stripslashes($_REQUEST['alert'])));
}
$AVE_Template->assign('unicalendars', $unicalendars);
$AVE_Template->assign('formaction', 'index.php?do=modules&action=modedit&mod=unicalendar&moduleaction=new&sub=save&amp;cp=' . SESSION);
$AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_unicalendar_list.tpl'));
}
/**
* Создание календаря
*
*/
function unicalendarNew()
{
if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'save')
{
global $AVE_DB;
$cont = true;
$alert = '';
if (empty($_POST['uca_title']))
{
$alert = '&alert=empty_uca_title';
$cont = false;
}
if ($cont)
{
$AVE_DB->Query("
INSERT
INTO " . PREFIX . "_module_unicalendar
SET
id = '',
uca_title = '" . $_POST['uca_title'] . "',
uca_events = '" . $_POST['uca_events'] . "',
uca_rubric_id = '" . $_POST['uca_rubric_id'] . "',
uca_doc_id = '" . $_POST['uca_doc_id'] . "'
");
}
header('Location:index.php?do=modules&action=modedit&mod=unicalendar&moduleaction=1'. $alert);
exit;
}
}
/**
* Удаление календаря
*
* @param int $unicalendar_id - идентификатор календаря
*/
function unicalendarDelete($unicalendar_id)
{
global $AVE_DB;
$AVE_DB->Query("DELETE FROM " . PREFIX . "_module_unicalendar WHERE id = '" . $unicalendar_id . "'");
header('Location:index.php?do=modules&action=modedit&mod=unicalendar&moduleaction=1&amp;cp=' . SESSION);
exit;
}
}
?>

99
unicalendar/css/eventCalendar.css

@ -0,0 +1,99 @@
/*= CORE CSS */
.eventCalendar-hidden {
display: none;
}
.eventCalendar-wrap {
position: relative;
overflow: hidden;
}
.eventCalendar-arrow {
position: absolute;
z-index: 5;
top: 3px;
}
.eventCalendar-prev {
left: 3px;
}
.eventCalendar-next {
right: 3px;
}
.eventCalendar-monthTitle {
display: block;
text-align: center;
}
.eventCalendar-monthWrap {
position: absolute;
top: 0;
left: 0;
z-index: 2;
}
.eventCalendar-currentMonth {
z-index: 1;
}
.eventCalendar-daysList {
display: table;
width: 100%;
}
.eventCalendar-showAsWeek {
display: block;
}
.eventCalendar-daysList li {
display: table-cell;
}
.eventCalendar-dayWithEvents {
background: rgba(0, 0, 0, 0.15);
}
.eventCalendar-current {
background: rgba(0, 0, 0, 0.35);
}
.eventCalendar-showAsWeek li {
display: block;
float: left;
width: 14.28%;
height: 20px;
}
.eventCalendar-daysList a {
padding: 0;
display: block;
text-align: center;
font-size: 8px;
min-width: 7px;
}
.eventCalendar-loading {
display: block;
min-width: 100px;
height: 40px;
line-height: 40px;
}
.eventCalendar-list {
position: relative;
z-index: 1;
}
.eventCalendar-oldEventList {
z-index: 2;
}
.eventCalendar-subtitle {
padding-left: 5px;
font-weight: bold;
font-size: 120%;
}
/* end of core CSS */

371
unicalendar/css/eventCalendar_theme_responsive.css

@ -0,0 +1,371 @@
/* Theme CSS */
/*html {
background-color:#eee;
}
body {
font-family: Arial, "Lucida Grande", sans-serif;
font-size: 13px;
line-height: 18px;
color: #555;
background-color:#fff;
}*/
.eventCalendar-wrap {
border:solid 1px #d3d3d3;
box-shadow:0 0 15px #999;
border-radius:5px;
margin-bottom:20px;
background-color:#fff;
color:#807E7E;
}
.eventCalendar-wrap .eventCalendar-arrow {
text-decoration:none;
color:#fff;
padding:0 5px;
line-height:28px;
top:9px;
padding:8px 10px;
}
.eventCalendar-wrap .eventCalendar-arrow.prev {
}
.eventCalendar-wrap .eventCalendar-arrow:hover { opacity:0.7;}
.eventCalendar-wrap .eventCalendar-arrow span {
height: 0;
width: 0;
font-size: 0;
line-height: 0;
border-top: 6px solid transparent;
border-bottom: 6px solid transparent;
border-left: 6px solid #fff;
float:left;
text-indent:-5000px;
}
.eventCalendar-wrap .eventCalendar-arrow.eventCalendar-prev span {
border-left-width:0;
border-right: 6px solid #fff;
}
.eventCalendar-slider { height:80px;}
.eventCalendar-monthWrap {
border-radius:5px;
top:10px;
left:0px;
}
.eventCalendar-currentTitle {
line-height:25px;
background-color:#138DA5;
outline:1px solid #138DA5;
border:1px solid #E3E3E3;
border-width:1px 0;
}
.eventCalendar-currentTitle .eventCalendar-monthTitle {
font-size:110%;
text-decoration:none;
font-weight:bold;
color:#fff;
}
.eventCalendar-daysList {
zoom: 1;
padding:0;
width:100%;
}
.eventCalendar-daysList.eventCalendar-showAsWeek {
margin:10px 5px;
width:auto;
border:solid 1px #BCBCBC;
border-bottom-width:0;
border-radius:0;
background-color:#CCCCCC;
background-image: linear-gradient(top, #EEEEEE 42%, #CCCCCC 71%);
background-image: -o-linear-gradient(top, #EEEEEE 42%, #CCCCCC 71%);
background-image: -moz-linear-gradient(top, #EEEEEE 42%, #CCCCCC 71%);
background-image: -webkit-linear-gradient(top, #EEEEEE 42%, #CCCCCC 71%);
background-image: -ms-linear-gradient(top, #EEEEEE 42%, #CCCCCC 71%);
background-image: -webkit-gradient(
linear,
left top,
left bottom,
color-stop(0.42, #EEEEEE),
color-stop(0.71, #CCCCCC)
);
}
.eventCalendar-daysList.showDayNames.eventCalendar-showAsWeek {
border-radius:5px 5px 0 0;
}
.eventCalendar-daysList:before, .eventCalendar-daysList:after { content:""; display:table; }
.eventCalendar-daysList:after { clear: both; }
.eventCalendar-day-header {
text-transform:lowercase;
text-align:center;
font-size:12px;
border-bottom:solid 1px #BCBCBC;
}
.eventCalendar-daysList.eventCalendar-showAsWeek li {
height:auto; margin:0;
}
.eventCalendar-daysList.eventCalendar-showAsWeek li.eventCalendar-empty {
background-color: #ccc;
min-height:27px;
border-top: solid 1px #ccc;
}
.eventCalendar-day a {
text-decoration:none;
font-size:10px;
color:#424242;
}
.eventCalendar-day {
border-left:solid 1px #BCBCBC;
}
.eventCalendar-day a {
border:solid 1px #BCBCBC;
border-width:0 1px 1px 0;
}
.eventCalendar-showAsWeek .eventCalendar-day { border-left-width:0;}
.eventCalendar-showAsWeek .eventCalendar-day a {
border:solid 1px red;
border-color:#fff #BCBCBC #BCBCBC #eee;
line-height:27px;
font-size:11px;
}
.eventCalendar-day a:hover {
background-color:#E4E4E4;
/* box-shadow:inset 5px 5px 10px #C1C1C1;
text-shadow: 2px 2px 2px #C1C1C1;*/
}
.eventCalendar-daysList li.today a {
color:#fff;
background:#aaa;
/* box-shadow:inset 5px 5px 10px #777;
text-shadow: 2px 2px 2px #777;*/
}
li.eventCalendar-day.today a:hover {
background-color:#ccc;
/*box-shadow:inset 5px 5px 10px #999;*/
}
.eventCalendar-daysList li.eventCalendar-dayWithEvents a {
background:#89B814;
/*box-shadow:inset 5px 5px 10px #698B10;
text-shadow: 2px 2px 2px #698B10;*/
color:#fff;
}
li.eventCalendar-day.eventCalendar-dayWithEvents a:hover {
background-color:#C2D374;
/*box-shadow:inset 5px 5px 10px #89B814;
text-shadow: 2px 2px 2px #89B814;*/
}
.eventCalendar-daysList li.current a {
color:#fff;
background:#449FB2;
box-shadow:inset 5px 5px 10px #216B7A;
text-shadow: 2px 2px 2px #216B7A;
}
li.eventCalendar-day.current a:hover {
background-color:#79BDCC;
box-shadow:inset 5px 5px 10px #449FB2;
text-shadow: 2px 2px 2px #449FB2;
}
.eventCalendar-loading {
border-radius:4px;
margin:5px auto;
padding:0 10px;
background-color:#ccc;
color:#fff;
text-align:center;
font-weight:bold;
box-shadow:0 0 10px #ccc;
text-shadow:0 0 3px #aaa;
position:absolute;
z-index:4;
top:25px;
left:5px;
}
.eventCalendar-loading.error {
background-color:red;
}
.eventCalendar-subtitle { padding-top:10px;}
.eventCalendar-list-wrap {
min-height:100px;
position:relative;
}
.eventCalendar-list-content.scrollable {
height:100px;
overflow-y:auto;
margin:0 5px 5px 0;
}
.eventCalendar-list {
margin:0; padding:0; list-style-type:none;
}
.eventCalendar-list li {
padding:0 5px 15px;
margin:0;
clear:both;
}
.eventCalendar-list li time {
font-size:10px;
line-height:13px;
}
.eventCalendar-list li time em {
float:left;
font-style:normal;
}
.eventCalendar-list li time small {
font-size:10px;
float:left;
background-color:#807E7E;
color:#fff;
padding:0 5px 0 4px;
margin:0 0 0 3px;
}
.eventCalendar-list li .eventCalendar-eventTitle {
display:block;
clear:both;
font-weight:bold;
text-decoration:none;
}
.eventCalendar-list li a.eventCalendar-eventTitle {
color:#0E8EAB;
}
.eventCalendar-list li a.eventCalendar-eventTitle:hover { text-decoration:underline;}
.eventCalendar-list li .eventDesc {
clear: both;
margin:0 0 5px 0;
font-size:80%;
line-height:1.2em;
}
.eventCalendar-list .eventCalendar-noEvents {
font-size:120%;
border-radius:4px;
margin:5px;
padding:5px;
background-color:#ccc;
color:#fff;
text-align:center;
font-weight:bold;
box-shadow:0 0 10px #ccc;
text-shadow:0 0 3px #aaa;
}
.bt {
font-size:12px;
display:block;
clear:both;
text-align: center;
margin-top:10px;
padding: 9px 34px 11px;
text-decoration: none;
font-weight: bold;
line-height: 1;
color: #ffffff;
background-color: #698B10;
background-repeat: repeat-x;
background-image: -khtml-gradient(linear, left top, left bottom, from(#89B814), to(#698B10));
background-image: -moz-linear-gradient(top, #89B814, #698B10);
background-image: -ms-linear-gradient(top, #89B814, #698B10);
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #89B814), color-stop(100%, #698B10));
background-image: -webkit-linear-gradient(top, #89B814, #698B10);
background-image: -o-linear-gradient(top, #89B814, #698B10);
background-image: linear-gradient(top, #89B814, #698B10);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#89B814', endColorstr='#698B10', GradientType=0);
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
border: 1px solid #698B10;
border-color: #698B10 #698B10 #465F05;
border-radius: 4px;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
-webkit-transition: 0.1s linear all;
-moz-transition: 0.1s linear all;
-ms-transition: 0.1s linear all;
-o-transition: 0.1s linear all;
transition: 0.1s linear all;
}
.bt:hover {
background-position: 0 -15px;
text-decoration: none;
color: #E4E4E4;
}
/* end of theme css */
/*= ONLY FOR DEMO PAGE */
body {
/*
width:978px;
box-shadow:0 0 10px #777;
padding: 20px 40px;
margin:0 auto;
*/
}
a { color: #0E8EAB}
/*
.eventCalendar-wrap {
width:265px;
}
*/
.features li { margin-bottom:3px;}
#thanksPanel li { margin-bottom:0;}
#introPanel { padding-top:20px;}
.poweredBy img {
float:left;
margin-right:3px;
}
.poweredBy .data {
float:left;
}
.poweredBy .name {
font-weight:bold;
color:#555;
text-decoration:none;
display:block;
margin-top:28px;
}
.poweredBy .twitter {
text-decoration:none;
display:block;
float:left;
}
.features {
padding-left:20px;
float:left;
}
#appLogo {
margin-right:30px;
}
pre {
clear:both;
background-color:#FFFFCC;
padding:5px;
border:solid 1px #FED17E;
overflow:auto;
}
#license {
width:300px;
float:right;
font-size:10px;
line-height:12px;
text-align:center;
}
/* end of demo page */

4
unicalendar/css/index.php

@ -0,0 +1,4 @@
<?php
header('Location:/');
exit;
?>

4
unicalendar/images/index.php

@ -0,0 +1,4 @@
<?php
header('Location:/');
exit;
?>

4
unicalendar/js/index.php

@ -0,0 +1,4 @@
<?php
header('Location:/');
exit;
?>

495
unicalendar/js/jquery.eventCalendar.js

@ -0,0 +1,495 @@
/* =
jquery.eventCalendar.js
version: 0.7
date: 13-08-2015
author:
Jaime Fernandez (@vissit)
company:
Paradigma Tecnologico (@paradigmate)
url:
http://www.vissit.com/projects/eventCalendar/
*/
;(function( $ ) {
$.fn.eventCalendar = function(options){
var calendar = this;
if ( options.locales && typeof(options.locales) == 'string' ) {
$.getJSON(options.locales, function(data) {
options.locales = $.extend({}, $.fn.eventCalendar.defaults.locales, data);
moment.locale(data.locale, options.locales.moment);
moment.locale(data.locale);
initEventCalendar(calendar, options);
}).error(function() {
showError("error getting locale json", $(this));
});
} else {
if ( options.locales && options.locales.locale ) {
options.locales = $.extend({}, $.fn.eventCalendar.defaults.locales, options.locales);
moment.locale(options.locales.locale, options.locales.moment);
moment.locale(options.locales.locale);
}
initEventCalendar(calendar, options);
}
};
// define the parameters with the default values of the function
$.fn.eventCalendar.defaults = {
eventsjson: 'js/events.json',
eventsLimit: 4,
locales: {
locale: "en",
txt_noEvents: "There are no events in this period",
txt_SpecificEvents_prev: "",
txt_SpecificEvents_after: "events:",
txt_next: "next",
txt_prev: "prev",
txt_NextEvents: "Next events:",
txt_GoToEventUrl: "See the event",
txt_loading: "loading..."
},
showDayAsWeeks: true,
startWeekOnMonday: true,
showDayNameInCalendar: true,
showDescription: false,
onlyOneDescription: true,
openEventInNewWindow: false,
eventsScrollable: false,
dateFormat: "D/MM/YYYY",
jsonDateFormat: 'timestamp', // you can use also "human" 'YYYY-MM-DD HH:MM:SS'
moveSpeed: 500, // speed of month move when you clic on a new date
moveOpacity: 0.15, // month and events fadeOut to this opacity
jsonData: "", // to load and inline json (not ajax calls)
cacheJson: true // if true plugin get a json only first time and after plugin filter events
// if false plugin get a new json on each date change
};
function initEventCalendar(that, options) {
var eventsOpts = $.extend({}, $.fn.eventCalendar.defaults, options);
// define global vars for the function
var flags = {
wrap: "",
directionLeftMove: "300",
eventsJson: {}
};
// each eventCalendar will execute this function
that.each(function(){
flags.wrap = $(this);
flags.wrap.addClass('eventCalendar-wrap').append("<div class='eventCalendar-list-wrap'><p class='eventCalendar-subtitle'></p><span class='eventCalendar-loading'>"+eventsOpts.locales.txt_loading+"</span><div class='eventCalendar-list-content'><ul class='eventCalendar-list'></ul></div></div>");
if (eventsOpts.eventsScrollable) {
flags.wrap.find('.eventCalendar-list-content').addClass('scrollable');
}
setCalendarWidth(flags);
$(window).resize(function(){
setCalendarWidth(flags);
});
//flags.directionLeftMove = flags.wrap.width();
// show current month
dateSlider("current", flags, eventsOpts);
getEvents(flags, eventsOpts, eventsOpts.eventsLimit,false,false,false,false);
changeMonth(flags, eventsOpts);
flags.wrap.on('click','.eventCalendar-day a',function(e){
//flags.wrap.find('.eventCalendar-day a').live('click',function(e){
e.preventDefault();
var year = flags.wrap.attr('data-current-year'),
month = flags.wrap.attr('data-current-month'),
day = $(this).parent().attr('rel');
getEvents(flags, eventsOpts, false, year, month,day, "day");
});
flags.wrap.on('click','.eventCalendar-monthTitle', function(e){
//flags.wrap.find('.eventCalendar-monthTitle').live('click',function(e){
e.preventDefault();
var year = flags.wrap.attr('data-current-year'),
month = flags.wrap.attr('data-current-month');
getEvents(flags, eventsOpts, eventsOpts.eventsLimit, year, month,false, "month");
});
});
// show event description
flags.wrap.find('.eventCalendar-list').on('click','.eventCalendar-eventTitle',function(e){
//flags.wrap.find('.eventCalendar-list .eventCalendar-eventTitle').live('click',function(e){
if(!eventsOpts.showDescription) {
e.preventDefault();
var desc = $(this).parent().find('.eventCalendar-eventDesc');
if (!desc.find('a').size()) {
var eventUrl = $(this).attr('href');
var eventTarget = $(this).attr('target');
// create a button to go to event url
if(eventUrl){
desc.append('<a href="' + eventUrl + '" target="'+eventTarget+'" class="bt">'+eventsOpts.locales.txt_GoToEventUrl+'</a>');
}
}
if ( desc.is(':visible') ) {
desc.slideUp();
} else {
if(eventsOpts.onlyOneDescription) {
flags.wrap.find('.eventCalendar-eventDesc').slideUp();
}
desc.slideDown();
}
}
});
}
function sortJson(a, b){
if ( typeof a.date === 'string' ) {
return a.date.toLowerCase() > b.date.toLowerCase() ? 1 : -1;
}
return a.date > b.date ? 1 : -1;
}
function dateSlider(show, flags, eventsOpts) {
var $eventsCalendarSlider = $("<div class='eventCalendar-slider'></div>"),
$eventsCalendarMonthWrap = $("<div class='eventCalendar-monthWrap'></div>"),
$eventsCalendarTitle = $("<div class='eventCalendar-currentTitle'><a href='#' class='eventCalendar-monthTitle'></a></div>"),
$eventsCalendarArrows = $("<a href='#' class='eventCalendar-arrow eventCalendar-prev'><span>" + eventsOpts.locales.txt_prev + "</span></a><a href='#' class='eventCalendar-arrow eventCalendar-next'><span>" + eventsOpts.locales.txt_next + "</span></a>");
$eventsCalendarDaysList = $("<ul class='eventCalendar-daysList'></ul>"),
date = new Date();
if ( !flags.wrap.find('.eventCalendar-slider').length ) {
flags.wrap.prepend($eventsCalendarSlider);
$eventsCalendarSlider.append($eventsCalendarMonthWrap);
} else {
flags.wrap.find('.eventCalendar-slider').append($eventsCalendarMonthWrap);
}
flags.wrap.find('.eventCalendar-monthWrap.eventCalendar-currentMonth').removeClass('eventCalendar-currentMonth').addClass('eventCalendar-oldMonth');
$eventsCalendarMonthWrap.addClass('eventCalendar-currentMonth').append($eventsCalendarTitle, $eventsCalendarDaysList);
// if current show current month & day
if (show === "current") {
day = date.getDate();
$eventsCalendarSlider.append($eventsCalendarArrows);
} else {
date = new Date(flags.wrap.attr('data-current-year'),flags.wrap.attr('data-current-month'),1,0,0,0); // current visible month
day = 0; // not show current day in days list
moveOfMonth = 1;
if (show === "prev") {
moveOfMonth = -1;
}
date.setMonth( date.getMonth() + moveOfMonth );
var tmpDate = new Date();
if (date.getMonth() === tmpDate.getMonth()) {
day = tmpDate.getDate();
}
}
// get date portions
var year = date.getFullYear(), // year of the events
currentYear = new Date().getFullYear(), // current year
month = date.getMonth(), // 0-11
monthToShow = month + 1;
if (show != "current") {
// month change
getEvents(flags, eventsOpts, eventsOpts.eventsLimit, year, month,false, show);
}
flags.wrap.attr('data-current-month',month)
.attr('data-current-year',year);
// add current date info
moment.locale(eventsOpts.locales.locale);
var formatedDate = moment(year+" "+monthToShow, "YYYY MM").format("MMMM YYYY");
$eventsCalendarTitle.find('.eventCalendar-monthTitle').html(formatedDate);
// print all month days
var daysOnTheMonth = 32 - new Date(year, month, 32).getDate();
var daysList = [],
i;
if (eventsOpts.showDayAsWeeks) {
$eventsCalendarDaysList.addClass('eventCalendar-showAsWeek');
// show day name in top of calendar
if (eventsOpts.showDayNameInCalendar) {
$eventsCalendarDaysList.addClass('eventCalendar-showDayNames');
i = 0;
// if week start on monday
if (eventsOpts.startWeekOnMonday) {
i = 1;
}
for (; i < 7; i++) {
daysList.push('<li class="eventCalendar-day-header">'+moment()._locale._weekdaysShort[i]+'</li>');
if (i === 6 && eventsOpts.startWeekOnMonday) {
// print sunday header
daysList.push('<li class="eventCalendar-day-header">'+moment()._locale._weekdaysShort[0]+'</li>');
}
}
}
dt=new Date(year, month, 01);
var weekDay = dt.getDay(); // day of the week where month starts
if (eventsOpts.startWeekOnMonday) {
weekDay = dt.getDay() - 1;
}
if (weekDay < 0) { weekDay = 6; } // if -1 is because day starts on sunday(0) and week starts on monday
for (i = weekDay; i > 0; i--) {
daysList.push('<li class="eventCalendar-day eventCalendar-empty"></li>');
}
}
for (dayCount = 1; dayCount <= daysOnTheMonth; dayCount++) {
var dayClass = "";
if (day > 0 && dayCount === day && year === currentYear) {
dayClass = "today";
}
daysList.push('<li id="dayList_' + dayCount + '" rel="'+dayCount+'" class="eventCalendar-day '+dayClass+'"><a href="#">' + dayCount + '</a></li>');
}
$eventsCalendarDaysList.append(daysList.join(''));
$eventsCalendarSlider.css('height',$eventsCalendarMonthWrap.height()+'px');
}
function getEvents(flags, eventsOpts, limit, year, month, day, direction) {
limit = limit || 0;
year = year || '';
day = day || '';
// to avoid problem with january (month = 0)
if (typeof month != 'undefined') {
month = month;
} else {
month = '';
}
//var month = month || '';
flags.wrap.find('.eventCalendar-loading').fadeIn();
if (eventsOpts.jsonData) {
// user send a json in the plugin params
eventsOpts.cacheJson = true;
flags.eventsJson = eventsOpts.jsonData;
getEventsData(flags, eventsOpts, flags.eventsJson, limit, year, month, day, direction);
} else if (!eventsOpts.cacheJson || !direction) {
// first load: load json and save it to future filters
$.getJSON(eventsOpts.eventsjson + "?limit="+limit+"&year="+year+"&month="+month+"&day="+day, function(data) {
flags.eventsJson = data; // save data to future filters
getEventsData(flags, eventsOpts, flags.eventsJson, limit, year, month, day, direction);
}).error(function() {
showError("error getting json: ", flags.wrap);
});
} else {
// filter previus saved json
getEventsData(flags, eventsOpts, flags.eventsJson, limit, year, month, day, direction);
}
if (day > '') {
flags.wrap.find('.eventCalendar-current').removeClass('eventCalendar-current');
flags.wrap.find('#dayList_'+day).addClass('eventCalendar-current');
}
}
function getEventsData(flags, eventsOpts, data, limit, year, month, day, direction){
directionLeftMove = "-=" + flags.directionLeftMove;
eventContentHeight = "auto";
subtitle = flags.wrap.find('.eventCalendar-list-wrap .eventCalendar-subtitle');
if ( !direction ) {
// first load
subtitle.html(eventsOpts.locales.txt_NextEvents);
eventContentHeight = "auto";
directionLeftMove = "-=0";
} else {
var jsMonth = parseInt(month) + 1,
formatedDate;
moment.locale(eventsOpts.locales.locale);
if (day !== '') {
formatedDate = moment(year+" "+jsMonth+" "+day, "YYYY MM DD").format("LL");
subtitle.html(eventsOpts.locales.txt_SpecificEvents_prev + formatedDate + " " + eventsOpts.locales.txt_SpecificEvents_after);
//eventStringDate = moment(eventDate).format(eventsOpts.dateFormat);
} else {
formatedDate = moment(year+" "+jsMonth, "YYYY MM").format("MMMM");
subtitle.html(eventsOpts.locales.txt_SpecificEvents_prev + formatedDate + " " + eventsOpts.locales.txt_SpecificEvents_after);
}
if (direction === 'eventCalendar-prev') {
directionLeftMove = "+=" + flags.directionLeftMove;
} else if (direction === 'day' || direction === 'month') {
directionLeftMove = "+=0";
eventContentHeight = 0;
}
}
flags.wrap.find('.eventCalendar-list').animate({
opacity: eventsOpts.moveOpacity,
left: directionLeftMove,
height: eventContentHeight
}, eventsOpts.moveSpeed, function() {
flags.wrap.find('.eventCalendar-list').css({'left':0, 'height': 'auto'}).hide();
//wrap.find('.eventCalendar-list li').fadeIn();
var events = [];
data = $(data).sort(sortJson); // sort event by dates
// each event
if ( data.length ) {
// show or hide event description
var eventDescClass = '';
if(!eventsOpts.showDescription) {
eventDescClass = 'eventCalendar-hidden';
}
var eventLinkTarget = "_self";
if(eventsOpts.openEventInNewWindow) {
eventLinkTarget = '_target';
}
var i = 0;
$.each(data, function(key, event) {
var eventDateTime, eventDate, eventTime, eventYear, eventMonth, eventDay,
eventMonthToShow, eventHour, eventMinute, eventSeconds;
if (eventsOpts.jsonDateFormat == 'human') {
eventDateTime = event.date.split(" ");
eventDate = eventDateTime[0].split("-");
eventTime = eventDateTime[1].split(":");
eventYear = eventDate[0];
eventMonth = parseInt(eventDate[1]) - 1;
eventDay = parseInt(eventDate[2]);
//eventMonthToShow = eventMonth;
eventMonthToShow = parseInt(eventMonth) + 1;
eventHour = eventTime[0];
eventMinute = eventTime[1];
eventSeconds = eventTime[2];
eventDate = new Date(eventYear, eventMonth, eventDay, eventHour, eventMinute, eventSeconds);
} else {
eventDate = new Date(parseInt(event.date));
eventYear = eventDate.getFullYear();
eventMonth = eventDate.getMonth();
eventDay = eventDate.getDate();
eventMonthToShow = eventMonth + 1;
eventHour = eventDate.getHours();
eventMinute = eventDate.getMinutes();
}
if (parseInt(eventMinute) <= 9) {
eventMinute = "0" + parseInt(eventMinute);
}
if (limit === 0 || limit > i) {
// if month or day exist then only show matched events
if ((month === false || month == eventMonth) && (day === '' || day == eventDay) && (year === '' || year == eventYear) ) {
// if initial load then load only future events
if (month === false && eventDate < new Date()) {
} else {
moment.locale(eventsOpts.locales.locale);
//eventStringDate = eventDay + "/" + eventMonthToShow + "/" + eventYear;
eventStringDate = moment(eventDate).format(eventsOpts.dateFormat);
var eventTitle;
if (event.url) {
eventTitle = '<a href="'+event.url+'" target="' + eventLinkTarget + '" class="eventCalendar-eventTitle">' + event.title + '</a>';
} else {
eventTitle = '<span class="eventCalendar-eventTitle">'+event.title+'</span>';
}
events.push('<li id="' + key + '" class="'+event.type+'"><time datetime="'+eventDate+'"><em>' + eventStringDate + '</em><small>'+eventHour+":"+eventMinute+'</small></time>'+eventTitle+'<p class="eventCalendar-eventDesc ' + eventDescClass + '">' + event.description + '</p></li>');
i++;
}
}
}
// add mark in the dayList to the days with events
if (eventYear == flags.wrap.attr('data-current-year') && eventMonth == flags.wrap.attr('data-current-month')) {
flags.wrap.find('.eventCalendar-currentMonth .eventCalendar-daysList #dayList_' + parseInt(eventDay)).addClass('eventCalendar-dayWithEvents');
}
});
}
// there is no events on this period
if (!events.length) {
events.push('<li class="eventCalendar-noEvents"><p>' + eventsOpts.locales.txt_noEvents + '</p></li>');
}
flags.wrap.find('.eventCalendar-loading').hide();
flags.wrap.find('.eventCalendar-list')
.html(events.join(''));
flags.wrap.find('.eventCalendar-list').animate({
opacity: 1,
height: "toggle"
}, eventsOpts.moveSpeed);
});
setCalendarWidth(flags);
}
function changeMonth(flags, eventsOpts) {
flags.wrap.find('.eventCalendar-arrow').click(function(e){
e.preventDefault();
var lastMonthMove;
if ($(this).hasClass('eventCalendar-next')) {
dateSlider("next", flags, eventsOpts);
lastMonthMove = '-=' + flags.directionLeftMove;
} else {
dateSlider("prev", flags, eventsOpts);
lastMonthMove = '+=' + flags.directionLeftMove;
}
flags.wrap.find('.eventCalendar-monthWrap.eventCalendar-oldMonth').animate({
opacity: eventsOpts.moveOpacity,
left: lastMonthMove
}, eventsOpts.moveSpeed, function() {
flags.wrap.find('.eventCalendar-monthWrap.eventCalendar-oldMonth').remove();
});
});
}
function showError(msg, wrap) {
wrap.find('.eventCalendar-list-wrap').html("<span class='eventCalendar-loading eventCalendar-error'>"+msg+"</span>");
}
function setCalendarWidth(flags){
// resize calendar width on window resize
flags.directionLeftMove = flags.wrap.width();
flags.wrap.find('.eventCalendar-monthWrap').width(flags.wrap.width() + 'px');
flags.wrap.find('.eventCalendar-list-wrap').width(flags.wrap.width() + 'px');
}
})( jQuery );

13
unicalendar/js/jquery.eventCalendar.min.js vendored

File diff suppressed because one or more lines are too long

2856
unicalendar/js/moment.js

File diff suppressed because it is too large Load Diff

4
unicalendar/lang/index.php

@ -0,0 +1,4 @@
<?php
header('Location:/');
exit;
?>

4
unicalendar/lang/ru.php

@ -0,0 +1,4 @@
<?php
$select_category = 'Выбрать рубрику';
$bad_post = 'Ошибка запроса ! ';
?>

34
unicalendar/lang/ru.txt

@ -0,0 +1,34 @@
UCA_NO_EVENTS = "Нет запланированных событий"
UCA_REAL_EVENTS = "события:"
UCA_NEXT_EVENTS = "Следующие события:"
UCA_LOOK_EVENTS = "Смотреть"
UCA_MONTHS_EVENTS = "[ 'Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь' ]"
UCA_MONSHORT_EVENTS = "[ 'Янв', 'Фев', 'Мар', 'Апр', 'Май', 'Июн', 'Июл', 'Авг', 'Сен', 'Окт', 'Ноя', 'Дек' ]"
UCA_WEEKDAYS_EVENTS = "[ 'Воскресенье', 'Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота' ]"
UCA_WDAYSHORT_EVENTS = "[ 'Вс', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб' ]"
UCA_WDAYMIN_EVENTS = "[ 'Вс', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб' ]"
[admin]
ModName = "Управление модулем Unicalendar"
ModTitle = "В данном разделе находится список всех календарей.<br> Так же, вы можете создать новый календарь."
UCA_LIST = "Список календарей"
UCA_NEW = "Создать новый календарь"
UCA_NO_ITEMS = "В настоящий момент не существует ни одного календаря."
UCA_TITLE = "Название календаря"
UCA_EVENTS = "События календаря"
UCA_EVENTS_SELECT = "Выберите тип событий календаря"
UCA_EVENTS_SELECT_A = "Все документы из заданной рубрики"
UCA_EVENTS_SELECT_AC = "Выбор рубрики"
UCA_EVENTS_SELECT_DOC = "Отметить для выбора"
UCA_EVENTS_SELECT_B = "Выбранные документы из заданной рубрики"
UCA_EVENTS_SELECT_C = "Выбранные документы без привязки к рубрикам"
UCA_BTN_CREATE = "Создать"
UCA_CP_TAG = "Тег в системе"
UCA_COPY_BUFF = "Скопировать тег в буфер обмена"
UCA_ACTIONS = "Действия"
UCA_DELETE_UNICLN = "Удалить календарь"
UCA_DELETE_UNICLN_A = "Вы уверены, что хотите удалить этот календарь?"
UCA_LIST_ALLDOC_RUB = "Выводит все документы из рубрики c Id = "
UCA_LIST_SELDOC_RUB = "Выводит выбранные документы из рубрики c Id = "
UCA_TITLE_WARNING = "Не заполнено поле Название календаря"
UCA_EVENTS_WARNING = "События для этого календаря не заданы..."

85
unicalendar/module.php

@ -0,0 +1,85 @@
<?php
/**
* AVE.cms - Модуль Универсальный календарь событий
*
* @autor Repellent
* @package AVE.cms
* @subpackage module_unicalendar
* @filesource
*/
if(!defined('BASE_DIR')) exit;
if (defined('ACP'))
{
$modul['ModuleName'] = 'Универсальный календарь событий';
$modul['ModuleSysName'] = 'unicalendar';
$modul['ModuleVersion'] = '1.0';
$modul['ModuleDescription'] = '<br>Модуль позволяет создавать различные календари событий. <br> Для вывода календаря используйте системный тег <strong>[mod_unicalendar:XXX]</strong>';
$modul['ModuleAutor'] = 'Repellent';
$modul['ModuleCopyright'] = '&copy; AVE.cms Team 2017';
$modul['ModuleIsFunction'] = 1;
$modul['ModuleAdminEdit'] = 1;
$modul['ModuleFunction'] = 'mod_unicalendar';
$modul['ModuleTag'] = '[mod_unicalendar:XXX]';
$modul['ModuleTagLink'] = null;
$modul['ModuleAveTag'] = '#\\\[mod_unicalendar:([\\\d-]+)]#';
$modul['ModulePHPTag'] = "<?php mod_unicalendar(''$1''); ?>";
}
/**
* Публичная часть - вывод календаря
*
* @param string $id идентификатор календаря
*/
function mod_unicalendar($id)
{
global $AVE_Template;
require_once(BASE_DIR . '/modules/unicalendar/class.unicalendar.php');
$unicalendar = new Unicalendar;
// папка с шаблонами
$tpl_dir = BASE_DIR . '/modules/unicalendar/templates/';
// ленги
$lang_file = BASE_DIR . '/modules/unicalendar/lang/' . $_SESSION['user_language'] . '.txt';
$AVE_Template->config_load($lang_file);
$unicalendar->unicalendarShow($tpl_dir, $id);
}
/**
* Админка
*/
if (defined('ACP') && (isset($_REQUEST['moduleaction'])))
{
// класс
require_once(BASE_DIR . '/modules/unicalendar/class.unicalendar.php');
$unicalendar = new Unicalendar;
// папка с шаблонами
$tpl_dir = BASE_DIR . '/modules/unicalendar/templates/';
// ленги
$AVE_Template->config_load(BASE_DIR . '/modules/unicalendar/lang/' . $_SESSION['admin_language'] . '.txt', 'admin');
$AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
switch($_REQUEST['moduleaction'])
{
case '1': // Просмотр списка календарей
$unicalendar->unicalendarList($tpl_dir);
break;
case 'new': // Создать новый календарь
$unicalendar->unicalendarNew();
break;
case 'delunicalendar': // Удаление календаря
$unicalendar->unicalendarDelete(intval($_REQUEST['id']));
break;
}
}
?>

43
unicalendar/sql.php

@ -0,0 +1,43 @@
<?php
/**
* AVE.cms - Универсальный календарь событий.
*
* @autor Repellent
* @package AVE.cms
* @subpackage module_unicalendar
* @filesource
*/
/**
* mySQL-запросы для установки, обновления и удаления модуля
*/
$module_sql_install = array();
$module_sql_deinstall = array();
$module_sql_update = array();
//Удаление модуля
$module_sql_deinstall[] = "DROP TABLE IF EXISTS CPPREFIX_module_unicalendar;";
//Установка модуля
$module_sql_install[] = "CREATE TABLE `CPPREFIX_module_unicalendar` (
`id` int(10) unsigned NOT NULL auto_increment,
`uca_title` varchar(255) NOT NULL,
`uca_events` varchar(10) NOT NULL,
`uca_rubric_id` varchar(10) NOT NULL,
`uca_doc_id` varchar(1024) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0;";
$module_sql_update[] = "
UPDATE `CPPREFIX_module`
SET
ModuleAveTag = '" . $modul['ModuleAveTag'] . "',
ModulePHPTag = '" . $modul['ModulePHPTag'] . "',
ModuleVersion = '" . $modul['ModuleVersion'] . "'
WHERE
ModuleSysName = '" . $modul['ModuleSysName'] . "'
LIMIT 1;
";
?>

279
unicalendar/templates/admin_unicalendar_list.tpl

@ -0,0 +1,279 @@
<div class="title"><h5>{#ModName#}</h5></div>
<div class="widget" style="margin-top: 0px;">
<div class="body">
<ul>
<li>{#ModTitle#}</li>
</ul>
</div>
</div>
<div class="breadCrumbHolder module">
<div class="breadCrumb module">
<ul>
<li class="firstB"><a href="index.php" title="{#MAIN_PAGE#}">{#MAIN_PAGE#}</a></li>
<li><a href="index.php?do=modules&amp;cp={$sess}">{#MODULES_SUB_TITLE#}</a></li>
<li>{#ModName#}</li>
</ul>
</div>
</div>
{if $page_nav}
<div class="pagination">
<ul class="pages">
{$page_nav}
</ul>
</div>
{/if}
<div class="widget first">
<ul class="tabs">
<li class="activeTab"><a href="#tab1">{#UCA_LIST#}</a></li>
<li class=""><a href="#tab2">{#UCA_NEW#}</a></li>
</ul>
<div class="tab_container">
<div id="tab1" class="tab_content" style="display: block;">
<form action="" method="post" class="mainForm">
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic settings">
<colgroup>
<col width="1">
<col width="*">
<col width="200">
<col width="300">
<col width="210">
<col width="1">
</colgroup>
<thead>
<tr class="noborder">
<td>Id</td>
<td>{#UCA_TITLE#}</td>
<td>{#UCA_CP_TAG#}</td>
<td>{#UCA_EVENTS#}</td>
<td colspan="3">{#UCA_ACTIONS#}</td>
</tr>
</thead>
<tbody>
<form action="" method="post" class="mainForm">
{foreach from=$unicalendars item=unicalendar}
<tr>
<td align="center">
<strong>{$unicalendar.id}</strong>
</td>
<td align="left">
<strong>{$unicalendar.uca_title|escape}</strong>
</td>
<td align="center">
<div class="pr12" style="display: table; position: relative; text-align: right;">
<input style="width: 130px;" id="uca_{$unicalendar.id}" name="textfield" type="text" readonly value="[mod_unicalendar:{$unicalendar.id}]" size="17" />
<a style="text-align: center; padding: 5px 3px 4px 3px;" class="whiteBtn copyBtn topDir" href="javascript:void(0);" data-clipboard-action="copy" data-clipboard-target="#uca_{$unicalendar.id}" title="{#UCA_COPY_BUFF#}">
<img style="margin-top: -3px; position: relative; top: 4px; padding: 0 3px;" class="clippy" src="{$ABS_PATH}admin/templates/images/clippy.svg" width="13"></a>
</div>
</td>
<td align="center">
<div align="left">
{if $unicalendar.uca_events == 1}<strong>{#UCA_LIST_ALLDOC_RUB#}</strong><strong class="code">{$unicalendar.uca_rubric_id}</strong>
{elseif $unicalendar.uca_events == 2}{#UCA_LIST_SELDOC_RUB#}{$unicalendar.uca_rubric_id}
{else}{#UCA_EVENTS_WARNING#}
{/if}
</div>
</td>
<td align="center">
</td>
<td align="right">
<a class="topleftDir ConfirmDelete icon_sprite ico_delete" title="{#UCA_DELETE_UNICLN#}" dir="{#UCA_DELETE_UNICLN#}" name="{#UCA_DELETE_UNICLN_A#}" href="index.php?do=modules&action=modedit&mod=unicalendar&moduleaction=delunicalendar&id={$unicalendar.id}&cp={$sess}"></a>
</td>
</tr>
{/foreach}
{if !$unicalendars}
<tr>
<td colspan="6">
<ul class="messages">
<li class="highlight yellow">{#UCA_NO_ITEMS#}</li>
</ul>
</td>
</tr>
{/if}
</form>
</tbody>
</table>
</form>
</div>
<div id="tab2" class="tab_content" style="display: none;">
<form id="add_unicalendar" name="add_unicalendar" class="mainForm">
<table id="tr_uca" cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm">
<tr class="noborder">
<td width="180">{#UCA_TITLE#}</td>
<td>
<input placeholder="{#UCA_TITLE#}" name="uca_title" type="text" id="uca_title" value="" style="width:300px" />
</td>
</tr>
<tr class="noborder">
<td width="180">{#UCA_EVENTS#}</td>
<td>
<input type="hidden" name="uca_doc_id" id="uca_doc_id" value="" />
<input type="hidden" name="uca_events" id="uca_events" value="" />
<select name="uca_events_sel" id="uca_events_sel" style="width: 300px; z-index: 1;">
<option style="color: #ABABAB;" value="" >{#UCA_EVENTS_SELECT#}</option>
<option value="1">{#UCA_EVENTS_SELECT_A#}</option>
<option value="2">{#UCA_EVENTS_SELECT_B#}</option>
{* <option value="3">{#UCA_EVENTS_SELECT_C#}</option> *}
</select>
</td>
</tr>
</table>
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm">
<tr>
<td colspan="2">
<div class="pr12" style="display: table; padding: 5px 0px 5px 0px;">
<a id="btn_ucasub" class="btn blueBtn" href="javascript:void(0);">{#UCA_BTN_CREATE#}</a>
</div>
</td>
</tr>
</table>
</form>
</div>
</div>
<div class="fix"></div>
</div>
{if $page_nav}
<div class="pagination">
<ul class="pages">
{$page_nav}
</ul>
</div>
{/if}
<script>
// START Получаем значениe value выбранного option - События календаря
$('#uca_events_sel').change(function(){ldelim}
$('#uca_events').val('');
$('#tr_uca_res' ).remove();
$('#tr_uca_res_doc').remove();
var uca_request = '';
var uca_events = $("#uca_events_sel option:selected").val();
// Если значение value не пустое и выбран тип события "Все документы из заданной рубрики", подставляем значение value в input,
// продолжаем таблицу, отправляем AJAX запрос и пишем данные в эту таблицу.
if (uca_events !='' && uca_events == '1' ){ldelim}
$('#uca_rubric_id').val('');
$('#uca_events').val(uca_events);
$('#tr_uca').after('<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm"><tr class="noborder" id="tr_uca_res"><td width="180">{#UCA_EVENTS_SELECT_AC#}</td><td><input type="hidden" name="uca_rubric_id" id="uca_rubric_id" value=""><select name="uca_result" id="uca_result" style="width: 300px;"></select></td></tr></table>');
uca_request = uca_events;
ucaCall();
$('#uca_result').change(function(){ldelim}
$('#uca_rubric_id').val('');
$('#uca_inp_res').val('');
var uca_inp_res = $("#uca_result option:selected").val();
$('#uca_rubric_id').val(uca_inp_res);
{rdelim});
{rdelim}// END Если значение value не пустое и выбран тип события "Все документы из заданной рубрики"...
// Если значение value не пустое и выбран тип события "Выбранные документы из заданной рубрики", подставляем значение value в input,
// продолжаем таблицу, отправляем AJAX запрос и пишем данные в эту таблицу.
if (uca_events !='' && uca_events == '2' ){ldelim}
$('#uca_rubric_id').val('');
$('#uca_events').val(uca_events);
$('#tr_uca').after('<table id="tr_uca_res" cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm"><tr class="noborder"><td width="180">{#UCA_EVENTS_SELECT_AC#}</td><td><input type="hidden" name="uca_rubric_id" id="uca_rubric_id" value=""><select name="uca_result" id="uca_result" style="width: 300px;"></select></td></tr></table>');
uca_request = uca_events;
ucaCall();
$('#uca_result').change(function(){ldelim}
$('#tr_uca_res_doc').remove();
$('#uca_rubric_id').val('');
$('#uca_inp_res').val('');
$('#uca_doc_id').val('');
var post_doc = '';
var uca_inp_res = $("#uca_result option:selected").val();
$('#tr_uca_res').after('<table id="tr_uca_res_doc" cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm"><colgroup><col width="180" /><col width="*" /></colgroup><col width="*" /></colgroup><col width="*" /><thead><tr class="noborder"><td align="center">{#UCA_EVENTS_SELECT_DOC#}</td><td align="center">Id</td><td align="center">Название документа</td><td align="center">Дата создания</td></tr></thead><tbody><tr id="result_doc"><td width="180" align="center"></td></tr></tbody></table>');
$('#uca_rubric_id').val(uca_inp_res);
uca_doc_request = uca_inp_res;
ucaDoc();
{rdelim});
{rdelim}// END Если значение value не пустое и выбран тип события "Выбранные документы из заданной рубрики"...
// START AJAX запрос по типу выбранного события - "Все документы из заданной рубрики"
function ucaCall() {ldelim}
$.ajax({ldelim}
type: 'POST',
url: '{$ABS_PATH}modules/unicalendar/uca.res.php',
async: true,
data: uca_request,
success: function(data) {ldelim}
$("#uca_result").html(data);
$('input, select').styler();
uca_request = '';
{rdelim},
error: function(xhr, str){ldelim}
$.jGrowl("{#SaveError#}", {ldelim}
header: '{#SentData#}',
theme: 'error'
{rdelim});
{rdelim}
{rdelim});
{rdelim}; // END AJAX запрос по типу выбранного события - "Все документы из заданной рубрики"
// START AJAX запрос получаем список документов из выбранной рубрики
function ucaDoc() {ldelim}
$.ajax({ldelim}
type: 'POST',
url: '{$ABS_PATH}modules/unicalendar/uca.res.php',
async: true,
data: {ldelim}a:'post_doc',b:uca_doc_request{rdelim},
success: function(data) {ldelim}
$("#result_doc").after(data);
{rdelim},
error: function(xhr, str){ldelim}
$.jGrowl("{#SaveError#}", {ldelim}
header: '{#SentData#}',
theme: 'error'
{rdelim});
{rdelim}
{rdelim});
{rdelim}; // END AJAX запрос получаем список документов из выбранной рубрики
{rdelim}); // END Получаем значениe value выбранного option - События календаря
// START CHEK - выбираем документы и пишем в input значение
jQuery(function($) {ldelim}
$( document ).on('click change', "input:checkbox.my-checkbox", function() {ldelim}
var values = [];
$("input:checkbox.my-checkbox").filter(':checked').each(function() {ldelim}
values.push(this.value);
{rdelim});
$('#uca_doc_id').val("Id="+values.join(' OR Id=')+" ");
{rdelim});
{rdelim});// END CHECK - выбираем документы и пишем в input значение
// Если произошло событие на кнопке "Добавить" - записываем в БД
$("#btn_ucasub").on('click', function() {ldelim}
var msg = $('#add_unicalendar').serialize();
var check_fields = $('#uca_title').val();
if (check_fields !=''){ldelim}
$.ajax({ldelim}
type: 'POST',
url: '{$formaction}',
data: msg,
success: function(data) {ldelim}
document.location.href = "index.php?do=modules&action=modedit&mod=unicalendar&moduleaction=1&cp={$sess}";
{rdelim},
error: function(xhr, str){ldelim}
$.jGrowl("{#SaveError#}", {ldelim}
header: '{#SentData#}',
theme: 'error'
{rdelim});
{rdelim}
{rdelim});
{rdelim} else {ldelim}
alert("{#UCA_TITLE_WARNING#}");
{rdelim};
{rdelim}); // END Если произошло событие на кнопке "Добавить" - записываем в БД
// Копируем системные теги при клике в буфер обмена
var clipboard = new Clipboard('.copyBtn');
</script>

4
unicalendar/templates/index.php

@ -0,0 +1,4 @@
<?php
header('Location:/');
exit;
?>

39
unicalendar/templates/unicalendar.tpl

@ -0,0 +1,39 @@
<link rel="stylesheet" href="{$ABS_PATH}modules/unicalendar/css/eventCalendar.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="{$ABS_PATH}modules/unicalendar/css/eventCalendar_theme_responsive.css" type="text/css" media="screen" charset="utf-8" />
<script src="{$ABS_PATH}modules/unicalendar/js/moment.js" type="text/javascript" charset="utf-8"></script>
<script src="{$ABS_PATH}modules/unicalendar/js/jquery.eventCalendar.js" type="text/javascript" charset="utf-8"></script>
{foreach from=$unicalendars item=unicalendar}
<div id="eventCalendar{$unicalendar.id}" style="width: 300px; margin: 50px auto;"></div>
<script>
$(function(){ldelim}
var data = [
{foreach from=$results item=result}
{ldelim} "date": "{$result.document_published|date_format:'%Y-%m-%d %H:%M:%S'|pretty_date}", "title": "{$result.document_title}", "description": "{$result.document_meta_description}", "url": "{$result.document_alias}" {rdelim},
{/foreach}
];
$('#eventCalendar{$unicalendar.id}').eventCalendar({ldelim}
jsonData: data,
jsonDateFormat: 'human',
startWeekOnMonday: true,
openEventInNewWindow: false,
dateFormat: 'dddd DD-MM-YYYY',
showDescription: false,
locales: {ldelim}
locale: "ru",
txt_noEvents: "{#UCA_NO_EVENTS#}",
txt_SpecificEvents_prev: "",
txt_SpecificEvents_after: "{#UCA_REAL_EVENTS#}",
txt_NextEvents: "{#UCA_NEXT_EVENTS#}",
txt_GoToEventUrl: "{#UCA_LOOK_EVENTS#}",
moment: {ldelim}
"months" : {#UCA_MONTHS_EVENTS#},
"monthsShort" : {#UCA_MONSHORT_EVENTS#},
"weekdays" : {#UCA_WEEKDAYS_EVENTS#},
"weekdaysShort" : {#UCA_WDAYSHORT_EVENTS#},
"weekdaysMin" : {#UCA_WDAYMIN_EVENTS#}
{rdelim}
{rdelim}
{rdelim});
{rdelim});
</script>
{/foreach}

54
unicalendar/uca.res.php

@ -0,0 +1,54 @@
<?php
ob_start();
ob_implicit_flush(0);
define('BASE_DIR', str_replace("\\", "/", dirname(dirname(dirname(__FILE__)))));
require_once(BASE_DIR . '/inc/init.php');
require_once(BASE_DIR . '/modules/unicalendar/lang/ru.php');
if (! check_permission('adminpanel'))
{
header('Location:/index.php');
exit;
}
if (isset($_POST['1']))
{
global $AVE_DB;
$sql = $AVE_DB->Query("
SELECT Id, rubric_title
FROM " . PREFIX . "_rubrics
");
echo "<option style='color: #ABABAB;' value='' >".$select_category."</option>";
while($result = $sql->FetchRow()){
echo "<option value=".$result->Id.">".$result->rubric_title."</option>";
};
}
if (isset($_POST['2']))
{
global $AVE_DB;
$sql = $AVE_DB->Query("
SELECT Id, rubric_title
FROM " . PREFIX . "_rubrics
");
echo "<option style='color: #ABABAB;' value='' >".$select_category."</option>";
while($result = $sql->FetchRow()){
echo "<option value=".$result->Id.">".$result->rubric_title."</option>";
};
}
if (isset($_POST['a']))
{
global $AVE_DB;
$sql = $AVE_DB->Query("
SELECT Id, document_alias, document_title, document_published, document_meta_description
FROM " . PREFIX . "_documents
WHERE rubric_id = '" . $_POST['b'] . "' AND Id > 2
");
$u_sel_doc = array();
while ($row = $sql->FetchAssocArray())
{
array_push($u_sel_doc, $row);
}
foreach ( $u_sel_doc as $k=>$v )
{
echo "<tr class='noborder'><td align='center'><input type='checkbox' class='my-checkbox' name='u_chek".$v['Id']."' value='".$v['Id']."'></td>"."<td align='center'>".$v['Id']."</td>"."<td>".$v['document_title']."</td>"."<td align='center'>".$v['document_published'] = pretty_date(strftime(TIME_FORMAT, $v['document_published']))."</td></tr>";
}
}
?>
Loading…
Cancel
Save