SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/Helpers/LinkSpecInternal.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. use Sprout\Helpers\Form;
  18.  
  19.  
  20. class LinkSpecInternal extends LinkSpec
  21. {
  22.  
  23. /**
  24.   * Get the URL for a given link
  25.   **/
  26. public function getUrl($specdata)
  27. {
  28. return Sprout::absRoot() . trim($specdata, '/');
  29. }
  30.  
  31.  
  32. /**
  33.   * Get any extra html attributes to use for a given link
  34.   * @return array
  35.   **/
  36. public function getAttrs($specdata)
  37. {
  38. return array();
  39. }
  40.  
  41.  
  42. /**
  43.   * Get the HTML to use for editing a given linkspec
  44.   *
  45.   * The HTML should create a HTML field with the name $field_name
  46.   * If there is a spec currently being edited, the specdata will
  47.   * be provided in $curr_specdata
  48.   **/
  49. public function getEditForm($field_name, $curr_specdata)
  50. {
  51. Form::setData([$field_name => $curr_specdata]);
  52. Form::nextFieldDetails('Internal URL', true);
  53. return Form::text($field_name, ['placeholder' => 'e.g. /contact']);
  54. }
  55.  
  56.  
  57. /**
  58.   * Validate the submission, for instances where certain constraints apply
  59.   **/
  60. public function isValid($specdata)
  61. {
  62. return true;
  63. }
  64.  
  65. }
  66.