00001 <?php
00002
00003 lt_include( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
00004 lt_include( PLOG_CLASS_PATH."class/locale/locales.class.php" );
00005 lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
00006 lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
00007 lt_include( PLOG_CLASS_PATH."class/dao/articlestatus.class.php" );
00008 lt_include( PLOG_CLASS_PATH."class/data/pager/pager.class.php" );
00009 lt_include( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
00010 lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
00011 lt_include( PLOG_CLASS_PATH."class/config/siteconfig.class.php" );
00012 lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
00013
00020 class AdminPostsListView extends AdminTemplatedView
00021 {
00022
00023 var $_showCategory = -1;
00024 var $_showStatus = 1;
00025 var $_showUser = 0;
00026 var $_showMonth;
00027 var $_searchTerms;
00028 var $_page;
00029
00030 function AdminPostsListView( $blogInfo, $params = Array())
00031 {
00032 $this->AdminTemplatedView( $blogInfo, "editposts" );
00033
00034
00035 $this->_locale =& $blogInfo->getLocale();
00036
00037
00038 $this->_setViewParameters( $params );
00039
00040 $this->_page = $this->getCurrentPageFromRequest();
00041
00042 $blogSettings = $blogInfo->getSettings();
00043
00044 $this->_itemsPerPage = $blogSettings->getValue( "show_posts_max" );
00045 if( $this->_itemsPerPage > SiteConfig::getHardShowPostsMax())
00046 $this->_itemsPerPage = SiteConfig::getHardShowPostsMax();
00047 }
00048
00049
00050
00056 function _getMonths()
00057 {
00058 $articles = new Articles();
00059 $archiveStats = $articles->getNumberPostsPerMonthAdmin( $this->_blogInfo->getId());
00060
00061 if( !$archiveStats )
00062 return Array();
00063
00064 $result = Array();
00065
00066 $t = new Timestamp();
00067 $curyear = (int)$t->getYear();
00068 $curmonth = (int)$t->getMonth();
00069
00070 $archiveDateFormat = $this->_locale->tr( "archive_date_format" );
00071 if( $archiveDateFormat == "archive_date_format" ) $archiveDateFormat = "%B %Y";
00072
00073
00074 if( empty( $archiveStats[$curyear][$curmonth] )) {
00075 $t = new Timestamp();
00076 $name = $this->_locale->formatDate( $t, $archiveDateFormat );
00077 $monthStr = Array( "name" => $name,
00078 "date" => $this->_locale->formatDate($t, "%Y%m"));
00079 array_push( $result, $monthStr );
00080 }
00081
00082 foreach( $archiveStats as $yearName => $year) {
00083 foreach( $year as $monthName => $month ) {
00084
00085 $t = new Timestamp( "" );
00086 $t->setYear( $yearName );
00087 $t->setMonth( $monthName );
00088 $name = $this->_locale->formatDate( $t, $archiveDateFormat );
00089 $monthStr = Array( "name" => $name,
00090 "date" => $this->_locale->formatDate($t, "%Y%m"));
00091 array_push( $result, $monthStr );
00092 }
00093 }
00094
00095 return $result;
00096 }
00097
00102 function _getParameter( $params, $paramId, $defaultValue )
00103 {
00104 $value = "";
00105 if( array_key_exists( $paramId, $params ) )
00106 {
00107 $value = $params["$paramId"];
00108 }
00109 if( $value == "" )
00110 $value = $this->getSessionValue( $paramId, $defaultValue );
00111
00112 return $value;
00113 }
00114
00115 function _setViewParameters( $params )
00116 {
00117
00118
00119
00120 $this->_showCategory = $this->_getParameter( $params, "showCategory", -1 );
00121 $this->_showStatus = $this->_getParameter( $params, "showStatus", POST_STATUS_ALL );
00122 $this->_showUser = $this->_getParameter( $params, "showUser", 0 );
00123 $this->_showMonth = $this->_getParameter( $params, "showMonth", $this->_locale->formatDate( new Timestamp(), "%Y%m" ));
00124 $this->_searchTerms = $this->_getParameter( $params, "searchTerms", "");
00125
00126
00127 }
00128
00132 function render()
00133 {
00134
00135
00136
00137 $articles = new Articles();
00138 $posts = $articles->getBlogArticles( $this->_blogInfo->getId(),
00139 $this->_showMonth,
00140 $this->_itemsPerPage,
00141 $this->_showCategory,
00142 $this->_showStatus,
00143 $this->_showUser,
00144 0,
00145 $this->_searchTerms,
00146 $this->_page
00147 );
00148
00149
00150 $numPosts = $articles->getNumBlogArticles(
00151 $this->_blogInfo->getId(),
00152 $this->_showMonth,
00153 $this->_showCategory,
00154 $this->_showStatus,
00155 $this->_showUser,
00156 0,
00157 $this->_searchTerms
00158 );
00159
00160 $pager = new Pager( "?op=editPosts&showMonth={$this->_showMonth}&showStatus={$this->_showStatus}&showCategory={$this->_showCategory}&showUser={$this->_showUser}&searchTerms={$this->_searchTerms}&page=",
00161 $this->_page,
00162 $numPosts,
00163 $this->_itemsPerPage );
00164
00165 $this->setValue( "posts", $posts );
00166
00167
00168 $this->notifyEvent( EVENT_POSTS_LOADED, Array( "posts" => &$posts ));
00169
00170
00171 $categories = new ArticleCategories();
00172 $blogSettings = $this->_blogInfo->getSettings();
00173 $categoriesOrder = $blogSettings->getValue( "categories_order" );
00174 $blogCategories = $categories->getBlogCategories( $this->_blogInfo->getId(),
00175 false, $categoriesOrder );
00176 $this->notifyEvent( EVENT_CATEGORIES_LOADED, Array( "categories" => &$blogCategories ));
00177
00178
00179 $users = new Users();
00180 $blogUsers = $users->getBlogUsers( $this->_blogInfo->getId());
00181
00182
00183 $postStatusList = ArticleStatus::getStatusList( true );
00184 $postStatusListWithoutAll = ArticleStatus::getStatusList( false );
00185
00186 $this->setValue( "categories", $blogCategories );
00187
00188
00189 $this->setSessionValue( "showCategory", $this->_showCategory );
00190 $this->setSessionValue( "showStatus", $this->_showStatus );
00191 $this->setSessionValue( "showUser", $this->_showUser );
00192 $this->setSessionValue( "showMonth", $this->_showMonth );
00193
00194 $this->setValue( "currentcategory", $this->_showCategory );
00195 $this->setValue( "currentstatus", $this->_showStatus );
00196 $this->setValue( "currentuser", $this->_showUser );
00197 $this->setValue( "currentmonth", $this->_showMonth );
00198 $this->setValue( "users", $blogUsers );
00199 $this->setValue( "months", $this->_getMonths());
00200 $this->setValue( "poststatus", $postStatusList );
00201 $this->setValue( "poststatusWithoutAll", $postStatusListWithoutAll );
00202 $this->setValue( "searchTerms", TextFilter::filterAllHTML( $this->_searchTerms ));
00203 $this->setValue( "pager", $pager );
00204
00205 parent::render();
00206 }
00207 }
00208 ?>