├── .github ├── FUNDING.yml └── ISSUE_TEMPLATE.md ├── .gitignore ├── README.md ├── build.xml ├── license.txt ├── manifest.mf ├── nbproject ├── build-impl.xml ├── genfiles.properties ├── platform.properties ├── project.properties └── project.xml ├── pom.xml ├── src └── org │ └── netbeans │ └── modules │ └── php │ └── wordpress │ ├── Bundle.properties │ ├── ConfigurationFiles.java │ ├── WordPress.java │ ├── WordPressActionsExtender.java │ ├── WordPressModuleInstall.java │ ├── WordPressPhpModuleExtender.java │ ├── WordPressPhpProvider.java │ ├── WordPressVersion.java │ ├── commands │ ├── WordPressCli.java │ ├── WordPressCliCommand.java │ ├── WordPressCliCommandListBuilder.java │ ├── WordPressCliCommandListXmlBuilder.java │ ├── WordPressCliCommandsXmlParser.java │ └── WordPressCommandSupport.java │ ├── customizer │ ├── Bundle.properties │ ├── WordPressCustomizerExtender.java │ ├── WordPressCustomizerExtenderPanel.form │ └── WordPressCustomizerExtenderPanel.java │ ├── editor │ ├── WordPressEditorExtender.java │ ├── completion │ │ ├── ActionCompletionDocumentation.java │ │ ├── ActionCompletionItem.java │ │ ├── FilterAndActionCompletion.java │ │ ├── FilterCompletionDocumentation.java │ │ ├── FilterCompletionItem.java │ │ ├── WordPressCompletionDocumentation.java │ │ ├── WordPressCompletionItem.java │ │ ├── WordPressCompletionProvider.java │ │ └── resources │ │ │ ├── code-completion-action.xml │ │ │ └── code-completion-filter.xml │ └── navi │ │ └── WordPressHyperlinkProviderExt.java │ ├── modules │ ├── WordPress3ModuleImpl.java │ ├── WordPressDummyModuleImpl.java │ ├── WordPressModule.java │ └── WordPressModuleImpl.java │ ├── preferences │ └── WordPressPreferences.java │ ├── resources │ ├── Bundle.properties │ ├── WpPlugin.php │ ├── layer.xml │ ├── org-netbeans-modules-phpeditor-snippets.xml │ ├── readme.txt │ ├── templates │ │ ├── .htaccess │ │ ├── WpChildThemeStyleDescription.html │ │ ├── WpGPLv2LicenseDescription.html │ │ ├── WpPermalinkHtaccessDescription.html │ │ ├── WpPlugin.php │ │ ├── WpPluginDescription.html │ │ ├── WpPluginReadmeDescription.html │ │ ├── WpThemeStyleDescription.html │ │ ├── child-style.css │ │ ├── license-wp-gpl20.txt │ │ ├── package-info.java │ │ ├── readme.txt │ │ └── style.css │ ├── wordpress_badge_8.png │ ├── wordpress_icon_16.png │ └── wordpress_icon_8.png │ ├── ui │ ├── actions │ │ ├── CreateBarebonesThemeAction.java │ │ ├── CreateChildThemeAction.java │ │ ├── CreateMinimumBlankThemeAction.java │ │ ├── CreatePermalinkHtaccessAction.java │ │ ├── CreatePluginAction.java │ │ ├── CreateThemeAction.java │ │ ├── CreateThemeBaseAction.java │ │ ├── CreateUnderscoresThemeAction.java │ │ ├── RefreshCodeCompletionAction.java │ │ ├── WordPressRunCommandAction.java │ │ └── ZipAction.java │ ├── logicalview │ │ ├── MVCNode.java │ │ └── MVCNodeFactory.java │ ├── options │ │ ├── Bundle.properties │ │ ├── WordPressOptions.java │ │ ├── WordPressOptionsPanel.form │ │ ├── WordPressOptionsPanel.java │ │ ├── WordPressOptionsPanelController.java │ │ └── WordPressOptionsValidator.java │ ├── status │ │ └── DebugStatusLineElement.java │ └── wizards │ │ ├── Bundle.properties │ │ ├── CreateChildThemePanel.form │ │ ├── CreateChildThemePanel.java │ │ ├── CreateMinimumBlankThemePanel.form │ │ ├── CreateMinimumBlankThemePanel.java │ │ ├── CreatePermalinkHtaccessPanel.form │ │ ├── CreatePermalinkHtaccessPanel.java │ │ ├── CreateUnderscoresThemePanel.form │ │ ├── CreateUnderscoresThemePanel.java │ │ ├── NewProjectConfigurationPanel.form │ │ ├── NewProjectConfigurationPanel.java │ │ ├── WpConfigPanel.form │ │ └── WpConfigPanel.java │ ├── update │ ├── UpdateItem.java │ ├── UpgradeUtils.java │ ├── WordPressCoreUpgradeChecker.java │ ├── WordPressPluginUpgradeChecker.java │ ├── WordPressThemeUpgradeChecker.java │ └── WordPressUpgradeChecker.java │ ├── util │ ├── Charset.java │ ├── DocUtils.java │ ├── GithubZipEntryFilter.java │ ├── NetUtils.java │ ├── UnderscoresUtils.java │ ├── UnderscoresZipEntryFilter.java │ ├── WPFileUtils.java │ ├── WPUtils.java │ ├── WPZipEntryFilter.java │ ├── WordPressUnzipException.java │ └── ZipEntryFilter.java │ ├── validators │ ├── WordPressCustomizerValidator.java │ ├── WordPressDirectoryNameValidator.java │ └── WordPressModuleValidator.java │ └── wpapis │ ├── WordPressApi.java │ └── WordPressVersionCheckApi.java └── test └── unit └── src └── org └── netbeans └── modules └── php └── wordpress ├── util └── UnderscoresUtilsTest.java └── validators └── WordPressDirectoryNameValidatorTest.java /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: junichi11 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | #### Issue type 2 | 3 | - [x] Bug 4 | - [ ] Enhancement 5 | 6 | #### Overview description 7 | 8 | #### Steps to reproduce 9 | 10 | 1. 11 | 2. 12 | 3. 13 | 14 | #### Actual results 15 | 16 | #### Expected results 17 | 18 | #### Your environment (NetBeans and plugin version, e.t.c.) 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | nbproject/private 3 | lib 4 | pom.xml.asc 5 | -------------------------------------------------------------------------------- /build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Builds, tests, and runs the project org.netbeans.modules.php.wordpress. 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 20 | 22 | 23 | 24 | 25 | 26 | 30 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /manifest.mf: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | OpenIDE-Module: org.netbeans.modules.php.wordpress 3 | OpenIDE-Module-Layer: org/netbeans/modules/php/wordpress/resources/layer.xml 4 | OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/php/wordpress/Bundle.properties 5 | OpenIDE-Module-Specification-Version: 1.3.0 6 | OpenIDE-Module-Install: org/netbeans/modules/php/wordpress/WordPressModuleInstall.class 7 | -------------------------------------------------------------------------------- /nbproject/build-impl.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /nbproject/genfiles.properties: -------------------------------------------------------------------------------- 1 | build.xml.data.CRC32=1a9c0250 2 | build.xml.script.CRC32=f6cbff90 3 | build.xml.stylesheet.CRC32=15ca8a54@2.74.1 4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 | nbproject/build-impl.xml.data.CRC32=b7da3fdb 7 | nbproject/build-impl.xml.script.CRC32=bfa38a5f 8 | nbproject/build-impl.xml.stylesheet.CRC32=49aa68b0@2.82 9 | -------------------------------------------------------------------------------- /nbproject/platform.properties: -------------------------------------------------------------------------------- 1 | cluster.path=\ 2 | ${nbplatform.active.dir}/websvccommon:\ 3 | ${nbplatform.active.dir}/php:\ 4 | ${nbplatform.active.dir}/harness:\ 5 | ${nbplatform.active.dir}/profiler:\ 6 | ${nbplatform.active.dir}/platform:\ 7 | ${nbplatform.active.dir}/ide:\ 8 | ${nbplatform.active.dir}/apisupport:\ 9 | ${nbplatform.active.dir}/nb:\ 10 | ${nbplatform.active.dir}/webcommon:\ 11 | ${nbplatform.active.dir}/java 12 | nbjdk.active=default 13 | nbplatform.active=default -------------------------------------------------------------------------------- /nbproject/project.properties: -------------------------------------------------------------------------------- 1 | javac.source=1.8 2 | javac.compilerargs=-Xlint -Xlint:-serial 3 | license.file=license.txt 4 | nbm.module.author=junichi11 5 | project.license=cddl-netbeans-sun 6 | keystore=nbproject/private/keystore 7 | nbm_alias=wordpress 8 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | com.junichi11.netbeans.modules 5 | netbeans-wordpress-plugin 6 | 7 | 1.3.0 8 | nbm 9 | PHP WordPress Blog/CMS 10 | https://github.com/junichi11/netbeans-wordpress-plugin 11 | This is a NetBeans plugin for WordPress. 12 | 13 | 14 | junichi11 15 | Junichi Yamamoto 16 | https://github.com/junichi11 17 | 18 | 19 | 20 | scm:git:https://github.com/junichi11/netbeans-wordpress-plugin 21 | scm:git:https://github.com/junichi11/netbeans-wordpress-plugin.git 22 | https://github.com/junichi11/netbeans-wordpress-plugin 23 | HEAD 24 | 25 | 26 | 27 | Common Development and Distribution License (CDDL) v1.0 and GNU General Public License (GPL) v2 28 | http://netbeans.org/cddl-gplv2.html 29 | 30 | 31 | 32 | 33 | ossrh 34 | https://oss.sonatype.org/content/repositories/snapshots 35 | 36 | 37 | ossrh 38 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 39 | 40 | 41 | 42 | 43 | 44 | org.apache.maven.plugins 45 | maven-deploy-plugin 46 | 3.0.0 47 | 48 | 49 | org.sonatype.plugins 50 | nexus-staging-maven-plugin 51 | 1.6.7 52 | true 53 | 54 | ossrh 55 | https://oss.sonatype.org/ 56 | true 57 | 58 | 59 | 60 | org.apache.maven.plugins 61 | maven-compiler-plugin 62 | 3.8.1 63 | 64 | 1.8 65 | 1.8 66 | 67 | 68 | 69 | org.apache.maven.plugins 70 | maven-jar-plugin 71 | 3.1.2 72 | 73 | 74 | ${project.build.outputDirectory}/META-INF/MANIFEST.MF 75 | 76 | 77 | 78 | 79 | org.apache.maven.plugins 80 | maven-gpg-plugin 81 | 1.6 82 | 83 | 84 | sign-artifacts 85 | verify 86 | 87 | sign 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/Bundle.properties: -------------------------------------------------------------------------------- 1 | OpenIDE-Module-Display-Category=PHP 2 | OpenIDE-Module-Long-Description=\ 3 | Support for WordPress.This plugin provides the following features.\n\ 4 | 5 | OpenIDE-Module-Name=PHP WordPress Blog/CMS 6 | OpenIDE-Module-Short-Description=Support for WordPress 7 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/ConfigurationFiles.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2015 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress; 43 | 44 | import java.io.File; 45 | import java.util.ArrayList; 46 | import java.util.Collection; 47 | import java.util.List; 48 | import javax.swing.event.ChangeListener; 49 | import org.netbeans.modules.php.api.phpmodule.PhpModule; 50 | import org.netbeans.modules.php.spi.phpmodule.ImportantFilesImplementation; 51 | import org.netbeans.modules.php.wordpress.modules.WordPressModule; 52 | import org.openide.filesystems.FileChangeAdapter; 53 | import org.openide.filesystems.FileEvent; 54 | import org.openide.filesystems.FileObject; 55 | import org.openide.filesystems.FileRenameEvent; 56 | import org.openide.filesystems.FileUtil; 57 | import org.openide.util.ChangeSupport; 58 | 59 | /** 60 | * 61 | * @author junichi11 62 | */ 63 | public final class ConfigurationFiles extends FileChangeAdapter implements ImportantFilesImplementation { 64 | 65 | private final PhpModule phpModule; 66 | private final ChangeSupport changeSupport = new ChangeSupport(this); 67 | 68 | // @GuardedBy("this") 69 | private boolean isInitialized = false; 70 | private static final String WP_CONFIG_PHP = "wp-config.php"; // NOI18N 71 | private static final String HTACCESS = ".htaccess"; // NOI18N 72 | private static final String[] CONFIG_FILES = { 73 | WP_CONFIG_PHP, 74 | HTACCESS 75 | }; 76 | 77 | public ConfigurationFiles(PhpModule phpModule) { 78 | assert phpModule != null; 79 | this.phpModule = phpModule; 80 | } 81 | 82 | @Override 83 | public Collection getFiles() { 84 | FileObject wordPressRoot = getWordPressRoot(); 85 | List files = new ArrayList<>(); 86 | if (wordPressRoot != null) { 87 | for (String configFile : CONFIG_FILES) { 88 | FileObject config = wordPressRoot.getFileObject(configFile); 89 | if (config != null) { 90 | files.add(new FileInfo(config)); 91 | } 92 | } 93 | } 94 | return files; 95 | } 96 | 97 | private synchronized FileObject getWordPressRoot() { 98 | WordPressModule wpModuel = WordPressModule.Factory.forPhpModule(phpModule); 99 | FileObject wordPressRoot = wpModuel.getWordPressRootDirecotry(); 100 | if (wordPressRoot != null) { 101 | if (!isInitialized) { 102 | FileObject config = wordPressRoot.getFileObject(WP_CONFIG_PHP); 103 | if (config != null) { 104 | isInitialized = true; 105 | addListener(FileUtil.toFile(config)); 106 | } 107 | } 108 | } 109 | return wordPressRoot; 110 | } 111 | 112 | private void addListener(File path) { 113 | try { 114 | FileUtil.addRecursiveListener(this, path); 115 | } catch (IllegalArgumentException ex) { 116 | // noop, already listening 117 | assert false : path; 118 | } 119 | } 120 | 121 | @Override 122 | public void addChangeListener(ChangeListener listener) { 123 | changeSupport.addChangeListener(listener); 124 | } 125 | 126 | @Override 127 | public void removeChangeListener(ChangeListener listener) { 128 | changeSupport.removeChangeListener(listener); 129 | } 130 | 131 | private void fireChange() { 132 | changeSupport.fireChange(); 133 | } 134 | 135 | //~ FS 136 | @Override 137 | public void fileRenamed(FileRenameEvent fe) { 138 | fireChange(); 139 | } 140 | 141 | @Override 142 | public void fileDeleted(FileEvent fe) { 143 | fireChange(); 144 | } 145 | 146 | @Override 147 | public void fileDataCreated(FileEvent fe) { 148 | fireChange(); 149 | } 150 | 151 | @Override 152 | public void fileFolderCreated(FileEvent fe) { 153 | fireChange(); 154 | } 155 | 156 | } 157 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/WordPress.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress; 43 | 44 | import org.netbeans.api.annotations.common.StaticResource; 45 | 46 | /** 47 | * 48 | * @author junichi11 49 | */ 50 | public final class WordPress { 51 | 52 | @StaticResource 53 | public static final String WP_ICON_8 = "org/netbeans/modules/php/wordpress/resources/wordpress_icon_8.png"; // NOI18N 54 | @StaticResource 55 | public static final String WP_ICON_16 = "org/netbeans/modules/php/wordpress/resources/wordpress_icon_16.png"; // NOI18N 56 | 57 | private WordPress() { 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/WordPressActionsExtender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress; 43 | 44 | import java.util.ArrayList; 45 | import java.util.List; 46 | import javax.swing.Action; 47 | import org.netbeans.modules.php.spi.framework.PhpModuleActionsExtender; 48 | import org.netbeans.modules.php.spi.framework.actions.RunCommandAction; 49 | import org.netbeans.modules.php.wordpress.ui.actions.CreateChildThemeAction; 50 | import org.netbeans.modules.php.wordpress.ui.actions.CreatePermalinkHtaccessAction; 51 | import org.netbeans.modules.php.wordpress.ui.actions.CreatePluginAction; 52 | import org.netbeans.modules.php.wordpress.ui.actions.CreateThemeAction; 53 | import org.netbeans.modules.php.wordpress.ui.actions.RefreshCodeCompletionAction; 54 | import org.netbeans.modules.php.wordpress.ui.actions.WordPressRunCommandAction; 55 | import org.openide.util.NbBundle; 56 | 57 | /** 58 | * 59 | * @author junichi11 60 | */ 61 | public class WordPressActionsExtender extends PhpModuleActionsExtender { 62 | 63 | @NbBundle.Messages("LBL_MenuName=WordPress") 64 | @Override 65 | public String getMenuName() { 66 | return Bundle.LBL_MenuName(); 67 | } 68 | 69 | @Override 70 | public RunCommandAction getRunCommandAction() { 71 | // wp-cli path is validated when the Run Command action is run 72 | return WordPressRunCommandAction.getInstance(); 73 | } 74 | 75 | @Override 76 | public List getActions() { 77 | List actions = new ArrayList<>(); 78 | actions.add(CreateThemeAction.getInstance()); 79 | actions.add(CreateChildThemeAction.getInstance()); 80 | actions.add(CreatePluginAction.getInstance()); 81 | actions.add(new RefreshCodeCompletionAction()); 82 | actions.add(CreatePermalinkHtaccessAction.getInstance()); 83 | return actions; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/WordPressModuleInstall.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress; 43 | 44 | import java.util.logging.Level; 45 | import java.util.logging.Logger; 46 | import org.netbeans.api.progress.ProgressHandle; 47 | import org.netbeans.modules.php.api.executable.InvalidPhpExecutableException; 48 | import org.netbeans.modules.php.api.util.StringUtils; 49 | import org.netbeans.modules.php.wordpress.commands.WordPressCli; 50 | import org.netbeans.modules.php.wordpress.ui.options.WordPressOptions; 51 | import org.openide.modules.ModuleInstall; 52 | import org.openide.util.NbBundle; 53 | import org.openide.util.RequestProcessor; 54 | 55 | /** 56 | * 57 | * @author junichi11 58 | */ 59 | public class WordPressModuleInstall extends ModuleInstall { 60 | 61 | private static final Logger LOGGER = Logger.getLogger(WordPressModuleInstall.class.getName()); 62 | private static final long serialVersionUID = 6916751777614125653L; 63 | 64 | @NbBundle.Messages("WordPressModule.get.commands=Getting wp-cli commands...") 65 | @Override 66 | public void restored() { 67 | super.restored(); 68 | WordPressOptions options = WordPressOptions.getInstance(); 69 | String wpCliPath = options.getWpCliPath(); 70 | if (!StringUtils.isEmpty(wpCliPath) && options.getWpCliGetCommandsOnBoot()) { 71 | RequestProcessor.getDefault().post(() -> { 72 | ProgressHandle handle = ProgressHandle.createHandle(Bundle.WordPressModule_get_commands()); 73 | try { 74 | handle.start(); 75 | try { 76 | WordPressCli wpCli = WordPressCli.getDefault(false); 77 | wpCli.getCommands(false); 78 | } catch (InvalidPhpExecutableException ex) { 79 | LOGGER.log(Level.WARNING, ex.getLocalizedMessage()); 80 | } 81 | } finally { 82 | handle.finish(); 83 | } 84 | }); 85 | } 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/commands/WordPressCliCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.commands; 43 | 44 | import java.util.Arrays; 45 | import org.netbeans.modules.php.api.util.StringUtils; 46 | import org.netbeans.modules.php.spi.framework.commands.FrameworkCommand; 47 | 48 | /** 49 | * 50 | * @author junichi11 51 | */ 52 | public final class WordPressCliCommand extends FrameworkCommand { 53 | 54 | private final String help; 55 | 56 | public WordPressCliCommand(String command, String description, String help) { 57 | super(command, description, command); 58 | this.help = help; 59 | } 60 | 61 | public WordPressCliCommand(String[] commands, String description, String help) { 62 | super(commands, description, StringUtils.implode(Arrays.asList(commands), " ")); 63 | this.help = help; 64 | } 65 | 66 | @Override 67 | protected String getHelpInternal() { 68 | return help; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/commands/WordPressCliCommandListBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.commands; 43 | 44 | import java.util.List; 45 | import org.netbeans.modules.php.spi.framework.commands.FrameworkCommand; 46 | 47 | /** 48 | * 49 | * @author junichi11 50 | */ 51 | public interface WordPressCliCommandListBuilder { 52 | 53 | public void build(List commands); 54 | 55 | public String asText(); 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/commands/WordPressCliCommandListXmlBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.commands; 43 | 44 | import java.io.StringWriter; 45 | import java.util.Arrays; 46 | import java.util.List; 47 | import java.util.logging.Level; 48 | import java.util.logging.Logger; 49 | import javax.xml.parsers.DocumentBuilder; 50 | import javax.xml.parsers.DocumentBuilderFactory; 51 | import javax.xml.parsers.ParserConfigurationException; 52 | import javax.xml.transform.Transformer; 53 | import javax.xml.transform.TransformerConfigurationException; 54 | import javax.xml.transform.TransformerException; 55 | import javax.xml.transform.TransformerFactory; 56 | import javax.xml.transform.dom.DOMSource; 57 | import javax.xml.transform.stream.StreamResult; 58 | import org.netbeans.modules.php.api.util.StringUtils; 59 | import org.netbeans.modules.php.spi.framework.commands.FrameworkCommand; 60 | import org.openide.util.Exceptions; 61 | import org.w3c.dom.Document; 62 | import org.w3c.dom.Element; 63 | import org.w3c.dom.Text; 64 | 65 | public class WordPressCliCommandListXmlBuilder implements WordPressCliCommandListBuilder { 66 | 67 | private static final Logger LOGGER = Logger.getLogger(WordPressCliCommandListXmlBuilder.class.getName()); 68 | private Document document = null; 69 | 70 | @Override 71 | public void build(List commands) { 72 | DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 73 | try { 74 | DocumentBuilder builder = factory.newDocumentBuilder(); 75 | document = builder.newDocument(); 76 | } catch (ParserConfigurationException ex) { 77 | Exceptions.printStackTrace(ex); 78 | } 79 | 80 | if (document == null) { 81 | LOGGER.log(Level.WARNING, "can't create xml document."); 82 | return; 83 | } 84 | Element commandsElement = document.createElement("commands"); // NOI18N 85 | document.appendChild(commandsElement); 86 | for (FrameworkCommand command : commands) { 87 | Element commandElement = document.createElement("command"); // NOI18N 88 | commandElement.setAttribute("name", StringUtils.implode(Arrays.asList(command.getCommands()), " ")); // NOI18N 89 | commandElement.setAttribute("displayname", command.getDisplayName()); // NOI18N 90 | 91 | // description 92 | Element descriptionElement = document.createElement("description"); // NOI18N 93 | Text descriptionText = document.createCDATASection(command.getDescription()); 94 | descriptionElement.appendChild(descriptionText); 95 | commandElement.appendChild(descriptionElement); 96 | 97 | // help 98 | Element helpElement = document.createElement("help"); // NOI18N 99 | Text helpText = document.createCDATASection(command.getHelp()); 100 | helpElement.appendChild(helpText); 101 | commandElement.appendChild(helpElement); 102 | 103 | commandsElement.appendChild(commandElement); 104 | } 105 | } 106 | 107 | @Override 108 | public String asText() { 109 | if (document == null) { 110 | return null; 111 | } 112 | TransformerFactory transformerFactory = TransformerFactory.newInstance(); 113 | try { 114 | StringWriter stringWriter = new StringWriter(); 115 | Transformer transformer = transformerFactory.newTransformer(); 116 | transformer.transform(new DOMSource(document), new StreamResult(stringWriter)); 117 | return stringWriter.toString(); 118 | } catch (TransformerConfigurationException ex) { 119 | Exceptions.printStackTrace(ex); 120 | } catch (TransformerException ex) { 121 | Exceptions.printStackTrace(ex); 122 | } 123 | return null; 124 | } 125 | 126 | } 127 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/commands/WordPressCliCommandsXmlParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.commands; 43 | 44 | import java.io.IOException; 45 | import java.io.Reader; 46 | import java.util.List; 47 | import org.netbeans.modules.php.api.util.FileUtils; 48 | import org.netbeans.modules.php.spi.framework.commands.FrameworkCommand; 49 | import org.openide.util.Exceptions; 50 | import org.xml.sax.Attributes; 51 | import org.xml.sax.InputSource; 52 | import org.xml.sax.SAXException; 53 | import org.xml.sax.XMLReader; 54 | import org.xml.sax.helpers.DefaultHandler; 55 | 56 | /** 57 | * 58 | * @author junichi11 59 | */ 60 | public class WordPressCliCommandsXmlParser extends DefaultHandler { 61 | 62 | private final List commands; 63 | private final XMLReader xmlReader; 64 | private String displayname; 65 | private String[] command; 66 | private Object content; 67 | private String description; 68 | private String help; 69 | 70 | public WordPressCliCommandsXmlParser(List commands) throws SAXException { 71 | assert commands != null; 72 | 73 | this.commands = commands; 74 | xmlReader = FileUtils.createXmlReader(); 75 | xmlReader.setContentHandler(this); 76 | } 77 | 78 | public static void parse(Reader reader, List commands) { 79 | try { 80 | WordPressCliCommandsXmlParser parser = new WordPressCliCommandsXmlParser(commands); 81 | parser.xmlReader.parse(new InputSource(reader)); 82 | } catch (SAXException | IOException ex) { 83 | Exceptions.printStackTrace(ex); 84 | } finally { 85 | try { 86 | reader.close(); 87 | } catch (IOException ex) { 88 | Exceptions.printStackTrace(ex); 89 | } 90 | } 91 | } 92 | 93 | @Override 94 | public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { 95 | if (null != qName) { 96 | switch (qName) { 97 | case "command": // NOI18N 98 | command = attributes.getValue("name").split(" "); // NOI18N 99 | displayname = attributes.getValue("displayname"); // NOI18N 100 | break; 101 | case "description": // NOI18N 102 | content = "description"; // NOI18N 103 | break; 104 | case "help": // NOI18N 105 | content = "help"; // NOI18N 106 | break; 107 | default: 108 | break; 109 | } 110 | } 111 | } 112 | 113 | @Override 114 | public void endElement(String uri, String localName, String qName) throws SAXException { 115 | if ("command".equals(qName)) { // NOI18N 116 | commands.add(new WordPressCliCommand(command, description, help)); 117 | command = null; 118 | description = null; 119 | help = null; 120 | } 121 | } 122 | 123 | @Override 124 | public void characters(char[] ch, int start, int length) throws SAXException { 125 | if ("description".equals(content)) { // NOI18N 126 | description = new String(ch, start, length); 127 | } else if ("help".equals(content)) { // NOI18N 128 | help = new String(ch, start, length); 129 | } 130 | } 131 | 132 | } 133 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/commands/WordPressCommandSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.commands; 43 | 44 | import java.io.File; 45 | import java.util.ArrayList; 46 | import java.util.Arrays; 47 | import java.util.Collections; 48 | import java.util.List; 49 | import org.netbeans.modules.php.api.executable.InvalidPhpExecutableException; 50 | import org.netbeans.modules.php.api.phpmodule.PhpModule; 51 | import org.netbeans.modules.php.api.util.UiUtils; 52 | import org.netbeans.modules.php.spi.framework.commands.FrameworkCommand; 53 | import org.netbeans.modules.php.spi.framework.commands.FrameworkCommandSupport; 54 | import org.netbeans.modules.php.wordpress.ui.options.WordPressOptions; 55 | import org.openide.util.Exceptions; 56 | import org.openide.util.NbBundle; 57 | 58 | /** 59 | * 60 | * @author junichi11 61 | */ 62 | public class WordPressCommandSupport extends FrameworkCommandSupport { 63 | 64 | private boolean isFirst = true; 65 | 66 | public WordPressCommandSupport(PhpModule phpModule) { 67 | super(phpModule); 68 | } 69 | 70 | @NbBundle.Messages("WordPressCommandSupport.name=WordPress") 71 | @Override 72 | public String getFrameworkName() { 73 | return Bundle.WordPressCommandSupport_name(); 74 | } 75 | 76 | @Override 77 | public void runCommand(CommandDescriptor commandDescriptor, Runnable postExecution) { 78 | String[] commands = commandDescriptor.getFrameworkCommand().getCommands(); 79 | String[] commandParams = commandDescriptor.getCommandParams(); 80 | List params = new ArrayList<>(commands.length + commandParams.length); 81 | params.addAll(Arrays.asList(commands)); 82 | params.addAll(Arrays.asList(commandParams)); 83 | try { 84 | WordPressCli.getDefault(false).runCommand(phpModule, params, postExecution); 85 | } catch (InvalidPhpExecutableException ex) { 86 | UiUtils.invalidScriptProvided(ex.getLocalizedMessage(), WordPressOptions.OPTIONS_SUBPATH); 87 | } 88 | } 89 | 90 | @Override 91 | protected String getOptionsPath() { 92 | return WordPressOptions.getOptionsPath(); 93 | } 94 | 95 | @Override 96 | protected File getPluginsDirectory() { 97 | return null; 98 | } 99 | 100 | @Override 101 | protected List getFrameworkCommandsInternal() { 102 | try { 103 | WordPressCli wpCli = WordPressCli.getDefault(true); 104 | if (isFirst) { 105 | isFirst = false; 106 | return wpCli.getCommands(false); 107 | } 108 | return wpCli.getCommands(true); 109 | 110 | } catch (InvalidPhpExecutableException ex) { 111 | Exceptions.printStackTrace(ex); 112 | } 113 | return Collections.emptyList(); 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/customizer/Bundle.properties: -------------------------------------------------------------------------------- 1 | WordPressCustomizerExtenderPanel.customContentNameLabel.text=custom content name: 2 | WordPressCustomizerExtenderPanel.customContentNameLabel.text=Custom content name: 3 | WordPressCustomizerExtenderPanel.customContentNameTextField.text= 4 | WordPressCustomizerExtenderPanel.customContentNameTextField.text= 5 | WordPressCustomizerExtenderPanel.toolTipText=Please check this if you want to enable as WordPress project 6 | WordPressCustomizerExtenderPanel.enabledCheckBox.text=Enabled 7 | WordPressCustomizerExtenderPanel.customDirectoryPathLabel.text=Custom directory paths from source directory: 8 | WordPressCustomizerExtenderPanel.pluginsLabel.text=plugins: 9 | WordPressCustomizerExtenderPanel.pluginsTextField.text= 10 | WordPressCustomizerExtenderPanel.themesLabel.text=themes: 11 | WordPressCustomizerExtenderPanel.wordPressRootLabel.text=WordPress Root: 12 | WordPressCustomizerExtenderPanel.wordPressRootTextField.text= 13 | WordPressCustomizerExtenderPanel.themesTextField.text= 14 | WordPressCustomizerExtenderPanel.customDirectoryPathLabel.toolTipText=empty is default directory structure 15 | WordPressCustomizerExtenderPanel.wpContentLabel.text=wp-content: 16 | WordPressCustomizerExtenderPanel.wpContentTextField.text= 17 | WordPressCustomizerExtenderPanel.jLabel1.text=(If wp-content is not in the WordPress Root) 18 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/editor/completion/ActionCompletionDocumentation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.editor.completion; 43 | 44 | import java.net.MalformedURLException; 45 | import java.net.URL; 46 | import org.openide.util.Exceptions; 47 | 48 | /** 49 | * 50 | * @author junichi11 51 | */ 52 | public class ActionCompletionDocumentation extends WordPressCompletionDocumentation { 53 | 54 | public ActionCompletionDocumentation(ActionCompletionItem item) { 55 | super(item); 56 | } 57 | 58 | @Override 59 | public URL getURL() { 60 | try { 61 | return new URL("http://codex.wordpress.org/Plugin_API/Action_Reference"); // NOI18N 62 | } catch (MalformedURLException ex) { 63 | Exceptions.printStackTrace(ex); 64 | } 65 | return null; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/editor/completion/ActionCompletionItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.editor.completion; 43 | 44 | import javax.swing.text.Document; 45 | import org.netbeans.spi.editor.completion.CompletionResultSet; 46 | import org.netbeans.spi.editor.completion.CompletionTask; 47 | import org.netbeans.spi.editor.completion.support.AsyncCompletionQuery; 48 | import org.netbeans.spi.editor.completion.support.AsyncCompletionTask; 49 | 50 | /** 51 | * 52 | * @author junichi11 53 | */ 54 | public class ActionCompletionItem extends WordPressCompletionItem { 55 | 56 | public ActionCompletionItem(String text, int startOffset, int removeLength) { 57 | super(text, startOffset, removeLength); 58 | } 59 | 60 | ActionCompletionItem(String text, String description) { 61 | super(text, description); 62 | } 63 | 64 | @Override 65 | public CompletionTask createDocumentationTask() { 66 | return new AsyncCompletionTask(new AsyncCompletionQuery() { 67 | @Override 68 | protected void query(CompletionResultSet completionResultSet, Document document, int i) { 69 | completionResultSet.setDocumentation(new ActionCompletionDocumentation(ActionCompletionItem.this)); 70 | completionResultSet.finish(); 71 | } 72 | }); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/editor/completion/FilterCompletionDocumentation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.editor.completion; 43 | 44 | import java.net.MalformedURLException; 45 | import java.net.URL; 46 | import org.openide.util.Exceptions; 47 | 48 | /** 49 | * 50 | * @author junichi11 51 | */ 52 | public class FilterCompletionDocumentation extends WordPressCompletionDocumentation { 53 | 54 | 55 | public FilterCompletionDocumentation(FilterCompletionItem item) { 56 | super(item); 57 | } 58 | 59 | @Override 60 | public URL getURL() { 61 | try { 62 | return new URL("http://codex.wordpress.org/Plugin_API/Filter_Reference"); // NO18N 63 | } catch (MalformedURLException ex) { 64 | Exceptions.printStackTrace(ex); 65 | } 66 | return null; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/editor/completion/FilterCompletionItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.editor.completion; 43 | 44 | import javax.swing.text.Document; 45 | import org.netbeans.spi.editor.completion.CompletionResultSet; 46 | import org.netbeans.spi.editor.completion.CompletionTask; 47 | import org.netbeans.spi.editor.completion.support.AsyncCompletionQuery; 48 | import org.netbeans.spi.editor.completion.support.AsyncCompletionTask; 49 | 50 | /** 51 | * 52 | * @author junichi11 53 | */ 54 | public class FilterCompletionItem extends WordPressCompletionItem { 55 | 56 | public FilterCompletionItem(String text, int startOffset, int removeLength) { 57 | super(text, startOffset, removeLength); 58 | } 59 | 60 | public FilterCompletionItem(String text, String description) { 61 | super(text, description); 62 | } 63 | 64 | @Override 65 | public CompletionTask createDocumentationTask() { 66 | return new AsyncCompletionTask(new AsyncCompletionQuery() { 67 | @Override 68 | protected void query(CompletionResultSet completionResultSet, Document document, int i) { 69 | completionResultSet.setDocumentation(new FilterCompletionDocumentation(FilterCompletionItem.this)); 70 | completionResultSet.finish(); 71 | } 72 | }); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/editor/completion/WordPressCompletionDocumentation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.editor.completion; 43 | 44 | import java.net.URL; 45 | import javax.swing.Action; 46 | import org.netbeans.spi.editor.completion.CompletionDocumentation; 47 | 48 | /** 49 | * 50 | * @author junichi11 51 | */ 52 | public class WordPressCompletionDocumentation implements CompletionDocumentation { 53 | 54 | private final WordPressCompletionItem item; 55 | 56 | WordPressCompletionDocumentation(WordPressCompletionItem item) { 57 | this.item = item; 58 | } 59 | 60 | @Override 61 | public String getText() { 62 | return item.getDescription(); 63 | } 64 | 65 | @Override 66 | public URL getURL() { 67 | return null; 68 | } 69 | 70 | @Override 71 | public CompletionDocumentation resolveLink(String string) { 72 | return null; 73 | } 74 | 75 | @Override 76 | public Action getGotoSourceAction() { 77 | return null; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/editor/completion/WordPressCompletionProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.editor.completion; 43 | 44 | import javax.swing.text.Document; 45 | import javax.swing.text.JTextComponent; 46 | import org.netbeans.modules.editor.NbEditorUtilities; 47 | import org.netbeans.modules.php.api.phpmodule.PhpModule; 48 | import org.netbeans.modules.php.wordpress.util.WPUtils; 49 | import org.netbeans.spi.editor.completion.CompletionProvider; 50 | import org.netbeans.spi.editor.completion.CompletionTask; 51 | import org.openide.filesystems.FileObject; 52 | 53 | /** 54 | * 55 | * @author junichi11 56 | */ 57 | public abstract class WordPressCompletionProvider implements CompletionProvider { 58 | 59 | @Override 60 | public CompletionTask createTask(int queryType, JTextComponent component) { 61 | PhpModule phpModule = getPhpModule(component); 62 | if (!WPUtils.isWP(phpModule)) { 63 | return null; 64 | } 65 | return createTask(queryType, component, phpModule); 66 | } 67 | 68 | public abstract CompletionTask createTask(int queryType, JTextComponent component, PhpModule phpModule); 69 | 70 | @Override 71 | public int getAutoQueryTypes(JTextComponent component, String typedText) { 72 | return 0; 73 | } 74 | 75 | private PhpModule getPhpModule(JTextComponent component) { 76 | Document doc = component.getDocument(); 77 | FileObject fileObject = NbEditorUtilities.getFileObject(doc); 78 | if (fileObject == null) { 79 | return null; 80 | } 81 | return PhpModule.Factory.forFileObject(fileObject); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/modules/WordPressDummyModuleImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2014 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2014 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.modules; 43 | 44 | import org.openide.filesystems.FileObject; 45 | 46 | public class WordPressDummyModuleImpl extends WordPressModuleImpl { 47 | 48 | @Override 49 | public FileObject getPluginsDirectory() { 50 | return null; 51 | } 52 | 53 | @Override 54 | public FileObject getThemesDirectory() { 55 | return null; 56 | } 57 | 58 | @Override 59 | public FileObject getIncludesDirectory() { 60 | return null; 61 | } 62 | 63 | @Override 64 | public FileObject getIncludesDirectory(String path) { 65 | return null; 66 | } 67 | 68 | @Override 69 | public FileObject getAdminDirectory() { 70 | return null; 71 | } 72 | 73 | @Override 74 | public FileObject getContentDirectory() { 75 | return null; 76 | } 77 | 78 | @Override 79 | public FileObject getWordPressRootDirecotry() { 80 | return null; 81 | } 82 | 83 | @Override 84 | public FileObject getDirecotry(WordPressModule.DIR_TYPE dirType) { 85 | return null; 86 | } 87 | 88 | @Override 89 | public FileObject getDirecotry(WordPressModule.DIR_TYPE dirType, String path) { 90 | return null; 91 | } 92 | 93 | @Override 94 | public FileObject getVersionFile() { 95 | return null; 96 | } 97 | 98 | @Override 99 | public void refresh() { 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/modules/WordPressModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2014 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2014 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.modules; 43 | 44 | import java.beans.PropertyChangeEvent; 45 | import java.beans.PropertyChangeListener; 46 | import java.beans.PropertyChangeSupport; 47 | import java.util.HashMap; 48 | import java.util.Map; 49 | import org.netbeans.modules.php.api.phpmodule.PhpModule; 50 | import org.openide.filesystems.FileObject; 51 | 52 | /** 53 | * 54 | * @author junichi11 55 | */ 56 | public final class WordPressModule { 57 | 58 | public enum DIR_TYPE { 59 | 60 | ADMIN, 61 | CONTENT, 62 | ROOT, 63 | INCLUDES, 64 | PLUGINS, 65 | THEMES; 66 | } 67 | 68 | private final WordPressModuleImpl impl; 69 | private final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this); 70 | public static final String PROPERTY_CHANGE_WP = "property-change-wp"; // NOI18N 71 | 72 | private WordPressModule(WordPressModuleImpl impl) { 73 | this.impl = impl; 74 | } 75 | 76 | public FileObject getPluginsDirectory() { 77 | return impl.getPluginsDirectory(); 78 | } 79 | 80 | public FileObject getThemesDirectory() { 81 | return impl.getThemesDirectory(); 82 | } 83 | 84 | public FileObject getIncludesDirectory() { 85 | return impl.getIncludesDirectory(); 86 | } 87 | 88 | public FileObject getIncludesDirectory(String path) { 89 | return impl.getIncludesDirectory(path); 90 | } 91 | 92 | public FileObject getAdminDirectory() { 93 | return impl.getAdminDirectory(); 94 | } 95 | 96 | public FileObject getWordPressRootDirecotry() { 97 | return impl.getWordPressRootDirecotry(); 98 | } 99 | 100 | public FileObject getVersionFile() { 101 | return impl.getVersionFile(); 102 | } 103 | 104 | public FileObject getDirecotry(DIR_TYPE dirType, String path) { 105 | return impl.getDirecotry(dirType, path); 106 | } 107 | 108 | public void addPropertyChangeListener(PropertyChangeListener listener) { 109 | propertyChangeSupport.addPropertyChangeListener(listener); 110 | } 111 | 112 | public void removePropertyChangeListener(PropertyChangeListener listener) { 113 | propertyChangeSupport.removePropertyChangeListener(listener); 114 | } 115 | 116 | public void notifyPropertyChanged(PropertyChangeEvent event) { 117 | if (PROPERTY_CHANGE_WP.equals(event.getPropertyName())) { 118 | refresh(); 119 | resetNode(); 120 | } 121 | } 122 | 123 | void refresh() { 124 | impl.refresh(); 125 | } 126 | 127 | void resetNode() { 128 | propertyChangeSupport.firePropertyChange(PROPERTY_CHANGE_WP, null, null); 129 | } 130 | 131 | //~ Inner class 132 | public static class Factory { 133 | 134 | private static final Map MODULES = new HashMap<>(); 135 | 136 | public static WordPressModule forPhpModule(PhpModule phpModule) { 137 | WordPressModule module = MODULES.get(phpModule); 138 | if (module != null) { 139 | return module; 140 | } 141 | 142 | WordPressModuleImpl impl; 143 | if (phpModule == null) { 144 | impl = new WordPressDummyModuleImpl(); 145 | } else { 146 | impl = new WordPress3ModuleImpl(phpModule); 147 | } 148 | module = new WordPressModule(impl); 149 | if (impl instanceof WordPress3ModuleImpl) { 150 | MODULES.put(phpModule, module); 151 | } 152 | return module; 153 | } 154 | 155 | public static void remove(PhpModule phpModule) { 156 | if (phpModule != null) { 157 | MODULES.remove(phpModule); 158 | } 159 | } 160 | } 161 | 162 | } 163 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/modules/WordPressModuleImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2014 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2014 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.modules; 43 | 44 | import org.netbeans.modules.php.wordpress.modules.WordPressModule.DIR_TYPE; 45 | import org.openide.filesystems.FileObject; 46 | 47 | /** 48 | * 49 | * @author junichi11 50 | */ 51 | public abstract class WordPressModuleImpl { 52 | 53 | public abstract FileObject getPluginsDirectory(); 54 | 55 | public abstract FileObject getThemesDirectory(); 56 | 57 | public abstract FileObject getIncludesDirectory(); 58 | 59 | public abstract FileObject getIncludesDirectory(String path); 60 | 61 | public abstract FileObject getAdminDirectory(); 62 | 63 | public abstract FileObject getContentDirectory(); 64 | 65 | public abstract FileObject getWordPressRootDirecotry(); 66 | 67 | public abstract FileObject getDirecotry(DIR_TYPE dirType); 68 | 69 | public abstract FileObject getDirecotry(DIR_TYPE dirType, String path); 70 | 71 | public abstract FileObject getVersionFile(); 72 | 73 | public abstract void refresh(); 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/resources/Bundle.properties: -------------------------------------------------------------------------------- 1 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 2 | # 3 | # Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. 4 | # 5 | # Oracle and Java are registered trademarks of Oracle and/or its affiliates. 6 | # Other names may be trademarks of their respective owners. 7 | # 8 | # The contents of this file are subject to the terms of either the GNU 9 | # General Public License Version 2 only ("GPL") or the Common 10 | # Development and Distribution License("CDDL") (collectively, the 11 | # "License"). You may not use this file except in compliance with the 12 | # License. You can obtain a copy of the License at 13 | # http://www.netbeans.org/cddl-gplv2.html 14 | # or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 15 | # specific language governing permissions and limitations under the 16 | # License. When distributing the software, include this License Header 17 | # Notice in each file and include the License file at 18 | # nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 19 | # particular file as subject to the "Classpath" exception as provided 20 | # by Oracle in the GPL Version 2 section of the License file that 21 | # accompanied this code. If applicable, add the following below the 22 | # License Header, with the fields enclosed by brackets [] replaced by 23 | # your own identifying information: 24 | # "Portions Copyrighted [year] [name of copyright owner]" 25 | # 26 | # If you wish your version of this file to be governed by only the CDDL 27 | # or only the GPL Version 2, indicate your decision by adding 28 | # "[Contributor] elects to include this software in this distribution 29 | # under the [CDDL or GPL Version 2] license." If you do not indicate a 30 | # single choice of license, a recipient has the option to distribute 31 | # your version of this file under either the CDDL, the GPL Version 2 or 32 | # to extend the choice of license to its licensees as provided above. 33 | # However, if you add GPL Version 2 code and therefore, elected the GPL 34 | # Version 2 license, then the option applies only if the new code is 35 | # made subject to such option by the copyright holder. 36 | # 37 | # Contributor(s): 38 | 39 | LBL_WordPressExportName=WordPress 40 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/resources/WpPlugin.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/resources/org-netbeans-modules-phpeditor-snippets.xml: -------------------------------------------------------------------------------- 1 | 2 | 43 | 44 | 45 | 46 | 47 | 57 | WordPress Snippet wordpress plugin header 58 | 59 | 60 | 76 | WordPress Snippet wordpress gplv2 77 | 78 | 79 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/resources/readme.txt: -------------------------------------------------------------------------------- 1 | === Plugin Name === 2 | Contributors: 3 | Donate link: 4 | Tags: 5 | Requires at least: 6 | Tested up to: 7 | Stable tag: 8 | License: GPLv2 or later 9 | License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 | 11 | 12 | == Description == 13 | 14 | 15 | == Installation == 16 | 17 | 18 | == Changelog == 19 | 20 | = 1.0 = 21 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/resources/templates/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | RewriteEngine On 3 | RewriteBase / 4 | RewriteRule ^index\.php$ - [L] 5 | RewriteCond %{REQUEST_FILENAME} !-f 6 | RewriteCond %{REQUEST_FILENAME} !-d 7 | RewriteRule . /index.php [L] 8 | 9 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/resources/templates/WpChildThemeStyleDescription.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Create a new WordPress Child Theme style file (style.css). 9 | 10 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/resources/templates/WpGPLv2LicenseDescription.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | WordPress License file for GPLv2. 9 | 10 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/resources/templates/WpPermalinkHtaccessDescription.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Create a new .htaccess file for permalink.
9 |
10 | <IfModule mod_rewrite.c>
11 | RewriteEngine On
12 | RewriteBase /
13 | RewriteRule ^index\.php$ - [L]
14 | RewriteCond %{REQUEST_FILENAME} !-f
15 | RewriteCond %{REQUEST_FILENAME} !-d
16 | RewriteRule . /index.php [L]
17 | </IfModule>
18 | 
19 | 20 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/resources/templates/WpPlugin.php: -------------------------------------------------------------------------------- 1 | 13 | <#assign licensePrefix = ""> 14 | <#assign licenseLast = "*/"> 15 | <#include "../Licenses/license-wp-gpl20.txt"> 16 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/resources/templates/WpPluginDescription.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Create a new WordPress Plugin file. 9 | 10 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/resources/templates/WpPluginReadmeDescription.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Create a new WordPress Plugin readme file(readme.txt). 9 | 10 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/resources/templates/WpThemeStyleDescription.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Create a new WordPress Theme style file (style.css). 9 | 10 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/resources/templates/child-style.css: -------------------------------------------------------------------------------- 1 | /* 2 | Theme Name: <#if name?? && name != "">${name} 3 | Theme URI: <#if uri?? && uri != "">${uri} 4 | Description: <#if description?? && description != "">${description} 5 | Version: <#if version?? && version != "">${version} 6 | Author: <#if author?? && author != "">${author} 7 | Author URI: <#if authorUri?? && authorUri != "">${authorUri} 8 | Template: <#if parent?? && parent != "">${parent} 9 | License: GNU General Public License v2 or later 10 | License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 | Tags: <#if tags?? && tags != "">${tags} 12 | Text Domain: <#if textDomain?? && textDomain != "">${textDomain} 13 | */ 14 | 15 | @import url("../<#if parent?? && parent != "">${parent}<#else>parent/style.css"); 16 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/resources/templates/license-wp-gpl20.txt: -------------------------------------------------------------------------------- 1 | <#if licenseFirst??> 2 | ${licenseFirst} 3 | 4 | ${licensePrefix}Copyright (C) ${date?date?string("yyyy")} ${project.organization!user} 5 | ${licensePrefix?replace(" +$", "", "r")} 6 | ${licensePrefix}This program is free software; you can redistribute it and/or 7 | ${licensePrefix}modify it under the terms of the GNU General Public License 8 | ${licensePrefix}as published by the Free Software Foundation; either version 2 9 | ${licensePrefix}of the License, or (at your option) any later version. 10 | ${licensePrefix?replace(" +$", "", "r")} 11 | ${licensePrefix}This program is distributed in the hope that it will be useful, 12 | ${licensePrefix}but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ${licensePrefix}MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ${licensePrefix}GNU General Public License for more details. 15 | ${licensePrefix?replace(" +$", "", "r")} 16 | ${licensePrefix}You should have received a copy of the GNU General Public License 17 | ${licensePrefix}along with this program; if not, write to the Free Software 18 | ${licensePrefix}Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 | <#if licenseLast??> 20 | ${licenseLast} 21 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/resources/templates/package-info.java: -------------------------------------------------------------------------------- 1 | @TemplateRegistrations({ 2 | @TemplateRegistration( 3 | folder = "Licenses", 4 | iconBase = WordPress.WP_ICON_16, 5 | displayName = "#WordPress_License_Template_DisplayName", 6 | content = "license-wp-gpl20.txt", 7 | description = "WpGPLv2LicenseDescription.html", 8 | scriptEngine = "freemarker"), 9 | @TemplateRegistration( 10 | folder = "WordPress", 11 | iconBase = WordPress.WP_ICON_16, 12 | displayName = "#WordPress_Plugin_Template_DisplayName", 13 | content = "WpPlugin.php", 14 | description = "WpPluginDescription.html", 15 | scriptEngine = "freemarker"), 16 | @TemplateRegistration( 17 | folder = "WordPress", 18 | iconBase = WordPress.WP_ICON_16, 19 | displayName = "#WordPress_Plugin_Readme_DisplayName", 20 | content = "readme.txt", 21 | description = "WpPluginReadmeDescription.html", 22 | scriptEngine = "freemarker"), 23 | @TemplateRegistration( 24 | folder = "WordPress", 25 | iconBase = WordPress.WP_ICON_16, 26 | displayName = "#WordPress_Theme_Style_DisplayName", 27 | content = "style.css", 28 | description = "WpThemeStyleDescription.html", 29 | scriptEngine = "freemarker"), 30 | @TemplateRegistration( 31 | folder = "WordPress", 32 | iconBase = WordPress.WP_ICON_16, 33 | displayName = "#WordPress_Child_Theme_Style_DisplayName", 34 | content = "child-style.css", 35 | description = "WpChildThemeStyleDescription.html", 36 | scriptEngine = "freemarker"), 37 | @TemplateRegistration( 38 | folder = "WordPress", 39 | // iconBase = WordPress.WP_ICON_16, 40 | displayName = "#WordPress_Permalink_Htaccess_DisplayName", 41 | content = ".htaccess", 42 | description = "WpPermalinkHtaccessDescription.html", 43 | scriptEngine = "freemarker"),}) 44 | @NbBundle.Messages({ 45 | "WordPress_License_Template_DisplayName=GPLv2", 46 | "WordPress_Plugin_Template_DisplayName=WordPress Plugin File", 47 | "WordPress_Plugin_Readme_DisplayName=WordPress Plugin Readme File", 48 | "WordPress_Theme_Style_DisplayName=WordPress Theme Style File", 49 | "WordPress_Child_Theme_Style_DisplayName=WordPress Child Theme Style File", 50 | "WordPress_Permalink_Htaccess_DisplayName=WordPress .htaccess file for permalink"}) 51 | package org.netbeans.modules.php.wordpress.resources.templates; 52 | 53 | import org.netbeans.api.templates.TemplateRegistration; 54 | import org.netbeans.api.templates.TemplateRegistrations; 55 | import org.netbeans.modules.php.wordpress.WordPress; 56 | import org.openide.util.NbBundle; 57 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/resources/templates/readme.txt: -------------------------------------------------------------------------------- 1 | === Plugin Name === 2 | Contributors: ${user} 3 | Donate link: 4 | Tags: 5 | Requires at least: 6 | Tested up to: 7 | Stable tag: 8 | License: GPLv2 or later 9 | License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 | 11 | 12 | == Description == 13 | 14 | 15 | == Installation == 16 | 17 | 18 | == Changelog == 19 | 20 | = 1.0 = 21 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/resources/templates/style.css: -------------------------------------------------------------------------------- 1 | /* 2 | Theme Name: 3 | Theme URI: 4 | Description: 5 | Version: 1.0 6 | Author: ${user} 7 | Author URI: 8 | License: GNU General Public License v2 or later 9 | License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 | Tags: 11 | Text Domain: 12 | */ 13 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/resources/wordpress_badge_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junichi11/netbeans-wordpress-plugin/12a0ae837044bd241153f8ba2e3fc0409dbc7323/src/org/netbeans/modules/php/wordpress/resources/wordpress_badge_8.png -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/resources/wordpress_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junichi11/netbeans-wordpress-plugin/12a0ae837044bd241153f8ba2e3fc0409dbc7323/src/org/netbeans/modules/php/wordpress/resources/wordpress_icon_16.png -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/resources/wordpress_icon_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junichi11/netbeans-wordpress-plugin/12a0ae837044bd241153f8ba2e3fc0409dbc7323/src/org/netbeans/modules/php/wordpress/resources/wordpress_icon_8.png -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/ui/actions/CreateBarebonesThemeAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.ui.actions; 43 | 44 | import java.util.Collections; 45 | import org.netbeans.modules.php.wordpress.util.GithubZipEntryFilter; 46 | import org.netbeans.modules.php.wordpress.util.ZipEntryFilter; 47 | import org.openide.util.NbBundle; 48 | 49 | /** 50 | * Create Barebones theme. 51 | * 52 | * @see https://github.com/welcomebrand/Barebones 53 | * @author junichi11 54 | */ 55 | public class CreateBarebonesThemeAction extends CreateThemeBaseAction { 56 | 57 | private static final long serialVersionUID = -2839579492132022777L; 58 | private static final String BAREBONES_GITHUB_ZIP_URL = "https://github.com/welcomebrand/Barebones/archive/master.zip"; // NOI18N 59 | private static final CreateBarebonesThemeAction INSTANCE = new CreateBarebonesThemeAction(); 60 | 61 | private CreateBarebonesThemeAction() { 62 | } 63 | 64 | public static CreateBarebonesThemeAction getInstance() { 65 | return INSTANCE; 66 | } 67 | 68 | @Override 69 | @NbBundle.Messages("LBL_Barebones=Barebones") 70 | protected String getName() { 71 | return Bundle.LBL_Barebones(); 72 | } 73 | 74 | @Override 75 | protected String getUrl() { 76 | return BAREBONES_GITHUB_ZIP_URL; 77 | } 78 | 79 | @Override 80 | protected ZipEntryFilter getZipEntryFilter() { 81 | return new GithubZipEntryFilter(Collections.singleton("assets")); // NOI18N 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/ui/actions/CreateThemeAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.ui.actions; 43 | 44 | import javax.swing.JMenu; 45 | import javax.swing.JMenuItem; 46 | import org.netbeans.modules.php.api.phpmodule.PhpModule; 47 | import org.netbeans.modules.php.spi.framework.actions.BaseAction; 48 | import org.openide.util.NbBundle; 49 | import org.openide.util.actions.Presenter; 50 | import org.openide.util.actions.Presenter.Popup; 51 | 52 | /** 53 | * 54 | * @author junichi11 55 | */ 56 | public class CreateThemeAction extends BaseAction implements Presenter.Menu, Popup { 57 | 58 | private static final long serialVersionUID = -1533566813298547558L; 59 | private static final CreateThemeAction INSTANCE = new CreateThemeAction(); 60 | 61 | private CreateThemeAction() { 62 | } 63 | 64 | public static CreateThemeAction getInstance() { 65 | return INSTANCE; 66 | } 67 | 68 | @Override 69 | protected String getFullName() { 70 | return getPureName(); 71 | } 72 | 73 | @Override 74 | @NbBundle.Messages("LBL_CreateThemeBaseAction=Create Theme") 75 | protected String getPureName() { 76 | return Bundle.LBL_CreateThemeBaseAction(); 77 | } 78 | 79 | @Override 80 | protected void actionPerformed(PhpModule pm) { 81 | } 82 | 83 | @Override 84 | public JMenuItem getMenuPresenter() { 85 | return createMenuItem(); 86 | } 87 | 88 | @Override 89 | public JMenuItem getPopupPresenter() { 90 | return createMenuItem(); 91 | } 92 | 93 | private JMenuItem createMenuItem() { 94 | JMenu menu = new JMenu(getPureName()); 95 | JMenuItem underscores = new JMenuItem(CreateUnderscoresThemeAction.getInstance()); 96 | JMenuItem barebones = new JMenuItem(CreateBarebonesThemeAction.getInstance()); 97 | menu.add(CreateMinimumBlankThemeAction.getInstance()); 98 | menu.add(underscores); 99 | menu.add(barebones); 100 | return menu; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/ui/actions/RefreshCodeCompletionAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.ui.actions; 43 | 44 | import java.util.Collection; 45 | import org.netbeans.api.editor.mimelookup.MimeLookup; 46 | import org.netbeans.api.editor.mimelookup.MimePath; 47 | import org.netbeans.modules.php.api.phpmodule.PhpModule; 48 | import org.netbeans.modules.php.api.util.FileUtils; 49 | import org.netbeans.modules.php.spi.framework.actions.BaseAction; 50 | import org.netbeans.modules.php.wordpress.editor.completion.FilterAndActionCompletion; 51 | import org.netbeans.modules.php.wordpress.util.WPUtils; 52 | import org.netbeans.spi.editor.completion.CompletionProvider; 53 | import org.openide.util.NbBundle; 54 | 55 | /** 56 | * 57 | * @author junichi11 58 | */ 59 | public class RefreshCodeCompletionAction extends BaseAction { 60 | 61 | private static final long serialVersionUID = -1446444622440007833L; 62 | 63 | @NbBundle.Messages({ 64 | "# {0} - name", 65 | "LBL_WordPressAction=WordPress Action: {0}" 66 | }) 67 | @Override 68 | protected String getFullName() { 69 | return Bundle.LBL_WordPressAction(getPureName()); 70 | } 71 | 72 | @NbBundle.Messages("LBL_ActionName=Refresh Code Completion") 73 | @Override 74 | protected String getPureName() { 75 | return Bundle.LBL_ActionName(); 76 | } 77 | 78 | @Override 79 | protected void actionPerformed(PhpModule pm) { 80 | if (!WPUtils.isWP(pm)) { 81 | // called via shortcut 82 | return; 83 | } 84 | MimePath mimePath = MimePath.parse(FileUtils.PHP_MIME_TYPE); 85 | Collection providers = MimeLookup.getLookup(mimePath).lookupAll(CompletionProvider.class); 86 | for (CompletionProvider provider : providers) { 87 | if (provider instanceof FilterAndActionCompletion) { 88 | FilterAndActionCompletion completion = (FilterAndActionCompletion) provider; 89 | completion.refresh(); 90 | } 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/ui/actions/WordPressRunCommandAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.ui.actions; 43 | 44 | import org.netbeans.api.options.OptionsDisplayer; 45 | import org.netbeans.modules.php.api.phpmodule.PhpModule; 46 | import org.netbeans.modules.php.api.util.StringUtils; 47 | import org.netbeans.modules.php.spi.framework.actions.RunCommandAction; 48 | import org.netbeans.modules.php.wordpress.WordPressPhpProvider; 49 | import org.netbeans.modules.php.wordpress.commands.WordPressCli; 50 | import org.netbeans.modules.php.wordpress.ui.options.WordPressOptions; 51 | import org.netbeans.modules.php.wordpress.util.WPUtils; 52 | import org.openide.DialogDisplayer; 53 | import org.openide.NotifyDescriptor; 54 | import org.openide.util.NbBundle; 55 | 56 | /** 57 | * 58 | * @author junichi11 59 | */ 60 | public class WordPressRunCommandAction extends RunCommandAction { 61 | 62 | private static final WordPressRunCommandAction INSTANCE = new WordPressRunCommandAction(); 63 | private static final long serialVersionUID = 158739462398606689L; 64 | 65 | private WordPressRunCommandAction() { 66 | } 67 | 68 | public static WordPressRunCommandAction getInstance() { 69 | return INSTANCE; 70 | } 71 | 72 | @Override 73 | public void actionPerformed(PhpModule phpModule) { 74 | if (!WPUtils.isWP(phpModule)) { 75 | return; 76 | } 77 | String wpCliPath = WordPressOptions.getInstance().getWpCliPath(); 78 | if (StringUtils.isEmpty(wpCliPath)) { 79 | openOptionsPanel(Bundle.WordPressRunCommandAction_message_no_wp_cli()); 80 | return; 81 | } 82 | String error = WordPressCli.validate(wpCliPath); 83 | if (error != null) { 84 | openOptionsPanel(Bundle.WordPressRunCommandAction_message_invalid_wp_cli()); 85 | return; 86 | } 87 | WordPressPhpProvider.getInstance().getFrameworkCommandSupport(phpModule).openPanel(); 88 | } 89 | 90 | @NbBundle.Messages({ 91 | "# {0} - action name", 92 | "WordPressRunCommandAction.name=WordPress: {0}" 93 | }) 94 | @Override 95 | protected String getFullName() { 96 | return Bundle.WordPressRunCommandAction_name(getPureName()); 97 | } 98 | 99 | @NbBundle.Messages({ 100 | "WordPressRunCommandAction.message.no.wp-cli=Please set wp-cli path.", 101 | "WordPressRunCommandAction.message.invalid.wp-cli=Please set valid wp-cli path." 102 | }) 103 | private void openOptionsPanel(String errorMessage) { 104 | NotifyDescriptor.Message message = new NotifyDescriptor.Message( 105 | errorMessage, 106 | NotifyDescriptor.ERROR_MESSAGE 107 | ); 108 | DialogDisplayer.getDefault().notify(message); 109 | OptionsDisplayer.getDefault().open(WordPressOptions.getOptionsPath()); 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/ui/options/Bundle.properties: -------------------------------------------------------------------------------- 1 | WordPressOptionsPanel.localFileTextField.text= 2 | WordPressOptionsPanel.downloadUrlLabel.text=Download URL : 3 | WordPressOptionsPanel.downloadUrlTextField.text= 4 | WordPressOptionsPanel.browseButton.text=Browse... 5 | WordPressOptionsPanel.hintLabel.text=HINT 6 | WordPressOptionsPanel.localFilePathLabel.text=Local file path : 7 | WordPressOptionsPanel.learnMoreWpCliLabel.text=learn more wp-cli 8 | WordPressOptionsPanel.noteLabel.text=Note: 9 | WordPressOptionsPanel.errorLabel.text=ERROR 10 | WordPressOptionsPanel.wpCliDownloadLabel.text=download: 11 | WordPressOptionsPanel.wpCliPathLabel.text=wp-cli path: 12 | WordPressOptionsPanel.newProjectLabel.text=New Project: 13 | WordPressOptionsPanel.wpCliLabel.text=wp-cli: 14 | WordPressOptionsPanel.wpCliSearchButton.text=Search... 15 | WordPressOptionsPanel.wpCliBrowseButton.text=Browse... 16 | WordPressOptionsPanel.wpCliPathTextField.text= 17 | WordPressOptionsPanel.wpCliDownloadVersionTextField.text= 18 | WordPressOptionsPanel.wpCliDownloadLocaleTextField.text= 19 | WordPressOptionsPanel.wpCliDownloadLocaleLabel.text=--locale= 20 | WordPressOptionsPanel.wpCliDownloadVersionLabel.text=--version= 21 | WordPressOptionsPanel.wpCliVersionLabel.text=VERSION 22 | WordPressOptionsPanel.wpCliGetCommandsOnBootCheckBox.text=Get command list on Boot 23 | WordPressOptionsPanel.generalLabel.text=General: 24 | WordPressOptionsPanel.localeLabel.text=locale: 25 | WordPressOptionsPanel.localeTextField.text= 26 | WordPressOptionsPanel.checkNewVersionLabel.text=Check new version when project is opened: 27 | WordPressOptionsPanel.checkCoreNewVersionCheckBox.text=core 28 | WordPressOptionsPanel.checkThemeNewVersionCheckBox.text=theme 29 | WordPressOptionsPanel.checkPluginNewVersionCheckBox.text=plugin 30 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/ui/options/WordPressOptionsPanelController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.ui.options; 43 | 44 | import java.beans.PropertyChangeListener; 45 | import java.beans.PropertyChangeSupport; 46 | import javax.swing.JComponent; 47 | import javax.swing.event.ChangeEvent; 48 | import javax.swing.event.ChangeListener; 49 | import org.netbeans.modules.php.api.util.UiUtils; 50 | import org.netbeans.spi.options.OptionsPanelController; 51 | import org.openide.util.HelpCtx; 52 | import org.openide.util.Lookup; 53 | import org.openide.util.NbBundle; 54 | 55 | @UiUtils.PhpOptionsPanelRegistration( 56 | id = WordPressOptionsPanelController.ID, 57 | displayName = "#LBL_WordPressOptionsName", 58 | position = 1000 59 | ) 60 | @NbBundle.Messages({"LBL_WordPressOptionsName=WordPress", "WordPress.options.keywords.TabTitle=Frameworks & Tools"}) 61 | @OptionsPanelController.Keywords(keywords = {"php", "wordpress", "wp"}, 62 | location = UiUtils.OPTIONS_PATH, tabTitle = "#WordPress.options.keywords.TabTitle") 63 | public final class WordPressOptionsPanelController extends OptionsPanelController implements ChangeListener { 64 | 65 | static final String ID = "WordPress"; // NOI18N 66 | private WordPressOptionsPanel panel; 67 | private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); 68 | private boolean changed = false; 69 | 70 | @Override 71 | public void update() { 72 | getPanel().load(); 73 | changed = false; 74 | } 75 | 76 | @Override 77 | public void applyChanges() { 78 | getPanel().store(); 79 | changed = false; 80 | } 81 | 82 | @Override 83 | public void cancel() { 84 | // need not do anything special, if no changes have been persisted yet 85 | } 86 | 87 | @Override 88 | public boolean isValid() { 89 | return getPanel().valid(); 90 | } 91 | 92 | @Override 93 | public boolean isChanged() { 94 | return changed; 95 | } 96 | 97 | @Override 98 | public HelpCtx getHelpCtx() { 99 | return null; // new HelpCtx("...ID") if you have a help set 100 | } 101 | 102 | @Override 103 | public JComponent getComponent(Lookup masterLookup) { 104 | return getPanel(); 105 | } 106 | 107 | @Override 108 | public void addPropertyChangeListener(PropertyChangeListener l) { 109 | pcs.addPropertyChangeListener(l); 110 | } 111 | 112 | @Override 113 | public void removePropertyChangeListener(PropertyChangeListener l) { 114 | pcs.removePropertyChangeListener(l); 115 | } 116 | 117 | private WordPressOptionsPanel getPanel() { 118 | if (panel == null) { 119 | panel = new WordPressOptionsPanel(); 120 | panel.addChangeListener(this); 121 | } 122 | return panel; 123 | } 124 | 125 | @Override 126 | public void stateChanged(ChangeEvent e) { 127 | if (!changed) { 128 | changed = true; 129 | pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true); 130 | } 131 | pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null); 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/ui/options/WordPressOptionsValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.ui.options; 43 | 44 | import org.netbeans.modules.php.api.validation.ValidationResult; 45 | import org.netbeans.modules.php.wordpress.commands.WordPressCli; 46 | 47 | /** 48 | * 49 | * @author junichi11 50 | */ 51 | public final class WordPressOptionsValidator { 52 | 53 | private final ValidationResult result; 54 | 55 | public WordPressOptionsValidator() { 56 | this.result = new ValidationResult(); 57 | } 58 | 59 | public WordPressOptionsValidator validate(String wpCliPath) { 60 | String error = WordPressCli.validate(wpCliPath); 61 | if (error != null) { 62 | result.addWarning(new ValidationResult.Message("wp-cli.path", error)); // NOI18N 63 | } 64 | return this; 65 | } 66 | 67 | public ValidationResult getResult() { 68 | return result; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/ui/wizards/Bundle.properties: -------------------------------------------------------------------------------- 1 | NewProjectConfigurationPanel.unzipLabel.text=Unzipping : 2 | NewProjectConfigurationPanel.unzipStatusTextField.text= 3 | NewProjectConfigurationPanel.useURLRadioButton.text=Use URL 4 | NewProjectConfigurationPanel.useLocalFileRadioButton.text=Use Local file 5 | NewProjectConfigurationPanel.localFileLabel.text= 6 | NewProjectConfigurationPanel.urlLabel.text= 7 | NewProjectConfigurationPanel.formatCheckBox.text=Set format options for WordPress to this project 8 | NewProjectConfigurationPanel.createConfigCheckBox.text=Create a wp-config.php 9 | CreateUnderscoresThemePanel.authorUriTextField.text= 10 | CreateUnderscoresThemePanel.descriptionTextField.text= 11 | CreateUnderscoresThemePanel.authorUriLabel.text=Author URI: 12 | CreateUnderscoresThemePanel.descriptionLabel.text=Description: 13 | CreateUnderscoresThemePanel.themeNameTextField.text= 14 | CreateUnderscoresThemePanel.authorTextField.text= 15 | CreateUnderscoresThemePanel.messageLabel.text=Please notice that license of theme is GPLv2 16 | CreateUnderscoresThemePanel.themeNameLabel.text=Theme Name: 17 | CreateUnderscoresThemePanel.authorLabel.text=Author: 18 | CreateThemePanel.themeNameLabel.text=Theme Name: 19 | CreateThemePanel.themeNameTextField.text= 20 | NewProjectConfigurationPanel.useWpCliRadioButton.text=Use wp-cli 21 | CreatePermalinkHtaccessPanel.messageLabel.text=MESSAGE 22 | CreateChildThemePanel.parentThemeLabel.text=Parent Theme: 23 | CreateChildThemePanel.errorLabel.text=ERROR 24 | CreateChildThemePanel.childThemeUriLabel.text=Child Theme URI: 25 | CreateChildThemePanel.descriptionLabel.text=Description: 26 | CreateChildThemePanel.versionLabel.text=Version: 27 | CreateChildThemePanel.authorLabel.text=Author: 28 | CreateChildThemePanel.tagsLabel.text=Tags: 29 | CreateChildThemePanel.textDomainLabel.text=Text Domain: 30 | CreateChildThemePanel.childThemeUriTextField.text= 31 | CreateChildThemePanel.descriptionTextField.text= 32 | CreateChildThemePanel.versionTextField.text=1.0.0 33 | CreateChildThemePanel.authorTextField.text= 34 | CreateChildThemePanel.tagsTextField.text= 35 | CreateChildThemePanel.textDomainTextField.text= 36 | CreateChildThemePanel.authorUriLabel.text=Author URI: 37 | CreateChildThemePanel.authorUriTextField.text= 38 | CreateChildThemePanel.childDirectoryNameLabel.text=Child Directory Name: 39 | CreateChildThemePanel.childDirectoryNameTextField.text= 40 | CreateChildThemePanel.childThemeNameLabel.text=Child Theme Name: 41 | CreateChildThemePanel.childThemeNameTextField.text= 42 | CreateMinimumBlankThemePanel.errorMessageLabel.text=ERROR 43 | CreateMinimumBlankThemePanel.themeDirectoryNameTextField.text= 44 | CreateMinimumBlankThemePanel.themeDirectoryNameLabel.text=Theme Directory Name: 45 | CreateMinimumBlankThemePanel.descriptionLabel.text=Just create a style.css and an empty index.php 46 | WpConfigPanel.dbNameLabel.text=DB_NAME: 47 | WpConfigPanel.dbCollateTextField.text= 48 | WpConfigPanel.dbCharsetTextField.text=utf8 49 | WpConfigPanel.dbHostTextField.text=localhost 50 | WpConfigPanel.dbPasswordTextField.text= 51 | WpConfigPanel.dbCollateLabel.toolTipText=DB_COLLATE 52 | WpConfigPanel.dbCollateLabel.text=DB_COLL: 53 | WpConfigPanel.dbCharsetLabel.toolTipText=DB_CHARSET 54 | WpConfigPanel.dbCharsetLabel.text=DB_CHAR: 55 | WpConfigPanel.dbHostLabel.text=DB_HOST: 56 | WpConfigPanel.dbPasswordLabel.toolTipText=DB_PASSWORD 57 | WpConfigPanel.dbPasswordLabel.text=DB_PASS: 58 | WpConfigPanel.dbUserTextField.text= 59 | WpConfigPanel.dbUserLabel.text=DB_USER: 60 | WpConfigPanel.dbNameTextField.text= 61 | NewProjectConfigurationPanel.setWpConfigValuesButton.text=Set wp-config values 62 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/ui/wizards/CreateMinimumBlankThemePanel.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 |
87 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/ui/wizards/CreatePermalinkHtaccessPanel.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 |
69 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/ui/wizards/CreatePermalinkHtaccessPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2014 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2014 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.ui.wizards; 43 | 44 | /** 45 | * 46 | * @author junichi11 47 | */ 48 | public class CreatePermalinkHtaccessPanel extends javax.swing.JPanel { 49 | 50 | private static final long serialVersionUID = -2916411786261985237L; 51 | 52 | /** 53 | * Creates new form CreatePermalinkHtaccessPanel 54 | */ 55 | public CreatePermalinkHtaccessPanel() { 56 | initComponents(); 57 | messageLabel.setText(" "); // NOI18N 58 | } 59 | 60 | public CreatePermalinkHtaccessPanel setMessage(String message) { 61 | messageLabel.setText(message); 62 | return this; 63 | } 64 | 65 | public CreatePermalinkHtaccessPanel setContents(String contents) { 66 | contentsTextArea.setText(contents); 67 | return this; 68 | } 69 | 70 | /** 71 | * This method is called from within the constructor to initialize the form. 72 | * WARNING: Do NOT modify this code. The content of this method is always 73 | * regenerated by the Form Editor. 74 | */ 75 | @SuppressWarnings("unchecked") 76 | // //GEN-BEGIN:initComponents 77 | private void initComponents() { 78 | 79 | messageLabel = new javax.swing.JLabel(); 80 | jScrollPane1 = new javax.swing.JScrollPane(); 81 | contentsTextArea = new javax.swing.JTextArea(); 82 | 83 | org.openide.awt.Mnemonics.setLocalizedText(messageLabel, org.openide.util.NbBundle.getMessage(CreatePermalinkHtaccessPanel.class, "CreatePermalinkHtaccessPanel.messageLabel.text")); // NOI18N 84 | 85 | contentsTextArea.setColumns(20); 86 | contentsTextArea.setRows(5); 87 | jScrollPane1.setViewportView(contentsTextArea); 88 | 89 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); 90 | this.setLayout(layout); 91 | layout.setHorizontalGroup( 92 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 93 | .addGroup(layout.createSequentialGroup() 94 | .addContainerGap() 95 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 96 | .addGroup(layout.createSequentialGroup() 97 | .addComponent(messageLabel) 98 | .addGap(0, 0, Short.MAX_VALUE)) 99 | .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 438, Short.MAX_VALUE)) 100 | .addContainerGap()) 101 | ); 102 | layout.setVerticalGroup( 103 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 104 | .addGroup(layout.createSequentialGroup() 105 | .addContainerGap() 106 | .addComponent(messageLabel) 107 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 108 | .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 167, Short.MAX_VALUE) 109 | .addContainerGap()) 110 | ); 111 | }// //GEN-END:initComponents 112 | 113 | // Variables declaration - do not modify//GEN-BEGIN:variables 114 | private javax.swing.JTextArea contentsTextArea; 115 | private javax.swing.JScrollPane jScrollPane1; 116 | private javax.swing.JLabel messageLabel; 117 | // End of variables declaration//GEN-END:variables 118 | } 119 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/update/UpdateItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.update; 43 | 44 | /** 45 | * depend on wp-cli. 46 | * 47 | * @author junichi11 48 | */ 49 | public class UpdateItem { 50 | 51 | private final String status; 52 | private final String name; 53 | private final String version; 54 | 55 | public UpdateItem(String status, String name, String version) { 56 | this.status = status; 57 | this.name = name; 58 | this.version = version; 59 | } 60 | 61 | public String getStatus() { 62 | return status; 63 | } 64 | 65 | public String getName() { 66 | return name; 67 | } 68 | 69 | public String getVersion() { 70 | return version; 71 | } 72 | 73 | public boolean isUpdate() { 74 | if (status == null) { 75 | return false; 76 | } 77 | return status.startsWith("U"); // NOI18N 78 | } 79 | 80 | public static class Factory { 81 | 82 | public Factory() { 83 | } 84 | 85 | public static UpdateItem create(String data) { 86 | data = data.trim(); 87 | data = data.replaceAll("\\s +", " "); // NOI18N 88 | String[] splitData = data.split(" "); // NOI18N 89 | if (splitData.length != 3) { 90 | return null; 91 | } 92 | return new UpdateItem(splitData[0], splitData[1], splitData[2]); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/update/UpgradeUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2015 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.update; 43 | 44 | import org.openide.DialogDisplayer; 45 | import org.openide.NotifyDescriptor; 46 | import org.openide.util.NbBundle; 47 | 48 | /** 49 | * 50 | * @author junichi11 51 | */ 52 | public final class UpgradeUtils { 53 | 54 | private UpgradeUtils() { 55 | } 56 | 57 | @NbBundle.Messages("UpgradeUtils.invalid.wpcli.message=Not found wp-cli: You can update the WordPress using the update command of wp-cli from this link if wp-cli path and locale are set to the Options.") 58 | public static void showInvalidWpCliDialog() { 59 | NotifyDescriptor.Message message = new NotifyDescriptor.Message( 60 | Bundle.UpgradeUtils_invalid_wpcli_message(), 61 | NotifyDescriptor.INFORMATION_MESSAGE 62 | ); 63 | DialogDisplayer.getDefault().notify(message); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/update/WordPressUpgradeChecker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.update; 43 | 44 | import org.netbeans.modules.php.api.phpmodule.PhpModule; 45 | 46 | /** 47 | * 48 | * @author junichi11 49 | */ 50 | public interface WordPressUpgradeChecker { 51 | 52 | public boolean hasUpgrade(PhpModule phpModule); 53 | 54 | public void notifyUpgrade(PhpModule phpModule); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/util/Charset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.util; 43 | 44 | /** 45 | * 46 | * @author junichi11 47 | */ 48 | public class Charset { 49 | 50 | public static final String UTF8 = "UTF-8"; // NOI18N 51 | } 52 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/util/DocUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.util; 43 | 44 | import javax.swing.text.AbstractDocument; 45 | import javax.swing.text.Document; 46 | import org.netbeans.api.lexer.TokenHierarchy; 47 | import org.netbeans.api.lexer.TokenSequence; 48 | import org.netbeans.modules.php.editor.lexer.PHPTokenId; 49 | 50 | /** 51 | * 52 | * @author junichi11 53 | */ 54 | public final class DocUtils { 55 | 56 | private DocUtils() { 57 | } 58 | 59 | /** 60 | * Get token sequence. 61 | * 62 | * @param doc 63 | * @return token sequence 64 | */ 65 | public static TokenSequence getTokenSequence(Document doc) { 66 | AbstractDocument ad = (AbstractDocument) doc; 67 | ad.readLock(); 68 | TokenSequence ts = null; 69 | try { 70 | TokenHierarchy hierarchy = TokenHierarchy.get(doc); 71 | ts = hierarchy.tokenSequence(PHPTokenId.language()); 72 | } finally { 73 | ad.readUnlock(); 74 | } 75 | return ts; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/util/GithubZipEntryFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.util; 43 | 44 | import java.util.Set; 45 | import java.util.zip.ZipEntry; 46 | import javax.swing.text.JTextComponent; 47 | 48 | /** 49 | * 50 | * @author junichi11 51 | */ 52 | public class GithubZipEntryFilter implements ZipEntryFilter { 53 | 54 | private JTextComponent component = null; 55 | protected Set topDirectories; 56 | 57 | public GithubZipEntryFilter() { 58 | } 59 | 60 | public GithubZipEntryFilter(Set topDirectories) { 61 | this.topDirectories = topDirectories; 62 | } 63 | 64 | public GithubZipEntryFilter(Set topDirectories, JTextComponent component) { 65 | this.topDirectories = topDirectories; 66 | this.component = component; 67 | } 68 | 69 | /** 70 | * Check whether unzip for ZipEntry. 71 | * 72 | * @param entry 73 | * @return true if unzip the file, otherwize false. 74 | */ 75 | @Override 76 | public boolean accept(ZipEntry entry) { 77 | String name = entry.getName(); 78 | String[] splitPath = splitPath(name); 79 | int length = splitPath.length; 80 | 81 | if (length == 1 && entry.isDirectory()) { 82 | return false; 83 | } 84 | 85 | return true; 86 | } 87 | 88 | /** 89 | * Get path of ZipEntry. 90 | * 91 | * @param entry 92 | * @return 93 | */ 94 | @Override 95 | public String getPath(ZipEntry entry) { 96 | String path = entry.getName(); 97 | String[] splitPath = splitPath(path); 98 | String topDirectory = splitPath[0]; 99 | if (topDirectories == null) { 100 | return path; 101 | } 102 | if (splitPath.length == 1 || topDirectories.contains(topDirectory)) { 103 | return path; 104 | } 105 | return path.replaceFirst(topDirectory + "/", ""); // NOI18N 106 | } 107 | 108 | /** 109 | * Set text to JTextComponent. e.g. display the file path on the 110 | * JTextComponent. 111 | * 112 | * @param text 113 | */ 114 | @Override 115 | public void setText(String text) { 116 | if (component != null) { 117 | component.setText(text); 118 | } 119 | } 120 | 121 | /** 122 | * Split path by "/". 123 | * 124 | * @param path 125 | * @return 126 | */ 127 | private String[] splitPath(String path) { 128 | return path.split("/"); // NOI18N 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/util/NetUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.util; 43 | 44 | import java.io.IOException; 45 | import java.net.MalformedURLException; 46 | import java.net.URL; 47 | import java.net.URLConnection; 48 | 49 | /** 50 | * 51 | * @author junichi11 52 | */ 53 | public class NetUtils { 54 | 55 | public static boolean isInternetReachable(String address) { 56 | try { 57 | URL url = new URL(address); 58 | URLConnection connection = url.openConnection(); 59 | connection.connect(); 60 | } catch (MalformedURLException ex) { 61 | return false; 62 | } catch (IOException ex) { 63 | return false; 64 | } 65 | return true; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/util/UnderscoresUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.util; 43 | 44 | /** 45 | * 46 | * @author junichi11 47 | */ 48 | public class UnderscoresUtils { 49 | 50 | public static String toFolderName(String text) { 51 | return toHyphen(text).toLowerCase(); 52 | } 53 | 54 | public static String toFunctionName(String text) { 55 | String name = toUnderscore(text); 56 | return name.toLowerCase() + "_"; // NOI18N 57 | } 58 | 59 | public static String toTextDomain(String text) { 60 | String domain = toUnderscore(text); 61 | return domain.toLowerCase(); 62 | } 63 | 64 | private static String toUnderscore(String text) { 65 | return text.replaceAll("[ \\.-]+", "_"); // NOI18N 66 | } 67 | 68 | private static String toHyphen(String text) { 69 | return text.replaceAll("[ \\.]+", "-"); // NOI18N 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/util/UnderscoresZipEntryFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.util; 43 | 44 | import java.util.HashSet; 45 | 46 | /** 47 | * 48 | * @author junichi11 49 | */ 50 | public class UnderscoresZipEntryFilter extends GithubZipEntryFilter { 51 | 52 | public UnderscoresZipEntryFilter() { 53 | topDirectories = new HashSet<>(); 54 | topDirectories.add("inc"); // NOI18N 55 | topDirectories.add("js"); // NOI18N 56 | topDirectories.add("languages"); // NOI18N 57 | topDirectories.add("layouts"); // NOI18N 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/util/WPUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.util; 43 | 44 | import java.io.IOException; 45 | import java.util.List; 46 | import java.util.regex.Matcher; 47 | import java.util.regex.Pattern; 48 | import org.netbeans.modules.php.api.phpmodule.PhpModule; 49 | import org.netbeans.modules.php.wordpress.WordPressPhpProvider; 50 | import org.openide.filesystems.FileObject; 51 | import org.openide.util.Exceptions; 52 | 53 | /** 54 | * 55 | * @author junichi11 56 | */ 57 | public final class WPUtils { 58 | 59 | private static final String VERSION_REGEX = "^\\$wp_version\\s*=\\s*'(.+)';$"; // NOI18N 60 | 61 | private WPUtils() { 62 | } 63 | 64 | public static boolean isWP(PhpModule phpModule) { 65 | if (phpModule == null) { 66 | return false; 67 | } 68 | return WordPressPhpProvider.getInstance().isInPhpModule(phpModule); 69 | } 70 | 71 | /** 72 | * Get WordPress version 73 | * 74 | * @param version version.php 75 | * @return version 76 | */ 77 | public static String getVersion(FileObject version) { 78 | String versionNumber = ""; // NOI18N 79 | Pattern pattern = Pattern.compile(VERSION_REGEX); 80 | 81 | try { 82 | List lines = version.asLines(); 83 | for (String line : lines) { 84 | Matcher matcher = pattern.matcher(line); 85 | if (matcher.find()) { 86 | versionNumber = matcher.group(1); 87 | break; 88 | } 89 | } 90 | } catch (IOException ex) { 91 | Exceptions.printStackTrace(ex); 92 | } 93 | 94 | return versionNumber; 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/util/WPZipEntryFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.util; 43 | 44 | import java.util.HashSet; 45 | import java.util.Set; 46 | import java.util.zip.ZipEntry; 47 | import javax.swing.text.JTextComponent; 48 | 49 | /** 50 | * 51 | * @author junichi11 52 | */ 53 | public class WPZipEntryFilter implements ZipEntryFilter { 54 | 55 | private JTextComponent component = null; 56 | private static final Set TOP_DIRECTORIES = new HashSet<>(); 57 | 58 | static { 59 | TOP_DIRECTORIES.add("wp-admin"); // NOI18N 60 | TOP_DIRECTORIES.add("wp-content"); // NOI18N 61 | TOP_DIRECTORIES.add("wp-includes"); // NOI18N 62 | } 63 | 64 | public WPZipEntryFilter() { 65 | } 66 | 67 | public WPZipEntryFilter(JTextComponent component) { 68 | this.component = component; 69 | } 70 | 71 | /** 72 | * Check whether unzip for ZipEntry. 73 | * 74 | * @param entry 75 | * @return true if unzip the file, otherwize false. 76 | */ 77 | @Override 78 | public boolean accept(ZipEntry entry) { 79 | String name = entry.getName(); 80 | String[] splitPath = splitPath(name); 81 | int length = splitPath.length; 82 | 83 | if (length == 1 && entry.isDirectory()) { 84 | return false; 85 | } 86 | 87 | return true; 88 | } 89 | 90 | /** 91 | * Get path of ZipEntry. 92 | * 93 | * @param entry 94 | * @return 95 | */ 96 | @Override 97 | public String getPath(ZipEntry entry) { 98 | String path = entry.getName(); 99 | String[] splitPath = splitPath(path); 100 | String topDirectory = splitPath[0]; 101 | if (splitPath.length == 1 || TOP_DIRECTORIES.contains(topDirectory)) { 102 | return path; 103 | } 104 | return path.replaceFirst(topDirectory + "/", ""); // NOI18N 105 | } 106 | 107 | /** 108 | * Set text to JTextComponent. e.g. display the file path on the 109 | * JTextComponent. 110 | * 111 | * @param text 112 | */ 113 | @Override 114 | public void setText(String text) { 115 | if (component != null) { 116 | component.setText(text); 117 | } 118 | } 119 | 120 | /** 121 | * Split path by "/". 122 | * 123 | * @param path 124 | * @return 125 | */ 126 | private String[] splitPath(String path) { 127 | return path.split("/"); // NOI18N 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/util/WordPressUnzipException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | */ 40 | package org.netbeans.modules.php.wordpress.util; 41 | 42 | /** 43 | * 44 | * @author junichi11 45 | */ 46 | public class WordPressUnzipException extends Exception { 47 | 48 | private static final long serialVersionUID = 1607655567611796935L; 49 | 50 | /** 51 | * Creates a new instance of WordPressUnzipException without 52 | * detail message. 53 | */ 54 | public WordPressUnzipException() { 55 | } 56 | 57 | /** 58 | * Constructs an instance of WordPressUnzipException with the 59 | * specified detail message. 60 | * 61 | * @param msg the detail message. 62 | */ 63 | public WordPressUnzipException(String msg) { 64 | super(msg); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/util/ZipEntryFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.util; 43 | 44 | import java.util.zip.ZipEntry; 45 | 46 | /** 47 | * 48 | * @author junichi11 49 | */ 50 | public interface ZipEntryFilter { 51 | 52 | /** 53 | * Check whether accept ZipEntry. If you don't need the ZipEntry, return 54 | * false. 55 | * 56 | * @param entry 57 | * @return 58 | */ 59 | public boolean accept(ZipEntry entry); 60 | 61 | /** 62 | * Get path for unzip. e.g. Original path is sample/foo/bar/moge.php. If you 63 | * would like to get /foo/bar/moge.php, return it. i.e. You can change the 64 | * path for unzipping. 65 | * 66 | * @param entry 67 | * @return 68 | */ 69 | public String getPath(ZipEntry entry); 70 | 71 | /** 72 | * For example, set text for JTextComponent. 73 | * 74 | * @param text 75 | */ 76 | public void setText(String text); 77 | 78 | public class DefaultZipEntryFilter implements ZipEntryFilter { 79 | 80 | @Override 81 | public boolean accept(ZipEntry entry) { 82 | String name = entry.getName(); 83 | String[] splits = name.split("/"); // NOI18N 84 | if (splits.length == 1 && entry.isDirectory()) { 85 | return false; 86 | } 87 | return true; 88 | } 89 | 90 | @Override 91 | public String getPath(ZipEntry entry) { 92 | String name = entry.getName(); 93 | String[] splits = name.split("/"); // NOI18N 94 | String topDirectory = splits[0]; 95 | 96 | return name.replace(topDirectory + "/", ""); // NOI18N 97 | } 98 | 99 | @Override 100 | public void setText(String text) { 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/validators/WordPressCustomizerValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.validators; 43 | 44 | import org.netbeans.api.annotations.common.NonNull; 45 | import org.netbeans.modules.php.api.phpmodule.PhpModule; 46 | import org.netbeans.modules.php.api.util.StringUtils; 47 | import org.netbeans.modules.php.api.validation.ValidationResult; 48 | import org.openide.filesystems.FileObject; 49 | import org.openide.util.NbBundle; 50 | 51 | /** 52 | * 53 | * @author junichi11 54 | */ 55 | public final class WordPressCustomizerValidator { 56 | 57 | private final ValidationResult result = new ValidationResult(); 58 | 59 | @NbBundle.Messages({ 60 | "# {0} - directory name", 61 | "WordPressCustomizerValidator.wordpress.dir.invalid=Existing {0} directory name must be set.", 62 | "WordPressCustomizerValidator.wordpress.source.dir.invalid=Project might be broken...", 63 | "WordPressCustomizerValidator.wordpress.content.name.contains.shash=The name must not contain slash." 64 | }) 65 | public WordPressCustomizerValidator validateWpContent(@NonNull PhpModule phpModule, FileObject wordPressRoot, String name, FileObject wpContentDirectory) { 66 | FileObject sourceDirectory = phpModule.getSourceDirectory(); 67 | if (sourceDirectory == null) { 68 | result.addWarning(new ValidationResult.Message("wordpress.dir", Bundle.WordPressCustomizerValidator_wordpress_source_dir_invalid())); // NOI18N 69 | return this; 70 | } 71 | 72 | if (wordPressRoot == null) { 73 | result.addWarning(new ValidationResult.Message("wordpress.dir", Bundle.WordPressCustomizerValidator_wordpress_dir_invalid("WordPress Root"))); // NOI18N 74 | return this; 75 | } 76 | 77 | if (wpContentDirectory == null) { 78 | FileObject wpContent = wordPressRoot.getFileObject(name); 79 | if (wpContent == null 80 | || !wpContent.isFolder() 81 | || StringUtils.isEmpty(name)) { 82 | result.addWarning(new ValidationResult.Message("wordpress.content.name", Bundle.WordPressCustomizerValidator_wordpress_dir_invalid("content"))); // NOI18N 83 | return this; 84 | } 85 | 86 | if (name.contains("/")) { // NOI18N 87 | result.addWarning(new ValidationResult.Message("wordpress.content.name.slash", Bundle.WordPressCustomizerValidator_wordpress_content_name_contains_shash())); // NOI18N 88 | return this; 89 | } 90 | } else { 91 | 92 | } 93 | 94 | return this; 95 | } 96 | 97 | public WordPressCustomizerValidator validateWordPressRootDirectory(@NonNull PhpModule phpModule, @NonNull String path) { 98 | return validateDirectory(phpModule, path, "WordPress Root"); // NOI18N 99 | } 100 | 101 | public WordPressCustomizerValidator validatePluginsDirectory(@NonNull PhpModule phpModule, @NonNull String path) { 102 | return validateDirectory(phpModule, path, "plugins"); // NOI18N 103 | } 104 | 105 | public WordPressCustomizerValidator validateThemesDirectory(@NonNull PhpModule phpModule, @NonNull String path) { 106 | return validateDirectory(phpModule, path, "themes"); // NOI18N 107 | } 108 | 109 | public WordPressCustomizerValidator validateWpContentDirectory(@NonNull PhpModule phpModule, @NonNull String path) { 110 | if (path.isEmpty()) { 111 | return this; 112 | } 113 | return validateDirectory(phpModule, path, "wp-content"); // NOI18N 114 | } 115 | 116 | private WordPressCustomizerValidator validateDirectory(PhpModule phpModule, String path, String dirname) { 117 | FileObject sourceDirectory = phpModule.getSourceDirectory(); 118 | if (sourceDirectory == null) { 119 | result.addWarning(new ValidationResult.Message("wordpress.dir", Bundle.WordPressCustomizerValidator_wordpress_source_dir_invalid())); // NOI18N 120 | return this; 121 | } 122 | 123 | FileObject targetDirectory = sourceDirectory.getFileObject(path); 124 | if (targetDirectory == null) { 125 | result.addWarning(new ValidationResult.Message("wordpress.dir", Bundle.WordPressCustomizerValidator_wordpress_dir_invalid(dirname))); 126 | } 127 | return this; 128 | } 129 | 130 | public ValidationResult getResult() { 131 | return result; 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/validators/WordPressDirectoryNameValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2014 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2014 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.validators; 43 | 44 | import java.util.List; 45 | import org.netbeans.modules.php.api.util.StringUtils; 46 | import org.netbeans.modules.php.api.validation.ValidationResult; 47 | import org.openide.util.NbBundle; 48 | 49 | /** 50 | * 51 | * @author junichi11 52 | */ 53 | public final class WordPressDirectoryNameValidator { 54 | 55 | private final ValidationResult result = new ValidationResult(); 56 | private static final String DIRECTORY_NAME_REGEX = "\\A[-.a-zA-Z0-9_]+\\z"; // NOI18N 57 | 58 | @NbBundle.Messages("WordPressDirectoryNameValidator.invalid.name=Please use alphanumeric, '-', '.' and '_'.") 59 | public WordPressDirectoryNameValidator validateName(String directoryName) { 60 | if (StringUtils.isEmpty(directoryName) || !directoryName.matches(DIRECTORY_NAME_REGEX)) { 61 | result.addWarning(new ValidationResult.Message("dir.name", Bundle.WordPressDirectoryNameValidator_invalid_name())); // NOI18N 62 | } 63 | return this; 64 | } 65 | 66 | @NbBundle.Messages("WordPressDirectoryNameValidator.existing.name=Child name already exists.") 67 | public WordPressDirectoryNameValidator validateExistingName(String directoryName, List exstingNames) { 68 | if (exstingNames.contains(directoryName)) { 69 | result.addWarning(new ValidationResult.Message("dir.name", Bundle.WordPressDirectoryNameValidator_existing_name())); // NOI18N 70 | } 71 | return this; 72 | } 73 | 74 | public ValidationResult getResult() { 75 | return result; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/validators/WordPressModuleValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2014 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2014 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.validators; 43 | 44 | import org.netbeans.api.annotations.common.NonNull; 45 | import org.netbeans.modules.php.api.validation.ValidationResult; 46 | import static org.netbeans.modules.php.wordpress.WordPressPhpProvider.WP_DIRS; 47 | import org.openide.filesystems.FileObject; 48 | import org.openide.util.NbBundle; 49 | 50 | /** 51 | * 52 | * @author junichi11 53 | */ 54 | public class WordPressModuleValidator { 55 | 56 | private final ValidationResult result = new ValidationResult(); 57 | 58 | @NbBundle.Messages({ 59 | "WordPressModuleValidator.core.dir.invalid=WordPress directories don't exit." 60 | }) 61 | public WordPressModuleValidator validateWordPressDirectories(@NonNull FileObject wordPressRoot, @NonNull String customContentName, FileObject wpContentDirectory) { 62 | for (String dir : WP_DIRS) { 63 | FileObject fileObject = wordPressRoot.getFileObject(dir); 64 | if (fileObject == null) { 65 | result.addWarning(new ValidationResult.Message("wp.dir", Bundle.WordPressModuleValidator_core_dir_invalid())); // NOI18N 66 | } 67 | } 68 | 69 | // content name 70 | FileObject content = wordPressRoot.getFileObject(customContentName); 71 | if (content == null && wpContentDirectory == null) { 72 | result.addWarning(new ValidationResult.Message("wp.dir", Bundle.WordPressModuleValidator_core_dir_invalid())); // NOI18N 73 | } 74 | 75 | return this; 76 | } 77 | 78 | public ValidationResult getResult() { 79 | return result; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/wpapis/WordPressApi.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.wpapis; 43 | 44 | import java.io.IOException; 45 | import java.io.InputStream; 46 | import java.net.URL; 47 | 48 | /** 49 | * 50 | * @author junichi11 51 | */ 52 | public abstract class WordPressApi { 53 | 54 | public abstract void parse() throws IOException; 55 | 56 | public abstract String getUrl(); 57 | 58 | public InputStream openStream() throws IOException { 59 | URL url = new URL(getUrl()); 60 | return url.openStream(); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/org/netbeans/modules/php/wordpress/wpapis/WordPressVersionCheckApi.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.wpapis; 43 | 44 | import java.io.IOException; 45 | import java.io.InputStream; 46 | import java.io.InputStreamReader; 47 | import java.util.logging.Level; 48 | import java.util.logging.Logger; 49 | import org.json.simple.JSONArray; 50 | import org.json.simple.JSONObject; 51 | import org.json.simple.JSONValue; 52 | import org.netbeans.modules.php.api.util.StringUtils; 53 | import org.netbeans.modules.php.wordpress.ui.options.WordPressOptions; 54 | import org.netbeans.modules.php.wordpress.util.Charset; 55 | 56 | public class WordPressVersionCheckApi extends WordPressApi { 57 | 58 | private final String locale; 59 | private String version; 60 | private String download; 61 | private String phpVersion; 62 | private String mysqlVersion; 63 | private static final String VERSION_CHECK_17_API = "http://api.wordpress.org/core/version-check/1.7"; // NOI18N 64 | private static final String VERSION_CHECK_LOCALE_PARAM = "?locale=%s"; // NOI18N 65 | private static final Logger LOGGER = Logger.getLogger(WordPressVersionCheckApi.class.getName()); 66 | 67 | public WordPressVersionCheckApi() { 68 | this.locale = WordPressOptions.getInstance().getWpLocale(); 69 | } 70 | 71 | public WordPressVersionCheckApi(String locale) { 72 | this.locale = locale; 73 | } 74 | 75 | @Override 76 | public String getUrl() { 77 | StringBuilder sb = new StringBuilder(); 78 | sb.append(VERSION_CHECK_17_API); 79 | if (!StringUtils.isEmpty(locale)) { 80 | sb.append(String.format(VERSION_CHECK_LOCALE_PARAM, locale)); 81 | } 82 | return sb.toString(); 83 | } 84 | 85 | @Override 86 | public void parse() throws IOException { 87 | try (InputStream inputStream = openStream()) { 88 | // get json 89 | JSONObject jsonObject = (JSONObject) JSONValue.parse(new InputStreamReader(inputStream, Charset.UTF8)); 90 | if (jsonObject == null) { 91 | LOGGER.log(Level.INFO, "Can't get json for version check information."); // NOI18N 92 | return; 93 | } 94 | JSONArray offers = (JSONArray) jsonObject.get("offers"); // NOI18N 95 | 96 | // get version and locale 97 | String upgradeLocale; 98 | for (Object offer : offers) { 99 | JSONObject object = (JSONObject) offer; 100 | upgradeLocale = object.get("locale").toString(); // NOI18N 101 | version = object.get("version").toString(); // NOI18N 102 | download = object.get("download").toString(); // NOI18N 103 | phpVersion = object.get("php_version").toString(); // NOI18N 104 | mysqlVersion = object.get("mysql_version").toString(); // NOI18N 105 | if (StringUtils.isEmpty(this.locale)) { 106 | return; 107 | } 108 | if (upgradeLocale.equals(this.locale)) { 109 | return; 110 | } 111 | } 112 | } 113 | 114 | // not found locale 115 | LOGGER.log(Level.WARNING, "Not found : specific locale data"); 116 | reset(); 117 | } 118 | 119 | private void reset() { 120 | this.version = null; 121 | this.download = null; 122 | this.phpVersion = null; 123 | this.mysqlVersion = null; 124 | } 125 | 126 | public String getLocale() { 127 | return locale; 128 | } 129 | 130 | public String getVersion() { 131 | return version; 132 | } 133 | 134 | public String getDownload() { 135 | return download; 136 | } 137 | 138 | public String getPhpVersion() { 139 | return phpVersion; 140 | } 141 | 142 | public String getMysqlVersion() { 143 | return mysqlVersion; 144 | } 145 | 146 | } 147 | -------------------------------------------------------------------------------- /test/unit/src/org/netbeans/modules/php/wordpress/util/UnderscoresUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright 2013 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * Oracle and Java are registered trademarks of Oracle and/or its affiliates. 7 | * Other names may be trademarks of their respective owners. 8 | * 9 | * The contents of this file are subject to the terms of either the GNU 10 | * General Public License Version 2 only ("GPL") or the Common 11 | * Development and Distribution License("CDDL") (collectively, the 12 | * "License"). You may not use this file except in compliance with the 13 | * License. You can obtain a copy of the License at 14 | * http://www.netbeans.org/cddl-gplv2.html 15 | * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the 16 | * specific language governing permissions and limitations under the 17 | * License. When distributing the software, include this License Header 18 | * Notice in each file and include the License file at 19 | * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this 20 | * particular file as subject to the "Classpath" exception as provided 21 | * by Oracle in the GPL Version 2 section of the License file that 22 | * accompanied this code. If applicable, add the following below the 23 | * License Header, with the fields enclosed by brackets [] replaced by 24 | * your own identifying information: 25 | * "Portions Copyrighted [year] [name of copyright owner]" 26 | * 27 | * If you wish your version of this file to be governed by only the CDDL 28 | * or only the GPL Version 2, indicate your decision by adding 29 | * "[Contributor] elects to include this software in this distribution 30 | * under the [CDDL or GPL Version 2] license." If you do not indicate a 31 | * single choice of license, a recipient has the option to distribute 32 | * your version of this file under either the CDDL, the GPL Version 2 or 33 | * to extend the choice of license to its licensees as provided above. 34 | * However, if you add GPL Version 2 code and therefore, elected the GPL 35 | * Version 2 license, then the option applies only if the new code is 36 | * made subject to such option by the copyright holder. 37 | * 38 | * Contributor(s): 39 | * 40 | * Portions Copyrighted 2013 Sun Microsystems, Inc. 41 | */ 42 | package org.netbeans.modules.php.wordpress.util; 43 | 44 | import org.junit.Test; 45 | import org.netbeans.junit.NbTestCase; 46 | 47 | /** 48 | * 49 | * @author junichi11 50 | */ 51 | public class UnderscoresUtilsTest extends NbTestCase { 52 | 53 | public UnderscoresUtilsTest(String name) { 54 | super(name); 55 | } 56 | 57 | /** 58 | * Test of toFolderName method, of class UnderscoresUtils. 59 | */ 60 | @Test 61 | public void testToFolderName() { 62 | assertEquals("name", UnderscoresUtils.toFolderName("name")); 63 | assertEquals("name", UnderscoresUtils.toFolderName("Name")); 64 | assertEquals("themename", UnderscoresUtils.toFolderName("ThemeName")); 65 | assertEquals("theme-name", UnderscoresUtils.toFolderName("Theme Name")); 66 | assertEquals("theme-name", UnderscoresUtils.toFolderName("Theme Name")); 67 | assertEquals("theme-name", UnderscoresUtils.toFolderName("Theme-Name")); 68 | assertEquals("theme--name", UnderscoresUtils.toFolderName("Theme--Name")); 69 | assertEquals("theme-name", UnderscoresUtils.toFolderName("Theme.Name")); 70 | assertEquals("theme-name", UnderscoresUtils.toFolderName("Theme..Name")); 71 | } 72 | 73 | /** 74 | * Test of toFunctionName method, of class UnderscoresUtils. 75 | */ 76 | @Test 77 | public void testToFunctionName() { 78 | assertEquals("name_", UnderscoresUtils.toFunctionName("name")); 79 | assertEquals("name_", UnderscoresUtils.toFunctionName("Name")); 80 | assertEquals("themename_", UnderscoresUtils.toFunctionName("ThemeName")); 81 | assertEquals("theme_name_", UnderscoresUtils.toFunctionName("Theme Name")); 82 | assertEquals("theme_name_", UnderscoresUtils.toFunctionName("Theme Name")); 83 | assertEquals("theme_name_", UnderscoresUtils.toFunctionName("Theme-Name")); 84 | assertEquals("theme_name_", UnderscoresUtils.toFunctionName("Theme---Name")); 85 | assertEquals("theme_name_", UnderscoresUtils.toFunctionName("Theme.Name")); 86 | assertEquals("theme_name_", UnderscoresUtils.toFunctionName("Theme..Name")); 87 | } 88 | 89 | /** 90 | * Test of toTextDomain method, of class UnderscoresUtils. 91 | */ 92 | @Test 93 | public void testToTextDomain() { 94 | assertEquals("name", UnderscoresUtils.toTextDomain("name")); 95 | assertEquals("name", UnderscoresUtils.toTextDomain("Name")); 96 | assertEquals("themename", UnderscoresUtils.toTextDomain("ThemeName")); 97 | assertEquals("theme_name", UnderscoresUtils.toTextDomain("Theme Name")); 98 | assertEquals("theme_name", UnderscoresUtils.toTextDomain("Theme Name")); 99 | assertEquals("theme_name", UnderscoresUtils.toTextDomain("Theme-Name")); 100 | assertEquals("theme_name", UnderscoresUtils.toTextDomain("Theme--Name")); 101 | assertEquals("theme_name", UnderscoresUtils.toTextDomain("Theme.Name")); 102 | assertEquals("theme_name", UnderscoresUtils.toTextDomain("Theme..Name")); 103 | } 104 | } 105 | --------------------------------------------------------------------------------