28 | This is a tool to create documentation from DocComments in the WebFramework sourcecode.
29 | We use it to automate and speed up things - and it will constantly remind us of missing documentation.
30 | It will create a bunch of cross-linked markdown files that we push to the WebFramework.wiki repository
31 | thus using the standard GitHub mechanism for our documentation.
32 |
33 |
=$run?>
--------------------------------------------------------------------------------
/web/logs/.htaccess:
--------------------------------------------------------------------------------
1 | Deny from all
2 |
--------------------------------------------------------------------------------
/web/sample_blog/.htaccess:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------------------
2 | # Scavix Web Development Framework
3 | #
4 | # Copyright (c) since 2012 Scavix Software Ltd. & Co. KG
5 | #
6 | # This library is free software; you can redistribute it
7 | # and/or modify it under the terms of the GNU Lesser General
8 | # Public License as published by the Free Software Foundation;
9 | # either version 3 of the License, or (at your option) any
10 | # later version.
11 | #
12 | # This library is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # Lesser General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Lesser General Public
18 | # License along with this library. If not, see
19 | #
20 | # @author Scavix Software Ltd. & Co. KG http://www.scavix.com
21 | # @copyright since 2012 Scavix Software Ltd. & Co. KG
22 | # @license http://www.opensource.org/licenses/lgpl-license.php LGPL
23 | # ----------------------------------------------------------------------------------------
24 |
25 | RewriteEngine On
26 |
27 | # redirect NoCache files to the real ones
28 | SetEnv WDF_FEATURES_NOCACHE on
29 | RewriteRule (.*)/nc([0-9]+)/(.*) $1/$3?_nc=$2 [L,QSA]
30 |
31 | # redirect inexistant requests to index.php
32 | SetEnv WDF_FEATURES_REWRITE on
33 | RewriteCond %{REQUEST_FILENAME} !-f
34 | RewriteCond %{REQUEST_FILENAME} !-d
35 | RewriteCond %{REQUEST_URI} !index.php
36 | RewriteRule (.*) index.php?wdf_route=$1 [L,QSA]
37 |
--------------------------------------------------------------------------------
/web/sample_blog/README.md:
--------------------------------------------------------------------------------
1 | Blog sample
2 | ===========
3 |
4 | This is the sample code used in the article describing the WebFramework basics:
5 | [Ultra-Rapid PHP Application Development](http://www.codeproject.com/Articles/553018/Ultra-Rapid-PHP-Application-Development)
6 |
--------------------------------------------------------------------------------
/web/sample_blog/config.php:
--------------------------------------------------------------------------------
1 |
20 | *
21 | * @author Scavix Software Ltd. & Co. KG http://www.scavix.com
22 | * @copyright since 2012 Scavix Software Ltd. & Co. KG
23 | * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
24 | */
25 |
26 | // Pages are PHP classes extending HtmlPage
27 | $CONFIG['system']['default_page'] = "Blog";
28 | // Events are mapped to PHP class methods
29 | $CONFIG['system']['default_event'] = "Index";
30 |
31 | // Application specific classpath
32 | classpath_add(__DIR__.'/controller');
33 | classpath_add(__DIR__.'/templates');
34 |
35 | // Database connection, a DSN passed to the PDO constructor
36 | $CONFIG['model']['system']['connection_string'] = "sqlite:../blog.db";
37 | $CONFIG['model']['system']['default'] = true;
38 |
39 | // Logger Config
40 | ini_set("error_log", __DIR__.'/../logs/blog_php_error.log');
41 | $CONFIG['system']['logging'] = array
42 | (
43 | 'human_readable' => array
44 | (
45 | 'path' => __DIR__.'/../logs/',
46 | 'filename_pattern' => 'blog_wdf.log',
47 | 'log_severity' => true,
48 | 'max_filesize' => 10*1024*1024,
49 | 'keep_for_days' => 5,
50 | 'max_trace_depth' => 16,
51 | ),
52 | 'full_trace' => array
53 | (
54 | 'class' => 'TraceLogger',
55 | 'path' => __DIR__.'/../logs/',
56 | 'filename_pattern' => 'blog_wdf.trace',
57 | 'log_severity' => true,
58 | 'max_trace_depth' => 10,
59 | 'max_filesize' => 10*1024*1024,
60 | 'keep_for_days' => 4,
61 | ),
62 | );
63 |
64 | // Resources config
65 | $CONFIG['resources'][] = array
66 | (
67 | 'ext' => 'js|css|less|png|jpg|jpeg|gif|htc|ico',
68 | 'path' => realpath(__DIR__.'/res/'),
69 | 'url' => 'res/',
70 | 'append_nc' => true,
71 | );
72 | // If you put WDF into a separate folder next to the app (like here), that folder must be externaly accessible.
73 | // So maybe you'll have to set up a subdomain for it and set that to 'resources_system_url_root'.
74 | // For now we just rely on the built in router that will output the resource contents via readfile().
75 | $CONFIG['resources_system_url_root'] = false;
76 | //$CONFIG['resources_system_url_root'] = 'http://wdf.domain.com/'; // <- sample
77 |
78 | // some essentials
79 | $CONFIG['system']['modules'] = array();
80 | date_default_timezone_set("Europe/Berlin");
81 |
--------------------------------------------------------------------------------
/web/sample_blog/controller/blog.class.php:
--------------------------------------------------------------------------------
1 |
20 | *
21 | * @author Scavix Software Ltd. & Co. KG http://www.scavix.com
22 | * @copyright since 2012 Scavix Software Ltd. & Co. KG
23 | * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
24 | */
25 |
26 | use ScavixWDF\Base\HtmlPage;
27 | use ScavixWDF\Base\Template;
28 | use ScavixWDF\Controls\Anchor;
29 |
30 | class Blog extends HtmlPage
31 | {
32 | function __construct()
33 | {
34 | parent::__construct();
35 | $ds = model_datasource('system');
36 | $ds->ExecuteSql("CREATE TABLE IF NOT EXISTS blog(id INTEGER,title VARCHAR(50),body TEXT,PRIMARY KEY(id))");
37 |
38 | $this->content(new Anchor( buildQuery('blog','newpost'), 'New post' ));
39 | }
40 |
41 | function Index()
42 | {
43 | $ds = model_datasource('system');
44 | foreach( $ds->Query('blog')->orderBy('id','desc') as $post )
45 | {
46 | $tpl = Template::Make('post')
47 | ->set('title',$post->title)
48 | ->set('body',$post->body);
49 | $this->content($tpl);
50 | }
51 | }
52 |
53 | function NewPost()
54 | {
55 | log_debug("New Post");
56 | $this->content( Template::Make('newpostform') );
57 | }
58 |
59 | /**
60 | * @attribute[RequestParam('title','string')]
61 | * @attribute[RequestParam('body','string')]
62 | */
63 | function AddPost($title,$body)
64 | {
65 | log_debug("Add Post");
66 | $ds = model_datasource('system');
67 | $ds->ExecuteSql("INSERT INTO blog(title,body)VALUES(?,?)",array($title,$body));
68 | redirect('blog','index');
69 | }
70 | }
--------------------------------------------------------------------------------
/web/sample_blog/index.php:
--------------------------------------------------------------------------------
1 |
20 | *
21 | * @author Scavix Software Ltd. & Co. KG http://www.scavix.com
22 | * @copyright since 2012 Scavix Software Ltd. & Co. KG
23 | * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
24 | */
25 | require_once(__DIR__."/../system/system.php");
26 |
27 | switchToDev();
28 | system_init('blog');
29 |
30 | if( isset($_GET['clear']) )
31 | {
32 | cache_clear();
33 | $_SESSION = array();
34 | }
35 |
36 | system_execute();
37 |
--------------------------------------------------------------------------------
/web/sample_blog/res/blog.less:
--------------------------------------------------------------------------------
1 | /**
2 | * Scavix Web Development Framework
3 | *
4 | * Copyright (c) since 2024 Scavix Software GmbH & Co. KG
5 | *
6 | * This library is free software; you can redistribute it
7 | * and/or modify it under the terms of the GNU Lesser General
8 | * Public License as published by the Free Software Foundation;
9 | * either version 3 of the License, or (at your option) any
10 | * later version.
11 | *
12 | * This library is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public
18 | * License along with this library. If not, see
19 | *
20 | * @author Scavix Software GmbH & Co. KG https://www.scavix.com
21 | * @copyright since 2024 Scavix Software GmbH & Co. KG
22 | * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
23 | */
24 | body
25 | {
26 | padding: 1em 25%;
27 |
28 | h1
29 | {
30 | color: red;
31 | }
32 |
33 | p
34 | {
35 | color: black;
36 | border-bottom: 1px dotted black;
37 | padding: 0 1em 1em 1em;
38 | }
39 |
40 | form
41 | {
42 | display: flex;
43 | flex-direction: column;
44 |
45 | > div
46 | {
47 | display: flex;
48 |
49 | span
50 | {
51 | flex: 1;
52 | min-width: 150px;
53 | }
54 | input, textarea
55 | {
56 | flex: 5;
57 | }
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/web/sample_blog/templates/newpostform.tpl.php:
--------------------------------------------------------------------------------
1 |
20 | *
21 | * @author Scavix Software Ltd. & Co. KG http://www.scavix.com
22 | * @copyright since 2012 Scavix Software Ltd. & Co. KG
23 | * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
24 | */
25 | ?>
26 |
--------------------------------------------------------------------------------
/web/sample_blog/templates/post.tpl.php:
--------------------------------------------------------------------------------
1 |
20 | *
21 | * @author Scavix Software Ltd. & Co. KG http://www.scavix.com
22 | * @copyright since 2012 Scavix Software Ltd. & Co. KG
23 | * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
24 | */
25 | ?>
26 |
=$title?>
27 |
=$body?>
--------------------------------------------------------------------------------
/web/sample_charts/.htaccess:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------------------
2 | # Scavix Web Development Framework
3 | #
4 | # Copyright (c) since 2012 Scavix Software Ltd. & Co. KG
5 | #
6 | # This library is free software; you can redistribute it
7 | # and/or modify it under the terms of the GNU Lesser General
8 | # Public License as published by the Free Software Foundation;
9 | # either version 3 of the License, or (at your option) any
10 | # later version.
11 | #
12 | # This library is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # Lesser General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Lesser General Public
18 | # License along with this library. If not, see
19 | #
20 | # @author Scavix Software Ltd. & Co. KG http://www.scavix.com
21 | # @copyright since 2012 Scavix Software Ltd. & Co. KG
22 | # @license http://www.opensource.org/licenses/lgpl-license.php LGPL
23 | # ----------------------------------------------------------------------------------------
24 |
25 | RewriteEngine On
26 |
27 | # redirect NoCache files to the real ones
28 | SetEnv WDF_FEATURES_NOCACHE on
29 | RewriteRule (.*)/nc([0-9]+)/(.*) $1/$3?_nc=$2 [L,QSA]
30 |
31 | # redirect inexistant requests to index.php
32 | SetEnv WDF_FEATURES_REWRITE on
33 | RewriteCond %{REQUEST_FILENAME} !-f
34 | RewriteCond %{REQUEST_FILENAME} !-d
35 | RewriteCond %{REQUEST_URI} !index.php
36 | RewriteRule (.*) index.php?wdf_route=$1 [L,QSA]
37 |
--------------------------------------------------------------------------------
/web/sample_charts/README.md:
--------------------------------------------------------------------------------
1 | Chart sample
2 | ============
3 |
4 | This is a sample on how to use the charts provided by the WebFramework in your web application.
5 |
--------------------------------------------------------------------------------
/web/sample_charts/config.php:
--------------------------------------------------------------------------------
1 |
20 | *
21 | * @author Scavix Software Ltd. & Co. KG http://www.scavix.com
22 | * @copyright since 2012 Scavix Software Ltd. & Co. KG
23 | * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
24 | */
25 |
26 | // Pages are PHP classes extending HtmlPage
27 | $CONFIG['system']['default_page'] = "ChartRoulette";
28 | // Events are mapped to PHP class methods
29 | $CONFIG['system']['default_event'] = "Index";
30 |
31 | // Application specific classpath
32 | classpath_add(__DIR__.'/controller');
33 |
34 | // Database connection, a DSN passed to the PDO constructor
35 | $CONFIG['model']['system']['connection_string'] = "sqlite:../chartroulette.db";
36 | $CONFIG['model']['system']['default'] = true;
37 | $GLOBALS['CREATE_DATA'] = !file_exists("../chartroulette.db");
38 |
39 |
40 | // Logger Config
41 | ini_set("error_log", __DIR__.'/../logs/chartroulette_php_error.log');
42 | $CONFIG['system']['logging'] = array
43 | (
44 | 'human_readable' => array
45 | (
46 | 'path' => __DIR__.'/../logs/',
47 | 'filename_pattern' => 'chartroulette_wdf.log',
48 | 'log_severity' => true,
49 | 'max_filesize' => 10*1024*1024,
50 | 'keep_for_days' => 5,
51 | 'max_trace_depth' => 16,
52 | ),
53 | 'full_trace' => array
54 | (
55 | 'class' => 'TraceLogger',
56 | 'path' => __DIR__.'/../logs/',
57 | 'filename_pattern' => 'chartroulette_wdf.trace',
58 | 'log_severity' => true,
59 | 'max_trace_depth' => 10,
60 | 'max_filesize' => 10*1024*1024,
61 | 'keep_for_days' => 4,
62 | ),
63 | );
64 |
65 | // Resources config
66 | $CONFIG['resources'][] = array
67 | (
68 | 'ext' => 'js|css|png|jpg|jpeg|gif|htc|ico',
69 | 'path' => realpath(__DIR__.'/res/'),
70 | 'url' => 'res/',
71 | 'append_nc' => true,
72 | );
73 | // If you put WDF into a separate folder next to the app (like here), that folder must be externaly accessible.
74 | // So maybe you'll have to set up a subdomain for it and set that to 'resources_system_url_root'.
75 | // For now we just rely on the built in router that will output the resource contents via readfile().
76 | $CONFIG['resources_system_url_root'] = false;
77 | //$CONFIG['resources_system_url_root'] = 'http://chartroulette.if.it.is.free.com/'; // <- sample
78 |
79 | // some essentials
80 | $CONFIG['system']['modules'] = array();
81 | date_default_timezone_set("Europe/Berlin");
82 |
--------------------------------------------------------------------------------
/web/sample_charts/controller/chartroulette.class.php:
--------------------------------------------------------------------------------
1 |
20 | *
21 | * @author Scavix Software Ltd. & Co. KG http://www.scavix.com
22 | * @copyright since 2012 Scavix Software Ltd. & Co. KG
23 | * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
24 | */
25 |
26 | use ScavixWDF\Base\HtmlPage;
27 | use ScavixWDF\Controls\ChartJS3;
28 | use ScavixWDF\Google\GoogleVisualization;
29 | use ScavixWDF\Google\gvBarChart;
30 | //use ScavixWDF\Google\gvComboChart;
31 | use ScavixWDF\Google\gvGeoChart;
32 | use ScavixWDF\Google\gvPieChart;
33 | use ScavixWDF\JQueryUI\uiTabs;
34 | use ScavixWDF\Localization\Localization;
35 | use ScavixWDF\Model\DataSource;
36 |
37 | class ChartRoulette extends HtmlPage
38 | {
39 | function __construct()
40 | {
41 | parent::__construct();
42 | if( $GLOBALS['CREATE_DATA'] )
43 | {
44 | $ds = model_datasource('system');
45 |
46 | $fn = array('John','Jane','Thomas','Marc','Jamie','Bob','Marie');
47 | $ln = array('Doe','Murphy','Anderson','Smith');
48 | $country_codes = array('DE','US','RU','FR','IT','SE');
49 | $ds->ExecuteSql("CREATE TABLE participants(name VARCHAR(50), country VARCHAR(5),age INTEGER,game_count INTEGER,PRIMARY KEY(name))");
50 | foreach( $fn as $f )
51 | {
52 | foreach( $ln as $l )
53 | {
54 | $cc = $country_codes[rand(0, count($country_codes)-1)];
55 | $ds->ExecuteSql("INSERT INTO participants(name,country,age,game_count)VALUES(?,?,?,?)",array("$f $l",$cc,rand(18,70),rand(0,100)));
56 | }
57 | }
58 |
59 | $nums = array();
60 | $ds->ExecuteSql("CREATE TABLE numbers(number INTEGER,hit_count INTEGER,PRIMARY KEY(number))");
61 | for($i=0; $i<=36; $i++)
62 | {
63 | $nums[$i] = 0;
64 | $ds->ExecuteSql("INSERT INTO numbers(number,hit_count)VALUES(?,?)",array($i,0));
65 | }
66 | for($i=0; $i<9999; $i++)
67 | {
68 | $rnd = rand(0,36);
69 | $nums[$rnd]++;
70 | }
71 | foreach( $nums as $i=>$c )
72 | $ds->ExecuteSql("UPDATE numbers SET hit_count=? WHERE number=?",array($c,$i));
73 | }
74 | GoogleVisualization::$DefaultDatasource = model_datasource('system');
75 | }
76 |
77 | /**
78 | * @attribute[RequestParam('type','string',false)]
79 | * @attribute[RequestParam('data','string',false)]
80 | */
81 | function Index($type,$data)
82 | {
83 | $tabs = new uiTabs();
84 | $tabs->AddTab("Participants by game count", $this->ParticipantsGames());
85 | $tabs->AddTab("Participants by age", $this->ParticipantsAge());
86 | $tabs->AddTab("Participants countries", $this->ParticipantsCountries());
87 |
88 | $this->content($tabs);
89 | }
90 |
91 | function ParticipantsAge()
92 | {
93 | $data = DataSource::Get()->ExecuteSql("SELECT age, count(*) as cnt FROM participants GROUP BY age ORDER BY cnt DESC")
94 | ->Enumerate('cnt', false, 'age');
95 | $labels = array_map(function ($a) { return "$a years";},array_keys($data));
96 | $data = array_combine($labels, array_values($data));
97 | return ChartJS3::Pie("Participants by age", 400)
98 | ->setSeries(['age'=>"Age",'cnt'=>"Count"])
99 | ->setPieData($data);
100 | }
101 |
102 | function ParticipantsGames()
103 | {
104 | $data = DataSource::Get()->ExecuteSql("SELECT name, game_count FROM participants ORDER BY game_count DESC")
105 | ->Enumerate('game_count', false, 'name');
106 | return ChartJS3::Bar("Participants by game count", 400)
107 | ->setPieData($data)
108 | ->legend('display',false)
109 | ->opt('indexAxis','y');
110 | }
111 |
112 | function ParticipantsCountries()
113 | {
114 | $chart = new gvGeoChart();
115 | $chart->setTitle("Participants countries")
116 | ->setDataHeader("Country","Participants")
117 | ->setSize(800, 400)
118 | ->opt('is3D',true);
119 | $country_names = Localization::get_country_names();
120 | foreach( DataSource::Get()->ExecuteSql("SELECT country, count(*) as cnt FROM participants GROUP BY country ORDER BY cnt DESC") as $row )
121 | $chart->addDataRow($country_names[$row['country']],intval($row['cnt']));
122 |
123 | return $chart;
124 | }
125 | }
--------------------------------------------------------------------------------
/web/sample_charts/index.php:
--------------------------------------------------------------------------------
1 |
20 | *
21 | * @author Scavix Software Ltd. & Co. KG http://www.scavix.com
22 | * @copyright since 2012 Scavix Software Ltd. & Co. KG
23 | * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
24 | */
25 | require_once(__DIR__."/../system/system.php");
26 |
27 | switchToDev();
28 | system_init('chartroulette');
29 |
30 | if( isset($_GET['clear']) )
31 | {
32 | cache_clear();
33 | $_SESSION = array();
34 | }
35 |
36 | system_execute();
37 |
--------------------------------------------------------------------------------
/web/sample_shop/.htaccess:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------------------
2 | # Scavix Web Development Framework
3 | #
4 | # Copyright (c) since 2012 Scavix Software Ltd. & Co. KG
5 | #
6 | # This library is free software; you can redistribute it
7 | # and/or modify it under the terms of the GNU Lesser General
8 | # Public License as published by the Free Software Foundation;
9 | # either version 3 of the License, or (at your option) any
10 | # later version.
11 | #
12 | # This library is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | # Lesser General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU Lesser General Public
18 | # License along with this library. If not, see
19 | #
20 | # @author Scavix Software Ltd. & Co. KG http://www.scavix.com
21 | # @copyright since 2012 Scavix Software Ltd. & Co. KG
22 | # @license http://www.opensource.org/licenses/lgpl-license.php LGPL
23 | # ----------------------------------------------------------------------------------------
24 |
25 |
26 | RewriteEngine On
27 |
28 | # redirect NoCache files to the real ones
29 | SetEnv WDF_FEATURES_NOCACHE on
30 | RewriteRule (.*)/nc([0-9]+)/(.*) $1/$3?_nc=$2 [L,QSA]
31 |
32 | # redirect inexistant requests to index.php
33 | SetEnv WDF_FEATURES_REWRITE on
34 | RewriteCond %{REQUEST_FILENAME} !-f
35 | RewriteCond %{REQUEST_FILENAME} !-d
36 | RewriteCond %{REQUEST_URI} !index.php
37 | RewriteRule (.*) index.php?wdf_route=$1 [L,QSA]
38 |
--------------------------------------------------------------------------------
/web/sample_shop/README.md:
--------------------------------------------------------------------------------
1 | Shop sample
2 | ===========
3 |
4 | This is the sample code used in the article describing how to use the WebFramework to
5 | [Easily implementing your own online shop](http://www.codeproject.com/Articles/586703/Easily-implementing-your-own-online-shop)
6 |
--------------------------------------------------------------------------------
/web/sample_shop/config.php:
--------------------------------------------------------------------------------
1 |
20 | *
21 | * @author Scavix Software Ltd. & Co. KG http://www.scavix.com
22 | * @copyright since 2012 Scavix Software Ltd. & Co. KG
23 | * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
24 | */
25 |
26 | // Pages are PHP classes extending HtmlPage
27 | $CONFIG['system']['default_page'] = "Products";
28 | // Events are mapped to PHP class methods
29 | $CONFIG['system']['default_event'] = "Index";
30 |
31 | // Application specific classpath
32 | classpath_add(__DIR__.'/controller');
33 | classpath_add(__DIR__.'/templates');
34 | classpath_add(__DIR__.'/model');
35 |
36 | // Database connection, a DSN passed to the PDO constructor
37 | $CONFIG['model']['system']['connection_string'] = "sqlite:../shop.db";
38 | $CONFIG['model']['system']['default'] = true;
39 |
40 | // Logger Config
41 | ini_set("error_log", __DIR__.'/../logs/shop_php_error.log');
42 | $CONFIG['system']['logging'] = array
43 | (
44 | 'human_readable' => array
45 | (
46 | 'path' => __DIR__.'/../logs/',
47 | 'filename_pattern' => 'shop_wdf.log',
48 | 'log_severity' => true,
49 | 'max_filesize' => 10*1024*1024,
50 | 'keep_for_days' => 5,
51 | 'max_trace_depth' => 16,
52 | ),
53 | 'full_trace' => array
54 | (
55 | 'class' => 'TraceLogger',
56 | 'path' => __DIR__.'/../logs/',
57 | 'filename_pattern' => 'shop_wdf.trace',
58 | 'log_severity' => true,
59 | 'max_trace_depth' => 10,
60 | 'max_filesize' => 10*1024*1024,
61 | 'keep_for_days' => 4,
62 | ),
63 | );
64 |
65 | // Resources config
66 | $CONFIG['resources'][] = array
67 | (
68 | 'ext' => 'js|css|png|jpg|jpeg|gif|htc|ico',
69 | 'path' => realpath(__DIR__.'/res/'),
70 | 'url' => 'res/',
71 | 'append_nc' => true,
72 | );
73 |
74 | // this is products image folder.
75 | // setting it up as resource folder allows us to simply use resFile() to reference a products image.
76 | $CONFIG['resources'][] = array
77 | (
78 | 'ext' => 'png|jpg|jpeg|gif',
79 | 'path' => realpath(__DIR__.'/images/'),
80 | 'url' => 'images/',
81 | 'append_nc' => true,
82 | );
83 |
84 | // some essentials
85 | $CONFIG['system']['modules'] = array('payment');
86 | date_default_timezone_set("Europe/Berlin");
87 |
88 | // configure payment module with your IShopOrder class
89 | $CONFIG["payment"]["order_model"] = 'SampleShopOrder';
90 | // set up Gate2Shop if you want to use it
91 | $CONFIG["payment"]["gate2shop"]["merchant_id"] = '';
92 | $CONFIG["payment"]["gate2shop"]["merchant_site_id"] = '';
93 | $CONFIG["payment"]["gate2shop"]["secret_key"] = '';
94 | // set up PayPal if you want to use it
95 | $CONFIG["payment"]["paypal"]["paypal_id"] = '';
96 | $CONFIG["payment"]["paypal"]["notify_handler"] = array('Basket','Notification');
97 |
98 | // Credentials for the Admin controller. Hardcoding them is okay for now, but they should obviously be stored in DB later.
99 | // Note: never store passwords, but salted password hashes!
100 | $CONFIG["admin"]["username"] = 'admin';
101 | $CONFIG["admin"]["password"] = 'admin';
--------------------------------------------------------------------------------
/web/sample_shop/controller/admin.class.php:
--------------------------------------------------------------------------------
1 |
20 | *
21 | * @author Scavix Software Ltd. & Co. KG http://www.scavix.com
22 | * @copyright since 2012 Scavix Software Ltd. & Co. KG
23 | * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
24 | */
25 | use ScavixWDF\Base\AjaxAction;
26 | use ScavixWDF\Base\AjaxResponse;
27 | use ScavixWDF\Base\Template;
28 | use ScavixWDF\Controls\Form\Form;
29 | use ScavixWDF\JQueryUI\Dialog\uiDialog;
30 | use ScavixWDF\JQueryUI\uiButton;
31 | use ScavixWDF\JQueryUI\uiDatabaseTable;
32 | use ScavixWDF\JQueryUI\uiMessage;
33 |
34 | class Admin extends ShopBase
35 | {
36 | /**
37 | * Checks if aa admin has logged in and redirects to login if not.
38 | */
39 | private function _login()
40 | {
41 | // check only the fact that somebody logged in
42 | if( avail($_SESSION,'logged_in') )
43 | return true;
44 |
45 | // redirect to login. this terminates the script execution.
46 | redirect('Admin','Login');
47 | }
48 |
49 | /**
50 | * @attribute[RequestParam('username','string',false)]
51 | * @attribute[RequestParam('password','string',false)]
52 | */
53 | function Login($username,$password)
54 | {
55 | // if credentials are given, try to log in
56 | if( $username && $password )
57 | {
58 | // see config.php for credentials
59 | if( $username==cfg_get('admin','username') && $password==cfg_get('admin','password') )
60 | {
61 | $_SESSION['logged_in'] = true; // check only the fact that somebody logged in
62 | redirect('Admin');
63 | }
64 | $this->content(uiMessage::Error("Unknown username/passsword"));
65 | }
66 | // putting it together as control here. other ways would be to create a new class
67 | // derived from Control or a Template (anonymous or with an own class)
68 | $form = $this->content(new Form());
69 | $form->content("Username:");
70 | $form->AddText('username', '');
71 | $form->content(" Password:");
72 | $form->AddPassword('password', '');
73 | $form->AddSubmit("Login");
74 | }
75 |
76 | function Index()
77 | {
78 | $this->_login(); // require admin to be logged in
79 |
80 | // add products table and a button to create a new product
81 | $this->content("