public function run()
    {
        if (Yii::app()->user->isGuest) {
            return;
        }
        $powerAdmin = array('sagittaros', 'yiseng', 'yugene');
        $username = Yii::app()->user->id;
        if (in_array($username, $powerAdmin)) {
            $solr = new Solr('search-engine');
            $res = $solr->query('id:"' . $this->dealUrl . '"');
            $docs = $res->response->docs;
            if (array_key_exists(0, $docs)) {
                $options = array('Eateries' => 'Eateries', 'Fun & Activities' => 'Fun & Activities', 'Beauty & Wellness' => 'Beauty & Wellness', 'Goods' => 'Goods', 'Services & Others' => 'Services & Others', 'Travel' => 'Travel');
                $ajaxScript = <<<EOD
jQuery.get('/admin/dealCrud/updateCategory',
    {'id':'{$this->dealUrl}','category':jQuery(this).val()},
    postUpdateCategoryAction
); 

function postUpdateCategoryAction(data) {
    if(data == 'SUCCESS'){
        console.log("success");
        alert('success');
    } else {
        console.log(data);
        alert("update failed");
    }
}

EOD;
                $htmlOptions = array('onchange' => $ajaxScript);
                echo CHtml::dropDownList('category', $res->response->docs[0]->category_raw, $options, $htmlOptions);
            }
        }
    }
 function test_search_by_id_returns_single_record()
 {
     # Check that searching for an ID only gives you one result
     $test_items = array('TKI80868', 'TKI80039', 'TKI80875');
     foreach ($test_items as $value) {
         $solr = new Solr();
         $this->assertEqual(1, $solr->count($value), Helpers::search_link($value) . " should return only 1 result");
     }
 }
 function test_staging_urls_return_no_matches()
 {
     # Test paths for common staging urls
     $test_items = array('staging.internal', 'dev.internal', 'preprod');
     foreach ($test_items as $value) {
         $solr = new Solr();
         $this->assertEqual(0, $solr->count($value), "Search for " . Helpers::search_link($value) . " returns " . $solr->count() . " results, when none should be returned");
     }
 }
 function test_community_names_return_homepage_as_first_result()
 {
     # Check that first result for each query is appropriate
     # homepage id
     $test_items = array('english online' => 'TKI80868', 'assessment online' => 'TKI58274', 'assessment' => 'TKI58274', 'education for enterprise' => 'TKI45249', 'digistore' => 'TKI59990', 'alternative education' => 'TKI17383', 'digital technology guidelines' => 'TKI50586', 'dtg' => 'TKI50586', 'e-asttle' => 'TKI38879', 'education for sustainability' => 'TKI50157', 'literacy online' => 'TKI58077', 'education outside the classroom' => 'TKI58260', 'esol online' => 'TKI13739', 'gifted and talented' => 'TKI17424', 'gifted and talented online' => 'TKI17424', 'he kohinga rauemi a-ipurangi' => 'TKI50637', 'new zealand curriculum' => 'TKI46672', 'tax citizenship' => 'TKI80668', 'arts online' => 'TKI31449', 'arts' => 'TKI31449', 'educational leaders' => 'TKI57127', 'home-school partnerships' => 'TKI59527', 'home school partnerships' => 'TKI59527', 'te tere auraki' => 'TKI28409', 'success for boys' => 'TKI50135', 'software for learning' => 'TKI50191');
     foreach ($test_items as $key => $value) {
         $solr = new Solr();
         $this->assertEqual($value, $solr->first($key), "{$value} wasn't first result for query " . Helpers::search_link($key));
     }
 }
 function test_phrases_in_index_return_matches()
 {
     # Checks first that searching for the phrase inside quotes does match
     # If it does, checks for matches without quotes.
     $test_items = array('"animals in circuses"', '"This Chinese official"', '"This Taihape Area School"', '"refers to Waitangi as"', '"posted on any forum"', '"highest level of their interest and ability"');
     foreach ($test_items as $value) {
         $solr = new Solr();
         if ($solr->count($value) >= 1) {
             $value = trim($value, '"');
             $solr = new Solr();
             $this->assertNotEqual(0, $solr->count($value), Helpers::search_link($value) . " has " . $solr->count() . " results");
         }
     }
 }
 function test_legacy_paths_not_indexed_with_nonlegacy_domains()
 {
     # Searches for legacy urls on non-legacy domains, like:
     # gifted.tki.org.nz/m/search/
     $test_domains = array('gifted.tki.org.nz', 'www.wicked.org.nz', 'assessment.tki.org.nz', 'nzcurriculum.tki.org.nz', 'secondary.tki.org.nz', 'englishonline.tki.org.nz', 'artsonline.tki.org.nz');
     $test_paths = array('/e/community/ncea/', '/e/community/maorieducation/', '/e/community/pasifika/', '/m/search/', '/e/search/', '/r/literacy_numeracy/professional/teachers_notes/ready_to_read/');
     foreach ($test_domains as $domain) {
         foreach ($test_paths as $path) {
             $solr = new Solr();
             $query = $domain . $path;
             $this->assertEqual(0, $solr->count($query), Helpers::search_link($query) . " should return no results");
         }
     }
 }
 public function actionIndex()
 {
     $solr = new Solr('deal-category');
     $solr->getService()->deleteByQuery('*:*');
     $cats = KeywordCategory::model()->findAll();
     $allkeywords = '';
     foreach ($cats as $c) {
         $sql = "select term from Keyword where category = {$c->id}";
         $command = Yii::app()->db->createCommand($sql);
         $rows = $command->queryColumn();
         $doc = $solr->getDoc();
         $doc->id = trim($c->name);
         $doc->keywords = implode(" ", $rows);
         $allkeywords .= $doc->keywords . ' ';
         d($doc);
         $solr->getService()->addDocument($doc);
     }
     $doc = $solr->getDoc();
     $doc->id = "Services & Others";
     $doc->keywords = $allkeywords;
     $solr->getService()->addDocument($doc);
     $solr->getService()->commit();
     $solr->getService()->optimize();
     $this->render('index');
 }
 function assessSimilarity($array, $strict = 1, $drift = 2)
 {
     foreach ($array as $key => $value) {
         $solr = new Solr();
         $results = $solr->search($key, count($value) * $drift);
         $matches = 0;
         foreach ($results as $pid) {
             if (in_array($pid, $value)) {
                 $matches++;
             }
         }
         $this->assertTrue($matches * $strict >= count($value), "Search for " . Helpers::search_link($key) . " returned " . $matches . " of it's expected results in the top " . count($value) * $drift);
     }
 }
 /**
  * Process a single group.
  *
  * Without queuedjobs, it's necessary to shell this out to a background task as this is
  * very memory intensive.
  *
  * The sub-process will then invoke $processor->runGroup() in {@see Solr_Reindex::doReindex}
  *
  * @param LoggerInterface $logger
  * @param SolrIndex $indexInstance Index instance
  * @param array $state Variant state
  * @param string $class Class to index
  * @param int $groups Total groups
  * @param int $group Index of group to process
  * @param string $taskName Name of task script to run
  */
 protected function processGroup(LoggerInterface $logger, SolrIndex $indexInstance, $state, $class, $groups, $group, $taskName)
 {
     // Build state
     $statevar = json_encode($state);
     if (strpos(PHP_OS, "WIN") !== false) {
         $statevar = '"' . str_replace('"', '\\"', $statevar) . '"';
     } else {
         $statevar = "'" . $statevar . "'";
     }
     // Build script
     $indexName = $indexInstance->getIndexName();
     $scriptPath = sprintf("%s%sframework%scli-script.php", BASE_PATH, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR);
     $scriptTask = "php {$scriptPath} dev/tasks/{$taskName}";
     $cmd = "{$scriptTask} index={$indexName} class={$class} group={$group} groups={$groups} variantstate={$statevar}";
     $cmd .= " verbose=1 2>&1";
     $logger->info("Running '{$cmd}'");
     // Execute script via shell
     $res = $logger ? passthru($cmd) : `{$cmd}`;
     if ($logger) {
         $logger->info(preg_replace('/\\r\\n|\\n/', '$0  ', $res));
     }
     // If we're in dev mode, commit more often for fun and profit
     if (Director::isDev()) {
         Solr::service($indexName)->commit();
     }
     // This will slow down things a tiny bit, but it is done so that we don't timeout to the database during a reindex
     DB::query('SELECT 1');
 }
 function test_nzmaths_where_appropriate()
 {
     # Checks that first 10 results for nzmaths related keywords
     # return good proportion of MZMaths items. Ensures fix for
     # previous function doesn't work too well.
     $test_items = array('ALiM school stories nzmaths', 'Algebra information', 'Attribute Blocks: Exploring Shape', 'scuba');
     foreach ($test_items as $value) {
         $solr = new Solr();
         $pids = $solr->search($value, 50);
         $i = 0;
         foreach ($pids as $id) {
             if (preg_match('/nzmaths/', $id)) {
                 $i++;
             }
         }
         $this->assertTrue($i > 0, "Search for " . Helpers::search_link($value) . " has insufficient nzmaths items");
     }
 }
 /**
  * Overwrite template paths to only use the path defined on the yaml file
  * @see SolrIndex::getTemplatesPath
  */
 public function getTemplatesPath()
 {
     $options = Config::inst()->get('FAQSearchIndex', 'options');
     $globalOptions = Solr::solr_options();
     if (isset($options['templatespath']) && file_exists($options['templatespath'])) {
         $globalOptions['templatespath'] = $options['templatespath'];
     }
     return $this->templatesPath ? $this->templatesPath : $globalOptions['templatespath'];
 }
