<commit_before><?php

/**
 * SearchInstall
 * Installer for the search module
 *
 * @package		installer
 * @subpackage	search
 *
 * @author		<NAME> <<EMAIL>>
 * @since		2.0
 */
class SearchInstall extends ModuleInstaller
{
	/**
	 * Install the module
	 *
	 * @return	void
	 */
	protected function execute()
	{
		// load install.sql
		$this->importSQL(PATH_WWW .'/backend/modules/search/installer/install.sql');

		// add 'search' as a module
		$this->addModule('search', 'The search module.');

		// general settings
		$this->setSetting('search', 'overview_num_items', 10);
		$this->setSetting('search', 'validate_search', true);

		// module rights
		$this->setModuleRights(1, 'search');

		// action rights
		$this->setActionRights(1, 'search', 'add_synonym');
		$this->setActionRights(1, 'search', 'edit_synonym');
		$this->setActionRights(1, 'search', 'delete_synonym');
		$this->setActionRights(1, 'search', 'settings');
		$this->setActionRights(1, 'search', 'statistics');
		$this->setActionRights(1, 'search', 'synonyms');

		// add extra's
		$this->insertExtra(array('module' => 'search',
									'type' => 'block',
									'label' => 'Search',
									'action' => null,
									'data' => null,
									'hidden' => 'N',
									'sequence' => 3000));

		$this->insertExtra(array('module' => 'search',
									'type' => 'widget',
									'label' => 'SearchForm',
									'action' => 'form',
									'data' => null,
									'hidden' => 'N',
									'sequence' => 3001));

		// make 'pages' searchable
		$this->makeSearchable('pages');

		// define required constants used by backend classes
		define('FRONTEND_CACHE_PATH', PATH_WWW .'/frontend/cache');
		define('DB_TYPE', 'mysql');
		define('DB_HOSTNAME', 'localhost');
		define('DB_USERNAME', 'root');
		define('DB_PASSWORD', '<PASSWORD>');
		define('DB_DATABASE', 'forkng');

		// include backend model & language class, pages model, search model
		include_once PATH_WWW .'/backend/core/engine/model.php';
		include_once PATH_WWW .'/backend/core/engine/language.php';
		include_once PATH_WWW .'/backend/modules/pages/engine/model.php';
		include_once PATH_WWW .'/backend/modules/search/engine/model.php';

		// get existing menu items
		$menu = $this->getDB()->retrieve('SELECT m.id, m.revision_id, m.language, m.title FROM pages AS m WHERE m.status = ?', array('active'));

		// loop menu items
		foreach($menu as $id => $page)
		{
			// get blocks
			$blocks = $this->getDB()->getColumn('SELECT mb.html FROM pages_blocks AS mb WHERE mb.revision_id = ?', array($page['revision_id']));

			// merge blocks content
			$text = implode(' ', $blocks);

			// add page to search index
			BackendSearchModel::addIndex('pages', (int) $page['id'], array('title' => $page['title'], 'text' => $text), $page['language']);
		}

		// insert locale (nl)
		$this->insertLocale('nl', 'backend', 'search', 'err', 'SynonymIsRequired', 'Synoniemen zijn verplicht.');
		$this->insertLocale('nl', 'backend', 'search', 'err', 'TermIsRequired', 'De zoekterm is verplicht.');
		$this->insertLocale('nl', 'backend', 'search', 'err', 'TermExists', 'Synoniemen voor deze zoekterm bestaan reeds.');
		$this->insertLocale('nl', 'backend', 'search', 'err', 'WeightNotNumeric', 'Het gewicht moet numeriek zijn.');
		$this->insertLocale('nl', 'backend', 'search', 'lbl', 'AddSynonym', 'synoniem toevoegen');
		$this->insertLocale('nl', 'backend', 'search', 'lbl', 'DeleteSynonym', 'synoniem verwijderen');
		$this->insertLocale('nl', 'backend', 'search', 'lbl', 'EditSynonym', 'synoniem bewerken');
		$this->insertLocale('nl', 'backend', 'search', 'lbl', 'IP', 'IP');
		$this->insertLocale('nl', 'backend', 'search', 'lbl', 'ModuleWeight', 'module gewicht');
		$this->insertLocale('nl', 'backend', 'search', 'lbl', 'SearchedOn', 'gezocht op');
		$this->insertLocale('nl', 'backend', 'search', 'lbl', 'Synonym', 'synoniem');<commit_msg>oops, i left some garbage. cleaning up after myself<commit_after><?php

/**
 * SearchInstall
 * Installer for the search module
 *
 * @package		installer
 * @subpackage	search
 *
 * @author		<NAME> <<EMAIL>>
 * @since		2.0
 */
class SearchInstall extends ModuleInstaller
{
	/**
	 * Install the module
	 *
	 * @return	void
	 */
	protected function execute()
	{
		// load install.sql
		$this->importSQL(PATH_WWW .'/backend/modules/search/installer/install.sql');

		// add 'search' as a module
		$this->addModule('search', 'The search module.');

		// general settings
		$this->setSetting('search', 'overview_num_items', 10);
		$this->setSetting('search', 'validate_search', true);

		// module rights
		$this->setModuleRights(1, 'search');

		// action rights
		$this->setActionRights(1, 'search', 'add_synonym');
		$this->setActionRights(1, 'search', 'edit_synonym');
		$this->setActionRights(1, 'search', 'delete_synonym');
		$this->setActionRights(1, 'search', 'settings');
		$this->setActionRights(1, 'search', 'statistics');
		$this->setActionRights(1, 'search', 'synonyms');

		// add extra's
		$this->insertExtra(array('module' => 'search',
									'type' => 'block',
									'label' => 'Search',
									'action' => null,
									'data' => null,
									'hidden' => 'N',
									'sequence' => 3000));

		$this->insertExtra(array('module' => 'search',
									'type' => 'widget',
									'label' => 'SearchForm',
									'action' => 'form',
									'data' => null,
									'hidden' => 'N',
									'sequence' => 3001));

		// make 'pages' searchable
		$this->makeSearchable('pages');

		// get existing menu items
		$menu = $this->getDB()->retrieve('SELECT m.id, m.revision_id, m.language, m.title FROM pages AS m WHERE m.status = ?', array('active'));

		// loop menu items
		foreach($menu as $id => $page)
		{
			// get blocks
			$blocks = $this->getDB()->getColumn('SELECT mb.html FROM pages_blocks AS mb WHERE mb.revision_id = ?', array($page['revision_id']));

			// merge blocks content
			$text = implode(' ', $blocks);

			// add page to search index
			BackendSearchModel::addIndex('pages', (int) $page['id'], array('title' => $page['title'], 'text' => $text), $page['language']);
		}

		// insert locale (nl)
		$this->insertLocale('nl', 'backend', 'search', 'err', 'SynonymIsRequired', 'Synoniemen zijn verplicht.');
		$this->insertLocale('nl', 'backend', 'search', 'err', 'TermIsRequired', 'De zoekterm is verplicht.');
		$this->insertLocale('nl', 'backend', 'search', 'err', 'TermExists', 'Synoniemen voor deze zoekterm bestaan reeds.');
		$this->insertLocale('nl', 'backend', 'search', 'err', 'WeightNotNumeric', 'Het gewicht moet numeriek zijn.');
		$this->insertLocale('nl', 'backend', 'search', 'lbl', 'AddSynonym', 'synoniem toevoegen');
		$this->insertLocale('nl', 'backend', 'search', 'lbl', 'DeleteSynonym', 'synoniem verwijderen');
		$this->insertLocale('nl', 'backend', 'search', 'lbl', 'EditSynonym', 'synoniem bewerken');
		$this->insertLocale('nl', 'backend', 'search', 'lbl', 'IP', 'IP');
		$this->insertLocale('nl', 'backend', 'search', 'lbl', 'ModuleWeight', 'module gewicht');
		$this->insertLocale('nl', 'backend', 'search', 'lbl', 'SearchedOn', 'gezocht op');
		$this->insertLocale('nl', 'backend', 'search', 'lbl', 'Synonym', 'synoniem');
{'fraction_non_alphanumeric': 0.20583717357910905, 'fraction_numerical': 0.005306521435553694, 'mean_word_length': 4.246886446886447, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 102, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6610877', 'n_tokens_mistral': 2736, 'n_tokens_neox': 2378, 'n_words': 548}