Skip to content

Commit 3a797c6

Browse files
committed
WIP
1 parent 76a7d0d commit 3a797c6

File tree

9 files changed

+55
-17
lines changed

9 files changed

+55
-17
lines changed

src/HTTPHelper.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use HTTPFriend\Tags\Tag as Tag;
88
use HTTPFriend\Tags\Link as Link;
99
use HTTPFriend\Tags\Meta as Meta;
10+
use HTTPFriend\Tags\Js as Js;
11+
use HTTPFriend\Tags\Css as Css;
1012

1113

1214
class HTTPHelper {
@@ -20,6 +22,7 @@ public function __construct( $config = [] )
2022
{
2123
$this->setConfig( $config );
2224
$this->tag = $this->tag ?: new Tag;
25+
$this->CSS = $this->CSS ?: new Css;
2326
}
2427

2528
public function setConfig( $config = [] ){

src/Tags/Css.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
namespace HTTPFriend\Tags;
44

5-
class Css {
6-
5+
class Css extends Tag {
6+
7+
public function __construct()
8+
{
9+
parent::__construct();
10+
}
11+
12+
public function css( $options = [] )
13+
{
14+
$options["rel"] = "stylesheet";
15+
$options["type"] = "text/css";
16+
$this->output( [ "tag" => "link", "attr" => $options, "selfClosing" => true ] );
17+
}
18+
719
}

src/Tags/Js.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
namespace HTTPFriend\Tags;
44

5-
class Js {
6-
5+
class Js extends Tag {
6+
7+
public function __construct()
8+
{
9+
parent::__construct();
10+
}
11+
12+
public function js( $options = [] )
13+
{
14+
15+
$this->output( [ "tag" => "script", "attr" => $options ] );
16+
$this->output( [ "tag" => "script", "close" => true ] );
17+
}
18+
719
}

src/Tags/Link.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,10 @@ class Link extends Tag {
77
public function __construct( ){
88
parent::__construct();
99
}
10+
11+
public function link( $options = [] )
12+
{
13+
$this->output( [ "tag" => "script", "attr" => $options, "selfClosing" => true ] );
14+
}
1015

1116
}

src/Tags/Meta.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@ public function __construct(){
88
parent::__construct( );
99
}
1010

11+
public function meta( $options = [] )
12+
{
13+
$this->output( [ "tag" => "meta", "attr" => $options, "selfClosing" => true ] );
14+
}
15+
1116
}

src/Tags/Tag.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ public function createElement( $tag, $attr = [], $selfClosing = false, $close =
5252
}
5353
}
5454

55-
$element = (( $selfClosing ) ? "/" : "" ) . ">";
55+
56+
$element .= (( $selfClosing ) ? "/" : "" ) . ">";
57+
error_log( print_r( $element,1 ) );
5658

5759
return $element;
5860
}

test/index.html

Lines changed: 0 additions & 10 deletions
This file was deleted.

test/index.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77

88
$HTTP = new HTTPFriend\HTTPHelper();
99

10-
1110
$HTTP->setConfigParameter( "baseURL", "/_tom/httphelper/test/" );
1211

13-
$HTTP->setHTML( file_get_contents( "./index.html" ) );
12+
ob_start();
13+
14+
require "./index2.php";
15+
16+
$HTTP->setHTML( ob_get_clean() );
1417

1518
$HTTP->parseHTML();
1619

test/php-error.log

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[17-Jan-2019 13:46:13 Europe/London] 1
2+
[17-Jan-2019 13:46:38 Europe/London] <link href="/main.css" />
3+
[17-Jan-2019 13:47:50 Europe/London] <link href="/main.css" rel="stylesheet" type="text/css" />
4+
[17-Jan-2019 13:50:32 Europe/London] <link href="/main.css" rel="stylesheet" type="text/css" />
5+
[17-Jan-2019 13:54:21 Europe/London] <link href="/main.css" rel="stylesheet" type="text/css" />
6+
[17-Jan-2019 13:54:42 Europe/London] <link href="/main.css" rel="stylesheet" type="text/css" />

0 commit comments

Comments
 (0)