Merge branch 'BusinessFields' into Dev

This commit is contained in:
Romain Neutron
2012-03-26 14:21:16 +02:00
80 changed files with 6309 additions and 1564 deletions

View File

@@ -35,6 +35,7 @@ $finder
->name('.gitignore')
->name('check_cs.php')
->name('cleaner.php')
->name('lib/phpunit.xml.dist')
->name('launchpadToLocales.php')
->name('localesToLaunchPad.php')
->name('pom.xml')

View File

@@ -68,6 +68,7 @@ class Description implements ControllerProviderInterface
$field->set_thumbtitle($request->get('thumbtitle_' . $id));
$field->set_source($request->get('src_' . $id));
$field->set_multi($request->get('multi_' . $id));
$field->set_business($request->get('business_' . $id));
$field->set_indexable($request->get('indexable_' . $id));
$field->set_required($request->get('required_' . $id));
$field->set_separator($request->get('separator_' . $id));

View File

@@ -47,7 +47,29 @@ class Query implements ControllerProviderInterface
$options = new \searchEngine_options();
$bas = is_array($request->get('bas')) ? $request->get('bas') : array();
$bas = is_array($request->get('bas')) ? $request->get('bas') : array_keys($user->ACL()->get_granted_base());
/* @var $user \User_Adapter */
if ($user->ACL()->has_right('modifyrecord'))
{
$options->set_business_fields(array());
$BF = array();
foreach ($user->ACL()->get_granted_base(array('canmodifrecord')) as $collection)
{
if (count($bas) === 0 || in_array($collection->get_base_id(), $bas))
{
$BF[] = $collection->get_base_id();
}
}
$options->set_business_fields($BF);
}
else
{
$options->set_business_fields(array());
}
$status = is_array($request->get('status')) ? $request->get('status') : array();
$fields = is_array($request->get('fields')) ? $request->get('fields') : array();
@@ -161,8 +183,6 @@ class Query implements ControllerProviderInterface
$explain .= '<br><div>' . $result->get_query_time() . ' s</div>dans index ' . $result->get_search_indexes();
$explain .= "</div>";
$infoResult = '<a href="#" class="infoDialog" infos="' . str_replace('"', '&quot;', $explain) . '">' . sprintf(_('reponses:: %d reponses'), $result->get_count_total_results()) . '</a> | ' . sprintf(_('reponses:: %s documents selectionnes'), '<span id="nbrecsel"></span>');
$json['infos'] = $infoResult;

View File

