コード例 #1
0
ファイル: downloads.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard modular run function for rendering a search result.
  *
  * @param  array		The data row stored when we retrieved the result
  * @return tempcode	The output
  */
 function render($row)
 {
     global $SEARCH__CONTENT_BITS;
     $highlight_bits = is_null($SEARCH__CONTENT_BITS) ? array() : $SEARCH__CONTENT_BITS;
     if (array_key_exists(0, $highlight_bits)) {
         $pos = strpos($row['download_data_mash'], $highlight_bits[0]) - 1000;
     } else {
         $pos = 0;
     }
     $mash_portion = substr($row['download_data_mash'], $pos, 10000);
     $_text_summary = trim(preg_replace('#\\s+#', ' ', $mash_portion));
     if ($_text_summary === false) {
         $_text_summary = '';
     }
     global $LAX_COMCODE;
     $LAX_COMCODE = true;
     $text_summary_h = comcode_to_tempcode($_text_summary, NULL, false, 60, NULL, NULL, false, false, false, false, false, $highlight_bits);
     $LAX_COMCODE = false;
     $text_summary = generate_text_summary($text_summary_h->evaluate(), $highlight_bits);
     return get_download_html($row, true, true, NULL, $text_summary);
 }
コード例 #2
0
ファイル: comcode_pages.php プロジェクト: erico-deh/ocPortal
 /**
  * Decide how to show a comcode page in the search results.
  *
  * @param  ID_TEXT		The zone for the page
  * @param  ID_TEXT		The page name
  * @param  string			What search hooks the search is being limited to (blank: not limited)
  * @return tempcode		The tempcode showing the comcode page
  */
 function decide_template($zone, $page, $limit_to)
 {
     global $SEARCH__CONTENT_BITS;
     require_code('xhtml');
     $url = build_url(array('page' => $page), $zone);
     /*		if ($limit_to=='') // If we're not limited to searching comcode pages, then we must show it is a Comcode page
     			return put_in_standard_box(hyperlink($url,escape_html($page)),escape_html($page)'COMCODE_PAGE'));
     		else return paragraph(hyperlink($url,$page));*/
     //		$_summary=request_page($page,true,$zone,NULL,true);
     //		$summary=$_summary->evaluate();
     $_summary = seo_meta_get_for('comcode_page', $zone . ':' . $page);
     $summary = $_summary[1];
     if ($summary == '') {
         $page_request = _request_page($page, $zone);
         if (strpos($page_request[0], 'COMCODE') === false) {
             return new ocp_tempcode();
         }
         $comcode_file = $page_request[count($page_request) - 1];
         if (file_exists($comcode_file)) {
             global $LAX_COMCODE;
             $LAX_COMCODE = true;
             /*$temp_summary=comcode_to_tempcode(file_get_contents($comcode_file,FILE_TEXT),NULL,true); Tempcode compiler slowed things down so easier just to show full thing
             		$_temp_summary=$temp_summary->evaluate();
             		if (strlen($_temp_summary)<500)
             		{
             			$summary=$_temp_summary;
             		} else
             		{
             			$entity='&hellip;';
             			if (function_exists('ocp_mark_as_escaped')) ocp_mark_as_escaped($entity);
             			$pos=false;//strpos($_temp_summary,'<span class="comcode_highlight">');
             			if ($pos===false) $pos=0;
             			$pos2=max(0,$pos-250);
             			$summary=(($pos2==0)?'':$entity).xhtml_substr($_temp_summary,$pos2,500).$entity;
             		}*/
             $GLOBALS['OVERRIDE_SELF_ZONE'] = $zone;
             $backup_search__contents_bits = $SEARCH__CONTENT_BITS;
             $SEARCH__CONTENT_BITS = NULL;
             // We do not want highlighting, as it'll result in far too much Comcode being parsed (ok for short snippets, not many full pages!)
             $temp_summary = request_page($page, true, $zone, strpos($comcode_file, '/comcode_custom/') ? 'comcode_custom' : 'comcode', true);
             $SEARCH__CONTENT_BITS = $backup_search__contents_bits;
             $GLOBALS['OVERRIDE_SELF_ZONE'] = NULL;
             $LAX_COMCODE = false;
             $_temp_summary = $temp_summary->evaluate();
             global $LOADED_PAGES;
             $LOADED_PAGES = array();
             // Decache this, or we'll eat up a tonne of RAM
             $summary = generate_text_summary($_temp_summary, is_null($SEARCH__CONTENT_BITS) ? array() : $SEARCH__CONTENT_BITS);
         }
     }
     $tpl = do_template('COMCODE_PAGE_PREVIEW', array('_GUID' => '79cd9e7d0b63ee916c4cd74b26c2f652', 'PAGE' => $page, 'ZONE' => $zone, 'URL' => $url, 'SUMMARY' => $summary));
     require_lang('comcode');
     $title = do_lang_tempcode('_SEARCH_RESULT_COMCODE_PAGE', escape_html($page));
     global $LAST_COMCODE_PARSED_TITLE;
     if ($LAST_COMCODE_PARSED_TITLE != '') {
         $title = do_lang_tempcode('_SEARCH_RESULT_COMCODE_PAGE_NICE', escape_html($LAST_COMCODE_PARSED_TITLE));
     }
     $tree = comcode_breadcrumbs($page, $zone);
     if (!$tree->is_empty()) {
         $tpl->attach(paragraph(do_lang_tempcode('LOCATED_IN', $tree)));
     }
     return put_in_standard_box($tpl, $title);
 }