1<?php 2 3/** 4 * Developer modules 5 * @package modules 6 * @subpackage developer 7 */ 8 9if (!defined('DEBUG_MODE')) { die(); } 10 11/** 12 * Build server information data 13 * @subpackage developer/handler 14 */ 15class Hm_Handler_process_server_info extends Hm_Handler_Module { 16 /*** 17 * Collect environment info 18 */ 19 public function process() { 20 $res = $this->request->server; 21 $res['phpversion'] = phpversion(); 22 $res['zend_version'] = zend_version(); 23 $res['sapi'] = php_sapi_name(); 24 $res['handlers'] = Hm_Handler_Modules::dump(); 25 $res['output'] = Hm_Output_Modules::dump(); 26 $this->out('server_info', $res); 27 } 28} 29 30/** 31 * Output links to developer resources 32 * @subpackage developer/output 33 */ 34class Hm_Output_dev_content extends Hm_Output_Module { 35 /** 36 * Dev resources 37 */ 38 protected function output() { 39 return '<div class="dev_content"><div class="content_title">'.$this->trans('Developer Documentation').'</div>'. 40 '<div class="long_text">'. 41 'There is not a lot of documentation yet, but there are a few resources available online. First is the module overview page at our website intended for developers interested in creating module sets.'. 42 '<br /><br /> <a href="http://cypht.org/modules.html">http://cypht.org/modules.html</a>'. 43 '<br /><br />Code Documentation for Cypht is auto-generated using <a href="http://www.apigen.org/">Apigen</a> and while '. 44 'not yet complete, has a lot of useful information'. 45 '<br /><br /> <a href="http://cypht.org/docs/code_docs/index.html">http://cypht.org/docs/code_docs/index.html</a>'. 46 '<br /><br />Finally there is a "hello world" module with lots of comments included in the project download and browsable at github'. 47 '<br /><br /> <a href="https://github.com/jasonmunro/hm3/tree/master/modules/hello_world">https://github.com/jasonmunro/hm3/tree/master/modules/hello_world</a>'. 48 '</div></div>'; 49 } 50} 51 52/** 53 * Start the info section on the dev page 54 * @subpackage developer/output 55 */ 56class Hm_Output_info_heading extends Hm_Output_Module { 57 /** 58 * Leaves an open div 59 */ 60 protected function output() { 61 return '<div class="info_content"><div class="content_title">'.$this->trans('Info').'</div>'; 62 } 63} 64 65/** 66 * Adds a link to the dev resources page to the folder list 67 * @subpackage developer/output 68 */ 69class Hm_Output_developer_doc_link extends Hm_Output_Module { 70 /** 71 * Link to the dev page 72 */ 73 protected function output() { 74 $res = '<li class="menu_dev"><a class="unread_link" href="?page=dev">'; 75 if (!$this->get('hide_folder_icons')) { 76 $res .= '<img class="account_icon" src="'.$this->html_safe(Hm_Image_Sources::$bug).'" alt="" width="16" height="16" /> '; 77 } 78 $res .= $this->trans('Dev').'</a></li>'; 79 if ($this->format == 'HTML5') { 80 return $res; 81 } 82 $this->concat('formatted_folder_list', $res); 83 } 84} 85 86 87/** 88 * Adds a link to the info page to the folder list 89 * @subpackage developer/output 90 */ 91class Hm_Output_info_page_link extends Hm_Output_Module { 92 /** 93 * Info page link 94 */ 95 protected function output() { 96 $res = '<li class="menu_info"><a class="unread_link" href="?page=info">'; 97 if (!$this->get('hide_folder_icons')) { 98 $res .= '<img class="account_icon" src="'.$this->html_safe(Hm_Image_Sources::$info).'" alt="" width="16" height="16" /> '; 99 } 100 $res .= $this->trans('Info').'</a></li>'; 101 if ($this->format == 'HTML5') { 102 return $res; 103 } 104 $this->concat('formatted_folder_list', $res); 105 } 106} 107 108/** 109 * Outputs server information 110 * @subpackage developer/output 111 */ 112class Hm_Output_server_information extends Hm_Output_Module { 113 /** 114 * Information about the running instance 115 */ 116 protected function output() { 117 $server_info = $this->get('server_info', array()); 118 if (!empty($server_info)) { 119 return '<div class="server_info"><table class="info">'. 120 '<tr><th>Server Name</th><td>'.$server_info['HTTP_HOST'].'</td></tr>'. 121 '<tr><th>Server Scheme</th><td>'.$server_info['REQUEST_SCHEME'].'</td></tr>'. 122 '<tr><th>Server Address</th><td>'.$server_info['SERVER_ADDR'].'</td></tr>'. 123 '<tr><th>Client Address</th><td>'.$server_info['REMOTE_ADDR'].'</td></tr>'. 124 '<tr><th>PHP version</th><td>'.$server_info['phpversion'].'</td></tr>'. 125 '<tr><th>Zend version</th><td>'.$server_info['zend_version'].'</td></tr>'. 126 '<tr><th>SAPI</th><td>'.$server_info['sapi'].'</td></tr>'. 127 '<tr><th>Enabled Modules</th><td>'.str_replace(',', ', ', implode(',', $this->get('router_module_list'))).'</td></tr>'. 128 '</table></div>'; 129 } 130 return ''; 131 } 132} 133 134/** 135 * Output the current configuration setup 136 * @subpackage developer/output 137 */ 138class Hm_Output_config_map extends Hm_Output_Module { 139 /** 140 * Show pages, module assignments, and input filters 141 */ 142 protected function output() { 143 $res = '<div class="content_title">'.$this->trans('Configuration Map').'</div><table class="config_map">'; 144 $handlers = array(); 145 $outputs = array(); 146 $ajax = array(); 147 $normal = array(); 148 $server_info = $this->get('server_info', array()); 149 if (!empty($server_info)) { 150 $handlers = $server_info['handlers']; 151 ksort($handlers); 152 $outputs = $server_info['output']; 153 } 154 $res .= '<tr><td colspan="3"><div class="settings_subtitle">Pages</div></td></tr>'; 155 foreach ($handlers as $page => $mods) { 156 if (substr($page, 0, 4) == 'ajax') { 157 continue; 158 } 159 $res .= '<tr><td colspan="3" class="config_map_page" data-target="c'.$page.'">'.$page.'</td></tr>'; 160 $res .= '<tr><th class="c'.$page.'" >Handler Modules</th><th class="c'.$page.'" >'.$this->trans('Source').'</th><th class="c'.$page.'" >Docs/Code</th></tr>'; 161 foreach ($mods as $name => $vals) { 162 $res .= '<tr><td class="hmod c'.$page.'">'.$name.'</td><td class="hmod_val c'.$page.'">'.$vals[0].'</td>'; 163 $res .= '<td class="hmod c'.$page.'"><a href="https://cypht.org/docs/code_docs/class-Hm_Handler_'.$name.'.html"><img src="'.Hm_Image_Sources::$code.'" /></a></td></tr>'; 164 } 165 if (array_key_exists($page, $outputs)) { 166 $res .= '<tr><th class="c'.$page.'" >Output Modules</th><th class="c'.$page.'" >'.$this->trans('Source').'</th><th class="c'.$page.'" >Docs/Code</th></tr>'; 167 foreach($outputs[$page] as $name => $vals) { 168 $res .= '<tr><td class="omod c'.$page.'">'.$name.'</td><td class="omod_val c'.$page.'">'.$vals[0].'</td>'; 169 $res .= '<td class="omod c'.$page.'"><a href="https://cypht.org/docs/code_docs/class-Hm_Output_'.$name.'.html"><img src="'.Hm_Image_Sources::$code.'" /></a></td></tr>'; 170 } 171 } 172 } 173 $res .= '<tr><td colspan="3"><div class="settings_subtitle">AJAX Requests</div></td></tr>'; 174 foreach ($handlers as $page => $mods) { 175 if (substr($page, 0, 4) != 'ajax') { 176 continue; 177 } 178 $res .= '<tr><td colspan="3" class="config_map_page" data-target="c'.$page.'">'.$page.'</td></tr>'; 179 $res .= '<tr><th class="c'.$page.'" >Handler Modules</th><th class="c'.$page.'" >'.$this->trans('Source').'</th><th class="c'.$page.'" >Docs/Code</th></tr>'; 180 foreach ($mods as $name => $vals) { 181 $res .= '<tr><td class="hmod c'.$page.'">'.$name.'</td><td class="hmod_val c'.$page.'">'.$vals[0].'</td>'; 182 $res .= '<td class="hmod c'.$page.'"><a href="https://cypht.org/docs/code_docs/class-Hm_Handler_'.$name.'.html"><img src="'.Hm_Image_Sources::$code.'" /></a></td></tr>'; 183 } 184 if (array_key_exists($page, $outputs)) { 185 $res .= '<tr><th class="c'.$page.'" >Output Modules</th><th class="c'.$page.'" >'.$this->trans('Source').'</th><th class="c'.$page.'" >Docs/Code</th></tr>'; 186 foreach($outputs[$page] as $name => $vals) { 187 $res .= '<tr><td class="omod c'.$page.'">'.$name.'</td><td class="omod_val c'.$page.'">'.$vals[0].'</td>'; 188 $res .= '<td class="omod c'.$page.'"><a href="https://cypht.org/docs/code_docs/class-Hm_Output_'.$name.'.html"><img src="'.Hm_Image_Sources::$code.'" /></a></td></tr>'; 189 } 190 } 191 } 192 $res .= '</table>'; 193 return $res; 194 } 195} 196 197/** 198 * Starts a status table used on the info page 199 * @subpackage developer/output 200 */ 201class Hm_Output_server_status_start extends Hm_Output_Module { 202 /** 203 * Modules populate this table to run a status check from the info page 204 */ 205 protected function output() { 206 $res = '<div class="content_title">Status</div><table><thead><tr><th>'.$this->trans('Type').'</th><th>'.$this->trans('Name').'</th><th>'. 207 $this->trans('Status').'</th></tr></thead><tbody>'; 208 return $res; 209 } 210} 211 212/** 213 * Close the status table used on the info page 214 * @subpackage developer/output 215 */ 216class Hm_Output_server_status_end extends Hm_Output_Module { 217 /** 218 * Close the table opened in Hm_Output_server_status_start 219 */ 220 protected function output() { 221 return '</tbody></table></div>'; 222 } 223} 224 225 226