<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html > < head > <? php echo html::stylesheet ( array ( 'assets/css/style' ), array ( 'screen' ), FALSE ); ? > < title > CD COLLECTION </ title > </ head > < body > <!-- BEGIN NAVIGATION MENU --> < ul id ="navigation" > < li ><? =html::anchor('album', 'Albums')? ></ li > </ ul > <!-- END NAVIGATION MENU --> <? =$content? > </ body > </ html > * This source code was highlighted with Source Code Highlighter .
* This source code was highlighted with Source Code Highlighter .
- #navigation {
- overflow: hidden;
- list-style-type: none;
- }
- #navigation li {
- float: left;
- margin-left: 0.5em;
- border: 1px solid black;
- }
- #navigation li a {
- font-size: 14px;
- display: block;
- padding: 2px 5px;
- text-decoration: none;
- color: #fff;
- background: # 666;
- }
* This source code was highlighted with Source Code Highlighter .
- <? php defined ( 'SYSPATH' ) or die ( 'No direct script access.' );
- echo html :: image ( 'assets / images / add.png' );
- echo html :: anchor ( 'album / show_create_editor' , 'Add new album' );
- ? >
- < table class = "list" cellspacing = "0" >
- < tr >
- < td colspan = "5" class = "list_title" > CD Collection </ td >
- </ tr >
- < tr >
- < td class = "headers" > Album name </ td >
- < td class = "headers" > Author </ td >
- < td colspan = '3' class = "headers" > Genre </ td >
- </ tr >
- <? php
- foreach ($ albums_list as $ item )
- {
- echo " < tr > ";
- echo " < td class = 'item' > ". $ item- > name. " </ td > ";
- echo " < td class = 'item' > ". $ item- > author. " </ td > ";
- echo " < td class = 'item' > ". $ item- > genre- > name. " </ td > ";
- echo " < td class = 'item' > " .html :: anchor ('album / delete /'.$ item- > id, html :: image (' assets / images / delete.png ')). " </ td > ";
- echo " < td class = 'item' > " .html :: anchor ('album / show_update_editor /'.$ item- > id, html :: image (' assets / images / edit.png ')). " </ td > ";
- echo " </ tr > ";
- }
- ? >
- </ table >
* This source code was highlighted with Source Code Highlighter .
- // now our controller is a descendant of Template_Controller!
- class Album_Controller extends Template_Controller
- {
- // set the basic template
- public $ template = 'index';
- ...
- private function show_albums_list ()
- {
- $ albums_list = $ this- > album_model- > get_list ();
- $ this- > template- > content = View :: factory ('list')
- - > set ('albums_list', $ albums_list);
- }
- ...
You can use several methods to set the value of variables in a template. The set () method is useful in the case of sequential manipulations on an object; in this case, such a chain of calls is obtained. Assigning values ​​directly ( $ this-> template-> content = ... ) does the same, but reads more pleasantly (IMHO).
* This source code was highlighted with Source Code Highlighter .
- / **
- * Name of the front controller for this application. Default: index.php
- *
- * This can be removed by using URL rewriting.
- * /
- $ config ['index_file'] = '';
// config / routes.php $ config ['_ default'] = 'album';
* This source code was highlighted with Source Code Highlighter .
- public function read ($ id)
- {
- $ this- > db- > where ('id', $ id);
- $ query = $ this- > db- > get ($ this- > album_table);
- return $ query- > result_array ();
- }
* This source code was highlighted with Source Code Highlighter .
- public function read ($ id)
- {
- return $ this- > db
- - > where ('id', $ id)
- - > get ($ this- > album_table)
- - > current ();
- }
* This source code was highlighted with Source Code Highlighter .
- public function show_update_editor ($ id)
- {
- $ album_data = $ this- > album_model- > read ($ id);
- if (FALSE === $ album_data)
- Event :: run ('system.404');
- $ this- > template- > content = View :: factory ('update')
- - > set ('album', $ album_data)
- - > set ('genres_list', $ this- > get_genres_list ());
- }
* This source code was highlighted with Source Code Highlighter .
- <? php echo form :: open ( 'album / update' ); ? >
- < table class = 'editor' >
- < tr >
- < td colspan = '2' class = 'editor_title' > Update album </ td >
- </ tr >
- <? php
- echo " < tr > ";
- echo " < td > " .form :: label ('name', 'Name:'). " </ td > ";
- echo " < td > " .form :: input ('name', $ album- > name). " </ td > ";
- echo " </ tr > ";
- echo " < tr > ";
- echo " < td > " .form :: label ('author', 'Author:'). " </ td > ";
- echo " < td > " .form :: input ('author', $ album- > author). " </ td > ";
- echo " < tr /> ";
- echo " < tr > ";
- echo " < td > " .form :: label ('genre', 'Genre:'). " </ td > ";
- echo " < td > " .form :: dropdown ('genre_id', $ genres_list, $ album- > genre_id). " </ td > ";
- echo " < tr /> ";
- echo " < tr > ";
- echo " < td colspan = '2' align = 'left' > " .form :: submit ('submit', 'Update album'). " </ td > ";
- echo " </ tr > ";
- ? >
- </ table >
- <? php
- echo form :: hidden ( 'album_id' , $ album- > id);
- echo form :: close ();
- ? >
* This source code was highlighted with Source Code Highlighter .
- class Album_Model extends ORM
- {
- protected $ belongs_to = array ('genre');
- }
- class Genre_Model extends ORM {
- protected $ has_many = array ('albums');
- }
* This source code was highlighted with Source Code Highlighter .
- private function show_albums_list ()
- {
- $ albums_list = ORM :: factory ('album') - > with ('genre') - > find_all ();
- $ this- > template- > content = View :: factory ('list')
- - > set ('albums_list', $ albums_list);
- }
In fact, if we comment out the method call with () , everything will still work! The ORM implemented lazy loading ( lazy loading ), so when you try to access the $ album-> genre property, a database query will be made. It is simply better to do one join than to make additional selections of genres in a loop. If you do not want to manually select genres with albums each time, add the following line to Album_Model :protected $ load_with = array ('genre');
After that, genres will be loaded with albums automatically.
* This source code was highlighted with Source Code Highlighter .
- private function get_genres_list ()
- {
- $ db_genres_list = $ this- > genre_model- > get_list ();
- $ genres_list = array ();
- if (sizeof ($ db_genres_list) > = 1)
- {
- foreach ($ db_genres_list as $ item)
- {
- $ genres_list [$ item- > id] = $ item- > name;
- }
- }
- return $ genres_list;
- }
* This source code was highlighted with Source Code Highlighter .
- private function get_genres_list ()
- {
- return ORM :: factory ('genre') - > find_all () - > select_list ('id', 'name');
- }
* This source code was highlighted with Source Code Highlighter .
- public function Validate (array & $ array, $ save = FALSE)
- {
- $ array = Validation :: factory ($ array)
- - > pre_filter ('trim')
- - > add_rules ('name', 'required')
- - > add_rules ('author', 'required')
- - > add_rules ('genre_id', 'required')
- - > add_callbacks ('name', array ($ this, '_album_available'));
- return parent :: validate ($ array, $ save);
- }
- public function _album_available (Validation $ array, $ field) {
- $ result = (bool)! $ this- > db
- - > where (array ('name' = > $ array ['name'], 'author' = > $ array ['author'], 'id! =' = > $ this- > id))
- - > count_records ($ this- > table_name);
- if (! $ result) $ array- > add_error ($ field, 'album_exists');
- return $ result;
- }
* This source code was highlighted with Source Code Highlighter .
- public function create ()
- {
- if ($ this- > input- > post ())
- {
- $ data = array
- (
- 'name' = > NULL,
- 'author' = > NULL,
- 'genre_id' = > NULL
- );
- $ data = arr :: overwrite ($ data, $ this- > input- > post ());
- $ album = ORM :: factory ('album');
- if ($ album- > validate ($ data, TRUE)) {
- url :: redirect ('album');
- }
- else {
- Session :: instance () - > set ('errors', $ data- > errors ('album'));
- Session :: instance () - > set ('data', $ data- > as_array ());
- }
- }
- url :: redirect ('album / show_create_editor');
- }
* This source code was highlighted with Source Code Highlighter .
- public function show_create_editor ()
- {
- $ errors = Session :: instance () - > get_once ('errors', array ());
- $ data = array ('name' = > '', 'author' = > '', 'genre_id' = > '');
- $ data = arr :: overwrite ($ data, Session :: instance () - > get_once ('data', array ()));
- $ genres_list = $ this- > get_genres_list ();
- $ this- > template- > content = View :: factory ('create')
- - > set ('genres_list', $ genres_list)
- - > set ('errors', $ errors)
- - > set ('data', $ data);
- }
* This source code was highlighted with Source Code Highlighter .
- <? php echo form :: open ( 'album / create' ); ? >
- <? php foreach ($ errors as $ error )
- echo " < div class = 'error' > ". $ error. " </ div > ";? >
- < table class = 'editor' >
- < tr >
- < td colspan = '2' class = 'editor_title' > Create new album </ td >
- </ tr >
- <? php
- echo " < tr > ";
- echo " < td > " .form :: label ('name', 'Name:'). " </ td > ";
- echo " < td > " .form :: input ('name', $ data ['name']). " </ td > ";
- echo " </ tr > ";
- echo " < tr > ";
- echo " < td > " .form :: label ('author', 'Author:'). " </ td > ";
- echo " < td > " .form :: input ('author', $ data ['author']). " </ td > ";
- echo " < tr /> ";
- echo " < tr > ";
- echo " < td > " .form :: label ('genre', 'Genre:'). " </ td > ";
- echo " < td > " .form :: dropdown ('genre_id', $ genres_list, $ data ['genre_id']). " </ td > ";
- echo " < tr /> ";
- echo " < tr > ";
- echo " < td colspan = '2' align = 'left' > " .form :: submit ('submit', 'Create album'). " </ td > ";
- echo " </ tr > ";
- ? >
- </ table >
- <? php echo form :: close (); ? >
* This source code was highlighted with Source Code Highlighter .
- // file i18n / ru_RU / album.php
- <? php defined ( 'SYSPATH' ) or die ( 'No direct script access.' );
- $ lang = array
- (
- 'name' = > array (
- 'required' = > 'Album name not specified',
- 'album_exists' = > 'Combination album + artist has already been added',
- ),
- 'author' = > array
- (
- 'required' = > 'Artist name not specified',
- ),
- 'genre_id' = > array
- (
- 'required' = > 'No genre of album selected',
- ),
- );
* This source code was highlighted with Source Code Highlighter .
- // file i18n / en_US / album.php
- <? php defined ( 'SYSPATH' ) or die ( 'No direct script access.' );
- $ lang = array
- (
- 'name' = > array (
- 'required' = > 'Album name required',
- 'album_exists' = > 'Album & artist combination already exists',
- ),
- 'author' = > array
- (
- 'required' = > 'Author name required',
- ),
- 'genre_id' = > array
- (
- 'required' = > 'Genre required',
- ),
- );
* This source code was highlighted with Source Code Highlighter .
- <? php defined ('SYSPATH') OR die ('No direct access allowed.');
- / **
- * @package Core
- *
- * Default language locale name (s).
- * First item must be a valid i18n directory name, subsequent items are alternative locales
- * for OS's that don't support the first (eg Windows). The first valid locale in the array will be used.
- * @see php.net/setlocale
- * /
- $ config ['language'] = array ('en_US', 'Russian_Russia');
- / **
- * Locale timezone. Defaults to use the server timezone.
- * @see php.net/timezones
- * /
- $ config ['timezone'] = '';
Source: https://habr.com/ru/post/64084/
All Articles