--- /dev/null
+<?php
+
+class Toolkit_Toolbox_Importer_Controller
+{
+
+ protected $dbhLocal;
+ protected $dbhRemote;
+ protected $pages = array();
+ protected $paragraphs = array();
+ protected $files = array();
+ protected $htImages = array();
+ protected $htImageFolders = array();
+ protected $newHtImages = array();
+
+ public function __construct(PDO $pdo, PDO $pdo2)
+ {
+ $this->setDbhLocal($pdo);
+ $this->setDbhRemote($pdo2);
+ }
+
+ public function createNewPage($id, $name, $parent, $pos)
+ {
+ try {
+ $sql = "
+ SELECT max(id)
+ FROM paragraphs";
+ $stmt = $this->dbhLocal->query($sql);
+ $maxId = $stmt->fetchColumn();
+ ++$maxId;
+ } catch (PDOException $e) {
+ Toolkit_Common::handleError($e);
+ }
+ $page = new Toolkit_Toolbox_Importer_Pages();
+ $page->setId($id)
+ ->setActive(true)
+ ->setHidden(false)
+ ->setMobile_active(false)
+ ->setHeadline(false)
+ ->setTemplate(1)
+ ->setParagraph_links(false)
+ ->setSearch_form(false)
+ ->setInclude_coupons(false)
+ ->setInclude_members(false)
+ ->setNavigation_name($name)
+ ->setParent($parent)
+ ->setPos($pos)
+ ->save($this->dbhLocal);
+ var_dump($page);
+ $paragraph = new Toolkit_Toolbox_Importer_Paragraphs();
+ $paragraph->setId($maxId)
+ ->setActive(true)
+ ->setPage($id)
+ ->setPos(1)
+ ->save($this->dbhLocal);
+ var_dump($paragraph);
+ }
+
+ public function cleanToolboxTables()
+ {
+ try {
+ $this->dbhLocal->query("DELETE FROM toolbox.pages");
+ $this->dbhLocal->query("DELETE FROM toolbox.pages_draft");
+ $this->dbhLocal->query("DELETE FROM toolbox.pages_history");
+ $this->dbhLocal->query("DELETE FROM toolbox.paragraphs");
+ $this->dbhLocal->query("DELETE FROM toolbox.paragraphs_draft");
+ $this->dbhLocal->query("DELETE FROM toolbox.paragraphs_history");
+ $this->dbhLocal->query("DELETE FROM toolbox.files");
+ $this->dbhLocal->query("DELETE FROM toolbox.files_draft");
+ $this->dbhLocal->query("DELETE FROM toolbox.files_history");
+ } catch (PDOException $e) {
+ Toolkit_Common::handleError($e);
+ }
+ }
+
+ public function resetMemberFlags()
+ {
+ try {
+ $sql = "
+ UPDATE toolbox.pages
+ SET include_members = :include_member,
+ include_member_map = :include_member_map,
+ search_form = :search_form
+ WHERE id = :id";
+ $update = $this->dbhLocal->prepare($sql);
+ $sql = "
+ SELECT id,category,no_search_form,include_member_map,region
+ FROM oldtoolbox.bus_category
+ WHERE id IN
+ (SELECT DISTINCT catid FROM oldtoolbox.bus_cat_member)";
+ $stmt = $this->dbhLocal->query($sql);
+ while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
+ $includeMember = true;
+ $update->bindParam(':include_member', $includeMember, PDO::PARAM_BOOL);
+ $includeMemberMap = (bool)$row['include_member_map'];
+ $update->bindParam(':include_member_map', $includeMemberMap, PDO::PARAM_BOOL);
+ $searchForm = (bool) (!$row['no_search_form']);
+ $update->bindParam(':search_form', $searchForm, PDO::PARAM_BOOL);
+ $update->bindParam(':id', $row['id'], PDO::PARAM_INT);
+ var_dump($row);
+ var_dump($searchForm);
+ var_dump($includeMember);
+ var_dump($includeMemberMap);
+ $update->execute();
+
+ }
+ } catch (PDOException $e) {
+ Toolkit_Common::handleError($e);
+ }
+
+ }
+
+ public function resetMemberWithRegions()
+ {
+ try {
+ $sql = "
+ UPDATE toolbox.pages
+ SET include_members = :include_member,
+ include_member_map = :include_member_map,
+ search_form = :search_form
+ WHERE id = :id";
+ $update = $this->dbhLocal->prepare($sql);
+ $sql = "
+ INSERT INTO toolbox.member_regions2toolbox_pages
+ (page, region)
+ VALUES
+ (:page, :region)";
+ $addPageRegion = $this->dbhLocal->prepare($sql);
+ $sql = "
+ SELECT id,category,no_search_form,include_member_map,region
+ FROM oldtoolbox.bus_category
+ WHERE region IS NOT NULL";
+ $stmt = $this->dbhLocal->query($sql);
+ while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
+ $includeMember = false;
+ $update->bindParam(':include_member', $includeMember, PDO::PARAM_BOOL);
+ $includeMemberMap = (bool)$row['include_member_map'];
+ $update->bindParam(':include_member_map', $includeMemberMap, PDO::PARAM_BOOL);
+ $searchForm = (bool) (!$row['no_search_form']);
+ $update->bindParam(':search_form', $searchForm, PDO::PARAM_BOOL);
+ $update->bindParam(':id', $row['id'], PDO::PARAM_INT);
+ var_dump($row);
+ $update->execute();
+ $addPageRegion->bindParam(':page', $row['id'], PDO::PARAM_INT);
+ $addPageRegion->bindParam(':region', $row['region'], PDO::PARAM_INT);
+ $addPageRegion->execute();
+ }
+ } catch (PDOException $e) {
+ Toolkit_Common::handleError($e);
+ }
+ }
+
+ public function getOldPages()
+ {
+ $mainParaStartCounter = 5000;
+ $sql = "
+ SELECT *
+ FROM files
+ WHERE bus_id = :id
+ ORDER BY pos";
+ $getFiles = $this->dbhRemote->prepare($sql);
+ $sql = "
+ SELECT b.*,bcb.pos
+ FROM bus b, bus_category_bus bcb
+ WHERE bcb.busid = b.id
+ AND bcb.catid = :catid
+ ORDER BY bcb.pos";
+ $getParas = $this->dbhRemote->prepare($sql);
+ try {
+ $sql = "
+ SELECT *
+ FROM bus_category
+ ORDER BY parent,pos";
+ $stmt = $this->dbhRemote->query($sql);
+ $stmt->execute();
+
+ while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
+ // first paragraph actually comes from the old bus_category table
+ $paragraph = new Toolkit_Toolbox_Importer_Paragraphs();
+ $paragraph
+ ->setId(++$mainParaStartCounter)
+ ->setTitle($row['intro'])
+ ->setPage($row['id'])
+ ->setPos(1)
+ ->setActive(true)
+ ->setDescription($row['description'])
+ ->setCaption($row['imagename'])
+ ->setImage($row['image']);
+ $this->paragraphs[] = $paragraph;
+ // now let's get the paragraphs from bus_category_bus and bus
+ // remember that we need to increment the pos by one
+ // because we already have one paragraph
+ $getParas->bindValue(
+ ":catid",
+ $row['id'],
+ PDO::PARAM_INT
+ );
+ $getParas->execute();
+ while ($row2 = $getParas->fetch(PDO::FETCH_ASSOC)) {
+ $paragraph = new Toolkit_Toolbox_Importer_Paragraphs();
+ $paragraph
+ ->setId($row2['id'])
+ ->setTitle($row2['name'])
+ ->setPage($row['id'])
+ ->setPos($row2['pos'] + 1)
+ ->setActive(true)
+ ->setDescription($row2['description'])
+ ->setCaption($row2['imagename'])
+ ->setImage($row2['image']);
+ $this->paragraphs[] = $paragraph;
+ // get the files for this paragraph
+ $getFiles->bindParam(
+ ':id',
+ $row2['id'],
+ PDO::PARAM_INT
+ );
+ $getFiles->execute();
+ while ($row3 = $getFiles->fetch(PDO::FETCH_ASSOC)) {
+ $file = new Toolkit_Toolbox_Importer_Files();
+ $file
+ ->setId($row3['id'])
+ ->setFilename($row3['filename'])
+ ->setBytes($row3['bytes'])
+ ->setType($row3['type'])
+ ->setUrltext($row3['urltext'])
+ ->setParagraph($row2['id'])
+ ->setPos($row3['pos']);
+ $this->files[] = $file;
+ }
+ }
+ $page = new Toolkit_Toolbox_Importer_Pages();
+ $includeMembers = false;
+ $searchForm = false;
+ $includeMemberMap = (bool)$row['include_member_map'];
+ $headline
+ = ($row['featured'])
+ ? true
+ : false;
+ $active
+ = ($row['active'])
+ ? true
+ : false;
+ $page
+ ->setId($row['id'])
+ ->setActive($active)
+ ->setMobile_active($active)
+ ->setMeta_title($row['title'])
+ ->setMeta_description($row['meta_descr'])
+ ->setNavigation_name($row['category'])
+ ->setPos($row['pos'])
+ ->setParent($row['parent'])
+ ->setKeyword($row['keyword'])
+ ->setTemplate($row['template'])
+ ->setHeadline($headline)
+ ->setHeadline_intro($row['feature_intro'])
+ ->setInclude_coupons(false)
+ ->setInclude_members($includeMembers)
+ ->setInclude_member_map($includeMemberMap)
+ ->setSearch_form($searchForm)
+ ->setShort_url($row['short_url'])
+ ->setParagraph_links($row['section_links']);
+
+ // set the page to pages array
+ $this->pages[$page->getParent()][$page->getId()] = $page;
+ }
+ //var_dump($this->pages);
+ //var_dump($this->paragraphs);
+ var_dump($this->files);
+ } catch(PDOException $e) {
+ Toolkit_Common::handleError($e);
+ }
+ }
+
+ public function getNewParagraphs()
+ {
+ $sql = "
+ SELECT *
+ FROM paragraphs
+ WHERE image != ''
+ AND image not like 'is%'";
+ $this->paragraphs = array();
+ try {
+ $stmt = $this->dbhLocal->query($sql);
+ while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
+ $paragraph = new Toolkit_Toolbox_Importer_Paragraphs();
+ $paragraph
+ ->setId($row['id'])
+ ->setImage($row['image']);
+ $this->paragraphs[] = $paragraph;
+ }
+// var_dump($this->paragraphs);
+ } catch(PDOException $e) {
+ Toolkit_Common::handleError($e);
+ }
+ }
+
+ public function getNewParagraphsWithDescr()
+ {
+ $sql = "
+ SELECT *
+ FROM paragraphs
+ WHERE description != ''
+ AND strpos(description, 'ht_images') > 0";
+ $this->paragraphs = array();
+ try {
+ $stmt = $this->dbhLocal->query($sql);
+ while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
+ $paragraph = new Toolkit_Toolbox_Importer_Paragraphs();
+ $paragraph
+ ->setId($row['id'])
+ ->setDescription($row['description']);
+ preg_match_all('/< *img[^>]*src *= *["\']?([^"\']*)/i', $row['description'], $matches);
+ if ($matches) {
+ foreach ($matches[1] as $match) {
+ $this->htImages[$match] = true;
+ }
+ }
+ $this->paragraphs[] = $paragraph;
+ }
+// var_dump($this->htImages);
+ } catch(PDOException $e) {
+ Toolkit_Common::handleError($e);
+ }
+ }
+
+ public function getNewFiles()
+ {
+ $this->files = array();
+ $sql = "
+ SELECT *
+ FROM files
+ WHERE filename != ''
+ AND filename not like 'fs%'";
+ try {
+ $stmt = $this->dbhLocal->query($sql);
+ while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
+ $file = new Toolkit_Toolbox_Importer_Files();
+ $file
+ ->setId($row['id'])
+ ->setFilename($row['filename']);
+ $this->files[] = $file;
+ }
+// var_dump($this->files);
+ } catch (PDOException $e) {
+ Toolkit_Common::handleError($e);
+ }
+ }
+
+ public function resetSequences()
+ {
+ $this->_resetPagesSequence();
+ $this->_resetParagraphsSequence();
+ $this->_resetFilesSequence();
+ }
+
+ private function _resetPagesSequence()
+ {
+ try {
+ $this->dbhLocal->query(
+ "SELECT setval('pages_id_seq', (SELECT max(id) FROM pages))"
+ );
+ } catch (PDOException $e) {
+ Toolkit_Common::handleError($e);
+ }
+ }
+
+ private function _resetParagraphsSequence()
+ {
+ try {
+ $this->dbhLocal->query(
+ "SELECT setval('paragraphs_id_seq', (SELECT max(id) FROM paragraphs))"
+ );
+ } catch (PDOException $e) {
+ Toolkit_Common::handleError($e);
+ }
+ }
+
+ private function _resetFilesSequence()
+ {
+ try {
+ $this->dbhLocal->query(
+ "SELECT setval('files_id_seq', (SELECT max(id) FROM files))"
+ );
+ } catch (PDOException $e) {
+ Toolkit_Common::handleError($e);
+ }
+ }
+
+ public function addPages()
+ {
+ if (!is_array($this->pages)) {
+ die('no pages');
+ }
+ foreach ($this->pages as $parent => $pages) {
+ foreach ($pages as $page) {
+ $page->save($this->dbhLocal);
+ }
+ }
+ }
+
+ public function addParagraphs()
+ {
+ if (!is_array($this->paragraphs)) {
+ return false;
+ }
+ foreach ($this->paragraphs as $paragraph) {
+ $paragraph->save($this->dbhLocal);
+ }
+ }
+
+ public function addFiles()
+ {
+ if (!is_array($this->files)) {
+ return false;
+ }
+ foreach ($this->files as $file) {
+ $file->save($this->dbhLocal);
+ }
+ }
+
+ public function addFolder($folderName, $parentId)
+ {
+ if (!is_numeric($parentId)) {
+ throw new InvalidArgumentException('parentId must be numeric');
+ }
+ if ($folderName == '') {
+ throw new InvalidArgumentException('folderName must not be empty');
+ }
+ try {
+ // check to see if the folder is already there
+ $sql = "
+ SELECT id
+ FROM ckeditor_folders
+ WHERE name = :name";
+ $stmt2 = $this->dbhLocal->prepare($sql);
+ $stmt2->bindParam(':name', $folderName);
+ $stmt2->execute();
+ $folderId = $stmt2->fetchColumn();
+ if ($folderId) {
+ return $folderId;
+ } else {
+ $sql = "
+ INSERT INTO ckeditor_folders
+ (name, parent)
+ VALUES
+ (:name, :parent)";
+ $stmt = $this->dbhLocal->prepare($sql);
+ $stmt->bindParam(':name', $folderName, PDO::PARAM_STR);
+ $stmt->bindParam(':parent', $parentId, PDO::PARAM_INT);
+ $stmt->execute();
+ return $this->dbhLocal->lastInsertId('ckeditor_folders_id_seq');
+ }
+ } catch (PDOException $e) {
+ Toolkit_Common::handleError($e);
+ }
+ }
+
+ public function addImage(Toolkit_FileServer_ImageAdapter $ia, $folder, $image)
+ {
+ if ($image == '') {
+ throw new InvalidArgumentException('Image must not be empty');
+ }
+ if (!is_numeric($folder['id'])) {
+ throw new InvalidArgumentException('Folder array must contain id');
+ }
+ // check to see if the folder is already there
+ $sql = "
+ SELECT name_on_disk
+ FROM ckeditor_images
+ WHERE file_name = :file_name";
+ $stmt2 = $this->dbhLocal->prepare($sql);
+ $stmt2->bindParam(':file_name', $image);
+ $stmt2->execute();
+ $imageName = $stmt2->fetchColumn();
+ if ($imageName) {
+ return $imageName;
+ }
+ $imageUrl
+ = FILEMANAGER_URL_ORG
+ . $folder['path']
+ . urlencode($image);
+ if ($image != '') {
+ try {
+ $img = $ia->upload($imageUrl);
+ } catch(PEAR_Exception $e) {
+ Toolkit_Common::handleError($e);
+ } catch(Toolkit_FileServer_Exception $e) {
+ return false;
+ }
+ }
+ $dimensions = $ia->getImageSize(CKIMAGE . $img['name']);
+ $sql = "
+ INSERT INTO ckeditor_images (file_name, name_on_disk, folder,
+ original_width, original_height)
+ VALUES (:fname, :nod, :folder, :width, :height)";
+
+ $stmt = $this->dbhLocal->prepare($sql);
+ $stmt->bindParam(
+ ':fname',
+ $image,
+ PDO::PARAM_STR
+ );
+ $stmt->bindParam(':nod', $img['name'], PDO::PARAM_STR);
+ $stmt->bindValue(':folder', $folder['id'], PDO::PARAM_INT);
+ $stmt->bindValue(':width', $dimensions[0], PDO::PARAM_INT);
+ $stmt->bindValue(':height', $dimensions[1], PDO::PARAM_INT);
+
+ $stmt->execute();
+ return $img['name'];
+ }
+
+ public function importFiles(Toolkit_FileServer_FileAdapter $fs)
+ {
+ if (is_array($this->files)) {
+ foreach ($this->files as $file) {
+ $filename = $file->getFilename();
+ $pattern = '/^fs/';
+ if ($filename != '' && !preg_match($pattern, $filename)) {
+ $file->importFile($this->dbhLocal, $fs);
+ }
+ }
+ }
+ }
+
+ public function importImages(Toolkit_Image_Server $is)
+ {
+ if (is_array($this->paragraphs)) {
+ foreach ($this->paragraphs as $paragraph) {
+ $img = $paragraph->getImage();
+ $pattern = '/^is/';
+ if ($img != '' && !preg_match($pattern, $img)) {
+ $paragraph->importImage($this->dbhLocal, $is);
+ }
+ }
+ }
+ }
+
+ public function importParagraphImages(Toolkit_FileServer_ImageAdapter $ia)
+ {
+ if (is_array($this->htImages)) {
+ foreach ($this->htImages as $href => $found) {
+ // parse out the url to find the ending
+// var_dump($href);
+// var_dump(FILEMANAGER_URL_ORG);
+ $dirPart = str_replace(FILEMANAGER_URL_ORG, '', $href);
+// var_dump($dirPart);
+ if ($dirPart != '') {
+ $items = explode('/', $dirPart);
+// var_dump($items);
+ $itemCount = count($items);
+ switch ($itemCount) {
+ case 3 :
+ $this->htImageFolders[$items[0]][$items[1]][] = $items[2];
+ break;
+ case 2 :
+ $this->htImageFolders[$items[0]][] = $items[1];
+ break;
+ case 1 :
+ $this->htImageFolders[] = $items[0];
+ break;
+ }
+ }
+ // old site name visittraversecity.com
+// var_dump($href);
+// var_dump(FILEMANAGER_URL_ORG2);
+ $dirPart = str_replace(FILEMANAGER_URL_ORG2, '', $href);
+// var_dump($dirPart);
+ if ($dirPart != '') {
+ $items = explode('/', $dirPart);
+// var_dump($items);
+ $itemCount = count($items);
+ switch ($itemCount) {
+ case 3 :
+ $this->htImageFolders2[$items[0]][$items[1]][] = $items[2];
+ break;
+ case 2 :
+ $this->htImageFolders2[$items[0]][] = $items[1];
+ break;
+ case 1 :
+ $this->htImageFolders2[] = $items[0];
+ break;
+ }
+ }
+ }
+// var_dump($this->htImageFolders);
+// var_dump($this->htImageFolders2);
+// exit;
+ if (is_array($this->htImageFolders)) {
+ foreach ($this->htImageFolders as $folderName => $images) {
+ if (!is_numeric($folderName)) {
+// var_dump($folderName);
+ $folderId = $this->addFolder($folderName, 0);
+ $folder = array(
+ 'id' => $folderId,
+ 'path' => $folderName . '/'
+ );
+ foreach ($images as $image) {
+ if (!$img = $this->addImage($ia, $folder, $image)) {
+ //echo 'not found!';
+ } else {
+ $this->newHtImages[] = array(
+ 'oldPath' => FILEMANAGER_URL_ORG
+ . $folderName . '/' . $image,
+ 'newPath' => CKIMAGE_ORIGINAL
+ . $img
+ );
+ }
+ }
+
+ } else {
+ $folder = array(
+ 'id' => 1,
+ 'path' => ''
+ );
+// var_dump($images);
+ if (!$img = $this->addImage($ia, $folder, $images)) {
+ //echo 'not found!';
+ } else {
+ $this->newHtImages[] = array(
+ 'oldPath' => FILEMANAGER_URL_ORG
+ . $images,
+ 'newPath' => CKIMAGE_ORIGINAL
+ . $img
+ );
+ }
+ }
+ }
+ }
+ if (is_array($this->htImageFolders2)) {
+ foreach ($this->htImageFolders2 as $folderName => $images) {
+ if (!is_numeric($folderName)) {
+// var_dump($folderName);
+ $folderId = $this->addFolder($folderName, 0);
+ $folder = array(
+ 'id' => $folderId,
+ 'path' => $folderName . '/'
+ );
+ foreach ($images as $image) {
+ if (!$img = $this->addImage($ia, $folder, $image)) {
+ //echo 'not found!';
+ } else {
+ $this->newHtImages[] = array(
+ 'oldPath' => FILEMANAGER_URL_ORG2
+ . $folderName . '/' . $image,
+ 'newPath' => CKIMAGE_ORIGINAL
+ . $img
+ );
+ }
+ }
+
+ } else {
+ $folder = array(
+ 'id' => 1,
+ 'path' => ''
+ );
+// var_dump($images);
+ if (!$img = $this->addImage($ia, $folder, $images)) {
+ //echo 'not found!';
+ } else {
+ $this->newHtImages[] = array(
+ 'oldPath' => FILEMANAGER_URL_ORG2
+ . $images,
+ 'newPath' => CKIMAGE_ORIGINAL
+ . $img
+ );
+ }
+ }
+ }
+ }
+ //var_dump($this->htImages);
+
+ }
+ }
+
+ public function setDbhLocal($dbh) {
+ $this->dbhLocal = $dbh;
+ }
+
+ public function setDbhRemote($dbh) {
+ $this->dbhRemote = $dbh;
+ }
+
+ public function updateParagraphsWithImageNames()
+ {
+// var_dump($this->htImageFolders);
+// var_dump($this->newHtImages);
+ try {
+ $sql = "
+ UPDATE paragraphs
+ SET description = replace(description, :oldImageName, :newImageName)";
+ $updateParagraphs = $this->dbhLocal->prepare($sql);
+ if (is_array($this->newHtImages)) {
+ foreach ($this->newHtImages as $image) {
+ $updateParagraphs->bindParam(
+ ':oldImageName',
+ $image['oldPath'],
+ PDO::PARAM_STR
+ );
+ $updateParagraphs->bindParam(
+ ':newImageName',
+ $image['newPath'],
+ PDO::PARAM_STR
+ );
+ $updateParagraphs->execute();
+ }
+ }
+ } catch(PDOException $e) {
+ Toolkit_Common::handleError($e);
+ }
+ }
+
+}
--- /dev/null
+<?php
+
+class Toolkit_Toolbox_Importer_Pages
+{
+
+ protected $id;
+ protected $active = true;
+ protected $mobile_active = true;
+ protected $navigation_name;
+ protected $keyword;
+ protected $meta_title;
+ protected $meta_description;
+ protected $template;
+ protected $parent;
+ protected $pos;
+ protected $headline;
+ protected $headline_intro;
+ protected $search_form;
+ protected $include_members;
+ protected $include_member_map;
+ protected $include_coupons;
+ protected $short_url;
+ protected $paragraph_links = false;
+
+ public function getId() {
+ return $this->id;
+ }
+
+ public function setId($id) {
+ if (!is_numeric($id)) {
+ throw new Exception('id must be a number');
+ }
+ if (!$this->id) {
+ $this->id = $id;
+ }
+ return $this;
+ }
+
+ public function getActive() {
+ return (bool)$this->active;
+ }
+
+ public function setActive($active) {
+ $this->active = ($active) ? true: false;
+ return $this;
+ }
+
+ public function getMobile_active() {
+ return (bool)$this->mobile_active;
+ }
+
+ public function setMobile_active($mobile_active) {
+ $this->mobile_active = ($mobile_active) ? true: false;
+ return $this;
+ }
+
+ public function getNavigation_name() {
+ return $this->navigation_name;
+ }
+
+ public function setNavigation_name($navigation_name) {
+ $this->navigation_name = $navigation_name;
+ return $this;
+ }
+
+ public function getKeyword() {
+ return $this->keyword;
+ }
+
+ public function setKeyword($keyword) {
+ $this->keyword = $keyword;
+ return $this;
+ }
+
+ public function getMeta_title() {
+ return $this->meta_title;
+ }
+
+ public function setMeta_title($meta_title) {
+ $this->meta_title = $meta_title;
+ return $this;
+ }
+
+ public function getMeta_description() {
+ return $this->meta_description;
+ }
+
+ public function setMeta_description($meta_description) {
+ $this->meta_description = $meta_description;
+ return $this;
+ }
+
+ public function getTemplate() {
+ return $this->template;
+ }
+
+ public function setTemplate($template) {
+ $this->template = $template;
+ return $this;
+ }
+
+ public function getParent() {
+ return $this->parent;
+ }
+
+ public function setParent($parent) {
+ $this->parent = $parent;
+ return $this;
+ }
+
+ public function getPos() {
+ return (int)$this->pos;
+ }
+
+ public function setPos($pos) {
+ $this->pos = $pos;
+ return $this;
+ }
+
+ public function getHeadline()
+ {
+ return $this->headline;
+ }
+
+ public function setHeadline($headline)
+ {
+ $this->headline = ($headline) ? true : false;
+ return $this;
+ }
+
+ public function getHeadline_intro()
+ {
+ return $this->headline_intro;
+ }
+
+ public function setHeadline_intro($headline_intro)
+ {
+ $this->headline_intro = $headline_intro;
+ return $this;
+ }
+
+ public function getSearch_form()
+ {
+ return $this->search_form;
+ }
+
+ public function setSearch_form($search_form)
+ {
+ $this->search_form = $search_form;
+ return $this;
+ }
+
+ public function getInclude_members()
+ {
+ return $this->include_members;
+ }
+
+ public function setInclude_members($include_members)
+ {
+ $this->include_members = $include_members;
+ return $this;
+ }
+
+ public function getInclude_member_map()
+ {
+ return $this->include_member_map;
+ }
+
+ public function setInclude_member_map($include_member_map)
+ {
+ $this->include_member_map = $include_member_map;
+ return $this;
+ }
+
+ public function getInclude_coupons()
+ {
+ return $this->include_coupons;
+ }
+
+ public function setInclude_coupons($include_coupons)
+ {
+ $this->include_coupons = $include_coupons;
+ return $this;
+ }
+
+ public function getShort_url()
+ {
+ return $this->short_url;
+ }
+
+ public function setShort_url($short_url)
+ {
+ $this->short_url = $short_url;
+ return $this;
+ }
+
+ public function getParagraph_links()
+ {
+ return (bool)$this->paragraph_links;
+ }
+
+ public function setParagraph_links($paragraph_links)
+ {
+ $this->paragraph_links = ($paragraph_links) ? true : false;
+ return $this;
+ }
+
+ public function save(PDO $dbh)
+ {
+ try {
+ $sql = "
+ INSERT INTO toolbox.pages
+ (id, active, mobile_active, navigation_name, keyword, meta_title,
+ meta_description, template, parent, pos, headline, headline_intro,
+ search_form, include_members, include_member_map, include_coupons, short_url,
+ paragraph_links)
+ VALUES
+ (:id, :active, :mobile_active, :navigation_name, :keyword, :meta_title,
+ :meta_description, :template, :parent, :pos, :headline, :headline_intro,
+ :search_form, :include_members, :include_member_map, :include_coupons, :short_url,
+ :paragraph_links)
+ RETURNING id";
+ $stmt = $dbh->prepare($sql);
+ $stmt->bindParam(':id', $this->getId(), PDO::PARAM_INT);
+ $stmt->bindParam(':active', $this->getActive(), PDO::PARAM_BOOL);
+ $stmt->bindParam(':mobile_active', $this->getMobile_active(), PDO::PARAM_BOOL);
+ $stmt->bindParam(':navigation_name', $this->getNavigation_name());
+ $stmt->bindParam(':keyword', $this->getKeyword());
+ $stmt->bindParam(':meta_title', $this->getMeta_title());
+ $stmt->bindParam(':meta_description', $this->getMeta_description());
+ $stmt->bindParam(':template', $this->getTemplate(), PDO::PARAM_INT);
+ $stmt->bindParam(':parent', $this->getParent(), PDO::PARAM_INT);
+ $stmt->bindParam(':pos', $this->getPos(), PDO::PARAM_INT);
+ $stmt->bindParam(':headline', $this->getHeadline(), PDO::PARAM_BOOL);
+ $stmt->bindParam(':headline_intro', $this->getHeadline_intro());
+ $stmt->bindParam(':search_form', $this->getSearch_form(), PDO::PARAM_BOOL);
+ $stmt->bindParam(':include_members', $this->getInclude_members(), PDO::PARAM_BOOL);
+ $stmt->bindParam(':include_member_map', $this->getInclude_member_map(), PDO::PARAM_BOOL);
+ $stmt->bindParam(':include_coupons', $this->getInclude_coupons(), PDO::PARAM_BOOL);
+ $stmt->bindParam(':short_url', $this->getShort_url(), PDO::PARAM_BOOL);
+ $stmt->bindParam(':paragraph_links', $this->getParagraph_links(), PDO::PARAM_BOOL);
+
+ $stmt->execute();
+ } catch(PDOException $e) {
+ Toolkit_Common::handleError($e);
+ }
+ }
+
+}