Resolved some TODOs
authorAlexander Ebert <ebert@woltlab.com>
Wed, 22 Feb 2012 14:37:24 +0000 (15:37 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 22 Feb 2012 14:37:24 +0000 (15:37 +0100)
15 files changed:
wcfsetup/install/files/lib/acp/form/PackageUpdateAuthForm.class.php
wcfsetup/install/files/lib/acp/page/PackagePage.class.php
wcfsetup/install/files/lib/data/language/LanguageEditor.class.php
wcfsetup/install/files/lib/data/option/Option.class.php
wcfsetup/install/files/lib/data/package/PackageAction.class.php
wcfsetup/install/files/lib/data/template/Template.class.php
wcfsetup/install/files/lib/data/template/group/TemplateGroupEditor.class.php
wcfsetup/install/files/lib/system/WCFSetup.class.php
wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php
wcfsetup/install/files/lib/system/option/FileSizeOptionType.class.php
wcfsetup/install/files/lib/system/option/SelectOptionType.class.php
wcfsetup/install/files/lib/system/package/PackageArchive.class.php
wcfsetup/install/files/lib/system/template/TemplateScriptingCompiler.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 01df233d85352a9a69b6f9d67e594d7a1ac67fa5..a7fbdf31b465abe8017960c6417862b3ac08faf3 100755 (executable)
@@ -138,6 +138,7 @@ class PackageUpdateAuthForm extends ACPForm {
        }
        
        /**
+        * @todo        This whole page is carzy, it's manipulating the requested page, but RequestHandler does not work this way
         * @see wcf\page\IPage::readParameters()
         */
        public function readParameters() {
index b7114fb286744643f6e3f87b06d22e44627bca5e..684e5053250bf83367a70c831924e17e0645b5de 100755 (executable)
@@ -12,6 +12,7 @@ use wcf\system\WCFACP;
  * Handles all request on the package.php script
  * and executes the requested action.
  * TODO: split this page into separate pages / actions
+ * TODO: I would recommend removing this entire class, it's pretty nasty to use a page just for redirections
  *
  * @author     Marcel Werk
  * @copyright  2001-2011 WoltLab GmbH
@@ -69,9 +70,7 @@ class PackagePage extends AbstractPage {
                        case 'rollback':
                                // TODO
                                die('ROLLBACK');
-                               WCF::getSession()->checkPermissions(array('admin.system.package.canInstallPackage'));
-                               require_once(WCF_DIR.'lib/acp/package/PackageInstallationRollback.class.php');
-                               new PackageInstallationRollback($this->queueID); // TODO: undefined class PackageInstallationRollback
+                               //WCF::getSession()->checkPermissions(array('admin.system.package.canInstallPackage'));
                        break;
                        
                        case 'openQueue':
index 7de4794ae7688a5a66277f5d16b99937005c66b6..c4b7cfa1e98e983874dff6374576759a965ee37e 100644 (file)
@@ -549,11 +549,10 @@ class LanguageEditor extends DatabaseObjectEditor {
                                // search and replace
                                $matches = 0;
                                if ($useRegex) {
-                                       $newValue = preg_replace('~'.$search.'~s'.(!$caseSensitive ? 'i' : ''), $replace, ($row['languageCustomItemValue'] ? $row['languageCustomItemValue'] : $row['languageItemValue']), -1, $matches); //TODO: undefined variable
+                                       $newValue = preg_replace('~'.$search.'~s', $replace, ($row['languageCustomItemValue'] ? $row['languageCustomItemValue'] : $row['languageItemValue']), -1, $matches);
                                }
                                else {
-                                       if ($caseSensitive) $newValue = StringUtil::replace($search, $replace, ($row['languageCustomItemValue'] ? $row['languageCustomItemValue'] : $row['languageItemValue']), $matches); //TODO: undefined variable
-                                       else $newValue = StringUtil::replaceIgnoreCase($search, $replace, ($row['languageCustomItemValue'] ? $row['languageCustomItemValue'] : $row['languageItemValue']), $matches);
+                                       $newValue = StringUtil::replaceIgnoreCase($search, $replace, ($row['languageCustomItemValue'] ? $row['languageCustomItemValue'] : $row['languageItemValue']), $matches);
                                }
                                
                                if ($matches > 0) {
index 0620e69d9fed4eeb4c58a2c4528453b8052c5d6b..87dbb4cafc2b5f27807a9d46f8d4a0badae293d2 100644 (file)
@@ -49,7 +49,6 @@ class Option extends DatabaseObject {
        
        /**
         * Returns a list of options.
-        * TODO: move to optionlist
         *
         * @param       integer         $packageID
         * @return      array
index ffebd224fec89ef774b5d5a6842f7880abee8d82..a8510c442dc5b6f362620cb2b8a06261f847a75b 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\data\package;
 use wcf\data\AbstractDatabaseObjectAction;
+use wcf\system\exception\ValidateActionException;
 use wcf\system\WCF;
 
 /**
@@ -35,9 +36,13 @@ class PackageAction extends AbstractDatabaseObjectAction {
        protected $permissionsUpdate = array('admin.system.package.canUpdatePackage');
        
        /**
-        * @todo        Implement validation
+        * Validates page parameter.
         */
-       public function validateGetPluginList() {}
+       public function validateGetPluginList() {
+               if (!isset($this->parameters['activePage']) || !intval($this->parameters['activePage'])) {
+                       throw new ValidateActionException("Missing or invalid parameter 'activePage'");
+               }
+       }
        
        /**
         * Returns a list of plugins.
index 7850c238d2f13700bb59a6e206233ac50a3b4f53..8f7cdc91bcf73fbb0a153b0d2fe6af5f86dabb74 100644 (file)
@@ -74,7 +74,6 @@ class Template extends DatabaseObject {
        
        /**
         * Searches in templates.
-        * TODO: move to template editor?
         * 
         * @param       string          $search         search query
         * @param       string          $replace
index f101610a5dd47c7dd95bf60a957f99ef04cbfd78..bbd19786b4bf12c75e7b7742e91628cf11de5d87 100644 (file)
@@ -81,7 +81,7 @@ class TemplateGroupEditor extends DatabaseObjectEditor {
         */
        public function deleteFolders() {
                // default template dir
-               $folders = array(WCF_DIR . 'templates/' . $this->templateGroupFolderName); // TODO: should this folder be deleted, too?
+               $folders = array(WCF_DIR . 'templates/' . $this->templateGroupFolderName);
                
                // get package dirs
                $sql = "SELECT  packageDir
index 29c3cb17910b2f120f3007d98ed826ff55df366b..df27e792e34be2d44e59f8b20afc18bac62a31bc 100644 (file)
@@ -1001,9 +1001,44 @@ class WCFSetup extends WCF {
                                $archive->openArchive();
                        }
                        catch (\Exception $e) {
-                               // TODO: Maybe break the installation if archive is broken?
-                               // this is a broken archive, skip it
-                               continue;
+                               // we've encountered a broken archive, revert everything and then fail
+                               $sql = "SELECT  queueID, parentQueueID
+                                       FROM    wcf".WCF_N."_package_installation_queue";
+                               $statement = WCF::getDB()->prepareStatement($sql);
+                               $statement->execute();
+                               $queues = array();
+                               while ($row = $statement->fetchArray()) {
+                                       $queues[$row['queueID']] = $row['parentQueueID'];
+                               }
+                               
+                               $queueIDs = array();
+                               $queueID = $queue->queueID;
+                               while ($queueID) {
+                                       $queueIDs[] = $queueID;
+                                       
+                                       $queueID = (isset($queues[$queueID])) ?: 0;
+                               }
+                               
+                               // remove previously created queues
+                               if (!empty($queueIDs)) {
+                                       $sql = "DELETE FROM     wcf".WCF_N."_package_installation_queue
+                                               WHERE           queueID = ?";
+                                       $statement = WCF::getDB()->prepareStatement($sql);
+                                       WCF::getDB()->beginTransaction();
+                                       foreach ($queueIDs as $queueID) {
+                                               $statement->execute(array($queueID));
+                                       }
+                                       WCF::getDB()->commitTransaction();
+                               }
+                               
+                               // remove package files
+                               @unlink(TMP_DIR.'install/packages/'.$wcfPackageFile);
+                               foreach ($otherPackages as $packageFile) {
+                                       @unlink(TMP_DIR.'install/packages/'.$packageFile);
+                               }
+                               
+                               // throw exception again
+                               throw new SystemException('', 0, '', $e);
                        }
                        
                        $queue = PackageInstallationQueueEditor::create(array(
@@ -1024,7 +1059,6 @@ class WCFSetup extends WCF {
                SessionHandler::getInstance()->register('masterPassword', 1);
                SessionHandler::getInstance()->update();
                
-               // TODO: print message if delete fails
                $installPhpDeleted = @unlink('./install.php');
                $testPhpDeleted = @unlink('./test.php');
                $wcfSetupTarDeleted = @unlink('./WCFSetup.tar.gz');
index 54f3e668f0c7841ded54f99014c128f0b64a716b..6e410f0f5d34db36d6d4da14b760ece37a1cfe3b 100644 (file)
@@ -44,7 +44,7 @@ class UserClipboardAction implements IClipboardAction {
                                }
                                
                                // TODO: use language variable
-                               $item->addInternalData('confirmMessage', 'Delete '.$count.' users?');
+                               $item->addInternalData('confirmMessage', WCF::getLanguage()->getDynamicVariable('wcf.clipboard.user.confirmMessage', array('count' => $count)));
                                $item->addParameter('actionName', 'delete');
                                $item->addParameter('className', 'wcf\data\user\UserAction');
                                $item->setName('user.delete');
@@ -131,15 +131,8 @@ class UserClipboardAction implements IClipboardAction {
        
        /**
         * @see wcf\system\clipboard\action\IClipboardAction::getEditorLabel()
-        * @todo        use language variable
         */
        public function getEditorLabel(array $objects) {
-               $count = count($objects);
-               if ($count == 1) {
-                       return 'One user marked';
-               }
-               else {
-                       return $count . ' users marked';
-               }
+               return WCF::getLanguage()->getDynamicVariable('wcf.clipboard.user.marked', array('count' => count($objects)));
        }
 }
index f647c6b71ed99e265401bf758aeb973c541c3142..fbff747d629e0f1d9751ef5eaae6c93ed23da2f9 100644 (file)
@@ -55,7 +55,6 @@ class FileSizeOptionType extends IntegerOptionType {
         * @see wcf\system\option\IOptionType::getFormElement()
         */
        public function getFormElement(Option $option, $value) {
-               // TODO: Maybe show more digits after the comma?
                $value = FileUtil::formatFileSize($value);
                return parent::getFormElement($option, $value);
        }
index e9285093d8d2468696d6374776f264eaf4f275ea..583a28e3c3372b96621563f397a53b42efeae0c9 100644 (file)
@@ -52,7 +52,7 @@ class SelectOptionType extends RadioButtonOptionType {
                        $options = $option->parseMultipleEnableOptions();
                        
                        foreach ($options as $key => $optionData) {
-                               $tmp = explode(',', $optionData); // TODO: is either optionData an array or tmp?
+                               $tmp = explode(',', $optionData);
                                
                                foreach ($optionData as $item) {
                                        if ($item{0} == '!') {
index 22cea3aed7a6aec56185e2d49b74285745777673..e147b4fd0a2a2f005c0f226bd24cb7d7c5e51603 100644 (file)
@@ -231,7 +231,8 @@ class PackageArchive {
                                                throw new SystemException("package date '".$element->nodeValue."' is invalid, violating ISO-8601 date format.");
                                        }
                                        
-                                       $this->packageInfo['date'] = strtotime($element->nodeValue) + 43201; // TODO: Is this even neccessary?
+                                       // TODO: Is this even neccessary?
+                                       //$this->packageInfo['date'] = strtotime($element->nodeValue) + 43201;
                                break;
                        }
                }
index aeb9cb42c18666ab776e633cbac733cf6b4fbe8f..0b7362810fdc38a1c81bed546d0f715fb6bc3c02 100644 (file)
@@ -173,12 +173,6 @@ class TemplateScriptingCompiler {
         */
        protected $staticIncludes = array();
        
-       /**
-        * list of previously included namespaces
-        * @var array<string>
-        */
-       protected $includedNamespaces = array();
-       
        /**
         * Creates a new TemplateScriptingCompiler object.
         * 
@@ -216,7 +210,7 @@ class TemplateScriptingCompiler {
                        );
                }
                else {
-                       $this->includedNamespaces = $this->staticIncludes = array();
+                       $this->staticIncludes = array();
                }
                
                // reset vars
@@ -282,14 +276,6 @@ class TemplateScriptingCompiler {
                if (count($this->autoloadPlugins) > 0) {
                        $compiledAutoloadPlugins = "<?php\n";
                        foreach ($this->autoloadPlugins as $className) {
-                               // prevent multiple use on the same namespace
-                               if (!in_array($className, $this->includedNamespaces)) {
-                                       // TODO: We're using the classes with prepended namespace, why should we first
-                                       //       import them with "use" for no reason?
-                                       //$compiledAutoloadPlugins .= "use ".$className.";\n";
-                                       $this->includedNamespaces[] = $className;
-                               }
-                               
                                $compiledAutoloadPlugins .= "if (!isset(\$this->pluginObjects['$className'])) {\n";
                                $compiledAutoloadPlugins .= "\$this->pluginObjects['$className'] = new $className;\n";
                                $compiledAutoloadPlugins .= "}\n";
index 9417383b4be350d7e44cf247d55d3351fb0538a7..88c16baeed6e56a1fd37e3b50ad3ccc61a20dfcb 100644 (file)
@@ -1,5 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <language xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/language.xsd" languagecode="de" languagename="Deutsch">
+       <category name="wcf.clipboard">
+               <item name="wcf.clipboard.user.confirmMessage"><![CDATA[{if $count == 1}Einen{else}{#$count}{/if} Benutzer löschen?]]></item>
+               <item name="wcf.clipboard.user.marked"><![CDATA[{if $count == 1}Ein{else}{#$count}{/if} Benutzer markiert]]></item>
+       </category>
+       
        <category name="wcf.acp.cronjob">
                <item name="wcf.acp.cronjob.list"><![CDATA[Cronjobs]]></item>
                <item name="wcf.acp.cronjob.add"><![CDATA[Cronjob hinzufügen]]></item>
index fa1ed57de714d9fdb40cf3632805e60fc5846b70..9e2199cdf17527ad25eba4338cb8688fa5fa2461 100644 (file)
@@ -1,5 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <language xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/maelstrom/language.xsd" languagecode="en" languagename="English">
+       <category name="wcf.clipboard">
+               <item name="wcf.clipboard.user.confirmMessage"><![CDATA[Delete {if $count == 1}one{else}{#$count}{/if} user{if $count > 1}s{/if}?]]></item>
+               <item name="wcf.clipboard.user.marked"><![CDATA[{if $count == 1}One{else}{#$count}{/if} user{if $count > 1}s{/if} marked]]></item>
+       </category>
+       
        <category name="wcf.acp.cronjob">
                <item name="wcf.acp.cronjob.list"><![CDATA[Cron jobs]]></item>
                <item name="wcf.acp.cronjob.add"><![CDATA[Add a new cron job]]></item>