private function getDocumentIds()
 {
     if ($this->search_result_ids === null) {
         $sphinx_config = SphinxSearch_Config::getInstance();
         $documents_config = $sphinx_config->getDocumentsAsArray();
         $query = $this->query;
         if (!$this->getUnpublished()) {
             $query = $query . " @o_published 1";
         }
         $language = "all";
         if ($this->plugin_config->documents->use_i18n == "true") {
             $locale = Zend_Registry::get("Zend_Locale");
             $language = $locale->getLanguage();
         }
         foreach ($documents_config as $document_name => $document_properties) {
             $indexes[] = "idx_document_" . $document_name . "_" . $language;
         }
         $search_result = $this->SphinxClient->Query($query, implode(", ", $indexes));
         if ($search_result === false) {
             throw new Exception($this->SphinxClient->GetLastError());
         }
         if ($search_result["total_found"] > 0) {
             $this->search_result_ids = array_keys($search_result["matches"]);
         } else {
             $this->search_result_ids = array();
         }
     }
     return $this->search_result_ids;
 }
 public function __construct($query, $class_name)
 {
     parent::__construct($query);
     $class_name = strtolower($class_name);
     $this->class_name = $class_name;
     $sphinx_config = SphinxSearch_Config::getInstance();
     $class_config = $sphinx_config->getClassesAsArray();
     // The configuration
     $field_weights = array();
     foreach ($class_config[$this->class_name] as $field_name => $field_config) {
         if (array_key_exists("weight", $field_config)) {
             $field_weights[$field_name] = $field_config["weight"];
         }
     }
     if (sizeof($field_weights) > 0) {
         $this->SphinxClient->setFieldWeights($field_weights);
     }
 }
ini_set('memory_limit', '2048M');
set_time_limit(-1);
date_default_timezone_set("Europe/Berlin");
include_once dirname(__FILE__) . "/../../../pimcore/config/startup.php";
Pimcore::initAutoloader();
Pimcore::initConfiguration();
Pimcore::initLogger();
Pimcore::initPlugins();
$opts = new Zend_Console_Getopt(array('language|l=s' => "language", 'document|d=s' => "document"));
try {
    $opts->parse();
} catch (Exception $e) {
    Logger::critical($e->getMessage());
    die("Error: " . $e->getMessage());
}
$sphinx_config = SphinxSearch_Config::getInstance();
$documents = $sphinx_config->getDocumentsAsArray();
if (!array_key_exists($opts->document, $documents)) {
    SphinxSearch_Logger::err("Unknown document: " . $opts->document . "\n");
    print "Unknown document: " . $opts->document . "\n";
    print "Possible documents are:\n";
    foreach ($documents as $document_name => $document_config) {
        print $document_name . "\n";
    }
    die;
}
$document_config = $documents[$opts->document];
$controller = $document_config["controller"];
$action = $document_config["action"];
$template = $document_config["template"];
$db = Pimcore_Resource::get();
 public static function queryDocument($query, $params = array())
 {
     if (trim($query) == "") {
         return array();
     }
     $sphinx_config = SphinxSearch_Config::getInstance();
     $documents_config = $sphinx_config->getDocumentsAsArray();
     $SphinxClient = new SphinxClient();
     $entries = array();
     $language = "all";
     if (SphinxSearch_Config_Plugin::getValue("documents", "use_i18n") == "true") {
         if (array_key_exists("language", $params)) {
             $language = $params["language"];
         } else {
             $locale = Zend_Registry::get("Zend_Locale");
             $language = $locale->getLanguage();
         }
     }
     $field_weights = array();
     $indexes = array();
     foreach ($documents_config as $document_name => $document_properties) {
         $indexes[] = "idx_document_" . $document_name . "_" . $language;
         foreach ($document_properties["elements"] as $field_name => $field_config) {
             if (array_key_exists("weight", $field_config) && intval($field_config["weight"]) > 0) {
                 $field_weights[$field_name] = intval($field_config["weight"]);
             }
         }
     }
     if (sizeof($field_weights) > 0) {
         $SphinxClient->setFieldWeights($field_weights);
     }
     $search_result = $SphinxClient->Query($query, implode(", ", $indexes));
     if ($search_result === false) {
         throw new Exception($SphinxClient->GetLastError());
     }
     if ($search_result["total_found"] > 0) {
         foreach ($search_result["matches"] as $id => $meta) {
             $entries[] = array("result" => Document::getById($id), "id" => $id, "meta" => $meta, "type" => "document");
         }
     }
     return $entries;
 }
 public static function isSearchdRunning()
 {
     $config = SphinxSearch_Config::getInstance();
     $pid_file = PIMCORE_DOCUMENT_ROOT . DIRECTORY_SEPARATOR . SphinxSearch_Config_Plugin::getValue("path", "pid");
     if (!file_exists($pid_file)) {
         //die("PIDFILE ".$pid_file." nicht gefunden");
         return false;
     }
     $pid = trim(file_get_contents($pid_file));
     exec("ps {$pid}", $output, $result);
     return count($output) >= 2;
 }