id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
46,400
snowcap/SnowcapImBundle
Wrapper.php
Wrapper.checkDirectory
public function checkDirectory($path) { $dir = dirname($path); if (!is_dir($dir)) { if (false === @mkdir($dir, 0777, true)) { throw new RuntimeException(sprintf('Unable to create the "%s" directory', $dir)); } } }
php
public function checkDirectory($path) { $dir = dirname($path); if (!is_dir($dir)) { if (false === @mkdir($dir, 0777, true)) { throw new RuntimeException(sprintf('Unable to create the "%s" directory', $dir)); } } }
[ "public", "function", "checkDirectory", "(", "$", "path", ")", "{", "$", "dir", "=", "dirname", "(", "$", "path", ")", ";", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "if", "(", "false", "===", "@", "mkdir", "(", "$", "dir", ",",...
Creates the given directory if unexistant @param string $path @throws RuntimeException
[ "Creates", "the", "given", "directory", "if", "unexistant" ]
2a15913b371e4b7d45d03a79c7decb620cce9c64
https://github.com/snowcap/SnowcapImBundle/blob/2a15913b371e4b7d45d03a79c7decb620cce9c64/Wrapper.php#L161-L169
46,401
snowcap/SnowcapImBundle
Wrapper.php
Wrapper.validateCommand
private function validateCommand($commandString) { $cmdParts = explode(" ", $commandString); if (count($cmdParts) < 2) { throw new InvalidArgumentException("This command isn't properly structured : '" . $commandString . "'"); } $binaryPath = $cmdParts[0]; $binaryPathParts = explode('/', $binaryPath); $binary = $binaryPathParts[count($binaryPathParts)-1]; if (!in_array($binary, $this->_acceptedBinaries)) { throw new InvalidArgumentException("This command isn't part of the ImageMagick command line tools : '" . $binary . "'"); } return true; }
php
private function validateCommand($commandString) { $cmdParts = explode(" ", $commandString); if (count($cmdParts) < 2) { throw new InvalidArgumentException("This command isn't properly structured : '" . $commandString . "'"); } $binaryPath = $cmdParts[0]; $binaryPathParts = explode('/', $binaryPath); $binary = $binaryPathParts[count($binaryPathParts)-1]; if (!in_array($binary, $this->_acceptedBinaries)) { throw new InvalidArgumentException("This command isn't part of the ImageMagick command line tools : '" . $binary . "'"); } return true; }
[ "private", "function", "validateCommand", "(", "$", "commandString", ")", "{", "$", "cmdParts", "=", "explode", "(", "\" \"", ",", "$", "commandString", ")", ";", "if", "(", "count", "(", "$", "cmdParts", ")", "<", "2", ")", "{", "throw", "new", "Inval...
Validates that the command launches a Imagemagick command line tool executable @param string $commandString @throws InvalidArgumentException @return boolean
[ "Validates", "that", "the", "command", "launches", "a", "Imagemagick", "command", "line", "tool", "executable" ]
2a15913b371e4b7d45d03a79c7decb620cce9c64
https://github.com/snowcap/SnowcapImBundle/blob/2a15913b371e4b7d45d03a79c7decb620cce9c64/Wrapper.php#L179-L196
46,402
grrr-amsterdam/garp3
library/Garp/Auth.php
Garp_Auth.isLoggedIn
public function isLoggedIn() { $hasUserData = isset($this->_store->userData); $hasLoginMethod = isset($this->_store->method); $hasValidToken = isset($this->_store->token) && $this->validateToken(); $isLoggedIn = $hasUserData && $hasLoginMethod && $hasValidToken; // Don't leave invalid cookies laying around. // Clear data only when data is present, but it is invalid. if ($hasUserData && $hasLoginMethod && !$hasValidToken) { $this->_store->userData = null; $this->_store->method = null; } return $isLoggedIn; }
php
public function isLoggedIn() { $hasUserData = isset($this->_store->userData); $hasLoginMethod = isset($this->_store->method); $hasValidToken = isset($this->_store->token) && $this->validateToken(); $isLoggedIn = $hasUserData && $hasLoginMethod && $hasValidToken; // Don't leave invalid cookies laying around. // Clear data only when data is present, but it is invalid. if ($hasUserData && $hasLoginMethod && !$hasValidToken) { $this->_store->userData = null; $this->_store->method = null; } return $isLoggedIn; }
[ "public", "function", "isLoggedIn", "(", ")", "{", "$", "hasUserData", "=", "isset", "(", "$", "this", "->", "_store", "->", "userData", ")", ";", "$", "hasLoginMethod", "=", "isset", "(", "$", "this", "->", "_store", "->", "method", ")", ";", "$", "...
Check if a user is logged in @return Boolean
[ "Check", "if", "a", "user", "is", "logged", "in" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Auth.php#L96-L109
46,403
grrr-amsterdam/garp3
library/Garp/Auth.php
Garp_Auth.createToken
public function createToken($input) { $config = $this->getConfigValues(); $salt = $config['salt']; $token = ''; $token .= !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; $token .= md5($input); $token .= md5($salt); /** * Embed an outline of the User table columns in the token. That way, whenever the * database changes, all current cookies are made invalid and users have to generate a * new cookie afresh by logging in. * This ensures the user cookies always contains all the columns. */ $columns = ''; try { $userModel = new Model_User(); $columns = $userModel->info(Zend_Db_Table_Abstract::COLS); $columns = implode('.', $columns); } catch (Zend_Db_Adapter_Exception $e) { Garp_ErrorHandler::handlePrematureException($e); } $token .= $columns; $token = md5($token); return $token; }
php
public function createToken($input) { $config = $this->getConfigValues(); $salt = $config['salt']; $token = ''; $token .= !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; $token .= md5($input); $token .= md5($salt); /** * Embed an outline of the User table columns in the token. That way, whenever the * database changes, all current cookies are made invalid and users have to generate a * new cookie afresh by logging in. * This ensures the user cookies always contains all the columns. */ $columns = ''; try { $userModel = new Model_User(); $columns = $userModel->info(Zend_Db_Table_Abstract::COLS); $columns = implode('.', $columns); } catch (Zend_Db_Adapter_Exception $e) { Garp_ErrorHandler::handlePrematureException($e); } $token .= $columns; $token = md5($token); return $token; }
[ "public", "function", "createToken", "(", "$", "input", ")", "{", "$", "config", "=", "$", "this", "->", "getConfigValues", "(", ")", ";", "$", "salt", "=", "$", "config", "[", "'salt'", "]", ";", "$", "token", "=", "''", ";", "$", "token", ".=", ...
Create a unique token for the currently logged in user. @param String $input Serialized user data @return String
[ "Create", "a", "unique", "token", "for", "the", "currently", "logged", "in", "user", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Auth.php#L133-L161
46,404
grrr-amsterdam/garp3
library/Garp/Auth.php
Garp_Auth.validateToken
public function validateToken() { $userData = $this->_store->userData; $currToken = $this->_store->token; $checkToken = $this->createToken(serialize($userData)); return $checkToken === $currToken; }
php
public function validateToken() { $userData = $this->_store->userData; $currToken = $this->_store->token; $checkToken = $this->createToken(serialize($userData)); return $checkToken === $currToken; }
[ "public", "function", "validateToken", "(", ")", "{", "$", "userData", "=", "$", "this", "->", "_store", "->", "userData", ";", "$", "currToken", "=", "$", "this", "->", "_store", "->", "token", ";", "$", "checkToken", "=", "$", "this", "->", "createTo...
Validate the current token @return Boolean
[ "Validate", "the", "current", "token" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Auth.php#L167-L172
46,405
grrr-amsterdam/garp3
library/Garp/Auth.php
Garp_Auth.store
public function store($data, $method = 'db') { $token = $this->createToken(serialize($data)); $this->_store->userData = $data; $this->_store->method = $method; $this->_store->token = $token; return $this; }
php
public function store($data, $method = 'db') { $token = $this->createToken(serialize($data)); $this->_store->userData = $data; $this->_store->method = $method; $this->_store->token = $token; return $this; }
[ "public", "function", "store", "(", "$", "data", ",", "$", "method", "=", "'db'", ")", "{", "$", "token", "=", "$", "this", "->", "createToken", "(", "serialize", "(", "$", "data", ")", ")", ";", "$", "this", "->", "_store", "->", "userData", "=", ...
Store user data in session @param Mixed $data The user data @param String $method The method used to login @return Void
[ "Store", "user", "data", "in", "session" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Auth.php#L180-L186
46,406
grrr-amsterdam/garp3
library/Garp/Auth.php
Garp_Auth.getConfigValues
public function getConfigValues($subSection = null) { $config = Zend_Registry::get('config'); // set defaults $values = $this->_defaultConfigValues; if ($config->auth) { $values = array_merge($values, $config->auth->toArray()); } if ($subSection) { return array_get($values, $subSection); } return $values; }
php
public function getConfigValues($subSection = null) { $config = Zend_Registry::get('config'); // set defaults $values = $this->_defaultConfigValues; if ($config->auth) { $values = array_merge($values, $config->auth->toArray()); } if ($subSection) { return array_get($values, $subSection); } return $values; }
[ "public", "function", "getConfigValues", "(", "$", "subSection", "=", "null", ")", "{", "$", "config", "=", "Zend_Registry", "::", "get", "(", "'config'", ")", ";", "// set defaults", "$", "values", "=", "$", "this", "->", "_defaultConfigValues", ";", "if", ...
Retrieve auth-related config values from application.ini @return Array
[ "Retrieve", "auth", "-", "related", "config", "values", "from", "application", ".", "ini" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Auth.php#L200-L211
46,407
grrr-amsterdam/garp3
library/Garp/Auth.php
Garp_Auth.getCurrentRole
public function getCurrentRole() { $role = self::DEFAULT_VISITOR_ROLE; if ($this->isLoggedIn()) { $role = self::DEFAULT_USER_ROLE; $data = $this->getUserData(); if (isset($data[self::ROLE_COLUMN])) { $role = $data[self::ROLE_COLUMN]; } } return $role; }
php
public function getCurrentRole() { $role = self::DEFAULT_VISITOR_ROLE; if ($this->isLoggedIn()) { $role = self::DEFAULT_USER_ROLE; $data = $this->getUserData(); if (isset($data[self::ROLE_COLUMN])) { $role = $data[self::ROLE_COLUMN]; } } return $role; }
[ "public", "function", "getCurrentRole", "(", ")", "{", "$", "role", "=", "self", "::", "DEFAULT_VISITOR_ROLE", ";", "if", "(", "$", "this", "->", "isLoggedIn", "(", ")", ")", "{", "$", "role", "=", "self", "::", "DEFAULT_USER_ROLE", ";", "$", "data", "...
Get the role associated with the current session. Note that an anonymous session, where nobody is logged in also has a role associated with it. @return String The role
[ "Get", "the", "role", "associated", "with", "the", "current", "session", ".", "Note", "that", "an", "anonymous", "session", "where", "nobody", "is", "logged", "in", "also", "has", "a", "role", "associated", "with", "it", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Auth.php#L239-L249
46,408
grrr-amsterdam/garp3
library/Garp/Auth.php
Garp_Auth.getRoles
public function getRoles($verbose = false) { if (Zend_Registry::isRegistered('Zend_Acl')) { $acl = Zend_Registry::get('Zend_Acl'); $roles = $acl->getRoles(); // collect parents if ($verbose) { $roles = array_fill_keys($roles, array()); foreach (array_keys($roles) as $role) { $roles[$role]['parents'] = $this->getRoleParents($role); $roles[$role]['children'] = $this->getRoleChildren($role); } } return $roles; } return array(); }
php
public function getRoles($verbose = false) { if (Zend_Registry::isRegistered('Zend_Acl')) { $acl = Zend_Registry::get('Zend_Acl'); $roles = $acl->getRoles(); // collect parents if ($verbose) { $roles = array_fill_keys($roles, array()); foreach (array_keys($roles) as $role) { $roles[$role]['parents'] = $this->getRoleParents($role); $roles[$role]['children'] = $this->getRoleChildren($role); } } return $roles; } return array(); }
[ "public", "function", "getRoles", "(", "$", "verbose", "=", "false", ")", "{", "if", "(", "Zend_Registry", "::", "isRegistered", "(", "'Zend_Acl'", ")", ")", "{", "$", "acl", "=", "Zend_Registry", "::", "get", "(", "'Zend_Acl'", ")", ";", "$", "roles", ...
Return all available roles from the ACL tree. @param Boolean $verbose Wether to include a role's parents @return Array A numeric array consisting of role strings
[ "Return", "all", "available", "roles", "from", "the", "ACL", "tree", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Auth.php#L256-L272
46,409
grrr-amsterdam/garp3
library/Garp/Auth.php
Garp_Auth.getRoleParents
public function getRoleParents($role, $onlyParents = true) { $parents = array(); if (Zend_Registry::isRegistered('Zend_Acl')) { $acl = Zend_Registry::get('Zend_Acl'); $roles = $acl->getRoles(); foreach ($roles as $potentialParent) { if ($acl->inheritsRole($role, $potentialParent, $onlyParents)) { $parents[] = $potentialParent; } } } return $parents; }
php
public function getRoleParents($role, $onlyParents = true) { $parents = array(); if (Zend_Registry::isRegistered('Zend_Acl')) { $acl = Zend_Registry::get('Zend_Acl'); $roles = $acl->getRoles(); foreach ($roles as $potentialParent) { if ($acl->inheritsRole($role, $potentialParent, $onlyParents)) { $parents[] = $potentialParent; } } } return $parents; }
[ "public", "function", "getRoleParents", "(", "$", "role", ",", "$", "onlyParents", "=", "true", ")", "{", "$", "parents", "=", "array", "(", ")", ";", "if", "(", "Zend_Registry", "::", "isRegistered", "(", "'Zend_Acl'", ")", ")", "{", "$", "acl", "=", ...
Return the parents of a given role @param String $role @param Boolean $onlyParents Wether to only return direct parents @return Array
[ "Return", "the", "parents", "of", "a", "given", "role" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Auth.php#L280-L293
46,410
grrr-amsterdam/garp3
library/Garp/Auth.php
Garp_Auth.getRoleChildren
public function getRoleChildren($role) { $children = array(); if (Zend_Registry::isRegistered('Zend_Acl')) { $acl = Zend_Registry::get('Zend_Acl'); $roles = $acl->getRoles(); foreach ($roles as $potentialChild) { if ($acl->inheritsRole($potentialChild, $role)) { $children[] = $potentialChild; } } } return $children; }
php
public function getRoleChildren($role) { $children = array(); if (Zend_Registry::isRegistered('Zend_Acl')) { $acl = Zend_Registry::get('Zend_Acl'); $roles = $acl->getRoles(); foreach ($roles as $potentialChild) { if ($acl->inheritsRole($potentialChild, $role)) { $children[] = $potentialChild; } } } return $children; }
[ "public", "function", "getRoleChildren", "(", "$", "role", ")", "{", "$", "children", "=", "array", "(", ")", ";", "if", "(", "Zend_Registry", "::", "isRegistered", "(", "'Zend_Acl'", ")", ")", "{", "$", "acl", "=", "Zend_Registry", "::", "get", "(", "...
Return the children of a given role @param String $role @return Array
[ "Return", "the", "children", "of", "a", "given", "role" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Auth.php#L300-L313
46,411
grrr-amsterdam/garp3
library/Garp/Auth.php
Garp_Auth.getSessionColumns
public function getSessionColumns() { $ini = Zend_Registry::get('config'); $sessionColumns = Zend_Db_Select::SQL_WILDCARD; if (!empty($ini->auth->login->sessionColumns)) { $sessionColumns = $ini->auth->login->sessionColumns; $sessionColumns = explode(',', $sessionColumns); } return $sessionColumns; }
php
public function getSessionColumns() { $ini = Zend_Registry::get('config'); $sessionColumns = Zend_Db_Select::SQL_WILDCARD; if (!empty($ini->auth->login->sessionColumns)) { $sessionColumns = $ini->auth->login->sessionColumns; $sessionColumns = explode(',', $sessionColumns); } return $sessionColumns; }
[ "public", "function", "getSessionColumns", "(", ")", "{", "$", "ini", "=", "Zend_Registry", "::", "get", "(", "'config'", ")", ";", "$", "sessionColumns", "=", "Zend_Db_Select", "::", "SQL_WILDCARD", ";", "if", "(", "!", "empty", "(", "$", "ini", "->", "...
Return which columns should be stored in the user session
[ "Return", "which", "columns", "should", "be", "stored", "in", "the", "user", "session" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Auth.php#L318-L326
46,412
grrr-amsterdam/garp3
library/Garp/Auth.php
Garp_Auth._getSnippetModel
protected function _getSnippetModel() { $snippetModel = new Model_Snippet(); if ($snippetModel->getObserver('Translatable')) { $i18nModelFactory = new Garp_I18n_ModelFactory(); $snippetModel = $i18nModelFactory->getModel($snippetModel); } return $snippetModel; }
php
protected function _getSnippetModel() { $snippetModel = new Model_Snippet(); if ($snippetModel->getObserver('Translatable')) { $i18nModelFactory = new Garp_I18n_ModelFactory(); $snippetModel = $i18nModelFactory->getModel($snippetModel); } return $snippetModel; }
[ "protected", "function", "_getSnippetModel", "(", ")", "{", "$", "snippetModel", "=", "new", "Model_Snippet", "(", ")", ";", "if", "(", "$", "snippetModel", "->", "getObserver", "(", "'Translatable'", ")", ")", "{", "$", "i18nModelFactory", "=", "new", "Garp...
Retrieve snippet model for system messages.
[ "Retrieve", "snippet", "model", "for", "system", "messages", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Auth.php#L393-L400
46,413
grrr-amsterdam/garp3
library/Garp/Content/Api/Rest.php
Garp_Content_Api_Rest.post
public function post(array $params, array $postData) { $this->_validatePostParams($params, $postData); $model = $this->_normalizeModelName($params['datatype']); $contentManager = $this->_getContentManager($model); $primaryKey = $contentManager->create($postData); $record = array_get( array_get( $this->get( array( 'datatype' => $params['datatype'], 'id' => $primaryKey ) ), 'data', array() ), 'result', array() ); $response = array( 'success' => true, 'result' => $record, 'link' => (string)new Garp_Util_FullUrl( array(array('datatype' => $params['datatype'], 'id' => $primaryKey), 'rest') ) ); return $this->_formatResponse($response, 201); }
php
public function post(array $params, array $postData) { $this->_validatePostParams($params, $postData); $model = $this->_normalizeModelName($params['datatype']); $contentManager = $this->_getContentManager($model); $primaryKey = $contentManager->create($postData); $record = array_get( array_get( $this->get( array( 'datatype' => $params['datatype'], 'id' => $primaryKey ) ), 'data', array() ), 'result', array() ); $response = array( 'success' => true, 'result' => $record, 'link' => (string)new Garp_Util_FullUrl( array(array('datatype' => $params['datatype'], 'id' => $primaryKey), 'rest') ) ); return $this->_formatResponse($response, 201); }
[ "public", "function", "post", "(", "array", "$", "params", ",", "array", "$", "postData", ")", "{", "$", "this", "->", "_validatePostParams", "(", "$", "params", ",", "$", "postData", ")", ";", "$", "model", "=", "$", "this", "->", "_normalizeModelName",...
POST a new record @param array $params @param array $postData @return array
[ "POST", "a", "new", "record" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Api/Rest.php#L53-L80
46,414
grrr-amsterdam/garp3
library/Garp/Content/Api/Rest.php
Garp_Content_Api_Rest.put
public function put(array $params, array $postData) { $this->_requireDataType($params); if (!array_get($params, 'id')) { throw new Garp_Content_Api_Rest_Exception( self::EXCEPTION_PUT_WITHOUT_ID ); } $model = $this->_normalizeModelName($params['datatype']); // First, see if the record actually exists list($record) = $this->_getSingleResult($params); if (is_null($record['result'])) { return $this->_formatResponse(array('success' => false), 404); } if (!array_get($params, 'relatedType')) { $this->_updateSingle($params, $postData); list($response, $httpCode) = $this->_getSingleResult($params); } else { $schema = new Garp_Content_Api_Rest_Schema('rest'); // Sanity check if related model exists list($relatedRecord) = $this->_getSingleResult( array( 'datatype' => getProperty( 'model', $schema->getRelation( $params['datatype'], $params['relatedType'] ) ), 'id' => $params['relatedId'] ) ); if (!$relatedRecord['result']) { return $this->_formatResponse(array('success' => false), 404); } $this->_addRelation($params, $postData); list($response, $httpCode) = $this->_getRelatedResults($params); } return $this->_formatResponse($response, $httpCode); }
php
public function put(array $params, array $postData) { $this->_requireDataType($params); if (!array_get($params, 'id')) { throw new Garp_Content_Api_Rest_Exception( self::EXCEPTION_PUT_WITHOUT_ID ); } $model = $this->_normalizeModelName($params['datatype']); // First, see if the record actually exists list($record) = $this->_getSingleResult($params); if (is_null($record['result'])) { return $this->_formatResponse(array('success' => false), 404); } if (!array_get($params, 'relatedType')) { $this->_updateSingle($params, $postData); list($response, $httpCode) = $this->_getSingleResult($params); } else { $schema = new Garp_Content_Api_Rest_Schema('rest'); // Sanity check if related model exists list($relatedRecord) = $this->_getSingleResult( array( 'datatype' => getProperty( 'model', $schema->getRelation( $params['datatype'], $params['relatedType'] ) ), 'id' => $params['relatedId'] ) ); if (!$relatedRecord['result']) { return $this->_formatResponse(array('success' => false), 404); } $this->_addRelation($params, $postData); list($response, $httpCode) = $this->_getRelatedResults($params); } return $this->_formatResponse($response, $httpCode); }
[ "public", "function", "put", "(", "array", "$", "params", ",", "array", "$", "postData", ")", "{", "$", "this", "->", "_requireDataType", "(", "$", "params", ")", ";", "if", "(", "!", "array_get", "(", "$", "params", ",", "'id'", ")", ")", "{", "th...
PUT changes into an existing record @param array $params @param array $postData @return array
[ "PUT", "changes", "into", "an", "existing", "record" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Api/Rest.php#L89-L130
46,415
grrr-amsterdam/garp3
library/Garp/Content/Api/Rest.php
Garp_Content_Api_Rest.delete
public function delete(array $params) { $this->_requireDataType($params); if (!array_get($params, 'id')) { throw new Garp_Content_Api_Rest_Exception( self::EXCEPTION_MISSING_ID ); } // First, see if the record actually exists list($record) = $this->_getSingleResult($params); if (is_null($record['result'])) { return $this->_formatResponse(array('success' => false), 404); } if (array_get($params, 'relatedType')) { $this->_removeRelation($params); return $this->_formatResponse(null, 204, false); } $contentManager = $this->_getContentManager($params['datatype']); $contentManager->destroy(array('id' => $params['id'])); return $this->_formatResponse(null, 204, false); }
php
public function delete(array $params) { $this->_requireDataType($params); if (!array_get($params, 'id')) { throw new Garp_Content_Api_Rest_Exception( self::EXCEPTION_MISSING_ID ); } // First, see if the record actually exists list($record) = $this->_getSingleResult($params); if (is_null($record['result'])) { return $this->_formatResponse(array('success' => false), 404); } if (array_get($params, 'relatedType')) { $this->_removeRelation($params); return $this->_formatResponse(null, 204, false); } $contentManager = $this->_getContentManager($params['datatype']); $contentManager->destroy(array('id' => $params['id'])); return $this->_formatResponse(null, 204, false); }
[ "public", "function", "delete", "(", "array", "$", "params", ")", "{", "$", "this", "->", "_requireDataType", "(", "$", "params", ")", ";", "if", "(", "!", "array_get", "(", "$", "params", ",", "'id'", ")", ")", "{", "throw", "new", "Garp_Content_Api_R...
DELETE a record @param array $params @return bool
[ "DELETE", "a", "record" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Api/Rest.php#L151-L171
46,416
grrr-amsterdam/garp3
library/Garp/Content/Api/Rest.php
Garp_Content_Api_Rest.getDictionary
public function getDictionary() { if (!Zend_Registry::isRegistered('Zend_Translate')) { throw new Garp_Content_Api_Rest_Exception( self::EXCEPTION_NO_DICTIONARY ); } $out = array( 'results' => Zend_Registry::get('Zend_Translate')->getMessages(), 'success' => true ); return $this->_formatResponse($out, 200); }
php
public function getDictionary() { if (!Zend_Registry::isRegistered('Zend_Translate')) { throw new Garp_Content_Api_Rest_Exception( self::EXCEPTION_NO_DICTIONARY ); } $out = array( 'results' => Zend_Registry::get('Zend_Translate')->getMessages(), 'success' => true ); return $this->_formatResponse($out, 200); }
[ "public", "function", "getDictionary", "(", ")", "{", "if", "(", "!", "Zend_Registry", "::", "isRegistered", "(", "'Zend_Translate'", ")", ")", "{", "throw", "new", "Garp_Content_Api_Rest_Exception", "(", "self", "::", "EXCEPTION_NO_DICTIONARY", ")", ";", "}", "...
Grab the dictionary containing all translatable strings. @return array
[ "Grab", "the", "dictionary", "containing", "all", "translatable", "strings", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Api/Rest.php#L218-L229
46,417
grrr-amsterdam/garp3
library/Garp/Content/Api/Rest.php
Garp_Content_Api_Rest._extractOptionsForFetch
protected function _extractOptionsForFetch(array $params) { if (!isset($params['options'])) { $params['options'] = array(); } try { $options = is_string($params['options']) ? Zend_Json::decode(urldecode($params['options'])) : $params['options']; } catch (Zend_Json_Exception $e) { throw new Garp_Content_Api_Rest_Exception( sprintf(self::EXCEPTION_INVALID_JSON, $e->getMessage()) ); } $options = array_get_subset( $options, array( 'sort', 'start', 'limit', 'fields', 'query', 'group', 'with' ) ); if (!isset($options['limit'])) { $options['limit'] = self::DEFAULT_PAGE_LIMIT; } if (isset($options['with'])) { // Normalize into an array $options['with'] = (array)$options['with']; } if (array_get($params, 'id')) { $options['query']['id'] = $params['id']; } return $options; }
php
protected function _extractOptionsForFetch(array $params) { if (!isset($params['options'])) { $params['options'] = array(); } try { $options = is_string($params['options']) ? Zend_Json::decode(urldecode($params['options'])) : $params['options']; } catch (Zend_Json_Exception $e) { throw new Garp_Content_Api_Rest_Exception( sprintf(self::EXCEPTION_INVALID_JSON, $e->getMessage()) ); } $options = array_get_subset( $options, array( 'sort', 'start', 'limit', 'fields', 'query', 'group', 'with' ) ); if (!isset($options['limit'])) { $options['limit'] = self::DEFAULT_PAGE_LIMIT; } if (isset($options['with'])) { // Normalize into an array $options['with'] = (array)$options['with']; } if (array_get($params, 'id')) { $options['query']['id'] = $params['id']; } return $options; }
[ "protected", "function", "_extractOptionsForFetch", "(", "array", "$", "params", ")", "{", "if", "(", "!", "isset", "(", "$", "params", "[", "'options'", "]", ")", ")", "{", "$", "params", "[", "'options'", "]", "=", "array", "(", ")", ";", "}", "try...
Remove cruft from HTTP params and provide sensible defaults. @param array $params The combined URL parameters @return array
[ "Remove", "cruft", "from", "HTTP", "params", "and", "provide", "sensible", "defaults", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Api/Rest.php#L250-L281
46,418
grrr-amsterdam/garp3
library/Garp/Content/Api/Rest.php
Garp_Content_Api_Rest._getRelatedResults
protected function _getRelatedResults(array $params) { // Check for existence of the subject record first, in order to return a 404 error list($subjectRecord, $httpCode) = $this->_getSingleResult($params); if (!$subjectRecord['success']) { return array( array( 'success' => false, 'result' => array() ), 404 ); } $schema = new Garp_Content_Api_Rest_Schema('rest'); $relation = $schema->getRelation($params['datatype'], $params['relatedType']); list($rule1, $rule2) = $relation->getRules($params['datatype']); $contentManager = $this->_getContentManager($relation->model); $subjectId = $params['id']; unset($params['id']); $options = $this->_extractOptionsForFetch($params); $options['query'][ucfirst($params['datatype']) . '.id'] = $subjectId; $options['bindingModel'] = $relation->getBindingModel()->id; $options['rule'] = $rule1; $options['rule2'] = $rule2; $options['fields'] = Zend_Db_Select::SQL_WILDCARD; if ($contentManager->getModel()->isMultilingual()) { $options['joinMultilingualModel'] = true; } $records = $contentManager->fetch($options); $amount = count($records); $records = array($params['relatedType'] => $records); if (isset($options['with'])) { $records = $this->_combineRecords($params['relatedType'], $records, $options['with']); } return array( array( 'success' => true, 'result' => $records, 'amount' => $amount, 'total' => intval($contentManager->count($options)) ), 200 ); }
php
protected function _getRelatedResults(array $params) { // Check for existence of the subject record first, in order to return a 404 error list($subjectRecord, $httpCode) = $this->_getSingleResult($params); if (!$subjectRecord['success']) { return array( array( 'success' => false, 'result' => array() ), 404 ); } $schema = new Garp_Content_Api_Rest_Schema('rest'); $relation = $schema->getRelation($params['datatype'], $params['relatedType']); list($rule1, $rule2) = $relation->getRules($params['datatype']); $contentManager = $this->_getContentManager($relation->model); $subjectId = $params['id']; unset($params['id']); $options = $this->_extractOptionsForFetch($params); $options['query'][ucfirst($params['datatype']) . '.id'] = $subjectId; $options['bindingModel'] = $relation->getBindingModel()->id; $options['rule'] = $rule1; $options['rule2'] = $rule2; $options['fields'] = Zend_Db_Select::SQL_WILDCARD; if ($contentManager->getModel()->isMultilingual()) { $options['joinMultilingualModel'] = true; } $records = $contentManager->fetch($options); $amount = count($records); $records = array($params['relatedType'] => $records); if (isset($options['with'])) { $records = $this->_combineRecords($params['relatedType'], $records, $options['with']); } return array( array( 'success' => true, 'result' => $records, 'amount' => $amount, 'total' => intval($contentManager->count($options)) ), 200 ); }
[ "protected", "function", "_getRelatedResults", "(", "array", "$", "params", ")", "{", "// Check for existence of the subject record first, in order to return a 404 error", "list", "(", "$", "subjectRecord", ",", "$", "httpCode", ")", "=", "$", "this", "->", "_getSingleRes...
Get index of items related to the given id. @param array $params @return array
[ "Get", "index", "of", "items", "related", "to", "the", "given", "id", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Api/Rest.php#L343-L388
46,419
grrr-amsterdam/garp3
library/Garp/Content/Api/Rest.php
Garp_Content_Api_Rest._combineRecords
protected function _combineRecords($datatype, array $records, $with) { $modelName = $this->_normalizeModelName($datatype); $rootModel = new $modelName; $schema = instance(new Garp_Content_Api_Rest_Schema('rest'))->getModelDetails($datatype); $hasOneRelations = array_filter($schema['fields'], propertyEquals('origin', 'relation')); $hasOneRelations = array_map(array_get('relationAlias'), $hasOneRelations); // Check validity of 'with' $unknowns = array_filter($with, callRight(not('in_array'), $hasOneRelations)); if (count($unknowns)) { $err = sprintf( Garp_Content_Api_Rest_Schema::EXCEPTION_RELATION_NOT_FOUND, $datatype, current($unknowns) ); throw new Garp_Content_Api_Rest_Exception($err); } $self = $this; return array_reduce( $with, function ($acc, $cur) use ($datatype, $schema, $self) { // Grab foreign key names from the relation $foreignKey = current( array_filter( $schema['fields'], propertyEquals('relationAlias', $cur) ) ); // Prepare a place for the result if (!isset($acc[$foreignKey['model']])) { $acc[$foreignKey['model']] = array(); } // Grab foreign key values $foreignKeyValues = array_map(array_get($foreignKey['name']), $acc[$datatype]); // No values to filter on? Bail. if (!count(array_filter($foreignKeyValues))) { return $acc; } $foreignKeyValues = array_values(array_unique($foreignKeyValues)); // Construct options object for manager $options = array( 'options' => array('query' => array('id' => $foreignKeyValues)), 'datatype' => $foreignKey['model'] ); // Fetch with options $relatedRowset = current($self->_getIndex($options)); $acc[$foreignKey['model']] = array_merge( $acc[$foreignKey['model']], $relatedRowset['result'][$foreignKey['model']] ); return $acc; }, $records ); }
php
protected function _combineRecords($datatype, array $records, $with) { $modelName = $this->_normalizeModelName($datatype); $rootModel = new $modelName; $schema = instance(new Garp_Content_Api_Rest_Schema('rest'))->getModelDetails($datatype); $hasOneRelations = array_filter($schema['fields'], propertyEquals('origin', 'relation')); $hasOneRelations = array_map(array_get('relationAlias'), $hasOneRelations); // Check validity of 'with' $unknowns = array_filter($with, callRight(not('in_array'), $hasOneRelations)); if (count($unknowns)) { $err = sprintf( Garp_Content_Api_Rest_Schema::EXCEPTION_RELATION_NOT_FOUND, $datatype, current($unknowns) ); throw new Garp_Content_Api_Rest_Exception($err); } $self = $this; return array_reduce( $with, function ($acc, $cur) use ($datatype, $schema, $self) { // Grab foreign key names from the relation $foreignKey = current( array_filter( $schema['fields'], propertyEquals('relationAlias', $cur) ) ); // Prepare a place for the result if (!isset($acc[$foreignKey['model']])) { $acc[$foreignKey['model']] = array(); } // Grab foreign key values $foreignKeyValues = array_map(array_get($foreignKey['name']), $acc[$datatype]); // No values to filter on? Bail. if (!count(array_filter($foreignKeyValues))) { return $acc; } $foreignKeyValues = array_values(array_unique($foreignKeyValues)); // Construct options object for manager $options = array( 'options' => array('query' => array('id' => $foreignKeyValues)), 'datatype' => $foreignKey['model'] ); // Fetch with options $relatedRowset = current($self->_getIndex($options)); $acc[$foreignKey['model']] = array_merge( $acc[$foreignKey['model']], $relatedRowset['result'][$foreignKey['model']] ); return $acc; }, $records ); }
[ "protected", "function", "_combineRecords", "(", "$", "datatype", ",", "array", "$", "records", ",", "$", "with", ")", "{", "$", "modelName", "=", "$", "this", "->", "_normalizeModelName", "(", "$", "datatype", ")", ";", "$", "rootModel", "=", "new", "$"...
Get related hasOne records and combine into a single response @param string $datatype @param array $records @param array $with @return array The combined resultsets
[ "Get", "related", "hasOne", "records", "and", "combine", "into", "a", "single", "response" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Api/Rest.php#L482-L541
46,420
grrr-amsterdam/garp3
library/Garp/Log.php
Garp_Log.factory
static public function factory($config = array()) { if (is_string($config)) { // Assume $config is a filename $filename = $config; $config = array( 'timestampFormat' => 'Y-m-d', array( 'writerName' => 'Stream', 'writerParams' => array( 'stream' => self::_getLoggingDirectory() . DIRECTORY_SEPARATOR . $filename ) ) ); } return parent::factory($config); }
php
static public function factory($config = array()) { if (is_string($config)) { // Assume $config is a filename $filename = $config; $config = array( 'timestampFormat' => 'Y-m-d', array( 'writerName' => 'Stream', 'writerParams' => array( 'stream' => self::_getLoggingDirectory() . DIRECTORY_SEPARATOR . $filename ) ) ); } return parent::factory($config); }
[ "static", "public", "function", "factory", "(", "$", "config", "=", "array", "(", ")", ")", "{", "if", "(", "is_string", "(", "$", "config", ")", ")", "{", "// Assume $config is a filename", "$", "filename", "=", "$", "config", ";", "$", "config", "=", ...
Shortcut to fetching a configured logger instance @param array|Zend_Config $config Array or instance of Zend_Config @return Zend_Log
[ "Shortcut", "to", "fetching", "a", "configured", "logger", "instance" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Log.php#L16-L31
46,421
grrr-amsterdam/garp3
library/Garp/Model/Db/AuthOpenId.php
Garp_Model_Db_AuthOpenId.createNew
public function createNew($openid, array $props) { // first save the new user $userModel = new Model_User(); $userId = $userModel->insert($props); $userData = $userModel->find($userId)->current(); $this->insert(array( 'openid' => $openid, 'user_id' => $userId )); $this->getObserver('Authenticatable')->updateLoginStats($userId); return $userData; }
php
public function createNew($openid, array $props) { // first save the new user $userModel = new Model_User(); $userId = $userModel->insert($props); $userData = $userModel->find($userId)->current(); $this->insert(array( 'openid' => $openid, 'user_id' => $userId )); $this->getObserver('Authenticatable')->updateLoginStats($userId); return $userData; }
[ "public", "function", "createNew", "(", "$", "openid", ",", "array", "$", "props", ")", "{", "// first save the new user", "$", "userModel", "=", "new", "Model_User", "(", ")", ";", "$", "userId", "=", "$", "userModel", "->", "insert", "(", "$", "props", ...
Store a new user. This creates a new auth_openid record, but also a new users record. @param String $openid @param Array $props Properties fetched thru Sreg @return Garp_Db_Table_Row The new user data
[ "Store", "a", "new", "user", ".", "This", "creates", "a", "new", "auth_openid", "record", "but", "also", "a", "new", "users", "record", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db/AuthOpenId.php#L27-L39
46,422
grrr-amsterdam/garp3
library/Garp/Application/Resource/Router.php
Garp_Application_Resource_Router.getRouter
public function getRouter() { $routesIni = $this->_getRoutesConfig(); $this->setOptions($routesIni->toArray()); $options = $this->getOptions(); if ($this->_localeIsEnabled()) { $bootstrap = $this->getBootstrap(); if (!$this->_locale) { $bootstrap->bootstrap('Locale'); $this->_locale = $bootstrap->getContainer()->locale; } $defaultLocale = array_keys($this->_locale->getDefault()); $defaultLocale = $defaultLocale[0]; $locales = $this->_getPossibleLocales(); $routes = $options['routes']; $localizedRoutes = Garp_I18n::getLocalizedRoutes($routes, $locales); $options['routes'] = array_merge($routes, $localizedRoutes); $this->setOptions($options); } $router = parent::getRouter(); $router->addDefaultRoutes(); return $router; }
php
public function getRouter() { $routesIni = $this->_getRoutesConfig(); $this->setOptions($routesIni->toArray()); $options = $this->getOptions(); if ($this->_localeIsEnabled()) { $bootstrap = $this->getBootstrap(); if (!$this->_locale) { $bootstrap->bootstrap('Locale'); $this->_locale = $bootstrap->getContainer()->locale; } $defaultLocale = array_keys($this->_locale->getDefault()); $defaultLocale = $defaultLocale[0]; $locales = $this->_getPossibleLocales(); $routes = $options['routes']; $localizedRoutes = Garp_I18n::getLocalizedRoutes($routes, $locales); $options['routes'] = array_merge($routes, $localizedRoutes); $this->setOptions($options); } $router = parent::getRouter(); $router->addDefaultRoutes(); return $router; }
[ "public", "function", "getRouter", "(", ")", "{", "$", "routesIni", "=", "$", "this", "->", "_getRoutesConfig", "(", ")", ";", "$", "this", "->", "setOptions", "(", "$", "routesIni", "->", "toArray", "(", ")", ")", ";", "$", "options", "=", "$", "thi...
Retrieve router object @return Zend_Controller_Router_Rewrite
[ "Retrieve", "router", "object" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Application/Resource/Router.php#L41-L67
46,423
grrr-amsterdam/garp3
library/Garp/Application/Resource/Router.php
Garp_Application_Resource_Router._getRoutesConfig
protected function _getRoutesConfig() { $options = $this->getOptions(); if (!isset($options['routesFile'])) { throw new Exception(self::ERROR_NO_ROUTE_DEFINED); } $routes = $options['routesFile']; if (is_string($routes)) { $genericRoutes = $this->_loadRoutesConfig($routes); } else { $genericRoutes = array_key_exists('generic', $routes) ? $this->_loadRoutesConfig($routes['generic']) : array() ; } $lang = $this->_getCurrentLanguage(); $territory = Garp_I18n::languageToTerritory($lang); $utf8_extension = PHP_OS === 'Linux' ? '.utf8' : '.UTF-8'; setlocale(LC_ALL, $territory . $utf8_extension); /** * Fix for Turkish language lowercasing issues. * * @see: http://www.sobstel.org/blog/php-call-to-undefined-method-on-tr-tr-locale/ * @see: https://bugs.php.net/bug.php?id=18556 */ if (in_array($territory, array('tr_TR', 'ku', 'az_AZ'))) { setlocale(LC_CTYPE, 'en_US' . $utf8_extension); } if ($this->_localeIsEnabled() && $lang && isset($options['routesFile'][$lang])) { $langFile = $options['routesFile'][$lang]; $langRoutes = $this->_loadRoutesConfig($langFile); return $genericRoutes->merge($langRoutes); } return $genericRoutes; }
php
protected function _getRoutesConfig() { $options = $this->getOptions(); if (!isset($options['routesFile'])) { throw new Exception(self::ERROR_NO_ROUTE_DEFINED); } $routes = $options['routesFile']; if (is_string($routes)) { $genericRoutes = $this->_loadRoutesConfig($routes); } else { $genericRoutes = array_key_exists('generic', $routes) ? $this->_loadRoutesConfig($routes['generic']) : array() ; } $lang = $this->_getCurrentLanguage(); $territory = Garp_I18n::languageToTerritory($lang); $utf8_extension = PHP_OS === 'Linux' ? '.utf8' : '.UTF-8'; setlocale(LC_ALL, $territory . $utf8_extension); /** * Fix for Turkish language lowercasing issues. * * @see: http://www.sobstel.org/blog/php-call-to-undefined-method-on-tr-tr-locale/ * @see: https://bugs.php.net/bug.php?id=18556 */ if (in_array($territory, array('tr_TR', 'ku', 'az_AZ'))) { setlocale(LC_CTYPE, 'en_US' . $utf8_extension); } if ($this->_localeIsEnabled() && $lang && isset($options['routesFile'][$lang])) { $langFile = $options['routesFile'][$lang]; $langRoutes = $this->_loadRoutesConfig($langFile); return $genericRoutes->merge($langRoutes); } return $genericRoutes; }
[ "protected", "function", "_getRoutesConfig", "(", ")", "{", "$", "options", "=", "$", "this", "->", "getOptions", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "options", "[", "'routesFile'", "]", ")", ")", "{", "throw", "new", "Exception", "(", ...
Retrieve a routes.ini file containing routes @return Zend_Config_Ini
[ "Retrieve", "a", "routes", ".", "ini", "file", "containing", "routes" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Application/Resource/Router.php#L74-L115
46,424
grrr-amsterdam/garp3
library/Garp/Application/Resource/Router.php
Garp_Application_Resource_Router._getPossibleLocales
protected function _getPossibleLocales() { $bootstrap = $this->getBootstrap(); $bootstrap->bootstrap('FrontController'); $frontController = $bootstrap->getContainer()->frontcontroller; $locales = $frontController->getParam('locales'); return $locales; }
php
protected function _getPossibleLocales() { $bootstrap = $this->getBootstrap(); $bootstrap->bootstrap('FrontController'); $frontController = $bootstrap->getContainer()->frontcontroller; $locales = $frontController->getParam('locales'); return $locales; }
[ "protected", "function", "_getPossibleLocales", "(", ")", "{", "$", "bootstrap", "=", "$", "this", "->", "getBootstrap", "(", ")", ";", "$", "bootstrap", "->", "bootstrap", "(", "'FrontController'", ")", ";", "$", "frontController", "=", "$", "bootstrap", "-...
Fetch all possible locales from the front controller parameters. @return array
[ "Fetch", "all", "possible", "locales", "from", "the", "front", "controller", "parameters", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Application/Resource/Router.php#L126-L132
46,425
grrr-amsterdam/garp3
library/Garp/Application/Resource/Router.php
Garp_Application_Resource_Router._getCurrentLanguage
protected function _getCurrentLanguage() { if (!isset($_SERVER['REQUEST_URI'])) { // Probably CLI context. Return the default locale return Garp_I18n::getDefaultLocale(); } $requestUri = $_SERVER['REQUEST_URI']; $bits = explode('/', $requestUri); // remove empty values $bits = array_filter($bits, 'strlen'); // reindex the array $bits = array_values($bits); $bits = array_map('strtolower', $bits); $locales = $this->_getPossibleLocales(); if (array_key_exists(0, $bits) && in_array($bits[0], $locales)) { return $bits[0]; } return Garp_I18n::getDefaultLocale(); }
php
protected function _getCurrentLanguage() { if (!isset($_SERVER['REQUEST_URI'])) { // Probably CLI context. Return the default locale return Garp_I18n::getDefaultLocale(); } $requestUri = $_SERVER['REQUEST_URI']; $bits = explode('/', $requestUri); // remove empty values $bits = array_filter($bits, 'strlen'); // reindex the array $bits = array_values($bits); $bits = array_map('strtolower', $bits); $locales = $this->_getPossibleLocales(); if (array_key_exists(0, $bits) && in_array($bits[0], $locales)) { return $bits[0]; } return Garp_I18n::getDefaultLocale(); }
[ "protected", "function", "_getCurrentLanguage", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ")", ")", "{", "// Probably CLI context. Return the default locale", "return", "Garp_I18n", "::", "getDefaultLocale", "(", ")", ...
Get current language from URL @return string
[ "Get", "current", "language", "from", "URL" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Application/Resource/Router.php#L149-L166
46,426
grrr-amsterdam/garp3
library/Garp/Model/Behavior/YouTubeable.php
Garp_Model_Behavior_YouTubeable._fillFields
protected function _fillFields(Array $input) { if (!array_key_exists($this->_fields['watch_url'], $input)) { throw new Garp_Model_Behavior_YouTubeable_Exception_MissingField( sprintf(self::EXCEPTION_MISSING_FIELD, $this->_fields['watch_url']) ); } $url = $input[$this->_fields['watch_url']]; if (empty($url)) { return; } $entry = $this->_fetchEntryByUrl($url); $images = $entry->getSnippet()->getThumbnails(); $duration = $entry->getContentDetails()->getDuration(); $data = array( 'identifier' => $entry->getId(), 'name' => $this->_getVideoName($entry, $input), 'description' => $this->_getVideoDescription($entry, $input), 'flash_player_url' => $this->_getFlashPlayerUrl($entry), 'watch_url' => $url, 'duration' => $this->_getDurationInSeconds($duration), 'image_url' => $images['high']['url'], 'thumbnail_url' => $images['default']['url'], ); $out = array(); foreach ($data as $ytKey => $value) { $garpKey = $this->_fields[$ytKey]; $this->_populateOutput($out, $garpKey, $value); } return $out; }
php
protected function _fillFields(Array $input) { if (!array_key_exists($this->_fields['watch_url'], $input)) { throw new Garp_Model_Behavior_YouTubeable_Exception_MissingField( sprintf(self::EXCEPTION_MISSING_FIELD, $this->_fields['watch_url']) ); } $url = $input[$this->_fields['watch_url']]; if (empty($url)) { return; } $entry = $this->_fetchEntryByUrl($url); $images = $entry->getSnippet()->getThumbnails(); $duration = $entry->getContentDetails()->getDuration(); $data = array( 'identifier' => $entry->getId(), 'name' => $this->_getVideoName($entry, $input), 'description' => $this->_getVideoDescription($entry, $input), 'flash_player_url' => $this->_getFlashPlayerUrl($entry), 'watch_url' => $url, 'duration' => $this->_getDurationInSeconds($duration), 'image_url' => $images['high']['url'], 'thumbnail_url' => $images['default']['url'], ); $out = array(); foreach ($data as $ytKey => $value) { $garpKey = $this->_fields[$ytKey]; $this->_populateOutput($out, $garpKey, $value); } return $out; }
[ "protected", "function", "_fillFields", "(", "Array", "$", "input", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "this", "->", "_fields", "[", "'watch_url'", "]", ",", "$", "input", ")", ")", "{", "throw", "new", "Garp_Model_Behavior_YouTubeable_E...
Retrieves additional data about the video corresponding with given input url from YouTube, and returns new data structure. @param array $input @return array
[ "Retrieves", "additional", "data", "about", "the", "video", "corresponding", "with", "given", "input", "url", "from", "YouTube", "and", "returns", "new", "data", "structure", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/YouTubeable.php#L96-L126
46,427
grrr-amsterdam/garp3
library/Garp/Model/Behavior/YouTubeable.php
Garp_Model_Behavior_YouTubeable._populateOutput
protected function _populateOutput(array &$output, $key, $value) { if (strpos($key, '.') === false) { $output[$key] = $value; return; } $array = Garp_Util_String::toArray($key, '.', $value); $output += $array; }
php
protected function _populateOutput(array &$output, $key, $value) { if (strpos($key, '.') === false) { $output[$key] = $value; return; } $array = Garp_Util_String::toArray($key, '.', $value); $output += $array; }
[ "protected", "function", "_populateOutput", "(", "array", "&", "$", "output", ",", "$", "key", ",", "$", "value", ")", "{", "if", "(", "strpos", "(", "$", "key", ",", "'.'", ")", "===", "false", ")", "{", "$", "output", "[", "$", "key", "]", "=",...
Populate record with new data @param array $output @param string $key @param string $value @return void
[ "Populate", "record", "with", "new", "data" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/YouTubeable.php#L136-L143
46,428
grrr-amsterdam/garp3
library/Garp/Model/Behavior/YouTubeable.php
Garp_Model_Behavior_YouTubeable._getId
protected function _getId($watchUrl) { $query = array(); if (!$watchUrl) { throw new Garp_Model_Behavior_YouTubeable_Exception_NoUrl(self::EXCEPTION_NO_URL); } $url = parse_url($watchUrl); if (empty($url['query']) && $url['host'] == 'youtu.be') { $videoId = substr($url['path'], 1); } elseif (isset($url['query'])) { parse_str($url['query'], $query); if (isset($query['v']) && $query['v']) { $videoId = $query['v']; } } if (!isset($videoId)) { throw new Garp_Model_Behavior_YouTubeable_Exception_InvalidUrl( sprintf(self::EXCEPTION_INVALID_YOUTUBE_URL, $watchUrl) ); } return $videoId; }
php
protected function _getId($watchUrl) { $query = array(); if (!$watchUrl) { throw new Garp_Model_Behavior_YouTubeable_Exception_NoUrl(self::EXCEPTION_NO_URL); } $url = parse_url($watchUrl); if (empty($url['query']) && $url['host'] == 'youtu.be') { $videoId = substr($url['path'], 1); } elseif (isset($url['query'])) { parse_str($url['query'], $query); if (isset($query['v']) && $query['v']) { $videoId = $query['v']; } } if (!isset($videoId)) { throw new Garp_Model_Behavior_YouTubeable_Exception_InvalidUrl( sprintf(self::EXCEPTION_INVALID_YOUTUBE_URL, $watchUrl) ); } return $videoId; }
[ "protected", "function", "_getId", "(", "$", "watchUrl", ")", "{", "$", "query", "=", "array", "(", ")", ";", "if", "(", "!", "$", "watchUrl", ")", "{", "throw", "new", "Garp_Model_Behavior_YouTubeable_Exception_NoUrl", "(", "self", "::", "EXCEPTION_NO_URL", ...
Retrieves the id value of a YouTube url. @param string $watchUrl @return string
[ "Retrieves", "the", "id", "value", "of", "a", "YouTube", "url", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/YouTubeable.php#L172-L194
46,429
grrr-amsterdam/garp3
library/Garp/Model/Behavior/YouTubeable.php
Garp_Model_Behavior_YouTubeable._getDurationInSeconds
protected function _getDurationInSeconds($duration) { $interval = new \DateInterval($duration); return ($interval->d * 24 * 60 * 60) + ($interval->h * 60 * 60) + ($interval->i * 60) + $interval->s; }
php
protected function _getDurationInSeconds($duration) { $interval = new \DateInterval($duration); return ($interval->d * 24 * 60 * 60) + ($interval->h * 60 * 60) + ($interval->i * 60) + $interval->s; }
[ "protected", "function", "_getDurationInSeconds", "(", "$", "duration", ")", "{", "$", "interval", "=", "new", "\\", "DateInterval", "(", "$", "duration", ")", ";", "return", "(", "$", "interval", "->", "d", "*", "24", "*", "60", "*", "60", ")", "+", ...
Convert ISO 8601 duration to seconds @param string $duration @return integer
[ "Convert", "ISO", "8601", "duration", "to", "seconds" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/YouTubeable.php#L216-L222
46,430
grrr-amsterdam/garp3
library/Garp/Spawn/MySql/View/Abstract.php
Garp_Spawn_MySql_View_Abstract.deleteAllByPostfix
public static function deleteAllByPostfix($postfix) { $adapter = Zend_Db_Table::getDefaultAdapter(); $config = Zend_Registry::get('config'); $dbName = $config->resources->db->params->dbname; $queryTpl = "SELECT table_name FROM information_schema.views WHERE table_schema = '%s' and table_name like '%%%s';"; $statement = sprintf($queryTpl, $dbName, $postfix); $views = $adapter->fetchAll($statement); foreach ($views as $view) { $viewName = $view['table_name']; $dropStatement = "DROP VIEW IF EXISTS `{$viewName}`;"; $adapter->query($dropStatement); } }
php
public static function deleteAllByPostfix($postfix) { $adapter = Zend_Db_Table::getDefaultAdapter(); $config = Zend_Registry::get('config'); $dbName = $config->resources->db->params->dbname; $queryTpl = "SELECT table_name FROM information_schema.views WHERE table_schema = '%s' and table_name like '%%%s';"; $statement = sprintf($queryTpl, $dbName, $postfix); $views = $adapter->fetchAll($statement); foreach ($views as $view) { $viewName = $view['table_name']; $dropStatement = "DROP VIEW IF EXISTS `{$viewName}`;"; $adapter->query($dropStatement); } }
[ "public", "static", "function", "deleteAllByPostfix", "(", "$", "postfix", ")", "{", "$", "adapter", "=", "Zend_Db_Table", "::", "getDefaultAdapter", "(", ")", ";", "$", "config", "=", "Zend_Registry", "::", "get", "(", "'config'", ")", ";", "$", "dbName", ...
Deletes all views in the database with given postfix. @param String $postfix The postfix for this type of view, f.i. '_joint'
[ "Deletes", "all", "views", "in", "the", "database", "with", "given", "postfix", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Spawn/MySql/View/Abstract.php#L25-L39
46,431
grrr-amsterdam/garp3
library/Garp/Spawn/MySql/Table/Synchronizer.php
Garp_Spawn_MySql_Table_Synchronizer.sync
public function sync($removeRedundantColumns = true) { $target = $this->getTarget(); $keysInSync = true; $configuredKeys = $this->_getConfiguredKeys(); $keySyncer = new Garp_Spawn_MySql_Key_Set_Synchronizer( $configuredKeys, $target->keys, $this->getFeedback() ); if (!$keySyncer->removeKeys()) { $keysInSync = false; } $colsInSync = $this->_syncColumns($target); $i18nTableFork = $this->_detectI18nTableFork(); if ($i18nTableFork) { $dbManager = Garp_Spawn_MySql_Manager::getInstance($this->_feedback); $dbManager->onI18nTableFork($this->getModel()); } if ($removeRedundantColumns) { $this->_deleteRedundantColumns(); } if (!$keySyncer->addKeys() || !$keySyncer->modifyKeys()) { $keysInSync = false; } return $colsInSync && $keysInSync; }
php
public function sync($removeRedundantColumns = true) { $target = $this->getTarget(); $keysInSync = true; $configuredKeys = $this->_getConfiguredKeys(); $keySyncer = new Garp_Spawn_MySql_Key_Set_Synchronizer( $configuredKeys, $target->keys, $this->getFeedback() ); if (!$keySyncer->removeKeys()) { $keysInSync = false; } $colsInSync = $this->_syncColumns($target); $i18nTableFork = $this->_detectI18nTableFork(); if ($i18nTableFork) { $dbManager = Garp_Spawn_MySql_Manager::getInstance($this->_feedback); $dbManager->onI18nTableFork($this->getModel()); } if ($removeRedundantColumns) { $this->_deleteRedundantColumns(); } if (!$keySyncer->addKeys() || !$keySyncer->modifyKeys()) { $keysInSync = false; } return $colsInSync && $keysInSync; }
[ "public", "function", "sync", "(", "$", "removeRedundantColumns", "=", "true", ")", "{", "$", "target", "=", "$", "this", "->", "getTarget", "(", ")", ";", "$", "keysInSync", "=", "true", ";", "$", "configuredKeys", "=", "$", "this", "->", "_getConfigure...
Syncs source and target tables with one another, trying to resolve any conflicts. @param bool $removeRedundantColumns Whether to remove no longer configured columns. This can be triggered separately with the cleanUp() method. @return bool In sync
[ "Syncs", "source", "and", "target", "tables", "with", "one", "another", "trying", "to", "resolve", "any", "conflicts", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Spawn/MySql/Table/Synchronizer.php#L52-L84
46,432
grrr-amsterdam/garp3
application/modules/g/controllers/BrowseboxController.php
G_BrowseboxController.indexAction
public function indexAction() { $request = $this->getRequest(); if (!$request->getParam('id') || !$request->getParam('chunk')) { throw new Exception('Not enough parameters: "id" and "chunk" are required.'); } $bb = $this->_initBrowsebox($request); $this->view->bb = $bb; $this->_helper->layout->setLayout('blank'); }
php
public function indexAction() { $request = $this->getRequest(); if (!$request->getParam('id') || !$request->getParam('chunk')) { throw new Exception('Not enough parameters: "id" and "chunk" are required.'); } $bb = $this->_initBrowsebox($request); $this->view->bb = $bb; $this->_helper->layout->setLayout('blank'); }
[ "public", "function", "indexAction", "(", ")", "{", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "if", "(", "!", "$", "request", "->", "getParam", "(", "'id'", ")", "||", "!", "$", "request", "->", "getParam", "(", "'chunk'", ...
Central entry point. @return void
[ "Central", "entry", "point", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/BrowseboxController.php#L15-L23
46,433
grrr-amsterdam/garp3
application/modules/g/controllers/BrowseboxController.php
G_BrowseboxController._initBrowsebox
protected function _initBrowsebox(Zend_Controller_Request_Abstract $request) { $bb = Garp_Browsebox::factory($request->getParam('id')); if ($request->getParam('conditions')) { $options = unserialize(base64_decode($request->getParam('conditions'))); if (!empty($options['filters'])) { $conditions = base64_decode($options['filters']); $conditions = explode( Garp_Browsebox::BROWSEBOX_QUERY_FILTER_SEPARATOR, $conditions ); foreach ($conditions as $condition) { $parts = explode(':', $condition); if (count($parts) < 2) { continue; } $filterId = $parts[0]; $params = explode( Garp_Browsebox::BROWSEBOX_QUERY_FILTER_PROP_SEPARATOR, $parts[1] ); $bb->setFilter($filterId, $params); } } unset($options['filters']); foreach ($options as $key => $value) { $bb->setOption($key, $value); } } $chunk = $request->getParam('chunk'); if ($chunk < 1) { $chunk = 1; } $bb->init($chunk); return $bb; }
php
protected function _initBrowsebox(Zend_Controller_Request_Abstract $request) { $bb = Garp_Browsebox::factory($request->getParam('id')); if ($request->getParam('conditions')) { $options = unserialize(base64_decode($request->getParam('conditions'))); if (!empty($options['filters'])) { $conditions = base64_decode($options['filters']); $conditions = explode( Garp_Browsebox::BROWSEBOX_QUERY_FILTER_SEPARATOR, $conditions ); foreach ($conditions as $condition) { $parts = explode(':', $condition); if (count($parts) < 2) { continue; } $filterId = $parts[0]; $params = explode( Garp_Browsebox::BROWSEBOX_QUERY_FILTER_PROP_SEPARATOR, $parts[1] ); $bb->setFilter($filterId, $params); } } unset($options['filters']); foreach ($options as $key => $value) { $bb->setOption($key, $value); } } $chunk = $request->getParam('chunk'); if ($chunk < 1) { $chunk = 1; } $bb->init($chunk); return $bb; }
[ "protected", "function", "_initBrowsebox", "(", "Zend_Controller_Request_Abstract", "$", "request", ")", "{", "$", "bb", "=", "Garp_Browsebox", "::", "factory", "(", "$", "request", "->", "getParam", "(", "'id'", ")", ")", ";", "if", "(", "$", "request", "->...
Fetch a Browsebox object configured based on parameters found in the request. @param Zend_Controller_Request_Abstract $request The current request @return Garp_Browsebox
[ "Fetch", "a", "Browsebox", "object", "configured", "based", "on", "parameters", "found", "in", "the", "request", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/BrowseboxController.php#L32-L69
46,434
grrr-amsterdam/garp3
library/Garp/Content/Export/Abstract.php
Garp_Content_Export_Abstract.getFilename
public function getFilename(Garp_Util_Configuration $params) { $className = Garp_Content_Api::modelAliasToClass($params['model']); $model = new $className(); $filename = 'export_'; $filename .= $model->getName(); $filename .= '_' . date('Y_m_d'); $filename .= '.'; $filename .= $this->_extension; return $filename; }
php
public function getFilename(Garp_Util_Configuration $params) { $className = Garp_Content_Api::modelAliasToClass($params['model']); $model = new $className(); $filename = 'export_'; $filename .= $model->getName(); $filename .= '_' . date('Y_m_d'); $filename .= '.'; $filename .= $this->_extension; return $filename; }
[ "public", "function", "getFilename", "(", "Garp_Util_Configuration", "$", "params", ")", "{", "$", "className", "=", "Garp_Content_Api", "::", "modelAliasToClass", "(", "$", "params", "[", "'model'", "]", ")", ";", "$", "model", "=", "new", "$", "className", ...
Generate a filename for the exported text file @param Garp_Util_Configuration $params @return string
[ "Generate", "a", "filename", "for", "the", "exported", "text", "file" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Export/Abstract.php#L111-L120
46,435
grrr-amsterdam/garp3
library/Garp/Content/Export/Abstract.php
Garp_Content_Export_Abstract._humanizeData
protected function _humanizeData($data, Garp_Model_Db $model) { $humanizedData = array(); foreach ($data as $i => $datum) { if (!is_array($datum)) { $humanizedData[$i] = $datum; continue; } foreach ($datum as $column => $value) { $field = $model->getFieldConfiguration($column); if ($field['type'] === 'checkbox') { $value = $value ? __('yes') : __('no'); } $alias = $column; if ($field) { $alias = $field['label']; } $alias = ucfirst(__($alias)); if (is_array($value) && $this->_isMultilingualArray($value)) { // special case: we convert the language keys to new columns in the output foreach ($value as $key => $data) { $i18n_alias = "$alias ($key)"; $humanizedData[$i][$i18n_alias] = $data; } // Continue so we don't add duplicate data continue; } elseif (is_array($value)) { // OMG recursion! $value = $this->_humanizeData($value, $model); } $humanizedData[$i][$alias] = $value; } } return $humanizedData; }
php
protected function _humanizeData($data, Garp_Model_Db $model) { $humanizedData = array(); foreach ($data as $i => $datum) { if (!is_array($datum)) { $humanizedData[$i] = $datum; continue; } foreach ($datum as $column => $value) { $field = $model->getFieldConfiguration($column); if ($field['type'] === 'checkbox') { $value = $value ? __('yes') : __('no'); } $alias = $column; if ($field) { $alias = $field['label']; } $alias = ucfirst(__($alias)); if (is_array($value) && $this->_isMultilingualArray($value)) { // special case: we convert the language keys to new columns in the output foreach ($value as $key => $data) { $i18n_alias = "$alias ($key)"; $humanizedData[$i][$i18n_alias] = $data; } // Continue so we don't add duplicate data continue; } elseif (is_array($value)) { // OMG recursion! $value = $this->_humanizeData($value, $model); } $humanizedData[$i][$alias] = $value; } } return $humanizedData; }
[ "protected", "function", "_humanizeData", "(", "$", "data", ",", "Garp_Model_Db", "$", "model", ")", "{", "$", "humanizedData", "=", "array", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "i", "=>", "$", "datum", ")", "{", "if", "(", "!", ...
Translate the columns of a record into the human-friendly versions used in the CMS @param array $data @param Garp_Model_Db $model @return array
[ "Translate", "the", "columns", "of", "a", "record", "into", "the", "human", "-", "friendly", "versions", "used", "in", "the", "CMS" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Export/Abstract.php#L141-L175
46,436
grrr-amsterdam/garp3
library/Garp/Content/Export/Abstract.php
Garp_Content_Export_Abstract._humanizeMultilingualData
protected function _humanizeMultilingualData(array $value) { $out = array(); foreach ($value as $key => $data) { $out[] = "[$key]: $data"; } return implode(" - ", $out); }
php
protected function _humanizeMultilingualData(array $value) { $out = array(); foreach ($value as $key => $data) { $out[] = "[$key]: $data"; } return implode(" - ", $out); }
[ "protected", "function", "_humanizeMultilingualData", "(", "array", "$", "value", ")", "{", "$", "out", "=", "array", "(", ")", ";", "foreach", "(", "$", "value", "as", "$", "key", "=>", "$", "data", ")", "{", "$", "out", "[", "]", "=", "\"[$key]: $d...
Humanize a multilingual data array @param array $value @return string
[ "Humanize", "a", "multilingual", "data", "array" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Export/Abstract.php#L183-L189
46,437
grrr-amsterdam/garp3
library/Garp/Content/Export/Abstract.php
Garp_Content_Export_Abstract._isMultilingualArray
protected function _isMultilingualArray($value) { if (!is_array($value)) { return false; } $locales = Garp_I18n::getLocales(); $keys = array_keys($value); sort($locales); sort($keys); return $locales === $keys; }
php
protected function _isMultilingualArray($value) { if (!is_array($value)) { return false; } $locales = Garp_I18n::getLocales(); $keys = array_keys($value); sort($locales); sort($keys); return $locales === $keys; }
[ "protected", "function", "_isMultilingualArray", "(", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "$", "locales", "=", "Garp_I18n", "::", "getLocales", "(", ")", ";", "$", "keys", ...
Check if value is a multilingual array. @param mixed $value @return bool
[ "Check", "if", "value", "is", "a", "multilingual", "array", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Export/Abstract.php#L197-L207
46,438
grrr-amsterdam/garp3
library/Garp/Content/Export/Abstract.php
Garp_Content_Export_Abstract._bindModels
protected function _bindModels(Garp_Model_Db $model) { // Add HABTM related records $relations = $model->getConfiguration('relations'); foreach ($relations as $key => $config) { if ($config['type'] !== 'hasAndBelongsToMany' && $config['type'] !== 'hasMany') { continue; } $otherModelName = 'Model_' . $config['model']; $otherModel = new $otherModelName(); $multilingual = false; $modelFactory = new Garp_I18n_ModelFactory(); if ($otherModel->getObserver('Translatable')) { $otherModel = $modelFactory->getModel($otherModel); $multilingual = true; } $otherModelAlias = $otherModel->getName(); $bindingModel = null; if ($config['type'] === 'hasAndBelongsToMany') { $bindingModelName = 'Model_' . $config['bindingModel']; $bindingModel = new $bindingModelName; if ($multilingual) { $refmapLocaliser = new Garp_Model_ReferenceMapLocalizer($bindingModel); $refmapLocaliser->populate($otherModelName); } $otherModelAlias = 'm'; } $labelFields = $otherModel->getListFields(); $prefixedLabelFields = array(); foreach ($labelFields as $labelField) { $prefixedLabelFields[] = "$otherModelAlias.$labelField"; } $labelFields = 'CONCAT_WS(", ", ' . implode(', ', $prefixedLabelFields) . ')'; // If the Translatable behavior would be effective, // the output would be in a localized array, which is overkill for this // purpose. $otherModel->unregisterObserver('Translatable'); $options = array( 'bindingModel' => $bindingModel, 'modelClass' => $otherModel, 'conditions' => $otherModel->select() ->setIntegrityCheck(false) ->from( array($otherModelAlias => $otherModel->getName()), array($config['label'] => $labelFields) ) ->order("$otherModelAlias.id") ); $model->bindModel($config['label'], $options); } }
php
protected function _bindModels(Garp_Model_Db $model) { // Add HABTM related records $relations = $model->getConfiguration('relations'); foreach ($relations as $key => $config) { if ($config['type'] !== 'hasAndBelongsToMany' && $config['type'] !== 'hasMany') { continue; } $otherModelName = 'Model_' . $config['model']; $otherModel = new $otherModelName(); $multilingual = false; $modelFactory = new Garp_I18n_ModelFactory(); if ($otherModel->getObserver('Translatable')) { $otherModel = $modelFactory->getModel($otherModel); $multilingual = true; } $otherModelAlias = $otherModel->getName(); $bindingModel = null; if ($config['type'] === 'hasAndBelongsToMany') { $bindingModelName = 'Model_' . $config['bindingModel']; $bindingModel = new $bindingModelName; if ($multilingual) { $refmapLocaliser = new Garp_Model_ReferenceMapLocalizer($bindingModel); $refmapLocaliser->populate($otherModelName); } $otherModelAlias = 'm'; } $labelFields = $otherModel->getListFields(); $prefixedLabelFields = array(); foreach ($labelFields as $labelField) { $prefixedLabelFields[] = "$otherModelAlias.$labelField"; } $labelFields = 'CONCAT_WS(", ", ' . implode(', ', $prefixedLabelFields) . ')'; // If the Translatable behavior would be effective, // the output would be in a localized array, which is overkill for this // purpose. $otherModel->unregisterObserver('Translatable'); $options = array( 'bindingModel' => $bindingModel, 'modelClass' => $otherModel, 'conditions' => $otherModel->select() ->setIntegrityCheck(false) ->from( array($otherModelAlias => $otherModel->getName()), array($config['label'] => $labelFields) ) ->order("$otherModelAlias.id") ); $model->bindModel($config['label'], $options); } }
[ "protected", "function", "_bindModels", "(", "Garp_Model_Db", "$", "model", ")", "{", "// Add HABTM related records", "$", "relations", "=", "$", "model", "->", "getConfiguration", "(", "'relations'", ")", ";", "foreach", "(", "$", "relations", "as", "$", "key",...
Bind all HABTM related models so they, too, get exported @param Garp_Model_Db $model @return void
[ "Bind", "all", "HABTM", "related", "models", "so", "they", "too", "get", "exported" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Export/Abstract.php#L215-L269
46,439
grrr-amsterdam/garp3
library/Garp/Model/Db/AuthFacebook.php
Garp_Model_Db_AuthFacebook.createNew
public function createNew(array $authData, array $userData) { // first save the new user $userModel = new Model_User(); $userId = $userModel->insert($userData); $userData = $userModel->find($userId)->current(); $authData['user_id'] = $userId; $this->insert($authData); $this->getObserver('Authenticatable')->updateLoginStats($userId); return $userData; }
php
public function createNew(array $authData, array $userData) { // first save the new user $userModel = new Model_User(); $userId = $userModel->insert($userData); $userData = $userModel->find($userId)->current(); $authData['user_id'] = $userId; $this->insert($authData); $this->getObserver('Authenticatable')->updateLoginStats($userId); return $userData; }
[ "public", "function", "createNew", "(", "array", "$", "authData", ",", "array", "$", "userData", ")", "{", "// first save the new user", "$", "userModel", "=", "new", "Model_User", "(", ")", ";", "$", "userId", "=", "$", "userModel", "->", "insert", "(", "...
Store a new user. This creates a new auth_facebook record, but also a new user record. @param Array $authData Data for the new Auth record @param Array $userData Data for the new User record @return Garp_Db_Table_Row The new user data
[ "Store", "a", "new", "user", ".", "This", "creates", "a", "new", "auth_facebook", "record", "but", "also", "a", "new", "user", "record", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db/AuthFacebook.php#L27-L37
46,440
grrr-amsterdam/garp3
application/modules/g/views/helpers/Vimeo.php
G_View_Helper_Vimeo.render
public function render($vimeo, array $options = array()) { $this->_setDefaultAttribs($options); $_attribs = $options['attribs']; $_attribs['width'] = $options['width']; $_attribs['height'] = $options['height']; unset($options['width']); unset($options['height']); unset($options['attribs']); $playerUrl = $this->getPlayerUrl($vimeo, $options); $_attribs['frameborder'] = 0; $_attribs['src'] = $playerUrl; $html = '<iframe' . $this->_htmlAttribs($_attribs) . '></iframe>'; return $html; }
php
public function render($vimeo, array $options = array()) { $this->_setDefaultAttribs($options); $_attribs = $options['attribs']; $_attribs['width'] = $options['width']; $_attribs['height'] = $options['height']; unset($options['width']); unset($options['height']); unset($options['attribs']); $playerUrl = $this->getPlayerUrl($vimeo, $options); $_attribs['frameborder'] = 0; $_attribs['src'] = $playerUrl; $html = '<iframe' . $this->_htmlAttribs($_attribs) . '></iframe>'; return $html; }
[ "public", "function", "render", "(", "$", "vimeo", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "this", "->", "_setDefaultAttribs", "(", "$", "options", ")", ";", "$", "_attribs", "=", "$", "options", "[", "'attribs'", "]", ";...
Render a Vimeo object tag. @param Garp_Db_Table_Row $vimeo A record from the `vimeo_videos` table (or `media` view) @param array $options Various rendering options @return mixed
[ "Render", "a", "Vimeo", "object", "tag", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Vimeo.php#L34-L51
46,441
grrr-amsterdam/garp3
application/modules/g/views/helpers/Vimeo.php
G_View_Helper_Vimeo._setDefaultAttribs
protected function _setDefaultAttribs(&$options) { $options = $options instanceof Garp_Util_Configuration ? $options : new Garp_Util_Configuration($options); $options ->setDefault('height', isset($options['width']) ? round($options['width']*0.55) : 264) ->setDefault('width', 480) ->setDefault('attribs', array()); }
php
protected function _setDefaultAttribs(&$options) { $options = $options instanceof Garp_Util_Configuration ? $options : new Garp_Util_Configuration($options); $options ->setDefault('height', isset($options['width']) ? round($options['width']*0.55) : 264) ->setDefault('width', 480) ->setDefault('attribs', array()); }
[ "protected", "function", "_setDefaultAttribs", "(", "&", "$", "options", ")", "{", "$", "options", "=", "$", "options", "instanceof", "Garp_Util_Configuration", "?", "$", "options", ":", "new", "Garp_Util_Configuration", "(", "$", "options", ")", ";", "$", "op...
Normalize some configuration values. @param array $options @return array Modified options
[ "Normalize", "some", "configuration", "values", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Vimeo.php#L68-L75
46,442
grrr-amsterdam/garp3
application/modules/g/views/helpers/Vimeo.php
G_View_Helper_Vimeo._setDefaultQueryParams
protected function _setDefaultQueryParams(&$options) { $options = $options instanceof Garp_Util_Configuration ? $options : new Garp_Util_Configuration($options); $options ->setDefault('portrait', 0) ->setDefault('title', 0) ->setDefault('byline', 0); }
php
protected function _setDefaultQueryParams(&$options) { $options = $options instanceof Garp_Util_Configuration ? $options : new Garp_Util_Configuration($options); $options ->setDefault('portrait', 0) ->setDefault('title', 0) ->setDefault('byline', 0); }
[ "protected", "function", "_setDefaultQueryParams", "(", "&", "$", "options", ")", "{", "$", "options", "=", "$", "options", "instanceof", "Garp_Util_Configuration", "?", "$", "options", ":", "new", "Garp_Util_Configuration", "(", "$", "options", ")", ";", "$", ...
Normalize some query parameters @param array $options @return void @see https://developers.google.com/youtube/player_parameters
[ "Normalize", "some", "query", "parameters" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Vimeo.php#L84-L91
46,443
grrr-amsterdam/garp3
application/modules/g/views/helpers/Video.php
G_View_Helper_Video.getPlayerUrl
public function getPlayerUrl($video, $options = array()) { $helper = $this->_getSpecializedHelper($video); return $helper->getPlayerUrl($video, $options); }
php
public function getPlayerUrl($video, $options = array()) { $helper = $this->_getSpecializedHelper($video); return $helper->getPlayerUrl($video, $options); }
[ "public", "function", "getPlayerUrl", "(", "$", "video", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "helper", "=", "$", "this", "->", "_getSpecializedHelper", "(", "$", "video", ")", ";", "return", "$", "helper", "->", "getPlayerUrl", ...
Get only a player URL. Some sensible default parameters will be applied. @param Garp_Db_Table_Row $video A record from a video table @param array $options Various rendering options @return string
[ "Get", "only", "a", "player", "URL", ".", "Some", "sensible", "default", "parameters", "will", "be", "applied", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Video.php#L57-L60
46,444
grrr-amsterdam/garp3
application/modules/g/views/helpers/Video.php
G_View_Helper_Video.isVimeo
public function isVimeo($video) { $playerurl = (is_string($video) ? $video : (isset($video['player']) ? $video['player'] : $video)); return preg_match('~player\.vimeo\.com~i', $playerurl); }
php
public function isVimeo($video) { $playerurl = (is_string($video) ? $video : (isset($video['player']) ? $video['player'] : $video)); return preg_match('~player\.vimeo\.com~i', $playerurl); }
[ "public", "function", "isVimeo", "(", "$", "video", ")", "{", "$", "playerurl", "=", "(", "is_string", "(", "$", "video", ")", "?", "$", "video", ":", "(", "isset", "(", "$", "video", "[", "'player'", "]", ")", "?", "$", "video", "[", "'player'", ...
Check if video is Vimeo @param Garp_Db_Table_Row|string|array $video @return bool
[ "Check", "if", "video", "is", "Vimeo" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Video.php#L68-L72
46,445
grrr-amsterdam/garp3
application/modules/g/views/helpers/Video.php
G_View_Helper_Video.isYoutube
public function isYoutube($video) { $playerurl = (is_string($video) ? $video : (isset($video['player']) ? $video['player'] : '')); return preg_match('~youtube\.com~i', $playerurl); }
php
public function isYoutube($video) { $playerurl = (is_string($video) ? $video : (isset($video['player']) ? $video['player'] : '')); return preg_match('~youtube\.com~i', $playerurl); }
[ "public", "function", "isYoutube", "(", "$", "video", ")", "{", "$", "playerurl", "=", "(", "is_string", "(", "$", "video", ")", "?", "$", "video", ":", "(", "isset", "(", "$", "video", "[", "'player'", "]", ")", "?", "$", "video", "[", "'player'",...
Check if video is Youtube @param Garp_Db_Table_Row|string|array $video @return bool
[ "Check", "if", "video", "is", "Youtube" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Video.php#L80-L84
46,446
grrr-amsterdam/garp3
application/modules/g/views/helpers/Video.php
G_View_Helper_Video._getSpecializedHelper
protected function _getSpecializedHelper($video) { if ($this->isVimeo($video)) { return $this->view->vimeo(); } elseif ($this->isYoutube($video)) { return $this->view->youTube(); } throw new Exception('Unsupported media type detected: ' . $video); }
php
protected function _getSpecializedHelper($video) { if ($this->isVimeo($video)) { return $this->view->vimeo(); } elseif ($this->isYoutube($video)) { return $this->view->youTube(); } throw new Exception('Unsupported media type detected: ' . $video); }
[ "protected", "function", "_getSpecializedHelper", "(", "$", "video", ")", "{", "if", "(", "$", "this", "->", "isVimeo", "(", "$", "video", ")", ")", "{", "return", "$", "this", "->", "view", "->", "vimeo", "(", ")", ";", "}", "elseif", "(", "$", "t...
Return either the Vimeo or YouTube helper @param Garp_Db_Table_Row|string|array $video @return Zend_View_Helper_Abstract
[ "Return", "either", "the", "Vimeo", "or", "YouTube", "helper" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Video.php#L92-L99
46,447
grrr-amsterdam/garp3
library/Garp/Service/Slack/Config.php
Garp_Service_Slack_Config.getParams
public function getParams(array $overrides = null) { $params = array( 'token' => $this->_token, 'channel' => $this->_channel, 'icon_emoji' => $this->_icon_emoji, 'username' => $this->_username ); if ($overrides) { $params = array_merge($params, $overrides); } return $params; }
php
public function getParams(array $overrides = null) { $params = array( 'token' => $this->_token, 'channel' => $this->_channel, 'icon_emoji' => $this->_icon_emoji, 'username' => $this->_username ); if ($overrides) { $params = array_merge($params, $overrides); } return $params; }
[ "public", "function", "getParams", "(", "array", "$", "overrides", "=", "null", ")", "{", "$", "params", "=", "array", "(", "'token'", "=>", "$", "this", "->", "_token", ",", "'channel'", "=>", "$", "this", "->", "_channel", ",", "'icon_emoji'", "=>", ...
Returns the app-wide configuration parameters. @param Array $overrides Optional values to pragmatically override the app-wide configuration.
[ "Returns", "the", "app", "-", "wide", "configuration", "parameters", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Service/Slack/Config.php#L52-L65
46,448
grrr-amsterdam/garp3
application/modules/g/views/helpers/GoogleStaticMap.php
G_View_Helper_GoogleStaticMap.getMarkersAsString
public function getMarkersAsString($options){ $markers = ''; foreach ($options['markers'] as $marker) { $markers .= $marker['lat'] . ',' . $marker['lng'] . '|'; } return $markers ? substr($markers, 0, -1) : ''; }
php
public function getMarkersAsString($options){ $markers = ''; foreach ($options['markers'] as $marker) { $markers .= $marker['lat'] . ',' . $marker['lng'] . '|'; } return $markers ? substr($markers, 0, -1) : ''; }
[ "public", "function", "getMarkersAsString", "(", "$", "options", ")", "{", "$", "markers", "=", "''", ";", "foreach", "(", "$", "options", "[", "'markers'", "]", "as", "$", "marker", ")", "{", "$", "markers", ".=", "$", "marker", "[", "'lat'", "]", "...
Walks through markers' array @param array $options @return string @todo: implement other marker options
[ "Walks", "through", "markers", "array" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/GoogleStaticMap.php#L47-L55
46,449
grrr-amsterdam/garp3
application/modules/g/views/helpers/GoogleStaticMap.php
G_View_Helper_GoogleStaticMap.render
public function render($options = array()) { $options = array_merge($this->_defaults, $options); $markers = $this->getMarkersAsString($options); $img = ''; $img .= '<img src="http://maps.google.com/maps/api/staticmap'; $img .= '?center=' . $options['location']['lat'] . ',' . $options['location']['lng']; $img .= '&amp;zoom=' . $options['zoomLevel']; $img .= '&amp;size=' . $options['width'] . 'x' . $options['height']; $img .= '&amp;maptype=' . $options['mapType']; $img .= ($markers ? '&amp;markers=' . $markers : ''); $img .= '&amp;sensor=' . ($options['sensor'] ? 'true' : 'false') . '" '; $img .= 'width="' . $options['width'] . '" height="' . $options['height'] . '" alt="'; $img .= $options['altText'] . '" class="g-googlemap" />'; $this->view->script()->src( 'https://www.google.com/maps/api/js?sensor=' . ($options['sensor'] ? 'true' : 'false') ); return $img; }
php
public function render($options = array()) { $options = array_merge($this->_defaults, $options); $markers = $this->getMarkersAsString($options); $img = ''; $img .= '<img src="http://maps.google.com/maps/api/staticmap'; $img .= '?center=' . $options['location']['lat'] . ',' . $options['location']['lng']; $img .= '&amp;zoom=' . $options['zoomLevel']; $img .= '&amp;size=' . $options['width'] . 'x' . $options['height']; $img .= '&amp;maptype=' . $options['mapType']; $img .= ($markers ? '&amp;markers=' . $markers : ''); $img .= '&amp;sensor=' . ($options['sensor'] ? 'true' : 'false') . '" '; $img .= 'width="' . $options['width'] . '" height="' . $options['height'] . '" alt="'; $img .= $options['altText'] . '" class="g-googlemap" />'; $this->view->script()->src( 'https://www.google.com/maps/api/js?sensor=' . ($options['sensor'] ? 'true' : 'false') ); return $img; }
[ "public", "function", "render", "(", "$", "options", "=", "array", "(", ")", ")", "{", "$", "options", "=", "array_merge", "(", "$", "this", "->", "_defaults", ",", "$", "options", ")", ";", "$", "markers", "=", "$", "this", "->", "getMarkersAsString",...
Render the map @param array $options @return string
[ "Render", "the", "map" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/GoogleStaticMap.php#L63-L82
46,450
grrr-amsterdam/garp3
library/Garp/Mail/Transport/AmazonSes.php
Garp_Mail_Transport_AmazonSes._sendMail
public function _sendMail() { $date = gmdate('D, d M Y H:i:s O'); //Send the request $client = new Zend_Http_Client($this->_host); $client->setMethod(Zend_Http_Client::POST); $client->setHeaders(array( 'Date' => $date, 'X-Amzn-Authorization' => $this->_buildAuthKey($date) )); $client->setEncType('application/x-www-form-urlencoded'); //Build the parameters $params = array( 'Action' => 'SendRawEmail', 'Source' => $this->_mail->getFrom(), 'RawMessage.Data' => base64_encode(sprintf("%s\n%s\n", $this->header, $this->body)) ); $recipients = explode(',', $this->recipients); while(list($index, $recipient) = each($recipients)){ $params[sprintf('Destination.ToAddresses.member.%d', $index + 1)] = $recipient; } $client->resetParameters(); $client->setParameterPost($params); $response = $client->request(Zend_Http_Client::POST); if($response->getStatus() != 200){ throw new Exception($response->getBody()); } }
php
public function _sendMail() { $date = gmdate('D, d M Y H:i:s O'); //Send the request $client = new Zend_Http_Client($this->_host); $client->setMethod(Zend_Http_Client::POST); $client->setHeaders(array( 'Date' => $date, 'X-Amzn-Authorization' => $this->_buildAuthKey($date) )); $client->setEncType('application/x-www-form-urlencoded'); //Build the parameters $params = array( 'Action' => 'SendRawEmail', 'Source' => $this->_mail->getFrom(), 'RawMessage.Data' => base64_encode(sprintf("%s\n%s\n", $this->header, $this->body)) ); $recipients = explode(',', $this->recipients); while(list($index, $recipient) = each($recipients)){ $params[sprintf('Destination.ToAddresses.member.%d', $index + 1)] = $recipient; } $client->resetParameters(); $client->setParameterPost($params); $response = $client->request(Zend_Http_Client::POST); if($response->getStatus() != 200){ throw new Exception($response->getBody()); } }
[ "public", "function", "_sendMail", "(", ")", "{", "$", "date", "=", "gmdate", "(", "'D, d M Y H:i:s O'", ")", ";", "//Send the request", "$", "client", "=", "new", "Zend_Http_Client", "(", "$", "this", "->", "_host", ")", ";", "$", "client", "->", "setMeth...
Send an email using the amazon webservice api @return void
[ "Send", "an", "email", "using", "the", "amazon", "webservice", "api" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Mail/Transport/AmazonSes.php#L88-L120
46,451
grrr-amsterdam/garp3
library/Garp/Mail/Transport/AmazonSes.php
Garp_Mail_Transport_AmazonSes._buildAuthKey
private function _buildAuthKey($date){ return sprintf('AWS3-HTTPS AWSAccessKeyId=%s,Algorithm=HmacSHA256,Signature=%s', $this->_accessKey, base64_encode(hash_hmac('sha256', $date, $this->_privateKey, TRUE))); }
php
private function _buildAuthKey($date){ return sprintf('AWS3-HTTPS AWSAccessKeyId=%s,Algorithm=HmacSHA256,Signature=%s', $this->_accessKey, base64_encode(hash_hmac('sha256', $date, $this->_privateKey, TRUE))); }
[ "private", "function", "_buildAuthKey", "(", "$", "date", ")", "{", "return", "sprintf", "(", "'AWS3-HTTPS AWSAccessKeyId=%s,Algorithm=HmacSHA256,Signature=%s'", ",", "$", "this", "->", "_accessKey", ",", "base64_encode", "(", "hash_hmac", "(", "'sha256'", ",", "$", ...
Returns header string containing encoded authentication key @param date $date @return string
[ "Returns", "header", "string", "containing", "encoded", "authentication", "key" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Mail/Transport/AmazonSes.php#L156-L158
46,452
grrr-amsterdam/garp3
library/Garp/Cli/Command/Spawn.php
Garp_Cli_Command_Spawn._spawn
protected function _spawn() { $filter = $this->getFilter(); $dbShouldSpawn = $filter->shouldSpawnDb(); $jsShouldSpawn = $filter->shouldSpawnJs(); $phpShouldSpawn = $filter->shouldSpawnPhp(); $someFilesShouldSpawn = $jsShouldSpawn || $phpShouldSpawn; if ($someFilesShouldSpawn) { $this->_spawnFiles(); } if ($this->getFeedback()->isInteractive()) { Garp_Cli::lineOut("\n"); } if ($dbShouldSpawn) { $this->_spawnDb(); }; }
php
protected function _spawn() { $filter = $this->getFilter(); $dbShouldSpawn = $filter->shouldSpawnDb(); $jsShouldSpawn = $filter->shouldSpawnJs(); $phpShouldSpawn = $filter->shouldSpawnPhp(); $someFilesShouldSpawn = $jsShouldSpawn || $phpShouldSpawn; if ($someFilesShouldSpawn) { $this->_spawnFiles(); } if ($this->getFeedback()->isInteractive()) { Garp_Cli::lineOut("\n"); } if ($dbShouldSpawn) { $this->_spawnDb(); }; }
[ "protected", "function", "_spawn", "(", ")", "{", "$", "filter", "=", "$", "this", "->", "getFilter", "(", ")", ";", "$", "dbShouldSpawn", "=", "$", "filter", "->", "shouldSpawnDb", "(", ")", ";", "$", "jsShouldSpawn", "=", "$", "filter", "->", "should...
Spawn JS and PHP files and the database structure. @return void
[ "Spawn", "JS", "and", "PHP", "files", "and", "the", "database", "structure", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Spawn.php#L127-L146
46,453
grrr-amsterdam/garp3
library/Garp/Cli/Command/Spawn.php
Garp_Cli_Command_Spawn._isHelpRequested
protected function _isHelpRequested($args) { if (array_key_exists('help', $args)) { return true; } if (!$this->_isFirstArgumentGiven($args)) { return false; } $helpWasAsked = strcasecmp($args[0], 'help') === 0; return $helpWasAsked; }
php
protected function _isHelpRequested($args) { if (array_key_exists('help', $args)) { return true; } if (!$this->_isFirstArgumentGiven($args)) { return false; } $helpWasAsked = strcasecmp($args[0], 'help') === 0; return $helpWasAsked; }
[ "protected", "function", "_isHelpRequested", "(", "$", "args", ")", "{", "if", "(", "array_key_exists", "(", "'help'", ",", "$", "args", ")", ")", "{", "return", "true", ";", "}", "if", "(", "!", "$", "this", "->", "_isFirstArgumentGiven", "(", "$", "a...
Detects whether the CLI user was asking for help. @param array $args @return bool
[ "Detects", "whether", "the", "CLI", "user", "was", "asking", "for", "help", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Spawn.php#L249-L260
46,454
grrr-amsterdam/garp3
library/Garp/Model/Behavior/HtmlFilterable.php
Garp_Model_Behavior_HtmlFilterable.filter
public function filter($string, HTMLPurifier_Config $config) { if (!$string) { return $string; } $config->finalize(); $purifier = new HTMLPurifier($config); $string = $purifier->purify($string); return $string; }
php
public function filter($string, HTMLPurifier_Config $config) { if (!$string) { return $string; } $config->finalize(); $purifier = new HTMLPurifier($config); $string = $purifier->purify($string); return $string; }
[ "public", "function", "filter", "(", "$", "string", ",", "HTMLPurifier_Config", "$", "config", ")", "{", "if", "(", "!", "$", "string", ")", "{", "return", "$", "string", ";", "}", "$", "config", "->", "finalize", "(", ")", ";", "$", "purifier", "=",...
Filter unwanted HTML out of a string @param String $string The string @param HTMLPurifier_Config $config @return String The filtered string
[ "Filter", "unwanted", "HTML", "out", "of", "a", "string" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/HtmlFilterable.php#L49-L57
46,455
grrr-amsterdam/garp3
library/Garp/Cli/Command/Aws.php
Garp_Cli_Command_Aws._exec
protected function _exec($group, $subCmd, $args) { $keys = array_keys($args); $cmd = "aws $group $subCmd"; foreach ($keys as $key) { $cmd .= is_numeric($key) ? ' ' : " --{$key}"; $cmd .= true === $args[$key] ? '' : ' ' . $args[$key]; } $cmd .= " --profile {$this->_profile}"; return passthru($cmd); }
php
protected function _exec($group, $subCmd, $args) { $keys = array_keys($args); $cmd = "aws $group $subCmd"; foreach ($keys as $key) { $cmd .= is_numeric($key) ? ' ' : " --{$key}"; $cmd .= true === $args[$key] ? '' : ' ' . $args[$key]; } $cmd .= " --profile {$this->_profile}"; return passthru($cmd); }
[ "protected", "function", "_exec", "(", "$", "group", ",", "$", "subCmd", ",", "$", "args", ")", "{", "$", "keys", "=", "array_keys", "(", "$", "args", ")", ";", "$", "cmd", "=", "\"aws $group $subCmd\"", ";", "foreach", "(", "$", "keys", "as", "$", ...
Execute awscmd function @param str $group For instance s3, or ec2 @param str $subCmd For instance 'ls' or 'cp' @param array $args Further commandline arguments @return bool
[ "Execute", "awscmd", "function" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Aws.php#L96-L106
46,456
grrr-amsterdam/garp3
library/Garp/Cli/Command/Aws.php
Garp_Cli_Command_Aws._setProfile
protected function _setProfile() { $projectName = basename(dirname(realpath(APPLICATION_PATH))); $profileName = $projectName . '_' . APPLICATION_ENV; $this->_profile = $profileName; }
php
protected function _setProfile() { $projectName = basename(dirname(realpath(APPLICATION_PATH))); $profileName = $projectName . '_' . APPLICATION_ENV; $this->_profile = $profileName; }
[ "protected", "function", "_setProfile", "(", ")", "{", "$", "projectName", "=", "basename", "(", "dirname", "(", "realpath", "(", "APPLICATION_PATH", ")", ")", ")", ";", "$", "profileName", "=", "$", "projectName", ".", "'_'", ".", "APPLICATION_ENV", ";", ...
Set the current profile @return void
[ "Set", "the", "current", "profile" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Aws.php#L113-L118
46,457
grrr-amsterdam/garp3
library/Garp/Cli/Command/Aws.php
Garp_Cli_Command_Aws._profileExists
protected function _profileExists() { $homeDir = trim(`echo \$HOME`); $config = file_get_contents($homeDir . DIRECTORY_SEPARATOR . self::AWS_CONFIG_LOCATION); return strpos($config, "[profile {$this->_profile}]") !== false; }
php
protected function _profileExists() { $homeDir = trim(`echo \$HOME`); $config = file_get_contents($homeDir . DIRECTORY_SEPARATOR . self::AWS_CONFIG_LOCATION); return strpos($config, "[profile {$this->_profile}]") !== false; }
[ "protected", "function", "_profileExists", "(", ")", "{", "$", "homeDir", "=", "trim", "(", "`echo \\$HOME`", ")", ";", "$", "config", "=", "file_get_contents", "(", "$", "homeDir", ".", "DIRECTORY_SEPARATOR", ".", "self", "::", "AWS_CONFIG_LOCATION", ")", ";"...
Check if the current profile exists @return bool
[ "Check", "if", "the", "current", "profile", "exists" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Aws.php#L125-L129
46,458
grrr-amsterdam/garp3
library/Garp/Cli/Command/Aws.php
Garp_Cli_Command_Aws._createProfile
protected function _createProfile() { $config = Zend_Registry::get('config'); $confStr = "[profile {$this->_profile}]\n"; $confStr .= "aws_access_key_id = {$config->cdn->s3->apikey}\n"; $confStr .= "aws_secret_access_key = {$config->cdn->s3->secret}\n"; $confStr .= "output = json\n"; $confStr .= "region = eu-west-1\n\n"; $homeDir = trim(`echo \$HOME`); file_put_contents( $homeDir . DIRECTORY_SEPARATOR . self::AWS_CONFIG_LOCATION, $confStr, FILE_APPEND ); }
php
protected function _createProfile() { $config = Zend_Registry::get('config'); $confStr = "[profile {$this->_profile}]\n"; $confStr .= "aws_access_key_id = {$config->cdn->s3->apikey}\n"; $confStr .= "aws_secret_access_key = {$config->cdn->s3->secret}\n"; $confStr .= "output = json\n"; $confStr .= "region = eu-west-1\n\n"; $homeDir = trim(`echo \$HOME`); file_put_contents( $homeDir . DIRECTORY_SEPARATOR . self::AWS_CONFIG_LOCATION, $confStr, FILE_APPEND ); }
[ "protected", "function", "_createProfile", "(", ")", "{", "$", "config", "=", "Zend_Registry", "::", "get", "(", "'config'", ")", ";", "$", "confStr", "=", "\"[profile {$this->_profile}]\\n\"", ";", "$", "confStr", ".=", "\"aws_access_key_id = {$config->cdn->s3->apike...
Create the currently used profile @return void
[ "Create", "the", "currently", "used", "profile" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Aws.php#L136-L150
46,459
grrr-amsterdam/garp3
library/Garp/Cli/Command/Aws.php
Garp_Cli_Command_Aws._usesAmazon
protected function _usesAmazon() { $config = Zend_Registry::get('config'); return !empty($config->cdn->s3->apikey) && !empty($config->cdn->s3->secret); }
php
protected function _usesAmazon() { $config = Zend_Registry::get('config'); return !empty($config->cdn->s3->apikey) && !empty($config->cdn->s3->secret); }
[ "protected", "function", "_usesAmazon", "(", ")", "{", "$", "config", "=", "Zend_Registry", "::", "get", "(", "'config'", ")", ";", "return", "!", "empty", "(", "$", "config", "->", "cdn", "->", "s3", "->", "apikey", ")", "&&", "!", "empty", "(", "$"...
Check wether environment actually uses Amazon @return bool
[ "Check", "wether", "environment", "actually", "uses", "Amazon" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Aws.php#L157-L160
46,460
grrr-amsterdam/garp3
application/modules/g/controllers/ContentController.php
G_ContentController.init
public function init() { // Do not cache CMS pages. This prevents a common situation where people logout, return to // the CMS, and see the interface but none of the content feeds load. Only after a browser // refresh they'll get bounced to the login page. $this->_helper->cache->setNoCacheHeaders($this->getResponse()); $config = Zend_Registry::get('config'); $this->_setCmsClosedMessage(); if (!$config->cms || !$config->cms->ipfilter || !count($config->cms->ipfilter->toArray())) { return true; } $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null; if ($ip === '127.0.0.1') { // i mean come on return true; } if (!in_array($ip, $config->cms->ipfilter->toArray())) { $authVars = Garp_Auth::getInstance()->getConfigValues(); $this->_helper->flashMessenger(__($authVars['noPermissionMsg'])); $this->_helper->redirector->gotoRoute(array(), $authVars['login']['route']); return false; } }
php
public function init() { // Do not cache CMS pages. This prevents a common situation where people logout, return to // the CMS, and see the interface but none of the content feeds load. Only after a browser // refresh they'll get bounced to the login page. $this->_helper->cache->setNoCacheHeaders($this->getResponse()); $config = Zend_Registry::get('config'); $this->_setCmsClosedMessage(); if (!$config->cms || !$config->cms->ipfilter || !count($config->cms->ipfilter->toArray())) { return true; } $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null; if ($ip === '127.0.0.1') { // i mean come on return true; } if (!in_array($ip, $config->cms->ipfilter->toArray())) { $authVars = Garp_Auth::getInstance()->getConfigValues(); $this->_helper->flashMessenger(__($authVars['noPermissionMsg'])); $this->_helper->redirector->gotoRoute(array(), $authVars['login']['route']); return false; } }
[ "public", "function", "init", "(", ")", "{", "// Do not cache CMS pages. This prevents a common situation where people logout, return to", "// the CMS, and see the interface but none of the content feeds load. Only after a browser", "// refresh they'll get bounced to the login page.", "$", "this...
Called before all actions @return Void
[ "Called", "before", "all", "actions" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/ContentController.php#L23-L45
46,461
grrr-amsterdam/garp3
application/modules/g/controllers/ContentController.php
G_ContentController.cookiesAction
public function cookiesAction() { $config = Zend_Registry::get('config'); $viewBasePath = $config->resources->view->basePath ?: APPLICATION_PATH . '/modules/default/views'; $this->_helper->layout->setLayoutPath($viewBasePath . '/layouts/'); $this->view->title = 'Cookies'; }
php
public function cookiesAction() { $config = Zend_Registry::get('config'); $viewBasePath = $config->resources->view->basePath ?: APPLICATION_PATH . '/modules/default/views'; $this->_helper->layout->setLayoutPath($viewBasePath . '/layouts/'); $this->view->title = 'Cookies'; }
[ "public", "function", "cookiesAction", "(", ")", "{", "$", "config", "=", "Zend_Registry", "::", "get", "(", "'config'", ")", ";", "$", "viewBasePath", "=", "$", "config", "->", "resources", "->", "view", "->", "basePath", "?", ":", "APPLICATION_PATH", "."...
Display some information about cookies @return Void
[ "Display", "some", "information", "about", "cookies" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/ContentController.php#L88-L95
46,462
grrr-amsterdam/garp3
application/modules/g/controllers/ContentController.php
G_ContentController.apiAction
public function apiAction() { /** * Prepare the server. Zend_Json_Server cannot work with batched requests natively, * so that's taken care of customly here. Therefore, autoEmitResponse is set to false * so the server doesn't print the response directly. */ $server = new Zend_Json_Server(); $server->setClass('Garp_Content_Manager_Proxy'); $server->setAutoEmitResponse(false); if ($this->getRequest()->isPost()) { $post = $this->_getJsonRpcRequest(); $batch = false; $responses = array(); $requests = Zend_Json::decode($post, Zend_Json::TYPE_ARRAY); /** * Check if this was a batch request. In that case the array is a plain array of * arrays. If not, there will be a 'jsonrpc' key in the root of the array. */ $batch = !array_key_exists('jsonrpc', $requests); if (!$batch) { $requests = array($requests); } foreach ($requests as $i => $request) { $request = $this->_reformJsonRpcRequest($request); $requestJson = Zend_Json::encode($request); $requestObj = new Zend_Json_Server_Request(); $requestObj->loadJson($requestJson); $server->setRequest($requestObj); /** * Note; response gets returned by reference, resulting in a $responses array * containing all the same items. * That's why clone is used here. */ $response = clone $server->handle(); $responses[] = $response; } $response = $batch ? '[' . implode(',', $responses) . ']' : $responses[0]; } else { $response = $server->getServiceMap(); } $this->_helper->layout->setLayout('json'); // filter out escaped slashes, because they're annoying and not necessary. $response = str_replace('\/', '/', $response); $this->view->response = $response; }
php
public function apiAction() { /** * Prepare the server. Zend_Json_Server cannot work with batched requests natively, * so that's taken care of customly here. Therefore, autoEmitResponse is set to false * so the server doesn't print the response directly. */ $server = new Zend_Json_Server(); $server->setClass('Garp_Content_Manager_Proxy'); $server->setAutoEmitResponse(false); if ($this->getRequest()->isPost()) { $post = $this->_getJsonRpcRequest(); $batch = false; $responses = array(); $requests = Zend_Json::decode($post, Zend_Json::TYPE_ARRAY); /** * Check if this was a batch request. In that case the array is a plain array of * arrays. If not, there will be a 'jsonrpc' key in the root of the array. */ $batch = !array_key_exists('jsonrpc', $requests); if (!$batch) { $requests = array($requests); } foreach ($requests as $i => $request) { $request = $this->_reformJsonRpcRequest($request); $requestJson = Zend_Json::encode($request); $requestObj = new Zend_Json_Server_Request(); $requestObj->loadJson($requestJson); $server->setRequest($requestObj); /** * Note; response gets returned by reference, resulting in a $responses array * containing all the same items. * That's why clone is used here. */ $response = clone $server->handle(); $responses[] = $response; } $response = $batch ? '[' . implode(',', $responses) . ']' : $responses[0]; } else { $response = $server->getServiceMap(); } $this->_helper->layout->setLayout('json'); // filter out escaped slashes, because they're annoying and not necessary. $response = str_replace('\/', '/', $response); $this->view->response = $response; }
[ "public", "function", "apiAction", "(", ")", "{", "/**\n * Prepare the server. Zend_Json_Server cannot work with batched requests natively,\n * so that's taken care of customly here. Therefore, autoEmitResponse is set to false\n * so the server doesn't print the response directly...
JSON-RPC entrance. @return Void
[ "JSON", "-", "RPC", "entrance", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/ContentController.php#L134-L179
46,463
grrr-amsterdam/garp3
application/modules/g/controllers/ContentController.php
G_ContentController.downloadAction
public function downloadAction() { $ini = Zend_Registry::get('config'); $downloadType = $this->getRequest()->getParam('downloadType') ?: Garp_File::TYPE_DOCUMENTS; $uploadOrStatic = $this->getRequest()->getParam('uploadOrStatic') ?: 'upload'; $file = $this->getRequest()->getParam('file'); if (!$file) { throw new Zend_Controller_Action_Exception('Geen bestandsnaam opgegeven.', 404); } try { $fileHandler = new Garp_File($downloadType, $uploadOrStatic); $url = $fileHandler->getUrl($file); $this->_downloadFile($url); } catch (Garp_File_Exception_InvalidType $e) { // Just throw a 404, since the error is basically just a wrong URL. throw new Zend_Controller_Action_Exception($e->getMessage(), 404); } }
php
public function downloadAction() { $ini = Zend_Registry::get('config'); $downloadType = $this->getRequest()->getParam('downloadType') ?: Garp_File::TYPE_DOCUMENTS; $uploadOrStatic = $this->getRequest()->getParam('uploadOrStatic') ?: 'upload'; $file = $this->getRequest()->getParam('file'); if (!$file) { throw new Zend_Controller_Action_Exception('Geen bestandsnaam opgegeven.', 404); } try { $fileHandler = new Garp_File($downloadType, $uploadOrStatic); $url = $fileHandler->getUrl($file); $this->_downloadFile($url); } catch (Garp_File_Exception_InvalidType $e) { // Just throw a 404, since the error is basically just a wrong URL. throw new Zend_Controller_Action_Exception($e->getMessage(), 404); } }
[ "public", "function", "downloadAction", "(", ")", "{", "$", "ini", "=", "Zend_Registry", "::", "get", "(", "'config'", ")", ";", "$", "downloadType", "=", "$", "this", "->", "getRequest", "(", ")", "->", "getParam", "(", "'downloadType'", ")", "?", ":", ...
Download an uploaded file @return Void
[ "Download", "an", "uploaded", "file" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/ContentController.php#L270-L288
46,464
grrr-amsterdam/garp3
application/modules/g/controllers/ContentController.php
G_ContentController.importAction
public function importAction() { $memLim = ini_get('memory_limit'); ini_set('memory_limit', '2G'); set_time_limit(0); // No time limit $params = new Garp_Util_Configuration($this->getRequest()->getParams()); $params->obligate('datafile') ->obligate('model') ->setDefault('firstRow', 0) ->setDefault('ignoreErrors', false); $importer = Garp_Content_Import_Factory::getImporter($params['datafile']); $success = false; if (isset($params['mapping'])) { $mapping = Zend_Json::decode($params['mapping']); $className = Garp_Content_Api::modelAliasToClass($params['model']); $model = new $className(); $model->setCmsContext(true); $response = array(); try { $success = !!$importer->save( $model, $mapping, array( 'firstRow' => $params['firstRow'], 'ignoreErrors' => $params['ignoreErrors'], ) ); } catch (Exception $e) { $response['message'] = $e->getMessage(); } if ($success) { // cleanup input file $gf = new Garp_File(); $gf->remove($params['datafile']); } $response['success'] = $success; $this->view->response = $response; } else { $std = new stdClass(); $std->success = true; $std->data = $importer->getSampleData(); $this->view->response = $std; } ini_set('memory_limit', $memLim); $this->_helper->layout->setLayout('json'); $this->renderScript('content/call.phtml'); }
php
public function importAction() { $memLim = ini_get('memory_limit'); ini_set('memory_limit', '2G'); set_time_limit(0); // No time limit $params = new Garp_Util_Configuration($this->getRequest()->getParams()); $params->obligate('datafile') ->obligate('model') ->setDefault('firstRow', 0) ->setDefault('ignoreErrors', false); $importer = Garp_Content_Import_Factory::getImporter($params['datafile']); $success = false; if (isset($params['mapping'])) { $mapping = Zend_Json::decode($params['mapping']); $className = Garp_Content_Api::modelAliasToClass($params['model']); $model = new $className(); $model->setCmsContext(true); $response = array(); try { $success = !!$importer->save( $model, $mapping, array( 'firstRow' => $params['firstRow'], 'ignoreErrors' => $params['ignoreErrors'], ) ); } catch (Exception $e) { $response['message'] = $e->getMessage(); } if ($success) { // cleanup input file $gf = new Garp_File(); $gf->remove($params['datafile']); } $response['success'] = $success; $this->view->response = $response; } else { $std = new stdClass(); $std->success = true; $std->data = $importer->getSampleData(); $this->view->response = $std; } ini_set('memory_limit', $memLim); $this->_helper->layout->setLayout('json'); $this->renderScript('content/call.phtml'); }
[ "public", "function", "importAction", "(", ")", "{", "$", "memLim", "=", "ini_get", "(", "'memory_limit'", ")", ";", "ini_set", "(", "'memory_limit'", ",", "'2G'", ")", ";", "set_time_limit", "(", "0", ")", ";", "// No time limit", "$", "params", "=", "new...
Import content from various formats. This action has two states; - first a datafile is uploaded. The user is presented with a mapping interface where they have to map columns in the datafile to columns in the database. - then this URL is called again with the selected mapping, and the columns are mapped and inserted into the database. @return Void
[ "Import", "content", "from", "various", "formats", ".", "This", "action", "has", "two", "states", ";", "-", "first", "a", "datafile", "is", "uploaded", ".", "The", "user", "is", "presented", "with", "a", "mapping", "interface", "where", "they", "have", "to...
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/ContentController.php#L379-L426
46,465
grrr-amsterdam/garp3
application/modules/g/controllers/ContentController.php
G_ContentController.exportAction
public function exportAction() { $mem = new Garp_Util_Memory(); $mem->useHighMemory(); $params = new Garp_Util_Configuration($this->getRequest()->getParams()); // make sure some required parameters are in place $params->obligate('exporttype') ->obligate('model') ->obligate('selection') ->setDefault('fields', Zend_Db_Select::SQL_WILDCARD); // fetch exporter $exporter = Garp_Content_Export_Factory::getExporter($params['exporttype']); $bytes = $exporter->getOutput($params); $filename = $exporter->getFilename($params); $download = Zend_Controller_Action_HelperBroker::getStaticHelper('download'); $download->force($bytes, $filename, $this->_response); $this->_helper->viewRenderer->setNoRender(); }
php
public function exportAction() { $mem = new Garp_Util_Memory(); $mem->useHighMemory(); $params = new Garp_Util_Configuration($this->getRequest()->getParams()); // make sure some required parameters are in place $params->obligate('exporttype') ->obligate('model') ->obligate('selection') ->setDefault('fields', Zend_Db_Select::SQL_WILDCARD); // fetch exporter $exporter = Garp_Content_Export_Factory::getExporter($params['exporttype']); $bytes = $exporter->getOutput($params); $filename = $exporter->getFilename($params); $download = Zend_Controller_Action_HelperBroker::getStaticHelper('download'); $download->force($bytes, $filename, $this->_response); $this->_helper->viewRenderer->setNoRender(); }
[ "public", "function", "exportAction", "(", ")", "{", "$", "mem", "=", "new", "Garp_Util_Memory", "(", ")", ";", "$", "mem", "->", "useHighMemory", "(", ")", ";", "$", "params", "=", "new", "Garp_Util_Configuration", "(", "$", "this", "->", "getRequest", ...
Export content in various formats @return Void
[ "Export", "content", "in", "various", "formats" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/ContentController.php#L433-L452
46,466
grrr-amsterdam/garp3
application/modules/g/controllers/ContentController.php
G_ContentController.clearcacheAction
public function clearcacheAction() { $request = $this->getRequest(); $tags = array(); if ($request->getParam('tags')) { $tags = explode(',', $request->getParam('tags')); } $createClusterJob = is_null($request->getParam('createClusterJob')) ? 1 : $request->getParam('createClusterJob'); $this->view->title = 'Clear that cache'; Garp_Cache_Manager::purge($tags, $createClusterJob); }
php
public function clearcacheAction() { $request = $this->getRequest(); $tags = array(); if ($request->getParam('tags')) { $tags = explode(',', $request->getParam('tags')); } $createClusterJob = is_null($request->getParam('createClusterJob')) ? 1 : $request->getParam('createClusterJob'); $this->view->title = 'Clear that cache'; Garp_Cache_Manager::purge($tags, $createClusterJob); }
[ "public", "function", "clearcacheAction", "(", ")", "{", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "$", "tags", "=", "array", "(", ")", ";", "if", "(", "$", "request", "->", "getParam", "(", "'tags'", ")", ")", "{", "$", ...
Clear all cache system wide. Static Cache is tagged, so a comma-separated list of tags may be given to only clear cache tagged with those tags. Memcache is not tagged. @return Void
[ "Clear", "all", "cache", "system", "wide", ".", "Static", "Cache", "is", "tagged", "so", "a", "comma", "-", "separated", "list", "of", "tags", "may", "be", "given", "to", "only", "clear", "cache", "tagged", "with", "those", "tags", ".", "Memcache", "is",...
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/ContentController.php#L462-L473
46,467
grrr-amsterdam/garp3
application/modules/g/controllers/ContentController.php
G_ContentController._getJsonRpcRequest
protected function _getJsonRpcRequest() { if ($this->getRequest()->getPost('request')) { return $this->getRequest()->getPost('request'); } return $request = $this->getRequest()->getRawBody(); }
php
protected function _getJsonRpcRequest() { if ($this->getRequest()->getPost('request')) { return $this->getRequest()->getPost('request'); } return $request = $this->getRequest()->getRawBody(); }
[ "protected", "function", "_getJsonRpcRequest", "(", ")", "{", "if", "(", "$", "this", "->", "getRequest", "(", ")", "->", "getPost", "(", "'request'", ")", ")", "{", "return", "$", "this", "->", "getRequest", "(", ")", "->", "getPost", "(", "'request'", ...
Retrieve POSTed JSON-RPC request @return String
[ "Retrieve", "POSTed", "JSON", "-", "RPC", "request" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/ContentController.php#L542-L547
46,468
grrr-amsterdam/garp3
library/Garp/Content/Upload/Mediator.php
Garp_Content_Upload_Mediator.fetchDiff
public function fetchDiff() { $progress = Garp_Cli_Ui_ProgressBar::getInstance(); $diffList = new Garp_Content_Upload_FileList(); $sourceList = $this->_source->fetchFileList(); $targetList = $this->_target->fetchFileList(); $progress->display("Looking for new files"); $newFiles = $this->_findNewFiles($sourceList, $targetList); $progress->display("Looking for conflicting files"); $conflictingFiles = $this->_findConflictingFiles($sourceList, $targetList); $diffList->addEntries($newFiles); $diffList->addEntries($conflictingFiles); return $diffList; }
php
public function fetchDiff() { $progress = Garp_Cli_Ui_ProgressBar::getInstance(); $diffList = new Garp_Content_Upload_FileList(); $sourceList = $this->_source->fetchFileList(); $targetList = $this->_target->fetchFileList(); $progress->display("Looking for new files"); $newFiles = $this->_findNewFiles($sourceList, $targetList); $progress->display("Looking for conflicting files"); $conflictingFiles = $this->_findConflictingFiles($sourceList, $targetList); $diffList->addEntries($newFiles); $diffList->addEntries($conflictingFiles); return $diffList; }
[ "public", "function", "fetchDiff", "(", ")", "{", "$", "progress", "=", "Garp_Cli_Ui_ProgressBar", "::", "getInstance", "(", ")", ";", "$", "diffList", "=", "new", "Garp_Content_Upload_FileList", "(", ")", ";", "$", "sourceList", "=", "$", "this", "->", "_so...
Finds out which files should be transferred. @return Garp_Content_Upload_FileList List of file paths that should be transferred from source to target.
[ "Finds", "out", "which", "files", "should", "be", "transferred", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Upload/Mediator.php#L54-L71
46,469
grrr-amsterdam/garp3
library/Garp/I18n/ModelFactory.php
Garp_I18n_ModelFactory.getModel
public function getModel($model) { $this->_normalizeModel($model); $langSuffix = ucfirst(strtolower($this->_language)); // Sanity check: is the model already localized? if ($this->_modelIsLocalized($model)) { throw new Garp_I18n_ModelFactory_Exception_ModelAlreadyLocalized( "Looks like model $model is already internationalized." ); } $modelName = $model.$langSuffix; $model = new $modelName(); return $model; }
php
public function getModel($model) { $this->_normalizeModel($model); $langSuffix = ucfirst(strtolower($this->_language)); // Sanity check: is the model already localized? if ($this->_modelIsLocalized($model)) { throw new Garp_I18n_ModelFactory_Exception_ModelAlreadyLocalized( "Looks like model $model is already internationalized." ); } $modelName = $model.$langSuffix; $model = new $modelName(); return $model; }
[ "public", "function", "getModel", "(", "$", "model", ")", "{", "$", "this", "->", "_normalizeModel", "(", "$", "model", ")", ";", "$", "langSuffix", "=", "ucfirst", "(", "strtolower", "(", "$", "this", "->", "_language", ")", ")", ";", "// Sanity check: ...
Load the model @param Garp_Model_Db|String $model The original model, based on a table. @return Garp_Model_Db
[ "Load", "the", "model" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/I18n/ModelFactory.php#L38-L50
46,470
grrr-amsterdam/garp3
library/Garp/I18n/ModelFactory.php
Garp_I18n_ModelFactory.getBindingModel
public function getBindingModel($bindingModel) { $this->_normalizeModel($bindingModel); $bindingModel = new $bindingModel(); $referenceMap = $bindingModel->getReferenceMapNormalized(); foreach ($referenceMap as $rule => $reference) { // Check here wether we need to internationalize the refTableClass $refModel = new $reference['refTableClass']; if ($refModel->getObserver('Translatable')) { try { $refModel = $this->getModel($reference['refTableClass']); } catch (Garp_I18n_ModelFactory_Exception_ModelAlreadyLocalized $e) { continue; } } $refTableClass = get_class($refModel); $bindingModel->addReference( $rule, $reference['columns'], $refTableClass, $reference['refColumns'] ); } return $bindingModel; }
php
public function getBindingModel($bindingModel) { $this->_normalizeModel($bindingModel); $bindingModel = new $bindingModel(); $referenceMap = $bindingModel->getReferenceMapNormalized(); foreach ($referenceMap as $rule => $reference) { // Check here wether we need to internationalize the refTableClass $refModel = new $reference['refTableClass']; if ($refModel->getObserver('Translatable')) { try { $refModel = $this->getModel($reference['refTableClass']); } catch (Garp_I18n_ModelFactory_Exception_ModelAlreadyLocalized $e) { continue; } } $refTableClass = get_class($refModel); $bindingModel->addReference( $rule, $reference['columns'], $refTableClass, $reference['refColumns'] ); } return $bindingModel; }
[ "public", "function", "getBindingModel", "(", "$", "bindingModel", ")", "{", "$", "this", "->", "_normalizeModel", "(", "$", "bindingModel", ")", ";", "$", "bindingModel", "=", "new", "$", "bindingModel", "(", ")", ";", "$", "referenceMap", "=", "$", "bind...
Retrieve an internationalized bindingModel. Its referenceMap will be tweaked to reflect the changes given as the second parameter. @param Garp_Model_Db|String $model The original model, based on a table. @return Garp_Model_Db
[ "Retrieve", "an", "internationalized", "bindingModel", ".", "Its", "referenceMap", "will", "be", "tweaked", "to", "reflect", "the", "changes", "given", "as", "the", "second", "parameter", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/I18n/ModelFactory.php#L58-L82
46,471
grrr-amsterdam/garp3
library/Garp/I18n/ModelFactory.php
Garp_I18n_ModelFactory._normalizeModel
protected function _normalizeModel(&$model) { if ($model instanceof Garp_Model_Db) { $model = get_class($model); } $model = strpos($model, 'Model_') !== false ? $model : 'Model_' . $model; }
php
protected function _normalizeModel(&$model) { if ($model instanceof Garp_Model_Db) { $model = get_class($model); } $model = strpos($model, 'Model_') !== false ? $model : 'Model_' . $model; }
[ "protected", "function", "_normalizeModel", "(", "&", "$", "model", ")", "{", "if", "(", "$", "model", "instanceof", "Garp_Model_Db", ")", "{", "$", "model", "=", "get_class", "(", "$", "model", ")", ";", "}", "$", "model", "=", "strpos", "(", "$", "...
Go from a modelname to a model object @param Mixed $model @return Garp_Model_Db
[ "Go", "from", "a", "modelname", "to", "a", "model", "object" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/I18n/ModelFactory.php#L107-L112
46,472
grrr-amsterdam/garp3
library/Garp/Spawn/MySql/View/Joint.php
Garp_Spawn_MySql_View_Joint._getRecordLabelSqlForModel
protected function _getRecordLabelSqlForModel($tableAlias, $modelName) { $model = $this->_getModelFromModelName($modelName); $tableName = $this->_getOtherTableName($modelName); $recordLabelFieldDefs = $this->_getRecordLabelFieldDefinitions($tableAlias, $model); $labelColumnsListSql = implode(', ', $recordLabelFieldDefs); $glue = $this->_modelHasFirstAndLastNameListFields($model) ? ' ' : ', '; $sql = "CONVERT(CONCAT_WS('{$glue}', " . $labelColumnsListSql . ') USING utf8)'; return $sql; }
php
protected function _getRecordLabelSqlForModel($tableAlias, $modelName) { $model = $this->_getModelFromModelName($modelName); $tableName = $this->_getOtherTableName($modelName); $recordLabelFieldDefs = $this->_getRecordLabelFieldDefinitions($tableAlias, $model); $labelColumnsListSql = implode(', ', $recordLabelFieldDefs); $glue = $this->_modelHasFirstAndLastNameListFields($model) ? ' ' : ', '; $sql = "CONVERT(CONCAT_WS('{$glue}', " . $labelColumnsListSql . ') USING utf8)'; return $sql; }
[ "protected", "function", "_getRecordLabelSqlForModel", "(", "$", "tableAlias", ",", "$", "modelName", ")", "{", "$", "model", "=", "$", "this", "->", "_getModelFromModelName", "(", "$", "modelName", ")", ";", "$", "tableName", "=", "$", "this", "->", "_getOt...
Compose the method to fetch composite columns as a string in a MySql query to use as a label to identify the record. These have to be columns in the provided table, to be able to be used flexibly in another query. @param string $tableAlias @param string $modelName @return string
[ "Compose", "the", "method", "to", "fetch", "composite", "columns", "as", "a", "string", "in", "a", "MySql", "query", "to", "use", "as", "a", "label", "to", "identify", "the", "record", ".", "These", "have", "to", "be", "columns", "in", "the", "provided",...
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Spawn/MySql/View/Joint.php#L203-L214
46,473
grrr-amsterdam/garp3
library/Garp/Util/FullName.php
Garp_Util_FullName._getFullName
protected function _getFullName($person) { if (array_key_exists('first_name', $person) && array_key_exists('last_name_prefix', $person) && array_key_exists('last_name', $person) ) { $first = $person['first_name']; $middle = $person['last_name_prefix'] ? ' ' . $person['last_name_prefix'] : ''; $last = $person['last_name'] ? ' ' . $person['last_name'] : ''; return $first . $middle . $last; } elseif (array_key_exists('name', $person)) { return $person['name']; } else { throw new Exception( 'This model does not have a first name, last name prefix ' . 'and last name. Nor does it have a singular name field.' ); } }
php
protected function _getFullName($person) { if (array_key_exists('first_name', $person) && array_key_exists('last_name_prefix', $person) && array_key_exists('last_name', $person) ) { $first = $person['first_name']; $middle = $person['last_name_prefix'] ? ' ' . $person['last_name_prefix'] : ''; $last = $person['last_name'] ? ' ' . $person['last_name'] : ''; return $first . $middle . $last; } elseif (array_key_exists('name', $person)) { return $person['name']; } else { throw new Exception( 'This model does not have a first name, last name prefix ' . 'and last name. Nor does it have a singular name field.' ); } }
[ "protected", "function", "_getFullName", "(", "$", "person", ")", "{", "if", "(", "array_key_exists", "(", "'first_name'", ",", "$", "person", ")", "&&", "array_key_exists", "(", "'last_name_prefix'", ",", "$", "person", ")", "&&", "array_key_exists", "(", "'l...
Create full name @param Garp_Db_Table_Row|StdClass|array $person @return string
[ "Create", "full", "name" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Util/FullName.php#L41-L58
46,474
grrr-amsterdam/garp3
library/Garp/Spawn/Behavior/Set.php
Garp_Spawn_Behavior_Set._addWeighableBehavior
protected function _addWeighableBehavior() { $model = $this->getModel(); $weighableRels = $model->relations->getRelations('weighable', true); if (!$weighableRels) { return; } $weighableConfig = array(); foreach ($weighableRels as $relName => $rel) { $weightColumn = Garp_Spawn_Util::camelcased2underscored($relName) . '_weight'; $weighableConfig[$relName] = array( 'foreignKeyColumn' => $rel->column, 'weightColumn' => $weightColumn ); } $this->_add('relation', 'Weighable', $weighableConfig); }
php
protected function _addWeighableBehavior() { $model = $this->getModel(); $weighableRels = $model->relations->getRelations('weighable', true); if (!$weighableRels) { return; } $weighableConfig = array(); foreach ($weighableRels as $relName => $rel) { $weightColumn = Garp_Spawn_Util::camelcased2underscored($relName) . '_weight'; $weighableConfig[$relName] = array( 'foreignKeyColumn' => $rel->column, 'weightColumn' => $weightColumn ); } $this->_add('relation', 'Weighable', $weighableConfig); }
[ "protected", "function", "_addWeighableBehavior", "(", ")", "{", "$", "model", "=", "$", "this", "->", "getModel", "(", ")", ";", "$", "weighableRels", "=", "$", "model", "->", "relations", "->", "getRelations", "(", "'weighable'", ",", "true", ")", ";", ...
Adds the weighable behavior, for user defined sorting of related objects. Can only be initialized after the relations for this model are set. @return void
[ "Adds", "the", "weighable", "behavior", "for", "user", "defined", "sorting", "of", "related", "objects", ".", "Can", "only", "be", "initialized", "after", "the", "relations", "for", "this", "model", "are", "set", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Spawn/Behavior/Set.php#L160-L179
46,475
PhpGt/WebEngine
src/Lifecycle.php
Lifecycle.start
public function start():void { $server = new ServerInfo($_SERVER); $cwd = dirname($server->getDocumentRoot()); chdir($cwd); $config = ConfigFactory::createForProject( $cwd, implode(DIRECTORY_SEPARATOR, [ dirname(__DIR__), "config.default.ini", ]) ); $input = new Input($_GET, $_POST, $_FILES); $cookie = new CookieHandler($_COOKIE); $sessionHandler = SessionSetup::attachHandler( $config->get("session.handler") ); $sessionConfig = $config->getSection("session"); $sessionId = $cookie[$sessionConfig["name"]]; $sessionHandler = new Session( $sessionHandler, $sessionConfig, $sessionId ); $databaseSettings = new Settings( $config->get("database.query_directory"), $config->get("database.driver"), $config->get("database.schema"), $config->get("database.host"), $config->get("database.port"), $config->get("database.username"), $config->get("database.password") ); $database = new Database($databaseSettings); $this->protectGlobals(); $this->attachAutoloaders( $server->getDocumentRoot(), $config->getSection("app") ); $request = $this->createServerRequest( $server, $input, $cookie ); $router = $this->createRouter( $request, $server->getDocumentRoot() ); $csrfProtection = new SessionTokenStore( $sessionHandler->getStore( "gt.csrf", true ) ); $csrfProtection->processAndVerify( $input->getAll(Input::DATA_BODY) ); $dispatcher = $this->createDispatcher( $config, $server, $input, $cookie, $sessionHandler, $database, $router, $csrfProtection ); $response = $this->process($request, $dispatcher); $this->finish($response); }
php
public function start():void { $server = new ServerInfo($_SERVER); $cwd = dirname($server->getDocumentRoot()); chdir($cwd); $config = ConfigFactory::createForProject( $cwd, implode(DIRECTORY_SEPARATOR, [ dirname(__DIR__), "config.default.ini", ]) ); $input = new Input($_GET, $_POST, $_FILES); $cookie = new CookieHandler($_COOKIE); $sessionHandler = SessionSetup::attachHandler( $config->get("session.handler") ); $sessionConfig = $config->getSection("session"); $sessionId = $cookie[$sessionConfig["name"]]; $sessionHandler = new Session( $sessionHandler, $sessionConfig, $sessionId ); $databaseSettings = new Settings( $config->get("database.query_directory"), $config->get("database.driver"), $config->get("database.schema"), $config->get("database.host"), $config->get("database.port"), $config->get("database.username"), $config->get("database.password") ); $database = new Database($databaseSettings); $this->protectGlobals(); $this->attachAutoloaders( $server->getDocumentRoot(), $config->getSection("app") ); $request = $this->createServerRequest( $server, $input, $cookie ); $router = $this->createRouter( $request, $server->getDocumentRoot() ); $csrfProtection = new SessionTokenStore( $sessionHandler->getStore( "gt.csrf", true ) ); $csrfProtection->processAndVerify( $input->getAll(Input::DATA_BODY) ); $dispatcher = $this->createDispatcher( $config, $server, $input, $cookie, $sessionHandler, $database, $router, $csrfProtection ); $response = $this->process($request, $dispatcher); $this->finish($response); }
[ "public", "function", "start", "(", ")", ":", "void", "{", "$", "server", "=", "new", "ServerInfo", "(", "$", "_SERVER", ")", ";", "$", "cwd", "=", "dirname", "(", "$", "server", "->", "getDocumentRoot", "(", ")", ")", ";", "chdir", "(", "$", "cwd"...
The start of the application's lifecycle. This function breaks the lifecycle down into its different functions, in order.
[ "The", "start", "of", "the", "application", "s", "lifecycle", ".", "This", "function", "breaks", "the", "lifecycle", "down", "into", "its", "different", "functions", "in", "order", "." ]
2dc4010349c3c07a695b28e25ec0a8a44cb93ea2
https://github.com/PhpGt/WebEngine/blob/2dc4010349c3c07a695b28e25ec0a8a44cb93ea2/src/Lifecycle.php#L45-L124
46,476
PhpGt/WebEngine
src/Lifecycle.php
Lifecycle.protectGlobals
public function protectGlobals() { // TODO: Merge whitelist from config $whitelist = [ "_COOKIE" => ["XDEBUG_SESSION"], ]; $globalsAfterRemoval = Protection::removeGlobals( $GLOBALS, $whitelist ); Protection::overrideInternals( $globalsAfterRemoval, $_ENV, $_SERVER, $_GET, $_POST, $_FILES, $_COOKIE, $_SESSION ); }
php
public function protectGlobals() { // TODO: Merge whitelist from config $whitelist = [ "_COOKIE" => ["XDEBUG_SESSION"], ]; $globalsAfterRemoval = Protection::removeGlobals( $GLOBALS, $whitelist ); Protection::overrideInternals( $globalsAfterRemoval, $_ENV, $_SERVER, $_GET, $_POST, $_FILES, $_COOKIE, $_SESSION ); }
[ "public", "function", "protectGlobals", "(", ")", "{", "// TODO: Merge whitelist from config", "$", "whitelist", "=", "[", "\"_COOKIE\"", "=>", "[", "\"XDEBUG_SESSION\"", "]", ",", "]", ";", "$", "globalsAfterRemoval", "=", "Protection", "::", "removeGlobals", "(", ...
By default, PHP passes all sensitive user information around in global variables, available for reading and modification in any code, including third party libraries. All global variables are replaced with objects that alert the developer of their protection and encapsulation through GlobalStub objects. @see https://php.gt/globals
[ "By", "default", "PHP", "passes", "all", "sensitive", "user", "information", "around", "in", "global", "variables", "available", "for", "reading", "and", "modification", "in", "any", "code", "including", "third", "party", "libraries", "." ]
2dc4010349c3c07a695b28e25ec0a8a44cb93ea2
https://github.com/PhpGt/WebEngine/blob/2dc4010349c3c07a695b28e25ec0a8a44cb93ea2/src/Lifecycle.php#L135-L154
46,477
grrr-amsterdam/garp3
library/Garp/Content/Import/Excel.php
Garp_Content_Import_Excel._getReader
protected function _getReader() { /** * Note: this is now autoloaded by Composer */ //require APPLICATION_PATH.'/../garp/library/Garp/3rdParty/PHPExcel/Classes/PHPExcel.php'; $inputFileType = PHPExcel_IOFactory::identify($this->_importFile); // HTML is never correct. Just default to Excel2007 // @todo Fix this. It should be able to determine the filetype correctly. if ($inputFileType === 'HTML') { $inputFileType = 'Excel2007'; } $reader = PHPExcel_IOFactory::createReader($inputFileType); // we are only interested in cell values (not formatting etc.), so set readDataOnly to true // $reader->setReadDataOnly(true); $phpexcel = $reader->load($this->_importFile); return $phpexcel; }
php
protected function _getReader() { /** * Note: this is now autoloaded by Composer */ //require APPLICATION_PATH.'/../garp/library/Garp/3rdParty/PHPExcel/Classes/PHPExcel.php'; $inputFileType = PHPExcel_IOFactory::identify($this->_importFile); // HTML is never correct. Just default to Excel2007 // @todo Fix this. It should be able to determine the filetype correctly. if ($inputFileType === 'HTML') { $inputFileType = 'Excel2007'; } $reader = PHPExcel_IOFactory::createReader($inputFileType); // we are only interested in cell values (not formatting etc.), so set readDataOnly to true // $reader->setReadDataOnly(true); $phpexcel = $reader->load($this->_importFile); return $phpexcel; }
[ "protected", "function", "_getReader", "(", ")", "{", "/**\n * Note: this is now autoloaded by Composer\n */", "//require APPLICATION_PATH.'/../garp/library/Garp/3rdParty/PHPExcel/Classes/PHPExcel.php';", "$", "inputFileType", "=", "PHPExcel_IOFactory", "::", "identify", ...
Return an Excel reader @return PHPExcel
[ "Return", "an", "Excel", "reader" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Import/Excel.php#L113-L131
46,478
grrr-amsterdam/garp3
library/Garp/DateTime.php
Garp_DateTime.format_local
public function format_local($format) { // Configure the timezone to account for timezone and/or daylight savings time $timezone = new DateTimeZone(date_default_timezone_get()); $this->setTimezone($timezone); $timestamp = $this->getTimestamp(); return strftime($format, $timestamp); }
php
public function format_local($format) { // Configure the timezone to account for timezone and/or daylight savings time $timezone = new DateTimeZone(date_default_timezone_get()); $this->setTimezone($timezone); $timestamp = $this->getTimestamp(); return strftime($format, $timestamp); }
[ "public", "function", "format_local", "(", "$", "format", ")", "{", "// Configure the timezone to account for timezone and/or daylight savings time", "$", "timezone", "=", "new", "DateTimeZone", "(", "date_default_timezone_get", "(", ")", ")", ";", "$", "this", "->", "s...
Support for localized formatting. @param String $format @return String
[ "Support", "for", "localized", "formatting", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/DateTime.php#L19-L26
46,479
grrr-amsterdam/garp3
library/Garp/DateTime.php
Garp_DateTime.formatFromConfig
public static function formatFromConfig($type, $date) { $ini = Zend_Registry::get('config'); $format = $ini->date->format->$type; if (strpos($format, '%') !== false) { return strftime($format, strtotime($date)); } else { return date($format, strtotime($date)); } }
php
public static function formatFromConfig($type, $date) { $ini = Zend_Registry::get('config'); $format = $ini->date->format->$type; if (strpos($format, '%') !== false) { return strftime($format, strtotime($date)); } else { return date($format, strtotime($date)); } }
[ "public", "static", "function", "formatFromConfig", "(", "$", "type", ",", "$", "date", ")", "{", "$", "ini", "=", "Zend_Registry", "::", "get", "(", "'config'", ")", ";", "$", "format", "=", "$", "ini", "->", "date", "->", "format", "->", "$", "type...
Format a date according to a format set in the global configuration
[ "Format", "a", "date", "according", "to", "a", "format", "set", "in", "the", "global", "configuration" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/DateTime.php#L31-L40
46,480
grrr-amsterdam/garp3
library/Garp/Content/Export/Factory.php
Garp_Content_Export_Factory.getExporter
public static function getExporter($type) { // normalize type $className = 'Garp_Content_Export_' . ucfirst($type); $obj = new $className(); if (!$obj instanceof Garp_Content_Export_Abstract) { throw new Garp_Content_Export_Exception( "Class $className does not implement Garp_Content_Export_Abstract." ); } return $obj; }
php
public static function getExporter($type) { // normalize type $className = 'Garp_Content_Export_' . ucfirst($type); $obj = new $className(); if (!$obj instanceof Garp_Content_Export_Abstract) { throw new Garp_Content_Export_Exception( "Class $className does not implement Garp_Content_Export_Abstract." ); } return $obj; }
[ "public", "static", "function", "getExporter", "(", "$", "type", ")", "{", "// normalize type", "$", "className", "=", "'Garp_Content_Export_'", ".", "ucfirst", "(", "$", "type", ")", ";", "$", "obj", "=", "new", "$", "className", "(", ")", ";", "if", "(...
Return instance of Garp_Content_Export_Abstract @param string $type The requested export type @return Garp_Content_Export_Abstract
[ "Return", "instance", "of", "Garp_Content_Export_Abstract" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Export/Factory.php#L17-L27
46,481
grrr-amsterdam/garp3
library/Garp/I18n.php
Garp_I18n.getLocalizedRoutes
public static function getLocalizedRoutes(array $routes, array $locales) { $localizedRoutes = array(); $defaultLocale = self::getDefaultLocale(); $requiredLocalesRegex = '^(' . join('|', $locales) . ')$'; foreach ($routes as $key => $value) { // First let's add the default locale to this routes defaults. $defaults = isset($value['defaults']) ? $value['defaults'] : array(); // Always default all routes to the Zend_Locale default $value['defaults'] = array_merge(array('locale' => $defaultLocale ), $defaults); //$routes[$key] = $value; // Get our route and make sure to remove the first forward slash // since it's not needed. $routeString = $value['route']; $routeString = ltrim($routeString, '/\\'); // Modify our normal route to have the locale parameter. if (!isset($value['type']) || $value['type'] === 'Zend_Controller_Router_Route') { $value['route'] = ':locale/' . $routeString; $value['reqs']['locale'] = $requiredLocalesRegex; $localizedRoutes['locale_' . $key] = $value; } else if ($value['type'] === 'Zend_Controller_Router_Route_Regex') { $value['route'] = '(' . join('|', $locales) . ')\/' . $routeString; // Since we added the local regex match, we need to bump the existing // match numbers plus one. $map = isset($value['map']) ? $value['map'] : array(); foreach ($map as $index => $word) { unset($map[$index++]); $map[$index] = $word; } // Add our locale map $map[1] = 'locale'; ksort($map); $value['map'] = $map; $localizedRoutes['locale_' . $key] = $value; } elseif ($value['type'] === 'Zend_Controller_Router_Route_Static') { foreach ($locales as $locale) { $value['route'] = $locale . '/' . $routeString; $value['defaults']['locale'] = $locale; $routes['locale_' . $locale . '_' . $key] = $value; } } } return $localizedRoutes; }
php
public static function getLocalizedRoutes(array $routes, array $locales) { $localizedRoutes = array(); $defaultLocale = self::getDefaultLocale(); $requiredLocalesRegex = '^(' . join('|', $locales) . ')$'; foreach ($routes as $key => $value) { // First let's add the default locale to this routes defaults. $defaults = isset($value['defaults']) ? $value['defaults'] : array(); // Always default all routes to the Zend_Locale default $value['defaults'] = array_merge(array('locale' => $defaultLocale ), $defaults); //$routes[$key] = $value; // Get our route and make sure to remove the first forward slash // since it's not needed. $routeString = $value['route']; $routeString = ltrim($routeString, '/\\'); // Modify our normal route to have the locale parameter. if (!isset($value['type']) || $value['type'] === 'Zend_Controller_Router_Route') { $value['route'] = ':locale/' . $routeString; $value['reqs']['locale'] = $requiredLocalesRegex; $localizedRoutes['locale_' . $key] = $value; } else if ($value['type'] === 'Zend_Controller_Router_Route_Regex') { $value['route'] = '(' . join('|', $locales) . ')\/' . $routeString; // Since we added the local regex match, we need to bump the existing // match numbers plus one. $map = isset($value['map']) ? $value['map'] : array(); foreach ($map as $index => $word) { unset($map[$index++]); $map[$index] = $word; } // Add our locale map $map[1] = 'locale'; ksort($map); $value['map'] = $map; $localizedRoutes['locale_' . $key] = $value; } elseif ($value['type'] === 'Zend_Controller_Router_Route_Static') { foreach ($locales as $locale) { $value['route'] = $locale . '/' . $routeString; $value['defaults']['locale'] = $locale; $routes['locale_' . $locale . '_' . $key] = $value; } } } return $localizedRoutes; }
[ "public", "static", "function", "getLocalizedRoutes", "(", "array", "$", "routes", ",", "array", "$", "locales", ")", "{", "$", "localizedRoutes", "=", "array", "(", ")", ";", "$", "defaultLocale", "=", "self", "::", "getDefaultLocale", "(", ")", ";", "$",...
Generate localized versions of routes @param array $routes The originals @param array $locales @return array
[ "Generate", "localized", "versions", "of", "routes" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/I18n.php#L61-L114
46,482
grrr-amsterdam/garp3
library/Garp/I18n.php
Garp_I18n.languageToTerritory
public static function languageToTerritory($lang) { $config = Zend_Registry::get('config'); $territory = isset($config->resources->locale->territories->{$lang}) ? $config->resources->locale->territories->{$lang} : Zend_Locale::getLocaleToTerritory($lang); return $territory; }
php
public static function languageToTerritory($lang) { $config = Zend_Registry::get('config'); $territory = isset($config->resources->locale->territories->{$lang}) ? $config->resources->locale->territories->{$lang} : Zend_Locale::getLocaleToTerritory($lang); return $territory; }
[ "public", "static", "function", "languageToTerritory", "(", "$", "lang", ")", "{", "$", "config", "=", "Zend_Registry", "::", "get", "(", "'config'", ")", ";", "$", "territory", "=", "isset", "(", "$", "config", "->", "resources", "->", "locale", "->", "...
Go from language to territory @param string $lang @return string
[ "Go", "from", "language", "to", "territory" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/I18n.php#L122-L128
46,483
grrr-amsterdam/garp3
library/Garp/I18n.php
Garp_I18n.getTranslateByLocale
public static function getTranslateByLocale(Zend_Locale $locale) { $adapterParams = array( 'locale' => $locale, 'disableNotices' => true, 'scan' => Zend_Translate::LOCALE_FILENAME, // Argh: the 'content' key is necessary in order to load the actual data, // even when using an adapter that ignores it. 'content' => '!' ); // Figure out which adapter to use $translateAdapter = 'array'; $config = Zend_Registry::get('config'); if (!empty($config->resources->locale->translate->adapter)) { $translateAdapter = $config->resources->locale->translate->adapter; } $adapterParams['adapter'] = $translateAdapter; // Some additional configuration for the array adapter if ($translateAdapter == 'array') { $language = $locale->getLanguage(); // @todo Move this to applciation.ini? $adapterParams['content'] = APPLICATION_PATH . '/data/i18n/' . $language . '.php'; // Turn on caching if (Zend_Registry::isRegistered('CacheFrontend')) { $adapterParams['cache'] = Zend_Registry::get('CacheFrontend'); } } $translate = new Zend_Translate($adapterParams); return $translate; }
php
public static function getTranslateByLocale(Zend_Locale $locale) { $adapterParams = array( 'locale' => $locale, 'disableNotices' => true, 'scan' => Zend_Translate::LOCALE_FILENAME, // Argh: the 'content' key is necessary in order to load the actual data, // even when using an adapter that ignores it. 'content' => '!' ); // Figure out which adapter to use $translateAdapter = 'array'; $config = Zend_Registry::get('config'); if (!empty($config->resources->locale->translate->adapter)) { $translateAdapter = $config->resources->locale->translate->adapter; } $adapterParams['adapter'] = $translateAdapter; // Some additional configuration for the array adapter if ($translateAdapter == 'array') { $language = $locale->getLanguage(); // @todo Move this to applciation.ini? $adapterParams['content'] = APPLICATION_PATH . '/data/i18n/' . $language . '.php'; // Turn on caching if (Zend_Registry::isRegistered('CacheFrontend')) { $adapterParams['cache'] = Zend_Registry::get('CacheFrontend'); } } $translate = new Zend_Translate($adapterParams); return $translate; }
[ "public", "static", "function", "getTranslateByLocale", "(", "Zend_Locale", "$", "locale", ")", "{", "$", "adapterParams", "=", "array", "(", "'locale'", "=>", "$", "locale", ",", "'disableNotices'", "=>", "true", ",", "'scan'", "=>", "Zend_Translate", "::", "...
Create a Zend_Translate instance for the given locale. @param Zend_Locale $locale @return Zend_Translate
[ "Create", "a", "Zend_Translate", "instance", "for", "the", "given", "locale", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/I18n.php#L136-L169
46,484
grrr-amsterdam/garp3
library/Garp/Image/Scaler.php
Garp_Image_Scaler.getTemplateParameters
public function getTemplateParameters($template) { if (count(self::$_config->template->{$template})) { $tplConfig = self::$_config->template->{$template}->toArray(); return $tplConfig; } throw new Exception('The template "' . $template . '" is not configured.'); }
php
public function getTemplateParameters($template) { if (count(self::$_config->template->{$template})) { $tplConfig = self::$_config->template->{$template}->toArray(); return $tplConfig; } throw new Exception('The template "' . $template . '" is not configured.'); }
[ "public", "function", "getTemplateParameters", "(", "$", "template", ")", "{", "if", "(", "count", "(", "self", "::", "$", "_config", "->", "template", "->", "{", "$", "template", "}", ")", ")", "{", "$", "tplConfig", "=", "self", "::", "$", "_config",...
Fetches the scaling parameters for this template. @param string $template Name of this template @return array
[ "Fetches", "the", "scaling", "parameters", "for", "this", "template", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Image/Scaler.php#L154-L160
46,485
grrr-amsterdam/garp3
library/Garp/Image/Scaler.php
Garp_Image_Scaler.generateTemplateScaledImages
public function generateTemplateScaledImages($filename, $id, $overwrite = false) { if (!$filename || !$id) { throw new Exception( 'A filename and id were not provided. Filename [' . $filename . '] Id [' . $id . ']' ); } $templates = $this->getTemplateNames(); foreach ($templates as $t) { try { $this->scaleAndStore($filename, $id, $t, $overwrite); } catch(Exception $e) { throw new Exception( "Error scaling " . $filename . " (#" . $id . "): " . $e->getMessage() ); } } }
php
public function generateTemplateScaledImages($filename, $id, $overwrite = false) { if (!$filename || !$id) { throw new Exception( 'A filename and id were not provided. Filename [' . $filename . '] Id [' . $id . ']' ); } $templates = $this->getTemplateNames(); foreach ($templates as $t) { try { $this->scaleAndStore($filename, $id, $t, $overwrite); } catch(Exception $e) { throw new Exception( "Error scaling " . $filename . " (#" . $id . "): " . $e->getMessage() ); } } }
[ "public", "function", "generateTemplateScaledImages", "(", "$", "filename", ",", "$", "id", ",", "$", "overwrite", "=", "false", ")", "{", "if", "(", "!", "$", "filename", "||", "!", "$", "id", ")", "{", "throw", "new", "Exception", "(", "'A filename and...
Generate versions of an image file that are scaled according to the configured scaling templates. @param string $filename The filename of the image to be scaled @param int $id The database ID of the image record @param bool $overwrite Whether to overwrite existing files @return void
[ "Generate", "versions", "of", "an", "image", "file", "that", "are", "scaled", "according", "to", "the", "configured", "scaling", "templates", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Image/Scaler.php#L181-L198
46,486
grrr-amsterdam/garp3
library/Garp/Image/Scaler.php
Garp_Image_Scaler.scaleAndStore
public function scaleAndStore($filename, $id, $template = null, $overwrite = false) { $templates = !is_null($template) ? (array)$template : // template is left empty; scale source file along all configured templates $templates = $this->getTemplateNames(); $file = new Garp_Image_File(Garp_File::FILE_VARIANT_UPLOAD); $sourceData = $file->fetch($filename); $imageType = $file->getImageType($filename); foreach ($templates as $template) { $this->_scaleAndStoreForTemplate($sourceData, $imageType, $id, $template, $overwrite); } }
php
public function scaleAndStore($filename, $id, $template = null, $overwrite = false) { $templates = !is_null($template) ? (array)$template : // template is left empty; scale source file along all configured templates $templates = $this->getTemplateNames(); $file = new Garp_Image_File(Garp_File::FILE_VARIANT_UPLOAD); $sourceData = $file->fetch($filename); $imageType = $file->getImageType($filename); foreach ($templates as $template) { $this->_scaleAndStoreForTemplate($sourceData, $imageType, $id, $template, $overwrite); } }
[ "public", "function", "scaleAndStore", "(", "$", "filename", ",", "$", "id", ",", "$", "template", "=", "null", ",", "$", "overwrite", "=", "false", ")", "{", "$", "templates", "=", "!", "is_null", "(", "$", "template", ")", "?", "(", "array", ")", ...
Scales an image according to an image template, and stores it. @param string $filename Filename of the source image @param int $id Id of the database record corresponding to this image file @param string $template Name of the template, if left empty, scaled versions for all templates will be generated. @param bool $overwrite @return void
[ "Scales", "an", "image", "according", "to", "an", "image", "template", "and", "stores", "it", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Image/Scaler.php#L228-L241
46,487
grrr-amsterdam/garp3
library/Garp/Image/Scaler.php
Garp_Image_Scaler._paintCanvas
private function _paintCanvas(&$image) { if ($this->_params['type'] === IMAGETYPE_JPEG) { if (!$this->_params['crop'] || !$this->_params['grow'] ) { $this->_paintCanvasOpaque($image); } } else { $this->_paintCanvasTransparent($image); } }
php
private function _paintCanvas(&$image) { if ($this->_params['type'] === IMAGETYPE_JPEG) { if (!$this->_params['crop'] || !$this->_params['grow'] ) { $this->_paintCanvasOpaque($image); } } else { $this->_paintCanvasTransparent($image); } }
[ "private", "function", "_paintCanvas", "(", "&", "$", "image", ")", "{", "if", "(", "$", "this", "->", "_params", "[", "'type'", "]", "===", "IMAGETYPE_JPEG", ")", "{", "if", "(", "!", "$", "this", "->", "_params", "[", "'crop'", "]", "||", "!", "$...
Fills the canvas with the provided background color. @param resource $image @return void
[ "Fills", "the", "canvas", "with", "the", "provided", "background", "color", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Image/Scaler.php#L365-L375
46,488
grrr-amsterdam/garp3
library/Garp/Image/Scaler.php
Garp_Image_Scaler._renderToImageData
private function _renderToImageData(&$canvas) { ob_start(); switch ($this->_params['type']) { case IMAGETYPE_GIF: imagegif($canvas); break; case IMAGETYPE_JPEG: imagejpeg($canvas, null, $this->_params['quality']); break; case IMAGETYPE_PNG: // Calculate PNG quality, because it runs from 0 (uncompressed) to 9, // instead of 0 - 100. $pngQuality = ($this->_params['quality'] - 100) / 11.111111; $pngQuality = round(abs($pngQuality)); imagepng($canvas, null, $pngQuality, null); break; default: throw new Exception('Sorry, this image type is not supported'); } $imgData = ob_get_contents(); ob_end_clean(); return $imgData; }
php
private function _renderToImageData(&$canvas) { ob_start(); switch ($this->_params['type']) { case IMAGETYPE_GIF: imagegif($canvas); break; case IMAGETYPE_JPEG: imagejpeg($canvas, null, $this->_params['quality']); break; case IMAGETYPE_PNG: // Calculate PNG quality, because it runs from 0 (uncompressed) to 9, // instead of 0 - 100. $pngQuality = ($this->_params['quality'] - 100) / 11.111111; $pngQuality = round(abs($pngQuality)); imagepng($canvas, null, $pngQuality, null); break; default: throw new Exception('Sorry, this image type is not supported'); } $imgData = ob_get_contents(); ob_end_clean(); return $imgData; }
[ "private", "function", "_renderToImageData", "(", "&", "$", "canvas", ")", "{", "ob_start", "(", ")", ";", "switch", "(", "$", "this", "->", "_params", "[", "'type'", "]", ")", "{", "case", "IMAGETYPE_GIF", ":", "imagegif", "(", "$", "canvas", ")", ";"...
Writes the graphical output to image file data. @param resource $canvas @return resource Scaled image data
[ "Writes", "the", "graphical", "output", "to", "image", "file", "data", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Image/Scaler.php#L423-L447
46,489
grrr-amsterdam/garp3
library/Garp/Image/Scaler.php
Garp_Image_Scaler._projectSourceOnCanvas
private function _projectSourceOnCanvas(&$source, &$canvas) { $srcX = 0; $srcY = 0; list($projectionWidth, $projectionHeight) = $this->_getProjectionSize(); list($destX, $destY) = $this->_getLeftUpperCoordinateOnCanvas( $projectionWidth, $projectionHeight ); imagecopyresampled( $canvas, $source, $destX, $destY, $srcX, $srcY, $projectionWidth, $projectionHeight, $this->_params['sourceWidth'], $this->_params['sourceHeight'] ); }
php
private function _projectSourceOnCanvas(&$source, &$canvas) { $srcX = 0; $srcY = 0; list($projectionWidth, $projectionHeight) = $this->_getProjectionSize(); list($destX, $destY) = $this->_getLeftUpperCoordinateOnCanvas( $projectionWidth, $projectionHeight ); imagecopyresampled( $canvas, $source, $destX, $destY, $srcX, $srcY, $projectionWidth, $projectionHeight, $this->_params['sourceWidth'], $this->_params['sourceHeight'] ); }
[ "private", "function", "_projectSourceOnCanvas", "(", "&", "$", "source", ",", "&", "$", "canvas", ")", "{", "$", "srcX", "=", "0", ";", "$", "srcY", "=", "0", ";", "list", "(", "$", "projectionWidth", ",", "$", "projectionHeight", ")", "=", "$", "th...
Performs the actual projection of the source onto the canvas. @param resource $source @param resource $canvas @return void
[ "Performs", "the", "actual", "projection", "of", "the", "source", "onto", "the", "canvas", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Image/Scaler.php#L456-L476
46,490
grrr-amsterdam/garp3
library/Garp/Image/Scaler.php
Garp_Image_Scaler._getLeftUpperCoordinateOnCanvas
private function _getLeftUpperCoordinateOnCanvas($projectionWidth, $projectionHeight) { $canvasWidth = $this->_params['w']; $canvasHeight = $this->_params['h']; // Always center the projection horizontally. if ($projectionWidth > $canvasWidth) { $x = - (($projectionWidth / 2) - ($this->_params['w'] / 2)); } else { $x = ($this->_params['w'] - $projectionWidth) / 2; } switch ($this->_params['cropfocus']) { case 'face': // If the image is taller than the canvas, move the starting point halfway up the center if ($projectionHeight > $canvasHeight) { $y = - ((($projectionHeight / 2) - ($this->_params['h'] / 2)) / 2); } else { $y = ($this->_params['h'] - $projectionHeight) / 2; } break; case 'center': default: // center the projection vertically if ($projectionHeight > $canvasHeight) { $y = - (($projectionHeight / 2) - ($this->_params['h'] / 2)); } else { $y = ($this->_params['h'] - $projectionHeight) / 2; } } return array($x, $y); }
php
private function _getLeftUpperCoordinateOnCanvas($projectionWidth, $projectionHeight) { $canvasWidth = $this->_params['w']; $canvasHeight = $this->_params['h']; // Always center the projection horizontally. if ($projectionWidth > $canvasWidth) { $x = - (($projectionWidth / 2) - ($this->_params['w'] / 2)); } else { $x = ($this->_params['w'] - $projectionWidth) / 2; } switch ($this->_params['cropfocus']) { case 'face': // If the image is taller than the canvas, move the starting point halfway up the center if ($projectionHeight > $canvasHeight) { $y = - ((($projectionHeight / 2) - ($this->_params['h'] / 2)) / 2); } else { $y = ($this->_params['h'] - $projectionHeight) / 2; } break; case 'center': default: // center the projection vertically if ($projectionHeight > $canvasHeight) { $y = - (($projectionHeight / 2) - ($this->_params['h'] / 2)); } else { $y = ($this->_params['h'] - $projectionHeight) / 2; } } return array($x, $y); }
[ "private", "function", "_getLeftUpperCoordinateOnCanvas", "(", "$", "projectionWidth", ",", "$", "projectionHeight", ")", "{", "$", "canvasWidth", "=", "$", "this", "->", "_params", "[", "'w'", "]", ";", "$", "canvasHeight", "=", "$", "this", "->", "_params", ...
Calculates the coordinates of the projection location on the canvas @param int $projectionWidth Width of the projection @param int $projectionHeight Height of the projection @return array Numeric array, containing x- and y-coordinates of the upper left point of the projection on the canvas
[ "Calculates", "the", "coordinates", "of", "the", "projection", "location", "on", "the", "canvas" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Image/Scaler.php#L487-L517
46,491
grrr-amsterdam/garp3
library/Garp/Image/Scaler.php
Garp_Image_Scaler._getProjectionSize
private function _getProjectionSize() { $sourceWidth = $this->_params['sourceWidth']; $sourceHeight = $this->_params['sourceHeight']; $sourceRatio = $sourceWidth / $sourceHeight; $canvasWidth = $this->_params['w']; $canvasHeight = $this->_params['h']; $canvasRatio = $canvasWidth / $canvasHeight; // the image is not allowed to be cut off in any dimension if ($sourceRatio < $canvasRatio) { // source is less landscape-like than canvas $leadDimension = !$this->_params['crop'] ? 'Height' : 'Width'; } else { // source is more landscape-like than canvas $leadDimension = !$this->_params['crop'] ? 'Width' : 'Height'; } if (!$this->_params['grow'] && ${'source' . $leadDimension} < ${'canvas' . $leadDimension} ) { ${'projection' . $leadDimension} = ${'source' . $leadDimension}; } else { ${'projection' . $leadDimension} = ${'canvas' . $leadDimension}; } if (isset($projectionWidth)) { $projectionHeight = $projectionWidth / $sourceRatio; } elseif (isset($projectionHeight)) { $projectionWidth = $projectionHeight * $sourceRatio; } return array(round($projectionWidth), round($projectionHeight)); }
php
private function _getProjectionSize() { $sourceWidth = $this->_params['sourceWidth']; $sourceHeight = $this->_params['sourceHeight']; $sourceRatio = $sourceWidth / $sourceHeight; $canvasWidth = $this->_params['w']; $canvasHeight = $this->_params['h']; $canvasRatio = $canvasWidth / $canvasHeight; // the image is not allowed to be cut off in any dimension if ($sourceRatio < $canvasRatio) { // source is less landscape-like than canvas $leadDimension = !$this->_params['crop'] ? 'Height' : 'Width'; } else { // source is more landscape-like than canvas $leadDimension = !$this->_params['crop'] ? 'Width' : 'Height'; } if (!$this->_params['grow'] && ${'source' . $leadDimension} < ${'canvas' . $leadDimension} ) { ${'projection' . $leadDimension} = ${'source' . $leadDimension}; } else { ${'projection' . $leadDimension} = ${'canvas' . $leadDimension}; } if (isset($projectionWidth)) { $projectionHeight = $projectionWidth / $sourceRatio; } elseif (isset($projectionHeight)) { $projectionWidth = $projectionHeight * $sourceRatio; } return array(round($projectionWidth), round($projectionHeight)); }
[ "private", "function", "_getProjectionSize", "(", ")", "{", "$", "sourceWidth", "=", "$", "this", "->", "_params", "[", "'sourceWidth'", "]", ";", "$", "sourceHeight", "=", "$", "this", "->", "_params", "[", "'sourceHeight'", "]", ";", "$", "sourceRatio", ...
Calculate projection size of source image on canvas. The resulting projection might be larger than the canvas; this function does not consider cutoff by means of cropping. @return array Numeric array containing projection width and height in pixels.
[ "Calculate", "projection", "size", "of", "source", "image", "on", "canvas", ".", "The", "resulting", "projection", "might", "be", "larger", "than", "the", "canvas", ";", "this", "function", "does", "not", "consider", "cutoff", "by", "means", "of", "cropping", ...
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Image/Scaler.php#L527-L563
46,492
grrr-amsterdam/garp3
application/modules/g/controllers/ExtController.php
G_ExtController.smdAction
public function smdAction() { $api = new Garp_Content_Api(); $this->view->api = $api->getLayout(); $this->_renderJs(); }
php
public function smdAction() { $api = new Garp_Content_Api(); $this->view->api = $api->getLayout(); $this->_renderJs(); }
[ "public", "function", "smdAction", "(", ")", "{", "$", "api", "=", "new", "Garp_Content_Api", "(", ")", ";", "$", "this", "->", "view", "->", "api", "=", "$", "api", "->", "getLayout", "(", ")", ";", "$", "this", "->", "_renderJs", "(", ")", ";", ...
Generate Ext.Direct API, publishing allowed actions to Ext.Direct, according to Service Mapping Description JSON-RPC protocol. @return Void
[ "Generate", "Ext", ".", "Direct", "API", "publishing", "allowed", "actions", "to", "Ext", ".", "Direct", "according", "to", "Service", "Mapping", "Description", "JSON", "-", "RPC", "protocol", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/ExtController.php#L44-L49
46,493
grrr-amsterdam/garp3
application/modules/g/controllers/ExtController.php
G_ExtController.getlocaleAction
public function getlocaleAction() { if (!Zend_Registry::isRegistered('Zend_Translate')) { throw new Zend_Controller_Action_Exception( 'Zend_Translate was not registered in Zend_Registry.', 500 ); } $translate = Zend_Registry::get('Zend_Translate'); $messages = $translate->getMessages(); $this->view->messages = $messages; $this->_renderJs(); }
php
public function getlocaleAction() { if (!Zend_Registry::isRegistered('Zend_Translate')) { throw new Zend_Controller_Action_Exception( 'Zend_Translate was not registered in Zend_Registry.', 500 ); } $translate = Zend_Registry::get('Zend_Translate'); $messages = $translate->getMessages(); $this->view->messages = $messages; $this->_renderJs(); }
[ "public", "function", "getlocaleAction", "(", ")", "{", "if", "(", "!", "Zend_Registry", "::", "isRegistered", "(", "'Zend_Translate'", ")", ")", "{", "throw", "new", "Zend_Controller_Action_Exception", "(", "'Zend_Translate was not registered in Zend_Registry.'", ",", ...
Get translation table @return Void
[ "Get", "translation", "table" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/ExtController.php#L64-L76
46,494
grrr-amsterdam/garp3
application/modules/g/controllers/ExtController.php
G_ExtController.preDispatch
public function preDispatch() { if ($this->getRequest()->isPost()) { $post = $this->_getJsonRpcRequest(); $requests = Zend_Json::decode($post, Zend_Json::TYPE_ARRAY); $modifiedRequests = array(); /** * Check if this was a batch request. In that case the array is a plain array of * arrays. If not, there will be a 'jsonrpc' key in the root of the array. */ $batch = !array_key_exists('jsonrpc', $requests); if (!$batch) { $requests = array($requests); } foreach ($requests as $i => $request) { $this->_saveRequestForModification($request, $i); if (array_key_exists('method', $request)) { $methodParts = explode('.', $request['method']); $method = array_pop($methodParts); if (in_array($method, array('create', 'update', 'destroy'))) { $modifyMethod = '_modifyBefore' . ucfirst($method); $request = $this->{$modifyMethod}($request); } } $modifiedRequests[] = $request; } if ($batch) { $this->getRequest()->setPost('request', Zend_Json::encode($modifiedRequests)); } else { $this->getRequest()->setPost('request', Zend_Json::encode($modifiedRequests[0])); } } parent::preDispatch(); $this->_toggleCache(false); }
php
public function preDispatch() { if ($this->getRequest()->isPost()) { $post = $this->_getJsonRpcRequest(); $requests = Zend_Json::decode($post, Zend_Json::TYPE_ARRAY); $modifiedRequests = array(); /** * Check if this was a batch request. In that case the array is a plain array of * arrays. If not, there will be a 'jsonrpc' key in the root of the array. */ $batch = !array_key_exists('jsonrpc', $requests); if (!$batch) { $requests = array($requests); } foreach ($requests as $i => $request) { $this->_saveRequestForModification($request, $i); if (array_key_exists('method', $request)) { $methodParts = explode('.', $request['method']); $method = array_pop($methodParts); if (in_array($method, array('create', 'update', 'destroy'))) { $modifyMethod = '_modifyBefore' . ucfirst($method); $request = $this->{$modifyMethod}($request); } } $modifiedRequests[] = $request; } if ($batch) { $this->getRequest()->setPost('request', Zend_Json::encode($modifiedRequests)); } else { $this->getRequest()->setPost('request', Zend_Json::encode($modifiedRequests[0])); } } parent::preDispatch(); $this->_toggleCache(false); }
[ "public", "function", "preDispatch", "(", ")", "{", "if", "(", "$", "this", "->", "getRequest", "(", ")", "->", "isPost", "(", ")", ")", "{", "$", "post", "=", "$", "this", "->", "_getJsonRpcRequest", "(", ")", ";", "$", "requests", "=", "Zend_Json",...
Callback called before executing action. Transforms requests to a format ExtJs accepts. Also turns off caching, since the CMS always receives live data. @return Void
[ "Callback", "called", "before", "executing", "action", ".", "Transforms", "requests", "to", "a", "format", "ExtJs", "accepts", ".", "Also", "turns", "off", "caching", "since", "the", "CMS", "always", "receives", "live", "data", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/ExtController.php#L85-L118
46,495
grrr-amsterdam/garp3
application/modules/g/controllers/ExtController.php
G_ExtController.postDispatch
public function postDispatch() { parent::postDispatch(); if (!empty($this->_postModifyMethods)) { $response = Zend_Json::decode($this->view->response, Zend_Json::TYPE_ARRAY); $modifiedResponse = array(); /** * Check if this was a batch request. In that case the array is a plain array of * arrays. If not, there will be a 'jsonrpc' key in the root of the array. */ $batch = !array_key_exists('jsonrpc', $response); if (!$batch) { $response = array($response); } /** * Post modify methods are recorded from $this:preDispatch() */ foreach ($this->_postModifyMethods as $i => $postMethod) { if (!empty($response[$i]) && !empty($this->_originalRequests[$i])) { $modifyMethod = '_modifyAfter' . ucfirst($postMethod); $response[$i] = $this->{$modifyMethod}( $response[$i], $this->_originalRequests[$i] ); } } if ($batch) { $this->view->response = Zend_Json::encode($response); } else { $this->view->response = Zend_Json::encode($response[0]); } } $this->_toggleCache(true); }
php
public function postDispatch() { parent::postDispatch(); if (!empty($this->_postModifyMethods)) { $response = Zend_Json::decode($this->view->response, Zend_Json::TYPE_ARRAY); $modifiedResponse = array(); /** * Check if this was a batch request. In that case the array is a plain array of * arrays. If not, there will be a 'jsonrpc' key in the root of the array. */ $batch = !array_key_exists('jsonrpc', $response); if (!$batch) { $response = array($response); } /** * Post modify methods are recorded from $this:preDispatch() */ foreach ($this->_postModifyMethods as $i => $postMethod) { if (!empty($response[$i]) && !empty($this->_originalRequests[$i])) { $modifyMethod = '_modifyAfter' . ucfirst($postMethod); $response[$i] = $this->{$modifyMethod}( $response[$i], $this->_originalRequests[$i] ); } } if ($batch) { $this->view->response = Zend_Json::encode($response); } else { $this->view->response = Zend_Json::encode($response[0]); } } $this->_toggleCache(true); }
[ "public", "function", "postDispatch", "(", ")", "{", "parent", "::", "postDispatch", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "_postModifyMethods", ")", ")", "{", "$", "response", "=", "Zend_Json", "::", "decode", "(", "$", "this...
Callback called after executing action. Transforms requests to a format ExtJs accepts. Also turns on caching, because this request might be chained. @return Void
[ "Callback", "called", "after", "executing", "action", ".", "Transforms", "requests", "to", "a", "format", "ExtJs", "accepts", ".", "Also", "turns", "on", "caching", "because", "this", "request", "might", "be", "chained", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/ExtController.php#L127-L159
46,496
grrr-amsterdam/garp3
application/modules/g/controllers/ExtController.php
G_ExtController._saveRequestForModification
protected function _saveRequestForModification($request, $i) { if (array_key_exists('method', $request)) { $methodParts = explode('.', $request['method']); $method = array_pop($methodParts); if (in_array($method, array('fetch', 'create', 'update', 'destroy'))) { $this->_postModifyMethods[$i] = $method; $this->_originalRequests[$i] = $request; } } }
php
protected function _saveRequestForModification($request, $i) { if (array_key_exists('method', $request)) { $methodParts = explode('.', $request['method']); $method = array_pop($methodParts); if (in_array($method, array('fetch', 'create', 'update', 'destroy'))) { $this->_postModifyMethods[$i] = $method; $this->_originalRequests[$i] = $request; } } }
[ "protected", "function", "_saveRequestForModification", "(", "$", "request", ",", "$", "i", ")", "{", "if", "(", "array_key_exists", "(", "'method'", ",", "$", "request", ")", ")", "{", "$", "methodParts", "=", "explode", "(", "'.'", ",", "$", "request", ...
Save a request preDispatch for modification postDispatch @param Array $request The request @param Int $i The index under which the request should be filed in the array @return Void
[ "Save", "a", "request", "preDispatch", "for", "modification", "postDispatch" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/ExtController.php#L168-L177
46,497
grrr-amsterdam/garp3
application/modules/g/controllers/ExtController.php
G_ExtController._fetchTotal
protected function _fetchTotal($modelName, $conditions) { if (!array_key_exists('query', $conditions)) { $conditions['query'] = array(); } $man = new Garp_Content_Manager($modelName); return $man->count($conditions); }
php
protected function _fetchTotal($modelName, $conditions) { if (!array_key_exists('query', $conditions)) { $conditions['query'] = array(); } $man = new Garp_Content_Manager($modelName); return $man->count($conditions); }
[ "protected", "function", "_fetchTotal", "(", "$", "modelName", ",", "$", "conditions", ")", "{", "if", "(", "!", "array_key_exists", "(", "'query'", ",", "$", "conditions", ")", ")", "{", "$", "conditions", "[", "'query'", "]", "=", "array", "(", ")", ...
Fetch total amount of records condoning to a set of conditions @param String $modelName The entity name @param Array $conditions Query modifiers @return Int
[ "Fetch", "total", "amount", "of", "records", "condoning", "to", "a", "set", "of", "conditions" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/ExtController.php#L186-L192
46,498
grrr-amsterdam/garp3
application/modules/g/controllers/ExtController.php
G_ExtController._modifyAfterFetch
protected function _modifyAfterFetch($response, $request) { if (!$this->_methodFailed($response)) { $rows = $response['result']; $methodParts = explode('.', $request['method']); $modelClass = Garp_Content_Api::modelAliasToClass(array_shift($methodParts)); $params = $request['params']; $params = !empty($params) ? $params[0] : array(); $response['result'] = array( 'rows' => $rows, 'total' => $this->_fetchTotal($modelClass, $params) ); } return $response; }
php
protected function _modifyAfterFetch($response, $request) { if (!$this->_methodFailed($response)) { $rows = $response['result']; $methodParts = explode('.', $request['method']); $modelClass = Garp_Content_Api::modelAliasToClass(array_shift($methodParts)); $params = $request['params']; $params = !empty($params) ? $params[0] : array(); $response['result'] = array( 'rows' => $rows, 'total' => $this->_fetchTotal($modelClass, $params) ); } return $response; }
[ "protected", "function", "_modifyAfterFetch", "(", "$", "response", ",", "$", "request", ")", "{", "if", "(", "!", "$", "this", "->", "_methodFailed", "(", "$", "response", ")", ")", "{", "$", "rows", "=", "$", "response", "[", "'result'", "]", ";", ...
Modify results after fetch @param Array $response The original response @param Array $request The original request @return String
[ "Modify", "results", "after", "fetch" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/ExtController.php#L228-L242
46,499
grrr-amsterdam/garp3
application/modules/g/controllers/ExtController.php
G_ExtController._modifyAfterCreate
protected function _modifyAfterCreate($response, $request) { if (!$this->_methodFailed($response)) { // figure out model name (request.method) $methodParts = explode('.', $request['method']); $modelClass = Garp_Content_Api::modelAliasToClass(array_shift($methodParts)); $model = new $modelClass(); // combine primary keys to query params $primaryKey = array_values((array)$model->info(Zend_Db_Table::PRIMARY)); $primaryKeyValues = array_values((array)$response['result']); $query = array(); foreach ($primaryKey as $i => $key) { $query[$key] = $primaryKeyValues[$i]; } // find the newly inserted rows $man = new Garp_Content_Manager(get_class($model)); $rows = $man->fetch(array('query' => $query)); $response['result'] = array( 'rows' => $rows ); } return $response; }
php
protected function _modifyAfterCreate($response, $request) { if (!$this->_methodFailed($response)) { // figure out model name (request.method) $methodParts = explode('.', $request['method']); $modelClass = Garp_Content_Api::modelAliasToClass(array_shift($methodParts)); $model = new $modelClass(); // combine primary keys to query params $primaryKey = array_values((array)$model->info(Zend_Db_Table::PRIMARY)); $primaryKeyValues = array_values((array)$response['result']); $query = array(); foreach ($primaryKey as $i => $key) { $query[$key] = $primaryKeyValues[$i]; } // find the newly inserted rows $man = new Garp_Content_Manager(get_class($model)); $rows = $man->fetch(array('query' => $query)); $response['result'] = array( 'rows' => $rows ); } return $response; }
[ "protected", "function", "_modifyAfterCreate", "(", "$", "response", ",", "$", "request", ")", "{", "if", "(", "!", "$", "this", "->", "_methodFailed", "(", "$", "response", ")", ")", "{", "// figure out model name (request.method)", "$", "methodParts", "=", "...
Modify results after create @param Array $response The original response @param Array $request The original request @return String
[ "Modify", "results", "after", "create" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/ExtController.php#L251-L272