get('aid', 0);
$wheres[] = " a.id = " . (int) $wb_id;
$wheres[] = " a.id = b.wb_id ";
$wheres[] = " b.ws_id = c.id ";
$wheres[] = " a.published=1 ";
$wheres[] = " c.published=1 ";
$wheres[] = " a.section=d.id ";
$wheres[] = " a.category=e.id ";
$wheres[] = " e.published=1 ";
if ($aid !== null) {
$wheres[] = "a.access <= " . (int) $aid;
$wheres[] = "c.access <= " . (int) $aid;
$wheres[] = "d.access <= " . (int) $aid;
$wheres[] = "e.access <= " . (int) $aid;
}
$query = " SELECT a.id as key1, c.id, c.sheetname, a.link_title as wbtitle, a.dlformat, a.preview_dl_btn " .
" FROM #__sql2excel_workbooks AS a, #__sql2excel_worksheet2book AS b, #__sql2excel_worksheets AS c, #__sql2excel_sections AS d, #__sql2excel_categories AS e " .
" WHERE " . implode( " AND ", $wheres ) .
" ORDER BY b.ordering";
$db->setQuery( $query );
$worksheets = $db->loadObjectList();
return $worksheets;
}
function getWorkbookParms($wb_id)
{
global $mainframe;
$db =& JFactory::getDBO();
$user =& JFactory::getUser();
$aid = $user->get('aid', 0);
$wheres[] = " a.id = " . (int) $wb_id;
$wheres[] = " a.id = b.wb_id ";
$wheres[] = " b.ws_id = c.id ";
//$wheres[] = " a.published=1 ";
$wheres[] = " c.published=1 ";
$wheres[] = " a.section=d.id ";
$wheres[] = " a.category=e.id ";
$wheres[] = " e.published=1 ";
if ($aid !== null) {
$wheres[] = "a.access <= " . (int) $aid;
$wheres[] = "c.access <= " . (int) $aid;
$wheres[] = "d.access <= " . (int) $aid;
$wheres[] = "e.access <= " . (int) $aid;
}
$query = " SELECT a.parms, a.parms_prompt, a.parms_length " .
" FROM #__sql2excel_workbooks a, #__sql2excel_worksheet2book b, #__sql2excel_worksheets c, #__sql2excel_sections d, #__sql2excel_categories e " .
" WHERE " . implode( " AND ", $wheres );
$db->setQuery( $query );
//$wbParms = $db->loadResult();
$parmInfo = $db->loadObjectList();
if ( count($parmInfo) ) {
$parmInfo = $parmInfo[0];
$wbParms = $parmInfo->parms;
$wbParmsPrompt = $parmInfo->parms_prompt;
$wbParmsLength = $parmInfo->parms_length;
}
if ( $wbParms == '' ) {
return '';
} else {
// Component Configuration Parameters
$cmpParms = Sql2excelParms::getParms();
//$substWBParms = $cmpParms->get( 'subst_wbparms', '1' );
$substWBParms = Sql2excelParms::get($cmpParms,'subst_wbparms', '1');
$wbParmVars = '';
$wbParmVarsAdd = '';
$wbParmvalidate = '';
$wbHiddenParms = '';
$wbValidate = '';
$wbMultiTicks = '';
$nrWbParms = 0;
$extraParms = array();
// Workbook Parameters defined
$wbParmsHTML = '
';
$wbParmsHTML .= '
';
$wbParmsHTML .= '
';
if ( $wbValidate != '' ) {
$wbValidate = substr($wbValidate,3);
$wbValidate = "if ( !validateParms(\"" . $wbValidate . "\",checkMulti) ) {\n";
$wbValidate .= " return false;\n";
$wbValidate .= "}\n";
}
$wbRefresh = " ";
// Add Preview hidden parameter
$wbHiddenParms .= "\n";
// Create Javascript snippet for Multi-Ticks check
$wbMultiTicks = Sql2excelCommon::multiTicksJS($wbMultiTicks);
if ( $wbParmsPrompt ) {
return array($wbParmsHTML, $wbParmVars, $wbParmVarsAdd, $wbHiddenParms, $nrWbParms, $wbRefresh, $wbValidate, $wbMultiTicks);
} else {
return array('', '', '', $wbHiddenParms, 0, '', '','');
}
}
}
function multiTicksJS($str) {
$str = substr($str,1);
$retStr = '';
$checkStr = '';
$ticksTokens = explode(',',$str);
foreach ($ticksTokens as $i) {
if ( $i > 0 ) {
if ( $checkStr == '' ) {
$checkStr = 'i==' . $i;
} else {
$checkStr .= ' || i==' . $i;
}
}
}
if ( $checkStr != '' ) {
$retStr = 'if (' . $checkStr . ') { ticks=1; }';
}
return $retStr;
}
function encodeHTML($str) {
return htmlspecialchars($str,ENT_COMPAT,'UTF-8');
}
function utf8_strrev($str, $reverse_numbers = true){
$pattern = $reverse_numbers ? '/./us' : '/(\d+)?./us';
preg_match_all($pattern, $str, $ar);
return join('',array_reverse($ar[0]));
}
}
?>