[limb-svn] r6736 - in 3.x/examples/crud: . lib/limb src/controller template template/main_page template/news template/rss var www
svn at limb-project.com
svn at limb-project.com
Thu Jan 24 12:12:50 MSK 2008
Author: serega
Date: 2008-01-24 12:12:50 +0300 (Thu, 24 Jan 2008)
New Revision: 6736
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6736
Added:
3.x/examples/crud/template/main_page/display.phtml
3.x/examples/crud/template/news/create.phtml
3.x/examples/crud/template/news/detail.phtml
3.x/examples/crud/template/news/display.phtml
3.x/examples/crud/template/news/edit.phtml
3.x/examples/crud/template/news/form_errors.phtml
3.x/examples/crud/template/news/form_fields.phtml
3.x/examples/crud/template/page.phtml
3.x/examples/crud/template/pager.phtml
3.x/examples/crud/template/rss/macro_last_news.rss
3.x/examples/crud/var/
3.x/examples/crud/www/last-news-feed-on-macro.php
Modified:
3.x/examples/crud/lib/limb/
3.x/examples/crud/setup.php
3.x/examples/crud/src/controller/NewsController.class.php
3.x/examples/crud/template/page.html
3.x/examples/crud/template/pager.html
Log:
-- CRUD example is updated to work with both MACRO and WACT and to be compatible with 2007.4 release
Property changes on: 3.x/examples/crud/lib/limb
___________________________________________________________________
Name: svn:externals
- active_record https://svn.limb-project.com/3.x/tags/2007.3/limb/active_record
config https://svn.limb-project.com/3.x/tags/2007.3/limb/config
core https://svn.limb-project.com/3.x/tags/2007.3/limb/core
dbal https://svn.limb-project.com/3.x/tags/2007.3/limb/dbal
i18n https://svn.limb-project.com/3.x/tags/2007.3/limb/i18n
log https://svn.limb-project.com/3.x/tags/2007.3/limb/log
filter_chain https://svn.limb-project.com/3.x/tags/2007.3/limb/filter_chain
net https://svn.limb-project.com/3.x/tags/2007.3/limb/net
fs https://svn.limb-project.com/3.x/tags/2007.3/limb/fs
session https://svn.limb-project.com/3.x/tags/2007.3/limb/session
toolkit https://svn.limb-project.com/3.x/tags/2007.3/limb/toolkit
validation https://svn.limb-project.com/3.x/tags/2007.3/limb/validation
view https://svn.limb-project.com/3.x/tags/2007.3/limb/view
wact https://svn.limb-project.com/3.x/tags/2007.3/limb/wact
web_app https://svn.limb-project.com/3.x/tags/2007.3/limb/web_app
+ active_record https://svn.limb-project.com/3.x/tags/2007.4/limb/active_record
config https://svn.limb-project.com/3.x/tags/2007.4/limb/config
core https://svn.limb-project.com/3.x/tags/2007.4/limb/core
dbal https://svn.limb-project.com/3.x/tags/2007.4/limb/dbal
i18n https://svn.limb-project.com/3.x/tags/2007.4/limb/i18n
log https://svn.limb-project.com/3.x/tags/2007.4/limb/log
filter_chain https://svn.limb-project.com/3.x/tags/2007.4/limb/filter_chain
net https://svn.limb-project.com/3.x/tags/2007.4/limb/net
macro https://svn.limb-project.com/3.x/tags/2007.4/limb/macro
fs https://svn.limb-project.com/3.x/tags/2007.4/limb/fs
session https://svn.limb-project.com/3.x/tags/2007.4/limb/session
toolkit https://svn.limb-project.com/3.x/tags/2007.4/limb/toolkit
validation https://svn.limb-project.com/3.x/tags/2007.4/limb/validation
view https://svn.limb-project.com/3.x/tags/2007.4/limb/view
wact https://svn.limb-project.com/3.x/tags/2007.4/limb/wact
web_app https://svn.limb-project.com/3.x/tags/2007.4/limb/web_app
Modified: 3.x/examples/crud/setup.php
===================================================================
--- 3.x/examples/crud/setup.php 2008-01-23 14:07:39 UTC (rev 6735)
+++ 3.x/examples/crud/setup.php 2008-01-24 09:12:50 UTC (rev 6736)
@@ -12,4 +12,10 @@
require_once('limb/core/common.inc.php');
require_once('limb/web_app/common.inc.php');
+
+lmbToolkit :: instance()->setSupportedViewTypes(array('.phtml' => 'lmbMacroView',
+ '.html' => 'lmbWactView'));
+
+lmb_require('src/model/*.class.php');
+
?>
Modified: 3.x/examples/crud/src/controller/NewsController.class.php
===================================================================
--- 3.x/examples/crud/src/controller/NewsController.class.php 2008-01-23 14:07:39 UTC (rev 6735)
+++ 3.x/examples/crud/src/controller/NewsController.class.php 2008-01-24 09:12:50 UTC (rev 6736)
@@ -13,7 +13,7 @@
$news->import($this->request);
$this->useForm('news_form');
- $this->setViewFormDatasource($news);
+ $this->setFormDatasource($news);
if($news->trySave($this->error_list))
$this->redirect();
@@ -24,7 +24,7 @@
$news = new News((int)$this->request->get('id'));
$this->useForm('news_form');
- $this->setViewFormDatasource($news);
+ $this->setFormDatasource($news);
if(!$this->request->hasPost())
return;
Added: 3.x/examples/crud/template/main_page/display.phtml
===================================================================
--- 3.x/examples/crud/template/main_page/display.phtml (rev 0)
+++ 3.x/examples/crud/template/main_page/display.phtml 2008-01-24 09:12:50 UTC (rev 6736)
@@ -0,0 +1,27 @@
+{{wrap with="page.phtml" slot="page_placeholder"}}
+
+<h1>Main page - <a href="news/">Newsline</a></h1>
+<hr />
+
+<? $news = lmbActiveRecord :: find('News')->sort('date', 'DESC')->paginate(0, 3); ?>
+
+{{list using="$news"}}
+ <table width="100%">
+ <caption>Last News</caption>
+ {{list:item}}
+ <tr>
+ <td rowspan="2"><strong>{$item.date}</strong></td>
+ <th>{$item.title}</th>
+ </tr>
+ <tr>
+ <td>
+ {$item.annotation}
+ <a href="{{route_url params='controller:news,action:detail,id:{$item.id}'}}">more...</a>
+ </td>
+ </tr>
+ {{/list:item}}
+ </table>
+{{/list}}
+
+<route_url params='controller:news'>All news...</route_url>
+{{/wrap}}
Added: 3.x/examples/crud/template/news/create.phtml
===================================================================
--- 3.x/examples/crud/template/news/create.phtml (rev 0)
+++ 3.x/examples/crud/template/news/create.phtml 2008-01-24 09:12:50 UTC (rev 6736)
@@ -0,0 +1,16 @@
+{{wrap with="page.phtml" slot="page_placeholder"}}
+
+<h1><a href="">Main page</a> - <a href="/news/">Newsline</a></h1>
+<hr />
+<h1>Create news</h1>
+
+{{form id='news_form' name='news_form' method='post'}}
+
+{{include file="news/form_errors.phtml"/}}
+
+{{include file="news/form_fields.html"/}}
+
+<input id='create' type='submit' value='Create' runat='client'/>
+{{/form}}
+
+{{/wrap}}
Added: 3.x/examples/crud/template/news/detail.phtml
===================================================================
--- 3.x/examples/crud/template/news/detail.phtml (rev 0)
+++ 3.x/examples/crud/template/news/detail.phtml 2008-01-24 09:12:50 UTC (rev 6736)
@@ -0,0 +1,14 @@
+{{wrap with="page.phtml" slot="page_placeholder"}}
+
+<h1><a href="">Main page</a> - <a href="news/">Newsline</a></h1>
+<hr />
+
+<? $item = lmbActiveRecord :: findById('News', (int)$this->request->get('id'), $throw_exception_on_not_found = false); ?>
+
+<h2>{$item.title}</h2>
+
+<strong>Date</strong> : {$item.date}<br/>
+
+{$item.content|raw}
+
+{{/wrap}}
Added: 3.x/examples/crud/template/news/display.phtml
===================================================================
--- 3.x/examples/crud/template/news/display.phtml (rev 0)
+++ 3.x/examples/crud/template/news/display.phtml 2008-01-24 09:12:50 UTC (rev 6736)
@@ -0,0 +1,29 @@
+{{wrap with="page.phtml" slot="page_placeholder"}}
+
+<h1><a href="">Main page</a> - Newsline</h1>
+<hr />
+
+<a href='last-news-feed.php'>RSS</a> <a href='{{route_url params="action:create"}}'>Create news</a>
+<p/>
+
+<? $news = lmbActiveRecord :: find('News')->sort(array('date' => 'DESC')); ?>
+
+{{paginate iterator='$news' pager="pager"/}}
+
+{{include file='pager.phtml'/}}
+
+{{list using="$news"}}
+ {{list:item}}
+ <h2>
+ {$item.title} <strong>({$item.date})</strong>
+ <a href="{{route_url params='action:edit,id:{$item.id}'}}">Edit</a>
+ <a href="{{route_url params='action:delete,id:{$item.id}'}}">Delete</a>
+ </h2>
+ <p>
+ {$item.annotation}
+ <a href="{{route_url params='controller:news,action:detail,id:{$item.id}'}}">more...</a>
+ </p>
+ {{/list:item}}
+{{/list}}
+
+{{/wrap}}
Added: 3.x/examples/crud/template/news/edit.phtml
===================================================================
--- 3.x/examples/crud/template/news/edit.phtml (rev 0)
+++ 3.x/examples/crud/template/news/edit.phtml 2008-01-24 09:12:50 UTC (rev 6736)
@@ -0,0 +1,17 @@
+{{wrap with="page.phtml" slot="page_placeholder"}}
+
+<h1><a href="">Main page</a> - <a href="/news/">Newsline</a></h1>
+<hr />
+<h1>Edit news</h1>
+
+{{form id='news_form' name='news_form' method='post'}}
+
+{{include file="news/form_errors.phtml"/}}
+
+{{include file="news/form_fields.phtml"/}}
+
+<input id='edit' type='submit' value='Edit' />
+
+{{/form}}
+
+{{/wrap}}
Added: 3.x/examples/crud/template/news/form_errors.phtml
===================================================================
--- 3.x/examples/crud/template/news/form_errors.phtml (rev 0)
+++ 3.x/examples/crud/template/news/form_errors.phtml 2008-01-24 09:12:50 UTC (rev 6736)
@@ -0,0 +1,7 @@
+{{form:errors to='$form_errors'/}}
+
+{{list using='$form_errors'}}
+{{list:item}}
+ <p>{$item.message}</p>
+{{/list:item}}
+{{/list}}
Added: 3.x/examples/crud/template/news/form_fields.phtml
===================================================================
--- 3.x/examples/crud/template/news/form_fields.phtml (rev 0)
+++ 3.x/examples/crud/template/news/form_fields.phtml 2008-01-24 09:12:50 UTC (rev 6736)
@@ -0,0 +1,12 @@
+<label for="title">Title</label> :<br/>
+{{input name='title' type='text' title='Title'/}}<br/>
+
+<label for="date">Date</label> :<br/>
+{{input name='date' type='text' title='Date'/}}<br/>
+
+<label for="annotation">Annotation</label> :<br/>
+{{textarea name='annotation' rows='2' title='Annotation'}}{{/textarea}}<br/>
+
+<label for="content">Content</label> :<br/>
+{{textarea name='content' rows='5'/}}<br/>
+
Modified: 3.x/examples/crud/template/page.html
===================================================================
--- 3.x/examples/crud/template/page.html 2008-01-23 14:07:39 UTC (rev 6735)
+++ 3.x/examples/crud/template/page.html 2008-01-24 09:12:50 UTC (rev 6736)
@@ -1,6 +1,6 @@
<html>
<head>
- <title>Limb3 tutorial</title>
+ <title>Limb3 tutorial on WACT</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<base href="{$'LIMB_HTTP_BASE_PATH'|const}" />
<link href="design.css" type="text/css" rel="stylesheet" />
Added: 3.x/examples/crud/template/page.phtml
===================================================================
--- 3.x/examples/crud/template/page.phtml (rev 0)
+++ 3.x/examples/crud/template/page.phtml 2008-01-24 09:12:50 UTC (rev 6736)
@@ -0,0 +1,12 @@
+<html>
+<head>
+ <title>Limb3 tutorial on MACRO</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <base href="<?=LIMB_HTTP_BASE_PATH?>" />
+ <link href="design.css" type="text/css" rel="stylesheet" />
+ <link rel="alternate" type="application/rss+xml" title="Recent News" href="/last-news-feed-on-macro.php" />
+</head>
+<body>
+ {{slot id="page_placeholder"/}}
+</body>
+</html>
Modified: 3.x/examples/crud/template/pager.html
===================================================================
--- 3.x/examples/crud/template/pager.html 2008-01-23 14:07:39 UTC (rev 6735)
+++ 3.x/examples/crud/template/pager.html 2008-01-24 09:12:50 UTC (rev 6736)
@@ -1,4 +1,4 @@
-<pager:NAVIGATOR id="pager" items="5">
+<pager:NAVIGATOR id="pager" items="3">
Shown: from <b>{$BeginItemNumber}</b> to <b>{$EndItemNumber}</b>
Added: 3.x/examples/crud/template/pager.phtml
===================================================================
--- 3.x/examples/crud/template/pager.phtml (rev 0)
+++ 3.x/examples/crud/template/pager.phtml 2008-01-24 09:12:50 UTC (rev 6736)
@@ -0,0 +1,25 @@
+{{pager id="pager" items="4"}}
+
+Shown: from <b>{$begin_item_number}</b> to <b>{$end_item_number}</b>
+
+
+{{pager:first}}<a href="{$href}" title="First page"><<</a>{{/pager:first}}
+
+{{pager:prev}}<a href="{$href}" title="Previous page"><</a>{{/pager:prev}}
+
+{{pager:list}}
+
+ {{pager:current}} <b>[ {$number} ]</b> {{/pager:current}}
+ {{pager:number}}<a href="{$href}"> {$number} </a>{{/pager:number}}
+
+{{/pager:list}}
+
+
+{{pager:next}}<a href="{$href}" title="Next page">></a>{{/pager:next}}
+
+{{pager:last}}<a href="{$href}" title="Last page">>></a>{{/pager:last}}
+
+
+Total: <b>{$total_items}</b>
+{{/pager}}
+
Added: 3.x/examples/crud/template/rss/macro_last_news.rss
===================================================================
--- 3.x/examples/crud/template/rss/macro_last_news.rss (rev 0)
+++ 3.x/examples/crud/template/rss/macro_last_news.rss 2008-01-24 09:12:50 UTC (rev 6736)
@@ -0,0 +1,25 @@
+<!--l version="1.0" encoding="utf-8"-->
+<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent">]>
+<? echo "<rss version='0.92' xml:base='http://". $_SERVER['HTTP_HOST']."'>"; ?>
+
+<channel>
+ <title>YourDomain.com last news</title>
+ <language>en</language>
+
+{{list using='$#last_news'}}
+ {{list:item}}
+ <item>
+ <title>{$item.title}</title>
+ <linka>{$item.path}</linka>
+ <description>
+ {$item.annotation}
+ </description>
+ <pubDate>
+ {$item.date}
+ </pubDate>
+ </item>
+ {{/list:item}}
+{{/list}}
+</channel>
+
+<? echo "</rss>"; ?>
\ No newline at end of file
Property changes on: 3.x/examples/crud/var
___________________________________________________________________
Name: svn:ignore
+ *
Added: 3.x/examples/crud/www/last-news-feed-on-macro.php
===================================================================
--- 3.x/examples/crud/www/last-news-feed-on-macro.php (rev 0)
+++ 3.x/examples/crud/www/last-news-feed-on-macro.php 2008-01-24 09:12:50 UTC (rev 6736)
@@ -0,0 +1,25 @@
+<?php
+require_once('../setup.php');
+require_once('limb/view/src/lmbMacroView.class.php');
+require_once('src/model/News.class.php');
+
+$view = new lmbMacroView('rss/macro_last_news.rss');
+$view->set('last_news', getNewsDataSetWithFullPaths());
+
+header("Content-Type: application/xml");
+
+echo $view->render();
+
+/*-------------------------------------------------------*/
+
+function getNewsDataSetWithFullPaths()
+{
+ $news_arr = lmbActiveRecord :: find('News')->sort(array('date' => 'DESC', 'title' => 'ASC'))->paginate(0, 5)->getArray();
+
+ foreach($news_arr as $key => $news)
+ $news_arr[$key]['path'] = 'http://' . $_SERVER['HTTP_HOST'] . '/news/detail/' . $news->getId();
+
+ return $news_arr;
+}
+
+?>
\ No newline at end of file
More information about the limb-svn
mailing list