/** * Get user-created categories for specified user. * @param string $username * @return array array of Category objects */ public function getUserCreatedCategories($username) { if (!$username) { throw new \Exception("Must supply a username argument"); } $arrCategories = array(); $strSQL = "SELECT * from xerxes_user_categories WHERE username = :username ORDER BY UPPER(name) ASC"; $arrResults = $this->select($strSQL, array(":username" => $username)); foreach ($arrResults as $arrResult) { $objCategory = new Category(); $objCategory->load($arrResult); array_push($arrCategories, $objCategory); } return $arrCategories; }
/** * Update a category * * @param Category $category */ public function updateCategory(Category $category) { $category->setOwner($this->owner); $this->update($category); }
/** * Map category to Summon subjects */ public function swapAction() { $normalized = $this->request->getParam('subject'); // pass along all params $params = $this->request->getParams(); $params['controller'] = 'summon'; $params['action'] = 'search'; // subject mapping $subjects = array(); $category = new Category(); // get the data if (($handle = fopen("data/test.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { // map it $name = $data[0]; $name = $category->setNormalizedFromName($name)->getNormalized(); array_shift($data); $subjects[$name] = $data; } fclose($handle); } if (array_key_exists($normalized, $subjects)) { $clean = $subjects[$normalized]; $params['facet.Discipline'] = array_filter($clean); } // send them to summon return $this->redirectTo($params); }