Subversion Repositories xrowsearch

[/] [trunk/] [bin/] [xrowSearch_old.php] - Blame information for rev 1

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1 rrobert
<?php
2
 
3
require 'autoload.php';
4
 
5
global $cli, $isQuiet;
6
$cli = eZCLI::instance();
7
$script = eZScript::instance( array(
8
    'description' => ( "eZ Publish Script Executor\n\n" . "Allows execution of simple PHP scripts which uses eZ Publish functionality,\n" . "when the script is called all necessary initialization is done\n" . "\n" . "ezexec.php myscript.php" ) ,
9
    'use-session' => false ,
10
    'use-modules' => true ,
11
    'use-extensions' => true
12
) );
13
 
14
$script->startup();
15
 
16
$options = $script->getOptions( "", "[provider]", array() );
17
 
18
$script->initialize();
19
 
20
$provider = $options['arguments'][0];
21
 
22
if ( ! $provider )
23
{
24
    throw new Exception( "Parameter Provider not given." );
25
}
26
 
27
$plug = xrowExternalSearchProvider::getExternalProvider( $provider );
28
 
29
if ( ! $plug instanceof ExternalSearchXMLPlugin )
30
{
31
    throw new Exception( "Provider Plugin not found." );
32
}
33
$records = $plug->load();
34
// setup
35
$handler = new xrowSOLRHandler();
36
$manager = new ezcSearchEmbeddedManager();
37
$session = new ezcSearchSession( $handler, $manager );
38
 
39
$session->beginTransaction();
40
 
41
if ( ! $isQuiet )
42
{
43
    $amount = count( $records );
44
    $cli->output( "Adding $amount items to the index from $records->params['ExternalURL']." );
45
    $output = new ezcConsoleOutput();
46
    $bar = new ezcConsoleProgressbar( $output, $amount );
47
}
48
foreach ( $records as $elem )
49
{
50
    $session->index( $elem );
51
    if ( isset( $bar ) )
52
    {
53
        $bar->advance();
54
    }
55
}
56
if ( ! $isQuiet )
57
{
58
    $bar->finish();
59
    $cli->output( "\n" );
60
}
61
 
62
$session->commit();
63
 
64
sleep( 3 );
65
 
66
$cli->output( "external xml file has already been uploaded!" );
67
 
68
$script->shutdown();