Transform thesaurus preset into doctrine Entity

This commit is contained in:
Nicolas Le Goff
2014-03-04 17:28:23 +01:00
parent 02f8357f18
commit 4af7dbddb1
12 changed files with 729 additions and 116 deletions

View File

@@ -358,82 +358,45 @@ class Xmlhttp implements ControllerProviderInterface
public function EditingPresetsJson(Application $app, Request $request) public function EditingPresetsJson(Application $app, Request $request)
{ {
$usr_id = $app['authentication']->getUser()->getId();
$ret = ['parm' => [ $ret = ['parm' => [
'act' => $request->get('act'), 'act' => $request->get('act'),
'sbas' => $request->get('sbas'), 'sbas' => $request->get('sbas'),
'presetid' => $request->get('presetid'), 'presetid' => $request->get('presetid'),
'title' => $request->get('title'), 'title' => $request->get('title'),
'f' => $request->get('f'), 'fields' => $request->get('fields'),
'debug' => $request->get('debug'), 'debug' => $request->get('debug'),
]]; ]];
switch ($request->get('act')) { switch ($request->get('act')) {
case 'DELETE': case 'DELETE':
$sql = 'DELETE FROM edit_presets if (null === $preset = $app['repo.presets']->find($id = $request->get('presetid'))) {
WHERE edit_preset_id = :editpresetid $app->abort(404, sprintf("Preset with id '%' could not be found", $id));
AND usr_id = :usr_id'; }
$app['manipulator.preset']->delete($preset);
$params = [ $ret['html'] = $this->getPresetHTMLList($app, $request->get('sbas'), $app['authentication']->getUser()->getId());
':editpresetid' => $request->get('presetid'),
':usr_id' => $usr_id
];
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$ret['html'] = $this->getPresetHTMLList($app, $request->get('sbas'), $usr_id);
break; break;
case 'SAVE': case 'SAVE':
$dom = new \DOMDocument('1.0', 'UTF-8'); $app['manipulator.preset']->create(
$dom->standalone = true; $app['authentication']->getUser(),
$dom->preserveWhiteSpace = false; $request->get('sbas'),
$dom->formatOutput = true; $request->get('title'),
$request->get('fields')
);
$xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><edit_preset>' . $request->get('f') . '</edit_preset>'; $ret['html'] = $this->getPresetHTMLList($app, $request->get('sbas'), $app['authentication']->getUser()->getId());
$dom->loadXML($xml);
$sql = 'INSERT INTO edit_presets
(creation_date, sbas_id, usr_id, title, xml)
VALUES
(NOW(), :sbas_id, :usr_id, :title, :presets)';
$params = [
':sbas_id' => $request->get('sbas'),
':usr_id' => $usr_id,
':title' => $request->get('title'),
':presets' => $dom->saveXML(),
];
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$ret['html'] = $this->getPresetHTMLList($app, $request->get('sbas'), $usr_id);
break; break;
case 'LIST': case 'LIST':
$ret['html'] = $this->getPresetHTMLList($app, $request->get('sbas'), $usr_id); $ret['html'] = $this->getPresetHTMLList($app, $request->get('sbas'), $app['authentication']->getUser()->getId());
break; break;
case "LOAD": case "LOAD":
$sql = 'SELECT edit_preset_id, creation_date, title, xml if (null === $preset = $app['repo.presets']->find($id = $request->get('presetid'))) {
FROM edit_presets $app->abort(404, sprintf("Preset with id '%' could not be found", $id));
WHERE edit_preset_id = :edit_preset_id'; }
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute([':edit_preset_id' => $request->get('presetid')]);
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
$fields = []; $fields = [];
if ($row && ($sx = @simplexml_load_string($row['xml']))) { foreach ($preset->getData() as $field) {
foreach ($sx->fields->children() as $fn => $fv) { $fields[$field['name']][] = $field['value'];
if (!array_key_exists($fn, $fields)) {
$fields[$fn] = [];
}
$fields[$fn][] = trim($fv);
}
} }
$ret['fields'] = $fields; $ret['fields'] = $fields;
@@ -443,45 +406,21 @@ class Xmlhttp implements ControllerProviderInterface
return $app->json($ret); return $app->json($ret);
} }
private function getPresetHTMLList(Application $app, $sbas_id, $usr_id) private function getPresetHTMLList(Application $app, $sbasId, User $user)
{ {
$conn = $app['phraseanet.appbox']->get_connection(); $data = [];
foreach ($app['repo.presets']->findBy(['user' => $user, 'sbasId' => $sbasId], ['creadted' => 'asc']) as $preset) {
$presetData = $fields = [];
array_walk($preset->getData(), function($field) use ($fields) {
$fields[$field['name']][] = $field['value'];
});
$presetData['id'] = $preset->getId();
$presetData['title'] = $preset->getTilte();
$presetData['fields'] = $fields;
$sql = 'SELECT edit_preset_id, creation_date, title, xml $data[] = $presetData;
FROM edit_presets
WHERE usr_id = :usr_id AND sbas_id = :sbas_id
ORDER BY creation_date ASC';
$stmt = $conn->prepare($sql);
$stmt->execute([
':sbas_id' => $sbas_id,
':usr_id' => $usr_id,
]);
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
$presets = [];
foreach ($rs as $row) {
$preset = [];
if (!($sx = @simplexml_load_string($row['xml']))) {
continue;
} }
$fields = []; return $app['twig']->render('thesaurus/presets.html.twig', ['presets' => $data]);
foreach ($sx->fields->children() as $fn => $fv) {
if (!array_key_exists($fn, $fields)) {
$t_desc[$fn] = trim($fv);
} else {
$t_desc[$fn] .= ' ; ' . trim($fv);
}
}
$preset['fields'] = $fields;
$preset['title'] = $row['title'];
$preset['id'] = $row['edit_preset_id'];
$presets[] = $preset;
}
return $app['twig']->render('thesaurus/presets.html.twig', ['presets' => $presets]);
} }
public function GetSynonymsXml(Application $app, Request $request) public function GetSynonymsXml(Application $app, Request $request)

View File

@@ -12,6 +12,7 @@
namespace Alchemy\Phrasea\Core\Provider; namespace Alchemy\Phrasea\Core\Provider;
use Alchemy\Phrasea\Model\Manipulator\ACLManipulator; use Alchemy\Phrasea\Model\Manipulator\ACLManipulator;
use Alchemy\Phrasea\Model\Manipulator\PresetManipulator;
use Alchemy\Phrasea\Model\Manipulator\RegistrationManipulator; use Alchemy\Phrasea\Model\Manipulator\RegistrationManipulator;
use Alchemy\Phrasea\Model\Manipulator\TaskManipulator; use Alchemy\Phrasea\Model\Manipulator\TaskManipulator;
use Alchemy\Phrasea\Model\Manipulator\TokenManipulator; use Alchemy\Phrasea\Model\Manipulator\TokenManipulator;
@@ -36,6 +37,10 @@ class ManipulatorServiceProvider implements ServiceProviderInterface
return new TokenManipulator($app['EM'], $app['random.medium'], $app['repo.tokens']); return new TokenManipulator($app['EM'], $app['random.medium'], $app['repo.tokens']);
}); });
$app['manipulator.preset'] = $app->share(function ($app) {
return new PresetManipulator($app['EM'], $app['repo.presets']);
});
$app['manipulator.acl'] = $app->share(function ($app) { $app['manipulator.acl'] = $app->share(function ($app) {
return new ACLManipulator($app['acl'], $app['phraseanet.appbox']); return new ACLManipulator($app['acl'], $app['phraseanet.appbox']);
}); });

