id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
6,300 | teeebor/decoy-framework | Application.php | Application.getInvokablesFromModule | private function getInvokablesFromModule(array $invokable)
{
foreach ($invokable as $key => $path) {
$this->invokable[$key] = $path;
}
} | php | private function getInvokablesFromModule(array $invokable)
{
foreach ($invokable as $key => $path) {
$this->invokable[$key] = $path;
}
} | [
"private",
"function",
"getInvokablesFromModule",
"(",
"array",
"$",
"invokable",
")",
"{",
"foreach",
"(",
"$",
"invokable",
"as",
"$",
"key",
"=>",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"invokable",
"[",
"$",
"key",
"]",
"=",
"$",
"path",
";",
"}",
"}"
] | Get all invokable from a module, then assign it to a global list.
@param array $invokable | [
"Get",
"all",
"invokable",
"from",
"a",
"module",
"then",
"assign",
"it",
"to",
"a",
"global",
"list",
"."
] | 3881ae63a7d13088efda5afd3932c1af1fc18b23 | https://github.com/teeebor/decoy-framework/blob/3881ae63a7d13088efda5afd3932c1af1fc18b23/Application.php#L323-L328 |
6,301 | teeebor/decoy-framework | Application.php | Application.getViewsFromModule | private function getViewsFromModule(array $views)
{
foreach ($views as $key => $path)
$this->views[$key] = $path;
} | php | private function getViewsFromModule(array $views)
{
foreach ($views as $key => $path)
$this->views[$key] = $path;
} | [
"private",
"function",
"getViewsFromModule",
"(",
"array",
"$",
"views",
")",
"{",
"foreach",
"(",
"$",
"views",
"as",
"$",
"key",
"=>",
"$",
"path",
")",
"$",
"this",
"->",
"views",
"[",
"$",
"key",
"]",
"=",
"$",
"path",
";",
"}"
] | Get all view from a module, then assign it to a global list.
@param array $views | [
"Get",
"all",
"view",
"from",
"a",
"module",
"then",
"assign",
"it",
"to",
"a",
"global",
"list",
"."
] | 3881ae63a7d13088efda5afd3932c1af1fc18b23 | https://github.com/teeebor/decoy-framework/blob/3881ae63a7d13088efda5afd3932c1af1fc18b23/Application.php#L334-L338 |
6,302 | indigophp-archive/fuel-dependency | classes/Container.php | Container.setDic | public static function setDic(DiC $dic = null)
{
// if a custom DiC is passed, use that
if ($dic)
{
static::$dic = $dic;
}
// else set one up if not done yet
elseif ( ! static::$dic)
{
// get us a Dependency Container instance
static::$dic = new DiC;
// register the DiC on classname so it can be auto-resolved
static::$dic->registerSingleton('Fuel\\Dependency\\Container', function($container)
{
static::$dic;
});
}
// register the dic for manual resolving
static::$dic->registerSingleton('dic', function($container)
{
static::$dic;
});
return static::$dic;
} | php | public static function setDic(DiC $dic = null)
{
// if a custom DiC is passed, use that
if ($dic)
{
static::$dic = $dic;
}
// else set one up if not done yet
elseif ( ! static::$dic)
{
// get us a Dependency Container instance
static::$dic = new DiC;
// register the DiC on classname so it can be auto-resolved
static::$dic->registerSingleton('Fuel\\Dependency\\Container', function($container)
{
static::$dic;
});
}
// register the dic for manual resolving
static::$dic->registerSingleton('dic', function($container)
{
static::$dic;
});
return static::$dic;
} | [
"public",
"static",
"function",
"setDic",
"(",
"DiC",
"$",
"dic",
"=",
"null",
")",
"{",
"// if a custom DiC is passed, use that",
"if",
"(",
"$",
"dic",
")",
"{",
"static",
"::",
"$",
"dic",
"=",
"$",
"dic",
";",
"}",
"// else set one up if not done yet",
"elseif",
"(",
"!",
"static",
"::",
"$",
"dic",
")",
"{",
"// get us a Dependency Container instance",
"static",
"::",
"$",
"dic",
"=",
"new",
"DiC",
";",
"// register the DiC on classname so it can be auto-resolved",
"static",
"::",
"$",
"dic",
"->",
"registerSingleton",
"(",
"'Fuel\\\\Dependency\\\\Container'",
",",
"function",
"(",
"$",
"container",
")",
"{",
"static",
"::",
"$",
"dic",
";",
"}",
")",
";",
"}",
"// register the dic for manual resolving",
"static",
"::",
"$",
"dic",
"->",
"registerSingleton",
"(",
"'dic'",
",",
"function",
"(",
"$",
"container",
")",
"{",
"static",
"::",
"$",
"dic",
";",
"}",
")",
";",
"return",
"static",
"::",
"$",
"dic",
";",
"}"
] | Sets the DiC
@param DiC $dic
@return DiC | [
"Sets",
"the",
"DiC"
] | ce482a2c660ce6325ebed4c7c068119a538913f2 | https://github.com/indigophp-archive/fuel-dependency/blob/ce482a2c660ce6325ebed4c7c068119a538913f2/classes/Container.php#L131-L159 |
6,303 | matryoshka-model/service-api | library/Service/HttpClientServiceFactory.php | HttpClientServiceFactory.createService | public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Config');
$client = new Client();
if (!empty($config[$this->configKey])) {
$clientOptions = $config[$this->configKey];
if (isset($clientOptions['uri'])) {
$client->setUri($clientOptions['uri']);
unset($clientOptions['uri']);
}
if (isset($clientOptions['auth'])) {
$auth = $clientOptions['auth'];
$client->setAuth(
isset($auth['user']) ? $auth['user'] : '',
isset($auth['password']) ? $auth['password'] : '',
isset($auth['type']) ? $auth['type'] : $client::AUTH_BASIC
);
unset($clientOptions['auth']);
}
$client->setOptions($config[$this->configKey]);
}
return $client;
} | php | public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Config');
$client = new Client();
if (!empty($config[$this->configKey])) {
$clientOptions = $config[$this->configKey];
if (isset($clientOptions['uri'])) {
$client->setUri($clientOptions['uri']);
unset($clientOptions['uri']);
}
if (isset($clientOptions['auth'])) {
$auth = $clientOptions['auth'];
$client->setAuth(
isset($auth['user']) ? $auth['user'] : '',
isset($auth['password']) ? $auth['password'] : '',
isset($auth['type']) ? $auth['type'] : $client::AUTH_BASIC
);
unset($clientOptions['auth']);
}
$client->setOptions($config[$this->configKey]);
}
return $client;
} | [
"public",
"function",
"createService",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
")",
"{",
"$",
"config",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'Config'",
")",
";",
"$",
"client",
"=",
"new",
"Client",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"config",
"[",
"$",
"this",
"->",
"configKey",
"]",
")",
")",
"{",
"$",
"clientOptions",
"=",
"$",
"config",
"[",
"$",
"this",
"->",
"configKey",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"clientOptions",
"[",
"'uri'",
"]",
")",
")",
"{",
"$",
"client",
"->",
"setUri",
"(",
"$",
"clientOptions",
"[",
"'uri'",
"]",
")",
";",
"unset",
"(",
"$",
"clientOptions",
"[",
"'uri'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"clientOptions",
"[",
"'auth'",
"]",
")",
")",
"{",
"$",
"auth",
"=",
"$",
"clientOptions",
"[",
"'auth'",
"]",
";",
"$",
"client",
"->",
"setAuth",
"(",
"isset",
"(",
"$",
"auth",
"[",
"'user'",
"]",
")",
"?",
"$",
"auth",
"[",
"'user'",
"]",
":",
"''",
",",
"isset",
"(",
"$",
"auth",
"[",
"'password'",
"]",
")",
"?",
"$",
"auth",
"[",
"'password'",
"]",
":",
"''",
",",
"isset",
"(",
"$",
"auth",
"[",
"'type'",
"]",
")",
"?",
"$",
"auth",
"[",
"'type'",
"]",
":",
"$",
"client",
"::",
"AUTH_BASIC",
")",
";",
"unset",
"(",
"$",
"clientOptions",
"[",
"'auth'",
"]",
")",
";",
"}",
"$",
"client",
"->",
"setOptions",
"(",
"$",
"config",
"[",
"$",
"this",
"->",
"configKey",
"]",
")",
";",
"}",
"return",
"$",
"client",
";",
"}"
] | Create a http client service
@param ServiceLocatorInterface $serviceLocator
@return Client | [
"Create",
"a",
"http",
"client",
"service"
] | c188baa8bf4ec8827fde2a9ea1851880778c32c9 | https://github.com/matryoshka-model/service-api/blob/c188baa8bf4ec8827fde2a9ea1851880778c32c9/library/Service/HttpClientServiceFactory.php#L32-L60 |
6,304 | unyx/diagnostics | Debug.php | Debug.enable | public static function enable(interfaces\handlers\Error $error = null, interfaces\handlers\Exception $exception = null, $threshold = null) : bool
{
// Only enable the Handlers once. See the class description for more on this.
if (static::$enabled) {
return false;
}
// Register the Handlers.
static::$errorHandler = handlers\Error::register($error, $threshold);
static::$exceptionHandler = handlers\Exception::register($exception);
return static::$enabled = true;
} | php | public static function enable(interfaces\handlers\Error $error = null, interfaces\handlers\Exception $exception = null, $threshold = null) : bool
{
// Only enable the Handlers once. See the class description for more on this.
if (static::$enabled) {
return false;
}
// Register the Handlers.
static::$errorHandler = handlers\Error::register($error, $threshold);
static::$exceptionHandler = handlers\Exception::register($exception);
return static::$enabled = true;
} | [
"public",
"static",
"function",
"enable",
"(",
"interfaces",
"\\",
"handlers",
"\\",
"Error",
"$",
"error",
"=",
"null",
",",
"interfaces",
"\\",
"handlers",
"\\",
"Exception",
"$",
"exception",
"=",
"null",
",",
"$",
"threshold",
"=",
"null",
")",
":",
"bool",
"{",
"// Only enable the Handlers once. See the class description for more on this.",
"if",
"(",
"static",
"::",
"$",
"enabled",
")",
"{",
"return",
"false",
";",
"}",
"// Register the Handlers.",
"static",
"::",
"$",
"errorHandler",
"=",
"handlers",
"\\",
"Error",
"::",
"register",
"(",
"$",
"error",
",",
"$",
"threshold",
")",
";",
"static",
"::",
"$",
"exceptionHandler",
"=",
"handlers",
"\\",
"Exception",
"::",
"register",
"(",
"$",
"exception",
")",
";",
"return",
"static",
"::",
"$",
"enabled",
"=",
"true",
";",
"}"
] | Enables the bundled Error and Exception Handlers by registering them with PHP.
Important note: The return values. When this method returns false, it merely means that the Handlers are
already registered and therefore could not be enabled again. This method will only return true for the call
that actually enables them. This is a little hack to make checking for certain conditions easier.
@param interfaces\handlers\Error $error An optional already instantiated Error Handler instance.
If none is given, a new one will be instantiated.
@param interfaces\handlers\Exception $exception An optional already instantiated Exception Handler instance.
If none is given, a new one will be instantiated.
@param int $threshold {@see handlers\Error::setThreshold()}
@return bool True when Debug was not yet enabled, false otherwise. | [
"Enables",
"the",
"bundled",
"Error",
"and",
"Exception",
"Handlers",
"by",
"registering",
"them",
"with",
"PHP",
"."
] | 024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e | https://github.com/unyx/diagnostics/blob/024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e/Debug.php#L64-L76 |
6,305 | unyx/diagnostics | Debug.php | Debug.setDumper | public static function setDumper($dumper)
{
if (!$dumper instanceof interfaces\Dumper && !is_callable($dumper)) {
throw new \InvalidArgumentException('Expected an instance of ['.interfaces\Dumper::class.'] or a callable, got ['.static::getTypeName($dumper).'] instead.');
}
static::$dumper = $dumper;
} | php | public static function setDumper($dumper)
{
if (!$dumper instanceof interfaces\Dumper && !is_callable($dumper)) {
throw new \InvalidArgumentException('Expected an instance of ['.interfaces\Dumper::class.'] or a callable, got ['.static::getTypeName($dumper).'] instead.');
}
static::$dumper = $dumper;
} | [
"public",
"static",
"function",
"setDumper",
"(",
"$",
"dumper",
")",
"{",
"if",
"(",
"!",
"$",
"dumper",
"instanceof",
"interfaces",
"\\",
"Dumper",
"&&",
"!",
"is_callable",
"(",
"$",
"dumper",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Expected an instance of ['",
".",
"interfaces",
"\\",
"Dumper",
"::",
"class",
".",
"'] or a callable, got ['",
".",
"static",
"::",
"getTypeName",
"(",
"$",
"dumper",
")",
".",
"'] instead.'",
")",
";",
"}",
"static",
"::",
"$",
"dumper",
"=",
"$",
"dumper",
";",
"}"
] | Sets the Dumper to be used.
@param interfaces\Dumper|callable $dumper | [
"Sets",
"the",
"Dumper",
"to",
"be",
"used",
"."
] | 024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e | https://github.com/unyx/diagnostics/blob/024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e/Debug.php#L141-L148 |
6,306 | laravelflare/media | src/Media/Media.php | Media.size | public function size($width = null, $height = null)
{
foreach (\Config::get('flare-config.media.resize') as $sizeArray) {
if ($width && $height && ($width == $sizeArray[0]) && ($height == $sizeArray[1])) {
return $this->path ? url('uploads/media/'.$sizeArray[0].'-'.(array_key_exists(1, $sizeArray) ? $sizeArray[1] : $sizeArray[0]).'-'.$this->path) : null;
}
if ($width && ($width == $sizeArray[0])) {
return $this->path ? url('uploads/media/'.$sizeArray[0].'-'.(array_key_exists(1, $sizeArray) ? $sizeArray[1] : $sizeArray[0]).'-'.$this->path) : null;
}
}
return $this->link;
} | php | public function size($width = null, $height = null)
{
foreach (\Config::get('flare-config.media.resize') as $sizeArray) {
if ($width && $height && ($width == $sizeArray[0]) && ($height == $sizeArray[1])) {
return $this->path ? url('uploads/media/'.$sizeArray[0].'-'.(array_key_exists(1, $sizeArray) ? $sizeArray[1] : $sizeArray[0]).'-'.$this->path) : null;
}
if ($width && ($width == $sizeArray[0])) {
return $this->path ? url('uploads/media/'.$sizeArray[0].'-'.(array_key_exists(1, $sizeArray) ? $sizeArray[1] : $sizeArray[0]).'-'.$this->path) : null;
}
}
return $this->link;
} | [
"public",
"function",
"size",
"(",
"$",
"width",
"=",
"null",
",",
"$",
"height",
"=",
"null",
")",
"{",
"foreach",
"(",
"\\",
"Config",
"::",
"get",
"(",
"'flare-config.media.resize'",
")",
"as",
"$",
"sizeArray",
")",
"{",
"if",
"(",
"$",
"width",
"&&",
"$",
"height",
"&&",
"(",
"$",
"width",
"==",
"$",
"sizeArray",
"[",
"0",
"]",
")",
"&&",
"(",
"$",
"height",
"==",
"$",
"sizeArray",
"[",
"1",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"path",
"?",
"url",
"(",
"'uploads/media/'",
".",
"$",
"sizeArray",
"[",
"0",
"]",
".",
"'-'",
".",
"(",
"array_key_exists",
"(",
"1",
",",
"$",
"sizeArray",
")",
"?",
"$",
"sizeArray",
"[",
"1",
"]",
":",
"$",
"sizeArray",
"[",
"0",
"]",
")",
".",
"'-'",
".",
"$",
"this",
"->",
"path",
")",
":",
"null",
";",
"}",
"if",
"(",
"$",
"width",
"&&",
"(",
"$",
"width",
"==",
"$",
"sizeArray",
"[",
"0",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"path",
"?",
"url",
"(",
"'uploads/media/'",
".",
"$",
"sizeArray",
"[",
"0",
"]",
".",
"'-'",
".",
"(",
"array_key_exists",
"(",
"1",
",",
"$",
"sizeArray",
")",
"?",
"$",
"sizeArray",
"[",
"1",
"]",
":",
"$",
"sizeArray",
"[",
"0",
"]",
")",
".",
"'-'",
".",
"$",
"this",
"->",
"path",
")",
":",
"null",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"link",
";",
"}"
] | Returns the media link in the requested size.
@return | [
"Returns",
"the",
"media",
"link",
"in",
"the",
"requested",
"size",
"."
] | 380a9d3f7c2fc370c2cbd34a77ced87675fc8491 | https://github.com/laravelflare/media/blob/380a9d3f7c2fc370c2cbd34a77ced87675fc8491/src/Media/Media.php#L41-L54 |
6,307 | laravelflare/media | src/Media/Media.php | Media.getHumanSizeAttribute | public function getHumanSizeAttribute()
{
$size = (int) $this->size;
if ($size >= 1 << 30) {
return number_format($size / (1 << 30), 2).'GB';
}
if ($size >= 1 << 20) {
return number_format($size / (1 << 20), 2).'MB';
}
if ($size >= 1 << 10) {
return number_format($size / (1 << 10), 2).'KB';
}
return number_format($size).' bytes';
} | php | public function getHumanSizeAttribute()
{
$size = (int) $this->size;
if ($size >= 1 << 30) {
return number_format($size / (1 << 30), 2).'GB';
}
if ($size >= 1 << 20) {
return number_format($size / (1 << 20), 2).'MB';
}
if ($size >= 1 << 10) {
return number_format($size / (1 << 10), 2).'KB';
}
return number_format($size).' bytes';
} | [
"public",
"function",
"getHumanSizeAttribute",
"(",
")",
"{",
"$",
"size",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"size",
";",
"if",
"(",
"$",
"size",
">=",
"1",
"<<",
"30",
")",
"{",
"return",
"number_format",
"(",
"$",
"size",
"/",
"(",
"1",
"<<",
"30",
")",
",",
"2",
")",
".",
"'GB'",
";",
"}",
"if",
"(",
"$",
"size",
">=",
"1",
"<<",
"20",
")",
"{",
"return",
"number_format",
"(",
"$",
"size",
"/",
"(",
"1",
"<<",
"20",
")",
",",
"2",
")",
".",
"'MB'",
";",
"}",
"if",
"(",
"$",
"size",
">=",
"1",
"<<",
"10",
")",
"{",
"return",
"number_format",
"(",
"$",
"size",
"/",
"(",
"1",
"<<",
"10",
")",
",",
"2",
")",
".",
"'KB'",
";",
"}",
"return",
"number_format",
"(",
"$",
"size",
")",
".",
"' bytes'",
";",
"}"
] | Convert Media Size to a Human Readable Format.
@return string | [
"Convert",
"Media",
"Size",
"to",
"a",
"Human",
"Readable",
"Format",
"."
] | 380a9d3f7c2fc370c2cbd34a77ced87675fc8491 | https://github.com/laravelflare/media/blob/380a9d3f7c2fc370c2cbd34a77ced87675fc8491/src/Media/Media.php#L71-L88 |
6,308 | webfactorybulgaria/Attributes | src/Http/Controllers/AttributeGroupsAdminController.php | AttributeGroupsAdminController.index | public function index()
{
$models = $this->repository->all([], true);
app('JavaScript')->put('models', $models);
return view('attributes::admin.index-groups');
} | php | public function index()
{
$models = $this->repository->all([], true);
app('JavaScript')->put('models', $models);
return view('attributes::admin.index-groups');
} | [
"public",
"function",
"index",
"(",
")",
"{",
"$",
"models",
"=",
"$",
"this",
"->",
"repository",
"->",
"all",
"(",
"[",
"]",
",",
"true",
")",
";",
"app",
"(",
"'JavaScript'",
")",
"->",
"put",
"(",
"'models'",
",",
"$",
"models",
")",
";",
"return",
"view",
"(",
"'attributes::admin.index-groups'",
")",
";",
"}"
] | List models.
@return \Illuminate\View\View | [
"List",
"models",
"."
] | 217739dfe7b974a1806d6baf4ea1e1861df24f5f | https://github.com/webfactorybulgaria/Attributes/blob/217739dfe7b974a1806d6baf4ea1e1861df24f5f/src/Http/Controllers/AttributeGroupsAdminController.php#L22-L28 |
6,309 | Niirrty/Niirrty.Web | src/Url.php | Url.checkForOpenRedirect | public function checkForOpenRedirect( $urlForTestContents, $testContents, $useAsRegex = false )
{
if ( \count( $this->openRedirectionURLs ) < 1 )
{
// If no open redirection URLs was found by isPossibleOpenRedirect(…) we are already done here
return false;
}
// Remember the current query parameters
$oldQuery = $this->query;
// Getting the query keys
$keys = \array_keys( $this->openRedirectionURLs );
// Loop the query keys and assign the replacement url to this query
foreach ( $keys as $key )
{
$this->query[ $key ] = $urlForTestContents;
}
// Adjust get_headers() to send a HEAD request
\stream_context_set_default(
array(
'http' => array( 'method' => 'HEAD' )
)
);
// Getting th URL string to call
$url = (string) $this;
// Init state flag
$handleHeaders = true;
// OK now we can reassign the origin headers
$this->query = $oldQuery;
if ( false === ( $headers = \get_headers( $url, 1 ) ) )
{
// If the head request fails get headers from GET request
\stream_context_set_default(
array(
'http' => array( 'method' => 'GET' )
)
);
// Get header by GET request
if ( false === ( $headers = \get_headers( $url, 1 ) ) )
{
$handleHeaders = false;
}
}
else
{
// reset get_header to use defaut GET request
\stream_context_set_default(
array(
'http' => array( 'method' => 'GET' )
)
);
}
if ( $handleHeaders && \count( $headers ) > 0 )
{
// There are usable headers in response, handle it
// Make header keys to lower case
$headers = \array_change_key_case( $headers, \CASE_LOWER );
if ( isset( $headers[ 'location' ] ) && ( $urlForTestContents === $headers[ 'location' ] ) )
{
// Location header to defined URL is defined. Now we know its a open redirection bug usage
return true;
}
if ( isset( $headers[ 'refresh' ] ) && \Niirrty\strContains( $headers[ 'refresh' ], $urlForTestContents ) )
{
// Refresh header to defined URL is defined. Now we know its a open redirection bug usage
return true;
}
}
// We can not work with headers because they dont gives us the required informations.
// Get the data from URL to check
$resultContents = \file_get_contents( $url );
if ( $useAsRegex )
{
try { return (bool) \preg_match( $testContents, $resultContents ); }
catch ( \Throwable $ex ) { unset( $ex ); }
}
$regex = '~<meta\s+http-equiv=(\'|")?refresh(\'|")?\s+content=(\'|")\d+;\s*url='
. \preg_quote( $url )
. '~i';
if ( \preg_match( $regex, $resultContents ) )
{
return true;
}
return $testContents === $resultContents;
} | php | public function checkForOpenRedirect( $urlForTestContents, $testContents, $useAsRegex = false )
{
if ( \count( $this->openRedirectionURLs ) < 1 )
{
// If no open redirection URLs was found by isPossibleOpenRedirect(…) we are already done here
return false;
}
// Remember the current query parameters
$oldQuery = $this->query;
// Getting the query keys
$keys = \array_keys( $this->openRedirectionURLs );
// Loop the query keys and assign the replacement url to this query
foreach ( $keys as $key )
{
$this->query[ $key ] = $urlForTestContents;
}
// Adjust get_headers() to send a HEAD request
\stream_context_set_default(
array(
'http' => array( 'method' => 'HEAD' )
)
);
// Getting th URL string to call
$url = (string) $this;
// Init state flag
$handleHeaders = true;
// OK now we can reassign the origin headers
$this->query = $oldQuery;
if ( false === ( $headers = \get_headers( $url, 1 ) ) )
{
// If the head request fails get headers from GET request
\stream_context_set_default(
array(
'http' => array( 'method' => 'GET' )
)
);
// Get header by GET request
if ( false === ( $headers = \get_headers( $url, 1 ) ) )
{
$handleHeaders = false;
}
}
else
{
// reset get_header to use defaut GET request
\stream_context_set_default(
array(
'http' => array( 'method' => 'GET' )
)
);
}
if ( $handleHeaders && \count( $headers ) > 0 )
{
// There are usable headers in response, handle it
// Make header keys to lower case
$headers = \array_change_key_case( $headers, \CASE_LOWER );
if ( isset( $headers[ 'location' ] ) && ( $urlForTestContents === $headers[ 'location' ] ) )
{
// Location header to defined URL is defined. Now we know its a open redirection bug usage
return true;
}
if ( isset( $headers[ 'refresh' ] ) && \Niirrty\strContains( $headers[ 'refresh' ], $urlForTestContents ) )
{
// Refresh header to defined URL is defined. Now we know its a open redirection bug usage
return true;
}
}
// We can not work with headers because they dont gives us the required informations.
// Get the data from URL to check
$resultContents = \file_get_contents( $url );
if ( $useAsRegex )
{
try { return (bool) \preg_match( $testContents, $resultContents ); }
catch ( \Throwable $ex ) { unset( $ex ); }
}
$regex = '~<meta\s+http-equiv=(\'|")?refresh(\'|")?\s+content=(\'|")\d+;\s*url='
. \preg_quote( $url )
. '~i';
if ( \preg_match( $regex, $resultContents ) )
{
return true;
}
return $testContents === $resultContents;
} | [
"public",
"function",
"checkForOpenRedirect",
"(",
"$",
"urlForTestContents",
",",
"$",
"testContents",
",",
"$",
"useAsRegex",
"=",
"false",
")",
"{",
"if",
"(",
"\\",
"count",
"(",
"$",
"this",
"->",
"openRedirectionURLs",
")",
"<",
"1",
")",
"{",
"// If no open redirection URLs was found by isPossibleOpenRedirect(…) we are already done here",
"return",
"false",
";",
"}",
"// Remember the current query parameters",
"$",
"oldQuery",
"=",
"$",
"this",
"->",
"query",
";",
"// Getting the query keys",
"$",
"keys",
"=",
"\\",
"array_keys",
"(",
"$",
"this",
"->",
"openRedirectionURLs",
")",
";",
"// Loop the query keys and assign the replacement url to this query",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"query",
"[",
"$",
"key",
"]",
"=",
"$",
"urlForTestContents",
";",
"}",
"// Adjust get_headers() to send a HEAD request",
"\\",
"stream_context_set_default",
"(",
"array",
"(",
"'http'",
"=>",
"array",
"(",
"'method'",
"=>",
"'HEAD'",
")",
")",
")",
";",
"// Getting th URL string to call",
"$",
"url",
"=",
"(",
"string",
")",
"$",
"this",
";",
"// Init state flag",
"$",
"handleHeaders",
"=",
"true",
";",
"// OK now we can reassign the origin headers",
"$",
"this",
"->",
"query",
"=",
"$",
"oldQuery",
";",
"if",
"(",
"false",
"===",
"(",
"$",
"headers",
"=",
"\\",
"get_headers",
"(",
"$",
"url",
",",
"1",
")",
")",
")",
"{",
"// If the head request fails get headers from GET request",
"\\",
"stream_context_set_default",
"(",
"array",
"(",
"'http'",
"=>",
"array",
"(",
"'method'",
"=>",
"'GET'",
")",
")",
")",
";",
"// Get header by GET request",
"if",
"(",
"false",
"===",
"(",
"$",
"headers",
"=",
"\\",
"get_headers",
"(",
"$",
"url",
",",
"1",
")",
")",
")",
"{",
"$",
"handleHeaders",
"=",
"false",
";",
"}",
"}",
"else",
"{",
"// reset get_header to use defaut GET request",
"\\",
"stream_context_set_default",
"(",
"array",
"(",
"'http'",
"=>",
"array",
"(",
"'method'",
"=>",
"'GET'",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"handleHeaders",
"&&",
"\\",
"count",
"(",
"$",
"headers",
")",
">",
"0",
")",
"{",
"// There are usable headers in response, handle it",
"// Make header keys to lower case",
"$",
"headers",
"=",
"\\",
"array_change_key_case",
"(",
"$",
"headers",
",",
"\\",
"CASE_LOWER",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"headers",
"[",
"'location'",
"]",
")",
"&&",
"(",
"$",
"urlForTestContents",
"===",
"$",
"headers",
"[",
"'location'",
"]",
")",
")",
"{",
"// Location header to defined URL is defined. Now we know its a open redirection bug usage",
"return",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"headers",
"[",
"'refresh'",
"]",
")",
"&&",
"\\",
"Niirrty",
"\\",
"strContains",
"(",
"$",
"headers",
"[",
"'refresh'",
"]",
",",
"$",
"urlForTestContents",
")",
")",
"{",
"// Refresh header to defined URL is defined. Now we know its a open redirection bug usage",
"return",
"true",
";",
"}",
"}",
"// We can not work with headers because they dont gives us the required informations.",
"// Get the data from URL to check",
"$",
"resultContents",
"=",
"\\",
"file_get_contents",
"(",
"$",
"url",
")",
";",
"if",
"(",
"$",
"useAsRegex",
")",
"{",
"try",
"{",
"return",
"(",
"bool",
")",
"\\",
"preg_match",
"(",
"$",
"testContents",
",",
"$",
"resultContents",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"ex",
")",
"{",
"unset",
"(",
"$",
"ex",
")",
";",
"}",
"}",
"$",
"regex",
"=",
"'~<meta\\s+http-equiv=(\\'|\")?refresh(\\'|\")?\\s+content=(\\'|\")\\d+;\\s*url='",
".",
"\\",
"preg_quote",
"(",
"$",
"url",
")",
".",
"'~i'",
";",
"if",
"(",
"\\",
"preg_match",
"(",
"$",
"regex",
",",
"$",
"resultContents",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"$",
"testContents",
"===",
"$",
"resultContents",
";",
"}"
] | Checks, if possible open redirection bug URLs are defined, if one of it its a real open redirection usage.
Attention. It sends a real request to each URL. Do'nt use it inside you're main web application because it
blocks it as long if it gets a answer. Maybe better use it in cron jobs or inside a very low frequenced area!
How it works is easy. All you need is a url and its well known output.
If we replace the possible redirection URL inside the current url with the URL where we know the output and
it redirects to the url with the known output, the bug is used.
@param string $urlForTestContents The URL with the known output
@param string $testContents The known output of $urlForTestContents (or a regex if $useAsRegex is TRUE)
@param boolean $useAsRegex Should $testContents be used as a regular expression?
@return boolean | [
"Checks",
"if",
"possible",
"open",
"redirection",
"bug",
"URLs",
"are",
"defined",
"if",
"one",
"of",
"it",
"its",
"a",
"real",
"open",
"redirection",
"usage",
"."
] | 66185109561e734f8a45e626369de5ac05afc2d5 | https://github.com/Niirrty/Niirrty.Web/blob/66185109561e734f8a45e626369de5ac05afc2d5/src/Url.php#L442-L550 |
6,310 | Niirrty/Niirrty.Web | src/Url.php | Url.getScheme | public function getScheme() : string
{
if ( null === $this->scheme )
{
$this->scheme = static::$fallbackScheme;
}
return $this->scheme;
} | php | public function getScheme() : string
{
if ( null === $this->scheme )
{
$this->scheme = static::$fallbackScheme;
}
return $this->scheme;
} | [
"public",
"function",
"getScheme",
"(",
")",
":",
"string",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"scheme",
")",
"{",
"$",
"this",
"->",
"scheme",
"=",
"static",
"::",
"$",
"fallbackScheme",
";",
"}",
"return",
"$",
"this",
"->",
"scheme",
";",
"}"
] | Gets the URL scheme. Default is 'http'
@return string | [
"Gets",
"the",
"URL",
"scheme",
".",
"Default",
"is",
"http"
] | 66185109561e734f8a45e626369de5ac05afc2d5 | https://github.com/Niirrty/Niirrty.Web/blob/66185109561e734f8a45e626369de5ac05afc2d5/src/Url.php#L583-L593 |
6,311 | Niirrty/Niirrty.Web | src/Url.php | Url.setScheme | public function setScheme( ?string $scheme = null ) : Url
{
if ( null === $scheme || ! \preg_match( '~^[a-z]{3,7}$~i', $scheme ) )
{
$this->scheme = 'http';
return $this;
}
$this->scheme = $scheme;
return $this;
} | php | public function setScheme( ?string $scheme = null ) : Url
{
if ( null === $scheme || ! \preg_match( '~^[a-z]{3,7}$~i', $scheme ) )
{
$this->scheme = 'http';
return $this;
}
$this->scheme = $scheme;
return $this;
} | [
"public",
"function",
"setScheme",
"(",
"?",
"string",
"$",
"scheme",
"=",
"null",
")",
":",
"Url",
"{",
"if",
"(",
"null",
"===",
"$",
"scheme",
"||",
"!",
"\\",
"preg_match",
"(",
"'~^[a-z]{3,7}$~i'",
",",
"$",
"scheme",
")",
")",
"{",
"$",
"this",
"->",
"scheme",
"=",
"'http'",
";",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"scheme",
"=",
"$",
"scheme",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the URL scheme. Default is 'http' if none is defined
@param string|null $scheme
@return \Niirrty\Web\Url | [
"Sets",
"the",
"URL",
"scheme",
".",
"Default",
"is",
"http",
"if",
"none",
"is",
"defined"
] | 66185109561e734f8a45e626369de5ac05afc2d5 | https://github.com/Niirrty/Niirrty.Web/blob/66185109561e734f8a45e626369de5ac05afc2d5/src/Url.php#L728-L741 |
6,312 | qq1060656096/brief-db | src/Database/Query/Condition.php | Condition.mapConditionOperator | protected function mapConditionOperator($operator) {
// $specials does not use drupal_static as its value never changes.
static $specials = array(
'BETWEEN' => array('delimiter' => ' AND '),
'IN' => array('delimiter' => ', ', 'prefix' => '(', 'postfix' => ')'),
'NOT IN' => array('delimiter' => ', ', 'prefix' => '(', 'postfix' => ')'),
'EXISTS' => array('prefix' => '(', 'postfix' => ')'),
'NOT EXISTS' => array('prefix' => '(', 'postfix' => ')'),
'IS NULL' => array('use_value' => FALSE),
'IS NOT NULL' => array('use_value' => FALSE),
// Use backslash for escaping wildcard characters.
'LIKE' => array('postfix' => " ESCAPE '\\\\'"),
'NOT LIKE' => array('postfix' => " ESCAPE '\\\\'"),
// These ones are here for performance reasons.
'=' => array(),
'<' => array(),
'>' => array(),
'>=' => array(),
'<=' => array(),
);
if (isset($specials[$operator])) {
$return = $specials[$operator];
}
else {
// We need to upper case because PHP index matches are case sensitive but
// do not need the more expensive drupal_strtoupper because SQL statements are ASCII.
$operator = strtoupper($operator);
$return = isset($specials[$operator]) ? $specials[$operator] : array();
}
$return += array('operator' => $operator);
return $return;
} | php | protected function mapConditionOperator($operator) {
// $specials does not use drupal_static as its value never changes.
static $specials = array(
'BETWEEN' => array('delimiter' => ' AND '),
'IN' => array('delimiter' => ', ', 'prefix' => '(', 'postfix' => ')'),
'NOT IN' => array('delimiter' => ', ', 'prefix' => '(', 'postfix' => ')'),
'EXISTS' => array('prefix' => '(', 'postfix' => ')'),
'NOT EXISTS' => array('prefix' => '(', 'postfix' => ')'),
'IS NULL' => array('use_value' => FALSE),
'IS NOT NULL' => array('use_value' => FALSE),
// Use backslash for escaping wildcard characters.
'LIKE' => array('postfix' => " ESCAPE '\\\\'"),
'NOT LIKE' => array('postfix' => " ESCAPE '\\\\'"),
// These ones are here for performance reasons.
'=' => array(),
'<' => array(),
'>' => array(),
'>=' => array(),
'<=' => array(),
);
if (isset($specials[$operator])) {
$return = $specials[$operator];
}
else {
// We need to upper case because PHP index matches are case sensitive but
// do not need the more expensive drupal_strtoupper because SQL statements are ASCII.
$operator = strtoupper($operator);
$return = isset($specials[$operator]) ? $specials[$operator] : array();
}
$return += array('operator' => $operator);
return $return;
} | [
"protected",
"function",
"mapConditionOperator",
"(",
"$",
"operator",
")",
"{",
"// $specials does not use drupal_static as its value never changes.",
"static",
"$",
"specials",
"=",
"array",
"(",
"'BETWEEN'",
"=>",
"array",
"(",
"'delimiter'",
"=>",
"' AND '",
")",
",",
"'IN'",
"=>",
"array",
"(",
"'delimiter'",
"=>",
"', '",
",",
"'prefix'",
"=>",
"'('",
",",
"'postfix'",
"=>",
"')'",
")",
",",
"'NOT IN'",
"=>",
"array",
"(",
"'delimiter'",
"=>",
"', '",
",",
"'prefix'",
"=>",
"'('",
",",
"'postfix'",
"=>",
"')'",
")",
",",
"'EXISTS'",
"=>",
"array",
"(",
"'prefix'",
"=>",
"'('",
",",
"'postfix'",
"=>",
"')'",
")",
",",
"'NOT EXISTS'",
"=>",
"array",
"(",
"'prefix'",
"=>",
"'('",
",",
"'postfix'",
"=>",
"')'",
")",
",",
"'IS NULL'",
"=>",
"array",
"(",
"'use_value'",
"=>",
"FALSE",
")",
",",
"'IS NOT NULL'",
"=>",
"array",
"(",
"'use_value'",
"=>",
"FALSE",
")",
",",
"// Use backslash for escaping wildcard characters.",
"'LIKE'",
"=>",
"array",
"(",
"'postfix'",
"=>",
"\" ESCAPE '\\\\\\\\'\"",
")",
",",
"'NOT LIKE'",
"=>",
"array",
"(",
"'postfix'",
"=>",
"\" ESCAPE '\\\\\\\\'\"",
")",
",",
"// These ones are here for performance reasons.",
"'='",
"=>",
"array",
"(",
")",
",",
"'<'",
"=>",
"array",
"(",
")",
",",
"'>'",
"=>",
"array",
"(",
")",
",",
"'>='",
"=>",
"array",
"(",
")",
",",
"'<='",
"=>",
"array",
"(",
")",
",",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"specials",
"[",
"$",
"operator",
"]",
")",
")",
"{",
"$",
"return",
"=",
"$",
"specials",
"[",
"$",
"operator",
"]",
";",
"}",
"else",
"{",
"// We need to upper case because PHP index matches are case sensitive but",
"// do not need the more expensive drupal_strtoupper because SQL statements are ASCII.",
"$",
"operator",
"=",
"strtoupper",
"(",
"$",
"operator",
")",
";",
"$",
"return",
"=",
"isset",
"(",
"$",
"specials",
"[",
"$",
"operator",
"]",
")",
"?",
"$",
"specials",
"[",
"$",
"operator",
"]",
":",
"array",
"(",
")",
";",
"}",
"$",
"return",
"+=",
"array",
"(",
"'operator'",
"=>",
"$",
"operator",
")",
";",
"return",
"$",
"return",
";",
"}"
] | Gets any special processing requirements for the condition operator.
Some condition types require special processing, such as IN, because
the value data they pass in is not a simple value. This is a simple
overridable lookup function.
@param $operator
The condition operator, such as "IN", "BETWEEN", etc. Case-sensitive.
@return
The extra handling directives for the specified operator, or NULL. | [
"Gets",
"any",
"special",
"processing",
"requirements",
"for",
"the",
"condition",
"operator",
"."
] | 19f693cc107cd6db677aa8385502310526395c7b | https://github.com/qq1060656096/brief-db/blob/19f693cc107cd6db677aa8385502310526395c7b/src/Database/Query/Condition.php#L170-L203 |
6,313 | oaugustus/direct-silex-provider | src/Direct/Router/Call.php | Call.getResponse | public function getResponse($result)
{
$content = $result->getContent();
if ($result->headers->get('content-type') == 'application/json'){
$content = json_decode($result->getContent(),true);
}
return array(
'type' => 'rpc',
'tid' => $this->tid,
'action' => $this->action,
'method' => $this->method,
'result' => $content
);
} | php | public function getResponse($result)
{
$content = $result->getContent();
if ($result->headers->get('content-type') == 'application/json'){
$content = json_decode($result->getContent(),true);
}
return array(
'type' => 'rpc',
'tid' => $this->tid,
'action' => $this->action,
'method' => $this->method,
'result' => $content
);
} | [
"public",
"function",
"getResponse",
"(",
"$",
"result",
")",
"{",
"$",
"content",
"=",
"$",
"result",
"->",
"getContent",
"(",
")",
";",
"if",
"(",
"$",
"result",
"->",
"headers",
"->",
"get",
"(",
"'content-type'",
")",
"==",
"'application/json'",
")",
"{",
"$",
"content",
"=",
"json_decode",
"(",
"$",
"result",
"->",
"getContent",
"(",
")",
",",
"true",
")",
";",
"}",
"return",
"array",
"(",
"'type'",
"=>",
"'rpc'",
",",
"'tid'",
"=>",
"$",
"this",
"->",
"tid",
",",
"'action'",
"=>",
"$",
"this",
"->",
"action",
",",
"'method'",
"=>",
"$",
"this",
"->",
"method",
",",
"'result'",
"=>",
"$",
"content",
")",
";",
"}"
] | Return a result wrapper to ExtDirect method call.
@param array $result
@return array | [
"Return",
"a",
"result",
"wrapper",
"to",
"ExtDirect",
"method",
"call",
"."
] | 8d92afdf5ede04c3048cde82b9879de7e1d6c153 | https://github.com/oaugustus/direct-silex-provider/blob/8d92afdf5ede04c3048cde82b9879de7e1d6c153/src/Direct/Router/Call.php#L114-L129 |
6,314 | oaugustus/direct-silex-provider | src/Direct/Router/Call.php | Call.getException | public function getException($exception)
{
return array(
'type' => 'exception',
'tid' => $this->tid,
'action' => $this->action,
'method' => $this->method,
'message' => $exception->getMessage(),
'where' => $exception->getTraceAsString()
);
} | php | public function getException($exception)
{
return array(
'type' => 'exception',
'tid' => $this->tid,
'action' => $this->action,
'method' => $this->method,
'message' => $exception->getMessage(),
'where' => $exception->getTraceAsString()
);
} | [
"public",
"function",
"getException",
"(",
"$",
"exception",
")",
"{",
"return",
"array",
"(",
"'type'",
"=>",
"'exception'",
",",
"'tid'",
"=>",
"$",
"this",
"->",
"tid",
",",
"'action'",
"=>",
"$",
"this",
"->",
"action",
",",
"'method'",
"=>",
"$",
"this",
"->",
"method",
",",
"'message'",
"=>",
"$",
"exception",
"->",
"getMessage",
"(",
")",
",",
"'where'",
"=>",
"$",
"exception",
"->",
"getTraceAsString",
"(",
")",
")",
";",
"}"
] | Return an exception to ExtDirect call stack
@param \Exception $exception
@return array | [
"Return",
"an",
"exception",
"to",
"ExtDirect",
"call",
"stack"
] | 8d92afdf5ede04c3048cde82b9879de7e1d6c153 | https://github.com/oaugustus/direct-silex-provider/blob/8d92afdf5ede04c3048cde82b9879de7e1d6c153/src/Direct/Router/Call.php#L137-L147 |
6,315 | oaugustus/direct-silex-provider | src/Direct/Router/Call.php | Call.initializeFromSingle | private function initializeFromSingle($call)
{
$this->action = $call['action'];
$this->method = $call['method'];
$this->type = $call['type'];
$this->tid = $call['tid'];
$this->data = (array)$call['data'][0];
} | php | private function initializeFromSingle($call)
{
$this->action = $call['action'];
$this->method = $call['method'];
$this->type = $call['type'];
$this->tid = $call['tid'];
$this->data = (array)$call['data'][0];
} | [
"private",
"function",
"initializeFromSingle",
"(",
"$",
"call",
")",
"{",
"$",
"this",
"->",
"action",
"=",
"$",
"call",
"[",
"'action'",
"]",
";",
"$",
"this",
"->",
"method",
"=",
"$",
"call",
"[",
"'method'",
"]",
";",
"$",
"this",
"->",
"type",
"=",
"$",
"call",
"[",
"'type'",
"]",
";",
"$",
"this",
"->",
"tid",
"=",
"$",
"call",
"[",
"'tid'",
"]",
";",
"$",
"this",
"->",
"data",
"=",
"(",
"array",
")",
"$",
"call",
"[",
"'data'",
"]",
"[",
"0",
"]",
";",
"}"
] | Initialize the call properties from a single call.
@param array $call | [
"Initialize",
"the",
"call",
"properties",
"from",
"a",
"single",
"call",
"."
] | 8d92afdf5ede04c3048cde82b9879de7e1d6c153 | https://github.com/oaugustus/direct-silex-provider/blob/8d92afdf5ede04c3048cde82b9879de7e1d6c153/src/Direct/Router/Call.php#L154-L161 |
6,316 | oaugustus/direct-silex-provider | src/Direct/Router/Call.php | Call.initializeFromForm | private function initializeFromForm($call)
{
$this->action = $call['extAction']; unset($call['extAction']);
$this->method = $call['extMethod']; unset($call['extMethod']);
$this->type = $call['extType']; unset($call['extType']);
$this->tid = $call['extTID']; unset($call['extTID']);
$this->upload = $call['extUpload']; unset($call['extUpload']);
foreach ($call as $key => $value) {
$this->data[$key] = $value;
}
} | php | private function initializeFromForm($call)
{
$this->action = $call['extAction']; unset($call['extAction']);
$this->method = $call['extMethod']; unset($call['extMethod']);
$this->type = $call['extType']; unset($call['extType']);
$this->tid = $call['extTID']; unset($call['extTID']);
$this->upload = $call['extUpload']; unset($call['extUpload']);
foreach ($call as $key => $value) {
$this->data[$key] = $value;
}
} | [
"private",
"function",
"initializeFromForm",
"(",
"$",
"call",
")",
"{",
"$",
"this",
"->",
"action",
"=",
"$",
"call",
"[",
"'extAction'",
"]",
";",
"unset",
"(",
"$",
"call",
"[",
"'extAction'",
"]",
")",
";",
"$",
"this",
"->",
"method",
"=",
"$",
"call",
"[",
"'extMethod'",
"]",
";",
"unset",
"(",
"$",
"call",
"[",
"'extMethod'",
"]",
")",
";",
"$",
"this",
"->",
"type",
"=",
"$",
"call",
"[",
"'extType'",
"]",
";",
"unset",
"(",
"$",
"call",
"[",
"'extType'",
"]",
")",
";",
"$",
"this",
"->",
"tid",
"=",
"$",
"call",
"[",
"'extTID'",
"]",
";",
"unset",
"(",
"$",
"call",
"[",
"'extTID'",
"]",
")",
";",
"$",
"this",
"->",
"upload",
"=",
"$",
"call",
"[",
"'extUpload'",
"]",
";",
"unset",
"(",
"$",
"call",
"[",
"'extUpload'",
"]",
")",
";",
"foreach",
"(",
"$",
"call",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] | Initialize the call properties from a form call.
@param array $call | [
"Initialize",
"the",
"call",
"properties",
"from",
"a",
"form",
"call",
"."
] | 8d92afdf5ede04c3048cde82b9879de7e1d6c153 | https://github.com/oaugustus/direct-silex-provider/blob/8d92afdf5ede04c3048cde82b9879de7e1d6c153/src/Direct/Router/Call.php#L168-L180 |
6,317 | meliorframework/melior | Classes/Registry/SimpleRegistry.php | SimpleRegistry.push | public function push(string $key, $data, bool $override = false)
{
if (!array_key_exists($key, $this->data) || $override) {
$this->data[$key] = $data;
return $this->data[$key];
}
return false;
} | php | public function push(string $key, $data, bool $override = false)
{
if (!array_key_exists($key, $this->data) || $override) {
$this->data[$key] = $data;
return $this->data[$key];
}
return false;
} | [
"public",
"function",
"push",
"(",
"string",
"$",
"key",
",",
"$",
"data",
",",
"bool",
"$",
"override",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"data",
")",
"||",
"$",
"override",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"data",
";",
"return",
"$",
"this",
"->",
"data",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"false",
";",
"}"
] | Pushs a value into the registry.
@param string $key The registry key to store the value in
@param mixed $data The data to store
@param bool $override (optional) Whether to override existing keys
@return mixed | [
"Pushs",
"a",
"value",
"into",
"the",
"registry",
"."
] | f6469fa6e85f66a0507ae13603d19d78f2774e0b | https://github.com/meliorframework/melior/blob/f6469fa6e85f66a0507ae13603d19d78f2774e0b/Classes/Registry/SimpleRegistry.php#L53-L62 |
6,318 | meliorframework/melior | Classes/Registry/SimpleRegistry.php | SimpleRegistry.get | public function get(string $key)
{
if (array_key_exists($key, $this->data)) {
return $this->data[$key];
}
return false;
} | php | public function get(string $key)
{
if (array_key_exists($key, $this->data)) {
return $this->data[$key];
}
return false;
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"key",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"data",
")",
")",
"{",
"return",
"$",
"this",
"->",
"data",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"false",
";",
"}"
] | Gets a value from the registry.
@param string $key The registry key to retrieve
@return mixed | [
"Gets",
"a",
"value",
"from",
"the",
"registry",
"."
] | f6469fa6e85f66a0507ae13603d19d78f2774e0b | https://github.com/meliorframework/melior/blob/f6469fa6e85f66a0507ae13603d19d78f2774e0b/Classes/Registry/SimpleRegistry.php#L71-L78 |
6,319 | easy-system/es-http | src/Uri.php | Uri.encode | public static function encode($value, $ignore = null)
{
if (null === $ignore) {
$ignore = static::CHAR_UNRESERVED
. static::CHAR_GEN_DELIMS
. static::CHAR_SUB_DELIMS;
}
$rawurlencode = function (array $matches) {
return rawurlencode($matches[0]);
};
return preg_replace_callback(
'/(?:[^' . $ignore . '%]+|%(?![A-Fa-f0-9]{2}))/',
$rawurlencode,
$value
);
} | php | public static function encode($value, $ignore = null)
{
if (null === $ignore) {
$ignore = static::CHAR_UNRESERVED
. static::CHAR_GEN_DELIMS
. static::CHAR_SUB_DELIMS;
}
$rawurlencode = function (array $matches) {
return rawurlencode($matches[0]);
};
return preg_replace_callback(
'/(?:[^' . $ignore . '%]+|%(?![A-Fa-f0-9]{2}))/',
$rawurlencode,
$value
);
} | [
"public",
"static",
"function",
"encode",
"(",
"$",
"value",
",",
"$",
"ignore",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"ignore",
")",
"{",
"$",
"ignore",
"=",
"static",
"::",
"CHAR_UNRESERVED",
".",
"static",
"::",
"CHAR_GEN_DELIMS",
".",
"static",
"::",
"CHAR_SUB_DELIMS",
";",
"}",
"$",
"rawurlencode",
"=",
"function",
"(",
"array",
"$",
"matches",
")",
"{",
"return",
"rawurlencode",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
";",
"}",
";",
"return",
"preg_replace_callback",
"(",
"'/(?:[^'",
".",
"$",
"ignore",
".",
"'%]+|%(?![A-Fa-f0-9]{2}))/'",
",",
"$",
"rawurlencode",
",",
"$",
"value",
")",
";",
"}"
] | URI-encode according to RFC 3986.
@param string $value The string to be encoded
@param string $ignore Optional; service symbols by default. Characters
that will not encoded
@return string The encoded string | [
"URI",
"-",
"encode",
"according",
"to",
"RFC",
"3986",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Uri.php#L110-L126 |
6,320 | easy-system/es-http | src/Uri.php | Uri.withPort | public function withPort($port)
{
$new = clone $this;
try {
$new->setPort($port);
} catch (InvalidArgumentException $ex) {
throw new InvalidArgumentException('Invalid port provided.', null, $ex);
}
return $new;
} | php | public function withPort($port)
{
$new = clone $this;
try {
$new->setPort($port);
} catch (InvalidArgumentException $ex) {
throw new InvalidArgumentException('Invalid port provided.', null, $ex);
}
return $new;
} | [
"public",
"function",
"withPort",
"(",
"$",
"port",
")",
"{",
"$",
"new",
"=",
"clone",
"$",
"this",
";",
"try",
"{",
"$",
"new",
"->",
"setPort",
"(",
"$",
"port",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"ex",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid port provided.'",
",",
"null",
",",
"$",
"ex",
")",
";",
"}",
"return",
"$",
"new",
";",
"}"
] | Return an instance with the provided port.
A null value provided for the port is equivalent to removing the port
information.
@param null|int $port The port to use with the new instance; a null value
removes the port information
@throw \InvalidArgumentException If invalid port provided
@return Uri The instance with the provided port | [
"Return",
"an",
"instance",
"with",
"the",
"provided",
"port",
".",
"A",
"null",
"value",
"provided",
"for",
"the",
"port",
"is",
"equivalent",
"to",
"removing",
"the",
"port",
"information",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Uri.php#L253-L263 |
6,321 | easy-system/es-http | src/Uri.php | Uri.withQuery | public function withQuery($query)
{
$new = clone $this;
try {
$new->setQuery($query);
} catch (InvalidArgumentException $ex) {
throw new InvalidArgumentException('Invalid query provided.', null, $ex);
}
return $new;
} | php | public function withQuery($query)
{
$new = clone $this;
try {
$new->setQuery($query);
} catch (InvalidArgumentException $ex) {
throw new InvalidArgumentException('Invalid query provided.', null, $ex);
}
return $new;
} | [
"public",
"function",
"withQuery",
"(",
"$",
"query",
")",
"{",
"$",
"new",
"=",
"clone",
"$",
"this",
";",
"try",
"{",
"$",
"new",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"ex",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid query provided.'",
",",
"null",
",",
"$",
"ex",
")",
";",
"}",
"return",
"$",
"new",
";",
"}"
] | Return an instance with the provided query string.
@param string $query The query string to use with the new instance
@throws \InvalidArgumentException If invalid query provided
@return Uri The instance with the provided query string | [
"Return",
"an",
"instance",
"with",
"the",
"provided",
"query",
"string",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Uri.php#L378-L388 |
6,322 | easy-system/es-http | src/Uri.php | Uri.fromString | protected function fromString($uri)
{
if (! is_string($uri)) {
throw new InvalidArgumentException(sprintf(
'"%s()" expects string; "%s" received.',
__METHOD__,
is_object($uri) ? get_class($uri) : gettype($uri)
));
}
$this
->setUserInfo(
parse_url($uri, PHP_URL_USER),
parse_url($uri, PHP_URL_PASS)
)
->setScheme(parse_url($uri, PHP_URL_SCHEME))
->setHost(parse_url($uri, PHP_URL_HOST))
->setPath(parse_url($uri, PHP_URL_PATH))
->setQuery(parse_url($uri, PHP_URL_QUERY))
->setFragment(parse_url($uri, PHP_URL_FRAGMENT));
if ($port = parse_url($uri, PHP_URL_PORT)) {
$this->setPort($port);
}
return $this;
} | php | protected function fromString($uri)
{
if (! is_string($uri)) {
throw new InvalidArgumentException(sprintf(
'"%s()" expects string; "%s" received.',
__METHOD__,
is_object($uri) ? get_class($uri) : gettype($uri)
));
}
$this
->setUserInfo(
parse_url($uri, PHP_URL_USER),
parse_url($uri, PHP_URL_PASS)
)
->setScheme(parse_url($uri, PHP_URL_SCHEME))
->setHost(parse_url($uri, PHP_URL_HOST))
->setPath(parse_url($uri, PHP_URL_PATH))
->setQuery(parse_url($uri, PHP_URL_QUERY))
->setFragment(parse_url($uri, PHP_URL_FRAGMENT));
if ($port = parse_url($uri, PHP_URL_PORT)) {
$this->setPort($port);
}
return $this;
} | [
"protected",
"function",
"fromString",
"(",
"$",
"uri",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"uri",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'\"%s()\" expects string; \"%s\" received.'",
",",
"__METHOD__",
",",
"is_object",
"(",
"$",
"uri",
")",
"?",
"get_class",
"(",
"$",
"uri",
")",
":",
"gettype",
"(",
"$",
"uri",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"setUserInfo",
"(",
"parse_url",
"(",
"$",
"uri",
",",
"PHP_URL_USER",
")",
",",
"parse_url",
"(",
"$",
"uri",
",",
"PHP_URL_PASS",
")",
")",
"->",
"setScheme",
"(",
"parse_url",
"(",
"$",
"uri",
",",
"PHP_URL_SCHEME",
")",
")",
"->",
"setHost",
"(",
"parse_url",
"(",
"$",
"uri",
",",
"PHP_URL_HOST",
")",
")",
"->",
"setPath",
"(",
"parse_url",
"(",
"$",
"uri",
",",
"PHP_URL_PATH",
")",
")",
"->",
"setQuery",
"(",
"parse_url",
"(",
"$",
"uri",
",",
"PHP_URL_QUERY",
")",
")",
"->",
"setFragment",
"(",
"parse_url",
"(",
"$",
"uri",
",",
"PHP_URL_FRAGMENT",
")",
")",
";",
"if",
"(",
"$",
"port",
"=",
"parse_url",
"(",
"$",
"uri",
",",
"PHP_URL_PORT",
")",
")",
"{",
"$",
"this",
"->",
"setPort",
"(",
"$",
"port",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Forms the an object from an URI string.
@param string $uri The URI string
@throws InvalidArgumentException On non-string $uri argument
@return Uri The current instance | [
"Forms",
"the",
"an",
"object",
"from",
"an",
"URI",
"string",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Uri.php#L499-L525 |
6,323 | easy-system/es-http | src/Uri.php | Uri.setScheme | protected function setScheme($scheme)
{
$this->uriString = null;
$this->scheme = strtolower(rtrim($scheme, ':/'));
return $this;
} | php | protected function setScheme($scheme)
{
$this->uriString = null;
$this->scheme = strtolower(rtrim($scheme, ':/'));
return $this;
} | [
"protected",
"function",
"setScheme",
"(",
"$",
"scheme",
")",
"{",
"$",
"this",
"->",
"uriString",
"=",
"null",
";",
"$",
"this",
"->",
"scheme",
"=",
"strtolower",
"(",
"rtrim",
"(",
"$",
"scheme",
",",
"':/'",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the URI scheme to current instance.
@param string $scheme The URI scheme
@return Uri The current instance with the provided scheme | [
"Sets",
"the",
"URI",
"scheme",
"to",
"current",
"instance",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Uri.php#L534-L541 |
6,324 | easy-system/es-http | src/Uri.php | Uri.setUserInfo | protected function setUserInfo($user = '', $password = '')
{
$this->uriString = null;
if (! $user) {
$this->userInfo = '';
return $this;
}
$this->userInfo = rtrim($user, '@');
if ($password) {
$this->userInfo .= ':' . $password;
}
return $this;
} | php | protected function setUserInfo($user = '', $password = '')
{
$this->uriString = null;
if (! $user) {
$this->userInfo = '';
return $this;
}
$this->userInfo = rtrim($user, '@');
if ($password) {
$this->userInfo .= ':' . $password;
}
return $this;
} | [
"protected",
"function",
"setUserInfo",
"(",
"$",
"user",
"=",
"''",
",",
"$",
"password",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"uriString",
"=",
"null",
";",
"if",
"(",
"!",
"$",
"user",
")",
"{",
"$",
"this",
"->",
"userInfo",
"=",
"''",
";",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"userInfo",
"=",
"rtrim",
"(",
"$",
"user",
",",
"'@'",
")",
";",
"if",
"(",
"$",
"password",
")",
"{",
"$",
"this",
"->",
"userInfo",
".=",
"':'",
".",
"$",
"password",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets the provided user information to current instance.
@param string $user The user name to use for authority
@param string $password The password associated with $user
@return Uri The current instance with the provided user information | [
"Sets",
"the",
"provided",
"user",
"information",
"to",
"current",
"instance",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Uri.php#L551-L567 |
6,325 | easy-system/es-http | src/Uri.php | Uri.setHost | protected function setHost($host)
{
$this->uriString = null;
$this->host = (string) $host;
return $this;
} | php | protected function setHost($host)
{
$this->uriString = null;
$this->host = (string) $host;
return $this;
} | [
"protected",
"function",
"setHost",
"(",
"$",
"host",
")",
"{",
"$",
"this",
"->",
"uriString",
"=",
"null",
";",
"$",
"this",
"->",
"host",
"=",
"(",
"string",
")",
"$",
"host",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the provided host to current instance.
@param string $host The hostname
@return Uri The current instance with the provided host | [
"Sets",
"the",
"provided",
"host",
"to",
"current",
"instance",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Uri.php#L576-L583 |
6,326 | easy-system/es-http | src/Uri.php | Uri.setPort | protected function setPort($port)
{
$this->uriString = null;
if (null === $port) {
$this->port = null;
return $this;
}
if (! $this->isPortValid($port)) {
throw new InvalidArgumentException(sprintf(
'Invalid port "%s" provided.',
(is_object($port) ? get_class($port) : gettype($port))
));
}
$this->port = (int) $port;
return $this;
} | php | protected function setPort($port)
{
$this->uriString = null;
if (null === $port) {
$this->port = null;
return $this;
}
if (! $this->isPortValid($port)) {
throw new InvalidArgumentException(sprintf(
'Invalid port "%s" provided.',
(is_object($port) ? get_class($port) : gettype($port))
));
}
$this->port = (int) $port;
return $this;
} | [
"protected",
"function",
"setPort",
"(",
"$",
"port",
")",
"{",
"$",
"this",
"->",
"uriString",
"=",
"null",
";",
"if",
"(",
"null",
"===",
"$",
"port",
")",
"{",
"$",
"this",
"->",
"port",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isPortValid",
"(",
"$",
"port",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid port \"%s\" provided.'",
",",
"(",
"is_object",
"(",
"$",
"port",
")",
"?",
"get_class",
"(",
"$",
"port",
")",
":",
"gettype",
"(",
"$",
"port",
")",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"port",
"=",
"(",
"int",
")",
"$",
"port",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the provided port to current instance.
@param null|int $port The port; a null value removes the port information
@throw \InvalidArgumentException For invalid ports
@return Uri The current instance with the provided port | [
"Sets",
"the",
"provided",
"port",
"to",
"current",
"instance",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Uri.php#L594-L613 |
6,327 | easy-system/es-http | src/Uri.php | Uri.setPath | protected function setPath($path)
{
$this->uriString = null;
$path = (string) $path;
if (strpos($path, '?') !== false) {
throw new InvalidArgumentException(
'Invalid path provided; must not contain a query string.'
);
}
if (strpos($path, '#') !== false) {
throw new InvalidArgumentException(
'Invalid path provided; must not contain a URI fragment.'
);
}
$this->path = static::encode($path);
return $this;
} | php | protected function setPath($path)
{
$this->uriString = null;
$path = (string) $path;
if (strpos($path, '?') !== false) {
throw new InvalidArgumentException(
'Invalid path provided; must not contain a query string.'
);
}
if (strpos($path, '#') !== false) {
throw new InvalidArgumentException(
'Invalid path provided; must not contain a URI fragment.'
);
}
$this->path = static::encode($path);
return $this;
} | [
"protected",
"function",
"setPath",
"(",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"uriString",
"=",
"null",
";",
"$",
"path",
"=",
"(",
"string",
")",
"$",
"path",
";",
"if",
"(",
"strpos",
"(",
"$",
"path",
",",
"'?'",
")",
"!==",
"false",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid path provided; must not contain a query string.'",
")",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"path",
",",
"'#'",
")",
"!==",
"false",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid path provided; must not contain a URI fragment.'",
")",
";",
"}",
"$",
"this",
"->",
"path",
"=",
"static",
"::",
"encode",
"(",
"$",
"path",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the provided path to current instance.
@param string $path The path
@throws \InvalidArgumentException If path contain query string or
URI fragment
@return Uri The current instance with the provided path | [
"Sets",
"the",
"provided",
"path",
"to",
"current",
"instance",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Uri.php#L625-L646 |
6,328 | easy-system/es-http | src/Uri.php | Uri.setQuery | protected function setQuery($query)
{
$this->uriString = null;
$query = ltrim($query, '?');
if (strpos($query, '#') !== false) {
throw new InvalidArgumentException(
'Query string must not include a URI fragment.'
);
}
$this->query = static::encode($query);
return $this;
} | php | protected function setQuery($query)
{
$this->uriString = null;
$query = ltrim($query, '?');
if (strpos($query, '#') !== false) {
throw new InvalidArgumentException(
'Query string must not include a URI fragment.'
);
}
$this->query = static::encode($query);
return $this;
} | [
"protected",
"function",
"setQuery",
"(",
"$",
"query",
")",
"{",
"$",
"this",
"->",
"uriString",
"=",
"null",
";",
"$",
"query",
"=",
"ltrim",
"(",
"$",
"query",
",",
"'?'",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"query",
",",
"'#'",
")",
"!==",
"false",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Query string must not include a URI fragment.'",
")",
";",
"}",
"$",
"this",
"->",
"query",
"=",
"static",
"::",
"encode",
"(",
"$",
"query",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the provided query string to current instance.
@param string $query The query string
@throws \InvalidArgumentException If query string contain URI fragment
@return Uri The current instance with the provided query string | [
"Sets",
"the",
"provided",
"query",
"string",
"to",
"current",
"instance",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Uri.php#L657-L672 |
6,329 | easy-system/es-http | src/Uri.php | Uri.setFragment | protected function setFragment($fragment)
{
$this->uriString = null;
$fragment = ltrim($fragment, '#');
$this->fragment = static::encode($fragment);
return $this;
} | php | protected function setFragment($fragment)
{
$this->uriString = null;
$fragment = ltrim($fragment, '#');
$this->fragment = static::encode($fragment);
return $this;
} | [
"protected",
"function",
"setFragment",
"(",
"$",
"fragment",
")",
"{",
"$",
"this",
"->",
"uriString",
"=",
"null",
";",
"$",
"fragment",
"=",
"ltrim",
"(",
"$",
"fragment",
",",
"'#'",
")",
";",
"$",
"this",
"->",
"fragment",
"=",
"static",
"::",
"encode",
"(",
"$",
"fragment",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the provided URI fragment to current instance.
@param type $fragment The URI fragment
@return Uri The current instance with the provided URI fragment | [
"Sets",
"the",
"provided",
"URI",
"fragment",
"to",
"current",
"instance",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Uri.php#L681-L690 |
6,330 | wasabi-cms/cms | src/Controller/SettingsController.php | SettingsController.theme | public function theme()
{
$keys = [
'Theme_id'
];
/** @var ThemeSettingsTable $ThemeSettings */
$ThemeSettings = $this->loadModel('Wasabi/Cms.ThemeSettings');
$settings = $ThemeSettings->getKeyValues(new GeneralSetting(), $keys);
if ($this->request->is('post') && !empty($this->request->data)) {
$settings = $ThemeSettings->newEntity($this->request->data);
if (!$settings->errors()) {
if ($ThemeSettings->saveKeyValues($settings, $keys)) {
$this->Flash->success(__d('wasabi_cms', 'The theme settings have been updated.'));
$this->redirect(['action' => 'theme']);
return;
} else {
$this->Flash->error($this->dbErrorMessage);
}
} else {
$this->Flash->error($this->formErrorMessage);
}
}
$this->set([
'settings' => $settings,
'themes' => ThemeManager::getThemesForSelect()
]);
} | php | public function theme()
{
$keys = [
'Theme_id'
];
/** @var ThemeSettingsTable $ThemeSettings */
$ThemeSettings = $this->loadModel('Wasabi/Cms.ThemeSettings');
$settings = $ThemeSettings->getKeyValues(new GeneralSetting(), $keys);
if ($this->request->is('post') && !empty($this->request->data)) {
$settings = $ThemeSettings->newEntity($this->request->data);
if (!$settings->errors()) {
if ($ThemeSettings->saveKeyValues($settings, $keys)) {
$this->Flash->success(__d('wasabi_cms', 'The theme settings have been updated.'));
$this->redirect(['action' => 'theme']);
return;
} else {
$this->Flash->error($this->dbErrorMessage);
}
} else {
$this->Flash->error($this->formErrorMessage);
}
}
$this->set([
'settings' => $settings,
'themes' => ThemeManager::getThemesForSelect()
]);
} | [
"public",
"function",
"theme",
"(",
")",
"{",
"$",
"keys",
"=",
"[",
"'Theme_id'",
"]",
";",
"/** @var ThemeSettingsTable $ThemeSettings */",
"$",
"ThemeSettings",
"=",
"$",
"this",
"->",
"loadModel",
"(",
"'Wasabi/Cms.ThemeSettings'",
")",
";",
"$",
"settings",
"=",
"$",
"ThemeSettings",
"->",
"getKeyValues",
"(",
"new",
"GeneralSetting",
"(",
")",
",",
"$",
"keys",
")",
";",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"is",
"(",
"'post'",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"request",
"->",
"data",
")",
")",
"{",
"$",
"settings",
"=",
"$",
"ThemeSettings",
"->",
"newEntity",
"(",
"$",
"this",
"->",
"request",
"->",
"data",
")",
";",
"if",
"(",
"!",
"$",
"settings",
"->",
"errors",
"(",
")",
")",
"{",
"if",
"(",
"$",
"ThemeSettings",
"->",
"saveKeyValues",
"(",
"$",
"settings",
",",
"$",
"keys",
")",
")",
"{",
"$",
"this",
"->",
"Flash",
"->",
"success",
"(",
"__d",
"(",
"'wasabi_cms'",
",",
"'The theme settings have been updated.'",
")",
")",
";",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'action'",
"=>",
"'theme'",
"]",
")",
";",
"return",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"Flash",
"->",
"error",
"(",
"$",
"this",
"->",
"dbErrorMessage",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"Flash",
"->",
"error",
"(",
"$",
"this",
"->",
"formErrorMessage",
")",
";",
"}",
"}",
"$",
"this",
"->",
"set",
"(",
"[",
"'settings'",
"=>",
"$",
"settings",
",",
"'themes'",
"=>",
"ThemeManager",
"::",
"getThemesForSelect",
"(",
")",
"]",
")",
";",
"}"
] | theme action
GET | POST | [
"theme",
"action",
"GET",
"|",
"POST"
] | 2787b6422ea1d719cf49951b3253fd0ac31d22ca | https://github.com/wasabi-cms/cms/blob/2787b6422ea1d719cf49951b3253fd0ac31d22ca/src/Controller/SettingsController.php#L19-L48 |
6,331 | wasabi-cms/cms | src/Controller/SettingsController.php | SettingsController.seo | public function seo()
{
$keys = [
'SEO__application-name',
'SEO__google-site-verification',
'SEO__meta-robots-index',
'SEO__meta-robots-follow',
'SEO__meta-robots-noodp',
'SEO__display-search-box',
'SEO__Social__facebook_url',
'SEO__Social__facebook_page_id',
'SEO__Social__twitter_username',
'SEO__Social__instagram_url',
'SEO__Social__linkedin_url',
'SEO__Social__myspace_url',
'SEO__Social__pinterest_url',
'SEO__Social__youtube_url',
'SEO__Social__googleplus_url'
];
/** @var SeoSettingsTable $SeoSettings */
$SeoSettings = $this->loadModel('Wasabi/Cms.SeoSettings');
$settings = $SeoSettings->getKeyValues(new GeneralSetting(), $keys);
if ($this->request->is('post') && !empty($this->request->data)) {
$this->request->data['SEO__Social__twitter_username'] = ltrim(trim($this->request->data['SEO__Social__twitter_username']), '@');
$settings = $SeoSettings->newEntity($this->request->data);
if (!$settings->errors()) {
if ($SeoSettings->saveKeyValues($settings, $keys)) {
$this->Flash->success(__d('wasabi_cms', 'The SEO settings have been updated.'));
$this->redirect(['action' => 'seo']);
return;
} else {
$this->Flash->error($this->dbErrorMessage);
}
} else {
$this->Flash->error($this->formErrorMessage);
}
}
$this->set([
'settings' => $settings
]);
} | php | public function seo()
{
$keys = [
'SEO__application-name',
'SEO__google-site-verification',
'SEO__meta-robots-index',
'SEO__meta-robots-follow',
'SEO__meta-robots-noodp',
'SEO__display-search-box',
'SEO__Social__facebook_url',
'SEO__Social__facebook_page_id',
'SEO__Social__twitter_username',
'SEO__Social__instagram_url',
'SEO__Social__linkedin_url',
'SEO__Social__myspace_url',
'SEO__Social__pinterest_url',
'SEO__Social__youtube_url',
'SEO__Social__googleplus_url'
];
/** @var SeoSettingsTable $SeoSettings */
$SeoSettings = $this->loadModel('Wasabi/Cms.SeoSettings');
$settings = $SeoSettings->getKeyValues(new GeneralSetting(), $keys);
if ($this->request->is('post') && !empty($this->request->data)) {
$this->request->data['SEO__Social__twitter_username'] = ltrim(trim($this->request->data['SEO__Social__twitter_username']), '@');
$settings = $SeoSettings->newEntity($this->request->data);
if (!$settings->errors()) {
if ($SeoSettings->saveKeyValues($settings, $keys)) {
$this->Flash->success(__d('wasabi_cms', 'The SEO settings have been updated.'));
$this->redirect(['action' => 'seo']);
return;
} else {
$this->Flash->error($this->dbErrorMessage);
}
} else {
$this->Flash->error($this->formErrorMessage);
}
}
$this->set([
'settings' => $settings
]);
} | [
"public",
"function",
"seo",
"(",
")",
"{",
"$",
"keys",
"=",
"[",
"'SEO__application-name'",
",",
"'SEO__google-site-verification'",
",",
"'SEO__meta-robots-index'",
",",
"'SEO__meta-robots-follow'",
",",
"'SEO__meta-robots-noodp'",
",",
"'SEO__display-search-box'",
",",
"'SEO__Social__facebook_url'",
",",
"'SEO__Social__facebook_page_id'",
",",
"'SEO__Social__twitter_username'",
",",
"'SEO__Social__instagram_url'",
",",
"'SEO__Social__linkedin_url'",
",",
"'SEO__Social__myspace_url'",
",",
"'SEO__Social__pinterest_url'",
",",
"'SEO__Social__youtube_url'",
",",
"'SEO__Social__googleplus_url'",
"]",
";",
"/** @var SeoSettingsTable $SeoSettings */",
"$",
"SeoSettings",
"=",
"$",
"this",
"->",
"loadModel",
"(",
"'Wasabi/Cms.SeoSettings'",
")",
";",
"$",
"settings",
"=",
"$",
"SeoSettings",
"->",
"getKeyValues",
"(",
"new",
"GeneralSetting",
"(",
")",
",",
"$",
"keys",
")",
";",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"is",
"(",
"'post'",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"request",
"->",
"data",
")",
")",
"{",
"$",
"this",
"->",
"request",
"->",
"data",
"[",
"'SEO__Social__twitter_username'",
"]",
"=",
"ltrim",
"(",
"trim",
"(",
"$",
"this",
"->",
"request",
"->",
"data",
"[",
"'SEO__Social__twitter_username'",
"]",
")",
",",
"'@'",
")",
";",
"$",
"settings",
"=",
"$",
"SeoSettings",
"->",
"newEntity",
"(",
"$",
"this",
"->",
"request",
"->",
"data",
")",
";",
"if",
"(",
"!",
"$",
"settings",
"->",
"errors",
"(",
")",
")",
"{",
"if",
"(",
"$",
"SeoSettings",
"->",
"saveKeyValues",
"(",
"$",
"settings",
",",
"$",
"keys",
")",
")",
"{",
"$",
"this",
"->",
"Flash",
"->",
"success",
"(",
"__d",
"(",
"'wasabi_cms'",
",",
"'The SEO settings have been updated.'",
")",
")",
";",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'action'",
"=>",
"'seo'",
"]",
")",
";",
"return",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"Flash",
"->",
"error",
"(",
"$",
"this",
"->",
"dbErrorMessage",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"Flash",
"->",
"error",
"(",
"$",
"this",
"->",
"formErrorMessage",
")",
";",
"}",
"}",
"$",
"this",
"->",
"set",
"(",
"[",
"'settings'",
"=>",
"$",
"settings",
"]",
")",
";",
"}"
] | seo action
GET | POST | [
"seo",
"action",
"GET",
"|",
"POST"
] | 2787b6422ea1d719cf49951b3253fd0ac31d22ca | https://github.com/wasabi-cms/cms/blob/2787b6422ea1d719cf49951b3253fd0ac31d22ca/src/Controller/SettingsController.php#L54-L97 |
6,332 | Fenzland/Htsl.php | libs/Parser/Node/TagNode.php | TagNode.open | public function open():string
{
if( isset($this->config['opener']) )
{ return $this->config['opener']; }
$this->parsePrivateAttributes();
$this->parseCommonAttributes();
if( isset($this->config['in_scope']) && isset($this->config['scope_function']) && is_callable($this->config['scope_function']) )
{ $this->config['scope_function']->call($this,$this->document->scope); }
$finisher= $this->isEmpty ? ' />' : '>';
return "<{$this->tagName}{$this->attributesString}{$finisher}";
} | php | public function open():string
{
if( isset($this->config['opener']) )
{ return $this->config['opener']; }
$this->parsePrivateAttributes();
$this->parseCommonAttributes();
if( isset($this->config['in_scope']) && isset($this->config['scope_function']) && is_callable($this->config['scope_function']) )
{ $this->config['scope_function']->call($this,$this->document->scope); }
$finisher= $this->isEmpty ? ' />' : '>';
return "<{$this->tagName}{$this->attributesString}{$finisher}";
} | [
"public",
"function",
"open",
"(",
")",
":",
"string",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'opener'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"config",
"[",
"'opener'",
"]",
";",
"}",
"$",
"this",
"->",
"parsePrivateAttributes",
"(",
")",
";",
"$",
"this",
"->",
"parseCommonAttributes",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'in_scope'",
"]",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'scope_function'",
"]",
")",
"&&",
"is_callable",
"(",
"$",
"this",
"->",
"config",
"[",
"'scope_function'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"config",
"[",
"'scope_function'",
"]",
"->",
"call",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"document",
"->",
"scope",
")",
";",
"}",
"$",
"finisher",
"=",
"$",
"this",
"->",
"isEmpty",
"?",
"' />'",
":",
"'>'",
";",
"return",
"\"<{$this->tagName}{$this->attributesString}{$finisher}\"",
";",
"}"
] | Opening this tag node, and returning node opener.
@access public
@return string | [
"Opening",
"this",
"tag",
"node",
"and",
"returning",
"node",
"opener",
"."
] | 28ecc4afd1a5bdb29dea3589c8132adba87f3947 | https://github.com/Fenzland/Htsl.php/blob/28ecc4afd1a5bdb29dea3589c8132adba87f3947/libs/Parser/Node/TagNode.php#L84-L98 |
6,333 | Fenzland/Htsl.php | libs/Parser/Node/TagNode.php | TagNode.sectionLedBy | protected function sectionLedBy( string$leader, bool$allowSpace=false ):string
{
return $this->line->pregGet(...[
(
'/ '.preg_quote($leader)
.
($allowSpace?
'((?!\()(?:[^ ]| (?=[a-zA-Z0-9]))+'
:
'([^ ]+'
)
.
'|(?<exp>\((?:[^()]+|(?&exp)?)+?\)))(?= |$)/'
),
1,
]);
} | php | protected function sectionLedBy( string$leader, bool$allowSpace=false ):string
{
return $this->line->pregGet(...[
(
'/ '.preg_quote($leader)
.
($allowSpace?
'((?!\()(?:[^ ]| (?=[a-zA-Z0-9]))+'
:
'([^ ]+'
)
.
'|(?<exp>\((?:[^()]+|(?&exp)?)+?\)))(?= |$)/'
),
1,
]);
} | [
"protected",
"function",
"sectionLedBy",
"(",
"string",
"$",
"leader",
",",
"bool",
"$",
"allowSpace",
"=",
"false",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"line",
"->",
"pregGet",
"(",
"...",
"[",
"(",
"'/ '",
".",
"preg_quote",
"(",
"$",
"leader",
")",
".",
"(",
"$",
"allowSpace",
"?",
"'((?!\\()(?:[^ ]| (?=[a-zA-Z0-9]))+'",
":",
"'([^ ]+'",
")",
".",
"'|(?<exp>\\((?:[^()]+|(?&exp)?)+?\\)))(?= |$)/'",
")",
",",
"1",
",",
"]",
")",
";",
"}"
] | Getting tag section with given leader.
@access protected
@param string $leader
@param boool $allowSpace
@return string | [
"Getting",
"tag",
"section",
"with",
"given",
"leader",
"."
] | 28ecc4afd1a5bdb29dea3589c8132adba87f3947 | https://github.com/Fenzland/Htsl.php/blob/28ecc4afd1a5bdb29dea3589c8132adba87f3947/libs/Parser/Node/TagNode.php#L215-L231 |
6,334 | Fenzland/Htsl.php | libs/Parser/Node/TagNode.php | TagNode.setMultinameAttribute | private function setMultinameAttribute( string$name, string$value, callable$processer=null ):self
{
if( strlen($value) && !empty($this->config[$name]) ){
return $this->setAttribute($this->config[$name],call_user_func($processer??[$this,'checkExpression',],$value));
}
return $this;
} | php | private function setMultinameAttribute( string$name, string$value, callable$processer=null ):self
{
if( strlen($value) && !empty($this->config[$name]) ){
return $this->setAttribute($this->config[$name],call_user_func($processer??[$this,'checkExpression',],$value));
}
return $this;
} | [
"private",
"function",
"setMultinameAttribute",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"value",
",",
"callable",
"$",
"processer",
"=",
"null",
")",
":",
"self",
"{",
"if",
"(",
"strlen",
"(",
"$",
"value",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"config",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"setAttribute",
"(",
"$",
"this",
"->",
"config",
"[",
"$",
"name",
"]",
",",
"call_user_func",
"(",
"$",
"processer",
"??",
"[",
"$",
"this",
",",
"'checkExpression'",
",",
"]",
",",
"$",
"value",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Setting attribute whitch has same name in HTSL but different name in HTML.
@access private
@param string $name Attribute name of HTSL
@param string $value Attribute value
@param callable|null $processer
@return \Htsl\Parser\Node\TagNode | [
"Setting",
"attribute",
"whitch",
"has",
"same",
"name",
"in",
"HTSL",
"but",
"different",
"name",
"in",
"HTML",
"."
] | 28ecc4afd1a5bdb29dea3589c8132adba87f3947 | https://github.com/Fenzland/Htsl.php/blob/28ecc4afd1a5bdb29dea3589c8132adba87f3947/libs/Parser/Node/TagNode.php#L290-L297 |
6,335 | Fenzland/Htsl.php | libs/Parser/Node/TagNode.php | TagNode.checkExpression | protected function checkExpression( string$value ):string
{
return preg_match('/^\(.*\)$/',$value) ? '<?=str_replace(\'"\',\'"\','.substr($value,1,-1).')?>' : str_replace('"','"',$value);
} | php | protected function checkExpression( string$value ):string
{
return preg_match('/^\(.*\)$/',$value) ? '<?=str_replace(\'"\',\'"\','.substr($value,1,-1).')?>' : str_replace('"','"',$value);
} | [
"protected",
"function",
"checkExpression",
"(",
"string",
"$",
"value",
")",
":",
"string",
"{",
"return",
"preg_match",
"(",
"'/^\\(.*\\)$/'",
",",
"$",
"value",
")",
"?",
"'<?=str_replace(\\'\"\\',\\'"\\','",
".",
"substr",
"(",
"$",
"value",
",",
"1",
",",
"-",
"1",
")",
".",
"')?>'",
":",
"str_replace",
"(",
"'\"'",
",",
"'"'",
",",
"$",
"value",
")",
";",
"}"
] | Checking and parse PHP expressions.
@access protected
@param string $value
@return string | [
"Checking",
"and",
"parse",
"PHP",
"expressions",
"."
] | 28ecc4afd1a5bdb29dea3589c8132adba87f3947 | https://github.com/Fenzland/Htsl.php/blob/28ecc4afd1a5bdb29dea3589c8132adba87f3947/libs/Parser/Node/TagNode.php#L348-L351 |
6,336 | Fenzland/Htsl.php | libs/Parser/Node/TagNode.php | TagNode.getAttributesString | protected function getAttributesString():string
{
ksort($this->attributes);
return implode('',array_map(static function( string$key, array$data ){
return (isset($data['condition'])&&strlen($data['condition'])?
"<?php if( {$data['condition']} ){?> $key=\"{$data['value']}\"<?php }?>"
:
" $key=\"{$data['value']}\""
);
},array_keys($this->attributes),$this->attributes));
} | php | protected function getAttributesString():string
{
ksort($this->attributes);
return implode('',array_map(static function( string$key, array$data ){
return (isset($data['condition'])&&strlen($data['condition'])?
"<?php if( {$data['condition']} ){?> $key=\"{$data['value']}\"<?php }?>"
:
" $key=\"{$data['value']}\""
);
},array_keys($this->attributes),$this->attributes));
} | [
"protected",
"function",
"getAttributesString",
"(",
")",
":",
"string",
"{",
"ksort",
"(",
"$",
"this",
"->",
"attributes",
")",
";",
"return",
"implode",
"(",
"''",
",",
"array_map",
"(",
"static",
"function",
"(",
"string",
"$",
"key",
",",
"array",
"$",
"data",
")",
"{",
"return",
"(",
"isset",
"(",
"$",
"data",
"[",
"'condition'",
"]",
")",
"&&",
"strlen",
"(",
"$",
"data",
"[",
"'condition'",
"]",
")",
"?",
"\"<?php if( {$data['condition']} ){?> $key=\\\"{$data['value']}\\\"<?php }?>\"",
":",
"\" $key=\\\"{$data['value']}\\\"\"",
")",
";",
"}",
",",
"array_keys",
"(",
"$",
"this",
"->",
"attributes",
")",
",",
"$",
"this",
"->",
"attributes",
")",
")",
";",
"}"
] | Getting attribute string with HTML syntax.
@access protected
@return string | [
"Getting",
"attribute",
"string",
"with",
"HTML",
"syntax",
"."
] | 28ecc4afd1a5bdb29dea3589c8132adba87f3947 | https://github.com/Fenzland/Htsl.php/blob/28ecc4afd1a5bdb29dea3589c8132adba87f3947/libs/Parser/Node/TagNode.php#L360-L370 |
6,337 | Fenzland/Htsl.php | libs/Parser/Node/TagNode.php | TagNode.setAttribute | protected function setAttribute( string$key, string$value, string$condition=null ):self
{
if( isset($this->attributes[$key]) )
{ $this->document->throw("Attribute $key of $this->name cannot redeclare."); }
$this->attributes[$key]=[
'value'=> $value,
'condition'=> $condition,
];
return $this;
} | php | protected function setAttribute( string$key, string$value, string$condition=null ):self
{
if( isset($this->attributes[$key]) )
{ $this->document->throw("Attribute $key of $this->name cannot redeclare."); }
$this->attributes[$key]=[
'value'=> $value,
'condition'=> $condition,
];
return $this;
} | [
"protected",
"function",
"setAttribute",
"(",
"string",
"$",
"key",
",",
"string",
"$",
"value",
",",
"string",
"$",
"condition",
"=",
"null",
")",
":",
"self",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"document",
"->",
"throw",
"(",
"\"Attribute $key of $this->name cannot redeclare.\"",
")",
";",
"}",
"$",
"this",
"->",
"attributes",
"[",
"$",
"key",
"]",
"=",
"[",
"'value'",
"=>",
"$",
"value",
",",
"'condition'",
"=>",
"$",
"condition",
",",
"]",
";",
"return",
"$",
"this",
";",
"}"
] | Setting attribute.
@access protected
@param string $key Attribute name.
@param string $value Attribute value
@param string|null $condition Optional condition, If given, attribute will seted only when condition is true. | [
"Setting",
"attribute",
"."
] | 28ecc4afd1a5bdb29dea3589c8132adba87f3947 | https://github.com/Fenzland/Htsl.php/blob/28ecc4afd1a5bdb29dea3589c8132adba87f3947/libs/Parser/Node/TagNode.php#L381-L392 |
6,338 | agalbourdin/agl-core | src/Data/String.php | String.toCamelCase | public static function toCamelCase($pStr, $pCapitaliseFirstChar = true)
{
if (empty($pStr)) {
return $pStr;
}
$pStr = strtolower($pStr);
if ($pCapitaliseFirstChar) {
$pStr[0] = strtoupper($pStr[0]);
}
return preg_replace_callback('/_([a-z])/', function ($pMatches)
{
return strtoupper($pMatches[1]);
}, $pStr);
} | php | public static function toCamelCase($pStr, $pCapitaliseFirstChar = true)
{
if (empty($pStr)) {
return $pStr;
}
$pStr = strtolower($pStr);
if ($pCapitaliseFirstChar) {
$pStr[0] = strtoupper($pStr[0]);
}
return preg_replace_callback('/_([a-z])/', function ($pMatches)
{
return strtoupper($pMatches[1]);
}, $pStr);
} | [
"public",
"static",
"function",
"toCamelCase",
"(",
"$",
"pStr",
",",
"$",
"pCapitaliseFirstChar",
"=",
"true",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"pStr",
")",
")",
"{",
"return",
"$",
"pStr",
";",
"}",
"$",
"pStr",
"=",
"strtolower",
"(",
"$",
"pStr",
")",
";",
"if",
"(",
"$",
"pCapitaliseFirstChar",
")",
"{",
"$",
"pStr",
"[",
"0",
"]",
"=",
"strtoupper",
"(",
"$",
"pStr",
"[",
"0",
"]",
")",
";",
"}",
"return",
"preg_replace_callback",
"(",
"'/_([a-z])/'",
",",
"function",
"(",
"$",
"pMatches",
")",
"{",
"return",
"strtoupper",
"(",
"$",
"pMatches",
"[",
"1",
"]",
")",
";",
"}",
",",
"$",
"pStr",
")",
";",
"}"
] | Create a camel-case string.
@param string $pStr Chaîne au format classique (avec "_")
@param bool $pCapitaliseFirstChar Make the first char uppercase
@return string Camel-case string | [
"Create",
"a",
"camel",
"-",
"case",
"string",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Data/String.php#L43-L59 |
6,339 | agalbourdin/agl-core | src/Data/String.php | String.fromCamelCase | public static function fromCamelCase($pStr)
{
if (empty($pStr)) {
return $pStr;
}
$pStr[0] = strtolower($pStr[0]);
return preg_replace_callback('/([A-Z])/', function ($pMatches)
{
return '_' . strtolower($pMatches[0]);
}, $pStr);
} | php | public static function fromCamelCase($pStr)
{
if (empty($pStr)) {
return $pStr;
}
$pStr[0] = strtolower($pStr[0]);
return preg_replace_callback('/([A-Z])/', function ($pMatches)
{
return '_' . strtolower($pMatches[0]);
}, $pStr);
} | [
"public",
"static",
"function",
"fromCamelCase",
"(",
"$",
"pStr",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"pStr",
")",
")",
"{",
"return",
"$",
"pStr",
";",
"}",
"$",
"pStr",
"[",
"0",
"]",
"=",
"strtolower",
"(",
"$",
"pStr",
"[",
"0",
"]",
")",
";",
"return",
"preg_replace_callback",
"(",
"'/([A-Z])/'",
",",
"function",
"(",
"$",
"pMatches",
")",
"{",
"return",
"'_'",
".",
"strtolower",
"(",
"$",
"pMatches",
"[",
"0",
"]",
")",
";",
"}",
",",
"$",
"pStr",
")",
";",
"}"
] | Revert a camel-case.
@param string $pStr Camel-case string
@return string Converted string | [
"Revert",
"a",
"camel",
"-",
"case",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Data/String.php#L67-L79 |
6,340 | agalbourdin/agl-core | src/Data/String.php | String.getRandomString | public static function getRandomString($pLength = 6, $pStrength = 1)
{
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
if ($pStrength >= 1) {
$chars .= '0123456789';
}
if ($pStrength >= 2) {
$strengthChars = '@#$%';
$chars .= $strengthChars;
}
$str = '';
for ($i = 0; $i < $pLength; $i++) {
$str .= $chars[(rand() % strlen($chars))];
}
if ($pStrength >= 2 and ! preg_match('/@|#|\$|%/', $str)) {
$str = substr($str, 0, -1);
$str = preg_replace("/^(.{" . (rand() % $pLength) ."})/", "$1" . $strengthChars[rand() % strlen($strengthChars)], $str);
}
return $str;
} | php | public static function getRandomString($pLength = 6, $pStrength = 1)
{
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
if ($pStrength >= 1) {
$chars .= '0123456789';
}
if ($pStrength >= 2) {
$strengthChars = '@#$%';
$chars .= $strengthChars;
}
$str = '';
for ($i = 0; $i < $pLength; $i++) {
$str .= $chars[(rand() % strlen($chars))];
}
if ($pStrength >= 2 and ! preg_match('/@|#|\$|%/', $str)) {
$str = substr($str, 0, -1);
$str = preg_replace("/^(.{" . (rand() % $pLength) ."})/", "$1" . $strengthChars[rand() % strlen($strengthChars)], $str);
}
return $str;
} | [
"public",
"static",
"function",
"getRandomString",
"(",
"$",
"pLength",
"=",
"6",
",",
"$",
"pStrength",
"=",
"1",
")",
"{",
"$",
"chars",
"=",
"'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'",
";",
"if",
"(",
"$",
"pStrength",
">=",
"1",
")",
"{",
"$",
"chars",
".=",
"'0123456789'",
";",
"}",
"if",
"(",
"$",
"pStrength",
">=",
"2",
")",
"{",
"$",
"strengthChars",
"=",
"'@#$%'",
";",
"$",
"chars",
".=",
"$",
"strengthChars",
";",
"}",
"$",
"str",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"pLength",
";",
"$",
"i",
"++",
")",
"{",
"$",
"str",
".=",
"$",
"chars",
"[",
"(",
"rand",
"(",
")",
"%",
"strlen",
"(",
"$",
"chars",
")",
")",
"]",
";",
"}",
"if",
"(",
"$",
"pStrength",
">=",
"2",
"and",
"!",
"preg_match",
"(",
"'/@|#|\\$|%/'",
",",
"$",
"str",
")",
")",
"{",
"$",
"str",
"=",
"substr",
"(",
"$",
"str",
",",
"0",
",",
"-",
"1",
")",
";",
"$",
"str",
"=",
"preg_replace",
"(",
"\"/^(.{\"",
".",
"(",
"rand",
"(",
")",
"%",
"$",
"pLength",
")",
".",
"\"})/\"",
",",
"\"$1\"",
".",
"$",
"strengthChars",
"[",
"rand",
"(",
")",
"%",
"strlen",
"(",
"$",
"strengthChars",
")",
"]",
",",
"$",
"str",
")",
";",
"}",
"return",
"$",
"str",
";",
"}"
] | Return a random string with a variable length and strength.
@param int $pLength Length of the string to generate
@param int $pStrength Strength of the string to generate
@return string Random string | [
"Return",
"a",
"random",
"string",
"with",
"a",
"variable",
"length",
"and",
"strength",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Data/String.php#L88-L111 |
6,341 | agalbourdin/agl-core | src/Data/String.php | String.truncate | public static function truncate($pStr, $pLimit, $pEnd = '...')
{
$str = strip_tags($pStr);
$length = mb_strlen($str);
if ($length <= $pLimit) {
return $str;
}
return trim(mb_substr($str, 0, $pLimit)) . $pEnd;
} | php | public static function truncate($pStr, $pLimit, $pEnd = '...')
{
$str = strip_tags($pStr);
$length = mb_strlen($str);
if ($length <= $pLimit) {
return $str;
}
return trim(mb_substr($str, 0, $pLimit)) . $pEnd;
} | [
"public",
"static",
"function",
"truncate",
"(",
"$",
"pStr",
",",
"$",
"pLimit",
",",
"$",
"pEnd",
"=",
"'...'",
")",
"{",
"$",
"str",
"=",
"strip_tags",
"(",
"$",
"pStr",
")",
";",
"$",
"length",
"=",
"mb_strlen",
"(",
"$",
"str",
")",
";",
"if",
"(",
"$",
"length",
"<=",
"$",
"pLimit",
")",
"{",
"return",
"$",
"str",
";",
"}",
"return",
"trim",
"(",
"mb_substr",
"(",
"$",
"str",
",",
"0",
",",
"$",
"pLimit",
")",
")",
".",
"$",
"pEnd",
";",
"}"
] | Truncate a string and add an optional suffix.
@param string $pStr String to truncate
@param int $pLimit Length of the string to return
@param string $pEnd Suffix | [
"Truncate",
"a",
"string",
"and",
"add",
"an",
"optional",
"suffix",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Data/String.php#L120-L129 |
6,342 | wearenolte/wp-widgets | src/Models/AbstractWidget.php | AbstractWidget.get_data | public function get_data() {
$settings = $this->get_settings()[ $this->number ];
return array_merge(
[ 'title' => $settings['title'] ],
Acf::get_widget_field( $this->id )
);
} | php | public function get_data() {
$settings = $this->get_settings()[ $this->number ];
return array_merge(
[ 'title' => $settings['title'] ],
Acf::get_widget_field( $this->id )
);
} | [
"public",
"function",
"get_data",
"(",
")",
"{",
"$",
"settings",
"=",
"$",
"this",
"->",
"get_settings",
"(",
")",
"[",
"$",
"this",
"->",
"number",
"]",
";",
"return",
"array_merge",
"(",
"[",
"'title'",
"=>",
"$",
"settings",
"[",
"'title'",
"]",
"]",
",",
"Acf",
"::",
"get_widget_field",
"(",
"$",
"this",
"->",
"id",
")",
")",
";",
"}"
] | Get the widget's data
@return mixed | [
"Get",
"the",
"widget",
"s",
"data"
] | 7b008dc3182f8b9da44657bd2fe714e7e48cf002 | https://github.com/wearenolte/wp-widgets/blob/7b008dc3182f8b9da44657bd2fe714e7e48cf002/src/Models/AbstractWidget.php#L53-L60 |
6,343 | mrcoco/phalms-core | user/forms/SignUpForm.php | SignUpForm.messages | public function messages($name)
{
if ($this->hasMessagesFor($name)) {
foreach ($this->getMessagesFor($name) as $message) {
$this->flash->error($message);
}
}
} | php | public function messages($name)
{
if ($this->hasMessagesFor($name)) {
foreach ($this->getMessagesFor($name) as $message) {
$this->flash->error($message);
}
}
} | [
"public",
"function",
"messages",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasMessagesFor",
"(",
"$",
"name",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getMessagesFor",
"(",
"$",
"name",
")",
"as",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"flash",
"->",
"error",
"(",
"$",
"message",
")",
";",
"}",
"}",
"}"
] | Prints messages for a specific element | [
"Prints",
"messages",
"for",
"a",
"specific",
"element"
] | 23486c3e75077896e708f0d2e257cde280a79ad4 | https://github.com/mrcoco/phalms-core/blob/23486c3e75077896e708f0d2e257cde280a79ad4/user/forms/SignUpForm.php#L122-L129 |
6,344 | Dhii/container-helper-base | src/ContainerSetPathCapableTrait.php | ContainerSetPathCapableTrait._containerSetPath | protected function _containerSetPath(&$container, $path, $value)
{
$path = $this->_normalizeArray($path);
$pathLength = count($path);
if (!$pathLength) {
throw $this->_createInvalidArgumentException($this->__('Path is empty'), null, null, $container);
}
if ($pathLength === 1) {
$this->_containerSet($container, $path[0], $value);
return;
}
$currentSegment = array_shift($path);
if (is_array($container)) {
$this->_containerSetPath($container[$currentSegment], $path, $value);
} else {
$childContainer = $this->_containerGet($container, $currentSegment);
$this->_containerSetPath($childContainer, $path, $value);
}
} | php | protected function _containerSetPath(&$container, $path, $value)
{
$path = $this->_normalizeArray($path);
$pathLength = count($path);
if (!$pathLength) {
throw $this->_createInvalidArgumentException($this->__('Path is empty'), null, null, $container);
}
if ($pathLength === 1) {
$this->_containerSet($container, $path[0], $value);
return;
}
$currentSegment = array_shift($path);
if (is_array($container)) {
$this->_containerSetPath($container[$currentSegment], $path, $value);
} else {
$childContainer = $this->_containerGet($container, $currentSegment);
$this->_containerSetPath($childContainer, $path, $value);
}
} | [
"protected",
"function",
"_containerSetPath",
"(",
"&",
"$",
"container",
",",
"$",
"path",
",",
"$",
"value",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"_normalizeArray",
"(",
"$",
"path",
")",
";",
"$",
"pathLength",
"=",
"count",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"$",
"pathLength",
")",
"{",
"throw",
"$",
"this",
"->",
"_createInvalidArgumentException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Path is empty'",
")",
",",
"null",
",",
"null",
",",
"$",
"container",
")",
";",
"}",
"if",
"(",
"$",
"pathLength",
"===",
"1",
")",
"{",
"$",
"this",
"->",
"_containerSet",
"(",
"$",
"container",
",",
"$",
"path",
"[",
"0",
"]",
",",
"$",
"value",
")",
";",
"return",
";",
"}",
"$",
"currentSegment",
"=",
"array_shift",
"(",
"$",
"path",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"container",
")",
")",
"{",
"$",
"this",
"->",
"_containerSetPath",
"(",
"$",
"container",
"[",
"$",
"currentSegment",
"]",
",",
"$",
"path",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"childContainer",
"=",
"$",
"this",
"->",
"_containerGet",
"(",
"$",
"container",
",",
"$",
"currentSegment",
")",
";",
"$",
"this",
"->",
"_containerSetPath",
"(",
"$",
"childContainer",
",",
"$",
"path",
",",
"$",
"value",
")",
";",
"}",
"}"
] | Sets data on the nested container.
@since [*next-version*]
@param array|ArrayAccess|stdClass|BaseContainerInterface $container The top container in the chain.
@param array|Traversable|stdClass $path The list of path segments.
@param mixed $value The value to set by path.
@throws ContainerExceptionInterface If an error occurred while reading or writing from one of the containers in the chain.
@throws InvalidArgumentException If one of the containers in the chain is invalid.
@throws NotFoundExceptionInterface If one of the containers in the chain does not have the corresponding key.
@throws OutOfRangeException If key in one of the containers in the chain is invalid. | [
"Sets",
"data",
"on",
"the",
"nested",
"container",
"."
] | ccb2f56971d70cf203baa596cd14fdf91be6bfae | https://github.com/Dhii/container-helper-base/blob/ccb2f56971d70cf203baa596cd14fdf91be6bfae/src/ContainerSetPathCapableTrait.php#L37-L59 |
6,345 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.BodyBox | public function BodyBox($Column = 'Body', $Attributes = array()) {
TouchValue('MultiLine', $Attributes, TRUE);
TouchValue('format', $Attributes, $this->GetValue('Format', C('Garden.InputFormatter')));
TouchValue('Wrap', $Attributes, TRUE);
TouchValue('class', $Attributes, '');
$Attributes['class'] .= ' TextBox BodyBox';
$this->SetValue('Format', $Attributes['format']);
$this->EventArguments['Table'] = GetValue('Table', $Attributes);
$this->EventArguments['Column'] = $Column;
$this->FireEvent('BeforeBodyBox');
return $this->TextBox($Column, $Attributes).$this->Hidden('Format');
} | php | public function BodyBox($Column = 'Body', $Attributes = array()) {
TouchValue('MultiLine', $Attributes, TRUE);
TouchValue('format', $Attributes, $this->GetValue('Format', C('Garden.InputFormatter')));
TouchValue('Wrap', $Attributes, TRUE);
TouchValue('class', $Attributes, '');
$Attributes['class'] .= ' TextBox BodyBox';
$this->SetValue('Format', $Attributes['format']);
$this->EventArguments['Table'] = GetValue('Table', $Attributes);
$this->EventArguments['Column'] = $Column;
$this->FireEvent('BeforeBodyBox');
return $this->TextBox($Column, $Attributes).$this->Hidden('Format');
} | [
"public",
"function",
"BodyBox",
"(",
"$",
"Column",
"=",
"'Body'",
",",
"$",
"Attributes",
"=",
"array",
"(",
")",
")",
"{",
"TouchValue",
"(",
"'MultiLine'",
",",
"$",
"Attributes",
",",
"TRUE",
")",
";",
"TouchValue",
"(",
"'format'",
",",
"$",
"Attributes",
",",
"$",
"this",
"->",
"GetValue",
"(",
"'Format'",
",",
"C",
"(",
"'Garden.InputFormatter'",
")",
")",
")",
";",
"TouchValue",
"(",
"'Wrap'",
",",
"$",
"Attributes",
",",
"TRUE",
")",
";",
"TouchValue",
"(",
"'class'",
",",
"$",
"Attributes",
",",
"''",
")",
";",
"$",
"Attributes",
"[",
"'class'",
"]",
".=",
"' TextBox BodyBox'",
";",
"$",
"this",
"->",
"SetValue",
"(",
"'Format'",
",",
"$",
"Attributes",
"[",
"'format'",
"]",
")",
";",
"$",
"this",
"->",
"EventArguments",
"[",
"'Table'",
"]",
"=",
"GetValue",
"(",
"'Table'",
",",
"$",
"Attributes",
")",
";",
"$",
"this",
"->",
"EventArguments",
"[",
"'Column'",
"]",
"=",
"$",
"Column",
";",
"$",
"this",
"->",
"FireEvent",
"(",
"'BeforeBodyBox'",
")",
";",
"return",
"$",
"this",
"->",
"TextBox",
"(",
"$",
"Column",
",",
"$",
"Attributes",
")",
".",
"$",
"this",
"->",
"Hidden",
"(",
"'Format'",
")",
";",
"}"
] | A special text box for formattable text.
Formatting plugins like ButtonBar will auto-attach to this element.
@param string $Column
@param array $Attributes
@since 2.1
@return string HTML element. | [
"A",
"special",
"text",
"box",
"for",
"formattable",
"text",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L150-L164 |
6,346 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.Button | public function Button($ButtonCode, $Attributes = FALSE) {
$Type = ArrayValueI('type', $Attributes);
if ($Type === FALSE) $Type = 'submit';
$CssClass = ArrayValueI('class', $Attributes);
if ($CssClass === FALSE) $Attributes['class'] = 'Button';
$Return = '<input type="' . $Type . '"';
$Return .= $this->_IDAttribute($ButtonCode, $Attributes);
$Return .= $this->_NameAttribute($ButtonCode, $Attributes);
$Return .= ' value="' . T($ButtonCode, ArrayValue('value', $Attributes)) . '"';
$Return .= $this->_AttributesToString($Attributes);
$Return .= " />\n";
return $Return;
} | php | public function Button($ButtonCode, $Attributes = FALSE) {
$Type = ArrayValueI('type', $Attributes);
if ($Type === FALSE) $Type = 'submit';
$CssClass = ArrayValueI('class', $Attributes);
if ($CssClass === FALSE) $Attributes['class'] = 'Button';
$Return = '<input type="' . $Type . '"';
$Return .= $this->_IDAttribute($ButtonCode, $Attributes);
$Return .= $this->_NameAttribute($ButtonCode, $Attributes);
$Return .= ' value="' . T($ButtonCode, ArrayValue('value', $Attributes)) . '"';
$Return .= $this->_AttributesToString($Attributes);
$Return .= " />\n";
return $Return;
} | [
"public",
"function",
"Button",
"(",
"$",
"ButtonCode",
",",
"$",
"Attributes",
"=",
"FALSE",
")",
"{",
"$",
"Type",
"=",
"ArrayValueI",
"(",
"'type'",
",",
"$",
"Attributes",
")",
";",
"if",
"(",
"$",
"Type",
"===",
"FALSE",
")",
"$",
"Type",
"=",
"'submit'",
";",
"$",
"CssClass",
"=",
"ArrayValueI",
"(",
"'class'",
",",
"$",
"Attributes",
")",
";",
"if",
"(",
"$",
"CssClass",
"===",
"FALSE",
")",
"$",
"Attributes",
"[",
"'class'",
"]",
"=",
"'Button'",
";",
"$",
"Return",
"=",
"'<input type=\"'",
".",
"$",
"Type",
".",
"'\"'",
";",
"$",
"Return",
".=",
"$",
"this",
"->",
"_IDAttribute",
"(",
"$",
"ButtonCode",
",",
"$",
"Attributes",
")",
";",
"$",
"Return",
".=",
"$",
"this",
"->",
"_NameAttribute",
"(",
"$",
"ButtonCode",
",",
"$",
"Attributes",
")",
";",
"$",
"Return",
".=",
"' value=\"'",
".",
"T",
"(",
"$",
"ButtonCode",
",",
"ArrayValue",
"(",
"'value'",
",",
"$",
"Attributes",
")",
")",
".",
"'\"'",
";",
"$",
"Return",
".=",
"$",
"this",
"->",
"_AttributesToString",
"(",
"$",
"Attributes",
")",
";",
"$",
"Return",
".=",
"\" />\\n\"",
";",
"return",
"$",
"Return",
";",
"}"
] | Returns XHTML for a button.
@param string $ButtonCode The translation code for the text on the button.
@param array $Attributes An associative array of attributes for the button. Here is a list of
"special" attributes and their default values:
Attribute Options Default
------------------------------------------------------------------------
Type The type of submit button 'submit'
Value Ignored for $ButtonCode $ButtonCode translated
@return string | [
"Returns",
"XHTML",
"for",
"a",
"button",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L179-L193 |
6,347 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.Calendar | public function Calendar($FieldName, $Attributes = FALSE) {
// TODO: CREATE A CALENDAR HELPER CLASS AND LOAD/REFERENCE IT HERE.
// THE CLASS SHOULD BE DECLARED WITH:
// if (!class_exists('Calendar') {
// AT THE BEGINNING SO OTHERS CAN OVERRIDE THE DEFAULT CALENDAR WITH ONE
// OF THEIR OWN.
$Class = ArrayValueI(
'class', $Attributes, FALSE);
if ($Class === FALSE) $Attributes['class'] = 'DateBox';
// IN THE MEANTIME...
return $this->Input($FieldName, 'text', $Attributes);
} | php | public function Calendar($FieldName, $Attributes = FALSE) {
// TODO: CREATE A CALENDAR HELPER CLASS AND LOAD/REFERENCE IT HERE.
// THE CLASS SHOULD BE DECLARED WITH:
// if (!class_exists('Calendar') {
// AT THE BEGINNING SO OTHERS CAN OVERRIDE THE DEFAULT CALENDAR WITH ONE
// OF THEIR OWN.
$Class = ArrayValueI(
'class', $Attributes, FALSE);
if ($Class === FALSE) $Attributes['class'] = 'DateBox';
// IN THE MEANTIME...
return $this->Input($FieldName, 'text', $Attributes);
} | [
"public",
"function",
"Calendar",
"(",
"$",
"FieldName",
",",
"$",
"Attributes",
"=",
"FALSE",
")",
"{",
"// TODO: CREATE A CALENDAR HELPER CLASS AND LOAD/REFERENCE IT HERE.",
"// THE CLASS SHOULD BE DECLARED WITH:",
"// if (!class_exists('Calendar') {",
"// AT THE BEGINNING SO OTHERS CAN OVERRIDE THE DEFAULT CALENDAR WITH ONE",
"// OF THEIR OWN.",
"$",
"Class",
"=",
"ArrayValueI",
"(",
"'class'",
",",
"$",
"Attributes",
",",
"FALSE",
")",
";",
"if",
"(",
"$",
"Class",
"===",
"FALSE",
")",
"$",
"Attributes",
"[",
"'class'",
"]",
"=",
"'DateBox'",
";",
"// IN THE MEANTIME...",
"return",
"$",
"this",
"->",
"Input",
"(",
"$",
"FieldName",
",",
"'text'",
",",
"$",
"Attributes",
")",
";",
"}"
] | Returns XHTML for a standard calendar input control.
@param string $FieldName The name of the field that is being displayed/posted with this input. It
should related directly to a field name in $this->_DataArray.
@param array $Attributes An associative array of attributes for the input. ie. onclick, class, etc
@return string
@todo Create calendar helper | [
"Returns",
"XHTML",
"for",
"a",
"standard",
"calendar",
"input",
"control",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L204-L216 |
6,348 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.CheckBox | public function CheckBox($FieldName, $Label = '', $Attributes = FALSE) {
$Value = ArrayValueI('value', $Attributes, true);
$Attributes['value'] = $Value;
if ($this->GetValue($FieldName) == $Value)
$Attributes['checked'] = 'checked';
// Show inline errors?
$ShowErrors = ($this->_InlineErrors && array_key_exists($FieldName, $this->_ValidationResults));
// Add error class to input element
if ($ShowErrors)
$this->AddErrorClass($Attributes);
$Input = $this->Input($FieldName, 'checkbox', $Attributes);
if ($Label != '') $Input = '<label for="' . ArrayValueI('id', $Attributes,
$this->EscapeID($FieldName, FALSE)) . '" class="CheckBoxLabel"'.Attribute('title', GetValue('title', $Attributes)).'>' . $Input . ' ' .
T($Label) . '</label>';
// Append validation error message
if ($ShowErrors && ArrayValueI('InlineErrors', $Attributes, TRUE))
$Return .= $this->InlineError($FieldName);
return $Input;
} | php | public function CheckBox($FieldName, $Label = '', $Attributes = FALSE) {
$Value = ArrayValueI('value', $Attributes, true);
$Attributes['value'] = $Value;
if ($this->GetValue($FieldName) == $Value)
$Attributes['checked'] = 'checked';
// Show inline errors?
$ShowErrors = ($this->_InlineErrors && array_key_exists($FieldName, $this->_ValidationResults));
// Add error class to input element
if ($ShowErrors)
$this->AddErrorClass($Attributes);
$Input = $this->Input($FieldName, 'checkbox', $Attributes);
if ($Label != '') $Input = '<label for="' . ArrayValueI('id', $Attributes,
$this->EscapeID($FieldName, FALSE)) . '" class="CheckBoxLabel"'.Attribute('title', GetValue('title', $Attributes)).'>' . $Input . ' ' .
T($Label) . '</label>';
// Append validation error message
if ($ShowErrors && ArrayValueI('InlineErrors', $Attributes, TRUE))
$Return .= $this->InlineError($FieldName);
return $Input;
} | [
"public",
"function",
"CheckBox",
"(",
"$",
"FieldName",
",",
"$",
"Label",
"=",
"''",
",",
"$",
"Attributes",
"=",
"FALSE",
")",
"{",
"$",
"Value",
"=",
"ArrayValueI",
"(",
"'value'",
",",
"$",
"Attributes",
",",
"true",
")",
";",
"$",
"Attributes",
"[",
"'value'",
"]",
"=",
"$",
"Value",
";",
"if",
"(",
"$",
"this",
"->",
"GetValue",
"(",
"$",
"FieldName",
")",
"==",
"$",
"Value",
")",
"$",
"Attributes",
"[",
"'checked'",
"]",
"=",
"'checked'",
";",
"// Show inline errors?",
"$",
"ShowErrors",
"=",
"(",
"$",
"this",
"->",
"_InlineErrors",
"&&",
"array_key_exists",
"(",
"$",
"FieldName",
",",
"$",
"this",
"->",
"_ValidationResults",
")",
")",
";",
"// Add error class to input element",
"if",
"(",
"$",
"ShowErrors",
")",
"$",
"this",
"->",
"AddErrorClass",
"(",
"$",
"Attributes",
")",
";",
"$",
"Input",
"=",
"$",
"this",
"->",
"Input",
"(",
"$",
"FieldName",
",",
"'checkbox'",
",",
"$",
"Attributes",
")",
";",
"if",
"(",
"$",
"Label",
"!=",
"''",
")",
"$",
"Input",
"=",
"'<label for=\"'",
".",
"ArrayValueI",
"(",
"'id'",
",",
"$",
"Attributes",
",",
"$",
"this",
"->",
"EscapeID",
"(",
"$",
"FieldName",
",",
"FALSE",
")",
")",
".",
"'\" class=\"CheckBoxLabel\"'",
".",
"Attribute",
"(",
"'title'",
",",
"GetValue",
"(",
"'title'",
",",
"$",
"Attributes",
")",
")",
".",
"'>'",
".",
"$",
"Input",
".",
"' '",
".",
"T",
"(",
"$",
"Label",
")",
".",
"'</label>'",
";",
"// Append validation error message",
"if",
"(",
"$",
"ShowErrors",
"&&",
"ArrayValueI",
"(",
"'InlineErrors'",
",",
"$",
"Attributes",
",",
"TRUE",
")",
")",
"$",
"Return",
".=",
"$",
"this",
"->",
"InlineError",
"(",
"$",
"FieldName",
")",
";",
"return",
"$",
"Input",
";",
"}"
] | Returns XHTML for a checkbox input element.
Cannot consider all checkbox values to be boolean. (2009-04-02 mosullivan)
Cannot assume checkboxes are stored in database as string 'TRUE'. (2010-07-28 loki_racer)
@param string $FieldName Name of the field that is being displayed/posted with this input.
It should related directly to a field name in $this->_DataArray.
@param string $Label Label to place next to the checkbox.
@param array $Attributes Associative array of attributes for the input. (e.g. onclick, class)\
Setting 'InlineErrors' to FALSE prevents error message even if $this->InlineErrors is enabled.
@return string | [
"Returns",
"XHTML",
"for",
"a",
"checkbox",
"input",
"element",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L342-L366 |
6,349 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.CheckBoxList | public function CheckBoxList($FieldName, $DataSet, $ValueDataSet = NULL, $Attributes = FALSE) {
// Never display individual inline errors for these CheckBoxes
$Attributes['InlineErrors'] = FALSE;
$Return = '';
// If the form hasn't been posted back, use the provided $ValueDataSet
if ($this->IsPostBack() === FALSE) {
if ($ValueDataSet === NULL) {
$CheckedValues = $this->GetValue($FieldName);
} else {
$CheckedValues = $ValueDataSet;
if (is_object($ValueDataSet))
$CheckedValues = ConsolidateArrayValuesByKey($ValueDataSet->ResultArray(), $FieldName);
}
} else {
$CheckedValues = $this->GetFormValue($FieldName, array());
}
$i = 1;
if (is_object($DataSet)) {
$ValueField = ArrayValueI('ValueField', $Attributes, 'value');
$TextField = ArrayValueI('TextField', $Attributes, 'text');
foreach($DataSet->Result() as $Data) {
$Instance = $Attributes;
$Instance = RemoveKeyFromArray($Instance,
array('TextField', 'ValueField'));
$Instance['value'] = $Data->$ValueField;
$Instance['id'] = $FieldName . $i;
if (is_array($CheckedValues) && in_array($Data->$ValueField,
$CheckedValues)) {
$Instance['checked'] = 'checked';
}
$Return .= '<li>' . $this->CheckBox($FieldName . '[]',
$Data->$TextField, $Instance) . "</li>\n";
++$i;
}
} elseif (is_array($DataSet)) {
foreach($DataSet as $Text => $ID) {
// Set attributes for this instance
$Instance = $Attributes;
$Instance = RemoveKeyFromArray($Instance, array('TextField', 'ValueField'));
$Instance['id'] = $FieldName . $i;
if (is_array($ID)) {
$ValueField = ArrayValueI('ValueField', $Attributes, 'value');
$TextField = ArrayValueI('TextField', $Attributes, 'text');
$Text = GetValue($TextField, $ID, '');
$ID = GetValue($ValueField, $ID, '');
} else {
if (is_numeric($Text))
$Text = $ID;
}
$Instance['value'] = $ID;
if (is_array($CheckedValues) && in_array($ID, $CheckedValues)) {
$Instance['checked'] = 'checked';
}
$Return .= '<li>' . $this->CheckBox($FieldName . '[]', $Text, $Instance) . "</li>\n";
++$i;
}
}
return '<ul class="'.ConcatSep(' ', 'CheckBoxList', GetValue('listclass', $Attributes)).'">' . $Return . '</ul>';
} | php | public function CheckBoxList($FieldName, $DataSet, $ValueDataSet = NULL, $Attributes = FALSE) {
// Never display individual inline errors for these CheckBoxes
$Attributes['InlineErrors'] = FALSE;
$Return = '';
// If the form hasn't been posted back, use the provided $ValueDataSet
if ($this->IsPostBack() === FALSE) {
if ($ValueDataSet === NULL) {
$CheckedValues = $this->GetValue($FieldName);
} else {
$CheckedValues = $ValueDataSet;
if (is_object($ValueDataSet))
$CheckedValues = ConsolidateArrayValuesByKey($ValueDataSet->ResultArray(), $FieldName);
}
} else {
$CheckedValues = $this->GetFormValue($FieldName, array());
}
$i = 1;
if (is_object($DataSet)) {
$ValueField = ArrayValueI('ValueField', $Attributes, 'value');
$TextField = ArrayValueI('TextField', $Attributes, 'text');
foreach($DataSet->Result() as $Data) {
$Instance = $Attributes;
$Instance = RemoveKeyFromArray($Instance,
array('TextField', 'ValueField'));
$Instance['value'] = $Data->$ValueField;
$Instance['id'] = $FieldName . $i;
if (is_array($CheckedValues) && in_array($Data->$ValueField,
$CheckedValues)) {
$Instance['checked'] = 'checked';
}
$Return .= '<li>' . $this->CheckBox($FieldName . '[]',
$Data->$TextField, $Instance) . "</li>\n";
++$i;
}
} elseif (is_array($DataSet)) {
foreach($DataSet as $Text => $ID) {
// Set attributes for this instance
$Instance = $Attributes;
$Instance = RemoveKeyFromArray($Instance, array('TextField', 'ValueField'));
$Instance['id'] = $FieldName . $i;
if (is_array($ID)) {
$ValueField = ArrayValueI('ValueField', $Attributes, 'value');
$TextField = ArrayValueI('TextField', $Attributes, 'text');
$Text = GetValue($TextField, $ID, '');
$ID = GetValue($ValueField, $ID, '');
} else {
if (is_numeric($Text))
$Text = $ID;
}
$Instance['value'] = $ID;
if (is_array($CheckedValues) && in_array($ID, $CheckedValues)) {
$Instance['checked'] = 'checked';
}
$Return .= '<li>' . $this->CheckBox($FieldName . '[]', $Text, $Instance) . "</li>\n";
++$i;
}
}
return '<ul class="'.ConcatSep(' ', 'CheckBoxList', GetValue('listclass', $Attributes)).'">' . $Return . '</ul>';
} | [
"public",
"function",
"CheckBoxList",
"(",
"$",
"FieldName",
",",
"$",
"DataSet",
",",
"$",
"ValueDataSet",
"=",
"NULL",
",",
"$",
"Attributes",
"=",
"FALSE",
")",
"{",
"// Never display individual inline errors for these CheckBoxes",
"$",
"Attributes",
"[",
"'InlineErrors'",
"]",
"=",
"FALSE",
";",
"$",
"Return",
"=",
"''",
";",
"// If the form hasn't been posted back, use the provided $ValueDataSet",
"if",
"(",
"$",
"this",
"->",
"IsPostBack",
"(",
")",
"===",
"FALSE",
")",
"{",
"if",
"(",
"$",
"ValueDataSet",
"===",
"NULL",
")",
"{",
"$",
"CheckedValues",
"=",
"$",
"this",
"->",
"GetValue",
"(",
"$",
"FieldName",
")",
";",
"}",
"else",
"{",
"$",
"CheckedValues",
"=",
"$",
"ValueDataSet",
";",
"if",
"(",
"is_object",
"(",
"$",
"ValueDataSet",
")",
")",
"$",
"CheckedValues",
"=",
"ConsolidateArrayValuesByKey",
"(",
"$",
"ValueDataSet",
"->",
"ResultArray",
"(",
")",
",",
"$",
"FieldName",
")",
";",
"}",
"}",
"else",
"{",
"$",
"CheckedValues",
"=",
"$",
"this",
"->",
"GetFormValue",
"(",
"$",
"FieldName",
",",
"array",
"(",
")",
")",
";",
"}",
"$",
"i",
"=",
"1",
";",
"if",
"(",
"is_object",
"(",
"$",
"DataSet",
")",
")",
"{",
"$",
"ValueField",
"=",
"ArrayValueI",
"(",
"'ValueField'",
",",
"$",
"Attributes",
",",
"'value'",
")",
";",
"$",
"TextField",
"=",
"ArrayValueI",
"(",
"'TextField'",
",",
"$",
"Attributes",
",",
"'text'",
")",
";",
"foreach",
"(",
"$",
"DataSet",
"->",
"Result",
"(",
")",
"as",
"$",
"Data",
")",
"{",
"$",
"Instance",
"=",
"$",
"Attributes",
";",
"$",
"Instance",
"=",
"RemoveKeyFromArray",
"(",
"$",
"Instance",
",",
"array",
"(",
"'TextField'",
",",
"'ValueField'",
")",
")",
";",
"$",
"Instance",
"[",
"'value'",
"]",
"=",
"$",
"Data",
"->",
"$",
"ValueField",
";",
"$",
"Instance",
"[",
"'id'",
"]",
"=",
"$",
"FieldName",
".",
"$",
"i",
";",
"if",
"(",
"is_array",
"(",
"$",
"CheckedValues",
")",
"&&",
"in_array",
"(",
"$",
"Data",
"->",
"$",
"ValueField",
",",
"$",
"CheckedValues",
")",
")",
"{",
"$",
"Instance",
"[",
"'checked'",
"]",
"=",
"'checked'",
";",
"}",
"$",
"Return",
".=",
"'<li>'",
".",
"$",
"this",
"->",
"CheckBox",
"(",
"$",
"FieldName",
".",
"'[]'",
",",
"$",
"Data",
"->",
"$",
"TextField",
",",
"$",
"Instance",
")",
".",
"\"</li>\\n\"",
";",
"++",
"$",
"i",
";",
"}",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"DataSet",
")",
")",
"{",
"foreach",
"(",
"$",
"DataSet",
"as",
"$",
"Text",
"=>",
"$",
"ID",
")",
"{",
"// Set attributes for this instance",
"$",
"Instance",
"=",
"$",
"Attributes",
";",
"$",
"Instance",
"=",
"RemoveKeyFromArray",
"(",
"$",
"Instance",
",",
"array",
"(",
"'TextField'",
",",
"'ValueField'",
")",
")",
";",
"$",
"Instance",
"[",
"'id'",
"]",
"=",
"$",
"FieldName",
".",
"$",
"i",
";",
"if",
"(",
"is_array",
"(",
"$",
"ID",
")",
")",
"{",
"$",
"ValueField",
"=",
"ArrayValueI",
"(",
"'ValueField'",
",",
"$",
"Attributes",
",",
"'value'",
")",
";",
"$",
"TextField",
"=",
"ArrayValueI",
"(",
"'TextField'",
",",
"$",
"Attributes",
",",
"'text'",
")",
";",
"$",
"Text",
"=",
"GetValue",
"(",
"$",
"TextField",
",",
"$",
"ID",
",",
"''",
")",
";",
"$",
"ID",
"=",
"GetValue",
"(",
"$",
"ValueField",
",",
"$",
"ID",
",",
"''",
")",
";",
"}",
"else",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"Text",
")",
")",
"$",
"Text",
"=",
"$",
"ID",
";",
"}",
"$",
"Instance",
"[",
"'value'",
"]",
"=",
"$",
"ID",
";",
"if",
"(",
"is_array",
"(",
"$",
"CheckedValues",
")",
"&&",
"in_array",
"(",
"$",
"ID",
",",
"$",
"CheckedValues",
")",
")",
"{",
"$",
"Instance",
"[",
"'checked'",
"]",
"=",
"'checked'",
";",
"}",
"$",
"Return",
".=",
"'<li>'",
".",
"$",
"this",
"->",
"CheckBox",
"(",
"$",
"FieldName",
".",
"'[]'",
",",
"$",
"Text",
",",
"$",
"Instance",
")",
".",
"\"</li>\\n\"",
";",
"++",
"$",
"i",
";",
"}",
"}",
"return",
"'<ul class=\"'",
".",
"ConcatSep",
"(",
"' '",
",",
"'CheckBoxList'",
",",
"GetValue",
"(",
"'listclass'",
",",
"$",
"Attributes",
")",
")",
".",
"'\">'",
".",
"$",
"Return",
".",
"'</ul>'",
";",
"}"
] | Returns the XHTML for a list of checkboxes.
@param string $FieldName Name of the field being posted with this input.
@param mixed $DataSet Data to fill the checkbox list. Either an associative
array or a database dataset. ex: RoleID, Name from GDN_Role.
@param mixed $ValueDataSet Values to be pre-checked in $DataSet. Either an associative array
or a database dataset. ex: RoleID from GDN_UserRole for a single user.
@param array $Attributes An associative array of attributes for the select. Here is a list of
"special" attributes and their default values:
Attribute Options Default
------------------------------------------------------------------------
ValueField The name of the field in 'value'
$DataSet that contains the
option values.
TextField The name of the field in 'text'
$DataSet that contains the
option text.
@return string | [
"Returns",
"the",
"XHTML",
"for",
"a",
"list",
"of",
"checkboxes",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L392-L459 |
6,350 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.CheckBoxGrid | public function CheckBoxGrid($FieldName, $DataSet, $ValueDataSet, $Attributes) {
// Never display individual inline errors for these CheckBoxes
$Attributes['InlineErrors'] = FALSE;
$Return = '';
$CheckedValues = $ValueDataSet;
if (is_object($ValueDataSet)) $CheckedValues = ConsolidateArrayValuesByKey(
$ValueDataSet->ResultArray(), $FieldName);
$i = 1;
if (is_object($DataSet)) {
$ValueField = ArrayValueI('ValueField', $Attributes, 'value');
$TextField = ArrayValueI('TextField', $Attributes, 'text');
$LastGroup = '';
$Group = array();
$Rows = array();
$Cols = array();
$CheckBox = '';
foreach($DataSet->Result() as $Data) {
// Define the checkbox
$Instance = $Attributes;
$Instance = RemoveKeyFromArray($Instance, array('TextField', 'ValueField'));
$Instance['value'] = $Data->$ValueField;
$Instance['id'] = $FieldName . $i;
if (is_array($CheckedValues) && in_array($Data->$ValueField,
$CheckedValues)) {
$Instance['checked'] = 'checked';
}
$CheckBox = $this->CheckBox($FieldName . '[]', '', $Instance);
// Organize the checkbox into an array for this group
$CurrentTextField = $Data->$TextField;
$aCurrentTextField = explode('.', $CurrentTextField);
$aCurrentTextFieldCount = count($aCurrentTextField);
$GroupName = array_shift($aCurrentTextField);
$ColName = array_pop($aCurrentTextField);
if ($aCurrentTextFieldCount >= 3) {
$RowName = implode('.', $aCurrentTextField);
if ($GroupName != $LastGroup && $LastGroup != '') {
// Render the last group
$Return .= $this->GetCheckBoxGridGroup(
$LastGroup,
$Group,
$Rows,
$Cols);
// Clean out the $Group array & Rowcount
$Group = array();
$Rows = array();
$Cols = array();
}
if (array_key_exists($ColName, $Group) === FALSE || is_array($Group[$ColName]) === FALSE) {
$Group[$ColName] = array();
if (!in_array($ColName, $Cols))
$Cols[] = $ColName;
}
if (!in_array($RowName, $Rows))
$Rows[] = $RowName;
$Group[$ColName][$RowName] = $CheckBox;
$LastGroup = $GroupName;
}
++$i;
}
}
/*elseif (is_array($DataSet)) {
foreach ($DataSet as $Text => $ID) {
$Instance = $Attributes;
$Instance = RemoveKeyFromArray($Instance, array('TextField', 'ValueField'));
$Instance['id'] = $FieldName.$i;
if (is_numeric($Text))
$Text = $ID;
$Instance['value'] = $ID;
if (in_array($ID, $CheckedValues))
$Instance['checked'] = 'checked';
$Return .= $this->CheckBox($FieldName.'[]', $Text, $Instance)."\n";
$i++;
}
}
*/
return $Return . $this->GetCheckBoxGridGroup($LastGroup, $Group, $Rows, $Cols);
} | php | public function CheckBoxGrid($FieldName, $DataSet, $ValueDataSet, $Attributes) {
// Never display individual inline errors for these CheckBoxes
$Attributes['InlineErrors'] = FALSE;
$Return = '';
$CheckedValues = $ValueDataSet;
if (is_object($ValueDataSet)) $CheckedValues = ConsolidateArrayValuesByKey(
$ValueDataSet->ResultArray(), $FieldName);
$i = 1;
if (is_object($DataSet)) {
$ValueField = ArrayValueI('ValueField', $Attributes, 'value');
$TextField = ArrayValueI('TextField', $Attributes, 'text');
$LastGroup = '';
$Group = array();
$Rows = array();
$Cols = array();
$CheckBox = '';
foreach($DataSet->Result() as $Data) {
// Define the checkbox
$Instance = $Attributes;
$Instance = RemoveKeyFromArray($Instance, array('TextField', 'ValueField'));
$Instance['value'] = $Data->$ValueField;
$Instance['id'] = $FieldName . $i;
if (is_array($CheckedValues) && in_array($Data->$ValueField,
$CheckedValues)) {
$Instance['checked'] = 'checked';
}
$CheckBox = $this->CheckBox($FieldName . '[]', '', $Instance);
// Organize the checkbox into an array for this group
$CurrentTextField = $Data->$TextField;
$aCurrentTextField = explode('.', $CurrentTextField);
$aCurrentTextFieldCount = count($aCurrentTextField);
$GroupName = array_shift($aCurrentTextField);
$ColName = array_pop($aCurrentTextField);
if ($aCurrentTextFieldCount >= 3) {
$RowName = implode('.', $aCurrentTextField);
if ($GroupName != $LastGroup && $LastGroup != '') {
// Render the last group
$Return .= $this->GetCheckBoxGridGroup(
$LastGroup,
$Group,
$Rows,
$Cols);
// Clean out the $Group array & Rowcount
$Group = array();
$Rows = array();
$Cols = array();
}
if (array_key_exists($ColName, $Group) === FALSE || is_array($Group[$ColName]) === FALSE) {
$Group[$ColName] = array();
if (!in_array($ColName, $Cols))
$Cols[] = $ColName;
}
if (!in_array($RowName, $Rows))
$Rows[] = $RowName;
$Group[$ColName][$RowName] = $CheckBox;
$LastGroup = $GroupName;
}
++$i;
}
}
/*elseif (is_array($DataSet)) {
foreach ($DataSet as $Text => $ID) {
$Instance = $Attributes;
$Instance = RemoveKeyFromArray($Instance, array('TextField', 'ValueField'));
$Instance['id'] = $FieldName.$i;
if (is_numeric($Text))
$Text = $ID;
$Instance['value'] = $ID;
if (in_array($ID, $CheckedValues))
$Instance['checked'] = 'checked';
$Return .= $this->CheckBox($FieldName.'[]', $Text, $Instance)."\n";
$i++;
}
}
*/
return $Return . $this->GetCheckBoxGridGroup($LastGroup, $Group, $Rows, $Cols);
} | [
"public",
"function",
"CheckBoxGrid",
"(",
"$",
"FieldName",
",",
"$",
"DataSet",
",",
"$",
"ValueDataSet",
",",
"$",
"Attributes",
")",
"{",
"// Never display individual inline errors for these CheckBoxes",
"$",
"Attributes",
"[",
"'InlineErrors'",
"]",
"=",
"FALSE",
";",
"$",
"Return",
"=",
"''",
";",
"$",
"CheckedValues",
"=",
"$",
"ValueDataSet",
";",
"if",
"(",
"is_object",
"(",
"$",
"ValueDataSet",
")",
")",
"$",
"CheckedValues",
"=",
"ConsolidateArrayValuesByKey",
"(",
"$",
"ValueDataSet",
"->",
"ResultArray",
"(",
")",
",",
"$",
"FieldName",
")",
";",
"$",
"i",
"=",
"1",
";",
"if",
"(",
"is_object",
"(",
"$",
"DataSet",
")",
")",
"{",
"$",
"ValueField",
"=",
"ArrayValueI",
"(",
"'ValueField'",
",",
"$",
"Attributes",
",",
"'value'",
")",
";",
"$",
"TextField",
"=",
"ArrayValueI",
"(",
"'TextField'",
",",
"$",
"Attributes",
",",
"'text'",
")",
";",
"$",
"LastGroup",
"=",
"''",
";",
"$",
"Group",
"=",
"array",
"(",
")",
";",
"$",
"Rows",
"=",
"array",
"(",
")",
";",
"$",
"Cols",
"=",
"array",
"(",
")",
";",
"$",
"CheckBox",
"=",
"''",
";",
"foreach",
"(",
"$",
"DataSet",
"->",
"Result",
"(",
")",
"as",
"$",
"Data",
")",
"{",
"// Define the checkbox",
"$",
"Instance",
"=",
"$",
"Attributes",
";",
"$",
"Instance",
"=",
"RemoveKeyFromArray",
"(",
"$",
"Instance",
",",
"array",
"(",
"'TextField'",
",",
"'ValueField'",
")",
")",
";",
"$",
"Instance",
"[",
"'value'",
"]",
"=",
"$",
"Data",
"->",
"$",
"ValueField",
";",
"$",
"Instance",
"[",
"'id'",
"]",
"=",
"$",
"FieldName",
".",
"$",
"i",
";",
"if",
"(",
"is_array",
"(",
"$",
"CheckedValues",
")",
"&&",
"in_array",
"(",
"$",
"Data",
"->",
"$",
"ValueField",
",",
"$",
"CheckedValues",
")",
")",
"{",
"$",
"Instance",
"[",
"'checked'",
"]",
"=",
"'checked'",
";",
"}",
"$",
"CheckBox",
"=",
"$",
"this",
"->",
"CheckBox",
"(",
"$",
"FieldName",
".",
"'[]'",
",",
"''",
",",
"$",
"Instance",
")",
";",
"// Organize the checkbox into an array for this group",
"$",
"CurrentTextField",
"=",
"$",
"Data",
"->",
"$",
"TextField",
";",
"$",
"aCurrentTextField",
"=",
"explode",
"(",
"'.'",
",",
"$",
"CurrentTextField",
")",
";",
"$",
"aCurrentTextFieldCount",
"=",
"count",
"(",
"$",
"aCurrentTextField",
")",
";",
"$",
"GroupName",
"=",
"array_shift",
"(",
"$",
"aCurrentTextField",
")",
";",
"$",
"ColName",
"=",
"array_pop",
"(",
"$",
"aCurrentTextField",
")",
";",
"if",
"(",
"$",
"aCurrentTextFieldCount",
">=",
"3",
")",
"{",
"$",
"RowName",
"=",
"implode",
"(",
"'.'",
",",
"$",
"aCurrentTextField",
")",
";",
"if",
"(",
"$",
"GroupName",
"!=",
"$",
"LastGroup",
"&&",
"$",
"LastGroup",
"!=",
"''",
")",
"{",
"// Render the last group",
"$",
"Return",
".=",
"$",
"this",
"->",
"GetCheckBoxGridGroup",
"(",
"$",
"LastGroup",
",",
"$",
"Group",
",",
"$",
"Rows",
",",
"$",
"Cols",
")",
";",
"// Clean out the $Group array & Rowcount",
"$",
"Group",
"=",
"array",
"(",
")",
";",
"$",
"Rows",
"=",
"array",
"(",
")",
";",
"$",
"Cols",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"ColName",
",",
"$",
"Group",
")",
"===",
"FALSE",
"||",
"is_array",
"(",
"$",
"Group",
"[",
"$",
"ColName",
"]",
")",
"===",
"FALSE",
")",
"{",
"$",
"Group",
"[",
"$",
"ColName",
"]",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"ColName",
",",
"$",
"Cols",
")",
")",
"$",
"Cols",
"[",
"]",
"=",
"$",
"ColName",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"RowName",
",",
"$",
"Rows",
")",
")",
"$",
"Rows",
"[",
"]",
"=",
"$",
"RowName",
";",
"$",
"Group",
"[",
"$",
"ColName",
"]",
"[",
"$",
"RowName",
"]",
"=",
"$",
"CheckBox",
";",
"$",
"LastGroup",
"=",
"$",
"GroupName",
";",
"}",
"++",
"$",
"i",
";",
"}",
"}",
"/*elseif (is_array($DataSet)) {\n foreach ($DataSet as $Text => $ID) {\n $Instance = $Attributes;\n $Instance = RemoveKeyFromArray($Instance, array('TextField', 'ValueField'));\n $Instance['id'] = $FieldName.$i;\n if (is_numeric($Text))\n $Text = $ID;\n\n $Instance['value'] = $ID;\n if (in_array($ID, $CheckedValues))\n $Instance['checked'] = 'checked';\n\n $Return .= $this->CheckBox($FieldName.'[]', $Text, $Instance).\"\\n\";\n $i++;\n }\n }\n */",
"return",
"$",
"Return",
".",
"$",
"this",
"->",
"GetCheckBoxGridGroup",
"(",
"$",
"LastGroup",
",",
"$",
"Group",
",",
"$",
"Rows",
",",
"$",
"Cols",
")",
";",
"}"
] | Returns the xhtml for a list of checkboxes; sorted into groups related to
the TextField value of the dataset.
@param string $FieldName The name of the field that is being displayed/posted with this input. It
should related directly to a field name in a user junction table.
ie. LUM_UserRole.RoleID
@param mixed $DataSet The data to fill the options in the select list. Either an associative
array or a database dataset. ie. RoleID, Name from LUM_Role.
@param mixed $ValueDataSet The data that should be checked in $DataSet. Either an associative array
or a database dataset. ie. RoleID from LUM_UserRole for a single user.
@param array $Attributes An associative array of attributes for the select. Here is a list of
"special" attributes and their default values:
Attribute Options Default
------------------------------------------------------------------------
ValueField The name of the field in 'value'
$DataSet that contains the
option values.
TextField The name of the field in 'text'
$DataSet that contains the
option text.
@return string | [
"Returns",
"the",
"xhtml",
"for",
"a",
"list",
"of",
"checkboxes",
";",
"sorted",
"into",
"groups",
"related",
"to",
"the",
"TextField",
"value",
"of",
"the",
"dataset",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L489-L575 |
6,351 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.Close | public function Close($ButtonCode = '', $Xhtml = '', $Attributes = FALSE) {
$Return = "</div>\n</form>";
if ($Xhtml != '') $Return = $Xhtml . $Return;
if ($ButtonCode != '') $Return = '<div class="Buttons">'.$this->Button($ButtonCode, $Attributes).'</div>'.$Return;
return $Return;
} | php | public function Close($ButtonCode = '', $Xhtml = '', $Attributes = FALSE) {
$Return = "</div>\n</form>";
if ($Xhtml != '') $Return = $Xhtml . $Return;
if ($ButtonCode != '') $Return = '<div class="Buttons">'.$this->Button($ButtonCode, $Attributes).'</div>'.$Return;
return $Return;
} | [
"public",
"function",
"Close",
"(",
"$",
"ButtonCode",
"=",
"''",
",",
"$",
"Xhtml",
"=",
"''",
",",
"$",
"Attributes",
"=",
"FALSE",
")",
"{",
"$",
"Return",
"=",
"\"</div>\\n</form>\"",
";",
"if",
"(",
"$",
"Xhtml",
"!=",
"''",
")",
"$",
"Return",
"=",
"$",
"Xhtml",
".",
"$",
"Return",
";",
"if",
"(",
"$",
"ButtonCode",
"!=",
"''",
")",
"$",
"Return",
"=",
"'<div class=\"Buttons\">'",
".",
"$",
"this",
"->",
"Button",
"(",
"$",
"ButtonCode",
",",
"$",
"Attributes",
")",
".",
"'</div>'",
".",
"$",
"Return",
";",
"return",
"$",
"Return",
";",
"}"
] | Returns the closing of the form tag with an optional submit button.
@param string $ButtonCode
@param string $Xhtml
@return string | [
"Returns",
"the",
"closing",
"of",
"the",
"form",
"tag",
"with",
"an",
"optional",
"submit",
"button",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L661-L668 |
6,352 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.CurrentImage | public function CurrentImage($FieldName, $Attributes = array()) {
$Result = $this->Hidden($FieldName);
$Value = $this->GetValue($FieldName);
if ($Value) {
TouchValue('class', $Attributes, 'CurrentImage');
$Result .= Img(Gdn_Upload::Url($Value), $Attributes);
}
return $Result;
} | php | public function CurrentImage($FieldName, $Attributes = array()) {
$Result = $this->Hidden($FieldName);
$Value = $this->GetValue($FieldName);
if ($Value) {
TouchValue('class', $Attributes, 'CurrentImage');
$Result .= Img(Gdn_Upload::Url($Value), $Attributes);
}
return $Result;
} | [
"public",
"function",
"CurrentImage",
"(",
"$",
"FieldName",
",",
"$",
"Attributes",
"=",
"array",
"(",
")",
")",
"{",
"$",
"Result",
"=",
"$",
"this",
"->",
"Hidden",
"(",
"$",
"FieldName",
")",
";",
"$",
"Value",
"=",
"$",
"this",
"->",
"GetValue",
"(",
"$",
"FieldName",
")",
";",
"if",
"(",
"$",
"Value",
")",
"{",
"TouchValue",
"(",
"'class'",
",",
"$",
"Attributes",
",",
"'CurrentImage'",
")",
";",
"$",
"Result",
".=",
"Img",
"(",
"Gdn_Upload",
"::",
"Url",
"(",
"$",
"Value",
")",
",",
"$",
"Attributes",
")",
";",
"}",
"return",
"$",
"Result",
";",
"}"
] | Returns the current image in a field.
This is meant to be used with image uploads so that users can see the current value.
@param type $FieldName
@param type $Attributes
@since 2.1 | [
"Returns",
"the",
"current",
"image",
"in",
"a",
"field",
".",
"This",
"is",
"meant",
"to",
"be",
"used",
"with",
"image",
"uploads",
"so",
"that",
"users",
"can",
"see",
"the",
"current",
"value",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L678-L688 |
6,353 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.DropDownGroup | public function DropDownGroup($FieldName, $Data, $GroupField, $TextField, $ValueField, $Attributes = array()) {
$Return = '<select'
. $this->_IDAttribute($FieldName, $Attributes)
. $this->_NameAttribute($FieldName, $Attributes)
. $this->_AttributesToString($Attributes)
. ">\n";
// Get the current value.
$CurrentValue = GetValue('Value', $Attributes, FALSE);
if ($CurrentValue === FALSE)
$CurrentValue = $this->GetValue($FieldName, GetValue('Default', $Attributes));
// Add a null option?
$IncludeNull = ArrayValueI('IncludeNull', $Attributes, FALSE);
if ($IncludeNull === TRUE)
$Return .= "<option value=\"\"></option>\n";
elseif ($IncludeNull)
$Return .= "<option value=\"\">$IncludeNull</option>\n";
$LastGroup = NULL;
foreach ($Data as $Row) {
$Group = $Row[$GroupField];
// Check for a group header.
if ($LastGroup !== $Group) {
// Close off the last opt group.
if ($LastGroup !== NULL) {
$Return .= '</optgroup>';
}
$Return .= '<optgroup label="'.htmlspecialchars($Group)."\">\n";
$LastGroup = $Group;
}
$Value = $Row[$ValueField];
if ($CurrentValue == $Value) {
$Selected = ' selected="selected"';
} else
$Selected = '';
$Return .= '<option value="'.htmlspecialchars($Value).'"'.$Selected.'>'.htmlspecialchars($Row[$TextField])."</option>\n";
}
if ($LastGroup)
$Return .= '</optgroup>';
$Return .= '</select>';
return $Return;
} | php | public function DropDownGroup($FieldName, $Data, $GroupField, $TextField, $ValueField, $Attributes = array()) {
$Return = '<select'
. $this->_IDAttribute($FieldName, $Attributes)
. $this->_NameAttribute($FieldName, $Attributes)
. $this->_AttributesToString($Attributes)
. ">\n";
// Get the current value.
$CurrentValue = GetValue('Value', $Attributes, FALSE);
if ($CurrentValue === FALSE)
$CurrentValue = $this->GetValue($FieldName, GetValue('Default', $Attributes));
// Add a null option?
$IncludeNull = ArrayValueI('IncludeNull', $Attributes, FALSE);
if ($IncludeNull === TRUE)
$Return .= "<option value=\"\"></option>\n";
elseif ($IncludeNull)
$Return .= "<option value=\"\">$IncludeNull</option>\n";
$LastGroup = NULL;
foreach ($Data as $Row) {
$Group = $Row[$GroupField];
// Check for a group header.
if ($LastGroup !== $Group) {
// Close off the last opt group.
if ($LastGroup !== NULL) {
$Return .= '</optgroup>';
}
$Return .= '<optgroup label="'.htmlspecialchars($Group)."\">\n";
$LastGroup = $Group;
}
$Value = $Row[$ValueField];
if ($CurrentValue == $Value) {
$Selected = ' selected="selected"';
} else
$Selected = '';
$Return .= '<option value="'.htmlspecialchars($Value).'"'.$Selected.'>'.htmlspecialchars($Row[$TextField])."</option>\n";
}
if ($LastGroup)
$Return .= '</optgroup>';
$Return .= '</select>';
return $Return;
} | [
"public",
"function",
"DropDownGroup",
"(",
"$",
"FieldName",
",",
"$",
"Data",
",",
"$",
"GroupField",
",",
"$",
"TextField",
",",
"$",
"ValueField",
",",
"$",
"Attributes",
"=",
"array",
"(",
")",
")",
"{",
"$",
"Return",
"=",
"'<select'",
".",
"$",
"this",
"->",
"_IDAttribute",
"(",
"$",
"FieldName",
",",
"$",
"Attributes",
")",
".",
"$",
"this",
"->",
"_NameAttribute",
"(",
"$",
"FieldName",
",",
"$",
"Attributes",
")",
".",
"$",
"this",
"->",
"_AttributesToString",
"(",
"$",
"Attributes",
")",
".",
"\">\\n\"",
";",
"// Get the current value.",
"$",
"CurrentValue",
"=",
"GetValue",
"(",
"'Value'",
",",
"$",
"Attributes",
",",
"FALSE",
")",
";",
"if",
"(",
"$",
"CurrentValue",
"===",
"FALSE",
")",
"$",
"CurrentValue",
"=",
"$",
"this",
"->",
"GetValue",
"(",
"$",
"FieldName",
",",
"GetValue",
"(",
"'Default'",
",",
"$",
"Attributes",
")",
")",
";",
"// Add a null option?",
"$",
"IncludeNull",
"=",
"ArrayValueI",
"(",
"'IncludeNull'",
",",
"$",
"Attributes",
",",
"FALSE",
")",
";",
"if",
"(",
"$",
"IncludeNull",
"===",
"TRUE",
")",
"$",
"Return",
".=",
"\"<option value=\\\"\\\"></option>\\n\"",
";",
"elseif",
"(",
"$",
"IncludeNull",
")",
"$",
"Return",
".=",
"\"<option value=\\\"\\\">$IncludeNull</option>\\n\"",
";",
"$",
"LastGroup",
"=",
"NULL",
";",
"foreach",
"(",
"$",
"Data",
"as",
"$",
"Row",
")",
"{",
"$",
"Group",
"=",
"$",
"Row",
"[",
"$",
"GroupField",
"]",
";",
"// Check for a group header.",
"if",
"(",
"$",
"LastGroup",
"!==",
"$",
"Group",
")",
"{",
"// Close off the last opt group.",
"if",
"(",
"$",
"LastGroup",
"!==",
"NULL",
")",
"{",
"$",
"Return",
".=",
"'</optgroup>'",
";",
"}",
"$",
"Return",
".=",
"'<optgroup label=\"'",
".",
"htmlspecialchars",
"(",
"$",
"Group",
")",
".",
"\"\\\">\\n\"",
";",
"$",
"LastGroup",
"=",
"$",
"Group",
";",
"}",
"$",
"Value",
"=",
"$",
"Row",
"[",
"$",
"ValueField",
"]",
";",
"if",
"(",
"$",
"CurrentValue",
"==",
"$",
"Value",
")",
"{",
"$",
"Selected",
"=",
"' selected=\"selected\"'",
";",
"}",
"else",
"$",
"Selected",
"=",
"''",
";",
"$",
"Return",
".=",
"'<option value=\"'",
".",
"htmlspecialchars",
"(",
"$",
"Value",
")",
".",
"'\"'",
".",
"$",
"Selected",
".",
"'>'",
".",
"htmlspecialchars",
"(",
"$",
"Row",
"[",
"$",
"TextField",
"]",
")",
".",
"\"</option>\\n\"",
";",
"}",
"if",
"(",
"$",
"LastGroup",
")",
"$",
"Return",
".=",
"'</optgroup>'",
";",
"$",
"Return",
".=",
"'</select>'",
";",
"return",
"$",
"Return",
";",
"}"
] | Returns the xhtml for a dropdown list with option groups.
@param string $FieldName
@param array $Data
@param string $GroupField
@param string $TextField
@param string $ValueField
@param array $Attributes
@return string | [
"Returns",
"the",
"xhtml",
"for",
"a",
"dropdown",
"list",
"with",
"option",
"groups",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L894-L946 |
6,354 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.Errors | public function Errors() {
$Return = '';
if (is_array($this->_ValidationResults) && count($this->_ValidationResults) > 0) {
$Return = "<div class=\"Messages Errors\">\n<ul>\n";
foreach($this->_ValidationResults as $FieldName => $Problems) {
$Count = count($Problems);
for($i = 0; $i < $Count; ++$i) {
if (substr($Problems[$i], 0, 1) == '@')
$Return .= '<li>'.substr($Problems[$i], 1)."</li>\n";
else
$Return .= '<li>' . sprintf(
T($Problems[$i]),
T($FieldName)) . "</li>\n";
}
}
$Return .= "</ul>\n</div>\n";
}
return $Return;
} | php | public function Errors() {
$Return = '';
if (is_array($this->_ValidationResults) && count($this->_ValidationResults) > 0) {
$Return = "<div class=\"Messages Errors\">\n<ul>\n";
foreach($this->_ValidationResults as $FieldName => $Problems) {
$Count = count($Problems);
for($i = 0; $i < $Count; ++$i) {
if (substr($Problems[$i], 0, 1) == '@')
$Return .= '<li>'.substr($Problems[$i], 1)."</li>\n";
else
$Return .= '<li>' . sprintf(
T($Problems[$i]),
T($FieldName)) . "</li>\n";
}
}
$Return .= "</ul>\n</div>\n";
}
return $Return;
} | [
"public",
"function",
"Errors",
"(",
")",
"{",
"$",
"Return",
"=",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"_ValidationResults",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"_ValidationResults",
")",
">",
"0",
")",
"{",
"$",
"Return",
"=",
"\"<div class=\\\"Messages Errors\\\">\\n<ul>\\n\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"_ValidationResults",
"as",
"$",
"FieldName",
"=>",
"$",
"Problems",
")",
"{",
"$",
"Count",
"=",
"count",
"(",
"$",
"Problems",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"Count",
";",
"++",
"$",
"i",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"Problems",
"[",
"$",
"i",
"]",
",",
"0",
",",
"1",
")",
"==",
"'@'",
")",
"$",
"Return",
".=",
"'<li>'",
".",
"substr",
"(",
"$",
"Problems",
"[",
"$",
"i",
"]",
",",
"1",
")",
".",
"\"</li>\\n\"",
";",
"else",
"$",
"Return",
".=",
"'<li>'",
".",
"sprintf",
"(",
"T",
"(",
"$",
"Problems",
"[",
"$",
"i",
"]",
")",
",",
"T",
"(",
"$",
"FieldName",
")",
")",
".",
"\"</li>\\n\"",
";",
"}",
"}",
"$",
"Return",
".=",
"\"</ul>\\n</div>\\n\"",
";",
"}",
"return",
"$",
"Return",
";",
"}"
] | Returns XHTML for all form-related errors that have occurred.
@return string | [
"Returns",
"XHTML",
"for",
"all",
"form",
"-",
"related",
"errors",
"that",
"have",
"occurred",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L953-L971 |
6,355 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.EscapeString | public function EscapeString($String) {
$Array = FALSE;
if (substr($String, -2) == '[]') {
$String = substr($String, 0, -2);
$Array = TRUE;
}
$Return = urlencode(str_replace(' ', '_', $String));
if ($Array === TRUE) $Return .= '[]';
return str_replace('.', '-dot-', $Return);
} | php | public function EscapeString($String) {
$Array = FALSE;
if (substr($String, -2) == '[]') {
$String = substr($String, 0, -2);
$Array = TRUE;
}
$Return = urlencode(str_replace(' ', '_', $String));
if ($Array === TRUE) $Return .= '[]';
return str_replace('.', '-dot-', $Return);
} | [
"public",
"function",
"EscapeString",
"(",
"$",
"String",
")",
"{",
"$",
"Array",
"=",
"FALSE",
";",
"if",
"(",
"substr",
"(",
"$",
"String",
",",
"-",
"2",
")",
"==",
"'[]'",
")",
"{",
"$",
"String",
"=",
"substr",
"(",
"$",
"String",
",",
"0",
",",
"-",
"2",
")",
";",
"$",
"Array",
"=",
"TRUE",
";",
"}",
"$",
"Return",
"=",
"urlencode",
"(",
"str_replace",
"(",
"' '",
",",
"'_'",
",",
"$",
"String",
")",
")",
";",
"if",
"(",
"$",
"Array",
"===",
"TRUE",
")",
"$",
"Return",
".=",
"'[]'",
";",
"return",
"str_replace",
"(",
"'.'",
",",
"'-dot-'",
",",
"$",
"Return",
")",
";",
"}"
] | Encodes the string in a php-form safe-encoded format.
@param string $String The string to encode.
@return string | [
"Encodes",
"the",
"string",
"in",
"a",
"php",
"-",
"form",
"safe",
"-",
"encoded",
"format",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L997-L1007 |
6,356 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.GetCheckBoxGridGroup | public function GetCheckBoxGridGroup($GroupName, $Group, $Rows, $Cols) {
$Return = '';
$Headings = '';
$Cells = '';
$RowCount = count($Rows);
$ColCount = count($Cols);
for($j = 0; $j < $RowCount; ++$j) {
$Alt = 1;
for($i = 0; $i < $ColCount; ++$i) {
$Alt = $Alt == 0 ? 1 : 0;
$ColName = $Cols[$i];
$RowName = $Rows[$j];
if ($j == 0) $Headings .= '<td' . ($Alt == 0 ? ' class="Alt"' : '') .
'>' . T($ColName) . '</td>';
if (array_key_exists($RowName, $Group[$ColName])) {
$Cells .= '<td' . ($Alt == 0 ? ' class="Alt"' : '') .
'>' . $Group[$ColName][$RowName] .
'</td>';
} else {
$Cells .= '<td' . ($Alt == 0 ? ' class="Alt"' : '') .
'> </td>';
}
}
if ($Headings != '') $Return .= "<thead><tr><th>" . T($GroupName) . "</th>" .
$Headings . "</tr></thead>\r\n<tbody>";
$aRowName = explode('.', $RowName);
$RowNameCount = count($aRowName);
if ($RowNameCount > 1) {
$RowName = '';
for($i = 0; $i < $RowNameCount; ++$i) {
if ($i < $RowNameCount - 1) $RowName .= '<span class="Parent">' .
T($aRowName[$i]) . '</span>';
else $RowName .= T($aRowName[$i]);
}
} else {
$RowName = T($RowName);
}
$Return .= '<tr><th>' . $RowName . '</th>' . $Cells . "</tr>\r\n";
$Headings = '';
$Cells = '';
}
return $Return == '' ? '' : '<table class="CheckBoxGrid">'.$Return.'</tbody></table>';
} | php | public function GetCheckBoxGridGroup($GroupName, $Group, $Rows, $Cols) {
$Return = '';
$Headings = '';
$Cells = '';
$RowCount = count($Rows);
$ColCount = count($Cols);
for($j = 0; $j < $RowCount; ++$j) {
$Alt = 1;
for($i = 0; $i < $ColCount; ++$i) {
$Alt = $Alt == 0 ? 1 : 0;
$ColName = $Cols[$i];
$RowName = $Rows[$j];
if ($j == 0) $Headings .= '<td' . ($Alt == 0 ? ' class="Alt"' : '') .
'>' . T($ColName) . '</td>';
if (array_key_exists($RowName, $Group[$ColName])) {
$Cells .= '<td' . ($Alt == 0 ? ' class="Alt"' : '') .
'>' . $Group[$ColName][$RowName] .
'</td>';
} else {
$Cells .= '<td' . ($Alt == 0 ? ' class="Alt"' : '') .
'> </td>';
}
}
if ($Headings != '') $Return .= "<thead><tr><th>" . T($GroupName) . "</th>" .
$Headings . "</tr></thead>\r\n<tbody>";
$aRowName = explode('.', $RowName);
$RowNameCount = count($aRowName);
if ($RowNameCount > 1) {
$RowName = '';
for($i = 0; $i < $RowNameCount; ++$i) {
if ($i < $RowNameCount - 1) $RowName .= '<span class="Parent">' .
T($aRowName[$i]) . '</span>';
else $RowName .= T($aRowName[$i]);
}
} else {
$RowName = T($RowName);
}
$Return .= '<tr><th>' . $RowName . '</th>' . $Cells . "</tr>\r\n";
$Headings = '';
$Cells = '';
}
return $Return == '' ? '' : '<table class="CheckBoxGrid">'.$Return.'</tbody></table>';
} | [
"public",
"function",
"GetCheckBoxGridGroup",
"(",
"$",
"GroupName",
",",
"$",
"Group",
",",
"$",
"Rows",
",",
"$",
"Cols",
")",
"{",
"$",
"Return",
"=",
"''",
";",
"$",
"Headings",
"=",
"''",
";",
"$",
"Cells",
"=",
"''",
";",
"$",
"RowCount",
"=",
"count",
"(",
"$",
"Rows",
")",
";",
"$",
"ColCount",
"=",
"count",
"(",
"$",
"Cols",
")",
";",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"$",
"RowCount",
";",
"++",
"$",
"j",
")",
"{",
"$",
"Alt",
"=",
"1",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"ColCount",
";",
"++",
"$",
"i",
")",
"{",
"$",
"Alt",
"=",
"$",
"Alt",
"==",
"0",
"?",
"1",
":",
"0",
";",
"$",
"ColName",
"=",
"$",
"Cols",
"[",
"$",
"i",
"]",
";",
"$",
"RowName",
"=",
"$",
"Rows",
"[",
"$",
"j",
"]",
";",
"if",
"(",
"$",
"j",
"==",
"0",
")",
"$",
"Headings",
".=",
"'<td'",
".",
"(",
"$",
"Alt",
"==",
"0",
"?",
"' class=\"Alt\"'",
":",
"''",
")",
".",
"'>'",
".",
"T",
"(",
"$",
"ColName",
")",
".",
"'</td>'",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"RowName",
",",
"$",
"Group",
"[",
"$",
"ColName",
"]",
")",
")",
"{",
"$",
"Cells",
".=",
"'<td'",
".",
"(",
"$",
"Alt",
"==",
"0",
"?",
"' class=\"Alt\"'",
":",
"''",
")",
".",
"'>'",
".",
"$",
"Group",
"[",
"$",
"ColName",
"]",
"[",
"$",
"RowName",
"]",
".",
"'</td>'",
";",
"}",
"else",
"{",
"$",
"Cells",
".=",
"'<td'",
".",
"(",
"$",
"Alt",
"==",
"0",
"?",
"' class=\"Alt\"'",
":",
"''",
")",
".",
"'> </td>'",
";",
"}",
"}",
"if",
"(",
"$",
"Headings",
"!=",
"''",
")",
"$",
"Return",
".=",
"\"<thead><tr><th>\"",
".",
"T",
"(",
"$",
"GroupName",
")",
".",
"\"</th>\"",
".",
"$",
"Headings",
".",
"\"</tr></thead>\\r\\n<tbody>\"",
";",
"$",
"aRowName",
"=",
"explode",
"(",
"'.'",
",",
"$",
"RowName",
")",
";",
"$",
"RowNameCount",
"=",
"count",
"(",
"$",
"aRowName",
")",
";",
"if",
"(",
"$",
"RowNameCount",
">",
"1",
")",
"{",
"$",
"RowName",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"RowNameCount",
";",
"++",
"$",
"i",
")",
"{",
"if",
"(",
"$",
"i",
"<",
"$",
"RowNameCount",
"-",
"1",
")",
"$",
"RowName",
".=",
"'<span class=\"Parent\">'",
".",
"T",
"(",
"$",
"aRowName",
"[",
"$",
"i",
"]",
")",
".",
"'</span>'",
";",
"else",
"$",
"RowName",
".=",
"T",
"(",
"$",
"aRowName",
"[",
"$",
"i",
"]",
")",
";",
"}",
"}",
"else",
"{",
"$",
"RowName",
"=",
"T",
"(",
"$",
"RowName",
")",
";",
"}",
"$",
"Return",
".=",
"'<tr><th>'",
".",
"$",
"RowName",
".",
"'</th>'",
".",
"$",
"Cells",
".",
"\"</tr>\\r\\n\"",
";",
"$",
"Headings",
"=",
"''",
";",
"$",
"Cells",
"=",
"''",
";",
"}",
"return",
"$",
"Return",
"==",
"''",
"?",
"''",
":",
"'<table class=\"CheckBoxGrid\">'",
".",
"$",
"Return",
".",
"'</tbody></table>'",
";",
"}"
] | Returns a checkbox table.
@param string $GroupName The name of the checkbox table (the text that appears in the top-left
cell of the table). This value will be passed through the T()
function before render.
@param array $Group An array of $PermissionName => $CheckBoxXhtml to be rendered within the
grid. This represents the final (third) part of the permission name
string, as in the "Edit" part of "Garden.Roles.Edit".
ie. 'Edit' => '<input type="checkbox" id="PermissionID"
name="Role/PermissionID[]" value="20" />';
@param array $Rows An array of rows to appear in the grid. This represents the middle part
of the permission name, as in the "Roles" part of "Garden.Roles.Edit".
@param array $Cols An array of columns to appear in the grid for each row. This (again)
represents the final part of the permission name, as in the "Edit" part
of "Garden.Roles.Edit".
ie. Row1 = array('Add', 'Edit', 'Delete'); | [
"Returns",
"a",
"checkbox",
"table",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L1030-L1075 |
6,357 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.GetHidden | public function GetHidden() {
$Return = '';
if (is_array($this->HiddenInputs)) {
foreach($this->HiddenInputs as $Name => $Value) {
$Return .= $this->Hidden($Name, array('value' => $Value));
}
// Clean out the array
// mosullivan - removed cleanout so that entry forms can all have the same hidden inputs added once on the entry/index view.
// TODO - WATCH FOR BUGS BECAUSE OF THIS CHANGE.
// $this->HiddenInputs = array();
}
return $Return;
} | php | public function GetHidden() {
$Return = '';
if (is_array($this->HiddenInputs)) {
foreach($this->HiddenInputs as $Name => $Value) {
$Return .= $this->Hidden($Name, array('value' => $Value));
}
// Clean out the array
// mosullivan - removed cleanout so that entry forms can all have the same hidden inputs added once on the entry/index view.
// TODO - WATCH FOR BUGS BECAUSE OF THIS CHANGE.
// $this->HiddenInputs = array();
}
return $Return;
} | [
"public",
"function",
"GetHidden",
"(",
")",
"{",
"$",
"Return",
"=",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"HiddenInputs",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"HiddenInputs",
"as",
"$",
"Name",
"=>",
"$",
"Value",
")",
"{",
"$",
"Return",
".=",
"$",
"this",
"->",
"Hidden",
"(",
"$",
"Name",
",",
"array",
"(",
"'value'",
"=>",
"$",
"Value",
")",
")",
";",
"}",
"// Clean out the array",
"// mosullivan - removed cleanout so that entry forms can all have the same hidden inputs added once on the entry/index view.",
"// TODO - WATCH FOR BUGS BECAUSE OF THIS CHANGE.",
"// $this->HiddenInputs = array();",
"}",
"return",
"$",
"Return",
";",
"}"
] | Returns XHTML for all hidden fields.
@todo reviews damien's summary of this Form::GetHidden()
@return string | [
"Returns",
"XHTML",
"for",
"all",
"hidden",
"fields",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L1083-L1095 |
6,358 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.Hidden | public function Hidden($FieldName, $Attributes = FALSE) {
$Return = '<input type="hidden"';
$Return .= $this->_IDAttribute($FieldName, $Attributes);
$Return .= $this->_NameAttribute($FieldName, $Attributes);
$Return .= $this->_ValueAttribute($FieldName, $Attributes);
$Return .= $this->_AttributesToString($Attributes);
$Return .= ' />';
return $Return;
} | php | public function Hidden($FieldName, $Attributes = FALSE) {
$Return = '<input type="hidden"';
$Return .= $this->_IDAttribute($FieldName, $Attributes);
$Return .= $this->_NameAttribute($FieldName, $Attributes);
$Return .= $this->_ValueAttribute($FieldName, $Attributes);
$Return .= $this->_AttributesToString($Attributes);
$Return .= ' />';
return $Return;
} | [
"public",
"function",
"Hidden",
"(",
"$",
"FieldName",
",",
"$",
"Attributes",
"=",
"FALSE",
")",
"{",
"$",
"Return",
"=",
"'<input type=\"hidden\"'",
";",
"$",
"Return",
".=",
"$",
"this",
"->",
"_IDAttribute",
"(",
"$",
"FieldName",
",",
"$",
"Attributes",
")",
";",
"$",
"Return",
".=",
"$",
"this",
"->",
"_NameAttribute",
"(",
"$",
"FieldName",
",",
"$",
"Attributes",
")",
";",
"$",
"Return",
".=",
"$",
"this",
"->",
"_ValueAttribute",
"(",
"$",
"FieldName",
",",
"$",
"Attributes",
")",
";",
"$",
"Return",
".=",
"$",
"this",
"->",
"_AttributesToString",
"(",
"$",
"Attributes",
")",
";",
"$",
"Return",
".=",
"' />'",
";",
"return",
"$",
"Return",
";",
"}"
] | Returns the xhtml for a hidden input.
@param string $FieldName The name of the field that is being hidden/posted with this input. It
should related directly to a field name in $this->_DataArray.
@param array $Attributes An associative array of attributes for the input. ie. maxlength, onclick,
class, etc
@return string | [
"Returns",
"the",
"xhtml",
"for",
"a",
"hidden",
"input",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L1107-L1115 |
6,359 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.ImageUpload | public function ImageUpload($FieldName, $Attributes = array()) {
$Result = '<div class="FileUpload ImageUpload">'.
$this->CurrentImage($FieldName, $Attributes).
$this->Input($FieldName.'_New', 'file').
'</div>';
return $Result;
} | php | public function ImageUpload($FieldName, $Attributes = array()) {
$Result = '<div class="FileUpload ImageUpload">'.
$this->CurrentImage($FieldName, $Attributes).
$this->Input($FieldName.'_New', 'file').
'</div>';
return $Result;
} | [
"public",
"function",
"ImageUpload",
"(",
"$",
"FieldName",
",",
"$",
"Attributes",
"=",
"array",
"(",
")",
")",
"{",
"$",
"Result",
"=",
"'<div class=\"FileUpload ImageUpload\">'",
".",
"$",
"this",
"->",
"CurrentImage",
"(",
"$",
"FieldName",
",",
"$",
"Attributes",
")",
".",
"$",
"this",
"->",
"Input",
"(",
"$",
"FieldName",
".",
"'_New'",
",",
"'file'",
")",
".",
"'</div>'",
";",
"return",
"$",
"Result",
";",
"}"
] | Return a control for uploading images.
@param string $FieldName
@param array $Attributes
@return string
@since 2.1 | [
"Return",
"a",
"control",
"for",
"uploading",
"images",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L1125-L1132 |
6,360 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.InlineError | public function InlineError($FieldName) {
$AppendError = '<p class="'.$this->ErrorClass.'">';
foreach ($this->_ValidationResults[$FieldName] as $ValidationError) {
$AppendError .= sprintf(T($ValidationError),T($FieldName)).' ';
}
$AppendError .= '</p>';
return $AppendError;
} | php | public function InlineError($FieldName) {
$AppendError = '<p class="'.$this->ErrorClass.'">';
foreach ($this->_ValidationResults[$FieldName] as $ValidationError) {
$AppendError .= sprintf(T($ValidationError),T($FieldName)).' ';
}
$AppendError .= '</p>';
return $AppendError;
} | [
"public",
"function",
"InlineError",
"(",
"$",
"FieldName",
")",
"{",
"$",
"AppendError",
"=",
"'<p class=\"'",
".",
"$",
"this",
"->",
"ErrorClass",
".",
"'\">'",
";",
"foreach",
"(",
"$",
"this",
"->",
"_ValidationResults",
"[",
"$",
"FieldName",
"]",
"as",
"$",
"ValidationError",
")",
"{",
"$",
"AppendError",
".=",
"sprintf",
"(",
"T",
"(",
"$",
"ValidationError",
")",
",",
"T",
"(",
"$",
"FieldName",
")",
")",
".",
"' '",
";",
"}",
"$",
"AppendError",
".=",
"'</p>'",
";",
"return",
"$",
"AppendError",
";",
"}"
] | Returns XHTML of inline error for specified field.
@since 2.0.18
@access public
@param string $FieldName The name of the field that is being displayed/posted with this input. It
should related directly to a field name in $this->_DataArray.
@return string | [
"Returns",
"XHTML",
"of",
"inline",
"error",
"for",
"specified",
"field",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L1144-L1152 |
6,361 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.Input | public function Input($FieldName, $Type = 'text', $Attributes = FALSE) {
if ($Type == 'text' || $Type == 'password') {
$CssClass = ArrayValueI('class', $Attributes);
if ($CssClass == FALSE) $Attributes['class'] = 'InputBox';
}
// Show inline errors?
$ShowErrors = $this->_InlineErrors && array_key_exists($FieldName, $this->_ValidationResults);
// Add error class to input element
if ($ShowErrors)
$this->AddErrorClass($Attributes);
$Return = '';
$Wrap = GetValue('Wrap', $Attributes, FALSE, TRUE);
$Strength = GetValue('Strength', $Attributes, FALSE, TRUE);
if ($Wrap) {
$Return .= '<div class="TextBoxWrapper">';
}
if (strtolower($Type) == 'checkbox') {
if (isset($Attributes['nohidden'])) {
unset($Attributes['nohidden']);
} else {
$Return .= '<input type="hidden" name="Checkboxes[]" value="'.
(substr($FieldName, -2) === '[]' ? substr($FieldName, 0, -2) : $FieldName).
'" />';
}
}
$Return .= '<input type="' . $Type . '"';
$Return .= $this->_IDAttribute($FieldName, $Attributes);
if ($Type == 'file') $Return .= Attribute('name',
ArrayValueI('Name', $Attributes, $FieldName));
else $Return .= $this->_NameAttribute($FieldName, $Attributes);
if ($Strength)
$Return .= ' data-strength="true"';
$Return .= $this->_ValueAttribute($FieldName, $Attributes);
$Return .= $this->_AttributesToString($Attributes);
$Return .= ' />';
// Append validation error message
if ($ShowErrors && ArrayValueI('InlineErrors', $Attributes, TRUE))
$Return .= $this->InlineError($FieldName);
if ($Type == 'password' && $Strength) {
$Return .= <<<PASSWORDMETER
<div class="PasswordStrength">
<div class="Background"></div>
<div class="Strength"></div>
<div class="Separator" style="left: 20%;"></div>
<div class="Separator" style="left: 40%;"></div>
<div class="Separator" style="left: 60%;"></div>
<div class="Separator" style="left: 80%;"></div>
<div class="StrengthText"> </div>
</div>
PASSWORDMETER;
}
if ($Wrap)
$Return .= '</div>';
return $Return;
} | php | public function Input($FieldName, $Type = 'text', $Attributes = FALSE) {
if ($Type == 'text' || $Type == 'password') {
$CssClass = ArrayValueI('class', $Attributes);
if ($CssClass == FALSE) $Attributes['class'] = 'InputBox';
}
// Show inline errors?
$ShowErrors = $this->_InlineErrors && array_key_exists($FieldName, $this->_ValidationResults);
// Add error class to input element
if ($ShowErrors)
$this->AddErrorClass($Attributes);
$Return = '';
$Wrap = GetValue('Wrap', $Attributes, FALSE, TRUE);
$Strength = GetValue('Strength', $Attributes, FALSE, TRUE);
if ($Wrap) {
$Return .= '<div class="TextBoxWrapper">';
}
if (strtolower($Type) == 'checkbox') {
if (isset($Attributes['nohidden'])) {
unset($Attributes['nohidden']);
} else {
$Return .= '<input type="hidden" name="Checkboxes[]" value="'.
(substr($FieldName, -2) === '[]' ? substr($FieldName, 0, -2) : $FieldName).
'" />';
}
}
$Return .= '<input type="' . $Type . '"';
$Return .= $this->_IDAttribute($FieldName, $Attributes);
if ($Type == 'file') $Return .= Attribute('name',
ArrayValueI('Name', $Attributes, $FieldName));
else $Return .= $this->_NameAttribute($FieldName, $Attributes);
if ($Strength)
$Return .= ' data-strength="true"';
$Return .= $this->_ValueAttribute($FieldName, $Attributes);
$Return .= $this->_AttributesToString($Attributes);
$Return .= ' />';
// Append validation error message
if ($ShowErrors && ArrayValueI('InlineErrors', $Attributes, TRUE))
$Return .= $this->InlineError($FieldName);
if ($Type == 'password' && $Strength) {
$Return .= <<<PASSWORDMETER
<div class="PasswordStrength">
<div class="Background"></div>
<div class="Strength"></div>
<div class="Separator" style="left: 20%;"></div>
<div class="Separator" style="left: 40%;"></div>
<div class="Separator" style="left: 60%;"></div>
<div class="Separator" style="left: 80%;"></div>
<div class="StrengthText"> </div>
</div>
PASSWORDMETER;
}
if ($Wrap)
$Return .= '</div>';
return $Return;
} | [
"public",
"function",
"Input",
"(",
"$",
"FieldName",
",",
"$",
"Type",
"=",
"'text'",
",",
"$",
"Attributes",
"=",
"FALSE",
")",
"{",
"if",
"(",
"$",
"Type",
"==",
"'text'",
"||",
"$",
"Type",
"==",
"'password'",
")",
"{",
"$",
"CssClass",
"=",
"ArrayValueI",
"(",
"'class'",
",",
"$",
"Attributes",
")",
";",
"if",
"(",
"$",
"CssClass",
"==",
"FALSE",
")",
"$",
"Attributes",
"[",
"'class'",
"]",
"=",
"'InputBox'",
";",
"}",
"// Show inline errors?",
"$",
"ShowErrors",
"=",
"$",
"this",
"->",
"_InlineErrors",
"&&",
"array_key_exists",
"(",
"$",
"FieldName",
",",
"$",
"this",
"->",
"_ValidationResults",
")",
";",
"// Add error class to input element",
"if",
"(",
"$",
"ShowErrors",
")",
"$",
"this",
"->",
"AddErrorClass",
"(",
"$",
"Attributes",
")",
";",
"$",
"Return",
"=",
"''",
";",
"$",
"Wrap",
"=",
"GetValue",
"(",
"'Wrap'",
",",
"$",
"Attributes",
",",
"FALSE",
",",
"TRUE",
")",
";",
"$",
"Strength",
"=",
"GetValue",
"(",
"'Strength'",
",",
"$",
"Attributes",
",",
"FALSE",
",",
"TRUE",
")",
";",
"if",
"(",
"$",
"Wrap",
")",
"{",
"$",
"Return",
".=",
"'<div class=\"TextBoxWrapper\">'",
";",
"}",
"if",
"(",
"strtolower",
"(",
"$",
"Type",
")",
"==",
"'checkbox'",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"Attributes",
"[",
"'nohidden'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"Attributes",
"[",
"'nohidden'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"Return",
".=",
"'<input type=\"hidden\" name=\"Checkboxes[]\" value=\"'",
".",
"(",
"substr",
"(",
"$",
"FieldName",
",",
"-",
"2",
")",
"===",
"'[]'",
"?",
"substr",
"(",
"$",
"FieldName",
",",
"0",
",",
"-",
"2",
")",
":",
"$",
"FieldName",
")",
".",
"'\" />'",
";",
"}",
"}",
"$",
"Return",
".=",
"'<input type=\"'",
".",
"$",
"Type",
".",
"'\"'",
";",
"$",
"Return",
".=",
"$",
"this",
"->",
"_IDAttribute",
"(",
"$",
"FieldName",
",",
"$",
"Attributes",
")",
";",
"if",
"(",
"$",
"Type",
"==",
"'file'",
")",
"$",
"Return",
".=",
"Attribute",
"(",
"'name'",
",",
"ArrayValueI",
"(",
"'Name'",
",",
"$",
"Attributes",
",",
"$",
"FieldName",
")",
")",
";",
"else",
"$",
"Return",
".=",
"$",
"this",
"->",
"_NameAttribute",
"(",
"$",
"FieldName",
",",
"$",
"Attributes",
")",
";",
"if",
"(",
"$",
"Strength",
")",
"$",
"Return",
".=",
"' data-strength=\"true\"'",
";",
"$",
"Return",
".=",
"$",
"this",
"->",
"_ValueAttribute",
"(",
"$",
"FieldName",
",",
"$",
"Attributes",
")",
";",
"$",
"Return",
".=",
"$",
"this",
"->",
"_AttributesToString",
"(",
"$",
"Attributes",
")",
";",
"$",
"Return",
".=",
"' />'",
";",
"// Append validation error message",
"if",
"(",
"$",
"ShowErrors",
"&&",
"ArrayValueI",
"(",
"'InlineErrors'",
",",
"$",
"Attributes",
",",
"TRUE",
")",
")",
"$",
"Return",
".=",
"$",
"this",
"->",
"InlineError",
"(",
"$",
"FieldName",
")",
";",
"if",
"(",
"$",
"Type",
"==",
"'password'",
"&&",
"$",
"Strength",
")",
"{",
"$",
"Return",
".=",
" <<<PASSWORDMETER\n<div class=\"PasswordStrength\">\n <div class=\"Background\"></div>\n <div class=\"Strength\"></div>\n <div class=\"Separator\" style=\"left: 20%;\"></div>\n <div class=\"Separator\" style=\"left: 40%;\"></div>\n <div class=\"Separator\" style=\"left: 60%;\"></div>\n <div class=\"Separator\" style=\"left: 80%;\"></div>\n <div class=\"StrengthText\"> </div>\n</div>\nPASSWORDMETER",
";",
"}",
"if",
"(",
"$",
"Wrap",
")",
"$",
"Return",
".=",
"'</div>'",
";",
"return",
"$",
"Return",
";",
"}"
] | Returns the xhtml for a standard input tag.
@param string $FieldName The name of the field that is being displayed/posted with this input. It
should related directly to a field name in $this->_DataArray.
@param string $Type The type attribute for the input.
@param array $Attributes An associative array of attributes for the input. (e.g. maxlength, onclick, class)
Setting 'InlineErrors' to FALSE prevents error message even if $this->InlineErrors is enabled.
@return string | [
"Returns",
"the",
"xhtml",
"for",
"a",
"standard",
"input",
"tag",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L1164-L1230 |
6,362 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.Label | public function Label($TranslationCode, $FieldName = '', $Attributes = FALSE) {
// Assume we always want a 'for' attribute because it's Good & Proper.
// Precedence: 'for' attribute, 'id' attribute, $FieldName, $TranslationCode
$DefaultFor = ($FieldName == '') ? $TranslationCode : $FieldName;
$For = ArrayValueI('for', $Attributes, ArrayValueI('id', $Attributes, $this->EscapeID($DefaultFor, FALSE)));
return '<label for="' . $For . '"' . $this->_AttributesToString($Attributes).'>' . T($TranslationCode) . "</label>\n";
} | php | public function Label($TranslationCode, $FieldName = '', $Attributes = FALSE) {
// Assume we always want a 'for' attribute because it's Good & Proper.
// Precedence: 'for' attribute, 'id' attribute, $FieldName, $TranslationCode
$DefaultFor = ($FieldName == '') ? $TranslationCode : $FieldName;
$For = ArrayValueI('for', $Attributes, ArrayValueI('id', $Attributes, $this->EscapeID($DefaultFor, FALSE)));
return '<label for="' . $For . '"' . $this->_AttributesToString($Attributes).'>' . T($TranslationCode) . "</label>\n";
} | [
"public",
"function",
"Label",
"(",
"$",
"TranslationCode",
",",
"$",
"FieldName",
"=",
"''",
",",
"$",
"Attributes",
"=",
"FALSE",
")",
"{",
"// Assume we always want a 'for' attribute because it's Good & Proper.",
"// Precedence: 'for' attribute, 'id' attribute, $FieldName, $TranslationCode",
"$",
"DefaultFor",
"=",
"(",
"$",
"FieldName",
"==",
"''",
")",
"?",
"$",
"TranslationCode",
":",
"$",
"FieldName",
";",
"$",
"For",
"=",
"ArrayValueI",
"(",
"'for'",
",",
"$",
"Attributes",
",",
"ArrayValueI",
"(",
"'id'",
",",
"$",
"Attributes",
",",
"$",
"this",
"->",
"EscapeID",
"(",
"$",
"DefaultFor",
",",
"FALSE",
")",
")",
")",
";",
"return",
"'<label for=\"'",
".",
"$",
"For",
".",
"'\"'",
".",
"$",
"this",
"->",
"_AttributesToString",
"(",
"$",
"Attributes",
")",
".",
"'>'",
".",
"T",
"(",
"$",
"TranslationCode",
")",
".",
"\"</label>\\n\"",
";",
"}"
] | Returns XHTML for a label element.
@param string $TranslationCode Code to be translated and presented within the label tag.
@param string $FieldName Name of the field that the label is for.
@param array $Attributes Associative array of attributes for the input that the label is for.
This is only available in case the related input has a custom id specified in the attributes array.
@return string | [
"Returns",
"XHTML",
"for",
"a",
"label",
"element",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L1242-L1249 |
6,363 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.LabelCode | public static function LabelCode($Item) {
if (is_array($Item)) {
if (isset($Item['LabelCode']))
return $Item['LabelCode'];
$LabelCode = $Item['Name'];
} else {
$LabelCode = $Item;
}
if (strpos($LabelCode, '.') !== FALSE)
$LabelCode = trim(strrchr($LabelCode, '.'), '.');
// Split camel case labels into seperate words.
$LabelCode = preg_replace('`(?<![A-Z0-9])([A-Z0-9])`', ' $1', $LabelCode);
$LabelCode = preg_replace('`([A-Z0-9])(?=[a-z])`', ' $1', $LabelCode);
$LabelCode = trim($LabelCode);
return $LabelCode;
} | php | public static function LabelCode($Item) {
if (is_array($Item)) {
if (isset($Item['LabelCode']))
return $Item['LabelCode'];
$LabelCode = $Item['Name'];
} else {
$LabelCode = $Item;
}
if (strpos($LabelCode, '.') !== FALSE)
$LabelCode = trim(strrchr($LabelCode, '.'), '.');
// Split camel case labels into seperate words.
$LabelCode = preg_replace('`(?<![A-Z0-9])([A-Z0-9])`', ' $1', $LabelCode);
$LabelCode = preg_replace('`([A-Z0-9])(?=[a-z])`', ' $1', $LabelCode);
$LabelCode = trim($LabelCode);
return $LabelCode;
} | [
"public",
"static",
"function",
"LabelCode",
"(",
"$",
"Item",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"Item",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"Item",
"[",
"'LabelCode'",
"]",
")",
")",
"return",
"$",
"Item",
"[",
"'LabelCode'",
"]",
";",
"$",
"LabelCode",
"=",
"$",
"Item",
"[",
"'Name'",
"]",
";",
"}",
"else",
"{",
"$",
"LabelCode",
"=",
"$",
"Item",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"LabelCode",
",",
"'.'",
")",
"!==",
"FALSE",
")",
"$",
"LabelCode",
"=",
"trim",
"(",
"strrchr",
"(",
"$",
"LabelCode",
",",
"'.'",
")",
",",
"'.'",
")",
";",
"// Split camel case labels into seperate words.",
"$",
"LabelCode",
"=",
"preg_replace",
"(",
"'`(?<![A-Z0-9])([A-Z0-9])`'",
",",
"' $1'",
",",
"$",
"LabelCode",
")",
";",
"$",
"LabelCode",
"=",
"preg_replace",
"(",
"'`([A-Z0-9])(?=[a-z])`'",
",",
"' $1'",
",",
"$",
"LabelCode",
")",
";",
"$",
"LabelCode",
"=",
"trim",
"(",
"$",
"LabelCode",
")",
";",
"return",
"$",
"LabelCode",
";",
"}"
] | Generate a friendly looking label translation code from a camel case variable name
@param string|array $Item The item to generate the label from.
- string: Generate the label directly from the item.
- array: Generate the label from the item as if it is a schema row passed to Gdn_Form::Simple().
@return string | [
"Generate",
"a",
"friendly",
"looking",
"label",
"translation",
"code",
"from",
"a",
"camel",
"case",
"variable",
"name"
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L1258-L1278 |
6,364 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.Radio | public function Radio($FieldName, $Label = '', $Attributes = FALSE) {
$Value = ArrayValueI('Value', $Attributes, 'TRUE');
$Attributes['value'] = $Value;
$FormValue = $this->GetValue($FieldName, ArrayValueI('Default', $Attributes));
// Check for 'checked'
if ($FormValue == $Value)
$Attributes['checked'] = 'checked';
// Never display individual inline errors for this Input
$Attributes['InlineErrors'] = FALSE;
// Get standard radio Input
$Input = $this->Input($FieldName, 'radio', $Attributes);
// Wrap with label
if ($Label != '') {
$Input = '<label for="' . ArrayValueI('id', $Attributes, $this->EscapeID($FieldName, FALSE)) .
'" class="RadioLabel">' . $Input . ' ' . T($Label) . '</label>';
}
return $Input;
} | php | public function Radio($FieldName, $Label = '', $Attributes = FALSE) {
$Value = ArrayValueI('Value', $Attributes, 'TRUE');
$Attributes['value'] = $Value;
$FormValue = $this->GetValue($FieldName, ArrayValueI('Default', $Attributes));
// Check for 'checked'
if ($FormValue == $Value)
$Attributes['checked'] = 'checked';
// Never display individual inline errors for this Input
$Attributes['InlineErrors'] = FALSE;
// Get standard radio Input
$Input = $this->Input($FieldName, 'radio', $Attributes);
// Wrap with label
if ($Label != '') {
$Input = '<label for="' . ArrayValueI('id', $Attributes, $this->EscapeID($FieldName, FALSE)) .
'" class="RadioLabel">' . $Input . ' ' . T($Label) . '</label>';
}
return $Input;
} | [
"public",
"function",
"Radio",
"(",
"$",
"FieldName",
",",
"$",
"Label",
"=",
"''",
",",
"$",
"Attributes",
"=",
"FALSE",
")",
"{",
"$",
"Value",
"=",
"ArrayValueI",
"(",
"'Value'",
",",
"$",
"Attributes",
",",
"'TRUE'",
")",
";",
"$",
"Attributes",
"[",
"'value'",
"]",
"=",
"$",
"Value",
";",
"$",
"FormValue",
"=",
"$",
"this",
"->",
"GetValue",
"(",
"$",
"FieldName",
",",
"ArrayValueI",
"(",
"'Default'",
",",
"$",
"Attributes",
")",
")",
";",
"// Check for 'checked'",
"if",
"(",
"$",
"FormValue",
"==",
"$",
"Value",
")",
"$",
"Attributes",
"[",
"'checked'",
"]",
"=",
"'checked'",
";",
"// Never display individual inline errors for this Input",
"$",
"Attributes",
"[",
"'InlineErrors'",
"]",
"=",
"FALSE",
";",
"// Get standard radio Input",
"$",
"Input",
"=",
"$",
"this",
"->",
"Input",
"(",
"$",
"FieldName",
",",
"'radio'",
",",
"$",
"Attributes",
")",
";",
"// Wrap with label",
"if",
"(",
"$",
"Label",
"!=",
"''",
")",
"{",
"$",
"Input",
"=",
"'<label for=\"'",
".",
"ArrayValueI",
"(",
"'id'",
",",
"$",
"Attributes",
",",
"$",
"this",
"->",
"EscapeID",
"(",
"$",
"FieldName",
",",
"FALSE",
")",
")",
".",
"'\" class=\"RadioLabel\">'",
".",
"$",
"Input",
".",
"' '",
".",
"T",
"(",
"$",
"Label",
")",
".",
"'</label>'",
";",
"}",
"return",
"$",
"Input",
";",
"}"
] | Returns XHTML for a radio input element.
Provides way of wrapping Input() with a label.
@param string $FieldName Name of the field that is being displayed/posted with this input.
It should related directly to a field name in $this->_DataArray.
@param string $Label Label to place next to the radio.
@param array $Attributes Associative array of attributes for the input (e.g. onclick, class).
Special values 'Value' and 'Default' (see RadioList).
@return string | [
"Returns",
"XHTML",
"for",
"a",
"radio",
"input",
"element",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L1374-L1396 |
6,365 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.RadioList | public function RadioList($FieldName, $DataSet, $Attributes = FALSE) {
$List = GetValue('list', $Attributes);
$Return = '';
if ($List) {
$Return .= '<ul'.(isset($Attributes['listclass']) ? " class=\"{$Attributes['listclass']}\"" : '').'>';
$LiOpen = '<li>';
$LiClose = '</li>';
} else {
$LiOpen = '';
$LiClose = ' ';
}
// Show inline errors?
$ShowErrors = ($this->_InlineErrors && array_key_exists($FieldName, $this->_ValidationResults));
// Add error class to input element
if ($ShowErrors)
$this->AddErrorClass($Attributes);
if (is_object($DataSet)) {
$ValueField = ArrayValueI('ValueField', $Attributes, 'value');
$TextField = ArrayValueI('TextField', $Attributes, 'text');
$Data = $DataSet->FirstRow();
if (property_exists($Data, $ValueField) && property_exists($Data,
$TextField)) {
foreach($DataSet->Result() as $Data) {
$Attributes['value'] = $Data->$ValueField;
$Return .= $LiOpen.$this->Radio($FieldName, $Data->$TextField, $Attributes).$LiClose;
}
}
} elseif (is_array($DataSet)) {
foreach($DataSet as $ID => $Text) {
$Attributes['value'] = $ID;
$Return .= $LiOpen.$this->Radio($FieldName, $Text, $Attributes).$LiClose;
}
}
if ($List)
$Return .= '</ul>';
// Append validation error message
if ($ShowErrors && ArrayValueI('InlineErrors', $Attributes, TRUE))
$Return .= $this->InlineError($FieldName);
return $Return;
} | php | public function RadioList($FieldName, $DataSet, $Attributes = FALSE) {
$List = GetValue('list', $Attributes);
$Return = '';
if ($List) {
$Return .= '<ul'.(isset($Attributes['listclass']) ? " class=\"{$Attributes['listclass']}\"" : '').'>';
$LiOpen = '<li>';
$LiClose = '</li>';
} else {
$LiOpen = '';
$LiClose = ' ';
}
// Show inline errors?
$ShowErrors = ($this->_InlineErrors && array_key_exists($FieldName, $this->_ValidationResults));
// Add error class to input element
if ($ShowErrors)
$this->AddErrorClass($Attributes);
if (is_object($DataSet)) {
$ValueField = ArrayValueI('ValueField', $Attributes, 'value');
$TextField = ArrayValueI('TextField', $Attributes, 'text');
$Data = $DataSet->FirstRow();
if (property_exists($Data, $ValueField) && property_exists($Data,
$TextField)) {
foreach($DataSet->Result() as $Data) {
$Attributes['value'] = $Data->$ValueField;
$Return .= $LiOpen.$this->Radio($FieldName, $Data->$TextField, $Attributes).$LiClose;
}
}
} elseif (is_array($DataSet)) {
foreach($DataSet as $ID => $Text) {
$Attributes['value'] = $ID;
$Return .= $LiOpen.$this->Radio($FieldName, $Text, $Attributes).$LiClose;
}
}
if ($List)
$Return .= '</ul>';
// Append validation error message
if ($ShowErrors && ArrayValueI('InlineErrors', $Attributes, TRUE))
$Return .= $this->InlineError($FieldName);
return $Return;
} | [
"public",
"function",
"RadioList",
"(",
"$",
"FieldName",
",",
"$",
"DataSet",
",",
"$",
"Attributes",
"=",
"FALSE",
")",
"{",
"$",
"List",
"=",
"GetValue",
"(",
"'list'",
",",
"$",
"Attributes",
")",
";",
"$",
"Return",
"=",
"''",
";",
"if",
"(",
"$",
"List",
")",
"{",
"$",
"Return",
".=",
"'<ul'",
".",
"(",
"isset",
"(",
"$",
"Attributes",
"[",
"'listclass'",
"]",
")",
"?",
"\" class=\\\"{$Attributes['listclass']}\\\"\"",
":",
"''",
")",
".",
"'>'",
";",
"$",
"LiOpen",
"=",
"'<li>'",
";",
"$",
"LiClose",
"=",
"'</li>'",
";",
"}",
"else",
"{",
"$",
"LiOpen",
"=",
"''",
";",
"$",
"LiClose",
"=",
"' '",
";",
"}",
"// Show inline errors?",
"$",
"ShowErrors",
"=",
"(",
"$",
"this",
"->",
"_InlineErrors",
"&&",
"array_key_exists",
"(",
"$",
"FieldName",
",",
"$",
"this",
"->",
"_ValidationResults",
")",
")",
";",
"// Add error class to input element",
"if",
"(",
"$",
"ShowErrors",
")",
"$",
"this",
"->",
"AddErrorClass",
"(",
"$",
"Attributes",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"DataSet",
")",
")",
"{",
"$",
"ValueField",
"=",
"ArrayValueI",
"(",
"'ValueField'",
",",
"$",
"Attributes",
",",
"'value'",
")",
";",
"$",
"TextField",
"=",
"ArrayValueI",
"(",
"'TextField'",
",",
"$",
"Attributes",
",",
"'text'",
")",
";",
"$",
"Data",
"=",
"$",
"DataSet",
"->",
"FirstRow",
"(",
")",
";",
"if",
"(",
"property_exists",
"(",
"$",
"Data",
",",
"$",
"ValueField",
")",
"&&",
"property_exists",
"(",
"$",
"Data",
",",
"$",
"TextField",
")",
")",
"{",
"foreach",
"(",
"$",
"DataSet",
"->",
"Result",
"(",
")",
"as",
"$",
"Data",
")",
"{",
"$",
"Attributes",
"[",
"'value'",
"]",
"=",
"$",
"Data",
"->",
"$",
"ValueField",
";",
"$",
"Return",
".=",
"$",
"LiOpen",
".",
"$",
"this",
"->",
"Radio",
"(",
"$",
"FieldName",
",",
"$",
"Data",
"->",
"$",
"TextField",
",",
"$",
"Attributes",
")",
".",
"$",
"LiClose",
";",
"}",
"}",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"DataSet",
")",
")",
"{",
"foreach",
"(",
"$",
"DataSet",
"as",
"$",
"ID",
"=>",
"$",
"Text",
")",
"{",
"$",
"Attributes",
"[",
"'value'",
"]",
"=",
"$",
"ID",
";",
"$",
"Return",
".=",
"$",
"LiOpen",
".",
"$",
"this",
"->",
"Radio",
"(",
"$",
"FieldName",
",",
"$",
"Text",
",",
"$",
"Attributes",
")",
".",
"$",
"LiClose",
";",
"}",
"}",
"if",
"(",
"$",
"List",
")",
"$",
"Return",
".=",
"'</ul>'",
";",
"// Append validation error message",
"if",
"(",
"$",
"ShowErrors",
"&&",
"ArrayValueI",
"(",
"'InlineErrors'",
",",
"$",
"Attributes",
",",
"TRUE",
")",
")",
"$",
"Return",
".=",
"$",
"this",
"->",
"InlineError",
"(",
"$",
"FieldName",
")",
";",
"return",
"$",
"Return",
";",
"}"
] | Returns XHTML for an unordered list of radio button elements.
@param string $FieldName The name of the field that is being displayed/posted with this input.
It should related directly to a field name in $this->_DataArray. ie. RoleID
@param mixed $DataSet The data to fill the options in the select list. Either an associative
array or a database dataset.
@param array $Attributes An associative array of attributes for the list. Here is a list of
"special" attributes and their default values:
Attribute Options Default
------------------------------------------------------------------------
ValueField The name of the field in 'value'
$DataSet that contains the
option values.
TextField The name of the field in 'text'
$DataSet that contains the
option text.
Value A string or array of strings. $this->_DataArray->$FieldName
Default The default value. empty
InlineErrors Show inline error message? TRUE
Allows disabling per-dropdown
for multi-fields like Date()
@return string | [
"Returns",
"XHTML",
"for",
"an",
"unordered",
"list",
"of",
"radio",
"button",
"elements",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L1424-L1471 |
6,366 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.TextBox | public function TextBox($FieldName, $Attributes = FALSE) {
if (!is_array($Attributes))
$Attributes = array();
$MultiLine = ArrayValueI('MultiLine', $Attributes);
if ($MultiLine) {
$Attributes['rows'] = ArrayValueI('rows', $Attributes, '6'); // For xhtml compliance
$Attributes['cols'] = ArrayValueI('cols', $Attributes, '100'); // For xhtml compliance
}
// Show inline errors?
$ShowErrors = $this->_InlineErrors && array_key_exists($FieldName, $this->_ValidationResults);
$CssClass = ArrayValueI('class', $Attributes);
if ($CssClass == FALSE) $Attributes['class'] = $MultiLine ? 'TextBox' : 'InputBox';
// Add error class to input element
if ($ShowErrors) $this->AddErrorClass($Attributes);
$Return = '';
$Wrap = GetValue('Wrap', $Attributes, FALSE, TRUE);
if ($Wrap)
$Return .= '<div class="TextBoxWrapper">';
$Return .= $MultiLine === TRUE ? '<textarea' : '<input type="'.GetValue('type', $Attributes, 'text').'"';
$Return .= $this->_IDAttribute($FieldName, $Attributes);
$Return .= $this->_NameAttribute($FieldName, $Attributes);
$Return .= $MultiLine === TRUE ? '' : $this->_ValueAttribute($FieldName, $Attributes);
$Return .= $this->_AttributesToString($Attributes);
$Value = ArrayValueI('value', $Attributes, $this->GetValue($FieldName));
$Return .= $MultiLine === TRUE ? '>' . htmlentities($Value, ENT_COMPAT, 'UTF-8') . '</textarea>' : ' />';
// Append validation error message
if ($ShowErrors)
$Return .= $this->InlineError($FieldName);
if ($Wrap)
$Return .= '</div>';
return $Return;
} | php | public function TextBox($FieldName, $Attributes = FALSE) {
if (!is_array($Attributes))
$Attributes = array();
$MultiLine = ArrayValueI('MultiLine', $Attributes);
if ($MultiLine) {
$Attributes['rows'] = ArrayValueI('rows', $Attributes, '6'); // For xhtml compliance
$Attributes['cols'] = ArrayValueI('cols', $Attributes, '100'); // For xhtml compliance
}
// Show inline errors?
$ShowErrors = $this->_InlineErrors && array_key_exists($FieldName, $this->_ValidationResults);
$CssClass = ArrayValueI('class', $Attributes);
if ($CssClass == FALSE) $Attributes['class'] = $MultiLine ? 'TextBox' : 'InputBox';
// Add error class to input element
if ($ShowErrors) $this->AddErrorClass($Attributes);
$Return = '';
$Wrap = GetValue('Wrap', $Attributes, FALSE, TRUE);
if ($Wrap)
$Return .= '<div class="TextBoxWrapper">';
$Return .= $MultiLine === TRUE ? '<textarea' : '<input type="'.GetValue('type', $Attributes, 'text').'"';
$Return .= $this->_IDAttribute($FieldName, $Attributes);
$Return .= $this->_NameAttribute($FieldName, $Attributes);
$Return .= $MultiLine === TRUE ? '' : $this->_ValueAttribute($FieldName, $Attributes);
$Return .= $this->_AttributesToString($Attributes);
$Value = ArrayValueI('value', $Attributes, $this->GetValue($FieldName));
$Return .= $MultiLine === TRUE ? '>' . htmlentities($Value, ENT_COMPAT, 'UTF-8') . '</textarea>' : ' />';
// Append validation error message
if ($ShowErrors)
$Return .= $this->InlineError($FieldName);
if ($Wrap)
$Return .= '</div>';
return $Return;
} | [
"public",
"function",
"TextBox",
"(",
"$",
"FieldName",
",",
"$",
"Attributes",
"=",
"FALSE",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"Attributes",
")",
")",
"$",
"Attributes",
"=",
"array",
"(",
")",
";",
"$",
"MultiLine",
"=",
"ArrayValueI",
"(",
"'MultiLine'",
",",
"$",
"Attributes",
")",
";",
"if",
"(",
"$",
"MultiLine",
")",
"{",
"$",
"Attributes",
"[",
"'rows'",
"]",
"=",
"ArrayValueI",
"(",
"'rows'",
",",
"$",
"Attributes",
",",
"'6'",
")",
";",
"// For xhtml compliance",
"$",
"Attributes",
"[",
"'cols'",
"]",
"=",
"ArrayValueI",
"(",
"'cols'",
",",
"$",
"Attributes",
",",
"'100'",
")",
";",
"// For xhtml compliance",
"}",
"// Show inline errors?",
"$",
"ShowErrors",
"=",
"$",
"this",
"->",
"_InlineErrors",
"&&",
"array_key_exists",
"(",
"$",
"FieldName",
",",
"$",
"this",
"->",
"_ValidationResults",
")",
";",
"$",
"CssClass",
"=",
"ArrayValueI",
"(",
"'class'",
",",
"$",
"Attributes",
")",
";",
"if",
"(",
"$",
"CssClass",
"==",
"FALSE",
")",
"$",
"Attributes",
"[",
"'class'",
"]",
"=",
"$",
"MultiLine",
"?",
"'TextBox'",
":",
"'InputBox'",
";",
"// Add error class to input element",
"if",
"(",
"$",
"ShowErrors",
")",
"$",
"this",
"->",
"AddErrorClass",
"(",
"$",
"Attributes",
")",
";",
"$",
"Return",
"=",
"''",
";",
"$",
"Wrap",
"=",
"GetValue",
"(",
"'Wrap'",
",",
"$",
"Attributes",
",",
"FALSE",
",",
"TRUE",
")",
";",
"if",
"(",
"$",
"Wrap",
")",
"$",
"Return",
".=",
"'<div class=\"TextBoxWrapper\">'",
";",
"$",
"Return",
".=",
"$",
"MultiLine",
"===",
"TRUE",
"?",
"'<textarea'",
":",
"'<input type=\"'",
".",
"GetValue",
"(",
"'type'",
",",
"$",
"Attributes",
",",
"'text'",
")",
".",
"'\"'",
";",
"$",
"Return",
".=",
"$",
"this",
"->",
"_IDAttribute",
"(",
"$",
"FieldName",
",",
"$",
"Attributes",
")",
";",
"$",
"Return",
".=",
"$",
"this",
"->",
"_NameAttribute",
"(",
"$",
"FieldName",
",",
"$",
"Attributes",
")",
";",
"$",
"Return",
".=",
"$",
"MultiLine",
"===",
"TRUE",
"?",
"''",
":",
"$",
"this",
"->",
"_ValueAttribute",
"(",
"$",
"FieldName",
",",
"$",
"Attributes",
")",
";",
"$",
"Return",
".=",
"$",
"this",
"->",
"_AttributesToString",
"(",
"$",
"Attributes",
")",
";",
"$",
"Value",
"=",
"ArrayValueI",
"(",
"'value'",
",",
"$",
"Attributes",
",",
"$",
"this",
"->",
"GetValue",
"(",
"$",
"FieldName",
")",
")",
";",
"$",
"Return",
".=",
"$",
"MultiLine",
"===",
"TRUE",
"?",
"'>'",
".",
"htmlentities",
"(",
"$",
"Value",
",",
"ENT_COMPAT",
",",
"'UTF-8'",
")",
".",
"'</textarea>'",
":",
"' />'",
";",
"// Append validation error message",
"if",
"(",
"$",
"ShowErrors",
")",
"$",
"Return",
".=",
"$",
"this",
"->",
"InlineError",
"(",
"$",
"FieldName",
")",
";",
"if",
"(",
"$",
"Wrap",
")",
"$",
"Return",
".=",
"'</div>'",
";",
"return",
"$",
"Return",
";",
"}"
] | Returns the xhtml for a text-based input.
@param string $FieldName The name of the field that is being displayed/posted with this input. It
should related directly to a field name in $this->_DataArray.
@param array $Attributes An associative array of attributes for the input. ie. maxlength, onclick,
class, etc
@return string | [
"Returns",
"the",
"xhtml",
"for",
"a",
"text",
"-",
"based",
"input",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L1482-L1525 |
6,367 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.AddHidden | public function AddHidden($FieldName, $Value = NULL, $ForceValue = FALSE) {
if ($this->IsPostBack() && $ForceValue === FALSE)
$Value = $this->GetFormValue($FieldName, $Value);
$this->HiddenInputs[$FieldName] = $Value;
} | php | public function AddHidden($FieldName, $Value = NULL, $ForceValue = FALSE) {
if ($this->IsPostBack() && $ForceValue === FALSE)
$Value = $this->GetFormValue($FieldName, $Value);
$this->HiddenInputs[$FieldName] = $Value;
} | [
"public",
"function",
"AddHidden",
"(",
"$",
"FieldName",
",",
"$",
"Value",
"=",
"NULL",
",",
"$",
"ForceValue",
"=",
"FALSE",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"IsPostBack",
"(",
")",
"&&",
"$",
"ForceValue",
"===",
"FALSE",
")",
"$",
"Value",
"=",
"$",
"this",
"->",
"GetFormValue",
"(",
"$",
"FieldName",
",",
"$",
"Value",
")",
";",
"$",
"this",
"->",
"HiddenInputs",
"[",
"$",
"FieldName",
"]",
"=",
"$",
"Value",
";",
"}"
] | Adds a hidden input value to the form.
If the $ForceValue parameter remains FALSE, it will grab the value into the hidden input from the form
on postback. Otherwise it will always force the assigned value to the
input regardless of postback.
@param string $FieldName The name of the field being added as a hidden input on the form.
@param string $Value The value being assigned in the hidden input. Unless $ForceValue is
changed to TRUE, this field will be retrieved from the form upon
postback.
@param bool $ForceValue | [
"Adds",
"a",
"hidden",
"input",
"value",
"to",
"the",
"form",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L1594-L1599 |
6,368 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.EscapeFieldName | public function EscapeFieldName($FieldName) {
$Return = $this->InputPrefix;
if ($Return != '') $Return .= '/';
return $Return . $this->EscapeString($FieldName);
} | php | public function EscapeFieldName($FieldName) {
$Return = $this->InputPrefix;
if ($Return != '') $Return .= '/';
return $Return . $this->EscapeString($FieldName);
} | [
"public",
"function",
"EscapeFieldName",
"(",
"$",
"FieldName",
")",
"{",
"$",
"Return",
"=",
"$",
"this",
"->",
"InputPrefix",
";",
"if",
"(",
"$",
"Return",
"!=",
"''",
")",
"$",
"Return",
".=",
"'/'",
";",
"return",
"$",
"Return",
".",
"$",
"this",
"->",
"EscapeString",
"(",
"$",
"FieldName",
")",
";",
"}"
] | Returns the provided fieldname with non-alpha-numeric values stripped.
@param string $FieldName The field name to escape.
@return string | [
"Returns",
"the",
"provided",
"fieldname",
"with",
"non",
"-",
"alpha",
"-",
"numeric",
"values",
"stripped",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L1667-L1671 |
6,369 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.IsMyPostBack | public function IsMyPostBack() {
switch (strtolower($this->Method)) {
case 'get':
return count($_GET) > 0 || (is_array($this->FormValues()) && count($this->FormValues()) > 0) ? TRUE : FALSE;
default:
return Gdn::Request()->IsPostBack();
}
} | php | public function IsMyPostBack() {
switch (strtolower($this->Method)) {
case 'get':
return count($_GET) > 0 || (is_array($this->FormValues()) && count($this->FormValues()) > 0) ? TRUE : FALSE;
default:
return Gdn::Request()->IsPostBack();
}
} | [
"public",
"function",
"IsMyPostBack",
"(",
")",
"{",
"switch",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"Method",
")",
")",
"{",
"case",
"'get'",
":",
"return",
"count",
"(",
"$",
"_GET",
")",
">",
"0",
"||",
"(",
"is_array",
"(",
"$",
"this",
"->",
"FormValues",
"(",
")",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"FormValues",
"(",
")",
")",
">",
"0",
")",
"?",
"TRUE",
":",
"FALSE",
";",
"default",
":",
"return",
"Gdn",
"::",
"Request",
"(",
")",
"->",
"IsPostBack",
"(",
")",
";",
"}",
"}"
] | Check if THIS particular form was submitted
Just like IsPostBack(), except auto populates FormValues and doesnt just check
"was some data submitted lol?!".
@return boolean | [
"Check",
"if",
"THIS",
"particular",
"form",
"was",
"submitted"
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L1922-L1929 |
6,370 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.Save | public function Save() {
$SaveResult = FALSE;
if ($this->ErrorCount() == 0) {
if (!isset($this->_Model)) trigger_error(
ErrorMessage(
"You cannot call the form's save method if a model has not been defined.",
"Form", "Save"), E_USER_ERROR);
$Data = $this->FormValues();
if (method_exists($this->_Model, 'FilterForm'))
$Data = $this->_Model->FilterForm($this->FormValues());
$Args = array_merge(func_get_args(),
array(
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL));
$SaveResult = $this->_Model->Save($Data, $Args[0], $Args[1],
$Args[2], $Args[3], $Args[4], $Args[5], $Args[6], $Args[7],
$Args[8], $Args[9]);
if ($SaveResult === FALSE) {
// NOTE: THE VALIDATION FUNCTION NAMES ARE ALSO THE LANGUAGE
// TRANSLATIONS OF THE ERROR MESSAGES. CHECK THEM OUT IN THE LOCALE
// FILE.
$this->SetValidationResults($this->_Model->ValidationResults());
}
}
return $SaveResult;
} | php | public function Save() {
$SaveResult = FALSE;
if ($this->ErrorCount() == 0) {
if (!isset($this->_Model)) trigger_error(
ErrorMessage(
"You cannot call the form's save method if a model has not been defined.",
"Form", "Save"), E_USER_ERROR);
$Data = $this->FormValues();
if (method_exists($this->_Model, 'FilterForm'))
$Data = $this->_Model->FilterForm($this->FormValues());
$Args = array_merge(func_get_args(),
array(
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL));
$SaveResult = $this->_Model->Save($Data, $Args[0], $Args[1],
$Args[2], $Args[3], $Args[4], $Args[5], $Args[6], $Args[7],
$Args[8], $Args[9]);
if ($SaveResult === FALSE) {
// NOTE: THE VALIDATION FUNCTION NAMES ARE ALSO THE LANGUAGE
// TRANSLATIONS OF THE ERROR MESSAGES. CHECK THEM OUT IN THE LOCALE
// FILE.
$this->SetValidationResults($this->_Model->ValidationResults());
}
}
return $SaveResult;
} | [
"public",
"function",
"Save",
"(",
")",
"{",
"$",
"SaveResult",
"=",
"FALSE",
";",
"if",
"(",
"$",
"this",
"->",
"ErrorCount",
"(",
")",
"==",
"0",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_Model",
")",
")",
"trigger_error",
"(",
"ErrorMessage",
"(",
"\"You cannot call the form's save method if a model has not been defined.\"",
",",
"\"Form\"",
",",
"\"Save\"",
")",
",",
"E_USER_ERROR",
")",
";",
"$",
"Data",
"=",
"$",
"this",
"->",
"FormValues",
"(",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
"->",
"_Model",
",",
"'FilterForm'",
")",
")",
"$",
"Data",
"=",
"$",
"this",
"->",
"_Model",
"->",
"FilterForm",
"(",
"$",
"this",
"->",
"FormValues",
"(",
")",
")",
";",
"$",
"Args",
"=",
"array_merge",
"(",
"func_get_args",
"(",
")",
",",
"array",
"(",
"NULL",
",",
"NULL",
",",
"NULL",
",",
"NULL",
",",
"NULL",
",",
"NULL",
",",
"NULL",
",",
"NULL",
",",
"NULL",
",",
"NULL",
")",
")",
";",
"$",
"SaveResult",
"=",
"$",
"this",
"->",
"_Model",
"->",
"Save",
"(",
"$",
"Data",
",",
"$",
"Args",
"[",
"0",
"]",
",",
"$",
"Args",
"[",
"1",
"]",
",",
"$",
"Args",
"[",
"2",
"]",
",",
"$",
"Args",
"[",
"3",
"]",
",",
"$",
"Args",
"[",
"4",
"]",
",",
"$",
"Args",
"[",
"5",
"]",
",",
"$",
"Args",
"[",
"6",
"]",
",",
"$",
"Args",
"[",
"7",
"]",
",",
"$",
"Args",
"[",
"8",
"]",
",",
"$",
"Args",
"[",
"9",
"]",
")",
";",
"if",
"(",
"$",
"SaveResult",
"===",
"FALSE",
")",
"{",
"// NOTE: THE VALIDATION FUNCTION NAMES ARE ALSO THE LANGUAGE",
"// TRANSLATIONS OF THE ERROR MESSAGES. CHECK THEM OUT IN THE LOCALE",
"// FILE.",
"$",
"this",
"->",
"SetValidationResults",
"(",
"$",
"this",
"->",
"_Model",
"->",
"ValidationResults",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"SaveResult",
";",
"}"
] | This is a convenience method so that you don't have to code this every time
you want to save a simple model's data.
It uses the assigned model to save the sent form fields.
If saving fails, it populates $this->_ValidationResults with validation errors & related fields.
@return unknown | [
"This",
"is",
"a",
"convenience",
"method",
"so",
"that",
"you",
"don",
"t",
"have",
"to",
"code",
"this",
"every",
"time",
"you",
"want",
"to",
"save",
"a",
"simple",
"model",
"s",
"data",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L1940-L1975 |
6,371 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.SetData | public function SetData($Data) {
if (is_object($Data) === TRUE) {
// If this is a result object (/garden/library/database/class.dataset.php)
// retrieve it's values as arrays
if ($Data instanceof DataSet) {
$ResultSet = $Data->ResultArray();
if (count($ResultSet) > 0)
$this->_DataArray = $ResultSet[0];
} else {
// Otherwise assume it is an object representation of a data row.
$this->_DataArray = Gdn_Format::ObjectAsArray($Data);
}
} else if (is_array($Data)) {
$this->_DataArray = $Data;
}
} | php | public function SetData($Data) {
if (is_object($Data) === TRUE) {
// If this is a result object (/garden/library/database/class.dataset.php)
// retrieve it's values as arrays
if ($Data instanceof DataSet) {
$ResultSet = $Data->ResultArray();
if (count($ResultSet) > 0)
$this->_DataArray = $ResultSet[0];
} else {
// Otherwise assume it is an object representation of a data row.
$this->_DataArray = Gdn_Format::ObjectAsArray($Data);
}
} else if (is_array($Data)) {
$this->_DataArray = $Data;
}
} | [
"public",
"function",
"SetData",
"(",
"$",
"Data",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"Data",
")",
"===",
"TRUE",
")",
"{",
"// If this is a result object (/garden/library/database/class.dataset.php)",
"// retrieve it's values as arrays",
"if",
"(",
"$",
"Data",
"instanceof",
"DataSet",
")",
"{",
"$",
"ResultSet",
"=",
"$",
"Data",
"->",
"ResultArray",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"ResultSet",
")",
">",
"0",
")",
"$",
"this",
"->",
"_DataArray",
"=",
"$",
"ResultSet",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"// Otherwise assume it is an object representation of a data row.",
"$",
"this",
"->",
"_DataArray",
"=",
"Gdn_Format",
"::",
"ObjectAsArray",
"(",
"$",
"Data",
")",
";",
"}",
"}",
"else",
"if",
"(",
"is_array",
"(",
"$",
"Data",
")",
")",
"{",
"$",
"this",
"->",
"_DataArray",
"=",
"$",
"Data",
";",
"}",
"}"
] | Assign a set of data to be displayed in the form elements.
@param Ressource $Data A result resource or associative array containing data to be filled in | [
"Assign",
"a",
"set",
"of",
"data",
"to",
"be",
"displayed",
"in",
"the",
"form",
"elements",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L1982-L1998 |
6,372 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.RemoveFormValue | public function RemoveFormValue($FieldName) {
$this->FormValues();
if (!is_array($FieldName))
$FieldName = array($FieldName);
foreach ($FieldName as $Field)
unset($this->_FormValues[$Field]);
} | php | public function RemoveFormValue($FieldName) {
$this->FormValues();
if (!is_array($FieldName))
$FieldName = array($FieldName);
foreach ($FieldName as $Field)
unset($this->_FormValues[$Field]);
} | [
"public",
"function",
"RemoveFormValue",
"(",
"$",
"FieldName",
")",
"{",
"$",
"this",
"->",
"FormValues",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"FieldName",
")",
")",
"$",
"FieldName",
"=",
"array",
"(",
"$",
"FieldName",
")",
";",
"foreach",
"(",
"$",
"FieldName",
"as",
"$",
"Field",
")",
"unset",
"(",
"$",
"this",
"->",
"_FormValues",
"[",
"$",
"Field",
"]",
")",
";",
"}"
] | Remove an element from a form
@param string $FieldName | [
"Remove",
"an",
"element",
"from",
"a",
"form"
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L2020-L2028 |
6,373 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.ValidateModel | public function ValidateModel() {
$this->_Model->DefineSchema();
if ($this->_Model->Validation->Validate($this->FormValues()) === FALSE) $this->_ValidationResults = $this->_Model->ValidationResults();
return $this->ErrorCount();
} | php | public function ValidateModel() {
$this->_Model->DefineSchema();
if ($this->_Model->Validation->Validate($this->FormValues()) === FALSE) $this->_ValidationResults = $this->_Model->ValidationResults();
return $this->ErrorCount();
} | [
"public",
"function",
"ValidateModel",
"(",
")",
"{",
"$",
"this",
"->",
"_Model",
"->",
"DefineSchema",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_Model",
"->",
"Validation",
"->",
"Validate",
"(",
"$",
"this",
"->",
"FormValues",
"(",
")",
")",
"===",
"FALSE",
")",
"$",
"this",
"->",
"_ValidationResults",
"=",
"$",
"this",
"->",
"_Model",
"->",
"ValidationResults",
"(",
")",
";",
"return",
"$",
"this",
"->",
"ErrorCount",
"(",
")",
";",
"}"
] | If not saving data directly to the model, this method allows you to
utilize a model's schema to validate a form's inputs regardless.
ie. A sign-in form that just needs to compare data to the model and still
enforce it's rules. Returns the number of errors that were recorded
through validation.
@return int | [
"If",
"not",
"saving",
"data",
"directly",
"to",
"the",
"model",
"this",
"method",
"allows",
"you",
"to",
"utilize",
"a",
"model",
"s",
"schema",
"to",
"validate",
"a",
"form",
"s",
"inputs",
"regardless",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L2171-L2175 |
6,374 | bishopb/vanilla | library/core/class.form.php | Gdn_Form.ValidateRule | public function ValidateRule($FieldName, $Rule, $CustomError = '') {
$Value = $this->GetFormValue($FieldName);
$Valid = Gdn_Validation::ValidateRule($Value, $FieldName, $Rule, $CustomError);
if ($Valid === TRUE)
return TRUE;
else {
$this->AddError('@'.$Valid);
return FALSE;
}
} | php | public function ValidateRule($FieldName, $Rule, $CustomError = '') {
$Value = $this->GetFormValue($FieldName);
$Valid = Gdn_Validation::ValidateRule($Value, $FieldName, $Rule, $CustomError);
if ($Valid === TRUE)
return TRUE;
else {
$this->AddError('@'.$Valid);
return FALSE;
}
} | [
"public",
"function",
"ValidateRule",
"(",
"$",
"FieldName",
",",
"$",
"Rule",
",",
"$",
"CustomError",
"=",
"''",
")",
"{",
"$",
"Value",
"=",
"$",
"this",
"->",
"GetFormValue",
"(",
"$",
"FieldName",
")",
";",
"$",
"Valid",
"=",
"Gdn_Validation",
"::",
"ValidateRule",
"(",
"$",
"Value",
",",
"$",
"FieldName",
",",
"$",
"Rule",
",",
"$",
"CustomError",
")",
";",
"if",
"(",
"$",
"Valid",
"===",
"TRUE",
")",
"return",
"TRUE",
";",
"else",
"{",
"$",
"this",
"->",
"AddError",
"(",
"'@'",
".",
"$",
"Valid",
")",
";",
"return",
"FALSE",
";",
"}",
"}"
] | Validates a rule on the form and adds its result to the errors collection.
@param string $FieldName The name of the field to validate.
@param string|array $Rule The rule to validate against.
@param string $CustomError A custom error string.
@return bool Whether or not the rule succeeded.
@see Gdn_Validation::ValidateRule() | [
"Validates",
"a",
"rule",
"on",
"the",
"form",
"and",
"adds",
"its",
"result",
"to",
"the",
"errors",
"collection",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.form.php#L2187-L2198 |
6,375 | bearframework/emails-addon | classes/Emails/Email/Headers.php | Headers.add | public function add(string $name, string $value): void
{
$header = $this->make();
$header->name = $name;
$header->value = $value;
$this->set($header);
} | php | public function add(string $name, string $value): void
{
$header = $this->make();
$header->name = $name;
$header->value = $value;
$this->set($header);
} | [
"public",
"function",
"add",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"value",
")",
":",
"void",
"{",
"$",
"header",
"=",
"$",
"this",
"->",
"make",
"(",
")",
";",
"$",
"header",
"->",
"name",
"=",
"$",
"name",
";",
"$",
"header",
"->",
"value",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"set",
"(",
"$",
"header",
")",
";",
"}"
] | Add a custom header.
@param string $name The name of the custom header.
@param string $value The value of the custom header.
@throws \InvalidArgumentException | [
"Add",
"a",
"custom",
"header",
"."
] | 43a68c47e2b1d231dc69a324249ff5f6827201ca | https://github.com/bearframework/emails-addon/blob/43a68c47e2b1d231dc69a324249ff5f6827201ca/classes/Emails/Email/Headers.php#L36-L42 |
6,376 | RitaCo/cakephp-tools-plugin | Model/Behavior/RevisionBehavior.php | RevisionBehavior.createRevision | public function createRevision(Model $Model) {
if (!$Model->id) {
trigger_error('RevisionBehavior: Model::id must be set', E_USER_WARNING);
return false;
}
if (!$Model->ShadowModel) {
trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
return false;
}
$habtm = array();
$allHabtm = $Model->getAssociated('hasAndBelongsToMany');
foreach ($allHabtm as $assocAlias) {
if (isset($Model->ShadowModel->_schema[$assocAlias])) {
$habtm[] = $assocAlias;
}
}
$data = $Model->find('first', array(
'conditions' => array($Model->alias . '.' . $Model->primaryKey => $Model->id),
'contain' => $habtm));
$Model->ShadowModel->create($data);
$Model->ShadowModel->set('version_created', date('Y-m-d H:i:s'));
foreach ($habtm as $assocAlias) {
$foreignKeys = Hash::extract($data, '{n}.' . $assocAlias . '.' . $Model->{$assocAlias}->primaryKey);
$Model->ShadowModel->set($assocAlias, implode(',', $foreignKeys));
}
return (bool)$Model->ShadowModel->save();
} | php | public function createRevision(Model $Model) {
if (!$Model->id) {
trigger_error('RevisionBehavior: Model::id must be set', E_USER_WARNING);
return false;
}
if (!$Model->ShadowModel) {
trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
return false;
}
$habtm = array();
$allHabtm = $Model->getAssociated('hasAndBelongsToMany');
foreach ($allHabtm as $assocAlias) {
if (isset($Model->ShadowModel->_schema[$assocAlias])) {
$habtm[] = $assocAlias;
}
}
$data = $Model->find('first', array(
'conditions' => array($Model->alias . '.' . $Model->primaryKey => $Model->id),
'contain' => $habtm));
$Model->ShadowModel->create($data);
$Model->ShadowModel->set('version_created', date('Y-m-d H:i:s'));
foreach ($habtm as $assocAlias) {
$foreignKeys = Hash::extract($data, '{n}.' . $assocAlias . '.' . $Model->{$assocAlias}->primaryKey);
$Model->ShadowModel->set($assocAlias, implode(',', $foreignKeys));
}
return (bool)$Model->ShadowModel->save();
} | [
"public",
"function",
"createRevision",
"(",
"Model",
"$",
"Model",
")",
"{",
"if",
"(",
"!",
"$",
"Model",
"->",
"id",
")",
"{",
"trigger_error",
"(",
"'RevisionBehavior: Model::id must be set'",
",",
"E_USER_WARNING",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"Model",
"->",
"ShadowModel",
")",
"{",
"trigger_error",
"(",
"'RevisionBehavior: ShadowModel doesnt exist.'",
",",
"E_USER_WARNING",
")",
";",
"return",
"false",
";",
"}",
"$",
"habtm",
"=",
"array",
"(",
")",
";",
"$",
"allHabtm",
"=",
"$",
"Model",
"->",
"getAssociated",
"(",
"'hasAndBelongsToMany'",
")",
";",
"foreach",
"(",
"$",
"allHabtm",
"as",
"$",
"assocAlias",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"Model",
"->",
"ShadowModel",
"->",
"_schema",
"[",
"$",
"assocAlias",
"]",
")",
")",
"{",
"$",
"habtm",
"[",
"]",
"=",
"$",
"assocAlias",
";",
"}",
"}",
"$",
"data",
"=",
"$",
"Model",
"->",
"find",
"(",
"'first'",
",",
"array",
"(",
"'conditions'",
"=>",
"array",
"(",
"$",
"Model",
"->",
"alias",
".",
"'.'",
".",
"$",
"Model",
"->",
"primaryKey",
"=>",
"$",
"Model",
"->",
"id",
")",
",",
"'contain'",
"=>",
"$",
"habtm",
")",
")",
";",
"$",
"Model",
"->",
"ShadowModel",
"->",
"create",
"(",
"$",
"data",
")",
";",
"$",
"Model",
"->",
"ShadowModel",
"->",
"set",
"(",
"'version_created'",
",",
"date",
"(",
"'Y-m-d H:i:s'",
")",
")",
";",
"foreach",
"(",
"$",
"habtm",
"as",
"$",
"assocAlias",
")",
"{",
"$",
"foreignKeys",
"=",
"Hash",
"::",
"extract",
"(",
"$",
"data",
",",
"'{n}.'",
".",
"$",
"assocAlias",
".",
"'.'",
".",
"$",
"Model",
"->",
"{",
"$",
"assocAlias",
"}",
"->",
"primaryKey",
")",
";",
"$",
"Model",
"->",
"ShadowModel",
"->",
"set",
"(",
"$",
"assocAlias",
",",
"implode",
"(",
"','",
",",
"$",
"foreignKeys",
")",
")",
";",
"}",
"return",
"(",
"bool",
")",
"$",
"Model",
"->",
"ShadowModel",
"->",
"save",
"(",
")",
";",
"}"
] | Manually create a revision of the current record of Model->id
@example $this->Post->id = 5; $this->Post->createRevision();
@param object $Model
@return bool Success | [
"Manually",
"create",
"a",
"revision",
"of",
"the",
"current",
"record",
"of",
"Model",
"-",
">",
"id"
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Model/Behavior/RevisionBehavior.php#L166-L192 |
6,377 | RitaCo/cakephp-tools-plugin | Model/Behavior/RevisionBehavior.php | RevisionBehavior.diff | public function diff(Model $Model, $fromVersionId = null, $toVersionId = null, $options = array()) {
if (!$Model->id) {
trigger_error('RevisionBehavior: Model::id must be set', E_USER_WARNING);
return array();
}
if (!$Model->ShadowModel) {
trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
return array();
}
if (isset($options['conditions'])) {
$conditions = array_merge($options['conditions'], array($Model->primaryKey => $Model->id));
} else {
$conditions = array($Model->primaryKey => $Model->id);
}
if (is_numeric($fromVersionId) || is_numeric($toVersionId)) {
if (is_numeric($fromVersionId) && is_numeric($toVersionId)) {
$conditions['version_id'] = array($fromVersionId, $toVersionId);
if ($Model->ShadowModel->find('count', array('conditions' => $conditions)) < 2) {
return array();
}
} else {
if (is_numeric($fromVersionId)) {
$conditions['version_id'] = $fromVersionId;
} else {
$conditions['version_id'] = $toVersionId;
}
if ($Model->ShadowModel->find('count', array('conditions' => $conditions)) < 1) {
return array();
}
}
}
$conditions = array($Model->primaryKey => $Model->id);
if (is_numeric($fromVersionId)) {
$conditions['version_id >='] = $fromVersionId;
}
if (is_numeric($toVersionId)) {
$conditions['version_id <='] = $toVersionId;
}
$options['conditions'] = $conditions;
$all = $this->revisions($Model, $options, true);
if (!$all) {
return array();
}
$unified = array();
$keys = array_keys($all[0][$Model->alias]);
foreach ($keys as $field) {
$allValues = Hash::extract($all, '{n}.' . $Model->alias . '.' . $field);
$allValues = array_reverse(array_unique(array_reverse($allValues, true)), true);
if (sizeof($allValues) == 1) {
$unified[$field] = reset($allValues);
} else {
$unified[$field] = $allValues;
}
}
return array($Model->alias => $unified);
} | php | public function diff(Model $Model, $fromVersionId = null, $toVersionId = null, $options = array()) {
if (!$Model->id) {
trigger_error('RevisionBehavior: Model::id must be set', E_USER_WARNING);
return array();
}
if (!$Model->ShadowModel) {
trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
return array();
}
if (isset($options['conditions'])) {
$conditions = array_merge($options['conditions'], array($Model->primaryKey => $Model->id));
} else {
$conditions = array($Model->primaryKey => $Model->id);
}
if (is_numeric($fromVersionId) || is_numeric($toVersionId)) {
if (is_numeric($fromVersionId) && is_numeric($toVersionId)) {
$conditions['version_id'] = array($fromVersionId, $toVersionId);
if ($Model->ShadowModel->find('count', array('conditions' => $conditions)) < 2) {
return array();
}
} else {
if (is_numeric($fromVersionId)) {
$conditions['version_id'] = $fromVersionId;
} else {
$conditions['version_id'] = $toVersionId;
}
if ($Model->ShadowModel->find('count', array('conditions' => $conditions)) < 1) {
return array();
}
}
}
$conditions = array($Model->primaryKey => $Model->id);
if (is_numeric($fromVersionId)) {
$conditions['version_id >='] = $fromVersionId;
}
if (is_numeric($toVersionId)) {
$conditions['version_id <='] = $toVersionId;
}
$options['conditions'] = $conditions;
$all = $this->revisions($Model, $options, true);
if (!$all) {
return array();
}
$unified = array();
$keys = array_keys($all[0][$Model->alias]);
foreach ($keys as $field) {
$allValues = Hash::extract($all, '{n}.' . $Model->alias . '.' . $field);
$allValues = array_reverse(array_unique(array_reverse($allValues, true)), true);
if (sizeof($allValues) == 1) {
$unified[$field] = reset($allValues);
} else {
$unified[$field] = $allValues;
}
}
return array($Model->alias => $unified);
} | [
"public",
"function",
"diff",
"(",
"Model",
"$",
"Model",
",",
"$",
"fromVersionId",
"=",
"null",
",",
"$",
"toVersionId",
"=",
"null",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"Model",
"->",
"id",
")",
"{",
"trigger_error",
"(",
"'RevisionBehavior: Model::id must be set'",
",",
"E_USER_WARNING",
")",
";",
"return",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"Model",
"->",
"ShadowModel",
")",
"{",
"trigger_error",
"(",
"'RevisionBehavior: ShadowModel doesnt exist.'",
",",
"E_USER_WARNING",
")",
";",
"return",
"array",
"(",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'conditions'",
"]",
")",
")",
"{",
"$",
"conditions",
"=",
"array_merge",
"(",
"$",
"options",
"[",
"'conditions'",
"]",
",",
"array",
"(",
"$",
"Model",
"->",
"primaryKey",
"=>",
"$",
"Model",
"->",
"id",
")",
")",
";",
"}",
"else",
"{",
"$",
"conditions",
"=",
"array",
"(",
"$",
"Model",
"->",
"primaryKey",
"=>",
"$",
"Model",
"->",
"id",
")",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"fromVersionId",
")",
"||",
"is_numeric",
"(",
"$",
"toVersionId",
")",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"fromVersionId",
")",
"&&",
"is_numeric",
"(",
"$",
"toVersionId",
")",
")",
"{",
"$",
"conditions",
"[",
"'version_id'",
"]",
"=",
"array",
"(",
"$",
"fromVersionId",
",",
"$",
"toVersionId",
")",
";",
"if",
"(",
"$",
"Model",
"->",
"ShadowModel",
"->",
"find",
"(",
"'count'",
",",
"array",
"(",
"'conditions'",
"=>",
"$",
"conditions",
")",
")",
"<",
"2",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"fromVersionId",
")",
")",
"{",
"$",
"conditions",
"[",
"'version_id'",
"]",
"=",
"$",
"fromVersionId",
";",
"}",
"else",
"{",
"$",
"conditions",
"[",
"'version_id'",
"]",
"=",
"$",
"toVersionId",
";",
"}",
"if",
"(",
"$",
"Model",
"->",
"ShadowModel",
"->",
"find",
"(",
"'count'",
",",
"array",
"(",
"'conditions'",
"=>",
"$",
"conditions",
")",
")",
"<",
"1",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"}",
"}",
"$",
"conditions",
"=",
"array",
"(",
"$",
"Model",
"->",
"primaryKey",
"=>",
"$",
"Model",
"->",
"id",
")",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"fromVersionId",
")",
")",
"{",
"$",
"conditions",
"[",
"'version_id >='",
"]",
"=",
"$",
"fromVersionId",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"toVersionId",
")",
")",
"{",
"$",
"conditions",
"[",
"'version_id <='",
"]",
"=",
"$",
"toVersionId",
";",
"}",
"$",
"options",
"[",
"'conditions'",
"]",
"=",
"$",
"conditions",
";",
"$",
"all",
"=",
"$",
"this",
"->",
"revisions",
"(",
"$",
"Model",
",",
"$",
"options",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"all",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"unified",
"=",
"array",
"(",
")",
";",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"all",
"[",
"0",
"]",
"[",
"$",
"Model",
"->",
"alias",
"]",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"field",
")",
"{",
"$",
"allValues",
"=",
"Hash",
"::",
"extract",
"(",
"$",
"all",
",",
"'{n}.'",
".",
"$",
"Model",
"->",
"alias",
".",
"'.'",
".",
"$",
"field",
")",
";",
"$",
"allValues",
"=",
"array_reverse",
"(",
"array_unique",
"(",
"array_reverse",
"(",
"$",
"allValues",
",",
"true",
")",
")",
",",
"true",
")",
";",
"if",
"(",
"sizeof",
"(",
"$",
"allValues",
")",
"==",
"1",
")",
"{",
"$",
"unified",
"[",
"$",
"field",
"]",
"=",
"reset",
"(",
"$",
"allValues",
")",
";",
"}",
"else",
"{",
"$",
"unified",
"[",
"$",
"field",
"]",
"=",
"$",
"allValues",
";",
"}",
"}",
"return",
"array",
"(",
"$",
"Model",
"->",
"alias",
"=>",
"$",
"unified",
")",
";",
"}"
] | Returns an array that maps to the Model, only with multiple values for fields that has been changed
@example $this->Post->id = 4; $changes = $this->Post->diff();
@example $this->Post->id = 4; $myChanges = $this->Post->diff(null,nul, array('conditions'=>array('user_id'=>4)));
@example $this->Post->id = 4; $difference = $this->Post->diff(45,192);
@param Object $Model
@param int $fromVersionId
@param int $toVersionId
@param array $options
@return array | [
"Returns",
"an",
"array",
"that",
"maps",
"to",
"the",
"Model",
"only",
"with",
"multiple",
"values",
"for",
"fields",
"that",
"has",
"been",
"changed"
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Model/Behavior/RevisionBehavior.php#L206-L261 |
6,378 | RitaCo/cakephp-tools-plugin | Model/Behavior/RevisionBehavior.php | RevisionBehavior._init | protected function _init(Model $Model, $page, $limit) {
$habtm = array();
$allHabtm = $Model->getAssociated('hasAndBelongsToMany');
foreach ($allHabtm as $assocAlias) {
if (isset($Model->ShadowModel->_schema[$assocAlias])) {
$habtm[] = $assocAlias;
}
}
$all = $Model->find('all', array(
'limit' => $limit,
'page' => $page,
'contain' => $habtm));
$versionCreated = date('Y-m-d H:i:s');
foreach ($all as $data) {
$Model->ShadowModel->create($data);
$Model->ShadowModel->set('version_created', $versionCreated);
$Model->ShadowModel->save();
}
} | php | protected function _init(Model $Model, $page, $limit) {
$habtm = array();
$allHabtm = $Model->getAssociated('hasAndBelongsToMany');
foreach ($allHabtm as $assocAlias) {
if (isset($Model->ShadowModel->_schema[$assocAlias])) {
$habtm[] = $assocAlias;
}
}
$all = $Model->find('all', array(
'limit' => $limit,
'page' => $page,
'contain' => $habtm));
$versionCreated = date('Y-m-d H:i:s');
foreach ($all as $data) {
$Model->ShadowModel->create($data);
$Model->ShadowModel->set('version_created', $versionCreated);
$Model->ShadowModel->save();
}
} | [
"protected",
"function",
"_init",
"(",
"Model",
"$",
"Model",
",",
"$",
"page",
",",
"$",
"limit",
")",
"{",
"$",
"habtm",
"=",
"array",
"(",
")",
";",
"$",
"allHabtm",
"=",
"$",
"Model",
"->",
"getAssociated",
"(",
"'hasAndBelongsToMany'",
")",
";",
"foreach",
"(",
"$",
"allHabtm",
"as",
"$",
"assocAlias",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"Model",
"->",
"ShadowModel",
"->",
"_schema",
"[",
"$",
"assocAlias",
"]",
")",
")",
"{",
"$",
"habtm",
"[",
"]",
"=",
"$",
"assocAlias",
";",
"}",
"}",
"$",
"all",
"=",
"$",
"Model",
"->",
"find",
"(",
"'all'",
",",
"array",
"(",
"'limit'",
"=>",
"$",
"limit",
",",
"'page'",
"=>",
"$",
"page",
",",
"'contain'",
"=>",
"$",
"habtm",
")",
")",
";",
"$",
"versionCreated",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
")",
";",
"foreach",
"(",
"$",
"all",
"as",
"$",
"data",
")",
"{",
"$",
"Model",
"->",
"ShadowModel",
"->",
"create",
"(",
"$",
"data",
")",
";",
"$",
"Model",
"->",
"ShadowModel",
"->",
"set",
"(",
"'version_created'",
",",
"$",
"versionCreated",
")",
";",
"$",
"Model",
"->",
"ShadowModel",
"->",
"save",
"(",
")",
";",
"}",
"}"
] | Saves revisions for rows matching page and limit given
@param object $Model
@param int $page
@param int $limit
@return void | [
"Saves",
"revisions",
"for",
"rows",
"matching",
"page",
"and",
"limit",
"given"
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Model/Behavior/RevisionBehavior.php#L313-L331 |
6,379 | RitaCo/cakephp-tools-plugin | Model/Behavior/RevisionBehavior.php | RevisionBehavior.newest | public function newest(Model $Model, $options = array()) {
if (!$Model->id) {
trigger_error('RevisionBehavior: Model::id must be set', E_USER_WARNING);
return array();
}
if (!$Model->ShadowModel) {
trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
return array();
}
if (isset($options['conditions'])) {
$options['conditions'] = array_merge($options['conditions'], array($Model->alias . '.' . $Model->primaryKey => $Model->id));
} else {
$options['conditions'] = array($Model->alias . '.' . $Model->primaryKey => $Model->id);
}
return $Model->ShadowModel->find('first', $options);
} | php | public function newest(Model $Model, $options = array()) {
if (!$Model->id) {
trigger_error('RevisionBehavior: Model::id must be set', E_USER_WARNING);
return array();
}
if (!$Model->ShadowModel) {
trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
return array();
}
if (isset($options['conditions'])) {
$options['conditions'] = array_merge($options['conditions'], array($Model->alias . '.' . $Model->primaryKey => $Model->id));
} else {
$options['conditions'] = array($Model->alias . '.' . $Model->primaryKey => $Model->id);
}
return $Model->ShadowModel->find('first', $options);
} | [
"public",
"function",
"newest",
"(",
"Model",
"$",
"Model",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"Model",
"->",
"id",
")",
"{",
"trigger_error",
"(",
"'RevisionBehavior: Model::id must be set'",
",",
"E_USER_WARNING",
")",
";",
"return",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"Model",
"->",
"ShadowModel",
")",
"{",
"trigger_error",
"(",
"'RevisionBehavior: ShadowModel doesnt exist.'",
",",
"E_USER_WARNING",
")",
";",
"return",
"array",
"(",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'conditions'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'conditions'",
"]",
"=",
"array_merge",
"(",
"$",
"options",
"[",
"'conditions'",
"]",
",",
"array",
"(",
"$",
"Model",
"->",
"alias",
".",
"'.'",
".",
"$",
"Model",
"->",
"primaryKey",
"=>",
"$",
"Model",
"->",
"id",
")",
")",
";",
"}",
"else",
"{",
"$",
"options",
"[",
"'conditions'",
"]",
"=",
"array",
"(",
"$",
"Model",
"->",
"alias",
".",
"'.'",
".",
"$",
"Model",
"->",
"primaryKey",
"=>",
"$",
"Model",
"->",
"id",
")",
";",
"}",
"return",
"$",
"Model",
"->",
"ShadowModel",
"->",
"find",
"(",
"'first'",
",",
"$",
"options",
")",
";",
"}"
] | Finds the newest revision, including the current one.
Use with caution, the live model may be different depending on the usage
of ignore fields.
@example $this->Post->id = 6; $newestRevision = $this->Post->newest();
@param object $Model
@param array $options
@return array | [
"Finds",
"the",
"newest",
"revision",
"including",
"the",
"current",
"one",
".",
"Use",
"with",
"caution",
"the",
"live",
"model",
"may",
"be",
"different",
"depending",
"on",
"the",
"usage",
"of",
"ignore",
"fields",
"."
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Model/Behavior/RevisionBehavior.php#L343-L359 |
6,380 | RitaCo/cakephp-tools-plugin | Model/Behavior/RevisionBehavior.php | RevisionBehavior.oldest | public function oldest(Model $Model, $options = array()) {
if (!$Model->id) {
trigger_error('RevisionBehavior: Model::id must be set', E_USER_WARNING);
return array();
}
if (!$Model->ShadowModel) {
trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
return array();
}
if (isset($options['conditions'])) {
$options['conditions'] = array_merge($options['conditions'], array($Model->primaryKey => $Model->id));
} else {
$options['conditions'] = array($Model->primaryKey => $Model->id);
}
$options['order'] = 'version_created ASC, version_id ASC';
return $Model->ShadowModel->find('first', $options);
} | php | public function oldest(Model $Model, $options = array()) {
if (!$Model->id) {
trigger_error('RevisionBehavior: Model::id must be set', E_USER_WARNING);
return array();
}
if (!$Model->ShadowModel) {
trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
return array();
}
if (isset($options['conditions'])) {
$options['conditions'] = array_merge($options['conditions'], array($Model->primaryKey => $Model->id));
} else {
$options['conditions'] = array($Model->primaryKey => $Model->id);
}
$options['order'] = 'version_created ASC, version_id ASC';
return $Model->ShadowModel->find('first', $options);
} | [
"public",
"function",
"oldest",
"(",
"Model",
"$",
"Model",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"Model",
"->",
"id",
")",
"{",
"trigger_error",
"(",
"'RevisionBehavior: Model::id must be set'",
",",
"E_USER_WARNING",
")",
";",
"return",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"Model",
"->",
"ShadowModel",
")",
"{",
"trigger_error",
"(",
"'RevisionBehavior: ShadowModel doesnt exist.'",
",",
"E_USER_WARNING",
")",
";",
"return",
"array",
"(",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'conditions'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'conditions'",
"]",
"=",
"array_merge",
"(",
"$",
"options",
"[",
"'conditions'",
"]",
",",
"array",
"(",
"$",
"Model",
"->",
"primaryKey",
"=>",
"$",
"Model",
"->",
"id",
")",
")",
";",
"}",
"else",
"{",
"$",
"options",
"[",
"'conditions'",
"]",
"=",
"array",
"(",
"$",
"Model",
"->",
"primaryKey",
"=>",
"$",
"Model",
"->",
"id",
")",
";",
"}",
"$",
"options",
"[",
"'order'",
"]",
"=",
"'version_created ASC, version_id ASC'",
";",
"return",
"$",
"Model",
"->",
"ShadowModel",
"->",
"find",
"(",
"'first'",
",",
"$",
"options",
")",
";",
"}"
] | Find the oldest revision for the current Model->id
If no limit is used on revision and revision has been enabled for the model
since start, this call will return the original first record.
@example $this->Post->id = 2; $original = $this->Post->oldest();
@param object $Model
@param array $options
@return array | [
"Find",
"the",
"oldest",
"revision",
"for",
"the",
"current",
"Model",
"-",
">",
"id",
"If",
"no",
"limit",
"is",
"used",
"on",
"revision",
"and",
"revision",
"has",
"been",
"enabled",
"for",
"the",
"model",
"since",
"start",
"this",
"call",
"will",
"return",
"the",
"original",
"first",
"record",
"."
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Model/Behavior/RevisionBehavior.php#L371-L387 |
6,381 | RitaCo/cakephp-tools-plugin | Model/Behavior/RevisionBehavior.php | RevisionBehavior.previous | public function previous(Model $Model, $options = array()) {
if (!$Model->id) {
trigger_error('RevisionBehavior: Model::id must be set', E_USER_WARNING);
return array();
}
if (!$Model->ShadowModel) {
trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
return array();
}
$options['limit'] = 1;
$options['page'] = 2;
if (isset($options['conditions'])) {
$options['conditions'] = array_merge($options['conditions'], array($Model->primaryKey => $Model->id));
} else {
$options['conditions'] = array($Model->primaryKey => $Model->id);
}
$revisions = $Model->ShadowModel->find('all', $options);
if (!$revisions) {
return array();
}
return $revisions[0];
} | php | public function previous(Model $Model, $options = array()) {
if (!$Model->id) {
trigger_error('RevisionBehavior: Model::id must be set', E_USER_WARNING);
return array();
}
if (!$Model->ShadowModel) {
trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
return array();
}
$options['limit'] = 1;
$options['page'] = 2;
if (isset($options['conditions'])) {
$options['conditions'] = array_merge($options['conditions'], array($Model->primaryKey => $Model->id));
} else {
$options['conditions'] = array($Model->primaryKey => $Model->id);
}
$revisions = $Model->ShadowModel->find('all', $options);
if (!$revisions) {
return array();
}
return $revisions[0];
} | [
"public",
"function",
"previous",
"(",
"Model",
"$",
"Model",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"Model",
"->",
"id",
")",
"{",
"trigger_error",
"(",
"'RevisionBehavior: Model::id must be set'",
",",
"E_USER_WARNING",
")",
";",
"return",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"Model",
"->",
"ShadowModel",
")",
"{",
"trigger_error",
"(",
"'RevisionBehavior: ShadowModel doesnt exist.'",
",",
"E_USER_WARNING",
")",
";",
"return",
"array",
"(",
")",
";",
"}",
"$",
"options",
"[",
"'limit'",
"]",
"=",
"1",
";",
"$",
"options",
"[",
"'page'",
"]",
"=",
"2",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'conditions'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'conditions'",
"]",
"=",
"array_merge",
"(",
"$",
"options",
"[",
"'conditions'",
"]",
",",
"array",
"(",
"$",
"Model",
"->",
"primaryKey",
"=>",
"$",
"Model",
"->",
"id",
")",
")",
";",
"}",
"else",
"{",
"$",
"options",
"[",
"'conditions'",
"]",
"=",
"array",
"(",
"$",
"Model",
"->",
"primaryKey",
"=>",
"$",
"Model",
"->",
"id",
")",
";",
"}",
"$",
"revisions",
"=",
"$",
"Model",
"->",
"ShadowModel",
"->",
"find",
"(",
"'all'",
",",
"$",
"options",
")",
";",
"if",
"(",
"!",
"$",
"revisions",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"return",
"$",
"revisions",
"[",
"0",
"]",
";",
"}"
] | Find the second newest revisions, including the current one.
@example $this->Post->id = 6; $undoRevision = $this->Post->previous();
@param object $Model
@param array $options
@return array | [
"Find",
"the",
"second",
"newest",
"revisions",
"including",
"the",
"current",
"one",
"."
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Model/Behavior/RevisionBehavior.php#L397-L418 |
6,382 | RitaCo/cakephp-tools-plugin | Model/Behavior/RevisionBehavior.php | RevisionBehavior.revertAll | public function revertAll(Model $Model, $options = array()) {
if (!$Model->ShadowModel) {
trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
return false;
}
if (empty($options) || !isset($options['date'])) {
return false;
}
if (!isset($options['conditions'])) {
$options['conditions'] = array();
}
// leave model rows out side of condtions alone
// leave model rows not edited since date alone
$all = $Model->find('all', array('conditions' => $options['conditions'], 'fields' => $Model->primaryKey));
$allIds = Hash::extract($all, '{n}.' . $Model->alias . '.' . $Model->primaryKey);
$cond = $options['conditions'];
$cond['version_created <'] = $options['date'];
$createdBeforeDate = $Model->ShadowModel->find('all', array(
'order' => $Model->primaryKey,
'conditions' => $cond,
'fields' => array('version_id', $Model->primaryKey)));
$createdBeforeDateIds = Hash::extract($createdBeforeDate, '{n}.' . $Model->alias . '.' . $Model->primaryKey);
$deleteIds = array_diff($allIds, $createdBeforeDateIds);
// delete all Model rows where there are only version_created later than date
$Model->deleteAll(array($Model->alias . '.' . $Model->primaryKey => $deleteIds), false, true);
unset($cond['version_created <']);
$cond['version_created >='] = $options['date'];
$createdAfterDate = $Model->ShadowModel->find('all', array(
'order' => $Model->primaryKey,
'conditions' => $cond,
'fields' => array('version_id', $Model->primaryKey)));
$createdAfterDateIds = Hash::extract($createdAfterDate, '{n}.' . $Model->alias . '.' . $Model->primaryKey);
$updateIds = array_diff($createdAfterDateIds, $deleteIds);
$revertSuccess = true;
// update model rows that have version_created earlier than date to latest before date
foreach ($updateIds as $mid) {
$Model->id = $mid;
if (!$Model->revertToDate($options['date'])) {
$revertSuccess = false;
}
}
return $revertSuccess;
} | php | public function revertAll(Model $Model, $options = array()) {
if (!$Model->ShadowModel) {
trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
return false;
}
if (empty($options) || !isset($options['date'])) {
return false;
}
if (!isset($options['conditions'])) {
$options['conditions'] = array();
}
// leave model rows out side of condtions alone
// leave model rows not edited since date alone
$all = $Model->find('all', array('conditions' => $options['conditions'], 'fields' => $Model->primaryKey));
$allIds = Hash::extract($all, '{n}.' . $Model->alias . '.' . $Model->primaryKey);
$cond = $options['conditions'];
$cond['version_created <'] = $options['date'];
$createdBeforeDate = $Model->ShadowModel->find('all', array(
'order' => $Model->primaryKey,
'conditions' => $cond,
'fields' => array('version_id', $Model->primaryKey)));
$createdBeforeDateIds = Hash::extract($createdBeforeDate, '{n}.' . $Model->alias . '.' . $Model->primaryKey);
$deleteIds = array_diff($allIds, $createdBeforeDateIds);
// delete all Model rows where there are only version_created later than date
$Model->deleteAll(array($Model->alias . '.' . $Model->primaryKey => $deleteIds), false, true);
unset($cond['version_created <']);
$cond['version_created >='] = $options['date'];
$createdAfterDate = $Model->ShadowModel->find('all', array(
'order' => $Model->primaryKey,
'conditions' => $cond,
'fields' => array('version_id', $Model->primaryKey)));
$createdAfterDateIds = Hash::extract($createdAfterDate, '{n}.' . $Model->alias . '.' . $Model->primaryKey);
$updateIds = array_diff($createdAfterDateIds, $deleteIds);
$revertSuccess = true;
// update model rows that have version_created earlier than date to latest before date
foreach ($updateIds as $mid) {
$Model->id = $mid;
if (!$Model->revertToDate($options['date'])) {
$revertSuccess = false;
}
}
return $revertSuccess;
} | [
"public",
"function",
"revertAll",
"(",
"Model",
"$",
"Model",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"Model",
"->",
"ShadowModel",
")",
"{",
"trigger_error",
"(",
"'RevisionBehavior: ShadowModel doesnt exist.'",
",",
"E_USER_WARNING",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"options",
")",
"||",
"!",
"isset",
"(",
"$",
"options",
"[",
"'date'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'conditions'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'conditions'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"// leave model rows out side of condtions alone",
"// leave model rows not edited since date alone",
"$",
"all",
"=",
"$",
"Model",
"->",
"find",
"(",
"'all'",
",",
"array",
"(",
"'conditions'",
"=>",
"$",
"options",
"[",
"'conditions'",
"]",
",",
"'fields'",
"=>",
"$",
"Model",
"->",
"primaryKey",
")",
")",
";",
"$",
"allIds",
"=",
"Hash",
"::",
"extract",
"(",
"$",
"all",
",",
"'{n}.'",
".",
"$",
"Model",
"->",
"alias",
".",
"'.'",
".",
"$",
"Model",
"->",
"primaryKey",
")",
";",
"$",
"cond",
"=",
"$",
"options",
"[",
"'conditions'",
"]",
";",
"$",
"cond",
"[",
"'version_created <'",
"]",
"=",
"$",
"options",
"[",
"'date'",
"]",
";",
"$",
"createdBeforeDate",
"=",
"$",
"Model",
"->",
"ShadowModel",
"->",
"find",
"(",
"'all'",
",",
"array",
"(",
"'order'",
"=>",
"$",
"Model",
"->",
"primaryKey",
",",
"'conditions'",
"=>",
"$",
"cond",
",",
"'fields'",
"=>",
"array",
"(",
"'version_id'",
",",
"$",
"Model",
"->",
"primaryKey",
")",
")",
")",
";",
"$",
"createdBeforeDateIds",
"=",
"Hash",
"::",
"extract",
"(",
"$",
"createdBeforeDate",
",",
"'{n}.'",
".",
"$",
"Model",
"->",
"alias",
".",
"'.'",
".",
"$",
"Model",
"->",
"primaryKey",
")",
";",
"$",
"deleteIds",
"=",
"array_diff",
"(",
"$",
"allIds",
",",
"$",
"createdBeforeDateIds",
")",
";",
"// delete all Model rows where there are only version_created later than date",
"$",
"Model",
"->",
"deleteAll",
"(",
"array",
"(",
"$",
"Model",
"->",
"alias",
".",
"'.'",
".",
"$",
"Model",
"->",
"primaryKey",
"=>",
"$",
"deleteIds",
")",
",",
"false",
",",
"true",
")",
";",
"unset",
"(",
"$",
"cond",
"[",
"'version_created <'",
"]",
")",
";",
"$",
"cond",
"[",
"'version_created >='",
"]",
"=",
"$",
"options",
"[",
"'date'",
"]",
";",
"$",
"createdAfterDate",
"=",
"$",
"Model",
"->",
"ShadowModel",
"->",
"find",
"(",
"'all'",
",",
"array",
"(",
"'order'",
"=>",
"$",
"Model",
"->",
"primaryKey",
",",
"'conditions'",
"=>",
"$",
"cond",
",",
"'fields'",
"=>",
"array",
"(",
"'version_id'",
",",
"$",
"Model",
"->",
"primaryKey",
")",
")",
")",
";",
"$",
"createdAfterDateIds",
"=",
"Hash",
"::",
"extract",
"(",
"$",
"createdAfterDate",
",",
"'{n}.'",
".",
"$",
"Model",
"->",
"alias",
".",
"'.'",
".",
"$",
"Model",
"->",
"primaryKey",
")",
";",
"$",
"updateIds",
"=",
"array_diff",
"(",
"$",
"createdAfterDateIds",
",",
"$",
"deleteIds",
")",
";",
"$",
"revertSuccess",
"=",
"true",
";",
"// update model rows that have version_created earlier than date to latest before date",
"foreach",
"(",
"$",
"updateIds",
"as",
"$",
"mid",
")",
"{",
"$",
"Model",
"->",
"id",
"=",
"$",
"mid",
";",
"if",
"(",
"!",
"$",
"Model",
"->",
"revertToDate",
"(",
"$",
"options",
"[",
"'date'",
"]",
")",
")",
"{",
"$",
"revertSuccess",
"=",
"false",
";",
"}",
"}",
"return",
"$",
"revertSuccess",
";",
"}"
] | Revert all rows matching conditions to given date.
Model rows outside condition or not edited will not be affected. Edits since date
will be reverted and rows created since date deleted.
@param object $Model
@param array $options 'conditions','date'
@return bool Success | [
"Revert",
"all",
"rows",
"matching",
"conditions",
"to",
"given",
"date",
".",
"Model",
"rows",
"outside",
"condition",
"or",
"not",
"edited",
"will",
"not",
"be",
"affected",
".",
"Edits",
"since",
"date",
"will",
"be",
"reverted",
"and",
"rows",
"created",
"since",
"date",
"deleted",
"."
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Model/Behavior/RevisionBehavior.php#L429-L477 |
6,383 | RitaCo/cakephp-tools-plugin | Model/Behavior/RevisionBehavior.php | RevisionBehavior.revertTo | public function revertTo(Model $Model, $versionId) {
if (!$Model->id) {
trigger_error('RevisionBehavior: Model::id must be set', E_USER_WARNING);
return false;
}
if (!$Model->ShadowModel) {
trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
return false;
}
$data = $Model->ShadowModel->find('first', array('conditions' => array('version_id' => $versionId)));
if (!$data) {
return false;
}
foreach ($Model->getAssociated('hasAndBelongsToMany') as $assocAlias) {
if (isset($Model->ShadowModel->_schema[$assocAlias])) {
$data[$assocAlias][$assocAlias] = explode(',', $data[$Model->alias][$assocAlias]);
}
}
return (bool)$Model->save($data);
} | php | public function revertTo(Model $Model, $versionId) {
if (!$Model->id) {
trigger_error('RevisionBehavior: Model::id must be set', E_USER_WARNING);
return false;
}
if (!$Model->ShadowModel) {
trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
return false;
}
$data = $Model->ShadowModel->find('first', array('conditions' => array('version_id' => $versionId)));
if (!$data) {
return false;
}
foreach ($Model->getAssociated('hasAndBelongsToMany') as $assocAlias) {
if (isset($Model->ShadowModel->_schema[$assocAlias])) {
$data[$assocAlias][$assocAlias] = explode(',', $data[$Model->alias][$assocAlias]);
}
}
return (bool)$Model->save($data);
} | [
"public",
"function",
"revertTo",
"(",
"Model",
"$",
"Model",
",",
"$",
"versionId",
")",
"{",
"if",
"(",
"!",
"$",
"Model",
"->",
"id",
")",
"{",
"trigger_error",
"(",
"'RevisionBehavior: Model::id must be set'",
",",
"E_USER_WARNING",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"Model",
"->",
"ShadowModel",
")",
"{",
"trigger_error",
"(",
"'RevisionBehavior: ShadowModel doesnt exist.'",
",",
"E_USER_WARNING",
")",
";",
"return",
"false",
";",
"}",
"$",
"data",
"=",
"$",
"Model",
"->",
"ShadowModel",
"->",
"find",
"(",
"'first'",
",",
"array",
"(",
"'conditions'",
"=>",
"array",
"(",
"'version_id'",
"=>",
"$",
"versionId",
")",
")",
")",
";",
"if",
"(",
"!",
"$",
"data",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"Model",
"->",
"getAssociated",
"(",
"'hasAndBelongsToMany'",
")",
"as",
"$",
"assocAlias",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"Model",
"->",
"ShadowModel",
"->",
"_schema",
"[",
"$",
"assocAlias",
"]",
")",
")",
"{",
"$",
"data",
"[",
"$",
"assocAlias",
"]",
"[",
"$",
"assocAlias",
"]",
"=",
"explode",
"(",
"','",
",",
"$",
"data",
"[",
"$",
"Model",
"->",
"alias",
"]",
"[",
"$",
"assocAlias",
"]",
")",
";",
"}",
"}",
"return",
"(",
"bool",
")",
"$",
"Model",
"->",
"save",
"(",
"$",
"data",
")",
";",
"}"
] | Revert current Model->id to the given revision id
Will return false if version id is invalid or save fails
@example $this->Post->id = 3; $this->Post->revertTo(12);
@param object $Model
@param int $versionId
@return bool Success | [
"Revert",
"current",
"Model",
"-",
">",
"id",
"to",
"the",
"given",
"revision",
"id",
"Will",
"return",
"false",
"if",
"version",
"id",
"is",
"invalid",
"or",
"save",
"fails"
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Model/Behavior/RevisionBehavior.php#L488-L507 |
6,384 | RitaCo/cakephp-tools-plugin | Model/Behavior/RevisionBehavior.php | RevisionBehavior.undo | public function undo(Model $Model) {
if (!$Model->id) {
trigger_error('RevisionBehavior: Model::id must be set', E_USER_WARNING);
return null;
}
if (!$Model->ShadowModel) {
trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
return false;
}
$data = $this->previous($Model);
if (!$data) {
$Model->logableAction['Revision'] = 'undo add';
$Model->delete($Model->id);
return false;
}
foreach ($Model->getAssociated('hasAndBelongsToMany') as $assocAlias) {
if (isset($Model->ShadowModel->_schema[$assocAlias])) {
$data[$assocAlias][$assocAlias] = explode(',', $data[$Model->alias][$assocAlias]);
}
}
$Model->logableAction['Revision'] = 'undo changes';
return (bool)$Model->save($data);
} | php | public function undo(Model $Model) {
if (!$Model->id) {
trigger_error('RevisionBehavior: Model::id must be set', E_USER_WARNING);
return null;
}
if (!$Model->ShadowModel) {
trigger_error('RevisionBehavior: ShadowModel doesnt exist.', E_USER_WARNING);
return false;
}
$data = $this->previous($Model);
if (!$data) {
$Model->logableAction['Revision'] = 'undo add';
$Model->delete($Model->id);
return false;
}
foreach ($Model->getAssociated('hasAndBelongsToMany') as $assocAlias) {
if (isset($Model->ShadowModel->_schema[$assocAlias])) {
$data[$assocAlias][$assocAlias] = explode(',', $data[$Model->alias][$assocAlias]);
}
}
$Model->logableAction['Revision'] = 'undo changes';
return (bool)$Model->save($data);
} | [
"public",
"function",
"undo",
"(",
"Model",
"$",
"Model",
")",
"{",
"if",
"(",
"!",
"$",
"Model",
"->",
"id",
")",
"{",
"trigger_error",
"(",
"'RevisionBehavior: Model::id must be set'",
",",
"E_USER_WARNING",
")",
";",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"Model",
"->",
"ShadowModel",
")",
"{",
"trigger_error",
"(",
"'RevisionBehavior: ShadowModel doesnt exist.'",
",",
"E_USER_WARNING",
")",
";",
"return",
"false",
";",
"}",
"$",
"data",
"=",
"$",
"this",
"->",
"previous",
"(",
"$",
"Model",
")",
";",
"if",
"(",
"!",
"$",
"data",
")",
"{",
"$",
"Model",
"->",
"logableAction",
"[",
"'Revision'",
"]",
"=",
"'undo add'",
";",
"$",
"Model",
"->",
"delete",
"(",
"$",
"Model",
"->",
"id",
")",
";",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"Model",
"->",
"getAssociated",
"(",
"'hasAndBelongsToMany'",
")",
"as",
"$",
"assocAlias",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"Model",
"->",
"ShadowModel",
"->",
"_schema",
"[",
"$",
"assocAlias",
"]",
")",
")",
"{",
"$",
"data",
"[",
"$",
"assocAlias",
"]",
"[",
"$",
"assocAlias",
"]",
"=",
"explode",
"(",
"','",
",",
"$",
"data",
"[",
"$",
"Model",
"->",
"alias",
"]",
"[",
"$",
"assocAlias",
"]",
")",
";",
"}",
"}",
"$",
"Model",
"->",
"logableAction",
"[",
"'Revision'",
"]",
"=",
"'undo changes'",
";",
"return",
"(",
"bool",
")",
"$",
"Model",
"->",
"save",
"(",
"$",
"data",
")",
";",
"}"
] | Update to previous revision
@example $this->Post->id = 2; $this->Post->undo();
@param object $Model
@return bool Success | [
"Update",
"to",
"previous",
"revision"
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Model/Behavior/RevisionBehavior.php#L731-L753 |
6,385 | RitaCo/cakephp-tools-plugin | Model/Behavior/RevisionBehavior.php | RevisionBehavior.afterDelete | public function afterDelete(Model $Model) {
if ($this->settings[$Model->alias]['auto'] === false) {
return;
}
if (!$Model->ShadowModel) {
return;
}
if (isset($this->deleteUpdates[$Model->alias]) && !empty($this->deleteUpdates[$Model->alias])) {
foreach ($this->deleteUpdates[$Model->alias] as $assocAlias => $assocIds) {
$Model->{$assocAlias}->updateRevisions($assocIds);
}
unset($this->deleteUpdates[$Model->alias]);
}
} | php | public function afterDelete(Model $Model) {
if ($this->settings[$Model->alias]['auto'] === false) {
return;
}
if (!$Model->ShadowModel) {
return;
}
if (isset($this->deleteUpdates[$Model->alias]) && !empty($this->deleteUpdates[$Model->alias])) {
foreach ($this->deleteUpdates[$Model->alias] as $assocAlias => $assocIds) {
$Model->{$assocAlias}->updateRevisions($assocIds);
}
unset($this->deleteUpdates[$Model->alias]);
}
} | [
"public",
"function",
"afterDelete",
"(",
"Model",
"$",
"Model",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"settings",
"[",
"$",
"Model",
"->",
"alias",
"]",
"[",
"'auto'",
"]",
"===",
"false",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"Model",
"->",
"ShadowModel",
")",
"{",
"return",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"deleteUpdates",
"[",
"$",
"Model",
"->",
"alias",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"deleteUpdates",
"[",
"$",
"Model",
"->",
"alias",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"deleteUpdates",
"[",
"$",
"Model",
"->",
"alias",
"]",
"as",
"$",
"assocAlias",
"=>",
"$",
"assocIds",
")",
"{",
"$",
"Model",
"->",
"{",
"$",
"assocAlias",
"}",
"->",
"updateRevisions",
"(",
"$",
"assocIds",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"deleteUpdates",
"[",
"$",
"Model",
"->",
"alias",
"]",
")",
";",
"}",
"}"
] | Causes revision for habtm associated models if that model does version control
on their relationship. BeforeDelete identifies the related models that will need
to do the revision update in afterDelete. Uses
@param unknown_type $Model
@return void | [
"Causes",
"revision",
"for",
"habtm",
"associated",
"models",
"if",
"that",
"model",
"does",
"version",
"control",
"on",
"their",
"relationship",
".",
"BeforeDelete",
"identifies",
"the",
"related",
"models",
"that",
"will",
"need",
"to",
"do",
"the",
"revision",
"update",
"in",
"afterDelete",
".",
"Uses"
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Model/Behavior/RevisionBehavior.php#L782-L795 |
6,386 | RitaCo/cakephp-tools-plugin | Model/Behavior/RevisionBehavior.php | RevisionBehavior.beforeDelete | public function beforeDelete(Model $Model, $cascade = true) {
if ($this->settings[$Model->alias]['auto'] === false) {
return true;
}
if (!$Model->ShadowModel) {
return true;
}
foreach ($Model->hasAndBelongsToMany as $assocAlias => $a) {
if (isset($Model->{$assocAlias}->ShadowModel->_schema[$Model->alias])) {
$joins = $Model->{$a['with']}->find('all', array('recursive' => -1, 'conditions' => array($a['foreignKey'] => $Model->
id)));
$this->deleteUpdates[$Model->alias][$assocAlias] = Hash::extract($joins, '{n}.' . $a['with'] . '.' . $a['associationForeignKey']);
}
}
return true;
} | php | public function beforeDelete(Model $Model, $cascade = true) {
if ($this->settings[$Model->alias]['auto'] === false) {
return true;
}
if (!$Model->ShadowModel) {
return true;
}
foreach ($Model->hasAndBelongsToMany as $assocAlias => $a) {
if (isset($Model->{$assocAlias}->ShadowModel->_schema[$Model->alias])) {
$joins = $Model->{$a['with']}->find('all', array('recursive' => -1, 'conditions' => array($a['foreignKey'] => $Model->
id)));
$this->deleteUpdates[$Model->alias][$assocAlias] = Hash::extract($joins, '{n}.' . $a['with'] . '.' . $a['associationForeignKey']);
}
}
return true;
} | [
"public",
"function",
"beforeDelete",
"(",
"Model",
"$",
"Model",
",",
"$",
"cascade",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"settings",
"[",
"$",
"Model",
"->",
"alias",
"]",
"[",
"'auto'",
"]",
"===",
"false",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"$",
"Model",
"->",
"ShadowModel",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"$",
"Model",
"->",
"hasAndBelongsToMany",
"as",
"$",
"assocAlias",
"=>",
"$",
"a",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"Model",
"->",
"{",
"$",
"assocAlias",
"}",
"->",
"ShadowModel",
"->",
"_schema",
"[",
"$",
"Model",
"->",
"alias",
"]",
")",
")",
"{",
"$",
"joins",
"=",
"$",
"Model",
"->",
"{",
"$",
"a",
"[",
"'with'",
"]",
"}",
"->",
"find",
"(",
"'all'",
",",
"array",
"(",
"'recursive'",
"=>",
"-",
"1",
",",
"'conditions'",
"=>",
"array",
"(",
"$",
"a",
"[",
"'foreignKey'",
"]",
"=>",
"$",
"Model",
"->",
"id",
")",
")",
")",
";",
"$",
"this",
"->",
"deleteUpdates",
"[",
"$",
"Model",
"->",
"alias",
"]",
"[",
"$",
"assocAlias",
"]",
"=",
"Hash",
"::",
"extract",
"(",
"$",
"joins",
",",
"'{n}.'",
".",
"$",
"a",
"[",
"'with'",
"]",
".",
"'.'",
".",
"$",
"a",
"[",
"'associationForeignKey'",
"]",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Causes revision for habtm associated models if that model does version control
on their relationship. BeforeDelete identifies the related models that will need
to do the revision update in afterDelete.
@param object $Model
@return bool Success | [
"Causes",
"revision",
"for",
"habtm",
"associated",
"models",
"if",
"that",
"model",
"does",
"version",
"control",
"on",
"their",
"relationship",
".",
"BeforeDelete",
"identifies",
"the",
"related",
"models",
"that",
"will",
"need",
"to",
"do",
"the",
"revision",
"update",
"in",
"afterDelete",
"."
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Model/Behavior/RevisionBehavior.php#L899-L914 |
6,387 | RitaCo/cakephp-tools-plugin | Model/Behavior/RevisionBehavior.php | RevisionBehavior.beforeSave | public function beforeSave(Model $Model, $options = array()) {
if ($this->settings[$Model->alias]['auto'] === false) {
return true;
}
if (!$Model->ShadowModel) {
return true;
}
$Model->ShadowModel->create();
if (!isset($Model->data[$Model->alias][$Model->primaryKey]) && !$Model->id) {
return true;
}
$habtm = array();
foreach ($Model->getAssociated('hasAndBelongsToMany') as $assocAlias) {
if (isset($Model->ShadowModel->_schema[$assocAlias])) {
$habtm[] = $assocAlias;
}
}
$this->_oldData[$Model->alias] = $Model->find('first', array(
'contain' => $habtm, 'conditions' => array($Model->alias . '.' . $Model->primaryKey => $Model->id)));
return true;
} | php | public function beforeSave(Model $Model, $options = array()) {
if ($this->settings[$Model->alias]['auto'] === false) {
return true;
}
if (!$Model->ShadowModel) {
return true;
}
$Model->ShadowModel->create();
if (!isset($Model->data[$Model->alias][$Model->primaryKey]) && !$Model->id) {
return true;
}
$habtm = array();
foreach ($Model->getAssociated('hasAndBelongsToMany') as $assocAlias) {
if (isset($Model->ShadowModel->_schema[$assocAlias])) {
$habtm[] = $assocAlias;
}
}
$this->_oldData[$Model->alias] = $Model->find('first', array(
'contain' => $habtm, 'conditions' => array($Model->alias . '.' . $Model->primaryKey => $Model->id)));
return true;
} | [
"public",
"function",
"beforeSave",
"(",
"Model",
"$",
"Model",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"settings",
"[",
"$",
"Model",
"->",
"alias",
"]",
"[",
"'auto'",
"]",
"===",
"false",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"$",
"Model",
"->",
"ShadowModel",
")",
"{",
"return",
"true",
";",
"}",
"$",
"Model",
"->",
"ShadowModel",
"->",
"create",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"Model",
"->",
"data",
"[",
"$",
"Model",
"->",
"alias",
"]",
"[",
"$",
"Model",
"->",
"primaryKey",
"]",
")",
"&&",
"!",
"$",
"Model",
"->",
"id",
")",
"{",
"return",
"true",
";",
"}",
"$",
"habtm",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"Model",
"->",
"getAssociated",
"(",
"'hasAndBelongsToMany'",
")",
"as",
"$",
"assocAlias",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"Model",
"->",
"ShadowModel",
"->",
"_schema",
"[",
"$",
"assocAlias",
"]",
")",
")",
"{",
"$",
"habtm",
"[",
"]",
"=",
"$",
"assocAlias",
";",
"}",
"}",
"$",
"this",
"->",
"_oldData",
"[",
"$",
"Model",
"->",
"alias",
"]",
"=",
"$",
"Model",
"->",
"find",
"(",
"'first'",
",",
"array",
"(",
"'contain'",
"=>",
"$",
"habtm",
",",
"'conditions'",
"=>",
"array",
"(",
"$",
"Model",
"->",
"alias",
".",
"'.'",
".",
"$",
"Model",
"->",
"primaryKey",
"=>",
"$",
"Model",
"->",
"id",
")",
")",
")",
";",
"return",
"true",
";",
"}"
] | Revision uses the beforeSave callback to remember the old data for comparison in afterSave
@param object $Model
@return bool Success | [
"Revision",
"uses",
"the",
"beforeSave",
"callback",
"to",
"remember",
"the",
"old",
"data",
"for",
"comparison",
"in",
"afterSave"
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Model/Behavior/RevisionBehavior.php#L922-L944 |
6,388 | mooti/framework | src/ServiceProvider/ServiceProvider.php | ServiceProvider.getServices | public function getServices()
{
return [
self::INFLECTOR => function () { return Inflector::get('en');},
self::APPLICATION_RUNTIME => function () { return new ApplicationRuntime();},
self::CONFIG_FACTORY => function () { return new ConfigFactory();}
];
} | php | public function getServices()
{
return [
self::INFLECTOR => function () { return Inflector::get('en');},
self::APPLICATION_RUNTIME => function () { return new ApplicationRuntime();},
self::CONFIG_FACTORY => function () { return new ConfigFactory();}
];
} | [
"public",
"function",
"getServices",
"(",
")",
"{",
"return",
"[",
"self",
"::",
"INFLECTOR",
"=>",
"function",
"(",
")",
"{",
"return",
"Inflector",
"::",
"get",
"(",
"'en'",
")",
";",
"}",
",",
"self",
"::",
"APPLICATION_RUNTIME",
"=>",
"function",
"(",
")",
"{",
"return",
"new",
"ApplicationRuntime",
"(",
")",
";",
"}",
",",
"self",
"::",
"CONFIG_FACTORY",
"=>",
"function",
"(",
")",
"{",
"return",
"new",
"ConfigFactory",
"(",
")",
";",
"}",
"]",
";",
"}"
] | Get the details of the services we are providing
@return array | [
"Get",
"the",
"details",
"of",
"the",
"services",
"we",
"are",
"providing"
] | 078da6699c5c6c7ac4e5a3d36751d645ad8aa93e | https://github.com/mooti/framework/blob/078da6699c5c6c7ac4e5a3d36751d645ad8aa93e/src/ServiceProvider/ServiceProvider.php#L20-L27 |
6,389 | nattreid/form | src/Rules.php | Rules.validateImage | public static function validateImage(UploadControl $control)
{
/* @var $file FileUpload */
$file = $control->getValue();
if (!in_array($file->getContentType(), ['image/gif', 'image/png', 'image/jpeg', 'image/svg+xml'], true)) {
return false;
}
return true;
} | php | public static function validateImage(UploadControl $control)
{
/* @var $file FileUpload */
$file = $control->getValue();
if (!in_array($file->getContentType(), ['image/gif', 'image/png', 'image/jpeg', 'image/svg+xml'], true)) {
return false;
}
return true;
} | [
"public",
"static",
"function",
"validateImage",
"(",
"UploadControl",
"$",
"control",
")",
"{",
"/* @var $file FileUpload */",
"$",
"file",
"=",
"$",
"control",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"file",
"->",
"getContentType",
"(",
")",
",",
"[",
"'image/gif'",
",",
"'image/png'",
",",
"'image/jpeg'",
",",
"'image/svg+xml'",
"]",
",",
"true",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Validace obrazku + svg
@param IControl $control
@return bool | [
"Validace",
"obrazku",
"+",
"svg"
] | d8b447f77e2374832e4c52520767847497a2033e | https://github.com/nattreid/form/blob/d8b447f77e2374832e4c52520767847497a2033e/src/Rules.php#L38-L47 |
6,390 | Ocelot-Framework/ocelot-mvc | src/Beans/BeanUtils.php | BeanUtils.beansOfType | public static function beansOfType(ApplicationInterface $applicationContext, $class)
{
/**
* @var $objectManager ObjectManagerInterface
*/
$objectManager = $applicationContext->search("ObjectManagerInterface");
$initialContext = new InitialContext();
$initialContext->injectApplication($applicationContext);
$beans = array();
foreach ($objectManager->getObjectDescriptors() as $descriptor) {
if ($descriptor instanceof ComponentDescriptorInterface) {
if (is_subclass_of($descriptor->getClassName(), $class)) {
$beans[$descriptor->getName()] = $initialContext->lookup($descriptor->getName());
}
}
}
return $beans;
} | php | public static function beansOfType(ApplicationInterface $applicationContext, $class)
{
/**
* @var $objectManager ObjectManagerInterface
*/
$objectManager = $applicationContext->search("ObjectManagerInterface");
$initialContext = new InitialContext();
$initialContext->injectApplication($applicationContext);
$beans = array();
foreach ($objectManager->getObjectDescriptors() as $descriptor) {
if ($descriptor instanceof ComponentDescriptorInterface) {
if (is_subclass_of($descriptor->getClassName(), $class)) {
$beans[$descriptor->getName()] = $initialContext->lookup($descriptor->getName());
}
}
}
return $beans;
} | [
"public",
"static",
"function",
"beansOfType",
"(",
"ApplicationInterface",
"$",
"applicationContext",
",",
"$",
"class",
")",
"{",
"/**\n * @var $objectManager ObjectManagerInterface\n */",
"$",
"objectManager",
"=",
"$",
"applicationContext",
"->",
"search",
"(",
"\"ObjectManagerInterface\"",
")",
";",
"$",
"initialContext",
"=",
"new",
"InitialContext",
"(",
")",
";",
"$",
"initialContext",
"->",
"injectApplication",
"(",
"$",
"applicationContext",
")",
";",
"$",
"beans",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"objectManager",
"->",
"getObjectDescriptors",
"(",
")",
"as",
"$",
"descriptor",
")",
"{",
"if",
"(",
"$",
"descriptor",
"instanceof",
"ComponentDescriptorInterface",
")",
"{",
"if",
"(",
"is_subclass_of",
"(",
"$",
"descriptor",
"->",
"getClassName",
"(",
")",
",",
"$",
"class",
")",
")",
"{",
"$",
"beans",
"[",
"$",
"descriptor",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"initialContext",
"->",
"lookup",
"(",
"$",
"descriptor",
"->",
"getName",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"$",
"beans",
";",
"}"
] | Returns beans of a specific type
@param ApplicationInterface $applicationContext The applicationContext to search in
@param string $class The type of the beans
@return array | [
"Returns",
"beans",
"of",
"a",
"specific",
"type"
] | 42a08208c6cebb87b363a0479331bafb7ec257c6 | https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Beans/BeanUtils.php#L49-L66 |
6,391 | Thuata/FrameworkBundle | Service/ServiceFactory.php | ServiceFactory.getFactorableInstance | public function getFactorableInstance(string $factorableClassName)
{
$factorable = $this->loadFromRegistry($factorableClassName);
if (!$factorable instanceof AbstractService) {
$factorable = parent::getFactorableInstance($factorableClassName);
}
return $factorable;
} | php | public function getFactorableInstance(string $factorableClassName)
{
$factorable = $this->loadFromRegistry($factorableClassName);
if (!$factorable instanceof AbstractService) {
$factorable = parent::getFactorableInstance($factorableClassName);
}
return $factorable;
} | [
"public",
"function",
"getFactorableInstance",
"(",
"string",
"$",
"factorableClassName",
")",
"{",
"$",
"factorable",
"=",
"$",
"this",
"->",
"loadFromRegistry",
"(",
"$",
"factorableClassName",
")",
";",
"if",
"(",
"!",
"$",
"factorable",
"instanceof",
"AbstractService",
")",
"{",
"$",
"factorable",
"=",
"parent",
"::",
"getFactorableInstance",
"(",
"$",
"factorableClassName",
")",
";",
"}",
"return",
"$",
"factorable",
";",
"}"
] | Gets a service
@param string $factorableClassName
@return AbstractService | [
"Gets",
"a",
"service"
] | 78c38a5103256d829d7f7574b4e15c9087d0cfd9 | https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Service/ServiceFactory.php#L79-L88 |
6,392 | Jinxes/layton | Layton/Library/Http/Headers.php | Headers.create | public static function create(array $params = [])
{
$headers = new static();
foreach ($params as $key => $value) {
$headers->set($key, $value);
}
return $headers;
} | php | public static function create(array $params = [])
{
$headers = new static();
foreach ($params as $key => $value) {
$headers->set($key, $value);
}
return $headers;
} | [
"public",
"static",
"function",
"create",
"(",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"headers",
"=",
"new",
"static",
"(",
")",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"headers",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"headers",
";",
"}"
] | Create the default values from httpMessages array.
@param array $httpMessages
@return static | [
"Create",
"the",
"default",
"values",
"from",
"httpMessages",
"array",
"."
] | 27b8eab2c59b9887eb93e40a533eb77cc5690584 | https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Library/Http/Headers.php#L15-L22 |
6,393 | Jinxes/layton | Layton/Library/Http/Headers.php | Headers.toPreserveCase | public static function toPreserveCase($name)
{
$params = explode('-', $name);
$newName = [];
foreach ($params as $param) {
$newName[] = ucwords($param);
}
return implode('-', $newName);
} | php | public static function toPreserveCase($name)
{
$params = explode('-', $name);
$newName = [];
foreach ($params as $param) {
$newName[] = ucwords($param);
}
return implode('-', $newName);
} | [
"public",
"static",
"function",
"toPreserveCase",
"(",
"$",
"name",
")",
"{",
"$",
"params",
"=",
"explode",
"(",
"'-'",
",",
"$",
"name",
")",
";",
"$",
"newName",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"param",
")",
"{",
"$",
"newName",
"[",
"]",
"=",
"ucwords",
"(",
"$",
"param",
")",
";",
"}",
"return",
"implode",
"(",
"'-'",
",",
"$",
"newName",
")",
";",
"}"
] | Replace name to preserve case format.
@param string $name
@return string | [
"Replace",
"name",
"to",
"preserve",
"case",
"format",
"."
] | 27b8eab2c59b9887eb93e40a533eb77cc5690584 | https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Library/Http/Headers.php#L46-L54 |
6,394 | Jinxes/layton | Layton/Library/Http/Headers.php | Headers.allPreserveCase | public function allPreserveCase()
{
$fields = $this->all();
$raw = [];
foreach ($fields as $key => $field) {
$raw[static::toPreserveCase($key)] = $field;
}
return $raw;
} | php | public function allPreserveCase()
{
$fields = $this->all();
$raw = [];
foreach ($fields as $key => $field) {
$raw[static::toPreserveCase($key)] = $field;
}
return $raw;
} | [
"public",
"function",
"allPreserveCase",
"(",
")",
"{",
"$",
"fields",
"=",
"$",
"this",
"->",
"all",
"(",
")",
";",
"$",
"raw",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"key",
"=>",
"$",
"field",
")",
"{",
"$",
"raw",
"[",
"static",
"::",
"toPreserveCase",
"(",
"$",
"key",
")",
"]",
"=",
"$",
"field",
";",
"}",
"return",
"$",
"raw",
";",
"}"
] | Get all header fields with Preserve Case format.
@return array | [
"Get",
"all",
"header",
"fields",
"with",
"Preserve",
"Case",
"format",
"."
] | 27b8eab2c59b9887eb93e40a533eb77cc5690584 | https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Library/Http/Headers.php#L120-L128 |
6,395 | larawos/framework | src/Illuminate/Foundation/Console/ControllerMakeCommand.php | ControllerMakeCommand.buildRequestReplacements | protected function buildRequestReplacements()
{
$name = $this->getNameInput();
$rootNamespace = trim(
$this->laravel->getNamespace() . 'Http\Requests' . '\\' . $this->getNamespace($name),
'\\'
);
$storeRequest = $rootNamespace . '\\' . str_replace('Controller', '', class_basename($name)) . 'StoreRequest';
$updateRequest = $rootNamespace . '\\' . str_replace('Controller', '', class_basename($name)) . 'UpdateRequest';
if (! class_exists($storeRequest)) {
if ($this->confirm("A {$storeRequest} request does not exist. Do you want to generate it?", true)) {
$this->call('make:request', ['name' => $storeRequest]);
}
}
if (! class_exists($updateRequest)) {
if ($this->confirm("A {$updateRequest} request does not exist. Do you want to generate it?", true)) {
$this->call('make:request', ['name' => $updateRequest]);
}
}
return [
'DummyFullStoreRequestClass' => $storeRequest,
'DummyStoreRequestClass' => class_basename($storeRequest),
'DummyFullUpdateRequestClass' => $updateRequest,
'DummyUpdateRequestClass' => class_basename($updateRequest),
];
} | php | protected function buildRequestReplacements()
{
$name = $this->getNameInput();
$rootNamespace = trim(
$this->laravel->getNamespace() . 'Http\Requests' . '\\' . $this->getNamespace($name),
'\\'
);
$storeRequest = $rootNamespace . '\\' . str_replace('Controller', '', class_basename($name)) . 'StoreRequest';
$updateRequest = $rootNamespace . '\\' . str_replace('Controller', '', class_basename($name)) . 'UpdateRequest';
if (! class_exists($storeRequest)) {
if ($this->confirm("A {$storeRequest} request does not exist. Do you want to generate it?", true)) {
$this->call('make:request', ['name' => $storeRequest]);
}
}
if (! class_exists($updateRequest)) {
if ($this->confirm("A {$updateRequest} request does not exist. Do you want to generate it?", true)) {
$this->call('make:request', ['name' => $updateRequest]);
}
}
return [
'DummyFullStoreRequestClass' => $storeRequest,
'DummyStoreRequestClass' => class_basename($storeRequest),
'DummyFullUpdateRequestClass' => $updateRequest,
'DummyUpdateRequestClass' => class_basename($updateRequest),
];
} | [
"protected",
"function",
"buildRequestReplacements",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getNameInput",
"(",
")",
";",
"$",
"rootNamespace",
"=",
"trim",
"(",
"$",
"this",
"->",
"laravel",
"->",
"getNamespace",
"(",
")",
".",
"'Http\\Requests'",
".",
"'\\\\'",
".",
"$",
"this",
"->",
"getNamespace",
"(",
"$",
"name",
")",
",",
"'\\\\'",
")",
";",
"$",
"storeRequest",
"=",
"$",
"rootNamespace",
".",
"'\\\\'",
".",
"str_replace",
"(",
"'Controller'",
",",
"''",
",",
"class_basename",
"(",
"$",
"name",
")",
")",
".",
"'StoreRequest'",
";",
"$",
"updateRequest",
"=",
"$",
"rootNamespace",
".",
"'\\\\'",
".",
"str_replace",
"(",
"'Controller'",
",",
"''",
",",
"class_basename",
"(",
"$",
"name",
")",
")",
".",
"'UpdateRequest'",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"storeRequest",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"confirm",
"(",
"\"A {$storeRequest} request does not exist. Do you want to generate it?\"",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'make:request'",
",",
"[",
"'name'",
"=>",
"$",
"storeRequest",
"]",
")",
";",
"}",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"updateRequest",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"confirm",
"(",
"\"A {$updateRequest} request does not exist. Do you want to generate it?\"",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'make:request'",
",",
"[",
"'name'",
"=>",
"$",
"updateRequest",
"]",
")",
";",
"}",
"}",
"return",
"[",
"'DummyFullStoreRequestClass'",
"=>",
"$",
"storeRequest",
",",
"'DummyStoreRequestClass'",
"=>",
"class_basename",
"(",
"$",
"storeRequest",
")",
",",
"'DummyFullUpdateRequestClass'",
"=>",
"$",
"updateRequest",
",",
"'DummyUpdateRequestClass'",
"=>",
"class_basename",
"(",
"$",
"updateRequest",
")",
",",
"]",
";",
"}"
] | Build the request replacement values.
@param array $replace
@return array | [
"Build",
"the",
"request",
"replacement",
"values",
"."
] | d4366ead47e39e604ba7afb2804ad3388691ecca | https://github.com/larawos/framework/blob/d4366ead47e39e604ba7afb2804ad3388691ecca/src/Illuminate/Foundation/Console/ControllerMakeCommand.php#L125-L153 |
6,396 | larawos/framework | src/Illuminate/Foundation/Console/ControllerMakeCommand.php | ControllerMakeCommand.buildResourceReplacements | protected function buildResourceReplacements(array $replace)
{
$name = $this->getNameInput();
$rootNamespace = trim(
$this->laravel->getNamespace() . 'Http\Resources' . '\\' . $this->getNamespace($name),
'\\'
);
$indexResource = $rootNamespace . '\\' . str_replace('Controller', '', class_basename($name)) . 'IndexResource';
$showResource = $rootNamespace . '\\' . str_replace('Controller', '', class_basename($name)) . 'ShowResource';
$storeResource = $rootNamespace . '\\' . str_replace('Controller', '', class_basename($name)) . 'StoreResource';
$updateResource = $rootNamespace . '\\' . str_replace('Controller', '', class_basename($name)) . 'UpdateResource';
$deleteResource = $rootNamespace . '\\' . str_replace('Controller', '', class_basename($name)) . 'DeleteResource';
if (! class_exists($indexResource)) {
if ($this->confirm("A {$indexResource} resource does not exist. Do you want to generate it?", true)) {
$this->call('make:resource', ['name' => $indexResource, '--collection' => true]);
}
}
if (! class_exists($showResource)) {
if ($this->confirm("A {$showResource} resource does not exist. Do you want to generate it?", true)) {
$this->call('make:resource', ['name' => $showResource]);
}
}
if (! class_exists($storeResource)) {
if ($this->confirm("A {$storeResource} resource does not exist. Do you want to generate it?", true)) {
$this->call('make:resource', ['name' => $storeResource]);
}
}
if (! class_exists($updateResource)) {
if ($this->confirm("A {$updateResource} resource does not exist. Do you want to generate it?", true)) {
$this->call('make:resource', ['name' => $updateResource]);
}
}
if (! class_exists($deleteResource)) {
if ($this->confirm("A {$deleteResource} resource does not exist. Do you want to generate it?", true)) {
$this->call('make:resource', ['name' => $deleteResource]);
}
}
return array_merge($replace, [
'DummyFullIndexResourceClass' => $indexResource,
'DummyIndexResourceClass' => class_basename($indexResource),
'DummyFullShowResourceClass' => $showResource,
'DummyShowResourceClass' => class_basename($showResource),
'DummyFullStoreResourceClass' => $storeResource,
'DummyStoreResourceClass' => class_basename($storeResource),
'DummyFullUpdateResourceClass' => $updateResource,
'DummyUpdateResourceClass' => class_basename($updateResource),
'DummyFullDeleteResourceClass' => $deleteResource,
'DummyDeleteResourceClass' => class_basename($deleteResource),
]);
} | php | protected function buildResourceReplacements(array $replace)
{
$name = $this->getNameInput();
$rootNamespace = trim(
$this->laravel->getNamespace() . 'Http\Resources' . '\\' . $this->getNamespace($name),
'\\'
);
$indexResource = $rootNamespace . '\\' . str_replace('Controller', '', class_basename($name)) . 'IndexResource';
$showResource = $rootNamespace . '\\' . str_replace('Controller', '', class_basename($name)) . 'ShowResource';
$storeResource = $rootNamespace . '\\' . str_replace('Controller', '', class_basename($name)) . 'StoreResource';
$updateResource = $rootNamespace . '\\' . str_replace('Controller', '', class_basename($name)) . 'UpdateResource';
$deleteResource = $rootNamespace . '\\' . str_replace('Controller', '', class_basename($name)) . 'DeleteResource';
if (! class_exists($indexResource)) {
if ($this->confirm("A {$indexResource} resource does not exist. Do you want to generate it?", true)) {
$this->call('make:resource', ['name' => $indexResource, '--collection' => true]);
}
}
if (! class_exists($showResource)) {
if ($this->confirm("A {$showResource} resource does not exist. Do you want to generate it?", true)) {
$this->call('make:resource', ['name' => $showResource]);
}
}
if (! class_exists($storeResource)) {
if ($this->confirm("A {$storeResource} resource does not exist. Do you want to generate it?", true)) {
$this->call('make:resource', ['name' => $storeResource]);
}
}
if (! class_exists($updateResource)) {
if ($this->confirm("A {$updateResource} resource does not exist. Do you want to generate it?", true)) {
$this->call('make:resource', ['name' => $updateResource]);
}
}
if (! class_exists($deleteResource)) {
if ($this->confirm("A {$deleteResource} resource does not exist. Do you want to generate it?", true)) {
$this->call('make:resource', ['name' => $deleteResource]);
}
}
return array_merge($replace, [
'DummyFullIndexResourceClass' => $indexResource,
'DummyIndexResourceClass' => class_basename($indexResource),
'DummyFullShowResourceClass' => $showResource,
'DummyShowResourceClass' => class_basename($showResource),
'DummyFullStoreResourceClass' => $storeResource,
'DummyStoreResourceClass' => class_basename($storeResource),
'DummyFullUpdateResourceClass' => $updateResource,
'DummyUpdateResourceClass' => class_basename($updateResource),
'DummyFullDeleteResourceClass' => $deleteResource,
'DummyDeleteResourceClass' => class_basename($deleteResource),
]);
} | [
"protected",
"function",
"buildResourceReplacements",
"(",
"array",
"$",
"replace",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getNameInput",
"(",
")",
";",
"$",
"rootNamespace",
"=",
"trim",
"(",
"$",
"this",
"->",
"laravel",
"->",
"getNamespace",
"(",
")",
".",
"'Http\\Resources'",
".",
"'\\\\'",
".",
"$",
"this",
"->",
"getNamespace",
"(",
"$",
"name",
")",
",",
"'\\\\'",
")",
";",
"$",
"indexResource",
"=",
"$",
"rootNamespace",
".",
"'\\\\'",
".",
"str_replace",
"(",
"'Controller'",
",",
"''",
",",
"class_basename",
"(",
"$",
"name",
")",
")",
".",
"'IndexResource'",
";",
"$",
"showResource",
"=",
"$",
"rootNamespace",
".",
"'\\\\'",
".",
"str_replace",
"(",
"'Controller'",
",",
"''",
",",
"class_basename",
"(",
"$",
"name",
")",
")",
".",
"'ShowResource'",
";",
"$",
"storeResource",
"=",
"$",
"rootNamespace",
".",
"'\\\\'",
".",
"str_replace",
"(",
"'Controller'",
",",
"''",
",",
"class_basename",
"(",
"$",
"name",
")",
")",
".",
"'StoreResource'",
";",
"$",
"updateResource",
"=",
"$",
"rootNamespace",
".",
"'\\\\'",
".",
"str_replace",
"(",
"'Controller'",
",",
"''",
",",
"class_basename",
"(",
"$",
"name",
")",
")",
".",
"'UpdateResource'",
";",
"$",
"deleteResource",
"=",
"$",
"rootNamespace",
".",
"'\\\\'",
".",
"str_replace",
"(",
"'Controller'",
",",
"''",
",",
"class_basename",
"(",
"$",
"name",
")",
")",
".",
"'DeleteResource'",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"indexResource",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"confirm",
"(",
"\"A {$indexResource} resource does not exist. Do you want to generate it?\"",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'make:resource'",
",",
"[",
"'name'",
"=>",
"$",
"indexResource",
",",
"'--collection'",
"=>",
"true",
"]",
")",
";",
"}",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"showResource",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"confirm",
"(",
"\"A {$showResource} resource does not exist. Do you want to generate it?\"",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'make:resource'",
",",
"[",
"'name'",
"=>",
"$",
"showResource",
"]",
")",
";",
"}",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"storeResource",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"confirm",
"(",
"\"A {$storeResource} resource does not exist. Do you want to generate it?\"",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'make:resource'",
",",
"[",
"'name'",
"=>",
"$",
"storeResource",
"]",
")",
";",
"}",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"updateResource",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"confirm",
"(",
"\"A {$updateResource} resource does not exist. Do you want to generate it?\"",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'make:resource'",
",",
"[",
"'name'",
"=>",
"$",
"updateResource",
"]",
")",
";",
"}",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"deleteResource",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"confirm",
"(",
"\"A {$deleteResource} resource does not exist. Do you want to generate it?\"",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'make:resource'",
",",
"[",
"'name'",
"=>",
"$",
"deleteResource",
"]",
")",
";",
"}",
"}",
"return",
"array_merge",
"(",
"$",
"replace",
",",
"[",
"'DummyFullIndexResourceClass'",
"=>",
"$",
"indexResource",
",",
"'DummyIndexResourceClass'",
"=>",
"class_basename",
"(",
"$",
"indexResource",
")",
",",
"'DummyFullShowResourceClass'",
"=>",
"$",
"showResource",
",",
"'DummyShowResourceClass'",
"=>",
"class_basename",
"(",
"$",
"showResource",
")",
",",
"'DummyFullStoreResourceClass'",
"=>",
"$",
"storeResource",
",",
"'DummyStoreResourceClass'",
"=>",
"class_basename",
"(",
"$",
"storeResource",
")",
",",
"'DummyFullUpdateResourceClass'",
"=>",
"$",
"updateResource",
",",
"'DummyUpdateResourceClass'",
"=>",
"class_basename",
"(",
"$",
"updateResource",
")",
",",
"'DummyFullDeleteResourceClass'",
"=>",
"$",
"deleteResource",
",",
"'DummyDeleteResourceClass'",
"=>",
"class_basename",
"(",
"$",
"deleteResource",
")",
",",
"]",
")",
";",
"}"
] | Build the resource replacement values.
@param array $replace
@return array | [
"Build",
"the",
"resource",
"replacement",
"values",
"."
] | d4366ead47e39e604ba7afb2804ad3388691ecca | https://github.com/larawos/framework/blob/d4366ead47e39e604ba7afb2804ad3388691ecca/src/Illuminate/Foundation/Console/ControllerMakeCommand.php#L161-L216 |
6,397 | larawos/framework | src/Illuminate/Foundation/Console/ControllerMakeCommand.php | ControllerMakeCommand.buildRepositoryReplacements | protected function buildRepositoryReplacements(array $replace)
{
$repository = $this->parseRepository($this->option('repository'));
if (empty(trim($repository, $this->laravel->getNamespace(). 'Repositories\\'))) {
$repository = $this->parseRepository($this->ask('witch repository do you want to injected to the controller?'));
}
if (! class_exists($repository)) {
if ($this->confirm("A {$repository} repository does not exist. Do you want to generate it?", true)) {
$this->call('make:repository', [
'name' => $repository,
'--model' => $this->modelClass
]);
}
}
return array_merge($replace, [
'DummyFullRepositoryClass' => $repository,
'DummyRepositoryClass' => class_basename($repository),
'DummyRepositoryVariable' => lcfirst(class_basename($repository)),
]);
} | php | protected function buildRepositoryReplacements(array $replace)
{
$repository = $this->parseRepository($this->option('repository'));
if (empty(trim($repository, $this->laravel->getNamespace(). 'Repositories\\'))) {
$repository = $this->parseRepository($this->ask('witch repository do you want to injected to the controller?'));
}
if (! class_exists($repository)) {
if ($this->confirm("A {$repository} repository does not exist. Do you want to generate it?", true)) {
$this->call('make:repository', [
'name' => $repository,
'--model' => $this->modelClass
]);
}
}
return array_merge($replace, [
'DummyFullRepositoryClass' => $repository,
'DummyRepositoryClass' => class_basename($repository),
'DummyRepositoryVariable' => lcfirst(class_basename($repository)),
]);
} | [
"protected",
"function",
"buildRepositoryReplacements",
"(",
"array",
"$",
"replace",
")",
"{",
"$",
"repository",
"=",
"$",
"this",
"->",
"parseRepository",
"(",
"$",
"this",
"->",
"option",
"(",
"'repository'",
")",
")",
";",
"if",
"(",
"empty",
"(",
"trim",
"(",
"$",
"repository",
",",
"$",
"this",
"->",
"laravel",
"->",
"getNamespace",
"(",
")",
".",
"'Repositories\\\\'",
")",
")",
")",
"{",
"$",
"repository",
"=",
"$",
"this",
"->",
"parseRepository",
"(",
"$",
"this",
"->",
"ask",
"(",
"'witch repository do you want to injected to the controller?'",
")",
")",
";",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"repository",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"confirm",
"(",
"\"A {$repository} repository does not exist. Do you want to generate it?\"",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'make:repository'",
",",
"[",
"'name'",
"=>",
"$",
"repository",
",",
"'--model'",
"=>",
"$",
"this",
"->",
"modelClass",
"]",
")",
";",
"}",
"}",
"return",
"array_merge",
"(",
"$",
"replace",
",",
"[",
"'DummyFullRepositoryClass'",
"=>",
"$",
"repository",
",",
"'DummyRepositoryClass'",
"=>",
"class_basename",
"(",
"$",
"repository",
")",
",",
"'DummyRepositoryVariable'",
"=>",
"lcfirst",
"(",
"class_basename",
"(",
"$",
"repository",
")",
")",
",",
"]",
")",
";",
"}"
] | Build the repository replacement values.
@param array $replace
@return array | [
"Build",
"the",
"repository",
"replacement",
"values",
"."
] | d4366ead47e39e604ba7afb2804ad3388691ecca | https://github.com/larawos/framework/blob/d4366ead47e39e604ba7afb2804ad3388691ecca/src/Illuminate/Foundation/Console/ControllerMakeCommand.php#L255-L277 |
6,398 | larawos/framework | src/Illuminate/Foundation/Console/ControllerMakeCommand.php | ControllerMakeCommand.parseRepository | protected function parseRepository($repository)
{
if (preg_match('([^A-Za-z0-9_/\\\\])', $repository)) {
throw new InvalidArgumentException('Repository name contains invalid characters.');
}
$repository = trim(str_replace('/', '\\', $repository), '\\');
if (! Str::startsWith($repository, $rootNamespace = $this->laravel->getNamespace())) {
$repository = $rootNamespace.'Repositories'.'\\'.$repository;
}
return $repository;
} | php | protected function parseRepository($repository)
{
if (preg_match('([^A-Za-z0-9_/\\\\])', $repository)) {
throw new InvalidArgumentException('Repository name contains invalid characters.');
}
$repository = trim(str_replace('/', '\\', $repository), '\\');
if (! Str::startsWith($repository, $rootNamespace = $this->laravel->getNamespace())) {
$repository = $rootNamespace.'Repositories'.'\\'.$repository;
}
return $repository;
} | [
"protected",
"function",
"parseRepository",
"(",
"$",
"repository",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'([^A-Za-z0-9_/\\\\\\\\])'",
",",
"$",
"repository",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Repository name contains invalid characters.'",
")",
";",
"}",
"$",
"repository",
"=",
"trim",
"(",
"str_replace",
"(",
"'/'",
",",
"'\\\\'",
",",
"$",
"repository",
")",
",",
"'\\\\'",
")",
";",
"if",
"(",
"!",
"Str",
"::",
"startsWith",
"(",
"$",
"repository",
",",
"$",
"rootNamespace",
"=",
"$",
"this",
"->",
"laravel",
"->",
"getNamespace",
"(",
")",
")",
")",
"{",
"$",
"repository",
"=",
"$",
"rootNamespace",
".",
"'Repositories'",
".",
"'\\\\'",
".",
"$",
"repository",
";",
"}",
"return",
"$",
"repository",
";",
"}"
] | Get the fully-qualified repository class name.
@param string $repository
@return string | [
"Get",
"the",
"fully",
"-",
"qualified",
"repository",
"class",
"name",
"."
] | d4366ead47e39e604ba7afb2804ad3388691ecca | https://github.com/larawos/framework/blob/d4366ead47e39e604ba7afb2804ad3388691ecca/src/Illuminate/Foundation/Console/ControllerMakeCommand.php#L285-L298 |
6,399 | larawos/framework | src/Illuminate/Foundation/Console/ControllerMakeCommand.php | ControllerMakeCommand.getViewModuleFiles | protected function getViewModuleFiles($view)
{
$rootPath = resource_path('views/' . str_replace('.', '/', $view));
return [
$rootPath . '/index',
$rootPath . '/show',
$rootPath . '/create',
$rootPath . '/edit'
];
} | php | protected function getViewModuleFiles($view)
{
$rootPath = resource_path('views/' . str_replace('.', '/', $view));
return [
$rootPath . '/index',
$rootPath . '/show',
$rootPath . '/create',
$rootPath . '/edit'
];
} | [
"protected",
"function",
"getViewModuleFiles",
"(",
"$",
"view",
")",
"{",
"$",
"rootPath",
"=",
"resource_path",
"(",
"'views/'",
".",
"str_replace",
"(",
"'.'",
",",
"'/'",
",",
"$",
"view",
")",
")",
";",
"return",
"[",
"$",
"rootPath",
".",
"'/index'",
",",
"$",
"rootPath",
".",
"'/show'",
",",
"$",
"rootPath",
".",
"'/create'",
",",
"$",
"rootPath",
".",
"'/edit'",
"]",
";",
"}"
] | Get the view files.
@param string $view
@return array | [
"Get",
"the",
"view",
"files",
"."
] | d4366ead47e39e604ba7afb2804ad3388691ecca | https://github.com/larawos/framework/blob/d4366ead47e39e604ba7afb2804ad3388691ecca/src/Illuminate/Foundation/Console/ControllerMakeCommand.php#L344-L354 |
Subsets and Splits