Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like CMSMain often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use CMSMain, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 74 | class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionProvider |
||
| 75 | { |
||
| 76 | |||
| 77 | private static $url_segment = 'pages'; |
||
|
|
|||
| 78 | |||
| 79 | private static $url_rule = '/$Action/$ID/$OtherID'; |
||
| 80 | |||
| 81 | // Maintain a lower priority than other administration sections |
||
| 82 | // so that Director does not think they are actions of CMSMain |
||
| 83 | private static $url_priority = 39; |
||
| 84 | |||
| 85 | private static $menu_title = 'Edit Page'; |
||
| 86 | |||
| 87 | private static $menu_icon_class = 'font-icon-sitemap'; |
||
| 88 | |||
| 89 | private static $menu_priority = 10; |
||
| 90 | |||
| 91 | private static $tree_class = SiteTree::class; |
||
| 92 | |||
| 93 | private static $subitem_class = Member::class; |
||
| 94 | |||
| 95 | private static $session_namespace = 'SilverStripe\\CMS\\Controllers\\CMSMain'; |
||
| 96 | |||
| 97 | private static $required_permission_codes = 'CMS_ACCESS_CMSMain'; |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Amount of results showing on a single page. |
||
| 101 | * |
||
| 102 | * @config |
||
| 103 | * @var int |
||
| 104 | */ |
||
| 105 | private static $page_length = 15; |
||
| 106 | |||
| 107 | private static $allowed_actions = array( |
||
| 108 | 'archive', |
||
| 109 | 'deleteitems', |
||
| 110 | 'DeleteItemsForm', |
||
| 111 | 'dialog', |
||
| 112 | 'duplicate', |
||
| 113 | 'duplicatewithchildren', |
||
| 114 | 'publishall', |
||
| 115 | 'publishitems', |
||
| 116 | 'PublishItemsForm', |
||
| 117 | 'submit', |
||
| 118 | 'EditForm', |
||
| 119 | 'SearchForm', |
||
| 120 | 'SiteTreeAsUL', |
||
| 121 | 'getshowdeletedsubtree', |
||
| 122 | 'batchactions', |
||
| 123 | 'treeview', |
||
| 124 | 'listview', |
||
| 125 | 'ListViewForm', |
||
| 126 | 'childfilter', |
||
| 127 | ); |
||
| 128 | |||
| 129 | private static $casting = array( |
||
| 130 | 'TreeIsFiltered' => 'Boolean', |
||
| 131 | 'AddForm' => 'HTMLFragment', |
||
| 132 | 'LinkPages' => 'Text', |
||
| 133 | 'Link' => 'Text', |
||
| 134 | 'ListViewForm' => 'HTMLFragment', |
||
| 135 | 'ExtraTreeTools' => 'HTMLFragment', |
||
| 136 | 'PageList' => 'HTMLFragment', |
||
| 137 | 'PageListSidebar' => 'HTMLFragment', |
||
| 138 | 'SiteTreeHints' => 'HTMLFragment', |
||
| 139 | 'SecurityID' => 'Text', |
||
| 140 | 'SiteTreeAsUL' => 'HTMLFragment', |
||
| 141 | ); |
||
| 142 | |||
| 143 | protected function init() |
||
| 144 | { |
||
| 145 | // set reading lang |
||
| 146 | if (SiteTree::has_extension('Translatable') && !$this->getRequest()->isAjax()) { |
||
| 147 | Translatable::choose_site_locale(array_keys(Translatable::get_existing_content_languages('SilverStripe\\CMS\\Model\\SiteTree'))); |
||
| 148 | } |
||
| 149 | |||
| 150 | parent::init(); |
||
| 151 | |||
| 152 | Requirements::javascript(CMS_DIR . '/client/dist/js/bundle.js'); |
||
| 153 | Requirements::javascript(CMS_DIR . '/client/dist/js/SilverStripeNavigator.js'); |
||
| 154 | Requirements::css(CMS_DIR . '/client/dist/styles/bundle.css'); |
||
| 155 | Requirements::customCSS($this->generatePageIconsCss()); |
||
| 156 | Requirements::add_i18n_javascript(CMS_DIR . '/client/lang', false, true); |
||
| 157 | |||
| 158 | CMSBatchActionHandler::register('restore', CMSBatchAction_Restore::class); |
||
| 159 | CMSBatchActionHandler::register('archive', CMSBatchAction_Archive::class); |
||
| 160 | CMSBatchActionHandler::register('unpublish', CMSBatchAction_Unpublish::class); |
||
| 161 | CMSBatchActionHandler::register('publish', CMSBatchAction_Publish::class); |
||
| 162 | } |
||
| 163 | |||
| 164 | public function index($request) |
||
| 165 | { |
||
| 166 | // In case we're not showing a specific record, explicitly remove any session state, |
||
| 167 | // to avoid it being highlighted in the tree, and causing an edit form to show. |
||
| 168 | if (!$request->param('Action')) { |
||
| 169 | $this->setCurrentPageID(null); |
||
| 170 | } |
||
| 171 | |||
| 172 | return parent::index($request); |
||
| 173 | } |
||
| 174 | |||
| 175 | public function getResponseNegotiator() |
||
| 176 | { |
||
| 177 | $negotiator = parent::getResponseNegotiator(); |
||
| 178 | |||
| 179 | // ListViewForm |
||
| 180 | $negotiator->setCallback('ListViewForm', function () { |
||
| 181 | return $this->ListViewForm()->forTemplate(); |
||
| 182 | }); |
||
| 183 | |||
| 184 | // PageList view |
||
| 185 | $negotiator->setCallback('Content-PageList', function () { |
||
| 186 | return $this->PageList()->forTemplate(); |
||
| 187 | }); |
||
| 188 | |||
| 189 | // PageList view for edit controller |
||
| 190 | $negotiator->setCallback('Content-PageList-Sidebar', function () { |
||
| 191 | return $this->PageListSidebar()->forTemplate(); |
||
| 192 | }); |
||
| 193 | |||
| 194 | return $negotiator; |
||
| 195 | } |
||
| 196 | |||
| 197 | /** |
||
| 198 | * Get pages listing area |
||
| 199 | * |
||
| 200 | * @return DBHTMLText |
||
| 201 | */ |
||
| 202 | public function PageList() |
||
| 203 | { |
||
| 204 | return $this->renderWith($this->getTemplatesWithSuffix('_PageList')); |
||
| 205 | } |
||
| 206 | |||
| 207 | /** |
||
| 208 | * Page list view for edit-form |
||
| 209 | * |
||
| 210 | * @return DBHTMLText |
||
| 211 | */ |
||
| 212 | public function PageListSidebar() |
||
| 213 | { |
||
| 214 | return $this->renderWith($this->getTemplatesWithSuffix('_PageList_Sidebar')); |
||
| 215 | } |
||
| 216 | |||
| 217 | /** |
||
| 218 | * If this is set to true, the "switchView" context in the |
||
| 219 | * template is shown, with links to the staging and publish site. |
||
| 220 | * |
||
| 221 | * @return boolean |
||
| 222 | */ |
||
| 223 | public function ShowSwitchView() |
||
| 224 | { |
||
| 225 | return true; |
||
| 226 | } |
||
| 227 | |||
| 228 | /** |
||
| 229 | * Overloads the LeftAndMain::ShowView. Allows to pass a page as a parameter, so we are able |
||
| 230 | * to switch view also for archived versions. |
||
| 231 | * |
||
| 232 | * @param SiteTree $page |
||
| 233 | * @return array |
||
| 234 | */ |
||
| 235 | public function SwitchView($page = null) |
||
| 236 | { |
||
| 237 | if (!$page) { |
||
| 238 | $page = $this->currentPage(); |
||
| 239 | } |
||
| 240 | |||
| 241 | if ($page) { |
||
| 242 | $nav = SilverStripeNavigator::get_for_record($page); |
||
| 243 | return $nav['items']; |
||
| 244 | } |
||
| 245 | } |
||
| 246 | |||
| 247 | //------------------------------------------------------------------------------------------// |
||
| 248 | // Main controllers |
||
| 249 | |||
| 250 | //------------------------------------------------------------------------------------------// |
||
| 251 | // Main UI components |
||
| 252 | |||
| 253 | /** |
||
| 254 | * Override {@link LeftAndMain} Link to allow blank URL segment for CMSMain. |
||
| 255 | * |
||
| 256 | * @param string|null $action Action to link to. |
||
| 257 | * @return string |
||
| 258 | */ |
||
| 259 | public function Link($action = null) |
||
| 260 | { |
||
| 261 | $link = Controller::join_links( |
||
| 262 | AdminRootController::admin_url(), |
||
| 263 | $this->stat('url_segment'), // in case we want to change the segment |
||
| 264 | '/', // trailing slash needed if $action is null! |
||
| 265 | "$action" |
||
| 266 | ); |
||
| 267 | $this->extend('updateLink', $link); |
||
| 268 | return $link; |
||
| 269 | } |
||
| 270 | |||
| 271 | public function LinkPages() |
||
| 272 | { |
||
| 273 | return CMSPagesController::singleton()->Link(); |
||
| 274 | } |
||
| 275 | |||
| 276 | public function LinkPagesWithSearch() |
||
| 277 | { |
||
| 278 | return $this->LinkWithSearch($this->LinkPages()); |
||
| 279 | } |
||
| 280 | |||
| 281 | /** |
||
| 282 | * Get link to tree view |
||
| 283 | * |
||
| 284 | * @return string |
||
| 285 | */ |
||
| 286 | public function LinkTreeView() |
||
| 287 | { |
||
| 288 | // Tree view is just default link to main pages section (no /treeview suffix) |
||
| 289 | return $this->LinkWithSearch(CMSMain::singleton()->Link()); |
||
| 290 | } |
||
| 291 | |||
| 292 | /** |
||
| 293 | * Get link to list view |
||
| 294 | * |
||
| 295 | * @return string |
||
| 296 | */ |
||
| 297 | public function LinkListView() |
||
| 298 | { |
||
| 299 | // Note : Force redirect to top level page controller |
||
| 300 | return $this->LinkWithSearch(CMSMain::singleton()->Link('listview')); |
||
| 301 | } |
||
| 302 | |||
| 303 | View Code Duplication | public function LinkPageEdit($id = null) |
|
| 304 | { |
||
| 305 | if (!$id) { |
||
| 306 | $id = $this->currentPageID(); |
||
| 307 | } |
||
| 308 | return $this->LinkWithSearch( |
||
| 309 | Controller::join_links(CMSPageEditController::singleton()->Link('show'), $id) |
||
| 310 | ); |
||
| 311 | } |
||
| 312 | |||
| 313 | View Code Duplication | public function LinkPageSettings() |
|
| 314 | { |
||
| 315 | if ($id = $this->currentPageID()) { |
||
| 316 | return $this->LinkWithSearch( |
||
| 317 | Controller::join_links(CMSPageSettingsController::singleton()->Link('show'), $id) |
||
| 318 | ); |
||
| 319 | } else { |
||
| 320 | return null; |
||
| 321 | } |
||
| 322 | } |
||
| 323 | |||
| 324 | View Code Duplication | public function LinkPageHistory() |
|
| 325 | { |
||
| 326 | if ($id = $this->currentPageID()) { |
||
| 327 | return $this->LinkWithSearch( |
||
| 328 | Controller::join_links(CMSPageHistoryController::singleton()->Link('show'), $id) |
||
| 329 | ); |
||
| 330 | } else { |
||
| 331 | return null; |
||
| 332 | } |
||
| 333 | } |
||
| 334 | |||
| 335 | public function LinkWithSearch($link) |
||
| 336 | { |
||
| 337 | // Whitelist to avoid side effects |
||
| 338 | $params = array( |
||
| 339 | 'q' => (array)$this->getRequest()->getVar('q'), |
||
| 340 | 'ParentID' => $this->getRequest()->getVar('ParentID') |
||
| 341 | ); |
||
| 342 | $link = Controller::join_links( |
||
| 343 | $link, |
||
| 344 | array_filter(array_values($params)) ? '?' . http_build_query($params) : null |
||
| 345 | ); |
||
| 346 | $this->extend('updateLinkWithSearch', $link); |
||
| 347 | return $link; |
||
| 348 | } |
||
| 349 | |||
| 350 | public function LinkPageAdd($extra = null, $placeholders = null) |
||
| 351 | { |
||
| 352 | $link = CMSPageAddController::singleton()->Link(); |
||
| 353 | $this->extend('updateLinkPageAdd', $link); |
||
| 354 | |||
| 355 | if ($extra) { |
||
| 356 | $link = Controller::join_links($link, $extra); |
||
| 357 | } |
||
| 358 | |||
| 359 | if ($placeholders) { |
||
| 360 | $link .= (strpos($link, '?') === false ? "?$placeholders" : "&$placeholders"); |
||
| 361 | } |
||
| 362 | |||
| 363 | return $link; |
||
| 364 | } |
||
| 365 | |||
| 366 | /** |
||
| 367 | * @return string |
||
| 368 | */ |
||
| 369 | public function LinkPreview() |
||
| 370 | { |
||
| 371 | $record = $this->getRecord($this->currentPageID()); |
||
| 372 | $baseLink = Director::absoluteBaseURL(); |
||
| 373 | if ($record && $record instanceof SiteTree) { |
||
| 374 | // if we are an external redirector don't show a link |
||
| 375 | if ($record instanceof RedirectorPage && $record->RedirectionType == 'External') { |
||
| 376 | $baseLink = false; |
||
| 377 | } else { |
||
| 378 | $baseLink = $record->Link('?stage=Stage'); |
||
| 379 | } |
||
| 380 | } |
||
| 381 | return $baseLink; |
||
| 382 | } |
||
| 383 | |||
| 384 | /** |
||
| 385 | * Return the entire site tree as a nested set of ULs |
||
| 386 | */ |
||
| 387 | public function SiteTreeAsUL() |
||
| 388 | { |
||
| 389 | // Pre-cache sitetree version numbers for querying efficiency |
||
| 390 | Versioned::prepopulate_versionnumber_cache(SiteTree::class, "Stage"); |
||
| 391 | Versioned::prepopulate_versionnumber_cache(SiteTree::class, "Live"); |
||
| 392 | $html = $this->getSiteTreeFor($this->stat('tree_class')); |
||
| 393 | |||
| 394 | $this->extend('updateSiteTreeAsUL', $html); |
||
| 395 | |||
| 396 | return $html; |
||
| 397 | } |
||
| 398 | |||
| 399 | /** |
||
| 400 | * @return boolean |
||
| 401 | */ |
||
| 402 | public function TreeIsFiltered() |
||
| 403 | { |
||
| 404 | $query = $this->getRequest()->getVar('q'); |
||
| 405 | |||
| 406 | if (!$query || (count($query) === 1 && isset($query['FilterClass']) && $query['FilterClass'] === 'SilverStripe\\CMS\\Controllers\\CMSSiteTreeFilter_Search')) { |
||
| 407 | return false; |
||
| 408 | } |
||
| 409 | |||
| 410 | return true; |
||
| 411 | } |
||
| 412 | |||
| 413 | public function ExtraTreeTools() |
||
| 414 | { |
||
| 415 | $html = ''; |
||
| 416 | $this->extend('updateExtraTreeTools', $html); |
||
| 417 | return $html; |
||
| 418 | } |
||
| 419 | |||
| 420 | /** |
||
| 421 | * Returns a Form for page searching for use in templates. |
||
| 422 | * |
||
| 423 | * Can be modified from a decorator by a 'updateSearchForm' method |
||
| 424 | * |
||
| 425 | * @return Form |
||
| 426 | */ |
||
| 427 | public function SearchForm() |
||
| 428 | { |
||
| 429 | // Create the fields |
||
| 430 | $content = new TextField('q[Term]', _t('CMSSearch.FILTERLABELTEXT', 'Search')); |
||
| 431 | $dateFrom = new DateField( |
||
| 432 | 'q[LastEditedFrom]', |
||
| 433 | _t('CMSSearch.FILTERDATEFROM', 'From') |
||
| 434 | ); |
||
| 435 | $dateTo = new DateField( |
||
| 436 | 'q[LastEditedTo]', |
||
| 437 | _t('CMSSearch.FILTERDATETO', 'To') |
||
| 438 | ); |
||
| 439 | $pageFilter = new DropdownField( |
||
| 440 | 'q[FilterClass]', |
||
| 441 | _t('CMSMain.PAGES', 'Page status'), |
||
| 442 | CMSSiteTreeFilter::get_all_filters() |
||
| 443 | ); |
||
| 444 | $pageClasses = new DropdownField( |
||
| 445 | 'q[ClassName]', |
||
| 446 | _t('CMSMain.PAGETYPEOPT', 'Page type', 'Dropdown for limiting search to a page type'), |
||
| 447 | $this->getPageTypes() |
||
| 448 | ); |
||
| 449 | $pageClasses->setEmptyString(_t('CMSMain.PAGETYPEANYOPT', 'Any')); |
||
| 450 | |||
| 451 | // Group the Datefields |
||
| 452 | $dateGroup = new FieldGroup( |
||
| 453 | $dateFrom, |
||
| 454 | $dateTo |
||
| 455 | ); |
||
| 456 | $dateGroup->setTitle(_t('CMSSearch.PAGEFILTERDATEHEADING', 'Last edited')); |
||
| 457 | |||
| 458 | // view mode |
||
| 459 | $viewMode = HiddenField::create('view', false, $this->ViewState()); |
||
| 460 | |||
| 461 | // Create the Field list |
||
| 462 | $fields = new FieldList( |
||
| 463 | $content, |
||
| 464 | $pageFilter, |
||
| 465 | $pageClasses, |
||
| 466 | $dateGroup, |
||
| 467 | $viewMode |
||
| 468 | ); |
||
| 469 | |||
| 470 | // Create the Search and Reset action |
||
| 471 | $actions = new FieldList( |
||
| 472 | FormAction::create('doSearch', _t('CMSMain_left_ss.APPLY_FILTER', 'Search')) |
||
| 473 | ->addExtraClass('btn btn-primary'), |
||
| 474 | ResetFormAction::create('clear', _t('CMSMain_left_ss.CLEAR_FILTER', 'Clear')) |
||
| 475 | ->addExtraClass('btn btn-secondary') |
||
| 476 | ); |
||
| 477 | |||
| 478 | // Use <button> to allow full jQuery UI styling on the all of the Actions |
||
| 479 | /** @var FormAction $action */ |
||
| 480 | foreach ($actions->dataFields() as $action) { |
||
| 481 | /** @var FormAction $action */ |
||
| 482 | $action->setUseButtonTag(true); |
||
| 483 | } |
||
| 484 | |||
| 485 | // Create the form |
||
| 486 | /** @skipUpgrade */ |
||
| 487 | $form = Form::create($this, 'SearchForm', $fields, $actions) |
||
| 488 | ->addExtraClass('cms-search-form') |
||
| 489 | ->setFormMethod('GET') |
||
| 490 | ->setFormAction($this->Link()) |
||
| 491 | ->disableSecurityToken() |
||
| 492 | ->unsetValidator(); |
||
| 493 | |||
| 494 | // Load the form with previously sent search data |
||
| 495 | $form->loadDataFrom($this->getRequest()->getVars()); |
||
| 496 | |||
| 497 | // Allow decorators to modify the form |
||
| 498 | $this->extend('updateSearchForm', $form); |
||
| 499 | |||
| 500 | return $form; |
||
| 501 | } |
||
| 502 | |||
| 503 | /** |
||
| 504 | * Returns a sorted array suitable for a dropdown with pagetypes and their translated name |
||
| 505 | * |
||
| 506 | * @return array |
||
| 507 | */ |
||
| 508 | protected function getPageTypes() |
||
| 517 | |||
| 518 | public function doSearch($data, $form) |
||
| 522 | |||
| 523 | /** |
||
| 524 | * @param bool $unlinked |
||
| 525 | * @return ArrayList |
||
| 526 | */ |
||
| 527 | public function Breadcrumbs($unlinked = false) |
||
| 539 | |||
| 540 | /** |
||
| 541 | * Create serialized JSON string with site tree hints data to be injected into |
||
| 542 | * 'data-hints' attribute of root node of jsTree. |
||
| 543 | * |
||
| 544 | * @return string Serialized JSON |
||
| 545 | */ |
||
| 546 | public function SiteTreeHints() |
||
| 612 | |||
| 613 | /** |
||
| 614 | * Populates an array of classes in the CMS |
||
| 615 | * which allows the user to change the page type. |
||
| 616 | * |
||
| 617 | * @return SS_List |
||
| 618 | */ |
||
| 619 | public function PageTypes() |
||
| 620 | { |
||
| 621 | $classes = SiteTree::page_type_classes(); |
||
| 622 | |||
| 623 | $result = new ArrayList(); |
||
| 624 | |||
| 625 | foreach ($classes as $class) { |
||
| 626 | $instance = SiteTree::singleton($class); |
||
| 627 | if ($instance instanceof HiddenClass) { |
||
| 628 | continue; |
||
| 629 | } |
||
| 630 | |||
| 631 | // skip this type if it is restricted |
||
| 632 | if ($instance->stat('need_permission') && !$this->can(singleton($class)->stat('need_permission'))) { |
||
| 633 | continue; |
||
| 634 | } |
||
| 653 | |||
| 654 | /** |
||
| 655 | * Get a database record to be managed by the CMS. |
||
| 656 | * |
||
| 657 | * @param int $id Record ID |
||
| 658 | * @param int $versionID optional Version id of the given record |
||
| 659 | * @return SiteTree |
||
| 660 | */ |
||
| 661 | public function getRecord($id, $versionID = null) |
||
| 713 | |||
| 714 | /** |
||
| 715 | * @param int $id |
||
| 716 | * @param FieldList $fields |
||
| 717 | * @return Form |
||
| 718 | */ |
||
| 719 | public function getEditForm($id = null, $fields = null) |
||
| 830 | |||
| 831 | /** |
||
| 832 | * @param HTTPRequest $request |
||
| 833 | * @return string HTML |
||
| 834 | */ |
||
| 835 | public function treeview($request) |
||
| 839 | |||
| 840 | /** |
||
| 841 | * @param HTTPRequest $request |
||
| 842 | * @return string HTML |
||
| 843 | */ |
||
| 844 | public function listview($request) |
||
| 848 | |||
| 849 | /** |
||
| 850 | * @return string |
||
| 851 | */ |
||
| 852 | public function ViewState() |
||
| 864 | |||
| 865 | /** |
||
| 866 | * Callback to request the list of page types allowed under a given page instance. |
||
| 867 | * Provides a slower but more precise response over SiteTreeHints |
||
| 868 | * |
||
| 869 | * @param HTTPRequest $request |
||
| 870 | * @return HTTPResponse |
||
| 871 | */ |
||
| 872 | public function childfilter($request) |
||
| 902 | |||
| 903 | /** |
||
| 904 | * Safely reconstruct a selected filter from a given set of query parameters |
||
| 905 | * |
||
| 906 | * @param array $params Query parameters to use |
||
| 907 | * @return CMSSiteTreeFilter The filter class, or null if none present |
||
| 908 | * @throws InvalidArgumentException if invalid filter class is passed. |
||
| 909 | */ |
||
| 910 | protected function getQueryFilter($params) |
||
| 921 | |||
| 922 | /** |
||
| 923 | * Returns the pages meet a certain criteria as {@see CMSSiteTreeFilter} or the subpages of a parent page |
||
| 924 | * defaulting to no filter and show all pages in first level. |
||
| 925 | * Doubles as search results, if any search parameters are set through {@link SearchForm()}. |
||
| 926 | * |
||
| 927 | * @param array $params Search filter criteria |
||
| 928 | * @param int $parentID Optional parent node to filter on (can't be combined with other search criteria) |
||
| 929 | * @return SS_List |
||
| 930 | * @throws InvalidArgumentException if invalid filter class is passed. |
||
| 931 | */ |
||
| 932 | public function getList($params = array(), $parentID = 0) |
||
| 942 | |||
| 943 | /** |
||
| 944 | * @return Form |
||
| 945 | */ |
||
| 946 | public function ListViewForm() |
||
| 1043 | |||
| 1044 | public function currentPageID() |
||
| 1052 | |||
| 1053 | //------------------------------------------------------------------------------------------// |
||
| 1054 | // Data saving handlers |
||
| 1055 | |||
| 1056 | /** |
||
| 1057 | * Save and Publish page handler |
||
| 1058 | * |
||
| 1059 | * @param array $data |
||
| 1060 | * @param Form $form |
||
| 1061 | * @return HTTPResponse |
||
| 1062 | * @throws HTTPResponse_Exception |
||
| 1063 | */ |
||
| 1064 | public function save($data, $form) |
||
| 1131 | |||
| 1132 | /** |
||
| 1133 | * @uses LeftAndMainExtension->augmentNewSiteTreeItem() |
||
| 1134 | * |
||
| 1135 | * @param int|string $id |
||
| 1136 | * @param bool $setID |
||
| 1137 | * @return mixed|DataObject |
||
| 1138 | * @throws HTTPResponse_Exception |
||
| 1139 | */ |
||
| 1140 | public function getNewItem($id, $setID = true) |
||
| 1191 | |||
| 1192 | /** |
||
| 1193 | * Actually perform the publication step |
||
| 1194 | * |
||
| 1195 | * @param Versioned|DataObject $record |
||
| 1196 | * @return mixed |
||
| 1197 | */ |
||
| 1198 | public function performPublish($record) |
||
| 1206 | |||
| 1207 | /** |
||
| 1208 | * Reverts a page by publishing it to live. |
||
| 1209 | * Use {@link restorepage()} if you want to restore a page |
||
| 1210 | * which was deleted from draft without publishing. |
||
| 1211 | * |
||
| 1212 | * @uses SiteTree->doRevertToLive() |
||
| 1213 | * |
||
| 1214 | * @param array $data |
||
| 1215 | * @param Form $form |
||
| 1216 | * @return HTTPResponse |
||
| 1217 | * @throws HTTPResponse_Exception |
||
| 1218 | */ |
||
| 1219 | public function revert($data, $form) |
||
| 1259 | |||
| 1260 | /** |
||
| 1261 | * Delete the current page from draft stage. |
||
| 1262 | * |
||
| 1263 | * @see deletefromlive() |
||
| 1264 | * |
||
| 1265 | * @param array $data |
||
| 1266 | * @param Form $form |
||
| 1267 | * @return HTTPResponse |
||
| 1268 | * @throws HTTPResponse_Exception |
||
| 1269 | */ |
||
| 1270 | View Code Duplication | public function delete($data, $form) |
|
| 1292 | |||
| 1293 | /** |
||
| 1294 | * Delete this page from both live and stage |
||
| 1295 | * |
||
| 1296 | * @param array $data |
||
| 1297 | * @param Form $form |
||
| 1298 | * @return HTTPResponse |
||
| 1299 | * @throws HTTPResponse_Exception |
||
| 1300 | */ |
||
| 1301 | View Code Duplication | public function archive($data, $form) |
|
| 1324 | |||
| 1325 | public function publish($data, $form) |
||
| 1331 | |||
| 1332 | public function unpublish($data, $form) |
||
| 1354 | |||
| 1355 | /** |
||
| 1356 | * @return HTTPResponse |
||
| 1357 | */ |
||
| 1358 | public function rollback() |
||
| 1365 | |||
| 1366 | /** |
||
| 1367 | * Rolls a site back to a given version ID |
||
| 1368 | * |
||
| 1369 | * @param array $data |
||
| 1370 | * @param Form $form |
||
| 1371 | * @return HTTPResponse |
||
| 1372 | */ |
||
| 1373 | public function doRollback($data, $form) |
||
| 1413 | |||
| 1414 | /** |
||
| 1415 | * Batch Actions Handler |
||
| 1416 | */ |
||
| 1417 | public function batchactions() |
||
| 1421 | |||
| 1422 | public function BatchActionParameters() |
||
| 1444 | /** |
||
| 1445 | * Returns a list of batch actions |
||
| 1446 | */ |
||
| 1447 | public function BatchActionList() |
||
| 1451 | |||
| 1452 | public function publishall($request) |
||
| 1516 | |||
| 1517 | /** |
||
| 1518 | * Restore a completely deleted page from the SiteTree_versions table. |
||
| 1519 | * |
||
| 1520 | * @param array $data |
||
| 1521 | * @param Form $form |
||
| 1522 | * @return HTTPResponse |
||
| 1523 | */ |
||
| 1524 | public function restore($data, $form) |
||
| 1550 | |||
| 1551 | public function duplicate($request) |
||
| 1594 | |||
| 1595 | public function duplicatewithchildren($request) |
||
| 1632 | |||
| 1633 | public function providePermissions() |
||
| 1648 | } |
||
| 1649 |