Permalink
Browse files

Initial import.

  • Loading branch information...
1 parent b5bd4da commit 320ba7c02dcfc8dba1e0cf00255cf29d93a268db mgiagnoni committed Jun 26, 2010
Showing with 2,482 additions and 0 deletions.
  1. +12 −0 LICENSE
  2. +3 −0 README
  3. +52 −0 config/doctrine/schema.yml
  4. +33 −0 config/lyMediaManagerPluginConfiguration.class.php
  5. +7 −0 data/fixtures/fixtures.yml
  6. +20 −0 lib/filter/doctrine/PluginlyMediaAssetFormFilter.class.php
  7. +20 −0 lib/filter/doctrine/PluginlyMediaFolderFormFilter.class.php
  8. +99 −0 lib/form/doctrine/PluginlyMediaAssetForm.class.php
  9. +108 −0 lib/form/doctrine/PluginlyMediaFolderForm.class.php
  10. +38 −0 lib/helper/lyMediaHelper.php
  11. +263 −0 lib/lyMediaTools.class.php
  12. +78 −0 lib/model/doctrine/PluginlyMediaAsset.class.php
  13. +21 −0 lib/model/doctrine/PluginlyMediaAssetTable.class.php
  14. +80 −0 lib/model/doctrine/PluginlyMediaFolder.class.php
  15. +31 −0 lib/model/doctrine/PluginlyMediaFolderTable.class.php
  16. +49 −0 lib/routing/lyMediaManagerRouting.class.php
  17. +61 −0 lib/task/lyMediaCreateRootTask.class.php
  18. +58 −0 lib/validator/lyMediaValidatorAsset.class.php
  19. +43 −0 lib/validator/lyMediaValidatorFile.class.php
  20. +42 −0 lib/validator/lyMediaValidatorFilename.class.php
  21. +56 −0 lib/validator/lyMediaValidatorFolder.class.php
  22. +63 −0 lib/widget/sfWidgetFormLyMediaTinyMCE.class.php
  23. +23 −0 modules/lyMediaAsset/actions/actions.class.php
  24. +25 −0 modules/lyMediaAsset/config/generator.yml
  25. 0 modules/lyMediaAsset/i18n/.sf
  26. +85 −0 modules/lyMediaAsset/lib/BaselyMediaAssetActions.class.php
  27. +27 −0 modules/lyMediaAsset/lib/lyMediaAssetGeneratorConfiguration.class.php
  28. +32 −0 modules/lyMediaAsset/lib/lyMediaAssetGeneratorHelper.class.php
  29. +30 −0 modules/lyMediaAsset/templates/_asset_icon.php
  30. +4 −0 modules/lyMediaAsset/templates/_assets.php
  31. +15 −0 modules/lyMediaAsset/templates/_field_image.php
  32. +8 −0 modules/lyMediaAsset/templates/_field_path.php
  33. +18 −0 modules/lyMediaAsset/templates/_folder_icon.php
  34. +5 −0 modules/lyMediaAsset/templates/_folder_icon_up.php
  35. +12 −0 modules/lyMediaAsset/templates/_folder_menu.php
  36. +20 −0 modules/lyMediaAsset/templates/_folder_path.php
  37. +2 −0 modules/lyMediaAsset/templates/_list_actions.php
  38. +10 −0 modules/lyMediaAsset/templates/_popup_menu.php
  39. +5 −0 modules/lyMediaAsset/templates/_td_image.php
  40. +32 −0 modules/lyMediaAsset/templates/iconsSuccess.php
  41. +32 −0 modules/lyMediaAsset/templates/indexSuccess.php
  42. +24 −0 modules/lyMediaFolder/actions/actions.class.php
  43. +20 −0 modules/lyMediaFolder/config/generator.yml
  44. 0 modules/lyMediaFolder/i18n/.sf
  45. +54 −0 modules/lyMediaFolder/lib/BaselyMediaFolderActions.class.php
  46. +26 −0 modules/lyMediaFolder/lib/lyMediaFolderGeneratorConfiguration.class.php
  47. +32 −0 modules/lyMediaFolder/lib/lyMediaFolderGeneratorHelper.class.php
  48. +3 −0 modules/lyMediaFolder/templates/_assets.php
  49. +8 −0 modules/lyMediaFolder/templates/_field_path.php
  50. +46 −0 package.xml.tmpl
  51. +8 −0 test/bin/prove.php
  52. +24 −0 test/bootstrap/functional.php
  53. +32 −0 test/bootstrap/unit.php
  54. BIN test/data/assets/asset1.png
  55. BIN test/data/assets/asset2.png
  56. BIN test/data/assets/asset3.png
  57. BIN test/data/assets/asseta.png
  58. BIN test/data/assets/assetb.png
  59. BIN test/data/assets/assetc.png
  60. +28 −0 test/data/fixtures/fixtures.yml
  61. +228 −0 test/functional/lyMediaManagerActionsTest.php
  62. +160 −0 web/css/lymedia.css
  63. +48 −0 web/css/lymedia_popup.css
  64. BIN web/images/delete.png
  65. BIN web/images/edit.png
  66. BIN web/images/folder-open.png
  67. BIN web/images/folder.png
  68. BIN web/images/go-up.png
  69. BIN web/images/txt.png
  70. +45 −0 web/js/lymedia_tiny.js
  71. +74 −0 web/js/lymedia_tiny_popup.js
