/** * Executes the PHP function for the operator cleanup and modifies $operatorValue. * * @param eZTemplate $tpl * @param string $operatorName * @param array $operatorParameters * @param string $rootNamespace * @param string $currentNamespace * @param mixed $operatorValue * @param array $namedParameters */ public function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters) { switch ($operatorName) { case 'json': $operatorValue = eZFlowAjaxContent::jsonEncode($operatorValue); break; } }
FROM $poolTMPTable, ezcontentobject_tree WHERE $poolTMPTable.block_id='" . $block->attribute('id') . "' AND $poolTMPTable.ts_visible>0 AND $poolTMPTable.ts_hidden=0 AND ezcontentobject_tree.node_id = $poolTMPTable.node_id ORDER BY $poolTMPTable.priority DESC" ); if( count( $validNodes ) ) { $validNodesObjects = array(); foreach( $validNodes as $validNode ) { $validNodeID = $validNode['node_id']; $validNodesObjects[] = eZContentObjectTreeNode::fetch( $validNodeID ); } $block->setAttribute( 'valid_nodes', $validNodesObjects ); } $outputBlock = array( 'objectid' => $block->attribute('zone_id') . '-' . $block->attribute('id') ); $tpl->setVariable( 'block', $block ); $outputBlock['xhtml'] = htmlentities( str_replace( array( "\r\n", "\r", "\n" ), array(""), $tpl->fetch( 'design:page/preview.tpl' ) ), ENT_QUOTES, $httpCharset ); $output[] = $outputBlock; } } header( 'Content-Type: application/json; charset=' . $httpCharset ); echo eZFlowAjaxContent::jsonEncode( $output ); eZExecution::cleanExit(); ?>
/** * Wrapper function for encoding to json with native or php version * depending on what the system supports * * @param mixed $obj * @return string */ public static function jsonEncode($obj) { if (self::$nativeJsonEncode === null) { self::$nativeJsonEncode = function_exists('json_encode'); } if (self::$nativeJsonEncode === true) { return json_encode($obj); } $inst = self::getInstance(); return $inst->phpJsonEncode($obj); }
/** * Returns search results based on given params * * @param mixed $args * @return array * @deprecated Use ezjsc::search instead (in ezjscore) */ public static function search($args) { $http = eZHTTPTool::instance(); if ($http->hasPostVariable('SearchStr')) { $searchStr = trim($http->postVariable('SearchStr')); } $searchOffset = 0; if ($http->hasPostVariable('SearchOffset')) { $searchOffset = (int) $http->postVariable('SearchOffset'); } $searchLimit = 10; if ($http->hasPostVariable('SearchLimit')) { $searchLimit = (int) $http->postVariable('SearchLimit'); } if ($searchLimit > 30) { $searchLimit = 30; } if ($http->hasPostVariable('SearchSubTreeArray') && $http->postVariable('SearchSubTreeArray')) { $search_sub_tree_array = explode(',', $http->postVariable('SearchSubTreeArray')); } //Prepare the search params $param = array('SearchOffset' => $searchOffset, 'SearchLimit' => $searchLimit + 1, 'SortArray' => array('score', 0), 'SearchSubTreeArray' => $search_sub_tree_array); if ($http->hasPostVariable('enable-spellcheck') and $http->postVariable('enable-spellcheck') == 1) { $param['SpellCheck'] = array(true); } if ($http->hasPostVariable('show-facets') and $http->postVariable('show-facets') == 1) { $defaultFacetFields = eZFunctionHandler::execute('ezfind', 'getDefaultSearchFacets', array()); $param['facet'] = $defaultFacetFields; } $solr = new eZSolr(); $searchList = $solr->search($searchStr, $param); $result = array(); $result['SearchResult'] = eZFlowAjaxContent::nodeEncode($searchList['SearchResult'], array(), false); $result['SearchCount'] = $searchList['SearchCount']; $result['SearchOffset'] = $searchOffset; $result['SearchLimit'] = $searchLimit; $result['SearchExtras'] = array(); if (isset($param['SpellCheck'])) { $result['SearchExtras']['spellcheck'] = $searchList['SearchExtras']->attribute('spellcheck'); } if (isset($param['facet'])) { $facetInfo = array(); $retrievedFacets = $searchList['SearchExtras']->attribute('facet_fields'); $baseSearchUrl = "/content/search/"; eZURI::transformURI($baseSearchUrl, false, 'full'); foreach ($defaultFacetFields as $key => $defaultFacet) { $facetData = $retrievedFacets[$key]; $facetInfo[$key] = array(); $facetInfo[$key][] = $defaultFacet['name']; if ($facetData != null) { foreach ($facetData['nameList'] as $key2 => $facetName) { $tmp = array(); if ($key2 != '') { $tmp[] = $baseSearchUrl . '?SearchText=' . $searchStr . '&filter[]=' . $facetData['queryLimit'][$key2] . '&activeFacets[' . $defaultFacet['field'] . ':' . $defaultFacet['name'] . ']=' . $facetName; $tmp[] = $facetName; $tmp[] = "(" . $facetData['countList'][$key2] . ")"; $facetInfo[$key][] = $tmp; } } } } $result['SearchExtras']['facets'] = $facetInfo; } return $result; }
} break; case 'zone': $blockINI = eZINI::instance('block.ini'); if ($http->hasPostVariable('zone')) { $zoneID = $http->postVariable('zone'); if ($page instanceof eZPage) { foreach ($page->attribute('zones') as $zone) { if ($zone->attribute('id') === $zoneID) { foreach ($zone->attribute('blocks') as $index => $block) { if ($blockINI->hasVariable($block->attribute('type'), 'ManualAddingOfItems') && $blockINI->variable($block->attribute('type'), 'ManualAddingOfItems') === 'enabled') { if ($blockINI->hasVariable($block->attribute('type'), 'AllowedClasses')) { $allowedClasses = $blockINI->variable($block->attribute('type'), 'AllowedClasses'); if (in_array($classIdentifier, $allowedClasses)) { $res[] = array('index' => $index, 'id' => $block->attribute('id'), 'name' => $block->attribute('name')); } } else { $res[] = array('index' => $index, 'id' => $block->attribute('id'), 'name' => $block->attribute('name')); } } } break; } } } } break; } echo eZFlowAjaxContent::jsonEncode($res); } eZExecution::cleanExit();