View File

@@ -94,6 +94,9 @@ class RepositoriesServiceProvider implements ServiceProviderInterface
$app['repo.tokens'] = $app->share(function ($app) { $app['repo.tokens'] = $app->share(function ($app) {
return $app['EM']->getRepository('Phraseanet:Token'); return $app['EM']->getRepository('Phraseanet:Token');
}); });
$app['repo.presets'] = $app->share(function (PhraseaApplication $app) {
return $app['EM']->getRepository('Phraseanet:Preset');
});
} }
public function boot(Application $app) public function boot(Application $app)

View File

@@ -0,0 +1,166 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Model\Entities;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Table(name="Presets")
* @ORM\Entity(repositoryClass="Alchemy\Phrasea\Model\Repositories\PresetRepository")
*/
class Preset
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false)
**/
private $user;
/**
* @ORM\Column(type="integer", name="sbas_id")
*/
private $sbasId;
/**
* @ORM\Column(type="string", length=128)
*/
private $title;
/**
* @ORM\Column(type="text")
*/
private $data;
/**
* @Gedmo\Timestampable(on="create")
* @ORM\Column(type="datetime")
*/
private $created;
/**
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* @return User
*/
public function getUser()
{
return $this->user;
}
/**
* @param User $user
*
* @return UserQuery
*/
public function setUser(User $user)
{
$this->user = $user;
return $this;
}
/**
* @return string
*/
public function getSbasId()
{
return $this->sbasId;
}
/**
* @param $sbasId
*
* @return $this
*/
public function setSbasId($sbasId)
{
$this->sbasId = $sbasId;
return $this;
}
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @param $title
*
* @return $this
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* @param array $data
*
* @return $this
*/
public function setData(array $data)
{
$this->data = json_encode($data);
return $this;
}
/**
* @return array
*/
public function getData()
{
return (array) json_decode($this->data, true);
return $this;
}
/**
* @return \DateTime
*/
public function getCreated()
{
return $this->created;
}
/**
* @param \DateTime $created
*
* @return UserQuery
*/
public function setCreated(\DateTime $created)
{
$this->created = $created;
return $this;
}
}

