У меня такая проблема... Делаю сайт на основе уроков по MVC от IRBIS-team.
Там есть модуль вывода даты. Вот оригинальный вид: (на сайте)
default.php
Свернутый текст
<?php
/**
* Функция перевода даты из азиатского формата в прописной
* Translation function of date from the Asian format in the string
* @param string $date, boolean $format
* @return string
*/
function formatDate($date, $format = true)
{
global $month;
$day = substr($date, 8, 2);
$mnt = $month[substr($date, 5, 2)];
$year = substr($date, 0, 4);
$time = '';
if($format)
$time = ' '. substr($date, 11);
return $day .' '. $mnt .' '. $year . $time;
}
view.php
Свернутый текст
<?php
/**
* Date formatting
* Форматирование даты
*/
$date = formatDate(date("Y-m-d"), false);
index.php
Свернутый текст
<?php
/**
* The main router
* Главный маршрутизатор (роутер)
* @author IT studio IRBIS-team
* @copyright © 2009 IRBIS-team
*/
/////////////////////////////////////////////////////////
/**
* We establish the charset and level of errors
* Устанавливаем кодировку и уровень ошибок
*/
header("Content-Type: text/html; charset=utf-8");
error_reporting(E_ALL);
/**
* Debug
* Дебаггер
* @TODO To clean in release
*/
define('IRB_TRACE', true);
include './debug.php';
/**
* We connect a configuration file
* Подключаем конфигурационный файл
*/
include './config.php';
/**
* We connect a file of the language
* Подключаем языковой файл
*/
include './language/'. IRB_LANGUAGE .'.php';
/**
* Получаем файл переменных
* Receive a variables file
*/
include './variables.php';
/**
* We connect a file of the general functions
* Подключаем файл общих функций
*/
include './libs/default.php';
/**
* We put in order a conclusion
* Приводим в порядок вывод
*/
include './libs/view.php';
ob_start();
/**
* Подключаем меню
* Includes the menu
*/
include './skins/tpl/menu.tpl';
/**
* The switch of modules
* Переключатель страниц
*/
switch($page)
{
/**
* Подключаем модуль приветствия
* Includes the greeting module
*/
case 'main':
include './modules/main/router.php';
break;
/**
* Подключаем модуль второй страницы
* Includes the module of the second page
*/
case 'second':
include './modules/second/router.php';
break;
/**
* Подключаем модуль приветствия по умолчанию
* Includes the greeting module
*/
default:
include './modules/main/router.php';
break;
}
$content = ob_get_contents();
ob_end_clean();
/**
* Подключаем главный шаблон
* Includes a template
*/
include './skins/tpl/index.tpl';
Я попытался сделать так, что при изменении языка сайта с русского на английский выводилась дата в американском формате. Вот что у меня поулчилось:
./libs/en/read_controller.php
Свернутый текст
<?php
/**
* Американский формат даты
* The American format of date
*/
$date = date("l, F y, Y");
./libs/en/view.php
Свернутый текст
<?php
/**
* Американский формат даты
* The American format of date
*/
$date = date("l, F y, Y");
[more]
./libs/ru/read_controller.php
[more]
<?php
/**
* Функция перевода даты из азиатского формата в прописной
* Translation function of date from the Asian format in the string
* @param string $date, boolean $format
* @return string
*/
function formatDate($date, $format = true)
{
global $month;
$day = substr($date, 8, 2);
$mnt = $month[substr($date, 5, 2)];
$year = substr($date, 0, 4);
$time = '';
if($format)
$time = ' '. substr($date, 11);
return $day .' '. $mnt .' '. $year . $time;
}
./libs/ru/view.php
Свернутый текст
<?php
/**
* Date formatting
* Форматирование даты
*/
$date = formatDate(date("Y-m-d"), false);
[more]
./libs/router.php
[more]
<?php
/**
* Подключаем контроллер перевода даты в прописной
* Translation function of date in the string
* Includes the controller of the main page
*/
include './libs/ru/read_controller.php';
/**
* Подготовка к выводу
* Preparation for a conclusion
*/
include './libs/ru/view.php';
/**
* Подключаем контроллер перевода даты в aмериканский формат даты
* Translation function of date in the American format
*/
include './libs/en/read_controller.php';
/**
* Подготовка к выводу
* Preparation for a conclusion
*/
include './libs/en/view.php';
/**
* Date formatting
* Форматирование даты
*/
$date = formatDate(date("Y-m-d"), false);
switch(CONTENT_LANGUAGE)
{
case: 'ru':
$DateString = 'Сегодня '. formatDate(date("Y-m-d"), false) .' года.';
break;
case: 'en':
include './modules/en/view.php';
break;
default:
$DateString = 'Сегодня '. formatDate(date("Y-m-d"), false) .' года.';
break;
}
./index.php
Свернутый текст
<?php
/**
* The main router
* Главный маршрутизатор (роутер)
* @author IT studio IRBIS-team
* @copyright © 2009 IRBIS-team
*/
/////////////////////////////////////////////////////////
/**
* We establish the charset and level of errors
* Устанавливаем кодировку и уровень ошибок
*/
header("Content-type: text/html; charset=utf-8");
error_reporting(E_ALL);
/**
* Debug
* Дебаггер
* @TODO To clean in release
define('IRB_TRACE', true);
include './debug.php';
*/
/**
* We connect a configuration file
* Подключаем конфигурационный файл
*/
include './config.php';
/**
* We connect a file of the language
* Подключаем языковой файл
*/
include './language/'. CONTENT_LANGUAGE .'.php';
/**
* Получаем файл переменных
* Receive a variables file
*/
include './variables.php';
/**
* We connect a file of the general functions
* Подключаем файл общих функций
*/
include './libs/view.php';
/**
* Подключаем модуль даты
* Includes the date module
*/
include '/libs/router.php';
ob_start();
/**
* Подключаем меню
* Includes the menu
*/
include './modules/menu.php';
include './skins/tpl/menu.tpl';
$menu = ob_get_contents();
ob_end_clean();
Ob_start();
/**
* The switch of modules
* Переключатель страниц
*/
switch($page)
{
/**
* Подключаем шаблон главной страницы
* Includes a content template of main page
*/
case 'main':
include './modules/main/router.php';
break;
/**
* Подключаем шаблон второй страницы
* Includes a content template of second page
*/
case 'second':
include './modules/second/router.php';
break;
/**
* Подключаем шаблон третей страницы
* Includes a content template of third page
*/
case 'third':
include './modules/third/router.php';
break;
/**
* Подключаем шаблон четвертой страницы
* Includes a content template of fourth page
*/
case 'fourth':
include './modules/fourth/router.php';
break;
/**
* Подключаем шаблон пятой страницы
* Includes a content template of fifth page
*/
case 'fifth':
include './modules/fifth/router.php';;
break;
/**
* Подключаем шаблон шестой страницы
* Includes a content template of sixth page
*/
case 'sixth':
include './modules/sixth/router.php';
break;
/**
* Подключаем шаблон седьмой страницы
* Includes a content template of seventh page
*/
case 'seventh':
include './modules/seventh/router.php';
break;
/**
* Подключаем шаблон восьмой страницы
* Includes a content template of eighth page
*/
case 'eighth':
include './modules/eighth/router.php';
break;
/**
* Подключаем шаблон девятой страницы
* Includes a content template of ninth page
*/
case 'ninth':
include './modules/ninth/router.php';
break;
/**
* Подключаем модуль главной страницы по умолчанию
* Includes a content template of main page
*/
default:
include './modules/main/router.php';
break;
}
$content = ob_get_contents();
ob_end_clean();
/**
* Подключаем шаблон
* Includes a template
*/
include './skins/tpl/index.tpl';
Но PHP ругается на вывод даты. Где-то похоже я намудрил, но где никак не пойму? :unsure:
Спустя 4 минуты, 26 секунд (21.07.2011 - 18:44) DySprozin написал(а):
;;Но PHP ругается на вывод даты.
текст ругани приведи (;
текст ругани приведи (;
Спустя 4 минуты, 20 секунд (21.07.2011 - 18:49) MNO121280 написал(а):
( ! ) Warning: include(./libs/view.php) [function.include]: failed to open stream: No such file or directory in W:\home\irbis027\www\index.php on line 51
( ! ) Warning: include() [function.include]: Failed opening './libs/view.php' for inclusion (include_path='.;/usr/local/php5/PEAR') in W:\home\irbis027\www\index.php on line 51
( ! ) Warning: include(/libs/router.php) [function.include]: failed to open stream: No such file or directory in W:\home\irbis027\www\index.php on line 57
( ! ) Warning: include() [function.include]: Failed opening '/libs/router.php' for inclusion (include_path='.;/usr/local/php5/PEAR') in W:\home\irbis027\www\index.php on line 57
( ! ) Warning: include() [function.include]: Failed opening './libs/view.php' for inclusion (include_path='.;/usr/local/php5/PEAR') in W:\home\irbis027\www\index.php on line 51
( ! ) Warning: include(/libs/router.php) [function.include]: failed to open stream: No such file or directory in W:\home\irbis027\www\index.php on line 57
( ! ) Warning: include() [function.include]: Failed opening '/libs/router.php' for inclusion (include_path='.;/usr/local/php5/PEAR') in W:\home\irbis027\www\index.php on line 57
Спустя 4 минуты, 58 секунд (21.07.2011 - 18:53) DySprozin написал(а):
MNO121280
папка libs лежит там же, где и index.php ? (;
папка libs лежит там же, где и index.php ? (;
Спустя 4 минуты, 31 секунда (21.07.2011 - 18:58) MNO121280 написал(а):
Цитата (DySprozin @ 21.07.2011 - 15:53) |
MNO121280 папка libs лежит там же, где и index.php ? (; |
Да, там же.
Спустя 2 минуты, 15 секунд (21.07.2011 - 19:00) DySprozin написал(а):
MNO121280
попробуй полный путь указать, типа:
include '/home/irbis027/www/libs/view.php';
попробуй полный путь указать, типа:
include '/home/irbis027/www/libs/view.php';
Спустя 16 минут, 53 секунды (21.07.2011 - 19:17) MNO121280 написал(а):
Я забыл поставить точку перед первым слешем в index.php
И еще неправильно написал тут switch:
Но по прежнему не работает. Сегодня некогда, надо идти по делам. Завтра еще раз посмотрю отпишусь. Как заработает плюсик с меня.
/**
* Подключаем модуль даты
* Includes the date module
*/
include '/libs/router.php';
И еще неправильно написал тут switch:
switch(CONTENT_LANGUAGE)
{
case: 'ru':
$DateString = 'Сегодня '. formatDate(date("Y-m-d"), false) .' года.';
break;
case: 'en':
include './modules/en/view.php';
break;
default:
$DateString = 'Сегодня '. formatDate(date("Y-m-d"), false) .' года.';
break;
}
Но по прежнему не работает. Сегодня некогда, надо идти по делам. Завтра еще раз посмотрю отпишусь. Как заработает плюсик с меня.
Спустя 23 часа, 24 минуты, 41 секунда (22.07.2011 - 18:42) MNO121280 написал(а):
На всякий случай добавил в первый пост архив с тем, что получилось. С предупреждениями разобрался, а вот дальше никак. Особенно не дают покоя строчки типа $date = formatDate(date("Y-m-d"), false); Зачем здесь false не понимаю, хотя оспаривать мудрость старших не собираюсь.
В общем так, разобрался. Вот ссылка в на тему, где архив с рабочим вариантом.
Twin огромное спасибо за моральную поддержку. Все можно переходить к изучению Ядра light.
Сылка на тему в архивом работающего сайта.
В общем так, разобрался. Вот ссылка в на тему, где архив с рабочим вариантом.
Twin огромное спасибо за моральную поддержку. Все можно переходить к изучению Ядра light.
Сылка на тему в архивом работающего сайта.