From 061a54c58c77a40866be336525abfd0a172d8ca5 Mon Sep 17 00:00:00 2001 From: voltan Date: Sun, 6 Aug 2017 13:39:18 +0430 Subject: [PATCH] Work on ask module --- config/module.php | 4 +- config/navigation.php | 64 ++++++++-- config/page.php | 5 - config/permission.php | 6 - locale/en/admin.mo | Bin 412 -> 412 bytes locale/en/admin.po | 38 ++++-- locale/en/default.mo | Bin 412 -> 412 bytes locale/en/default.po | 89 ++++++------- locale/fa/admin.mo | Bin 2516 -> 2804 bytes locale/fa/admin.po | 24 +++- locale/fa/default.mo | Bin 6985 -> 7024 bytes locale/fa/default.po | 100 ++++++++------- src/Controller/Admin/IndexController.php | 1 + src/Controller/Admin/QuestionController.php | 73 ++++++++--- src/Controller/Admin/ToolsController.php | 24 ---- src/Form/Element/Project.php | 35 ++++++ src/Form/UpdateFilter.php | 55 +++++++- src/Form/UpdateForm.php | 131 +++++++++++++++++++- template/admin/question-index.phtml | 40 +++--- template/admin/question-update.phtml | 22 +++- template/admin/tools-index.phtml | 4 - 21 files changed, 509 insertions(+), 206 deletions(-) delete mode 100644 src/Controller/Admin/ToolsController.php create mode 100644 src/Form/Element/Project.php delete mode 100644 template/admin/tools-index.phtml diff --git a/config/module.php b/config/module.php index bd8673e..2aef3e8 100644 --- a/config/module.php +++ b/config/module.php @@ -14,12 +14,12 @@ 'meta' => array( 'title' => _a('Ask'), 'description' => _a('Ask and Answer'), - 'version' => '0.2.2', + 'version' => '0.2.7', 'license' => 'New BSD', 'logo' => 'image/logo.png', 'readme' => 'docs/readme.txt', 'demo' => 'http://pialog', - 'icon' => 'fa-question', + 'icon' => 'fa-database', 'clonable' => true, ), // Author information diff --git a/config/navigation.php b/config/navigation.php index ae21f30..ff01165 100644 --- a/config/navigation.php +++ b/config/navigation.php @@ -21,6 +21,60 @@ 'module' => 'ask', 'controller' => 'question', 'action' => 'index', + 'params' => array( + 'type' => 'all', + ), + 'pages' => array( + 'all' => array( + 'label' => _a('List of all Questions and Answers'), + 'permission' => array( + 'resource' => 'question', + ), + 'route' => 'admin', + 'module' => 'ask', + 'controller' => 'question', + 'action' => 'index', + 'params' => array( + 'type' => 'all', + ), + ), + 'question' => array( + 'label' => _a('List of just Questions'), + 'permission' => array( + 'resource' => 'question', + ), + 'route' => 'admin', + 'module' => 'ask', + 'controller' => 'question', + 'action' => 'index', + 'params' => array( + 'type' => 'question', + ), + ), + 'answer' => array( + 'label' => _a('List of just Answers'), + 'permission' => array( + 'resource' => 'question', + ), + 'route' => 'admin', + 'module' => 'ask', + 'controller' => 'question', + 'action' => 'index', + 'params' => array( + 'type' => 'answer', + ), + ), + 'update' => array( + 'label' => _a('New question'), + 'permission' => array( + 'resource' => 'question', + ), + 'route' => 'admin', + 'module' => 'ask', + 'controller' => 'question', + 'action' => 'update', + ), + ), ), 'project' => array( 'label' => _a('projects'), @@ -54,15 +108,5 @@ ), ), ), - 'tools' => array( - 'label' => _a('Tools'), - 'permission' => array( - 'resource' => 'tools', - ), - 'route' => 'admin', - 'module' => 'ask', - 'controller' => 'tools', - 'action' => 'index', - ), ), ); \ No newline at end of file diff --git a/config/page.php b/config/page.php index 864ca8f..6493c4e 100644 --- a/config/page.php +++ b/config/page.php @@ -23,11 +23,6 @@ 'controller' => 'project', 'permission' => 'project', ), - array( - 'title' => _a('Tools'), - 'controller' => 'tools', - 'permission' => 'tools', - ), ), // Front section 'front' => array( diff --git a/config/permission.php b/config/permission.php index 5da70eb..6949de0 100755 --- a/config/permission.php +++ b/config/permission.php @@ -47,11 +47,5 @@ //'admin', ), ), - 'tools' => array( - 'title' => _a('Tools'), - 'access' => array( - //'admin', - ), - ), ), ); \ No newline at end of file diff --git a/locale/en/admin.mo b/locale/en/admin.mo index 0c574823a11e1a99435cab36ba38ca30e2ce1e89..a7dd459dbf5b1f1a4531e0074a63a2bc9d3fa6f4 100644 GIT binary patch delta 15 WcmbQkJcoHgE{n01vBkzhZAJhk=>%o~ delta 15 WcmbQkJcoHgE{lJRAG;dzRJpsqpDrCaaM_H2h}cxGPn%rmny^PSmu^*@b_PPAUl+x=|f3;2s>rR?J`n7E%3{k%6{_JMkqt_&V?hYNC2pE1OaM+OQgrBVDWq z>zLpAsA%Pv$_-{isGa3-H{L)tVRumj7m&y9QRw?p(EbQD!75%QiY_Xu309#6^kEwN zQT;Ztf%&aO9gkv7joDs28Q72Y zypN$Gd=qCosVq?0kDHjpSEz};p$7aye$!$!sy#uWiCR$$=)rwBh&(n)p>Z?8`+d{` z9|rGh*v|XYTH>!ze+)W&K_XX93Rz1~??4TxB;AKLax7@jWZD43%XcGaE~AC(*mT5| z#D2;fb!_y{S?WVGS^og-Oi7nbyHg0Y$irlXol`RXIkaOX9g%LlLaL;@qTL=LA0pSe z(Qqs@emkhD0UgR7g3J)D&=%Mp$2|p32GDrEQC?4 z_Z&b?H0C*lg|z1|50{b4R=E}925MuwUV9I<@na0KzMWBFO}jxZyW^%WeZ(L>d;RaI z1-@~dENM_POfZ`^uz}N{aA`4*n%@yjR~y7ebhWxsBvlJvRAMF3pJ19C;wWYib@ssqFx+Ey*TQ%=TRG2 z^4go&M0*F7$`kMTIVv%lQ%9(*(3QzT04pg95@-<$YsNDZYf+umU(`_17wNxH#3))w z=NP5vcp51>HhtOu(9fsMEA*B6hZM?;LYY-GP-^v*EL-MhPmTHl&i0`jNL{;O$L;Ft Y=t;d~M|}R%`-AlQLo&UVTJbM9zX8uf8~^|S diff --git a/locale/fa/admin.po b/locale/fa/admin.po index 8d7de1e..ea81255 100644 --- a/locale/fa/admin.po +++ b/locale/fa/admin.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" -"POT-Creation-Date: 2017-08-06 12:07+0430\n" +"POT-Creation-Date: 2017-08-06 13:36+0430\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -111,16 +111,32 @@ msgstr "سیستم ارسال پرسش و درج پاسخ" msgid "List of Questions" msgstr "فهرست سوالات" -#: config/navigation.php:26 config/navigation.php:36 config/page.php:22 +#: config/navigation.php:29 +msgid "List of all Questions and Answers" +msgstr "فهرست سوالات و پاسخ ها" + +#: config/navigation.php:42 +msgid "List of just Questions" +msgstr "فهرست سوال ها" + +#: config/navigation.php:55 +msgid "List of just Answers" +msgstr "فهرست پاسخ ها" + +#: config/navigation.php:68 +msgid "New question" +msgstr "سوال جدید" + +#: config/navigation.php:80 config/navigation.php:90 config/page.php:22 #: config/permission.php:45 msgid "projects" msgstr "پروژه ها" -#: config/navigation.php:46 +#: config/navigation.php:100 msgid "New project" msgstr "پروژه جدید" -#: config/navigation.php:58 config/page.php:27 config/permission.php:51 +#: config/navigation.php:112 config/page.php:27 config/permission.php:51 msgid "Tools" msgstr "ابزار" diff --git a/locale/fa/default.mo b/locale/fa/default.mo index 82f559d2375aea9c45ad6cc1fc45ead51c64f80b..b6b08829f4c10da08c1042e7ab7c12b25743d28e 100644 GIT binary patch delta 1775 zcmXxkX>5!^9LMoly=a$GUANk1X-X+tyR=GCtvXt?yl}*sN)ay{Nd?Kq3qhQ*Dy7a4 zMM6`XI1;Tiq|p#U6Sj@G5=SBugpd+^f7>zH|MQu7o@eHn`Oougv+uLd{~{r>(op6R z1BhFlj9HJ1qc~99F~$tSWQ@ki*aHh~dm+ZrUT)8?Ll_d!C+Ngan80nO zoeDqGwR8A{aiN=bD)KYaIjBPk_Qs{i98Co>fZ2k2z&`6?)P$;0YpB6Uyo~+vDysiO zOyv3IF%`}Do%J_%r=8HHW2GJ(NZX6CSc;nP64ZUGuq#&B>pQTR_CeIRFR>SXM?Kid zAl)z?(|Nv0qA~=FFax*j#)X6%dGQTJ7&CUDxeZ=h0LZ@q)VXg6aHena&e%|1#W zYD>pE$-hn%(kjIwEWk6k5IV-+T0J*wYxT;VY0wY@$yzGI74V=C7-Aw!rG z*b^_ICfC?--5?Pbkjha|B($8T&uP#y2#9(-h7 z#Kl9j-{Usi!YroX4;+Ts{M%@}GUOdK(}^*}G$MtVK!i`|A?n~Ev||0)DAg=HTr_*1 ztt+K@fum6#ZxOXjLdh&4l-w*LmtcnBGMS@ts(j2PW(K}Q_0P(nHi{@D1`*6Jyv6yb z&-H&{2g7A7M`d_wAV1oZr6sD&BjymPgx=g4gqG_jR3;K$Vl<%_VqD-%bedOxjI)S1 zqLdg(s3^e^gkCKby?X!4q@W|FHX?W-wu>WhEv`Ir{>HKm!GX?Kj>ydHOkdE^?O9B0 nYeT56byr(e>(1aa*GEU7xpy$O?P91VR2RAssta!I^RUxDixsp3 delta 1743 zcmXxkSx8h-9LMo9E@P>=o0er0qqZ1kZaJ2gwwt>Z1O<^)R1X#HP)wn=*;7OGQe;Ju z6qSr95k!e(3Rd*c2JIV24@JF|)b}@YI?Vrm&bjxVbI<7-SX#%qSD z@G~R96DE9=F)rGv$j^8VFrL zc)qz$MKgY8{f2S0Lq-Qznurr=XJRBSKux#?b>Au+gPZL2-B?5W5Nh1VI2J#n9{dMm z@Gs`@d=tZ{nOKTh*o5kE0`;H^=)w+E1_n_N{(y{Oej;-=BdC=+S-!R?3YD3O)(q5y zvXP%D=ipU`YAU+1!MYkX;5rv|7b0Vu zy*L?qo!x`9)n&=Q} zVlOZolSrFh=K084%tq9N_Mz@SjMMNWvU^_B9jur>REnRXQvL(gA(CavWUC96nQYWV z7Nb(R6VUaU$@T#?di>GMc!vomJ zEGqB`PRB(4T{KP^@@|@CL_VR1WfA%kmJoV|?spUEdK>lU;vraYplJ4mwyu;`_&UPf zg;mt@2qm+gP;!fjGJ+Wf%6yI_HIR=wtn@jYX`X6oxx`Xp62bh;B4Qz-t@~ft!9XeE zs0=Ugt#rCQ<-wDI?^G|qR6=j8ik9nAg;Gis5VMF9Vz#f-nH^Y$zT_yPftX3CD8ZqG z{wP)S%Kb0%{P7VtL;VjU9gffy`?vf0qqg{qqTf2g@=9_&{&6wSBmBRUhaJwBM_wL# PaohJPrOSUQbtvQ?>m#55 diff --git a/locale/fa/default.po b/locale/fa/default.po index 1a09acb..42d26e3 100644 --- a/locale/fa/default.po +++ b/locale/fa/default.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" -"POT-Creation-Date: 2017-08-06 12:09+0430\n" +"POT-Creation-Date: 2017-08-06 13:36+0430\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -36,26 +36,26 @@ msgstr "اطلاعات پروژه با موفقیت ذخیره شد" msgid "Add project" msgstr "پروژه جدید" -#: src/Controller/Admin/QuestionController.php:85 +#: src/Controller/Admin/QuestionController.php:98 #, php-format msgid "%s question accept successfully" msgstr "%s با موفقیت تایید شد" -#: src/Controller/Admin/QuestionController.php:90 +#: src/Controller/Admin/QuestionController.php:103 #, php-format msgid "Error in accept %s question" msgstr "خطا در تایید %s" -#: src/Controller/Admin/QuestionController.php:96 -#: src/Controller/Admin/QuestionController.php:185 +#: src/Controller/Admin/QuestionController.php:109 +#: src/Controller/Admin/QuestionController.php:222 msgid "Please select question" msgstr "لطفا یک سوال انتخاب کنید" -#: src/Controller/Admin/QuestionController.php:154 +#: src/Controller/Admin/QuestionController.php:189 msgid "Your selected item edit successfully" msgstr "آیتم انتخابی شما با موفقیت ویرایش شد" -#: src/Controller/Admin/QuestionController.php:183 +#: src/Controller/Admin/QuestionController.php:220 msgid "Your selected question deleted" msgstr "سوال انتخابی شما حذف شد" @@ -77,17 +77,17 @@ msgid "The question not found." msgstr "سوال یافت نشد" #: src/Controller/Front/AnswerController.php:54 -#: src/Controller/Front/AnswerController.php:99 +#: src/Controller/Front/AnswerController.php:101 #, php-format msgid "Answer to %s" msgstr "پاسخ به %s" -#: src/Controller/Front/AnswerController.php:87 +#: src/Controller/Front/AnswerController.php:89 msgid "" "Your new answer to this question save successfully, and show under question" msgstr "پاسخ شما به این پرسش با موفقیت ثبت شد، و در زیر سوال نمایش داده می شود" -#: src/Controller/Front/AnswerController.php:89 +#: src/Controller/Front/AnswerController.php:91 msgid "" "Your new answer to this question save successfully, But it need review and " "publish by website admin" @@ -148,7 +148,7 @@ msgstr "همه سوالات در مورد %s" msgid "List of all used tags" msgstr "فهرست تمام برچسب های استفاده شده" -#: src/Form/AnswerForm.php:49 template/admin/question-index.phtml:32 +#: src/Form/AnswerForm.php:49 template/admin/question-index.phtml:26 #: template/front/question-index.phtml:104 #: template/front/question-index.phtml:108 #: template/front/question-list.phtml:73 @@ -156,43 +156,44 @@ msgid "Answer" msgstr "پاسخ" #: src/Form/AnswerForm.php:63 src/Form/AskForm.php:107 -#: src/Form/ProjectForm.php:180 src/Form/UpdateForm.php:81 +#: src/Form/ProjectForm.php:180 src/Form/UpdateForm.php:202 msgid "Submit" msgstr "ارسال" #: src/Form/AskForm.php:42 src/Form/ProjectForm.php:42 -#: src/Form/UpdateForm.php:42 template/admin/project-index.phtml:8 +#: src/Form/UpdateForm.php:48 template/admin/project-index.phtml:8 #: template/admin/question-index.phtml:15 -#: template/admin/question-update.phtml:3 +#: template/admin/question-update.phtml:5 msgid "Title" msgstr "عنوان" -#: src/Form/AskForm.php:53 src/Form/UpdateForm.php:53 -#: template/admin/question-index.phtml:29 +#: src/Form/AskForm.php:53 src/Form/UpdateForm.php:70 +#: template/admin/question-index.phtml:23 msgid "Question" msgstr "سوال" #: src/Form/AskForm.php:67 src/Form/ProjectForm.php:78 +#: src/Form/UpdateForm.php:84 msgid "Main image" msgstr "تصویر اصلی" -#: src/Form/AskForm.php:94 src/Form/UpdateForm.php:68 +#: src/Form/AskForm.php:94 src/Form/UpdateForm.php:189 msgid "Tags" msgstr "برچسب ها" -#: src/Form/AskForm.php:98 src/Form/UpdateForm.php:72 +#: src/Form/AskForm.php:98 src/Form/UpdateForm.php:193 msgid "Use `|` as delimiter to separate tag terms" msgstr "با استفاده از `|` کلمات را از هم جدا کنید" -#: src/Form/ProjectForm.php:53 +#: src/Form/ProjectForm.php:53 src/Form/UpdateForm.php:59 msgid "slug" msgstr "اسلاگ" -#: src/Form/ProjectForm.php:57 +#: src/Form/ProjectForm.php:57 src/Form/UpdateForm.php:63 msgid "Used on URL value : must be unique, short, and user oriented" msgstr "در آدرس URL صفحه استفاده می شود، باید یکتا، کوتاه و مفید باشد" -#: src/Form/ProjectForm.php:64 template/admin/question-update.phtml:5 +#: src/Form/ProjectForm.php:64 template/admin/question-update.phtml:14 msgid "Description" msgstr "توضیحات" @@ -200,29 +201,29 @@ msgstr "توضیحات" msgid "Additional images" msgstr "تصاویر اضافی" -#: src/Form/ProjectForm.php:104 +#: src/Form/ProjectForm.php:104 src/Form/UpdateForm.php:110 msgid "Status" msgstr "وضعیت" -#: src/Form/ProjectForm.php:106 template/admin/project-index.phtml:34 -#: template/admin/question-index.phtml:62 +#: src/Form/ProjectForm.php:106 src/Form/UpdateForm.php:112 +#: template/admin/project-index.phtml:34 template/admin/question-index.phtml:61 msgid "Published" msgstr "منتشر شده" -#: src/Form/ProjectForm.php:107 template/admin/project-index.phtml:35 -#: template/admin/question-index.phtml:63 +#: src/Form/ProjectForm.php:107 src/Form/UpdateForm.php:113 +#: template/admin/project-index.phtml:35 template/admin/question-index.phtml:62 msgid "Pending review" msgstr "در انتظار تایید" -#: src/Form/ProjectForm.php:108 +#: src/Form/ProjectForm.php:108 src/Form/UpdateForm.php:114 msgid "Draft" msgstr "پیش نویس" -#: src/Form/ProjectForm.php:109 +#: src/Form/ProjectForm.php:109 src/Form/UpdateForm.php:115 msgid "Private" msgstr "خصوصی" -#: src/Form/ProjectForm.php:110 +#: src/Form/ProjectForm.php:110 src/Form/UpdateForm.php:116 msgid "Remove" msgstr "حذف شده" @@ -234,45 +235,49 @@ msgstr "مدیر" msgid "Project manager user id" msgstr "شناسه کاربری مدیر پروژه" -#: src/Form/ProjectForm.php:133 +#: src/Form/ProjectForm.php:133 src/Form/UpdateForm.php:141 msgid "SEO options" msgstr "گزینه های سئو" -#: src/Form/ProjectForm.php:140 +#: src/Form/ProjectForm.php:140 src/Form/UpdateForm.php:148 msgid "Meta Title" msgstr "عنوان متا ( Meta Title )" -#: src/Form/ProjectForm.php:146 +#: src/Form/ProjectForm.php:146 src/Form/UpdateForm.php:154 msgid "" "Displayed in search Engine result pages as Title : between 10 to 70 " "character. If empty, will be popuated automaticaly by main title value" msgstr "" -#: src/Form/ProjectForm.php:153 +#: src/Form/ProjectForm.php:153 src/Form/UpdateForm.php:161 msgid "Meta Keywords" msgstr "کلمات کلیدی متا ( Meta Keywords )" -#: src/Form/ProjectForm.php:159 +#: src/Form/ProjectForm.php:159 src/Form/UpdateForm.php:167 msgid "" "Not used anymore by search engines : between 5 to 12 words / left it empty, " "it will be automaticaly populated with main title values" msgstr "" -#: src/Form/ProjectForm.php:166 +#: src/Form/ProjectForm.php:166 src/Form/UpdateForm.php:174 msgid "Meta Description" msgstr "توضیحات متا (Meta Keywords )" -#: src/Form/ProjectForm.php:172 +#: src/Form/ProjectForm.php:172 src/Form/UpdateForm.php:180 msgid "" "Displayed in search Engine result pages : quick summary to incitate user to " "click, between 80 to 160 character" msgstr "" +#: src/Form/UpdateForm.php:129 +msgid "Project" +msgstr "پروژه" + #: template/admin/project-index.phtml:4 msgid "List of projects" msgstr "فهرست پروژه ها" -#: template/admin/project-index.phtml:7 template/admin/question-index.phtml:14 +#: template/admin/project-index.phtml:7 msgid "ID" msgstr "شناسه" @@ -285,7 +290,7 @@ msgid "View" msgstr "نمایش" #: template/admin/project-index.phtml:26 template/admin/project-index.phtml:28 -#: template/admin/question-index.phtml:54 +#: template/admin/question-index.phtml:53 msgid "Edit" msgstr "ویرایش" @@ -298,29 +303,29 @@ msgid "List of questions and answers" msgstr "فهرست سوالات و پاسخ ها" #: template/admin/question-index.phtml:16 -msgid "Type" -msgstr "نوع" +msgid "User" +msgstr "کاربر" #: template/admin/question-index.phtml:17 -#: template/admin/question-update.phtml:6 +#: template/admin/question-update.phtml:11 msgid "Create" msgstr "ایجاد" -#: template/admin/question-index.phtml:50 +#: template/admin/question-index.phtml:49 #: template/admin/question-index.phtml:78 msgid "Reject" msgstr "رد کردن" -#: template/admin/question-index.phtml:52 +#: template/admin/question-index.phtml:51 #: template/admin/question-index.phtml:83 msgid "Accept" msgstr "تایید" -#: template/admin/question-index.phtml:55 +#: template/admin/question-index.phtml:54 msgid "Delete" msgstr "حذف" -#: template/admin/question-index.phtml:66 +#: template/admin/question-index.phtml:65 msgid "No question submit yet" msgstr "هنوز هیچ سوالی ارسال نشده است" @@ -328,7 +333,7 @@ msgstr "هنوز هیچ سوالی ارسال نشده است" msgid "Accept in process" msgstr "تایید در حال انجام است" -#: template/admin/question-update.phtml:4 +#: template/admin/question-update.phtml:8 msgid "Slug" msgstr "اسلاگ" @@ -403,6 +408,9 @@ msgstr "" "هیچ اطلاعاتی از کلمات کلیدی به عنوان برچسب هنوز در سیستم درج نشده است. لطفا " "بعدا از این صفحه را بررسی فرمایید. " +#~ msgid "Type" +#~ msgstr "نوع" + #~ msgid "The tag not set." #~ msgstr "برچسب یافت نشد" diff --git a/src/Controller/Admin/IndexController.php b/src/Controller/Admin/IndexController.php index 782ca0b..3c953ed 100644 --- a/src/Controller/Admin/IndexController.php +++ b/src/Controller/Admin/IndexController.php @@ -22,6 +22,7 @@ public function indexAction() return $this->redirect()->toRoute('', array( 'controller' => 'question', 'action' => 'index', + 'type' => 'all', )); } } diff --git a/src/Controller/Admin/QuestionController.php b/src/Controller/Admin/QuestionController.php index 289bcda..9e90f22 100644 --- a/src/Controller/Admin/QuestionController.php +++ b/src/Controller/Admin/QuestionController.php @@ -19,6 +19,7 @@ use Module\Ask\Form\UpdateForm; use Module\Ask\Form\UpdateFilter; use Zend\Json\Json; +use Zend\Db\Sql\Predicate\Expression; class QuestionController extends ActionController { @@ -26,8 +27,8 @@ public function indexAction() { // Get page $page = $this->params('page', 1); - $module = $this->params('module'); $status = $this->params('status'); + $type = $this->params('type'); // Set info $offset = (int)($page - 1) * $this->config('admin_perpage'); $order = array('time_create DESC', 'id DESC'); @@ -38,15 +39,26 @@ public function indexAction() if (!empty($status)) { $where['status'] = $status; } + if (!empty($type) && $type == 'question') { + $where['type'] = 'Q'; + } elseif (!empty($type) && $type == 'answer') { + $where['type'] = 'A'; + } // Set select $select = $this->getModel('question')->select()->where($where)->order($order)->offset($offset)->limit($limit); $rowset = $this->getModel('question')->selectWith($select); // Make list foreach ($rowset as $row) { $question[$row->id] = Pi::api('question', 'ask')->canonizeQuestion($row); + $question[$row->id]['user_url'] = Pi::url($this->url('', array( + 'module' => 'user', + 'controller' => 'edit', + 'action' => 'index', + 'uid' => $row->uid, + ))); } // Set paginator - $count = array('count' => new \Zend\Db\Sql\Predicate\Expression('count(*)')); + $count = array('count' => new Expression('count(*)')); $select = $this->getModel('question')->select()->where($where)->columns($count); $count = $this->getModel('question')->selectWith($select)->current()->count; $paginator = Paginator::factory(intval($count)); @@ -60,6 +72,7 @@ public function indexAction() 'controller' => 'question', 'action' => 'index', 'status' => $status, + 'type' => $type, )), )); // Set view @@ -106,12 +119,23 @@ public function updateAction() // Get id $id = $this->params('id'); $module = $this->params('module'); - // find item - $question = Pi::api('question', 'ask')->getQuestion($id); - $form = new UpdateForm('question'); + // Get config + $config = Pi::service('registry')->config->read($module); + // Set option + $option = array( + 'project_active' => $config['project_active'], + ); + // Get question + if ($id) { + $question = Pi::api('question', 'ask')->getQuestion($id); + } else { + $question = array(); + } + // form + $form = new UpdateForm('question', $option); if ($this->request->isPost()) { $data = $this->request->getPost(); - $form->setInputFilter(new UpdateFilter); + $form->setInputFilter(new UpdateFilter($option)); $form->setData($data); if ($form->isValid()) { $values = $form->getData(); @@ -141,9 +165,20 @@ public function updateAction() $filter = new Filter\HeadDescription; $values['seo_description'] = $filter($description); // Set time - $values['time_update'] = time(); + if (!empty($values['id'])) { + $values['time_update'] = time(); + } else { + $values['time_create'] = time(); + $values['time_update'] = time(); + $values['uid'] = Pi::user()->getId(); + $values['type'] = 'Q'; + } // Save values - $row = $this->getModel('question')->find($values['id']); + if (!empty($values['id'])) { + $row = $this->getModel('question')->find($values['id']); + } else { + $row = $this->getModel('question')->createRow(); + } $row->assign($values); $row->save(); // Tag @@ -152,19 +187,21 @@ public function updateAction() } // Check it save or not $message = __('Your selected item edit successfully'); - $url = array('', 'module' => $module, 'controller' => 'question', 'action' => 'index'); + $url = array('', 'module' => $module, 'controller' => 'question', 'action' => 'index', 'type' => 'all'); $this->jump($url, $message); } } else { - // Get tag list - if (Pi::service('module')->isActive('tag')) { - $tag = Pi::service('tag')->get($module, $question['id'], ''); - if (is_array($tag)) { - $question['tag'] = implode('|', $tag); + if ($id) { + // Get tag list + if (Pi::service('module')->isActive('tag')) { + $tag = Pi::service('tag')->get($module, $question['id'], ''); + if (is_array($tag)) { + $question['tag'] = implode('|', $tag); + } } + // Set to form + $form->setData($question); } - // Set to form - $form->setData($question); } // Set view $this->view()->setTemplate('question-update'); @@ -180,9 +217,9 @@ public function deleteAction() $row = $this->getModel('question')->find($id); if ($row) { $row->delete(); - $this->jump(array('action' => 'index'), __('Your selected question deleted')); + $this->jump(array('action' => 'index', 'type' => 'all'), __('Your selected question deleted')); } else { - $this->jump(array('action' => 'index'), __('Please select question')); + $this->jump(array('action' => 'index', 'type' => 'all'), __('Please select question')); } } } \ No newline at end of file diff --git a/src/Controller/Admin/ToolsController.php b/src/Controller/Admin/ToolsController.php deleted file mode 100644 index 727d262..0000000 --- a/src/Controller/Admin/ToolsController.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ -namespace Module\Ask\Controller\Admin; - -use Pi; -use Pi\Mvc\Controller\ActionController; - -class ToolsController extends ActionController -{ - public function indexAction() - { - $this->view()->setTemplate('tools-index'); - } -} \ No newline at end of file diff --git a/src/Form/Element/Project.php b/src/Form/Element/Project.php new file mode 100644 index 0000000..46e5ee8 --- /dev/null +++ b/src/Form/Element/Project.php @@ -0,0 +1,35 @@ + + */ +namespace Module\Ask\Form\Element; + +use Pi; +use Zend\Form\Element\Select; + +class Project extends Select +{ + public function getValueOptions() + { + if (empty($this->valueOptions)) { + $list = array(); + $columns = array('id', 'title'); + $order = array('title ASC', 'id DESC'); + $select = Pi::model('project', 'ask')->select()->columns($columns)->order($order); + $rowset = Pi::model('project', 'ask')->selectWith($select); + foreach ($rowset as $row) { + $list[$row->id] = $row->title; + } + $this->valueOptions = $list; + } + return $this->valueOptions; + } +} \ No newline at end of file diff --git a/src/Form/UpdateFilter.php b/src/Form/UpdateFilter.php index 8c9e6ba..85c8965 100644 --- a/src/Form/UpdateFilter.php +++ b/src/Form/UpdateFilter.php @@ -18,7 +18,7 @@ class UpdateFilter extends InputFilter { - public function __construct() + public function __construct($option = array()) { // id $this->add(array( @@ -35,6 +35,22 @@ public function __construct() ), ), )); + // slug + $this->add(array( + 'name' => 'slug', + 'required' => false, + 'filters' => array( + array( + 'name' => 'StringTrim', + ), + ), + 'validators' => array( + new \Module\Ask\Validator\SlugDuplicate(array( + 'module' => Pi::service('module')->current(), + 'table' => 'question', + )), + ), + )); // text_description $this->add(array( 'name' => 'text_description', @@ -45,6 +61,43 @@ public function __construct() ), ), )); + //main_image + $this->add(array( + 'name' => 'main_image', + 'required' => false, + )); + // additional_images + /* $this->add(array( + 'name' => 'additional_images', + 'required' => false, + )); */ + // status + $this->add(array( + 'name' => 'status', + 'required' => true, + )); + // project_id + if ($option['project_active']) { + $this->add(array( + 'name' => 'project_id', + 'required' => true, + )); + } + // seo_title + $this->add(array( + 'name' => 'seo_title', + 'required' => false, + )); + // seo_keywords + $this->add(array( + 'name' => 'seo_keywords', + 'required' => false, + )); + // seo_description + $this->add(array( + 'name' => 'seo_description', + 'required' => false, + )); // tag if (Pi::service('module')->isActive('tag')) { $this->add(array( diff --git a/src/Form/UpdateForm.php b/src/Form/UpdateForm.php index a7430a5..078cbaf 100644 --- a/src/Form/UpdateForm.php +++ b/src/Form/UpdateForm.php @@ -18,10 +18,16 @@ class UpdateForm extends BaseForm { - public function getInputFilter() + public function __construct($name = null, $option = array()) + { + $this->option = $option; + parent::__construct($name); + } + + public function getInputFilter() { if (!$this->filter) { - $this->filter = new UpdateFilter; + $this->filter = new UpdateFilter($this->option); } return $this->filter; } @@ -46,19 +52,134 @@ public function init() 'description' => '', ) )); + // slug + $this->add(array( + 'name' => 'slug', + 'options' => array( + 'label' => __('slug'), + ), + 'attributes' => array( + 'type' => 'text', + 'description' => __('Used on URL value : must be unique, short, and user oriented'), + ) + )); // text_description $this->add(array( 'name' => 'text_description', 'options' => array( 'label' => __('Question'), - 'editor' => 'html', - 'set' => '', ), 'attributes' => array( - 'type' => 'editor', + 'type' => 'textarea', + 'rows' => '10', + 'cols' => '40', 'description' => '', ) )); + // main_image + $this->add(array( + 'name' => 'main_image', + 'type' => 'Module\Media\Form\Element\Media', + 'options' => array( + 'label' => __('Main image'), + 'media_gallery' => false, + 'media_season' => false, + 'media_season_recommended' => false, + 'is_freemium' => true, + 'can_connect_lists' => false, + ), + )); + // additional_images + /* $this->add(array( + 'name' => 'additional_images', + 'type' => 'Module\Media\Form\Element\Media', + 'options' => array( + 'label' => __('Additional images'), + 'media_gallery' => true, + 'media_season' => false, + 'media_season_recommended' => false, + 'is_freemium' => true, + 'can_connect_lists' => false, + ), + )); */ + // status + $this->add(array( + 'name' => 'status', + 'type' => 'select', + 'options' => array( + 'label' => __('Status'), + 'value_options' => array( + 1 => __('Published'), + 2 => __('Pending review'), + 3 => __('Draft'), + 4 => __('Private'), + 5 => __('Remove'), + ), + ), + 'attributes' => array( + 'required' => true, + ), + )); + // project_id + if ($this->option['project_active']) { + $this->add(array( + 'name' => 'project_id', + 'type' => 'Module\Ask\Form\Element\Project', + 'options' => array( + 'label' => __('Project'), + ), + 'attributes' => array( + 'required' => true, + ), + )); + } + // extra_seo + $this->add(array( + 'name' => 'extra_seo', + 'type' => 'fieldset', + 'options' => array( + 'label' => __('SEO options'), + ), + )); + // seo_title + $this->add(array( + 'name' => 'seo_title', + 'options' => array( + 'label' => __('Meta Title'), + ), + 'attributes' => array( + 'type' => 'textarea', + 'rows' => '2', + 'cols' => '40', + 'description' => __('Displayed in search Engine result pages as Title : between 10 to 70 character. If empty, will be popuated automaticaly by main title value'), + ) + )); + // seo_keywords + $this->add(array( + 'name' => 'seo_keywords', + 'options' => array( + 'label' => __('Meta Keywords'), + ), + 'attributes' => array( + 'type' => 'textarea', + 'rows' => '2', + 'cols' => '40', + 'description' => __('Not used anymore by search engines : between 5 to 12 words / left it empty, it will be automaticaly populated with main title values'), + ) + )); + // seo_description + $this->add(array( + 'name' => 'seo_description', + 'options' => array( + 'label' => __('Meta Description'), + ), + 'attributes' => array( + 'type' => 'textarea', + 'rows' => '3', + 'cols' => '40', + 'description' => __('Displayed in search Engine result pages : quick summary to incitate user to click, between 80 to 160 character'), + ) + )); // tag if (Pi::service('module')->isActive('tag')) { $this->add(array( diff --git a/template/admin/question-index.phtml b/template/admin/question-index.phtml index fa784a8..9f003a8 100644 --- a/template/admin/question-index.phtml +++ b/template/admin/question-index.phtml @@ -11,39 +11,38 @@ $this->js($this->assetModule('script/system-msg.js', 'system'));

- - - - - + + + + + - + } ?> - - +
escape($question['id']); ?> + - + escape($question['title']); ?> - escape($question['title']); ?> + + escape($question['title']); ?> + + + escape($question['user']['name']); ?> + + escape($question['time_create_view']); ?> @@ -68,6 +67,7 @@ $this->js($this->assetModule('script/system-msg.js', 'system'));