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]; }
/** * Dropdown(select with options) shortcode attribute type generator. * * @param $settings * @param $value * * @since 4.4 * @return string - html string. */ function vc_dropdown_form_field($settings, $value) { $output = ''; $css_option = str_replace('#', 'hash-', vc_get_dropdown_option($settings, $value)); $output .= '<select name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-input wpb-select ' . $settings['param_name'] . ' ' . $settings['type'] . ' ' . $css_option . '" data-option="' . $css_option . '">'; if (is_array($value)) { $value = isset($value['value']) ? $value['value'] : array_shift($value); } if (!empty($settings['value'])) { foreach ($settings['value'] as $index => $data) { if (is_numeric($index) && (is_string($data) || is_numeric($data))) { $option_label = $data; $option_value = $data; } elseif (is_numeric($index) && is_array($data)) { $option_label = isset($data['label']) ? $data['label'] : array_pop($data); $option_value = isset($data['value']) ? $data['value'] : array_pop($data); } else { $option_value = $data; $option_label = $index; } $selected = ''; $option_value_string = (string) $option_value; $value_string = (string) $value; if ('' !== $value && $option_value_string === $value_string) { $selected = ' selected="selected"'; } $option_class = str_replace('#', 'hash-', $option_value); $output .= '<option class="' . esc_attr($option_class) . '" value="' . esc_attr($option_value) . '"' . $selected . '>' . htmlspecialchars($option_label) . '</option>'; } } $output .= '</select>'; return $output; }
/** * Constructor for the Anthologize class * * This constructor does the following: * - Checks minimum PHP and WP version, and bails if they're not met * - Includes Anthologize's main files * - Sets up the basic hooks that initialize Anthologize's post types and UI * * @since 0.7 */ public function __construct() { // Bail if PHP version is not at least 5.0 if (!self::check_minimum_php()) { add_action('admin_notices', array('Anthologize', 'phpversion_nag')); return; } // Bail if WP version is not at least 3.3 if (!self::check_minimum_wp()) { add_action('admin_notices', array('Anthologize', 'wpversion_nag')); } // If we've made it this far, start initializing Anthologize register_activation_hook(__FILE__, array($this, 'activation')); register_deactivation_hook(__FILE__, array($this, 'deactivation')); // @todo WP's functions plugin_basename() etc don't work // correctly on symlinked setups, so I'm implementing my own $bn = explode(DIRECTORY_SEPARATOR, dirname(__FILE__)); $this->basename = array_pop($bn); $this->plugin_dir = plugin_dir_path(__FILE__); $this->plugin_url = plugin_dir_url(__FILE__); $this->includes_dir = trailingslashit($this->plugin_dir . 'includes'); $upload_dir = wp_upload_dir(); $this->cache_dir = trailingslashit($upload_dir['basedir'] . '/anthologize-cache'); $this->cache_url = trailingslashit($upload_dir['baseurl'] . '/anthologize-cache'); $this->setup_constants(); $this->includes(); $this->setup_hooks(); }
public function parsePadding($v) { $padding = explode('|*|', $v); $unit = array_pop($padding); $padding[] = ''; return 'padding:' . implode($unit . ' ', $padding) . ';'; }
/** * Joins strings into a natural-language list. * Can be internationalized with gettext or the su_lang_implode filter. * * @since 1.1 * * @param array $items The strings (or objects with $var child strings) to join. * @param string|false $var The name of the items' object variables whose values should be imploded into a list. If false, the items themselves will be used. * @param bool $ucwords Whether or not to capitalize the first letter of every word in the list. * @return string|array The items in a natural-language list. */ function su_lang_implode($items, $var = false, $ucwords = false) { if (is_array($items)) { if (strlen($var)) { $_items = array(); foreach ($items as $item) { $_items[] = $item->{$var}; } $items = $_items; } if ($ucwords) { $items = array_map('ucwords', $items); } switch (count($items)) { case 0: $list = ''; break; case 1: $list = $items[0]; break; case 2: $list = sprintf(__('%s and %s', 'seo-update'), $items[0], $items[1]); break; default: $last = array_pop($items); $list = implode(__(', ', 'seo-update'), $items); $list = sprintf(__('%s, and %s', 'seo-update'), $list, $last); break; } return apply_filters('su_lang_implode', $list, $items); } return $items; }
/** * determines the langauge settings of the browser, details see here: * http://aktuell.de.selfhtml.org/artikel/php/httpsprache/ */ function lang_getfrombrowser($allowed_languages, $default_language, $lang_variable = null, $strict_mode = true) { // $_SERVER['HTTP_ACCEPT_LANGUAGE'] verwenden, wenn keine Sprachvariable mitgegeben wurde if ($lang_variable === null && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $lang_variable = $_SERVER['HTTP_ACCEPT_LANGUAGE']; } // wurde irgendwelche Information mitgeschickt? if (empty($lang_variable)) { // Nein? => Standardsprache zurückgeben return $default_language; } // Den Header auftrennen $accepted_languages = preg_split('/,\\s*/', $lang_variable); // Die Standardwerte einstellen $current_lang = $default_language; $current_q = 0; // Nun alle mitgegebenen Sprachen abarbeiten foreach ($accepted_languages as $accepted_language) { // Alle Infos über diese Sprache rausholen $res = preg_match('/^([a-z]{1,8}(?:-[a-z]{1,8})*)' . '(?:;\\s*q=(0(?:\\.[0-9]{1,3})?|1(?:\\.0{1,3})?))?$/i', $accepted_language, $matches); // war die Syntax gültig? if (!$res) { // Nein? Dann ignorieren continue; } // Sprachcode holen und dann sofort in die Einzelteile trennen $lang_code = explode('-', $matches[1]); // Wurde eine Qualität mitgegeben? if (isset($matches[2])) { // die Qualität benutzen $lang_quality = (double) $matches[2]; } else { // Kompabilitätsmodus: Qualität 1 annehmen $lang_quality = 1.0; } // Bis der Sprachcode leer ist... while (count($lang_code)) { // mal sehen, ob der Sprachcode angeboten wird if (in_array(strtolower(join('-', $lang_code)), $allowed_languages)) { // Qualität anschauen if ($lang_quality > $current_q) { // diese Sprache verwenden $current_lang = strtolower(join('-', $lang_code)); $current_q = $lang_quality; // Hier die innere while-Schleife verlassen break; } } // Wenn wir im strengen Modus sind, die Sprache nicht versuchen zu minimalisieren if ($strict_mode) { // innere While-Schleife aufbrechen break; } // den rechtesten Teil des Sprachcodes abschneiden array_pop($lang_code); } } // die gefundene Sprache zurückgeben return $current_lang; }
function tplsadmin_copy_templates_db2db($tplset_from, $tplset_to, $whr_append = '1') { global $db; // get tplfile and tplsource $result = $db->query("SELECT tpl_refid,tpl_module,'" . addslashes($tplset_to) . "',tpl_file,tpl_desc,tpl_lastmodified,tpl_lastimported,tpl_type,tpl_source FROM " . $db->prefix("tplfile") . " NATURAL LEFT JOIN " . $db->prefix("tplsource") . " WHERE tpl_tplset='" . addslashes($tplset_from) . "' AND ({$whr_append})"); while ($row = $db->fetchArray($result)) { $tpl_source = array_pop($row); $drs = $db->query("SELECT tpl_id FROM " . $db->prefix("tplfile") . " WHERE tpl_tplset='" . addslashes($tplset_to) . "' AND ({$whr_append}) AND tpl_file='" . addslashes($row['tpl_file']) . "' AND tpl_refid='" . addslashes($row['tpl_refid']) . "'"); if (!$db->getRowsNum($drs)) { // INSERT mode $sql = "INSERT INTO " . $db->prefix("tplfile") . " (tpl_refid,tpl_module,tpl_tplset,tpl_file,tpl_desc,tpl_lastmodified,tpl_lastimported,tpl_type) VALUES ("; foreach ($row as $colval) { $sql .= "'" . addslashes($colval) . "',"; } $db->query(substr($sql, 0, -1) . ')'); $tpl_id = $db->getInsertId(); $db->query("INSERT INTO " . $db->prefix("tplsource") . " SET tpl_id='{$tpl_id}', tpl_source='" . addslashes($tpl_source) . "'"); altsys_template_touch($tpl_id); } else { while (list($tpl_id) = $db->fetchRow($drs)) { // UPDATE mode $db->query("UPDATE " . $db->prefix("tplfile") . " SET tpl_refid='" . addslashes($row['tpl_refid']) . "',tpl_desc='" . addslashes($row['tpl_desc']) . "',tpl_lastmodified='" . addslashes($row['tpl_lastmodified']) . "',tpl_lastimported='" . addslashes($row['tpl_lastimported']) . "',tpl_type='" . addslashes($row['tpl_type']) . "' WHERE tpl_id='{$tpl_id}'"); $db->query("UPDATE " . $db->prefix("tplsource") . " SET tpl_source='" . addslashes($tpl_source) . "' WHERE tpl_id='{$tpl_id}'"); altsys_template_touch($tpl_id); } } } }
/** * Methode to compile a Smarty template * * @param $_content template source * @return bool true if compiling succeeded, false if it failed */ protected function doCompile($_content) { /* here is where the compiling takes place. Smarty tags in the templates are replaces with PHP code, then written to compiled files. */ // init the lexer/parser to compile the template $this->lex = new $this->lexer_class($_content, $this); $this->parser = new $this->parser_class($this->lex, $this); if (isset($this->smarty->_parserdebug)) $this->parser->PrintTrace(); // get tokens from lexer and parse them while ($this->lex->yylex() && !$this->abort_and_recompile) { if (isset($this->smarty->_parserdebug)) echo "<pre>Line {$this->lex->line} Parsing {$this->parser->yyTokenName[$this->lex->token]} Token " . htmlentities($this->lex->value) . "</pre>"; $this->parser->doParse($this->lex->token, $this->lex->value); } if ($this->abort_and_recompile) { // exit here on abort return false; } // finish parsing process $this->parser->doParse(0, 0); // check for unclosed tags if (count($this->_tag_stack) > 0) { // get stacked info list($_open_tag, $_data) = array_pop($this->_tag_stack); $this->trigger_template_error("unclosed {" . $_open_tag . "} tag"); } // return compiled code // return str_replace(array("? >\n<?php","? ><?php"), array('',''), $this->parser->retvalue); return $this->parser->retvalue; }
/** * Truncates a string to the given length. It will optionally preserve * HTML tags if $is_html is set to true. * * @param string $string the string to truncate * @param int $limit the number of characters to truncate too * @param string $continuation the string to use to denote it was truncated * @param bool $is_html whether the string has HTML * @return string the truncated string */ public static function truncate($string, $limit, $continuation = '...', $is_html = false) { $offset = 0; $tags = array(); if ($is_html) { // Handle special characters. preg_match_all('/&[a-z]+;/i', strip_tags($string), $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER); foreach ($matches as $match) { if ($match[0][1] >= $limit) { break; } $limit += static::length($match[0][0]) - 1; } // Handle all the html tags. preg_match_all('/<[^>]+>([^<]*)/', $string, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER); foreach ($matches as $match) { if ($match[0][1] - $offset >= $limit) { break; } $tag = static::sub(strtok($match[0][0], " \t\n\r\v>"), 1); if ($tag[0] != '/') { $tags[] = $tag; } elseif (end($tags) == static::sub($tag, 1)) { array_pop($tags); } $offset += $match[1][1] - $match[0][1]; } } $new_string = static::sub($string, 0, $limit = min(static::length($string), $limit + $offset)); $new_string .= static::length($string) > $limit ? $continuation : ''; $new_string .= count($tags = array_reverse($tags)) ? '</' . implode('></', $tags) . '>' : ''; return $new_string; }
public function getCurrentPattern() { $patterns = $this->getAttribute('patterns', array(), 'psdf'); $pattern = array_pop($patterns); $this->setAttribute('patterns', $patterns, 'psdf'); return $pattern; }
/** Creates directory or throws exception on fail * @param string $pathname * @param int $mode Mode in octal * @return bool */ public static function create($pathname, $mode = self::MOD_DEFAULT) { if (strpos($pathname, '/') !== false) { $pathname = explode('/', $pathname); } if (is_array($pathname)) { $current_dir = ''; $create = array(); do { $current_dir = implode('/', $pathname); if (is_dir($current_dir)) { break; } $create[] = array_pop($pathname); } while (any($pathname)); if (any($create)) { $create = array_reverse($create); $current_dir = implode('/', $pathname); foreach ($create as $dir) { $current_dir .= '/' . $dir; if (!is_dir($current_dir)) { if (!($action = @mkdir($current_dir, $mode))) { throw new \System\Error\Permissions(sprintf('Failed to create directory on path "%s" in mode "%s". Please check your permissions.', $current_dir, base_convert($mode, 10, 8))); } } } } } else { if (!($action = @mkdir($pathname, $mode, true))) { throw new \System\Error\Permissions(sprintf('Failed to create directory on path "%s" in mode "%s". Please check your permissions.', $pathname, base_convert($mode, 10, 8))); } } return $action; }
/** * Write a button drop down control. * * @param array $Links An array of arrays with the following keys: * - Text: The text of the link. * - Url: The url of the link. * @param string|array $CssClass The css class of the link. This can be a two-item array where the second element will be added to the buttons. * @param string $Label The text of the button. * @since 2.1 */ function buttonDropDown($Links, $CssClass = 'Button', $Label = false) { if (!is_array($Links) || count($Links) < 1) { return; } $ButtonClass = ''; if (is_array($CssClass)) { list($CssClass, $ButtonClass) = $CssClass; } if (count($Links) < 2) { $Link = array_pop($Links); if (strpos(GetValue('CssClass', $Link, ''), 'Popup') !== false) { $CssClass .= ' Popup'; } echo Anchor($Link['Text'], $Link['Url'], GetValue('ButtonCssClass', $Link, $CssClass)); } else { // NavButton or Button? $ButtonClass = ConcatSep(' ', $ButtonClass, strpos($CssClass, 'NavButton') !== false ? 'NavButton' : 'Button'); if (strpos($CssClass, 'Primary') !== false) { $ButtonClass .= ' Primary'; } // Strip "Button" or "NavButton" off the group class. echo '<div class="ButtonGroup' . str_replace(array('NavButton', 'Button'), array('', ''), $CssClass) . '">'; // echo Anchor($Text, $Url, $ButtonClass); echo '<ul class="Dropdown MenuItems">'; foreach ($Links as $Link) { echo wrap(Anchor($Link['Text'], $Link['Url'], val('CssClass', $Link, '')), 'li'); } echo '</ul>'; echo anchor($Label . ' ' . sprite('SpDropdownHandle'), '#', $ButtonClass . ' Handle'); echo '</div>'; } }
public static function run() { foreach (glob(app_path() . '/Http/Controllers/*.php') as $filename) { $file_parts = explode('/', $filename); $file = array_pop($file_parts); $file = rtrim($file, '.php'); if ($file == 'Controller') { continue; } $controllerName = 'App\\Http\\Controllers\\' . $file; $controller = new $controllerName(); if (isset($controller->exclude) && $controller->exclude === true) { continue; } $methods = []; $reflector = new \ReflectionClass($controller); foreach ($reflector->getMethods(\ReflectionMethod::IS_PUBLIC) as $rMethod) { // check whether method is explicitly defined in this class if ($rMethod->getDeclaringClass()->getName() == $reflector->getName()) { $methods[] = $rMethod->getName(); } } \Route::resource(strtolower(str_replace('Controller', '', $file)), $file, ['only' => $methods]); } }
/** * Restore the most recently pushed set of templates. * * @return void */ public function pop() { if (empty($this->_configStack)) { return; } list($this->_config, $this->_compiled) = array_pop($this->_configStack); }
public function testLogSave() { $timed = $this->_getMemoryMock(); $a = array(); $timed->save($a); $this->assertContains('Kolab Format data generation complete. Memory usage:', array_pop($this->logger->log)); }
public function run() { //TODO: genericise this behaviour $cls_name = explode('\\', get_class($this)); $this->shortName = array_pop($cls_name); if (file_exists(dirname(__FILE__) . '/js/' . $this->shortName . '.js')) { $this->assetFolder = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . '/js/'); Yii::app()->getClientScript()->registerScriptFile($this->assetFolder . '/' . $this->shortName . '.js'); Yii::app()->getAssetManager()->registerCssFile('css/module.css', 'application.modules.PatientTicketing.assets', 10, \AssetManager::OUTPUT_ALL); } if ($this->ticket) { $this->event_types = $this->ticket->current_queue->getRelatedEventTypes(); $this->ticket_info = $this->ticket->getInfoData(false); $this->current_queue_name = $this->ticket->current_queue->name; $this->outcome_options = array(); $od = $this->ticket->current_queue->getOutcomeData(false); foreach ($od as $out) { $this->outcome_options[$out['id']] = $out['name']; } if (count($od) == 1) { $this->outcome_queue_id = $od[0]['id']; } } $this->render('TicketMove'); }
function archive($id = null) { $modelClass = $this->modelClass; // get the name of the current model $user_id = $this->Auth->user('id'); // get user id from session $archive_model = "Archive" . $modelClass; // get the record from the database eval('$data = $this->' . $modelClass . '->read(null, ' . $id . ');'); // Because of the formatting of the return , need this to get the values $data = $data[$modelClass]; $data_out = array(); // go trough all the records and changing the names so that they get the prefix archive_ foreach (array_keys($data) as $keys) { $key = 'archive_' . $keys; $data_out[$key] = $data[$keys]; } $data_out['user_id'] = $user_id; // add the user id if (!empty($this->data)) { // If edited we want to get the archive reason // Extract the reason field from the $this->data array eval('$reason = Set::extract("/' . $modelClass . '/archive_reason", $this->data);'); $data_out['archive_reason'] = array_pop($reason); } // Need to format the array we want to save this way $save[$archive_model] = $data_out; // create a new record and save the data eval('$this->' . $archive_model . '->create();'); eval('$this->' . $archive_model . '->save($save);'); }
function content_565ead2acc18a3_66288090($_smarty_tpl) { echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('wishlistProductsIds' => $_smarty_tpl->tpl_vars['wishlist_products']->value), $_smarty_tpl); $_smarty_tpl->smarty->_tag_stack[] = array('addJsDefL', array('name' => 'loggin_required')); $_block_repeat = true; echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'loggin_required'), null, $_smarty_tpl, $_block_repeat); while ($_block_repeat) { ob_start(); echo smartyTranslate(array('s' => 'You must be logged in to manage your wishlist.', 'mod' => 'blockwishlist', 'js' => 1), $_smarty_tpl); $_block_content = ob_get_clean(); $_block_repeat = false; echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'loggin_required'), $_block_content, $_smarty_tpl, $_block_repeat); } array_pop($_smarty_tpl->smarty->_tag_stack); $_smarty_tpl->smarty->_tag_stack[] = array('addJsDefL', array('name' => 'added_to_wishlist')); $_block_repeat = true; echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'added_to_wishlist'), null, $_smarty_tpl, $_block_repeat); while ($_block_repeat) { ob_start(); echo smartyTranslate(array('s' => 'The product was successfully added to your wishlist.', 'mod' => 'blockwishlist', 'js' => 1), $_smarty_tpl); $_block_content = ob_get_clean(); $_block_repeat = false; echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'added_to_wishlist'), $_block_content, $_smarty_tpl, $_block_repeat); } array_pop($_smarty_tpl->smarty->_tag_stack); echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('mywishlist_url' => preg_replace("%(?<!\\\\)'%", "\\'", $_smarty_tpl->tpl_vars['link']->value->getModuleLink('blockwishlist', 'mywishlist', array(), true))), $_smarty_tpl); ?> <?php }
/** * @dataProvider providerCodePage */ public function testCodePageNumberToName() { $args = func_get_args(); $expectedResult = array_pop($args); $result = call_user_func_array(array('PHPExcel_Shared_CodePage', 'NumberToName'), $args); $this->assertEquals($expectedResult, $result); }
/** * Singletons factory * * @param int|array|null $userIdOrConditions [optional] default: NULL: viewing user, int: User-id (0: guest), array: Criteria, e.g. array( 'username' => 'uniqueUsername' ) or array( 'email' => 'uniqueEmail' ) * @return self|boolean Boolean FALSE if user does not exist (and userId not 0) */ public static function getInstance($userIdOrConditions = null) { if ($userIdOrConditions === null) { $userId = static::getMyId(); } elseif (is_array($userIdOrConditions)) { if (count($userIdOrConditions) == 1 && array_keys($userIdOrConditions) == array('username')) { $jUser = \JUser::getInstance($userIdOrConditions['username']); if ($jUser == false) { return false; } $userId = (int) $jUser->id; } else { $ids = static::getIds($userIdOrConditions, null, 0, 2); if (is_array($ids) && count($ids) == 1) { $userId = (int) array_pop($ids); } else { return false; } } } else { $userId = (int) $userIdOrConditions; } if (!isset(static::$cmsUsers[$userId])) { $self = new static($userId); if ($userId == 0) { return $self; } static::$cmsUsers[$userId] = $self; } return static::$cmsUsers[$userId]; }
/** * Echo data from executed command */ public function output($data) { $this->_out = $data; if ('stdout' === $this->_logStream) { if (is_string($data)) { echo $data . "<br/>" . str_repeat(" ", 256); } elseif (is_array($data)) { $data = array_pop($data); if (!empty($data['message']) && is_string($data['message'])) { echo $data['message'] . "<br/>" . str_repeat(" ", 256); } elseif (!empty($data['data'])) { if (is_string($data['data'])) { echo $data['data'] . "<br/>" . str_repeat(" ", 256); } else { if (isset($data['title'])) { echo $data['title'] . "<br/>" . str_repeat(" ", 256); } if (is_array($data['data'])) { foreach ($data['data'] as $row) { foreach ($row as $msg) { echo " " . $msg; } echo "<br/>" . str_repeat(" ", 256); } } else { echo " " . $data['data']; } } } } else { print_r($data); } } }
/** * get a new view-part instance * @param View $view */ public function __construct(View $view) { $this->_view = $view; $viewPart = explode('\\', get_class($this)); $this->_direct = array_pop($viewPart); return $this; }
private function execute() { $this->prepareBaseValues(); $listingsProducts = $this->getNextListingsProducts(); if (count($listingsProducts) <= 0) { $lastTime = strtotime($this->getLastTimeStartCircle()); $interval = $this->getMinIntervalBetweenCircles(); if ($lastTime + $interval > Mage::helper('M2ePro')->getCurrentGmtDate(true)) { return; } $this->setLastListingProductId(0); $this->resetLastTimeStartCircle(); $listingsProducts = $this->getNextListingsProducts(); if (count($listingsProducts) <= 0) { return; } } $tempIndex = 0; $totalItems = count($listingsProducts); foreach ($listingsProducts as $listingProduct) { $this->updateListingsProductChange($listingProduct); if (++$tempIndex % 20 == 0) { $percentsPerOneItem = self::PERCENTS_INTERVAL / $totalItems; $this->_lockItem->setPercents($percentsPerOneItem * $tempIndex); $this->_lockItem->activate(); } } $listingProduct = array_pop($listingsProducts); $this->setLastListingProductId($listingProduct->getId()); }
public function testXPath() { // Create new customer profile $request = new AuthorizeNetCIM; $customerProfile = new AuthorizeNetCustomer; $customerProfile->description = $description = "Some Description of customer 2"; $customerProfile->merchantCustomerId = $merchantCustomerId = time().rand(1,150); $customerProfile->email = $email = "*****@*****.**"; // Add payment profile. $paymentProfile = new AuthorizeNetPaymentProfile; $paymentProfile->customerType = "individual"; $paymentProfile->payment->creditCard->cardNumber = "4111111111111111"; $paymentProfile->payment->creditCard->expirationDate = "2021-04"; $customerProfile->paymentProfiles[] = $paymentProfile; $response = $request->createCustomerProfile($customerProfile); $this->assertTrue($response->isOk()); $array = $response->xpath('customerProfileId'); $this->assertEquals($response->getCustomerProfileId(), "{$array[0]}"); $profile = $request->getCustomerProfile($response->getCustomerProfileId()); $this->assertEquals($email, (string)array_pop($profile->xpath('profile/email'))); $this->assertEquals($email, (string)array_pop($profile->xpath('profile/email'))); $this->assertEquals($description, (string)array_pop($profile->xpath('profile/description'))); $this->assertEquals($merchantCustomerId, (string)array_pop($profile->xpath('profile/merchantCustomerId'))); }
/** * Returns an array of found directories * * This function checks every found directory if they match either $uid or $gid, if they do * the found directory is valid. It uses recursive function calls to find subdirectories. Due * to the recursive behauviour this function may consume much memory. * * @param string path The path to start searching in * @param integer uid The uid which must match the found directories * @param integer gid The gid which must match the found direcotries * @param array _fileList recursive transport array !for internal use only! * @return array Array of found valid pathes * * @author Martin Burchert <*****@*****.**> * @author Manuel Bernhardt <*****@*****.**> */ function findDirs($path, $uid, $gid) { $list = array($path); $_fileList = array(); while (sizeof($list) > 0) { $path = array_pop($list); $path = makeCorrectDir($path); $dh = opendir($path); if ($dh === false) { standard_error('cannotreaddir', $path); return null; } else { while (false !== ($file = @readdir($dh))) { if ($file == '.' && (fileowner($path . '/' . $file) == $uid || filegroup($path . '/' . $file) == $gid)) { $_fileList[] = makeCorrectDir($path); } if (is_dir($path . '/' . $file) && $file != '..' && $file != '.') { array_push($list, $path . '/' . $file); } } @closedir($dh); } } return $_fileList; }
/** * @param string $name * @return object */ public function getClassInfo($name) { $explodedClassNamespace = explode('\\', $name); $className = array_pop($explodedClassNamespace); $fullNamespace = join('\\', $explodedClassNamespace); return (object) ['namespace' => $fullNamespace, 'className' => $className]; }
function beforeLoad(&$params) { $basePath = JPATH_CONFIGURATION . '/administrator/components/com_jckman/editor/lang'; $languages = JFolder::files($basePath, '.js$', 1, true); $js = ""; $default = $params->get("joomlaLang", "en"); foreach ($languages as $language) { $content = file_get_contents($language); $content = preg_replace("/\\/\\*.*?\\*\\//s", "", $content); $content = str_replace('"', "'", $content); $language = str_replace("\\", "/", $language); $parts = explode("/", $language); $lang = preg_replace("/\\.js\$/", "", array_pop($parts)); $plugin = array_pop($parts); if ($lang != $default && $lang != 'en' || $plugin == 'lang') { //make sure we always load in default english file continue; } $content = preg_replace("/\\)\$/", ");", trim($content)); if ($plugin == 'jflash') { $plug = 'flash'; } else { $plug = $plugin; } $js .= "CKEDITOR.on('" . $plugin . "PluginLoaded', function(evt)\r\n {\r\n editor.lang." . $plug . " = null;\r\n evt.data.lang = ['" . $default . "']; \r\n " . $content . " \r\n });"; } //lets create JS object $javascript = new JCKJavascript(); $javascript->addScriptDeclaration($js); return $javascript->toRaw(); }
public static function NewStr($FinallyStr) { if (preg_match('/[^a-z0-9]/i', $FinallyStr)) { return false; } $StrLength = strlen($FinallyStr); if ($StrLength < 0) { return false; } $NewArr = array(); $i = 0; $AnStr = str_split($FinallyStr); $obj = new str_increment(); //instantiation self do { $NewAnStr = $obj->Calculation(array_pop($AnStr)); ++$i; $IsDo = false; if ($NewAnStr !== false) { if ($NewAnStr === $obj->Table[0]) { if ($i < $StrLength) { $IsDo = true; } } $NewArr[] = $NewAnStr; } } while ($IsDo); $ObverseStr = implode('', $AnStr) . implode('', array_reverse($NewArr)); if (self::$FirstRandomCode) { $ObverseStr = $obj->ReplaceFirstCode($ObverseStr); } return $StrLength == strlen($ObverseStr) ? $ObverseStr : false; }
function plugin_skype_inline() { $options = $this->conf['options']; $args = func_get_args(); $alias = array_pop($args); $this->fetch_options($options, $args, array('id')); if (!$options['id']) { return FALSE; } else { $id = $this->func->htmlspecialchars($options['id']); } if (!$alias) { $alias = $id; } foreach ($this->conf['modes'] as $mode) { if (!empty($options[$mode])) { break; } } if ($options['status']) { foreach ($this->conf['statuses'] as $status) { if ($options['status'] === $status) { break; } } } else { $status = ''; } $image = ''; if ($status) { $image = '<img src="http://mystatus.skype.com/' . $status . '/' . $id . '" />'; } $link = 'skype:' . $id . '?' . $mode; return str_replace(array('$image', '$link', '$alias'), array($image, $link, $alias), $this->conf['format']); }
/** * @inheritdoc * * @param array $arguments */ public function process_call($arguments) { $am = $this->get_am(); $am->ajax_begin(array('nonce' => $am->get_action_js_name(Types_Ajax::CALLBACK_SETTINGS_ACTION))); $setting = sanitize_text_field(wpcf_getpost('setting')); $setting_value = wpcf_getpost('setting_value'); if (!is_array($setting_value)) { parse_str($setting_value, $setting_value); $setting_value = array_pop($setting_value); } $sanitized_value = array(); foreach ($setting_value as $key => $value) { $sanitized_key = sanitize_title($key); $sanitized_value[$sanitized_key] = sanitize_text_field($value); } // use toolset settings if available if (class_exists('Toolset_Settings') && method_exists('Toolset_Settings', 'get_instance')) { $toolset_settings = Toolset_Settings::get_instance(); if (method_exists($toolset_settings, 'save')) { $toolset_settings[$setting] = $sanitized_value; $toolset_settings->save(); $am->ajax_finish('success', true); } } else { update_option($setting, $sanitized_value); $am->ajax_finish('success', true); } // default toolset setting error will be used // todo throw specific error $am->ajax_finish(array('error'), false); }