3 * every class extends this...
7 class MTrackWeb extends HTML_FlexyFramework_Page
9 var $template = 'wiki.html';
10 var $priorities = array();
11 var $severities = array();
12 var $link = false; // the link handler..
14 function hasPerm($what, $cando) {
15 return MTrackACL::hasAnyRights($what, $cando);
20 $this->registerClasses();
21 $ff = HTML_FlexyFramework::get();
26 MTrackConfig::boot(); // eak.. .remove me...
29 $me = MTrackAuth::whoami();
30 require_once 'MTrack/DataObjects/Userinfo.php';
31 $this->authUser = MTrack_DataObjects_UserInfo::get($me);
32 $this->authUser->setCurrentTimeZone();
36 return true; // anyone at present..
43 die ("invalid location". htmlspecialchars($loc));
45 if ($this->authUser->userid == 'anonymous') {
47 return HTML_FlexyFramework::run('Wiki');
49 return HTML_FlexyFramework::run('Wiki/Today');
55 header("Status: 404 Not Found");
60 function initOptions()
64 $q = MTrackDB::q('select priorityname, value from priorities');
66 foreach ($q->fetchAll() as $row) {
67 $this->priorities[$row[0]] = $row[1];
69 $q = MTrackDB::q('select sevname, ordinal from severities');
71 foreach ($q->fetchAll() as $row) {
72 $this->severities[$row[0]] = $row[1];
77 function registerClasses()
79 require_once 'MTrack/Wiki.php';
80 require_once 'MTrack/Milestone.php';
81 require_once 'MTrack/Report.php';
82 require_once 'MTrack/ACL.php';
83 require_once 'MTrack/SearchDB.php';
84 require_once 'MTrack/Watch.php';
85 require_once 'MTrack/CommitChecker.php';
86 require_once 'MTrack/Repo.php';
87 require_once 'MTrack/SCM/Git/Repo.php';
88 require_once 'MTrack/SCM/Svn.php';
89 require_once 'MTrack/SCM/Hg.php';
90 require_once 'MTrackWeb/LinkHandler.php';
91 require_once 'MTrack/Wiki/HTMLFormatter.php';
93 $this->link = new MTrackWeb_LinkHandler();
94 MTrack_Wiki_HTMLFormatter::registerLinkHandler($this->link);
96 MTrackRepo::registerSCM('git', 'MTrack_SCM_Git_Repo');
97 MTrackRepo::registerSCM('svn', 'MTrackSCMSVN');
98 MTrackRepo::registerSCM('hg', 'MTrackSCMHg');
100 MTrack_Wiki::register_macro('MilestoneSummary', array('MTrack_Milestone', 'macro_MilestoneSummary'));
101 MTrack_Wiki::register_macro('BurnDown', array('MTrack_Milestone', 'macro_BurnDown'));
102 MTrack_Wiki::register_macro('RunReport', array('MTrack_Report', 'macro_RunReport'));
103 MTrack_Wiki::register_macro('TicketQuery', array('MTrack_Report', 'macro_TicketQuery'));
104 MTrack_Wiki::register_macro('IncludeWikiPage', array('MTrack_Wiki', 'macro_IncludeWiki'));
105 MTrack_Wiki::register_macro('IncludeHelpPage', array('MTrack_Wiki', 'macro_IncludeHelp'));
106 MTrack_Wiki::register_macro('Comment', array('MTrack_Wiki', 'macro_comment'));
107 MTrack_Wiki::register_processor('comment', array('MTrack_Wiki', 'processor_comment'));
108 MTrack_Wiki::register_processor('html', array('MTrack_Wiki', 'processor_html'));
109 MTrack_Wiki::register_processor('dataset', array('MTrack_Wiki', 'processor_dataset'));
112 MTrackACL::registerAncestry('milestone', 'Roadmap');
113 MTrackACL::registerAncestry('report', 'Reports');
114 MTrackACL::registerAncestry('snippet', 'Snippets');
115 MTrackACL::registerAncestry('repo', 'Browser');
116 MTrackACL::registerAncestry('enum', 'Enumerations');
117 MTrackACL::registerAncestry("component", 'Components');
118 MTrackACL::registerAncestry("project", 'Projects');
119 MTrackACL::registerAncestry("ticket", "Tickets");
120 MTrackACL::registerAncestry('wiki', array('MTrack_Wiki_Item', '_get_parent_for_acl'));
122 MTrackSearchDB::register_indexer('ticket', array('MTrackIssue', 'index_issue'));
123 MTrackSearchDB::register_indexer('wiki', array('MTrack_Wiki_Item', 'index_item'));
127 MTrackWatch::registerEventTypes('ticket', array( 'ticket' => 'Tickets' ));
128 MTrackWatch::registerEventTypes('milestone', array( 'ticket' => 'Tickets', 'changeset' => 'Code changes' ));
129 MTrackWatch::registerEventTypes('repo', array( 'ticket' => 'Tickets', 'changeset' => 'Code changes' ));
131 // should this get registered here??
132 MTrackCommitChecker::addCheck('Wiki');
142 /// FIXME - we should allow upload of a favion...
143 $ff = HTML_FlexyFramework::get();
149 /* renders the attachment list for a given object */
150 // was Attachments::render
151 // move it to MTrackWebAttachemnt...
153 function attachmentsToHtml($object)
155 if (is_object($object)) {
156 $object = $object->toIdString(); // eg. ticket:1
158 $atts = MTrackDB::q('
159 select * from attachments
160 left join changes on (attachments.cid = changes.cid)
161 where attachments.object = ? order by changedate, filename',
162 $object)->fetchAll(PDO::FETCH_ASSOC);
164 if (count($atts) == 0) return '';
168 $html = "<div class='attachment-list'><b>Attachments</b><ul>";
169 foreach ($atts as $row) {
170 $url = "{$this->baseURL}/Attachment/$object/". $row['cid'] . '/' . $row['filename'];
172 $html .= "<li><a class='attachment'" .
174 "$row[filename]</a> ($row[size]) added by " .
175 $this->link->username($row['who'], array(
178 " " . $this->link->date($row['changedate']);
179 require_once 'MTrack/Attachment.php';
180 list($width, $height) = getimagesize(MTrackAttachment::local_path($row['hash']));
181 if ($width + $height) {
182 /* limit maximum size */
183 if ($width > $max_dim) {
184 $height *= $max_dim / $width;
187 if ($height > $max_dim) {
188 $width *= $max_dim / $height;
191 $html .= "<br><a href='$url'><img src='$url' width='$width' border='0' height='$height'></a>";
196 $html .= "</ul></div>";