/**
  * @desc Buils a ContentFormattingParser object.
  */
 public function __construct()
 {
     parent::__construct();
     $content_formatting_config = ContentFormattingConfig::load();
     $this->forbidden_tags = $content_formatting_config->get_forbidden_tags();
     $this->html_auth = $content_formatting_config->get_html_tag_auth();
 }
Ejemplo n.º 2
0
 /**
  * Create a Transaction from MT940 transaction text lines
  *
  * ING only provides a book date, not a valuation date. This
  * is opposite from standard MT940 so the AbstractReader will read it
  * as a valueDate. This must be corrected.
  *
  * ING does sometimes supplies a book date inside the description.
  *
  * @param array $lines The transaction text at offset 0 and the description at offset 1
  * @return \Jejik\MT940\Transaction
  */
 protected function transaction(array $lines)
 {
     $transaction = parent::transaction($lines);
     $transaction->setBookDate($transaction->getValueDate())->setValueDate(null);
     if (preg_match('/transactiedatum: (\\d{2}-\\d{2}-\\d{4})/', $lines[1], $match)) {
         $valueDate = \DateTime::createFromFormat('d-m-Y', $match[1]);
         $valueDate->setTime(0, 0, 0);
         $transaction->setValueDate($valueDate);
     }
     return $transaction;
 }
Ejemplo n.º 3
0
 /**
  * Determine the format for this statement
  *
  * @param string $text Statement body text
  * @return \Jejik\MT940\Statement
  */
 protected function statementBody($text)
 {
     switch (substr($this->getLine('20', $text), 0, 4)) {
         case '940A':
             $this->format = self::FORMAT_CLASSIC;
             break;
         case '940S':
             $this->format = self::FORMAT_STRUCTURED;
             break;
         default:
             throw new \RuntimeException('Unknown file format');
     }
     return parent::statementBody($text);
 }
Ejemplo n.º 4
0
Archivo: Ing.php Proyecto: avido/mt940
 /**
  * Create a Transaction from MT940 transaction text lines
  *
  * ING only provides a book date, not a valuation date. This
  * is opposite from standard MT940 so the AbstractReader will read it
  * as a valueDate. This must be corrected.
  *
  * ING does sometimes supplies a book date inside the description.
  *
  * @param array $lines The transaction text at offset 0 and the description at offset 1
  * @return \Jejik\MT940\Transaction
  */
 protected function transaction(array $lines)
 {
     $transaction = parent::transaction($lines);
     // If a bookdate was provided, do not switch the value and book dates
     // Since 2014 this should be the case as the 2nd subfield in tag 61 is the book date
     if (is_null($transaction->getBookDate())) {
         $transaction->setBookDate($transaction->getValueDate())->setValueDate(null);
         if (preg_match('/transactiedatum: (\\d{2}-\\d{2}-\\d{4})/', $lines[1], $match)) {
             $valueDate = \DateTime::createFromFormat('d-m-Y', $match[1]);
             $valueDate->setTime(0, 0, 0);
             $transaction->setValueDate($valueDate);
         }
     }
     return $transaction;
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function parse()
 {
     if (!$this->dom || !($topBox = $this->getTopBox())) {
         return $this->meta;
     }
     $this->contentDom = new \DOMDocument('1.0');
     $this->contentDom->appendChild($this->contentDom->importNode($topBox, true));
     foreach ($this->junkTags as $tag) {
         $this->removeJunkTag($tag);
     }
     foreach ($this->junkAttrs as $attr) {
         $this->removeJunkAttr($attr);
     }
     $this->content = mb_convert_encoding($this->contentDom->saveHTML(), 'utf-8', "HTML-ENTITIES");
     return parent::parse();
 }
Ejemplo n.º 6
0
 public function parse($format, $data, $charset = 'UTF-8')
 {
     if (!$this->isSupported($format)) {
         return new \RuntimeException("Format {$format} is not supported.");
     }
     $date = $this->getCrawler($data, $charset)->filter(static::$selectorDate)->first()->attr('id');
     $today = true;
     if (!empty($date) && is_string($date)) {
         $date = preg_replace('/^[^.0-9[:space:]]+[[:space:]]+/', '', $date);
         $date = \DateTime::createFromFormat('j.n.Y', $date);
         if ($date !== false && (new \DateTime('today'))->getTimestamp() - $date->getTimestamp() > 24 * 60 * 60) {
             $today = false;
         }
     }
     if ($today) {
         return parent::parse($format, $data, $charset);
     } else {
         return [];
     }
 }
 /**
  * @desc Builds a ContentFormattingUnparser class.
  */
 public function __construct()
 {
     parent::__construct();
 }
Ejemplo n.º 8
0
 /**
  * {@inheritDoc}
  */
 public function __construct(Parser $parser, $level = 0)
 {
     parent::__construct($parser, $level);
     $this->counter = 0;
 }
Ejemplo n.º 9
0
 public function parse($format, $data, $charset = 'UTF-8')
 {
     $data = preg_replace('/ /', ' ', $data);
     return parent::parse($format, $data, $charset);
 }
Ejemplo n.º 10
0
 /**
  * @param string $context
  * @param array $params Context parameters
  * @return mixed Data returned by context
  */
 public function enterContext($context, array $params = array())
 {
     return $this->parser->enterContext($context, $params, $this);
 }
Ejemplo n.º 11
0
 /**
  * @desc Builds a BBCodeHighlighter objet
  */
 public function __construct()
 {
     //We call the parent constructor
     parent::__construct();
 }
Ejemplo n.º 12
0
Archivo: Meta.php Proyecto: yoozi/golem
 /**
  * Return the title of the document.
  *
  * @return string
  */
 protected function getTitle()
 {
     return $this->og['title'] ?: parent::getTitle();
 }