Permalink
Browse files

Init

  • Loading branch information...
0 parents commit 5f5129dd209520bf142e10407b510aafc7879839 @Sorien committed May 12, 2012
Showing with 4,808 additions and 0 deletions.
  1. +42 −0 DependencyInjection/Compiler/GridExtensionPass.php
  2. +26 −0 DependencyInjection/SorienDataGridExtension.php
  3. +85 −0 Form/GridTypeGuesser.php
  4. +26 −0 Grid/Action/DeleteMassAction.php
  5. +103 −0 Grid/Action/MassAction.php
  6. +36 −0 Grid/Action/MassActionInterface.php
  7. +189 −0 Grid/Action/RowAction.php
  8. +57 −0 Grid/Action/RowActionInterface.php
  9. +49 −0 Grid/Column/ActionsColumn.php
  10. +27 −0 Grid/Column/BlankColumn.php
  11. +40 −0 Grid/Column/BooleanColumn.php
  12. +495 −0 Grid/Column/Column.php
  13. +56 −0 Grid/Column/DateColumn.php
  14. +40 −0 Grid/Column/MassActionColumn.php
  15. +99 −0 Grid/Column/RangeColumn.php
  16. +62 −0 Grid/Column/SelectColumn.php
  17. +37 −0 Grid/Column/TextColumn.php
  18. +142 −0 Grid/Columns.php
  19. +60 −0 Grid/Filter.php
  20. +884 −0 Grid/Grid.php
  21. +118 −0 Grid/GridManager.php
  22. +32 −0 Grid/Helper/ColumnsIterator.php
  23. +30 −0 Grid/Mapping/Column.php
  24. +132 −0 Grid/Mapping/Driver/Annotation.php
  25. +19 −0 Grid/Mapping/Driver/DriverInterface.php
  26. +89 −0 Grid/Mapping/Metadata/Manager.php
  27. +91 −0 Grid/Mapping/Metadata/Metadata.php
  28. +42 −0 Grid/Mapping/Source.php
  29. +79 −0 Grid/Row.php
  30. +58 −0 Grid/Rows.php
  31. +279 −0 Grid/Source/Document.php
  32. +347 −0 Grid/Source/Entity.php
  33. +132 −0 Grid/Source/Source.php
  34. +75 −0 Resources/config/services.xml
  35. +19 −0 Resources/meta/LICENSE
  36. +55 −0 Resources/translations/messages.de.xliff
  37. +55 −0 Resources/translations/messages.fr.xliff
  38. +55 −0 Resources/translations/messages.sk.xliff
  39. +197 −0 Resources/views/blocks.html.twig
  40. +26 −0 SorienDataGridBundle.php
  41. +323 −0 Twig/DataGridExtension.php
