Example #1
0
File: env.php Project: mdkarch/mal
 public function __construct($outer, $binds = NULL, $exprs = NULL)
 {
     $this->outer = $outer;
     if ($binds) {
         if (_sequential_Q($exprs)) {
             $exprs = $exprs->getArrayCopy();
         }
         for ($i = 0; $i < count($binds); $i++) {
             if ($binds[$i]->value === "&") {
                 if ($exprs !== NULL && $i < count($exprs)) {
                     $lst = call_user_func_array('_list', array_slice($exprs, $i));
                 } else {
                     $lst = _list();
                 }
                 $this->data[$binds[$i + 1]->value] = $lst;
                 break;
             } else {
                 if ($exprs !== NULL && $i < count($exprs)) {
                     $this->data[$binds[$i]->value] = $exprs[$i];
                 } else {
                     $this->data[$binds[$i]->value] = NULL;
                 }
             }
         }
     }
 }
 function _list($type = 'ul', $list, $attributes = '', $depth = 0)
 {
     if (!is_array($list)) {
         return $list;
     }
     $out = str_repeat(" ", $depth);
     if (is_array($attributes)) {
         $atts = '';
         foreach ($attributes as $key => $val) {
             $atts .= ' ' . $key . '="' . $val . '"';
         }
         $attributes = $atts;
     } elseif (is_string($attributes) and strlen($attributes) > 0) {
         $attributes = ' ' . $attributes;
     }
     $out .= "<" . $type . $attributes . ">\n";
     static $_last_list_item = '';
     foreach ($list as $key => $val) {
         $_last_list_item = $key;
         $out .= str_repeat(" ", $depth + 2);
         $out .= "<li>";
         if (!is_array($val)) {
             $out .= $val;
         } else {
             $out .= $_last_list_item . "\n";
             $out .= _list($type, $val, '', $depth + 4);
             $out .= str_repeat(" ", $depth + 2);
         }
         $out .= "</li>\n";
     }
     $out .= str_repeat(" ", $depth);
     $out .= "</" . $type . ">\n";
     return $out;
 }
Example #3
0
 function _list($type = 'ul', $list, $attributes = '', $depth = 0)
 {
     // If an array wasn't submitted there's nothing to do...
     if (!is_array($list)) {
         return $list;
     }
     // Set the indentation based on the depth
     $out = str_repeat(" ", $depth);
     // Were any attributes submitted?  If so generate a string
     if (is_array($attributes)) {
         $atts = '';
         foreach ($attributes as $key => $val) {
             $atts .= ' ' . $key . '="' . $val . '"';
         }
         $attributes = $atts;
     } elseif (is_string($attributes) and strlen($attributes) > 0) {
         $attributes = ' ' . $attributes;
     }
     // Write the opening list tag
     $out .= "<" . $type . $attributes . ">\n";
     // Cycle through the list elements.  If an array is
     // encountered we will recursively call _list()
     static $_last_list_item = '';
     foreach ($list as $key => $val) {
         $_last_list_item = $key;
         $out .= str_repeat(" ", $depth + 2);
         $out .= "<li>";
         if (!is_array($val)) {
             $out .= $val;
         } else {
             $out .= $_last_list_item . "\n";
             $out .= _list($type, $val, '', $depth + 4);
             $out .= str_repeat(" ", $depth + 2);
         }
         $out .= "</li>\n";
     }
     // Set the indentation for the closing tag
     $out .= str_repeat(" ", $depth);
     // Write the closing list tag
     $out .= "</" . $type . ">\n";
     return $out;
 }
