Ejemplo n.º 1
0
 function CamelizeResult($Data, $bRemoveUnderscoreKeys = True)
 {
     $Data = Gdn_Format::ObjectAsArray($Data);
     $Keys = array_keys($Data);
     $CamelizedKeys = array_map('Camelize', $Keys);
     $Keys = array_combine($Keys, $CamelizedKeys);
     foreach ($Keys as $Key => $CamelizedKey) {
         $Data[$CamelizedKey] = $Data[$Key];
         if ($bRemoveUnderscoreKeys) {
             unset($Data[$Key]);
         }
     }
     $Data = Gdn_Format::ArrayAsObject($Data);
     return $Data;
 }
 public function GetAllSettings()
 {
     self::$All = array('SearchOptions' => Gdn_Format::ArrayAsObject(self::GetSearchOptions()), 'Wizard' => Gdn_Format::ArrayAsObject(self::GetWizardSettings()), 'Install' => Gdn_Format::ArrayAsObject(self::GetInstall()), 'Status' => Gdn_Format::ArrayAsObject(self::GetStatus()), 'Admin' => Gdn_Format::ArrayAsObject(self::GetAdminSettings()));
     return self::$All;
 }
 private function RunSearch($Sender = FALSE)
 {
     $FinalResults = array();
     if (sizeof($this->Queries) == 0) {
         return $FinalResults;
     } else {
         if (true) {
             //if($this->Settings['Status']->SearchdRunning)
             //print_r($this->Queries); die;
             // print_r($this->SphinxClient->_filters); die;
             $Results = $this->SphinxClient->RunQueries();
             //perform all of the queries
             //print_r($Results); die;
             /**
              * This will publicly announce any errors or warnings to the main search page. If this is unwarranted, simply
              * comment the following few lines. However this if usually the first place to look for any errors in the install
              */
             if ($Results === false) {
                 echo "Query failed: " . $this->SphinxClient->GetLastError() . ".\n";
             } else {
                 if ($this->SphinxClient->GetLastWarning()) {
                     echo "WARNING: " . $this->SphinxClient->GetLastWarning() . ".\n";
                 }
             }
             if ($Results) {
                 foreach ($this->Queries as $Query) {
                     $ResultDocs = array();
                     $Index = $Query['Index'];
                     $Name = $Query['Name'];
                     $Result = $Results[$Index];
                     //get the individual query result from the results tree
                     if ($Result['error'] == FALSE && $Result['total_found'] != 0 && isset($Result['matches'])) {
                         //no errors
                         foreach ($Result['matches'] as $Id => $Info) {
                             //preserve the returned Doc ID
                             if (isset($Info['attrs'])) {
                                 $ResultDocs[$Id] = Gdn_Format::ArrayAsObject($Info['attrs']);
                             }
                             //get the result documents
                         }
                         $Words = '';
                         if (isset($Result['words'])) {
                             foreach ($Result['words'] as $Word => $Info) {
                                 $Words .= $Word . ' ';
                                 //get the submitted input query
                             }
                             $Results[$Index]['query'] = $Words;
                             //add the query back into the resuls array
                         }
                         $Results[$Index]['matches'] = $ResultDocs;
                         //replace highlighted docs back into the main results array
                     }
                     $FinalResults[$Name] = $Results[$Index];
                 }
             }
         }
     }
     //PRINT_R($FinalResults); die;
     return $FinalResults;
 }
Ejemplo n.º 4
0
<ul class="DataList SearchResults">
<?php 
if (is_array($this->SearchResults) && count($this->SearchResults) > 0) {
    foreach ($this->SearchResults as $Key => $Row) {
        $Row = Gdn_Format::ArrayAsObject($Row);
        ?>
	<li class="Item">
		<div class="ItemContent">
			<?php 
        echo Anchor(Gdn_Format::Text($Row->Title), $Row->Url, 'Title');
        ?>
			<div class="Excerpt"><?php 
        echo Anchor(SliceString($Row->Summary, 250), $Row->Url);
        ?>
</div>
			<div class="Meta">
				<span><?php 
        printf(T('Comment by %s'), UserAnchor($Row));
        ?>
</span>
				<span><?php 
        echo Gdn_Format::Date($Row->DateInserted);
        ?>
</span>
				<span><?php 
        echo Anchor(T('permalink'), $Row->Url);
        ?>
</span>
			</div>
		</div>
	</li>