function partial($param, $level = 0, $first = true) { if ($first) { echo "\n\r"; } if (is_string($param)) { $param = array($param); } foreach ($param as $key => $item) { if (is_int($key)) { $filename = $item; } else { $filename = $key; } if (@is_file(__ROOT__ . '/partials/' . $filename . '.php')) { include __ROOT__ . '/partials/' . $filename . '.php'; } else { echo gTab($level) . '<div class="' . $filename . ' undefinedBlock">' . "\n\r"; if (is_array($item)) { partial($item, $level + 1, false); } echo gTab($level) . '</div><!--END OF ' . $filename . '-->' . "\n\r"; } } }
/** * Almost an alias. * * @author Sérgio Rafael Siqueira <*****@*****.**> * * @return mixed */ function reduce() { $args = func_get_args(); $reduce = function (callable $fn, array $xs, $initial = null) { return array_reduce($xs, $fn, $initial); }; return call_user_func_array(partial($reduce), $args); }
/** * Get a search form if the ajax is activated * @return string HTML representation of the search form */ function aiga_nebraska_get_search_form() { if (pjaxify(true)) { partial('searchform', 'ajax'); } else { partial('searchform'); } }
/** * Almost an alias. * * @author Sérgio Rafael Siqueira <*****@*****.**> * * @return mixed */ function filter() { $args = func_get_args(); $filter = function (callable $fn, array $xs) { return array_filter($xs, $fn); }; return call_user_func_array(partial($filter), $args); }
/** * Less than * * @author Sérgio Rafael Siqueira <*****@*****.**> * * @return mixed */ function lt() { $args = func_get_args(); $lt = function ($a, $b) { return $a < $b; }; return call_user_func_array(partial($lt), $args); }
/** * @author Sérgio Rafael Siqueira <*****@*****.**> * * @return mixed */ function take() { $args = func_get_args(); $take = function ($n, array $xs) { return array_slice($xs, 0, $n); }; return call_user_func_array(partial($take), $args); }
/** * Greater than or equals to * * @author Sérgio Rafael Siqueira <*****@*****.**> * * @return mixed */ function gte() { $args = func_get_args(); $gte = function ($a, $b) { return $a >= $b; }; return call_user_func_array(partial($gte), $args); }
public function getForm() { $contactForm = config('cms.contact.config.view', 'contact-form-1'); if (!view()->exists(partial(sprintf('contact::frontend.%s', $contactForm)))) { $contactForm = 'contact-form-1'; } return $this->setView(sprintf('frontend.%s', $contactForm), []); }
/** * @author Sérgio Rafael Siqueira <*****@*****.**> * * @return mixed */ function drop() { $args = func_get_args(); $drop = function ($n, array $xs) { return array_slice($xs, $n); }; return call_user_func_array(partial($drop), $args); }
/** * @author Sérgio Rafael Siqueira <*****@*****.**> * * @return mixed */ function prepend() { $args = func_get_args(); $prepend = function ($x, array $xs) { return array_merge([$x], $xs); }; return call_user_func_array(partial($prepend), $args); }
/** * @author Sérgio Rafael Siqueira <*****@*****.**> * * @return mixed */ function prop() { $args = func_get_args(); $prop = function ($x, array $xs) { return get($xs, $x, false); }; return call_user_func_array(partial($prop), $args); }
/** * @author Sérgio Rafael Siqueira <*****@*****.**> * * @return mixed */ function append() { $args = func_get_args(); $append = function ($x, array $xs) { return array_merge($xs, [$x]); }; return call_user_func_array(partial($append), $args); }
/** * @author Sérgio Rafael Siqueira <*****@*****.**> * * @return mixed */ function equals() { $args = func_get_args(); $equals = function ($a, $b) { return $a === $b; }; return call_user_func_array(partial($equals), $args); }
/** * mediaplugin_filter * * @param xxx $hotpot * @param xxx $text * @param xxx $options (optional, default=array) * @return xxx */ function mediaplugin_filter($hotpot, $text, $options = array()) { global $CFG, $PAGE; // Keep track of the id of the current quiz // so that eolas_fix.js is only included once in each quiz // Note: the cron script calls this method for multiple quizzes static $eolas_fix_applied = 0; if (!is_string($text)) { // non string data can not be filtered anyway return $text; } $newtext = $text; // fullclone is slow and not needed here foreach (array_keys($this->media_filetypes) as $filetype) { // set $adminsetting, the name of the $CFG setting, if any, which enables/disables filtering of this file type $adminsetting = ''; if (preg_match('/^[a-z]+$/', $filetype)) { $hotpot_enable = 'hotpot_enable' . $filetype; $filter_mediaplugin_enable = 'filter_mediaplugin_enable_' . $filetype; if (isset($CFG->{$hotpot_enable})) { $adminsetting = $hotpot_enable; } else { if (isset($CFG->{$filter_mediaplugin_enable})) { $adminsetting = $filter_mediaplugin_enable; } } } // set $search and $replace strings $search = '/<a.*?href="([^"?>]*\\.' . $filetype . '[^">]*)"[^>]*>.*?<\\/a>/is'; if ($adminsetting == '' || $CFG->{$adminsetting}) { // filtering of this file type is allowed $callback = array($this, 'hotpot_mediaplugin_filter'); $callback = partial($callback, $filetype, $options); $newtext = preg_replace_callback($search, $callback, $newtext, -1, $count); } else { // filtering of this file type is disabled $replace = '$1<br />' . get_string('error_disabledfilter', 'hotpot', $adminsetting); $newtext = preg_replace($search, $replace, $newtext, -1, $count); } if ($count > 0) { break; } } if (is_null($newtext) || $newtext == $text) { // error or not filtered return $text; } if ($eolas_fix_applied == $hotpot->id) { // do nothing - the external javascripts have already been included for this quiz } else { $PAGE->requires->js('/mod/hotpot/mediafilter/ufo.js', true); $PAGE->requires->js('/mod/hotpot/mediafilter/eolas_fix.js'); //$newtext .= "\n".'<script type="text/javascript" src="'.$CFG->wwwroot.'/mod/hotpot/mediafilter/ufo.js"></script>'; //$newtext .= "\n".'<script type="text/javascript" src="'.$CFG->wwwroot.'/mod/hotpot/mediafilter/eolas_fix.js" defer="defer"></script>'; $eolas_fix_applied = $hotpot->id; } return $newtext; }
public function remove($commentId) { // Get the comment $comment = $this->repo->getById($commentId); // Get the current user (for brevity) $user = $this->currentUser; $message = ($user->isStaff() or !$user->isStaff() and $user->id == $comment->user_id) ? view('pages.devplans.comments.remove', compact('comment')) : alert('alert-danger', "You do not have permission to remove this comment."); return partial('common/modal_content', ['modalHeader' => "Remove Comment", 'modalBody' => $message, 'modalFooter' => false]); }
/** * @author Sérgio Rafael Siqueira <*****@*****.**> * * @return mixed */ function each() { $args = func_get_args(); $each = function (callable $fn, array $xs) { array_walk($xs, $fn); return $xs; }; return call_user_func_array(partial($each), $args); }
/** * @author Sérgio Rafael Siqueira <*****@*****.**> * * @return mixed */ function concat() { $args = func_get_args(); $concat = function ($a, $b) { $rest = array_slice(func_get_args(), 2); return call_user_func_array('array_merge', array_merge([$a, $b], $rest)); }; return call_user_func_array(partial($concat), $args); }
public function comments() { $output = ''; if ($this->entity->comments->count() > 0) { foreach ($this->entity->comments as $c) { $output .= partial('common.blockquote', ['author' => $c->user->present()->name, 'content' => $c->present()->content, 'class' => $c->user->isStaff() ? ' quote-staff' : false]); } } return $output; }
public function remove($itemId, $image) { // Get the item $item = $this->items->find($itemId); if ($item) { $content = $this->checkPermissions($item) ? View::make('pages.item.images-remove')->withItem($item)->withImage($image) : alert('danger', "You don't have access to manage images for this Xtra."); } else { $content = alert('danger', "We couldn't find the Xtra you're looking for."); } return partial('modal_content', ['modalHeader' => "Remove Image", 'modalBody' => $content, 'modalFooter' => false]); }
/** * Returns the value mapped to key, $notfound value if key not present. * * @author Sérgio Rafael Siqueira <*****@*****.**> * * @link https://clojuredocs.org/clojure.core/get * * @return mixed */ function get() { $args = func_get_args(); $get = function (array $xs, $x, $notfound = false) { if (array_key_exists($x, $xs)) { return $xs[$x]; } return $notfound; }; return call_user_func_array(partial($get), $args); }
function deleteat() { $args = func_get_args(); $deleteat = function ($n, array $xs) { if ($n > 0) { return array_merge(take($n, $xs), drop($n + 1, $xs)); } return $xs; }; return call_user_func_array(partial($deleteat), $args); }
function knowledge_test() { $show_score = isset($_GET['test_score']); if ($show_score) { set_query_var('knowledge_test_success', get_knowledge_test_success()); partial('knowledge-test-success'); } else { set_query_var('knowledge_test', get_knowledge_test_questions()); partial('knowledge-test'); } }
/** * @author Sérgio Rafael Siqueira <*****@*****.**> * * @return mixed */ function ifelse() { $args = func_get_args(); $ifelse = function (callable $condition, callable $ontrue, callable $onfalse) { return function ($x) use($condition, $ontrue, $onfalse) { if ($condition($x)) { return $ontrue($x); } return $onfalse($x); }; }; return call_user_func_array(partial($ifelse), $args); }
/** * Returns the value in a nested associative structure, * where $ks is a sequence of keys. Returns false if the key * is not present, or the $notfound value if supplied. * * @author Sérgio Rafael Siqueira <*****@*****.**> * * @link https://clojuredocs.org/clojure.core/get-in * * @return mixed */ function getin() { $args = func_get_args(); $getin = function (array $xs, array $ks, $notfound = false) { if (!array_key_exists(0, $ks)) { return $notfound; } $x = get($xs, $ks[0], $notfound); if (is_array($x)) { return getin($x, array_slice($ks, 1), $notfound); } return $x; }; return call_user_func_array(partial($getin), $args); }
/** * @author Sérgio Rafael Siqueira <*****@*****.**> * * @return array */ function dropwhile() { $args = func_get_args(); $dropwhile = function (callable $condition, array $xss) { if ([] === $xss) { return []; } $head = head($xss); $tail = tail($xss); if ($condition($head)) { return dropwhile($condition, $tail); } return $xss; }; return call_user_func_array(partial($dropwhile), $args); }
/** * @author Marcelo Camargo <*****@*****.**> * @author Sérgio Rafael Siqueira <*****@*****.**> * * @return array */ function takewhile() { $args = func_get_args(); $takewhile = function (callable $condition, array $xss) { if ([] === $xss) { return []; } $head = head($xss); $tail = tail($xss); if ($condition($head)) { return array_merge([$head], takewhile($condition, $tail)); } return []; }; return call_user_func_array(partial($takewhile), $args); }
/** * Generate a shortname based on a template. * * @param array|object $data course data. * @param string $templateshortname template of shortname. * @return null|string shortname based on the template, or null when an error occured. */ public static function generate_shortname($data, $templateshortname) { if (empty($templateshortname) && !is_numeric($templateshortname)) { return null; } if (strpos($templateshortname, '%') === false) { return $templateshortname; } $course = (object) $data; $fullname = isset($course->fullname) ? $course->fullname : ''; $idnumber = isset($course->idnumber) ? $course->idnumber : ''; $callback = partial(array('tool_uploadcourse_helper', 'generate_shortname_callback'), $fullname, $idnumber); $result = preg_replace_callback('/(?<!%)%([+~-])?(\\d)*([fi])/', $callback, $templateshortname); if (!is_null($result)) { $result = clean_param($result, PARAM_TEXT); } if (empty($result) && !is_numeric($result)) { $result = null; } return $result; }
/** * Extend lifetime of a file */ public function extendAction() { $file = $this->getFile(); $result = array(); if ($file->extends_count < fz_config_get('app', 'max_extend_count')) { $file->extendLifetime(); $file->save(); $result['status'] = 'success'; $result['statusText'] = __('Lifetime extended'); $result['html'] = partial('main/_file_row.php', array('file' => $file)); } else { $result['status'] = 'error'; $result['statusText'] = __r('You can\'t extend a file lifetime more than %x% times', array('x' => fz_config_get('app', 'max_extend_count'))); } if ($this->isXhrRequest()) { return json($result); } else { flash($result['status'] == 'success' ? 'notification' : 'error', $result['statusText']); redirect_to('/'); } }
<?php partial('partials/header'); ?> <h1 class="page-header">Criar</h1> <form action="<?php echo url('candidates', 'store'); ?> " method="POST" enctype="multipart/form-data"> <?php partial('candidates/form'); ?> </form> <?php partial('partials/footer');
<h2>Envoyer le fichier par email <span class="filename">(<?php echo h($file->file_name); ?> )</span></h2> <?php echo partial('file/_mailForm.php', array('file' => $file));