SVN Alba r4546 - in prosistem/alba/trunk/alba/plugins: . sfMediaLibraryPlugin sfMediaLibraryPlugin/lib sfMediaLibraryPlugin/lib/helper sfMediaLibraryPlugin/modules sfMediaLibraryPlugin/modules/sfMediaLibrary sfMediaLibraryPlugin/modules/sfMediaLibrary/actions sfMediaLibraryPlugin/modules/sfMediaLibrary/config sfMediaLibraryPlugin/modules/sfMediaLibrary/i18n sfMediaLibraryPlugin/modules/sfMediaLibrary/lib sfMediaLibraryPlugin/modules/sfMediaLibrary/templates sfMediaLibraryPlugin/web sfMedia
Author: josx Date: 2007-04-18 12:22:07 -0300 (Wed, 18 Apr 2007) New Revision: 4546 Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/LICENSE prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/README prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/lib/ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/lib/helper/ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/lib/helper/sfMediaLibraryHelper.php prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/actions/ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/actions/actions.class.php prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/config/ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/config/view.yml prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/i18n/ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/i18n/sfMediaLibrary.fr.xml prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/lib/ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/lib/BasesfMediaLibraryActions.class.php prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/_block.php prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/_dirs.php prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/_files.php prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/choiceSuccess.php prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/indexSuccess.php prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/renameSuccess.php prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/css/ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/css/media.css prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/archive.png prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/bin.png prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/delete.png prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/doc.png prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/edit.png prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/filenew.png prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/folder.png prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/folder_new.png prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/folder_open.png prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/html.png prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/image.png prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/pdf.png prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/ppt.png prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/txt.png prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/unknown.png prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/up.png prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/xls.png prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/js/ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/js/main.js Log: Version 0.81 del plugin sfMediaLibrary Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/LICENSE =================================================================== --- prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/LICENSE 2007-04-18 15:20:37 UTC (rev 4545) +++ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/LICENSE 2007-04-18 15:22:07 UTC (rev 4546) @@ -0,0 +1,7 @@ +Copyright (c) 2004-2007 Fabien Potencier, Frederic Coelho, Fran�ois Zaninotto + +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. Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/README =================================================================== --- prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/README 2007-04-18 15:20:37 UTC (rev 4545) +++ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/README 2007-04-18 15:22:07 UTC (rev 4546) @@ -0,0 +1,125 @@ += sfMediaLibrary plugin = + +The `sfMediaLibraryPlugin` provides an easy-to-use interface to manage web assets (images, PDF documents, Flash objects, and so on). It also provides an extension to tinyMCE so that the media inclusion feature of rich text editors uses the assets uploaded through the plugin's module. + +This plug-in consists of: + + - one module + - one helper group + - one JavaScript script + +== Installation == + +To install the plugin for a symfony project, the usual process is to use the symfony command line: +{{{ +$ php symfony plugin-install http://plugins.symfony-project.com/sfMediaLibraryPlugin +}}} + +Alternatively, if you don't have PEAR installed, you can download the latest package attached to this plugin's wiki page and extract it under your project's `plugins/` directory. You will also have to copy the contents of the `myproject/plugins/sfMediaLibraryPlugin/web/` directory into a `myproject/web/sfMediaLibraryPlugin/` directory. + +Enable the new module in your application, via the `settings.yml` file. +{{{ +// in myproject/apps/frontend/config/settings.yml +all: + .settings: + enabled_modules: [default, sfMediaLibrary] +}}} + +Clear the cache to enable the autoloading to find the new classes: +{{{ +$ php symfony cc +}}} + +Start using the new module by making a request to: + +{{{ +http://myproject/frontend_dev.php/sfMediaLibrary +}}} + +== The `sfMediaLibrary` module == + +The module allows for the upload, renaming and deletion of all types of files (image, pdf, spreadsheet, etc). Click on an asset name to rename it, click on the trashcan icon to delete it. + +You can create, rename and delete subdirectories as well, resulting in a real tree structure that will keep your media assets organized. + +The module is fully i18n'ed, and the plugin comes with English and French translations. + +Uploaded assets end up under the `myproject/web/uploads/assets/` directory. This means that when you want to include them in a template with, for instance, an `image_tag()`, you must use an absolute path, as follows: + +{{{ +<?php echo image_tag('/uploads/assets/path_to_asset.suffix') ?> +}}} + +== Using the media library with TinyMCE == + +If you want to use the sfMediaLibrary plugin as a replacement for tinyMCE's file browser for image insertion, you must first initiate the plugin with a helper in the template: + +{{{ +<?php use_helper('sfMediaLibrary') ?> +<?php echo init_media_library() ?> +}}} + +The next thing to do is to pass a special JavaScript callback function to the TinyMCE object at initialization. This is done with the `tinymce_options` option of the `textarea_tag()` helper: + +{{{ +<?php echo textarea_tag('content', '', array ( + 'rich' => true, + 'tinymce_options' => 'file_browser_callback:"sfMediaLibrary.fileBrowserCallBack"', + )); ?> +}}} + +That's it, the TinyMCE file browser is now the sfMediaLibrary's one. + +Tip: For use with an admin generated module, place the `init_media_library()` call in the `_edit_header.php` partial in the `templates/` directory of the module. To define the callback in a `generator.yml`, do as follows: + +{{{ +generator: + class: sfPropelAdminGenerator + param: + model_class: Post + theme: default + + edit: + fields: + content: { params: rich=true tinymce_options=\'file_browser_callback:"sfMediaLibrary.fileBrowserCallBack"\' } +}}} + +== Using the Media Library input_file helper == + +Traditionally, when an asset has to be referenced in a form, a file input is used (`<input type='file'>`). It allows the user to upload a file from his computer to the server, and this file can be further embedded in a rich text content. + +Using the sfMediaLibrary, you can change this control into some sort of file input that wouldn't refer to the client's computer, but to the media library itself, or, to put it differently, to the files located in `web/uploads/assets/`. The plugin comes with a special helper for that purpose, the `input_asset_tag()`. Use is just like a regular `input_tag()`: + +{{{ +<?php echo form_tag('foo/bar') ?> + <?php echo input_asset_tag('my_asset_field', '') ?> +</form> +}}} + +The input is not a real file input tag, meaning that the chosen asset file will not be posted woth the request. It is iseless anyway, since the file is already on the server. Instead, the action will be able to retrieve the asset file path relative to the web root, exactly what is needed to display it. + +Optionally, you can restrict the choice of possible assets in this input to images only, as follows: + +{{{ +<?php echo input_asset_tag('my_asset_field', '', array('images_only' => true)) ?> +}}} + +== TODO == + + * Add screenshots to the wiki description + * Use [wiki:sfThumbnailPlugin] when available + * Improve CSS and design + * Improve compatibility + * Allow to move an asset to another directory + * Make path clickable to go up in the tree structure + * More translations for the `sfMediaLibrary` module + +== Changelog == + +=== 2007-04-16 | 0.8.1 Beta === + + * francois: Fixed a conflict with URL rewriting rules making folder navigation impossible + +=== 2007-04-13 | 0.8.0 Beta === + + * francois: Initial release \ No newline at end of file Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/lib/helper/sfMediaLibraryHelper.php =================================================================== --- prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/lib/helper/sfMediaLibraryHelper.php 2007-04-18 15:20:37 UTC (rev 4545) +++ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/lib/helper/sfMediaLibraryHelper.php 2007-04-18 15:22:07 UTC (rev 4546) @@ -0,0 +1,56 @@ +<?php + +function init_media_library() +{ + sfContext::getInstance()->getResponse()->addJavascript('/sfMediaLibraryPlugin/js/main', 'last'); + $url = url_for('sfMediaLibrary/choice'); + $js = 'sfMediaLibrary.init(\''.$url.'\')'; + + return javascript_tag($js); +} + +function input_asset_tag($name, $value, $options = array()) +{ + use_helper('Javascript'); + + $type = 'all'; + if (isset($options['images_only'])) + { + $type = 'image'; + unset($options['images_only']); + } + + $form_name = 'this.previousSibling.previousSibling.form.name'; + if (isset($options['form_name'])) + { + $form_name = '\''.$options['form_name'].'\''; + unset($options['form_name']); + } + + $html = ''; + + if (is_file(sfConfig::get('sf_web_dir').$value)) + { + $ext = substr($value, strpos($value, '.') - strlen($value) + 1); + if (in_array($ext, array('png', 'jpg', 'gif'))) + { + $image_path = $value; + } + else + { + if (!is_file(sfConfig::get('sf_plugins_dir').'/sfMediaLibraryPlugin/web/images/'.$ext.'.png')) + { + $ext = 'unknown'; + } + $image_path = '/sfMediaLibraryPlugin/images/'.$ext; + } + $html .= link_to_function(image_tag($image_path, array('alt' => 'File', 'height' => '64')), "window.open('$value')"); + $html .= '<br />'; + } + + $html .= input_tag($name, $value, $options); + $html .= ' '.image_tag('/sfMediaLibraryPlugin/images/folder_open', array('alt' => __('Insert Image'), 'style' => 'cursor: pointer; vertical-align: middle', 'onclick' => 'sfMediaLibrary.openWindow({ form_name: '.$form_name.', field_name: \''.$name.'\', type: \''.$type.'\', scrollbars: \'yes\' })')); + $html .= init_media_library(); + + return $html; +} Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/lib/helper/sfMediaLibraryHelper.php ___________________________________________________________________ Name: svn:keywords + "Id Author URL Date Rev" Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/actions/actions.class.php =================================================================== --- prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/actions/actions.class.php 2007-04-18 15:20:37 UTC (rev 4545) +++ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/actions/actions.class.php 2007-04-18 15:22:07 UTC (rev 4546) @@ -0,0 +1,22 @@ +<?php + +/* + * This file is part of the symfony package. + * (c) 2004-2006 Fabien Potencier <[email protected]> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once(dirname(__FILE__).'/../lib/BasesfMediaLibraryActions.class.php'); + +/** + * + * @package symfony + * @subpackage plugin + * @author Fabien Potencier <[email protected]> + * @version SVN: $Id: actions.class.php 1949 2006-09-05 14:40:20Z fabien $ + */ +class sfMediaLibraryActions extends BasesfMediaLibraryActions +{ +} Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/actions/actions.class.php ___________________________________________________________________ Name: svn:keywords + "Id Author URL Date Rev" Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/config/view.yml =================================================================== --- prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/config/view.yml 2007-04-18 15:20:37 UTC (rev 4545) +++ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/config/view.yml 2007-04-18 15:22:07 UTC (rev 4546) @@ -0,0 +1,6 @@ +all: + stylesheets: [%SF_ADMIN_WEB_DIR%/main, /sfMediaLibraryPlugin/css/media] + +choiceSuccess: + has_layout: false + stylesheets: [-*, %SF_ADMIN_WEB_DIR%/main, /sfMediaLibraryPlugin/css/media] \ No newline at end of file Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/config/view.yml ___________________________________________________________________ Name: svn:keywords + "Id Author URL Date Rev" Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/i18n/sfMediaLibrary.fr.xml =================================================================== --- prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/i18n/sfMediaLibrary.fr.xml 2007-04-18 15:20:37 UTC (rev 4545) +++ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/i18n/sfMediaLibrary.fr.xml 2007-04-18 15:22:07 UTC (rev 4546) @@ -0,0 +1,63 @@ +<?xml version="1.0" ?> +<xliff version="1.0"> + <file orginal="global" source-language="en_US" datatype="plaintext" date="2004-12-28T18:10:19Z"> + <body> + <trans-unit id="1"> + <source>Add</source> + <target>Ajouter</target> + </trans-unit> + <trans-unit id="2"> + <source>Media library (%1%)</source> + <target>Médiathèque (%1%)</target> + </trans-unit> + <trans-unit id="3"> + <source>Add a file:</source> + <target>Ajouter un fichier</target> + </trans-unit> + <trans-unit id="4"> + <source>Create a dir:</source> + <target>Créer un répertoire</target> + </trans-unit> + <trans-unit id="5"> + <source>Create</source> + <target>Créer</target> + </trans-unit> + <trans-unit id="6"> + <source>Rename in process...</source> + <target>Renommage en cours...</target> + </trans-unit> + <trans-unit id="7"> + <source>Cancel</source> + <target>Annuler</target> + </trans-unit> + <trans-unit id="8"> + <source>Delete</source> + <target>Supprimer</target> + </trans-unit> + <trans-unit id="9"> + <source>Click to edit</source> + <target>Cliquer pour editer</target> + </trans-unit> + <trans-unit id="10"> + <source>Are you sure to want to delete this folder?</source> + <target>Etes-vous sûr de vouloir supprimer ce répertoire ?</target> + </trans-unit> + <trans-unit id="11"> + <source>Are you sure to want to delete this file?</source> + <target>Etes-vous sûr de vouloir supprimer ce fichier ?</target> + </trans-unit> + <trans-unit id="12"> + <source>Rename</source> + <target>Renommer</target> + </trans-unit> + <trans-unit id="13"> + <source>Please choose a file first</source> + <target>Veuillez d\'abord sélectionner un fichier à charger</target> + </trans-unit> + <trans-unit id="14"> + <source>Please enter a directory name first</source> + <target>Veuillez d\'abord saisir un nom de répertoire</target> + </trans-unit> + </body> + </file> +</xliff> \ No newline at end of file Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/lib/BasesfMediaLibraryActions.class.php =================================================================== --- prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/lib/BasesfMediaLibraryActions.class.php 2007-04-18 15:20:37 UTC (rev 4545) +++ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/lib/BasesfMediaLibraryActions.class.php 2007-04-18 15:22:07 UTC (rev 4546) @@ -0,0 +1,195 @@ +<?php + +/* + * This file is part of the symfony package. + * (c) 2004-2006 Fabien Potencier <[email protected]> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * + * @package symfony + * @subpackage plugin + * @author Fabien Potencier <[email protected]> + * @version SVN: $Id: actions.class.php 1949 2006-09-05 14:40:20Z fabien $ + */ +class BasesfMediaLibraryActions extends sfActions +{ + public function executeIndex() + { + $currentDir = $this->dot2slash($this->getRequestParameter('dir')); + $this->currentDir = $this->getRequestParameter('dir'); + $this->current_dir_slash = $currentDir . '/'; + $this->webAbsCurrentDir = '/'.sfConfig::get('sf_upload_dir_name').'/assets'.$currentDir; + $this->absCurrentDir = sfConfig::get('sf_upload_dir').'/assets/'.$currentDir; + + $this->forward404Unless(is_dir($this->absCurrentDir)); + + $dirs = sfFinder::type('dir')->maxdepth(0)->prune('.*')->discard('.*')->relative()->in($this->absCurrentDir); + $files = sfFinder::type('file')->maxdepth(0)->prune('.*')->discard('.*')->relative()->in($this->absCurrentDir); + + sort($dirs); + sort($files); + + $this->dirs = $dirs; + + // compute some stats for each file + $infos = array(); + foreach ($files as $file) + { + $info = array(); + + $info['ext'] = substr($file, strpos($file, '.') - strlen($file) + 1); + if ($this->getRequestParameter('images_only') && !$this->isImage($info['ext'])) + { + continue; + } + $stats = stat($this->absCurrentDir.'/'.$file); + $info['size'] = $stats['size']; + $info['icon'] = $this->isImage($info['ext']) ? $this->webAbsCurrentDir.'/'.$file : (is_readable(sfConfig::get('sf_web_dir').'/sfMediaLibraryPlugin/images/'.$info['ext'].'.png') ? '/sfMediaLibraryPlugin/images/'.$info['ext'].'.png' : '/sfMediaLibraryPlugin/images/unknown.png'); + $infos[$file] = $info; + } + $this->files = $infos; + + // parent dir + $tmp = explode(' ', $this->currentDir); + array_pop($tmp); + $this->parentDir = implode(' ', $tmp); + } + + protected function isImage($ext) + { + return in_array($ext, array('png', 'jpg', 'gif')); + } + + public function executeChoice() + { + $this->executeIndex(); + } + + public function executeRename() + { + $current_path = $this->dot2slash($this->getRequestParameter('current_path')); + $this->current_path = $this->getRequestParameter('current_path'); + $type = $this->getRequestParameter('type'); + $this->count = $this->getRequestParameter('count'); + + $this->abs_current_path = sfConfig::get('sf_upload_dir').'/assets/'.$current_path; + $this->web_abs_current_path = '/'.sfConfig::get('sf_upload_dir_name').'/assets/'.$current_path; + + $name = $this->getRequestParameter('name'); + $new_name = $this->getRequestParameter('new_name'); + if ($type === 'folder') + { + $new_name = $this->sanitizeDir($new_name); + $this->forward404Unless(is_dir($this->abs_current_path.'/'.$name)); + } + else + { + $new_name = $this->sanitizeFile($new_name); + $this->forward404Unless(is_file($this->abs_current_path.'/'.$name)); + } + + @rename($this->abs_current_path.'/'.$name, $this->abs_current_path.'/'.$new_name); + + $this->info = array(); + if (is_dir($this->abs_current_path.'/'.$new_name) and ($type === 'folder')) + { + $this->name = $new_name; + } + else if (is_file($this->abs_current_path.'/'.$new_name) and ($type === 'file')) + { + $this->name = $new_name; + $this->getInfo($new_name); + } + else + { + $this->name = $name; + $this->getInfo($name); + } + $this->type = $type; + } + + protected function getInfo($filename) + { + $this->info['ext'] = substr($filename, strpos($filename, '.') - strlen($filename) + 1); + $stats = stat($this->abs_current_path.'/'.$filename); + $this->info['size'] = $stats['size']; + $this->info['icon'] = $this->isImage($this->info['ext']) ? $this->web_abs_current_path.'/'.$filename : (is_readable(sfConfig::get('sf_web_dir').'/sfMediaLibraryPlugin/images/'.$this->info['ext'].'.png') ? '/sfMediaLibraryPlugin/images/'.$this->info['ext'].'.png' : '/sfMediaLibraryPlugin/images/unknown.png'); + } + + public function executeUpload() + { + $currentDir = $this->dot2slash($this->getRequestParameter('current_dir')); + $webAbsCurrentDir = '/'.sfConfig::get('sf_upload_dir_name').'/assets/'.$currentDir; + $absCurrentDir = sfConfig::get('sf_upload_dir').'/assets/'.$currentDir; + + $this->forward404Unless(is_dir($absCurrentDir)); + + $fileName = $this->sanitizeFile($this->getRequest()->getFileName('file')); + + $this->getRequest()->moveFile('file', $absCurrentDir.'/'.$fileName); + + $this->redirect('sfMediaLibrary/index?dir='.$this->getRequestParameter('current_dir')); + } + + public function executeDelete() + { + $currentDir = $this->dot2slash($this->getRequestParameter('current_path')); + $currentFile = $this->getRequestParameter('name'); + $absCurrentFile = sfConfig::get('sf_upload_dir').'/assets/'.$currentDir.'/'.$currentFile; + + $this->forward404Unless(is_readable($absCurrentFile)); + + unlink($absCurrentFile); + + $this->redirect('sfMediaLibrary/index?dir='.$this->getRequestParameter('current_path')); + } + + public function executeMkdir() + { + $currentDir = $this->dot2slash($this->getRequestParameter('current_dir')); + $dirName = $this->sanitizeDir($this->getRequestParameter('name')); + $absCurrentDir = sfConfig::get('sf_upload_dir').'/assets/'.(empty($currentDir) ? '' : $currentDir.'/').$dirName; + + $old = umask(0000); + @mkdir($absCurrentDir, 0777); + umask($old); + + $this->redirect('sfMediaLibrary/index?dir='.$this->getRequestParameter('current_dir')); + } + + public function executeRmdir() + { + $currentDir = $this->dot2slash('.'.$this->getRequestParameter('current_path')); + $absCurrentDir = sfConfig::get('sf_upload_dir').'/assets/'.$currentDir.'/'.$this->getRequestParameter('name'); + + $this->forward404Unless(is_dir($absCurrentDir)); + + rmdir($absCurrentDir); + + $this->redirect('sfMediaLibrary/index?dir='.$this->getRequestParameter('current_path')); + } + + protected function dot2slash($txt) + { + return preg_replace('#[\+\s]+#', '/', $txt); + } + + protected function slash2dot($txt) + { + return preg_replace('#/+#', '+', $txt); + } + + protected function sanitizeDir($dir) + { + return preg_replace('/[^a-z0-9_-]/i', '_', $dir); + } + + protected function sanitizeFile($file) + { + return preg_replace('/[^a-z0-9_\.-]/i', '_', $file); + } +} Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/lib/BasesfMediaLibraryActions.class.php ___________________________________________________________________ Name: svn:keywords + "Id Author URL Date Rev" Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/_block.php =================================================================== --- prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/_block.php 2007-04-18 15:20:37 UTC (rev 4545) +++ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/_block.php 2007-04-18 15:22:07 UTC (rev 4546) @@ -0,0 +1,85 @@ +<?php if($sf_context->getActionName() !== 'choice'): ?> + <?php $action = 'index' ?> +<?php else: ?> + <?php $action = $sf_context->getActionName() ?> +<?php endif; ?> + +<div class="thumbnails"> +<?php if ($type === 'folder'): ?> + <?php echo link_to(image_tag('/sfMediaLibraryPlugin/images/folder', array( + 'alt' => $name, + 'title' => $name, + 'size' => '64x64', + )), 'sfMediaLibrary/'.$action.'?dir='.$current_path.'+'.$name) ?> + <?php if (($action !== "index") and $is_file): ?> + <?php $size = ' ' ?> + <?php else: ?> + <?php $size = '' ?> + <?php endif; ?> + <?php $delete = 'rmdir' ?> +<?php else: ?> + <?php if ($info['size'] < 4000): ?> + <?php $size2 = array() ?> + <?php else: ?> + <?php $size2 = array('height' => '64') ?> + <?php endif; ?> + <?php $thumbnail = image_tag($info['icon'], array( + 'alt' => $name, + 'title' => $name, + ) + $size2) ?> + <?php if($action === "index"): ?> + <?php echo content_tag('a', $thumbnail, array( + 'href' => $web_abs_current_path.'/'.$name, + 'target' => '_blank', + )) ?> + <?php else: ?> + <?php echo link_to_function($thumbnail, "setFileSrc('".$web_abs_current_path.'/'.$name."')") ?> + <?php endif; ?> + + <?php ob_start() ?> + <?php if ($info['size'] < 1000): ?> + [<?php printf('%d', $info['size']) ?> o] + <?php else: ?> + [<?php printf('%d', $info['size'] / 1000) ?> Ko] + <?php endif; ?> + <?php $size = ob_get_contents() ?> + <?php ob_end_clean() ?> + <?php $delete = 'delete' ?> +<?php endif; ?> +</div> +<div class="assetComment"> + <div id="view_<?php echo $count ?>"><?php echo ($action === "index") ? link_to_function($name, "Element.show('edit_".$count."');Element.hide('view_".$count."')") : $name ?></div> + <?php if($action === "index"): ?> + <div id="edit_<?php echo $count ?>"> + <?php echo form_tag('sfMediaLibrary/rename', 'name=sf_asset_rename_form') ?> + <?php echo input_hidden_tag('current_path', $current_path) ?> + <?php echo input_hidden_tag('name', $name) ?> + <?php echo input_hidden_tag('type', $type) ?> + <?php echo input_hidden_tag('count', $count) ?> + <?php echo input_tag('new_name', $name) ?> + <?php echo submit_to_remote('rename', __('Rename', null, 'sfMediaLibrary'), array( + 'url' => 'sfMediaLibrary/rename', + 'update' => 'block_'.$count, + 'script'=> true, + 'before' => visual_effect('opacity', 'block_'.$count, array('duration' => '0.5', 'from' => '1.0', 'to' => '0.3')), + 'complete' => visual_effect('opacity', 'block_'.$count, array('duration' => '0.5', 'from' => '0.3', 'to' => '1.0')), + ),'class=sf_asset_action_rename')?> + <?php echo button_to_function(__('Cancel', null, 'sfMediaLibrary'), "Element.hide('edit_".$count."');Element.show('view_".$count."')") ?> + </form> + </div> + <?php echo javascript_tag(" + Element.hide('edit_".$count."'); + ") ?> + <div style="text-align:right"> + <?php echo $size ?> + <?php echo link_to(image_tag('/sfMediaLibraryPlugin/images/delete.png', array( + 'alt' => __('Delete', null, 'sfMediaLibrary'), + 'title' => __('Delete', null, 'sfMediaLibrary'), + 'align' => 'absmiddle', + )), 'sfMediaLibrary/'.$delete.'?name='.$name.'¤t_path='.$current_path, array( + 'confirm' => __('Are you sure to want to delete this '.$type.'?', null, 'sfMediaLibrary') + )) ?> + </div> + <?php endif; ?> +</div> + Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/_block.php ___________________________________________________________________ Name: svn:keywords + "Id Author URL Date Rev" Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/_dirs.php =================================================================== --- prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/_dirs.php 2007-04-18 15:20:37 UTC (rev 4545) +++ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/_dirs.php 2007-04-18 15:22:07 UTC (rev 4546) @@ -0,0 +1,17 @@ +<?php if ($currentDir != ''): ?> + <div class="assetImage"><?php echo link_to(image_tag('/sfMediaLibraryPlugin/images/up', array('alt' => '..', 'title' => '..', 'size' => '64x64')), 'sfMediaLibrary/'.$sf_context->getActionName().'?dir='.$parentDir) ?> + <p class="assetComment">» ..<?php if ($is_file or ($sf_context->getActionName() === 'index')): ?> + <br /> + <?php endif; ?></p> + </div> +<?php endif; ?> +<?php $count = 0; foreach ($dirs as $dir): $count++ ?> + <div id="block_<?php echo $count ?>" class="assetImage"><?php include_partial('sfMediaLibrary/block', array( + 'name' => $dir, + 'current_path' => $currentDir, + 'type' => 'folder', + 'info' => array(), + 'count' => $count, + 'is_file' => $is_file, + )) ?></div> +<?php endforeach; ?> Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/_dirs.php ___________________________________________________________________ Name: svn:keywords + "Id Author URL Date Rev" Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/_files.php =================================================================== --- prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/_files.php 2007-04-18 15:20:37 UTC (rev 4545) +++ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/_files.php 2007-04-18 15:22:07 UTC (rev 4546) @@ -0,0 +1,10 @@ +<?php foreach ($files as $file => $info): $count++ ?> +<div id="block_<?php echo $count ?>" class="assetImage"><?php include_partial('sfMediaLibrary/block', array( + 'name' => $file, + 'current_path' => $currentDir, + 'web_abs_current_path' => $webAbsCurrentDir, + 'type' => 'file', + 'info' => $info, + 'count' => $count, +)) ?></div> +<?php endforeach; ?> Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/_files.php ___________________________________________________________________ Name: svn:keywords + "Id Author URL Date Rev" Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/choiceSuccess.php =================================================================== --- prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/choiceSuccess.php 2007-04-18 15:20:37 UTC (rev 4545) +++ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/choiceSuccess.php 2007-04-18 15:22:07 UTC (rev 4546) @@ -0,0 +1,24 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/2000/REC-xhtml1-200000126/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> +</head> +<body> + +<?php use_helper('Javascript', 'I18N') ?> +<?php echo javascript_tag(" +function setFileSrc(src) +{ + opener.sfMediaLibrary.fileBrowserReturn(src); + window.close(); +} +") ?> +<div id="sf_asset_container"> + <h1><?php echo __('Media library (%1%)', array('%1%' => $current_dir_slash), 'sfMediaLibrary') ?></h1> + <div id="sf_asset_content_popup"> + <?php include_partial('sfMediaLibrary/dirs', array('dirs' => $dirs, 'currentDir' => $currentDir, 'parentDir' => $parentDir, 'is_file' => (count($files) > 0))) ?> + <?php include_partial('sfMediaLibrary/files', array('files' => $files, 'currentDir' => $currentDir, 'webAbsCurrentDir' => $webAbsCurrentDir, 'count' => count($dirs))) ?> + </div> +</div> + +</body> +</html> \ No newline at end of file Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/choiceSuccess.php ___________________________________________________________________ Name: svn:keywords + "Id Author URL Date Rev" Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/indexSuccess.php =================================================================== --- prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/indexSuccess.php 2007-04-18 15:20:37 UTC (rev 4545) +++ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/indexSuccess.php 2007-04-18 15:22:07 UTC (rev 4546) @@ -0,0 +1,60 @@ +<?php use_helper('Javascript', 'I18N') ?> + +<div id="sf_asset_container"> + + <h1><?php echo __('Media library (%1%)', array('%1%' => $current_dir_slash), 'sfMediaLibrary') ?></h1> + +<div id="sf_asset_content"> + + <div id="sf_asset_controls"> + + <?php echo form_tag('sfMediaLibrary/upload', 'class=float-left id=sf_asset_upload_form name=sf_asset_upload_form multipart=true') ?> + <?php echo input_hidden_tag('current_dir', $currentDir) ?> + <fieldset> + <div class="form-row"> + <?php echo label_for('file', __('Add a file:', null, 'sfMediaLibrary'), '') ?> + <div class="content"><?php echo input_file_tag('file') ?></div> + </div> + </fieldset> + + <ul class="sf_asset_actions"> + <li><?php echo submit_tag(__('Add', null, 'sfMediaLibrary'), array ( + 'name' => 'add', + 'class' => 'sf_asset_action_add_file', + 'onclick' => "if($('file').value=='') { alert('".__('Please choose a file first', null, 'sfMediaLibrary')."');return false; }", + )) ?></li> + </ul> + + </form> + + <?php echo form_tag('sfMediaLibrary/mkdir', 'class=float-left id=sf_asset_mkdir_form name=sf_asset_mkdir_form') ?> + <?php echo input_hidden_tag('current_dir', $currentDir) ?> + <fieldset> + <div class="form-row"> + <?php echo label_for('dir', __('Create a dir:', null, 'sfMediaLibrary'), '') ?> + <div class="content"><?php echo input_tag('name', null, 'size=15 id=dir') ?></div> + </div> + </fieldset> + + <ul class="sf_asset_actions"> + <li><?php echo submit_tag(__('Create', null, 'sfMediaLibrary'), array ( + 'name' => 'create', + 'class' => 'sf_asset_action_add_folder', + 'onclick' => "if($('dir').value=='') { alert('".__('Please enter a directory name first', null, 'sfMediaLibrary')."');return false; }", + )) ?></li> + </ul> + + </form> + + </div> + + <div id="sf_asset_assets"> + + <?php include_partial('sfMediaLibrary/dirs', array('dirs' => $dirs, 'currentDir' => $currentDir, 'parentDir' => $parentDir, 'is_file' => (count($files) > 0))) ?> + <?php include_partial('sfMediaLibrary/files', array('files' => $files, 'currentDir' => $currentDir, 'webAbsCurrentDir' => $webAbsCurrentDir, 'count' => count($dirs))) ?> + + </div> + +</div> + +</div> Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/indexSuccess.php ___________________________________________________________________ Name: svn:keywords + "Id Author URL Date Rev" Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/renameSuccess.php =================================================================== --- prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/renameSuccess.php 2007-04-18 15:20:37 UTC (rev 4545) +++ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/renameSuccess.php 2007-04-18 15:22:07 UTC (rev 4546) @@ -0,0 +1,10 @@ +<?php use_helper('Javascript', 'I18N') ?> + +<?php include_partial('sfMediaLibrary/block', array( + 'name' => $name, + 'current_path' => $current_path, + 'web_abs_current_path' => $web_abs_current_path, + 'type' => $type, + 'info' => $info, + 'count' => $count, +)) ?> \ No newline at end of file Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/modules/sfMediaLibrary/templates/renameSuccess.php ___________________________________________________________________ Name: svn:keywords + "Id Author URL Date Rev" Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/css/media.css =================================================================== --- prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/css/media.css 2007-04-18 15:20:37 UTC (rev 4545) +++ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/css/media.css 2007-04-18 15:22:07 UTC (rev 4546) @@ -0,0 +1,190 @@ +#sf_asset_container ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,p,blockquote,fieldset,input +{ margin: 0; padding: 0; } +#sf_asset_container a img,:link img,:visited img { border: none; } + +#sf_asset_container a:link, #sf_admin_container a:visited +{ + text-decoration: none; +} + +#sf_asset_container a:hover +{ + text-decoration: underline; +} + +#sf_asset_container td +{ + margin: 0; + padding: 20px; + font-family: Arial, sans-serif; + font-size: 11px; + background-color: #fff; +} + +#sf_asset_container p +{ + margin-bottom: 5px; +} + + +#sf_asset_container #sf_asset_assets +{ + padding-top: 10px; + clear: left; +} + +#sf_asset_container h1 +{ + margin: 8px 0; + padding: 3px; + padding-left: 0px; + color: #555; + font-family: "Trebuchet MS", Arial, Verdana, sans-serif; + font-size: 25px; +} + +#sf_asset_container input +{ + padding: 3px; + font-family: Arial, sans-serif; + font-size: 11px; + border: 1px solid #ddd; + vertical-align:middle; +} + +#sf_asset_container label +{ + display: block; + padding: 0 1em 3px 0; + text-align: left; + color: #666; + font-weight: normal !important; +} + +#sf_asset_container .form-row +{ + padding: 10px; + border-bottom: 1px solid #ddd; + height: 40px; +} + +#sf_asset_container #sf_asset_upload_form +{ + width: 240px; + margin-right: 10px; +} + +#sf_asset_container #sf_asset_mkdir_form +{ + width: 150px; +} + +#sf_asset_container fieldset +{ + margin-bottom: 3px; + border: 1px solid #ddd; + border-bottom: 0px; +} + +#sf_asset_container .float-left +{ + float: left; +} + +#sf_asset_container .float-right +{ + float: right; +} + +#sf_asset_container ul.sf_asset_actions +{ + display: block; + margin: 0; + list-style-type: none; + text-align: right; +} + +#sf_asset_container ul.sf_asset_actions a +{ + color: #333; +} + +#sf_asset_container ul.sf_asset_actions li +{ + list-style-type: none; + display: inline; +} + +#sf_asset_container ul.sf_asset_actions input +{ + padding: 3px 3px 3px 20px; + color: #333; + font-size: 11px; + font-family: Arial, sans-serif; + border: 0px; + border-right: 4px solid #999; + background-color: #ffc; + cursor: hand; + cursor: pointer; +} + +#sf_asset_container .sf_asset_action_add_file +{ + background: url(../images/filenew.png) no-repeat 3px 2px; + border-right: 4px solid #73B65A !important; +} + +#sf_asset_container .sf_asset_action_add_folder +{ + background: url(../images/folder_new.png) no-repeat 3px 2px; + border-right: 4px solid #73B65A !important; +} + +#sf_asset_container .sf_asset_filters li +{ + list-style-type: none; +} + +#sf_asset_container .assetImage +{ + float: left; + padding: 10px 20px 5px 20px; + margin-right: 15px; + margin-bottom: 15px; + border: 1px solid #ddd; + background-color: #eee; + text-align: center; +} + +#sf_asset_container .assetComment +{ + font-family: Arial, sans-serif; + margin: -5px -20px; + margin-top: 10px; + padding: 2px; + padding-left: 5px; + padding-right: 5px; + background-color: #aaa; + font-size: 90%; + color: #eee; + text-align: left; +} + +#sf_asset_container .assetComment a +{ + border-bottom: 0; +} + +#sf_asset_container .assetImage a +{ + color: #eee; + border-bottom: 0; +} + +#sf_asset_container .thumbnails +{ + width: auto !important; + width: 0; + height: 64px; + +} Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/archive.png =================================================================== (Binary files differ) Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/archive.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/bin.png =================================================================== (Binary files differ) Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/bin.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/delete.png =================================================================== (Binary files differ) Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/delete.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/doc.png =================================================================== (Binary files differ) Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/doc.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/edit.png =================================================================== (Binary files differ) Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/edit.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/filenew.png =================================================================== (Binary files differ) Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/filenew.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/folder.png =================================================================== (Binary files differ) Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/folder.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/folder_new.png =================================================================== (Binary files differ) Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/folder_new.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/folder_open.png =================================================================== (Binary files differ) Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/folder_open.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/html.png =================================================================== (Binary files differ) Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/html.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/image.png =================================================================== (Binary files differ) Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/image.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/pdf.png =================================================================== (Binary files differ) Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/pdf.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/ppt.png =================================================================== (Binary files differ) Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/ppt.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/txt.png =================================================================== (Binary files differ) Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/txt.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/unknown.png =================================================================== (Binary files differ) Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/unknown.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/up.png =================================================================== (Binary files differ) Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/up.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/xls.png =================================================================== (Binary files differ) Property changes on: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/images/xls.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/js/main.js =================================================================== --- prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/js/main.js 2007-04-18 15:20:37 UTC (rev 4545) +++ prosistem/alba/trunk/alba/plugins/sfMediaLibraryPlugin/web/js/main.js 2007-04-18 15:22:07 UTC (rev 4546) @@ -0,0 +1,132 @@ +function sfMediaLibrary_Engine() +{ + // Browser check + var ua = navigator.userAgent; + this.isMSIE = (navigator.appName == "Microsoft Internet Explorer"); + this.isMSIE5 = this.isMSIE && (ua.indexOf('MSIE 5') != -1); + this.isMSIE5_0 = this.isMSIE && (ua.indexOf('MSIE 5.0') != -1); + this.isGecko = ua.indexOf('Gecko') != -1; + this.isSafari = ua.indexOf('Safari') != -1; + this.isOpera = ua.indexOf('Opera') != -1; + this.isMac = ua.indexOf('Mac') != -1; + this.isNS7 = ua.indexOf('Netscape/7') != -1; + this.isNS71 = ua.indexOf('Netscape/7.1') != -1; + this.isTinyMCE = false; + + // Fake MSIE on Opera and if Opera fakes IE, Gecko or Safari cancel those + if (this.isOpera) { + this.isMSIE = true; + this.isGecko = false; + this.isSafari = false; + } +} + +sfMediaLibrary_Engine.prototype = { + init : function(url) + { + this.url = url; + }, + + fileBrowserReturn : function (url) + { + if(this.isTinyMCE) + { + tinyMCE.setWindowArg('editor_id', this.fileBrowserWindowArg); + if (this.fileBrowserType == 'image') + { + this.fileBrowserWin.showPreviewImage(url); + } + } + this.fileBrowserWin.document.forms[this.fileBrowserFormName].elements[this.fileBrowserFieldName].value = url; + }, + + fileBrowserCallBack : function (field_name, url, type, win) + { + this.isTinyMCE = true; + this.fileBrowserWindowArg = tinyMCE.getWindowArg('editor_id'); + var template = new Array(); + template['title'] = 'Assets'; + var url = this.url; + if (type == 'image') + url += '/images_only/1'; + template['file'] = url; + template['width'] = 550; + template['height'] = 600; + template['close_previous'] = 'no'; + + this.fileBrowserWin = win; + this.fileBrowserFormName = 0; + this.fileBrowserFieldName = field_name; + this.fileBrowserType = type; + tinyMCE.openWindow(template, {inline : "yes", scrollbars: 'yes'}); + }, + + openWindow : function(options) + { + var width, height, x, y, resizable, scrollbars, url; + + if (!options) + return; + if (!options['field_name']) + return; + if (!options['url'] && !this.url) + return; + this.fileBrowserWin = self; + this.fileBrowserFormName = (options['form_name'] == '') ? 0 : options['form_name']; + this.fileBrowserFieldName = options['field_name']; + this.fileBrowserType = options['type']; + + url = this.url; + if (options['type'] == 'image') + url += '/images_only/1'; + + if (!(width = parseInt(options['width']))) + width = 550; + + if (!(width = parseInt(options['width']))) + width = 550; + + if (!(height = parseInt(options['height']))) + height = 600; + + // Add to height in M$ due to SP2 WHY DON'T YOU GUYS IMPLEMENT innerWidth of windows!! + if (sfMediaLibrary.isMSIE) + height += 40; + else + height += 20; + + x = parseInt(screen.width / 2.0) - (width / 2.0); + y = parseInt(screen.height / 2.0) - (height / 2.0); + + resizable = (options && options['resizable']) ? options['resizable'] : "no"; + scrollbars = (options && options['scrollbars']) ? options['scrollbars'] : "no"; + + var modal = (resizable == "yes") ? "no" : "yes"; + + if (sfMediaLibrary.isGecko && sfMediaLibrary.isMac) + modal = "no"; + + if (options['close_previous'] != "no") + try {sfMediaLibrary.lastWindow.close();} catch (ex) {} + + var win = window.open(url, "sfPopup" + new Date().getTime(), "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=" + modal + ",minimizable=" + resizable + ",modal=" + modal + ",width=" + width + ",height=" + height + ",resizable=" + resizable); + + if (options['close_previous'] != "no") + sfMediaLibrary.lastWindow = win; + + eval('try { win.resizeTo(width, height); } catch(e) { }'); + + // Make it bigger if statusbar is forced + if (sfMediaLibrary.isGecko) + { + if (win.document.defaultView.statusbar.visible) + win.resizeBy(0, sfMediaLibrary.isMac ? 10 : 24); + } + + win.focus(); + + } +} + +var SfMediaLibrary = sfMediaLibrary_Engine; // Compatiblity with gzip compressors +var sfMediaLibrary = new sfMediaLibrary_Engine();
participants (1)
-
commits@pressenter.com.ar