SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/Helpers/LinkSpec.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.  * Base class for the backend of the extensible link system: {@see Lnk}
  19.  */
  20. abstract class LinkSpec {
  21.  
  22. /**
  23.   * Get the URL for a given link
  24.   **/
  25. abstract public function getUrl($specdata);
  26.  
  27.  
  28. /**
  29.   * Get any extra html attributes to use for a given link
  30.   * @return array
  31.   **/
  32. abstract public function getAttrs($specdata);
  33.  
  34.  
  35. /**
  36.   * If there are any {@see Needs} calls that the edit form requires, they should be loaded here
  37.   **/
  38. public function loadNeeds() {}
  39.  
  40.  
  41. /**
  42.   * Get the HTML to use for editing a given linkspec
  43.   *
  44.   * The HTML should create a HTML field with the name $field_name
  45.   * If there is a spec currently being edited, the specdata will
  46.   * be provided in $curr_specdata
  47.   **/
  48. abstract public function getEditForm($field_name, $curr_specdata);
  49.  
  50.  
  51. /**
  52.   * Validate the submission, for instances where certain constraints apply
  53.   **/
  54. abstract public function isValid($specdata);
  55.  
  56. }
  57.  
  58.