@@ -253,7 +253,7 @@ class Edit extends RecordHelper
$_lst[$indice]['originalname'] = $record->get_original_name();
foreach ($record->get_caption()->get_fields() as $field)
foreach ($record->get_caption()->get_fields(null, true) as $field)
{
$meta_struct_id = $field->get_meta_struct_id();
if (!isset($this->javascript_fields[$meta_struct_id]))
@@ -538,7 +538,7 @@ class Edit extends RecordHelper
*/
if ($write_edit_el instanceof \databox_field)
{
$fields = $record->get_caption()->get_fields(array($write_edit_el->get_name()));
$fields = $record->get_caption()->get_fields(array($write_edit_el->get_name()), true);
$field = array_pop($fields);
$meta_id = null;

View File

@@ -279,7 +279,31 @@ class API_V1_adapter extends API_V1_Abstract
$options = new searchEngine_options();
$params['bases'] = is_array($params['bases']) ? $params['bases'] : array_keys($user->ACL()->get_granted_base());
/* @var $user \User_Adapter */
if ($user->ACL()->has_right('modifyrecord'))
{
$options->set_business_fields(array());
$BF = array();
foreach ($user->ACL()->get_granted_base(array('canmodifrecord')) as $collection)
{
if (count($params['bases']) === 0 || in_array($collection->get_base_id(), $params['bases']))
{
$BF[] = $collection->get_base_id();
}
}
$options->set_business_fields($BF);
}
else
{
$options->set_business_fields(array());
}
$options->set_bases($params['bases'], $user->ACL());
if ( ! is_array($params['fields']))
$params['fields'] = array();
$options->set_fields($params['fields']);
@@ -1132,7 +1156,6 @@ class API_V1_adapter extends API_V1_Abstract
* @todo ajouter une option pour avoir les values serialisées
* dans un cas multi
*/
return array(
'meta_id' => $value->getId()
, 'meta_structure_id' => $field->get_meta_struct_id()

View File

@@ -108,7 +108,7 @@ class cache_databox
$record = new \record_adapter($sbas_id, $row['value']);
$record->get_caption()->delete_data_from_cache();
foreach ($record->get_caption()->get_fields() as $field)
foreach ($record->get_caption()->get_fields(null, true) as $field)
{
$field->delete_data_from_cache();
}

View File

@@ -301,20 +301,41 @@ class caption_Field_Value
if (isset($sbas_params[$sbas_id]))
{
$params = $sbas_params[$sbas_id];
$sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
$sbas_crc = crc32(
str_replace(
array('.', '%')
, '_'
, sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])
)
);
$sphinx_rt = sphinxrt::get_instance($registry);
$sphinx_rt->replace_in_metas(
"metas_realtime" . $sbas_crc, $this->id, $this->databox_field->get_id(), $this->record->get_record_id(), $sbas_id, phrasea::collFromBas($this->record->get_base_id()), ($this->record->is_grouping() ? '1' : '0'), $this->record->get_type(), $value, $this->record->get_creation_date()
"metas_realtime" . $sbas_crc
, $this->id
, $this->databox_field->get_id()
, $this->record->get_record_id()
, $sbas_id
, phrasea::collFromBas($this->record->get_base_id())
, ($this->record->is_grouping() ? '1' : '0')
, $this->record->get_type()
, $value
, ($this->databox_field->isBusiness() ? '1' : '0')
, $this->record->get_creation_date()
);
$all_datas = array();
foreach ($this->record->get_caption()->get_fields() as $field)
foreach ($this->record->get_caption()->get_fields(null, true) as $field)
{
if ( ! $field->is_indexable())
{
continue;
}
$all_datas[] = $field->get_serialized_values();
}
$all_datas = implode(' ', $all_datas);
$sphinx_rt->replace_in_documents(
@@ -335,6 +356,35 @@ class caption_Field_Value
{
$connbas = $databox_field->get_connection();
/**
* Check consistency
*/
if ( ! $databox_field->is_multi())
{
try
{
$field = $record->get_caption()->get_field($databox_field->get_name());
$caption_field_value = array_pop($field->get_values());
/* @var $value \caption_Field_Value */
$caption_field_value->set_value($value);
if ( ! $vocabulary || ! $vocabularyId)
{
$caption_field_value->removeVocabulary();
}
else
{
$caption_field_value->setVocab($vocabulary, $vocabularyId);
}
return $caption_field_value;
}
catch (\Exception $e)
{
}
}
$sql_ins = 'INSERT INTO metadatas
(id, record_id, meta_struct_id, value, VocabularyType, VocabularyId)
VALUES

View File

@@ -65,16 +65,17 @@ class caption_field
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if (!$databox_field->is_multi() && count($rs) > 1)
{
/**
* TRIGG CORRECTION;
*/
}
foreach ($rs as $row)
{
$this->values[$row['id']] = new caption_Field_Value($databox_field, $record, $row['id']);
/**
* Inconsistent, should not happen
*/
if(!$databox_field->is_multi())
{
break;
}
}
return $this;
@@ -337,6 +338,79 @@ class caption_field
return;
}
protected static function merge_metadatas(databox_field $databox_field, record_adapter $record)
{
$sql = 'SELECT record_id, id, value FROM metadatas
WHERE meta_struct_id = :meta_struct_id
AND record_id = :record_id';
$params = array(
':meta_struct_id' => $databox_field->get_id(),
':record_id' => $record->get_record_id()
);
$stmt = $databox_field->get_databox()->get_connection()->prepare($sql);
$stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
unset($stmt);
$values = $current_metadatas = array();
foreach ($rs as $row)
{
$current_metadatas[] = array(
'meta_id' => $row['id']
, 'meta_struct_id' => $databox_field->get_id()
, 'value' => ''
);
$values[] = $row['value'];
}
try
{
$record = $databox_field->get_databox()->get_record($record->get_record_id());
$record->set_metadatas($current_metadatas);
$record->set_metadatas(array(array(
'meta_id' => null
, 'meta_struct_id' => $databox_field->get_id()
, 'value' => implode(' ; ', $values)
)));
unset($record);
}
catch (Exception $e)
{
}
return;
}
public static function merge_all_metadatas(databox_field $databox_field)
{
$sql = 'SELECT distinct record_id FROM metadatas
WHERE meta_struct_id = :meta_struct_id ';
$params = array(
':meta_struct_id' => $databox_field->get_id()
);
$stmt = $databox_field->get_databox()->get_connection()->prepare($sql);
$stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
unset($stmt);
foreach ($rs as $row)
{
self::merge_metadatas($databox_field, $databox_field->get_databox()->get_record($row['record_id']));
}
return;
}
public static function delete_all_metadatas(databox_field $databox_field)
{
$sql = 'SELECT count(id) as count_id FROM metadatas

View File

@@ -38,6 +38,9 @@ class caption_record implements caption_interface, cache_cacheableInterface
protected $dces_elements = array();
protected $databox;
const SERIALIZE_XML = 'xml';
const SERIALIZE_YAML = 'yaml';
/**
*
* @param record_Interface $record
@@ -53,6 +56,94 @@ class caption_record implements caption_interface, cache_cacheableInterface
return $this;
}
public function serialize($format, $includeBusinessFields = false)
{
switch ($format)
{
case self::SERIALIZE_XML:
return $this->serializeXML(!!$includeBusinessFields);
break;
case self::SERIALIZE_YAML:
return $this->serializeYAML(!!$includeBusinessFields);
break;
default:
throw new \Exception(sprintf('Unknown format %s', $format));
break;
}
}
protected function serializeYAML($includeBusinessFields)
{
$buffer = array();
foreach ($this->get_fields(array(), $includeBusinessFields) as $field)
{
$vi = $field->get_values();
if ($field->is_multi())
{
$buffer[$field->get_name()] = array();
foreach ($vi as $value)
{
$val = $value->getValue();
$buffer[$field->get_name()][] = ctype_digit($val) ? (int) $val : $val;
}
}
else
{
$value = array_pop($vi);
$val = $value->getValue();
$buffer[$field->get_name()] = ctype_digit($val) ? (int) $val : $val;
}
}
$buffer = array('record' => array('description' => $buffer));
$dumper = new Symfony\Component\Yaml\Dumper();
return $dumper->dump($buffer, 3);
}
protected function serializeXML($includeBusinessFields)
{
$dom_doc = new DOMDocument('1.0', 'UTF-8');
$dom_doc->formatOutput = true;
$dom_doc->standalone = true;
$record = $dom_doc->createElement('record');
$record->setAttribute('record_id', $this->record->get_record_id());
$dom_doc->appendChild($record);
$description = $dom_doc->createElement('description');
$record->appendChild($description);
foreach ($this->get_fields(array(), $includeBusinessFields) as $field)
{
$values = $field->get_values();
foreach ($values as $value)
{
$elem = $dom_doc->createElement($field->get_name());
$elem->appendChild($dom_doc->createTextNode($value->getValue()));
$elem->setAttribute('meta_id', $value->getId());
$elem->setAttribute('meta_struct_id', $field->get_meta_struct_id());
$description->appendChild($elem);
}
}
$doc = $dom_doc->createElement('doc');
$tc_datas = $this->record->get_technical_infos();
foreach ($tc_datas as $key => $data)
{
$doc->setAttribute($key, $data);
}
$record->appendChild($doc);
return $dom_doc->saveXML();
}
protected function retrieve_fields()
{
if (is_array($this->fields))
@@ -79,8 +170,6 @@ class caption_record implements caption_interface, cache_cacheableInterface
$rec_fields = array();
foreach ($fields as $row)
{
try
{
$databox_meta_struct = databox_field::get_instance($this->databox, $row['structure_id']);
$metadata = new caption_field($databox_meta_struct, $this->record);
@@ -92,11 +181,6 @@ class caption_record implements caption_interface, cache_cacheableInterface
$this->dces_elements[$dces_element->get_label()] = $databox_meta_struct->get_id();
}
}
catch (Exception $e)
{
}
}
$this->fields = $rec_fields;
return $this->fields;
@@ -107,14 +191,21 @@ class caption_record implements caption_interface, cache_cacheableInterface
* @param array $grep_fields
* @return array
*/
public function get_fields(Array $grep_fields = null)
public function get_fields(Array $grep_fields = null, $IncludeBusiness = false)
{
$fields = array();
foreach ($this->retrieve_fields() as $meta_struct_id => $field)
{
if ($grep_fields && !in_array($field->get_name(), $grep_fields))
{
continue;
}
if($field->get_databox_field()->isBusiness() === true && !$IncludeBusiness)
{
continue;
}
$fields[] = $field;
}
@@ -130,10 +221,9 @@ class caption_record implements caption_interface, cache_cacheableInterface
*/
public function get_field($fieldname)
{
foreach ($this->retrieve_fields() as $meta_struct_id => $field)
foreach ($this->get_fields() as $meta_struct_id => $field)
{
if ($field->get_name() == $fieldname)
return $field;
}
@@ -147,7 +237,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
*/
public function get_dc_field($label)
{
$fields = $this->retrieve_fields();
$fields = $this->get_fields();
if (isset($this->dces_elements[$label]))
{
return $fields[$this->dces_elements[$label]];
@@ -163,9 +253,9 @@ class caption_record implements caption_interface, cache_cacheableInterface
* @param searchEngine_adapter $searchEngine
* @return array
*/
public function get_highlight_fields($highlight = '', Array $grep_fields = null, searchEngine_adapter $searchEngine = null)
public function get_highlight_fields($highlight = '', Array $grep_fields = null, searchEngine_adapter $searchEngine = null, $includeBusiness = false)
{
return $this->highlight_fields($highlight, $grep_fields, $searchEngine);
return $this->highlight_fields($highlight, $grep_fields, $searchEngine, $includeBusiness);
}
/**
@@ -175,11 +265,11 @@ class caption_record implements caption_interface, cache_cacheableInterface
* @param searchEngine_adapter $searchEngine
* @return array
*/
protected function highlight_fields($highlight, Array $grep_fields = null, searchEngine_adapter $searchEngine = null)
protected function highlight_fields($highlight, Array $grep_fields = null, searchEngine_adapter $searchEngine = null, $includeBusiness = false)
{
$fields = array();
foreach ($this->retrieve_fields() as $meta_struct_id => $field)
foreach ($this->get_fields(array(), $includeBusiness) as $meta_struct_id => $field)
{
if (is_array($grep_fields) && !in_array($field->get_name(), $grep_fields))
continue;

View File

@@ -98,7 +98,13 @@ class databox_field implements cache_cacheableInterface
*/
protected $thumbtitle;
/**
*
* @var boolean
*/
protected $Business;
protected $renamed = false;
protected $metaToMerge = false;
/**
*
@@ -157,7 +163,7 @@ class databox_field implements cache_cacheableInterface
$sql = "SELECT `thumbtitle`, `separator`
, `dces_element`, `tbranch`, `type`, `report`, `multi`, `required`
, `readonly`, `indexable`, `name`, `src`
, `readonly`, `indexable`, `name`, `src`, `business`
, `VocabularyControlType`, `RestrictToVocabularyControl`
FROM metadatas_structure WHERE id=:id";
@@ -173,6 +179,7 @@ class databox_field implements cache_cacheableInterface
$this->readonly = !!$row['readonly'];
$this->required = !!$row['required'];
$this->multi = !!$row['multi'];
$this->Business = !!$row['business'];
$this->report = !!$row['report'];
$this->type = $row['type'] ? : self::TYPE_STRING;
$this->tbranch = $row['tbranch'];
@@ -193,19 +200,8 @@ class databox_field implements cache_cacheableInterface
$this->dces_element = new $dc_class();
}
if (!$this->multi)
{
$separator = "";
}
else
{
$separator = $row['separator'];
$this->separator = self::checkMultiSeparator($row['separator'], $this->multi);
if (strpos($separator, ';') === false)
$separator .= ';';
}
$this->separator = $separator;
$this->thumbtitle = $row['thumbtitle'];
return $this;
@@ -231,9 +227,18 @@ class databox_field implements cache_cacheableInterface
/**
*
* @param databox $databox
* @return boolean
*/
public function isBusiness()
{
return $this->Business;
}
/**
*
* @param \databox $databox
* @param int $id
* @return databox_field
* @return \databox_field
*/
public static function get_instance(databox &$databox, $id)
{
@@ -327,6 +332,7 @@ class databox_field implements cache_cacheableInterface
`required` = :required,
`separator` = :separator,
`multi` = :multi,
`business` = :business,
`report` = :report,
`type` = :type,
`tbranch` = :tbranch,
@@ -343,6 +349,7 @@ class databox_field implements cache_cacheableInterface
':required' => $this->required ? '1' : '0',
':separator' => $this->separator,
':multi' => $this->multi ? '1' : '0',
':business' => $this->Business ? '1' : '0',
':report' => $this->report ? '1' : '0',
':type' => $this->type,
':tbranch' => $this->tbranch,
@@ -361,6 +368,12 @@ class databox_field implements cache_cacheableInterface
$this->renamed = false;
}
if ($this->metaToMerge)
{
caption_field::merge_all_metadatas($this);
$this->metaToMerge = false;
}
$dom_struct = $this->databox->get_dom_structure();
$xp_struct = $this->databox->get_xpath_structure();
@@ -417,7 +430,14 @@ class databox_field implements cache_cacheableInterface
{
$previous_name = $this->name;
$this->name = self::generateName($name);
$name = self::generateName($name);
if($name === '')
{
throw new \Exception_InvalidArgument();
}
$this->name = $name;
if ($this->name !== $previous_name)
{
@@ -535,6 +555,18 @@ class databox_field implements cache_cacheableInterface
return $this;
}
/**
*
* @param boolean $boolean
* @return databox_field
*/
public function set_business($boolean)
{
$this->Business = !!$boolean;
return $this;
}
/**
*
* @param boolean $bool
@@ -554,7 +586,16 @@ class databox_field implements cache_cacheableInterface
*/
public function set_multi($multi)
{
$this->multi = !!$multi;
$multi = !!$multi;
if ($this->multi !== $multi && !$multi)
{
$this->metaToMerge = true;
}
$this->multi = $multi;
$this->set_separator(';');
return $this;
}
@@ -602,14 +643,26 @@ class databox_field implements cache_cacheableInterface
*/
public function set_separator($separator)
{
if (strpos($separator, ';') === false)
$separator .= ';';
$this->separator = $separator;
$this->separator = self::checkMultiSeparator($separator, $this->multi);
return $this;
}
protected static function checkMultiSeparator($separator, $multi)
{
if (!$multi)
{
return '';
}
if (strpos($separator, ';') === false)
{
$separator .= ';';
}
return $separator;
}
/**
*
* @param string $type
@@ -622,35 +675,6 @@ class databox_field implements cache_cacheableInterface
return $this;
}
/**
*
* @param string $attr
* @return databox_field
*/
protected function set_reg_attr($attr)
{
try
{
$sql = 'UPDATE metadatas_structure SET reg' . $attr . ' = null';
$stmt = $this->get_connection()->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
$sql = 'UPDATE metadatas_structure SET reg' . $attr . '= 1 WHERE id= :id';
$stmt = $this->get_connection()->prepare($sql);
$stmt->execute(array(':id' => $this->id));
$stmt->closeCursor();
}
catch (Exception $e)
{
}
return $this;
}
/**
*
* @return string
@@ -732,15 +756,6 @@ class databox_field implements cache_cacheableInterface
return $this->multi;
}
/**
*
* @return boolean
*/
public function is_distinct()
{
return true;
}
/**
*
* @return boolean
@@ -811,14 +826,21 @@ class databox_field implements cache_cacheableInterface
$sql = "INSERT INTO metadatas_structure
(`id`, `name`, `src`, `readonly`, `indexable`, `type`, `tbranch`,
`thumbtitle`, `multi`,
`thumbtitle`, `multi`, `business`,
`report`, `sorter`)
VALUES (null, :name, '', 0, 1, 'text', '',
VALUES (null, :name, '', 0, 1, 'string', '',
null, 0,
1, :sorter)";
0, 1, :sorter)";
$name = self::generateName($name);
if($name === '')
{
throw new \Exception_InvalidArgument();
}
$stmt = $databox->get_connection()->prepare($sql);
$stmt->execute(array(':name' => self::generateName($name), ':sorter' => $sorter));
$stmt->execute(array(':name' => $name, ':sorter' => $sorter));
$id = $databox->get_connection()->lastInsertId();
$stmt->closeCursor();

View File

@@ -83,7 +83,7 @@ class databox_fieldUnknown extends databox_field
}
/**
* Return tru because the field is unknown
* Return true because the field is unknown
*
* @return boolean
*/

View File

@@ -44,7 +44,7 @@ class module_console_checkExtension extends Command
if (!extension_loaded('phrasea2'))
printf("Missing Extension php-phrasea");
$appbox = \appbox::get_instance();
$appbox = \appbox::get_instance(\bootstrap::getCore());
$registry = $appbox->get_registry();
$usr_id = $input->getOption('usr_id');

View File

@@ -49,8 +49,10 @@ class module_console_schedulerState extends Command
{
$appbox = appbox::get_instance(\bootstrap::getCore());
$task_manager = new task_manager($appbox);
$state = $task_manager->get_scheduler_state();
if ($state['schedstatus'] == 'started')
if ($state['status'] == 'started')
{
$output->writeln(sprintf(
'Scheduler is %s on pid %d'
@@ -60,7 +62,7 @@ class module_console_schedulerState extends Command
}
else
{
$output->writeln(sprintf('Scheduler is %s', $state['schedstatus']));
$output->writeln(sprintf('Scheduler is %s', $state['status']));
}
return 0;

View File

@@ -139,7 +139,7 @@ class module_console_systemExport extends Command
$output->writeln("Export datas from selected base_ids");
}
$appbox = \appbox::get_instance();
$appbox = \appbox::get_instance(\bootstrap::getCore());
$total = $errors = 0;
@@ -298,8 +298,9 @@ class module_console_systemExport extends Command
{
case 'xml':
$pathinfo = pathinfo($dest_file->getPathname());
$xml = $record->get_caption()->serialize(caption_record::SERIALIZE_XML);
$xml_file = dirname($outfile) . '/' . $pathinfo['filename'] . '.xml';
file_put_contents($xml_file, $record->get_xml());
file_put_contents($xml_file, $xml);
break;
default:
break;

View File

@@ -75,14 +75,12 @@ class module_console_taskrun extends Command
return 1;
}
require_once __DIR__ . '/../../../../lib/bootstrap.php';
$task_id = (int) $input->getArgument('task_id');
if ($task_id <= 0 || strlen($task_id) !== strlen($input->getArgument('task_id')))
throw new \RuntimeException('Argument must be an Id.');
$appbox = appbox::get_instance();
$appbox = \appbox::get_instance(\bootstrap::getCore());
$task_manager = new task_manager($appbox);
$this->task = $task_manager->get_task($task_id);

View File

@@ -500,8 +500,10 @@ class module_report
public function getOrder($k = false)
{
if ($k === false)
{
return $this->tab_order;
}
return $this->tab_order[$k];
}
@@ -675,7 +677,7 @@ class module_report
'telechargement' => _('report:: telechargement'),
'record_id' => _('report:: record id'),
'final' => _('report:: type d\'action'),
'xml' => _('report:: sujet'),
// 'xml' => _('report:: sujet'),
'file' => _('report:: fichier'),
'mime' => _('report:: type'),
'size' => _('report:: taille'),
@@ -820,8 +822,10 @@ class module_report
public function buildReport($tab = false, $groupby = false, $on = false)
{
if (sizeof($this->report) > 0)
{
return $this->report;
}
$conn = connection::getPDOConnection($this->sbas_id);
$this->buildReq($groupby, $on);
@@ -863,75 +867,23 @@ class module_report
}
}
/**
* @desc return the text between the node we are looking for
* @param string $unXml the XML string
* @param string $champ the node
* @return string
*/
public static function getChamp($unXml, $champ, $attribut = false)
{
$ret = "";
$sxe = simplexml_load_string($unXml);
if ($sxe)
{
if ($attribut)
{
foreach ($sxe->$champ->attributes() as $a => $b)
{
if ($a == $attribut)
{
$ret.= $b;
}
}
}
else
{
$z = $sxe->xpath('/description/' . $champ);
if (!$z)
$z = $sxe->xpath('/record/description/' . $champ);
if ($z && is_array($z))
{
$ret .= $z[0];
}
}
}
$ret = trim($ret);
if ($ret == "" || $ret == null)
$ret = "<i>" . _('report:: non-renseigne') . "</i>";
return $ret;
}
public static function getPreff($sbasid)
{
$tab = array();
$tab["struct"] = "";
$tab['champs'] = array();
$databox = databox::get_instance((int) $sbasid);
$tab['struct'] = $databox->get_structure();
$sxe = $databox->get_sxml_structure();
if ($sxe)
foreach ($databox->get_meta_structure() as $databox_field)
{
$z = $sxe->xpath('/record/description');
if ($z && is_array($z))
/* @var $databox_field \databox_field */
if ($databox_field->is_report())
{
foreach ($z[0] as $ki => $vi)
{
foreach ($vi->attributes() as $a => $b)
{
if ($a == "report" && $b == 1)
$tab['champs'][] = $ki;
}
}
$tab[] = $databox_field->get_name();
}
}
return $tab['champs'];
return $tab;
}
public static function getHost($url)

View File

@@ -37,7 +37,6 @@ class module_report_activity extends module_report
'fonction' => 'log.fonction',
'usrid' => 'log.usrid',
'coll_id' => 'record.coll_id',
'xml' => 'record.xml',
'ddate' => "DATE_FORMAT(log.date, '%Y-%m-%d')",
'id' => 'log_docs.id',
'log_id' => 'log_docs.log_id',
@@ -301,6 +300,7 @@ class module_report_activity extends module_report
$filter = $s->getFilters();
$conn = $s->getConnBas();
$databox = \databox::get_instance($this->sbas_id);
$params = array();
@@ -314,8 +314,7 @@ class module_report_activity extends module_report
$params = array_merge($params, $user_filter['params']);
$sql = "
SELECT record.xml as titre,
log_docs.record_id,
SELECT log_docs.record_id,
log_docs.date, log_docs.final as objets
FROM (`log_docs` inner join log on log_docs.log_id = log.id
inner join record on log_docs.record_id = record.record_id)
@@ -350,13 +349,15 @@ class module_report_activity extends module_report
foreach ($rs as $row)
{
$record = $databox->get_record($row['record_id']);
foreach ($this->champ as $key => $value)
{
if ($value == 'titre')
$result[$i][$value] = parent::getChamp($row[$value], 'Titre');
else
$result[$i][$value] = $row[$value];
}
$result[$i]['titre'] = $record->get_title();
$i++;
}
$this->title = sprintf(_('report:: Telechargement effectue par l\'utilisateur %s'), $login);

View File

@@ -109,7 +109,6 @@ class module_report_add extends module_report
protected function buildResult($rs)
{
$i = 0;
$pref = parent::getPreff($this->sbas_id);
foreach ($rs as $row)
{
foreach ($this->champ as $key => $value)

View File

@@ -27,7 +27,6 @@ class module_report_download extends module_report
'fonction' => 'log.fonction',
'usrid' => 'log.usrid',
'coll_id' => 'record.coll_id',
'xml' => 'record.xml',
'ddate' => "log_docs.date",
'id' => 'log_docs.id',
'log_id' => 'log_docs.log_id',
@@ -117,27 +116,40 @@ class module_report_download extends module_report
{
if ($this->enable_limit && ($i > $this->nb_record))
break;
foreach ($this->champ as $column)
{
$this->formatResult($column, $row[$column], $pref, $i);
$this->formatResult($column, $row[$column], $i);
}
if (array_key_exists('record_id', $row))
{
$record = new \record_adapter($this->sbas_id, $row['record_id']);
foreach ($pref as $field)
{
try
{
$this->result[$i][$field] = $record->get_caption()
->get_field($field)
->get_serialized_values();
}
catch (\Exception $e)
{
$this->result[$i][$field] = '';
}
}
}
$i++;
}
}
private function formatResult($column, $value, $pref, $i)
private function formatResult($column, $value, $i)
{
if ($value)
{
if ($column == 'coll_id')
$this->result[$i][$column] = $this->formatCollId($value);
elseif ($column == 'xml' && (sizeof($pref) > 0))
{
foreach ($pref as $field)
{
$this->result[$i][$field] = parent::getChamp($value, $field);
}
}
elseif ($column == 'ddate')
$this->result[$i][$column] = $this->formatDateValue($value);
elseif ($column == 'size')
@@ -212,8 +224,10 @@ class module_report_download extends module_report
public static function getTopDl($dmin, $dmax, $sbas_id, $list_coll_id)
{
$conn = connection::getPDOConnection($sbas_id);
$registry = registry::get_instance();
$databox = \databox::get_instance((int) $sbas_id);
$conn = $databox->get_connection();
$registry = $databox->get_registry();
$params = array(':site_id' => $registry->get('GV_sit'));
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
@@ -232,7 +246,7 @@ class module_report_download extends module_report
$sql = '
SELECT record.record_id as id, SUM(1) AS nb, subdef.name, record.xml
SELECT record.record_id as id, SUM(1) AS nb, subdef.name
FROM ( log
INNER JOIN log_docs as log_date ON log.id = log_date.log_id
INNER JOIN record ON log_date.record_id = record.record_id
@@ -256,8 +270,11 @@ class module_report_download extends module_report
foreach ($rs as $row)
{
$record = $databox->get_record($row['id']);
$k = $row['id'] . '_' . $sbas_id;
$orig_name = parent::getChamp($row['xml'], 'doc', 'originalname');
$orig_name = $record->get_original_name();
if ($row['name'] == 'document')
{
$array[$row['name']][$k]['nb'] = (int) $row['nb'];
@@ -277,6 +294,5 @@ class module_report_download extends module_report
return $array;
}
}

View File

@@ -113,7 +113,6 @@ class module_report_edit extends module_report
protected function buildResult($rs)
{
$i = 0;
$pref = parent::getPreff($this->sbas_id);
foreach ($rs as $row)
{

View File

@@ -35,7 +35,6 @@ class module_report_filter
'coll_id' => 'report:: collections',
'comment' => 'report:: commentaire',
'search' => 'report:: question',
'xml' => 'report:: description'
);
public function __construct($current_filter, $correspondance)

View File

@@ -33,7 +33,6 @@ class module_report_nav extends module_report
'fonction' => 'log.fonction',
'usrid' => 'log.usrid',
'coll_id' => 'record.coll_id',
'xml' => 'record.xml',
'ddate' => "log.date",
'id' => 'log_docs.id',
'log_id' => 'log_docs.log_id',

View File

@@ -112,7 +112,6 @@ class module_report_push extends module_report
protected function buildResult($rs)
{
$i = 0;
$pref = parent::getPreff($this->sbas_id);
foreach ($rs as $row)
{

View File

@@ -48,7 +48,6 @@ class module_report_sqldownload extends module_report_sql implements module_repo
log.fonction,
log.usrid,
record.coll_id,
record.xml,
log_docs.date AS ddate,
log_docs.id,
log_docs.log_id,
@@ -89,7 +88,6 @@ class module_report_sqldownload extends module_report_sql implements module_repo
TRIM( ' . $field . ' ) AS ' . $name . ',
SUM(1) AS telechargement,
record.coll_id,
record.xml,
log_docs.final,
log_docs.comment,
subdef.size,

View File

@@ -112,7 +112,6 @@ class module_report_validate extends module_report
protected function buildResult($rs)
{
$i = 0;
$pref = parent::getPreff($this->sbas_id);
foreach ($rs as $row)
{

View File

@@ -69,8 +69,6 @@ interface record_Interface
public function get_caption();
public function get_xml();
public function get_original_name();
public function get_title($highlight = false, searchEngine_adapter $searchEngine = null);

View File

@@ -765,61 +765,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface
*/
public function get_caption()
{
if (!$this->caption_record)
$this->caption_record = new caption_record($this, $this->get_databox());
return $this->caption_record;
}
/**
*
* @return string
*/
public function get_xml()
{
if (!$this->xml)
{
$dom_doc = new DOMDocument('1.0', 'UTF-8');
$dom_doc->formatOutput = true;
$dom_doc->standalone = true;
$record = $dom_doc->createElement('record');
$record->setAttribute('record_id', $this->get_record_id());
$dom_doc->appendChild($record);
$description = $dom_doc->createElement('description');
$record->appendChild($description);
$caption = $this->get_caption();
foreach ($caption->get_fields() as $field)
{
$values = $field->get_values();
foreach ($values as $value)
{
$elem = $dom_doc->createElement($field->get_name());
$elem->appendChild($dom_doc->createTextNode($value->getValue()));
$elem->setAttribute('meta_id', $value->getId());
$elem->setAttribute('meta_struct_id', $field->get_meta_struct_id());
$description->appendChild($elem);
}
}
$doc = $dom_doc->createElement('doc');
$tc_datas = $this->get_technical_infos();
foreach ($tc_datas as $key => $data)
{
$doc->setAttribute($key, $data);
}
$record->appendChild($doc);
$this->xml = $dom_doc->saveXML();
}
return $this->xml;
return new caption_record($this, $this->get_databox());
}
/**
@@ -1274,7 +1221,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$this->caption_record = null;
$xml = new DOMDocument();
$xml->loadXML($this->get_xml());
$xml->loadXML($this->get_caption()->serialize(\caption_record::SERIALIZE_XML));
$this->set_xml($xml);
$this->reindex();
@@ -1383,7 +1330,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
return $this;
}
/**
*
* @param collection $collection
@@ -1591,9 +1537,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface
public function get_hd_file()
{
$hd = $this->get_subdef('document');
if ($hd->is_physically_present())
if ($hd->is_physically_present())
{
return new system_file(p4string::addEndSlash($hd->get_path()) . $hd->get_file());
}
return null;
}
@@ -1626,8 +1575,10 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$origcoll = phrasea::collFromBas($this->get_base_id());
$xml = $this->get_caption()->serialize(\caption_record::SERIALIZE_XML);
$appbox->get_session()->get_logger($this->get_databox())
->log($this, Session_Logger::EVENT_DELETE, $origcoll, $this->get_xml());
->log($this, Session_Logger::EVENT_DELETE, $origcoll, $xml);
$sql = "DELETE FROM record WHERE record_id = :record_id";
$stmt = $connbas->prepare($sql);

View File

@@ -222,7 +222,7 @@ class record_exportElement extends record_adapter
}
}
$xml = $this->get_xml();
$xml = $this->get_caption()->serialize(caption_record::SERIALIZE_XML);
if ($xml)
{

View File

@@ -211,10 +211,10 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
{
$proposals = self::proposalsToHTML($this->qp['main']->proposals);
if (trim($proposals) !== '')
return "<div style='height:0px; overflow:hidden'>" . $this->qp['main']->proposals["QRY"]
{ return "<div style='height:0px; overflow:hidden'>" . $this->qp['main']->proposals["QRY"]
. "</div><div class='proposals'>" . $proposals . "</div>";
}
}
return null;
}
@@ -357,7 +357,17 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
*/
public function get_suggestions(Session_Handler $session)
{
return array();
$props = array();
foreach($this->qp['main']->proposals['QUERIES'] as $prop)
{
$props[] = array(
'value' => $prop
, 'current' => false
, 'hits' => null
);
}
return $props;
}
/**
@@ -415,6 +425,13 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
foreach ($this->queries as $sbas_id => $qry)
{
$BF = array();
foreach ($this->options->get_business_fields() as $base_id)
{
$BF[] = phrasea::collFromBas($base_id);
}
$this->results[$sbas_id] = phrasea_query2(
$session->get_ses_id()
, $sbas_id
@@ -425,6 +442,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
, false
, $this->opt_search_type == 1 ? PHRASEA_MULTIDOC_REGONLY : PHRASEA_MULTIDOC_DOCONLY
, $sort
, $BF
);
$total_time += $this->results[$sbas_id]['time_all'];
@@ -627,13 +645,14 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
);
if ( ! isset($res['results']) || ! is_array($res['results']))
return array();
$rs = $res['results'];
$res = array_shift($rs);
if ( ! isset($res['xml']))
{
return array();
}
$sxe = simplexml_load_string($res['xml']);
foreach ($fields as $name => $field)

View File

@@ -81,7 +81,7 @@ class searchEngine_adapter_phrasea_queryParser
*
* @var array
*/
var $proposals = Array("QRY" => "", "BASES" => array());
var $proposals = Array("QRY" => "", "BASES" => array(), "QUERIES" => array());
/**
* Current language for thesaurus
@@ -119,7 +119,7 @@ class searchEngine_adapter_phrasea_queryParser
}
}
$this->proposals = Array("QRY" => "", "BASES" => array());
$this->proposals = Array("QRY" => "", "BASES" => array(), "QUERIES" => array());
$this->phq = $this->mb_trim($phq, 'UTF-8');
if ($this->phq != "")
@@ -663,6 +663,8 @@ class searchEngine_adapter_phrasea_queryParser
}
}
$this->proposals['QUERIES'][$syfound["w"]] = $syfound["w"];
$thtml = $syfound["v"];
$kjs = $syfound["k"] ? ("'" . p4string::MakeString($syfound["k"], "js") . "'") : "null";
$wjs = "'" . p4string::MakeString($syfound["w"], "js") . "'";

View File

@@ -116,6 +116,33 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
}
}
$crc_coll_business = array();
if ($options->get_business_fields())
{
$this->search_in_field = true;
foreach ($options->get_business_fields() as $base_id)
{
$crc_coll_business[] = crc32(phrasea::collFromBas($base_id) . '_1');
$crc_coll_business[] = crc32(phrasea::collFromBas($base_id) . '_0');
}
$non_business = array_diff($options->get_bases(), $options->get_business_fields());
foreach ($non_business as $base_id)
{
$crc_coll_business[] = crc32(phrasea::collFromBas($base_id) . '_0');
}
$this->sphinx->SetFilter('crc_coll_business', $crc_coll_business);
}
elseif ($this->search_in_field)
{
$this->sphinx->SetFilter('business', array(0));
}
if ($filters)
{
$this->sphinx->SetFilter('crc_struct_id', $filters);
@@ -603,7 +630,13 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
$n ++;
}
$propals = array(array('value' => $supposed_qry, 'current' => true, 'hits' => $this->get_total_results()));
$propals = array(
array(
'value' => $supposed_qry
, 'current' => true
, 'hits' => $this->get_total_results()
)
);
foreach ($q_todo as $f)
{
@@ -641,7 +674,12 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
if ($found > 0)
{
$propals[] = array('value' => $f, 'current' => false, 'hits' => $found, 'cache' => $cache);
$propals[] = array(
'value' => $f
, 'current' => false
, 'hits' => $found
, 'cache' => $cache
);
}
}

View File

@@ -17,20 +17,18 @@
*/
class searchEngine_options implements Serializable
{
const RECORD_RECORD = 0;
const RECORD_GROUPING = 1;
const TYPE_IMAGE = 'image';
const TYPE_VIDEO = 'video';
const TYPE_AUDIO = 'audio';
const TYPE_DOCUMENT = 'document';
const TYPE_FLASH = 'flash';
const TYPE_ALL = '';
const SORT_RELEVANCE = 'relevance';
const SORT_CREATED_ON = 'created_on';
const SORT_RANDOM = 'random';
const SORT_MODE_ASC = 'asc';
const SORT_MODE_DESC = 'desc';
@@ -105,6 +103,7 @@ class searchEngine_options implements Serializable
* @var string
*/
protected $sort_ord = self::SORT_MODE_DESC;
protected $business_fields = array();
/**
* Constructor
@@ -148,6 +147,18 @@ class searchEngine_options implements Serializable
return $this;
}
public function set_business_fields(Array $base_ids)
{
$this->business_fields = $base_ids;
return $this;
}
public function get_business_fields()
{
return $this->business_fields;
}
/**
*
* @return string
@@ -460,7 +471,6 @@ class searchEngine_options implements Serializable
$k = ctype_digit($k) ? (int) $k : $k;
$value[$k] = $data;
}
}
$this->$key = $value;

View File

@@ -27,6 +27,7 @@ class set_export extends set_abstract
protected $display_ftp;
protected $ftp_datas;
protected $list;
protected $businessFieldsAccess;
/**
*
@@ -186,8 +187,15 @@ class set_export extends set_abstract
$this->total_order = 0;
$this->total_ftp = 0;
$this->businessFieldsAccess = false;
foreach ($this->elements as $download_element)
{
if($user->ACL()->has_right_on_base($download_element->get_base_id(), 'canmodifrecord'))
{
$this->businessFieldsAccess = true;
}
foreach ($download_element->get_downloadable() as $name => $properties)
{
if (!isset($display_download[$name]))
@@ -206,14 +214,13 @@ class set_export extends set_abstract
{
$display_download[$name]['available']++;
$display_download[$name]['label'] = $properties['label'];
$display_download[$name]['class'] = $properties['class'];
$this->total_download++;
$display_download[$name]['size'] +=
$download_element->get_size($name);
$display_download[$name]['size'] += $download_element->get_size($name);
}
else
{
$display_download[$name]['refused'][] =
$download_element->get_thumbnail();
$display_download[$name]['refused'][] = $download_element->get_thumbnail();
}
}
foreach ($download_element->get_orderable() as $name => $properties)
@@ -236,8 +243,7 @@ class set_export extends set_abstract
}
else
{
$display_orderable[$name]['refused'][] =
$download_element->get_thumbnail();
$display_orderable[$name]['refused'][] = $download_element->get_thumbnail();
}
}
}
@@ -357,6 +363,10 @@ class set_export extends set_abstract
{
return $this->ftp_datas;
}
public function has_business_fields_access()
{
return $this->businessFieldsAccess;
}
/**
*
@@ -418,12 +428,15 @@ class set_export extends set_abstract
* @param boolean $rename_title
* @return Array
*/
public function prepare_export(Array $subdefs, $rename_title = false)
public function prepare_export(Array $subdefs, $rename_title, $includeBusinessFields )
{
if (!is_array($subdefs))
{
throw new Exception('No subdefs given');
}
$includeBusinessFields = !!$includeBusinessFields;
$appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$registry = $appbox->get_registry();
@@ -451,11 +464,16 @@ class set_export extends set_abstract
'subdefs' => array()
);
$sbas_id = phrasea::sbasFromBas($download_element->get_base_id());
$rename_done = false;
$desc = $download_element->get_xml();
$BF = false;
if($includeBusinessFields && $user->ACL()->has_right_on_base($download_element->get_base_id(), 'canmodifrecord'))
{
$BF = true;
}
$desc = $download_element->get_caption()->serialize(caption_record::SERIALIZE_XML, $BF);
$files[$id]['original_name'] =
$files[$id]['export_name'] =
@@ -689,10 +707,7 @@ class set_export extends set_abstract
system_file::mkdir($caption_dir);
$desc = self::get_caption(
$download_element->get_base_id()
, $download_element->get_record_id()
);
$desc = $download_element->get_caption()->serialize(\caption_record::SERIALIZE_XML, $BF);
$file = $files[$id]["export_name"]
. $files[$id]["subdefs"]['caption']["ajout"] . '.'
@@ -700,14 +715,12 @@ class set_export extends set_abstract
$path = $caption_dir;
if ($handle = fopen($path . $file, "w"))
{
fwrite($handle, $desc);
fclose($handle);
file_put_contents($path . $file, $desc);
$files[$id]["subdefs"]['caption']["path"] = $path;
$files[$id]["subdefs"]['caption']["file"] = $file;
$files[$id]["subdefs"]['caption']["size"] = filesize($path . $file);
}
$files[$id]["subdefs"]['caption']['businessfields'] = $BF ? '1' : '0';
}
if (in_array('caption-yaml', $subdefs))
{
@@ -716,14 +729,7 @@ class set_export extends set_abstract
. $session->get_ses_id() . '/';
system_file::mkdir($caption_dir);
$desc = self::get_caption(
$download_element->get_base_id()
, $download_element->get_record_id()
, true
, 'yaml'
);
$desc = $download_element->get_caption()->serialize(\caption_record::SERIALIZE_YAML, $BF);
$file = $files[$id]["export_name"]
. $files[$id]["subdefs"]['caption-yaml']["ajout"] . '.'
@@ -731,14 +737,12 @@ class set_export extends set_abstract
$path = $caption_dir;
if ($handle = fopen($path . $file, "w"))
{
fwrite($handle, $desc);
fclose($handle);
file_put_contents($path . $file, $desc);
$files[$id]["subdefs"]['caption-yaml']["path"] = $path;
$files[$id]["subdefs"]['caption-yaml']["file"] = $file;
$files[$id]["subdefs"]['caption-yaml']["size"] = filesize($path . $file);
}
$files[$id]["subdefs"]['caption-yaml']['businessfields'] = $BF ? '1' : '0';
}
}
@@ -839,121 +843,6 @@ class set_export extends set_abstract
return $zipFile;
}
/**
*
* @param Int $bas
* @param Int $rec
* @param boolean $check_rights
* @return string
*/
public static function get_caption($bas, $rec, $check_rights = true, $format = 'xml')
{
$dom = new DOMDocument();
$dom->formatOutput = true;
$dom->xmlStandalone = true;
$dom->encoding = 'UTF-8';
$dom_record = $dom->createElement('record');
$dom_desc = $dom->createElement('description');
$dom_record->appendChild($dom_desc);
$dom->appendChild($dom_record);
$restrict = array();
$sbas_id = phrasea::sbasFromBas($bas);
$record = new record_adapter($sbas_id, $rec);
$desc = $record->get_xml();
$appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$databox = databox::get_instance($sbas_id);
$struct = $databox->get_structure();
$rights = true;
if ($check_rights && $session->is_authenticated())
{
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
$rights = $user->ACL()->has_right_on_base($bas, 'canmodifrecord');
if ($rights == false)
{
if ($sxe = simplexml_load_string($struct))
{
$z = $sxe->xpath('/record/description');
if ($z && is_array($z))
{
foreach ($z[0] as $ki => $vi)
{
if (isset($vi["export"])
&& ($vi["export"] == "0" || $vi["export"] == "off"))
$restrict[$ki] = true;
}
}
}
}
}
$buffer = array();
foreach ($record->get_caption()->get_fields() as $field)
{
if (($rights || !isset($restrict[$field->get_name()])))
{
switch ($format)
{
case 'yaml':
case 'yml':
$vi = $field->get_values();
if ($field->is_multi())
{
$buffer[$field->get_name()] = array();
foreach ($vi as $value)
{
$val = $value->getValue();
$buffer[$field->get_name()][] = ctype_digit($val) ? (int) $val : $val;
}
}
else
{
$value = array_pop($vi);
$val = $value->getValue();
$buffer[$field->get_name()] = ctype_digit($val) ? (int) $val : $val;
}
break;
case 'xml':
default:
$dom_el = $dom->createElement($field->get_name());
$dom_el->appendChild($dom->createTextNode($field->get_serialized_values()));
$dom_desc->appendChild($dom_el);
break;
}
}
}
$buffer = array('record' => array('description' => $buffer));
$dumper = new Symfony\Component\Yaml\Dumper();
$buffer = $dumper->dump($buffer, 3);
switch ($format)
{
case 'xml':
default:
$ret = $dom->saveXML();
break;
case 'yaml':
case 'yml':
$ret = $buffer;
break;
}
return $ret;
}
/**
*
* @param string $file
@@ -1111,7 +1000,7 @@ class set_export extends set_abstract
$log["rid"] = $record_object->get_record_id();
$log["subdef"] = $o;
$log["poids"] = $obj["size"];
$log["shortXml"] = $record_object->get_xml();
$log["shortXml"] = $record_object->get_caption()->serialize(caption_record::SERIALIZE_XML);
$tmplog[$record_object->get_base_id()][] = $log;
if (!$anonymous && $o == 'document')
$user->ACL()->remove_remaining($record_object->get_base_id());

View File

@@ -122,10 +122,10 @@ class set_exportftp extends set_export
$ftp_export_id = $conn->lastInsertId();
$sql = 'INSERT INTO ftp_export_elements
(id, ftp_export_id, base_id, record_id, subdef, filename, folder)
(id, ftp_export_id, base_id, record_id, subdef, filename, folder, businessfields)
VALUES
(null, :ftp_export_id, :base_id, :record_id, :subdef,
:filename, :folder)';
:filename, :folder, :businessfields)';
$stmt = $conn->prepare($sql);
@@ -137,6 +137,8 @@ class set_exportftp extends set_export
. $properties["ajout"] . '.'
. $properties['exportExt'];
$bfields = isset($properties['businessfields']) ? $properties['businessfields'] : null;
$params = array(
':ftp_export_id' => $ftp_export_id
, ':base_id' => $file['base_id']
@@ -144,6 +146,7 @@ class set_exportftp extends set_export
, ':subdef' => $subdef
, ':filename' => $filename
, ':folder' => $properties['folder']
, ':businessfields' => $bfields
);
$stmt->execute($params);
}

View File

@@ -17,15 +17,13 @@
*/
class sphinx_configuration
{
const OPT_ALL_SBAS = 'all';
const OPT_ALL_SBAS = 'all';
const OPT_LIBSTEMMER_NONE = 'none';
const OPT_LIBSTEMMER_FR = 'fr';
const OPT_LIBSTEMMER_EN = 'en';
const OPT_ENABLE_STAR_ON = 'yes';
const OPT_ENABLE_STAR_OFF = 'no';
const OPT_MIN_PREFIX_LEN = 0;
const OPT_MIN_INFIX_LEN = 1;
@@ -216,7 +214,9 @@ class sphinx_configuration
CRC32(CONCAT_WS("_", ' . $id . ', r.record_id)) as crc_sbas_record, \
CONCAT_WS("_", ' . $id . ', r.coll_id) as sbas_coll, \
CRC32(r.type) as crc_type, r.coll_id, \
UNIX_TIMESTAMP(credate) as created_on, 0 as deleted \
UNIX_TIMESTAMP(credate) as created_on, 0 as deleted, \
CRC32(CONCAT_WS("_", r.coll_id, s.business)) as crc_coll_business, \
s.business \
FROM metadatas m, metadatas_structure s, record r \
WHERE m.record_id = r.record_id AND m.meta_struct_id = s.id \
AND s.indexable = "1"
@@ -231,9 +231,12 @@ class sphinx_configuration
sql_attr_uint = crc_sbas_record
sql_attr_uint = crc_type
sql_attr_uint = deleted
sql_attr_uint = business
sql_attr_uint = crc_coll_business
sql_attr_timestamp = created_on
sql_attr_multi = uint status from query; SELECT m.id as id, CRC32(CONCAT_WS("_", ' . $id . ', s.name)) as name \
sql_attr_multi = uint status from query; SELECT m.id as id, \
CRC32(CONCAT_WS("_", ' . $id . ', s.name)) as name \
FROM metadatas m, status s \
WHERE s.record_id = m.record_id AND s.value = 1 \
ORDER BY m.id ASC
@@ -341,6 +344,8 @@ class sphinx_configuration
rt_attr_uint = crc_sbas_record
rt_attr_uint = crc_type
rt_attr_uint = deleted
rt_attr_uint = business
rt_attr_uint = crc_coll_business
rt_attr_timestamp = created_on
}
@@ -371,13 +376,17 @@ class sphinx_configuration
sql_attr_uint = deleted
sql_attr_timestamp = created_on
sql_attr_multi = uint status from query; SELECT r.record_id as id, CRC32(CONCAT_WS("_", ' . $id . ', s.name)) as name \
sql_attr_multi = uint status from query; SELECT r.record_id as id, \
CRC32(CONCAT_WS("_", ' . $id . ', s.name)) as name \
FROM record r, status s \
WHERE s.record_id = r.record_id AND s.value = 1 \
ORDER BY r.record_id ASC
sql_joined_field = metas from query; \
SELECT record_id as id, value FROM metadatas ORDER BY record_id ASC
SELECT m.record_id as id, m.value \
FROM metadatas m, metadatas_structure s \
WHERE s.id = m.meta_struct_id AND s.business = 0 \
ORDER BY m.record_id ASC
# datas returned in the resultset
sql_query_info = SELECT r.* FROM record r WHERE r.record_id=$id

View File

@@ -99,8 +99,9 @@ class sphinxrt
$cl = new SphinxClient();
if ($cl->Status() === false)
{
return $this;
}
$cl->SetServer($registry->get('GV_sphinx_host'), (int) $registry->get('GV_sphinx_port'));
$cl->SetConnectTimeout(1);
@@ -122,7 +123,7 @@ class sphinxrt
return $this;
}
public function replace_in_metas($rt_id, $meta_id, $tag_id, $record_id, $sbas_id, $coll_id, $grouping, $type, $content, DateTime $created)
public function replace_in_metas($rt_id, $meta_id, $tag_id, $record_id, $sbas_id, $coll_id, $grouping, $type, $content, $business, DateTime $created)
{
$crc_sbas_tag = crc32($sbas_id . '_' . $tag_id);
$crc_sbas_coll = crc32($sbas_id . '_' . $coll_id);
@@ -144,6 +145,8 @@ class sphinxrt
," . (int) $crc_sbas_record . "
," . (int) $crc_type . "
,0
," . (int) $business . "
," . (int) crc32($coll_id . '_' . $business) . "
," . (int) $created->format('U') . " )";
$stmt = $this->connection->prepare($sql);
$stmt->execute();

View File

@@ -55,8 +55,7 @@ class task_Scheduler
protected static function get_connection()
{
require dirname(__FILE__) . '/../../../config/connexion.inc';
return(appbox::get_instance()->get_connection());
return appbox::get_instance(\bootstrap::getCore())->get_connection();
}
public function run($input=null, OutputInterface $output = null) //, $log = true, $log_tasks = true)
@@ -66,7 +65,7 @@ class task_Scheduler
require_once dirname(__FILE__) . '/../../bootstrap.php';
$this->input = $input;
$this->output = $output;
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$registry = $appbox->get_registry();
$nullfile = '';
@@ -122,7 +121,7 @@ class task_Scheduler
$logdir = $registry->get('GV_RootPath') . 'logs/';
$conn = appbox::get_instance()->get_connection();
$conn = appbox::get_instance(\bootstrap::getCore())->get_connection();
$taskPoll = array(); // the poll of tasks
@@ -184,7 +183,7 @@ class task_Scheduler
sleep(1);
try
{
$conn = appbox::get_instance()->get_connection();
$conn = appbox::get_instance(\bootstrap::getCore())->get_connection();
}
catch(ErrorException $e)
{

View File

@@ -153,22 +153,9 @@ class task_manager
}
public function get_scheduler_state()
{
$sql = "SELECT schedstatus,
UNIX_TIMESTAMP()-UNIX_TIMESTAMP(schedqtime) AS schedqdelay, schedpid
FROM sitepreff";
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
return $row;
}
public function get_scheduler_state2()
{
$pid = NULL;
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$lockdir = $appbox->get_registry()->get('GV_RootPath') . 'tmp/locks/';
if( ($schedlock = fopen( $lockdir . 'scheduler.lock', 'a+')) )
{
@@ -185,7 +172,8 @@ class task_manager
fclose($schedlock);
}
$sql = "SELECT UNIX_TIMESTAMP()-UNIX_TIMESTAMP(schedqtime) AS qdelay, schedstatus AS status FROM sitepreff";
$sql = "SELECT UNIX_TIMESTAMP()-UNIX_TIMESTAMP(schedqtime) AS qdelay
, schedstatus AS status FROM sitepreff";
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute();
$ret = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -198,7 +186,8 @@ class task_manager
$ret['status'] = 'stopped';
}
$ret['pid'] = $pid;
return($ret);
return $ret;
}
public static function getAvailableTasks()

View File

@@ -470,12 +470,14 @@ class task_period_ftp extends task_appboxAbstract
{
$sbas_id = phrasea::sbasFromBas($base_id);
$record = new record_adapter($sbas_id, $record_id);
$sdcaption = $record->get_xml();
$sdcaption = $record->get_caption()->serialize(caption_record::SERIALIZE_XML, $ftp_export["businessfields"]);
$remotefile = $file["filename"];
if ($subdef == 'caption')
{
$desc = set_export::get_caption($base_id, $record_id, false);
$desc = $record->get_caption()->serialize(\caption_record::SERIALIZE_XML, $ftp_export["businessfields"]);
$localfile = $registry->get('GV_RootPath') . 'tmp/' . md5($desc . time() . mt_rand());
if (file_put_contents($localfile, $desc) === false)
@@ -485,7 +487,7 @@ class task_period_ftp extends task_appboxAbstract
}
elseif ($subdef == 'caption-yaml')
{
$desc = set_export::get_caption($base_id, $record_id, false, 'yaml');
$desc = $record->get_caption()->serialize(\caption_record::SERIALIZE_YAML, $ftp_export["businessfields"]);
$localfile = $registry->get('GV_RootPath') . 'tmp/' . md5($desc . time() . mt_rand());
if (file_put_contents($localfile, $desc) === false)

View File

@@ -320,8 +320,12 @@ class task_period_writemeta extends task_databoxAbstract
{
$meta = $field->get_databox_field();
/* @var $meta \databox_field */
if (trim($meta->get_metadata_source()) === '')
{
continue;
}
$multi = $meta->is_multi();
$type = $meta->get_type();

View File

@@ -2253,6 +2253,14 @@
<default></default>
<comment></comment>
</field>
<field>
<name>businessfields</name>
<type>tinyint(1) unsigned</type>
<null>YES</null>
<extra></extra>
<default></default>
<comment></comment>
</field>
<field>
<name>error</name>
<type>tinyint(1) unsigned</type>
@@ -5111,6 +5119,14 @@
<default></default>
<comment></comment>
</field>
<field>
<name>business</name>
<type>int(1) unsigned</type>
<null></null>
<extra></extra>
<default></default>
<comment></comment>
</field>
<field>
<name>indexable</name>
<type>int(1) unsigned</type>
@@ -5476,6 +5492,14 @@
<default>0</default>
<comment></comment>
</field>
<field>
<name>business</name>
<type>tinyint(1) unsigned</type>
<null></null>
<extra></extra>
<default>1</default>
<comment></comment>
</field>
</fields>
<indexes>
<index>
@@ -6468,6 +6492,14 @@
<comment></comment>
</field>
<field>
<name>business</name>
<type>tinyint(1) unsigned</type>
<null></null>
<extra></extra>
<default>1</default>
<comment></comment>
</field>
</fields>
<indexes>
<index>
@@ -7179,6 +7211,15 @@
<comment></comment>
</field>
<field>
<name>business</name>
<type>tinyint(1) unsigned</type>
<null></null>
<extra></extra>
<default>1</default>
<comment></comment>
</field>
</fields>
<indexes>
<index>

View File

@@ -40,7 +40,7 @@
</filter>
<listeners>
<listener class="SimpleTestListener" file="unitTest/PHPUNITListener.inc"></listener>
<listener class="PhraseanetPHPUnitListener" file="unitTest/PhraseanetPHPUnitListener.class"></listener>
</listeners>
</phpunit>

View File

@@ -16,6 +16,10 @@ class ApcCacheTest extends \PHPUnit_Framework_TestCase
public function setUp()
{
if (extension_loaded('apc'))
{
$this->markTestSkipped('Apc is not installed');
}
$this->object = new \Alchemy\Phrasea\Cache\ApcCache;
}

View File

@@ -470,31 +470,32 @@ class ControllerBasketTest extends PhraseanetWebTestCaseAuthenticatedAbstract
$datas = $em->getRepository('Entities\ValidationData')->findAll();
$countDatas = count($datas);
$basket = $this->insertOneBasket();
$validationSession = new \Entities\ValidationSession();
$validationSession->setDescription('Une description au hasard');
$validationSession->setName('Un nom de validation');
$expires = new \DateTime();
$expires->modify('+1 week');
$validationSession->setExpires($expires);
$validationSession->setInitiator(self::$user);
$basket = new \Entities\Basket();
$basket->setName('test');
$basket->setDescription('description');
$basket->setOwner(self::$user);
$basket->setValidation($validationSession);
$validationSession->setBasket($basket);
$em->persist($validationSession);
$basket->setValidation($validationSession);
$validationSession->setBasket($basket);
$validationParticipant = new \Entities\ValidationParticipant();
$validationParticipant->setSession($validationSession);
$validationParticipant->setUser(self::$user_alt1);
$validationSession->addValidationParticipant($validationParticipant);
$em->persist($validationParticipant);
$em->persist($basket);
$em->persist($validationSession);
$validationSession->addValidationParticipant($validationParticipant);
$em->flush();

View File

@@ -29,7 +29,7 @@ class ServiceApcCacheTest extends PhraseanetPHPUnitAbstract
if (extension_loaded('apc'))
{
$service = $cache->getDriver();
$this->assertTrue($service instanceof \Doctrine\Common\Cache\AbstractCache);
$this->assertTrue($service instanceof \Doctrine\Common\Cache\CacheProvider);
}
else
{

View File

@@ -27,7 +27,7 @@ class ServiceArrayCacheTest extends PhraseanetPHPUnitAbstract
);
$service = $cache->getDriver();
$this->assertTrue($service instanceof \Doctrine\Common\Cache\AbstractCache);
$this->assertTrue($service instanceof \Doctrine\Common\Cache\CacheProvider);
}
public function testServiceException()

View File

@@ -29,7 +29,7 @@ class ServiceMemcacheCacheTest extends PhraseanetPHPUnitAbstract
if (extension_loaded('memcache'))
{
$service = $cache->getDriver();
$this->assertTrue($service instanceof \Doctrine\Common\Cache\AbstractCache);
$this->assertTrue($service instanceof \Doctrine\Common\Cache\CacheProvider);
}
else
{

View File

@@ -29,7 +29,7 @@ class ServiceXcacheCacheTest extends PhraseanetPHPUnitAbstract
if (extension_loaded('xcache'))
{
$service = $cache->getDriver();
$this->assertTrue($service instanceof \Doctrine\Common\Cache\AbstractCache);
$this->assertTrue($service instanceof \Doctrine\Common\Cache\CacheProvider);
}
else
{

View File

@@ -10,6 +10,7 @@
*/
require_once __DIR__ . "/../../lib/classes/bootstrap.class.php";
require_once __DIR__ . "/PhraseanetPHPUnitListener.class.inc";
use Silex\WebTestCase;
use Symfony\Component\HttpKernel\Client;
@@ -1313,6 +1314,20 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
*/
private static function deleteRessources()
{
$skipped = \PhraseanetPHPUnitListener::getSkipped();
if($skipped)
{
echo "\nSkipped test : \n\n";
foreach($skipped as $skipped_test)
{
echo $skipped_test . "\n";
}
echo "\n";
}
\PhraseanetPHPUnitListener::resetSkipped();
if (self::$story_1 instanceof record_adapter)
{
self::$story_1->delete();

View File

@@ -1,8 +1,10 @@
<?php
class SimpleTestListener implements PHPUnit_Framework_TestListener
class PhraseanetPHPUnitListener implements PHPUnit_Framework_TestListener
{
private static $skipped = array();
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
{
return;
@@ -20,6 +22,20 @@ class SimpleTestListener implements PHPUnit_Framework_TestListener
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
{
static::$skipped[] = get_class($test) . ':' . $test->getName() . ' - ' . $e->getMessage();
return;
}
public function getSkipped()
{
return static::$skipped;
}
public function resetSkipped()
{
static::$skipped = array();
return;
}

View File

@@ -0,0 +1,182 @@
<?php
require_once __DIR__ . '/../PhraseanetPHPUnitAbstract.class.inc';
/**
* Test class for caption_record.
* Generated by PHPUnit on 2012-03-20 at 15:12:31.
*/
class caption_recordTest extends PhraseanetPHPUnitAbstract
{
/**
* @var caption_record
*/
protected $object;
protected static $need_records = 1;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
public function setUp()
{
$this->object = new caption_record(self::$record_1, self::$record_1->get_databox());
}
/**
* @covers {className}::{origMethodName}
* @todo Implement testSerialize().
*/
public function testSerializeXML()
{
foreach (self::$record_1->get_databox()->get_meta_structure() as $databox_field)
{
$n = $databox_field->is_multi() ? 3 : 1;
for ($i = 0; $i < $n; $i++)
{
\caption_Field_Value::create($databox_field, self::$record_1, \random::generatePassword());
}
}
$xml = $this->object->serialize(\caption_record::SERIALIZE_XML);
$sxe = simplexml_load_string($xml);
$this->assertInstanceOf('SimpleXMLElement', $sxe);
foreach (self::$record_1->get_caption()->get_fields() as $field)
{
if($field->get_databox_field()->is_multi())
{
$tagname = $field->get_name();
$retrieved = array();
foreach($sxe->description->$tagname as $value)
{
$retrieved[] = (string) $value;
}
$values = $field->get_values();
$this->assertEquals(count($values), count($retrieved));
foreach($values as $val)
{
$this->assertTrue(in_array($val->getValue(), $retrieved));
}
}
else
{
$tagname = $field->get_name();
$value = array_pop($field->get_values());
$this->assertEquals($value->getValue(), (string) $sxe->description->$tagname);
}
}
}
public function testSerializeYAML()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_fields().
*/
public function testGet_fields()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_field().
*/
public function testGet_field()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_dc_field().
*/
public function testGet_dc_field()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_highlight_fields().
*/
public function testGet_highlight_fields()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_cache_key().
*/
public function testGet_cache_key()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_data_from_cache().
*/
public function testGet_data_from_cache()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers {className}::{origMethodName}
* @todo Implement testSet_data_to_cache().
*/
public function testSet_data_to_cache()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers {className}::{origMethodName}
* @todo Implement testDelete_data_from_cache().
*/
public function testDelete_data_from_cache()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
}
?>

View File

@@ -12,10 +12,11 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
/**
* @var databox_field
*/
protected $object;
protected $object_mono;
protected $object_multi;
protected $databox;
protected $name;
protected $id;
protected $name_mono;
protected $name_multi;
protected static $need_records = 1;
/**
@@ -25,33 +26,41 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
public function setUp()
{
$this->databox = self::$record_1->get_databox();
$this->name = 'Field Test';
$this->name_mono = 'Field Test Mono';
$this->name_multi = 'Field Test Multi';
$this->object = $this->databox->get_meta_structure()->get_element_by_name($this->name);
$this->object_mono = $this->databox->get_meta_structure()->get_element_by_name($this->name_mono);
if(!$this->object instanceof databox_field)
$this->object = databox_field::create($this->databox, $this->name);
$this->object_multi = $this->databox->get_meta_structure()->get_element_by_name($this->name_multi);
$this->id = $this->object->get_id();
if(!$this->object_mono instanceof databox_field)
$this->object_mono = databox_field::create($this->databox, $this->name_mono);
if(!$this->object_multi instanceof databox_field)
{
$this->object_multi = databox_field::create($this->databox, $this->name_multi);
$this->object_multi->set_multi(true)->save();
}
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
public function tearDown()
{
if($this->object instanceof databox_field)
$this->object->delete();
if($this->object_mono instanceof databox_field)
$this->object_mono->delete();
if($this->object_multi instanceof databox_field)
$this->object_multi->delete();
$extra = $this->databox->get_meta_structure()->get_element_by_name('Bonoboyoyo');
if($extra instanceof databox_field)
$extra->delete();
}
/**
* @todo Implement testGet_instance().
*/
public function testGet_instance()
{
$instance = databox_field::get_instance($this->databox, $this->id);
$this->assertEquals($this->object->get_id(), $instance->get_id());
$instance = databox_field::get_instance($this->databox, $this->object_mono->get_id());
$this->assertEquals($this->object_mono->get_id(), $instance->get_id());
$instance = databox_field::get_instance($this->databox, $this->object_multi->get_id());
$this->assertEquals($this->object_multi->get_id(), $instance->get_id());
}
/**
@@ -64,26 +73,18 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
);
}
/**
* @todo Implement testGet_connection().
*/
public function testGet_connection()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->assertInstanceOf('\connection_pdo', $this->object_mono->get_connection());
$this->assertInstanceOf('\connection_pdo', $this->object_multi->get_connection());
}
/**
* @todo Implement testGet_databox().
*/
public function testGet_databox()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->assertInstanceOf('\databox', $this->object_mono->get_databox());
$this->assertEquals(self::$record_1->get_databox()->get_sbas_id(), $this->object_mono->get_databox()->get_sbas_id());
$this->assertInstanceOf('\databox', $this->object_multi->get_databox());
$this->assertEquals(self::$record_1->get_databox()->get_sbas_id(), $this->object_multi->get_databox()->get_sbas_id());
}
/**
@@ -108,26 +109,23 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
);
}
/**
* @todo Implement testSet_name().
*/
public function testSet_name()
{
$name = 'Eléphant';
$this->object->set_name($name);
$this->assertEquals('Elephant', $this->object->get_name());
$this->object_mono->set_name($name);
$this->assertEquals('Elephant', $this->object_mono->get_name());
$name = '0!èEléphant ';
$this->object->set_name($name);
$this->assertEquals('eElephant', $this->object->get_name());
$this->object_mono->set_name($name);
$this->assertEquals('eElephant', $this->object_mono->get_name());
$name = 'Gaston';
$this->object->set_name($name);
$this->assertEquals('Gaston', $this->object->get_name());
$this->object_mono->set_name($name);
$this->assertEquals('Gaston', $this->object_mono->get_name());
try
{
$this->object->set_name('');
$this->object_mono->set_name('');
$this->fail();
}
catch (Exception $e)
@@ -137,8 +135,8 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
try
{
$this->object->set_name('éà');
$this->assertEquals('ea', $this->object->get_name());
$this->object_mono->set_name('éà');
$this->assertEquals('ea', $this->object_mono->get_name());
}
catch (Exception $e)
{
@@ -157,26 +155,29 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
);
}
/**
* @todo Implement testSet_source().
*/
public function testSet_source()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$source = '/rdf:RDF/rdf:Description/PHRASEANET:tf-filename';
$this->object_mono->set_source($source);
$this->object_multi->set_source($source);
$this->assertEquals($source, $this->object_mono->get_source()->get_source());
$this->assertEquals($source, $this->object_multi->get_source()->get_source());
$this->object_mono->set_source(null);
$this->object_multi->set_source(null);
$this->assertInstanceOf('\metadata_Interface', $this->object_mono->get_source());
$this->assertInstanceOf('\metadata_Interface', $this->object_multi->get_source());
$this->assertEquals('', $this->object_mono->get_source()->get_source());
$this->assertEquals('', $this->object_multi->get_source()->get_source());
}
/**
* @todo Implement testGet_source().
*/
public function testGet_source()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->assertInstanceOf('\metadata_Interface', $this->object_mono->get_source());
$this->assertInstanceOf('\metadata_Interface', $this->object_multi->get_source());
}
/**
@@ -184,296 +185,271 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
*/
public function testGet_dces_element()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->assertNull($this->object_mono->get_dces_element());
$this->assertNull($this->object_multi->get_dces_element());
}
/**
* @todo Implement testSet_dces_element().
*/
public function testSet_dces_element()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->object_mono->set_dces_element(new \databox_Field_DCES_Contributor());
$this->object_multi->set_dces_element(new \databox_Field_DCES_Format());
$this->assertInstanceOf('\databox_Field_DCESAbstract', $this->object_mono->get_dces_element());
$this->assertInstanceOf('\databox_Field_DCESAbstract', $this->object_multi->get_dces_element());
$this->object_multi->set_dces_element(null);
$this->assertNull($this->object_multi->get_dces_element());
}
/**
* @todo Implement testSet_indexable().
*/
public function testSet_indexable()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->object_mono->set_indexable(false);
$this->assertFalse($this->object_mono->is_indexable());
$this->object_mono->set_indexable(true);
$this->assertTrue($this->object_mono->is_indexable());
}
/**
* @todo Implement testSet_readonly().
*/
public function testSet_readonly()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->object_mono->set_readonly(false);
$this->assertFalse($this->object_mono->is_readonly());
$this->object_mono->set_readonly(true);
$this->assertTrue($this->object_mono->is_readonly());
}
/**
* @todo Implement testSet_required().
*/
public function testSet_required()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->object_mono->set_required(false);
$this->assertFalse($this->object_mono->is_required());
$this->object_mono->set_required(true);
$this->assertTrue($this->object_mono->is_required());
}
public function testSet_business()
{
$this->object_mono->set_business(false);
$this->assertFalse($this->object_mono->isBusiness());
$this->object_mono->set_business(true);
$this->assertTrue($this->object_mono->isBusiness());
}
/**
* @todo Implement testSet_multi().
*/
public function testSet_multi()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->object_mono->set_multi(false);
$this->assertFalse($this->object_mono->is_multi());
$this->object_mono->set_multi(true);
$this->assertTrue($this->object_mono->is_multi());
}
/**
* @todo Implement testSet_report().
*/
public function testSet_report()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->object_mono->set_report(false);
$this->assertFalse($this->object_mono->is_report());
$this->object_mono->set_report(true);
$this->assertTrue($this->object_mono->is_report());
}
/**
* @todo Implement testSet_type().
*/
public function testSet_type()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->object_mono->set_type('date');
$this->assertEquals('date', $this->object_mono->get_type());
$this->object_mono->set_type('text');
$this->assertEquals('text', $this->object_mono->get_type());
}
/**
* @todo Implement testSet_tbranch().
*/
public function testSet_tbranch()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->object_mono->set_tbranch('newBranche');
$this->assertEquals('newBranche', $this->object_mono->get_tbranch());
$this->object_mono->set_tbranch(null);
$this->assertNull($this->object_mono->get_tbranch());
}
/**
* @todo Implement testSet_separator().
*/
public function testSet_separator()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->assertEquals('', $this->object_mono->get_separator());
$this->assertEquals(';', $this->object_multi->get_separator());
$this->object_mono->set_separator(';.:');
$this->object_multi->set_separator(';.:');
$this->assertEquals('', $this->object_mono->get_separator());
$this->assertEquals(';.:', $this->object_multi->get_separator());
$this->object_multi->set_separator('.:-');
$this->assertEquals('.:-;', $this->object_multi->get_separator());
}
/**
* @todo Implement testSet_thumbtitle().
*/
public function testSet_thumbtitle()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->object_mono->set_thumbtitle(true);
$this->assertTrue($this->object_mono->get_thumbtitle());
$this->object_mono->set_thumbtitle('fr');
$this->assertEquals('fr', $this->object_mono->get_thumbtitle());
$this->object_mono->set_thumbtitle(false);
$this->assertFalse($this->object_mono->get_thumbtitle());
}
/**
* @todo Implement testGet_thumbtitle().
*/
public function testGet_thumbtitle()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->assertNull($this->object_mono->get_thumbtitle());
$this->assertNull($this->object_multi->get_thumbtitle());
}
/**
* @todo Implement testGet_id().
*/
public function testGet_id()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->assertTrue(is_int($this->object_mono->get_id()));
$this->assertTrue(is_int($this->object_multi->get_id()));
}
/**
* @todo Implement testGet_type().
*/
public function testGet_type()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->assertEquals('string', $this->object_mono->get_type());
$this->assertEquals('string', $this->object_multi->get_type());
}
/**
* @todo Implement testGet_tbranch().
*/
public function testGet_tbranch()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->assertEquals('', $this->object_mono->get_tbranch());
$this->assertEquals('', $this->object_multi->get_tbranch());
}
/**
* @todo Implement testGet_separator().
*/
public function testGet_separator()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->assertEquals('', $this->object_mono->get_separator());
$this->assertEquals(';', $this->object_multi->get_separator());
}
/**
* @todo Implement testIs_indexable().
*/
public function testIs_indexable()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->assertTrue($this->object_mono->is_indexable());
$this->assertTrue($this->object_multi->is_indexable());
}
/**
* @todo Implement testIs_readonly().
*/
public function testIs_readonly()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->assertFalse($this->object_mono->is_readonly());
$this->assertFalse($this->object_multi->is_readonly());
}
/**
* @todo Implement testIs_required().
*/
public function testIs_required()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->assertFalse($this->object_mono->is_required());
$this->assertFalse($this->object_multi->is_required());
}
/**
* @todo Implement testIs_multi().
*/
public function testIs_multi()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->assertFalse($this->object_mono->is_multi());
$this->assertTrue($this->object_multi->is_multi());
}
/**
* @todo Implement testIs_distinct().
*/
public function testIs_distinct()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @todo Implement testIs_report().
*/
public function testIs_report()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->assertTrue($this->object_mono->is_report());
$this->assertTrue($this->object_multi->is_report());
}
/**
* @todo Implement testGet_name().
*/
public function testGet_name()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->assertEquals(str_replace(' ', '', $this->name_mono), $this->object_mono->get_name());
$this->assertEquals(str_replace(' ', '', $this->name_multi), $this->object_multi->get_name());
}
/**
* @todo Implement testGet_metadata_source().
*/
public function testGet_metadata_source()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->assertEquals('', $this->object_mono->get_metadata_source());
$this->assertEquals('', $this->object_multi->get_metadata_source());
$source = '/rdf:RDF/rdf:Description/PHRASEANET:tf-filename';
$this->object_mono->set_source($source);
$this->object_multi->set_source($source);
$this->assertEquals($source, $this->object_mono->get_metadata_source());
$this->assertEquals($source, $this->object_multi->get_metadata_source());
}
/**
* @todo Implement testGet_metadata_namespace().
*/
public function testGet_metadata_namespace()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->assertEquals('NoSource', $this->object_mono->get_metadata_namespace());
$this->assertEquals('NoSource', $this->object_multi->get_metadata_namespace());
$source = '/rdf:RDF/rdf:Description/PHRASEANET:tf-filename';
$this->object_mono->set_source($source);
$this->object_multi->set_source($source);
$this->assertEquals('PHRASEANET', $this->object_mono->get_metadata_namespace());
$this->assertEquals('PHRASEANET', $this->object_multi->get_metadata_namespace());
}
/**
* @todo Implement testGet_metadata_tagname().
*/
public function testGet_metadata_tagname()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->assertEquals('NoSource', $this->object_mono->get_metadata_tagname());
$this->assertEquals('NoSource', $this->object_multi->get_metadata_tagname());
$source = '/rdf:RDF/rdf:Description/PHRASEANET:tf-filename';
$this->object_mono->set_source($source);
$this->object_multi->set_source($source);
$this->assertEquals('tf-filename', $this->object_mono->get_metadata_tagname());
$this->assertEquals('tf-filename', $this->object_multi->get_metadata_tagname());
}
/**
* @todo Implement testIs_on_error().
*/
public function testIs_on_error()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->assertFalse($this->object_mono->is_on_error());
$this->assertFalse($this->object_multi->is_on_error());
$meta = databox_fieldUnknown::get_instance(self::$record_1->get_databox(), 25);
$meta->set_name('A beautifull name');
$this->assertTrue($meta->is_on_error());
}
public function testRenameField()
{
$AddedValue = 'scalar value';
self::$record_1->set_metadatas(array(
array(
'meta_id' => null,
'meta_struct_id' => $this->object_mono->get_id(),
'value'=> $AddedValue
)
));
$this->object_mono->set_name('Bonobo yoyo')->save();
$value = array_pop(self::$record_1->get_caption()->get_field('Bonoboyoyo')->get_values());
$this->assertEquals($value->getValue(), $AddedValue);
}
public function testChangeMulti()
{
$AddedValue_1 = 'scalar value 1';
$AddedValue_2 = 'scalar value 2';
self::$record_1->set_metadatas(array(
array(
'meta_id' => null,
'meta_struct_id' => $this->object_multi->get_id(),
'value'=> $AddedValue_1
),
array(
'meta_id' => null,
'meta_struct_id' => $this->object_multi->get_id(),
'value'=> $AddedValue_2
)
));
$this->assertEquals(2, count(self::$record_1->get_caption()->get_field(str_replace(' ', '', $this->name_multi))->get_values()));
$this->object_multi->set_multi(false)->save();
$this->assertEquals(1, count(self::$record_1->get_caption()->get_field(str_replace(' ', '', $this->name_multi))->get_values()));
}
/**

View File

@@ -24,7 +24,7 @@ class module_console_schedulerStateTest extends PHPUnit_Framework_TestCase
$task_manager = new task_manager(appbox::get_instance(\bootstrap::getCore()));
$state = $task_manager->get_scheduler_state();
$sentence = sprintf('Scheduler is %s', $state['schedstatus']);
$sentence = sprintf('Scheduler is %s', $state['status']);
$this->assertTrue(strpos($commandTester->getDisplay(), $sentence) !== false);
}

View File

@@ -30,6 +30,18 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$metadatas = $system_file->extract_metadatas($databox->get_meta_structure());
static::$record_23->set_metadatas($metadatas['metadatas']);
/**
* Reset thumbtitle in order to have consistent tests (testGet_title)
*/
foreach(static::$record_1->get_databox()->get_meta_structure() as $databox_field)
{
/* @var $databox_field \databox_field */
$databox_field->set_thumbtitle(false)->save();
}
$system_file = new system_file(__DIR__ . '/../testfiles/cestlafete.jpg');
}
@@ -246,19 +258,6 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertTrue((static::$record_1->get_caption() instanceof caption_record));
}
public function testGet_xml()
{
$xml = self::$record_1->get_xml();
$sxe = simplexml_load_string($xml);
$this->assertInstanceOf('SimpleXMLElement', $sxe);
foreach (self::$record_1->get_caption()->get_fields() as $field)
{
$tagname = $field->get_name();
$this->assertEquals($field->get_serialized_values(), (string) $sxe->description->$tagname);
}
}
public function testGet_original_name()
{
$this->assertTrue(static::$record_1->get_original_name() === self::$record_sf_1->getFilename());
@@ -366,7 +365,13 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$metadatas[] = array(
'meta_struct_id' => $meta_el->get_id()
, 'meta_id' => $meta_id
, 'value' => 'un jeu de test'
, 'value' => 'un premier jeu de test'
);
$metadatas[] = array(
'meta_struct_id' => $meta_el->get_id()
, 'meta_id' => $meta_id
, 'value' => 'un second jeu de test'
);
}
}
@@ -409,7 +414,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertEquals($multi_imploded, $field->get_serialized_values());
}
else
$this->assertEquals('un jeu de test', $field->get_serialized_values());
$this->assertEquals('un second jeu de test', $field->get_serialized_values());
}
}

