SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/Helpers/LinkSpecDocument.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\FileConstants;
  18. use Sprout\Helpers\Form;
  19.  
  20.  
  21. class LinkSpecDocument extends LinkSpec
  22. {
  23.  
  24. /**
  25.   * Get the URL for a given link
  26.   **/
  27. public function getUrl($specdata)
  28. {
  29. return File::absUrl($specdata);
  30. }
  31.  
  32.  
  33. /**
  34.   * Get any extra html attributes to use for a given link
  35.   * @return array
  36.   **/
  37. public function getAttrs($specdata)
  38. {
  39. return array();
  40. }
  41.  
  42.  
  43. /**
  44.   * If there are any {@see Needs} calls that the edit form requires, they should be loaded here
  45.   **/
  46. public function loadNeeds()
  47. {
  48. }
  49.  
  50.  
  51. /**
  52.   * Get the HTML to use for editing a given linkspec
  53.   *
  54.   * The HTML should create a HTML field with the name $field_name
  55.   * If there is a spec currently being edited, the specdata will
  56.   * be provided in $curr_specdata
  57.   **/
  58. public function getEditForm($field_name, $curr_specdata)
  59. {
  60. Form::setData([$field_name => $curr_specdata]);
  61. Form::nextFieldDetails('Document', true);
  62. return Form::fileselector($field_name, ['filter' => FileConstants::TYPE_DOCUMENT]);
  63. }
  64.  
  65.  
  66. /**
  67.   * Validate the submission, for instances where certain constraints apply
  68.   **/
  69. public function isValid($specdata)
  70. {
  71. return true;
  72. }
  73.  
  74. }
  75.