|
CATALOGO DIGITAL
Referencia Bibliográfica
$v) {
$kk = AddslashesDeep($v);
}
foreach ($_POST as $k => $v) {
$kk = AddslashesDeep($v);
}
foreach ($_COOKIE as $k => $v) {
$kk = AddslashesDeep($v);
}
}
$encap = ( ($encap=="false") ? false : true );
require_once "./include/config.php3";
require_once AA_INC_PATH."easy_scroller.php3";
require_once AA_INC_PATH."util.php3";
require_once AA_INC_PATH."item.php3";
require_once AA_INC_PATH."view.php3";
require_once AA_INC_PATH."pagecache.php3";
require_once AA_INC_PATH."searchlib.php3";
require_once AA_INC_PATH."discussion.php3";
require_once AA_INC_PATH."mgettext.php3";
require_once AA_INC_PATH."slice.class.php3";
require_once AA_INC_PATH."hitcounter.class.php3";
// function definitions:
require_once AA_INC_PATH."slice.php3";
require_once AA_INC_PATH."locsess.php3";
$slice_starttime = get_microtime();
//MLX stuff
require_once AA_INC_PATH."mlx.php";
page_open(array("sess" => "AA_SL_Session"));
$sess->register(r_packed_state_vars);
$sess->register(slices);
$r_state_vars = unserialize($r_packed_state_vars);
// there was problems with storing too much ids in session veriable,
// so I commented it out. It is not necessary to have it in session. The only
// reason to have it there is the display speed, but because of impementing
// pagecache.php3, it is not so big problem now
//$sess->register(item_ids);
if ($encap) { // adds values from QUERY_STRING_UNESCAPED
add_vars(""); // and REDIRECT_STRING_UNESCAPED
}
if (($key != $lock) OR $scrl) { // command is for other slice on page
RestoreVariables(); // or scroller
}
// url posted command to display specified text instead of slice content -------
if ($slicetext) {
echo $slicetext;
ExitPage();
}
// url posted command to display another file ----------------------------------
if ( $inc ) { // this section must be after add_vars()
// StoreVariables(array("inc")); // store in session
if ( !eregi("^([0-9a-z_])+(\.[0-9a-z]*)?$", $inc) ) {
echo _m("Bad inc parameter - included file must be in the same directory as this .shtml file and must contain only alphanumeric characters"). " $inc";
ExitPage();
} else {
$fp = @fopen(shtml_base().$inc, "r"); // if encapsulated
if (!$fp) {
echo _m("No such file") ." $inc";
} else {
FPassThru($fp);
}
ExitPage();
}
}
// Take any slice to work with
if (!$slice_id AND is_array($slices)) {
reset ($slices);
$slice_id = current($slices);
}
// if someone breaks ';
ExitPage();
}
$add_aliases = $aliases = GetAliasesFromUrl($als);
// this is not good way - aliases are then different on each call, so it isn't
// cached. The better way is below
// $add_aliases['_#SESSION_'] = GetAliasDef( 'f_s:'. $sess->id, '', _m('session id'));
$add_aliases['_#SESSION_'] = GetAliasDef( 'f_e:session', 'id..............', _m('session id'));
// if banner parameter supplied => set format
$slice_info = array_merge( $slice_info, ParseBannerParam($banner));
// get alias list from database and possibly from url
// if working with multi-slice, get aliases for all slices
if (!is_array($slices)) {
$aliases = GetAliasesFromFields($fields);
array_add($add_aliases, $aliases);
} else {
foreach ($slices as $sid) {
list($fields) = GetSliceFields($sid);
// hack for searching in multiple slices. This is not so nice part
// of code - we mix there $aliases[
$item_ids ";
}
if ( !$scrl ) {
$scr->current = $scr_go;
}
}
elseif ($srch) { // posted by bigsrch form -------------------
$r_state_vars = StoreVariables(array("listlen","no_scr","scr_go","big","search", "s_col", "mlx")); // store in session
if ( !$big ) {
$search['slice'] = $slice_id;
}
$item_ids = SearchWhere($search, $s_col);
if ( !$scrl ) {
$scr->current = $scr_go;
}
}
elseif ($debug) {
echo "ERROR: This branch should never be entered.";
}
} else {
/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Parse parameters posted by query form and from $slice_info
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
$r_state_vars = StoreVariables(array("no_scr","scr_go","order","cat_id", "cat_name",
"exact","restrict","res_val","highlight","conds","group_by", "sort","als","defaultCondsOperator","mlx")); // store in session, added mlx
// ***** CONDS *****
if ($cat_id) { // optional parameter cat_id - deprecated - slow ------
$tmpobj = $slice->getFields();
$cat_field = $tmpobj->getCategoryFieldId();
$cat_group = GetCategoryGroup($slice_id);
$SQL = "SELECT value FROM constant
WHERE group_id = '$cat_group' AND id='". q_pack_id($cat_id) ."'";
$db->query($SQL);
if ( $db->next_record() ) {
$conds[] = array( $cat_field => 1,
'value' => $db->f('value'),
'operator' => ($exact ? '=' : 'LIKE'));
}
} elseif ($cat_name) { // optional parameter cat_name -------
$tmpobj = $slice->getFields();
$cat_field = $tmpobj->getCategoryFieldId();
$conds[] = array( $cat_field => 1,
'value' => $cat_name,
'operator' => ($exact ? '=' : 'LIKE'));
}
if ($restrict) {
$conds[] = array( $restrict => 1,
'value' => ((($res_val[0] == '"' OR $res_val[0] == "'") AND $exact != 2 ) ? $res_val : "\"$res_val\""),
'operator' => ($exact ? '=' : 'LIKE'));
}
if ($highlight != "") {
$conds[] = array('highlight.......' => 1);
}
if (!isset($defaultCondsOperator)) {
$defaultCondsOperator = 'LIKE';
}
if (is_array($conds)) {
ParseEasyConds($conds, $defaultCondsOperator);
foreach ( $conds as $k => $v ) {
SubstituteAliases( $als, $conds[$k]['value'] );
}
}
// ***** SORT *****
/** order by field xy if other than publish date.
* Syntax: [number]field_id[-]
* (add minus sign for descending order (like "headline.......1-")
* (add number before the field if you want to group limit (limit number of items of the same value))
*/
if ($order) {
$set = new AA_Set;
$set->addSortFromString($order);
$order = reset($set->getSort()); // get the first from array
list($order, $orderdirection) = each($order);
}
if ($debug) {
echo "Group by: -$group_by- Slice_info[category_sort] -$slice_info[category_sort]- slice_info[group_by] -$slice_info[group_by]-"; } $sort_tmp = array(); if ($group_by) { $set = new AA_Set; $set->addSortFromString($group_by); $sort_tmp = $set->getSort(); $slice_info["group_by"] = key($sort_tmp[0]); } elseif ($slice_info['category_sort']) { $tmpobj = $slice->getFields(); $group_field = $tmpobj->getCategoryFieldId(); $grp_odir = (($order==$group_field) AND ($orderdirection!='d')) ? 'a' : 'd'; $sort_tmp[] = array( $group_field => $grp_odir ); } elseif ($slice_info['group_by']) { switch( (string)$slice_info['gb_direction'] ) { // gb_direction is number case '1': $gbd = '1'; break; // 1 (1)- ascending by priority case 'd': // d - descending - goes from view (iview) settings case '8': $gbd = 'd'; break; // d (8)- descending case '9': $gbd = '9'; break; // 9 (9)- descending by priority (for fields using constants) default: $gbd = 'a'; // 2 (2)- ascending; } $sort_tmp[] = array($slice_info['group_by'] => $gbd); } $sort_tmp = array_merge($sort_tmp, getSortFromUrl($sort)); if ($order) { add2sort($sort_tmp, array($order => (strstr('aAdD19',$orderdirection) ? $orderdirection : 'a'))); } // time order the fields in compact view add2sort($sort_tmp, array('publish_date....' => (($timeorder == "rev") ? 'a' : 'd'))); $sort = $sort_tmp; //mlx stuff if (isMLXSlice($slice_info)) { if (!$mlxView) { $mlxView = new MLXView($mlx); } $mlxView->preQueryZIDs(unpack_id128($slice_info[MLX_SLICEDB_COLUMN]),$conds,$slices); } $zids = QueryZIDs( ($slices ? $slices : array($slice_id)), $conds, $sort, "ACTIVE", $neverAllItems, 0, $defaultCondsOperator, true ); if (isMLXSlice($slice_info)) { $mlxView->postQueryZIDs($zids,unpack_id128($slice_info[MLX_SLICEDB_COLUMN]),$slice_id, $conds, $sort, $slice_info['group_by'],"ACTIVE", $slices, $neverAllItems, 0, $defaultCondsOperator,$nocache); } if ( !$scrl ) { $scr->current = $scr_go; } } if ( !$srch AND !$encap AND !$easy_query ) { $cur_cats=GetCategories($db,$p_slice_id); // get list of categories pCatSelector($sess->name,$sess->id,$sess->MyUrl($slice_id, $encap, true),$cur_cats,$scr->filters[category_id]['value'], $slice_id, $encap); } if ($zids->count() > 0) { $scr->countPages( $zids->count() ); $itemview = new itemview($slice_info, $fields, $aliases, $zids, $scr->metapage * ($scr->current - 1), ($group_n ? -$group_n : $scr->metapage), // negative number used for displaying n-th group $sess->MyUrl($slice_id, $encap) ); $itemview->print_view(); if (($scr->pageCount() > 1) AND !$no_scr AND !$group_n) { $scr->pnavbar(); } } else { // test if the the noitem_msg is filled (be carefull - "0" should be considered as filled) echo (isset($slice_info['noitem_msg']) AND (strlen($slice_info['noitem_msg']) > 0)) ? // is keyword for removing 'no item message' str_replace( '', '', AA_Stringexpand::unalias($slice_info['noitem_msg'])) : (" "._m("No item found") ." ");
}
if ($searchlog) {
PutSearchLog();
}
if ($debug) {
$timeend = get_microtime();
$time = $timeend - $slice_starttime;
echo "Page generation time: $time"; } ExitPage(); ?> |