View File

@@ -113,7 +113,6 @@ class connexionReportTest extends PhraseanetPHPUnitAbstract
}
$result = $this->save_report->buildReport(false, 'user');
$this->reporttestResultWithChamp($result, $this->save_report->getChamps());
}

View File

@@ -54,7 +54,6 @@ class downloadReportTest extends PhraseanetPHPUnitAbstract
$this->manyCol($ret);
$ret = $this->report->colFilter('coll_id');
$this->manyCol($ret);
}
public function manyCol($ret)
@@ -95,8 +94,10 @@ class downloadReportTest extends PhraseanetPHPUnitAbstract
$result = $this->report->buildReport($conf);
$this->reporttestPage($result);
if (count($result['result']) > 0) $this->reporttestConf($conf);
if (count($result['result']) > 0) $this->reporttestResult($result, $conf);
if (count($result['result']) > 0)
$this->reporttestConf($conf);
if (count($result['result']) > 0)
$this->reporttestResult($result, $conf);
}
foreach ($this->ret as $sbasid => $collections)
@@ -111,9 +112,12 @@ class downloadReportTest extends PhraseanetPHPUnitAbstract
$this->ColFilter();
$result = $this->report->buildReport(false, 'fonction');
$this->reporttestPage($result);
if (count($result['result']) > 0) $this->reporttestConf($conf, 'fonction');
if (count($result['result']) > 0) $this->reporttestResult($result, $conf, 'fonction');
if (count($result['result']) > 0)
$this->reporttestConf($conf, 'fonction');
if (count($result['result']) > 0)
$this->reporttestResult($result, $conf, 'fonction');
}
foreach ($this->ret as $sbasid => $collections)
@@ -129,8 +133,10 @@ class downloadReportTest extends PhraseanetPHPUnitAbstract
$result = $this->report->buildReport(false, 'record_id', 'DOC');
$this->reporttestPage($result);
if (count($result['result']) > 0) $this->reporttestConf($conf, 'record_id');
if (count($result['result']) > 0) $this->reporttestResult($result, $conf, 'record_id');
if (count($result['result']) > 0)
$this->reporttestConf($conf, 'record_id');
if (count($result['result']) > 0)
$this->reporttestResult($result, $conf, 'record_id');
}
foreach ($this->ret as $sbasid => $collections)
@@ -146,8 +152,10 @@ class downloadReportTest extends PhraseanetPHPUnitAbstract
$result = $this->report->buildReport(false, 'user', 'DOC');
$this->reporttestPage($result);
if (count($result['result']) > 0) $this->reporttestConf($conf, 'user');
if (count($result['result']) > 0) $this->reporttestResult($result, $conf, 'user');
if (count($result['result']) > 0)
$this->reporttestConf($conf, 'user');
if (count($result['result']) > 0)
$this->reporttestResult($result, $conf, 'user');
}
}
@@ -157,14 +165,20 @@ class downloadReportTest extends PhraseanetPHPUnitAbstract
$nbPage = $this->report->getTotal() / $this->report->getNbRecord();
if ($this->report->getTotal() > $this->report->getNbRecord()) $this->assertTrue($report['display_nav']);
else $this->assertFalse($report['display_nav']);
if ($this->report->getTotal() > $this->report->getNbRecord())
$this->assertTrue($report['display_nav']);
else
$this->assertFalse($report['display_nav']);
if ($report['page'] == 1) $this->assertFalse($report['previous_page']);
else $this->assertEquals($report['page'] - 1, $report['previous_page']);
if ($report['page'] == 1)
$this->assertFalse($report['previous_page']);
else
$this->assertEquals($report['page'] - 1, $report['previous_page']);
if (intval(ceil($nbPage)) == $report['page'] || intval(ceil($nbPage)) == 0) $this->assertFalse($report['next_page']);
else $this->assertEquals($report['page'] + 1, $report['next_page']);
if (intval(ceil($nbPage)) == $report['page'] || intval(ceil($nbPage)) == 0)
$this->assertFalse($report['next_page']);
else
$this->assertEquals($report['page'] + 1, $report['next_page']);
}
public function reporttestConf($conf, $groupby = false)
@@ -174,7 +188,8 @@ class downloadReportTest extends PhraseanetPHPUnitAbstract
if ($groupby != 'record_id')
$this->assertEquals(count($this->report->getDisplay()), 2);
}
else $this->assertEquals(count($this->report->getDisplay()), count($conf));
else
$this->assertEquals(count($this->report->getDisplay()), count($conf));
if (!$groupby)
{
@@ -190,10 +205,14 @@ class downloadReportTest extends PhraseanetPHPUnitAbstract
$i = 0;
foreach ($colconf as $key => $value)
{
if ($i == 1) $this->assertEquals($conf[$col][$i], $value);
elseif ($i == 2) $this->assertEquals($conf[$col][$i], $value);
elseif ($i == 3) $this->assertEquals($conf[$col][$i], $value);
elseif ($i == 4) $this->assertEquals($conf[$col][$i], $value);
if ($i == 1)
$this->assertEquals($conf[$col][$i], $value);
elseif ($i == 2)
$this->assertEquals($conf[$col][$i], $value);
elseif ($i == 3)
$this->assertEquals($conf[$col][$i], $value);
elseif ($i == 4)
$this->assertEquals($conf[$col][$i], $value);
$i++;
}
}
@@ -202,7 +221,6 @@ class downloadReportTest extends PhraseanetPHPUnitAbstract
{
$this->assertArrayHasKey($groupby, $this->report->getDisplay());
}
}

