Ejemplo n.º 1
0
    /**
     * Дополнение для общего лунного календаря и всех статей из данной категории
     *
     * @param object $post Объект класса Post (статья)
     */
    public static function fullMoonCalendar($post)
    {
        if ($post->id == 1758) {
            $currentYear = date('Y');
            $currentMonth = date('n');
            $calendarYear = $currentMonth == 12 ? ++$currentYear : $currentYear;
            $moonCal = '<h2 align="center">Лунный календарь на ' . $calendarYear . ' год по месяцам</h2><br />
            <table width="100%" class="moon_calendar_table">
			<tr>';
            for ($d = 1; $d <= 12; $d++) {
                if ($currentMonth == 12 && $d == 12) {
                    $mLink = AppData::getMoonCalLinks($currentYear, $d);
                    $moonCal .= '<td><a href="' . $mLink . '">Лунный календарь на ' . GlobalHelper::rusMonth($d) . ' ' . $currentYear . ' года</a></td>';
                } else {
                    $mLink = AppData::getMoonCalLinks($calendarYear, $d);
                    $moonCal .= '<td><a href="' . $mLink . '">Лунный календарь на ' . GlobalHelper::rusMonth($d) . ' ' . $calendarYear . ' года</a></td>';
                }
                if ($d % 2 == 0) {
                    $moonCal .= '</tr><tr>';
                }
            }
            $moonCal .= '</tr></table><br />';
            $post->title = str_replace("YEAR", $calendarYear, $post->title);
            $post->full = str_replace("[YEAR]", $calendarYear, $post->full);
            $post->full = str_replace("[MOON-MONTH]", $moonCal, $post->full);
        }
    }
Ejemplo n.º 2
0
 private function replace($string)
 {
     // Год
     $string = str_replace('[year]', $this->year, $string);
     // Img Alt
     $string = str_replace('[alt]', $this->replace($this->alt), $string);
     // Месяцы
     if (preg_match('@\\[month_([a-z]{1})\\]@si', $string)) {
         $string = preg_replace_callback('@\\[month_([a-z]{1})\\]@si', function ($matches) {
             return GlobalHelper::rusMonth((int) $this->month, $matches[1]);
         }, $string);
     }
     if (preg_match('@\\[engmonth_([a-z]{1})\\]@si', $string)) {
         $string = preg_replace_callback('@\\[engmonth_([a-z]{1})\\]@si', function ($matches) {
             return GlobalHelper::engMonth((int) $this->month, $matches[1]);
         }, $string);
     }
     // Знаки
     if (preg_match('@\\[znak_([a-z]{1})\\]@si', $string)) {
         $string = preg_replace_callback('@\\[znak_([a-z]{1})\\]@si', function ($matches) {
             return GlobalHelper::rusZodiac((int) $this->znak, $matches[1]);
         }, $string);
     }
     if (preg_match('@\\[engznak_([a-z]{1})\\]@si', $string)) {
         $string = preg_replace_callback('@\\[engznak_([a-z]{1})\\]@si', function ($matches) {
             return mb_strtolower(GlobalHelper::translit(GlobalHelper::rusZodiac((int) $this->znak, $matches[1])));
         }, $string);
     }
     return $string;
 }
Ejemplo n.º 3
0
<?php

/* @var $this yii\web\View */
use yii\helpers\Html;
use common\components\helpers\GlobalHelper;
$controls = '';
if (!$noControls) {
    $controls = Html::tag('div', '<i class="fa fa-angle-double-left fa-lg"></i>', ['class' => 'calendar_control', 'id' => 'calendar-prev']);
    $controls .= Html::tag('div', '<i class="fa fa-angle-double-right fa-lg"></i>', ['class' => 'calendar_control', 'id' => 'calendar-next']);
}
list($year, $month) = explode('-', $date);
$daysInMonth = date('t', strtotime($date));
$dateOut = GlobalHelper::ucfirst(GlobalHelper::rusMonth($month)) . ' ' . $year;
if (!empty($posts)) {
    $dateOut = Html::a($dateOut, '/' . $year . '/' . $month . '/');
}
$calendar = '<div class="calendar_nowmonth">' . $dateOut . '</div>
<table class="calendar_table">
	    <tr>
	        <th class="weekday">Пн</th>
	        <th class="weekday">Вт</th>
	        <th class="weekday">Ср</th>
	        <th class="weekday">Чт</th>
	        <th class="weekday">Пт</th>
	        <th class="weekday">Сб</th>
	        <th class="weekday">Вс</th>
	    </tr><tr>';
for ($i = 1; $i <= $daysInMonth; $i++) {
    $day = sprintf('%02d', $i);
    $dayOfWeek = date('w', strtotime("{$year}-{$month}-{$day}"));
    if (!$dayOfWeek) {