2017 © Pedro Peláez
 

kohana-module flatfile

A simple FlatFile ORM

image

ziopod/flatfile

A simple FlatFile ORM

  • Thursday, January 12, 2017
  • by ziopod
  • Repository
  • 2 Watchers
  • 2 Stars
  • 99 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 4 Open issues
  • 17 Versions
  • 18 % Grown

The README.md

Flatfile

A simple Flatfile ORM, (*1)

How to use it

This is a example with a Welcome controller., (*2)

Create your model

Create a page model:, (*3)

| application
    | classes
        | Model
            Page.php

In your model:, (*4)

class Model_Page extend Flatfile {

    /**
    * Somes filters
    *
    * @return array
    **/

    public function filters()
    {
        return array(
            array(
                'content' => array('Flatfile::Markdown'),
            ),
        );
    }
}

Create your content

In your root project:, (*5)

| content
    | pages
        hello-world.md

In your hello-world file:, (*6)

title: Hi!
---
Hello **World**

Grab your content

Create your controller, (*7)

| application
    | classes
        | Controller
            Welcome.php

In your controller, in classic Kohana MVC design pattern, (*8)

class Controller_Welcome extends Controller {

    /**
    * Action call by defaults
    *
    * @return void
    **/

    public function action_index()
    {
        $view = View::factory('welcome/index')
            ->bind('page', $page);
        $page = new Model_Page('hello-world');
        $this->response->body($view);
    }
}

Show your content

Create your View, (*9)

| application 
    | views
        | welcome
            index.php

In your view index, (*10)

<html>
    <head>
        <title>
            <?php echo $page->title; ?>
        </title>
    </head>
    <body>
        <?php echo $page->content; ?>
    </body>
</html>

The result

<html>
    <head>
        <title>Hi!</title>
    </head>
    <body>
        Hello <strong>World</strong>    
    </body>
</html>

Filters

Similar usage to Kohana ORM., (*11)

Flatfile embed a specifics filters :, (*12)

Markdown

Process a Markdown transformation., (*13)

str_to_list

Convert a comma separate list to an array of term and slug., (*14)

For example :, (*15)

tags: Laitue, Choux rouge

Be converted to, (*16)

array(
    array(
        'name'  => 'Laitue',
        'slug'  => 'laitue',
    ),
    array(
        'name'  => 'Choux rouge',
        'slug'  => 'choux-rouge',
    ),
)

Usefull, for example, to create a list of tags; in your view :, (*17)

<uL>
<?php foreach($page->tags as $tag): ?>
    <li>
        <a href="http://my_awesome_blog.com/posts/tag/<?php echo $tag['slug']; ?>">
            <?php echo $tag['name']; ?>
        </a>
    </li>
<?php endforeach; ?>
</ul>

json_api

Give him a json API service address, it will return a result ready to use., (*18)

For example :, (*19)

bloginfo: https://api.tumblr.com/v2/blog/blogdamientran.tumblr.com/info?api_key=fuiKNFp9vQFvjLNvx4sUwti4Yb5yGutBN4Xh10LXZhhRKjWlV4

Resulting to, (*20)

stdClass Object
(
    [blog] => stdClass Object
    (
        [title] => Damien Tran
        [name] => blogdamientran
        [posts] => 66
        [url] => http://blogdamientran.tumblr.com/
        [updated] => 1434963170
        [description] => damientran.com - palefroi.net
        [is_nsfw] => 
        [ask] => 
        [ask_page_title] => Ask me anything
        [ask_anon] => 
        [share_likes] => 1
        [likes] => 6
    )
)

You can use the result in your view, (*21)

<a href="<?php echo $page->bloginfo->blog->url; ?>">
    See the blog <?php echo $page->bloginfo->blog->title; ?>
</a>

Flatfile methods

Flatfile contain somes usefull methods, (*22)

order

query

Operators

like

Multiple queries

date and slug

offset

limit

find

find_all

The Versions

12/01 2017

dev-master

9999999-dev http://ziopod.com

A simple FlatFile ORM

  Sources   Download

The Requires

 

by Steve Beau

orm markdown kohana kohana module flatfile

12/01 2017

v0.0.2.5

0.0.2.5 http://ziopod.com

A simple FlatFile ORM

  Sources   Download

The Requires

 

by Steve Beau

orm markdown kohana kohana module flatfile

09/01 2017

v0.0.2.4

0.0.2.4 http://ziopod.com

A simple FlatFile ORM

  Sources   Download

The Requires

 

by Steve Beau

orm markdown kohana kohana module flatfile

15/12 2016

v0.0.2.3

0.0.2.3 http://ziopod.com

A simple FlatFile ORM

  Sources   Download

The Requires

 

by Steve Beau

orm markdown kohana kohana module flatfile

15/12 2016

v0.0.2.2

0.0.2.2 http://ziopod.com

A simple FlatFile ORM

  Sources   Download

The Requires

 

by Steve Beau

orm markdown kohana kohana module flatfile

14/12 2016

v0.0.2.1

0.0.2.1 http://ziopod.com

A simple FlatFile ORM

  Sources   Download

The Requires

 

by Steve Beau

orm markdown kohana kohana module flatfile

14/12 2016

v0.0.2.0

0.0.2.0 http://ziopod.com

A simple FlatFile ORM

  Sources   Download

The Requires

 

by Steve Beau

orm markdown kohana kohana module flatfile

30/11 2016

v0.0.1.9

0.0.1.9 http://ziopod.com

A simple FlatFile ORM

  Sources   Download

The Requires

 

by Steve Beau

orm markdown kohana kohana module flatfile

23/11 2016

v0.0.1.8

0.0.1.8 http://ziopod.com

A simple FlatFile ORM

  Sources   Download

The Requires

 

by Steve Beau

orm markdown kohana kohana module flatfile

15/11 2016

v0.0.1.7

0.0.1.7 http://ziopod.com

A simple FlatFile ORM

  Sources   Download

The Requires

 

by Steve Beau

orm markdown kohana kohana module flatfile

04/04 2016

v0.0.1.6

0.0.1.6 http://ziopod.com

A simple FlatFile ORM

  Sources   Download

The Requires

 

by Steve Beau

orm markdown kohana kohana module flatfile

04/04 2016

v0.0.1.5

0.0.1.5 http://ziopod.com

A simple FlatFile ORM

  Sources   Download

The Requires

 

by Steve Beau

orm markdown kohana kohana module flatfile

01/04 2016

V0.0.1.4

0.0.1.4 http://ziopod.com

A simple FlatFile ORM

  Sources   Download

The Requires

 

by Steve Beau

orm markdown kohana kohana module flatfile

10/01 2016

v0.0.1.3

0.0.1.3 http://ziopod.com

A simple FlatFile ORM

  Sources   Download

The Requires

 

by Steve Beau

orm markdown kohana kohana module flatfile

04/01 2016

v0.0.1.2

0.0.1.2 http://ziopod.com

A simple FlatFile ORM

  Sources   Download

The Requires

 

by Steve Beau

orm markdown kohana kohana module flatfile

02/09 2015

v0.0.1.1

0.0.1.1 http://ziopod.com

A simple FlatFile ORM

  Sources   Download

The Requires

 

by Steve Beau

orm markdown kohana kohana module flatfile

27/07 2015

v0.0.1

0.0.1.0 http://ziopod.com

A simple FlatFile ORM

  Sources   Download

The Requires

 

by Steve Beau

orm markdown kohana kohana module flatfile