本文整理汇总了PHP中partial函数的典型用法代码示例。如果您正苦于以下问题:PHP partial函数的具体用法?PHP partial怎么用?PHP partial使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了partial函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: partial
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";
}
}
}
示例2: reduce
/**
* Almost an alias.
*
* @author Sérgio Rafael Siqueira <sergio@inbep.com.br>
*
* @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);
}
示例3: aiga_nebraska_get_search_form
/**
* 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');
}
}
示例4: filter
/**
* Almost an alias.
*
* @author Sérgio Rafael Siqueira <sergio@inbep.com.br>
*
* @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);
}
示例5: lt
/**
* Less than
*
* @author Sérgio Rafael Siqueira <sergio@inbep.com.br>
*
* @return mixed
*/
function lt()
{
$args = func_get_args();
$lt = function ($a, $b) {
return $a < $b;
};
return call_user_func_array(partial($lt), $args);
}
示例6: take
/**
* @author Sérgio Rafael Siqueira <sergio@inbep.com.br>
*
* @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);
}
示例7: gte
/**
* Greater than or equals to
*
* @author Sérgio Rafael Siqueira <sergio@inbep.com.br>
*
* @return mixed
*/
function gte()
{
$args = func_get_args();
$gte = function ($a, $b) {
return $a >= $b;
};
return call_user_func_array(partial($gte), $args);
}
示例8: getForm
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), []);
}
示例9: drop
/**
* @author Sérgio Rafael Siqueira <sergio@inbep.com.br>
*
* @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);
}
示例10: prepend
/**
* @author Sérgio Rafael Siqueira <sergio@inbep.com.br>
*
* @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);
}
示例11: prop
/**
* @author Sérgio Rafael Siqueira <sergio@inbep.com.br>
*
* @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);
}
示例12: append
/**
* @author Sérgio Rafael Siqueira <sergio@inbep.com.br>
*
* @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);
}
示例13: equals
/**
* @author Sérgio Rafael Siqueira <sergio@inbep.com.br>
*
* @return mixed
*/
function equals()
{
$args = func_get_args();
$equals = function ($a, $b) {
return $a === $b;
};
return call_user_func_array(partial($equals), $args);
}
示例14: mediaplugin_filter
/**
* 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;
}
示例15: remove
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]);
}