Пример #1
0
 /**
  *	viewAction
  *
  *	Tag index
  *
  */
 public function viewAction()
 {
     $this->view->title = 'tag-view-title';
     //$params = $this->getRequest()->getParams();
     $tagId = $this->getRequest()->getParam('id');
     //$data = array();
     $result = array();
     $tag = new Default_Model_Tags();
     $contentList = $tag->getTagContentById($tagId);
     $tagName = $tag->getTagNameById($tagId);
     /* What is this
        $contentTypesModel = new Default_Model_ContentTypes();
        $contentTypes = $contentTypesModel->getAllNamesAndIds();
        
        // match content type with data
        $i = 0;
        foreach ($data as $dat) {   // for each content that has tag
            if ($dat['published_cnt'] == 1) {
                $result[$i] = $dat;
                
                $break = false;
                
                $j = 0;                 // go through content types until hit
                while (!$break) {
                    if (isset($result[$i]) && isset($contentTypes[$j])){
                        if ($dat['id_cty_cnt'] == $contentTypes[$j]['id_cty']) {
                            $result[$i]['type'] = $contentTypes[$j]['key_cty'];
                            $break = true;  // break if hit
                        }
                    }
                    
                    $j++;
                    
                    if ($j > 100) {     // break if appears to be infinite...
                        $break = true;
                    }
                }
                
                $i++;
            }
        }
        */
     $this->view->content = $contentList;
     $this->view->tagName = $tagName;
 }
Пример #2
0
 /**
  * checkExistingTags
  *
  *
  */
 public function checkExistingTags($contentId = -1, $tagArray = array())
 {
     $result = null;
     if ($contentId != -1 && !empty($tagArray)) {
         // Go through all existing keywords
         $existingTags = $this->getContentTags($contentId);
         foreach ($existingTags as $id => $tag) {
             // If some of the existing keywords aren't found in sent keywords,
             // that keyword is deleted the from content and maybe even from the
             // database
             if (!in_array($tag['name_tag'], $tagArray)) {
                 // Removing tag from content
                 $this->deleteTagFromContent($tag['id_tag'], $contentId);
                 // If other content(s) doesn't have this tag, the whole
                 // tag is going to be removed from the database
                 if (!$this->checkIfOtherContentHasTag($tag['id_tag'], $contentId)) {
                     $modelTags = new Default_Model_Tags();
                     $modelTags->removeTag($tag['id_tag']);
                 }
                 // Remove tag from existingTags array
                 unset($existingTags[$id]);
             }
         }
         $result = $existingTags;
     }
     return $result;
 }
Пример #3
0
 /**
  *   listAction
  *
  *   Lists content by content type.
  *
  */
 public function listAction()
 {
     $url = $this->_urlHelper->url(array('controller' => 'index', 'language' => $this->view->language), 'lang_default', true);
     // Get cache from registry
     $cache = Zend_Registry::get('cache');
     // Set array for content data
     $data = array();
     // Get requests
     $params = $this->getRequest()->getParams();
     // Get content type
     $cty = isset($params['type']) ? $params['type'] : 'all';
     if ($cty != "idea" && $cty != "finfo" && $cty != "problem") {
         $this->_redirect($url);
     }
     // Get page nummber and items per page
     $page = isset($params['page']) ? $params['page'] : 1;
     $count = isset($params['count']) ? $params['count'] : 15;
     // Get list oreder value
     $order = isset($params['order']) ? $params['order'] : 'created';
     $ind = isset($params['ind']) ? $params['ind'] : 0;
     // Get current language id
     // $languages = new Default_Model_Languages();
     // $idLngInd = $languages->getLangIdByLangName($this->view->language);
     // Get recent content by type
     $contentModel = new Default_Model_Content();
     $data = $contentModel->listRecent($cty, $page, $count, $order, $this->view->language, $ind);
     $results = array();
     // gather other content data and insert to results array
     if (isset($data[0])) {
         $contentHasTagModel = new Default_Model_ContentHasTag();
         // $contentRatingsModel = new Default_Model_ContentRatings();
         $i = 0;
         foreach ($data as $content) {
             $results[$i] = $content;
             $results[$i]['tags'] = $contentHasTagModel->getContentTags($content['id_cnt']);
             //$results[$i]['ratingdata'] = $contentRatingsModel
             //                        ->getPercentagesById($content['id_cnt']);
             $i++;
         }
     }
     // Get total content count
     $contentCount = $contentModel->getContentCountByContentType($cty, $this->view->language);
     // Calculate total page count
     $pageCount = ceil($contentCount / $count);
     // Most viewed content
     $mostViewedData = $contentModel->getMostViewedType($cty, $page, $count, 'views', 'en', $ind);
     // Get all industries
     //$industries = new Default_Model_Industries();
     //$this->view->industries = $industries->getNamesAndIdsById($ind, $idLngInd);
     // Get industry data by id
     //$this->view->industryParent = $industries->getById($ind);
     // Load most popular tags from cache
     if (!($result = $cache->load('IndexTags'))) {
         $tagsModel = new Default_Model_Tags();
         $tags = $tagsModel->getPopular(20);
         /*
         // resize tags
         foreach ($tags as $k => $tag) {
         $size = round(50 + ($tag['count'] * 30));
         if ($size > 300) {
         $size = 300;
         }
         $tags[$k]['tag_size'] = $size;
         }
         */
         // Action helper for tags
         $tags = $this->_helper->tagsizes->popularTagCalc($tags);
         //Action helper for define is tag running number divisible by two
         $tags = $this->_helper->tagsizes->isTagDivisibleByTwo($tags);
         // Save most popular tags data to cache
         $cache->save($tags, 'IndexTags');
     } else {
         $tags = $result;
     }
     // Custom pagination to fix memory error on large amount of data
     /*
     $paginator = new Zend_View();
     $paginator->setScriptPath('../application/views/scripts');
     $paginator->pageCount = $pageCount;
     $paginator->currentPage = $page;
     $paginator->pagesInRange = 10;
     */
     // Send to view
     $this->view->tags = $tags;
     //$this->view->contentPaginator = $paginator;
     $this->view->contentData = $results;
     $this->view->type = $cty;
     $this->view->count = $count;
     $this->view->page = $page;
     $this->view->contentCount = $contentCount;
     $this->view->ind = $ind;
     $this->view->mostViewedData = $mostViewedData;
     // RSS type for the layout
     $this->view->rsstype = $cty;
 }
Пример #4
0
 /**
  *   removeContent
  *   Removes specified content from the database and all related stuff
  *
  *   @param int id_cnt The id of content to be removed
  *   @return boolean array $contentRemoveChecker
  *   @author Mikko Korpinen
  */
 public function removeContentAndDepending($id_cnt = 0)
 {
     $contentRemoveChecker = array('removeContentFromCampaign' => true, 'removeContentFromContent' => true, 'removeContentFromFutureinfoClasses' => true, 'removeContentFromIndustries' => true, 'removeContentFromInnovationTypes' => true, 'removeContentFromRelatedCompanies' => true, 'removeContentRelatedCompanies' => true, 'removeContentFromTags' => true, 'removeContentTags' => true, 'removeContentFromUser' => true, 'removeContentViews' => true, 'removeContentFlags' => true, 'removeContentCommentFlags' => true, 'removeContentRatings' => true, 'removeContentFiles' => true, 'removeUserFromFavorites' => true, 'removeContent' => true, 'removeContentComments' => true);
     // cnt_has_cmp
     $cmpHasCnt = new Default_Model_CampaignHasContent();
     if (!$cmpHasCnt->removeContentCampaignLinks($id_cnt)) {
         $contentRemoveChecker['removeContentFromCampaign'] = false;
     }
     // cnt_has_cnt
     $cntHasCnt = new Default_Model_ContentHasContent();
     if (!$cntHasCnt->removeContentFromContents($id_cnt)) {
         $contentRemoveChecker['removeContentFromContent'] = false;
     }
     // cnt_has_fic
     /* not used
                 $cntHasFic = new Default_Model_ContentHasFutureinfoClasses();
                 if (!$cntHasFic->removeFutureinfoClassesFromContent($id_cnt))
                     $contentRemoveChecker['removeContentFromFutureinfoClasses'] = false;
     			*/
     // cnt_has_grp
     // Not used?
     // cnt_has_ind
     /* not used
        $cntHasInd = new Default_Model_ContentHasIndustries();
        if (!$cntHasInd->removeIndustriesFromContent($id_cnt))
            $contentRemoveChecker['removeContentFromIndustries'] = false;
        */
     // cnt_has_ivt
     /* not used
        $cntHasIvt = new Default_Model_ContentHasInnovationTypes();
        if (!$cntHasIvt->removeInnovationTypesFromContent($id_cnt))
            $contentRemoveChecker['removeContentFromInnovationTypes'] = false;
        */
     // related_companies_rec and cnt_has_rec
     $cntHasRec = new Default_Model_ContentHasRelatedCompany();
     $recs = $cntHasRec->getContentRelComps($id_cnt);
     $rec = new Default_Model_RelatedCompanies();
     foreach ($recs as $id_rec) {
         if (!$cntHasRec->checkIfOtherContentHasRelComp($id_rec['id_rec'], $id_cnt)) {
             if (!$rec->removeRelComp($id_rec['id_rec'])) {
                 $contentRemoveChecker['removeRelatedCompanies'] = false;
             }
         }
     }
     if (!$cntHasRec->removeContentRelComps($id_cnt)) {
         $contentRemoveChecker['removeContentFromRelatedCompanies'] = false;
     }
     // tags_tag and cnt_has_tag
     $cntHasTag = new Default_Model_ContentHasTag();
     $tags = $cntHasTag->getContentTags($id_cnt);
     $tag = new Default_Model_Tags();
     foreach ($tags as $id_tag) {
         if (!$cntHasTag->checkIfOtherContentHasTag($id_tag['id_tag'], $id_cnt)) {
             if (!$tag->removeTag($id_tag['id_tag'])) {
                 $contentRemoveChecker['removeTags'] = false;
             }
         }
     }
     if (!$cntHasTag->removeContentTags($id_cnt)) {
         $contentRemoveChecker['removeContentFromTags'] = false;
     }
     // cnt_has_usr
     $cntHasUsr = new Default_Model_ContentHasUser();
     if (!$cntHasUsr->removeUserFromContent($id_cnt)) {
         $contentRemoveChecker['removeContentFromUser'] = false;
     }
     // cnt_publish_times_pbt
     // Not used?
     // cnt_views_vws
     $cntWiewsVws = new Default_Model_ContentViews();
     if (!$cntWiewsVws->removeContentViews($id_cnt)) {
         $contentRemoveChecker['removeContentViews'] = false;
     }
     // Flags from content_flags_cfl
     $contentflagmodel = new Default_Model_ContentFlags();
     $cnfl_ids = $contentflagmodel->getFlagsByContentId($id_cnt);
     if (is_array($cnfl_ids)) {
         foreach ($cnfl_ids as $cfl_id) {
             if (!$contentflagmodel->removeFlag($cfl_id)) {
                 $contentRemoveChecker['removeContentFlags'] = false;
             }
         }
     }
     // Flags from comment_flags_cfl
     $commentflagmodel = new Default_Model_CommentFlags();
     $cmfl_ids = $commentflagmodel->getFlagsByContentId($id_cnt);
     if (is_array($cmfl_ids)) {
         foreach ($cmfl_ids as $cfl_id) {
             if (!$commentflagmodel->removeFlag($cfl_id)) {
                 $contentRemoveChecker['removeContentCommentFlags'] = false;
             }
         }
     }
     // content_ratings_crt
     $contentRatingRct = new Default_Model_ContentRatings();
     if (!$contentRatingRct->removeContentRatings($id_cnt)) {
         $contentRemoveChecker['removeContentRatings'] = false;
     }
     // files_fil
     $files = new Default_Model_Files();
     if (!$files->removeFiles($id_cnt, "content")) {
         $contentRemoveChecker['removeContentFiles'] = false;
     }
     // links_lnk
     // Not used?
     // usr_has_fvr
     $usrHasFvr = new Default_Model_UserHasFavourites();
     if (!$usrHasFvr->removeAllContentFromFavouritesByContentId($id_cnt)) {
         $contentRemoveChecker['removeUserFromFavorites'] = false;
     }
     // contents_cnt
     $contentmodel = new Default_Model_Content();
     if (!$contentmodel->removeContent($id_cnt)) {
         $contentRemoveChecker['removeContent'] = false;
     }
     // coments_cmt
     $commentmodel = new Default_Model_Comments();
     if (!$commentmodel->removeAllContentComments($id_cnt)) {
         $contentRemoveChecker['removeContentComments'] = false;
     }
     return $contentRemoveChecker;
 }
Пример #5
0
 /**
  *	Show mainpage and list newest and most viewed ideas and problems
  */
 function indexAction()
 {
     // Variable for number recent campaigns to be sent to view
     $recentCampaignsCount = 0;
     $this->view->title = "index-home";
     // Get cache from registry
     $cache = Zend_Registry::get('cache');
     // $contentTypesModel = new Default_Model_ContentTypes();
     // $userModel = new Default_Model_User();
     // Load recent posts from cache
     $cachePosts = 'IndexPosts_' . $this->view->language;
     if (!($result = $cache->load($cachePosts))) {
         $contentModel = new Default_Model_Content();
         $contentHasTagModel = new Default_Model_ContentHasTag();
         // get data
         //($cty = 'all', $page = 1, $count = -1, $order = 'created', $lang = 'en', $ind = 0)
         $recentposts_raw = $contentModel->listRecent('all', 12, -1, 'created', $this->view->language, -1);
         $recentposts = array();
         $i = 0;
         // gather data for recent posts
         foreach ($recentposts_raw as $post) {
             $recentposts[$i] = $post;
             $recentposts[$i]['tags'] = $contentHasTagModel->getContentTags($post['id_cnt']);
             $i++;
         }
         // Save recent posts data to cache
         $cache->save($recentposts, $cachePosts);
     } else {
         $recentposts = $result;
     }
     // Load most popular tags from cache
     if (!($result = $cache->load('IndexTags'))) {
         $tagsModel = new Default_Model_Tags();
         $tags = $tagsModel->getPopular(20);
         /*
         // resize tags
         foreach ($tags as $k => $tag) {
             $size = round(50 + ($tag['count'] * 30));
             if ($size > 300) {
                 $size = 300;
             }
             $tags[$k]['tag_size'] = $size;
         }
         */
         // Action helper for tags
         $tags = $this->_helper->tagsizes->popularTagCalc($tags);
         // Action helper for define is tag running number divisible by two
         $tags = $this->_helper->tagsizes->isTagDivisibleByTwo($tags);
         // Save most popular tags data to cache
         $cache->save($tags, 'IndexTags');
     } else {
         $tags = $result;
     }
     // Laod most active users from cache
     if (!($result = $cache->load('IndexUsers'))) {
         $contentHasUserModel = new Default_Model_ContentHasUser();
         $activeusers = $contentHasUserModel->getMostActive(5);
         // Save most active users data to cache
         $cache->save($activeusers, 'IndexUsers');
     } else {
         $activeusers = $result;
     }
     // inject data to view
     if (isset($recentposts)) {
         $this->view->recentposts = $recentposts;
     } else {
         $this->view->recentposts = '';
     }
     // Get recent campaigns
     $grpmodel = new Default_Model_Groups();
     $campaignModel = new Default_Model_Campaigns();
     $recentcampaigns = $campaignModel->getRecent(5);
     // If you find (time to think of) a better way to do this, be my guest.
     $cmps_new = array();
     foreach ($recentcampaigns as $cmp) {
         $grp = $grpmodel->getGroupData($cmp['id_grp_cmp']);
         $cmp['group_name_grp'] = $grp['group_name_grp'];
         $cmps_new[] = $cmp;
     }
     // Get recent groups
     $grps = $grpmodel->getRecent(5);
     $grps_new = array();
     $grpadm = new Default_Model_GroupAdmins();
     foreach ($grps as $grp) {
         $adm = $grpadm->getGroupAdmins($grp['id_grp']);
         $grp['id_admin'] = $adm[0]['id_usr'];
         $grp['login_name_admin'] = $adm[0]['login_name_usr'];
         $grps_new[] = $grp;
     }
     $this->view->campaigns = $cmps_new;
     $this->view->groups = $grps_new;
     $this->view->poptags = $tags;
     $this->view->activeusers = $activeusers;
     $this->view->isLoggedIn = Zend_Auth::getInstance()->hasIdentity();
     $this->view->recentCampaignsCount = $recentCampaignsCount;
 }
