From: Steve Sutton Date: Fri, 10 Jul 2015 18:01:53 +0000 (-0400) Subject: updates X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;ds=sidebyside;p=user%2Fsteve%2FToolboxContentMigrator.git updates --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..97c3d3c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +views_c/ diff --git a/fetchImage.php b/fetchImage.php new file mode 100644 index 0000000..d813282 --- /dev/null +++ b/fetchImage.php @@ -0,0 +1,14 @@ +'.print_r($_REQUEST, true).''; +$ch = curl_init(RESIZED . $_REQUEST['img']); +curl_setopt($ch, CURLOPT_TIMEOUT, 50); +curl_setopt($ch, CURLOPT_HEADER, false); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +$data = curl_exec($ch); +$httpCode = curl_getinfo($ch); +curl_close($ch); +$im = new Imagick(); +$im->readImageBlob($data); +header('Content-Type: image/' . $im->getImageFormat()); +echo $im; diff --git a/index.php b/index.php index f3f4133..bfdee36 100644 --- a/index.php +++ b/index.php @@ -3,13 +3,15 @@ ob_start(); require_once '../setup.phtml'; ob_end_clean(); +define('TOOLBOX_IMAGE_URL', SITE_URL . 'uploads/2015/07/'); +require '/var/www/server/CommonApps/Smarty/3.1/Smarty.class.php'; if (!defined('CONN_STR')) { die('There is no define for CONN_STR'); } -echo '
'.print_r(CONN_STR, true).'
'; +//echo '
'.print_r(CONN_STR, true).'
'; if (isset($applicationConfig)) { - echo '
Yes, found $applicationConfig
'; + //echo '
Yes, found $applicationConfig
'; } else { echo '
No, did not find $applicationConfig
'; } @@ -20,6 +22,12 @@ if (!$dbh) { die('Error: no $dbh'); } +$smarty = new Smarty(); +$smarty->setTemplateDir('./views/'); +$smarty->setCompileDir('./views_c/'); +$smarty->setConfigDir('./configs/'); +$smarty->setCacheDir('./cache/'); + $pageSql = " SELECT * FROM pages @@ -31,10 +39,109 @@ $paragraphSql = " WHERE page = :page ORDER BY pos"; $paraStmt = $dbh->prepare($paragraphSql); +function displayImage($data, $alignment) +{ + if ($data['caption']) { + $content .= '[caption id="attachment_'.$data['id'].'" align="align'.$alignment.'"]' + .' ' + . $data['caption'] . '[/caption]'; + } else { + $content .= ''; + } + return $content; +} +function isMemberOnlyPage($gateway, $pageId) +{ + if (defined('MEMBERS_DB') && MEMBERS_DB) { + return Toolkit_Template_Page::isMemberOnly( + $gateway, $pageId + ); + } + return false; +} foreach ($pageData as &$page) { $paraStmt->bindParam(':page', $page['id'], PDO::PARAM_INT); $paraStmt->execute(); - $page['paragraphs'] = $paraStmt->fetchAll(PDO::FETCH_ASSOC); + $pagegatewayFactory = new Toolkit_Toolbox_PageGatewayPublishFactory($dbh); + $page['ping_name'] = Toolkit_Template_Page::getSeoUrl( + $pagegatewayFactory->createGateway(), + $page['id'] + ); + $paragraphs = $paraStmt->fetchAll(PDO::FETCH_ASSOC); + //$page['paragraphs'] = $paragraphs; + $primaryAlign = 'right'; + $secondaryAlign = 'right'; + $alternateImg = false; + + switch ($page['template']) { + case 1: + break; + case 2: + $primaryAlign = 'left'; + $secondaryAlign = 'left'; + break; + case 3: + $secondaryAlign = 'left'; + $alternateImg = true; + break; + case 4: + $primaryAlign = 'left'; + $alternateImg = true; + break; + case 5: + $primaryAlign = 'left'; + break; + case 6: + $secondaryAlign = 'left'; + break; + } + //$page['paragraphs'] = $paragraphs; + $iterator = 1; + $page['pageContent'] = ''; + foreach ($paragraphs as $paragraph) { + switch ($iterator) { + case 1: + if ($paragraph['title']) { + $page['pageContent'] .= '

'.$paragraph['title'].'

'; + } + if ($paragraph['image']) { + $page['pageContent'] .= displayImage($paragraph, $primaryAlign); + } + break; + case 2: + if ($paragraph['title']) { + $page['pageContent'] .= '

'.$paragraph['title'].'

'; + } + if ($paragraph['image']) { + $page['pageContent'] .= displayImage($paragraph, $secondaryAlign); + } + break; + default: + if ($paragraph['title']) { + $page['pageContent'] .= '

'.$paragraph['title'].'

'; + } + if ($alternateImg && $page['template'] == 3) { + $align = ($iterator%2 == 0) ? 'left' : 'right'; + } else { + $align = $secondaryAlign; + } + if ($paragraph['image']) { + $page['pageContent'] .= displayImage($paragraph, $align); + } + break; + } + $page['pageContent'] .= $paragraph['description']; + ++$iterator; + } + } -echo '
'.print_r($pageData, true).'
'; -echo 'here'; +//echo '
'.print_r($pageData, true).'
'; +//echo 'here'; +header('Content-type: text/xml'); +$smarty->assign('resized', RESIZED); +$smarty->assign('exportTitle', SITENAME); +$smarty->assign('siteUrl', SITE_URL); +$smarty->assign('data', $pageData); +$smarty->display('wordPress.tpl'); diff --git a/views/wordPress.tpl b/views/wordPress.tpl new file mode 100644 index 0000000..c2ad8a8 --- /dev/null +++ b/views/wordPress.tpl @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + {$exportTitle} + http://{$siteUrl} + Just another Gaslight Media Sites site + {$pubDate} + en-US + 1.2 + http://{$siteUrl} + http://{$siteUrl} + + 1Stevesteve@gaslightmedia.com + + + http://wordpress.org/?v=4.1.1 + {foreach $data as $row} + + <![CDATA[{$row.navigation_name}]]> + {$row.ping_name} + {$row.pubDate} + + {$row.ping_name} + + + + {$row.id} + {$row.pr_date} + {$row.pr_date} + closed + open + {$row.ping_name} + publish + {$row.parent} + {$row.pos} + page + + 0 + + + _edit_last + + + + {/foreach} + +