updates master
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 10 Jul 2015 18:01:53 +0000 (14:01 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 10 Jul 2015 18:01:53 +0000 (14:01 -0400)
.gitignore [new file with mode: 0644]
fetchImage.php [new file with mode: 0644]
index.php
views/wordPress.tpl [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..97c3d3c
--- /dev/null
@@ -0,0 +1 @@
+views_c/
diff --git a/fetchImage.php b/fetchImage.php
new file mode 100644 (file)
index 0000000..d813282
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+require_once '../setup.phtml';
+//echo '<pre>'.print_r($_REQUEST, true).'</pre>';
+$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;
index f3f4133..bfdee36 100644 (file)
--- 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 '<pre>'.print_r(CONN_STR, true).'</pre>';
+//echo '<pre>'.print_r(CONN_STR, true).'</pre>';
 if (isset($applicationConfig)) {
-    echo '<pre>Yes, found $applicationConfig</pre>';
+    //echo '<pre>Yes, found $applicationConfig</pre>';
 } else {
     echo '<pre>No, did not find $applicationConfig</pre>';
 }
@@ -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.'"]'
+            .'<img class="align'.$alignment.' size-medium wp-image-'.$data['id'].'" '
+            . ' src="' . TOOLBOX_IMAGE_URL . $data['image'].'"> '
+            . $data['caption'] . '[/caption]';
+    } else {
+        $content .= '<img class="align'.$alignment.' size-medium wp-image-'.$data['id'].'" '
+            . ' src="' . TOOLBOX_IMAGE_URL . $data['image'].'">';
+    }
+    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'] .= '<h1>'.$paragraph['title'].'</h1>';
+            }
+            if ($paragraph['image']) {
+                $page['pageContent'] .= displayImage($paragraph, $primaryAlign);
+            }
+            break;
+        case 2:
+            if ($paragraph['title']) {
+                $page['pageContent'] .= '<h2>'.$paragraph['title'].'</h2>';
+            }
+            if ($paragraph['image']) {
+                $page['pageContent'] .= displayImage($paragraph, $secondaryAlign);
+            }
+            break;
+        default:
+            if ($paragraph['title']) {
+                $page['pageContent'] .= '<h2>'.$paragraph['title'].'</h2>';
+            }
+            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 '<pre>'.print_r($pageData, true).'</pre>';
-echo 'here';
+//echo '<pre>'.print_r($pageData, true).'</pre>';
+//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 (file)
index 0000000..c2ad8a8
--- /dev/null
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
+<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
+<!-- You may use this file to transfer that content from one site to another. -->
+<!-- This file is not intended to serve as a complete backup of your site. -->
+
+<!-- To import this information into a WordPress site follow these steps: -->
+<!-- 1. Log in to that site as an administrator. -->
+<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
+<!-- 3. Install the "WordPress" importer from the list. -->
+<!-- 4. Activate & Run Importer. -->
+<!-- 5. Upload this file using the form provided on that page. -->
+<!-- 6. You will first be asked to map the authors in this export file to users -->
+<!--    on the site. For each author, you may choose to map to an -->
+<!--    existing user on the site or to create a new user. -->
+<!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->
+<!--    contained in this file into your site. -->
+
+<!-- generator="WordPress/4.1.1" created="2015-03-10 16:34" -->
+<rss version="2.0"
+    xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"
+    xmlns:content="http://purl.org/rss/1.0/modules/content/"
+    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
+    xmlns:dc="http://purl.org/dc/elements/1.1/"
+    xmlns:wp="http://wordpress.org/export/1.2/"
+>
+
+<channel>
+    <title>{$exportTitle}</title>
+    <link>http://{$siteUrl}</link>
+    <description>Just another Gaslight Media Sites site</description>
+    <pubDate>{$pubDate}</pubDate>
+    <language>en-US</language>
+    <wp:wxr_version>1.2</wp:wxr_version>
+    <wp:base_site_url>http://{$siteUrl}</wp:base_site_url>
+    <wp:base_blog_url>http://{$siteUrl}</wp:base_blog_url>
+
+    <wp:author><wp:author_id>1</wp:author_id><wp:author_login>Steve</wp:author_login><wp:author_email>steve@gaslightmedia.com</wp:author_email><wp:author_display_name><![CDATA[Steve]]></wp:author_display_name><wp:author_first_name><![CDATA[]]></wp:author_first_name><wp:author_last_name><![CDATA[]]></wp:author_last_name></wp:author>
+
+
+    <generator>http://wordpress.org/?v=4.1.1</generator>
+    {foreach $data as $row}
+    <item>
+        <title><![CDATA[{$row.navigation_name}]]></title>
+        <link>{$row.ping_name}</link>
+        <pubDate>{$row.pubDate}</pubDate>
+        <dc:creator><![CDATA[Steve]]></dc:creator>
+        <guid isPermaLink="false">{$row.ping_name}</guid>
+        <description></description>
+        <content:encoded><![CDATA[{$row.pageContent}]]></content:encoded>
+        <excerpt:encoded><![CDATA[]]></excerpt:encoded>
+        <wp:post_id>{$row.id}</wp:post_id>
+        <wp:post_date>{$row.pr_date}</wp:post_date>
+        <wp:post_date_gmt>{$row.pr_date}</wp:post_date_gmt>
+        <wp:comment_status>closed</wp:comment_status>
+        <wp:ping_status>open</wp:ping_status>
+        <wp:post_name>{$row.ping_name}</wp:post_name>
+        <wp:status>publish</wp:status>
+        <wp:post_parent>{$row.parent}</wp:post_parent>
+        <wp:menu_order>{$row.pos}</wp:menu_order>
+        <wp:post_type>page</wp:post_type>
+        <wp:post_password></wp:post_password>
+        <wp:is_sticky>0</wp:is_sticky>
+        <category domain="category" nicename="uncategorized"><![CDATA[Uncategorized]]></category>
+        <wp:postmeta>
+            <wp:meta_key>_edit_last</wp:meta_key>
+            <wp:meta_value><![CDATA[1]]></wp:meta_value>
+        </wp:postmeta>
+    </item>
+    {/foreach}
+</channel>
+</rss>