diff --git a/frm/App.php b/frm/App.php index 30f04c4..d432b04 100644 --- a/frm/App.php +++ b/frm/App.php @@ -22,29 +22,65 @@ class App { error_reporting(E_ALL); $this->user_agent = $_SERVER['HTTP_USER_AGENT']; $this->user_IP = $_SERVER['REMOTE_ADDR']; - $this->setRoute('/^\/$/','Index','index'); + $this->setRoute( '|^/$|', 'Index', 'index' ); } /** - * @return mixed + * Получение useragent пользователя + * + * @return string */ - public function getUseragent() { + public function getUserAgent() { return $this->user_agent; } /** - * @return mixed + * Получение IP пользователя + * + * @return string */ public function getUserIP() { return $this->user_IP; } + /** + * Установка маршрута + * + * @param string $regexp регулярное выражение описывающее путь + * @param string $controller котроллер. + * @param string $action действие. по умолчанию 'index' + */ public function setRoute( $regexp, $controller, $action = 'index') { $this->route_table[] = array($regexp,$controller,$action); } + /** + * Редирект + * + * @param string $url адрес переброса + */ + public function Redirect( $url ) { + header( 'Location: ' . $url ); + exit(0); + } + /** + * Запуск маршрутов + */ public function run(){ - + foreach ( $this->route_table as $route_array ) { + if ( preg_match( $route_array[0], $_SERVER['REQUEST_URI'], $matches ) ) { + $a = $this->config->controller_namespace . $route_array[1] . 'Controller'; + $obj = new $a; + $param_arr = []; + foreach ( $matches as $key => $value ) { + if ( ! is_int( $key ) ) { + $param_arr[] = $value; + } + } + call_user_func_array( [ $obj, $route_array[2] . 'Action' ], $param_arr ); + break; + } + } } } \ No newline at end of file diff --git a/frm/View.php b/frm/View.php index cd7e819..7c8bcc1 100644 --- a/frm/View.php +++ b/frm/View.php @@ -12,10 +12,30 @@ namespace PFRM; class View { public $app; - function __construct() { + private $view_filename; + + public $site_name; + + function __construct( $filename ) { + global $app; + $this->app = $app; + $this->view_filename = $this->app->config->views_dir . $filename . '.php'; + $this->site_name = $this->app->config->site_name; } - public function render( ) { + /** + * Установка HTTP-заголовка + * + * @param string $header http-заголовок + */ + public function setHTTPHeader( $header ) { + header( $header, 1 ); + } + /** + * Запуск php-шаблона + */ + public function render( ) { + require $this->view_filename; } } \ No newline at end of file diff --git a/grunt/css/style.styl b/grunt/css/style.styl index e139bc8..442d85f 100644 --- a/grunt/css/style.styl +++ b/grunt/css/style.styl @@ -3,6 +3,10 @@ /** ptest css */ +body + -ff _ffv + -fs 16 + $link_color = #0063ff $link_color_border = alpha($link_color,.3) $link_hover_color = #ff475d @@ -27,4 +31,25 @@ a .page &__container - -wmax 800 \ No newline at end of file + -wmax 800 + -m 0 auto + +.header + -p 30 + -bg #ffcc56 + -bg -moz-repeating-linear-gradient(178deg, rgba(255,204,86,.5) 8px, rgba(255,140,0,.5) 18px); + -bg -webkit-repeating-linear-gradient(178deg, rgba(255,204,86,.5) 8px,rgba(255,140,0,.5) 18px); + -bg repeating-linear-gradient(178deg, rgba(255,204,86,.5) 8px,rgba(255,140,0,.5) 18px); + bx-shadow 2px 3px 15px #eb4 inset + b-radius 2 + -mt 30 + -mb 60 + -ta center + + &__title + line-height 1 + -m 0 + -ff _fftnr + -fst italic + -ts 1 1 1 #a76f19 + -fs 52 diff --git a/public/css/style.css b/public/css/style.css index a195944..1c93224 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -1 +1 @@ -html{font-family:sans-serif;line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,footer,header,nav,section{display:block}h1{font-size:2em;margin:.67em 0}figcaption,figure,main{display:block}figure{margin:1em 40px}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent;-webkit-text-decoration-skip:objects}a:active,a:hover{outline-width:0}abbr[title]{border-bottom:none;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}dfn{font-style:italic}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}audio,video{display:inline-block}audio:not([controls]){display:none;height:0}img{border-style:none}svg:not(:root){overflow:hidden}button,input,optgroup,select,textarea{font-family:sans-serif;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}button,html [type="button"],[type="reset"],[type="submit"]{-webkit-appearance:button}button::-moz-focus-inner,[type="button"]::-moz-focus-inner,[type="reset"]::-moz-focus-inner,[type="submit"]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type="button"]:-moz-focusring,[type="reset"]:-moz-focusring,[type="submit"]:-moz-focusring{outline:1px dotted ButtonText}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{display:inline-block;vertical-align:baseline}textarea{overflow:auto}[type="checkbox"],[type="radio"]{box-sizing:border-box;padding:0}[type="number"]::-webkit-inner-spin-button,[type="number"]::-webkit-outer-spin-button{height:auto}[type="search"]{-webkit-appearance:textfield;outline-offset:-2px}[type="search"]::-webkit-search-cancel-button,[type="search"]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details,menu{display:block}summary{display:list-item}canvas{display:inline-block}template,[hidden]{display:none}a{color:#0063ff;text-decoration:none;border-bottom:1px solid rgba(0,99,255,.3)}a:visited{color:#cf00cf;border-bottom-color:rgba(207,0,207,.3)}a:hover,a:visited:hover{color:#ff475d;border-bottom-color:rgba(255,71,93,.24)}.page__container{max-width:800px} \ No newline at end of file +html{font-family:sans-serif;line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,footer,header,nav,section{display:block}h1{font-size:2em;margin:.67em 0}figcaption,figure,main{display:block}figure{margin:1em 40px}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent;-webkit-text-decoration-skip:objects}a:active,a:hover{outline-width:0}abbr[title]{border-bottom:none;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}dfn{font-style:italic}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}audio,video{display:inline-block}audio:not([controls]){display:none;height:0}img{border-style:none}svg:not(:root){overflow:hidden}button,input,optgroup,select,textarea{font-family:sans-serif;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}button,html [type="button"],[type="reset"],[type="submit"]{-webkit-appearance:button}button::-moz-focus-inner,[type="button"]::-moz-focus-inner,[type="reset"]::-moz-focus-inner,[type="submit"]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type="button"]:-moz-focusring,[type="reset"]:-moz-focusring,[type="submit"]:-moz-focusring{outline:1px dotted ButtonText}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{display:inline-block;vertical-align:baseline}textarea{overflow:auto}[type="checkbox"],[type="radio"]{box-sizing:border-box;padding:0}[type="number"]::-webkit-inner-spin-button,[type="number"]::-webkit-outer-spin-button{height:auto}[type="search"]{-webkit-appearance:textfield;outline-offset:-2px}[type="search"]::-webkit-search-cancel-button,[type="search"]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details,menu{display:block}summary{display:list-item}canvas{display:inline-block}template,[hidden]{display:none}body{font-family:Verdana,"Geneva CY","DejaVu Sans",sans-serif;font-size:16px}a{color:#0063ff;text-decoration:none;border-bottom:1px solid rgba(0,99,255,.3)}a:visited{color:#cf00cf;border-bottom-color:rgba(207,0,207,.3)}a:hover,a:visited:hover{color:#ff475d;border-bottom-color:rgba(255,71,93,.24)}.page__container{max-width:800px;margin:0 auto}.header{padding:30px;background:#ffcc56;background:-moz-repeating-linear-gradient(178deg,rgba(255,204,86,.5)8px,rgba(255,140,0,.5)18px);background:-webkit-repeating-linear-gradient(178deg,rgba(255,204,86,.5)8px,rgba(255,140,0,.5)18px);background:repeating-linear-gradient(178deg,rgba(255,204,86,.5)8px,rgba(255,140,0,.5)18px);-moz-box-shadow:2px 3px 15px #eb4 inset;-webkit-box-shadow:2px 3px 15px #eb4 inset;box-shadow:2px 3px 15px #eb4 inset;-webkit-border-radius:2px;-moz-border-radius:2px;-o-border-radius:2px;-ms-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;margin-top:30px;margin-bottom:60px;text-align:center}.header__title{line-height:1;margin:0;font-family:"Times New Roman","Times CY","Nimbus Roman No9 L",serif;font-style:italic;text-shadow:1px 1px 1px #a76f19;font-size:52px} \ No newline at end of file diff --git a/public/css/style.raw.css b/public/css/style.raw.css index 0f4191f..cca0b9a 100644 --- a/public/css/style.raw.css +++ b/public/css/style.raw.css @@ -196,6 +196,10 @@ template { display: none; } /** ptest css */ +body { + font-family: Verdana, "Geneva CY", "DejaVu Sans", sans-serif; + font-size: 16px; +} a { color: #0063ff; text-decoration: none; @@ -212,4 +216,32 @@ a:visited:hover { } .page__container { max-width: 800px; + margin: 0 auto; +} +.header { + padding: 30px; + background: #ffcc56; + background: -moz-repeating-linear-gradient(178deg, rgba(255,204,86,0.5) 8px, rgba(255,140,0,0.5) 18px); + background: -webkit-repeating-linear-gradient(178deg, rgba(255,204,86,0.5) 8px, rgba(255,140,0,0.5) 18px); + background: repeating-linear-gradient(178deg, rgba(255,204,86,0.5) 8px, rgba(255,140,0,0.5) 18px); + -moz-box-shadow: 2px 3px 15px #eb4 inset; + -webkit-box-shadow: 2px 3px 15px #eb4 inset; + box-shadow: 2px 3px 15px #eb4 inset; + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + -o-border-radius: 2px; + -ms-border-radius: 2px; + -khtml-border-radius: 2px; + border-radius: 2px; + margin-top: 30px; + margin-bottom: 60px; + text-align: center; +} +.header__title { + line-height: 1; + margin: 0; + font-family: "Times New Roman", "Times CY", "Nimbus Roman No9 L", serif; + font-style: italic; + text-shadow: 1px 1px 1px #a76f19; + font-size: 52px; } diff --git a/src/C/CAPTCHAController.php b/src/C/CAPTCHAController.php index ce8e547..d091678 100644 --- a/src/C/CAPTCHAController.php +++ b/src/C/CAPTCHAController.php @@ -6,10 +6,10 @@ * Time: 00:18 */ -namespace PTEST\Controller; +namespace PTEST\C; -class CAPTCHA { +class CAPTCHAController { public function indexAction() { diff --git a/src/C/IndexController.php b/src/C/IndexController.php index 0e1ae1c..f16e3f1 100644 --- a/src/C/IndexController.php +++ b/src/C/IndexController.php @@ -6,15 +6,21 @@ * Time: 00:16 */ -namespace PTEST\Controller; +namespace PTEST\C; use PFRM\Controller; +use PFRM\View as View; -class Index extends Controller { +class IndexController extends Controller { public function indexAction() { - print "index action"; + $view = new View('index'); + $view->page_title = "Доска объявлений"; + $view->render(); } + public function pageAction( $numder ) { + print "number = ".$numder; + } } \ No newline at end of file diff --git a/src/C/error404Controller.php b/src/C/error404Controller.php new file mode 100644 index 0000000..6007882 --- /dev/null +++ b/src/C/error404Controller.php @@ -0,0 +1,21 @@ +setHTTPHeader('HTTP/1.0 404 Not Found'); + $view->render(); + } + +} \ No newline at end of file diff --git a/src/M/AdModel.php b/src/M/AdModel.php index b4557e6..b2503b5 100644 --- a/src/M/AdModel.php +++ b/src/M/AdModel.php @@ -9,7 +9,7 @@ namespace PTEST\Model; -class Ad { +class AdModel { protected $id; diff --git a/src/V/404.php b/src/V/404.php new file mode 100644 index 0000000..d57d260 --- /dev/null +++ b/src/V/404.php @@ -0,0 +1,6 @@ +page_title = "Ошибка: 404 Страница не найдена"; + +require __DIR__ . '/inc/head.php'; +require __DIR__ . '/inc/body.php'; \ No newline at end of file diff --git a/src/V/inc/body.php b/src/V/inc/body.php new file mode 100644 index 0000000..387d480 --- /dev/null +++ b/src/V/inc/body.php @@ -0,0 +1,14 @@ +
+