Changeset 3241 for plugins/licenseBootstrap
- Timestamp:
- 10/28/13 13:13:35 (10 years ago)
- Location:
- plugins/licenseBootstrap
- Files:
-
- 7 added
- 2 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/licenseBootstrap/LICENSE
r1561 r3241 1 GNU GENERAL PUBLIC LICENSE 2 Version 2, June 1991 1 This file is part of %module_id%, a %module_type% for Dotclear 2. 3 2 4 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 Everyone is permitted to copy and distribute verbatim copies 7 of this license document, but changing it is not allowed. 3 Copyright (c) %year% %user_cn% and contributors 4 %user_email% 8 5 9 Preamble 10 11 The licenses for most software are designed to take away your 12 freedom to share and change it. By contrast, the GNU General Public 13 License is intended to guarantee your freedom to share and change free 14 software--to make sure the software is free for all its users. This 15 General Public License applies to most of the Free Software 16 Foundation's software and to any other program whose authors commit to 17 using it. (Some other Free Software Foundation software is covered by 18 the GNU Lesser General Public License instead.) You can apply it to 19 your programs, too. 20 21 When we speak of free software, we are referring to freedom, not 22 price. Our General Public Licenses are designed to make sure that you 23 have the freedom to distribute copies of free software (and charge for 24 this service if you wish), that you receive source code or can get it 25 if you want it, that you can change the software or use pieces of it 26 in new free programs; and that you know you can do these things. 27 28 To protect your rights, we need to make restrictions that forbid 29 anyone to deny you these rights or to ask you to surrender the rights. 30 These restrictions translate to certain responsibilities for you if you 31 distribute copies of the software, or if you modify it. 32 33 For example, if you distribute copies of such a program, whether 34 gratis or for a fee, you must give the recipients all the rights that 35 you have. You must make sure that they, too, receive or can get the 36 source code. And you must show them these terms so they know their 37 rights. 38 39 We protect your rights with two steps: (1) copyright the software, and 40 (2) offer you this license which gives you legal permission to copy, 41 distribute and/or modify the software. 42 43 Also, for each author's protection and ours, we want to make certain 44 that everyone understands that there is no warranty for this free 45 software. If the software is modified by someone else and passed on, we 46 want its recipients to know that what they have is not the original, so 47 that any problems introduced by others will not reflect on the original 48 authors' reputations. 49 50 Finally, any free program is threatened constantly by software 51 patents. We wish to avoid the danger that redistributors of a free 52 program will individually obtain patent licenses, in effect making the 53 program proprietary. To prevent this, we have made it clear that any 54 patent must be licensed for everyone's free use or not licensed at all. 55 56 The precise terms and conditions for copying, distribution and 57 modification follow. 58 59 GNU GENERAL PUBLIC LICENSE 60 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 62 0. This License applies to any program or other work which contains 63 a notice placed by the copyright holder saying it may be distributed 64 under the terms of this General Public License. The "Program", below, 65 refers to any such program or work, and a "work based on the Program" 66 means either the Program or any derivative work under copyright law: 67 that is to say, a work containing the Program or a portion of it, 68 either verbatim or with modifications and/or translated into another 69 language. (Hereinafter, translation is included without limitation in 70 the term "modification".) Each licensee is addressed as "you". 71 72 Activities other than copying, distribution and modification are not 73 covered by this License; they are outside its scope. The act of 74 running the Program is not restricted, and the output from the Program 75 is covered only if its contents constitute a work based on the 76 Program (independent of having been made by running the Program). 77 Whether that is true depends on what the Program does. 78 79 1. You may copy and distribute verbatim copies of the Program's 80 source code as you receive it, in any medium, provided that you 81 conspicuously and appropriately publish on each copy an appropriate 82 copyright notice and disclaimer of warranty; keep intact all the 83 notices that refer to this License and to the absence of any warranty; 84 and give any other recipients of the Program a copy of this License 85 along with the Program. 86 87 You may charge a fee for the physical act of transferring a copy, and 88 you may at your option offer warranty protection in exchange for a fee. 89 90 2. You may modify your copy or copies of the Program or any portion 91 of it, thus forming a work based on the Program, and copy and 92 distribute such modifications or work under the terms of Section 1 93 above, provided that you also meet all of these conditions: 94 95 a) You must cause the modified files to carry prominent notices 96 stating that you changed the files and the date of any change. 97 98 b) You must cause any work that you distribute or publish, that in 99 whole or in part contains or is derived from the Program or any 100 part thereof, to be licensed as a whole at no charge to all third 101 parties under the terms of this License. 102 103 c) If the modified program normally reads commands interactively 104 when run, you must cause it, when started running for such 105 interactive use in the most ordinary way, to print or display an 106 announcement including an appropriate copyright notice and a 107 notice that there is no warranty (or else, saying that you provide 108 a warranty) and that users may redistribute the program under 109 these conditions, and telling the user how to view a copy of this 110 License. (Exception: if the Program itself is interactive but 111 does not normally print such an announcement, your work based on 112 the Program is not required to print an announcement.) 113 114 These requirements apply to the modified work as a whole. If 115 identifiable sections of that work are not derived from the Program, 116 and can be reasonably considered independent and separate works in 117 themselves, then this License, and its terms, do not apply to those 118 sections when you distribute them as separate works. But when you 119 distribute the same sections as part of a whole which is a work based 120 on the Program, the distribution of the whole must be on the terms of 121 this License, whose permissions for other licensees extend to the 122 entire whole, and thus to each and every part regardless of who wrote it. 123 124 Thus, it is not the intent of this section to claim rights or contest 125 your rights to work written entirely by you; rather, the intent is to 126 exercise the right to control the distribution of derivative or 127 collective works based on the Program. 128 129 In addition, mere aggregation of another work not based on the Program 130 with the Program (or with a work based on the Program) on a volume of 131 a storage or distribution medium does not bring the other work under 132 the scope of this License. 133 134 3. You may copy and distribute the Program (or a work based on it, 135 under Section 2) in object code or executable form under the terms of 136 Sections 1 and 2 above provided that you also do one of the following: 137 138 a) Accompany it with the complete corresponding machine-readable 139 source code, which must be distributed under the terms of Sections 140 1 and 2 above on a medium customarily used for software interchange; or, 141 142 b) Accompany it with a written offer, valid for at least three 143 years, to give any third party, for a charge no more than your 144 cost of physically performing source distribution, a complete 145 machine-readable copy of the corresponding source code, to be 146 distributed under the terms of Sections 1 and 2 above on a medium 147 customarily used for software interchange; or, 148 149 c) Accompany it with the information you received as to the offer 150 to distribute corresponding source code. (This alternative is 151 allowed only for noncommercial distribution and only if you 152 received the program in object code or executable form with such 153 an offer, in accord with Subsection b above.) 154 155 The source code for a work means the preferred form of the work for 156 making modifications to it. For an executable work, complete source 157 code means all the source code for all modules it contains, plus any 158 associated interface definition files, plus the scripts used to 159 control compilation and installation of the executable. However, as a 160 special exception, the source code distributed need not include 161 anything that is normally distributed (in either source or binary 162 form) with the major components (compiler, kernel, and so on) of the 163 operating system on which the executable runs, unless that component 164 itself accompanies the executable. 165 166 If distribution of executable or object code is made by offering 167 access to copy from a designated place, then offering equivalent 168 access to copy the source code from the same place counts as 169 distribution of the source code, even though third parties are not 170 compelled to copy the source along with the object code. 171 172 4. You may not copy, modify, sublicense, or distribute the Program 173 except as expressly provided under this License. Any attempt 174 otherwise to copy, modify, sublicense or distribute the Program is 175 void, and will automatically terminate your rights under this License. 176 However, parties who have received copies, or rights, from you under 177 this License will not have their licenses terminated so long as such 178 parties remain in full compliance. 179 180 5. You are not required to accept this License, since you have not 181 signed it. However, nothing else grants you permission to modify or 182 distribute the Program or its derivative works. These actions are 183 prohibited by law if you do not accept this License. Therefore, by 184 modifying or distributing the Program (or any work based on the 185 Program), you indicate your acceptance of this License to do so, and 186 all its terms and conditions for copying, distributing or modifying 187 the Program or works based on it. 188 189 6. Each time you redistribute the Program (or any work based on the 190 Program), the recipient automatically receives a license from the 191 original licensor to copy, distribute or modify the Program subject to 192 these terms and conditions. You may not impose any further 193 restrictions on the recipients' exercise of the rights granted herein. 194 You are not responsible for enforcing compliance by third parties to 195 this License. 196 197 7. If, as a consequence of a court judgment or allegation of patent 198 infringement or for any other reason (not limited to patent issues), 199 conditions are imposed on you (whether by court order, agreement or 200 otherwise) that contradict the conditions of this License, they do not 201 excuse you from the conditions of this License. If you cannot 202 distribute so as to satisfy simultaneously your obligations under this 203 License and any other pertinent obligations, then as a consequence you 204 may not distribute the Program at all. For example, if a patent 205 license would not permit royalty-free redistribution of the Program by 206 all those who receive copies directly or indirectly through you, then 207 the only way you could satisfy both it and this License would be to 208 refrain entirely from distribution of the Program. 209 210 If any portion of this section is held invalid or unenforceable under 211 any particular circumstance, the balance of the section is intended to 212 apply and the section as a whole is intended to apply in other 213 circumstances. 214 215 It is not the purpose of this section to induce you to infringe any 216 patents or other property right claims or to contest validity of any 217 such claims; this section has the sole purpose of protecting the 218 integrity of the free software distribution system, which is 219 implemented by public license practices. Many people have made 220 generous contributions to the wide range of software distributed 221 through that system in reliance on consistent application of that 222 system; it is up to the author/donor to decide if he or she is willing 223 to distribute software through any other system and a licensee cannot 224 impose that choice. 225 226 This section is intended to make thoroughly clear what is believed to 227 be a consequence of the rest of this License. 228 229 8. If the distribution and/or use of the Program is restricted in 230 certain countries either by patents or by copyrighted interfaces, the 231 original copyright holder who places the Program under this License 232 may add an explicit geographical distribution limitation excluding 233 those countries, so that distribution is permitted only in or among 234 countries not thus excluded. In such case, this License incorporates 235 the limitation as if written in the body of this License. 236 237 9. The Free Software Foundation may publish revised and/or new versions 238 of the General Public License from time to time. Such new versions will 239 be similar in spirit to the present version, but may differ in detail to 240 address new problems or concerns. 241 242 Each version is given a distinguishing version number. If the Program 243 specifies a version number of this License which applies to it and "any 244 later version", you have the option of following the terms and conditions 245 either of that version or of any later version published by the Free 246 Software Foundation. If the Program does not specify a version number of 247 this License, you may choose any version ever published by the Free Software 248 Foundation. 249 250 10. If you wish to incorporate parts of the Program into other free 251 programs whose distribution conditions are different, write to the author 252 to ask for permission. For software which is copyrighted by the Free 253 Software Foundation, write to the Free Software Foundation; we sometimes 254 make exceptions for this. Our decision will be guided by the two goals 255 of preserving the free status of all derivatives of our free software and 256 of promoting the sharing and reuse of software generally. 257 258 NO WARRANTY 259 260 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 REPAIR OR CORRECTION. 269 270 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 POSSIBILITY OF SUCH DAMAGES. 279 280 END OF TERMS AND CONDITIONS 281 282 How to Apply These Terms to Your New Programs 283 284 If you develop a new program, and you want it to be of the greatest 285 possible use to the public, the best way to achieve this is to make it 286 free software which everyone can redistribute and change under these terms. 287 288 To do so, attach the following notices to the program. It is safest 289 to attach them to the start of each source file to most effectively 290 convey the exclusion of warranty; and each file should have at least 291 the "copyright" line and a pointer to where the full notice is found. 292 293 <one line to give the program's name and a brief idea of what it does.> 294 Copyright (C) <year> <name of author> 295 296 This program is free software; you can redistribute it and/or modify 297 it under the terms of the GNU General Public License as published by 298 the Free Software Foundation; either version 2 of the License, or 299 (at your option) any later version. 300 301 This program is distributed in the hope that it will be useful, 302 but WITHOUT ANY WARRANTY; without even the implied warranty of 303 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 GNU General Public License for more details. 305 306 You should have received a copy of the GNU General Public License along 307 with this program; if not, write to the Free Software Foundation, Inc., 308 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 310 Also add information on how to contact you by electronic and paper mail. 311 312 If the program is interactive, make it output a short notice like this 313 when it starts in an interactive mode: 314 315 Gnomovision version 69, Copyright (C) year name of author 316 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 This is free software, and you are welcome to redistribute it 318 under certain conditions; type `show c' for details. 319 320 The hypothetical commands `show w' and `show c' should show the appropriate 321 parts of the General Public License. Of course, the commands you use may 322 be called something other than `show w' and `show c'; they could even be 323 mouse-clicks or menu items--whatever suits your program. 324 325 You should also get your employer (if you work as a programmer) or your 326 school, if any, to sign a "copyright disclaimer" for the program, if 327 necessary. Here is a sample; alter the names: 328 329 Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 332 <signature of Ty Coon>, 1 April 1989 333 Ty Coon, President of Vice 334 335 This General Public License does not permit incorporating your program into 336 proprietary programs. If your program is a subroutine library, you may 337 consider it more useful to permit linking proprietary applications with the 338 library. If this is what you want to do, use the GNU Lesser General 339 Public License instead of this License. 6 Licensed under the GPL version 2.0 license. 7 A copy of this license is available in LICENSE file or at 8 http://www.gnu.org/licenses/old-licenses/gpl-2.0.html -
plugins/licenseBootstrap/_admin.php
r3129 r3241 13 13 # -- END LICENSE BLOCK ------------------------------------ 14 14 15 if (!defined('DC_CONTEXT_ADMIN')){return;} 15 if (!defined('DC_CONTEXT_ADMIN')) { 16 17 return null; 18 } 19 20 $core->blog->settings->addNamespace('licenseBootstrap'); 21 22 $core->addBehavior( 23 'adminDashboardFavorites', 24 array('licenseBootstrapBehaviors', 'adminDashboardFavorites') 25 ); 26 27 $core->addBehavior( 28 'packmanBeforeCreatePackage', 29 array('licenseBootstrapBehaviors', 'packmanBeforeCreatePackage') 30 ); 16 31 17 32 $_menu['Plugins']->addItem( … … 19 34 'plugin.php?p=licenseBootstrap', 20 35 'index.php?pf=licenseBootstrap/icon.png', 21 preg_match('/plugin.php\?p=licenseBootstrap(&.*)?$/',$_SERVER['REQUEST_URI']), 36 preg_match( 37 '/plugin.php\?p=licenseBootstrap(&.*)?$/', 38 $_SERVER['REQUEST_URI'] 39 ), 22 40 $core->auth->isSuperAdmin() 23 41 ); 24 ?> 42 43 class licenseBootstrapBehaviors 44 { 45 public static function adminDashboardFavorites($core, $favs) 46 { 47 $favs->register('licenseBootstrap', array( 48 'title' => __('License bootstrap'), 49 'url' => 'plugin.php?p=licenseBootstrap', 50 'small-icon' => 'index.php?pf=licenseBootstrap/icon.png', 51 'large-icon' => 'index.php?pf=licenseBootstrap/icon-big.png', 52 'permissions' => $core->auth->isSuperAdmin(), 53 'active_cb' => array( 54 'licenseBootstrapBehaviors', 55 'adminDashboardFavoritesActive' 56 ) 57 )); 58 } 59 60 public static function adminDashboardFavoritesActive($request, $params) 61 { 62 return $request == 'plugin.php' 63 && isset($params['p']) 64 && $params['p'] == 'licenseBootstrap'; 65 } 66 67 public static function packmanBeforeCreatePackage($core, $module, $a, $b, $c, $d) 68 { 69 licenseBootstrap::addLicense($core, $module); 70 } 71 } -
plugins/licenseBootstrap/_define.php
r3129 r3241 13 13 # -- END LICENSE BLOCK ------------------------------------ 14 14 15 if (!defined('DC_RC_PATH')){return;} 15 if (!defined('DC_RC_PATH')) { 16 17 return null; 18 } 16 19 17 20 $this->registerModule( 18 /* Name */ "License bootstrap", 19 /* Description*/ "Add license to your plugins and themes", 20 /* Author */ "JC Denis", 21 /* Version */ '2013.05.11', 22 /* Permissions */ null 21 /* Name */ 22 "License bootstrap", 23 /* Description*/ 24 "Add license to your plugins and themes", 25 /* Author */ 26 "Jean-Christian Denis", 27 /* Version */ 28 '2013.10.28', 29 /* Properties */ 30 array( 31 'permissions' => null, 32 'type' => 'plugin', 33 'dc_min' => '2.6', 34 'support' => 'http://jcd.lv?q=licenseBootstrap', 35 'details' => 'http://plugins.dotaddict.org/dc2/details/licenseBootstrap' 36 ) 23 37 ); 24 ?> -
plugins/licenseBootstrap/_install.php
r3129 r3241 13 13 # -- END LICENSE BLOCK ------------------------------------ 14 14 15 if (!defined('DC_CONTEXT_ADMIN')) {return;}15 if (!defined('DC_CONTEXT_ADMIN')) { 16 16 17 $rdc_version = '2.5-alpha'; 18 $new_version = $core->plugins->moduleInfo('licenseBootstrap','version'); 19 $old_version = $core->getVersion('licenseBootstrap'); 17 return null; 18 } 20 19 21 if (version_compare($old_version,$new_version,'>=')) return; 20 # -- Module specs -- 22 21 23 try 24 { 25 if (version_compare(str_replace("-r","-p",DC_VERSION),$rdc_version,'<')) { 26 throw new Exception(sprintf('%s requires Dotclear %s','licenseBootstrap',$rdc_version)); 22 $dc_min = '2.6'; 23 $mod_id = 'licenseBootstrap'; 24 $mod_conf = array( 25 array( 26 'overwrite', 27 'Overwrite existing licence', 28 false, 29 'boolean' 30 ), 31 array( 32 'write_full', 33 'Add complete licence file', 34 true, 35 'boolean' 36 ), 37 array( 38 'write_php', 39 'Write license into php files', 40 true, 41 'boolean' 42 ), 43 array( 44 'write_js', 45 'Write license into js files', 46 false, 47 'boolean' 48 ), 49 array( 50 'exclude_locales', 51 'Exclude locales from license', 52 true, 53 'boolean' 54 ), 55 array( 56 'license_name', 57 'License short name', 58 'gpl2', 59 'string' 60 ), 61 array( 62 'license_head', 63 'File header licence text', 64 licenseBootstrap::encode( 65 licenseBootstrap::getHead('gpl2') 66 ), 67 'string' 68 ), 69 array( 70 'behavior_packman', 71 'Add LicenceBootstrap to plugin pacKman', 72 false, 73 'boolean' 74 ) 75 ); 76 77 # -- Nothing to change below -- 78 79 try { 80 81 # Check module version 82 if (version_compare( 83 $core->getVersion($mod_id), 84 $core->plugins->moduleInfo($mod_id, 'version'), 85 '>=' 86 )) { 87 88 return null; 27 89 } 28 29 $default_license = 'gpl2';30 $default_exts = licenseBootstrap::getDefaultExtensions();31 $default_headers = licenseBootstrap::getDefaultLicenses();32 90 33 $core->blog->settings->addNamespace('licenseBootstrap'); 34 $core->blog->settings->licenseBootstrap->put('licensebootstrap_addfull',true,'boolean','Add complete licence file',false,true); 35 $core->blog->settings->licenseBootstrap->put('licensebootstrap_overwrite',false,'boolean','Overwrite existing licence',false,true); 36 $core->blog->settings->licenseBootstrap->put('licensebootstrap_license',$default_license,'string','default licence',false,true); 37 $core->blog->settings->licenseBootstrap->put('licensebootstrap_files_exts',licenseBootstrap::encode($default_exts),'string','List of files to include licenceEnable xiti',false,true); 38 $core->blog->settings->licenseBootstrap->put('licensebootstrap_licenses_headers',licenseBootstrap::encode($default_headers),'string','File header licence text',false,true); 39 $core->blog->settings->licenseBootstrap->put('licensebootstrap_exclusion','/(\/locales\/)/','string','Path to exlude',false,true); 40 $core->blog->settings->licenseBootstrap->put('licensebootstrap_packman_behavior',false,'boolean','Add LicenceBootstrap to plugin pacKman',false,true); 41 $core->blog->settings->licenseBootstrap->put('licensebootstrap_translater_behavior',false,'boolean','Add LicenceBootstrap to plugin translater',false,true); 91 # Check Dotclear version 92 if (!method_exists('dcUtils', 'versionsCompare') 93 || dcUtils::versionsCompare(DC_VERSION, $dc_min, '>', false)) { 94 throw new Exception(sprintf( 95 '%s requires Dotclear %s', $mod_id, $dc_min 96 )); 97 } 42 98 43 $core->setVersion('licenseBootstrap',$new_version); 99 # Set module settings 100 $core->blog->settings->addNamespace($mod_id); 101 foreach($mod_conf as $v) { 102 $core->blog->settings->{$mod_id}->put( 103 $v[0], $v[2], $v[3], $v[1], false, true 104 ); 105 } 106 107 # Set module version 108 $core->setVersion( 109 $mod_id, 110 $core->plugins->moduleInfo($mod_id, 'version') 111 ); 44 112 45 113 return true; 46 114 } 47 catch (Exception $e) 48 { 115 catch (Exception $e) { 49 116 $core->error->add($e->getMessage()); 117 118 return false; 50 119 } 51 return false;52 ?> -
plugins/licenseBootstrap/_prepend.php
r3129 r3241 13 13 # -- END LICENSE BLOCK ------------------------------------ 14 14 15 if (!defined('DC_RC_PATH')) {return;}15 if (!defined('DC_RC_PATH')) { 16 16 17 global $__autoload,$core; 17 return null; 18 } 18 19 19 if ($core->blog === null) return;20 $d = dirname(__FILE__).'/inc/'; 20 21 21 $__autoload['licenseBootstrap'] = dirname(__FILE__).'/inc/class.license.bootstrap.php'; 22 $__autoload['libLicenseBootstrap'] = dirname(__FILE__).'/inc/lib.license.bootstrap.index.php'; 23 24 $core->addBehavior('packmanBeforeCreatePackage',array('licenseBootstrap','packmanBeforeCreatePackage')); 25 $core->addBehavior('dcTranslaterAfterWriteLangFile',array('licenseBootstrap','dcTranslaterAfterWriteLangFile')); 26 ?> 22 $__autoload['licenseBootstrap'] = $d.'class.license.bootstrap.php'; 23 $__autoload['libLicenseBootstrap'] = $d.'lib.license.bootstrap.php'; -
plugins/licenseBootstrap/_uninstall.php
r3129 r3241 13 13 # -- END LICENSE BLOCK ------------------------------------ 14 14 15 if (!defined('DC_CONTEXT_ADMIN')){return;} 15 if (!defined('DC_CONTEXT_ADMIN')) { 16 17 return null; 18 } 19 20 $mod_id = 'pacKman'; 16 21 17 22 $this->addUserAction( 18 /* type */ 19 /* action */ 20 /* ns */ 'licenseBootstrap',21 /* desc ription */__('delete all settings')23 /* type */ 'settings', 24 /* action */ 'delete_all', 25 /* ns */ $mod_id, 26 /* desc */ __('delete all settings') 22 27 ); 23 28 24 29 $this->addUserAction( 25 /* type */ 26 /* action */ 27 /* ns */ 'licenseBootstrap',28 /* desc ription */__('delete plugin files')30 /* type */ 'plugins', 31 /* action */ 'delete', 32 /* ns */ $mod_id, 33 /* desc */ __('delete plugin files') 29 34 ); 30 35 31 36 $this->addDirectAction( 32 /* type */ 33 /* action */ 34 /* ns */ 'licenseBootstrap',35 /* desc ription */ sprintf(__('delete all %s settings'),'licenseBootstrap')37 /* type */ 'settings', 38 /* action */ 'delete_all', 39 /* ns */ $mod_id, 40 /* desc */ sprintf(__('delete all %s settings'), $mod_id) 36 41 ); 37 42 38 43 $this->addDirectAction( 39 /* type */ 40 /* action */ 41 /* ns */ 'licenseBootstrap',42 /* desc ription */ sprintf(__('delete %s plugin files'),'licenseBootstrap')44 /* type */ 'plugins', 45 /* action */ 'delete', 46 /* ns */ $mod_id, 47 /* desc */ sprintf(__('delete %s plugin files'), $mod_id) 43 48 ); 44 ?> -
plugins/licenseBootstrap/inc/class.license.bootstrap.php
r3129 r3241 13 13 # -- END LICENSE BLOCK ------------------------------------ 14 14 15 if (!defined('DC_CONTEXT_ADMIN')){return;} 15 if (!defined('DC_CONTEXT_ADMIN')) { 16 17 return null; 18 } 16 19 17 20 class licenseBootstrap 18 21 { 19 public $core; 20 public $extensions; 21 public $license; 22 public $head; 23 public $full; 24 public $addfull; 25 public $overwrite; 26 public $exclusion; 27 28 public function __construct($core,$extensions=null,$license=null,$head=null,$addfull=true,$overwrite=false,$exclusion='') 29 { 30 $this->core = $core; 31 $this->overwrite = (boolean) $overwrite; 32 $this->exclusion = (string) $exclusion; 33 $this->license = (string) $license; 34 35 $this->extensions = self::getDefaultExtensions($extensions); 36 $this->head = self::getDefaultLicenses('head',$license,$head); 37 $this->full = self::getDefaultLicenses('full',$license); 38 } 39 40 public function moduleInfo($type,$id) 41 { 42 $info = array(); 43 44 if ($type == 'plugin') 45 { 46 $modules = $this->core->plugins; 47 } 48 elseif ($type = 'theme') 49 { 50 $modules = new dcModules($core); 51 $modules->loadModules($this->core->blog->themes_path,null); 52 } 53 else 54 { 55 $type = ''; 56 } 57 58 if ($type && $modules->moduleExists($id)) 59 { 60 $info = $modules->getModules($id); 61 $info['user_cn'] = $this->core->auth->getInfo('user_cn'); 62 $info['user_name'] = $this->core->auth->getInfo('user_name'); 63 $info['user_email'] = $this->core->auth->getInfo('user_email'); 64 } 65 66 return $info; 67 } 68 69 public function writeModuleLicense($type,$id) 70 { 71 $info = $this->moduleInfo($type,$id); 72 73 # Try if root is writable 74 if (!isset($info['root']) || !is_writable($info['root'])) 75 { 76 throw new Exception('Failed to get module directory'); 77 } 78 $root = $info['root']; 79 80 # Get license text 81 $head = self::parseInfo($type,$id,$info,$this->head[$this->license]); 82 $full = self::parseInfo($type,$id,$info,$this->full[$this->license]); 83 84 # Get files from module root 85 $files = self::scandir($root); 86 if (empty($files)) 87 { 88 throw new Exception('Nothing to do'); 89 } 90 91 # Write full license file 92 if (!file_exists($root.'/LICENSE') || $overwrite) 93 { 94 files::putContent($root.'/LICENSE',$full); 95 } 96 97 # Write license header in files 98 foreach($files as $file) 99 { 100 if (!is_file($root.'/'.$file)) continue; 101 102 if (!empty($this->exclusion)) 103 { 104 if (preg_match($this->exclusion,$file)) continue; 105 } 106 107 $ext = files::getExtension($file) ; 108 $func = 'filesLicenseBootstrap::'.$ext.'File'; 109 if (!in_array($ext,$this->extensions) || !is_callable($func)) continue; 110 111 $content = file_get_contents($root.'/'.$file); 112 $content = call_user_func($func,$content,$head,$this->overwrite); 113 114 if (!empty($content)) 115 { 116 files::putContent($root.'/'.$file,$content); 117 } 118 } 119 return true; 120 } 121 122 public function addFileLicense($type,$id,$file,$content) 123 { 124 $info = $this->moduleInfo($type,$id); 125 $head = self::parseInfo($type,$id,$info,$this->head); 126 127 if (!empty($this->exclusion)) 128 { 129 if (preg_match($this->exclusion,$file)) return $content; 130 } 131 132 $ext = files::getExtension($file) ; 133 $func = 'filesLicenseBootstrap::'.$ext.'File'; 134 if (!in_array($ext,$this->extensions) || !is_callable($func)) return $content; 135 136 return call_user_func($func,$content,$head[$this->license],$this->overwrite); 137 } 138 139 public static function getDefaultExtensions($exts=null) 140 { 141 $default = array('php','js'); 142 if (null === $exts) $exts = $default; 143 elseif (!is_array($exts)) $exts = array($exts); 144 145 return array_intersect($default,$exts); 146 } 147 148 public static function getDefaultLicenses($type='head',$license=null,$content=null) 149 { 150 $rs = array(); 151 152 if ($license && $content) 153 { 154 $rs = array($license => $content); 155 } 156 157 if ($license && !$content) 158 { 159 $f = dirname(__FILE__).'/licenses/'.$license.'.'.$type.'.txt'; 160 if (file_exists($f)) 161 { 162 $rs = array($license => file_get_contents($f)); 163 } 164 } 165 166 if (!$license) 167 { 168 $files = files::scandir(dirname(__FILE__).'/licenses'); 169 foreach($files as $file) 170 { 171 if (preg_match('/^(.*?)\.'.$type.'\.txt$/',$file,$m)) 172 { 173 $rs[$m[1]] = file_get_contents(dirname(__FILE__).'/licenses/'.$m[0]); 22 protected static $licenses = array(); 23 24 /** 25 * Add license to a module. 26 * 27 * Note that you must check if module exists 28 * before calling this method. 29 * 30 * @param object $core dcCore instance 31 * @param array $module Module info 32 */ 33 public static function addLicense($core, $module) 34 { 35 $s = $core->blog->settings->licenseBootstrap; 36 37 # --BEHAVIOR-- licenseBootstrapBeforeAddLicense 38 $core->callBehavior( 39 'licenseBootstrapBeforeAddLicense', 40 $core, 41 $module 42 ); 43 44 if ($s->write_full) { 45 licenseBootstrap::writeFullContent( 46 $s->license_name, 47 $module, 48 $s->overwrite 49 ); 50 } 51 licenseBootstrap::writeHeadContent( 52 $s->license_name, 53 licenseBootstrap::decode($s->license_head), 54 $module, 55 $core->auth, 56 $s->overwrite, 57 $s->write_php, 58 $s->write_js, 59 $s->exclude_locales 60 ); 61 62 # --BEHAVIOR-- licenseBootstrapAfterAddLicense 63 $core->callBehavior( 64 'licenseBootstrapAfterAddLicense', 65 $core, 66 $module 67 ); 68 } 69 70 /** 71 * Get available licenses. 72 * 73 * @return array List of licenses names 74 */ 75 public static function getLicenses() 76 { 77 if (empty(licenseBootstrap::$licenses)) { 78 $file_reg = '/^([a-z0-9]+)\.head\.txt$/'; 79 $res = array(); 80 foreach (files::scandir(dirname(__FILE__).'/licenses/') as $file) { 81 if (preg_match($file_reg, $file, $matches)) { 82 $res[] = $matches[1]; 174 83 } 175 84 } 176 } 177 return $rs; 178 } 179 180 private function parseInfo($type,$id,$info,$text) 85 licenseBootstrap::$licenses = $res; 86 } 87 88 return licenseBootstrap::$licenses; 89 } 90 91 /** 92 * Get license name. 93 * 94 * Check requested license name and return existing one. 95 * 96 * @param string $name License name 97 * @return string License name 98 */ 99 public static function getName($name='gpl2') 100 { 101 return in_array($name, self::getLicenses()) ? $name : 'gpl2'; 102 } 103 104 /** 105 * Get license header. 106 * 107 * @param string $name License name 108 * @param string $content Header content 109 * @return string Header content 110 */ 111 public static function getHead($name='gpl2', $content='') 112 { 113 if (!in_array($name, self::getLicenses())) { 114 $name = 'gpl2'; 115 $content = ''; 116 } 117 118 return empty($content) ? 119 self::getContent($name, 'head') : $content; 120 } 121 122 /** 123 * Get full license. 124 * 125 * @param string $name License name 126 * @return string Full license content 127 */ 128 public static function getFull($name='gpl2') 129 { 130 return self::getContent($name, 'full'); 131 } 132 133 /** 134 * Get original license content. 135 * 136 * @param string $name License name 137 * @param string $part License part (head or full) 138 * @return string License content 139 */ 140 public static function getContent($name='gpl2', $part='head') 141 { 142 if (!in_array($name, self::getLicenses())) { 143 $name = 'gpl2'; 144 } 145 if (!in_array($part, array('head, full'))) { 146 $part = 'head'; 147 } 148 149 return file_get_contents( 150 dirname(__FILE__).'/licenses/'.$name.'.'.$part.'.txt' 151 ); 152 } 153 154 /** 155 * Write license block into module files headers 156 * 157 * @param string $name License name 158 * @param string $content License block content 159 * @param array $module Module info 160 * @param object $user dcAuth instance 161 * @param boolean $overwrite Overwrite existing license 162 * @param boolean $php Write license in PHP 163 * @param boolean $js Write license in JS 164 * @param boolean $locales Excludes locales folder 165 */ 166 public static function writeHeadContent($name, $content, $module, $user, $overwrite, $php, $js, $locales) 167 { 168 if (!isset($module['root']) || !is_writable($module['root'])) { 169 throw new Exception(); 170 } 171 172 $license = self::replaceInfo( 173 self::getHead($name, $content), 174 $module, 175 $user 176 ); 177 178 foreach(self::getModuleFiles($module['root']) as $file) { 179 180 if ($locales && preg_match('/(locales|libs)/', $file)) { 181 continue; 182 } 183 184 $path = $module['root'].'/'.$file; 185 $extension = files::getExtension($file); 186 187 if ($php && $extension == 'php') { 188 file_put_contents( 189 $file, 190 self::replacePhpContent( 191 file_get_contents($file), 192 $license, 193 $overwrite 194 ) 195 ); 196 } 197 elseif ($js && $extension == 'js') { 198 file_put_contents( 199 $file, 200 self::replaceJsContent( 201 file_get_contents($file), 202 $license, 203 $overwrite 204 ) 205 ); 206 } 207 } 208 } 209 210 /** 211 * Write full license file 212 * 213 * @param string $name License name 214 * @param array $module Module info 215 * @param boolean $overwrite Overwrite existing license 216 */ 217 public static function writeFullContent($name, $module, $overwrite) 218 { 219 if (!isset($module['root']) || !is_writable($module['root'])) { 220 throw new Exception(); 221 } 222 if (file_exists($module['root'].'/LICENSE') && !$overwrite) { 223 224 return null; 225 } 226 227 file_put_contents( 228 $module['root'].'/LICENSE', 229 self::getFull($name) 230 ); 231 } 232 233 /** 234 * Replace license block in PHP file 235 * 236 * @param string $content File content 237 * @param string $license License content 238 * @param boolean $overwrite Overwrite existing license 239 * @return string File content 240 */ 241 protected static function replacePhpContent($content, $license, $overwrite) 242 { 243 $clean = preg_replace( 244 '/((# -- BEGIN LICENSE BLOCK ([-]+))(.*?)'. 245 '(# -- END LICENSE BLOCK ([-]+))([\n|\r\n]+))/msi', 246 '', 247 $content 248 ); 249 250 if ($clean != $content && !$overwrite) { 251 252 return $content; 253 } 254 255 return preg_replace( 256 '/(\<\?php)/', 257 '<?php'. 258 "\r\n# -- BEGIN LICENSE BLOCK ----------------------------------\r\n". 259 "#\r\n". 260 '# '.str_replace("\n", "\n# ", trim($license)). 261 "\r\n#". 262 "\r\n# -- END LICENSE BLOCK ------------------------------------\r\n", 263 $clean, 264 1 265 ); 266 } 267 268 /** 269 * Replace license block in JS files 270 * 271 * @param string $content File content 272 * @param string $license License content 273 * @param boolean $overwrite Overwrite existing license 274 * @return string File content 275 */ 276 protected static function replaceJsContent($content, $license, $overwrite) 277 { 278 $clean = preg_replace( 279 '/((\/\* -- BEGIN LICENSE BLOCK ([-]+))(.*?)'. 280 '(\* -- END LICENSE BLOCK ([-]+)\*\/)([\n|\r\n]+))/msi', 281 '', 282 $content 283 ); 284 285 if ($clean != $content && !$overwrite) { 286 287 return $content; 288 } 289 290 return 291 "/* -- BEGIN LICENSE BLOCK ----------------------------------\r\n". 292 " *\r\n". 293 ' * '.str_replace("\n", "\n * ", trim($license)). 294 "\r\n *". 295 "\r\n * -- END LICENSE BLOCK ------------------------------------*/\r\n\r\n". 296 $clean; 297 } 298 299 /** 300 * Replace info in license 301 * 302 * @param string $content License content 303 * @param array $module Module info 304 * @param array $user User info 305 * @return string License content 306 */ 307 protected static function replaceInfo($content, $module, $user) 181 308 { 182 309 return str_replace( … … 189 316 '%user_cn%', 190 317 '%user_name%', 191 '%user_email%' 318 '%user_email%', 319 '%user_url%' 192 320 ), 193 321 array( 194 322 date('Y'), 195 $id, 196 $info['name'], 197 $info['author'], 198 $type, 199 $info['user_cn'], 200 $info['user_name'], 201 $info['user_email'] 323 $module['id'], 324 $module['name'], 325 $module['author'], 326 $module['type'], 327 $user->getInfo('user_cn'), 328 $user->getinfo('user_name'), 329 $user->getInfo('user_email'), 330 $user->getInfo('user_user') 202 331 ), 203 $text 204 ); 205 } 206 207 private static function scandir($path,$dir='',$res=array()) 332 $content 333 ); 334 } 335 336 /** 337 * Get list of module files 338 * 339 * @param string $path Path to scan 340 * @param string $dir Ignore 341 * @param array $res Ignore 342 * @return array List of files 343 */ 344 protected static function getModuleFiles($path, $dir='', $res=array()) 208 345 { 209 346 $path = path::real($path); 210 if (!is_dir($path) || !is_readable($path)) return array(); 347 if (!is_dir($path) || !is_readable($path)) { 348 349 return array(); 350 } 351 352 if (!$dir) { 353 $dir = $path; 354 } 211 355 212 356 $files = files::scandir($path); 213 357 214 foreach($files AS $file) 215 { 216 if ($file == '.' || $file == '..') continue; 217 218 if (is_dir($path.'/'.$file)) 219 { 220 $res[] = $file; 221 $res = self::scandir($path.'/'.$file,$dir.'/'.$file,$res); 222 } 223 else 224 { 358 foreach($files AS $file) { 359 if (substr($file, 0, 1) == '.') { 360 continue; 361 } 362 363 if (is_dir($path.'/'.$file)) { 364 $res = self::getModuleFiles( 365 $path.'/'.$file, $dir.'/'.$file, 366 $res 367 ); 368 } 369 else { 225 370 $res[] = empty($dir) ? $file : $dir.'/'.$file; 226 371 } 227 372 } 373 228 374 return $res; 229 375 } 230 376 231 377 public static function encode($a) 232 378 { … … 238 384 return unserialize(base64_decode($a)); 239 385 } 240 241 public static function packmanBeforeCreatePackage($info,$a,$b,$c,$d)242 {243 global $core;244 245 if (!$core->blog->settings->licenseBootstrap->licensebootstrap_packman_behavior) {246 return;247 }248 249 $addfull = (boolean) $core->blog->settings->licenseBootstrap->licensebootstrap_addfull;250 $overwrite = (boolean) $core->blog->settings->licenseBootstrap->licensebootstrap_overwrite;251 $exclusion = $core->blog->settings->licenseBootstrap->licensebootstrap_exclusion;252 253 $license = $core->blog->settings->licenseBootstrap->licensebootstrap_license;254 if (empty($license)) $license = 'gpl2';255 256 $exts = licenseBootstrap::decode($core->blog->settings->licenseBootstrap->licensebootstrap_files_exts);257 if (!is_array($exts)) $exts = self::getDefaultExtensions();258 259 $headers = licenseBootstrap::decode($core->blog->settings->licenseBootstrap->licensebootstrap_licenses_headers);260 if (!is_array($headers)) $headers = self::getDefaulLicenses();261 262 $license = new licenseBootstrap($core,$exts,$license,$headers[$license],$addfull,$overwrite,$exclusion);263 $license->writeModuleLicense($info['type'],$info['id']);264 }265 266 public static function dcTranslaterAfterWriteLangFile($f,$file,$content,$throw)267 {268 if (!$f) return;269 270 global $core;271 272 if (!$core->blog->settings->licenseBootstrap->licensebootstrap_translater_behavior) {273 return;274 }275 276 $id = '';277 $type = 'theme';278 $dir = path::real($file);279 280 # Is a plugin281 $plugins_roots = explode(PATH_SEPARATOR,DC_PLUGINS_ROOT);282 foreach($plugins_roots as $path)283 {284 $root = path::real($path);285 if ($root == substr($dir,0,strlen($root)))286 {287 $type = 'plugin';288 $reg = '/'.preg_quote($root,'/').'\/([^\/]+)\/(.*?)/';289 if (!preg_match($reg,$dir,$m))290 {291 if ($throw)292 {293 throw new Exception('Failed to retreive module id for adding license');294 }295 //return;296 }297 $id = $m[1];298 break;299 }300 }301 # Not a plugin try a theme302 if ($type == 'theme')303 {304 $path = $core->blog->themes_path;305 $root = path::real($path);306 if ($root == substr($dir,0,strlen($root)))307 {308 $reg = '/'.preg_quote($root,'/').'\/([^\/]+)\/(.*?)/';309 if (!preg_match($reg,$dir,$m))310 {311 if ($throw)312 {313 throw new Exception('Failed to retreive module id for adding license');314 }315 //return;316 }317 $id = $m[1];318 }319 }320 # Not a plugin nor theme321 if (empty($id)) return;322 323 $core->blog->settings->addNamespace('licenseBootstrap');324 325 $addfull = (boolean) $core->blog->settings->licenseBootstrap->licensebootstrap_addfull;326 $overwrite = (boolean) $core->blog->settings->licenseBootstrap->licensebootstrap_overwrite;327 $exclusion = $core->blog->settings->licenseBootstrap->licensebootstrap_exclusion;328 329 $license = $core->blog->settings->licenseBootstrap->licensebootstrap_license;330 if (empty($license)) $license = 'gpl2';331 332 $exts = licenseBootstrap::decode($core->blog->settings->licenseBootstrap->licensebootstrap_files_exts);333 if (!is_array($exts)) $exts = self::getDefaultExtensions();334 335 $headers = licenseBootstrap::decode($core->blog->settings->licenseBootstrap->licensebootstrap_licenses_headers);336 if (!is_array($headers)) $headers = self::getDefaultLicenses();337 338 $license = new licenseBootstrap($core,$exts,$license,$headers[$license],$addfull,$overwrite,$exclusion);339 $content = $license->addFileLicense($type,$id,$file,$content);340 341 files::putContent($file,$content);342 }343 386 } 344 345 class filesLicenseBootstrap346 {347 public static function phpFile($content,$license,$overwrite=false)348 {349 $c = preg_replace('/((# -- BEGIN LICENSE BLOCK ([-]+))(.*?)(# -- END LICENSE BLOCK ([-]+))([\n|\r\n]+))/msi','',$content);350 351 if ($c != $content && !$overwrite) return $content;352 $content = $c;353 354 $block =355 "\r\n# -- BEGIN LICENSE BLOCK ----------------------------------\r\n".356 "#\r\n".357 '# '.str_replace("\n","\n# ",$license).358 "\r\n#".359 "\r\n# -- END LICENSE BLOCK ------------------------------------\r\n";360 361 $content = preg_replace('/(\<\?php)/','<?php'.$block,$content,1);362 return $content;363 }364 365 public static function jsFile($content,$license,$overwrite=false)366 {367 $c = preg_replace('/((\/\* -- BEGIN LICENSE BLOCK ([-]+))(.*?)(\* -- END LICENSE BLOCK ([-]+)\*\/)([\n|\r\n]+))/msi','',$content);368 369 if ($c != $content && !$overwrite) return $content;370 $content = $c;371 372 $block =373 "/* -- BEGIN LICENSE BLOCK ----------------------------------\r\n".374 " *\r\n".375 ' * '.str_replace("\n","\n * ",$license).376 "\r\n *".377 "\r\n * -- END LICENSE BLOCK ------------------------------------*/\r\n\r\n";378 379 $content = $block.$content;380 381 return $content;382 }383 }384 ?> -
plugins/licenseBootstrap/inc/licenses/mit.head.txt
r1561 r3241 1 2 1 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 3 2 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -
plugins/licenseBootstrap/index.php
r3129 r3241 13 13 # -- END LICENSE BLOCK ------------------------------------ 14 14 15 if (!defined('DC_CONTEXT_ADMIN')){return;} 15 if (!defined('DC_CONTEXT_ADMIN')) { 16 17 return null; 18 } 19 16 20 dcPage::checkSuper(); 17 21 18 $default_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : 'setting'; 19 $section = isset($_REQUEST['section']) ? $_REQUEST['section'] : ''; 20 21 # Default lists 22 $default_exts = licenseBootstrap::getDefaultExtensions(); 23 $default_headers = licenseBootstrap::getDefaultLicenses(); 22 # Queries 23 $p_url = 'plugin.php?p=licenseBootstrap'; 24 $action = isset($_POST['action']) ? $_POST['action'] : ''; 25 $type = isset($_POST['type']) && in_array($_POST['type'], array('plugins','themes')) ? $_POST['type'] : ''; 24 26 25 27 # Settings 26 28 $core->blog->settings->addNamespace('licenseBootstrap'); 27 $addfull = (boolean) $core->blog->settings->licenseBootstrap->licensebootstrap_addfull; 28 $overwrite = (boolean) $core->blog->settings->licenseBootstrap->licensebootstrap_overwrite; 29 $license = $core->blog->settings->licenseBootstrap->licensebootstrap_license; 30 if (empty($license)) $license = 'gpl2'; 31 $files_exts = licenseBootstrap::decode($core->blog->settings->licenseBootstrap->licensebootstrap_files_exts); 32 if (!is_array($files_exts)) $files_exts = $default_exts; 33 $licenses_headers = licenseBootstrap::decode($core->blog->settings->licenseBootstrap->licensebootstrap_licenses_headers); 34 if (!is_array($licenses_headers)) $licenses_headers = array(); 35 $exclusion = $core->blog->settings->licenseBootstrap->licensebootstrap_exclusion; 36 $packman_behavior = $core->blog->settings->licenseBootstrap->licensebootstrap_packman_behavior; 37 $translater_behavior = $core->blog->settings->licenseBootstrap->licensebootstrap_translater_behavior; 29 $s = $core->blog->settings->licenseBootstrap; 38 30 31 # Modules 32 if (!isset($core->themes)) { 33 $core->themes = new dcThemes($core); 34 $core->themes->loadModules($core->blog->themes_path,null); 35 } 36 $themes = $core->themes; 37 $plugins = $core->plugins; 38 39 # Rights 40 $is_editable = 41 !empty($type) 42 && !empty($_POST['modules']) 43 && is_array($_POST['modules']); 44 45 # Actions 39 46 try 40 47 { 41 # Reset settings 42 if (isset($_POST['reset_settings'])) 43 { 44 $core->blog->settings->licenseBootstrap->put('licensebootstrap_addfull',true); 45 $core->blog->settings->licenseBootstrap->put('licensebootstrap_overwrite',false); 46 $core->blog->settings->licenseBootstrap->put('licensebootstrap_license','gpl2'); 47 $core->blog->settings->licenseBootstrap->put('licensebootstrap_files_exts',licenseBootstrap::encode($default_exts)); 48 $core->blog->settings->licenseBootstrap->put('licensebootstrap_licenses_headers',licenseBootstrap::encode($default_headers)); 49 $core->blog->settings->licenseBootstrap->put('licensebootstrap_exclusion',''); 50 $core->blog->settings->licenseBootstrap->put('licensebootstrap_packman_behavior',false); 51 $core->blog->settings->licenseBootstrap->put('licensebootstrap_translater_behavior',false); 52 53 http::redirect($p_url.'&tab=setting§ion='.$section.'&done=1'); 54 } 55 56 # Save settings 57 if (isset($_POST['save_settings'])) 58 { 59 $addfull = !empty($_POST['addfull']); 60 $overwrite = !empty($_POST['overwrite']); 61 $license = $_POST['license']; 62 $files_exts = is_array($_POST['files_exts']) ? $_POST['files_exts'] : array(); 63 $licenses_headers = is_array($_POST['licenses_headers']) ? $_POST['licenses_headers'] : array(); 64 $exclusion = $_POST['exclusion']; 65 $packman_behavior = !empty($_POST['packman_behavior']); 66 $translater_behavior = !empty($_POST['translater_behavior']); 67 68 $core->blog->settings->licenseBootstrap->put('licensebootstrap_addfull',$addfull); 69 $core->blog->settings->licenseBootstrap->put('licensebootstrap_overwrite',$overwrite); 70 $core->blog->settings->licenseBootstrap->put('licensebootstrap_license',$license); 71 $core->blog->settings->licenseBootstrap->put('licensebootstrap_files_exts',licenseBootstrap::encode($files_exts)); 72 $core->blog->settings->licenseBootstrap->put('licensebootstrap_licenses_headers',licenseBootstrap::encode($licenses_headers)); 73 $core->blog->settings->licenseBootstrap->put('licensebootstrap_exclusion',$exclusion); 74 $core->blog->settings->licenseBootstrap->put('licensebootstrap_packman_behavior',$packman_behavior); 75 $core->blog->settings->licenseBootstrap->put('licensebootstrap_translater_behavior',$translater_behavior); 76 77 http::redirect($p_url.'&tab=setting§ion='.$section.'&done=1'); 78 } 79 # Object 80 $LB = new licenseBootstrap($core,$files_exts,$license,$licenses_headers[$license],$addfull,$overwrite,$exclusion); 81 82 # Add license to files 83 if (isset($_POST['add_license'])) 84 { 85 if (!isset($_POST['type']) || empty($_POST['modules']) || !is_array($_POST['modules'])) 86 { 87 throw new Exception('Nothing to pack'); 48 # Add license to modules 49 if ($action == 'addlicense' && $is_editable) { 50 51 $modules = array_keys($_POST['modules']); 52 53 foreach ($modules as $id) { 54 55 if (!${$type}->moduleExists($id)) { 56 throw new Exception('No such module'); 57 } 58 59 $module = ${$type}->getModules($id); 60 $module['id'] = $id; 61 $module['type'] = $type == 'themes' ? 'theme' : 'plugin'; 62 63 licenseBootstrap::addLicense($core, $module); 88 64 } 89 90 $type = $_POST['type'] == 'theme' ? 'theme' : 'plugin'; 91 $modules = array_keys($_POST['modules']); 92 93 foreach ($modules as $id) 94 { 95 $LB->writeModuleLicense($type,$id); 96 } 97 98 if (!empty($_POST['redir'])) 99 { 100 http::redirect($_POST['redir']); 101 } 102 http::redirect($p_url.'&tab='.$type.'&done=1'); 65 66 dcPage::addSuccessNotice( 67 __('License successfully added.') 68 ); 69 http::redirect(empty($_POST['redir']) ? 70 $p_url : $_POST['redir'] 71 ); 103 72 } 104 73 } 105 catch(Exception $e) 106 { 74 catch(Exception $e) { 107 75 $core->error->add($e->getMessage()); 108 76 } 109 77 110 $title = '';111 if ($default_tab == 'plugin') {112 $title = __('Plugins');113 }114 elseif ($default_tab == 'theme') {115 $title = __('Theme');116 }117 elseif ($default_tab == 'setting') {118 $title = __('Settings');119 }120 $title = html::escapeHTML($title);121 122 78 # Display 123 79 echo 124 '<html><head><title>'.__('License bootstrap'); 125 if (!empty($title)) { 126 echo ' - '.$title; 127 } 128 echo 129 '</title></head><body>'. 130 '<h2>'.__('License bootstrap'); 131 if (!empty($title)) { 132 echo ' › <span class="page-title">'.$title.'</span>'; 133 } 134 echo 135 ' - <a class="button" href="'.$p_url.'&tab=plugin">'.__('Plugins').'</a>'. 136 ' - <a class="button" href="'.$p_url.'&tab=theme">'.__('Themes').'</a>'. 137 '</h2>'; 80 '<html><head><title>'.__('License bootstrap').'</title>'. 81 dcPage::jsPageTabs(). 82 dcPage::jsLoad('index.php?pf=licenseBootstrap/js/licensebootstrap.js'). 138 83 139 if ($default_tab == 'plugin') 140 { 141 libLicenseBootstrap::tab($core->plugins->getModules(),'plugin'); 142 } 143 elseif ($default_tab == 'theme') 144 { 145 $themes = new dcModules($core); 146 $themes->loadModules($core->blog->themes_path,null); 147 libLicenseBootstrap::tab($themes->getModules(),'theme'); 148 } 149 elseif ($default_tab == 'setting') 150 { 151 if (isset($_REQUEST['done'])) 152 { 153 dcPage::message(__('Configuration successfully saved')); 154 } 155 echo '<form id="setting-form" method="post" action="'.$p_url.'">'; 156 157 if ($core->plugins->moduleExists('pacKman') || $core->plugins->moduleExists('translater')) 158 { 159 echo '<fieldset id="settingbehavior"><legend>'.__('Behaviors').'</legend>'; 160 161 if ($core->plugins->moduleExists('pacKman')) 162 { 163 echo ' 164 <p><label class="classic">'. 165 form::checkbox(array('packman_behavior'),'1',$packman_behavior).' '. 166 __('Add license before create package with plugin pacKman').'</label></p>'; 167 } 168 if ($core->plugins->moduleExists('translater')) 169 { 170 echo ' 171 <p><label class="classic">'. 172 form::checkbox(array('translater_behavior'),'1',$translater_behavior).' '. 173 __('Add license after create lang file with plugin translater').'</label></p>'; 174 } 175 echo '</fieldset>'; 176 } 177 178 echo ' 179 <fieldset id="settingfile"><legend>'.__('Files').'</legend> 180 <p><label class="classic">'. 181 form::checkbox(array('overwrite'),'1',$overwrite).' '. 182 __('Overwrite existing license').'</label></p> 183 <p><label class="classic">'. 184 form::checkbox(array('addfull'),'1',$addfull).' '. 185 __('Add full LICENSE file to module root').'</label></p>'; 186 187 foreach($default_exts as $ext) 188 { 189 echo ' 190 <p><label class="classic">'. 191 form::checkbox(array('files_exts[]'),$ext,in_array($ext,$files_exts)).' '. 192 sprintf(__('Add license to the header of %s files'),$ext).'</label></p>'; 193 } 194 195 echo ' 196 <p><label>'.__('Exclusion:'). 197 form::field('exclusion',60,255,html::escapeHTML($exclusion)).' 198 </label></p> 199 </fieldset> 200 201 <fieldset id="settingheader"><legend>'.__('Headers').'</legend>'; 202 203 foreach($default_headers as $type => $header) 204 { 205 $text = isset($licenses_headers[$type]) ? $licenses_headers[$type] : $header; 206 207 echo ' 208 <p><label class="classic">'. 209 form::radio(array('license'),$type,($license == $type)).' '. 210 sprintf(__('License %s:'),$type).'</label></p> 211 <p class="area">'. 212 form::textarea('licenses_headers['.$type.']',50,10,html::escapeHTML($text)).' 213 </p>'; 214 } 215 echo '</fieldset>'; 216 217 echo ' 218 <p class="clear"> 219 <input type="submit" name="save_settings" value="'.__('save').'" /> 220 <input type="submit" name="reset_settings" value="'.__('Reset settings').'" />'. 221 $core->formNonce(). 222 form::hidden(array('section'),$section). 223 form::hidden(array('tab'),'settings'). 224 form::hidden(array('p'),'licenseBootstrap').' 225 </p> 226 </form> 227 </div>'; 228 } 84 # --BEHAVIOR-- licenseBootstrapAdminHeader 85 $core->callBehavior('licenseBootstrapAdminHeader', $core). 86 87 '</head><body>'. 88 89 dcPage::breadcrumb( 90 array( 91 __('Plugins') => '', 92 __('License bootstrap') => '' 93 ) 94 ). 95 dcPage::notices(); 96 97 libLicenseBootstrap::modules( 98 $core, 99 $plugins->getModules(), 100 'plugins', 101 __('Installed plugins') 102 ); 103 104 libLicenseBootstrap::modules( 105 $core, 106 $themes->getModules(), 107 'themes', 108 __('Installed themes') 109 ); 110 229 111 dcPage::helpBlock('licenseBootstrap'); 230 112 231 echo '<hr class="clear"/><p class="right"> 232 <a class="button" href="'.$p_url.'&tab=setting">'.__('Settings').'</a> - 233 licenseBootstrap - '.$core->plugins->moduleInfo('licenseBootstrap','version').' 113 echo 114 '<hr class="clear"/><p class="right modules"> 115 <a class="module-config" '. 116 'href="plugins.php?module=licenseBootstrap&conf=1&redir='. 117 urlencode('plugin.php?p=licenseBootstrap').'">'.__('Configuration').'</a> - 118 licenseBootstrap - '.$core->plugins->moduleInfo('licenseBootstrap', 'version').' 234 119 <img alt="'.__('licenseBootstrap').'" src="index.php?pf=licenseBootstrap/icon.png" /> 235 </p> </body></html>';236 ?> 120 </p> 121 </body></html>'; -
plugins/licenseBootstrap/locales/en/resources.php
r1561 r3241 1 1 <?php 2 2 # -- BEGIN LICENSE BLOCK ---------------------------------- 3 # 3 4 # This file is part of licenseBootstrap, a plugin for Dotclear 2. 4 5 # 5 # Copyright (c) 2009 JCDenis and contributors6 # jcdenis@gdwd.com6 # Copyright (c) 2009-2013 Jean-Christian Denis and contributors 7 # contact@jcdenis.fr 7 8 # 8 9 # Licensed under the GPL version 2.0 license. 9 10 # A copy of this license is available in LICENSE file or at 10 11 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 12 # 11 13 # -- END LICENSE BLOCK ------------------------------------ 12 14 13 if (!defined('DC_RC_PATH')) { return; }15 if (!defined('DC_RC_PATH')) { 14 16 15 $__resources['help']['licenseBootstrap'] = dirname(__FILE__).'/help/help.html'; 16 ?> 17 return null; 18 } 19 20 if (!empty($_REQUEST['module']) && $_REQUEST['module'] == 'licenseBootstrap') { 21 $__resources['help']['core_plugins_conf'] = dirname(__FILE__).'/help/help.html'; 22 } -
plugins/licenseBootstrap/locales/fr/main.lang.php
r2300 r3241 1 1 <?php 2 2 // Language: Français 3 // Module: licenseBootstrap - 0.34 // Date: 201 0-06-05 10:09:545 // Translated with dcTranslater - 1.43 // Module: licenseBootstrap - 2013.10.25 4 // Date: 2013-10-28 10:27:46 5 // Translated with dcTranslater - 2013.05.11 6 6 7 # inc/lib.license.bootstrap.index.php:228 $GLOBALS['__l10n'][' Extensions'] = 'Extensions';7 #_config.php:56 8 $GLOBALS['__l10n']['Configuration has been successfully updated.'] = 'La configuration a été mise à jour avec succés.'; 9 9 10 #inc/lib.license.bootstrap.index.php:26 11 $GLOBALS['__l10n']['License successfully included'] = 'Licence incluse avec succès'; 10 #_config.php:71 11 #_config.php:124 12 $GLOBALS['__l10n']['Files'] = 'Fichiers'; 12 13 13 # inc/lib.license.bootstrap.index.php:3414 $GLOBALS['__l10n'][' Name'] = 'Nom';14 #_config.php:75 15 $GLOBALS['__l10n']['Overwrite existing licenses'] = 'Écraser les licences existantes'; 15 16 16 #inc/lib.license.bootstrap.index.php:36 17 #_config.php:80 18 $GLOBALS['__l10n']['Add full LICENSE file to module root'] = 'Ajouter le fichier de licence complet à la racine du module'; 19 20 #_config.php:85 21 $GLOBALS['__l10n']['Add license block to PHP files'] = 'Ajouter le bloc de licence aux ficheirs PHP'; 22 23 #_config.php:90 24 $GLOBALS['__l10n']['Add license block to JS files'] = 'Ajouter le bloc de licence aux ficheirs JS'; 25 26 #_config.php:95 27 $GLOBALS['__l10n']['Do not add license block to files from locales folder'] = 'Ne pas ajouter la licence aux fichiers du dossier locales'; 28 29 #_config.php:101 30 $GLOBALS['__l10n']['Licenses'] = 'Licences'; 31 32 #_config.php:114 33 $GLOBALS['__l10n']['License %s:'] = 'Licence %s :'; 34 35 #inc/lib.license.bootstrap.php:40 17 36 $GLOBALS['__l10n']['Id'] = 'Id'; 18 37 19 #inc/lib.license.bootstrap. index.php:6520 $GLOBALS['__l10n'][' Add license'] = 'Ajouter la licence';38 #inc/lib.license.bootstrap.php:43 39 $GLOBALS['__l10n']['Root'] = 'Racine'; 21 40 22 #inc/lib.license.bootstrap. index.php:7123 $GLOBALS['__l10n'][' No available module'] = 'Pas de module disponibles';41 #inc/lib.license.bootstrap.php:79 42 $GLOBALS['__l10n']['Add license to selected modules'] = 'Ajouter la licence aux modules selectionner'; 24 43 25 #index.php: 11326 $GLOBALS['__l10n'][' Please wait'] = 'Veulliez patienter';44 #index.php:67 45 $GLOBALS['__l10n']['License successfully added.'] = 'Licence ajouter avec succès'; 27 46 28 #index.php:134 29 #index.php:216 30 $GLOBALS['__l10n']['Settings'] = 'Paramètres'; 31 32 #index.php:138 33 $GLOBALS['__l10n']['Configuration successfully saved'] = 'Configuration sauvergardée avec succès'; 34 35 #index.php:142 36 $GLOBALS['__l10n']['Files'] = 'Fichiers'; 37 38 #index.php:145 39 $GLOBALS['__l10n']['Overwrite existing license'] = 'Écraser la licence existante'; 40 41 #index.php:148 42 $GLOBALS['__l10n']['Add full LICENSE file to module root'] = 'Ajouter le fichier de licence complet à la racine du module'; 43 44 #index.php:155 45 $GLOBALS['__l10n']['Add license to the header of %s files'] = 'Ajouter la licence en entête de fichier %s'; 46 47 #index.php:159 48 $GLOBALS['__l10n']['Exclusion:'] = 'Exclusion :'; 49 50 #index.php:164 51 $GLOBALS['__l10n']['Headers'] = 'Entêtes'; 52 53 #index.php:173 54 $GLOBALS['__l10n']['License %s:'] = 'Licence %s :'; 55 56 #index.php:182 57 $GLOBALS['__l10n']['Behaviors'] = 'Comportements'; 58 59 #index.php:189 60 $GLOBALS['__l10n']['Add license before create package with plugin pacKman'] = 'Ajouter la licence avant de créer un paquetage avec le plugin pacKman'; 61 62 #index.php:196 63 $GLOBALS['__l10n']['Add license after create lang file with plugin translater'] = 'Ajouter la licence après avoir créé une traduction avec le plugin translater'; 64 65 #index.php:204 66 $GLOBALS['__l10n']['Reset settings'] = 'Remise à zéro'; 47 #index.php:119 48 $GLOBALS['__l10n']['Configuration'] = 'Configuration'; 67 49 68 50 ?> -
plugins/licenseBootstrap/locales/fr/main.po
r2300 r3241 1 1 # Language: Français 2 # Module: licenseBootstrap - 0.33 # Date: 201 0-06-05 10:09:544 # Translated with translater 1.42 # Module: licenseBootstrap - 2013.10.25 3 # Date: 2013-10-28 10:27:47 4 # Translated with translater 2013.05.11 5 5 6 6 msgid "" 7 7 msgstr "" 8 8 "Content-Type: text/plain; charset=UTF-8\n" 9 "Project-Id-Version: licenseBootstrap 0.3\n"9 "Project-Id-Version: licenseBootstrap 2013.10.25\n" 10 10 "POT-Creation-Date: \n" 11 "PO-Revision-Date: 201 0-06-05T10:09:54+00:00\n"12 "Last-Translator: J CDenis\n"11 "PO-Revision-Date: 2013-10-28T10:27:47+00:00\n" 12 "Last-Translator: Jean-Christian Denis\n" 13 13 "Language-Team: \n" 14 14 "MIME-Version: 1.0\n" 15 15 "Content-Transfer-Encoding: 8bit\n" 16 16 17 #: inc/lib.license.bootstrap.index.php:2218 msgid " Extensions"19 msgstr " Extensions"17 #: _config.php:56 18 msgid "Configuration has been successfully updated." 19 msgstr "La configuration a été mise à jour avec succés." 20 20 21 #: inc/lib.license.bootstrap.index.php:26 22 msgid "License successfully included" 23 msgstr "Licence incluse avec succès" 21 #: _config.php:71 22 #: _config.php:124 23 msgid "Files" 24 msgstr "Fichiers" 24 25 25 #: inc/lib.license.bootstrap.index.php:3426 msgid " Name"27 msgstr " Nom"26 #: _config.php:75 27 msgid "Overwrite existing licenses" 28 msgstr "Écraser les licences existantes" 28 29 29 #: inc/lib.license.bootstrap.index.php:36 30 #: _config.php:80 31 msgid "Add full LICENSE file to module root" 32 msgstr "Ajouter le fichier de licence complet à la racine du module" 33 34 #: _config.php:85 35 msgid "Add license block to PHP files" 36 msgstr "Ajouter le bloc de licence aux ficheirs PHP" 37 38 #: _config.php:90 39 msgid "Add license block to JS files" 40 msgstr "Ajouter le bloc de licence aux ficheirs JS" 41 42 #: _config.php:95 43 msgid "Do not add license block to files from locales folder" 44 msgstr "Ne pas ajouter la licence aux fichiers du dossier locales" 45 46 #: _config.php:101 47 msgid "Licenses" 48 msgstr "Licences" 49 50 #: _config.php:114 51 msgid "License %s:" 52 msgstr "Licence %s :" 53 54 #: inc/lib.license.bootstrap.php:40 30 55 msgid "Id" 31 56 msgstr "Id" 32 57 33 #: inc/lib.license.bootstrap. index.php:6534 msgid " Add license"35 msgstr " Ajouter la licence"58 #: inc/lib.license.bootstrap.php:43 59 msgid "Root" 60 msgstr "Racine" 36 61 37 #: inc/lib.license.bootstrap. index.php:7138 msgid " No available module"39 msgstr " Pas de module disponibles"62 #: inc/lib.license.bootstrap.php:79 63 msgid "Add license to selected modules" 64 msgstr "Ajouter la licence aux modules selectionner" 40 65 41 #: index.php: 11342 msgid " Please wait"43 msgstr " Veulliez patienter"66 #: index.php:67 67 msgid "License successfully added." 68 msgstr "Licence ajouter avec succès" 44 69 45 #: index.php:134 46 #: index.php:216 47 msgid "Settings" 48 msgstr "Paramètres" 70 #: index.php:119 71 msgid "Configuration" 72 msgstr "Configuration" 49 73 50 #: index.php:13851 msgid "Configuration successfully saved"52 msgstr "Configuration sauvergardée avec succès"53 54 #: index.php:14255 msgid "Files"56 msgstr "Fichiers"57 58 #: index.php:14559 msgid "Overwrite existing license"60 msgstr "Écraser la licence existante"61 62 #: index.php:14863 msgid "Add full LICENSE file to module root"64 msgstr "Ajouter le fichier de licence complet à la racine du module"65 66 #: index.php:15567 msgid "Add license to the header of %s files"68 msgstr "Ajouter la licence en entête de fichier %s"69 70 #: index.php:15971 msgid "Exclusion:"72 msgstr "Exclusion :"73 74 #: index.php:16475 msgid "Headers"76 msgstr "Entêtes"77 78 #: index.php:17379 msgid "License %s:"80 msgstr "Licence %s :"81 82 #: index.php:18283 msgid "Behaviors"84 msgstr "Comportements"85 86 #: index.php:18987 msgid "Add license before create package with plugin pacKman"88 msgstr "Ajouter la licence avant de créer un paquetage avec le plugin pacKman"89 90 #: index.php:19691 msgid "Add license after create lang file with plugin translater"92 msgstr "Ajouter la licence après avoir créé une traduction avec le plugin translater"93 94 #: index.php:20495 msgid "Reset settings"96 msgstr "Remise à zéro"97 -
plugins/licenseBootstrap/locales/fr/resources.php
r1561 r3241 1 1 <?php 2 2 # -- BEGIN LICENSE BLOCK ---------------------------------- 3 # 3 4 # This file is part of licenseBootstrap, a plugin for Dotclear 2. 4 5 # 5 # Copyright (c) 2009 JCDenis and contributors6 # jcdenis@gdwd.com6 # Copyright (c) 2009-2013 Jean-Christian Denis and contributors 7 # contact@jcdenis.fr 7 8 # 8 9 # Licensed under the GPL version 2.0 license. 9 10 # A copy of this license is available in LICENSE file or at 10 11 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 12 # 11 13 # -- END LICENSE BLOCK ------------------------------------ 12 14 13 if (!defined('DC_RC_PATH')) { return; }15 if (!defined('DC_RC_PATH')) { 14 16 15 $__resources['help']['licenseBootstrap'] = dirname(__FILE__).'/help/help.html'; 16 ?> 17 return null; 18 } 19 20 if (!empty($_REQUEST['module']) && $_REQUEST['module'] == 'licenseBootstrap') { 21 $__resources['help']['core_plugins_conf'] = dirname(__FILE__).'/help/help.html'; 22 }
Note: See TracChangeset
for help on using the changeset viewer.