<commit_before><?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
 * documentAdminView class
 * Document admin view of the module class
 *
 * @author NAVER (<EMAIL>)
 * @package /modules/document
 * @version 0.1
 */
class documentAdminView extends document
{
	/**
	 * Initialization
	 * @return void
	 */
	function init()
	{
		// check current location in admin menu
		$oModuleModel = getModel('module');
		$info = $oModuleModel->getModuleActionXml('document');
		foreach($info->menu AS $key => $menu)
		{
			if(in_array($this->act, $menu->acts))
			{
				Context::set('currentMenu', $key);
				break;
			}
		}
	}

	/**
	 * Display a list(administrative)
	 * @return void
	 */
	function dispDocumentAdminList()
	{
		// option to get a list
		$args = new stdClass();
		$args->page = Context::get('page'); // /< Page
		$args->list_count = 30; // /< the number of posts to display on a single page
		$args->page_count = 5; // /< the number of pages that appear in the page navigation
		
		$args->search_target = Context::get('search_target'); // /< search (title, contents ...)
		$args->search_keyword = Context::get('search_keyword'); // /< keyword to search
		if ($args->search_target === 'member_srl')
		{
			$logged_info = Context::get('logged_info');
			if ($logged_info->is_admin === 'Y' || intval($logged_info->member_srl) === intval($args->search_keyword))
			{
				$args->member_srl = array(intval($args->search_keyword), intval($args->search_keyword) * -1);
				unset($args->search_target, $args->search_keyword);
			}
		}

		$args->sort_index = 'list_order'; // /< sorting value

		$args->module_srl = Context::get('module_srl');

		// get a list
		$oDocumentModel = getModel('document');
		$columnList = array('document_srl', 'module_srl', 'title', 'member_srl', 'nick_name', 'readed_count', 'voted_count', 'blamed_count', 'regdate', 'ipaddress', 'status', 'category_srl');
		$output = $oDocumentModel->getDocumentList($args, false, true, $columnList);

		// get Status name list
		$statusNameList = $oDocumentModel->getStatusNameList();

		// Set values of document_model::getDocumentList() objects for a template
		Context::set('total_count', $output->total_count);
		Context::set('total_page', $output->total_page);
		Context::set('page', $output->page);
		Context::set('document_list', $output->data);
		Context::set('status_name_list', $statusNameList);
		Context::set('page_navigation', $output->page_navigation);

		// set a search option used in the template
		$count_search_option = count($this->search_option);
		for($i=0;$i<$count_search_option;$i++)
		{
			$search_option[$this->search_option[$i]] = lang($this->search_option[$i]);
		}
		Context::set('search_option', $search_option);

		// Module List
		$oModuleModel = getModel('module');
		$module_list = array();
		$mod_srls = array();
		foreach($output->data as $oDocument)
		{
			$mod_srls[] = $oDocument->get('module_srl');
		}
		$mod_srls = array_unique($mod_srls);
		$mod_srls_count = count($mod_srls);
		if($mod_srls_count)
		{
			$columnList = array('module_srl', 'mid', 'browser_title');
			$module_output = $oModuleModel->getModulesInfo($mod_srls, $columnList);
			if($module_output && is_array($module_output))
			{
				foreach($module_output as $module)
				{
					$module_list[$module->module_srl] = $module;
				}
			}
		}
		Context::set('module_list', $module_list);
		
		// Get anonymous nicknames
		$anonymous_member_srls = array();
		foreach($output->data as $oDocument)
		{
			if($oDocument->get('member_srl') < 0)
			{
				$anonymous_member_srls[] = abs($oDocument->get('member_srl'));
			}
		}
		if($anonymous_member_srls)
		{
			$member_args = new stdClass();
			$member_args->member_srl = $anonymous_member_srls;
			$member_output = executeQueryArray('member.getMembers', $member_args);
			if($member_output)
			{
				$member_nick_neme = array();
				foreach($member_output->data as $member)
				{
					$member_nick_neme[$member->member_srl] = $member->nick_name;
				}
			}
		}
		Context::set('member_nick_name', $member_nick_neme);

		$security = new Security();
		$security->encodeHTML('search_target', 'search_keyword');

		// Specify a template
		$this->setTemplatePath($this->module_path.'tpl');
		$this->setTemplateFile('document_list');
	}

