BoonEx Home Trac
 
 

root/trunk/articles.php

Revision 7554, 5.2 kB (checked in by aramis, 2 months ago)

--

Line 
1 <?
2
3 /***************************************************************************
4 *                            Dolphin Smart Community Builder
5 *                              -----------------
6 *     begin                : Mon Mar 23 2006
7 *     copyright            : (C) 2006 BoonEx Group
8 *     website              : http://www.boonex.com/
9 * This file is part of Dolphin - Smart Community Builder
10 *
11 * Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
12 * http://creativecommons.org/licenses/by/3.0/
13 *
14 * Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15 * without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the Creative Commons Attribution 3.0 License for more details.
17 * You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
18 * see license.txt file; if not, write to marketing@boonex.com
19 ***************************************************************************/
20
21 require_once( 'inc/header.inc.php' );
22 require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
23 require_once( BX_DIRECTORY_PATH_INC . 'admin_design.inc.php' );
24 require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
25 require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolArticles.php' );
26
27 check_logged();
28     
29 $_page['name_index'] = 49;
30 $_ni = $_page['name_index'];
31 $_page_cont[$_ni]['page_main_code'] = PageCompArticles();
32 $_page['extra_js'] = $oTemplConfig->sTinyMceEditorJS;
33 $_page['css_name'] = 'articles.css';
34
35 $_page['header'] = _t( "_ARTICLES_H", $site['title'] );
36
37 $_page['header_text'] = _t( '_Articles' );
38
39 // --------------- page components
40
41 function PageCompArticles() {
42
43     global $logged;
44     global $site;
45     global $sActionText;
46
47     $oArticles = new BxDolArticles($logged);
48     $oAPV = new BxDolArticlesPageView($oArticles);
49
50     $iCategoryID = ( isset($_POST['categoryID']) )
51         ? (int) $_POST['categoryID']
52         : 0;
53
54     $iArticleID = ( isset($_POST['articleID']) )
55         ? (int)$_POST['articleID']
56         : 0;
57     
58     // init some get or post var
59     $sArticleTitle = ( isset($_POST['title']) )
60         ? trim( process_db_input( $_POST['title'], 1 ) )
61         : null;
62
63     $sArticle = ( isset( $_POST['article'])  )
64         ? trim( $oArticles->process_html_db_input( $_POST['article'] ) )
65         : null;
66
67     $sFlag = ( isset($_POST['flag']) and $_POST['flag'] == 'HTML' )
68         ? 'HTML'
69         : 'Text';
70
71     $sRet = '';
72
73     // add new article
74     if ( isset($_POST['add_article']) ) {
75
76
77         if ( !$iCategoryID or !$sArticleTitle or !$sArticle ) {
78             $sRet .= '<div class="error_message">' . _t( '_Please fill up all fields' ) . '</div>';
79             $sRet .= $oArticles->getArticleEditForm();
80         }
81         else
82             if ( $oArticles->addArticle( $iCategoryID, $sArticleTitle, $sArticle, $sFlag )  ) {
83
84                 $_GET['action'] = 'viewcategory';
85                 $_GET['catID']     = $iCategoryID;
86
87                 $sRet .= '<div class="success_message">' . _t( '_post_successfully_added' ) . '</div>';
88                 $sRet .= $oArticles->getArticlesList( $iCategoryID );
89
90             }   
91             else
92                 echo '<div class="error_message">' . _t( '_failed_to_add_post' ) .  '</div>';
93
94     }
95     else if ( isset($_POST['edit_article']) ) {
96
97         if ( !$iCategoryID or !$sArticleTitle or !$sArticle ) {
98             $sRet .= '<div class="error_message">' . _t( '_Please fill up all fields' ) . '</div>';
99             $sRet .= $oArticles->getArticleEditForm($iArticleID);
100         }
101         else  {
102                 if ( $iArticleID ) {
103
104                         $oArticles->updateArticle( $iCategoryID, $sArticleTitle, $sArticle, $sFlag, $iArticleID );   
105
106                         $_GET['action'] = 'viewcategory';
107                         $_GET['catID']     = $iCategoryID;
108
109                         $sRet .= '<div class="success_message">' . _t( '_changes_successfully_applied' ) .  '</div>';
110                         $sRet .= $oArticles->getArticlesList( $iCategoryID );
111
112                 }   
113                 else
114                     echo '<div class="error_message">' . _t( '_failed_to_add_post' ) .  '</div>';
115             }   
116     }
117     else {
118
119         if ( isset($_GET['delete']) and isset($_GET['article_id']) ) {
120             // delete action
121             $sRet .= $oArticles->deleteArticle( (int) $_GET['article_id'] );
122             $sRet .= $oArticles->getArticlesList( (int) $_GET['catID'] );
123             
124             return $sRet;
125         }
126
127         switch ($_GET['action'] ) {
128
129             case 'viewcategory':
130                 if (isset($_REQUEST['articleCatUri']))
131                     $iCategoryID = (int)$oArticles->getArticleCatIdByUri( $_REQUEST['articleCatUri'] );
132                 else
133                     $iCategoryID = (int)$_REQUEST['catID'];
134                 $sRet .= $oArticles->getArticlesList( $iCategoryID );
135             break;
136             case 'viewarticle':
137                 if (isset($_REQUEST['articleUri']))
138                     $iArticleID = $oArticles->getArticleIdByUri( $_REQUEST['articleUri'] );
139                 else
140                     $iArticleID = $_REQUEST['articleID'];
141                 
142                 $oArticles->getArticle( $iArticleID );
143                 $sRet .= $oAPV->getCode();
144             break;
145             case 'addarticle':
146                 $sRet .= $oArticles->getArticleEditForm();
147             break;
148             case 'editarticle':
149                 $iArticleID = (int)$_REQUEST['articleID'];
150                 $sRet .= $oArticles->getArticleEditForm( $iArticleID );
151             break;
152             default:
153                 $sRet .= $oArticles->getArticlesCategoriesList();
154                 if ($logged['admin'] and $oArticles->sUrl == $_SERVER['PHP_SELF'] ) {
155                     $sRet .= $oArticles->GenAdmModerHeader();
156                     $sRet .= $oArticles->getArticlesList(0, "`Status`='0'");
157                 }
158             break;
159         }
160     }
161
162     if ( !$iCategoryID )
163         return DesignBoxContent( $oArticles->getBreadGrit(0, $iArticleID), $sRet, 1 );
164     else
165         return DesignBoxContent( $oArticles->getBreadGrit($iCategoryID), $sRet, 1 );
166
167 }
168
169 PageCode();
170 ?>
Note: See TracBrowser for help on using the browser.