/** * Search for words. * * Returns a list of items that have the word, sorted by module with: * <pre> * - id => id of the item found. * - moduleId => id of the module. * - moduleName => Name of the module. * - moduleLabel => Display for the module. * - firstDisplay => Firts display for the item (Ej. title). * - secondDisplay => Second display for the item (Ej. notes). * - projectId => Parent project id of the item. * </pre> * * REQUIRES request parameters: * <pre> * - string <b>words</b> An string of words (Will be separated by the spaces). * </pre> * * OPTIONAL request parameters: * <pre> * - integer <b>count</b> Number of results. * </pre> * * The return is in JSON format. * * @return void */ public function jsonSearchAction() { $words = (string) $this->getRequest()->getParam('words'); $count = (int) $this->getRequest()->getParam('count', null); $offset = (int) $this->getRequest()->getParam('start', null); $search = new Phprojekt_Search(); $tags = new Phprojekt_Tags(); $searchresults = $search->search($words, $count); $tagresults = $tags->search($words, $count); $results = array('search' => $searchresults, 'tags' => $tagresults); Phprojekt_Converter_Json::echoConvert($results); }
/** * Test of jsonDeleteTagsAction */ public function testJsonDeleteTagsAction() { $tag = new Phprojekt_Tags(); $tags = $tag->search("this"); $this->assertEquals(array(array('id' => 2, 'moduleId' => 1, 'moduleName' => 'Project', 'moduleLabel' => 'Project', 'firstDisplay' => '', 'secondDisplay' => '', 'projectId' => 1)), $tags); $this->setRequestUrl('Default/Tag/jsonDeleteTags/'); $this->request->setParam('moduleName', 'Project'); $this->request->setParam('id', 2); $response = $this->getResponse(); $this->assertEquals('{}&&({"type":"success","message":"The Tags were deleted correctly","id":0})', $response); $tags = $tag->search("this"); $this->assertTrue(empty($tags)); }
public function testSaveMultipleTags() { $tag = new Phprojekt_Tags(); $tag->saveTags(1, 1, "love phprojekt"); $tag->saveTags(1, 2, "admire phprojekt"); $tags = $tag->search("love"); $this->assertEquals(array(array('id' => 1, 'moduleId' => 1, 'moduleName' => 'Project', 'moduleLabel' => 'Project', 'firstDisplay' => 'Hallo Welt', 'secondDisplay' => null, 'projectId' => 1)), $tags); $tags = $tag->search("phprojekt"); $this->assertEquals(array(array('id' => 1, 'moduleId' => 1, 'moduleName' => 'Project', 'moduleLabel' => 'Project', 'firstDisplay' => 'Hallo Welt', 'secondDisplay' => null, 'projectId' => 1), array('id' => 2, 'moduleId' => 1, 'moduleName' => 'Project', 'moduleLabel' => 'Project', 'firstDisplay' => '', 'secondDisplay' => '', 'projectId' => 1)), $tags); $tags = $tag->search("admire phprojekt"); $this->assertEquals(array(array('id' => 2, 'moduleId' => 1, 'moduleName' => 'Project', 'moduleLabel' => 'Project', 'firstDisplay' => '', 'secondDisplay' => '', 'projectId' => 1)), $tags); }