	/**
	 * Set a document module
	 * @return void
	 */
	function dispDocumentAdminConfig()
	{
		$oDocumentModel = getModel('document');
		$config = $oDocumentModel->getDocumentConfig();
		Context::set('config',$config);

		$oModuleModel = getModel('module');
		$pcIconSkinList = $oModuleModel->getSkins($this->module_path . 'tpl', 'icons');
		$mobileIconSkinList = $oModuleModel->getSkins($this->module_path . 'tpl', 'micons');

		Context::set('pcIconSkinList', $pcIconSkinList);
		Context::set('mobileIconSkinList', $mobileIconSkinList);

		// Set the template file
		$this->setTemplatePath($this->module_path.'tpl');
		$this->setTemplateFile('document_config');
	}

	/**
	 * Display a report list on the admin page
	 * @return void
	 */
	function dispDocumentAdminDeclared()
	{
		// get Status name list
		$oDocumentModel = getModel('document');
		$statusNameList = $oDocumentModel->getStatusNameList();

		// option for a list
		$args = new stdClass();
		$args->page = Context::get('page'); // /< Page
		$args->list_count = 30; // /< the number of posts to display on a single page
		$args->page_count = 10; // /< the number of pages that appear in the page navigation
		$args->order_type = strtolower(Context::get('order_type')) === 'asc' ? 'asc' : 'desc';
		
		// get latest declared list
		if (Context::get('sort_index') === 'declared_latest')
		{
			$declared_output = executeQueryArray('document.getDeclaredLatest', $args);
			if ($declared_output->data && count($declared_output->data))
			{
				$args->document_srls = array_map(function($item) { return $item->document_srl; }, $declared_output->data);
				$documents = executeQueryArray('document.getDocuments', $args);
				$document_list = array();
				foreach ($declared_output->data as $key => $declared_info)
				{
					foreach ($documents->data as $document)
					{
						if ($document->document_srl == $declared_info->document_srl)
						{
							$document->declared_count = $declared_info->declared_count;
							$document->latest_declared = $declared_info->latest_declared;
							$document_list[$key] = new documentItem();
							$document_list[$key]->setAttribute($document);
							break;
						}
					}
				}
				$declared_output->data = $document_list;
			}
		}
		else
		{
			$declared_output = executeQueryArray('document.getDeclaredList', $args);
			if ($declared_output->data && count($declared_output->data))
			{
				$args->document_srls = array_map(function($item) { return $item->document_srl; }, $declared_output->data);
				$declared_latest = executeQueryArray('document.getDeclaredLatest', $args);
				$document_list = array();
				foreach ($declared_output->data as $key => $document)
				{
					foreach ($declared_latest->data as $key => $declared_info)
					{
						if ($document->document_srl == $declared_info->document_srl)
						{
							$document->declared_count = $declared_info->declared_count;
							$document->latest_declared = $declared_info->latest_declared;
							$document_list[$key] = new documentItem();
							$document_list[$key]->setAttribute($document);
						}
					}
				}
				$declared_output->data = $document_list;
			}
		}

		// Set values of document_model::getDocumentList() objects for a template
		Context::set('total_count', $declared_output->total_count);
		Context::set('total_page', $declared_output->total_page);
		Context::set('page', $declared_output->page);
		Context::set('document_list', $declared_output->data);
		Context::set('page_navigation', $declared_output->page_navigation);
		Context::set('status_name_list', $statusNameList);
		// Set the template
		$this->setTemplatePath($this->module_path.'tpl');
		$this->setTemplateFile('declared_list');
	}

