/** * @param string clusterIdentifier * @param array $applicationIds * @return string */ protected function bulidUpdateXml( $clusterIdentifier, $applicationIds = array() ) { $xml = '<add>'; $sql = $this->getSql( $clusterIdentifier ); if ( !empty( $applicationIds ) ) { $sql .= sprintf( " AND a.id IN ('%s')", implode( "','" , $applicationIds ) ); } $applications = MMDB::instance()->arrayQuery( $sql ); foreach( $applications as $row ) { $application = new ApplicationLocalized( $row ); $cacheApp = CacheApplicationTool::buildLocalizedApplicationByLocalizedId($application->id); if( !($cacheApp instanceof ApplicationLocalized) ) { continue; } $xml .= '<doc>'; $this->addField( $xml, self::META_INSTALLATION_ID_MS_KEY, self::META_INSTALLATION_ID_MS_VAL ); $this->addField( $xml, 'meta_guid_ms', md5( $application->application_id ) . "-{$application->cluster_identifier}" ); $this->addField( $xml, 'identifier_s', $row['application_identifier'] ); $this->addField( $xml, 'name_s', htmlspecialchars( $application->name ) ); $this->addField( $xml, 'cluster_identifier_s', $application->cluster_identifier ); $headlineKeywords = $this->prepareHeadlineKeywords($application->headline); foreach ($headlineKeywords as $headlineKeyword) { $this->addField( $xml, self::HEADLINE_KEYWORD, self::prepareKeywordString( $headlineKeyword ) ); } $keywords = $application->getKeywords(); if ( is_array( $keywords ) ) { foreach ( $keywords as $keyword ) { $this->addField( $xml, self::META_APPLICATION_KEYWORD, self::prepareKeywordString( $keyword ) ); } } $xml .= '</doc>'; } $xml .= '</add>'; return $xml; }