public function executeMain() { $user = ""; $group = ""; $path = ""; $menuManager = new MenuManager(); $sections = $menuManager->getSections(); $this->page->addVar('menu', $sections); if ($this->getApplication()->getRequest()->hasPostValues()) { if ($this->getApplication()->getRequest()->getPostData("user")) { $user = $this->getApplication()->getRequest()->getPostData("user"); } if ($this->getApplication()->getRequest()->getPostData("group")) { $group = $this->getApplication()->getRequest()->getPostData("group"); } if ($this->getApplication()->getRequest()->getPostData("path")) { $path = $this->getApplication()->getRequest()->getPostData("path"); } $searchManager = new SearchManager(); $result = $searchManager->getStatistics($user, $group, $path); $rowNumber = $searchManager->getRowNumber(); $this->page->addVar('result', $result); $this->page->addVar('rowNumber', $rowNumber); $this->page->addVar('page', 'result'); } else { $this->page->addVar('page', 'form'); } $this->page->addVar('fsname', $menuManager->getfsname()); }
/** * Parses the $query into an SearchQuery Object, and send it to the * SearchManager Obect, which prepare and execute the search, and * returns the results. * * Example of returned value: * <pre> * array( * 'category' => array ( * 'amount' => integer * 'results' => array ('type' => (string) $markup->type, 'path' => (string) $markup->path, 'name' => (string) $markup->name, 'size' => (string) $markup->size) * ) * ) * </pre> * * FIXME: to be fixed using a generic Searchresult object. * * * @see SearchQuery * @see SearchManager * * @param string $query * @return array $results */ public function search($query) { $searchQuery = new SearchQuery(); $searchQuery->parseQuery($query); $searchManager = new SearchManager(); return $searchManager->search($searchQuery); }
function searchTag($tagLabel) { $searcher = new SearchManager(); //TODO controllare che il tag con quella etichetta non esista gi�!!! $tagToSearch = new Tag($tagLabel); // DA COMMENTARE PER TEST !!!!!!!!!!! /* if ($searcher->getResourceResultsByTag($tagToSearch) == NULL){ return 2; } else $this->composeResources($searcher->getResourceResultsByTag($tagToSearch)); */ return $searcher->getResourceResultsByTag($tagToSearch); }
private static function getAllSearchPluginClassNames() { if (self::$SearchPluginsImplementations === null) { self::$SearchPluginsImplementations = array(); $dir = new DirectoryIterator(FRAMEWORK_SEARCH_PLUGINS_PATH); foreach ($dir as $subFile) { $pluginName = $subFile->getFilename(); if ($subFile->isDir() && $pluginName[0] != '.') { if (is_file(FRAMEWORK_SEARCH_PLUGINS_PATH . '/' . $pluginName . '/' . $pluginName . '.php')) { require FRAMEWORK_SEARCH_PLUGINS_PATH . '/' . $pluginName . '/' . $pluginName . '.php'; if (class_exists($pluginName)) { self::$SearchPluginsImplementations[] = $pluginName; } } } } } return self::$SearchPluginsImplementations; }
public static function listsByProdType($userid, $limit, $offset, $type, $prodType) { $device = IjoyPlusServiceUtils::getDevice(); $where = ''; if ($device === false) { $key = SearchManager::CACHE_LISTS_BY_TYPE_LIMIT_OFFSET . '_USER_' . $userid . '_LIMIT_' . $limit . '_OFFSET_' . $offset . '_type_' . $prodType; } else { $where = ' AND (can_search_device like \'%' . $device . '%\' or can_search_device is null or can_search_device =\'\' ) '; $key = SearchManager::CACHE_LISTS_BY_TYPE_LIMIT_OFFSET . '_USER_' . $userid . '_LIMIT_' . $limit . '_OFFSET_' . $offset . '_type_' . $prodType . '_DEVICE_' . $device; } $lists = CacheManager::getValueFromCache($key); if ($lists) { return $lists; } if ($userid > 0) { $lists = Yii::app()->db->createCommand()->select('t_id as id, t_name as name, t_type as prod_type, t_pic as pic_url,t_des as content')->from('mac_vod_topic ')->where('t_userid=:t_userid and t_id>4 and t_type in (' . $prodType . ')' . $where, array(':t_userid' => $userid))->order('t_sort desc,create_date desc ')->limit($limit)->offset($offset)->queryAll(); } else { $lists = Yii::app()->db->createCommand()->select('t_id as id, t_name as name, t_type as prod_type, t_pic as pic_url,t_des as content')->from('mac_vod_topic ')->where('t_flag=:t_flag and t_id>4 and t_bdtype=:type and t_type in (' . $prodType . ')' . $where, array(':t_flag' => 1, ':type' => $type))->order('t_sort desc,create_date desc ')->limit($limit)->offset($offset)->queryAll(); } $temp = array(); if (isset($lists) && is_array($lists)) { foreach ($lists as $list) { $items = SearchManager::listItems($list['id'], SearchManager::USER_TOPS_LIST_ITEM_NUM, 0); if (isset($items) && is_array($items) && count($items) > 0) { $list['items'] = $items; if (!(isset($list['pic_url']) && is_null($list['pic_url']))) { $list['pic_url'] = $items[0]['prod_pic_url']; } $list['big_pic_url'] = $items[0]['big_prod_pic_url']; } $temp[] = $list; } if (count($temp) > 0) { $prodExpired = CacheManager::getExpireByCache(CacheManager::CACHE_PARAM_EXPIRED_POPULAR_PROGRAM); CacheManager::setValueToCache($key, $temp, $prodExpired); } } return $temp; }
public function testSearchFileRecollPlugin() { $query = "filename:*foo* filename:*lol* type:pdf OR type:xml AND ext:html OR ext:xml"; $searchQuery = new SearchQuery(); $searchQuery->setQueryString($this->query); $searchQuery->setQueryTokens($this->tokens); // we want to check if the SearchManager is well working, // means if it is able to load all the required library. $searchManager = new SearchManager(); $searchManager->search($searchQuery); // we also want to check if the parsing process // gives us a well formatted string. $recollPlugin = new SearchFileRecollPlugin(); $recollPlugin->search($searchQuery); $this->assertEquals($query, $recollPlugin->getSearchQuery()); // FileSearchListener::fileCreated() $this->assertFalse(is_file($this->fixture_file_path)); $this->assertTrue($this->fixture_file->createNewFile()); $this->assertTrue(is_file($this->fixture_file_path)); $searchQuery->setQueryString('testFile'); $searchQuery->setQueryTokens(null); $recollPlugin->resetSearchQuery(); $recollPlugin->search($searchQuery); $results = $recollPlugin->getResults(); $this->assertEquals($results[0]['name'], 'testFile.txt'); // FileSearchListener::fileDeleted() $this->assertTrue(is_file($this->fixture_file_path)); $this->assertTrue($this->fixture_file->delete()); $this->assertFalse(is_file($this->fixture_file_path)); $searchQuery->setQueryString('testFile'); $searchQuery->setQueryTokens(null); $recollPlugin->resetSearchQuery(); $recollPlugin->search($searchQuery); $results = $recollPlugin->getResults(); $this->assertTrue(empty($results)); // FileSearchListener::directoryCreated() $this->assertFalse(is_dir($this->fixture_dir_path)); $this->assertTrue($this->fixture_dir->mkdir()); $this->assertTrue(is_dir($this->fixture_dir_path)); $searchQuery->setQueryString('testDir'); $searchQuery->setQueryTokens(null); $recollPlugin->resetSearchQuery(); $recollPlugin->search($searchQuery); $results = $recollPlugin->getResults(); $this->assertEquals($results[0]['name'], 'testDir'); // FileSearchListener::fileMoved() $this->assertFalse(is_file($this->fixture_file_path)); $this->assertTrue($this->fixture_file->createNewFile()); $this->assertTrue(is_file($this->fixture_file_path)); $newFile = FSI::getFile('home://~fakeUser/testDir/testFile2.txt'); $this->assertTrue($this->fixture_file->moveTo($newFile)); $this->assertTrue(is_file($this->fixture_newFile_path)); $this->assertFalse(is_file($this->fixture_file_path)); $searchQuery->setQueryString('testFile2'); $searchQuery->setQueryTokens(null); $recollPlugin->resetSearchQuery(); $recollPlugin->search($searchQuery); $results = $recollPlugin->getResults(); $this->assertEquals($results[0]['name'], 'testFile2.txt'); $searchQuery->setQueryString('testFile'); $searchQuery->setQueryTokens(null); $recollPlugin->resetSearchQuery(); $recollPlugin->search($searchQuery); $results = $recollPlugin->getResults(); $this->assertNotEquals($results[0]['name'], 'testFile.txt'); $newFile->delete(); // FileSearchListener::fileRenamed() $this->assertFalse(is_file($this->fixture_file_path)); $this->assertTrue($this->fixture_file->createNewFile()); $this->assertTrue(is_file($this->fixture_file_path)); $this->assertTrue($this->fixture_file->renameTo('testFileRenamed.txt')); $searchQuery->setQueryString('testFile'); $searchQuery->setQueryTokens(null); $recollPlugin->resetSearchQuery(); $recollPlugin->search($searchQuery); $results = $recollPlugin->getResults(); $this->assertNotEquals($results[0]['name'], 'testFile.txt'); $this->assertEquals($results[0]['name'], 'testFileRenamed.txt'); // FileSearchListener::fileWritten() $this->fixture_file->putContents('take it easy!'); // TODO: check if the content's file is up to date. }
private function handlePluginSelect($tag, $parameters) { $pagesize = 20; $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $request = Request::getInstance(); $view = ViewManager::getInstance(); $page = $this->getPage(); $searchcriteria = isset($parameters) && array_key_exists('searchcriteria', $parameters) ? $parameters['searchcriteria'] : array(); $keys = isset($parameters) && array_key_exists('keys', $parameters) ? $parameters['keys'] : array(); $this->pagerUrl->addParameters($searchcriteria); $this->pagerUrl->setParameter($view->getUrlId(), $view->getType()); // handle searchcriteria $search = new SearchManager(); $search->setUrl($this->pagerUrl); $search->setExclude($this->pagerKey); $search->setParameter('search'); $search->saveList(); $searchcriteria = $search->getSearchParameterList(); //$searchcriteria = array_merge($searchcriteria, $key); $rangeKeys = array(); $list = $this->getList($searchcriteria, $pagesize, $page); foreach ($list['data'] as &$item) { $rangeKeys[] = $item['id']; $item['selected'] = in_array($item['id'], $keys); if ($item['thumbnail']) { $img = new Image($item['thumbnail'], $this->plugin->getContentPath(true)); $item['thumbnail'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight()); } } $template->setVariable('list', $list); $template->setVariable('searchparam', $search->getMandatoryParameterList()); $template->setVariable('searchcriteria', $searchcriteria); $template->setVariable('rangeKeys', $rangeKeys); $this->template[$tag] = $template; }
function actionSohuProduce() { header('Content-type: application/json'); if (!IjoyPlusServiceUtils::validateAPPKey()) { IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID); return; } $page_size = Yii::app()->request->getParam("page_size"); $page_num = Yii::app()->request->getParam("page_num"); if (!(isset($page_size) && is_numeric($page_size))) { $page_size = 10; $page_num = 1; } else { if (!(isset($page_num) && is_numeric($page_num))) { $page_num = 1; } } $top_id = 12192; try { $lists = SearchManager::listSohuProduce($top_id, $page_size, $page_size * ($page_num - 1)); if (isset($lists) && is_array($lists)) { IjoyPlusServiceUtils::exportEntity(array('results' => $lists)); } else { IjoyPlusServiceUtils::exportEntity(array('results' => array())); } } catch (Exception $e) { Yii::log(CJSON::encode($e), "error"); IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR); } }
/** * handle tree overview */ private function handleTreeOverview() { $pagesize = 20; $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $request = Request::getInstance(); $view = ViewManager::getInstance(); $view->setType(ViewManager::TREE_OVERVIEW); $page = $this->getPage(); if (!$request->exists('tree_id')) { throw new Exception('Node is missing.'); } if (!$request->exists('tag')) { throw new Exception('Tag is missing.'); } $tree_id = intval($request->getValue('tree_id')); $tag = $request->getValue('tag'); $key = array('tree_id' => $tree_id, 'tag' => $tag); $this->pagerUrl->addParameters($key); $this->pagerUrl->setParameter($view->getUrlId(), $view->getType()); // handle searchcriteria $search = new SearchManager(); $search->setUrl($this->pagerUrl); $search->setExclude($this->pagerKey); $search->setParameter('search'); $search->saveList(); $searchcriteria = $search->getSearchParameterList(); $searchcriteria = array_merge($searchcriteria, $key); // add breadcrumb item $url = new Url(true); $url->clearParameter('id'); $url->setParameter('tree_id', $tree_id); $url->setParameter('tag', $tag); // create urls $url_new = clone $url; $url_new->setParameter($view->getUrlId(), ViewManager::TREE_NEW); $template->setVariable('href_new', $url_new->getUrl(true), false); $url_conf = clone $url; $url_conf->setParameter($view->getUrlId(), Links::VIEW_CONFIG); $template->setVariable('href_conf', $url_conf->getUrl(true), false); $url_import = clone $url; $url_import->setParameter($view->getUrlId(), Links::VIEW_IMPORT); $template->setVariable('href_import', $url_import->getUrl(true), false); $url_resize = clone $url; $url_resize->setParameter($view->getUrlId(), Links::VIEW_RESIZE); $template->setVariable('href_resize', $url_resize->getUrl(true), false); $url_edit = clone $url; $url_edit->setParameter($view->getUrlId(), ViewManager::TREE_EDIT); $url_mv_prev = clone $url; $url_mv_prev->setParameter($view->getUrlId(), Links::VIEW_MV_PREC); $url_mv_next = clone $url; $url_mv_next->setParameter($view->getUrlId(), Links::VIEW_MV_FOL); $url_del = clone $url; $url_del->setParameter($view->getUrlId(), ViewManager::TREE_DELETE); $counter = 0; $list = $this->getList($searchcriteria, $pagesize, $page); $maxcount = $list['totalItems']; foreach ($list['data'] as &$item) { $counter++; $url_edit->setParameter('id', $item['id']); $url_del->setParameter('id', $item['id']); $url_mv_prev->setParameter('id', $item['id']); $url_mv_next->setParameter('id', $item['id']); $item['href_edit'] = $url_edit->getUrl(true); $item['href_del'] = $url_del->getUrl(true); if ($counter > 1) { $item['href_mv_prev'] = $url_mv_prev->getUrl(true); } if ($counter < $maxcount) { $item['href_mv_next'] = $url_mv_next->getUrl(true); } if ($item['url']) { $item['link'] = $item['url']; } elseif ($item['ref_tree_id']) { $item['link'] = $this->director->tree->getPath($item['ref_tree_id']); } else { $item['link'] = "link detailed page"; } if ($item['thumbnail']) { $img = new Image($item['thumbnail'], $this->getContentPath(true)); $item['thumbnail'] = array('src' => $this->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight()); } } $template->setVariable('list', $list, false); $template->setVariable('searchparam', $search->getMandatoryParameterList(), false); $template->setVariable('searchcriteria', $searchcriteria, false); $this->template[$this->director->theme->getConfig()->main_tag] = $template; }
static function searchForLikelihood($post) { return SearchManager::searchForLikelihood($post); }
/** * handle tree overview */ private function handleTreeOverview() { $pagesize = 20; $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $request = Request::getInstance(); $view = ViewManager::getInstance(); $view->setType(ViewManager::TREE_OVERVIEW); $page = $this->getPage(); if (!$request->exists('tree_id')) { throw new Exception('Node is missing.'); } if (!$request->exists('tag')) { throw new Exception('Tag is missing.'); } $tree_id = intval($request->getValue('tree_id')); $tag = $request->getValue('tag'); $key = array('tree_id' => $tree_id, 'tag' => $tag); $this->pagerUrl->addParameters($key); $this->pagerUrl->setParameter($view->getUrlId(), $view->getType()); // handle searchcriteria $search = new SearchManager(); $search->setUrl($this->pagerUrl); $search->setExclude($this->pagerKey); $search->setParameter('search'); $search->saveList(); $searchcriteria = $search->getSearchParameterList(); $searchcriteria = array_merge($searchcriteria, $key); $url = new Url(true); $url->clearParameter('id'); $url->clearParameter('poll_id'); $url->setParameter('tree_id', $tree_id); $url->setParameter('tag', $tag); // create urls $url_new = clone $url; $url_new->setParameter($view->getUrlId(), ViewManager::TREE_NEW); $template->setVariable('href_new', $url_new->getUrl(true), false); $url_conf = clone $url; $url_conf->setParameter($view->getUrlId(), Poll::VIEW_CONFIG); $template->setVariable('href_conf', $url_conf->getUrl(true), false); $url_edit = clone $url; $url_edit->setParameter($view->getUrlId(), ViewManager::TREE_EDIT); $url_del = clone $url; $url_del->setParameter($view->getUrlId(), ViewManager::TREE_DELETE); $url_item = clone $url; $url_item->setParameter($view->getUrlId(), Poll::VIEW_ITEM_OVERVIEW); $list = $this->getList($searchcriteria, $pagesize, $page); foreach ($list['data'] as &$item) { $url_edit->setParameter('id', $item['id']); $url_del->setParameter('id', $item['id']); $url_item->setParameter('poll_id', $item['id']); $item['href_edit'] = $url_edit->getUrl(true); $item['href_del'] = $url_del->getUrl(true); $item['href_item'] = $url_item->getUrl(true); } $template->setVariable('list', $list, false); $template->setVariable('searchparam', $search->getMandatoryParameterList(), false); $template->setVariable('searchcriteria', $searchcriteria, false); $this->template[$this->director->theme->getConfig()->main_tag] = $template; }
function actionPopShow() { header('Content-type: application/json'); // if(Yii::app()->user->isGuest){ // IjoyPlusServiceUtils::exportServiceError(Constants::SEESION_IS_EXPIRED); // return ; // } if (!IjoyPlusServiceUtils::validateAPPKey()) { IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID); return; } $page_size = Yii::app()->request->getParam("page_size"); $page_num = Yii::app()->request->getParam("page_num"); if (!(isset($page_size) && is_numeric($page_size))) { $page_size = 10; $page_num = 1; } else { if (!(isset($page_num) && is_numeric($page_num))) { $page_num = 1; } } try { $prods = SearchManager::popularProgram(SearchManager::POPULAR_TV_SHOW_SPECIAL_ID, $page_size, $page_size * ($page_num - 1)); if (isset($prods) && is_array($prods)) { IjoyPlusServiceUtils::exportEntity(array('show' => $prods)); } else { IjoyPlusServiceUtils::exportEntity(array('show' => array())); } } catch (Exception $e) { IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR); } }
<?php require dirname(dirname(__FILE__)) . '/includes/LoginManager.php'; if (!empty($_GET['query'])) { require_once dirname(dirname(__FILE__)) . '/includes/SearchManager.php'; $searchManager = new SearchManager(); $array = $searchManager->getArray($_GET['query']); if (!empty($array) && $array != null) { echo json_encode($array); } }
static function searchForLikelihood($post) { require_once 'manager/SearchManager.php'; return SearchManager::searchForLikelihood($post); }
function actionTops() { header('Content-type: application/json'); if (!IjoyPlusServiceUtils::validateAPPKey()) { IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID); return; } $userid = Yii::app()->request->getParam("userid"); if (!isset($userid) || is_null($userid)) { if (IjoyPlusServiceUtils::validateUserID()) { IjoyPlusServiceUtils::exportServiceError(Constants::USER_ID_INVALID); return; } $userid = Yii::app()->user->id; } $page_size = Yii::app()->request->getParam("page_size"); $page_num = Yii::app()->request->getParam("page_num"); $type = Yii::app()->request->getParam("type"); if (!(isset($page_size) && is_numeric($page_size))) { $page_size = 10; $page_num = 1; } else { if (!(isset($page_num) && is_numeric($page_num))) { $page_num = 1; } } try { if (isset($type) && !is_null($type) && strlen(trim($type)) > 0) { $lists = SearchManager::listsByProdType($userid, $page_size, $page_size * ($page_num - 1), 0, $type); } else { $lists = SearchManager::lists($userid, $page_size, $page_size * ($page_num - 1), 0); } if (isset($lists) && is_array($lists)) { IjoyPlusServiceUtils::exportEntity(array('tops' => $lists)); } else { IjoyPlusServiceUtils::exportEntity(array('tops' => array())); } } catch (Exception $e) { IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR); } }
private static function PCSameAuthor($data) { if (isset(self::$currentObject) && !is_null(self::$currentObject) && self::$currentObject !== false) { require_once 'user/UserManager.php'; $user = UserManager::loadUser(self::$currentObject->getAuthor(), false); if (true) { //TODO se l'autore vuole echo "<p>Dello stesso autore</p>"; require_once 'search/SearchManager.php'; $posts = SearchManager::searchBy("Post", array("author" => $user->getID(), "no_id" => self::$currentObject->getID(), "loadComments" => false), array("order" => -1, "by" => "ps_creationDate")); self::$post_options[PostPage::SHORT] = true; self::$post_options[PostPage::NO_COMMENTS] = true; self::$post_options[PostPage::NO_MODIF_DATE] = true; require_once 'post/PostPage.php'; foreach ($posts as $p) { PostPage::showPost($p, self::$post_options); } self::$post_options[PostPage::SHORT] = false; self::$post_options[PostPage::NO_COMMENTS] = false; self::$post_options[PostPage::NO_MODIF_DATE] = false; } } }
/** * handle tree overview */ private function handleTreeOverview() { $pagesize = 10; $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $record = $this->plugin->getObject(Form::TYPE_RECORD); $recordItem = $this->plugin->getObject(Form::TYPE_RECORD_ITEM); $request = Request::getInstance(); $view = ViewManager::getInstance(); $view->setType(ViewManager::TREE_OVERVIEW); $page = $this->getPage(); if (!$request->exists('tree_id')) { throw new Exception('Node ontbreekt.'); } if (!$request->exists('tag')) { throw new Exception('Tag ontbreekt.'); } $tree_id = intval($request->getValue('tree_id')); $tag = $request->getValue('tag'); $key = array('tree_id' => $tree_id, 'tag' => $tag); $template->setVariable($key); $this->pagerUrl->addParameters($key); $this->pagerUrl->setParameter($view->getUrlId(), $view->getType()); // store updated pager url to record object $record->setPagerUrl($this->pagerUrl); // handle searchcriteria $search = new SearchManager(); $search->setUrl($this->pagerUrl); $search->setExclude($this->pagerKey); $search->setParameter('search'); $search->saveList(); $searchcriteria = $search->getSearchParameterList(); $searchcriteria = array_merge($searchcriteria, $key); $url = new Url(true); $url->clearParameter('id'); $url->setParameter('tree_id', $tree_id); $url->setParameter('tag', $tag); // create urls $url_conf = clone $url; $url_conf->setParameter($view->getUrlId(), Form::VIEW_CONFIG); $template->setVariable('href_conf', $url_conf->getUrl(true), false); $url_elem = clone $url; $url_elem->setParameter($view->getUrlId(), Form::VIEW_ELEMENT_OVERVIEW); $template->setVariable('href_elem', $url_elem->getUrl(true), false); $url_del_all = clone $url; $url_del_all->setParameter($view->getUrlId(), Form::VIEW_RECORD_DEL_ALL); $template->setVariable('href_del_all', $url_del_all->getUrl(true), false); $url_export = clone $url; $url_export->setParameter($view->getUrlId(), Form::VIEW_RECORD_EXPORT); $template->setVariable('href_export', $url_export->getUrl(true), false); $url_new = clone $url; $url_new->setParameter($view->getUrlId(), ViewManager::TREE_NEW); $template->setVariable('href_new', $url_new->getUrl(true), false); $url_edit = clone $url; $url_edit->setParameter($view->getUrlId(), ViewManager::TREE_EDIT); // get columns and create template column list because not every record may have all the columns. $recordTemplate = array(); $columns = $recordItem->getColumns($tree_id, $tag); $columns[] = 'timestamp'; $columns[] = 'host'; foreach ($columns as $column) { $recordTemplate[$column] = ''; } $template->setVariable('columns', $columns); $themeVars = $this->director->theme->getFileVars(); $img_edit = $themeVars['img_edit']; $editString = '<a href="%s">' . sprintf('<img class="noborder" src="%s" width="%s" height="%s" alt="edit" title="edit" /></a>', $img_edit['src'], $img_edit['width'], $img_edit['height']); $delString = '<input type="checkbox" name="id[]" value="%d" class="noborder" />'; // retrieve all records within this tree node // array[record id] => timestamp $searchcriteria = array_merge($searchcriteria, $key); $searchcriteria['optin'] = ''; $recordlist = array(); $records = $record->getList($searchcriteria, $pagesize, $page); foreach ($records['data'] as $item) { $recordlist[$item['id']] = $item; } $template->setVariable('records', $records); $recordItemListFinal = array(); if ($recordlist) { // search for all form elements within the specified records $elemsearch = array('rcd_id' => array_keys($recordlist)); $recordItemList = $recordItem->getItems($elemsearch); foreach ($recordItemList as $rcd_id => $recordElement) { // set values to all the columns $element = $recordTemplate; foreach ($recordElement as $recordColumn) { // columnames are forced to lowercase, do the same for this result to merge case sensitive versions of columns $element[strtolower($recordColumn['name'])] = $recordColumn['value']; } $element['timestamp'] = strftime('%c', $recordlist[$rcd_id]['createdate']); $element['host'] = $recordlist[$rcd_id]['host']; $url_edit->setParameter('rcd_id', $rcd_id); $urls = array(); $urls[] = sprintf($delString, $rcd_id); $urls[] = sprintf($editString, $url_edit->getUrl(true)); array_unshift($element, join('', $urls)); $recordItemListFinal[] = $element; } } $template->setVariable('list', $recordItemListFinal); $template->setVariable('searchparam', $search->getMandatoryParameterList(), false); $template->setVariable('searchcriteria', $searchcriteria, false); $this->template[$this->director->theme->getConfig()->main_tag] = $template; }
/** * handle tree overview */ private function handleTreeOverview() { $pagesize = 20; $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $request = Request::getInstance(); $view = ViewManager::getInstance(); $view->setType(ViewManager::TREE_OVERVIEW); $page = $this->getPage(); if (!$request->exists('tree_id')) { throw new Exception('Node is missing.'); } if (!$request->exists('tag')) { throw new Exception('Tag is missing.'); } $tree_id = intval($request->getValue('tree_id')); $tag = $request->getValue('tag'); $key = array('tree_id' => $tree_id, 'tag' => $tag); $this->pagerUrl->addParameters($key); $this->pagerUrl->setParameter($view->getUrlId(), $view->getType()); // handle searchcriteria $search = new SearchManager(); $search->setUrl($this->pagerUrl); $search->setExclude($this->pagerKey); $search->setParameter('search'); $search->saveList(); $searchcriteria = $search->getSearchParameterList(); $searchcriteria = array_merge($searchcriteria, $key); $url = new Url(true); $url->clearParameter('id'); $url->clearParameter('nl_id'); $url->setParameter('tree_id', $tree_id); $url->setParameter('tag', $tag); // create urls $url_new = clone $url; $url_new->setParameter($view->getUrlId(), ViewManager::TREE_NEW); $template->setVariable('href_new', $url_new->getUrl(true), false); $url_conf = clone $url; $url_conf->setParameter($view->getUrlId(), NewsLetter::VIEW_CONFIG); $template->setVariable('href_conf', $url_conf->getUrl(true), false); $url_user = clone $url; $url_user->setParameter($view->getUrlId(), NewsLetter::VIEW_USER_OVERVIEW); $template->setVariable('href_user', $url_user->getUrl(true), false); $url_group = clone $url; $url_group->setParameter($view->getUrlId(), NewsLetter::VIEW_GROUP_OVERVIEW); $template->setVariable('href_group', $url_group->getUrl(true), false); $url_edit = clone $url; $url_edit->setParameter($view->getUrlId(), ViewManager::TREE_EDIT); $url_del = clone $url; $url_del->setParameter($view->getUrlId(), ViewManager::TREE_DELETE); $url_att = clone $url; $url_att->setParameter($view->getUrlId(), NewsLetter::VIEW_FILE_OVERVIEW); $url_preview = clone $url; $url_preview->setParameter($view->getUrlId(), NewsLetter::VIEW_PREVIEW); $url_send = clone $url; $url_send->setParameter($view->getUrlId(), NewsLetter::VIEW_SEND); $url_plugin = clone $url; $url_plugin->setParameter($view->getUrlId(), NewsLetter::VIEW_PLUGIN_OVERVIEW); $list = $this->getList($searchcriteria, $pagesize, $page); foreach ($list['data'] as &$item) { $url_edit->setParameter('id', $item['id']); $url_del->setParameter('id', $item['id']); $url_att->setParameter('nl_id', $item['id']); $url_plugin->setParameter('nl_id', $item['id']); $url_preview->setParameter('nl_id', $item['id']); $url_send->setParameter('nl_id', $item['id']); $item['href_edit'] = $url_edit->getUrl(true); $item['href_del'] = $url_del->getUrl(true); $item['href_att'] = $url_att->getUrl(true); $item['href_plugin'] = $url_plugin->getUrl(true); $item['href_preview'] = $url_preview->getUrl(true); $item['href_send'] = $url_send->getUrl(true); if ($item['thumbnail']) { $img = new Image($item['thumbnail'], $this->plugin->getContentPath(true)); $item['thumbnail'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight()); } } $template->setVariable('list', $list, false); $template->setVariable('searchparam', $search->getMandatoryParameterList(), false); $template->setVariable('searchcriteria', $searchcriteria, false); $this->template[$this->director->theme->getConfig()->main_tag] = $template; }
/** * handle overview request */ private function handleOverview() { $request = Request::getInstance(); $view = ViewManager::getInstance(); $page = $this->getPage(); $this->pagerUrl->setParameter($view->getUrlId(), $view->getType()); $view->setType(self::VIEW_OVERVIEW); $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $template->setVariable('pageTitle', $this->description); if (!$request->exists('ext_id')) { throw new Exception('Extension is missing.'); } $ext_id = intval($request->getValue('ext_id')); // handle searchcriteria $search = new SearchManager(); $search->setUrl($this->pagerUrl); $search->setExclude($this->pagerKey); $search->setParameter('search'); $search->setParameter('ext_id', $ext_id); $search->saveList(); $searchcriteria = $search->getSearchParameterList(); $url = new Url(true); $url->clearParameter('ip'); $url->setParameter('ext_id', $ext_id); $url_new = clone $url; $url_new->setParameter($view->getUrlId(), self::VIEW_NEW); $template->setVariable('href_new', $url_new->getUrl(true)); $url_edit = clone $url; $url_edit->setParameter($view->getUrlId(), self::VIEW_EDIT); $url_del = clone $url; $url_del->setParameter($view->getUrlId(), self::VIEW_DELETE); $list = $this->getList($searchcriteria, $this->pagesize, $page); foreach ($list['data'] as &$item) { $url_edit->setParameter('ip', $item['ip']); $url_del->setParameter('ip', $item['ip']); $item['href_edit'] = $url_edit->getUrl(true); $item['href_del'] = $url_del->getUrl(true); if ($item['suspect']) { $item['state'] = 'suspect'; } elseif (!$item['activated']) { $item['state'] = 'expired'; } else { $item['state'] = 'intruder'; } } $template->setVariable('list', $list); $template->setVariable('searchparam', $search->getMandatoryParameterList()); $template->setVariable('searchcriteria', $searchcriteria); $this->template[$this->director->theme->getConfig()->main_tag] = $template; }
/** * handle export */ private function handleExport() { $request = Request::getInstance(); $view = ViewManager::getInstance(); $cache = Cache::getInstance(); $filename = strtolower($this->getClassName()) . ".csv"; $csvContent = ''; if (!$cache->isCached($filename)) { require_once DIF_ROOT . "utils/CsvFile.php"; // handle searchcriteria $search = new SearchManager(); $search->setUrl($this->pagerUrl); $search->setExclude($this->pagerKey); $search->setParameter('search'); $search->saveList(); $searchcriteria = $search->getSearchParameterList(); $exportlist = array(); $list = $this->getList($searchcriteria); foreach ($list['data'] as $item) { $row = array_intersect_key($item, $this->exportColumns); $row['password'] = ''; $row['role'] = $this->getRoleDesc($row['role']); $exportlist[] = $row; } $csvFile = new CsvFile(); $csvContent = join("\n", $csvFile->array2csv($exportlist)); $cache->save($csvContent, $filename); } else { $csvContent = $cache->getCache($filename); } header("Content-type: text/csv"); header("Content-Disposition: attachment; filename=\"{$filename}\""); echo $csvContent; exit; }
/** * handle tree overview */ private function handleTreeOverview() { $pagesize = 20; $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $request = Request::getInstance(); $view = ViewManager::getInstance(); $view->setType(Calendar::VIEW_COMMENT_OVERVIEW); $page = $this->getPage(); if (!$request->exists('cal_id')) { throw new Exception('Nieuwsbericht ontbreekt.'); } if (!$request->exists('tree_id')) { throw new Exception('Node ontbreekt.'); } if (!$request->exists('tag')) { throw new Exception('Tag ontbreekt.'); } $cal_id = intval($request->getValue('cal_id')); $tree_id = intval($request->getValue('tree_id')); $tag = $request->getValue('tag'); $key = array('cal_id' => $cal_id); $this->pagerUrl->addParameters($key); $this->pagerUrl->setParameter($view->getUrlId(), $view->getType()); // handle searchcriteria $search = new SearchManager(); $search->setUrl($this->pagerUrl); $search->setExclude($this->pagerKey); $search->setParameter('search'); $search->saveList(); $searchcriteria = $search->getSearchParameterList(); $searchcriteria = array_merge($searchcriteria, $key); // add breadcrumb item $this->director->theme->handleAdminLinks($template); $url = new Url(true); $url->clearParameter('id'); $url->setParameter('cal_id', $cal_id); $url->setParameter('tree_id', $tree_id); $url->setParameter('tag', $tag); // create urls $url_edit = clone $url; $url_edit->setParameter($view->getUrlId(), Calendar::VIEW_COMMENT_EDIT); $url_del = clone $url; $url_del->setParameter($view->getUrlId(), Calendar::VIEW_COMMENT_DELETE); $list = $this->getList($searchcriteria, $pagesize, $page); foreach ($list['data'] as &$item) { $url_edit->setParameter('id', $item['id']); $url_del->setParameter('id', $item['id']); $item['href_edit'] = $url_edit->getUrl(true); $item['href_del'] = $url_del->getUrl(true); } $template->setVariable('list', $list, false); $this->template[$this->director->theme->getConfig()->main_tag] = $template; }
* must display the words "Powered by eyeos" and retain the original copyright notice. */ define('FRAMEWORK_SEARCH_TOKENS_DIR', 'Tokens'); define('FRAMEWORK_SEARCH_TOKENS_PATH', FRAMEWORK_SEARCH_PATH . '/' . FRAMEWORK_SEARCH_TOKENS_DIR); define('FRAMEWORK_SEARCH_PLUGINS_DIR', 'SearchPlugins'); define('FRAMEWORK_SEARCH_PLUGINS_PATH', FRAMEWORK_SEARCH_PATH . '/' . FRAMEWORK_SEARCH_PLUGINS_DIR); define('FRAMEWORK_SEARCH_UTILS_DIR', 'utils'); define('FRAMEWORK_SEARCH_UTILS_PATH', FRAMEWORK_SEARCH_PATH . '/' . FRAMEWORK_SEARCH_UTILS_DIR); require_once FRAMEWORK_SEARCH_PATH . '/interfaces.php'; require_once FRAMEWORK_SEARCH_PATH . '/SearchController.php'; require_once FRAMEWORK_SEARCH_PATH . '/SearchQuery.php'; require_once FRAMEWORK_SEARCH_PATH . '/ParserManager.php'; require_once FRAMEWORK_SEARCH_PATH . '/SearchManager.php'; // FIXME: to be putted inside Searchmanager class!! $tokens = new DirectoryIterator(FRAMEWORK_SEARCH_TOKENS_PATH); foreach ($tokens as $fileInfo) { $fileInfoName = $fileInfo->getFileName(); if (!$fileInfo->isDot() && strpos($fileInfoName, '.php')) { require_once FRAMEWORK_SEARCH_TOKENS_PATH . '/' . $fileInfoName; } } // FIXME: to be deleted ?!?! $abstractPlugins = new DirectoryIterator(FRAMEWORK_SEARCH_PLUGINS_PATH); foreach ($abstractPlugins as $plugin) { $fileName = $plugin->getFilename(); if ($plugin->isFile() && $fileName[0] != '.') { require FRAMEWORK_SEARCH_PLUGINS_PATH . '/' . $plugin->getFilename(); } } SearchManager::init();