public function findallAction() { $html = array("collection" => array()); try { if ($data = $this->getRequest()->getParams()) { // if($device_uid = $this->getRequest()->getParam('device_uid')) { $device_uid = $this->getRequest()->getParam('device_uid'); $topic = new Topic_Model_Topic(); $topic->find(array("value_id" => $data["value_id"])); $subscription = new Topic_Model_Subscription(); $html = array(); if ($topic->getId()) { $html["description"] = $topic->getDescription(); $parent_categories = $topic->getCategories(); foreach ($parent_categories as $category) { $picture = $category->getPicture() ? Application_Model_Application::getImagePath() . $category->getPicture() : ""; $data_category = array("id" => $category->getId(), "name" => $category->getName(), "description" => $category->getDescription(), "picture" => $picture, "is_subscribed" => $device_uid ? $subscription->isSubscribed($category->getId(), $device_uid) : null); $children = $category->getChildren(); $data_children = array(); foreach ($children as $child) { $picture = $child->getPicture() ? Application_Model_Application::getImagePath() . $child->getPicture() : ""; $data_children[] = array("id" => $child->getId(), "name" => $child->getName(), "description" => $child->getDescription(), "picture" => $picture, "is_subscribed" => $device_uid ? $subscription->isSubscribed($child->getId(), $device_uid) : null); } $data_category["children"] = $data_children; $html["collection"][] = $data_category; } } // } } } catch (Exception $e) { $html = array('error' => 1, 'message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1); } $html["page_title"] = $this->getCurrentOptionValue()->getTabbarName(); $this->_sendHtml($html); }
public function editdescriptionAction() { if ($data = $this->getRequest()->getPost()) { try { $topic = new Topic_Model_Topic(); $topic->find(array("value_id" => $this->getCurrentOptionValue()->getValueId())); if (!$topic->getId()) { throw new Exception($this->_('An error occurred while saving. Please try again later.')); } $topic->setData($data)->save(); $html = array('success' => '1', 'success_message' => $this->_('Description successfully saved.'), 'message_timeout' => 2, 'message_button' => 0, 'message_loader' => 0); } catch (Exception $e) { $html = array('error' => 1, 'message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1); } $this->_sendHtml($html); } }