repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.checkForKeyword
private function checkForKeyword($value) { if (! isset($_SESSION['behat']['GenesisSqlExtension']['keywords'])) { return $value; } foreach ($_SESSION['behat']['GenesisSqlExtension']['keywords'] as $keyword => $val) { $key = sprintf('{%s}', $keyword); if ($value == $key) { $value = str_replace($key, $val, $value); } } return $value; }
php
private function checkForKeyword($value) { if (! isset($_SESSION['behat']['GenesisSqlExtension']['keywords'])) { return $value; } foreach ($_SESSION['behat']['GenesisSqlExtension']['keywords'] as $keyword => $val) { $key = sprintf('{%s}', $keyword); if ($value == $key) { $value = str_replace($key, $val, $value); } } return $value; }
[ "private", "function", "checkForKeyword", "(", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "_SESSION", "[", "'behat'", "]", "[", "'GenesisSqlExtension'", "]", "[", "'keywords'", "]", ")", ")", "{", "return", "$", "value", ";", "}", "fore...
Checks the value for possible keywords set in behat.yml file.
[ "Checks", "the", "value", "for", "possible", "keywords", "set", "in", "behat", ".", "yml", "file", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L354-L369
train
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.debugLog
public function debugLog($log) { if (defined('DEBUG_MODE') and DEBUG_MODE == 1) { $log = 'DEBUG >>> ' . $log; echo $log . PHP_EOL . PHP_EOL; } return $this; }
php
public function debugLog($log) { if (defined('DEBUG_MODE') and DEBUG_MODE == 1) { $log = 'DEBUG >>> ' . $log; echo $log . PHP_EOL . PHP_EOL; } return $this; }
[ "public", "function", "debugLog", "(", "$", "log", ")", "{", "if", "(", "defined", "(", "'DEBUG_MODE'", ")", "and", "DEBUG_MODE", "==", "1", ")", "{", "$", "log", "=", "'DEBUG >>> '", ".", "$", "log", ";", "echo", "$", "log", ".", "PHP_EOL", ".", "...
Prints out messages when in debug mode.
[ "Prints", "out", "messages", "when", "in", "debug", "mode", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L374-L382
train
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.execute
protected function execute($sql) { $this->lastQuery = $sql; $this->debugLog(sprintf('Executing SQL: %s', $sql)); $this->sqlStatement = $this->getConnection()->prepare($sql, []); $this->sqlStatement->execute(); $this->lastId = $this->connection->lastInsertId(sprintf('%s_id_seq', $this->getEntity())); // If their is an id, save it! if ($this->lastId) { $this->handleLastId($this->getEntity(), $this->lastId); } return $this->sqlStatement; }
php
protected function execute($sql) { $this->lastQuery = $sql; $this->debugLog(sprintf('Executing SQL: %s', $sql)); $this->sqlStatement = $this->getConnection()->prepare($sql, []); $this->sqlStatement->execute(); $this->lastId = $this->connection->lastInsertId(sprintf('%s_id_seq', $this->getEntity())); // If their is an id, save it! if ($this->lastId) { $this->handleLastId($this->getEntity(), $this->lastId); } return $this->sqlStatement; }
[ "protected", "function", "execute", "(", "$", "sql", ")", "{", "$", "this", "->", "lastQuery", "=", "$", "sql", ";", "$", "this", "->", "debugLog", "(", "sprintf", "(", "'Executing SQL: %s'", ",", "$", "sql", ")", ")", ";", "$", "this", "->", "sqlSta...
Executes sql command.
[ "Executes", "sql", "command", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L387-L403
train
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.saveLastId
protected function saveLastId($entity, $id) { $this->debugLog(sprintf('Last ID fetched: %d', $id)); $_SESSION['behat']['GenesisSqlExtension']['last_id'][$entity][] = $id; }
php
protected function saveLastId($entity, $id) { $this->debugLog(sprintf('Last ID fetched: %d', $id)); $_SESSION['behat']['GenesisSqlExtension']['last_id'][$entity][] = $id; }
[ "protected", "function", "saveLastId", "(", "$", "entity", ",", "$", "id", ")", "{", "$", "this", "->", "debugLog", "(", "sprintf", "(", "'Last ID fetched: %d'", ",", "$", "id", ")", ")", ";", "$", "_SESSION", "[", "'behat'", "]", "[", "'GenesisSqlExtens...
Save the last insert id in the session for later retrieval.
[ "Save", "the", "last", "insert", "id", "in", "the", "session", "for", "later", "retrieval", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L408-L413
train
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.throwErrorIfNoRowsAffected
public function throwErrorIfNoRowsAffected($sqlStatement, $ignoreDuplicate = false) { if (! $this->hasFetchedRows($sqlStatement)) { $error = print_r($sqlStatement->errorInfo(), true); if ($ignoreDuplicate and preg_match('/duplicate/i', $error)) { return $sqlStatement->errorInfo(); } throw new \Exception( sprintf( 'No rows were effected!%sSQL: "%s",%sError: %s', PHP_EOL, $sqlStatement->queryString, PHP_EOL, $error ) ); } return false; }
php
public function throwErrorIfNoRowsAffected($sqlStatement, $ignoreDuplicate = false) { if (! $this->hasFetchedRows($sqlStatement)) { $error = print_r($sqlStatement->errorInfo(), true); if ($ignoreDuplicate and preg_match('/duplicate/i', $error)) { return $sqlStatement->errorInfo(); } throw new \Exception( sprintf( 'No rows were effected!%sSQL: "%s",%sError: %s', PHP_EOL, $sqlStatement->queryString, PHP_EOL, $error ) ); } return false; }
[ "public", "function", "throwErrorIfNoRowsAffected", "(", "$", "sqlStatement", ",", "$", "ignoreDuplicate", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "hasFetchedRows", "(", "$", "sqlStatement", ")", ")", "{", "$", "error", "=", "print_r", "...
Check for any mysql errors.
[ "Check", "for", "any", "mysql", "errors", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L430-L451
train
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.throwExceptionIfErrors
public function throwExceptionIfErrors($sqlStatement) { if ((int) $sqlStatement->errorCode()) { throw new \Exception( print_r($sqlStatement->errorInfo(), true) ); } return false; }
php
public function throwExceptionIfErrors($sqlStatement) { if ((int) $sqlStatement->errorCode()) { throw new \Exception( print_r($sqlStatement->errorInfo(), true) ); } return false; }
[ "public", "function", "throwExceptionIfErrors", "(", "$", "sqlStatement", ")", "{", "if", "(", "(", "int", ")", "$", "sqlStatement", "->", "errorCode", "(", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "print_r", "(", "$", "sqlStatement", "->", ...
Errors found then throw exception.
[ "Errors", "found", "then", "throw", "exception", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L456-L465
train
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.quoteOrNot
public function quoteOrNot($val) { return ((is_string($val) || is_numeric($val)) and !$this->isNotQuotable($val)) ? sprintf("'%s'", $val) : $val; }
php
public function quoteOrNot($val) { return ((is_string($val) || is_numeric($val)) and !$this->isNotQuotable($val)) ? sprintf("'%s'", $val) : $val; }
[ "public", "function", "quoteOrNot", "(", "$", "val", ")", "{", "return", "(", "(", "is_string", "(", "$", "val", ")", "||", "is_numeric", "(", "$", "val", ")", ")", "and", "!", "$", "this", "->", "isNotQuotable", "(", "$", "val", ")", ")", "?", "...
Quotes value if needed for sql.
[ "Quotes", "value", "if", "needed", "for", "sql", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L482-L485
train
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.getKeyFromDuplicateError
public function getKeyFromDuplicateError($error) { if (! isset($error[2])) { return false; } // Extract duplicate key and run update using it $matches = []; if (preg_match('/.*DETAIL:\s*Key (.*)=.*/sim', $error[2], $matches)) { // Index 1 holds the name of the key matched $key = trim($matches[1], '()'); echo sprintf('Duplicate record, running update using "%s"...%s', $key, PHP_EOL); return $key; } return false; }
php
public function getKeyFromDuplicateError($error) { if (! isset($error[2])) { return false; } // Extract duplicate key and run update using it $matches = []; if (preg_match('/.*DETAIL:\s*Key (.*)=.*/sim', $error[2], $matches)) { // Index 1 holds the name of the key matched $key = trim($matches[1], '()'); echo sprintf('Duplicate record, running update using "%s"...%s', $key, PHP_EOL); return $key; } return false; }
[ "public", "function", "getKeyFromDuplicateError", "(", "$", "error", ")", "{", "if", "(", "!", "isset", "(", "$", "error", "[", "2", "]", ")", ")", "{", "return", "false", ";", "}", "// Extract duplicate key and run update using it", "$", "matches", "=", "["...
Get the duplicate key from the error message.
[ "Get", "the", "duplicate", "key", "from", "the", "error", "message", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L490-L508
train
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.setLastIdWhere
protected function setLastIdWhere($entity, $criteria) { $sql = sprintf('SELECT id FROM %s WHERE %s', $entity, $criteria); $statement = $this->execute($sql); $this->throwErrorIfNoRowsAffected($statement); $result = $statement->fetchAll(); if (! isset($result[0]['id'])) { throw new \Exception('Id not found in table.'); } $this->debugLog(sprintf('Last ID fetched: %d', $result[0]['id'])); $this->handleLastId($entity, $result[0]['id']); return $statement; }
php
protected function setLastIdWhere($entity, $criteria) { $sql = sprintf('SELECT id FROM %s WHERE %s', $entity, $criteria); $statement = $this->execute($sql); $this->throwErrorIfNoRowsAffected($statement); $result = $statement->fetchAll(); if (! isset($result[0]['id'])) { throw new \Exception('Id not found in table.'); } $this->debugLog(sprintf('Last ID fetched: %d', $result[0]['id'])); $this->handleLastId($entity, $result[0]['id']); return $statement; }
[ "protected", "function", "setLastIdWhere", "(", "$", "entity", ",", "$", "criteria", ")", "{", "$", "sql", "=", "sprintf", "(", "'SELECT id FROM %s WHERE %s'", ",", "$", "entity", ",", "$", "criteria", ")", ";", "$", "statement", "=", "$", "this", "->", ...
Sets the last id by executing a select on the id column.
[ "Sets", "the", "last", "id", "by", "executing", "a", "select", "on", "the", "id", "column", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L513-L528
train
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.handleLastId
protected function handleLastId($entity, $id) { $entity = $this->getUserInputEntity($entity); $this->lastId = $id; $entity = $this->makeSQLUnsafe($entity); $this->saveLastId($entity, $this->lastId); $this->setKeyword($entity . '_id', $this->lastId); }
php
protected function handleLastId($entity, $id) { $entity = $this->getUserInputEntity($entity); $this->lastId = $id; $entity = $this->makeSQLUnsafe($entity); $this->saveLastId($entity, $this->lastId); $this->setKeyword($entity . '_id', $this->lastId); }
[ "protected", "function", "handleLastId", "(", "$", "entity", ",", "$", "id", ")", "{", "$", "entity", "=", "$", "this", "->", "getUserInputEntity", "(", "$", "entity", ")", ";", "$", "this", "->", "lastId", "=", "$", "id", ";", "$", "entity", "=", ...
Do what needs to be done with the last insert id.
[ "Do", "what", "needs", "to", "be", "done", "with", "the", "last", "insert", "id", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L533-L540
train
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.getUserInputEntity
private function getUserInputEntity($entity) { // Get rid of any special chars introduced. $entity = $this->makeSQLUnsafe($entity); // Only replace first occurrence. return preg_replace('/' . $this->getParams()['DBPREFIX'] . '/', '', $entity, 1); }
php
private function getUserInputEntity($entity) { // Get rid of any special chars introduced. $entity = $this->makeSQLUnsafe($entity); // Only replace first occurrence. return preg_replace('/' . $this->getParams()['DBPREFIX'] . '/', '', $entity, 1); }
[ "private", "function", "getUserInputEntity", "(", "$", "entity", ")", "{", "// Get rid of any special chars introduced.", "$", "entity", "=", "$", "this", "->", "makeSQLUnsafe", "(", "$", "entity", ")", ";", "// Only replace first occurrence.", "return", "preg_replace",...
Get the entity the way the user had inputted it.
[ "Get", "the", "entity", "the", "way", "the", "user", "had", "inputted", "it", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L545-L552
train
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.isNotQuotable
private function isNotQuotable($val) { $keywords = [ 'true', 'false', 'null', 'NOW\(\)', 'COUNT\(.*\)', 'MAX\(.*\)', '\d+' ]; $keywords = array_merge($keywords, $_SESSION['behat']['GenesisSqlExtension']['notQuotableKeywords']); // Check if the val is a keyword foreach ($keywords as $keyword) { if (preg_match(sprintf('/^%s$/is', $keyword), $val)) { return true; } } return false; }
php
private function isNotQuotable($val) { $keywords = [ 'true', 'false', 'null', 'NOW\(\)', 'COUNT\(.*\)', 'MAX\(.*\)', '\d+' ]; $keywords = array_merge($keywords, $_SESSION['behat']['GenesisSqlExtension']['notQuotableKeywords']); // Check if the val is a keyword foreach ($keywords as $keyword) { if (preg_match(sprintf('/^%s$/is', $keyword), $val)) { return true; } } return false; }
[ "private", "function", "isNotQuotable", "(", "$", "val", ")", "{", "$", "keywords", "=", "[", "'true'", ",", "'false'", ",", "'null'", ",", "'NOW\\(\\)'", ",", "'COUNT\\(.*\\)'", ",", "'MAX\\(.*\\)'", ",", "'\\d+'", "]", ";", "$", "keywords", "=", "array_m...
Checks if the value isn't a keyword.
[ "Checks", "if", "the", "value", "isn", "t", "a", "keyword", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L557-L579
train
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.makeSQLSafe
public function makeSQLSafe($string) { $string = str_replace('', '', $string); $chunks = explode('.', $string); return implode('.', $chunks); }
php
public function makeSQLSafe($string) { $string = str_replace('', '', $string); $chunks = explode('.', $string); return implode('.', $chunks); }
[ "public", "function", "makeSQLSafe", "(", "$", "string", ")", "{", "$", "string", "=", "str_replace", "(", "''", ",", "''", ",", "$", "string", ")", ";", "$", "chunks", "=", "explode", "(", "'.'", ",", "$", "string", ")", ";", "return", "implode", ...
Make a string SQL safe.
[ "Make", "a", "string", "SQL", "safe", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L657-L664
train
forceedge01/behat-sql-extension
src/Context/SQLHandler.php
SQLHandler.setEntity
public function setEntity($entity) { $this->debugLog(sprintf('ENTITY: %s', $entity)); $expectedEntity = $this->makeSQLSafe($this->getParams()['DBPREFIX'] . $entity); $this->debugLog(sprintf('SET ENTITY: %s', $expectedEntity)); // Concatinate the entity with the sqldbprefix value only if not already done. if ($expectedEntity !== $this->entity) { $this->entity = $expectedEntity; } return $this; }
php
public function setEntity($entity) { $this->debugLog(sprintf('ENTITY: %s', $entity)); $expectedEntity = $this->makeSQLSafe($this->getParams()['DBPREFIX'] . $entity); $this->debugLog(sprintf('SET ENTITY: %s', $expectedEntity)); // Concatinate the entity with the sqldbprefix value only if not already done. if ($expectedEntity !== $this->entity) { $this->entity = $expectedEntity; } return $this; }
[ "public", "function", "setEntity", "(", "$", "entity", ")", "{", "$", "this", "->", "debugLog", "(", "sprintf", "(", "'ENTITY: %s'", ",", "$", "entity", ")", ")", ";", "$", "expectedEntity", "=", "$", "this", "->", "makeSQLSafe", "(", "$", "this", "->"...
Set the entity for further processing.
[ "Set", "the", "entity", "for", "further", "processing", "." ]
ce2b1ea9927ff2a65bf18bd3e757246188976d69
https://github.com/forceedge01/behat-sql-extension/blob/ce2b1ea9927ff2a65bf18bd3e757246188976d69/src/Context/SQLHandler.php#L677-L691
train
tarsana/command
src/Template/TemplateLoader.php
TemplateLoader.load
public function load (string $name) : TemplateInterface { $supportedExtensions = array_keys(self::$providers); $fsPathLength = strlen($this->fs->path()); $files = $this->fs ->find("{$name}.*") ->files() ->asArray(); $found = []; foreach ($files as $file) { $ext = $file->extension(); if (!in_array($ext, $supportedExtensions)) continue; $found[] = [ 'name' => substr($file->path(), $fsPathLength), 'extension' => $ext ]; } if (count($found) == 0) { throw new \InvalidArgumentException("Unable to find template with name '{$name}' on '{$this->fs->path()}'"); } if (count($found) > 1) { throw new \InvalidArgumentException("Mutiple templates found for the name '{$name}' on '{$this->fs->path()}'"); } return $this->loaders[$found[0]['extension']]->load($found[0]['name']); }
php
public function load (string $name) : TemplateInterface { $supportedExtensions = array_keys(self::$providers); $fsPathLength = strlen($this->fs->path()); $files = $this->fs ->find("{$name}.*") ->files() ->asArray(); $found = []; foreach ($files as $file) { $ext = $file->extension(); if (!in_array($ext, $supportedExtensions)) continue; $found[] = [ 'name' => substr($file->path(), $fsPathLength), 'extension' => $ext ]; } if (count($found) == 0) { throw new \InvalidArgumentException("Unable to find template with name '{$name}' on '{$this->fs->path()}'"); } if (count($found) > 1) { throw new \InvalidArgumentException("Mutiple templates found for the name '{$name}' on '{$this->fs->path()}'"); } return $this->loaders[$found[0]['extension']]->load($found[0]['name']); }
[ "public", "function", "load", "(", "string", "$", "name", ")", ":", "TemplateInterface", "{", "$", "supportedExtensions", "=", "array_keys", "(", "self", "::", "$", "providers", ")", ";", "$", "fsPathLength", "=", "strlen", "(", "$", "this", "->", "fs", ...
Load a template by name. The name is the relative path of the template file from the templates folder The name is given without extension; Exceptions are thrown if no file with supported extension is found or if many exists. @param string $name @return Tarsana\Command\Interfaces\TemplateInterface @throws Tarsana\Command\Exceptions\TemplateNotFound @throws Tarsana\Command\Exceptions\TemplateNameConflict
[ "Load", "a", "template", "by", "name", ".", "The", "name", "is", "the", "relative", "path", "of", "the", "template", "file", "from", "the", "templates", "folder", "The", "name", "is", "given", "without", "extension", ";", "Exceptions", "are", "thrown", "if...
d439b949140c226a0cc5a30f72fbbe25570b9871
https://github.com/tarsana/command/blob/d439b949140c226a0cc5a30f72fbbe25570b9871/src/Template/TemplateLoader.php#L77-L108
train
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.delete
public function delete(string $path, $callback, ...$args): FrameworkHandler { return $this->route('delete', $path, $callback, ...$args); }
php
public function delete(string $path, $callback, ...$args): FrameworkHandler { return $this->route('delete', $path, $callback, ...$args); }
[ "public", "function", "delete", "(", "string", "$", "path", ",", "$", "callback", ",", "...", "$", "args", ")", ":", "FrameworkHandler", "{", "return", "$", "this", "->", "route", "(", "'delete'", ",", "$", "path", ",", "$", "callback", ",", "...", "...
Adds routing middleware for DELETE method @param *string $path The route path @param *callable|string $callback The middleware handler @param callable|string ...$args Arguments for flow @return FrameworkHandler
[ "Adds", "routing", "middleware", "for", "DELETE", "method" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L101-L104
train
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.get
public function get(string $path, $callback, ...$args): FrameworkHandler { return $this->route('get', $path, $callback, ...$args); }
php
public function get(string $path, $callback, ...$args): FrameworkHandler { return $this->route('get', $path, $callback, ...$args); }
[ "public", "function", "get", "(", "string", "$", "path", ",", "$", "callback", ",", "...", "$", "args", ")", ":", "FrameworkHandler", "{", "return", "$", "this", "->", "route", "(", "'get'", ",", "$", "path", ",", "$", "callback", ",", "...", "$", ...
Adds routing middleware for GET method @param *string $path The route path @param *callable|string $callback The middleware handler @param callable|string ...$args Arguments for flow @return FrameworkHandler
[ "Adds", "routing", "middleware", "for", "GET", "method" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L115-L118
train
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.getPackages
public function getPackages(string $name = null): array { if (isset($this->packages[$name])) { return $this->packages[$name]; } return $this->packages; }
php
public function getPackages(string $name = null): array { if (isset($this->packages[$name])) { return $this->packages[$name]; } return $this->packages; }
[ "public", "function", "getPackages", "(", "string", "$", "name", "=", "null", ")", ":", "array", "{", "if", "(", "isset", "(", "$", "this", "->", "packages", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "packages", "[", "$", ...
Returns all the packages @param string|null $name Name of package @return array
[ "Returns", "all", "the", "packages" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L127-L134
train
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.export
public function export(string $event, bool $map = false) { $handler = $this; $next = function (...$args) use ($handler, $event, $map) { $request = $handler->getRequest(); $response = $handler->getResponse(); $meta = $handler //do this directly from the handler ->getEventHandler() //trigger ->trigger($event, $request, $response, ...$args) //if our events returns false //lets tell the interface the same ->getMeta(); //no map ? let's try our best //if we have meta if ($meta === EventHandler::STATUS_OK) { //return the response return $response->getContent(true); } //otherwise return false return false; }; if (!$map) { return $next; } $request = $handler->getRequest(); $response = $handler->getResponse(); return [$request, $response, $next]; }
php
public function export(string $event, bool $map = false) { $handler = $this; $next = function (...$args) use ($handler, $event, $map) { $request = $handler->getRequest(); $response = $handler->getResponse(); $meta = $handler //do this directly from the handler ->getEventHandler() //trigger ->trigger($event, $request, $response, ...$args) //if our events returns false //lets tell the interface the same ->getMeta(); //no map ? let's try our best //if we have meta if ($meta === EventHandler::STATUS_OK) { //return the response return $response->getContent(true); } //otherwise return false return false; }; if (!$map) { return $next; } $request = $handler->getRequest(); $response = $handler->getResponse(); return [$request, $response, $next]; }
[ "public", "function", "export", "(", "string", "$", "event", ",", "bool", "$", "map", "=", "false", ")", "{", "$", "handler", "=", "$", "this", ";", "$", "next", "=", "function", "(", "...", "$", "args", ")", "use", "(", "$", "handler", ",", "$",...
Exports a flow to another external interface @param *string $event @param bool $map @return Closure|array
[ "Exports", "a", "flow", "to", "another", "external", "interface" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L154-L190
train
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.import
public function import(array $flows): FrameworkHandler { foreach ($flows as $flow) { //it's gotta be an array if (!is_array($flow)) { continue; } $this->flow(...$flow); } return $this; }
php
public function import(array $flows): FrameworkHandler { foreach ($flows as $flow) { //it's gotta be an array if (!is_array($flow)) { continue; } $this->flow(...$flow); } return $this; }
[ "public", "function", "import", "(", "array", "$", "flows", ")", ":", "FrameworkHandler", "{", "foreach", "(", "$", "flows", "as", "$", "flow", ")", "{", "//it's gotta be an array", "if", "(", "!", "is_array", "(", "$", "flow", ")", ")", "{", "continue",...
Imports a set of flows @param *array $flows @return FrameworkHandler
[ "Imports", "a", "set", "of", "flows" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L199-L211
train
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.makePayload
public function makePayload($load = true) { $request = Request::i(); $response = Response::i(); if ($load) { $request->load(); $response->load(); $stage = $this->getRequest()->getStage(); if (is_array($stage)) { $request->setSoftStage($stage); } } return [ 'request' => $request, 'response' => $response ]; }
php
public function makePayload($load = true) { $request = Request::i(); $response = Response::i(); if ($load) { $request->load(); $response->load(); $stage = $this->getRequest()->getStage(); if (is_array($stage)) { $request->setSoftStage($stage); } } return [ 'request' => $request, 'response' => $response ]; }
[ "public", "function", "makePayload", "(", "$", "load", "=", "true", ")", "{", "$", "request", "=", "Request", "::", "i", "(", ")", ";", "$", "response", "=", "Response", "::", "i", "(", ")", ";", "if", "(", "$", "load", ")", "{", "$", "request", ...
Creates a new Request and Response @param bool $load whether to load the RnRs @return array
[ "Creates", "a", "new", "Request", "and", "Response" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L220-L240
train
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.method
public function method($event, $request = [], Response $response = null) { if (is_array($request)) { $request = Request::i()->load()->setStage($request); } if (!($request instanceof Request)) { $request = Request::i()->load(); } if (is_null($response)) { $response = Response::i()->load(); } $this->trigger($event, $request, $response); if ($response->isError()) { return false; } return $response->getResults(); }
php
public function method($event, $request = [], Response $response = null) { if (is_array($request)) { $request = Request::i()->load()->setStage($request); } if (!($request instanceof Request)) { $request = Request::i()->load(); } if (is_null($response)) { $response = Response::i()->load(); } $this->trigger($event, $request, $response); if ($response->isError()) { return false; } return $response->getResults(); }
[ "public", "function", "method", "(", "$", "event", ",", "$", "request", "=", "[", "]", ",", "Response", "$", "response", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "request", ")", ")", "{", "$", "request", "=", "Request", "::", "i", ...
Runs an event like a method @param bool $load whether to load the RnRs @return array
[ "Runs", "an", "event", "like", "a", "method" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L249-L270
train
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.post
public function post(string $path, $callback, ...$args): FrameworkHandler { return $this->route('post', $path, $callback, ...$args); }
php
public function post(string $path, $callback, ...$args): FrameworkHandler { return $this->route('post', $path, $callback, ...$args); }
[ "public", "function", "post", "(", "string", "$", "path", ",", "$", "callback", ",", "...", "$", "args", ")", ":", "FrameworkHandler", "{", "return", "$", "this", "->", "route", "(", "'post'", ",", "$", "path", ",", "$", "callback", ",", "...", "$", ...
Adds routing middleware for POST method @param *string $path The route path @param *callable|string $callback The middleware handler @param callable|string ...$args Arguments for flow @return FrameworkHandler
[ "Adds", "routing", "middleware", "for", "POST", "method" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L281-L284
train
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.put
public function put(string $path, $callback, ...$args): FrameworkHandler { return $this->route('put', $path, $callback, ...$args); }
php
public function put(string $path, $callback, ...$args): FrameworkHandler { return $this->route('put', $path, $callback, ...$args); }
[ "public", "function", "put", "(", "string", "$", "path", ",", "$", "callback", ",", "...", "$", "args", ")", ":", "FrameworkHandler", "{", "return", "$", "this", "->", "route", "(", "'put'", ",", "$", "path", ",", "$", "callback", ",", "...", "$", ...
Adds routing middleware for PUT method @param *string $path The route path @param *callable|string $callback The middleware handler @param callable|string ...$args Arguments for flow @return FrameworkHandler
[ "Adds", "routing", "middleware", "for", "PUT", "method" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L295-L298
train
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.register
public function register($vendor): FrameworkHandler { //if it's callable if (is_callable($vendor)) { //it's not a package //it's a preprocess return $this->preprocess($vendor); } return $this->registerPackage($vendor); }
php
public function register($vendor): FrameworkHandler { //if it's callable if (is_callable($vendor)) { //it's not a package //it's a preprocess return $this->preprocess($vendor); } return $this->registerPackage($vendor); }
[ "public", "function", "register", "(", "$", "vendor", ")", ":", "FrameworkHandler", "{", "//if it's callable", "if", "(", "is_callable", "(", "$", "vendor", ")", ")", "{", "//it's not a package", "//it's a preprocess", "return", "$", "this", "->", "preprocess", ...
Registers and initializes a package @param *string|callable $vendor The vendor/package name @return FrameworkHandler
[ "Registers", "and", "initializes", "a", "package" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L307-L317
train
CradlePHP/framework
src/FrameworkHandler.php
FrameworkHandler.handler
public function handler(string $root, FrameworkHandler $handler = null): FrameworkHandler { //if we have this handler in memory if (isset($this->handlers[$root])) { //if a handler was provided if ($handler instanceof FrameworkHandler) { //we mean to change up the handler $this->handlers[$root] = $handler; } //either way return the handler return $this->handlers[$root]; } //otherwise the handler is not in memory if (!($handler instanceof FrameworkHandler)) { // By default // - Routes are unique per Handler. // - Middleware are unique per Handler. // - Child pre processors aren't triggered. // - Child post processors aren't triggered. // - Child error processors are set by Parent. // - Child protocols are set by Parent. // - Child packages are set by Parent. // - Child requests are set by Parent. // - Child responses are set by Parent. // - Events are still global. $handler = FrameworkHandler::i()->setParent($this); } //remember the handler $this->handlers[$root] = $handler; //since this is out first time with this, //lets have the parent listen to the root and all possible $this->all($root . '**', function ($request, $response) use ($root) { //we need the original path $path = $request->getPath('string'); //determine the sub route $route = substr($path, strlen($root)); //because substr('/', 1); --> false if (!is_string($route) || !strlen($route)) { $route = '/'; } //set up the sub rout in request $request->setPath($route); //we want to lazy load this in because it is //possible that the hander could have changed $this->handler($root) ->setRequest($request) ->setResponse($response) ->process(); //bring the path back $request->setPath($path); }); return $this->handlers[$root]; }
php
public function handler(string $root, FrameworkHandler $handler = null): FrameworkHandler { //if we have this handler in memory if (isset($this->handlers[$root])) { //if a handler was provided if ($handler instanceof FrameworkHandler) { //we mean to change up the handler $this->handlers[$root] = $handler; } //either way return the handler return $this->handlers[$root]; } //otherwise the handler is not in memory if (!($handler instanceof FrameworkHandler)) { // By default // - Routes are unique per Handler. // - Middleware are unique per Handler. // - Child pre processors aren't triggered. // - Child post processors aren't triggered. // - Child error processors are set by Parent. // - Child protocols are set by Parent. // - Child packages are set by Parent. // - Child requests are set by Parent. // - Child responses are set by Parent. // - Events are still global. $handler = FrameworkHandler::i()->setParent($this); } //remember the handler $this->handlers[$root] = $handler; //since this is out first time with this, //lets have the parent listen to the root and all possible $this->all($root . '**', function ($request, $response) use ($root) { //we need the original path $path = $request->getPath('string'); //determine the sub route $route = substr($path, strlen($root)); //because substr('/', 1); --> false if (!is_string($route) || !strlen($route)) { $route = '/'; } //set up the sub rout in request $request->setPath($route); //we want to lazy load this in because it is //possible that the hander could have changed $this->handler($root) ->setRequest($request) ->setResponse($response) ->process(); //bring the path back $request->setPath($path); }); return $this->handlers[$root]; }
[ "public", "function", "handler", "(", "string", "$", "root", ",", "FrameworkHandler", "$", "handler", "=", "null", ")", ":", "FrameworkHandler", "{", "//if we have this handler in memory", "if", "(", "isset", "(", "$", "this", "->", "handlers", "[", "$", "root...
Sets up a sub handler given the path. @param *string $root The root path to handle @param FrameworkHandler|null $handler the child handler @return FrameworkHandler
[ "Sets", "up", "a", "sub", "handler", "given", "the", "path", "." ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/FrameworkHandler.php#L373-L434
train
CradlePHP/framework
src/CommandLine.php
CommandLine.setMap
public static function setMap($map = null) { if (is_null(self::$map)) { self::$map = include(__DIR__ . '/CommandLine/map.php'); } if (!is_null($map)) { self::$map = $map; } }
php
public static function setMap($map = null) { if (is_null(self::$map)) { self::$map = include(__DIR__ . '/CommandLine/map.php'); } if (!is_null($map)) { self::$map = $map; } }
[ "public", "static", "function", "setMap", "(", "$", "map", "=", "null", ")", "{", "if", "(", "is_null", "(", "self", "::", "$", "map", ")", ")", "{", "self", "::", "$", "map", "=", "include", "(", "__DIR__", ".", "'/CommandLine/map.php'", ")", ";", ...
Setups the output map @param string|null $map
[ "Setups", "the", "output", "map" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/CommandLine.php#L316-L325
train
CradlePHP/framework
src/Package.php
Package.addMethod
public function addMethod(string $name, Closure $callback): Package { $this->methods[$name] = $callback->bindTo($this, get_class($this)); return $this; }
php
public function addMethod(string $name, Closure $callback): Package { $this->methods[$name] = $callback->bindTo($this, get_class($this)); return $this; }
[ "public", "function", "addMethod", "(", "string", "$", "name", ",", "Closure", "$", "callback", ")", ":", "Package", "{", "$", "this", "->", "methods", "[", "$", "name", "]", "=", "$", "callback", "->", "bindTo", "(", "$", "this", ",", "get_class", "...
Registers a method to be used @param *string $name The class route name @param *Closure $callback The callback handler @return Package
[ "Registers", "a", "method", "to", "be", "used" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/Package.php#L96-L101
train
CradlePHP/framework
src/Package.php
Package.getPackagePath
public function getPackagePath() { $type = $this->getPackageType(); if ($type === self::TYPE_PSEUDO) { return false; } $root = $this->getPackageRoot(); //the vendor name also represents the path $path = $this->name; //if it's a root package if ($type === self::TYPE_ROOT) { $path = substr($path, 1); } return $root . '/' . $path; }
php
public function getPackagePath() { $type = $this->getPackageType(); if ($type === self::TYPE_PSEUDO) { return false; } $root = $this->getPackageRoot(); //the vendor name also represents the path $path = $this->name; //if it's a root package if ($type === self::TYPE_ROOT) { $path = substr($path, 1); } return $root . '/' . $path; }
[ "public", "function", "getPackagePath", "(", ")", "{", "$", "type", "=", "$", "this", "->", "getPackageType", "(", ")", ";", "if", "(", "$", "type", "===", "self", "::", "TYPE_PSEUDO", ")", "{", "return", "false", ";", "}", "$", "root", "=", "$", "...
Returns the path of the project @return string|false
[ "Returns", "the", "path", "of", "the", "project" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/Package.php#L108-L126
train
CradlePHP/framework
src/Package.php
Package.getPackageRoot
public function getPackageRoot() { $type = $this->getPackageType(); if ($type === self::TYPE_PSEUDO) { return false; } if (is_string($this->packageRoot)) { return $this->packageRoot; } //determine where it is located //luckily we know where we are in vendor folder :) //is there a better recommended way? $root = __DIR__ . '/../../..'; //HAX using the composer package to get the root of the vendor folder //is there a better recommended way? if (class_exists(SpdxLicenses::class) && method_exists(SpdxLicenses::class, 'getResourcesDir') && realpath(SpdxLicenses::getResourcesDir() . '/../../..') ) { $root = realpath(SpdxLicenses::getResourcesDir() . '/../../..'); } //if it's a root package if ($type === self::TYPE_ROOT) { $root .= '/..'; } $this->packageRoot = realpath($root); return $this->packageRoot; }
php
public function getPackageRoot() { $type = $this->getPackageType(); if ($type === self::TYPE_PSEUDO) { return false; } if (is_string($this->packageRoot)) { return $this->packageRoot; } //determine where it is located //luckily we know where we are in vendor folder :) //is there a better recommended way? $root = __DIR__ . '/../../..'; //HAX using the composer package to get the root of the vendor folder //is there a better recommended way? if (class_exists(SpdxLicenses::class) && method_exists(SpdxLicenses::class, 'getResourcesDir') && realpath(SpdxLicenses::getResourcesDir() . '/../../..') ) { $root = realpath(SpdxLicenses::getResourcesDir() . '/../../..'); } //if it's a root package if ($type === self::TYPE_ROOT) { $root .= '/..'; } $this->packageRoot = realpath($root); return $this->packageRoot; }
[ "public", "function", "getPackageRoot", "(", ")", "{", "$", "type", "=", "$", "this", "->", "getPackageType", "(", ")", ";", "if", "(", "$", "type", "===", "self", "::", "TYPE_PSEUDO", ")", "{", "return", "false", ";", "}", "if", "(", "is_string", "(...
Returns the root path of the project @return string|false
[ "Returns", "the", "root", "path", "of", "the", "project" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/Package.php#L133-L166
train
CradlePHP/framework
src/Package.php
Package.getPackageType
public function getPackageType(): string { //if it starts with / like /foo/bar if (strpos($this->name, '/') === 0) { //it's a root package return self::TYPE_ROOT; } //if theres a slash like foo/bar if (strpos($this->name, '/') !== false) { //it's vendor package return self::TYPE_VENDOR; } //by default it's a pseudo package return self::TYPE_PSEUDO; }
php
public function getPackageType(): string { //if it starts with / like /foo/bar if (strpos($this->name, '/') === 0) { //it's a root package return self::TYPE_ROOT; } //if theres a slash like foo/bar if (strpos($this->name, '/') !== false) { //it's vendor package return self::TYPE_VENDOR; } //by default it's a pseudo package return self::TYPE_PSEUDO; }
[ "public", "function", "getPackageType", "(", ")", ":", "string", "{", "//if it starts with / like /foo/bar", "if", "(", "strpos", "(", "$", "this", "->", "name", ",", "'/'", ")", "===", "0", ")", "{", "//it's a root package", "return", "self", "::", "TYPE_ROOT...
Returns the package type @return string
[ "Returns", "the", "package", "type" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/Package.php#L173-L189
train
CradlePHP/framework
src/PackageTrait.php
PackageTrait.package
public function package(string $vendor) { if (!array_key_exists($vendor, $this->packages)) { throw Exception::forPackageNotFound($vendor); } return $this->packages[$vendor]; }
php
public function package(string $vendor) { if (!array_key_exists($vendor, $this->packages)) { throw Exception::forPackageNotFound($vendor); } return $this->packages[$vendor]; }
[ "public", "function", "package", "(", "string", "$", "vendor", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "vendor", ",", "$", "this", "->", "packages", ")", ")", "{", "throw", "Exception", "::", "forPackageNotFound", "(", "$", "vendor", ")",...
Returns a package space @param *string $vendor The vendor/package name @return PackageTrait
[ "Returns", "a", "package", "space" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/PackageTrait.php#L62-L69
train
CradlePHP/framework
src/PackageTrait.php
PackageTrait.register
public function register(string $vendor, ...$args) { //determine class if (method_exists($this, 'resolve')) { $this->packages[$vendor] = $this->resolve(Package::class, $vendor); // @codeCoverageIgnoreStart } else { $this->packages[$vendor] = new Package($vendor); } // @codeCoverageIgnoreEnd //if the type is not pseudo (vendor or root) if ($this->packages[$vendor]->getPackageType() !== Package::TYPE_PSEUDO) { //let's try to call the bootstrap $cradle = $this; //we should check for events $file = $this->packages[$vendor]->getPackagePath() . '/' . $this->bootstrapFile; // @codeCoverageIgnoreStart if (file_exists($file)) { //so you can access cradle //within the included file include_once($file); } else if (file_exists($file . '.php')) { //so the IDE can have color include_once($file . '.php'); } // @codeCoverageIgnoreEnd } return $this; }
php
public function register(string $vendor, ...$args) { //determine class if (method_exists($this, 'resolve')) { $this->packages[$vendor] = $this->resolve(Package::class, $vendor); // @codeCoverageIgnoreStart } else { $this->packages[$vendor] = new Package($vendor); } // @codeCoverageIgnoreEnd //if the type is not pseudo (vendor or root) if ($this->packages[$vendor]->getPackageType() !== Package::TYPE_PSEUDO) { //let's try to call the bootstrap $cradle = $this; //we should check for events $file = $this->packages[$vendor]->getPackagePath() . '/' . $this->bootstrapFile; // @codeCoverageIgnoreStart if (file_exists($file)) { //so you can access cradle //within the included file include_once($file); } else if (file_exists($file . '.php')) { //so the IDE can have color include_once($file . '.php'); } // @codeCoverageIgnoreEnd } return $this; }
[ "public", "function", "register", "(", "string", "$", "vendor", ",", "...", "$", "args", ")", "{", "//determine class", "if", "(", "method_exists", "(", "$", "this", ",", "'resolve'", ")", ")", "{", "$", "this", "->", "packages", "[", "$", "vendor", "]...
Registers and initializes a plugin @param *string $vendor The vendor/package name @param mixed ...$args @return PackageTrait
[ "Registers", "and", "initializes", "a", "plugin" ]
e8da3103e17880f4d31246d5c202ca64a64b8dc4
https://github.com/CradlePHP/framework/blob/e8da3103e17880f4d31246d5c202ca64a64b8dc4/src/PackageTrait.php#L79-L111
train
TerranetMD/localizer
src/Terranet/Localizer/Provider.php
Provider.find
public function find($locale) { if (null === static::$language) { foreach ($this->fetchAll() as $item) { if ($item->locale() == $locale || $item->iso6391() == $locale) { static::$language = $item; break; } } } return static::$language; }
php
public function find($locale) { if (null === static::$language) { foreach ($this->fetchAll() as $item) { if ($item->locale() == $locale || $item->iso6391() == $locale) { static::$language = $item; break; } } } return static::$language; }
[ "public", "function", "find", "(", "$", "locale", ")", "{", "if", "(", "null", "===", "static", "::", "$", "language", ")", "{", "foreach", "(", "$", "this", "->", "fetchAll", "(", ")", "as", "$", "item", ")", "{", "if", "(", "$", "item", "->", ...
Find language by locale @param $locale @return mixed
[ "Find", "language", "by", "locale" ]
63ae70653e21caa39a2d518e6e5c23bc1a413acc
https://github.com/TerranetMD/localizer/blob/63ae70653e21caa39a2d518e6e5c23bc1a413acc/src/Terranet/Localizer/Provider.php#L57-L69
train
TerranetMD/localizer
src/Terranet/Localizer/Provider.php
Provider.fetchAll
public function fetchAll() { if (static::$languages === null) { static::$languages = $this->driver()->fetchAll(); static::$languages = array_map(function ($language) { return new Locale($language); }, static::$languages); } return static::$languages; }
php
public function fetchAll() { if (static::$languages === null) { static::$languages = $this->driver()->fetchAll(); static::$languages = array_map(function ($language) { return new Locale($language); }, static::$languages); } return static::$languages; }
[ "public", "function", "fetchAll", "(", ")", "{", "if", "(", "static", "::", "$", "languages", "===", "null", ")", "{", "static", "::", "$", "languages", "=", "$", "this", "->", "driver", "(", ")", "->", "fetchAll", "(", ")", ";", "static", "::", "$...
Fetch all active languages @return mixed
[ "Fetch", "all", "active", "languages" ]
63ae70653e21caa39a2d518e6e5c23bc1a413acc
https://github.com/TerranetMD/localizer/blob/63ae70653e21caa39a2d518e6e5c23bc1a413acc/src/Terranet/Localizer/Provider.php#L76-L87
train
TerranetMD/localizer
src/Terranet/Localizer/Resolvers/RequestResolver.php
RequestResolver.resolveHeader
private function resolveHeader() { if (null === static::$languages) { $httpLanguages = $this->request->server(config('localizer.request.header', 'HTTP_ACCEPT_LANGUAGE')); if (empty($httpLanguages)) { static::$languages = []; } else { $accepted = preg_split('/,\s*/', $httpLanguages); static::$languages = empty($languages = $this->buildCollection($accepted, $languages = [])) ? null : array_keys($languages)[0]; } } return static::$languages; }
php
private function resolveHeader() { if (null === static::$languages) { $httpLanguages = $this->request->server(config('localizer.request.header', 'HTTP_ACCEPT_LANGUAGE')); if (empty($httpLanguages)) { static::$languages = []; } else { $accepted = preg_split('/,\s*/', $httpLanguages); static::$languages = empty($languages = $this->buildCollection($accepted, $languages = [])) ? null : array_keys($languages)[0]; } } return static::$languages; }
[ "private", "function", "resolveHeader", "(", ")", "{", "if", "(", "null", "===", "static", "::", "$", "languages", ")", "{", "$", "httpLanguages", "=", "$", "this", "->", "request", "->", "server", "(", "config", "(", "'localizer.request.header'", ",", "'H...
Resolve language using HTTP_ACCEPT_LANGUAGE header which is used mostly by API requests @return array|null
[ "Resolve", "language", "using", "HTTP_ACCEPT_LANGUAGE", "header", "which", "is", "used", "mostly", "by", "API", "requests" ]
63ae70653e21caa39a2d518e6e5c23bc1a413acc
https://github.com/TerranetMD/localizer/blob/63ae70653e21caa39a2d518e6e5c23bc1a413acc/src/Terranet/Localizer/Resolvers/RequestResolver.php#L52-L69
train
TerranetMD/localizer
src/Terranet/Localizer/Resolvers/RequestResolver.php
RequestResolver.assemble
public function assemble($iso, $url = null) { $url = rtrim($url, '/'); $locales = locales()->map->iso6391()->all(); $default = getDefault()->iso6391(); foreach ($locales as $locale) { # handle urls that contains language in request uri: /en | /en/profile # skip urls that starts with string equals with one of locales: /english if (starts_with($url, "/{$locale}/") || "/{$locale}" === $url) { return url(preg_replace( '~^\/' . $locale . '~si', $iso === $default ? "" : "/{$iso}", $url )); } } # prepend url with $iso return url( ($iso === $default ? "" : $iso . '/') . ltrim($url, '/') ); }
php
public function assemble($iso, $url = null) { $url = rtrim($url, '/'); $locales = locales()->map->iso6391()->all(); $default = getDefault()->iso6391(); foreach ($locales as $locale) { # handle urls that contains language in request uri: /en | /en/profile # skip urls that starts with string equals with one of locales: /english if (starts_with($url, "/{$locale}/") || "/{$locale}" === $url) { return url(preg_replace( '~^\/' . $locale . '~si', $iso === $default ? "" : "/{$iso}", $url )); } } # prepend url with $iso return url( ($iso === $default ? "" : $iso . '/') . ltrim($url, '/') ); }
[ "public", "function", "assemble", "(", "$", "iso", ",", "$", "url", "=", "null", ")", "{", "$", "url", "=", "rtrim", "(", "$", "url", ",", "'/'", ")", ";", "$", "locales", "=", "locales", "(", ")", "->", "map", "->", "iso6391", "(", ")", "->", ...
Re-Assemble current url with different locale. @param $iso @param null $url @return mixed
[ "Re", "-", "Assemble", "current", "url", "with", "different", "locale", "." ]
63ae70653e21caa39a2d518e6e5c23bc1a413acc
https://github.com/TerranetMD/localizer/blob/63ae70653e21caa39a2d518e6e5c23bc1a413acc/src/Terranet/Localizer/Resolvers/RequestResolver.php#L121-L143
train
TerranetMD/localizer
src/Terranet/Localizer/Resolvers/DomainResolver.php
DomainResolver.resolve
public function resolve() { $httpHost = $this->request->getHttpHost(); $domains = explode('.', $httpHost); $level = config('localizer.domain.level', 3); return ($total = count($domains)) >= $level ? $domains[$total - $level] : null; }
php
public function resolve() { $httpHost = $this->request->getHttpHost(); $domains = explode('.', $httpHost); $level = config('localizer.domain.level', 3); return ($total = count($domains)) >= $level ? $domains[$total - $level] : null; }
[ "public", "function", "resolve", "(", ")", "{", "$", "httpHost", "=", "$", "this", "->", "request", "->", "getHttpHost", "(", ")", ";", "$", "domains", "=", "explode", "(", "'.'", ",", "$", "httpHost", ")", ";", "$", "level", "=", "config", "(", "'...
Resolve locale using domain name @return mixed
[ "Resolve", "locale", "using", "domain", "name" ]
63ae70653e21caa39a2d518e6e5c23bc1a413acc
https://github.com/TerranetMD/localizer/blob/63ae70653e21caa39a2d518e6e5c23bc1a413acc/src/Terranet/Localizer/Resolvers/DomainResolver.php#L31-L38
train
thujohn/rss-l4
src/Thujohn/Rss/SimpleXMLElement.php
SimpleXMLElement.setChildCdataValue
private function setChildCdataValue($value) { $domNode = dom_import_simplexml($this); $domNode->appendChild($domNode->ownerDocument->createCDATASection($value)); }
php
private function setChildCdataValue($value) { $domNode = dom_import_simplexml($this); $domNode->appendChild($domNode->ownerDocument->createCDATASection($value)); }
[ "private", "function", "setChildCdataValue", "(", "$", "value", ")", "{", "$", "domNode", "=", "dom_import_simplexml", "(", "$", "this", ")", ";", "$", "domNode", "->", "appendChild", "(", "$", "domNode", "->", "ownerDocument", "->", "createCDATASection", "(",...
Sets a cdata value for this child @param string $value The value to be enclosed in CDATA @return void
[ "Sets", "a", "cdata", "value", "for", "this", "child" ]
b65908ca63101b0f6bf53972b0245b0d0454d5ca
https://github.com/thujohn/rss-l4/blob/b65908ca63101b0f6bf53972b0245b0d0454d5ca/src/Thujohn/Rss/SimpleXMLElement.php#L49-L52
train
gravatarphp/gravatar
src/Gravatar.php
Gravatar.avatar
public function avatar(string $email, array $options = [], ?bool $secure = null, bool $validateOptions = false): string { $url = 'avatar/'.$this->createEmailHash($email); $options = array_merge($this->defaults, array_filter($options)); if ($validateOptions) { $this->validateOptions($options); } if (!empty($options)) { $url .= '?'.http_build_query($options); } return $this->buildUrl($url, $secure); }
php
public function avatar(string $email, array $options = [], ?bool $secure = null, bool $validateOptions = false): string { $url = 'avatar/'.$this->createEmailHash($email); $options = array_merge($this->defaults, array_filter($options)); if ($validateOptions) { $this->validateOptions($options); } if (!empty($options)) { $url .= '?'.http_build_query($options); } return $this->buildUrl($url, $secure); }
[ "public", "function", "avatar", "(", "string", "$", "email", ",", "array", "$", "options", "=", "[", "]", ",", "?", "bool", "$", "secure", "=", "null", ",", "bool", "$", "validateOptions", "=", "false", ")", ":", "string", "{", "$", "url", "=", "'a...
Returns an Avatar URL.
[ "Returns", "an", "Avatar", "URL", "." ]
54a5d48b4564ec9f1db8a498ad23d500ab83c063
https://github.com/gravatarphp/gravatar/blob/54a5d48b4564ec9f1db8a498ad23d500ab83c063/src/Gravatar.php#L83-L98
train
gravatarphp/gravatar
src/Gravatar.php
Gravatar.profile
public function profile(string $email, ?bool $secure = null): string { return $this->buildUrl($this->createEmailHash($email), $secure); }
php
public function profile(string $email, ?bool $secure = null): string { return $this->buildUrl($this->createEmailHash($email), $secure); }
[ "public", "function", "profile", "(", "string", "$", "email", ",", "?", "bool", "$", "secure", "=", "null", ")", ":", "string", "{", "return", "$", "this", "->", "buildUrl", "(", "$", "this", "->", "createEmailHash", "(", "$", "email", ")", ",", "$",...
Returns a profile URL.
[ "Returns", "a", "profile", "URL", "." ]
54a5d48b4564ec9f1db8a498ad23d500ab83c063
https://github.com/gravatarphp/gravatar/blob/54a5d48b4564ec9f1db8a498ad23d500ab83c063/src/Gravatar.php#L103-L106
train
gravatarphp/gravatar
src/Gravatar.php
Gravatar.vcard
public function vcard(string $email, ?bool $secure = null): string { return $this->profile($email, $secure).'.vcf'; }
php
public function vcard(string $email, ?bool $secure = null): string { return $this->profile($email, $secure).'.vcf'; }
[ "public", "function", "vcard", "(", "string", "$", "email", ",", "?", "bool", "$", "secure", "=", "null", ")", ":", "string", "{", "return", "$", "this", "->", "profile", "(", "$", "email", ",", "$", "secure", ")", ".", "'.vcf'", ";", "}" ]
Returns a vCard URL.
[ "Returns", "a", "vCard", "URL", "." ]
54a5d48b4564ec9f1db8a498ad23d500ab83c063
https://github.com/gravatarphp/gravatar/blob/54a5d48b4564ec9f1db8a498ad23d500ab83c063/src/Gravatar.php#L111-L114
train
gravatarphp/gravatar
src/Gravatar.php
Gravatar.qrCode
public function qrCode(string $email, ?bool $secure = null): string { return $this->profile($email, $secure).'.qr'; }
php
public function qrCode(string $email, ?bool $secure = null): string { return $this->profile($email, $secure).'.qr'; }
[ "public", "function", "qrCode", "(", "string", "$", "email", ",", "?", "bool", "$", "secure", "=", "null", ")", ":", "string", "{", "return", "$", "this", "->", "profile", "(", "$", "email", ",", "$", "secure", ")", ".", "'.qr'", ";", "}" ]
Returns a QR Code URL.
[ "Returns", "a", "QR", "Code", "URL", "." ]
54a5d48b4564ec9f1db8a498ad23d500ab83c063
https://github.com/gravatarphp/gravatar/blob/54a5d48b4564ec9f1db8a498ad23d500ab83c063/src/Gravatar.php#L119-L122
train
gravatarphp/gravatar
src/Gravatar.php
Gravatar.createEmailHash
private function createEmailHash(string $email): string { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { throw new \InvalidArgumentException('Invalid email address'); } return md5(strtolower(trim($email))); }
php
private function createEmailHash(string $email): string { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { throw new \InvalidArgumentException('Invalid email address'); } return md5(strtolower(trim($email))); }
[ "private", "function", "createEmailHash", "(", "string", "$", "email", ")", ":", "string", "{", "if", "(", "!", "filter_var", "(", "$", "email", ",", "FILTER_VALIDATE_EMAIL", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid email...
Creates a hash from an email address.
[ "Creates", "a", "hash", "from", "an", "email", "address", "." ]
54a5d48b4564ec9f1db8a498ad23d500ab83c063
https://github.com/gravatarphp/gravatar/blob/54a5d48b4564ec9f1db8a498ad23d500ab83c063/src/Gravatar.php#L127-L134
train
gravatarphp/gravatar
src/Gravatar.php
Gravatar.buildUrl
private function buildUrl(string $resource, ?bool $secure): string { $secure = isset($secure) ? (bool) $secure : $this->secure; $endpoint = $secure ? self::HTTPS_ENDPOINT : self::HTTP_ENDPOINT; return sprintf('%s/%s', $endpoint, $resource); }
php
private function buildUrl(string $resource, ?bool $secure): string { $secure = isset($secure) ? (bool) $secure : $this->secure; $endpoint = $secure ? self::HTTPS_ENDPOINT : self::HTTP_ENDPOINT; return sprintf('%s/%s', $endpoint, $resource); }
[ "private", "function", "buildUrl", "(", "string", "$", "resource", ",", "?", "bool", "$", "secure", ")", ":", "string", "{", "$", "secure", "=", "isset", "(", "$", "secure", ")", "?", "(", "bool", ")", "$", "secure", ":", "$", "this", "->", "secure...
Builds the URL based on the given parameters.
[ "Builds", "the", "URL", "based", "on", "the", "given", "parameters", "." ]
54a5d48b4564ec9f1db8a498ad23d500ab83c063
https://github.com/gravatarphp/gravatar/blob/54a5d48b4564ec9f1db8a498ad23d500ab83c063/src/Gravatar.php#L220-L227
train
johnstevenson/json-works
src/Utils.php
Utils.dataToJson
public static function dataToJson($data, $pretty) { $newLine = $pretty ? chr(10) : null; if (version_compare(PHP_VERSION, '5.4', '>=')) { $pprint = $pretty ? JSON_PRETTY_PRINT : 0; $options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | $pprint; return static::finalizeJson(json_encode($data, $options), $newLine); } $json = json_encode($data); $len = strlen($json); $result = $string = ''; $inString = $escaped = false; $level = 0; $space = $pretty ? chr(32) : null; $convert = function_exists('mb_convert_encoding'); for ($i = 0; $i < $len; $i++) { $char = $json[$i]; # are we inside a json string? if ('"' === $char && !$escaped) { $inString = !$inString; } if ($inString) { $string .= $char; $escaped = '\\' === $char ? !$escaped : false; continue; } elseif ($string) { # end of the json string $string .= $char; # unescape slashes $string = str_replace('\\/', '/', $string); # unescape unicode if ($convert) { $string = preg_replace_callback('/\\\\u([0-9a-f]{4})/i', function ($match) { return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE'); }, $string); } $result .= $string; $string = ''; continue; } if (':' === $char) { # add space after colon $char .= $space; } elseif (strpbrk($char, '}]')) { # char is an end element, so add a newline $result .= $newLine; # decrease indent level $level--; $result .= str_repeat($space, $level * 4); } $result .= $char; if (strpbrk($char, ',{[')) { # char is a start element, so add a newline $result .= $newLine; # increase indent level if not a comma if (',' !== $char) { $level++; } $result .= str_repeat($space, $level * 4); } } return static::finalizeJson($result, $newLine); }
php
public static function dataToJson($data, $pretty) { $newLine = $pretty ? chr(10) : null; if (version_compare(PHP_VERSION, '5.4', '>=')) { $pprint = $pretty ? JSON_PRETTY_PRINT : 0; $options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | $pprint; return static::finalizeJson(json_encode($data, $options), $newLine); } $json = json_encode($data); $len = strlen($json); $result = $string = ''; $inString = $escaped = false; $level = 0; $space = $pretty ? chr(32) : null; $convert = function_exists('mb_convert_encoding'); for ($i = 0; $i < $len; $i++) { $char = $json[$i]; # are we inside a json string? if ('"' === $char && !$escaped) { $inString = !$inString; } if ($inString) { $string .= $char; $escaped = '\\' === $char ? !$escaped : false; continue; } elseif ($string) { # end of the json string $string .= $char; # unescape slashes $string = str_replace('\\/', '/', $string); # unescape unicode if ($convert) { $string = preg_replace_callback('/\\\\u([0-9a-f]{4})/i', function ($match) { return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE'); }, $string); } $result .= $string; $string = ''; continue; } if (':' === $char) { # add space after colon $char .= $space; } elseif (strpbrk($char, '}]')) { # char is an end element, so add a newline $result .= $newLine; # decrease indent level $level--; $result .= str_repeat($space, $level * 4); } $result .= $char; if (strpbrk($char, ',{[')) { # char is a start element, so add a newline $result .= $newLine; # increase indent level if not a comma if (',' !== $char) { $level++; } $result .= str_repeat($space, $level * 4); } } return static::finalizeJson($result, $newLine); }
[ "public", "static", "function", "dataToJson", "(", "$", "data", ",", "$", "pretty", ")", "{", "$", "newLine", "=", "$", "pretty", "?", "chr", "(", "10", ")", ":", "null", ";", "if", "(", "version_compare", "(", "PHP_VERSION", ",", "'5.4'", ",", "'>='...
Encodes data into JSON @param mixed $data The data to be encoded @param boolean $pretty Format the output @return string Encoded json
[ "Encodes", "data", "into", "JSON" ]
97eca2c9956894374d41dcaf8031d123a8705100
https://github.com/johnstevenson/json-works/blob/97eca2c9956894374d41dcaf8031d123a8705100/src/Utils.php#L193-L273
train
madkom/nginx-configurator
src/Factory.php
Factory.createServer
public function createServer(int $port = 80) : Server { $listenIPv4 = new Directive('listen', [new Param($port)]); $listenIPv6 = new Directive('listen', [new Param("[::]:{$port}"), new Param('default'), new Param('ipv6only=on')]); return new Server([$listenIPv4, $listenIPv6]); }
php
public function createServer(int $port = 80) : Server { $listenIPv4 = new Directive('listen', [new Param($port)]); $listenIPv6 = new Directive('listen', [new Param("[::]:{$port}"), new Param('default'), new Param('ipv6only=on')]); return new Server([$listenIPv4, $listenIPv6]); }
[ "public", "function", "createServer", "(", "int", "$", "port", "=", "80", ")", ":", "Server", "{", "$", "listenIPv4", "=", "new", "Directive", "(", "'listen'", ",", "[", "new", "Param", "(", "$", "port", ")", "]", ")", ";", "$", "listenIPv6", "=", ...
Creates Server node @param int $port @return Server
[ "Creates", "Server", "node" ]
19eb02251fb2ae82c92375d039272cbf257f3137
https://github.com/madkom/nginx-configurator/blob/19eb02251fb2ae82c92375d039272cbf257f3137/src/Factory.php#L27-L33
train
madkom/nginx-configurator
src/Factory.php
Factory.createLocation
public function createLocation(string $location, string $match = null) : Location { return new Location(new Param($location), is_null($match) ? null : new Param($match)); }
php
public function createLocation(string $location, string $match = null) : Location { return new Location(new Param($location), is_null($match) ? null : new Param($match)); }
[ "public", "function", "createLocation", "(", "string", "$", "location", ",", "string", "$", "match", "=", "null", ")", ":", "Location", "{", "return", "new", "Location", "(", "new", "Param", "(", "$", "location", ")", ",", "is_null", "(", "$", "match", ...
Creates Location node @param string $location @param string|null $match @return Location
[ "Creates", "Location", "node" ]
19eb02251fb2ae82c92375d039272cbf257f3137
https://github.com/madkom/nginx-configurator/blob/19eb02251fb2ae82c92375d039272cbf257f3137/src/Factory.php#L41-L44
train
breeswish/php-marked
src/Marked/Parser.php
Parser.doParse
public static function doParse($src, $src_links, $options) { $parser = new Parser($options); return $parser->parse($src, $src_links); }
php
public static function doParse($src, $src_links, $options) { $parser = new Parser($options); return $parser->parse($src, $src_links); }
[ "public", "static", "function", "doParse", "(", "$", "src", ",", "$", "src_links", ",", "$", "options", ")", "{", "$", "parser", "=", "new", "Parser", "(", "$", "options", ")", ";", "return", "$", "parser", "->", "parse", "(", "$", "src", ",", "$",...
Static Parse Method
[ "Static", "Parse", "Method" ]
b67fe5bdc90beb877e03974a899e98f856e0006d
https://github.com/breeswish/php-marked/blob/b67fe5bdc90beb877e03974a899e98f856e0006d/src/Marked/Parser.php#L20-L24
train
breeswish/php-marked
src/Marked/Parser.php
Parser.peek
public function peek() { $l = count($this->tokens); if ($l == 0) { return null; } else { return $this->tokens[$l - 1]; } }
php
public function peek() { $l = count($this->tokens); if ($l == 0) { return null; } else { return $this->tokens[$l - 1]; } }
[ "public", "function", "peek", "(", ")", "{", "$", "l", "=", "count", "(", "$", "this", "->", "tokens", ")", ";", "if", "(", "$", "l", "==", "0", ")", "{", "return", "null", ";", "}", "else", "{", "return", "$", "this", "->", "tokens", "[", "$...
Preview Next Token
[ "Preview", "Next", "Token" ]
b67fe5bdc90beb877e03974a899e98f856e0006d
https://github.com/breeswish/php-marked/blob/b67fe5bdc90beb877e03974a899e98f856e0006d/src/Marked/Parser.php#L69-L77
train
breeswish/php-marked
src/Marked/Parser.php
Parser.parseText
public function parseText() { $body = $this->token['text']; $p = $this->peek(); while (isset($p) && $p['type'] === 'text') { $n = $this->next(); $body .= "\n" . $n['text']; $p = $this->peek(); } return $this->inline->output($body); }
php
public function parseText() { $body = $this->token['text']; $p = $this->peek(); while (isset($p) && $p['type'] === 'text') { $n = $this->next(); $body .= "\n" . $n['text']; $p = $this->peek(); } return $this->inline->output($body); }
[ "public", "function", "parseText", "(", ")", "{", "$", "body", "=", "$", "this", "->", "token", "[", "'text'", "]", ";", "$", "p", "=", "$", "this", "->", "peek", "(", ")", ";", "while", "(", "isset", "(", "$", "p", ")", "&&", "$", "p", "[", ...
Parse Text Tokens
[ "Parse", "Text", "Tokens" ]
b67fe5bdc90beb877e03974a899e98f856e0006d
https://github.com/breeswish/php-marked/blob/b67fe5bdc90beb877e03974a899e98f856e0006d/src/Marked/Parser.php#L82-L94
train
madkom/nginx-configurator
src/Node/Node.php
Node.append
public function append(Node $node) : bool { $node->parent = $this; return $this->childNodes->add($node); }
php
public function append(Node $node) : bool { $node->parent = $this; return $this->childNodes->add($node); }
[ "public", "function", "append", "(", "Node", "$", "node", ")", ":", "bool", "{", "$", "node", "->", "parent", "=", "$", "this", ";", "return", "$", "this", "->", "childNodes", "->", "add", "(", "$", "node", ")", ";", "}" ]
Append new child node @param Node $node @return bool
[ "Append", "new", "child", "node" ]
19eb02251fb2ae82c92375d039272cbf257f3137
https://github.com/madkom/nginx-configurator/blob/19eb02251fb2ae82c92375d039272cbf257f3137/src/Node/Node.php#L62-L67
train
madkom/nginx-configurator
src/Parser.php
Parser.parseFile
public function parseFile(string $filename) : RootNode { $this->content = null; $this->filename = $filename; return $this->parse(file_get_contents($filename)); }
php
public function parseFile(string $filename) : RootNode { $this->content = null; $this->filename = $filename; return $this->parse(file_get_contents($filename)); }
[ "public", "function", "parseFile", "(", "string", "$", "filename", ")", ":", "RootNode", "{", "$", "this", "->", "content", "=", "null", ";", "$", "this", "->", "filename", "=", "$", "filename", ";", "return", "$", "this", "->", "parse", "(", "file_get...
Parses config file @param string $filename @return mixed @throws ParseFailureException
[ "Parses", "config", "file" ]
19eb02251fb2ae82c92375d039272cbf257f3137
https://github.com/madkom/nginx-configurator/blob/19eb02251fb2ae82c92375d039272cbf257f3137/src/Parser.php#L134-L140
train
madkom/nginx-configurator
src/Parser.php
Parser.parseSection
protected function parseSection($section, $space0, $params, $open, $space1, $directives) : Context { switch ($section) { case 'server': return new Server($directives); case 'http': return new Http($directives); case 'location': $modifier = null; if (sizeof($params) == 2) { list($modifier, $location) = $params; } elseif (sizeof($params) == 1) { $location = $params[0]; } else { throw new GrammarException( sprintf( "Location context missing in %s", $this->filename ? var_export($this->filename, true) : var_export($this->content, true) ) ); } return new Location($location, $modifier, $directives); case 'events': return new Events($directives); case 'upstream': list($upstream) = $params; return new Upstream($upstream, $directives); } throw new UnrecognizedContextException( sprintf( "Unrecognized context: {$section} found in %s", $this->filename ? var_export($this->filename, true) : var_export($this->content, true) ) ); }
php
protected function parseSection($section, $space0, $params, $open, $space1, $directives) : Context { switch ($section) { case 'server': return new Server($directives); case 'http': return new Http($directives); case 'location': $modifier = null; if (sizeof($params) == 2) { list($modifier, $location) = $params; } elseif (sizeof($params) == 1) { $location = $params[0]; } else { throw new GrammarException( sprintf( "Location context missing in %s", $this->filename ? var_export($this->filename, true) : var_export($this->content, true) ) ); } return new Location($location, $modifier, $directives); case 'events': return new Events($directives); case 'upstream': list($upstream) = $params; return new Upstream($upstream, $directives); } throw new UnrecognizedContextException( sprintf( "Unrecognized context: {$section} found in %s", $this->filename ? var_export($this->filename, true) : var_export($this->content, true) ) ); }
[ "protected", "function", "parseSection", "(", "$", "section", ",", "$", "space0", ",", "$", "params", ",", "$", "open", ",", "$", "space1", ",", "$", "directives", ")", ":", "Context", "{", "switch", "(", "$", "section", ")", "{", "case", "'server'", ...
Parses section entries @param string $section Section name @param null $space0 Ignored @param Param[] $params Params collection @param null $open Ignored @param null $space1 Ignored @param Directive[] $directives Directives collection @return Context @throws GrammarException @throws UnrecognizedContextException
[ "Parses", "section", "entries" ]
19eb02251fb2ae82c92375d039272cbf257f3137
https://github.com/madkom/nginx-configurator/blob/19eb02251fb2ae82c92375d039272cbf257f3137/src/Parser.php#L168-L207
train
marciioluucas/phiber
src/Phiber/Util/FuncoesString.php
FuncoesString.separaString
public function separaString($string, $posicaoInicial, $posicaoFinal = null) { if ($posicaoFinal == null) { return substr($string, $posicaoInicial - 1); } return substr($string, $posicaoInicial - 1, ($posicaoFinal - 1) * (-1)); }
php
public function separaString($string, $posicaoInicial, $posicaoFinal = null) { if ($posicaoFinal == null) { return substr($string, $posicaoInicial - 1); } return substr($string, $posicaoInicial - 1, ($posicaoFinal - 1) * (-1)); }
[ "public", "function", "separaString", "(", "$", "string", ",", "$", "posicaoInicial", ",", "$", "posicaoFinal", "=", "null", ")", "{", "if", "(", "$", "posicaoFinal", "==", "null", ")", "{", "return", "substr", "(", "$", "string", ",", "$", "posicaoInici...
Separa uma string. @param string $string @param int $posicaoInicial @param int $posicaoFinal default null @return string
[ "Separa", "uma", "string", "." ]
7218e07872279f8c6cd8286460c82782ec62de4c
https://github.com/marciioluucas/phiber/blob/7218e07872279f8c6cd8286460c82782ec62de4c/src/Phiber/Util/FuncoesString.php#L73-L80
train
marciioluucas/phiber
src/Phiber/ORM/Logger/PhiberLogger.php
PhiberLogger.create
public static function create($languageReference, $level = 'info', $objectName = '', $execTime = null) { if (JsonReader::read(BASE_DIR.'/phiber_config.json')->phiber->log == 1 ? true : false) { $date = date('Y-m-d H:i:s'); switch ($level) { case 'info': $levelStr = strtoupper(new Internationalization("log_info")); $msg = "\033[0;35m PHIBER LOG -> [$date] [$levelStr]: (" . new Internationalization("reference") . "=> \"$objectName\") " . new Internationalization($languageReference) . " - "; if($execTime != null){ $msg .= "em " . $execTime . "."; } echo $msg . "\e[0m \n"; break; case 'warning': $levelStr = strtoupper(new Internationalization("log_warning")); $msg = "\033[1;33m PHIBER LOG -> [$date] [$levelStr]: (" . new Internationalization("reference") . "=> \"$objectName\") " . new Internationalization($languageReference) . " - "; if($execTime != null){ $msg .= "em " . $execTime . "."; } echo $msg . "\e[0m \n"; break; case 'error': $levelStr = strtoupper(new Internationalization("log_error")); $msg = "\033[0;31m PHIBER LOG -> [$date] [$levelStr]: (" . new Internationalization("reference") . "=> \"$objectName\") " . new Internationalization($languageReference) . " - "; if($execTime != null){ $msg .= "em " . $execTime . "."; } echo $msg . "\e[0m \n"; break; } } }
php
public static function create($languageReference, $level = 'info', $objectName = '', $execTime = null) { if (JsonReader::read(BASE_DIR.'/phiber_config.json')->phiber->log == 1 ? true : false) { $date = date('Y-m-d H:i:s'); switch ($level) { case 'info': $levelStr = strtoupper(new Internationalization("log_info")); $msg = "\033[0;35m PHIBER LOG -> [$date] [$levelStr]: (" . new Internationalization("reference") . "=> \"$objectName\") " . new Internationalization($languageReference) . " - "; if($execTime != null){ $msg .= "em " . $execTime . "."; } echo $msg . "\e[0m \n"; break; case 'warning': $levelStr = strtoupper(new Internationalization("log_warning")); $msg = "\033[1;33m PHIBER LOG -> [$date] [$levelStr]: (" . new Internationalization("reference") . "=> \"$objectName\") " . new Internationalization($languageReference) . " - "; if($execTime != null){ $msg .= "em " . $execTime . "."; } echo $msg . "\e[0m \n"; break; case 'error': $levelStr = strtoupper(new Internationalization("log_error")); $msg = "\033[0;31m PHIBER LOG -> [$date] [$levelStr]: (" . new Internationalization("reference") . "=> \"$objectName\") " . new Internationalization($languageReference) . " - "; if($execTime != null){ $msg .= "em " . $execTime . "."; } echo $msg . "\e[0m \n"; break; } } }
[ "public", "static", "function", "create", "(", "$", "languageReference", ",", "$", "level", "=", "'info'", ",", "$", "objectName", "=", "''", ",", "$", "execTime", "=", "null", ")", "{", "if", "(", "JsonReader", "::", "read", "(", "BASE_DIR", ".", "'/p...
Cria o log. @param $languageReference @param string $level @param string $objectName @param null $execTime
[ "Cria", "o", "log", "." ]
7218e07872279f8c6cd8286460c82782ec62de4c
https://github.com/marciioluucas/phiber/blob/7218e07872279f8c6cd8286460c82782ec62de4c/src/Phiber/ORM/Logger/PhiberLogger.php#L24-L66
train
marciioluucas/phiber
src/Phiber/ORM/Persistence/TableMySql.php
TableMySql.drop
static function drop($obj) { $tabela = strtolower(FuncoesReflections::pegaNomeClasseObjeto($obj)); $atributosObjeto = FuncoesReflections::pegaAtributosDoObjeto($obj); $columnsTabela = self::columns($tabela); $arrayCamposTabela = []; for ($i = 0; $i < count($columnsTabela); $i++) { array_push($arrayCamposTabela, $columnsTabela[$i]['Field']); } $arrayDiff = array_diff($arrayCamposTabela, $atributosObjeto); $arrayDiff = array_values($arrayDiff); $sqlDrop = "ALTER TABLE $tabela \n"; for ($j = 0; $j < count($arrayDiff); $j++) { if ($j != count($arrayDiff) - 1) { $sqlDrop .= "DROP " . $arrayDiff[$j] . ", "; } else { $sqlDrop .= "DROP " . $arrayDiff[$j] . ";"; } } $contentFile = JsonReader::read(BASE_DIR."/phiber_config.json")->phiber->code_sync == 1 ? true : false; if ($contentFile) { $pdo = self::getConnection()->prepare($sqlDrop); if ($pdo->execute()) { return true; }; } else { return $sqlDrop; } return false; }
php
static function drop($obj) { $tabela = strtolower(FuncoesReflections::pegaNomeClasseObjeto($obj)); $atributosObjeto = FuncoesReflections::pegaAtributosDoObjeto($obj); $columnsTabela = self::columns($tabela); $arrayCamposTabela = []; for ($i = 0; $i < count($columnsTabela); $i++) { array_push($arrayCamposTabela, $columnsTabela[$i]['Field']); } $arrayDiff = array_diff($arrayCamposTabela, $atributosObjeto); $arrayDiff = array_values($arrayDiff); $sqlDrop = "ALTER TABLE $tabela \n"; for ($j = 0; $j < count($arrayDiff); $j++) { if ($j != count($arrayDiff) - 1) { $sqlDrop .= "DROP " . $arrayDiff[$j] . ", "; } else { $sqlDrop .= "DROP " . $arrayDiff[$j] . ";"; } } $contentFile = JsonReader::read(BASE_DIR."/phiber_config.json")->phiber->code_sync == 1 ? true : false; if ($contentFile) { $pdo = self::getConnection()->prepare($sqlDrop); if ($pdo->execute()) { return true; }; } else { return $sqlDrop; } return false; }
[ "static", "function", "drop", "(", "$", "obj", ")", "{", "$", "tabela", "=", "strtolower", "(", "FuncoesReflections", "::", "pegaNomeClasseObjeto", "(", "$", "obj", ")", ")", ";", "$", "atributosObjeto", "=", "FuncoesReflections", "::", "pegaAtributosDoObjeto", ...
Deleta a tabela do banco de dados. @param Object $obj @return bool|string
[ "Deleta", "a", "tabela", "do", "banco", "de", "dados", "." ]
7218e07872279f8c6cd8286460c82782ec62de4c
https://github.com/marciioluucas/phiber/blob/7218e07872279f8c6cd8286460c82782ec62de4c/src/Phiber/ORM/Persistence/TableMySql.php#L74-L107
train
marciioluucas/phiber
src/Phiber/ORM/Persistence/TableMySql.php
TableMySql.columns
static function columns($table) { $sql = "show columns from " . strtolower($table); $contentFile = JsonReader::read(BASE_DIR . "/phiber_config.json")->phiber->execute_querys == 1 ? true : false; if ($contentFile) { $pdo = self::getConnection()->prepare($sql); if ($pdo->execute()) { return $pdo->fetchAll(\PDO::FETCH_ASSOC); } else { return false; } } else { return false; } }
php
static function columns($table) { $sql = "show columns from " . strtolower($table); $contentFile = JsonReader::read(BASE_DIR . "/phiber_config.json")->phiber->execute_querys == 1 ? true : false; if ($contentFile) { $pdo = self::getConnection()->prepare($sql); if ($pdo->execute()) { return $pdo->fetchAll(\PDO::FETCH_ASSOC); } else { return false; } } else { return false; } }
[ "static", "function", "columns", "(", "$", "table", ")", "{", "$", "sql", "=", "\"show columns from \"", ".", "strtolower", "(", "$", "table", ")", ";", "$", "contentFile", "=", "JsonReader", "::", "read", "(", "BASE_DIR", ".", "\"/phiber_config.json\"", ")"...
Mostra as colunas daquela tabela. @param string $table @return array|bool
[ "Mostra", "as", "colunas", "daquela", "tabela", "." ]
7218e07872279f8c6cd8286460c82782ec62de4c
https://github.com/marciioluucas/phiber/blob/7218e07872279f8c6cd8286460c82782ec62de4c/src/Phiber/ORM/Persistence/TableMySql.php#L115-L130
train
marciioluucas/phiber
src/Phiber/ORM/Queries/PhiberQueryWriter.php
PhiberQueryWriter.update
public function update($infos) { $tabela = $infos['table']; $campos = $infos['fields']; $camposV = $infos['values']; $whereCriteria = $infos['where']; try { $camposNome = []; for ($i = 0; $i < count($campos); $i++) { if ($camposV[$i] != null) { $camposNome[$i] = $campos[$i]; } } $camposNome = array_values($camposNome); $this->sql = "UPDATE $tabela SET "; for ($i = 0; $i < count($camposNome); $i++) { if (!empty($camposNome[$i])) { if ($i != count($camposNome) - 1) { $this->sql .= $camposNome[$i] . " = :" . $camposNome[$i] . ", "; } else { $this->sql .= $camposNome[$i] . " = :" . $camposNome[$i]; } } } if (!empty($whereCriteria)) { $this->sql .= " WHERE " . $whereCriteria . " "; } return $this->sql . ";"; } catch (PhiberException $e) { throw new PhiberException(new Internationalization("query_processor_error")); } }
php
public function update($infos) { $tabela = $infos['table']; $campos = $infos['fields']; $camposV = $infos['values']; $whereCriteria = $infos['where']; try { $camposNome = []; for ($i = 0; $i < count($campos); $i++) { if ($camposV[$i] != null) { $camposNome[$i] = $campos[$i]; } } $camposNome = array_values($camposNome); $this->sql = "UPDATE $tabela SET "; for ($i = 0; $i < count($camposNome); $i++) { if (!empty($camposNome[$i])) { if ($i != count($camposNome) - 1) { $this->sql .= $camposNome[$i] . " = :" . $camposNome[$i] . ", "; } else { $this->sql .= $camposNome[$i] . " = :" . $camposNome[$i]; } } } if (!empty($whereCriteria)) { $this->sql .= " WHERE " . $whereCriteria . " "; } return $this->sql . ";"; } catch (PhiberException $e) { throw new PhiberException(new Internationalization("query_processor_error")); } }
[ "public", "function", "update", "(", "$", "infos", ")", "{", "$", "tabela", "=", "$", "infos", "[", "'table'", "]", ";", "$", "campos", "=", "$", "infos", "[", "'fields'", "]", ";", "$", "camposV", "=", "$", "infos", "[", "'values'", "]", ";", "$...
Faz a query de update de um registro no banco com os dados. @param $infos @return mixed @throws PhiberException @internal param $object @internal param $id
[ "Faz", "a", "query", "de", "update", "de", "um", "registro", "no", "banco", "com", "os", "dados", "." ]
7218e07872279f8c6cd8286460c82782ec62de4c
https://github.com/marciioluucas/phiber/blob/7218e07872279f8c6cd8286460c82782ec62de4c/src/Phiber/ORM/Queries/PhiberQueryWriter.php#L92-L129
train
marciioluucas/phiber
src/Phiber/ORM/Queries/PhiberQueryWriter.php
PhiberQueryWriter.delete
public function delete(array $infos) { $tabela = $infos['table']; $whereCriteria = $infos['where']; try { $this->sql = "DELETE FROM $tabela "; if (!empty($whereCriteria)) { $this->sql .= " WHERE " . $whereCriteria . " "; } return $this->sql . ";"; } catch (PhiberException $e) { throw new PhiberException(new Internationalization("query_processor_error")); } }
php
public function delete(array $infos) { $tabela = $infos['table']; $whereCriteria = $infos['where']; try { $this->sql = "DELETE FROM $tabela "; if (!empty($whereCriteria)) { $this->sql .= " WHERE " . $whereCriteria . " "; } return $this->sql . ";"; } catch (PhiberException $e) { throw new PhiberException(new Internationalization("query_processor_error")); } }
[ "public", "function", "delete", "(", "array", "$", "infos", ")", "{", "$", "tabela", "=", "$", "infos", "[", "'table'", "]", ";", "$", "whereCriteria", "=", "$", "infos", "[", "'where'", "]", ";", "try", "{", "$", "this", "->", "sql", "=", "\"DELET...
Faz a query de delete de um registro no banco com os dados. @param array $infos @return bool|string @throws PhiberException @internal param $object @internal param array $conditions @internal param array $conjunctions
[ "Faz", "a", "query", "de", "delete", "de", "um", "registro", "no", "banco", "com", "os", "dados", "." ]
7218e07872279f8c6cd8286460c82782ec62de4c
https://github.com/marciioluucas/phiber/blob/7218e07872279f8c6cd8286460c82782ec62de4c/src/Phiber/ORM/Queries/PhiberQueryWriter.php#L141-L157
train
marciioluucas/phiber
src/Phiber/ORM/Queries/PhiberQueryWriter.php
PhiberQueryWriter.select
public function select(array $infos) { try { $tabela = $infos['table']; $campos = $infos['fields']; $whereCriteria = $infos['where']; $joins = $infos['join']; $limitCriteria = $infos['limit']; $offsetCriteria = $infos['offset']; $orderByCriteria = $infos['orderby']; $campos = gettype($campos) == "array" ? implode(", ", $campos) : $campos; $this->sql = "SELECT " . $campos . " FROM $tabela"; // responsável por montar JOIN if (!empty($joins)) { for ($i = 0; $i < count($joins); $i++) { $this->sql .= " " . $joins[$i] . " "; } } // responsável por montar o WHERE. if (!empty($whereCriteria)) { $this->sql .= " WHERE " . $whereCriteria; } // responsável por montar o order by. if (!is_null($orderByCriteria)) { $orderBy = gettype($orderByCriteria) == "array" ? implode(", ", $orderByCriteria) : $orderByCriteria; $this->sql .= " ORDER BY " . $orderBy; } // responsável por montar o limit. if (!empty($limitCriteria)) { $this->sql .= " LIMIT " . $limitCriteria; } // responsável por montar OFFSET if (!empty($offsetCriteria)) { $this->sql .= " OFFSET " . $offsetCriteria; } $this->sql .= ";"; return $this->sql; } catch (PhiberException $phiberException) { throw new PhiberException(new Internationalization("query_processor_error")); } }
php
public function select(array $infos) { try { $tabela = $infos['table']; $campos = $infos['fields']; $whereCriteria = $infos['where']; $joins = $infos['join']; $limitCriteria = $infos['limit']; $offsetCriteria = $infos['offset']; $orderByCriteria = $infos['orderby']; $campos = gettype($campos) == "array" ? implode(", ", $campos) : $campos; $this->sql = "SELECT " . $campos . " FROM $tabela"; // responsável por montar JOIN if (!empty($joins)) { for ($i = 0; $i < count($joins); $i++) { $this->sql .= " " . $joins[$i] . " "; } } // responsável por montar o WHERE. if (!empty($whereCriteria)) { $this->sql .= " WHERE " . $whereCriteria; } // responsável por montar o order by. if (!is_null($orderByCriteria)) { $orderBy = gettype($orderByCriteria) == "array" ? implode(", ", $orderByCriteria) : $orderByCriteria; $this->sql .= " ORDER BY " . $orderBy; } // responsável por montar o limit. if (!empty($limitCriteria)) { $this->sql .= " LIMIT " . $limitCriteria; } // responsável por montar OFFSET if (!empty($offsetCriteria)) { $this->sql .= " OFFSET " . $offsetCriteria; } $this->sql .= ";"; return $this->sql; } catch (PhiberException $phiberException) { throw new PhiberException(new Internationalization("query_processor_error")); } }
[ "public", "function", "select", "(", "array", "$", "infos", ")", "{", "try", "{", "$", "tabela", "=", "$", "infos", "[", "'table'", "]", ";", "$", "campos", "=", "$", "infos", "[", "'fields'", "]", ";", "$", "whereCriteria", "=", "$", "infos", "[",...
Faz a query de select de um registro no banco com os dados. @param array $infos @return string @throws PhiberException
[ "Faz", "a", "query", "de", "select", "de", "um", "registro", "no", "banco", "com", "os", "dados", "." ]
7218e07872279f8c6cd8286460c82782ec62de4c
https://github.com/marciioluucas/phiber/blob/7218e07872279f8c6cd8286460c82782ec62de4c/src/Phiber/ORM/Queries/PhiberQueryWriter.php#L166-L220
train
webdevops/TYPO3-metaseo
Classes/Hook/HttpHook.php
HttpHook.main
public function main() { // INIT $tsSetup = $GLOBALS['TSFE']->tmpl->setup; $headers = array(); // don't send any headers if headers are already sent if (headers_sent()) { return; } // Init caches $cacheIdentification = sprintf( '%s_%s_http', $GLOBALS['TSFE']->id, substr(sha1(FrontendUtility::getCurrentUrl()), 10, 30) ); /** @var \TYPO3\CMS\Core\Cache\CacheManager $cacheManager */ $objectManager = Typo3GeneralUtility::makeInstance( 'TYPO3\\CMS\\Extbase\\Object\\ObjectManager' ); $cacheManager = $objectManager->get('TYPO3\\CMS\\Core\\Cache\\CacheManager'); $cache = $cacheManager->getCache('cache_pagesection'); if (!empty($GLOBALS['TSFE']->tmpl->loaded)) { // ################################## // Non-Cached page // ################################## if (!empty($tsSetup['plugin.']['metaseo.']['metaTags.'])) { $tsSetupSeo = $tsSetup['plugin.']['metaseo.']['metaTags.']; // ################################## // W3C P3P Tags // ################################## $p3pCP = null; $p3pPolicyUrl = null; if (!empty($tsSetupSeo['p3pCP'])) { $p3pCP = $tsSetupSeo['p3pCP']; } if (!empty($tsSetupSeo['p3pPolicyUrl'])) { $p3pPolicyUrl = $tsSetupSeo['p3pPolicyUrl']; } if (!empty($p3pCP) || !empty($p3pPolicyUrl)) { $p3pHeader = array(); if (!empty($p3pCP)) { $p3pHeader[] = 'CP="' . $p3pCP . '"'; } if (!empty($p3pPolicyUrl)) { $p3pHeader[] = 'policyref="' . $p3pPolicyUrl . '"'; } $headers['P3P'] = implode(' ', $p3pHeader); } } // Store headers into cache $cache->set($cacheIdentification, $headers, array('pageId_' . $GLOBALS['TSFE']->id)); } else { // ##################################### // Cached page // ##################################### // Fetched cached headers $cachedHeaders = $cache->get($cacheIdentification); if (!empty($cachedHeaders)) { $headers = $cachedHeaders; } } // Call hook GeneralUtility::callHookAndSignal(__CLASS__, 'httpHeaderOutput', $this, $headers); // ##################################### // Sender headers // ##################################### if (!empty($headers['P3P'])) { header('P3P: ' . $headers['P3P']); } }
php
public function main() { // INIT $tsSetup = $GLOBALS['TSFE']->tmpl->setup; $headers = array(); // don't send any headers if headers are already sent if (headers_sent()) { return; } // Init caches $cacheIdentification = sprintf( '%s_%s_http', $GLOBALS['TSFE']->id, substr(sha1(FrontendUtility::getCurrentUrl()), 10, 30) ); /** @var \TYPO3\CMS\Core\Cache\CacheManager $cacheManager */ $objectManager = Typo3GeneralUtility::makeInstance( 'TYPO3\\CMS\\Extbase\\Object\\ObjectManager' ); $cacheManager = $objectManager->get('TYPO3\\CMS\\Core\\Cache\\CacheManager'); $cache = $cacheManager->getCache('cache_pagesection'); if (!empty($GLOBALS['TSFE']->tmpl->loaded)) { // ################################## // Non-Cached page // ################################## if (!empty($tsSetup['plugin.']['metaseo.']['metaTags.'])) { $tsSetupSeo = $tsSetup['plugin.']['metaseo.']['metaTags.']; // ################################## // W3C P3P Tags // ################################## $p3pCP = null; $p3pPolicyUrl = null; if (!empty($tsSetupSeo['p3pCP'])) { $p3pCP = $tsSetupSeo['p3pCP']; } if (!empty($tsSetupSeo['p3pPolicyUrl'])) { $p3pPolicyUrl = $tsSetupSeo['p3pPolicyUrl']; } if (!empty($p3pCP) || !empty($p3pPolicyUrl)) { $p3pHeader = array(); if (!empty($p3pCP)) { $p3pHeader[] = 'CP="' . $p3pCP . '"'; } if (!empty($p3pPolicyUrl)) { $p3pHeader[] = 'policyref="' . $p3pPolicyUrl . '"'; } $headers['P3P'] = implode(' ', $p3pHeader); } } // Store headers into cache $cache->set($cacheIdentification, $headers, array('pageId_' . $GLOBALS['TSFE']->id)); } else { // ##################################### // Cached page // ##################################### // Fetched cached headers $cachedHeaders = $cache->get($cacheIdentification); if (!empty($cachedHeaders)) { $headers = $cachedHeaders; } } // Call hook GeneralUtility::callHookAndSignal(__CLASS__, 'httpHeaderOutput', $this, $headers); // ##################################### // Sender headers // ##################################### if (!empty($headers['P3P'])) { header('P3P: ' . $headers['P3P']); } }
[ "public", "function", "main", "(", ")", "{", "// INIT", "$", "tsSetup", "=", "$", "GLOBALS", "[", "'TSFE'", "]", "->", "tmpl", "->", "setup", ";", "$", "headers", "=", "array", "(", ")", ";", "// don't send any headers if headers are already sent", "if", "("...
Add HTTP Headers
[ "Add", "HTTP", "Headers" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Hook/HttpHook.php#L42-L128
train
webdevops/TYPO3-metaseo
Classes/Page/SitemapTxtPage.php
SitemapTxtPage.main
public function main() { // INIT $this->tsSetup = $GLOBALS['TSFE']->tmpl->setup['plugin.']['metaseo.']['sitemap.']; // check if sitemap is enabled in root if (!GeneralUtility::getRootSettingValue('is_sitemap', true)) { $this->showError('Sitemap is not available, please check your configuration [control-center]'); } return $this->build(); }
php
public function main() { // INIT $this->tsSetup = $GLOBALS['TSFE']->tmpl->setup['plugin.']['metaseo.']['sitemap.']; // check if sitemap is enabled in root if (!GeneralUtility::getRootSettingValue('is_sitemap', true)) { $this->showError('Sitemap is not available, please check your configuration [control-center]'); } return $this->build(); }
[ "public", "function", "main", "(", ")", "{", "// INIT", "$", "this", "->", "tsSetup", "=", "$", "GLOBALS", "[", "'TSFE'", "]", "->", "tmpl", "->", "setup", "[", "'plugin.'", "]", "[", "'metaseo.'", "]", "[", "'sitemap.'", "]", ";", "// check if sitemap i...
Build sitemap xml @return string
[ "Build", "sitemap", "xml" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Page/SitemapTxtPage.php#L51-L62
train
webdevops/TYPO3-metaseo
Classes/Utility/DatabaseUtility.php
DatabaseUtility.addCondition
public static function addCondition($condition) { $ret = ' '; if (!empty($condition)) { if (is_array($condition)) { $ret .= ' AND (( ' . implode(" )\nAND (", $condition) . ' ))'; } else { $ret .= ' AND ( ' . $condition . ' )'; } } return $ret; }
php
public static function addCondition($condition) { $ret = ' '; if (!empty($condition)) { if (is_array($condition)) { $ret .= ' AND (( ' . implode(" )\nAND (", $condition) . ' ))'; } else { $ret .= ' AND ( ' . $condition . ' )'; } } return $ret; }
[ "public", "static", "function", "addCondition", "(", "$", "condition", ")", "{", "$", "ret", "=", "' '", ";", "if", "(", "!", "empty", "(", "$", "condition", ")", ")", "{", "if", "(", "is_array", "(", "$", "condition", ")", ")", "{", "$", "ret", ...
Add condition to query @param array|string $condition Condition @return string
[ "Add", "condition", "to", "query" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/DatabaseUtility.php#L331-L344
train
webdevops/TYPO3-metaseo
Classes/Utility/DatabaseUtility.php
DatabaseUtility.quoteArray
public static function quoteArray(array $valueList, $table = null) { $ret = array(); foreach ($valueList as $k => $v) { $ret[$k] = self::quote($v, $table); } return $ret; }
php
public static function quoteArray(array $valueList, $table = null) { $ret = array(); foreach ($valueList as $k => $v) { $ret[$k] = self::quote($v, $table); } return $ret; }
[ "public", "static", "function", "quoteArray", "(", "array", "$", "valueList", ",", "$", "table", "=", "null", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "foreach", "(", "$", "valueList", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "ret...
Quote array with values @param array $valueList Values @param string $table Table @return array
[ "Quote", "array", "with", "values" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/DatabaseUtility.php#L404-L412
train
webdevops/TYPO3-metaseo
Classes/Page/Part/FooterPart.php
FooterPart.main
public function main($title) { // INIT $ret = array(); $tsSetup = $GLOBALS['TSFE']->tmpl->setup; $tsServices = array(); $beLoggedIn = isset($GLOBALS['BE_USER']->user['username']); $disabledHeaderCode = false; if (!empty($tsSetup['config.']['disableAllHeaderCode'])) { $disabledHeaderCode = true; } if (!empty($tsSetup['plugin.']['metaseo.']['services.'])) { $tsServices = $tsSetup['plugin.']['metaseo.']['services.']; } // Call hook GeneralUtility::callHookAndSignal(__CLASS__, 'pageFooterSetup', $this, $tsServices); // ######################################### // GOOGLE ANALYTICS // ######################################### if (!empty($tsServices['googleAnalytics'])) { $gaConf = $tsServices['googleAnalytics.']; $gaEnabled = true; if ($disabledHeaderCode && empty($gaConf['enableIfHeaderIsDisabled'])) { $gaEnabled = false; } if ($gaEnabled && !(empty($gaConf['showIfBeLogin']) && $beLoggedIn)) { // Build Google Analytics service $ret['ga'] = $this->buildGoogleAnalyticsCode($tsServices, $gaConf); if (!empty($gaConf['trackDownloads']) && !empty($gaConf['trackDownloadsScript'])) { $ret['ga.trackdownload'] = $this->serviceGoogleAnalyticsTrackDownloads($gaConf); } } elseif ($gaEnabled && $beLoggedIn) { // Disable caching $GLOBALS['TSFE']->set_no_cache('MetaSEO: Google Analytics code disabled, backend login detected'); // Backend login detected, disable cache because this page is viewed by BE-users $ret['ga.disabled'] = '<!-- Google Analytics disabled, ' . 'Page cache disabled - Backend-Login detected -->'; } } // ######################################### // PIWIK // ######################################### if (!empty($tsServices['piwik.']) && !empty($tsServices['piwik.']['url']) && !empty($tsServices['piwik.']['id']) ) { $piwikConf = $tsServices['piwik.']; $piwikEnabled = true; if ($disabledHeaderCode && empty($piwikConf['enableIfHeaderIsDisabled'])) { $piwikEnabled = false; } if ($piwikEnabled && !(empty($piwikConf['showIfBeLogin']) && $beLoggedIn)) { // Build Piwik service $ret['piwik'] = $this->buildPiwikCode($tsServices, $piwikConf); } elseif ($piwikEnabled && $beLoggedIn) { // Disable caching $GLOBALS['TSFE']->set_no_cache('MetaSEO: Piwik code disabled, backend login detected'); // Backend login detected, disable cache because this page is viewed by BE-users $ret['piwik.disabled'] = '<!-- Piwik disabled, Page cache disabled - Backend-Login detected -->'; } } // Call hook GeneralUtility::callHookAndSignal(__CLASS__, 'pageFooterOutput', $this, $ret); return implode("\n", $ret); }
php
public function main($title) { // INIT $ret = array(); $tsSetup = $GLOBALS['TSFE']->tmpl->setup; $tsServices = array(); $beLoggedIn = isset($GLOBALS['BE_USER']->user['username']); $disabledHeaderCode = false; if (!empty($tsSetup['config.']['disableAllHeaderCode'])) { $disabledHeaderCode = true; } if (!empty($tsSetup['plugin.']['metaseo.']['services.'])) { $tsServices = $tsSetup['plugin.']['metaseo.']['services.']; } // Call hook GeneralUtility::callHookAndSignal(__CLASS__, 'pageFooterSetup', $this, $tsServices); // ######################################### // GOOGLE ANALYTICS // ######################################### if (!empty($tsServices['googleAnalytics'])) { $gaConf = $tsServices['googleAnalytics.']; $gaEnabled = true; if ($disabledHeaderCode && empty($gaConf['enableIfHeaderIsDisabled'])) { $gaEnabled = false; } if ($gaEnabled && !(empty($gaConf['showIfBeLogin']) && $beLoggedIn)) { // Build Google Analytics service $ret['ga'] = $this->buildGoogleAnalyticsCode($tsServices, $gaConf); if (!empty($gaConf['trackDownloads']) && !empty($gaConf['trackDownloadsScript'])) { $ret['ga.trackdownload'] = $this->serviceGoogleAnalyticsTrackDownloads($gaConf); } } elseif ($gaEnabled && $beLoggedIn) { // Disable caching $GLOBALS['TSFE']->set_no_cache('MetaSEO: Google Analytics code disabled, backend login detected'); // Backend login detected, disable cache because this page is viewed by BE-users $ret['ga.disabled'] = '<!-- Google Analytics disabled, ' . 'Page cache disabled - Backend-Login detected -->'; } } // ######################################### // PIWIK // ######################################### if (!empty($tsServices['piwik.']) && !empty($tsServices['piwik.']['url']) && !empty($tsServices['piwik.']['id']) ) { $piwikConf = $tsServices['piwik.']; $piwikEnabled = true; if ($disabledHeaderCode && empty($piwikConf['enableIfHeaderIsDisabled'])) { $piwikEnabled = false; } if ($piwikEnabled && !(empty($piwikConf['showIfBeLogin']) && $beLoggedIn)) { // Build Piwik service $ret['piwik'] = $this->buildPiwikCode($tsServices, $piwikConf); } elseif ($piwikEnabled && $beLoggedIn) { // Disable caching $GLOBALS['TSFE']->set_no_cache('MetaSEO: Piwik code disabled, backend login detected'); // Backend login detected, disable cache because this page is viewed by BE-users $ret['piwik.disabled'] = '<!-- Piwik disabled, Page cache disabled - Backend-Login detected -->'; } } // Call hook GeneralUtility::callHookAndSignal(__CLASS__, 'pageFooterOutput', $this, $ret); return implode("\n", $ret); }
[ "public", "function", "main", "(", "$", "title", ")", "{", "// INIT", "$", "ret", "=", "array", "(", ")", ";", "$", "tsSetup", "=", "$", "GLOBALS", "[", "'TSFE'", "]", "->", "tmpl", "->", "setup", ";", "$", "tsServices", "=", "array", "(", ")", "...
Add Page Footer @param string $title Default page title (rendered by TYPO3) @return string Modified page title
[ "Add", "Page", "Footer" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Page/Part/FooterPart.php#L51-L134
train
webdevops/TYPO3-metaseo
Classes/Connector.php
Connector.setPageTitle
public static function setPageTitle($value, $updateTsfe = true) { $value = (string)$value; if ($updateTsfe && !empty($GLOBALS['TSFE'])) { $GLOBALS['TSFE']->page['title'] = $value; $GLOBALS['TSFE']->indexedDocTitle = $value; } self::$store['pagetitle']['pagetitle.title'] = $value; }
php
public static function setPageTitle($value, $updateTsfe = true) { $value = (string)$value; if ($updateTsfe && !empty($GLOBALS['TSFE'])) { $GLOBALS['TSFE']->page['title'] = $value; $GLOBALS['TSFE']->indexedDocTitle = $value; } self::$store['pagetitle']['pagetitle.title'] = $value; }
[ "public", "static", "function", "setPageTitle", "(", "$", "value", ",", "$", "updateTsfe", "=", "true", ")", "{", "$", "value", "=", "(", "string", ")", "$", "value", ";", "if", "(", "$", "updateTsfe", "&&", "!", "empty", "(", "$", "GLOBALS", "[", ...
Set page title @param string $value Page title @param boolean $updateTsfe Update TSFE values
[ "Set", "page", "title" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Connector.php#L66-L76
train
webdevops/TYPO3-metaseo
Classes/Connector.php
Connector.setOpenGraphTag
public static function setOpenGraphTag($key, $value) { $key = (string)$key; $value = (string)$value; self::$store['flag']['meta:og:external'] = true; self::$store['meta:og'][$key] = $value; }
php
public static function setOpenGraphTag($key, $value) { $key = (string)$key; $value = (string)$value; self::$store['flag']['meta:og:external'] = true; self::$store['meta:og'][$key] = $value; }
[ "public", "static", "function", "setOpenGraphTag", "(", "$", "key", ",", "$", "value", ")", "{", "$", "key", "=", "(", "string", ")", "$", "key", ";", "$", "value", "=", "(", "string", ")", "$", "value", ";", "self", "::", "$", "store", "[", "'fl...
Set opengraph tag @param string $key Metatag name @param string $value Metatag value
[ "Set", "opengraph", "tag" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Connector.php#L152-L159
train
webdevops/TYPO3-metaseo
Classes/Connector.php
Connector.setCustomOpenGraphTag
public static function setCustomOpenGraphTag($key, $value) { $key = (string)$key; $value = (string)$value; self::$store['flag']['custom:og:external'] = true; self::$store['custom:og'][$key] = $value; }
php
public static function setCustomOpenGraphTag($key, $value) { $key = (string)$key; $value = (string)$value; self::$store['flag']['custom:og:external'] = true; self::$store['custom:og'][$key] = $value; }
[ "public", "static", "function", "setCustomOpenGraphTag", "(", "$", "key", ",", "$", "value", ")", "{", "$", "key", "=", "(", "string", ")", "$", "key", ";", "$", "value", "=", "(", "string", ")", "$", "value", ";", "self", "::", "$", "store", "[", ...
Set custom opengraph tag @param string $key Metatag name @param string $value Metatag value
[ "Set", "custom", "opengraph", "tag" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Connector.php#L181-L188
train
webdevops/TYPO3-metaseo
Classes/Hook/SitemapIndexLinkHook.php
SitemapIndexLinkHook.checkIfFileIsWhitelisted
protected function checkIfFileIsWhitelisted($url) { $ret = false; // check for valid url if (empty($url)) { return false; } // parse url to extract only path $urlParts = parse_url($url); $filePath = $urlParts['path']; // Extract last file extension if (preg_match('/\.([^\.]+)$/', $filePath, $matches)) { $fileExt = trim(strtolower($matches[1])); // Check if file extension is whitelisted foreach ($this->fileExtList as $allowedFileExt) { if ($allowedFileExt === $fileExt) { // File is whitelisted, not blacklisted $ret = true; break; } } } return $ret; }
php
protected function checkIfFileIsWhitelisted($url) { $ret = false; // check for valid url if (empty($url)) { return false; } // parse url to extract only path $urlParts = parse_url($url); $filePath = $urlParts['path']; // Extract last file extension if (preg_match('/\.([^\.]+)$/', $filePath, $matches)) { $fileExt = trim(strtolower($matches[1])); // Check if file extension is whitelisted foreach ($this->fileExtList as $allowedFileExt) { if ($allowedFileExt === $fileExt) { // File is whitelisted, not blacklisted $ret = true; break; } } } return $ret; }
[ "protected", "function", "checkIfFileIsWhitelisted", "(", "$", "url", ")", "{", "$", "ret", "=", "false", ";", "// check for valid url", "if", "(", "empty", "(", "$", "url", ")", ")", "{", "return", "false", ";", "}", "// parse url to extract only path", "$", ...
Check if file is whitelisted Configuration specified in plugin.metaseo.sitemap.index.fileExtension @param string $url Url to file @return boolean
[ "Check", "if", "file", "is", "whitelisted" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Hook/SitemapIndexLinkHook.php#L265-L293
train
webdevops/TYPO3-metaseo
Classes/Hook/TCA/RobotsTxtDefault.php
RobotsTxtDefault.main
public function main(array $data) { // ############################ // Init // ############################ /** @var \TYPO3\CMS\Extbase\Object\ObjectManager objectManager */ $this->objectManager = GeneralUtility::makeInstance( 'TYPO3\\CMS\\Extbase\\Object\\ObjectManager' ); /** @var ConfigurationManager configurationManager */ $this->configurationManager = $this->objectManager->get( 'TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager' ); /** @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer cObj */ $this->cObj = $this->objectManager->get('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); // ############################ // Init TSFE // ############################ $rootPageId = $data['row']['pid']; // Disables the time tracker to speed up TypoScript execution /** @var \TYPO3\CMS\Core\TimeTracker\TimeTracker $timeTracker */ $timeTracker = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TimeTracker\\TimeTracker', false); $GLOBALS['TT'] = $timeTracker; $GLOBALS['TT']->start(); /** @var \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $tsfeController */ $tsfeController = $this->objectManager->get( 'TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', $GLOBALS['TYPO3_CONF_VARS'], $rootPageId, 0 ); $GLOBALS['TSFE'] = $tsfeController; //allow dynamically robots.txt to be dynamically scripted via TS if (empty($GLOBALS['TSFE']->sys_page)) { $GLOBALS['TSFE']->sys_page = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); $GLOBALS['TSFE']->initTemplate(); } // ############################ // Render default robots.txt content // ############################ // Fetch TypoScript setup $tsSetup = $this->configurationManager->getConfiguration( ConfigurationManager::CONFIGURATION_TYPE_FULL_TYPOSCRIPT, 'metaseo', 'plugin' ); $content = ''; if (!empty($tsSetup['plugin.']['metaseo.']['robotsTxt.'])) { $content = $this->cObj->cObjGetSingle( $tsSetup['plugin.']['metaseo.']['robotsTxt.']['default'], $tsSetup['plugin.']['metaseo.']['robotsTxt.']['default.'] ); } $content = htmlspecialchars($content); $content = nl2br($content); return $content; }
php
public function main(array $data) { // ############################ // Init // ############################ /** @var \TYPO3\CMS\Extbase\Object\ObjectManager objectManager */ $this->objectManager = GeneralUtility::makeInstance( 'TYPO3\\CMS\\Extbase\\Object\\ObjectManager' ); /** @var ConfigurationManager configurationManager */ $this->configurationManager = $this->objectManager->get( 'TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager' ); /** @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer cObj */ $this->cObj = $this->objectManager->get('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); // ############################ // Init TSFE // ############################ $rootPageId = $data['row']['pid']; // Disables the time tracker to speed up TypoScript execution /** @var \TYPO3\CMS\Core\TimeTracker\TimeTracker $timeTracker */ $timeTracker = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TimeTracker\\TimeTracker', false); $GLOBALS['TT'] = $timeTracker; $GLOBALS['TT']->start(); /** @var \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $tsfeController */ $tsfeController = $this->objectManager->get( 'TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', $GLOBALS['TYPO3_CONF_VARS'], $rootPageId, 0 ); $GLOBALS['TSFE'] = $tsfeController; //allow dynamically robots.txt to be dynamically scripted via TS if (empty($GLOBALS['TSFE']->sys_page)) { $GLOBALS['TSFE']->sys_page = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); $GLOBALS['TSFE']->initTemplate(); } // ############################ // Render default robots.txt content // ############################ // Fetch TypoScript setup $tsSetup = $this->configurationManager->getConfiguration( ConfigurationManager::CONFIGURATION_TYPE_FULL_TYPOSCRIPT, 'metaseo', 'plugin' ); $content = ''; if (!empty($tsSetup['plugin.']['metaseo.']['robotsTxt.'])) { $content = $this->cObj->cObjGetSingle( $tsSetup['plugin.']['metaseo.']['robotsTxt.']['default'], $tsSetup['plugin.']['metaseo.']['robotsTxt.']['default.'] ); } $content = htmlspecialchars($content); $content = nl2br($content); return $content; }
[ "public", "function", "main", "(", "array", "$", "data", ")", "{", "// ############################", "// Init", "// ############################", "/** @var \\TYPO3\\CMS\\Extbase\\Object\\ObjectManager objectManager */", "$", "this", "->", "objectManager", "=", "GeneralUtility",...
Render default Robots.txt from TypoScript Setup @param array $data TCE Information array @return string
[ "Render", "default", "Robots", ".", "txt", "from", "TypoScript", "Setup" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Hook/TCA/RobotsTxtDefault.php#L66-L136
train
webdevops/TYPO3-metaseo
Classes/Dao/PageSeoDao.php
PageSeoDao.listCalcDepth
protected function listCalcDepth($pageUid, array $rootLineRaw, $depth = null) { if ($depth === null) { $depth = 1; } if (empty($rootLineRaw[$pageUid])) { // found root page return $depth; } // we must be at least in the first depth ++$depth; $pagePid = $rootLineRaw[$pageUid]; if (!empty($pagePid)) { // recursive $depth = $this->listCalcDepth($pagePid, $rootLineRaw, $depth); } return $depth; }
php
protected function listCalcDepth($pageUid, array $rootLineRaw, $depth = null) { if ($depth === null) { $depth = 1; } if (empty($rootLineRaw[$pageUid])) { // found root page return $depth; } // we must be at least in the first depth ++$depth; $pagePid = $rootLineRaw[$pageUid]; if (!empty($pagePid)) { // recursive $depth = $this->listCalcDepth($pagePid, $rootLineRaw, $depth); } return $depth; }
[ "protected", "function", "listCalcDepth", "(", "$", "pageUid", ",", "array", "$", "rootLineRaw", ",", "$", "depth", "=", "null", ")", "{", "if", "(", "$", "depth", "===", "null", ")", "{", "$", "depth", "=", "1", ";", "}", "if", "(", "empty", "(", ...
Calculate the depth of a page @param integer $pageUid Page UID @param array $rootLineRaw Root line (raw list) @param integer $depth Current depth @return integer
[ "Calculate", "the", "depth", "of", "a", "page" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Dao/PageSeoDao.php#L213-L235
train
webdevops/TYPO3-metaseo
Classes/Dao/PageSeoDao.php
PageSeoDao.updatePageTableField
public function updatePageTableField($pid, $sysLanguage, $fieldName, $fieldValue) { $tableName = 'pages'; if (!empty($sysLanguage)) { // check if field is in overlay if ($this->isFieldInTcaTable('pages_language_overlay', $fieldName)) { // Field is in pages language overlay $tableName = 'pages_language_overlay'; } } switch ($tableName) { case 'pages_language_overlay': // Update field in pages overlay (also logs update event and clear cache for this page) // check uid of pages language overlay $query = 'SELECT uid FROM pages_language_overlay WHERE pid = ' . (int)$pid . ' AND sys_language_uid = ' . (int)$sysLanguage; $overlayId = DatabaseUtility::getOne($query); if (empty($overlayId)) { // No access throw new AjaxException( 'message.error.no_language_overlay_found', '[0x4FBF3C05]', HttpUtility::HTTP_STATUS_BAD_REQUEST ); } // ################ // UPDATE // ################ $this->getDataHandler()->updateDB( 'pages_language_overlay', (int)$overlayId, array( $fieldName => $fieldValue ) ); break; case 'pages': // Update field in page (also logs update event and clear cache for this page) $this->getDataHandler()->updateDB( 'pages', (int)$pid, array( $fieldName => $fieldValue ) ); break; } return array(); }
php
public function updatePageTableField($pid, $sysLanguage, $fieldName, $fieldValue) { $tableName = 'pages'; if (!empty($sysLanguage)) { // check if field is in overlay if ($this->isFieldInTcaTable('pages_language_overlay', $fieldName)) { // Field is in pages language overlay $tableName = 'pages_language_overlay'; } } switch ($tableName) { case 'pages_language_overlay': // Update field in pages overlay (also logs update event and clear cache for this page) // check uid of pages language overlay $query = 'SELECT uid FROM pages_language_overlay WHERE pid = ' . (int)$pid . ' AND sys_language_uid = ' . (int)$sysLanguage; $overlayId = DatabaseUtility::getOne($query); if (empty($overlayId)) { // No access throw new AjaxException( 'message.error.no_language_overlay_found', '[0x4FBF3C05]', HttpUtility::HTTP_STATUS_BAD_REQUEST ); } // ################ // UPDATE // ################ $this->getDataHandler()->updateDB( 'pages_language_overlay', (int)$overlayId, array( $fieldName => $fieldValue ) ); break; case 'pages': // Update field in page (also logs update event and clear cache for this page) $this->getDataHandler()->updateDB( 'pages', (int)$pid, array( $fieldName => $fieldValue ) ); break; } return array(); }
[ "public", "function", "updatePageTableField", "(", "$", "pid", ",", "$", "sysLanguage", ",", "$", "fieldName", ",", "$", "fieldValue", ")", "{", "$", "tableName", "=", "'pages'", ";", "if", "(", "!", "empty", "(", "$", "sysLanguage", ")", ")", "{", "//...
Update field in page table @param integer $pid PID @param integer|NULL $sysLanguage System language id @param string $fieldName Field name @param string $fieldValue Field value @return array @throws AjaxException
[ "Update", "field", "in", "page", "table" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Dao/PageSeoDao.php#L249-L307
train
webdevops/TYPO3-metaseo
Classes/Controller/Ajax/SitemapController.php
SitemapController.executeIndex
protected function executeIndex() { // Init $rootPid = (int)$this->postVar['pid']; $offset = (int)$this->postVar['start']; $itemsPerPage = (int)$this->postVar['pagingSize']; $searchFulltext = trim((string)$this->postVar['criteriaFulltext']); $searchPageUid = trim((int)$this->postVar['criteriaPageUid']); $searchPageLanguage = trim((string)$this->postVar['criteriaPageLanguage']); $searchPageDepth = trim((string)$this->postVar['criteriaPageDepth']); $searchIsBlacklisted = (bool)trim((string)$this->postVar['criteriaIsBlacklisted']); // ############################ // Criteria // ############################ $where = array(); // Root pid limit $where[] = 's.page_rootpid = ' . (int)$rootPid; // Fulltext if (!empty($searchFulltext)) { $where[] = 's.page_url LIKE ' . DatabaseUtility::quote('%' . $searchFulltext . '%', 'tx_metaseo_sitemap'); } // Page id if (!empty($searchPageUid)) { $where[] = 's.page_uid = ' . (int)$searchPageUid; } // Language if ($searchPageLanguage != -1 && strlen($searchPageLanguage) >= 1) { $where[] = 's.page_language = ' . (int)$searchPageLanguage; } // Depth if ($searchPageDepth != -1 && strlen($searchPageDepth) >= 1) { $where[] = 's.page_depth = ' . (int)$searchPageDepth; } if ($searchIsBlacklisted) { $where[] = 's.is_blacklisted = 1'; } // Filter blacklisted page types $where[] = DatabaseUtility::conditionNotIn( 'p.doktype', SitemapUtility::getDoktypeBlacklist() ); // Build where $where = DatabaseUtility::buildCondition($where); // ############################ // Pager // ############################ // Fetch total count of items with this filter settings $query = 'SELECT COUNT(*) AS count FROM tx_metaseo_sitemap s INNER JOIN pages p ON p.uid = s.page_uid WHERE ' . $where; $itemCount = DatabaseUtility::getOne($query); // ############################ // Sort // ############################ // default sort $sort = 's.page_depth ASC, s.page_uid ASC'; if (!empty($this->sortField) && !empty($this->sortDir)) { // already filtered $sort = $this->sortField . ' ' . $this->sortDir; } // ############################ // Fetch sitemap // ############################ $query = 'SELECT s.uid, s.page_rootpid, s.page_uid, s.page_language, s.page_url, s.page_depth, s.page_type, s.is_blacklisted, p.tx_metaseo_is_exclude, FROM_UNIXTIME(s.tstamp) as tstamp, FROM_UNIXTIME(s.crdate) as crdate FROM tx_metaseo_sitemap s INNER JOIN pages p ON p.uid = s.page_uid WHERE ' . $where . ' ORDER BY ' . $sort . ' LIMIT ' . (int)$offset . ', ' . (int)$itemsPerPage; $list = DatabaseUtility::getAll($query); return array( 'results' => $itemCount, 'rows' => $list, ); }
php
protected function executeIndex() { // Init $rootPid = (int)$this->postVar['pid']; $offset = (int)$this->postVar['start']; $itemsPerPage = (int)$this->postVar['pagingSize']; $searchFulltext = trim((string)$this->postVar['criteriaFulltext']); $searchPageUid = trim((int)$this->postVar['criteriaPageUid']); $searchPageLanguage = trim((string)$this->postVar['criteriaPageLanguage']); $searchPageDepth = trim((string)$this->postVar['criteriaPageDepth']); $searchIsBlacklisted = (bool)trim((string)$this->postVar['criteriaIsBlacklisted']); // ############################ // Criteria // ############################ $where = array(); // Root pid limit $where[] = 's.page_rootpid = ' . (int)$rootPid; // Fulltext if (!empty($searchFulltext)) { $where[] = 's.page_url LIKE ' . DatabaseUtility::quote('%' . $searchFulltext . '%', 'tx_metaseo_sitemap'); } // Page id if (!empty($searchPageUid)) { $where[] = 's.page_uid = ' . (int)$searchPageUid; } // Language if ($searchPageLanguage != -1 && strlen($searchPageLanguage) >= 1) { $where[] = 's.page_language = ' . (int)$searchPageLanguage; } // Depth if ($searchPageDepth != -1 && strlen($searchPageDepth) >= 1) { $where[] = 's.page_depth = ' . (int)$searchPageDepth; } if ($searchIsBlacklisted) { $where[] = 's.is_blacklisted = 1'; } // Filter blacklisted page types $where[] = DatabaseUtility::conditionNotIn( 'p.doktype', SitemapUtility::getDoktypeBlacklist() ); // Build where $where = DatabaseUtility::buildCondition($where); // ############################ // Pager // ############################ // Fetch total count of items with this filter settings $query = 'SELECT COUNT(*) AS count FROM tx_metaseo_sitemap s INNER JOIN pages p ON p.uid = s.page_uid WHERE ' . $where; $itemCount = DatabaseUtility::getOne($query); // ############################ // Sort // ############################ // default sort $sort = 's.page_depth ASC, s.page_uid ASC'; if (!empty($this->sortField) && !empty($this->sortDir)) { // already filtered $sort = $this->sortField . ' ' . $this->sortDir; } // ############################ // Fetch sitemap // ############################ $query = 'SELECT s.uid, s.page_rootpid, s.page_uid, s.page_language, s.page_url, s.page_depth, s.page_type, s.is_blacklisted, p.tx_metaseo_is_exclude, FROM_UNIXTIME(s.tstamp) as tstamp, FROM_UNIXTIME(s.crdate) as crdate FROM tx_metaseo_sitemap s INNER JOIN pages p ON p.uid = s.page_uid WHERE ' . $where . ' ORDER BY ' . $sort . ' LIMIT ' . (int)$offset . ', ' . (int)$itemsPerPage; $list = DatabaseUtility::getAll($query); return array( 'results' => $itemCount, 'rows' => $list, ); }
[ "protected", "function", "executeIndex", "(", ")", "{", "// Init", "$", "rootPid", "=", "(", "int", ")", "$", "this", "->", "postVar", "[", "'pid'", "]", ";", "$", "offset", "=", "(", "int", ")", "$", "this", "->", "postVar", "[", "'start'", "]", "...
Return sitemap entry list for root tree @return array
[ "Return", "sitemap", "entry", "list", "for", "root", "tree" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Controller/Ajax/SitemapController.php#L66-L167
train
webdevops/TYPO3-metaseo
Classes/Controller/Ajax/SitemapController.php
SitemapController.executeDelete
protected function executeDelete() { $uidList = $this->postVar['uidList']; $rootPid = (int)$this->postVar['pid']; $uidList = DatabaseUtility::connection()->cleanIntArray($uidList); if (empty($uidList) || empty($rootPid)) { throw new AjaxException( 'message.warning.incomplete_data_received.message', '[0x4FBF3C11]', HttpUtility::HTTP_STATUS_BAD_REQUEST ); } $where = array(); $where[] = 'page_rootpid = ' . (int)$rootPid; $where[] = DatabaseUtility::conditionIn('uid', $uidList); $where = DatabaseUtility::buildCondition($where); $query = 'DELETE FROM tx_metaseo_sitemap WHERE ' . $where; DatabaseUtility::exec($query); return array(); }
php
protected function executeDelete() { $uidList = $this->postVar['uidList']; $rootPid = (int)$this->postVar['pid']; $uidList = DatabaseUtility::connection()->cleanIntArray($uidList); if (empty($uidList) || empty($rootPid)) { throw new AjaxException( 'message.warning.incomplete_data_received.message', '[0x4FBF3C11]', HttpUtility::HTTP_STATUS_BAD_REQUEST ); } $where = array(); $where[] = 'page_rootpid = ' . (int)$rootPid; $where[] = DatabaseUtility::conditionIn('uid', $uidList); $where = DatabaseUtility::buildCondition($where); $query = 'DELETE FROM tx_metaseo_sitemap WHERE ' . $where; DatabaseUtility::exec($query); return array(); }
[ "protected", "function", "executeDelete", "(", ")", "{", "$", "uidList", "=", "$", "this", "->", "postVar", "[", "'uidList'", "]", ";", "$", "rootPid", "=", "(", "int", ")", "$", "this", "->", "postVar", "[", "'pid'", "]", ";", "$", "uidList", "=", ...
Delete sitemap entries @return array @throws AjaxException
[ "Delete", "sitemap", "entries" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Controller/Ajax/SitemapController.php#L296-L322
train
webdevops/TYPO3-metaseo
Classes/Controller/Ajax/SitemapController.php
SitemapController.executeDeleteAll
protected function executeDeleteAll() { $rootPid = (int)$this->postVar['pid']; if (empty($rootPid)) { throw new AjaxException( 'message.warning.incomplete_data_received.message', '[0x4FBF3C12]', HttpUtility::HTTP_STATUS_BAD_REQUEST ); } $where = array(); $where[] = 'page_rootpid = ' . (int)$rootPid; $where = DatabaseUtility::buildCondition($where); $query = 'DELETE FROM tx_metaseo_sitemap WHERE ' . $where; DatabaseUtility::exec($query); return array(); }
php
protected function executeDeleteAll() { $rootPid = (int)$this->postVar['pid']; if (empty($rootPid)) { throw new AjaxException( 'message.warning.incomplete_data_received.message', '[0x4FBF3C12]', HttpUtility::HTTP_STATUS_BAD_REQUEST ); } $where = array(); $where[] = 'page_rootpid = ' . (int)$rootPid; $where = DatabaseUtility::buildCondition($where); $query = 'DELETE FROM tx_metaseo_sitemap WHERE ' . $where; DatabaseUtility::exec($query); return array(); }
[ "protected", "function", "executeDeleteAll", "(", ")", "{", "$", "rootPid", "=", "(", "int", ")", "$", "this", "->", "postVar", "[", "'pid'", "]", ";", "if", "(", "empty", "(", "$", "rootPid", ")", ")", "{", "throw", "new", "AjaxException", "(", "'me...
Delete all sitemap entries @return array @throws AjaxException
[ "Delete", "all", "sitemap", "entries" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Controller/Ajax/SitemapController.php#L347-L369
train
webdevops/TYPO3-metaseo
class.ext_update.php
ext_update.renameDatabaseTableField
protected function renameDatabaseTableField($table, $oldFieldName, $newFieldName) { $title = 'Renaming "' . $table . ':' . $oldFieldName . '" to "' . $table . ':' . $newFieldName . '": '; $currentTableFields = $this->databaseConnection->admin_get_fields($table); if ($currentTableFields[$newFieldName]) { $message = 'Field ' . $table . ':' . $newFieldName . ' already existing.'; $status = FlashMessage::OK; } else { if (!$currentTableFields[$oldFieldName]) { $message = 'Field ' . $table . ':' . $oldFieldName . ' not existing'; $status = FlashMessage::ERROR; } else { $sql = 'ALTER TABLE ' . $table . ' CHANGE COLUMN ' . $oldFieldName . ' ' . $newFieldName . ' ' . $currentTableFields[$oldFieldName]['Type']; if ($this->databaseConnection->admin_query($sql) === false) { $message = ' SQL ERROR: ' . $this->databaseConnection->sql_error(); $status = FlashMessage::ERROR; } else { $message = 'OK!'; $status = FlashMessage::OK; } } } $this->addMessage($status, $title, $message); return $status; }
php
protected function renameDatabaseTableField($table, $oldFieldName, $newFieldName) { $title = 'Renaming "' . $table . ':' . $oldFieldName . '" to "' . $table . ':' . $newFieldName . '": '; $currentTableFields = $this->databaseConnection->admin_get_fields($table); if ($currentTableFields[$newFieldName]) { $message = 'Field ' . $table . ':' . $newFieldName . ' already existing.'; $status = FlashMessage::OK; } else { if (!$currentTableFields[$oldFieldName]) { $message = 'Field ' . $table . ':' . $oldFieldName . ' not existing'; $status = FlashMessage::ERROR; } else { $sql = 'ALTER TABLE ' . $table . ' CHANGE COLUMN ' . $oldFieldName . ' ' . $newFieldName . ' ' . $currentTableFields[$oldFieldName]['Type']; if ($this->databaseConnection->admin_query($sql) === false) { $message = ' SQL ERROR: ' . $this->databaseConnection->sql_error(); $status = FlashMessage::ERROR; } else { $message = 'OK!'; $status = FlashMessage::OK; } } } $this->addMessage($status, $title, $message); return $status; }
[ "protected", "function", "renameDatabaseTableField", "(", "$", "table", ",", "$", "oldFieldName", ",", "$", "newFieldName", ")", "{", "$", "title", "=", "'Renaming \"'", ".", "$", "table", ".", "':'", ".", "$", "oldFieldName", ".", "'\" to \"'", ".", "$", ...
Renames a tabled field and does some plausibility checks. @param string $table @param string $oldFieldName @param string $newFieldName @return int
[ "Renames", "a", "tabled", "field", "and", "does", "some", "plausibility", "checks", "." ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/class.ext_update.php#L219-L249
train
webdevops/TYPO3-metaseo
Classes/Utility/BackendUtility.php
BackendUtility.getRootPageSettingList
public static function getRootPageSettingList() { static $cache = null; if ($cache === null) { $query = 'SELECT seosr.* FROM tx_metaseo_setting_root seosr INNER JOIN pages p ON p.uid = seosr.pid AND p.is_siteroot = 1 AND p.deleted = 0 WHERE seosr.deleted = 0'; $cache = DatabaseUtility::getAllWithIndex($query, 'pid'); } return $cache; }
php
public static function getRootPageSettingList() { static $cache = null; if ($cache === null) { $query = 'SELECT seosr.* FROM tx_metaseo_setting_root seosr INNER JOIN pages p ON p.uid = seosr.pid AND p.is_siteroot = 1 AND p.deleted = 0 WHERE seosr.deleted = 0'; $cache = DatabaseUtility::getAllWithIndex($query, 'pid'); } return $cache; }
[ "public", "static", "function", "getRootPageSettingList", "(", ")", "{", "static", "$", "cache", "=", "null", ";", "if", "(", "$", "cache", "===", "null", ")", "{", "$", "query", "=", "'SELECT seosr.*\n FROM tx_metaseo_setting_root seosr\n ...
Fetch list of setting entries @return array
[ "Fetch", "list", "of", "setting", "entries" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/BackendUtility.php#L62-L78
train
webdevops/TYPO3-metaseo
Classes/Utility/TypoScript.php
TypoScript.getNode
public function getNode($tsNodePath) { $ret = null; // extract TypoScript-path information $nodeSections = explode('.', $tsNodePath); $nodeValueType = end($nodeSections); $nodeValueName = end($nodeSections) . '.'; // remove last node from sections because we already got the node name unset($nodeSections[key($nodeSections)]); // walk though array to find node $nodeData = $this->tsData; if (!empty($nodeSections) && is_array($nodeSections)) { foreach ($nodeSections as $sectionName) { $sectionName .= '.'; if (is_array($nodeData) && array_key_exists($sectionName, $nodeData)) { $nodeData = $nodeData[$sectionName]; } else { break; } } } // Fetch TypoScript configuration data $tsData = array(); if (is_array($nodeData) && array_key_exists($nodeValueName, $nodeData)) { $tsData = $nodeData[$nodeValueName]; } // Fetch TypoScript configuration type $tsType = null; if (is_array($nodeData) && array_key_exists($nodeValueType, $nodeData)) { $tsType = $nodeData[$nodeValueType]; } // Clone object and set values $ret = clone $this; $ret->tsData = $tsData; $ret->tsType = $tsType; $ret->iteratorPosition = false; return $ret; }
php
public function getNode($tsNodePath) { $ret = null; // extract TypoScript-path information $nodeSections = explode('.', $tsNodePath); $nodeValueType = end($nodeSections); $nodeValueName = end($nodeSections) . '.'; // remove last node from sections because we already got the node name unset($nodeSections[key($nodeSections)]); // walk though array to find node $nodeData = $this->tsData; if (!empty($nodeSections) && is_array($nodeSections)) { foreach ($nodeSections as $sectionName) { $sectionName .= '.'; if (is_array($nodeData) && array_key_exists($sectionName, $nodeData)) { $nodeData = $nodeData[$sectionName]; } else { break; } } } // Fetch TypoScript configuration data $tsData = array(); if (is_array($nodeData) && array_key_exists($nodeValueName, $nodeData)) { $tsData = $nodeData[$nodeValueName]; } // Fetch TypoScript configuration type $tsType = null; if (is_array($nodeData) && array_key_exists($nodeValueType, $nodeData)) { $tsType = $nodeData[$nodeValueType]; } // Clone object and set values $ret = clone $this; $ret->tsData = $tsData; $ret->tsType = $tsType; $ret->iteratorPosition = false; return $ret; }
[ "public", "function", "getNode", "(", "$", "tsNodePath", ")", "{", "$", "ret", "=", "null", ";", "// extract TypoScript-path information", "$", "nodeSections", "=", "explode", "(", "'.'", ",", "$", "tsNodePath", ")", ";", "$", "nodeValueType", "=", "end", "(...
Get TypoScript subnode @param string $tsNodePath TypoScript node-path @return TypoScript TypoScript subnode-object
[ "Get", "TypoScript", "subnode" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/TypoScript.php#L137-L182
train
webdevops/TYPO3-metaseo
Classes/Utility/TypoScript.php
TypoScript.iteratorNextNode
public function iteratorNextNode() { // INIT $iteratorPosition = null; $this->iteratorPosition = false; $nextNode = false; do { if ($nextNode) { next($this->tsData); } $currentNode = current($this->tsData); if ($currentNode !== false) { // get key $iteratorPosition = key($this->tsData); // check if node is subnode or value if (substr($iteratorPosition, -1) == '.') { // next subnode fond $this->iteratorPosition = $iteratorPosition; break; } } else { $iteratorPosition = false; $this->iteratorPosition = false; } $nextNode = true; } while ($iteratorPosition !== false); }
php
public function iteratorNextNode() { // INIT $iteratorPosition = null; $this->iteratorPosition = false; $nextNode = false; do { if ($nextNode) { next($this->tsData); } $currentNode = current($this->tsData); if ($currentNode !== false) { // get key $iteratorPosition = key($this->tsData); // check if node is subnode or value if (substr($iteratorPosition, -1) == '.') { // next subnode fond $this->iteratorPosition = $iteratorPosition; break; } } else { $iteratorPosition = false; $this->iteratorPosition = false; } $nextNode = true; } while ($iteratorPosition !== false); }
[ "public", "function", "iteratorNextNode", "(", ")", "{", "// INIT", "$", "iteratorPosition", "=", "null", ";", "$", "this", "->", "iteratorPosition", "=", "false", ";", "$", "nextNode", "=", "false", ";", "do", "{", "if", "(", "$", "nextNode", ")", "{", ...
Search next iterator node
[ "Search", "next", "iterator", "node" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/TypoScript.php#L200-L231
train
webdevops/TYPO3-metaseo
Classes/Utility/TypoScript.php
TypoScript.getValue
public function getValue($tsNodePath, $defaultValue = null) { $ret = $defaultValue; // extract TypoScript-path information $nodeFound = true; $nodeSections = explode('.', $tsNodePath); $nodeValueName = end($nodeSections); // remove last node from sections because we already got the node name unset($nodeSections[key($nodeSections)]); // walk though array to find node $nodeData = $this->tsData; if (!empty($nodeSections) && is_array($nodeSections)) { foreach ($nodeSections as $sectionName) { $sectionName .= '.'; if (is_array($nodeData) && array_key_exists($sectionName, $nodeData)) { $nodeData = $nodeData[$sectionName]; } else { $nodeFound = false; break; } } } // check if we got the value of the node if ($nodeFound && is_array($nodeData) && array_key_exists($nodeValueName, $nodeData)) { $ret = $nodeData[$nodeValueName]; } return $ret; }
php
public function getValue($tsNodePath, $defaultValue = null) { $ret = $defaultValue; // extract TypoScript-path information $nodeFound = true; $nodeSections = explode('.', $tsNodePath); $nodeValueName = end($nodeSections); // remove last node from sections because we already got the node name unset($nodeSections[key($nodeSections)]); // walk though array to find node $nodeData = $this->tsData; if (!empty($nodeSections) && is_array($nodeSections)) { foreach ($nodeSections as $sectionName) { $sectionName .= '.'; if (is_array($nodeData) && array_key_exists($sectionName, $nodeData)) { $nodeData = $nodeData[$sectionName]; } else { $nodeFound = false; break; } } } // check if we got the value of the node if ($nodeFound && is_array($nodeData) && array_key_exists($nodeValueName, $nodeData)) { $ret = $nodeData[$nodeValueName]; } return $ret; }
[ "public", "function", "getValue", "(", "$", "tsNodePath", ",", "$", "defaultValue", "=", "null", ")", "{", "$", "ret", "=", "$", "defaultValue", ";", "// extract TypoScript-path information", "$", "nodeFound", "=", "true", ";", "$", "nodeSections", "=", "explo...
Get value from node @param string $tsNodePath TypoScript node-path @param mixed $defaultValue Default value @return mixed Node value (or default value)
[ "Get", "value", "from", "node" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/TypoScript.php#L241-L275
train
webdevops/TYPO3-metaseo
Classes/Utility/TypoScript.php
TypoScript.getCObj
protected function getCObj() { if ($this->cObj === null) { $this->cObj = Typo3GeneralUtility::makeInstance( 'TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer' ); } return $this->cObj; }
php
protected function getCObj() { if ($this->cObj === null) { $this->cObj = Typo3GeneralUtility::makeInstance( 'TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer' ); } return $this->cObj; }
[ "protected", "function", "getCObj", "(", ")", "{", "if", "(", "$", "this", "->", "cObj", "===", "null", ")", "{", "$", "this", "->", "cObj", "=", "Typo3GeneralUtility", "::", "makeInstance", "(", "'TYPO3\\\\CMS\\\\Frontend\\\\ContentObject\\\\ContentObjectRenderer'"...
Return instance of \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer @return \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
[ "Return", "instance", "of", "\\", "TYPO3", "\\", "CMS", "\\", "Frontend", "\\", "ContentObject", "\\", "ContentObjectRenderer" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/TypoScript.php#L329-L338
train
webdevops/TYPO3-metaseo
Classes/Utility/RootPageUtility.php
RootPageUtility.getFrontendUrl
public static function getFrontendUrl($rootPid, $typeNum) { $domain = self::getDomain($rootPid); if (!empty($domain)) { $domain = 'http://' . $domain . '/'; } else { $domain = Typo3GeneralUtility::getIndpEnv('TYPO3_SITE_URL'); } $url = $domain . 'index.php?id=' . (int)$rootPid . '&type=' . (int)$typeNum; return $url; }
php
public static function getFrontendUrl($rootPid, $typeNum) { $domain = self::getDomain($rootPid); if (!empty($domain)) { $domain = 'http://' . $domain . '/'; } else { $domain = Typo3GeneralUtility::getIndpEnv('TYPO3_SITE_URL'); } $url = $domain . 'index.php?id=' . (int)$rootPid . '&type=' . (int)$typeNum; return $url; }
[ "public", "static", "function", "getFrontendUrl", "(", "$", "rootPid", ",", "$", "typeNum", ")", "{", "$", "domain", "=", "self", "::", "getDomain", "(", "$", "rootPid", ")", ";", "if", "(", "!", "empty", "(", "$", "domain", ")", ")", "{", "$", "do...
Build a frontend url @param integer $rootPid Root Page ID @param integer $typeNum Type num @return string
[ "Build", "a", "frontend", "url" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/RootPageUtility.php#L68-L79
train
webdevops/TYPO3-metaseo
Classes/Controller/Ajax/PageSeo/PageTitleSimController.php
PageTitleSimController.simulateTitle
protected function simulateTitle(array $page, $sysLanguage) { $this->getFrontendUtility()->initTsfe($page, null, $page, null, $sysLanguage); $pagetitle = $this->objectManager->get('Metaseo\\Metaseo\\Page\\Part\\PagetitlePart'); $ret = $pagetitle->main($page['title']); return $ret; }
php
protected function simulateTitle(array $page, $sysLanguage) { $this->getFrontendUtility()->initTsfe($page, null, $page, null, $sysLanguage); $pagetitle = $this->objectManager->get('Metaseo\\Metaseo\\Page\\Part\\PagetitlePart'); $ret = $pagetitle->main($page['title']); return $ret; }
[ "protected", "function", "simulateTitle", "(", "array", "$", "page", ",", "$", "sysLanguage", ")", "{", "$", "this", "->", "getFrontendUtility", "(", ")", "->", "initTsfe", "(", "$", "page", ",", "null", ",", "$", "page", ",", "null", ",", "$", "sysLan...
Generate simulated page title @param array $page Page @param integer $sysLanguage System language @return string
[ "Generate", "simulated", "page", "title" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Controller/Ajax/PageSeo/PageTitleSimController.php#L84-L92
train
webdevops/TYPO3-metaseo
Classes/Page/Part/MetatagPart.php
MetatagPart.initExtensionSupportNews
protected function initExtensionSupportNews() { if (empty($GLOBALS['TSFE']->register)) { return; } /** @var \Metaseo\Metaseo\Connector $connector */ $connector = $this->objectManager->get('Metaseo\\Metaseo\\Connector'); if (isset($GLOBALS['TSFE']->register['newsTitle'])) { $connector->setMetaTag('title', $GLOBALS['TSFE']->register['newsTitle']); } if (isset($GLOBALS['TSFE']->register['newsAuthor'])) { $connector->setMetaTag('author', $GLOBALS['TSFE']->register['newsAuthor']); } if (isset($GLOBALS['TSFE']->register['newsAuthoremail'])) { $connector->setMetaTag('email', $GLOBALS['TSFE']->register['newsAuthoremail']); } if (isset($GLOBALS['TSFE']->register['newsAuthorEmail'])) { $connector->setMetaTag('email', $GLOBALS['TSFE']->register['newsAuthorEmail']); } if (isset($GLOBALS['TSFE']->register['newsKeywords'])) { $connector->setMetaTag('keywords', $GLOBALS['TSFE']->register['newsKeywords']); } if (isset($GLOBALS['TSFE']->register['newsTeaser'])) { $connector->setMetaTag('description', $GLOBALS['TSFE']->register['newsTeaser']); } }
php
protected function initExtensionSupportNews() { if (empty($GLOBALS['TSFE']->register)) { return; } /** @var \Metaseo\Metaseo\Connector $connector */ $connector = $this->objectManager->get('Metaseo\\Metaseo\\Connector'); if (isset($GLOBALS['TSFE']->register['newsTitle'])) { $connector->setMetaTag('title', $GLOBALS['TSFE']->register['newsTitle']); } if (isset($GLOBALS['TSFE']->register['newsAuthor'])) { $connector->setMetaTag('author', $GLOBALS['TSFE']->register['newsAuthor']); } if (isset($GLOBALS['TSFE']->register['newsAuthoremail'])) { $connector->setMetaTag('email', $GLOBALS['TSFE']->register['newsAuthoremail']); } if (isset($GLOBALS['TSFE']->register['newsAuthorEmail'])) { $connector->setMetaTag('email', $GLOBALS['TSFE']->register['newsAuthorEmail']); } if (isset($GLOBALS['TSFE']->register['newsKeywords'])) { $connector->setMetaTag('keywords', $GLOBALS['TSFE']->register['newsKeywords']); } if (isset($GLOBALS['TSFE']->register['newsTeaser'])) { $connector->setMetaTag('description', $GLOBALS['TSFE']->register['newsTeaser']); } }
[ "protected", "function", "initExtensionSupportNews", "(", ")", "{", "if", "(", "empty", "(", "$", "GLOBALS", "[", "'TSFE'", "]", "->", "register", ")", ")", "{", "return", ";", "}", "/** @var \\Metaseo\\Metaseo\\Connector $connector */", "$", "connector", "=", "...
Init extension support for "news" extension
[ "Init", "extension", "support", "for", "news", "extension" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Page/Part/MetatagPart.php#L258-L290
train
webdevops/TYPO3-metaseo
Classes/Page/Part/MetatagPart.php
MetatagPart.applyStdWrap
protected function applyStdWrap($key, $value) { $key .= '.'; if (empty($this->stdWrapList[$key])) { return $value; } return $this->cObj->stdWrap($value, $this->stdWrapList[$key]); }
php
protected function applyStdWrap($key, $value) { $key .= '.'; if (empty($this->stdWrapList[$key])) { return $value; } return $this->cObj->stdWrap($value, $this->stdWrapList[$key]); }
[ "protected", "function", "applyStdWrap", "(", "$", "key", ",", "$", "value", ")", "{", "$", "key", ".=", "'.'", ";", "if", "(", "empty", "(", "$", "this", "->", "stdWrapList", "[", "$", "key", "]", ")", ")", "{", "return", "$", "value", ";", "}",...
Process stdWrap from stdWrap list @param string $key StdWrap-List key @param string $value Value @return string
[ "Process", "stdWrap", "from", "stdWrap", "list" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Page/Part/MetatagPart.php#L300-L309
train
webdevops/TYPO3-metaseo
Classes/Page/Part/MetatagPart.php
MetatagPart.isXhtml
protected function isXhtml() { $ret = false; if (strpos($GLOBALS['TSFE']->config['config']['doctype'], 'xhtml') !== false) { // doctype xhtml $ret = true; } if (strpos($GLOBALS['TSFE']->config['config']['xhtmlDoctype'], 'xhtml') !== false) { // doctype xhtml doctype $ret = true; } return $ret; }
php
protected function isXhtml() { $ret = false; if (strpos($GLOBALS['TSFE']->config['config']['doctype'], 'xhtml') !== false) { // doctype xhtml $ret = true; } if (strpos($GLOBALS['TSFE']->config['config']['xhtmlDoctype'], 'xhtml') !== false) { // doctype xhtml doctype $ret = true; } return $ret; }
[ "protected", "function", "isXhtml", "(", ")", "{", "$", "ret", "=", "false", ";", "if", "(", "strpos", "(", "$", "GLOBALS", "[", "'TSFE'", "]", "->", "config", "[", "'config'", "]", "[", "'doctype'", "]", ",", "'xhtml'", ")", "!==", "false", ")", "...
Check if page is configured as XHTML @return bool
[ "Check", "if", "page", "is", "configured", "as", "XHTML" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Page/Part/MetatagPart.php#L326-L341
train
webdevops/TYPO3-metaseo
Classes/Page/Part/MetatagPart.php
MetatagPart.generateLink
protected function generateLink($url, array $conf = null, $disableMP = false) { if ($conf === null) { $conf = array(); } $mpOldConfValue = $GLOBALS['TSFE']->config['config']['MP_disableTypolinkClosestMPvalue']; if ($disableMP === true) { // Disable MP usage in typolink - link to the real page instead $GLOBALS['TSFE']->config['config']['MP_disableTypolinkClosestMPvalue'] = 1; } $conf['parameter'] = $url; $ret = $this->cObj->typoLink_URL($conf); // maybe baseUrlWrap is better? but breaks with realurl currently? $ret = GeneralUtility::fullUrl($ret); if ($disableMP === true) { // Restore old MP linking configuration $GLOBALS['TSFE']->config['config']['MP_disableTypolinkClosestMPvalue'] = $mpOldConfValue; } return $ret; }
php
protected function generateLink($url, array $conf = null, $disableMP = false) { if ($conf === null) { $conf = array(); } $mpOldConfValue = $GLOBALS['TSFE']->config['config']['MP_disableTypolinkClosestMPvalue']; if ($disableMP === true) { // Disable MP usage in typolink - link to the real page instead $GLOBALS['TSFE']->config['config']['MP_disableTypolinkClosestMPvalue'] = 1; } $conf['parameter'] = $url; $ret = $this->cObj->typoLink_URL($conf); // maybe baseUrlWrap is better? but breaks with realurl currently? $ret = GeneralUtility::fullUrl($ret); if ($disableMP === true) { // Restore old MP linking configuration $GLOBALS['TSFE']->config['config']['MP_disableTypolinkClosestMPvalue'] = $mpOldConfValue; } return $ret; }
[ "protected", "function", "generateLink", "(", "$", "url", ",", "array", "$", "conf", "=", "null", ",", "$", "disableMP", "=", "false", ")", "{", "if", "(", "$", "conf", "===", "null", ")", "{", "$", "conf", "=", "array", "(", ")", ";", "}", "$", ...
Generate a link via TYPO3-Api @param integer|string $url URL (id or string) @param array|NULL $conf URL configuration @param boolean $disableMP Disable mountpoint linking @return string URL
[ "Generate", "a", "link", "via", "TYPO3", "-", "Api" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Page/Part/MetatagPart.php#L353-L377
train
webdevops/TYPO3-metaseo
Classes/Page/Part/MetatagPart.php
MetatagPart.detectCanonicalPage
protected function detectCanonicalPage(array $tsConfig = array()) { ##################### # Fetch typoscript config ##################### $strictMode = (bool)(int)$tsConfig['strict']; $noMpMode = (bool)(int)$tsConfig['noMP']; $linkConf = !empty($tsConfig['typolink.']) ? $tsConfig['typolink.'] : array(); $blacklist = !empty($tsConfig['blacklist.']) ? $tsConfig['blacklist.'] : array(); $linkParam = null; $linkMpMode = false; // Init link configuration if ($linkConf === null) { $linkConf = array(); } // Fetch chash $pageHash = null; if (!empty($GLOBALS['TSFE']->cHash)) { $pageHash = $GLOBALS['TSFE']->cHash; } ##################### # Blacklisting ##################### if (FrontendUtility::checkPageForBlacklist($blacklist)) { if ($strictMode) { if ($noMpMode && GeneralUtility::isMountpointInRootLine()) { // Mountpoint detected $linkParam = $GLOBALS['TSFE']->id; // Force removing of MP param $linkConf['addQueryString'] = 1; if (!empty($linkConf['addQueryString.']['exclude'])) { $linkConf['addQueryString.']['exclude'] .= ',id,MP,no_cache'; } else { $linkConf['addQueryString.']['exclude'] = ',id,MP,no_cache'; } // disable mount point linking $linkMpMode = true; } else { // force canonical-url to page url (without any parameters) $linkParam = $GLOBALS['TSFE']->id; } } else { // Blacklisted and no strict mode, we don't output canonical tag return null; } } ##################### # No cached pages ##################### if (!empty($GLOBALS['TSFE']->no_cache)) { if ($strictMode) { // force canonical-url to page url (without any parameters) $linkParam = $GLOBALS['TSFE']->id; } } ##################### # Content from PID ##################### if (!$linkParam && !empty($this->cObj->data['content_from_pid'])) { $linkParam = $this->cObj->data['content_from_pid']; } ##################### # Mountpoint ##################### if (!$linkParam && $noMpMode && GeneralUtility::isMountpointInRootLine()) { // Mountpoint detected $linkParam = $GLOBALS['TSFE']->id; // Force removing of MP param $linkConf['addQueryString'] = 1; if (!empty($linkConf['addQueryString.']['exclude'])) { $linkConf['addQueryString.']['exclude'] .= ',id,MP,no_cache'; } else { $linkConf['addQueryString.']['exclude'] = ',id,MP,no_cache'; } // disable mount point linking $linkMpMode = true; } ##################### # Normal page ##################### if (!$linkParam) { // Fetch pageUrl if ($pageHash !== null) { // Virtual plugin page, we have to use anchor or site script $linkParam = FrontendUtility::getCurrentUrl(); } else { $linkParam = $GLOBALS['TSFE']->id; } } ##################### # Fallback ##################### if ($strictMode && empty($linkParam)) { $linkParam = $GLOBALS['TSFE']->id; } return array($linkParam, $linkConf, $linkMpMode); }
php
protected function detectCanonicalPage(array $tsConfig = array()) { ##################### # Fetch typoscript config ##################### $strictMode = (bool)(int)$tsConfig['strict']; $noMpMode = (bool)(int)$tsConfig['noMP']; $linkConf = !empty($tsConfig['typolink.']) ? $tsConfig['typolink.'] : array(); $blacklist = !empty($tsConfig['blacklist.']) ? $tsConfig['blacklist.'] : array(); $linkParam = null; $linkMpMode = false; // Init link configuration if ($linkConf === null) { $linkConf = array(); } // Fetch chash $pageHash = null; if (!empty($GLOBALS['TSFE']->cHash)) { $pageHash = $GLOBALS['TSFE']->cHash; } ##################### # Blacklisting ##################### if (FrontendUtility::checkPageForBlacklist($blacklist)) { if ($strictMode) { if ($noMpMode && GeneralUtility::isMountpointInRootLine()) { // Mountpoint detected $linkParam = $GLOBALS['TSFE']->id; // Force removing of MP param $linkConf['addQueryString'] = 1; if (!empty($linkConf['addQueryString.']['exclude'])) { $linkConf['addQueryString.']['exclude'] .= ',id,MP,no_cache'; } else { $linkConf['addQueryString.']['exclude'] = ',id,MP,no_cache'; } // disable mount point linking $linkMpMode = true; } else { // force canonical-url to page url (without any parameters) $linkParam = $GLOBALS['TSFE']->id; } } else { // Blacklisted and no strict mode, we don't output canonical tag return null; } } ##################### # No cached pages ##################### if (!empty($GLOBALS['TSFE']->no_cache)) { if ($strictMode) { // force canonical-url to page url (without any parameters) $linkParam = $GLOBALS['TSFE']->id; } } ##################### # Content from PID ##################### if (!$linkParam && !empty($this->cObj->data['content_from_pid'])) { $linkParam = $this->cObj->data['content_from_pid']; } ##################### # Mountpoint ##################### if (!$linkParam && $noMpMode && GeneralUtility::isMountpointInRootLine()) { // Mountpoint detected $linkParam = $GLOBALS['TSFE']->id; // Force removing of MP param $linkConf['addQueryString'] = 1; if (!empty($linkConf['addQueryString.']['exclude'])) { $linkConf['addQueryString.']['exclude'] .= ',id,MP,no_cache'; } else { $linkConf['addQueryString.']['exclude'] = ',id,MP,no_cache'; } // disable mount point linking $linkMpMode = true; } ##################### # Normal page ##################### if (!$linkParam) { // Fetch pageUrl if ($pageHash !== null) { // Virtual plugin page, we have to use anchor or site script $linkParam = FrontendUtility::getCurrentUrl(); } else { $linkParam = $GLOBALS['TSFE']->id; } } ##################### # Fallback ##################### if ($strictMode && empty($linkParam)) { $linkParam = $GLOBALS['TSFE']->id; } return array($linkParam, $linkConf, $linkMpMode); }
[ "protected", "function", "detectCanonicalPage", "(", "array", "$", "tsConfig", "=", "array", "(", ")", ")", "{", "#####################", "# Fetch typoscript config", "#####################", "$", "strictMode", "=", "(", "bool", ")", "(", "int", ")", "$", "tsConfi...
Detect canonical page @param array $tsConfig TypoScript config setup @return null|array of (linkParam, linkConf, linkMpMode)
[ "Detect", "canonical", "page" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Page/Part/MetatagPart.php#L386-L501
train
webdevops/TYPO3-metaseo
Classes/Page/Part/MetatagPart.php
MetatagPart.advMetaTags
protected function advMetaTags(array &$metaTags, array $pageRecord, $sysLanguageId, array $customMetaTagList) { $pageRecordId = $pageRecord['uid']; $storeMeta = $this->getStoreMeta(); $advMetaTagCondition = array(); // ################# // External Og tags (from connector) // ################# if ($this->isAvailableExternalOgTags()) { // External OpenGraph support $advMetaTagCondition[] = 'tag_name NOT LIKE \'og:%\''; if (!empty($storeMeta['meta:og'])) { //overwrite known og tags $externalOgTags = $storeMeta['meta:og']; foreach ($externalOgTags as $tagName => $tagValue) { if (array_key_exists('og.' . $tagName, $metaTags)) { //_only_ known og tags $metaTags['og.' . $tagName] = array( 'tag' => 'meta', 'attributes' => array( 'property' => 'og:' . $tagName, 'content' => $tagValue, ), ); } } } } if ($this->isAvailableExternalOgCustomTags()) { $ogTagKeys = array(); if (!empty($storeMeta['custom:og'])) { $externalCustomOgTags = $storeMeta['custom:og']; foreach ($externalCustomOgTags as $tagName => $tagValue) { //take all tags $metaTags['og.' . $tagName] = array( 'tag' => 'meta', 'attributes' => array( 'property' => 'og:' . $tagName, 'content' => $tagValue, ), ); $ogTagKeys[] = 'og:' . $tagName; } } $advMetaTagCondition[] = DatabaseUtility::conditionNotIn('tag_name', $ogTagKeys, true); } // ################# // Adv meta tags (from editor) // ################# if (!empty($advMetaTagCondition)) { $advMetaTagCondition = '( ' . implode(') AND (', $advMetaTagCondition) . ' )'; } else { $advMetaTagCondition = '1=1'; } // Fetch list of meta tags from database $query = 'SELECT tag_name, tag_value FROM tx_metaseo_metatag WHERE pid = ' . (int)$pageRecordId . ' AND sys_language_uid = ' . (int)$sysLanguageId . ' AND ' . $advMetaTagCondition; $advMetaTagList = DatabaseUtility::getList($query); // Add metadata to tag list foreach ($advMetaTagList as $tagName => $tagValue) { if (substr($tagName, 0, 3) === 'og:') { $metaTags['og.' . $tagName] = array( 'tag' => 'meta', 'attributes' => array( 'property' => $tagName, 'content' => $tagValue, ), ); } else { $metaTags['adv.' . $tagName] = array( 'tag' => 'meta', 'attributes' => array( 'rel' => $tagName, //see https://github.com/webdevops/TYPO3-metaseo/issues/464 'href' => $tagValue, ), ); } } // ################# // Custom meta tags (from connector) // ################# foreach ($customMetaTagList as $tagName => $tagValue) { $metaTags['adv.' . $tagName] = array( 'tag' => 'meta', 'attributes' => array( 'rel' => $tagName, //see https://github.com/webdevops/TYPO3-metaseo/issues/464 'href' => $tagValue, ), ); } }
php
protected function advMetaTags(array &$metaTags, array $pageRecord, $sysLanguageId, array $customMetaTagList) { $pageRecordId = $pageRecord['uid']; $storeMeta = $this->getStoreMeta(); $advMetaTagCondition = array(); // ################# // External Og tags (from connector) // ################# if ($this->isAvailableExternalOgTags()) { // External OpenGraph support $advMetaTagCondition[] = 'tag_name NOT LIKE \'og:%\''; if (!empty($storeMeta['meta:og'])) { //overwrite known og tags $externalOgTags = $storeMeta['meta:og']; foreach ($externalOgTags as $tagName => $tagValue) { if (array_key_exists('og.' . $tagName, $metaTags)) { //_only_ known og tags $metaTags['og.' . $tagName] = array( 'tag' => 'meta', 'attributes' => array( 'property' => 'og:' . $tagName, 'content' => $tagValue, ), ); } } } } if ($this->isAvailableExternalOgCustomTags()) { $ogTagKeys = array(); if (!empty($storeMeta['custom:og'])) { $externalCustomOgTags = $storeMeta['custom:og']; foreach ($externalCustomOgTags as $tagName => $tagValue) { //take all tags $metaTags['og.' . $tagName] = array( 'tag' => 'meta', 'attributes' => array( 'property' => 'og:' . $tagName, 'content' => $tagValue, ), ); $ogTagKeys[] = 'og:' . $tagName; } } $advMetaTagCondition[] = DatabaseUtility::conditionNotIn('tag_name', $ogTagKeys, true); } // ################# // Adv meta tags (from editor) // ################# if (!empty($advMetaTagCondition)) { $advMetaTagCondition = '( ' . implode(') AND (', $advMetaTagCondition) . ' )'; } else { $advMetaTagCondition = '1=1'; } // Fetch list of meta tags from database $query = 'SELECT tag_name, tag_value FROM tx_metaseo_metatag WHERE pid = ' . (int)$pageRecordId . ' AND sys_language_uid = ' . (int)$sysLanguageId . ' AND ' . $advMetaTagCondition; $advMetaTagList = DatabaseUtility::getList($query); // Add metadata to tag list foreach ($advMetaTagList as $tagName => $tagValue) { if (substr($tagName, 0, 3) === 'og:') { $metaTags['og.' . $tagName] = array( 'tag' => 'meta', 'attributes' => array( 'property' => $tagName, 'content' => $tagValue, ), ); } else { $metaTags['adv.' . $tagName] = array( 'tag' => 'meta', 'attributes' => array( 'rel' => $tagName, //see https://github.com/webdevops/TYPO3-metaseo/issues/464 'href' => $tagValue, ), ); } } // ################# // Custom meta tags (from connector) // ################# foreach ($customMetaTagList as $tagName => $tagValue) { $metaTags['adv.' . $tagName] = array( 'tag' => 'meta', 'attributes' => array( 'rel' => $tagName, //see https://github.com/webdevops/TYPO3-metaseo/issues/464 'href' => $tagValue, ), ); } }
[ "protected", "function", "advMetaTags", "(", "array", "&", "$", "metaTags", ",", "array", "$", "pageRecord", ",", "$", "sysLanguageId", ",", "array", "$", "customMetaTagList", ")", "{", "$", "pageRecordId", "=", "$", "pageRecord", "[", "'uid'", "]", ";", "...
Advanced meta tags @param array $metaTags MetaTags @param array $pageRecord TSFE Page @param integer $sysLanguageId Sys Language ID @param array $customMetaTagList Custom Meta Tag list
[ "Advanced", "meta", "tags" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Page/Part/MetatagPart.php#L511-L608
train
webdevops/TYPO3-metaseo
Classes/Page/Part/MetatagPart.php
MetatagPart.processMetaTags
protected function processMetaTags(array &$tags) { // Call hook GeneralUtility::callHookAndSignal(__CLASS__, 'metatagOutput', $this, $tags); // Add marker $markerList = array( '%YEAR%' => date('Y'), ); $keyList = array( 'meta.title', 'meta.description', 'meta.description.dc', 'meta.keywords', 'meta.keywords.dc', 'meta.copyright', 'meta.copyright.dc', 'meta.publisher.dc', ); foreach ($keyList as $key) { if (!empty($tags[$key]['attributes'])) { foreach ($markerList as $marker => $value) { foreach ($tags[$key]['attributes'] as &$metaTagAttribute) { // only replace markers if they are present if (strpos($metaTagAttribute, $marker) !== false) { $metaTagAttribute = str_replace($marker, $value, $metaTagAttribute); } } unset($metaTagAttribute); } } } }
php
protected function processMetaTags(array &$tags) { // Call hook GeneralUtility::callHookAndSignal(__CLASS__, 'metatagOutput', $this, $tags); // Add marker $markerList = array( '%YEAR%' => date('Y'), ); $keyList = array( 'meta.title', 'meta.description', 'meta.description.dc', 'meta.keywords', 'meta.keywords.dc', 'meta.copyright', 'meta.copyright.dc', 'meta.publisher.dc', ); foreach ($keyList as $key) { if (!empty($tags[$key]['attributes'])) { foreach ($markerList as $marker => $value) { foreach ($tags[$key]['attributes'] as &$metaTagAttribute) { // only replace markers if they are present if (strpos($metaTagAttribute, $marker) !== false) { $metaTagAttribute = str_replace($marker, $value, $metaTagAttribute); } } unset($metaTagAttribute); } } } }
[ "protected", "function", "processMetaTags", "(", "array", "&", "$", "tags", ")", "{", "// Call hook", "GeneralUtility", "::", "callHookAndSignal", "(", "__CLASS__", ",", "'metatagOutput'", ",", "$", "this", ",", "$", "tags", ")", ";", "// Add marker", "$", "ma...
Process meta tags @param array $tags
[ "Process", "meta", "tags" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Page/Part/MetatagPart.php#L615-L649
train
webdevops/TYPO3-metaseo
Classes/Page/Part/MetatagPart.php
MetatagPart.renderMetaTags
protected function renderMetaTags(array $metaTags) { $ret = array(); $isXhtml = $this->isXhtml(); foreach ($metaTags as $metaTag) { $tag = $metaTag['tag']; $attributes = array(); foreach ($metaTag['attributes'] as $key => $value) { $attributes[] = $key . '="' . htmlspecialchars($value) . '"'; } if ($isXhtml) { $ret[] = '<' . $tag . ' ' . implode(' ', $attributes) . '/>'; } else { $ret[] = '<' . $tag . ' ' . implode(' ', $attributes) . '>'; } } $separator = "\n"; return $separator . implode($separator, $ret) . $separator; }
php
protected function renderMetaTags(array $metaTags) { $ret = array(); $isXhtml = $this->isXhtml(); foreach ($metaTags as $metaTag) { $tag = $metaTag['tag']; $attributes = array(); foreach ($metaTag['attributes'] as $key => $value) { $attributes[] = $key . '="' . htmlspecialchars($value) . '"'; } if ($isXhtml) { $ret[] = '<' . $tag . ' ' . implode(' ', $attributes) . '/>'; } else { $ret[] = '<' . $tag . ' ' . implode(' ', $attributes) . '>'; } } $separator = "\n"; return $separator . implode($separator, $ret) . $separator; }
[ "protected", "function", "renderMetaTags", "(", "array", "$", "metaTags", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "$", "isXhtml", "=", "$", "this", "->", "isXhtml", "(", ")", ";", "foreach", "(", "$", "metaTags", "as", "$", "metaTag", ")",...
Render meta tags @param array $metaTags List of metatags with configuration (tag, attributes) @return string
[ "Render", "meta", "tags" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Page/Part/MetatagPart.php#L659-L684
train
webdevops/TYPO3-metaseo
Classes/Page/Part/MetatagPart.php
MetatagPart.collectMetaDataFromConnector
protected function collectMetaDataFromConnector() { $ret = array(); $storeMeta = $this->getStoreMeta(); // Std meta tags foreach ($storeMeta['meta'] as $metaKey => $metaValue) { if ($metaValue === null) { // Remove meta unset($this->tsSetupSeo[$metaKey]); } elseif (!empty($metaValue)) { $this->tsSetupSeo[$metaKey] = trim($metaValue); } } // Custom meta tags foreach ($storeMeta['custom'] as $metaKey => $metaValue) { if ($metaValue === null) { // Remove meta unset($ret[$metaKey]); } elseif (!empty($metaValue)) { $ret[$metaKey] = trim($metaValue); } } return $ret; }
php
protected function collectMetaDataFromConnector() { $ret = array(); $storeMeta = $this->getStoreMeta(); // Std meta tags foreach ($storeMeta['meta'] as $metaKey => $metaValue) { if ($metaValue === null) { // Remove meta unset($this->tsSetupSeo[$metaKey]); } elseif (!empty($metaValue)) { $this->tsSetupSeo[$metaKey] = trim($metaValue); } } // Custom meta tags foreach ($storeMeta['custom'] as $metaKey => $metaValue) { if ($metaValue === null) { // Remove meta unset($ret[$metaKey]); } elseif (!empty($metaValue)) { $ret[$metaKey] = trim($metaValue); } } return $ret; }
[ "protected", "function", "collectMetaDataFromConnector", "(", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "$", "storeMeta", "=", "$", "this", "->", "getStoreMeta", "(", ")", ";", "// Std meta tags", "foreach", "(", "$", "storeMeta", "[", "'meta'", "...
Collect metadata from connector @return mixed
[ "Collect", "metadata", "from", "connector" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Page/Part/MetatagPart.php#L808-L835
train
webdevops/TYPO3-metaseo
Classes/Page/Part/MetatagPart.php
MetatagPart.generateGeoPosMetaTags
protected function generateGeoPosMetaTags() { // Geo-Position if (!empty($this->tsSetupSeo['geoPositionLatitude']) && !empty($this->tsSetupSeo['geoPositionLongitude'])) { $this->metaTagList['geo.icmb'] = array( 'tag' => 'meta', 'attributes' => array( 'name' => 'ICBM', 'content' => $this->tsSetupSeo['geoPositionLatitude'] . ', ' . $this->tsSetupSeo['geoPositionLongitude'], ), ); $this->metaTagList['geo.position'] = array( 'tag' => 'meta', 'attributes' => array( 'name' => 'geo.position', 'content' => $this->tsSetupSeo['geoPositionLatitude'] . ';' . $this->tsSetupSeo['geoPositionLongitude'], ), ); } // Geo-Region if (!empty($this->tsSetupSeo['geoRegion'])) { $this->metaTagList['geo.region'] = array( 'tag' => 'meta', 'attributes' => array( 'name' => 'geo.region', 'content' => $this->tsSetupSeo['geoRegion'], ), ); } // Geo Placename if (!empty($this->tsSetupSeo['geoPlacename'])) { $this->metaTagList['geo.placename'] = array( 'tag' => 'meta', 'attributes' => array( 'name' => 'geo.placename', 'content' => $this->tsSetupSeo['geoPlacename'], ), ); } }
php
protected function generateGeoPosMetaTags() { // Geo-Position if (!empty($this->tsSetupSeo['geoPositionLatitude']) && !empty($this->tsSetupSeo['geoPositionLongitude'])) { $this->metaTagList['geo.icmb'] = array( 'tag' => 'meta', 'attributes' => array( 'name' => 'ICBM', 'content' => $this->tsSetupSeo['geoPositionLatitude'] . ', ' . $this->tsSetupSeo['geoPositionLongitude'], ), ); $this->metaTagList['geo.position'] = array( 'tag' => 'meta', 'attributes' => array( 'name' => 'geo.position', 'content' => $this->tsSetupSeo['geoPositionLatitude'] . ';' . $this->tsSetupSeo['geoPositionLongitude'], ), ); } // Geo-Region if (!empty($this->tsSetupSeo['geoRegion'])) { $this->metaTagList['geo.region'] = array( 'tag' => 'meta', 'attributes' => array( 'name' => 'geo.region', 'content' => $this->tsSetupSeo['geoRegion'], ), ); } // Geo Placename if (!empty($this->tsSetupSeo['geoPlacename'])) { $this->metaTagList['geo.placename'] = array( 'tag' => 'meta', 'attributes' => array( 'name' => 'geo.placename', 'content' => $this->tsSetupSeo['geoPlacename'], ), ); } }
[ "protected", "function", "generateGeoPosMetaTags", "(", ")", "{", "// Geo-Position", "if", "(", "!", "empty", "(", "$", "this", "->", "tsSetupSeo", "[", "'geoPositionLatitude'", "]", ")", "&&", "!", "empty", "(", "$", "this", "->", "tsSetupSeo", "[", "'geoPo...
Generate geo position MetaTags
[ "Generate", "geo", "position", "MetaTags" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Page/Part/MetatagPart.php#L1104-L1147
train
webdevops/TYPO3-metaseo
Classes/Page/Part/MetatagPart.php
MetatagPart.generateUserAgentMetaTags
protected function generateUserAgentMetaTags() { if (!empty($this->tsSetupSeo['ieCompatibilityMode'])) { if (is_numeric($this->tsSetupSeo['ieCompatibilityMode'])) { $this->metaTagList['ua.msie.compat'] = array( 'tag' => 'meta', 'attributes' => array( 'http-equiv' => 'X-UA-Compatible', 'content' => 'IE=EmulateIE' . (int)$this->tsSetupSeo['ieCompatibilityMode'], ), ); } else { $this->metaTagList['ua.msie.compat'] = array( 'tag' => 'meta', 'attributes' => array( 'http-equiv' => 'X-UA-Compatible', 'content' => $this->tsSetupSeo['ieCompatibilityMode'], ), ); } } }
php
protected function generateUserAgentMetaTags() { if (!empty($this->tsSetupSeo['ieCompatibilityMode'])) { if (is_numeric($this->tsSetupSeo['ieCompatibilityMode'])) { $this->metaTagList['ua.msie.compat'] = array( 'tag' => 'meta', 'attributes' => array( 'http-equiv' => 'X-UA-Compatible', 'content' => 'IE=EmulateIE' . (int)$this->tsSetupSeo['ieCompatibilityMode'], ), ); } else { $this->metaTagList['ua.msie.compat'] = array( 'tag' => 'meta', 'attributes' => array( 'http-equiv' => 'X-UA-Compatible', 'content' => $this->tsSetupSeo['ieCompatibilityMode'], ), ); } } }
[ "protected", "function", "generateUserAgentMetaTags", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "tsSetupSeo", "[", "'ieCompatibilityMode'", "]", ")", ")", "{", "if", "(", "is_numeric", "(", "$", "this", "->", "tsSetupSeo", "[", "'ieCo...
Generate user agent metatags
[ "Generate", "user", "agent", "metatags" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Page/Part/MetatagPart.php#L1214-L1235
train
webdevops/TYPO3-metaseo
Classes/Page/Part/MetatagPart.php
MetatagPart.generateCanonicalUrl
protected function generateCanonicalUrl() { $extCompat7 = ExtensionManagementUtility::isLoaded('compatibility7'); //User has specified a canonical URL in the page properties if (!empty($this->pageRecord['tx_metaseo_canonicalurl'])) { return $this->generateLink($this->pageRecord['tx_metaseo_canonicalurl']); } //Fallback to global settings to generate Url if (!empty($this->tsSetupSeo['canonicalUrl'])) { list($clUrl, $clLinkConf, $clDisableMpMode) = $this->detectCanonicalPage( $this->tsSetupSeo['canonicalUrl.'] ); if (!empty($clUrl) && isset($clLinkConf) && isset($clDisableMpMode)) { $url = $this->generateLink($clUrl, $clLinkConf, $clDisableMpMode); return $this->setFallbackProtocol( $extCompat7 ? $this->pageRecord['url_scheme'] : null, //page properties protocol selection $this->tsSetupSeo['canonicalUrl.']['fallbackProtocol'], $url ); } } return null; }
php
protected function generateCanonicalUrl() { $extCompat7 = ExtensionManagementUtility::isLoaded('compatibility7'); //User has specified a canonical URL in the page properties if (!empty($this->pageRecord['tx_metaseo_canonicalurl'])) { return $this->generateLink($this->pageRecord['tx_metaseo_canonicalurl']); } //Fallback to global settings to generate Url if (!empty($this->tsSetupSeo['canonicalUrl'])) { list($clUrl, $clLinkConf, $clDisableMpMode) = $this->detectCanonicalPage( $this->tsSetupSeo['canonicalUrl.'] ); if (!empty($clUrl) && isset($clLinkConf) && isset($clDisableMpMode)) { $url = $this->generateLink($clUrl, $clLinkConf, $clDisableMpMode); return $this->setFallbackProtocol( $extCompat7 ? $this->pageRecord['url_scheme'] : null, //page properties protocol selection $this->tsSetupSeo['canonicalUrl.']['fallbackProtocol'], $url ); } } return null; }
[ "protected", "function", "generateCanonicalUrl", "(", ")", "{", "$", "extCompat7", "=", "ExtensionManagementUtility", "::", "isLoaded", "(", "'compatibility7'", ")", ";", "//User has specified a canonical URL in the page properties", "if", "(", "!", "empty", "(", "$", "...
Generate CanonicalUrl for this page @return null|string Url or null if Url is empty
[ "Generate", "CanonicalUrl", "for", "this", "page" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Page/Part/MetatagPart.php#L1329-L1353
train
webdevops/TYPO3-metaseo
Classes/Page/Part/MetatagPart.php
MetatagPart.setFallbackProtocol
protected function setFallbackProtocol($pagePropertiesProtocol, $canonicalFallbackProtocol, $url) { $url = ltrim($url); if (empty($url)) { return null; } if (empty($canonicalFallbackProtocol)) { // Fallback not defined return $url; } if (!empty($pagePropertiesProtocol)) { // Protocol is well-defined via page properties (default is '0' with type string). // User cannot request with wrong protocol. Canonical URL cannot be wrong. return $url; } //get length of protocol substring $protocolLength = $this->getProtocolLength($url); if (is_null($protocolLength)) { //unknown protocol return $url; } //replace protocol prefix return substr_replace($url, $canonicalFallbackProtocol . '://', 0, $protocolLength); }
php
protected function setFallbackProtocol($pagePropertiesProtocol, $canonicalFallbackProtocol, $url) { $url = ltrim($url); if (empty($url)) { return null; } if (empty($canonicalFallbackProtocol)) { // Fallback not defined return $url; } if (!empty($pagePropertiesProtocol)) { // Protocol is well-defined via page properties (default is '0' with type string). // User cannot request with wrong protocol. Canonical URL cannot be wrong. return $url; } //get length of protocol substring $protocolLength = $this->getProtocolLength($url); if (is_null($protocolLength)) { //unknown protocol return $url; } //replace protocol prefix return substr_replace($url, $canonicalFallbackProtocol . '://', 0, $protocolLength); }
[ "protected", "function", "setFallbackProtocol", "(", "$", "pagePropertiesProtocol", ",", "$", "canonicalFallbackProtocol", ",", "$", "url", ")", "{", "$", "url", "=", "ltrim", "(", "$", "url", ")", ";", "if", "(", "empty", "(", "$", "url", ")", ")", "{",...
Replaces protocol in URL with a fallback protocol Missing or unknown protocol will not be replaced @param string $pagePropertiesProtocol protocol from page properties @param string $canonicalFallbackProtocol fallback protocol to go for if protocol in page properties is undefined @param string $url @return string|null
[ "Replaces", "protocol", "in", "URL", "with", "a", "fallback", "protocol", "Missing", "or", "unknown", "protocol", "will", "not", "be", "replaced" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Page/Part/MetatagPart.php#L1365-L1392
train
webdevops/TYPO3-metaseo
Classes/Page/Part/MetatagPart.php
MetatagPart.getProtocolLength
protected function getProtocolLength($url) { if (substr_compare($url, 'http://', 0, 7, true) === 0) { return 7; } if (substr_compare($url, 'https://', 0, 8, true) === 0) { return 8; } if (substr_compare($url, '//', 0, 2, false) === 0) { return 2; } return null; }
php
protected function getProtocolLength($url) { if (substr_compare($url, 'http://', 0, 7, true) === 0) { return 7; } if (substr_compare($url, 'https://', 0, 8, true) === 0) { return 8; } if (substr_compare($url, '//', 0, 2, false) === 0) { return 2; } return null; }
[ "protected", "function", "getProtocolLength", "(", "$", "url", ")", "{", "if", "(", "substr_compare", "(", "$", "url", ",", "'http://'", ",", "0", ",", "7", ",", "true", ")", "===", "0", ")", "{", "return", "7", ";", "}", "if", "(", "substr_compare",...
Case-insensitive detection of the protocol used in an Url. Returns protocol length if found. @param $url @return int|null length of protocol or null for unknown protocol
[ "Case", "-", "insensitive", "detection", "of", "the", "protocol", "used", "in", "an", "Url", ".", "Returns", "protocol", "length", "if", "found", "." ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Page/Part/MetatagPart.php#L1401-L1414
train
webdevops/TYPO3-metaseo
Classes/Page/Part/MetatagPart.php
MetatagPart.convertOpenGraphTypoScriptToMetaTags
protected function convertOpenGraphTypoScriptToMetaTags(array $prefixes, array $tsSetupSeoOg) { // Get list of tags (filtered array) $ogTagNameList = array_keys($tsSetupSeoOg); $ogTagNameList = array_unique( array_map( function ($item) { return rtrim($item, '.'); }, $ogTagNameList ) ); foreach ($ogTagNameList as $ogTagName) { $ogTagValue = null; // Check if TypoScript value is a simple one (eg. title = foo) // or it is a cObject if (!empty($tsSetupSeoOg[$ogTagName]) && !array_key_exists($ogTagName . '.', $tsSetupSeoOg)) { // Simple value $ogTagValue = $tsSetupSeoOg[$ogTagName]; } elseif (!empty($tsSetupSeoOg[$ogTagName])) { // Content object (eg. TEXT) $ogTagValue = $this->cObj->cObjGetSingle( $tsSetupSeoOg[$ogTagName], $tsSetupSeoOg[$ogTagName . '.'] ); } elseif (!array_key_exists($ogTagName, $tsSetupSeoOg) && array_key_exists($ogTagName . '.', $tsSetupSeoOg)) { // Nested object (e.g. image) array_push($prefixes, $ogTagName); $this->convertOpenGraphTypoScriptToMetaTags($prefixes, $tsSetupSeoOg[$ogTagName . '.']); array_pop($prefixes); } if ($ogTagValue !== null && strlen($ogTagValue) >= 1) { $path = $prefixes; $path[] = $ogTagName; $this->metaTagList[implode('.', $path)] = array( 'tag' => 'meta', 'attributes' => array( 'property' => implode(':', $path), 'content' => $ogTagValue, ), ); } } }
php
protected function convertOpenGraphTypoScriptToMetaTags(array $prefixes, array $tsSetupSeoOg) { // Get list of tags (filtered array) $ogTagNameList = array_keys($tsSetupSeoOg); $ogTagNameList = array_unique( array_map( function ($item) { return rtrim($item, '.'); }, $ogTagNameList ) ); foreach ($ogTagNameList as $ogTagName) { $ogTagValue = null; // Check if TypoScript value is a simple one (eg. title = foo) // or it is a cObject if (!empty($tsSetupSeoOg[$ogTagName]) && !array_key_exists($ogTagName . '.', $tsSetupSeoOg)) { // Simple value $ogTagValue = $tsSetupSeoOg[$ogTagName]; } elseif (!empty($tsSetupSeoOg[$ogTagName])) { // Content object (eg. TEXT) $ogTagValue = $this->cObj->cObjGetSingle( $tsSetupSeoOg[$ogTagName], $tsSetupSeoOg[$ogTagName . '.'] ); } elseif (!array_key_exists($ogTagName, $tsSetupSeoOg) && array_key_exists($ogTagName . '.', $tsSetupSeoOg)) { // Nested object (e.g. image) array_push($prefixes, $ogTagName); $this->convertOpenGraphTypoScriptToMetaTags($prefixes, $tsSetupSeoOg[$ogTagName . '.']); array_pop($prefixes); } if ($ogTagValue !== null && strlen($ogTagValue) >= 1) { $path = $prefixes; $path[] = $ogTagName; $this->metaTagList[implode('.', $path)] = array( 'tag' => 'meta', 'attributes' => array( 'property' => implode(':', $path), 'content' => $ogTagValue, ), ); } } }
[ "protected", "function", "convertOpenGraphTypoScriptToMetaTags", "(", "array", "$", "prefixes", ",", "array", "$", "tsSetupSeoOg", ")", "{", "// Get list of tags (filtered array)", "$", "ogTagNameList", "=", "array_keys", "(", "$", "tsSetupSeoOg", ")", ";", "$", "ogTa...
Convert nested TypoScript to OpenGraph MetaTags @param array $prefixes @param array $tsSetupSeoOg
[ "Convert", "nested", "TypoScript", "to", "OpenGraph", "MetaTags" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Page/Part/MetatagPart.php#L1432-L1478
train
webdevops/TYPO3-metaseo
Classes/Utility/SitemapUtility.php
SitemapUtility.index
public static function index(array $pageData) { static $cache = array(); // do not index empty urls if (empty($pageData['page_url'])) { return; } // Trim url $pageData['page_url'] = trim($pageData['page_url']); // calc page hash $pageData['page_hash'] = md5($pageData['page_url']); $pageHash = $pageData['page_hash']; // set default type if not set if (!isset($pageData['page_type'])) { $pageData['page_type'] = self::SITEMAP_TYPE_PAGE; } // Escape/Quote data foreach ($pageData as &$pageDataValue) { if ($pageDataValue === null) { $pageDataValue = 'NULL'; } elseif (is_int($pageDataValue) || is_numeric($pageDataValue)) { // Don't quote numeric/integers $pageDataValue = (int)$pageDataValue; } else { // String $pageDataValue = DatabaseUtility::quote($pageDataValue, 'tx_metaseo_sitemap'); } } unset($pageDataValue); // only process each page once to keep sql-statements at a normal level if (empty($cache[$pageHash])) { // $pageData is already quoted $query = 'SELECT uid FROM tx_metaseo_sitemap WHERE page_uid = ' . $pageData['page_uid'] . ' AND page_language = ' . $pageData['page_language'] . ' AND page_hash = ' . $pageData['page_hash'] . ' AND page_type = ' . $pageData['page_type']; $sitemapUid = DatabaseUtility::getOne($query); if (!empty($sitemapUid)) { $query = 'UPDATE tx_metaseo_sitemap SET tstamp = ' . $pageData['tstamp'] . ', page_rootpid = ' . $pageData['page_rootpid'] . ', page_language = ' . $pageData['page_language'] . ', page_url = ' . $pageData['page_url'] . ', page_depth = ' . $pageData['page_depth'] . ', page_change_frequency = ' . $pageData['page_change_frequency'] . ', page_type = ' . $pageData['page_type'] . ', expire = ' . $pageData['expire'] . ' WHERE uid = ' . (int)$sitemapUid; DatabaseUtility::exec($query); } else { // ##################################### // INSERT // ##################################### DatabaseUtility::connection()->exec_INSERTquery( 'tx_metaseo_sitemap', $pageData, array_keys($pageData) ); } $cache[$pageHash] = 1; } }
php
public static function index(array $pageData) { static $cache = array(); // do not index empty urls if (empty($pageData['page_url'])) { return; } // Trim url $pageData['page_url'] = trim($pageData['page_url']); // calc page hash $pageData['page_hash'] = md5($pageData['page_url']); $pageHash = $pageData['page_hash']; // set default type if not set if (!isset($pageData['page_type'])) { $pageData['page_type'] = self::SITEMAP_TYPE_PAGE; } // Escape/Quote data foreach ($pageData as &$pageDataValue) { if ($pageDataValue === null) { $pageDataValue = 'NULL'; } elseif (is_int($pageDataValue) || is_numeric($pageDataValue)) { // Don't quote numeric/integers $pageDataValue = (int)$pageDataValue; } else { // String $pageDataValue = DatabaseUtility::quote($pageDataValue, 'tx_metaseo_sitemap'); } } unset($pageDataValue); // only process each page once to keep sql-statements at a normal level if (empty($cache[$pageHash])) { // $pageData is already quoted $query = 'SELECT uid FROM tx_metaseo_sitemap WHERE page_uid = ' . $pageData['page_uid'] . ' AND page_language = ' . $pageData['page_language'] . ' AND page_hash = ' . $pageData['page_hash'] . ' AND page_type = ' . $pageData['page_type']; $sitemapUid = DatabaseUtility::getOne($query); if (!empty($sitemapUid)) { $query = 'UPDATE tx_metaseo_sitemap SET tstamp = ' . $pageData['tstamp'] . ', page_rootpid = ' . $pageData['page_rootpid'] . ', page_language = ' . $pageData['page_language'] . ', page_url = ' . $pageData['page_url'] . ', page_depth = ' . $pageData['page_depth'] . ', page_change_frequency = ' . $pageData['page_change_frequency'] . ', page_type = ' . $pageData['page_type'] . ', expire = ' . $pageData['expire'] . ' WHERE uid = ' . (int)$sitemapUid; DatabaseUtility::exec($query); } else { // ##################################### // INSERT // ##################################### DatabaseUtility::connection()->exec_INSERTquery( 'tx_metaseo_sitemap', $pageData, array_keys($pageData) ); } $cache[$pageHash] = 1; } }
[ "public", "static", "function", "index", "(", "array", "$", "pageData", ")", "{", "static", "$", "cache", "=", "array", "(", ")", ";", "// do not index empty urls", "if", "(", "empty", "(", "$", "pageData", "[", "'page_url'", "]", ")", ")", "{", "return"...
Insert into sitemap @param array $pageData page information
[ "Insert", "into", "sitemap" ]
bd5cd757b519795d761a67e944b5c7ccaeabb38c
https://github.com/webdevops/TYPO3-metaseo/blob/bd5cd757b519795d761a67e944b5c7ccaeabb38c/Classes/Utility/SitemapUtility.php#L83-L155
train