Add timeline see BT#10658

ofaj
jmontoyaa 9 years ago
parent 7eb9af9053
commit 49271d84b3
  1. 2
      app/AppKernel.php
  2. 11
      app/Migrations/Schema/V111/Version20160330103045.php
  3. 10
      main/install/index.php
  4. 32
      src/Chamilo/TimelineBundle/ChamiloTimelineBundle.php
  5. 42
      src/Chamilo/TimelineBundle/Entity/Action.php
  6. 42
      src/Chamilo/TimelineBundle/Entity/ActionComponent.php
  7. 42
      src/Chamilo/TimelineBundle/Entity/Component.php
  8. 42
      src/Chamilo/TimelineBundle/Entity/Timeline.php
  9. 21
      src/Chamilo/TimelineBundle/Resources/config/doctrine/Action.orm.xml
  10. 21
      src/Chamilo/TimelineBundle/Resources/config/doctrine/ActionComponent.orm.xml
  11. 21
      src/Chamilo/TimelineBundle/Resources/config/doctrine/Component.orm.xml
  12. 21
      src/Chamilo/TimelineBundle/Resources/config/doctrine/Timeline.orm.xml
  13. 14
      src/Chamilo/TimelineBundle/Resources/config/serializer/Entity.Action.xml
  14. 14
      src/Chamilo/TimelineBundle/Resources/config/serializer/Entity.ActionComponent.xml
  15. 14
      src/Chamilo/TimelineBundle/Resources/config/serializer/Entity.Component.xml
  16. 14
      src/Chamilo/TimelineBundle/Resources/config/serializer/Entity.Timeline.xml
  17. 62
      src/Chamilo/TimelineBundle/Resources/views/Block/timeline.html.twig

@ -97,7 +97,7 @@ class AppKernel extends Kernel
new Chamilo\ThemeBundle\ChamiloThemeBundle(),
//new Chamilo\NotificationBundle\ChamiloNotificationBundle(),
new Chamilo\AdminBundle\ChamiloAdminBundle(),
//new Chamilo\TimelineBundle\ChamiloTimelineBundle(),
new Chamilo\TimelineBundle\ChamiloTimelineBundle(),
// Based in Sonata
new Chamilo\ClassificationBundle\ChamiloClassificationBundle(),

