ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 10605


Ignore:
Timestamp:
Feb 3, 2009, 3:02:09 PM (12 years ago)
Author:
nagasawa
Message:

#3557:fixed changed SimpleXML to SimplePie?

Location:
OpenPNE3/plugins/opBlogPlugin/trunk
Files:
3 added
12 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/plugins/opBlogPlugin/trunk/apps/pc_frontend/modules/blog/actions/actions.class.php

    r10254 r10605  
    2222  * Executes index action
    2323  *
    24   * @param sfRequest $request A request object
     24  * @param sfRequest $request A request t
    2525  */
    2626  public function executeIndex($request)
    2727  {
    28     $this->blogList = BlogPeer::getBlogListOfAllMember();
     28    $this->blogList = BlogPeer::getBlogListOfAllMember(sfConfig::get('app_blog_action_size'));
    2929    if (!count($this->blogList))
    3030    {
     
    4040  public function executeFriend($request)
    4141  {
    42     $this->blogList = BlogPeer::getBlogListOfFriend($this->getUser()->getMemberId());
     42    $this->blogList = BlogPeer::getBlogListOfFriend(
     43      $this->getUser()->getMemberId(),
     44      sfConfig::get('app_blog_action_size')
     45    );
    4346    if (!count($this->blogList))
    4447    {
     
    5558  {
    5659    $this->member = $this->getUser()->getMember();
    57     $this->blogList = BlogPeer::getBlogListOfMember($this->getUser()->getMemberId());
     60    $this->blogList = BlogPeer::getBlogListOfMember(
     61      $this->getUser()->getMemberId(),
     62      sfConfig::get('app_blog_action_size')
     63    );
    5864    if (!count($this->blogList))
    5965    {
     
    7480      return sfView::ERROR;
    7581    }
    76     $this->blogList = BlogPeer::getBlogListOfMember($this->id);
     82    $this->blogList = BlogPeer::getBlogListOfMember(
     83      $this->id,
     84      sfConfig::get('app_blog_action_size')
     85    );
    7786    if (!count($this->blogList))
    7887    {
  • OpenPNE3/plugins/opBlogPlugin/trunk/apps/pc_frontend/modules/blog/actions/components.class.php

    r10251 r10605  
    1111  public function executeBlogHomeFriend()
    1212  {
    13     $this->blogList = BlogPeer::getBlogListOfFriend($this->getUser()->getMemberId(), 10, true);
     13    $this->blogList = BlogPeer::getBlogListOfFriend(
     14      $this->getUser()->getMemberId(),
     15      sfConfig::get('app_blog_component_size'),
     16      true
     17    );
    1418  }
    1519
     
    1721  {
    1822    $this->member = $this->getUser()->getMember();
    19     $this->blogList = BlogPeer::getBlogListOfMember($this->getUser()->getMemberId(), 10, true);
     23    $this->blogList = BlogPeer::getBlogListOfMember(
     24      $this->getUser()->getMemberId(),
     25      sfConfig::get('app_blog_component_size'),
     26      true
     27    );
    2028  }
    2129
     
    2331  {
    2432    $this->member = MemberPeer::retrieveByPk($this->id);
    25     $this->blogList = BlogPeer::getBlogListOfMember($this->id, 10, true);
     33    $this->blogList = BlogPeer::getBlogListOfMember(
     34      $this->id,
     35      sfConfig::get('app_blog_component_size'),
     36      true
     37    );
    2638  }
    2739}
  • OpenPNE3/plugins/opBlogPlugin/trunk/apps/pc_frontend/modules/blog/templates/_blogHomeUser.php

    r10598 r10605  
    88    array(
    99      'title' => sprintf(__('Newest blog of %s'), $member->getName()),
    10       'list' => $blogList,
     10      'list' => $sf_data->getRaw('blogList'),
    1111      'showName' => false,
    1212      'moreInfo' => 'blog/user'
  • OpenPNE3/plugins/opBlogPlugin/trunk/apps/pc_frontend/modules/blog/templates/_blogProfile.php

    r10488 r10605  
    77
    88<ul class="articleList">
    9 <?php foreach($blogList as $res): ?>
     9<?php foreach($sf_data->getRaw('blogList') as $res): ?>
    1010<li>
    1111<span class="date"><?php echo date( __('m/d'), $res['date']) ?></span>
  • OpenPNE3/plugins/opBlogPlugin/trunk/apps/pc_frontend/modules/blog/templates/friendSuccess.php

    r10254 r10605  
    66  array(
    77    'title' => __('Newest blog'),
    8     'list' => $blogList,
     8    'list' => $sf_data->getRaw('blogList'),
    99    'showName' => true
    1010  )
  • OpenPNE3/plugins/opBlogPlugin/trunk/apps/pc_frontend/modules/blog/templates/indexSuccess.php

    r10563 r10605  
    66  array(
    77    'title' => __('Newest blog'),
    8     'list' => $blogList,
     8    'list' => $sf_data->getRaw('blogList'),
    99    'showName' => true
    1010  )
  • OpenPNE3/plugins/opBlogPlugin/trunk/apps/pc_frontend/modules/blog/templates/profileSuccess.php

    r10241 r10605  
    66  array(
    77    'title' => sprintf(__('Newest blog of %s'), $member->getName()),
    8     'list' => $blogList,
     8    'list' => $sf_data->getRaw('blogList'),
    99    'showName' => false
    1010  )
  • OpenPNE3/plugins/opBlogPlugin/trunk/apps/pc_frontend/modules/blog/templates/userSuccess.php

    r10229 r10605  
    66  array(
    77    'title' => sprintf(__('Newest blog of %s'), $member->getName()),
    8     'list' => $blogList,
     8    'list' => $sf_data->getRaw('blogList'),
    99    'showName' => false
    1010  )
  • OpenPNE3/plugins/opBlogPlugin/trunk/apps/pc_frontend/templates/_partsBlogListBox.php

    r10529 r10605  
    99
    1010<ul class="articleList">
    11 <?php foreach($options['list'] as $res): ?>
     11<?php foreach($options->getRaw('list') as $res): ?>
    1212<li>
    1313<span class="date"><?php echo date( __('m/d'), $res['date']) ?></span>
  • OpenPNE3/plugins/opBlogPlugin/trunk/apps/pc_frontend/templates/_partsBlogListPage.php

    r10529 r10605  
    66</div>
    77
    8 <?php foreach ($options['list'] as $res): ?>
     8<?php foreach ($options->getRaw('list') as $res): ?>
    99<dl>
    1010<dt><?php echo date( __('Y/m/d H:i'), $res['date']) ?></dt>
  • OpenPNE3/plugins/opBlogPlugin/trunk/lib/form/MemberConfigForm/MemberConfigBlogUrlForm.class.php

    r10553 r10605  
    3939    if ($value['blog_url'] !== "")
    4040    {
    41       $root = BlogPeer::getXmlByUrl($value['blog_url']);
    42       if (!BlogPeer::getFeedType($root))
     41      $root = BlogPeer::getFeedByUrl($value['blog_url']);
     42      if (!$root)
    4343      {
    4444        $error = new sfValidatorError($validator, 'URL is invalid.');
  • OpenPNE3/plugins/opBlogPlugin/trunk/lib/model/BlogPeer.php

    r10464 r10605  
    1111class BlogPeer
    1212{
    13   public static function getXmlByUrl($url)
     13  public static function getFeedByUrl($url)
    1414  {
    15     if (is_null($url) || $url === '')
     15    if (is_null($url))
    1616    {
    1717      return false;
    1818    }
    19     $root = @simplexml_load_file($url);
    20     if (!$root)
     19    $feed = new SimplePie();
     20    $dir = sfConfig::get('sf_app_cache_dir') . '/plugins';
     21    if (!file_exists($dir))
     22    {
     23      mkdir($dir);
     24    }
     25    $dir .= '/opBlogPlugin';
     26    if (!file_exists($dir))
     27    {
     28      mkdir($dir);
     29    }
     30    $feed->set_cache_location($dir);
     31    $feed->set_feed_url($url);
     32    if(!@$feed->init())
    2133    {
    2234      return false;
    2335    }
    24     return $root;
    25   }
     36    $feed->handle_content_type();
    2637
    27   public static function getFeedType($root)
    28   {
    29     if (!$root)
    30     {
    31       return false;
    32     }
    33     switch (strtolower($root->getName()))
    34     {
    35       case "rdf":
    36         $feedType = "rdf";
    37         // rss0.8, rss1.0
    38         break;
    39       case "rss":
    40         $feedType = "rss";
    41         // rss2.0
    42         break;
    43       case "feed":
    44         $feedType = "atom";
    45         // atom
    46         break;
    47       default:
    48         $feedType = false;
    49         break;
    50     }
    51     return $feedType;
     38    return $feed;
    5239  }
    5340
     
    5946      return;
    6047    }
    61     $root = self::getXmlByUrl($member->getConfig('blog_url'));
    6248
     49    $feed = self::getFeedByUrl($member->getConfig('blog_url'));
     50    if (!$feed)
     51    {
     52      return;
     53    }
    6354
    64     $feedType = BlogPeer::getFeedType($root);
    65 
    66     switch ($feedType)
    67     {
    68     case 'rdf':
    69       self::addBlogFromRdf($member, $root, $list);
    70       break;
    71     case 'rss':
    72       self::addBlogFromRss($member, $root, $list);
    73       break;
    74     case 'atom':
    75       self::addBlogFromAtom($member, $root, $list);
    76       break;
    77     default:
    78       break;
    79     }
    80   }
    81 
    82   protected static function addBlogFromRdf(&$member, &$root, &$list)
    83   {
    84     foreach ($root->item as $item)
    85     {
    86       $dc = $item->children('http://purl.org/dc/elements/1.1/');
    87       $list[] = self::setBlog(
    88         strtotime(strval($dc->date)),
    89         strval($item->title),
    90         strval($item->link),
    91         $member->getName()
    92       );
    93     }
    94   }
    95 
    96   protected static function addBlogFromRss(&$member, &$root, &$list)
    97   {
    98     foreach ($root->channel->item as $item)
     55    foreach ($feed->get_items() as $item)
    9956    {
    10057      $list[] = self::setBlog(
    101         strtotime(strval($item->pubDate)),
    102         strval($item->title),
    103         strval($item->link),
     58        strtotime(@$item->get_date()),
     59        @$item->get_title(),
     60        @$item->get_link(),
    10461        $member->getName()
    105       );
    106     }
    107   }
    108 
    109   protected static function addBlogFromAtom(&$member, &$root, &$list)
    110   {
    111     foreach ($root->entry as $entry)
    112     {
    113       $list[] = self::setBlog(
    114         strtotime(strval($entry->published)),
    115         strval($entry->title),
    116         strval($entry->link),
    117         $member->getName()
    118       );
     62      );
    11963    }
    12064  }
     
    12468    return array(
    12569      'date' => $date,
    126       'title' => $title,
     70      'title' => htmlspecialchars_decode($title),
    12771      'link_to_external' => $link,
    12872      'name' => $name
     
    159103  }
    160104
    161   public static function getBlogListOfFriend($member_id, $size=20, $limitTitle = false)
     105  public static function getBlogListOfFriend($member_id, $size = 20, $limitTitle = false)
    162106  {
    163107    $c = new Criteria();
     
    180124  }
    181125
    182   public static function getBlogListOfMember($member_id, $size=20, $limitTitle = false)
     126  public static function getBlogListOfMember($member_id, $size = 20, $limitTitle = false)
    183127  {
    184128    $list = array();
     
    193137  }
    194138
    195   public static function getBlogListOfAllMember($size=20, $limitTitle = false)
     139  public static function getBlogListOfAllMember($size = 20, $limitTitle = false)
    196140  {
    197141    $c = new Criteria();
Note: See TracChangeset for help on using the changeset viewer.