Extensiones: fixtureHelper y multimodelform
git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_IntranetNueva/trunk@15 77cfc57b-8ef4-1849-9df6-4a38aa5da120
This commit is contained in:
parent
d1a6a3d30b
commit
3713ff3c51
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* FixtureHelper is a command application lets you work with your fixtures outside
|
||||
* testing. Currently what it does is just helping you to load you fixtures from your
|
||||
* fixture files to your database, without the need to invoke PHPUnit.
|
||||
*
|
||||
* @author Sum-Wai Low
|
||||
* @link https://github.com/sumwai/fixtureHelper
|
||||
* @copyright Copyright © 2010 Sum-Wai Low
|
||||
*/
|
||||
class FixtureHelperCommand extends CConsoleCommand {
|
||||
private $fixture;
|
||||
function getHelp() {
|
||||
return <<<EOD
|
||||
USAGE
|
||||
fixture [load]
|
||||
|
||||
DESCRIPTION
|
||||
This command lets you work with your fixtures outside testing
|
||||
|
||||
PARAMETERS
|
||||
* load: Load fixtures into the database
|
||||
* --alias: The alias to the directory that contains "models" and "tests"
|
||||
folders. Please note that folder "models" should contain the Model class of
|
||||
the fixtures to be loaded. Defaults to "application". Optional for "load".
|
||||
* --tables: Name of the tables to be loaded with your defined fixtures. Name
|
||||
values are comma separated. Required for "load".
|
||||
|
||||
EXAMPLES
|
||||
yiic fixture load --alias=application.modules.mymodule --tables=fruit,transport,country
|
||||
|
||||
|
||||
EOD;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads fixtures into the database tables from fixtures.
|
||||
* @param string $alias alias to the path that contains both models and tests folders
|
||||
* @param string $tables comma separated value of table names that should be loaded with fixtures
|
||||
*/
|
||||
function actionLoad($tables, $alias='application'){
|
||||
Yii::import($alias.'.models.*');
|
||||
$this->fixture = Yii::app()->getComponent('fixture');
|
||||
$this->fixture->basePath = Yii::getPathOfAlias($alias.'.tests.fixtures');
|
||||
$this->fixture->init();
|
||||
|
||||
$tables = explode(',', $tables);
|
||||
foreach ($tables as $table) {
|
||||
try {
|
||||
$this->fixture->resetTable($table);
|
||||
$this->fixture->loadFixture($table);
|
||||
} catch (Exception $e) {
|
||||
echo "ERROR: There is a problem working with the table $table. ".
|
||||
"Is it spelled correctly or exist?\n\n";
|
||||
}
|
||||
}
|
||||
echo "Done.\n\n";
|
||||
}
|
||||
|
||||
}
|
||||
45
www/protected/extensions/fixtureHelper/README.markdown
Normal file
45
www/protected/extensions/fixtureHelper/README.markdown
Normal file
@ -0,0 +1,45 @@
|
||||
FixtureHelper for Yii Framework
|
||||
===============================
|
||||
|
||||
FixtureHelper is a command application lets you work with your fixtures outside
|
||||
testing. Currently what it does is just helping you to load you fixtures from your
|
||||
fixture files to your database, without the need to invoke PHPUnit.
|
||||
|
||||
INSTALL
|
||||
-------
|
||||
Copy FixtureHelperCommand.php and place it under `protected/extensions/fixtureHelper/`
|
||||
|
||||
Edit `protected/config/console.php`, add the following to the config array under
|
||||
first dimension:
|
||||
|
||||
'commandMap' => array(
|
||||
'fixture' => array(
|
||||
'class'=>'application.extensions.fixtureHelper.FixtureHelperCommand',
|
||||
),
|
||||
),
|
||||
|
||||
Configure your database by setting up your db under `components`.
|
||||
|
||||
Add the following inside `components`.
|
||||
|
||||
'fixture'=>array(
|
||||
'class'=>'system.test.CDbFixtureManager',
|
||||
),
|
||||
|
||||
USAGE
|
||||
------
|
||||
fixture load [--alias=folderalias] --table=tablename1[,tablename2[,...]]
|
||||
|
||||
PARAMETERS
|
||||
-----------
|
||||
* load: Load fixtures into the database
|
||||
* --alias: The alias to the directory that contains "models" and "tests"
|
||||
folders. Please note that folder "models" should contain the Model class of
|
||||
the fixtures to be loaded. Defaults to "application". Optional for "load".
|
||||
* --tables: Name of the tables to be loaded with your defined fixtures. Name
|
||||
values are comma separated. Required for "load".
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
yiic fixture load --alias=application.modules.mymodule --tables=fruit,transport,country
|
||||
1161
www/protected/extensions/multimodelform/MultiModelForm.php
Normal file
1161
www/protected/extensions/multimodelform/MultiModelForm.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,129 @@
|
||||
/**
|
||||
* jquery.relcopy.yii.1.0.js
|
||||
* Version for Yii extension 'jqrelcopy' and 'multimodelform'
|
||||
* Added: beforeClone,afterClone,beforeNewId,afterNewId
|
||||
* @link http://www.yiiframework.com/extension/jqrelcopy
|
||||
* @link http://www.yiiframework.com/extension/multimodelform
|
||||
* @author: J. Blocher
|
||||
* -----------------------------------------------------------------
|
||||
* jQuery-Plugin "relCopy"
|
||||
*
|
||||
* @version: 1.1.0, 25.02.2010
|
||||
*
|
||||
* @author: Andres Vidal
|
||||
* code@andresvidal.com
|
||||
* http://www.andresvidal.com
|
||||
*
|
||||
* Instructions: Call $(selector).relCopy(options) on an element with a jQuery type selector
|
||||
* defined in the attribute "rel" tag. This defines the DOM element to copy.
|
||||
* @example: $('a.copy').relCopy({limit: 5}); // <a href="example.com" class="copy" rel=".phone">Copy Phone</a>
|
||||
*
|
||||
* @param: string excludeSelector - A jQuery selector used to exclude an element and its children
|
||||
* @param: integer limit - The number of allowed copies. Default: 0 is unlimited
|
||||
* @param: string append - HTML to attach at the end of each copy. Default: remove link
|
||||
* @param: string copyClass - A class to attach to each copy
|
||||
* @param: boolean clearInputs - Option to clear each copies text input fields or textarea
|
||||
*
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
|
||||
$.fn.relCopy = function(options) {
|
||||
var settings = jQuery.extend({
|
||||
excludeSelector: ".exclude",
|
||||
emptySelector: ".empty",
|
||||
copyClass: "copy",
|
||||
append: '',
|
||||
clearInputs: true,
|
||||
limit: 0, // 0 = unlimited
|
||||
beforeClone: null,
|
||||
afterClone: null,
|
||||
beforeNewId: null,
|
||||
afterNewId: null
|
||||
}, options);
|
||||
|
||||
settings.limit = parseInt(settings.limit);
|
||||
|
||||
// loop each element
|
||||
this.each(function() {
|
||||
|
||||
// set click action
|
||||
$(this).click(function(){
|
||||
var rel = $(this).attr('rel'); // rel in jquery selector format
|
||||
var counter = $(rel).length;
|
||||
|
||||
// stop limit
|
||||
if (settings.limit != 0 && counter >= settings.limit){
|
||||
return false;
|
||||
};
|
||||
|
||||
var funcBeforeClone = function(){eval(settings.beforeClone);};
|
||||
var funcAfterClone = function(){eval(settings.afterClone);};
|
||||
var funcBeforeNewId = function(){eval(settings.beforeNewId);};
|
||||
var funcAfterNewId = function(){eval(settings.afterNewId);};
|
||||
|
||||
var master = $(rel+":first");
|
||||
funcBeforeClone.call(master);
|
||||
|
||||
var parent = $(master).parent();
|
||||
var clone = $(master).clone(true).addClass(settings.copyClass+counter).append(settings.append);
|
||||
funcAfterClone.call(clone);
|
||||
|
||||
//Remove Elements with excludeSelector
|
||||
if (settings.excludeSelector){
|
||||
$(clone).find(settings.excludeSelector).remove();
|
||||
};
|
||||
|
||||
//Empty Elements with emptySelector
|
||||
if (settings.emptySelector){
|
||||
$(clone).find(settings.emptySelector).empty();
|
||||
};
|
||||
|
||||
// Increment Clone IDs
|
||||
if ( $(clone).attr('id') ){
|
||||
var newid = $(clone).attr('id') + (counter +1);
|
||||
funcBeforeNewId.call(clone);
|
||||
$(clone).attr('id', newid);
|
||||
funcAfterNewId.call(clone);
|
||||
};
|
||||
|
||||
// Increment Clone Children IDs
|
||||
$(clone).find('[id]').each(function(){
|
||||
var newid = $(this).attr('id') + (counter +1);
|
||||
funcBeforeNewId.call($(this));
|
||||
$(this).attr('id', newid);
|
||||
funcAfterNewId.call($(this));
|
||||
});
|
||||
|
||||
//Clear Inputs/Textarea
|
||||
if (settings.clearInputs){
|
||||
$(clone).find(':input').each(function(){
|
||||
var type = $(this).attr('type');
|
||||
switch(type)
|
||||
{
|
||||
case "button":
|
||||
break;
|
||||
case "reset":
|
||||
break;
|
||||
case "submit":
|
||||
break;
|
||||
case "checkbox":
|
||||
$(this).attr('checked', '');
|
||||
break;
|
||||
default:
|
||||
$(this).val("");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$(parent).find(rel+':last').after(clone);
|
||||
return false;
|
||||
|
||||
}); // end click action
|
||||
|
||||
}); //end each loop
|
||||
|
||||
return this; // return to jQuery
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
28
www/protected/extensions/multimodelform/license.txt
Normal file
28
www/protected/extensions/multimodelform/license.txt
Normal file
@ -0,0 +1,28 @@
|
||||
Copyright © 2011 by myticket it-solutions gmbh (http://www.myticket.at)
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of myticket it-solutions gmbh nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
Loading…
Reference in New Issue
Block a user