View File

@@ -0,0 +1,54 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Model\Manipulator;
use Alchemy\Phrasea\Model\Entities\Preset;
use Alchemy\Phrasea\Model\Entities\User;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityRepository;
class PresetManipulator implements ManipulatorInterface
{
/** @var Objectmanager */
private $om;
/** @var TranslatorInterface */
private $translator;
/** @var EntityRepository */
private $repository;
public function __construct(ObjectManager $om, EntityRepository $repo)
{
$this->om = $om;
$this->repository = $repo;
}
public function create(User $user, $sbasId, $title, array $data)
{
$preset = new Preset();
$preset->setUser($user);
$preset->setTitle($title);
$preset->setData($data);
$preset->setSbasId($sbasId);
$this->om->persist($preset);
$this->om->flush();
return $preset;
}
public function delete(Preset $preset)
{
$this->om->remove($preset);
$this->om->flush();
}
}

View File

@@ -0,0 +1,18 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Model\Repositories;
use Doctrine\ORM\EntityRepository;
class PresetRepository extends EntityRepository
{
}

View File

@@ -0,0 +1,99 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Model\Entities\Preset;
use Gedmo\Timestampable\TimestampableListener;
class patch_390alpha16a extends patchAbstract
{
/** @var string */
private $release = '3.9.0-alpha.16';
/** @var array */
private $concern = [base::APPLICATION_BOX];
/**
* {@inheritdoc}
*/
public function get_release()
{
return $this->release;
}
/**
* {@inheritdoc}
*/
public function require_all_upgrades()
{
return false;
}
/**
* {@inheritdoc}
*/
public function concern()
{
return $this->concern;
}
/**
* {@inheritdoc}
*/
public function getDoctrineMigrations()
{
return [];
}
/**
* {@inheritdoc}
*/
public function apply(base $appbox, Application $app)
{
$sql = ' SELECT edit_preset_id, creation_date, title, xml
FROM edit_presets';
$em = $app['EM'];
$n = 0;
$em->getEventManager()->removeEventSubscriber(new TimestampableListener());
foreach ($app['phraseanet.appbox']->get_connection()->fetchAll($sql) as $row) {
if (null === $user = $this->loadUser($app['EM'], $row['usr_id'])) {
continue;
}
$preset = new Preset();
$preset->setUser($user);
$preset->setSbasId($row['sbas_id']);
$preset->setTitle($row['title']);
$fields = [];
if (false !== ($sx = @simplexml_load_string($row['xml']))) {
foreach ($sx->fields->children() as $name => $value) {
$fields[] = ['name' => $name, 'value' => $value];
}
}
$preset->setData($fields);
$em->persist($preset);
$n++;
if ($n % 20 === 0) {
$em->flush();
$em->clear();
}
}
$em->flush();
$em->clear();
$em->getEventManager()->addEventSubscriber(new TimestampableListener());
return true;
}
}

View File

@@ -6,8 +6,8 @@
<a class="delete" style="position:absolute;right:0px;" href="#">{{ 'boutton::supprimer'| trans }}</a> <a class="delete" style="position:absolute;right:0px;" href="#">{{ 'boutton::supprimer'| trans }}</a>
</h1> </h1>
<div> <div>
{% for name, field in preset['fields'] %} {% for name, fields in preset['fields'] %}
<p><b>{{ name }} : </b> {{ field }}</p> <p><b>{{ name }} : </b> {{ fields|join(';') }}</p>
{% endfor %} {% endfor %}
</div> </div>
</li> </li>

View File

@@ -32,6 +32,7 @@ class RepositoriesServiceProviderTest extends ServiceProviderTestCase
['Alchemy\Phrasea\Core\Provider\RepositoriesServiceProvider', 'repo.ftp-exports', 'Alchemy\Phrasea\Model\Repositories\FtpExportRepository'], ['Alchemy\Phrasea\Core\Provider\RepositoriesServiceProvider', 'repo.ftp-exports', 'Alchemy\Phrasea\Model\Repositories\FtpExportRepository'],
['Alchemy\Phrasea\Core\Provider\RepositoriesServiceProvider', 'repo.user-queries', 'Alchemy\Phrasea\Model\Repositories\UserQueryRepository'], ['Alchemy\Phrasea\Core\Provider\RepositoriesServiceProvider', 'repo.user-queries', 'Alchemy\Phrasea\Model\Repositories\UserQueryRepository'],
['Alchemy\Phrasea\Core\Provider\RepositoriesServiceProvider', 'repo.tokens', 'Alchemy\Phrasea\Model\Repositories\TokenRepository'], ['Alchemy\Phrasea\Core\Provider\RepositoriesServiceProvider', 'repo.tokens', 'Alchemy\Phrasea\Model\Repositories\TokenRepository'],
['Alchemy\Phrasea\Core\Provider\RepositoriesServiceProvider', 'repo.presets', 'Alchemy\Phrasea\Model\Repositories\PresetRepository'],
]; ];
} }
} }

View File

