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,700 | grrr-amsterdam/garp3 | library/Garp/Model/Db/Chapter.php | Garp_Model_Db_Chapter._getValidContentNodeData | protected function _getValidContentNodeData($contentNode) {
$contentNode = $contentNode instanceof Garp_Util_Configuration ? $contentNode : new Garp_Util_Configuration($contentNode);
$contentNode
->obligate('model')
->obligate('data')
->obligate('columns')
->setDefault('type', '')
->setDefault('classes', '')
;
return $contentNode;
} | php | protected function _getValidContentNodeData($contentNode) {
$contentNode = $contentNode instanceof Garp_Util_Configuration ? $contentNode : new Garp_Util_Configuration($contentNode);
$contentNode
->obligate('model')
->obligate('data')
->obligate('columns')
->setDefault('type', '')
->setDefault('classes', '')
;
return $contentNode;
} | [
"protected",
"function",
"_getValidContentNodeData",
"(",
"$",
"contentNode",
")",
"{",
"$",
"contentNode",
"=",
"$",
"contentNode",
"instanceof",
"Garp_Util_Configuration",
"?",
"$",
"contentNode",
":",
"new",
"Garp_Util_Configuration",
"(",
"$",
"contentNode",
")",
... | Validate content node
@param Array $contentNode
@return Array | [
"Validate",
"content",
"node"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db/Chapter.php#L164-L174 |
46,701 | grrr-amsterdam/garp3 | library/Garp/Content/Db/Server/Remote.php | Garp_Content_Db_Server_Remote.store | public function store($path, &$data) {
$ssh = $this->getSshSession();
$sftp = ssh2_sftp($ssh);
$sftpStream = @fopen('ssh2.sftp://' . $sftp . $path, 'wb');
if (!$sftpStream) {
throw new Exception("Could not open remote file: $path");
}
if (@fwrite($sftpStream, $data) === false) {
throw new Exception("Could not store {$path} by SFTP on " . $this->getEnvironment());
}
fclose($sftpStream);
return true;
} | php | public function store($path, &$data) {
$ssh = $this->getSshSession();
$sftp = ssh2_sftp($ssh);
$sftpStream = @fopen('ssh2.sftp://' . $sftp . $path, 'wb');
if (!$sftpStream) {
throw new Exception("Could not open remote file: $path");
}
if (@fwrite($sftpStream, $data) === false) {
throw new Exception("Could not store {$path} by SFTP on " . $this->getEnvironment());
}
fclose($sftpStream);
return true;
} | [
"public",
"function",
"store",
"(",
"$",
"path",
",",
"&",
"$",
"data",
")",
"{",
"$",
"ssh",
"=",
"$",
"this",
"->",
"getSshSession",
"(",
")",
";",
"$",
"sftp",
"=",
"ssh2_sftp",
"(",
"$",
"ssh",
")",
";",
"$",
"sftpStream",
"=",
"@",
"fopen",
... | Stores data in a file.
@param String $path Absolute path within the server to a file where the data should be stored.
@param String &$data The data to store.
@return Boolean Success status of the storage process. | [
"Stores",
"data",
"in",
"a",
"file",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Db/Server/Remote.php#L124-L140 |
46,702 | grrr-amsterdam/garp3 | library/Garp/Controller/Helper/CanonicalUrl.php | Garp_Controller_Helper_CanonicalUrl.validateOrRedirect | public function validateOrRedirect($canonical) {
if (!$this->validate($canonical)) {
$this->redirect($canonical);
return false;
}
return true;
} | php | public function validateOrRedirect($canonical) {
if (!$this->validate($canonical)) {
$this->redirect($canonical);
return false;
}
return true;
} | [
"public",
"function",
"validateOrRedirect",
"(",
"$",
"canonical",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validate",
"(",
"$",
"canonical",
")",
")",
"{",
"$",
"this",
"->",
"redirect",
"(",
"$",
"canonical",
")",
";",
"return",
"false",
";",
... | Helper method that combines validating and redirecting
@param String $canonical
@return Boolean | [
"Helper",
"method",
"that",
"combines",
"validating",
"and",
"redirecting"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Controller/Helper/CanonicalUrl.php#L16-L22 |
46,703 | grrr-amsterdam/garp3 | library/Garp/Controller/Helper/CanonicalUrl.php | Garp_Controller_Helper_CanonicalUrl.validate | public function validate($canonical) {
$currUrl = $this->getRequest()->getRequestUri();
// match using a full url if the canonical starts with a protocol
if (preg_match('~^[a-z]+://~', $canonical)) {
$isObj = $canonical instanceof Garp_Util_FullUrl;
$omitProtocol = $isObj ? $canonical->getOmitProtocol() : false;
$omitBaseUrl = $isObj ? $canonical->getOmitBaseUrl() : false;
$currUrl = new Garp_Util_FullUrl($currUrl, $omitProtocol, $omitBaseUrl);
}
return (string)$currUrl == (string)$canonical;
} | php | public function validate($canonical) {
$currUrl = $this->getRequest()->getRequestUri();
// match using a full url if the canonical starts with a protocol
if (preg_match('~^[a-z]+://~', $canonical)) {
$isObj = $canonical instanceof Garp_Util_FullUrl;
$omitProtocol = $isObj ? $canonical->getOmitProtocol() : false;
$omitBaseUrl = $isObj ? $canonical->getOmitBaseUrl() : false;
$currUrl = new Garp_Util_FullUrl($currUrl, $omitProtocol, $omitBaseUrl);
}
return (string)$currUrl == (string)$canonical;
} | [
"public",
"function",
"validate",
"(",
"$",
"canonical",
")",
"{",
"$",
"currUrl",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getRequestUri",
"(",
")",
";",
"// match using a full url if the canonical starts with a protocol",
"if",
"(",
"preg_match",
"... | Validate wether the supposed canonical url is actually the current request url
@param String $canonical
@return Boolean | [
"Validate",
"wether",
"the",
"supposed",
"canonical",
"url",
"is",
"actually",
"the",
"current",
"request",
"url"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Controller/Helper/CanonicalUrl.php#L29-L39 |
46,704 | grrr-amsterdam/garp3 | library/Garp/Controller/Helper/CanonicalUrl.php | Garp_Controller_Helper_CanonicalUrl.redirect | public function redirect($canonical) {
if (!preg_match('~^[a-z]+://~', $canonical)) {
$canonical = new Garp_Util_FullUrl($canonical);
}
$controller = $this->getActionController();
$controller->getHelper('cache')->disable();
$controller->getHelper('viewRenderer')->setNoRender(true);
$controller->getHelper('layout')->disableLayout();
$controller->getHelper('redirector')->gotoUrl((string)$canonical, array('code' => 301));
} | php | public function redirect($canonical) {
if (!preg_match('~^[a-z]+://~', $canonical)) {
$canonical = new Garp_Util_FullUrl($canonical);
}
$controller = $this->getActionController();
$controller->getHelper('cache')->disable();
$controller->getHelper('viewRenderer')->setNoRender(true);
$controller->getHelper('layout')->disableLayout();
$controller->getHelper('redirector')->gotoUrl((string)$canonical, array('code' => 301));
} | [
"public",
"function",
"redirect",
"(",
"$",
"canonical",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'~^[a-z]+://~'",
",",
"$",
"canonical",
")",
")",
"{",
"$",
"canonical",
"=",
"new",
"Garp_Util_FullUrl",
"(",
"$",
"canonical",
")",
";",
"}",
"$",
... | Redirect to the canonical URL
@param String $canonical
@return Void | [
"Redirect",
"to",
"the",
"canonical",
"URL"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Controller/Helper/CanonicalUrl.php#L46-L55 |
46,705 | grrr-amsterdam/garp3 | library/Garp/Spawn/Relation.php | Garp_Spawn_Relation.getRules | public function getRules($subjectModel) {
if ($this->type === 'hasMany') {
return array($this->oppositeRule);
}
if ($this->type === 'hasAndBelongsToMany') {
$bindingModel = $this->getBindingModel();
$relations = $bindingModel->relations->getRelations();
$rules = array_keys($relations);
/* Now sort egocentrically, because current sorting is alphabetical
(since $relations is an associative array) */
$firstRel = current($relations);
if ($firstRel->model !== $subjectModel) {
$rules = array_reverse($rules);
}
if ($this->isHomo()
&& ($rules[0] !== $subjectModel && $rules[1] === $subjectModel)
) {
// Make sure that the custom named relation always comes second.
// This is part of egocentrism.
$rules = array_reverse($rules);
}
return $rules;
}
return array($this->name);
} | php | public function getRules($subjectModel) {
if ($this->type === 'hasMany') {
return array($this->oppositeRule);
}
if ($this->type === 'hasAndBelongsToMany') {
$bindingModel = $this->getBindingModel();
$relations = $bindingModel->relations->getRelations();
$rules = array_keys($relations);
/* Now sort egocentrically, because current sorting is alphabetical
(since $relations is an associative array) */
$firstRel = current($relations);
if ($firstRel->model !== $subjectModel) {
$rules = array_reverse($rules);
}
if ($this->isHomo()
&& ($rules[0] !== $subjectModel && $rules[1] === $subjectModel)
) {
// Make sure that the custom named relation always comes second.
// This is part of egocentrism.
$rules = array_reverse($rules);
}
return $rules;
}
return array($this->name);
} | [
"public",
"function",
"getRules",
"(",
"$",
"subjectModel",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"type",
"===",
"'hasMany'",
")",
"{",
"return",
"array",
"(",
"$",
"this",
"->",
"oppositeRule",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"type",
... | Return the rules that make up this relation, as used in the referenceMap.
@param string $subjectModel Name of the model you're viewing from. Determines the direction
in some cases.
@return array In case of 'hasMany', an array containing a single rule, in case of
'hasAndBelongsToMany', an array containing two rules referencing two models. | [
"Return",
"the",
"rules",
"that",
"make",
"up",
"this",
"relation",
"as",
"used",
"in",
"the",
"referenceMap",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Spawn/Relation.php#L281-L307 |
46,706 | grrr-amsterdam/garp3 | library/Garp/Spawn/Relation.php | Garp_Spawn_Relation._addRelationFieldInLocalModel | protected function _addRelationFieldInLocalModel() {
if (!$this->isSingular()) {
return;
}
$column = Garp_Spawn_Relation_Set::getRelationColumn($this->name);
$fieldParams = array(
'model' => $this->model,
'type' => 'numeric',
'editable' => true,
'visible' => true,
'primary' => $this->primary,
'required' => $this->required,
'relationAlias' => $this->name,
'relationType' => $this->type
);
if ($this->multilingual && $this->_localModel->isMultilingual()) {
// The relation is added to the i18n model by Garp_Spawn_Config_Model_I18n
return;
}
$this->_localModel->fields->add('relation', $column, $fieldParams);
} | php | protected function _addRelationFieldInLocalModel() {
if (!$this->isSingular()) {
return;
}
$column = Garp_Spawn_Relation_Set::getRelationColumn($this->name);
$fieldParams = array(
'model' => $this->model,
'type' => 'numeric',
'editable' => true,
'visible' => true,
'primary' => $this->primary,
'required' => $this->required,
'relationAlias' => $this->name,
'relationType' => $this->type
);
if ($this->multilingual && $this->_localModel->isMultilingual()) {
// The relation is added to the i18n model by Garp_Spawn_Config_Model_I18n
return;
}
$this->_localModel->fields->add('relation', $column, $fieldParams);
} | [
"protected",
"function",
"_addRelationFieldInLocalModel",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isSingular",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"column",
"=",
"Garp_Spawn_Relation_Set",
"::",
"getRelationColumn",
"(",
"$",
"this",
"->"... | Registers this relation as a Field in the Model.
@return void | [
"Registers",
"this",
"relation",
"as",
"a",
"Field",
"in",
"the",
"Model",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Spawn/Relation.php#L477-L498 |
46,707 | grrr-amsterdam/garp3 | library/Garp/Content/Manager.php | Garp_Content_Manager.count | public function count(array $options = null) {
if ($this->_model instanceof Garp_Model_Db) {
unset($options['sort']);
$options['fields'] = 'COUNT(*)';
try {
$result = $this->fetch($options);
return !empty($result[0]['COUNT(*)']) ? $result[0]['COUNT(*)'] : 0;
} catch (Zend_Db_Statement_Exception $e) {
/**
* @todo When fetching results
* filtered using a HABTM relationship, extra
* meta field are returned from the binding table.
* This results in an SQL error; when using COUNT()
* and returning results from multiple tables a
* GROUP BY clause is mandatory. This must be fixed in
* the future.
*/
return 1000;
}
} else {
return $this->_model->count();
}
} | php | public function count(array $options = null) {
if ($this->_model instanceof Garp_Model_Db) {
unset($options['sort']);
$options['fields'] = 'COUNT(*)';
try {
$result = $this->fetch($options);
return !empty($result[0]['COUNT(*)']) ? $result[0]['COUNT(*)'] : 0;
} catch (Zend_Db_Statement_Exception $e) {
/**
* @todo When fetching results
* filtered using a HABTM relationship, extra
* meta field are returned from the binding table.
* This results in an SQL error; when using COUNT()
* and returning results from multiple tables a
* GROUP BY clause is mandatory. This must be fixed in
* the future.
*/
return 1000;
}
} else {
return $this->_model->count();
}
} | [
"public",
"function",
"count",
"(",
"array",
"$",
"options",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_model",
"instanceof",
"Garp_Model_Db",
")",
"{",
"unset",
"(",
"$",
"options",
"[",
"'sort'",
"]",
")",
";",
"$",
"options",
"[",
"'fi... | Count records according to given criteria
@param Array $options Options
@return Int | [
"Count",
"records",
"according",
"to",
"given",
"criteria"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Manager.php#L249-L271 |
46,708 | grrr-amsterdam/garp3 | library/Garp/Content/Manager.php | Garp_Content_Manager.relate | public function relate(array $options) {
$this->_checkAcl('relate');
extract($options);
if (!isset($primaryKey) || !isset($model) || !isset($foreignKeys)) {
throw new Garp_Content_Exception(
'Not enough options. "primaryKey", "model" and "foreignKeys" are required.'
);
}
$model = Garp_Content_Api::modelAliasToClass($model);
$primaryKey = (array)$primaryKey;
$foreignKeys = (array)$foreignKeys;
$rule = isset($rule) ? $rule : null;
$rule2 = isset($rule2) ? $rule2 : null;
$bindingModel = isset($bindingModel) ? 'Model_' . $bindingModel : null;
$bidirectional = isset($bidirectional) ? $bidirectional : null;
if (isset($bindingModel)) {
$bindingModel = new $bindingModel();
$bindingModel->setCmsContext(true);
}
if (array_key_exists('unrelateExisting', $options) && $options['unrelateExisting']) {
Garp_Content_Relation_Manager::unrelate(
array(
'modelA' => $this->_model,
'modelB' => $model,
'keyA' => $primaryKey,
'rule' => $rule,
'ruleB' => $rule2,
'bindingModel' => $bindingModel,
'bidirectional' => $bidirectional,
)
);
}
$success = $attempts = 0;
foreach ($foreignKeys as $i => $relationData) {
if (!array_key_exists('key', $relationData)) {
throw new Garp_Content_Exception('Foreign key is a required key.');
}
$foreignKey = $relationData['key'];
$extraFields = array_key_exists('relationMetadata', $relationData)
? $relationData['relationMetadata']
: array();
if (Garp_Content_Relation_Manager::relate(
array(
'modelA' => $this->_model,
'modelB' => $model,
'keyA' => $primaryKey,
'keyB' => $foreignKey,
'extraFields' => $extraFields,
'rule' => $rule,
'ruleB' => $rule2,
'bindingModel' => $bindingModel,
'bidirectional' => $bidirectional,
)
)
) {
$success++;
}
$attempts++;
}
return $success == $attempts;
} | php | public function relate(array $options) {
$this->_checkAcl('relate');
extract($options);
if (!isset($primaryKey) || !isset($model) || !isset($foreignKeys)) {
throw new Garp_Content_Exception(
'Not enough options. "primaryKey", "model" and "foreignKeys" are required.'
);
}
$model = Garp_Content_Api::modelAliasToClass($model);
$primaryKey = (array)$primaryKey;
$foreignKeys = (array)$foreignKeys;
$rule = isset($rule) ? $rule : null;
$rule2 = isset($rule2) ? $rule2 : null;
$bindingModel = isset($bindingModel) ? 'Model_' . $bindingModel : null;
$bidirectional = isset($bidirectional) ? $bidirectional : null;
if (isset($bindingModel)) {
$bindingModel = new $bindingModel();
$bindingModel->setCmsContext(true);
}
if (array_key_exists('unrelateExisting', $options) && $options['unrelateExisting']) {
Garp_Content_Relation_Manager::unrelate(
array(
'modelA' => $this->_model,
'modelB' => $model,
'keyA' => $primaryKey,
'rule' => $rule,
'ruleB' => $rule2,
'bindingModel' => $bindingModel,
'bidirectional' => $bidirectional,
)
);
}
$success = $attempts = 0;
foreach ($foreignKeys as $i => $relationData) {
if (!array_key_exists('key', $relationData)) {
throw new Garp_Content_Exception('Foreign key is a required key.');
}
$foreignKey = $relationData['key'];
$extraFields = array_key_exists('relationMetadata', $relationData)
? $relationData['relationMetadata']
: array();
if (Garp_Content_Relation_Manager::relate(
array(
'modelA' => $this->_model,
'modelB' => $model,
'keyA' => $primaryKey,
'keyB' => $foreignKey,
'extraFields' => $extraFields,
'rule' => $rule,
'ruleB' => $rule2,
'bindingModel' => $bindingModel,
'bidirectional' => $bidirectional,
)
)
) {
$success++;
}
$attempts++;
}
return $success == $attempts;
} | [
"public",
"function",
"relate",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"this",
"->",
"_checkAcl",
"(",
"'relate'",
")",
";",
"extract",
"(",
"$",
"options",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"primaryKey",
")",
"||",
"!",
"isset",
"... | Relate entities to each other, optionally removing previous existing relations.
@param array $options
@return bool | [
"Relate",
"entities",
"to",
"each",
"other",
"optionally",
"removing",
"previous",
"existing",
"relations",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Manager.php#L374-L441 |
46,709 | grrr-amsterdam/garp3 | library/Garp/Content/Manager.php | Garp_Content_Manager.unrelate | public function unrelate(array $options) {
$this->_checkAcl('relate');
extract($options);
if (!isset($primaryKey) || !isset($model) || !isset($foreignKeys)) {
throw new Garp_Content_Exception(
'Not enough options. "primaryKey", "model" and "foreignKeys" are required.'
);
}
$model = Garp_Content_Api::modelAliasToClass($model);
$primaryKey = (array)$primaryKey;
$foreignKeys = (array)$foreignKeys;
$rule = isset($rule) ? $rule : null;
$rule2 = isset($rule2) ? $rule2 : null;
$bindingModel = isset($bindingModel) ? 'Model_' . $bindingModel : null;
$bidirectional = isset($bidirectional) ? $bidirectional : null;
Garp_Content_Relation_Manager::unrelate(
array(
'modelA' => $this->_model,
'modelB' => $model,
'keyA' => $primaryKey,
'keyB' => $foreignKeys,
'rule' => $rule,
'ruleB' => $rule2,
'bindingModel' => $bindingModel,
'bidirectional' => $bidirectional,
)
);
} | php | public function unrelate(array $options) {
$this->_checkAcl('relate');
extract($options);
if (!isset($primaryKey) || !isset($model) || !isset($foreignKeys)) {
throw new Garp_Content_Exception(
'Not enough options. "primaryKey", "model" and "foreignKeys" are required.'
);
}
$model = Garp_Content_Api::modelAliasToClass($model);
$primaryKey = (array)$primaryKey;
$foreignKeys = (array)$foreignKeys;
$rule = isset($rule) ? $rule : null;
$rule2 = isset($rule2) ? $rule2 : null;
$bindingModel = isset($bindingModel) ? 'Model_' . $bindingModel : null;
$bidirectional = isset($bidirectional) ? $bidirectional : null;
Garp_Content_Relation_Manager::unrelate(
array(
'modelA' => $this->_model,
'modelB' => $model,
'keyA' => $primaryKey,
'keyB' => $foreignKeys,
'rule' => $rule,
'ruleB' => $rule2,
'bindingModel' => $bindingModel,
'bidirectional' => $bidirectional,
)
);
} | [
"public",
"function",
"unrelate",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"this",
"->",
"_checkAcl",
"(",
"'relate'",
")",
";",
"extract",
"(",
"$",
"options",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"primaryKey",
")",
"||",
"!",
"isset",
... | Unrelate entities from each other
@param array $options
@return bool | [
"Unrelate",
"entities",
"from",
"each",
"other"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Manager.php#L449-L478 |
46,710 | grrr-amsterdam/garp3 | library/Garp/Content/Manager.php | Garp_Content_Manager._createWhereClause | protected function _createWhereClause(array $query, $separator = 'AND', $useJointView = true) {
$where = array();
$adapter = $this->_model->getAdapter();
$nativeColumns = $this->_model->info(Zend_Db_Table_Abstract::COLS);
if ($useJointView) {
$tableName = $this->_getTableName($this->_model);
$mockTable = new Zend_Db_Table(
array(
Zend_Db_Table_Abstract::NAME => $tableName,
Zend_Db_Table_Abstract::PRIMARY => $this->_model->info(
Zend_Db_Table_Abstract::PRIMARY
))
);
$nativeColumns = $mockTable->info(Zend_Db_Table_Abstract::COLS);
} else {
$tableName = $this->_model->getName();
}
// change native columns to lowercase
// because when columnName is configured in camelcase in the model config
// it causes problems when checking if refColumn is a native column
$nativeColumns = array_map(
function ($column) {
return strtolower($column);
}, $nativeColumns
);
foreach ($query as $column => $value) {
if (strtoupper($column) === 'OR' && is_array($value)) {
$where[] = $this->_createWhereClause($value, 'OR');
} elseif (is_array($value)) {
$where[] = $adapter->quoteInto(
$adapter->quoteIdentifier($tableName) . '.' . $column . ' IN(?)',
$value
);
} elseif (is_null($value)) {
if (substr($column, -2) == '<>') {
$column = preg_replace('/<>$/', '', $column);
$where[] = $column . ' IS NOT NULL';
} else {
$where[] = $column . ' IS NULL';
}
} elseif (is_scalar($value)) {
// Use $refColumn to see if this column is native to the current
// model.
$refColumn = null;
if (!preg_match('/(>=?|<=?|like|<>)/i', $column, $matches)) {
$refColumn = $column;
$column = $adapter->quoteIdentifier($column) . ' =';
} else {
// explode column so the actual column name can be quoted
$parts = explode(' ', $column);
$refColumn = $parts[0];
$column = $adapter->quoteIdentifier($parts[0]) . ' ' . $parts[1];
}
if (strpos($refColumn, '.') === false && in_array($refColumn, $nativeColumns)) {
$column = $adapter->quoteIdentifier($tableName) . '.' . $column;
}
$where[] = $adapter->quoteInto($column . ' ?', $value);
}
}
return '(' . implode(" $separator ", $where) . ')';
} | php | protected function _createWhereClause(array $query, $separator = 'AND', $useJointView = true) {
$where = array();
$adapter = $this->_model->getAdapter();
$nativeColumns = $this->_model->info(Zend_Db_Table_Abstract::COLS);
if ($useJointView) {
$tableName = $this->_getTableName($this->_model);
$mockTable = new Zend_Db_Table(
array(
Zend_Db_Table_Abstract::NAME => $tableName,
Zend_Db_Table_Abstract::PRIMARY => $this->_model->info(
Zend_Db_Table_Abstract::PRIMARY
))
);
$nativeColumns = $mockTable->info(Zend_Db_Table_Abstract::COLS);
} else {
$tableName = $this->_model->getName();
}
// change native columns to lowercase
// because when columnName is configured in camelcase in the model config
// it causes problems when checking if refColumn is a native column
$nativeColumns = array_map(
function ($column) {
return strtolower($column);
}, $nativeColumns
);
foreach ($query as $column => $value) {
if (strtoupper($column) === 'OR' && is_array($value)) {
$where[] = $this->_createWhereClause($value, 'OR');
} elseif (is_array($value)) {
$where[] = $adapter->quoteInto(
$adapter->quoteIdentifier($tableName) . '.' . $column . ' IN(?)',
$value
);
} elseif (is_null($value)) {
if (substr($column, -2) == '<>') {
$column = preg_replace('/<>$/', '', $column);
$where[] = $column . ' IS NOT NULL';
} else {
$where[] = $column . ' IS NULL';
}
} elseif (is_scalar($value)) {
// Use $refColumn to see if this column is native to the current
// model.
$refColumn = null;
if (!preg_match('/(>=?|<=?|like|<>)/i', $column, $matches)) {
$refColumn = $column;
$column = $adapter->quoteIdentifier($column) . ' =';
} else {
// explode column so the actual column name can be quoted
$parts = explode(' ', $column);
$refColumn = $parts[0];
$column = $adapter->quoteIdentifier($parts[0]) . ' ' . $parts[1];
}
if (strpos($refColumn, '.') === false && in_array($refColumn, $nativeColumns)) {
$column = $adapter->quoteIdentifier($tableName) . '.' . $column;
}
$where[] = $adapter->quoteInto($column . ' ?', $value);
}
}
return '(' . implode(" $separator ", $where) . ')';
} | [
"protected",
"function",
"_createWhereClause",
"(",
"array",
"$",
"query",
",",
"$",
"separator",
"=",
"'AND'",
",",
"$",
"useJointView",
"=",
"true",
")",
"{",
"$",
"where",
"=",
"array",
"(",
")",
";",
"$",
"adapter",
"=",
"$",
"this",
"->",
"_model"... | Create a WHERE clause for use with Zend_Db_Select
@param array $query WHERE options
@param string $separator AND/OR
@param bool $useJointView Wether to use the *_joint view or the table.
@return string WHERE clause | [
"Create",
"a",
"WHERE",
"clause",
"for",
"use",
"with",
"Zend_Db_Select"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Manager.php#L508-L571 |
46,711 | grrr-amsterdam/garp3 | library/Garp/Content/Manager.php | Garp_Content_Manager._addJoinClause | protected function _addJoinClause(Zend_Db_Select $select, array $related, $rule = null,
$bindingModel = null, $bidirectional = true
) {
foreach ($related as $filterModelName => $filterValue) {
$fieldInfo = explode('.', $filterModelName, 2);
$filterModelName = Garp_Content_Api::modelAliasToClass($fieldInfo[0]);
$filterColumn = $fieldInfo[1];
$filterModel = new $filterModelName();
/**
* Determine wether a negation clause (e.g. !=) is requested
* and normalize the filterColumn.
*/
$negation = strpos($filterColumn, '<>') !== false;
$filterColumn = str_replace(' <>', '', $filterColumn);
if ($filterModelName === get_class($this->_model)) {
/* This is a homophile relation and the current condition touches the
homophile model.
The following condition prevents a 'relatable' list to include the
current record, because a record cannot be related to itself.
*/
$select->where(
$this->_getTableName($filterModel) . '.' . $filterColumn . ' != ?',
$filterValue
);
}
try {
// the other model is a child
$reference = $filterModel->getReference(get_class($this->_model), $rule);
$this->_addHasManyClause(
array(
'select' => $select,
'filterModel' => $filterModel,
'reference' => $reference,
'filterColumn' => $filterColumn,
'filterValue' => $filterValue,
'negation' => $negation
)
);
} catch (Zend_Db_Table_Exception $e) {
try {
// the other model is the parent
$reference = $this->_model->getReference(get_class($filterModel), $rule);
$this->_addBelongsToClause(
array(
'select' => $select,
'reference' => $reference,
'filterColumn' => $filterColumn,
'filterValue' => $filterValue,
'negation' => $negation
)
);
} catch (Zend_Db_Table_Exception $e) {
try {
// the models are equal; a binding model is needed
$this->_addHasAndBelongsToManyClause(
array(
'select' => $select,
'filterModel' => $filterModel,
'filterColumn' => $filterColumn,
'filterValue' => $filterValue,
'negation' => $negation,
'bindingModel' => $bindingModel,
'bidirectional' => $bidirectional
)
);
} catch (Zend_Db_Table_Exception $e) {
throw $e;
}
}
}
}
} | php | protected function _addJoinClause(Zend_Db_Select $select, array $related, $rule = null,
$bindingModel = null, $bidirectional = true
) {
foreach ($related as $filterModelName => $filterValue) {
$fieldInfo = explode('.', $filterModelName, 2);
$filterModelName = Garp_Content_Api::modelAliasToClass($fieldInfo[0]);
$filterColumn = $fieldInfo[1];
$filterModel = new $filterModelName();
/**
* Determine wether a negation clause (e.g. !=) is requested
* and normalize the filterColumn.
*/
$negation = strpos($filterColumn, '<>') !== false;
$filterColumn = str_replace(' <>', '', $filterColumn);
if ($filterModelName === get_class($this->_model)) {
/* This is a homophile relation and the current condition touches the
homophile model.
The following condition prevents a 'relatable' list to include the
current record, because a record cannot be related to itself.
*/
$select->where(
$this->_getTableName($filterModel) . '.' . $filterColumn . ' != ?',
$filterValue
);
}
try {
// the other model is a child
$reference = $filterModel->getReference(get_class($this->_model), $rule);
$this->_addHasManyClause(
array(
'select' => $select,
'filterModel' => $filterModel,
'reference' => $reference,
'filterColumn' => $filterColumn,
'filterValue' => $filterValue,
'negation' => $negation
)
);
} catch (Zend_Db_Table_Exception $e) {
try {
// the other model is the parent
$reference = $this->_model->getReference(get_class($filterModel), $rule);
$this->_addBelongsToClause(
array(
'select' => $select,
'reference' => $reference,
'filterColumn' => $filterColumn,
'filterValue' => $filterValue,
'negation' => $negation
)
);
} catch (Zend_Db_Table_Exception $e) {
try {
// the models are equal; a binding model is needed
$this->_addHasAndBelongsToManyClause(
array(
'select' => $select,
'filterModel' => $filterModel,
'filterColumn' => $filterColumn,
'filterValue' => $filterValue,
'negation' => $negation,
'bindingModel' => $bindingModel,
'bidirectional' => $bidirectional
)
);
} catch (Zend_Db_Table_Exception $e) {
throw $e;
}
}
}
}
} | [
"protected",
"function",
"_addJoinClause",
"(",
"Zend_Db_Select",
"$",
"select",
",",
"array",
"$",
"related",
",",
"$",
"rule",
"=",
"null",
",",
"$",
"bindingModel",
"=",
"null",
",",
"$",
"bidirectional",
"=",
"true",
")",
"{",
"foreach",
"(",
"$",
"r... | Add a JOIN clause to a Zend_Db_Select object
@param Zend_Db_Select $select The select object
@param array $related Collection of related models
@param string $rule Used to figure out the relationship metadata from the referencemap
@param string $bindingModel Binding model used in HABTM relations
@param bool $bidirectional
@return void | [
"Add",
"a",
"JOIN",
"clause",
"to",
"a",
"Zend_Db_Select",
"object"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Manager.php#L583-L657 |
46,712 | grrr-amsterdam/garp3 | library/Garp/Content/Manager.php | Garp_Content_Manager._filterForeignKeyColumns | protected function _filterForeignKeyColumns($fields, $referenceMap) {
$out = array();
$foreignKeys = array();
// create an array of foreign keys...
foreach ($referenceMap as $relName => $relConfig) {
$foreignKeys = array_merge($foreignKeys, (array)$relConfig['columns']);
}
// ...and return the values that are not in that array.
return array_diff($fields, $foreignKeys);
} | php | protected function _filterForeignKeyColumns($fields, $referenceMap) {
$out = array();
$foreignKeys = array();
// create an array of foreign keys...
foreach ($referenceMap as $relName => $relConfig) {
$foreignKeys = array_merge($foreignKeys, (array)$relConfig['columns']);
}
// ...and return the values that are not in that array.
return array_diff($fields, $foreignKeys);
} | [
"protected",
"function",
"_filterForeignKeyColumns",
"(",
"$",
"fields",
",",
"$",
"referenceMap",
")",
"{",
"$",
"out",
"=",
"array",
"(",
")",
";",
"$",
"foreignKeys",
"=",
"array",
"(",
")",
";",
"// create an array of foreign keys...",
"foreach",
"(",
"$",... | Filter columns that are foreign keys.
@param array $fields All columns
@param array $referenceMap The model's referenceMap
@return array | [
"Filter",
"columns",
"that",
"are",
"foreign",
"keys",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Manager.php#L892-L901 |
46,713 | grrr-amsterdam/garp3 | library/Garp/Content/Manager.php | Garp_Content_Manager._findSecondRuleKeyForHomophiles | protected function _findSecondRuleKeyForHomophiles($filterModel, $bindingModel) {
$homophileSecondRuleKey = null;
if ($this->_isHomophile($filterModel)) {
$bindingReferenceMap = $bindingModel->info(Zend_Db_Table_Abstract::REFERENCE_MAP);
$foundRelevantRule = false;
foreach ($bindingReferenceMap as $ruleKey => $rule) {
if ($rule['refTableClass'] === get_class($this->_model)) {
if ($foundRelevantRule) {
$homophileSecondRuleKey = $ruleKey;
}
$foundRelevantRule = !$foundRelevantRule;
}
}
}
return $homophileSecondRuleKey;
} | php | protected function _findSecondRuleKeyForHomophiles($filterModel, $bindingModel) {
$homophileSecondRuleKey = null;
if ($this->_isHomophile($filterModel)) {
$bindingReferenceMap = $bindingModel->info(Zend_Db_Table_Abstract::REFERENCE_MAP);
$foundRelevantRule = false;
foreach ($bindingReferenceMap as $ruleKey => $rule) {
if ($rule['refTableClass'] === get_class($this->_model)) {
if ($foundRelevantRule) {
$homophileSecondRuleKey = $ruleKey;
}
$foundRelevantRule = !$foundRelevantRule;
}
}
}
return $homophileSecondRuleKey;
} | [
"protected",
"function",
"_findSecondRuleKeyForHomophiles",
"(",
"$",
"filterModel",
",",
"$",
"bindingModel",
")",
"{",
"$",
"homophileSecondRuleKey",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"_isHomophile",
"(",
"$",
"filterModel",
")",
")",
"{",
"$",... | In case of a homophile relation, this function returns the key to the second rule,
to prevent the same rule being returned twice, because both rules in
a homophile binding model point to the same related model.
@param Garp_Model_Db $filterModel
@param string $bindingModel
@return string|null Returns the name of the second rule key in the reference map,
if this is a homophile relation. Otherwise, null is returned. | [
"In",
"case",
"of",
"a",
"homophile",
"relation",
"this",
"function",
"returns",
"the",
"key",
"to",
"the",
"second",
"rule",
"to",
"prevent",
"the",
"same",
"rule",
"being",
"returned",
"twice",
"because",
"both",
"rules",
"in",
"a",
"homophile",
"binding",... | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Manager.php#L923-L941 |
46,714 | grrr-amsterdam/garp3 | library/Garp/Content/Manager.php | Garp_Content_Manager._checkAcl | protected function _checkAcl($method) {
if (!Garp_Auth::getInstance()->isAllowed(get_class($this->_model), $method)) {
throw new Garp_Auth_Exception('You are not allowed to execute the requested action.');
}
} | php | protected function _checkAcl($method) {
if (!Garp_Auth::getInstance()->isAllowed(get_class($this->_model), $method)) {
throw new Garp_Auth_Exception('You are not allowed to execute the requested action.');
}
} | [
"protected",
"function",
"_checkAcl",
"(",
"$",
"method",
")",
"{",
"if",
"(",
"!",
"Garp_Auth",
"::",
"getInstance",
"(",
")",
"->",
"isAllowed",
"(",
"get_class",
"(",
"$",
"this",
"->",
"_model",
")",
",",
"$",
"method",
")",
")",
"{",
"throw",
"n... | Check to see if the current model supports the requested method
@param string $method The method
@return bool
@throws Garp_Content_Exception If the method is not supported | [
"Check",
"to",
"see",
"if",
"the",
"current",
"model",
"supports",
"the",
"requested",
"method"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Manager.php#L950-L954 |
46,715 | grrr-amsterdam/garp3 | library/Garp/Content/Manager.php | Garp_Content_Manager._itemBelongsToUser | protected function _itemBelongsToUser($data, $where = false) {
$userData = Garp_Auth::getInstance()->getUserData();
$userId = $userData['id'];
if (!array_key_exists('author_id', $data)) {
if (!$where) {
return false;
}
// fetch the record based on the given WHERE clause
$row = $this->_model->fetchRow($where);
if (!$row || !$row->author_id) {
return false;
}
$data = $row->toArray();
}
return $userId == $data['author_id'];
} | php | protected function _itemBelongsToUser($data, $where = false) {
$userData = Garp_Auth::getInstance()->getUserData();
$userId = $userData['id'];
if (!array_key_exists('author_id', $data)) {
if (!$where) {
return false;
}
// fetch the record based on the given WHERE clause
$row = $this->_model->fetchRow($where);
if (!$row || !$row->author_id) {
return false;
}
$data = $row->toArray();
}
return $userId == $data['author_id'];
} | [
"protected",
"function",
"_itemBelongsToUser",
"(",
"$",
"data",
",",
"$",
"where",
"=",
"false",
")",
"{",
"$",
"userData",
"=",
"Garp_Auth",
"::",
"getInstance",
"(",
")",
"->",
"getUserData",
"(",
")",
";",
"$",
"userId",
"=",
"$",
"userData",
"[",
... | Check a record belongs to the currently logged in user.
This check is based on the author_id column.
@param array $data The record data. Primary key must be present here.
@param string $where A WHERE clause to find the record
@return bool | [
"Check",
"a",
"record",
"belongs",
"to",
"the",
"currently",
"logged",
"in",
"user",
".",
"This",
"check",
"is",
"based",
"on",
"the",
"author_id",
"column",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Manager.php#L964-L979 |
46,716 | grrr-amsterdam/garp3 | library/Garp/Content/Manager.php | Garp_Content_Manager._getTableName | protected function _getTableName($model) {
if (!$this->usesJointView()) {
return $model->getName();
}
return $model->getJointView() ?: $model->getName();
} | php | protected function _getTableName($model) {
if (!$this->usesJointView()) {
return $model->getName();
}
return $model->getJointView() ?: $model->getName();
} | [
"protected",
"function",
"_getTableName",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"usesJointView",
"(",
")",
")",
"{",
"return",
"$",
"model",
"->",
"getName",
"(",
")",
";",
"}",
"return",
"$",
"model",
"->",
"getJointView",
... | Negotiate between joint view and actual table name.
@param Garp_Model_Db $model
@return string | [
"Negotiate",
"between",
"joint",
"view",
"and",
"actual",
"table",
"name",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Manager.php#L1000-L1005 |
46,717 | grrr-amsterdam/garp3 | library/Garp/I18n/Translate/Adapter/Snippet.php | Garp_I18n_Translate_Adapter_Snippet._loadTranslationData | protected function _loadTranslationData($data, $locale, array $options = array()) {
$data = array();
try {
$i18nModelFactory = new Garp_I18n_ModelFactory($locale);
$snippetModel = $i18nModelFactory->getModel('Snippet');
$out = array();
$data = $snippetModel->fetchAll(
$snippetModel->select()
->from($snippetModel->getName(), array(
'identifier',
'text' => new Zend_Db_Expr('IF(text IS NULL, IF(name IS NULL, identifier, name), text)'),
))
->where('has_text = ?', 1)
->orWhere('has_name = ?', 1)
->order('identifier ASC')
);
$data = $this->_reformatData($data);
} catch (Zend_Db_Adapter_Exception $e) {
Garp_ErrorHandler::handlePrematureException($e);
}
$out[$locale] = $data;
return $out;
} | php | protected function _loadTranslationData($data, $locale, array $options = array()) {
$data = array();
try {
$i18nModelFactory = new Garp_I18n_ModelFactory($locale);
$snippetModel = $i18nModelFactory->getModel('Snippet');
$out = array();
$data = $snippetModel->fetchAll(
$snippetModel->select()
->from($snippetModel->getName(), array(
'identifier',
'text' => new Zend_Db_Expr('IF(text IS NULL, IF(name IS NULL, identifier, name), text)'),
))
->where('has_text = ?', 1)
->orWhere('has_name = ?', 1)
->order('identifier ASC')
);
$data = $this->_reformatData($data);
} catch (Zend_Db_Adapter_Exception $e) {
Garp_ErrorHandler::handlePrematureException($e);
}
$out[$locale] = $data;
return $out;
} | [
"protected",
"function",
"_loadTranslationData",
"(",
"$",
"data",
",",
"$",
"locale",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"try",
"{",
"$",
"i18nModelFactory",
"=",
"new",
"Garp_I18n... | Load translation data
@param string|array $data
@param string $locale Locale/Language to add data for, identical with locale identifier,
see Zend_Locale for more information
@param array $options OPTIONAL Options to use
@return array | [
"Load",
"translation",
"data"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/I18n/Translate/Adapter/Snippet.php#L20-L44 |
46,718 | grrr-amsterdam/garp3 | library/Garp/I18n/Translate/Adapter/Snippet.php | Garp_I18n_Translate_Adapter_Snippet._reformatData | protected function _reformatData(Garp_Db_Table_Rowset $data) {
$out = array();
foreach ($data as $datum) {
$out[$datum->identifier] = $datum->text;
}
return $out;
} | php | protected function _reformatData(Garp_Db_Table_Rowset $data) {
$out = array();
foreach ($data as $datum) {
$out[$datum->identifier] = $datum->text;
}
return $out;
} | [
"protected",
"function",
"_reformatData",
"(",
"Garp_Db_Table_Rowset",
"$",
"data",
")",
"{",
"$",
"out",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"datum",
")",
"{",
"$",
"out",
"[",
"$",
"datum",
"->",
"identifier",
"]",
... | Reformat rowset into a usable array.
@param Garp_Db_Table_Rowset $data
@return Array | [
"Reformat",
"rowset",
"into",
"a",
"usable",
"array",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/I18n/Translate/Adapter/Snippet.php#L51-L57 |
46,719 | grrr-amsterdam/garp3 | library/Garp/Util/String.php | Garp_Util_String.camelcasedToUnderscored | static public function camelcasedToUnderscored($str) {
$str = lcfirst($str);
return preg_replace_callback(
'/([A-Z])/',
function ($str) {
return "_" . strtolower($str[1]);
},
$str
);
} | php | static public function camelcasedToUnderscored($str) {
$str = lcfirst($str);
return preg_replace_callback(
'/([A-Z])/',
function ($str) {
return "_" . strtolower($str[1]);
},
$str
);
} | [
"static",
"public",
"function",
"camelcasedToUnderscored",
"(",
"$",
"str",
")",
"{",
"$",
"str",
"=",
"lcfirst",
"(",
"$",
"str",
")",
";",
"return",
"preg_replace_callback",
"(",
"'/([A-Z])/'",
",",
"function",
"(",
"$",
"str",
")",
"{",
"return",
"\"_\"... | Converts 'SnoopDoggyDog' to 'snoop_doggy_dog'
@param string $str
@return string | [
"Converts",
"SnoopDoggyDog",
"to",
"snoop_doggy_dog"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Util/String.php#L20-L29 |
46,720 | grrr-amsterdam/garp3 | library/Garp/Util/String.php | Garp_Util_String.camelcasedToDashed | static public function camelcasedToDashed($str) {
$str = lcfirst($str);
return preg_replace_callback(
'/([A-Z])/',
function ($str) {
return "-" . strtolower($str[1]);
},
$str
);
} | php | static public function camelcasedToDashed($str) {
$str = lcfirst($str);
return preg_replace_callback(
'/([A-Z])/',
function ($str) {
return "-" . strtolower($str[1]);
},
$str
);
} | [
"static",
"public",
"function",
"camelcasedToDashed",
"(",
"$",
"str",
")",
"{",
"$",
"str",
"=",
"lcfirst",
"(",
"$",
"str",
")",
";",
"return",
"preg_replace_callback",
"(",
"'/([A-Z])/'",
",",
"function",
"(",
"$",
"str",
")",
"{",
"return",
"\"-\"",
... | Converts 'SnoopDoggyDog' to 'snoop-doggy-dog'
@param string $str
@return string | [
"Converts",
"SnoopDoggyDog",
"to",
"snoop",
"-",
"doggy",
"-",
"dog"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Util/String.php#L37-L46 |
46,721 | grrr-amsterdam/garp3 | library/Garp/Util/String.php | Garp_Util_String.underscoredToReadable | static public function underscoredToReadable($str, $ucfirst = true) {
if ($ucfirst) {
$str = ucfirst($str);
}
$str = str_replace("_", " ", $str);
return $str;
} | php | static public function underscoredToReadable($str, $ucfirst = true) {
if ($ucfirst) {
$str = ucfirst($str);
}
$str = str_replace("_", " ", $str);
return $str;
} | [
"static",
"public",
"function",
"underscoredToReadable",
"(",
"$",
"str",
",",
"$",
"ucfirst",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"ucfirst",
")",
"{",
"$",
"str",
"=",
"ucfirst",
"(",
"$",
"str",
")",
";",
"}",
"$",
"str",
"=",
"str_replace",
"... | Converts 'doggy_dog_world_id' to 'Doggy dog world id'
@param string $str
@param bool $ucfirst Wether to uppercase the fist character
@return string | [
"Converts",
"doggy_dog_world_id",
"to",
"Doggy",
"dog",
"world",
"id"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Util/String.php#L99-L105 |
46,722 | grrr-amsterdam/garp3 | library/Garp/Util/String.php | Garp_Util_String.underscoredToCamelcased | static public function underscoredToCamelcased($str, $ucfirst = false) {
if ($ucfirst) {
$str = ucfirst($str);
}
$func = f\compose('strtoupper', f\prop(1));
return preg_replace_callback('/_([a-z])/', $func, $str);
} | php | static public function underscoredToCamelcased($str, $ucfirst = false) {
if ($ucfirst) {
$str = ucfirst($str);
}
$func = f\compose('strtoupper', f\prop(1));
return preg_replace_callback('/_([a-z])/', $func, $str);
} | [
"static",
"public",
"function",
"underscoredToCamelcased",
"(",
"$",
"str",
",",
"$",
"ucfirst",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"ucfirst",
")",
"{",
"$",
"str",
"=",
"ucfirst",
"(",
"$",
"str",
")",
";",
"}",
"$",
"func",
"=",
"f",
"\\",
... | Converts 'doggy_dog_world_id' to 'doggyDogWorldId'
@param string $str
@param bool $ucfirst Wether to uppercase the fist character
@return string | [
"Converts",
"doggy_dog_world_id",
"to",
"doggyDogWorldId"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Util/String.php#L114-L120 |
46,723 | grrr-amsterdam/garp3 | library/Garp/Util/String.php | Garp_Util_String.mbstringBinarySafeEncoding | static public function mbstringBinarySafeEncoding($reset = false) {
static $encodings = array();
static $overloaded = null;
if (is_null($overloaded)) {
$overloaded = function_exists('mb_internal_encoding')
&& (ini_get('mbstring.func_overload') & 2);
}
if (false === $overloaded) {
return;
}
if (!$reset) {
$encoding = mb_internal_encoding();
array_push($encodings, $encoding);
mb_internal_encoding('ISO-8859-1');
}
if ($reset && $encodings) {
$encoding = array_pop($encodings);
mb_internal_encoding($encoding);
}
} | php | static public function mbstringBinarySafeEncoding($reset = false) {
static $encodings = array();
static $overloaded = null;
if (is_null($overloaded)) {
$overloaded = function_exists('mb_internal_encoding')
&& (ini_get('mbstring.func_overload') & 2);
}
if (false === $overloaded) {
return;
}
if (!$reset) {
$encoding = mb_internal_encoding();
array_push($encodings, $encoding);
mb_internal_encoding('ISO-8859-1');
}
if ($reset && $encodings) {
$encoding = array_pop($encodings);
mb_internal_encoding($encoding);
}
} | [
"static",
"public",
"function",
"mbstringBinarySafeEncoding",
"(",
"$",
"reset",
"=",
"false",
")",
"{",
"static",
"$",
"encodings",
"=",
"array",
"(",
")",
";",
"static",
"$",
"overloaded",
"=",
"null",
";",
"if",
"(",
"is_null",
"(",
"$",
"overloaded",
... | Set the mbstring internal encoding to a binary safe encoding when func_overload
is enabled.
When mbstring.func_overload is in use for multi-byte encodings, the results from
strlen() and similar functions respect the utf8 characters, causing binary data
to return incorrect lengths.
This function overrides the mbstring encoding to a binary-safe encoding, and
resets it to the users expected encoding afterwards through the
`resetMbstringEncoding` function.
It is safe to recursively call this function, however each
`mbstring_binary_safe_encoding()` call must be followed up with an equal number
of `resetMbstringEncoding()` calls.
@param bool $reset Optional. Whether to reset the encoding back to a previously-set encoding.
Default false.
@return void
@since 3.7.0
@see resetMbstringEncoding() | [
"Set",
"the",
"mbstring",
"internal",
"encoding",
"to",
"a",
"binary",
"safe",
"encoding",
"when",
"func_overload",
"is",
"enabled",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Util/String.php#L546-L569 |
46,724 | grrr-amsterdam/garp3 | library/Garp/Util/String.php | Garp_Util_String.humanList | static public function humanList(array $list, $decorator = null, $lastItemSeperator = 'and') {
$listCount = count($list);
if ($listCount === 1) {
return $decorator . current($list) . $decorator;
} elseif ($listCount === 2) {
return $decorator . implode(
$decorator . " {$lastItemSeperator} " . $decorator, $list
) . $decorator;
} elseif ($listCount > 2) {
$last = array_pop($list);
return $decorator . implode(
$decorator . ", " . $decorator, $list
) . $decorator . " {$lastItemSeperator} " . $decorator . $last . $decorator;
}
} | php | static public function humanList(array $list, $decorator = null, $lastItemSeperator = 'and') {
$listCount = count($list);
if ($listCount === 1) {
return $decorator . current($list) . $decorator;
} elseif ($listCount === 2) {
return $decorator . implode(
$decorator . " {$lastItemSeperator} " . $decorator, $list
) . $decorator;
} elseif ($listCount > 2) {
$last = array_pop($list);
return $decorator . implode(
$decorator . ", " . $decorator, $list
) . $decorator . " {$lastItemSeperator} " . $decorator . $last . $decorator;
}
} | [
"static",
"public",
"function",
"humanList",
"(",
"array",
"$",
"list",
",",
"$",
"decorator",
"=",
"null",
",",
"$",
"lastItemSeperator",
"=",
"'and'",
")",
"{",
"$",
"listCount",
"=",
"count",
"(",
"$",
"list",
")",
";",
"if",
"(",
"$",
"listCount",
... | Creates a human-readable string of an array.
@param array $list Numeric Array of String elements,
@param string $decorator Element decorator, f.i. a quote.
@param string $lastItemSeperator Seperates the last item from the rest instead of a comma,
for instance: 'and' or 'or'.
@return string Listed elements, like "Snoop, Dre and Devin". | [
"Creates",
"a",
"human",
"-",
"readable",
"string",
"of",
"an",
"array",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Util/String.php#L591-L605 |
46,725 | grrr-amsterdam/garp3 | library/Garp/Util/String.php | Garp_Util_String.linkUrls | static public function linkUrls($text, array $attribs = array()) {
$htmlAttribs = array();
foreach ($attribs as $name => $value) {
$htmlAttribs[] = $name . '="' . $value . '"';
}
$htmlAttribs = implode(' ', $htmlAttribs);
$htmlAttribs = $htmlAttribs ? ' ' . $htmlAttribs : '';
$regexpProtocol = "/(?:^|\s)((http|https|ftp):\/\/[^\s<]+[\w\/#])([?!,.])?(?=$|\s)/i";
$regexpWww = "/(?:^|\s)((www\.)[^\s<]+[\w\/#])([?!,.])?(?=$|\s)/i";
$text = preg_replace($regexpProtocol, " <a href=\"\\1\"$htmlAttribs>\\1</a>\\3 ", $text);
$text = preg_replace($regexpWww, " <a href=\"http://\\1\"$htmlAttribs>\\1</a>\\3 ", $text);
return trim($text);
} | php | static public function linkUrls($text, array $attribs = array()) {
$htmlAttribs = array();
foreach ($attribs as $name => $value) {
$htmlAttribs[] = $name . '="' . $value . '"';
}
$htmlAttribs = implode(' ', $htmlAttribs);
$htmlAttribs = $htmlAttribs ? ' ' . $htmlAttribs : '';
$regexpProtocol = "/(?:^|\s)((http|https|ftp):\/\/[^\s<]+[\w\/#])([?!,.])?(?=$|\s)/i";
$regexpWww = "/(?:^|\s)((www\.)[^\s<]+[\w\/#])([?!,.])?(?=$|\s)/i";
$text = preg_replace($regexpProtocol, " <a href=\"\\1\"$htmlAttribs>\\1</a>\\3 ", $text);
$text = preg_replace($regexpWww, " <a href=\"http://\\1\"$htmlAttribs>\\1</a>\\3 ", $text);
return trim($text);
} | [
"static",
"public",
"function",
"linkUrls",
"(",
"$",
"text",
",",
"array",
"$",
"attribs",
"=",
"array",
"(",
")",
")",
"{",
"$",
"htmlAttribs",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"attribs",
"as",
"$",
"name",
"=>",
"$",
"value",
")... | Link URLs.
@param string $text
@param array $attribs HTML attributes
@return string | [
"Link",
"URLs",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Util/String.php#L706-L720 |
46,726 | grrr-amsterdam/garp3 | library/Garp/Util/String.php | Garp_Util_String.linkEmailAddresses | static public function linkEmailAddresses($text, array $attribs = array()) {
$htmlAttribs = array();
foreach ($attribs as $name => $value) {
$htmlAttribs[] = $name . '="' . $value . '"';
}
$htmlAttribs = implode(' ', $htmlAttribs);
$htmlAttribs = $htmlAttribs ? ' ' . $htmlAttribs : '';
$regexp = '/[a-zA-Z0-9\.-_+]+@[a-zA-Z0-9\.\-_]+\.([a-zA-Z]{2,})/';
$text = preg_replace($regexp, "<a href=\"mailto:$0\"$htmlAttribs>$0</a>", $text);
return $text;
} | php | static public function linkEmailAddresses($text, array $attribs = array()) {
$htmlAttribs = array();
foreach ($attribs as $name => $value) {
$htmlAttribs[] = $name . '="' . $value . '"';
}
$htmlAttribs = implode(' ', $htmlAttribs);
$htmlAttribs = $htmlAttribs ? ' ' . $htmlAttribs : '';
$regexp = '/[a-zA-Z0-9\.-_+]+@[a-zA-Z0-9\.\-_]+\.([a-zA-Z]{2,})/';
$text = preg_replace($regexp, "<a href=\"mailto:$0\"$htmlAttribs>$0</a>", $text);
return $text;
} | [
"static",
"public",
"function",
"linkEmailAddresses",
"(",
"$",
"text",
",",
"array",
"$",
"attribs",
"=",
"array",
"(",
")",
")",
"{",
"$",
"htmlAttribs",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"attribs",
"as",
"$",
"name",
"=>",
"$",
"va... | Link email addresses
@param string $text
@param array $attribs HTML attributes
@return string | [
"Link",
"email",
"addresses"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Util/String.php#L729-L740 |
46,727 | grrr-amsterdam/garp3 | library/Garp/Util/String.php | Garp_Util_String.scrambleEmail | static public function scrambleEmail($email, $mailTo = false) {
for ($i = 0, $c = strlen($email), $out = ''; $i < $c; $i++) {
$out .= '&#' . ord($email[$i]) . ';';
}
if ($mailTo) {
$out = self::scrambleEmail('mailto:') . $out;
}
return $out;
} | php | static public function scrambleEmail($email, $mailTo = false) {
for ($i = 0, $c = strlen($email), $out = ''; $i < $c; $i++) {
$out .= '&#' . ord($email[$i]) . ';';
}
if ($mailTo) {
$out = self::scrambleEmail('mailto:') . $out;
}
return $out;
} | [
"static",
"public",
"function",
"scrambleEmail",
"(",
"$",
"email",
",",
"$",
"mailTo",
"=",
"false",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"c",
"=",
"strlen",
"(",
"$",
"email",
")",
",",
"$",
"out",
"=",
"''",
";",
"$",
"i",
"... | Output email address as entities
@param string $email
@param boolean $mailTo Wether to append "mailto:" for embedding in <a href="">
@return string | [
"Output",
"email",
"address",
"as",
"entities"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Util/String.php#L749-L757 |
46,728 | grrr-amsterdam/garp3 | library/Garp/Util/String.php | Garp_Util_String.interpolate | static public function interpolate($str, array $vars) {
$keys = array_keys($vars);
$vals = array_values($vars);
// surround keys by "%"
array_walk(
$keys, function (&$s) {
$s = '%' . $s . '%';
}
);
$str = str_replace($keys, $vals, $str);
return $str;
} | php | static public function interpolate($str, array $vars) {
$keys = array_keys($vars);
$vals = array_values($vars);
// surround keys by "%"
array_walk(
$keys, function (&$s) {
$s = '%' . $s . '%';
}
);
$str = str_replace($keys, $vals, $str);
return $str;
} | [
"static",
"public",
"function",
"interpolate",
"(",
"$",
"str",
",",
"array",
"$",
"vars",
")",
"{",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"vars",
")",
";",
"$",
"vals",
"=",
"array_values",
"(",
"$",
"vars",
")",
";",
"// surround keys by \"%\"",
... | Interpolate strings with variables
@param string $str The string
@param array $vars The variables
@return string The interpolated string | [
"Interpolate",
"strings",
"with",
"variables"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Util/String.php#L789-L800 |
46,729 | grrr-amsterdam/garp3 | library/Garp/Deploy/Config.php | Garp_Deploy_Config.isConfigured | public function isConfigured($env) {
if (!file_exists($this->_createPathFromEnv($env))) {
return false;
}
return !!$this->_fetchEnvContent($env);
} | php | public function isConfigured($env) {
if (!file_exists($this->_createPathFromEnv($env))) {
return false;
}
return !!$this->_fetchEnvContent($env);
} | [
"public",
"function",
"isConfigured",
"(",
"$",
"env",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"_createPathFromEnv",
"(",
"$",
"env",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"!",
"!",
"$",
"this",
"->",
"... | Returns whether the deployment setup is configured
for this environmentparameters for a specific environment.
@param String $env The environment to get parameters for
(i.e. 'integration' or 'production').
@return Bool Whether the deploy configuration is set. | [
"Returns",
"whether",
"the",
"deployment",
"setup",
"is",
"configured",
"for",
"this",
"environmentparameters",
"for",
"a",
"specific",
"environment",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Deploy/Config.php#L32-L37 |
46,730 | grrr-amsterdam/garp3 | library/Garp/Deploy/Config.php | Garp_Deploy_Config.getParams | public function getParams($env) {
$genericParams = $this->_parseContent($this->_genericContent);
$envParams = $this->_parseContent($this->_fetchEnvContent($env));
$output = $genericParams + $envParams;
return $output;
} | php | public function getParams($env) {
$genericParams = $this->_parseContent($this->_genericContent);
$envParams = $this->_parseContent($this->_fetchEnvContent($env));
$output = $genericParams + $envParams;
return $output;
} | [
"public",
"function",
"getParams",
"(",
"$",
"env",
")",
"{",
"$",
"genericParams",
"=",
"$",
"this",
"->",
"_parseContent",
"(",
"$",
"this",
"->",
"_genericContent",
")",
";",
"$",
"envParams",
"=",
"$",
"this",
"->",
"_parseContent",
"(",
"$",
"this",... | Returns the deploy parameters for a specific environment.
@param String $env The environment to get parameters for
(i.e. 'integration' or 'production').
@return Array List of deploy parameters:
'server' => 'myhost.example.com',
'deploy_to' => '/var/www/mylittlepony',
'user' => 'SSH user' | [
"Returns",
"the",
"deploy",
"parameters",
"for",
"a",
"specific",
"environment",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Deploy/Config.php#L49-L55 |
46,731 | grrr-amsterdam/garp3 | library/Garp/Deploy/Config.php | Garp_Deploy_Config._parseContent | protected function _parseContent($content) {
$output = array();
$matches = array();
$paramsString = implode('|', $this->_deployParams);
$pattern = '/:?(?P<paramName>' . $paramsString
. ')[,:]? [\'"](?P<paramValue>[^\'"]*)[\'"]/';
if (!preg_match_all($pattern, $content, $matches)) {
throw new Exception(
"Could not extract deploy parameters from "
. self::GENERIC_CONFIG_PATH
);
}
foreach ($this->_deployParams as $p) {
$indices = array_keys(
array_filter(
$matches['paramName'], function ($pn) use ($p) {
return $pn === $p;
}
)
);
if (!count($indices)) {
continue;
}
$output[$p] = array_values(array_get_subset($matches['paramValue'], $indices));
// For now: only treat the server param as array (since it's common for it to be an
// array, in the case of a multi-server setup)
if ($p !== 'server') {
$output[$p] = $output[$p][0];
}
}
// explode server into user and server parts
if (!empty($output['server'])) {
$output['server'] = array_map(
function ($serverConfig) {
$bits = explode('@', $serverConfig, 2);
return array(
'user' => $bits[0],
'server' => $bits[1]
);
}, $output['server']
);
}
return $output;
} | php | protected function _parseContent($content) {
$output = array();
$matches = array();
$paramsString = implode('|', $this->_deployParams);
$pattern = '/:?(?P<paramName>' . $paramsString
. ')[,:]? [\'"](?P<paramValue>[^\'"]*)[\'"]/';
if (!preg_match_all($pattern, $content, $matches)) {
throw new Exception(
"Could not extract deploy parameters from "
. self::GENERIC_CONFIG_PATH
);
}
foreach ($this->_deployParams as $p) {
$indices = array_keys(
array_filter(
$matches['paramName'], function ($pn) use ($p) {
return $pn === $p;
}
)
);
if (!count($indices)) {
continue;
}
$output[$p] = array_values(array_get_subset($matches['paramValue'], $indices));
// For now: only treat the server param as array (since it's common for it to be an
// array, in the case of a multi-server setup)
if ($p !== 'server') {
$output[$p] = $output[$p][0];
}
}
// explode server into user and server parts
if (!empty($output['server'])) {
$output['server'] = array_map(
function ($serverConfig) {
$bits = explode('@', $serverConfig, 2);
return array(
'user' => $bits[0],
'server' => $bits[1]
);
}, $output['server']
);
}
return $output;
} | [
"protected",
"function",
"_parseContent",
"(",
"$",
"content",
")",
"{",
"$",
"output",
"=",
"array",
"(",
")",
";",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"$",
"paramsString",
"=",
"implode",
"(",
"'|'",
",",
"$",
"this",
"->",
"_deployParams",
... | Parses the generic configuration.
@param String $content
@return Array | [
"Parses",
"the",
"generic",
"configuration",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Deploy/Config.php#L78-L126 |
46,732 | grrr-amsterdam/garp3 | library/Garp/Content/Db/Server/Abstract.php | Garp_Content_Db_Server_Abstract.backup | public function backup() {
$dbConfigParams = $this->getDbConfigParams();
$backupDir = $this->getBackupDir();
$environment = $this->getEnvironment();
if (!$this->databaseExists()) {
return;
}
$createBackupDir = new Garp_Shell_Command_CreateDir($backupDir);
$dumpToFile = new Garp_Shell_Command_DumpDatabaseToFile($dbConfigParams, $backupDir, $environment);
$this->shellExec($createBackupDir);
$this->shellExec($dumpToFile);
/**
* @todo: verifiëren of:
* - backupbestand bestaat
* - backupbestand meer dan 0 bytes heeft
*/
} | php | public function backup() {
$dbConfigParams = $this->getDbConfigParams();
$backupDir = $this->getBackupDir();
$environment = $this->getEnvironment();
if (!$this->databaseExists()) {
return;
}
$createBackupDir = new Garp_Shell_Command_CreateDir($backupDir);
$dumpToFile = new Garp_Shell_Command_DumpDatabaseToFile($dbConfigParams, $backupDir, $environment);
$this->shellExec($createBackupDir);
$this->shellExec($dumpToFile);
/**
* @todo: verifiëren of:
* - backupbestand bestaat
* - backupbestand meer dan 0 bytes heeft
*/
} | [
"public",
"function",
"backup",
"(",
")",
"{",
"$",
"dbConfigParams",
"=",
"$",
"this",
"->",
"getDbConfigParams",
"(",
")",
";",
"$",
"backupDir",
"=",
"$",
"this",
"->",
"getBackupDir",
"(",
")",
";",
"$",
"environment",
"=",
"$",
"this",
"->",
"getE... | Backs up the database and writes it to a file on the server itself. | [
"Backs",
"up",
"the",
"database",
"and",
"writes",
"it",
"to",
"a",
"file",
"on",
"the",
"server",
"itself",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Db/Server/Abstract.php#L121-L141 |
46,733 | grrr-amsterdam/garp3 | library/Garp/Content/Db/Server/Abstract.php | Garp_Content_Db_Server_Abstract.restore | public function restore(&$dump) {
$this->_adjustDumpToEnvironment($dump);
//$dump = $this->_lowerCaseTableAndViewNames($dump);
$this->_removeDefinerCalls($dump);
$dbConfig = $this->getDbConfigParams();
$restoreFile = $this->getRestoreFilePath();
$restoreDir = $this->getBackupDir();
$executeFile = new Garp_Shell_Command_CreateDatabase($dbConfig);
$this->shellExec($executeFile);
if (!$this->_validateDump($dump)) {
throw new Exception("The fetched database seems invalid.");
}
$createRestoreDir = new Garp_Shell_Command_CreateDir($restoreDir);
$this->shellExec($createRestoreDir);
if ($this->store($restoreFile, $dump)) {
$executeFile = new Garp_Shell_Command_ExecuteDatabaseDumpFile($dbConfig, $restoreFile);
$this->shellExec($executeFile);
$removeFile = new Garp_Shell_Command_RemoveFile($restoreFile);
$this->shellExec($removeFile);
}
} | php | public function restore(&$dump) {
$this->_adjustDumpToEnvironment($dump);
//$dump = $this->_lowerCaseTableAndViewNames($dump);
$this->_removeDefinerCalls($dump);
$dbConfig = $this->getDbConfigParams();
$restoreFile = $this->getRestoreFilePath();
$restoreDir = $this->getBackupDir();
$executeFile = new Garp_Shell_Command_CreateDatabase($dbConfig);
$this->shellExec($executeFile);
if (!$this->_validateDump($dump)) {
throw new Exception("The fetched database seems invalid.");
}
$createRestoreDir = new Garp_Shell_Command_CreateDir($restoreDir);
$this->shellExec($createRestoreDir);
if ($this->store($restoreFile, $dump)) {
$executeFile = new Garp_Shell_Command_ExecuteDatabaseDumpFile($dbConfig, $restoreFile);
$this->shellExec($executeFile);
$removeFile = new Garp_Shell_Command_RemoveFile($restoreFile);
$this->shellExec($removeFile);
}
} | [
"public",
"function",
"restore",
"(",
"&",
"$",
"dump",
")",
"{",
"$",
"this",
"->",
"_adjustDumpToEnvironment",
"(",
"$",
"dump",
")",
";",
"//$dump = $this->_lowerCaseTableAndViewNames($dump);",
"$",
"this",
"->",
"_removeDefinerCalls",
"(",
"$",
"dump",
... | Restores a database from a MySQL dump result, executing the contained SQL queries.
@param String $dump The MySQL dump output | [
"Restores",
"a",
"database",
"from",
"a",
"MySQL",
"dump",
"result",
"executing",
"the",
"contained",
"SQL",
"queries",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Db/Server/Abstract.php#L153-L178 |
46,734 | grrr-amsterdam/garp3 | library/Garp/Content/Db/Server/Abstract.php | Garp_Content_Db_Server_Abstract._adjustDumpToEnvironment | protected function _adjustDumpToEnvironment(&$dump) {
$dbParams = $this->getDbConfigParams();
$thisDbName = $dbParams->dbname;
$otherDbParams = $this->_fetchOtherDatabaseParams();
$otherDbName = $otherDbParams->dbname;
// Firstly, adjust the USE DATABASE statements.
$oldUseDbSql = sprintf(self::SQL_USE_STATEMENT, $otherDbName);
$newUseDbSql = sprintf(self::SQL_USE_STATEMENT, $thisDbName);
$dump = str_replace($oldUseDbSql, $newUseDbSql, $dump);
// Then adjust the CREATE DATABASE queries.
$oldCreateDbSql = sprintf(self::SQL_CREATE_DB_STATEMENT, $otherDbName);
$newCreateDbSql = sprintf(self::SQL_CREATE_DB_STATEMENT, $thisDbName);
$dump = str_replace($oldCreateDbSql, $newCreateDbSql, $dump);
// Fixes an incompatibility issue between MySQL 5.1 and 5.6, where keys can have comments.
// Note that this only fixes keys that get a null comment from mysqldump, not keys with
// actual comments. But who would ever do that?
// @see http://9seeds.com/tech/import-export-issues-between-mysql-5-1-and-5-6/
$dump = str_replace(" COMMENT '(null)'", '', $dump);
// preg_replace seems to be way too demanding for large (180 MB) mysqldump files. Using str_replace now.
} | php | protected function _adjustDumpToEnvironment(&$dump) {
$dbParams = $this->getDbConfigParams();
$thisDbName = $dbParams->dbname;
$otherDbParams = $this->_fetchOtherDatabaseParams();
$otherDbName = $otherDbParams->dbname;
// Firstly, adjust the USE DATABASE statements.
$oldUseDbSql = sprintf(self::SQL_USE_STATEMENT, $otherDbName);
$newUseDbSql = sprintf(self::SQL_USE_STATEMENT, $thisDbName);
$dump = str_replace($oldUseDbSql, $newUseDbSql, $dump);
// Then adjust the CREATE DATABASE queries.
$oldCreateDbSql = sprintf(self::SQL_CREATE_DB_STATEMENT, $otherDbName);
$newCreateDbSql = sprintf(self::SQL_CREATE_DB_STATEMENT, $thisDbName);
$dump = str_replace($oldCreateDbSql, $newCreateDbSql, $dump);
// Fixes an incompatibility issue between MySQL 5.1 and 5.6, where keys can have comments.
// Note that this only fixes keys that get a null comment from mysqldump, not keys with
// actual comments. But who would ever do that?
// @see http://9seeds.com/tech/import-export-issues-between-mysql-5-1-and-5-6/
$dump = str_replace(" COMMENT '(null)'", '', $dump);
// preg_replace seems to be way too demanding for large (180 MB) mysqldump files. Using str_replace now.
} | [
"protected",
"function",
"_adjustDumpToEnvironment",
"(",
"&",
"$",
"dump",
")",
"{",
"$",
"dbParams",
"=",
"$",
"this",
"->",
"getDbConfigParams",
"(",
")",
";",
"$",
"thisDbName",
"=",
"$",
"dbParams",
"->",
"dbname",
";",
"$",
"otherDbParams",
"=",
"$",... | Replace the environment values in the given MySQL dump with the environment values for the target.
@param String &$dump Output of MySQL dump.
@return Void The dump input is changed and not returned, for
the sake of memory conservation. | [
"Replace",
"the",
"environment",
"values",
"in",
"the",
"given",
"MySQL",
"dump",
"with",
"the",
"environment",
"values",
"for",
"the",
"target",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Db/Server/Abstract.php#L196-L219 |
46,735 | grrr-amsterdam/garp3 | library/Garp/Content/Db/Server/Abstract.php | Garp_Content_Db_Server_Abstract._fetchOtherDatabaseParams | protected function _fetchOtherDatabaseParams() {
$otherEnvironment = $this->getOtherEnvironment();
$appConfigParams = $this->_fetchAppConfigParams($otherEnvironment);
$params = $appConfigParams->resources->db->params;
return $params;
} | php | protected function _fetchOtherDatabaseParams() {
$otherEnvironment = $this->getOtherEnvironment();
$appConfigParams = $this->_fetchAppConfigParams($otherEnvironment);
$params = $appConfigParams->resources->db->params;
return $params;
} | [
"protected",
"function",
"_fetchOtherDatabaseParams",
"(",
")",
"{",
"$",
"otherEnvironment",
"=",
"$",
"this",
"->",
"getOtherEnvironment",
"(",
")",
";",
"$",
"appConfigParams",
"=",
"$",
"this",
"->",
"_fetchAppConfigParams",
"(",
"$",
"otherEnvironment",
")",
... | Returns the database name of the counterpart server,
i.e. source if this is target, and vice versa.
@return String The other database name | [
"Returns",
"the",
"database",
"name",
"of",
"the",
"counterpart",
"server",
"i",
".",
"e",
".",
"source",
"if",
"this",
"is",
"target",
"and",
"vice",
"versa",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Db/Server/Abstract.php#L226-L232 |
46,736 | grrr-amsterdam/garp3 | library/Garp/Content/Db/Server/Abstract.php | Garp_Content_Db_Server_Abstract._lowerCaseTableAndViewNames | protected function _lowerCaseTableAndViewNames(&$dump) {
$configDir = APPLICATION_PATH."/modules/default/Model/config/";
$extension = 'json';
$patterns = array();
$replacements = array();
$hardcodedTables = array('AuthFacebook', 'AuthLocal', 'Video');
foreach ($hardcodedTables as $hardcodedTable) {
$patterns[] = "`{$hardcodedTable}`";
$replacements[] = "`" . strtolower($hardcodedTable) ."`";
}
$modelConfig = new Garp_Model_Spawn_Config_Model_Set(
new Garp_Model_Spawn_Config_Storage_File($configDir, $extension),
new Garp_Model_Spawn_Config_Format_Json
);
$modelSet = new Garp_Model_Spawn_ModelSet($modelConfig);
foreach ($modelSet as $model) {
$lcModel = strtolower($model->id);
$patterns[] = "`{$model->id}`";
$replacements[] = "`{$lcModel}`";
$relations = $model->relations->getRelations();
foreach ($relations as $relation) {
if ($relation->type === 'hasAndBelongsToMany') {
$bindingModel = $relation->getBindingModel();
$bindingName = '_' . $bindingModel->id;
$lcRelation = strtolower($bindingName);
$patterns[] = "`{$bindingName}`";
$replacements[] = "`{$lcRelation}`";
} else {
$lcRelation = strtolower($relation->name);
$patterns[] = "`{$relation->name}`";
$replacements[] = "`{$lcRelation}`";
}
}
}
$dump = str_replace($patterns, $replacements, $dump);
return $dump;
} | php | protected function _lowerCaseTableAndViewNames(&$dump) {
$configDir = APPLICATION_PATH."/modules/default/Model/config/";
$extension = 'json';
$patterns = array();
$replacements = array();
$hardcodedTables = array('AuthFacebook', 'AuthLocal', 'Video');
foreach ($hardcodedTables as $hardcodedTable) {
$patterns[] = "`{$hardcodedTable}`";
$replacements[] = "`" . strtolower($hardcodedTable) ."`";
}
$modelConfig = new Garp_Model_Spawn_Config_Model_Set(
new Garp_Model_Spawn_Config_Storage_File($configDir, $extension),
new Garp_Model_Spawn_Config_Format_Json
);
$modelSet = new Garp_Model_Spawn_ModelSet($modelConfig);
foreach ($modelSet as $model) {
$lcModel = strtolower($model->id);
$patterns[] = "`{$model->id}`";
$replacements[] = "`{$lcModel}`";
$relations = $model->relations->getRelations();
foreach ($relations as $relation) {
if ($relation->type === 'hasAndBelongsToMany') {
$bindingModel = $relation->getBindingModel();
$bindingName = '_' . $bindingModel->id;
$lcRelation = strtolower($bindingName);
$patterns[] = "`{$bindingName}`";
$replacements[] = "`{$lcRelation}`";
} else {
$lcRelation = strtolower($relation->name);
$patterns[] = "`{$relation->name}`";
$replacements[] = "`{$lcRelation}`";
}
}
}
$dump = str_replace($patterns, $replacements, $dump);
return $dump;
} | [
"protected",
"function",
"_lowerCaseTableAndViewNames",
"(",
"&",
"$",
"dump",
")",
"{",
"$",
"configDir",
"=",
"APPLICATION_PATH",
".",
"\"/modules/default/Model/config/\"",
";",
"$",
"extension",
"=",
"'json'",
";",
"$",
"patterns",
"=",
"array",
"(",
")",
";"... | Lowercase the table and view names, for compatibility's sake.
Can we deprecate this method already?
@param String &$dump Output of MySQL dump.
@return String The dump output, with adjusted casing. | [
"Lowercase",
"the",
"table",
"and",
"view",
"names",
"for",
"compatibility",
"s",
"sake",
".",
"Can",
"we",
"deprecate",
"this",
"method",
"already?"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Db/Server/Abstract.php#L241-L284 |
46,737 | grrr-amsterdam/garp3 | library/Garp/Content/Relation/Manager.php | Garp_Content_Relation_Manager.relate | public static function relate($options) {
self::_normalizeOptionsForRelate($options);
$modelA = $options['modelA'];
$modelB = $options['modelB'];
/**
* If bindingModel is set, we can safely skip all those difficult checks below.
*/
if (is_object($options['bindingModel'])) {
return self::_relateHasAndBelongsToMany($options);
}
try {
/**
* If this succeeds, it's a regular relationship where the foreign key
* resides inside modelA. Continue as usual.
*/
$reference = $modelA->getReference(get_class($modelB), $options['rule']);
} catch (Exception $e) {
if (!self::isInvalidReferenceException($e)) {
throw $e;
}
try {
/**
* If this succeeds, the foreign key resides in the modelA.
* Flip modelA and modelB and keyA and keyB in order to normalize
* the given configuration.
* Call self::relate() recursively with these new options.
*/
$reference = $modelB->getReference(get_class($modelA), $options['rule']);
$keyA = $options['keyA'];
$keyB = $options['keyB'];
$options['modelA'] = $modelB;
$options['modelB'] = $modelA;
$options['keyA'] = $keyB;
$options['keyB'] = $keyA;
return Garp_Content_Relation_Manager::relate($options);
} catch (Exception $e) {
if (!self::isInvalidReferenceException($e)) {
throw $e;
}
/**
* Goody, we're dealing with a hasAndBelongsToMany relationship here.
* Try to construct the intersection model and save the relation
* that way.
*/
return self::_relateHasAndBelongsToMany($options);
}
}
$rowA = call_user_func_array(array($options['modelA'], 'find'), (array)$options['keyA']);
if (!count($rowA)) {
$errorMsg = sprintf(
self::EXCEPTION_ROW_NOT_FOUND_BY_PRIMARY_KEY,
$modelA->getName(), implode(',', (array)$options['keyA'])
);
throw new Garp_Content_Relation_Exception($errorMsg);
}
$rowA = $rowA->current();
self::_addForeignKeysToRow($rowA, $reference, $options['keyB']);
return $rowA->save();
} | php | public static function relate($options) {
self::_normalizeOptionsForRelate($options);
$modelA = $options['modelA'];
$modelB = $options['modelB'];
/**
* If bindingModel is set, we can safely skip all those difficult checks below.
*/
if (is_object($options['bindingModel'])) {
return self::_relateHasAndBelongsToMany($options);
}
try {
/**
* If this succeeds, it's a regular relationship where the foreign key
* resides inside modelA. Continue as usual.
*/
$reference = $modelA->getReference(get_class($modelB), $options['rule']);
} catch (Exception $e) {
if (!self::isInvalidReferenceException($e)) {
throw $e;
}
try {
/**
* If this succeeds, the foreign key resides in the modelA.
* Flip modelA and modelB and keyA and keyB in order to normalize
* the given configuration.
* Call self::relate() recursively with these new options.
*/
$reference = $modelB->getReference(get_class($modelA), $options['rule']);
$keyA = $options['keyA'];
$keyB = $options['keyB'];
$options['modelA'] = $modelB;
$options['modelB'] = $modelA;
$options['keyA'] = $keyB;
$options['keyB'] = $keyA;
return Garp_Content_Relation_Manager::relate($options);
} catch (Exception $e) {
if (!self::isInvalidReferenceException($e)) {
throw $e;
}
/**
* Goody, we're dealing with a hasAndBelongsToMany relationship here.
* Try to construct the intersection model and save the relation
* that way.
*/
return self::_relateHasAndBelongsToMany($options);
}
}
$rowA = call_user_func_array(array($options['modelA'], 'find'), (array)$options['keyA']);
if (!count($rowA)) {
$errorMsg = sprintf(
self::EXCEPTION_ROW_NOT_FOUND_BY_PRIMARY_KEY,
$modelA->getName(), implode(',', (array)$options['keyA'])
);
throw new Garp_Content_Relation_Exception($errorMsg);
}
$rowA = $rowA->current();
self::_addForeignKeysToRow($rowA, $reference, $options['keyB']);
return $rowA->save();
} | [
"public",
"static",
"function",
"relate",
"(",
"$",
"options",
")",
"{",
"self",
"::",
"_normalizeOptionsForRelate",
"(",
"$",
"options",
")",
";",
"$",
"modelA",
"=",
"$",
"options",
"[",
"'modelA'",
"]",
";",
"$",
"modelB",
"=",
"$",
"options",
"[",
... | Relate records.
@param array|Garp_Util_Configuration $options Lots o' options:
'modelA' string|Garp_Model_Db The first model or classname thereof
'modelB' string|Garp_Model_Db The second model or classname thereof
'keyA' mixed Primary key(s) of the first model
'keyB' mixed Primary key(s) of the second model
'rule' string The rule that stores this relationship in one
of the reference maps
'extraFields' Array Extra fields that can be saved with a HABTM record
@return bool Success | [
"Relate",
"records",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Relation/Manager.php#L28-L89 |
46,738 | grrr-amsterdam/garp3 | library/Garp/Content/Relation/Manager.php | Garp_Content_Relation_Manager.unrelate | public static function unrelate($options) {
self::_normalizeOptionsForUnrelate($options);
$modelA = $options['modelA'];
$modelB = $options['modelB'];
/**
* If bindingModel is set, we can safely skip all those difficult checks below.
*/
if (is_object($options['bindingModel'])) {
return self::_unrelateHasAndBelongsToMany($options);
}
try {
/**
* If this succeeds, it's a regular relationship where the foreign key
* resides inside modelA. Continue as usual.
*/
$reference = $modelA->getReference(get_class($modelB), $options['rule']);
} catch (Exception $e) {
if (!self::isInvalidReferenceException($e)) {
throw $e;
}
try {
/**
* If this succeeds, the foreign key resides in the modelA.
* Flip modelA and modelB and keyA and keyB in order to normalize the
* given configuration.
* Call self::relate() recursively with these new options.
*/
$reference = $modelB->getReference(get_class($modelA), $options['rule']);
$keyA = $options['keyA'];
$keyB = $options['keyB'];
$options['modelA'] = $modelB;
$options['modelB'] = $modelA;
$options['keyA'] = $keyB;
$options['keyB'] = $keyA;
return Garp_Content_Relation_Manager::unrelate($options);
} catch (Exception $e) {
if (!self::isInvalidReferenceException($e)) {
throw $e;
}
/**
* Goody, we're dealing with a hasAndBelongsToMany relationship here.
* Try to construct the intersection model and save the relation
* that way.
*/
return self::_unrelateHasAndBelongsToMany($options);
}
}
/**
* Figure out which model is leading. This depends on which of the two keys is provided.
* This kind of flips the query around. For instance, when keyA is given, the query is
* something like this:
* UPDATE modelA SET foreignkey = NULL WHERE primarykey = keyA
* When keyB is given however, the query goes something like this:
* UPDATE modelA SET foreignkey = NULL WHERE foreignkey = keyB
*/
$query = 'UPDATE `' . $modelA->getName() . '` SET ';
$columnsToValues = array();
foreach ($reference['columns'] as $column) {
$columnsToValues[] = '`' . $column . '` = NULL';
}
$columnsToValues = implode(' AND ', $columnsToValues);
$query .= $columnsToValues;
$whereColumnsToValues = array();
if ($options['keyA']) {
$useColumns = 'refColumns';
$useKeys = 'keyA';
} else {
$useColumns = 'columns';
$useKeys = 'keyB';
}
foreach ($reference[$useColumns] as $i => $column) {
$whereColumnsToValues[] = '`' . $column . '` = ' . $options[$useKeys][$i];
}
$whereColumnsToValues = implode(' AND ', $whereColumnsToValues);
$query .= ' WHERE ';
$query .= $whereColumnsToValues;
return $modelA->getAdapter()->query($query);
} | php | public static function unrelate($options) {
self::_normalizeOptionsForUnrelate($options);
$modelA = $options['modelA'];
$modelB = $options['modelB'];
/**
* If bindingModel is set, we can safely skip all those difficult checks below.
*/
if (is_object($options['bindingModel'])) {
return self::_unrelateHasAndBelongsToMany($options);
}
try {
/**
* If this succeeds, it's a regular relationship where the foreign key
* resides inside modelA. Continue as usual.
*/
$reference = $modelA->getReference(get_class($modelB), $options['rule']);
} catch (Exception $e) {
if (!self::isInvalidReferenceException($e)) {
throw $e;
}
try {
/**
* If this succeeds, the foreign key resides in the modelA.
* Flip modelA and modelB and keyA and keyB in order to normalize the
* given configuration.
* Call self::relate() recursively with these new options.
*/
$reference = $modelB->getReference(get_class($modelA), $options['rule']);
$keyA = $options['keyA'];
$keyB = $options['keyB'];
$options['modelA'] = $modelB;
$options['modelB'] = $modelA;
$options['keyA'] = $keyB;
$options['keyB'] = $keyA;
return Garp_Content_Relation_Manager::unrelate($options);
} catch (Exception $e) {
if (!self::isInvalidReferenceException($e)) {
throw $e;
}
/**
* Goody, we're dealing with a hasAndBelongsToMany relationship here.
* Try to construct the intersection model and save the relation
* that way.
*/
return self::_unrelateHasAndBelongsToMany($options);
}
}
/**
* Figure out which model is leading. This depends on which of the two keys is provided.
* This kind of flips the query around. For instance, when keyA is given, the query is
* something like this:
* UPDATE modelA SET foreignkey = NULL WHERE primarykey = keyA
* When keyB is given however, the query goes something like this:
* UPDATE modelA SET foreignkey = NULL WHERE foreignkey = keyB
*/
$query = 'UPDATE `' . $modelA->getName() . '` SET ';
$columnsToValues = array();
foreach ($reference['columns'] as $column) {
$columnsToValues[] = '`' . $column . '` = NULL';
}
$columnsToValues = implode(' AND ', $columnsToValues);
$query .= $columnsToValues;
$whereColumnsToValues = array();
if ($options['keyA']) {
$useColumns = 'refColumns';
$useKeys = 'keyA';
} else {
$useColumns = 'columns';
$useKeys = 'keyB';
}
foreach ($reference[$useColumns] as $i => $column) {
$whereColumnsToValues[] = '`' . $column . '` = ' . $options[$useKeys][$i];
}
$whereColumnsToValues = implode(' AND ', $whereColumnsToValues);
$query .= ' WHERE ';
$query .= $whereColumnsToValues;
return $modelA->getAdapter()->query($query);
} | [
"public",
"static",
"function",
"unrelate",
"(",
"$",
"options",
")",
"{",
"self",
"::",
"_normalizeOptionsForUnrelate",
"(",
"$",
"options",
")",
";",
"$",
"modelA",
"=",
"$",
"options",
"[",
"'modelA'",
"]",
";",
"$",
"modelB",
"=",
"$",
"options",
"["... | Unrelate records.
@param array|Garp_Util_Configuration $options Lots o' options:
'modelA' string|Garp_Model_Db The first model or classname thereof
'modelB' string|Garp_Model_Db The second model or classname thereof
'keyA' mixed Primary key(s) of the first model
'keyB' mixed Primary key(s) of the second model
'rule' string The rule that stores this relationship in one of the
reference maps
@return bool Success | [
"Unrelate",
"records",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Relation/Manager.php#L194-L275 |
46,739 | grrr-amsterdam/garp3 | library/Garp/Content/Relation/Manager.php | Garp_Content_Relation_Manager._addForeignKeysToRow | protected static function _addForeignKeysToRow(Zend_Db_Table_Row_Abstract &$row,
array $reference, array $values
) {
// Normalize array keys
$values = array_values($values);
foreach ($reference['columns'] as $i => $column) {
if (!isset($values[$i])) {
throw new Garp_Content_Relation_Exception(
sprintf(static::EXCEPTION_MISSING_VALUE, $column)
);
}
$row->{$column} = $values[$i];
}
} | php | protected static function _addForeignKeysToRow(Zend_Db_Table_Row_Abstract &$row,
array $reference, array $values
) {
// Normalize array keys
$values = array_values($values);
foreach ($reference['columns'] as $i => $column) {
if (!isset($values[$i])) {
throw new Garp_Content_Relation_Exception(
sprintf(static::EXCEPTION_MISSING_VALUE, $column)
);
}
$row->{$column} = $values[$i];
}
} | [
"protected",
"static",
"function",
"_addForeignKeysToRow",
"(",
"Zend_Db_Table_Row_Abstract",
"&",
"$",
"row",
",",
"array",
"$",
"reference",
",",
"array",
"$",
"values",
")",
"{",
"// Normalize array keys",
"$",
"values",
"=",
"array_values",
"(",
"$",
"values",... | Fill foreign key columns in a row.
@param Zend_Db_Table_Row_Abstract $row The row object
@param array $reference The reference from the referencemap
@param array $values The foreign key values
@return void Edits the row by reference | [
"Fill",
"foreign",
"key",
"columns",
"in",
"a",
"row",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Relation/Manager.php#L397-L410 |
46,740 | grrr-amsterdam/garp3 | library/Garp/Content/Relation/Manager.php | Garp_Content_Relation_Manager.isInvalidReferenceException | static public function isInvalidReferenceException(Exception $e) {
return stripos($e->getMessage(), 'No reference') !== false ||
preg_match('/Reference rule "(.+)" does not reference table (.+)/', $e->getMessage());
} | php | static public function isInvalidReferenceException(Exception $e) {
return stripos($e->getMessage(), 'No reference') !== false ||
preg_match('/Reference rule "(.+)" does not reference table (.+)/', $e->getMessage());
} | [
"static",
"public",
"function",
"isInvalidReferenceException",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"stripos",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"'No reference'",
")",
"!==",
"false",
"||",
"preg_match",
"(",
"'/Reference rule \"(.+)\"... | Unfortunately, almost all the Zend exceptions coming from Zend_Db_Table_Abstract are of type
Zend_Db_Table_Exception, so we cannot check wether a query fails or wether there is no
binding possible.
This method checks wether the exception describes an invalid reference.
@param Exception $e
@return bool | [
"Unfortunately",
"almost",
"all",
"the",
"Zend",
"exceptions",
"coming",
"from",
"Zend_Db_Table_Abstract",
"are",
"of",
"type",
"Zend_Db_Table_Exception",
"so",
"we",
"cannot",
"check",
"wether",
"a",
"query",
"fails",
"or",
"wether",
"there",
"is",
"no",
"binding... | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Relation/Manager.php#L421-L424 |
46,741 | grrr-amsterdam/garp3 | library/Garp/Db/Table/Rowset.php | Garp_Db_Table_Rowset.flatten | public function flatten($column) {
$out = array();
foreach ($this as $row) {
$out[] = $row->flatten($column);
}
return $out;
} | php | public function flatten($column) {
$out = array();
foreach ($this as $row) {
$out[] = $row->flatten($column);
}
return $out;
} | [
"public",
"function",
"flatten",
"(",
"$",
"column",
")",
"{",
"$",
"out",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"row",
")",
"{",
"$",
"out",
"[",
"]",
"=",
"$",
"row",
"->",
"flatten",
"(",
"$",
"column",
")",
... | Flatten a rowset to a simpler array containing the specified columns.
@param Mixed $columns Array of columns or column.
@return Array | [
"Flatten",
"a",
"rowset",
"to",
"a",
"simpler",
"array",
"containing",
"the",
"specified",
"columns",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Db/Table/Rowset.php#L18-L24 |
46,742 | grrr-amsterdam/garp3 | library/Garp/Model/Validator/NotEmpty.php | Garp_Model_Validator_NotEmpty.validate | public function validate(array $data, Garp_Model_Db $model, $onlyIfAvailable = false) {
foreach ($this->_fields as $field) {
$this->_validate($field, $model, $data, $onlyIfAvailable);
}
} | php | public function validate(array $data, Garp_Model_Db $model, $onlyIfAvailable = false) {
foreach ($this->_fields as $field) {
$this->_validate($field, $model, $data, $onlyIfAvailable);
}
} | [
"public",
"function",
"validate",
"(",
"array",
"$",
"data",
",",
"Garp_Model_Db",
"$",
"model",
",",
"$",
"onlyIfAvailable",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_fields",
"as",
"$",
"field",
")",
"{",
"$",
"this",
"->",
"_valid... | Validate wether the given columns are not empty.
@param array $data The data to validate
@param Garp_Model_Db $model The model
@param bool $onlyIfAvailable Wether to skip validation on fields that are not in the array
@return void
@throws Garp_Model_Validator_Exception | [
"Validate",
"wether",
"the",
"given",
"columns",
"are",
"not",
"empty",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Validator/NotEmpty.php#L38-L42 |
46,743 | grrr-amsterdam/garp3 | library/Garp/Model/Validator/NotEmpty.php | Garp_Model_Validator_NotEmpty._validate | protected function _validate($column, $model, $data, $onlyIfAvailable) {
if ($onlyIfAvailable && !array_key_exists($column, $data)) {
return;
}
$value = array_key_exists($column, $data) ? $data[$column] : null;
$colType = $this->_getColumnType($column, $model);
if ($colType == 'numeric') {
$this->_validateNumber($value, $column);
return;
}
$this->_validateString($value, $column);
} | php | protected function _validate($column, $model, $data, $onlyIfAvailable) {
if ($onlyIfAvailable && !array_key_exists($column, $data)) {
return;
}
$value = array_key_exists($column, $data) ? $data[$column] : null;
$colType = $this->_getColumnType($column, $model);
if ($colType == 'numeric') {
$this->_validateNumber($value, $column);
return;
}
$this->_validateString($value, $column);
} | [
"protected",
"function",
"_validate",
"(",
"$",
"column",
",",
"$",
"model",
",",
"$",
"data",
",",
"$",
"onlyIfAvailable",
")",
"{",
"if",
"(",
"$",
"onlyIfAvailable",
"&&",
"!",
"array_key_exists",
"(",
"$",
"column",
",",
"$",
"data",
")",
")",
"{",... | Pass value along to more specific validate functions.
@param string $column Column value
@param Garp_Model_Db $model The model
@param array $data
@param bool $onlyIfAvailable
@return void | [
"Pass",
"value",
"along",
"to",
"more",
"specific",
"validate",
"functions",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Validator/NotEmpty.php#L53-L66 |
46,744 | grrr-amsterdam/garp3 | library/Garp/Model/Validator/NotEmpty.php | Garp_Model_Validator_NotEmpty._validateString | protected function _validateString($value, $column) {
$value = is_string($value) ? trim($value) : $value;
if (empty($value) && $value !== '0') {
throw new Garp_Model_Validator_Exception(
sprintf(__('%s is a required field'), __(Garp_Util_String::underscoredToReadable($column)))
);
}
} | php | protected function _validateString($value, $column) {
$value = is_string($value) ? trim($value) : $value;
if (empty($value) && $value !== '0') {
throw new Garp_Model_Validator_Exception(
sprintf(__('%s is a required field'), __(Garp_Util_String::underscoredToReadable($column)))
);
}
} | [
"protected",
"function",
"_validateString",
"(",
"$",
"value",
",",
"$",
"column",
")",
"{",
"$",
"value",
"=",
"is_string",
"(",
"$",
"value",
")",
"?",
"trim",
"(",
"$",
"value",
")",
":",
"$",
"value",
";",
"if",
"(",
"empty",
"(",
"$",
"value",... | Validate the emptiness of a string.
@param mixed $value
@param string $column
@return void
@throws Garp_Model_Validator_Exception | [
"Validate",
"the",
"emptiness",
"of",
"a",
"string",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Validator/NotEmpty.php#L76-L83 |
46,745 | grrr-amsterdam/garp3 | library/Garp/Model/Validator/NotEmpty.php | Garp_Model_Validator_NotEmpty._validateNumber | protected function _validateNumber($value, $column) {
// Not much to check, since 0 is falsy but also a valid integer value.
if (is_null($value)) {
throw new Garp_Model_Validator_Exception(
sprintf(__('%s is a required field'), __(Garp_Util_String::underscoredToReadable($column)))
);
}
} | php | protected function _validateNumber($value, $column) {
// Not much to check, since 0 is falsy but also a valid integer value.
if (is_null($value)) {
throw new Garp_Model_Validator_Exception(
sprintf(__('%s is a required field'), __(Garp_Util_String::underscoredToReadable($column)))
);
}
} | [
"protected",
"function",
"_validateNumber",
"(",
"$",
"value",
",",
"$",
"column",
")",
"{",
"// Not much to check, since 0 is falsy but also a valid integer value.",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"Garp_Model_Validator_Exception... | Validate the emptiness of a number.
@param mixed $value
@param string $column
@return void
@throws Garp_Model_Validator_Exception | [
"Validate",
"the",
"emptiness",
"of",
"a",
"number",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Validator/NotEmpty.php#L93-L100 |
46,746 | grrr-amsterdam/garp3 | library/Garp/Cli/Command/Elasticsearch.php | Garp_Cli_Command_Elasticsearch.prepare | public function prepare() {
Garp_Cli::lineOut('Preparing Elasticsearch index...');
$report = $this->_createIndexIfNotExists();
Garp_Cli::lineOut($report, Garp_Cli::BLUE);
return true;
} | php | public function prepare() {
Garp_Cli::lineOut('Preparing Elasticsearch index...');
$report = $this->_createIndexIfNotExists();
Garp_Cli::lineOut($report, Garp_Cli::BLUE);
return true;
} | [
"public",
"function",
"prepare",
"(",
")",
"{",
"Garp_Cli",
"::",
"lineOut",
"(",
"'Preparing Elasticsearch index...'",
")",
";",
"$",
"report",
"=",
"$",
"this",
"->",
"_createIndexIfNotExists",
"(",
")",
";",
"Garp_Cli",
"::",
"lineOut",
"(",
"$",
"report",
... | Prepares an index for storing and searching.
@return bool | [
"Prepares",
"an",
"index",
"for",
"storing",
"and",
"searching",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Elasticsearch.php#L30-L35 |
46,747 | grrr-amsterdam/garp3 | library/Garp/Cli/Command/Elasticsearch.php | Garp_Cli_Command_Elasticsearch.index | public function index() {
Garp_Cli::lineOut('Building up index. Hang on to your knickers...');
$modelSet = Garp_Spawn_Model_Set::getInstance();
foreach ($modelSet as $model) {
$this->_indexModel($model);
}
return true;
} | php | public function index() {
Garp_Cli::lineOut('Building up index. Hang on to your knickers...');
$modelSet = Garp_Spawn_Model_Set::getInstance();
foreach ($modelSet as $model) {
$this->_indexModel($model);
}
return true;
} | [
"public",
"function",
"index",
"(",
")",
"{",
"Garp_Cli",
"::",
"lineOut",
"(",
"'Building up index. Hang on to your knickers...'",
")",
";",
"$",
"modelSet",
"=",
"Garp_Spawn_Model_Set",
"::",
"getInstance",
"(",
")",
";",
"foreach",
"(",
"$",
"modelSet",
"as",
... | Pushes all appropriate existing database content to the indexer.
@return bool | [
"Pushes",
"all",
"appropriate",
"existing",
"database",
"content",
"to",
"the",
"indexer",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Elasticsearch.php#L53-L61 |
46,748 | grrr-amsterdam/garp3 | library/Garp/Cli/Command/Elasticsearch.php | Garp_Cli_Command_Elasticsearch._createIndexIfNotExists | protected function _createIndexIfNotExists() {
$service = $this->getService();
$indexExists = $service->doesIndexExist();
if ($indexExists) {
return self::MSG_INDEX_EXISTS;
}
return $service->createIndex()
? self::MSG_INDEX_CREATED
: self::MSG_INDEX_CREATION_FAILURE;
} | php | protected function _createIndexIfNotExists() {
$service = $this->getService();
$indexExists = $service->doesIndexExist();
if ($indexExists) {
return self::MSG_INDEX_EXISTS;
}
return $service->createIndex()
? self::MSG_INDEX_CREATED
: self::MSG_INDEX_CREATION_FAILURE;
} | [
"protected",
"function",
"_createIndexIfNotExists",
"(",
")",
"{",
"$",
"service",
"=",
"$",
"this",
"->",
"getService",
"(",
")",
";",
"$",
"indexExists",
"=",
"$",
"service",
"->",
"doesIndexExist",
"(",
")",
";",
"if",
"(",
"$",
"indexExists",
")",
"{... | Makes sure the service can be used; creates a primary index.
@return String Log message | [
"Makes",
"sure",
"the",
"service",
"can",
"be",
"used",
";",
"creates",
"a",
"primary",
"index",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Elasticsearch.php#L92-L103 |
46,749 | grrr-amsterdam/garp3 | library/Garp/Browsebox.php | Garp_Browsebox.init | public function init($chunk = null) {
if (is_null($chunk) && is_null($chunk = $this->_getCurrentStateFromRequest())) {
$chunk = 1;
}
if ($chunk < 1) {
$chunk = 1;
}
$this->_chunk = $chunk;
$this->_results = $this->_fetchContent($chunk);
$this->_max = $this->_fetchMaxChunks();
return $this;
} | php | public function init($chunk = null) {
if (is_null($chunk) && is_null($chunk = $this->_getCurrentStateFromRequest())) {
$chunk = 1;
}
if ($chunk < 1) {
$chunk = 1;
}
$this->_chunk = $chunk;
$this->_results = $this->_fetchContent($chunk);
$this->_max = $this->_fetchMaxChunks();
return $this;
} | [
"public",
"function",
"init",
"(",
"$",
"chunk",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"chunk",
")",
"&&",
"is_null",
"(",
"$",
"chunk",
"=",
"$",
"this",
"->",
"_getCurrentStateFromRequest",
"(",
")",
")",
")",
"{",
"$",
"chunk",
... | Initialize this browsebox - fetch content and attach to the view.
@param Int $chunk What chunk to load. If null, the browsebox tries to find its state
in the current URL. If that doesn't work, default to chunk #1.
@return Garp_Browsebox $this | [
"Initialize",
"this",
"browsebox",
"-",
"fetch",
"content",
"and",
"attach",
"to",
"the",
"view",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Browsebox.php#L106-L117 |
46,750 | grrr-amsterdam/garp3 | library/Garp/Browsebox.php | Garp_Browsebox.setConfig | public function setConfig(Garp_Util_Configuration $options) {
$options->obligate('id')
->obligate('model')
->setDefault('pageSize', 10)
->setDefault('chunkSize', 1)
->setDefault('order', null)
->setDefault('conditions', null)
->setDefault('viewPath', 'partials/browsebox/'.$options['id'].'.phtml')
->setDefault('bindings', array())
->setDefault('filters', array())
->setDefault('cycle', false)
->setDefault('javascriptOptions', new Garp_Util_Configuration())
->setDefault('select', null)
;
if (!empty($options['filters'])) {
$options['filters'] = $this->_parseFilters($options['filters']);
}
$this->_options = $options;
return $this;
} | php | public function setConfig(Garp_Util_Configuration $options) {
$options->obligate('id')
->obligate('model')
->setDefault('pageSize', 10)
->setDefault('chunkSize', 1)
->setDefault('order', null)
->setDefault('conditions', null)
->setDefault('viewPath', 'partials/browsebox/'.$options['id'].'.phtml')
->setDefault('bindings', array())
->setDefault('filters', array())
->setDefault('cycle', false)
->setDefault('javascriptOptions', new Garp_Util_Configuration())
->setDefault('select', null)
;
if (!empty($options['filters'])) {
$options['filters'] = $this->_parseFilters($options['filters']);
}
$this->_options = $options;
return $this;
} | [
"public",
"function",
"setConfig",
"(",
"Garp_Util_Configuration",
"$",
"options",
")",
"{",
"$",
"options",
"->",
"obligate",
"(",
"'id'",
")",
"->",
"obligate",
"(",
"'model'",
")",
"->",
"setDefault",
"(",
"'pageSize'",
",",
"10",
")",
"->",
"setDefault",... | Set configuration options. This method makes sure there are usable defaults in place.
@param Garp_Util_Configuration $options
@return Garp_Browsebox $this | [
"Set",
"configuration",
"options",
".",
"This",
"method",
"makes",
"sure",
"there",
"are",
"usable",
"defaults",
"in",
"place",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Browsebox.php#L125-L144 |
46,751 | grrr-amsterdam/garp3 | library/Garp/Browsebox.php | Garp_Browsebox._parseFilters | protected function _parseFilters(array $filters) {
$out = array();
foreach ($filters as $key => $value) {
// The deprecated way
if (is_string($key) && is_array($value)) {
$out[$key] = new Garp_Browsebox_Filter_Where($key, $value);
} elseif ($value instanceof Garp_Browsebox_Filter_Abstract) {
$out[$value->getId()] = $value;
} else {
throw new Garp_Browsebox_Exception('Invalid filter configuration encountered. Please use instances of Garp_Browsebox_Filter_Abstract to add filters.');
}
}
return $out;
} | php | protected function _parseFilters(array $filters) {
$out = array();
foreach ($filters as $key => $value) {
// The deprecated way
if (is_string($key) && is_array($value)) {
$out[$key] = new Garp_Browsebox_Filter_Where($key, $value);
} elseif ($value instanceof Garp_Browsebox_Filter_Abstract) {
$out[$value->getId()] = $value;
} else {
throw new Garp_Browsebox_Exception('Invalid filter configuration encountered. Please use instances of Garp_Browsebox_Filter_Abstract to add filters.');
}
}
return $out;
} | [
"protected",
"function",
"_parseFilters",
"(",
"array",
"$",
"filters",
")",
"{",
"$",
"out",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"// The deprecated way",
"if",
"(",
"is_string",
... | Parse filter configuration
@param Array $filters The given filter configuration
@return Array | [
"Parse",
"filter",
"configuration"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Browsebox.php#L152-L165 |
46,752 | grrr-amsterdam/garp3 | library/Garp/Browsebox.php | Garp_Browsebox.setSelect | public function setSelect() {
$select = $this->_options['select'];
if (!$select) {
$select = $this->getModel()->select();
}
if ($this->_options['conditions']) {
$select->where($this->_options['conditions']);
}
if ($this->_options['order']) {
$select->order($this->_options['order']);
}
$this->_select = $select;
return $this;
} | php | public function setSelect() {
$select = $this->_options['select'];
if (!$select) {
$select = $this->getModel()->select();
}
if ($this->_options['conditions']) {
$select->where($this->_options['conditions']);
}
if ($this->_options['order']) {
$select->order($this->_options['order']);
}
$this->_select = $select;
return $this;
} | [
"public",
"function",
"setSelect",
"(",
")",
"{",
"$",
"select",
"=",
"$",
"this",
"->",
"_options",
"[",
"'select'",
"]",
";",
"if",
"(",
"!",
"$",
"select",
")",
"{",
"$",
"select",
"=",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"select",
... | Create the Zend_Db_Select object that generates the results
@return Garp_Browsebox $this | [
"Create",
"the",
"Zend_Db_Select",
"object",
"that",
"generates",
"the",
"results"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Browsebox.php#L195-L208 |
46,753 | grrr-amsterdam/garp3 | library/Garp/Browsebox.php | Garp_Browsebox.setFilter | public function setFilter($filterId, array $params = array()) {
if (!array_key_exists($filterId, $this->_options['filters'])) {
throw new Garp_Browsebox_Exception('Filter "'.$filterId.'" not found in browsebox '.$this->getId().'.');
}
$filter = $this->_options['filters'][$filterId];
$filter->init($params);
try {
$filter->modifySelect($this->_select);
} catch (Garp_Browsebox_Filter_Exception_NotApplicable $e) {
// It's okay, this filter makes no modifications to the Select object
}
// save the custom filters as a property so they can be sent along in the URL
$this->_filters[$filterId] = $params;
return $this;
} | php | public function setFilter($filterId, array $params = array()) {
if (!array_key_exists($filterId, $this->_options['filters'])) {
throw new Garp_Browsebox_Exception('Filter "'.$filterId.'" not found in browsebox '.$this->getId().'.');
}
$filter = $this->_options['filters'][$filterId];
$filter->init($params);
try {
$filter->modifySelect($this->_select);
} catch (Garp_Browsebox_Filter_Exception_NotApplicable $e) {
// It's okay, this filter makes no modifications to the Select object
}
// save the custom filters as a property so they can be sent along in the URL
$this->_filters[$filterId] = $params;
return $this;
} | [
"public",
"function",
"setFilter",
"(",
"$",
"filterId",
",",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"filterId",
",",
"$",
"this",
"->",
"_options",
"[",
"'filters'",
"]",
")",
")",
"{"... | Add custom filtering to WHERE clause
@param String $filterId Key in $this->_options['filters']
@param Array $params Filter values (by order of $this->_options['filters'][$filterId])
@return Garp_Browsebox $this | [
"Add",
"custom",
"filtering",
"to",
"WHERE",
"clause"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Browsebox.php#L217-L233 |
46,754 | grrr-amsterdam/garp3 | library/Garp/Browsebox.php | Garp_Browsebox._fetchContent | protected function _fetchContent($chunk) {
$model = $this->getModel();
$select = clone $this->getSelect();
$select->limit(
$this->_options['chunkSize'] * $this->_options['pageSize'],
(($chunk-1) * ($this->_options['pageSize'] * $this->_options['chunkSize']))
);
/**
* Filters may take over the fetching of results. This is neccessary for instance when you're filtering content on a HABTM related model. (in the same way Model Behaviors may return data in the beforeFetch callback)
*/
if ($content = $this->_fetchContentFromFilters($select)) {
return $content;
} else {
return $model->fetchAll($select);
}
} | php | protected function _fetchContent($chunk) {
$model = $this->getModel();
$select = clone $this->getSelect();
$select->limit(
$this->_options['chunkSize'] * $this->_options['pageSize'],
(($chunk-1) * ($this->_options['pageSize'] * $this->_options['chunkSize']))
);
/**
* Filters may take over the fetching of results. This is neccessary for instance when you're filtering content on a HABTM related model. (in the same way Model Behaviors may return data in the beforeFetch callback)
*/
if ($content = $this->_fetchContentFromFilters($select)) {
return $content;
} else {
return $model->fetchAll($select);
}
} | [
"protected",
"function",
"_fetchContent",
"(",
"$",
"chunk",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"getModel",
"(",
")",
";",
"$",
"select",
"=",
"clone",
"$",
"this",
"->",
"getSelect",
"(",
")",
";",
"$",
"select",
"->",
"limit",
"(",
"... | Fetch records matching the given conditions
@param Int $chunk The chunk index
@return Zend_Db_Table_Rowset | [
"Fetch",
"records",
"matching",
"the",
"given",
"conditions"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Browsebox.php#L241-L258 |
46,755 | grrr-amsterdam/garp3 | library/Garp/Browsebox.php | Garp_Browsebox._fetchContentFromFilters | protected function _fetchContentFromFilters(Zend_Db_Select $select) {
foreach ($this->_options['filters'] as $filter) {
try {
$content = $filter->fetchResults($select, $this);
return $content;
} catch (Garp_Browsebox_Filter_Exception_NotApplicable $e) {
// It's ok, this filter does not return content
}
}
return null;
} | php | protected function _fetchContentFromFilters(Zend_Db_Select $select) {
foreach ($this->_options['filters'] as $filter) {
try {
$content = $filter->fetchResults($select, $this);
return $content;
} catch (Garp_Browsebox_Filter_Exception_NotApplicable $e) {
// It's ok, this filter does not return content
}
}
return null;
} | [
"protected",
"function",
"_fetchContentFromFilters",
"(",
"Zend_Db_Select",
"$",
"select",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_options",
"[",
"'filters'",
"]",
"as",
"$",
"filter",
")",
"{",
"try",
"{",
"$",
"content",
"=",
"$",
"filter",
"->",
... | Allow filters to fetch browsebox content.
Note that there is no chaining. The first filter that returns content exits the loop.
@param Zend_Db_Select $select
@return Garp_Db_Table_Rowset | [
"Allow",
"filters",
"to",
"fetch",
"browsebox",
"content",
".",
"Note",
"that",
"there",
"is",
"no",
"chaining",
".",
"The",
"first",
"filter",
"that",
"returns",
"content",
"exits",
"the",
"loop",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Browsebox.php#L267-L277 |
46,756 | grrr-amsterdam/garp3 | library/Garp/Browsebox.php | Garp_Browsebox._fetchMaxChunks | protected function _fetchMaxChunks() {
$count = 'COUNT(*)';
$model = $this->getModel();
$select = clone $this->getSelect();
$select->reset(Zend_Db_Select::COLUMNS)
->reset(Zend_Db_Select::FROM)
->reset(Zend_Db_Select::ORDER)
->reset(Zend_Db_Select::GROUP)
;
$select->from($model->getName(), array('c' => $count));
if ($max = $this->_fetchMaxChunksFromFilters($select)) {
return $max;
} else {
$result = $model->fetchRow($select);
return $result->c;
}
} | php | protected function _fetchMaxChunks() {
$count = 'COUNT(*)';
$model = $this->getModel();
$select = clone $this->getSelect();
$select->reset(Zend_Db_Select::COLUMNS)
->reset(Zend_Db_Select::FROM)
->reset(Zend_Db_Select::ORDER)
->reset(Zend_Db_Select::GROUP)
;
$select->from($model->getName(), array('c' => $count));
if ($max = $this->_fetchMaxChunksFromFilters($select)) {
return $max;
} else {
$result = $model->fetchRow($select);
return $result->c;
}
} | [
"protected",
"function",
"_fetchMaxChunks",
"(",
")",
"{",
"$",
"count",
"=",
"'COUNT(*)'",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"getModel",
"(",
")",
";",
"$",
"select",
"=",
"clone",
"$",
"this",
"->",
"getSelect",
"(",
")",
";",
"$",
"select... | Determine what the max amount of chunks is for the given conditions.
@return Int | [
"Determine",
"what",
"the",
"max",
"amount",
"of",
"chunks",
"is",
"for",
"the",
"given",
"conditions",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Browsebox.php#L284-L301 |
46,757 | grrr-amsterdam/garp3 | library/Garp/Browsebox.php | Garp_Browsebox._fetchMaxChunksFromFilters | protected function _fetchMaxChunksFromFilters(Zend_Db_Select $select) {
foreach ($this->_options['filters'] as $filter) {
try {
$content = $filter->fetchMaxChunks($select, $this);
return $content;
} catch (Garp_Browsebox_Filter_Exception_NotApplicable $e) {
// It's ok, this filter does not return content
}
}
return null;
} | php | protected function _fetchMaxChunksFromFilters(Zend_Db_Select $select) {
foreach ($this->_options['filters'] as $filter) {
try {
$content = $filter->fetchMaxChunks($select, $this);
return $content;
} catch (Garp_Browsebox_Filter_Exception_NotApplicable $e) {
// It's ok, this filter does not return content
}
}
return null;
} | [
"protected",
"function",
"_fetchMaxChunksFromFilters",
"(",
"Zend_Db_Select",
"$",
"select",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_options",
"[",
"'filters'",
"]",
"as",
"$",
"filter",
")",
"{",
"try",
"{",
"$",
"content",
"=",
"$",
"filter",
"->"... | Fetch max chunks from filters.
Note that there is no chaining. The first filter that returns content exits the loop.
@param Zend_Db_Select $select
@return Garp_Db_Table_Rowset | [
"Fetch",
"max",
"chunks",
"from",
"filters",
".",
"Note",
"that",
"there",
"is",
"no",
"chaining",
".",
"The",
"first",
"filter",
"that",
"returns",
"content",
"exits",
"the",
"loop",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Browsebox.php#L310-L320 |
46,758 | grrr-amsterdam/garp3 | library/Garp/Browsebox.php | Garp_Browsebox.getModel | public function getModel() {
$model = new $this->_options['model']();
foreach ($this->_options['bindings'] as $binding => $bindingOptions) {
if (is_numeric($binding)) {
$model->bindModel($bindingOptions);
} elseif (is_string($binding)) {
$model->bindModel($binding, $bindingOptions);
}
}
return $model;
} | php | public function getModel() {
$model = new $this->_options['model']();
foreach ($this->_options['bindings'] as $binding => $bindingOptions) {
if (is_numeric($binding)) {
$model->bindModel($bindingOptions);
} elseif (is_string($binding)) {
$model->bindModel($binding, $bindingOptions);
}
}
return $model;
} | [
"public",
"function",
"getModel",
"(",
")",
"{",
"$",
"model",
"=",
"new",
"$",
"this",
"->",
"_options",
"[",
"'model'",
"]",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_options",
"[",
"'bindings'",
"]",
"as",
"$",
"binding",
"=>",
"$",
"b... | Retrieve a prepared model for this browsebox
@return Garp_Model | [
"Retrieve",
"a",
"prepared",
"model",
"for",
"this",
"browsebox"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Browsebox.php#L345-L355 |
46,759 | grrr-amsterdam/garp3 | library/Garp/Browsebox.php | Garp_Browsebox.getFilters | public function getFilters($encoded = true) {
$out = array();
foreach ($this->_filters as $filterId => $params) {
$out[] = $filterId.':'.implode(Garp_Browsebox::BROWSEBOX_QUERY_FILTER_PROP_SEPARATOR, $params);
}
$out = implode(Garp_Browsebox::BROWSEBOX_QUERY_FILTER_SEPARATOR, $out);
return base64_encode($out);
} | php | public function getFilters($encoded = true) {
$out = array();
foreach ($this->_filters as $filterId => $params) {
$out[] = $filterId.':'.implode(Garp_Browsebox::BROWSEBOX_QUERY_FILTER_PROP_SEPARATOR, $params);
}
$out = implode(Garp_Browsebox::BROWSEBOX_QUERY_FILTER_SEPARATOR, $out);
return base64_encode($out);
} | [
"public",
"function",
"getFilters",
"(",
"$",
"encoded",
"=",
"true",
")",
"{",
"$",
"out",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_filters",
"as",
"$",
"filterId",
"=>",
"$",
"params",
")",
"{",
"$",
"out",
"[",
"]",
"=... | Get encoded custom filters for passing along to BrowseboxController.
@param Boolean $encoded Pass FALSE if you wish to retrieve the raw array
@return String | [
"Get",
"encoded",
"custom",
"filters",
"for",
"passing",
"along",
"to",
"BrowseboxController",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Browsebox.php#L381-L388 |
46,760 | grrr-amsterdam/garp3 | library/Garp/Browsebox.php | Garp_Browsebox.getJavascriptOptions | public function getJavascriptOptions() {
$out = $this->_options['javascriptOptions'];
$out['options'] = base64_encode(serialize(array(
'pageSize' => $this->_options['pageSize'],
'viewPath' => $this->_options['viewPath'],
'filters' => $this->getFilters()
)));
return $out;
} | php | public function getJavascriptOptions() {
$out = $this->_options['javascriptOptions'];
$out['options'] = base64_encode(serialize(array(
'pageSize' => $this->_options['pageSize'],
'viewPath' => $this->_options['viewPath'],
'filters' => $this->getFilters()
)));
return $out;
} | [
"public",
"function",
"getJavascriptOptions",
"(",
")",
"{",
"$",
"out",
"=",
"$",
"this",
"->",
"_options",
"[",
"'javascriptOptions'",
"]",
";",
"$",
"out",
"[",
"'options'",
"]",
"=",
"base64_encode",
"(",
"serialize",
"(",
"array",
"(",
"'pageSize'",
"... | Return config options relevant for the Javascript Browsebox implementation.
@return Garp_Util_Configuration | [
"Return",
"config",
"options",
"relevant",
"for",
"the",
"Javascript",
"Browsebox",
"implementation",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Browsebox.php#L395-L403 |
46,761 | grrr-amsterdam/garp3 | library/Garp/Browsebox.php | Garp_Browsebox.getPrevUrl | public function getPrevUrl() {
if ($this->_chunk == 1) {
return $this->_options['cycle'] ? $this->createStateUrl(ceil($this->_max / $this->_options['pageSize'])) : false;
}
return $this->createStateUrl($this->_chunk-1);
} | php | public function getPrevUrl() {
if ($this->_chunk == 1) {
return $this->_options['cycle'] ? $this->createStateUrl(ceil($this->_max / $this->_options['pageSize'])) : false;
}
return $this->createStateUrl($this->_chunk-1);
} | [
"public",
"function",
"getPrevUrl",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_chunk",
"==",
"1",
")",
"{",
"return",
"$",
"this",
"->",
"_options",
"[",
"'cycle'",
"]",
"?",
"$",
"this",
"->",
"createStateUrl",
"(",
"ceil",
"(",
"$",
"this",
"... | Return the URL of the previous browsebox page.
@return Int|Boolean False if this is the first page | [
"Return",
"the",
"URL",
"of",
"the",
"previous",
"browsebox",
"page",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Browsebox.php#L410-L415 |
46,762 | grrr-amsterdam/garp3 | library/Garp/Browsebox.php | Garp_Browsebox.getNextUrl | public function getNextUrl() {
$lastChunk = ceil($this->_max / $this->_options['pageSize']);
if ($this->_chunk == $lastChunk) {
return $this->_options['cycle'] ? $this->createStateUrl(1) : false;
}
return $this->createStateUrl($this->_chunk+1);
} | php | public function getNextUrl() {
$lastChunk = ceil($this->_max / $this->_options['pageSize']);
if ($this->_chunk == $lastChunk) {
return $this->_options['cycle'] ? $this->createStateUrl(1) : false;
}
return $this->createStateUrl($this->_chunk+1);
} | [
"public",
"function",
"getNextUrl",
"(",
")",
"{",
"$",
"lastChunk",
"=",
"ceil",
"(",
"$",
"this",
"->",
"_max",
"/",
"$",
"this",
"->",
"_options",
"[",
"'pageSize'",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_chunk",
"==",
"$",
"lastChunk",
... | Return the URL of the next browsebox page.
@return Int|Boolean False if this is the last page | [
"Return",
"the",
"URL",
"of",
"the",
"next",
"browsebox",
"page",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Browsebox.php#L422-L428 |
46,763 | grrr-amsterdam/garp3 | library/Garp/Browsebox.php | Garp_Browsebox._getCurrentStateFromRequest | protected function _getCurrentStateFromRequest() {
$here = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
$queryString = parse_url($here, PHP_URL_QUERY);
parse_str($queryString, $queryComponents);
if (!empty($queryComponents[Garp_Browsebox::BROWSEBOX_QUERY_IDENTIFIER][$this->getId()])) {
$chunk = $queryComponents[Garp_Browsebox::BROWSEBOX_QUERY_IDENTIFIER][$this->getId()];
return $chunk;
}
return null;
} | php | protected function _getCurrentStateFromRequest() {
$here = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
$queryString = parse_url($here, PHP_URL_QUERY);
parse_str($queryString, $queryComponents);
if (!empty($queryComponents[Garp_Browsebox::BROWSEBOX_QUERY_IDENTIFIER][$this->getId()])) {
$chunk = $queryComponents[Garp_Browsebox::BROWSEBOX_QUERY_IDENTIFIER][$this->getId()];
return $chunk;
}
return null;
} | [
"protected",
"function",
"_getCurrentStateFromRequest",
"(",
")",
"{",
"$",
"here",
"=",
"Zend_Controller_Front",
"::",
"getInstance",
"(",
")",
"->",
"getRequest",
"(",
")",
"->",
"getRequestUri",
"(",
")",
";",
"$",
"queryString",
"=",
"parse_url",
"(",
"$",... | Find out wether the current browsebox has a state available in the current URL.
@see self::createStateUrl() for an explanation on what the URL format looks like.
@return Int The requested chunk if found, or NULL. | [
"Find",
"out",
"wether",
"the",
"current",
"browsebox",
"has",
"a",
"state",
"available",
"in",
"the",
"current",
"URL",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Browsebox.php#L436-L445 |
46,764 | grrr-amsterdam/garp3 | library/Garp/Model/Db/BindingManager.php | Garp_Model_Db_BindingManager.storeBinding | public static function storeBinding($subjectModel, $alias, Garp_Util_Configuration $options = null) {
static::$_bindings[$subjectModel][$alias] = self::_setRelationDefaultOptions($alias, $options);
} | php | public static function storeBinding($subjectModel, $alias, Garp_Util_Configuration $options = null) {
static::$_bindings[$subjectModel][$alias] = self::_setRelationDefaultOptions($alias, $options);
} | [
"public",
"static",
"function",
"storeBinding",
"(",
"$",
"subjectModel",
",",
"$",
"alias",
",",
"Garp_Util_Configuration",
"$",
"options",
"=",
"null",
")",
"{",
"static",
"::",
"$",
"_bindings",
"[",
"$",
"subjectModel",
"]",
"[",
"$",
"alias",
"]",
"="... | Store a binding between models.
@param String $subjectModel
@param String $alias
@param Garp_Util_Configuration $options
@return Void | [
"Store",
"a",
"binding",
"between",
"models",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db/BindingManager.php#L39-L41 |
46,765 | grrr-amsterdam/garp3 | library/Garp/Model/Db/BindingManager.php | Garp_Model_Db_BindingManager.removeBinding | public static function removeBinding($subjectModel, $alias = false) {
if ($alias) {
unset(static::$_bindings[$subjectModel][$alias]);
} else {
static::$_bindings[$subjectModel] = array();
}
self::resetRecursion($subjectModel);
} | php | public static function removeBinding($subjectModel, $alias = false) {
if ($alias) {
unset(static::$_bindings[$subjectModel][$alias]);
} else {
static::$_bindings[$subjectModel] = array();
}
self::resetRecursion($subjectModel);
} | [
"public",
"static",
"function",
"removeBinding",
"(",
"$",
"subjectModel",
",",
"$",
"alias",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"alias",
")",
"{",
"unset",
"(",
"static",
"::",
"$",
"_bindings",
"[",
"$",
"subjectModel",
"]",
"[",
"$",
"alias",
... | Remove a binding between models.
@param String $subjectModel
@param String $alias
@return Void | [
"Remove",
"a",
"binding",
"between",
"models",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db/BindingManager.php#L49-L56 |
46,766 | grrr-amsterdam/garp3 | library/Garp/Model/Db/BindingManager.php | Garp_Model_Db_BindingManager.getBindings | public static function getBindings($subjectModel = null) {
if (is_null($subjectModel)) {
return static::$_bindings;
}
return !empty(static::$_bindings[$subjectModel]) ? static::$_bindings[$subjectModel] : array();
} | php | public static function getBindings($subjectModel = null) {
if (is_null($subjectModel)) {
return static::$_bindings;
}
return !empty(static::$_bindings[$subjectModel]) ? static::$_bindings[$subjectModel] : array();
} | [
"public",
"static",
"function",
"getBindings",
"(",
"$",
"subjectModel",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"subjectModel",
")",
")",
"{",
"return",
"static",
"::",
"$",
"_bindings",
";",
"}",
"return",
"!",
"empty",
"(",
"static",
... | Get all bindings to a certain model
@param String $subjectModel
@return Array | [
"Get",
"all",
"bindings",
"to",
"a",
"certain",
"model"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db/BindingManager.php#L72-L77 |
46,767 | grrr-amsterdam/garp3 | library/Garp/Model/Db/BindingManager.php | Garp_Model_Db_BindingManager.getRecursion | public static function getRecursion($subjectModel, $alias) {
$key = self::getStoreKey($subjectModel, $alias);
return !array_key_exists($key, static::$_recursion) ? 0 : static::$_recursion[$key];
} | php | public static function getRecursion($subjectModel, $alias) {
$key = self::getStoreKey($subjectModel, $alias);
return !array_key_exists($key, static::$_recursion) ? 0 : static::$_recursion[$key];
} | [
"public",
"static",
"function",
"getRecursion",
"(",
"$",
"subjectModel",
",",
"$",
"alias",
")",
"{",
"$",
"key",
"=",
"self",
"::",
"getStoreKey",
"(",
"$",
"subjectModel",
",",
"$",
"alias",
")",
";",
"return",
"!",
"array_key_exists",
"(",
"$",
"key"... | Return recursion level for two models
@param String $subjectModel
@param String $alias
@return Int | [
"Return",
"recursion",
"level",
"for",
"two",
"models"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db/BindingManager.php#L105-L108 |
46,768 | grrr-amsterdam/garp3 | library/Garp/Model/Db/BindingManager.php | Garp_Model_Db_BindingManager.getStoreKey | public static function getStoreKey($subjectModel, $alias) {
if ($subjectModel == $alias) {
$subjectModel .= '1';
$alias .= '2';
}
$models = array($subjectModel, $alias);
sort($models);
$key = implode('.', $models);
return $key;
} | php | public static function getStoreKey($subjectModel, $alias) {
if ($subjectModel == $alias) {
$subjectModel .= '1';
$alias .= '2';
}
$models = array($subjectModel, $alias);
sort($models);
$key = implode('.', $models);
return $key;
} | [
"public",
"static",
"function",
"getStoreKey",
"(",
"$",
"subjectModel",
",",
"$",
"alias",
")",
"{",
"if",
"(",
"$",
"subjectModel",
"==",
"$",
"alias",
")",
"{",
"$",
"subjectModel",
".=",
"'1'",
";",
"$",
"alias",
".=",
"'2'",
";",
"}",
"$",
"mode... | Create a key by which a binding gets stored.
@param String $subjectModel
@param String $alias
@return String | [
"Create",
"a",
"key",
"by",
"which",
"a",
"binding",
"gets",
"stored",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db/BindingManager.php#L174-L183 |
46,769 | grrr-amsterdam/garp3 | library/Garp/Cli/Command/Models.php | Garp_Cli_Command_Models.insert | public function insert($args) {
if (empty($args)) {
Garp_Cli::errorOut('Please provide a model');
return false;
}
$className = "Model_{$args[0]}";
$model = new $className();
$fields = $model->getConfiguration('fields');
$fields = array_filter($fields, not(propertyEquals('name', 'id')));
$mode = $this->_getInsertionMode();
if ($mode === 'g') {
$newData = $this->_createGibberish($fields);
} else {
$newData = array_reduce(
$fields,
function ($acc, $cur) {
$acc[$cur['name']] = Garp_Cli::prompt($cur['name']) ?: null;
return $acc;
},
array()
);
}
$id = $model->insert($newData);
Garp_Cli::lineOut("Record created: #{$id}");
return true;
} | php | public function insert($args) {
if (empty($args)) {
Garp_Cli::errorOut('Please provide a model');
return false;
}
$className = "Model_{$args[0]}";
$model = new $className();
$fields = $model->getConfiguration('fields');
$fields = array_filter($fields, not(propertyEquals('name', 'id')));
$mode = $this->_getInsertionMode();
if ($mode === 'g') {
$newData = $this->_createGibberish($fields);
} else {
$newData = array_reduce(
$fields,
function ($acc, $cur) {
$acc[$cur['name']] = Garp_Cli::prompt($cur['name']) ?: null;
return $acc;
},
array()
);
}
$id = $model->insert($newData);
Garp_Cli::lineOut("Record created: #{$id}");
return true;
} | [
"public",
"function",
"insert",
"(",
"$",
"args",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"args",
")",
")",
"{",
"Garp_Cli",
"::",
"errorOut",
"(",
"'Please provide a model'",
")",
";",
"return",
"false",
";",
"}",
"$",
"className",
"=",
"\"Model_{$args[... | Interactively insert a new record
@param array $args
@return bool | [
"Interactively",
"insert",
"a",
"new",
"record"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Models.php#L17-L45 |
46,770 | grrr-amsterdam/garp3 | library/Garp/Cli/Command/Models.php | Garp_Cli_Command_Models.migrateGarpModels | public function migrateGarpModels() {
$modelDir = APPLICATION_PATH . '/modules/default/Model';
$dirIterator = new DirectoryIterator($modelDir);
foreach ($dirIterator as $finfo) {
if ($finfo->isDot()) {
continue;
}
$this->_modifyModelFile($finfo);
}
$this->_updateCropTemplateRefs();
return true;
} | php | public function migrateGarpModels() {
$modelDir = APPLICATION_PATH . '/modules/default/Model';
$dirIterator = new DirectoryIterator($modelDir);
foreach ($dirIterator as $finfo) {
if ($finfo->isDot()) {
continue;
}
$this->_modifyModelFile($finfo);
}
$this->_updateCropTemplateRefs();
return true;
} | [
"public",
"function",
"migrateGarpModels",
"(",
")",
"{",
"$",
"modelDir",
"=",
"APPLICATION_PATH",
".",
"'/modules/default/Model'",
";",
"$",
"dirIterator",
"=",
"new",
"DirectoryIterator",
"(",
"$",
"modelDir",
")",
";",
"foreach",
"(",
"$",
"dirIterator",
"as... | Garp models have moved from the G_Model namespace to the Garp_Model_Db_ namespace.
This command migrates extended models to the new namespace.
@return bool | [
"Garp",
"models",
"have",
"moved",
"from",
"the",
"G_Model",
"namespace",
"to",
"the",
"Garp_Model_Db_",
"namespace",
".",
"This",
"command",
"migrates",
"extended",
"models",
"to",
"the",
"new",
"namespace",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Models.php#L53-L65 |
46,771 | grrr-amsterdam/garp3 | library/Garp/Cli/Command/Models.php | Garp_Cli_Command_Models._updateCropTemplateRefs | protected function _updateCropTemplateRefs() {
$iniPaths = ['/configs/content.ini', '/configs/acl.ini'];
foreach ($iniPaths as $i => $path) {
$content = file_get_contents(APPLICATION_PATH . $path);
$content = str_replace('G_Model_CropTemplate', 'Garp_Model_Db_CropTemplate', $content);
file_put_contents(APPLICATION_PATH . $path, $content);
}
} | php | protected function _updateCropTemplateRefs() {
$iniPaths = ['/configs/content.ini', '/configs/acl.ini'];
foreach ($iniPaths as $i => $path) {
$content = file_get_contents(APPLICATION_PATH . $path);
$content = str_replace('G_Model_CropTemplate', 'Garp_Model_Db_CropTemplate', $content);
file_put_contents(APPLICATION_PATH . $path, $content);
}
} | [
"protected",
"function",
"_updateCropTemplateRefs",
"(",
")",
"{",
"$",
"iniPaths",
"=",
"[",
"'/configs/content.ini'",
",",
"'/configs/acl.ini'",
"]",
";",
"foreach",
"(",
"$",
"iniPaths",
"as",
"$",
"i",
"=>",
"$",
"path",
")",
"{",
"$",
"content",
"=",
... | Change references to G_Model_CropTemplate
@return void | [
"Change",
"references",
"to",
"G_Model_CropTemplate"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Models.php#L72-L79 |
46,772 | grrr-amsterdam/garp3 | library/Garp/Gumball.php | Garp_Gumball.make | public function make() {
if (!$this->createTargetDirectory()) {
throw new Garp_Gumball_Exception_CannotWriteTargetDirectory();
}
if (!$this->copySourceFilesToTargetDirectory()) {
throw new Garp_Gumball_Exception_CannotCopySourceFiles();
}
// Create database dump of given environment
if (!$this->createDataDump()) {
throw new Garp_Gumball_Exception_DatadumpFailed();
}
// Create VERSION file
$this->addVersionFile();
// Create Under Construction index.html in public that's used when unpacking the gumball
$this->addUnderConstructionLock();
// Create config file which can be read @ restore time
$this->addSettingsFile();
// Zip target folder
$this->createZipArchive();
// Remove target folder
$this->_removeTargetDirectory();
} | php | public function make() {
if (!$this->createTargetDirectory()) {
throw new Garp_Gumball_Exception_CannotWriteTargetDirectory();
}
if (!$this->copySourceFilesToTargetDirectory()) {
throw new Garp_Gumball_Exception_CannotCopySourceFiles();
}
// Create database dump of given environment
if (!$this->createDataDump()) {
throw new Garp_Gumball_Exception_DatadumpFailed();
}
// Create VERSION file
$this->addVersionFile();
// Create Under Construction index.html in public that's used when unpacking the gumball
$this->addUnderConstructionLock();
// Create config file which can be read @ restore time
$this->addSettingsFile();
// Zip target folder
$this->createZipArchive();
// Remove target folder
$this->_removeTargetDirectory();
} | [
"public",
"function",
"make",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"createTargetDirectory",
"(",
")",
")",
"{",
"throw",
"new",
"Garp_Gumball_Exception_CannotWriteTargetDirectory",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"copySo... | Kick off the build
@return void | [
"Kick",
"off",
"the",
"build"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Gumball.php#L60-L88 |
46,773 | grrr-amsterdam/garp3 | library/Garp/Gumball.php | Garp_Gumball.addSettingsFile | public function addSettingsFile() {
$config = new Zend_Config(array(), true);
$config->gumball = array();
$config->gumball->sourceDbEnvironment = $this->_dbEnv;
$writer = new Zend_Config_Writer_Ini(
array(
'config' => $config,
'filename' => $this->_getTargetDirectoryPath() . '/application/configs/gumball.ini'
)
);
$writer->setRenderWithoutSections();
$writer->write();
} | php | public function addSettingsFile() {
$config = new Zend_Config(array(), true);
$config->gumball = array();
$config->gumball->sourceDbEnvironment = $this->_dbEnv;
$writer = new Zend_Config_Writer_Ini(
array(
'config' => $config,
'filename' => $this->_getTargetDirectoryPath() . '/application/configs/gumball.ini'
)
);
$writer->setRenderWithoutSections();
$writer->write();
} | [
"public",
"function",
"addSettingsFile",
"(",
")",
"{",
"$",
"config",
"=",
"new",
"Zend_Config",
"(",
"array",
"(",
")",
",",
"true",
")",
";",
"$",
"config",
"->",
"gumball",
"=",
"array",
"(",
")",
";",
"$",
"config",
"->",
"gumball",
"->",
"sourc... | For now only contains the database source environment, but can be used to add more
configuration that's needed at restore time.
@return void | [
"For",
"now",
"only",
"contains",
"the",
"database",
"source",
"environment",
"but",
"can",
"be",
"used",
"to",
"add",
"more",
"configuration",
"that",
"s",
"needed",
"at",
"restore",
"time",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Gumball.php#L154-L167 |
46,774 | grrr-amsterdam/garp3 | library/Garp/Gumball.php | Garp_Gumball._getGumballConfig | protected function _getGumballConfig($configKey) {
if (!$this->_gumballConfig) {
$this->_gumballConfig = new Garp_Config_Ini(APPLICATION_PATH . '/configs/gumball.ini');
}
return $this->_gumballConfig->gumball->{$configKey};
} | php | protected function _getGumballConfig($configKey) {
if (!$this->_gumballConfig) {
$this->_gumballConfig = new Garp_Config_Ini(APPLICATION_PATH . '/configs/gumball.ini');
}
return $this->_gumballConfig->gumball->{$configKey};
} | [
"protected",
"function",
"_getGumballConfig",
"(",
"$",
"configKey",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_gumballConfig",
")",
"{",
"$",
"this",
"->",
"_gumballConfig",
"=",
"new",
"Garp_Config_Ini",
"(",
"APPLICATION_PATH",
".",
"'/configs/gumball.ini... | Read config values from packaged config file
@param string $configKey
@return string | [
"Read",
"config",
"values",
"from",
"packaged",
"config",
"file"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Gumball.php#L322-L327 |
46,775 | grrr-amsterdam/garp3 | library/Garp/Service/Google/Maps/Response.php | Garp_Service_Google_Maps_Response._isValidResponse | protected function _isValidResponse(array $response) {
return (
array_key_exists('results', $response) &&
array_key_exists(0, $response['results']) &&
array_key_exists('address_components', $response['results'][0]) &&
array_key_exists('geometry', $response['results'][0])
);
} | php | protected function _isValidResponse(array $response) {
return (
array_key_exists('results', $response) &&
array_key_exists(0, $response['results']) &&
array_key_exists('address_components', $response['results'][0]) &&
array_key_exists('geometry', $response['results'][0])
);
} | [
"protected",
"function",
"_isValidResponse",
"(",
"array",
"$",
"response",
")",
"{",
"return",
"(",
"array_key_exists",
"(",
"'results'",
",",
"$",
"response",
")",
"&&",
"array_key_exists",
"(",
"0",
",",
"$",
"response",
"[",
"'results'",
"]",
")",
"&&",
... | Validates Google API response.
@param Array $response
@return Void | [
"Validates",
"Google",
"API",
"response",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Service/Google/Maps/Response.php#L41-L48 |
46,776 | grrr-amsterdam/garp3 | library/Garp/Config/Ini.php | Garp_Config_Ini.getCached | public static function getCached($filename, $environment = null) {
$environment = $environment ?: APPLICATION_ENV;
$cache = Zend_Registry::get('CacheFrontend');
$key = preg_replace('/[^0-9a-zA-Z_]/', '_', basename($filename));
$key .= '_' . $environment;
// Check the store first to see if the ini file is already loaded within this session
if (array_key_exists($key, static::$_store)) {
return static::$_store[$key];
}
$config = $cache->load('Ini_Config_' . $key);
if (!$config) {
$config = new Garp_Config_Ini($filename, $environment);
$cache->save($config, 'Ini_Config_' . $key);
}
static::$_store[$key] = $config;
return $config;
} | php | public static function getCached($filename, $environment = null) {
$environment = $environment ?: APPLICATION_ENV;
$cache = Zend_Registry::get('CacheFrontend');
$key = preg_replace('/[^0-9a-zA-Z_]/', '_', basename($filename));
$key .= '_' . $environment;
// Check the store first to see if the ini file is already loaded within this session
if (array_key_exists($key, static::$_store)) {
return static::$_store[$key];
}
$config = $cache->load('Ini_Config_' . $key);
if (!$config) {
$config = new Garp_Config_Ini($filename, $environment);
$cache->save($config, 'Ini_Config_' . $key);
}
static::$_store[$key] = $config;
return $config;
} | [
"public",
"static",
"function",
"getCached",
"(",
"$",
"filename",
",",
"$",
"environment",
"=",
"null",
")",
"{",
"$",
"environment",
"=",
"$",
"environment",
"?",
":",
"APPLICATION_ENV",
";",
"$",
"cache",
"=",
"Zend_Registry",
"::",
"get",
"(",
"'CacheF... | Receive a config ini file from cache
@param string $filename
@param string $environment
@return Garp_Config_Ini | [
"Receive",
"a",
"config",
"ini",
"file",
"from",
"cache"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Config/Ini.php#L28-L46 |
46,777 | grrr-amsterdam/garp3 | library/Garp/Config/Ini.php | Garp_Config_Ini._parseIniFile | protected function _parseIniFile($filename) {
if ($filename instanceof Garp_Config_Ini_String) {
$ini = $filename->getValue();
return parse_ini_string($ini);
}
return parent::_parseIniFile($filename);
} | php | protected function _parseIniFile($filename) {
if ($filename instanceof Garp_Config_Ini_String) {
$ini = $filename->getValue();
return parse_ini_string($ini);
}
return parent::_parseIniFile($filename);
} | [
"protected",
"function",
"_parseIniFile",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"$",
"filename",
"instanceof",
"Garp_Config_Ini_String",
")",
"{",
"$",
"ini",
"=",
"$",
"filename",
"->",
"getValue",
"(",
")",
";",
"return",
"parse_ini_string",
"(",
"$",... | Hacked to allow ini strings as well as ini files.
@param string|Garp_Config_Ini_String $filename If this is a Garp_Config_Ini_String, an ini
string is assumed instead of an ini file.
@return array | [
"Hacked",
"to",
"allow",
"ini",
"strings",
"as",
"well",
"as",
"ini",
"files",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Config/Ini.php#L83-L89 |
46,778 | grrr-amsterdam/garp3 | library/Garp/Config/Ini.php | Garp_Config_Ini.fromString | public static function fromString($iniString, $section = null, $options = false) {
return new Garp_Config_Ini(new Garp_Config_Ini_String($iniString), $section, $options);
} | php | public static function fromString($iniString, $section = null, $options = false) {
return new Garp_Config_Ini(new Garp_Config_Ini_String($iniString), $section, $options);
} | [
"public",
"static",
"function",
"fromString",
"(",
"$",
"iniString",
",",
"$",
"section",
"=",
"null",
",",
"$",
"options",
"=",
"false",
")",
"{",
"return",
"new",
"Garp_Config_Ini",
"(",
"new",
"Garp_Config_Ini_String",
"(",
"$",
"iniString",
")",
",",
"... | Take an ini string to populate the config object.
@param string $iniString
@param string $section
@param array $options
@return Garp_Config_Ini
@see Zend_Config_Ini::__construct for an explanation of the second and third arguments. | [
"Take",
"an",
"ini",
"string",
"to",
"populate",
"the",
"config",
"object",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Config/Ini.php#L100-L102 |
46,779 | grrr-amsterdam/garp3 | application/modules/g/views/helpers/Script.php | G_View_Helper_Script.minifiedSrc | public function minifiedSrc($identifier, $render = false) {
$config = Zend_Registry::get('config');
if (empty($config->assets->js->{$identifier})) {
throw new Garp_Exception(
"JS configuration for identifier {$identifier} not found. " .
"Please configure assets.js.{$identifier}"
);
}
$jsRoot = rtrim($config->assets->js->basePath ?: '/js', '/') . '/';
$config = $config->assets->js->{$identifier};
if (!isset($config->disabled) || !$config->disabled) {
// If minification is not disabled (for instance in a development environment),
// return the path to the minified file.
return $this->src($jsRoot . $config->filename, $render);
} else {
// Otherwise, return all the script tags for all the individual source files
if (!isset($config->sourcefiles)) {
return '';
}
$out = '';
foreach ($config->sourcefiles as $sourceFile) {
$response = $this->src($jsRoot . $sourceFile, $render);
if ($render) {
$out .= $response;
}
}
if ($render) {
return $out;
}
return $this;
}
} | php | public function minifiedSrc($identifier, $render = false) {
$config = Zend_Registry::get('config');
if (empty($config->assets->js->{$identifier})) {
throw new Garp_Exception(
"JS configuration for identifier {$identifier} not found. " .
"Please configure assets.js.{$identifier}"
);
}
$jsRoot = rtrim($config->assets->js->basePath ?: '/js', '/') . '/';
$config = $config->assets->js->{$identifier};
if (!isset($config->disabled) || !$config->disabled) {
// If minification is not disabled (for instance in a development environment),
// return the path to the minified file.
return $this->src($jsRoot . $config->filename, $render);
} else {
// Otherwise, return all the script tags for all the individual source files
if (!isset($config->sourcefiles)) {
return '';
}
$out = '';
foreach ($config->sourcefiles as $sourceFile) {
$response = $this->src($jsRoot . $sourceFile, $render);
if ($render) {
$out .= $response;
}
}
if ($render) {
return $out;
}
return $this;
}
} | [
"public",
"function",
"minifiedSrc",
"(",
"$",
"identifier",
",",
"$",
"render",
"=",
"false",
")",
"{",
"$",
"config",
"=",
"Zend_Registry",
"::",
"get",
"(",
"'config'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"config",
"->",
"assets",
"->",
"js",
... | Render a script tag containing a minified script reference.
@param String $identifier Needs to be in the config under assets.js.$identifier
@param String $render Wether to render directly
@return String Script tag to the right file.
NOTE: this method does not check for the existence of said minified file. | [
"Render",
"a",
"script",
"tag",
"containing",
"a",
"minified",
"script",
"reference",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Script.php#L50-L81 |
46,780 | grrr-amsterdam/garp3 | application/modules/g/views/helpers/Script.php | G_View_Helper_Script.block | public function block($code, $render = false, array $attrs = array()) {
return $this->_storeOrRender(
'block',
array(
'value' => $code,
'render' => $render,
'attrs' => $attrs
)
);
} | php | public function block($code, $render = false, array $attrs = array()) {
return $this->_storeOrRender(
'block',
array(
'value' => $code,
'render' => $render,
'attrs' => $attrs
)
);
} | [
"public",
"function",
"block",
"(",
"$",
"code",
",",
"$",
"render",
"=",
"false",
",",
"array",
"$",
"attrs",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_storeOrRender",
"(",
"'block'",
",",
"array",
"(",
"'value'",
"=>",
"$",
... | Push a script to the stack. It will be rendered later.
@param String $code Javascript source code
@param Boolean $render Wether to render directly
@param Array $attrs HTML attributes
@return Mixed | [
"Push",
"a",
"script",
"to",
"the",
"stack",
".",
"It",
"will",
"be",
"rendered",
"later",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Script.php#L91-L100 |
46,781 | grrr-amsterdam/garp3 | application/modules/g/views/helpers/Script.php | G_View_Helper_Script.src | public function src($url, $render = false, array $attrs = array()) {
return $this->_storeOrRender(
'src',
array(
'value' => $url,
'render' => $render,
'attrs' => $attrs
)
);
} | php | public function src($url, $render = false, array $attrs = array()) {
return $this->_storeOrRender(
'src',
array(
'value' => $url,
'render' => $render,
'attrs' => $attrs
)
);
} | [
"public",
"function",
"src",
"(",
"$",
"url",
",",
"$",
"render",
"=",
"false",
",",
"array",
"$",
"attrs",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_storeOrRender",
"(",
"'src'",
",",
"array",
"(",
"'value'",
"=>",
"$",
"url... | Push a URL to a script to the stack. It will be rendered later.
@param String $url Url to Javascript file
@param Boolean $render Wether to render directly
@param Array $attrs HTML attributes
@return Mixed | [
"Push",
"a",
"URL",
"to",
"a",
"script",
"to",
"the",
"stack",
".",
"It",
"will",
"be",
"rendered",
"later",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Script.php#L110-L119 |
46,782 | grrr-amsterdam/garp3 | application/modules/g/views/helpers/Script.php | G_View_Helper_Script.render | public function render() {
$string = '';
foreach (static::$_scripts as $script) {
$method = '_render' . ucfirst($script['type']);
$string .= $this->{$method}($script['value'], $script['attrs']);
}
return $string;
} | php | public function render() {
$string = '';
foreach (static::$_scripts as $script) {
$method = '_render' . ucfirst($script['type']);
$string .= $this->{$method}($script['value'], $script['attrs']);
}
return $string;
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"string",
"=",
"''",
";",
"foreach",
"(",
"static",
"::",
"$",
"_scripts",
"as",
"$",
"script",
")",
"{",
"$",
"method",
"=",
"'_render'",
".",
"ucfirst",
"(",
"$",
"script",
"[",
"'type'",
"]",
"... | Render everything on the stack
@return String | [
"Render",
"everything",
"on",
"the",
"stack"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Script.php#L126-L133 |
46,783 | grrr-amsterdam/garp3 | application/modules/g/views/helpers/Script.php | G_View_Helper_Script._renderBlock | protected function _renderBlock($code, array $attrs = array()) {
$attrs = $this->_htmlAttribs($attrs);
$html = "<script{$attrs}>\n\t%s\n</script>";
return sprintf($html, $code);
} | php | protected function _renderBlock($code, array $attrs = array()) {
$attrs = $this->_htmlAttribs($attrs);
$html = "<script{$attrs}>\n\t%s\n</script>";
return sprintf($html, $code);
} | [
"protected",
"function",
"_renderBlock",
"(",
"$",
"code",
",",
"array",
"$",
"attrs",
"=",
"array",
"(",
")",
")",
"{",
"$",
"attrs",
"=",
"$",
"this",
"->",
"_htmlAttribs",
"(",
"$",
"attrs",
")",
";",
"$",
"html",
"=",
"\"<script{$attrs}>\\n\\t%s\\n</... | Render a Javascript.
@param String $code If not given, everything in $this->_scripts will be rendered.
@param Array $attrs HTML attributes for the <script> tag
@return String | [
"Render",
"a",
"Javascript",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Script.php#L162-L166 |
46,784 | grrr-amsterdam/garp3 | application/modules/g/views/helpers/Script.php | G_View_Helper_Script._renderSrc | protected function _renderSrc($url, array $attrs = array()) {
if ('http://' !== substr($url, 0, 7)
&& 'https://' !== substr($url, 0, 8)
&& '//' !== substr($url, 0, 2)
) {
$url = $this->view->assetUrl($url);
}
$attrs['src'] = $url;
$attrs = $this->_htmlAttribs($attrs);
return "<script{$attrs}></script>";
} | php | protected function _renderSrc($url, array $attrs = array()) {
if ('http://' !== substr($url, 0, 7)
&& 'https://' !== substr($url, 0, 8)
&& '//' !== substr($url, 0, 2)
) {
$url = $this->view->assetUrl($url);
}
$attrs['src'] = $url;
$attrs = $this->_htmlAttribs($attrs);
return "<script{$attrs}></script>";
} | [
"protected",
"function",
"_renderSrc",
"(",
"$",
"url",
",",
"array",
"$",
"attrs",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"'http://'",
"!==",
"substr",
"(",
"$",
"url",
",",
"0",
",",
"7",
")",
"&&",
"'https://'",
"!==",
"substr",
"(",
"$",
... | Render Javascript tags with a "src" attribute.
@param String $url If not given, everything in $this->_urls will be rendered.
@param Array $attrs HTML attributes for the <script> tag
@return String | [
"Render",
"Javascript",
"tags",
"with",
"a",
"src",
"attribute",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Script.php#L175-L185 |
46,785 | grrr-amsterdam/garp3 | library/Garp/Service/Elasticsearch/Request.php | Garp_Service_Elasticsearch_Request.execute | public function execute() {
$method = constant('Zend_Http_Client::' . $this->getMethod());
$client = $this->getClient();
$url = $this->getUrl();
$data = $this->getData();
$client
->setMethod($method)
->setUri($url)
;
if ($data) {
$client->setRawData($data);
}
$response = $client->request();
return new Garp_Service_Elasticsearch_Response($response);
} | php | public function execute() {
$method = constant('Zend_Http_Client::' . $this->getMethod());
$client = $this->getClient();
$url = $this->getUrl();
$data = $this->getData();
$client
->setMethod($method)
->setUri($url)
;
if ($data) {
$client->setRawData($data);
}
$response = $client->request();
return new Garp_Service_Elasticsearch_Response($response);
} | [
"public",
"function",
"execute",
"(",
")",
"{",
"$",
"method",
"=",
"constant",
"(",
"'Zend_Http_Client::'",
".",
"$",
"this",
"->",
"getMethod",
"(",
")",
")",
";",
"$",
"client",
"=",
"$",
"this",
"->",
"getClient",
"(",
")",
";",
"$",
"url",
"=",
... | Executes the request and returns a response.
@return Garp_Service_Elasticsearch_Response | [
"Executes",
"the",
"request",
"and",
"returns",
"a",
"response",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Service/Elasticsearch/Request.php#L70-L88 |
46,786 | grrr-amsterdam/garp3 | library/Garp/Service/Elasticsearch/Request.php | Garp_Service_Elasticsearch_Request.getUrl | public function getUrl() {
$config = $this->getConfig();
$baseUrl = $this->isReadOnly()
? $config->getReadBaseUrl()
: $config->getWriteBaseUrl()
;
$index = $config->getIndex();
$path = $this->getPath();
$url = $baseUrl . '/' . $index . $path;
return $url;
} | php | public function getUrl() {
$config = $this->getConfig();
$baseUrl = $this->isReadOnly()
? $config->getReadBaseUrl()
: $config->getWriteBaseUrl()
;
$index = $config->getIndex();
$path = $this->getPath();
$url = $baseUrl . '/' . $index . $path;
return $url;
} | [
"public",
"function",
"getUrl",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
";",
"$",
"baseUrl",
"=",
"$",
"this",
"->",
"isReadOnly",
"(",
")",
"?",
"$",
"config",
"->",
"getReadBaseUrl",
"(",
")",
":",
"$",
"confi... | Creates a full url out of a relative path.
@param String $path A relative path without index, preceded by a slash. | [
"Creates",
"a",
"full",
"url",
"out",
"of",
"a",
"relative",
"path",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Service/Elasticsearch/Request.php#L94-L106 |
46,787 | grrr-amsterdam/garp3 | library/Garp/Service/Amazon/Ses.php | Garp_Service_Amazon_Ses.getSendQuota | public function getSendQuota() {
$response = $this->_makeRequest(array(
'Action' => 'GetSendQuota'
));
$dom = new DOMDocument();
$dom->loadXML($response);
$out = array(
'Max24HourSend' => $dom->getElementsByTagName('Max24HourSend')->item(0)->nodeValue,
'MaxSendRate' => $dom->getElementsByTagName('MaxSendRate')->item(0)->nodeValue,
'SentLast24Hours' => $dom->getElementsByTagName('SentLast24Hours')->item(0)->nodeValue
);
return $out;
} | php | public function getSendQuota() {
$response = $this->_makeRequest(array(
'Action' => 'GetSendQuota'
));
$dom = new DOMDocument();
$dom->loadXML($response);
$out = array(
'Max24HourSend' => $dom->getElementsByTagName('Max24HourSend')->item(0)->nodeValue,
'MaxSendRate' => $dom->getElementsByTagName('MaxSendRate')->item(0)->nodeValue,
'SentLast24Hours' => $dom->getElementsByTagName('SentLast24Hours')->item(0)->nodeValue
);
return $out;
} | [
"public",
"function",
"getSendQuota",
"(",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"_makeRequest",
"(",
"array",
"(",
"'Action'",
"=>",
"'GetSendQuota'",
")",
")",
";",
"$",
"dom",
"=",
"new",
"DOMDocument",
"(",
")",
";",
"$",
"dom",
"->",
... | Returns the user's current activity limits.
@return Array Describing various statistics about your usage. The keys correspond to
nodes in Amazon's response | [
"Returns",
"the",
"user",
"s",
"current",
"activity",
"limits",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Service/Amazon/Ses.php#L109-L121 |
46,788 | grrr-amsterdam/garp3 | library/Garp/Service/Amazon/Ses.php | Garp_Service_Amazon_Ses.getSendStatistics | public function getSendStatistics() {
$response = $this->_makeRequest(array(
'Action' => 'GetSendStatistics'
));
$dom = new DOMDocument();
$dom->loadXML($response);
$members = $dom->getElementsByTagName('member');
$out = array();
foreach ($members as $member) {
$out[] = array(
'DeliveryAttempts' => $member->getElementsByTagName('DeliveryAttempts')->item(0)->nodeValue,
'Timestamp' => $member->getElementsByTagName('Timestamp')->item(0)->nodeValue,
'Rejects' => $member->getElementsByTagName('Rejects')->item(0)->nodeValue,
'Bounces' => $member->getElementsByTagName('Bounces')->item(0)->nodeValue,
'Complaints' => $member->getElementsByTagName('Complaints')->item(0)->nodeValue,
);
}
return $out;
} | php | public function getSendStatistics() {
$response = $this->_makeRequest(array(
'Action' => 'GetSendStatistics'
));
$dom = new DOMDocument();
$dom->loadXML($response);
$members = $dom->getElementsByTagName('member');
$out = array();
foreach ($members as $member) {
$out[] = array(
'DeliveryAttempts' => $member->getElementsByTagName('DeliveryAttempts')->item(0)->nodeValue,
'Timestamp' => $member->getElementsByTagName('Timestamp')->item(0)->nodeValue,
'Rejects' => $member->getElementsByTagName('Rejects')->item(0)->nodeValue,
'Bounces' => $member->getElementsByTagName('Bounces')->item(0)->nodeValue,
'Complaints' => $member->getElementsByTagName('Complaints')->item(0)->nodeValue,
);
}
return $out;
} | [
"public",
"function",
"getSendStatistics",
"(",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"_makeRequest",
"(",
"array",
"(",
"'Action'",
"=>",
"'GetSendStatistics'",
")",
")",
";",
"$",
"dom",
"=",
"new",
"DOMDocument",
"(",
")",
";",
"$",
"dom"... | Returns the user's sending statistics. The result is a list of data points, representing the last two weeks of sending activity.
Each data point in the list contains statistics for a 15-minute interval.
@return Array | [
"Returns",
"the",
"user",
"s",
"sending",
"statistics",
".",
"The",
"result",
"is",
"a",
"list",
"of",
"data",
"points",
"representing",
"the",
"last",
"two",
"weeks",
"of",
"sending",
"activity",
".",
"Each",
"data",
"point",
"in",
"the",
"list",
"contain... | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Service/Amazon/Ses.php#L128-L146 |
46,789 | grrr-amsterdam/garp3 | library/Garp/Service/Amazon/Ses.php | Garp_Service_Amazon_Ses.listVerifiedEmailAddresses | public function listVerifiedEmailAddresses() {
$response = $this->_makeRequest(array(
'Action' => 'ListVerifiedEmailAddresses'
));
$dom = new DOMDocument();
$dom->loadXML($response);
$members = $dom->getElementsByTagName('member');
$out = array();
foreach ($members as $member) {
$out[] = $member->nodeValue;
}
return $out;
} | php | public function listVerifiedEmailAddresses() {
$response = $this->_makeRequest(array(
'Action' => 'ListVerifiedEmailAddresses'
));
$dom = new DOMDocument();
$dom->loadXML($response);
$members = $dom->getElementsByTagName('member');
$out = array();
foreach ($members as $member) {
$out[] = $member->nodeValue;
}
return $out;
} | [
"public",
"function",
"listVerifiedEmailAddresses",
"(",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"_makeRequest",
"(",
"array",
"(",
"'Action'",
"=>",
"'ListVerifiedEmailAddresses'",
")",
")",
";",
"$",
"dom",
"=",
"new",
"DOMDocument",
"(",
")",
"... | Returns a list containing all of the email addresses that have been verified.
@return Array | [
"Returns",
"a",
"list",
"containing",
"all",
"of",
"the",
"email",
"addresses",
"that",
"have",
"been",
"verified",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Service/Amazon/Ses.php#L152-L164 |
46,790 | grrr-amsterdam/garp3 | library/Garp/Service/Amazon/Ses.php | Garp_Service_Amazon_Ses.sendRawEmail | public function sendRawEmail($args) {
$args = $args instanceof Garp_Util_Configuration ? $args : new Garp_Util_Configuration($args);
$args['Action'] = 'SendRawEmail';
$args->obligate('RawMessage');
$args = (array)$args;
// normalize so-called "String List" parameters
if (!empty($args['Destinations'])) {
$destinations = $this->_arrayToStringList((array)$args['Destinations'], 'Destinations');
$args += $destinations;
unset($args['Destinations']);
}
$args['RawMessage.Data'] = $args['RawMessage'];
unset($args['RawMessage']);
$response = $this->_makeRequest((array)$args);
return true;
} | php | public function sendRawEmail($args) {
$args = $args instanceof Garp_Util_Configuration ? $args : new Garp_Util_Configuration($args);
$args['Action'] = 'SendRawEmail';
$args->obligate('RawMessage');
$args = (array)$args;
// normalize so-called "String List" parameters
if (!empty($args['Destinations'])) {
$destinations = $this->_arrayToStringList((array)$args['Destinations'], 'Destinations');
$args += $destinations;
unset($args['Destinations']);
}
$args['RawMessage.Data'] = $args['RawMessage'];
unset($args['RawMessage']);
$response = $this->_makeRequest((array)$args);
return true;
} | [
"public",
"function",
"sendRawEmail",
"(",
"$",
"args",
")",
"{",
"$",
"args",
"=",
"$",
"args",
"instanceof",
"Garp_Util_Configuration",
"?",
"$",
"args",
":",
"new",
"Garp_Util_Configuration",
"(",
"$",
"args",
")",
";",
"$",
"args",
"[",
"'Action'",
"]"... | Sends an email message, with header and content specified by the client. The SendRawEmail action is useful for sending multipart MIME emails.
The raw text of the message must comply with Internet email standards; otherwise, the message cannot be sent.
@param Array|Garp_Util_Configuration $args Might contain;
['RawMessage'] [required] String The raw email message (headers and body)
['Source'] [optional] String A FROM address
['Destinations'] [optional] Array Email addresses of recipients (optional because TO fields may be present in raw message)
@return Boolean | [
"Sends",
"an",
"email",
"message",
"with",
"header",
"and",
"content",
"specified",
"by",
"the",
"client",
".",
"The",
"SendRawEmail",
"action",
"is",
"useful",
"for",
"sending",
"multipart",
"MIME",
"emails",
".",
"The",
"raw",
"text",
"of",
"the",
"message... | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Service/Amazon/Ses.php#L298-L315 |
46,791 | grrr-amsterdam/garp3 | library/Garp/Service/Amazon/Ses.php | Garp_Service_Amazon_Ses._makeRequest | protected function _makeRequest($args = array()) {
$date = date(DATE_RFC1123);
$sig = $this->_createSignature($date);
$amznAuthHeader = 'AWS3-HTTPS '.
'AWSAccessKeyId='.$this->_accessKey.
', Algorithm=Hmac'.strtoupper(self::SIGNATURE_HASH_METHOD).
', Signature='.$sig;
$client = $this->getHttpClient()->resetParameters();
$endpoint = sprintf(self::ENDPOINT, $this->_region);
$client->setUri($endpoint);
$client->setHeaders(array(
'Date' => $date,
'X-Amzn-Authorization' => $amznAuthHeader
));
// required parameters for each request
$args['Signature'] = $sig;
$args['SignatureMethod'] = 'Hmac'.self::SIGNATURE_HASH_METHOD;
$args['SignatureVersion'] = 2;
$args['Version'] = self::API_VERSION;
$client->setParameterPost($args);
$response = $client->request(Zend_Http_Client::POST);
if ($response->getStatus() !== 200) {
$this->throwException($response->getBody());
}
return $response->getBody();
} | php | protected function _makeRequest($args = array()) {
$date = date(DATE_RFC1123);
$sig = $this->_createSignature($date);
$amznAuthHeader = 'AWS3-HTTPS '.
'AWSAccessKeyId='.$this->_accessKey.
', Algorithm=Hmac'.strtoupper(self::SIGNATURE_HASH_METHOD).
', Signature='.$sig;
$client = $this->getHttpClient()->resetParameters();
$endpoint = sprintf(self::ENDPOINT, $this->_region);
$client->setUri($endpoint);
$client->setHeaders(array(
'Date' => $date,
'X-Amzn-Authorization' => $amznAuthHeader
));
// required parameters for each request
$args['Signature'] = $sig;
$args['SignatureMethod'] = 'Hmac'.self::SIGNATURE_HASH_METHOD;
$args['SignatureVersion'] = 2;
$args['Version'] = self::API_VERSION;
$client->setParameterPost($args);
$response = $client->request(Zend_Http_Client::POST);
if ($response->getStatus() !== 200) {
$this->throwException($response->getBody());
}
return $response->getBody();
} | [
"protected",
"function",
"_makeRequest",
"(",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"date",
"=",
"date",
"(",
"DATE_RFC1123",
")",
";",
"$",
"sig",
"=",
"$",
"this",
"->",
"_createSignature",
"(",
"$",
"date",
")",
";",
"$",
"amznAuthHe... | Makes the actual AWS request.
@param String $method
@param Array $args
@return Mixed | [
"Makes",
"the",
"actual",
"AWS",
"request",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Service/Amazon/Ses.php#L337-L366 |
46,792 | grrr-amsterdam/garp3 | library/Garp/Service/Amazon/Ses.php | Garp_Service_Amazon_Ses._createSignature | protected function _createSignature($date) {
$sig = Zend_Crypt_Hmac::compute($this->_secretKey, self::SIGNATURE_HASH_METHOD, $date, Zend_Crypt_Hmac::BINARY);
return base64_encode($sig);
} | php | protected function _createSignature($date) {
$sig = Zend_Crypt_Hmac::compute($this->_secretKey, self::SIGNATURE_HASH_METHOD, $date, Zend_Crypt_Hmac::BINARY);
return base64_encode($sig);
} | [
"protected",
"function",
"_createSignature",
"(",
"$",
"date",
")",
"{",
"$",
"sig",
"=",
"Zend_Crypt_Hmac",
"::",
"compute",
"(",
"$",
"this",
"->",
"_secretKey",
",",
"self",
"::",
"SIGNATURE_HASH_METHOD",
",",
"$",
"date",
",",
"Zend_Crypt_Hmac",
"::",
"B... | Create the HMAC-SHA signature required for every request.
@return String | [
"Create",
"the",
"HMAC",
"-",
"SHA",
"signature",
"required",
"for",
"every",
"request",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Service/Amazon/Ses.php#L372-L375 |
46,793 | grrr-amsterdam/garp3 | library/Garp/Content/Api.php | Garp_Content_Api.modelAliasToClass | public static function modelAliasToClass($model) {
$classes = self::getAllModels();
foreach ($classes as $class) {
if ($class->alias === $model || $class->class === self::ENTITIES_NAMESPACE.'_'.$model) {
return $class->class;
}
}
throw new Garp_Content_Exception('Invalid model alias specified: '.$model);
} | php | public static function modelAliasToClass($model) {
$classes = self::getAllModels();
foreach ($classes as $class) {
if ($class->alias === $model || $class->class === self::ENTITIES_NAMESPACE.'_'.$model) {
return $class->class;
}
}
throw new Garp_Content_Exception('Invalid model alias specified: '.$model);
} | [
"public",
"static",
"function",
"modelAliasToClass",
"(",
"$",
"model",
")",
"{",
"$",
"classes",
"=",
"self",
"::",
"getAllModels",
"(",
")",
";",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"class",
"->",
"alias",
... | Convert a model alias to the real class name
@param String $model
@return String | [
"Convert",
"a",
"model",
"alias",
"to",
"the",
"real",
"class",
"name"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Api.php#L103-L112 |
46,794 | grrr-amsterdam/garp3 | library/Garp/Spawn/Php/Model/Abstract.php | Garp_Spawn_Php_Model_Abstract.save | public function save() {
$path = $this->getPath();
$content = $this->render();
$overwrite = $this->isOverwriteEnabled();
if (!$overwrite && file_exists($path)) {
return true;
}
if (!file_put_contents($path, $content)) {
$model = $this->getModel();
throw new Exception("Could not generate {$model->id}" . get_class());
}
return true;
} | php | public function save() {
$path = $this->getPath();
$content = $this->render();
$overwrite = $this->isOverwriteEnabled();
if (!$overwrite && file_exists($path)) {
return true;
}
if (!file_put_contents($path, $content)) {
$model = $this->getModel();
throw new Exception("Could not generate {$model->id}" . get_class());
}
return true;
} | [
"public",
"function",
"save",
"(",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getPath",
"(",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"render",
"(",
")",
";",
"$",
"overwrite",
"=",
"$",
"this",
"->",
"isOverwriteEnabled",
"(",
")",
... | Saves the model file, if applicable. A model that exists and should not be overwritten
will not be touched by this method.
@return void | [
"Saves",
"the",
"model",
"file",
"if",
"applicable",
".",
"A",
"model",
"that",
"exists",
"and",
"should",
"not",
"be",
"overwritten",
"will",
"not",
"be",
"touched",
"by",
"this",
"method",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Spawn/Php/Model/Abstract.php#L25-L39 |
46,795 | grrr-amsterdam/garp3 | library/Garp/Form.php | Garp_Form.getValues | public function getValues($suppressArrayNotation = false) {
$values = parent::getValues($suppressArrayNotation);
unset($values[self::HONEYPOT_FIELD_KEY]);
unset($values[self::TIMESTAMP_FIELD_KEY]);
return $values;
} | php | public function getValues($suppressArrayNotation = false) {
$values = parent::getValues($suppressArrayNotation);
unset($values[self::HONEYPOT_FIELD_KEY]);
unset($values[self::TIMESTAMP_FIELD_KEY]);
return $values;
} | [
"public",
"function",
"getValues",
"(",
"$",
"suppressArrayNotation",
"=",
"false",
")",
"{",
"$",
"values",
"=",
"parent",
"::",
"getValues",
"(",
"$",
"suppressArrayNotation",
")",
";",
"unset",
"(",
"$",
"values",
"[",
"self",
"::",
"HONEYPOT_FIELD_KEY",
... | Override to unset automatically added security fields
@param bool $suppressArrayNotation
@return array | [
"Override",
"to",
"unset",
"automatically",
"added",
"security",
"fields"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Form.php#L108-L113 |
46,796 | grrr-amsterdam/garp3 | library/Garp/Form.php | Garp_Form.addDisplayGroup | public function addDisplayGroup(array $elements, $name, $options = null) {
// Allow custom decorators, but default to a sensible set
if (empty($options['decorators'])) {
$options['decorators'] = array(
'FormElements',
'Fieldset',
);
}
return parent::addDisplayGroup($elements, $name, $options);
} | php | public function addDisplayGroup(array $elements, $name, $options = null) {
// Allow custom decorators, but default to a sensible set
if (empty($options['decorators'])) {
$options['decorators'] = array(
'FormElements',
'Fieldset',
);
}
return parent::addDisplayGroup($elements, $name, $options);
} | [
"public",
"function",
"addDisplayGroup",
"(",
"array",
"$",
"elements",
",",
"$",
"name",
",",
"$",
"options",
"=",
"null",
")",
"{",
"// Allow custom decorators, but default to a sensible set",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'decorators'",
"]",
... | Add a display group
Groups named elements for display purposes.
If a referenced element does not yet exist in the form, it is omitted.
@param array $elements
@param string $name
@param array|Zend_Config $options
@return Zend_Form
@throws Zend_Form_Exception if no valid elements provided | [
"Add",
"a",
"display",
"group"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Form.php#L202-L211 |
46,797 | grrr-amsterdam/garp3 | library/Garp/Form.php | Garp_Form.setAjax | public function setAjax($flag) {
$this->_ajax = $flag;
$class = $this->getAttrib('class');
if ($flag && !preg_match('/(^|\s)ajax($|\s)/', $class)) {
$class .= ' ajax';
} else {
$class = preg_replace('/(^|\s)(ajax)($|\s)/', '$1$3', $class);
}
$this->setAttrib('class', $class);
return $this;
} | php | public function setAjax($flag) {
$this->_ajax = $flag;
$class = $this->getAttrib('class');
if ($flag && !preg_match('/(^|\s)ajax($|\s)/', $class)) {
$class .= ' ajax';
} else {
$class = preg_replace('/(^|\s)(ajax)($|\s)/', '$1$3', $class);
}
$this->setAttrib('class', $class);
return $this;
} | [
"public",
"function",
"setAjax",
"(",
"$",
"flag",
")",
"{",
"$",
"this",
"->",
"_ajax",
"=",
"$",
"flag",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"getAttrib",
"(",
"'class'",
")",
";",
"if",
"(",
"$",
"flag",
"&&",
"!",
"preg_match",
"(",
"'/... | Set wether to hijack the form using AJAX
@param bool $flag
@return $this | [
"Set",
"wether",
"to",
"hijack",
"the",
"form",
"using",
"AJAX"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Form.php#L255-L265 |
46,798 | grrr-amsterdam/garp3 | library/Garp/Form.php | Garp_Form.addTimestampValidation | public function addTimestampValidation() {
// Add timestamp-based spam counter-measure
$this->addElement(
'hidden', self::TIMESTAMP_FIELD_KEY, array(
'validators' => array(new Garp_Validate_Duration)
)
);
// If the form is submitted, do not set the value.
if (!$this->getValue(self::TIMESTAMP_FIELD_KEY)) {
$now = time();
$this->getElement(self::TIMESTAMP_FIELD_KEY)->setValue($now);
}
} | php | public function addTimestampValidation() {
// Add timestamp-based spam counter-measure
$this->addElement(
'hidden', self::TIMESTAMP_FIELD_KEY, array(
'validators' => array(new Garp_Validate_Duration)
)
);
// If the form is submitted, do not set the value.
if (!$this->getValue(self::TIMESTAMP_FIELD_KEY)) {
$now = time();
$this->getElement(self::TIMESTAMP_FIELD_KEY)->setValue($now);
}
} | [
"public",
"function",
"addTimestampValidation",
"(",
")",
"{",
"// Add timestamp-based spam counter-measure",
"$",
"this",
"->",
"addElement",
"(",
"'hidden'",
",",
"self",
"::",
"TIMESTAMP_FIELD_KEY",
",",
"array",
"(",
"'validators'",
"=>",
"array",
"(",
"new",
"G... | Add field that records how long it took to submit the form.
This should be longer than 1 second, otherwise we suspect spammy
behavior.
@return void | [
"Add",
"field",
"that",
"records",
"how",
"long",
"it",
"took",
"to",
"submit",
"the",
"form",
".",
"This",
"should",
"be",
"longer",
"than",
"1",
"second",
"otherwise",
"we",
"suspect",
"spammy",
"behavior",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Form.php#L281-L293 |
46,799 | grrr-amsterdam/garp3 | library/Garp/Form.php | Garp_Form._getDefaultDecoratorOptions | protected function _getDefaultDecoratorOptions($type, array $options = []): array {
// Set default required label suffix
$labelOptions = [];
if ($this->_defaultRequiredLabelSuffix) {
$labelOptions['requiredSuffix'] = $this->getDefaultRequiredLabelSuffix();
// labeloptions should never be escaped because of required suffix (<i>*</i>)
$labelOptions['escape'] = false;
}
$decorators = [
'ViewHelper',
['Label', $labelOptions],
'Description',
'Errors'
];
if ($type != 'hidden') {
$divWrapperOptions = ['tag' => 'div'];
if (isset($options['parentClass'])) {
$divWrapperOptions['class'] = $options['parentClass'];
}
$decorators[] = ['HtmlTag', $divWrapperOptions];
}
return $decorators;
} | php | protected function _getDefaultDecoratorOptions($type, array $options = []): array {
// Set default required label suffix
$labelOptions = [];
if ($this->_defaultRequiredLabelSuffix) {
$labelOptions['requiredSuffix'] = $this->getDefaultRequiredLabelSuffix();
// labeloptions should never be escaped because of required suffix (<i>*</i>)
$labelOptions['escape'] = false;
}
$decorators = [
'ViewHelper',
['Label', $labelOptions],
'Description',
'Errors'
];
if ($type != 'hidden') {
$divWrapperOptions = ['tag' => 'div'];
if (isset($options['parentClass'])) {
$divWrapperOptions['class'] = $options['parentClass'];
}
$decorators[] = ['HtmlTag', $divWrapperOptions];
}
return $decorators;
} | [
"protected",
"function",
"_getDefaultDecoratorOptions",
"(",
"$",
"type",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"array",
"{",
"// Set default required label suffix",
"$",
"labelOptions",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"_de... | Retrieve default decorators
@param string $type Type of element
@param array $options Options given with the element
@return void | [
"Retrieve",
"default",
"decorators"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Form.php#L373-L396 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.