~mcas/kubuntu-de.org-website/newsprep

« back to all changes in this revision

Viewing changes to inc/kdowikinews.php

  • Committer: Arthur Schiwon
  • Date: 2009-12-27 01:09:19 UTC
  • Revision ID: blizzz@arthur-schiwon.de-20091227010919-kp3y4c0zqqv3ei6g
Erste Implemenation der Ini-Config in KDOWikiNews
Dazu erste Basisklasse KDOBase erstellt. Davon leiten künftig alle ab.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
2
 
3
 
class KDOWikiNews {
 
3
class KDOWikiNews extends KDOBase {
4
4
    private $url   = null;
5
5
    private $html  = null;
6
6
    private $title = null;
7
7
 
8
8
    //TODO: these variables from config
9
 
    private $leadBorder    = '<h2> <span class="mw-headline">';
10
 
    private $leadFinish    = '</span></h2>';
11
 
    private $trailerBorder = '<div class="printfooter">';
12
9
    private $blacklist = array(
13
10
                                '/class="external text"/',
14
11
                                '/rel="nofollow"/',
19
16
 
20
17
 
21
18
    public function __construct($url) {
 
19
        KDOBase::__construct();
 
20
 
22
21
        $this->url = $url;
23
22
        $this->fetchPage();
24
23
        $this->fitHTML();
40
39
        $i = 0;
41
40
        $isTitle = false;
42
41
 
43
 
        while($i = strpos($this->html, $this->leadBorder, $i+1)) {
 
42
        while($i = strpos($this->html, $this->config->WikiParsing_leadBorder, $i+1)) {
44
43
            if($isTitle) {
45
44
                break;
46
45
            }
55
54
    }
56
55
 
57
56
    private function removeTrailer() {
58
 
        $i = strpos($this->html, $this->trailerBorder);
 
57
        $i = strpos($this->html, $this->config->WikiParsing_trailerBorder);
59
58
        if($i) {
60
59
            $this->html = substr($this->html, 0, $i);
61
60
        } else {
70
69
    }
71
70
 
72
71
    private function isolizeTitle() {
73
 
        $titleHtmlLen = strpos($this->html, $this->leadFinish) + strlen($this->leadFinish);
 
72
        $titleHtmlLen = strpos($this->html, $this->config->WikiParsing_leadFinish) + strlen($this->config->WikiParsing_leadFinish);
74
73
        $titleHtml    = substr($this->html, 0, $titleHtmlLen);
75
 
        
 
74
 
76
75
        //clean article html
77
76
        $this->html = substr($this->html, $titleHtmlLen);
78
 
        
 
77
 
79
78
        //set clean Title
80
 
        $this->title = str_replace($this->leadFinish, '', str_replace($this->leadBorder, '', $titleHtml));
 
79
        $this->title = str_replace($this->config->WikiParsing_leadFinish, '', str_replace($this->config->WikiParsing_leadBorder, '', $titleHtml));
81
80
    }
82
81
 
83
82
    private function insertBreak() {
98
97
            throw new Exception('Fuck Life Hardest!');
99
98
        }
100
99
    }
101
 
    
 
100
 
102
101
    public function getTitle() {
103
102
        return $this->title;
104
103
    }