Skip to content

Commit a146616

Browse files
committed
review later
1 parent 192cc31 commit a146616

File tree

868 files changed

+470
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

868 files changed

+470
-9
lines changed

.gitignore

100644100755
File mode changed.

.htaccess

100644100755
File mode changed.

Api/Controller.php

100644100755
File mode changed.

Api/Model/Header.php

100644100755
File mode changed.

Api/Model/OpCache.php

100644100755
File mode changed.

Api/index.php

100644100755
File mode changed.

Console/Controller.php

100644100755
File mode changed.

Console/Model/ConvertPassword.php

100644100755
File mode changed.

Console/Model/Newsletter.php

100644100755
File mode changed.

Console/Model/User.php

100644100755
File mode changed.

DotKernel/admin/Admin.php

100644100755
File mode changed.

DotKernel/admin/Article.php

100644100755
File mode changed.

DotKernel/admin/System.php

100644100755
File mode changed.

DotKernel/admin/User.php

100644100755
File mode changed.

DotKernel/admin/View.php

100644100755
File mode changed.

DotKernel/admin/views/AdminView.php

100644100755
File mode changed.

DotKernel/admin/views/ArticleView.php

100644100755
File mode changed.

DotKernel/admin/views/SystemView.php

100644100755
File mode changed.

DotKernel/admin/views/UserView.php

100644100755
File mode changed.

DotKernel/frontend/Article.php

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
3+
class Article extends Dot_Model
4+
{
5+
6+
// get all questions from table "question"
7+
public function getArticleList()
8+
{
9+
$select = $this->db->select()
10+
->from('question');
11+
$result = $this->db->fetchAll($select);
12+
return $result;
13+
}
14+
15+
16+
public function getArticleById($id)
17+
{
18+
// $select from table "question" where id = $id ;
19+
$select = $this->db->select()
20+
->from("question")
21+
->where("id = ?",$id)
22+
23+
;
24+
25+
// store in $result all the data from the database ;
26+
$result = $this->db->fetchAll($select);
27+
28+
// return $result ;
29+
return $result;
30+
}
31+
32+
// add an question , $data is our question we want to add .
33+
public function addArticle($data)
34+
{
35+
// insert a question into the "question" table,with the data we want.
36+
$this->db->insert("question",$data);
37+
}
38+
39+
// post a comment, $data is our comment we want to post .
40+
public function postComment($data)
41+
{
42+
//dataToBeInserted it's an array , we store in it our userId , questionId and content
43+
// insert intro table "comment" our array
44+
$dataToBeInserted = array('userId'=>$data['userId'],'questionId'=>$data['questionId'],'content'=>$data['comment']);
45+
$this->db->insert("comment",$dataToBeInserted);
46+
}
47+
48+
49+
//get all comments from a question by questionId
50+
public function getCommentListByQuestionId($questionId)
51+
{
52+
// select all from table "comment" where questionId is equal to "questionId"
53+
// we want to get all comments from table user where userId = id from table user, we use joinLeft .
54+
$select = $this->db->select()
55+
->from('comment')
56+
->where('questionId = ?', $questionId)
57+
//->where('parent = ?', 0)
58+
->joinLeft("user","comment.userId=user.id",["username"=>"username"])
59+
;
60+
$result = $this->db->fetchAll($select);
61+
return $result;
62+
}
63+
64+
// post a question into table "question" ;
65+
public function postQuestion($data,$userId)
66+
{
67+
$title = $data['title'];
68+
$question=$data['question'];
69+
$dataToBeInserted = array('title'=>$title,'content'=>$question,'userId'=>$userId);
70+
$this->db->insert("question",$dataToBeInserted);
71+
}
72+
73+
public function getReplyListByQuestionId($questionId)
74+
{
75+
//var_dump("ajuns in reply list" . $questionId);
76+
//exit();
77+
$select = $this->db->select()
78+
->from('comment')
79+
->where("parent <> 0");
80+
$result = $this->db->fetchAll($select);
81+
return $result ;
82+
}
83+
84+
public function postReply($questionId,$userId,$reply)
85+
{
86+
$dataToBeInserted = array('id'=>$questionId,'userId'=>$userId,'content'=>$reply,'parent'=>$questionId);
87+
$this->db->insert("comment",$dataToBeInserted);
88+
var_dump($dataToBeInserted);
89+
//exit();
90+
91+
}
92+
93+
94+
}

DotKernel/frontend/Page.php