@@ -0,0 +1,34 @@
<?php
namespace Alchemy\Tests\Phrasea\Model\Manipulator;
use Alchemy\Phrasea\Model\Manipulator\PresetManipulator;
class PresetManipulatorTest extends \PhraseanetTestCase
{
public function testCreate()
{
$manipulator = new PresetManipulator(self::$DI['app']['EM'], self::$DI['app']['repo.presets']);
$this->assertCount(0, self::$DI['app']['repo.presets']->findAll());
$fields = [
['name' => 'titi', 'value' => 'titi_value'], ['name' => 'tutu', 'value' => 'tutu_value'],
['name' => 'titi', 'value' => 'titi2_value'], ['name' => 'tutu', 'value' => 'tutu2_value'],
];
$title = 'title';
$preset = $manipulator->create(self::$DI['user'], self::$DI['collection']->get_sbas_id(), $title, $fields);
$this->assertEquals($title, $preset->getTitle());
$this->assertEquals($fields, $preset->getData());
$this->assertEquals(self::$DI['collection']->get_sbas_id(), $preset->getSbasId());
$this->assertEquals(self::$DI['user']->getid(), $preset->getUser()->getId());
$this->assertCount(1, self::$DI['app']['repo.presets']->findAll());
}
public function testDelete()
{
$manipulator = new PresetManipulator(self::$DI['app']['EM'], self::$DI['app']['repo.presets']);
$preset = $manipulator->create(self::$DI['user'], self::$DI['collection']->get_sbas_id(), 'title', []);
$countBefore = count(self::$DI['app']['repo.presets']->findAll());
$manipulator->delete($preset);
$this->assertGreaterThan(count(self::$DI['app']['repo.presets']->findAll()), $countBefore);
}
}

View File

@@ -0,0 +1,301 @@
<?php
namespace Alchemy\Phrasea\Model\Proxies\__CG__\Alchemy\Phrasea\Model\Entities;
/**
* DO NOT EDIT THIS FILE - IT WAS CREATED BY DOCTRINE'S PROXY GENERATOR
*/
class Preset extends \Alchemy\Phrasea\Model\Entities\Preset implements \Doctrine\ORM\Proxy\Proxy
{
/**
* @var \Closure the callback responsible for loading properties in the proxy object. This callback is called with
* three parameters, being respectively the proxy object to be initialized, the method that triggered the
* initialization process and an array of ordered parameters that were passed to that method.
*
* @see \Doctrine\Common\Persistence\Proxy::__setInitializer
*/
public $__initializer__;
/**
* @var \Closure the callback responsible of loading properties that need to be copied in the cloned object
*
* @see \Doctrine\Common\Persistence\Proxy::__setCloner
*/
public $__cloner__;
/**
* @var boolean flag indicating if this object was already initialized
*
* @see \Doctrine\Common\Persistence\Proxy::__isInitialized
*/
public $__isInitialized__ = false;
/**
* @var array properties to be lazy loaded, with keys being the property
* names and values being their default values
*
* @see \Doctrine\Common\Persistence\Proxy::__getLazyProperties
*/
public static $lazyPropertiesDefaults = array();
/**
* @param \Closure $initializer
* @param \Closure $cloner
*/
public function __construct($initializer = null, $cloner = null)
{
$this->__initializer__ = $initializer;
$this->__cloner__ = $cloner;
}
/**
*
* @return array
*/
public function __sleep()
{
if ($this->__isInitialized__) {
return array('__isInitialized__', 'id', 'user', 'sbasId', 'title', 'data', 'created');
}
return array('__isInitialized__', 'id', 'user', 'sbasId', 'title', 'data', 'created');
}
/**
*
*/
public function __wakeup()
{
if ( ! $this->__isInitialized__) {
$this->__initializer__ = function (Preset $proxy) {
$proxy->__setInitializer(null);
$proxy->__setCloner(null);
$existingProperties = get_object_vars($proxy);
foreach ($proxy->__getLazyProperties() as $property => $defaultValue) {
if ( ! array_key_exists($property, $existingProperties)) {
$proxy->$property = $defaultValue;
}
}
};
}
}
/**
*
*/
public function __clone()
{
$this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', array());
}
/**
* Forces initialization of the proxy
*/
public function __load()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, '__load', array());
}
/**
* {@inheritDoc}
* @internal generated method: use only when explicitly handling proxy specific loading logic
*/
public function __isInitialized()
{
return $this->__isInitialized__;
}
/**
* {@inheritDoc}
* @internal generated method: use only when explicitly handling proxy specific loading logic
*/
public function __setInitialized($initialized)
{
$this->__isInitialized__ = $initialized;
}
/**
* {@inheritDoc}
* @internal generated method: use only when explicitly handling proxy specific loading logic
*/
public function __setInitializer(\Closure $initializer = null)
{
$this->__initializer__ = $initializer;
}
/**
* {@inheritDoc}
* @internal generated method: use only when explicitly handling proxy specific loading logic
*/
public function __getInitializer()
{
return $this->__initializer__;
}
/**
* {@inheritDoc}
* @internal generated method: use only when explicitly handling proxy specific loading logic
*/
public function __setCloner(\Closure $cloner = null)
{
$this->__cloner__ = $cloner;
}
/**
* {@inheritDoc}
* @internal generated method: use only when explicitly handling proxy specific cloning logic
*/
public function __getCloner()
{
return $this->__cloner__;
}
/**
* {@inheritDoc}
* @internal generated method: use only when explicitly handling proxy specific loading logic
* @static
*/
public function __getLazyProperties()
{
return self::$lazyPropertiesDefaults;
}
/**
* {@inheritDoc}
*/
public function getId()
{
if ($this->__isInitialized__ === false) {
return (int) parent::getId();
}
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array());
return parent::getId();
}
/**
* {@inheritDoc}
*/
public function getUser()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array());
return parent::getUser();
}
/**
* {@inheritDoc}
*/
public function setUser(\Alchemy\Phrasea\Model\Entities\User $user)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user));
return parent::setUser($user);
}
/**
* {@inheritDoc}
*/
public function getSbasId()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getSbasId', array());
return parent::getSbasId();
}
/**
* {@inheritDoc}
*/
public function setSbasId($sbasId)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setSbasId', array($sbasId));
return parent::setSbasId($sbasId);
}
/**
* {@inheritDoc}
*/
public function getTitle()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getTitle', array());
return parent::getTitle();
}
/**
* {@inheritDoc}
*/
public function setTitle($title)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setTitle', array($title));
return parent::setTitle($title);
}
/**
* {@inheritDoc}
*/
public function setData(array $data)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setData', array($data));
return parent::setData($data);
}
/**
* {@inheritDoc}
*/
public function getData()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getData', array());
return parent::getData();
}
/**
* {@inheritDoc}
*/
public function getCreated()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getCreated', array());
return parent::getCreated();
}
/**
* {@inheritDoc}
*/
public function setCreated(\DateTime $created)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setCreated', array($created));
return parent::setCreated($created);
}
}

