1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13: class Wicked_Page_AddPage extends Wicked_Page {
14:
15: 16: 17: 18: 19:
20: public $supportedModes = array(
21: Wicked::MODE_DISPLAY => true);
22:
23: 24: 25: 26: 27:
28: protected $_newpage;
29:
30: 31: 32: 33: 34:
35: protected $_results;
36:
37: public function __construct($newpage)
38: {
39: $this->_newpage = $newpage;
40: $this->_results = $GLOBALS['wicked']->searchTitles($newpage);
41: }
42:
43: 44: 45:
46: public function preDisplay()
47: {
48: if (!strlen($this->referrer())) {
49: $GLOBALS['notification']->push(_("Page name must not be empty"));
50: Wicked::url('', true)->redirect();
51: }
52: }
53:
54: 55: 56: 57: 58:
59: public function display()
60: {
61: try {
62: $templates = $GLOBALS['wicked']->getMatchingPages('Template', Wicked_Page::MATCH_ENDS);
63: } catch (Wicked_Exception $e) {
64: $GLOBALS['notification']->push(sprintf(_("Error retrieving templates: %s"),
65: $e->getMessage()), 'horde.error');
66: throw $e;
67: }
68:
69: $search_results = null;
70: if ($this->_results) {
71: $template = $GLOBALS['injector']->createInstance('Horde_Template');
72: $pages = array();
73: foreach ($this->_results as $page) {
74: if (!empty($page['page_history'])) {
75: $page = new Wicked_Page_StandardHistoryPage($page);
76: } else {
77: $page = new Wicked_Page_StandardPage($page);
78: }
79:
80: $pages[] = array('author' => $page->author(),
81: 'created' => $page->formatVersionCreated(),
82: 'name' => $page->pageName(),
83: 'context' => false,
84: 'url' => $page->pageUrl(),
85: 'version' => $page->version());
86: }
87: $template->set('pages', $pages, true);
88: $template->set('hits', false, true);
89: $search_results = $template->fetch(WICKED_TEMPLATES . '/pagelist/pagelist.html');
90: }
91:
92: require WICKED_TEMPLATES . '/edit/create.inc';
93: }
94:
95: public function pageName()
96: {
97: return 'AddPage';
98: }
99:
100: public function pageTitle()
101: {
102: return sprintf(_("Add Page: %s"), $this->referrer());
103: }
104:
105: public function referrer()
106: {
107: return $this->_newpage;
108: }
109:
110: 111: 112: 113: 114:
115: public function getText()
116: {
117:
118: return '';
119: }
120:
121: }
122: