Changeset 556104
- Timestamp:
- 06/11/2012 01:01:36 PM (14 years ago)
- Location:
- click-to-donate/trunk
- Files:
-
- 3 edited
-
click-to-donate.php (modified) (1 diff)
-
php/ClickToDonateModel.php (modified) (2 diffs)
-
php/ClickToDonateView.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
click-to-donate/trunk/click-to-donate.php
r556095 r556104 3 3 Plugin Name: Click to donate 4 4 Description: Provides a system for managing "click to donate" campaigns based on user visits and clicks 5 Version: 1.0. 15 Version: 1.0.2 6 6 Plugin URI: http://code.google.com/p/click-to-donate-for-wordpress/ 7 7 Author: Cláudio Esperança, Diogo Serra -
click-to-donate/trunk/php/ClickToDonateModel.php
r556070 r556104 354 354 355 355 // If we have more than one banner, rearrange the data to a more suitable form 356 if( !empty($visitsData->postIds)):356 if(count($visitsData->postIds)>1): 357 357 $tRows = array(); 358 358 $bannerColumns = array(); … … 363 363 364 364 foreach ($rows as $row): 365 if(!is _array($tRows[$row[$dateField]])):365 if(!isset($tRows[$row[$dateField]]) || !is_array($tRows[$row[$dateField]])): 366 366 $tRows[$row[$dateField]]=array($dateField=>$row[$dateField])+$bannerColumns; 367 367 endif; -
click-to-donate/trunk/php/ClickToDonateView.php
r556070 r556104 756 756 return $posts; 757 757 758 foreach ($posts as $index => $post): 759 // If is a countable post type, is a single post and we are getting the post from the front office, verify and count the visit 760 if(get_post_type($post) == ClickToDonateController::POST_TYPE && is_single($post) && !is_admin()): 761 $status = ClickToDonateController::bannerCanBeShown($post, true); 762 switch($status): 763 // The campaign was finished 764 case ClickToDonateController::MSG_URL_ERROR: 765 $posts[$index]->post_content="<span class=\"ctd-visit-error\">".__('Sorry, but the URL for this campaign is invalid.', 'ClickToDonate')."</span>"; 766 break; 767 // The campaign was finished 768 case ClickToDonateController::MSG_AUTHENTICATION_ERROR: 769 $posts[$index]->post_content="<span class=\"ctd-visit-error\">".sprintf(__('You must %s in the site to validate your visit.', 'ClickToDonate'), '<a href="'.wp_login_url(home_url()).'" title="'.__('Follow the link to login in the site', 'ClickToDonate').'">'.__('login', 'ClickToDonate').'</a>')."</span>"; 770 break; 771 // The campaign was finished 772 case ClickToDonateController::MSG_CAMPAIGN_FINISHED: 773 $posts[$index]->post_content="<span class=\"ctd-visit-error\">".__('Thanks for visiting, but this campaign has been completed.', 'ClickToDonate')."</span>"; 774 break; 775 // The campaign is scheduled to start 776 case ClickToDonateController::MSG_CAMPAIGN_SCHEDULED: 777 $posts[$index]->post_content="<span class=\"ctd-visit-error\">".__('Thanks for visiting, but this campaign has not started.', 'ClickToDonate')."</span>"; 778 break; 779 case ClickToDonateController::MSG_CAMPAIGN_UNAVAILABLE: 780 $posts[$index]->post_content="<span class=\"ctd-visit-error\">".__('Thanks for visiting, but this campaign is not available.', 'ClickToDonate')."</span>"; 781 break; 782 case ClickToDonateController::MSG_RESTRITED_BY_COOKIE: 783 case ClickToDonateController::MSG_RESTRITED_BY_LOGIN: 784 $posts[$index]->post_content="<span class=\"ctd-visit-error\">".sprintf(__('Thanks for visiting, but this campaign has already been visited by you recently. Please try again in %s.', 'ClickToDonate'), self::stringfyTime(ClickToDonateController::getCoolOffLimitRemainingForAuthenticatedUser($post)))."</span>"; 785 break; 786 // Everything ok, let's try to register the visit 787 case ClickToDonateController::MSG_OK: 788 if (ClickToDonateController::registerVisit($post)): 789 $posts[$index]->post_content.="<span class=\"ctd-visit-registered\"><hr/>".__('<br/>Visit registered.', 'ClickToDonate')."</span>"; 758 if($query->is_single()): 759 foreach ($posts as $index => $post): 760 // If is a countable post type, is a single post and we are getting the post from the front office, verify and count the visit 761 if(get_post_type($post) == ClickToDonateController::POST_TYPE && !is_admin()): 762 $status = ClickToDonateController::bannerCanBeShown($post, true); 763 switch($status): 764 // The campaign was finished 765 case ClickToDonateController::MSG_URL_ERROR: 766 $posts[$index]->post_content="<span class=\"ctd-visit-error\">".__('Sorry, but the URL for this campaign is invalid.', 'ClickToDonate')."</span>"; 790 767 break; 791 endif; 792 // Houston, we have problems 793 case ClickToDonateController::MSG_UNKNOWN_ERROR: 794 case ClickToDonateController::MSG_UNKNOWN_POST_STATUS: 795 case ClickToDonateController::MSG_UNKNOWN_POST_TYPE: 796 default: 797 $posts[$index]->post_content="<span class=\"ctd-visit-error\">".__('Unable to register the visit. Please try again later.', 'ClickToDonate')."</span>"; 798 break; 799 endswitch; 800 endif; 801 endforeach; 802 768 // The campaign was finished 769 case ClickToDonateController::MSG_AUTHENTICATION_ERROR: 770 $posts[$index]->post_content="<span class=\"ctd-visit-error\">".sprintf(__('You must %s in the site to validate your visit.', 'ClickToDonate'), '<a href="'.wp_login_url(home_url()).'" title="'.__('Follow the link to login in the site', 'ClickToDonate').'">'.__('login', 'ClickToDonate').'</a>')."</span>"; 771 break; 772 // The campaign was finished 773 case ClickToDonateController::MSG_CAMPAIGN_FINISHED: 774 $posts[$index]->post_content="<span class=\"ctd-visit-error\">".__('Thanks for visiting, but this campaign has been completed.', 'ClickToDonate')."</span>"; 775 break; 776 // The campaign is scheduled to start 777 case ClickToDonateController::MSG_CAMPAIGN_SCHEDULED: 778 $posts[$index]->post_content="<span class=\"ctd-visit-error\">".__('Thanks for visiting, but this campaign has not started.', 'ClickToDonate')."</span>"; 779 break; 780 case ClickToDonateController::MSG_CAMPAIGN_UNAVAILABLE: 781 $posts[$index]->post_content="<span class=\"ctd-visit-error\">".__('Thanks for visiting, but this campaign is not available.', 'ClickToDonate')."</span>"; 782 break; 783 case ClickToDonateController::MSG_RESTRITED_BY_COOKIE: 784 case ClickToDonateController::MSG_RESTRITED_BY_LOGIN: 785 $posts[$index]->post_content="<span class=\"ctd-visit-error\">".sprintf(__('Thanks for visiting, but this campaign has already been visited by you recently. Please try again in %s.', 'ClickToDonate'), self::stringfyTime(ClickToDonateController::getCoolOffLimitRemainingForAuthenticatedUser($post)))."</span>"; 786 break; 787 // Everything ok, let's try to register the visit 788 case ClickToDonateController::MSG_OK: 789 if (ClickToDonateController::registerVisit($post)): 790 $posts[$index]->post_content.="<span class=\"ctd-visit-registered\"><hr/>".__('<br/>Visit registered.', 'ClickToDonate')."</span>"; 791 break; 792 endif; 793 // Houston, we have problems 794 case ClickToDonateController::MSG_UNKNOWN_ERROR: 795 case ClickToDonateController::MSG_UNKNOWN_POST_STATUS: 796 case ClickToDonateController::MSG_UNKNOWN_POST_TYPE: 797 default: 798 $posts[$index]->post_content="<span class=\"ctd-visit-error\">".__('Unable to register the visit. Please try again later.', 'ClickToDonate')."</span>"; 799 break; 800 endswitch; 801 endif; 802 endforeach; 803 endif; 804 803 805 return $posts; 804 806 }
Note: See TracChangeset
for help on using the changeset viewer.