View File

@@ -65,17 +65,10 @@ class reportTest extends PhraseanetPHPUnitAbstract
$this->report = new module_report($this->dmin, $this->dmax, $sbasid, $collections);
$this->report->setUser_id(self::$user->get_id());
$this->assertEquals($collections, $this->report->getListCollId());
$this->champ($this->report);
$this->host($this->report);
}
}
public function champ($report)
{
$chps = $report->getChamp($this->xml, 'report');
$this->assertEquals('hello',$chps);
}
public function host($report)
{
$host ='http://www.google.fr/search?q=helloworld&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:fr:official&client=firefox-a#pq=fake%20url%20constructor&hl=fr&sugexp=gsnos%2Cn%3D2&cp=8&gs_id=y&xhr=t&q=hello+world&pf=p&sclient=psy&client=firefox-a&hs=mIa&rls=org.mozilla:fr%3Aofficial&source=hp&pbx=1&oq=hello+wo&aq=0&aqi=g2&aql=t&gs_sm=&gs_upl=&bav=on.2,or.r_gc.r_pw.&fp=ab54cb1d4456efee&biw=1152&bih=712';
@@ -200,7 +193,7 @@ class reportTest extends PhraseanetPHPUnitAbstract
$report->expects($this->any())->method('buildReq')->will($this->returnValue(''));
$report->expects($this->any())->method('buildResult')->will($this->returnValue(array()));
$result = $report->buildReport(false, 'user');
$this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $report->getChamps());
// $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $report->getChamps());
}
}
}

