SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/module_template/has_categories/Controllers/Admin/CNAMEAdminController.php

  1. <?php
  2. /*
  3.  * Copyright (C) 2017 Karmabunny Pty Ltd.
  4.  *
  5.  * This file is a part of SproutCMS.
  6.  *
  7.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  8.  * of the GNU General Public License as published by the Free Software Foundation, either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * For more information, visit <http://getsproutcms.com>.
  12.  */
  13.  
  14. namespace SproutModules\AUTHOR\MODULE\Controllers\Admin;
  15.  
  16. use InvalidArgumentException;
  17.  
  18. use Sprout\Controllers\Admin\HasCategoriesAdminController;
  19. use Sprout\Helpers\ColModifierBinary;
  20.  
  21.  
  22. /**
  23.  * Handles admin processing for PNICE
  24.  */
  25. class CNAMEAdminController extends HasCategoriesAdminController
  26. {
  27. protected $controller_name = 'SNAME';
  28. protected $friendly_name = 'PNICE';
  29. protected $add_defaults = [
  30. 'active' => 1,
  31. ];
  32. protected $main_columns = [];
  33.  
  34.  
  35. /**
  36.   * Constructor
  37.   **/
  38. public function __construct()
  39. {
  40. $this->main_columns = [
  41. FIELDS_MAIN
  42. 'Active' => [new ColModifierBinary(), 'active'],
  43. ];
  44.  
  45. $this->initRefineBar();
  46.  
  47. parent::__construct();
  48. }
  49.  
  50.  
  51. /**
  52.   * Pre-render hook for adding
  53.   **/
  54. protected function _addPreRender($view)
  55. {
  56. parent::_addPreRender($view);
  57. }
  58.  
  59.  
  60. /**
  61.   * Return the sub-actions for adding; for spec {@see AdminController::renderSubActions}
  62.   * @return array
  63.   */
  64. public function _getAddSubActions()
  65. {
  66. $actions = parent::_getAddSubActions();
  67. // Add your actions here, like this: $actions[] = [ ... ];
  68. return $actions;
  69. }
  70.  
  71.  
  72. /**
  73.   * Saves the provided POST data into a new record in the database
  74.   *
  75.   * @param int $item_id After saving, the new record id will be returned in this parameter
  76.   * @param bool True on success, false on failure
  77.   */
  78. public function _addSave(&$item_id)
  79. {
  80. return parent::_addSave($item_id);
  81. }
  82.  
  83.  
  84. /**
  85.   * Pre-render hook for editing
  86.   **/
  87. protected function _editPreRender($view, $item_id)
  88. {
  89. parent::_editPreRender($view, $item_id);
  90. }
  91.  
  92.  
  93. /**
  94.   * Return the sub-actions for editing; for spec {@see AdminController::renderSubActions}
  95.   * @return array
  96.   */
  97. public function _getEditSubActions($item_id)
  98. {
  99. $actions = parent::_getEditSubActions($item_id);
  100. // Add your actions here, like this: $actions[] = [ ... ];
  101. return $actions;
  102. }
  103.  
  104.  
  105. /**
  106.   * Saves the provided POST data into the specified record
  107.   *
  108.   * @param int $item_id The record to update
  109.   * @param bool True on success, false on failure
  110.   */
  111. public function _editSave($item_id)
  112. {
  113. $item_id = (int) $item_id;
  114. if ($item_id <= 0) throw new InvalidArgumentException('$item_id must be greater than 0');
  115.  
  116. return parent::_editSave($item_id);
  117. }
  118.  
  119. }
  120.  
  121.