[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/simplepie/library/SimplePie/ -> Source.php (source)

   1  <?php
   2  /**
   3   * SimplePie
   4   *
   5   * A PHP-Based RSS and Atom Feed Framework.
   6   * Takes the hard work out of managing a complete RSS/Atom solution.
   7   *
   8   * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
   9   * All rights reserved.
  10   *
  11   * Redistribution and use in source and binary forms, with or without modification, are
  12   * permitted provided that the following conditions are met:
  13   *
  14   *     * Redistributions of source code must retain the above copyright notice, this list of
  15   *       conditions and the following disclaimer.
  16   *
  17   *     * Redistributions in binary form must reproduce the above copyright notice, this list
  18   *       of conditions and the following disclaimer in the documentation and/or other materials
  19   *       provided with the distribution.
  20   *
  21   *     * Neither the name of the SimplePie Team nor the names of its contributors may be used
  22   *       to endorse or promote products derived from this software without specific prior
  23   *       written permission.
  24   *
  25   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  26   * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  27   * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
  28   * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  29   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  31   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  32   * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33   * POSSIBILITY OF SUCH DAMAGE.
  34   *
  35   * @package SimplePie
  36   * @version 1.3.1
  37   * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  38   * @author Ryan Parman
  39   * @author Geoffrey Sneddon
  40   * @author Ryan McCue
  41   * @link http://simplepie.org/ SimplePie
  42   * @license http://www.opensource.org/licenses/bsd-license.php BSD License
  43   */
  44  
  45  /**
  46   * Handles `<atom:source>`
  47   *
  48   * Used by {@see SimplePie_Item::get_source()}
  49   *
  50   * This class can be overloaded with {@see SimplePie::set_source_class()}
  51   *
  52   * @package SimplePie
  53   * @subpackage API
  54   */
  55  class SimplePie_Source
  56  {
  57      var $item;
  58      var $data = array();
  59      protected $registry;
  60  
  61  	public function __construct($item, $data)
  62      {
  63          $this->item = $item;
  64          $this->data = $data;
  65      }
  66  
  67  	public function set_registry(SimplePie_Registry $registry)
  68      {
  69          $this->registry = $registry;
  70      }
  71  
  72  	public function __toString()
  73      {
  74          return md5(serialize($this->data));
  75      }
  76  
  77  	public function get_source_tags($namespace, $tag)
  78      {
  79          if (isset($this->data['child'][$namespace][$tag]))
  80          {
  81              return $this->data['child'][$namespace][$tag];
  82          }
  83          else
  84          {
  85              return null;
  86          }
  87      }
  88  
  89  	public function get_base($element = array())
  90      {
  91          return $this->item->get_base($element);
  92      }
  93  
  94  	public function sanitize($data, $type, $base = '')
  95      {
  96          return $this->item->sanitize($data, $type, $base);
  97      }
  98  
  99  	public function get_item()
 100      {
 101          return $this->item;
 102      }
 103  
 104  	public function get_title()
 105      {
 106          if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
 107          {
 108              return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
 109          }
 110          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
 111          {
 112              return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
 113          }
 114          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
 115          {
 116              return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
 117          }
 118          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
 119          {
 120              return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
 121          }
 122          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
 123          {
 124              return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
 125          }
 126          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
 127          {
 128              return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
 129          }
 130          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
 131          {
 132              return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
 133          }
 134          else
 135          {
 136              return null;
 137          }
 138      }
 139  
 140  	public function get_category($key = 0)
 141      {
 142          $categories = $this->get_categories();
 143          if (isset($categories[$key]))
 144          {
 145              return $categories[$key];
 146          }
 147          else
 148          {
 149              return null;
 150          }
 151      }
 152  
 153  	public function get_categories()
 154      {
 155          $categories = array();
 156  
 157          foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category)
 158          {
 159              $term = null;
 160              $scheme = null;
 161              $label = null;
 162              if (isset($category['attribs']['']['term']))
 163              {
 164                  $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
 165              }
 166              if (isset($category['attribs']['']['scheme']))
 167              {
 168                  $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
 169              }
 170              if (isset($category['attribs']['']['label']))
 171              {
 172                  $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
 173              }
 174              $categories[] = $this->registry->create('Category', array($term, $scheme, $label));
 175          }
 176          foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)
 177          {
 178              // This is really the label, but keep this as the term also for BC.
 179              // Label will also work on retrieving because that falls back to term.
 180              $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
 181              if (isset($category['attribs']['']['domain']))
 182              {
 183                  $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT);
 184              }
 185              else
 186              {
 187                  $scheme = null;
 188              }
 189              $categories[] = $this->registry->create('Category', array($term, $scheme, null));
 190          }
 191          foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
 192          {
 193              $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
 194          }
 195          foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category)
 196          {
 197              $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
 198          }
 199  
 200          if (!empty($categories))
 201          {
 202              return array_unique($categories);
 203          }
 204          else
 205          {
 206              return null;
 207          }
 208      }
 209  
 210  	public function get_author($key = 0)
 211      {
 212          $authors = $this->get_authors();
 213          if (isset($authors[$key]))
 214          {
 215              return $authors[$key];
 216          }
 217          else
 218          {
 219              return null;
 220          }
 221      }
 222  
 223  	public function get_authors()
 224      {
 225          $authors = array();
 226          foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author)
 227          {
 228              $name = null;
 229              $uri = null;
 230              $email = null;
 231              if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
 232              {
 233                  $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
 234              }
 235              if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
 236              {
 237                  $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
 238              }
 239              if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
 240              {
 241                  $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
 242              }
 243              if ($name !== null || $email !== null || $uri !== null)
 244              {
 245                  $authors[] = $this->registry->create('Author', array($name, $uri, $email));
 246              }
 247          }
 248          if ($author = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
 249          {
 250              $name = null;
 251              $url = null;
 252              $email = null;
 253              if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
 254              {
 255                  $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
 256              }
 257              if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
 258              {
 259                  $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
 260              }
 261              if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
 262              {
 263                  $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
 264              }
 265              if ($name !== null || $email !== null || $url !== null)
 266              {
 267                  $authors[] = $this->registry->create('Author', array($name, $url, $email));
 268              }
 269          }
 270          foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author)
 271          {
 272              $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
 273          }
 274          foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author)
 275          {
 276              $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
 277          }
 278          foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author)
 279          {
 280              $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null));
 281          }
 282  
 283          if (!empty($authors))
 284          {
 285              return array_unique($authors);
 286          }
 287          else
 288          {
 289              return null;
 290          }
 291      }
 292  
 293  	public function get_contributor($key = 0)
 294      {
 295          $contributors = $this->get_contributors();
 296          if (isset($contributors[$key]))
 297          {
 298              return $contributors[$key];
 299          }
 300          else
 301          {
 302              return null;
 303          }
 304      }
 305  
 306  	public function get_contributors()
 307      {
 308          $contributors = array();
 309          foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor)
 310          {
 311              $name = null;
 312              $uri = null;
 313              $email = null;
 314              if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
 315              {
 316                  $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
 317              }
 318              if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
 319              {
 320                  $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
 321              }
 322              if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
 323              {
 324                  $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
 325              }
 326              if ($name !== null || $email !== null || $uri !== null)
 327              {
 328                  $contributors[] = $this->registry->create('Author', array($name, $uri, $email));
 329              }
 330          }
 331          foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor)
 332          {
 333              $name = null;
 334              $url = null;
 335              $email = null;
 336              if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
 337              {
 338                  $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
 339              }
 340              if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
 341              {
 342                  $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
 343              }
 344              if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
 345              {
 346                  $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
 347              }
 348              if ($name !== null || $email !== null || $url !== null)
 349              {
 350                  $contributors[] = $this->registry->create('Author', array($name, $url, $email));
 351              }
 352          }
 353  
 354          if (!empty($contributors))
 355          {
 356              return array_unique($contributors);
 357          }
 358          else
 359          {
 360              return null;
 361          }
 362      }
 363  
 364  	public function get_link($key = 0, $rel = 'alternate')
 365      {
 366          $links = $this->get_links($rel);
 367          if (isset($links[$key]))
 368          {
 369              return $links[$key];
 370          }
 371          else
 372          {
 373              return null;
 374          }
 375      }
 376  
 377      /**
 378       * Added for parity between the parent-level and the item/entry-level.
 379       */
 380  	public function get_permalink()
 381      {
 382          return $this->get_link(0);
 383      }
 384  
 385  	public function get_links($rel = 'alternate')
 386      {
 387          if (!isset($this->data['links']))
 388          {
 389              $this->data['links'] = array();
 390              if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link'))
 391              {
 392                  foreach ($links as $link)
 393                  {
 394                      if (isset($link['attribs']['']['href']))
 395                      {
 396                          $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
 397                          $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
 398                      }
 399                  }
 400              }
 401              if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link'))
 402              {
 403                  foreach ($links as $link)
 404                  {
 405                      if (isset($link['attribs']['']['href']))
 406                      {
 407                          $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
 408                          $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
 409  
 410                      }
 411                  }
 412              }
 413              if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
 414              {
 415                  $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
 416              }
 417              if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
 418              {
 419                  $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
 420              }
 421              if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
 422              {
 423                  $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
 424              }
 425  
 426              $keys = array_keys($this->data['links']);
 427              foreach ($keys as $key)
 428              {
 429                  if ($this->registry->call('Misc', 'is_isegment_nz_nc', array($key)))
 430                  {
 431                      if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]))
 432                      {
 433                          $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
 434                          $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
 435                      }
 436                      else
 437                      {
 438                          $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
 439                      }
 440                  }
 441                  elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
 442                  {
 443                      $this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
 444                  }
 445                  $this->data['links'][$key] = array_unique($this->data['links'][$key]);
 446              }
 447          }
 448  
 449          if (isset($this->data['links'][$rel]))
 450          {
 451              return $this->data['links'][$rel];
 452          }
 453          else
 454          {
 455              return null;
 456          }
 457      }
 458  
 459  	public function get_description()
 460      {
 461          if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle'))
 462          {
 463              return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
 464          }
 465          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline'))
 466          {
 467              return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
 468          }
 469          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
 470          {
 471              return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
 472          }
 473          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
 474          {
 475              return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
 476          }
 477          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
 478          {
 479              return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
 480          }
 481          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
 482          {
 483              return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
 484          }
 485          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
 486          {
 487              return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
 488          }
 489          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
 490          {
 491              return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
 492          }
 493          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
 494          {
 495              return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
 496          }
 497          else
 498          {
 499              return null;
 500          }
 501      }
 502  
 503  	public function get_copyright()
 504      {
 505          if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights'))
 506          {
 507              return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
 508          }
 509          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright'))
 510          {
 511              return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
 512          }
 513          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright'))
 514          {
 515              return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
 516          }
 517          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights'))
 518          {
 519              return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
 520          }
 521          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights'))
 522          {
 523              return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
 524          }
 525          else
 526          {
 527              return null;
 528          }
 529      }
 530  
 531  	public function get_language()
 532      {
 533          if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language'))
 534          {
 535              return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
 536          }
 537          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language'))
 538          {
 539              return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
 540          }
 541          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language'))
 542          {
 543              return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
 544          }
 545          elseif (isset($this->data['xml_lang']))
 546          {
 547              return $this->sanitize($this->data['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
 548          }
 549          else
 550          {
 551              return null;
 552          }
 553      }
 554  
 555  	public function get_latitude()
 556      {
 557          if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
 558          {
 559              return (float) $return[0]['data'];
 560          }
 561          elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
 562          {
 563              return (float) $match[1];
 564          }
 565          else
 566          {
 567              return null;
 568          }
 569      }
 570  
 571  	public function get_longitude()
 572      {
 573          if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long'))
 574          {
 575              return (float) $return[0]['data'];
 576          }
 577          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
 578          {
 579              return (float) $return[0]['data'];
 580          }
 581          elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match))
 582          {
 583              return (float) $match[2];
 584          }
 585          else
 586          {
 587              return null;
 588          }
 589      }
 590  
 591  	public function get_image_url()
 592      {
 593          if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image'))
 594          {
 595              return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI);
 596          }
 597          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo'))
 598          {
 599              return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
 600          }
 601          elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon'))
 602          {
 603              return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
 604          }
 605          else
 606          {
 607              return null;
 608          }
 609      }
 610  }
 611  


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1