View File

@@ -284,6 +284,9 @@
<th>
{% trans 'Afficher en titre' %}
</th>
<th>
{% trans 'Business Field' %}
</th>
</tr>
</thead>
<tbody>
@@ -361,6 +364,9 @@
{{_self.thumbtitle_selector(field.get_thumbtitle())}}
</select>
</td>
<td>
<input class="metafield_{{field.get_id()}}" {{disabled}} name="business_{{field.get_id()}}" type="checkbox" {% if field.isBusiness() %}checked="checked"{% endif %}/>
</td>
</tr>
{% endfor %}
</tbody>

View File

@@ -5,16 +5,18 @@
{% import 'common/caption_templates/overview.html' as cap_ovr %}
{% import 'common/caption_templates/preview.html' as cap_prev %}
{% set business = user.ACL().has_right_on_base(record.get_base_id(), 'canmodifrecord') %}
{% if view == 'answer' %}
{{cap_ans.format_caption(record, highlight|default(''), searchEngine|default(null))}}
{{cap_ans.format_caption(record, highlight|default(''), searchEngine|default(null), business)}}
{% elseif view == 'lazaret' %}
{{cap_laz.format_caption(record, highlight|default(''), searchEngine|default(null))}}
{{cap_laz.format_caption(record, highlight|default(''), searchEngine|default(null), business)}}
{% elseif view == 'preview' %}
{{cap_prev.format_caption(record, highlight|default(''), searchEngine|default(null))}}
{{cap_prev.format_caption(record, highlight|default(''), searchEngine|default(null), business)}}
{% elseif view == 'basket' %}
{{cap_bas.format_caption(record, highlight|default(''), searchEngine|default(null))}}
{{cap_bas.format_caption(record, highlight|default(''), searchEngine|default(null), business)}}
{% elseif view == 'overview' %}
{{cap_ovr.format_caption(record, highlight|default(''), searchEngine|default(null))}}
{{cap_ovr.format_caption(record, highlight|default(''), searchEngine|default(null), business)}}
{% elseif view == 'publi' %}
{{cap_pub.format_caption(record, '', null)}}
{{cap_pub.format_caption(record, '', null, business)}}
{% endif %}

