コード例 #1
0
 public function update($data)
 {
     $PerchEvents_Events = new PerchEvents_Events();
     if (isset($data['eventDescRaw'])) {
         $data['eventDescHTML'] = $PerchEvents_Events->text_to_html($data['eventDescRaw']);
     } else {
         $data['eventDescHTML'] = false;
     }
     if (isset($data['eventTitle'])) {
         $data['eventSlug'] = PerchUtil::urlify(date('Y m d', strtotime($data['eventDateTime'])) . ' ' . $data['eventTitle']);
     }
     if (isset($data['cat_ids'])) {
         $catIDs = $data['cat_ids'];
         unset($data['cat_ids']);
     } else {
         $catIDs = false;
     }
     // Update the event itself
     parent::update($data);
     // Delete existing categories
     $this->db->delete(PERCH_DB_PREFIX . 'events_to_categories', $this->pk, $this->id());
     // Add new categories
     if (is_array($catIDs)) {
         for ($i = 0; $i < sizeOf($catIDs); $i++) {
             $tmp = array();
             $tmp['eventID'] = $this->id();
             $tmp['categoryID'] = $catIDs[$i];
             $this->db->insert(PERCH_DB_PREFIX . 'events_to_categories', $tmp);
         }
     }
     return true;
 }
コード例 #2
0
 public function update($data, $do_cats = true, $do_tags = true)
 {
     $PerchBlog_Posts = new PerchBlog_Posts();
     if (isset($data['cat_ids'])) {
         $catIDs = $data['cat_ids'];
         unset($data['cat_ids']);
     } else {
         $catIDs = false;
     }
     // Update the post itself
     parent::update($data);
     // slug
     if (isset($data['postTitle'])) {
         $API = new PerchAPI(1.0, 'perch_blog');
         $Settings = $API->get('Settings');
         $format = $Settings->get('perch_blog_slug_format')->val();
         if (!$format) {
             $format = '%Y-%m-%d-{postTitle}';
         }
         $this->tmp_slug_vars = $this->details;
         $slug = preg_replace_callback('/{([A-Za-z0-9_\\-]+)}/', array($this, "substitute_slug_vars"), $format);
         $this->tmp_slug_vars = array();
         $data['postSlug'] = strtolower(strftime($slug, strtotime($data['postDateTime'])));
         parent::update($data);
     }
     if ($do_tags) {
         // Delete existing tags
         $this->db->delete(PERCH_DB_PREFIX . 'blog_posts_to_tags', $this->pk, $this->id());
         // Split tag string into array
         if (isset($data['postTags']) && $data['postTags'] != '') {
             $a = explode(',', $data['postTags']);
             if (is_array($a)) {
                 for ($i = 0; $i < sizeOf($a); $i++) {
                     $tmp = array();
                     $tmp['postID'] = $this->id();
                     $tag_str = trim($a[$i]);
                     //does this tag exist
                     $sql = 'SELECT tagID, tagTitle FROM ' . PERCH_DB_PREFIX . 'blog_tags WHERE tagTitle = ' . $this->db->pdb($tag_str) . ' LIMIT 1';
                     $row = $this->db->get_row($sql);
                     if (is_array($row)) {
                         $tmp['tagID'] = $row['tagID'];
                     } else {
                         $tag = array();
                         $tag['tagTitle'] = $tag_str;
                         $tag['tagSlug'] = PerchUtil::urlify($tag_str);
                         $tmp['tagID'] = $this->db->insert(PERCH_DB_PREFIX . 'blog_tags', $tag);
                     }
                     $this->db->insert(PERCH_DB_PREFIX . 'blog_posts_to_tags', $tmp);
                 }
             }
         }
     }
     return true;
 }
コード例 #3
0
 public function update_meta($fire_events = true)
 {
     $data = array();
     if ($this->catParentID() !== '0' && $this->catParentID() !== 'null') {
         $Categories = new PerchCategories_Categories();
         $ParentCat = $Categories->find($this->catParentID());
         $data['catPath'] = $ParentCat->catPath() . $this->catSlug() . '/';
         $data['catTreePosition'] = $ParentCat->catTreePosition() . '-' . str_pad($this->catOrder(), 3, '0', STR_PAD_LEFT);
     } else {
         $Sets = new PerchCategories_Sets();
         $Set = $Sets->find($this->setID());
         $data['catPath'] = $Set->setSlug() . '/' . $this->catSlug() . '/';
         $data['catTreePosition'] = str_pad($this->setID(), 3, '0', STR_PAD_LEFT) . '-' . str_pad($this->catOrder(), 3, '0', STR_PAD_LEFT);
     }
     $data['catDisplayPath'] = $this->get_display_path();
     if (count($data)) {
         parent::update($data);
         if ($fire_events) {
             $Perch = Perch::fetch();
             $Perch->event($this->event_prefix . '.update', $this);
         }
     }
 }
コード例 #4
0
 public function update($data)
 {
     parent::update($data);
     return true;
 }
コード例 #5
0
 public function update($data)
 {
     // Update the data
     parent::update($data);
     return true;
 }
コード例 #6
0
 /**
  * Update object attributes and persist to data store
  *
  * @param array $data
  * @param bool  $geocode
  *
  * @return mixed
  */
 public function update($data, $geocode = false)
 {
     $result = parent::update($data);
     if ($geocode) {
         $result = $this->geocode(true);
     }
     return $result;
 }