Beispiel #1
0
 public function createContent($pageName, $contentType, $contentItemTitle, $contentItem)
 {
     try {
         $pdo = new DbManager();
         $conn = $pdo->getPdoInstance();
         $result = '';
         $stmt = $conn->prepare('INSERT INTO content(contentId, pageName, contentType, contentItemTitle, contentItem, created) VALUES (DEFAULT, :pagename, :contenttype, :contentitemtitle, :contentitem, curdate())');
         $stmt->bindParam(':pagename', $pageName);
         $stmt->bindParam(':contenttype', $contentType);
         $stmt->bindParam(':contentitemtitle', $contentItemTitle);
         $stmt->bindParam(':contentitem', $contentItem);
         if (!$stmt->execute()) {
             $result .= 'Heuston we have a problem!';
         }
         return $result .= 'Nice. Some new content created';
     } catch (PDOException $e) {
         echo $e->getMessage();
     }
 }
Beispiel #2
0
$config = parse_ini_file(realpath('../config/config.ini'), true);
# get the theme and add it to the twig loaders path.
$myTemplatesPath1 = __DIR__ . '/../themes/' . $config['themes']['theme'] . '/templates';
$myTemplatesPath2 = __DIR__ . '/../templates/admin';
# $loggerPath = dirname(__DIR__).'/logs';
$app = new Silex\Application();
$app['title'] = '';
if (isset($config['title']['title'])) {
    $app['title'] = $config['title']['title'];
}
$app['image'] = '';
if (isset($config['bg-image']['image'])) {
    $app['image'] = '/images/' . $config['bg-image']['image'];
}
# store regularly used variables(services?) in the app container
$dbmanager = new DbManager();
# app['dbh'] is a connection instance and is passed to the constructor
# of the database repository.
$app['dbh'] = $dbmanager->getPdoInstance();
$db = new DbRepository($app['dbh']);
# The $pages variable will be accessible in twig templates as app.pages.
# and will (usually) be an array of page objects
# so you can loop through with a twig for loop.
# e.g {% for page in app.pages %}{{ page.pageName or page.pageTemplate }}
# this will save having to query the database every time you want to access
# the page objects.
$app['pages'] = $db->getAllPages();
$app['images'] = $db->viewImages();
# twig loaders for templates: a database loader for dynamically created templates,
# and a filesystem loader for templates stored on the filesystem.
$app['loader1'] = new Twig_Loader_Filesystem(array($myTemplatesPath1, $myTemplatesPath2));