<?php /** @var eZModule $module */ $module = $Params['Module']; $repositoryID = isset($Params['RepositoryID']) ? $Params['RepositoryID'] : false; $tpl = eZTemplate::factory(); $http = eZHTTPTool::instance(); try { if (!$repositoryID) { $list = OCCrossSearch::listAvailableRepositories(); $tpl->setVariable('repository_list', $list); $Result = array(); $Result['content'] = $tpl->fetch('design:repository/list.tpl'); $Result['path'] = array(array('text' => 'Repository', 'url' => false)); } elseif (OCCrossSearch::isAvailableRepository($repositoryID)) { $repository = OCCrossSearch::instanceRepository($repositoryID); if ($http->hasVariable('action')) { $repository->setCurrentAction($http->variable('action')); $repository->setCurrentActionParameters($_GET); } $definition = $repository->attribute('definition'); $tpl->setVariable('repository', $repository); $Result = array(); $Result['content'] = $tpl->fetch($repository->templateName()); $Result['path'] = array(array('text' => 'Repository', 'url' => 'repository/client'), array('text' => isset($definition['Name']) ? $definition['Name'] : $repositoryID, 'url' => false)); } else { $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel'); return; } } catch (Exception $e) { $Result = array();
function modify(&$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters) { switch ($operatorName) { case 'repository_list': $operatorValue = OCCrossSearch::listAvailableRepositories(); break; case 'class_search_result': try { $operatorValue = OCClassSearchFormHelper::result($namedParameters['parameters'], $namedParameters['fields'], true); } catch (Exception $e) { eZDebug::writeError($e->getMessage(), $operatorName); } break; case 'attribute_search_form': try { $operatorValue = OCClassSearchFormHelper::displayAttribute($namedParameters['helper'], $namedParameters['input_field']); } catch (Exception $e) { eZDebug::writeError($e->getMessage(), $operatorName); } break; case 'class_search_form': try { $operatorValue = OCClassSearchFormHelper::displayForm($namedParameters['class_identifier'], $namedParameters['parameters']); } catch (Exception $e) { eZDebug::writeError($e->getMessage(), $operatorName); } break; case 'strtotime': $operatorValue = strtotime($operatorValue); break; case 'calendar': $data = new OCCalendarData($namedParameters['node']); $data->setParameters($namedParameters['parameters']); $data->fetch(); $operatorValue = $data->data; break; case 'facet_navigation': $operatorValue = OCFacetNavgationHelper::data($namedParameters['base_query'], $namedParameters['override'], $namedParameters['base_uri']); break; case 'setFilterParameter': self::$filters[$namedParameters['name']][] = $namedParameters['value']; $this->log($namedParameters, 'setFilterParameter'); $operatorValue = self::$filters[$namedParameters['name']]; break; case 'getFilterParameter': $this->getAllFilters(); if (isset(self::$query_filters[$namedParameters['name']])) { $this->log($namedParameters['name'] . ': ' . var_export(self::$query_filters[$namedParameters['name']], true), 'getFilterParameter'); $operatorValue = is_array(self::$query_filters[$namedParameters['name']]) ? self::$query_filters[$namedParameters['name']] : array(self::$query_filters[$namedParameters['name']]); return true; } $operatorValue = array(); return false; break; case 'removeFilterParameter': $this->getAllFilters(); if (isset(self::$query_filters[$namedParameters['name']])) { self::$query_filters[$namedParameters['name']] = array(); return true; } return false; break; case 'getFilterParameters': $http = eZHTTPTool::instance(); $this->getAllFilters(); $filterList = self::$query_filters; if ($namedParameters['as_array']) { $operatorValue = $filterList; return; } $filterSearchHash = array(); if ($namedParameters['cond']) { $filterSearchHash[] = $namedParameters['cond']; } foreach ($filterList as $name => $value) { if (count($value) > 1) { $temp_array = array('or'); foreach ($value as $v) { $temp_array[] = $name . ':' . $v; } $filterSearchHash[] = $temp_array; } else { $filterSearchHash[] = $name . ':' . $value[0]; } } $this->log($filterSearchHash, 'getFilterParameters'); $operatorValue = $filterSearchHash; break; case 'getFilterUrlSuffix': $filterSearchHash = $operatorValue; $urlSuffix = ''; $tempArray = array(); foreach ($filterSearchHash as $filter) { if (is_array($filter)) { foreach ($filter as $f) { if ('and' != $f and 'or' != $f) { if (!in_array($f, $tempArray)) { $tempArray[] = $f; $urlSuffix .= '&filter[]=' . rawurlencode($f); } } } } else { if (!in_array($filter, $tempArray)) { $tempArray[] = $filter; $urlSuffix .= '&filter[]=' . rawurlencode($filter); } } } $operatorValue = $urlSuffix; break; case 'getFilterHiddenInput': $filterSearchHash = $operatorValue; $input = array(); $tempArray = array(); foreach ($filterSearchHash as $filter) { if (is_array($filter)) { foreach ($filter as $f) { if ('and' != $f and 'or' != $f) { if (!in_array($f, $tempArray)) { $tempArray[] = $f; $input[] = $f; } } } } else { if (!in_array($filter, $tempArray)) { $tempArray[] = $filter; $input[] = $filter; } } } $html = ''; foreach ($input as $i) { $html .= "<input type='hidden' name='filter[]' value='{$i}' />"; } $operatorValue = $html; break; case 'addQuoteOnFilter': $tempVar = $operatorValue; list($name, $value) = explode(':', $tempVar); $operatorValue = $name . ':"' . $value . '"'; break; case 'in_array_r': if ($this->recursiveArraySearch($namedParameters['needle'], $namedParameters['haystack']) !== false) { $operatorValue = true; return true; } $operatorValue = false; return false; break; case 'sort': sort($operatorValue); break; case 'asort': asort($operatorValue); break; case 'parsedate': $operatorValue = str_replace('"', '', $operatorValue); if (DateTime::createFromFormat("Y-m-d\\TH:i:sP", $operatorValue)) { $operatorValue = DateTime::createFromFormat("Y-m-d\\TH:i:sP", $operatorValue)->format("U"); } else { eZDebug::writeError($operatorValue . ': ' . var_export(DateTime::getLastErrors(), 1), 'parsedate'); $operatorValue = 0; } break; default: break; } }