PageRenderTime 41ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/web/classes/link.php

https://github.com/truenorf/Siteframe
PHP | 117 lines | 99 code | 7 blank | 11 comment | 3 complexity | 0773f75fb370fcdc9076ff4031e6ecc9 MD5 | raw file
  1. <?php
  2. /* link.php
  3. ** Copyright (c)2001-2003, Broadpool, LLC. All rights reserved. See LICENSE.txt for details.
  4. ** $Id: link.php,v 1.9 2003/05/06 22:16:51 glen Exp $
  5. **
  6. ** A "link" is a URL with attached description.
  7. */
  8. class Link extends Document {
  9. // Link - constructor
  10. function Link($id=0, $dbrow=0) {
  11. parent::Document($id, $dbrow);
  12. $this->set_property(doc_type,'Link');
  13. $this->set_property(doc_summary,'');
  14. }
  15. // get_property
  16. function get_property($name) {
  17. switch($name) {
  18. case 'doc_summary':
  19. return parent::get_property('doc_body');
  20. default:
  21. return parent::get_property($name);
  22. }
  23. }
  24. // get_properties
  25. function get_properties() {
  26. $a = parent::get_properties();
  27. $a['doc_summary'] = $this->get_property('doc_summary');
  28. return $a;
  29. }
  30. // set_property(name,value)
  31. function set_property($name,$value) {
  32. switch($name) {
  33. case 'doc_link_url':
  34. if (clean($value)=='')
  35. $this->add_error(_ERR_BADURL,_PROMPT_LINK_URL);
  36. else
  37. parent::set_property($name,clean($value));
  38. break;
  39. default:
  40. parent::set_property($name,$value);
  41. }
  42. }
  43. // input_form_values() - return input form array
  44. function input_form_values() {
  45. global $PUBLISH_MODEL,$CURUSER,$MAX_DOC_CATEGORIES;
  46. $a = array(
  47. array(name => doc_id,
  48. type => hidden,
  49. value => $this->get_property(doc_id)),
  50. array(name => doc_title,
  51. type => text,
  52. size => 250,
  53. value => $this->get_property(doc_title),
  54. prompt => _PROMPT_LINK_TITLE),
  55. array(name => doc_folder_id,
  56. type => select,
  57. options => folderlist($CURUSER->get_property(user_id),'Link'),
  58. value => $this->get_property(doc_folder_id),
  59. prompt => _PROMPT_DOC_FOLDER),
  60. array(name => doc_link_url,
  61. type => text,
  62. value => $this->get_property(doc_link_url),
  63. size => 250,
  64. prompt => _PROMPT_LINK_URL),
  65. array(name => doc_body,
  66. type => textarea,
  67. value => $this->get_property(doc_body),
  68. rows => 5,
  69. doc => _DOC_DOC_BODY,
  70. prompt => _PROMPT_DOC_BODY),
  71. array(name => doc_hidden,
  72. type => checkbox,
  73. rval => 1,
  74. value => $this->get_property(doc_hidden),
  75. prompt => _PROMPT_DOC_HIDDEN),
  76. array(name => allow_ratings,
  77. type => checkbox,
  78. rval => 1,
  79. value => $this->get_property(allow_ratings),
  80. prompt => _PROMPT_DOC_RATING),
  81. array(name => allow_comments,
  82. type => checkbox,
  83. rval => 1,
  84. value => $this->get_property(allow_comments),
  85. prompt => _PROMPT_DOC_COMMENTS),
  86. );
  87. $a = array_merge($a,$this->custom_properties());
  88. $cats = doc_categories($this->get_property('doc_type'));
  89. for($i=1; $i<=$MAX_DOC_CATEGORIES; $i++) {
  90. $a[] = array(name => "doc_category_$i",
  91. type => select,
  92. options => $cats,
  93. value => $this->get_property("doc_category_$i"),
  94. prompt => sprintf(_PROMPT_DOC_CATEGORY,$i)
  95. );
  96. }
  97. if (isadmin())
  98. $a[] = array(name => doc_tag,
  99. type => text,
  100. size => 32,
  101. value => $this->get_property(doc_tag),
  102. prompt => _PROMPT_DOC_TAG);
  103. else
  104. $a[] = array(name => doc_tag,
  105. type => hidden,
  106. value => $this->get_property(doc_tag));
  107. return $a;
  108. }
  109. }
  110. ?>