Exemple #12
0
 /**
  * this will load the file containing the class
  *
  * @param string $className
  */
 public static function autoload($className)
 {
     if (!is_string($className)) {
         throw new InvalidArgumentException();
     }
     if (array_key_exists($className, self::$classMap)) {
         require_once dirname(__FILE__) . '/' . self::$classMap[$className];
     } else {
         parent::autoload($className);
     }
 }
 public function actionUpdateCategory($id, $category)
 {
     $solr = new Solr('search-engine');
     $solr_arc = new Solr('archive');
     $res = $solr->query('id:"' . $id . '"');
     $oldDoc = (array) $res->response->docs[0];
     $doc = $solr->getDoc();
     $doc->id = $id;
     $doc->category = $category;
     foreach ($oldDoc as $k => $v) {
         switch ($k) {
             case 'title':
             case 'dealsource':
             case 'price':
             case 'discount':
             case 'worth':
             case 'description':
             case 'imgsrc':
             case 'expiry':
             case 'merchant':
             case 'location':
             case 'bought':
             case 'created':
                 $doc->{$k} = $v;
                 break;
         }
     }
     try {
         $solr->getService()->addDocument($doc);
         $solr->getService()->commit();
         $solr->getService()->optimize();
         $solr_arc->getService()->addDocument($doc);
         $solr_arc->getService()->commit();
         $solr_arc->getService()->optimize();
         echo 'SUCCESS';
     } catch (Exception $e) {
         echo $e->getMessage();
         echo $e->getTrace();
     }
     Yii::app()->end();
 }
Exemple #14
0
 private function loadSolrRecord($id)
 {
     global $configArray;
     //Load basic information
     $this->id = $_GET['id'];
     $itemData['id'] = $this->id;
     // Setup Search Engine Connection
     $class = $configArray['Index']['engine'];
     $url = $configArray['Index']['url'];
     $this->db = new $class($url);
     // Retrieve Full Marc Record
     if (!($record = $this->db->getRecord($this->id))) {
         PEAR_Singleton::raiseError(new PEAR_Error('Record Does Not Exist'));
     }
     return $record;
 }
 /**
  * @inheritdoc
  *
  * @return array
  */
 function check()
 {
     $brokenCores = array();
     if (!class_exists('Solr')) {
         return array(EnvironmentCheck::ERROR, 'Class `Solr` not found. Is the fulltextsearch module installed?');
     }
     $service = Solr::service();
     foreach (Solr::get_indexes($this->indexClass) as $index) {
         $core = $index->getIndexName();
         if (!$service->coreIsActive($core)) {
             $brokenCores[] = $core;
         }
     }
     if (!empty($brokenCores)) {
         return array(EnvironmentCheck::ERROR, 'The following indexes are unavailable: ' . implode($brokenCores, ', '));
     }
     return array(EnvironmentCheck::OK, 'Expected indexes are available.');
 }