Пример #6
0
 /**
  *	Show mainpage and list newest and most viewed ideas and problems
  */
 function indexAction()
 {
     $this->view->title = "index-home";
     // Get cache from registry
     $cache = Zend_Registry::get('cache');
     // $contentTypesModel = new Default_Model_ContentTypes();
     // $userModel = new Default_Model_User();
     /*
     // Load recent posts from cache
     $cachePosts = 'IndexPosts_' . $this->view->language;
     
     if(!$result = $cache->load($cachePosts)) {
         $contentModel = new Default_Model_Content();
         $contentHasTagModel = new Default_Model_ContentHasTag();
         
         // get data
         //($cty = 'all', $page = 1, $count = -1, $order = 'created', $lang = 'en', $ind = 0)
         $recentposts_raw = $contentModel->listRecent(
             'all', 12, -1, 'created', $this->view->language, -1
         );
         
         $recentposts = array();
         
         $i = 0;
         // gather data for recent posts
         foreach ($recentposts_raw as $post) {
             $recentposts[$i] = $post;
             $recentposts[$i]['tags'] = $contentHasTagModel->getContentTags(
                 $post['id_cnt']
             );
             
             $i++;
         }
         
         // Save recent posts data to cache
         $cache->save($recentposts, $cachePosts);          
     } else {
         $recentposts = $result;
     }
     */
     // Load most popular tags from cache
     if (!($result = $cache->load('IndexTags'))) {
         $tagsModel = new Default_Model_Tags();
         $tags = $tagsModel->getPopular(20);
         /*
         // resize tags
         foreach ($tags as $k => $tag) {
             $size = round(50 + ($tag['count'] * 30));
             if ($size > 300) {
                 $size = 300;
             }
             $tags[$k]['tag_size'] = $size;
         }
         */
         // Action helper for tags
         $tags = $this->_helper->tagsizes->tagCalc($tags);
         // Save most popular tags data to cache
         $cache->save($tags, 'IndexTags');
     } else {
         $tags = $result;
     }
     // Laod most active users from cache
     if (!($result = $cache->load('IndexUsers'))) {
         $contentHasUserModel = new Default_Model_ContentHasUser();
         $activeusers = $contentHasUserModel->getMostActive(10);
         // Save most active users data to cache
         $cache->save($activeusers, 'IndexUsers');
     } else {
         $activeusers = $result;
     }
     // inject data to view
     if (isset($recentposts)) {
         $this->view->recentposts = $recentposts;
     } else {
         $this->view->recentposts = '';
     }
     $this->view->poptags = $tags;
     $this->view->activeusers = $activeusers;
     $this->view->isLoggedIn = Zend_Auth::getInstance()->hasIdentity();
 }