Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
tools.inc
1 <?php
31 class Tools extends MySource_Object
32 {
33 
34 
43  function paintBackend(&$backend)
44  {
45  $o =& $backend->out;
46  $o->setHeading(translate('system_tools'), sq_get_icon($o->filesPath('/images/icons/header/whereami.png'), 20, 20, 'Tools'));
47  $o->setPageTitle(translate('system_tools'));
48 
49  if (isset($_REQUEST['committed_tool_type_code'])) {
50  // the user has pressed commit for a specific tool
51  if (!$this->_processTool($o)) {
52  // something went wrong - need to show the interface again
53  $_REQUEST['tool_type_code'] = $_REQUEST['committed_tool_type_code'];
54  }
55  }
56 
57  // the user has selected a tool, lets call its interface
58  if (isset($_REQUEST['tool_type_code'])) {
59  $this->_paintTool($o);
60  return;
61  }
62 
63  // At this point, the user just wants to view a list of the available tools
64  $o->openSection(translate('system_tools'));
65  $o->openField('');
66  $tools = $GLOBALS['SQ_SYSTEM']->am->getTypeDescendants('tool');
67 
68  if (count($tools) > 0) {
69  ?>
70  <table class="sq-backend-table">
71  <tr>
72  <th><?php echo translate('name'); ?></th>
73  <th><?php echo translate('description'); ?></th>
74  </tr>
75  <?php
76  foreach ($tools as $tool) {
77  $tool_info = $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($tool);
78  $backend_url = $backend->getBackendUrl('main');
79  ?>
80  <tr>
81  <td class="sq-backend-table-cell"><a href="<?php echo $backend_url; ?>&backend_section=tools&tool_type_code=<?php echo $tool; ?>"><?php echo $tool_info['name']; ?></a></td>
82  <td class="sq-backend-table-cell"><?php echo $tool_info['description']; ?></td>
83  </tr>
84  <?php
85  }
86  ?>
87  </table>
88  <?php
89  } else {
90  echo translate('tools_none_installed');
91  }
92  $o->closeField();
93  $o->closeSection();
94 
95  }//end paintBackend()
96 
97 
106  function _paintTool(&$o)
107  {
108  $type_code = $_REQUEST['tool_type_code'];
109  $am =& $GLOBALS['SQ_SYSTEM']->am;
110 
111  if ($am->installed($type_code)) {
112  $am->includeAsset($type_code);
113  $tool_info = $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($type_code);
114  $o->setHeading('System Tools: '.$tool_info['name'], sq_get_icon($o->filesPath('/images/icons/header/asset_tree.png'), 20, 20, 'Tools'));
115  $o->setPageTitle('System Tools: '.$tool_info['name']);
116  call_user_func_array(Array($type_code, 'paintTool'), Array(&$o, $type_code));
117  $o->addHiddenField('committed_tool_type_code', $type_code);
118  $o->commitButton();
119  }
120 
121  }//end _paintTool()
122 
123 
132  function _processTool(&$o)
133  {
134  $type_code = $_REQUEST['committed_tool_type_code'];
135  $am =& $GLOBALS['SQ_SYSTEM']->am;
136 
137  if ($am->installed($type_code)) {
138  $am->includeAsset($type_code);
139  return call_user_func_array(Array($type_code, 'processTool'), Array(&$o, $type_code));
140  }
141 
142  return FALSE;
143 
144  }//end _processTool()
145 
146 
147 }//end class
148 
149 ?>