*/ protected $record_buffer_size; /** * Return about text * * @return */ public function help() { return( _("task::subdef:creation des sous definitions des documents d'origine") ); } /** * Returns task name * * @return string */ public function getName() { return(_('task::subdef:creation des sous definitions')); } /** * must return the xml (text) version of the form * * @param string $oldxml * @return string */ public function graphic2xml($oldxml) { $request = http_request::getInstance(); $parm2 = $request->get_parms('period', 'flush', 'maxrecs', 'maxmegs'); $dom = new DOMDocument(); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; if (@$dom->loadXML($oldxml)) { $xmlchanged = false; foreach (array('str:period', 'str:flush', 'str:maxrecs', 'str:maxmegs') as $pname) { $ptype = substr($pname, 0, 3); $pname = substr($pname, 4); $pvalue = $parm2[$pname]; if (($ns = $dom->getElementsByTagName($pname)->item(0)) != NULL) { while (($n = $ns->firstChild)) { $ns->removeChild($n); } } else { $ns = $dom->documentElement->appendChild($dom->createElement($pname)); } switch ($ptype) { case "str": case "pop": $ns->appendChild($dom->createTextNode($pvalue)); break; case "boo": $ns->appendChild($dom->createTextNode($pvalue ? '1' : '0')); break; } $xmlchanged = true; } } return($dom->saveXML()); } /** * must fill the graphic form (using js) from xml * * @param string $xml * @param string $form * @return string */ public function xml2graphic($xml, $form) { if (false !== $sxml = simplexml_load_string($xml)) { if ((int) ($sxml->period) < self::MINPERIOD) { $sxml->period = self::MINPERIOD; } elseif ((int) ($sxml->period) > self::MAXPERIOD) { $sxml->period = self::MAXPERIOD; } if ((int) ($sxml->flush) < self::MINFLUSH) { $sxml->flush = self::MINFLUSH; } elseif ((int) ($sxml->flush) > self::MAXFLUSH) { $sxml->flush = self::MAXFLUSH; } if ((int) ($sxml->maxrecs) < self::MINRECS) { $sxml->maxrecs = self::MINRECS; } elseif (self::MAXRECS != -1 && (int) ($sxml->maxrecs) > self::MAXRECS) { $sxml->maxrecs = self::MAXRECS; } if ((int) ($sxml->maxmegs) < self::MINMEGS) { $sxml->maxmegs = self::MINMEGS; } elseif (self::MAXMEGS != -1 && (int) ($sxml->maxmegs) > self::MAXMEGS) { $sxml->maxmegs = self::MAXMEGS; } ?>

 : 

'); ?>

    Mo
get_connection(); $sql = 'SELECT coll_id, record_id FROM record WHERE jeton & ' . JETON_MAKE_SUBDEF . ' > 0 ORDER BY record_id DESC LIMIT 0, '.$this->maxrecs; $stmt = $connbas->prepare($sql); $stmt->execute(); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); return $rs; } public function processOneContent(databox $databox, Array $row) { $record_id = $row['record_id']; $this->log(sprintf( "Generate subdefs for : sbasid=%s / databox=%s / recordid=%s " , $databox->get_sbas_id(), $databox->get_dbname() , $record_id) , self::LOG_INFO ); try { $record = new record_adapter($this->dependencyContainer, $this->sbas_id, $record_id); $record->generate_subdefs($databox, $this->dependencyContainer); } catch (\Exception $e) { $this->log( sprintf( "Generate subdefs failed for : sbasid=%s / databox=%s / recordid=%s : %s" , $databox->get_sbas_id(), $databox->get_dbname() , $record_id, $e->getMessage()) , self::LOG_WARNING ); } $this->recs_to_write[] = $record->get_record_id(); if (count($this->recs_to_write) >= $this->record_buffer_size) { $this->flushRecordsSbas(); } unset($record); return $this; } protected function postProcessOneContent(databox $databox, Array $row) { $connbas = $databox->get_connection(); $sql = 'UPDATE record SET jeton=(jeton & ~' . JETON_MAKE_SUBDEF . '), moddate=NOW() WHERE record_id=:record_id'; $stmt = $connbas->prepare($sql); $stmt->execute(array(':record_id' => $row['record_id'])); $stmt->closeCursor(); return $this; } protected function flushRecordsSbas() { $sql = implode(', ', $this->recs_to_write); if ($sql != '') { $this->log(sprintf( 'setting %d record(s) to subdef meta writing' , count($this->recs_to_write) ), self::LOG_INFO); try { $connbas = connection::getPDOConnection($this->dependencyContainer, $this->sbas_id); $sql = 'UPDATE record SET status=(status & ~0x03), jeton=(jeton | ' . JETON_WRITE_META_SUBDEF . ') WHERE record_id IN (' . $sql . ')'; $stmt = $connbas->prepare($sql); $stmt->execute(); $stmt->closeCursor(); } catch (\Exception $e) { $this->log($e->getMessage(), self::LOG_CRITICAL); } } $this->recs_to_write = array(); return $this; } }