repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
symphonycms/symphony-2 | symphony/lib/core/class.session.php | Session.write | public static function write($id, $data)
{
// Only prevent this record from saving if there isn't already a record
// in the database. This prevents empty Sessions from being created, but
// allows them to be nulled.
$session_data = Session::read($id);
if (!$session_data) {
... | php | public static function write($id, $data)
{
// Only prevent this record from saving if there isn't already a record
// in the database. This prevents empty Sessions from being created, but
// allows them to be nulled.
$session_data = Session::read($id);
if (!$session_data) {
... | [
"public",
"static",
"function",
"write",
"(",
"$",
"id",
",",
"$",
"data",
")",
"{",
"// Only prevent this record from saving if there isn't already a record",
"// in the database. This prevents empty Sessions from being created, but",
"// allows them to be nulled.",
"$",
"session_da... | Given an ID, and some data, save it into `tbl_sessions`. This uses
the ID as a unique key, and will override any existing data. If the
`$data` is deemed to be empty, no row will be saved in the database
unless there is an existing row.
@param string $id
The ID of the Session, usually a hash
@param string $data
The Ses... | [
"Given",
"an",
"ID",
"and",
"some",
"data",
"save",
"it",
"into",
"tbl_sessions",
".",
"This",
"uses",
"the",
"ID",
"as",
"a",
"unique",
"key",
"and",
"will",
"override",
"any",
"existing",
"data",
".",
"If",
"the",
"$data",
"is",
"deemed",
"to",
"be",... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/core/class.session.php#L180-L214 |
symphonycms/symphony-2 | symphony/lib/core/class.session.php | Session.unserialize | private static function unserialize($data)
{
$hasBuffer = isset($_SESSION);
$buffer = $_SESSION;
session_decode($data);
$session = $_SESSION;
if ($hasBuffer) {
$_SESSION = $buffer;
} else {
unset($_SESSION);
}
return $session;... | php | private static function unserialize($data)
{
$hasBuffer = isset($_SESSION);
$buffer = $_SESSION;
session_decode($data);
$session = $_SESSION;
if ($hasBuffer) {
$_SESSION = $buffer;
} else {
unset($_SESSION);
}
return $session;... | [
"private",
"static",
"function",
"unserialize",
"(",
"$",
"data",
")",
"{",
"$",
"hasBuffer",
"=",
"isset",
"(",
"$",
"_SESSION",
")",
";",
"$",
"buffer",
"=",
"$",
"_SESSION",
";",
"session_decode",
"(",
"$",
"data",
")",
";",
"$",
"session",
"=",
"... | Given raw session data return the unserialized array.
Used to check if the session is really empty before writing.
@since Symphony 2.3.3
@param string $data
The serialized session data
@return array
The unserialised session data | [
"Given",
"raw",
"session",
"data",
"return",
"the",
"unserialized",
"array",
".",
"Used",
"to",
"check",
"if",
"the",
"session",
"is",
"really",
"empty",
"before",
"writing",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/core/class.session.php#L226-L240 |
symphonycms/symphony-2 | symphony/lib/core/class.session.php | Session.read | public static function read($id)
{
return (string)Symphony::Database()->fetchVar(
'session_data',
0,
sprintf(
"SELECT `session_data`
FROM `tbl_sessions`
WHERE `session` = '%s'
LIMIT 1",
Sympho... | php | public static function read($id)
{
return (string)Symphony::Database()->fetchVar(
'session_data',
0,
sprintf(
"SELECT `session_data`
FROM `tbl_sessions`
WHERE `session` = '%s'
LIMIT 1",
Sympho... | [
"public",
"static",
"function",
"read",
"(",
"$",
"id",
")",
"{",
"return",
"(",
"string",
")",
"Symphony",
"::",
"Database",
"(",
")",
"->",
"fetchVar",
"(",
"'session_data'",
",",
"0",
",",
"sprintf",
"(",
"\"SELECT `session_data`\n FROM `tbl_se... | Given a session's ID, return it's row from `tbl_sessions`
@param string $id
The identifier for the Session to fetch
@return string
The serialised session data | [
"Given",
"a",
"session",
"s",
"ID",
"return",
"it",
"s",
"row",
"from",
"tbl_sessions"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/core/class.session.php#L250-L263 |
symphonycms/symphony-2 | symphony/lib/core/class.session.php | Session.destroy | public static function destroy($id)
{
return Symphony::Database()->query(
sprintf(
"DELETE
FROM `tbl_sessions`
WHERE `session` = '%s'",
Symphony::Database()->cleanValue($id)
)
);
} | php | public static function destroy($id)
{
return Symphony::Database()->query(
sprintf(
"DELETE
FROM `tbl_sessions`
WHERE `session` = '%s'",
Symphony::Database()->cleanValue($id)
)
);
} | [
"public",
"static",
"function",
"destroy",
"(",
"$",
"id",
")",
"{",
"return",
"Symphony",
"::",
"Database",
"(",
")",
"->",
"query",
"(",
"sprintf",
"(",
"\"DELETE\n FROM `tbl_sessions`\n WHERE `session` = '%s'\"",
",",
"Symphony",
"::",
... | Given a session's ID, remove it's row from `tbl_sessions`
@param string $id
The identifier for the Session to destroy
@throws DatabaseException
@return boolean
true if the Session was deleted successfully, false otherwise | [
"Given",
"a",
"session",
"s",
"ID",
"remove",
"it",
"s",
"row",
"from",
"tbl_sessions"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/core/class.session.php#L274-L284 |
symphonycms/symphony-2 | symphony/lib/core/class.session.php | Session.gc | public static function gc($max)
{
return Symphony::Database()->query(
sprintf(
"DELETE
FROM `tbl_sessions`
WHERE `session_expires` <= %d",
Symphony::Database()->cleanValue(time() - $max)
)
);
} | php | public static function gc($max)
{
return Symphony::Database()->query(
sprintf(
"DELETE
FROM `tbl_sessions`
WHERE `session_expires` <= %d",
Symphony::Database()->cleanValue(time() - $max)
)
);
} | [
"public",
"static",
"function",
"gc",
"(",
"$",
"max",
")",
"{",
"return",
"Symphony",
"::",
"Database",
"(",
")",
"->",
"query",
"(",
"sprintf",
"(",
"\"DELETE\n FROM `tbl_sessions`\n WHERE `session_expires` <= %d\"",
",",
"Symphony",
"::"... | The garbage collector, which removes all empty Sessions, or any
Sessions that have expired. This has a 10% chance of firing based
off the `gc_probability`/`gc_divisor`.
@param integer $max
The max session lifetime.
@throws DatabaseException
@return boolean
true on Session deletion, false if an error occurs | [
"The",
"garbage",
"collector",
"which",
"removes",
"all",
"empty",
"Sessions",
"or",
"any",
"Sessions",
"that",
"have",
"expired",
".",
"This",
"has",
"a",
"10%",
"chance",
"of",
"firing",
"based",
"off",
"the",
"gc_probability",
"/",
"gc_divisor",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/core/class.session.php#L297-L307 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.jsonpage.php | JSONPage.generate | public function generate($page = null)
{
// Set the actual status code in the xml response
$this->_Result['status'] = $this->getHttpStatusCode();
parent::generate($page);
return json_encode($this->_Result);
} | php | public function generate($page = null)
{
// Set the actual status code in the xml response
$this->_Result['status'] = $this->getHttpStatusCode();
parent::generate($page);
return json_encode($this->_Result);
} | [
"public",
"function",
"generate",
"(",
"$",
"page",
"=",
"null",
")",
"{",
"// Set the actual status code in the xml response",
"$",
"this",
"->",
"_Result",
"[",
"'status'",
"]",
"=",
"$",
"this",
"->",
"getHttpStatusCode",
"(",
")",
";",
"parent",
"::",
"gen... | The generate functions outputs the correct headers for
this `JSONPage`, adds `$this->getHttpStatusCode()` code to the root attribute
before calling the parent generate function and generating
the `$this->_Result` json string
@param null $page
@return string | [
"The",
"generate",
"functions",
"outputs",
"the",
"correct",
"headers",
"for",
"this",
"JSONPage",
"adds",
"$this",
"-",
">",
"getHttpStatusCode",
"()",
"code",
"to",
"the",
"root",
"attribute",
"before",
"calling",
"the",
"parent",
"generate",
"function",
"and"... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.jsonpage.php#L56-L64 |
symphonycms/symphony-2 | symphony/content/content.systempreferences.php | contentSystemPreferences.view | public function view()
{
$this->setPageType('form');
$this->setTitle(__('%1$s – %2$s', array(__('Preferences'), __('Symphony'))));
$this->addElementToHead(new XMLElement('link', null, array(
'rel' => 'canonical',
'href' => SYMPHONY_URL . '/system/preferences/',
... | php | public function view()
{
$this->setPageType('form');
$this->setTitle(__('%1$s – %2$s', array(__('Preferences'), __('Symphony'))));
$this->addElementToHead(new XMLElement('link', null, array(
'rel' => 'canonical',
'href' => SYMPHONY_URL . '/system/preferences/',
... | [
"public",
"function",
"view",
"(",
")",
"{",
"$",
"this",
"->",
"setPageType",
"(",
"'form'",
")",
";",
"$",
"this",
"->",
"setTitle",
"(",
"__",
"(",
"'%1$s – %2$s'",
",",
"array",
"(",
"__",
"(",
"'Preferences'",
")",
",",
"__",
"(",
"'Symphony... | Overload the parent 'view' function since we dont need the switchboard logic | [
"Overload",
"the",
"parent",
"view",
"function",
"since",
"we",
"dont",
"need",
"the",
"switchboard",
"logic"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/content/content.systempreferences.php#L19-L180 |
symphonycms/symphony-2 | symphony/lib/toolkit/fields/field.textarea.php | fieldTextarea.__applyFormatting | protected function __applyFormatting($data, $validate = false, &$errors = null)
{
$result = '';
if ($this->get('formatter')) {
$formatter = TextformatterManager::create($this->get('formatter'));
$result = $formatter->run($data);
}
if ($validate === true) {
... | php | protected function __applyFormatting($data, $validate = false, &$errors = null)
{
$result = '';
if ($this->get('formatter')) {
$formatter = TextformatterManager::create($this->get('formatter'));
$result = $formatter->run($data);
}
if ($validate === true) {
... | [
"protected",
"function",
"__applyFormatting",
"(",
"$",
"data",
",",
"$",
"validate",
"=",
"false",
",",
"&",
"$",
"errors",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"get",
"(",
"'formatter'",
")",
")",
"{... | /*-------------------------------------------------------------------------
Utilities:
------------------------------------------------------------------------- | [
"/",
"*",
"-------------------------------------------------------------------------",
"Utilities",
":",
"-------------------------------------------------------------------------"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/fields/field.textarea.php#L60-L81 |
symphonycms/symphony-2 | symphony/lib/toolkit/fields/field.textarea.php | fieldTextarea.displayPublishPanel | public function displayPublishPanel(XMLElement &$wrapper, $data = null, $flagWithError = null, $fieldnamePrefix = null, $fieldnamePostfix = null, $entry_id = null)
{
$label = Widget::Label($this->get('label'));
if ($this->get('required') !== 'yes') {
$label->appendChild(new XMLElement('... | php | public function displayPublishPanel(XMLElement &$wrapper, $data = null, $flagWithError = null, $fieldnamePrefix = null, $fieldnamePostfix = null, $entry_id = null)
{
$label = Widget::Label($this->get('label'));
if ($this->get('required') !== 'yes') {
$label->appendChild(new XMLElement('... | [
"public",
"function",
"displayPublishPanel",
"(",
"XMLElement",
"&",
"$",
"wrapper",
",",
"$",
"data",
"=",
"null",
",",
"$",
"flagWithError",
"=",
"null",
",",
"$",
"fieldnamePrefix",
"=",
"null",
",",
"$",
"fieldnamePostfix",
"=",
"null",
",",
"$",
"entr... | /*-------------------------------------------------------------------------
Publish:
------------------------------------------------------------------------- | [
"/",
"*",
"-------------------------------------------------------------------------",
"Publish",
":",
"-------------------------------------------------------------------------"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/fields/field.textarea.php#L145-L183 |
symphonycms/symphony-2 | symphony/lib/toolkit/fields/field.textarea.php | fieldTextarea.prepareExportValue | public function prepareExportValue($data, $mode, $entry_id = null)
{
$modes = (object)$this->getExportModes();
// Export handles:
if ($mode === $modes->getHandle) {
if (isset($data['handle'])) {
return $data['handle'];
} elseif (isset($data['value']))... | php | public function prepareExportValue($data, $mode, $entry_id = null)
{
$modes = (object)$this->getExportModes();
// Export handles:
if ($mode === $modes->getHandle) {
if (isset($data['handle'])) {
return $data['handle'];
} elseif (isset($data['value']))... | [
"public",
"function",
"prepareExportValue",
"(",
"$",
"data",
",",
"$",
"mode",
",",
"$",
"entry_id",
"=",
"null",
")",
"{",
"$",
"modes",
"=",
"(",
"object",
")",
"$",
"this",
"->",
"getExportModes",
"(",
")",
";",
"// Export handles:",
"if",
"(",
"$"... | Give the field some data and ask it to return a value using one of many
possible modes.
@param mixed $data
@param integer $mode
@param integer $entry_id
@return string|null | [
"Give",
"the",
"field",
"some",
"data",
"and",
"ask",
"it",
"to",
"return",
"a",
"value",
"using",
"one",
"of",
"many",
"possible",
"modes",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/fields/field.textarea.php#L329-L357 |
symphonycms/symphony-2 | symphony/lib/toolkit/fields/field.textarea.php | fieldTextarea.buildDSRetrievalSQL | public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation = false)
{
$field_id = $this->get('id');
if (self::isFilterRegex($data[0])) {
$this->buildRegexSQL($data[0], array('value'), $joins, $where);
} elseif (self::isFilterSQL($data[0])) {
$this->bu... | php | public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation = false)
{
$field_id = $this->get('id');
if (self::isFilterRegex($data[0])) {
$this->buildRegexSQL($data[0], array('value'), $joins, $where);
} elseif (self::isFilterSQL($data[0])) {
$this->bu... | [
"public",
"function",
"buildDSRetrievalSQL",
"(",
"$",
"data",
",",
"&",
"$",
"joins",
",",
"&",
"$",
"where",
",",
"$",
"andOperation",
"=",
"false",
")",
"{",
"$",
"field_id",
"=",
"$",
"this",
"->",
"get",
"(",
"'id'",
")",
";",
"if",
"(",
"self... | /*-------------------------------------------------------------------------
Filtering:
------------------------------------------------------------------------- | [
"/",
"*",
"-------------------------------------------------------------------------",
"Filtering",
":",
"-------------------------------------------------------------------------"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/fields/field.textarea.php#L363-L389 |
symphonycms/symphony-2 | symphony/lib/toolkit/fields/field.textarea.php | fieldTextarea.getExampleFormMarkup | public function getExampleFormMarkup()
{
$label = Widget::Label($this->get('label'));
$label->appendChild(Widget::Textarea('fields['.$this->get('element_name').']', (int)$this->get('size'), 50));
return $label;
} | php | public function getExampleFormMarkup()
{
$label = Widget::Label($this->get('label'));
$label->appendChild(Widget::Textarea('fields['.$this->get('element_name').']', (int)$this->get('size'), 50));
return $label;
} | [
"public",
"function",
"getExampleFormMarkup",
"(",
")",
"{",
"$",
"label",
"=",
"Widget",
"::",
"Label",
"(",
"$",
"this",
"->",
"get",
"(",
"'label'",
")",
")",
";",
"$",
"label",
"->",
"appendChild",
"(",
"Widget",
"::",
"Textarea",
"(",
"'fields['",
... | /*-------------------------------------------------------------------------
Events:
------------------------------------------------------------------------- | [
"/",
"*",
"-------------------------------------------------------------------------",
"Events",
":",
"-------------------------------------------------------------------------"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/fields/field.textarea.php#L395-L401 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.validateString | public static function validateString($string, $rule)
{
if (!is_array($rule) && ($rule == '' || $rule == null)) {
return true;
}
if (!is_array($string) && ($string == '' || $rule == null)) {
return true;
}
if (!is_array($rule)) {
$rule = ... | php | public static function validateString($string, $rule)
{
if (!is_array($rule) && ($rule == '' || $rule == null)) {
return true;
}
if (!is_array($string) && ($string == '' || $rule == null)) {
return true;
}
if (!is_array($rule)) {
$rule = ... | [
"public",
"static",
"function",
"validateString",
"(",
"$",
"string",
",",
"$",
"rule",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"rule",
")",
"&&",
"(",
"$",
"rule",
"==",
"''",
"||",
"$",
"rule",
"==",
"null",
")",
")",
"{",
"return",
"tr... | Validate a string against a set of regular expressions.
@param array|string $string
string to operate on
@param array|string $rule
a single rule or array of rules
@return boolean
false if any of the rules in $rule do not match any of the strings in
`$string`, return true otherwise. | [
"Validate",
"a",
"string",
"against",
"a",
"set",
"of",
"regular",
"expressions",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L72-L98 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.validateXML | public static function validateXML($data, &$errors, $isFile = true, $xsltProcessor = null, $encoding = 'UTF-8')
{
$_data = ($isFile) ? file_get_contents($data) : $data;
$_data = preg_replace('/<!DOCTYPE[-.:"\'\/\\w\\s]+>/', null, $_data);
if (strpos($_data, '<?xml') === false) {
... | php | public static function validateXML($data, &$errors, $isFile = true, $xsltProcessor = null, $encoding = 'UTF-8')
{
$_data = ($isFile) ? file_get_contents($data) : $data;
$_data = preg_replace('/<!DOCTYPE[-.:"\'\/\\w\\s]+>/', null, $_data);
if (strpos($_data, '<?xml') === false) {
... | [
"public",
"static",
"function",
"validateXML",
"(",
"$",
"data",
",",
"&",
"$",
"errors",
",",
"$",
"isFile",
"=",
"true",
",",
"$",
"xsltProcessor",
"=",
"null",
",",
"$",
"encoding",
"=",
"'UTF-8'",
")",
"{",
"$",
"_data",
"=",
"(",
"$",
"isFile",
... | Checks an xml document for well-formedness.
@param string $data
filename, xml document as a string, or arbitrary string
@param pointer &$errors
pointer to an array which will contain any validation errors
@param boolean $isFile (optional)
if this is true, the method will attempt to read from a file, `$data`
instead.
@... | [
"Checks",
"an",
"xml",
"document",
"for",
"well",
"-",
"formedness",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L135-L173 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.validateURL | public static function validateURL($url = null)
{
$url = trim($url);
if (is_null($url) || $url == '') {
return $url;
}
if (!preg_match('#^http[s]?:\/\/#i', $url)) {
$url = 'http://' . $url;
}
include TOOLKIT . '/util.validators.php';
... | php | public static function validateURL($url = null)
{
$url = trim($url);
if (is_null($url) || $url == '') {
return $url;
}
if (!preg_match('#^http[s]?:\/\/#i', $url)) {
$url = 'http://' . $url;
}
include TOOLKIT . '/util.validators.php';
... | [
"public",
"static",
"function",
"validateURL",
"(",
"$",
"url",
"=",
"null",
")",
"{",
"$",
"url",
"=",
"trim",
"(",
"$",
"url",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"url",
")",
"||",
"$",
"url",
"==",
"''",
")",
"{",
"return",
"$",
"url",... | Check that a string is a valid URL.
@param string $url
string to operate on
@return string
a blank string or a valid URL | [
"Check",
"that",
"a",
"string",
"is",
"a",
"valid",
"URL",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L183-L202 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.cleanArray | public static function cleanArray(array &$arr)
{
foreach ($arr as $k => $v) {
if (is_array($v)) {
self::cleanArray($arr[$k]);
} else {
$arr[$k] = stripslashes($v);
}
}
} | php | public static function cleanArray(array &$arr)
{
foreach ($arr as $k => $v) {
if (is_array($v)) {
self::cleanArray($arr[$k]);
} else {
$arr[$k] = stripslashes($v);
}
}
} | [
"public",
"static",
"function",
"cleanArray",
"(",
"array",
"&",
"$",
"arr",
")",
"{",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"v",
")",
")",
"{",
"self",
"::",
"cleanArray",
"(",
"... | Strip any slashes from all array values.
@param array &$arr
Pointer to an array to operate on. Can be multi-dimensional. | [
"Strip",
"any",
"slashes",
"from",
"all",
"array",
"values",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L210-L219 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.flattenArray | public static function flattenArray(array &$source, &$output = null, $path = null)
{
if (is_null($output)) {
$output = array();
}
foreach ($source as $key => $value) {
if (is_int($key)) {
$key = (string)($key + 1);
}
if (!is_n... | php | public static function flattenArray(array &$source, &$output = null, $path = null)
{
if (is_null($output)) {
$output = array();
}
foreach ($source as $key => $value) {
if (is_int($key)) {
$key = (string)($key + 1);
}
if (!is_n... | [
"public",
"static",
"function",
"flattenArray",
"(",
"array",
"&",
"$",
"source",
",",
"&",
"$",
"output",
"=",
"null",
",",
"$",
"path",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"output",
")",
")",
"{",
"$",
"output",
"=",
"array",
... | Flatten the input array. Any elements of the input array that are
themselves arrays will be removed and the contents of the removed array
inserted in its place. The keys for the inserted values will be the
concatenation of the keys in the original arrays in which it was embedded.
The elements of the path are separated ... | [
"Flatten",
"the",
"input",
"array",
".",
"Any",
"elements",
"of",
"the",
"input",
"array",
"that",
"are",
"themselves",
"arrays",
"will",
"be",
"removed",
"and",
"the",
"contents",
"of",
"the",
"removed",
"array",
"inserted",
"in",
"its",
"place",
".",
"Th... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L247-L270 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.flattenArraySub | protected static function flattenArraySub(array &$output, array &$source, $path)
{
foreach ($source as $key => $value) {
$key = $path . ':' . $key;
if (is_array($value)) {
self::flattenArraySub($output, $value, $key);
} else {
$output[$key... | php | protected static function flattenArraySub(array &$output, array &$source, $path)
{
foreach ($source as $key => $value) {
$key = $path . ':' . $key;
if (is_array($value)) {
self::flattenArraySub($output, $value, $key);
} else {
$output[$key... | [
"protected",
"static",
"function",
"flattenArraySub",
"(",
"array",
"&",
"$",
"output",
",",
"array",
"&",
"$",
"source",
",",
"$",
"path",
")",
"{",
"foreach",
"(",
"$",
"source",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"key",
"=",
"$... | Flatten the input array. Any elements of the input array that are
themselves arrays will be removed and the contents of the removed array
inserted in its place. The keys for the inserted values will be the
concatenation of the keys in the original arrays in which it was embedded.
The elements of the path are separated ... | [
"Flatten",
"the",
"input",
"array",
".",
"Any",
"elements",
"of",
"the",
"input",
"array",
"that",
"are",
"themselves",
"arrays",
"will",
"be",
"removed",
"and",
"the",
"contents",
"of",
"the",
"removed",
"array",
"inserted",
"in",
"its",
"place",
".",
"Th... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L297-L308 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.createHandle | public static function createHandle($string, $max_length = 255, $delim = '-', $uriencode = false, $additional_rule_set = null)
{
$max_length = intval($max_length);
// Strip out any tag
$string = strip_tags($string);
// Remove punctuation
$string = preg_replace('/[\\.\'"]+/'... | php | public static function createHandle($string, $max_length = 255, $delim = '-', $uriencode = false, $additional_rule_set = null)
{
$max_length = intval($max_length);
// Strip out any tag
$string = strip_tags($string);
// Remove punctuation
$string = preg_replace('/[\\.\'"]+/'... | [
"public",
"static",
"function",
"createHandle",
"(",
"$",
"string",
",",
"$",
"max_length",
"=",
"255",
",",
"$",
"delim",
"=",
"'-'",
",",
"$",
"uriencode",
"=",
"false",
",",
"$",
"additional_rule_set",
"=",
"null",
")",
"{",
"$",
"max_length",
"=",
... | Given a string, this will clean it for use as a Symphony handle. Preserves multi-byte characters.
@since Symphony 2.2.1
@param string $string
String to be cleaned up
@param integer $max_length
The maximum number of characters in the handle
@param string $delim
All non-valid characters will be replaced with this
@param... | [
"Given",
"a",
"string",
"this",
"will",
"clean",
"it",
"for",
"use",
"as",
"a",
"Symphony",
"handle",
".",
"Preserves",
"multi",
"-",
"byte",
"characters",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L328-L371 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.createFilename | public static function createFilename($string, $delim = '-')
{
// Strip out any tag
$string = strip_tags($string);
// Find all legal characters
$count = preg_match_all('/[\p{L}\w:;.,+=~]+/u', $string, $matches);
if ($count <= 0 || $count == false) {
preg_match_al... | php | public static function createFilename($string, $delim = '-')
{
// Strip out any tag
$string = strip_tags($string);
// Find all legal characters
$count = preg_match_all('/[\p{L}\w:;.,+=~]+/u', $string, $matches);
if ($count <= 0 || $count == false) {
preg_match_al... | [
"public",
"static",
"function",
"createFilename",
"(",
"$",
"string",
",",
"$",
"delim",
"=",
"'-'",
")",
"{",
"// Strip out any tag",
"$",
"string",
"=",
"strip_tags",
"(",
"$",
"string",
")",
";",
"// Find all legal characters",
"$",
"count",
"=",
"preg_matc... | Given a string, this will clean it for use as a filename. Preserves multi-byte characters.
@since Symphony 2.2.1
@param string $string
String to be cleaned up
@param string $delim
All non-valid characters will be replaced with this
@return string
Returns created filename | [
"Given",
"a",
"string",
"this",
"will",
"clean",
"it",
"for",
"use",
"as",
"a",
"filename",
".",
"Preserves",
"multi",
"-",
"byte",
"characters",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L384-L405 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.strpos | public static function strpos($haystack, $needle, $offset = 0)
{
if (function_exists('mb_strpos')) {
return mb_strpos($haystack, $needle, $offset, 'utf-8');
}
return strpos($haystack, $needle, $offset);
} | php | public static function strpos($haystack, $needle, $offset = 0)
{
if (function_exists('mb_strpos')) {
return mb_strpos($haystack, $needle, $offset, 'utf-8');
}
return strpos($haystack, $needle, $offset);
} | [
"public",
"static",
"function",
"strpos",
"(",
"$",
"haystack",
",",
"$",
"needle",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'mb_strpos'",
")",
")",
"{",
"return",
"mb_strpos",
"(",
"$",
"haystack",
",",
"$",
"needle"... | Finds position of the first occurrence of a string in a string.
This function will attempt to use PHP's `mbstring` functions if they are available.
This function also forces utf-8 encoding for mbstring.
@since Symphony 2.7.0
@param string $haystack
the string to look into
@param string $needle
the string to look for
@... | [
"Finds",
"position",
"of",
"the",
"first",
"occurrence",
"of",
"a",
"string",
"in",
"a",
"string",
".",
"This",
"function",
"will",
"attempt",
"to",
"use",
"PHP",
"s",
"mbstring",
"functions",
"if",
"they",
"are",
"available",
".",
"This",
"function",
"als... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L442-L448 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.substr | public static function substr($str, $start, $length = null)
{
if (function_exists('mb_substr')) {
return mb_substr($str, $start, $length, 'utf-8');
}
if ($length === null) {
return substr($str, $start);
}
return substr($str, $start, $length);
} | php | public static function substr($str, $start, $length = null)
{
if (function_exists('mb_substr')) {
return mb_substr($str, $start, $length, 'utf-8');
}
if ($length === null) {
return substr($str, $start);
}
return substr($str, $start, $length);
} | [
"public",
"static",
"function",
"substr",
"(",
"$",
"str",
",",
"$",
"start",
",",
"$",
"length",
"=",
"null",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'mb_substr'",
")",
")",
"{",
"return",
"mb_substr",
"(",
"$",
"str",
",",
"$",
"start",
",",
... | Creates a sub string.
This function will attempt to use PHP's `mbstring` functions if they are available.
This function also forces utf-8 encoding.
@since Symphony 2.5.0
@param string $str
the string to operate on
@param int $start
the starting offset
@param int $length
the length of the substring
@return string
the r... | [
"Creates",
"a",
"sub",
"string",
".",
"This",
"function",
"will",
"attempt",
"to",
"use",
"PHP",
"s",
"mbstring",
"functions",
"if",
"they",
"are",
"available",
".",
"This",
"function",
"also",
"forces",
"utf",
"-",
"8",
"encoding",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L465-L474 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.substrmin | public static function substrmin($str, $val)
{
return self::substr($str, 0, min(self::strlen($str), $val));
} | php | public static function substrmin($str, $val)
{
return self::substr($str, 0, min(self::strlen($str), $val));
} | [
"public",
"static",
"function",
"substrmin",
"(",
"$",
"str",
",",
"$",
"val",
")",
"{",
"return",
"self",
"::",
"substr",
"(",
"$",
"str",
",",
"0",
",",
"min",
"(",
"self",
"::",
"strlen",
"(",
"$",
"str",
")",
",",
"$",
"val",
")",
")",
";",... | Extract the first `$val` characters of the input string. If `$val`
is larger than the length of the input string then the original
input string is returned.
@param string $str
the string to operate on
@param integer $val
the number to compare lengths with
@return string|boolean
the resulting string or false on failure... | [
"Extract",
"the",
"first",
"$val",
"characters",
"of",
"the",
"input",
"string",
".",
"If",
"$val",
"is",
"larger",
"than",
"the",
"length",
"of",
"the",
"input",
"string",
"then",
"the",
"original",
"input",
"string",
"is",
"returned",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L488-L491 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.substrmax | public static function substrmax($str, $val)
{
return self::substr($str, 0, max(self::strlen($str), $val));
} | php | public static function substrmax($str, $val)
{
return self::substr($str, 0, max(self::strlen($str), $val));
} | [
"public",
"static",
"function",
"substrmax",
"(",
"$",
"str",
",",
"$",
"val",
")",
"{",
"return",
"self",
"::",
"substr",
"(",
"$",
"str",
",",
"0",
",",
"max",
"(",
"self",
"::",
"strlen",
"(",
"$",
"str",
")",
",",
"$",
"val",
")",
")",
";",... | Extract the first `$val` characters of the input string. If
`$val` is larger than the length of the input string then
the original input string is returned
@param string $str
the string to operate on
@param integer $val
the number to compare lengths with
@return string|boolean
the resulting string or false on failure. | [
"Extract",
"the",
"first",
"$val",
"characters",
"of",
"the",
"input",
"string",
".",
"If",
"$val",
"is",
"larger",
"than",
"the",
"length",
"of",
"the",
"input",
"string",
"then",
"the",
"original",
"input",
"string",
"is",
"returned"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L505-L508 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.right | public static function right($str, $num)
{
$str = self::substr($str, self::strlen($str)-$num, $num);
return $str;
} | php | public static function right($str, $num)
{
$str = self::substr($str, self::strlen($str)-$num, $num);
return $str;
} | [
"public",
"static",
"function",
"right",
"(",
"$",
"str",
",",
"$",
"num",
")",
"{",
"$",
"str",
"=",
"self",
"::",
"substr",
"(",
"$",
"str",
",",
"self",
"::",
"strlen",
"(",
"$",
"str",
")",
"-",
"$",
"num",
",",
"$",
"num",
")",
";",
"ret... | Extract the last `$num` characters from a string.
@param string $str
the string to extract the characters from.
@param integer $num
the number of characters to extract.
@return string|boolean
a string containing the last `$num` characters of the
input string, or false on failure. | [
"Extract",
"the",
"last",
"$num",
"characters",
"from",
"a",
"string",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L521-L525 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.realiseDirectory | public static function realiseDirectory($path, $mode = 0755, $silent = true)
{
if (is_dir($path)) {
return true;
}
try {
$current_umask = umask(0);
$success = @mkdir($path, intval($mode, 8), true);
umask($current_umask);
return $s... | php | public static function realiseDirectory($path, $mode = 0755, $silent = true)
{
if (is_dir($path)) {
return true;
}
try {
$current_umask = umask(0);
$success = @mkdir($path, intval($mode, 8), true);
umask($current_umask);
return $s... | [
"public",
"static",
"function",
"realiseDirectory",
"(",
"$",
"path",
",",
"$",
"mode",
"=",
"0755",
",",
"$",
"silent",
"=",
"true",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"return",
"true",
";",
"}",
"try",
"{",
"$",
"cu... | Create all the directories as specified by the input path. If the current
directory already exists, this function will return true.
@param string $path
the path containing the directories to create.
@param string|integer $mode (optional)
the permissions (in octal) of the directories to create. Defaults to 0755
@param ... | [
"Create",
"all",
"the",
"directories",
"as",
"specified",
"by",
"the",
"input",
"path",
".",
"If",
"the",
"current",
"directory",
"already",
"exists",
"this",
"function",
"will",
"return",
"true",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L558-L577 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.deleteDirectory | public static function deleteDirectory($dir, $silent = true)
{
try {
if (!@file_exists($dir)) {
return true;
}
if (!@is_dir($dir)) {
return @unlink($dir);
}
foreach (scandir($dir) as $item) {
if ($i... | php | public static function deleteDirectory($dir, $silent = true)
{
try {
if (!@file_exists($dir)) {
return true;
}
if (!@is_dir($dir)) {
return @unlink($dir);
}
foreach (scandir($dir) as $item) {
if ($i... | [
"public",
"static",
"function",
"deleteDirectory",
"(",
"$",
"dir",
",",
"$",
"silent",
"=",
"true",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"@",
"file_exists",
"(",
"$",
"dir",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"@",
"is_di... | Recursively deletes all files and directories given a directory. This
function has two path. This function optionally takes a `$silent` parameter,
which when `false` will throw an `Exception` if there is an error deleting a file
or folder.
@since Symphony 2.3
@param string $dir
the path of the directory to delete
@par... | [
"Recursively",
"deletes",
"all",
"files",
"and",
"directories",
"given",
"a",
"directory",
".",
"This",
"function",
"has",
"two",
"path",
".",
"This",
"function",
"optionally",
"takes",
"a",
"$silent",
"parameter",
"which",
"when",
"false",
"will",
"throw",
"a... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L594-L623 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.in_array_multi | public static function in_array_multi($needle, $haystack)
{
if ($needle == $haystack) {
return true;
}
if (is_array($haystack)) {
foreach ($haystack as $key => $val) {
if (is_array($val)) {
if (self::in_array_multi($needle, $val)) ... | php | public static function in_array_multi($needle, $haystack)
{
if ($needle == $haystack) {
return true;
}
if (is_array($haystack)) {
foreach ($haystack as $key => $val) {
if (is_array($val)) {
if (self::in_array_multi($needle, $val)) ... | [
"public",
"static",
"function",
"in_array_multi",
"(",
"$",
"needle",
",",
"$",
"haystack",
")",
"{",
"if",
"(",
"$",
"needle",
"==",
"$",
"haystack",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"haystack",
")",
")",
"{",
... | Search a multi-dimensional array for a value.
@param mixed $needle
the value to search for.
@param array $haystack
the multi-dimensional array to search.
@return boolean
true if `$needle` is found in `$haystack`.
true if `$needle` == `$haystack`.
true if `$needle` is found in any of the arrays contained within `$hayst... | [
"Search",
"a",
"multi",
"-",
"dimensional",
"array",
"for",
"a",
"value",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L638-L657 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.in_array_all | public static function in_array_all($needles, $haystack)
{
foreach ($needles as $n) {
if (!in_array($n, $haystack)) {
return false;
}
}
return true;
} | php | public static function in_array_all($needles, $haystack)
{
foreach ($needles as $n) {
if (!in_array($n, $haystack)) {
return false;
}
}
return true;
} | [
"public",
"static",
"function",
"in_array_all",
"(",
"$",
"needles",
",",
"$",
"haystack",
")",
"{",
"foreach",
"(",
"$",
"needles",
"as",
"$",
"n",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"n",
",",
"$",
"haystack",
")",
")",
"{",
"return",... | Search an array for multiple values.
@param array $needles
the values to search the `$haystack` for.
@param array $haystack
the in which to search for the `$needles`
@return boolean
true if any of the `$needles` are in `$haystack`,
false otherwise. | [
"Search",
"an",
"array",
"for",
"multiple",
"values",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L670-L679 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.processFilePostData | public static function processFilePostData($filedata)
{
$result = array();
foreach ($filedata as $key => $data) {
foreach ($data as $handle => $value) {
if (is_array($value)) {
foreach ($value as $index => $pair) {
if (!is_arra... | php | public static function processFilePostData($filedata)
{
$result = array();
foreach ($filedata as $key => $data) {
foreach ($data as $handle => $value) {
if (is_array($value)) {
foreach ($value as $index => $pair) {
if (!is_arra... | [
"public",
"static",
"function",
"processFilePostData",
"(",
"$",
"filedata",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"filedata",
"as",
"$",
"key",
"=>",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",... | Transform a multi-dimensional array to a flat array. The input array
is expected to conform to the structure of the `$_FILES` variable.
@param array $filedata
the raw `$_FILES` data structured array
@return array
the flattened array. | [
"Transform",
"a",
"multi",
"-",
"dimensional",
"array",
"to",
"a",
"flat",
"array",
".",
"The",
"input",
"array",
"is",
"expected",
"to",
"conform",
"to",
"the",
"structure",
"of",
"the",
"$_FILES",
"variable",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L690-L715 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.getPostData | public static function getPostData()
{
if (!function_exists('merge_file_post_data')) {
function merge_file_post_data($type, array $file, &$post)
{
foreach ($file as $key => $value) {
if (!isset($post[$key])) {
$post[$key] = ... | php | public static function getPostData()
{
if (!function_exists('merge_file_post_data')) {
function merge_file_post_data($type, array $file, &$post)
{
foreach ($file as $key => $value) {
if (!isset($post[$key])) {
$post[$key] = ... | [
"public",
"static",
"function",
"getPostData",
"(",
")",
"{",
"if",
"(",
"!",
"function_exists",
"(",
"'merge_file_post_data'",
")",
")",
"{",
"function",
"merge_file_post_data",
"(",
"$",
"type",
",",
"array",
"$",
"file",
",",
"&",
"$",
"post",
")",
"{",... | Merge `$_POST` with `$_FILES` to produce a flat array of the contents
of both. If there is no merge_file_post_data function defined then
such a function is created. This is necessary to overcome PHP's ability
to handle forms. This overcomes PHP's convoluted `$_FILES` structure
to make it simpler to access `multi-part/f... | [
"Merge",
"$_POST",
"with",
"$_FILES",
"to",
"produce",
"a",
"flat",
"array",
"of",
"the",
"contents",
"of",
"both",
".",
"If",
"there",
"is",
"no",
"merge_file_post_data",
"function",
"defined",
"then",
"such",
"a",
"function",
"is",
"created",
".",
"This",
... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L728-L773 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.array_find_available_index | public static function array_find_available_index($array, $seed = null)
{
if (!is_null($seed)) {
$index = $seed;
} else {
$keys = array_keys($array);
sort($keys);
$index = array_pop($keys);
}
if (isset($array[$index])) {
do... | php | public static function array_find_available_index($array, $seed = null)
{
if (!is_null($seed)) {
$index = $seed;
} else {
$keys = array_keys($array);
sort($keys);
$index = array_pop($keys);
}
if (isset($array[$index])) {
do... | [
"public",
"static",
"function",
"array_find_available_index",
"(",
"$",
"array",
",",
"$",
"seed",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"seed",
")",
")",
"{",
"$",
"index",
"=",
"$",
"seed",
";",
"}",
"else",
"{",
"$",
"keys"... | Find the next available index in an array. Works best with numeric keys.
The next available index is the minimum integer such that the array does
not have a mapping for that index. Uses the increment operator on the
index type of the input array, whatever that may do.
@param array $array
the array to find the next ind... | [
"Find",
"the",
"next",
"available",
"index",
"in",
"an",
"array",
".",
"Works",
"best",
"with",
"numeric",
"keys",
".",
"The",
"next",
"available",
"index",
"is",
"the",
"minimum",
"integer",
"such",
"that",
"the",
"array",
"does",
"not",
"have",
"a",
"m... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L789-L806 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.in_iarray | public static function in_iarray($needle, array $haystack)
{
foreach ($haystack as $key => $value) {
if (strcasecmp($value, $needle) == 0) {
return true;
}
}
return false;
} | php | public static function in_iarray($needle, array $haystack)
{
foreach ($haystack as $key => $value) {
if (strcasecmp($value, $needle) == 0) {
return true;
}
}
return false;
} | [
"public",
"static",
"function",
"in_iarray",
"(",
"$",
"needle",
",",
"array",
"$",
"haystack",
")",
"{",
"foreach",
"(",
"$",
"haystack",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"strcasecmp",
"(",
"$",
"value",
",",
"$",
"needle",... | Test whether a value is in an array based on string comparison, ignoring
the case of the values.
@param mixed $needle
the object to search the array for.
@param array $haystack
the array to search for the `$needle`.
@return boolean
true if the `$needle` is in the `$haystack`, false otherwise. | [
"Test",
"whether",
"a",
"value",
"is",
"in",
"an",
"array",
"based",
"on",
"string",
"comparison",
"ignoring",
"the",
"case",
"of",
"the",
"values",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L836-L844 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.array_iunique | public static function array_iunique(array $array)
{
$tmp = array();
foreach ($array as $key => $value) {
if (!self::in_iarray($value, $tmp)) {
$tmp[$key] = $value;
}
}
return $tmp;
} | php | public static function array_iunique(array $array)
{
$tmp = array();
foreach ($array as $key => $value) {
if (!self::in_iarray($value, $tmp)) {
$tmp[$key] = $value;
}
}
return $tmp;
} | [
"public",
"static",
"function",
"array_iunique",
"(",
"array",
"$",
"array",
")",
"{",
"$",
"tmp",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"in_iarray",... | Filter the input array for duplicates, treating each element in the array
as a string and comparing them using a case insensitive comparison function.
@param array $array
the array to filter.
@return array
a new array containing only the unique elements of the input array. | [
"Filter",
"the",
"input",
"array",
"for",
"duplicates",
"treating",
"each",
"element",
"in",
"the",
"array",
"as",
"a",
"string",
"and",
"comparing",
"them",
"using",
"a",
"case",
"insensitive",
"comparison",
"function",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L855-L866 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.array_map_recursive | public static function array_map_recursive($function, array $array)
{
$tmp = array();
foreach ($array as $key => $value) {
if (is_array($value)) {
$tmp[$key] = self::array_map_recursive($function, $value);
} else {
$tmp[$key] = call_user_func(... | php | public static function array_map_recursive($function, array $array)
{
$tmp = array();
foreach ($array as $key => $value) {
if (is_array($value)) {
$tmp[$key] = self::array_map_recursive($function, $value);
} else {
$tmp[$key] = call_user_func(... | [
"public",
"static",
"function",
"array_map_recursive",
"(",
"$",
"function",
",",
"array",
"$",
"array",
")",
"{",
"$",
"tmp",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is... | Function recursively apply a function to an array's values.
This will not touch the keys, just the values.
@since Symphony 2.2
@param string $function
@param array $array
@return array
a new array with all the values passed through the given `$function` | [
"Function",
"recursively",
"apply",
"a",
"function",
"to",
"an",
"array",
"s",
"values",
".",
"This",
"will",
"not",
"touch",
"the",
"keys",
"just",
"the",
"values",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L878-L891 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.array_to_xml | public static function array_to_xml(XMLElement $parent, array $data, $validate = false)
{
foreach ($data as $element_name => $value) {
if (!is_numeric($value) && empty($value)) {
continue;
}
if (is_int($element_name)) {
$child = new XMLEle... | php | public static function array_to_xml(XMLElement $parent, array $data, $validate = false)
{
foreach ($data as $element_name => $value) {
if (!is_numeric($value) && empty($value)) {
continue;
}
if (is_int($element_name)) {
$child = new XMLEle... | [
"public",
"static",
"function",
"array_to_xml",
"(",
"XMLElement",
"$",
"parent",
",",
"array",
"$",
"data",
",",
"$",
"validate",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"element_name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
... | Convert an array into an XML fragment and append it to an existing
XML element. Any arrays contained as elements in the input array will
also be recursively formatted and appended to the input XML fragment.
The input XML element will be modified as a result of calling this.
@param XMLElement $parent
the XML element to... | [
"Convert",
"an",
"array",
"into",
"an",
"XML",
"fragment",
"and",
"append",
"it",
"to",
"an",
"existing",
"XML",
"element",
".",
"Any",
"arrays",
"contained",
"as",
"elements",
"in",
"the",
"input",
"array",
"will",
"also",
"be",
"recursively",
"formatted",
... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L907-L935 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.writeFile | public static function writeFile($file, $data, $perm = 0644, $mode = 'w', $trim = false)
{
if (static::checkFileWritable($file) === false) {
return false;
}
if (!$handle = fopen($file, $mode)) {
return false;
}
if ($trim === true) {
$data... | php | public static function writeFile($file, $data, $perm = 0644, $mode = 'w', $trim = false)
{
if (static::checkFileWritable($file) === false) {
return false;
}
if (!$handle = fopen($file, $mode)) {
return false;
}
if ($trim === true) {
$data... | [
"public",
"static",
"function",
"writeFile",
"(",
"$",
"file",
",",
"$",
"data",
",",
"$",
"perm",
"=",
"0644",
",",
"$",
"mode",
"=",
"'w'",
",",
"$",
"trim",
"=",
"false",
")",
"{",
"if",
"(",
"static",
"::",
"checkFileWritable",
"(",
"$",
"file"... | Create a file at the input path with the (optional) input permissions
with the input content. This function will ignore errors in opening,
writing, closing and changing the permissions of the resulting file.
If opening or writing the file fail then this will return false.
This method calls `General::checkFileWritable()... | [
"Create",
"a",
"file",
"at",
"the",
"input",
"path",
"with",
"the",
"(",
"optional",
")",
"input",
"permissions",
"with",
"the",
"input",
"content",
".",
"This",
"function",
"will",
"ignore",
"errors",
"in",
"opening",
"writing",
"closing",
"and",
"changing"... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L962-L1000 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.checkFile | public static function checkFile($file)
{
if (Symphony::Log()) {
Symphony::Log()->pushDeprecateWarningToLog('General::checkFile()', '`General::checkFileWritable()');
}
clearstatcache();
$dir = dirname($file);
if (
(!is_writable($dir) || !is_readable($... | php | public static function checkFile($file)
{
if (Symphony::Log()) {
Symphony::Log()->pushDeprecateWarningToLog('General::checkFile()', '`General::checkFileWritable()');
}
clearstatcache();
$dir = dirname($file);
if (
(!is_writable($dir) || !is_readable($... | [
"public",
"static",
"function",
"checkFile",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"Symphony",
"::",
"Log",
"(",
")",
")",
"{",
"Symphony",
"::",
"Log",
"(",
")",
"->",
"pushDeprecateWarningToLog",
"(",
"'General::checkFile()'",
",",
"'`General::checkFileWrit... | Checks that the file and its folder are readable and writable.
@deprecated @since Symphony 2.7.0
@since Symphony 2.6.3
@return boolean | [
"Checks",
"that",
"the",
"file",
"and",
"its",
"folder",
"are",
"readable",
"and",
"writable",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L1009-L1025 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.checkFileWritable | public static function checkFileWritable($file)
{
clearstatcache();
if (@file_exists($file)) {
// Writing to an existing file does not require write
// permissions on the directory.
return @is_writable($file);
}
$dir = dirname($file);
// Cr... | php | public static function checkFileWritable($file)
{
clearstatcache();
if (@file_exists($file)) {
// Writing to an existing file does not require write
// permissions on the directory.
return @is_writable($file);
}
$dir = dirname($file);
// Cr... | [
"public",
"static",
"function",
"checkFileWritable",
"(",
"$",
"file",
")",
"{",
"clearstatcache",
"(",
")",
";",
"if",
"(",
"@",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"// Writing to an existing file does not require write",
"// permissions on the directory.... | Checks that the file is writable.
It first checks to see if the $file path exists
and if it does, checks that is it writable. If the file
does not exits, it checks that the directory exists and if it does,
checks that it is writable.
@uses clearstatcache()
@since Symphony 2.7.0
@param string $file
The path of the file... | [
"Checks",
"that",
"the",
"file",
"is",
"writable",
".",
"It",
"first",
"checks",
"to",
"see",
"if",
"the",
"$file",
"path",
"exists",
"and",
"if",
"it",
"does",
"checks",
"that",
"is",
"it",
"writable",
".",
"If",
"the",
"file",
"does",
"not",
"exits",... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L1058-L1069 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.checkFileDeletable | public static function checkFileDeletable($file)
{
clearstatcache();
$dir = dirname($file);
// Deleting a file requires write permissions on the directory.
// It does not require write permissions on the file
return @file_exists($dir) && @is_writable($dir);
} | php | public static function checkFileDeletable($file)
{
clearstatcache();
$dir = dirname($file);
// Deleting a file requires write permissions on the directory.
// It does not require write permissions on the file
return @file_exists($dir) && @is_writable($dir);
} | [
"public",
"static",
"function",
"checkFileDeletable",
"(",
"$",
"file",
")",
"{",
"clearstatcache",
"(",
")",
";",
"$",
"dir",
"=",
"dirname",
"(",
"$",
"file",
")",
";",
"// Deleting a file requires write permissions on the directory.",
"// It does not require write pe... | Checks that the file is deletable.
It first checks to see if the $file path exists
and if it does, checks that is it writable.
@uses clearstatcache()
@since Symphony 2.7.0
@param string $file
The path of the file
@return boolean | [
"Checks",
"that",
"the",
"file",
"is",
"deletable",
".",
"It",
"first",
"checks",
"to",
"see",
"if",
"the",
"$file",
"path",
"exists",
"and",
"if",
"it",
"does",
"checks",
"that",
"is",
"it",
"writable",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L1082-L1089 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.deleteFile | public static function deleteFile($file, $silent = true)
{
try {
if (static::checkFileDeletable($file) === false) {
throw new Exception(__('Denied by permission'));
}
if (!@file_exists($file)) {
return true;
}
return... | php | public static function deleteFile($file, $silent = true)
{
try {
if (static::checkFileDeletable($file) === false) {
throw new Exception(__('Denied by permission'));
}
if (!@file_exists($file)) {
return true;
}
return... | [
"public",
"static",
"function",
"deleteFile",
"(",
"$",
"file",
",",
"$",
"silent",
"=",
"true",
")",
"{",
"try",
"{",
"if",
"(",
"static",
"::",
"checkFileDeletable",
"(",
"$",
"file",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"Exception",
"(",
... | Delete a file at a given path, silently ignoring errors depending
on the value of the input variable $silent.
@uses General::checkFileDeletable()
@param string $file
the path of the file to delete
@param boolean $silent (optional)
true if an exception should be raised if an error occurs, false
otherwise. this defaults... | [
"Delete",
"a",
"file",
"at",
"a",
"given",
"path",
"silently",
"ignoring",
"errors",
"depending",
"on",
"the",
"value",
"of",
"the",
"input",
"variable",
"$silent",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L1107-L1124 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.getMimeType | public function getMimeType($file)
{
if (!empty($file)) {
// in PHP 5.3 we can use 'finfo'
if (PHP_VERSION_ID >= 50300 && function_exists('finfo_open')) {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime_type = finfo_file($finfo, $file);
... | php | public function getMimeType($file)
{
if (!empty($file)) {
// in PHP 5.3 we can use 'finfo'
if (PHP_VERSION_ID >= 50300 && function_exists('finfo_open')) {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime_type = finfo_file($finfo, $file);
... | [
"public",
"function",
"getMimeType",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"file",
")",
")",
"{",
"// in PHP 5.3 we can use 'finfo'",
"if",
"(",
"PHP_VERSION_ID",
">=",
"50300",
"&&",
"function_exists",
"(",
"'finfo_open'",
")",
")",... | Gets mime type of a file.
For email attachments, the mime type is very important.
Uses the PHP 5.3 function `finfo_open` when available, otherwise falls
back to using a mapping of known of common mimetypes. If no matches
are found `application/octet-stream` will be returned.
@author Michael Eichelsdoerfer
@author Hui... | [
"Gets",
"mime",
"type",
"of",
"a",
"file",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L1154-L1205 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.listDirStructure | public static function listDirStructure($dir = '.', $filter = null, $recurse = true, $strip_root = null, $exclude = array(), $ignore_hidden = true)
{
if (!is_dir($dir)) {
return null;
}
$files = array();
foreach (scandir($dir) as $file) {
if (
... | php | public static function listDirStructure($dir = '.', $filter = null, $recurse = true, $strip_root = null, $exclude = array(), $ignore_hidden = true)
{
if (!is_dir($dir)) {
return null;
}
$files = array();
foreach (scandir($dir) as $file) {
if (
... | [
"public",
"static",
"function",
"listDirStructure",
"(",
"$",
"dir",
"=",
"'.'",
",",
"$",
"filter",
"=",
"null",
",",
"$",
"recurse",
"=",
"true",
",",
"$",
"strip_root",
"=",
"null",
",",
"$",
"exclude",
"=",
"array",
"(",
")",
",",
"$",
"ignore_hi... | Construct a multi-dimensional array that reflects the directory
structure of a given path.
@param string $dir (optional)
the path of the directory to construct the multi-dimensional array
for. this defaults to '.'.
@param string $filter (optional)
A regular expression to filter the directories. This is positive filter... | [
"Construct",
"a",
"multi",
"-",
"dimensional",
"array",
"that",
"reflects",
"the",
"directory",
"structure",
"of",
"a",
"given",
"path",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L1232-L1265 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.listStructure | public static function listStructure($dir = ".", $filters = array(), $recurse = true, $sort = "asc", $strip_root = null, $exclude = array(), $ignore_hidden = true)
{
if (!is_dir($dir)) {
return null;
}
// Check to see if $filters is a string containing a regex, or an array of fi... | php | public static function listStructure($dir = ".", $filters = array(), $recurse = true, $sort = "asc", $strip_root = null, $exclude = array(), $ignore_hidden = true)
{
if (!is_dir($dir)) {
return null;
}
// Check to see if $filters is a string containing a regex, or an array of fi... | [
"public",
"static",
"function",
"listStructure",
"(",
"$",
"dir",
"=",
"\".\"",
",",
"$",
"filters",
"=",
"array",
"(",
")",
",",
"$",
"recurse",
"=",
"true",
",",
"$",
"sort",
"=",
"\"asc\"",
",",
"$",
"strip_root",
"=",
"null",
",",
"$",
"exclude",... | Construct a multi-dimensional array that reflects the directory
structure of a given path grouped into directory and file keys
matching any input constraints.
@param string $dir (optional)
the path of the directory to construct the multi-dimensional array
for. this defaults to '.'.
@param array|string $filters (option... | [
"Construct",
"a",
"multi",
"-",
"dimensional",
"array",
"that",
"reflects",
"the",
"directory",
"structure",
"of",
"a",
"given",
"path",
"grouped",
"into",
"directory",
"and",
"file",
"keys",
"matching",
"any",
"input",
"constraints",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L1296-L1357 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.countWords | public static function countWords($string)
{
$string = strip_tags($string);
// Strip spaces:
$string = html_entity_decode($string, ENT_NOQUOTES, 'UTF-8');
$spaces = array(
' ', ' ', ' ', ' ',
' ', ' ', ' ', '&#... | php | public static function countWords($string)
{
$string = strip_tags($string);
// Strip spaces:
$string = html_entity_decode($string, ENT_NOQUOTES, 'UTF-8');
$spaces = array(
' ', ' ', ' ', ' ',
' ', ' ', ' ', '&#... | [
"public",
"static",
"function",
"countWords",
"(",
"$",
"string",
")",
"{",
"$",
"string",
"=",
"strip_tags",
"(",
"$",
"string",
")",
";",
"// Strip spaces:",
"$",
"string",
"=",
"html_entity_decode",
"(",
"$",
"string",
",",
"ENT_NOQUOTES",
",",
"'UTF-8'",... | Count the number of words in a string. Words are delimited by "spaces".
The characters included in the set of "spaces" are:
' ', ' ', ' ', ' ',
' ', ' ', ' ', ' ',
'​', '𠀯', ' '
Any html/xml tags are first removed by strip_tags() and any incl... | [
"Count",
"the",
"number",
"of",
"words",
"in",
"a",
"string",
".",
"Words",
"are",
"delimited",
"by",
"spaces",
".",
"The",
"characters",
"included",
"in",
"the",
"set",
"of",
"spaces",
"are",
":",
" ",
";",
" ",
";",
" ",
";",
" ... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L1374-L1394 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.limitWords | public static function limitWords($string, $maxChars = 200, $appendHellip = false)
{
if ($appendHellip) {
$maxChars -= 1;
}
$string = trim(strip_tags(nl2br($string)));
$original_length = strlen($string);
if ($original_length == 0) {
return null;
... | php | public static function limitWords($string, $maxChars = 200, $appendHellip = false)
{
if ($appendHellip) {
$maxChars -= 1;
}
$string = trim(strip_tags(nl2br($string)));
$original_length = strlen($string);
if ($original_length == 0) {
return null;
... | [
"public",
"static",
"function",
"limitWords",
"(",
"$",
"string",
",",
"$",
"maxChars",
"=",
"200",
",",
"$",
"appendHellip",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"appendHellip",
")",
"{",
"$",
"maxChars",
"-=",
"1",
";",
"}",
"$",
"string",
"=",
... | Truncate a string to a given length, respecting word boundaries. The returned
string will always be less than `$maxChars`. Newlines, HTML elements and
leading or trailing spaces are removed from the string.
@param string $string
the string to truncate.
@param integer $maxChars (optional)
the maximum length of the stri... | [
"Truncate",
"a",
"string",
"to",
"a",
"given",
"length",
"respecting",
"word",
"boundaries",
".",
"The",
"returned",
"string",
"will",
"always",
"be",
"less",
"than",
"$maxChars",
".",
"Newlines",
"HTML",
"elements",
"and",
"leading",
"or",
"trailing",
"spaces... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L1414-L1442 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.uploadFile | public static function uploadFile($dest_path, $dest_name, $tmp_name, $perm = 0644)
{
// Upload the file
if (@is_uploaded_file($tmp_name)) {
$dest_path = rtrim($dest_path, '/') . '/';
$dest = $dest_path . $dest_name;
// Check that destination is writable
... | php | public static function uploadFile($dest_path, $dest_name, $tmp_name, $perm = 0644)
{
// Upload the file
if (@is_uploaded_file($tmp_name)) {
$dest_path = rtrim($dest_path, '/') . '/';
$dest = $dest_path . $dest_name;
// Check that destination is writable
... | [
"public",
"static",
"function",
"uploadFile",
"(",
"$",
"dest_path",
",",
"$",
"dest_name",
",",
"$",
"tmp_name",
",",
"$",
"perm",
"=",
"0644",
")",
"{",
"// Upload the file",
"if",
"(",
"@",
"is_uploaded_file",
"(",
"$",
"tmp_name",
")",
")",
"{",
"$",... | Move a file from the source path to the destination path and name and
set its permissions to the input permissions. This will ignore errors
in the `is_uploaded_file()`, `move_uploaded_file()` and `chmod()` functions.
@uses General::checkFileWritable()
@param string $dest_path
the file path to which the source file is ... | [
"Move",
"a",
"file",
"from",
"the",
"source",
"path",
"to",
"the",
"destination",
"path",
"and",
"name",
"and",
"set",
"its",
"permissions",
"to",
"the",
"input",
"permissions",
".",
"This",
"will",
"ignore",
"errors",
"in",
"the",
"is_uploaded_file",
"()",
... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L1462-L1485 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.formatFilesize | public static function formatFilesize($file_size)
{
$file_size = intval($file_size);
if ($file_size >= (1024 * 1024)) {
$file_size = number_format($file_size * (1 / (1024 * 1024)), 2) . ' MB';
} elseif ($file_size >= 1024) {
$file_size = intval($file_size * (1/1024))... | php | public static function formatFilesize($file_size)
{
$file_size = intval($file_size);
if ($file_size >= (1024 * 1024)) {
$file_size = number_format($file_size * (1 / (1024 * 1024)), 2) . ' MB';
} elseif ($file_size >= 1024) {
$file_size = intval($file_size * (1/1024))... | [
"public",
"static",
"function",
"formatFilesize",
"(",
"$",
"file_size",
")",
"{",
"$",
"file_size",
"=",
"intval",
"(",
"$",
"file_size",
")",
";",
"if",
"(",
"$",
"file_size",
">=",
"(",
"1024",
"*",
"1024",
")",
")",
"{",
"$",
"file_size",
"=",
"n... | Format a number of bytes in human readable format. This will append MB as
appropriate for values greater than 1,024*1,024, KB for values between
1,024 and 1,024*1,024-1 and bytes for values between 0 and 1,024.
@param integer $file_size
the number to format.
@return string
the formatted number. | [
"Format",
"a",
"number",
"of",
"bytes",
"in",
"human",
"readable",
"format",
".",
"This",
"will",
"append",
"MB",
"as",
"appropriate",
"for",
"values",
"greater",
"than",
"1",
"024",
"*",
"1",
"024",
"KB",
"for",
"values",
"between",
"1",
"024",
"and",
... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L1497-L1510 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.convertHumanFileSizeToBytes | public static function convertHumanFileSizeToBytes($file_size)
{
$file_size = str_replace(
array(' MB', ' KB', ' bytes'),
array('M', 'K', 'B'),
trim($file_size)
);
$last = strtolower($file_size[strlen($file_size)-1]);
$file_size = (int) $file_siz... | php | public static function convertHumanFileSizeToBytes($file_size)
{
$file_size = str_replace(
array(' MB', ' KB', ' bytes'),
array('M', 'K', 'B'),
trim($file_size)
);
$last = strtolower($file_size[strlen($file_size)-1]);
$file_size = (int) $file_siz... | [
"public",
"static",
"function",
"convertHumanFileSizeToBytes",
"(",
"$",
"file_size",
")",
"{",
"$",
"file_size",
"=",
"str_replace",
"(",
"array",
"(",
"' MB'",
",",
"' KB'",
",",
"' bytes'",
")",
",",
"array",
"(",
"'M'",
",",
"'K'",
",",
"'B'",
")",
"... | Gets the number of bytes from 'human readable' size value. Supports
the output of `General::formatFilesize` as well as reading values
from the PHP configuration. eg. 1 MB or 1M
@since Symphony 2.5.2
@param string $file_size
@return integer | [
"Gets",
"the",
"number",
"of",
"bytes",
"from",
"human",
"readable",
"size",
"value",
".",
"Supports",
"the",
"output",
"of",
"General",
"::",
"formatFilesize",
"as",
"well",
"as",
"reading",
"values",
"from",
"the",
"PHP",
"configuration",
".",
"eg",
".",
... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L1521-L1543 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.createXMLDateObject | public static function createXMLDateObject($timestamp, $element = 'date', $date_format = 'Y-m-d', $time_format = 'H:i', $namespace = null)
{
if (!class_exists('XMLElement')) {
return false;
}
if (empty($date_format)) {
$date_format = DateTimeObj::getSetting('date_for... | php | public static function createXMLDateObject($timestamp, $element = 'date', $date_format = 'Y-m-d', $time_format = 'H:i', $namespace = null)
{
if (!class_exists('XMLElement')) {
return false;
}
if (empty($date_format)) {
$date_format = DateTimeObj::getSetting('date_for... | [
"public",
"static",
"function",
"createXMLDateObject",
"(",
"$",
"timestamp",
",",
"$",
"element",
"=",
"'date'",
",",
"$",
"date_format",
"=",
"'Y-m-d'",
",",
"$",
"time_format",
"=",
"'H:i'",
",",
"$",
"namespace",
"=",
"null",
")",
"{",
"if",
"(",
"!"... | Construct an XML fragment that reflects the structure of the input timestamp.
@param integer $timestamp
the timestamp to construct the XML element from.
@param string $element (optional)
the name of the element to append to the namespace of the constructed XML.
this defaults to "date".
@param string $date_format (opti... | [
"Construct",
"an",
"XML",
"fragment",
"that",
"reflects",
"the",
"structure",
"of",
"the",
"input",
"timestamp",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L1566-L1592 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.buildPaginationElement | public static function buildPaginationElement($total_entries = 0, $total_pages = 0, $entries_per_page = 1, $current_page = 1)
{
$pageinfo = new XMLElement('pagination');
$pageinfo->setAttribute('total-entries', $total_entries);
$pageinfo->setAttribute('total-pages', $total_pages);
$... | php | public static function buildPaginationElement($total_entries = 0, $total_pages = 0, $entries_per_page = 1, $current_page = 1)
{
$pageinfo = new XMLElement('pagination');
$pageinfo->setAttribute('total-entries', $total_entries);
$pageinfo->setAttribute('total-pages', $total_pages);
$... | [
"public",
"static",
"function",
"buildPaginationElement",
"(",
"$",
"total_entries",
"=",
"0",
",",
"$",
"total_pages",
"=",
"0",
",",
"$",
"entries_per_page",
"=",
"1",
",",
"$",
"current_page",
"=",
"1",
")",
"{",
"$",
"pageinfo",
"=",
"new",
"XMLElement... | Construct an XML fragment that describes a pagination structure.
@param integer $total_entries (optional)
the total number of entries that this structure is paginating. this
defaults to 0.
@param integer $total_pages (optional)
the total number of pages within the pagination structure. this defaults
to 0.
@param integ... | [
"Construct",
"an",
"XML",
"fragment",
"that",
"describes",
"a",
"pagination",
"structure",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L1611-L1621 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.hash | public static function hash($input, $algorithm = 'sha1')
{
switch ($algorithm) {
case 'sha1':
return SHA1::hash($input);
case 'md5':
return MD5::hash($input);
case 'pbkdf2':
default:
return Crytography::hash($i... | php | public static function hash($input, $algorithm = 'sha1')
{
switch ($algorithm) {
case 'sha1':
return SHA1::hash($input);
case 'md5':
return MD5::hash($input);
case 'pbkdf2':
default:
return Crytography::hash($i... | [
"public",
"static",
"function",
"hash",
"(",
"$",
"input",
",",
"$",
"algorithm",
"=",
"'sha1'",
")",
"{",
"switch",
"(",
"$",
"algorithm",
")",
"{",
"case",
"'sha1'",
":",
"return",
"SHA1",
"::",
"hash",
"(",
"$",
"input",
")",
";",
"case",
"'md5'",... | Uses `SHA1` or `MD5` to create a hash based on some input
This function is currently very basic, but would allow
future expansion. Salting the hash comes to mind.
@param string $input
the string to be hashed
@param string $algorithm
This function supports 'md5', 'sha1' and 'pbkdf2'. Any
other algorithm will default to... | [
"Uses",
"SHA1",
"or",
"MD5",
"to",
"create",
"a",
"hash",
"based",
"on",
"some",
"input",
"This",
"function",
"is",
"currently",
"very",
"basic",
"but",
"would",
"allow",
"future",
"expansion",
".",
"Salting",
"the",
"hash",
"comes",
"to",
"mind",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L1636-L1649 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.ensureType | public static function ensureType(array $params)
{
foreach ($params as $name => $param) {
if (isset($param['optional']) && ($param['optional'] === true)) {
if (is_null($param['var'])) {
continue;
}
// if not null, check it's typ... | php | public static function ensureType(array $params)
{
foreach ($params as $name => $param) {
if (isset($param['optional']) && ($param['optional'] === true)) {
if (is_null($param['var'])) {
continue;
}
// if not null, check it's typ... | [
"public",
"static",
"function",
"ensureType",
"(",
"array",
"$",
"params",
")",
"{",
"foreach",
"(",
"$",
"params",
"as",
"$",
"name",
"=>",
"$",
"param",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"param",
"[",
"'optional'",
"]",
")",
"&&",
"(",
"$",... | Helper to cut down on variables' type check.
Currently known types are the PHP defaults.
Uses `is_XXX()` functions internally.
@since Symphony 2.3
@param array $params - an array of arrays containing variables info
Array[
$key1 => $value1
$key2 => $value2
...
]
$key = the name of the variable
$value = Array[
'var' ... | [
"Helper",
"to",
"cut",
"down",
"on",
"variables",
"type",
"check",
".",
"Currently",
"known",
"types",
"are",
"the",
"PHP",
"defaults",
".",
"Uses",
"is_XXX",
"()",
"functions",
"internally",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L1687-L1709 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.general.php | General.wrapInCDATA | public static function wrapInCDATA($value)
{
if (empty($value)) {
return $value;
}
$startRegExp = '/^' . preg_quote(CDATA_BEGIN) . '/';
$endRegExp = '/' . preg_quote(CDATA_END) . '$/';
if (!preg_match($startRegExp, $value)) {
$value = CDATA_BEGIN . $... | php | public static function wrapInCDATA($value)
{
if (empty($value)) {
return $value;
}
$startRegExp = '/^' . preg_quote(CDATA_BEGIN) . '/';
$endRegExp = '/' . preg_quote(CDATA_END) . '$/';
if (!preg_match($startRegExp, $value)) {
$value = CDATA_BEGIN . $... | [
"public",
"static",
"function",
"wrapInCDATA",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"$",
"startRegExp",
"=",
"'/^'",
".",
"preg_quote",
"(",
"CDATA_BEGIN",
")",
".",
"'/'... | Wrap a value in CDATA tags for XSL output of non encoded data, only
if not already wrapped.
@since Symphony 2.3.2
@param string $value
The string to wrap in CDATA
@return string
The wrapped string | [
"Wrap",
"a",
"value",
"in",
"CDATA",
"tags",
"for",
"XSL",
"output",
"of",
"non",
"encoded",
"data",
"only",
"if",
"not",
"already",
"wrapped",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.general.php#L1723-L1741 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.authormanager.php | AuthorManager.add | public static function add(array $fields)
{
if (!Symphony::Database()->insert($fields, 'tbl_authors')) {
return false;
}
$author_id = Symphony::Database()->getInsertID();
return $author_id;
} | php | public static function add(array $fields)
{
if (!Symphony::Database()->insert($fields, 'tbl_authors')) {
return false;
}
$author_id = Symphony::Database()->getInsertID();
return $author_id;
} | [
"public",
"static",
"function",
"add",
"(",
"array",
"$",
"fields",
")",
"{",
"if",
"(",
"!",
"Symphony",
"::",
"Database",
"(",
")",
"->",
"insert",
"(",
"$",
"fields",
",",
"'tbl_authors'",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"author_i... | Given an associative array of fields, insert them into the database
returning the resulting Author ID if successful, or false if there
was an error
@param array $fields
Associative array of field names => values for the Author object
@throws DatabaseException
@return integer|boolean
Returns an Author ID of the created... | [
"Given",
"an",
"associative",
"array",
"of",
"fields",
"insert",
"them",
"into",
"the",
"database",
"returning",
"the",
"resulting",
"Author",
"ID",
"if",
"successful",
"or",
"false",
"if",
"there",
"was",
"an",
"error"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.authormanager.php#L33-L42 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.authormanager.php | AuthorManager.fetch | public static function fetch($sortby = 'id', $sortdirection = 'ASC', $limit = null, $start = null, $where = null, $joins = null)
{
$sortby = is_null($sortby) ? 'id' : Symphony::Database()->cleanValue($sortby);
$sortdirection = $sortdirection === 'ASC' ? 'ASC' : 'DESC';
$records = Symphony::... | php | public static function fetch($sortby = 'id', $sortdirection = 'ASC', $limit = null, $start = null, $where = null, $joins = null)
{
$sortby = is_null($sortby) ? 'id' : Symphony::Database()->cleanValue($sortby);
$sortdirection = $sortdirection === 'ASC' ? 'ASC' : 'DESC';
$records = Symphony::... | [
"public",
"static",
"function",
"fetch",
"(",
"$",
"sortby",
"=",
"'id'",
",",
"$",
"sortdirection",
"=",
"'ASC'",
",",
"$",
"limit",
"=",
"null",
",",
"$",
"start",
"=",
"null",
",",
"$",
"where",
"=",
"null",
",",
"$",
"joins",
"=",
"null",
")",
... | The fetch method returns all Authors from Symphony with the option to sort
or limit the output. This method returns an array of Author objects.
@param string $sortby
The field to sort the authors by, defaults to 'id'
@param string $sortdirection
Available values of ASC (Ascending) or DESC (Descending), which refer to ... | [
"The",
"fetch",
"method",
"returns",
"all",
"Authors",
"from",
"Symphony",
"with",
"the",
"option",
"to",
"sort",
"or",
"limit",
"the",
"output",
".",
"This",
"method",
"returns",
"an",
"array",
"of",
"Author",
"objects",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.authormanager.php#L102-L140 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.authormanager.php | AuthorManager.fetchByID | public static function fetchByID($id)
{
$return_single = false;
if (is_null($id)) {
return null;
}
if (!is_array($id)) {
$return_single = true;
$id = array((int)$id);
}
if (empty($id)) {
return null;
}
... | php | public static function fetchByID($id)
{
$return_single = false;
if (is_null($id)) {
return null;
}
if (!is_array($id)) {
$return_single = true;
$id = array((int)$id);
}
if (empty($id)) {
return null;
}
... | [
"public",
"static",
"function",
"fetchByID",
"(",
"$",
"id",
")",
"{",
"$",
"return_single",
"=",
"false",
";",
"if",
"(",
"is_null",
"(",
"$",
"id",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"id",
")",
")",... | Returns Author's that match the provided ID's with the option to
sort or limit the output. This function will search the
`AuthorManager::$_pool` for Authors first before querying `tbl_authors`
@param integer|array $id
A single ID or an array of ID's
@throws DatabaseException
@return mixed
If `$id` is an integer, the r... | [
"Returns",
"Author",
"s",
"that",
"match",
"the",
"provided",
"ID",
"s",
"with",
"the",
"option",
"to",
"sort",
"or",
"limit",
"the",
"output",
".",
"This",
"function",
"will",
"search",
"the",
"AuthorManager",
"::",
"$_pool",
"for",
"Authors",
"first",
"b... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.authormanager.php#L155-L211 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.authormanager.php | AuthorManager.fetchByUsername | public static function fetchByUsername($username)
{
if (!isset(self::$_pool[$username])) {
$records = Symphony::Database()->fetchRow(0, sprintf(
"SELECT *
FROM `tbl_authors`
WHERE `username` = '%s'
LIMIT 1",
Symphony... | php | public static function fetchByUsername($username)
{
if (!isset(self::$_pool[$username])) {
$records = Symphony::Database()->fetchRow(0, sprintf(
"SELECT *
FROM `tbl_authors`
WHERE `username` = '%s'
LIMIT 1",
Symphony... | [
"public",
"static",
"function",
"fetchByUsername",
"(",
"$",
"username",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"_pool",
"[",
"$",
"username",
"]",
")",
")",
"{",
"$",
"records",
"=",
"Symphony",
"::",
"Database",
"(",
")",
"->",
... | Returns an Author by Username. This function will search the
`AuthorManager::$_pool` for Authors first before querying `tbl_authors`
@param string $username
The Author's username
@return Author|null
If an Author is found, an Author object is returned, otherwise null. | [
"Returns",
"an",
"Author",
"by",
"Username",
".",
"This",
"function",
"will",
"search",
"the",
"AuthorManager",
"::",
"$_pool",
"for",
"Authors",
"first",
"before",
"querying",
"tbl_authors"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.authormanager.php#L222-L247 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.authormanager.php | AuthorManager.activateAuthToken | public static function activateAuthToken($author_id)
{
if (!is_int($author_id)) {
return false;
}
return Symphony::Database()->query(sprintf(
"UPDATE `tbl_authors`
SET `auth_token_active` = 'yes'
WHERE `id` = %d",
$author_id
... | php | public static function activateAuthToken($author_id)
{
if (!is_int($author_id)) {
return false;
}
return Symphony::Database()->query(sprintf(
"UPDATE `tbl_authors`
SET `auth_token_active` = 'yes'
WHERE `id` = %d",
$author_id
... | [
"public",
"static",
"function",
"activateAuthToken",
"(",
"$",
"author_id",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"author_id",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"Symphony",
"::",
"Database",
"(",
")",
"->",
"query",
"(",
"sp... | This function will allow an Author to sign into Symphony by using their
authentication token as well as username/password.
@param integer $author_id
The Author ID to allow to use their authentication token.
@throws DatabaseException
@return boolean | [
"This",
"function",
"will",
"allow",
"an",
"Author",
"to",
"sign",
"into",
"Symphony",
"by",
"using",
"their",
"authentication",
"token",
"as",
"well",
"as",
"username",
"/",
"password",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.authormanager.php#L258-L270 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.authormanager.php | AuthorManager.deactivateAuthToken | public static function deactivateAuthToken($author_id)
{
if (!is_int($author_id)) {
return false;
}
return Symphony::Database()->query(sprintf(
"UPDATE `tbl_authors`
SET `auth_token_active` = 'no'
WHERE `id` = %d",
$author_id
... | php | public static function deactivateAuthToken($author_id)
{
if (!is_int($author_id)) {
return false;
}
return Symphony::Database()->query(sprintf(
"UPDATE `tbl_authors`
SET `auth_token_active` = 'no'
WHERE `id` = %d",
$author_id
... | [
"public",
"static",
"function",
"deactivateAuthToken",
"(",
"$",
"author_id",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"author_id",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"Symphony",
"::",
"Database",
"(",
")",
"->",
"query",
"(",
"... | This function will remove the ability for an Author to sign into Symphony
by using their authentication token
@param integer $author_id
The Author ID to allow to use their authentication token.
@throws DatabaseException
@return boolean | [
"This",
"function",
"will",
"remove",
"the",
"ability",
"for",
"an",
"Author",
"to",
"sign",
"into",
"Symphony",
"by",
"using",
"their",
"authentication",
"token"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.authormanager.php#L281-L293 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.smtp.php | SMTP.sendMail | public function sendMail($from, $to, $message)
{
$this->_connect($this->_host, $this->_port);
$this->mail($from);
if (!is_array($to)) {
$to = array($to);
}
foreach ($to as $recipient) {
$this->rcpt($recipient);
}
$this->data($message)... | php | public function sendMail($from, $to, $message)
{
$this->_connect($this->_host, $this->_port);
$this->mail($from);
if (!is_array($to)) {
$to = array($to);
}
foreach ($to as $recipient) {
$this->rcpt($recipient);
}
$this->data($message)... | [
"public",
"function",
"sendMail",
"(",
"$",
"from",
",",
"$",
"to",
",",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"_connect",
"(",
"$",
"this",
"->",
"_host",
",",
"$",
"this",
"->",
"_port",
")",
";",
"$",
"this",
"->",
"mail",
"(",
"$",
"... | The actual email sending.
The connection to the server (connecting, EHLO, AUTH, etc) is done here,
right before the actual email is sent. This is to make sure the connection does not time out.
@param string $from
The from string. Should have the following format: email@domain.tld
@param string $to
The email address to... | [
"The",
"actual",
"email",
"sending",
".",
"The",
"connection",
"to",
"the",
"server",
"(",
"connecting",
"EHLO",
"AUTH",
"etc",
")",
"is",
"done",
"here",
"right",
"before",
"the",
"actual",
"email",
"is",
"sent",
".",
"This",
"is",
"to",
"make",
"sure",... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.smtp.php#L136-L150 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.smtp.php | SMTP.setHeader | public function setHeader($header, $value)
{
if (is_array($value)) {
throw new SMTPException(__('Header fields can only contain strings'));
}
$this->_header_fields[$header] = $value;
} | php | public function setHeader($header, $value)
{
if (is_array($value)) {
throw new SMTPException(__('Header fields can only contain strings'));
}
$this->_header_fields[$header] = $value;
} | [
"public",
"function",
"setHeader",
"(",
"$",
"header",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"SMTPException",
"(",
"__",
"(",
"'Header fields can only contain strings'",
")",
")",
";",
"}",
... | Sets a header to be sent in the email.
@throws SMTPException
@param string $header
@param string $value
@return void | [
"Sets",
"a",
"header",
"to",
"be",
"sent",
"in",
"the",
"email",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.smtp.php#L160-L167 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.smtp.php | SMTP.helo | public function helo()
{
if ($this->_mail !== false) {
throw new SMTPException(__('Can not call HELO on existing session'));
}
//wait for the server to be ready
$this->_expect(220, 300);
//send ehlo or ehlo request.
try {
$this->_ehlo();
... | php | public function helo()
{
if ($this->_mail !== false) {
throw new SMTPException(__('Can not call HELO on existing session'));
}
//wait for the server to be ready
$this->_expect(220, 300);
//send ehlo or ehlo request.
try {
$this->_ehlo();
... | [
"public",
"function",
"helo",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_mail",
"!==",
"false",
")",
"{",
"throw",
"new",
"SMTPException",
"(",
"__",
"(",
"'Can not call HELO on existing session'",
")",
")",
";",
"}",
"//wait for the server to be ready",
"... | Initiates the ehlo/helo requests.
@throws SMTPException
@throws Exception
@return void | [
"Initiates",
"the",
"ehlo",
"/",
"helo",
"requests",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.smtp.php#L177-L196 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.smtp.php | SMTP.mail | public function mail($from)
{
if ($this->_helo == false) {
throw new SMTPException(__('Must call EHLO (or HELO) before calling MAIL'));
} elseif ($this->_mail !== false) {
throw new SMTPException(__('Only one call to MAIL may be made at a time.'));
}
$this->_... | php | public function mail($from)
{
if ($this->_helo == false) {
throw new SMTPException(__('Must call EHLO (or HELO) before calling MAIL'));
} elseif ($this->_mail !== false) {
throw new SMTPException(__('Only one call to MAIL may be made at a time.'));
}
$this->_... | [
"public",
"function",
"mail",
"(",
"$",
"from",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_helo",
"==",
"false",
")",
"{",
"throw",
"new",
"SMTPException",
"(",
"__",
"(",
"'Must call EHLO (or HELO) before calling MAIL'",
")",
")",
";",
"}",
"elseif",
"(",
... | Calls the MAIL command on the server.
@throws SMTPException
@param string $from
The email address to send the email from.
@return void | [
"Calls",
"the",
"MAIL",
"command",
"on",
"the",
"server",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.smtp.php#L206-L221 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.smtp.php | SMTP.rcpt | public function rcpt($to)
{
if ($this->_mail == false) {
throw new SMTPException(__('Must call MAIL before calling RCPT'));
}
$this->_send('RCPT TO:<' . $to . '>');
$this->_expect(array(250, 251), 300);
$this->_rcpt = true;
} | php | public function rcpt($to)
{
if ($this->_mail == false) {
throw new SMTPException(__('Must call MAIL before calling RCPT'));
}
$this->_send('RCPT TO:<' . $to . '>');
$this->_expect(array(250, 251), 300);
$this->_rcpt = true;
} | [
"public",
"function",
"rcpt",
"(",
"$",
"to",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_mail",
"==",
"false",
")",
"{",
"throw",
"new",
"SMTPException",
"(",
"__",
"(",
"'Must call MAIL before calling RCPT'",
")",
")",
";",
"}",
"$",
"this",
"->",
"_se... | Calls the RCPT command on the server. May be called multiple times for more than one recipient.
@throws SMTPException
@param string $to
The address to send the email to.
@return void | [
"Calls",
"the",
"RCPT",
"command",
"on",
"the",
"server",
".",
"May",
"be",
"called",
"multiple",
"times",
"for",
"more",
"than",
"one",
"recipient",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.smtp.php#L231-L241 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.smtp.php | SMTP.data | public function data($data)
{
if ($this->_rcpt == false) {
throw new SMTPException(__('Must call RCPT before calling DATA'));
}
$this->_send('DATA');
$this->_expect(354, 120);
foreach ($this->_header_fields as $name => $body) {
// Every header can co... | php | public function data($data)
{
if ($this->_rcpt == false) {
throw new SMTPException(__('Must call RCPT before calling DATA'));
}
$this->_send('DATA');
$this->_expect(354, 120);
foreach ($this->_header_fields as $name => $body) {
// Every header can co... | [
"public",
"function",
"data",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_rcpt",
"==",
"false",
")",
"{",
"throw",
"new",
"SMTPException",
"(",
"__",
"(",
"'Must call RCPT before calling DATA'",
")",
")",
";",
"}",
"$",
"this",
"->",
"_... | Calls the data command on the server.
Also includes header fields in the command.
@throws SMTPException
@param string $data
@return void | [
"Calls",
"the",
"data",
"command",
"on",
"the",
"server",
".",
"Also",
"includes",
"header",
"fields",
"in",
"the",
"command",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.smtp.php#L251-L290 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.smtp.php | SMTP._auth | protected function _auth()
{
if ($this->_helo == false) {
throw new SMTPException(__('Must call EHLO (or HELO) before calling AUTH'));
} elseif ($this->_auth !== false) {
throw new SMTPException(__('Can not call AUTH again.'));
}
$this->_send('AUTH LOGIN');
... | php | protected function _auth()
{
if ($this->_helo == false) {
throw new SMTPException(__('Must call EHLO (or HELO) before calling AUTH'));
} elseif ($this->_auth !== false) {
throw new SMTPException(__('Can not call AUTH again.'));
}
$this->_send('AUTH LOGIN');
... | [
"protected",
"function",
"_auth",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_helo",
"==",
"false",
")",
"{",
"throw",
"new",
"SMTPException",
"(",
"__",
"(",
"'Must call EHLO (or HELO) before calling AUTH'",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"thi... | Authenticates to the server.
Currently supports the AUTH LOGIN command.
May be extended if more methods are needed.
@throws SMTPException
@return void | [
"Authenticates",
"to",
"the",
"server",
".",
"Currently",
"supports",
"the",
"AUTH",
"LOGIN",
"command",
".",
"May",
"be",
"extended",
"if",
"more",
"methods",
"are",
"needed",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.smtp.php#L330-L345 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.smtp.php | SMTP._tls | protected function _tls()
{
if ($this->_secure == 'tls') {
$this->_send('STARTTLS');
$this->_expect(220, 180);
if (!stream_socket_enable_crypto($this->_connection, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
throw new SMTPException(__('Unable to connect via ... | php | protected function _tls()
{
if ($this->_secure == 'tls') {
$this->_send('STARTTLS');
$this->_expect(220, 180);
if (!stream_socket_enable_crypto($this->_connection, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
throw new SMTPException(__('Unable to connect via ... | [
"protected",
"function",
"_tls",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_secure",
"==",
"'tls'",
")",
"{",
"$",
"this",
"->",
"_send",
"(",
"'STARTTLS'",
")",
";",
"$",
"this",
"->",
"_expect",
"(",
"220",
",",
"180",
")",
";",
"if",
"(",
... | Encrypts the current session with TLS.
@throws SMTPException
@return void | [
"Encrypts",
"the",
"current",
"session",
"with",
"TLS",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.smtp.php#L379-L389 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.smtp.php | SMTP._send | protected function _send($request)
{
$this->checkConnection();
$result = fwrite($this->_connection, $request . "\r\n");
if ($result === false) {
throw new SMTPException(__('Could not send request: %s', array($request)));
}
return $result;
} | php | protected function _send($request)
{
$this->checkConnection();
$result = fwrite($this->_connection, $request . "\r\n");
if ($result === false) {
throw new SMTPException(__('Could not send request: %s', array($request)));
}
return $result;
} | [
"protected",
"function",
"_send",
"(",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"checkConnection",
"(",
")",
";",
"$",
"result",
"=",
"fwrite",
"(",
"$",
"this",
"->",
"_connection",
",",
"$",
"request",
".",
"\"\\r\\n\"",
")",
";",
"if",
"(",
"$... | Send a request to the host, appends the request with a line break.
@param string $request
@throws SMTPException
@return boolean|integer number of characters written. | [
"Send",
"a",
"request",
"to",
"the",
"host",
"appends",
"the",
"request",
"with",
"a",
"line",
"break",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.smtp.php#L398-L408 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.smtp.php | SMTP._receive | protected function _receive($timeout = null)
{
$this->checkConnection();
if ($timeout !== null) {
stream_set_timeout($this->_connection, $timeout);
}
$response = fgets($this->_connection, 1024);
$info = stream_get_meta_data($this->_connection);
if (!emp... | php | protected function _receive($timeout = null)
{
$this->checkConnection();
if ($timeout !== null) {
stream_set_timeout($this->_connection, $timeout);
}
$response = fgets($this->_connection, 1024);
$info = stream_get_meta_data($this->_connection);
if (!emp... | [
"protected",
"function",
"_receive",
"(",
"$",
"timeout",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"checkConnection",
"(",
")",
";",
"if",
"(",
"$",
"timeout",
"!==",
"null",
")",
"{",
"stream_set_timeout",
"(",
"$",
"this",
"->",
"_connection",
",",
... | Get a line from the stream.
@param integer $timeout
Per-request timeout value if applicable. Defaults to null which
will not set a timeout.
@throws SMTPException
@return string | [
"Get",
"a",
"line",
"from",
"the",
"stream",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.smtp.php#L419-L437 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.smtp.php | SMTP._expect | protected function _expect($code, $timeout = null)
{
$this->_response = array();
$cmd = '';
$more = '';
$msg = '';
$errMsg = '';
if (!is_array($code)) {
$code = array($code);
}
// Borrowed from the Zend Email Library
do {
... | php | protected function _expect($code, $timeout = null)
{
$this->_response = array();
$cmd = '';
$more = '';
$msg = '';
$errMsg = '';
if (!is_array($code)) {
$code = array($code);
}
// Borrowed from the Zend Email Library
do {
... | [
"protected",
"function",
"_expect",
"(",
"$",
"code",
",",
"$",
"timeout",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_response",
"=",
"array",
"(",
")",
";",
"$",
"cmd",
"=",
"''",
";",
"$",
"more",
"=",
"''",
";",
"$",
"msg",
"=",
"''",
";",
... | Parse server response for successful codes
Read the response from the stream and check for expected return code.
@throws SMTPException
@param string|array $code
One or more codes that indicate a successful response
@param integer $timeout
Per-request timeout value if applicable. Defaults to null which
will not set a... | [
"Parse",
"server",
"response",
"for",
"successful",
"codes"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.smtp.php#L453-L483 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.smtp.php | SMTP._connect | protected function _connect($host, $port)
{
$errorNum = 0;
$errorStr = '';
$remoteAddr = $this->_transport . '://' . $host . ':' . $port;
if (!is_resource($this->_connection)) {
$this->_connection = @stream_socket_client($remoteAddr, $errorNum, $errorStr, self::TIMEOUT)... | php | protected function _connect($host, $port)
{
$errorNum = 0;
$errorStr = '';
$remoteAddr = $this->_transport . '://' . $host . ':' . $port;
if (!is_resource($this->_connection)) {
$this->_connection = @stream_socket_client($remoteAddr, $errorNum, $errorStr, self::TIMEOUT)... | [
"protected",
"function",
"_connect",
"(",
"$",
"host",
",",
"$",
"port",
")",
"{",
"$",
"errorNum",
"=",
"0",
";",
"$",
"errorStr",
"=",
"''",
";",
"$",
"remoteAddr",
"=",
"$",
"this",
"->",
"_transport",
".",
"'://'",
".",
"$",
"host",
".",
"':'",... | Connect to the host, and perform basic functions like helo and auth.
@param string $host
@param integer $port
@throws SMTPException
@throws Exception
@return void | [
"Connect",
"to",
"the",
"host",
"and",
"perform",
"basic",
"functions",
"like",
"helo",
"and",
"auth",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.smtp.php#L495-L527 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.getInstance | public static function getInstance($name)
{
return (isset(self::$_pool[$name]) ? self::$_pool[$name] : self::create($name));
} | php | public static function getInstance($name)
{
return (isset(self::$_pool[$name]) ? self::$_pool[$name] : self::create($name));
} | [
"public",
"static",
"function",
"getInstance",
"(",
"$",
"name",
")",
"{",
"return",
"(",
"isset",
"(",
"self",
"::",
"$",
"_pool",
"[",
"$",
"name",
"]",
")",
"?",
"self",
"::",
"$",
"_pool",
"[",
"$",
"name",
"]",
":",
"self",
"::",
"create",
"... | This function returns an instance of an extension from it's name
@param string $name
The name of the Extension Class minus the extension prefix.
@throws SymphonyErrorPage
@throws Exception
@return Extension | [
"This",
"function",
"returns",
"an",
"instance",
"of",
"an",
"extension",
"from",
"it",
"s",
"name"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L125-L128 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.__buildExtensionList | private static function __buildExtensionList($update = false)
{
if (empty(self::$_extensions) || $update) {
self::$_extensions = Symphony::Database()->fetch("SELECT * FROM `tbl_extensions`", 'name');
}
} | php | private static function __buildExtensionList($update = false)
{
if (empty(self::$_extensions) || $update) {
self::$_extensions = Symphony::Database()->fetch("SELECT * FROM `tbl_extensions`", 'name');
}
} | [
"private",
"static",
"function",
"__buildExtensionList",
"(",
"$",
"update",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"_extensions",
")",
"||",
"$",
"update",
")",
"{",
"self",
"::",
"$",
"_extensions",
"=",
"Symphony",
"::",
... | Populates the `ExtensionManager::$_extensions` array with all the
extensions stored in `tbl_extensions`. If `ExtensionManager::$_extensions`
isn't empty, passing true as a parameter will force the array to update
@param boolean $update
Updates the `ExtensionManager::$_extensions` array even if it was
populated, defaul... | [
"Populates",
"the",
"ExtensionManager",
"::",
"$_extensions",
"array",
"with",
"all",
"the",
"extensions",
"stored",
"in",
"tbl_extensions",
".",
"If",
"ExtensionManager",
"::",
"$_extensions",
"isn",
"t",
"empty",
"passing",
"true",
"as",
"a",
"parameter",
"will"... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L140-L145 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.fetchStatus | public static function fetchStatus($about)
{
$return = array();
self::__buildExtensionList();
if (isset($about['handle']) && array_key_exists($about['handle'], self::$_extensions)) {
if (self::$_extensions[$about['handle']]['status'] == 'enabled') {
$return[] = E... | php | public static function fetchStatus($about)
{
$return = array();
self::__buildExtensionList();
if (isset($about['handle']) && array_key_exists($about['handle'], self::$_extensions)) {
if (self::$_extensions[$about['handle']]['status'] == 'enabled') {
$return[] = E... | [
"public",
"static",
"function",
"fetchStatus",
"(",
"$",
"about",
")",
"{",
"$",
"return",
"=",
"array",
"(",
")",
";",
"self",
"::",
"__buildExtensionList",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"about",
"[",
"'handle'",
"]",
")",
"&&",
"arra... | Returns the status of an Extension given an associative array containing
the Extension `handle` and `version` where the `version` is the file
version, not the installed version. This function returns an array
which may include a maximum of two statuses.
@param array $about
An associative array of the extension meta da... | [
"Returns",
"the",
"status",
"of",
"an",
"Extension",
"given",
"an",
"associative",
"array",
"containing",
"the",
"Extension",
"handle",
"and",
"version",
"where",
"the",
"version",
"is",
"the",
"file",
"version",
"not",
"the",
"installed",
"version",
".",
"Thi... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L163-L183 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.fetchInstalledVersion | public static function fetchInstalledVersion($name)
{
self::__buildExtensionList();
return (isset(self::$_extensions[$name]) ? self::$_extensions[$name]['version'] : null);
} | php | public static function fetchInstalledVersion($name)
{
self::__buildExtensionList();
return (isset(self::$_extensions[$name]) ? self::$_extensions[$name]['version'] : null);
} | [
"public",
"static",
"function",
"fetchInstalledVersion",
"(",
"$",
"name",
")",
"{",
"self",
"::",
"__buildExtensionList",
"(",
")",
";",
"return",
"(",
"isset",
"(",
"self",
"::",
"$",
"_extensions",
"[",
"$",
"name",
"]",
")",
"?",
"self",
"::",
"$",
... | A convenience method that returns an extension version from it's name.
@param string $name
The name of the Extension Class minus the extension prefix.
@return string | [
"A",
"convenience",
"method",
"that",
"returns",
"an",
"extension",
"version",
"from",
"it",
"s",
"name",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L192-L197 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.getProvidersOf | public static function getProvidersOf($type = null)
{
// Loop over all extensions and build an array of providable objects
if (empty(self::$_providers)) {
self::$_providers = array();
foreach (self::listInstalledHandles() as $handle) {
$obj = self::getInstanc... | php | public static function getProvidersOf($type = null)
{
// Loop over all extensions and build an array of providable objects
if (empty(self::$_providers)) {
self::$_providers = array();
foreach (self::listInstalledHandles() as $handle) {
$obj = self::getInstanc... | [
"public",
"static",
"function",
"getProvidersOf",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"// Loop over all extensions and build an array of providable objects",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"_providers",
")",
")",
"{",
"self",
"::",
"$",
"_provide... | Return an array all the Provider objects supplied by extensions,
optionally filtered by a given `$type`.
@since Symphony 2.3
@todo Add information about the possible types
@param string $type
This will only return Providers of this type. If null, which is
default, all providers will be returned.
@throws Exception
@thr... | [
"Return",
"an",
"array",
"all",
"the",
"Provider",
"objects",
"supplied",
"by",
"extensions",
"optionally",
"filtered",
"by",
"a",
"given",
"$type",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L227-L261 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.getCacheProvider | public static function getCacheProvider($key = null, $reuse = true)
{
$cacheDriver = Symphony::Configuration()->get($key, 'caching');
if (in_array($cacheDriver, array_keys(Symphony::ExtensionManager()->getProvidersOf('cache')))) {
$cacheable = new $cacheDriver;
} else {
... | php | public static function getCacheProvider($key = null, $reuse = true)
{
$cacheDriver = Symphony::Configuration()->get($key, 'caching');
if (in_array($cacheDriver, array_keys(Symphony::ExtensionManager()->getProvidersOf('cache')))) {
$cacheable = new $cacheDriver;
} else {
... | [
"public",
"static",
"function",
"getCacheProvider",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"reuse",
"=",
"true",
")",
"{",
"$",
"cacheDriver",
"=",
"Symphony",
"::",
"Configuration",
"(",
")",
"->",
"get",
"(",
"$",
"key",
",",
"'caching'",
")",
";",
... | This function will return the `Cacheable` object with the appropriate
caching layer for the given `$key`. This `$key` should be stored in
the Symphony configuration in the caching group with a reference
to the class of the caching object. If the key is not found, this
will return a default `Cacheable` object created wi... | [
"This",
"function",
"will",
"return",
"the",
"Cacheable",
"object",
"with",
"the",
"appropriate",
"caching",
"layer",
"for",
"the",
"given",
"$key",
".",
"This",
"$key",
"should",
"be",
"stored",
"in",
"the",
"Symphony",
"configuration",
"in",
"the",
"caching"... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L278-L296 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.__requiresInstallation | private static function __requiresInstallation($name)
{
self::__buildExtensionList();
$id = self::$_extensions[$name]['id'];
return (is_numeric($id) ? false : true);
} | php | private static function __requiresInstallation($name)
{
self::__buildExtensionList();
$id = self::$_extensions[$name]['id'];
return (is_numeric($id) ? false : true);
} | [
"private",
"static",
"function",
"__requiresInstallation",
"(",
"$",
"name",
")",
"{",
"self",
"::",
"__buildExtensionList",
"(",
")",
";",
"$",
"id",
"=",
"self",
"::",
"$",
"_extensions",
"[",
"$",
"name",
"]",
"[",
"'id'",
"]",
";",
"return",
"(",
"... | Determines whether the current extension is installed or not by checking
for an id in `tbl_extensions`
@param string $name
The name of the Extension Class minus the extension prefix.
@return boolean | [
"Determines",
"whether",
"the",
"current",
"extension",
"is",
"installed",
"or",
"not",
"by",
"checking",
"for",
"an",
"id",
"in",
"tbl_extensions"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L306-L312 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.__requiresUpdate | private static function __requiresUpdate($name, $file_version)
{
$installed_version = self::fetchInstalledVersion($name);
if (is_null($installed_version)) {
return false;
}
return (version_compare($installed_version, $file_version, '<') ? $installed_version : false);
... | php | private static function __requiresUpdate($name, $file_version)
{
$installed_version = self::fetchInstalledVersion($name);
if (is_null($installed_version)) {
return false;
}
return (version_compare($installed_version, $file_version, '<') ? $installed_version : false);
... | [
"private",
"static",
"function",
"__requiresUpdate",
"(",
"$",
"name",
",",
"$",
"file_version",
")",
"{",
"$",
"installed_version",
"=",
"self",
"::",
"fetchInstalledVersion",
"(",
"$",
"name",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"installed_version",
... | Determines whether an extension needs to be updated or not using
PHP's `version_compare` function. This function will return the
installed version if the extension requires an update, or
false otherwise.
@param string $name
The name of the Extension Class minus the extension prefix.
@param string $file_version
The ver... | [
"Determines",
"whether",
"an",
"extension",
"needs",
"to",
"be",
"updated",
"or",
"not",
"using",
"PHP",
"s",
"version_compare",
"function",
".",
"This",
"function",
"will",
"return",
"the",
"installed",
"version",
"if",
"the",
"extension",
"requires",
"an",
"... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L329-L338 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.enable | public static function enable($name)
{
$obj = self::getInstance($name);
// If not installed, install it
if (self::__requiresInstallation($name) && $obj->install() === false) {
// If the installation failed, run the uninstall method which
// should rollback the instal... | php | public static function enable($name)
{
$obj = self::getInstance($name);
// If not installed, install it
if (self::__requiresInstallation($name) && $obj->install() === false) {
// If the installation failed, run the uninstall method which
// should rollback the instal... | [
"public",
"static",
"function",
"enable",
"(",
"$",
"name",
")",
"{",
"$",
"obj",
"=",
"self",
"::",
"getInstance",
"(",
"$",
"name",
")",
";",
"// If not installed, install it",
"if",
"(",
"self",
"::",
"__requiresInstallation",
"(",
"$",
"name",
")",
"&&... | Enabling an extension will re-register all it's delegates with Symphony.
It will also install or update the extension if needs be by calling the
extensions respective install and update methods. The enable method is
of the extension object is finally called.
@see toolkit.ExtensionManager#registerDelegates()
@see toolk... | [
"Enabling",
"an",
"extension",
"will",
"re",
"-",
"register",
"all",
"it",
"s",
"delegates",
"with",
"Symphony",
".",
"It",
"will",
"also",
"install",
"or",
"update",
"the",
"extension",
"if",
"needs",
"be",
"by",
"calling",
"the",
"extensions",
"respective"... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L354-L398 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.disable | public static function disable($name)
{
$obj = self::getInstance($name);
self::__canUninstallOrDisable($obj);
$info = self::about($name);
$id = self::fetchExtensionID($name);
Symphony::Database()->update(
array(
'name' => $name,
... | php | public static function disable($name)
{
$obj = self::getInstance($name);
self::__canUninstallOrDisable($obj);
$info = self::about($name);
$id = self::fetchExtensionID($name);
Symphony::Database()->update(
array(
'name' => $name,
... | [
"public",
"static",
"function",
"disable",
"(",
"$",
"name",
")",
"{",
"$",
"obj",
"=",
"self",
"::",
"getInstance",
"(",
"$",
"name",
")",
";",
"self",
"::",
"__canUninstallOrDisable",
"(",
"$",
"obj",
")",
";",
"$",
"info",
"=",
"self",
"::",
"abou... | Disabling an extension will prevent it from executing but retain all it's
settings in the relevant tables. Symphony checks that an extension can
be disabled using the `canUninstallorDisable()` before removing
all delegate subscriptions from the database and calling the extension's
`disable()` function.
@see toolkit.Ex... | [
"Disabling",
"an",
"extension",
"will",
"prevent",
"it",
"from",
"executing",
"but",
"retain",
"all",
"it",
"s",
"settings",
"in",
"the",
"relevant",
"tables",
".",
"Symphony",
"checks",
"that",
"an",
"extension",
"can",
"be",
"disabled",
"using",
"the",
"ca... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L416-L440 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.uninstall | public static function uninstall($name)
{
// If this function is called because the extension doesn't exist,
// then catch the error and just remove from the database. This
// means that the uninstall() function will not run on the extension,
// which may be a blessing in disguise as... | php | public static function uninstall($name)
{
// If this function is called because the extension doesn't exist,
// then catch the error and just remove from the database. This
// means that the uninstall() function will not run on the extension,
// which may be a blessing in disguise as... | [
"public",
"static",
"function",
"uninstall",
"(",
"$",
"name",
")",
"{",
"// If this function is called because the extension doesn't exist,",
"// then catch the error and just remove from the database. This",
"// means that the uninstall() function will not run on the extension,",
"// which... | Uninstalling an extension will unregister all delegate subscriptions and
remove all extension settings. Symphony checks that an extension can
be uninstalled using the `canUninstallorDisable()` before calling
the extension's `uninstall()` function. Alternatively, if this function
is called because the extension describe... | [
"Uninstalling",
"an",
"extension",
"will",
"unregister",
"all",
"delegate",
"subscriptions",
"and",
"remove",
"all",
"extension",
"settings",
".",
"Symphony",
"checks",
"that",
"an",
"extension",
"can",
"be",
"uninstalled",
"using",
"the",
"canUninstallorDisable",
"... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L461-L484 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.registerDelegates | public static function registerDelegates($name)
{
$obj = self::getInstance($name);
$id = self::fetchExtensionID($name);
if (!$id) {
return false;
}
Symphony::Database()->delete('tbl_extensions_delegates', sprintf("
`extension_id` = %d ", $id
... | php | public static function registerDelegates($name)
{
$obj = self::getInstance($name);
$id = self::fetchExtensionID($name);
if (!$id) {
return false;
}
Symphony::Database()->delete('tbl_extensions_delegates', sprintf("
`extension_id` = %d ", $id
... | [
"public",
"static",
"function",
"registerDelegates",
"(",
"$",
"name",
")",
"{",
"$",
"obj",
"=",
"self",
"::",
"getInstance",
"(",
"$",
"name",
")",
";",
"$",
"id",
"=",
"self",
"::",
"fetchExtensionID",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
... | This functions registers an extensions delegates in `tbl_extensions_delegates`.
@param string $name
The name of the Extension Class minus the extension prefix.
@throws Exception
@throws SymphonyErrorPage
@return integer
The Extension ID | [
"This",
"functions",
"registers",
"an",
"extensions",
"delegates",
"in",
"tbl_extensions_delegates",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L496-L529 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.removeDelegates | public static function removeDelegates($name)
{
$delegates = Symphony::Database()->fetchCol('id', sprintf("
SELECT tbl_extensions_delegates.`id`
FROM `tbl_extensions_delegates`
LEFT JOIN `tbl_extensions`
ON (`tbl_extensions`.id = `tbl_extensions_delegates`.ext... | php | public static function removeDelegates($name)
{
$delegates = Symphony::Database()->fetchCol('id', sprintf("
SELECT tbl_extensions_delegates.`id`
FROM `tbl_extensions_delegates`
LEFT JOIN `tbl_extensions`
ON (`tbl_extensions`.id = `tbl_extensions_delegates`.ext... | [
"public",
"static",
"function",
"removeDelegates",
"(",
"$",
"name",
")",
"{",
"$",
"delegates",
"=",
"Symphony",
"::",
"Database",
"(",
")",
"->",
"fetchCol",
"(",
"'id'",
",",
"sprintf",
"(",
"\"\n SELECT tbl_extensions_delegates.`id`\n FROM `t... | This function will remove all delegate subscriptions for an extension
given an extension's name. This triggers `cleanupDatabase()`
@see toolkit.ExtensionManager#cleanupDatabase()
@param string $name
The name of the Extension Class minus the extension prefix.
@return boolean | [
"This",
"function",
"will",
"remove",
"all",
"delegate",
"subscriptions",
"for",
"an",
"extension",
"given",
"an",
"extension",
"s",
"name",
".",
"This",
"triggers",
"cleanupDatabase",
"()"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L540-L559 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.__canUninstallOrDisable | private static function __canUninstallOrDisable(Extension $obj)
{
$extension_handle = strtolower(preg_replace('/^extension_/i', null, get_class($obj)));
$about = self::about($extension_handle);
// Fields:
if (is_dir(EXTENSIONS . "/{$extension_handle}/fields")) {
foreach ... | php | private static function __canUninstallOrDisable(Extension $obj)
{
$extension_handle = strtolower(preg_replace('/^extension_/i', null, get_class($obj)));
$about = self::about($extension_handle);
// Fields:
if (is_dir(EXTENSIONS . "/{$extension_handle}/fields")) {
foreach ... | [
"private",
"static",
"function",
"__canUninstallOrDisable",
"(",
"Extension",
"$",
"obj",
")",
"{",
"$",
"extension_handle",
"=",
"strtolower",
"(",
"preg_replace",
"(",
"'/^extension_/i'",
",",
"null",
",",
"get_class",
"(",
"$",
"obj",
")",
")",
")",
";",
... | This function checks that if the given extension has provided Fields,
Data Sources or Events, that they aren't in use before the extension
is uninstalled or disabled. This prevents exceptions from occurring when
accessing an object that was using something provided by this Extension
can't anymore because it has been re... | [
"This",
"function",
"checks",
"that",
"if",
"the",
"given",
"extension",
"has",
"provided",
"Fields",
"Data",
"Sources",
"or",
"Events",
"that",
"they",
"aren",
"t",
"in",
"use",
"before",
"the",
"extension",
"is",
"uninstalled",
"or",
"disabled",
".",
"This... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L573-L633 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.notifyMembers | public static function notifyMembers($delegate, $page, array $context = array())
{
// Make sure $page is an array
if (!is_array($page)) {
$page = array($page);
}
// Support for global delegate subscription
if (!in_array('*', $page)) {
$page[] = '*';
... | php | public static function notifyMembers($delegate, $page, array $context = array())
{
// Make sure $page is an array
if (!is_array($page)) {
$page = array($page);
}
// Support for global delegate subscription
if (!in_array('*', $page)) {
$page[] = '*';
... | [
"public",
"static",
"function",
"notifyMembers",
"(",
"$",
"delegate",
",",
"$",
"page",
",",
"array",
"$",
"context",
"=",
"array",
"(",
")",
")",
"{",
"// Make sure $page is an array",
"if",
"(",
"!",
"is_array",
"(",
"$",
"page",
")",
")",
"{",
"$",
... | Given a delegate name, notify all extensions that have registered to that
delegate to executing their callbacks with a `$context` array parameter
that contains information about the current Symphony state.
@param string $delegate
The delegate name
@param string $page
The current page namespace that this delegate opera... | [
"Given",
"a",
"delegate",
"name",
"notify",
"all",
"extensions",
"that",
"have",
"registered",
"to",
"that",
"delegate",
"to",
"executing",
"their",
"callbacks",
"with",
"a",
"$context",
"array",
"parameter",
"that",
"contains",
"information",
"about",
"the",
"c... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L659-L711 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.listInstalledHandles | public static function listInstalledHandles()
{
if (empty(self::$_enabled_extensions) && Symphony::Database()->isConnected()) {
self::$_enabled_extensions = Symphony::Database()->fetchCol(
'name',
"SELECT `name` FROM `tbl_extensions` WHERE `status` = 'enabled'"
... | php | public static function listInstalledHandles()
{
if (empty(self::$_enabled_extensions) && Symphony::Database()->isConnected()) {
self::$_enabled_extensions = Symphony::Database()->fetchCol(
'name',
"SELECT `name` FROM `tbl_extensions` WHERE `status` = 'enabled'"
... | [
"public",
"static",
"function",
"listInstalledHandles",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"_enabled_extensions",
")",
"&&",
"Symphony",
"::",
"Database",
"(",
")",
"->",
"isConnected",
"(",
")",
")",
"{",
"self",
"::",
"$",
"_ena... | Returns an array of all the enabled extensions available
@return array | [
"Returns",
"an",
"array",
"of",
"all",
"the",
"enabled",
"extensions",
"available"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L718-L727 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.listAll | public static function listAll($filter = '/^((?![-^?%:*|"<>]).)*$/')
{
$result = array();
$extensions = General::listDirStructure(EXTENSIONS, $filter, false, EXTENSIONS);
if (is_array($extensions) && !empty($extensions)) {
foreach ($extensions as $extension) {
$e... | php | public static function listAll($filter = '/^((?![-^?%:*|"<>]).)*$/')
{
$result = array();
$extensions = General::listDirStructure(EXTENSIONS, $filter, false, EXTENSIONS);
if (is_array($extensions) && !empty($extensions)) {
foreach ($extensions as $extension) {
$e... | [
"public",
"static",
"function",
"listAll",
"(",
"$",
"filter",
"=",
"'/^((?![-^?%:*|\"<>]).)*$/'",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"extensions",
"=",
"General",
"::",
"listDirStructure",
"(",
"EXTENSIONS",
",",
"$",
"filter",
",",
... | Will return an associative array of all extensions and their about information
@param string $filter
Allows a regular expression to be passed to return only extensions whose
folders match the filter.
@throws SymphonyErrorPage
@throws Exception
@return array
An associative array with the key being the extension folder ... | [
"Will",
"return",
"an",
"associative",
"array",
"of",
"all",
"extensions",
"and",
"their",
"about",
"information"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L741-L757 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.sortByAuthor | private static function sortByAuthor($a, $b, $i = 0)
{
$first = $a;
$second = $b;
if (isset($a[$i])) {
$first = $a[$i];
}
if (isset($b[$i])) {
$second = $b[$i];
}
if ($first == $a && $second == $b && $first['name'] == $second['name']... | php | private static function sortByAuthor($a, $b, $i = 0)
{
$first = $a;
$second = $b;
if (isset($a[$i])) {
$first = $a[$i];
}
if (isset($b[$i])) {
$second = $b[$i];
}
if ($first == $a && $second == $b && $first['name'] == $second['name']... | [
"private",
"static",
"function",
"sortByAuthor",
"(",
"$",
"a",
",",
"$",
"b",
",",
"$",
"i",
"=",
"0",
")",
"{",
"$",
"first",
"=",
"$",
"a",
";",
"$",
"second",
"=",
"$",
"b",
";",
"if",
"(",
"isset",
"(",
"$",
"a",
"[",
"$",
"i",
"]",
... | Custom user sorting function used inside `fetch` to recursively sort authors
by their names.
@param array $a
@param array $b
@param integer $i
@return integer | [
"Custom",
"user",
"sorting",
"function",
"used",
"inside",
"fetch",
"to",
"recursively",
"sort",
"authors",
"by",
"their",
"names",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L768-L788 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.fetch | public static function fetch(array $select = array(), array $where = array(), $order_by = null)
{
$extensions = self::listAll();
$data = array();
if (empty($select) && empty($where) && is_null($order_by)) {
return $extensions;
}
if (empty($extensions)) {
... | php | public static function fetch(array $select = array(), array $where = array(), $order_by = null)
{
$extensions = self::listAll();
$data = array();
if (empty($select) && empty($where) && is_null($order_by)) {
return $extensions;
}
if (empty($extensions)) {
... | [
"public",
"static",
"function",
"fetch",
"(",
"array",
"$",
"select",
"=",
"array",
"(",
")",
",",
"array",
"$",
"where",
"=",
"array",
"(",
")",
",",
"$",
"order_by",
"=",
"null",
")",
"{",
"$",
"extensions",
"=",
"self",
"::",
"listAll",
"(",
")"... | This function will return an associative array of Extension information. The
information returned is defined by the `$select` parameter, which will allow
a developer to restrict what information is returned about the Extension.
Optionally, `$where` (not implemented) and `$order_by` parameters allow a developer to
furth... | [
"This",
"function",
"will",
"return",
"an",
"associative",
"array",
"of",
"Extension",
"information",
".",
"The",
"information",
"returned",
"is",
"defined",
"by",
"the",
"$select",
"parameter",
"which",
"will",
"allow",
"a",
"developer",
"to",
"restrict",
"what... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L811-L867 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.about | public static function about($name, $rawXML = false)
{
// See if the extension has the new meta format
if (file_exists(self::__getClassPath($name) . '/extension.meta.xml')) {
try {
$meta = new DOMDocument;
$meta->load(self::__getClassPath($name) . '/extens... | php | public static function about($name, $rawXML = false)
{
// See if the extension has the new meta format
if (file_exists(self::__getClassPath($name) . '/extension.meta.xml')) {
try {
$meta = new DOMDocument;
$meta->load(self::__getClassPath($name) . '/extens... | [
"public",
"static",
"function",
"about",
"(",
"$",
"name",
",",
"$",
"rawXML",
"=",
"false",
")",
"{",
"// See if the extension has the new meta format",
"if",
"(",
"file_exists",
"(",
"self",
"::",
"__getClassPath",
"(",
"$",
"name",
")",
".",
"'/extension.meta... | This function will load an extension's meta information given the extension
`$name`. Since Symphony 2.3, this function will look for an `extension.meta.xml`
file inside the extension's folder. If this is not found, it will initialise
the extension and invoke the `about()` function. By default this extension will
return... | [
"This",
"function",
"will",
"load",
"an",
"extension",
"s",
"meta",
"information",
"given",
"the",
"extension",
"$name",
".",
"Since",
"Symphony",
"2",
".",
"3",
"this",
"function",
"will",
"look",
"for",
"an",
"extension",
".",
"meta",
".",
"xml",
"file",... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L890-L1005 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.create | public static function create($name)
{
if (!isset(self::$_pool[$name])) {
$classname = self::__getClassName($name);
$path = self::__getDriverPath($name);
if (!is_file($path)) {
$errMsg = __('Could not find extension %s at location %s.', array(
... | php | public static function create($name)
{
if (!isset(self::$_pool[$name])) {
$classname = self::__getClassName($name);
$path = self::__getDriverPath($name);
if (!is_file($path)) {
$errMsg = __('Could not find extension %s at location %s.', array(
... | [
"public",
"static",
"function",
"create",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"_pool",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"classname",
"=",
"self",
"::",
"__getClassName",
"(",
"$",
"name",
")",
";... | Creates an instance of a given class and returns it
@param string $name
The name of the Extension Class minus the extension prefix.
@throws Exception
@throws SymphonyErrorPage
@return Extension | [
"Creates",
"an",
"instance",
"of",
"a",
"given",
"class",
"and",
"returns",
"it"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L1016-L1052 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.extensionmanager.php | ExtensionManager.cleanupDatabase | public static function cleanupDatabase()
{
// Grab any extensions sitting in the database
$rows = Symphony::Database()->fetch("SELECT `name` FROM `tbl_extensions`");
// Iterate over each row
if (is_array($rows) && !empty($rows)) {
foreach ($rows as $r) {
... | php | public static function cleanupDatabase()
{
// Grab any extensions sitting in the database
$rows = Symphony::Database()->fetch("SELECT `name` FROM `tbl_extensions`");
// Iterate over each row
if (is_array($rows) && !empty($rows)) {
foreach ($rows as $r) {
... | [
"public",
"static",
"function",
"cleanupDatabase",
"(",
")",
"{",
"// Grab any extensions sitting in the database",
"$",
"rows",
"=",
"Symphony",
"::",
"Database",
"(",
")",
"->",
"fetch",
"(",
"\"SELECT `name` FROM `tbl_extensions`\"",
")",
";",
"// Iterate over each row... | A utility function that is used by the ExtensionManager to ensure
stray delegates are not in `tbl_extensions_delegates`. It is called when
a new Delegate is added or removed. | [
"A",
"utility",
"function",
"that",
"is",
"used",
"by",
"the",
"ExtensionManager",
"to",
"ensure",
"stray",
"delegates",
"are",
"not",
"in",
"tbl_extensions_delegates",
".",
"It",
"is",
"called",
"when",
"a",
"new",
"Delegate",
"is",
"added",
"or",
"removed",
... | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.extensionmanager.php#L1059-L1083 |
symphonycms/symphony-2 | symphony/lib/core/class.cookie.php | Cookie.__init | private function __init()
{
$this->_session = Session::start($this->_timeout, $this->_path, $this->_domain, $this->_httpOnly, $this->_secure);
if (!$this->_session) {
return false;
}
if (!isset($_SESSION[$this->_index])) {
$_SESSION[$this->_index] = array();... | php | private function __init()
{
$this->_session = Session::start($this->_timeout, $this->_path, $this->_domain, $this->_httpOnly, $this->_secure);
if (!$this->_session) {
return false;
}
if (!isset($_SESSION[$this->_index])) {
$_SESSION[$this->_index] = array();... | [
"private",
"function",
"__init",
"(",
")",
"{",
"$",
"this",
"->",
"_session",
"=",
"Session",
"::",
"start",
"(",
"$",
"this",
"->",
"_timeout",
",",
"$",
"this",
"->",
"_path",
",",
"$",
"this",
"->",
"_domain",
",",
"$",
"this",
"->",
"_httpOnly",... | Initialises a new Session instance using this cookie's params
@throws Throwable
@return string|boolean | [
"Initialises",
"a",
"new",
"Session",
"instance",
"using",
"this",
"cookie",
"s",
"params"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/core/class.cookie.php#L125-L142 |
symphonycms/symphony-2 | symphony/lib/core/class.cookie.php | Cookie.get | public function get($name = null)
{
if (is_null($name) && isset($_SESSION[$this->_index])) {
return $_SESSION[$this->_index];
}
if (isset($_SESSION[$this->_index]) && is_array($_SESSION[$this->_index]) && array_key_exists($name, $_SESSION[$this->_index])) {
return $_... | php | public function get($name = null)
{
if (is_null($name) && isset($_SESSION[$this->_index])) {
return $_SESSION[$this->_index];
}
if (isset($_SESSION[$this->_index]) && is_array($_SESSION[$this->_index]) && array_key_exists($name, $_SESSION[$this->_index])) {
return $_... | [
"public",
"function",
"get",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
"&&",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"_index",
"]",
")",
")",
"{",
"return",
"$",
"_SESSION",
"[",
"$",
"... | Accessor function for properties in the `$_SESSION` array
@param string $name
The name of the property to retrieve (optional)
@return string|null
The value of the property, or null if it does not exist. If
no `$name` is provided, return the entire Cookie. | [
"Accessor",
"function",
"for",
"properties",
"in",
"the",
"$_SESSION",
"array"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/core/class.cookie.php#L167-L178 |
symphonycms/symphony-2 | symphony/lib/core/class.cookie.php | Cookie.expire | public function expire()
{
if (!isset($_SESSION[$this->_index]) || !is_array($_SESSION[$this->_index]) || empty($_SESSION[$this->_index])) {
return;
}
unset($_SESSION[$this->_index]);
// Calling session_destroy triggers the Session::destroy function which removes the en... | php | public function expire()
{
if (!isset($_SESSION[$this->_index]) || !is_array($_SESSION[$this->_index]) || empty($_SESSION[$this->_index])) {
return;
}
unset($_SESSION[$this->_index]);
// Calling session_destroy triggers the Session::destroy function which removes the en... | [
"public",
"function",
"expire",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"_index",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"_index",
"]",
")",
"||",
"empty",
"(",... | Expires the current `$_SESSION` by unsetting the Symphony
namespace (`$this->_index`). If the `$_SESSION`
is empty, the function will destroy the entire `$_SESSION`
@link http://au2.php.net/manual/en/function.session-destroy.php | [
"Expires",
"the",
"current",
"$_SESSION",
"by",
"unsetting",
"the",
"Symphony",
"namespace",
"(",
"$this",
"-",
">",
"_index",
")",
".",
"If",
"the",
"$_SESSION",
"is",
"empty",
"the",
"function",
"will",
"destroy",
"the",
"entire",
"$_SESSION"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/core/class.cookie.php#L187-L201 |
symphonycms/symphony-2 | symphony/lib/toolkit/cryptography/class.sha1.php | SHA1.hash | public static function hash($input)
{
if (Symphony::Log()) {
Symphony::Log()->pushDeprecateWarningToLog('SHA1::hash()', 'PBKDF2::hash()', array(
'message-format' => __('The use of `%s` is strongly discouraged due to severe security flaws.'),
));
}
retu... | php | public static function hash($input)
{
if (Symphony::Log()) {
Symphony::Log()->pushDeprecateWarningToLog('SHA1::hash()', 'PBKDF2::hash()', array(
'message-format' => __('The use of `%s` is strongly discouraged due to severe security flaws.'),
));
}
retu... | [
"public",
"static",
"function",
"hash",
"(",
"$",
"input",
")",
"{",
"if",
"(",
"Symphony",
"::",
"Log",
"(",
")",
")",
"{",
"Symphony",
"::",
"Log",
"(",
")",
"->",
"pushDeprecateWarningToLog",
"(",
"'SHA1::hash()'",
",",
"'PBKDF2::hash()'",
",",
"array",... | Uses `SHA1` to create a hash based on some input
@param string $input
the string to be hashed
@return string
the hashed string | [
"Uses",
"SHA1",
"to",
"create",
"a",
"hash",
"based",
"on",
"some",
"input"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/cryptography/class.sha1.php#L24-L32 |
symphonycms/symphony-2 | symphony/lib/toolkit/cryptography/class.sha1.php | SHA1.file | public static function file($input)
{
if (Symphony::Log()) {
Symphony::Log()->pushDeprecateWarningToLog('SHA1::file()', 'PBKDF2::hash()', array(
'message-format' => __('The use of `%s` is strongly discouraged due to severe security flaws.'),
));
}
retu... | php | public static function file($input)
{
if (Symphony::Log()) {
Symphony::Log()->pushDeprecateWarningToLog('SHA1::file()', 'PBKDF2::hash()', array(
'message-format' => __('The use of `%s` is strongly discouraged due to severe security flaws.'),
));
}
retu... | [
"public",
"static",
"function",
"file",
"(",
"$",
"input",
")",
"{",
"if",
"(",
"Symphony",
"::",
"Log",
"(",
")",
")",
"{",
"Symphony",
"::",
"Log",
"(",
")",
"->",
"pushDeprecateWarningToLog",
"(",
"'SHA1::file()'",
",",
"'PBKDF2::hash()'",
",",
"array",... | Uses `SHA1` to create a hash from the contents of a file
@param string $input
the file to be hashed
@return string
the hashed string | [
"Uses",
"SHA1",
"to",
"create",
"a",
"hash",
"from",
"the",
"contents",
"of",
"a",
"file"
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/cryptography/class.sha1.php#L42-L50 |
symphonycms/symphony-2 | symphony/lib/toolkit/class.page.php | Page.setHttpStatusValue | final public static function setHttpStatusValue($status_code, $string_value)
{
if (!$string_value) {
unset(self::$HTTP_STATUSES[$status_code]);
} elseif (is_int($status_code) && $status_code >= 100 && $status_code < 600) {
self::$HTTP_STATUSES[$status_code] = $string_value;
... | php | final public static function setHttpStatusValue($status_code, $string_value)
{
if (!$string_value) {
unset(self::$HTTP_STATUSES[$status_code]);
} elseif (is_int($status_code) && $status_code >= 100 && $status_code < 600) {
self::$HTTP_STATUSES[$status_code] = $string_value;
... | [
"final",
"public",
"static",
"function",
"setHttpStatusValue",
"(",
"$",
"status_code",
",",
"$",
"string_value",
")",
"{",
"if",
"(",
"!",
"$",
"string_value",
")",
"{",
"unset",
"(",
"self",
"::",
"$",
"HTTP_STATUSES",
"[",
"$",
"status_code",
"]",
")",
... | Sets the `$sting_value` for the specified `$status_code`.
If `$sting_value` is null, the `$status_code` is removed from
the array.
This allow developers to register customs HTTP_STATUS into the
static `Page::$HTTP_STATUSES` array and use `$page->setHttpStatus()`.
@since Symphony 2.3.2
@param integer $status_code
The... | [
"Sets",
"the",
"$sting_value",
"for",
"the",
"specified",
"$status_code",
".",
"If",
"$sting_value",
"is",
"null",
"the",
"$status_code",
"is",
"removed",
"from",
"the",
"array",
"."
] | train | https://github.com/symphonycms/symphony-2/blob/68f44f0c36ad3345068676bfb8a61c2e6a2e51f4/symphony/lib/toolkit/class.page.php#L188-L197 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.