function Field() { $parts = explode("\n", chunk_split($this->value, 4, "\n")); $parts = array_pad($parts, 4, ""); $field = "<span id=\"{$this->name}_Holder\" class=\"creditCardField\">" . "<input autocomplete=\"off\" name=\"{$this->name}[0]\" value=\"{$parts['0']}\" maxlength=\"4\"" . $this->getTabIndexHTML(0) . " /> - " . "<input autocomplete=\"off\" name=\"{$this->name}[1]\" value=\"{$parts['1']}\" maxlength=\"4\"" . $this->getTabIndexHTML(1) . " /> - " . "<input autocomplete=\"off\" name=\"{$this->name}[2]\" value=\"{$parts['2']}\" maxlength=\"4\"" . $this->getTabIndexHTML(2) . " /> - " . "<input autocomplete=\"off\" name=\"{$this->name}[3]\" value=\"{$parts['3']}\" maxlength=\"4\"" . $this->getTabIndexHTML(3) . " /></span>"; return $field; }
public function resize($w, $h) { $this->width = $w; $this->height = $h; for ($i = 0; $i < count($this->data); $i++) { $row =& $this->data[$i]; if ($row == null) { $this->data[$i] = array(); $row =& $this->data[$i]; } while (count($row) < $this->width) { array_push($row, null); } unset($row); } if (count($this->data) < $this->height) { $start = count($this->data); for ($i = $start; $i < $this->height; $i++) { $row = array(); $row = array_pad(array(), $this->width, null); array_push($this->data, $row); unset($row); } } return true; }
public function getRelativePath($to) { // some compatibility fixes for Windows paths $from = $this->from; $from = is_dir($from) ? rtrim($from, '\\/') . '/' : $from; $to = is_dir($to) ? rtrim($to, '\\/') . '/' : $to; $from = str_replace('\\', '/', $from); $to = str_replace('\\', '/', $to); $from = explode('/', $from); $to = explode('/', $to); $relPath = $to; foreach ($from as $depth => $dir) { // find first non-matching dir if ($dir === $to[$depth]) { // ignore this directory array_shift($relPath); } else { // get number of remaining dirs to $from $remaining = count($from) - $depth; if ($remaining > 1) { // add traversals up to first matching dir $padLength = (count($relPath) + $remaining - 1) * -1; $relPath = array_pad($relPath, $padLength, '..'); break; } else { $relPath[0] = './' . $relPath[0]; } } } return implode('/', $relPath); }
/** * Register the Authorization server with the IoC container. * * @param \Illuminate\Contracts\Container\Container $app * * @return void */ public function registerAuthorizer(Application $app) { $app->singleton('oauth2-server.authorizer', function ($app) { $config = $app['config']->get('oauth2'); $issuer = $app->make(AuthorizationServer::class)->setClientStorage($app->make(ClientInterface::class))->setSessionStorage($app->make(SessionInterface::class))->setAuthCodeStorage($app->make(AuthCodeInterface::class))->setAccessTokenStorage($app->make(AccessTokenInterface::class))->setRefreshTokenStorage($app->make(RefreshTokenInterface::class))->setScopeStorage($app->make(ScopeInterface::class))->requireScopeParam($config['scope_param'])->setDefaultScope($config['default_scope'])->requireStateParam($config['state_param'])->setScopeDelimiter($config['scope_delimiter'])->setAccessTokenTTL($config['access_token_ttl']); // add the supported grant types to the authorization server foreach ($config['grant_types'] as $grantIdentifier => $grantParams) { $grant = $app->make($grantParams['class']); $grant->setAccessTokenTTL($grantParams['access_token_ttl']); if (array_key_exists('callback', $grantParams)) { list($className, $method) = array_pad(explode('@', $grantParams['callback']), 2, 'verify'); $verifier = $app->make($className); $grant->setVerifyCredentialsCallback([$verifier, $method]); } if (array_key_exists('auth_token_ttl', $grantParams)) { $grant->setAuthTokenTTL($grantParams['auth_token_ttl']); } if (array_key_exists('refresh_token_ttl', $grantParams)) { $grant->setRefreshTokenTTL($grantParams['refresh_token_ttl']); } if (array_key_exists('rotate_refresh_tokens', $grantParams)) { $grant->setRefreshTokenRotation($grantParams['rotate_refresh_tokens']); } $issuer->addGrantType($grant, $grantIdentifier); } $checker = $app->make(ResourceServer::class); $authorizer = new Authorizer($issuer, $checker); $authorizer->setRequest($app['request']); $authorizer->setTokenType($app->make($config['token_type'])); $app->refresh('request', $authorizer, 'setRequest'); return $authorizer; }); $app->alias('oauth2-server.authorizer', Authorizer::class); }
/** * Returns a Guid object that has all its bits set to zero. * * @return Zend_Guid a nil Guid. * @static */ public static function emptyGuid() { if (!isset($this->emptyGuid)) { $this->emptyGuid = new Zend_Guid(array_pad(array(), 16, 0)); } return $this->emptyGuid; }
function convert() { // arguments if (func_num_args() === 0) { return; } $args = func_get_args(); $body = array_pop($args); $body = str_replace("\r", "\n", $body); foreach ($args as $arg) { list($key, $val) = array_pad(explode('=', $arg, 2), 2, true); $this->options[$key] = $val; } $this->options['style'] = htmlspecialchars($this->options['style']); $this->options['width'] = htmlspecialchars($this->options['width']); // main list($bodies, $splitargs) = $this->splitbody($body); $splitoptions = array(); foreach ($splitargs as $i => $splitarg) { $splitoptions[$i] = array(); foreach ($splitarg as $arg) { list($key, $val) = array_pad(explode('=', $arg, 2), 2, true); $splitoptions[$i][$key] = htmlspecialchars($val); } } if ($this->options['tag'] == 'table') { $output = $this->table($bodies, $splitoptions); } else { $output = $this->div($bodies, $splitoptions); } return $output; }
function verComp($ver1, $ver2) { $v1 = explode(".", $ver1); $v2 = explode(".", $ver2); for ($i = 0; $i < count($v1); $i++) { $v1[$i] = intval($v1[$i]); } for ($i = 0; $i < count($v2); $i++) { $v2[$i] = intval($v2[$i]); } if (count($v1) < count($v2)) { $v1 = array_pad($v1, count($v2)); } if (count($v1) > count($v2)) { $v2 = array_pad($v2, count($v1)); } for ($i = 0; $i < count($v1); $i++) { if ($v1[$i] > $v2[$i]) { return 1; } if ($v1[$i] < $v2[$i]) { return -1; } } return 0; }
/** * Magic call method * * @param string $method * @param array $args */ public function __call($method, array $args = array()) { if ($this->_logger) { array_pad($args, 1); $this->_logger->{$method}($args[0]); } }
/** * Calculs de paramètres de contexte automatiques pour la balise FORMULAIRE_INSCRIPTION * * En absence de mode d'inscription transmis à la balise, celui-ci est * calculé en fonction de la configuration : * * - '1comite' si les rédacteurs peuvent s'inscrire, * - '6forum' sinon si les forums sur abonnements sont actifs, * - rien sinon. * * @example * ``` * #FORMULAIRE_INSCRIPTION * [(#FORMULAIRE_INSCRIPTION{mode_inscription, #ID_RUBRIQUE})] * ``` * * @param array $args * - args[0] un statut d'auteur (rédacteur par defaut) * - args[1] indique la rubrique éventuelle de proposition * @param array $context_compil * Tableau d'informations sur la compilation * @return array|string * - Liste (statut, id) si un mode d'inscription est possible * - chaîne vide sinon. */ function balise_FORMULAIRE_INSCRIPTION_stat($args, $context_compil) { list($mode, $id) = array_pad($args, 2, null); include_spip('action/inscrire_auteur'); $mode = tester_statut_inscription($mode, $id); return $mode ? array($mode, $id) : ''; }
/** * @return array The return value should include 'errno' and 'data' */ function parse_url() { $request_uri = trim($_SERVER['REQUEST_URI']); $request_uri = trim($request_uri, '/'); /* parse request uri start * ----------------------------------- */ $p = strpos($request_uri, '?'); $request_uri = $p !== false ? substr($request_uri, 0, $p) : $request_uri; // security request uri filter if (preg_match('/(\\.\\.|\\"|\'|<|>)/', $request_uri)) { return array('errno' => self::ERRNO_FORBIDDEN, 'data' => "permission denied."); } // get display format if (($p = strrpos($request_uri, '.')) !== false) { $tail = substr($request_uri, $p + 1); if (preg_match('/^[a-zA-Z0-9]+$/', $tail)) { $display = $tail; //'json' $request_uri = substr($request_uri, 0, $p); } } $url_piece = array_pad(explode('/', $request_uri, 5), 5, null); return ['errno' => self::ERRNO_OK, 'data' => $url_piece]; }
function IPv4To6($Ip, $expand = false) { static $Mask = '::ffff:'; // This tells IPv6 it has an IPv4 address $IPv6 = strpos($Ip, ':') !== false; $IPv4 = strpos($Ip, '.') !== false; if (!$IPv4 && !$IPv6) { return false; } if ($IPv6 && $IPv4) { $Ip = substr($Ip, strrpos($Ip, ':') + 1); } elseif (!$IPv4) { return ExpandIPv6Notation($Ip); } // Seems to be IPv6 already? $Ip = array_pad(explode('.', $Ip), 4, 0); if (count($Ip) > 4) { return false; } for ($i = 0; $i < 4; $i++) { if ($Ip[$i] > 255) { return false; } } $Part7 = base_convert($Ip[0] * 256 + $Ip[1], 10, 16); $Part8 = base_convert($Ip[2] * 256 + $Ip[3], 10, 16); if ($expand) { return ExpandIPv6Notation($Mask . $Part7 . ':' . $Part8); } else { return $Mask . $Part7 . ':' . $Part8; } }
/** * Pad to the specified size with a value. * * @param $size * @param null $value * @return $this */ public function pad($size, $value = null) { if ($this->isEmpty()) { return $this; } return new static(array_pad($this->items, $size, $value)); }
public static function run($task, $args) { // Just call and run() or did they have a specific method in mind? list($task, $method)=array_pad(explode(':', $task), 2, 'run'); $task = ucfirst(strtolower($task)); if ( ! $file = \Fuel::find_file('tasks', $task)) { throw new \Exception('Well that didnt work...'); return; } require $file; $task = '\\Fuel\\Tasks\\'.$task; $new_task = new $task; // The help option hs been called, so call help instead if (\Cli::option('help') && is_callable(array($new_task, 'help'))) { $method = 'help'; } if ($return = call_user_func_array(array($new_task, $method), $args)) { \Cli::write($return); } }
protected static function parse($conf) { $routes = []; $curpos = []; foreach (explode("\n", $conf) as $line) { if (($pos = strpos($line, '#')) !== false) { $line = substr($line, 0, $pos); } if (!($line = rtrim($line))) { continue; } $depth = strlen(preg_filter('/^(\\s+).*/', '$1', $line)); $data = preg_split('/\\s+/', ltrim($line)); $path = $data[0]; $node = $data[1] ?? null; $curpos = array_slice($curpos, 0, $depth); $curpos = array_pad($curpos, $depth, ''); $curpos[] = $path; if (!$node) { continue; } $line = preg_replace('/^\\s*.*?\\s+/', '', $line); $path = preg_replace('/\\/+/', '/', '/' . join('/', $curpos)); $node = preg_replace('/\\s*/', '', $line); $patt = str_replace('.', '\\.', $path); $patt = preg_replace('/:\\w+/', '([^/]+)', $patt); $patt = preg_replace('/@\\w+/', '(\\d+)', $patt); $class = preg_replace('/\\//', '\\controller\\', dirname($node), 1); $class = preg_replace('/\\//', '\\', $class); $routes[] = ['path' => $path, 'controller' => dirname($node), 'action' => basename($node), 'pattern' => $patt, 'class' => $class]; } return $routes; }
public function save() { # Check we have the necessary data before proceeding. foreach ($this->td->columns() as $col) { # TODO: pk, not id if ($col == "id") { continue; } $coldata = $this->td->column($col); if (!($coldata['is_nullable'] || !empty($this->data[$col]))) { throw new Exception("{$col} must have value"); } } $query = "INSERT INTO `%s` (%s) VALUES (%s)"; $query_cols = array(); $query_vals = array(); foreach ($this->td->columns() as $col) { # TODO: pk, not id if ($col == "id") { continue; } $coldata = $this->td->column($col); #TODO: implement this. # if ($coldata['is_ai']) continue; $query_cols[] = "`{$col}`"; $query_vals[] = $this->data[$col]; } # TODO: This will devolve into the query class eventually. $query = sprintf($query, $this->td->table_name(), join(",", $query_cols), join(",", array_pad(array(), count($query_vals), "?"))); $this->schema->query($query, $query_vals); }
public static function callFunction($functionName, $parameters) { $db = self::getInstance(); $bindParams = Arrays::toArray($parameters); $paramsQueryString = implode(',', array_pad(array(), sizeof($bindParams), '?')); return Arrays::first($db->query("SELECT {$functionName}({$paramsQueryString})", $parameters)->fetch()); }
public static function packageData(&$metadata, $filepath) { $metadata['directory'] = dirname($filepath); if (empty($metadata['packageName'])) { $metadata['packageName'] = dirname(str_replace(DOCROOT, '', $filepath)); } if (empty($metadata['identifier'])) { //kohana::log('debug', 'Creating identifier from md5(\'' .$metadata['packageName'] .$metadata['version'] .'\');'); $metadata['identifier'] = md5($metadata['packageName'] . $metadata['version']); } if (empty($metadata['displayName'])) { $metadata['displayName'] = ucfirst(inflector::humanize($metadata['packageName'])); } if (!is_bool($metadata['default'])) { $metadata['default'] = FALSE; } if (!is_array($metadata['required'])) { $metadata['required'] = array(); Package_Message::log('error', 'Package ' . $metadata['packageName'] . ' required parameter is poorly formated, ignoring'); } if (is_numeric($metadata['version'])) { $versionParts = explode('.', $metadata['version']); $versionParts = array_pad($versionParts, 3, 0); $metadata['version'] = implode('.', $versionParts); } $metadata['version'] = (string) $metadata['version']; $metadata['upgrades'] = array(); $metadata['downgrades'] = array(); $metadata['basedir'] = dirname(str_replace(DOCROOT, '', $filepath)); $metadata['status'] = Package_Manager::STATUS_UNINSTALLED; $metadata['datastore_id'] = NULL; }
function checkStatic($line) { $validStatics = array('Yii::', 'parent::', 'LimeExpressionManager::', 'Answer::', 'Question::', 'Survey::', 'QuestionGroup::', 'self::', 'PDO::', 'Participants::', 'SurveyLink::', 'ParticipantAttribute::', 'Tokens::', 'UserGroup::', 'Condition::', 'Survey_Common_Action::', 'Quota::', 'SurveyURLParameter::', 'Survey_languagesettings::', 'Permission::', 'SavedControl::', 'QuotaMember::', 'QuotaLanguageSetting::', 'ParticipantAttributeName::', 'User::', 'SurveyLanguageSetting::', 'QuestionAttribute::', 'Assessment::', 'CDbConnection::', 'ParticipantShare::', '\'{INSERTANS::', 'DefaultValue::', 'CHtml::', 'ExpressionManager::', '\'::\'', 'LabelSet::', 'SurveyDynamic::', 'PEAR::', 'SettingGlobal::', 'Zend_Http_Client::', 'Zend_XmlRpc_Value::', 'Templates_rights_model::', 'Zend_XmlRpc_Server_Fault::', 'Zend_XmlRpc_Value::', 'Zend_Server_Cache::', 'Zend_XmlRpc_Server_Cache::', 'Label::', 'Assessments::', 'XMLReader::', 'LEM::', 'Question::', 'DateTime::', 'Installer::', 'Session::', 'dataentry::', 'Assessments::', 'Zend_Server_Reflection::', 'Participants::', 'jsonRPCServer::', 'FailedLoginAttempt::', 'survey::', 'tokens::', 'questiongroup::', 'printanswers::', 'imagick::', ':: ', 'Assessments::', 'InstallerConfigForm::', 'Database::', 'UserInGroups::', 'Usergroups::', 'SurveyTimingDynamic::', '::regClass', 'surveypermission::', 'Template::', 'templates::', 'Templates_rights::', 'register::', '::first', '::before', '::after', '::reg', 'text::', 'httpCache::'); $replacements = array_pad(array(), count($validStatics), ''); $line = str_replace($validStatics, $replacements, $line); return strpos($line, '::') !== false; }
function convert() { if (func_num_args() == 0) { return '<p>$this->plugin(): no argument(s). </p>'; } global $vars; $args = func_get_args(); $url = array_shift($args); if (!is_url($url) && is_interwiki($url)) { list($interwiki, $page) = explode(':', $url, 2); $url = get_interwiki_url($interwiki, $page); } $page = $vars['page']; if (!(PKWK_READONLY > 0 or is_freeze($page) or $this->is_edit_auth($page))) { if (!$this->accept($url)) { return "<p>{$this->plugin}(): The specified url, {$url}, is not allowed, modify iframe.inc.php<br />" . "Or, restrict editing of current page using freeze or edit_auth or PKWK_READONLY.</p>"; } } $url = htmlspecialchars($url); $options = array(); foreach ($args as $arg) { list($key, $val) = array_pad(explode('=', $arg, 2), 2, TRUE); $options[$key] = htmlspecialchars($val); } $style = isset($options['style']) ? $options['style'] : NULL; if (preg_match("/MSIE (3|4|5|6|7)/", getenv("HTTP_USER_AGENT"))) { $style = isset($options['iestyle']) ? $options['iestyle'] : $style; return $this->show_iframe($url, $style); } else { return $this->show_object($url, $style); } }
/** * @param $abstract * * @return array */ protected function extractControllerAndMethod($abstract) { if (is_array($abstract)) { return array_pad($abstract, 2, null); } return [null, null]; }
/** * Returns javascript which creates an instance of the class defined in formJavascriptClass() * * @param int $repeatCounter repeat group counter * * @return string */ public function elementJavascript($repeatCounter) { if (!$this->isEditable()) { return; } FabrikHelperHTML::addPath(COM_FABRIK_BASE . 'plugins/fabrik_element/colourpicker/images/', 'image', 'form', false); $params = $this->getParams(); $element = $this->getElement(); $id = $this->getHTMLId($repeatCounter); $data = $this->_form->_data; $value = $this->getValue($data, $repeatCounter); $vars = explode(",", $value); $vars = array_pad($vars, 3, 0); $opts = $this->getElementJSOptions($repeatCounter); $c = new stdClass(); // 14/06/2011 changed over to color param object from ind colour settings $c->red = (int) $vars[0]; $c->green = (int) $vars[1]; $c->blue = (int) $vars[2]; $opts->colour = $c; $swatch = $params->get('colourpicker-swatch', 'default.js'); $swatchFile = JPATH_SITE . '/plugins/fabrik_element/colourpicker/swatches/' . $swatch; $opts->swatch = json_decode(JFile::read($swatchFile)); $opts->closeImage = FabrikHelperHTML::image("close.gif", 'form', @$this->tmpl, array(), true); $opts->handleImage = FabrikHelperHTML::image("handle.gif", 'form', @$this->tmpl, array(), true); $opts->trackImage = FabrikHelperHTML::image("track.gif", 'form', @$this->tmpl, array(), true); $opts = json_encode($opts); return "new ColourPicker('{$id}', {$opts})"; }
/** * Return the travel path between two file paths (relative path). * * @param string $from The starting path * @param string $to The the end path * * @return string */ public static function getTravelPath($from, $to) { $from = explode(DS, $from); $to = explode(DS, $to); $relPath = $to; foreach ($from as $depth => $dir) { // find first non-matching dir if ($dir === $to[$depth]) { // ignore this directory array_shift($relPath); } else { // get number of remaining dirs to $from $remaining = count($from) - ($depth - 1); if ($remaining > 1) { // add traversals up to first matching dir $padLength = (count($relPath) + $remaining - 1) * -1; $relPath = array_pad($relPath, $padLength, '..'); break; } else { $relPath[0] = './' . $relPath[0]; } } } return implode('/', $relPath); }
/** * Take an array of parameters, use the first as the FormControl class/type, and run the constructor with the rest * @param array $arglist The array of arguments * @throws \Exception When the requested type is invalid * @return FormControl The created control. */ public static function from_args($arglist) { $arglist = array_pad($arglist, 6, null); list($type, $name, $storage, $properties, $settings) = $arglist; if (class_exists('\\Habari\\FormControl' . ucwords($type))) { $type = '\\Habari\\FormControl' . ucwords($type); } if (!class_exists($type)) { throw new \Exception(_t('The FormControl type "%s" is invalid.', array($type))); } if (is_null($properties)) { $properties = array(); } if (is_null($settings)) { $settings = array(); } if (is_string($properties)) { $bt = debug_backtrace(false, 4); $x = reset($bt); while ($x['function'] != 'append' && count($bt) > 0) { array_shift($bt); $x = reset($bt); } $params = implode("\n\t", $arglist); $err = <<<ERR <div class="error">Fixup for {$x['file']}[{$x['line']}]:<br/><code style="font-family:monospace;color:#c00;">{$type}::create('{$name}', '{$storage}')->label('{$properties}');</code></div> \t<!-- {$params} --> ERR; return FormControlStatic::create(uniqid('fc', true))->set_static($err); } return new $type($name, $storage, $properties, $settings); }
/** * 标准的处理器 * * @param array $dataset * @return mixed */ public function standard($dataset) { $tmp = array(); $pad = 0; foreach ($dataset as $data) { if (is_array($data)) { foreach ($data as $key => $value) { if (!array_key_exists($key, $tmp)) { $tmp[$key] = array(); } $tmp[$key] = array_pad($tmp[$key], count($tmp[$key]) + $pad, null); $tmp[$key][] = $value; } $pad = 0; } else { $pad++; } } if ($pad > 0) { $tmp = array_map(function ($v) use($pad) { return array_pad($v, count($v) + $pad, null); }, $tmp); } $label = array_keys($dataset); $count = count($label); return compact('label', 'count') + $tmp; }
/** * Display graphs as embedded images. Graphs are noon to noon unless parameters are provided. Results undefined if bounds are narrower than data. * @param int $startHourPM earliest hour to show in graphs * @param int $endHourPM end bound of graphs */ public function displaygraphs($startHourPM = 0, $endHourAM = 0) { foreach ($this->data as $night) { $nightstart = strtotime($night['Start of Night']); $nightend = strtotime($night['End of Night']); //find noon of that day $noon = self::previous_noon($nightstart); //start at 9pm (adjust this if you have data earlier than this) //The right way to do this would be to actually check the data upfront and set the offset automatically $startoffset = 60 * 60 * $startHourPM; $starttime = $noon + $startoffset; //end data at noon $endoffset = 60 * 60 * (12 - $endHourAM); //find out how many intervals are needed to pad the data from noon $intervalseconds = 30; $pad_needed = round(($nightstart - $starttime) / $intervalseconds); $pad = str_repeat('0 ', $pad_needed); //put the padded data in an array for progressbar $sleepdata = explode(' ', $pad . $night['Detailed Sleep Graph']); //pad the array for the total number of hours $sleepdata = array_pad($sleepdata, (60 * 60 * 24 - $startoffset - $endoffset) / $intervalseconds, 0); //print((round($nightend-$nightstart)/30) . '-'. count($sleepdata).'<br>'); $progressbar = new ProgressBar($sleepdata, 1000, 50, ProgressBar::MODE_INTEGER, 'zeo'); print $night['Start of Night'] . ' ' . $progressbar->embedded_imagetag() . $night['End of Night'] . '<br>'; } }
/** * Build the SQL query. */ public function buildQuery(string $query, array $bindings = []) { $patterns = $placeholders = []; preg_match_all('/\\?/', $query, $placeholders, PREG_SET_ORDER); $patterns = array_pad([], count($placeholders), '/\\?/'); return preg_replace($patterns, $bindings, $query, $limit = 1); }
/** * Submenu Plugin * * @author sonots * @license http://www.gnu.org/licenses/gpl.html GPL v2 * @link http://lsx.sourceforge.jp/?Plugin%2Fsubmenu.inc.php * @version $Id: submenu.inc.php,v 1.1 2007-02-24 16:28:39Z sonots $ * @package plugin */ function plugin_submenu_convert() { global $vars; $args = func_get_args(); $body = array_pop($args); $body = str_replace("\r", "\n", str_replace("\r\n", "\n", $body)); $options = array('prefix' => '', 'filter' => '', 'except' => ''); foreach ($args as $arg) { list($key, $val) = array_pad(explode('=', $arg), 2, ''); $options[$key] = $val; } if ($options['prefix'] != '') { if (strpos($vars['page'], $options['prefix']) !== 0) { return ''; } } if ($options['filter'] != '') { if (!preg_match('/' . str_replace('/', '\\/', $options['filter']) . '/', $vars['page'])) { return ''; } } if ($options['except'] != '') { if (preg_match('/' . str_replace('/', '\\/', $options['except']) . '/', $vars['page'])) { return ''; } } return convert_html($body); }
public static function getRelativePath($from, $to) { $from = is_dir($from) ? rtrim($from, '\\/') . '/' : $from; $to = is_dir($to) ? rtrim($to, '\\/') . '/' : $to; $from = str_replace('\\', '/', $from); $to = str_replace('\\', '/', $to); $from = explode('/', $from); $to = explode('/', $to); $relPath = $to; foreach ($from as $depth => $dir) { if ($dir === $to[$depth]) { array_shift($relPath); } else { $remaining = count($from) - $depth; if ($remaining > 1) { $padLength = (count($relPath) + $remaining - 1) * -1; $relPath = array_pad($relPath, $padLength, '..'); break; } else { $relPath[0] = './' . $relPath[0]; } } } return implode('/', $relPath); }
/** * @group mapper * @covers \PHPExif\Mapper\Native::mapRawData */ public function testMapRawDataMapsFieldsCorrectly() { $reflProp = new \ReflectionProperty(get_class($this->mapper), 'map'); $reflProp->setAccessible(true); $map = $reflProp->getValue($this->mapper); // ignore custom formatted data stuff: unset($map[\PHPExif\Mapper\Native::DATETIMEORIGINAL]); unset($map[\PHPExif\Mapper\Native::EXPOSURETIME]); unset($map[\PHPExif\Mapper\Native::FOCALLENGTH]); unset($map[\PHPExif\Mapper\Native::XRESOLUTION]); unset($map[\PHPExif\Mapper\Native::YRESOLUTION]); unset($map[\PHPExif\Mapper\Native::GPSLATITUDE]); unset($map[\PHPExif\Mapper\Native::GPSLONGITUDE]); // create raw data $keys = array_keys($map); $values = array(); $values = array_pad($values, count($keys), 'foo'); $rawData = array_combine($keys, $values); $mapped = $this->mapper->mapRawData($rawData); $i = 0; foreach ($mapped as $key => $value) { $this->assertEquals($map[$keys[$i]], $key); $i++; } }
function CarteIndividu($individu) { $v = new vCard(); $acl = Zend_Registry::get('acl'); $ind = Zend_Registry::get('user'); if ($acl->isAllowed($ind, $individu, 'fiche')) { $v->setName($individu->nom, $individu->prenom); if ($individu->naissance) { $v->setBirthday($individu->naissance); } $t0 = explode("\n", $individu->adresse); $t0 = array_pad($t0, 3, ''); list($adresse, $ville, $pays) = $t0; if (preg_match("`(\\d{5}) (.*)`", $ville, $res)) { $v->setAddress("", "", $adresse, $res[2], "", $res[1], $pays); } $v->setPhoneNumber($individu->fixe, "HOME"); $v->setPhoneNumber($individu->portable, "CELL"); if ($photo = $individu->getCheminImage()) { $v->setPhoto('jpeg', file_get_contents($photo)); } $v->setEmail($individu->adelec); $v->setURL($this->view->urlIndividu($individu, 'fiche', 'individus', true, true)); } else { $v->setName($individu->getName()); $v->setBirthday(substr($individu->naissance, 0, 4)); } array_push($this->view->vcards, $v); }