	/**
	 * Display a reported post and log of reporting
	 * @return void
	 */
	function dispDocumentAdminDeclaredLogByDocumentSrl()
	{
		// option for a list
		$args = new stdClass;
		$args->page = Context::get('page'); // /< Page
		$args->list_count = 30; // /< the number of posts to display on a single page
		$args->page_count = 10; // /< the number of pages that appear in the page navigation
		$args->document_srl = intval(Context::get('target_srl'));


		// get Status name list
		$oDocumentModel = getModel('document');
		$oMemberModel = getModel('member');
		$oDocument = $oDocumentModel->getDocument($args->document_srl);

		$declared_output = executeQuery('document.getDeclaredLogByDocumentSrl', $args);
		if($declared_output->data && count($declared_output->data))
		{
			$reporter_list = array();

			foreach($declared_output->data as $key => $log)
			{
				$reporter_list[$log->member_srl] = $oMemberModel->getMemberInfoByMemberSrl($log->member_srl);
			}
		}

		// Set values of document_model::getDocumentList() objects for a template
		Context::set('total_count', $declared_output->total_count);
		Context::set('total_page', $declared_output->total_page);
		Context::set('page', $declared_output->page);
		Context::set('declare_log', $declared_output->data);
		Context::set('reporter_list', $reporter_list);
		Context::set('declared_document', $oDocument);
		Context::set('page_navigation', $declared_output->page_navigation);

		// Set the template
		$this->setLayoutFile('popup_layout');
		$this->setTemplatePath($this->module_path.'tpl');
		$this->setTemplateFile('declared_log');
	}

	/**
	 * Display a alias list on the admin page
	 * @return void
	 */
	function dispDocumentAdminAlias()
	{
		$args = new stdClass();
		$args->document_srl = Context::get('document_srl');
		if(!$args->document_srl) return $this->dispDocumentAdminList();

		$oModel = getModel('document');
		$oDocument = $oModel->getDocument($args->document_srl);
		if(!$oDocument->isExists()) return $this->dispDocumentAdminList();
		Context::set('oDocument', $oDocument);

		$output = executeQueryArray('document.getAliases', $args);
		if(!$output->data)
		{
			$aliases = array();
		}
		else
		{
			$aliases = $output->data; 
		}

		Context::set('aliases', $aliases);

		$this->setTemplatePath($this->module_path.'tpl');
		$this->setTemplateFile('document_alias');
	}

	/**
	 * Display a trash list on the admin page
	 * @return void
	 */
	function dispDocumentAdminTrashList()
	{
		// options for a list
		$args = new stdClass();
		$args->page = Context::get('page'); // /< Page
		$args->list_count = 30; // /< the number of posts to display on a single page
		$args->page_count = 10; // /< the number of pages that appear in the page navigation

		$args->sort_index = 'list_order'; // /< sorting values
		$args->order_type = 'desc'; // /< sorting values by order

		$args->module_srl = Context::get('module_srl');

		// get a list
		$oDocumentAdminModel = getAdminModel('document');
		$output = $oDocumentAdminModel->getDocumentTrashList($args);

		// Set values of document_admin_model::getDocumentTrashList() objects for a template
		Context::set('total_count', $output->total_count);
		Context::set('total_page', $output->total_page);
		Context::set('page', $output->page);
		Context::set('document_list', $output->data);
		Context::set('page_navigation', $output->page_navigation);
		// set the template
		$this->setTemplatePath($this->module_path.'tpl');
		$this->setTemplateFile('document_trash_list');
	}
}
/* End of file document.admin.view.php */
/* Location: ./modules/document/document.admin.view.php */
<commit_msg>Fix #1006 missing comment count in member document list<commit_after><?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
 * documentAdminView class
 * Document admin view of the module class
 *
 * @author NAVER (<EMAIL>)
 * @package /modules/document
 * @version 0.1
 */
