3 * Code Snippets Repository
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * http://fusionforge.org
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 require_once('../env.inc.php');
25 require_once $gfcommon.'include/pre.php';
26 require_once $gfwww.'snippet/snippet_utils.php';
28 if (session_loggedin()) {
30 if (getStringFromRequest('post_changes')) {
31 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
32 exit_form_double_submit();
34 $name = getStringFromRequest('name');
35 $description = getStringFromRequest('description');
36 $language = getIntFromRequest('language');
37 $category = getIntFromRequest('category');
38 $changes = getStringFromRequest('changes');
39 $version = getStringFromRequest('version');
42 Create a new snippet entry, then create a new snippet version entry
44 if ($name && $description && $language != 0 && $category != 0 && $version) {
46 Create the new package
48 $result = db_query_params ('INSERT INTO snippet_package (category,created_by,name,description,language) VALUES ($1,$2,$3,$4,$5)',
51 htmlspecialchars($name),
52 htmlspecialchars($description),
56 form_release_key(getStringFromRequest("form_key"));
57 $error_msg .= _('ERROR DOING SNIPPET PACKAGE INSERT!');
58 snippet_header(array('title'=>_('Submit A New Snippet Package')));
60 snippet_footer(array());
63 $feedback .= _('Snippet Package Added Successfully.');
64 $snippet_package_id=db_insertid($result,'snippet_package','snippet_package_id');
66 create the snippet package version
68 $result = db_query_params ('INSERT INTO snippet_package_version (snippet_package_id,changes,version,submitted_by,post_date) VALUES ($1,$2,$3,$4,$5)',
69 array ($snippet_package_id,
70 htmlspecialchars($changes),
71 htmlspecialchars($version),
76 $error_msg .= _('ERROR DOING SNIPPET PACKAGE VERSION INSERT!');
77 snippet_header(array('title'=>_('Submit A New Snippet Package')));
79 snippet_footer(array());
82 //so far so good - now add snippets to the package
83 $feedback .= _('Snippet Pacakge Version Added Successfully.');
85 //id for this snippet_package_version
86 $snippet_package_version_id=
87 db_insertid($result,'snippet_package_version','snippet_package_version_id');
88 snippet_header(array('title'=>_('Add snippets to package')));
91 This raw HTML allows the user to add snippets to the package
96 <script language="JavaScript" type="text/javascript">/* <![CDATA[ */
97 function show_add_snippet_box() {
98 newWindow = open("","occursDialog","height=500,width=300,scrollbars=yes,resizable=yes");
99 newWindow.location=('/snippet/add_snippet_to_package.php?suppress_nav=1&snippet_package_version_id=<?php
100 echo $snippet_package_version_id; ?>');
103 <body onload="show_add_snippet_box()">
106 <span class="important"><?php echo _('IMPORTANT!'); ?></span>
108 <?php echo _('If a new window opened, use it to add snippets to your package. If a new window did not open, use the following link to add to your package BEFORE you leave this page.'); ?></p>
110 <p><?php echo util_make_link ('/snippet/add_snippet_to_package.php?snippet_package_version_id='.$snippet_package_version_id,_('Add snippets to package'),array('target'=>'_blank')); ?></p>
113 <?php echo _('<strong>Browse the library</strong> to find the snippets you want to add, then add them using the new window link shown above.'); ?>
118 snippet_footer(array());
123 form_release_key(getStringFromRequest("form_key"));
124 exit_error(_('Error - Go back and fill in all the information'));
128 snippet_header(array('title'=>_('Submit A New Snippet Package')));
133 <?php echo _('You can group together existing snippets into a package using this interface. Before creating your package, make sure all your snippets are in place and you have made a note of the snippet ID\'s.'); ?>
136 <li><?php echo _('Create the package using this form.'); ?></li>
137 <li><?php echo _('<strong>Then</strong> use the "Add Snippets to Package" link to add files to your package.'); ?></li>
139 <p><?php echo _('<span class="important">Note:</span> You can submit a new version of an existing package by browsing the library and using the link on the existing package. You should only use this page if you are submitting an entirely new package.'); ?>
141 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="post">
142 <input type="hidden" name="form_key" value="<?php echo form_generate_key(); ?>"/>
143 <input type="hidden" name="post_changes" value="y" />
144 <input type="hidden" name="changes" value="First Posted Version" />
148 <tr><td colspan="2"><strong><?php echo _('Title:'); ?></strong><?php echo utils_requiredField(); ?><br />
149 <input type="text" name="name" size="45" maxlength="60" />
152 <tr><td colspan="2"><strong><?php echo _('Description:'); ?></strong><?php echo utils_requiredField(); ?><br />
153 <textarea name="description" rows="5" cols="45"></textarea>
157 <td><strong><?php echo _('Language') ?>:</strong><?php echo utils_requiredField(); ?><br />
158 <?php echo html_build_select_box_from_array ($SCRIPT_LANGUAGE,'language'); ?>
160 <!--<?php echo util_make_link ('/support/?func=addsupport&group_id=1',_('Suggest a Language')); ?>-->
163 <td><strong><?php echo _('Category') ?></strong><?php echo utils_requiredField(); ?><br />
164 <?php echo html_build_select_box_from_array ($SCRIPT_CATEGORY,'category'); ?>
166 <!--<?php echo util_make_link ('/support/?func=addsupport&group_id=1',_('Suggest a Category')); ?>-->
170 <tr><td colspan="2"><strong><?php echo _('Version') ?>:</strong><?php echo utils_requiredField(); ?><br />
171 <input type="text" name="version" size="10" maxlength="15" />
174 <tr><td colspan="2" style="text-align:center">
175 <strong><?php echo _('Make sure all info is complete and accurate'); ?></strong>
177 <input type="submit" name="submit" value="<?php echo _('SUBMIT'); ?>" />
182 snippet_footer(array());
186 exit_not_logged_in();
192 // c-file-style: "bsd"