Exemple #16
0
 /**
  * Constructor
  *
  * @param string $host The URL for the local Solr Server
  *
  * @access public
  */
 public function __construct($host)
 {
     parent::__construct($host, 'stats');
 }
Exemple #17
0
 /**
  * Getter for magic properties.
  * 
  * @param string $property The parameter.
  * @return mixed
  */
 public function __get($property)
 {
     if (!is_string($property)) {
         throw new InvalidArgumentException();
     }
     switch ($property) {
         case 'facets':
             if (is_null($this->facets)) {
                 Solr::autoload('SolrSimpleFacets');
                 $this->facets = new SolrSimpleFacets();
             }
             return $this->facets;
         default:
             throw new OutOfRangeException('Undefined property.');
     }
 }
Exemple #18
0
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * 
 * @package php_solr
 * @subpackage indexer
 * @author Alexander M. Turek <*****@*****.**>
 * @copyright 2008, Alexander M. Turek
 * @license http://www.opensource.org/licenses/bsd-license.php BSD License
 * @version $Id$
 */
Solr::autoload('SolrField');
/**
 * A Solr Field.
 * 
 * @author Alexander M. Turek <*****@*****.**>
 * @package php_solr
 * @subpackage indexer
 */
class SolrSimpleField implements SolrField
{
    /**
     * The name of the field.
     *
     * @var string
     */
    private $name = null;
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * 
 * @package php_solr
 * @subpackage testcases
 * @author Alexander M. Turek <*****@*****.**>
 * @copyright 2008, Alexander M. Turek
 * @license http://www.opensource.org/licenses/bsd-license.php BSD License
 * @version $Id$
 */
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__) . '/../src/Solr.php';
Solr::autoload('SolrSimpleDocument');
Solr::autoload('SolrSimpleField');
/**
 *  Test case for {@link SolrSimpleDocument}.
 * 
 * @package php_solr
 * @subpackage testcases
 * @author Alexander M. Turek <*****@*****.**>
 */
