Autodoc
  • Namespace
  • Class
  • Tree

Namespaces

  • BlueTihi
    • Context
  • Brickrouge
    • Element
      • Nodes
    • Renderer
    • Widget
  • ICanBoogie
    • ActiveRecord
    • AutoConfig
    • CLDR
    • Composer
    • Core
    • Event
    • Exception
    • HTTP
      • Dispatcher
      • Request
    • I18n
      • Translator
    • Mailer
    • Modules
      • Taxonomy
        • Support
      • Thumbnailer
        • Versions
    • Object
    • Operation
      • Dispatcher
    • Prototype
    • Routes
    • Routing
      • Dispatcher
    • Session
  • Icybee
    • ActiveRecord
      • Model
    • ConfigOperation
    • Document
    • EditBlock
    • Element
      • ActionbarContextual
      • ActionbarSearch
      • ActionbarToolbar
    • FormBlock
    • Installer
    • ManageBlock
    • Modules
      • Articles
      • Cache
        • Collection
        • ManageBlock
      • Comments
        • ManageBlock
      • Contents
        • ManageBlock
      • Dashboard
      • Editor
        • Collection
      • Files
        • File
        • ManageBlock
      • Forms
        • Form
        • ManageBlock
      • I18n
      • Images
        • ManageBlock
      • Members
      • Modules
        • ManageBlock
      • Nodes
        • ManageBlock
        • Module
      • Pages
        • BreadcrumbElement
        • LanguagesElement
        • ManageBlock
        • NavigationBranchElement
        • NavigationElement
        • Page
        • PageController
      • Registry
      • Search
      • Seo
      • Sites
        • ManageBlock
      • Taxonomy
        • Terms
          • ManageBlock
        • Vocabulary
          • ManageBlock
      • Users
        • ManageBlock
        • NonceLogin
        • Roles
      • Views
        • ActiveRecordProvider
        • Collection
        • View
    • Operation
      • ActiveRecord
      • Constructor
      • Module
      • Widget
    • Rendering
  • None
  • Patron
  • PHP

Classes

  • Blueprint
  • BlueprintNode
  • BreadcrumbElement
  • Content
  • ContentModel
  • CopyOperation
  • DeleteOperation
  • EditBlock
  • ExportBlock
  • ExportOperation
  • Hooks
  • ImportOperation
  • LanguagesElement
  • ListView
  • ManageBlock
  • Model
  • Module
  • NavigationBranchElement
  • NavigationElement
  • NavigationExcludeOperation
  • NavigationIncludeOperation
  • Page
  • PageController
  • PopPage
  • PopTemplate
  • QueryOperationOperation
  • SaveOperation
  • TemplateEditorsOperation
  • UpdateTreeOperation
  1 <?php
  2 
  3 /*
  4  * This file is part of the Icybee package.
  5  *
  6  * (c) Olivier Laviale <olivier.laviale@gmail.com>
  7  *
  8  * For the full copyright and license information, please view the LICENSE
  9  * file that was distributed with this source code.
 10  */
 11 
 12 namespace Icybee\Modules\Pages;
 13 
 14 use ICanBoogie\HTTP\Request;
 15 
 16 class ImportOperation extends \Icybee\Modules\Nodes\ImportOperation
 17 {
 18     private $parentid = array();
 19     private $locationid = array();
 20 
 21     protected function parse_data(array $data)
 22     {
 23         foreach ($data as $nid => $obj)
 24         {
 25             if ($obj->parentid)
 26             {
 27                 $this->parentid[$nid] = $obj->parentid;
 28             }
 29 
 30             unset($obj->parentid);
 31 
 32             if ($obj->locationid)
 33             {
 34                 $this->locationid[$nid] = $obj->locationid;
 35             }
 36 
 37             unset($obj->locationid);
 38 
 39             if (empty($obj->contents))
 40             {
 41                 \ICanBoogie\log("page $nid has no content");
 42             }
 43             else
 44             {
 45                 $contents = (array) $obj->contents;
 46                 $editors = (array) $obj->editors;
 47 
 48                 foreach ($contents as $contentid => &$content)
 49                 {
 50                     if (($content{0} == '{' || $content{0} == '[') && $content{1} == '"')
 51                     {
 52                         $content = json_decode($content, true);
 53                     }
 54                 }
 55 
 56                 foreach ($editors as $contentid => $editor_name)
 57                 {
 58                     if ($editor_name != 'widgets' || empty($contents[$contentid]))
 59                     {
 60                         continue;
 61                     }
 62 
 63                     $content = &$contents[$contentid];
 64                     $content = array_combine($content, array_fill(0, count($content), 'on'));
 65                 }
 66 
 67                 $obj->contents = $contents;
 68                 $obj->editors = $editors;
 69             }
 70         }
 71 
 72         return parent::parse_data($data);
 73     }
 74 
 75     protected function import(array $data, Request $save)
 76     {
 77         global $core;
 78 
 79         parent::import($data, $save);
 80 
 81         //var_dump($this->keys_translations, $this->locationid, $data);
 82 
 83         $update = $core->db->prepare('UPDATE {prefix}pages SET parentid = ?, locationid = ? WHERE nid = ?');
 84 
 85         $original_nodes_with_parentid = $this->parentid;
 86         $original_nodes_with_locationid = $this->locationid;
 87 
 88         foreach (array_keys($data) as $nid)
 89         {
 90             $parentid = 0;
 91 
 92             if (isset($original_nodes_with_parentid[$nid]))
 93             {
 94                 $parentid = $this->keys_translations[$original_nodes_with_parentid[$nid]];
 95             }
 96 
 97             $locationid = 0;
 98 
 99             if (isset($original_nodes_with_locationid[$nid]))
100             {
101                 $locationid = $this->keys_translations[$original_nodes_with_locationid[$nid]];
102             }
103 
104             if ($parentid || $locationid)
105             {
106                 $update->execute(array($parentid, $locationid, $this->keys_translations[$nid]));
107             }
108         }
109     }
110 }
Autodoc API documentation generated by ApiGen 2.8.0