class documentAdminView extends document
{
	/**
	 * Initialization
	 * @return void
	 */
	function init()
	{
		// check current location in admin menu
		$oModuleModel = getModel('module');
		$info = $oModuleModel->getModuleActionXml('document');
		foreach($info->menu AS $key => $menu)
		{
			if(in_array($this->act, $menu->acts))
			{
				Context::set('currentMenu', $key);
				break;
			}
		}
	}

	/**
	 * Display a list(administrative)
	 * @return void
	 */
	function dispDocumentAdminList()
	{
		// option to get a list
		$args = new stdClass();
		$args->page = Context::get('page'); // /< Page
		$args->list_count = 30; // /< the number of posts to display on a single page
		$args->page_count = 5; // /< the number of pages that appear in the page navigation
		
		$args->search_target = Context::get('search_target'); // /< search (title, contents ...)
		$args->search_keyword = Context::get('search_keyword'); // /< keyword to search
		if ($args->search_target === 'member_srl')
		{
			$logged_info = Context::get('logged_info');
			if ($logged_info->is_admin === 'Y' || intval($logged_info->member_srl) === intval($args->search_keyword))
			{
				$args->member_srl = array(intval($args->search_keyword), intval($args->search_keyword) * -1);
				unset($args->search_target, $args->search_keyword);
			}
		}

		$args->sort_index = 'list_order'; // /< sorting value

		$args->module_srl = Context::get('module_srl');

		// get a list
		$oDocumentModel = getModel('document');
		$columnList = array('document_srl', 'module_srl', 'category_srl', 'member_srl', 'title', 'nick_name', 'comment_count', 'trackback_count', 'readed_count', 'voted_count', 'blamed_count', 'regdate', 'ipaddress', 'status');
		$output = $oDocumentModel->getDocumentList($args, false, true, $columnList);

		// get Status name list
		$statusNameList = $oDocumentModel->getStatusNameList();

		// Set values of document_model::getDocumentList() objects for a template
		Context::set('total_count', $output->total_count);
		Context::set('total_page', $output->total_page);
		Context::set('page', $output->page);
		Context::set('document_list', $output->data);
		Context::set('status_name_list', $statusNameList);
		Context::set('page_navigation', $output->page_navigation);

		// set a search option used in the template
		$count_search_option = count($this->search_option);
		for($i=0;$i<$count_search_option;$i++)
		{
			$search_option[$this->search_option[$i]] = lang($this->search_option[$i]);
		}
		Context::set('search_option', $search_option);

		// Module List
		$oModuleModel = getModel('module');
		$module_list = array();
		$mod_srls = array();
		foreach($output->data as $oDocument)
		{
			$mod_srls[] = $oDocument->get('module_srl');
		}
		$mod_srls = array_unique($mod_srls);
		$mod_srls_count = count($mod_srls);
		if($mod_srls_count)
		{
			$columnList = array('module_srl', 'mid', 'browser_title');
			$module_output = $oModuleModel->getModulesInfo($mod_srls, $columnList);
			if($module_output && is_array($module_output))
			{
				foreach($module_output as $module)
				{
					$module_list[$module->module_srl] = $module;
				}
			}
		}
		Context::set('module_list', $module_list);
		
		// Get anonymous nicknames
		$anonymous_member_srls = array();
		foreach($output->data as $oDocument)
		{
			if($oDocument->get('member_srl') < 0)
			{
				$anonymous_member_srls[] = abs($oDocument->get('member_srl'));
			}
		}
		if($anonymous_member_srls)
		{
			$member_args = new stdClass();
			$member_args->member_srl = $anonymous_member_srls;
			$member_output = executeQueryArray('member.getMembers', $member_args);
			if($member_output)
			{
				$member_nick_neme = array();
				foreach($member_output->data as $member)
				{
					$member_nick_neme[$member->member_srl] = $member->nick_name;
				}
			}
		}
		Context::set('member_nick_name', $member_nick_neme);

		$security = new Security();
		$security->encodeHTML('search_target', 'search_keyword');

		// Specify a template
		$this->setTemplatePath($this->module_path.'tpl');
		$this->setTemplateFile('document_list');
	}

