コード例 #1
0
ファイル: Campaign.php プロジェクト: si2info/cinda-server
 /**
  * Constructor
  * @param integer $id
  */
 function __construct($id)
 {
     global $wpdb;
     $this->ID = intval($id);
     $row = $wpdb->get_row("SELECT post_title, post_content, post_modified FROM " . $wpdb->prefix . "posts WHERE ID = " . $this->ID . " AND post_type = '" . CINDA_PREFIX . "campaign'");
     if ($row) {
         // Title
         $this->title = $row->post_title;
         $this->last_modified = $row->post_modified;
         // The image
         $this->image = wp_get_attachment_url(get_post_meta($this->ID, CINDA_PREFIX . 'logo_image', true));
         if (!$this->image) {
             $this->image = '';
         }
         // default: CINDA_URL."/assets/images/no_photo.png";
         $this->cover = wp_get_attachment_url(get_post_meta($this->ID, CINDA_PREFIX . 'cover_image', true));
         if (!$this->cover) {
             $this->cover = '';
         }
         // Description
         $description = get_post_field('post_excerpt', $this->ID);
         if ($description instanceof WP_Error || empty($description) || $description == "") {
             $this->description = wp_trim_words(strip_tags($row->post_content, "<b><strong><a><i><em><p><br><ul><ol><li>"), 55, '...');
         } else {
             $this->description = $description;
         }
         $this->description_extended = apply_filters('the_content', $row->post_content);
         $this->description_extended = str_replace(']]>', ']]&gt;', $this->description_extended);
         $this->description_extended = strip_tags($this->description_extended, "<b><strong><a><i><em><p><br><ul><ol><li>");
         $meta = get_post_meta($this->ID);
         if (isset($meta[CINDA_PREFIX . 'start_date'])) {
             $this->date_start = $meta[CINDA_PREFIX . 'start_date'][0];
         }
         if (isset($meta[CINDA_PREFIX . 'end_date'])) {
             $this->date_end = $meta[CINDA_PREFIX . 'end_date'][0];
         }
         if (isset($meta[CINDA_PREFIX . 'color'])) {
             $this->color = $meta[CINDA_PREFIX . 'color'][0];
         } else {
             $this->color = CINDA_DEFAULT_COLOR;
         }
         if (isset($meta[CINDA_PREFIX . 'scope'])) {
             $this->scope = $meta[CINDA_PREFIX . 'scope'][0];
         }
         if (isset($meta[CINDA_PREFIX . 'geoposition'])) {
             $this->geoposition = $meta[CINDA_PREFIX . 'geoposition'][0];
         }
         if (isset($meta[CINDA_PREFIX . 'radium'])) {
             $this->radium = intval($meta[CINDA_PREFIX . 'radium'][0]);
         }
         if (isset($meta[CINDA_PREFIX . 'tracking'])) {
             $this->tracking = $meta[CINDA_PREFIX . 'tracking'][0];
         }
         if ($this->tracking == "" || $this->tracking == "false") {
             $this->tracking = false;
         } else {
             $this->tracking = true;
         }
         $this->volunteers_number = VolunteerList::get_volunteerNumber($this->ID);
         $this->volunteers_top = VolunteerList::get_volunteerList(array('campaign' => $this->ID, 'number' => $this->get_numberTopVolunteers()));
         $this->suscriptions = intval($wpdb->get_var("SELECT COUNT( DISTINCT id_volunteer ) FROM " . CINDA_TABLE_SUSCRIPTIONS_NAME . " WHERE id_campaign = " . $this->ID));
     }
 }
コード例 #2
0
 /**
  * Print (JSON) Volunteers List
  */
 static function volunteers_list()
 {
     global $wp;
     $args = array();
     if (isset($wp->query_vars['cid']) && !empty($wp->query_vars['cid'])) {
         $args['campaign'] = $wp->query_vars['cid'];
     }
     echo json_encode(VolunteerList::get_volunteerList($args));
     die;
 }