/** * Returns an array with tags for one item. * * Returns the metadata of the fieds and the data itself with: * <pre> * - string => The tag. * - count => Number of ocurrences. * </pre> * Also the number of rows is returned. * * OPTIONAL request parameters: * <pre> * - integer <b>id</b> id of the item. * - integer <b>limit</b> Number of results. * - integer <b>moduleName</b> Name of the module. * </pre> * * The return is in JSON format. * * @return void */ public function jsonGetTagsByModuleAction() { $tagObj = new Phprojekt_Tags(); $id = (int) $this->getRequest()->getParam('id', 0); $limit = (int) $this->getRequest()->getParam('limit', 0); $module = Cleaner::sanitize('alnum', $this->getRequest()->getParam('moduleName', 'Project')); $moduleId = (int) Phprojekt_Module::getId($module); if (!empty($id)) { $tags = $tagObj->getTagsByModule($moduleId, $id, $limit); } else { $tags = array(); } $fields = $tagObj->getFieldDefinition(); Phprojekt_Converter_Json::echoConvert($tags, $fields); }
public function testGetFieldDefinition() { $tag = new Phprojekt_Tags(); $fdef = $tag->getFieldDefinition(); $this->assertEquals(array(array('key' => 'string', 'label' => 'Tags'), array('key' => 'count', 'label' => 'Count')), $fdef); }