本文整理汇总了PHP中current函数的典型用法代码示例。如果您正苦于以下问题:PHP current函数的具体用法?PHP current怎么用?PHP current使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了current函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup_wizard
/**
* Show the setup wizard
*/
public function setup_wizard()
{
if (empty($_GET['page']) || 'wc-setup' !== $_GET['page']) {
return;
}
$this->steps = array('introduction' => array('name' => __('Introduction', 'woocommerce'), 'view' => array($this, 'wc_setup_introduction'), 'handler' => ''), 'pages' => array('name' => __('Page Setup', 'woocommerce'), 'view' => array($this, 'wc_setup_pages'), 'handler' => array($this, 'wc_setup_pages_save')), 'locale' => array('name' => __('Store Locale', 'woocommerce'), 'view' => array($this, 'wc_setup_locale'), 'handler' => array($this, 'wc_setup_locale_save')), 'shipping_taxes' => array('name' => __('Shipping & Tax', 'woocommerce'), 'view' => array($this, 'wc_setup_shipping_taxes'), 'handler' => array($this, 'wc_setup_shipping_taxes_save')), 'payments' => array('name' => __('Payments', 'woocommerce'), 'view' => array($this, 'wc_setup_payments'), 'handler' => array($this, 'wc_setup_payments_save')), 'next_steps' => array('name' => __('Ready!', 'woocommerce'), 'view' => array($this, 'wc_setup_ready'), 'handler' => ''));
$this->step = isset($_GET['step']) ? sanitize_key($_GET['step']) : current(array_keys($this->steps));
$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
wp_register_script('select2', WC()->plugin_url() . '/assets/js/select2/select2' . $suffix . '.js', array('jquery'), '3.5.2');
wp_register_script('wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array('jquery', 'select2'), WC_VERSION);
wp_localize_script('wc-enhanced-select', 'wc_enhanced_select_params', array('i18n_matches_1' => _x('One result is available, press enter to select it.', 'enhanced select', 'woocommerce'), 'i18n_matches_n' => _x('%qty% results are available, use up and down arrow keys to navigate.', 'enhanced select', 'woocommerce'), 'i18n_no_matches' => _x('No matches found', 'enhanced select', 'woocommerce'), 'i18n_ajax_error' => _x('Loading failed', 'enhanced select', 'woocommerce'), 'i18n_input_too_short_1' => _x('Please enter 1 or more characters', 'enhanced select', 'woocommerce'), 'i18n_input_too_short_n' => _x('Please enter %qty% or more characters', 'enhanced select', 'woocommerce'), 'i18n_input_too_long_1' => _x('Please delete 1 character', 'enhanced select', 'woocommerce'), 'i18n_input_too_long_n' => _x('Please delete %qty% characters', 'enhanced select', 'woocommerce'), 'i18n_selection_too_long_1' => _x('You can only select 1 item', 'enhanced select', 'woocommerce'), 'i18n_selection_too_long_n' => _x('You can only select %qty% items', 'enhanced select', 'woocommerce'), 'i18n_load_more' => _x('Loading more results…', 'enhanced select', 'woocommerce'), 'i18n_searching' => _x('Searching…', 'enhanced select', 'woocommerce'), 'ajax_url' => admin_url('admin-ajax.php'), 'search_products_nonce' => wp_create_nonce('search-products'), 'search_customers_nonce' => wp_create_nonce('search-customers')));
wp_enqueue_style('woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array(), WC_VERSION);
wp_enqueue_style('wc-setup', WC()->plugin_url() . '/assets/css/wc-setup.css', array('dashicons', 'install'), WC_VERSION);
wp_register_script('wc-setup', WC()->plugin_url() . '/assets/js/admin/wc-setup.min.js', array('jquery', 'wc-enhanced-select'), WC_VERSION);
wp_localize_script('wc-setup', 'wc_setup_params', array('locale_info' => json_encode(include WC()->plugin_path() . '/i18n/locale-info.php')));
if (!empty($_POST['save_step']) && isset($this->steps[$this->step]['handler'])) {
call_user_func($this->steps[$this->step]['handler']);
}
ob_start();
$this->setup_wizard_header();
$this->setup_wizard_steps();
$this->setup_wizard_content();
$this->setup_wizard_footer();
exit;
}
示例2: apply
/**
* {@inheritdoc}
*/
public function apply(DataSourceInterface $dataSource, $name, $data, array $options)
{
$expressionBuilder = $dataSource->getExpressionBuilder();
if (is_array($data) && !isset($data['type'])) {
$data['type'] = isset($options['type']) ? $options['type'] : self::TYPE_CONTAINS;
}
if (!is_array($data)) {
$data = ['type' => self::TYPE_CONTAINS, 'value' => $data];
}
$fields = array_key_exists('fields', $options) ? $options['fields'] : [$name];
$type = $data['type'];
$value = array_key_exists('value', $data) ? $data['value'] : null;
if (!in_array($type, [self::TYPE_NOT_EMPTY, self::TYPE_EMPTY], true) && '' === trim($value)) {
return;
}
if (1 === count($fields)) {
$dataSource->restrict($this->getExpression($expressionBuilder, $type, current($fields), $value));
return;
}
$expressions = [];
foreach ($fields as $field) {
$expressions[] = $this->getExpression($expressionBuilder, $type, $field, $value);
}
$dataSource->restrict($expressionBuilder->orX(...$expressions));
}
示例3: prepare_form
/**
* {@inheritdoc}
*/
public function prepare_form($request, $template, $user, $row, &$error)
{
$avatar_list = $this->get_avatar_list($user);
$category = $request->variable('avatar_local_cat', key($avatar_list));
foreach ($avatar_list as $cat => $null) {
if (!empty($avatar_list[$cat])) {
$template->assign_block_vars('avatar_local_cats', array('NAME' => $cat, 'SELECTED' => $cat == $category));
}
if ($cat != $category) {
unset($avatar_list[$cat]);
}
}
if (!empty($avatar_list[$category])) {
$template->assign_vars(array('AVATAR_LOCAL_SHOW' => true));
$table_cols = isset($row['avatar_gallery_cols']) ? $row['avatar_gallery_cols'] : 4;
$row_count = $col_count = $avatar_pos = 0;
$avatar_count = sizeof($avatar_list[$category]);
reset($avatar_list[$category]);
while ($avatar_pos < $avatar_count) {
$img = current($avatar_list[$category]);
next($avatar_list[$category]);
if ($col_count == 0) {
++$row_count;
$template->assign_block_vars('avatar_local_row', array());
}
$template->assign_block_vars('avatar_local_row.avatar_local_col', array('AVATAR_IMAGE' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $img['file'], 'AVATAR_NAME' => $img['name'], 'AVATAR_FILE' => $img['filename'], 'CHECKED' => $img['file'] === $row['avatar']));
$template->assign_block_vars('avatar_local_row.avatar_local_option', array('AVATAR_FILE' => $img['filename'], 'S_OPTIONS_AVATAR' => $img['filename'], 'CHECKED' => $img['file'] === $row['avatar']));
$col_count = ($col_count + 1) % $table_cols;
++$avatar_pos;
}
}
return true;
}
示例4: preforward
/**
* preprocess before forwarding.
*
* @access public
*/
function preforward()
{
$this->subtitle = _('Select language');
$config = $this->backend->getConfig();
$this->af->setApp('allow_language', $config->get('allow_language'));
$this->af->setApp('cur_lang', current($this->backend->ctl->getLanguage()));
}
示例5: cronCleanlogs
static function cronCleanlogs()
{
global $DB;
$pmLog = new PluginMonitoringLog();
$pmConfig = new PluginMonitoringConfig();
$id_restart = 0;
$a_restarts = $pmLog->find("`action`='restart'", "`id` DESC", 1);
if (count($a_restarts) > 0) {
$a_restart = current($a_restarts);
$id_restart = $a_restart['id'];
}
$id_reload = 0;
$a_reloads = $pmLog->find("`action`='reload'", "`id` DESC", 1);
if (count($a_reloads) > 0) {
$a_reload = current($a_reloads);
$id_reload = $a_reload['id'];
}
$pmConfig->getFromDB(1);
$secs = $pmConfig->fields['logretention'] * DAY_TIMESTAMP;
$query = "DELETE FROM `" . $pmLog->getTable() . "`\n WHERE UNIX_TIMESTAMP(date_mod) < UNIX_TIMESTAMP()-{$secs}";
if ($id_restart > 0 || $id_reload > 0) {
// Keep last reload or restart command
$id_restart = max($id_restart, $id_reload);
$query .= " AND `id` < '" . $id_restart . "'";
}
$DB->query($query);
// TODO: Delete serviceevents table content ???
$query = "DELETE FROM `glpi_plugin_monitoring_serviceevents`\n WHERE UNIX_TIMESTAMP(date) < UNIX_TIMESTAMP()-{$secs}";
$DB->query($query);
return true;
}
示例6: get_product_categories
function get_product_categories($parent_id, $open_nodes_ids = array())
{
$href_string = "javascript:set_return('productcategories')";
reset($open_nodes_ids);
$nodes = array();
if ($parent_id == '') {
$query = "select * from product_categories where (parent_id is null or parent_id='') and deleted=0 order by list_order";
} else {
$query = "select * from product_categories where parent_id ='{$parent_id}' and deleted=0 order by list_order";
}
$result = $GLOBALS['db']->query($query);
while (($row = $GLOBALS['db']->fetchByAssoc($result)) != null) {
$node = new Node($row['id'], $row['name']);
$node->set_property("href", $href_string);
if (count($open_nodes_ids) > 0 and $row['id'] == current($open_nodes_ids)) {
$node->expanded = true;
$node->dynamic_load = false;
$current_id = current($open_nodes_ids);
array_shift($open_nodes_ids);
$child_nodes = get_product_categories($current_id, $open_nodes_ids);
//add all returned node to current node.
foreach ($child_nodes as $child_node) {
$node->add_node($child_node);
}
} else {
$node->expanded = false;
$node->dynamic_load = true;
}
$nodes[] = $node;
}
return $nodes;
}
示例7: array_to_xml
function array_to_xml($phpResponse, &$phpResponseToXML)
{
foreach ($phpResponse as $key => $value) {
if (is_array($value)) {
if (!is_numeric($key)) {
// For non-numeric keys, give name same as key to the node
$subnode = $phpResponseToXML->addChild("{$key}");
// Recursive call to the function since the value was an array
array_to_xml($value, $subnode);
} else {
// For numeric keys, give a name to the node
//$subnode = $phpResponseToXML->addChild("item$key");
if (current($phpResponseToXML->xpath('parent::*'))) {
$subnode = $phpResponseToXML->addChild("Showing");
} else {
$subnode = $phpResponseToXML->addChild("Show");
}
//Recursive call to the function since the value was an array
array_to_xml($value, $subnode);
}
} else {
// Save the node and its value in XMLFiles format
//$phpResponseToXML->addChild("$key","$value");
$phpResponseToXML->{$key} = $value;
}
}
}
示例8: apply_filters_ref_array
function apply_filters_ref_array($tag, $args)
{
global $wp_filter, $merged_filters, $wp_current_filter;
// Do 'all' actions first
if (isset($wp_filter['all'])) {
$wp_current_filter[] = $tag;
$all_args = func_get_args();
_wp_call_all_hook($all_args);
}
if (!isset($wp_filter[$tag])) {
if (isset($wp_filter['all'])) {
array_pop($wp_current_filter);
}
return $args[0];
}
if (!isset($wp_filter['all'])) {
$wp_current_filter[] = $tag;
}
// Sort
if (!isset($merged_filters[$tag])) {
ksort($wp_filter[$tag]);
$merged_filters[$tag] = true;
}
reset($wp_filter[$tag]);
do {
foreach ((array) current($wp_filter[$tag]) as $the_) {
if (!is_null($the_['function'])) {
$args[0] = call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
}
}
} while (next($wp_filter[$tag]) !== false);
array_pop($wp_current_filter);
return $args[0];
}
示例9: download
public function download($urls, $merge = TRUE)
{
if (!$urls || !is_array($urls)) {
return FALSE;
}
$extFlag = FALSE;
$videoName = $this->title;
if (count($urls) == 1) {
$fileName = './video/' . $videoName . '.mp4';
$url = current($urls);
system("curl -o {$fileName} {$url}");
} else {
foreach ($urls as $key => $url) {
$videoName = './video/' . $key . 'tudou.mp4.download';
$parts[] = $videoName;
system("curl -o {$videoName} {$url}");
$extFlag = TRUE;
}
if ($extFlag && $merge) {
$outFile = $this->title . '.mp4';
$this->merge($parts, 'tudou', $this->ext);
}
}
return $fileName;
}
示例10: addFailure
/**
* A failure occurred.
*
* @param PHPUnit_Framework_Test $test
* @param PHPUnit_Framework_AssertionFailedError $e
* @param float $time
*/
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
{
$this->write('fail: ' . $e->getMessage());
$trace = current(PHPUnit_Util_Filter::getFilteredStacktrace($e, FALSE));
$this->write('trace: ' . print_r($trace, 1));
$this->currentTestPass = FALSE;
}
示例11: _getRecipient
protected function _getRecipient()
{
$rs = $this->_getMailComponent()->getRecipientSources();
$recipientId = $this->_getParam('recipientId');
if (!$recipientId) {
$component = Kwf_Component_Data_Root::getInstance()->getComponentById($this->_getParam('componentId'), array('ignoreVisible' => true));
$source = reset($rs);
$model = Kwf_Model_Abstract::getInstance($source['model']);
$select = $model->select();
if ($model->hasColumn('newsletter_component_id')) {
$select->whereEquals('newsletter_component_id', $component->parent->componentId);
}
if (isset($source['select'])) {
$select->merge($source['select']);
}
$row = $model->getRow($select);
if (!$row) {
throw new Kwf_Exception_Client(trlKwf('Preview cannot be shown because it needs at least one recipient of this newsletter'));
}
$recipientId = $row->id;
}
$select = new Kwf_Model_Select();
$select->whereEquals('id', $recipientId);
$subscribeModelKey = $this->_getParam('subscribeModelKey');
if (!$subscribeModelKey) {
$subscribeModelKey = current(array_keys($rs));
}
$model = $rs[$subscribeModelKey]['model'];
$row = Kwf_Model_Abstract::getInstance($model)->getRow($select);
return $row;
}
示例12: action_registro
public function action_registro()
{
if ($this->request->method() == 'POST') {
$aProducto = $this->request->post('prod');
$name = $this->request->post('nombre_cliente');
$oOrden = ORM::factory('Orden');
$oOrden->nombre_cliente = $name;
$dias = array("Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sábado");
$meses = array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
$oOrden->fecha_emision = $dias[date('w')] . " " . date('d') . " de " . $meses[date('n') - 1] . " del " . date('Y');
$oOrden->save();
foreach ($aProducto as $id_prod => $oProducto) {
$producto = ORM::factory('Producto', $id_prod);
$oItem = ORM::factory('Item');
$oItem->id_orden = $oOrden->id;
$oItem->id_prod = $id_prod;
$oItem->cantidad = (int) current($oProducto);
$oItem->subtotal = (double) $producto->precio * (int) current($oProducto);
$oItem->save();
$oOrden->total += $oItem->subtotal;
$oOrden->save();
$producto->stock -= $oItem->cantidad;
$producto->save();
}
$this->redirect('/venta/orden_pago/' . $oOrden->id);
// $this->redirect('/venta/orden/'.$oOrden->id);
}
$aProducto = ORM::factory('Producto')->find_all();
$this->template->content = View::factory('venta/registro')->set('aProducto', $aProducto);
}
示例13: convert
/**
* @param mixed $item
* @return mixed
* @throws \Exception
*/
public function convert($item)
{
foreach ($this->processors as $field => $actions) {
// If field doesn't exist:
// - Create new column with null value
// - Add new route to this column
if (!array_key_exists($field, $item)) {
$item[$field] = null;
$this->route[$field] = $field;
}
// An array of actions has been given
if (is_array($actions) && count($actions) > 0) {
foreach ($actions as $action) {
// Get action name and options
$name = is_array($action) ? key($action) : $action;
$options = is_array($action) ? current($action) : null;
// Set processor name in CamelCase
$name = implode('', array_map('ucwords', explode('_', $name)));
// Get processor class from action name
$class = 'Stratis\\Component\\Migrator\\Processor\\' . $name . 'Processor';
// Check if class exists
if (!class_exists($class)) {
throw new \Exception($class . ' does not exists');
}
// Use processor exec function
$item[$field] = $class::exec($item[$field], $options, $item);
}
}
}
return $item;
}
示例14: extendData
public function extendData($items)
{
$prefLocale = osc_current_user_locale();
$results = array();
foreach ($items as $item) {
$descriptions = $this->conn->osc_dbFetchResults('SELECT * FROM %st_item_description WHERE fk_i_item_id = %d', DB_TABLE_PREFIX, $item['fk_i_item_id']);
$item['locale'] = array();
foreach ($descriptions as $desc) {
$item['locale'][$desc['fk_c_locale_code']] = $desc;
}
if (isset($item['locale'][$prefLocale])) {
$item['s_title'] = $item['locale'][$prefLocale]['s_title'];
$item['s_description'] = $item['locale'][$prefLocale]['s_description'];
$item['s_what'] = $item['locale'][$prefLocale]['s_what'];
} else {
$data = current($item['locale']);
$item['s_title'] = $data['s_title'];
$item['s_description'] = $data['s_description'];
$item['s_what'] = $data['s_what'];
unset($data);
}
$results[] = $item;
}
return $results;
}
示例15: doClean
/**
* @see sfValidatorBase
*/
protected function doClean($values)
{
$originalValues = $values;
if (!is_array($this->getOption('column'))) {
$this->setOption('column', array($this->getOption('column')));
}
//if $values isn't an array, make it one
if (!is_array($values)) {
//use first column for key
$columns = $this->getOption('column');
$values = array($columns[0] => $values);
}
$qb = $this->em->createQueryBuilder()->select('a')->from($this->getOption('model'), 'a');
$i = 0;
foreach ($this->getOption('column') as $column) {
if (!array_key_exists($column, $values)) {
// one of the columns has be removed from the form
return $originalValues;
}
$qb->andWhere('a.' . $column . ' = ?' . ++$i);
$qb->setParameter($i, $values[$column]);
}
$object = current($qb->setMaxResults(1)->getQuery()->execute());
// if no object or if we're updating the object, it's ok
if (!$object || $this->isUpdate($object, $values)) {
return $originalValues;
}
$error = new sfValidatorError($this, 'invalid', array('column' => implode(', ', $this->getOption('column'))));
if ($this->getOption('throw_global_error')) {
throw $error;
}
$columns = $this->getOption('column');
throw new sfValidatorErrorSchema($this, array($columns[0] => $error));
}