Example #4
0
function eval_ast($ast, $env)
{
    if (_symbol_Q($ast)) {
        return $env->get($ast);
    } elseif (_sequential_Q($ast)) {
        if (_list_Q($ast)) {
            $el = _list();
        } else {
            $el = _vector();
        }
        foreach ($ast as $a) {
            $el[] = MAL_EVAL($a, $env);
        }
        return $el;
    } elseif (_hash_map_Q($ast)) {
        $new_hm = _hash_map();
        foreach (array_keys($ast->getArrayCopy()) as $key) {
            $new_hm[$key] = MAL_EVAL($ast[$key], $env);
        }
        return $new_hm;
    } else {
        return $ast;
    }
}
Example #5
0
 /**
  * Generates the list
  *
  * Generates an HTML ordered list from an single or multi-dimensional array.
  *
  * @param	string
  * @param	mixed
  * @param	mixed
  * @param	int
  * @return	string
  */
 function _list($type = 'ul', $list = array(), $attributes = '', $depth = 0)
 {
     // If an array wasn't submitted there's nothing to do...
     if (!is_array($list)) {
         return $list;
     }
     // Set the indentation based on the depth
     $out = str_repeat(' ', $depth) . '<' . $type . _stringify_attributes($attributes) . ">\n";
     // Cycle through the list elements.  If an array is
     // encountered we will recursively call _list()
     static $_last_list_item = '';
     foreach ($list as $key => $val) {
         $_last_list_item = $key;
         $out .= str_repeat(' ', $depth + 2) . '<li>';
         if (!is_array($val)) {
             $out .= $val;
         } else {
             $out .= $_last_list_item . "\n" . _list($type, $val, '', $depth + 4) . str_repeat(' ', $depth + 2);
         }
         $out .= "</li>\n";
     }
     // Set the indentation for the closing tag and apply it
     return $out . str_repeat(' ', $depth) . '</' . $type . ">\n";
 }
