2017 © Pedro Peláez
 

library page

Manipulate every part of an HTML Page at any time.

image

bootpress/page

Manipulate every part of an HTML Page at any time.

  • Monday, January 30, 2017
  • by BootPress
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,484 Installations
  • PHP
  • 10 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

use BootPress\Page\Component as Page;

Packagist ![License MIT][badge-license] HHVM Tested ![PHP 7 Supported][badge-php] Build Status ![Code Climate][badge-code-climate] Test Coverage, (*1)

A framework agnostic HTML framework that allows you to manipulate every part of an HTML Page at any time., (*2)

Installation

Add the following to your composer.json file., (*3)

``` bash { "require": { "bootpress/page": "^1.0" } }, (*4)


## Example Usage ``` php <?php use BootPress\Page\Component as Page; $page = Page::html();

The Page class implements the Singleton design pattern so that you can call it from anywhere, and still be on the same "Page". You don't have to, but if you would like to enforce a desired url scheme (recommended), then do this:, (*5)

``` php $page = Page::html(array( 'dir' => '../', // a root folder where you can keep everything safe and sound 'base' => 'https://example.com/', // this will be enforced now 'suffix' => '.html', // goes at the end of your urls )); // You can only do this once, (*6)


Symfony is our undisputed friend here. This class relies on their HttpFoundation component. You can pass us an instance if you already have one going, or we will create one for you. Check this out: ```php $page->response->request->query->get('key'); // or ... $page->post('key'); // ie. a $_POST['key'] with benefits

The $page->response above is the Symfony Response object that you can access directly. You can also call (or set) $page->session, and if you didn't have one before, you do now., (*7)

Now that setting up is out of the way ..., (*8)

``` php // The .ico and .css files will go to your , (*9)

// The .js file will be at the bottom of your $page->link(array( $page->url('images/favicon.ico'), $page->url('css/stylesheet.css'), $page->url('js/functions.js'), ));

// To put a before all the others you have set $page->link('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css', 'prepend');, (*10)

// Meta tags are placed at the top of the , (*11)

$page->meta('name="author" content="name"'); // or ... $page->meta(array('name'=>'author', 'content'=>'name')); // or ... $page->link(''); // You can spell all these tags out with the link method

// ');, (*12)

// ');, (*13)

// All of these will go into one $(document).ready(function(){...}); at the bottom of your page $page->jquery('$("button.continue").html("Next Step...");');, (*14)


Of course, none of that does any good if you don't give us the final HTML to work with: ``` php echo $page->display('<p>Content</p>');

That will return you a nice:, (*15)

``` html , (*16)

Content, (*17)

$(document).ready(function(){ $("button.continue").html("Next Step..."); });

To change (or access) the default values that have been set (by anyone), you can: ``` php $page->title = 'Page Title'; $page->description = 'Page description.'; $page->charset = 'UTF-8'; $page->language = 'en-us'; echo '

'.$page->title.'

'; //

Page Title

Above, you just gave us your <p>Content</p>, and we created the HTML Page around it. You can also give us the entire page, and we'll still put things where they belong:, (*18)

``` php $page->display(<<<'EOT', (*19)

<  !doctype html>

, (*20)

< title>Broken </ head>
I'm in the body!</body>

< /html>, (*21)

EOT; );, (*22)


That will give you: ``` php < !doctype html> <html > <HEad> <meta charset="UTF-8"> <meta name="description" content="Page description."> < title>Broken</tit <META content=" name " name="author"> <link rel="shortcut icon" href="https://example.com/images/favicon.ico"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <link rel="stylesheet" href="https://example.com/css/stylesheet.css"> <style>body { background-color:red; color:black; }</style> </head> <body style="color:#333;"> I'm in the body! <script src="https://example.com/js/functions.js"></script> <script>alert("Hello World");</script> $(document).ready(function(){ $("button.continue").html("Next Step..."); }); </body> </html>

It's a bit screwed up still, but that's how you wanted it. We took nothing out, and only added the parts that were missing with the information you gave us. This class can do as little, or as much as you like. It's all the same to us. Even if you use none of the above, it's still nice to have a central location where an application can create, and work with urls established according to your specs., (*23)

``` php $page->enforce('seo-path'); // If the current url was not https://example.com/seo-path.html, it is now., (*24)

echo $page->url['path']; // seo-path, (*25)

if ($page->get('form') == 'submitted') { // https://example.com/seo-path.html?form=submitted $eject = $page->url('delete', '', 'form'); // https://example.com/seo-path.html $page->eject($page->url('add', $eject, 'payment', 'received')); // go now to https://example.com/seo-path.html?payment=received } elseif ($page->get('payment') == 'received') { mail($address, 'Thanks for your money!'); } ```, (*26)

That should be a good enough sampling for a README file. We didn't even get to directories, filters, and responses, but it's all there in the source code, fully documented., (*27)

Enjoy!, (*28)

License

The MIT License (MIT). Please see License File for more information., (*29)

The Versions

30/01 2017

dev-master

9999999-dev https://www.bootpress.org/components/page.html

Manipulate every part of an HTML Page at any time.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kyle Gadd

framework url html page uri bootpress

30/01 2017

v1.2

1.2.0.0 https://www.bootpress.org/components/page.html

Manipulate every part of an HTML Page at any time.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kyle Gadd

framework url html page uri bootpress

09/01 2017

v1.1.1

1.1.1.0

Manipulate every part of an HTML Page at any time.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kyle Gadd

framework url html page uri bootpress

04/01 2017

v1.1

1.1.0.0

Manipulate every part of an HTML Page at any time.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kyle Gadd

framework url html page uri bootpress

21/12 2016

v1.0.1

1.0.1.0

Manipulate every part of an HTML Page at any time.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kyle Gadd

framework url html page uri bootpress

16/09 2016

v1.0

1.0.0.0

Manipulate every part of an HTML Page at any time.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kyle Gadd

framework url html page uri bootpress