/**
  * @param array $option
  *
  * @return string
  */
 protected function isSelected($option)
 {
     if (!$this->multiple && $this->isSelectedSet) {
         return '';
     }
     $check = parent::isSelected($option);
     $this->isSelectedSet = $check != '';
     return $check;
 }
 /**
  * Return the select field widget as object
  * @param mixed
  * @return object
  */
 protected function getEventTypeWidget($value = null)
 {
     $widget = new SelectMenu();
     $widget->id = 'event_type';
     $widget->name = 'event_type';
     $widget->mandatory = false;
     $widget->options = array(array('value' => '0', 'label' => $GLOBALS['TL_LANG']['tl_calendar_events']['event_type']['label'][0]), array('value' => '1', 'label' => $GLOBALS['TL_LANG']['tl_calendar_events']['event_type']['label'][1]), array('value' => '2', 'label' => $GLOBALS['TL_LANG']['tl_calendar_events']['event_type']['label'][2]), array('value' => '3', 'label' => $GLOBALS['TL_LANG']['tl_calendar_events']['event_type']['label'][3]), array('value' => '4', 'label' => $GLOBALS['TL_LANG']['tl_calendar_events']['event_type']['label'][4]));
     $widget->value = $value;
     $widget->label = $GLOBALS['TL_LANG']['tl_calendar_events']['event_type'][0];
     if ($GLOBALS['TL_CONFIG']['showHelp'] && strlen($GLOBALS['TL_LANG']['tl_calendar_events']['event_type'][1])) {
         $widget->help = $GLOBALS['TL_LANG']['tl_calendar_events']['event_type'][1];
     }
     // Valiate input
     if (\Input::post('FORM_SUBMIT') == 'tl_importExt_calendar') {
         $widget->validate();
         if ($widget->hasErrors()) {
             $this->blnSave = false;
         }
     }
     return $widget;
 }
Example #3
0
    public function compile()
    {
        \System::loadLanguageFile('tl_iso_gallery');
        $strBuffer = '
<table style="width:100%">
<thead>
    <tr>
        <th>' . $GLOBALS['TL_LANG']['tl_iso_gallery']['name'][0] . '</th>
        <th>' . $GLOBALS['TL_LANG']['tl_iso_gallery']['lightbox_template'][0] . '<span class="mandatory">*</span></th>
    </tr>
</thead>
<tbody>';
        foreach ($this->objGaleries as $objGallery) {
            $objSelect = new \SelectMenu(\Widget::getAttributesFromDca(array('options' => array_merge(\Controller::getTemplateGroup('moo_'), \Controller::getTemplateGroup('j_')), 'eval' => array('includeBlankOption' => true, 'mandatory' => true)), 'gallery[' . $objGallery->id . ']'));
            if (\Input::post('FORM_SUBMIT') == 'tl_iso_upgrade_20010000') {
                $objSelect->validate();
                if (!$objSelect->hasErrors()) {
                    $objGallery->lightbox_template = serialize(array($objSelect->value));
                    $objGallery->save();
                }
            }
            $strBuffer .= '
    <tr>
        <td>' . $objGallery->name . '</td>
        <td>' . $objSelect->generateWithError() . '</td>
    </tr>';
        }
        $strBuffer .= '
</tbody>
</table>';
        $this->Template->formSubmit = 'tl_iso_upgrade_20010000';
        $this->Template->fields = $strBuffer;
        $this->Template->matter = $GLOBALS['TL_LANG']['UPG']['20010000'];
        if (\Input::post('FORM_SUBMIT') == 'tl_iso_upgrade_20010000') {
            \Controller::reload();
        }
    }
Example #4
0
<?php

ini_set('display_errors', 1);
spl_autoload_register(function ($val) {
    require_once __DIR__ . '/lib/' . $val . '.php';
});
$number = isset($_POST['number']) ? $_POST['number'] : 10;
$url = 'https://itunes.apple.com/jp/rss/topsongs/limit=' . $number . '/xml';
$req = new ItunesRss($url);
$smenu = new SelectMenu(array('10' => 10, '25' => 25, '50' => 50, '100' => 100));
//echo '<pre>';
//print_r($req->getRequest());
//echo '</pre>';
?>
<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <title>itunesRsscustom</title>
</head>
<body>
   <div class="container">
      <div class="controll">
          <form action="" method="post" id="number">
             邦楽top
              <select name="number" onChange="document.getElementById('number').submit()">
                  <?php 
