SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/Helpers/AttrEditor.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 Sprout\Helpers;
  15.  
  16.  
  17. /**
  18.  * Specialised input field for page attributes
  19.  */
  20. abstract class AttrEditor {
  21.  
  22. /**
  23.   * Return HTML for editing the attribute.
  24.   * Your attribute needs to return HTML for a single input element.
  25.   * The field name for the element needs to be 'value'.
  26.   *
  27.   * @param string $val The current value of the attribute
  28.   * @param string $attr_name The name of the attribute
  29.   **/
  30. abstract public function render($val, $attr_name);
  31.  
  32.  
  33. /**
  34.   * If your class has script needs, load them in here.
  35.   * This is run on page load, not on ajax request.
  36.   **/
  37. public function needs() {}
  38.  
  39.  
  40. /**
  41.   * If you have any custom javascript to run, return it using this method.
  42.   *
  43.   * When your script runs, take a look at the $outer variable.
  44.   **/
  45. public function javascript($val, $attr_name)
  46. {
  47. return '';
  48. }
  49.  
  50. }
  51.