| 1 |
<? |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 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 |
?> |
|---|