View File

@@ -1,5 +1,5 @@
{% macro format_caption(record, highlight, searchEngine) %}
{% for name, value in record.get_caption().get_highlight_fields(highlight, null, searchEngine) %}
{% macro format_caption(record, highlight, searchEngine, includeBusiness) %}
{% for name, value in record.get_caption().get_highlight_fields(highlight, null, searchEngine, includeBusiness) %}
<div class="desc{% if loop.index is odd %}im{% endif %}pair"><b>{{name}}</b> : {{value.value|raw}}</div>
{% endfor %}
{% endmacro %}

View File

@@ -1,5 +1,5 @@
{% macro format_caption(record) %}
{% for name, value in record.get_caption().get_highlight_fields() %}
{% macro format_caption(record, highlight, searchEngine, includeBusiness) %}
{% for name, value in record.get_caption().get_highlight_fields(highlight, null, searchEngine, includeBusiness) %}
<div class="desc{% if loop.index is odd %}im{% endif %}pair"><b>{{name}}</b> : {{value.value|raw}}</div>
{% endfor %}
{% endmacro %}

View File

@@ -1,5 +1,5 @@
{% macro format_caption(record) %}
{% for name, value in record.get_caption().get_highlight_fields() %}
{% macro format_caption(record, highlight, searchEngine, includeBusiness) %}
{% for name, value in record.get_caption().get_highlight_fields(highlight, null, searchEngine, includeBusiness) %}
<div class="desc{% if loop.index is odd %}im{% endif %}pair"><b>{{name}}</b> : {{value.value|raw}}</div>
{% endfor %}
{% endmacro %}

