本文整理汇总了PHP中js函数的典型用法代码示例。如果您正苦于以下问题:PHP js函数的具体用法?PHP js怎么用?PHP js使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了js函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
function run()
{
$base = publish(__DIR__ . '/google-code-prettify');
js_file($base . '/prettify.js');
css_file($base . '/theme/' . $this->theme . '.css');
js("prettyPrint();");
}
示例2: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// Put in cache all of route which are tag
$routes = Cache::remember('tags', 120, function () {
return Route::all();
});
$results = [];
// Check if current route has tags
foreach ($routes as $route) {
if (preg_match('%^' . $route->route . '$%', $request->url())) {
array_push($results, $route->tag_container_id);
}
}
// Get all container tag of the current route and add this to the layout
$contents = Tag::whereIn('tag_container_id', $results)->get();
if ($contents) {
foreach ($contents as $content) {
// if data content format this to integrate them into the script
if ($content->data) {
$data = explode(',', $content->data);
$params = [];
foreach ($data as $value) {
$params[] = "'+ {$value} +'";
}
$script = sprintf($content->content, ...$params);
} else {
$script = $content->content;
}
// add script to namespace declared in database
js($content->position . '-tag')->append($script);
}
}
return $next($request);
}
示例3: form
public function form()
{
$this->load->library('cart');
$total_amount = $this->cart->format_number($this->cart->total());
$this->paypallib->add_field('business', 'sandbox@email.com');
$this->paypallib->add_field('return', site_url('pyrocart/paypal/success'));
$this->paypallib->add_field('cancel_return', site_url('pyrocart/paypal/cancel'));
$this->paypallib->add_field('notify_url', site_url('pyrocart/paypal/ipn'));
// <-- IPN url
$this->paypallib->add_field('custom', '1234567890');
// <-- Verify return
$this->paypallib->add_field('item_name', 'Paypal Test Transaction');
$this->paypallib->add_field('item_number', '6941');
$this->paypallib->add_field('amount', $total_amount);
// if you want an image button use this:
$this->paypallib->image('button_03.gif');
// otherwise, don't write anything or (if you want to
// change the default button text), write this:
// $this->paypallib->button('Click to Pay!');
$this->data->paypal_form = $this->paypallib->paypal_form();
$this->data->countries = $this->checkout_m->retrieve_countries();
$this->data->zones = $this->checkout_m->retrieve_zones();
$this->data->cart_contents = $this->cart->contents();
$this->template->append_metadata(css('smart_wizard.css', 'pyrocart'))->append_metadata(css('checkout.css', 'pyrocart'))->append_metadata(js('jquery.smartWizard-2.0.min.js', 'pyrocart'))->append_metadata(js('jquery.chained.mini.js', 'pyrocart'))->append_metadata(js('checkout.js', 'pyrocart'))->build('paypal/form', $this->data);
}
示例4: body
function body($data)
{
srand(seed());
$body = array();
array_push($body, js($data));
return implode("\r\n", $body);
}
示例5: ajaxForm
static function ajaxForm($id, $script = null, $replace = '##ajax-form-alert##:')
{
$update = "ajaxForm" . md5(uniqid(microtime()));
js("\n\t\t\t\$('#" . $id . "').ajaxForm(function(data) { \n\t\t\t\tdata = data.substr(strrpos(data,'" . $replace . "'));\n\t\t\t\tdata = str_replace('" . $replace . "','',data);\n\t\t\t\t" . $script . " \n\t\t\t}); \n\t\t");
js('misc/php.js');
js('misc/jquery.form.js');
}
示例6: profile
public function profile()
{
$user_id = app('auth')->user()->getKey();
$user = User::with('wishlists', 'wishlists.givingCircle', 'wishlists.items')->where('id', '=', $user_id)->get()->first();
js(['user' => $user->getAttributes(), 'wishlists' => $user->wishlists->toArray()]);
return view('profile', ['user' => $user]);
}
示例7: Admin_Controller
function Admin_Controller()
{
parent::__construct();
// Load the Language files ready for output
$this->lang->load('admin');
$this->lang->load('buttons');
// Show error and exit if the user does not have sufficient permissions
if (!self::_check_access()) {
show_error($this->lang->line('cp_access_denied'));
exit;
}
// Get a list of all modules available to this user / group
if ($this->user) {
$this->template->core_modules = $this->cache->model('module_m', 'get_all', array(array('is_backend_menu' => TRUE, 'is_backend' => TRUE, 'group' => $this->user->group, 'lang' => CURRENT_LANGUAGE)), $this->config->item('navigation_cache'));
$addon_modules = $this->cache->model('module_m', 'get_all', array(array('is_core' => FALSE, 'is_backend' => TRUE, 'group' => $this->user->group, 'lang' => CURRENT_LANGUAGE)), $this->config->item('navigation_cache'));
// This takes the modules array and creates a keyed array with the slug as the key.
$modules_keyed = array();
foreach ($addon_modules as $mod) {
$modules_keyed[$mod['slug']] = $mod;
}
$this->template->addon_modules = $modules_keyed;
}
// Template configuration
$this->template->set_layout('admin/layout');
$this->template->enable_parser(FALSE);
$this->template->append_metadata(css('admin/style.css'))->append_metadata(css('jquery/jquery-ui.css'))->append_metadata(css('jquery/colorbox.css'))->append_metadata('<script type="text/javascript">jQuery.noConflict();</script>')->append_metadata(js('jquery/jquery-ui-1.8.4.min.js'))->append_metadata(js('jquery/jquery.colorbox.min.js'))->append_metadata(js('jquery/jquery.livequery.js'))->append_metadata(js('admin/jquery.uniform.min.js'))->append_metadata(js('admin/functions.js'))->append_metadata('<script type="text/javascript">pyro.apppath_uri="' . APPPATH_URI . '";pyro.base_uri="' . BASE_URI . '";</script>');
$this->template->set_partial('header', 'admin/partials/header', FALSE);
$this->template->set_partial('navigation', 'admin/partials/navigation', FALSE);
$this->template->set_partial('metadata', 'admin/partials/metadata', FALSE);
$this->template->set_partial('footer', 'admin/partials/footer', FALSE);
// $this->output->enable_profiler(TRUE);
}
示例8: rules
public function rules($groupID)
{
$this->js = js(array('jquery-1.9.0.min'));
$data['groupID'] = $groupID;
$groupID = (int) $groupID;
$get['table'] = MSTABLE_GROUPS;
$get['display'] = array('gro_name_en', 'gro_name_en as groupName', 'permission');
$data['group'] = $this->dbObject_model->get($get, array('gro_id' => $groupID));
$vars['table'] = MSTABLE_RULES;
$vars['display'] = array('rul_name_en', 'rul_id', 'parent', 'rul_slug');
$vars['orderby'] = "parent";
$rule = $this->dbObject_model->get($vars);
//print_r($rule);
$data['rules'] = array();
for ($i = 0; $i < count($rule); $i++) {
if ($rule[$i]['parent'] == 0 || $rule[$i]['parent'] == "") {
$data['rules'][$rule[$i]['rul_id']] = $rule[$i];
} else {
$data['rules'][$rule[$i]['parent']]['child'][] = $rule[$i];
}
}
// print_r($rule);
// exit();
unset($rule);
$this->load->view('dash/permission/rules', $data);
}
示例9: indexAction
/**
* 管理中心。如果未登陆,跳转至登陆页
*
* @author mrmsl
* @date 2012-07-02 11:12:49
* @lastmodify 2013-03-29 15:58:41 by mrmsl
*
* @return void 无返回值。如果未登陆跳转至登陆页
*/
function indexAction()
{
if (!($admin_info = $this->_admin_info)) {
$this->_redirect(WEB_ADMIN_ENTRY . '/login', false);
return false;
}
$admin_priv = strtolower(json_encode(array_values($this->_role_info['priv'])));
$role_info = $this->_getCache($admin_info['role_id'], 'Role');
//css文件
$css_file = $this->_loadTimeScript('START_TIME');
//,extjs/v4.1.1/resources/css/ext-patch.css
$css_file .= css('extjs/v4.1.1a//resources/css/ext-all-gray.css,extjs/v4.1.1a/resources/css/ext-patch.css', COMMON_IMGCACHE);
$css_file .= css('app.css', ADMIN_IMGCACHE . 'css/');
$js_file = $this->_loadTimeScript('LOAD_CSS_TIME');
$js_file .= js('', true, COMMON_IMGCACHE . 'extjs/v4.1.1a/');
$js_file .= $this->_loadTimeScript('LOAD_EXT_TIME');
$js_file .= js('System.js', false, '/static/js/');
$js_file .= js('System.sys_base_admin_entry = "' . WEB_ADMIN_ENTRY . '"', 'script');
//后台入口
$js_file .= js(MODULE_NAME . '.' . LANG . '.js', false, '/static/js/lang/') . ('en' != LANG ? js('ext-lang-' . LANG . '.js', false, '/static/js/lang/') : '');
if (APP_DEBUG) {
$js_arr = (include APP_PATH . 'include/required_js.php');
$js_file .= js($js_arr, false, ADMIN_IMGCACHE . 'app/');
} else {
$js_file .= js('app/pack/app.js', false);
}
//$js_file .= js('editor_config.js', false, COMMON_IMGCACHE . 'ueditor/v1.2.5/');
$js_file .= $this->_loadTimeScript('LOAD_JS_TIME');
include TEMPLATE_FILE;
}
示例10: jsErrors
function jsErrors($errors)
{
if (is_string($errors)) {
$errors = ['message' => $errors];
}
js(['errors' => $errors]);
}
示例11: Admin_Controller
function Admin_Controller()
{
parent::__construct();
// Load the Language files ready for output
$this->lang->load('admin');
$this->lang->load('buttons');
// Show error and exit if the user does not have sufficient permissions
if (!self::_check_access()) {
show_error($this->lang->line('cp_access_denied'));
exit;
}
// Get a list of all modules available to this user / group
if ($this->user) {
$modules = $this->module_m->get_all(array('is_backend' => TRUE, 'group' => $this->user->group, 'lang' => CURRENT_LANGUAGE));
$grouped_modules = array();
$grouped_menu[] = 'content';
foreach ($modules as $module) {
if ($module['menu'] != 'content' && $module['menu'] != 'design' && $module['menu'] != 'users' && $module['menu'] != 'utilities' && $module['menu'] != '0') {
$grouped_menu[] = $module['menu'];
}
}
array_push($grouped_menu, 'design', 'users', 'utilities');
$grouped_menu = array_unique($grouped_menu);
foreach ($modules as $module) {
$grouped_modules[$module['menu']][$module['name']] = $module;
}
$this->template->menu_items = $grouped_menu;
$this->template->modules = $grouped_modules;
}
// Template configuration
$this->template->set_layout('default', 'admin')->enable_parser(FALSE)->append_metadata(css('admin/style.css'))->append_metadata(css('jquery/jquery-ui.css'))->append_metadata(css('jquery/colorbox.css'))->append_metadata('<script type="text/javascript">jQuery.noConflict();</script>')->append_metadata(js('jquery/jquery-ui-1.8.4.min.js'))->append_metadata(js('jquery/jquery.colorbox.min.js'))->append_metadata(js('jquery/jquery.livequery.js'))->append_metadata(js('admin/jquery.uniform.min.js'))->append_metadata(js('admin/functions.js'))->append_metadata('<script type="text/javascript">pyro.apppath_uri="' . APPPATH_URI . '";pyro.base_uri="' . BASE_URI . '";</script>')->set('user', $this->user)->set_partial('header', 'admin/partials/header')->set_partial('navigation', 'admin/partials/navigation')->set_partial('metadata', 'admin/partials/metadata')->set_partial('footer', 'admin/partials/footer');
// $this->output->enable_profiler(TRUE);
}
示例12: daemons_servers_delete
function daemons_servers_delete()
{
$cfg = $GLOBALS['cfg'];
$db = $GLOBALS['db'];
$server_id = intval(params('server_id'));
$daemon_id = intval(params('daemon_id'));
$arrService = $db->select("SELECT id\n FROM {$cfg['tblService']}\n WHERE server_id='{$server_id}'\n AND daemon_id='{$daemon_id}'");
if (!$arrService) {
halt(SERVER_ERROR);
return;
}
$id = $arrService[0]['id'];
$result = $db->delete("DELETE FROM {$cfg['tblService']}\n WHERE id='{$id}'\n LIMIT 1");
$resultForeign = $db->delete("DELETE FROM {$cfg['tblAccess']}\n WHERE dienst_id='{$id}'");
if (!$result || !$resultForeign) {
halt(SERVER_ERROR);
return;
}
set('server', array('id' => $server_id));
set('daemon', array('id' => $daemon_id));
if (isAjaxRequest()) {
return js('daemons_servers/delete.js.php', null);
} else {
halt(HTTP_NOT_IMPLEMENTED);
}
}
示例13: Public_Controller
function Public_Controller()
{
parent::MY_Controller();
$this->benchmark->mark('public_controller_start');
// Check the frontend hasnt been disabled by an admin
if (!$this->settings->item('frontend_enabled')) {
$error = $this->settings->item('unavailable_message') ? $this->settings->item('unavailable_message') : lang('cms_fatal_error');
show_error($error);
}
// -- Navigation menu -----------------------------------
$this->load->model('pages/pages_m');
// Set the theme view folder
$this->template->set_theme($this->settings->item('default_theme'));
$this->asset->set_theme($this->settings->item('default_theme'));
$this->template->set_layout('layout');
$this->template->append_metadata(js('jquery/jquery.js'))->append_metadata(js('jquery/jquery.fancybox.js'))->append_metadata(css('jquery/jquery.fancybox.css'))->append_metadata(js('front.js'));
// Make sure whatever page the user loads it by, its telling search robots the correct formatted URL
$this->template->set_metadata('canonical', site_url($this->uri->uri_string()), 'link');
// If there is a news module, link to its RSS feed in the head
if (module_exists('news')) {
$this->template->append_metadata('<link rel="alternate" type="application/rss+xml" title="' . $this->settings->item('site_name') . '" href="' . site_url('news/rss/all|rss') . '" />');
}
// Enable profiler on local box
if (ENV == 'local' && $this->input->get('_debug')) {
$this->output->enable_profiler(TRUE);
}
// Frontend data
$this->load->library('variables/variables');
$this->load->vars('variable', $this->variables->get());
$this->benchmark->mark('public_controller_end');
}
示例14: index
/**
* Show the control panel
*
* @access public
* @return void
*/
public function index()
{
if (CMS_VERSION !== $this->settings->version) {
$this->data->messages['notice'] = sprintf(lang('cp_upgrade_message'), CMS_VERSION, $this->settings->version, site_url('upgrade'));
} else {
if (is_dir('./installer')) {
$this->data->messages['notice'] = lang('cp_delete_installer_message');
}
}
$this->load->model('comments/comments_m');
$this->load->model('pages/pages_m');
$this->load->model('users/users_m');
$this->lang->load('comments/comments');
$this->data->recent_users = $this->users_m->get_recent(5);
$recent_comments = $this->comments_m->get_recent(5);
$this->data->recent_comments = process_comment_items($recent_comments);
// Dashboard RSS feed (using SimplePie)
$this->load->library('simplepie');
$this->simplepie->set_cache_location(APPPATH . 'cache/simplepie/');
$this->simplepie->set_feed_url($this->settings->dashboard_rss);
$this->simplepie->init();
$this->simplepie->handle_content_type();
// Dashboard Analytics
//$this->load->library('analytics');
// Just use dummy data for now - we need more settings to make this work...
// Note: Data will need to be in javascript timestamps (multiply unix timestamp by 1000)
$times = array(time() - 7 * 24 * 60 * 60 * 5 * 1000, time() - 7 * 24 * 60 * 60 * 4 * 1000, time() - 7 * 24 * 60 * 60 * 3 * 1000, time() - 7 * 24 * 60 * 60 * 2 * 1000, time() - 7 * 24 * 60 * 60 * 1000);
$this->data->ga_visits = '[[' . $times[0] . ', 300], [' . $times[1] . ', 800], [' . $times[2] . ', 500], [' . $times[3] . ', 800], [' . $times[4] . ', 1300]]';
$this->template->append_metadata(js('jquery/jquery.flot.js'));
// Store the feed items
$this->data->rss_items = $this->simplepie->get_items(0, $this->settings->dashboard_rss_count);
$this->template->set_partial('sidebar', 'admin/partials/sidebar', FALSE);
$this->template->title(lang('cp_admin_home_title'))->build('admin/dashboard', $this->data);
}
示例15: modal
/**
* Render a modal
*
* @param \FrenchFrogs\Modal\Modal\Modal $modal
* @return string
*/
public function modal(Modal\Modal $modal)
{
$html = '';
// header
if ($modal->hasCloseButton()) {
$html .= html('button', ['type' => 'button', 'class' => 'close', 'data-dismiss' => 'modal', 'aria-label' => $modal->getCloseButtonLabel()], '<span aria-hidden="true">×</span>');
}
if ($modal->hasTitle()) {
$html .= html('h4', ['class' => Style::MODAL_HEADER_TITLE_CLASS], $modal->getTitle());
$html = html('div', ['class' => Style::MODAL_HEADER_CLASS], $html);
}
// body
$html .= html('div', ['class' => Style::MODAL_BODY_CLASS], $modal->getBody());
// footer
if ($modal->hasActions()) {
$actions = '';
if ($modal->hasCloseButton()) {
$actions .= html('button', ['type' => 'button', 'class' => 'btn btn-default', 'data-dismiss' => 'modal'], $modal->getCloseButtonLabel());
}
foreach ($modal->getActions() as $action) {
/** @var Element\Button $action */
$actions .= $this->render('action', $action);
}
$html .= html('div', ['class' => Style::MODAL_FOOTER_CLASS], $actions);
}
// container
if (!$modal->isRemote()) {
$html = html('div', ['class' => Style::MODAL_CONTENT_CLASS], $html);
$html = html('div', ['class' => Style::MODAL_DIALOG_CLASS, 'role' => 'document'], $html);
$html = html('div', ['class' => Style::MODAL_CLASS, 'role' => 'dialog'], $html);
}
$html .= html('script', ['type' => 'text/javascript'], js('onload'));
return $html;
}