@ -96,6 +96,17 @@ class Version20160330103045 extends AbstractMigration
$this->addSql(
'ALTER TABLE media__gallery_media ADD CONSTRAINT FK_80D4C541EA9FDD75 FOREIGN KEY (media_id) REFERENCES media__media (id)'
);
$this->addSql("CREATE TABLE timeline__timeline (id INT AUTO_INCREMENT NOT NULL, action_id INT DEFAULT NULL, subject_id INT DEFAULT NULL, context VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, INDEX IDX_FFBC6AD59D32F035 (action_id), INDEX IDX_FFBC6AD523EDC87 (subject_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$this->addSql("CREATE TABLE timeline__component (id INT AUTO_INCREMENT NOT NULL, model VARCHAR(255) NOT NULL, identifier LONGTEXT NOT NULL COMMENT '(DC2Type:array)', hash VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_1B2F01CDD1B862B8 (hash), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$this->addSql("CREATE TABLE timeline__action (id INT AUTO_INCREMENT NOT NULL, verb VARCHAR(255) NOT NULL, status_current VARCHAR(255) NOT NULL, status_wanted VARCHAR(255) NOT NULL, duplicate_key VARCHAR(255) DEFAULT NULL, duplicate_priority INT DEFAULT NULL, created_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$this->addSql("CREATE TABLE timeline__action_component (id INT AUTO_INCREMENT NOT NULL, action_id INT DEFAULT NULL, component_id INT DEFAULT NULL, type VARCHAR(255) NOT NULL, text VARCHAR(255) DEFAULT NULL, INDEX IDX_6ACD1B169D32F035 (action_id), INDEX IDX_6ACD1B16E2ABAFFF (component_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$this->addSql("ALTER TABLE timeline__timeline ADD CONSTRAINT FK_FFBC6AD59D32F035 FOREIGN KEY (action_id) REFERENCES timeline__action (id);");
$this->addSql("ALTER TABLE timeline__timeline ADD CONSTRAINT FK_FFBC6AD523EDC87 FOREIGN KEY (subject_id) REFERENCES timeline__component (id) ON DELETE CASCADE;");
$this->addSql("ALTER TABLE timeline__action_component ADD CONSTRAINT FK_6ACD1B169D32F035 FOREIGN KEY (action_id) REFERENCES timeline__action (id) ON DELETE CASCADE;");
$this->addSql("ALTER TABLE timeline__action_component ADD CONSTRAINT FK_6ACD1B16E2ABAFFF FOREIGN KEY (component_id) REFERENCES timeline__component (id) ON DELETE CASCADE;");
$this->addSql("CREATE UNIQUE INDEX UNIQ_8D93D649A0D96FBF ON user (email_canonical);");
$this->addSql('DROP TABLE extra_field_saved_search');
$this->addSql('DROP INDEX user_sco_course_sv_stack ON track_stored_values_stack');
$this->addSql('ALTER TABLE session_rel_user ADD duration INT DEFAULT NULL');

@ -892,6 +892,16 @@ if (@$_POST['step2']) {
'ALTER TABLE media__gallery_media ADD CONSTRAINT FK_80D4C541EA9FDD75 FOREIGN KEY (media_id) REFERENCES media__media (id)'
);
$connection->executeQuery("CREATE TABLE timeline__timeline (id INT AUTO_INCREMENT NOT NULL, action_id INT DEFAULT NULL, subject_id INT DEFAULT NULL, context VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, INDEX IDX_FFBC6AD59D32F035 (action_id), INDEX IDX_FFBC6AD523EDC87 (subject_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$connection->executeQuery("CREATE TABLE timeline__component (id INT AUTO_INCREMENT NOT NULL, model VARCHAR(255) NOT NULL, identifier LONGTEXT NOT NULL COMMENT '(DC2Type:array)', hash VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_1B2F01CDD1B862B8 (hash), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$connection->executeQuery("CREATE TABLE timeline__action (id INT AUTO_INCREMENT NOT NULL, verb VARCHAR(255) NOT NULL, status_current VARCHAR(255) NOT NULL, status_wanted VARCHAR(255) NOT NULL, duplicate_key VARCHAR(255) DEFAULT NULL, duplicate_priority INT DEFAULT NULL, created_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$connection->executeQuery("CREATE TABLE timeline__action_component (id INT AUTO_INCREMENT NOT NULL, action_id INT DEFAULT NULL, component_id INT DEFAULT NULL, type VARCHAR(255) NOT NULL, text VARCHAR(255) DEFAULT NULL, INDEX IDX_6ACD1B169D32F035 (action_id), INDEX IDX_6ACD1B16E2ABAFFF (component_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$connection->executeQuery("ALTER TABLE timeline__timeline ADD CONSTRAINT FK_FFBC6AD59D32F035 FOREIGN KEY (action_id) REFERENCES timeline__action (id);");
$connection->executeQuery("ALTER TABLE timeline__timeline ADD CONSTRAINT FK_FFBC6AD523EDC87 FOREIGN KEY (subject_id) REFERENCES timeline__component (id) ON DELETE CASCADE;");
$connection->executeQuery("ALTER TABLE timeline__action_component ADD CONSTRAINT FK_6ACD1B169D32F035 FOREIGN KEY (action_id) REFERENCES timeline__action (id) ON DELETE CASCADE;");
$connection->executeQuery("ALTER TABLE timeline__action_component ADD CONSTRAINT FK_6ACD1B16E2ABAFFF FOREIGN KEY (component_id) REFERENCES timeline__component (id) ON DELETE CASCADE;");
$connection->executeQuery("CREATE UNIQUE INDEX UNIQ_8D93D649A0D96FBF ON user (email_canonical);");
$sysPath = api_get_path(SYS_PATH);
finishInstallation(

@ -0,0 +1,32 @@
<?php
/**
* This file is part of the <name> project.
*
* (c) <yourname> <youremail>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Chamilo\TimelineBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
/**
* This file has been generated by the EasyExtends bundle ( https://sonata-project.org/easy-extends )
*
* References :
* bundles : http://symfony.com/doc/current/book/bundles.html
*
* @author <yourname> <youremail>
*/
class ChamiloTimelineBundle extends Bundle
{
/**
* {@inheritdoc}
*/
public function getParent()
{
return 'SonataTimelineBundle';
}
}

@ -0,0 +1,42 @@
<?php
/**
* This file is part of the <name> project.
*
* (c) <yourname> <youremail>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Chamilo\TimelineBundle\Entity;
use Sonata\TimelineBundle\Entity\Action as BaseAction;
/**
* This file has been generated by the Sonata EasyExtends bundle.
*
* @link https://sonata-project.org/bundles/easy-extends
*
* References :
* working with object : http://www.doctrine-project.org/projects/orm/2.0/docs/reference/working-with-objects/en
*
* @author <yourname> <youremail>
*/
class Action extends BaseAction
{
/**
* @var int $id
*/
protected $id;
/**
* Get id
*
* @return int $id
*/
public function getId()
{
return $this->id;
}
}

@ -0,0 +1,42 @@
<?php
/**
* This file is part of the <name> project.
*
* (c) <yourname> <youremail>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Chamilo\TimelineBundle\Entity;
use Sonata\TimelineBundle\Entity\ActionComponent as BaseActionComponent;
/**
* This file has been generated by the Sonata EasyExtends bundle.
*
* @link https://sonata-project.org/bundles/easy-extends
*
* References :
* working with object : http://www.doctrine-project.org/projects/orm/2.0/docs/reference/working-with-objects/en
*
* @author <yourname> <youremail>
*/
class ActionComponent extends BaseActionComponent
{
/**
* @var int $id
*/
protected $id;
/**
* Get id
*
* @return int $id
*/
public function getId()
{
return $this->id;
}
}

@ -0,0 +1,42 @@
<?php
/**
* This file is part of the <name> project.
*
* (c) <yourname> <youremail>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Chamilo\TimelineBundle\Entity;
use Sonata\TimelineBundle\Entity\Component as BaseComponent;
/**
* This file has been generated by the Sonata EasyExtends bundle.
*
* @link https://sonata-project.org/bundles/easy-extends
*
* References :
* working with object : http://www.doctrine-project.org/projects/orm/2.0/docs/reference/working-with-objects/en
*
* @author <yourname> <youremail>
*/
class Component extends BaseComponent
{
/**
* @var int $id
*/
protected $id;
/**
* Get id
*
* @return int $id
*/
public function getId()
{
return $this->id;
}
}

@ -0,0 +1,42 @@
<?php
/**
* This file is part of the <name> project.
*
* (c) <yourname> <youremail>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Chamilo\TimelineBundle\Entity;
use Sonata\TimelineBundle\Entity\Timeline as BaseTimeline;
/**
* This file has been generated by the Sonata EasyExtends bundle.
*
* @link https://sonata-project.org/bundles/easy-extends
*
* References :
* working with object : http://www.doctrine-project.org/projects/orm/2.0/docs/reference/working-with-objects/en
*
* @author <yourname> <youremail>
*/
class Timeline extends BaseTimeline
{
/**
* @var int $id
*/
protected $id;
/**
* Get id
*
* @return int $id
*/
public function getId()
{
return $this->id;
}
}

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<!--
This file has been generated by the EasyExtends bundle ( https://sonata-project.org/easy-extends )
References :
xsd : https://github.com/doctrine/doctrine2/blob/master/doctrine-mapping.xsd
xml mapping : http://www.doctrine-project.org/projects/orm/2.0/docs/reference/xml-mapping/en
association mapping : http://www.doctrine-project.org/projects/orm/2.0/docs/reference/association-mapping/en
-->
<entity
name="Chamilo\TimelineBundle\Entity\Action"
table="timeline__action"
repository-class="Doctrine\ORM\EntityRepository">
<id name="id" type="integer" column="id">
<generator strategy="AUTO"/>
</id>
</entity>
</doctrine-mapping>

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<!--
This file has been generated by the EasyExtends bundle ( https://sonata-project.org/easy-extends )
References :
xsd : https://github.com/doctrine/doctrine2/blob/master/doctrine-mapping.xsd
xml mapping : http://www.doctrine-project.org/projects/orm/2.0/docs/reference/xml-mapping/en
association mapping : http://www.doctrine-project.org/projects/orm/2.0/docs/reference/association-mapping/en
-->
<entity
name="Chamilo\TimelineBundle\Entity\ActionComponent"
table="timeline__action_component"
repository-class="Doctrine\ORM\EntityRepository">
<id name="id" type="integer" column="id">
<generator strategy="AUTO"/>
</id>
</entity>
</doctrine-mapping>

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<!--
This file has been generated by the EasyExtends bundle ( https://sonata-project.org/easy-extends )
References :
xsd : https://github.com/doctrine/doctrine2/blob/master/doctrine-mapping.xsd
xml mapping : http://www.doctrine-project.org/projects/orm/2.0/docs/reference/xml-mapping/en
association mapping : http://www.doctrine-project.org/projects/orm/2.0/docs/reference/association-mapping/en
-->
<entity
name="Chamilo\TimelineBundle\Entity\Component"
table="timeline__component"
repository-class="Doctrine\ORM\EntityRepository">
<id name="id" type="integer" column="id">
<generator strategy="AUTO"/>
</id>
</entity>
</doctrine-mapping>

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<!--
This file has been generated by the EasyExtends bundle ( https://sonata-project.org/easy-extends )
References :
xsd : https://github.com/doctrine/doctrine2/blob/master/doctrine-mapping.xsd
xml mapping : http://www.doctrine-project.org/projects/orm/2.0/docs/reference/xml-mapping/en
association mapping : http://www.doctrine-project.org/projects/orm/2.0/docs/reference/association-mapping/en
-->
<entity
name="Chamilo\TimelineBundle\Entity\Timeline"
table="timeline__timeline"
repository-class="Doctrine\ORM\EntityRepository">
<id name="id" type="integer" column="id">
<generator strategy="AUTO"/>
</id>
</entity>
</doctrine-mapping>

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<serializer>
<!--
This file has been generated by the EasyExtends bundle ( https://sonata-project.org/bundles/easy-extends )
@author <yourname> <youremail>
-->
<class name="Chamilo\TimelineBundle\Entity\Action" exclusion-policy="all" xml-root-name="_action">
<property xml-attribute-map="true" name="id" type="integer" expose="true" since-version="1.0" groups="sonata_api_read,sonata_api_write,sonata_search" />
</class>
</serializer>

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<serializer>
<!--
This file has been generated by the EasyExtends bundle ( https://sonata-project.org/bundles/easy-extends )
@author <yourname> <youremail>
-->
<class name="Chamilo\TimelineBundle\Entity\ActionComponent" exclusion-policy="all" xml-root-name="_action_component">
<property xml-attribute-map="true" name="id" type="integer" expose="true" since-version="1.0" groups="sonata_api_read,sonata_api_write,sonata_search" />
</class>
</serializer>

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<serializer>
<!--
This file has been generated by the EasyExtends bundle ( https://sonata-project.org/bundles/easy-extends )
@author <yourname> <youremail>
-->
<class name="Chamilo\TimelineBundle\Entity\Component" exclusion-policy="all" xml-root-name="_component">
<property xml-attribute-map="true" name="id" type="integer" expose="true" since-version="1.0" groups="sonata_api_read,sonata_api_write,sonata_search" />
</class>
</serializer>

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<serializer>
<!--
This file has been generated by the EasyExtends bundle ( https://sonata-project.org/bundles/easy-extends )
@author <yourname> <youremail>
-->
<class name="Chamilo\TimelineBundle\Entity\Timeline" exclusion-policy="all" xml-root-name="_timeline">
<property xml-attribute-map="true" name="id" type="integer" expose="true" since-version="1.0" groups="sonata_api_read,sonata_api_write,sonata_search" />
</class>
</serializer>

@ -0,0 +1,62 @@
{% extends sonata_block.templates.block_base %}
{% block block %}
<div class="box box-primary">
{% if settings.title is not empty %}
<div class="box-header with-border">
<h4 class="box-title">
<i class="fa fa-clock-o fa-fw"></i> {{ settings.title }}
</h4>
</div>
{% endif %}
<div class="box-body">
<div class="row">
<div class="col-md-12">
<ul class="timeline">
{% for entry in entries %}
{% if currentDay is not defined or currentDay != entry.createdAt|format_date %}
{% set currentDay = entry.createdAt|format_date %}
<li class="time-label">
<span class="bg-red">{{ currentDay }}</span>
</li>
{% endif %}
{% set subject = entry.getComponent('subject') %}
{% set target = entry.getComponent('target') %}
{% set target_text_component = entry.getComponent('target_text') %}
{% if subject.data %}
{% set subject_text = sonata_timeline_generate_link(subject, entry) %}
{% else %}
{% set subject_text = '<abbr title="' ~ 'element_reference_deleted'|trans({'%reference%': target.hash}, "SonataTimelineBundle") ~ '">' ~ 'element_deleted'|trans({}, "SonataTimelineBundle") ~ '</abbr>' %}
{% endif %}
{% if target.data is defined and target.data is not empty %}
{% set target_text = sonata_timeline_generate_link(target, entry) %}
{% elseif target_text_component %}
{% set target_text = '<abbr title="' ~ 'element_deleted'|trans({}, "SonataTimelineBundle") ~ '">'~target_text_component~'</abbr>' %}
{% else %}
{% set target_text = '<abbr title="' ~ 'element_reference_deleted'|trans({'%reference%': target.hash}, "SonataTimelineBundle") ~ '">' ~ 'element_deleted'|trans({}, "SonataTimelineBundle") ~ '</abbr>' %}
{% endif %}
{% set verb = "actions."~entry.verb %}
{% set icon = "actions.icon."~entry.verb %}
<li>
<i class="{{ icon|trans({}, "SonataTimelineBundle") }}"></i>
<div class="timeline-item" style="background: #f3f4f5;">
<span class="time"><i class="fa fa-clock-o"></i> {{ entry.createdAt|format_time }}</span>
<div class="timeline-body" style="border-bottom: none;">{{ verb|trans({'%subject%': subject_text, '%target%': target_text}, "SonataTimelineBundle")|raw }}</div>
</div>
</li>
{% else %}
{{ 'no_action'|trans({}, "SonataTimelineBundle") }}
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
{% endblock %}
Loading…
Cancel
Save