View File

@@ -1,5 +1,5 @@
{% macro format_caption(record) %}
{% for name, value in record.get_caption().get_highlight_fields() %}
{% macro format_caption(record, highlight, searchEngine, includeBusiness) %}
{% for name, value in record.get_caption().get_highlight_fields(highlight, null, searchEngine, includeBusiness) %}
<div class="desc{% if loop.index is odd %}im{% endif %}pair"><b>{{name}}</b> : {{value.value|raw}}</div>
{% endfor %}
{% endmacro %}

View File

@@ -1,5 +1,5 @@
{% macro format_caption(record) %}
{% for name, value in record.get_caption().get_highlight_fields() %}
{% macro format_caption(record, highlight, searchEngine, includeBusiness) %}
{% for name, value in record.get_caption().get_highlight_fields(highlight, null, searchEngine, includeBusiness) %}
<div><b>{{name}}</b> : {{value.value|raw}}</div>
{% endfor %}
{% endmacro %}

View File

@@ -1,5 +1,5 @@
{% macro format_caption(record, highlight, searchEngine) %}
{% for name, value in record.get_caption().get_highlight_fields(highlight, null, searchEngine) %}
{% macro format_caption(record, highlight, searchEngine, includeBusiness) %}
{% for name, value in record.get_caption().get_highlight_fields(highlight, null, searchEngine, includeBusiness) %}
<div class="desc{% if loop.index is odd %}im{% endif %}pair"><b>{{name}}</b> : {{value.value|raw}}</div>
{% endfor %}
{% endmacro %}

View File

@@ -120,9 +120,8 @@
<input type="hidden" name="ssttid" value="{{ssttid}}"/>
{% for name, values in download.get_display_download() %}
{% if values.available > 0 %}
<div>
<input class="checkbox" type="checkbox" id="download_{{name}}" name="obj[]" value="{{name}}" />
<input class="checkbox {{values.class}}" type="checkbox" id="download_{{name}}" name="obj[]" value="{{name}}" />
<input type="hidden" name="download_{{name}}" value="{{values.size}}" />
<input type="hidden" name="count_{{name}}" value="{{values.available}}" />
<label for="download_{{name}}">{{values.label}} {% if values.total != values.available %}{{values.available}}/{{values.total}}{% endif %} ({{values.size|format_octets}})</label>
@@ -141,7 +140,13 @@
</div>
{% endif %}
{% endfor %}
{{ _self.choose_title('sendmail', choose_export_title, default_export_title) }}
{% if download.has_business_fields_access() %}
<div class="businessfields" style="margin-left:20px;display:none;">
<input type="checkbox" class="checkbox" name="businessfields" id="business_download" value="1" />
<label for="business_download">{% trans 'Include Business-fields in caption' %}</label>
</div>
{% endif %}
{{ _self.choose_title('download', choose_export_title, default_export_title) }}
<div class="buttons_line">
<button type="button" class="download_button">{% trans 'boutton::telecharger'%}</button>
<button type="button" class="close_button">{% trans 'boutton::annuler'%}</button>
@@ -178,7 +183,7 @@
{% for name, values in download.get_display_download() %}
{% if values.available > 0 %}
<div>
<input class="checkbox" type="checkbox" id="sendmail_{{name}}" name="obj[]" value="{{name}}" />
<input class="checkbox {{values.class}}" type="checkbox" id="sendmail_{{name}}" name="obj[]" value="{{name}}" />
<label for="sendmail_{{name}}"> {{values.label}} {% if values.total != values.available %}{{values.available}}/{{values.total}}{% endif %} ({{values.size|format_octets}})</label>
{% set title%}
{% trans 'Documents indisponibles' %}
@@ -196,7 +201,13 @@
{% endif %}
{% endfor %}
</div>
{{ _self.choose_title('download', choose_export_title, default_export_title) }}
{% if download.has_business_fields_access() %}
<div class="businessfields" style="margin-left:20px;display:none;">
<input type="checkbox" class="checkbox" name="businessfields" id="business_sendmail" value="1" />
<label for="business_sendmail">{% trans 'Include Business-fields in caption' %}</label>
</div>
{% endif %}
{{ _self.choose_title('sendmail', choose_export_title, default_export_title) }}
<div class="buttons_line">
<button type="button" class="sendmail_button">{% trans 'boutton::envoyer'%}</button>
<img class="sendmail_button_loader" src="/skins/icons/loader404040.gif" style="visibility:hidden;margin:0 5px;"/>
@@ -386,7 +397,7 @@
{% for name, values in download.get_display_ftp() %}
{% if values.available > 0 %}
<div>
<input class="checkbox" type="checkbox" id="ftp_{{name}}" name="obj[]" value="{{name}}" />
<input class="checkbox {{values.class}}" type="checkbox" id="ftp_{{name}}" name="obj[]" value="{{name}}" />
<label for="ftp_{{name}}"> {{values.label}} {% if values.total != values.available %}{{values.available}}/{{values.total}}{% endif %} ({{values.size|format_octets}}))</label>
{% set title%}
{% trans 'Documents indisponibles' %}
@@ -404,6 +415,12 @@
{% endif %}
{% endfor %}
</div>
{% if download.has_business_fields_access() %}
<div class="businessfields" style="margin-left:20px;display:none;">
<input type="checkbox" class="checkbox" name="businessfields" id="business_ftp" value="1" />
<label for="business_ftp">{% trans 'Include Business-fields in caption' %}</label>
</div>
{% endif %}
<div class="buttons_line">
<button type="button" class="tryftp_button">{% trans 'boutton::essayer'%}</button>
<img class="tryftp_button_loader" src="/skins/icons/loader404040.gif" style="visibility:hidden;margin:0 5px;"/>
@@ -608,6 +625,20 @@
return false;
});
$('input[name="obj[]"]', $('#download, #sendmail, #ftp')).bind('change', function(){
var $form = $(this).closest('form');
if($('input.caption[name="obj[]"]:checked', $form).length > 0)
{
$('div.businessfields', $form).show();
}
else
{
$('div.businessfields', $form).hide();
}
});
});
</script>
</div>