@@ -0,0 +1,42 @@
+<?php
+
+/*
+ * This file is part of the DataGridBundle.
+ *
+ * (c) Stanislav Turza <sorien@mail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Sorien\DataGridBundle\DependencyInjection\Compiler;
+
+use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
+
+class GridExtensionPass implements CompilerPassInterface
+{
+ public function process(ContainerBuilder $container)
+ {
+ if (false === $container->hasDefinition('grid')) {
+ return;
+ }
+
+ $definition = $container->getDefinition('grid');
+
+ // Extensions must always be registered before everything else.
+ // For instance, global variable definitions must be registered
+ // afterward. If not, the globals from the extensions will never
+ // be registered.
+ $calls = $definition->getMethodCalls();
+ $definition->setMethodCalls(array());
+
+ foreach ($container->findTaggedServiceIds('grid.column.extension') as $id => $attributes)
+ {
+ $definition->addMethodCall('addColumnExtension', array(new Reference($id)));
+ }
+
+ $definition->setMethodCalls(array_merge($definition->getMethodCalls(), $calls));
+ }
+}
@@ -0,0 +1,26 @@
+<?php
+
+/*
+ * This file is part of the DataGridBundle.
+ *
+ * (c) Stanislav Turza <sorien@mail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Sorien\DataGridBundle\DependencyInjection;
+
+use Symfony\Component\HttpKernel\DependencyInjection\Extension;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\Config\FileLocator;
+
+class SorienDataGridExtension extends Extension
+{
+ public function load(array $config, ContainerBuilder $container)
+ {
+ $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
+ $loader->load('services.xml');
+ }
+}
@@ -0,0 +1,85 @@
+<?php
+
+/*
+ * This file is part of the DataGridBundle.
+ *
+ * (c) Stanislav Turza <sorien@mail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Sorien\DataGridBundle\Form;
+
+use Symfony\Component\Form\FormTypeGuesserInterface;
+use Symfony\Component\Form\Guess\Guess;
+use Symfony\Component\Form\Guess\TypeGuess;
+use Symfony\Component\Form\Guess\ValueGuess;
+
+class GridTypeGuesser implements FormTypeGuesserInterface
+{
+ /**
+ * @var \Sorien\DataGridBundle\Grid\Mapping\Metadata\Manager;
+ */
+ private $manager;
+
+ /**
+ * @var \Sorien\DataGridBundle\Grid\Mapping\Metadata\Metadata
+ */
+ private $metadata;
+
+ /**
+ * @param $manager
+ */
+ public function __construct($manager)
+ {
+ $this->manager = $manager;
+ }
+
+ public function guessType($class, $property)
+ {
+ $metadata = $this->manager->getMetadata($class);
+
+ if ($metadata->hasFieldMapping($property))
+ {
+ $params = $metadata->getFieldMapping($property);
+ switch ($metadata->getFieldMappingType($property))
+ {
+// case 'text':
+// if (isset($params['title']) && $params['title'] != '') // && strpos($params['id'], '.') === false
+// {
+// return new TypeGuess('text', array('label' => $params['title']), Guess::LOW_CONFIDENCE);
+// }
+// break;
+ case 'select':
+ if (!empty($params['values']))
+ {
+ return new TypeGuess('choice', array('choices' => $params['values']), Guess::HIGH_CONFIDENCE);
+ }
+ break;
+ case 'boolean':
+ return new TypeGuess('choice', array('choices' => array('1'=>'true','0'=>'false')), Guess::HIGH_CONFIDENCE);
+ break;
+ default:
+ return null;
+ }
+ }
+ }
+
+ public function guessRequired($class, $property)
+ {
+ }
+
+ public function guessMaxLength($class, $property)
+ {
+ }
+
+ public function guessMinLength($class, $property)
+ {
+ }
+
+ protected function isMappedClass($class)
+ {
+ return ;
+ }
+}
@@ -0,0 +1,26 @@
+<?php
+
+/*
+ * This file is part of the DataGridBundle.
+ *
+ * (c) Stanislav Turza <sorien@mail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Sorien\DataGridBundle\Grid\Action;
+
+class DeleteMassAction extends MassAction
+{
+ /**
+ * Default DeleteMassAction constructor
+ *
+ * @param boolean $confirm Show confirm message if true
+ * @return \Sorien\DataGridBundle\Grid\Action\MassAction
+ */
+ public function __construct($confirm = false)
+ {
+ parent::__construct('Delete', 'static::deleteAction', $confirm);
+ }
+}
@@ -0,0 +1,103 @@
+<?php
+
+/*
+ * This file is part of the DataGridBundle.
+ *
+ * (c) Stanislav Turza <sorien@mail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Sorien\DataGridBundle\Grid\Action;
+
+class MassAction implements MassActionInterface
+{
+ private $title;
+ private $callback;
+ private $confirm;
+
+ /**
+ * Default MassAction constructor
+ *
+ * @param string $title Title of the mass action
+ * @param string $callback Callback of the mass action
+ * @param boolean $confirm Show confirm message if true
+ * @return \Sorien\DataGridBundle\Grid\Action\MassAction
+ */
+ public function __construct($title, $callback = null, $confirm = false)
+ {
+ $this->title = $title;
+ $this->callback = $callback;
+ $this->confirm = $confirm;
+ }
+
+ /**
+ * Set action title
+ *
+ * @param $title
+ * @return \Sorien\DataGridBundle\Grid\Action\MassAction
+ */
+ public function setTitle($title)
+ {
+ $this->title = $title;
+
+ return $this;
+ }
+
+ /**
+ * get action title
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Set action callback
+ *
+ * @param $callback
+ * @return \Sorien\DataGridBundle\Grid\Action\MassAction
+ */
+ public function setCallback($callback)
+ {
+ $this->callback = $callback;
+
+ return $this;
+ }
+
+ /**
+ * get action callback
+ *
+ * @return string
+ */
+ public function getCallback()
+ {
+ return $this->callback;
+ }
+
+ /**
+ * Set action confirm
+ *
+ * @param $confirm
+ * @return \Sorien\DataGridBundle\Grid\Action\MassAction
+ */
+ public function setConfirm($confirm)
+ {
+ $this->confirm = $confirm;
+
+ return $this;
+ }
+
+ /**
+ * get action confirm
+ *
+ * @return boolean
+ */
+ public function getConfirm()
+ {
+ return $this->confirm;
+ }
+}
@@ -0,0 +1,36 @@
+<?php
+
+/*
+ * This file is part of the DataGridBundle.
+ *
+ * (c) Stanislav Turza <sorien@mail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Sorien\DataGridBundle\Grid\Action;
+
+interface MassActionInterface
+{
+ /**
+ * get action title
+ *
+ * @return string
+ */
+ public function getTitle();
+
+ /**
+ * get action callback
+ *
+ * @return string
+ */
+ public function getCallback();
+
+ /**
+ * get action confirm
+ *
+ * @return boolean
+ */
+ public function getConfirm();
+}
Oops, something went wrong.

0 comments on commit 5f5129d

Please sign in to comment.