function SearchBlog($pattern) { global $dataDir, $gp_index, $gp_titles, $config; if (!$this->search_config['search_blog']) { return; } $blog_index = SimpleSearch::BlogInstalled(); if (!$blog_index) { return; } $slug = array_search($blog_index, $gp_index); $addon = $gp_titles[$blog_index]['addon']; $blog_label = $gp_titles[$blog_index]['label']; //blod data folder $addon_info = $config['addons'][$addon]; if (isset($addon_info['data_folder'])) { $blog_data_folder = $dataDir . '/data/_addondata/' . $addon_info['data_folder']; } else { $blog_data_folder = $dataDir . '/data/_addondata/' . $addon; } // config of installed addon to get to know how many post files are $full_path = $blog_data_folder . '/index.php'; if (!file_exists($full_path)) { //nothing in the blog yet return; } require $full_path; $fileIndexMax = floor($blogData['post_index'] / 20); // '20' I found in SimpleBlogCommon.php function GetPostFile (line 62) for ($fileIndex = 0; $fileIndex <= $fileIndexMax; $fileIndex++) { $postFile = $blog_data_folder . '/posts_' . $fileIndex . '.php'; if (!file_exists($postFile)) { continue; } require $postFile; foreach ($posts as $id => $post) { $title = $blog_label . ': ' . str_replace('_', ' ', $post['title']); $content = str_replace('_', ' ', $post['title']) . ' ' . $post['content']; $this->findString($content, $pattern, $title, $slug, '?cmd=post&id=' . $id); } $posts = array(); } $this->ReduceResults(); }
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * SimpleSearch; if not, write to the Free Software Foundation, Inc., 59 Temple Place, * Suite 330, Boston, MA 02111-1307 USA * * @package simplesearch */ /** * SimpleSearchIndexAll snippet, used for indexing all resources with alternate search drivers * * @package simplesearch */ require_once $modx->getOption('sisea.core_path', null, $modx->getOption('core_path') . 'components/simplesearch/') . 'model/simplesearch/simplesearch.class.php'; $search = new SimpleSearch($modx, $scriptProperties); $search->loadDriver($scriptProperties); $memoryLimit = $modx->getOption('memory_limit', $scriptProperties, '512M'); @ini_set('memory_limit', $memoryLimit); @set_time_limit(0); $includeTVs = $modx->getOption('includeTVs', $scriptProperties, true); $processTVs = $modx->getOption('processTVs', $scriptProperties, true); /* build query */ $c = $modx->newQuery('modResource'); $c->where(array('searchable' => true, 'deleted' => false, 'published' => true)); $c->sortby('id', 'ASC'); $resources = $modx->getIterator('modResource', $c); $i = 0; foreach ($resources as $resource) { $resourceArray = $resource->toArray(); $templateVars =& $resource->getMany('TemplateVars');
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * SimpleSearch; if not, write to the Free Software Foundation, Inc., 59 Temple Place, * Suite 330, Boston, MA 02111-1307 USA * * @package simplesearch */ /** * Show the search form * * @var modX $modx * @var array $scriptProperties * @package simplesearch */ require_once $modx->getOption('sisea.core_path', null, $modx->getOption('core_path') . 'components/simplesearch/') . 'model/simplesearch/simplesearch.class.php'; $search = new SimpleSearch($modx, $scriptProperties); /* setup default options */ $scriptProperties = array_merge(array('tpl' => 'SearchForm', 'method' => 'get', 'searchIndex' => 'search', 'toPlaceholder' => false, 'landing' => $modx->resource->get('id')), $scriptProperties); if (empty($scriptProperties['landing'])) { $scriptProperties['landing'] = $modx->resource->get('id'); } /* if get value already exists, set it as default */ $searchValue = isset($_REQUEST[$scriptProperties['searchIndex']]) ? $_REQUEST[$scriptProperties['searchIndex']] : ''; $searchValues = explode(' ', $searchValue); array_map(array($modx, 'sanitizeString'), $searchValues); $searchValue = implode(' ', $searchValues); $placeholders = array('method' => $scriptProperties['method'], 'landing' => $scriptProperties['landing'], 'searchValue' => strip_tags(str_replace(array('[', ']', '"', "'"), array('[', ']', '"', '''), $searchValue)), 'searchIndex' => $scriptProperties['searchIndex']); $output = $search->getChunk($scriptProperties['tpl'], $placeholders); return $search->output($output, $scriptProperties['toPlaceholder']);
* * You should have received a copy of the GNU General Public License along with * SimpleSearch; if not, write to the Free Software Foundation, Inc., 59 Temple Place, * Suite 330, Boston, MA 02111-1307 USA * * @package simplesearch */ /** * SimpleSearch snippet * * @var modX $modx * @var array $scriptProperties * @package simplesearch */ require_once $modx->getOption('sisea.core_path', null, $modx->getOption('core_path') . 'components/simplesearch/') . 'model/simplesearch/simplesearch.class.php'; $search = new SimpleSearch($modx, $scriptProperties); /* find search index and toplaceholder setting */ $searchIndex = $modx->getOption('searchIndex', $scriptProperties, 'search'); $toPlaceholder = $modx->getOption('toPlaceholder', $scriptProperties, false); $noResultsTpl = $modx->getOption('noResultsTpl', $scriptProperties, 'SearchNoResults'); /* get search string */ if (empty($_REQUEST[$searchIndex])) { $output = $search->getChunk($noResultsTpl, array('query' => '')); return $search->output($output, $toPlaceholder); } $searchString = $search->parseSearchString($_REQUEST[$searchIndex]); if (!$searchString) { $output = $search->getChunk($noResultsTpl, array('query' => $searchString)); return $search->output($output, $toPlaceholder); } /* setup default properties */