Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
tool_reindex.inc
1 <?php
17 require_once SQ_SYSTEM_ROOT.'/core/assets/system/tool/tool.inc';
18 
34 class Tool_Reindex extends Tool
35 {
36 
37 
44  function __construct($assetid=0)
45  {
46  parent::__construct($assetid);
47 
48  }//end constructor
49 
50 
60  static function paintTool(&$o, $type_code)
61  {
62  $tool_info = $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($type_code);
63  $o->openSection($tool_info['name']);
64 
65  $o->openField('Root Node');
66  asset_finder($type_code.'_reindexing_root_assetid', '');
67  echo '&nbsp;&nbsp;&nbsp;<b>OR</b>';
68  $o->closeField();
69 
70  $o->openField('System Wide');
71  check_box($type_code.'_reindexing_root_folder');
72  echo translate('sch_reindex_all_assets');
73  $o->closeField();
74 
75  $o->closeSection();
76 
77  }//end paintTool()
78 
79 
89  static function processTool(&$o, $type_code)
90  {
91  $index_all = 0;
92 
93  if (isset($_REQUEST[$type_code.'_reindexing_root_folder'])) {
94  $index_all = $_REQUEST[$type_code.'_reindexing_root_folder'];
95  }
96 
97  if ($index_all == 1) {
98  // System-wide reindex
99  $vars = Array('root_assetid' => $GLOBALS['SQ_SYSTEM']->am->getSystemAssetid('root_folder'));
100  } else {
101  $root_assetid = $_REQUEST[$type_code.'_reindexing_root_assetid']['assetid'];
102  $vars = Array('root_assetid' => $root_assetid);
103  }
104 
105  // Save the context we are in
106  $vars['contextid'] = $GLOBALS['SQ_SYSTEM']->getContextId();
107 
108  $hh = $GLOBALS['SQ_SYSTEM']->getHipoHerder();
109  $hh->queueHipo('hipo_job_reindex', $vars, '', SQ_PACKAGES_PATH.'/search/hipo_jobs');
110  $url = $hh->runQueuedJobs();
111  if (!empty($url)) $o->setRedirect($url);
112  return TRUE;
113 
114  }//end processTool()
115 
116 
117 }//end class
118 
119 
120 ?>