	/**
	 * Set a document module
	 * @return void
	 */
	function dispDocumentAdminConfig()
	{
		$oDocumentModel = getModel('document');
		$config = $oDocumentModel->getDocumentConfig();
		Context::set('config',$config);

		$oModuleModel = getModel('module');
		$pcIconSkinList = $oModuleModel->getSkins($this->module_path . 'tpl', 'icons');
		$mobileIconSkinList = $oModuleModel->getSkins($this->module_path . 'tpl', 'micons');

		Context::set('pcIconSkinList', $pcIconSkinList);
		Context::set('mobileIconSkinList', $mobileIconSkinList);

		// Set the template file
		$this->setTemplatePath($this->module_path.'tpl');
		$this->setTemplateFile('document_config');
	}

	/**
	 * Display a report list on the admin page
	 * @return void
	 */
	function dispDocumentAdminDeclared()
	{
		// get Status name list
		$oDocumentModel = getModel('document');
		$statusNameList = $oDocumentModel->getStatusNameList();

		// option for a list
		$args = new stdClass();
		$args->page = Context::get('page'); // /< Page
		$args->list_count = 30; // /< the number of posts to display on a single page
		$args->page_count = 10; // /< the number of pages that appear in the page navigation
		$args->order_type = strtolower(Context::get('order_type')) === 'asc' ? 'asc' : 'desc';
		
		// get latest declared list
		if (Context::get('sort_index') === 'declared_latest')
		{
			$declared_output = executeQueryArray('document.getDeclaredLatest', $args);
			if ($declared_output->data && count($declared_output->data))
			{
				$args->document_srls = array_map(function($item) { return $item->document_srl; }, $declared_output->data);
				$documents = executeQueryArray('document.getDocuments', $args);
				$document_list = array();
				foreach ($declared_output->data as $key => $declared_info)
				{
					foreach ($documents->data as $document)
					{
						if ($document->document_srl == $declared_info->document_srl)
						{
							$document->declared_count = $declared_info->declared_count;
							$document->latest_declared = $declared_info->latest_declared;
							$document_list[$key] = new documentItem();
							$document_list[$key]->setAttribute($document);
							break;
						}
					}
				}
				$declared_output->data = $document_list;
			}
		}
		else
		{
			$declared_output = executeQueryArray('document.getDeclaredList', $args);
			if ($declared_output->data && count($declared_output->data))
			{
				$args->document_srls = array_map(function($item) { return $item->document_srl; }, $declared_output->data);
				$declared_latest = executeQueryArray('document.getDeclaredLatest', $args);
				$document_list = array();
				foreach ($declared_output->data as $key => $document)
				{
					foreach ($declared_latest->data as $key => $declared_info)
					{
						if ($document->document_srl == $declared_info->document_srl)
						{
							$document->declared_count = $declared_info->declared_count;
							$document->latest_declared = $declared_info->latest_declared;
							$document_list[$key] = new documentItem();
							$document_list[$key]->setAttribute($document);
						}
					}
				}
				$declared_output->data = $document_list;
			}
		}

		// Set values of document_model::getDocumentList() objects for a template
		Context::set('total_count', $declared_output->total_count);
		Context::set('total_page', $declared_output->total_page);
		Context::set('page', $declared_output->page);
		Context::set('document_list', $declared_output->data);
		Context::set('page_navigation', $declared_output->page_navigation);
		Context::set('status_name_list', $statusNameList);
		// Set the template
		$this->setTemplatePath($this->module_path.'tpl');
		$this->setTemplateFile('declared_list');
	}