function _create(&$PDOdb, &$db, &$user, &$conf, &$langs, $df = false, $ds = false, $de = false, $amount = 0, $label = '')
{
    unset($_SESSION['SENDTOINVOICETOADHERENT_ERRORS']);
    _list($PDOdb, $db, $user, $conf, $langs, 0);
    if (!$user->rights->sendinvoicetoadherent->create) {
        accessforbidden();
    } else {
        $form = new TFormCore();
        print_fiche_titre($langs->trans("sendinvoicetoadherentTitleCreate"));
        echo '<script type="text/javascript">
			$(function() {
				displayDateCotisation();
			});
			
			function displayDateCotisation(obj) {
				if ($(obj).attr("checked") == "checked") {
					$(".cotisation_create").show()
				} else {
					$(".cotisation_create").hide()
				}
			}
		</script>';
        echo '<form style="padding-top:15px;" name="formsoc" action="' . $_SERVER["PHP_SELF"] . '" method="post" enctype="multipart/form-data">';
        echo '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
        echo '<input type="hidden" name="action" value="createConfirm">';
        echo '<table class="border" width="100%">';
        $date_fac = $df === false ? date('d/m/Y') : $df;
        $date_start = $ds === false ? date('d/m/Y') : $ds;
        $date_end = $de === false ? date('d/m/Y', strtotime('+1 year -1 day')) : $de;
        $label = empty($label) ? $langs->trans("Subscription") . ' ' . ($ds ? substr($date_start, -4, 4) : dol_print_date(time(), '%Y')) : $label;
        echo '<tr><td width="20%" class="fieldrequired">' . $langs->trans("sendinvoicetoadherentDateFacture") . '</td><td width="80%">' . $form->calendrier('', 'date_fac', $date_fac) . '</td></tr>';
        echo '<tr><td width="20%">' . $langs->trans("sendinvoicetoadherentCreateCotisation") . '</td><td width="80%"><input type="checkbox" name="create_cotisation" value="1" onclick="javascript:displayDateCotisation(this);" /></td></tr>';
        echo '<tr class="cotisation_create" style="display:none;"><td width="20%" class="fieldrequired">' . $langs->trans("sendinvoicetoadherentDateStartAdhesion") . '</td><td width="80%">' . $form->calendrier('', 'date_start', $date_start) . '</td></tr>';
        echo '<tr class="cotisation_create" style="display:none;"><td width="20%">' . $langs->trans("sendinvoicetoadherentDateEndAdhesion") . '</td><td width="80%">' . $form->calendrier('', 'date_end', $date_end) . '</td></tr>';
        echo '<tr class="cotisation_create" style="display:none;"><td width="20%" class="fieldrequired">' . $langs->trans("sendinvoicetoadherentAmountAdhesion") . '</td><td width="80%">' . $form->texte('', 'amount_cotisation', $amount, 6, 15) . ' ' . $langs->trans("Currency" . $conf->currency) . '</td></tr>';
        echo '<tr class="cotisation_create" style="display:none;"><td width="20%">' . $langs->trans("sendinvoicetoadherentLabelAdhesion") . '</td><td width="80%">' . $form->texte('', 'label', $label, 32, 255) . '</td></tr>';
        echo '</table>';
        if ($user->rights->sendinvoicetoadherent->create) {
            echo '<br /><center>';
            echo '<input type="submit" class="button" value="' . $langs->trans('sendinvoicetoadherentActionCreateConfirm') . '" />&nbsp;&nbsp;&nbsp;&nbsp;';
            echo '<a href="' . dol_buildpath('/sendinvoicetoadherent/sendinvoicetoadherent.php?action=list', 2) . '" class="button" style="text-decoration:none;font-weight:normal;cusor:pointer;height:15px;padding-top:5px;">' . $langs->trans('Cancel') . '</a>';
            echo '</center>';
        }
        echo '</form>';
    }
    $PDOdb->close();
    llxFooter('');
}
Example #7
0
function read_form($reader)
{
    $token = $reader->peek();
    switch ($token) {
        case '\'':
            $reader->next();
            return _list(_symbol('quote'), read_form($reader));
        case '`':
            $reader->next();
            return _list(_symbol('quasiquote'), read_form($reader));
        case '~':
            $reader->next();
            return _list(_symbol('unquote'), read_form($reader));
        case '~@':
            $reader->next();
            return _list(_symbol('splice-unquote'), read_form($reader));
        case '^':
            $reader->next();
            $meta = read_form($reader);
            return _list(_symbol('with-meta'), read_form($reader), $meta);
        case '@':
            $reader->next();
            return _list(_symbol('deref'), read_form($reader));
        case ')':
            throw new Exception("unexpected ')'");
        case '(':
            return read_list($reader);
        case ']':
            throw new Exception("unexpected ']'");
        case '[':
            return read_list($reader, '_vector', '[', ']');
        case '}':
            throw new Exception("unexpected '}'");
        case '{':
            return read_hash_map($reader);
        default:
            return read_atom($reader);
    }
}
Example #8
0
}
### function }}}
### modes {{{
if ($mode == 'setavail') {
    //dd($form);
    $cbs = $form['cb'];
    // array
    $mode2 = $form['mode2'];
    foreach ($cbs as $cb) {
        print $cb;
        if ($mode2 == '1') {
            _set_ce_avail($cb, true);
        } else {
            _set_ce_avail($cb, false);
        }
    }
    print <<<EOS
<script>
//alert("Changed !!");
parent.document.location.reload();
</script>
EOS;
    exit;
}
### modes }}}
pagehead($page_title);
ptitle('CE List');
_style();
_list();
pagetail();
exit;
        } else {
            $object->set_values($_POST);
            $object->save($PDOdb);
            setEventMessage('BDDSaved');
        }
        _list($PDOdb);
        break;
    case 'edit':
        $object->load($PDOdb, GETPOST('id'));
        _card($PDOdb, $object);
        break;
    case 'new':
        _card($PDOdb, $object);
        break;
    default:
        _list($PDOdb);
        break;
}
function _card(&$PDOdb, &$object)
{
    global $langs, $conf, $user, $db;
    if (empty($user->rights->query->bdd->use_other_db)) {
        return '';
    }
    llxHeader();
    dol_fiche_head(array(), 'bdd', 'BDD');
    $tbs = new TTemplateTBS();
    $object->connect();
    $formCore = new TFormCore('auto', 'formBDD', 'post');
    echo $formCore->hidden('action', 'save');
    echo $formCore->hidden('id', $object->getId());