예제 #1
0
    $class_params = explode("_", $name);
    require 'component/' . $class_params[0] . '/' . $class_params[1] . '/' . $class_params[0] . '.php';
    return true;
}
spl_autoload_register('autoload');
function class_to_file($class)
{
    //$file = substr($class,2);
    $class = preg_replace('/[A-Z]+/', '_$0$1', $class);
    $class = substr($class, 1);
    $class = strtolower($class);
    return $class;
}
if ($_GET['task'] == 'categories') {
    $ob = new CategoriesController();
    $ob->{$_GET}['action']();
} else {
    if ($_GET['task'] == 'articles') {
        $ob = new ArticlesController();
        $ob->{$_GET}['action']();
    } else {
        if ($_GET['task'] == 'news') {
            $ob = new NewsController();
            $ob->{$_GET}['action']();
        } else {
            //echo '<div>dasdadsa</div>';
            $ob = new ArticlesController();
            $ob->index();
        }
    }
}
예제 #2
0
<?php

if (isset($_POST['submit'])) {
    $new_title = $_POST['title'];
    $new_content = $_POST['content'];
    if ('' !== $new_title && '' !== $new_content) {
        $ctrl = new ArticlesController();
        $ctrl->AddedAction($new_title, $new_content);
        echo "Вы успешно добавили статью";
        echo "Хотите опубликовать <a href='?ctrl=Articles&action=New'>еще одну</a>?";
    } else {
        echo '<p>Вы не заполнили поля заголовка и/или контента.</p>';
    }
} else {
    ?>

<form action="" method="post">
		<label for="title">Заголовок:</label>
		<input type="text" id="title" name="title" value="<?php 
    if (!empty($title)) {
        echo $title;
    }
    ?>
" style="resize: horizontal; width: 200px;"><br>

		<label for="content">Текст статьи:</label>
		<textarea id="content" name="content" cols="100" rows="20" value="<?php 
    if (!empty($content)) {
        echo $content;
    }
    ?>