Пример #1
0
 public function update()
 {
     // grab xml
     $items = zest::get_xml_entries($this->url);
     $this->last_updated = date('Y-m-d H:i:s');
     $this->save();
     $count = 0;
     if (!is_array($items)) {
     }
     foreach ($items as $item) {
         $values = array("title" => $item->title, "text" => $item->text, "pubDate" => date('Y-m-d H:i:s', strtotime($item->pubDate)), "permalink" => $item->link, "status_id" => $this->default_status, "external_feed_id" => $this->id);
         $item = ORM::factory('external_feedpost')->like(array("permalink" => $values['permalink'], 'external_feed_id' => $this->id))->find();
         if ($item->id > 0) {
         } else {
             $count++;
             foreach ($values as $key => $val) {
                 $item->{$key} = (string) $val;
             }
             $item->save();
         }
     }
     return "Updated " . $count . " " . $this->title . " posts<br/>";
 }