View File

@@ -1823,30 +1823,23 @@ function startThisEditing(sbas_id, what, regbasprid, ssel) {
"act": "SAVE", "act": "SAVE",
"sbas": p4.edit.sbas_id, "sbas": p4.edit.sbas_id,
"title": jtitle.val(), "title": jtitle.val(),
"f": {} "fields": []
}; };
var f = {};
var x = "<fields>";
$(":checkbox", form).each(
function (idx, elem) {
if (elem.checked) {
var i = 0 | elem.value;
var f;
if (p4.edit.T_fields[i].multi)
f = p4.edit.T_fields[i]._value.split(";");
else
f = [ p4.edit.T_fields[i]._value ];
for (j in f) {
x += "<" + p4.edit.T_fields[i].name + ">"
+ cleanTags(f[j])
+ "</" + p4.edit.T_fields[i].name + ">";
}
}
}
);
x += "</fields>"; $(":checkbox", form).each(function (idx, elem) {
p["f"] = x; var $el = $(elem);
if ($el.is(":checked")) {
var val = $el.val();
var field = {name: p4.edit.T_fields[val].name};
if (p4.edit.T_fields[val].multi) {
field.value = $.map(p4.edit.T_fields[i]._value.split(";"), cleanTags);
} else {
field.value = $.map([p4.edit.T_fields[i]._value], cleanTags);
}
p.fields.push(field);
}
});
$.ajax({ $.ajax({
type: 'POST', type: 'POST',