	/**
	 * Display a reported post and log of reporting
	 * @return void
	 */
	function dispDocumentAdminDeclaredLogByDocumentSrl()
	{
		// option for a list
		$args = new stdClass;
		$args->page = Context::get('page'); // /< Page
		$args->list_count = 30; // /< the number of posts to display on a single page
		$args->page_count = 10; // /< the number of pages that appear in the page navigation
		$args->document_srl = intval(Context::get('target_srl'));


		// get Status name list
		$oDocumentModel = getModel('document');
		$oMemberModel = getModel('member');
		$oDocument = $oDocumentModel->getDocument($args->document_srl);

		$declared_output = executeQuery('document.getDeclaredLogByDocumentSrl', $args);
		if($declared_output->data && count($declared_output->data))
		{
			$reporter_list = array();

			foreach($declared_output->data as $key => $log)
			{
				$reporter_list[$log->member_srl] = $oMemberModel->getMemberInfoByMemberSrl($log->member_srl);
			}
		}

		// Set values of document_model::getDocumentList() objects for a template
		Context::set('total_count', $declared_output->total_count);
		Context::set('total_page', $declared_output->total_page);
		Context::set('page', $declared_output->page);
		Context::set('declare_log', $declared_output->data);
		Context::set('reporter_list', $reporter_list);
		Context::set('declared_document', $oDocument);
		Context::set('page_navigation', $declared_output->page_navigation);

		// Set the template
		$this->setLayoutFile('popup_layout');
		$this->setTemplatePath($this->module_path.'tpl');
		$this->setTemplateFile('declared_log');
	}

	/**
	 * Display a alias list on the admin page
	 * @return void
	 */
	function dispDocumentAdminAlias()
	{
		$args = new stdClass();
		$args->document_srl = Context::get('document_srl');
		if(!$args->document_srl) return $this->dispDocumentAdminList();

		$oModel = getModel('document');
		$oDocument = $oModel->getDocument($args->document_srl);
		if(!$oDocument->isExists()) return $this->dispDocumentAdminList();
		Context::set('oDocument', $oDocument);

		$output = executeQueryArray('document.getAliases', $args);
		if(!$output->data)
		{
			$aliases = array();
		}
		else
		{
			$aliases = $output->data; 
		}

		Context::set('aliases', $aliases);

		$this->setTemplatePath($this->module_path.'tpl');
		$this->setTemplateFile('document_alias');
	}

	/**
	 * Display a trash list on the admin page
	 * @return void
	 */
	function dispDocumentAdminTrashList()
	{
		// options for a list
		$args = new stdClass();
		$args->page = Context::get('page'); // /< Page
		$args->list_count = 30; // /< the number of posts to display on a single page
		$args->page_count = 10; // /< the number of pages that appear in the page navigation

		$args->sort_index = 'list_order'; // /< sorting values
		$args->order_type = 'desc'; // /< sorting values by order

		$args->module_srl = Context::get('module_srl');

		// get a list
		$oDocumentAdminModel = getAdminModel('document');
		$output = $oDocumentAdminModel->getDocumentTrashList($args);

		// Set values of document_admin_model::getDocumentTrashList() objects for a template
		Context::set('total_count', $output->total_count);
		Context::set('total_page', $output->total_page);
		Context::set('page', $output->page);
		Context::set('document_list', $output->data);
		Context::set('page_navigation', $output->page_navigation);
		// set the template
		$this->setTemplatePath($this->module_path.'tpl');
		$this->setTemplateFile('document_trash_list');
	}
}
/* End of file document.admin.view.php */
/* Location: ./modules/document/document.admin.view.php */

{'fraction_non_alphanumeric': 0.16698284038975597, 'fraction_numerical': 0.0018970423385358283, 'mean_word_length': 4.521304451321114, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 305, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '118701', 'n_tokens_mistral': 8590, 'n_tokens_neox': 7530, 'n_words': 1410}