17 error_reporting(E_ALL);
18 if ((php_sapi_name() !=
'cli')) {
19 trigger_error(
"You can only run this script from the command line\n", E_USER_ERROR);
23 $SYSTEM_ROOT = (isset($_SERVER[
'argv'][1])) ? $_SERVER[
'argv'][1] :
'';
24 if (empty($SYSTEM_ROOT) || !is_dir($SYSTEM_ROOT)) {
25 trigger_error(
"You need to supply the path to the System Root as the first argument\n", E_USER_ERROR);
27 $root_collection = (isset($_SERVER[
'argv'][2])) ? $_SERVER[
'argv'][2] :
'';
29 define(
'SQ_SYSTEM_ROOT', $SYSTEM_ROOT);
30 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
32 $root_user =& $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_user');
33 $GLOBALS[
'SQ_SYSTEM']->setCurrentUser($root_user);
34 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
37 $fm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'funnelback_manager');
38 $collections = $fm->attr(
'collections');
40 trigger_localised_error(
'FNB0020', E_USER_WARNING);
43 if (!$fm->attr(
'indexing')) {
44 echo
"\n\nBEFORE RUNNING THE SCRIPT, PLEASE CHECK THAT THE INDEXING STATUS IS TURNED ON\n";
45 echo
'Note: You can change this option from the backend "System Management" > "Funnelback Manager" > "Details"'.
"\n\n";
50 if (!empty($root_collection) && !isset($collections[$root_collection])) {
51 echo
"\n\nInvalid Collection ID passed in\n";
56 if (file_exists(SQ_TEMP_PATH.
'/funnelback.indexer')) {
57 trigger_localised_error(
'FNB0019', E_USER_WARNING);
62 touch(SQ_TEMP_PATH.
'/funnelback.indexer');
65 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
67 'collections'=> ((empty($root_collection)) ? Array() : $root_collection),
69 $errors = $hh->freestyleHipo(
'hipo_job_funnelback_reindex', $vars, SQ_PACKAGES_PATH.
'/funnelback/hipo_jobs');
70 if (!empty($errors)) {
71 echo
'Funnelback Reindexing FAILED'.
"\n";
72 foreach ($errors as $error) {
73 $line = array_get_index($error,
'message',
'');
81 if (file_exists(SQ_TEMP_PATH.
'/funnelback.indexer')) {
82 unlink(SQ_TEMP_PATH.
'/funnelback.indexer');
85 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();