<?php
$date = date('Y-m-01');
$next_month = date('Y-m-d', strtotime('+1 month', strtotime($date)));
function nextWorkDay($date) {
$day_of_week = date('N', strtotime($date));
if ($day_of_week>5) {
//echo "Weekend: " . $date;
$shift = 8-$day_of_week;
return date('Y-m-d', strtotime("+{$shift} day", strtotime($date)));
} else {
echo "Work day ($day_of_week):" . $date . PHP_EOL;
return date('Y-m-d', strtotime('+3 day', strtotime($date)));
}
}
while ($date < $next_month) {
$date = nextWorkDay($date);
}
$date = time(); // strtotime(date('Y-m-d H:i:s'))
$dateInfo = getdate($date);
$dayNumber = $dateInfo['wday'];
$dayHour = (int)$dateInfo['hours'];
$dayLangs = [
'Воскресение',
'Понедельник',
'Вторник',
'Среда',
'Четверк',
'Тяпница',
'Развратница',
];
if (!in_array($dayNumber, [0, 6])) {
if ($dayHour >= 8 && $dayHour <= 21) {
echo "Сейчас Будние дни c 08:00 - 21:00";
} else {
echo "Сегодня {$dayLangs[$dayHour]}, рабочий день закончен, Все на танцы, товарищи!";
}
} else if ($dayHour >= 8 && $dayHour <= 20) {
echo "Сейчас {$dayLangs[$dayHour]} с 08-20:00";
}
AddEventHandler('main', 'OnBuildGlobalMenu', 'addMenuItem');
function addMenuItem(&$aGlobalMenu, &$aModuleMenu)
{
global $USER;
if ($USER->IsAdmin()) {
$aGlobalMenu['global_menu_custom'] = [
'menu_id' => 'custom',
'text' => 'Bitrix Studio',
'title' => 'Bitrix Studio',
'url' => 'settingss.php?lang=ru',
'sort' => 1000,
'items_id' => 'global_menu_custom',
'help_section' => 'custom',
'items' => [
[
'parent_menu' => 'global_menu_custom',
'sort' => 10,
'url' => 'your_new_page.php?lang=ru',
'text' => 'your_new_page',
'title' => 'your_new_page',
'icon' => 'fav_menu_icon',
'page_icon' => 'fav_menu_icon',
'items_id' => 'menu_custom',
],
[
'parent_menu' => 'global_menu_custom',
'sort' => 20,
'url' => 'your_new_page_2.php?lang=ru',
'text' => 'your_new_page_2',
'title' => 'your_new_page_2',
'icon' => 'fav_menu_icon_2',
'page_icon' => 'fav_menu_icon_2',
'items_id' => 'menu_custom',
],
],
];
}
}
<?
AddEventHandler("search", "BeforeIndex", Array("MyClass", "BeforeIndexHandler"));
class MyClass
{
private $file_abs_path = "";
function BeforeIndexHandler($arFields)
{
$io = CBXVirtualIo::GetInstance();
if($arFields["MODULE_ID"] == "main")
{
list($site_id, $file_rel_path) = explode("|", $arFields["ITEM_ID"]);
$file_doc_root = CSite::GetSiteDocRoot($site_id);
$file_abs_path = preg_replace("#[\\\\\\/]+#", "/", $file_doc_root."/".$file_rel_path);
$f = $io->GetFile($file_abs_path);
$sFile = $f->GetContents();
if(isset($sFile) && $sFile != "")
{
$replacer = new MyClass;
$replacer->file_abs_path = $file_abs_path;
$sFile = preg_replace_callback("/<\\?\\\$APPLICATION->IncludeComponent\\(\\s*\"bitrix:main.include\",(.*?)\\?>/mis", array($replacer, "replace"), $sFile);
$arFields["BODY"] = CSearch::KillTags($sFile);
}
}
return $arFields;
}
function replace($matchParams)
{
$io = CBXVirtualIo::GetInstance();
if (preg_match("/\"AREA_FILE_SUFFIX\"\\s*=>\\s*\"(.*?)\",/", $matchParams[1], $match))
{
$slash_pos = strrpos($this->file_abs_path, "/");
$sFilePath = substr($this->file_abs_path, 0, $slash_pos+1);
$sFileName = substr($this->file_abs_path, $slash_pos+1);
$sFileName = substr($sFileName, 0, strlen($sFileName)-4)."_".$match[1].".php";
$f = $io->GetFile($sFilePath.$sFileName);
return $f->GetContents();
}
return "";
}
}
<?php if ($APPLICATION->GetCurPage(false) == '/news/'): ?>Код блока<?php endif; ?>
<input type="text" id="min" placeholder="min">
<input type="text" id="max" placeholder="max">
<p class="text"></p>
$('#max').change(function(){
let min = parseInt($('#min').val())
let max = parseInt($('#max').val())
if (max < min) {
$('.text').html('введите число больше минимума')
$('#max').val('')
} else {
$('.text').html('пойдет!')
}
})
$GLOBALS['arrFilter'] = array("PROPERTY_ARCHIVE" => 123);
$GLOBALS['arrFilter'] = array("PROPERTY_ARCHIVE_VALUE" => 'Активное');
$(function() {
$('#form-data').on('submit', function(e){
e.preventDefault()
var form = $(this); // Предположу, что этот код выполняется в обработчике события 'submit' формы
var data = new FormData(); // Для отправки файлов понадобится объект FormData. Подробнее про него можно прочитать в документации - https://developer.mozilla.org/en-US/docs/Web/API/FormData
// Сбор данных из обычных полей
form.find(':input[name]').not('[type="file"]').each(function() {
var field = $(this);
data.append(field.attr('name'), field.val());
});
// Сбор данных о файле (будет немного отличаться для нескольких файлов)
var filesField = form.find('input[type="file"]');
var fileName = filesField.attr('name');
var file = filesField.prop('files')[0];
data.append(fileName, file) ;
// Отправка данных
var url = 'upload.php';
$.ajax({
url: url,
type: 'POST',
data: data,
contentType: false,
cache: false,
processData:false,
success: function(response) {
console.log(response)
}
});
})
});
Есть слишком замороченный скрипт отправки, но он завязан на валидаторе.
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
function author_per_page( $query ) {
if( is_author() && !is_admin() && $query->is_main_query() ) {
$query->set( 'posts_per_page', 5 );
}
add_action( 'pre_get_posts', 'author_per_page' );
if (get_post_meta(get_the_ID(), '_stock_status', true) == 'outofstock') {
echo '<div class="outofstock">Нет в наличии</div>';
} else {
echo '<div class="stock">В наличии</div>';
}
[class*="ymaps-2"][class*="-ground-pane"] {
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale");
/* Firefox 3.5+ */
-webkit-filter: grayscale(100%);
/* Chrome 19+ & Safari 6+ */
}