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 /**
15  * Updates the order and relation of the specified records.
16  */
17 class UpdateTreeOperation extends \ICanBoogie\Operation
18 {
19     protected function get_controls()
20     {
21         return array
22         (
23             self::CONTROL_PERMISSION => Module::PERMISSION_ADMINISTER
24         )
25 
26         + parent::get_controls();
27     }
28 
29     protected function validate(\ICanboogie\Errors $errors)
30     {
31         $order = $this->request['order'];
32         $relation = $this->request['relation'];
33 
34         if ($order && $relation)
35         {
36             foreach ($order as $nid)
37             {
38                 if (!isset($relation[$nid]))
39                 {
40                     $errors['relation'] = $errors->format("Missing relation for nid %nid.", array('nid' => $nid));
41                 }
42             }
43         }
44         else
45         {
46             if (!$order)
47             {
48                 $errors['order'] = $errors->format("The %param param is required", array('param' => 'order'));
49             }
50 
51             if (!$relation)
52             {
53                 $errors['relation'] = $errors->format("The %param param is required", array('param' => 'relation'));
54             }
55         }
56 
57         return !$errors->count();
58     }
59 
60     protected function process()
61     {
62         $w = 0;
63         $update = $this->module->model->prepare('UPDATE {self} SET `parentid` = ?, `weight` = ? WHERE `{primary}` = ? LIMIT 1');
64 
65         $order = $this->request['order'];
66         $relation = $this->request['relation'];
67 
68         foreach ($order as $nid)
69         {
70             $parent_id = $relation[$nid];
71 
72             // FIXME-20100429: cached entries are not updated here, we should flush the cache.
73 
74             $update($parent_id, $w++, $nid);
75         }
76 
77         return true;
78     }
79 }
Autodoc API documentation generated by ApiGen 2.8.0