Skip to content
Browse files

Wijzigingen naar aanleiding van MidvlietTV implementatie

  • Loading branch information...
1 parent 92498f6 commit 760ff20f31af24642fa060c683700a97dceec1ff @skinkie skinkie committed May 21, 2012
Showing with 143 additions and 55 deletions.
  1. +3 −2 broadcast.php
  2. +27 −17 config.php
  3. +4 −3 functions.php
  4. +1 −1 index.php
  5. +4 −1 message.php
  6. +104 −31 template-toevoegen.php
View
5 broadcast.php
@@ -33,7 +33,7 @@
$stmt->execute();
$vandaagresult = $stmt->fetchAll(PDO::FETCH_ASSOC);
- $stmt = $dbh->prepare('SELECT content_text.id, content_text.template, content_text.category, content_category.title, content_text.title, content_text.photo, content_text.content, content_text.duration FROM content_run, content, content_text, content_category, content_category_image WHERE content_run.enabled = 1 AND (content_run.day = 0 or content_run.day = :curday) AND content_run.start <= :start AND content_run.eind >= :end AND content.id = content_run.contentid AND content.id=content_text.contentid AND (content_text.category is NULL OR (content_category.id=content_category_image.categoryid AND content_text.category=content_category_image.id)) AND content_text.template <> \'ng-advertentie.xsl\' AND content_category.title <> \'Vandaag\' AND content_category.title <> \'Colofon\' ORDER BY content_text.id DESC, '.(THEMESEQ ? 'content_category_image.categoryid, ':'').'content_text.id, content.start, content.eind ASC');
+ $stmt = $dbh->prepare('SELECT content_text.id, content_text.template, content_text.category, content_category.title, content_text.title, content_text.photo, content_text.content, content_text.duration FROM content_run, content, content_text, content_category, content_category_image WHERE content_run.enabled = 1 AND (content_run.day = 0 or content_run.day = :curday) AND content_run.start <= :start AND content_run.eind >= :end AND content.id = content_run.contentid AND content.id=content_text.contentid AND (content_text.category is NULL OR (content_category.id=content_category_image.categoryid AND content_text.category=content_category_image.id)) AND content_text.template <> \'ng-advertentie.xsl\' AND content_category.title <> \'Vandaag\' AND content_category.title <> \'Colofon\' ORDER BY '.(THEMESEQ ? 'content_category_image.categoryid, ':'').'content_text.id, content.start, content.eind ASC');
$stmt->bindParam(':curday', $curday, PDO::PARAM_INT);
$stmt->bindParam(':start', $start, PDO::PARAM_INT);
$stmt->bindParam(':end', $end, PDO::PARAM_INT);
@@ -69,8 +69,9 @@
$result = array_merge($vandaagresult, $contentresult, $colofonresult, $adsintro, $adsresult, $adsoutro);
// exec('/usr/bin/sudo -u broadcast sshfs -o nonempty -o allow_other tv@'.REMOTEHOST.':'.REMOTEDIR.' '.BROADCASTDIR);
-
+
$tmpdirectory = CACHEDIR.'/'.date('Y-m-d',$now);
+// $tmpdirectory = CACHEDIR;
if (!file_exists($tmpdirectory)) {
if (!file_exists(CACHEDIR)) mkdir(CACHEDIR);
mkdir($tmpdirectory);
View
44 config.php
@@ -1,26 +1,36 @@
<?php
define ('VERSION', '1.1.0');
- define ('OWNER', 'MidvlietTV');
- define ('ABSOLUTEDIR', '/usr/src/BroadcastAdmin/CMS/Kabelkrantadmin');
- define ('TEMPLATEDIR', ABSOLUTEDIR.'/xsl');
- define ('PREVIEWDIR', ABSOLUTEDIR.'/preview');
- define ('USER_IMAGEDIR', ABSOLUTEDIR.'/fotos');
- define ('BROADCASTDIR', ABSOLUTEDIR.'/broadcast');
- define ('BROADCASTCACHEDIR', ABSOLUTEDIR.'/broadcast/cache');
- define ('CACHEDIR', ABSOLUTEDIR.'/broadcast/cache');
+ define ('OWNER', 'DemoVM');
+ define ('ABSOLUTEDIR', '/usr/src/bca/Kabelkrantadmin');
+ define ('TEMPLATEDIR', '/home/tv/xsl');
+ define ('PREVIEWDIR', '/home/tv/preview');
+ define ('USER_IMAGEDIR', '/home/tv/fotos');
+ define ('BROADCASTDIR', '/home/tv/broadcast');
+ define ('BROADCASTCACHEDIR', '/home/tv/broadcast/cache');
+ define ('CACHEDIR', '/home/tv/broadcast/cache');
define ('DATABASE', 'pgsql:host=localhost;dbname=kka');
define ('DB_USER', 'kka');
- define ('DB_PASSWORD', '1234');
- define ('THEMESEQ', TRUE);
+ define ('DB_PASSWORD', 'kka');
+ define ('THEMESEQ', FALSE);
define ('BUMPDURATION', 10);
- define ('DURATION', 23);
+ define ('DURATION', 27);
define ('REMOTEHOST', '127.0.0.1');
define ('REMOTEDIR', 'broadcast');
-/* define ('RESOLUTIONW', '720');
- define ('RESOLUTIONH', '576');
-*/
- define ('RESOLUTIONW', '1024');
- define ('RESOLUTIONH', '768');
+
+
+# SD 4:3
+# define ('RESOLUTIONW', '720');
+# define ('RESOLUTIONH', '576');
+
+
+# HD Ready
+ define ('RESOLUTIONW', '1280');
+ define ('RESOLUTIONH', '720');
+
+# HD
+# define ('RESOLUTIONW', '1920');
+# define ('RESOLUTIONH', '1080');
+
/* 4:3
define ('PREVIEWRESOLUTIONW', '269');
@@ -36,7 +46,7 @@
define ('WEBRESOLUTIONH', '360');
define ('EMERGENCY', false);
-
+
date_default_timezone_set('Europe/Amsterdam');
setlocale(LC_ALL,'nl_NL');
setlocale(LC_NUMERIC, 'en_US'); /* Make sure this is EN, because of . , in XSLT */
View
7 functions.php
@@ -1,4 +1,5 @@
<?php
+ setlocale(LC_ALL,'nl_NL');
require_once('message.php');
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') === false)
header('Content-type: application/xhtml+xml; charset=utf-8');
@@ -82,7 +83,7 @@ function dirtoselect($name, $dir, $active = '', $empty = false, $maxdate = 0, $e
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
- if ($file[0] != '.' && !is_dir($dir.'/'.$file)) {
+ if (!is_dir($dir.'/'.$file)) {
if ($maxdate == 0 || (filectime($dir.'/'.$file) > $maxdate)) {
if ($extension == '' || (substr( $file, strlen( $file ) - strlen( $extension ) ) === $extension)) {
$templates[]=$file;
@@ -267,7 +268,7 @@ function checkandpreview($safebox=0, $width=RESOLUTIONW, $height=RESOLUTIONH, $f
if ($batch === true) return $filename;
- $debug = shell_exec('/usr/bin/inkscape -z --file='.$svgfile.' --export-width='.$width.' --export-height='.$height.' --export-png='.$file.' 2>&1 1>/dev/null');
+ $debug = shell_exec('/usr/bin/inkscape -d 150 -z --file='.$svgfile.' --export-width='.$width.' --export-height='.$height.' --export-png='.$file.' 2>&1 1>/dev/null');
//echo $debug;
//exit;
@@ -288,7 +289,7 @@ function batchrender($dir, $width, $height, $playlist) {
$svgfile = $dir.'/'.$filename.'.svg';
$file = $dir.'/'.$filename.'.png';
- $cmd .= $svgfile.' --export-width='.$width.' --export-height='.$height.' --export-png='.$file."\n";
+ $cmd .= $svgfile.' --export-width='.$width.' --export-height='.$height.' --export-png='.$file.'\n';
}
$cmd .= 'quit';
shell_exec('echo "'.$cmd.'" | /usr/bin/inkscape --shell 2>&1 1>/dev/null');
View
2 index.php
@@ -58,7 +58,7 @@
$result = $stmt->fetchAll();
?>
- <th class="none"><?php echo OWNER; ?> <a href="toevoegen.php" style="text-align: right;"><?php echo ADD; ?></a><br />
+ <th class="none"><?php echo OWNER; ?> <a href="toevoegen.php" style="text-align: right;"><?php echo ADD; ?></a> <a href="broadcast.php" style="text-align: right;"><?php echo GENERATEANDBROADCAST; ?></a><br />
<?php echo LENGTH; ?>: <?php echo $result[0]['duration']; ?>s
<?php echo '('.(($result[0]['duration']-($result[0]['duration']%60))/60).':'.(($result[0]['duration']%60)<10?'0':'').($result[0]['duration']%60).')'; ?> <a href="overzicht.html"><?php echo NEXTPER; ?></a></th>
<th><?php echo START; ?></th>
View
5 message.php
@@ -13,11 +13,14 @@
define('LASTMOD', 'Laatste wijziging door');
define('VIEW', 'Toon');
define('UNDEFINED', 'undefined');
+define('GENERATEANDBROADCAST', 'Genereren = Kopie&euml;ren');
define('EXAMPLE', 'Voorbeeld');
define('PLAYEDAT', 'Looptijden');
define('ACTION', 'Acties');
+define('TPL_OPEN', 'Open');
+define('TPL_REMOVE', 'Verwijder');
define('ACT_UPD', 'Update');
define('ACT_ADD', 'Toevoegen');
define('ACT_DEL', 'Wissen');
@@ -32,7 +35,7 @@
define('PHOTO', 'Foto');
define('TITLE', 'Titel');
define('TEXT', 'Tekst');
-define('NEWIMAGE', 'Nieuwe Afbeelding');
+define('NEWIMAGE', 'Sjablonen');
define('UPLOAD', 'Upload');
define('ERROR_IN_TEMPLATE', 'XML-fout in document');
View
135 template-toevoegen.php
@@ -3,8 +3,6 @@
require_once('functions.php');
- $_SESSION['newtemplate']['activeid']=0;
-
post2sessionactive('x', 'newtemplate');
post2sessionactive('y', 'newtemplate');
post2sessionactive('h', 'newtemplate');
@@ -13,22 +11,79 @@
post2sessionactive('title', 'newtemplate');
post2sessionactive('category', 'newtemplate');
- if (isset($_POST['action']) && $_POST['action']==ACT_NEW) {
- unset($_SESSION['newtemplate'][0]);
- }
-
+ $dbh = new PDO(DATABASE, DB_USER, DB_PASSWORD);
+ if (!isset($_SESSION['newtemplate']['activeid'])) {
+ $_SESSION['newtemplate']['activeid']=0;
+ }
+
+ if (isset($_POST['action'])) {
+
+ if ($_POST['action']==ACT_NEW) {
+ unset($_SESSION['newtemplate'][0]);
+ $_SESSION['newtemplate']['activeid']=0;
+ }
+ elseif ($_POST['action']==TPL_OPEN) {
+ unset($_SESSION['newtemplate']);
+ $_SESSION['newtemplate']['activeid']=0;
+ $stmt = $dbh->prepare('SELECT categoryid, title, photo, width, height, x, y FROM content_category_image AS cci WHERE cci.id=:categoryimageid');
+ $stmt->bindParam(':categoryimageid', $_POST['activeid'], PDO::PARAM_INT);
+ $stmt->execute();
+ $qresult = $stmt->fetchAll();
+ if (isset($qresult[0])) {
+ $_SESSION['newtemplate'][$_POST['activeid']]['x'] = $qresult[0]['x'];
+ $_SESSION['newtemplate'][$_POST['activeid']]['y'] = $qresult[0]['y'];
+ $_SESSION['newtemplate'][$_POST['activeid']]['h'] = $qresult[0]['height'];
+ $_SESSION['newtemplate'][$_POST['activeid']]['w'] = $qresult[0]['width'];
+ $_SESSION['newtemplate'][$_POST['activeid']]['photo'] = $qresult[0]['photo'];
+ $_SESSION['newtemplate'][$_POST['activeid']]['title'] = $qresult[0]['title'];
+ $_SESSION['newtemplate'][$_POST['activeid']]['category'] = $qresult[0]['categoryid'];
+ $_SESSION['newtemplate']['activeid']=$_POST['activeid'];
+ } else {
+ $_SESSION['newtemplate']['activeid']=0;
+ }
+ }
+ elseif ($_POST['action']==TPL_REMOVE) {
+ $dbh->beginTransaction();
+ $stmt = $dbh->prepare('select min(id) AS min, max(id) AS max from content_category_image where categoryid = :categoryid group by categoryid;');
+ $stmt->bindParam(':categoryid', active('category', 'newtemplate'), PDO::PARAM_INT);
+ $stmt->execute();
+ $qresult = $stmt->fetchAll();
+ if (isset($qresult[0])) {
+ $current = active('category', 'newtemplate');
+ $suggestion = $qresult[0]['min'];
+ if ($suggestion == $current) {
+ $suggestion = $qresult[0]['min'];
+ if ($suggestion == $current) {
+ $suggestion = 1;
+ }
+ }
+
+ $stmt = $dbh->prepare('update content_text set category = :suggestion where category = :categoryid;');
+ $stmt->bindParam(':categoryid', $_SESSION['newtemplate']['activeid'], PDO::PARAM_INT);
+ $stmt->bindParam(':suggestion', $suggestion, PDO::PARAM_INT);
+ $stmt->execute();
+ $stmt = $dbh->prepare('delete from content_category_image where id = :categoryid;');
+ $stmt->bindParam(':categoryid', $_SESSION['newtemplate']['activeid'], PDO::PARAM_INT);
+ $stmt->execute();
+ $dbh->commit();
+ unset($_SESSION['newtemplate'][0]);
+ $_SESSION['newtemplate']['activeid']=0;
+ } else {
+ $dbh->rollback();
+ }
+ $qresult = null;
+ }
+ }
if (!is_numeric(active('x', 'newtemplate'))) paste2sessionactive('x', 'newtemplate', 0);
if (!is_numeric(active('y', 'newtemplate'))) paste2sessionactive('y', 'newtemplate', 0);
- if (!is_numeric(active('h', 'newtemplate'))) paste2sessionactive('h', 'newtemplate', 840);
+ if (!is_numeric(active('h', 'newtemplate'))) paste2sessionactive('h', 'newtemplate', 850);
if (!is_numeric(active('w', 'newtemplate'))) paste2sessionactive('w', 'newtemplate', 1120);
- $dbh = new PDO(DATABASE, DB_USER, DB_PASSWORD);
-
+
if (active('category', 'newtemplate') != '') {
- $param_newtemplate = active('category', 'newtemplate');
$stmt = $dbh->prepare('SELECT title FROM content_category WHERE content_category.id=:contentcategoryid');
- $stmt->bindParam(':contentcategoryid', $param_newtemplate, PDO::PARAM_INT);
+ $stmt->bindParam(':contentcategoryid', active('category', 'newtemplate'), PDO::PARAM_INT);
$stmt->execute();
$qresult = $stmt->fetchAll();
}
@@ -37,7 +92,7 @@
if (isset($qresult[0])) {
- $preview = checkandpreview($safebox=1, $width=PREVIEWRESOLUTIONW, $height=PREVIEWRESOLUTIONH, $format='png',
+ $preview = checkandpreview($safebox=1, $width=269, $height=200, $format='png',
active('title', 'newtemplate'), 'Laten we het eens zonder tekst doen.', '',
'default.xsl', $dir='', $filename=md5('default.xsl'.$qresult[0]['title'].active('title', 'newtemplate').active('photo', 'newtemplate').active('w', 'newtemplate').active('h', 'newtemplate').active('x', 'newtemplate').active('y', 'newtemplate')),
$qresult[0]['title'],
@@ -48,8 +103,14 @@
if (isset($_POST['action'])) {
if ($_POST['action']==ACT_SAVE && active('title', 'newtemplate')!='' && active('photo', 'newtemplate')!='' && active('category', 'newtemplate')!='') {
+
$dbh->beginTransaction();
- $stmt = $dbh->prepare('INSERT INTO content_category_image(categoryid, title, photo, width, height, x, y) VALUES (:categoryid, :title, :photo, :width, :height, :x, :y)');
+ if ($_SESSION['newtemplate']['activeid'] == 0) {
+ $stmt = $dbh->prepare('INSERT INTO content_category_image(categoryid, title, photo, width, height, x, y) VALUES (:categoryid, :title, :photo, :width, :height, :x, :y)');
+ } else {
+ $stmt = $dbh->prepare('UPDATE content_category_image SET categoryid = :categoryid, title = :title, photo = :photo, width = :width, height = :height, x = :x, y = :y WHERE id = :id');
+ $stmt->bindParam(':id', $_SESSION['newtemplate']['activeid'], PDO::PARAM_INT);
+ }
$stmt->bindParam(':categoryid', active('category', 'newtemplate'), PDO::PARAM_INT);
$stmt->bindParam(':title', active('title', 'newtemplate'), PDO::PARAM_STR, 20);
$stmt->bindParam(':photo', active('photo', 'newtemplate'), PDO::PARAM_STR, 100);
@@ -59,9 +120,8 @@
$stmt->bindParam(':y', active('y', 'newtemplate'), PDO::PARAM_INT);
$stmt->execute();
$dbh->commit();
- $dbh = null;
- header('Location: toevoegen.php');
- exit;
+ #header('Location: toevoegen.php');
+ #exit;
}
if ($_POST['action']==ACT_BACK) {
@@ -93,22 +153,33 @@
<form method="post">
<fieldset>
<legend><?php echo NEWTEMP; ?></legend>
+ <fieldset>
+ <legend><?php echo CATEGORY; ?> &amp; <?php echo TEMPLATE; ?></legend>
+ <?php
+ $stmt = $dbh->query('SELECT content_category.id, content_category.title FROM content_category ORDER BY content_category.title');
+ $stmt->execute();
+ $qresult = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ echo dbtoselect('category', $qresult, active('category', 'newtemplate'), true);
+
+ if (active('category', 'newtemplate') > 0) {
+ $stmt = $dbh->prepare('SELECT cci.id, cci.title FROM content_category_image AS cci WHERE cci.categoryid = :categoryid ORDER BY cci.title');
+ $stmt->bindParam(':categoryid', active('category', 'newtemplate'), PDO::PARAM_INT);
+ $stmt->execute();
+ $qresult = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ echo dbtoselect('activeid', $qresult, active('activeid', 'newtemplate'), true);
+ }
+
+ ?>
+ <a href="categorie-toevoegen.php"><?php echo NEWCATEGORY; ?></a>
+ </fieldset>
<fieldset class="buttons">
<legend><?php echo ACTION; ?></legend>
<input type="submit" name="action" value="<?php echo ACT_UPD; ?>" />
- <input type="submit" name="action" value="<?php echo ACT_NEW; ?>" />
+ <input type="submit" name="action" value="<?php echo ACT_NEW; ?>" />
<input type="submit" name="action" value="<?php echo ACT_SAVE; ?>" />
<input type="submit" name="action" value="<?php echo ACT_BACK; ?>" />
- </fieldset>
- <fieldset>
- <legend><?php echo CATEGORY; ?></legend>
- <?php
- $stmt = $dbh->query('SELECT content_category.id, content_category.title FROM content_category ORDER BY content_category.title');
- $stmt->execute();
- $qresult = $stmt->fetchAll(PDO::FETCH_ASSOC);
- echo dbtoselect('category', $qresult, active('category', 'newtemplate'), true);
- ?>
- <a href="categorie-toevoegen.php"><?php echo NEWCATEGORY; ?></a>
+ <input type="submit" name="action" value="<?php echo TPL_OPEN; ?>" />
+ <input type="submit" name="action" style="float: right; background-color: #f00;" value="<?php echo TPL_REMOVE; ?>" />
</fieldset>
<fieldset>
<legend><?php echo TITLE; ?></legend>
@@ -121,10 +192,12 @@
</fieldset>
<fieldset>
<legend><?php echo PARAM; ?></legend>
- <label><?php echo LEFT; ?></label><input type="text" name="x" value="<?php echo active('x', 'newtemplate');?>" maxlength="4" />
- <label><?php echo TOP; ?></label><input type="text" name="y" value="<?php echo active('y', 'newtemplate'); ?>" maxlength="4" />
- <label><?php echo HEIGHT; ?> (840)</label><input type="text" name="h" value="<?php echo active('h', 'newtemplate'); ?>" maxlength="4" />
- <label><?php echo WIDTH; ?> (1120/630)</label><input type="text" name="w" value="<?php echo active('w', 'newtemplate'); ?>" maxlength="4" />
+ <div style="float: left;">
+ <label><?php echo LEFT; ?></label><input type="text" name="x" value="<?php echo active('x', 'newtemplate');?>" maxlength="4" style="width: 7em;" />
+ <label><?php echo TOP; ?></label><input type="text" name="y" value="<?php echo active('y', 'newtemplate'); ?>" maxlength="4" style="width: 7em;" />
+ <label><?php echo HEIGHT; ?> (850)</label><input type="text" name="h" value="<?php echo active('h', 'newtemplate'); ?>" maxlength="4" style="width: 7em;" />
+ <label><?php echo WIDTH; ?> (1120/630)</label><input type="text" name="w" value="<?php echo active('w', 'newtemplate'); ?>" maxlength="4" style="width: 7em;" />
+ </div>
<img alt="<?php echo EXAMPLE; ?>" src="preview/<?php echo $preview; ?>.png" style="float: left; border: solid 1px #000; margin-left: 2px; margin-top: 1px;"/>
</fieldset>
</fieldset>

0 comments on commit 760ff20

Please sign in to comment.
Something went wrong with that request. Please try again.