1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130:
<?php
class FeedMenu extends Menu
{
const FEED_MENU__CLASS = 'FeedMenu';
public $url = '';
public $module_id = '';
public $name = '';
public $category = 0;
public $number = 10;
public $begin_at = 0;
public function __construct($title, $module_id, $category = 0, $name = Feed::DEFAULT_FEED_NAME, $number = 10, $begin_at = 0)
{
parent::__construct($title);
$this->module_id = $module_id;
$this->category = $category;
$this->name = $name;
$this->number = $number;
$this->begin_at = $begin_at;
}
public static function get_template($id, $name = '', $block_position = Menu::BLOCK_POSITION__LEFT, $hidden_with_small_screens = false)
{
$tpl = new FileTemplate('framework/menus/feed.tpl');
$tpl->put_all(array(
'NAME' => $name,
'ID' => $id,
'C_NAME' => !empty($name),
'C_VERTICAL_BLOCK' => ($block_position == Menu::BLOCK_POSITION__LEFT || $block_position == Menu::BLOCK_POSITION__RIGHT),
'C_HIDDEN_WITH_SMALL_SCREENS' => $hidden_with_small_screens
));
return $tpl;
}
public function get_module_id() { return $this->module_id; }
public function get_url($relative = false)
{
$url = DispatchManager::get_url('/syndication', '/rss/' . $this->module_id . '/' . $this->category . '/' . $this->name . '/');
if ($relative)
{
return $url->relative();
}
return $url->absolute();
}
public function set_module_id($value) { $this->module_id = $value; }
public function set_cat($value) { $this->category = is_numeric($value) ? NumberHelper::numeric($value) : 0; }
public function set_name($value) { $this->name = $value; }
public function get_number()
{
return $this->number;
}
public function set_number($value) { $this->number = $value; }
public function display()
{
$filters = $this->get_filters();
$is_displayed = empty($filters) || $filters[0]->get_pattern() == '/';
foreach ($filters as $key => $filter)
{
if ($filter->get_pattern() != '/' && $filter->match())
{
$is_displayed = true;
break;
}
}
if ($is_displayed)
{
return Feed::get_parsed($this->module_id, $this->name, $this->category, self::get_template($this->id, $this->get_title(), $this->get_block(), $this->hidden_with_small_screens), $this->number, $this->begin_at);
}
return '';
}
}
?>