_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q8000 | SystemSetting.setCoreResourceTreeNodeNameFallback | train | public function setCoreResourceTreeNodeNameFallback($value)
{
$this->setFieldName('resource_tree_node_name_fallback');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8001 | SystemSetting.setCoreResourceTreeNodeTooltip | train | public function setCoreResourceTreeNodeTooltip($value)
{
$this->setFieldName('resource_tree_node_tooltip');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8002 | SystemSetting.setCoreRichtextDefault | train | public function setCoreRichtextDefault($value)
{
$this->setFieldName('richtext_default');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8003 | SystemSetting.setCoreSearchDefault | train | public function setCoreSearchDefault($value)
{
$this->setFieldName('search_default');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8004 | SystemSetting.setCoreSendPoweredbyHeader | train | public function setCoreSendPoweredbyHeader($value)
{
$this->setFieldName('send_poweredby_header');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8005 | SystemSetting.setCoreServerOffsetTime | train | public function setCoreServerOffsetTime($value)
{
$this->setFieldName('server_offset_time');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8006 | SystemSetting.setCoreServerProtocol | train | public function setCoreServerProtocol($value)
{
$this->setFieldName('server_protocol');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8007 | SystemSetting.setCoreSessionCookieDomain | train | public function setCoreSessionCookieDomain($value)
{
$this->setFieldName('session_cookie_domain');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8008 | SystemSetting.setCoreSessionCookieHttponly | train | public function setCoreSessionCookieHttponly($value)
{
$this->setFieldName('session_cookie_httponly');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8009 | SystemSetting.setCoreSessionCookieLifetime | train | public function setCoreSessionCookieLifetime($value)
{
$this->setFieldName('session_cookie_lifetime');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8010 | SystemSetting.setCoreSessionCookiePath | train | public function setCoreSessionCookiePath($value)
{
$this->setFieldName('session_cookie_path');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8011 | SystemSetting.setCoreSessionGcMaxlifetime | train | public function setCoreSessionGcMaxlifetime($value)
{
$this->setFieldName('session_gc_maxlifetime');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8012 | SystemSetting.setCoreSessionHandlerClass | train | public function setCoreSessionHandlerClass($value)
{
$this->setFieldName('session_handler_class');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8013 | SystemSetting.setCoreSessionName | train | public function setCoreSessionName($value)
{
$this->setFieldName('session_name');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8014 | SystemSetting.setCoreSetHeader | train | public function setCoreSetHeader($value)
{
$this->setFieldName('set_header');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8015 | SystemSetting.setCoreSettingsDistro | train | public function setCoreSettingsDistro($value)
{
$this->setFieldName('settings_distro');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8016 | SystemSetting.setCoreSettingsVersion | train | public function setCoreSettingsVersion($value)
{
$this->setFieldName('settings_version');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8017 | SystemSetting.setCoreShowTvCategoriesHeader | train | public function setCoreShowTvCategoriesHeader($value)
{
$this->setFieldName('show_tv_categories_header');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8018 | SystemSetting.setCoreSiteName | train | public function setCoreSiteName($value)
{
$this->setFieldName('site_name');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8019 | SystemSetting.setCoreSiteStatus | train | public function setCoreSiteStatus($value)
{
$this->setFieldName('site_status');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8020 | SystemSetting.setCoreSymlinkMergeFields | train | public function setCoreSymlinkMergeFields($value)
{
$this->setFieldName('symlink_merge_fields');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8021 | SystemSetting.setCoreSyncsiteDefault | train | public function setCoreSyncsiteDefault($value)
{
$this->setFieldName('syncsite_default');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8022 | SystemSetting.setCoreTopmenuShowDescriptions | train | public function setCoreTopmenuShowDescriptions($value)
{
$this->setFieldName('topmenu_show_descriptions');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8023 | SystemSetting.setCoreTreeDefaultSort | train | public function setCoreTreeDefaultSort($value)
{
$this->setFieldName('tree_default_sort');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8024 | SystemSetting.setCoreTreeRootId | train | public function setCoreTreeRootId($value)
{
$this->setFieldName('tree_root_id');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8025 | SystemSetting.setCoreTvsBelowContent | train | public function setCoreTvsBelowContent($value)
{
$this->setFieldName('tvs_below_content');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8026 | SystemSetting.setCoreUdpermsAllowroot | train | public function setCoreUdpermsAllowroot($value)
{
$this->setFieldName('udperms_allowroot');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8027 | SystemSetting.setCoreUseBrowser | train | public function setCoreUseBrowser($value)
{
$this->setFieldName('use_browser');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8028 | SystemSetting.setCoreUseContextResourceTable | train | public function setCoreUseContextResourceTable($value)
{
$this->setFieldName('use_context_resource_table');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8029 | SystemSetting.setCoreUseEditor | train | public function setCoreUseEditor($value)
{
$this->setFieldName('use_editor');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8030 | SystemSetting.setCoreUseFrozenParentUris | train | public function setCoreUseFrozenParentUris($value)
{
$this->setFieldName('use_frozen_parent_uris');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8031 | SystemSetting.setCoreUseMultibyte | train | public function setCoreUseMultibyte($value)
{
$this->setFieldName('use_multibyte');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8032 | SystemSetting.setCoreUserNavParent | train | public function setCoreUserNavParent($value)
{
$this->setFieldName('user_nav_parent');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8033 | SystemSetting.setCoreWelcomeAction | train | public function setCoreWelcomeAction($value)
{
$this->setFieldName('welcome_action');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8034 | SystemSetting.setCoreWelcomeNamespace | train | public function setCoreWelcomeNamespace($value)
{
$this->setFieldName('welcome_namespace');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8035 | SystemSetting.setCoreWelcomeScreen | train | public function setCoreWelcomeScreen($value)
{
$this->setFieldName('welcome_screen');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8036 | SystemSetting.setCoreWelcomeScreenUrl | train | public function setCoreWelcomeScreenUrl($value)
{
$this->setFieldName('welcome_screen_url');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8037 | SystemSetting.setCoreWhichEditor | train | public function setCoreWhichEditor($value)
{
$this->setFieldName('which_editor');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8038 | SystemSetting.setCoreWhichElementEditor | train | public function setCoreWhichElementEditor($value)
{
$this->setFieldName('which_element_editor');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8039 | SystemSetting.setCoreXhtmlUrls | train | public function setCoreXhtmlUrls($value)
{
$this->setFieldName('xhtml_urls');
$this->loadObject(true);
$this->setFieldValue($value);
return $this;
} | php | {
"resource": ""
} |
q8040 | Sql.connect | train | public function connect()
{
if ($this->connected) {
return $this;
}
# Set that we are connected here, because queries can be run as part of the below code, which would cause an infinite loop
$this->connected = true;
switch ($this->mode) {
case "mysql":
$this->server = new \Mysqli($this->options["hostname"], $this->options["username"], $this->options["password"]);
if ($this->server->connect_error) {
$this->error();
}
if ($this->options["charset"]) {
$this->server->set_charset($this->options["charset"]);
}
if ($timezone = $this->options["timezone"]) {
if ($timezone === self::USE_PHP_TIMEZONE) {
$timezone = ini_get("date.timezone");
}
$this->query("SET time_zone='" . $timezone . "'");
}
if ($database = $this->options["database"]) {
if (!$this->server->select_db($database)) {
$this->error();
}
}
break;
case "postgres":
case "redshift":
$connect = "host=" . $this->options["hostname"] . " ";
$connect .= "user=" . $this->options["username"] . " ";
$connect .= "password=" . $this->options["password"] . " ";
$connect .= "dbname= " . $this->options["database"] . " ";
$this->server = pg_connect($connect, PGSQL_CONNECT_FORCE_NEW);
break;
case "odbc":
$this->server = odbc_connect($this->options["hostname"], $this->options["username"], $this->options["password"]);
break;
case "sqlite":
$this->server = new \Sqlite3($this->options["database"]);
break;
case "mssql":
$this->server = mssql_connect($this->options["hostname"], $this->options["username"], $this->options["password"]);
break;
case "mssqlsrv":
if (!$port = $this->options["port"]) {
$port = 1433;
}
$this->server = sqlsrv_connect("tcp:" . $this->options["hostname"] . ",{$port}", [
"Uid" => $this->options["username"],
"PWD" => $this->options["password"],
]);
break;
}
if (!$this->server) {
$this->error();
}
return $this;
} | php | {
"resource": ""
} |
q8041 | Sql.attachDatabase | train | public function attachDatabase($filename, $database = null)
{
if ($this->mode != "sqlite") {
throw new \Exception("You can only attach databases when in sqlite mode");
}
if (!$database) {
$database = pathinfo($filename, PATHINFO_FILENAME);
}
$query = "ATTACH DATABASE '" . $filename . "' AS " . $this->quoteTable($database);
$result = $this->query($query);
if (!$result) {
$this->error();
}
$this->attached[$database] = $filename;
return $result;
} | php | {
"resource": ""
} |
q8042 | Sql.getTableDatabase | train | protected function getTableDatabase($table)
{
if (!array_key_exists($table, $this->tables)) {
return false;
}
$database = $this->tables[$table];
# If this table's database depends on the mode
if (is_array($database)) {
if (array_key_exists($this->mode, $database)) {
$database = $database[$this->mode];
} else {
$database = $database["default"];
}
}
return $database;
} | php | {
"resource": ""
} |
q8043 | Sql.getTableName | train | protected function getTableName($table)
{
$database = $this->getTableDatabase($table);
# If we found a database for this table then include it in the return value
if ($database) {
$database = $this->quoteField($database);
if (substr($this->mode, 0, 5) === "mssql") {
$database .= ".dbo";
}
return $database . "." . $this->quoteField($table);
}
# If we didn't find a database, and this table already looks like it includes
if (strpos($table, ".") !== false) {
return $table;
}
return $this->quoteField($table);
} | php | {
"resource": ""
} |
q8044 | Sql.quoteChars | train | protected function quoteChars(&$query)
{
$checked = [];
$chars = $this->quoteChars[$this->mode];
if (is_array($chars)) {
$newFrom = $chars[0];
$newTo = $chars[1];
} else {
$newFrom = $chars;
$newTo = $chars;
}
foreach ($this->quoteChars as $mode => $chars) {
if ($mode == $this->mode) {
continue;
}
if (is_array($chars)) {
$oldFrom = $chars[0];
$oldTo = $chars[1];
} else {
$oldFrom = $chars;
$oldTo = $chars;
}
if ($oldFrom == $newFrom && $oldTo == $newTo) {
continue;
}
# Create part of the regex that will represent the quoted field we are trying to find
$match = preg_quote($oldFrom) . "([^" . preg_quote($oldTo) . "]*)" . preg_quote($oldTo);
# If we've already checked this regex then don't check it again
if (in_array($match, $checked, true)) {
continue;
}
$checked[] = $match;
$this->modifyQuery($query, function($part) use($match, $newFrom, $newTo) {
return preg_replace("/" . $match . "/", $newFrom . "$1" . $newTo, $part);
});
}
} | php | {
"resource": ""
} |
q8045 | Sql.functions | train | protected function functions(&$query)
{
switch ($this->mode) {
case "mysql":
case "odbc":
case "sqlite":
$query = preg_replace("/\bISNULL\(/", "IFNULL(", $query);
break;
case "postgres":
case "redshift":
$query = preg_replace("/\bI[FS]NULL\(/", "COALESCE(", $query);
break;
case "mssql":
case "mssqlsrv":
$query = preg_replace("/\bIFNULL\(/", "ISNULL(", $query);
break;
}
switch ($this->mode) {
case "mysql":
case "postgres":
case "redshift":
case "odbc":
case "mssql":
case "mssqlsrv":
$query = preg_replace("/\bSUBSTR\(/", "SUBSTRING(", $query);
break;
case "sqlite":
$query = preg_replace("/\bSUBSTRING\(/", "SUBSTR(", $query);
break;
}
switch ($this->mode) {
case "postgres":
case "redshift":
$query = preg_replace("/\FROM_UNIXTIME\(([^,\)]+),(\s*)([^\)]+)\)/", "TO_CHAR(ABSTIME($1), $3)", $query);
break;
}
} | php | {
"resource": ""
} |
q8046 | Sql.limit | train | protected function limit(&$query)
{
switch ($this->mode) {
case "mysql":
case "postgres":
case "redshift":
case "sqlite":
$query = preg_replace("/\bFETCH\s+FIRST\s+([0-9]+)\s+ROW(S?)\s+ONLY\b/i", "\nLIMIT $1\n", $query);
break;
case "odbc":
$query = preg_replace("/\bLIMIT\s+([0-9]+)\b/i", "\nFETCH FIRST $1 ROWS ONLY\n", $query);
break;
}
} | php | {
"resource": ""
} |
q8047 | Sql.paramArrays | train | protected function paramArrays(&$query, &$params)
{
if (!is_array($params)) {
return;
}
$newParams = [];
$this->modifyQuery($query, function ($part) use (&$params, &$newParams) {
$newPart = "";
$tmpPart = $part;
while (count($params) > 0) {
$pos = strpos($tmpPart, "?");
if ($pos === false) {
break;
}
$val = array_shift($params);
$newPart .= substr($tmpPart, 0, $pos);
$tmpPart = substr($tmpPart, $pos + 1);
# If this is just a straight value then don't do anything to it
if (!is_array($val)) {
$newPart .= "?";
$newParams[] = $val;
continue;
}
# If the array is only 1 element (or no elements) long then convert it to an = (or <> for NOT IN)
if (count($val) < 2) {
$newPart = preg_replace("/\s*\bNOT\s+IN\s*$/i", "<>", $newPart);
$newPart = preg_replace("/\s*\bIN\s*$/i", "=", $newPart);
$newPart .= "?";
$newParams[] = reset($val);
continue;
}
# Convert each element of the array to a separate marker
$markers = [];
foreach ($val as $v) {
$markers[] = "?";
$newParams[] = $v;
}
$newPart .= "(" . implode(",", $markers) . ")";
}
$newPart .= $tmpPart;
return $newPart;
});
$params = $newParams;
} | php | {
"resource": ""
} |
q8048 | Sql.namedParams | train | protected function namedParams(&$query, &$params)
{
if (!is_array($params)) {
return;
}
$pattern = "a-zA-Z0-9_";
if (!preg_match("/\?([" . $pattern . "]+)/", $query)) {
return;
}
$oldParams = $params;
$params = [];
reset($oldParams);
$this->modifyQuery($query, function($part) use(&$params, &$oldParams, $pattern) {
return preg_replace_callback("/\?([" . $pattern . "]*)([^" . $pattern . "]|$)/", function($match) use(&$params, &$oldParams) {
if ($key = $match[1]) {
$params[] = $oldParams[$key];
} else {
$params[] = current($oldParams);
next($oldParams);
}
return "?" . $match[2];
}, $part);
});
} | php | {
"resource": ""
} |
q8049 | Sql.cache | train | public function cache($query, array $params = null, $timeout = null)
{
$options = array_merge($this->cacheOptions, [
"sql" => $this,
"query" => $query,
"params" => $params,
]);
if ($timeout) {
$options["timeout"] = $timeout;
}
return new Cache($options);
} | php | {
"resource": ""
} |
q8050 | Sql.where | train | public function where($where, &$params)
{
if (!is_array($where)) {
throw new \Exception("Invalid where clause specified, must be an array");
}
$params = Helper::toArray($params);
$query = "";
$andFlag = false;
foreach ($where as $field => $value) {
# Add the and flag if this isn't the first field
if ($andFlag) {
$query .= "AND ";
} else {
$andFlag = true;
}
# Add the field name to the query
$query .= $this->quoteField($field);
# Convert arrays to use the in helper
if (is_array($value)) {
$helperMap = [
"<" => "lessThan",
"<=" => "lessThanOrEqualTo",
">" => "greaterThan",
">=" => "greaterThanOrEqualTo",
"=" => "equals",
"<>" => "notEqualTo",
];
$clause = (string) reset($value);
if (count($value) === 2 && isset($helperMap[$clause])) {
$method = $helperMap[$clause];
$val = next($value);
trigger_error("Using arrays for complex where clauses is deprecated in favour of the helper methods, eg Sql::" . $method . "(" . $val . ")", E_USER_DEPRECATED);
$value = static::$method($val);
} else {
$value = static::in($value);
}
}
# Any parameters not using a helper should use the standard equals helper
if (!is_object($value)) {
$value = static::equals($value);
}
$query .= " " . $value->getClause() . " ";
foreach ($value->getValues() as $val) {
$params[] = $val;
}
}
return $query;
} | php | {
"resource": ""
} |
q8051 | Sql.fieldSelect | train | public function fieldSelect($table, $fields, $where, $orderBy = null)
{
$table = $this->getTableName($table);
$query = "SELECT ";
if (substr($this->mode, 0, 5) === "mssql") {
$query .= "TOP 1 ";
}
$query .= $this->selectFields($fields);
$query .= " FROM " . $table . " ";
$params = null;
if ($where !== self::NO_WHERE_CLAUSE) {
$query .= "WHERE " . $this->where($where, $params);
}
if ($orderBy) {
$query .= $this->orderBy($orderBy) . " ";
}
switch ($this->mode) {
case "mysql":
case "postgres":
case "redshift":
case "sqlite":
$query .= "LIMIT 1";
break;
case "odbc":
$query .= "FETCH FIRST 1 ROW ONLY";
break;
}
return $this->query($query, $params)->fetch();
} | php | {
"resource": ""
} |
q8052 | Sql.fieldSelectAll | train | public function fieldSelectAll($table, $fields, $where, $orderBy = null)
{
$table = $this->getTableName($table);
$query = "SELECT ";
$query .= $this->selectFields($fields);
$query .= " FROM " . $table . " ";
$params = null;
if ($where !== self::NO_WHERE_CLAUSE) {
$query .= "WHERE " . $this->where($where, $params);
}
if ($orderBy) {
$query .= $this->orderBy($orderBy) . " ";
}
return $this->query($query, $params);
} | php | {
"resource": ""
} |
q8053 | Sql.insertOrUpdate | train | public function insertOrUpdate($table, array $set, array $where)
{
if ($this->select($table, $where)) {
$result = $this->update($table, $set, $where);
} else {
$params = array_merge($where, $set);
$result = $this->insert($table, $params);
}
return $result;
} | php | {
"resource": ""
} |
q8054 | Sql.orderBy | train | public function orderBy($fields)
{
if (!is_array($fields)) {
$fields = explode(",", $fields);
}
$orderBy = "";
foreach ($fields as $field) {
if (!$field = trim($field)) {
continue;
}
if (!$orderBy) {
$orderBy = "ORDER BY ";
} else {
$orderBy .= ", ";
}
if (strpos($field, " ")) {
$orderBy .= $field;
} else {
$orderBy .= $this->quoteField($field);
}
}
return $orderBy;
} | php | {
"resource": ""
} |
q8055 | Sql.quoteField | train | protected function quoteField($field)
{
# The odbc sql only uses it's quote strings for renaming fields, not for quoting table/field names
if ($this->mode == "odbc") {
return $field;
}
$field = trim($field);
$chars = $this->quoteChars[$this->mode];
if (is_array($chars)) {
$from = $chars[0];
$to = $chars[1];
} else {
$from = $chars;
$to = $chars;
}
$quoted = $from . $field . $to;
return $quoted;
} | php | {
"resource": ""
} |
q8056 | Sql.quoteTable | train | protected function quoteTable($table)
{
# The odbc sql only uses it's quote strings for renaming fields, not for quoting table/field names
if ($this->mode == "odbc") {
return $table;
}
$table = trim($table);
# There is a standard function for quoting postgres table names
if (in_array($this->mode, ["postgres", "redshift"], true)) {
$this->connect();
return pg_escape_identifier($this->server, $table);
}
$chars = $this->quoteChars[$this->mode];
if (is_array($chars)) {
$from = $chars[0];
$to = $chars[1];
} else {
$from = $chars;
$to = $chars;
}
$quoted = $from . $table . $to;
return $quoted;
} | php | {
"resource": ""
} |
q8057 | Sql.startTransaction | train | public function startTransaction()
{
# Ensure we have a connection to start the transaction on
$this->connect();
switch ($this->mode) {
case "mysql":
$result = $this->server->autocommit(false);
break;
case "postgres":
$result = $this->query("SET AUTOCOMMIT = OFF");
break;
case "redshift":
$result = $this->query("START TRANSACTION");
break;
case "odbc":
$result = odbc_autocommit($this->server, false);
break;
default:
throw new \Exception("startTransaction() not supported in this mode (" . $this->mode . ")");
}
if (!$result) {
$this->error();
}
$this->transaction = true;
return true;
} | php | {
"resource": ""
} |
q8058 | Sql.endTransaction | train | public function endTransaction($commit)
{
if ($commit) {
$result = $this->commit();
} else {
$result = $this->rollback();
}
switch ($this->mode) {
case "mysql":
if (!$this->server->autocommit(true)) {
$result = false;
}
break;
case "postgres":
$result = $this->query("SET AUTOCOMMIT = ON");
break;
case "redshift":
# Do nothing, and use the result from the commit/rollback
break;
case "odbc":
if (!odbc_autocommit($this->server, true)) {
$result = false;
}
break;
default:
throw new \Exception("endTransaction() not supported in this mode (" . $this->mode . ")");
}
if (!$result) {
$this->error();
}
$this->transaction = false;
return true;
} | php | {
"resource": ""
} |
q8059 | Sql.commit | train | public function commit()
{
switch ($this->mode) {
case "mysql":
$result = $this->server->commit();
break;
case "postgres":
case "redshift":
$result = $this->query("COMMIT");
break;
case "odbc":
$result = odbc_commit($this->server);
break;
default:
throw new \Exception("commit() not supported in this mode (" . $this->mode . ")");
}
if (!$result) {
$this->error();
}
return true;
} | php | {
"resource": ""
} |
q8060 | Sql.rollback | train | public function rollback()
{
switch ($this->mode) {
case "mysql":
$result = $this->server->rollback();
break;
case "postgres":
case "redshift":
$result = $this->query("ROLLBACK");
break;
case "odbc":
$result = odbc_rollback($this->server);
break;
default:
throw new \Exception("rollback() not supported in this mode (" . $this->mode . ")");
}
if (!$result) {
$this->error();
}
return true;
} | php | {
"resource": ""
} |
q8061 | Sql.lockTables | train | public function lockTables($tables)
{
/**
* Unlock any previously locked tables
* This is done to provide consistency across different modes, as mysql only allows one single lock over multiple tables
* Also the odbc only allows all locks to be released, not individual tables. So it makes sense to force the batching of lock/unlock operations
*/
$this->unlockTables();
$tables = Helper::toArray($tables);
if ($this->mode == "odbc") {
foreach ($tables as $table) {
$table = $this->getTableName($table);
$query = "LOCK TABLE " . $table . " IN EXCLUSIVE MODE ALLOW READ";
$this->query($query);
}
# If none of the locks failed then report success
return true;
}
foreach ($tables as &$table) {
$table = $this->getTableName($table);
}
unset($table);
if ($this->mode == "mysql") {
$query = "LOCK TABLES " . implode(",", $tables) . " WRITE";
return $this->query($query);
}
if (in_array($this->mode, ["postgres", "redshift"], true)) {
$query = "LOCK TABLE " . implode(",", $tables) . " IN EXCLUSIVE MODE";
return $this->query($query);
}
throw new \Exception("lockTables() not supported in this mode (" . $this->mode . ")");
} | php | {
"resource": ""
} |
q8062 | Sql.unlockTables | train | public function unlockTables()
{
switch ($this->mode) {
case "mysql":
$query = "UNLOCK TABLES";
break;
case "postgres":
case "redshift":
case "odbc":
$query = "COMMIT";
break;
default:
throw new \Exception("unlockTables() not supported in this mode (" . $this->mode . ")");
}
return $this->query($query);
} | php | {
"resource": ""
} |
q8063 | Sql.disconnect | train | public function disconnect()
{
if (!$this->connected || !$this->server || ($this->mode == "mysql" && $this->server->connect_error)) {
return false;
}
$result = false;
switch ($this->mode) {
case "mysql":
case "sqlite":
$result = $this->server->close();
break;
case "postgres":
case "redshift":
$result = pg_close($this->server);
break;
case "odbc":
odbc_close($this->server);
$result = true;
break;
case "mssql":
$result = mssql_close($this->server);
break;
case "mssqlsrv":
$result = sqlsrv_close($this->server);
break;
}
# If the disconnect was successful, set class property to reflect it
if ($result) {
$this->connected = false;
}
return $result;
} | php | {
"resource": ""
} |
q8064 | VerifierControlTrait.redirectVerified | train | public function redirectVerified($code, $destination = null, $parameters = []): void
{
// first parameter is optional
if (!is_numeric($code)) {
$parameters = is_array($destination) ? $destination : array_slice(func_get_args(), 1);
$destination = $code;
$code = null;
} elseif (!is_array($parameters)) {
$parameters = array_slice(func_get_args(), 2);
}
/** @var Presenter $presenter */
$presenter = $this->getPresenter();
$link = $presenter->createRequest($this, $destination, $parameters, 'redirect');
if ($presenter->getVerifier()->isLinkVerified($presenter->getLastCreatedRequest(), $this)) {
$presenter->redirectUrl($link, $code);
}
} | php | {
"resource": ""
} |
q8065 | VerifierControlTrait.linkVerified | train | public function linkVerified(string $destination, array $args = []): ?string
{
$link = $this->link($destination, $args);
/** @var Presenter $presenter */
$presenter = $this->getPresenter();
return $presenter->getVerifier()->isLinkVerified($presenter->getLastCreatedRequest(), $this) ? $link : null;
} | php | {
"resource": ""
} |
q8066 | VerifierControlTrait.getComponentVerified | train | public function getComponentVerified(string $name): ?IComponent
{
/** @var Presenter $presenter */
$presenter = $this->getPresenter();
return $presenter->getVerifier()->isComponentVerified($name, $presenter->getRequest(), $this) ? $this->getComponent($name) : null;
} | php | {
"resource": ""
} |
q8067 | VerifierControlTrait.attached | train | protected function attached($component): void
{
if ($component instanceof Presenter) {
$this->onPresenter($component);
}
parent::attached($component);
} | php | {
"resource": ""
} |
q8068 | Verifier.getRules | train | public function getRules(Reflector $reflection): array
{
if ($reflection instanceof ReflectionMethod) {
$key = $reflection->getDeclaringClass()->getName().'::'.$reflection->getName();
} elseif ($reflection instanceof ReflectionClass) {
$key = $reflection->getName();
} elseif ($reflection instanceof ReflectionProperty) {
$key = $reflection->getDeclaringClass()->getName().'::$'.$reflection->getName();
} else {
throw new InvalidArgumentException('Reflection must be an instance of either ReflectionMethod, ReflectionClass or ReflectionProperty.');
}
if (!isset($this->cache[$key])) {
$this->cache[$key] = $this->ruleProvider->getRules($reflection);
}
return $this->cache[$key];
} | php | {
"resource": ""
} |
q8069 | Verifier.checkRules | train | public function checkRules(array $rules, Request $request, ?string $component = null): void
{
foreach ($rules as $rule) {
$class = get_class($rule);
$handler = ($this->handlerResolver)($class);
if (!$handler instanceof RuleHandlerInterface) {
throw new UnexpectedTypeException("No rule handler found for type '$class'.");
}
$handler->checkRule($rule, $request, $component);
}
} | php | {
"resource": ""
} |
q8070 | Verifier.checkReflection | train | public function checkReflection(Reflector $reflection, Request $request, ?string $component = null): void
{
$rules = $this->getRules($reflection);
$this->checkRules($rules, $request, $component);
} | php | {
"resource": ""
} |
q8071 | Verifier.isLinkVerified | train | public function isLinkVerified(Request $request, Component $component): bool
{
try {
$parameters = $request->getParameters();
if (isset($parameters[Presenter::SIGNAL_KEY])) {
// No need to check anything else, the requirements for presenter,
// action and component had to be met for the current request.
$signalId = $parameters[Presenter::SIGNAL_KEY];
if (!is_string($signalId)) {
throw new InvalidArgumentException('Signal name is not a string.');
}
$pos = strrpos($signalId, '-');
if ($pos !== false) {
// signal for a component
$name = $component->getUniqueId();
if ($name !== substr($signalId, 0, $pos)) {
throw new InvalidArgumentException("Wrong signal receiver, expected '".substr($signalId, 0, $pos)."' component but '$name' was given.");
}
$reflection = new ComponentReflection($component);
$signal = substr($signalId, $pos + 1);
} else {
// signal for presenter
$name = null;
$presenter = $request->getPresenterName();
$reflection = new ComponentReflection($this->presenterFactory->getPresenterClass($presenter));
$signal = $signalId;
}
// Signal requirements
$method = 'handle'.$signal;
if ($reflection->hasCallableMethod($method)) {
$this->checkReflection($reflection->getMethod($method), $request, $name);
}
} else {
$presenter = $request->getPresenterName();
$reflection = new ComponentReflection($this->presenterFactory->getPresenterClass($presenter));
// Presenter requirements
$this->checkReflection($reflection, $request);
// Action requirements
$action = $parameters[Presenter::ACTION_KEY];
$method = 'action'.$action;
if ($reflection->hasCallableMethod($method)) {
$this->checkReflection($reflection->getMethod($method), $request);
}
}
} catch (VerificationException $e) {
return false;
}
return true;
} | php | {
"resource": ""
} |
q8072 | Verifier.isComponentVerified | train | public function isComponentVerified(string $name, Request $request, Component $parent): bool
{
$reflection = new ComponentReflection($parent);
$method = 'createComponent'.ucfirst($name);
if ($reflection->hasMethod($method)) {
$factory = $reflection->getMethod($method);
try {
$this->checkReflection($factory, $request, $parent->getParent() !== null ? $parent->getUniqueId() : null);
} catch (VerificationException $e) {
return false;
}
}
return true;
} | php | {
"resource": ""
} |
q8073 | RouteMethods.addRouteToGroup | train | protected function addRouteToGroup (\MvcCore\IRoute & $route, $routeName, $groupName, $prepend) {
if ($groupName === NULL) {
$routesGroupsKey = '';
} else {
$routesGroupsKey = $groupName;
$route->SetGroupName($groupName);
}
if (isset($this->routesGroups[$routesGroupsKey])) {
$groupRoutes = & $this->routesGroups[$routesGroupsKey];
} else {
$groupRoutes = [];
$this->routesGroups[$routesGroupsKey] = & $groupRoutes;
}
if ($prepend) {
$newItem = [$routeName => $route];
$groupRoutes = $newItem + $groupRoutes;
} else {
$groupRoutes[$routeName] = $route;
}
} | php | {
"resource": ""
} |
q8074 | RouteMethods.HasRoute | train | public function HasRoute ($routeOrRouteName) {
if (is_string($routeOrRouteName)) {
return isset($this->routes[$routeOrRouteName]);
} else /*if ($routeOrRouteName instance of \MvcCore\IRoute)*/ {
return (
isset($this->routes[$routeOrRouteName->GetName()]) ||
isset($this->routes[$routeOrRouteName->GetControllerAction()])
);
}
//return FALSE;
} | php | {
"resource": ""
} |
q8075 | RouteMethods.RemoveRoute | train | public function RemoveRoute ($routeName) {
$result = NULL;
if (isset($this->routes[$routeName])) {
$result = $this->routes[$routeName];
unset($this->routes[$routeName]);
$this->removeRouteFromGroup($result, $routeName);
$controllerAction = $result->GetControllerAction();
if (isset($this->urlRoutes[$routeName]))
unset($this->urlRoutes[$routeName]);
if (isset($this->urlRoutes[$controllerAction]))
unset($this->urlRoutes[$controllerAction]);
/** @var $currentRoute \MvcCore\Route */
$currentRoute = & $this->currentRoute;
if ($currentRoute->GetName() === $result->GetName())
$this->currentRoute = NULL;
}
if (!$this->routes && $this->preRouteMatchingHandler === NULL)
$this->anyRoutesConfigured = FALSE;
return $result;
} | php | {
"resource": ""
} |
q8076 | RouteMethods.& | train | public function & GetRoute ($routeName) {
if (isset($this->routes[$routeName]))
return $this->routes[$routeName];
return NULL;
} | php | {
"resource": ""
} |
q8077 | Yaml.addFile | train | public function addFile($file, $resource = null)
{
if (!file_exists($file) || !is_file($file)) {
throw new \Exception('The configuration file ' . $file . ' does not exist.');
} else {
if ($resource === null) {
$resource = $file;
}
if (!array_key_exists($resource, self::$parameters)) {
self::$parameters[$resource] = new ParameterBag();
}
$content = YamlParser::parse(file_get_contents($file));
if ($content !== null) {
$content = self::parseImports($content, $resource);
$content = self::parseParameters($content, $resource);
self::addConfig($content, $resource);
}
}
return self::getInstance();
} | php | {
"resource": ""
} |
q8078 | Yaml.addDirectory | train | public function addDirectory($directory)
{
if (!file_exists($directory) || !is_dir($directory)) {
throw new \Exception('The configuration directory does not exist.');
} else {
if (substr($directory, -1) != DIRECTORY_SEPARATOR) {
$directory .= DIRECTORY_SEPARATOR;
}
foreach (glob($directory . '*.yml') as $file) {
self::addFile($file);
}
}
return self::getInstance();
} | php | {
"resource": ""
} |
q8079 | Yaml.addParameters | train | public function addParameters(array $parameters)
{
self::$global_parameters = array_merge(self::$global_parameters, $parameters);
return self::getInstance();
} | php | {
"resource": ""
} |
q8080 | Yaml.addConfig | train | protected function addConfig(array $content, $resource)
{
foreach ($content as $key => $value) {
$parameterBag = self::$parameters[$resource];
$value = $parameterBag->unescapeValue($parameterBag->resolveValue($value));
if (is_array($value) && !is_numeric($key)) {
$key = array($key => $value);
$value = true;
}
self::$slim->config($key, $value);
}
} | php | {
"resource": ""
} |
q8081 | Yaml.parseImports | train | protected function parseImports(array $content, $resource)
{
if (isset($content['imports'])) {
$chdir = dirname($resource);
foreach ($content['imports'] as $import) {
self::addFile($chdir . DIRECTORY_SEPARATOR . $import['resource'], $resource);
}
unset($content['imports']);
}
return $content;
} | php | {
"resource": ""
} |
q8082 | RateAjaxController.ratingAction | train | public function ratingAction(Request $request)
{
$arrData = $request->request->get('data');
$fltValue = $request->request->get('rating');
if (!($arrData && $arrData['id'] && $arrData['pid'] && $arrData['item'])) {
$this->bail('Invalid request.');
}
$objMetaModel = $this->factory->getMetaModel($this->factory->translateIdToMetaModelName($arrData['pid']));
if (!$objMetaModel) {
$this->bail('No MetaModel.');
}
/** @var Rating $objAttribute */
$objAttribute = $objMetaModel->getAttributeById($arrData['id']);
if (!$objAttribute) {
$this->bail('No Attribute.');
}
$objAttribute->addVote($arrData['item'], (float) $fltValue, true);
return new Response();
} | php | {
"resource": ""
} |
q8083 | KeywordsMetaElement.withAddedKeywords | train | public function withAddedKeywords(array $keywords = []) : self
{
$existing = array_map('trim', explode(',', $this->getAttribute('content') ?: ''));
$new = array_merge($existing, $keywords);
return $this->withAttribute('content', implode(', ', $new));
} | php | {
"resource": ""
} |
q8084 | DataMethods.GetValues | train | public function GetValues ($getNullValues = FALSE, $includeInheritProperties = TRUE, $publicOnly = TRUE) {
$data = [];
$modelClassName = get_class($this);
$classReflector = new \ReflectionClass($modelClassName);
$properties = $publicOnly ? $classReflector->getProperties(\ReflectionProperty::IS_PUBLIC) : $classReflector->getProperties();
foreach ($properties as $property) {
if (!$includeInheritProperties && $property->class != $modelClassName) continue;
$propertyName = $property->name;
if (isset(static::$protectedProperties[$propertyName])) continue;
if (!$getNullValues && $this->$propertyName === NULL) continue;
$data[$propertyName] = $this->$propertyName;
}
return $data;
} | php | {
"resource": ""
} |
q8085 | PropsGettersSetters.& | train | public function & SetCode ($code, $codeMessage = NULL) {
/** @var $this \MvcCore\Response */
$this->code = $code;
if ($codeMessage !== NULL) $this->codeMessage = $codeMessage;
http_response_code($code);
return $this;
} | php | {
"resource": ""
} |
q8086 | PropsGettersSetters.GetCode | train | public function GetCode () {
if ($this->code === NULL) {
$phpCode = http_response_code();
$this->code = $phpCode === FALSE ? static::OK : $phpCode;
}
return $this->code;
} | php | {
"resource": ""
} |
q8087 | VendorDirectoryFixer.getLocation | train | public function getLocation($component_name, $path_within_component)
{
if ($this->complete_symfony_checkout) {
$component_location = $this->vendor_directory . 'symfony/symfony/src';
} else {
$component_location = $this->vendor_directory . 'symfony/' . $component_name;
}
return $component_location . $path_within_component;
} | php | {
"resource": ""
} |
q8088 | MelisEngineLangService.getAvailableLanguages | train | public function getAvailableLanguages()
{
// Event parameters prepare
$arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args());
// Sending service start event
$arrayParameters = $this->sendEvent('melisengine_service_get_available_languages_start', $arrayParameters);
// Service implementation start
$langTable = $this->getServiceLocator()->get('MelisEngineTableCmsLang');
$results = $langTable->fetchAll()->toArray();
// Service implementation end
// Adding results to parameters for events treatment if needed
$arrayParameters['results'] = $results;
// Sending service end event
$arrayParameters = $this->sendEvent('melisengine_service_get_available_languages_end', $arrayParameters);
return $arrayParameters['results'];
} | php | {
"resource": ""
} |
q8089 | MelisEngineLangService.getSiteLanguage | train | public function getSiteLanguage()
{
// Event parameters prepare
$arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args());
// Sending service start event
$arrayParameters = $this->sendEvent('melisengine_service_get_site_lang_start', $arrayParameters);
// Service implementation start
$siteModule = getenv('MELIS_MODULE');
$container = new Container('melisplugins');
$config = $this->getServiceLocator()->get('config');
$langId = $container['melis-plugins-lang-id'];
$langLocale = $container['melis-plugins-lang-locale'];
if (!empty($config['site'][$siteModule]['language']['language_id']))
$langId = $config['site'][$siteModule]['language']['language_id'];
if (!empty($config['site'][$siteModule]['language']['language_locale']))
$langLocale = $config['site'][$siteModule]['language']['language_locale'];
$result = array(
'langId' => $langId,
'langLocale' => $langLocale,
);
// Service implementation end
// Adding results to parameters for events treatment if needed
$arrayParameters['results'] = $result;
// Sending service end event
$arrayParameters = $this->sendEvent('melisengine_service_get_site_lang_end', $arrayParameters);
return $arrayParameters['results'];
} | php | {
"resource": ""
} |
q8090 | Inspector.isEmpty | train | public static function isEmpty($value)
{
if (!isset($value)) {
return true;
} elseif (is_bool($value)) {
return false;
} elseif ($value === 0) {
return false;
} elseif (empty($value)) {
return true;
} elseif (is_object($value) && method_exists($value, 'isEmpty')) {
return $value->isEmpty();
} elseif (static::isTraversable($value)) {
foreach ($value as $k => $val) {
if (!static::isEmpty($val)) {
return false;
}
}
return true;
}
return false;
} | php | {
"resource": ""
} |
q8091 | Inspector.isTraversable | train | public static function isTraversable($value)
{
return is_array($value) || (is_object($value) && (get_class($value) == 'stdClass' || $value instanceof \Traversable));
} | php | {
"resource": ""
} |
q8092 | Closing.GetSessionMaxTime | train | public static function GetSessionMaxTime () {
static::$sessionMaxTime = static::$sessionStartTime;
if (static::$meta->expirations) {
foreach (static::$meta->expirations as /*$sessionNamespaceName => */$expiration) {
if ($expiration > static::$sessionMaxTime)
static::$sessionMaxTime = $expiration;
}
}
return static::$sessionMaxTime;
} | php | {
"resource": ""
} |
q8093 | AliasAssertTrait.assertArray | train | public static function assertArray($actual, string $message = '')
{
self::assertTypeOfScalar($actual, $message, 'assertArray', new ScalarConstraint(ScalarConstraint::TYPE_ARRAY));
} | php | {
"resource": ""
} |
q8094 | AliasAssertTrait.assertScalar | train | public static function assertScalar($actual, string $message = '')
{
self::assertTypeOfScalar($actual, $message, 'assertScalar', new ScalarConstraint(ScalarConstraint::TYPE_SCALAR));
} | php | {
"resource": ""
} |
q8095 | AliasAssertTrait.assertString | train | public static function assertString($actual, string $message = '')
{
self::assertTypeOfScalar($actual, $message, 'assertString', new ScalarConstraint(ScalarConstraint::TYPE_STRING));
} | php | {
"resource": ""
} |
q8096 | AliasAssertTrait.assertNotArray | train | public static function assertNotArray($actual, string $message = '')
{
self::assertTypeOfScalar($actual, $message, 'assertNotArray', new LogicalNot(new ScalarConstraint(ScalarConstraint::TYPE_ARRAY)));
} | php | {
"resource": ""
} |
q8097 | AliasAssertTrait.assertNotScalar | train | public static function assertNotScalar($actual, string $message = '')
{
self::assertTypeOfScalar($actual, $message, 'assertNotScalar', new LogicalNot(new ScalarConstraint(ScalarConstraint::TYPE_SCALAR)));
} | php | {
"resource": ""
} |
q8098 | AliasAssertTrait.assertNotString | train | public static function assertNotString($actual, string $message = '')
{
self::assertTypeOfScalar($actual, $message, 'assertNotString', new LogicalNot(new ScalarConstraint(ScalarConstraint::TYPE_STRING)));
} | php | {
"resource": ""
} |
q8099 | ViewHelpers.& | train | public function & SetHelper ($helperName, & $instance, $forAllTemplates = TRUE) {
/** @var $this \MvcCore\View */
$implementsIHelper = FALSE;
if ($forAllTemplates) {
if (self::$_toolClass === NULL)
self::$_toolClass = \MvcCore\Application::GetInstance()->GetToolClass();
$toolClass = self::$_toolClass;
$helpersInterface = self::HELPERS_INTERFACE_CLASS_NAME;
$className = get_class($instance);
$implementsIHelper = $toolClass::CheckClassInterface($className, $helpersInterface, FALSE, FALSE);
self::$_globalHelpers[$helperName] = [& $instance, $implementsIHelper];
}
$this->__protected['helpers'][$helperName] = & $instance;
if ($implementsIHelper) $instance->SetView($this);
return $this;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.