100644100755
File mode changed.

DotKernel/frontend/User.php

100644100755
File mode changed.

DotKernel/frontend/View.php

100644100755
File mode changed.
+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
<?php
2+
3+
4+
class Article_View extends View
5+
{
6+
7+
8+
public function __construct($tpl)
9+
{
10+
$this->tpl = $tpl;
11+
}
12+
13+
// show a tpl file .
14+
public function showPage($templateFile = '')
15+
{
16+
if ($templateFile != '') $this->templateFile = $templateFile;//in some cases we need to overwrite this variable
17+
$this->tpl->setFile('tpl_main', 'page/' . $this->templateFile . '.tpl');
18+
}
19+
20+
21+
private function _getReplyList($replyList, $commentId)
22+
{
23+
$replies = [];
24+
foreach ($replyList as $reply)
25+
{
26+
if($reply['parent'] == $commentId)
27+
{
28+
$replies[] = $reply;
29+
}
30+
}
31+
return $replies;
32+
}
33+
34+
private function _setData($data, $prefix='')
35+
{
36+
if(!is_array($data))
37+
{
38+
error_log('not an array' . __FILE__ .':'. __LINE__);
39+
return false;
40+
}
41+
foreach($data as $key => $value)
42+
{
43+
$this->tpl->setVar(strtoupper($prefix.$key), $value);
44+
}
45+
return true;
46+
}
47+
// show all questions, we have 2 parameters. The first one stores the name of the tpl file we want to show .
48+
// The second parameter "data" stores the data we want to load into our tpl file in order to be displayed.
49+
public function showAllArticles($templateFile="",$data)
50+
{
51+
// if our tpl file exists set it
52+
if($templateFile !="") $this->templateFile = $templateFile;
53+
$this->tpl->setFile('tpl_main','article/'.$this->templateFile.".tpl");
54+
// in ou tpl file we must have a article_list block, in order to set it .
55+
$this->tpl->setBlock('tpl_main','article_list','article_list_block');
56+
57+
// for each value in our "data" array set to upper the key .
58+
foreach ($data as $key => $value)
59+
{
60+
foreach ($value as $key => $value)
61+
{
62+
$this->tpl->setVar(strtoupper($key),$value);
63+
}
64+
// parse the block with the value "true" in order to repeat it,if we have to .
65+
$this->tpl->parse("article_list_block","article_list",true);
66+
}
67+
}
68+
69+
70+
// show question,we have 4 parameters
71+
// templateFile stores the name of the tpl file .
72+
// data stores the data we want to display
73+
// commentList stores the commentList
74+
// userId stores the userId, if userId it's not equal to NULL we have a user logged.
75+
public function showArticle($templateFile="",$data,$commentList,$replyList, $userId=null)
76+
{
77+
if($templateFile !="") $this->templateFile = $templateFile;
78+
$this->tpl->setFile('tpl_main','article/'.$this->templateFile.".tpl");
79+
$this->tpl->setBlock('tpl_main','comment_form','comment_form_block');
80+
$this->tpl->setBlock('tpl_main','comment_list','comment_list_block');
81+
$this->tpl->setBlock('comment_list','reply_list','reply_list_block');
82+
foreach ($data as $key => $value)
83+
{
84+
foreach ($value as $k => $v)
85+
{
86+
$this->tpl->setVar(strtoupper($k),$v);
87+
}
88+
89+
$this->tpl->parse("comment_form_block","comment_form",true);
90+
}
91+
foreach ($commentList as $comment)
92+
{
93+
$this->_setData($comment,'COMMENT_');
94+
foreach ($comment as $key => $value) {
95+
$this->tpl->setVar(strtoupper('COMMENT_' . $key),$value);
96+
}
97+
$currentReplyList = $this->_getReplyList($replyList, $comment['id']);
98+
99+
//echo "<pre/>";var_dump($comment);exit;
100+
101+
$lastKey = count($currentReplyList)-1 ;
102+
if(empty($currentReplyList))
103+
{
104+
$this->tpl->parse("comment_list_block","comment_list",true);
105+
continue;
106+
}
107+
108+
foreach ($currentReplyList as $key => $reply)
109+
{
110+
$this->_setData($reply,'REPLY_');
111+
//var_dump($currentReplyList);
112+
// foreach ($reply as $key => $value) {
113+
// $this->tpl->setVar(strtoupper('REPLY_' . $key),$value);
114+
// }
115+
$this->tpl->parse("reply_list_block","reply_list",true);
116+
if($key == $lastKey)
117+
{
118+
$this->tpl->parse("comment_list_block","comment_list",true);
119+
$this->tpl->parse("reply_list_block","");
120+
}
121+
}
122+
123+
}
124+
// $this->tpl->parse("comment_list_block","comment_list",true);
125+
126+
127+
128+
}
129+
130+
// set the tpl file and display it .
131+
public function showPostQuestion($templateFile="")
132+
{
133+
if($templateFile !="") $this->templateFile = $templateFile;
134+
$this->tpl->setFile('tpl_main','article/'.$this->templateFile.".tpl");
135+
}
136+
137+
}

