1<?php 2 3namespace dokuwiki\plugin\prosemirror\parser; 4 5class RSSNode extends Node 6{ 7 8 protected $parent; 9 protected $data; 10 11 public function __construct($data, Node $parent) 12 { 13 $this->parent = &$parent; 14 $this->data = $data; 15 } 16 17 public function toSyntax() 18 { 19 $attrs = $this->data['attrs']; 20 return self::attrToSyntax($attrs); 21 } 22 23 protected static function attrToSyntax($attrs) { 24 $prefix = '{{rss>'; 25 $url = ''; 26 if (!empty($attrs['url'])) { 27 $url = $attrs['url']; 28 } 29 $paramString = ''; 30 31 if (!empty($attrs['max']) && $attrs['max'] !== 8) { 32 $paramString .= ' ' . $attrs['max']; 33 } 34 35 if (!empty($attrs['reverse'])) { 36 $paramString .= ' reverse'; 37 } 38 39 if (!empty($attrs['author'])) { 40 $paramString .= ' author'; 41 } 42 43 if (!empty($attrs['date'])) { 44 $paramString .= ' date'; 45 } 46 47 if (!empty($attrs['details'])) { 48 $paramString .= ' description'; 49 } 50 51 if (!empty($attrs['refresh']) && $attrs['refresh'] !== '4h') { 52 $paramString .= ' ' . $attrs['refresh']; 53 } 54 $postfix = '}}'; 55 return $prefix . $url . $paramString . $postfix; 56 } 57 58 public static function renderAttrsToHTML($attrs) { 59 $syntax = self::attrToSyntax($attrs); 60 $ins = p_get_instructions($syntax); 61 return p_render('xhtml', $ins, $info); 62 } 63} 64