[FEATURE] first commit 23/22123/2 master
authorJonas Felix <jonas.felix@typo3.org>
Sun, 7 Jul 2013 15:15:58 +0000 (17:15 +0200)
committerGordon Brüggemann <gb@gb-web.de>
Mon, 8 Jul 2013 13:03:26 +0000 (15:03 +0200)
Fixes #49767

Change-Id: I30d5395bfd88928a2801b56c333d56b58fee1e8a
Reviewed-on: https://review.typo3.org/22123
Reviewed-by: Nils Blattner
Tested-by: Nils Blattner
Reviewed-by: Gordon Brüggemann
Tested-by: Gordon Brüggemann
70 files changed:
ChangeLog [new file with mode: 0644]
Classes/Controller/BaseController.php [new file with mode: 0644]
Classes/Controller/ContentController.php [new file with mode: 0644]
Classes/Controller/InitializeController.php [new file with mode: 0644]
Classes/Controller/SnapshotController.php [new file with mode: 0644]
Classes/Domain/Repository/ContentRepository.php [new file with mode: 0644]
Classes/Domain/Repository/Result.php [new file with mode: 0644]
Classes/Domain/Repository/SnapshotRepository.php [new file with mode: 0644]
Classes/Eid/ClearCache.php [new file with mode: 0644]
Classes/Utility/Diff.php [new file with mode: 0644]
Classes/Utility/Packetize.php [new file with mode: 0644]
Classes/Utility/Shell.php [new file with mode: 0644]
Classes/Utility/Tca.php [new file with mode: 0644]
Classes/ViewHelpers/TcaLabelViewHelper.php [new file with mode: 0644]
Resources/Private/Backend/Layouts/Admin.html [new file with mode: 0644]
Resources/Private/Backend/Layouts/Default.html [new file with mode: 0644]
Resources/Private/Backend/Partials/FormErrors.html [new file with mode: 0644]
Resources/Private/Backend/Partials/PageNode.html [new file with mode: 0644]
Resources/Private/Backend/Partials/Rootline.html [new file with mode: 0644]
Resources/Private/Backend/Partials/Snapshot/FormFields.html [new file with mode: 0644]
Resources/Private/Backend/Templates/Content/Compare.html [new file with mode: 0644]
Resources/Private/Backend/Templates/Content/View.html [new file with mode: 0644]
Resources/Private/Backend/Templates/Initialize/Show.html [new file with mode: 0644]
Resources/Private/Backend/Templates/Snapshot/List.html [new file with mode: 0644]
Resources/Private/Backend/Templates/Snapshot/New.html [new file with mode: 0644]
Resources/Private/Language/locallang.xml [new file with mode: 0644]
Resources/Private/Language/locallang_csh_tx_contentstage_domain_model_content.xml [new file with mode: 0644]
Resources/Private/Language/locallang_csh_tx_contentstage_domain_model_initialize.xml [new file with mode: 0644]
Resources/Private/Language/locallang_csh_tx_contentstage_domain_model_snapshot.xml [new file with mode: 0644]
Resources/Private/Language/locallang_db.xml [new file with mode: 0644]
Resources/Private/Language/locallang_stage.xml [new file with mode: 0644]
Resources/Private/Language/locallang_stageAdmin.xml [new file with mode: 0644]
Resources/Private/Language/locallang_stageInit.xml [new file with mode: 0644]
Resources/Private/Language/locallang_stageSnapshots.xml [new file with mode: 0644]
Resources/Public/CSS/Main.css [new file with mode: 0644]
Resources/Public/Icons/relation.gif [new file with mode: 0644]
Resources/Public/Icons/tx_contentstage_domain_model_content.gif [new file with mode: 0644]
Resources/Public/Icons/tx_contentstage_domain_model_initialize.gif [new file with mode: 0644]
Resources/Public/Icons/tx_contentstage_domain_model_snapshot.gif [new file with mode: 0644]
Resources/Public/Images/ajax-loader.gif [new file with mode: 0644]
Resources/Public/Images/file.gif [new file with mode: 0644]
Resources/Public/Images/folder-closed.gif [new file with mode: 0644]
Resources/Public/Images/folder.gif [new file with mode: 0644]
Resources/Public/Images/minus.gif [new file with mode: 0644]
Resources/Public/Images/plus.gif [new file with mode: 0644]
Resources/Public/Images/treeview-black-line.gif [new file with mode: 0644]
Resources/Public/Images/treeview-black.gif [new file with mode: 0644]
Resources/Public/Images/treeview-default-line.gif [new file with mode: 0644]
Resources/Public/Images/treeview-default.gif [new file with mode: 0644]
Resources/Public/Images/treeview-famfamfam-line.gif [new file with mode: 0644]
Resources/Public/Images/treeview-famfamfam.gif [new file with mode: 0644]
Resources/Public/Images/treeview-gray-line.gif [new file with mode: 0644]
Resources/Public/Images/treeview-gray.gif [new file with mode: 0644]
Resources/Public/Images/treeview-red.gif [new file with mode: 0644]
Resources/Public/JavaScript/Loader.js [new file with mode: 0644]
Resources/Public/JavaScript/Main.js [new file with mode: 0644]
Resources/Public/JavaScript/jquery-1.8.3.min.js [new file with mode: 0644]
Resources/Public/JavaScript/jquery.tmpl.js [new file with mode: 0644]
Resources/Public/JavaScript/jquery.tmpl.min.js [new file with mode: 0644]
Resources/Public/JavaScript/jquery.tmplPlus.js [new file with mode: 0644]
Resources/Public/JavaScript/jquery.tmplPlus.min.js [new file with mode: 0644]
Resources/Public/JavaScript/jquery.treeview.js [new file with mode: 0644]
doc/manual.sxw [new file with mode: 0644]
ext_conf_template.txt [new file with mode: 0644]
ext_emconf.php [new file with mode: 0644]
ext_icon.gif [new file with mode: 0644]
ext_localconf.php [new file with mode: 0644]
ext_tables.php [new file with mode: 0644]
ext_typoscript_constants.txt [new file with mode: 0644]
ext_typoscript_setup.txt [new file with mode: 0644]