foreach ($smenu->getoption() as $n => $v) {
    if (isset($_POST['number']) && $n == $_POST['number']) {
        echo "<option value='" . $n . "' selected>" . $v . "</option>";
    } else {
Example #5
0
	/**
	 * Return the progress widget as object
	 * @param mixed
	 * @return Widget
	 */
	protected function getProgressWidget($value=null)
	{
		$widget = new SelectMenu();

		$widget->id = 'progress';
		$widget->name = 'progress';
		$widget->mandatory = true;
		$widget->value = $value;

		$widget->label = $GLOBALS['TL_LANG']['tl_task']['progress'][0];

		if ($GLOBALS['TL_CONFIG']['showHelp'] && $GLOBALS['TL_LANG']['tl_task']['progress'][1] != '')
		{
			$widget->help = $GLOBALS['TL_LANG']['tl_task']['progress'][1];
		}

		$arrOptions = array();
		$arrProgress = array(0,10,20,30,40,50,60,70,80,90,100);

		// Get all active users
		foreach ($arrProgress as $v)
		{
			$arrOptions[] = array('value'=>$v, 'label'=>$v . '%');
		}

		$widget->options = $arrOptions;

		// Valiate input
		if ($this->Input->post('FORM_SUBMIT') == 'tl_tasks')
		{
			$widget->validate();

			if ($widget->hasErrors())
			{
				$this->blnSave = false;
			}
		}

		return $widget;
	}
 /**
  * {@inheritdoc}
  */
 public function handle(\Input $input)
 {
     /** @var RootPackage $rootPackage */
     $rootPackage = $this->composer->getPackage();
     /** @var Config $config */
     $config = $this->composer->getConfig();
     $minimumStability = new \SelectMenu(array('id' => 'minimum-stability', 'name' => 'minimum-stability', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_minimum_stability'][0], 'description' => $GLOBALS['TL_LANG']['composer_client']['widget_minimum_stability'][1], 'options' => array(array('value' => 'stable', 'label' => $GLOBALS['TL_LANG']['composer_client']['stability_stable']), array('value' => 'RC', 'label' => $GLOBALS['TL_LANG']['composer_client']['stability_rc']), array('value' => 'beta', 'label' => $GLOBALS['TL_LANG']['composer_client']['stability_beta']), array('value' => 'alpha', 'label' => $GLOBALS['TL_LANG']['composer_client']['stability_alpha']), array('value' => 'dev', 'label' => $GLOBALS['TL_LANG']['composer_client']['stability_dev'])), 'value' => $rootPackage->getMinimumStability(), 'class' => 'minimum-stability', 'required' => true));
     $preferStable = new \CheckBox(array('id' => 'prefer-stable', 'name' => 'prefer-stable', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_prefer_stable'][0], 'description' => $GLOBALS['TL_LANG']['composer_client']['widget_prefer_stable'][1], 'options' => array(array('value' => '1', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_prefer_stable'][0])), 'value' => $rootPackage->getPreferStable(), 'class' => 'prefer-stable', 'required' => true));
     $preferredInstall = new \SelectMenu(array('id' => 'preferred-install', 'name' => 'preferred-install', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_preferred_install'][0], 'description' => $GLOBALS['TL_LANG']['composer_client']['widget_preferred_install'][1], 'options' => array(array('value' => 'source', 'label' => $GLOBALS['TL_LANG']['composer_client']['install_source']), array('value' => 'dist', 'label' => $GLOBALS['TL_LANG']['composer_client']['install_dist']), array('value' => 'auto', 'label' => $GLOBALS['TL_LANG']['composer_client']['install_auto'])), 'value' => $config->get('preferred-install'), 'class' => 'preferred-install', 'required' => true));
     $configGithubOauth = $config->get('github-oauth');
     $githubOauth = new \TextField(array('id' => 'github-oauth', 'name' => 'github-oauth', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_github_oauth'][0], 'description' => $GLOBALS['TL_LANG']['composer_client']['widget_github_oauth'][1], 'value' => $configGithubOauth['github.com'], 'class' => 'github-oauth'));
     $discardChanges = new \SelectMenu(array('id' => 'discard-changes', 'name' => 'discard-changes', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_discard_changes'][0], 'description' => $GLOBALS['TL_LANG']['composer_client']['widget_discard_changes'][1], 'options' => array(array('value' => '', 'label' => $GLOBALS['TL_LANG']['composer_client']['discard_changes_no']), array('value' => '1', 'label' => $GLOBALS['TL_LANG']['composer_client']['discard_changes_yes']), array('value' => 'stash', 'label' => $GLOBALS['TL_LANG']['composer_client']['discard_changes_stash'])), 'value' => (string) $config->get('discard-changes'), 'class' => 'github-oauth'));
     if ($input->post('FORM_SUBMIT') == 'tl_composer_settings') {
         $doSave = false;
         $json = new JsonFile(TL_ROOT . '/' . $this->configPathname);
         $config = $json->read();
         $minimumStability->validate();
         $preferStable->validate();
         $preferredInstall->validate();
         $githubOauth->validate();
         $discardChanges->validate();
         if (!$minimumStability->hasErrors()) {
             $config['minimum-stability'] = $minimumStability->value;
             $doSave = true;
         }
         if (!$preferStable->hasErrors()) {
             $config['prefer-stable'] = (bool) $preferStable->value;
             $doSave = true;
         }
         if (!$preferredInstall->hasErrors()) {
             $config['config']['preferred-install'] = $preferredInstall->value;
             $doSave = true;
         }
         if (!$githubOauth->hasErrors()) {
             if ($githubOauth->value) {
                 $config['config']['github-oauth']['github.com'] = $githubOauth->value;
             } else {
                 unset($config['config']['github-oauth']['github.com']);
                 if (empty($config['config']['github-oauth'])) {
                     unset($config['config']['github-oauth']);
                 }
             }
             $doSave = true;
         }
         if (!$discardChanges->hasErrors()) {
             if ($discardChanges->value) {
                 $config['config']['discard-changes'] = $discardChanges->value == 'stash' ? 'stash' : (bool) $discardChanges->value;
             } else {
                 unset($config['config']['discard-changes']);
             }
             $doSave = true;
         }
         if ($doSave) {
             // make a backup
             copy(TL_ROOT . '/' . $this->configPathname, TL_ROOT . '/' . $this->configPathname . '~');
             // update config file
             $json->write($config);
         }
         $this->redirect('contao/main.php?do=composer&settings=dialog');
     }
     $template = new \BackendTemplate('be_composer_client_settings');
     $template->composer = $this->composer;
     $template->minimumStability = $minimumStability;
     $template->preferStable = $preferStable;
     $template->preferredInstall = $preferredInstall;
     $template->githubOauth = $githubOauth;
     $template->discardChanges = $discardChanges;
     return $template->parse();
 }
Example #7
0
    /**
     * Pass an order to the document
     * @param   DataContainer
     */
    public function printDocument(\DataContainer $dc)
    {
        $strRedirectUrl = str_replace('&key=print_document', '', \Environment::get('request'));
        if (\Input::post('FORM_SUBMIT') == 'tl_iso_print_document') {
            if (($objOrder = Order::findByPk($dc->id)) === null) {
                \Message::addError('Could not find order id.');
                \Controller::redirect($strRedirectUrl);
            }
            if (($objConfig = $objOrder->getRelated('config_id')) === null) {
                \Message::addError('Could not find config id.');
                \Controller::redirect($strRedirectUrl);
            }
            // Set current config
            Isotope::setConfig($objConfig);
            /** @var \Isotope\Interfaces\IsotopeDocument $objDocument */
            if (($objDocument = Document::findByPk(\Input::post('document'))) === null) {
                \Message::addError('Could not find document id.');
                \Controller::redirect($strRedirectUrl);
            }
            $objDocument->outputToBrowser($objOrder);
        }
        $arrSelect = array('name' => 'document', 'label' => &$GLOBALS['TL_LANG']['tl_iso_product_collection']['document_choice'], 'inputType' => 'select', 'foreignKey' => 'tl_iso_document.name', 'eval' => array('mandatory' => true));
        $objSelect = new \SelectMenu(\SelectMenu::getAttributesFromDca($arrSelect, $arrSelect['name']));
        $strMessages = \Message::generate();
        \Message::reset();
        // Return form
        return '
<div id="tl_buttons">
<a href="' . ampersand($strRedirectUrl) . '" class="header_back" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['backBT']) . '">' . $GLOBALS['TL_LANG']['MSC']['backBT'] . '</a>
</div>

<h2 class="sub_headline">' . sprintf($GLOBALS['TL_LANG']['tl_iso_product_collection']['print_document'][1], $dc->id) . '</h2>' . $strMessages . '

<form action="' . ampersand(\Environment::get('request'), true) . '" id="tl_iso_product_import" class="tl_form" method="post">
<div class="tl_formbody_edit">
<input type="hidden" name="FORM_SUBMIT" value="tl_iso_print_document">
<input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '">

<div class="tl_tbox block">
  ' . $objSelect->parse() . '
  <p class="tl_help">' . $objSelect->description . '</p>
</div>

</div>

<div class="tl_formbody_submit">

<div class="tl_submit_container">
<input type="submit" name="print" id="print" class="tl_submit" alt="" accesskey="s" value="' . specialchars($GLOBALS['TL_LANG']['tl_iso_product_collection']['print']) . '">
</div>

</div>
</form>';
    }
Example #8
0
    /**
     * Provide a select menu to choose orders by status and print PDF
     * @return string
     */
    public function printInvoices()
    {
        $strMessage = '';
        $strReturn = '
<div id="tl_buttons">
<a href="' . ampersand(str_replace('&key=print_invoices', '', $this->Environment->request)) . '" class="header_back" title="' . specialchars($GLOBALS['TL_LANG']['MSC']['backBT']) . '">' . $GLOBALS['TL_LANG']['MSC']['backBT'] . '</a>
</div>

<h2 class="sub_headline">' . $GLOBALS['TL_LANG']['tl_iso_orders']['print_invoices'][0] . '</h2>
<form action="' . $this->Environment->request . '"  id="tl_print_invoices" class="tl_form" method="post">
<input type="hidden" name="FORM_SUBMIT" value="tl_print_invoices">
<input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '">
<div class="tl_formbody_edit">
<div class="tl_tbox block">';
        $objWidget = new SelectMenu($this->prepareForWidget($GLOBALS['TL_DCA']['tl_iso_orders']['fields']['status'], 'status'));
        if ($this->Input->post('FORM_SUBMIT') == 'tl_print_invoices') {
            $objOrders = $this->Database->prepare("SELECT id FROM tl_iso_orders WHERE status=?")->execute($this->Input->post('status'));
            if ($objOrders->numRows) {
                $this->generateInvoices($objOrders->fetchEach('id'));
            } else {
                $strMessage = '<p class="tl_gerror">' . $GLOBALS['TL_LANG']['MSC']['noOrders'] . '</p>';
            }
        }
        return $strReturn . $strMessage . $objWidget->parse() . '
</div>
</div>
<div class="tl_formbody_submit">
<div class="tl_submit_container">
<input type="submit" name="print_invoices" id="ctrl_print_invoices" value="' . $GLOBALS['TL_LANG']['MSC']['labelSubmit'] . '">
</div>
</div>
</form>
</div>';
    }
Example #9
0
    /**
     * Generate the widget and return it as string
     * @return string
     */
    public function generate()
    {
        if (!is_array($this->arrOptions) || !count($this->arrOptions)) {
            return '';
        }
        $this->import('Database');
        $objVariant = $this->Database->prepare("SELECT * FROM tl_iso_products WHERE id=?")->limit(1)->execute($this->currentRecord);
        // Begin table
        $return = '<table class="tl_variantwizard" id="ctrl_' . $this->strId . '">
  <tbody>';
        // Add fields
        foreach ($this->arrOptions as $option) {
            $datepicker = '';
            $arrData = $GLOBALS['TL_DCA']['tl_iso_products']['fields'][$option['value']];
            switch ($arrData['inputType']) {
                case 'text':
                    $objWidget = new TextField($this->prepareForWidget($arrData, $this->strId . '[' . $option['value'] . ']', $objVariant->{$option['value']}));
                    if ($arrData['eval']['datepicker']) {
                        $objWidget->id = str_replace('[', '_', $objWidget->id);
                        $objWidget->id = str_replace(']', '_', $objWidget->id);
                        $datepicker = '
			  <script>
			  window.addEvent(\'domready\', function() { ' . sprintf($arrData['eval']['datepicker'], 'ctrl_' . $objWidget->id) . ' });
			  </script>';
                    }
                    break;
                default:
                    $arrField = $this->prepareForWidget($arrData, $this->strId . '[' . $option['value'] . ']', $objVariant->{$option['value']});
                    foreach ($arrField['options'] as $k => $v) {
                        if ($v['value'] == '') {
                            unset($arrField['options'][$k]);
                        }
                    }
                    $objWidget = new SelectMenu($arrField);
                    break;
            }
            $return .= '
    <tr>
      <td>' . $objWidget->generateLabel() . '&nbsp;</td>
      <td>' . $objWidget->generate() . $datepicker . '&nbsp;</td>
    </tr>';
        }
        return $return . '
  </tbody>
</table>';
    }