| Total Complexity | 86 |
| Total Lines | 738 |
| Duplicated Lines | 4.07 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
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 BaseElement 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.
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 BaseElement, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 44 | class BaseElement extends DataObject implements CMSPreviewable |
||
| 45 | { |
||
| 46 | /** |
||
| 47 | * Override this on your custom elements to specify a cms icon |
||
| 48 | * |
||
| 49 | * @var string |
||
| 50 | */ |
||
| 51 | private static $icon = 'dnadesign/silverstripe-elemental:images/base.svg'; |
||
|
|
|||
| 52 | |||
| 53 | private static $db = [ |
||
| 54 | 'Title' => 'Varchar(255)', |
||
| 55 | 'ShowTitle' => 'Boolean', |
||
| 56 | 'Sort' => 'Int', |
||
| 57 | 'ExtraClass' => 'Varchar(255)', |
||
| 58 | 'Style' => 'Varchar(255)' |
||
| 59 | ]; |
||
| 60 | |||
| 61 | private static $has_one = [ |
||
| 62 | 'Parent' => ElementalArea::class |
||
| 63 | ]; |
||
| 64 | |||
| 65 | private static $extensions = [ |
||
| 66 | Versioned::class |
||
| 67 | ]; |
||
| 68 | |||
| 69 | private static $versioned_gridfield_extensions = true; |
||
| 70 | |||
| 71 | private static $table_name = 'Element'; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @var string |
||
| 75 | */ |
||
| 76 | private static $controller_class = ElementController::class; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @var string |
||
| 80 | */ |
||
| 81 | private static $controller_template = 'ElementHolder'; |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @var ElementController |
||
| 85 | */ |
||
| 86 | protected $controller; |
||
| 87 | |||
| 88 | private static $default_sort = 'Sort'; |
||
| 89 | |||
| 90 | private static $singular_name = 'block'; |
||
| 91 | |||
| 92 | private static $plural_name = 'blocks'; |
||
| 93 | |||
| 94 | private static $summary_fields = [ |
||
| 95 | 'EditorPreview' => 'Summary' |
||
| 96 | ]; |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @var array |
||
| 100 | */ |
||
| 101 | private static $styles = []; |
||
| 102 | |||
| 103 | private static $searchable_fields = [ |
||
| 104 | 'ID' => [ |
||
| 105 | 'field' => NumericField::class, |
||
| 106 | ], |
||
| 107 | 'Title', |
||
| 108 | 'LastEdited' |
||
| 109 | ]; |
||
| 110 | |||
| 111 | /** |
||
| 112 | * Enable for backwards compatibility |
||
| 113 | * |
||
| 114 | * @var boolean |
||
| 115 | */ |
||
| 116 | private static $disable_pretty_anchor_name = false; |
||
| 117 | |||
| 118 | /** |
||
| 119 | * Store used anchor names, this is to avoid title clashes |
||
| 120 | * when calling 'getAnchor' |
||
| 121 | * |
||
| 122 | * @var array |
||
| 123 | */ |
||
| 124 | protected static $_used_anchors = []; |
||
| 125 | |||
| 126 | /** |
||
| 127 | * For caching 'getAnchor' |
||
| 128 | * |
||
| 129 | * @var string |
||
| 130 | */ |
||
| 131 | protected $_anchor = null; |
||
| 132 | |||
| 133 | /** |
||
| 134 | * Basic permissions, defaults to page perms where possible. |
||
| 135 | * |
||
| 136 | * @param Member $member |
||
| 137 | * |
||
| 138 | * @return boolean |
||
| 139 | */ |
||
| 140 | View Code Duplication | public function canView($member = null) |
|
| 141 | { |
||
| 142 | if ($this->hasMethod('getPage')) { |
||
| 143 | if ($page = $this->getPage()) { |
||
| 144 | return $page->canView($member); |
||
| 145 | } |
||
| 146 | } |
||
| 147 | |||
| 148 | return (Permission::check('CMS_ACCESS', 'any', $member)) ? true : null; |
||
| 149 | } |
||
| 150 | |||
| 151 | /** |
||
| 152 | * Basic permissions, defaults to page perms where possible. |
||
| 153 | * |
||
| 154 | * @param Member $member |
||
| 155 | * |
||
| 156 | * @return boolean |
||
| 157 | */ |
||
| 158 | View Code Duplication | public function canEdit($member = null) |
|
| 159 | { |
||
| 160 | if ($this->hasMethod('getPage')) { |
||
| 161 | if ($page = $this->getPage()) { |
||
| 162 | return $page->canEdit($member); |
||
| 163 | } |
||
| 164 | } |
||
| 165 | |||
| 166 | return (Permission::check('CMS_ACCESS', 'any', $member)) ? true : null; |
||
| 167 | } |
||
| 168 | |||
| 169 | /** |
||
| 170 | * Basic permissions, defaults to page perms where possible. |
||
| 171 | * |
||
| 172 | * Uses archive not delete so that current stage is respected i.e if a |
||
| 173 | * element is not published, then it can be deleted by someone who doesn't |
||
| 174 | * have publishing permissions. |
||
| 175 | * |
||
| 176 | * @param Member $member |
||
| 177 | * |
||
| 178 | * @return boolean |
||
| 179 | */ |
||
| 180 | View Code Duplication | public function canDelete($member = null) |
|
| 189 | } |
||
| 190 | |||
| 191 | /** |
||
| 192 | * Basic permissions, defaults to page perms where possible. |
||
| 193 | * |
||
| 194 | * @param Member $member |
||
| 195 | * @param array $context |
||
| 196 | * |
||
| 197 | * @return boolean |
||
| 198 | */ |
||
| 199 | public function canCreate($member = null, $context = array()) |
||
| 200 | { |
||
| 201 | return (Permission::check('CMS_ACCESS', 'any', $member)) ? true : null; |
||
| 202 | } |
||
| 203 | |||
| 204 | /** |
||
| 205 | * |
||
| 206 | */ |
||
| 207 | public function onBeforeWrite() |
||
| 208 | { |
||
| 209 | parent::onBeforeWrite(); |
||
| 210 | |||
| 211 | if ($areaID = $this->ParentID) { |
||
| 212 | if ($elementalArea = ElementalArea::get()->byID($areaID)) { |
||
| 213 | $elementalArea->write(); |
||
| 214 | } |
||
| 215 | } |
||
| 216 | |||
| 217 | if (!$this->Sort) { |
||
| 218 | $parentID = ($this->ParentID) ? $this->ParentID : 0; |
||
| 219 | |||
| 220 | $this->Sort = static::get()->max('Sort') + 1; |
||
| 221 | } |
||
| 222 | } |
||
| 223 | |||
| 224 | public function getCMSFields() |
||
| 289 | } |
||
| 290 | |||
| 291 | /** |
||
| 292 | * Returns the history fields for this element. |
||
| 293 | * |
||
| 294 | * @return FieldList |
||
| 295 | */ |
||
| 296 | public function getHistoryFields() |
||
| 297 | { |
||
| 298 | if (!$this->isLatestVersion()) { |
||
| 299 | // if viewing the history of the of page then don't show the history |
||
| 300 | // fields as then we have recursion. |
||
| 301 | return null; |
||
| 302 | } |
||
| 303 | |||
| 304 | $config = GridFieldConfig_RecordViewer::create(); |
||
| 305 | $config->removeComponentsByType(GridFieldPageCount::class); |
||
| 306 | |||
| 307 | $config |
||
| 308 | ->getComponentByType(GridFieldDetailForm::class) |
||
| 309 | ->setItemRequestClass(HistoricalVersionedGridFieldItemRequest::class); |
||
| 310 | |||
| 311 | $config->getComponentByType(GridFieldDataColumns::class) |
||
| 312 | ->setDisplayFields([ |
||
| 313 | 'Version' => '#', |
||
| 314 | 'RecordStatus' => _t(__CLASS__ . '.Record', 'Record'), |
||
| 315 | 'getAuthor.Name' => _t(__CLASS__ . '.Author', 'Author') |
||
| 316 | ]) |
||
| 317 | ->setFieldFormatting([ |
||
| 318 | 'RecordStatus' => '$VersionedStateNice <span class=\"element-history__date--small\">on $LastEditedNice</span>', |
||
| 319 | ]); |
||
| 320 | |||
| 321 | $config->removeComponentsByType(GridFieldViewButton::class); |
||
| 322 | $config->addComponent(new ElementalGridFieldHistoryButton()); |
||
| 323 | |||
| 324 | $history = Versioned::get_all_versions(__CLASS__, $this->ID) |
||
| 325 | ->sort('Version', 'DESC'); |
||
| 326 | |||
| 327 | return FieldList::create( |
||
| 328 | GridField::create( |
||
| 329 | 'History', |
||
| 330 | '', |
||
| 331 | $history, |
||
| 332 | $config |
||
| 333 | ) |
||
| 334 | ); |
||
| 335 | } |
||
| 336 | |||
| 337 | /** |
||
| 338 | * Get the type of the current block, for use in GridField summaries, block |
||
| 339 | * type dropdowns etc. Examples are "Content", "File", "Media", etc. |
||
| 340 | * |
||
| 341 | * @return string |
||
| 342 | */ |
||
| 343 | public function getType() |
||
| 344 | { |
||
| 345 | return _t(__CLASS__ . '.BlockType', 'Block'); |
||
| 346 | } |
||
| 347 | |||
| 348 | /** |
||
| 349 | * @param ElementController |
||
| 350 | * |
||
| 351 | * @return $this |
||
| 352 | */ |
||
| 353 | public function setController($controller) |
||
| 354 | { |
||
| 355 | $this->controller = $controller; |
||
| 356 | |||
| 357 | return $this; |
||
| 358 | } |
||
| 359 | |||
| 360 | /** |
||
| 361 | * @throws Exception |
||
| 362 | * |
||
| 363 | * @return ElementController |
||
| 364 | */ |
||
| 365 | public function getController() |
||
| 366 | { |
||
| 367 | if ($this->controller) { |
||
| 368 | return $this->controller; |
||
| 369 | } |
||
| 370 | |||
| 371 | $controllerClass = self::config()->controller_class; |
||
| 372 | |||
| 373 | if (!class_exists($controllerClass)) { |
||
| 374 | throw new Exception('Could not find controller class ' . $controllerClass . ' as defined in ' . static::class); |
||
| 375 | } |
||
| 376 | |||
| 377 | $this->controller = Injector::inst()->create($controllerClass, $this); |
||
| 378 | $this->controller->doInit(); |
||
| 379 | |||
| 380 | return $this->controller; |
||
| 381 | } |
||
| 382 | |||
| 383 | /** |
||
| 384 | * @return Controller |
||
| 385 | */ |
||
| 386 | public function Top() |
||
| 387 | { |
||
| 388 | return (Controller::has_curr()) ? Controller::curr() : null; |
||
| 389 | } |
||
| 390 | |||
| 391 | /** |
||
| 392 | * Default way to render element in templates. Note that all blocks should |
||
| 393 | * be rendered through their {@link ElementController} class as this |
||
| 394 | * contains the holder styles. |
||
| 395 | * |
||
| 396 | * @return string HTML |
||
| 397 | */ |
||
| 398 | public function forTemplate($holder = true) |
||
| 399 | { |
||
| 400 | $templates = $this->getRenderTemplates(); |
||
| 401 | |||
| 402 | if ($templates) { |
||
| 403 | return $this->renderWith($templates); |
||
| 404 | } |
||
| 405 | } |
||
| 406 | |||
| 407 | /** |
||
| 408 | * @param string $suffix |
||
| 409 | * |
||
| 410 | * @return array |
||
| 411 | */ |
||
| 412 | public function getRenderTemplates($suffix = '') |
||
| 413 | { |
||
| 414 | $classes = ClassInfo::ancestry($this->ClassName); |
||
| 415 | $classes[static::class] = static::class; |
||
| 416 | $classes = array_reverse($classes); |
||
| 417 | $templates = array(); |
||
| 418 | |||
| 419 | foreach ($classes as $key => $value) { |
||
| 420 | if ($value == BaseElement::class) { |
||
| 421 | continue; |
||
| 422 | } |
||
| 423 | |||
| 424 | if ($value == DataObject::class) { |
||
| 425 | break; |
||
| 426 | } |
||
| 427 | |||
| 428 | $templates[] = $value . $suffix; |
||
| 429 | } |
||
| 430 | |||
| 431 | return $templates; |
||
| 432 | } |
||
| 433 | |||
| 434 | /** |
||
| 435 | * Strip all namespaces from class namespace. |
||
| 436 | * |
||
| 437 | * @param string $classname e.g. "\Fully\Namespaced\Class" |
||
| 438 | * |
||
| 439 | * @return string following the param example, "Class" |
||
| 440 | */ |
||
| 441 | protected function stripNamespacing($classname) |
||
| 442 | { |
||
| 443 | $classParts = explode('\\', $classname); |
||
| 444 | return array_pop($classParts); |
||
| 445 | } |
||
| 446 | |||
| 447 | /** |
||
| 448 | * @return string |
||
| 449 | */ |
||
| 450 | public function getSimpleClassName() |
||
| 451 | { |
||
| 452 | return strtolower($this->sanitiseClassName($this->ClassName, '__')); |
||
| 453 | } |
||
| 454 | |||
| 455 | /** |
||
| 456 | * @return SiteTree |
||
| 457 | */ |
||
| 458 | public function getPage() |
||
| 459 | { |
||
| 460 | $area = $this->Parent(); |
||
| 461 | |||
| 462 | if ($area instanceof ElementalArea && $area->exists()) { |
||
| 463 | return $area->getOwnerPage(); |
||
| 464 | } |
||
| 465 | |||
| 466 | return null; |
||
| 467 | } |
||
| 468 | |||
| 469 | /** |
||
| 470 | * Get a unique anchor name |
||
| 471 | * |
||
| 472 | * @return string |
||
| 473 | */ |
||
| 474 | public function getAnchor() |
||
| 475 | { |
||
| 476 | if ($this->_anchor !== null) { |
||
| 477 | return $this->_anchor; |
||
| 478 | } |
||
| 479 | |||
| 480 | $anchorTitle = ''; |
||
| 481 | |||
| 482 | if (!$this->config()->disable_pretty_anchor_name) { |
||
| 483 | if ($this->hasMethod('getAnchorTitle')) { |
||
| 484 | $anchorTitle = $this->getAnchorTitle(); |
||
| 485 | } elseif ($this->config()->enable_title_in_template) { |
||
| 486 | $anchorTitle = $this->getField('Title'); |
||
| 487 | } |
||
| 488 | } |
||
| 489 | |||
| 490 | if (!$anchorTitle) { |
||
| 491 | $anchorTitle = 'e'.$this->ID; |
||
| 492 | } |
||
| 493 | |||
| 494 | $filter = URLSegmentFilter::create(); |
||
| 495 | $titleAsURL = $filter->filter($anchorTitle); |
||
| 496 | |||
| 497 | // Ensure that this anchor name isn't already in use |
||
| 498 | // ie. If two elemental blocks have the same title, it'll append '-2', '-3' |
||
| 499 | $result = $titleAsURL; |
||
| 500 | $count = 1; |
||
| 501 | while (isset(self::$_used_anchors[$result]) && self::$_used_anchors[$result] !== $this->ID) { |
||
| 502 | ++$count; |
||
| 503 | $result = $titleAsURL.'-'.$count; |
||
| 504 | } |
||
| 505 | self::$_used_anchors[$result] = $this->ID; |
||
| 506 | return $this->_anchor = $result; |
||
| 507 | } |
||
| 508 | |||
| 509 | /** |
||
| 510 | * @param string $action |
||
| 511 | * |
||
| 512 | * @return string |
||
| 513 | */ |
||
| 514 | public function AbsoluteLink($action = null) |
||
| 515 | { |
||
| 516 | if ($page = $this->getPage()) { |
||
| 517 | $link = $page->AbsoluteLink($action) . '#' . $this->getAnchor(); |
||
| 518 | |||
| 519 | return $link; |
||
| 520 | } |
||
| 521 | } |
||
| 522 | |||
| 523 | /** |
||
| 524 | * @param string $action |
||
| 525 | * |
||
| 526 | * @return string |
||
| 527 | */ |
||
| 528 | public function Link($action = null) |
||
| 529 | { |
||
| 530 | if ($page = $this->getPage()) { |
||
| 531 | $link = $page->Link($action) . '#' . $this->getAnchor(); |
||
| 532 | |||
| 533 | $this->extend('updateLink', $link); |
||
| 534 | |||
| 535 | return $link; |
||
| 536 | } |
||
| 537 | } |
||
| 538 | |||
| 539 | /** |
||
| 540 | * @param string $action |
||
| 541 | * |
||
| 542 | * @return string |
||
| 543 | */ |
||
| 544 | public function PreviewLink($action = null) |
||
| 545 | { |
||
| 546 | $action = $action . '?ElementalPreview=' . mt_rand(); |
||
| 547 | $link = $this->Link($action); |
||
| 548 | $this->extend('updatePreviewLink', $link); |
||
| 549 | |||
| 550 | return $link; |
||
| 551 | } |
||
| 552 | |||
| 553 | /** |
||
| 554 | * @return boolean |
||
| 555 | */ |
||
| 556 | public function isCMSPreview() |
||
| 557 | { |
||
| 558 | if (Controller::has_curr()) { |
||
| 559 | $c = Controller::curr(); |
||
| 560 | |||
| 561 | if ($c->getRequest()->requestVar('CMSPreview')) { |
||
| 562 | return true; |
||
| 563 | } |
||
| 564 | } |
||
| 565 | |||
| 566 | return false; |
||
| 567 | } |
||
| 568 | |||
| 569 | /** |
||
| 570 | * @return string |
||
| 571 | */ |
||
| 572 | public function CMSEditLink() |
||
| 573 | { |
||
| 574 | $relationName = $this->getAreaRelationName(); |
||
| 575 | $page = $this->getPage(true); |
||
| 576 | |||
| 577 | if (!$page) { |
||
| 578 | return null; |
||
| 579 | } |
||
| 580 | |||
| 581 | $link = Controller::join_links( |
||
| 582 | singleton(CMSPageEditController::class)->Link('EditForm'), |
||
| 583 | $page->ID, |
||
| 584 | 'field/' . $relationName . '/item/', |
||
| 585 | $this->ID |
||
| 586 | ); |
||
| 587 | |||
| 588 | return Controller::join_links( |
||
| 589 | $link, |
||
| 590 | 'edit' |
||
| 591 | ); |
||
| 592 | } |
||
| 593 | |||
| 594 | /** |
||
| 595 | * Retrieve a elemental area relation for creating cms links |
||
| 596 | * |
||
| 597 | * @return string - the name of a valid elemental area relation |
||
| 598 | */ |
||
| 599 | public function getAreaRelationName() |
||
| 600 | { |
||
| 601 | $page = $this->getPage(true); |
||
| 602 | |||
| 603 | if ($page) { |
||
| 604 | $has_one = $page->config()->get('has_one'); |
||
| 605 | $area = $this->Parent(); |
||
| 606 | |||
| 607 | foreach ($has_one as $relationName => $relationClass) { |
||
| 608 | if ($relationClass === $area->ClassName) { |
||
| 609 | return $relationName; |
||
| 610 | } |
||
| 611 | } |
||
| 612 | } |
||
| 613 | |||
| 614 | return 'ElementalArea'; |
||
| 615 | } |
||
| 616 | |||
| 617 | /** |
||
| 618 | * Sanitise a model class' name for inclusion in a link. |
||
| 619 | * |
||
| 620 | * @return string |
||
| 621 | */ |
||
| 622 | public function sanitiseClassName($class, $delimiter = '-') |
||
| 623 | { |
||
| 624 | return str_replace('\\', $delimiter, $class); |
||
| 625 | } |
||
| 626 | |||
| 627 | public function unsanitiseClassName($class, $delimiter = '-') |
||
| 628 | { |
||
| 629 | return str_replace($delimiter, '\\', $class); |
||
| 630 | } |
||
| 631 | |||
| 632 | /** |
||
| 633 | * @return string |
||
| 634 | */ |
||
| 635 | public function getEditLink() |
||
| 636 | { |
||
| 637 | return $this->CMSEditLink(); |
||
| 638 | } |
||
| 639 | |||
| 640 | /** |
||
| 641 | * @return HTMLText |
||
| 642 | */ |
||
| 643 | public function PageCMSEditLink() |
||
| 644 | { |
||
| 645 | if ($page = $this->getPage()) { |
||
| 646 | return DBField::create_field('HTMLText', sprintf( |
||
| 647 | '<a href="%s">%s</a>', |
||
| 648 | $page->CMSEditLink(), |
||
| 649 | $page->Title |
||
| 650 | )); |
||
| 651 | } |
||
| 652 | } |
||
| 653 | |||
| 654 | /** |
||
| 655 | * @return string |
||
| 656 | */ |
||
| 657 | public function getMimeType() |
||
| 658 | { |
||
| 659 | return 'text/html'; |
||
| 660 | } |
||
| 661 | |||
| 662 | /** |
||
| 663 | * This can be overridden on child elements to create a summary for display |
||
| 664 | * in GridFields. |
||
| 665 | * |
||
| 666 | * @return string |
||
| 667 | */ |
||
| 668 | public function getSummary() |
||
| 669 | { |
||
| 670 | return ''; |
||
| 671 | } |
||
| 672 | |||
| 673 | |||
| 674 | /** |
||
| 675 | * Generate markup for element type icons suitable for use in GridFields. |
||
| 676 | * |
||
| 677 | * @return DBField |
||
| 678 | */ |
||
| 679 | public function getIcon() |
||
| 680 | { |
||
| 681 | $icon = $this->config()->get('icon'); |
||
| 682 | |||
| 683 | if ($icon) { |
||
| 684 | $icon = ModuleResourceLoader::resourceURL($icon); |
||
| 685 | |||
| 686 | return DBField::create_field('HTMLVarchar', '<img width="16px" src="' . Director::absoluteBaseURL() . $icon . '" alt="" />'); |
||
| 687 | } |
||
| 688 | } |
||
| 689 | |||
| 690 | /** |
||
| 691 | * Generate markup for element type, with description suitable for use in |
||
| 692 | * GridFields. |
||
| 693 | * |
||
| 694 | * @return DBField |
||
| 695 | */ |
||
| 696 | public function getTypeNice() |
||
| 697 | { |
||
| 698 | $description = $this->config()->get('description'); |
||
| 699 | $desc = ($description) ? ' <span class="el-description"> — ' . $description . '</span>' : ''; |
||
| 700 | |||
| 701 | return DBField::create_field( |
||
| 702 | 'HTMLVarchar', |
||
| 703 | $this->getType() . $desc |
||
| 704 | ); |
||
| 705 | } |
||
| 706 | |||
| 707 | /** |
||
| 708 | * @return HTMLText |
||
| 709 | */ |
||
| 710 | public function getEditorPreview() |
||
| 711 | { |
||
| 712 | $templates = $this->getRenderTemplates('_EditorPreview'); |
||
| 713 | $templates[] = BaseElement::class . '_EditorPreview'; |
||
| 714 | |||
| 715 | return $this->renderWith($templates); |
||
| 716 | } |
||
| 717 | |||
| 718 | /** |
||
| 719 | * @return Member |
||
| 720 | */ |
||
| 721 | public function getAuthor() |
||
| 722 | { |
||
| 723 | if ($this->AuthorID) { |
||
| 724 | return Member::get()->byId($this->AuthorID); |
||
| 725 | } |
||
| 726 | } |
||
| 727 | |||
| 728 | /** |
||
| 729 | * @return string |
||
| 730 | */ |
||
| 731 | public function getStyleVariant() |
||
| 732 | { |
||
| 733 | $style = $this->Style; |
||
| 734 | |||
| 735 | if (isset($styles[$style])) { |
||
| 736 | $style = strtolower($styles[$style]); |
||
| 737 | } else { |
||
| 738 | $style = ''; |
||
| 739 | } |
||
| 740 | |||
| 741 | $this->extend('updateStyleVariant', $style); |
||
| 742 | |||
| 743 | return $style; |
||
| 744 | } |
||
| 745 | |||
| 746 | /** |
||
| 747 | * |
||
| 748 | */ |
||
| 749 | public function getPageTitle() |
||
| 750 | { |
||
| 751 | $page = $this->getPage(); |
||
| 752 | |||
| 753 | if ($page) { |
||
| 754 | return $page->Title; |
||
| 755 | } |
||
| 756 | |||
| 757 | return null; |
||
| 758 | } |
||
| 759 | |||
| 760 | /** |
||
| 761 | * Get a "nice" label for use in the block history GridField |
||
| 762 | * |
||
| 763 | * @return string |
||
| 764 | */ |
||
| 765 | public function getVersionedStateNice() |
||
| 766 | { |
||
| 767 | if ($this->WasPublished) { |
||
| 768 | return _t(__CLASS__ . '.Published', 'Published'); |
||
| 769 | } |
||
| 770 | |||
| 771 | return _t(__CLASS__ . '.Modified', 'Modified'); |
||
| 772 | } |
||
| 773 | |||
| 774 | /** |
||
| 775 | * Return a formatted date for use in the block history GridField |
||
| 776 | * |
||
| 777 | * @return string |
||
| 778 | */ |
||
| 779 | public function getLastEditedNice() |
||
| 782 | } |
||
| 783 | } |
||
| 784 |
This check marks private properties in classes that are never used. Those properties can be removed.