Beispiel #1
0
 public function getusercontentsAction()
 {
     $output = "";
     // Get requests
     $params = $this->getRequest()->getParams();
     $userId = isset($params['search']) ? $params['search'] : null;
     $start = isset($params['start']) ? $params['start'] : null;
     $cache = Zend_Registry::get('cache');
     if (is_numeric($userId) && is_numeric($start)) {
         // Load user locations from cache
         if ($resultList = $cache->load('UserContentsList_' . $userId)) {
             $newContents = array();
             $userModel = new Default_Model_User();
             for ($i = $start; $i < $start + 3; $i++) {
                 if (isset($resultList[$i])) {
                     $newContents[] = $resultList[$i];
                 }
             }
             if (!sizeof($newContents) == 0) {
                 $contentList = $userModel->getUserContentList($newContents, 3);
             } else {
                 $contentList = array();
             }
         }
         $output = json_encode($contentList);
     } elseif (is_numeric($userId) && !$start) {
         // Load user locations from cache
         if ($resultList = $cache->load('UserContentsList_' . $userId)) {
             $userModel = new Default_Model_User();
             $contentList = $userModel->getWholeUserContentList($userId, $resultList);
         }
         $output = json_encode($contentList);
     }
     $this->view->output = $output;
 }