/** * Zips two or more sequences * * @param array|\Traversable $sequence1 * @param array|\Traversable $sequence2 * @return array */ function zip($sequence1, $sequence2) { $lists = func_get_args(); $count = func_num_args(); for ($j = 0; $j < $count; ++$j) { args\expects(args\traversable, $lists[$j], $j + 1); $lists[$j] = ds\traversableToArray($lists[$j]); if (!ds\isList($lists[$j])) { $lists[$j] = array_values($lists[$j]); } } $i = 0; $result = array(); do { $zipped = array(); for ($j = 0; $j < $count; ++$j) { if (!isset($lists[$j][$i]) && !array_key_exists($i, $lists[$j])) { break 2; } $zipped[] = $lists[$j][$i]; } $result[] = $zipped; ++$i; } while (true); return $result; }
/** * Default constructor * @param value some value */ function __construct() { $args = func_get_args(); if (func_num_args() == 1) { $this->init($args[0]); } }
/** * Carrega a página "/views/user-register/index.php" */ public function index() { // Page title $this->title = 'User Register'; // Verifica se o usuário está logado if (!$this->logged_in) { // Se não; garante o logout $this->logout(); // Redireciona para a página de login $this->goto_login(); // Garante que o script não vai passar daqui return; } // Verifica se o usuário tem a permissão para acessar essa página if (!$this->check_permissions($this->permission_required, $this->userdata['user_permissions'])) { // Exibe uma mensagem echo 'Você não tem permissões para acessar essa página.'; // Finaliza aqui return; } // Parametros da função $parametros = func_num_args() >= 1 ? func_get_arg(0) : array(); // Carrega o modelo para este view $modelo = $this->load_model('user-register/user-register-model'); /** Carrega os arquivos do view **/ // /views/_includes/header.php require ABSPATH . '/views/_includes/header.php'; // /views/_includes/menu.php require ABSPATH . '/views/_includes/menu.php'; // /views/user-register/index.php require ABSPATH . '/views/user-register/user-register-view.php'; // /views/_includes/footer.php require ABSPATH . '/views/_includes/footer.php'; }
/** * Returns a specific character in UTF-8. * @param int codepoint * @return string */ public static function chr($code) { if (func_num_args() > 1 && strcasecmp(func_get_arg(1), 'UTF-8')) { trigger_error(__METHOD__ . ' supports only UTF-8 encoding.', E_USER_DEPRECATED); } return iconv('UTF-32BE', 'UTF-8//IGNORE', pack('N', $code)); }
/** * Set asset url path * * @param string $path * @param null $packageName * @param null $version * @param bool|false $absolute * @param bool|false $ignorePrefix * * @return string */ public function getUrl($path, $packageName = null, $version = null) { // Dirty hack to work around strict notices with parent::getUrl $absolute = $ignorePrefix = false; if (func_num_args() > 3) { $args = func_get_args(); $absolute = $args[3]; if (isset($args[4])) { $ignorePrefix = $args[4]; } } // if we have http in the url it is absolute and we can just return it if (strpos($path, 'http') === 0) { return $path; } // otherwise build the complete path if (!$ignorePrefix) { $assetPrefix = $this->getAssetPrefix(strpos($path, '/') !== 0); $path = $assetPrefix . $path; } $url = parent::getUrl($path, $packageName, $version); if ($absolute) { $url = $this->getBaseUrl() . $url; } return $url; }
public function dump(\Twig_Environment $env, $context) { if (!$env->isDebug()) { return; } if (2 === func_num_args()) { $vars = array(); foreach ($context as $key => $value) { if (!$value instanceof \Twig_Template) { $vars[$key] = $value; } } $vars = array($vars); } else { $vars = func_get_args(); unset($vars[0], $vars[1]); } $dump = fopen('php://memory', 'r+b'); $dumper = new HtmlDumper($dump); foreach ($vars as $value) { $dumper->dump($this->cloner->cloneVar($value)); } rewind($dump); return stream_get_contents($dump); }
/** * Creates a new user from the "Users" form using $_POST information. * * It seems that the first half is for backwards compatibility, but only * has the ability to alter the user's role. WordPress core seems to * use this function only in the second way, running edit_user() with * no id so as to create a new user. * * @since 2.0 * * @param int $user_id Optional. User ID. * @return null|WP_Error|int Null when adding user, WP_Error or User ID integer when no parameters. */ function add_user() { if (func_num_args()) { // The hackiest hack that ever did hack global $current_user, $wp_roles; $user_id = (int) func_get_arg(0); if (isset($_POST['role'])) { $new_role = sanitize_text_field($_POST['role']); // Don't let anyone with 'edit_users' (admins) edit their own role to something without it. if ($user_id != $current_user->id || $wp_roles->role_objects[$new_role]->has_cap('edit_users')) { // If the new role isn't editable by the logged-in user die with error $editable_roles = get_editable_roles(); if (empty($editable_roles[$new_role])) { wp_die(__('You can’t give users that role.')); } $user = new WP_User($user_id); $user->set_role($new_role); } } } else { add_action('user_register', 'add_user'); // See above return edit_user(); } }
/** * Set the browser cookie * @param string $name The name of the cookie. * @param string $value The value to be stored in the cookie. * @param int|null $expire Unix timestamp (in seconds) when the cookie should expire. * 0 (the default) causes it to expire $wgCookieExpiration seconds from now. * null causes it to be a session cookie. * @param array $options Assoc of additional cookie options: * prefix: string, name prefix ($wgCookiePrefix) * domain: string, cookie domain ($wgCookieDomain) * path: string, cookie path ($wgCookiePath) * secure: bool, secure attribute ($wgCookieSecure) * httpOnly: bool, httpOnly attribute ($wgCookieHttpOnly) * raw: bool, if true uses PHP's setrawcookie() instead of setcookie() * For backwards compatibility, if $options is not an array then it and * the following two parameters will be interpreted as values for * 'prefix', 'domain', and 'secure' * @since 1.22 Replaced $prefix, $domain, and $forceSecure with $options */ public function setcookie($name, $value, $expire = 0, $options = array()) { global $wgCookiePath, $wgCookiePrefix, $wgCookieDomain; global $wgCookieSecure, $wgCookieExpiration, $wgCookieHttpOnly; if (!is_array($options)) { // Backwards compatibility $options = array('prefix' => $options); if (func_num_args() >= 5) { $options['domain'] = func_get_arg(4); } if (func_num_args() >= 6) { $options['secure'] = func_get_arg(5); } } $options = array_filter($options, function ($a) { return $a !== null; }) + array('prefix' => $wgCookiePrefix, 'domain' => $wgCookieDomain, 'path' => $wgCookiePath, 'secure' => $wgCookieSecure, 'httpOnly' => $wgCookieHttpOnly, 'raw' => false); if ($expire === null) { $expire = 0; // Session cookie } elseif ($expire == 0 && $wgCookieExpiration != 0) { $expire = time() + $wgCookieExpiration; } $func = $options['raw'] ? 'setrawcookie' : 'setcookie'; if (Hooks::run('WebResponseSetCookie', array(&$name, &$value, &$expire, $options))) { wfDebugLog('cookie', $func . ': "' . implode('", "', array($options['prefix'] . $name, $value, $expire, $options['path'], $options['domain'], $options['secure'], $options['httpOnly'])) . '"'); call_user_func($func, $options['prefix'] . $name, $value, $expire, $options['path'], $options['domain'], $options['secure'], $options['httpOnly']); } }
/** * Dequeues one or several values from the beginning of the Queue * * When called without argument, returns a single value, else returns an array. * If there is not anough elements in the queue, all the elements are returned * without raising any error. * * @param int $quantity * * @return mixed */ public function dequeue($quantity = 1) { if (!func_num_args()) { return array_pop($this->elements); } return array_splice($this->elements, max(0, count($this->elements) - $quantity), $quantity, []); }
public static function parse($parser) { $parser->disableCache(); $title = $parser->getTitle()->getText(); $titleArray = explode(':', $title); $ontAbbr = $titleArray[0]; $termID = str_replace(' ', '_', $titleArray[1]); $ontology = new OntologyData($ontAbbr); $term = $ontology->parseTermByID($termID); $params = array(); for ($i = 2; $i < func_num_args(); $i++) { $params[] = func_get_arg($i); } list($options, $valids, $invalids) = self::extractSupClass($params, $ontology); $pathType = $GLOBALS['okwHierarchyConfig']['pathType']; $supClasses = array(); if (!empty($valids)) { foreach ($valids as $index => $value) { $supClasses[] = $value['iri']; $hierarchy = $ontology->parseTermHierarchy($term, $pathType, $value['iri']); if ($value['iri'] == $GLOBALS['okwRDFConfig']['Thing']) { $GLOBALS['okwCache']['hierarchy'][$index] = $hierarchy; } else { foreach ($hierarchy as $path) { if (!empty($path['path'])) { $GLOBALS['okwCache']['hierarchy'][$index] = $hierarchy; } } } } } wfDebugLog('OntoKiWi', sprintf('OKW\\Parser\\HierarchyParser: parsed hierarchy {%s} for [[%s]]', join(';', $supClasses), $title)); wfDebugLog('OntoKiWi', '[caches] OKW\\Parser\\HierarchyParser: hierarchy'); return array('', 'noparse' => true); }
protected final function __new__() { parent::__new__(func_num_args() > 0 ? func_get_arg(0) : null); $this->o('Template')->cp($this->vars); $this->request_url = parent::current_url(); $this->request_query = parent::query_string() == null ? null : '?' . parent::query_string(); }
public static function checkRights() { //print_r(func_get_args()); if (func_num_args() == 0) { return true; } //print_r($_SESSION['user']); if (empty($_SESSION['user'])) { return false; } $right = $_SESSION['user']['type']; //echo $right; if ($right == USR_ADMIN) { return true; } $right_groups = func_get_args(); // print_r($right_groups); if (empty($right_groups)) { return false; } /* foreach($right_groups as $group){ if(is_array($group)) if($group==$right) return true; } return false; */ return UserRights::checkRight($right_groups, $right); }
/** * Creates an exception using a formatted message. * * @param string $format The message format. * @param mixed $value,... A value. * * @return static The exception. */ public static function format($format, $value = null) { if (1 < func_num_args()) { $format = vsprintf($format, array_slice(func_get_args(), 1)); } return new static($format); }
/** * @param bool|null $onlyForAjaxRequests * @return null|bool */ public function onlyForAjaxRequests($onlyForAjaxRequests = null) { if (func_num_args() == 0) { return $this->onlyForAjaxRequests; } $this->onlyForAjaxRequests = (bool) $onlyForAjaxRequests; }
/** * Default logger method logging to STDOUT. * This is the default/reference implementation of a logger. * This method will write the message value to STDOUT (screen) unless * you have changed the mode of operation to C_LOGGER_ARRAY. * * @param $message (optional) message to log (might also be data or output) * * @return void */ public function log() { if (func_num_args() < 1) { return; } foreach (func_get_args() as $argument) { if (is_array($argument)) { $log = print_r($argument, TRUE); if ($this->mode === self::C_LOGGER_ECHO) { echo $log; } else { $this->logs[] = $log; } } else { if ($this->mode === self::C_LOGGER_ECHO) { echo $argument; } else { $this->logs[] = $argument; } } if ($this->mode === self::C_LOGGER_ECHO) { echo "<br>\n"; } } }
function plugin_lookup_convert() { global $vars; static $id = 0; $num = func_num_args(); if ($num == 0 || $num > 3) { return PLUGIN_LOOKUP_USAGE; } $args = func_get_args(); $interwiki = htmlsc(trim($args[0])); $button = isset($args[1]) ? trim($args[1]) : ''; $button = $button != '' ? htmlsc($button) : 'lookup'; $default = $num > 2 ? htmlsc(trim($args[2])) : ''; $s_page = htmlsc($vars['page']); ++$id; $script = get_script_uri(); $ret = <<<EOD <form action="{$script}" method="post"> <div> <input type="hidden" name="plugin" value="lookup" /> <input type="hidden" name="refer" value="{$s_page}" /> <input type="hidden" name="inter" value="{$interwiki}" /> <label for="_p_lookup_{$id}">{$interwiki}:</label> <input type="text" name="page" id="_p_lookup_{$id}" size="30" value="{$default}" /> <input type="submit" value="{$button}" /> </div> </form> EOD; return $ret; }
/** * dijit.layout.StackContainer * * @param string $id * @param string $content * @param array $params Parameters to use for dijit creation * @param array $attribs HTML attributes * @return string */ public function stackContainer($id = null, $content = '', array $params = array(), array $attribs = array()) { if (0 === func_num_args()) { return $this; } return $this->_createLayoutContainer($id, $content, $params, $attribs); }
/** * Verify the incoming request's user has a subscription. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string $subscription * @param string $plan * @return \Illuminate\Http\Response */ public function handle($request, $next, $subscription = 'default', $plan = null) { if ($this->subscribed($request->user(), $subscription, $plan, func_num_args() === 2)) { return $next($request); } return $request->ajax() || $request->wantsJson() ? response('Subscription Required.', 402) : redirect('/settings#/subscription'); }
public function Invoke($arguments = null) { if (!is_array($arguments) || func_num_args() > 1) { $arguments = func_get_args(); } return $this->InvokeInternal($arguments); }
public function __construct() { if (func_num_args() == 1) { $this->setDefaultValue(func_get_arg(0)); $this->setHumanValue(func_get_arg(0)); } }
/** * Init the minify class - optionally, code may be passed along already. */ public function __construct() { // it's possible to add the source through the constructor as well ;) if (func_num_args()) { call_user_func_array(array($this, 'add'), func_get_args()); } }
/** * Sends an error message to the collector for later use * @param $line Integer line number, or HTMLPurifier_Token that caused error * @param $severity int Error severity, PHP error style (don't use E_USER_) * @param $msg string Error message text */ function send($severity, $msg) { $args = array(); if (func_num_args() > 2) { $args = func_get_args(); array_shift($args); unset($args[0]); } $token = $this->context->get('CurrentToken', true); $line = $token ? $token->line : $this->context->get('CurrentLine', true); $attr = $this->context->get('CurrentAttr', true); // perform special substitutions, also add custom parameters $subst = array(); if (!is_null($token)) { $args['CurrentToken'] = $token; } if (!is_null($attr)) { $subst['$CurrentAttr.Name'] = $attr; if (isset($token->attr[$attr])) { $subst['$CurrentAttr.Value'] = $token->attr[$attr]; } } if (empty($args)) { $msg = $this->locale->getMessage($msg); } else { $msg = $this->locale->formatMessage($msg, $args); } if (!empty($subst)) { $msg = strtr($msg, $subst); } $this->errors[] = array($line, $severity, $msg); }
/** * execute query - show be regarded as private to insulate the rest of * the application from sql differences * @access private */ function query($sql) { global $CONF; if (is_null($this->dblink)) { $this->_connect(); } //been passed more parameters? do some smart replacement if (func_num_args() > 1) { //query contains ? placeholders, but it's possible the //replacement string have ? in too, so we replace them in //our sql with something more unique $q = md5(uniqid(rand(), true)); $sql = str_replace('?', $q, $sql); $args = func_get_args(); for ($i = 1; $i <= count($args); $i++) { $sql = preg_replace("/{$q}/", "'" . preg_quote(mysql_real_escape_string($args[$i])) . "'", $sql, 1); } //we shouldn't have any $q left, but it will help debugging if we change them back! $sql = str_replace($q, '?', $sql); } $this->dbresult = mysql_query($sql, $this->dblink); if (!$this->dbresult) { die("Query failure: " . mysql_error() . "<br />{$sql}"); } return $this->dbresult; }
function gitDir() { if (func_num_args()) { $this->gitDir = func_get_arg(0); } return $this->gitDir; }
/** * Sets validator options * * @param array|Zend_Config $haystack * @return void */ public function __construct($options) { if ($options instanceof Zend_Config) { $options = $options->toArray(); } else { if (!is_array($options)) { require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception('Array expected as parameter'); } else { $count = func_num_args(); $temp = array(); if ($count > 1) { $temp['haystack'] = func_get_arg(0); $temp['strict'] = func_get_arg(1); $options = $temp; } else { $temp = func_get_arg(0); if (!array_key_exists('haystack', $options)) { $options = array(); $options['haystack'] = $temp; } else { $options = $temp; } } } } $this->setHaystack($options['haystack']); if (array_key_exists('strict', $options)) { $this->setStrict($options['strict']); } if (array_key_exists('recursive', $options)) { $this->setRecursive($options['recursive']); } }
/** * Processes the dump variables, if none is supplied, all the twig * template variables are used * @param Twig_Environment $env * @param array $context * @return string */ public function runDump(Twig_Environment $env, $context) { if (!$env->isDebug()) { return; } $result = ''; $count = func_num_args(); if ($count == 2) { $this->variablePrefix = true; $vars = []; foreach ($context as $key => $value) { if (!$value instanceof Twig_Template) { $vars[$key] = $value; } } $result .= $this->dump($vars, static::PAGE_CAPTION); } else { $this->variablePrefix = false; for ($i = 2; $i < $count; $i++) { $var = func_get_arg($i); if ($var instanceof ComponentBase) { $caption = [static::COMPONENT_CAPTION, get_class($var)]; } elseif (is_array($var)) { $caption = static::ARRAY_CAPTION; } elseif (is_object($var)) { $caption = [static::OBJECT_CAPTION, get_class($var)]; } else { $caption = [static::OBJECT_CAPTION, gettype($var)]; } $result .= $this->dump($var, $caption); } } return $result; }
/** * Smarty strip_tags modifier plugin * * Type: modifier * Name: strip_tags * Purpose: strip html tags from text * @link http://www.smarty.net/manual/en/language.modifier.strip.tags.php * strip_tags (Smarty online manual) * * @author Monte Ohrt <monte at="" ohrt="" dot="" com=""> * @author Jordon Mears <jordoncm at="" gmail="" dot="" com=""> * * @version 2.0 * * @param string * @param boolean optional * @param string optional * @return string */ function smarty_modifier_stripTags($string) { switch (func_num_args()) { case 1: $replace_with_space = true; break; case 2: $arg = func_get_arg(1); if ($arg === 1 || $arg === true || $arg === '1' || $arg === 'true') { // for full legacy support || $arg === 'false' should be included $replace_with_space = true; $allowable_tags = ''; } elseif ($arg === 0 || $arg === false || $arg === '0' || $arg === 'false') { // for full legacy support || $arg === 'false' should be removed $replace_with_space = false; $allowable_tags = ''; } else { $replace_with_space = true; $allowable_tags = $arg; } break; case 3: $replace_with_space = func_get_arg(1); $allowable_tags = func_get_arg(2); break; } if ($replace_with_space) { $string = preg_replace('!(<[^>]*?>)!', '$1 ', $string); } $string = strip_tags($string, $allowable_tags); if ($replace_with_space) { $string = preg_replace('!(<[^>]*?>) !', '$1', $string); } return $string; }
function plugin_color_inline() { global $pkwk_dtd; $args = func_get_args(); $text = strip_autolink(array_pop($args)); // htmlsc(text) already $color = isset($args[0]) ? trim($args[0]) : ''; $bgcolor = isset($args[1]) ? trim($args[1]) : ''; if ($color == '' && $bgcolor == '' || func_num_args() > 3) { return PLUGIN_COLOR_USAGE; } if ($text == '') { if ($color != '' && $bgcolor != '') { $text = htmlsc($bgcolor); $bgcolor = ''; } else { return PLUGIN_COLOR_USAGE; } } foreach (array($color, $bgcolor) as $_color) { if ($_color != '' && !preg_match(PLUGIN_COLOR_REGEX, $_color)) { return '&color():Invalid color: ' . htmlsc($_color) . ';'; } } if ($color != '') { $color = 'color:' . $color; } if ($bgcolor != '') { $bgcolor = 'background-color:' . $bgcolor; } $delimiter = $color != '' && $bgcolor != '' ? ';' : ''; return '<span class="wikicolor" style="' . $color . $delimiter . $bgcolor . '">' . $text . '</span>'; }
/** * Creates new instance of \Google\Protobuf\DescriptorProto\ReservedRange * * @throws \InvalidArgumentException * * @return ReservedRange */ public static function create() { switch (func_num_args()) { case 0: return new ReservedRange(); case 1: return new ReservedRange(func_get_arg(0)); case 2: return new ReservedRange(func_get_arg(0), func_get_arg(1)); case 3: return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new ReservedRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
/** * @param ChartJSOptions $options * * @return ChartJSOptions */ public function &Options(ChartJSOptions $options = null) { if (func_num_args() != 0) { $this->_options = $options; } return $this->_options; }