diff --git a/ChangeLog b/ChangeLog
new file mode 100644 (file)
index 0000000..b5240e4
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,128 @@
+2013-05-02 Dimitri König <dk@cabag.ch>
+       * version 0.2.7
+       * modified findCmd in Shell - fixed WIN bug
+
+2013-04-16 Dimitri König <dk@cabag.ch>
+       * version 0.2.6
+       * set clear cache call from file_get_contents to curl due to ssl
+       * fixed hash not found bug
+
+2013-04-15 Nils Blattner <nb@cabag.ch>
+       * version 0.2.5
+       * fixed a bug in the eID-script that would not properly clean up temporary hashes
+
+2013-04-12 Nils Blattner <nb@cabag.ch>
+       * version 0.2.4
+       * fixed a bug that dependencies are not properly staged
+
+2013-04-11 Dimitri König <dk@cabag.ch>
+       * version 0.2.3
+       * fixed some bugs in shell class
+
+2013-04-03 Nils Blattner <nb@cabag.ch>
+       * version 0.2.2
+       * fixed snapshots so that they actually consider the tables to be ignored
+
+2013-02-07 Nils Blattner <nb@cabag.ch>
+       * version 0.2.1
+       * added language labels for source/target missing
+
+2013-02-07 Nils Blattner <nb@cabag.ch>
+       * version 0.2.0
+       * separated snapshot and initialize into separate modules
+
+2013-02-05 Nils Blattner <nb@cabag.ch>
+       * version 0.1.9
+       * fixed a bug with the remote page tree
+       * separated initialize and snapshot functions to a different "admin"-module
+       * fixed an issue if a page did not exist remotely
+
+2013-02-05 Nils Blattner <nb@cabag.ch>
+       * version 0.1.8
+       * fixed an issue when the remote page tree does not exist
+       * now a snapshot of the current state is created before reverting to a given snapshot
+
+2013-01-30 Nils Blattner <nb@cabag.ch>
+       * version 0.1.7
+       * fixed an issue with clearcache "all" and domains
+
+2013-01-30 Nils Blattner <nb@cabag.ch>
+       * version 0.1.6
+       * fixed issue where inserts were not properly split up into packs of 100 queries
+       * removed usage of admin_get_tables
+       * fixed an issue where folders do not have a trailing slash
+       * implemented the possibility to enforce the whole cache to be cleared
+
+2013-01-29 Nils Blattner <nb@cabag.ch>
+       * version 0.1.5
+       * added dependency for cabag_extbase 0.5.5
+
+2013-01-04 Nils Blattner <nb@cabag.ch>
+       * version 0.1.4
+       * fixed some issues with shell on windows
+       * added TYPO3 4.7+ caching framework tables (cf_*) to auto ignore tables
+
+2013-01-02 Nils Blattner <nb@cabag.ch>
+       * version 0.1.3
+       * fixed some issues with fields (fallback in JS)
+       * fixed an issue, where the repository would attempt to find sys_log/_history records of files
+       * added german translations
+
+2012-12-27 Nils Blattner <nb@cabag.ch>
+       * version 0.1.2
+       * implemented the day after yesterday routine!
+       * implemented remote cache clearing
+       * changed extension icon
+
+2012-12-20 Nils Blattner <nb@cabag.ch>
+       * version 0.1.1
+       * implemented the day before tomorrow routine!
+       * implemented 2 column diff view
+       * implemented sys_log/sys_history migration
+       * implemented ignore tables/fields
+
+2012-12-13 Nils Blattner <nb@cabag.ch>
+       * version 0.1.0
+       * changes are rendered with jQuery templates now
+       * changed some visuals
+
+2012-12-11 Nils Blattner <nb@cabag.ch>
+       * version 0.0.9
+       * small code refactoring in Classes/Utility/Tca.php
+
+2012-12-10 Nils Blattner <nb@cabag.ch>
+       * version 0.0.8
+       * finished TCA parser
+       * implemented relation resolving
+       * implemented file push
+
+2012-12-07 Nils Blattner <nb@cabag.ch>
+       * version 0.0.7
+       * implemented part of the TCA parser
+       * moved all typoscript to ext_typoscript_*.txt
+       * implemented gzip compression for sql snapshots
+
+2012-12-06 Nils Blattner <nb@cabag.ch>
+       * version 0.0.6
+       * implemented snapshots
+       * implemented initialization
+
+2012-11-21 Nils Blattner <nb@cabag.ch>
+       * version 0.0.5
+       * implemented diff display
+
+2012-11-16 Nils Blattner <nb@cabag.ch>
+       * version 0.0.4
+       * fixed/implemented row diff'ing
+
+2012-11-15 Nils Blattner <nb@cabag.ch>
+       * version 0.0.3
+       * implemented table base row diff'ing
+
+2012-11-13 Nils Blattner <nb@cabag.ch>
+       * version 0.0.2
+       * implemented diff functionality
+
+2012-11-08 Nils Blattner <nb@cabag.ch>
+       * version 0.0.1
+       * initial release
diff --git a/Classes/Controller/BaseController.php b/Classes/Controller/BaseController.php
new file mode 100644 (file)
index 0000000..96b602d
--- /dev/null
@@ -0,0 +1,442 @@
+<?php
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Nils Blattner <nb@cabag.ch>, cab services ag
+ *  
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ *
+ *
+ * @package contentstage
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
+ *
+ */
+class Tx_Contentstage_Controller_BaseController extends Tx_CabagExtbase_Controller_BaseController {
+       /**
+        * @var array An array of table => true pairs to be ignored in sync/diff.
+        */
+       protected $ignoreSyncTables = array(
+               'be_sessions' => true,
+               'cache_extensions' => true,
+               'cache_hash' => true,
+               'cache_imagesizes' => true,
+               'cache_md5params' => true,
+               'cache_pages' => true,
+               'cache_pagesection' => true,
+               'cache_treelist' => true,
+               'cache_typo3temp_log' => true,
+               'cachingframework_cache_hash' => true,
+               'cachingframework_cache_hash_tags' => true,
+               'cachingframework_cache_pages' => true,
+               'cachingframework_cache_pages_tags' => true,
+               'cachingframework_cache_pagesection' => true,
+               'cachingframework_cache_pagesection_tags' => true,
+               'cf_cache_hash' => true,
+               'cf_cache_hash_tags' => true,
+               'cf_cache_pages' => true,
+               'cf_cache_pages_tags' => true,
+               'cf_cache_pagesection' => true,
+               'cf_cache_pagesection_tags' => true,
+               'cf_extbase_object' => true,
+               'cf_extbase_object_tags' => true,
+               'cf_extbase_reflection' => true,
+               'cf_extbase_reflection_tags' => true,
+               'fe_session_data' => true,
+               'fe_sessions' => true,
+               'index_debug' => true,
+               'index_fulltext' => true,
+               'index_grlist' => true,
+               'index_phash' => true,
+               'index_rel' => true,
+               'index_section' => true,
+               'index_stat_search' => true,
+               'index_stat_word' => true,
+               'index_words' => true,
+               'sys_be_shortcuts' => true,
+               'sys_collection_entries' => true,
+               'sys_history' => true,
+               'sys_lockedrecords' => true,
+               'sys_log' => true,
+               'sys_preview' => true,
+               'sys_refindex' => true,
+               'sys_registry' => true,
+               'sys_ter' => true,
+               'sys_workspace' => true,
+               'static_tsconfig_help' => true,
+               'tx_extbase_cache_object' => true,
+               'tx_extbase_cache_object_tags' => true,
+               'tx_extbase_cache_reflection' => true,
+               'tx_extbase_cache_reflection_tags' => true,
+               'tx_impexp_presets' => true,
+               'tx_scheduler_task' => true
+       );
+       
+       /**
+        * @var array An array of table => true pairs to be ignored in snapshots.
+        */
+       protected $ignoreSnapshotTables = array(
+               'be_sessions' => true,
+               'cache_extensions' => true,
+               'cache_hash' => true,
+               'cache_imagesizes' => true,
+               'cache_md5params' => true,
+               'cache_pages' => true,
+               'cache_pagesection' => true,
+               'cache_treelist' => true,
+               'cache_typo3temp_log' => true,
+               'cachingframework_cache_hash' => true,
+               'cachingframework_cache_hash_tags' => true,
+               'cachingframework_cache_pages' => true,
+               'cachingframework_cache_pages_tags' => true,
+               'cachingframework_cache_pagesection' => true,
+               'cachingframework_cache_pagesection_tags' => true,
+               'cf_cache_hash' => true,
+               'cf_cache_hash_tags' => true,
+               'cf_cache_pages' => true,
+               'cf_cache_pages_tags' => true,
+               'cf_cache_pagesection' => true,
+               'cf_cache_pagesection_tags' => true,
+               'cf_extbase_object' => true,
+               'cf_extbase_object_tags' => true,
+               'cf_extbase_reflection' => true,
+               'cf_extbase_reflection_tags' => true,
+               'fe_session_data' => true,
+               'fe_sessions' => true,
+               'tx_extbase_cache_object' => true,
+               'tx_extbase_cache_object_tags' => true,
+               'tx_extbase_cache_reflection' => true,
+               'tx_extbase_cache_reflection_tags' => true
+       );
+       
+       /**
+        * The extension configuration.
+        *
+        * @var array The extension config.
+        */
+       protected $extensionConfiguration = null;
+       
+       /**
+        * The local t3lib_db.
+        *
+        * @var t3lib_db The local DB object.
+        */
+       protected $localDB = null;
+       
+       /**
+        * The remote t3lib_db.
+        *
+        * @var t3lib_db The remote DB object.
+        */
+       protected $remoteDB = null;
+       
+       /**
+        * The local repository.
+        *
+        * @var Tx_Contentstage_Domain_Repository_ContentRepository The local repository object.
+        */
+       protected $localRepository = null;
+       
+       /**
+        * The remote repository.
+        *
+        * @var Tx_Contentstage_Domain_Repository_ContentRepository The remote repository object.
+        */
+       protected $remoteRepository = null;
+
+       /**
+        * The snapshot repository.
+        *
+        * @var Tx_Contentstage_Domain_Repository_SnapshotRepository
+        */
+       protected $snapshotRepository;
+       
+       /**
+        * The cache.
+        *
+        * @var t3lib_cache_frontend_AbstractFrontend The cache.
+        */
+       protected $cache = null;
+       
+       /**
+        * The logging object.
+        *
+        * @var Tx_CabagExtbase_Utility_Logging The logging object.
+        */
+       protected $log = null;
+       
+       /**
+        * The diff object.
+        *
+        * @var Tx_Contentstage_Utility_Diff The diff object.
+        */
+       protected $diff = null;
+       
+       /**
+        * The TCA utility object.
+        *
+        * @var Tx_Contentstage_Utility_Tca The TCA utility object.
+        */
+       protected $tca = null;
+
+       /**
+        * Injects the snapshot repository.
+        *
+        * @param Tx_Contentstage_Domain_Repository_SnapshotRepository $snapshotRepository
+        * @return void
+        */
+       public function injectSnapshotRepository(Tx_Contentstage_Domain_Repository_SnapshotRepository $snapshotRepository) {
+               $this->snapshotRepository = $snapshotRepository;
+       }
+       
+       /**
+        * Injects the diff utility.
+        *
+        * @param Tx_Contentstage_Utility_Diff $diff The diff utility.
+        */
+       public function injectDiff(Tx_Contentstage_Utility_Diff $diff = null) {
+               $this->diff = $diff;
+       }
+       
+       /**
+        * Injects the TCA utility object.
+        *
+        * @param Tx_Contentstage_Utility_Tca $diff The TCA utility object.
+        */
+       public function injectTca(Tx_Contentstage_Utility_Tca $tca = null) {
+               $this->tca = $tca;
+       }
+
+       /**
+        * Initialize the controller.
+        *
+        * @return void
+        */
+       public function initializeAction() {
+               t3lib_cache::initializeCachingFramework();
+               t3lib_cache::initContentHashCache();
+               $this->cache = $GLOBALS['typo3CacheManager']->getCache('cache_hash');
+               
+               $this->extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['contentstage']);
+               define('TX_CONTENTSTAGE_USECACHE', !empty($this->extensionConfiguration['useCache']));
+               define('TX_CONTENTSTAGE_CACHETIME', intval($this->extensionConfiguration['cacheTime']));
+               
+               $this->localDB = $GLOBALS['TYPO3_DB'];
+               
+               $info = $this->extensionConfiguration['remote.']['db.'];
+               
+               $noPconnect = $GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect'];
+               $GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect'] = true;
+               $this->remoteDB = t3lib_div::makeInstance('t3lib_db');
+               $this->remoteDB->connectDB($info['host'], $info['user'], $info['password'], $info['database']);
+               $GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect'] = $noPconnect;
+               
+               if ($this->log === null) {
+                       $this->log = $this->objectManager->create('Tx_CabagExtbase_Utility_Logging');
+               }
+               
+               $this->log->setDefaultTag($this->extensionName)
+                       ->setWriteSeverity(400)
+                       ->addOutput($this->extensionName . 'Flash', 'flash', array(
+                               'flashMessageContainer' => $this->flashMessageContainer,
+                               'severity' => Tx_CabagExtbase_Utility_Logging::OK
+                       ));
+               
+               if ($this->extensionConfiguration['logging.']['file.']['enable']) {
+                       $this->extensionConfiguration['logging.']['file.']['file'] .= '-' . date('Ymd');
+                       $this->log->addOutput($this->extensionName . 'File', 'file', $this->extensionConfiguration['logging.']['file.']);
+               }
+               if ($this->extensionConfiguration['logging.']['mail.']['enable']) {
+                       $this->log->addOutput($this->extensionName . 'Mail', 'mail', $this->extensionConfiguration['logging.']['mail.']);
+               }
+               if ($this->extensionConfiguration['logging.']['devLog.']['enable']) {
+                       $this->log->addOutput($this->extensionName . 'DevLog', 'devlog', $this->extensionConfiguration['logging.']['devLog.']);
+               }
+               $this->log->log($this->translate('info.init'), Tx_CabagExtbase_Utility_Logging::INFORMATION);
+               
+               $this->localRepository = $this->objectManager->create(
+                       'Tx_Contentstage_Domain_Repository_ContentRepository',
+                       $this->localDB,
+                       $this->log,
+                       $this->cache,
+                       'localRepository'
+               );
+               $this->localRepository->setFolder(PATH_site);
+               
+               $this->remoteRepository = $this->objectManager->create(
+                       'Tx_Contentstage_Domain_Repository_ContentRepository',
+                       $this->remoteDB,
+                       $this->log,
+                       $this->cache,
+                       'remoteRepository'
+               );
+               $this->remoteRepository->setFolder($this->extensionConfiguration['remote.']['folder']);
+               
+               $this->initializeIgnoreTables();
+       }
+       
+       /**
+        * Initializes the ignore tables.
+        *
+        * @return void
+        */
+       protected function initializeIgnoreTables() {
+               $this->applyTablesToIndex($this->ignoreSyncTables, $this->extensionConfiguration['tables.']['doNotSync']);
+               
+               $this->applyTablesToIndex($this->ignoreSnapshotTables, $this->extensionConfiguration['tables.']['doNotSnapshot']);
+               
+               $id = intval(t3lib_div::_GP('id'));
+               if ($id <= 0) {
+                       return;
+               }
+               
+               $rootline = array();
+               $c = PHP_INT_MAX;
+               foreach ($this->localRepository->getRootline($id) as $uid => $page) {
+                       $rootline[$c] = &$page;
+                       $c--;
+               }
+               $pageTS = t3lib_befunc::getPagesTSconfig($id, $rootline);
+               
+               $this->applyTableIndexToIndex($this->ignoreSyncTables, $pageTS['tx_contentstage.']['doNotSync.']);
+               
+               $this->applyTableIndexToIndex($this->ignoreSnapshotTables, $pageTS['tx_contentstage.']['doNotSnapshot.']);
+               
+               $this->snapshotRepository->setIgnoreSnapshotTables($this->ignoreSnapshotTables);
+               
+               $this->tca->initializeIgnoreFields($pageTS['tx_contentstage.']['doNotDisplay.']);
+       }
+       
+       /**
+        * Apply the given tables to the index.
+        *
+        * @param array $index The index (array of value => true pairs).
+        * @param string $tables The comma separated list of tables.
+        * @return void
+        */
+       protected function applyTablesToIndex(array &$index, $tables) {
+               foreach (t3lib_div::trimExplode(',', $tables, true) as $table) {
+                       $index[$table] = true;
+               }
+       }
+       
+       /**
+        * Apply the given table index to the index.
+        *
+        * @param array $index The index (array of value => true pairs).
+        * @param array $tables The index (array of table => true/false).
+        * @return void
+        */
+       protected function applyTableIndexToIndex(array &$index, &$tableIndex = array()) {
+               if (!is_array($tableIndex)) {
+                       return;
+               }
+               foreach ($tableIndex as $table => &$ignore) {
+                       if ($ignore) {
+                               $index[$table] = true;
+                       }
+               }
+       }
+       
+       /**
+        * Filters a given array of tables with the ignore tables.
+        *
+        * @param array $tables The tables to filter.
+        * @param array $ignoreTables The index of 'tablename' => true pairs to be ignored.
+        * @return array The $tables minus the $ignoreTables
+        */
+       protected function filterTables(array $tables, array $ignoreTables) {
+               $result = array();
+               foreach ($tables as $table) {
+                       if (!isset($ignoreTables[$table]) || !$ignoreTables[$table]) {
+                               $result[] = $table;
+                       }
+               }
+               return $result;
+       }
+       
+       /**
+        * Returns the extension configuration.
+        *
+        * @return array The extension config.
+        */
+       public function getExtensionConfiguration() {
+               return $this->extensionConfiguration;
+       }
+       
+       /**
+        * Returns the local t3lib_db.
+        *
+        * @return t3lib_db The local DB object.
+        */
+       public function getLocalDB() {
+               return $this->localDB;
+       }
+       
+       /**
+        * Returns the remote t3lib_db.
+        *
+        * @return t3lib_db The remote DB object.
+        */
+       public function getRemoteDB() {
+               return $this->remoteDB;
+       }
+       
+       /**
+        * Returns the local repository.
+        *
+        * @return Tx_Contentstage_Domain_Repository_ContentRepository The local repository object.
+        */
+       public function getLocalRepository() {
+               return $this->localRepository;
+       }
+       
+       /**
+        * Returns the remote repository.
+        *
+        * @return Tx_Contentstage_Domain_Repository_ContentRepository The remote repository object.
+        */
+       public function getRemoteRepository() {
+               return $this->remoteRepository;
+       }
+       
+       /**
+        * Returns the info needed to connect to the local database.
+        *
+        * @return array The login info for the local database.
+        */
+       public function getLocalDbInfo() {
+               $info = array(
+                       'user' => TYPO3_db_username,
+                       'password' => TYPO3_db_password,
+                       'host' => TYPO3_db_host,
+                       'database' => TYPO3_db
+               );
+               
+               if ($portInfo = strstr($info['host'], ':')) {
+                       $info['port'] = intval($portInfo);
+                       $info['host'] = strstr($info['host'], ':', true);
+               }
+               return $info;
+       }
+}
+?>
\ No newline at end of file
diff --git a/Classes/Controller/ContentController.php b/Classes/Controller/ContentController.php
new file mode 100644 (file)
index 0000000..a7da006
--- /dev/null
@@ -0,0 +1,356 @@
+<?php
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Nils Blattner <nb@cabag.ch>, cab services ag
+ *  
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ *
+ *
+ * @package contentstage
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
+ *
+ */
+class Tx_Contentstage_Controller_ContentController extends Tx_Contentstage_Controller_BaseController {
+       
+       /**
+        * @var array The differences by table and uid.
+        */
+       protected $differences = array();
+       
+       /**
+        * @var array The differences by pid => table => uid => field.
+        */
+       protected $pidIndex = array();
+       
+       /**
+        * @var array The page tree.
+        */
+       protected $pageTree = array();
+       
+       /**
+        * action compare
+        *
+        * @return void
+        */
+       public function compareAction() {
+               $id = intval(t3lib_div::_GP('id'));
+               
+               if ($id <= 0) {
+                       $this->log->log($this->translate('info.compare.noId'), Tx_CabagExtbase_Utility_Logging::INFORMATION);
+                       $this->log->write();
+                       return $this->translate('info.compare.noId');
+               }
+               
+               try {
+                       $localTree = $this->localRepository->getFullPageTree();
+                       $remoteTree = $this->remoteRepository->getFullPageTree();
+                       if (!is_array($remoteTree[$id])) {
+                               $remoteTree[$id] = array();
+                       }
+                       if (!is_array($localTree[$id])) {
+                               $localTree[$id] = array();
+                       }
+                       $this->pageTree = &$localTree;
+                       $this->diff->rows($remoteTree[$id], $localTree[$id]);
+                       $this->compareTables($id);
+                       $this->generatePidIndex();
+                       
+                       $this->log->log($this->translate('info.compare.done'), Tx_CabagExtbase_Utility_Logging::INFORMATION, $localTree[$id]);
+               } catch (Exception $e) {
+                       $this->log->log($this->translate('error.' . $e->getCode(), array($e->getMessage())) ?: $e->getMessage(), Tx_CabagExtbase_Utility_Logging::ERROR);
+               }
+
+               $this->view->assign('localRootline', $this->localRepository->getRootline($id));
+               $this->view->assign('remoteRootline', $this->remoteRepository->getRootline($id));
+               
+               $this->view->assign('pageTree', $this->pageTree[$id]);
+               
+               $this->view->assign('pidIndex', $this->pidIndex);
+               
+               $this->view->assign('tca', $this->tca->getProcessedTca());
+               
+               $this->log->log($this->translate('info.compare.startFluid'), Tx_CabagExtbase_Utility_Logging::INFORMATION, $localTree[$id]);
+               
+               $content = $this->view->render();
+               
+               $this->log->log($this->translate('info.compare.endFluid'), Tx_CabagExtbase_Utility_Logging::INFORMATION, $localTree[$id]);
+               
+               $this->log->write();
+               
+               return $content;
+       }
+       
+       /**
+        * action view
+        * @TODO: change to https for some cases
+        *
+        * @return void
+        */
+       public function viewAction() {
+               $id = intval(t3lib_div::_GP('id'));
+               
+               if ($id <= 0) {
+                       $this->log->log($this->translate('info.compare.noId'), Tx_CabagExtbase_Utility_Logging::INFORMATION);
+                       $this->log->write();
+                       return $this->translate('info.compare.noId');
+               }
+               
+               $localDomain = $this->localRepository->getDomain($id);
+               $remoteDomain = $this->remoteRepository->getDomain($id);
+               
+               if ($localDomain === null) {
+                       $this->log->log($this->translate('warning.view.noDomain', array('local', $id)), Tx_CabagExtbase_Utility_Logging::WARNING);
+               }
+               if ($remoteDomain === null) {
+                       $this->log->log($this->translate('warning.view.noDomain', array('remote', $id)), Tx_CabagExtbase_Utility_Logging::WARNING);
+               }
+               
+               $this->view->assign('localUrl', 'http://' . $localDomain . '/index.php?id=' . $id);
+               $this->view->assign('remoteUrl', 'http://' . $remoteDomain . '/index.php?id=' . $id);
+               
+               $this->log->write();
+       }
+
+       /**
+        * action push
+        *
+        * @return void
+        */
+       public function pushAction() {
+               $id = intval(t3lib_div::_GP('id'));
+               
+               try {
+                       $tables = $this->filterTables(array_keys($this->remoteRepository->getTables()), $this->ignoreSnapshotTables);
+                       $info = $this->snapshotRepository->create(
+                               $tables,
+                               $this->extensionConfiguration['remote.']['db.'],
+                               Tx_Contentstage_Domain_Repository_ContentRepository::TYPE_REMOTE
+                       );
+                       $this->log->log($this->translate('info.push.snapshot', array($info['file'])), Tx_CabagExtbase_Utility_Logging::OK);
+                       
+                       $this->pushTables($id);
+                       $this->log->log($this->translate('info.push.done'), Tx_CabagExtbase_Utility_Logging::OK);
+                       
+                       $this->remoteRepository->clearCache($id, !!$this->extensionConfiguration['clearAllCaches']);
+                       $this->log->log($this->translate('info.push.clearCache'), Tx_CabagExtbase_Utility_Logging::OK);
+               } catch (Exception $e) {
+                       $this->log->log($this->translate('error.' . $e->getCode(), array($e->getMessage())) ?: $e->getMessage(), Tx_CabagExtbase_Utility_Logging::ERROR);
+               }
+               
+               $this->log->write();
+               $this->redirect('compare');
+       }
+
+       /**
+        * Compares all the tables.
+        *
+        * @param int $root The root id.
+        * @return void
+        */
+       protected function compareTables($root = 0) {
+               $this->_compareTables($this->localRepository, $this->remoteRepository, $root);
+       }
+
+       /**
+        * Compares all the tables.
+        *
+        * @param Tx_Contentstage_Domain_Repository_ContentRepository $fromRepository Repository to compare from.
+        * @param Tx_Contentstage_Domain_Repository_ContentRepository $toRepository Repository to compare to.
+        * @param int $root The root id.
+        * @return void
+        */
+       protected function _compareTables(Tx_Contentstage_Domain_Repository_ContentRepository $fromRepository, Tx_Contentstage_Domain_Repository_ContentRepository $toRepository, $root = 0) {
+               $tables = $fromRepository->getTables();
+               
+               foreach ($tables as $table => &$data) {
+                       if (substr($table, -3) === '_mm' || $this->ignoreSyncTables[$table]) {
+                               continue;
+                       }
+                       $this->differences[$table] = array();
+                       $resource1 = $fromRepository->findInPageTree($root, $table);
+                       $resource2 = $toRepository->findInPageTree($root, $table);
+                       
+                       $this->diff->resources($resource2, $resource1, $this->differences[$table], 'uid', $table === 'pages' ? 'uid' : 'pid');
+                       
+                       $resource1->free();
+                       $resource2->free();
+               }
+       }
+       
+       /**
+        * Push all tables in the given page tree.
+        *
+        * @param int $root The root id of the page tree.
+        * @return void
+        */
+       protected function pushTables($root = 0) {
+               $this->_pushTables($this->localRepository, $this->remoteRepository, $root);
+       }
+       
+       /**
+        * Push all tables in the given page tree.
+        *
+        * @param Tx_Contentstage_Domain_Repository_ContentRepository $fromRepository Repository to push from.
+        * @param Tx_Contentstage_Domain_Repository_ContentRepository $toRepository Repository to push to.
+        * @param int $root The root id of the page tree.
+        * @return void
+        */
+       protected function _pushTables(Tx_Contentstage_Domain_Repository_ContentRepository $fromRepository, Tx_Contentstage_Domain_Repository_ContentRepository $toRepository, $root = 0) {
+               $tables = $fromRepository->getTables();
+               foreach ($tables as $table => &$data) {
+                       if (substr($table, -3) === '_mm' || $this->ignoreSyncTables[$table]) {
+                               $this->log->log('ignored: ' . $table, Tx_CabagExtbase_Utility_Logging::INFORMATION);
+                               continue;
+                       }
+                       
+                       $resource = $fromRepository->findInPageTree($root, $table);
+                       $this->pushTable($resource, $toRepository);
+               }
+               
+               $this->pushDependencies($fromRepository, $toRepository);
+       }
+       
+       /**
+        * Resolves and pushes dependencies.
+        *
+        * @param Tx_Contentstage_Domain_Repository_ContentRepository $fromRepository Repository to push from.
+        * @param Tx_Contentstage_Domain_Repository_ContentRepository $toRepository Repository to push to.
+        * @return void
+        */
+       protected function pushDependencies(Tx_Contentstage_Domain_Repository_ContentRepository $fromRepository, Tx_Contentstage_Domain_Repository_ContentRepository $toRepository) {
+               $this->log->log($this->translate('info.push.dependencies'), Tx_CabagExtbase_Utility_Logging::OK);
+               
+               do {
+                       $relations = $fromRepository->getUnresolvedRelations();
+                       $unSynced = $fromRepository->setRelationsSynced();
+                       
+                       $this->pushFiles($fromRepository, $toRepository, $relations['__FILE'] ?: array());
+                       $this->pushFiles($fromRepository, $toRepository, $relations['__FOLDER'] ?: array());
+                       
+                       foreach ($relations as $table => &$data) {
+                               if (is_array($data) && isset($data[0])) {
+                                       unset($data[0]);
+                               }
+                               if (substr($table, 0, 2) === '__' || empty($data)) {
+                                       continue;
+                               }
+                               
+                               if (substr($table, -3) === '_mm') {
+                                       $localUids = implode(',', array_keys($data));
+                                       $toRepository->_sql('DELETE FROM ' . $table . ' WHERE uid_local IN (' . $localUids . ')', false);
+                                       $where = 'uid_local IN (' . $localUids . ')';
+                               } else {
+                                       $where = 'uid IN (' . implode(',', array_keys($data)) . ')';
+                               }
+                               
+                               $resource = $fromRepository->findInPageTree(0, $table, '*', $where, '', '');
+                               $this->pushTable($resource, $toRepository);
+                       }
+               } while ($unSynced > 0);
+               
+               $sysLogResource = $fromRepository->findResolvedSysLog();
+               $this->pushTable($sysLogResource, $toRepository);
+               
+               $sysHistoryResource = $fromRepository->findResolvedSysHistory();
+               $sysHistoryResource->setTable('sys_history');
+               $this->pushTable($sysHistoryResource, $toRepository);
+       }
+       
+       /**
+        * Pushes a single table.
+        *
+        * @param Tx_Contentstage_Domain_Repository_Result $resource The db resource to get the data from.
+        * @param Tx_Contentstage_Domain_Repository_ContentRepository $toRepository Repository to push to.
+        */
+       protected function pushTable(Tx_Contentstage_Domain_Repository_Result $resource, Tx_Contentstage_Domain_Repository_ContentRepository $toRepository) {
+               $toRepository->insert($resource);
+               
+               $table = $resource->getTable();
+               $tcaName = $this->tca->getTableName($table);
+               
+               $this->log->log(
+                       $this->translate(
+                               'info.push.table',
+                               array(
+                                       (empty($tcaName) || $table === $tcaName ? $table : '"' . $tcaName . '" (' . $table . ')'),
+                                       $resource->count()
+                               )
+                       ),
+                       $resource->count() > 0 ? Tx_CabagExtbase_Utility_Logging::OK : Tx_CabagExtbase_Utility_Logging::INFORMATION
+               );
+               
+               $resource->free();
+       }
+       
+       /**
+        * Pushes files.
+        *
+        * @param Tx_Contentstage_Domain_Repository_ContentRepository $fromRepository Repository to push from.
+        * @param Tx_Contentstage_Domain_Repository_ContentRepository $toRepository Repository to push to.
+        * @param array $files The files to push.
+        * @return void
+        */
+       protected function pushFiles(Tx_Contentstage_Domain_Repository_ContentRepository $fromRepository, Tx_Contentstage_Domain_Repository_ContentRepository $toRepository, array $files) {
+               $filesOK = 0;
+               $errors = 0;
+               foreach ($files as $file => &$ignored) {
+                       $this->log->log(
+                               $this->translate(
+                                       'info.push.file',
+                                       array($fromHandle, $toHandle)
+                               ),
+                               Tx_CabagExtbase_Utility_Logging::INFORMATION
+                       );
+                       
+                       $fromHandle = $fromRepository->getFileHandle($file);
+                       $toHandle = $toRepository->getFileHandle($file);
+                       if ($toRepository->copy($fromHandle, $toHandle)) {
+                               $filesOK++;
+                       } else {
+                               $errors++;
+                       }
+               }
+               
+               $this->log->log(
+                       $this->translate('info.push.files', array($filesOK + $errors, $filesOK, $errors)),
+                       $errors > 0 ? Tx_CabagExtbase_Utility_Logging::WARNING : ($filesOK > 0 ? Tx_CabagExtbase_Utility_Logging::OK : Tx_CabagExtbase_Utility_Logging::INFORMATION),
+                       $files
+               );
+       }
+       
+       /**
+        * Generates the pid index from the local differences.
+        */
+       protected function generatePidIndex() {
+               foreach ($this->differences as $table => &$data) {
+                       if (isset($data['byPid'])) {
+                               foreach ($data['byPid'] as $pid => &$changes) {
+                                       $this->pidIndex[$pid][$table] = &$changes;
+                                       $this->pageTree[$pid]['_differences'][$table] = &$changes;
+                               }
+                       }
+               }
+       }
+}
+?>
\ No newline at end of file
diff --git a/Classes/Controller/InitializeController.php b/Classes/Controller/InitializeController.php
new file mode 100644 (file)
index 0000000..8c80674
--- /dev/null
@@ -0,0 +1,147 @@
+<?php
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Nils Blattner <nb@cabag.ch>, cab services ag
+ *  
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ *
+ *
+ * @package contentstage
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
+ *
+ */
+class Tx_Contentstage_Controller_InitializeController extends Tx_Contentstage_Controller_BaseController {
+       /**
+        * @var array The db info to write to.
+        */
+       protected $toInfo;
+       
+       /**
+        * @var Tx_Contentstage_Domain_Repository_ContentRepository The repository to write to.
+        */
+       protected $toRepository;
+       
+       /**
+        * @var array The type to write to.
+        */
+       protected $toType;
+       
+       /**
+        * @var array The db info to read from.
+        */
+       protected $fromInfo;
+       
+       /**
+        * @var Tx_Contentstage_Domain_Repository_ContentRepository The repository to read from.
+        */
+       protected $fromRepository;
+       
+       /**
+        * @var array The type to read from.
+        */
+       protected $fromType;
+
+       /**
+        * action initalize
+        *
+        * @return void
+        */
+       public function showAction() {
+               
+       }
+
+       /**
+        * action doInitialize
+        *
+        * @param string $direction Either 'down' which overwrites the local installation or 'up' which overwrites the remote installation!
+        * @return void
+        */
+       public function doInitializeAction($direction = 'down') {
+               $this->initializeDirection($direction);
+               
+               $step = $this->extensionConfiguration['autoIncrementStep'];
+               $threshold = $this->extensionConfiguration['autoIncrementThreshold'];
+               
+               try {
+                       $tables = $this->filterTables(array_keys($this->toRepository->getTables()), $this->ignoreSnapshotTables);
+                       $backupInfo = $this->snapshotRepository->create(
+                               $tables,
+                               $this->toInfo,
+                               $this->toType
+                       );
+                       
+                       $this->log->log($this->translate('info.init.backup', array($backupInfo['file'])), Tx_CabagExtbase_Utility_Logging::OK);
+                       
+                       // do not log the active users out
+                       $tables = $this->filterTables(array_keys($this->fromRepository->getTables()), $this->ignoreSnapshotTables);
+                       $snapshotInfo = $this->snapshotRepository->create(
+                               array_keys($tables),
+                               $this->fromInfo,
+                               $this->fromType
+                       );
+                       
+                       $this->log->log($this->translate('info.init.dumped', array($snapshotInfo['file'])), Tx_CabagExtbase_Utility_Logging::OK);
+                       
+                       $revertInfo = $this->snapshotRepository->revert(
+                               $snapshotInfo['file'],
+                               $this->toInfo
+                       );
+                       
+                       $this->log->log($this->translate('info.init.reverted', array($revertInfo['file'])), Tx_CabagExtbase_Utility_Logging::OK);
+                       
+                       $raiseInfo = $this->snapshotRepository->raiseAutoIncrement($this->toRepository, $step, $threshold);
+                       
+                       $this->log->log($this->translate('info.init.raised', array($raiseInfo['newAutoIncrement'])), Tx_CabagExtbase_Utility_Logging::OK);
+               } catch (Exception $e) {
+                       $this->log->log($this->translate('error.' . $e->getCode(), array($e->getMessage())), Tx_CabagExtbase_Utility_Logging::ERROR);
+               }
+               
+               $this->log->write();
+               $this->redirect('show');
+       }
+
+       /**
+        * Initialize the directional fields.
+        *
+        * @param string $direction Either 'down' which overwrites the local installation or 'up' which overwrites the remote installation!
+        */
+       protected function initializeDirection($direction = 'down') {
+               if ($direction === 'up') {
+                       $this->toInfo = $this->extensionConfiguration['remote.']['db.'];
+                       $this->toRepository = $this->remoteRepository;
+                       $this->toType = Tx_Contentstage_Domain_Repository_ContentRepository::TYPE_REMOTE;
+                       $this->fromInfo = $this->getLocalDbInfo();
+                       $this->fromRepository = $this->localRepository;
+                       $this->fromType = Tx_Contentstage_Domain_Repository_ContentRepository::TYPE_LOCAL;
+               } else {
+                       $this->toInfo = $this->getLocalDbInfo();
+                       $this->toRepository = $this->localRepository;
+                       $this->toType = Tx_Contentstage_Domain_Repository_ContentRepository::TYPE_LOCAL;
+                       $this->fromInfo = $this->extensionConfiguration['remote.']['db.'];
+                       $this->fromRepository = $this->remoteRepository;
+                       $this->fromType = Tx_Contentstage_Domain_Repository_ContentRepository::TYPE_REMOTE;
+               }
+       }
+}
+?>
\ No newline at end of file
diff --git a/Classes/Controller/SnapshotController.php b/Classes/Controller/SnapshotController.php
new file mode 100644 (file)
index 0000000..0094ad7
--- /dev/null
@@ -0,0 +1,117 @@
+<?php
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Nils Blattner <nb@cabag.ch>, cab services ag
+ *  
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ *
+ *
+ * @package contentstage
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
+ *
+ */
+class Tx_Contentstage_Controller_SnapshotController extends Tx_Contentstage_Controller_BaseController {
+
+       /**
+        * action list
+        *
+        * @return void
+        */
+       public function listAction() {
+               $snapshots = $this->snapshotRepository->findAll();
+               $this->view->assign('snapshots', $snapshots);
+       }
+
+       /**
+        * action create
+        *
+        * @param string $type 'local' or 'remote'.
+        * @return void
+        */
+       public function createAction($type = Tx_Contentstage_Domain_Repository_ContentRepository::TYPE_LOCAL) {
+               $info = $this->getLocalDbInfo();
+               $repository = $this->localRepository;
+               
+               if ($type === Tx_Contentstage_Domain_Repository_ContentRepository::TYPE_REMOTE) {
+                       $info = $this->extensionConfiguration['remote.']['db.'];
+                       $repository = $this->remoteRepository;
+               }
+               
+               try {
+                       $tables = $this->filterTables(array_keys($repository->getTables()), $this->ignoreSnapshotTables);
+                       $info = $this->snapshotRepository->create($tables, $info, $type);
+                       $this->log->log($this->translate('info.snapshot.done', array(basename($info['file']))), Tx_CabagExtbase_Utility_Logging::OK);
+               } catch (Exception $e) {
+                       $this->log->log($this->translate('error.' . $e->getCode(), array($e->getMessage())) ?: $e->getMessage(), Tx_CabagExtbase_Utility_Logging::ERROR);
+               }
+               
+               $this->log->write();
+               $this->redirect('list');
+       }
+
+       /**
+        * Action delete
+        *
+        * @param string $snapshot Delete this file.
+        * @return void
+        */
+       public function deleteAction($snapshot) {
+               $this->snapshotRepository->remove($snapshot);
+               $this->log->log($this->translate('info.snapshot.removed', array($snapshot)), Tx_CabagExtbase_Utility_Logging::OK);
+               $this->log->write();
+               $this->redirect('list');
+       }
+
+       /**
+        * Action revert
+        *
+        * @param string $snapshot Revert to this file.
+        * @param string $type 'local' or 'remote'.
+        * @return void
+        */
+       public function revertAction($snapshot, $type = Tx_Contentstage_Domain_Repository_ContentRepository::TYPE_LOCAL) {
+               $info = $this->getLocalDbInfo();
+               $repository = $this->localRepository;
+               
+               if ($type === Tx_Contentstage_Domain_Repository_ContentRepository::TYPE_REMOTE) {
+                       $info = $this->extensionConfiguration['remote.']['db.'];
+                       $repository = $this->remoteRepository;
+               }
+               
+               try {
+                       $tables = $this->filterTables(array_keys($repository->getTables()), $this->ignoreSnapshotTables);
+                       $newInfo = $this->snapshotRepository->create($tables, $info, $type);
+                       $this->log->log($this->translate('info.snapshot.done', array(basename($newInfo['file']))), Tx_CabagExtbase_Utility_Logging::OK);
+                       $revertInfo = $this->snapshotRepository->revert($snapshot, $info);
+                       $this->log->log($this->translate('info.snapshot.reverted', array(basename($revertInfo['file']), $type)), Tx_CabagExtbase_Utility_Logging::OK);
+               } catch (Exception $e) {
+                       $this->log->log($this->translate('error.' . $e->getCode(), array($e->getMessage())) ?: $e->getMessage(), Tx_CabagExtbase_Utility_Logging::ERROR);
+               }
+               
+               $this->log->write();
+               $this->redirect('list');
+       }
+
+}
+?>
\ No newline at end of file
diff --git a/Classes/Domain/Repository/ContentRepository.php b/Classes/Domain/Repository/ContentRepository.php
new file mode 100644 (file)
index 0000000..95b9943
--- /dev/null
@@ -0,0 +1,744 @@
+<?php
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Nils Blattner <nb@cabag.ch>, cab services ag
+ *  
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ *
+ *
+ * @package contentstage
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
+ *
+ */
+class Tx_Contentstage_Domain_Repository_ContentRepository {
+       /**
+        * @const string The cache table to write to. Might have to be changed for future versions.
+        * @see Tx_Contentstage_Eid_ClearCache::CACHE_TABLE
+        */
+       const CACHE_TABLES = 'cachingframework_cache_hash,cf_cache_hash';
+       
+       /**
+        * @const string Type local.
+        */
+       const TYPE_LOCAL = 'local';
+       
+       /**
+        * @const string Type remote.
+        */
+       const TYPE_REMOTE = 'remote';
+       
+       /**
+        * @const int Insert error code.
+        */
+       const ERROR_GET = 1355144402;
+       
+       /**
+        * @const int Insert error code.
+        */
+       const ERROR_INSERT = 1354799704;
+       
+       /**
+        * The fields to collect for the page tree.
+        *
+        * @var array
+        */
+       protected $fieldNames = array('uid', 'pid', 'title', 'deleted', 'hidden', 'tstamp', 'TSconfig');
+       
+       /**
+        * The associated folder.
+        *
+        * @var string
+        */
+       protected $folder = '';
+       
+       /**
+        * An array of table => array of uid => true pairs for all the resolved relations.
+        *
+        * @var array
+        */
+       protected $resolvedRelations = array();
+       
+       /**
+        * An array of table => array of uid => true pairs for all the unresolved relations.
+        *
+        * @var array
+        */
+       protected $unresolvedRelations = array();
+       
+       /**
+        * The internal t3lib_db.
+        *
+        * @var t3lib_db
+        */
+       protected $db = null;
+       
+       /**
+        * The associated tag (for possible cachings).
+        *
+        * @var string
+        */
+       protected $tag = '';
+       
+       /**
+        * The selected database.
+        *
+        * @var string
+        */
+       protected $database = '';
+       
+       /**
+        * The cache.
+        *
+        * @var t3lib_cache_frontend_AbstractFrontend The cache.
+        */
+       protected $cache = null;
+       
+       /**
+        * The logging object.
+        *
+        * @var Tx_CabagExtbase_Utility_Logging The logging object.
+        */
+       protected $log = null;
+       
+       /**
+        * @var Tx_Extbase_Object_ObjectManagerInterface
+        */
+       protected $objectManager;
+
+       /**
+        * Injects the object manager
+        *
+        * @param Tx_Extbase_Object_ObjectManagerInterface $objectManager
+        * @return void
+        */
+       public function injectObjectManager(Tx_Extbase_Object_ObjectManagerInterface $objectManager) {
+               $this->objectManager = $objectManager;
+       }
+       
+       /**
+        * Constructor.
+        *
+        * @param t3lib_db $db The t3lib_db connection.
+        * @param Tx_CabagExtbase_Utility_Logging $log The logging object.
+        * @param t3lib_cache_frontend_AbstractFrontend $cache The cache to use.
+        * @param string $tag The local tag to use while caching.
+        */
+       public function __construct(t3lib_db $db, Tx_CabagExtbase_Utility_Logging $log, t3lib_cache_frontend_AbstractFrontend $cache, $tag = 'ContentRepository') {
+               $this->db = $db;
+               $this->log = $log;
+               $this->cache = $cache;
+               $this->tag = $tag;
+               $res = $db->sql_query('SELECT DATABASE();');
+               if (($row = $db->sql_fetch_row($res)) !== false) {
+                       $this->database = current($row);
+               }
+       }
+       
+       /**
+        * Set the folder.
+        *
+        * @param string $folder The associated folder.
+        * @return void
+        */
+       public function setFolder($folder) {
+               $folder = preg_replace(
+                       array(
+                               '/\.{2,}/',
+                               '#/+#',
+                               '#/$#'
+                       ),
+                       array(
+                               '',
+                               '/',
+                               ''
+                       ),
+                       $folder
+               );
+               if (!is_dir($folder)) {
+                       throw new Exception(sprintf($this->translate('fatal.remoteFolder'), $folder), 1355153307);
+               }
+               $this->folder = $folder .  '/';
+       }
+       
+       /**
+        * Get the folder.
+        *
+        * @return string The associated folder.
+        */
+       public function getFolder() {
+               return $this->folder;
+       }
+       
+       /**
+        * Returns a handle for a given file.
+        * Possibility to change to some sort of rsync://path or similar.
+        *
+        * @param string $file File relative to the $this->folder.
+        * @return string The absolute file handle.
+        */
+       public function getFileHandle($file) {
+               return $this->folder . $file;
+       }
+       
+       /**
+        * Copy given file to destination.
+        * Possibility to change to some sort of rsync://path or similar.
+        *
+        * @param string $fromFile File handle to copy from.
+        * @param string $toFile File handle to copy to.
+        * @return void
+        */
+       public function copy($fromFile, $toFile) {
+               if (!file_exists($fromFile)) {
+                       $this->log->log($this->translate('copy.fileMissing', array($fromFile)), Tx_CabagExtbase_Utility_Logging::WARNING);
+                       return false;
+               }
+               if (!is_dir(dirname($toFile))) {
+                       $ok = mkdir(dirname($toFile), octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask']), true);
+                       if (!$ok) {
+                               $this->log->log($this->translate('copy.targetFolder', array(dirname($toFile))), Tx_CabagExtbase_Utility_Logging::WARNING);
+                               return $false;
+                       }
+               }
+               return copy($fromFile, $toFile);
+       }
+       
+       /**
+        * Returns the full page tree.
+        *
+        * @return array An array of the root pages with all subpages given with the key '_children' recursively.
+        */
+       public function &getFullPageTree() {
+               $identifier = 'tx_contentstage_ContentRepository_getFullPageTree_' . $this->tag;
+               if (TX_CONTENTSTAGE_USECACHE && $this->cache->has($identifier)) {
+                       return $this->cache->get($identifier);
+               }
+               $this->log->log($this->translate('pageTree.rebuild', array($this->tag)), Tx_CabagExtbase_Utility_Logging::INFORMATION);
+               
+               $res = $this->db->exec_SELECT_queryArray(array(
+                       'SELECT' => implode(', ', $this->fieldNames),
+                       'FROM' => 'pages',
+                       'WHERE' => '',
+                       'GROUPBY' => '',
+                       'ORDERBY' => 'sorting ASC',
+                       'LIMIT' => ''
+               ));
+               $tree = array();
+               $index = array();
+               $index[0]['_children'] = &$tree;
+               
+               while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
+                       $uid = intval($row['uid']);
+                       
+                       if (isset($index[$uid]) && isset($index[$uid]['_children'])) {
+                               $row['_children'] = &$index[$uid]['_children'];
+                       } else {
+                               $row['_children'] = array();
+                       }
+                       
+                       $index[$uid] = &$row;
+                       $index[intval($row['pid'])]['_children'][intval($row['uid'])] = &$row;
+                       unset($row);
+               }
+               
+               if (TX_CONTENTSTAGE_USECACHE) {
+                       $this->cache->set($identifier, $index, array(), TX_CONTENTSTAGE_CACHETIME);
+               }
+               $this->log->log($this->translate('pageTree.rebuilt', array($this->tag)), Tx_CabagExtbase_Utility_Logging::INFORMATION);
+               return $index;
+       }
+       
+       /**
+        * Returns an array with all the page uids for the given root (includes the root if it exists). 
+        *
+        * @param int $root The page id to start from.
+        * @return array The array with the pids.
+        */
+       public function getPageTreeUids($root = 0) {
+               $root = intval($root);
+               $tree = &$this->getFullPageTree();
+               
+               if (!isset($tree[$root])) {
+                       return array();
+               }
+               
+               return $this->_getPageTreeUids($root, $tree[$root]);
+       }
+       
+       /**
+        * Returns an array with all the page uids for the given root (includes the root). 
+        *
+        * @param int $root The page id to start from.
+        * @param array $tree The recursive tree to work on.
+        * @param array $result The optional array to store the pids in the recursion.
+        * @return array The array with the pids.
+        */
+       protected function _getPageTreeUids($root = 0, array &$tree = null, array &$result = array()) {
+               $identifier = 'tx_contentstage_ContentRepository_getPageTreeUids_' . $this->tag . '_' . $root;
+               if (TX_CONTENTSTAGE_USECACHE && $this->cache->has($identifier)) {
+                       return $this->cache->get($identifier);
+               }
+               
+               if (isset($result[$root])) {
+                       // RECURSIVE ARRAY DETECTED!!
+                       return $result;
+               }
+               
+               if ($root > 0) {
+                       $result[$root] = $root;
+               }
+               
+               if (isset($tree['_children'])) {
+                       foreach ($tree['_children'] as &$child) {
+                               $this->_getPageTreeUids(intval($child['uid']), $child, $result);
+                       }
+               }
+               
+               if (TX_CONTENTSTAGE_USECACHE) {
+                       $this->cache->set($identifier, $result, array(), TX_CONTENTSTAGE_CACHETIME);
+               }
+               return $result;
+       }
+       
+       /**
+        * Returns the rootline to a given page.
+        *
+        * @param int $page The page uid to get the rootline for.
+        * @return array The rootline, where the first item is the page and the last item is the root. Null if page not found or broken rootline!
+        */
+       public function getRootline($page) {
+               $index = &$this->getFullPageTree();
+               $rootline = array();
+               $page = intval($page);
+               
+               while (isset($index[$page]) && $page > 0) {
+                       $local = $index[$page];
+                       unset($local['_children']);
+                       $rootline[$page] = $local;
+                       $page = intval($local['pid']);
+               }
+               
+               if (empty($rootline) || $page > 0) {
+                       // not found or broken rootline respectively
+                       return array();
+               }
+               return $rootline;
+       }
+       
+       /**
+        * Returns the domain to a given page.
+        *
+        * @param int $page The page uid to get the domain for.
+        * @return string The domain
+        */
+       public function getDomain($page) {
+               $rootline = $this->getRootline($page);
+               
+               if (empty($rootline)) {
+                       return null;
+               }
+               
+               $pids = array();
+               $orderParts = array();
+               foreach ($rootline as $p) {
+                       $pid = intval($p['uid']);
+                       if ($pid <= 0) {
+                               break;
+                       }
+                       $pids[] = $pid;
+                       $orderParts[] = '(pid = ' . $pid . ') DESC';
+               }
+               $orderParts[] = 'sorting ASC';
+               $rows = $this->db->exec_SELECTgetRows(
+                       'domainName',
+                       'sys_domain',
+                       'hidden = 0 AND !redirectTo AND pid IN (' . implode(',', $pids) . ')',
+                       '',
+                       implode(', ', $orderParts),
+                       1
+               );
+               
+               return count($rows) > 0 ? $rows[0]['domainName'] : null;
+       }
+       
+       /**
+        * Returns the list of tables from the current db.
+        *
+        * @return array An array of tableName => SHOW TABLE STATUS row pairs.
+        */
+       public function getTables() {
+               return $this->_sql('SHOW TABLE STATUS FROM `' . $this->database . '`', 'Name');
+       }
+       
+       /**
+        * Returns a repository result object for the given query, but only records from within the given pagetree.
+        *
+        * @param int $root The root page to start from.
+        * @param string $table The table to query (CAN ONLY BE A SINGLE TABLE!).
+        * @param string $fields The fields to get (* by default).
+        * @param string $where The where condition (empty by default).
+        * @param string $groupBy Group the query (empty by default).
+        * @param string $orderBy Order to use on the query (uid ASC by default).
+        * @param string $limit Limit the query.
+        * @return Tx_Contentstage_Domain_Repository_Result The result object.
+        */
+       public function findInPageTree($root = 0, $table, $fields = '*', $where = '', $groupBy = '', $orderBy = 'uid ASC', $limit = '') {
+               $result = $this->objectManager->create('Tx_Contentstage_Domain_Repository_Result');
+               $result->setRepository($this);
+               $result->setTable($table);
+               $whereParts = array();
+               
+               if ($root !== 0) {
+                       $pids = $this->getPageTreeUids($root);
+                       
+                       if (empty($pids)) {
+                               $whereParts = array('1 <> 1');
+                       } else {
+                               $whereParts = array(($table === 'pages' ? 'uid' : 'pid') . ' IN (' . implode(',', $pids) . ')');
+                       }
+               }
+               if (!empty($where)) {
+                       $whereParts[] = '(' . $where . ')';
+               }
+               
+               $query = $this->db->SELECTquery($fields, $table, implode(' AND ', $whereParts), $groupBy, $orderBy, $limit);
+               
+               // this slows the process down imensely!
+               //$this->log->log($query, Tx_CabagExtbase_Utility_Logging::INFORMATION);
+               
+               $resource = $this->db->sql_query($query);
+               
+               if (!$resource || $this->db->sql_error()) {
+                       throw new Exception($this->db->sql_error() . ' [Query: ' . $this->db->SELECTquery($fields, $table, implode(' AND ', $whereParts), $groupBy, $orderBy, $limit) . ']', self::ERROR_GET);
+               }
+               
+               $result->setResource($resource);
+               return $result;
+       }
+       
+       /**
+        * Takes the resolved relations and finds the associated sys_log entries.
+        *
+        * @return Tx_Contentstage_Domain_Repository_Result The result object.
+        */
+       public function findResolvedSysLog() {
+               return $this->findInPageTree(0, 'sys_log', 'sys_log.*', $this->_getSysLogWhere());
+       }
+       
+       /**
+        * Takes the resolved relations and finds the associated sys_history entries.
+        *
+        * @return Tx_Contentstage_Domain_Repository_Result The result object.
+        */
+       public function findResolvedSysHistory() {
+               return $this->findInPageTree(0, 'sys_history LEFT JOIN sys_log ON (sys_log.uid = sys_history.sys_log_uid)', 'sys_history.*', $this->_getSysLogWhere());
+       }
+       
+       /**
+        * Creates a where condition with the resolved relations to find the associated sys_log entries.
+        *
+        * @return string The generated where.
+        */
+       protected function _getSysLogWhere() {
+               $whereParts = array();
+               
+               foreach ($this->resolvedRelations as $table => &$tableData) {
+                       if (substr($table, 0, 2) !== '__' && !empty($tableData)) {
+                               $uids = array_filter(array_keys($tableData), 'is_numeric');
+                               $uids = empty($uids) ? array(0) : $uids;
+                               $whereParts[] = '(sys_log.tablename = ' . $this->db->fullQuoteStr($table, 'sys_log') . ' AND sys_log.recuid IN (' . implode(',', $uids) . '))';
+                       }
+               }
+               
+               if (count($whereParts) === 0) {
+                       return '1 = 0';
+               }
+               
+               return implode(' OR ', $whereParts);
+       }
+       
+       /**
+        * Insert/update a given resource in the table. The resource must have the same fields, e.g. should be from the same table in another db.
+        *
+        * @param Tx_Contentstage_Domain_Repository_Result $resource The db resource to get the data from.
+        * @return void.
+        * @throws Exception
+        */
+       public function insert(Tx_Contentstage_Domain_Repository_Result $resource) {
+               $buffer = array();
+               $c = 0;
+               $updateTerm = false;
+               $fields = array();
+               $table = $resource->getTable();
+               
+               while (($row = $resource->nextWithRelations()) !== false) {
+                       $buffer[] = $row;
+                       //$this->log->log($table, Tx_CabagExtbase_Utility_Logging::INFORMATION, $row);
+                       
+                       if ($updateTerm === false) {
+                               $fields = array_keys($row);
+                               $update = array();
+                               foreach ($fields as &$field) {
+                                       $update[] = $field . ' = VALUES(' . $field . ')';
+                               }
+                               $updateTerm = implode(',', $update);
+                       }
+                       
+                       if ($c % 100) {
+                               $this->_insert($table, $buffer, $fields, $updateTerm);
+                               $buffer = array();
+                       }
+                       $c++;
+               }
+               // if no row was looped, fields/updateTerm are not set, but that does not matter
+               $this->_insert($table, $buffer, $fields, $updateTerm);
+       }
+       
+       /**
+        * Takes a set of rows and inserts/updates them in the table.
+        *
+        * @param string $table The table to insert into.
+        * @param array $rows The db rows to insert/update.
+        * @param array $fields The fields.
+        * @param string $updateTerm The term to add for the on duplicate statement.
+        * @return void.
+        * @throws Exception
+        */
+       protected function _insert($table, $rows, $fields, $updateTerm) {
+               if (empty($rows)) {
+                       return;
+               }
+               $query = $this->db->INSERTmultipleRows($table, $fields, $rows) . ' ON DUPLICATE KEY UPDATE ' . $updateTerm;
+               
+               $this->db->sql_query($query);
+               
+               if ($error = $this->db->sql_error()) {
+                       throw new Exception($error . ' [' . $query . ']', self::ERROR_INSERT);
+               }
+       }
+       
+       /**
+        * Adds relation dependencies.
+        *
+        * @param array $relations An array of table => array of uids.
+        * @param boolean $force Force the relations already synced.
+        * @return void
+        */
+       public function addRelations(array &$relations, $force = false) {
+               foreach ($relations as $table => &$ignored) {
+                       if (substr($table, 0, 2) === '__') {
+                               if ($table !== '__FILE' && $table !== '__FOLDER') {
+                                       unset($relations[$table]);
+                               }
+                       }
+               }
+               foreach ($relations as $table => &$uidArray) {
+                       foreach ($uidArray as $uid => &$ignored) {
+                               if ($force) {
+                                       $this->resolvedRelations[$table][$uid] = true;
+                                       if (isset($this->unresolvedRelations[$table][$uid])) {
+                                               unset($this->unresolvedRelations[$table][$uid]);
+                                       }
+                               } else if (!$this->resolvedRelations[$table][$uid]) {
+                                       $this->unresolvedRelations[$table][$uid] = true;
+                               }
+                       }
+               }
+       }
+       
+       /**
+        * Returns the unresolved dependency relations.
+        *
+        * @return array An array of table => array of uid => true.
+        */
+       public function getUnresolvedRelations() {
+               return $this->unresolvedRelations;
+       }
+       
+       /**
+        * Returns the resolved dependency relations.
+        *
+        * @return array An array of table => array of uid => true.
+        */
+       public function getResolvedRelations() {
+               return $this->resolvedRelations;
+       }
+       
+       /**
+        * Sets all relations to synced and returns the amount of relations that were set.
+        *
+        * @return int The amount of relations changed.
+        */
+       public function setRelationsSynced() {
+               $count = 0;
+               
+               foreach ($this->unresolvedRelations as $table => &$tableData) {
+                       foreach ($tableData as $uid => $ignored) {
+                               $this->resolvedRelations[$table][$uid] = true;
+                               
+                               $count++;
+                       }
+               }
+               
+               unset($this->unresolvedRelations);
+               $this->unresolvedRelations = array();
+               return $count;
+       }
+       
+       /**
+        * Sets the relation to the table/uid synced (this is a performance optimization and technically not needed).
+        *
+        * @param string $table The table.
+        * @param string $uid The uid (could be a file).
+        * @return void
+        */
+       public function setRelationSynced($table, $uid) {
+               $this->resolvedRelations[$table][$uid] = true;
+               if (isset($this->unresolvedRelations[$table][$uid])) {
+                       unset($this->unresolvedRelations[$table][$uid]);
+               }
+       }
+       
+       /**
+        * This should only be used for a remote system!
+        * Clears the cache for the given root.
+        * Note: There must be a sys_domain record in the given rootline! (This does not work for root = 0!).
+        *
+        * @param int $root The root to clear from.
+        * @param boolean $clearAll Whether to clear all caches.
+        * @return void
+        * @throws Exception
+        */
+       public function clearCache($root, $clearAll = false) {
+               $domain = $this->getDomain($root);
+               if ($clearAll) {
+                       $content = 'ALL';
+               } else {
+                       $pids = $this->getPageTreeUids($root);
+                       $content = is_array($pids) ? implode(',', $pids) : '';
+               }
+               
+               if (empty($content) || $domain === null) {
+                       // do nothing
+                       return;
+               }
+               
+               $hash = t3lib_div::getRandomHexString(32);
+               $fields = array(
+                       'identifier' => $hash,
+                       'crdate' => time(),
+                       'content' => serialize($content),
+                       'lifetime' => 120,
+                       'expires' => time() + 120
+               );
+               
+               foreach (t3lib_div::trimExplode(',', self::CACHE_TABLES, true) as $table) {
+                       $res = $this->db->sql_query('SHOW TABLES LIKE \'' . $table . '\'');
+                       if ($this->db->sql_num_rows($res) > 0) {
+                               break;
+                       }
+               }
+               
+               if ($table === 'cf_cache_hash') {
+                       unset($fields['crdate']);
+                       unset($fields['lifetime']);
+               } else {
+                       unset($fields['expires']);
+               }
+               $this->db->exec_INSERTquery($table, $fields);
+        
+               $sqlError = $this->db->sql_error();
+        if (!empty($sqlError)) {
+               throw new Exception($sqlError, 1356616552);
+        }
+               
+               $url = (t3lib_div::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://') . $domain . '/index.php?eID=tx_contentstage&hash=' . $hash;
+               $ch = curl_init($url);
+               curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
+               curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);                                                                     
+               curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+               curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
+               curl_setopt($ch, CURLOPT_SSLVERSION, 3);
+
+               $result = curl_exec($ch);
+        $data = json_decode($result);
+
+        if (empty($data->success)) {
+               $errors = array_map(function ($value) { return $value->message; }, $data->errors);
+               throw new Exception('[' . $url . '] ' . implode(', ', $errors), 1356616552);
+        }
+       }
+       
+       /**
+        * Returns the internal t3lib_db object. Only for internal use!
+        *
+        * @return t3lib_db The db.
+        * @internal
+        */
+       public function _getDb() {
+               return $this->db;
+       }
+       
+       /**
+        * Directly execute a query on the db and return the result.
+        *
+        * @param string $query The query.
+        * @param mixed $result If set to false, no result is returned. If set to true, an array with the rows is returned. If set to a string, an associated array is returned, where the $row[$result] is used as the key.
+        * @return array The assoc return array.
+        */
+       public function _sql($query, $result = true) {
+               $resource = $this->db->sql_query($query);
+               
+               if ($result === false) {
+                       $this->db->sql_free_result($resource);
+                       return;
+               }
+               
+               $output = array();
+               if ($result === true) {
+                       while (($row = $this->db->sql_fetch_assoc($resource)) !== false) {
+                               $output[] = $row;
+                       }
+               } else {
+                       $result = (string)$result;
+                       while (($row = $this->db->sql_fetch_assoc($resource)) !== false) {
+                               $output[$row[$result]] = $row;
+                       }
+               }
+               $this->db->sql_free_result($resource);
+               return $output;
+       }
+       
+       /**
+        * Translate a given key.
+        *
+        * @param string $key The locallang key.
+        * @param array $arguments If given, it will be passed to vsprintf.
+        * @return string The locallized string.
+        */
+       public function translate($key, $arguments = null) {
+               return Tx_Extbase_Utility_Localization::translate($key, 'Contentstage', $arguments);
+       }
+}
+?>
\ No newline at end of file
diff --git a/Classes/Domain/Repository/Result.php b/Classes/Domain/Repository/Result.php
new file mode 100644 (file)
index 0000000..5b1b1ab
--- /dev/null
@@ -0,0 +1,246 @@
+<?php
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Nils Blattner <nb@cabag.ch>, cab services ag
+ *  
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Pseudo repository result object.
+ *
+ * @package contentstage
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
+ *
+ */
+class Tx_Contentstage_Domain_Repository_Result {
+       /**
+        * @var Tx_Contentstage_Domain_Repository_ContentRepository The parent repository.
+        */
+       protected $repository = null;
+       
+       /**
+        * @var resource DB-resource.
+        */
+       protected $resource = false;
+       
+       /**
+        * The internal t3lib_db.
+        *
+        * @var t3lib_db
+        */
+       protected $db = null;
+       
+       /**
+        * The table of this result.
+        *
+        * @var string
+        */
+       protected $table = null;
+       
+       /**
+        * The table config array for this table.
+        *
+        * @var array
+        */
+       protected $tca = null;
+       
+       /**
+        * @var int The count of the rows retrieved.
+        */
+       protected $count = 0;
+       
+       /**
+        * @var boolean Whether or not the end of the resource was reached.
+        */
+       protected $countDone = false;
+       
+       /**
+        * The TCA utility object.
+        *
+        * @var Tx_Contentstage_Utility_Tca The TCA utility object.
+        */
+       protected $tcaObject = null;
+       
+       /**
+        * Injects the TCA utility object.
+        *
+        * @param Tx_Contentstage_Utility_Tca $diff The TCA utility object.
+        */
+       public function injectTca(Tx_Contentstage_Utility_Tca $tcaObject = null) {
+               $this->tcaObject = $tcaObject;
+       }
+       
+       /**
+        * Set the repository.
+        *
+        * @param Tx_Contentstage_Domain_Repository_ContentRepository $repository The repository.
+        * @return array A row.
+        */
+       public function setRepository(Tx_Contentstage_Domain_Repository_ContentRepository $repository) {
+               $this->repository = $repository;
+               $this->db = $this->repository->_getDb();
+       }
+       
+       /**
+        * Get the repository.
+        *
+        * @return Tx_Contentstage_Domain_Repository_ContentRepository The repository.
+        */
+       public function getRepository() {
+               return $this->repository;
+       }
+       
+       /**
+        * Set the resource.
+        *
+        * @param resource $resource The resource.
+        * @return array A row.
+        */
+       public function setResource($resource) {
+               $this->resource = $resource;
+       }
+       
+       /**
+        * Get the resource.
+        *
+        * @return resource The resource.
+        */
+       public function getResource() {
+               return $this->resource;
+       }
+       
+       /**
+        * Set the table.
+        *
+        * @param string $table The table.
+        * @return array A row.
+        */
+       public function setTable($table) {
+               $this->table = $table;
+               $this->tca = &$this->tcaObject->getProcessedTca($table);
+       }
+       
+       /**
+        * Get the table.
+        *
+        * @return string The table.
+        */
+       public function getTable() {
+               return $this->table;
+       }
+       
+       /**
+        * Returns the next available row or false.
+        *
+        * @return mixed The associative array or false.
+        */
+       public function next() {
+               $row = $this->db->sql_fetch_assoc($this->resource);
+               
+               if ($row === false) {
+                       $this->countDone = true;
+               } else {
+                       $this->count++;
+               }
+               
+               return $row;
+       }
+       
+       /**
+        * Returns the next row, with the relations resolved.
+        *
+        * @see self::next()
+        */
+       public function nextResolved() {
+               if (($row = $this->next()) !== false) {
+                       foreach ($this->tca as $field => &$config) {
+                               if (substr($field, 0, 2) === '__') {
+                                       continue;
+                               }
+                               $row[$field] = $this->tcaObject->resolve($this->repository, $this->table, $field, $row[$field], $row);
+                       }
+               }
+               
+               return $row;
+       }
+       
+       /**
+        * Returns the next row, with the relations stored.
+        *
+        * @see self::next()
+        */
+       public function nextWithRelations() {
+               if (($row = $this->next()) !== false) {
+                       $this->repository->setRelationSynced($this->table, $row['uid']);
+                       if (is_array($this->tca)) {
+                               foreach ($this->tca as $field => &$config) {
+                                       if (substr($field, 0, 2) === '__') {
+                                               continue;
+                                       }
+                                       $this->repository->addRelations($this->tcaObject->resolveUids($this->repository, $this->table, $field, $row[$field], $row));
+                               }
+                       }
+               }
+               
+               return $row;
+       }
+       
+       /**
+        * Returns all records.
+        *
+        * @param string $onlyField If $onlyField is set, the returned array will directly contain the values of that field.
+        * @return array Array of rows.
+        */
+       public function all($onlyField = null) {
+               $rows = array();
+               
+               while (($row = $this->next()) !== false) $rows[] = ($onlyField === null ? $row : $row[$onlyField]);
+               
+               return $rows;
+       }
+       
+       /**
+        * Returns the amount of rows in the result.
+        * Important: If count() is called after all rows are read, this operation is only returning the total.
+        * If count() is called before the read is done, this has to call the database for the total count!
+        *
+        * @return int The row count.
+        */
+       public function count() {
+               if (!$this->countDone) {
+                       $this->count = $this->db->sql_num_rows($this->resource);
+                       $this->countDone = true;
+               }
+               
+               return $this->count;
+       }
+       
+       /**
+        * Return the memory for the sql query.
+        *
+        * @return void
+        */
+       public function free() {
+               $this->db->sql_free_result($this->resource);
+       }
+}
+?>
diff --git a/Classes/Domain/Repository/SnapshotRepository.php b/Classes/Domain/Repository/SnapshotRepository.php
new file mode 100644 (file)
index 0000000..63d3a03
--- /dev/null
@@ -0,0 +1,264 @@
+<?php
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Nils Blattner <nb@cabag.ch>, cab services ag
+ *  
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Allows to create/revert/delete mysqldump snapshots.
+ *
+ * @package contentstage
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
+ *
+ */
+class Tx_Contentstage_Domain_Repository_SnapshotRepository {
+       /**
+        * @const string strftime()-filename for the snapshot.
+        */
+       const DUMPFILE = 'uploads/tx_contentstage/snapshots/%Y%m%d-%H%M%S_contentstage_snapshot_%type.sql.gz';
+       
+       /**
+        * @const string Write error.
+        */
+       const ERROR_WRITE = 1354723058;
+       
+       /**
+        * @const string Dump error.
+        */
+       const ERROR_DUMP = 1354723059;
+       
+       /**
+        * @const string No file error.
+        */
+       const ERROR_NOFILE = 1354723060;
+       
+       /**
+        * @const string Read error.
+        */
+       const ERROR_READ = 1354723061;
+       
+       /**
+        * @const string SQL error.
+        */
+       const ERROR_ALTER = 1354790965;
+       
+       /**
+        * @var array An array of table => true pairs to be ignored in snapshots.
+        */
+       protected $ignoreSnapshotTables = array();
+       
+       /**
+        * Creates a new snapshot.
+        *
+        * @param array $tables An array of the tables to dump.
+        * @param array $login The DB login data.
+        * @param string $type The type of the snapshot. Should be either local or remote.
+        * @return array An array with additional debug information.
+        * @throws Exception
+        */
+       public function create($tables, $login, $type = Tx_Contentstage_Domain_Repository_ContentRepository::TYPE_LOCAL) {
+               $debug = array();
+               $debug['file'] = $filename = PATH_site . strftime(str_replace(array('%type'), array($type), self::DUMPFILE));
+               
+               if (file_put_contents($filename, '') === false){
+                       throw new Exception($filename, self::ERROR_WRITE);
+               }
+               
+               @file_put_contents(dirname($filename) . '/.htaccess', 'deny from all');
+               
+               $port = (intval($login['port']) > 0 ? intval($login['port']) : ini_get('mysql.default_port')) ?: 3306;
+               
+               $debug['command'] = $datadumpcmd = Tx_Contentstage_Utility_Shell::findCmd('mysqldump').' \
+                       --quote-names \
+                       --complete-insert \
+                       --skip-comments \
+                       --port=' . $port . '\
+                       --user=' . $login['user'] . ' \
+                       --password=' . $login['password'] . ' \
+                       --host=' . $login['host'] . ' \
+                       ' . $login['database'] . ' \
+                       '.implode(' ', $tables) . ' | ' . Tx_Contentstage_Utility_Shell::findCmd('gzip');
+               
+               $dumpdata = t3lib_div::makeInstance('Tx_Contentstage_Utility_Shell');
+               if (!$dumpdata->exec($datadumpcmd, PATH_site, $filename, 'a')){
+                       throw new Exception($dumpdata->getStderr(), self::ERROR_DUMP);
+               }
+               
+               $debug['filesize'] = round((@filesize($filename)/1024)/1024, 1).' MB';
+               
+               return $debug;
+       }
+       
+       /**
+        * Revert given db to an existing snapshot.
+        *
+        * @param string $file The snapshot file. Must be relative to the snapshot dir or absolute!
+        * @param array $login The DB login data.
+        * @return array An array with additional debug information.
+        * @throws Exception
+        */
+       public function revert($file, $login) {
+               $debug = array();
+               if (substr($file, 0, 1) !== '/' && !preg_match('#[A-Z]:[/\\\\]#', $file)) {
+                       $file = PATH_site . dirname(self::DUMPFILE) . '/' . $file;
+               }
+               $debug['file'] = $filename = $file;
+               
+               if (!file_exists($filename)){
+                       throw new Exception($filename, self::ERROR_NOFILE);
+               }
+               
+               $port = (intval($login['port']) > 0 ? intval($login['port']) : ini_get('mysql.default_port')) ?: 3306;
+               
+               $debug['command'] = $datadumpcmd = Tx_Contentstage_Utility_Shell::findCmd('cat') . ' ' . escapeshellarg($filename) . ' | ' . Tx_Contentstage_Utility_Shell::findCmd('gunzip') . ' | ' . Tx_Contentstage_Utility_Shell::findCmd('mysql').' \
+                       --port=' . $port . '\
+                       --user=' . $login['user'] . ' \
+                       --password=' . $login['password'] . ' \
+                       --host=' . $login['host'] . ' \
+                       ' . $login['database'];
+               
+               $dumpdata = t3lib_div::makeInstance('Tx_Contentstage_Utility_Shell');
+               if (!$dumpdata->exec($datadumpcmd, PATH_site, $filename, 'a')){
+                       throw new Exception($dumpdata->getStderr(), self::ERROR_READ);
+               }
+               
+               return $debug;
+       }
+       
+       /**
+        * Deletes a snapshot file.
+        *
+        * @param string $file The file name to delete.
+        * @return void
+        */
+       public function remove($file) {
+               $path = PATH_site . dirname(self::DUMPFILE) . '/' . $file;
+               if (file_exists($path)) {
+                       unlink($path);
+               }
+       }
+       
+       /**
+        * Go through all tables and raise the auto_increment index for each table.
+        *
+        * @param Tx_Contentstage_Domain_Repository_ContentRepository $repository The repository to do the raise for.
+        * @param int $step The step to go up.
+        * @param float $threshold Ensures that there will be at least (1 - threshold) * step auto_increments left between the next remote uid hits the new auto_increment.
+        * @return array An array with additional debug information.
+        * @throws Exception
+        */
+       public function raiseAutoIncrement($repository, $step, $threshold) {
+               $debug = array();
+               
+               $debug['tables'] = $tables = $repository->getTables();
+               
+               $maximumAutoIncrement = 0;
+               foreach ($tables as $tableName => &$table) {
+                       $maximumAutoIncrement = max($maximumAutoIncrement, $table['Auto_increment']);
+               }
+               
+               $plusOne = ($maximumAutoIncrement % $step) > ($step * $threshold) ? 1 : 0;
+               
+               $debug['plusOne'] = $plusOne;
+               $debug['maximumAutoIncrement'] = $maximumAutoIncrement;
+               $debug['newAutoIncrement'] = $newAutoIncrement = (ceil($maximumAutoIncrement / $step) + $plusOne) * $step + 1;
+               
+               $db = $repository->_getDb();
+               foreach ($tables as $tableName => &$table) {
+                       if (intval($table['Auto_increment']) > 0) {
+                               $db->sql_query('ALTER TABLE ' . $db->quoteStr($tableName, $tableName) . ' AUTO_INCREMENT = ' . $newAutoIncrement . ';');
+                               
+                               if ($db->sql_error()){
+                                       throw new Exception('[' . $tableName . '] ' . $db->sql_error(), self::ERROR_ALTER);
+                               }
+                       }
+               }
+               
+               return $debug;
+       }
+       
+       /**
+        * Returns all snapshots.
+        *
+        * @return array Array of arrays with keys fileName and relativePath.
+        */
+       public function findAll() {
+               $files = array();
+               $relativeDirectory = dirname(self::DUMPFILE) . '/';
+               $directory = PATH_site . $relativeDirectory;
+               
+               if ($handle = opendir($directory)) {
+                       while (false !== ($file = readdir($handle))) {
+                               if (substr($file, 0, 1) !== '.' && $file !== 'index.html') {
+                                       $files[$file] = array(
+                                               'fileName' => $file,
+                                               'relativePath' => $relativeDirectory . $file,
+                                               'size' => round((@filesize($directory . $file)/1024)/1024, 1).' MB'
+                                       );
+                               }
+                       }
+                       closedir($handle);
+               }
+               krsort($files);
+               return $files;
+       }
+       
+       /**
+        * Removes the ignored tables from the given tables for a snapshot.
+        *
+        * @param array $tables An array of table names.
+        * @return array An array of table names.
+        */
+       public function removeIgnoredTablesForSnapshot($tables) {
+               $cleanTables = array();
+               
+               foreach ($tables as $table) {
+                       if (!isset($this->ignoreSnapshotTables[$table])) {
+                               $cleanTables[] = $table;
+                       }
+               }
+               
+               return $cleanTables;
+       }
+       
+       /**
+        * Sets the tables to be ignored in a snapshot.
+        *
+        * @param array $ignoreSnapshotTables An array of table => true of tables to be ignored.
+        * @return Tx_Contentstage_Domain_Repository_SnapshotRepository Self reference.
+        */
+       public function setIgnoreSnapshotTables($ignoreSnapshotTables) {
+               $this->ignoreSnapshotTables = $ignoreSnapshotTables;
+               return $this;
+       }
+       
+       /**
+        * Gets the tables to be ignored in a snapshot.
+        *
+        * @return array  An array of table => true of tables to be ignored.
+        */
+       public function getIgnoreSnapshotTables() {
+               return $this->ignoreSnapshotTables;
+       }
+}
+?>
\ No newline at end of file
diff --git a/Classes/Eid/ClearCache.php b/Classes/Eid/ClearCache.php
new file mode 100644 (file)
index 0000000..e66c9ad
--- /dev/null
@@ -0,0 +1,195 @@
+<?php
+if (!defined('PATH_typo3conf')) die ('Could not access this script directly!');
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Nils Blattner <nb@cabag.ch>, cab services ag
+ *  
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Clear cache EId.
+ *
+ * @package contentstage
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
+ *
+ */
+class Tx_Contentstage_Eid_ClearCache {
+       /**
+        * @const string The cache table to write to. Might have to be changed for future versions.
+        * @see Tx_Contentstage_Domain_Repository_ContentRepository::CACHE_TABLE
+        */
+       const CACHE_TABLES = 'cachingframework_cache_hash,cf_cache_hash';
+       
+       /**
+        * @var string The md5 hash for the call.
+        */
+       protected $hash = false;
+       
+       /**
+        * @var array The errors if any occured.
+        */
+       protected $errors = array();
+       
+       /**
+        * @var string The pages to be cleared or "ALL".
+        */
+       protected $command = '';
+       
+       /**
+        * Initialize.
+        */
+       public function initialize() {
+               $hash = t3lib_div::_GP('hash');
+               
+               if (!preg_match('/^[a-z0-9]{32}$/i', $hash)) {
+                       $this->errors[] = array(
+                               'ident' => 'badHash',
+                               'message' => 'Incorrect hash given [' . $hash . ']!'
+                       );
+                       return;
+               }
+               $this->hash = $hash;
+
+           if (!tslib_eidtools::connectDB()) {
+                       $this->errors[] = array(
+                               'ident' => 'noDb',
+                               'message' => 'Could not connect to DB!'
+                       );
+                       $this->hash = false;
+           }
+       }
+       
+       /**
+        * Clear the cache for the given hash.
+        */
+       public function clear() {
+               if ($this->hash === false) {
+                       return;
+               }
+               
+               $table = false;
+               foreach (t3lib_div::trimExplode(',', self::CACHE_TABLES, true) as $possibleTable) {
+                       $res = $GLOBALS['TYPO3_DB']->sql_query('SHOW TABLES LIKE \'' . $possibleTable . '\'');
+                       if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) {
+                               $table = $possibleTable;
+                               break;
+                       }
+               }
+               
+               if (!$table) {
+                       $this->errors[] = array(
+                               'ident' => 'noTable',
+                               'message' => 'No caching table found!'
+                       );
+                       return;
+               }
+               
+               $expires = $table === 'cf_cache_hash' ? 'expires' : 'crdate';
+               $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                       '*',
+                       $table,
+                       ($table === 'cf_cache_hash' ? 'expires > ' : '(crdate + lifetime) > ') . time() . ' AND identifier = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->hash, $table),
+                       '',
+                       $expires . ' DESC',
+                       1
+               );
+
+               if (count($rows) === 0) {
+                       $this->errors[] = array(
+                               'ident' => 'noHash',
+                               'message' => 'Hash not found in DB (or expired) [' . $this->hash . ']!'
+                       );
+                       return;
+               }
+               
+               $row = current($rows);
+               $this->command = $content = unserialize($row['content']);
+               
+               try {
+                       if ($content === 'ALL') {
+                               // fake tcemain
+                               $tceMain = t3lib_div::makeInstance('t3lib_TCEmain');
+                               $tceMain->BE_USER = new Tx_Contentstage_Eid_ClearCache_FakeBEUSER();
+                               $tceMain->BE_USER->user = array('username' => 'tx_contentstage_eId');
+                               $tceMain->admin = true;
+                               
+                               $tceMain->clear_cacheCmd('all');
+                       } else {
+                               $tsfe = t3lib_div::makeInstance('tslib_fe', $GLOBALS['TYPO3_CONF_VARS'], 0, 0);
+                               
+                               $tsfe->clearPageCacheContent_pidList($content);
+                       }
+               } catch (Exception $e) {
+                       $this->errors[] = array(
+                               'ident' => 'exception',
+                               'message' => $e->getMessage()
+                       );
+               }
+               
+               $GLOBALS['TYPO3_DB']->exec_DELETEquery(
+                       $table,
+                       'identifier = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->hash, $table)
+               );
+       }
+       
+       /**
+        * Display success/error.
+        */
+       public function display() {
+               echo json_encode(array(
+                       'success' => (count($this->errors) === 0),
+                       'errors' => $this->errors
+               ));
+       }
+       
+       /**
+        * Returns the errors (if any).
+        *
+        * @return array The errors.
+        */
+       public function getErrors() {
+               return $this->errors;
+       }
+       
+       /**
+        * Returns the cache command.
+        *
+        * @return string The page uid or "ALL".
+        */
+       public function getCommand() {
+               return $this->command;
+       }
+}
+
+/**
+ * Fake BE_USER
+ */
+class Tx_Contentstage_Eid_ClearCache_FakeBEUSER {
+       public function writelog() {}
+}
+
+$clearCache = new Tx_Contentstage_Eid_ClearCache();
+$clearCache->initialize();
+$clearCache->clear();
+$clearCache->display();
+die();
+?>
diff --git a/Classes/Utility/Diff.php b/Classes/Utility/Diff.php
new file mode 100644 (file)
index 0000000..d1ee44c
--- /dev/null
@@ -0,0 +1,264 @@
+<?php
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Nils Blattner <nb@cabag.ch>, cab services ag
+ *  
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ *
+ *
+ * @package contentstage
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
+ *
+ */
+class Tx_Contentstage_Utility_Diff {
+       
+       /**
+        * The TCA utility object.
+        *
+        * @var Tx_Contentstage_Utility_Tca The TCA utility object.
+        */
+       protected $tca = null;
+       
+       /**
+        * Injects the TCA utility object.
+        *
+        * @param Tx_Contentstage_Utility_Tca $diff The TCA utility object.
+        */
+       public function injectTca(Tx_Contentstage_Utility_Tca $tca = null) {
+               $this->tca = $tca;
+       }
+       
+       /**
+        * @var t3lib_diff Diff helper object.
+        */
+       protected $diff = null;
+       
+       /**
+        * Ensures that the local diff helper object is initialized.
+        */
+       protected function init() {
+               if ($this->diff !== null) {
+                       return;
+               }
+               $this->diff = t3lib_div::makeInstance('t3lib_diff');
+       }
+       
+       /**
+        * Diff's two rows (must be an array of key => value pairs and _children => array of children items).
+        *
+        * @param array $tree1 The source tree.
+        * @param array $tree2 The target tree.
+        * @param array $differences The difference array, passed this way for recursions etc.
+        * @param string $keyField The key field of each row (usually uid).
+        * @param string $table The table to perform the diff for. Is only used to hide certain fields. Defaults to pages.
+        * @return array An array with keys 'tree1', 'tree2', 'differences', whereas the two trees contain '_differences' keys and the 'differences' key contains an index by uid.
+        */
+       public function &rows(array &$tree1 = array(), array &$tree2 = array(), array &$differences = array(), $keyField = 'uid', $table = 'pages') {
+               $this->init();
+               $tree1Keys = $this->getKeyIndex($tree1, $table);
+               $tree2Keys = $this->getKeyIndex($tree2, $table);
+               
+               $uid = intval($tree1[$keyField]);
+               
+               if (!isset($differences[$uid])) {
+                       $differences[$uid] = array();
+               }
+               $d = &$differences[$uid];
+               
+               if ($uid !== intval($tree2[$keyField])) {
+                       $d[$keyField] = 'Internal Error! Keyfield mismatch [' . $keyField . '].';
+               }
+               unset($tree1Keys[$keyField]);
+               unset($tree2Keys[$keyField]);
+               
+               foreach ($tree1Keys as $key => &$true) {
+                       if (isset($tree2Keys[$key])) {
+                               if ((string)$tree1[$key] !== (string)$tree2[$key]) {
+                                       $d[$key] = $this->diff->makeDiffDisplay($tree1[$key], $tree2[$key]);
+                               }
+                               unset($tree2Keys[$key]);
+                       } else {
+                               $d[$key] = '<span class="diff-r">' . $this->translate('diff.source.fieldMissing', array($key)) . '</span>';
+                       }
+               }
+               
+               foreach ($tree2Keys as $key => &$true) {
+                       $d[$key] = '<span class="diff-g">' . $this->translate('diff.target.fieldMissing', array($key)) . '</span>';
+               }
+               
+               $tree1['_differences'] = &$d;
+               $tree2['_differences'] = &$d;
+               return array(
+                       'tree1' => &$tree1,
+                       'tree2' => &$tree2,
+                       'differences' => &$differences
+               );
+       }
+       
+       /**
+        * Diff's two rows recursively (must be an array of key => value pairs and _children => array of children items).
+        *
+        * @param array $tree1 The source tree.
+        * @param array $tree2 The target tree.
+        * @param array $differences The difference array, passed this way for recursions etc.
+        * @param string $keyField The key field of each row (usually uid).
+        * @param string $table The table to perform the diff for. Is only used to hide certain fields. Defaults to pages.
+        * @return array An array with keys 'tree1', 'tree2', 'differences', whereas the two trees contain '_differences' keys and the 'differences' key contains an index by uid.
+        */
+       public function &rowsRecursive(array &$tree1 = array(), array &$tree2 = array(), array &$differences = array(), $keyField = 'uid', $table = 'pages') {
+               $this->rows($tree1, $tree2, $differences, $keyField, $table);
+               
+               $this->children($tree1['_children'], $tree2['_children'], $differences, $keyField, $table);
+               
+               return array(
+                       'tree1' => &$tree1,
+                       'tree2' => &$tree2,
+                       'differences' => &$differences
+               );
+       }
+       
+       /**
+        * Diff's two arrays of rows (must be an array of array of key => value pairs and _children => array of children items).
+        *
+        * @param array $children1 The source children.
+        * @param array $children2 The target children.
+        * @param array $differences The difference array, passed this way for recursions etc.
+        * @param string $keyField The key field of each row (usually uid).
+        * @param string $table The table to perform the diff for. Is only used to hide certain fields. Defaults to pages.
+        * @return array An array with keys 'children1', 'children2', 'differences', whereas the two children arrays contain '_differences' keys and the 'differences' key contains an index by uid.
+        */
+       public function &children(array &$children1 = array(), array &$children2 = array(), array &$differences = array(), $keyField = 'uid', $table = 'pages') {
+               $this->init();
+               $children1Keys = $this->getKeyIndex($children1, $table);
+               $children2Keys = $this->getKeyIndex($children2, $table);
+               if (!isset($differences[$uid])) {
+                       $differences[$uid] = array();
+               }
+               $d = &$differences[$uid];
+               
+               foreach ($children1Keys as $uid => &$true) {
+                       if (isset($children2Keys[$uid])) {
+                               unset($children2Keys[$uid]);
+                       } else {
+                               $d[$uid] = '<span class="diff-r">' . $this->translate('diff.source.recordMissing', array($keyField, $uid)) . '</span>';
+                       }
+               }
+               
+               foreach ($children2Keys as $uid => &$true) {
+                       $d[$uid] = '<span class="diff-g">' . $this->translate('diff.target.recordMissing', array($keyField, $uid)) . '</span>';
+               }
+               
+               $children1['_differences'] = &$d;
+               $children2['_differences'] = &$d;
+               return array(
+                       'children1' => &$children1,
+                       'children2' => &$children2,
+                       'differences' => &$differences
+               );
+       }
+       
+       /**
+        * Diff's two repository resources. IMPORTANT: This function assumes that there is a total order over the key field and that they are sorted by the keyfield ascending! Basically it assumes that the key field is an integer aswell!
+        *
+        * @param Tx_Contentstage_Domain_Repository_Result $resource1 The source resource.
+        * @param Tx_Contentstage_Domain_Repository_Result $resource2 The target resource.
+        * @param array $differences The difference array, passed this way for recursions etc.
+        * @param string $keyField The key field of each row (usually uid).
+        * @param string $table The table to perform the diff for. Is only used to hide certain fields. Defaults to pages.
+        * @return array An array with keys for each $keyField found in either (or both) of the resources. These arrays contain an array with differences for each field or a lone message if the row was missing entirely.
+        */
+       public function &resources(Tx_Contentstage_Domain_Repository_Result &$resource1 = null, Tx_Contentstage_Domain_Repository_Result &$resource2 = null, array &$differences = array(), $keyField = 'uid', $pidField = 'pid', $table = 'pages') {
+               $differences = array('byPid' => array());
+               $r1 = $resource1->nextResolved();
+               $r2 = $resource2->nextResolved();
+               
+               while (true) {
+                       if ($r1 === false && $r2 === false) {
+                               break;
+                       }
+                       
+                       $uid1 = $r1 === false ? PHP_INT_MAX : $r1[$keyField];
+                       $uid2 = $r2 === false ? PHP_INT_MAX : $r2[$keyField];
+                       $r1Next = $r2Next = false;
+                       $uid = min($uid1, $uid2);
+                       
+                       if ($uid1 < $uid2) {
+                               $differences[$uid]['_sourceMissing'] = '<span class="diff-r">' . $this->translate('diff.source.recordMissing', array($keyField, $uid)) . '</span>';
+                               $r1Next = true;
+                       } else if ($uid2 < $uid1) {
+                               $differences[$uid]['_targetMissing'] = '<span class="diff-g">' . $this->translate('diff.target.recordMissing', array($keyField, $uid)) . '</span>';
+                               $r2Next = true;
+                       } else {
+                               $this->rows($r1, $r2, $differences, $keyField, $table);
+                               $r1Next = $r2Next = true;
+                       }
+                       
+                       if (!empty($differences[$uid])) {
+                               $differences['byPid'][($r1 === false ? $r2[$pidField] : $r1[$pidField])][$uid] = &$differences[$uid];
+                       }
+                       
+                       if ($r1Next) {
+                               $r1 = $resource1->nextResolved();
+                       }
+                       if ($r2Next) {
+                               $r2 = $resource2->nextResolved();
+                       }
+               }
+               
+               return $differences;
+       }
+       
+       /**
+        * Returns an index of the keys of the given array. The idea is, that keys can be set/unset without touching the original array.
+        *
+        * @param array $array The source associative array.
+        * @param string $table The table to perform the diff for. Is only used to hide certain fields. Defaults to pages
+        * @return array An array with the same keys, but no content.
+        */
+       protected function &getKeyIndex(array &$array = array(), $table = 'pages') {
+               $keys = array();
+               foreach ($array as $key => &$value) {
+                       if ($this->tca->isVisibleField($table, $key)) {
+                               $keys[$key] = true;
+                       }
+               }
+               
+               unset($keys['_children']);
+               unset($keys['_differences']);
+               
+               return $keys;
+       }
+       
+       /**
+        * Translate a given key.
+        *
+        * @param string $key The locallang key.
+        * @param array $arguments If given, it will be passed to vsprintf.
+        * @return string The locallized string.
+        */
+       public function translate($key, $arguments = null) {
+               return Tx_Extbase_Utility_Localization::translate($key, 'Contentstage', $arguments);
+       }
+}
+?>
diff --git a/Classes/Utility/Packetize.php b/Classes/Utility/Packetize.php
new file mode 100644 (file)
index 0000000..d55a943
--- /dev/null
@@ -0,0 +1,283 @@
+<?php
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Jonas Felix <jf@cabag.ch>, Nils Blattner <nb@cabag.ch>, cab services ag
+ *  
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Packetizer utility class.
+ *
+ * @package contentstage
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
+ *
+ */
+class Tx_Contentstage_Utility_Packetize {
+       private $piVars; // http post/get vars for packetize
+       private $filepreset; // presets with filelists for tar
+       private $form; // object for form widgets
+       private $lastremovedTables; // array with tables removed from an array
+       private $fileincludeliste = array(); // list of files for tar
+       private $fileexcludelist; // list of files for tar to exclude
+       
+       private $ownermod; // object of the owner module
+       
+       private $content;
+       
+       const dbdumpfile = 'dbdump.sql'; // filename (path relative to PATH_site) for db dump
+       const packagefile = '%Y%m%d-%H%M%S_contentstage_snapshot.tar.gz'; // tar archive file for all the data :-)
+       
+       public function __construct(){
+               
+               $this->filepreset['projectdata'] = array(
+                       'fileadmin',
+                       'uploads'
+               );
+               
+               $this->excludedcachetables = array(
+                       'cache_extensions',
+                       'cache_hash',
+                       'cache_imagesizes',
+                       'cache_pages',
+                       'cache_pagesection',
+                       'tx_realurl_pathcache',
+                       'tx_realurl_uniqalias',
+                       'tx_realurl_urldecodecache',
+                       'tx_realurl_urlencodecache',
+                       'tx_rtehtmlarea_acronym',
+                       'cachingframework_cache_hash',
+                       'cachingframework_cache_hash_tags',
+                       'cachingframework_cache_pages',
+                       'cachingframework_cache_pagesection',
+                       'cachingframework_cache_pagesection_tags',
+                       'cachingframework_cache_pages_tags'
+                       );
+               
+               $this->excludedindextables = array(
+                       'index_fulltext',
+                       'index_grlist',
+                       'index_phash',
+                       'index_rel',
+                       'index_section',
+                       'index_words'
+                       );
+       }
+       
+       private function packetize() {
+               global $LANG;
+               
+               $content = '';
+               
+               if(!empty($this->piVars['dbstructure']) || !empty($this->piVars['dbdata'])){
+                       $content .= $this->packetizeDatabase();
+               }
+               
+               $content .= $this->packetizeFiles();
+               
+               $content .= '<hr/>';
+               return $content;
+       }
+       
+       private function packetizeDatabase(){
+               global $LANG;
+               
+               $content = '';
+               
+               if(file_put_contents(PATH_site.self::dbdumpfile, '') === false){
+                       throw new Exception('Could not writhe db file '.PATH_site.self::dbdumpfile);
+               } else {
+                       $this->fileincludeliste[] = self::dbdumpfile;
+               }
+               
+               // get existing tables
+               $origTables = $GLOBALS['TYPO3_DB']->admin_get_tables();
+               
+               // remove obsolete tables
+               foreach($origTables as $tablename => $info){
+                       if(stristr($tablename, 'zzz_deleted') === false){
+                               $tables[] = $tablename; 
+                       }
+               }
+               
+               // get mysql port
+               $mysqlPort = ini_get('mysql.default_port');
+               
+               if($mysqlPort == '') {
+                       //$mysqlPort = 3306;
+               }
+               
+               // dump structure information
+               if(!empty($this->piVars['dbstructure'])){
+                       $content .= '<h3>Dump structure.</h3>';
+                       
+                       $structuredumpcmd = tx_cabagsla_shell::findCmd('mysqldump').' \
+                               --add-drop-table  \
+                               --quote-names \
+                               --no-data \
+                               --no-create-db \
+                               --skip-comments \
+                               --port='.$mysqlPort.'\
+                               --user='.TYPO3_db_username.' \
+                               --password='.TYPO3_db_password.' \
+                               --host='.TYPO3_db_host.' \
+                               '.TYPO3_db.' \
+                               '.implode(' ', $tables);
+                               
+                       $dumpstructure = t3lib_div::makeInstance('tx_cabagsla_shell');
+                       if(!$dumpstructure->exec($structuredumpcmd, PATH_site, self::dbdumpfile, 'w')){
+                               throw new Exception('Could not dump db structure '.$dumpstructure->getStderr());
+                       }
+                       
+                       $content .= '<div>'.$structuredumpcmd.'</div>';
+               }
+               
+               
+               if(!empty($this->piVars['dbdata'])){
+                       // remove cache tables 
+                       if(empty($this->piVars['dbincludecache'])){
+                               $content .= '<h3>'.$LANG->getLL('removecachetables').'</h3>';
+                               $tables = $this->removeTables($tables, $this->excludedcachetables);
+                               $content .= '<div>'.implode(', ', $this->lastremovedTables).'</div>';
+                       }
+                       
+                       // remove index tables 
+                       if(empty($this->piVars['dbincludeindex'])){
+                               $content .= '<h3>'.$LANG->getLL('removeindextables').'</h3>';
+                               $tables = $this->removeTables($tables, $this->excludedindextables);
+                               $content .= '<div>'.implode(', ', $this->lastremovedTables).'</div>';
+                       }
+                       
+                       // remove log tables 
+                       if(empty($this->piVars['dbincludelog'])){
+                               $content .= '<h3>'.$LANG->getLL('removelogtables').'</h3>';
+                               $tables = $this->removeTables($tables, $this->excludedlogtables);
+                               $content .= '<div>'.implode(', ', $this->lastremovedTables).'</div>';
+                       }
+                       
+                       // dump data
+                       $content .= '<h3>Dump data.</h3>';
+                       $datadumpcmd = tx_cabagsla_shell::findCmd('mysqldump').' \
+                               --quote-names \
+                               --no-create-db \
+                               --no-create-info \
+                               --complete-insert \
+                               --skip-comments \
+                               --port='.$mysqlPort.'\
+                               --user='.TYPO3_db_username.' \
+                               --password='.TYPO3_db_password.' \
+                               --host='.TYPO3_db_host.' \
+                               '.TYPO3_db.' \
+                               '.implode(' ', $tables);
+                       
+                       $dumpdata = t3lib_div::makeInstance('tx_cabagsla_shell');
+                       if(!$dumpdata->exec($datadumpcmd, PATH_site, self::dbdumpfile, 'a')){
+                               throw new Exception('Could not dump db data '.$dumpdata->getStderr());
+                       }
+                       
+                       $content .= '<div>'.$datadumpcmd.'</div>';
+               }
+               
+               $content .= '
+                       <h3>
+                               Generated successfully db dump file. Size: '.round((@filesize(PATH_site.self::dbdumpfile)/1024)/1024, 1).' MB
+                       </h3>';
+               
+               return $content;
+       }
+       
+       private function packetizeFiles(){
+               $content = '';
+               
+               if(!empty($this->piVars['filepreset'])){
+                       if(!empty($this->filepreset[$this->piVars['filepreset']])){
+                               $this->fileincludeliste = array_merge($this->fileincludeliste, $this->filepreset[$this->piVars['filepreset']]);
+                       } else {
+                               throw new Exception('Filepreset '.$this->piVars['filepreset'].' not found.');
+                       }
+               } else if(!empty($this->piVars['files'])){
+                       $this->fileincludeliste = array_merge($this->fileincludeliste, $this->piVars['files']);
+               }
+               
+               if(count($this->fileincludeliste) < 1){
+                       throw new Exception('No files in include list for packetizing');
+               } else {
+                       
+                       if(empty($this->piVars['includecachefiles'])){
+                               $this->fileexcludelist[] = 'typo3temp/\*.jpg';
+                               $this->fileexcludelist[] = 'typo3temp/\*.gif';
+                               $this->fileexcludelist[] = 'typo3temp/\*.zip';
+                               $this->fileexcludelist[] = 'typo3temp/\*temp\*';
+                               $this->fileexcludelist[] = 'typo3temp/mw_\*';
+                               $this->fileexcludelist[] = 'typo3temp/\*.cache';
+                               $this->fileexcludelist[] = 'typo3temp/\*.tbl';
+                               $this->fileexcludelist[] = 'typo3temp/\*.js';
+                               $this->fileexcludelist[] = 'typo3temp/\*.css';
+                               $this->fileexcludelist[] = 'typo3temp/\*.html';
+                               $this->fileexcludelist[] = 'typo3temp/\*.txt';
+                               $this->fileexcludelist[] = 'typo3temp/\*.xml.gz';
+                               $this->fileexcludelist[] = 'typo3conf/temp_\*';
+                               $this->fileexcludelist[] = 'typo3conf/l10n/\*.zip';
+                               $exclude = ' --exclude='.implode(' --exclude=', $this->fileexcludelist);
+                       } else {
+                               $exclude = ' ';
+                       }
+                       
+                       // remove files which do not exist
+                       foreach($this->fileincludeliste as $filekey => $filename) {
+                               if(!file_exists(PATH_site.$filename)){
+                                       unset($this->fileincludeliste[$filekey]);
+                               }
+                       }
+                       
+                       $packetizecmd =  tx_cabagsla_shell::findCmd('tar').' \
+                               -zcf '.self::packagefile.' \
+                               '.$exclude.' \
+                               '.implode(' ', $this->fileincludeliste);
+                               
+                       $packetize = t3lib_div::makeInstance('tx_cabagsla_shell');
+                       if(!$packetize->exec($packetizecmd, PATH_site)){
+                               throw new Exception('Could not tar files '.$packetize->getStderr().' '.$packetize->getCmd());
+                       }
+                       
+                       $content .= '<h3> Create tape archive package: </h3>';
+                       $content .= '<div>'.$packetizecmd.'</div>';
+                       $content .= '<div>'.$packetize->getStdout().'</div>';
+               }
+               
+               return $content;
+       }
+       
+       private function removeTables($tables, $removetables){
+               $this->lastremovedTables = array();
+               foreach($removetables as $tablename){
+                       $this->lastremovedTables[] = $tablename;
+                       $key = array_search($tablename, $tables);
+                       if($key !== false){
+                               unset($tables[$key]);
+                       }
+               }
+               
+               return $tables;
+       }
+}
+
+?>
diff --git a/Classes/Utility/Shell.php b/Classes/Utility/Shell.php
new file mode 100644 (file)
index 0000000..bf334ca
--- /dev/null
@@ -0,0 +1,135 @@
+<?php
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Jonas Felix <jf@cabag.ch>, Nils Blattner <nb@cabag.ch>, cab services ag
+ *  
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Shell utility class.
+ *
+ * @package contentstage
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
+ *
+ */
+class Tx_Contentstage_Utility_Shell {
+       private $cmd = '';
+       private $stdout = '';
+       private $stderr = '';
+       private $stderrfile;
+       
+       public function __construct(){
+               $this->stderrfile = PATH_site.'typo3temp/tx_contentstage_shell_exec_stderr';
+       }
+       
+       public function exec($cmd, $cwd, $stdoutfile = false, $stdoutfilemode = 'w'){
+               $this->stdout = '';
+               $this->stderr = '';
+               
+               $prefix = 'export LC_ALL=de_CH.UTF-8; export LANG=de_CH.UTF-8; cd '.$cwd.' ; ';
+               if (TYPO3_OS == 'WIN') {
+                       $prefix = '';
+                       $cmd = preg_replace('/\\\\\s*\r?\n/', ' ', $cmd);
+               }
+               
+               if(empty($stdoutfile)){
+                       $this->cmd = $prefix . $cmd . ' 2>' . $this->stderrfile;
+                       if(function_exists('shell_exec')) {
+                               $this->stdout = shell_exec($this->cmd);
+                       } else {
+                               exec($this->cmd, $outputarray);
+                               $this->stdout = implode("\n", $outputarray);
+                       }
+               } else {
+                       if($stdoutfilemode == 'a'){
+                               $stdoutfilemode = '>>';
+                       } else {
+                               $stdoutfilemode = '>';
+                       }
+                       $this->cmd = $prefix . $cmd . ' 2>' . $this->stderrfile . ' ' . $stdoutfilemode . $stdoutfile;
+                       if(function_exists('shell_exec')) {
+                               shell_exec($this->cmd);
+                       } else {
+                               exec($this->cmd);
+                       }
+                       $this->stdout = 'dumped into '.$stdoutfilemode.$stdoutfile;
+               }
+               
+               if(file_exists($this->stderrfile)){
+                       $this->stderr = file_get_contents($this->stderrfile);
+                       unlink($this->stderrfile);
+                       if(strlen($this->stderr) > 0){
+                               return false;
+                       } else {
+                               return true;
+                       }
+               } else {
+                       return true;
+               }
+       }
+       
+       public function getStdout() {
+               return $this->stdout;
+       }
+       
+       public function getStderr() {
+               return $this->stderr;
+       }
+
+       public function getCmd() {
+               return $this->cmd;
+       }
+       
+       static function findCmd($cmd) {
+               $binFolders = array(
+                       '',
+                       '/usr/bin/',
+                       '/usr/local/bin/',
+                       '/bin/',
+                       '/Applications/xampp/xamppfiles/bin/'
+                       );
+               $binFolders = array_merge($binFolders, t3lib_div::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['SYS']['binPath']));
+               
+               $extensions = array('');
+               
+               if (TYPO3_OS == 'WIN') {
+                       array_unshift($extensions, '.exe');
+               }
+               
+               foreach ($extensions as $extension) {
+                       $cwd = false;
+                       reset($binFolders);
+                       foreach ($binFolders as $cwd) {
+                               $which = t3lib_div::makeInstance('Tx_Contentstage_Utility_Shell');
+                               $which->exec('which ' . $cwd . $cmd . $extension, '');
+                               $stdout = $which->getStdout();
+                               if (strlen($stdout) > 0) {
+                                       return trim($stdout);
+                               }
+                       }
+               }
+
+               throw new Exception('Command not found '.$cmd);
+       }
+}
+
+?>
diff --git a/Classes/Utility/Tca.php b/Classes/Utility/Tca.php
new file mode 100644 (file)
index 0000000..847ab3e
--- /dev/null
@@ -0,0 +1,611 @@
+<?php
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Nils Blattner <nb@cabag.ch>, cab services ag
+ *  
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * TCA helper utility.
+ *
+ * @package contentstage
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
+ *
+ */
+class Tx_Contentstage_Utility_Tca implements t3lib_singleton {
+       /**
+        * @const string File field.
+        */
+       const FILE = 'file';
+       
+       /**
+        * @const string Folder field.
+        */
+       const FOLDER = 'folder';
+       
+       /**
+        * @const string 1:n relation, field is uid of the related record.
+        */
+       const RELATION_DIRECT = 'direct';
+       
+       /**
+        * @const string n:1 relation, field x in related record points to the current uid.
+        */
+       const RELATION_FOREIGN = 'foreign';
+       
+       /**
+        * @const string n:m relation with a _mm table.
+        */
+       const RELATION_MM = 'mm';
+       
+       /**
+        * @const string The locallang prefix for the current extension.
+        */
+       const LLL_PREFIX = 'LLL:EXT:contentstage/Resources/Private/Language/locallang.xml:';
+       
+       /**
+        * @var array The processed values for the TCA.
+        */
+       protected $tca = false;
+       
+       /**
+        * @var array The default fields that no TCA exists for (tstamp, crdate etc.).
+        */
+       protected $defaultFields = array(
+               'pid' => 'field.pid',
+               't3ver_oid' => 'field.t3ver_oid',
+               't3ver_id' => 'field.t3ver_id',
+               't3ver_wsid' => 'field.t3ver_wsid',
+               't3ver_label' => 'field.t3ver_label',
+               't3ver_state' => 'field.t3ver_state',
+               't3ver_stage' => 'field.t3ver_stage',
+               't3ver_count' => 'field.t3ver_count',
+               't3ver_tstamp' => 'field.t3ver_tstamp',
+               't3ver_move_id' => 'field.t3ver_move_id',
+               't3_origuid' => 'field.t3_origuid',
+               'tstamp' => 'field.tstamp',
+               'crdate' => 'field.crdate',
+               'cruser_id' => 'field.cruser_id',
+               'hidden' => 'field.hidden',
+               'sorting' => 'field.sorting',
+               'sys_language_uid' => 'field.sys_language_uid',
+               'l18n_parent' => 'field.l18n_parent',
+               'l18n_diffsource' => 'field.l18n_diffsource',
+               '_targetMissing' => 'field._targetMissing',
+               '_sourceMissing' => 'field._sourceMissing',
+       );
+       
+       /**
+        * @var array The fields that should not be displayed. Array of table. => array of field. => 0/1.
+        */
+       protected $ignoreFields = array();
+       
+       /**
+        * The cache.
+        *
+        * @var t3lib_cache_frontend_AbstractFrontend The cache.
+        */
+       protected $cache = null;
+
+       /**
+        * Initialize the cache.
+        *
+        * @return void
+        */
+       protected function initializeCache() {
+               t3lib_cache::initializeCachingFramework();
+               t3lib_cache::initContentHashCache();
+               $this->cache = $GLOBALS['typo3CacheManager']->getCache('cache_hash');
+       }
+       
+       /**
+        * Initialize the ignore fields.
+        *
+        * @param array $ignoreFields Array of table. => array of field. => 0/1.
+        * @return void
+        */
+       public function initializeIgnoreFields($ignoreFields) {
+               $this->ignoreFields = &$ignoreFields;
+       }
+       
+       /**
+        * Returns the relevant information from the TCA.
+        *
+        * @param string $table If set, only the tables part of the processed TCA is returned.
+        * @param string $field If set, only the fields part of the processed TCA is returned. (Table must be set).
+        * @return array The relevant part of the processed array.
+        */
+       public function &getProcessedTca($table = null, $field = null) {
+               $this->processTca();
+               
+               $tca = &$this->tca;
+               
+               if (is_string($table) && strlen($table) > 0) {
+                       $tca = &$tca[$table];
+                       
+                       if (is_string($field) && strlen($field) > 0) {
+                               $tca = &$tca[$field];
+                       }
+               }
+               
+               return $tca;
+       }
+       
+       /**
+        * Process the TCA.
+        *
+        * @return void
+        */
+       protected function processTca() {
+               if ($this->tca !== false) {
+                       return;
+               }
+               $this->initializeCache();
+               
+               $language = $this->translate(self::LLL_PREFIX . 'language');
+               $identifier = 'tx_contentstage_Tca_' . $language;
+               if (TX_CONTENTSTAGE_USECACHE && $this->cache->has($identifier)) {
+                       $this->tca = $this->cache->get($identifier);
+                       return;
+               }
+               
+               $this->tca = array();
+               $defaultFields = array();
+               foreach ($this->defaultFields as $field => &$label) {
+                       $defaultFields[$field] = array(
+                               '__name' => $this->translate(self::LLL_PREFIX . $label)
+                       );
+               }
+               
+               foreach ($GLOBALS['TCA'] as $table => &$tableData) {
+                       $this->tca[$table] = $defaultFields;
+                       $this->tca[$table]['__name'] = $this->translate($tableData['ctrl']['title']);
+                       $this->tca[$table]['__labelField'] = $tableData['ctrl']['label'];
+                       
+                       t3lib_div::loadTCA($table);
+                       foreach ($tableData['columns'] as $field => &$fieldData) {
+                               $this->processTcaField($table, $field, $fieldData['config'], $fieldData['label']);
+                       }
+               }
+               
+               if (TX_CONTENTSTAGE_USECACHE) {
+                       $this->cache->set($identifier, $this->tca, array(), TX_CONTENTSTAGE_CACHETIME);
+               }
+       }
+       
+       /**
+        * Process a TCA field.
+        * TODO: 
+        * - select:neg_foreign_table
+        * - irre:foreign_selector
+        * IGNORED:
+        * - irre:foreign_table_field: irrelevant
+        * - irre: symmetric stuff: irrelevant
+        *
+        * @param string $table The table of the field.
+        * @param string $field The field.
+        * @param array $config The field config.
+        * @param string $label The The label of the field (may be LLL:-reference).
+        * @return void
+        */
+       protected function processTcaField($table, $field, &$config, $label) {
+               $processed = array();
+               switch (strtolower($config['type'])) {
+                       case 'group':
+                               switch (strtolower($config['internal_type'])) {
+                                       case 'file':
+                                       case 'file_reference':
+                                               $processed = array(
+                                                       'type' => self::FILE,
+                                                       'folder' => preg_replace('#[/\\\\]?$#', '/', $config['uploadfolder'])
+                                               );
+                                               break;
+                                       
+                                       case 'folder':
+                                               $processed = array(
+                                                       'type' => self::FOLDER
+                                               );
+                                               break;
+                                               
+                                       case 'db':
+                                               if ($config['MM']) {
+                                                       $processed = array(
+                                                               'type' => self::RELATION_MM,
+                                                               'table' => $config['allowed'],
+                                                               'mmTable' => $config['MM']
+                                                       );
+                                               }
+                                               break;
+                                               
+                                       default:
+                                               break;
+                               }
+                               break;
+                               
+                       case 'radio':
+                       case 'select':
+                               if (empty($config['foreign_table'])) {
+                                       if (!empty($config['fileFolder'])) {
+                                               $processed = array(
+                                                       'type' => self::FILE,
+                                                       'folder' => preg_replace('#[/\\\\]$#', '/', $config['fileFolder'])
+                                               );
+                                               break;
+                                       }
+                               }
+                               $processed = array(
+                                       'type' => self::RELATION_DIRECT,
+                                       'table' => $config['foreign_table']
+                               );
+                               
+                               if (is_array($config['items']) && count($config['items']) > 0) {
+                                       $itemIndex = array();
+                                       foreach ($config['items'] as $item) {
+                                               $itemIndex[$item[1]] = $this->translate($item[0]);
+                                       }
+                                       $processed['items'] = $itemIndex;
+                               }
+                               
+                               if (!empty($config['MM'])) {
+                                       $processed['type'] = self::RELATION_MM;
+                                       $processed['mmTable'] = $config['MM'];
+                               }
+                               
+                               break;
+                       
+                       case 'inline':
+                               $processed = array(
+                                       'type' => self::RELATION_DIRECT,
+                                       'table' => $config['foreign_table']
+                               );
+                               
+                               if (!empty($config['foreign_field'])) {
+                                       $processed['type'] = self::RELATION_FOREIGN;
+                                       $processed['foreignField'] = $config['foreign_field'];
+                               } else if (!empty($config['MM'])) {
+                                       $processed['type'] = self::RELATION_MM;
+                                       $processed['mmTable'] = $config['MM'];
+                               }
+                               break;
+                               
+                       default:
+                               break;
+               }
+               
+               $processed['__name'] = $this->translate($label);
+               $this->tca[$table][$field] = $processed;
+       }
+       
+       /**
+        * Returns the name of the given table.
+        *
+        * @param string $table The table to get the name for.
+        * @return string The table name.
+        */
+       public function getTableName($table) {
+               $this->processTca();
+               return $this->tca[$table]['__name'] ?: $table;
+       }
+       
+       /**
+        * Returns the name of the given field.
+        *
+        * @param string $table The table.
+        * @param string $field The field to get the name for.
+        * @return string The field name.
+        */
+       public function getFieldName($table, $field) {
+               $this->processTca();
+               return $this->tca[$table][$field]['__name'] ?: $field;
+       }
+       
+       /**
+        * Returns the label field of the given table.
+        *
+        * @param string $table The table.
+        * @return string The label field.
+        */
+       public function getLabelField($table) {
+               $this->processTca();
+               return $this->tca[$table]['__labelField'];
+       }
+       
+       /**
+        * Returns the if the given field should be displayed or not.
+        *
+        * @param string $table The table.
+        * @param string $field The field.
+        * @return boolean true if it should be visible, false otherwise.
+        */
+       public function isVisibleField($table, $field) {
+               $_table = $table . '.';
+               if (isset($this->ignoreFields['__all.'][$field]) && !empty($this->ignoreFields['__all.'][$field])) {
+                       return false;
+               }
+               
+               return !isset($this->ignoreFields[$_table][$field]) || empty($this->ignoreFields[$_table][$field]);
+       }
+       
+       /**
+        * Resolves the relations for a given table/field/value pair.
+        *
+        * @param Tx_Contentstage_Domain_Repository_ContentRepository $repository The repository to get the data from.
+        * @param string $table The table.
+        * @param string $field The field.
+        * @param string $value The value in the db.
+        * @param array $row The full row, used for the uid in it.
+        * @return string The string representation of the resolved field.
+        */
+       public function resolve($repository, $table, $field, $value, &$row) {
+               $config = &$this->getProcessedTca($table, $field);
+               switch ($config['type']) {
+                       case self::RELATION_DIRECT:
+                               $value = $this->resolveDirect($repository, $config, $value);
+                               break;
+                               
+                       case self::RELATION_FOREIGN:
+                               $value = $this->resolveForeign($repository, $config, $row['uid']);
+                               break;
+                               
+                       case self::RELATION_MM:
+                               $value = $this->resolveMM($repository, $config, $row['uid']);
+                               break;
+                               
+                       default:
+                               break;
+               }
+               
+               if (is_array($value)) {
+                       $value = implode(', ', $value);
+               }
+               
+               return $value;
+       }
+       
+       /**
+        * Resolves the relations for a given table/field/value pair. This does not necessarily go and check the record if not necessary and can only return the uids.
+        *
+        * @param Tx_Contentstage_Domain_Repository_ContentRepository $repository The repository to get the data from.
+        * @param string $table The table.
+        * @param string $field The field.
+        * @param string $value The value in the db.
+        * @param array $row The full row, used for the uid in it.
+        * @return array The table/uid or folder relations.
+        */
+       public function &resolveUids($repository, $table, $field, $value, &$row) {
+               $config = &$this->getProcessedTca($table, $field);
+               $result = array();
+               switch ($config['type']) {
+                       case self::RELATION_DIRECT:
+                               $result = &$this->resolveDirectUids($config, $value);
+                               break;
+                               
+                       case self::RELATION_FOREIGN:
+                               $result = &$this->resolveForeignUids($repository, $config, $row['uid'], 'uid');
+                               break;
+                               
+                       case self::RELATION_MM:
+                               $result = &$this->resolveMMUids($repository, $config, $row['uid']);
+                               $result[$config['mmTable']][$row['uid']] = true;
+                               break;
+                               
+                       case self::FILE:
+                               $key = '__FILE';
+                               
+                       case self::FOLDER:
+                               $key = $key ?: '__FOLDER';
+                               $files = t3lib_div::trimExplode(',', $value, true);
+                               $fileIndex = array();
+                               foreach ($files as $file) {
+                                       $fileIndex[$config['folder'] . $file] = true;
+                               }
+                               $result[$key] = $fileIndex;
+                               break;
+                               
+                       default:
+                               break;
+               }
+               
+               return $result;
+       }
+       
+       /**
+        * Resolves the direct relation for a given table/field/value pair.
+        *
+        * @param Tx_Contentstage_Domain_Repository_ContentRepository $repository The repository to get the data from.
+        * @param array $config The config.
+        * @param string $value The value in the db.
+        * @param string $returnField The field to return into the value.
+        * @return string The string representation of the resolved field.
+        */
+       protected function resolveDirect(Tx_Contentstage_Domain_Repository_ContentRepository $repository, $config, &$value, $returnField = null) {
+               
+               $uidsByTable = &$this->resolveDirectUids($config, $value);
+               
+               $this->resolveTables($repository, $uidsByTable, $returnField);
+               
+               return implode(', ', array_map(function (&$tableValues) {
+                       return implode(', ', $tableValues);
+               }, $uidsByTable));
+       }
+       
+       /**
+        * Resolves the direct relation for a given table/field/value pair and returns the uids.
+        *
+        * @param array $config The config.
+        * @param string $value The value in the db.
+        * @return array The table/uids.
+        */
+       protected function &resolveDirectUids($config, &$value) {
+               $uids = t3lib_div::trimExplode(',', $value, true);
+               
+               $uidsByTable = array();
+               
+               foreach ($uids as $itemValue) {
+                       if (is_array($config['items']) && isset($config['items'][$itemValue])) {
+                               $uidsByTable['__item'][] = $config['items'][$itemValue];
+                       } else {
+                               $parts = t3lib_div::trimExplode('_', $itemValue);
+                               $uid = array_pop($parts);
+                               $table = (count($parts) > 0 ? implode('_', $parts) : $config['table']);
+                               if (is_numeric($uid) && !empty($table)) {
+                                       $uidsByTable[$table][intval($uid)] = intval($uid);
+                               } else {
+                                       $uidsByTable['__passthrough'][] = $itemValue;
+                               }
+                       }
+               }
+               
+               return $uidsByTable;
+       }
+       
+       /**
+        * Resolves the mm relation for a given table/field/uid pair.
+        *
+        * @param Tx_Contentstage_Domain_Repository_ContentRepository $repository The repository to get the data from.
+        * @param array $config The config.
+        * @param string $localUid The uid of the record to resolve.
+        * @param string $returnField The field to return into the value.
+        * @return string The string representation of the resolved field.
+        */
+       protected function resolveMM(Tx_Contentstage_Domain_Repository_ContentRepository $repository, $config, $localUid, $returnField = null) {
+               $uidsByTable = $this->resolveMMUids($repository, $config, $localUid);
+               
+               $this->resolveTables($repository, $uidsByTable, $returnField);
+               
+               return implode(', ', array_map(function (&$value) {
+                       return implode(', ', $value);
+               }, $uidsByTable));
+       }
+       
+       /**
+        * Resolves the mm relation uids for a given table/field/uid pair.
+        *
+        * @param Tx_Contentstage_Domain_Repository_ContentRepository $repository The repository to get the data from.
+        * @param array $config The config.
+        * @param string $localUid The uid of the record to resolve.
+        * @return string The string representation of the resolved field.
+        */
+       protected function &resolveMMUids(Tx_Contentstage_Domain_Repository_ContentRepository $repository, $config, $localUid) {
+               $resource = $repository->findInPageTree(
+                       0,
+                       $config['mmTable'],
+                       '*',
+                       'uid_local = ' . $localUid,
+                       '',
+                       ''
+               );
+               
+               $uidsByTable = array();
+               while (($row = $resource->next()) !== false) {
+                       $uidsByTable[($row['tablenames'] ?: $config['table'])][$row['uid_foreign']] = $row['uid_foreign'];
+               }
+               
+               return $uidsByTable;
+       }
+       
+       /**
+        * Resolves the foreign relation for a given table/field/uid pair.
+        *
+        * @param Tx_Contentstage_Domain_Repository_ContentRepository $repository The repository to get the data from.
+        * @param array $config The config.
+        * @param string $localUid The uid of the record to resolve.
+        * @param string $returnField The field to return into the value.
+        * @return string The string representation of the resolved field.
+        */
+       protected function resolveForeign(Tx_Contentstage_Domain_Repository_ContentRepository $repository, $config, $localUid, $returnField = null) {
+               $values = &$this->resolveForeignUids($repository, $config, $localUid, $returnField);
+               
+               return implode(', ', $values[$config['table']]);
+       }
+       
+       /**
+        * Resolves the foreign relation for a given table/field/uid pair and returns the table/uid pair.
+        *
+        * @param Tx_Contentstage_Domain_Repository_ContentRepository $repository The repository to get the data from.
+        * @param array $config The config.
+        * @param string $localUid The uid of the record to resolve.
+        * @param string $returnField The field to return into the value.
+        * @return string The string representation of the resolved field.
+        */
+       protected function &resolveForeignUids(Tx_Contentstage_Domain_Repository_ContentRepository $repository, $config, $localUid, $returnField = null) {
+               $labelField = $this->getLabelField($config['table']);
+               $resource = $repository->findInPageTree(
+                       0,
+                       $config['table'],
+                       ($returnField !== null ? $returnField . ', ' : '') . $labelField,
+                       $config['foreignField'] . ' = ' . $localUid,
+                       '',
+                       $config['foreignField'] . ' ASC'
+               );
+               
+               $values = array($config['table'] => array());
+               while (($row = $resource->next()) !== false) {
+                       $values[$config['table']][$row['uid']] = $row[($returnField ?: $labelField)];
+               }
+               
+               return $values;
+       }
+       
+       /**
+        * Resolves the table => array of uids array.
+        *
+        * @param Tx_Contentstage_Domain_Repository_ContentRepository $repository The repository to get the data from.
+        * @param array $uidsByTable The array with table => uids pairs.
+        * @param string $returnField The field to return into the value.
+        * @return string The string representation of the resolved field.
+        */
+       protected function resolveTables(Tx_Contentstage_Domain_Repository_ContentRepository $repository, &$uidsByTable, $returnField = null) {
+               foreach ($uidsByTable as $table => &$uidData) {
+                       if (substr($table, 0, 2) === '__') {
+                               continue;
+                       }
+                       
+                       $labelField = $this->getLabelField($table);
+                       $resource = $repository->findInPageTree(
+                               0,
+                               $table,
+                               ($returnField !== null ? $returnField . ', ' : '') . $labelField,
+                               'uid IN (' . implode(',', $uidData) . ')',
+                               '',
+                               'uid ASC'
+                       );
+                       
+                       $uidData = $resource->all($returnField ?: $labelField);
+               }
+       }
+       
+       /**
+        * Translate a given local lang reference.
+        *
+        * @param string $lll The local lang reference LLL:EXT:ext/locallang_db.xml:some.key. If no LLL: is present, the $lll value is returned.
+        * @return string The translated text.
+        */
+       protected function translate($lll) {
+               if (substr($lll, 0, 4) !== 'LLL:') {
+                       return $lll;
+               }
+               
+               return Tx_Extbase_Utility_Localization::translate($lll, '');
+       }
+}
+?>
diff --git a/Classes/ViewHelpers/TcaLabelViewHelper.php b/Classes/ViewHelpers/TcaLabelViewHelper.php
new file mode 100644 (file)
index 0000000..01acbf5
--- /dev/null
@@ -0,0 +1,78 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2012 Nils Blattner <nb@cabag.ch>, cab services ag
+*  
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 3 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+/**
+ * Allows to get table/field names.
+ *
+ * @version $Id:$
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
+ * @scope prototype
+ */
+class Tx_Contentstage_ViewHelpers_TcaLabelViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
+       
+       /**
+        * The TCA utility object.
+        *
+        * @var Tx_Contentstage_Utility_Tca The TCA utility object.
+        */
+       protected $tca = null;
+       
+       /**
+        * Injects the TCA utility object.
+        *
+        * @param Tx_Contentstage_Utility_Tca $diff The TCA utility object.
+        */
+       public function injectTca(Tx_Contentstage_Utility_Tca $tca = null) {
+               $this->tca = $tca;
+       }
+       
+       /**
+        * constructor
+        *
+        * @return void
+        */
+       public function __construct() {
+               
+       }
+
+       /**
+        * Returns the name of the given table/field.
+        *
+        * @param string $table The table to get the name for.
+        * @param string $field The field to get the name for.
+        * @return string The field name.
+        * @author Nils Blattner <nb@cabag.ch>
+        */
+       public function render($table, $field = null) {
+               if ($field === null) {
+                       return $this->tca->getTableName($table);
+               } else {
+                       return $this->tca->getFieldName($table, $field);
+               }
+       }
+}
+
+
+?>
diff --git a/Resources/Private/Backend/Layouts/Admin.html b/Resources/Private/Backend/Layouts/Admin.html
new file mode 100644 (file)
index 0000000..198498d
--- /dev/null
@@ -0,0 +1,30 @@
+<f:be.container addJsFile="{f:uri.resource(path: 'JavaScript/Loader.js')}" addCssFile="{f:uri.resource(path: 'CSS/Main.css')}">
+       <div class="typo3-fullDoc">
+               <div id="typo3-docheader">
+                       <div id="typo3-docheader-row1">
+                               <div class="buttonsleft">
+
+                               </div>
+                               <div class="buttonsright">
+                                       <f:be.buttons.shortcut />
+                               </div>
+                       </div>
+                       <div id="typo3-docheader-row2">
+                               <div class="docheader-row2-left">
+                                       <f:be.buttons.csh />
+                               </div>
+                               <div class="docheader-row2-right">
+                                       <f:be.pagePath />
+                                       <f:be.pageInfo />
+                               </div>
+                       </div>
+
+               </div>
+               <div id="typo3-docbody">
+                       <div id="typo3-inner-docbody">
+                               <f:flashMessages renderMode="div" />
+                               <f:render section="content" />
+                       </div>
+               </div>
+       </div>
+</f:be.container>
diff --git a/Resources/Private/Backend/Layouts/Default.html b/Resources/Private/Backend/Layouts/Default.html
new file mode 100644 (file)
index 0000000..6f9c1cb
--- /dev/null
@@ -0,0 +1,34 @@
+<f:be.container addJsFile="{f:uri.resource(path: 'JavaScript/Loader.js')}" addCssFile="{f:uri.resource(path: 'CSS/Main.css')}">
+       <div class="typo3-fullDoc">
+               <div id="typo3-docheader">
+                       <div id="typo3-docheader-row1">
+                               <div class="buttonsleft">
+
+                               </div>
+                               <div class="buttonsright">
+                                       <f:be.buttons.shortcut />
+                               </div>
+                       </div>
+                       <div id="typo3-docheader-row2">
+                               <div class="docheader-row2-left">
+                                       <f:be.buttons.csh />
+                                       <f:be.menus.actionMenu>
+                                               <f:be.menus.actionMenuItem label="{f:translate(key: 'module.compare')}" action="compare" controller="Content" />
+                                               <f:be.menus.actionMenuItem label="{f:translate(key: 'module.view')}" action="view" controller="Content" />
+                                       </f:be.menus.actionMenu>
+                               </div>
+                               <div class="docheader-row2-right">
+                                       <f:be.pagePath />
+                                       <f:be.pageInfo />
+                               </div>
+                       </div>
+
+               </div>
+               <div id="typo3-docbody">
+                       <div id="typo3-inner-docbody">
+                               <f:flashMessages renderMode="div" />
+                               <f:render section="content" />
+                       </div>
+               </div>
+       </div>
+</f:be.container>
\ No newline at end of file
diff --git a/Resources/Private/Backend/Partials/FormErrors.html b/Resources/Private/Backend/Partials/FormErrors.html
new file mode 100644 (file)
index 0000000..b19c6ce
--- /dev/null
@@ -0,0 +1,13 @@
+<f:form.errors>
+       <div class="error">
+               {error.message}
+               <f:if condition="{error.propertyName}">
+                       <p>
+                               <strong>{error.propertyName}</strong>:
+                               <f:for each="{error.errors}" as="errorDetail">
+                                       {errorDetail.message}
+                               </f:for>
+                       </p>
+               </f:if>
+       </div>
+</f:form.errors>
\ No newline at end of file
diff --git a/Resources/Private/Backend/Partials/PageNode.html b/Resources/Private/Backend/Partials/PageNode.html
new file mode 100644 (file)
index 0000000..47f744e
--- /dev/null
@@ -0,0 +1,15 @@
+<li>
+       <a data-page="{page.uid}" href="#" class="pageNode" title="{page.title} [{page.uid}]">{page.title} [{page.uid}]<f:if condition="{page._differences}">
+               <f:then>
+                       <strong class="changes">
+                               [<f:translate key="changes" />]
+                       </strong>
+               </f:then>
+               <f:else>
+                       <strong class="subHasChanges">
+                               [<f:translate key="subHasChanges" />]
+                       </strong>
+               </f:else>
+       </f:if></a>
+       <f:if condition="{page._children}"><ul><f:for each="{page._children}" as="child"><f:render partial="PageNode" arguments="{page: child}" /></f:for></ul></f:if>
+</li>
diff --git a/Resources/Private/Backend/Partials/Rootline.html b/Resources/Private/Backend/Partials/Rootline.html
new file mode 100644 (file)
index 0000000..df3153c
--- /dev/null
@@ -0,0 +1,12 @@
+<f:if condition="{rootline}">
+       <f:then>
+               <f:for each="{rootline}" as="node" reverse="1">
+                       <span>{node.title} [{node.uid}] /</span>
+               </f:for>
+       </f:then>
+       <f:else>
+               <span class="badRootline">
+                       <f:translate key="info.compare.badRootline" />
+               </span>
+       </f:else>
+</f:if>
diff --git a/Resources/Private/Backend/Partials/Snapshot/FormFields.html b/Resources/Private/Backend/Partials/Snapshot/FormFields.html
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/Resources/Private/Backend/Templates/Content/Compare.html b/Resources/Private/Backend/Templates/Content/Compare.html
new file mode 100644 (file)
index 0000000..0ab6ee5
--- /dev/null
@@ -0,0 +1,75 @@
+{namespace s=Tx_Contentstage_ViewHelpers}{namespace c=Tx_CabagExtbase_ViewHelpers}<f:layout name="Default" />
+<f:section name="content">
+<h1><f:translate key="content.compare.title" /></h1>
+
+<f:flashMessages />
+<div class="rootline">
+       <strong>
+               <f:translate key="local.rootline" />
+       </strong>
+       <f:render partial="Rootline" arguments="{rootline: localRootline}" />
+</div>
+
+<div class="rootline">
+       <strong>
+               <f:translate key="remote.rootline" />
+       </strong>
+       <f:render partial="Rootline" arguments="{rootline: remoteRootline}" />
+</div>
+
+<div class="push">
+       <form method="POST" action="{f:uri.action(action: 'push')}">
+               <input type="submit" value="{f:translate(key: 'push.doIt')}" />
+       </form>
+</div>
+
+<div class="treeContainer">
+       <ul class="pageTree">
+               <f:render partial="PageNode" arguments="{page: pageTree}" />
+       </ul>
+</div>
+<div class="differencesContainer">
+       <ul class="differences">
+       </ul>
+</div>
+<script id="contentstageChangesTemplate" type="text/x-jquery-tmpl"><![CDATA[
+       <li class="field" data-page="${page}" data-table="${table}" data-record="${record}" data-field="${field}">
+               <span class="fieldTitle title">${tableName} [uid=${record}] &gt; ${fieldName}</span>
+               <span class="changes">{{html change}}</span>
+       </li>
+]]></script>
+<script id="contentstagePageChangesTemplate" type="text/x-jquery-tmpl"><![CDATA[
+       {{if changes.length}}
+               <li class="page" data-page="${page}">
+                       <span class="title pageTitle">{{html title}}</span>
+                       <ul class="tableContainer">{{tmpl(changes) "#contentstageChangesTemplate"}}</ul>
+               </li>
+       {{/if}}
+]]></script>
+<script id="contentstagePageTreeTemplate" type="text/x-jquery-tmpl"><![CDATA[
+       <li>
+               <a data-page="${uid}" href="#" class="pageNode" title="${title} [${uid}]">
+                       ${title} [${uid}]
+                       {{if jQuery.isEmptyObject(_differences)}}
+                               <strong class="changes">[' + $.contentstage.translations.changes + '</strong>
+                       {{else}}
+                               <strong class="subHasChanges">[' + $.contentstage.translations.subHasChanges + ']</strong>
+                       {{/if}}
+               </a>
+               {{if jQuery.isEmptyObject(_children)}}
+                       <ul>{{tmpl(_children) "#contentstagePageTreeTemplate"}}</ul>
+               {{/if}}
+       </li>
+]]></script>
+<script type="text/javascript">
+<![CDATA[(function($){
+       $.contentstage = {};
+       $.contentstage.differences = ]]><c:json value="{pidIndex}" /><![CDATA[;
+       $.contentstage.TCA = ]]><c:json value="{tca}" /><![CDATA[;
+       $.contentstage.pageTree = ]]><c:json value="{pageTree}" /><![CDATA[;
+       $.contentstage.translations = ]]><c:json value="{changes: '{f:translate(key: \'changes\')}', subHasChanges: '{f:translate(key: \'subHasChanges\')}'}" /><![CDATA[;
+})(jQuery);]]>
+</script>
+
+<div class="clear"></div>
+</f:section>
diff --git a/Resources/Private/Backend/Templates/Content/View.html b/Resources/Private/Backend/Templates/Content/View.html
new file mode 100644 (file)
index 0000000..f340033
--- /dev/null
@@ -0,0 +1,16 @@
+<f:layout name="Default" />
+<f:section name="content">
+<f:flashMessages />
+<div class="viewDifferences">
+       <div class="header">
+               <div class="localUrl url">{localUrl}</div>
+               <div class="remoteUrl url">{remoteUrl}</div>
+       </div>
+</div>
+<script type="text/javascript"><![CDATA[
+       (function($){
+               var localUrl = ']]>{localUrl}<![CDATA[', remoteUrl = ']]>{remoteUrl}<![CDATA[', diff = $('.viewDifferences'), iframe1 = $('<iframe/>').attr('width', '49%').attr('height', '100%').attr('src', localUrl).appendTo(diff), iframe2 = iframe1.clone().attr('src', remoteUrl).appendTo(diff);
+               diff.parent().css({height: '100%'});
+       })(jQuery);
+]]></script>
+</f:section>
diff --git a/Resources/Private/Backend/Templates/Initialize/Show.html b/Resources/Private/Backend/Templates/Initialize/Show.html
new file mode 100644 (file)
index 0000000..e328404
--- /dev/null
@@ -0,0 +1,12 @@
+{namespace c=Tx_CabagExtbase_ViewHelpers}<f:layout name="Admin" />
+<f:section name="content">
+<h1><f:translate key="initialize.initialize.title" /></h1>
+
+<f:flashMessages />
+
+<f:link.action action="doInitialize">
+       <f:translate key="initialize.doIt" />
+</f:link.action>
+
+<div class="clear"></div>
+</f:section>
diff --git a/Resources/Private/Backend/Templates/Snapshot/List.html b/Resources/Private/Backend/Templates/Snapshot/List.html
new file mode 100644 (file)
index 0000000..d411310
--- /dev/null
@@ -0,0 +1,44 @@
+<f:layout name="Admin" />
+<f:section name="content">
+<h1><f:translate key="snapshot.title" /></h1>
+
+<f:flashMessages />
+
+<ul class="newSnapshots">
+       <li>
+               <f:link.action action="create" arguments="{type: 'local'}">
+                       <f:translate key="snapshot.newLocal" />
+               </f:link.action>
+       </li>
+       <li>
+               <f:link.action action="create" arguments="{type: 'remote'}">
+                       <f:translate key="snapshot.newRemote" />
+               </f:link.action>
+       </li>
+</ul>
+
+<ul class="snapshots">
+       <f:for each="{snapshots}" as="snapshot">
+               <li class="snapshot">
+                       <h3>{snapshot.fileName} [{snapshot.size}]</h3>
+                       <ul>
+                               <li>
+                                       <f:link.action action="delete" arguments="{snapshot: snapshot.fileName}">
+                                               <f:translate key="snapshot.delete" />
+                                       </f:link.action>
+                               </li>
+                               <li>
+                                       <f:link.action action="revert" arguments="{snapshot: snapshot.fileName}">
+                                               <f:translate key="snapshot.revertLocal" />
+                                       </f:link.action>
+                               </li>
+                               <li>
+                                       <f:link.action action="revert" arguments="{snapshot: snapshot.fileName, type: 'remote'}">
+                                               <f:translate key="snapshot.revertRemote" />
+                                       </f:link.action>
+                               </li>
+               </li>
+       </f:for>
+</ul>
+
+</f:section>
\ No newline at end of file
diff --git a/Resources/Private/Backend/Templates/Snapshot/New.html b/Resources/Private/Backend/Templates/Snapshot/New.html
new file mode 100644 (file)
index 0000000..649cdc3
--- /dev/null
@@ -0,0 +1,25 @@
+<f:layout name="Default" />
+
+This template displays a NEW form for the current domain object.
+
+If you modify this template, do not forget to change the overwrite settings
+in /Configuration/ExtensionBuilder/settings.yaml:
+  Resources:
+    Private:
+      Templates:
+        New.html: keep
+
+Otherwise your changes will be overwritten the next time you save the extension in the extension builder
+
+<f:section name="content">
+<h1>New Snapshot</h1>
+
+<f:flashMessages />
+
+<f:render partial="FormErrors" />
+
+<f:form action="create"  name="newSnapshot" object="{newSnapshot}">
+<f:render partial="Snapshot/FormFields" />
+       <f:form.submit value="Create new" />
+</f:form>
+</f:section>
\ No newline at end of file
diff --git a/Resources/Private/Language/locallang.xml b/Resources/Private/Language/locallang.xml
new file mode 100644 (file)
index 0000000..18d1c58
--- /dev/null
@@ -0,0 +1,185 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<T3locallang>
+       <meta type="array">
+               <type>module</type>
+               <description>Language labels for the Content staging extension in the FRONTEND</description>
+       </meta>
+       <data type="array">
+               <languageKey index="default" type="array">
+                       <label index="changes">Changes!</label>
+                       <label index="content.compare.title">Compare local and remote</label>
+                       <label index="copy.fileMissing">File missing at source: %1$s.</label>
+                       <label index="copy.targetFolder">Cannot create target folder: %1$s.</label>
+                       <label index="diff.source.fieldMissing">Field missing at source [%1$s].</label>
+                       <label index="diff.source.recordMissing">Record missing at source [%1$s=%2$s].</label>
+                       <label index="diff.target.fieldMissing">Field missing at target [%1$s].</label>
+                       <label index="diff.target.recordMissing">Record missing at target [%1$s=%2$s].</label>
+                       <label index="error.1354723058">Error while generating snapshot - File cannot be written: %1$s</label>
+                       <label index="error.1354723059">Error while generating snapshot - Dump not successfull: %1$s</label>
+                       <label index="error.1354723060">Error while reverting snapshot - Dump file does not exist: %1$s</label>
+                       <label index="error.1354723061">Error while reverting snapshot - Dump could not be loaded into the database: %1$s</label>
+                       <label index="error.1354790965">Error while altering table: %1$s</label>
+                       <label index="error.1354799704">Error while inserting data: %1$s</label>
+                       <label index="error.1355144402">Error while selecting data: %1$s</label>
+                       <label index="error.1356616552">Error while clearing the cache: %1$s</label>
+                       <label index="error.1356616553">Error while calling the clear cache command: %1$s</label>
+                       <label index="error.1356616554">Curl error: %1$s</label>
+                       <label index="fatal.remoteFolder">The remote folder (%1$s) does not exist!</label>
+                       <label index="field.crdate">Creation date</label>
+                       <label index="field.cruser_id">Creation user</label>
+                       <label index="field.hidden">Hidden</label>
+                       <label index="field.l18n_diffsource">Translation difference</label>
+                       <label index="field.l18n_parent">Translation parent record</label>
+                       <label index="field.pid">Page id</label>
+                       <label index="field.sorting">Sorting</label>
+                       <label index="field.sys_language_uid">System language id</label>
+                       <label index="field.t3_origuid">TYPO3 original id</label>
+                       <label index="field.t3ver_count">TYPO3 version count</label>
+                       <label index="field.t3ver_id">TYPO3 version id</label>
+                       <label index="field.t3ver_label">TYPO3 version label</label>
+                       <label index="field.t3ver_move_id">TYPO3 version move id</label>
+                       <label index="field.t3ver_oid">TYPO3 version original id</label>
+                       <label index="field.t3ver_stage">TYPO3 version stage</label>
+                       <label index="field.t3ver_state">TYPO3 version state</label>
+                       <label index="field.t3ver_tstamp">TYPO3 version last modified time</label>
+                       <label index="field.t3ver_wsid">TYPO3 version workspace id</label>
+                       <label index="field.tstamp">Last modified</label>
+                       <label index="field._targetMissing">Record missing at target</label>
+                       <label index="field._sourceMissing">Record missing at source</label>
+                       <label index="info.compare.done">Compare done</label>
+                       <label index="info.compare.endFluid">Fluid rendering done.</label>
+                       <label index="info.compare.noId">No page id selected, please select one.</label>
+                       <label index="info.compare.startFluid">Starting fluid rendering.</label>
+                       <label index="info.compare.badRootline">Rootline could not be resolved!</label>
+                       <label index="info.init">Logging initialized.</label>
+                       <label index="info.init.backup">Backup generated for initialization. [%1$s]</label>
+                       <label index="info.init.dumped">Dump generated for initialization. [%1$s]</label>
+                       <label index="info.init.raised">Auto increment raised to %1$s for all tables.</label>
+                       <label index="info.init.reverted">Dump read into database for initialization. [%1$s]</label>
+                       <label index="info.push.clearCache">Cleared the remote cache.</label>
+                       <label index="info.push.dependencies">Resolving and synchronizing dependencies.</label>
+                       <label index="info.push.done">All data successfully pushed to remote.</label>
+                       <label index="info.push.file">Copying from '%1$s' to '%2$s'.</label>
+                       <label index="info.push.files">Copied %1$s file(s). [OK: %2$s Error(s): %3$s]</label>
+                       <label index="info.push.snapshot">Created snapshot file %1$s.</label>
+                       <label index="info.push.table">Pushed table %1$s [%2$s row(s)].</label>
+                       <label index="info.snapshot.done">Created snapshot file %1$s.</label>
+                       <label index="info.snapshot.removed">Removed snapshot file %1$s.</label>
+                       <label index="info.snapshot.reverted">Dump read into database [%2$s]. [%1$s]</label>
+                       <label index="initialize.doIt">Initialize this system</label>
+                       <label index="initialize.initialize.title">Initialize Systems</label>
+                       <label index="language">en</label>
+                       <label index="local.rootline">Local rootline: </label>
+                       <label index="module.compare">Compare</label>
+                       <label index="module.initialize">Initialize</label>
+                       <label index="module.snapshots">Snapshots</label>
+                       <label index="module.view">View differences</label>
+                       <label index="pageTree.rebuild">Rebuilding page tree information start (%1$s).</label>
+                       <label index="pageTree.rebuilt">Rebuilding page tree information done (%1$s).</label>
+                       <label index="push.doIt">Push all data in the current page tree to the remote system.</label>
+                       <label index="remote.rootline">Remote rootline: </label>
+                       <label index="snapshot.delete">Delete this snapshot</label>
+                       <label index="snapshot.newLocal">New local Snapshot</label>
+                       <label index="snapshot.newRemote">New remote Snapshot</label>
+                       <label index="snapshot.revertLocal">Revert the local system to this snapshot (ONLY DB!)</label>
+                       <label index="snapshot.revertRemote">Revert the remote system to this snapshot (ONLY DB!)</label>
+                       <label index="snapshot.title">Snapshots</label>
+                       <label index="subHasChanges">Contained page has changes!</label>
+                       <label index="text.collapseAll.text">Collapse all</label>
+                       <label index="text.collapseAll.title">Collapse the entire tree below.</label>
+                       <label index="text.expandAll.text">Expand all</label>
+                       <label index="text.expandAll.title">Expand the entire tree below.</label>
+                       <label index="text.toggleAll.text">Toggle all</label>
+                       <label index="text.toggleAll.title">Toggle the tree below, opening closed branches, closing open branches.</label>
+                       <label index="warning.view.noDomain">No domain record found for id. [%1$s => %2$s]</label>
+               </languageKey>
+               <languageKey index="de" type="array">
+                       <label index="changes">Änderungen!</label>
+                       <label index="content.compare.title">Lokales und entferntes System vergleichen</label>
+                       <label index="copy.fileMissing">Datei fehlt bei der Quelle: %1$s.</label>
+                       <label index="copy.targetFolder">Konnte Zielordner nicht erstellen: %1$s.</label>
+                       <label index="diff.source.fieldMissing">Feld fehlt bei der Quelle [%1$s].</label>
+                       <label index="diff.source.recordMissing">Datensatz fehlt bei der Quelle [%1$s=%2$s].</label>
+                       <label index="diff.target.fieldMissing">Feld fehlt beim Ziel [%1$s].</label>
+                       <label index="diff.target.recordMissing">Datensatz fehlt beim Ziel [%1$s=%2$s].</label>
+                       <label index="error.1354723058">Fehler während dem Generieren des Snapshots - Datei kann nicht geschrieben werden: %1$s</label>
+                       <label index="error.1354723059">Fehler während dem Generieren des Snapshots - Dump nicht erfolgreich: %1$s</label>
+                       <label index="error.1354723060">Fehler während dem Zurückspielen des Snapshots - Dump-Datei existiert nicht: %1$s</label>
+                       <label index="error.1354723061">Fehler während dem Zurückspielen des Snapshots - Dump konnte nicht in die Datenbank gelesen werden: %1$s</label>
+                       <label index="error.1354790965">Fehler während dem Ändern der Tabelle: %1$s</label>
+                       <label index="error.1354799704">Fehler während dem Einfügen der Daten: %1$s</label>
+                       <label index="error.1355144402">Fehler während der Auswahl der Daten: %1$s</label>
+                       <label index="error.1356616552">Fehler während dem Löschen des Caches: %1$s</label>
+                       <label index="error.1356616553">Fehler während dem Aufrufen des Cache-Löschen: %1$s</label>
+                       <label index="error.1356616554">Curl-Fehler: %1$s</label>
+                       <label index="fatal.remoteFolder">Der entfernte Odner (%1$s) existiert nicht!</label>
+                       <label index="field.crdate">Erstellungsdatum</label>
+                       <label index="field.cruser_id">Ersteller</label>
+                       <label index="field.hidden">Versteckt</label>
+                       <label index="field.l18n_diffsource">Unterschied der Sprachen</label>
+                       <label index="field.l18n_parent">Sprach-Eltern</label>
+                       <label index="field.pid">Seiten-Id</label>
+                       <label index="field.sorting">Sortierung</label>
+                       <label index="field.sys_language_uid">Systemsprachen-Id</label>
+                       <label index="field.t3_origuid">TYPO3 Original-Id</label>
+                       <label index="field.t3ver_count">TYPO3 Versionszahl</label>
+                       <label index="field.t3ver_id">TYPO3 Version-Id</label>
+                       <label index="field.t3ver_label">TYPO3 Versiontext</label>
+                       <label index="field.t3ver_move_id">TYPO3 Versions-Verschiebungs-Id</label>
+                       <label index="field.t3ver_oid">TYPO3 Version Original-Id</label>
+                       <label index="field.t3ver_stage">TYPO3 Version-Stadium</label>
+                       <label index="field.t3ver_state">TYPO3 Version-Stand</label>
+                       <label index="field.t3ver_tstamp">TYPO3 Version Zuletzt geändert</label>
+                       <label index="field.t3ver_wsid">TYPO3 Version Workspace-Id</label>
+                       <label index="field.tstamp">Zuletzt verändert</label>
+                       <label index="field._targetMissing">Datensatz fehlt beim Ziel</label>
+                       <label index="field._sourceMissing">Datensatz fehlt bei der Quelle</label>
+                       <label index="info.compare.done">Vergleich erledigt</label>
+                       <label index="info.compare.endFluid">Fluid-Rendering erledigt.</label>
+                       <label index="info.compare.noId">Keine Seiten-Id ausgewählt, bitte wählen Sie eine aus.</label>
+                       <label index="info.compare.startFluid">Fluid-Rendering wird gestartet.</label>
+                       <label index="info.compare.badRootline">Rootline konnte nicht generiert werden!</label>
+                       <label index="info.init">Logging initialisiert.</label>
+                       <label index="info.init.backup">Backup generiert für die Initialisierung. [%1$s]</label>
+                       <label index="info.init.dumped">Dump generiert für die Initialisierung. [%1$s]</label>
+                       <label index="info.init.raised">Auto increment erhöht auf %1$s für alle Tabellen.</label>
+                       <label index="info.init.reverted">Dump in die Datenbank zur Initialisierung eingelesen. [%1$s]</label>
+                       <label index="info.push.clearCache">Entfernter Cache gelöscht.</label>
+                       <label index="info.push.dependencies">Abhängigkeiten werden gesucht und synchronisiert.</label>
+                       <label index="info.push.done">Alle Daten wurden erfolgreich auf das entfernte System kopiert.</label>
+                       <label index="info.push.file">Kopiere von '%1$s' nach '%2$s'.</label>
+                       <label index="info.push.files">%1$s Datei(en) kopiert. [OK: %2$s Fehler: %3$s]</label>
+                       <label index="info.push.snapshot">Snapshot-Datei erstellt %1$s.</label>
+                       <label index="info.push.table">Tabelle %1$s kopiert [%2$s Zeile(n)].</label>
+                       <label index="info.snapshot.done">Snapshot-Datei erstellt %1$s.</label>
+                       <label index="info.snapshot.removed">Snapshot-Datei gelöscht %1$s.</label>
+                       <label index="info.snapshot.reverted">Dump in Datenbank [%2$s] eingelesen. [%1$s]</label>
+                       <label index="initialize.doIt">Dieses System initialisieren</label>
+                       <label index="initialize.initialize.title">Systeminitialisierung</label>
+                       <label index="language">de</label>
+                       <label index="local.rootline">Lokale Rootline: </label>
+                       <label index="module.compare">Vergleichen</label>
+                       <label index="module.initialize">Initialisieren</label>
+                       <label index="module.snapshots">Snapshots</label>
+                       <label index="module.view">Änderungen vergleichen</label>
+                       <label index="pageTree.rebuild">Seitenbauminformationen - Neugenerieren start (%1$s).</label>
+                       <label index="pageTree.rebuilt">Seitenbauminformationen - Neugenerieren erledigt (%1$s).</label>
+                       <label index="push.doIt">Alle Daten aus dem aktuellen Seitenbaum auf das entfernte System kopieren.</label>
+                       <label index="remote.rootline">Entfernte Rootline: </label>
+                       <label index="snapshot.delete">Diesen Snapshot löschen</label>
+                       <label index="snapshot.newLocal">Neuen lokalen Snapshot</label>
+                       <label index="snapshot.newRemote">Neuen entfernten Snapshot</label>
+                       <label index="snapshot.revertLocal">Das lokale System auf den Stand von diesem Snapshot zurücksetzen (NUR DB!)</label>
+                       <label index="snapshot.revertRemote">Das entfernte System auf den Stand von diesem Snapshot zurücksetzen (NUR DB!)</label>
+                       <label index="snapshot.title">Snapshots</label>
+                       <label index="subHasChanges">Enthaltene Seiten enthalten Änderungen!</label>
+                       <label index="text.collapseAll.text">Alle zuklappen</label>
+                       <label index="text.collapseAll.title">Den gesamten Baum zuklappen.</label>
+                       <label index="text.expandAll.text">Alle aufklappen</label>
+                       <label index="text.expandAll.title">Den gesamten Baum aufklappen.</label>
+                       <label index="text.toggleAll.text">Alle auf-/zuklappen</label>
+                       <label index="text.toggleAll.title">Beim gesamten Baum die geöffneten Seiten schliessen und die geschlossenen öffnen.</label>
+                       <label index="warning.view.noDomain">Kein Domänen-Eintrag für die id gefunden. [%1$s => %2$s]</label>
+               </languageKey>
+       </data>
+</T3locallang>
\ No newline at end of file
diff --git a/Resources/Private/Language/locallang_csh_tx_contentstage_domain_model_content.xml b/Resources/Private/Language/locallang_csh_tx_contentstage_domain_model_content.xml
new file mode 100644 (file)
index 0000000..915d072
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<T3locallang>
+       <meta type="array">
+               <description>Context Sensitive Help (CSH) for table tx_contentstage_domain_model_content</description>
+               <type>CSH</type>
+               <csh_table>tx_contentstage_domain_model_content</csh_table>
+       </meta>
+       <data type="array">
+       <languageKey index="default" type="array">
+          
+               </languageKey>
+       </data>
+</T3locallang>
\ No newline at end of file
diff --git a/Resources/Private/Language/locallang_csh_tx_contentstage_domain_model_initialize.xml b/Resources/Private/Language/locallang_csh_tx_contentstage_domain_model_initialize.xml
new file mode 100644 (file)
index 0000000..7246c58
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<T3locallang>
+       <meta type="array">
+               <description>Context Sensitive Help (CSH) for table tx_contentstage_domain_model_initialize</description>
+               <type>CSH</type>
+               <csh_table>tx_contentstage_domain_model_initialize</csh_table>
+       </meta>
+       <data type="array">
+       <languageKey index="default" type="array">
+          
+               </languageKey>
+       </data>
+</T3locallang>
\ No newline at end of file
diff --git a/Resources/Private/Language/locallang_csh_tx_contentstage_domain_model_snapshot.xml b/Resources/Private/Language/locallang_csh_tx_contentstage_domain_model_snapshot.xml
new file mode 100644 (file)
index 0000000..f3654c0
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<T3locallang>
+       <meta type="array">
+               <description>Context Sensitive Help (CSH) for table tx_contentstage_domain_model_snapshot</description>
+               <type>CSH</type>
+               <csh_table>tx_contentstage_domain_model_snapshot</csh_table>
+       </meta>
+       <data type="array">
+       <languageKey index="default" type="array">
+          
+               </languageKey>
+       </data>
+</T3locallang>
\ No newline at end of file
diff --git a/Resources/Private/Language/locallang_db.xml b/Resources/Private/Language/locallang_db.xml
new file mode 100644 (file)
index 0000000..29c4dbd
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<T3locallang>
+       <meta type="array">
+               <type>database</type>
+               <description>Language labels for database tables/fields belonging to extension 'contentstage'</description>
+       </meta>
+       <data type="array">
+               <languageKey index="default" type="array">
+            
+                       <label index="tx_contentstage_domain_model_content">Content</label>
+
+                       <label index="tx_contentstage_domain_model_initialize">Initialize</label>
+
+                       <label index="tx_contentstage_domain_model_snapshot">Snapshot</label>
+
+               </languageKey>
+       </data>
+</T3locallang>
\ No newline at end of file
diff --git a/Resources/Private/Language/locallang_stage.xml b/Resources/Private/Language/locallang_stage.xml
new file mode 100644 (file)
index 0000000..5289e5f
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<T3locallang>
+       <meta type="array">
+               <type>module</type>
+               <description>Language labels for backend module Content staging belonging to extension 'contentstage'</description>
+       </meta>
+       <data type="array">
+               <languageKey index="default" type="array">
+                       <label index="mlang_tabs_tab">Content staging</label>
+                       <label index="mlang_labels_tabdescr">An module that allows to migrate partial content from one system to another.</label>
+                       <label index="mlang_labels_tablabel">Content staging</label>
+               </languageKey>
+               <languageKey index="de" type="array">
+                       <label index="mlang_tabs_tab">Inhalts-Staging</label>
+                       <label index="mlang_labels_tabdescr">Ein Modul, dass es erlaubt gewisse Inhalte von einem System auf ein anderes zu migrieren.</label>
+                       <label index="mlang_labels_tablabel">Inhalts-Staging</label>
+               </languageKey>
+       </data>
+</T3locallang>
\ No newline at end of file
diff --git a/Resources/Private/Language/locallang_stageAdmin.xml b/Resources/Private/Language/locallang_stageAdmin.xml
new file mode 100644 (file)
index 0000000..d38afb1
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<T3locallang>
+       <meta type="array">
+               <type>module</type>
+               <description>Language labels for backend module Content staging belonging to extension 'contentstage'</description>
+       </meta>
+       <data type="array">
+               <languageKey index="default" type="array">
+                       <label index="mlang_tabs_tab">Staging admin</label>
+                       <label index="mlang_labels_tabdescr">An module that allows to migrate a complete database from one server to another.</label>
+                       <label index="mlang_labels_tablabel">Staging admin</label>
+               </languageKey>
+               <languageKey index="de" type="array">
+                       <label index="mlang_tabs_tab">Staging-Admin</label>
+                       <label index="mlang_labels_tabdescr">Ein Modul, dass es erlaubt die gesamte Datenbank von einem System auf ein anderes zu migrieren.</label>
+                       <label index="mlang_labels_tablabel">Staging-Admin</label>
+               </languageKey>
+       </data>
+</T3locallang>
\ No newline at end of file
diff --git a/Resources/Private/Language/locallang_stageInit.xml b/Resources/Private/Language/locallang_stageInit.xml
new file mode 100644 (file)
index 0000000..78416d8
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<T3locallang>
+       <meta type="array">
+               <type>module</type>
+               <description>Language labels for backend module Content staging belonging to extension 'contentstage'</description>
+       </meta>
+       <data type="array">
+               <languageKey index="default" type="array">
+                       <label index="mlang_tabs_tab">Staging init</label>
+                       <label index="mlang_labels_tabdescr">An module that allows to initialize the system for contentstage.</label>
+                       <label index="mlang_labels_tablabel">Staging init</label>
+               </languageKey>
+               <languageKey index="de" type="array">
+                       <label index="mlang_tabs_tab">Staging-Init</label>
+                       <label index="mlang_labels_tabdescr">Ein Modul, dass es erlaubt das System für contentastage zu initizieren.</label>
+                       <label index="mlang_labels_tablabel">Staging-Init</label>
+               </languageKey>
+       </data>
+</T3locallang>
\ No newline at end of file
diff --git a/Resources/Private/Language/locallang_stageSnapshots.xml b/Resources/Private/Language/locallang_stageSnapshots.xml
new file mode 100644 (file)
index 0000000..9f56a3c
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<T3locallang>
+       <meta type="array">
+               <type>module</type>
+               <description>Language labels for backend module Content staging belonging to extension 'contentstage'</description>
+       </meta>
+       <data type="array">
+               <languageKey index="default" type="array">
+                       <label index="mlang_tabs_tab">Staging snapshots</label>
+                       <label index="mlang_labels_tabdescr">An module that allows to migrate a complete database from one server to another.</label>
+                       <label index="mlang_labels_tablabel">Staging snapshots</label>
+               </languageKey>
+               <languageKey index="de" type="array">
+                       <label index="mlang_tabs_tab">Staging-Snapshots</label>
+                       <label index="mlang_labels_tabdescr">Ein Modul, dass es erlaubt die gesamte Datenbank von einem System auf ein anderes zu migrieren.</label>
+                       <label index="mlang_labels_tablabel">Staging-Snapshots</label>
+               </languageKey>
+       </data>
+</T3locallang>
\ No newline at end of file
diff --git a/Resources/Public/CSS/Main.css b/Resources/Public/CSS/Main.css
new file mode 100644 (file)
index 0000000..5beeacd
--- /dev/null
@@ -0,0 +1,167 @@
+.typo3-message .message-header {
+       display: none;
+}
+
+.push {
+       padding-top: 20px;
+}
+
+.treeview, .treeview ul { 
+       padding: 0;
+       margin: 0;
+       list-style: none;
+}
+
+.treeview ul {
+       margin-top: 4px;
+}
+
+.treeview .hitarea {
+       background: url(../Images/treeview-default.gif) -64px -25px no-repeat;
+       height: 16px;
+       width: 16px;
+       margin-left: -16px;
+       float: left;
+       cursor: pointer;
+}
+/* fix for IE6 */
+* html .hitarea {
+       display: inline;
+       float:none;
+}
+
+.treeview li { 
+       margin: 0;
+       padding: 3px 0pt 3px 16px;
+}
+
+.treeview a.selected {
+       background-color: #eee;
+}
+
+#treecontrol { margin: 1em 0; display: none; }
+
+.treeview .hover { cursor: pointer; }
+
+.treeview li { background: url(../Images/treeview-default-line.gif) 0 0 no-repeat; }
+.treeview li.collapsable, .treeview li.expandable { background-position: 0 -176px; }
+
+.treeview .expandable-hitarea { background-position: -80px -3px; }
+
+.treeview li.last { background-position: 0 -1766px }
+.treeview li.lastCollapsable, .treeview li.lastExpandable { background-image: url(../Images/treeview-default.gif); }  
+.treeview li.lastCollapsable { background-position: 0 -111px }
+.treeview li.lastExpandable { background-position: -32px -67px }
+
+.treeview div.lastCollapsable-hitarea, .treeview div.lastExpandable-hitarea { background-position: 0; }
+
+.treeview-red li { background-image: url(../Images/treeview-red-line.gif); }
+.treeview-red .hitarea, .treeview-red li.lastCollapsable, .treeview-red li.lastExpandable { background-image: url(../Images/treeview-red.gif); } 
+
+.treeview-black li { background-image: url(../Images/treeview-black-line.gif); }
+.treeview-black .hitarea, .treeview-black li.lastCollapsable, .treeview-black li.lastExpandable { background-image: url(../Images/treeview-black.gif); }  
+
+.treeview-gray li { background-image: url(../Images/treeview-gray-line.gif); }
+.treeview-gray .hitarea, .treeview-gray li.lastCollapsable, .treeview-gray li.lastExpandable { background-image: url(../Images/treeview-gray.gif); } 
+
+.treeview-famfamfam li { background-image: url(../Images/treeview-famfamfam-line.gif); }
+.treeview-famfamfam .hitarea, .treeview-famfamfam li.lastCollapsable, .treeview-famfamfam li.lastExpandable { background-image: url(../Images/treeview-famfamfam.gif); } 
+
+.treeview .placeholder {
+       background: url(../Images/ajax-loader.gif) 0 0 no-repeat;
+       height: 16px;
+       width: 16px;
+       display: block;
+}
+
+.filetree li { padding: 3px 0 2px 16px; }
+.filetree span.folder, .filetree span.file { padding: 1px 0 1px 16px; display: block; }
+.filetree span.folder { background: url(../Images/folder.gif) 0 0 no-repeat; }
+.filetree li.expandable span.folder { background: url(../Images/folder-closed.gif) 0 0 no-repeat; }
+.filetree span.file { background: url(../Images/file.gif) 0 0 no-repeat; }
+
+
+.treeContainer {
+       margin-top: 20px;
+       margin-bottom: 20px;
+       float: left;
+       width: 500px;
+       
+       clear: both;
+}
+
+.differencesContainer {
+       margin-top: 20px;
+       margin-bottom: 20px;
+       float: left;
+       width: 500px;
+       min-height: 20px;
+}
+
+.clear {
+       clear: both;
+}
+
+strong.subHasChanges {
+       display: none;
+}
+
+a.subHasChanges strong.subHasChanges {
+       display: inline;
+}
+
+.differencesContainer span.title .subHasChanges,
+.differencesContainer span.title strong.changes {
+       display: none;
+}
+
+.differencesContainer li.page {
+       margin-bottom: 5px;
+}
+
+.differencesContainer span.pageTitle {
+       font-weight: bold;
+}
+
+.differencesContainer li.field span.changes {
+       display: block;
+       padding-left: 10px;
+}
+
+.viewDifferences {
+       height: 90%;
+}
+
+.viewDifferences iframe {
+       width: 49% !important;
+       height: 100% !important;
+       border: 0;
+}
+
+.viewDifferences div.header {
+       height: 30px;
+       clear: both;
+}
+
+.viewDifferences div.header div.url {
+       float: left;
+       width: 49%;
+}
+
+.treeContainer .control a {
+       background-color: #F6F6F6;
+    background-image: -moz-linear-gradient(center top , #F6F6F6 10%, #D5D5D5 90%);
+    background-position: center bottom;
+    background-repeat: repeat-x;
+    border: 1px solid #7C7C7C;
+    border-radius: 1px 1px 1px 1px;
+    color: #434343;
+    cursor: pointer;
+    padding: 2px 4px;
+    margin-right: 10px;
+    margin-bottom: 5px;
+}
+
+span.badRootline {
+       font-weight: bold;
+}
diff --git a/Resources/Public/Icons/relation.gif b/Resources/Public/Icons/relation.gif
new file mode 100644 (file)
index 0000000..db61d7e
Binary files /dev/null and b/Resources/Public/Icons/relation.gif differ
diff --git a/Resources/Public/Icons/tx_contentstage_domain_model_content.gif b/Resources/Public/Icons/tx_contentstage_domain_model_content.gif
new file mode 100644 (file)
index 0000000..6cc5f16
Binary files /dev/null and b/Resources/Public/Icons/tx_contentstage_domain_model_content.gif differ
diff --git a/Resources/Public/Icons/tx_contentstage_domain_model_initialize.gif b/Resources/Public/Icons/tx_contentstage_domain_model_initialize.gif
new file mode 100644 (file)
index 0000000..6cc5f16
Binary files /dev/null and b/Resources/Public/Icons/tx_contentstage_domain_model_initialize.gif differ
diff --git a/Resources/Public/Icons/tx_contentstage_domain_model_snapshot.gif b/Resources/Public/Icons/tx_contentstage_domain_model_snapshot.gif
new file mode 100644 (file)
index 0000000..6cc5f16
Binary files /dev/null and b/Resources/Public/Icons/tx_contentstage_domain_model_snapshot.gif differ
diff --git a/Resources/Public/Images/ajax-loader.gif b/Resources/Public/Images/ajax-loader.gif
new file mode 100644 (file)
index 0000000..bc54585
Binary files /dev/null and b/Resources/Public/Images/ajax-loader.gif differ
diff --git a/Resources/Public/Images/file.gif b/Resources/Public/Images/file.gif
new file mode 100644 (file)
index 0000000..7e62167
Binary files /dev/null and b/Resources/Public/Images/file.gif differ
diff --git a/Resources/Public/Images/folder-closed.gif b/Resources/Public/Images/folder-closed.gif
new file mode 100644 (file)
index 0000000..5411078
Binary files /dev/null and b/Resources/Public/Images/folder-closed.gif differ
diff --git a/Resources/Public/Images/folder.gif b/Resources/Public/Images/folder.gif
new file mode 100644 (file)
index 0000000..2b31631
Binary files /dev/null and b/Resources/Public/Images/folder.gif differ
diff --git a/Resources/Public/Images/minus.gif b/Resources/Public/Images/minus.gif
new file mode 100644 (file)
index 0000000..47fb7b7
Binary files /dev/null and b/Resources/Public/Images/minus.gif differ
diff --git a/Resources/Public/Images/plus.gif b/Resources/Public/Images/plus.gif
new file mode 100644 (file)
index 0000000..6906621
Binary files /dev/null and b/Resources/Public/Images/plus.gif differ
diff --git a/Resources/Public/Images/treeview-black-line.gif b/Resources/Public/Images/treeview-black-line.gif
new file mode 100644 (file)
index 0000000..e549687
Binary files /dev/null and b/Resources/Public/Images/treeview-black-line.gif differ
diff --git a/Resources/Public/Images/treeview-black.gif b/Resources/Public/Images/treeview-black.gif
new file mode 100644 (file)
index 0000000..d549b9f
Binary files /dev/null and b/Resources/Public/Images/treeview-black.gif differ
diff --git a/Resources/Public/Images/treeview-default-line.gif b/Resources/Public/Images/treeview-default-line.gif
new file mode 100644 (file)
index 0000000..37114d3
Binary files /dev/null and b/Resources/Public/Images/treeview-default-line.gif differ
diff --git a/Resources/Public/Images/treeview-default.gif b/Resources/Public/Images/treeview-default.gif
new file mode 100644 (file)
index 0000000..a12ac52
Binary files /dev/null and b/Resources/Public/Images/treeview-default.gif differ
diff --git a/Resources/Public/Images/treeview-famfamfam-line.gif b/Resources/Public/Images/treeview-famfamfam-line.gif
new file mode 100644 (file)
index 0000000..6e289ce
Binary files /dev/null and b/Resources/Public/Images/treeview-famfamfam-line.gif differ
diff --git a/Resources/Public/Images/treeview-famfamfam.gif b/Resources/Public/Images/treeview-famfamfam.gif
new file mode 100644 (file)
index 0000000..0cb178e
Binary files /dev/null and b/Resources/Public/Images/treeview-famfamfam.gif differ
diff --git a/Resources/Public/Images/treeview-gray-line.gif b/Resources/Public/Images/treeview-gray-line.gif
new file mode 100644 (file)
index 0000000..3760044
Binary files /dev/null and b/Resources/Public/Images/treeview-gray-line.gif differ
diff --git a/Resources/Public/Images/treeview-gray.gif b/Resources/Public/Images/treeview-gray.gif
new file mode 100644 (file)
index 0000000..cfb8a2f
Binary files /dev/null and b/Resources/Public/Images/treeview-gray.gif differ
diff --git a/Resources/Public/Images/treeview-red.gif b/Resources/Public/Images/treeview-red.gif
new file mode 100644 (file)
index 0000000..3bbb3a1
Binary files /dev/null and b/Resources/Public/Images/treeview-red.gif differ
diff --git a/Resources/Public/JavaScript/Loader.js b/Resources/Public/JavaScript/Loader.js
new file mode 100644 (file)
index 0000000..9ee2b60
--- /dev/null
@@ -0,0 +1,5 @@
+document.write('<sc' + 'ript type="text/javascript" src="../typo3conf/ext/contentstage/Resources/Public/JavaScript/jquery-1.8.3.min.js"></script>');
+document.write('<sc' + 'ript type="text/javascript">$j=jQuery.noConflict();</script>');
+document.write('<sc' + 'ript type="text/javascript" src="../typo3conf/ext/contentstage/Resources/Public/JavaScript/jquery.treeview.js"></script>');
+document.write('<sc' + 'ript type="text/javascript" src="../typo3conf/ext/contentstage/Resources/Public/JavaScript/jquery.tmpl.min.js"></script>');
+document.write('<sc' + 'ript type="text/javascript" src="../typo3conf/ext/contentstage/Resources/Public/JavaScript/Main.js"></script>');
diff --git a/Resources/Public/JavaScript/Main.js b/Resources/Public/JavaScript/Main.js
new file mode 100644 (file)
index 0000000..85113f3
--- /dev/null
@@ -0,0 +1,50 @@
+jQuery(function($){
+       var differenceContainer = $('.differencesContainer ul.differences'), tcaLabel = function (table, field) {
+               if (!table || !$.contentstage.TCA || !$.contentstage.TCA[table]) return table;
+               if (!field) {
+                       return $.contentstage.TCA[table]['__name'] ? $.contentstage.TCA[table]['__name'] : table;
+               }
+               if (!$.contentstage.TCA[table][field]) return field;
+               return $.contentstage.TCA[table][field]['__name'] ? $.contentstage.TCA[table][field]['__name'] : field;
+       }, renderPageDifferences = function (page) {
+               var tables = $.contentstage.differences[page], dom = $('<li class="page" data-page="' + page + '"/>'), ul = $('<ul class="tableContainer" />').appendTo(dom);
+               if (!tables) return [];
+               var changes = [];
+               
+               $.each(tables, function (table, records) {
+                       $.each(records, function (record, fields) {
+                               $.each(fields, function (field, change) {
+                                       changes.push({
+                                               page: page,
+                                               table: table,
+                                               record: record,
+                                               field: field,
+                                               tableName: tcaLabel(table),
+                                               fieldName: tcaLabel(table, field),
+                                               change: change
+                                       });
+                               });
+                       });
+               });
+               
+               return changes;
+       };
+       
+       //$('#contentstagePageTreeTemplate').tmpl($.contentstage.pageTree).appendTo($('ul.pageTree'));
+       
+       $('ul.pageTree').treeview({collapsed: true}).find('a').click(function(){
+               differenceContainer.empty();
+               
+               var th = $(this), pid = th.attr('data-page'), pages = [];
+               th.parent().find('a').each(function () {
+                       var pid = $(this).attr('data-page');
+                       pages.push({page: pid, changes: renderPageDifferences(pid), title: $(this).html()});
+               });
+               
+               $('#contentstagePageChangesTemplate').tmpl(pages).appendTo(differenceContainer);
+               
+               return false;
+       });
+       
+       $('ul.pageTree').find('strong.changes').parents('li').children('a').addClass('subHasChanges');
+});
diff --git a/Resources/Public/JavaScript/jquery-1.8.3.min.js b/Resources/Public/JavaScript/jquery-1.8.3.min.js
new file mode 100644 (file)
index 0000000..45477c0
--- /dev/null
@@ -0,0 +1,2 @@
+/*! jQuery v1.8.3 jquery.com | jquery.org/license */
+(function(e,t){function _(e){var t=M[e]={};return v.each(e.split(y),function(e,n){t[n]=!0}),t}function H(e,n,r){if(r===t&&e.nodeType===1){var i="data-"+n.replace(P,"-$1").toLowerCase();r=e.getAttribute(i);if(typeof r=="string"){try{r=r==="true"?!0:r==="false"?!1:r==="null"?null:+r+""===r?+r:D.test(r)?v.parseJSON(r):r}catch(s){}v.data(e,n,r)}else r=t}return r}function B(e){var t;for(t in e){if(t==="data"&&v.isEmptyObject(e[t]))continue;if(t!=="toJSON")return!1}return!0}function et(){return!1}function tt(){return!0}function ut(e){return!e||!e.parentNode||e.parentNode.nodeType===11}function at(e,t){do e=e[t];while(e&&e.nodeType!==1);return e}function ft(e,t,n){t=t||0;if(v.isFunction(t))return v.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return v.grep(e,function(e,r){return e===t===n});if(typeof t=="string"){var r=v.grep(e,function(e){return e.nodeType===1});if(it.test(t))return v.filter(t,r,!n);t=v.filter(t,r)}return v.grep(e,function(e,r){return v.inArray(e,t)>=0===n})}function lt(e){var t=ct.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}function Lt(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function At(e,t){if(t.nodeType!==1||!v.hasData(e))return;var n,r,i,s=v._data(e),o=v._data(t,s),u=s.events;if(u){delete o.handle,o.events={};for(n in u)for(r=0,i=u[n].length;r<i;r++)v.event.add(t,n,u[n][r])}o.data&&(o.data=v.extend({},o.data))}function Ot(e,t){var n;if(t.nodeType!==1)return;t.clearAttributes&&t.clearAttributes(),t.mergeAttributes&&t.mergeAttributes(e),n=t.nodeName.toLowerCase(),n==="object"?(t.parentNode&&(t.outerHTML=e.outerHTML),v.support.html5Clone&&e.innerHTML&&!v.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):n==="input"&&Et.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):n==="option"?t.selected=e.defaultSelected:n==="input"||n==="textarea"?t.defaultValue=e.defaultValue:n==="script"&&t.text!==e.text&&(t.text=e.text),t.removeAttribute(v.expando)}function Mt(e){return typeof e.getElementsByTagName!="undefined"?e.getElementsByTagName("*"):typeof e.querySelectorAll!="undefined"?e.querySelectorAll("*"):[]}function _t(e){Et.test(e.type)&&(e.defaultChecked=e.checked)}function Qt(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=Jt.length;while(i--){t=Jt[i]+n;if(t in e)return t}return r}function Gt(e,t){return e=t||e,v.css(e,"display")==="none"||!v.contains(e.ownerDocument,e)}function Yt(e,t){var n,r,i=[],s=0,o=e.length;for(;s<o;s++){n=e[s];if(!n.style)continue;i[s]=v._data(n,"olddisplay"),t?(!i[s]&&n.style.display==="none"&&(n.style.display=""),n.style.display===""&&Gt(n)&&(i[s]=v._data(n,"olddisplay",nn(n.nodeName)))):(r=Dt(n,"display"),!i[s]&&r!=="none"&&v._data(n,"olddisplay",r))}for(s=0;s<o;s++){n=e[s];if(!n.style)continue;if(!t||n.style.display==="none"||n.style.display==="")n.style.display=t?i[s]||"":"none"}return e}function Zt(e,t,n){var r=Rt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function en(e,t,n,r){var i=n===(r?"border":"content")?4:t==="width"?1:0,s=0;for(;i<4;i+=2)n==="margin"&&(s+=v.css(e,n+$t[i],!0)),r?(n==="content"&&(s-=parseFloat(Dt(e,"padding"+$t[i]))||0),n!=="margin"&&(s-=parseFloat(Dt(e,"border"+$t[i]+"Width"))||0)):(s+=parseFloat(Dt(e,"padding"+$t[i]))||0,n!=="padding"&&(s+=parseFloat(Dt(e,"border"+$t[i]+"Width"))||0));return s}function tn(e,t,n){var r=t==="width"?e.offsetWidth:e.offsetHeight,i=!0,s=v.support.boxSizing&&v.css(e,"boxSizing")==="border-box";if(r<=0||r==null){r=Dt(e,t);if(r<0||r==null)r=e.style[t];if(Ut.test(r))return r;i=s&&(v.support.boxSizingReliable||r===e.style[t]),r=parseFloat(r)||0}return r+en(e,t,n||(s?"border":"content"),i)+"px"}function nn(e){if(Wt[e])return Wt[e];var t=v("<"+e+">").appendTo(i.body),n=t.css("display");t.remove();if(n==="none"||n===""){Pt=i.body.appendChild(Pt||v.extend(i.createElement("iframe"),{frameBorder:0,width:0,height:0}));if(!Ht||!Pt.createElement)Ht=(Pt.contentWindow||Pt.contentDocument).document,Ht.write("<!doctype html><html><body>"),Ht.close();t=Ht.body.appendChild(Ht.createElement(e)),n=Dt(t,"display"),i.body.removeChild(Pt)}return Wt[e]=n,n}function fn(e,t,n,r){var i;if(v.isArray(t))v.each(t,function(t,i){n||sn.test(e)?r(e,i):fn(e+"["+(typeof i=="object"?t:"")+"]",i,n,r)});else if(!n&&v.type(t)==="object")for(i in t)fn(e+"["+i+"]",t[i],n,r);else r(e,t)}function Cn(e){return function(t,n){typeof t!="string"&&(n=t,t="*");var r,i,s,o=t.toLowerCase().split(y),u=0,a=o.length;if(v.isFunction(n))for(;u<a;u++)r=o[u],s=/^\+/.test(r),s&&(r=r.substr(1)||"*"),i=e[r]=e[r]||[],i[s?"unshift":"push"](n)}}function kn(e,n,r,i,s,o){s=s||n.dataTypes[0],o=o||{},o[s]=!0;var u,a=e[s],f=0,l=a?a.length:0,c=e===Sn;for(;f<l&&(c||!u);f++)u=a[f](n,r,i),typeof u=="string"&&(!c||o[u]?u=t:(n.dataTypes.unshift(u),u=kn(e,n,r,i,u,o)));return(c||!u)&&!o["*"]&&(u=kn(e,n,r,i,"*",o)),u}function Ln(e,n){var r,i,s=v.ajaxSettings.flatOptions||{};for(r in n)n[r]!==t&&((s[r]?e:i||(i={}))[r]=n[r]);i&&v.extend(!0,e,i)}function An(e,n,r){var i,s,o,u,a=e.contents,f=e.dataTypes,l=e.responseFields;for(s in l)s in r&&(n[l[s]]=r[s]);while(f[0]==="*")f.shift(),i===t&&(i=e.mimeType||n.getResponseHeader("content-type"));if(i)for(s in a)if(a[s]&&a[s].test(i)){f.unshift(s);break}if(f[0]in r)o=f[0];else{for(s in r){if(!f[0]||e.converters[s+" "+f[0]]){o=s;break}u||(u=s)}o=o||u}if(o)return o!==f[0]&&f.unshift(o),r[o]}function On(e,t){var n,r,i,s,o=e.dataTypes.slice(),u=o[0],a={},f=0;e.dataFilter&&(t=e.dataFilter(t,e.dataType));if(o[1])for(n in e.converters)a[n.toLowerCase()]=e.converters[n];for(;i=o[++f];)if(i!=="*"){if(u!=="*"&&u!==i){n=a[u+" "+i]||a["* "+i];if(!n)for(r in a){s=r.split(" ");if(s[1]===i){n=a[u+" "+s[0]]||a["* "+s[0]];if(n){n===!0?n=a[r]:a[r]!==!0&&(i=s[0],o.splice(f--,0,i));break}}}if(n!==!0)if(n&&e["throws"])t=n(t);else try{t=n(t)}catch(l){return{state:"parsererror",error:n?l:"No conversion from "+u+" to "+i}}}u=i}return{state:"success",data:t}}function Fn(){try{return new e.XMLHttpRequest}catch(t){}}function In(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}function $n(){return setTimeout(function(){qn=t},0),qn=v.now()}function Jn(e,t){v.each(t,function(t,n){var r=(Vn[t]||[]).concat(Vn["*"]),i=0,s=r.length;for(;i<s;i++)if(r[i].call(e,t,n))return})}function Kn(e,t,n){var r,i=0,s=0,o=Xn.length,u=v.Deferred().always(function(){delete a.elem}),a=function(){var t=qn||$n(),n=Math.max(0,f.startTime+f.duration-t),r=n/f.duration||0,i=1-r,s=0,o=f.tweens.length;for(;s<o;s++)f.tweens[s].run(i);return u.notifyWith(e,[f,i,n]),i<1&&o?n:(u.resolveWith(e,[f]),!1)},f=u.promise({elem:e,props:v.extend({},t),opts:v.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:qn||$n(),duration:n.duration,tweens:[],createTween:function(t,n,r){var i=v.Tween(e,f.opts,t,n,f.opts.specialEasing[t]||f.opts.easing);return f.tweens.push(i),i},stop:function(t){var n=0,r=t?f.tweens.length:0;for(;n<r;n++)f.tweens[n].run(1);return t?u.resolveWith(e,[f,t]):u.rejectWith(e,[f,t]),this}}),l=f.props;Qn(l,f.opts.specialEasing);for(;i<o;i++){r=Xn[i].call(f,e,l,f.opts);if(r)return r}return Jn(f,l),v.isFunction(f.opts.start)&&f.opts.start.call(e,f),v.fx.timer(v.extend(a,{anim:f,queue:f.opts.queue,elem:e})),f.progress(f.opts.progress).done(f.opts.done,f.opts.complete).fail(f.opts.fail).always(f.opts.always)}function Qn(e,t){var n,r,i,s,o;for(n in e){r=v.camelCase(n),i=t[r],s=e[n],v.isArray(s)&&(i=s[1],s=e[n]=s[0]),n!==r&&(e[r]=s,delete e[n]),o=v.cssHooks[r];if(o&&"expand"in o){s=o.expand(s),delete e[r];for(n in s)n in e||(e[n]=s[n],t[n]=i)}else t[r]=i}}function Gn(e,t,n){var r,i,s,o,u,a,f,l,c,h=this,p=e.style,d={},m=[],g=e.nodeType&&Gt(e);n.queue||(l=v._queueHooks(e,"fx"),l.unqueued==null&&(l.unqueued=0,c=l.empty.fire,l.empty.fire=function(){l.unqueued||c()}),l.unqueued++,h.always(function(){h.always(function(){l.unqueued--,v.queue(e,"fx").length||l.empty.fire()})})),e.nodeType===1&&("height"in t||"width"in t)&&(n.overflow=[p.overflow,p.overflowX,p.overflowY],v.css(e,"display")==="inline"&&v.css(e,"float")==="none"&&(!v.support.inlineBlockNeedsLayout||nn(e.nodeName)==="inline"?p.display="inline-block":p.zoom=1)),n.overflow&&(p.overflow="hidden",v.support.shrinkWrapBlocks||h.done(function(){p.overflow=n.overflow[0],p.overflowX=n.overflow[1],p.overflowY=n.overflow[2]}));for(r in t){s=t[r];if(Un.exec(s)){delete t[r],a=a||s==="toggle";if(s===(g?"hide":"show"))continue;m.push(r)}}o=m.length;if(o){u=v._data(e,"fxshow")||v._data(e,"fxshow",{}),"hidden"in u&&(g=u.hidden),a&&(u.hidden=!g),g?v(e).show():h.done(function(){v(e).hide()}),h.done(function(){var t;v.removeData(e,"fxshow",!0);for(t in d)v.style(e,t,d[t])});for(r=0;r<o;r++)i=m[r],f=h.createTween(i,g?u[i]:0),d[i]=u[i]||v.style(e,i),i in u||(u[i]=f.start,g&&(f.end=f.start,f.start=i==="width"||i==="height"?1:0))}}function Yn(e,t,n,r,i){return new Yn.prototype.init(e,t,n,r,i)}function Zn(e,t){var n,r={height:e},i=0;t=t?1:0;for(;i<4;i+=2-t)n=$t[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}function tr(e){return v.isWindow(e)?e:e.nodeType===9?e.defaultView||e.parentWindow:!1}var n,r,i=e.document,s=e.location,o=e.navigator,u=e.jQuery,a=e.$,f=Array.prototype.push,l=Array.prototype.slice,c=Array.prototype.indexOf,h=Object.prototype.toString,p=Object.prototype.hasOwnProperty,d=String.prototype.trim,v=function(e,t){return new v.fn.init(e,t,n)},m=/[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,g=/\S/,y=/\s+/,b=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,w=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,E=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,S=/^[\],:{}\s]*$/,x=/(?:^|:|,)(?:\s*\[)+/g,T=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,N=/"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,C=/^-ms-/,k=/-([\da-z])/gi,L=function(e,t){return(t+"").toUpperCase()},A=function(){i.addEventListener?(i.removeEventListener("DOMContentLoaded",A,!1),v.ready()):i.readyState==="complete"&&(i.detachEvent("onreadystatechange",A),v.ready())},O={};v.fn=v.prototype={constructor:v,init:function(e,n,r){var s,o,u,a;if(!e)return this;if(e.nodeType)return this.context=this[0]=e,this.length=1,this;if(typeof e=="string"){e.charAt(0)==="<"&&e.charAt(e.length-1)===">"&&e.length>=3?s=[null,e,null]:s=w.exec(e);if(s&&(s[1]||!n)){if(s[1])return n=n instanceof v?n[0]:n,a=n&&n.nodeType?n.ownerDocument||n:i,e=v.parseHTML(s[1],a,!0),E.test(s[1])&&v.isPlainObject(n)&&this.attr.call(e,n,!0),v.merge(this,e);o=i.getElementById(s[2]);if(o&&o.parentNode){if(o.id!==s[2])return r.find(e);this.length=1,this[0]=o}return this.context=i,this.selector=e,this}return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e)}return v.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),v.makeArray(e,this))},selector:"",jquery:"1.8.3",length:0,size:function(){return this.length},toArray:function(){return l.call(this)},get:function(e){return e==null?this.toArray():e<0?this[this.length+e]:this[e]},pushStack:function(e,t,n){var r=v.merge(this.constructor(),e);return r.prevObject=this,r.context=this.context,t==="find"?r.selector=this.selector+(this.selector?" ":"")+n:t&&(r.selector=this.selector+"."+t+"("+n+")"),r},each:function(e,t){return v.each(this,e,t)},ready:function(e){return v.ready.promise().done(e),this},eq:function(e){return e=+e,e===-1?this.slice(e):this.slice(e,e+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(l.apply(this,arguments),"slice",l.call(arguments).join(","))},map:function(e){return this.pushStack(v.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:[].sort,splice:[].splice},v.fn.init.prototype=v.fn,v.extend=v.fn.extend=function(){var e,n,r,i,s,o,u=arguments[0]||{},a=1,f=arguments.length,l=!1;typeof u=="boolean"&&(l=u,u=arguments[1]||{},a=2),typeof u!="object"&&!v.isFunction(u)&&(u={}),f===a&&(u=this,--a);for(;a<f;a++)if((e=arguments[a])!=null)for(n in e){r=u[n],i=e[n];if(u===i)continue;l&&i&&(v.isPlainObject(i)||(s=v.isArray(i)))?(s?(s=!1,o=r&&v.isArray(r)?r:[]):o=r&&v.isPlainObject(r)?r:{},u[n]=v.extend(l,o,i)):i!==t&&(u[n]=i)}return u},v.extend({noConflict:function(t){return e.$===v&&(e.$=a),t&&e.jQuery===v&&(e.jQuery=u),v},isReady:!1,readyWait:1,holdReady:function(e){e?v.readyWait++:v.ready(!0)},ready:function(e){if(e===!0?--v.readyWait:v.isReady)return;if(!i.body)return setTimeout(v.ready,1);v.isReady=!0;if(e!==!0&&--v.readyWait>0)return;r.resolveWith(i,[v]),v.fn.trigger&&v(i).trigger("ready").off("ready")},isFunction:function(e){return v.type(e)==="function"},isArray:Array.isArray||function(e){return v.type(e)==="array"},isWindow:function(e){return e!=null&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return e==null?String(e):O[h.call(e)]||"object"},isPlainObject:function(e){if(!e||v.type(e)!=="object"||e.nodeType||v.isWindow(e))return!1;try{if(e.constructor&&!p.call(e,"constructor")&&!p.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}var r;for(r in e);return r===t||p.call(e,r)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw new Error(e)},parseHTML:function(e,t,n){var r;return!e||typeof e!="string"?null:(typeof t=="boolean"&&(n=t,t=0),t=t||i,(r=E.exec(e))?[t.createElement(r[1])]:(r=v.buildFragment([e],t,n?null:[]),v.merge([],(r.cacheable?v.clone(r.fragment):r.fragment).childNodes)))},parseJSON:function(t){if(!t||typeof t!="string")return null;t=v.trim(t);if(e.JSON&&e.JSON.parse)return e.JSON.parse(t);if(S.test(t.replace(T,"@").replace(N,"]").replace(x,"")))return(new Function("return "+t))();v.error("Invalid JSON: "+t)},parseXML:function(n){var r,i;if(!n||typeof n!="string")return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(s){r=t}return(!r||!r.documentElement||r.getElementsByTagName("parsererror").length)&&v.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&g.test(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(C,"ms-").replace(k,L)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,n,r){var i,s=0,o=e.length,u=o===t||v.isFunction(e);if(r){if(u){for(i in e)if(n.apply(e[i],r)===!1)break}else for(;s<o;)if(n.apply(e[s++],r)===!1)break}else if(u){for(i in e)if(n.call(e[i],i,e[i])===!1)break}else for(;s<o;)if(n.call(e[s],s,e[s++])===!1)break;return e},trim:d&&!d.call("\ufeff\u00a0")?function(e){return e==null?"":d.call(e)}:function(e){return e==null?"":(e+"").replace(b,"")},makeArray:function(e,t){var n,r=t||[];return e!=null&&(n=v.type(e),e.length==null||n==="string"||n==="function"||n==="regexp"||v.isWindow(e)?f.call(r,e):v.merge(r,e)),r},inArray:function(e,t,n){var r;if(t){if(c)return c.call(t,e,n);r=t.length,n=n?n<0?Math.max(0,r+n):n:0;for(;n<r;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,s=0;if(typeof r=="number")for(;s<r;s++)e[i++]=n[s];else while(n[s]!==t)e[i++]=n[s++];return e.length=i,e},grep:function(e,t,n){var r,i=[],s=0,o=e.length;n=!!n;for(;s<o;s++)r=!!t(e[s],s),n!==r&&i.push(e[s]);return i},map:function(e,n,r){var i,s,o=[],u=0,a=e.length,f=e instanceof v||a!==t&&typeof a=="number"&&(a>0&&e[0]&&e[a-1]||a===0||v.isArray(e));if(f)for(;u<a;u++)i=n(e[u],u,r),i!=null&&(o[o.length]=i);else for(s in e)i=n(e[s],s,r),i!=null&&(o[o.length]=i);return o.concat.apply([],o)},guid:1,proxy:function(e,n){var r,i,s;return typeof n=="string"&&(r=e[n],n=e,e=r),v.isFunction(e)?(i=l.call(arguments,2),s=function(){return e.apply(n,i.concat(l.call(arguments)))},s.guid=e.guid=e.guid||v.guid++,s):t},access:function(e,n,r,i,s,o,u){var a,f=r==null,l=0,c=e.length;if(r&&typeof r=="object"){for(l in r)v.access(e,n,l,r[l],1,o,i);s=1}else if(i!==t){a=u===t&&v.isFunction(i),f&&(a?(a=n,n=function(e,t,n){return a.call(v(e),n)}):(n.call(e,i),n=null));if(n)for(;l<c;l++)n(e[l],r,a?i.call(e[l],l,n(e[l],r)):i,u);s=1}return s?e:f?n.call(e):c?n(e[0],r):o},now:function(){return(new Date).getTime()}}),v.ready.promise=function(t){if(!r){r=v.Deferred();if(i.readyState==="complete")setTimeout(v.ready,1);else if(i.addEventListener)i.addEventListener("DOMContentLoaded",A,!1),e.addEventListener("load",v.ready,!1);else{i.attachEvent("onreadystatechange",A),e.attachEvent("onload",v.ready);var n=!1;try{n=e.frameElement==null&&i.documentElement}catch(s){}n&&n.doScroll&&function o(){if(!v.isReady){try{n.doScroll("left")}catch(e){return setTimeout(o,50)}v.ready()}}()}}return r.promise(t)},v.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(e,t){O["[object "+t+"]"]=t.toLowerCase()}),n=v(i);var M={};v.Callbacks=function(e){e=typeof e=="string"?M[e]||_(e):v.extend({},e);var n,r,i,s,o,u,a=[],f=!e.once&&[],l=function(t){n=e.memory&&t,r=!0,u=s||0,s=0,o=a.length,i=!0;for(;a&&u<o;u++)if(a[u].apply(t[0],t[1])===!1&&e.stopOnFalse){n=!1;break}i=!1,a&&(f?f.length&&l(f.shift()):n?a=[]:c.disable())},c={add:function(){if(a){var t=a.length;(function r(t){v.each(t,function(t,n){var i=v.type(n);i==="function"?(!e.unique||!c.has(n))&&a.push(n):n&&n.length&&i!=="string"&&r(n)})})(arguments),i?o=a.length:n&&(s=t,l(n))}return this},remove:function(){return a&&v.each(arguments,function(e,t){var n;while((n=v.inArray(t,a,n))>-1)a.splice(n,1),i&&(n<=o&&o--,n<=u&&u--)}),this},has:function(e){return v.inArray(e,a)>-1},empty:function(){return a=[],this},disable:function(){return a=f=n=t,this},disabled:function(){return!a},lock:function(){return f=t,n||c.disable(),this},locked:function(){return!f},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],a&&(!r||f)&&(i?f.push(t):l(t)),this},fire:function(){return c.fireWith(this,arguments),this},fired:function(){return!!r}};return c},v.extend({Deferred:function(e){var t=[["resolve","done",v.Callbacks("once memory"),"resolved"],["reject","fail",v.Callbacks("once memory"),"rejected"],["notify","progress",v.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return v.Deferred(function(n){v.each(t,function(t,r){var s=r[0],o=e[t];i[r[1]](v.isFunction(o)?function(){var e=o.apply(this,arguments);e&&v.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[s+"With"](this===i?n:this,[e])}:n[s])}),e=null}).promise()},promise:function(e){return e!=null?v.extend(e,r):r}},i={};return r.pipe=r.then,v.each(t,function(e,s){var o=s[2],u=s[3];r[s[1]]=o.add,u&&o.add(function(){n=u},t[e^1][2].disable,t[2][2].lock),i[s[0]]=o.fire,i[s[0]+"With"]=o.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=l.call(arguments),r=n.length,i=r!==1||e&&v.isFunction(e.promise)?r:0,s=i===1?e:v.Deferred(),o=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?l.call(arguments):r,n===u?s.notifyWith(t,n):--i||s.resolveWith(t,n)}},u,a,f;if(r>1){u=new Array(r),a=new Array(r),f=new Array(r);for(;t<r;t++)n[t]&&v.isFunction(n[t].promise)?n[t].promise().done(o(t,f,n)).fail(s.reject).progress(o(t,a,u)):--i}return i||s.resolveWith(f,n),s.promise()}}),v.support=function(){var t,n,r,s,o,u,a,f,l,c,h,p=i.createElement("div");p.setAttribute("className","t"),p.innerHTML="  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",n=p.getElementsByTagName("*"),r=p.getElementsByTagName("a")[0];if(!n||!r||!n.length)return{};s=i.createElement("select"),o=s.appendChild(i.createElement("option")),u=p.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t={leadingWhitespace:p.firstChild.nodeType===3,tbody:!p.getElementsByTagName("tbody").length,htmlSerialize:!!p.getElementsByTagName("link").length,style:/top/.test(r.getAttribute("style")),hrefNormalized:r.getAttribute("href")==="/a",opacity:/^0.5/.test(r.style.opacity),cssFloat:!!r.style.cssFloat,checkOn:u.value==="on",optSelected:o.selected,getSetAttribute:p.className!=="t",enctype:!!i.createElement("form").enctype,html5Clone:i.createElement("nav").cloneNode(!0).outerHTML!=="<:nav></:nav>",boxModel:i.compatMode==="CSS1Compat",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},u.checked=!0,t.noCloneChecked=u.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!o.disabled;try{delete p.test}catch(d){t.deleteExpando=!1}!p.addEventListener&&p.attachEvent&&p.fireEvent&&(p.attachEvent("onclick",h=function(){t.noCloneEvent=!1}),p.cloneNode(!0).fireEvent("onclick"),p.detachEvent("onclick",h)),u=i.createElement("input"),u.value="t",u.setAttribute("type","radio"),t.radioValue=u.value==="t",u.setAttribute("checked","checked"),u.setAttribute("name","t"),p.appendChild(u),a=i.createDocumentFragment(),a.appendChild(p.lastChild),t.checkClone=a.cloneNode(!0).cloneNode(!0).lastChild.checked,t.appendChecked=u.checked,a.removeChild(u),a.appendChild(p);if(p.attachEvent)for(l in{submit:!0,change:!0,focusin:!0})f="on"+l,c=f in p,c||(p.setAttribute(f,"return;"),c=typeof p[f]=="function"),t[l+"Bubbles"]=c;return v(function(){var n,r,s,o,u="padding:0;margin:0;border:0;display:block;overflow:hidden;",a=i.getElementsByTagName("body")[0];if(!a)return;n=i.createElement("div"),n.style.cssText="visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px",a.insertBefore(n,a.firstChild),r=i.createElement("div"),n.appendChild(r),r.innerHTML="<table><tr><td></td><td>t</td></tr></table>",s=r.getElementsByTagName("td"),s[0].style.cssText="padding:0;margin:0;border:0;display:none",c=s[0].offsetHeight===0,s[0].style.display="",s[1].style.display="none",t.reliableHiddenOffsets=c&&s[0].offsetHeight===0,r.innerHTML="",r.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",t.boxSizing=r.offsetWidth===4,t.doesNotIncludeMarginInBodyOffset=a.offsetTop!==1,e.getComputedStyle&&(t.pixelPosition=(e.getComputedStyle(r,null)||{}).top!=="1%",t.boxSizingReliable=(e.getComputedStyle(r,null)||{width:"4px"}).width==="4px",o=i.createElement("div"),o.style.cssText=r.style.cssText=u,o.style.marginRight=o.style.width="0",r.style.width="1px",r.appendChild(o),t.reliableMarginRight=!parseFloat((e.getComputedStyle(o,null)||{}).marginRight)),typeof r.style.zoom!="undefined"&&(r.innerHTML="",r.style.cssText=u+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=r.offsetWidth===3,r.style.display="block",r.style.overflow="visible",r.innerHTML="<div></div>",r.firstChild.style.width="5px",t.shrinkWrapBlocks=r.offsetWidth!==3,n.style.zoom=1),a.removeChild(n),n=r=s=o=null}),a.removeChild(p),n=r=s=o=u=a=p=null,t}();var D=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,P=/([A-Z])/g;v.extend({cache:{},deletedIds:[],uuid:0,expando:"jQuery"+(v.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(e){return e=e.nodeType?v.cache[e[v.expando]]:e[v.expando],!!e&&!B(e)},data:function(e,n,r,i){if(!v.acceptData(e))return;var s,o,u=v.expando,a=typeof n=="string",f=e.nodeType,l=f?v.cache:e,c=f?e[u]:e[u]&&u;if((!c||!l[c]||!i&&!l[c].data)&&a&&r===t)return;c||(f?e[u]=c=v.deletedIds.pop()||v.guid++:c=u),l[c]||(l[c]={},f||(l[c].toJSON=v.noop));if(typeof n=="object"||typeof n=="function")i?l[c]=v.extend(l[c],n):l[c].data=v.extend(l[c].data,n);return s=l[c],i||(s.data||(s.data={}),s=s.data),r!==t&&(s[v.camelCase(n)]=r),a?(o=s[n],o==null&&(o=s[v.camelCase(n)])):o=s,o},removeData:function(e,t,n){if(!v.acceptData(e))return;var r,i,s,o=e.nodeType,u=o?v.cache:e,a=o?e[v.expando]:v.expando;if(!u[a])return;if(t){r=n?u[a]:u[a].data;if(r){v.isArray(t)||(t in r?t=[t]:(t=v.camelCase(t),t in r?t=[t]:t=t.split(" ")));for(i=0,s=t.length;i<s;i++)delete r[t[i]];if(!(n?B:v.isEmptyObject)(r))return}}if(!n){delete u[a].data;if(!B(u[a]))return}o?v.cleanData([e],!0):v.support.deleteExpando||u!=u.window?delete u[a]:u[a]=null},_data:function(e,t,n){return v.data(e,t,n,!0)},acceptData:function(e){var t=e.nodeName&&v.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),v.fn.extend({data:function(e,n){var r,i,s,o,u,a=this[0],f=0,l=null;if(e===t){if(this.length){l=v.data(a);if(a.nodeType===1&&!v._data(a,"parsedAttrs")){s=a.attributes;for(u=s.length;f<u;f++)o=s[f].name,o.indexOf("data-")||(o=v.camelCase(o.substring(5)),H(a,o,l[o]));v._data(a,"parsedAttrs",!0)}}return l}return typeof e=="object"?this.each(function(){v.data(this,e)}):(r=e.split(".",2),r[1]=r[1]?"."+r[1]:"",i=r[1]+"!",v.access(this,function(n){if(n===t)return l=this.triggerHandler("getData"+i,[r[0]]),l===t&&a&&(l=v.data(a,e),l=H(a,e,l)),l===t&&r[1]?this.data(r[0]):l;r[1]=n,this.each(function(){var t=v(this);t.triggerHandler("setData"+i,r),v.data(this,e,n),t.triggerHandler("changeData"+i,r)})},null,n,arguments.length>1,null,!1))},removeData:function(e){return this.each(function(){v.removeData(this,e)})}}),v.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=v._data(e,t),n&&(!r||v.isArray(n)?r=v._data(e,t,v.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=v.queue(e,t),r=n.length,i=n.shift(),s=v._queueHooks(e,t),o=function(){v.dequeue(e,t)};i==="inprogress"&&(i=n.shift(),r--),i&&(t==="fx"&&n.unshift("inprogress"),delete s.stop,i.call(e,o,s)),!r&&s&&s.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return v._data(e,n)||v._data(e,n,{empty:v.Callbacks("once memory").add(function(){v.removeData(e,t+"queue",!0),v.removeData(e,n,!0)})})}}),v.fn.extend({queue:function(e,n){var r=2;return typeof e!="string"&&(n=e,e="fx",r--),arguments.length<r?v.queue(this[0],e):n===t?this:this.each(function(){var t=v.queue(this,e,n);v._queueHooks(this,e),e==="fx"&&t[0]!=="inprogress"&&v.dequeue(this,e)})},dequeue:function(e){return this.each(function(){v.dequeue(this,e)})},delay:function(e,t){return e=v.fx?v.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,s=v.Deferred(),o=this,u=this.length,a=function(){--i||s.resolveWith(o,[o])};typeof e!="string"&&(n=e,e=t),e=e||"fx";while(u--)r=v._data(o[u],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(a));return a(),s.promise(n)}});var j,F,I,q=/[\t\r\n]/g,R=/\r/g,U=/^(?:button|input)$/i,z=/^(?:button|input|object|select|textarea)$/i,W=/^a(?:rea|)$/i,X=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,V=v.support.getSetAttribute;v.fn.extend({attr:function(e,t){return v.access(this,v.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){v.removeAttr(this,e)})},prop:function(e,t){return v.access(this,v.prop,e,t,arguments.length>1)},removeProp:function(e){return e=v.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,s,o,u;if(v.isFunction(e))return this.each(function(t){v(this).addClass(e.call(this,t,this.className))});if(e&&typeof e=="string"){t=e.split(y);for(n=0,r=this.length;n<r;n++){i=this[n];if(i.nodeType===1)if(!i.className&&t.length===1)i.className=e;else{s=" "+i.className+" ";for(o=0,u=t.length;o<u;o++)s.indexOf(" "+t[o]+" ")<0&&(s+=t[o]+" ");i.className=v.trim(s)}}}return this},removeClass:function(e){var n,r,i,s,o,u,a;if(v.isFunction(e))return this.each(function(t){v(this).removeClass(e.call(this,t,this.className))});if(e&&typeof e=="string"||e===t){n=(e||"").split(y);for(u=0,a=this.length;u<a;u++){i=this[u];if(i.nodeType===1&&i.className){r=(" "+i.className+" ").replace(q," ");for(s=0,o=n.length;s<o;s++)while(r.indexOf(" "+n[s]+" ")>=0)r=r.replace(" "+n[s]+" "," ");i.className=e?v.trim(r):""}}}return this},toggleClass:function(e,t){var n=typeof e,r=typeof t=="boolean";return v.isFunction(e)?this.each(function(n){v(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if(n==="string"){var i,s=0,o=v(this),u=t,a=e.split(y);while(i=a[s++])u=r?u:!o.hasClass(i),o[u?"addClass":"removeClass"](i)}else if(n==="undefined"||n==="boolean")this.className&&v._data(this,"__className__",this.className),this.className=this.className||e===!1?"":v._data(this,"__className__")||""})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;n<r;n++)if(this[n].nodeType===1&&(" "+this[n].className+" ").replace(q," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,s=this[0];if(!arguments.length){if(s)return n=v.valHooks[s.type]||v.valHooks[s.nodeName.toLowerCase()],n&&"get"in n&&(r=n.get(s,"value"))!==t?r:(r=s.value,typeof r=="string"?r.replace(R,""):r==null?"":r);return}return i=v.isFunction(e),this.each(function(r){var s,o=v(this);if(this.nodeType!==1)return;i?s=e.call(this,r,o.val()):s=e,s==null?s="":typeof s=="number"?s+="":v.isArray(s)&&(s=v.map(s,function(e){return e==null?"":e+""})),n=v.valHooks[this.type]||v.valHooks[this.nodeName.toLowerCase()];if(!n||!("set"in n)||n.set(this,s,"value")===t)this.value=s})}}),v.extend({valHooks:{option:{get:function(e){var t=e.attributes.value;return!t||t.specified?e.value:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,s=e.type==="select-one"||i<0,o=s?null:[],u=s?i+1:r.length,a=i<0?u:s?i:0;for(;a<u;a++){n=r[a];if((n.selected||a===i)&&(v.support.optDisabled?!n.disabled:n.getAttribute("disabled")===null)&&(!n.parentNode.disabled||!v.nodeName(n.parentNode,"optgroup"))){t=v(n).val();if(s)return t;o.push(t)}}return o},set:function(e,t){var n=v.makeArray(t);return v(e).find("option").each(function(){this.selected=v.inArray(v(this).val(),n)>=0}),n.length||(e.selectedIndex=-1),n}}},attrFn:{},attr:function(e,n,r,i){var s,o,u,a=e.nodeType;if(!e||a===3||a===8||a===2)return;if(i&&v.isFunction(v.fn[n]))return v(e)[n](r);if(typeof e.getAttribute=="undefined")return v.prop(e,n,r);u=a!==1||!v.isXMLDoc(e),u&&(n=n.toLowerCase(),o=v.attrHooks[n]||(X.test(n)?F:j));if(r!==t){if(r===null){v.removeAttr(e,n);return}return o&&"set"in o&&u&&(s=o.set(e,r,n))!==t?s:(e.setAttribute(n,r+""),r)}return o&&"get"in o&&u&&(s=o.get(e,n))!==null?s:(s=e.getAttribute(n),s===null?t:s)},removeAttr:function(e,t){var n,r,i,s,o=0;if(t&&e.nodeType===1){r=t.split(y);for(;o<r.length;o++)i=r[o],i&&(n=v.propFix[i]||i,s=X.test(i),s||v.attr(e,i,""),e.removeAttribute(V?i:n),s&&n in e&&(e[n]=!1))}},attrHooks:{type:{set:function(e,t){if(U.test(e.nodeName)&&e.parentNode)v.error("type property can't be changed");else if(!v.support.radioValue&&t==="radio"&&v.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}},value:{get:function(e,t){return j&&v.nodeName(e,"button")?j.get(e,t):t in e?e.value:null},set:function(e,t,n){if(j&&v.nodeName(e,"button"))return j.set(e,t,n);e.value=t}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(e,n,r){var i,s,o,u=e.nodeType;if(!e||u===3||u===8||u===2)return;return o=u!==1||!v.isXMLDoc(e),o&&(n=v.propFix[n]||n,s=v.propHooks[n]),r!==t?s&&"set"in s&&(i=s.set(e,r,n))!==t?i:e[n]=r:s&&"get"in s&&(i=s.get(e,n))!==null?i:e[n]},propHooks:{tabIndex:{get:function(e){var n=e.getAttributeNode("tabindex");return n&&n.specified?parseInt(n.value,10):z.test(e.nodeName)||W.test(e.nodeName)&&e.href?0:t}}}}),F={get:function(e,n){var r,i=v.prop(e,n);return i===!0||typeof i!="boolean"&&(r=e.getAttributeNode(n))&&r.nodeValue!==!1?n.toLowerCase():t},set:function(e,t,n){var r;return t===!1?v.removeAttr(e,n):(r=v.propFix[n]||n,r in e&&(e[r]=!0),e.setAttribute(n,n.toLowerCase())),n}},V||(I={name:!0,id:!0,coords:!0},j=v.valHooks.button={get:function(e,n){var r;return r=e.getAttributeNode(n),r&&(I[n]?r.value!=="":r.specified)?r.value:t},set:function(e,t,n){var r=e.getAttributeNode(n);return r||(r=i.createAttribute(n),e.setAttributeNode(r)),r.value=t+""}},v.each(["width","height"],function(e,t){v.attrHooks[t]=v.extend(v.attrHooks[t],{set:function(e,n){if(n==="")return e.setAttribute(t,"auto"),n}})}),v.attrHooks.contenteditable={get:j.get,set:function(e,t,n){t===""&&(t="false"),j.set(e,t,n)}}),v.support.hrefNormalized||v.each(["href","src","width","height"],function(e,n){v.attrHooks[n]=v.extend(v.attrHooks[n],{get:function(e){var r=e.getAttribute(n,2);return r===null?t:r}})}),v.support.style||(v.attrHooks.style={get:function(e){return e.style.cssText.toLowerCase()||t},set:function(e,t){return e.style.cssText=t+""}}),v.support.optSelected||(v.propHooks.selected=v.extend(v.propHooks.selected,{get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}})),v.support.enctype||(v.propFix.enctype="encoding"),v.support.checkOn||v.each(["radio","checkbox"],function(){v.valHooks[this]={get:function(e){return e.getAttribute("value")===null?"on":e.value}}}),v.each(["radio","checkbox"],function(){v.valHooks[this]=v.extend(v.valHooks[this],{set:function(e,t){if(v.isArray(t))return e.checked=v.inArray(v(e).val(),t)>=0}})});var $=/^(?:textarea|input|select)$/i,J=/^([^\.]*|)(?:\.(.+)|)$/,K=/(?:^|\s)hover(\.\S+|)\b/,Q=/^key/,G=/^(?:mouse|contextmenu)|click/,Y=/^(?:focusinfocus|focusoutblur)$/,Z=function(e){return v.event.special.hover?e:e.replace(K,"mouseenter$1 mouseleave$1")};v.event={add:function(e,n,r,i,s){var o,u,a,f,l,c,h,p,d,m,g;if(e.nodeType===3||e.nodeType===8||!n||!r||!(o=v._data(e)))return;r.handler&&(d=r,r=d.handler,s=d.selector),r.guid||(r.guid=v.guid++),a=o.events,a||(o.events=a={}),u=o.handle,u||(o.handle=u=function(e){return typeof v=="undefined"||!!e&&v.event.triggered===e.type?t:v.event.dispatch.apply(u.elem,arguments)},u.elem=e),n=v.trim(Z(n)).split(" ");for(f=0;f<n.length;f++){l=J.exec(n[f])||[],c=l[1],h=(l[2]||"").split(".").sort(),g=v.event.special[c]||{},c=(s?g.delegateType:g.bindType)||c,g=v.event.special[c]||{},p=v.extend({type:c,origType:l[1],data:i,handler:r,guid:r.guid,selector:s,needsContext:s&&v.expr.match.needsContext.test(s),namespace:h.join(".")},d),m=a[c];if(!m){m=a[c]=[],m.delegateCount=0;if(!g.setup||g.setup.call(e,i,h,u)===!1)e.addEventListener?e.addEventListener(c,u,!1):e.attachEvent&&e.attachEvent("on"+c,u)}g.add&&(g.add.call(e,p),p.handler.guid||(p.handler.guid=r.guid)),s?m.splice(m.delegateCount++,0,p):m.push(p),v.event.global[c]=!0}e=null},global:{},remove:function(e,t,n,r,i){var s,o,u,a,f,l,c,h,p,d,m,g=v.hasData(e)&&v._data(e);if(!g||!(h=g.events))return;t=v.trim(Z(t||"")).split(" ");for(s=0;s<t.length;s++){o=J.exec(t[s])||[],u=a=o[1],f=o[2];if(!u){for(u in h)v.event.remove(e,u+t[s],n,r,!0);continue}p=v.event.special[u]||{},u=(r?p.delegateType:p.bindType)||u,d=h[u]||[],l=d.length,f=f?new RegExp("(^|\\.)"+f.split(".").sort().join("\\.(?:.*\\.|)")+"(\\.|$)"):null;for(c=0;c<d.length;c++)m=d[c],(i||a===m.origType)&&(!n||n.guid===m.guid)&&(!f||f.test(m.namespace))&&(!r||r===m.selector||r==="**"&&m.selector)&&(d.splice(c--,1),m.selector&&d.delegateCount--,p.remove&&p.remove.call(e,m));d.length===0&&l!==d.length&&((!p.teardown||p.teardown.call(e,f,g.handle)===!1)&&v.removeEvent(e,u,g.handle),delete h[u])}v.isEmptyObject(h)&&(delete g.handle,v.removeData(e,"events",!0))},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(n,r,s,o){if(!s||s.nodeType!==3&&s.nodeType!==8){var u,a,f,l,c,h,p,d,m,g,y=n.type||n,b=[];if(Y.test(y+v.event.triggered))return;y.indexOf("!")>=0&&(y=y.slice(0,-1),a=!0),y.indexOf(".")>=0&&(b=y.split("."),y=b.shift(),b.sort());if((!s||v.event.customEvent[y])&&!v.event.global[y])return;n=typeof n=="object"?n[v.expando]?n:new v.Event(y,n):new v.Event(y),n.type=y,n.isTrigger=!0,n.exclusive=a,n.namespace=b.join("."),n.namespace_re=n.namespace?new RegExp("(^|\\.)"+b.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,h=y.indexOf(":")<0?"on"+y:"";if(!s){u=v.cache;for(f in u)u[f].events&&u[f].events[y]&&v.event.trigger(n,r,u[f].handle.elem,!0);return}n.result=t,n.target||(n.target=s),r=r!=null?v.makeArray(r):[],r.unshift(n),p=v.event.special[y]||{};if(p.trigger&&p.trigger.apply(s,r)===!1)return;m=[[s,p.bindType||y]];if(!o&&!p.noBubble&&!v.isWindow(s)){g=p.delegateType||y,l=Y.test(g+y)?s:s.parentNode;for(c=s;l;l=l.parentNode)m.push([l,g]),c=l;c===(s.ownerDocument||i)&&m.push([c.defaultView||c.parentWindow||e,g])}for(f=0;f<m.length&&!n.isPropagationStopped();f++)l=m[f][0],n.type=m[f][1],d=(v._data(l,"events")||{})[n.type]&&v._data(l,"handle"),d&&d.apply(l,r),d=h&&l[h],d&&v.acceptData(l)&&d.apply&&d.apply(l,r)===!1&&n.preventDefault();return n.type=y,!o&&!n.isDefaultPrevented()&&(!p._default||p._default.apply(s.ownerDocument,r)===!1)&&(y!=="click"||!v.nodeName(s,"a"))&&v.acceptData(s)&&h&&s[y]&&(y!=="focus"&&y!=="blur"||n.target.offsetWidth!==0)&&!v.isWindow(s)&&(c=s[h],c&&(s[h]=null),v.event.triggered=y,s[y](),v.event.triggered=t,c&&(s[h]=c)),n.result}return},dispatch:function(n){n=v.event.fix(n||e.event);var r,i,s,o,u,a,f,c,h,p,d=(v._data(this,"events")||{})[n.type]||[],m=d.delegateCount,g=l.call(arguments),y=!n.exclusive&&!n.namespace,b=v.event.special[n.type]||{},w=[];g[0]=n,n.delegateTarget=this;if(b.preDispatch&&b.preDispatch.call(this,n)===!1)return;if(m&&(!n.button||n.type!=="click"))for(s=n.target;s!=this;s=s.parentNode||this)if(s.disabled!==!0||n.type!=="click"){u={},f=[];for(r=0;r<m;r++)c=d[r],h=c.selector,u[h]===t&&(u[h]=c.needsContext?v(h,this).index(s)>=0:v.find(h,this,null,[s]).length),u[h]&&f.push(c);f.length&&w.push({elem:s,matches:f})}d.length>m&&w.push({elem:this,matches:d.slice(m)});for(r=0;r<w.length&&!n.isPropagationStopped();r++){a=w[r],n.currentTarget=a.elem;for(i=0;i<a.matches.length&&!n.isImmediatePropagationStopped();i++){c=a.matches[i];if(y||!n.namespace&&!c.namespace||n.namespace_re&&n.namespace_re.test(c.namespace))n.data=c.data,n.handleObj=c,o=((v.event.special[c.origType]||{}).handle||c.handler).apply(a.elem,g),o!==t&&(n.result=o,o===!1&&(n.preventDefault(),n.stopPropagation()))}}return b.postDispatch&&b.postDispatch.call(this,n),n.result},props:"attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return e.which==null&&(e.which=t.charCode!=null?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,s,o,u=n.button,a=n.fromElement;return e.pageX==null&&n.clientX!=null&&(r=e.target.ownerDocument||i,s=r.documentElement,o=r.body,e.pageX=n.clientX+(s&&s.scrollLeft||o&&o.scrollLeft||0)-(s&&s.clientLeft||o&&o.clientLeft||0),e.pageY=n.clientY+(s&&s.scrollTop||o&&o.scrollTop||0)-(s&&s.clientTop||o&&o.clientTop||0)),!e.relatedTarget&&a&&(e.relatedTarget=a===e.target?n.toElement:a),!e.which&&u!==t&&(e.which=u&1?1:u&2?3:u&4?2:0),e}},fix:function(e){if(e[v.expando])return e;var t,n,r=e,s=v.event.fixHooks[e.type]||{},o=s.props?this.props.concat(s.props):this.props;e=v.Event(r);for(t=o.length;t;)n=o[--t],e[n]=r[n];return e.target||(e.target=r.srcElement||i),e.target.nodeType===3&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,r):e},special:{load:{noBubble:!0},focus:{delegateType:"focusin"},blur:{delegateType:"focusout"},beforeunload:{setup:function(e,t,n){v.isWindow(this)&&(this.onbeforeunload=n)},teardown:function(e,t){this.onbeforeunload===t&&(this.onbeforeunload=null)}}},simulate:function(e,t,n,r){var i=v.extend(new v.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?v.event.trigger(i,null,t):v.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},v.event.handle=v.event.dispatch,v.removeEvent=i.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]=="undefined"&&(e[r]=null),e.detachEvent(r,n))},v.Event=function(e,t){if(!(this instanceof v.Event))return new v.Event(e,t);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?tt:et):this.type=e,t&&v.extend(this,t),this.timeStamp=e&&e.timeStamp||v.now(),this[v.expando]=!0},v.Event.prototype={preventDefault:function(){this.isDefaultPrevented=tt;var e=this.originalEvent;if(!e)return;e.preventDefault?e.preventDefault():e.returnValue=!1},stopPropagation:function(){this.isPropagationStopped=tt;var e=this.originalEvent;if(!e)return;e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=tt,this.stopPropagation()},isDefaultPrevented:et,isPropagationStopped:et,isImmediatePropagationStopped:et},v.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){v.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,s=e.handleObj,o=s.selector;if(!i||i!==r&&!v.contains(r,i))e.type=s.origType,n=s.handler.apply(this,arguments),e.type=t;return n}}}),v.support.submitBubbles||(v.event.special.submit={setup:function(){if(v.nodeName(this,"form"))return!1;v.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=v.nodeName(n,"input")||v.nodeName(n,"button")?n.form:t;r&&!v._data(r,"_submit_attached")&&(v.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),v._data(r,"_submit_attached",!0))})},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&v.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){if(v.nodeName(this,"form"))return!1;v.event.remove(this,"._submit")}}),v.support.changeBubbles||(v.event.special.change={setup:function(){if($.test(this.nodeName)){if(this.type==="checkbox"||this.type==="radio")v.event.add(this,"propertychange._change",function(e){e.originalEvent.propertyName==="checked"&&(this._just_changed=!0)}),v.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),v.event.simulate("change",this,e,!0)});return!1}v.event.add(this,"beforeactivate._change",function(e){var t=e.target;$.test(t.nodeName)&&!v._data(t,"_change_attached")&&(v.event.add(t,"change._change",function(e){this.parentNode&&!e.isSimulated&&!e.isTrigger&&v.event.simulate("change",this.parentNode,e,!0)}),v._data(t,"_change_attached",!0))})},handle:function(e){var t=e.target;if(this!==t||e.isSimulated||e.isTrigger||t.type!=="radio"&&t.type!=="checkbox")return e.handleObj.handler.apply(this,arguments)},teardown:function(){return v.event.remove(this,"._change"),!$.test(this.nodeName)}}),v.support.focusinBubbles||v.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){v.event.simulate(t,e.target,v.event.fix(e),!0)};v.event.special[t]={setup:function(){n++===0&&i.addEventListener(e,r,!0)},teardown:function(){--n===0&&i.removeEventListener(e,r,!0)}}}),v.fn.extend({on:function(e,n,r,i,s){var o,u;if(typeof e=="object"){typeof n!="string"&&(r=r||n,n=t);for(u in e)this.on(u,n,r,e[u],s);return this}r==null&&i==null?(i=n,r=n=t):i==null&&(typeof n=="string"?(i=r,r=t):(i=r,r=n,n=t));if(i===!1)i=et;else if(!i)return this;return s===1&&(o=i,i=function(e){return v().off(e),o.apply(this,arguments)},i.guid=o.guid||(o.guid=v.guid++)),this.each(function(){v.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,s;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,v(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if(typeof e=="object"){for(s in e)this.off(s,n,e[s]);return this}if(n===!1||typeof n=="function")r=n,n=t;return r===!1&&(r=et),this.each(function(){v.event.remove(this,e,r,n)})},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},live:function(e,t,n){return v(this.context).on(e,this.selector,t,n),this},die:function(e,t){return v(this.context).off(e,this.selector||"**",t),this},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return arguments.length===1?this.off(e,"**"):this.off(t,e||"**",n)},trigger:function(e,t){return this.each(function(){v.event.trigger(e,t,this)})},triggerHandler:function(e,t){if(this[0])return v.event.trigger(e,t,this[0],!0)},toggle:function(e){var t=arguments,n=e.guid||v.guid++,r=0,i=function(n){var i=(v._data(this,"lastToggle"+e.guid)||0)%r;return v._data(this,"lastToggle"+e.guid,i+1),n.preventDefault(),t[i].apply(this,arguments)||!1};i.guid=n;while(r<t.length)t[r++].guid=n;return this.click(i)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),v.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(e,t){v.fn[t]=function(e,n){return n==null&&(n=e,e=null),arguments.length>0?this.on(t,null,e,n):this.trigger(t)},Q.test(t)&&(v.event.fixHooks[t]=v.event.keyHooks),G.test(t)&&(v.event.fixHooks[t]=v.event.mouseHooks)}),function(e,t){function nt(e,t,n,r){n=n||[],t=t||g;var i,s,a,f,l=t.nodeType;if(!e||typeof e!="string")return n;if(l!==1&&l!==9)return[];a=o(t);if(!a&&!r)if(i=R.exec(e))if(f=i[1]){if(l===9){s=t.getElementById(f);if(!s||!s.parentNode)return n;if(s.id===f)return n.push(s),n}else if(t.ownerDocument&&(s=t.ownerDocument.getElementById(f))&&u(t,s)&&s.id===f)return n.push(s),n}else{if(i[2])return S.apply(n,x.call(t.getElementsByTagName(e),0)),n;if((f=i[3])&&Z&&t.getElementsByClassName)return S.apply(n,x.call(t.getElementsByClassName(f),0)),n}return vt(e.replace(j,"$1"),t,n,r,a)}function rt(e){return function(t){var n=t.nodeName.toLowerCase();return n==="input"&&t.type===e}}function it(e){return function(t){var n=t.nodeName.toLowerCase();return(n==="input"||n==="button")&&t.type===e}}function st(e){return N(function(t){return t=+t,N(function(n,r){var i,s=e([],n.length,t),o=s.length;while(o--)n[i=s[o]]&&(n[i]=!(r[i]=n[i]))})})}function ot(e,t,n){if(e===t)return n;var r=e.nextSibling;while(r){if(r===t)return-1;r=r.nextSibling}return 1}function ut(e,t){var n,r,s,o,u,a,f,l=L[d][e+" "];if(l)return t?0:l.slice(0);u=e,a=[],f=i.preFilter;while(u){if(!n||(r=F.exec(u)))r&&(u=u.slice(r[0].length)||u),a.push(s=[]);n=!1;if(r=I.exec(u))s.push(n=new m(r.shift())),u=u.slice(n.length),n.type=r[0].replace(j," ");for(o in i.filter)(r=J[o].exec(u))&&(!f[o]||(r=f[o](r)))&&(s.push(n=new m(r.shift())),u=u.slice(n.length),n.type=o,n.matches=r);if(!n)break}return t?u.length:u?nt.error(e):L(e,a).slice(0)}function at(e,t,r){var i=t.dir,s=r&&t.dir==="parentNode",o=w++;return t.first?function(t,n,r){while(t=t[i])if(s||t.nodeType===1)return e(t,n,r)}:function(t,r,u){if(!u){var a,f=b+" "+o+" ",l=f+n;while(t=t[i])if(s||t.nodeType===1){if((a=t[d])===l)return t.sizset;if(typeof a=="string"&&a.indexOf(f)===0){if(t.sizset)return t}else{t[d]=l;if(e(t,r,u))return t.sizset=!0,t;t.sizset=!1}}}else while(t=t[i])if(s||t.nodeType===1)if(e(t,r,u))return t}}function ft(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function lt(e,t,n,r,i){var s,o=[],u=0,a=e.length,f=t!=null;for(;u<a;u++)if(s=e[u])if(!n||n(s,r,i))o.push(s),f&&t.push(u);return o}function ct(e,t,n,r,i,s){return r&&!r[d]&&(r=ct(r)),i&&!i[d]&&(i=ct(i,s)),N(function(s,o,u,a){var f,l,c,h=[],p=[],d=o.length,v=s||dt(t||"*",u.nodeType?[u]:u,[]),m=e&&(s||!t)?lt(v,h,e,u,a):v,g=n?i||(s?e:d||r)?[]:o:m;n&&n(m,g,u,a);if(r){f=lt(g,p),r(f,[],u,a),l=f.length;while(l--)if(c=f[l])g[p[l]]=!(m[p[l]]=c)}if(s){if(i||e){if(i){f=[],l=g.length;while(l--)(c=g[l])&&f.push(m[l]=c);i(null,g=[],f,a)}l=g.length;while(l--)(c=g[l])&&(f=i?T.call(s,c):h[l])>-1&&(s[f]=!(o[f]=c))}}else g=lt(g===o?g.splice(d,g.length):g),i?i(null,o,g,a):S.apply(o,g)})}function ht(e){var t,n,r,s=e.length,o=i.relative[e[0].type],u=o||i.relative[" "],a=o?1:0,f=at(function(e){return e===t},u,!0),l=at(function(e){return T.call(t,e)>-1},u,!0),h=[function(e,n,r){return!o&&(r||n!==c)||((t=n).nodeType?f(e,n,r):l(e,n,r))}];for(;a<s;a++)if(n=i.relative[e[a].type])h=[at(ft(h),n)];else{n=i.filter[e[a].type].apply(null,e[a].matches);if(n[d]){r=++a;for(;r<s;r++)if(i.relative[e[r].type])break;return ct(a>1&&ft(h),a>1&&e.slice(0,a-1).join("").replace(j,"$1"),n,a<r&&ht(e.slice(a,r)),r<s&&ht(e=e.slice(r)),r<s&&e.join(""))}h.push(n)}return ft(h)}function pt(e,t){var r=t.length>0,s=e.length>0,o=function(u,a,f,l,h){var p,d,v,m=[],y=0,w="0",x=u&&[],T=h!=null,N=c,C=u||s&&i.find.TAG("*",h&&a.parentNode||a),k=b+=N==null?1:Math.E;T&&(c=a!==g&&a,n=o.el);for(;(p=C[w])!=null;w++){if(s&&p){for(d=0;v=e[d];d++)if(v(p,a,f)){l.push(p);break}T&&(b=k,n=++o.el)}r&&((p=!v&&p)&&y--,u&&x.push(p))}y+=w;if(r&&w!==y){for(d=0;v=t[d];d++)v(x,m,a,f);if(u){if(y>0)while(w--)!x[w]&&!m[w]&&(m[w]=E.call(l));m=lt(m)}S.apply(l,m),T&&!u&&m.length>0&&y+t.length>1&&nt.uniqueSort(l)}return T&&(b=k,c=N),x};return o.el=0,r?N(o):o}function dt(e,t,n){var r=0,i=t.length;for(;r<i;r++)nt(e,t[r],n);return n}function vt(e,t,n,r,s){var o,u,f,l,c,h=ut(e),p=h.length;if(!r&&h.length===1){u=h[0]=h[0].slice(0);if(u.length>2&&(f=u[0]).type==="ID"&&t.nodeType===9&&!s&&i.relative[u[1].type]){t=i.find.ID(f.matches[0].replace($,""),t,s)[0];if(!t)return n;e=e.slice(u.shift().length)}for(o=J.POS.test(e)?-1:u.length-1;o>=0;o--){f=u[o];if(i.relative[l=f.type])break;if(c=i.find[l])if(r=c(f.matches[0].replace($,""),z.test(u[0].type)&&t.parentNode||t,s)){u.splice(o,1),e=r.length&&u.join("");if(!e)return S.apply(n,x.call(r,0)),n;break}}}return a(e,h)(r,t,s,n,z.test(e)),n}function mt(){}var n,r,i,s,o,u,a,f,l,c,h=!0,p="undefined",d=("sizcache"+Math.random()).replace(".",""),m=String,g=e.document,y=g.documentElement,b=0,w=0,E=[].pop,S=[].push,x=[].slice,T=[].indexOf||function(e){var t=0,n=this.length;for(;t<n;t++)if(this[t]===e)return t;return-1},N=function(e,t){return e[d]=t==null||t,e},C=function(){var e={},t=[];return N(function(n,r){return t.push(n)>i.cacheLength&&delete e[t.shift()],e[n+" "]=r},e)},k=C(),L=C(),A=C(),O="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",_=M.replace("w","w#"),D="([*^$|!~]?=)",P="\\["+O+"*("+M+")"+O+"*(?:"+D+O+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+_+")|)|)"+O+"*\\]",H=":("+M+")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:"+P+")|[^:]|\\\\.)*|.*))\\)|)",B=":(even|odd|eq|gt|lt|nth|first|last)(?:\\("+O+"*((?:-\\d)?\\d*)"+O+"*\\)|)(?=[^-]|$)",j=new RegExp("^"+O+"+|((?:^|[^\\\\])(?:\\\\.)*)"+O+"+$","g"),F=new RegExp("^"+O+"*,"+O+"*"),I=new RegExp("^"+O+"*([\\x20\\t\\r\\n\\f>+~])"+O+"*"),q=new RegExp(H),R=/^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,U=/^:not/,z=/[\x20\t\r\n\f]*[+~]/,W=/:not\($/,X=/h\d/i,V=/input|select|textarea|button/i,$=/\\(?!\\)/g,J={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),NAME:new RegExp("^\\[name=['\"]?("+M+")['\"]?\\]"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+H),POS:new RegExp(B,"i"),CHILD:new RegExp("^:(only|nth|first|last)-child(?:\\("+O+"*(even|odd|(([+-]|)(\\d*)n|)"+O+"*(?:([+-]|)"+O+"*(\\d+)|))"+O+"*\\)|)","i"),needsContext:new RegExp("^"+O+"*[>+~]|"+B,"i")},K=function(e){var t=g.createElement("div");try{return e(t)}catch(n){return!1}finally{t=null}},Q=K(function(e){return e.appendChild(g.createComment("")),!e.getElementsByTagName("*").length}),G=K(function(e){return e.innerHTML="<a href='#'></a>",e.firstChild&&typeof e.firstChild.getAttribute!==p&&e.firstChild.getAttribute("href")==="#"}),Y=K(function(e){e.innerHTML="<select></select>";var t=typeof e.lastChild.getAttribute("multiple");return t!=="boolean"&&t!=="string"}),Z=K(function(e){return e.innerHTML="<div class='hidden e'></div><div class='hidden'></div>",!e.getElementsByClassName||!e.getElementsByClassName("e").length?!1:(e.lastChild.className="e",e.getElementsByClassName("e").length===2)}),et=K(function(e){e.id=d+0,e.innerHTML="<a name='"+d+"'></a><div name='"+d+"'></div>",y.insertBefore(e,y.firstChild);var t=g.getElementsByName&&g.getElementsByName(d).length===2+g.getElementsByName(d+0).length;return r=!g.getElementById(d),y.removeChild(e),t});try{x.call(y.childNodes,0)[0].nodeType}catch(tt){x=function(e){var t,n=[];for(;t=this[e];e++)n.push(t);return n}}nt.matches=function(e,t){return nt(e,null,null,t)},nt.matchesSelector=function(e,t){return nt(t,null,null,[e]).length>0},s=nt.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(i===1||i===9||i===11){if(typeof e.textContent=="string")return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=s(e)}else if(i===3||i===4)return e.nodeValue}else for(;t=e[r];r++)n+=s(t);return n},o=nt.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?t.nodeName!=="HTML":!1},u=nt.contains=y.contains?function(e,t){var n=e.nodeType===9?e.documentElement:e,r=t&&t.parentNode;return e===r||!!(r&&r.nodeType===1&&n.contains&&n.contains(r))}:y.compareDocumentPosition?function(e,t){return t&&!!(e.compareDocumentPosition(t)&16)}:function(e,t){while(t=t.parentNode)if(t===e)return!0;return!1},nt.attr=function(e,t){var n,r=o(e);return r||(t=t.toLowerCase()),(n=i.attrHandle[t])?n(e):r||Y?e.getAttribute(t):(n=e.getAttributeNode(t),n?typeof e[t]=="boolean"?e[t]?t:null:n.specified?n.value:null:null)},i=nt.selectors={cacheLength:50,createPseudo:N,match:J,attrHandle:G?{}:{href:function(e){return e.getAttribute("href",2)},type:function(e){return e.getAttribute("type")}},find:{ID:r?function(e,t,n){if(typeof t.getElementById!==p&&!n){var r=t.getElementById(e);return r&&r.parentNode?[r]:[]}}:function(e,n,r){if(typeof n.getElementById!==p&&!r){var i=n.getElementById(e);return i?i.id===e||typeof i.getAttributeNode!==p&&i.getAttributeNode("id").value===e?[i]:t:[]}},TAG:Q?function(e,t){if(typeof t.getElementsByTagName!==p)return t.getElementsByTagName(e)}:function(e,t){var n=t.getElementsByTagName(e);if(e==="*"){var r,i=[],s=0;for(;r=n[s];s++)r.nodeType===1&&i.push(r);return i}return n},NAME:et&&function(e,t){if(typeof t.getElementsByName!==p)return t.getElementsByName(name)},CLASS:Z&&function(e,t,n){if(typeof t.getElementsByClassName!==p&&!n)return t.getElementsByClassName(e)}},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace($,""),e[3]=(e[4]||e[5]||"").replace($,""),e[2]==="~="&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),e[1]==="nth"?(e[2]||nt.error(e[0]),e[3]=+(e[3]?e[4]+(e[5]||1):2*(e[2]==="even"||e[2]==="odd")),e[4]=+(e[6]+e[7]||e[2]==="odd")):e[2]&&nt.error(e[0]),e},PSEUDO:function(e){var t,n;if(J.CHILD.test(e[0]))return null;if(e[3])e[2]=e[3];else if(t=e[4])q.test(t)&&(n=ut(t,!0))&&(n=t.indexOf(")",t.length-n)-t.length)&&(t=t.slice(0,n),e[0]=e[0].slice(0,n)),e[2]=t;return e.slice(0,3)}},filter:{ID:r?function(e){return e=e.replace($,""),function(t){return t.getAttribute("id")===e}}:function(e){return e=e.replace($,""),function(t){var n=typeof t.getAttributeNode!==p&&t.getAttributeNode("id");return n&&n.value===e}},TAG:function(e){return e==="*"?function(){return!0}:(e=e.replace($,"").toLowerCase(),function(t){return t.nodeName&&t.nodeName.toLowerCase()===e})},CLASS:function(e){var t=k[d][e+" "];return t||(t=new RegExp("(^|"+O+")"+e+"("+O+"|$)"))&&k(e,function(e){return t.test(e.className||typeof e.getAttribute!==p&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r,i){var s=nt.attr(r,e);return s==null?t==="!=":t?(s+="",t==="="?s===n:t==="!="?s!==n:t==="^="?n&&s.indexOf(n)===0:t==="*="?n&&s.indexOf(n)>-1:t==="$="?n&&s.substr(s.length-n.length)===n:t==="~="?(" "+s+" ").indexOf(n)>-1:t==="|="?s===n||s.substr(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r){return e==="nth"?function(e){var t,i,s=e.parentNode;if(n===1&&r===0)return!0;if(s){i=0;for(t=s.firstChild;t;t=t.nextSibling)if(t.nodeType===1){i++;if(e===t)break}}return i-=r,i===n||i%n===0&&i/n>=0}:function(t){var n=t;switch(e){case"only":case"first":while(n=n.previousSibling)if(n.nodeType===1)return!1;if(e==="first")return!0;n=t;case"last":while(n=n.nextSibling)if(n.nodeType===1)return!1;return!0}}},PSEUDO:function(e,t){var n,r=i.pseudos[e]||i.setFilters[e.toLowerCase()]||nt.error("unsupported pseudo: "+e);return r[d]?r(t):r.length>1?(n=[e,e,"",t],i.setFilters.hasOwnProperty(e.toLowerCase())?N(function(e,n){var i,s=r(e,t),o=s.length;while(o--)i=T.call(e,s[o]),e[i]=!(n[i]=s[o])}):function(e){return r(e,0,n)}):r}},pseudos:{not:N(function(e){var t=[],n=[],r=a(e.replace(j,"$1"));return r[d]?N(function(e,t,n,i){var s,o=r(e,null,i,[]),u=e.length;while(u--)if(s=o[u])e[u]=!(t[u]=s)}):function(e,i,s){return t[0]=e,r(t,null,s,n),!n.pop()}}),has:N(function(e){return function(t){return nt(e,t).length>0}}),contains:N(function(e){return function(t){return(t.textContent||t.innerText||s(t)).indexOf(e)>-1}}),enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return t==="input"&&!!e.checked||t==="option"&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},parent:function(e){return!i.pseudos.empty(e)},empty:function(e){var t;e=e.firstChild;while(e){if(e.nodeName>"@"||(t=e.nodeType)===3||t===4)return!1;e=e.nextSibling}return!0},header:function(e){return X.test(e.nodeName)},text:function(e){var t,n;return e.nodeName.toLowerCase()==="input"&&(t=e.type)==="text"&&((n=e.getAttribute("type"))==null||n.toLowerCase()===t)},radio:rt("radio"),checkbox:rt("checkbox"),file:rt("file"),password:rt("password"),image:rt("image"),submit:it("submit"),reset:it("reset"),button:function(e){var t=e.nodeName.toLowerCase();return t==="input"&&e.type==="button"||t==="button"},input:function(e){return V.test(e.nodeName)},focus:function(e){var t=e.ownerDocument;return e===t.activeElement&&(!t.hasFocus||t.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},active:function(e){return e===e.ownerDocument.activeElement},first:st(function(){return[0]}),last:st(function(e,t){return[t-1]}),eq:st(function(e,t,n){return[n<0?n+t:n]}),even:st(function(e,t){for(var n=0;n<t;n+=2)e.push(n);return e}),odd:st(function(e,t){for(var n=1;n<t;n+=2)e.push(n);return e}),lt:st(function(e,t,n){for(var r=n<0?n+t:n;--r>=0;)e.push(r);return e}),gt:st(function(e,t,n){for(var r=n<0?n+t:n;++r<t;)e.push(r);return e})}},f=y.compareDocumentPosition?function(e,t){return e===t?(l=!0,0):(!e.compareDocumentPosition||!t.compareDocumentPosition?e.compareDocumentPosition:e.compareDocumentPosition(t)&4)?-1:1}:function(e,t){if(e===t)return l=!0,0;if(e.sourceIndex&&t.sourceIndex)return e.sourceIndex-t.sourceIndex;var n,r,i=[],s=[],o=e.parentNode,u=t.parentNode,a=o;if(o===u)return ot(e,t);if(!o)return-1;if(!u)return 1;while(a)i.unshift(a),a=a.parentNode;a=u;while(a)s.unshift(a),a=a.parentNode;n=i.length,r=s.length;for(var f=0;f<n&&f<r;f++)if(i[f]!==s[f])return ot(i[f],s[f]);return f===n?ot(e,s[f],-1):ot(i[f],t,1)},[0,0].sort(f),h=!l,nt.uniqueSort=function(e){var t,n=[],r=1,i=0;l=h,e.sort(f);if(l){for(;t=e[r];r++)t===e[r-1]&&(i=n.push(r));while(i--)e.splice(n[i],1)}return e},nt.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},a=nt.compile=function(e,t){var n,r=[],i=[],s=A[d][e+" "];if(!s){t||(t=ut(e)),n=t.length;while(n--)s=ht(t[n]),s[d]?r.push(s):i.push(s);s=A(e,pt(i,r))}return s},g.querySelectorAll&&function(){var e,t=vt,n=/'|\\/g,r=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,i=[":focus"],s=[":active"],u=y.matchesSelector||y.mozMatchesSelector||y.webkitMatchesSelector||y.oMatchesSelector||y.msMatchesSelector;K(function(e){e.innerHTML="<select><option selected=''></option></select>",e.querySelectorAll("[selected]").length||i.push("\\["+O+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),e.querySelectorAll(":checked").length||i.push(":checked")}),K(function(e){e.innerHTML="<p test=''></p>",e.querySelectorAll("[test^='']").length&&i.push("[*^$]="+O+"*(?:\"\"|'')"),e.innerHTML="<input type='hidden'/>",e.querySelectorAll(":enabled").length||i.push(":enabled",":disabled")}),i=new RegExp(i.join("|")),vt=function(e,r,s,o,u){if(!o&&!u&&!i.test(e)){var a,f,l=!0,c=d,h=r,p=r.nodeType===9&&e;if(r.nodeType===1&&r.nodeName.toLowerCase()!=="object"){a=ut(e),(l=r.getAttribute("id"))?c=l.replace(n,"\\$&"):r.setAttribute("id",c),c="[id='"+c+"'] ",f=a.length;while(f--)a[f]=c+a[f].join("");h=z.test(e)&&r.parentNode||r,p=a.join(",")}if(p)try{return S.apply(s,x.call(h.querySelectorAll(p),0)),s}catch(v){}finally{l||r.removeAttribute("id")}}return t(e,r,s,o,u)},u&&(K(function(t){e=u.call(t,"div");try{u.call(t,"[test!='']:sizzle"),s.push("!=",H)}catch(n){}}),s=new RegExp(s.join("|")),nt.matchesSelector=function(t,n){n=n.replace(r,"='$1']");if(!o(t)&&!s.test(n)&&!i.test(n))try{var a=u.call(t,n);if(a||e||t.document&&t.document.nodeType!==11)return a}catch(f){}return nt(n,null,null,[t]).length>0})}(),i.pseudos.nth=i.pseudos.eq,i.filters=mt.prototype=i.pseudos,i.setFilters=new mt,nt.attr=v.attr,v.find=nt,v.expr=nt.selectors,v.expr[":"]=v.expr.pseudos,v.unique=nt.uniqueSort,v.text=nt.getText,v.isXMLDoc=nt.isXML,v.contains=nt.contains}(e);var nt=/Until$/,rt=/^(?:parents|prev(?:Until|All))/,it=/^.[^:#\[\.,]*$/,st=v.expr.match.needsContext,ot={children:!0,contents:!0,next:!0,prev:!0};v.fn.extend({find:function(e){var t,n,r,i,s,o,u=this;if(typeof e!="string")return v(e).filter(function(){for(t=0,n=u.length;t<n;t++)if(v.contains(u[t],this))return!0});o=this.pushStack("","find",e);for(t=0,n=this.length;t<n;t++){r=o.length,v.find(e,this[t],o);if(t>0)for(i=r;i<o.length;i++)for(s=0;s<r;s++)if(o[s]===o[i]){o.splice(i--,1);break}}return o},has:function(e){var t,n=v(e,this),r=n.length;return this.filter(function(){for(t=0;t<r;t++)if(v.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e,!1),"not",e)},filter:function(e){return this.pushStack(ft(this,e,!0),"filter",e)},is:function(e){return!!e&&(typeof e=="string"?st.test(e)?v(e,this.context).index(this[0])>=0:v.filter(e,this).length>0:this.filter(e).length>0)},closest:function(e,t){var n,r=0,i=this.length,s=[],o=st.test(e)||typeof e!="string"?v(e,t||this.context):0;for(;r<i;r++){n=this[r];while(n&&n.ownerDocument&&n!==t&&n.nodeType!==11){if(o?o.index(n)>-1:v.find.matchesSelector(n,e)){s.push(n);break}n=n.parentNode}}return s=s.length>1?v.unique(s):s,this.pushStack(s,"closest",e)},index:function(e){return e?typeof e=="string"?v.inArray(this[0],v(e)):v.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.prevAll().length:-1},add:function(e,t){var n=typeof e=="string"?v(e,t):v.makeArray(e&&e.nodeType?[e]:e),r=v.merge(this.get(),n);return this.pushStack(ut(n[0])||ut(r[0])?r:v.unique(r))},addBack:function(e){return this.add(e==null?this.prevObject:this.prevObject.filter(e))}}),v.fn.andSelf=v.fn.addBack,v.each({parent:function(e){var t=e.parentNode;return t&&t.nodeType!==11?t:null},parents:function(e){return v.dir(e,"parentNode")},parentsUntil:function(e,t,n){return v.dir(e,"parentNode",n)},next:function(e){return at(e,"nextSibling")},prev:function(e){return at(e,"previousSibling")},nextAll:function(e){return v.dir(e,"nextSibling")},prevAll:function(e){return v.dir(e,"previousSibling")},nextUntil:function(e,t,n){return v.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return v.dir(e,"previousSibling",n)},siblings:function(e){return v.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return v.sibling(e.firstChild)},contents:function(e){return v.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:v.merge([],e.childNodes)}},function(e,t){v.fn[e]=function(n,r){var i=v.map(this,t,n);return nt.test(e)||(r=n),r&&typeof r=="string"&&(i=v.filter(r,i)),i=this.length>1&&!ot[e]?v.unique(i):i,this.length>1&&rt.test(e)&&(i=i.reverse()),this.pushStack(i,e,l.call(arguments).join(","))}}),v.extend({filter:function(e,t,n){return n&&(e=":not("+e+")"),t.length===1?v.find.matchesSelector(t[0],e)?[t[0]]:[]:v.find.matches(e,t)},dir:function(e,n,r){var i=[],s=e[n];while(s&&s.nodeType!==9&&(r===t||s.nodeType!==1||!v(s).is(r)))s.nodeType===1&&i.push(s),s=s[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)e.nodeType===1&&e!==t&&n.push(e);return n}});var ct="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",ht=/ jQuery\d+="(?:null|\d+)"/g,pt=/^\s+/,dt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,vt=/<([\w:]+)/,mt=/<tbody/i,gt=/<|&#?\w+;/,yt=/<(?:script|style|link)/i,bt=/<(?:script|object|embed|option|style)/i,wt=new RegExp("<(?:"+ct+")[\\s/>]","i"),Et=/^(?:checkbox|radio)$/,St=/checked\s*(?:[^=]|=\s*.checked.)/i,xt=/\/(java|ecma)script/i,Tt=/^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g,Nt={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]},Ct=lt(i),kt=Ct.appendChild(i.createElement("div"));Nt.optgroup=Nt.option,Nt.tbody=Nt.tfoot=Nt.colgroup=Nt.caption=Nt.thead,Nt.th=Nt.td,v.support.htmlSerialize||(Nt._default=[1,"X<div>","</div>"]),v.fn.extend({text:function(e){return v.access(this,function(e){return e===t?v.text(this):this.empty().append((this[0]&&this[0].ownerDocument||i).createTextNode(e))},null,e,arguments.length)},wrapAll:function(e){if(v.isFunction(e))return this.each(function(t){v(this).wrapAll(e.call(this,t))});if(this[0]){var t=v(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&e.firstChild.nodeType===1)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return v.isFunction(e)?this.each(function(t){v(this).wrapInner(e.call(this,t))}):this.each(function(){var t=v(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=v.isFunction(e);return this.each(function(n){v(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){v.nodeName(this,"body")||v(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(e){(this.nodeType===1||this.nodeType===11)&&this.appendChild(e)})},prepend:function(){return this.domManip(arguments,!0,function(e){(this.nodeType===1||this.nodeType===11)&&this.insertBefore(e,this.firstChild)})},before:function(){if(!ut(this[0]))return this.domManip(arguments,!1,function(e){this.parentNode.insertBefore(e,this)});if(arguments.length){var e=v.clean(arguments);return this.pushStack(v.merge(e,this),"before",this.selector)}},after:function(){if(!ut(this[0]))return this.domManip(arguments,!1,function(e){this.parentNode.insertBefore(e,this.nextSibling)});if(arguments.length){var e=v.clean(arguments);return this.pushStack(v.merge(this,e),"after",this.selector)}},remove:function(e,t){var n,r=0;for(;(n=this[r])!=null;r++)if(!e||v.filter(e,[n]).length)!t&&n.nodeType===1&&(v.cleanData(n.getElementsByTagName("*")),v.cleanData([n])),n.parentNode&&n.parentNode.removeChild(n);return this},empty:function(){var e,t=0;for(;(e=this[t])!=null;t++){e.nodeType===1&&v.cleanData(e.getElementsByTagName("*"));while(e.firstChild)e.removeChild(e.firstChild)}return this},clone:function(e,t){return e=e==null?!1:e,t=t==null?e:t,this.map(function(){return v.clone(this,e,t)})},html:function(e){return v.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return n.nodeType===1?n.innerHTML.replace(ht,""):t;if(typeof e=="string"&&!yt.test(e)&&(v.support.htmlSerialize||!wt.test(e))&&(v.support.leadingWhitespace||!pt.test(e))&&!Nt[(vt.exec(e)||["",""])[1].toLowerCase()]){e=e.replace(dt,"<$1></$2>");try{for(;r<i;r++)n=this[r]||{},n.nodeType===1&&(v.cleanData(n.getElementsByTagName("*")),n.innerHTML=e);n=0}catch(s){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(e){return ut(this[0])?this.length?this.pushStack(v(v.isFunction(e)?e():e),"replaceWith",e):this:v.isFunction(e)?this.each(function(t){var n=v(this),r=n.html();n.replaceWith(e.call(this,t,r))}):(typeof e!="string"&&(e=v(e).detach()),this.each(function(){var t=this.nextSibling,n=this.parentNode;v(this).remove(),t?v(t).before(e):v(n).append(e)}))},detach:function(e){return this.remove(e,!0)},domManip:function(e,n,r){e=[].concat.apply([],e);var i,s,o,u,a=0,f=e[0],l=[],c=this.length;if(!v.support.checkClone&&c>1&&typeof f=="string"&&St.test(f))return this.each(function(){v(this).domManip(e,n,r)});if(v.isFunction(f))return this.each(function(i){var s=v(this);e[0]=f.call(this,i,n?s.html():t),s.domManip(e,n,r)});if(this[0]){i=v.buildFragment(e,this,l),o=i.fragment,s=o.firstChild,o.childNodes.length===1&&(o=s);if(s){n=n&&v.nodeName(s,"tr");for(u=i.cacheable||c-1;a<c;a++)r.call(n&&v.nodeName(this[a],"table")?Lt(this[a],"tbody"):this[a],a===u?o:v.clone(o,!0,!0))}o=s=null,l.length&&v.each(l,function(e,t){t.src?v.ajax?v.ajax({url:t.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):v.error("no ajax"):v.globalEval((t.text||t.textContent||t.innerHTML||"").replace(Tt,"")),t.parentNode&&t.parentNode.removeChild(t)})}return this}}),v.buildFragment=function(e,n,r){var s,o,u,a=e[0];return n=n||i,n=!n.nodeType&&n[0]||n,n=n.ownerDocument||n,e.length===1&&typeof a=="string"&&a.length<512&&n===i&&a.charAt(0)==="<"&&!bt.test(a)&&(v.support.checkClone||!St.test(a))&&(v.support.html5Clone||!wt.test(a))&&(o=!0,s=v.fragments[a],u=s!==t),s||(s=n.createDocumentFragment(),v.clean(e,n,s,r),o&&(v.fragments[a]=u&&s)),{fragment:s,cacheable:o}},v.fragments={},v.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){v.fn[e]=function(n){var r,i=0,s=[],o=v(n),u=o.length,a=this.length===1&&this[0].parentNode;if((a==null||a&&a.nodeType===11&&a.childNodes.length===1)&&u===1)return o[t](this[0]),this;for(;i<u;i++)r=(i>0?this.clone(!0):this).get(),v(o[i])[t](r),s=s.concat(r);return this.pushStack(s,e,o.selector)}}),v.extend({clone:function(e,t,n){var r,i,s,o;v.support.html5Clone||v.isXMLDoc(e)||!wt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(kt.innerHTML=e.outerHTML,kt.removeChild(o=kt.firstChild));if((!v.support.noCloneEvent||!v.support.noCloneChecked)&&(e.nodeType===1||e.nodeType===11)&&!v.isXMLDoc(e)){Ot(e,o),r=Mt(e),i=Mt(o);for(s=0;r[s];++s)i[s]&&Ot(r[s],i[s])}if(t){At(e,o);if(n){r=Mt(e),i=Mt(o);for(s=0;r[s];++s)At(r[s],i[s])}}return r=i=null,o},clean:function(e,t,n,r){var s,o,u,a,f,l,c,h,p,d,m,g,y=t===i&&Ct,b=[];if(!t||typeof t.createDocumentFragment=="undefined")t=i;for(s=0;(u=e[s])!=null;s++){typeof u=="number"&&(u+="");if(!u)continue;if(typeof u=="string")if(!gt.test(u))u=t.createTextNode(u);else{y=y||lt(t),c=t.createElement("div"),y.appendChild(c),u=u.replace(dt,"<$1></$2>"),a=(vt.exec(u)||["",""])[1].toLowerCase(),f=Nt[a]||Nt._default,l=f[0],c.innerHTML=f[1]+u+f[2];while(l--)c=c.lastChild;if(!v.support.tbody){h=mt.test(u),p=a==="table"&&!h?c.firstChild&&c.firstChild.childNodes:f[1]==="<table>"&&!h?c.childNodes:[];for(o=p.length-1;o>=0;--o)v.nodeName(p[o],"tbody")&&!p[o].childNodes.length&&p[o].parentNode.removeChild(p[o])}!v.support.leadingWhitespace&&pt.test(u)&&c.insertBefore(t.createTextNode(pt.exec(u)[0]),c.firstChild),u=c.childNodes,c.parentNode.removeChild(c)}u.nodeType?b.push(u):v.merge(b,u)}c&&(u=c=y=null);if(!v.support.appendChecked)for(s=0;(u=b[s])!=null;s++)v.nodeName(u,"input")?_t(u):typeof u.getElementsByTagName!="undefined"&&v.grep(u.getElementsByTagName("input"),_t);if(n){m=function(e){if(!e.type||xt.test(e.type))return r?r.push(e.parentNode?e.parentNode.removeChild(e):e):n.appendChild(e)};for(s=0;(u=b[s])!=null;s++)if(!v.nodeName(u,"script")||!m(u))n.appendChild(u),typeof u.getElementsByTagName!="undefined"&&(g=v.grep(v.merge([],u.getElementsByTagName("script")),m),b.splice.apply(b,[s+1,0].concat(g)),s+=g.length)}return b},cleanData:function(e,t){var n,r,i,s,o=0,u=v.expando,a=v.cache,f=v.support.deleteExpando,l=v.event.special;for(;(i=e[o])!=null;o++)if(t||v.acceptData(i)){r=i[u],n=r&&a[r];if(n){if(n.events)for(s in n.events)l[s]?v.event.remove(i,s):v.removeEvent(i,s,n.handle);a[r]&&(delete a[r],f?delete i[u]:i.removeAttribute?i.removeAttribute(u):i[u]=null,v.deletedIds.push(r))}}}}),function(){var e,t;v.uaMatch=function(e){e=e.toLowerCase();var t=/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return{browser:t[1]||"",version:t[2]||"0"}},e=v.uaMatch(o.userAgent),t={},e.browser&&(t[e.browser]=!0,t.version=e.version),t.chrome?t.webkit=!0:t.webkit&&(t.safari=!0),v.browser=t,v.sub=function(){function e(t,n){return new e.fn.init(t,n)}v.extend(!0,e,this),e.superclass=this,e.fn=e.prototype=this(),e.fn.constructor=e,e.sub=this.sub,e.fn.init=function(r,i){return i&&i instanceof v&&!(i instanceof e)&&(i=e(i)),v.fn.init.call(this,r,i,t)},e.fn.init.prototype=e.fn;var t=e(i);return e}}();var Dt,Pt,Ht,Bt=/alpha\([^)]*\)/i,jt=/opacity=([^)]*)/,Ft=/^(top|right|bottom|left)$/,It=/^(none|table(?!-c[ea]).+)/,qt=/^margin/,Rt=new RegExp("^("+m+")(.*)$","i"),Ut=new RegExp("^("+m+")(?!px)[a-z%]+$","i"),zt=new RegExp("^([-+])=("+m+")","i"),Wt={BODY:"block"},Xt={position:"absolute",visibility:"hidden",display:"block"},Vt={letterSpacing:0,fontWeight:400},$t=["Top","Right","Bottom","Left"],Jt=["Webkit","O","Moz","ms"],Kt=v.fn.toggle;v.fn.extend({css:function(e,n){return v.access(this,function(e,n,r){return r!==t?v.style(e,n,r):v.css(e,n)},e,n,arguments.length>1)},show:function(){return Yt(this,!0)},hide:function(){return Yt(this)},toggle:function(e,t){var n=typeof e=="boolean";return v.isFunction(e)&&v.isFunction(t)?Kt.apply(this,arguments):this.each(function(){(n?e:Gt(this))?v(this).show():v(this).hide()})}}),v.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Dt(e,"opacity");return n===""?"1":n}}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":v.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(!e||e.nodeType===3||e.nodeType===8||!e.style)return;var s,o,u,a=v.camelCase(n),f=e.style;n=v.cssProps[a]||(v.cssProps[a]=Qt(f,a)),u=v.cssHooks[n]||v.cssHooks[a];if(r===t)return u&&"get"in u&&(s=u.get(e,!1,i))!==t?s:f[n];o=typeof r,o==="string"&&(s=zt.exec(r))&&(r=(s[1]+1)*s[2]+parseFloat(v.css(e,n)),o="number");if(r==null||o==="number"&&isNaN(r))return;o==="number"&&!v.cssNumber[a]&&(r+="px");if(!u||!("set"in u)||(r=u.set(e,r,i))!==t)try{f[n]=r}catch(l){}},css:function(e,n,r,i){var s,o,u,a=v.camelCase(n);return n=v.cssProps[a]||(v.cssProps[a]=Qt(e.style,a)),u=v.cssHooks[n]||v.cssHooks[a],u&&"get"in u&&(s=u.get(e,!0,i)),s===t&&(s=Dt(e,n)),s==="normal"&&n in Vt&&(s=Vt[n]),r||i!==t?(o=parseFloat(s),r||v.isNumeric(o)?o||0:s):s},swap:function(e,t,n){var r,i,s={};for(i in t)s[i]=e.style[i],e.style[i]=t[i];r=n.call(e);for(i in t)e.style[i]=s[i];return r}}),e.getComputedStyle?Dt=function(t,n){var r,i,s,o,u=e.getComputedStyle(t,null),a=t.style;return u&&(r=u.getPropertyValue(n)||u[n],r===""&&!v.contains(t.ownerDocument,t)&&(r=v.style(t,n)),Ut.test(r)&&qt.test(n)&&(i=a.width,s=a.minWidth,o=a.maxWidth,a.minWidth=a.maxWidth=a.width=r,r=u.width,a.width=i,a.minWidth=s,a.maxWidth=o)),r}:i.documentElement.currentStyle&&(Dt=function(e,t){var n,r,i=e.currentStyle&&e.currentStyle[t],s=e.style;return i==null&&s&&s[t]&&(i=s[t]),Ut.test(i)&&!Ft.test(t)&&(n=s.left,r=e.runtimeStyle&&e.runtimeStyle.left,r&&(e.runtimeStyle.left=e.currentStyle.left),s.left=t==="fontSize"?"1em":i,i=s.pixelLeft+"px",s.left=n,r&&(e.runtimeStyle.left=r)),i===""?"auto":i}),v.each(["height","width"],function(e,t){v.cssHooks[t]={get:function(e,n,r){if(n)return e.offsetWidth===0&&It.test(Dt(e,"display"))?v.swap(e,Xt,function(){return tn(e,t,r)}):tn(e,t,r)},set:function(e,n,r){return Zt(e,n,r?en(e,t,r,v.support.boxSizing&&v.css(e,"boxSizing")==="border-box"):0)}}}),v.support.opacity||(v.cssHooks.opacity={get:function(e,t){return jt.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var n=e.style,r=e.currentStyle,i=v.isNumeric(t)?"alpha(opacity="+t*100+")":"",s=r&&r.filter||n.filter||"";n.zoom=1;if(t>=1&&v.trim(s.replace(Bt,""))===""&&n.removeAttribute){n.removeAttribute("filter");if(r&&!r.filter)return}n.filter=Bt.test(s)?s.replace(Bt,i):s+" "+i}}),v(function(){v.support.reliableMarginRight||(v.cssHooks.marginRight={get:function(e,t){return v.swap(e,{display:"inline-block"},function(){if(t)return Dt(e,"marginRight")})}}),!v.support.pixelPosition&&v.fn.position&&v.each(["top","left"],function(e,t){v.cssHooks[t]={get:function(e,n){if(n){var r=Dt(e,t);return Ut.test(r)?v(e).position()[t]+"px":r}}}})}),v.expr&&v.expr.filters&&(v.expr.filters.hidden=function(e){return e.offsetWidth===0&&e.offsetHeight===0||!v.support.reliableHiddenOffsets&&(e.style&&e.style.display||Dt(e,"display"))==="none"},v.expr.filters.visible=function(e){return!v.expr.filters.hidden(e)}),v.each({margin:"",padding:"",border:"Width"},function(e,t){v.cssHooks[e+t]={expand:function(n){var r,i=typeof n=="string"?n.split(" "):[n],s={};for(r=0;r<4;r++)s[e+$t[r]+t]=i[r]||i[r-2]||i[0];return s}},qt.test(e)||(v.cssHooks[e+t].set=Zt)});var rn=/%20/g,sn=/\[\]$/,on=/\r?\n/g,un=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,an=/^(?:select|textarea)/i;v.fn.extend({serialize:function(){return v.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?v.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||an.test(this.nodeName)||un.test(this.type))}).map(function(e,t){var n=v(this).val();return n==null?null:v.isArray(n)?v.map(n,function(e,n){return{name:t.name,value:e.replace(on,"\r\n")}}):{name:t.name,value:n.replace(on,"\r\n")}}).get()}}),v.param=function(e,n){var r,i=[],s=function(e,t){t=v.isFunction(t)?t():t==null?"":t,i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};n===t&&(n=v.ajaxSettings&&v.ajaxSettings.traditional);if(v.isArray(e)||e.jquery&&!v.isPlainObject(e))v.each(e,function(){s(this.name,this.value)});else for(r in e)fn(r,e[r],n,s);return i.join("&").replace(rn,"+")};var ln,cn,hn=/#.*$/,pn=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,dn=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,vn=/^(?:GET|HEAD)$/,mn=/^\/\//,gn=/\?/,yn=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,bn=/([?&])_=[^&]*/,wn=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,En=v.fn.load,Sn={},xn={},Tn=["*/"]+["*"];try{cn=s.href}catch(Nn){cn=i.createElement("a"),cn.href="",cn=cn.href}ln=wn.exec(cn.toLowerCase())||[],v.fn.load=function(e,n,r){if(typeof e!="string"&&En)return En.apply(this,arguments);if(!this.length)return this;var i,s,o,u=this,a=e.indexOf(" ");return a>=0&&(i=e.slice(a,e.length),e=e.slice(0,a)),v.isFunction(n)?(r=n,n=t):n&&typeof n=="object"&&(s="POST"),v.ajax({url:e,type:s,dataType:"html",data:n,complete:function(e,t){r&&u.each(r,o||[e.responseText,t,e])}}).done(function(e){o=arguments,u.html(i?v("<div>").append(e.replace(yn,"")).find(i):e)}),this},v.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(e,t){v.fn[t]=function(e){return this.on(t,e)}}),v.each(["get","post"],function(e,n){v[n]=function(e,r,i,s){return v.isFunction(r)&&(s=s||i,i=r,r=t),v.ajax({type:n,url:e,data:r,success:i,dataType:s})}}),v.extend({getScript:function(e,n){return v.get(e,t,n,"script")},getJSON:function(e,t,n){return v.get(e,t,n,"json")},ajaxSetup:function(e,t){return t?Ln(e,v.ajaxSettings):(t=e,e=v.ajaxSettings),Ln(e,t),e},ajaxSettings:{url:cn,isLocal:dn.test(ln[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":Tn},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":e.String,"text html":!0,"text json":v.parseJSON,"text xml":v.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:Cn(Sn),ajaxTransport:Cn(xn),ajax:function(e,n){function T(e,n,s,a){var l,y,b,w,S,T=n;if(E===2)return;E=2,u&&clearTimeout(u),o=t,i=a||"",x.readyState=e>0?4:0,s&&(w=An(c,x,s));if(e>=200&&e<300||e===304)c.ifModified&&(S=x.getResponseHeader("Last-Modified"),S&&(v.lastModified[r]=S),S=x.getResponseHeader("Etag"),S&&(v.etag[r]=S)),e===304?(T="notmodified",l=!0):(l=On(c,w),T=l.state,y=l.data,b=l.error,l=!b);else{b=T;if(!T||e)T="error",e<0&&(e=0)}x.status=e,x.statusText=(n||T)+"",l?d.resolveWith(h,[y,T,x]):d.rejectWith(h,[x,T,b]),x.statusCode(g),g=t,f&&p.trigger("ajax"+(l?"Success":"Error"),[x,c,l?y:b]),m.fireWith(h,[x,T]),f&&(p.trigger("ajaxComplete",[x,c]),--v.active||v.event.trigger("ajaxStop"))}typeof e=="object"&&(n=e,e=t),n=n||{};var r,i,s,o,u,a,f,l,c=v.ajaxSetup({},n),h=c.context||c,p=h!==c&&(h.nodeType||h instanceof v)?v(h):v.event,d=v.Deferred(),m=v.Callbacks("once memory"),g=c.statusCode||{},b={},w={},E=0,S="canceled",x={readyState:0,setRequestHeader:function(e,t){if(!E){var n=e.toLowerCase();e=w[n]=w[n]||e,b[e]=t}return this},getAllResponseHeaders:function(){return E===2?i:null},getResponseHeader:function(e){var n;if(E===2){if(!s){s={};while(n=pn.exec(i))s[n[1].toLowerCase()]=n[2]}n=s[e.toLowerCase()]}return n===t?null:n},overrideMimeType:function(e){return E||(c.mimeType=e),this},abort:function(e){return e=e||S,o&&o.abort(e),T(0,e),this}};d.promise(x),x.success=x.done,x.error=x.fail,x.complete=m.add,x.statusCode=function(e){if(e){var t;if(E<2)for(t in e)g[t]=[g[t],e[t]];else t=e[x.status],x.always(t)}return this},c.url=((e||c.url)+"").replace(hn,"").replace(mn,ln[1]+"//"),c.dataTypes=v.trim(c.dataType||"*").toLowerCase().split(y),c.crossDomain==null&&(a=wn.exec(c.url.toLowerCase()),c.crossDomain=!(!a||a[1]===ln[1]&&a[2]===ln[2]&&(a[3]||(a[1]==="http:"?80:443))==(ln[3]||(ln[1]==="http:"?80:443)))),c.data&&c.processData&&typeof c.data!="string"&&(c.data=v.param(c.data,c.traditional)),kn(Sn,c,n,x);if(E===2)return x;f=c.global,c.type=c.type.toUpperCase(),c.hasContent=!vn.test(c.type),f&&v.active++===0&&v.event.trigger("ajaxStart");if(!c.hasContent){c.data&&(c.url+=(gn.test(c.url)?"&":"?")+c.data,delete c.data),r=c.url;if(c.cache===!1){var N=v.now(),C=c.url.replace(bn,"$1_="+N);c.url=C+(C===c.url?(gn.test(c.url)?"&":"?")+"_="+N:"")}}(c.data&&c.hasContent&&c.contentType!==!1||n.contentType)&&x.setRequestHeader("Content-Type",c.contentType),c.ifModified&&(r=r||c.url,v.lastModified[r]&&x.setRequestHeader("If-Modified-Since",v.lastModified[r]),v.etag[r]&&x.setRequestHeader("If-None-Match",v.etag[r])),x.setRequestHeader("Accept",c.dataTypes[0]&&c.accepts[c.dataTypes[0]]?c.accepts[c.dataTypes[0]]+(c.dataTypes[0]!=="*"?", "+Tn+"; q=0.01":""):c.accepts["*"]);for(l in c.headers)x.setRequestHeader(l,c.headers[l]);if(!c.beforeSend||c.beforeSend.call(h,x,c)!==!1&&E!==2){S="abort";for(l in{success:1,error:1,complete:1})x[l](c[l]);o=kn(xn,c,n,x);if(!o)T(-1,"No Transport");else{x.readyState=1,f&&p.trigger("ajaxSend",[x,c]),c.async&&c.timeout>0&&(u=setTimeout(function(){x.abort("timeout")},c.timeout));try{E=1,o.send(b,T)}catch(k){if(!(E<2))throw k;T(-1,k)}}return x}return x.abort()},active:0,lastModified:{},etag:{}});var Mn=[],_n=/\?/,Dn=/(=)\?(?=&|$)|\?\?/,Pn=v.now();v.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Mn.pop()||v.expando+"_"+Pn++;return this[e]=!0,e}}),v.ajaxPrefilter("json jsonp",function(n,r,i){var s,o,u,a=n.data,f=n.url,l=n.jsonp!==!1,c=l&&Dn.test(f),h=l&&!c&&typeof a=="string"&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Dn.test(a);if(n.dataTypes[0]==="jsonp"||c||h)return s=n.jsonpCallback=v.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,o=e[s],c?n.url=f.replace(Dn,"$1"+s):h?n.data=a.replace(Dn,"$1"+s):l&&(n.url+=(_n.test(f)?"&":"?")+n.jsonp+"="+s),n.converters["script json"]=function(){return u||v.error(s+" was not called"),u[0]},n.dataTypes[0]="json",e[s]=function(){u=arguments},i.always(function(){e[s]=o,n[s]&&(n.jsonpCallback=r.jsonpCallback,Mn.push(s)),u&&v.isFunction(o)&&o(u[0]),u=o=t}),"script"}),v.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(e){return v.globalEval(e),e}}}),v.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),v.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=i.head||i.getElementsByTagName("head")[0]||i.documentElement;return{send:function(s,o){n=i.createElement("script"),n.async="async",e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,i){if(i||!n.readyState||/loaded|complete/.test(n.readyState))n.onload=n.onreadystatechange=null,r&&n.parentNode&&r.removeChild(n),n=t,i||o(200,"success")},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(0,1)}}}});var Hn,Bn=e.ActiveXObject?function(){for(var e in Hn)Hn[e](0,1)}:!1,jn=0;v.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&Fn()||In()}:Fn,function(e){v.extend(v.support,{ajax:!!e,cors:!!e&&"withCredentials"in e})}(v.ajaxSettings.xhr()),v.support.ajax&&v.ajaxTransport(function(n){if(!n.crossDomain||v.support.cors){var r;return{send:function(i,s){var o,u,a=n.xhr();n.username?a.open(n.type,n.url,n.async,n.username,n.password):a.open(n.type,n.url,n.async);if(n.xhrFields)for(u in n.xhrFields)a[u]=n.xhrFields[u];n.mimeType&&a.overrideMimeType&&a.overrideMimeType(n.mimeType),!n.crossDomain&&!i["X-Requested-With"]&&(i["X-Requested-With"]="XMLHttpRequest");try{for(u in i)a.setRequestHeader(u,i[u])}catch(f){}a.send(n.hasContent&&n.data||null),r=function(e,i){var u,f,l,c,h;try{if(r&&(i||a.readyState===4)){r=t,o&&(a.onreadystatechange=v.noop,Bn&&delete Hn[o]);if(i)a.readyState!==4&&a.abort();else{u=a.status,l=a.getAllResponseHeaders(),c={},h=a.responseXML,h&&h.documentElement&&(c.xml=h);try{c.text=a.responseText}catch(p){}try{f=a.statusText}catch(p){f=""}!u&&n.isLocal&&!n.crossDomain?u=c.text?200:404:u===1223&&(u=204)}}}catch(d){i||s(-1,d)}c&&s(u,f,c,l)},n.async?a.readyState===4?setTimeout(r,0):(o=++jn,Bn&&(Hn||(Hn={},v(e).unload(Bn)),Hn[o]=r),a.onreadystatechange=r):r()},abort:function(){r&&r(0,1)}}}});var qn,Rn,Un=/^(?:toggle|show|hide)$/,zn=new RegExp("^(?:([-+])=|)("+m+")([a-z%]*)$","i"),Wn=/queueHooks$/,Xn=[Gn],Vn={"*":[function(e,t){var n,r,i=this.createTween(e,t),s=zn.exec(t),o=i.cur(),u=+o||0,a=1,f=20;if(s){n=+s[2],r=s[3]||(v.cssNumber[e]?"":"px");if(r!=="px"&&u){u=v.css(i.elem,e,!0)||n||1;do a=a||".5",u/=a,v.style(i.elem,e,u+r);while(a!==(a=i.cur()/o)&&a!==1&&--f)}i.unit=r,i.start=u,i.end=s[1]?u+(s[1]+1)*n:n}return i}]};v.Animation=v.extend(Kn,{tweener:function(e,t){v.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;r<i;r++)n=e[r],Vn[n]=Vn[n]||[],Vn[n].unshift(t)},prefilter:function(e,t){t?Xn.unshift(e):Xn.push(e)}}),v.Tween=Yn,Yn.prototype={constructor:Yn,init:function(e,t,n,r,i,s){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=s||(v.cssNumber[n]?"":"px")},cur:function(){var e=Yn.propHooks[this.prop];return e&&e.get?e.get(this):Yn.propHooks._default.get(this)},run:function(e){var t,n=Yn.propHooks[this.prop];return this.options.duration?this.pos=t=v.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):Yn.propHooks._default.set(this),this}},Yn.prototype.init.prototype=Yn.prototype,Yn.propHooks={_default:{get:function(e){var t;return e.elem[e.prop]==null||!!e.elem.style&&e.elem.style[e.prop]!=null?(t=v.css(e.elem,e.prop,!1,""),!t||t==="auto"?0:t):e.elem[e.prop]},set:function(e){v.fx.step[e.prop]?v.fx.step[e.prop](e):e.elem.style&&(e.elem.style[v.cssProps[e.prop]]!=null||v.cssHooks[e.prop])?v.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},Yn.propHooks.scrollTop=Yn.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},v.each(["toggle","show","hide"],function(e,t){var n=v.fn[t];v.fn[t]=function(r,i,s){return r==null||typeof r=="boolean"||!e&&v.isFunction(r)&&v.isFunction(i)?n.apply(this,arguments):this.animate(Zn(t,!0),r,i,s)}}),v.fn.extend({fadeTo:function(e,t,n,r){return this.filter(Gt).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=v.isEmptyObject(e),s=v.speed(t,n,r),o=function(){var t=Kn(this,v.extend({},e),s);i&&t.stop(!0)};return i||s.queue===!1?this.each(o):this.queue(s.queue,o)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return typeof e!="string"&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=e!=null&&e+"queueHooks",s=v.timers,o=v._data(this);if(n)o[n]&&o[n].stop&&i(o[n]);else for(n in o)o[n]&&o[n].stop&&Wn.test(n)&&i(o[n]);for(n=s.length;n--;)s[n].elem===this&&(e==null||s[n].queue===e)&&(s[n].anim.stop(r),t=!1,s.splice(n,1));(t||!r)&&v.dequeue(this,e)})}}),v.each({slideDown:Zn("show"),slideUp:Zn("hide"),slideToggle:Zn("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){v.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),v.speed=function(e,t,n){var r=e&&typeof e=="object"?v.extend({},e):{complete:n||!n&&t||v.isFunction(e)&&e,duration:e,easing:n&&t||t&&!v.isFunction(t)&&t};r.duration=v.fx.off?0:typeof r.duration=="number"?r.duration:r.duration in v.fx.speeds?v.fx.speeds[r.duration]:v.fx.speeds._default;if(r.queue==null||r.queue===!0)r.queue="fx";return r.old=r.complete,r.complete=function(){v.isFunction(r.old)&&r.old.call(this),r.queue&&v.dequeue(this,r.queue)},r},v.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},v.timers=[],v.fx=Yn.prototype.init,v.fx.tick=function(){var e,n=v.timers,r=0;qn=v.now();for(;r<n.length;r++)e=n[r],!e()&&n[r]===e&&n.splice(r--,1);n.length||v.fx.stop(),qn=t},v.fx.timer=function(e){e()&&v.timers.push(e)&&!Rn&&(Rn=setInterval(v.fx.tick,v.fx.interval))},v.fx.interval=13,v.fx.stop=function(){clearInterval(Rn),Rn=null},v.fx.speeds={slow:600,fast:200,_default:400},v.fx.step={},v.expr&&v.expr.filters&&(v.expr.filters.animated=function(e){return v.grep(v.timers,function(t){return e===t.elem}).length});var er=/^(?:body|html)$/i;v.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){v.offset.setOffset(this,e,t)});var n,r,i,s,o,u,a,f={top:0,left:0},l=this[0],c=l&&l.ownerDocument;if(!c)return;return(r=c.body)===l?v.offset.bodyOffset(l):(n=c.documentElement,v.contains(n,l)?(typeof l.getBoundingClientRect!="undefined"&&(f=l.getBoundingClientRect()),i=tr(c),s=n.clientTop||r.clientTop||0,o=n.clientLeft||r.clientLeft||0,u=i.pageYOffset||n.scrollTop,a=i.pageXOffset||n.scrollLeft,{top:f.top+u-s,left:f.left+a-o}):f)},v.offset={bodyOffset:function(e){var t=e.offsetTop,n=e.offsetLeft;return v.support.doesNotIncludeMarginInBodyOffset&&(t+=parseFloat(v.css(e,"marginTop"))||0,n+=parseFloat(v.css(e,"marginLeft"))||0),{top:t,left:n}},setOffset:function(e,t,n){var r=v.css(e,"position");r==="static"&&(e.style.position="relative");var i=v(e),s=i.offset(),o=v.css(e,"top"),u=v.css(e,"left"),a=(r==="absolute"||r==="fixed")&&v.inArray("auto",[o,u])>-1,f={},l={},c,h;a?(l=i.position(),c=l.top,h=l.left):(c=parseFloat(o)||0,h=parseFloat(u)||0),v.isFunction(t)&&(t=t.call(e,n,s)),t.top!=null&&(f.top=t.top-s.top+c),t.left!=null&&(f.left=t.left-s.left+h),"using"in t?t.using.call(e,f):i.css(f)}},v.fn.extend({position:function(){if(!this[0])return;var e=this[0],t=this.offsetParent(),n=this.offset(),r=er.test(t[0].nodeName)?{top:0,left:0}:t.offset();return n.top-=parseFloat(v.css(e,"marginTop"))||0,n.left-=parseFloat(v.css(e,"marginLeft"))||0,r.top+=parseFloat(v.css(t[0],"borderTopWidth"))||0,r.left+=parseFloat(v.css(t[0],"borderLeftWidth"))||0,{top:n.top-r.top,left:n.left-r.left}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||i.body;while(e&&!er.test(e.nodeName)&&v.css(e,"position")==="static")e=e.offsetParent;return e||i.body})}}),v.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);v.fn[e]=function(i){return v.access(this,function(e,i,s){var o=tr(e);if(s===t)return o?n in o?o[n]:o.document.documentElement[i]:e[i];o?o.scrollTo(r?v(o).scrollLeft():s,r?s:v(o).scrollTop()):e[i]=s},e,i,arguments.length,null)}}),v.each({Height:"height",Width:"width"},function(e,n){v.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){v.fn[i]=function(i,s){var o=arguments.length&&(r||typeof i!="boolean"),u=r||(i===!0||s===!0?"margin":"border");return v.access(this,function(n,r,i){var s;return v.isWindow(n)?n.document.documentElement["client"+e]:n.nodeType===9?(s=n.documentElement,Math.max(n.body["scroll"+e],s["scroll"+e],n.body["offset"+e],s["offset"+e],s["client"+e])):i===t?v.css(n,r,i,u):v.style(n,r,i,u)},n,o?i:t,o,null)}})}),e.jQuery=e.$=v,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return v})})(window);
diff --git a/Resources/Public/JavaScript/jquery.tmpl.js b/Resources/Public/JavaScript/jquery.tmpl.js
new file mode 100644 (file)
index 0000000..a23092b
--- /dev/null
@@ -0,0 +1,484 @@
+/*!
+ * jQuery Templates Plugin 1.0.0pre
+ * http://github.com/jquery/jquery-tmpl
+ * Requires jQuery 1.4.2
+ *
+ * Copyright 2011, Software Freedom Conservancy, Inc.
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ */
+(function( jQuery, undefined ){
+       var oldManip = jQuery.fn.domManip, tmplItmAtt = "_tmplitem", htmlExpr = /^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,
+               newTmplItems = {}, wrappedItems = {}, appendToTmplItems, topTmplItem = { key: 0, data: {} }, itemKey = 0, cloneIndex = 0, stack = [];
+
+       function newTmplItem( options, parentItem, fn, data ) {
+               // Returns a template item data structure for a new rendered instance of a template (a 'template item').
+               // The content field is a hierarchical array of strings and nested items (to be
+               // removed and replaced by nodes field of dom elements, once inserted in DOM).
+               var newItem = {
+                       data: data || (data === 0 || data === false) ? data : (parentItem ? parentItem.data : {}),
+                       _wrap: parentItem ? parentItem._wrap : null,
+                       tmpl: null,
+                       parent: parentItem || null,
+                       nodes: [],
+                       calls: tiCalls,
+                       nest: tiNest,
+                       wrap: tiWrap,
+                       html: tiHtml,
+                       update: tiUpdate
+               };
+               if ( options ) {
+                       jQuery.extend( newItem, options, { nodes: [], parent: parentItem });
+               }
+               if ( fn ) {
+                       // Build the hierarchical content to be used during insertion into DOM
+                       newItem.tmpl = fn;
+                       newItem._ctnt = newItem._ctnt || newItem.tmpl( jQuery, newItem );
+                       newItem.key = ++itemKey;
+                       // Keep track of new template item, until it is stored as jQuery Data on DOM element
+                       (stack.length ? wrappedItems : newTmplItems)[itemKey] = newItem;
+               }
+               return newItem;
+       }
+
+       // Override appendTo etc., in order to provide support for targeting multiple elements. (This code would disappear if integrated in jquery core).
+       jQuery.each({
+               appendTo: "append",
+               prependTo: "prepend",
+               insertBefore: "before",
+               insertAfter: "after",
+               replaceAll: "replaceWith"
+       }, function( name, original ) {
+               jQuery.fn[ name ] = function( selector ) {
+                       var ret = [], insert = jQuery( selector ), elems, i, l, tmplItems,
+                               parent = this.length === 1 && this[0].parentNode;
+
+                       appendToTmplItems = newTmplItems || {};
+                       if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
+                               insert[ original ]( this[0] );
+                               ret = this;
+                       } else {
+                               for ( i = 0, l = insert.length; i < l; i++ ) {
+                                       cloneIndex = i;
+                                       elems = (i > 0 ? this.clone(true) : this).get();
+                                       jQuery( insert[i] )[ original ]( elems );
+                                       ret = ret.concat( elems );
+                               }
+                               cloneIndex = 0;
+                               ret = this.pushStack( ret, name, insert.selector );
+                       }
+                       tmplItems = appendToTmplItems;
+                       appendToTmplItems = null;
+                       jQuery.tmpl.complete( tmplItems );
+                       return ret;
+               };
+       });
+
+       jQuery.fn.extend({
+               // Use first wrapped element as template markup.
+               // Return wrapped set of template items, obtained by rendering template against data.
+               tmpl: function( data, options, parentItem ) {
+                       return jQuery.tmpl( this[0], data, options, parentItem );
+               },
+
+               // Find which rendered template item the first wrapped DOM element belongs to
+               tmplItem: function() {
+                       return jQuery.tmplItem( this[0] );
+               },
+
+               // Consider the first wrapped element as a template declaration, and get the compiled template or store it as a named template.
+               template: function( name ) {
+                       return jQuery.template( name, this[0] );
+               },
+
+               domManip: function( args, table, callback, options ) {
+                       if ( args[0] && jQuery.isArray( args[0] )) {
+                               var dmArgs = jQuery.makeArray( arguments ), elems = args[0], elemsLength = elems.length, i = 0, tmplItem;
+                               while ( i < elemsLength && !(tmplItem = jQuery.data( elems[i++], "tmplItem" ))) {}
+                               if ( tmplItem && cloneIndex ) {
+                                       dmArgs[2] = function( fragClone ) {
+                                               // Handler called by oldManip when rendered template has been inserted into DOM.
+                                               jQuery.tmpl.afterManip( this, fragClone, callback );
+                                       };
+                               }
+                               oldManip.apply( this, dmArgs );
+                       } else {
+                               oldManip.apply( this, arguments );
+                       }
+                       cloneIndex = 0;
+                       if ( !appendToTmplItems ) {
+                               jQuery.tmpl.complete( newTmplItems );
+                       }
+                       return this;
+               }
+       });
+
+       jQuery.extend({
+               // Return wrapped set of template items, obtained by rendering template against data.
+               tmpl: function( tmpl, data, options, parentItem ) {
+                       var ret, topLevel = !parentItem;
+                       if ( topLevel ) {
+                               // This is a top-level tmpl call (not from a nested template using {{tmpl}})
+                               parentItem = topTmplItem;
+                               tmpl = jQuery.template[tmpl] || jQuery.template( null, tmpl );
+                               wrappedItems = {}; // Any wrapped items will be rebuilt, since this is top level
+                       } else if ( !tmpl ) {
+                               // The template item is already associated with DOM - this is a refresh.
+                               // Re-evaluate rendered template for the parentItem
+                               tmpl = parentItem.tmpl;
+                               newTmplItems[parentItem.key] = parentItem;
+                               parentItem.nodes = [];
+                               if ( parentItem.wrapped ) {
+                                       updateWrapped( parentItem, parentItem.wrapped );
+                               }
+                               // Rebuild, without creating a new template item
+                               return jQuery( build( parentItem, null, parentItem.tmpl( jQuery, parentItem ) ));
+                       }
+                       if ( !tmpl ) {
+                               return []; // Could throw...
+                       }
+                       if ( typeof data === "function" ) {
+                               data = data.call( parentItem || {} );
+                       }
+                       if ( options && options.wrapped ) {
+                               updateWrapped( options, options.wrapped );
+                       }
+                       ret = jQuery.isArray( data ) ?
+                               jQuery.map( data, function( dataItem ) {
+                                       return dataItem ? newTmplItem( options, parentItem, tmpl, dataItem ) : null;
+                               }) :
+                               [ newTmplItem( options, parentItem, tmpl, data ) ];
+                       return topLevel ? jQuery( build( parentItem, null, ret ) ) : ret;
+               },
+
+               // Return rendered template item for an element.
+               tmplItem: function( elem ) {
+                       var tmplItem;
+                       if ( elem instanceof jQuery ) {
+                               elem = elem[0];
+                       }
+                       while ( elem && elem.nodeType === 1 && !(tmplItem = jQuery.data( elem, "tmplItem" )) && (elem = elem.parentNode) ) {}
+                       return tmplItem || topTmplItem;
+               },
+
+               // Set:
+               // Use $.template( name, tmpl ) to cache a named template,
+               // where tmpl is a template string, a script element or a jQuery instance wrapping a script element, etc.
+               // Use $( "selector" ).template( name ) to provide access by name to a script block template declaration.
+
+               // Get:
+               // Use $.template( name ) to access a cached template.
+               // Also $( selectorToScriptBlock ).template(), or $.template( null, templateString )
+               // will return the compiled template, without adding a name reference.
+               // If templateString includes at least one HTML tag, $.template( templateString ) is equivalent
+               // to $.template( null, templateString )
+               template: function( name, tmpl ) {
+                       if (tmpl) {
+                               // Compile template and associate with name
+                               if ( typeof tmpl === "string" ) {
+                                       // This is an HTML string being passed directly in.
+                                       tmpl = buildTmplFn( tmpl );
+                               } else if ( tmpl instanceof jQuery ) {
+                                       tmpl = tmpl[0] || {};
+                               }
+                               if ( tmpl.nodeType ) {
+                                       // If this is a template block, use cached copy, or generate tmpl function and cache.
+                                       tmpl = jQuery.data( tmpl, "tmpl" ) || jQuery.data( tmpl, "tmpl", buildTmplFn( tmpl.innerHTML ));
+                                       // Issue: In IE, if the container element is not a script block, the innerHTML will remove quotes from attribute values whenever the value does not include white space.
+                                       // This means that foo="${x}" will not work if the value of x includes white space: foo="${x}" -> foo=value of x.
+                                       // To correct this, include space in tag: foo="${ x }" -> foo="value of x"
+                               }
+                               return typeof name === "string" ? (jQuery.template[name] = tmpl) : tmpl;
+                       }
+                       // Return named compiled template
+                       return name ? (typeof name !== "string" ? jQuery.template( null, name ):
+                               (jQuery.template[name] ||
+                                       // If not in map, and not containing at least on HTML tag, treat as a selector.
+                                       // (If integrated with core, use quickExpr.exec)
+                                       jQuery.template( null, htmlExpr.test( name ) ? name : jQuery( name )))) : null;
+               },
+
+               encode: function( text ) {
+                       // Do HTML encoding replacing < > & and ' and " by corresponding entities.
+                       return ("" + text).split("<").join("&lt;").split(">").join("&gt;").split('"').join("&#34;").split("'").join("&#39;");
+               }
+       });
+
+       jQuery.extend( jQuery.tmpl, {
+               tag: {
+                       "tmpl": {
+                               _default: { $2: "null" },
+                               open: "if($notnull_1){__=__.concat($item.nest($1,$2));}"
+                               // tmpl target parameter can be of type function, so use $1, not $1a (so not auto detection of functions)
+                               // This means that {{tmpl foo}} treats foo as a template (which IS a function).
+                               // Explicit parens can be used if foo is a function that returns a template: {{tmpl foo()}}.
+                       },
+                       "wrap": {
+                               _default: { $2: "null" },
+                               open: "$item.calls(__,$1,$2);__=[];",
+                               close: "call=$item.calls();__=call._.concat($item.wrap(call,__));"
+                       },
+                       "each": {
+                               _default: { $2: "$index, $value" },
+                               open: "if($notnull_1){$.each($1a,function($2){with(this){",
+                               close: "}});}"
+                       },
+                       "if": {
+                               open: "if(($notnull_1) && $1a){",
+                               close: "}"
+                       },
+                       "else": {
+                               _default: { $1: "true" },
+                               open: "}else if(($notnull_1) && $1a){"
+                       },
+                       "html": {
+                               // Unecoded expression evaluation.
+                               open: "if($notnull_1){__.push($1a);}"
+                       },
+                       "=": {
+                               // Encoded expression evaluation. Abbreviated form is ${}.
+                               _default: { $1: "$data" },
+                               open: "if($notnull_1){__.push($.encode($1a));}"
+                       },
+                       "!": {
+                               // Comment tag. Skipped by parser
+                               open: ""
+                       }
+               },
+
+               // This stub can be overridden, e.g. in jquery.tmplPlus for providing rendered events
+               complete: function( items ) {
+                       newTmplItems = {};
+               },
+
+               // Call this from code which overrides domManip, or equivalent
+               // Manage cloning/storing template items etc.
+               afterManip: function afterManip( elem, fragClone, callback ) {
+                       // Provides cloned fragment ready for fixup prior to and after insertion into DOM
+                       var content = fragClone.nodeType === 11 ?
+                               jQuery.makeArray(fragClone.childNodes) :
+                               fragClone.nodeType === 1 ? [fragClone] : [];
+
+                       // Return fragment to original caller (e.g. append) for DOM insertion
+                       callback.call( elem, fragClone );
+
+                       // Fragment has been inserted:- Add inserted nodes to tmplItem data structure. Replace inserted element annotations by jQuery.data.
+                       storeTmplItems( content );
+                       cloneIndex++;
+               }
+       });
+
+       //========================== Private helper functions, used by code above ==========================
+
+       function build( tmplItem, nested, content ) {
+               // Convert hierarchical content into flat string array
+               // and finally return array of fragments ready for DOM insertion
+               var frag, ret = content ? jQuery.map( content, function( item ) {
+                       return (typeof item === "string") ?
+                               // Insert template item annotations, to be converted to jQuery.data( "tmplItem" ) when elems are inserted into DOM.
+                               (tmplItem.key ? item.replace( /(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g, "$1 " + tmplItmAtt + "=\"" + tmplItem.key + "\" $2" ) : item) :
+                               // This is a child template item. Build nested template.
+                               build( item, tmplItem, item._ctnt );
+               }) :
+               // If content is not defined, insert tmplItem directly. Not a template item. May be a string, or a string array, e.g. from {{html $item.html()}}.
+               tmplItem;
+               if ( nested ) {
+                       return ret;
+               }
+
+               // top-level template
+               ret = ret.join("");
+
+               // Support templates which have initial or final text nodes, or consist only of text
+               // Also support HTML entities within the HTML markup.
+               ret.replace( /^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/, function( all, before, middle, after) {
+                       frag = jQuery( middle ).get();
+
+                       storeTmplItems( frag );
+                       if ( before ) {
+                               frag = unencode( before ).concat(frag);
+                       }
+                       if ( after ) {
+                               frag = frag.concat(unencode( after ));
+                       }
+               });
+               return frag ? frag : unencode( ret );
+       }
+
+       function unencode( text ) {
+               // Use createElement, since createTextNode will not render HTML entities correctly
+               var el = document.createElement( "div" );
+               el.innerHTML = text;
+               return jQuery.makeArray(el.childNodes);
+       }
+
+       // Generate a reusable function that will serve to render a template against data
+       function buildTmplFn( markup ) {
+               return new Function("jQuery","$item",
+                       // Use the variable __ to hold a string array while building the compiled template. (See https://github.com/jquery/jquery-tmpl/issues#issue/10).
+                       "var $=jQuery,call,__=[],$data=$item.data;" +
+
+                       // Introduce the data as local variables using with(){}
+                       "with($data){__.push('" +
+
+                       // Convert the template into pure JavaScript
+                       jQuery.trim(markup)
+                               .replace( /([\\'])/g, "\\$1" )
+                               .replace( /[\r\t\n]/g, " " )
+                               .replace( /\$\{([^\}]*)\}/g, "{{= $1}}" )
+                               .replace( /\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,
+                               function( all, slash, type, fnargs, target, parens, args ) {
+                                       var tag = jQuery.tmpl.tag[ type ], def, expr, exprAutoFnDetect;
+                                       if ( !tag ) {
+                                               throw "Unknown template tag: " + type;
+                                       }
+                                       def = tag._default || [];
+                                       if ( parens && !/\w$/.test(target)) {
+                                               target += parens;
+                                               parens = "";
+                                       }
+                                       if ( target ) {
+                                               target = unescape( target );
+                                               args = args ? ("," + unescape( args ) + ")") : (parens ? ")" : "");
+                                               // Support for target being things like a.toLowerCase();
+                                               // In that case don't call with template item as 'this' pointer. Just evaluate...
+                                               expr = parens ? (target.indexOf(".") > -1 ? target + unescape( parens ) : ("(" + target + ").call($item" + args)) : target;
+                                               exprAutoFnDetect = parens ? expr : "(typeof(" + target + ")==='function'?(" + target + ").call($item):(" + target + "))";
+                                       } else {
+                                               exprAutoFnDetect = expr = def.$1 || "null";
+                                       }
+                                       fnargs = unescape( fnargs );
+                                       return "');" +
+                                               tag[ slash ? "close" : "open" ]
+                                                       .split( "$notnull_1" ).join( target ? "typeof(" + target + ")!=='undefined' && (" + target + ")!=null" : "true" )
+                                                       .split( "$1a" ).join( exprAutoFnDetect )
+                                                       .split( "$1" ).join( expr )
+                                                       .split( "$2" ).join( fnargs || def.$2 || "" ) +
+                                               "__.push('";
+                               }) +
+                       "');}return __;"
+               );
+       }
+       function updateWrapped( options, wrapped ) {
+               // Build the wrapped content.
+               options._wrap = build( options, true,
+                       // Suport imperative scenario in which options.wrapped can be set to a selector or an HTML string.
+                       jQuery.isArray( wrapped ) ? wrapped : [htmlExpr.test( wrapped ) ? wrapped : jQuery( wrapped ).html()]
+               ).join("");
+       }
+
+       function unescape( args ) {
+               return args ? args.replace( /\\'/g, "'").replace(/\\\\/g, "\\" ) : null;
+       }
+       function outerHtml( elem ) {
+               var div = document.createElement("div");
+               div.appendChild( elem.cloneNode(true) );
+               return div.innerHTML;
+       }
+
+       // Store template items in jQuery.data(), ensuring a unique tmplItem data data structure for each rendered template instance.
+       function storeTmplItems( content ) {
+               var keySuffix = "_" + cloneIndex, elem, elems, newClonedItems = {}, i, l, m;
+               for ( i = 0, l = content.length; i < l; i++ ) {
+                       if ( (elem = content[i]).nodeType !== 1 ) {
+                               continue;
+                       }
+                       elems = elem.getElementsByTagName("*");
+                       for ( m = elems.length - 1; m >= 0; m-- ) {
+                               processItemKey( elems[m] );
+                       }
+                       processItemKey( elem );
+               }
+               function processItemKey( el ) {
+                       var pntKey, pntNode = el, pntItem, tmplItem, key;
+                       // Ensure that each rendered template inserted into the DOM has its own template item,
+                       if ( (key = el.getAttribute( tmplItmAtt ))) {
+                               while ( pntNode.parentNode && (pntNode = pntNode.parentNode).nodeType === 1 && !(pntKey = pntNode.getAttribute( tmplItmAtt ))) { }
+                               if ( pntKey !== key ) {
+                                       // The next ancestor with a _tmplitem expando is on a different key than this one.
+                                       // So this is a top-level element within this template item
+                                       // Set pntNode to the key of the parentNode, or to 0 if pntNode.parentNode is null, or pntNode is a fragment.
+                                       pntNode = pntNode.parentNode ? (pntNode.nodeType === 11 ? 0 : (pntNode.getAttribute( tmplItmAtt ) || 0)) : 0;
+                                       if ( !(tmplItem = newTmplItems[key]) ) {
+               &