873 lines
		
	
	
		
			41 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			873 lines
		
	
	
		
			41 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| /**
 | |
|  * @version		1.0.0 tabulizer $
 | |
|  * @package		tabulizer
 | |
|  * @copyright	Copyright © 2011 - All rights reserved.
 | |
|  * @license		GNU/GPL
 | |
|  * @author		Dimitrios Mourloukos
 | |
|  * @author mail	info@alterora.gr
 | |
|  * @website		www.alterora.gr
 | |
|  *
 | |
|  *
 | |
|  * @MVC architecture generated by MVC generator tool at http://www.alphaplug.com
 | |
|  */
 | |
| 
 | |
| // no direct access
 | |
| defined('_JEXEC') or die('Restricted access');
 | |
| 
 | |
| jimport( 'joomla.application.component.view' );
 | |
| 
 | |
| class tabulizerViewDatasources extends JViewLegacy
 | |
| {
 | |
| 	function __construct(){
 | |
| 		// add tabulizer CSS to override form styling
 | |
| 		$doc=JFactory::getDocument();
 | |
| 		$cssfile = TabulizerPath::getURLPath('tabulizer.css', 'admin_css');		
 | |
| 		$doc->addStyleSheet($cssfile);
 | |
| 		
 | |
| 		TabulizerPath::requireLib('data_source','common');
 | |
| 		
 | |
| 		parent::__construct();		
 | |
| 	}
 | |
| 
 | |
| 	function display($tpl = null){
 | |
|         $jinput = JFactory::getApplication()->input;
 | |
| 		$option = $jinput->getCmd('option');
 | |
|         $return_urls = null;
 | |
| 		
 | |
| 		$model = $this->getModel();
 | |
| 		$data_sources = $model->getDataSources();
 | |
|         $pagination = $model->getPagination();
 | |
| 		$model->getReturnURLs($return_urls);				
 | |
| 		
 | |
| 		$this->assignRef('data_sources', $data_sources);
 | |
| 		$this->assignRef('return_urls', $return_urls);
 | |
| 	    $this->assignRef('pagination', $pagination);
 | |
| 				
 | |
| 		parent::display($tpl);
 | |
| 	}					
 | |
| 	
 | |
| 	function displayPreview($tpl = null) {
 | |
|         $jinput = JFactory::getApplication()->input;
 | |
| 		$option = $jinput->getCmd('option');
 | |
|         $return_urls = null;
 | |
| 		
 | |
| 		TabulizerPath::requireLib('ruleset','admin');
 | |
| 		
 | |
| 		$model = $this->getModel();
 | |
| 		$model->getReturnURLs($return_urls);	
 | |
| 		$data_source = $model->getDataSource();
 | |
| 		
 | |
| 		TabulizerDataSource::decodeParams($data_source->source_type, $data_source->source_params, $source_params, $errors);
 | |
| 		
 | |
| 		$ruleset = new Ruleset();		
 | |
| 		$selected_ruleset = $ruleset->getRuleset($source_params['ruleset_name'], $source_params['ruleset_archive']);
 | |
| 		if (empty($selected_ruleset)) {
 | |
| 			$error_msg = sprintf(JText::_('COM_TABULIZER_DATA_SOURCE_ERROR_RULESET_NOT_FOUND'),$source_params['ruleset_archive'],$source_params['ruleset_name']);
 | |
| 			TabulizerUserMessage::printError($error_msg);
 | |
| 			return;
 | |
| 		} 				
 | |
| 				
 | |
| 		$this->assignRef('ruleset', $selected_ruleset);
 | |
| 		$this->assignRef('data_source', $data_source);		
 | |
| 		$this->assignRef('return_urls', $return_urls);						
 | |
| 		
 | |
| 		parent::display($tpl);		
 | |
| 	}
 | |
| 
 | |
| 	function displayNew($tpl = null) {
 | |
|         $jinput = JFactory::getApplication()->input;
 | |
| 		$option = $jinput->getCmd('option');
 | |
|         $return_urls = null;
 | |
| 		
 | |
| 		$model = $this->getModel();
 | |
| 		$model->getReturnURLs($return_urls);	
 | |
| 		
 | |
| 		$default_source_type = 'csv';
 | |
| 		$default_source_params = "strip_tags=1\nremove_empty=1";
 | |
| 			
 | |
| 		$lists = array();	
 | |
| 												
 | |
| 		$lists['edit'] = false;
 | |
| 
 | |
|         $lists['id'] = '<input type="hidden" name="ds_id" id="ds_id" value="">';
 | |
| 		
 | |
| 		$lists['title'] = TabulizerForm::getTextCtrl('ds_title', null, array('class'=>'ds_param_wide'));
 | |
| 		
 | |
| 		$random_tag = TabulizerString::generateRandomString(24);
 | |
| 		$lists['tag'] = TabulizerForm::getTextCtrl("ds_tag",$random_tag, array('readonly'=>'readonly')) . ' <span class="tip">'.JText::_('COM_TABULIZER_DATA_SOURCE_TAG_TIP').'</span>';
 | |
| 						
 | |
| 		$options = TabulizerDataSource::getSourceTypeLabel();
 | |
| 		$attributes = array('onchange'=>'updateSourceParams()');
 | |
| 		$lists['source_type'] = TabulizerForm::getSelectCtrl('ds_source_type',$default_source_type,$options,$attributes);		
 | |
| 		
 | |
| 		$default_cache_type = TABULIZER_DATA_SOURCE_DEFAULT_CACHE_TYPE; 
 | |
| 		$options = array(TABULIZER_DATA_SOURCE_CACHE_OFF => JText::_('COM_TABULIZER_DATA_SOURCE_CACHE_OFF'), TABULIZER_DATA_SOURCE_CACHE_ON => JText::_('COM_TABULIZER_DATA_SOURCE_CACHE_ON'));
 | |
| 		$attributes = array('onchange'=>'updateCacheType()');
 | |
| 		$cache_type = TabulizerForm::getSelectCtrl('ds_cache_type',$default_cache_type,$options,$attributes);		
 | |
| 	
 | |
| 		$default_cache_time = TABULIZER_DATA_SOURCE_DEFAULT_CACHE_TIME; // minutes	
 | |
| 		$attributes = ($default_cache_type==TABULIZER_DATA_SOURCE_CACHE_OFF)?array('disabled'=>'disabled'):array();
 | |
| 		$cache_time = TabulizerForm::getTextCtrl('ds_cache_time',$default_cache_time,$attributes). ' <span class="tip">'.JText::_('COM_TABULIZER_DATA_SOURCE_CACHE_TIME_TIP').'</span>';								
 | |
| 		
 | |
| 		$lists['cache_params'] = '<table><tr><td class="ds_param_label">'.JText::_('COM_TABULIZER_DATA_SOURCE_CACHE_TYPE').': </td><td>'.$cache_type.'</td></tr><tr><td class="ds_param_label">'.JText::_('COM_TABULIZER_DATA_SOURCE_CACHE_TIME').': </td><td>'.$cache_time.'</td></tr></table>';
 | |
| 		
 | |
| 		$source_params = array(
 | |
| 						'ruleset_archive' => null,
 | |
| 						'ruleset_name' => null,
 | |
|                         'table_caption' => null,
 | |
|                         'table_summary' => null,
 | |
|                         'server_side' => null,
 | |
| 						'filepath'=> null,
 | |
|                         'encoding'=> null,
 | |
|                         'feed_type'=> null,
 | |
| 						'article_id'=>null,	
 | |
| 						'query'=> null,
 | |
|                         'edb_driver'=>'mysqli',
 | |
|                         'edb_host'=>'localhost',
 | |
|                         'edb_user'=>null,
 | |
|                         'edb_password'=>null,
 | |
|                         'edb_database'=>null,
 | |
|                         'edb_prefix'=>null,
 | |
| 						'sheet_name'=> null,
 | |
| 						'sheet_selection'=> null,
 | |
|                         'sheet_references'=>null,
 | |
| 						'read_font'=> null,	
 | |
| 						'read_color'=> null,	
 | |
| 						'read_images'=> null,	
 | |
| 						'read_hyperlinks'=> null,
 | |
|                         'boost'=>null,
 | |
|                         'cellcache'=>null,
 | |
| 						'remove_empty'=> null,	
 | |
| 						'separator'=> null,
 | |
| 						'enclosure'=> null,
 | |
| 						'consistency'=>null,
 | |
| 						'strip_tags'=>null,
 | |
| 						'table_order'=> null,
 | |
| 						'table_attribute_name'=> null,
 | |
| 						'table_attribute_value'=> null,
 | |
|                         'merging_tree'=> null,
 | |
|                         'td_map'=>null);
 | |
| 								
 | |
| 		TabulizerDataSource::decodeParams($default_source_type, $default_source_params, $source_params, $errors);				
 | |
| 		
 | |
| 		TabulizerPath::requireLib('ruleset','admin');				
 | |
| 		$rs = new Ruleset();
 | |
| 		$ruleset_archive_options = array(0=>JText::_('COM_TABULIZER_NONE'));
 | |
| 		$ruleset_name_options = array();
 | |
| 		$archive_to_rulesets = '';
 | |
| 
 | |
| 		$ruleset_archives = $rs->loadRulesets(null, 0, 0, $total_count);
 | |
| 		if ($total_count) {
 | |
| 			$ruleset_archives = $rs->getRulesets(null, 0, 0, $total_count);
 | |
|             uasort($ruleset_archives, array($this,'sortArrayByTitle'));
 | |
| 			foreach ($ruleset_archives as $ruleset_archive) {
 | |
| 				$ruleset_archive_options[$ruleset_archive['filename']] = $ruleset_archive['title'];
 | |
| 				if (!empty($ruleset_archive['rulesets'])) {
 | |
|                     $rulesets = $ruleset_archive['rulesets'];
 | |
|                     uasort($rulesets, array($this,'sortArrayByTitle'));
 | |
| 					$archive_to_ruleset_entries = array();
 | |
| 					foreach ($rulesets as $ruleset_name => $ruleset) {
 | |
| 						if ($source_params['ruleset_archive'] == $ruleset_archive['filename']) {
 | |
| 							$ruleset_name_options[$ruleset['name']] = $ruleset['title'];
 | |
| 						}
 | |
| 						$archive_to_ruleset_entries[] = '"'.$ruleset['name'].'": "'.htmlspecialchars($ruleset['title'],ENT_COMPAT,'UTF-8'). '"';
 | |
| 					}					
 | |
| 					if (!empty($archive_to_ruleset_entries)) $archive_to_rulesets .= '		archive_to_rulesets["'.$ruleset_archive['filename'].'"] = {'.implode(',',$archive_to_ruleset_entries).'};' . "\n";
 | |
| 				}
 | |
| 			}
 | |
| 		}
 | |
| 		if (empty($ruleset_name_options)) $ruleset_name_options = array(0=>JText::_('COM_TABULIZER_NONE'));						
 | |
| 		$this->assignRef('archive_to_rulesets', $archive_to_rulesets);				
 | |
| 		
 | |
| 		$labels = TabulizerDataSource::getSourceParamsLabel();
 | |
|         $tips = TabulizerDataSource::getSourceParamsTip();
 | |
| 
 | |
| 		$source_params_html = '<table>';				
 | |
| 		foreach ($source_params as $key => $value) {			
 | |
| 			switch ($key) {
 | |
| 				case 'ruleset_archive':
 | |
| 					$html_value = TabulizerForm::getSelectCtrl('ds_'.$key, $source_params[$key], $ruleset_archive_options, array('onchange'=>'TabulizerUpdateRulesetArchive(this)', 'class'=>'ds_param_wide'));
 | |
| 					break;
 | |
| 				case 'ruleset_name':
 | |
| 					$html_value = TabulizerForm::getSelectCtrl('ds_'.$key, $source_params[$key], $ruleset_name_options, array('class'=>'ds_param_wide'));
 | |
| 					break;
 | |
|                 case 'table_caption':
 | |
|                     $attributes = array('maxlength'=>TABLE_CAPTION_MAX_LEN,'class'=>'ds_param_wide');
 | |
|                     $html_value = TabulizerForm::getInputCtrl('ds_'.$key, $source_params[$key],$attributes);
 | |
|                     $tip = '<br style="clear: both"><div class="tipdiv">'.JText::_('COM_TABULIZER_DATA_SOURCE_PARAM_TABLE_CAPTION_TIP').'</div>';
 | |
|                     $html_value .= $tip;
 | |
|                     break;
 | |
|                 case 'table_summary':
 | |
|                     $attributes = array('maxlength'=>TABLE_CAPTION_MAX_LEN, 'style'=>'width:98%; height: 80px;');
 | |
|                     $html_value = TabulizerForm::getTextareaCtrl('ds_'.$key, $source_params[$key],$attributes);
 | |
|                     break;
 | |
|                 case 'server_side':
 | |
|                     $checked = empty($value)?false:true;
 | |
|                     $html_value = TabulizerForm::getCheckboxCtrl('ds_'.$key, '1', $checked, array());
 | |
|                     break;
 | |
| 				case 'article_id':
 | |
| 					$html_value = $this->getArticleSelectionInput('ds_'.$key, $source_params[$key]);
 | |
| 					break;
 | |
|                 case 'filepath':
 | |
|                     $html_value = TabulizerForm::getTextCtrl('ds_'.$key,$value,array('class'=>'ds_param_extra_wide')); // '<input type="text" name="ds_'.$key.'" id="ds_'.$key.'" value="'.$value.'" class="ds_param_wide" />';
 | |
|                     $site_path = TabulizerPath::getDirPath('site_root');
 | |
|                     $data_path = TabulizerPath::getDirPath('data');
 | |
|                     $data_manage = JRoute::_('index.php?option=com_tabulizer&task=manageDataFiles');
 | |
|                     $tip = '<br style="clear: both"><div class="tipdiv">'.sprintf(JText::_('COM_TABULIZER_DATA_SOURCE_FILEPATH_TIP'),$site_path,$site_path,$site_path,$data_path,$data_manage).'</div>';
 | |
|                     $html_value .= $tip;
 | |
|                     break;
 | |
|                 case 'encoding':
 | |
|                     $html_value = TabulizerForm::getTextCtrl('ds_'.$key,$value); // '<input type="text" name="ds_'.$key.'" id="ds_'.$key.'" value="'.$value.'" class="ds_param_wide" />';
 | |
|                     $tip = '<br style="clear: both"><div class="tipdiv">'.JText::_('COM_TABULIZER_DATA_SOURCE_ENCODING_TIP').'</div>';
 | |
|                     $html_value .= $tip;
 | |
|                     break;
 | |
|                 case 'feed_type':
 | |
|                     $feed_types = array('rss2'=>'RSS 2.0','atom'=>'Atom');
 | |
|                     $html_value = TabulizerForm::getSelectCtrl('ds_'.$key,$value,$feed_types);
 | |
|                     break;
 | |
| 				case 'query':
 | |
|                     $html_value = TabulizerForm::getTextareaCtrl('ds_'.$key,$value,array('style'=>'width:98%; height:120px;')); // '<input type="text" name="ds_'.$key.'" id="ds_'.$key.'" value="'.$value.'" class="ds_param_wide" />';
 | |
|                     break;
 | |
|                 case 'edb_driver':
 | |
|                     $html_value = TabulizerForm::getTextCtrl('ds_'.$key,$value,array('class'=>'ds_param_wide'));
 | |
|                     $supported_drivers = array('mysql','mysqli');
 | |
|                     if (class_exists('PDO')) {
 | |
|                         $drivers = PDO::getAvailableDrivers();
 | |
|                         if (!empty($drivers)) {
 | |
|                             foreach ($drivers as $driver) {
 | |
|                                 $supported_drivers[] = $driver;
 | |
|                             }
 | |
|                         }
 | |
|                     }
 | |
|                     $supported_drivers_str = implode(', ',$supported_drivers);
 | |
|                     $tip = sprintf(JText::_('COM_TABULIZER_DATA_SOURCE_EXTERNAL_DATABASE_SUPPORTED_DRIVERS'),$supported_drivers_str);
 | |
|                     $html_value .= '<br style="clear: both" /><div class="tipdiv">'.$tip.'</div>';
 | |
|                     break;
 | |
|                 case 'edb_host':
 | |
|                 case 'edb_user':
 | |
|                 case 'edb_password':
 | |
|                 case 'edb_database':
 | |
|                 case 'edb_prefix':
 | |
|                     $html_value = TabulizerForm::getTextCtrl('ds_'.$key,$value,array('class'=>'ds_param_wide'));
 | |
|                     break;
 | |
| 				case 'sheet_name':
 | |
| 				case 'sheet_selection':				
 | |
| 				case 'table_attribute_value':
 | |
|                 case 'merging_tree':
 | |
| 					$html_value = TabulizerForm::getTextCtrl('ds_'.$key,$value,array('class'=>'ds_param_wide')); // '<input type="text" name="ds_'.$key.'" id="ds_'.$key.'" value="'.$value.'" class="ds_param_wide" />';
 | |
| 					break;
 | |
|                 case 'td_map':
 | |
|                     $html_value = TabulizerForm::getTextareaCtrl('ds_'.$key,$value,array('style'=>'width:98%; height:120px;'));
 | |
|                     break;
 | |
|                 case 'sheet_references':
 | |
|                     $sheet_references_custom_style ='none';
 | |
|                     $attr_none = array('onclick'=>'TabulizerUpdateSheetReferences(this)', 'style'=>'float:none');
 | |
|                     $attr_all = array('onclick'=>'TabulizerUpdateSheetReferences(this)', 'style'=>'float:none');
 | |
|                     $attr_custom = array('onclick'=>'TabulizerUpdateSheetReferences(this)', 'style'=>'float:none');
 | |
|                     if (empty($value)) {
 | |
|                         $attr_none['checked'] = 'checked';
 | |
|                     } else if ($value == 'all') {
 | |
|                         $attr_all['checked'] = 'checked';
 | |
|                     } else {
 | |
|                         $attr_custom['checked'] = 'checked';
 | |
|                         $sheet_references_custom_style ='block';
 | |
|                     }
 | |
|                     $html_value = TabulizerForm::getInputCtrl('ds_sheet_references_type', 'none', $attr_none, 'radio') . ' ' . JText::_('COM_TABULIZER_SHEET_REFERENCES_NONE') . '   ' .
 | |
|                         TabulizerForm::getInputCtrl('ds_sheet_references_type', 'all', $attr_all, 'radio') . ' ' . JText::_('COM_TABULIZER_SHEET_REFERENCES_ALL') . '   ' .
 | |
|                         TabulizerForm::getInputCtrl('ds_sheet_references_type', 'custom', $attr_custom, 'radio') . ' ' . JText::_('COM_TABULIZER_SHEET_REFERENCES_CUSTOM') .
 | |
|                         '<div id="ds_sheet_references_custom" style="display:'.$sheet_references_custom_style.'">' .
 | |
|                         TabulizerForm::getTextCtrl('ds_'.$key,$value,array('class'=>'ds_param_wide')) .
 | |
|                         '</div>';
 | |
|                     break;
 | |
| 				case 'table_attribute_name':
 | |
| 					$options = array(0=>JText::_('COM_TABULIZER_NONE'),'id'=>'id','name'=>'name','class'=>'class');
 | |
| 					$html_value = TabulizerForm::getSelectCtrl('ds_'.$key,$source_params[$key],$options);	
 | |
| 					break;	
 | |
| 				case 'table_order':
 | |
| 					$options = array();
 | |
| 					for ($j=1;$j<=32;$j++) $options[$j] = $j;
 | |
| 					$html_value = TabulizerForm::getSelectCtrl('ds_'.$key,$source_params[$key],$options);				
 | |
| 					break;
 | |
| 				case 'separator':					
 | |
| 					$options = TabulizerUtils::getSeparatorListLabels();
 | |
| 					$html_value = TabulizerForm::getSelectCtrl('ds_'.$key,$value,$options);				
 | |
| 					break;
 | |
| 				case 'enclosure':
 | |
| 					$options = array(ENCLOSURE_NONE=>JText::_('COM_TABULIZER_NO_ENCLOSURE'),
 | |
| 								     ENCLOSURE_DOUBLE_QUOTES=>JText::_('COM_TABULIZER_DOUBLE_QUOTES_ENCLOSURE'),
 | |
|    				 					ENCLOSURE_SINGLE_QUOTES=>JText::_('COM_TABULIZER_SINGLE_QUOTES_ENCLOSURE'));
 | |
| 					$html_value = TabulizerForm::getSelectCtrl('ds_'.$key,$source_params[$key],$options);
 | |
| 					break;
 | |
| 				case 'consistency':
 | |
| 					$options = array(1 => JText::_('COM_TABULIZER_COLUMN_CONSISTENCY_STRICT'),
 | |
| 					  				 0 => JText::_('COM_TABULIZER_COLUMN_CONSISTENCY_LOOSE'));
 | |
| 					$html_value = TabulizerForm::getSelectCtrl('ds_'.$key,$source_params[$key],$options); 
 | |
| 					break;
 | |
|                 case 'boost':
 | |
|                     $options = array(BOOST_NONE => JText::_('COM_TABULIZER_BOOST_NONE'),
 | |
|                         BOOST_NO_EXT => JText::_('COM_TABULIZER_BOOST_NOEXT'),
 | |
|                         BOOST_XLSX_PARSER => JText::_('COM_TABULIZER_XLSX_PARSER')
 | |
|                     );
 | |
|                     $html_value = TabulizerForm::getSelectCtrl('ds_'.$key,$source_params[$key],$options);
 | |
|                     break;
 | |
|                 case 'cellcache':
 | |
|                     $options = array(CELLCACHE_NONE => JText::_('COM_TABULIZER_CELLCACHE_NONE'),
 | |
|                         CELLCACHE_SQLITE3 => JText::_('COM_TABULIZER_CELLCACHE_SQLITE3')
 | |
|                     );
 | |
|                     $html_value = TabulizerForm::getSelectCtrl('ds_'.$key,$source_params[$key],$options);
 | |
|                     break;
 | |
| 				case 'read_font':
 | |
| 				case 'read_color':
 | |
| 				case 'read_images':
 | |
| 				case 'read_hyperlinks':
 | |
| 				case 'remove_empty':
 | |
| 				case 'strip_tags':
 | |
| 					$value = empty($value)?false:true;
 | |
| 					$html_value = TabulizerForm::getCheckboxCtrl('ds_'.$key, 1, $value);
 | |
| 					break;
 | |
| 				default:
 | |
| 					$html_value = null;	
 | |
| 			}
 | |
| 
 | |
|             if (isset($tips[$key])) $tip = TabulizerUtils::opentip($tips[$key], $labels[$key]); else $tip = '';
 | |
| 			if (isset($html_value)) $source_params_html .= '<tr id="tr_'.$key.'" class="'.$this->getShowHideClass($default_source_type, $key).'"><td class="ds_param_label">'.$labels[$key].$tip.': </td><td>'.$html_value.'</td></tr>';
 | |
| 		}				
 | |
| 		$source_params_html .= '</table>';				
 | |
| 								
 | |
| 		$lists['source_params'] = $source_params_html;								
 | |
| 								
 | |
| 		$this->assignRef('lists', $lists);		
 | |
| 		$this->assignRef('return_urls', $return_urls);						
 | |
| 		
 | |
| 		parent::display($tpl);	
 | |
| 	}
 | |
| 
 | |
| 	function displayEdit($tpl = null){
 | |
|         $jinput = JFactory::getApplication()->input;
 | |
|         $jinput = JFactory::getApplication()->input;
 | |
| 		$option = $jinput->getCmd('option');
 | |
|         $return_urls = null;
 | |
| 		
 | |
| 		$model = $this->getModel();
 | |
| 		$model->getReturnURLs($return_urls);	
 | |
| 		$data_source = $model->getDataSource();
 | |
| 			
 | |
| 		$lists = array();	
 | |
| 												
 | |
| 		$lists['edit'] = true;
 | |
| 		$lists['id'] = '<input type="hidden" name="ds_id" id="ds_id" value="'.$data_source->id.'">';
 | |
| 		$lists['title'] = TabulizerForm::getTextCtrl('ds_title', $data_source->title, array('class'=>'ds_param_wide'));
 | |
| 		$lists['tag'] = TabulizerForm::getTextCtrl('ds_tag', $data_source->tag, array('readonly'=>'readonly')) . ' <span class="tip">'.JText::_('COM_TABULIZER_DATA_SOURCE_TAG_TIP').'</span>';
 | |
| 				
 | |
| 		$options = array(TABULIZER_DATA_SOURCE_CACHE_OFF => JText::_('COM_TABULIZER_DATA_SOURCE_CACHE_OFF'), TABULIZER_DATA_SOURCE_CACHE_ON => JText::_('COM_TABULIZER_DATA_SOURCE_CACHE_ON'));
 | |
| 		$attributes = array('onchange'=>'updateCacheType()');
 | |
| 		$cache_type = TabulizerForm::getSelectCtrl('ds_cache_type',$data_source->cache_type,$options,$attributes);		
 | |
| 		
 | |
| 		if ($data_source->cache_type!=TABULIZER_DATA_SOURCE_CACHE_OFF) {
 | |
| 			$cache_clear_url = str_replace('&','&',JRoute::_('index.php?option=com_tabulizer&task=clearDataSourceCache&ds_id='.$data_source->id));
 | |
| 			if (!empty($return_urls['data_sources'])) $cache_clear_url .= '&data_sources_return_url='.urlencode($return_urls['data_sources']);
 | |
| 			$cache_type .= ' <a href="'.$cache_clear_url.'">'.JText::_('COM_TABULIZER_DATA_SOURCE_CACHE_CLEAR').'</a>'; 
 | |
| 		}
 | |
| 	
 | |
| 		$attributes = ($data_source->cache_type==TABULIZER_DATA_SOURCE_CACHE_OFF)?array('disabled'=>'disabled'):array();
 | |
| 		$cache_time = TabulizerForm::getTextCtrl('ds_cache_time',$data_source->cache_time,$attributes). ' <span class="tip">'.JText::_('COM_TABULIZER_DATA_SOURCE_CACHE_TIME_TIP').'</span>';						
 | |
| 		
 | |
| 		$lists['cache_params'] = '<table><tr><td class="ds_param_label">'.JText::_('COM_TABULIZER_DATA_SOURCE_CACHE_TYPE').': </td><td>'.$cache_type.'</td></tr><tr><td class="ds_param_label">'.JText::_('COM_TABULIZER_DATA_SOURCE_CACHE_TIME').': </td><td>'.$cache_time.'</td></tr></table>';
 | |
| 		
 | |
| 		$options = TabulizerDataSource::getSourceTypeLabel();
 | |
| 		$attributes = array('onchange'=>'updateSourceParams()');
 | |
| 		$lists['source_type'] = TabulizerForm::getSelectCtrl('ds_source_type',$data_source->source_type,$options,$attributes);		
 | |
| 				
 | |
| 		$source_params = array(
 | |
| 						'ruleset_archive' => null,
 | |
| 						'ruleset_name' => null,
 | |
|                         'table_caption'=>null,
 | |
|                         'table_summary'=>null,
 | |
|                         'server_side' => null,
 | |
| 						'filepath'=> null,
 | |
|                         'encoding'=> null,
 | |
|                         'feed_type'=>null,
 | |
| 						'article_id'=>null,	
 | |
| 						'query'=> null,
 | |
|                         'edb_driver'=>null,
 | |
|                         'edb_host'=>null,
 | |
|                         'edb_user'=>null,
 | |
|                         'edb_password'=>null,
 | |
|                         'edb_database'=>null,
 | |
|                         'edb_prefix'=>null,
 | |
| 						'sheet_name'=> null,
 | |
|                         'sheet_references'=>null,
 | |
| 						'sheet_selection'=> null,					
 | |
| 						'read_font'=> null,	
 | |
| 						'read_color'=> null,	
 | |
| 						'read_images'=> null,	
 | |
| 						'read_hyperlinks'=> null,
 | |
|                         'boost'=> null,
 | |
|                         'cellcache'=> null,
 | |
| 						'remove_empty'=> null,	
 | |
| 						'separator'=> null,
 | |
| 						'enclosure'=> null,
 | |
| 						'consistency'=>null,
 | |
| 						'strip_tags'=>null,
 | |
| 						'table_order'=> null,
 | |
| 						'table_attribute_name'=> null,
 | |
| 						'table_attribute_value'=> null,
 | |
|                         'merging_tree'=> null,
 | |
|                         'td_map'=>null);
 | |
| 		
 | |
| 		TabulizerDataSource::decodeParams($data_source->source_type, $data_source->source_params, $source_params, $errors);				
 | |
| 		
 | |
| 		TabulizerPath::requireLib('ruleset','admin');				
 | |
| 		$rs = new Ruleset();
 | |
| 		$ruleset_archive_options = array(0=>JText::_('COM_TABULIZER_NONE'));
 | |
| 		$ruleset_name_options = array();
 | |
| 		$archive_to_rulesets = '';
 | |
| 
 | |
| 		$ruleset_archives = $rs->loadRulesets(null, 0, 0, $total_count);
 | |
| 		if ($total_count) {
 | |
|             $ruleset_archives = $rs->getRulesets(null, 0, 0, $total_count);
 | |
|             uasort($ruleset_archives, array($this,'sortArrayByTitle'));
 | |
| 			foreach ($ruleset_archives as $ruleset_archive) {
 | |
| 				$ruleset_archive_options[$ruleset_archive['filename']] = $ruleset_archive['title'];
 | |
| 				if (!empty($ruleset_archive['rulesets'])) {
 | |
|                     $rulesets = $ruleset_archive['rulesets'];
 | |
|                     uasort($rulesets, array($this,'sortArrayByTitle'));
 | |
| 					$archive_to_ruleset_entries = array();
 | |
| 					foreach ($rulesets as $ruleset_name => $ruleset) {
 | |
| 						if ($source_params['ruleset_archive'] == $ruleset_archive['filename']) {
 | |
| 							$ruleset_name_options[$ruleset['name']] = $ruleset['title'];
 | |
| 						}
 | |
| 						$archive_to_ruleset_entries[] = '"'.$ruleset['name'].'": "'.htmlspecialchars($ruleset['title'],ENT_COMPAT,'UTF-8'). '"';
 | |
| 					}					
 | |
| 					if (!empty($archive_to_ruleset_entries)) $archive_to_rulesets .= '		archive_to_rulesets["'.$ruleset_archive['filename'].'"] = {'.implode(',',$archive_to_ruleset_entries).'};' . "\n";
 | |
| 				}
 | |
| 			}
 | |
| 		}
 | |
| 		if (empty($ruleset_name_options)) $ruleset_name_options = array(0=>JText::_('COM_TABULIZER_NONE'));						
 | |
| 		$this->assignRef('archive_to_rulesets', $archive_to_rulesets);				
 | |
| 		
 | |
| 		$labels = TabulizerDataSource::getSourceParamsLabel();
 | |
|         $tips = TabulizerDataSource::getSourceParamsTip();
 | |
| 		$source_params_html = '<table>';				
 | |
| 		foreach ($source_params as $key => $value) {			
 | |
| 			switch ($key) {
 | |
| 				case 'ruleset_archive':
 | |
| 					$html_value = TabulizerForm::getSelectCtrl('ds_'.$key, $source_params[$key], $ruleset_archive_options, array('onchange'=>'TabulizerUpdateRulesetArchive(this)', 'class'=>'ds_param_wide'));
 | |
| 					break;
 | |
| 				case 'ruleset_name':
 | |
| 					$html_value = TabulizerForm::getSelectCtrl('ds_'.$key, $source_params[$key], $ruleset_name_options, array('class'=>'ds_param_wide'));
 | |
| 					break;
 | |
|                 case 'table_caption':
 | |
|                     $attributes = array('maxlength'=>TABLE_CAPTION_MAX_LEN,'class'=>'ds_param_wide');
 | |
|                     $html_value = TabulizerForm::getInputCtrl('ds_'.$key, $source_params[$key],$attributes);
 | |
|                     break;
 | |
|                 case 'table_summary':
 | |
|                     $attributes = array('maxlength'=>TABLE_CAPTION_MAX_LEN, 'style'=>'width:98%;height:80px;');
 | |
|                     $html_value = TabulizerForm::getTextareaCtrl('ds_'.$key, $source_params[$key],$attributes);
 | |
|                     break;
 | |
|                 case 'server_side':
 | |
|                     $checked = empty($value)?false:true;
 | |
|                     $html_value = TabulizerForm::getCheckboxCtrl('ds_'.$key, '1', $checked, array());
 | |
|                     break;
 | |
| 				case 'article_id':
 | |
| 					$html_value = $this->getArticleSelectionInput('ds_'.$key, $source_params[$key]);									
 | |
| 					break;			  
 | |
| 				case 'filepath':
 | |
|                 case 'encoding':
 | |
| 				case 'sheet_name':
 | |
| 				case 'sheet_selection':				
 | |
| 				case 'table_attribute_value':
 | |
|                 case 'merging_tree':
 | |
| 					$html_value = TabulizerForm::getTextCtrl('ds_'.$key, $value, array('class'=>'ds_param_wide'));
 | |
| 					break;
 | |
|                 case 'td_map':
 | |
|                     $html_value = TabulizerForm::getTextareaCtrl('ds_'.$key, $value, array('style'=>'width:98%; height:120px;'));
 | |
|                     break;
 | |
|                 case 'feed_type':
 | |
|                     $feed_types = array('rss2'=>'RSS 2.0','atom'=>'Atom');
 | |
|                     $html_value = TabulizerForm::getSelectCtrl('ds_'.$key, $value, $feed_types);
 | |
|                     break;
 | |
|                 case 'query':
 | |
|                     $html_value = TabulizerForm::getTextareaCtrl('ds_'.$key, $value, array('style'=>'width:98%; height:120px;'));
 | |
|                     break;
 | |
|                 case 'edb_driver':
 | |
|                     $html_value = TabulizerForm::getTextCtrl('ds_'.$key,$value,array('class'=>'ds_param_wide'));
 | |
|                     $supported_drivers = array('mysql','mysqli');
 | |
|                     if (class_exists('PDO')) {
 | |
|                         $drivers = PDO::getAvailableDrivers();
 | |
|                         if (!empty($drivers)) {
 | |
|                             foreach ($drivers as $driver) {
 | |
|                                 $supported_drivers[] = $driver;
 | |
|                             }
 | |
|                         }
 | |
|                     }
 | |
|                     $supported_drivers_str = implode(', ',$supported_drivers);
 | |
|                     $tip = sprintf(JText::_('COM_TABULIZER_DATA_SOURCE_EXTERNAL_DATABASE_SUPPORTED_DRIVERS'),$supported_drivers_str);
 | |
|                     $html_value .= '<br style="clear: both" /><div class="tipdiv">'.$tip.'</span>';
 | |
|                     break;
 | |
|                 case 'edb_host':
 | |
|                 case 'edb_user':
 | |
|                 case 'edb_password':
 | |
|                 case 'edb_database':
 | |
|                 case 'edb_prefix':
 | |
|                     $html_value = TabulizerForm::getTextCtrl('ds_'.$key,$value,array('class'=>'ds_param_wide'));
 | |
|                     break;
 | |
|                 case 'sheet_references':
 | |
|                     $sheet_references_custom_style ='none';
 | |
|                     $attr_none = array('onclick'=>'TabulizerUpdateSheetReferences(this)', 'style'=>'float:none');
 | |
|                     $attr_all = array('onclick'=>'TabulizerUpdateSheetReferences(this)', 'style'=>'float:none');
 | |
|                     $attr_custom = array('onclick'=>'TabulizerUpdateSheetReferences(this)', 'style'=>'float:none');
 | |
|                     if (empty($value)) {
 | |
|                         $attr_none['checked'] = 'checked';
 | |
|                     } else if ($value == 'all') {
 | |
|                         $attr_all['checked'] = 'checked';
 | |
|                     } else {
 | |
|                         $attr_custom['checked'] = 'checked';
 | |
|                         $sheet_references_custom_style ='block';
 | |
|                     }
 | |
|                     $html_value = TabulizerForm::getInputCtrl('ds_sheet_references_type', 'none', $attr_none, 'radio') . ' ' . JText::_('COM_TABULIZER_SHEET_REFERENCES_NONE') . '   ' .
 | |
|                         TabulizerForm::getInputCtrl('ds_sheet_references_type', 'all', $attr_all, 'radio') . ' ' . JText::_('COM_TABULIZER_SHEET_REFERENCES_ALL') . '   ' .
 | |
|                         TabulizerForm::getInputCtrl('ds_sheet_references_type', 'custom', $attr_custom, 'radio') . ' ' . JText::_('COM_TABULIZER_SHEET_REFERENCES_CUSTOM') .
 | |
|                         '<div id="ds_sheet_references_custom" style="display:'.$sheet_references_custom_style.'">' .
 | |
|                         TabulizerForm::getTextCtrl('ds_'.$key,$value,array('class'=>'ds_param_wide')) .
 | |
|                         '</div>';
 | |
|                     break;
 | |
| 				case 'table_attribute_name':
 | |
| 					$options = array(0=>JText::_('COM_TABULIZER_NONE'),'id'=>'id','name'=>'name','class'=>'class');
 | |
| 					$html_value = TabulizerForm::getSelectCtrl('ds_'.$key,$source_params[$key],$options);	
 | |
| 					break;	
 | |
| 				case 'table_order':
 | |
| 					$options = array();
 | |
| 					for ($j=1;$j<=32;$j++) $options[$j] = $j;
 | |
| 					$html_value = TabulizerForm::getSelectCtrl('ds_'.$key,$source_params[$key],$options);				
 | |
| 					break;
 | |
| 				case 'separator':					
 | |
| 					$options = TabulizerUtils::getSeparatorListLabels();
 | |
| 					$html_value = TabulizerForm::getSelectCtrl('ds_'.$key,$source_params[$key],$options);				
 | |
| 					break;
 | |
| 				case 'enclosure':
 | |
| 					$options = array(ENCLOSURE_NONE=>JText::_('COM_TABULIZER_NO_ENCLOSURE'),
 | |
| 								     ENCLOSURE_DOUBLE_QUOTES=>JText::_('COM_TABULIZER_DOUBLE_QUOTES_ENCLOSURE'),
 | |
|    				 					ENCLOSURE_SINGLE_QUOTES=>JText::_('COM_TABULIZER_SINGLE_QUOTES_ENCLOSURE'));
 | |
| 					$html_value = TabulizerForm::getSelectCtrl('ds_'.$key,$source_params[$key],$options);
 | |
| 					break;
 | |
| 				case 'consistency':
 | |
| 					$options = array(1 => JText::_('COM_TABULIZER_COLUMN_CONSISTENCY_STRICT'),
 | |
| 					  				 0 => JText::_('COM_TABULIZER_COLUMN_CONSISTENCY_LOOSE'));
 | |
| 					$html_value = TabulizerForm::getSelectCtrl('ds_'.$key,$source_params[$key],$options); 
 | |
| 					break;
 | |
|                 case 'boost':
 | |
|                     $options = array(BOOST_NONE => JText::_('COM_TABULIZER_BOOST_NONE'),
 | |
|                         BOOST_NO_EXT => JText::_('COM_TABULIZER_BOOST_NOEXT'),
 | |
|                         BOOST_XLSX_PARSER => JText::_('COM_TABULIZER_XLSX_PARSER')
 | |
|                     );
 | |
|                     $html_value = TabulizerForm::getSelectCtrl('ds_'.$key,$source_params[$key],$options);
 | |
|                     break;
 | |
|                 case 'cellcache':
 | |
|                     $options = array(CELLCACHE_NONE => JText::_('COM_TABULIZER_CELLCACHE_NONE'),
 | |
|                         CELLCACHE_SQLITE3 => JText::_('COM_TABULIZER_CELLCACHE_SQLITE3')
 | |
|                     );
 | |
|                     $html_value = TabulizerForm::getSelectCtrl('ds_'.$key,$source_params[$key],$options);
 | |
|                     break;
 | |
| 				case 'read_font':
 | |
| 				case 'read_color':
 | |
| 				case 'read_images':
 | |
| 				case 'read_hyperlinks':
 | |
| 				case 'remove_empty':
 | |
| 				case 'strip_tags':
 | |
| 					$value = empty($value)?false:true;
 | |
| 					$html_value = TabulizerForm::getCheckboxCtrl('ds_'.$key, 1, $value);
 | |
| 					break;						
 | |
| 				default:
 | |
| 					$html_value = null;	
 | |
| 			}
 | |
| 
 | |
|             if (isset($tips[$key])) $tip = TabulizerUtils::opentip($tips[$key], $labels[$key]); else $tip = '';
 | |
| 			if (isset($html_value)) $source_params_html .= '<tr id="tr_'.$key.'" class="'.$this->getShowHideClass($data_source->source_type, $key).'"><td class="ds_param_label">'.$labels[$key].$tip.': </td><td>'.$html_value.'</td></tr>';
 | |
| 		}				
 | |
| 		$source_params_html .= '</table>';				
 | |
| 								
 | |
| 		$lists['source_params'] = $source_params_html;
 | |
| 								
 | |
| 		$this->assignRef('lists', $lists);		
 | |
| 		$this->assignRef('return_urls', $return_urls);						
 | |
| 		
 | |
| 		parent::display($tpl);	
 | |
| 	}
 | |
| 
 | |
|     function displayImport($tpl = null) {
 | |
|         $model = $this->getModel();
 | |
| 
 | |
|         parent::display($tpl);
 | |
|     }
 | |
| 
 | |
|     function displayDataFiles($tpl = null){
 | |
|         $jinput = JFactory::getApplication()->input;
 | |
|         $option = $jinput->getCmd('option');
 | |
|         $return_urls = null;
 | |
| 
 | |
|         $model = $this->getModel();
 | |
|         $data_files = $model->getDataFiles();
 | |
|         $pagination = $model->getPagination();
 | |
|         $model->getReturnURLs($return_urls);
 | |
| 
 | |
|         $this->assignRef('data_files', $data_files);
 | |
|         $this->assignRef('return_urls', $return_urls);
 | |
|         $this->assignRef('pagination', $pagination);
 | |
| 
 | |
|         parent::display($tpl);
 | |
|     }
 | |
| 
 | |
|     function displayDataFileImport($tpl = null) {
 | |
|         $model = $this->getModel();
 | |
| 
 | |
|         parent::display($tpl);
 | |
|     }
 | |
| 
 | |
|     function editPublishingPreferences($tpl = null) {
 | |
|         $model = $this->getModel();
 | |
| 
 | |
|         $data_source = $model->getDataSource();
 | |
|         $preferences = $model->getPublishingPreferences();
 | |
|         $return_urls = null;
 | |
| 
 | |
|         $model->getReturnURLs($return_urls);
 | |
| 
 | |
|         if (!empty($preferences)) {
 | |
|             $status = $preferences->status;
 | |
|             $mode = $preferences->mode;
 | |
|             $keyphrases = $preferences->keyphrases;
 | |
|         } else {
 | |
|             $status = 0;
 | |
|             $mode = 'json';
 | |
|             $keyphrases = array();
 | |
|         }
 | |
| 
 | |
|         $lists = array();
 | |
| 
 | |
|         $options = array(PUBLISHING_PREFERENCES_STATUS_UNPUBLISHED=>JText::_('COM_TABULIZER_DATA_SOURCE_PUBLISHING_STATUS_UNPUBLISHED'), PUBLISHING_PREFERENCES_STATUS_PUBLISHED=>JText::_('COM_TABULIZER_DATA_SOURCE_PUBLISHING_STATUS_PUBLISHED'));
 | |
|         $lists['status'] = TabulizerForm::getSelectCtrl('ds_status',$status,$options);
 | |
| 
 | |
|         $options = array(PUBLISHING_PREFERENCES_MODE_JSON=>JText::_('COM_TABULIZER_DATA_SOURCE_PUBLISHING_MODE_JSON'), PUBLISHING_PREFERENCES_MODE_HTML=>JText::_('COM_TABULIZER_DATA_SOURCE_PUBLISHING_MODE_HTML'));
 | |
|         $lists['mode'] = TabulizerForm::getSelectCtrl('ds_mode',$mode,$options);
 | |
| 
 | |
|         $attributes = array('style'=>'height: 125px; width: 220px;');
 | |
|         if (!empty($keyphrases)) {
 | |
|             $lists['keyphrases'] = TabulizerForm::getSelectCtrlMultiple('ds_keyphrases', array(), $keyphrases, $attributes);
 | |
|         } else {
 | |
|             $lists['keyphrases'] = '<select name="ds_keyphrases" id="ds_keyphrases" multiple style="'.$attributes['style'].'"></select>';
 | |
|         }
 | |
|         $lists['keyphrases'] .= '<br style="clear: both;"/><a href="javascript:addNewKeyphrase();">'.JText::_('COM_TABULIZER_DATA_SOURCE_PUBLISHING_KEYPHRASE_ADD').'</a> | <a href="javascript:removeKeyphrase();">'.JText::_('COM_TABULIZER_DATA_SOURCE_PUBLISHING_KEYPHRASE_REMOVE').'</a> | <a href="javascript:removeAllKeyphrases();">'.JText::_('COM_TABULIZER_DATA_SOURCE_PUBLISHING_KEYPHRASE_REMOVE_ALL').'</a>';
 | |
| 
 | |
|         $this->assignRef('return_urls', $return_urls);
 | |
|         $this->assignRef('data_source', $data_source);
 | |
|         $this->assignRef('preferences', $preferences);
 | |
|         $this->assignRef('lists', $lists);
 | |
| 
 | |
|         parent::display($tpl);
 | |
|     }
 | |
| 
 | |
|     function sortArrayByTitle($a, $b) {
 | |
|         return ($a['title'] > $b['title']);
 | |
|     }
 | |
| 	
 | |
| 	function getShowHideClass($source_type, $param_key) {
 | |
| 		$class = 'hidden_tr';
 | |
| 		switch ($source_type) {
 | |
| 			case 'csv': $show_keys = array('ruleset_archive',
 | |
| 						'ruleset_name',
 | |
|                         'table_caption',
 | |
|                         'table_summary',
 | |
|                         'server_side',
 | |
| 						'filepath',
 | |
|                         'encoding',
 | |
| 						'separator',
 | |
| 						'enclosure',
 | |
| 						'consistency');
 | |
| 						break;
 | |
| 						
 | |
| 			case 'excel': $show_keys = array('ruleset_archive',
 | |
| 						'ruleset_name',
 | |
|                         'table_caption',
 | |
|                         'table_summary',
 | |
|                         'server_side',
 | |
| 						'filepath',												
 | |
| 						'sheet_name',
 | |
|                         'sheet_references',
 | |
| 						'sheet_selection',					
 | |
| 						'read_font',	
 | |
| 						'read_color',	
 | |
| 						'read_images',	
 | |
| 						'read_hyperlinks',
 | |
|                         'boost',
 | |
|                         'cellcache',
 | |
| 						'remove_empty');
 | |
| 						break;
 | |
| 						
 | |
| 			case 'database': $show_keys = array('ruleset_archive',
 | |
| 						'ruleset_name',
 | |
|                         'table_caption',
 | |
|                         'table_summary',
 | |
|                         'server_side',
 | |
| 						'query');
 | |
| 						break;
 | |
| 
 | |
|             case 'external_database': $show_keys = array('ruleset_archive',
 | |
|                         'ruleset_name',
 | |
|                         'table_caption',
 | |
|                         'table_summary',
 | |
|                         'server_side',
 | |
|                         'query',
 | |
|                         'edb_driver',
 | |
|                         'edb_host',
 | |
|                         'edb_user',
 | |
|                         'edb_password',
 | |
|                         'edb_database',
 | |
|                         'edb_prefix');
 | |
|                          break;
 | |
| 						
 | |
| 			case 'html': $show_keys = array('ruleset_archive',
 | |
| 						'ruleset_name',
 | |
|                         'table_caption',
 | |
|                         'table_summary',
 | |
|                         'server_side',
 | |
| 						'filepath',
 | |
|                         'encoding',
 | |
| 						'table_order',
 | |
| 						'table_attribute_name',
 | |
| 						'table_attribute_value');
 | |
| 						break;
 | |
| 
 | |
|             case 'xml': $show_keys = array('ruleset_archive',
 | |
|                         'ruleset_name',
 | |
|                         'table_caption',
 | |
|                         'table_summary',
 | |
|                         'server_side',
 | |
|                         'filepath',
 | |
|                         'encoding',
 | |
|                         'td_map');
 | |
|                         break;
 | |
| 
 | |
|             case 'rss': $show_keys = array('ruleset_archive',
 | |
|                         'ruleset_name',
 | |
|                         'table_caption',
 | |
|                         'table_summary',
 | |
|                         'server_side',
 | |
|                         'filepath',
 | |
|                         'encoding',
 | |
|                         'feed_type');
 | |
|                         break;
 | |
| 
 | |
|             case 'json': $show_keys = array('ruleset_archive',
 | |
|                         'ruleset_name',
 | |
|                         'table_caption',
 | |
|                         'table_summary',
 | |
|                         'server_side',
 | |
|                         'filepath',
 | |
|                         'encoding');
 | |
|                         break;
 | |
| 						
 | |
| 			case 'article': $show_keys = array('ruleset_archive',
 | |
| 						'ruleset_name',
 | |
|                         'table_caption',
 | |
|                         'table_summary',
 | |
|                         'server_side',
 | |
| 						'article_id',
 | |
| 						'separator',
 | |
| 						'enclosure',
 | |
| 						'consistency',
 | |
| 						'strip_tags');
 | |
| 						break;
 | |
| 
 | |
|             case 'merger': $show_keys = array('ruleset_archive',
 | |
|                         'ruleset_name',
 | |
|                         'table_caption',
 | |
|                         'table_summary',
 | |
|                         'server_side',
 | |
|                         'merging_tree');
 | |
|                         break;
 | |
| 
 | |
|             default:
 | |
| 						$show_keys = array();
 | |
| 						break;			
 | |
| 		}
 | |
| 		
 | |
| 		if (in_array($param_key, $show_keys)) $class = '';
 | |
| 		
 | |
| 		return $class;	
 | |
| 	}	
 | |
| 	
 | |
| 	function getArticleSelectionInput($element_id, $element_value = 0) {
 | |
| 		if (defined('JOOMLA_1_MODE')) {			
 | |
| 			$session_token = JSession::getFormToken();
 | |
| 			$element_value = (empty($element_value))?'':intval($element_value);
 | |
| 			$html = TabulizerForm::getTextCtrl($element_id, $element_value) . 
 | |
| 						  ' <a rel="{handler: \'iframe\', size: {x: 650, y: 375}}" href="'.JRoute::_("index.php?option=com_content&task=element&tmpl=component&object=id'&{$session_token}=1").'" class="modal">'.JText::_('COM_TABULIZER_DATA_SOURCE_PARAM_ARTICLE_ID_VIEW_LIST').'</a>';
 | |
| 								  								  			
 | |
| 			return $html;
 | |
| 		}	
 | |
| 	
 | |
| 		// Load the modal behavior script.
 | |
| 		JHtml::_('behavior.modal', 'a.modal');
 | |
| 		
 | |
| 		// Build the script.
 | |
| 		$script = array();
 | |
| 		$script[] = '   function jSelectArticle_'.$element_id.'(id, title, catid, object) {';
 | |
| 		$script[] = '       document.id("'.$element_id.'").value = id;';
 | |
| 		$script[] = '       document.id("'.$element_id.'_title").value = title;';
 | |
| 		$script[] = '       SqueezeBox.close();';
 | |
| 		$script[] = '   }';
 | |
| 		
 | |
| 		// Add the script to the document head.
 | |
| 		TabulizerJS::addScriptDeclaration(implode("\n", $script));
 | |
| 		
 | |
| 		// Setup variables for display.
 | |
| 		$html   = array();
 | |
| 		$link   = 'index.php?option=com_content&view=articles&layout=modal&tmpl=component&function=jSelectArticle_'.$element_id;
 | |
| 		
 | |
| 		if (!empty($element_value)) {
 | |
| 			$db = JFactory::getDBO();				
 | |
| 			$db->setQuery(
 | |
| 				'SELECT title' .
 | |
| 				' FROM #__content' .
 | |
| 				' WHERE id = '.(int) $element_value
 | |
| 			);
 | |
| 			$title = $db->loadResult();
 | |
| 			if ($error = $db->getErrorMsg()) {
 | |
|                 JFactory::getApplication()->enqueueMessage($error, 'error');
 | |
|                 return '';
 | |
| 			}
 | |
| 		} else {
 | |
| 			$element_value = '';
 | |
| 			$title = '';
 | |
| 		}				
 | |
| 		
 | |
| 		if (empty($title)) {
 | |
| 			$title = JText::_('COM_TABULIZER_NO_ARTICLE_IS_SELECTED');
 | |
| 		}
 | |
| 		$title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
 | |
| 		
 | |
| 		$session_token = JSession::getFormToken();
 | |
| 		
 | |
| 		// The current user display field.
 | |
| 		$html[] = '<span class="article_selection_title">';
 | |
| 		$html[] = '<input type="text" id="'.$element_id.'_title" value="'.$title.'" disabled="disabled" /> ';
 | |
| 		$html[] = '<a class="modal" title="'.JText::_('COM_TABULIZER_CHANGE_ARTICLE').'"  href="'.$link.'&'.$session_token.'=1" rel="{handler: \'iframe\', size: {x: 800, y: 450}}">'.JText::_('COM_TABULIZER_CHANGE_ARTICLE_BUTTON').'</a>';
 | |
| 		$html[] = '</span>';
 | |
| 			
 | |
| 		// The active article id field.
 | |
| 		if (empty($element_value)) {
 | |
| 			$value = '';
 | |
| 		} else {
 | |
| 			$value = (int)$element_value;
 | |
| 		}	
 | |
| 		
 | |
| 		$html[] = '<input type="hidden" id="'.$element_id.'" name="'.$element_id.'" value="'.$value.'" />';
 | |
| 		
 | |
| 		return implode("\n", $html);
 | |
| 				
 | |
| 	}
 | |
| 	
 | |
| }
 | |
| ?>
 |