@@ -21,17 +21,15 @@ private function _CheckCategoryData(&$param)
2121 private function _CheckPostData (&$ Param )
2222 {
2323 $ id_category = $ Param ->id_category ;
24- if ($ Param ->title == '' ||
25- $ Param ->alt == '' ||
26- !is_array ($ id_category ) ||
27- count ($ id_category ) == 0 ) {
24+ if ($ Param ->title == '' || $ Param ->alt == '' || !is_array ($ id_category ) || count ($ id_category ) == 0 ) {
2825 $ this ->Message (T ('XMLcms_text_need_all_data ' ));
2926 $ this ->_Referer ();
3027 return false ;
3128 }
3229 $ Param ->alt = strtolower (fsFunctions::Chpu ($ Param ->alt ));
3330 $ Param ->active = $ Param ->Exists ('active ' ) ? 1 : 0 ;
3431 $ Param ->auth = $ Param ->Exists ('auth ' ) ? 1 : 0 ;
32+ $ Param ->id_user = $ Param ->Exists ('id_user ' , true ) ? $ Param ->id_user : fsSession::GetArrInstance ('AUTH ' , 'id ' );
3533 if ($ Param ->time == '' ) {
3634 $ Param ->time = date ('H:i:s ' );
3735 }
@@ -77,7 +75,7 @@ public function Init($request)
7775 public function actionAddPost ($ Param )
7876 {
7977 $ posts_category = new posts_category ();
80- $ posts_category = $ posts_category ->GetAll (true , false , array ('name ' ));
78+ $ posts_category = $ posts_category ->GetAll (true , false , array ('id_parent ' , ' name ' ), ' id ' );
8179 if (count ($ posts_category ) < 2 ) {
8280 $ this ->Message (T ('XMLcms_text_no_category_found ' ));
8381 return $ this ->_Referer ();
@@ -101,7 +99,7 @@ public function actionEditPost($param)
10199 $ templates_short = fsFunctions::DirectoryInfo (PATH_TPL .CMSSettings::GetInstance ('template ' ).'/MPosts/ ' , true , false , 'ShortPost ' , array ('php ' ));
102100 $ this ->Tag ('templates ' , $ templates ['NAMES ' ]);
103101 $ this ->Tag ('templates_short ' , $ templates_short ['NAMES ' ]);
104- $ this ->Tag ('categories ' , $ posts_category ->GetAll (true , false , array ('name ' )));
102+ $ this ->Tag ('categories ' , $ posts_category ->GetAll (true , false , array ('id_parent ' , ' name ' ), ' id ' ));
105103 $ this ->Tag ('post ' , $ this ->_table ->result );
106104 $ this ->Tag ('post_categories ' , $ post_category ->GetByPostId ($ param ->key ));
107105 }
@@ -117,13 +115,13 @@ public function actionIndex($Param)
117115 {
118116 $ posts_category = new posts_category ();
119117 $ this ->Tag ('table ' , $ this ->_PostsTable ($ Param ));
120- $ this ->Tag ('categories ' , $ posts_category ->GetAll (true , false , array ('name ' )));
118+ $ this ->Tag ('categories ' , $ posts_category ->GetAll (true , false , array ('name ' ), ' id ' ));
121119 }
122120
123121 public function actionCategories ($ Param )
124122 {
125123 $ posts_category = new posts_category ();
126- $ this ->Tag ('categories ' , $ posts_category ->GetAll (true , false , array ('name ' )));
124+ $ this ->Tag ('categories ' , $ posts_category ->GetAll (true , false , array ('name ' ), ' id ' ));
127125 }
128126
129127 public function actionAjaxCategoryTemplate ($ Param )
@@ -141,6 +139,17 @@ public function actionAjaxCategoryTemplate($Param)
141139 $ this ->Json ($ result );
142140 }
143141
142+ private function _GetCategoriesAsArray ()
143+ {
144+ $ c = new posts_category ();
145+ $ all = $ c ->GetAll (true , false , array ('id_parent ' , 'name ' ), 'id ' );
146+ $ result = array ();
147+ foreach ($ all as $ c ) {
148+ $ result [$ c ['id ' ]] = PostsFunctions::GetFullCategoryName ($ all , $ c );
149+ }
150+ return $ result ;
151+ }
152+
144153 public function actionAddCategory ($ Param )
145154 {
146155 $ templates = fsFunctions::DirectoryInfo (PATH_TPL .CMSSettings::GetInstance ('template ' ).'/MPosts/ ' , true , false , 'Index ' , array ('php ' ));
@@ -149,15 +158,17 @@ public function actionAddCategory($Param)
149158 $ this ->Tag ('templates ' , $ templates ['NAMES ' ]);
150159 $ this ->Tag ('templates_ps ' , $ templates_sp ['NAMES ' ]);
151160 $ this ->Tag ('templates_pf ' , $ templates_fp ['NAMES ' ]);
161+ $ this ->Tag ('parents ' , $ this ->_GetCategoriesAsArray ());
152162 }
153163
154- public function actionEditCategory ($ Param )
164+ public function actionEditCategory ($ param )
155165 {
156166 $ posts_category = new posts_category ();
157- $ posts_category ->current = $ Param ->key ;
158- if ($ Param ->key != $ posts_category ->id ) {
167+ $ this ->Tag ('parents ' , $ this ->_GetCategoriesAsArray ());
168+ $ posts_category ->current = $ param ->key ;
169+ if ($ param ->key != $ posts_category ->id ) {
159170 return $ this ->_Referer ();
160- }
171+ }
161172 $ templates = fsFunctions::DirectoryInfo (PATH_TPL .CMSSettings::GetInstance ('template ' ).'/MPosts/ ' , true , false , 'Index ' , array ('php ' ));
162173 $ templates_sp = fsFunctions::DirectoryInfo (PATH_TPL .CMSSettings::GetInstance ('template ' ).'/MPosts/ ' , true , false , 'ShortPost ' , array ('php ' ));
163174 $ templates_fp = fsFunctions::DirectoryInfo (PATH_TPL .CMSSettings::GetInstance ('template ' ).'/MPosts/ ' , true , false , 'Post ' , array ('php ' ));
0 commit comments