Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/classes/modules/topic/Topic.class.php on line 481

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/classes/modules/topic/Topic.class.php on line 481

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/classes/modules/topic/Topic.class.php on line 368

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/classes/modules/topic/Topic.class.php on line 368

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/classes/actions/ActionBlog.class.php on line 817

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/classes/actions/ActionBlog.class.php on line 817
Демка Publicate. Ч I / Qb / pyhapyha.ru - социальная сеть сайта pyha.ru

Qb →  Демка Publicate. Ч I

Написал простую демку для испытания каркаса. Лежит в репозитории trunc/demos/publicate/



Всё, что делает — по шаблону мастрячит странички из mardown-файлов.

Дема демонстрирует:
— работу роутера (проекция шаблона URL на Controller-Action)
— автозагрузку системных классов (Qb*) и классов приложения (все прочие)
— разделение
— использование преднастроенных компонент ( qb::get('parser') )
— написание страничек в Markdown
— наипростейший шаблонизатор

Проверяю для себя правильность описания интерфейсов IQbView, IQbRouter, IQbController

Как выглядит контроллер: два экшена — index() для оглавления и view() для всех прочих. Никакого редактирования/добавления ПОКА не заложено:

<?php

class DocsController extends QbCustomComponent implements IQbController
{
	public function defaultAction($vars)
	{
		Qb::end('Docs: Invalid action');
	}

	public function index($vars)
	{
		$docList = DocsModel::byName('index');

		$view = new DocsView;
		$view->renderDocument(array('body'=>$docList, 'navi'=>$docList, 'pageTitle'=>'Index'));
	}

	public function view($vars)
	{
		$name = $vars['docname'];

		if (is_null($doc = DocsModel::byName($name))) {
			Qb::end('Docs: "' . $name . '" not found');
		}
		$docList = DocsModel::byName('index');

		$view = new DocsView;
		$view->renderDocument(array('body'=>$doc, 'navi'=>$docList, 'pageTitle'=>$name));
	}
}


Представление «документ»:

<?php

class DocsView extends QbSimpleView
{

	public function renderDocument($data)
	{
		$parser = Qb::get('parser');

		$data['body'] = $parser->transform($data['body']);
		$data['navi'] = $parser->transform($data['navi']);
		$data['baseUrl'] = Qb::get('baseUrl');

		header('Content-type: text/html; charset=utf-8');
		$this->render('default', $data);
	}
}


DocsView наследует от QbSimpleView — простейший класс-шаблонизатор:

<?php

class QbSimpleView implements IQbView
{
	public function render($viewId, $viewData)
	{
		extract($viewData);
		require Qb::$appDir.'templates/'.$viewId.'.tpl.php';
	}

	public function fetch($viewId, $viewData)
	{
		extract($viewData);
		ob_start();
		//ob_implicit_flush(FALSE);
		require Qb::$appDir.'templates/'.$viewId.'.tpl.php';
		return ob_get_clean();
	}
}


Модель умеет только получать markdown-файл по его имени:

<?php

class DocsModel
{
	public static function byName($name)
	{
		$file = Qb::$appDir . 'data/docs/' . $name . '.markdown';
		if (file_exists($file)) {
			return file_get_contents($file);
		} else {
			return NULL;
		}
	}
}


Все не просто, а очень просто.

  • Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/templates/compiled/%%27^27A^27A2FB40%%topic.tpl.php on line 130

    Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/templates/compiled/%%27^27A^27A2FB40%%topic.tpl.php on line 130
    0

  • Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/include/function.php on line 326

    Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/include/function.php on line 326

    Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/include/function.php on line 329

    Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/include/function.php on line 329

    Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/include/function.php on line 334

    Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Moscow' for 'MSK/4,0/no DST' instead in /home/pyha/pyhapyha.ru/include/function.php on line 334
    20 марта 2010, 09:30
  • artoodetoo

Комментарии (0)

RSS свернуть / развернуть

Только зарегистрированные и авторизованные пользователи могут оставлять комментарии.