class SolrSimpleDocumentTest extends PHPUnit_Framework_TestCase
{
    /**
     * Tests the normal usage of the class.
     */
    function testNormalUsage()
    {
        $doc = new SolrSimpleDocument();
Exemple #20
0
 /**
  * @covers Phansible\Roles\Solr::getInitialValues
  */
 public function testShouldGetInitialValues()
 {
     $role = new Solr($app);
     $expected = ['install' => 0, 'port' => '8983', 'version' => '5.2.0'];
     $this->assertEquals($expected, $role->getInitialValues());
 }
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * 
 * @package php_solr
 * @subpackage testcases
 * @author Alexander M. Turek <*****@*****.**>
 * @copyright 2008, Alexander M. Turek
 * @license http://www.opensource.org/licenses/bsd-license.php BSD License
 * @version $Id$
 */
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__) . '/../src/Solr.php';
Solr::autoload('SolrConnection');
Solr::autoload('SolrDocument');
Solr::autoload('SolrField');
Solr::autoload('SolrHttpClient');
/**
 *  Test case for the <add /> command.
 * 
 * @package php_solr
 * @subpackage testcases
 * @author Alexander M. Turek <*****@*****.**>
 */
class SolrAddCommandTest extends PHPUnit_Framework_TestCase
{
    /**
     * A {@link SolrConnection} instance with a mocked HTTP_Client.
     *
     * @var SolrConnection
     */
    private $solr = null;
Exemple #22
0
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * 
 * @package php_solr
 * @subpackage search
 * @author Alexander M. Turek <*****@*****.**>
 * @copyright 2009, Alexander M. Turek
 * @license http://www.opensource.org/licenses/bsd-license.php BSD License
 * @version $Id$
 */
Solr::autoload('SolrFacetFieldParameters');
/**
 * A facet field.
 * 
 * @see http://wiki.apache.org/solr/SimpleFacetParameters
 * 
 * @package php_solr
 * @subpackage search
 * @author Alexander M. Turek <*****@*****.**>
 * @since 0.4.1
 */
class SolrFacetField extends SolrFacetFieldParameters
{
    /**
     * Constructor for {@link SolrFacetField}.
     * 
 /**
  * @param string $sourceSolrId
  * @param string $issn
  * @param integer $numResourcesToLoad
  * @param Solr $db
  * @return null
  */
 private static function getXISSN($sourceSolrId, $issn, $numResourcesToLoad, $db)
 {
     global $configArray;
     // Build URL
     $url = 'http://xissn.worldcat.org/webservices/xid/issn/' . urlencode(is_array($issn) ? $issn[0] : $issn) . '?method=getEditions&format=xml';
     if (isset($configArray['WorldCat']['id'])) {
         $url .= '&ai=' . $configArray['WorldCat']['id'];
     }
     // Print Debug code
     if ($configArray['System']['debug']) {
         global $logger;
         $logger->log("<pre>XISSN: {$url}</pre>", PEAR_LOG_INFO);
     }
     // Fetch results
     $query = '';
     $data = @file_get_contents($url);
     if (empty($data)) {
         return null;
     }
     $unxml = new XML_Unserializer();
     $unxml->unserialize($data);
     $data = $unxml->getUnserializedData($data);
     if (!empty($data) && isset($data['group']['issn'])) {
         if (is_array($data['group']['issn'])) {
             foreach ($data['group']['issn'] as $issn) {
                 if ($query != '') {
                     $query .= ' OR issn:' . $issn;
                 } else {
                     $query = 'issn:' . $issn;
                 }
             }
         } else {
             $query = 'issn:' . $data['group']['issn'];
         }
     }
     if ($query) {
         // Filter out current record
         $query .= ' NOT id:' . $sourceSolrId;
         $result = $db->search($query, null, null, 0, $numResourcesToLoad);
         if (!PEAR_Singleton::isError($result)) {
             if (isset($result['response']['docs']) && !empty($result['response']['docs'])) {
                 return $result['response']['docs'];
             } else {
                 return null;
             }
         } else {
             return $result;
         }
     } else {
         return null;
     }
 }
Exemple #24
0
 /**
  * Constructor
  *
  * @param \VuFind\Search\Results\PluginManager $results Results plugin manager
  */
 public function __construct(\VuFind\Search\Results\PluginManager $results)
 {
     parent::__construct($results);
     $this->defaultDisplayField = 'heading';
     $this->searchClassId = 'SolrAuth';
 }
Exemple #25
0
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */
ini_set('memory_limit', '50M');
ini_set('max_execution_time', '3600');
require_once 'util.inc.php';
// set up util environment
require_once 'sys/Solr.php';
// Read Config file
$configArray = parse_ini_file('../web/conf/config.ini', true);
// Setup Solr Connection -- Allow core to be specified as first command line param.
$url = $configArray['Index']['url'];
$solr = new Solr($url, isset($argv[1]) ? $argv[1] : '');
if ($configArray['System']['debugSolr']) {
    $solr->debug = true;
}
// Commit and Optimize the Solr Index
$solr->commit();
$solr->optimize();
Exemple #26
0
 function __construct($subAction = false, $record_id = null)
 {
     global $interface;
     global $configArray;
     global $library;
     global $timer;
     global $logger;
     $interface->assign('page_body_style', 'sidebar_left');
     $interface->assign('libraryThingUrl', $configArray['LibraryThing']['url']);
     //Determine whether or not materials request functionality should be enabled
     $interface->assign('enableMaterialsRequest', MaterialsRequest::enableMaterialsRequest());
     //Load basic information needed in subclasses
     if ($record_id == null || !isset($record_id)) {
         $this->id = $_GET['id'];
     } else {
         $this->id = $record_id;
     }
     //Check to see if the record exists within the resources table
     $resource = new Resource();
     $resource->record_id = $this->id;
     $resource->source = 'VuFind';
     $resource->deleted = 0;
     if (!$resource->find()) {
         //Check to see if the record has been converted to an eContent record
         require_once ROOT_DIR . '/sys/eContent/EContentRecord.php';
         $econtentRecord = new EContentRecord();
         $econtentRecord->ilsId = $this->id;
         $econtentRecord->status = 'active';
         if ($econtentRecord->find(true)) {
             header("Location: /EcontentRecord/{$econtentRecord->id}/Home");
             die;
         }
         $logger->log("Did not find a record for id {$this->id} in resources table.", PEAR_LOG_DEBUG);
         $interface->setTemplate('invalidRecord.tpl');
         $interface->display('layout.tpl');
         die;
     }
     if ($configArray['Catalog']['ils'] == 'Millennium') {
         $interface->assign('classicId', substr($this->id, 1, strlen($this->id) - 2));
         $interface->assign('classicUrl', $configArray['Catalog']['linking_url']);
     }
     // Setup Search Engine Connection
     $class = $configArray['Index']['engine'];
     $url = $configArray['Index']['url'];
     $this->db = new $class($url);
     $this->db->disableScoping();
     // Retrieve Full Marc Record
     if (!($record = $this->db->getRecord($this->id))) {
         $logger->log("Did not find a record for id {$this->id} in solr.", PEAR_LOG_DEBUG);
         $interface->setTemplate('invalidRecord.tpl');
         $interface->display('layout.tpl');
         die;
     }
     $this->db->enableScoping();
     $this->record = $record;
     $interface->assign('record', $record);
     $this->recordDriver = RecordDriverFactory::initRecordDriver($record);
     $timer->logTime('Initialized the Record Driver');
     $interface->assign('coreMetadata', $this->recordDriver->getCoreMetadata());
     // Process MARC Data
     require_once ROOT_DIR . '/sys/MarcLoader.php';
     $marcRecord = MarcLoader::loadMarcRecordFromRecord($record);
     if ($marcRecord) {
         $this->marcRecord = $marcRecord;
         $interface->assign('marc', $marcRecord);
     } else {
         $interface->assign('error', 'Cannot Process MARC Record');
     }
     $timer->logTime('Processed the marc record');
     //Load information for display in the template rather than processing specific fields in the template
     $marcField = $marcRecord->getField('245');
     $recordTitle = $this->getSubfieldData($marcField, 'a');
     $interface->assign('recordTitle', $recordTitle);
     $recordTitleSubtitle = trim($this->concatenateSubfieldData($marcField, array('a', 'b', 'h', 'n', 'p')));
     $recordTitleSubtitle = preg_replace('~\\s+[\\/:]$~', '', $recordTitleSubtitle);
     $interface->assign('recordTitleSubtitle', $recordTitleSubtitle);
     $recordTitleWithAuth = trim($this->concatenateSubfieldData($marcField, array('a', 'b', 'h', 'n', 'p', 'c')));
     $interface->assign('recordTitleWithAuth', $recordTitleWithAuth);
     $marcField = $marcRecord->getField('100');
     if ($marcField) {
         $mainAuthor = $this->concatenateSubfieldData($marcField, array('a', 'b', 'c', 'd'));
         $interface->assign('mainAuthor', $mainAuthor);
     }
     $marcField = $marcRecord->getField('110');
     if ($marcField) {
         $corporateAuthor = $this->getSubfieldData($marcField, 'a');
         $interface->assign('corporateAuthor', $corporateAuthor);
     }
     $marcFields = $marcRecord->getFields('700');
     if ($marcFields) {
         $contributors = array();
         foreach ($marcFields as $marcField) {
             $contributors[] = $this->concatenateSubfieldData($marcField, array('a', 'b', 'c', 'd'));
         }
         $interface->assign('contributors', $contributors);
     }
     $published = $this->recordDriver->getPublicationDetails();
     $interface->assign('published', $published);
     $marcFields = $marcRecord->getFields('250');
     if ($marcFields) {
         $editionsThis = array();
         foreach ($marcFields as $marcField) {
             $editionsThis[] = $this->getSubfieldData($marcField, 'a');
         }
         $interface->assign('editionsThis', $editionsThis);
     }
     $marcFields = $marcRecord->getFields('300');
     if ($marcFields) {
         $physicalDescriptions = array();
         foreach ($marcFields as $marcField) {
             $description = $this->concatenateSubfieldData($marcField, array('a', 'b', 'c', 'e', 'f', 'g'));
             if ($description != 'p. cm.') {
                 $description = preg_replace("/[\\/|;:]\$/", '', $description);
                 $description = preg_replace("/p\\./", 'pages', $description);
                 $physicalDescriptions[] = $description;
             }
         }
         $interface->assign('physicalDescriptions', $physicalDescriptions);
     }
     // Get ISBN for cover and review use
     $mainIsbnSet = false;
     /** @var File_MARC_Data_Field[] $isbnFields */
     if ($isbnFields = $this->marcRecord->getFields('020')) {
         $isbns = array();
         //Use the first good ISBN we find.
         foreach ($isbnFields as $isbnField) {
             /** @var File_MARC_Subfield $isbnSubfieldA */
             if ($isbnSubfieldA = $isbnField->getSubfield('a')) {
                 $tmpIsbn = trim($isbnSubfieldA->getData());
                 if (strlen($tmpIsbn) > 0) {
                     $isbns[] = $isbnSubfieldA->getData();
                     $pos = strpos($tmpIsbn, ' ');
                     if ($pos > 0) {
                         $tmpIsbn = substr($tmpIsbn, 0, $pos);
                     }
                     $tmpIsbn = trim($tmpIsbn);
                     if (strlen($tmpIsbn) > 0) {
                         if (strlen($tmpIsbn) < 10) {
                             $tmpIsbn = str_pad($tmpIsbn, 10, "0", STR_PAD_LEFT);
                         }
                         if (!$mainIsbnSet) {
                             $this->isbn = $tmpIsbn;
                             $interface->assign('isbn', $tmpIsbn);
                             $mainIsbnSet = true;
                         }
                     }
                 }
             }
         }
         if (isset($this->isbn)) {
             if (strlen($this->isbn) == 13) {
                 require_once ROOT_DIR . '/Drivers/marmot_inc/ISBNConverter.php';
                 $this->isbn10 = ISBNConverter::convertISBN13to10($this->isbn);
             } else {
                 $this->isbn10 = $this->isbn;
             }
             $interface->assign('isbn10', $this->isbn10);
         }
         $interface->assign('isbns', $isbns);
     }
     if ($upcField = $this->marcRecord->getField('024')) {
         /** @var File_MARC_Data_Field $upcField */
         if ($upcSubField = $upcField->getSubfield('a')) {
             $this->upc = trim($upcSubField->getData());
             $interface->assign('upc', $this->upc);
         }
     }
     if ($issnField = $this->marcRecord->getField('022')) {
         /** @var File_MARC_Data_Field $issnField */
         if ($issnSubField = $issnField->getSubfield('a')) {
             $this->issn = trim($issnSubField->getData());
             if ($pos = strpos($this->issn, ' ')) {
                 $this->issn = substr($this->issn, 0, $pos);
             }
             $interface->assign('issn', $this->issn);
             //Also setup GoldRush link
             if (isset($library) && strlen($library->goldRushCode) > 0) {
                 $interface->assign('goldRushLink', "http://goldrush.coalliance.org/index.cfm?fuseaction=Search&amp;inst_code={$library->goldRushCode}&amp;search_type=ISSN&amp;search_term={$this->issn}");
             }
         }
     }
     $timer->logTime("Got basic data from Marc Record subaction = {$subAction}, record_id = {$record_id}");
     //stop if this is not the main action.
     if ($subAction == true) {
         return;
     }
     //Get street date
     if ($streetDateField = $this->marcRecord->getField('263')) {
         $streetDate = $this->getSubfieldData($streetDateField, 'a');
         if ($streetDate != '') {
             $interface->assign('streetDate', $streetDate);
         }
     }
     /** @var File_MARC_Data_Field[] $marcField440 */
     $marcField440 = $marcRecord->getFields('440');
     /** @var File_MARC_Data_Field[] $marcField490 */
     $marcField490 = $marcRecord->getFields('490');
     /** @var File_MARC_Data_Field[] $marcField830 */
     $marcField830 = $marcRecord->getFields('830');
     if ($marcField440 || $marcField490 || $marcField830) {
         $series = array();
         foreach ($marcField440 as $field) {
             $series[] = $this->getSubfieldData($field, 'a');
         }
         foreach ($marcField490 as $field) {
             if ($field->getIndicator(1) == 0) {
                 $series[] = $this->getSubfieldData($field, 'a');
             }
         }
         foreach ($marcField830 as $field) {
             $series[] = $this->getSubfieldData($field, 'a');
         }
         $interface->assign('series', $series);
     }
     //Load description from Syndetics
     $useMarcSummary = true;
     if ($this->isbn || $this->upc) {
         if ($library && $library->preferSyndeticsSummary == 1) {
             require_once ROOT_DIR . '/Drivers/marmot_inc/GoDeeperData.php';
             $summaryInfo = GoDeeperData::getSummary($this->isbn, $this->upc);
             if (isset($summaryInfo['summary'])) {
                 $interface->assign('summaryTeaser', $summaryInfo['summary']);
                 $interface->assign('summary', $summaryInfo['summary']);
                 $useMarcSummary = false;
             }
         }
     }
     if ($useMarcSummary) {
         if ($summaryField = $this->marcRecord->getField('520')) {
             $interface->assign('summary', $this->getSubfieldData($summaryField, 'a'));
             $interface->assign('summaryTeaser', $this->getSubfieldData($summaryField, 'a'));
         } elseif ($library && $library->preferSyndeticsSummary == 0) {
             require_once ROOT_DIR . '/Drivers/marmot_inc/GoDeeperData.php';
             $summaryInfo = GoDeeperData::getSummary($this->isbn, $this->upc);
             if (isset($summaryInfo['summary'])) {
                 $interface->assign('summaryTeaser', $summaryInfo['summary']);
                 $interface->assign('summary', $summaryInfo['summary']);
                 $useMarcSummary = false;
             }
         }
     }
     if ($mpaaField = $this->marcRecord->getField('521')) {
         $interface->assign('mpaaRating', $this->getSubfieldData($mpaaField, 'a'));
     }
     if (isset($configArray['Content']['subjectFieldsToShow'])) {
         $subjectFieldsToShow = $configArray['Content']['subjectFieldsToShow'];
         $subjectFields = explode(',', $subjectFieldsToShow);
         $subjects = array();
         foreach ($subjectFields as $subjectField) {
             /** @var File_MARC_Data_Field[] $marcFields */
             $marcFields = $marcRecord->getFields($subjectField);
             if ($marcFields) {
                 foreach ($marcFields as $marcField) {
                     $searchSubject = "";
                     $subject = array();
                     foreach ($marcField->getSubFields() as $subField) {
                         /** @var File_MARC_Subfield $subField */
                         if ($subField->getCode() != 2) {
                             $searchSubject .= " " . $subField->getData();
                             $subject[] = array('search' => trim($searchSubject), 'title' => $subField->getData());
                         }
                     }
                     $subjects[] = $subject;
                 }
             }
             $interface->assign('subjects', $subjects);
         }
     }
     $format = $record['format'];
     $interface->assign('recordFormat', $record['format']);
     $format_category = isset($record['format_category'][0]) ? $record['format_category'][0] : '';
     $interface->assign('format_category', $format_category);
     $interface->assign('recordLanguage', isset($record['language']) ? $record['language'] : null);
     $timer->logTime('Got detailed data from Marc Record');
     $tableOfContents = array();
     $marcFields505 = $marcRecord->getFields('505');
     if ($marcFields505) {
         $tableOfContents = $this->processTableOfContentsFields($marcFields505);
     }
     $notes = array();
     $marcFields500 = $marcRecord->getFields('500');
     $marcFields504 = $marcRecord->getFields('504');
     $marcFields511 = $marcRecord->getFields('511');
     $marcFields518 = $marcRecord->getFields('518');
     $marcFields520 = $marcRecord->getFields('520');
     if ($marcFields500 || $marcFields504 || $marcFields505 || $marcFields511 || $marcFields518 || $marcFields520) {
         $allFields = array_merge($marcFields500, $marcFields504, $marcFields511, $marcFields518, $marcFields520);
         $notes = $this->processNoteFields($allFields);
     }
     if (isset($library) && $library->showTableOfContentsTab == 0 || count($tableOfContents) == 0) {
         $notes = array_merge($notes, $tableOfContents);
     } else {
         $interface->assign('tableOfContents', $tableOfContents);
     }
     if (isset($library) && strlen($library->notesTabName) > 0) {
         $interface->assign('notesTabName', $library->notesTabName);
     } else {
         $interface->assign('notesTabName', 'Notes');
     }
     $additionalNotesFields = array('310' => 'Current Publication Frequency', '321' => 'Former Publication Frequency', '351' => 'Organization & arrangement of materials', '362' => 'Dates of publication and/or sequential designation', '501' => '"With"', '502' => 'Dissertation', '506' => 'Restrictions on Access', '507' => 'Scale for Graphic Material', '508' => 'Creation/Production Credits', '510' => 'Citation/References', '511' => 'Participant or Performer', '513' => 'Type of Report an Period Covered', '515' => 'Numbering Peculiarities', '518' => 'Date/Time and Place of Event', '521' => 'Target Audience', '522' => 'Geographic Coverage', '525' => 'Supplement', '526' => 'Study Program Information', '530' => 'Additional Physical Form', '533' => 'Reproduction', '534' => 'Original Version', '536' => 'Funding Information', '538' => 'System Details', '545' => 'Biographical or Historical Data', '546' => 'Language', '547' => 'Former Title Complexity', '550' => 'Issuing Body', '555' => 'Cumulative Index/Finding Aids', '556' => 'Information About Documentation', '561' => 'Ownership and Custodial History', '563' => 'Binding Information', '580' => 'Linking Entry Complexity', '581' => 'Publications About Described Materials', '586' => 'Awards', '590' => 'Local note', '599' => 'Differentiable Local note');
     foreach ($additionalNotesFields as $tag => $label) {
         $marcFields = $marcRecord->getFields($tag);
         foreach ($marcFields as $marcField) {
             $noteText = array();
             foreach ($marcField->getSubFields() as $subfield) {
                 /** @var File_MARC_Subfield $subfield */
                 $noteText[] = $subfield->getData();
             }
             $note = implode(',', $noteText);
             if (strlen($note) > 0) {
                 $notes[] = "<b>{$label}</b>: " . $note;
             }
         }
     }
     if (count($notes) > 0) {
         $interface->assign('notes', $notes);
     }
     /** @var File_MARC_Data_Field[] $linkFields */
     $linkFields = $marcRecord->getFields('856');
     if ($linkFields) {
         $internetLinks = array();
         $purchaseLinks = array();
         $field856Index = 0;
         foreach ($linkFields as $marcField) {
             $field856Index++;
             //Get the link
             if ($marcField->getSubfield('u')) {
                 $link = $marcField->getSubfield('u')->getData();
                 if ($marcField->getSubfield('3')) {
                     $linkText = $marcField->getSubfield('3')->getData();
                 } elseif ($marcField->getSubfield('y')) {
                     $linkText = $marcField->getSubfield('y')->getData();
                 } elseif ($marcField->getSubfield('z')) {
                     $linkText = $marcField->getSubfield('z')->getData();
                 } else {
                     $linkText = $link;
                 }
                 $showLink = true;
                 //Process some links differently so we can either hide them
                 //or show them in different areas of the catalog.
                 if (preg_match('/purchase|buy/i', $linkText) || preg_match('/barnesandnoble|tatteredcover|amazon|smashwords\\.com/i', $link)) {
                     $showLink = false;
                 }
                 $isBookLink = preg_match('/acs\\.dcl\\.lan|vufind\\.douglascountylibraries\\.org|catalog\\.douglascountylibraries\\.org/i', $link);
                 if ($isBookLink == 1) {
                     //e-book link, don't show
                     $showLink = false;
                 }
                 if ($showLink) {
                     //Rewrite the link so we can track usage
                     $link = $configArray['Site']['path'] . '/Record/' . $this->id . '/Link?index=' . $field856Index;
                     $internetLinks[] = array('link' => $link, 'linkText' => $linkText);
                 }
             }
         }
         if (count($internetLinks) > 0) {
             $interface->assign('internetLinks', $internetLinks);
         }
     }
     if (isset($purchaseLinks) && count($purchaseLinks) > 0) {
         $interface->assign('purchaseLinks', $purchaseLinks);
     }
     //Determine the cover to use
     $bookCoverUrl = $configArray['Site']['coverUrl'] . "/bookcover.php?id={$this->id}&amp;isn={$this->isbn}&amp;issn={$this->issn}&amp;size=large&amp;upc={$this->upc}&amp;category=" . urlencode($format_category) . "&amp;format=" . urlencode(isset($format[0]) ? $format[0] : '');
     $interface->assign('bookCoverUrl', $bookCoverUrl);
     //Load accelerated reader data
     if (isset($record['accelerated_reader_interest_level'])) {
         $arData = array('interestLevel' => $record['accelerated_reader_interest_level'], 'pointValue' => $record['accelerated_reader_point_value'], 'readingLevel' => $record['accelerated_reader_reading_level']);
         $interface->assign('arData', $arData);
     }
     if (isset($record['lexile_score']) && $record['lexile_score'] > -1) {
         $lexileScore = $record['lexile_score'];
         if (isset($record['lexile_code'])) {
             $lexileScore = $record['lexile_code'] . $lexileScore;
         }
         $interface->assign('lexileScore', $lexileScore . 'L');
     }
     //Do actions needed if this is the main action.
     //$interface->caching = 1;
     $interface->assign('id', $this->id);
     if (substr($this->id, 0, 1) == '.') {
         $interface->assign('shortId', substr($this->id, 1));
     } else {
         $interface->assign('shortId', $this->id);
     }
     $interface->assign('addHeader', '<link rel="alternate" type="application/rdf+xml" title="RDF Representation" href="' . $configArray['Site']['path'] . '/Record/' . urlencode($this->id) . '/RDF" />');
     // Define Default Tab
     $tab = isset($_GET['action']) ? $_GET['action'] : 'Description';
     $interface->assign('tab', $tab);
     if (isset($_REQUEST['detail'])) {
         $detail = strip_tags($_REQUEST['detail']);
         $interface->assign('defaultDetailsTab', $detail);
     }
     // Define External Content Provider
     if ($this->marcRecord->getField('020')) {
         if (isset($configArray['Content']['reviews'])) {
             $interface->assign('hasReviews', true);
         }
         if (isset($configArray['Content']['excerpts'])) {
             $interface->assign('hasExcerpt', true);
         }
     }
     // Retrieve User Search History
     $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false);
     // Retrieve tags associated with the record
     $limit = 5;
     $resource = new Resource();
     $resource->record_id = $_GET['id'];
     $resource->source = 'VuFind';
     $resource->find(true);
     $tags = $resource->getTags($limit);
     $interface->assign('tagList', $tags);
     $timer->logTime('Got tag list');
     $this->cacheId = 'Record|' . $_GET['id'] . '|' . get_class($this);
     // Find Similar Records
     /** @var Memcache $memCache */
     global $memCache;
     $similar = $memCache->get('similar_titles_' . $this->id);
     if ($similar == false) {
         $similar = $this->db->getMoreLikeThis($this->id);
         // Send the similar items to the template; if there is only one, we need
         // to force it to be an array or things will not display correctly.
         if (isset($similar) && count($similar['response']['docs']) > 0) {
             $similar = $similar['response']['docs'];
         } else {
             $similar = array();
             $timer->logTime("Did not find any similar records");
         }
         $memCache->set('similar_titles_' . $this->id, $similar, 0, $configArray['Caching']['similar_titles']);
     }
     $this->similarTitles = $similar;
     $interface->assign('similarRecords', $similar);
     $timer->logTime('Loaded similar titles');
     // Find Other Editions
     if ($configArray['Content']['showOtherEditionsPopup'] == false) {
         $editions = OtherEditionHandler::getEditions($this->id, $this->isbn, isset($this->record['issn']) ? $this->record['issn'] : null);
         if (!PEAR_Singleton::isError($editions)) {
             $interface->assign('editions', $editions);
         } else {
             $timer->logTime("Did not find any other editions");
         }
         $timer->logTime('Got Other editions');
     }
     $interface->assign('showStrands', isset($configArray['Strands']['APID']) && strlen($configArray['Strands']['APID']) > 0);
     // Send down text for inclusion in breadcrumbs
     $interface->assign('breadcrumbText', $this->recordDriver->getBreadcrumb());
     // Send down OpenURL for COinS use:
     $interface->assign('openURL', $this->recordDriver->getOpenURL());
     // Send down legal export formats (if any):
     $interface->assign('exportFormats', $this->recordDriver->getExportFormats());
     // Set AddThis User
     $interface->assign('addThis', isset($configArray['AddThis']['key']) ? $configArray['AddThis']['key'] : false);
     // Set Proxy URL
     if (isset($configArray['EZproxy']['host'])) {
         $interface->assign('proxy', $configArray['EZproxy']['host']);
     }
     //setup 5 star ratings
     global $user;
     $ratingData = $resource->getRatingData($user);
     $interface->assign('ratingData', $ratingData);
     $timer->logTime('Got 5 star data');
     //Get Next/Previous Links
     $searchSource = isset($_REQUEST['searchSource']) ? $_REQUEST['searchSource'] : 'local';
     $searchObject = SearchObjectFactory::initSearchObject();
     $searchObject->init($searchSource);
     $searchObject->getNextPrevLinks();
     //Load Staff Details
     $interface->assign('staffDetails', $this->recordDriver->getStaffView());
 }
Exemple #27
0
 /**
  * Sends a query to the Solr server.
  * 
  * Although it is recommended to provide the query as a {@link SolrQuery}
  * object, it is also possible to pass it as a string. So, the following
  * two lines of code produce exactly the same result:
  * 
  * <code>
  * $result = $solr->query('hello world');
  * $result = $solr->query(new SolrQuery('hello world'));
  * </code>
  * 
  * Please refer to the {@link SolrQuery} class for more details on query
  * parameters and the query syntax.
  * 
  * @see SolrQuery
  * @uses json_decode()
  * 
  * @param SolrQuery|string $query The query.
  * 
  * @return SolrSearchResult
  */
 public function query($query)
 {
     Solr::autoload('SolrSearchResult');
     if (is_string($query)) {
         Solr::autoload('SolrQuery');
         $query = new SolrQuery($query);
     } elseif (!$query instanceof SolrQuery) {
         throw new InvalidArgumentException('Invalid query.');
     }
     $response = $this->httpClient->sendRequest('/select' . $query->getQueryString());
     return SolrSearchResult::parseResponse($response->getBody());
 }
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * 
 * @package php_solr
 * @subpackage search
 * @author Alexander M. Turek <*****@*****.**>
 * @copyright 2009, Alexander M. Turek
 * @license http://www.opensource.org/licenses/bsd-license.php BSD License
 * @version $Id$
 */
Solr::autoload('SolrQuery');
/**
 * Common parameters for facet fields.
 * 
 * @see http://wiki.apache.org/solr/SimpleFacetParameters
 * 
 * @package php_solr
 * @subpackage search
 * @author Alexander M. Turek <*****@*****.**>
 * @since 0.4.1
 */
abstract class SolrFacetFieldParameters
{
    /**
     * The prefix.
     * 
Exemple #29
0
 /**
  * Get list product by condition tolerances and weight of extra field
  *
  * @author MinhNV
  * Date 2010/08/18
  */
 private function getListProductByCondOfExtraField()
 {
     $cat_product_id = Url::get('cat_product_id', 0);
     $product_id = Url::get('product_id', 0);
     $cur_page = Url::get('page_no', 0);
     $table = CGlobal::TABLE_PRODUCTS_PRODUCT;
     $aryExtraField = array();
     $aryExtraProduct = array();
     $aryProduct = array();
     $aryData = array();
     $query = '';
     $fq = array();
     if ($cat_product_id > 0 && $product_id > 0) {
         $aryExtra = array();
         $table = SoLib::getTableProduct($cat_product_id, $product_id);
         $aryExtra = DB::get_row('SELECT name,extra_fields FROM ' . $table . ' WHERE id= ' . $product_id . ' ');
         if ($aryExtra['extra_fields'] != '') {
             $objJSON = new Services_JSON();
             $aryExtraProduct = objectToArray($objJSON->decode($aryExtra['extra_fields']));
         }
         $aryExtraField = $this->getListExtraField($cat_product_id);
         //if($cat_product_id > 0)  {
         //	$query .= '( published:1 AND  category_id:'.$cat_product_id.' AND min_price:[1 TO *] AND max_price:[1 TO *]) AND ';
         //}
         //else {
         //	$query .= '( published:1 AND min_price:[1 TO *] AND max_price:[1 TO *]) AND ';
         //}
         $fq[] = "published:1 AND status:1";
         if ($cat_product_id > 0) {
             $query .= '( category_id:' . $cat_product_id . ' AND min_price:[1 TO *] AND max_price:[1 TO *]) AND ';
         } else {
             $query .= '( min_price:[1 TO *] AND max_price:[1 TO *]) AND ';
         }
         $querySolr = '';
         $querySolr = $this->buildQueryFromTolerancesAndWeightOfExtraField($aryExtraField, $aryExtraProduct);
         if ($querySolr == '') {
             if (strlen($query) > 0) {
                 $query = substr($query, 0, strlen($query) - 4);
             }
         } else {
             $query .= '(' . $querySolr . ')';
         }
         //add them dieu kien search name de cho chinh xac
         if ($aryExtra['name'] != '') {
             $objLib = new SoLib();
             $query .= ' AND name:' . $objLib->escapeSolrKeyword(trim($aryExtra['name']));
         }
         //if($query != '') {
         //
         //}
         //if (strlen($query) > 0) {
         //	$query = substr($query, 0, (strlen($query) - 4));
         //}
         //var_dump($query);
         $params = array();
         $params['fl'] = 'id, name, min_price, max_price, num_classified, images, date, description';
         //$params['fq'] = "-id : $product_id";
         $fq[] = "-id : {$product_id}";
         $params['fq'] = $fq;
         if ($query != "") {
             $solr = Solr::getInstanceProduct();
             $start = 0;
             $offset = self::NUMBER_PER_PAGE;
             $responseCheck = $solr->search($query, 0, 0);
             $total_row = 0;
             $paging = '';
             if ($responseCheck) {
                 if ($responseCheck->getHttpStatus() == 200) {
                     $total_row = $responseCheck->response->numFound;
                     if ($total_row > 0) {
                         $url_path = 'ajax.php?act=so_advanced&code=get_list_product_extra_field&cat_product_id=' . $cat_product_id . '&product_id=' . $product_id;
                         BMPaging::AjaxPagingSolr($paging, $start, $total_row, $offset, self::NUMBER_PAGE_SHOW, 'page_no', true, $url_path, 'paging_ajax_extra_field_template');
                         $response = $solr->search($query, $start, $offset, $params);
                         if ($response->getHttpStatus() == 200) {
                             if ($response->response->numFound > 0) {
                                 $i = 0;
                                 foreach ($response->response->docs as $doc) {
                                     $aryProduct[$i]['id'] = $doc->id;
                                     $aryProduct[$i]['name'] = $doc->name;
                                     $aryProduct[$i]['min_price'] = number_format($doc->min_price, 0, '.', '.');
                                     $aryProduct[$i]['max_price'] = number_format($doc->max_price, 0, '.', '.');
                                     $aryProduct[$i]['num_classified'] = $doc->num_classified;
                                     $aryProduct[$i]['description'] = $doc->description;
                                     $aryProduct[$i]['images'] = SoImg::getImage($doc->images, $doc->id, SoImg::FOLDER_PRODUCT, $doc->date, '70x0');
                                     $i++;
                                 }
                             }
                         } else {
                             $aryData['msg'] = 'Query solr thất bại.';
                             $aryData['intIsOK'] = -1;
                         }
                         if (is_array($aryProduct) && count($aryProduct) > 0) {
                             global $display;
                             $display->add('aryProduct', $aryProduct);
                             $display->add('paging', $paging);
                             $display->add('total_row', $total_row);
                             $aryHtml = $display->output('list_product_extra_field', true, 'SoBoxAdvanced');
                             $aryData['htmlProduct'] = $aryHtml;
                             $aryData['intIsOK'] = 1;
                         }
                     }
                 } else {
                     $aryData['msg'] = 'Query solr thất bại.';
                     $aryData['intIsOK'] = -1;
                 }
             }
         }
     }
     echo json_encode($aryData);
     exit;
 }
Exemple #30
0
 /**
  * Constructor
  *
  * @param \VuFind\Search\Results\PluginManager $results Results plugin manager
  */
 public function __construct(\VuFind\Search\Results\PluginManager $results)
 {
     parent::__construct($results);
     $this->defaultDisplayField = 'course';
     $this->searchClassId = 'SolrReserves';
 }