View File

@@ -1,6 +1,10 @@
{% macro format(thumbnail, b_w, b_h, extraclass, session, wrap)%}
{% set record_type = thumbnail.get_type() %}
{% set b_width = b_w %}
{% set b_height = b_h|default(b_w) %}
{% if record_type == 'AUDIO_MP3' %}
{% set d_width = 320 %}
@@ -13,9 +17,6 @@
{% set top = 0 %}
{% else %}
{% set b_width = b_w %}
{% set b_height = b_h|default(b_w) %}
{% set b_ratio = b_width / b_height %}
{% set i_ratio = thumbnail.get_width() / thumbnail.get_height() %}

View File

@@ -85,8 +85,9 @@
<div class="right_column_wrapper right_column_wrapper_caption left unselectable" style="width:230px;height:auto;">
<div id="record_infos">
<div class="container">
{% set business = user.ACL().has_right_on_base(first_item.get_record().get_base_id(), 'canmodifrecord') %}
{% if first_item %}
{{caption.format_caption(first_item.get_record())}}
{{caption.format_caption(first_item.get_record(), '', null, business)}}
{% endif %}
</div>
</div>

View File

@@ -95,8 +95,9 @@
<div class="right_column_wrapper right_column_wrapper_caption left unselectable" style="width:230px;height:auto;{% if basket.getValidation() %}display:none;{% endif %}">
<div id="record_infos">
<div class="container">
{% set business = user.ACL().has_right_on_base(basket_element.getRecord().get_base_id(), 'canmodifrecord') %}
{% if basket_element %}
{{caption.format_caption(basket_element.getRecord())}}
{{caption.format_caption(basket_element.getRecord(), '', null, business)}}
{% endif %}
</div>
</div>

View File

@@ -80,8 +80,9 @@
<div class="right_column_wrapper caption right_column_wrapper_caption PNB">
<div id="record_infos" class="PNB">
<div class="container PNB">
{% set business = user.ACL().has_right_on_base(first_item.get_record().get_base_id(), 'canmodifrecord') %}
{% if first_item %}
{{caption.format_caption(first_item.get_record())}}
{{caption.format_caption(first_item.get_record(), '', null, business)}}
{% endif %}
</div>
</div>

View File

@@ -93,8 +93,9 @@
<div class="right_column_wrapper caption right_column_wrapper_caption PNB" style="{% if basket.getValidation() %}display:none;{% endif %}">
<div id="record_infos" class="PNB">
<div class="container PNB">
{% set business = user.ACL().has_right_on_base(basket_element.getRecord().get_base_id(), 'canmodifrecord') %}
{% if basket_element %}
{{caption.format_caption(basket_element.getRecord())}}
{{caption.format_caption(basket_element.getRecord(), '', null, business)}}
{% endif %}
</div>
</div>

View File

@@ -11,10 +11,11 @@
<div style="text-align:center;">
{{record.get_status_icons()|raw}}
</div>
{% set business = user.ACL().has_right_on_base(record.get_base_id(), 'canmodifrecord') %}
{% if record.is_from_reg() %}
{{caption.format_caption(record)}}
{{caption.format_caption(record, '', null, business)}}
{% else %}
{{caption.format_caption(record, highlight, searchEngine)}}
{{caption.format_caption(record, highlight, searchEngine, business)}}
{% endif %}
<hr style="margin:10px 0;"/>
{% include 'common/technical_datas.twig' %}

View File

@@ -19,7 +19,8 @@
<td valign="top">
<div class='desc' style='max-height:{{th_size+70}}px;overflow-y:auto;'>
<div class="fixeddesc">
{{caption.format_caption(record, highlight, searchEngine)}}
{% set business = user.ACL().has_right_on_base(record.get_base_id(), 'canmodifrecord') %}
{{caption.format_caption(record, highlight, searchEngine, business)}}
{% if user.getPrefs('technical_display') == 'group' %}<hr/>{{record.get_technical_infos|raw}}{% endif %}
</div>
</div>

View File

@@ -206,79 +206,11 @@ switch ($parm['action'])
$output = $ret->saveXML();
break;
/*
case 'PINGSCHEDULER':
$lockdir = $registry->get('GV_RootPath') . 'tmp/locks/';
$ret = new DOMDocument("1.0", "UTF-8");
$ret->standalone = true;
$ret->preserveWhiteSpace = false;
$root = $ret->appendChild($ret->createElement("result"));
$root->appendChild($ret->createCDATASection(var_export(array(), true)));
$h = "";
$dat = date("H:i:s");
$root->setAttribute('time', $dat);
$task_manager = new task_manager($appbox);
$scheduler_state = $task_manager->get_scheduler_state();
$schedstatus = $scheduler_state['schedstatus'];
$schedqdelay = $scheduler_state['schedqdelay'];
$schedpid = $scheduler_state['schedpid'];
$root->setAttribute('status', $schedstatus);
$root->setAttribute('qdelay', $schedqdelay);
$schedlock = fopen($lockfile = ($lockdir . 'scheduler.lock'), 'a+');
if (flock($schedlock, LOCK_SH | LOCK_NB) != true)
{
$root->setAttribute('locked', '1');
}
else
{
$root->setAttribute('locked', '0');
}
if ($schedpid > 0)
$root->setAttribute('pid', $schedpid);
else
$root->setAttribute('pid', '');
foreach ($task_manager->get_tasks() as $task)
{
$task_node = $root->appendChild($ret->createElement("task"));
$task_node->setAttribute('id', $task->get_task_id());
$task_node->setAttribute('status', $task->get_status());
$task_node->setAttribute('active', $task->is_active());
$task_node->setAttribute('crashed', $task->get_crash_counter());
$task_node->setAttribute('completed', $task->get_completed_percentage());
$task_node->setAttribute('runner', $task->get_runner());
if ($task->is_running())
{
$task_node->setAttribute('running', '1');
$task_node->setAttribute('pid', $task->get_pid());
}
else
{
$task_node->setAttribute('running', '0');
$task_node->setAttribute('pid', '');
}
}
$output = $ret->saveXML();
break;
*/
case 'PINGSCHEDULER_JS':
$ret = array('time'=> date("H:i:s") );
$task_manager = new task_manager($appbox);
$ret['scheduler'] = $task_manager->get_scheduler_state2();
$ret['scheduler'] = $task_manager->get_scheduler_state();
$ret['tasks'] = array();

View File

@@ -57,7 +57,7 @@ if($parm["act"] == "DELETETASK")
<head>
<link type="text/css" rel="stylesheet" href="/include/minify/f=skins/common/main.css,skins/admin/admincolor.css" />
<link rel="stylesheet" href="/include/minify/f=include/jslibs/jquery.contextmenu.css,include/jslibs/jquery-ui-1.8.12/css/ui-lightness/jquery-ui-1.8.12.custom.css" type="text/css" media="screen" />
<link rel="stylesheet" href="/include/minify/f=include/jslibs/jquery.contextmenu.css,include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css" type="text/css" media="screen" />
<style>
.divTop
{
@@ -69,35 +69,6 @@ if($parm["act"] == "DELETETASK")
text-align:center;
table-layout: fixed;
}
table.task_manager {
border: 1px solid #e0e0e0;
border-collapse: collapse;
table-layout: fixed;
}
table.task_manager tr {
height:auto;
}
table.task_manager th, table.task_manager td {
height:auto;
padding: 2px;
margin: 0px;
border: 1px solid #e0e0e0;
padding-left: 5px;
padding-right: 5px;
}
table.db_processlist {
border: 1px solid #e0e0e0;
border-collapse: collapse;
table-layout: fixed;
}
table.db_processlist th, table.db_processlist td {
height:auto;
padding: 2px;
margin: 0px;
border: 1px solid #e0e0e0;
padding-left: 5px;
padding-right: 5px;
}
</style>
<link rel="stylesheet" href="/include/minify/f=include/jslibs/jquery.contextmenu.css,include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css" type="text/css" media="screen" />
<script type="text/javascript" src="/include/minify/f=include/jslibs/jquery-1.7.1.js,include/jslibs/jquery-ui-1.8.17/jquery-ui-i18n.js,include/jslibs/jquery.contextmenu.js"></script>

View File

@@ -91,11 +91,30 @@ $mod_xy = $mod_col * $mod_row;
$tbases = array();
$options = new searchEngine_options();
$parm['bas'] = is_array($parm['bas']) ? $parm['bas'] : array_keys($user->ACL()->get_granted_base());
/* @var $user \User_Adapter */
if ($user->ACL()->has_right('modifyrecord'))
{
$options->set_business_fields(array());
$BF = array();
foreach ($user->ACL()->get_granted_base(array('canmodifrecord')) as $collection)
{
if (count($parm['bas']) === 0 || in_array($collection->get_base_id(), $parm['bas']))
{
$BF[] = $collection->get_base_id();
}
}
$options->set_business_fields($BF);
}
else
{
$options->set_business_fields(array());
}
$options->set_bases($parm['bas'], $user->ACL());
if ( ! is_array($parm['infield']))

View File

@@ -28,7 +28,7 @@ $gatekeeper->require_session();
$request = http_request::getInstance();
$parm = $request->get_parms("lst", "obj", "ssttid", "type");
$parm = $request->get_parms("lst", "obj", "ssttid", "type", "businessfields");
$download = new set_export($parm['lst'], $parm['ssttid']);
@@ -37,7 +37,7 @@ if ($parm["type"] == "title")
else
$titre=false;
$list = $download->prepare_export($parm['obj'], $titre);
$list = $download->prepare_export($parm['obj'], $titre, $parm['businessfields']);
$exportname = "Export_" . date("Y-n-d") . '_' . mt_rand(100, 999);

View File

@@ -54,7 +54,7 @@ if ($Request->get("ssttid", "") != "")
$download = new set_export($Request->get('lst', ''), $Request->get('ssttid', ''));
$list = $download->prepare_export($Request->get('obj'), $titre);
$list = $download->prepare_export($Request->get('obj'), $titre, $Request->get('businessfields'));
$list['export_name'] = $exportname . '.zip';
$list['email'] = $Request->get("destmail", "");

View File

@@ -15,7 +15,6 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
/* @var $Core \Alchemy\Phrasea\Core */
$Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance($Core);
@@ -42,8 +41,33 @@ switch ($action)
$options = new searchEngine_options();
$parm['bas'] = is_array($parm['bas']) ? $parm['bas'] : array_keys($user->ACL()->get_granted_base());
/* @var $user \User_Adapter */
if ($user->ACL()->has_right('modifyrecord'))
{
$options->set_business_fields(array());
$BF = array();
foreach ($user->ACL()->get_granted_base(array('canmodifrecord')) as $collection)
{
if (count($params['bases']) === 0 || in_array($collection->get_base_id(), $params['bases']))
{
$BF[] = $collection->get_base_id();
}
}
$options->set_business_fields($BF);
}
else
{
$options->set_business_fields(array());
}
$options->set_bases($parm['bas'], $user->ACL());
if (!is_array($parm['fields']))
if ( !! is_array($parm['fields']))
$parm['fields'] = array();
$options->set_fields($parm['fields']);
if ( ! is_array($parm['status']))
@@ -56,11 +80,9 @@ switch ($action)
$options->set_date_fields(explode('|', $parm['datefield']));
$options->set_use_stemming($parm['stemme']);
$engine->set_options($options);
$result = $engine->results($parm['term'], 0, 1);
$res = $engine->get_suggestions($session, true);
// $res = array(array('id'=>'oui','label'=>'oui','value'=>'oui'));
$output = p4string::jsonencode($res);
break;
@@ -112,7 +134,7 @@ switch ($action)
case 'VIDEOTOKEN':
$parm = $request->get_parms('sbas_id', 'record_id');
$parm = $request->get_parms( ! 'sbas_id', 'record_id');
$sbas_id = (int) $parm['sbas_id'];
$record = new record_adapter($sbas_id, $parm['record_id']);
@@ -263,6 +285,7 @@ switch ($action)
, "namecaract"
, "NAMMKDFOLD"
, "logfile"
, "businessfields"
);
$download = new set_exportftp($parm['lst'], $parm['ssttid']);
@@ -275,10 +298,26 @@ switch ($action)
{
try
{
$download->prepare_export($parm['obj']);
$download->export_ftp($parm['usr_dest'], $parm['addr'], $parm['login'], $parm['pwd'], $parm['ssl'], $parm['nbretry'], $parm['passif'], $parm['destfolder'], $parm['NAMMKDFOLD'], $parm['logfile']);
$download->prepare_export($parm['obj'], false, $parm['businessfields']);
$download->export_ftp(
$parm['usr_dest']
, $parm['addr']
, $parm['login']
, $parm['pwd']
, $parm['ssl']
, $parm['nbretry']
, $parm['passif']
, $parm['destfolder']
, $parm['NAMMKDFOLD']
, $parm['logfile']
);
$output = p4string::jsonencode(array('error' => false, 'message' => _('Export enregistre dans la file dattente')));
$out = array(
'error' => false
, 'message' => _('Export enregistre dans la file dattente')
);
$output = p4string::jsonencode($out);
}
catch (Exception $e)
{

4329
www/testextension3.php Normal file

File diff suppressed because it is too large Load Diff