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
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
19,500 | ClanCats/Core | src/classes/CCFile.php | CCFile.upload | public static function upload( $key, $path )
{
if ( $file = static::upload_path( $key ) ) {
return move_uploaded_file( $file, $path );
}
return false;
} | php | public static function upload( $key, $path )
{
if ( $file = static::upload_path( $key ) ) {
return move_uploaded_file( $file, $path );
}
return false;
} | [
"public",
"static",
"function",
"upload",
"(",
"$",
"key",
",",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"file",
"=",
"static",
"::",
"upload_path",
"(",
"$",
"key",
")",
")",
"{",
"return",
"move_uploaded_file",
"(",
"$",
"file",
",",
"$",
"path",
")",
";",
"}",
"return",
"false",
";",
"}"
]
| Move user uploads to another dir
@param string $key
@param string $path
@return bool | [
"Move",
"user",
"uploads",
"to",
"another",
"dir"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCFile.php#L194-L202 |
19,501 | ClanCats/Core | src/classes/CCError.php | CCError._init | public static function _init()
{
// we capture non fatal errors only in dev environments
if ( ClanCats::in_development() )
{
// add a hook to the main resposne
CCEvent::mind( 'response.output', function( $output ) {
if ( strpos( $output, '</body>' ) === false )
{
return $output;
}
$table = \UI\Table::create( array(
'style' => array(
'width' => '100%',
),
'cellpadding' => '5',
'class' => 'table debug-table debug-table-errors',
));
$table->header( array( '#', 'message', 'file' ) );
foreach( \CCError::$non_fatals as $key => $item )
{
$table->row( array(
$key+1,
$item->getMessage(),
CCStr::strip( $item->getFile(), CCROOT ).':'.$item->getLine(),
));
}
return str_replace( '</body>', $table."\n</body>", $output );
});
}
} | php | public static function _init()
{
// we capture non fatal errors only in dev environments
if ( ClanCats::in_development() )
{
// add a hook to the main resposne
CCEvent::mind( 'response.output', function( $output ) {
if ( strpos( $output, '</body>' ) === false )
{
return $output;
}
$table = \UI\Table::create( array(
'style' => array(
'width' => '100%',
),
'cellpadding' => '5',
'class' => 'table debug-table debug-table-errors',
));
$table->header( array( '#', 'message', 'file' ) );
foreach( \CCError::$non_fatals as $key => $item )
{
$table->row( array(
$key+1,
$item->getMessage(),
CCStr::strip( $item->getFile(), CCROOT ).':'.$item->getLine(),
));
}
return str_replace( '</body>', $table."\n</body>", $output );
});
}
} | [
"public",
"static",
"function",
"_init",
"(",
")",
"{",
"// we capture non fatal errors only in dev environments",
"if",
"(",
"ClanCats",
"::",
"in_development",
"(",
")",
")",
"{",
"// add a hook to the main resposne",
"CCEvent",
"::",
"mind",
"(",
"'response.output'",
",",
"function",
"(",
"$",
"output",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"output",
",",
"'</body>'",
")",
"===",
"false",
")",
"{",
"return",
"$",
"output",
";",
"}",
"$",
"table",
"=",
"\\",
"UI",
"\\",
"Table",
"::",
"create",
"(",
"array",
"(",
"'style'",
"=>",
"array",
"(",
"'width'",
"=>",
"'100%'",
",",
")",
",",
"'cellpadding'",
"=>",
"'5'",
",",
"'class'",
"=>",
"'table debug-table debug-table-errors'",
",",
")",
")",
";",
"$",
"table",
"->",
"header",
"(",
"array",
"(",
"'#'",
",",
"'message'",
",",
"'file'",
")",
")",
";",
"foreach",
"(",
"\\",
"CCError",
"::",
"$",
"non_fatals",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"$",
"table",
"->",
"row",
"(",
"array",
"(",
"$",
"key",
"+",
"1",
",",
"$",
"item",
"->",
"getMessage",
"(",
")",
",",
"CCStr",
"::",
"strip",
"(",
"$",
"item",
"->",
"getFile",
"(",
")",
",",
"CCROOT",
")",
".",
"':'",
".",
"$",
"item",
"->",
"getLine",
"(",
")",
",",
")",
")",
";",
"}",
"return",
"str_replace",
"(",
"'</body>'",
",",
"$",
"table",
".",
"\"\\n</body>\"",
",",
"$",
"output",
")",
";",
"}",
")",
";",
"}",
"}"
]
| error class init
@return void | [
"error",
"class",
"init"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCError.php#L62-L97 |
19,502 | ClanCats/Core | src/classes/CCError.php | CCError.is_fatal_level | private static function is_fatal_level( $level )
{
$fatals = array(
E_ERROR,
E_PARSE,
E_CORE_ERROR,
E_CORE_WARNING,
E_COMPILE_ERROR,
E_COMPILE_WARNING,
E_DEPRECATED,
);
if ( is_object( ClanCats::$config ) && ClanCats::$config instanceof CCConfig )
{
if ( in_array( $level, ClanCats::$config->get( 'error.fatal_levels', $fatals ) ))
{
return true;
}
}
return false;
} | php | private static function is_fatal_level( $level )
{
$fatals = array(
E_ERROR,
E_PARSE,
E_CORE_ERROR,
E_CORE_WARNING,
E_COMPILE_ERROR,
E_COMPILE_WARNING,
E_DEPRECATED,
);
if ( is_object( ClanCats::$config ) && ClanCats::$config instanceof CCConfig )
{
if ( in_array( $level, ClanCats::$config->get( 'error.fatal_levels', $fatals ) ))
{
return true;
}
}
return false;
} | [
"private",
"static",
"function",
"is_fatal_level",
"(",
"$",
"level",
")",
"{",
"$",
"fatals",
"=",
"array",
"(",
"E_ERROR",
",",
"E_PARSE",
",",
"E_CORE_ERROR",
",",
"E_CORE_WARNING",
",",
"E_COMPILE_ERROR",
",",
"E_COMPILE_WARNING",
",",
"E_DEPRECATED",
",",
")",
";",
"if",
"(",
"is_object",
"(",
"ClanCats",
"::",
"$",
"config",
")",
"&&",
"ClanCats",
"::",
"$",
"config",
"instanceof",
"CCConfig",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"level",
",",
"ClanCats",
"::",
"$",
"config",
"->",
"get",
"(",
"'error.fatal_levels'",
",",
"$",
"fatals",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| check if a level is fatal
@param int $level
@return bool | [
"check",
"if",
"a",
"level",
"is",
"fatal"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCError.php#L105-L126 |
19,503 | ClanCats/Core | src/classes/CCError.php | CCError.error | public static function error( $num, $message, $file, $line )
{
$exception = new CCException( static::$error_types[$num]." - ".$message, 0, $num, $file, $line );
if ( static::is_fatal_level( $num ) )
{
if ( static::$in_shutdown_process )
{
static::exception( $exception );
} else
{
throw $exception;
}
} else
{
static::$non_fatals[] = $exception;
}
} | php | public static function error( $num, $message, $file, $line )
{
$exception = new CCException( static::$error_types[$num]." - ".$message, 0, $num, $file, $line );
if ( static::is_fatal_level( $num ) )
{
if ( static::$in_shutdown_process )
{
static::exception( $exception );
} else
{
throw $exception;
}
} else
{
static::$non_fatals[] = $exception;
}
} | [
"public",
"static",
"function",
"error",
"(",
"$",
"num",
",",
"$",
"message",
",",
"$",
"file",
",",
"$",
"line",
")",
"{",
"$",
"exception",
"=",
"new",
"CCException",
"(",
"static",
"::",
"$",
"error_types",
"[",
"$",
"num",
"]",
".",
"\" - \"",
".",
"$",
"message",
",",
"0",
",",
"$",
"num",
",",
"$",
"file",
",",
"$",
"line",
")",
";",
"if",
"(",
"static",
"::",
"is_fatal_level",
"(",
"$",
"num",
")",
")",
"{",
"if",
"(",
"static",
"::",
"$",
"in_shutdown_process",
")",
"{",
"static",
"::",
"exception",
"(",
"$",
"exception",
")",
";",
"}",
"else",
"{",
"throw",
"$",
"exception",
";",
"}",
"}",
"else",
"{",
"static",
"::",
"$",
"non_fatals",
"[",
"]",
"=",
"$",
"exception",
";",
"}",
"}"
]
| The error handler converts PHP errors to CCExceptions.
These get handled by the CCError exception handler.
Also the error handler decides the fatality of an error.
@param CCException $exception
@return void | [
"The",
"error",
"handler",
"converts",
"PHP",
"errors",
"to",
"CCExceptions",
".",
"These",
"get",
"handled",
"by",
"the",
"CCError",
"exception",
"handler",
"."
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCError.php#L167-L184 |
19,504 | raoul2000/yii2-scrollup-widget | Scrollup.php | Scrollup.init | public function init()
{
parent::init();
if (! empty($this->theme) && ! in_array($this->theme, $this->_supportedThemes)) {
throw new InvalidConfigException('Unsupported built-in theme : ' . $this->theme);
}
if (isset($this->pluginOptions['animation']) && ! in_array($this->pluginOptions['animation'], $this->_supportedAnimation)) {
throw new InvalidConfigException('Unsupported animation mode : ' . $this->pluginOptions['animation']);
}
} | php | public function init()
{
parent::init();
if (! empty($this->theme) && ! in_array($this->theme, $this->_supportedThemes)) {
throw new InvalidConfigException('Unsupported built-in theme : ' . $this->theme);
}
if (isset($this->pluginOptions['animation']) && ! in_array($this->pluginOptions['animation'], $this->_supportedAnimation)) {
throw new InvalidConfigException('Unsupported animation mode : ' . $this->pluginOptions['animation']);
}
} | [
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"theme",
")",
"&&",
"!",
"in_array",
"(",
"$",
"this",
"->",
"theme",
",",
"$",
"this",
"->",
"_supportedThemes",
")",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"'Unsupported built-in theme : '",
".",
"$",
"this",
"->",
"theme",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"pluginOptions",
"[",
"'animation'",
"]",
")",
"&&",
"!",
"in_array",
"(",
"$",
"this",
"->",
"pluginOptions",
"[",
"'animation'",
"]",
",",
"$",
"this",
"->",
"_supportedAnimation",
")",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"'Unsupported animation mode : '",
".",
"$",
"this",
"->",
"pluginOptions",
"[",
"'animation'",
"]",
")",
";",
"}",
"}"
]
| Chekcs validity of theme and animation options | [
"Chekcs",
"validity",
"of",
"theme",
"and",
"animation",
"options"
]
| 54d0d40755d81b039b90bfb36ed90325294b6864 | https://github.com/raoul2000/yii2-scrollup-widget/blob/54d0d40755d81b039b90bfb36ed90325294b6864/Scrollup.php#L66-L75 |
19,505 | raoul2000/yii2-scrollup-widget | Scrollup.php | Scrollup.registerClientScript | public function registerClientScript()
{
$view = $this->getView();
if (isset($this->theme)) {
$path = $view->getAssetManager()->publish(__DIR__ . '/assets/css/themes');
$view->registerCSSFile($path[1] . '/' . $this->theme . '.css');
if ($this->theme == 'image' && isset($this->pluginOptions['scrollText'])) {
$this->pluginOptions['scrollText'] = '';
}
}
ScrollupAsset::register($view);
$options = empty($this->pluginOptions) ? '{}' : Json::encode($this->pluginOptions);
$js = "$.scrollUp($options);";
$view->registerJs($js);
} | php | public function registerClientScript()
{
$view = $this->getView();
if (isset($this->theme)) {
$path = $view->getAssetManager()->publish(__DIR__ . '/assets/css/themes');
$view->registerCSSFile($path[1] . '/' . $this->theme . '.css');
if ($this->theme == 'image' && isset($this->pluginOptions['scrollText'])) {
$this->pluginOptions['scrollText'] = '';
}
}
ScrollupAsset::register($view);
$options = empty($this->pluginOptions) ? '{}' : Json::encode($this->pluginOptions);
$js = "$.scrollUp($options);";
$view->registerJs($js);
} | [
"public",
"function",
"registerClientScript",
"(",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"getView",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"theme",
")",
")",
"{",
"$",
"path",
"=",
"$",
"view",
"->",
"getAssetManager",
"(",
")",
"->",
"publish",
"(",
"__DIR__",
".",
"'/assets/css/themes'",
")",
";",
"$",
"view",
"->",
"registerCSSFile",
"(",
"$",
"path",
"[",
"1",
"]",
".",
"'/'",
".",
"$",
"this",
"->",
"theme",
".",
"'.css'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"theme",
"==",
"'image'",
"&&",
"isset",
"(",
"$",
"this",
"->",
"pluginOptions",
"[",
"'scrollText'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"pluginOptions",
"[",
"'scrollText'",
"]",
"=",
"''",
";",
"}",
"}",
"ScrollupAsset",
"::",
"register",
"(",
"$",
"view",
")",
";",
"$",
"options",
"=",
"empty",
"(",
"$",
"this",
"->",
"pluginOptions",
")",
"?",
"'{}'",
":",
"Json",
"::",
"encode",
"(",
"$",
"this",
"->",
"pluginOptions",
")",
";",
"$",
"js",
"=",
"\"$.scrollUp($options);\"",
";",
"$",
"view",
"->",
"registerJs",
"(",
"$",
"js",
")",
";",
"}"
]
| Registers the needed JavaScript and inject the JS initialization code.
Note that if a supported theme is set, all css in the assets/css/theme folder are published
but only the css for the theme is registred.Moreover, if the select theme is 'image', the
'scrollText plugin option is cleared. | [
"Registers",
"the",
"needed",
"JavaScript",
"and",
"inject",
"the",
"JS",
"initialization",
"code",
"."
]
| 54d0d40755d81b039b90bfb36ed90325294b6864 | https://github.com/raoul2000/yii2-scrollup-widget/blob/54d0d40755d81b039b90bfb36ed90325294b6864/Scrollup.php#L92-L110 |
19,506 | fubhy/graphql-php | src/Language/Source.php | Source.getLocation | public function getLocation($position)
{
$pattern = '/\r\n|[\n\r\u2028\u2029]/g';
$subject = mb_substr($this->body, 0, $position, 'UTF-8');
preg_match_all($pattern, $subject, $matches, PREG_OFFSET_CAPTURE);
$location = array_reduce($matches[0], function ($carry, $match) use ($position) {
return [
$carry[0] + 1,
$position + 1 - ($match[1] + mb_strlen($match[0], 'UTF-8'))
];
}, [1, $position + 1]);
return new SourceLocation($location[0], $location[1]);
} | php | public function getLocation($position)
{
$pattern = '/\r\n|[\n\r\u2028\u2029]/g';
$subject = mb_substr($this->body, 0, $position, 'UTF-8');
preg_match_all($pattern, $subject, $matches, PREG_OFFSET_CAPTURE);
$location = array_reduce($matches[0], function ($carry, $match) use ($position) {
return [
$carry[0] + 1,
$position + 1 - ($match[1] + mb_strlen($match[0], 'UTF-8'))
];
}, [1, $position + 1]);
return new SourceLocation($location[0], $location[1]);
} | [
"public",
"function",
"getLocation",
"(",
"$",
"position",
")",
"{",
"$",
"pattern",
"=",
"'/\\r\\n|[\\n\\r\\u2028\\u2029]/g'",
";",
"$",
"subject",
"=",
"mb_substr",
"(",
"$",
"this",
"->",
"body",
",",
"0",
",",
"$",
"position",
",",
"'UTF-8'",
")",
";",
"preg_match_all",
"(",
"$",
"pattern",
",",
"$",
"subject",
",",
"$",
"matches",
",",
"PREG_OFFSET_CAPTURE",
")",
";",
"$",
"location",
"=",
"array_reduce",
"(",
"$",
"matches",
"[",
"0",
"]",
",",
"function",
"(",
"$",
"carry",
",",
"$",
"match",
")",
"use",
"(",
"$",
"position",
")",
"{",
"return",
"[",
"$",
"carry",
"[",
"0",
"]",
"+",
"1",
",",
"$",
"position",
"+",
"1",
"-",
"(",
"$",
"match",
"[",
"1",
"]",
"+",
"mb_strlen",
"(",
"$",
"match",
"[",
"0",
"]",
",",
"'UTF-8'",
")",
")",
"]",
";",
"}",
",",
"[",
"1",
",",
"$",
"position",
"+",
"1",
"]",
")",
";",
"return",
"new",
"SourceLocation",
"(",
"$",
"location",
"[",
"0",
"]",
",",
"$",
"location",
"[",
"1",
"]",
")",
";",
"}"
]
| Takes a Source and a UTF-8 character offset, and returns the
corresponding line and column as a SourceLocation.
@param $position
@return \Fubhy\GraphQL\Language\SourceLocation | [
"Takes",
"a",
"Source",
"and",
"a",
"UTF",
"-",
"8",
"character",
"offset",
"and",
"returns",
"the",
"corresponding",
"line",
"and",
"column",
"as",
"a",
"SourceLocation",
"."
]
| c1de2233c731ca29e5c5db4c43f3b9db36478c83 | https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Language/Source.php#L74-L88 |
19,507 | joomlatools/joomlatools-platform-legacy | code/base/node.php | JNode.addChild | public function addChild(&$child)
{
JLog::add('JNode::addChild() is deprecated.', JLog::WARNING, 'deprecated');
if ($child instanceof Jnode)
{
$child->setParent($this);
}
} | php | public function addChild(&$child)
{
JLog::add('JNode::addChild() is deprecated.', JLog::WARNING, 'deprecated');
if ($child instanceof Jnode)
{
$child->setParent($this);
}
} | [
"public",
"function",
"addChild",
"(",
"&",
"$",
"child",
")",
"{",
"JLog",
"::",
"add",
"(",
"'JNode::addChild() is deprecated.'",
",",
"JLog",
"::",
"WARNING",
",",
"'deprecated'",
")",
";",
"if",
"(",
"$",
"child",
"instanceof",
"Jnode",
")",
"{",
"$",
"child",
"->",
"setParent",
"(",
"$",
"this",
")",
";",
"}",
"}"
]
| Add child to this node
If the child already has a parent, the link is unset
@param JNode &$child The child to be added
@return void
@since 11.1 | [
"Add",
"child",
"to",
"this",
"node"
]
| 3a76944e2f2c415faa6504754c75321a3b478c06 | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/base/node.php#L60-L68 |
19,508 | joomlatools/joomlatools-platform-legacy | code/base/node.php | JNode.setParent | public function setParent(&$parent)
{
JLog::add('JNode::setParent() is deprecated.', JLog::WARNING, 'deprecated');
if ($parent instanceof JNode || is_null($parent))
{
$hash = spl_object_hash($this);
if (!is_null($this->_parent))
{
unset($this->_parent->children[$hash]);
}
if (!is_null($parent))
{
$parent->_children[$hash] = & $this;
}
$this->_parent = & $parent;
}
} | php | public function setParent(&$parent)
{
JLog::add('JNode::setParent() is deprecated.', JLog::WARNING, 'deprecated');
if ($parent instanceof JNode || is_null($parent))
{
$hash = spl_object_hash($this);
if (!is_null($this->_parent))
{
unset($this->_parent->children[$hash]);
}
if (!is_null($parent))
{
$parent->_children[$hash] = & $this;
}
$this->_parent = & $parent;
}
} | [
"public",
"function",
"setParent",
"(",
"&",
"$",
"parent",
")",
"{",
"JLog",
"::",
"add",
"(",
"'JNode::setParent() is deprecated.'",
",",
"JLog",
"::",
"WARNING",
",",
"'deprecated'",
")",
";",
"if",
"(",
"$",
"parent",
"instanceof",
"JNode",
"||",
"is_null",
"(",
"$",
"parent",
")",
")",
"{",
"$",
"hash",
"=",
"spl_object_hash",
"(",
"$",
"this",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"_parent",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_parent",
"->",
"children",
"[",
"$",
"hash",
"]",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"parent",
")",
")",
"{",
"$",
"parent",
"->",
"_children",
"[",
"$",
"hash",
"]",
"=",
"&",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"_parent",
"=",
"&",
"$",
"parent",
";",
"}",
"}"
]
| Set the parent of a this node
If the node already has a parent, the link is unset
@param mixed &$parent The JNode for parent to be set or null
@return void
@since 11.1 | [
"Set",
"the",
"parent",
"of",
"a",
"this",
"node"
]
| 3a76944e2f2c415faa6504754c75321a3b478c06 | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/base/node.php#L81-L101 |
19,509 | Nobiles2/smsapi-bundle | DependencyInjection/KCHSmsApiExtension.php | KCHSmsApiExtension.registerFactories | private function registerFactories(ContainerBuilder $container, Definition $clientService, $clientName)
{
// SmsFactory
$container->setDefinition(
sprintf('kch_sms_api.sms_factory.%s', $clientName),
new Definition('%kch_sms_api.sms_factory.class%')
)
->addMethodCall('setClient', array($clientService))
->addTag('kch_sms_api.factory', array('alias' => 'kch_sms_api_factory'));
// MmsFactory
$container->setDefinition(
sprintf('kch_sms_api.mms_factory.%s', $clientName),
new Definition('%kch_sms_api.mms_factory.class%')
)
->addMethodCall('setClient', array($clientService))
->addTag('kch_sms_api.factory', array('alias' => 'kch_sms_api_factory'));
// VmsFactory
$container->setDefinition(
sprintf('kch_sms_api.vms_factory.%s', $clientName),
new Definition('%kch_sms_api.vms_factory.class%')
)
->addMethodCall('setClient', array($clientService))
->addTag('kch_sms_api.factory', array('alias' => 'kch_sms_api_factory'));
// SenderFactory
$container->setDefinition(
sprintf('kch_sms_api.sender_factory.%s', $clientName),
new Definition('%kch_sms_api.sender_factory.class%')
)
->addMethodCall('setClient', array($clientService))
->addTag('kch_sms_api.factory', array('alias' => 'kch_sms_api_factory'));
// ContactsFactory
$container->setDefinition(
sprintf('kch_sms_api.contacts_factory.%s', $clientName),
new Definition('%kch_sms_api.contacts_factory.class%')
)
->addMethodCall('setClient', array($clientService))
->addTag('kch_sms_api.factory', array('alias' => 'kch_sms_api_factory'));
} | php | private function registerFactories(ContainerBuilder $container, Definition $clientService, $clientName)
{
// SmsFactory
$container->setDefinition(
sprintf('kch_sms_api.sms_factory.%s', $clientName),
new Definition('%kch_sms_api.sms_factory.class%')
)
->addMethodCall('setClient', array($clientService))
->addTag('kch_sms_api.factory', array('alias' => 'kch_sms_api_factory'));
// MmsFactory
$container->setDefinition(
sprintf('kch_sms_api.mms_factory.%s', $clientName),
new Definition('%kch_sms_api.mms_factory.class%')
)
->addMethodCall('setClient', array($clientService))
->addTag('kch_sms_api.factory', array('alias' => 'kch_sms_api_factory'));
// VmsFactory
$container->setDefinition(
sprintf('kch_sms_api.vms_factory.%s', $clientName),
new Definition('%kch_sms_api.vms_factory.class%')
)
->addMethodCall('setClient', array($clientService))
->addTag('kch_sms_api.factory', array('alias' => 'kch_sms_api_factory'));
// SenderFactory
$container->setDefinition(
sprintf('kch_sms_api.sender_factory.%s', $clientName),
new Definition('%kch_sms_api.sender_factory.class%')
)
->addMethodCall('setClient', array($clientService))
->addTag('kch_sms_api.factory', array('alias' => 'kch_sms_api_factory'));
// ContactsFactory
$container->setDefinition(
sprintf('kch_sms_api.contacts_factory.%s', $clientName),
new Definition('%kch_sms_api.contacts_factory.class%')
)
->addMethodCall('setClient', array($clientService))
->addTag('kch_sms_api.factory', array('alias' => 'kch_sms_api_factory'));
} | [
"private",
"function",
"registerFactories",
"(",
"ContainerBuilder",
"$",
"container",
",",
"Definition",
"$",
"clientService",
",",
"$",
"clientName",
")",
"{",
"// SmsFactory",
"$",
"container",
"->",
"setDefinition",
"(",
"sprintf",
"(",
"'kch_sms_api.sms_factory.%s'",
",",
"$",
"clientName",
")",
",",
"new",
"Definition",
"(",
"'%kch_sms_api.sms_factory.class%'",
")",
")",
"->",
"addMethodCall",
"(",
"'setClient'",
",",
"array",
"(",
"$",
"clientService",
")",
")",
"->",
"addTag",
"(",
"'kch_sms_api.factory'",
",",
"array",
"(",
"'alias'",
"=>",
"'kch_sms_api_factory'",
")",
")",
";",
"// MmsFactory",
"$",
"container",
"->",
"setDefinition",
"(",
"sprintf",
"(",
"'kch_sms_api.mms_factory.%s'",
",",
"$",
"clientName",
")",
",",
"new",
"Definition",
"(",
"'%kch_sms_api.mms_factory.class%'",
")",
")",
"->",
"addMethodCall",
"(",
"'setClient'",
",",
"array",
"(",
"$",
"clientService",
")",
")",
"->",
"addTag",
"(",
"'kch_sms_api.factory'",
",",
"array",
"(",
"'alias'",
"=>",
"'kch_sms_api_factory'",
")",
")",
";",
"// VmsFactory",
"$",
"container",
"->",
"setDefinition",
"(",
"sprintf",
"(",
"'kch_sms_api.vms_factory.%s'",
",",
"$",
"clientName",
")",
",",
"new",
"Definition",
"(",
"'%kch_sms_api.vms_factory.class%'",
")",
")",
"->",
"addMethodCall",
"(",
"'setClient'",
",",
"array",
"(",
"$",
"clientService",
")",
")",
"->",
"addTag",
"(",
"'kch_sms_api.factory'",
",",
"array",
"(",
"'alias'",
"=>",
"'kch_sms_api_factory'",
")",
")",
";",
"// SenderFactory",
"$",
"container",
"->",
"setDefinition",
"(",
"sprintf",
"(",
"'kch_sms_api.sender_factory.%s'",
",",
"$",
"clientName",
")",
",",
"new",
"Definition",
"(",
"'%kch_sms_api.sender_factory.class%'",
")",
")",
"->",
"addMethodCall",
"(",
"'setClient'",
",",
"array",
"(",
"$",
"clientService",
")",
")",
"->",
"addTag",
"(",
"'kch_sms_api.factory'",
",",
"array",
"(",
"'alias'",
"=>",
"'kch_sms_api_factory'",
")",
")",
";",
"// ContactsFactory",
"$",
"container",
"->",
"setDefinition",
"(",
"sprintf",
"(",
"'kch_sms_api.contacts_factory.%s'",
",",
"$",
"clientName",
")",
",",
"new",
"Definition",
"(",
"'%kch_sms_api.contacts_factory.class%'",
")",
")",
"->",
"addMethodCall",
"(",
"'setClient'",
",",
"array",
"(",
"$",
"clientService",
")",
")",
"->",
"addTag",
"(",
"'kch_sms_api.factory'",
",",
"array",
"(",
"'alias'",
"=>",
"'kch_sms_api_factory'",
")",
")",
";",
"}"
]
| Method register all library factories for Client.
@param ContainerBuilder $container
@param Definition $clientService
@param $clientName | [
"Method",
"register",
"all",
"library",
"factories",
"for",
"Client",
"."
]
| f3f5e76e021b6a5da8c8d8accb81c4e283b9faa7 | https://github.com/Nobiles2/smsapi-bundle/blob/f3f5e76e021b6a5da8c8d8accb81c4e283b9faa7/DependencyInjection/KCHSmsApiExtension.php#L52-L93 |
19,510 | webforge-labs/psc-cms | lib/Psc/Doctrine/EntityBuilder.php | EntityBuilder.isMetaProperty | public function isMetaProperty($property) {
if (array_key_exists($property->getName(), $this->forcedMetaProperties)) return $this->forcedMetaProperties[$property->getName()];
return TRUE;
} | php | public function isMetaProperty($property) {
if (array_key_exists($property->getName(), $this->forcedMetaProperties)) return $this->forcedMetaProperties[$property->getName()];
return TRUE;
} | [
"public",
"function",
"isMetaProperty",
"(",
"$",
"property",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"property",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"forcedMetaProperties",
")",
")",
"return",
"$",
"this",
"->",
"forcedMetaProperties",
"[",
"$",
"property",
"->",
"getName",
"(",
")",
"]",
";",
"return",
"TRUE",
";",
"}"
]
| Soll dsa Property z.b. im SetMetaGetter genannt werden? | [
"Soll",
"dsa",
"Property",
"z",
".",
"b",
".",
"im",
"SetMetaGetter",
"genannt",
"werden?"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/EntityBuilder.php#L443-L447 |
19,511 | ClanCats/Core | src/classes/CCIn/Instance.php | CCIn_Instance.get | public function get( $key, $default = null )
{
if ( !isset( $this->GET[$key] ) )
{
return $default;
}
return $this->GET[$key];
} | php | public function get( $key, $default = null )
{
if ( !isset( $this->GET[$key] ) )
{
return $default;
}
return $this->GET[$key];
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"GET",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"return",
"$",
"this",
"->",
"GET",
"[",
"$",
"key",
"]",
";",
"}"
]
| get a GET param
@param string $key
@param mixed $default
@return mixed | [
"get",
"a",
"GET",
"param"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCIn/Instance.php#L77-L84 |
19,512 | ClanCats/Core | src/classes/CCIn/Instance.php | CCIn_Instance.post | public function post( $key, $default = null )
{
if ( !isset( $this->POST[$key] ) )
{
return $default;
}
return $this->POST[$key];
} | php | public function post( $key, $default = null )
{
if ( !isset( $this->POST[$key] ) )
{
return $default;
}
return $this->POST[$key];
} | [
"public",
"function",
"post",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"POST",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"return",
"$",
"this",
"->",
"POST",
"[",
"$",
"key",
"]",
";",
"}"
]
| get a POST param
@param string $key
@param mixed $default
@return mixed | [
"get",
"a",
"POST",
"param"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCIn/Instance.php#L104-L111 |
19,513 | ClanCats/Core | src/classes/CCIn/Instance.php | CCIn_Instance.server | public function server( $key, $default = null ) {
if ( !isset( $this->SERVER[strtoupper( $key )] ) )
{
return $default;
}
return $this->SERVER[strtoupper( $key )];
} | php | public function server( $key, $default = null ) {
if ( !isset( $this->SERVER[strtoupper( $key )] ) )
{
return $default;
}
return $this->SERVER[strtoupper( $key )];
} | [
"public",
"function",
"server",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"SERVER",
"[",
"strtoupper",
"(",
"$",
"key",
")",
"]",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"return",
"$",
"this",
"->",
"SERVER",
"[",
"strtoupper",
"(",
"$",
"key",
")",
"]",
";",
"}"
]
| get a SERVER param
@param string $key
@return mixed | [
"get",
"a",
"SERVER",
"param"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCIn/Instance.php#L130-L136 |
19,514 | ClanCats/Core | src/classes/CCIn/Instance.php | CCIn_Instance.file | public function file( $key, $default = null )
{
if ( !isset( $this->FILES[$key] ) )
{
return $default;
}
return $this->FILES[$key];
} | php | public function file( $key, $default = null )
{
if ( !isset( $this->FILES[$key] ) )
{
return $default;
}
return $this->FILES[$key];
} | [
"public",
"function",
"file",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"FILES",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"return",
"$",
"this",
"->",
"FILES",
"[",
"$",
"key",
"]",
";",
"}"
]
| get a FILE param
@param string $key
@param mixed $default
@return mixed | [
"get",
"a",
"FILE",
"param"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCIn/Instance.php#L156-L163 |
19,515 | ClanCats/Core | src/classes/CCIn/Instance.php | CCIn_Instance.client | public function client( $key = null ) {
// check if we already set the client object
if ( is_null( $this->client ) )
{
// make client
$this->client = new \stdClass;
/*
* get clients ip address
*/
// Cloudlfare fix
if ( $this->has_server( 'HTTP_CF_CONNECTING_IP' ) )
{
$this->client->ip = $this->server( 'HTTP_CF_CONNECTING_IP' );
}
// proxy?
elseif ( $this->has_server( 'HTTP_X_FORWARDED_FOR' ) )
{
$this->client->ip = $this->server( 'HTTP_X_FORWARDED_FOR' );
}
// another proxy?
elseif ( $this->has_server( 'HTTP_CLIENT_IP' ) )
{
$this->client->ip = $this->server( 'HTTP_CLIENT_IP' );
}
// or default
else
{
$this->client->ip = $this->server( 'REMOTE_ADDR', '127.0.0.1' );
}
/*
* set clients user agent
*/
$this->client->agent = $this->server( 'HTTP_USER_AGENT', '' );
/*
* set clients port
*/
$this->client->port = $this->server( 'REMOTE_PORT', '' );
/*
* set clients fingerprint based on host and agent
*/
$this->client->fingerprint = CCStr::hash( $this->client('agent').$this->client('ip') );
/*
* set clients language
*/
$this->client->language = CCLang::set_current( $this->server( 'HTTP_ACCEPT_LANGUAGE' ) );
}
// return the object
if ( is_null( $key ) )
{
return $this->client;
}
// return a special key
return $this->client->{$key};
} | php | public function client( $key = null ) {
// check if we already set the client object
if ( is_null( $this->client ) )
{
// make client
$this->client = new \stdClass;
/*
* get clients ip address
*/
// Cloudlfare fix
if ( $this->has_server( 'HTTP_CF_CONNECTING_IP' ) )
{
$this->client->ip = $this->server( 'HTTP_CF_CONNECTING_IP' );
}
// proxy?
elseif ( $this->has_server( 'HTTP_X_FORWARDED_FOR' ) )
{
$this->client->ip = $this->server( 'HTTP_X_FORWARDED_FOR' );
}
// another proxy?
elseif ( $this->has_server( 'HTTP_CLIENT_IP' ) )
{
$this->client->ip = $this->server( 'HTTP_CLIENT_IP' );
}
// or default
else
{
$this->client->ip = $this->server( 'REMOTE_ADDR', '127.0.0.1' );
}
/*
* set clients user agent
*/
$this->client->agent = $this->server( 'HTTP_USER_AGENT', '' );
/*
* set clients port
*/
$this->client->port = $this->server( 'REMOTE_PORT', '' );
/*
* set clients fingerprint based on host and agent
*/
$this->client->fingerprint = CCStr::hash( $this->client('agent').$this->client('ip') );
/*
* set clients language
*/
$this->client->language = CCLang::set_current( $this->server( 'HTTP_ACCEPT_LANGUAGE' ) );
}
// return the object
if ( is_null( $key ) )
{
return $this->client;
}
// return a special key
return $this->client->{$key};
} | [
"public",
"function",
"client",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"// check if we already set the client object",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"client",
")",
")",
"{",
"// make client ",
"$",
"this",
"->",
"client",
"=",
"new",
"\\",
"stdClass",
";",
"/*\n\t\t\t * get clients ip address\n\t\t\t */",
"// Cloudlfare fix ",
"if",
"(",
"$",
"this",
"->",
"has_server",
"(",
"'HTTP_CF_CONNECTING_IP'",
")",
")",
"{",
"$",
"this",
"->",
"client",
"->",
"ip",
"=",
"$",
"this",
"->",
"server",
"(",
"'HTTP_CF_CONNECTING_IP'",
")",
";",
"}",
"// proxy?",
"elseif",
"(",
"$",
"this",
"->",
"has_server",
"(",
"'HTTP_X_FORWARDED_FOR'",
")",
")",
"{",
"$",
"this",
"->",
"client",
"->",
"ip",
"=",
"$",
"this",
"->",
"server",
"(",
"'HTTP_X_FORWARDED_FOR'",
")",
";",
"}",
"// another proxy?",
"elseif",
"(",
"$",
"this",
"->",
"has_server",
"(",
"'HTTP_CLIENT_IP'",
")",
")",
"{",
"$",
"this",
"->",
"client",
"->",
"ip",
"=",
"$",
"this",
"->",
"server",
"(",
"'HTTP_CLIENT_IP'",
")",
";",
"}",
"// or default",
"else",
"{",
"$",
"this",
"->",
"client",
"->",
"ip",
"=",
"$",
"this",
"->",
"server",
"(",
"'REMOTE_ADDR'",
",",
"'127.0.0.1'",
")",
";",
"}",
"/*\n\t\t\t * set clients user agent\n\t\t\t */",
"$",
"this",
"->",
"client",
"->",
"agent",
"=",
"$",
"this",
"->",
"server",
"(",
"'HTTP_USER_AGENT'",
",",
"''",
")",
";",
"/*\n\t\t\t * set clients port\n\t\t\t */",
"$",
"this",
"->",
"client",
"->",
"port",
"=",
"$",
"this",
"->",
"server",
"(",
"'REMOTE_PORT'",
",",
"''",
")",
";",
"/*\n\t\t\t * set clients fingerprint based on host and agent\n\t\t\t */",
"$",
"this",
"->",
"client",
"->",
"fingerprint",
"=",
"CCStr",
"::",
"hash",
"(",
"$",
"this",
"->",
"client",
"(",
"'agent'",
")",
".",
"$",
"this",
"->",
"client",
"(",
"'ip'",
")",
")",
";",
"/*\n\t\t\t * set clients language\n\t\t\t */",
"$",
"this",
"->",
"client",
"->",
"language",
"=",
"CCLang",
"::",
"set_current",
"(",
"$",
"this",
"->",
"server",
"(",
"'HTTP_ACCEPT_LANGUAGE'",
")",
")",
";",
"}",
"// return the object",
"if",
"(",
"is_null",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"client",
";",
"}",
"// return a special key",
"return",
"$",
"this",
"->",
"client",
"->",
"{",
"$",
"key",
"}",
";",
"}"
]
| get the client data
@param string $key
@return mixed | [
"get",
"the",
"client",
"data"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCIn/Instance.php#L182-L243 |
19,516 | ClanCats/Core | src/classes/CCIn/Instance.php | CCIn_Instance.method | public function method( $is = null )
{
if ( !is_null( $is ) )
{
return strtoupper( $is ) === $this->method();
}
return strtoupper( $this->server( 'HTTP_X_HTTP_METHOD_OVERRIDE', $this->server( 'REQUEST_METHOD', 'GET' ) ) );
} | php | public function method( $is = null )
{
if ( !is_null( $is ) )
{
return strtoupper( $is ) === $this->method();
}
return strtoupper( $this->server( 'HTTP_X_HTTP_METHOD_OVERRIDE', $this->server( 'REQUEST_METHOD', 'GET' ) ) );
} | [
"public",
"function",
"method",
"(",
"$",
"is",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"is",
")",
")",
"{",
"return",
"strtoupper",
"(",
"$",
"is",
")",
"===",
"$",
"this",
"->",
"method",
"(",
")",
";",
"}",
"return",
"strtoupper",
"(",
"$",
"this",
"->",
"server",
"(",
"'HTTP_X_HTTP_METHOD_OVERRIDE'",
",",
"$",
"this",
"->",
"server",
"(",
"'REQUEST_METHOD'",
",",
"'GET'",
")",
")",
")",
";",
"}"
]
| get the current requesting method
GET, POST, PUT, DELETE
@param string $is
@return string | [
"get",
"the",
"current",
"requesting",
"method",
"GET",
"POST",
"PUT",
"DELETE"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCIn/Instance.php#L252-L260 |
19,517 | ClanCats/Core | src/classes/CCIn/Instance.php | CCIn_Instance.uri | public function uri( $full = false )
{
// check if we already set the current uri
if ( is_null( $this->uri ) )
{
$this->uri = $this->server('REQUEST_URI', '/' );
// fix doubled slashes
$this->uri = preg_replace( '/(\/+)/','/', $this->uri );
// remove get params
if ( !$full )
{
$this->uri = CCStr::cut( $this->uri, '?' );
}
// cut the offset from the config
$this->uri = substr( $this->uri, strlen( ClanCats::$config->get( 'url.path' ) ) );
// if null or false set to default
if ( !$this->uri )
{
$this->uri = '';
}
}
return $this->uri;
} | php | public function uri( $full = false )
{
// check if we already set the current uri
if ( is_null( $this->uri ) )
{
$this->uri = $this->server('REQUEST_URI', '/' );
// fix doubled slashes
$this->uri = preg_replace( '/(\/+)/','/', $this->uri );
// remove get params
if ( !$full )
{
$this->uri = CCStr::cut( $this->uri, '?' );
}
// cut the offset from the config
$this->uri = substr( $this->uri, strlen( ClanCats::$config->get( 'url.path' ) ) );
// if null or false set to default
if ( !$this->uri )
{
$this->uri = '';
}
}
return $this->uri;
} | [
"public",
"function",
"uri",
"(",
"$",
"full",
"=",
"false",
")",
"{",
"// check if we already set the current uri",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"uri",
")",
")",
"{",
"$",
"this",
"->",
"uri",
"=",
"$",
"this",
"->",
"server",
"(",
"'REQUEST_URI'",
",",
"'/'",
")",
";",
"// fix doubled slashes",
"$",
"this",
"->",
"uri",
"=",
"preg_replace",
"(",
"'/(\\/+)/'",
",",
"'/'",
",",
"$",
"this",
"->",
"uri",
")",
";",
"// remove get params",
"if",
"(",
"!",
"$",
"full",
")",
"{",
"$",
"this",
"->",
"uri",
"=",
"CCStr",
"::",
"cut",
"(",
"$",
"this",
"->",
"uri",
",",
"'?'",
")",
";",
"}",
"// cut the offset from the config",
"$",
"this",
"->",
"uri",
"=",
"substr",
"(",
"$",
"this",
"->",
"uri",
",",
"strlen",
"(",
"ClanCats",
"::",
"$",
"config",
"->",
"get",
"(",
"'url.path'",
")",
")",
")",
";",
"// if null or false set to default",
"if",
"(",
"!",
"$",
"this",
"->",
"uri",
")",
"{",
"$",
"this",
"->",
"uri",
"=",
"''",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"uri",
";",
"}"
]
| get the requestet uri
@param bool $full Don't cut the get params
@return string | [
"get",
"the",
"requestet",
"uri"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCIn/Instance.php#L308-L334 |
19,518 | ClanCats/Core | src/bundles/Database/Handler/Driver.php | Handler_Driver.connect | public function connect( $conf )
{
$connection_params = array();
foreach( $conf as $key => $value )
{
if ( is_string( $value ) )
{
$connection_params[ '{'.$key.'}' ] = $value;
}
}
$connection_string = \CCStr::replace( $this->connection_string, $connection_params );
$this->connection = new \PDO( $connection_string, $conf['user'], $conf['pass'], $this->connection_attributes( $conf ) );
// At the moment this will never happen because pdo is going to
// trhow an exception when the connection fails
/*if ( !$this->connection )
{
return false;
}*/
// let pdo throw exceptions
$this->connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
return true;
} | php | public function connect( $conf )
{
$connection_params = array();
foreach( $conf as $key => $value )
{
if ( is_string( $value ) )
{
$connection_params[ '{'.$key.'}' ] = $value;
}
}
$connection_string = \CCStr::replace( $this->connection_string, $connection_params );
$this->connection = new \PDO( $connection_string, $conf['user'], $conf['pass'], $this->connection_attributes( $conf ) );
// At the moment this will never happen because pdo is going to
// trhow an exception when the connection fails
/*if ( !$this->connection )
{
return false;
}*/
// let pdo throw exceptions
$this->connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
return true;
} | [
"public",
"function",
"connect",
"(",
"$",
"conf",
")",
"{",
"$",
"connection_params",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"conf",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"connection_params",
"[",
"'{'",
".",
"$",
"key",
".",
"'}'",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"$",
"connection_string",
"=",
"\\",
"CCStr",
"::",
"replace",
"(",
"$",
"this",
"->",
"connection_string",
",",
"$",
"connection_params",
")",
";",
"$",
"this",
"->",
"connection",
"=",
"new",
"\\",
"PDO",
"(",
"$",
"connection_string",
",",
"$",
"conf",
"[",
"'user'",
"]",
",",
"$",
"conf",
"[",
"'pass'",
"]",
",",
"$",
"this",
"->",
"connection_attributes",
"(",
"$",
"conf",
")",
")",
";",
"// At the moment this will never happen because pdo is going to ",
"// trhow an exception when the connection fails",
"/*if ( !$this->connection )\n\t\t{\n\t\t\treturn false;\n\t\t}*/",
"// let pdo throw exceptions",
"$",
"this",
"->",
"connection",
"->",
"setAttribute",
"(",
"\\",
"PDO",
"::",
"ATTR_ERRMODE",
",",
"\\",
"PDO",
"::",
"ERRMODE_EXCEPTION",
")",
";",
"return",
"true",
";",
"}"
]
| connect to database
@param array $conf
@return bool | [
"connect",
"to",
"database"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Handler/Driver.php#L34-L61 |
19,519 | drnkwati/guzzle-promises | src/Promise.php | Promise.__callHandler | public static function __callHandler($index, $value, array $handler)
{
/** @var PromiseInterface $promise */
$promise = $handler[0];
// The promise may have been cancelled or resolved before placing
// this thunk in the queue.
if ($promise->getState() !== self::PENDING) {
return;
}
try {
if (isset($handler[$index])) {
$promise->resolve(call_user_func($handler[$index], $value));
} elseif ($index === 1) {
// Forward resolution values as-is.
$promise->resolve($value);
} else {
// Forward rejections down the chain.
$promise->reject($value);
}
} catch (\Throwable $reason) {
$promise->reject($reason);
} catch (\Exception $reason) {
$promise->reject($reason);
}
} | php | public static function __callHandler($index, $value, array $handler)
{
/** @var PromiseInterface $promise */
$promise = $handler[0];
// The promise may have been cancelled or resolved before placing
// this thunk in the queue.
if ($promise->getState() !== self::PENDING) {
return;
}
try {
if (isset($handler[$index])) {
$promise->resolve(call_user_func($handler[$index], $value));
} elseif ($index === 1) {
// Forward resolution values as-is.
$promise->resolve($value);
} else {
// Forward rejections down the chain.
$promise->reject($value);
}
} catch (\Throwable $reason) {
$promise->reject($reason);
} catch (\Exception $reason) {
$promise->reject($reason);
}
} | [
"public",
"static",
"function",
"__callHandler",
"(",
"$",
"index",
",",
"$",
"value",
",",
"array",
"$",
"handler",
")",
"{",
"/** @var PromiseInterface $promise */",
"$",
"promise",
"=",
"$",
"handler",
"[",
"0",
"]",
";",
"// The promise may have been cancelled or resolved before placing",
"// this thunk in the queue.",
"if",
"(",
"$",
"promise",
"->",
"getState",
"(",
")",
"!==",
"self",
"::",
"PENDING",
")",
"{",
"return",
";",
"}",
"try",
"{",
"if",
"(",
"isset",
"(",
"$",
"handler",
"[",
"$",
"index",
"]",
")",
")",
"{",
"$",
"promise",
"->",
"resolve",
"(",
"call_user_func",
"(",
"$",
"handler",
"[",
"$",
"index",
"]",
",",
"$",
"value",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"index",
"===",
"1",
")",
"{",
"// Forward resolution values as-is.",
"$",
"promise",
"->",
"resolve",
"(",
"$",
"value",
")",
";",
"}",
"else",
"{",
"// Forward rejections down the chain.",
"$",
"promise",
"->",
"reject",
"(",
"$",
"value",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"reason",
")",
"{",
"$",
"promise",
"->",
"reject",
"(",
"$",
"reason",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"reason",
")",
"{",
"$",
"promise",
"->",
"reject",
"(",
"$",
"reason",
")",
";",
"}",
"}"
]
| Call a stack of handlers using a specific callback index and value.
@internal
@param int $index 1 (resolve) or 2 (reject).
@param mixed $value Value to pass to the callback.
@param array $handler Array of handler data (promise and callbacks).
@return array Returns the next group to resolve. | [
"Call",
"a",
"stack",
"of",
"handlers",
"using",
"a",
"specific",
"callback",
"index",
"and",
"value",
"."
]
| e5c302747c348d618474add41c7d442bb1bfc2cf | https://github.com/drnkwati/guzzle-promises/blob/e5c302747c348d618474add41c7d442bb1bfc2cf/src/Promise.php#L193-L219 |
19,520 | inc2734/wp-share-buttons | src/App/Contract/Model/Requester.php | Requester._add_localize_script | public function _add_localize_script() {
$handle = get_template();
if ( ! wp_script_is( get_template() ) && wp_script_is( get_stylesheet() ) ) {
$handle = get_stylesheet();
}
$handle = apply_filters( 'inc2734_wp_share_buttons_localize_script_handle', $handle );
wp_localize_script(
$handle,
'inc2734_wp_share_buttons_' . $this->service_name,
[
'endpoint' => admin_url( 'admin-ajax.php' ),
'action' => 'inc2734_wp_share_buttons_' . $this->service_name,
'_ajax_nonce' => wp_create_nonce( $this->_get_nonce_key() ),
]
);
} | php | public function _add_localize_script() {
$handle = get_template();
if ( ! wp_script_is( get_template() ) && wp_script_is( get_stylesheet() ) ) {
$handle = get_stylesheet();
}
$handle = apply_filters( 'inc2734_wp_share_buttons_localize_script_handle', $handle );
wp_localize_script(
$handle,
'inc2734_wp_share_buttons_' . $this->service_name,
[
'endpoint' => admin_url( 'admin-ajax.php' ),
'action' => 'inc2734_wp_share_buttons_' . $this->service_name,
'_ajax_nonce' => wp_create_nonce( $this->_get_nonce_key() ),
]
);
} | [
"public",
"function",
"_add_localize_script",
"(",
")",
"{",
"$",
"handle",
"=",
"get_template",
"(",
")",
";",
"if",
"(",
"!",
"wp_script_is",
"(",
"get_template",
"(",
")",
")",
"&&",
"wp_script_is",
"(",
"get_stylesheet",
"(",
")",
")",
")",
"{",
"$",
"handle",
"=",
"get_stylesheet",
"(",
")",
";",
"}",
"$",
"handle",
"=",
"apply_filters",
"(",
"'inc2734_wp_share_buttons_localize_script_handle'",
",",
"$",
"handle",
")",
";",
"wp_localize_script",
"(",
"$",
"handle",
",",
"'inc2734_wp_share_buttons_'",
".",
"$",
"this",
"->",
"service_name",
",",
"[",
"'endpoint'",
"=>",
"admin_url",
"(",
"'admin-ajax.php'",
")",
",",
"'action'",
"=>",
"'inc2734_wp_share_buttons_'",
".",
"$",
"this",
"->",
"service_name",
",",
"'_ajax_nonce'",
"=>",
"wp_create_nonce",
"(",
"$",
"this",
"->",
"_get_nonce_key",
"(",
")",
")",
",",
"]",
")",
";",
"}"
]
| Setup localize script
@return void | [
"Setup",
"localize",
"script"
]
| cd032893ca083a343f5871e855cce68f4ede3a17 | https://github.com/inc2734/wp-share-buttons/blob/cd032893ca083a343f5871e855cce68f4ede3a17/src/App/Contract/Model/Requester.php#L44-L60 |
19,521 | CakeCMS/Core | src/Utility/Macros.php | Macros.get | public function get($key = null)
{
if (Arr::key($key, $this->_data)) {
return $this->_data[$key];
}
return $this->_data;
} | php | public function get($key = null)
{
if (Arr::key($key, $this->_data)) {
return $this->_data[$key];
}
return $this->_data;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"Arr",
"::",
"key",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"_data",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_data",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"_data",
";",
"}"
]
| Get replacement val or all list.
@param null|string|int $key
@return array | [
"Get",
"replacement",
"val",
"or",
"all",
"list",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Utility/Macros.php#L60-L67 |
19,522 | CakeCMS/Core | src/Utility/Macros.php | Macros.set | public function set($key, $val)
{
$this->_data = Hash::merge([$key => $val], $this->_data);
return $this;
} | php | public function set($key, $val)
{
$this->_data = Hash::merge([$key => $val], $this->_data);
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"val",
")",
"{",
"$",
"this",
"->",
"_data",
"=",
"Hash",
"::",
"merge",
"(",
"[",
"$",
"key",
"=>",
"$",
"val",
"]",
",",
"$",
"this",
"->",
"_data",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Add new value in list.
@param string|int $key
@param string|int $val
@return $this | [
"Add",
"new",
"value",
"in",
"list",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Utility/Macros.php#L76-L80 |
19,523 | CakeCMS/Core | src/Utility/Macros.php | Macros.text | public function text($text)
{
foreach ($this->_data as $macros => $value) {
$macros = '{' . $macros . '}';
$text = preg_replace('#' . $macros . '#ius', $value, $text);
}
return $text;
} | php | public function text($text)
{
foreach ($this->_data as $macros => $value) {
$macros = '{' . $macros . '}';
$text = preg_replace('#' . $macros . '#ius', $value, $text);
}
return $text;
} | [
"public",
"function",
"text",
"(",
"$",
"text",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_data",
"as",
"$",
"macros",
"=>",
"$",
"value",
")",
"{",
"$",
"macros",
"=",
"'{'",
".",
"$",
"macros",
".",
"'}'",
";",
"$",
"text",
"=",
"preg_replace",
"(",
"'#'",
".",
"$",
"macros",
".",
"'#ius'",
",",
"$",
"value",
",",
"$",
"text",
")",
";",
"}",
"return",
"$",
"text",
";",
"}"
]
| Get replacement text.
@param string $text
@return string mixed | [
"Get",
"replacement",
"text",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Utility/Macros.php#L88-L96 |
19,524 | lode/fem | src/page.php | page.exception | public function exception($exception, $user_message=null) {
if ($exception instanceof \Exception == false) {
return $this->error('unknown exception format', response::STATUS_INTERNAL_SERVER_ERROR);
}
$exception_class = bootstrap::get_library('exception');
$this->data['exception']['current'] = $exception;
$this->data['exception']['current_trace_string'] = $exception_class::clean_paths(nl2br($exception->getTraceAsString()));
$previous = $exception->getPrevious();
if ($previous) {
$this->data['exception']['previous'] = $previous;
$this->data['exception']['previous_trace_string'] = $exception_class::clean_paths(nl2br($previous->getTraceAsString()));
}
$reason = $exception->getMessage();
$code = $exception->getCode();
$this->error($reason, $code, $user_message);
} | php | public function exception($exception, $user_message=null) {
if ($exception instanceof \Exception == false) {
return $this->error('unknown exception format', response::STATUS_INTERNAL_SERVER_ERROR);
}
$exception_class = bootstrap::get_library('exception');
$this->data['exception']['current'] = $exception;
$this->data['exception']['current_trace_string'] = $exception_class::clean_paths(nl2br($exception->getTraceAsString()));
$previous = $exception->getPrevious();
if ($previous) {
$this->data['exception']['previous'] = $previous;
$this->data['exception']['previous_trace_string'] = $exception_class::clean_paths(nl2br($previous->getTraceAsString()));
}
$reason = $exception->getMessage();
$code = $exception->getCode();
$this->error($reason, $code, $user_message);
} | [
"public",
"function",
"exception",
"(",
"$",
"exception",
",",
"$",
"user_message",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"exception",
"instanceof",
"\\",
"Exception",
"==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"error",
"(",
"'unknown exception format'",
",",
"response",
"::",
"STATUS_INTERNAL_SERVER_ERROR",
")",
";",
"}",
"$",
"exception_class",
"=",
"bootstrap",
"::",
"get_library",
"(",
"'exception'",
")",
";",
"$",
"this",
"->",
"data",
"[",
"'exception'",
"]",
"[",
"'current'",
"]",
"=",
"$",
"exception",
";",
"$",
"this",
"->",
"data",
"[",
"'exception'",
"]",
"[",
"'current_trace_string'",
"]",
"=",
"$",
"exception_class",
"::",
"clean_paths",
"(",
"nl2br",
"(",
"$",
"exception",
"->",
"getTraceAsString",
"(",
")",
")",
")",
";",
"$",
"previous",
"=",
"$",
"exception",
"->",
"getPrevious",
"(",
")",
";",
"if",
"(",
"$",
"previous",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"'exception'",
"]",
"[",
"'previous'",
"]",
"=",
"$",
"previous",
";",
"$",
"this",
"->",
"data",
"[",
"'exception'",
"]",
"[",
"'previous_trace_string'",
"]",
"=",
"$",
"exception_class",
"::",
"clean_paths",
"(",
"nl2br",
"(",
"$",
"previous",
"->",
"getTraceAsString",
"(",
")",
")",
")",
";",
"}",
"$",
"reason",
"=",
"$",
"exception",
"->",
"getMessage",
"(",
")",
";",
"$",
"code",
"=",
"$",
"exception",
"->",
"getCode",
"(",
")",
";",
"$",
"this",
"->",
"error",
"(",
"$",
"reason",
",",
"$",
"code",
",",
"$",
"user_message",
")",
";",
"}"
]
| show an error page using an exception
@param object $exception one that extends \Exception
@param string $user_message optional, human-friendly message to show to the user
@return void script execution terminates | [
"show",
"an",
"error",
"page",
"using",
"an",
"exception"
]
| c1c466c1a904d99452b341c5ae7cbc3e22b106e1 | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/page.php#L35-L54 |
19,525 | lode/fem | src/page.php | page.error | public function error($reason=null, $code=response::STATUS_INTERNAL_SERVER_ERROR, $user_message=null) {
$response = bootstrap::get_library('response');
$error_data = [
'status_code' => $code,
'status_message' => $response::get_status_message($code),
];
$error_data['status_code_is_'.$code] = true;
if ($user_message) {
$error_data['user_message'] = $user_message;
}
if (ENVIRONMENT == 'development') {
$error_data['development'] = true;
if ($reason) {
$error_data['reason'] = $reason;
}
}
if (!empty($this->data['exception']['current'])) {
if ($this->data['exception']['current'] instanceof \alsvanzelf\fem\exception) {
if (empty($error_data['user_message'])) {
$error_data['user_message'] = $this->data['exception']['current']->getUserMessage();
}
$error_data['user_action'] = $this->data['exception']['current']->getUserAction();
}
if (ENVIRONMENT != 'development') {
unset($this->data['exception']);
}
}
$response::send_status($code);
if (empty(static::$default_error_template)) {
$page_data = [
'error' => $error_data,
];
if (!empty($this->data['exception'])) {
$page_data['exception'] = $this->data['exception'];
}
static::show_default_error($page_data);
}
else {
$this->data['title'] = $error_data['status_message'];
$this->data['error'] = $error_data;
$this->show(static::$default_error_template);
}
die;
} | php | public function error($reason=null, $code=response::STATUS_INTERNAL_SERVER_ERROR, $user_message=null) {
$response = bootstrap::get_library('response');
$error_data = [
'status_code' => $code,
'status_message' => $response::get_status_message($code),
];
$error_data['status_code_is_'.$code] = true;
if ($user_message) {
$error_data['user_message'] = $user_message;
}
if (ENVIRONMENT == 'development') {
$error_data['development'] = true;
if ($reason) {
$error_data['reason'] = $reason;
}
}
if (!empty($this->data['exception']['current'])) {
if ($this->data['exception']['current'] instanceof \alsvanzelf\fem\exception) {
if (empty($error_data['user_message'])) {
$error_data['user_message'] = $this->data['exception']['current']->getUserMessage();
}
$error_data['user_action'] = $this->data['exception']['current']->getUserAction();
}
if (ENVIRONMENT != 'development') {
unset($this->data['exception']);
}
}
$response::send_status($code);
if (empty(static::$default_error_template)) {
$page_data = [
'error' => $error_data,
];
if (!empty($this->data['exception'])) {
$page_data['exception'] = $this->data['exception'];
}
static::show_default_error($page_data);
}
else {
$this->data['title'] = $error_data['status_message'];
$this->data['error'] = $error_data;
$this->show(static::$default_error_template);
}
die;
} | [
"public",
"function",
"error",
"(",
"$",
"reason",
"=",
"null",
",",
"$",
"code",
"=",
"response",
"::",
"STATUS_INTERNAL_SERVER_ERROR",
",",
"$",
"user_message",
"=",
"null",
")",
"{",
"$",
"response",
"=",
"bootstrap",
"::",
"get_library",
"(",
"'response'",
")",
";",
"$",
"error_data",
"=",
"[",
"'status_code'",
"=>",
"$",
"code",
",",
"'status_message'",
"=>",
"$",
"response",
"::",
"get_status_message",
"(",
"$",
"code",
")",
",",
"]",
";",
"$",
"error_data",
"[",
"'status_code_is_'",
".",
"$",
"code",
"]",
"=",
"true",
";",
"if",
"(",
"$",
"user_message",
")",
"{",
"$",
"error_data",
"[",
"'user_message'",
"]",
"=",
"$",
"user_message",
";",
"}",
"if",
"(",
"ENVIRONMENT",
"==",
"'development'",
")",
"{",
"$",
"error_data",
"[",
"'development'",
"]",
"=",
"true",
";",
"if",
"(",
"$",
"reason",
")",
"{",
"$",
"error_data",
"[",
"'reason'",
"]",
"=",
"$",
"reason",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"data",
"[",
"'exception'",
"]",
"[",
"'current'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"data",
"[",
"'exception'",
"]",
"[",
"'current'",
"]",
"instanceof",
"\\",
"alsvanzelf",
"\\",
"fem",
"\\",
"exception",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"error_data",
"[",
"'user_message'",
"]",
")",
")",
"{",
"$",
"error_data",
"[",
"'user_message'",
"]",
"=",
"$",
"this",
"->",
"data",
"[",
"'exception'",
"]",
"[",
"'current'",
"]",
"->",
"getUserMessage",
"(",
")",
";",
"}",
"$",
"error_data",
"[",
"'user_action'",
"]",
"=",
"$",
"this",
"->",
"data",
"[",
"'exception'",
"]",
"[",
"'current'",
"]",
"->",
"getUserAction",
"(",
")",
";",
"}",
"if",
"(",
"ENVIRONMENT",
"!=",
"'development'",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"data",
"[",
"'exception'",
"]",
")",
";",
"}",
"}",
"$",
"response",
"::",
"send_status",
"(",
"$",
"code",
")",
";",
"if",
"(",
"empty",
"(",
"static",
"::",
"$",
"default_error_template",
")",
")",
"{",
"$",
"page_data",
"=",
"[",
"'error'",
"=>",
"$",
"error_data",
",",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"data",
"[",
"'exception'",
"]",
")",
")",
"{",
"$",
"page_data",
"[",
"'exception'",
"]",
"=",
"$",
"this",
"->",
"data",
"[",
"'exception'",
"]",
";",
"}",
"static",
"::",
"show_default_error",
"(",
"$",
"page_data",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"data",
"[",
"'title'",
"]",
"=",
"$",
"error_data",
"[",
"'status_message'",
"]",
";",
"$",
"this",
"->",
"data",
"[",
"'error'",
"]",
"=",
"$",
"error_data",
";",
"$",
"this",
"->",
"show",
"(",
"static",
"::",
"$",
"default_error_template",
")",
";",
"}",
"die",
";",
"}"
]
| show an error page
@param string $reason technical description, only shown on development environments
@param int $code http status code, @see response::STATUS_*
@param string $user_message optional, human-friendly message to show to the user
@return void script execution terminates | [
"show",
"an",
"error",
"page"
]
| c1c466c1a904d99452b341c5ae7cbc3e22b106e1 | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/page.php#L64-L118 |
19,526 | lode/fem | src/page.php | page.show_default_error | private static function show_default_error($error_data) {
$template_path = \alsvanzelf\fem\ROOT_DIR.'vendor/alsvanzelf/fem/src/templates/default_error.html';
$template_content = file_get_contents($template_path);
$renderer = new \Mustache_Engine();
echo $renderer->render($template_content, $error_data);
} | php | private static function show_default_error($error_data) {
$template_path = \alsvanzelf\fem\ROOT_DIR.'vendor/alsvanzelf/fem/src/templates/default_error.html';
$template_content = file_get_contents($template_path);
$renderer = new \Mustache_Engine();
echo $renderer->render($template_content, $error_data);
} | [
"private",
"static",
"function",
"show_default_error",
"(",
"$",
"error_data",
")",
"{",
"$",
"template_path",
"=",
"\\",
"alsvanzelf",
"\\",
"fem",
"\\",
"ROOT_DIR",
".",
"'vendor/alsvanzelf/fem/src/templates/default_error.html'",
";",
"$",
"template_content",
"=",
"file_get_contents",
"(",
"$",
"template_path",
")",
";",
"$",
"renderer",
"=",
"new",
"\\",
"Mustache_Engine",
"(",
")",
";",
"echo",
"$",
"renderer",
"->",
"render",
"(",
"$",
"template_content",
",",
"$",
"error_data",
")",
";",
"}"
]
| shows a default error template in case no specific one is set
@param array $error_data as build up in ::error()
@return void however, mustache has echo'd the html | [
"shows",
"a",
"default",
"error",
"template",
"in",
"case",
"no",
"specific",
"one",
"is",
"set"
]
| c1c466c1a904d99452b341c5ae7cbc3e22b106e1 | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/page.php#L126-L132 |
19,527 | joseph-walker/vector | src/Lib/Logic.php | Logic.__orCombinator | protected static function __orCombinator(array $fs, $a)
{
return self::any(Arrays::map(function ($c) use ($a) {
return $c($a);
}, $fs));
} | php | protected static function __orCombinator(array $fs, $a)
{
return self::any(Arrays::map(function ($c) use ($a) {
return $c($a);
}, $fs));
} | [
"protected",
"static",
"function",
"__orCombinator",
"(",
"array",
"$",
"fs",
",",
"$",
"a",
")",
"{",
"return",
"self",
"::",
"any",
"(",
"Arrays",
"::",
"map",
"(",
"function",
"(",
"$",
"c",
")",
"use",
"(",
"$",
"a",
")",
"{",
"return",
"$",
"c",
"(",
"$",
"a",
")",
";",
"}",
",",
"$",
"fs",
")",
")",
";",
"}"
]
| Logical Or Combinator
Given n functions {f1, f2, ..., fn}, combine them in such a way to produce a new
function g that returns true given at least one of {f1(x), f2(x), ... fn(x)} return true.
@example
$funcF = function($x) { return $x >= 5; };
$funcG = function($x) { return $x == 0; };
$combinator = Logic::orCombinator([$funcF, $funcG]);
$combinator(9); // True
$combinator(0); // True
$combinator(2); // False
@type [(a -> Bool)] -> a -> Bool
@param array $fs array of functions to combine
@param mixed $a value to test
@return \Closure test for or using provided functions | [
"Logical",
"Or",
"Combinator"
]
| e349aa2e9e0535b1993f9fffc0476e7fd8e113fc | https://github.com/joseph-walker/vector/blob/e349aa2e9e0535b1993f9fffc0476e7fd8e113fc/src/Lib/Logic.php#L48-L53 |
19,528 | joseph-walker/vector | src/Lib/Logic.php | Logic.__andCombinator | protected static function __andCombinator(array $fs, $a)
{
return self::all(Arrays::map(function ($c) use ($a) {
return $c($a);
}, $fs));
} | php | protected static function __andCombinator(array $fs, $a)
{
return self::all(Arrays::map(function ($c) use ($a) {
return $c($a);
}, $fs));
} | [
"protected",
"static",
"function",
"__andCombinator",
"(",
"array",
"$",
"fs",
",",
"$",
"a",
")",
"{",
"return",
"self",
"::",
"all",
"(",
"Arrays",
"::",
"map",
"(",
"function",
"(",
"$",
"c",
")",
"use",
"(",
"$",
"a",
")",
"{",
"return",
"$",
"c",
"(",
"$",
"a",
")",
";",
"}",
",",
"$",
"fs",
")",
")",
";",
"}"
]
| Logical And Combinator
Given n functions {f1, f2, ..., fn}, combine them in such a way to produce a new
function g that returns true given {f1(x), f2(x), ... fn(x)} all return true.
@example
$funcF = function($x) { return $x < 5; };
$funcG = function($x) { return $x > 0; };
$combinator = Logic::andCombinator([$funcF, $funcG]);
$combinator(4); // True
$combinator(2); // True
$combinator(7); // False
@type [(a -> Bool)] -> a -> Bool
@param array $fs array of functions to combine
@param mixed $a value to test
@return \Closure test for or using provided functions | [
"Logical",
"And",
"Combinator"
]
| e349aa2e9e0535b1993f9fffc0476e7fd8e113fc | https://github.com/joseph-walker/vector/blob/e349aa2e9e0535b1993f9fffc0476e7fd8e113fc/src/Lib/Logic.php#L75-L80 |
19,529 | yuncms/framework | src/models/BaseUser.php | BaseUser.loadAllowance | public function loadAllowance($request, $action)
{
$allowance = Yii::$app->cache->get($action->controller->id . ':' . $action->id . ':' . $this->id . '_allowance');
$allowanceUpdatedAt = Yii::$app->cache->get($action->controller->id . ':' . $action->id . ':' . $this->id . '_allowance_update_at');
if ($allowance && $allowanceUpdatedAt) {
return [$allowance, $allowanceUpdatedAt];
} else {
return [Yii::$app->settings->get('requestRateLimit', 'user', 60), time()];
}
} | php | public function loadAllowance($request, $action)
{
$allowance = Yii::$app->cache->get($action->controller->id . ':' . $action->id . ':' . $this->id . '_allowance');
$allowanceUpdatedAt = Yii::$app->cache->get($action->controller->id . ':' . $action->id . ':' . $this->id . '_allowance_update_at');
if ($allowance && $allowanceUpdatedAt) {
return [$allowance, $allowanceUpdatedAt];
} else {
return [Yii::$app->settings->get('requestRateLimit', 'user', 60), time()];
}
} | [
"public",
"function",
"loadAllowance",
"(",
"$",
"request",
",",
"$",
"action",
")",
"{",
"$",
"allowance",
"=",
"Yii",
"::",
"$",
"app",
"->",
"cache",
"->",
"get",
"(",
"$",
"action",
"->",
"controller",
"->",
"id",
".",
"':'",
".",
"$",
"action",
"->",
"id",
".",
"':'",
".",
"$",
"this",
"->",
"id",
".",
"'_allowance'",
")",
";",
"$",
"allowanceUpdatedAt",
"=",
"Yii",
"::",
"$",
"app",
"->",
"cache",
"->",
"get",
"(",
"$",
"action",
"->",
"controller",
"->",
"id",
".",
"':'",
".",
"$",
"action",
"->",
"id",
".",
"':'",
".",
"$",
"this",
"->",
"id",
".",
"'_allowance_update_at'",
")",
";",
"if",
"(",
"$",
"allowance",
"&&",
"$",
"allowanceUpdatedAt",
")",
"{",
"return",
"[",
"$",
"allowance",
",",
"$",
"allowanceUpdatedAt",
"]",
";",
"}",
"else",
"{",
"return",
"[",
"Yii",
"::",
"$",
"app",
"->",
"settings",
"->",
"get",
"(",
"'requestRateLimit'",
",",
"'user'",
",",
"60",
")",
",",
"time",
"(",
")",
"]",
";",
"}",
"}"
]
| Loads the number of allowed requests and the corresponding timestamp from a persistent storage.
@param \yii\web\Request $request the current request
@param \yii\base\Action $action the action to be executed
@return array an array of two elements. The first element is the number of allowed requests,
and the second element is the corresponding UNIX timestamp. | [
"Loads",
"the",
"number",
"of",
"allowed",
"requests",
"and",
"the",
"corresponding",
"timestamp",
"from",
"a",
"persistent",
"storage",
"."
]
| af42e28ea4ae15ab8eead3f6d119f93863b94154 | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/models/BaseUser.php#L444-L453 |
19,530 | yuncms/framework | src/models/BaseUser.php | BaseUser.saveAllowance | public function saveAllowance($request, $action, $allowance, $timestamp)
{
Yii::$app->cache->set($action->controller->id . ':' . $action->id . ':' . $this->id . '_allowance', $allowance, 60);
Yii::$app->cache->set($action->controller->id . ':' . $action->id . ':' . $this->id . '_allowance_update_at', $timestamp, 60);
} | php | public function saveAllowance($request, $action, $allowance, $timestamp)
{
Yii::$app->cache->set($action->controller->id . ':' . $action->id . ':' . $this->id . '_allowance', $allowance, 60);
Yii::$app->cache->set($action->controller->id . ':' . $action->id . ':' . $this->id . '_allowance_update_at', $timestamp, 60);
} | [
"public",
"function",
"saveAllowance",
"(",
"$",
"request",
",",
"$",
"action",
",",
"$",
"allowance",
",",
"$",
"timestamp",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"cache",
"->",
"set",
"(",
"$",
"action",
"->",
"controller",
"->",
"id",
".",
"':'",
".",
"$",
"action",
"->",
"id",
".",
"':'",
".",
"$",
"this",
"->",
"id",
".",
"'_allowance'",
",",
"$",
"allowance",
",",
"60",
")",
";",
"Yii",
"::",
"$",
"app",
"->",
"cache",
"->",
"set",
"(",
"$",
"action",
"->",
"controller",
"->",
"id",
".",
"':'",
".",
"$",
"action",
"->",
"id",
".",
"':'",
".",
"$",
"this",
"->",
"id",
".",
"'_allowance_update_at'",
",",
"$",
"timestamp",
",",
"60",
")",
";",
"}"
]
| Saves the number of allowed requests and the corresponding timestamp to a persistent storage.
@param \yii\web\Request $request the current request
@param \yii\base\Action $action the action to be executed
@param int $allowance the number of allowed requests remaining.
@param int $timestamp the current timestamp. | [
"Saves",
"the",
"number",
"of",
"allowed",
"requests",
"and",
"the",
"corresponding",
"timestamp",
"to",
"a",
"persistent",
"storage",
"."
]
| af42e28ea4ae15ab8eead3f6d119f93863b94154 | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/models/BaseUser.php#L462-L466 |
19,531 | necrox87/yii2-nudity-detector | Image.php | Image.rgbXY | public function rgbXY($x, $y) {
$color = $this->colorXY($x, $y);
return array(($color >> 16) & 0xFF, ($color >> 8) & 0xFF, $color & 0xFF);
} | php | public function rgbXY($x, $y) {
$color = $this->colorXY($x, $y);
return array(($color >> 16) & 0xFF, ($color >> 8) & 0xFF, $color & 0xFF);
} | [
"public",
"function",
"rgbXY",
"(",
"$",
"x",
",",
"$",
"y",
")",
"{",
"$",
"color",
"=",
"$",
"this",
"->",
"colorXY",
"(",
"$",
"x",
",",
"$",
"y",
")",
";",
"return",
"array",
"(",
"(",
"$",
"color",
">>",
"16",
")",
"&",
"0xFF",
",",
"(",
"$",
"color",
">>",
"8",
")",
"&",
"0xFF",
",",
"$",
"color",
"&",
"0xFF",
")",
";",
"}"
]
| Returns RGB array of pixel's color
@param int $x
@param int $y | [
"Returns",
"RGB",
"array",
"of",
"pixel",
"s",
"color"
]
| 59474b1480f5ed53a17f06551318d30c3765d143 | https://github.com/necrox87/yii2-nudity-detector/blob/59474b1480f5ed53a17f06551318d30c3765d143/Image.php#L110-L113 |
19,532 | necrox87/yii2-nudity-detector | Image.php | Image.create | public function create() {
switch($this->info[2]) {
case IMAGETYPE_JPEG:
$this->resource = imagecreatefromjpeg($this->file);
break;
case IMAGETYPE_GIF:
$this->resource = imagecreatefromgif($this->file);
break;
case IMAGETYPE_PNG:
$this->resource = imagecreatefrompng($this->file);
break;
default:
throw new Exception('Image type is not supported');
break;
}
} | php | public function create() {
switch($this->info[2]) {
case IMAGETYPE_JPEG:
$this->resource = imagecreatefromjpeg($this->file);
break;
case IMAGETYPE_GIF:
$this->resource = imagecreatefromgif($this->file);
break;
case IMAGETYPE_PNG:
$this->resource = imagecreatefrompng($this->file);
break;
default:
throw new Exception('Image type is not supported');
break;
}
} | [
"public",
"function",
"create",
"(",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"info",
"[",
"2",
"]",
")",
"{",
"case",
"IMAGETYPE_JPEG",
":",
"$",
"this",
"->",
"resource",
"=",
"imagecreatefromjpeg",
"(",
"$",
"this",
"->",
"file",
")",
";",
"break",
";",
"case",
"IMAGETYPE_GIF",
":",
"$",
"this",
"->",
"resource",
"=",
"imagecreatefromgif",
"(",
"$",
"this",
"->",
"file",
")",
";",
"break",
";",
"case",
"IMAGETYPE_PNG",
":",
"$",
"this",
"->",
"resource",
"=",
"imagecreatefrompng",
"(",
"$",
"this",
"->",
"file",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"Exception",
"(",
"'Image type is not supported'",
")",
";",
"break",
";",
"}",
"}"
]
| Create an image resource | [
"Create",
"an",
"image",
"resource"
]
| 59474b1480f5ed53a17f06551318d30c3765d143 | https://github.com/necrox87/yii2-nudity-detector/blob/59474b1480f5ed53a17f06551318d30c3765d143/Image.php#L119-L134 |
19,533 | necrox87/yii2-nudity-detector | Image.php | Image.save | public function save($file, $type = IMAGETYPE_JPEG, $quality = 75,
$permissions = false) {
// create directory if necessary
$dir = dirname($file);
if(!file_exists($dir)) {
$mask = umask();
mkdir($dir, 0777, true);
umask($mask);
}
switch($type) {
case IMAGETYPE_JPEG:
imagejpeg($this->resource, $file, $quality);
break;
case IMAGETYPE_GIF:
imagegif($this->resource, $file);
break;
case IMAGETYPE_PNG:
imagepng($this->resource, $file);
break;
default:
throw new Exception('Image type is not supported');
break;
}
// change image rights
if($permissions !== false) chmod($file, $permissions);
// for method chaining
return $this;
} | php | public function save($file, $type = IMAGETYPE_JPEG, $quality = 75,
$permissions = false) {
// create directory if necessary
$dir = dirname($file);
if(!file_exists($dir)) {
$mask = umask();
mkdir($dir, 0777, true);
umask($mask);
}
switch($type) {
case IMAGETYPE_JPEG:
imagejpeg($this->resource, $file, $quality);
break;
case IMAGETYPE_GIF:
imagegif($this->resource, $file);
break;
case IMAGETYPE_PNG:
imagepng($this->resource, $file);
break;
default:
throw new Exception('Image type is not supported');
break;
}
// change image rights
if($permissions !== false) chmod($file, $permissions);
// for method chaining
return $this;
} | [
"public",
"function",
"save",
"(",
"$",
"file",
",",
"$",
"type",
"=",
"IMAGETYPE_JPEG",
",",
"$",
"quality",
"=",
"75",
",",
"$",
"permissions",
"=",
"false",
")",
"{",
"// create directory if necessary",
"$",
"dir",
"=",
"dirname",
"(",
"$",
"file",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"mask",
"=",
"umask",
"(",
")",
";",
"mkdir",
"(",
"$",
"dir",
",",
"0777",
",",
"true",
")",
";",
"umask",
"(",
"$",
"mask",
")",
";",
"}",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"IMAGETYPE_JPEG",
":",
"imagejpeg",
"(",
"$",
"this",
"->",
"resource",
",",
"$",
"file",
",",
"$",
"quality",
")",
";",
"break",
";",
"case",
"IMAGETYPE_GIF",
":",
"imagegif",
"(",
"$",
"this",
"->",
"resource",
",",
"$",
"file",
")",
";",
"break",
";",
"case",
"IMAGETYPE_PNG",
":",
"imagepng",
"(",
"$",
"this",
"->",
"resource",
",",
"$",
"file",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"Exception",
"(",
"'Image type is not supported'",
")",
";",
"break",
";",
"}",
"// change image rights",
"if",
"(",
"$",
"permissions",
"!==",
"false",
")",
"chmod",
"(",
"$",
"file",
",",
"$",
"permissions",
")",
";",
"// for method chaining",
"return",
"$",
"this",
";",
"}"
]
| Save image to file
@param string $file File path
@param int $type Image type constant
@param int $quality JPEG compression quality from 0 to 100
@param int $permissions Unix file permissions | [
"Save",
"image",
"to",
"file"
]
| 59474b1480f5ed53a17f06551318d30c3765d143 | https://github.com/necrox87/yii2-nudity-detector/blob/59474b1480f5ed53a17f06551318d30c3765d143/Image.php#L162-L193 |
19,534 | necrox87/yii2-nudity-detector | Image.php | Image.fitResize | public function fitResize($max_width = 150, $max_height = 150, $min_width = 20, $min_height = 20) {
$kw = $max_width / $this->width();
$kh = $max_height / $this->height();
if($kw > $kh) {
$new_h = $max_height;
$new_w = round($kh * $this->width());
} else {
$new_w = $max_width;
$new_h = round($kw * $this->height());
}
$this->resize($new_w, $new_h);
// Method chaining
return $this;
} | php | public function fitResize($max_width = 150, $max_height = 150, $min_width = 20, $min_height = 20) {
$kw = $max_width / $this->width();
$kh = $max_height / $this->height();
if($kw > $kh) {
$new_h = $max_height;
$new_w = round($kh * $this->width());
} else {
$new_w = $max_width;
$new_h = round($kw * $this->height());
}
$this->resize($new_w, $new_h);
// Method chaining
return $this;
} | [
"public",
"function",
"fitResize",
"(",
"$",
"max_width",
"=",
"150",
",",
"$",
"max_height",
"=",
"150",
",",
"$",
"min_width",
"=",
"20",
",",
"$",
"min_height",
"=",
"20",
")",
"{",
"$",
"kw",
"=",
"$",
"max_width",
"/",
"$",
"this",
"->",
"width",
"(",
")",
";",
"$",
"kh",
"=",
"$",
"max_height",
"/",
"$",
"this",
"->",
"height",
"(",
")",
";",
"if",
"(",
"$",
"kw",
">",
"$",
"kh",
")",
"{",
"$",
"new_h",
"=",
"$",
"max_height",
";",
"$",
"new_w",
"=",
"round",
"(",
"$",
"kh",
"*",
"$",
"this",
"->",
"width",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"new_w",
"=",
"$",
"max_width",
";",
"$",
"new_h",
"=",
"round",
"(",
"$",
"kw",
"*",
"$",
"this",
"->",
"height",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"resize",
"(",
"$",
"new_w",
",",
"$",
"new_h",
")",
";",
"// Method chaining",
"return",
"$",
"this",
";",
"}"
]
| Fit the image with the same proportion into an area
@param int $max_width
@param int $max_height
@param int $min_width
@param int $min_height
@return Image | [
"Fit",
"the",
"image",
"with",
"the",
"same",
"proportion",
"into",
"an",
"area"
]
| 59474b1480f5ed53a17f06551318d30c3765d143 | https://github.com/necrox87/yii2-nudity-detector/blob/59474b1480f5ed53a17f06551318d30c3765d143/Image.php#L258-L272 |
19,535 | necrox87/yii2-nudity-detector | Image.php | Image.scaleResize | public function scaleResize($width, $height) {
// calculate source coordinates
$kw = $this->width() / $width;
$kh = $this->height() / $height;
if($kh < $kw) {
$src_h = $this->height();
$src_y = 0;
$src_w = round($kh * $width);
$src_x = round(($this->width() - $src_w) / 2);
} else {
$src_h = round($kh * $height);
$src_y = round(($this->height() - $src_h) / 2);
$src_w = $this->width();
$src_x = 0;
}
// copy new image
$new = imagecreatetruecolor($width, $height);
imagecopyresampled($new, $this->resource, 0, 0, $src_x, $src_y,
$width, $height, $src_w, $src_h);
$this->resource = $new;
// for method chaining
return $this;
} | php | public function scaleResize($width, $height) {
// calculate source coordinates
$kw = $this->width() / $width;
$kh = $this->height() / $height;
if($kh < $kw) {
$src_h = $this->height();
$src_y = 0;
$src_w = round($kh * $width);
$src_x = round(($this->width() - $src_w) / 2);
} else {
$src_h = round($kh * $height);
$src_y = round(($this->height() - $src_h) / 2);
$src_w = $this->width();
$src_x = 0;
}
// copy new image
$new = imagecreatetruecolor($width, $height);
imagecopyresampled($new, $this->resource, 0, 0, $src_x, $src_y,
$width, $height, $src_w, $src_h);
$this->resource = $new;
// for method chaining
return $this;
} | [
"public",
"function",
"scaleResize",
"(",
"$",
"width",
",",
"$",
"height",
")",
"{",
"// calculate source coordinates",
"$",
"kw",
"=",
"$",
"this",
"->",
"width",
"(",
")",
"/",
"$",
"width",
";",
"$",
"kh",
"=",
"$",
"this",
"->",
"height",
"(",
")",
"/",
"$",
"height",
";",
"if",
"(",
"$",
"kh",
"<",
"$",
"kw",
")",
"{",
"$",
"src_h",
"=",
"$",
"this",
"->",
"height",
"(",
")",
";",
"$",
"src_y",
"=",
"0",
";",
"$",
"src_w",
"=",
"round",
"(",
"$",
"kh",
"*",
"$",
"width",
")",
";",
"$",
"src_x",
"=",
"round",
"(",
"(",
"$",
"this",
"->",
"width",
"(",
")",
"-",
"$",
"src_w",
")",
"/",
"2",
")",
";",
"}",
"else",
"{",
"$",
"src_h",
"=",
"round",
"(",
"$",
"kh",
"*",
"$",
"height",
")",
";",
"$",
"src_y",
"=",
"round",
"(",
"(",
"$",
"this",
"->",
"height",
"(",
")",
"-",
"$",
"src_h",
")",
"/",
"2",
")",
";",
"$",
"src_w",
"=",
"$",
"this",
"->",
"width",
"(",
")",
";",
"$",
"src_x",
"=",
"0",
";",
"}",
"// copy new image",
"$",
"new",
"=",
"imagecreatetruecolor",
"(",
"$",
"width",
",",
"$",
"height",
")",
";",
"imagecopyresampled",
"(",
"$",
"new",
",",
"$",
"this",
"->",
"resource",
",",
"0",
",",
"0",
",",
"$",
"src_x",
",",
"$",
"src_y",
",",
"$",
"width",
",",
"$",
"height",
",",
"$",
"src_w",
",",
"$",
"src_h",
")",
";",
"$",
"this",
"->",
"resource",
"=",
"$",
"new",
";",
"// for method chaining",
"return",
"$",
"this",
";",
"}"
]
| Resize image correctly scaled and than crop
the necessary area
@param int $width New width
@param int $height New height | [
"Resize",
"image",
"correctly",
"scaled",
"and",
"than",
"crop",
"the",
"necessary",
"area"
]
| 59474b1480f5ed53a17f06551318d30c3765d143 | https://github.com/necrox87/yii2-nudity-detector/blob/59474b1480f5ed53a17f06551318d30c3765d143/Image.php#L281-L306 |
19,536 | okitcom/ok-lib-php | src/Service/BaseService.php | BaseService.getAttribute | public function getAttribute($attributes, $name) {
foreach($attributes as $a) {
if ($a->key == $name) {
return $a->value;
}
}
return null;
} | php | public function getAttribute($attributes, $name) {
foreach($attributes as $a) {
if ($a->key == $name) {
return $a->value;
}
}
return null;
} | [
"public",
"function",
"getAttribute",
"(",
"$",
"attributes",
",",
"$",
"name",
")",
"{",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"a",
")",
"{",
"if",
"(",
"$",
"a",
"->",
"key",
"==",
"$",
"name",
")",
"{",
"return",
"$",
"a",
"->",
"value",
";",
"}",
"}",
"return",
"null",
";",
"}"
]
| Returns the value of attribute with name
@param $attributes array of attributes
@param $name string Attribute's name
@return mixed Attribute value | [
"Returns",
"the",
"value",
"of",
"attribute",
"with",
"name"
]
| 1f441f3d216af7c952788e864bfe66bc4f089467 | https://github.com/okitcom/ok-lib-php/blob/1f441f3d216af7c952788e864bfe66bc4f089467/src/Service/BaseService.php#L33-L40 |
19,537 | shiftio/safestream-php-sdk | src/Http/SafeStreamHttpClient.php | SafeStreamHttpClient.getAuthToken | public function getAuthToken() {
try {
$response = $this->client->request('GET', "authenticate/accessToken", ['headers' => [
'x-api-client-id' => $this->clientId,
'x-api-key' => $this->apiKey
]]);
$this->authToken = json_decode($response->getBody())->token;
return $this->authToken;
} catch (GuzzleHttp\Exception\RequestException $e) {
$this->handleExceptionResult($e);
}
} | php | public function getAuthToken() {
try {
$response = $this->client->request('GET', "authenticate/accessToken", ['headers' => [
'x-api-client-id' => $this->clientId,
'x-api-key' => $this->apiKey
]]);
$this->authToken = json_decode($response->getBody())->token;
return $this->authToken;
} catch (GuzzleHttp\Exception\RequestException $e) {
$this->handleExceptionResult($e);
}
} | [
"public",
"function",
"getAuthToken",
"(",
")",
"{",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'GET'",
",",
"\"authenticate/accessToken\"",
",",
"[",
"'headers'",
"=>",
"[",
"'x-api-client-id'",
"=>",
"$",
"this",
"->",
"clientId",
",",
"'x-api-key'",
"=>",
"$",
"this",
"->",
"apiKey",
"]",
"]",
")",
";",
"$",
"this",
"->",
"authToken",
"=",
"json_decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
")",
"->",
"token",
";",
"return",
"$",
"this",
"->",
"authToken",
";",
"}",
"catch",
"(",
"GuzzleHttp",
"\\",
"Exception",
"\\",
"RequestException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"handleExceptionResult",
"(",
"$",
"e",
")",
";",
"}",
"}"
]
| Gets an authorization token using the clients API key. Most requests to the SafeStream API
require an authorization token.
@return mixed: The JSON decoded response
@throws SafeStreamHttpAuthException
@throws SafeStreamHttpBadRequestException
@throws SafeStreamHttpException
@throws SafeStreamHttpThrottleException | [
"Gets",
"an",
"authorization",
"token",
"using",
"the",
"clients",
"API",
"key",
".",
"Most",
"requests",
"to",
"the",
"SafeStream",
"API",
"require",
"an",
"authorization",
"token",
"."
]
| 1957cd5574725b24da1bbff9059aa30a9ca123c2 | https://github.com/shiftio/safestream-php-sdk/blob/1957cd5574725b24da1bbff9059aa30a9ca123c2/src/Http/SafeStreamHttpClient.php#L167-L180 |
19,538 | jacobemerick/pqp | src/Display.php | Display.getReadableTime | protected function getReadableTime($time, $percision = 3)
{
$unit = 's';
if ($time < 1) {
$time *= 1000;
$percision = 0;
$unit = 'ms';
} elseif ($time > 60) {
$time /= 60;
$unit = 'm';
}
$time = number_format($time, $percision);
return "{$time} {$unit}";
} | php | protected function getReadableTime($time, $percision = 3)
{
$unit = 's';
if ($time < 1) {
$time *= 1000;
$percision = 0;
$unit = 'ms';
} elseif ($time > 60) {
$time /= 60;
$unit = 'm';
}
$time = number_format($time, $percision);
return "{$time} {$unit}";
} | [
"protected",
"function",
"getReadableTime",
"(",
"$",
"time",
",",
"$",
"percision",
"=",
"3",
")",
"{",
"$",
"unit",
"=",
"'s'",
";",
"if",
"(",
"$",
"time",
"<",
"1",
")",
"{",
"$",
"time",
"*=",
"1000",
";",
"$",
"percision",
"=",
"0",
";",
"$",
"unit",
"=",
"'ms'",
";",
"}",
"elseif",
"(",
"$",
"time",
">",
"60",
")",
"{",
"$",
"time",
"/=",
"60",
";",
"$",
"unit",
"=",
"'m'",
";",
"}",
"$",
"time",
"=",
"number_format",
"(",
"$",
"time",
",",
"$",
"percision",
")",
";",
"return",
"\"{$time} {$unit}\"",
";",
"}"
]
| Formatter for human-readable time
Only handles time up to 60 minutes gracefully
@param double $time
@param integer $percision
@return string | [
"Formatter",
"for",
"human",
"-",
"readable",
"time",
"Only",
"handles",
"time",
"up",
"to",
"60",
"minutes",
"gracefully"
]
| 08276f050425d1ab71e7ca3b897eb8c409ccbe70 | https://github.com/jacobemerick/pqp/blob/08276f050425d1ab71e7ca3b897eb8c409ccbe70/src/Display.php#L311-L324 |
19,539 | jacobemerick/pqp | src/Display.php | Display.getReadableMemory | protected function getReadableMemory($size, $percision = 2)
{
$unitOptions = array('b', 'k', 'M', 'G');
$base = log($size, 1024);
$memory = round(pow(1024, $base - floor($base)), $percision);
$unit = $unitOptions[floor($base)];
return "{$memory} {$unit}";
} | php | protected function getReadableMemory($size, $percision = 2)
{
$unitOptions = array('b', 'k', 'M', 'G');
$base = log($size, 1024);
$memory = round(pow(1024, $base - floor($base)), $percision);
$unit = $unitOptions[floor($base)];
return "{$memory} {$unit}";
} | [
"protected",
"function",
"getReadableMemory",
"(",
"$",
"size",
",",
"$",
"percision",
"=",
"2",
")",
"{",
"$",
"unitOptions",
"=",
"array",
"(",
"'b'",
",",
"'k'",
",",
"'M'",
",",
"'G'",
")",
";",
"$",
"base",
"=",
"log",
"(",
"$",
"size",
",",
"1024",
")",
";",
"$",
"memory",
"=",
"round",
"(",
"pow",
"(",
"1024",
",",
"$",
"base",
"-",
"floor",
"(",
"$",
"base",
")",
")",
",",
"$",
"percision",
")",
";",
"$",
"unit",
"=",
"$",
"unitOptions",
"[",
"floor",
"(",
"$",
"base",
")",
"]",
";",
"return",
"\"{$memory} {$unit}\"",
";",
"}"
]
| Formatter for human-readable memory
Only handles time up to a few gigs gracefully
@param double $size
@param integer $percision | [
"Formatter",
"for",
"human",
"-",
"readable",
"memory",
"Only",
"handles",
"time",
"up",
"to",
"a",
"few",
"gigs",
"gracefully"
]
| 08276f050425d1ab71e7ca3b897eb8c409ccbe70 | https://github.com/jacobemerick/pqp/blob/08276f050425d1ab71e7ca3b897eb8c409ccbe70/src/Display.php#L333-L342 |
19,540 | hendrikmaus/reynaldo | src/Elements/BaseElement.php | BaseElement.addContentElement | public function addContentElement(ApiElement $element)
{
$newContent = [];
$rawElements = [];
$content = $this->getContent();
if ($this->hasCopy()) {
$newContent[] = array_shift($content);
}
foreach ($content as $resourceGroup) {
if (!is_array($resourceGroup)) {
$newContent[] = array_shift($content);
} else {
$rawElements[] = $resourceGroup;
}
}
array_shift($rawElements);
$newContent[] = $element;
$this->content = array_merge($newContent, $rawElements);
} | php | public function addContentElement(ApiElement $element)
{
$newContent = [];
$rawElements = [];
$content = $this->getContent();
if ($this->hasCopy()) {
$newContent[] = array_shift($content);
}
foreach ($content as $resourceGroup) {
if (!is_array($resourceGroup)) {
$newContent[] = array_shift($content);
} else {
$rawElements[] = $resourceGroup;
}
}
array_shift($rawElements);
$newContent[] = $element;
$this->content = array_merge($newContent, $rawElements);
} | [
"public",
"function",
"addContentElement",
"(",
"ApiElement",
"$",
"element",
")",
"{",
"$",
"newContent",
"=",
"[",
"]",
";",
"$",
"rawElements",
"=",
"[",
"]",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"getContent",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasCopy",
"(",
")",
")",
"{",
"$",
"newContent",
"[",
"]",
"=",
"array_shift",
"(",
"$",
"content",
")",
";",
"}",
"foreach",
"(",
"$",
"content",
"as",
"$",
"resourceGroup",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"resourceGroup",
")",
")",
"{",
"$",
"newContent",
"[",
"]",
"=",
"array_shift",
"(",
"$",
"content",
")",
";",
"}",
"else",
"{",
"$",
"rawElements",
"[",
"]",
"=",
"$",
"resourceGroup",
";",
"}",
"}",
"array_shift",
"(",
"$",
"rawElements",
")",
";",
"$",
"newContent",
"[",
"]",
"=",
"$",
"element",
";",
"$",
"this",
"->",
"content",
"=",
"array_merge",
"(",
"$",
"newContent",
",",
"$",
"rawElements",
")",
";",
"}"
]
| Add content element to the current content
This method has to be used sequentially while querying the recursive
element tree. It will replace the raw content element one by one, top to bottom.
Example:
- copy element
- raw array element (1)
- raw array element (2)
Calling `addContentElement` with a resource element:
- copy element
- resource element
- raw array element (2)
As you can see `raw array element (1)` was replaced with `resource element`
So *you* need to make sure that *you* turned the raw array element into the resource element.
@param ApiElement $element | [
"Add",
"content",
"element",
"to",
"the",
"current",
"content"
]
| be100f56e8f39d86d16ce9222838d20f462e8678 | https://github.com/hendrikmaus/reynaldo/blob/be100f56e8f39d86d16ce9222838d20f462e8678/src/Elements/BaseElement.php#L52-L74 |
19,541 | hendrikmaus/reynaldo | src/Elements/BaseElement.php | BaseElement.getCopyText | public function getCopyText()
{
$content = $this->getContent();
$copy = array_shift($content);
if (!is_array($copy)) {
return null;
}
if ($copy['element'] !== 'copy') {
return null;
}
return $copy['content'];
} | php | public function getCopyText()
{
$content = $this->getContent();
$copy = array_shift($content);
if (!is_array($copy)) {
return null;
}
if ($copy['element'] !== 'copy') {
return null;
}
return $copy['content'];
} | [
"public",
"function",
"getCopyText",
"(",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"getContent",
"(",
")",
";",
"$",
"copy",
"=",
"array_shift",
"(",
"$",
"content",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"copy",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"copy",
"[",
"'element'",
"]",
"!==",
"'copy'",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"copy",
"[",
"'content'",
"]",
";",
"}"
]
| Get the copy text of the current element; raw markdown likely
@api
@return string|null | [
"Get",
"the",
"copy",
"text",
"of",
"the",
"current",
"element",
";",
"raw",
"markdown",
"likely"
]
| be100f56e8f39d86d16ce9222838d20f462e8678 | https://github.com/hendrikmaus/reynaldo/blob/be100f56e8f39d86d16ce9222838d20f462e8678/src/Elements/BaseElement.php#L109-L123 |
19,542 | hendrikmaus/reynaldo | src/Elements/BaseElement.php | BaseElement.hasClass | public function hasClass($className)
{
foreach ($this->meta['classes'] as $classInMeta) {
if ($classInMeta === $className) {
return true;
}
}
return false;
} | php | public function hasClass($className)
{
foreach ($this->meta['classes'] as $classInMeta) {
if ($classInMeta === $className) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasClass",
"(",
"$",
"className",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"meta",
"[",
"'classes'",
"]",
"as",
"$",
"classInMeta",
")",
"{",
"if",
"(",
"$",
"classInMeta",
"===",
"$",
"className",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| Check whether or not this element has a given class
@param string $className e.g. 'resourceGroup', 'messageBody'
@return bool | [
"Check",
"whether",
"or",
"not",
"this",
"element",
"has",
"a",
"given",
"class"
]
| be100f56e8f39d86d16ce9222838d20f462e8678 | https://github.com/hendrikmaus/reynaldo/blob/be100f56e8f39d86d16ce9222838d20f462e8678/src/Elements/BaseElement.php#L199-L208 |
19,543 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Section.php | PHPWord_Section.addTOC | public function addTOC($styleFont = null, $styleTOC = null) {
$toc = new PHPWord_TOC($styleFont, $styleTOC);
$this->_elementCollection[] = $toc;
return $toc;
} | php | public function addTOC($styleFont = null, $styleTOC = null) {
$toc = new PHPWord_TOC($styleFont, $styleTOC);
$this->_elementCollection[] = $toc;
return $toc;
} | [
"public",
"function",
"addTOC",
"(",
"$",
"styleFont",
"=",
"null",
",",
"$",
"styleTOC",
"=",
"null",
")",
"{",
"$",
"toc",
"=",
"new",
"PHPWord_TOC",
"(",
"$",
"styleFont",
",",
"$",
"styleTOC",
")",
";",
"$",
"this",
"->",
"_elementCollection",
"[",
"]",
"=",
"$",
"toc",
";",
"return",
"$",
"toc",
";",
"}"
]
| Add a Table-of-Contents Element
@param mixed $styleFont
@param mixed $styleTOC
@return PHPWord_TOC | [
"Add",
"a",
"Table",
"-",
"of",
"-",
"Contents",
"Element"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section.php#L269-L273 |
19,544 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Section.php | PHPWord_Section.addTitle | public function addTitle($text, $depth = 1) {
$styles = PHPWord_Style::getStyles();
if(array_key_exists('Heading_'.$depth, $styles)) {
$style = 'Heading'.$depth;
} else {
$style = null;
}
$title = new PHPWord_Section_Title($text, $depth, $style);
$data = PHPWord_TOC::addTitle($text, $depth);
$anchor = $data[0];
$bookmarkId = $data[1];
$title->setAnchor($anchor);
$title->setBookmarkId($bookmarkId);
$this->_elementCollection[] = $title;
return $title;
} | php | public function addTitle($text, $depth = 1) {
$styles = PHPWord_Style::getStyles();
if(array_key_exists('Heading_'.$depth, $styles)) {
$style = 'Heading'.$depth;
} else {
$style = null;
}
$title = new PHPWord_Section_Title($text, $depth, $style);
$data = PHPWord_TOC::addTitle($text, $depth);
$anchor = $data[0];
$bookmarkId = $data[1];
$title->setAnchor($anchor);
$title->setBookmarkId($bookmarkId);
$this->_elementCollection[] = $title;
return $title;
} | [
"public",
"function",
"addTitle",
"(",
"$",
"text",
",",
"$",
"depth",
"=",
"1",
")",
"{",
"$",
"styles",
"=",
"PHPWord_Style",
"::",
"getStyles",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'Heading_'",
".",
"$",
"depth",
",",
"$",
"styles",
")",
")",
"{",
"$",
"style",
"=",
"'Heading'",
".",
"$",
"depth",
";",
"}",
"else",
"{",
"$",
"style",
"=",
"null",
";",
"}",
"$",
"title",
"=",
"new",
"PHPWord_Section_Title",
"(",
"$",
"text",
",",
"$",
"depth",
",",
"$",
"style",
")",
";",
"$",
"data",
"=",
"PHPWord_TOC",
"::",
"addTitle",
"(",
"$",
"text",
",",
"$",
"depth",
")",
";",
"$",
"anchor",
"=",
"$",
"data",
"[",
"0",
"]",
";",
"$",
"bookmarkId",
"=",
"$",
"data",
"[",
"1",
"]",
";",
"$",
"title",
"->",
"setAnchor",
"(",
"$",
"anchor",
")",
";",
"$",
"title",
"->",
"setBookmarkId",
"(",
"$",
"bookmarkId",
")",
";",
"$",
"this",
"->",
"_elementCollection",
"[",
"]",
"=",
"$",
"title",
";",
"return",
"$",
"title",
";",
"}"
]
| Add a Title Element
@param string $text
@param int $depth
@return PHPWord_Section_Title | [
"Add",
"a",
"Title",
"Element"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section.php#L282-L301 |
19,545 | dreamfactorysoftware/df-file | src/Components/RemoteFileSystem.php | RemoteFileSystem.deleteContainers | public function deleteContainers($containers, $force = false)
{
if (!empty($containers)) {
if (!isset($containers[0])) {
// single folder, make into array
$containers = [$containers];
}
foreach ($containers as $key => $folder) {
try {
// path is full path, name is relative to root, take either
$name = array_get($folder, 'name', trim(array_get($folder, 'path'), '/'));
if (!empty($name)) {
$this->deleteContainer($name, $force);
} else {
throw new DfException('No name found for container in delete request.');
}
} catch (\Exception $ex) {
// error whole batch here?
$containers[$key]['error'] = ['message' => $ex->getMessage(), 'code' => $ex->getCode()];
}
}
}
return $containers;
} | php | public function deleteContainers($containers, $force = false)
{
if (!empty($containers)) {
if (!isset($containers[0])) {
// single folder, make into array
$containers = [$containers];
}
foreach ($containers as $key => $folder) {
try {
// path is full path, name is relative to root, take either
$name = array_get($folder, 'name', trim(array_get($folder, 'path'), '/'));
if (!empty($name)) {
$this->deleteContainer($name, $force);
} else {
throw new DfException('No name found for container in delete request.');
}
} catch (\Exception $ex) {
// error whole batch here?
$containers[$key]['error'] = ['message' => $ex->getMessage(), 'code' => $ex->getCode()];
}
}
}
return $containers;
} | [
"public",
"function",
"deleteContainers",
"(",
"$",
"containers",
",",
"$",
"force",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"containers",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"containers",
"[",
"0",
"]",
")",
")",
"{",
"// single folder, make into array",
"$",
"containers",
"=",
"[",
"$",
"containers",
"]",
";",
"}",
"foreach",
"(",
"$",
"containers",
"as",
"$",
"key",
"=>",
"$",
"folder",
")",
"{",
"try",
"{",
"// path is full path, name is relative to root, take either",
"$",
"name",
"=",
"array_get",
"(",
"$",
"folder",
",",
"'name'",
",",
"trim",
"(",
"array_get",
"(",
"$",
"folder",
",",
"'path'",
")",
",",
"'/'",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"deleteContainer",
"(",
"$",
"name",
",",
"$",
"force",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"DfException",
"(",
"'No name found for container in delete request.'",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"// error whole batch here?",
"$",
"containers",
"[",
"$",
"key",
"]",
"[",
"'error'",
"]",
"=",
"[",
"'message'",
"=>",
"$",
"ex",
"->",
"getMessage",
"(",
")",
",",
"'code'",
"=>",
"$",
"ex",
"->",
"getCode",
"(",
")",
"]",
";",
"}",
"}",
"}",
"return",
"$",
"containers",
";",
"}"
]
| Delete multiple containers and all of their content
@param array $containers
@param bool $force Force a delete if it is not empty
@throws DfException
@return array | [
"Delete",
"multiple",
"containers",
"and",
"all",
"of",
"their",
"content"
]
| e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66 | https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/RemoteFileSystem.php#L79-L103 |
19,546 | geekwright/Po | src/PoInitAbstract.php | PoInitAbstract.msginitFile | public function msginitFile(string $filename): PoFile
{
if (!is_readable($filename)) {
$source = false;
} else {
$source = file_get_contents($filename);
}
if (false===$source) {
throw new FileNotReadableException($filename);
}
return $this->msginitString($source, $filename);
} | php | public function msginitFile(string $filename): PoFile
{
if (!is_readable($filename)) {
$source = false;
} else {
$source = file_get_contents($filename);
}
if (false===$source) {
throw new FileNotReadableException($filename);
}
return $this->msginitString($source, $filename);
} | [
"public",
"function",
"msginitFile",
"(",
"string",
"$",
"filename",
")",
":",
"PoFile",
"{",
"if",
"(",
"!",
"is_readable",
"(",
"$",
"filename",
")",
")",
"{",
"$",
"source",
"=",
"false",
";",
"}",
"else",
"{",
"$",
"source",
"=",
"file_get_contents",
"(",
"$",
"filename",
")",
";",
"}",
"if",
"(",
"false",
"===",
"$",
"source",
")",
"{",
"throw",
"new",
"FileNotReadableException",
"(",
"$",
"filename",
")",
";",
"}",
"return",
"$",
"this",
"->",
"msginitString",
"(",
"$",
"source",
",",
"$",
"filename",
")",
";",
"}"
]
| Inspect the supplied source file, capture gettext references as a PoFile object
@param string $filename name of source file
@return PoFile
@throws FileNotReadableException | [
"Inspect",
"the",
"supplied",
"source",
"file",
"capture",
"gettext",
"references",
"as",
"a",
"PoFile",
"object"
]
| 9474d059a83b64e6242cc41e5c5b7a08bc57e4e2 | https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoInitAbstract.php#L173-L184 |
19,547 | geekwright/Po | src/PoInitAbstract.php | PoInitAbstract.escapeForPo | public function escapeForPo(string $string): string
{
if ($string[0]=='"' || $string[0]=="'") {
$string = substr($string, 1, -1);
}
$string = str_replace("\r\n", "\n", $string);
$string = stripcslashes($string);
return addcslashes($string, "\0..\37\"");
} | php | public function escapeForPo(string $string): string
{
if ($string[0]=='"' || $string[0]=="'") {
$string = substr($string, 1, -1);
}
$string = str_replace("\r\n", "\n", $string);
$string = stripcslashes($string);
return addcslashes($string, "\0..\37\"");
} | [
"public",
"function",
"escapeForPo",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"if",
"(",
"$",
"string",
"[",
"0",
"]",
"==",
"'\"'",
"||",
"$",
"string",
"[",
"0",
"]",
"==",
"\"'\"",
")",
"{",
"$",
"string",
"=",
"substr",
"(",
"$",
"string",
",",
"1",
",",
"-",
"1",
")",
";",
"}",
"$",
"string",
"=",
"str_replace",
"(",
"\"\\r\\n\"",
",",
"\"\\n\"",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"stripcslashes",
"(",
"$",
"string",
")",
";",
"return",
"addcslashes",
"(",
"$",
"string",
",",
"\"\\0..\\37\\\"\"",
")",
";",
"}"
]
| Prepare a string from tokenized output for use in a po file. Remove any
surrounding quotes, escape control characters and double quotes.
@param string $string raw string (T_STRING) identified by php token_get_all
@return string | [
"Prepare",
"a",
"string",
"from",
"tokenized",
"output",
"for",
"use",
"in",
"a",
"po",
"file",
".",
"Remove",
"any",
"surrounding",
"quotes",
"escape",
"control",
"characters",
"and",
"double",
"quotes",
"."
]
| 9474d059a83b64e6242cc41e5c5b7a08bc57e4e2 | https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoInitAbstract.php#L204-L212 |
19,548 | geekwright/Po | src/PoInitAbstract.php | PoInitAbstract.checkPhpFormatFlag | public function checkPhpFormatFlag(PoEntry $entry): void
{
if (preg_match(
'#(?<!%)%(?:\d+\$)?[+-]?(?:[ 0]|\'.{1})?-?\d*(?:\.\d+)?[bcdeEufFgGosxX]#',
$entry->get(PoTokens::MESSAGE) . $entry->get(PoTokens::PLURAL)
)) {
$entry->addFlag('php-format');
}
} | php | public function checkPhpFormatFlag(PoEntry $entry): void
{
if (preg_match(
'#(?<!%)%(?:\d+\$)?[+-]?(?:[ 0]|\'.{1})?-?\d*(?:\.\d+)?[bcdeEufFgGosxX]#',
$entry->get(PoTokens::MESSAGE) . $entry->get(PoTokens::PLURAL)
)) {
$entry->addFlag('php-format');
}
} | [
"public",
"function",
"checkPhpFormatFlag",
"(",
"PoEntry",
"$",
"entry",
")",
":",
"void",
"{",
"if",
"(",
"preg_match",
"(",
"'#(?<!%)%(?:\\d+\\$)?[+-]?(?:[ 0]|\\'.{1})?-?\\d*(?:\\.\\d+)?[bcdeEufFgGosxX]#'",
",",
"$",
"entry",
"->",
"get",
"(",
"PoTokens",
"::",
"MESSAGE",
")",
".",
"$",
"entry",
"->",
"get",
"(",
"PoTokens",
"::",
"PLURAL",
")",
")",
")",
"{",
"$",
"entry",
"->",
"addFlag",
"(",
"'php-format'",
")",
";",
"}",
"}"
]
| Check the supplied entry for sprintf directives and set php-format flag if found
@param PoEntry $entry entry to check
@return void | [
"Check",
"the",
"supplied",
"entry",
"for",
"sprintf",
"directives",
"and",
"set",
"php",
"-",
"format",
"flag",
"if",
"found"
]
| 9474d059a83b64e6242cc41e5c5b7a08bc57e4e2 | https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoInitAbstract.php#L221-L229 |
19,549 | spiral-modules/scaffolder | source/Scaffolder/Commands/CommandCommand.php | CommandCommand.perform | public function perform()
{
/** @var CommandDeclaration $declaration */
$declaration = $this->createDeclaration(compact('alias'));
$declaration->setAlias($this->argument('alias') ?? $this->argument('name'));
$declaration->setDescription((string)$this->option('description'));
$this->writeDeclaration($declaration);
} | php | public function perform()
{
/** @var CommandDeclaration $declaration */
$declaration = $this->createDeclaration(compact('alias'));
$declaration->setAlias($this->argument('alias') ?? $this->argument('name'));
$declaration->setDescription((string)$this->option('description'));
$this->writeDeclaration($declaration);
} | [
"public",
"function",
"perform",
"(",
")",
"{",
"/** @var CommandDeclaration $declaration */",
"$",
"declaration",
"=",
"$",
"this",
"->",
"createDeclaration",
"(",
"compact",
"(",
"'alias'",
")",
")",
";",
"$",
"declaration",
"->",
"setAlias",
"(",
"$",
"this",
"->",
"argument",
"(",
"'alias'",
")",
"??",
"$",
"this",
"->",
"argument",
"(",
"'name'",
")",
")",
";",
"$",
"declaration",
"->",
"setDescription",
"(",
"(",
"string",
")",
"$",
"this",
"->",
"option",
"(",
"'description'",
")",
")",
";",
"$",
"this",
"->",
"writeDeclaration",
"(",
"$",
"declaration",
")",
";",
"}"
]
| Create command declaration. | [
"Create",
"command",
"declaration",
"."
]
| 9be9dd0da6e4b02232db24e797fe5c288afbbddf | https://github.com/spiral-modules/scaffolder/blob/9be9dd0da6e4b02232db24e797fe5c288afbbddf/source/Scaffolder/Commands/CommandCommand.php#L36-L45 |
19,550 | Chill-project/Main | Entity/User.php | User.isGroupCenterPresentOnce | public function isGroupCenterPresentOnce(ExecutionContextInterface $context)
{
$groupCentersIds = array();
foreach ($this->getGroupCenters() as $groupCenter) {
if (in_array($groupCenter->getId(), $groupCentersIds)) {
$context->buildViolation("The user has already those permissions")
->addViolation();
} else {
$groupCentersIds[] = $groupCenter->getId();
}
}
} | php | public function isGroupCenterPresentOnce(ExecutionContextInterface $context)
{
$groupCentersIds = array();
foreach ($this->getGroupCenters() as $groupCenter) {
if (in_array($groupCenter->getId(), $groupCentersIds)) {
$context->buildViolation("The user has already those permissions")
->addViolation();
} else {
$groupCentersIds[] = $groupCenter->getId();
}
}
} | [
"public",
"function",
"isGroupCenterPresentOnce",
"(",
"ExecutionContextInterface",
"$",
"context",
")",
"{",
"$",
"groupCentersIds",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getGroupCenters",
"(",
")",
"as",
"$",
"groupCenter",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"groupCenter",
"->",
"getId",
"(",
")",
",",
"$",
"groupCentersIds",
")",
")",
"{",
"$",
"context",
"->",
"buildViolation",
"(",
"\"The user has already those permissions\"",
")",
"->",
"addViolation",
"(",
")",
";",
"}",
"else",
"{",
"$",
"groupCentersIds",
"[",
"]",
"=",
"$",
"groupCenter",
"->",
"getId",
"(",
")",
";",
"}",
"}",
"}"
]
| This function check that groupCenter are present only once. The validator
use this function to avoid a user to be associated to the same groupCenter
more than once. | [
"This",
"function",
"check",
"that",
"groupCenter",
"are",
"present",
"only",
"once",
".",
"The",
"validator",
"use",
"this",
"function",
"to",
"avoid",
"a",
"user",
"to",
"be",
"associated",
"to",
"the",
"same",
"groupCenter",
"more",
"than",
"once",
"."
]
| 384cb6c793072a4f1047dc5cafc2157ee2419f60 | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Entity/User.php#L216-L228 |
19,551 | alanpich/slender | src/Core/Util/Util.php | Util.stringStartsWith | public static function stringStartsWith($str, $prefix)
{
if(is_array($prefix)){
foreach($prefix as $p){
if($p === "" || strpos($str, $p) === 0){
return true;
};
}
return false;
}
return $prefix === "" || strpos($str, $prefix) === 0;
} | php | public static function stringStartsWith($str, $prefix)
{
if(is_array($prefix)){
foreach($prefix as $p){
if($p === "" || strpos($str, $p) === 0){
return true;
};
}
return false;
}
return $prefix === "" || strpos($str, $prefix) === 0;
} | [
"public",
"static",
"function",
"stringStartsWith",
"(",
"$",
"str",
",",
"$",
"prefix",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"prefix",
")",
")",
"{",
"foreach",
"(",
"$",
"prefix",
"as",
"$",
"p",
")",
"{",
"if",
"(",
"$",
"p",
"===",
"\"\"",
"||",
"strpos",
"(",
"$",
"str",
",",
"$",
"p",
")",
"===",
"0",
")",
"{",
"return",
"true",
";",
"}",
";",
"}",
"return",
"false",
";",
"}",
"return",
"$",
"prefix",
"===",
"\"\"",
"||",
"strpos",
"(",
"$",
"str",
",",
"$",
"prefix",
")",
"===",
"0",
";",
"}"
]
| Does a string start with another string?
@param string $str The string to check
@param string|array $prefix The prefix to check for
@return bool | [
"Does",
"a",
"string",
"start",
"with",
"another",
"string?"
]
| 247f5c08af20cda95b116eb5d9f6f623d61e8a8a | https://github.com/alanpich/slender/blob/247f5c08af20cda95b116eb5d9f6f623d61e8a8a/src/Core/Util/Util.php#L77-L88 |
19,552 | alanpich/slender | src/Core/Util/Util.php | Util.stringEndsWith | public static function stringEndsWith($str, $postfix)
{
if(is_array($postfix)){
foreach($postfix as $p){
if($p === "" || substr($str, -strlen($p)) === $p){
return true;
}
}
return false;
}
return $postfix === "" || substr($str, -strlen($postfix)) === $postfix;
} | php | public static function stringEndsWith($str, $postfix)
{
if(is_array($postfix)){
foreach($postfix as $p){
if($p === "" || substr($str, -strlen($p)) === $p){
return true;
}
}
return false;
}
return $postfix === "" || substr($str, -strlen($postfix)) === $postfix;
} | [
"public",
"static",
"function",
"stringEndsWith",
"(",
"$",
"str",
",",
"$",
"postfix",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"postfix",
")",
")",
"{",
"foreach",
"(",
"$",
"postfix",
"as",
"$",
"p",
")",
"{",
"if",
"(",
"$",
"p",
"===",
"\"\"",
"||",
"substr",
"(",
"$",
"str",
",",
"-",
"strlen",
"(",
"$",
"p",
")",
")",
"===",
"$",
"p",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
"return",
"$",
"postfix",
"===",
"\"\"",
"||",
"substr",
"(",
"$",
"str",
",",
"-",
"strlen",
"(",
"$",
"postfix",
")",
")",
"===",
"$",
"postfix",
";",
"}"
]
| Does a string end with another string?
@param string $str The string to check
@param string|array $postfix The postfix to check for
@return bool | [
"Does",
"a",
"string",
"end",
"with",
"another",
"string?"
]
| 247f5c08af20cda95b116eb5d9f6f623d61e8a8a | https://github.com/alanpich/slender/blob/247f5c08af20cda95b116eb5d9f6f623d61e8a8a/src/Core/Util/Util.php#L98-L109 |
19,553 | 4devs/ElfinderPhpConnector | FileInfo.php | FileInfo.toArray | public function toArray()
{
$data = array(
'name' => $this->name,
'hash' => $this->hash,
'phash' => $this->phash,
'mime' => $this->mime,
'ts' => $this->ts,
'size' => $this->size,
'dirs' => $this->dirs,
'read' => $this->read,
'write' => $this->write,
'locked' => $this->locked,
'tmb' => $this->tmb,
'alias' => $this->alias,
'thash' => $this->thash,
'dim' => $this->dim,
'volumeid' => $this->volumeid,
'path' => $this->path,
'url' => $this->url,
);
return array_filter(
$data,
function ($var) {
return !is_null($var);
}
);
} | php | public function toArray()
{
$data = array(
'name' => $this->name,
'hash' => $this->hash,
'phash' => $this->phash,
'mime' => $this->mime,
'ts' => $this->ts,
'size' => $this->size,
'dirs' => $this->dirs,
'read' => $this->read,
'write' => $this->write,
'locked' => $this->locked,
'tmb' => $this->tmb,
'alias' => $this->alias,
'thash' => $this->thash,
'dim' => $this->dim,
'volumeid' => $this->volumeid,
'path' => $this->path,
'url' => $this->url,
);
return array_filter(
$data,
function ($var) {
return !is_null($var);
}
);
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"this",
"->",
"name",
",",
"'hash'",
"=>",
"$",
"this",
"->",
"hash",
",",
"'phash'",
"=>",
"$",
"this",
"->",
"phash",
",",
"'mime'",
"=>",
"$",
"this",
"->",
"mime",
",",
"'ts'",
"=>",
"$",
"this",
"->",
"ts",
",",
"'size'",
"=>",
"$",
"this",
"->",
"size",
",",
"'dirs'",
"=>",
"$",
"this",
"->",
"dirs",
",",
"'read'",
"=>",
"$",
"this",
"->",
"read",
",",
"'write'",
"=>",
"$",
"this",
"->",
"write",
",",
"'locked'",
"=>",
"$",
"this",
"->",
"locked",
",",
"'tmb'",
"=>",
"$",
"this",
"->",
"tmb",
",",
"'alias'",
"=>",
"$",
"this",
"->",
"alias",
",",
"'thash'",
"=>",
"$",
"this",
"->",
"thash",
",",
"'dim'",
"=>",
"$",
"this",
"->",
"dim",
",",
"'volumeid'",
"=>",
"$",
"this",
"->",
"volumeid",
",",
"'path'",
"=>",
"$",
"this",
"->",
"path",
",",
"'url'",
"=>",
"$",
"this",
"->",
"url",
",",
")",
";",
"return",
"array_filter",
"(",
"$",
"data",
",",
"function",
"(",
"$",
"var",
")",
"{",
"return",
"!",
"is_null",
"(",
"$",
"var",
")",
";",
"}",
")",
";",
"}"
]
| FileInfo return as array.
@return array | [
"FileInfo",
"return",
"as",
"array",
"."
]
| 510e295dcafeaa0f796986ad87b3ed5f6b0d9338 | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/FileInfo.php#L574-L602 |
19,554 | okitcom/ok-lib-php | src/Model/Cash/LineItem.php | LineItem.create | public static function create($quantity, $productCode, $description, $amount, $vat, $currency = "EUR") {
$item = new LineItem;
$item->quantity = $quantity;
$item->productCode = $productCode;
$item->description = $description;
$item->amount = $amount;
$item->vat = $vat;
$item->currency = $currency;
return $item;
} | php | public static function create($quantity, $productCode, $description, $amount, $vat, $currency = "EUR") {
$item = new LineItem;
$item->quantity = $quantity;
$item->productCode = $productCode;
$item->description = $description;
$item->amount = $amount;
$item->vat = $vat;
$item->currency = $currency;
return $item;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"quantity",
",",
"$",
"productCode",
",",
"$",
"description",
",",
"$",
"amount",
",",
"$",
"vat",
",",
"$",
"currency",
"=",
"\"EUR\"",
")",
"{",
"$",
"item",
"=",
"new",
"LineItem",
";",
"$",
"item",
"->",
"quantity",
"=",
"$",
"quantity",
";",
"$",
"item",
"->",
"productCode",
"=",
"$",
"productCode",
";",
"$",
"item",
"->",
"description",
"=",
"$",
"description",
";",
"$",
"item",
"->",
"amount",
"=",
"$",
"amount",
";",
"$",
"item",
"->",
"vat",
"=",
"$",
"vat",
";",
"$",
"item",
"->",
"currency",
"=",
"$",
"currency",
";",
"return",
"$",
"item",
";",
"}"
]
| LineItem creator.
@param int $quantity
@param string $productCode
@param string $description
@param Amount $amount
@param int $vat
@param string $currency
@return LineItem | [
"LineItem",
"creator",
"."
]
| 1f441f3d216af7c952788e864bfe66bc4f089467 | https://github.com/okitcom/ok-lib-php/blob/1f441f3d216af7c952788e864bfe66bc4f089467/src/Model/Cash/LineItem.php#L66-L75 |
19,555 | slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountryQuery.php | BaseCountryQuery.create | public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof CountryQuery) {
return $criteria;
}
$query = new CountryQuery(null, null, $modelAlias);
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
} | php | public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof CountryQuery) {
return $criteria;
}
$query = new CountryQuery(null, null, $modelAlias);
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"modelAlias",
"=",
"null",
",",
"$",
"criteria",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"criteria",
"instanceof",
"CountryQuery",
")",
"{",
"return",
"$",
"criteria",
";",
"}",
"$",
"query",
"=",
"new",
"CountryQuery",
"(",
"null",
",",
"null",
",",
"$",
"modelAlias",
")",
";",
"if",
"(",
"$",
"criteria",
"instanceof",
"Criteria",
")",
"{",
"$",
"query",
"->",
"mergeWith",
"(",
"$",
"criteria",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
]
| Returns a new CountryQuery object.
@param string $modelAlias The alias of a model in the query
@param CountryQuery|Criteria $criteria Optional Criteria to build the query from
@return CountryQuery | [
"Returns",
"a",
"new",
"CountryQuery",
"object",
"."
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountryQuery.php#L79-L91 |
19,556 | slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountryQuery.php | BaseCountryQuery.filterByEn | public function filterByEn($en = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($en)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $en)) {
$en = str_replace('*', '%', $en);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CountryPeer::EN, $en, $comparison);
} | php | public function filterByEn($en = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($en)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $en)) {
$en = str_replace('*', '%', $en);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CountryPeer::EN, $en, $comparison);
} | [
"public",
"function",
"filterByEn",
"(",
"$",
"en",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"en",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"en",
")",
")",
"{",
"$",
"en",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"en",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CountryPeer",
"::",
"EN",
",",
"$",
"en",
",",
"$",
"comparison",
")",
";",
"}"
]
| Filter the query on the en column
Example usage:
<code>
$query->filterByEn('fooValue'); // WHERE en = 'fooValue'
$query->filterByEn('%fooValue%'); // WHERE en LIKE '%fooValue%'
</code>
@param string $en The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return CountryQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"en",
"column"
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountryQuery.php#L330-L342 |
19,557 | slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountryQuery.php | BaseCountryQuery.filterByDe | public function filterByDe($de = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($de)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $de)) {
$de = str_replace('*', '%', $de);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CountryPeer::DE, $de, $comparison);
} | php | public function filterByDe($de = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($de)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $de)) {
$de = str_replace('*', '%', $de);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CountryPeer::DE, $de, $comparison);
} | [
"public",
"function",
"filterByDe",
"(",
"$",
"de",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"de",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"de",
")",
")",
"{",
"$",
"de",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"de",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CountryPeer",
"::",
"DE",
",",
"$",
"de",
",",
"$",
"comparison",
")",
";",
"}"
]
| Filter the query on the de column
Example usage:
<code>
$query->filterByDe('fooValue'); // WHERE de = 'fooValue'
$query->filterByDe('%fooValue%'); // WHERE de LIKE '%fooValue%'
</code>
@param string $de The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return CountryQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"de",
"column"
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountryQuery.php#L359-L371 |
19,558 | steeffeen/FancyManiaLinks | FML/Stylesheet/Stylesheet.php | Stylesheet.addStyle | public function addStyle(Style $style)
{
if (!in_array($style, $this->styles, true)) {
array_push($this->styles, $style);
}
return $this;
} | php | public function addStyle(Style $style)
{
if (!in_array($style, $this->styles, true)) {
array_push($this->styles, $style);
}
return $this;
} | [
"public",
"function",
"addStyle",
"(",
"Style",
"$",
"style",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"style",
",",
"$",
"this",
"->",
"styles",
",",
"true",
")",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"styles",
",",
"$",
"style",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Add a new Style
@api
@param Style $style The Style to be added
@return static | [
"Add",
"a",
"new",
"Style"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Stylesheet/Stylesheet.php#L59-L65 |
19,559 | steeffeen/FancyManiaLinks | FML/Stylesheet/Stylesheet.php | Stylesheet.addStyle3d | public function addStyle3d(Style3d $style3d)
{
if (!in_array($style3d, $this->styles3d, true)) {
array_push($this->styles3d, $style3d);
}
return $this;
} | php | public function addStyle3d(Style3d $style3d)
{
if (!in_array($style3d, $this->styles3d, true)) {
array_push($this->styles3d, $style3d);
}
return $this;
} | [
"public",
"function",
"addStyle3d",
"(",
"Style3d",
"$",
"style3d",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"style3d",
",",
"$",
"this",
"->",
"styles3d",
",",
"true",
")",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"styles3d",
",",
"$",
"style3d",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Add a new Style3d
@api
@param Style3d $style3d The Style3d to be added
@return static | [
"Add",
"a",
"new",
"Style3d"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Stylesheet/Stylesheet.php#L97-L103 |
19,560 | steeffeen/FancyManiaLinks | FML/Stylesheet/Stylesheet.php | Stylesheet.getMood | public function getMood($createIfEmpty = true)
{
if (!$this->mood && $createIfEmpty) {
$this->createMood();
}
return $this->mood;
} | php | public function getMood($createIfEmpty = true)
{
if (!$this->mood && $createIfEmpty) {
$this->createMood();
}
return $this->mood;
} | [
"public",
"function",
"getMood",
"(",
"$",
"createIfEmpty",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"mood",
"&&",
"$",
"createIfEmpty",
")",
"{",
"$",
"this",
"->",
"createMood",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"mood",
";",
"}"
]
| Get the Mood
@api
@param bool $createIfEmpty (optional) If the Mood should be created if it doesn't exist yet
@return Mood | [
"Get",
"the",
"Mood"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Stylesheet/Stylesheet.php#L138-L144 |
19,561 | steeffeen/FancyManiaLinks | FML/Stylesheet/Stylesheet.php | Stylesheet.createMood | public function createMood()
{
if ($this->mood) {
return $this->mood;
}
$mood = new Mood();
$this->setMood($mood);
return $this->mood;
} | php | public function createMood()
{
if ($this->mood) {
return $this->mood;
}
$mood = new Mood();
$this->setMood($mood);
return $this->mood;
} | [
"public",
"function",
"createMood",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"mood",
")",
"{",
"return",
"$",
"this",
"->",
"mood",
";",
"}",
"$",
"mood",
"=",
"new",
"Mood",
"(",
")",
";",
"$",
"this",
"->",
"setMood",
"(",
"$",
"mood",
")",
";",
"return",
"$",
"this",
"->",
"mood",
";",
"}"
]
| Create a new Mood if necessary
@api
@return Mood | [
"Create",
"a",
"new",
"Mood",
"if",
"necessary"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Stylesheet/Stylesheet.php#L165-L173 |
19,562 | steeffeen/FancyManiaLinks | FML/Stylesheet/Stylesheet.php | Stylesheet.render | public function render(\DOMDocument $domDocument)
{
$stylesheetXml = $domDocument->createElement("stylesheet");
if ($this->styles3d) {
$stylesXml = $domDocument->createElement("frame3dstyles");
$stylesheetXml->appendChild($stylesXml);
foreach ($this->styles3d as $style3d) {
$style3dXml = $style3d->render($domDocument);
$stylesXml->appendChild($style3dXml);
}
}
if ($this->mood) {
$moodXml = $this->mood->render($domDocument);
$stylesheetXml->appendChild($moodXml);
}
return $stylesheetXml;
} | php | public function render(\DOMDocument $domDocument)
{
$stylesheetXml = $domDocument->createElement("stylesheet");
if ($this->styles3d) {
$stylesXml = $domDocument->createElement("frame3dstyles");
$stylesheetXml->appendChild($stylesXml);
foreach ($this->styles3d as $style3d) {
$style3dXml = $style3d->render($domDocument);
$stylesXml->appendChild($style3dXml);
}
}
if ($this->mood) {
$moodXml = $this->mood->render($domDocument);
$stylesheetXml->appendChild($moodXml);
}
return $stylesheetXml;
} | [
"public",
"function",
"render",
"(",
"\\",
"DOMDocument",
"$",
"domDocument",
")",
"{",
"$",
"stylesheetXml",
"=",
"$",
"domDocument",
"->",
"createElement",
"(",
"\"stylesheet\"",
")",
";",
"if",
"(",
"$",
"this",
"->",
"styles3d",
")",
"{",
"$",
"stylesXml",
"=",
"$",
"domDocument",
"->",
"createElement",
"(",
"\"frame3dstyles\"",
")",
";",
"$",
"stylesheetXml",
"->",
"appendChild",
"(",
"$",
"stylesXml",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"styles3d",
"as",
"$",
"style3d",
")",
"{",
"$",
"style3dXml",
"=",
"$",
"style3d",
"->",
"render",
"(",
"$",
"domDocument",
")",
";",
"$",
"stylesXml",
"->",
"appendChild",
"(",
"$",
"style3dXml",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"mood",
")",
"{",
"$",
"moodXml",
"=",
"$",
"this",
"->",
"mood",
"->",
"render",
"(",
"$",
"domDocument",
")",
";",
"$",
"stylesheetXml",
"->",
"appendChild",
"(",
"$",
"moodXml",
")",
";",
"}",
"return",
"$",
"stylesheetXml",
";",
"}"
]
| Render the Stylesheet
@param \DOMDocument $domDocument DOMDocument for which the Stylesheet should be rendered
@return \DOMElement | [
"Render",
"the",
"Stylesheet"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Stylesheet/Stylesheet.php#L181-L197 |
19,563 | Lansoweb/LosReCaptcha | src/Form/View/Helper/Captcha/Invisible.php | Invisible.renderHiddenInput | private function renderHiddenInput($responseName, $responseId)
{
$pattern = '<input type="hidden" %s%s';
$closingBracket = $this->getInlineClosingBracket();
$attributes = $this->createAttributesString([
'name' => $responseName,
'id' => $responseId,
]);
$response = sprintf($pattern, $attributes, $closingBracket);
return $response;
} | php | private function renderHiddenInput($responseName, $responseId)
{
$pattern = '<input type="hidden" %s%s';
$closingBracket = $this->getInlineClosingBracket();
$attributes = $this->createAttributesString([
'name' => $responseName,
'id' => $responseId,
]);
$response = sprintf($pattern, $attributes, $closingBracket);
return $response;
} | [
"private",
"function",
"renderHiddenInput",
"(",
"$",
"responseName",
",",
"$",
"responseId",
")",
"{",
"$",
"pattern",
"=",
"'<input type=\"hidden\" %s%s'",
";",
"$",
"closingBracket",
"=",
"$",
"this",
"->",
"getInlineClosingBracket",
"(",
")",
";",
"$",
"attributes",
"=",
"$",
"this",
"->",
"createAttributesString",
"(",
"[",
"'name'",
"=>",
"$",
"responseName",
",",
"'id'",
"=>",
"$",
"responseId",
",",
"]",
")",
";",
"$",
"response",
"=",
"sprintf",
"(",
"$",
"pattern",
",",
"$",
"attributes",
",",
"$",
"closingBracket",
")",
";",
"return",
"$",
"response",
";",
"}"
]
| Render hidden input elements for the response
@param string $responseName
@param string $responseId
@return string | [
"Render",
"hidden",
"input",
"elements",
"for",
"the",
"response"
]
| 8df866995501db087c3850f97fd2b6547632e6ed | https://github.com/Lansoweb/LosReCaptcha/blob/8df866995501db087c3850f97fd2b6547632e6ed/src/Form/View/Helper/Captcha/Invisible.php#L74-L86 |
19,564 | maniaplanet/matchmaking-lobby | MatchMakingLobby/Match/Plugin.php | Plugin.prepare | protected function prepare($match)
{
\ManiaLive\Utilities\Logger::debug($match);
$this->players = array_fill_keys($match->players, Services\PlayerInfo::PLAYER_STATE_NOT_CONNECTED);
$this->match = $match;
$this->matchId = $match->id;
Label::EraseAll();
foreach($match->players as $login)
{
$this->connection->addGuest((string)$login, true);
}
$this->connection->restartMap(false, true);
$this->connection->executeMulticall();
$this->enableDedicatedEvents(
ServerEvent::ON_PLAYER_CONNECT |
ServerEvent::ON_PLAYER_DISCONNECT |
ServerEvent::ON_END_MATCH |
ServerEvent::ON_END_ROUND |
ServerEvent::ON_PLAYER_INFO_CHANGED |
ServerEvent::ON_MODE_SCRIPT_CALLBACK |
ServerEvent::ON_MODE_SCRIPT_CALLBACK_ARRAY
);
\ManiaLive\Utilities\Logger::debug(sprintf('Preparing match for %s (%s)',$this->lobby->login, implode(',', array_keys($this->players))));
$this->changeState(self::WAITING);
$this->waitingTime = 0;
$this->connection->setForcedTeams(true);
} | php | protected function prepare($match)
{
\ManiaLive\Utilities\Logger::debug($match);
$this->players = array_fill_keys($match->players, Services\PlayerInfo::PLAYER_STATE_NOT_CONNECTED);
$this->match = $match;
$this->matchId = $match->id;
Label::EraseAll();
foreach($match->players as $login)
{
$this->connection->addGuest((string)$login, true);
}
$this->connection->restartMap(false, true);
$this->connection->executeMulticall();
$this->enableDedicatedEvents(
ServerEvent::ON_PLAYER_CONNECT |
ServerEvent::ON_PLAYER_DISCONNECT |
ServerEvent::ON_END_MATCH |
ServerEvent::ON_END_ROUND |
ServerEvent::ON_PLAYER_INFO_CHANGED |
ServerEvent::ON_MODE_SCRIPT_CALLBACK |
ServerEvent::ON_MODE_SCRIPT_CALLBACK_ARRAY
);
\ManiaLive\Utilities\Logger::debug(sprintf('Preparing match for %s (%s)',$this->lobby->login, implode(',', array_keys($this->players))));
$this->changeState(self::WAITING);
$this->waitingTime = 0;
$this->connection->setForcedTeams(true);
} | [
"protected",
"function",
"prepare",
"(",
"$",
"match",
")",
"{",
"\\",
"ManiaLive",
"\\",
"Utilities",
"\\",
"Logger",
"::",
"debug",
"(",
"$",
"match",
")",
";",
"$",
"this",
"->",
"players",
"=",
"array_fill_keys",
"(",
"$",
"match",
"->",
"players",
",",
"Services",
"\\",
"PlayerInfo",
"::",
"PLAYER_STATE_NOT_CONNECTED",
")",
";",
"$",
"this",
"->",
"match",
"=",
"$",
"match",
";",
"$",
"this",
"->",
"matchId",
"=",
"$",
"match",
"->",
"id",
";",
"Label",
"::",
"EraseAll",
"(",
")",
";",
"foreach",
"(",
"$",
"match",
"->",
"players",
"as",
"$",
"login",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"addGuest",
"(",
"(",
"string",
")",
"$",
"login",
",",
"true",
")",
";",
"}",
"$",
"this",
"->",
"connection",
"->",
"restartMap",
"(",
"false",
",",
"true",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"executeMulticall",
"(",
")",
";",
"$",
"this",
"->",
"enableDedicatedEvents",
"(",
"ServerEvent",
"::",
"ON_PLAYER_CONNECT",
"|",
"ServerEvent",
"::",
"ON_PLAYER_DISCONNECT",
"|",
"ServerEvent",
"::",
"ON_END_MATCH",
"|",
"ServerEvent",
"::",
"ON_END_ROUND",
"|",
"ServerEvent",
"::",
"ON_PLAYER_INFO_CHANGED",
"|",
"ServerEvent",
"::",
"ON_MODE_SCRIPT_CALLBACK",
"|",
"ServerEvent",
"::",
"ON_MODE_SCRIPT_CALLBACK_ARRAY",
")",
";",
"\\",
"ManiaLive",
"\\",
"Utilities",
"\\",
"Logger",
"::",
"debug",
"(",
"sprintf",
"(",
"'Preparing match for %s (%s)'",
",",
"$",
"this",
"->",
"lobby",
"->",
"login",
",",
"implode",
"(",
"','",
",",
"array_keys",
"(",
"$",
"this",
"->",
"players",
")",
")",
")",
")",
";",
"$",
"this",
"->",
"changeState",
"(",
"self",
"::",
"WAITING",
")",
";",
"$",
"this",
"->",
"waitingTime",
"=",
"0",
";",
"$",
"this",
"->",
"connection",
"->",
"setForcedTeams",
"(",
"true",
")",
";",
"}"
]
| Prepare the server config to host a match
Then wait players' connection
@param Services\Match $match | [
"Prepare",
"the",
"server",
"config",
"to",
"host",
"a",
"match",
"Then",
"wait",
"players",
"connection"
]
| 384f22cdd2cfb0204a071810549eaf1eb01d8b7f | https://github.com/maniaplanet/matchmaking-lobby/blob/384f22cdd2cfb0204a071810549eaf1eb01d8b7f/MatchMakingLobby/Match/Plugin.php#L569-L598 |
19,565 | maniaplanet/matchmaking-lobby | MatchMakingLobby/Match/Plugin.php | Plugin.end | protected function end()
{
\ManiaLive\Utilities\Logger::debug('end()');
$this->showTansfertLabel(null, -50);
foreach($this->storage->players as $player)
{
try
{
$this->connection->sendOpenLink((string) $player->login, '#qjoin='.$this->lobby->backLink, 1);
}
catch (\DedicatedApi\Xmlrpc\Exception $e)
{
//do nothing
}
}
$this->connection->cleanGuestList();
$this->match = null;
$this->matchId = null;
$this->matchMakingService->updateServerCurrentMatchId(
null,
$this->storage->serverLogin,
$this->scriptName,
$this->titleIdString
);
$this->connection->setForcedTeams(false);
$this->sleep();
} | php | protected function end()
{
\ManiaLive\Utilities\Logger::debug('end()');
$this->showTansfertLabel(null, -50);
foreach($this->storage->players as $player)
{
try
{
$this->connection->sendOpenLink((string) $player->login, '#qjoin='.$this->lobby->backLink, 1);
}
catch (\DedicatedApi\Xmlrpc\Exception $e)
{
//do nothing
}
}
$this->connection->cleanGuestList();
$this->match = null;
$this->matchId = null;
$this->matchMakingService->updateServerCurrentMatchId(
null,
$this->storage->serverLogin,
$this->scriptName,
$this->titleIdString
);
$this->connection->setForcedTeams(false);
$this->sleep();
} | [
"protected",
"function",
"end",
"(",
")",
"{",
"\\",
"ManiaLive",
"\\",
"Utilities",
"\\",
"Logger",
"::",
"debug",
"(",
"'end()'",
")",
";",
"$",
"this",
"->",
"showTansfertLabel",
"(",
"null",
",",
"-",
"50",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"storage",
"->",
"players",
"as",
"$",
"player",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"connection",
"->",
"sendOpenLink",
"(",
"(",
"string",
")",
"$",
"player",
"->",
"login",
",",
"'#qjoin='",
".",
"$",
"this",
"->",
"lobby",
"->",
"backLink",
",",
"1",
")",
";",
"}",
"catch",
"(",
"\\",
"DedicatedApi",
"\\",
"Xmlrpc",
"\\",
"Exception",
"$",
"e",
")",
"{",
"//do nothing\r",
"}",
"}",
"$",
"this",
"->",
"connection",
"->",
"cleanGuestList",
"(",
")",
";",
"$",
"this",
"->",
"match",
"=",
"null",
";",
"$",
"this",
"->",
"matchId",
"=",
"null",
";",
"$",
"this",
"->",
"matchMakingService",
"->",
"updateServerCurrentMatchId",
"(",
"null",
",",
"$",
"this",
"->",
"storage",
"->",
"serverLogin",
",",
"$",
"this",
"->",
"scriptName",
",",
"$",
"this",
"->",
"titleIdString",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"setForcedTeams",
"(",
"false",
")",
";",
"$",
"this",
"->",
"sleep",
"(",
")",
";",
"}"
]
| Free the match for the lobby | [
"Free",
"the",
"match",
"for",
"the",
"lobby"
]
| 384f22cdd2cfb0204a071810549eaf1eb01d8b7f | https://github.com/maniaplanet/matchmaking-lobby/blob/384f22cdd2cfb0204a071810549eaf1eb01d8b7f/MatchMakingLobby/Match/Plugin.php#L775-L803 |
19,566 | titon/db | src/Titon/Db/Behavior/SlugBehavior.php | SlugBehavior.makeUnique | public function makeUnique($id, $slug) {
$repo = $this->getRepository();
$scope = $this->getConfig('scope');
/** @type \Titon\Db\Query $query */
foreach ([
$repo->select()->where($this->getConfig('slug'), $slug),
$repo->select()->where($this->getConfig('slug'), 'like', $slug . '%')
] as $i => $query) {
if ($scope) {
$query->bindCallback($scope);
}
if ($id) {
$query->where($repo->getPrimaryKey(), '!=', $id);
}
$count = $query->count();
if ($count <= 0) {
break;
} else if ($i) {
return $slug . '-' . $count;
}
}
return $slug;
} | php | public function makeUnique($id, $slug) {
$repo = $this->getRepository();
$scope = $this->getConfig('scope');
/** @type \Titon\Db\Query $query */
foreach ([
$repo->select()->where($this->getConfig('slug'), $slug),
$repo->select()->where($this->getConfig('slug'), 'like', $slug . '%')
] as $i => $query) {
if ($scope) {
$query->bindCallback($scope);
}
if ($id) {
$query->where($repo->getPrimaryKey(), '!=', $id);
}
$count = $query->count();
if ($count <= 0) {
break;
} else if ($i) {
return $slug . '-' . $count;
}
}
return $slug;
} | [
"public",
"function",
"makeUnique",
"(",
"$",
"id",
",",
"$",
"slug",
")",
"{",
"$",
"repo",
"=",
"$",
"this",
"->",
"getRepository",
"(",
")",
";",
"$",
"scope",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'scope'",
")",
";",
"/** @type \\Titon\\Db\\Query $query */",
"foreach",
"(",
"[",
"$",
"repo",
"->",
"select",
"(",
")",
"->",
"where",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"'slug'",
")",
",",
"$",
"slug",
")",
",",
"$",
"repo",
"->",
"select",
"(",
")",
"->",
"where",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"'slug'",
")",
",",
"'like'",
",",
"$",
"slug",
".",
"'%'",
")",
"]",
"as",
"$",
"i",
"=>",
"$",
"query",
")",
"{",
"if",
"(",
"$",
"scope",
")",
"{",
"$",
"query",
"->",
"bindCallback",
"(",
"$",
"scope",
")",
";",
"}",
"if",
"(",
"$",
"id",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"$",
"repo",
"->",
"getPrimaryKey",
"(",
")",
",",
"'!='",
",",
"$",
"id",
")",
";",
"}",
"$",
"count",
"=",
"$",
"query",
"->",
"count",
"(",
")",
";",
"if",
"(",
"$",
"count",
"<=",
"0",
")",
"{",
"break",
";",
"}",
"else",
"if",
"(",
"$",
"i",
")",
"{",
"return",
"$",
"slug",
".",
"'-'",
".",
"$",
"count",
";",
"}",
"}",
"return",
"$",
"slug",
";",
"}"
]
| Validate the slug is unique by querying for other slugs.
If the slug is not unique, append a count to it.
@param int|int[] $id
@param string $slug
@return string | [
"Validate",
"the",
"slug",
"is",
"unique",
"by",
"querying",
"for",
"other",
"slugs",
".",
"If",
"the",
"slug",
"is",
"not",
"unique",
"append",
"a",
"count",
"to",
"it",
"."
]
| fbc5159d1ce9d2139759c9367565986981485604 | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/SlugBehavior.php#L50-L78 |
19,567 | titon/db | src/Titon/Db/Behavior/SlugBehavior.php | SlugBehavior.preSave | public function preSave(Event $event, Query $query, $id, array &$data) {
$config = $this->allConfig();
if (empty($data) || empty($data[$config['field']]) || !empty($data[$config['slug']])) {
return true;
} else if ($query->getType() === Query::UPDATE && !$config['onUpdate']) {
return true;
}
$slug = static::slugify($data[$config['field']]);
// Leave a gap of 3 to account for the appended numbers
if (mb_strlen($slug) > ($config['length'] - 3)) {
$slug = mb_substr($slug, 0, ($config['length'] - 3));
}
if ($config['unique']) {
$slug = $this->makeUnique($id, $slug);
}
$data[$config['slug']] = $slug;
return true;
} | php | public function preSave(Event $event, Query $query, $id, array &$data) {
$config = $this->allConfig();
if (empty($data) || empty($data[$config['field']]) || !empty($data[$config['slug']])) {
return true;
} else if ($query->getType() === Query::UPDATE && !$config['onUpdate']) {
return true;
}
$slug = static::slugify($data[$config['field']]);
// Leave a gap of 3 to account for the appended numbers
if (mb_strlen($slug) > ($config['length'] - 3)) {
$slug = mb_substr($slug, 0, ($config['length'] - 3));
}
if ($config['unique']) {
$slug = $this->makeUnique($id, $slug);
}
$data[$config['slug']] = $slug;
return true;
} | [
"public",
"function",
"preSave",
"(",
"Event",
"$",
"event",
",",
"Query",
"$",
"query",
",",
"$",
"id",
",",
"array",
"&",
"$",
"data",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"allConfig",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
"||",
"empty",
"(",
"$",
"data",
"[",
"$",
"config",
"[",
"'field'",
"]",
"]",
")",
"||",
"!",
"empty",
"(",
"$",
"data",
"[",
"$",
"config",
"[",
"'slug'",
"]",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"$",
"query",
"->",
"getType",
"(",
")",
"===",
"Query",
"::",
"UPDATE",
"&&",
"!",
"$",
"config",
"[",
"'onUpdate'",
"]",
")",
"{",
"return",
"true",
";",
"}",
"$",
"slug",
"=",
"static",
"::",
"slugify",
"(",
"$",
"data",
"[",
"$",
"config",
"[",
"'field'",
"]",
"]",
")",
";",
"// Leave a gap of 3 to account for the appended numbers",
"if",
"(",
"mb_strlen",
"(",
"$",
"slug",
")",
">",
"(",
"$",
"config",
"[",
"'length'",
"]",
"-",
"3",
")",
")",
"{",
"$",
"slug",
"=",
"mb_substr",
"(",
"$",
"slug",
",",
"0",
",",
"(",
"$",
"config",
"[",
"'length'",
"]",
"-",
"3",
")",
")",
";",
"}",
"if",
"(",
"$",
"config",
"[",
"'unique'",
"]",
")",
"{",
"$",
"slug",
"=",
"$",
"this",
"->",
"makeUnique",
"(",
"$",
"id",
",",
"$",
"slug",
")",
";",
"}",
"$",
"data",
"[",
"$",
"config",
"[",
"'slug'",
"]",
"]",
"=",
"$",
"slug",
";",
"return",
"true",
";",
"}"
]
| Before a save occurs, generate a unique slug using another field as the base.
If no data exists, or the base doesn't exist, or the slug is already set, exit early.
@param \Titon\Event\Event $event
@param \Titon\Db\Query $query
@param int|int[] $id
@param array $data
@return bool | [
"Before",
"a",
"save",
"occurs",
"generate",
"a",
"unique",
"slug",
"using",
"another",
"field",
"as",
"the",
"base",
".",
"If",
"no",
"data",
"exists",
"or",
"the",
"base",
"doesn",
"t",
"exist",
"or",
"the",
"slug",
"is",
"already",
"set",
"exit",
"early",
"."
]
| fbc5159d1ce9d2139759c9367565986981485604 | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/SlugBehavior.php#L90-L114 |
19,568 | slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php | BaseUserQuery.create | public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof UserQuery) {
return $criteria;
}
$query = new UserQuery(null, null, $modelAlias);
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
} | php | public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof UserQuery) {
return $criteria;
}
$query = new UserQuery(null, null, $modelAlias);
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"modelAlias",
"=",
"null",
",",
"$",
"criteria",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"criteria",
"instanceof",
"UserQuery",
")",
"{",
"return",
"$",
"criteria",
";",
"}",
"$",
"query",
"=",
"new",
"UserQuery",
"(",
"null",
",",
"null",
",",
"$",
"modelAlias",
")",
";",
"if",
"(",
"$",
"criteria",
"instanceof",
"Criteria",
")",
"{",
"$",
"query",
"->",
"mergeWith",
"(",
"$",
"criteria",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
]
| Returns a new UserQuery object.
@param string $modelAlias The alias of a model in the query
@param UserQuery|Criteria $criteria Optional Criteria to build the query from
@return UserQuery | [
"Returns",
"a",
"new",
"UserQuery",
"object",
"."
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php#L120-L132 |
19,569 | slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php | BaseUserQuery.filterBySalt | public function filterBySalt($salt = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($salt)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $salt)) {
$salt = str_replace('*', '%', $salt);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::SALT, $salt, $comparison);
} | php | public function filterBySalt($salt = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($salt)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $salt)) {
$salt = str_replace('*', '%', $salt);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::SALT, $salt, $comparison);
} | [
"public",
"function",
"filterBySalt",
"(",
"$",
"salt",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"salt",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"salt",
")",
")",
"{",
"$",
"salt",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"salt",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"SALT",
",",
"$",
"salt",
",",
"$",
"comparison",
")",
";",
"}"
]
| Filter the query on the salt column
Example usage:
<code>
$query->filterBySalt('fooValue'); // WHERE salt = 'fooValue'
$query->filterBySalt('%fooValue%'); // WHERE salt LIKE '%fooValue%'
</code>
@param string $salt The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return UserQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"salt",
"column"
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php#L400-L412 |
19,570 | slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php | BaseUserQuery.filterByFirstname | public function filterByFirstname($firstname = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($firstname)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $firstname)) {
$firstname = str_replace('*', '%', $firstname);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::FIRSTNAME, $firstname, $comparison);
} | php | public function filterByFirstname($firstname = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($firstname)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $firstname)) {
$firstname = str_replace('*', '%', $firstname);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::FIRSTNAME, $firstname, $comparison);
} | [
"public",
"function",
"filterByFirstname",
"(",
"$",
"firstname",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"firstname",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"firstname",
")",
")",
"{",
"$",
"firstname",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"firstname",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"FIRSTNAME",
",",
"$",
"firstname",
",",
"$",
"comparison",
")",
";",
"}"
]
| Filter the query on the firstname column
Example usage:
<code>
$query->filterByFirstname('fooValue'); // WHERE firstname = 'fooValue'
$query->filterByFirstname('%fooValue%'); // WHERE firstname LIKE '%fooValue%'
</code>
@param string $firstname The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return UserQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"firstname",
"column"
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php#L429-L441 |
19,571 | slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php | BaseUserQuery.filterByLastname | public function filterByLastname($lastname = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($lastname)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $lastname)) {
$lastname = str_replace('*', '%', $lastname);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::LASTNAME, $lastname, $comparison);
} | php | public function filterByLastname($lastname = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($lastname)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $lastname)) {
$lastname = str_replace('*', '%', $lastname);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::LASTNAME, $lastname, $comparison);
} | [
"public",
"function",
"filterByLastname",
"(",
"$",
"lastname",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"lastname",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"lastname",
")",
")",
"{",
"$",
"lastname",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"lastname",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"LASTNAME",
",",
"$",
"lastname",
",",
"$",
"comparison",
")",
";",
"}"
]
| Filter the query on the lastname column
Example usage:
<code>
$query->filterByLastname('fooValue'); // WHERE lastname = 'fooValue'
$query->filterByLastname('%fooValue%'); // WHERE lastname LIKE '%fooValue%'
</code>
@param string $lastname The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return UserQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"lastname",
"column"
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php#L458-L470 |
19,572 | slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php | BaseUserQuery.filterByPhone | public function filterByPhone($phone = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($phone)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $phone)) {
$phone = str_replace('*', '%', $phone);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::PHONE, $phone, $comparison);
} | php | public function filterByPhone($phone = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($phone)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $phone)) {
$phone = str_replace('*', '%', $phone);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::PHONE, $phone, $comparison);
} | [
"public",
"function",
"filterByPhone",
"(",
"$",
"phone",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"phone",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"phone",
")",
")",
"{",
"$",
"phone",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"phone",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"PHONE",
",",
"$",
"phone",
",",
"$",
"comparison",
")",
";",
"}"
]
| Filter the query on the phone column
Example usage:
<code>
$query->filterByPhone('fooValue'); // WHERE phone = 'fooValue'
$query->filterByPhone('%fooValue%'); // WHERE phone LIKE '%fooValue%'
</code>
@param string $phone The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return UserQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"phone",
"column"
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php#L516-L528 |
19,573 | slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php | BaseUserQuery.filterByMemo | public function filterByMemo($memo = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($memo)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $memo)) {
$memo = str_replace('*', '%', $memo);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::MEMO, $memo, $comparison);
} | php | public function filterByMemo($memo = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($memo)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $memo)) {
$memo = str_replace('*', '%', $memo);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(UserPeer::MEMO, $memo, $comparison);
} | [
"public",
"function",
"filterByMemo",
"(",
"$",
"memo",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"memo",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"memo",
")",
")",
"{",
"$",
"memo",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"memo",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"MEMO",
",",
"$",
"memo",
",",
"$",
"comparison",
")",
";",
"}"
]
| Filter the query on the memo column
Example usage:
<code>
$query->filterByMemo('fooValue'); // WHERE memo = 'fooValue'
$query->filterByMemo('%fooValue%'); // WHERE memo LIKE '%fooValue%'
</code>
@param string $memo The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return UserQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"memo",
"column"
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php#L545-L557 |
19,574 | slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php | BaseUserQuery.filterByActivated | public function filterByActivated($activated = null, $comparison = null)
{
if (is_string($activated)) {
$activated = in_array(strtolower($activated), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(UserPeer::ACTIVATED, $activated, $comparison);
} | php | public function filterByActivated($activated = null, $comparison = null)
{
if (is_string($activated)) {
$activated = in_array(strtolower($activated), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(UserPeer::ACTIVATED, $activated, $comparison);
} | [
"public",
"function",
"filterByActivated",
"(",
"$",
"activated",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"activated",
")",
")",
"{",
"$",
"activated",
"=",
"in_array",
"(",
"strtolower",
"(",
"$",
"activated",
")",
",",
"array",
"(",
"'false'",
",",
"'off'",
",",
"'-'",
",",
"'no'",
",",
"'n'",
",",
"'0'",
",",
"''",
")",
")",
"?",
"false",
":",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"ACTIVATED",
",",
"$",
"activated",
",",
"$",
"comparison",
")",
";",
"}"
]
| Filter the query on the activated column
Example usage:
<code>
$query->filterByActivated(true); // WHERE activated = true
$query->filterByActivated('yes'); // WHERE activated = true
</code>
@param boolean|string $activated The value to use as filter.
Non-boolean arguments are converted using the following rules:
* 1, '1', 'true', 'on', and 'yes' are converted to boolean true
* 0, '0', 'false', 'off', and 'no' are converted to boolean false
Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return UserQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"activated",
"column"
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php#L577-L584 |
19,575 | slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php | BaseUserQuery.filterByLastLogin | public function filterByLastLogin($lastLogin = null, $comparison = null)
{
if (is_array($lastLogin)) {
$useMinMax = false;
if (isset($lastLogin['min'])) {
$this->addUsingAlias(UserPeer::LAST_LOGIN, $lastLogin['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($lastLogin['max'])) {
$this->addUsingAlias(UserPeer::LAST_LOGIN, $lastLogin['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(UserPeer::LAST_LOGIN, $lastLogin, $comparison);
} | php | public function filterByLastLogin($lastLogin = null, $comparison = null)
{
if (is_array($lastLogin)) {
$useMinMax = false;
if (isset($lastLogin['min'])) {
$this->addUsingAlias(UserPeer::LAST_LOGIN, $lastLogin['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($lastLogin['max'])) {
$this->addUsingAlias(UserPeer::LAST_LOGIN, $lastLogin['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(UserPeer::LAST_LOGIN, $lastLogin, $comparison);
} | [
"public",
"function",
"filterByLastLogin",
"(",
"$",
"lastLogin",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"lastLogin",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"lastLogin",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"LAST_LOGIN",
",",
"$",
"lastLogin",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"lastLogin",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"LAST_LOGIN",
",",
"$",
"lastLogin",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"UserPeer",
"::",
"LAST_LOGIN",
",",
"$",
"lastLogin",
",",
"$",
"comparison",
")",
";",
"}"
]
| Filter the query on the last_login column
Example usage:
<code>
$query->filterByLastLogin('2011-03-14'); // WHERE last_login = '2011-03-14'
$query->filterByLastLogin('now'); // WHERE last_login = '2011-03-14'
$query->filterByLastLogin(array('max' => 'yesterday')); // WHERE last_login < '2011-03-13'
</code>
@param mixed $lastLogin The value to use as filter.
Values can be integers (unix timestamps), DateTime objects, or strings.
Empty strings are treated as NULL.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return UserQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"last_login",
"column"
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserQuery.php#L606-L627 |
19,576 | ivliev/imagefly | src/Ivliev/Imagefly/Imagefly.php | Imagefly._set_params | private function _set_params()
{
// Get values from request
$params = \Request::route('params');
$filepath = $this->config['abs_path'] . '/' . \Request::route('imagepath');
// echo $params; exit;
// If enforcing params, ensure it's a match
if ($this->config['enforce_presets'] && !in_array($params, $this->config['presets'])) {
abort(404);
}
$image = new Image();
$image->configure(config('image'));
if (function_exists('exif_read_data')) {
$this->image = $image->make($filepath)->orientate();
} else {
$this->image = $image->make($filepath);
}
// The parameters are separated by hyphens
$raw_params = explode('-', $params);
// Update param values from passed values
foreach ($raw_params as $raw_param) {
$name = $raw_param[0];
$value = substr($raw_param, 1, strlen($raw_param) - 1);
if ($name == 'c') {
$this->url_params[$name] = TRUE;
// When croping, we must have a width and height to pass to imagecreatetruecolor method
// Make width the height or vice versa if either is not passed
if (empty($this->url_params['w'])) {
$this->url_params['w'] = $this->url_params['h'];
}
if (empty($this->url_params['h'])) {
$this->url_params['h'] = $this->url_params['w'];
}
} elseif (key_exists($name, $this->url_params)) {
// Remaining expected params (w, h, q)
$this->url_params[$name] = $value;
} else {
// Watermarks or invalid params
$this->url_params[$raw_param] = $raw_param;
}
}
// Do not scale up images
if (! $this->config['scale_up']) {
if ($this->url_params['w'] > $this->image->width()) {
$this->url_params['w'] = $this->image->width();
}
if ($this->url_params['h'] > $this->image->height()) {
$this->url_params['h'] = $this->image->height();
}
}
// Must have at least a width or height
if (empty($this->url_params['w']) and empty($this->url_params['h'])) {
throw new HTTP_Exception_404('The requested URL :uri was not found on this server.', array(
':uri' => Request::$current->uri()
));
}
// Set the url filepath
$this->source_file = $filepath;
} | php | private function _set_params()
{
// Get values from request
$params = \Request::route('params');
$filepath = $this->config['abs_path'] . '/' . \Request::route('imagepath');
// echo $params; exit;
// If enforcing params, ensure it's a match
if ($this->config['enforce_presets'] && !in_array($params, $this->config['presets'])) {
abort(404);
}
$image = new Image();
$image->configure(config('image'));
if (function_exists('exif_read_data')) {
$this->image = $image->make($filepath)->orientate();
} else {
$this->image = $image->make($filepath);
}
// The parameters are separated by hyphens
$raw_params = explode('-', $params);
// Update param values from passed values
foreach ($raw_params as $raw_param) {
$name = $raw_param[0];
$value = substr($raw_param, 1, strlen($raw_param) - 1);
if ($name == 'c') {
$this->url_params[$name] = TRUE;
// When croping, we must have a width and height to pass to imagecreatetruecolor method
// Make width the height or vice versa if either is not passed
if (empty($this->url_params['w'])) {
$this->url_params['w'] = $this->url_params['h'];
}
if (empty($this->url_params['h'])) {
$this->url_params['h'] = $this->url_params['w'];
}
} elseif (key_exists($name, $this->url_params)) {
// Remaining expected params (w, h, q)
$this->url_params[$name] = $value;
} else {
// Watermarks or invalid params
$this->url_params[$raw_param] = $raw_param;
}
}
// Do not scale up images
if (! $this->config['scale_up']) {
if ($this->url_params['w'] > $this->image->width()) {
$this->url_params['w'] = $this->image->width();
}
if ($this->url_params['h'] > $this->image->height()) {
$this->url_params['h'] = $this->image->height();
}
}
// Must have at least a width or height
if (empty($this->url_params['w']) and empty($this->url_params['h'])) {
throw new HTTP_Exception_404('The requested URL :uri was not found on this server.', array(
':uri' => Request::$current->uri()
));
}
// Set the url filepath
$this->source_file = $filepath;
} | [
"private",
"function",
"_set_params",
"(",
")",
"{",
"// Get values from request",
"$",
"params",
"=",
"\\",
"Request",
"::",
"route",
"(",
"'params'",
")",
";",
"$",
"filepath",
"=",
"$",
"this",
"->",
"config",
"[",
"'abs_path'",
"]",
".",
"'/'",
".",
"\\",
"Request",
"::",
"route",
"(",
"'imagepath'",
")",
";",
"// echo $params; exit;",
"// If enforcing params, ensure it's a match",
"if",
"(",
"$",
"this",
"->",
"config",
"[",
"'enforce_presets'",
"]",
"&&",
"!",
"in_array",
"(",
"$",
"params",
",",
"$",
"this",
"->",
"config",
"[",
"'presets'",
"]",
")",
")",
"{",
"abort",
"(",
"404",
")",
";",
"}",
"$",
"image",
"=",
"new",
"Image",
"(",
")",
";",
"$",
"image",
"->",
"configure",
"(",
"config",
"(",
"'image'",
")",
")",
";",
"if",
"(",
"function_exists",
"(",
"'exif_read_data'",
")",
")",
"{",
"$",
"this",
"->",
"image",
"=",
"$",
"image",
"->",
"make",
"(",
"$",
"filepath",
")",
"->",
"orientate",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"image",
"=",
"$",
"image",
"->",
"make",
"(",
"$",
"filepath",
")",
";",
"}",
"// The parameters are separated by hyphens",
"$",
"raw_params",
"=",
"explode",
"(",
"'-'",
",",
"$",
"params",
")",
";",
"// Update param values from passed values",
"foreach",
"(",
"$",
"raw_params",
"as",
"$",
"raw_param",
")",
"{",
"$",
"name",
"=",
"$",
"raw_param",
"[",
"0",
"]",
";",
"$",
"value",
"=",
"substr",
"(",
"$",
"raw_param",
",",
"1",
",",
"strlen",
"(",
"$",
"raw_param",
")",
"-",
"1",
")",
";",
"if",
"(",
"$",
"name",
"==",
"'c'",
")",
"{",
"$",
"this",
"->",
"url_params",
"[",
"$",
"name",
"]",
"=",
"TRUE",
";",
"// When croping, we must have a width and height to pass to imagecreatetruecolor method",
"// Make width the height or vice versa if either is not passed",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'w'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"url_params",
"[",
"'w'",
"]",
"=",
"$",
"this",
"->",
"url_params",
"[",
"'h'",
"]",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'h'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"url_params",
"[",
"'h'",
"]",
"=",
"$",
"this",
"->",
"url_params",
"[",
"'w'",
"]",
";",
"}",
"}",
"elseif",
"(",
"key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"url_params",
")",
")",
"{",
"// Remaining expected params (w, h, q)",
"$",
"this",
"->",
"url_params",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"// Watermarks or invalid params",
"$",
"this",
"->",
"url_params",
"[",
"$",
"raw_param",
"]",
"=",
"$",
"raw_param",
";",
"}",
"}",
"// Do not scale up images",
"if",
"(",
"!",
"$",
"this",
"->",
"config",
"[",
"'scale_up'",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'w'",
"]",
">",
"$",
"this",
"->",
"image",
"->",
"width",
"(",
")",
")",
"{",
"$",
"this",
"->",
"url_params",
"[",
"'w'",
"]",
"=",
"$",
"this",
"->",
"image",
"->",
"width",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'h'",
"]",
">",
"$",
"this",
"->",
"image",
"->",
"height",
"(",
")",
")",
"{",
"$",
"this",
"->",
"url_params",
"[",
"'h'",
"]",
"=",
"$",
"this",
"->",
"image",
"->",
"height",
"(",
")",
";",
"}",
"}",
"// Must have at least a width or height",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'w'",
"]",
")",
"and",
"empty",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'h'",
"]",
")",
")",
"{",
"throw",
"new",
"HTTP_Exception_404",
"(",
"'The requested URL :uri was not found on this server.'",
",",
"array",
"(",
"':uri'",
"=>",
"Request",
"::",
"$",
"current",
"->",
"uri",
"(",
")",
")",
")",
";",
"}",
"// Set the url filepath",
"$",
"this",
"->",
"source_file",
"=",
"$",
"filepath",
";",
"}"
]
| Sets the operations params from the url | [
"Sets",
"the",
"operations",
"params",
"from",
"the",
"url"
]
| 0363eb37cc0748292a2142f0ec9027827e9d4eba | https://github.com/ivliev/imagefly/blob/0363eb37cc0748292a2142f0ec9027827e9d4eba/src/Ivliev/Imagefly/Imagefly.php#L165-L233 |
19,577 | ivliev/imagefly | src/Ivliev/Imagefly/Imagefly.php | Imagefly._cached_required | private function _cached_required()
{
$image_info = getimagesize($this->source_file);
if (($this->url_params['w'] == $image_info[0]) and ($this->url_params['h'] == $image_info[1])) {
$this->serve_default = TRUE;
return FALSE;
}
return TRUE;
} | php | private function _cached_required()
{
$image_info = getimagesize($this->source_file);
if (($this->url_params['w'] == $image_info[0]) and ($this->url_params['h'] == $image_info[1])) {
$this->serve_default = TRUE;
return FALSE;
}
return TRUE;
} | [
"private",
"function",
"_cached_required",
"(",
")",
"{",
"$",
"image_info",
"=",
"getimagesize",
"(",
"$",
"this",
"->",
"source_file",
")",
";",
"if",
"(",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'w'",
"]",
"==",
"$",
"image_info",
"[",
"0",
"]",
")",
"and",
"(",
"$",
"this",
"->",
"url_params",
"[",
"'h'",
"]",
"==",
"$",
"image_info",
"[",
"1",
"]",
")",
")",
"{",
"$",
"this",
"->",
"serve_default",
"=",
"TRUE",
";",
"return",
"FALSE",
";",
"}",
"return",
"TRUE",
";",
"}"
]
| Checks that the param dimensions are are lower then current image dimensions
@return boolean | [
"Checks",
"that",
"the",
"param",
"dimensions",
"are",
"are",
"lower",
"then",
"current",
"image",
"dimensions"
]
| 0363eb37cc0748292a2142f0ec9027827e9d4eba | https://github.com/ivliev/imagefly/blob/0363eb37cc0748292a2142f0ec9027827e9d4eba/src/Ivliev/Imagefly/Imagefly.php#L250-L260 |
19,578 | ivliev/imagefly | src/Ivliev/Imagefly/Imagefly.php | Imagefly._encoded_filename | private function _encoded_filename()
{
$ext = strtolower(pathinfo($this->source_file, PATHINFO_EXTENSION));
$encode = md5($this->source_file . http_build_query($this->url_params));
// Build the parts of the filename
$encoded_name = $encode . '-' . $this->source_modified . '.' . $ext;
return $encoded_name;
} | php | private function _encoded_filename()
{
$ext = strtolower(pathinfo($this->source_file, PATHINFO_EXTENSION));
$encode = md5($this->source_file . http_build_query($this->url_params));
// Build the parts of the filename
$encoded_name = $encode . '-' . $this->source_modified . '.' . $ext;
return $encoded_name;
} | [
"private",
"function",
"_encoded_filename",
"(",
")",
"{",
"$",
"ext",
"=",
"strtolower",
"(",
"pathinfo",
"(",
"$",
"this",
"->",
"source_file",
",",
"PATHINFO_EXTENSION",
")",
")",
";",
"$",
"encode",
"=",
"md5",
"(",
"$",
"this",
"->",
"source_file",
".",
"http_build_query",
"(",
"$",
"this",
"->",
"url_params",
")",
")",
";",
"// Build the parts of the filename",
"$",
"encoded_name",
"=",
"$",
"encode",
".",
"'-'",
".",
"$",
"this",
"->",
"source_modified",
".",
"'.'",
".",
"$",
"ext",
";",
"return",
"$",
"encoded_name",
";",
"}"
]
| Returns a hash of the filepath and params plus last modified of source to be used as a unique filename
@return string | [
"Returns",
"a",
"hash",
"of",
"the",
"filepath",
"and",
"params",
"plus",
"last",
"modified",
"of",
"source",
"to",
"be",
"used",
"as",
"a",
"unique",
"filename"
]
| 0363eb37cc0748292a2142f0ec9027827e9d4eba | https://github.com/ivliev/imagefly/blob/0363eb37cc0748292a2142f0ec9027827e9d4eba/src/Ivliev/Imagefly/Imagefly.php#L267-L276 |
19,579 | ivliev/imagefly | src/Ivliev/Imagefly/Imagefly.php | Imagefly._create_headers | private function _create_headers($file_data)
{
// Create the required header vars
$last_modified = gmdate('D, d M Y H:i:s', filemtime($file_data)) . ' GMT';
$filesystem = new \Illuminate\Filesystem\Filesystem;
$content_type = $filesystem->mimeType($file_data);
// $content_type = \Illuminate\Filesystem\Filesystem::mimeType($file_data);
$content_length = filesize($file_data);
$expires = gmdate('D, d M Y H:i:s', (time() + $this->config['cache_expire'])) . ' GMT';
$max_age = 'max-age=' . $this->config['cache_expire'] . ', public';
// Some required headers
header("Last-Modified: $last_modified");
header("Content-Type: $content_type");
header("Content-Length: $content_length");
// How long to hold in the browser cache
header("Expires: $expires");
/**
* Public in the Cache-Control lets proxies know that it is okay to
* cache this content.
* If this is being served over HTTPS, there may be
* sensitive content and therefore should probably not be cached by
* proxy servers.
*/
header("Cache-Control: $max_age");
// Set the 304 Not Modified if required
$this->_modified_headers($last_modified);
/**
* The "Connection: close" header allows us to serve the file and let
* the browser finish processing the script so we can do extra work
* without making the user wait.
* This header must come last or the file
* size will not properly work for images in the browser's cache
*/
header("Connection: close");
} | php | private function _create_headers($file_data)
{
// Create the required header vars
$last_modified = gmdate('D, d M Y H:i:s', filemtime($file_data)) . ' GMT';
$filesystem = new \Illuminate\Filesystem\Filesystem;
$content_type = $filesystem->mimeType($file_data);
// $content_type = \Illuminate\Filesystem\Filesystem::mimeType($file_data);
$content_length = filesize($file_data);
$expires = gmdate('D, d M Y H:i:s', (time() + $this->config['cache_expire'])) . ' GMT';
$max_age = 'max-age=' . $this->config['cache_expire'] . ', public';
// Some required headers
header("Last-Modified: $last_modified");
header("Content-Type: $content_type");
header("Content-Length: $content_length");
// How long to hold in the browser cache
header("Expires: $expires");
/**
* Public in the Cache-Control lets proxies know that it is okay to
* cache this content.
* If this is being served over HTTPS, there may be
* sensitive content and therefore should probably not be cached by
* proxy servers.
*/
header("Cache-Control: $max_age");
// Set the 304 Not Modified if required
$this->_modified_headers($last_modified);
/**
* The "Connection: close" header allows us to serve the file and let
* the browser finish processing the script so we can do extra work
* without making the user wait.
* This header must come last or the file
* size will not properly work for images in the browser's cache
*/
header("Connection: close");
} | [
"private",
"function",
"_create_headers",
"(",
"$",
"file_data",
")",
"{",
"// Create the required header vars",
"$",
"last_modified",
"=",
"gmdate",
"(",
"'D, d M Y H:i:s'",
",",
"filemtime",
"(",
"$",
"file_data",
")",
")",
".",
"' GMT'",
";",
"$",
"filesystem",
"=",
"new",
"\\",
"Illuminate",
"\\",
"Filesystem",
"\\",
"Filesystem",
";",
"$",
"content_type",
"=",
"$",
"filesystem",
"->",
"mimeType",
"(",
"$",
"file_data",
")",
";",
"// $content_type = \\Illuminate\\Filesystem\\Filesystem::mimeType($file_data);",
"$",
"content_length",
"=",
"filesize",
"(",
"$",
"file_data",
")",
";",
"$",
"expires",
"=",
"gmdate",
"(",
"'D, d M Y H:i:s'",
",",
"(",
"time",
"(",
")",
"+",
"$",
"this",
"->",
"config",
"[",
"'cache_expire'",
"]",
")",
")",
".",
"' GMT'",
";",
"$",
"max_age",
"=",
"'max-age='",
".",
"$",
"this",
"->",
"config",
"[",
"'cache_expire'",
"]",
".",
"', public'",
";",
"// Some required headers",
"header",
"(",
"\"Last-Modified: $last_modified\"",
")",
";",
"header",
"(",
"\"Content-Type: $content_type\"",
")",
";",
"header",
"(",
"\"Content-Length: $content_length\"",
")",
";",
"// How long to hold in the browser cache",
"header",
"(",
"\"Expires: $expires\"",
")",
";",
"/**\n * Public in the Cache-Control lets proxies know that it is okay to\n * cache this content.\n * If this is being served over HTTPS, there may be\n * sensitive content and therefore should probably not be cached by\n * proxy servers.\n */",
"header",
"(",
"\"Cache-Control: $max_age\"",
")",
";",
"// Set the 304 Not Modified if required",
"$",
"this",
"->",
"_modified_headers",
"(",
"$",
"last_modified",
")",
";",
"/**\n * The \"Connection: close\" header allows us to serve the file and let\n * the browser finish processing the script so we can do extra work\n * without making the user wait.\n * This header must come last or the file\n * size will not properly work for images in the browser's cache\n */",
"header",
"(",
"\"Connection: close\"",
")",
";",
"}"
]
| Create the image HTTP headers
@param
string path to the file to server (either default or cached version) | [
"Create",
"the",
"image",
"HTTP",
"headers"
]
| 0363eb37cc0748292a2142f0ec9027827e9d4eba | https://github.com/ivliev/imagefly/blob/0363eb37cc0748292a2142f0ec9027827e9d4eba/src/Ivliev/Imagefly/Imagefly.php#L336-L375 |
19,580 | ivliev/imagefly | src/Ivliev/Imagefly/Imagefly.php | Imagefly._modified_headers | private function _modified_headers($last_modified)
{
$modified_since = (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) ? stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']) : FALSE;
if (! $modified_since or $modified_since != $last_modified)
return;
// Nothing has changed since their last request - serve a 304 and exit
header('HTTP/1.1 304 Not Modified');
header('Connection: close');
exit();
} | php | private function _modified_headers($last_modified)
{
$modified_since = (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) ? stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']) : FALSE;
if (! $modified_since or $modified_since != $last_modified)
return;
// Nothing has changed since their last request - serve a 304 and exit
header('HTTP/1.1 304 Not Modified');
header('Connection: close');
exit();
} | [
"private",
"function",
"_modified_headers",
"(",
"$",
"last_modified",
")",
"{",
"$",
"modified_since",
"=",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_IF_MODIFIED_SINCE'",
"]",
")",
")",
"?",
"stripslashes",
"(",
"$",
"_SERVER",
"[",
"'HTTP_IF_MODIFIED_SINCE'",
"]",
")",
":",
"FALSE",
";",
"if",
"(",
"!",
"$",
"modified_since",
"or",
"$",
"modified_since",
"!=",
"$",
"last_modified",
")",
"return",
";",
"// Nothing has changed since their last request - serve a 304 and exit",
"header",
"(",
"'HTTP/1.1 304 Not Modified'",
")",
";",
"header",
"(",
"'Connection: close'",
")",
";",
"exit",
"(",
")",
";",
"}"
]
| Rerurns 304 Not Modified HTTP headers if required and exits
@param
string header formatted date | [
"Rerurns",
"304",
"Not",
"Modified",
"HTTP",
"headers",
"if",
"required",
"and",
"exits"
]
| 0363eb37cc0748292a2142f0ec9027827e9d4eba | https://github.com/ivliev/imagefly/blob/0363eb37cc0748292a2142f0ec9027827e9d4eba/src/Ivliev/Imagefly/Imagefly.php#L383-L394 |
19,581 | ivliev/imagefly | src/Ivliev/Imagefly/Imagefly.php | Imagefly._serve_file | private function _serve_file()
{
// Set either the source or cache file as our datasource
if ($this->serve_default) {
$file_data = $this->source_file;
} else {
$file_data = $this->cached_file;
}
// Output the file
$this->_output_file($file_data);
} | php | private function _serve_file()
{
// Set either the source or cache file as our datasource
if ($this->serve_default) {
$file_data = $this->source_file;
} else {
$file_data = $this->cached_file;
}
// Output the file
$this->_output_file($file_data);
} | [
"private",
"function",
"_serve_file",
"(",
")",
"{",
"// Set either the source or cache file as our datasource",
"if",
"(",
"$",
"this",
"->",
"serve_default",
")",
"{",
"$",
"file_data",
"=",
"$",
"this",
"->",
"source_file",
";",
"}",
"else",
"{",
"$",
"file_data",
"=",
"$",
"this",
"->",
"cached_file",
";",
"}",
"// Output the file",
"$",
"this",
"->",
"_output_file",
"(",
"$",
"file_data",
")",
";",
"}"
]
| Decide which filesource we are using and serve | [
"Decide",
"which",
"filesource",
"we",
"are",
"using",
"and",
"serve"
]
| 0363eb37cc0748292a2142f0ec9027827e9d4eba | https://github.com/ivliev/imagefly/blob/0363eb37cc0748292a2142f0ec9027827e9d4eba/src/Ivliev/Imagefly/Imagefly.php#L399-L410 |
19,582 | ivliev/imagefly | src/Ivliev/Imagefly/Imagefly.php | Imagefly._output_file | private function _output_file($file_data)
{
// Create the headers
$this->_create_headers($file_data);
// Get the file data
$data = file_get_contents($file_data);
// Send the image to the browser in bite-sized chunks
$chunk_size = 1024 * 8;
$fp = fopen('php://memory', 'r+b');
// Process file data
fwrite($fp, $data);
rewind($fp);
while (! feof($fp)) {
echo fread($fp, $chunk_size);
flush();
}
fclose($fp);
exit();
} | php | private function _output_file($file_data)
{
// Create the headers
$this->_create_headers($file_data);
// Get the file data
$data = file_get_contents($file_data);
// Send the image to the browser in bite-sized chunks
$chunk_size = 1024 * 8;
$fp = fopen('php://memory', 'r+b');
// Process file data
fwrite($fp, $data);
rewind($fp);
while (! feof($fp)) {
echo fread($fp, $chunk_size);
flush();
}
fclose($fp);
exit();
} | [
"private",
"function",
"_output_file",
"(",
"$",
"file_data",
")",
"{",
"// Create the headers",
"$",
"this",
"->",
"_create_headers",
"(",
"$",
"file_data",
")",
";",
"// Get the file data",
"$",
"data",
"=",
"file_get_contents",
"(",
"$",
"file_data",
")",
";",
"// Send the image to the browser in bite-sized chunks",
"$",
"chunk_size",
"=",
"1024",
"*",
"8",
";",
"$",
"fp",
"=",
"fopen",
"(",
"'php://memory'",
",",
"'r+b'",
")",
";",
"// Process file data",
"fwrite",
"(",
"$",
"fp",
",",
"$",
"data",
")",
";",
"rewind",
"(",
"$",
"fp",
")",
";",
"while",
"(",
"!",
"feof",
"(",
"$",
"fp",
")",
")",
"{",
"echo",
"fread",
"(",
"$",
"fp",
",",
"$",
"chunk_size",
")",
";",
"flush",
"(",
")",
";",
"}",
"fclose",
"(",
"$",
"fp",
")",
";",
"exit",
"(",
")",
";",
"}"
]
| Outputs the cached image file and exits
@param
string path to the file to server (either default or cached version) | [
"Outputs",
"the",
"cached",
"image",
"file",
"and",
"exits"
]
| 0363eb37cc0748292a2142f0ec9027827e9d4eba | https://github.com/ivliev/imagefly/blob/0363eb37cc0748292a2142f0ec9027827e9d4eba/src/Ivliev/Imagefly/Imagefly.php#L418-L440 |
19,583 | devmobgroup/postcodes | src/Providers/HttpProvider.php | HttpProvider.getClient | public function getClient(): ClientInterface
{
if (! isset($this->client)) {
$this->client = new GuzzleClient();
}
return $this->client;
} | php | public function getClient(): ClientInterface
{
if (! isset($this->client)) {
$this->client = new GuzzleClient();
}
return $this->client;
} | [
"public",
"function",
"getClient",
"(",
")",
":",
"ClientInterface",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"client",
")",
")",
"{",
"$",
"this",
"->",
"client",
"=",
"new",
"GuzzleClient",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"client",
";",
"}"
]
| Get the Http client.
@return \GuzzleHttp\ClientInterface | [
"Get",
"the",
"Http",
"client",
"."
]
| 1a8438fd960a8f50ec28d61af94560892b529f12 | https://github.com/devmobgroup/postcodes/blob/1a8438fd960a8f50ec28d61af94560892b529f12/src/Providers/HttpProvider.php#L39-L46 |
19,584 | devmobgroup/postcodes | src/Providers/HttpProvider.php | HttpProvider.lookup | public function lookup(string $postcode, string $number): array
{
$input = [
'postcode' => $postcode,
'number' => $number
];
// Create http request to send
$request = $this->request($input);
$response = null;
try {
// Make request and parse response
return $this->parse(
$response = $this->client->send($request),
$input
);
} catch (GuzzleException $e) {
// Catch request exceptions and try to parse the response
if ($e instanceof RequestException && $e->hasResponse()) {
return $this->parse($e->getResponse(), $input);
}
throw new HttpException('Guzzle: ' . $e->getMessage(), $request, $response, $e);
} catch (Throwable $e) {
// Only rethrow exceptions from our own package
if ($e instanceof PostcodesException) {
throw $e;
}
throw new LogicException('Uncaught exception: ' . $e->getMessage(), 0, $e);
}
} | php | public function lookup(string $postcode, string $number): array
{
$input = [
'postcode' => $postcode,
'number' => $number
];
// Create http request to send
$request = $this->request($input);
$response = null;
try {
// Make request and parse response
return $this->parse(
$response = $this->client->send($request),
$input
);
} catch (GuzzleException $e) {
// Catch request exceptions and try to parse the response
if ($e instanceof RequestException && $e->hasResponse()) {
return $this->parse($e->getResponse(), $input);
}
throw new HttpException('Guzzle: ' . $e->getMessage(), $request, $response, $e);
} catch (Throwable $e) {
// Only rethrow exceptions from our own package
if ($e instanceof PostcodesException) {
throw $e;
}
throw new LogicException('Uncaught exception: ' . $e->getMessage(), 0, $e);
}
} | [
"public",
"function",
"lookup",
"(",
"string",
"$",
"postcode",
",",
"string",
"$",
"number",
")",
":",
"array",
"{",
"$",
"input",
"=",
"[",
"'postcode'",
"=>",
"$",
"postcode",
",",
"'number'",
"=>",
"$",
"number",
"]",
";",
"// Create http request to send",
"$",
"request",
"=",
"$",
"this",
"->",
"request",
"(",
"$",
"input",
")",
";",
"$",
"response",
"=",
"null",
";",
"try",
"{",
"// Make request and parse response",
"return",
"$",
"this",
"->",
"parse",
"(",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"$",
"request",
")",
",",
"$",
"input",
")",
";",
"}",
"catch",
"(",
"GuzzleException",
"$",
"e",
")",
"{",
"// Catch request exceptions and try to parse the response",
"if",
"(",
"$",
"e",
"instanceof",
"RequestException",
"&&",
"$",
"e",
"->",
"hasResponse",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"parse",
"(",
"$",
"e",
"->",
"getResponse",
"(",
")",
",",
"$",
"input",
")",
";",
"}",
"throw",
"new",
"HttpException",
"(",
"'Guzzle: '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"request",
",",
"$",
"response",
",",
"$",
"e",
")",
";",
"}",
"catch",
"(",
"Throwable",
"$",
"e",
")",
"{",
"// Only rethrow exceptions from our own package",
"if",
"(",
"$",
"e",
"instanceof",
"PostcodesException",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"throw",
"new",
"LogicException",
"(",
"'Uncaught exception: '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
]
| Lookup an address by postcode and house number.
@param string $postcode
@param string $number
@return \DevMob\Postcodes\Address\Address[]
@throws \DevMob\Postcodes\Exceptions\NoSuchCombinationException
@throws \DevMob\Postcodes\Exceptions\PostcodesException | [
"Lookup",
"an",
"address",
"by",
"postcode",
"and",
"house",
"number",
"."
]
| 1a8438fd960a8f50ec28d61af94560892b529f12 | https://github.com/devmobgroup/postcodes/blob/1a8438fd960a8f50ec28d61af94560892b529f12/src/Providers/HttpProvider.php#L58-L90 |
19,585 | webforge-labs/psc-cms | lib/Psc/Data/FileCache.php | FileCache.remove | public function remove($key) {
$file = $this->getFile($this->getKey($key));
$file->delete();
return $this;
} | php | public function remove($key) {
$file = $this->getFile($this->getKey($key));
$file->delete();
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getFile",
"(",
"$",
"this",
"->",
"getKey",
"(",
"$",
"key",
")",
")",
";",
"$",
"file",
"->",
"delete",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Entfernt die Dateia us dem Cache
@chainable | [
"Entfernt",
"die",
"Dateia",
"us",
"dem",
"Cache"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Data/FileCache.php#L96-L100 |
19,586 | jfusion/org.jfusion.framework | src/Installer/Framework.php | Framework.uninstall | public static function uninstall()
{
$results = array();
//see if any mods from jfusion plugins need to be removed
$plugins = Factory::getPlugins('all', false, 0);
foreach($plugins as $plugin) {
$model = new Plugin();
$result = $model->uninstall($plugin->name);
$r = new stdClass();
$result['status'] = 1;
$r->status = $result['status'];
if (!$r->status) {
$r->message = Text::_('UNINSTALL') . ' ' . $plugin->name . ' ' . Text::_('FAILED');
} else {
$r->message = Text::_('UNINSTALL') . ' ' . $plugin->name . ' ' . Text::_('SUCCESS');
}
$results[] = $r;
}
//remove the jfusion tables.
$db = Factory::getDBO();
$query = 'DROP TABLE IF EXISTS #__jfusion';
$db->setQuery($query);
$db->execute();
$query = 'DROP TABLE IF EXISTS #__jfusion_sync';
$db->setQuery($query);
$db->execute();
$query = 'DROP TABLE IF EXISTS #__jfusion_sync_details';
$db->setQuery($query);
$db->execute();
$query = 'DROP TABLE IF EXISTS #__jfusion_users';
$db->setQuery($query);
$db->execute();
return $results;
} | php | public static function uninstall()
{
$results = array();
//see if any mods from jfusion plugins need to be removed
$plugins = Factory::getPlugins('all', false, 0);
foreach($plugins as $plugin) {
$model = new Plugin();
$result = $model->uninstall($plugin->name);
$r = new stdClass();
$result['status'] = 1;
$r->status = $result['status'];
if (!$r->status) {
$r->message = Text::_('UNINSTALL') . ' ' . $plugin->name . ' ' . Text::_('FAILED');
} else {
$r->message = Text::_('UNINSTALL') . ' ' . $plugin->name . ' ' . Text::_('SUCCESS');
}
$results[] = $r;
}
//remove the jfusion tables.
$db = Factory::getDBO();
$query = 'DROP TABLE IF EXISTS #__jfusion';
$db->setQuery($query);
$db->execute();
$query = 'DROP TABLE IF EXISTS #__jfusion_sync';
$db->setQuery($query);
$db->execute();
$query = 'DROP TABLE IF EXISTS #__jfusion_sync_details';
$db->setQuery($query);
$db->execute();
$query = 'DROP TABLE IF EXISTS #__jfusion_users';
$db->setQuery($query);
$db->execute();
return $results;
} | [
"public",
"static",
"function",
"uninstall",
"(",
")",
"{",
"$",
"results",
"=",
"array",
"(",
")",
";",
"//see if any mods from jfusion plugins need to be removed",
"$",
"plugins",
"=",
"Factory",
"::",
"getPlugins",
"(",
"'all'",
",",
"false",
",",
"0",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"$",
"model",
"=",
"new",
"Plugin",
"(",
")",
";",
"$",
"result",
"=",
"$",
"model",
"->",
"uninstall",
"(",
"$",
"plugin",
"->",
"name",
")",
";",
"$",
"r",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"result",
"[",
"'status'",
"]",
"=",
"1",
";",
"$",
"r",
"->",
"status",
"=",
"$",
"result",
"[",
"'status'",
"]",
";",
"if",
"(",
"!",
"$",
"r",
"->",
"status",
")",
"{",
"$",
"r",
"->",
"message",
"=",
"Text",
"::",
"_",
"(",
"'UNINSTALL'",
")",
".",
"' '",
".",
"$",
"plugin",
"->",
"name",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'FAILED'",
")",
";",
"}",
"else",
"{",
"$",
"r",
"->",
"message",
"=",
"Text",
"::",
"_",
"(",
"'UNINSTALL'",
")",
".",
"' '",
".",
"$",
"plugin",
"->",
"name",
".",
"' '",
".",
"Text",
"::",
"_",
"(",
"'SUCCESS'",
")",
";",
"}",
"$",
"results",
"[",
"]",
"=",
"$",
"r",
";",
"}",
"//remove the jfusion tables.",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"$",
"query",
"=",
"'DROP TABLE IF EXISTS #__jfusion'",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"$",
"query",
"=",
"'DROP TABLE IF EXISTS #__jfusion_sync'",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"$",
"query",
"=",
"'DROP TABLE IF EXISTS #__jfusion_sync_details'",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"$",
"query",
"=",
"'DROP TABLE IF EXISTS #__jfusion_users'",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"return",
"$",
"results",
";",
"}"
]
| method to uninstall the component
@return stdClass[] with status/message field for plugin uninstall info | [
"method",
"to",
"uninstall",
"the",
"component"
]
| 65771963f23ccabcf1f867eb17c9452299cfe683 | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Installer/Framework.php#L226-L267 |
19,587 | yuncms/framework | src/admin/widgets/Box.php | Box.renderTools | protected function renderTools()
{
$tools = '';
if($this->collapseButton !== false){
$tools .= '<a class="collapse-link"><i class="fa fa-chevron-up"></i></a>';
}
if ($this->closeButton !== false) {
$tools .= '<a class="close-link"><i class="fa fa-times"></i></a>';
}
if (!empty($tools)) {
return Html::tag('div', $tools, ['class' => 'ibox-tools']);
} else {
return null;
}
} | php | protected function renderTools()
{
$tools = '';
if($this->collapseButton !== false){
$tools .= '<a class="collapse-link"><i class="fa fa-chevron-up"></i></a>';
}
if ($this->closeButton !== false) {
$tools .= '<a class="close-link"><i class="fa fa-times"></i></a>';
}
if (!empty($tools)) {
return Html::tag('div', $tools, ['class' => 'ibox-tools']);
} else {
return null;
}
} | [
"protected",
"function",
"renderTools",
"(",
")",
"{",
"$",
"tools",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"collapseButton",
"!==",
"false",
")",
"{",
"$",
"tools",
".=",
"'<a class=\"collapse-link\"><i class=\"fa fa-chevron-up\"></i></a>'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"closeButton",
"!==",
"false",
")",
"{",
"$",
"tools",
".=",
"'<a class=\"close-link\"><i class=\"fa fa-times\"></i></a>'",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"tools",
")",
")",
"{",
"return",
"Html",
"::",
"tag",
"(",
"'div'",
",",
"$",
"tools",
",",
"[",
"'class'",
"=>",
"'ibox-tools'",
"]",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
]
| Renders the tools
@return string the rendering result | [
"Renders",
"the",
"tools"
]
| af42e28ea4ae15ab8eead3f6d119f93863b94154 | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/widgets/Box.php#L148-L162 |
19,588 | jfusion/org.jfusion.framework | src/User/User.php | User.search | public static function search(Userinfo $userinfo, $lookup = false)
{
$exsistingUser = null;
if ($lookup && $userinfo->getJname() !== null) {
$userPlugin = Factory::getUser($userinfo->getJname());
$exsistingUser = $userPlugin->lookupUser($userinfo);
}
if (!$exsistingUser instanceof Userinfo) {
$plugins = Factory::getPlugins();
foreach ($plugins as $plugin) {
try {
$JFusionSlave = Factory::getUser($plugin->name);
$exsistingUser = $JFusionSlave->getUser($userinfo);
if ($exsistingUser instanceof Userinfo) {
break;
}
} catch (Exception $e) {
}
}
}
return $exsistingUser;
} | php | public static function search(Userinfo $userinfo, $lookup = false)
{
$exsistingUser = null;
if ($lookup && $userinfo->getJname() !== null) {
$userPlugin = Factory::getUser($userinfo->getJname());
$exsistingUser = $userPlugin->lookupUser($userinfo);
}
if (!$exsistingUser instanceof Userinfo) {
$plugins = Factory::getPlugins();
foreach ($plugins as $plugin) {
try {
$JFusionSlave = Factory::getUser($plugin->name);
$exsistingUser = $JFusionSlave->getUser($userinfo);
if ($exsistingUser instanceof Userinfo) {
break;
}
} catch (Exception $e) {
}
}
}
return $exsistingUser;
} | [
"public",
"static",
"function",
"search",
"(",
"Userinfo",
"$",
"userinfo",
",",
"$",
"lookup",
"=",
"false",
")",
"{",
"$",
"exsistingUser",
"=",
"null",
";",
"if",
"(",
"$",
"lookup",
"&&",
"$",
"userinfo",
"->",
"getJname",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"userPlugin",
"=",
"Factory",
"::",
"getUser",
"(",
"$",
"userinfo",
"->",
"getJname",
"(",
")",
")",
";",
"$",
"exsistingUser",
"=",
"$",
"userPlugin",
"->",
"lookupUser",
"(",
"$",
"userinfo",
")",
";",
"}",
"if",
"(",
"!",
"$",
"exsistingUser",
"instanceof",
"Userinfo",
")",
"{",
"$",
"plugins",
"=",
"Factory",
"::",
"getPlugins",
"(",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"try",
"{",
"$",
"JFusionSlave",
"=",
"Factory",
"::",
"getUser",
"(",
"$",
"plugin",
"->",
"name",
")",
";",
"$",
"exsistingUser",
"=",
"$",
"JFusionSlave",
"->",
"getUser",
"(",
"$",
"userinfo",
")",
";",
"if",
"(",
"$",
"exsistingUser",
"instanceof",
"Userinfo",
")",
"{",
"break",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"}",
"}",
"}",
"return",
"$",
"exsistingUser",
";",
"}"
]
| Finds the first user that match starting with master
@param Userinfo $userinfo
@param bool $lookup
@return null|Userinfo returns first used founed | [
"Finds",
"the",
"first",
"user",
"that",
"match",
"starting",
"with",
"master"
]
| 65771963f23ccabcf1f867eb17c9452299cfe683 | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/User.php#L494-L518 |
19,589 | jfusion/org.jfusion.framework | src/User/User.php | User.remove | public static function remove(Userinfo $userinfo)
{
$db = Factory::getDBO();
$query = $db->getQuery(true)
->delete('#__jfusion_users')
->where('userid = ' . $db->quote($userinfo->userid));
$db->setQuery($query);
$db->execute();
} | php | public static function remove(Userinfo $userinfo)
{
$db = Factory::getDBO();
$query = $db->getQuery(true)
->delete('#__jfusion_users')
->where('userid = ' . $db->quote($userinfo->userid));
$db->setQuery($query);
$db->execute();
} | [
"public",
"static",
"function",
"remove",
"(",
"Userinfo",
"$",
"userinfo",
")",
"{",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"delete",
"(",
"'#__jfusion_users'",
")",
"->",
"where",
"(",
"'userid = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"userinfo",
"->",
"userid",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"}"
]
| Delete old user data in the lookup table
@param Userinfo $userinfo userinfo of the user to be deleted | [
"Delete",
"old",
"user",
"data",
"in",
"the",
"lookup",
"table"
]
| 65771963f23ccabcf1f867eb17c9452299cfe683 | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/User/User.php#L525-L535 |
19,590 | RobinMalfait/l4-laracasts-feed | src/Malfaitrobin/Laracasts/Laracasts.php | Laracasts.meta | public function meta()
{
$xml = (array) $this->xml;
unset($xml['entry']);
$xml['link'] = (object) $xml['link']->{"@attributes"};
return (object) $xml;
} | php | public function meta()
{
$xml = (array) $this->xml;
unset($xml['entry']);
$xml['link'] = (object) $xml['link']->{"@attributes"};
return (object) $xml;
} | [
"public",
"function",
"meta",
"(",
")",
"{",
"$",
"xml",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"xml",
";",
"unset",
"(",
"$",
"xml",
"[",
"'entry'",
"]",
")",
";",
"$",
"xml",
"[",
"'link'",
"]",
"=",
"(",
"object",
")",
"$",
"xml",
"[",
"'link'",
"]",
"->",
"{",
"\"@attributes\"",
"}",
";",
"return",
"(",
"object",
")",
"$",
"xml",
";",
"}"
]
| Get the meta information of the xml feed
@return object | [
"Get",
"the",
"meta",
"information",
"of",
"the",
"xml",
"feed"
]
| 26033545dc42dd15fa5c2ed64c28868cdd43f933 | https://github.com/RobinMalfait/l4-laracasts-feed/blob/26033545dc42dd15fa5c2ed64c28868cdd43f933/src/Malfaitrobin/Laracasts/Laracasts.php#L59-L67 |
19,591 | RobinMalfait/l4-laracasts-feed | src/Malfaitrobin/Laracasts/Laracasts.php | Laracasts.getXML | protected function getXML()
{
$key = 'xml_' . md5($this->url); // Everybody loves md5!
if ($this->cache->has($key)) {
$this->xml = $this->cache->get($key);
} else {
$this->xml = $this->fetchXML();
$this->xml = $this->changeLinkElements($this->xml);
$this->cache->put($key, $this->xml, $this->cacheTime);
}
} | php | protected function getXML()
{
$key = 'xml_' . md5($this->url); // Everybody loves md5!
if ($this->cache->has($key)) {
$this->xml = $this->cache->get($key);
} else {
$this->xml = $this->fetchXML();
$this->xml = $this->changeLinkElements($this->xml);
$this->cache->put($key, $this->xml, $this->cacheTime);
}
} | [
"protected",
"function",
"getXML",
"(",
")",
"{",
"$",
"key",
"=",
"'xml_'",
".",
"md5",
"(",
"$",
"this",
"->",
"url",
")",
";",
"// Everybody loves md5!",
"if",
"(",
"$",
"this",
"->",
"cache",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
"xml",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"$",
"key",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"xml",
"=",
"$",
"this",
"->",
"fetchXML",
"(",
")",
";",
"$",
"this",
"->",
"xml",
"=",
"$",
"this",
"->",
"changeLinkElements",
"(",
"$",
"this",
"->",
"xml",
")",
";",
"$",
"this",
"->",
"cache",
"->",
"put",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"xml",
",",
"$",
"this",
"->",
"cacheTime",
")",
";",
"}",
"}"
]
| Get the xml from the server, and cache the result
@return void | [
"Get",
"the",
"xml",
"from",
"the",
"server",
"and",
"cache",
"the",
"result"
]
| 26033545dc42dd15fa5c2ed64c28868cdd43f933 | https://github.com/RobinMalfait/l4-laracasts-feed/blob/26033545dc42dd15fa5c2ed64c28868cdd43f933/src/Malfaitrobin/Laracasts/Laracasts.php#L84-L97 |
19,592 | askupasoftware/amarkal | Autoloader.php | Autoloader.register_assets | static function register_assets()
{
\wp_enqueue_script( 'jquery' );
\wp_enqueue_script( 'jquery-ui' );
\wp_enqueue_script( 'jquery-ui-datepicker' );
\wp_enqueue_script( 'jquery-ui-spinner' );
\wp_enqueue_script( 'jquery-ui-slider' );
\wp_enqueue_script( 'jquery-ui-resizable' );
\wp_enqueue_script( 'wp-color-picker' );
\wp_enqueue_script( 'amarkal', AMARKAL_ASSETS_URL.'js/amarkal.min.js', array('jquery'), AMARKAL_VERSION, true );
\wp_enqueue_script( 'select2', AMARKAL_ASSETS_URL.'js/select2.min.js', array('jquery'), '4.0.3', true );
\wp_enqueue_script( 'ace-editor', 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ace.js', array(), '1.2.6', true );
\wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css', array(), '4.7.0' );
\wp_enqueue_style( 'amarkal', AMARKAL_ASSETS_URL.'css/amarkal.min.css', array('wp-color-picker'), AMARKAL_VERSION );
\wp_enqueue_style( 'select2', AMARKAL_ASSETS_URL.'css/select2.min.css', array(), '4.0.3' );
} | php | static function register_assets()
{
\wp_enqueue_script( 'jquery' );
\wp_enqueue_script( 'jquery-ui' );
\wp_enqueue_script( 'jquery-ui-datepicker' );
\wp_enqueue_script( 'jquery-ui-spinner' );
\wp_enqueue_script( 'jquery-ui-slider' );
\wp_enqueue_script( 'jquery-ui-resizable' );
\wp_enqueue_script( 'wp-color-picker' );
\wp_enqueue_script( 'amarkal', AMARKAL_ASSETS_URL.'js/amarkal.min.js', array('jquery'), AMARKAL_VERSION, true );
\wp_enqueue_script( 'select2', AMARKAL_ASSETS_URL.'js/select2.min.js', array('jquery'), '4.0.3', true );
\wp_enqueue_script( 'ace-editor', 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ace.js', array(), '1.2.6', true );
\wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css', array(), '4.7.0' );
\wp_enqueue_style( 'amarkal', AMARKAL_ASSETS_URL.'css/amarkal.min.css', array('wp-color-picker'), AMARKAL_VERSION );
\wp_enqueue_style( 'select2', AMARKAL_ASSETS_URL.'css/select2.min.css', array(), '4.0.3' );
} | [
"static",
"function",
"register_assets",
"(",
")",
"{",
"\\",
"wp_enqueue_script",
"(",
"'jquery'",
")",
";",
"\\",
"wp_enqueue_script",
"(",
"'jquery-ui'",
")",
";",
"\\",
"wp_enqueue_script",
"(",
"'jquery-ui-datepicker'",
")",
";",
"\\",
"wp_enqueue_script",
"(",
"'jquery-ui-spinner'",
")",
";",
"\\",
"wp_enqueue_script",
"(",
"'jquery-ui-slider'",
")",
";",
"\\",
"wp_enqueue_script",
"(",
"'jquery-ui-resizable'",
")",
";",
"\\",
"wp_enqueue_script",
"(",
"'wp-color-picker'",
")",
";",
"\\",
"wp_enqueue_script",
"(",
"'amarkal'",
",",
"AMARKAL_ASSETS_URL",
".",
"'js/amarkal.min.js'",
",",
"array",
"(",
"'jquery'",
")",
",",
"AMARKAL_VERSION",
",",
"true",
")",
";",
"\\",
"wp_enqueue_script",
"(",
"'select2'",
",",
"AMARKAL_ASSETS_URL",
".",
"'js/select2.min.js'",
",",
"array",
"(",
"'jquery'",
")",
",",
"'4.0.3'",
",",
"true",
")",
";",
"\\",
"wp_enqueue_script",
"(",
"'ace-editor'",
",",
"'https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ace.js'",
",",
"array",
"(",
")",
",",
"'1.2.6'",
",",
"true",
")",
";",
"\\",
"wp_enqueue_style",
"(",
"'font-awesome'",
",",
"'//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'",
",",
"array",
"(",
")",
",",
"'4.7.0'",
")",
";",
"\\",
"wp_enqueue_style",
"(",
"'amarkal'",
",",
"AMARKAL_ASSETS_URL",
".",
"'css/amarkal.min.css'",
",",
"array",
"(",
"'wp-color-picker'",
")",
",",
"AMARKAL_VERSION",
")",
";",
"\\",
"wp_enqueue_style",
"(",
"'select2'",
",",
"AMARKAL_ASSETS_URL",
".",
"'css/select2.min.css'",
",",
"array",
"(",
")",
",",
"'4.0.3'",
")",
";",
"}"
]
| Register Amarkal Scripts and Stylesheets | [
"Register",
"Amarkal",
"Scripts",
"and",
"Stylesheets"
]
| fe8283e2d6847ef697abec832da7ee741a85058c | https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Autoloader.php#L70-L87 |
19,593 | jfusion/org.jfusion.framework | src/Plugin/Admin.php | Admin.getDefaultUsergroup | function getDefaultUsergroup()
{
$usergroups = Groups::get($this->getJname(), true);
$groups = array();
if ($usergroups !== null) {
$list = $this->getUsergroupList();
foreach ($list as $group) {
if(in_array($group->id, $usergroups)){
$groups[] = $group->name;
}
}
}
return $groups;
} | php | function getDefaultUsergroup()
{
$usergroups = Groups::get($this->getJname(), true);
$groups = array();
if ($usergroups !== null) {
$list = $this->getUsergroupList();
foreach ($list as $group) {
if(in_array($group->id, $usergroups)){
$groups[] = $group->name;
}
}
}
return $groups;
} | [
"function",
"getDefaultUsergroup",
"(",
")",
"{",
"$",
"usergroups",
"=",
"Groups",
"::",
"get",
"(",
"$",
"this",
"->",
"getJname",
"(",
")",
",",
"true",
")",
";",
"$",
"groups",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"usergroups",
"!==",
"null",
")",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"getUsergroupList",
"(",
")",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"group",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"group",
"->",
"id",
",",
"$",
"usergroups",
")",
")",
"{",
"$",
"groups",
"[",
"]",
"=",
"$",
"group",
"->",
"name",
";",
"}",
"}",
"}",
"return",
"$",
"groups",
";",
"}"
]
| Function used to display the default usergroup in the JFusion plugin overview
@return array Default usergroup name | [
"Function",
"used",
"to",
"display",
"the",
"default",
"usergroup",
"in",
"the",
"JFusion",
"plugin",
"overview"
]
| 65771963f23ccabcf1f867eb17c9452299cfe683 | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Plugin/Admin.php#L89-L103 |
19,594 | jfusion/org.jfusion.framework | src/Plugin/Admin.php | Admin.debugConfig | function debugConfig()
{
$jname = $this->getJname();
//get registration status
$new_registration = $this->allowRegistration();
if ($new_registration) {
$plugins = Framework::getSlaves();
foreach ($plugins as $plugin) {
if ($plugin->name == $jname) {
Framework::raise(LogLevel::NOTICE, Text::_('DISABLE_REGISTRATION'), $jname);
}
}
} else {
$master = Framework::getMaster();
if ($master && $master->name == $jname) {
Framework::raise(LogLevel::NOTICE, Text::_('ENABLE_REGISTRATION'), $jname);
}
}
//most dual login problems are due to incorrect cookie domain settings
//therefore we should check it and output a warning if needed.
$cookie_domain = $this->params->get('cookie_domain',-1);
if ($cookie_domain!==-1) {
$cookie_domain = str_replace(array('http://', 'https://'), array('', ''), $cookie_domain);
$correct_array = explode('.', html_entity_decode($_SERVER['SERVER_NAME']));
//check for domain names with double extentions
if (isset($correct_array[count($correct_array) - 2]) && isset($correct_array[count($correct_array) - 1])) {
//domain array
$domain_array = array('com', 'net', 'org', 'co', 'me');
if (in_array($correct_array[count($correct_array) - 2], $domain_array)) {
$correct_domain = '.' . $correct_array[count($correct_array) - 3] . '.' . $correct_array[count($correct_array) - 2] . '.' . $correct_array[count($correct_array) - 1];
} else {
$correct_domain = '.' . $correct_array[count($correct_array) - 2] . '.' . $correct_array[count($correct_array) - 1];
}
if ($correct_domain != $cookie_domain && !$this->allowEmptyCookieDomain()) {
Framework::raise(LogLevel::NOTICE, Text::_('BEST_COOKIE_DOMAIN') . ' ' . $correct_domain, $jname);
}
}
}
//also check the cookie path as it can interfere with frameless
$cookie_path = $this->params->get('cookie_path',-1);
if ($cookie_path !== -1) {
if ($cookie_path != '/' && !$this->allowEmptyCookiePath()) {
Framework::raise(LogLevel::NOTICE, Text::_('BEST_COOKIE_PATH') . ' /', $jname);
}
}
// allow additional checking of the configuration
$this->debugConfigExtra();
} | php | function debugConfig()
{
$jname = $this->getJname();
//get registration status
$new_registration = $this->allowRegistration();
if ($new_registration) {
$plugins = Framework::getSlaves();
foreach ($plugins as $plugin) {
if ($plugin->name == $jname) {
Framework::raise(LogLevel::NOTICE, Text::_('DISABLE_REGISTRATION'), $jname);
}
}
} else {
$master = Framework::getMaster();
if ($master && $master->name == $jname) {
Framework::raise(LogLevel::NOTICE, Text::_('ENABLE_REGISTRATION'), $jname);
}
}
//most dual login problems are due to incorrect cookie domain settings
//therefore we should check it and output a warning if needed.
$cookie_domain = $this->params->get('cookie_domain',-1);
if ($cookie_domain!==-1) {
$cookie_domain = str_replace(array('http://', 'https://'), array('', ''), $cookie_domain);
$correct_array = explode('.', html_entity_decode($_SERVER['SERVER_NAME']));
//check for domain names with double extentions
if (isset($correct_array[count($correct_array) - 2]) && isset($correct_array[count($correct_array) - 1])) {
//domain array
$domain_array = array('com', 'net', 'org', 'co', 'me');
if (in_array($correct_array[count($correct_array) - 2], $domain_array)) {
$correct_domain = '.' . $correct_array[count($correct_array) - 3] . '.' . $correct_array[count($correct_array) - 2] . '.' . $correct_array[count($correct_array) - 1];
} else {
$correct_domain = '.' . $correct_array[count($correct_array) - 2] . '.' . $correct_array[count($correct_array) - 1];
}
if ($correct_domain != $cookie_domain && !$this->allowEmptyCookieDomain()) {
Framework::raise(LogLevel::NOTICE, Text::_('BEST_COOKIE_DOMAIN') . ' ' . $correct_domain, $jname);
}
}
}
//also check the cookie path as it can interfere with frameless
$cookie_path = $this->params->get('cookie_path',-1);
if ($cookie_path !== -1) {
if ($cookie_path != '/' && !$this->allowEmptyCookiePath()) {
Framework::raise(LogLevel::NOTICE, Text::_('BEST_COOKIE_PATH') . ' /', $jname);
}
}
// allow additional checking of the configuration
$this->debugConfigExtra();
} | [
"function",
"debugConfig",
"(",
")",
"{",
"$",
"jname",
"=",
"$",
"this",
"->",
"getJname",
"(",
")",
";",
"//get registration status",
"$",
"new_registration",
"=",
"$",
"this",
"->",
"allowRegistration",
"(",
")",
";",
"if",
"(",
"$",
"new_registration",
")",
"{",
"$",
"plugins",
"=",
"Framework",
"::",
"getSlaves",
"(",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"$",
"plugin",
"->",
"name",
"==",
"$",
"jname",
")",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"NOTICE",
",",
"Text",
"::",
"_",
"(",
"'DISABLE_REGISTRATION'",
")",
",",
"$",
"jname",
")",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"master",
"=",
"Framework",
"::",
"getMaster",
"(",
")",
";",
"if",
"(",
"$",
"master",
"&&",
"$",
"master",
"->",
"name",
"==",
"$",
"jname",
")",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"NOTICE",
",",
"Text",
"::",
"_",
"(",
"'ENABLE_REGISTRATION'",
")",
",",
"$",
"jname",
")",
";",
"}",
"}",
"//most dual login problems are due to incorrect cookie domain settings",
"//therefore we should check it and output a warning if needed.",
"$",
"cookie_domain",
"=",
"$",
"this",
"->",
"params",
"->",
"get",
"(",
"'cookie_domain'",
",",
"-",
"1",
")",
";",
"if",
"(",
"$",
"cookie_domain",
"!==",
"-",
"1",
")",
"{",
"$",
"cookie_domain",
"=",
"str_replace",
"(",
"array",
"(",
"'http://'",
",",
"'https://'",
")",
",",
"array",
"(",
"''",
",",
"''",
")",
",",
"$",
"cookie_domain",
")",
";",
"$",
"correct_array",
"=",
"explode",
"(",
"'.'",
",",
"html_entity_decode",
"(",
"$",
"_SERVER",
"[",
"'SERVER_NAME'",
"]",
")",
")",
";",
"//check for domain names with double extentions",
"if",
"(",
"isset",
"(",
"$",
"correct_array",
"[",
"count",
"(",
"$",
"correct_array",
")",
"-",
"2",
"]",
")",
"&&",
"isset",
"(",
"$",
"correct_array",
"[",
"count",
"(",
"$",
"correct_array",
")",
"-",
"1",
"]",
")",
")",
"{",
"//domain array",
"$",
"domain_array",
"=",
"array",
"(",
"'com'",
",",
"'net'",
",",
"'org'",
",",
"'co'",
",",
"'me'",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"correct_array",
"[",
"count",
"(",
"$",
"correct_array",
")",
"-",
"2",
"]",
",",
"$",
"domain_array",
")",
")",
"{",
"$",
"correct_domain",
"=",
"'.'",
".",
"$",
"correct_array",
"[",
"count",
"(",
"$",
"correct_array",
")",
"-",
"3",
"]",
".",
"'.'",
".",
"$",
"correct_array",
"[",
"count",
"(",
"$",
"correct_array",
")",
"-",
"2",
"]",
".",
"'.'",
".",
"$",
"correct_array",
"[",
"count",
"(",
"$",
"correct_array",
")",
"-",
"1",
"]",
";",
"}",
"else",
"{",
"$",
"correct_domain",
"=",
"'.'",
".",
"$",
"correct_array",
"[",
"count",
"(",
"$",
"correct_array",
")",
"-",
"2",
"]",
".",
"'.'",
".",
"$",
"correct_array",
"[",
"count",
"(",
"$",
"correct_array",
")",
"-",
"1",
"]",
";",
"}",
"if",
"(",
"$",
"correct_domain",
"!=",
"$",
"cookie_domain",
"&&",
"!",
"$",
"this",
"->",
"allowEmptyCookieDomain",
"(",
")",
")",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"NOTICE",
",",
"Text",
"::",
"_",
"(",
"'BEST_COOKIE_DOMAIN'",
")",
".",
"' '",
".",
"$",
"correct_domain",
",",
"$",
"jname",
")",
";",
"}",
"}",
"}",
"//also check the cookie path as it can interfere with frameless",
"$",
"cookie_path",
"=",
"$",
"this",
"->",
"params",
"->",
"get",
"(",
"'cookie_path'",
",",
"-",
"1",
")",
";",
"if",
"(",
"$",
"cookie_path",
"!==",
"-",
"1",
")",
"{",
"if",
"(",
"$",
"cookie_path",
"!=",
"'/'",
"&&",
"!",
"$",
"this",
"->",
"allowEmptyCookiePath",
"(",
")",
")",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"NOTICE",
",",
"Text",
"::",
"_",
"(",
"'BEST_COOKIE_PATH'",
")",
".",
"' /'",
",",
"$",
"jname",
")",
";",
"}",
"}",
"// allow additional checking of the configuration",
"$",
"this",
"->",
"debugConfigExtra",
"(",
")",
";",
"}"
]
| Function that checks if the plugin has a valid config
jerror is used for output
@return void | [
"Function",
"that",
"checks",
"if",
"the",
"plugin",
"has",
"a",
"valid",
"config",
"jerror",
"is",
"used",
"for",
"output"
]
| 65771963f23ccabcf1f867eb17c9452299cfe683 | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Plugin/Admin.php#L234-L287 |
19,595 | jfusion/org.jfusion.framework | src/Plugin/Admin.php | Admin.saveParameters | final public function saveParameters($post, $wizard = false)
{
$jname = $this->getJname();
$result = false;
try {
if (!empty($jname)) {
$db = Factory::getDBO();
if (isset($post['source_url'])) {
//check for trailing slash in URL, in order for us not to worry about it later
$post['source_path'] = rtrim($post['source_path'], '/\\');
$post['source_path'] .= '/';
//now also check to see that the url starts with http:// or https://
if (substr($post['source_url'], 0, 7) != 'http://' && substr($post['source_url'], 0, 8) != 'https://') {
if (substr($post['source_url'], 0, 1) != '/') {
$post['source_url'] = 'http://' . $post['source_url'];
}
}
}
if (isset($post['source_path'])) {
if (!empty($post['source_path'])) {
$post['source_path'] = rtrim($post['source_path'], '/\\');
$post['source_path'] .= '/';
if (!is_dir($post['source_path'])) {
Framework::raise(LogLevel::WARNING, Text::_('SOURCE_PATH_NOT_FOUND'));
}
}
}
if ($wizard) {
//data submitted by the wizard so merge the data with existing params if they do indeed exist
$query = $db->getQuery(true)
->select('params')
->from('#__jfusion')
->where('name = ' . $db->quote($jname));
$db->setQuery($query);
$params = $db->loadResult();
$params = new Registry($params);
$existing_params = $params->toArray();
if (is_array($existing_params)) {
$post = array_merge($existing_params, $post);
}
}
$data = new Registry($post);
//set the current parameters in the jfusion table
$query = $db->getQuery(true)
->update('#__jfusion')
->set('params = ' . $db->quote($data->toString()))
->where('name = ' . $db->quote($jname));
$db->setQuery($query);
$db->execute();
//reset the params instance for this plugin
Factory::getParams($jname, true);
$result = true;
}
} catch (Exception $e ) {
//there was an error saving the parameters
Framework::raise(LogLevel::ERROR, $e, $jname);
}
return $result;
} | php | final public function saveParameters($post, $wizard = false)
{
$jname = $this->getJname();
$result = false;
try {
if (!empty($jname)) {
$db = Factory::getDBO();
if (isset($post['source_url'])) {
//check for trailing slash in URL, in order for us not to worry about it later
$post['source_path'] = rtrim($post['source_path'], '/\\');
$post['source_path'] .= '/';
//now also check to see that the url starts with http:// or https://
if (substr($post['source_url'], 0, 7) != 'http://' && substr($post['source_url'], 0, 8) != 'https://') {
if (substr($post['source_url'], 0, 1) != '/') {
$post['source_url'] = 'http://' . $post['source_url'];
}
}
}
if (isset($post['source_path'])) {
if (!empty($post['source_path'])) {
$post['source_path'] = rtrim($post['source_path'], '/\\');
$post['source_path'] .= '/';
if (!is_dir($post['source_path'])) {
Framework::raise(LogLevel::WARNING, Text::_('SOURCE_PATH_NOT_FOUND'));
}
}
}
if ($wizard) {
//data submitted by the wizard so merge the data with existing params if they do indeed exist
$query = $db->getQuery(true)
->select('params')
->from('#__jfusion')
->where('name = ' . $db->quote($jname));
$db->setQuery($query);
$params = $db->loadResult();
$params = new Registry($params);
$existing_params = $params->toArray();
if (is_array($existing_params)) {
$post = array_merge($existing_params, $post);
}
}
$data = new Registry($post);
//set the current parameters in the jfusion table
$query = $db->getQuery(true)
->update('#__jfusion')
->set('params = ' . $db->quote($data->toString()))
->where('name = ' . $db->quote($jname));
$db->setQuery($query);
$db->execute();
//reset the params instance for this plugin
Factory::getParams($jname, true);
$result = true;
}
} catch (Exception $e ) {
//there was an error saving the parameters
Framework::raise(LogLevel::ERROR, $e, $jname);
}
return $result;
} | [
"final",
"public",
"function",
"saveParameters",
"(",
"$",
"post",
",",
"$",
"wizard",
"=",
"false",
")",
"{",
"$",
"jname",
"=",
"$",
"this",
"->",
"getJname",
"(",
")",
";",
"$",
"result",
"=",
"false",
";",
"try",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"jname",
")",
")",
"{",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"post",
"[",
"'source_url'",
"]",
")",
")",
"{",
"//check for trailing slash in URL, in order for us not to worry about it later",
"$",
"post",
"[",
"'source_path'",
"]",
"=",
"rtrim",
"(",
"$",
"post",
"[",
"'source_path'",
"]",
",",
"'/\\\\'",
")",
";",
"$",
"post",
"[",
"'source_path'",
"]",
".=",
"'/'",
";",
"//now also check to see that the url starts with http:// or https://",
"if",
"(",
"substr",
"(",
"$",
"post",
"[",
"'source_url'",
"]",
",",
"0",
",",
"7",
")",
"!=",
"'http://'",
"&&",
"substr",
"(",
"$",
"post",
"[",
"'source_url'",
"]",
",",
"0",
",",
"8",
")",
"!=",
"'https://'",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"post",
"[",
"'source_url'",
"]",
",",
"0",
",",
"1",
")",
"!=",
"'/'",
")",
"{",
"$",
"post",
"[",
"'source_url'",
"]",
"=",
"'http://'",
".",
"$",
"post",
"[",
"'source_url'",
"]",
";",
"}",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"post",
"[",
"'source_path'",
"]",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"post",
"[",
"'source_path'",
"]",
")",
")",
"{",
"$",
"post",
"[",
"'source_path'",
"]",
"=",
"rtrim",
"(",
"$",
"post",
"[",
"'source_path'",
"]",
",",
"'/\\\\'",
")",
";",
"$",
"post",
"[",
"'source_path'",
"]",
".=",
"'/'",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"post",
"[",
"'source_path'",
"]",
")",
")",
"{",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"WARNING",
",",
"Text",
"::",
"_",
"(",
"'SOURCE_PATH_NOT_FOUND'",
")",
")",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"wizard",
")",
"{",
"//data submitted by the wizard so merge the data with existing params if they do indeed exist",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"select",
"(",
"'params'",
")",
"->",
"from",
"(",
"'#__jfusion'",
")",
"->",
"where",
"(",
"'name = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"jname",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"params",
"=",
"$",
"db",
"->",
"loadResult",
"(",
")",
";",
"$",
"params",
"=",
"new",
"Registry",
"(",
"$",
"params",
")",
";",
"$",
"existing_params",
"=",
"$",
"params",
"->",
"toArray",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"existing_params",
")",
")",
"{",
"$",
"post",
"=",
"array_merge",
"(",
"$",
"existing_params",
",",
"$",
"post",
")",
";",
"}",
"}",
"$",
"data",
"=",
"new",
"Registry",
"(",
"$",
"post",
")",
";",
"//set the current parameters in the jfusion table",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"update",
"(",
"'#__jfusion'",
")",
"->",
"set",
"(",
"'params = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"data",
"->",
"toString",
"(",
")",
")",
")",
"->",
"where",
"(",
"'name = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"jname",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"//reset the params instance for this plugin",
"Factory",
"::",
"getParams",
"(",
"$",
"jname",
",",
"true",
")",
";",
"$",
"result",
"=",
"true",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"//there was an error saving the parameters",
"Framework",
"::",
"raise",
"(",
"LogLevel",
"::",
"ERROR",
",",
"$",
"e",
",",
"$",
"jname",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
]
| Saves the posted JFusion component variables
@param array $post Array of JFusion plugin parameters posted to the JFusion component
@param boolean $wizard Notes if function was called by wizardresult();
@return boolean returns true if successful and false if an error occurred | [
"Saves",
"the",
"posted",
"JFusion",
"component",
"variables"
]
| 65771963f23ccabcf1f867eb17c9452299cfe683 | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Plugin/Admin.php#L402-L472 |
19,596 | austinkregel/Warden | src/Warden/Warden.php | Warden.clearInput | public static function clearInput($input)
{
if (is_array($input)) {
foreach ($input as $key => $value) {
if (!isset($value) || $value === '') {
unset($input[$key]);
}
}
return $input;
}
return $input;
} | php | public static function clearInput($input)
{
if (is_array($input)) {
foreach ($input as $key => $value) {
if (!isset($value) || $value === '') {
unset($input[$key]);
}
}
return $input;
}
return $input;
} | [
"public",
"static",
"function",
"clearInput",
"(",
"$",
"input",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"input",
")",
")",
"{",
"foreach",
"(",
"$",
"input",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"value",
")",
"||",
"$",
"value",
"===",
"''",
")",
"{",
"unset",
"(",
"$",
"input",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"return",
"$",
"input",
";",
"}",
"return",
"$",
"input",
";",
"}"
]
| This will look through the input and remove any unset values.
@param $input
@return mixed | [
"This",
"will",
"look",
"through",
"the",
"input",
"and",
"remove",
"any",
"unset",
"values",
"."
]
| 6f5a98bd79a488f0f300f4851061ac6f7d19f8a3 | https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/Warden.php#L16-L29 |
19,597 | austinkregel/Warden | src/Warden/Warden.php | Warden.apiRoutes | public static function apiRoutes()
{
Route::group([
'namespace' => 'Kregel\\Warden\\Http\\Controllers',
'prefix' => config('kregel.warden.route').'/api/v1.0',
'as' => 'warden::api.',
'middleware' => config('kregel.warden.auth.middleware_api'),
], function ($router) {
Route::get('media/{model}/{uuid}', ['as' => 'media', 'uses' => 'ApiController@displayMediaPage']);
// Should retrieve almost all items...
Route::get('{model}s', ['as' => 'get-all', 'uses' => 'ApiController@getAllModels']);
// Should retrieve some items...
Route::get('{model}', ['as' => 'get-models', 'uses' => 'ApiController@getSomeModels']);
// Should get an item...
Route::get('{model}/{id}', ['as' => 'get-model', 'uses' => 'ApiController@findModel']);
// Should create a model using /warden/api/v1.0/user/
Route::post('{model}', ['as' => 'create-model', 'uses' => 'ApiController@postModel']);
// Should update a model.
Route::post('{model}/{id}', ['as' => 'update-model-post', 'uses' => 'ApiController@putModel']);
Route::put('{model}/{id}', ['as' => 'update-model', 'uses' => 'ApiController@putModel']);
// Should delete a model.
Route::delete('d/{model}/{id}', ['as' => 'delete-model', 'uses' => 'ApiController@deleteModel']);
});
} | php | public static function apiRoutes()
{
Route::group([
'namespace' => 'Kregel\\Warden\\Http\\Controllers',
'prefix' => config('kregel.warden.route').'/api/v1.0',
'as' => 'warden::api.',
'middleware' => config('kregel.warden.auth.middleware_api'),
], function ($router) {
Route::get('media/{model}/{uuid}', ['as' => 'media', 'uses' => 'ApiController@displayMediaPage']);
// Should retrieve almost all items...
Route::get('{model}s', ['as' => 'get-all', 'uses' => 'ApiController@getAllModels']);
// Should retrieve some items...
Route::get('{model}', ['as' => 'get-models', 'uses' => 'ApiController@getSomeModels']);
// Should get an item...
Route::get('{model}/{id}', ['as' => 'get-model', 'uses' => 'ApiController@findModel']);
// Should create a model using /warden/api/v1.0/user/
Route::post('{model}', ['as' => 'create-model', 'uses' => 'ApiController@postModel']);
// Should update a model.
Route::post('{model}/{id}', ['as' => 'update-model-post', 'uses' => 'ApiController@putModel']);
Route::put('{model}/{id}', ['as' => 'update-model', 'uses' => 'ApiController@putModel']);
// Should delete a model.
Route::delete('d/{model}/{id}', ['as' => 'delete-model', 'uses' => 'ApiController@deleteModel']);
});
} | [
"public",
"static",
"function",
"apiRoutes",
"(",
")",
"{",
"Route",
"::",
"group",
"(",
"[",
"'namespace'",
"=>",
"'Kregel\\\\Warden\\\\Http\\\\Controllers'",
",",
"'prefix'",
"=>",
"config",
"(",
"'kregel.warden.route'",
")",
".",
"'/api/v1.0'",
",",
"'as'",
"=>",
"'warden::api.'",
",",
"'middleware'",
"=>",
"config",
"(",
"'kregel.warden.auth.middleware_api'",
")",
",",
"]",
",",
"function",
"(",
"$",
"router",
")",
"{",
"Route",
"::",
"get",
"(",
"'media/{model}/{uuid}'",
",",
"[",
"'as'",
"=>",
"'media'",
",",
"'uses'",
"=>",
"'ApiController@displayMediaPage'",
"]",
")",
";",
"// Should retrieve almost all items...",
"Route",
"::",
"get",
"(",
"'{model}s'",
",",
"[",
"'as'",
"=>",
"'get-all'",
",",
"'uses'",
"=>",
"'ApiController@getAllModels'",
"]",
")",
";",
"// Should retrieve some items...",
"Route",
"::",
"get",
"(",
"'{model}'",
",",
"[",
"'as'",
"=>",
"'get-models'",
",",
"'uses'",
"=>",
"'ApiController@getSomeModels'",
"]",
")",
";",
"// Should get an item...",
"Route",
"::",
"get",
"(",
"'{model}/{id}'",
",",
"[",
"'as'",
"=>",
"'get-model'",
",",
"'uses'",
"=>",
"'ApiController@findModel'",
"]",
")",
";",
"// Should create a model using /warden/api/v1.0/user/",
"Route",
"::",
"post",
"(",
"'{model}'",
",",
"[",
"'as'",
"=>",
"'create-model'",
",",
"'uses'",
"=>",
"'ApiController@postModel'",
"]",
")",
";",
"// Should update a model.",
"Route",
"::",
"post",
"(",
"'{model}/{id}'",
",",
"[",
"'as'",
"=>",
"'update-model-post'",
",",
"'uses'",
"=>",
"'ApiController@putModel'",
"]",
")",
";",
"Route",
"::",
"put",
"(",
"'{model}/{id}'",
",",
"[",
"'as'",
"=>",
"'update-model'",
",",
"'uses'",
"=>",
"'ApiController@putModel'",
"]",
")",
";",
"// Should delete a model.",
"Route",
"::",
"delete",
"(",
"'d/{model}/{id}'",
",",
"[",
"'as'",
"=>",
"'delete-model'",
",",
"'uses'",
"=>",
"'ApiController@deleteModel'",
"]",
")",
";",
"}",
")",
";",
"}"
]
| Define the api routes more dynamically. | [
"Define",
"the",
"api",
"routes",
"more",
"dynamically",
"."
]
| 6f5a98bd79a488f0f300f4851061ac6f7d19f8a3 | https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/Warden.php#L45-L71 |
19,598 | austinkregel/Warden | src/Warden/Warden.php | Warden.webRoutes | public static function webRoutes()
{
Route::group([
'namespace' => 'Kregel\\Warden\\Http\\Controllers',
'prefix' => config('kregel.warden.route'),
'as' => 'warden::',
'middleware' => config('kregel.warden.auth.middleware'),
], function ($router) {
Route::get('/', function () {
return view('warden::base');
});
Route::get('{model}/manage/new', ['as' => 'new-model', 'uses' => 'ModelController@getNewModel']);
Route::get('{model}s/manage', ['as' => 'models', 'uses' => 'ModelController@getModelList']);
Route::get('{model}/manage/{id}', ['as' => 'model', 'uses' => 'ModelController@getModel']);
});
} | php | public static function webRoutes()
{
Route::group([
'namespace' => 'Kregel\\Warden\\Http\\Controllers',
'prefix' => config('kregel.warden.route'),
'as' => 'warden::',
'middleware' => config('kregel.warden.auth.middleware'),
], function ($router) {
Route::get('/', function () {
return view('warden::base');
});
Route::get('{model}/manage/new', ['as' => 'new-model', 'uses' => 'ModelController@getNewModel']);
Route::get('{model}s/manage', ['as' => 'models', 'uses' => 'ModelController@getModelList']);
Route::get('{model}/manage/{id}', ['as' => 'model', 'uses' => 'ModelController@getModel']);
});
} | [
"public",
"static",
"function",
"webRoutes",
"(",
")",
"{",
"Route",
"::",
"group",
"(",
"[",
"'namespace'",
"=>",
"'Kregel\\\\Warden\\\\Http\\\\Controllers'",
",",
"'prefix'",
"=>",
"config",
"(",
"'kregel.warden.route'",
")",
",",
"'as'",
"=>",
"'warden::'",
",",
"'middleware'",
"=>",
"config",
"(",
"'kregel.warden.auth.middleware'",
")",
",",
"]",
",",
"function",
"(",
"$",
"router",
")",
"{",
"Route",
"::",
"get",
"(",
"'/'",
",",
"function",
"(",
")",
"{",
"return",
"view",
"(",
"'warden::base'",
")",
";",
"}",
")",
";",
"Route",
"::",
"get",
"(",
"'{model}/manage/new'",
",",
"[",
"'as'",
"=>",
"'new-model'",
",",
"'uses'",
"=>",
"'ModelController@getNewModel'",
"]",
")",
";",
"Route",
"::",
"get",
"(",
"'{model}s/manage'",
",",
"[",
"'as'",
"=>",
"'models'",
",",
"'uses'",
"=>",
"'ModelController@getModelList'",
"]",
")",
";",
"Route",
"::",
"get",
"(",
"'{model}/manage/{id}'",
",",
"[",
"'as'",
"=>",
"'model'",
",",
"'uses'",
"=>",
"'ModelController@getModel'",
"]",
")",
";",
"}",
")",
";",
"}"
]
| Define the web routes more dynamically. | [
"Define",
"the",
"web",
"routes",
"more",
"dynamically",
"."
]
| 6f5a98bd79a488f0f300f4851061ac6f7d19f8a3 | https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/Warden.php#L76-L92 |
19,599 | 2amigos/yiifoundation | helpers/Foundation.php | Foundation.register | public static function register($useZepto = false, $ie8Support = false)
{
static::registerCoreCss();
static::registerCoreScripts($useZepto);
if ($ie8Support)
static::registerBlockGridIeSupport();
} | php | public static function register($useZepto = false, $ie8Support = false)
{
static::registerCoreCss();
static::registerCoreScripts($useZepto);
if ($ie8Support)
static::registerBlockGridIeSupport();
} | [
"public",
"static",
"function",
"register",
"(",
"$",
"useZepto",
"=",
"false",
",",
"$",
"ie8Support",
"=",
"false",
")",
"{",
"static",
"::",
"registerCoreCss",
"(",
")",
";",
"static",
"::",
"registerCoreScripts",
"(",
"$",
"useZepto",
")",
";",
"if",
"(",
"$",
"ie8Support",
")",
"static",
"::",
"registerBlockGridIeSupport",
"(",
")",
";",
"}"
]
| Registers all core css and js scripts for foundation | [
"Registers",
"all",
"core",
"css",
"and",
"js",
"scripts",
"for",
"foundation"
]
| 49bed0d3ca1a9bac9299000e48a2661bdc8f9a29 | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Foundation.php#L27-L34 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.