예제 #1
0
파일: sfPakeDev.php 프로젝트: kotow/work
function run_dis($task, $args)
{
    ini_set("memory_limit", "1024M");
    ini_set("display_errors", 1);
    define('SF_ROOT_DIR', sfConfig::get('sf_root_dir'));
    define('SF_APP', 'frontend');
    define('SF_ENVIRONMENT', 'prod');
    define('SF_DEBUG', true);
    require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
    $databaseManager = new sfDatabaseManager();
    $databaseManager->initialize();
    $c = new Criteria();
    $c->add(ImportSessionPeer::CREATED_AT, "2014-10-21", Criteria::GREATER_EQUAL);
    $imports = ImportSessionPeer::doSelect($c);
    $i = 0;
    foreach ($imports as $import) {
        $i++;
        $import->delete();
        echo ".";
    }
    exit(">>" . $i . "\n");
}
예제 #2
0
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(ImportSessionPeer::ID, $pks, Criteria::IN);
         $objs = ImportSessionPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
예제 #3
0
파일: sfPakeImport.php 프로젝트: kotow/work
function run_session_search($task, $args)
{
    ini_set("memory_limit", "8192M");
    ini_set("display_errors", 1);
    define('SF_ROOT_DIR', sfConfig::get('sf_root_dir'));
    define('SF_APP', 'frontend');
    define('SF_ENVIRONMENT', 'prod');
    define('SF_DEBUG', true);
    require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
    $databaseManager = new sfDatabaseManager();
    $databaseManager->initialize();
    //sfConfig::set('sf_cache_objects', false);
    //sfConfig::set('sf_cache_relations', false);
    //sfConfig::set('sf_use_relations_cache', false);
    //get all serch templates
    $c = new Criteria();
    $searcheTemplates = SearchPeer::doSelect($c);
    //$searcheTemplates = array($st);
    $fields = array('Label', 'ApplicationNumber', 'RegisterNumber', 'RegistrationDate', 'ApplicationDate', 'ExpiresOn', 'ViennaClasses', 'NiceClasses', 'RightsOwner', 'RightsRepresentative', 'OfficeOfOrigin', 'DesignatedContractingParty');
    $c = new Criteria();
    //$c->add(ImportSessionPeer::CREATED_AT, "2014-11-03", Criteria::GREATER_EQUAL );
    $importSessions = ImportSessionPeer::doSelect($c);
    /*if($args[0] == "-d")
    	{
    	foreach ($importSessions as $importSession)
    	{
    	$res = Document::getChildrenOf($importSession->getId(), "SearchMatch");
    	foreach ($res as $r)
    	{
    	$r->delete();
    	echo ".";
    	}
    	}
    	exit();
    	}*/
    $ind = 0;
    foreach ($importSessions as $importSession) {
        $found = false;
        if ($importSession->getTmCount() == 0) {
            continue;
        }
        $searchMatches = Document::getChildrenOf($importSession->getId(), "SearchMatch", false);
        //if($importSession->getId() == 552172) continue;
        if (count($searchMatches) > 0) {
            continue;
        }
        echo ">>> searching session: " . $importSession->getId() . "\n";
        try {
            $sti = 1;
            foreach ($searcheTemplates as $searcheTemplate) {
                $searchOf = array();
                foreach ($fields as $field) {
                    $getter = "get" . $field;
                    $param = $searcheTemplate->{$getter}();
                    if ($param) {
                        $param = str_replace(array('+', '-', '&&', '||', '!', '(', ')', '{', '}', '[', ']', '^', '"', '~', ':', '\\', '.', '/'), array('\\+', '\\-', '\\&&', '\\||', '\\!', '\\(', '\\)', '\\{', '\\}', '\\[', '\\]', '\\^', '\\"', '\\~', '\\:', '\\\\', '\\.', '\\/'), $param);
                        $searchOf[$field] = trim($param);
                    }
                }
                /////////////////////// QUERY BUILDING //////////////////////////
                $q = new Zend_Search_Lucene_Search_Query_Boolean();
                $queryTerms = explode(" ", strtolower($query));
                $i = 0;
                $query = "";
                foreach ($searchOf as $field => $term) {
                    if ($i > 0) {
                        $query .= ' AND ';
                    }
                    if ($field == "NiceClasses" || $field == "ViennaClasses") {
                        $query .= '(';
                        $parts = explode(",", $term);
                        foreach ($parts as $el) {
                            for ($e = 1; $e < 15; $e++) {
                                $query .= $field . $e . ':"' . trim($el) . '" OR ';
                            }
                        }
                        $query = substr($query, 0, -4) . ')';
                    } elseif ($field == "ApplicationNumber" || $field == "RegisterNumber") {
                        $query .= $field . ':';
                        $query .= trim($term);
                    } else {
                        $query .= $field . ':';
                        if (strpos($term, "*") !== false || strpos($term, "?") !== false) {
                            $query .= trim(UtilsHelper::cyrillicConvert($term));
                        } else {
                            $query .= trim(UtilsHelper::cyrillicConvert($term)) . '~0.7';
                        }
                    }
                    $i++;
                }
                $q = Zend_Search_Lucene_Search_QueryParser::parse($query);
                //////////////////////// SEARCH EXECUTION ////////////////////
                echo " | " . $sti . " > " . $searcheTemplate->getId();
                $searchIndex = Zend_Search_Lucene::open(sfConfig::get('sf_root_dir') . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'search/' . $importSession->getId() . "/");
                $searchResults = $searchIndex->find($q);
                $brandId = Document::getParentOf($searcheTemplate->getId(), "Brand", false);
                foreach ($searchResults as $searchResult) {
                    if ($foundEls[$searchResult->did] == $brandId) {
                        continue;
                    }
                    $foundEls[$searchResult->did] = $brandId;
                    $found = true;
                    $sm = new SearchMatch();
                    $sm->setLabel("Match");
                    $sm->setImportSession($importSession->getId());
                    $sm->setSearch($searcheTemplate->getId());
                    $sm->setTrademark($searchResult->did);
                    $sm->save(null, $importSession);
                }
                $sti++;
            }
            if ($found) {
                UtilsHelper::sendEmail(UtilsHelper::Settings('main_email'), "Matches have been found, click below to see them <br> <a href='http://www.tm-smart.com/import-session-report.html?is=" . $importSession->getId() . "'>http://www.tm-smart.com/import-session-report.html?is=" . $importSession->getId() . "</a>", "TM Smart - Matches foud");
                $ind++;
            } else {
                //				UtilsHelper::sendEmail(UtilsHelper::Settings('main_email'), "No matches have been found", "TM Smart - No matches foud");
            }
        } catch (Exception $e) {
            echo ">>>>>>>>>> Error on Session " . $importSession->getId() . "\n" . $e->getMessage();
            continue;
            //echo_cms_error("ERROR: ".$e->getMessage());
        }
        if ($ind > 10) {
            break;
        }
    }
    //sfConfig::set('sf_cache_objects', true);
    //sfConfig::set('sf_cache_relations', true);
    //sfConfig::set('sf_use_relations_cache', true);
}
예제 #4
0
 public function executeImportSessions()
 {
     $this->setLayout(false);
     if ($page = Document::getDocumentByExclusiveTag('website_page_import_session_report')) {
         $this->reportHref = $page->getHref();
     } else {
         $this->reportHref = '#';
     }
     $c = new Criteria();
     $importsArr = ImportSessionPeer::doSelect($c);
     $this->importsArr = array_reverse($importsArr);
 }