18 require_once SQ_INCLUDE_PATH.
'/asset.inc';
43 $this->_ser_attrs = TRUE;
44 parent::__construct($assetid);
60 require_once SQ_CORE_PACKAGE_PATH.
'/system/system_asset_fns.inc';
61 if (!system_asset_fns_create_pre_check($this)) {
64 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
65 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
67 if ($linkid = parent::create($link)) {
68 if (!system_asset_fns_create_cleanup($this)) {
74 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
76 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
79 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
96 return $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($this->
type(),
'name');
142 if (!$this->
attr(
'indexing'))
return FALSE;
143 $vars[
'action'] =
'update';
163 if (!$this->
attr(
'indexing'))
return FALSE;
164 $vars[
'action'] =
'status_update';
183 if (!$this->
attr(
'indexing'))
return FALSE;
184 $vars[
'action'] =
'update';
204 if (!$this->
attr(
'indexing'))
return FALSE;
205 $vars[
'action'] =
'update';
225 if (!$this->
attr(
'indexing'))
return FALSE;
226 $vars[
'action'] =
'delete';
246 if (!$this->
attr(
'indexing'))
return FALSE;
247 $vars[
'action'] =
'permission_change';
267 if (!$this->
attr(
'indexing'))
return FALSE;
268 $vars[
'action'] =
'lookups_updated';
288 if (!$this->
attr(
'indexing'))
return FALSE;
289 $vars[
'action'] =
'metadata_delete';
309 if (!$this->
attr(
'indexing'))
return FALSE;
310 $vars[
'action'] =
'metadata_update';
333 if ($asset->id == $this->id)
return FALSE;
338 if (isset($asset->_tmp[
'__creating__']) && $asset->_tmp[
'__creating__'] === TRUE)
return FALSE;
341 $urls = $asset->getURLs();
343 return $this->_cleanupEntriesByAssetid($asset->id);
346 $action = array_get_index($vars,
'action',
'');
349 if ($action ==
'delete') {
350 return $this->_cleanupEntriesByAssetid($asset->id);
354 $exclusions = $this->
attr(
'global_exclude');
355 $excluded_assets = array_get_index($exclusions,
'assetid', Array());
356 $excluded_types = array_get_index($exclusions,
'type', Array());
357 $excluded_nodes = array_get_index($exclusions,
'tree', Array());
358 $asset_type = $asset->type();
361 if (in_array($asset->id, $excluded_assets)) {
362 return $this->_cleanupEntriesByAssetid($asset->id);
366 if (in_array($asset_type, $excluded_types)) {
367 return $this->_cleanupEntriesByAssetid($asset->id);
371 if (!empty($excluded_nodes)) {
372 if ($GLOBALS[
'SQ_SYSTEM']->am->isUnderRootNodes($asset->id, $excluded_nodes)) {
373 return $this->_cleanupEntriesByAssetid($asset->id);
379 $new_status = array_get_index($vars,
'new_status', 0);
380 $old_status = array_get_index($vars,
'old_status', 0);
381 if ($action ==
'status_update' && $new_status != $asset->status && $new_status != $old_status) {
382 $asset_status = $new_status;
384 $asset_status = $asset->status;
387 $public_user = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAssetid(
'public_user');
388 $live = (!($asset_status & SQ_SC_STATUS_NOT_LIVE) && $asset->readAccess(Array($public_user)));
389 $lookups = $asset->getLookups();
392 if ($this->_cleanupEntriesByAssetid($asset->id)) {
395 $url_template = $this->
_generateXML(
'%%sq_temp_fb_url%%', $asset);
401 $root_urls = array();
402 foreach ($lookups as $lookup) {
403 $lookup_url = array_get_index($lookup,
'url',
'');
404 $root_urlid = array_get_index($lookup,
'root_urlid', FALSE);
405 if ($root_urlid === FALSE)
continue;
406 if (empty($lookup_url))
continue;
407 $root_urls[$lookup_url] = $root_urlid;
411 foreach ($urls as $url_info) {
413 if (empty($url_info[
'url']))
continue;
416 if (array_key_exists($url_info[
'url'], $root_urls) === TRUE) {
417 $root_urlid = $root_urls[$url_info[
'url']];
423 $http_url = (($url_info[
'http']) ?
'http://'.$url_info[
'url'] :
'');
424 $https_url = (($url_info[
'https']) ?
'https://'.$url_info[
'url'] :
'');
426 $all_site_urls = $this->
_getSiteURL($root_urlid, $asset, $url_info[
'url']);
429 if (!empty($http_url)) {
430 $sitemap_url = str_replace(
''',
''', htmlspecialchars($http_url, ENT_QUOTES, SQ_CONF_DEFAULT_CHARACTER_SET));
431 $sitemap_xml = str_replace(
'%%sq_temp_fb_url%%', $sitemap_url, $url_template);
432 if (!empty($sitemap_xml)) {
433 foreach ($all_site_urls as $site_url) {
434 if(strpos($http_url,
'__data') !== FALSE) {
435 $original_urls = $asset->getOriginalURL($http_url, $site_url);
437 $original_urls = Array($http_url);
439 foreach($original_urls as $original_url) {
440 if (strpos($site_url,
'http:') === 0) {
441 $this->
_addEntry($http_url, $asset->id, $site_url, $root_urlid, $live, $sitemap_xml, $original_url);
449 if (!empty($https_url)) {
450 $sitemap_url = str_replace(
''',
''', htmlspecialchars($https_url, ENT_QUOTES, SQ_CONF_DEFAULT_CHARACTER_SET));
451 $sitemap_xml = str_replace(
'%%sq_temp_fb_url%%', $sitemap_url, $url_template);
452 if (!empty($sitemap_xml)) {
453 foreach ($all_site_urls as $site_url) {
454 if(strpos($https_url,
'__data') !== FALSE) {
455 $original_urls = $asset->getOriginalURL($https_url, $site_url);
457 $original_urls = Array($https_url);
459 foreach($original_urls as $original_url) {
460 if (strpos($site_url,
'https:') === 0) {
461 $this->
_addEntry($https_url, $asset->id, $site_url, $root_urlid, $live, $sitemap_xml, $original_url);
496 if (is_null($asset)) {
501 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
504 $xml .=
'<loc>'.$url.
'</loc>';
505 $xml .=
'<lastmod>'.date(
'Y-m-d', $asset->updated).
'T'.date(
'H:i:s', $asset->updated).
'</lastmod>';
508 if (!empty($access_locks)) {
509 $xml .=
'<fbmeta name="access_locks" content="'.$access_locks.
'" />';
514 $metadata = $mm->getMetadata($asset->id);
517 $schemas_applied = $mm->getSchemas($asset->id, TRUE);
518 $default_values = Array();
519 foreach($schemas_applied as $schemaid) {
520 $defaults = $mm->getSchemaDefaultValues($schemaid);
522 foreach ($defaults as $field_id => $field_info) {
523 if(isset($metadata[$field_id]))
continue;
524 $metadata[$field_id][0] = $field_info;
528 foreach ($metadata as $info) {
529 $name = $info[0][
'name'];
533 if ($name ==
'access_locks')
continue;
535 $value = $info[0][
'value'];
536 require_once SQ_FUDGE_PATH.
'/general/text.inc';
537 $keywords = retrieve_keywords_replacements($value);
538 $replacements = Array();
539 foreach ($keywords as $keyword) {
540 $replacements[$keyword] = $asset->getKeywordReplacement($keyword);
542 replace_keywords($value, $replacements);
543 $name = htmlspecialchars($name, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET);
544 $value = htmlspecialchars($value, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET);
545 $xml .=
'<fbmeta name="'.$name.
'" content="'.$value.
'" />';
547 $xml .=
'<fbmeta name="SQUIZASSETID" content="'.$asset->id.
'" />';
548 $xml .=
'<fbmeta name="SQUIZASSETTYPE" content="'.$asset->type().
'" />';
568 $am = $GLOBALS[
'SQ_SYSTEM']->am;
575 if (!($asset->status & SQ_SC_STATUS_NOT_LIVE)) {
576 $permissions = $am->getPermission($asset->id, SQ_PERMISSION_READ, TRUE);
578 $permissions = $am->getPermission($asset->id, SQ_PERMISSION_WRITE, TRUE);
580 $public_user_id = $am->getSystemAssetId(
'public_user');
581 $root_user_id = $am->getSystemAssetId(
'root_user');
582 $sys_admin_folder_id = $am->getSystemAssetId(
'system_user_group');
585 if (in_array($public_user_id, $permissions) && !($asset->status & SQ_SC_STATUS_NOT_LIVE)) {
586 $permissions[] =
'public';
588 $all_permissions = Array();
589 foreach ($permissions as $permission) {
590 $all_permissions[] =
"'".$this->encodeText(htmlspecialchars($permission, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET)).
"'";
594 if (!in_array(
"'".$root_user_id.
"'", $all_permissions)) {
595 $all_permissions[] =
"'".$this->encodeText(htmlspecialchars($root_user_id, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET)).
"'";
599 if (!in_array(
"'".$sys_admin_folder_id.
"'", $all_permissions)) {
600 $all_permissions[] =
"'".$this->encodeText(htmlspecialchars($sys_admin_folder_id, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET)).
"'";
603 $xml = rtrim(implode(
',', $all_permissions),
',');
624 public function _addEntry($url, $assetid, $root_url, $root_urlid, $live, $xml, $original_url)
640 $base_url = $root_url;
641 while ($base_url !==
'.') {
643 if($base_url ==
'http:' || $base_url ==
'https:')
break;
645 if (strpos($url, $base_url) === 0) {
649 $base_url = dirname($base_url);
659 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
660 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
662 $check_sql =
'SELECT assetid FROM sq_fnb_idx WHERE url=:url AND assetid=:assetid AND root_url=:root_url';
663 $check_query = MatrixDAL::preparePDOQuery($check_sql);
668 if (empty($results)) {
670 $sql =
'INSERT INTO sq_fnb_idx (url, assetid, root_url, root_urlid, live, xml, original_url) VALUES (:url, :assetid, :root_url, :root_urlid, :live, :xml, :original_url)';
671 $query = MatrixDAL::preparePDOQuery($sql);
681 }
catch (PDOException $e) {
682 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
683 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
684 trigger_error(
'Unable to add entry to database: '.$e->getMessage());
687 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
688 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
704 private function _cleanupEntriesByAssetid($assetid)
706 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
707 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
709 $sql =
'DELETE FROM sq_fnb_idx WHERE assetid=:assetid';
710 $query = MatrixDAL::preparePDOQuery($sql);
713 }
catch (PDOException $e) {
714 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
715 trigger_error(
'Unable to remove entries from database: '.$e->getMessage());
718 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
719 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
738 $results = $this->
getXMLCache($url, $assetid, $public);
741 echo
'<'.
'?xml version="1.0" encoding="utf-8"?'.
'>';
742 echo
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
743 foreach ($results as $result) {
744 echo $result[
'xml'].
"\n";
747 $contents = ob_get_contents();
766 public function getXMLCache($url=Array(), $assetid=0, $public=TRUE, $excludes=Array())
768 if (empty($url) || empty($assetid)) {
772 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
773 $is_site_asset = !empty($asset) ? ($asset->type() ==
'site') : TRUE;
776 $bind_vars = Array();
777 $include_collection_sql =
'';
778 $exclude_string =
'';
781 foreach ($url as $index => $single_url) {
782 if (!$is_site_asset) {
783 $suburl = substr($single_url, strpos($single_url,
'://') + 3);
784 $root_url_info = $GLOBALS[
'SQ_SYSTEM']->am->getRootURL($suburl);
785 $root_url = array_get_index($root_url_info,
'url',
'');
786 $assetid = array_get_index($root_url_info,
'assetid', $assetid);
789 $bind_vars[
'asset_url'.$index] = $single_url;
790 $include_collection_sql =
' OR f.url LIKE :asset_url'.$index;
792 $root_url = $single_url;
795 $single_url = rtrim($single_url,
'/');
796 $root_url = rtrim($root_url,
'/');
797 $protocol = parse_url($single_url, PHP_URL_SCHEME);
798 $where[] =
'((f.url LIKE :url'.$index.$include_collection_sql.
') AND f.root_urlid IN (SELECT urlid FROM sq_ast_url WHERE assetid=:assetid'.$index.
')) OR ((f.root_url = :root_url'.$index.
' AND f.root_urlid=\'0\') AND (f.original_url LIKE :original_url'.$index.
'))';
799 $bind_vars[
'url'.$index] = $single_url.
'/%';
800 $bind_vars[
'original_url'.$index] = $single_url.
'/%';
801 $bind_vars[
'assetid'.$index] = $assetid;
802 if (strpos($root_url,
'http:') === FALSE && strpos($root_url,
'https:') === FALSE) {
803 $bind_vars[
'root_url'.$index] = $protocol.
'://'.$root_url;
805 $bind_vars[
'root_url'.$index] = $root_url;
810 foreach ($excludes as $index => $exclude) {
811 $excluded[] =
'f.url||\'/\' NOT LIKE :exclude'.$index.
' OR f.url <> :exclude_asset'.$index;
812 $bind_vars[
'exclude'.$index] = rtrim($exclude,
'/').
'/%';
813 $bind_vars[
'exclude_asset'.$index] = rtrim($exclude,
'/');
815 if (!empty($excluded)) {
816 $exclude_string =
' AND (('.implode(
') AND (', $excluded).
'))';
819 if (isset($root_url_info)) unset($root_url_info);
824 $sql =
'SELECT DISTINCT f.url, f.xml
826 INNER JOIN sq_ast_lnk l ON l.minorid=f.assetid
827 WHERE l.is_dependant=:dependant';
830 $sql =
'SELECT f.url, f.assetid, f.root_url, f.xml
832 INNER JOIN sq_ast_lnk l ON l.minorid=f.assetid
833 WHERE l.is_dependant=:dependant';
836 if ($public) $sql .=
' AND f.live=:live';
838 $sql .= rtrim(implode(
' OR ', $where),
'OR');
840 $sql .= $exclude_string;
841 $sql .=
' ORDER BY f.url';
843 $query = MatrixDAL::preparePDOQuery($sql);
846 foreach ($bind_vars as $var_name => $var_value) {
851 }
catch (Exception $e) {
852 trigger_error(
'DB Error '.$e->getMessage());
858 $unique_results = Array();
859 foreach($results as $key => $result) {
861 if (isset($unique_results[$result[
'url'].
'|'.$result[
'assetid'].
'|'.$result[
'root_url']])) {
862 unset($results[$key]);
864 $unique_results[$result[
'url'].
'|'.$result[
'assetid'].
'|'.$result[
'root_url']] = 1;
867 unset($unique_results);
884 protected function _getSiteURL($root_urlid=
'0', &$asset, $asset_url)
888 if (empty($root_urlid)) {
890 $sites = array_keys($GLOBALS[
'SQ_SYSTEM']->am->getParents($asset->id,
'site', TRUE));
892 foreach ($sites as $site) {
893 $url_info = $GLOBALS[
'SQ_SYSTEM']->am->getUrls($site);
894 foreach ($url_info as $info) {
900 foreach ($urls as $details) {
901 $http = array_get_index($details,
'http', 0);
902 $https = array_get_index($details,
'https', 0);
903 $url = array_get_index($details,
'url',
'');
906 if (empty($url))
continue;
909 $system_root_url = sq_root_url($asset_url, FALSE);
910 if(strpos($url, $system_root_url) !== 0)
continue;
914 $site_url[] =
'http://'.$url;
917 $site_url[] =
'https://'.$url;
925 $sql =
'SELECT http, https, url FROM sq_ast_url WHERE urlid=:urlid';
926 $query = MatrixDAL::preparePDOQuery($sql);
929 }
catch (Exception $e) {
930 trigger_error(
'DB Error '.$e->getMessage());
934 if (!empty($results)) {
936 $result = $results[0];
937 $http = array_get_index($result,
'http', 0);
938 $https = array_get_index($result,
'https', 0);
939 $url = array_get_index($result,
'url',
'');
941 if (($http) && !empty($url)) {
942 $site_url[] =
'http://'.$url;
945 if (($https) && !empty($url)) {
946 $site_url[] =
'https://'.$url;
971 if (isset($collections[$collection_id][
'valid']) && $collections[$collection_id][
'valid'] === TRUE) {
988 $collections = $this->
attr(
'collections');
1005 $collections = $this->
attr(
'collections');
1006 $collection = array_get_index($collections, $collection_id, Array());
1007 return array_get_index($collection,
'name',
'');
1024 $fb_data_path = $this->data_path;
1026 if (empty($collection_id))
return $path;
1027 if (!isset($collections[$collection_id]))
return $path;
1029 $path = $fb_data_path.
'/'.$collection_id;
1030 if (!empty($sub_dir)) $path .=
'/'.$sub_dir;
1031 if (!is_dir($path) && !is_writable($path)) {
1033 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
1034 $status = create_directory($path);
1035 if ($status === FALSE) {
1037 trigger_localised_error(
'FNB0013', E_USER_WARNING);
1059 if (empty($path))
return $config;
1061 $config[
'executables'] = $path.
'/executables.cfg';
1062 $config[
'collection'] = $path.
'/collection.cfg';
1063 $config[
'fluster'] = $path.
'/contextual_navigation.cfg';
1064 $config[
'metadata'] = $path.
'/metamap.cfg';
1065 $config[
'xml'] = $path.
'/xml.cfg';
1083 $config = (string) $config;
1087 if (file_exists($default_file) && !file_exists($file)) {
1088 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
1089 copy_file($default_file, $file);
1095 if (file_exists($default_file) && !file_exists($file)) {
1096 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
1097 copy_file($default_file, $file);
1103 case 'contextual_navigation.cfg':
1105 if (file_exists($default_file) && !file_exists($file)) {
1106 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
1107 copy_file($default_file, $file);
1117 if (file_exists($default_file) && !file_exists($file)) {
1118 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
1119 copy_file($default_file, $file);
1127 if (file_exists($default_file) && !file_exists($file)) {
1128 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
1129 copy_file($default_file, $file);
1150 'web' => translate(
'funnelback_collection_type_web'),
1151 'meta' => translate(
'funnelback_collection_type_meta'),
1169 $available_opts = Array(
1170 'politeness' =>
'-politeness',
1172 'spelleroff' =>
'-spelleroff',
1173 'spelling_threshold' =>
'-spelling_threshold',
1175 'ixcom' =>
'-ixcom',
1179 $options[] =
'-annie';
1180 $options[] =
'-cleanup';
1183 foreach ($available_opts as $opt_name => $opt_switch) {
1184 $attribute = $this->
attr($opt_name);
1185 if (in_array($opt_name, Array(
'politeness',
'spelling_threshold')) && $attribute ==
'0') {
1187 $options[] = $opt_switch.
'0';
1188 }
else if ($opt_name ==
'orgname') {
1190 if (!empty($attribute)) {
1191 $options[] =
'-O'.escapeshellarg($attribute);
1194 if (!empty($attribute)) {
1195 if (in_array($opt_name, Array(
'politeness',
'spelling_threshold'))) {
1196 $options[] = $opt_switch.$attribute;
1198 $options[] = $opt_switch;
1226 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
1227 $contents = file_to_string($config);
1228 $lines = explode(
"\n", $contents);
1231 foreach ($lines as $line) {
1232 if (strpos($line, $delimiter) !== FALSE) {
1234 $line_contents = explode($delimiter, $line);
1236 $number_elements = count($line_contents);
1241 $query =
'substring';
1242 if ($number_elements == 4) {
1244 $trigger = array_get_index($line_contents, 0,
'');
1245 $title = array_get_index($line_contents, 1,
'');
1246 $desc = array_get_index($line_contents, 2,
'');
1247 $url = array_get_index($line_contents, 3,
'');
1248 }
else if ($number_elements == 3) {
1250 $trigger = array_get_index($line_contents, 0,
'');
1251 $title = array_get_index($line_contents, 1,
'');
1252 $url = array_get_index($line_contents, 3,
'');
1255 $trigger = array_get_index($line_contents, 0,
'');
1256 $url = array_get_index($line_contents, 3,
'');
1260 if (!empty($trigger) && !empty($url)) {
1261 if (strpos($trigger,
'~') === 0) {
1262 $trigger = substr($trigger, 1);
1264 }
else if (strpos($trigger,
'%') === 0) {
1265 $trigger = substr($trigger, 1);
1267 }
else if (strpos($trigger,
'+') === 0) {
1268 $trigger = substr($trigger, 1);
1274 'trigger' => $trigger,
1277 if (!empty($title)) $data_line[
'title'] = $title;
1278 if (!empty($desc)) $data_line[
'desc'] = $desc;
1279 $data[] = $data_line;
1286 foreach ($lines as $line) {
1287 $line = trim($line);
1288 if (!empty($line) && ((strpos($line,
'#') !== 0) || (strpos($line, $delimiter) !== FALSE))) {
1289 $line_data = explode($delimiter, $line);
1290 if (isset($line_data[0]) && !empty($line_data[0])) {
1294 'site.max_clusters',
1295 'type.max_clusters',
1296 'topic.max_clusters',
1298 if (!in_array($line_data[0], $invalid)) {
1299 $data[$line_data[0]] = $line_data[1];
1307 foreach ($lines as $line) {
1308 $line = trim($line);
1309 if (!empty($line) && ((strpos($line,
'#') !== 0) && (strpos($line, $delimiter) !== FALSE))) {
1310 $line_data = explode($delimiter, $line);
1311 if (!empty($line_data[0]) && isset($line_data[1]) && !empty($line_data[2])) {
1312 $alias = $line_data[0];
1313 $content = (($line_data[1] ==
'1') ?
'1' :
'0');
1314 $metatag = $line_data[2];
1315 $found_comment = strpos($metatag,
'#');
1316 if ($found_comment !== FALSE) {
1317 $metatag = substr($metatag, 0, $found_comment);
1321 'content' => $content,
1322 'metatag' => trim($metatag),
1333 'metatag' =>
'access_locks',
1340 foreach ($lines as $line) {
1341 if (strpos($line, $delimiter) !== FALSE) {
1343 $line_contents = explode($delimiter, $line);
1344 $query = array_get_index($line_contents, 0,
'%');
1345 $term = array_get_index($line_contents, 1,
'');
1346 $expansion = array_get_index($line_contents, 2,
'');
1347 if ($query ==
'+') {
1348 $query_exp =
'whole';
1349 }
else if ($query ==
'~') {
1350 $query_exp =
'regex';
1351 }
else if ($query ==
'%') {
1352 $query_exp =
'term';
1355 if (!empty($term) && !empty($expansion)) {
1358 'query' => $query_exp,
1360 'expansion' => $expansion,
1390 foreach ($data as $line) {
1391 $query = array_get_index($line,
'query',
'substring');
1392 $trigger = array_get_index($line,
'trigger',
'');
1393 $title = array_get_index($line,
'title',
'');
1394 $desc = array_get_index($line,
'desc',
'');
1395 $url = array_get_index($line,
'url',
'');
1397 if ($query ==
'exact') {
1399 }
else if ($query ==
'term') {
1401 }
else if ($query ==
'regex') {
1405 if (!empty($trigger) && !empty($url)) {
1407 $contents .= $pre_line.$trigger.$delimiter;
1408 if (!empty($title)) $contents .= $title.$delimiter;
1409 if (!empty($desc)) $contents .= $desc.$delimiter;
1410 $contents .= $url.
"\n";
1417 $contents .=
"# Fluster Configuration\n";
1422 'site.max_clusters',
1423 'type.max_clusters',
1424 'topic.max_clusters',
1427 foreach ($data as $switch => $parameter) {
1428 if (in_array($switch, $invalid))
continue;
1429 $contents .= $switch.$delimiter.$parameter.
"\n";
1435 $contents .=
"# Metadata Mapping Configuration\n";
1437 foreach ($data as $line) {
1438 $alias = array_get_index($line,
'alias',
'');
1439 $field = array_get_index($line,
'content', 0);
1440 $metag = array_get_index($line,
'metatag',
'');
1441 if (!empty($metag) || $alias !=
'S') {
1442 $contents .= $alias.$delimiter.$field.$delimiter.$metag.
"\n";
1447 $contents .=
'S,4,access_locks'.
"\n";
1452 $contents =
"PADRE Thesaurus Version: 2\n";
1453 foreach ($data as $line) {
1454 $query = array_get_index($line,
'query',
'%');
1455 $term = array_get_index($line,
'term',
'');
1456 $expansion = array_get_index($line,
'expansion',
'');
1458 if (!empty($term) && !empty($expansion)) {
1459 $contents .= $query.$delimiter.$term.$delimiter.$expansion.
"\n";
1465 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
1466 $status = string_to_file($contents, $config);
1486 function runCommand($command, &$output, $input=NULL, $log_file=NULL, $cwd=NULL, $environment=Array())
1489 $fm = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'funnelback_manager');
1491 $environment[
'SEARCH_HOME'] = $search_home;
1492 if (!isset($environment[
'SITE_SEARCH_ROOT']) && !is_null($cwd)) {
1493 $environment[
'SITE_SEARCH_ROOT'] = $cwd;
1495 if (is_null($log_file)) {
1518 $process = proc_open($command, $spec, $pipes, $cwd, $environment);
1520 if (is_resource($process)) {
1522 if (!is_null($input)) {
1523 fwrite($pipes[0], $input);
1527 if (is_null($log_file)) {
1529 $output .= stream_get_contents($pipes[1]);
1533 $errors = stream_get_contents($pipes[2]);
1534 if (!empty($errors)) {
1535 error_log(
"Funnelback Command failed, see funnelback.log for additional detail.");
1536 log_write($errors,
'funnelback');
1542 $status = proc_close($process);
1565 for ($i=0; $i<32; $i++) {
1566 $pattern[] = chr($i);
1568 for ($i=127; $i<161; $i++) {
1569 $pattern[] = chr($i);
1572 foreach ($pattern as $patt) {
1573 if (SQ_CONF_DEFAULT_CHARACTER_SET ==
'utf-8' && function_exists(
'mb_substr') && function_exists(
'mb_strlen') && function_exists(
'mb_strpos')) {
1575 $patt = utf8_encode($patt);
1577 $pos = mb_strpos($text, $patt);
1578 while ($pos !== FALSE) {
1579 $text = mb_substr($text, 0, $pos).$replace.mb_substr($text, $pos + mb_strlen($patt));
1580 $pos = mb_strpos($text, $patt, $pos+mb_strlen($replace));
1583 $text = str_replace($patt,
'', $text);
1588 $text = str_replace(
'"',
'', $text);
1589 $text = str_replace(
"'",
'', $text);
1592 $text = str_replace(
' ',
'', $text);
1593 $text = str_replace(
' ',
'', $text);
1612 $text = str_replace(
'“',
'"', $text);
1613 $text = str_replace(
'‘',
"'", $text);
1616 $text = str_replace(
' ',
' ', $text);
1633 'a' => translate(
'fb_mclass',
'a'),
1634 'b' => translate(
'fb_mclass',
'b'),
1635 'c' => translate(
'fb_mclass',
'c'),
1636 'd' => translate(
'fb_mclass',
'd'),
1637 'e' => translate(
'fb_mclass',
'e'),
1638 'f' => translate(
'fb_mclass',
'f'),
1639 'g' => translate(
'fb_mclass',
'g'),
1640 'h' => translate(
'fb_mclass',
'h'),
1641 'i' => translate(
'fb_mclass',
'i'),
1642 'j' => translate(
'fb_mclass',
'j'),
1643 'k' => translate(
'fb_mclass',
'k'),
1644 'l' => translate(
'fb_mclass',
'l'),
1645 'm' => translate(
'fb_mclass',
'm'),
1646 'n' => translate(
'fb_mclass',
'n'),
1647 'o' => translate(
'fb_mclass',
'o'),
1648 'p' => translate(
'fb_mclass',
'p'),
1649 'q' => translate(
'fb_mclass',
'q'),
1650 'r' => translate(
'fb_mclass',
'r'),
1651 's' => translate(
'fb_mclass',
's'),
1652 't' => translate(
'fb_mclass',
't'),
1653 'u' => translate(
'fb_mclass',
'u'),
1654 'v' => translate(
'fb_mclass',
'v'),
1655 'w' => translate(
'fb_mclass',
'w'),
1656 'x' => translate(
'fb_mclass',
'x'),
1657 'y' => translate(
'fb_mclass',
'y'),
1658 'z' => translate(
'fb_mclass',
'z'),
1659 'A' => translate(
'fb_mclass',
'A'),
1660 'B' => translate(
'fb_mclass',
'B'),
1661 'C' => translate(
'fb_mclass',
'C'),
1662 'D' => translate(
'fb_mclass',
'D'),
1663 'E' => translate(
'fb_mclass',
'E'),
1664 'F' => translate(
'fb_mclass',
'F'),
1665 'G' => translate(
'fb_mclass',
'G'),
1666 'H' => translate(
'fb_mclass',
'H'),
1667 'I' => translate(
'fb_mclass',
'I'),
1668 'J' => translate(
'fb_mclass',
'J'),
1669 'K' => translate(
'fb_mclass',
'K'),
1670 'L' => translate(
'fb_mclass',
'L'),
1671 'M' => translate(
'fb_mclass',
'M'),
1672 'N' => translate(
'fb_mclass',
'N'),
1673 'O' => translate(
'fb_mclass',
'O'),
1674 'P' => translate(
'fb_mclass',
'P'),
1675 'Q' => translate(
'fb_mclass',
'Q'),
1676 'R' => translate(
'fb_mclass',
'R'),
1677 'S' => translate(
'fb_mclass',
'S'),
1678 'T' => translate(
'fb_mclass',
'T'),
1679 'U' => translate(
'fb_mclass',
'U'),
1680 'V' => translate(
'fb_mclass',
'V'),
1681 'W' => translate(
'fb_mclass',
'W'),
1682 'X' => translate(
'fb_mclass',
'X'),
1683 'Y' => translate(
'fb_mclass',
'Y'),
1684 'Z' => translate(
'fb_mclass',
'Z'),
1685 '0' => translate(
'fb_mclass',
'0'),
1686 '1' => translate(
'fb_mclass',
'1'),
1687 '2' => translate(
'fb_mclass',
'2'),
1688 '3' => translate(
'fb_mclass',
'3'),
1689 '4' => translate(
'fb_mclass',
'4'),
1690 '5' => translate(
'fb_mclass',
'5'),
1691 '6' => translate(
'fb_mclass',
'6'),
1692 '7' => translate(
'fb_mclass',
'7'),
1693 '8' => translate(
'fb_mclass',
'8'),
1694 '9' => translate(
'fb_mclass',
'9'),
1708 return '/opt/funnelback-oem';
1722 return '!NOdfadksjflTERMSdsjdskfSUBMITTED';
1738 if (!file_exists($search_dir.
'/'.$file) && !is_readable($search_dir.
'/'.$file)) {
1758 $indexer = (($path) ?
'bin/' :
'').
'padre-iw';
1759 $search = (($path) ?
'bin/' :
'').
'padre-sw';
1760 $fl = (($path) ?
'bin/' :
'').
'padre-fl';
1761 $annie = (($path) ?
'bin/' :
'').
'annie-a';
1762 $spelling = (($path) ?
'bin/' :
'').
'build_spelling_index';
1763 $click = (($path) ?
'bin/' :
'').
'clix2anx';
1764 $config_xml = (($path) ?
'conf/' :
'').
'xml.cfg';
1765 $config_metamap = (($path) ?
'conf/' :
'').
'metamap.cfg';
1766 $config_fluster = (($path) ?
'conf/' :
'').
'contextual_navigation.cfg';
1767 $licence = (($path) ?
'VERSION/' :
'').
'squiz.lic';