<commit_before><?php
/*
* Project:		EQdkp-Plus
* License:		Creative Commons - Attribution-Noncommercial-Share Alike 3.0 Unported
* Link:			http://creativecommons.org/licenses/by-nc-sa/3.0/
* -----------------------------------------------------------------------
* Began:		2010
* Date:			$Date$
* -----------------------------------------------------------------------
* @author		$Author$
* @copyright	2006-2011 EQdkp-Plus Developer Team
* @link			http://eqdkp-plus.com
* @package		eqdkpplus
* @version		$Rev$
*
* $Id$
*/

if ( !defined('EQDKP_INC') ){
	die('Do not access this file directly.');
}

if ( !class_exists( "pdh_r_article_categories" ) ) {
	class pdh_r_article_categories extends pdh_r_generic{

		public $default_lang = 'english';
		public $categories;
		public $sortation;
		private $arrTempPermissions = array();

		public $hooks = array(
			'article_categories_update',
			'article_updates',
		);
				
		public $presets = array(
			'category_sortable' => array('sort_id', array('%category_id%'), array()),
			'category_editicon' => array('editicon', array('%category_id%'), array()),
			'category_published' => array('published', array('%category_id%'), array()),
			'category_article_count' => array('article_count', array('%category_id%'), array()),
			'category_name' => array('name', array('%category_id%'), array()),
			'category_alias' => array('alias', array('%category_id%'), array()),
			'category_portallayout' => array('portal_layout', array('%category_id%'), array()),
		);

		public function reset(){
			$this->pdc->del('pdh_article_categories_table');
			$this->categories = NULL;
			$this->sortation = NULL;
			$this->alias = NULL;
		}

		public function init(){
			$this->categories	= $this->pdc->get('pdh_article_categories_table');
			$this->sortation	= $this->pdc->get('pdh_article_categories_sortation');
			$this->alias		= $this->pdc->get('pdh_article_categories_alias');
			if($this->categories !== NULL){
				return true;
			}
			
			$objQuery = $this->db->query("SELECT * FROM __article_categories ORDER BY sort_id ASC");
			if($objQuery){
				while($drow = $objQuery->fetchAssoc()){
					$this->categories[intval($drow['id'])] = array(
						'id'				=> intval($drow['id']),
						'name'				=> $drow['name'],
						'alias'				=> utf8_strtolower($drow['alias']),
						'description'		=> $drow['description'],
						'per_page'			=> intval($drow['per_page']),
						'permissions'		=> $drow['permissions'],
						'published'			=> intval($drow['published']),
						'parent'			=> intval($drow['parent']),
						'sort_id'			=> intval($drow['sort_id']),
						'list_type'			=> intval($drow['list_type']),
						'aggregation'		=> $drow['aggregation'],
						'featured_only'		=> intval($drow['featured_only']),
						'social_share_buttons'=> intval($drow['social_share_buttons']),
						'portal_layout'		=> intval($drow['portal_layout']),
						'show_childs'		=> intval($drow['show_childs']),
						'article_published_state' => intval($drow['article_published_state']),
						'notify_on_onpublished_articles' => intval($drow['notify_on_onpublished_articles']),
						'hide_header'		=> intval($drow['hide_header']),
						'sortation_type'	=> intval($drow['sortation_type']),
						'featured_ontop'	=> intval($drow['featured_ontop']),
						'hide_on_rss'		=> intval($drow['hide_on_rss']),
					);
					$this->alias[utf8_strtolower($drow['alias'])] = intval($drow['id']);
				}
				
				$this->sortation = $this->get_sortation();
				
				$this->pdc->put('pdh_article_categories_table', $this->categories, null);
				$this->pdc->put('pdh_article_categories_sortation', $this->sortation, null);
				$this->pdc->put('pdh_article_categories_alias', $this->alias, null);
			}
	
		}

		public function get_id_list($blnPublishedOnly = false) {
			if ($this->categories == NULL) return array();
			
			if ($blnPublishedOnly){
				$arrOut = array();
				foreach($this->categories as $intCategoryID => $arrCat){
					if ($this->get_published($intCategoryID)) $arrOut[] = $intCategoryID;
				}
				return $arrOut;
			} else return array_keys($this->categories);
		}
		
		//Get all published article IDs
		public function get_published_id_list($intCategoryID, $intUserID = false, $forRSS=false, $blnFeaturedOnly=NULL){
			if($blnFeaturedOnly === NULL) $blnFeaturedOnly = $this->get_featured_only($intCategoryID);
			if (!$this->get_published($intCategoryID)) return array();
			if ($intUserID === false) $intUserID = $this->user->id;
			$arrOut = array();
			//Get articles from all aggregation categorys
			$arrAggregation = $this->get_aggregation($intCategoryID);
			if (is_array($arrAggregation) && count($arrAggregation) > 0){
				foreach($arrAggregation as $intCatID){
					//Check published cat
					if (!$this->get_published($intCatID)) continue;
					//Check if category should be hidden on RSS
					if($forRSS && $this->get_hide_on_rss($intCatID)) continue;
					
					//Check cat permission
					$arrPermissions = $this->get_user_permissions($intCatID, $intUserID);
					if (!$arrPermissions['read']) continue;
					
					//Foreach Article
					$arrArticles = $this->pdh->get('articles', 'id_list', array($intCatID));
					foreach($arrArticles as $intArticleID){
						//Check published
						if (!$this->pdh->get('articles', 'published', array($intArticleID))) continue;
						//Check featured
						if ($blnFeaturedOnly && !$this->pdh->get('articles', 'featured', array($intArticleID))) continue;
						//Check start from/to
						if (($this->pdh->get('articles', 'show_from', array($intArticleID)) != "" && $this->pdh->get('articles', 'show_from', array($intArticleID)) < $this->time->time) || ($this->pdh->get('articles', 'show_to', array($intArticleID)) != "" && $this->pdh->get('articles', 'show_to', array($intArticleID)) > $this->time->time)) continue;
						
						$arrOut[] = $intArticleID;
					}	
				}
			}
			$arrOut = array_unique($arrOut);
			
			return $arrOut;
		}
		
		public function get_data($intCategoryID){
			if (isset($this->categories[$intCategoryID])){
				return $this->categories[$intCategoryID];
			}
			return false;
		}

		public function get_name($intCategoryID){<commit_msg>Publish Articles from the Frontend<commit_after><?php
/*
* Project:		EQdkp-Plus
* License:		Creative Commons - Attribution-Noncommercial-Share Alike 3.0 Unported
* Link:			http://creativecommons.org/licenses/by-nc-sa/3.0/
* -----------------------------------------------------------------------
* Began:		2010
* Date:			$Date$
* -----------------------------------------------------------------------
* @author		$Author$
* @copyright	2006-2011 EQdkp-Plus Developer Team
* @link			http://eqdkp-plus.com
* @package		eqdkpplus
* @version		$Rev$
*
* $Id$
*/

if ( !defined('EQDKP_INC') ){
	die('Do not access this file directly.');
}

if ( !class_exists( "pdh_r_article_categories" ) ) {
	class pdh_r_article_categories extends pdh_r_generic{

		public $default_lang = 'english';
		public $categories;
		public $sortation;
		private $arrTempPermissions = array();

		public $hooks = array(
			'article_categories_update',
			'article_updates',
		);
				
		public $presets = array(
			'category_sortable' => array('sort_id', array('%category_id%'), array()),
			'category_editicon' => array('editicon', array('%category_id%'), array()),
			'category_published' => array('published', array('%category_id%'), array()),
			'category_article_count' => array('article_count', array('%category_id%'), array()),
			'category_name' => array('name', array('%category_id%'), array()),
			'category_alias' => array('alias', array('%category_id%'), array()),
			'category_portallayout' => array('portal_layout', array('%category_id%'), array()),
		);

		public function reset(){
			$this->pdc->del('pdh_article_categories_table');
			$this->categories = NULL;
			$this->sortation = NULL;
			$this->alias = NULL;
		}

		public function init(){
			$this->categories	= $this->pdc->get('pdh_article_categories_table');
			$this->sortation	= $this->pdc->get('pdh_article_categories_sortation');
			$this->alias		= $this->pdc->get('pdh_article_categories_alias');
			if($this->categories !== NULL){
				return true;
			}
			
			$objQuery = $this->db->query("SELECT * FROM __article_categories ORDER BY sort_id ASC");
			if($objQuery){
				while($drow = $objQuery->fetchAssoc()){
					$this->categories[intval($drow['id'])] = array(
						'id'				=> intval($drow['id']),
						'name'				=> $drow['name'],
						'alias'				=> utf8_strtolower($drow['alias']),
						'description'		=> $drow['description'],
						'per_page'			=> intval($drow['per_page']),
						'permissions'		=> $drow['permissions'],
						'published'			=> intval($drow['published']),
						'parent'			=> intval($drow['parent']),
						'sort_id'			=> intval($drow['sort_id']),
						'list_type'			=> intval($drow['list_type']),
						'aggregation'		=> $drow['aggregation'],
						'featured_only'		=> intval($drow['featured_only']),
						'social_share_buttons'=> intval($drow['social_share_buttons']),
						'portal_layout'		=> intval($drow['portal_layout']),
						'show_childs'		=> intval($drow['show_childs']),
						'article_published_state' => intval($drow['article_published_state']),
						'notify_on_onpublished_articles' => intval($drow['notify_on_onpublished_articles']),
						'hide_header'		=> intval($drow['hide_header']),
						'sortation_type'	=> intval($drow['sortation_type']),
						'featured_ontop'	=> intval($drow['featured_ontop']),
						'hide_on_rss'		=> intval($drow['hide_on_rss']),
					);
					$this->alias[utf8_strtolower($drow['alias'])] = intval($drow['id']);
				}
				
				$this->sortation = $this->get_sortation();
				
				$this->pdc->put('pdh_article_categories_table', $this->categories, null);
				$this->pdc->put('pdh_article_categories_sortation', $this->sortation, null);
				$this->pdc->put('pdh_article_categories_alias', $this->alias, null);
			}
	
		}

		public function get_id_list($blnPublishedOnly = false) {
			if ($this->categories == NULL) return array();
			
			if ($blnPublishedOnly){
				$arrOut = array();
				foreach($this->categories as $intCategoryID => $arrCat){
					if ($this->get_published($intCategoryID)) $arrOut[] = $intCategoryID;
				}
				return $arrOut;
			} else return array_keys($this->categories);
		}
		
		//Get all published article IDs
		public function get_published_id_list($intCategoryID, $intUserID = false, $forRSS=false, $blnFeaturedOnly=NULL, $isAdmin=false){
			if($blnFeaturedOnly === NULL) $blnFeaturedOnly = $this->get_featured_only($intCategoryID);
			if (!$this->get_published($intCategoryID)) return array();
			if ($intUserID === false) $intUserID = $this->user->id;
			$arrOut = array();
			//Get articles from all aggregation categorys
			$arrAggregation = $this->get_aggregation($intCategoryID);
			if (is_array($arrAggregation) && count($arrAggregation) > 0){
				foreach($arrAggregation as $intCatID){
					//Check published cat
					if (!$this->get_published($intCatID)) continue;
					//Check if category should be hidden on RSS
					if($forRSS && $this->get_hide_on_rss($intCatID)) continue;
					
					//Check cat permission
					$arrPermissions = $this->get_user_permissions($intCatID, $intUserID);
					if (!$arrPermissions['read']) continue;
					
					//Foreach Article
					$arrArticles = $this->pdh->get('articles', 'id_list', array($intCatID));
					foreach($arrArticles as $intArticleID){
						//Check published
						if (!$this->pdh->get('articles', 'published', array($intArticleID)) && !$isAdmin) continue;
						//Check featured
						if ($blnFeaturedOnly && !$this->pdh->get('articles', 'featured', array($intArticleID))) continue;
						//Check start from/to
						if (($this->pdh->get('articles', 'show_from', array($intArticleID)) != "" && $this->pdh->get('articles', 'show_from', array($intArticleID)) < $this->time->time) || ($this->pdh->get('articles', 'show_to', array($intArticleID)) != "" && $this->pdh->get('articles', 'show_to', array($intArticleID)) > $this->time->time)) continue;
						
						$arrOut[] = $intArticleID;
					}	
				}
			}
			$arrOut = array_unique($arrOut);
			
			return $arrOut;
		}
		
		public function get_data($intCategoryID){
			if (isset($this->categories[$intCategoryID])){
				return $this->categories[$intCategoryID];
			}
			return false;
		}

		public function get_name($intCategoryID){
{'fraction_non_alphanumeric': 0.2051469394382205, 'fraction_numerical': 0.0030849163825296313, 'mean_word_length': 3.8884920634920634, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 191, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5568090', 'n_tokens_mistral': 4948, 'n_tokens_neox': 4092, 'n_words': 679}