本文整理汇总了PHP中cmsCore::spellCount方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsCore::spellCount方法的具体用法?PHP cmsCore::spellCount怎么用?PHP cmsCore::spellCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsCore
的用法示例。
在下文中一共展示了cmsCore::spellCount方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseHide
private function parseHide($text, $hidden = false) {
global $_LANG;
$pattern = '/\[hide(?:=?)([0-9]*)\](.*?)\[\/hide\]/sui';
preg_match($pattern, $text, $matches);
if (!$matches) { return $text; }
if ($hidden) {
$replacement = '<noindex>'. $_LANG['P_HIDE_TEXT_MOD'] .'</noindex>';
} else if (!cmsCore::c('user')->id) {
$replacement = '<noindex><div class="bb_tag_hide">'. $_LANG['P_HIDE_TEXT'] .'</div></noindex>';
} else {
if (!$matches[1]) {
$replacement = '<div class="bb_tag_hide">${2}</div>';
} else if (cmsCore::c('user')->rating > $matches[1] || cmsCore::c('user')->is_admin) {
$replacement = '<div class="bb_tag_hide">${2}</div>';
} else {
$replacement = '<div class="bb_tag_hide">'.sprintf($_LANG['P_HIDE_TEXT_RATING'], cmsCore::spellCount($matches[1], $_LANG['P_ITEM1'], $_LANG['P_ITEM2'], $_LANG['P_ITEM10'])).'</div>';
}
}
return preg_replace($pattern, $replacement, $text);
}
示例2: getDownLoadLink
function getDownLoadLink($file){
$file = preg_replace('/\.+\//', '', trim($file));
$file = htmlspecialchars($file);
$filefull = PATH.$file;
global $_LANG;
if (file_exists($filefull)){
$downloaded = cmsCore::fileDownloadCount($file);
$filesize = round(filesize($filefull)/1024, 2);
$link = '<span class="filelink">';
$link .= '<a href="/load/url=-'.base64_encode($file).'" alt="'.$_LANG['FILE_DOWNLOAD'].'">'.basename($file).'</a> ';
$link .= '<span>| '.$filesize.' '.$_LANG['SIZE_KB'].'</span> ';
$link .= '<span>| '.$_LANG['FILE_DOWNLOADED'].': '.cmsCore::spellCount($downloaded, $_LANG['TIME1'], $_LANG['TIME2'], $_LANG['TIME1']).'</span>';
$link .= '</span>';
} else {
$link = $_LANG['FILE'].' "'.$file.'" '.$_LANG['NOT_FOUND'];
}
return $link;
}
示例3: str_replace
$inPage->addHeadJS('includes/jquery/jquery.form.js');
/* ==================================================================================================== */
/* ==================================================================================================== */
if ($do == 'edit') {
// получаем комментарий
$comment = $model->getComment($comment_id);
if (!$comment) {
cmsCore::halt();
}
$is_author = $comment['user_id'] == $inUser->id;
// редактировать могут авторы (если время редактирования есть)
// модераторы и администраторы
if (!$model->is_can_moderate && !$inUser->is_admin && !($is_author && $comment['is_editable'])) {
cmsCore::halt();
}
// Для авторов показываем сколько осталось для редактирования
if ($is_author && $comment['is_editable'] && !$inUser->is_admin && !$model->is_can_moderate) {
$notice = str_replace('{min}', cmsCore::spellCount($comment['is_editable'], $_LANG['MINUTE1'], $_LANG['MINUTE2'], $_LANG['MINUTE10']), $_LANG['EDIT_INFO']);
}
}
if ($model->is_can_bbcode) {
$bb_toolbar = cmsPage::getBBCodeToolbar('content', true, 'comments', 'comment', $comment_id);
$smilies = cmsPage::getSmilesPanel('content');
}
/* ==================================================================================================== */
/* ==================================================================================================== */
$karma_need = $model->config['min_karma_add'];
$can_by_karma = $model->config['min_karma'] && $inUser->karma >= $karma_need || $inUser->is_admin;
$need_captcha = $model->config['regcap'] ? true : ($inUser->id ? false : true);
cmsPage::initTemplate('components', 'com_comments_add')->assign('user_can_add', $model->is_can_add)->assign('is_can_bbcode', $model->is_can_bbcode)->assign('do', $do)->assign('comment', isset($comment) ? $comment : array())->assign('is_user', $inUser->id)->assign('cfg', $model->config)->assign('target', $target)->assign('target_id', $target_id)->assign('parent_id', $parent_id)->assign('user_subscribed', cmsUser::isSubscribed($inUser->id, $target, $target_id))->assign('can_by_karma', $can_by_karma)->assign('karma_need', $karma_need)->assign('karma_has', $inUser->karma)->assign('need_captcha', $need_captcha)->assign('bb_toolbar', isset($bb_toolbar) ? $bb_toolbar : '')->assign('smilies', isset($smilies) ? $smilies : '')->assign('notice', isset($notice) ? $notice : '')->display('com_comments_add.tpl');
cmsCore::halt();
示例4: checkBan
/**
* Проверяет, находится ли текущий посетитель в бан-листе
* Если да, то показывает сообщение и завершает работу
*/
private function checkBan()
{
$inDB = cmsDatabase::getInstance();
$user_where = $this->id ? "(ip = '{$this->ip}' OR user_id = '{$this->id}')" : "ip = '{$this->ip}'";
// Проверяем бан
$ban = $inDB->get_fields('cms_banlist', $user_where . ' AND status=1', 'int_num, int_period, autodelete, id, status, bandate, user_id, cause');
if (!$ban) {
return;
}
if ($this->id) {
$inDB->query("UPDATE cms_banlist SET ip = '{$this->ip}' WHERE user_id = '{$this->id}'");
}
$interval = $ban['int_num'] . ' ' . $ban['int_period'];
// проверяем истек ли срок бана
if ($inDB->rows_count('cms_banlist', "id = '{$ban['id']}' AND bandate <= DATE_SUB(NOW(), INTERVAL {$interval}) AND int_num > 0")) {
// если истек и флаг автоудаления есть, удаляем
if ($ban['autodelete']) {
$inDB->query("DELETE FROM cms_banlist WHERE id='{$ban['id']}'");
} else {
$inDB->query("UPDATE cms_banlist SET status=0 WHERE id='{$ban['id']}'");
}
} else {
global $_LANG;
$ban['bandate'] = cmsCore::dateFormat($ban['bandate']);
$ban['enddate'] = cmsCore::spellCount($ban['int_num'], $_LANG[$ban['int_period'] . '1'], $_LANG[$ban['int_period'] . '2'], $_LANG[$ban['int_period'] . '10']);
cmsPage::includeTemplateFile('special/bantext.php', array('ban' => $ban));
$this->logout();
cmsCore::halt();
}
}
示例5: applet_modules
//.........这里部分代码省略.........
echo 'selected="selected"';
}
?>
><?php
echo $_LANG['YES'];
?>
</option>
</select>
</div>
<div style="margin-top:15px">
<strong><?php
echo $_LANG['AD_MODULE_CACHE_PERIOD'];
?>
</strong>
</div>
<div>
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top:5px;">
<tr>
<td valign="top" width="100">
<input name="cachetime" type="text" id="int_1" style="width:99%" value="<?php
echo @(int) $mod['cachetime'];
?>
"/>
</td>
<td valign="top" style="padding-left:5px">
<select name="cacheint" id="int_2" style="width:100%">
<option value="MINUTE" <?php
if (@mb_strstr($mod['cacheint'], 'MINUTE')) {
echo 'selected="selected"';
}
?>
><?php
echo cmsCore::spellCount((int) @$mod['cachetime'], $_LANG['MINUTE1'], $_LANG['MINUTE2'], $_LANG['MINUTE10'], false);
?>
</option>
<option value="HOUR" <?php
if (@mb_strstr($mod['cacheint'], 'HOUR')) {
echo 'selected="selected"';
}
?>
><?php
echo cmsCore::spellCount((int) @$mod['cachetime'], $_LANG['HOUR1'], $_LANG['HOUR2'], $_LANG['HOUR10'], false);
?>
</option>
<option value="DAY" <?php
if (@mb_strstr($mod['cacheint'], 'DAY')) {
echo 'selected="selected"';
}
?>
><?php
echo cmsCore::spellCount((int) @$mod['cachetime'], $_LANG['DAY1'], $_LANG['DAY2'], $_LANG['DAY10'], false);
?>
</option>
<option value="MONTH" <?php
if (@mb_strstr($mod['cacheint'], 'MONTH')) {
echo 'selected="selected"';
}
?>
><?php
echo cmsCore::spellCount((int) @$mod['cachetime'], $_LANG['MONTH1'], $_LANG['MONTH2'], $_LANG['MONTH10'], false);
?>
</option>
</select>
</td>
</tr>
示例6: spellcount
public function spellcount($num, $one, $two, $many, $is_full=true) {
return cmsCore::spellCount($num, $one, $two, $many, $is_full);
}
示例7: applet_modules
//.........这里部分代码省略.........
<?php } ?>
</table>
</div>
<label class="show_list">
<input type="checkbox" name="is_strict_bind" id="is_strict_bind" value="1" <?php if ($mod['is_strict_bind']) { echo 'checked="checked"'; } ?> />
<?php echo $_LANG['AD_DONT_VIEW']; ?>
</label>
<label class="hide_list">
<input type="checkbox" name="is_strict_bind_hidden" id="is_strict_bind_hidden" value="1" <?php if ($mod['is_strict_bind_hidden']) { echo 'checked="checked"'; } ?> />
<?php echo $_LANG['AD_EXCEPT_NESTED']; ?>
</label>
</div>
</div>
<?php if ((($mod['is_external'] && $do == 'edit') || $do == 'add') && cmsCore::c('config')->cache) { ?>
<div id="upr_cache">
<div class="form-group">
<label><?php echo $_LANG['AD_DO_MODULE_CACHE']; ?></label>
<select id="cache" class="form-control" style="width:100%" name="cache">
<option value="0" <?php if (!cmsCore::getArrVal($mod, 'cache')) { echo 'selected="selected"'; } ?>><?php echo $_LANG['NO']; ?></option>
<option value="1" <?php if (cmsCore::getArrVal($mod, 'cache')) { echo 'selected="selected"'; } ?>><?php echo $_LANG['YES']; ?></option>
</select>
</div>
<div class="form-group">
<label><?php echo $_LANG['AD_MODULE_CACHE_PERIOD']; ?></label>
<table class="table">
<tr>
<td valign="top" width="100">
<input id="int_1" class="form-control" style="width:99%" name="cachetime" type="text" value="<?php echo cmsCore::getArrVal($mod, 'cachetime', 0); ?>"/>
</td>
<td valign="top" style="padding-left:5px">
<select id="int_2" class="form-control" style="width:100%" name="cacheint">
<option value="MINUTE" <?php if(mb_strstr(cmsCore::getArrVal($mod, 'cacheint', 'MINUTES'), 'MINUTE')) { echo 'selected="selected"'; } ?>><?php echo cmsCore::spellCount(cmsCore::getArrVal($mod, 'cachetime', 0), $_LANG['MINUTE1'], $_LANG['MINUTE2'], $_LANG['MINUTE10'], false); ?></option>
<option value="HOUR" <?php if(mb_strstr(cmsCore::getArrVal($mod, 'cacheint', 'MINUTES'), 'HOUR')) { echo 'selected="selected"'; } ?>><?php echo cmsCore::spellCount(cmsCore::getArrVal($mod, 'cachetime', 0), $_LANG['HOUR1'], $_LANG['HOUR2'], $_LANG['HOUR10'], false); ?></option>
<option value="DAY" <?php if(mb_strstr(cmsCore::getArrVal($mod, 'cacheint', 'MINUTES'), 'DAY')) { echo 'selected="selected"'; } ?>><?php echo cmsCore::spellCount(cmsCore::getArrVal($mod, 'cachetime', 0), $_LANG['DAY1'], $_LANG['DAY2'], $_LANG['DAY10'], false); ?></option>
<option value="MONTH" <?php if(mb_strstr(cmsCore::getArrVal($mod, 'cacheint', 'MINUTES'), 'MONTH')) { echo 'selected="selected"'; } ?>><?php echo cmsCore::spellCount(cmsCore::getArrVal($mod, 'cachetime', 0), $_LANG['MONTH1'], $_LANG['MONTH2'], $_LANG['MONTH10'], false); ?></option>
</select>
</td>
</tr>
</table>
<div style="margin-top:15px">
<?php
if ($do == 'edit') {
$cache = cmsCore::c('cache')->get('modules', $mod['id'], $mod['content'], array(cmsCore::getArrVal($mod, 'cachetime', 1), cmsCore::getArrVal($mod, 'cacheint', 'MINUTES')));
if (!empty($cache)){
$kb = round(mb_strlen($cache)/1024, 2);
unset($cache);
echo '<a href="index.php?view=cache&component=modules&target='. $mod['content'] .'&target_id='. $mod['id'] .'">'. $_LANG['AD_MODULE_CACHE_DELETE'] .'</a> ('. $kb . $_LANG['SIZE_KB'] .')';
} else {
echo '<span style="color:gray">'. $_LANG['AD_NO_CACHE'] .'</span>';
}
}
?>
</div>
</div>
</div>
<?php } ?>
<div id="upr_access">
<div class="form-group">
<?php
$groups = cmsUser::getGroups();
$style = 'disabled="disabled"';
$public = 'checked="checked"';
示例8: addPost
public function addPost($post)
{
// Получаем последний пост темы
$last_post = $this->inDB->get_fields('cms_forum_posts', "thread_id = '{$post['thread_id']}'", '*', 'pubdate DESC');
// Если он этого же автора и прошло не более 20 минут, склеиваем, иначе просто добавляем
$minutes_passed = round((time() - strtotime($last_post['pubdate'])) / 60);
if ($last_post['user_id'] == $post['user_id'] && $minutes_passed < 20) {
global $_LANG;
$u_post['content'] = $this->inDB->escape_string($last_post['content'] . "\r\n" . $post['content']);
$u_post['content_html'] = $this->inDB->escape_string($last_post['content_html'] . '<em class="added_later">' . $_LANG['ADDED_LATER'] . ($minutes_passed ? cmsCore::spellCount($minutes_passed, $_LANG['MINUTU1'], $_LANG['MINUTE2'], $_LANG['MINUTE10']) : $_LANG['FEW_SECONDS']) . '</em>' . $post['content_html']);
$this->updatePost($u_post, $last_post['id']);
return $last_post['id'];
}
$post_id = $this->inDB->insert('cms_forum_posts', cmsCore::callEvent('ADD_FORUM_POST', $post));
// регистрируем загруженные изображения
cmsCore::setIdUploadImage('post', $post_id);
return $post_id;
}
示例9: parseHide
private function parseHide($text, $hidden = false)
{
$inUser = cmsUser::getInstance();
global $_LANG;
$pattern = '/\\[hide(?:=?)([0-9]*)\\](.*?)\\[\\/hide\\]/sui';
preg_match($pattern, $text, $matches);
if (!$matches) {
return $text;
}
if ($hidden) {
$replacement = '';
} else {
if (!$inUser->id) {
$replacement = '<div class="bb_tag_hide">' . $_LANG['P_HIDE_TEXT'] . '</div>';
} else {
if (!$matches[1]) {
$replacement = '<div class="bb_tag_hide">${2}</div>';
} elseif ($inUser->rating > $matches[1] || $inUser->is_admin) {
$replacement = '<div class="bb_tag_hide">${2}</div>';
} else {
$replacement = '<div class="bb_tag_hide">' . sprintf($_LANG['P_HIDE_TEXT_RATING'], cmsCore::spellCount($matches[1], $_LANG['P_ITEM1'], $_LANG['P_ITEM2'], $_LANG['P_ITEM10'])) . '</div>';
}
}
}
return preg_replace($pattern, $replacement, $text);
}
示例10: forum
//.........这里部分代码省略.........
$inPage->setDescription(crop($first_post_content));
} else {
$inPage->setDescription($thread['title']);
}
} else {
$inPage->setDescription(crop($thread['description']));
}
// meta keywords
$all_post_content = '';
foreach ($posts as $p) {
$all_post_content .= ' ' . strip_tags($p['content_html']);
}
$meta_keys = cmsCore::getKeywords($all_post_content);
$inPage->setKeywords($meta_keys ? $meta_keys : $thread['title']);
cmsCore::initAutoGrowText('#message');
cmsPage::initTemplate('components', 'com_forum_view_thread')->assign('forum', $pcat)->assign('forums', $model->getForums())->assign('is_subscribed', cmsUser::isSubscribed($inUser->id, 'forum', $thread['id']))->assign('thread', $thread)->assign('prev_thread', $inDB->get_fields('cms_forum_threads', "id < '{$thread['id']}' AND forum_id = '{$thread['forum_id']}'", 'id, title', 'id DESC'))->assign('next_thread', $inDB->get_fields('cms_forum_threads', "id > '{$thread['id']}' AND forum_id = '{$thread['forum_id']}'", 'id, title', 'id ASC'))->assign('posts', $posts)->assign('thread_poll', $model->getThreadPoll($thread['id']))->assign('page', $page)->assign('num', ($page - 1) * $model->config['pp_thread'] + 1)->assign('lastpage', ceil($thread['post_count'] / $model->config['pp_thread']))->assign('pagebar', cmsPage::getPagebar($thread['post_count'], $page, $model->config['pp_thread'], '/forum/thread' . $thread['id'] . '-%page%.html'))->assign('user_id', $inUser->id)->assign('do', $do)->assign('is_moder', $is_forum_moder)->assign('is_admin', $inUser->is_admin)->assign('is_can_add_post', cmsUser::isUserCan('forum/add_post'))->assign('cfg', $model->config)->assign('bb_toolbar', $inUser->id && $model->config['fast_on'] && $model->config['fast_bb'] ? cmsPage::getBBCodeToolbar('message', $model->config['img_on']) : '')->assign('smilies', $inUser->id && $model->config['fast_on'] && $model->config['fast_bb'] ? cmsPage::getSmilesPanel('message') : '')->display('com_forum_view_thread.tpl');
}
//============================================================================//
//================ Новая тема, написать/редактировать пост ===================//
//============================================================================//
if (in_array($do, array('newthread', 'newpost', 'editpost'))) {
if (!$inUser->id) {
cmsUser::goToLogin();
}
// id первого поста в теме
$first_post_id = false;
// опросов по умолчанию нет
$thread_poll = array();
// применяется при редактировании поста
$is_allow_attach = true;
// ограничение по карме
if (in_array($do, array('newthread', 'newpost'))) {
if ($inUser->karma < $model->config['min_karma_add'] && !$inUser->is_admin) {
cmsCore::addSessionMessage(sprintf($_LANG['ADD_KARMA_LIMIT'], cmsCore::spellCount($model->config['min_karma_add'], $_LANG['KPOINT1'], $_LANG['KPOINT2'], $_LANG['KPOINT10']), $inUser->karma), 'error');
cmsCore::redirectBack();
}
}
// новая тема
if ($do == 'newthread') {
// права доступа
if (!cmsUser::isUserCan('forum/add_thread') && !$inUser->is_admin) {
cmsPage::includeTemplateFile('special/accessdenied.php');
return;
}
$forum = $model->getForum($id);
if (!$forum) {
cmsCore::error404();
}
if (!cmsCore::checkContentAccess($forum['access_list'])) {
cmsPage::includeTemplateFile('special/accessdenied.php');
return;
}
$path_list = $inDB->getNsCategoryPath('cms_forums', $forum['NSLeft'], $forum['NSRight'], 'id, title, access_list, moder_list');
if ($path_list) {
foreach ($path_list as $pcat) {
if (!cmsCore::checkContentAccess($pcat['access_list'])) {
cmsPage::includeTemplateFile('special/accessdenied.php');
return;
}
$inPage->addPathway($pcat['title'], '/forum/' . $pcat['id']);
}
$is_forum_moder = $model->isForumModerator($pcat['moder_list']);
}
if (IS_BILLING && $forum['topic_cost']) {
cmsBilling::checkBalance('forum', 'add_thread', false, $forum['topic_cost']);
}
示例11: getFileValue
private function getFileValue($form_field)
{
$link = '';
if (array_key_exists($form_field['id'], $this->values)) {
$field_value = $this->values[$form_field['id']];
global $_LANG;
if (is_file(PATH . $field_value['url'])) {
$downloaded = cmsCore::fileDownloadCount($field_value['url']);
$filesize = round(filesize(PATH . $field_value['url']) / 1024, 2);
$link = '<span class="filelink">';
$link .= '<a href="/load/url=-' . base64_encode($field_value['url']) . '" alt="' . $_LANG['FILE_DOWNLOAD'] . '">' . $field_value['name'] . '</a> ';
$link .= '<span>| ' . $filesize . ' ' . $_LANG['SIZE_KB'] . '</span> ';
$link .= '<span>| ' . $_LANG['FILE_DOWNLOADED'] . ': ' . cmsCore::spellCount($downloaded, $_LANG['TIME1'], $_LANG['TIME2'], $_LANG['TIME1']) . '</span>';
$link .= '</span>';
}
}
return $link;
}
示例12:
<option value="DAY" <?php
if (mb_strstr(cmsCore::getArrVal($mod, 'cacheint', 'MINUTES'), 'DAY')) {
echo 'selected="selected"';
}
?>
><?php
echo cmsCore::spellCount(cmsCore::getArrVal($mod, 'cachetime', 0), $_LANG['DAY1'], $_LANG['DAY2'], $_LANG['DAY10'], false);
?>
</option>
<option value="MONTH" <?php
if (mb_strstr(cmsCore::getArrVal($mod, 'cacheint', 'MINUTES'), 'MONTH')) {
echo 'selected="selected"';
}
?>
><?php
echo cmsCore::spellCount(cmsCore::getArrVal($mod, 'cachetime', 0), $_LANG['MONTH1'], $_LANG['MONTH2'], $_LANG['MONTH10'], false);
?>
</option>
</select>
</td>
</tr>
</table>
<div style="margin-top:15px">
<?php
if ($do == 'edit') {
if (!empty($kb_cache)) {
echo '<a href="index.php?view=cache&component=modules&target=' . $mod['content'] . '&target_id=' . $mod['id'] . '">' . $_LANG['AD_MODULE_CACHE_DELETE'] . '</a> (' . $kb_cache . $_LANG['SIZE_KB'] . ')';
} else {
echo '<span style="color:gray">' . $_LANG['AD_NO_CACHE'] . '</span>';
}
}
示例13: pogoda
function pogoda()
{
$inCore = cmsCore::getInstance();
$inPage = cmsPage::getInstance();
$inDB = cmsDatabase::getInstance();
$inCore->loadModel('pogoda');
$model = new cms_model_pogoda();
//Загрузка настроек компонента
$cfg = $inCore->loadComponentConfig('pogoda');
$cfg["name_en"] = $cfg["name_en"] ? $cfg["name_en"] . '_' : '';
// Проверяем включен ли компонент и установлен ли city_id
if (!$cfg['component_enabled'] || !$cfg['city_id']) {
cmsCore::error404();
}
//Получаем входные параметры
$do = $inCore->request('do', 'str', 'current');
$days = $inCore->request('days', 'int', 1);
$model->setTable($do);
$dbWeather = $model->getWeather();
$xml = simplexml_load_string($dbWeather["xml"]);
$props = $model->getPagesProps($days);
$props = $props[$days];
$title = $props['title'] ? $props['title'] : 'Прогноз погоды на ' . cmsCore::spellCount($days, 'день', 'дня', 'дней');
if (!$props['title'] && $days == 1) {
$title = 'Текущая погода';
}
$inPage->setTitle($title);
$keys = $props['meta_keys'] ? $props['meta_keys'] : 'прогноз, погода, ' . cmsCore::spellCount($days, 'день', 'дня', 'дней');
$inPage->setKeywords($keys);
$desc = $props['meta_desc'] ? $props['meta_desc'] : 'Прогноз погоды в ' . $cfg["name_ru"] . ' на ' . cmsCore::spellCount($days, 'день', 'дня', 'дней');
$inPage->setDescription($desc);
if ($days == 1) {
$inPage->addPathway('Текущая погода', '/pogoda/');
} else {
$inPage->addPathway('Погода', '/pogoda/');
$inPage->addPathway('Прогноз погоды на ' . cmsCore::spellCount($days, 'день', 'дня', 'дней'));
}
//======================================== CURRENT WEATHER ====================================================//
if ($do == 'current') {
$current = array();
$current["temperature"] = round($xml->temperature["value"]) . ' °C';
$current["humidity"] = $xml->humidity["value"] . ' ' . $xml->humidity["unit"];
$current["pressure"] = round($xml->pressure["value"] * 0.7500637554192) . ' мм. рт. ст.';
$current["wind"]["speed"] = $xml->wind->speed["value"] . ' м\\с';
$current["wind"]["direction"] = directToRus($xml->wind->direction["code"]);
$current["clouds"] = cloudsToRus($xml->clouds["name"]);
$current["precipitation"] = precipitationToRus($xml->precipitation["mode"]) . ' ' . ($xml->precipitation["value"] ? round((double) $xml->precipitation["value"], 1) . ' мм' : '');
$current["weather"]["value"] = $xml->weather["value"];
$current["weather"]["icon"] = $xml->weather["icon"];
$current["lastupdate"] = date('d.m.y H:i', strtotime($xml->lastupdate["value"]) + $cfg["utc_diff"] * 3600);
cmsPage::initTemplate('components', 'com_pogoda_current')->assign('current', $current)->assign('cfg', $cfg)->assign('props', $props)->display('com_pogoda_current.tpl');
}
//======================================== FORECAST 3,5 DAYS ==================================================//
if ($do == '5_days') {
$forecast = array();
foreach ($xml->forecast->time as $v) {
$to = explode('T', $v["to"]);
$from = explode('T', $v["from"]);
$to_utime = strtotime($to[0] . ' ' . $to[1]) + $cfg["utc_diff"] * 3600;
$from_utime = strtotime($from[0] . ' ' . $from[1]) + $cfg["utc_diff"] * 3600;
if ($to_utime < time()) {
continue;
}
if ($from_utime > strtotime(date('d-m-Y')) + $days * 24 * 3600) {
continue;
}
$to[0] = date('d.m.Y', $to_utime);
$to[1] = date('H:i', $to_utime);
$from[0] = date('d.m.Y', $from_utime);
$from[1] = date('H:i', $from_utime);
$forecast[$from[0]][$from[1]]["temperature"] = round($v->temperature["value"]) . ' °C';
$forecast[$from[0]][$from[1]]["humidity"] = $v->humidity["value"] . ' ' . $v->humidity["unit"];
$forecast[$from[0]][$from[1]]["pressure"] = round($v->pressure["value"] * 0.7500637554192) . ' мм. рт. ст.';
$forecast[$from[0]][$from[1]]["wind"]["speed"] = $v->windSpeed["mps"] . ' м\\с';
$forecast[$from[0]][$from[1]]["wind"]["direction"] = directToRus($v->windDirection["code"]);
$forecast[$from[0]][$from[1]]["clouds"] = cloudsToRus($v->clouds["value"]);
$forecast[$from[0]][$from[1]]["precipitation"] = precipitationToRus($v->precipitation["type"]) . ' ' . ($v->precipitation["value"] ? round((double) $v->precipitation["value"], 1) . ' мм' : '');
$forecast[$from[0]][$from[1]]["weather"]["value"] = (string) $v->symbol["name"];
$forecast[$from[0]][$from[1]]["weather"]["icon"] = (string) $v->symbol["var"];
}
$counts = $fdates = array();
foreach ($forecast as $k => $v) {
$counts[$k] = count($v);
$fdates[$k] = getRusDate(date("j F, D", strtotime($k)));
}
$counts['days'] = count($forecast);
cmsPage::initTemplate('components', 'com_pogoda_5days')->assign('forecast', $forecast)->assign('days', $days)->assign('counts', $counts)->assign('fdates', $fdates)->assign('cfg', $cfg)->assign('props', $props)->display('com_pogoda_5days.tpl');
}
//======================================== FORECAST 7,10,14 DAYS ==================================================//
if ($do == '16_days') {
$forecast = array();
foreach ($xml->forecast->time as $v) {
$date = $v["day"];
if (strtotime($date) < strtotime(date('d-m-Y'))) {
continue;
}
if (strtotime($date) >= strtotime(date('d-m-Y')) + $days * 24 * 3600) {
continue;
}
$forecast["{$date}"]["temperature"]["day"] = round($v->temperature["day"]) . ' °C';
//.........这里部分代码省略.........