DotKernel/frontend/views/PageView.php

100644100755
File mode changed.

DotKernel/frontend/views/UserView.php

100644100755
File mode changed.

DotKernel/mobile/Page.php

100644100755
File mode changed.

DotKernel/mobile/View.php

100644100755
File mode changed.

DotKernel/mobile/views/PageView.php

100644100755
File mode changed.

DotKernel/rss/Sample.php

100644100755
File mode changed.

DotKernel/rss/View.php

100644100755
File mode changed.

DotKernel/rss/views/SampleView.php

100644100755
File mode changed.

README.md

100644100755
File mode changed.

cache/.htaccess

100644100755
File mode changed.

configs/.htaccess

100644100755
File mode changed.

configs/acl/role.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<guest>
1313
<Page>all</Page><!-- allow 'guest' to access 'Page' controller -->
1414
<User>all</User><!-- allow 'guest' to access 'User' controller -->
15-
<Question>all</Question> <!-- allow 'guest' to acces 'Article' controller -->
15+
<Article>all</Article> <!-- allow 'guest' to acces 'Article' controller -->
1616
</guest>
1717
<user>
1818
<User>account</User><!-- allow 'user' to access 'User' controller and also 'account' action-->

configs/admin/menu.xml

100644100755
File mode changed.

configs/dots.xml

100644100755
File mode changed.

configs/dots/admin.xml

100644100755
File mode changed.

configs/dots/article.xml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<config>
3+
<dots>
4+
<variable option="global">
5+
</variable>
6+
<variable option="admin">
7+
<pageTitle>
8+
<action>
9+
<list>TEST</list>
10+
</action>
11+
</pageTitle>
12+
</variable>
13+
<variable option="frontend">
14+
<pageTitle>
15+
<action>
16+
<list>List Articles</list>
17+
</action>
18+
</pageTitle>
19+
</variable>
20+
<variable option="mobile"></variable>
21+
</dots>
22+
</config>

configs/dots/page.xml

100644100755
File mode changed.

configs/dots/sample.xml

100644100755
File mode changed.

configs/dots/seo.xml

100644100755
File mode changed.

configs/dots/system.xml

100644100755
File mode changed.

configs/dots/user.xml

100644100755
File mode changed.

configs/plugins.ini

100644100755
File mode changed.

configs/router.xml

100644100755
+3-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<controllers>
66
<frontend>Page</frontend>
77
<frontend>User</frontend>
8-
<frontend>Question</frontend>
8+
<frontend>Article</frontend>
99
<admin>Admin</admin>
1010
<admin>System</admin>
1111
<admin>User</admin>
@@ -16,17 +16,16 @@
1616
<routes>
1717
<!-- default controllers for modules -->
1818
<controller>
19-
<frontend>Question</frontend>
19+
<frontend>Article</frontend>
2020
<admin>System</admin>
2121
<rss>Sample</rss>
2222
<mobile>Page</mobile>
2323
</controller>
2424
<action>
2525
<!-- default action for controllers ... -->
2626
<frontend>
27-
<Page>home</Page>
27+
<Article>list</Article>
2828
<User>login</User>
29-
<Question>list</Question>
3029
</frontend>
3130
<admin>
3231
<Admin>account</Admin>

configs/useragent/browser.xml

100644100755
File mode changed.

configs/useragent/os.xml

100644100755
File mode changed.

controllers/admin/AdminController.php

100644100755
File mode changed.

controllers/admin/ArticleController.php

100644100755
File mode changed.

controllers/admin/IndexController.php

100644100755
File mode changed.

controllers/admin/SystemController.php

100644100755
File mode changed.

controllers/admin/UserController.php

100644100755
File mode changed.

0 commit comments

Comments
 (0)