Exemplo n.º 1
0
function cg2_combopage_getOptions($function, $name, $description, $type)
{
    // error checking
    if (@$_REQUEST['_showCode']) {
        $errorsAndAlerts = '';
        if (!@$_REQUEST['tableName']) {
            alert("Please select a section!<br />\n");
        }
        if (!@$_REQUEST['howMany']) {
            alert("Please select 'How Many'!<br />\n");
        }
        if (!@$_REQUEST['titleField']) {
            alert("Please select a Title field!<br />\n");
        }
        if (!alert()) {
            // if no other errors, check fields exist in schema
            $schema = loadSchema($_REQUEST['tableName']);
            if (!in_array($_REQUEST['titleField'], array_keys($schema))) {
                alert("Invalid field '" . htmlencode($_REQUEST['titleField']) . "' selected!<br/>\n");
            }
        }
        if (!alert()) {
            return;
        }
        // if form submitted and no errors than return and generate code
    }
    // set form defaults
    $defaults['howMany'] = 'all';
    $defaults['limit'] = '5';
    $defaults['showUploads'] = 'all';
    $defaults['showUploadsCount'] = '1';
    $defaults['titleField'] = 'title';
    foreach ($defaults as $key => $value) {
        if (!array_key_exists($key, $_REQUEST)) {
            $_REQUEST[$key] = $value;
        }
    }
    // show header
    echo cg2_header($function, $name);
    print "<input type='hidden' name='_showCode' value='1' />\n";
    cg2_combopage_ajaxJsCode();
    // show ajax js code
    ?>

<div class="code-generator" style="display: block; ">

<?php 
    cg2_option_selectSection();
    ?>

  <div class='content-box content-box-divider'>
    <div class='content-box-header'><h3><?php 
    echo t('List Viewer Options');
    ?>
</h3></div>
  </div>

  <div class="fieldOption">
    <div class="label"><?php 
    et('How Many');
    ?>
</div>
    <div style="float:left; line-height: 1.5em">
        <label>
          <?php 
    echo cg2_inputRadio('howMany', 'all');
    ?>
          <?php 
    et('Show all records');
    ?>
        </label><br/>

        <label>
          <?php 
    echo cg2_inputRadio('howMany', 'firstN');
    ?>
          <?php 
    echo sprintf(t('Show the first %s records only'), cg2_inputText('limit', 3));
    ?>
        </label><br/><br/>

    </div>
    <div class="clear"></div>
  </div>

    <div class="fieldOption">
      <div class="label"><?php 
    et('Title/Name field');
    ?>
</div>
      <?php 
    echo cg2_inputSchemaField('titleField');
    ?>
      <div class="clear"></div>
    </div>

  <div class='content-box content-box-divider'>
    <div class='content-box-header'><h3><?php 
    echo t('Detail Viewer Options');
    ?>
</h3></div>
  </div><br/>

<?php 
    cg2_option_uploads();
    ?>

  <div align="center" style="padding-right: 5px" class="fieldOption"><input class="button" type="submit" name="_null_" value="<?php 
    echo t('Show Code');
    ?>
 &gt;&gt;" /></div>
</div>


  <?php 
    echo cg2_footer();
    exit;
}
Exemplo n.º 2
0
function cg2_rssfeed_getOptions($function, $name, $description, $type)
{
    // error checking
    if (@$_REQUEST['_showCode']) {
        $errorsAndAlerts = '';
        if (!@$_REQUEST['tableName']) {
            alert("Please select a section!<br />\n");
        }
        if (!@$_REQUEST['feedTitle']) {
            alert("Please enter a value for Feed Title!<br />\n");
        }
        if (!@$_REQUEST['feedLink']) {
            alert("Please enter a value for Feed Link!<br />\n");
        }
        if (!@$_REQUEST['feedDescription']) {
            alert("Please enter a value for Feed Description!<br />\n");
        }
        if (!@$_REQUEST['feedLanguage']) {
            alert("Please enter a value for Feed Language!<br />\n");
        }
        if (!@$_REQUEST['titleField']) {
            alert("Please select a title field!<br />\n");
        }
        if (!@$_REQUEST['descriptionField']) {
            alert("Please enter a description field!<br />\n");
        }
        if (!alert()) {
            // if no other errors, check fields exist in schema
            $schema = loadSchema($_REQUEST['tableName']);
            if (!in_array($_REQUEST['titleField'], array_keys($schema))) {
                alert("Invalid field '" . htmlencode($_REQUEST['titleField']) . "' selected!<br/>\n");
            }
            if (!in_array($_REQUEST['descriptionField'], array_keys($schema))) {
                alert("Invalid field '" . htmlencode($_REQUEST['descriptionField']) . "' selected!<br/>\n");
            }
        }
        if (!alert()) {
            return;
        }
        // if form submitted and no errors than return and generate code
    }
    // set form defaults
    $defaults['howMany'] = 'all';
    $defaults['limit'] = 25;
    $defaults['feedTitle'] = "Name of your site or RSS feed";
    $defaults['feedLink'] = "http://www.example.com/";
    $defaults['feedDescription'] = 'Your site description goes here';
    $defaults['feedLanguage'] = 'en-us';
    $defaults['titleField'] = '';
    $defaults['descriptionField'] = '';
    foreach ($defaults as $key => $value) {
        if (!array_key_exists($key, $_REQUEST)) {
            $_REQUEST[$key] = $value;
        }
    }
    // show header
    echo cg2_header($function, $name);
    print "<input type='hidden' name='_showCode' value='1' />\n";
    cg2_rssfeed_ajaxJsCode();
    // show ajax js code
    ?>
<div class="code-generator" style="display: block; ">

<?php 
    cg2_option_selectSection();
    ?>

  <div class='content-box content-box-divider'>
    <div class='content-box-header'><h3><?php 
    eht("Feed Options");
    ?>
</h3></div>
  </div>

  <div class="fieldOption">
    <div class="label"><?php 
    et('How Many');
    ?>
</div>
    <div style="float:left; line-height: 1.5em">
        <label>
          <?php 
    echo cg2_inputRadio('howMany', 'all');
    ?>
          <?php 
    et('Show all records');
    ?>
        </label><br/>

        <label>
          <?php 
    echo cg2_inputRadio('howMany', 'firstN');
    ?>
          <?php 
    echo sprintf(t('Show the first %s records only'), cg2_inputText('limit', 3));
    ?>
        </label><br/><br/>
    </div>
    <div class="clear"></div>
  </div>

<br/>

  <div class="fieldOption">
    <div class="label"><?php 
    et('Feed Title');
    ?>
</div>
    <?php 
    echo cg2_inputText('feedTitle', 60, true);
    ?>
  </div>

  <div class="fieldOption">
    <div class="label"><?php 
    et('Feed Link');
    ?>
</div>
    <?php 
    echo cg2_inputText('feedLink', 60, true);
    ?>
    <div class="clear"></div>
  </div>

  <div class="fieldOption">
    <div class="label"><?php 
    et('Feed Description');
    ?>
</div>
    <?php 
    echo cg2_inputText('feedDescription', 60, true);
    ?>
    <div class="clear"></div>
  </div>

  <div class="fieldOption">
    <div class="label"><?php 
    et('Feed Language');
    ?>
</div>
    <?php 
    echo cg2_inputText('feedLanguage', 60, true);
    ?>
    <div class="clear"></div>
  </div>

<br/><br/>

    <div class="fieldOption">
      <div class="label"><?php 
    et('Title field');
    ?>
</div>
      <?php 
    echo cg2_inputSchemaField('titleField');
    ?>
      <div class="clear"></div>
    </div>

    <div class="fieldOption">
      <div class="label"><?php 
    et('Description field');
    ?>
</div>
      <?php 
    echo cg2_inputSchemaField('descriptionField');
    ?>
      <div class="clear"></div>
    </div>

  <div align="center" style="padding-right: 5px" class="fieldOption"><input class="button" type="submit" name="_null_" value="<?php 
    echo t('Show Code &gt;&gt;');
    ?>
" /></div>
</div>


  <?php 
    echo cg2_footer();
    exit;
}