コード例 #1
0
 public function validate($validator, $value)
 {
     if ($value['blog_url'] !== "") {
         $root = opBlogPlugin::getFeedByUrl($value['blog_url']);
         if (!$root) {
             $error = new sfValidatorError($validator, 'URL is invalid.');
             throw new sfValidatorErrorSchema($validator, array('blog_url' => $error));
         }
     }
     return $value;
 }
コード例 #2
0
 protected function updateByMemberIdAndUrl($memberId, $url)
 {
     $feed = opBlogPlugin::getFeedByUrl($url);
     foreach ($feed as $item) {
         $blogRssCache = $this->findOneByMemberIdAndLink($memberId, $item['link']);
         if ($blogRssCache && $blogRssCache->getDate() == $item['date'] || strtotime($item['date']) > time()) {
             continue;
         }
         if (!$blogRssCache) {
             $blogRssCache = new BlogRssCache();
         }
         $blogRssCache->setMemberId($memberId);
         $blogRssCache->setTitle($item['title']);
         $blogRssCache->setDescription($item['description']);
         $blogRssCache->setLink($item['link']);
         $blogRssCache->setDate($item['date']);
         $blogRssCache->save();
     }
     return true;
 }