Ok, hvala svima, mislim da cu se odluciti za Symfony. Dokumentacija je stvarno OK pa pretpostavljam da cu ga najbrze i savladati.
Iskreno se nadam da ce klijent odustati od toga. Jeste, lepo je imati MVC ali nisam siguran da bi mi mnogo znacilo to. Evo, pogledajte strukturu fajlova:
modules direktorijum je nesto slicno action-ima u controller-ima. Evo kako izgleda jedan od njih:
Code:
<?php
require_once ('../adminConfig.php') ;
$action = isset($_GET['action']) ? $_GET['action'] : 'READ_ALL' ;
switch($action):
case 'ADD':
$category = new Category() ;
if (empty($_POST)) {
$smarty->assign('category', $category) ;
$smarty->assign('page', 1) ;
$smarty->display('categoryManager/add.tpl') ;
} else {
$category->fromArray($_POST) ;
if (!$category->isValid()) {
$smarty->assign('category', $category) ;
$smarty->assign('class', $category->getCssErrors());
$smarty->assign('page', 1) ;
$smarty->display('categoryManager/add.tpl') ;
} else {
$category->save() ;
$smarty->assign('page', 2) ;
$smarty->display('categoryManager/add.tpl') ;
}
}
break ;
case 'EDIT':
$category = Category::getById( isset($_GET['id']) ? (int)$_GET['id'] : null ) ;
if (empty($_POST)) {
$smarty->assign('category', $category) ;
$smarty->assign('page', 1) ;
$smarty->display('categoryManager/edit.tpl') ;
} else {
$category->fromArray($_POST) ;
if (!$category->isValid()) {
$smarty->assign('category', $category) ;
$smarty->assign('class', $category->getCssErrors());
$smarty->assign('page', 1) ;
$smarty->display('categoryManager/edit.tpl') ;
} else {
$category->save() ;
$smarty->assign('page', 2) ;
$smarty->display('categoryManager/edit.tpl') ;
}
}
break ;
case 'DELETE':
$category = Category::getById( isset($_GET['id']) ? (int)$_GET['id'] : null ) ;
if (empty($_POST)) { // check if there is name of 'submit' button in $_POST
$smarty->assign('category', $category) ;
$smarty->assign('page', 1) ;
$smarty->display('categoryManager/delete.tpl') ;
} else {
$category->delete() ;
$smarty->assign('page', 2) ;
$smarty->display('categoryManager/delete.tpl') ;
}
break ;
case 'ABANDON_DELETE':
$smarty->assign('page', 3) ;
$smarty->display('categoryManager/delete.tpl') ;
break ;
default:
throw new Exception(HACK_DETECTED, 42) ;
endswitch ;
Znaci modul je samo posrednik izmedju browser-a i metoda klasa. Kod je ultra jednostavan, cak akcije 'add, edit i delete' mogu da se lako spoje. Sta dobijam ako koristim neki FW, osim standardizacije?