View
@@ -0,0 +1,12 @@
+Copyright (c) 2010 Massimo Giagnoni
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+lyMediamanagerPlugin is partially derivative work of sfAssetsLibraryPlugin (MIT license).
+
+Copyright (c) 2008 Ma Generation, Francois Zaninotto, Gabriele Santini, William Garcia
+
View
@@ -0,0 +1,3 @@
+The plugin offers a simple web interface to upload and manage images, documents and other media files directly from the backend of your symfony application. File upload and file browsing features can be easily integrated into the TinyMCE editor.
+
+lyMediaManagerPlugin is inspired to sfAssetsLibraryPlugin for Propel, but some of its features have not been ported yet while others have been reimplemented in a different way.
@@ -0,0 +1,52 @@
+lyMediaAsset:
+ actAs:
+ Timestampable: ~
+ columns:
+ id:
+ type: integer(4)
+ primary: true
+ autoincrement: true
+ folder_id:
+ type: integer(4)
+ notnull: true
+ filename:
+ type: string(255)
+ title:
+ type: string(255)
+ description:
+ type: clob
+ author:
+ type: string(255)
+ copyright:
+ type: string(100)
+ type:
+ type: string(80)
+ filesize:
+ type: integer(4)
+ relations:
+ Folder:
+ class: lyMediaFolder
+ local: folder_id
+ foreign: id
+ foreignAlias: Assets
+ onDelete: CASCADE
+
+lyMediaFolder:
+ actAs:
+ Timestampable: ~
+ NestedSet:
+ hasManyRoots: false
+ columns:
+ id:
+ type: integer(4)
+ primary: true
+ autoincrement: true
+ name:
+ type: string(255)
+ notnull: true
+ title:
+ type: string(255)
+ description:
+ type: clob
+ relative_path:
+ type: string(255)
@@ -0,0 +1,33 @@
+<?php
+/*
+ * This file is part of the lyMediaManagerPlugin package.
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * lyMediaManagerPlugin configuration.
+ *
+ * @package lyMediaManagerPlugin
+ * @subpackage config
+ * @copyright Copyright (C) 2010 Massimo Giagnoni.
+ * @license http://www.symfony-project.org/license MIT
+ * @version SVN: $Id$
+ */
+class lyMediaManagerPluginConfiguration extends sfPluginConfiguration
+{
+ const VERSION = '1.0.0-DEV';
+
+ /**
+ * @see sfPluginConfiguration
+ */
+ public function initialize()
+ {
+
+ if (in_array('lyMediaAsset', sfConfig::get('sf_enabled_modules', array())))
+ {
+ $this->dispatcher->connect('routing.load_configuration', array('lyMediaManagerRouting', 'addRouteForAdmin'));
+ }
+ }
+}
@@ -0,0 +1,7 @@
+lyMediaFolder:
+ root:
+ name: media
+ children: []
+
+
+
@@ -0,0 +1,20 @@
+<?php
+/*
+ * This file is part of the lyMediaManagerPlugin package.
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * lyMediaAsset filter class.
+ *
+ * @package lyMediaManagerPlugin
+ * @subpackage filter
+ * @copyright Copyright (C) 2010 Massimo Giagnoni.
+ * @license http://www.symfony-project.org/license MIT
+ * @version SVN: $Id$
+ */
+abstract class PluginlyMediaAssetFormFilter extends BaselyMediaAssetFormFilter
+{
+}
@@ -0,0 +1,20 @@
+<?php
+/*
+ * This file is part of the lyMediaManagerPlugin package.
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * lyMediaFolder filter class.
+ *
+ * @package lyMediaManagerPlugin
+ * @subpackage filter
+ * @copyright Copyright (C) 2010 Massimo Giagnoni.
+ * @license http://www.symfony-project.org/license MIT
+ * @version SVN: $Id$
+ */
+abstract class PluginlyMediaFolderFormFilter extends BaselyMediaFolderFormFilter
+{
+}
@@ -0,0 +1,99 @@
+<?php
+/*
+ * This file is part of the lyMediaManagerPlugin package.
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * lyMediaAsset form class.
+ *
+ * @package lyMediaManagerPlugin
+ * @subpackage form
+ * @copyright Copyright (C) 2010 Massimo Giagnoni.
+ * @license http://www.symfony-project.org/license MIT
+ * @version SVN: $Id$
+ */
+abstract class PluginlyMediaAssetForm extends BaselyMediaAssetForm
+{
+ public function setup()
+ {
+ parent::setup();
+
+ unset(
+ $this['type'],
+ $this['filesize'],
+ $this['created_at'],
+ $this['updated_at']
+ );
+
+ $this->widgetSchema['folder_id']->setOption('method','getIndentName');
+
+ if($this->isNew())
+ {
+ $this->widgetSchema['filename'] = new sfWidgetFormInputFile();
+ $this->validatorSchema['filename'] = new lyMediaValidatorFile(array(
+ 'required' => 'true',
+ 'path' => $this->getOption('upload_root') . sfConfig::get('app_lyMediaManager_media_root', 'media'),
+ 'mime_types' => lyMediaTools::getAllowedMimeTypes(),
+ 'allowed_extensions' => lyMediaTools::getAllowedExtensions()
+ ));
+
+ if($user = $this->getOption('user'))
+ {
+ if($user->getAttribute('view') == 'icons' && $user->getAttribute('folder_id'))
+ {
+ $this->setDefault('folder_id', $user->getAttribute('folder_id'));
+ }
+ }
+ }
+ else
+ {
+ $query= Doctrine_query::create()
+ ->from('lyMediaFolder')
+ ->where('id != ?', $this->getObject()->getFolder()->getId());
+ $this->widgetSchema['folder_id']->setOption('query', $query);
+ $this->widgetSchema['folder_id']->setOption('add_empty', 'Move to ...');
+
+ $this->widgetSchema['filename'] = new sfWidgetFormInput();
+ $this->validatorSchema['filename'] = new lyMediaValidatorFilename(array(
+ 'required' => true,
+ 'allowed_extensions' => lyMediaTools::getAllowedExtensions()
+ ));
+ }
+ $this->validatorSchema->setPostValidator(new lyMediaValidatorAsset());
+ }
+
+ protected function doBind(array $values)
+ {
+ if($this->isNew())
+ {
+ if($values['folder_id'])
+ {
+ $folder = Doctrine::getTable('lyMediaFolder')
+ ->find($values['folder_id']);
+ $this->validatorSchema['filename']
+ ->setOption('path', $this->getOption('upload_root') . $folder->getPath());
+ }
+ }
+ else
+ {
+ if(empty($values['folder_id']))
+ {
+ //Folder unchanged
+ $values['folder_id'] = $this->getObject()->getFolderId();
+ }
+ }
+ parent::doBind($values);
+ }
+
+ public function processValues($values)
+ {
+ if($this->isNew())
+ {
+ $values['type'] = $values['filename']->getType();
+ }
+ return parent::processValues($values);
+ }
+}
@@ -0,0 +1,108 @@
+<?php
+/*
+ * This file is part of the lyMediaManagerPlugin package.
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * lyMediaFolder form class.
+ *
+ * @package lyMediaManagerPlugin
+ * @subpackage form
+ * @copyright Copyright (C) 2010 Massimo Giagnoni.
+ * @license http://www.symfony-project.org/license MIT
+ * @version SVN: $Id$
+ */
+abstract class PluginlyMediaFolderForm extends BaselyMediaFolderForm
+{
+ public function setup()
+ {
+ parent::setup();
+
+ unset(
+ $this['relative_path'],
+ $this['lft'],
+ $this['rgt'],
+ $this['level'],
+ $this['created_at'],
+ $this['updated_at']
+ );
+
+ $query = Doctrine_Query::create()
+ ->from('lyMediaFolder f');
+
+ if(!$this->isNew())
+ {
+ $query->where('f.lft < ? OR f.rgt > ?', array(
+ $this->getObject()->getLft(),
+ $this->getObject()->getRgt()
+ ));
+ }
+
+ $this->widgetSchema['parent_id'] = new sfWidgetFormDoctrineChoice(array(
+ 'model' => 'lyMediaManagerFolder',
+ 'order_by' => array('lft', ''),
+ 'method' => 'getIndentName',
+ 'query' => $query
+ ));
+
+ if($this->isNew())
+ {
+ if($user = $this->getOption('user'))
+ {
+ if($user->getAttribute('view') == 'icons' && $user->getAttribute('folder_id'))
+ {
+ $this->setDefault('parent_id', $user->getAttribute('folder_id'));
+ }
+ }
+ }
+ else
+ {
+ $this->widgetSchema['parent_id']->setOption('add_empty', 'Move to ...');
+ }
+
+ $this->validatorSchema['parent_id'] = new sfValidatorDoctrineChoice(array(
+ 'required' => $this->isNew(),
+ 'model' => 'lyMediaFolder'
+ ));
+
+ $this->validatorSchema['name'] = new sfValidatorRegex(array(
+ 'required' => true,
+ 'must_match' => false,
+ 'pattern' => '#[^a-z0-9-_]#i'
+ ));
+
+ $this->validatorSchema->setPostValidator(new lyMediaValidatorFolder());
+ }
+
+ public function updateObject($values = null)
+ {
+ $object = parent::updateObject($values);
+ $node = $object->getNode();
+
+ if($parent_id = $this->getValue('parent_id'))
+ {
+ $parent = $object->getTable()
+ ->find($parent_id);
+
+ $object->changedParent($parent_id);
+ }
+
+ if($this->isNew())
+ {
+ $node->insertAsLastChildOf($parent);
+ }
+ else
+ {
+ if(!empty($parent_id) && $parent_id != $node->getParent()->getId())
+ {
+ //A new parent has been selected
+ $node->moveAsLastChildOf($parent);
+ }
+ }
+
+ return $object;
+ }
+}
Oops, something went wrong.

0 comments on commit 320ba7c

Please sign in to comment.