repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
grrr-amsterdam/garp3
library/Garp/Form.php
Garp_Form._mergeDecoratorOptions
protected function _mergeDecoratorOptions(Zend_Form_Element $element, array $inheritance) { foreach ($inheritance as $mergedDecorator) { $name = is_array($mergedDecorator) ? $mergedDecorator[0] : $mergedDecorator; $options = is_array($mergedDecorator) ? $mergedDecorator[1] : []; $existingDecorator = $element->getDecorator($name); if (!$existingDecorator) { continue; } foreach ($options as $key => $value) { $existingDecorator->setOption($key, $value); } } }
php
protected function _mergeDecoratorOptions(Zend_Form_Element $element, array $inheritance) { foreach ($inheritance as $mergedDecorator) { $name = is_array($mergedDecorator) ? $mergedDecorator[0] : $mergedDecorator; $options = is_array($mergedDecorator) ? $mergedDecorator[1] : []; $existingDecorator = $element->getDecorator($name); if (!$existingDecorator) { continue; } foreach ($options as $key => $value) { $existingDecorator->setOption($key, $value); } } }
[ "protected", "function", "_mergeDecoratorOptions", "(", "Zend_Form_Element", "$", "element", ",", "array", "$", "inheritance", ")", "{", "foreach", "(", "$", "inheritance", "as", "$", "mergedDecorator", ")", "{", "$", "name", "=", "is_array", "(", "$", "merged...
Overwrite or append existing decorator options. @param Zend_Form_Element $element @param array $inheritance Spec describing which options to merge @return void
[ "Overwrite", "or", "append", "existing", "decorator", "options", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Form.php#L405-L417
train
grrr-amsterdam/garp3
library/Garp/Form.php
Garp_Form._mergeDecorators
protected function _mergeDecorators(Zend_Form_Element $element, array $inheritance) { if (empty($inheritance)) { return; } $element->setDecorators( f\reduce( function ($decorators, $mergeSpec) { if (!isset($mergeSpec['at']) && !isset($mergeSpec['after'])) { return f\concat($decorators, [$mergeSpec]); } if (!isset($mergeSpec['spec'])) { throw new InvalidArgumentException( 'key "spec" is required to describe decorator' ); } $mergeCallback = $this->_getDecoratorMergeCallback( $mergeSpec['at'] ?? $mergeSpec['after'] ); $mergeFn = isset($mergeSpec['at']) ? f\merge_at($mergeSpec['spec'], $mergeCallback) : f\merge_after($mergeSpec['spec'], $mergeCallback); return $mergeFn($decorators); }, $element->getDecorators(), $inheritance ) ); }
php
protected function _mergeDecorators(Zend_Form_Element $element, array $inheritance) { if (empty($inheritance)) { return; } $element->setDecorators( f\reduce( function ($decorators, $mergeSpec) { if (!isset($mergeSpec['at']) && !isset($mergeSpec['after'])) { return f\concat($decorators, [$mergeSpec]); } if (!isset($mergeSpec['spec'])) { throw new InvalidArgumentException( 'key "spec" is required to describe decorator' ); } $mergeCallback = $this->_getDecoratorMergeCallback( $mergeSpec['at'] ?? $mergeSpec['after'] ); $mergeFn = isset($mergeSpec['at']) ? f\merge_at($mergeSpec['spec'], $mergeCallback) : f\merge_after($mergeSpec['spec'], $mergeCallback); return $mergeFn($decorators); }, $element->getDecorators(), $inheritance ) ); }
[ "protected", "function", "_mergeDecorators", "(", "Zend_Form_Element", "$", "element", ",", "array", "$", "inheritance", ")", "{", "if", "(", "empty", "(", "$", "inheritance", ")", ")", "{", "return", ";", "}", "$", "element", "->", "setDecorators", "(", "...
Merge a new decorator into the list of default decorators. Control placement with 'at' or 'after' flags. @param Zend_Form_Element $element @param array $inheritance @return void
[ "Merge", "a", "new", "decorator", "into", "the", "list", "of", "default", "decorators", ".", "Control", "placement", "with", "at", "or", "after", "flags", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Form.php#L427-L455
train
grrr-amsterdam/garp3
library/Garp/Form.php
Garp_Form._omitDefaultDecorators
protected function _omitDefaultDecorators(Zend_Form_Element $element, array $omitted) { foreach ($omitted as $name) { $element->removeDecorator($name); } }
php
protected function _omitDefaultDecorators(Zend_Form_Element $element, array $omitted) { foreach ($omitted as $name) { $element->removeDecorator($name); } }
[ "protected", "function", "_omitDefaultDecorators", "(", "Zend_Form_Element", "$", "element", ",", "array", "$", "omitted", ")", "{", "foreach", "(", "$", "omitted", "as", "$", "name", ")", "{", "$", "element", "->", "removeDecorator", "(", "$", "name", ")", ...
Remove existing decorators. @param Zend_Form_Element $element @param array $omitted @return void
[ "Remove", "existing", "decorators", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Form.php#L464-L468
train
grrr-amsterdam/garp3
library/Garp/ErrorHandler.php
Garp_ErrorHandler.logErrorToFile
public static function logErrorToFile($errors) { $errorMessage = self::_composeFullErrorMessage($errors); $stream = fopen(APPLICATION_PATH . '/data/logs/errors.log', 'a'); $writer = new Zend_Log_Writer_Stream($stream); $logger = new Zend_Log($writer); $logger->log($errorMessage, Zend_Log::ALERT); }
php
public static function logErrorToFile($errors) { $errorMessage = self::_composeFullErrorMessage($errors); $stream = fopen(APPLICATION_PATH . '/data/logs/errors.log', 'a'); $writer = new Zend_Log_Writer_Stream($stream); $logger = new Zend_Log($writer); $logger->log($errorMessage, Zend_Log::ALERT); }
[ "public", "static", "function", "logErrorToFile", "(", "$", "errors", ")", "{", "$", "errorMessage", "=", "self", "::", "_composeFullErrorMessage", "(", "$", "errors", ")", ";", "$", "stream", "=", "fopen", "(", "APPLICATION_PATH", ".", "'/data/logs/errors.log'"...
Log that pesky error to a file @param ArrayObject $errors @return void
[ "Log", "that", "pesky", "error", "to", "a", "file" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/ErrorHandler.php#L44-L51
train
grrr-amsterdam/garp3
library/Garp/ErrorHandler.php
Garp_ErrorHandler.mailErrorToAdmin
public static function mailErrorToAdmin(ArrayObject $errors) { $errorMessage = self::_composeFullErrorMessage($errors); $subjectPrefix = ''; if (isset($_SERVER) && !empty($_SERVER['HTTP_HOST'])) { $subjectPrefix = '[' . $_SERVER['HTTP_HOST'] . '] '; } $ini = Zend_Registry::get('config'); $to = ( isset($ini->app) && isset($ini->app->errorReportEmailAddress) && $ini->app->errorReportEmailAddress ) ? $ini->app->errorReportEmailAddress : self::ERROR_REPORT_MAIL_ADDRESS_FALLBACK ; $mailer = new Garp_Mailer(); return $mailer->send( array( 'to' => $to, 'subject' => $subjectPrefix . 'An application error occurred', 'message' => $errorMessage ) ); }
php
public static function mailErrorToAdmin(ArrayObject $errors) { $errorMessage = self::_composeFullErrorMessage($errors); $subjectPrefix = ''; if (isset($_SERVER) && !empty($_SERVER['HTTP_HOST'])) { $subjectPrefix = '[' . $_SERVER['HTTP_HOST'] . '] '; } $ini = Zend_Registry::get('config'); $to = ( isset($ini->app) && isset($ini->app->errorReportEmailAddress) && $ini->app->errorReportEmailAddress ) ? $ini->app->errorReportEmailAddress : self::ERROR_REPORT_MAIL_ADDRESS_FALLBACK ; $mailer = new Garp_Mailer(); return $mailer->send( array( 'to' => $to, 'subject' => $subjectPrefix . 'An application error occurred', 'message' => $errorMessage ) ); }
[ "public", "static", "function", "mailErrorToAdmin", "(", "ArrayObject", "$", "errors", ")", "{", "$", "errorMessage", "=", "self", "::", "_composeFullErrorMessage", "(", "$", "errors", ")", ";", "$", "subjectPrefix", "=", "''", ";", "if", "(", "isset", "(", ...
Mail an error to an admin @param ArrayObject $errors @return void
[ "Mail", "an", "error", "to", "an", "admin" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/ErrorHandler.php#L108-L133
train
grrr-amsterdam/garp3
library/Garp/Model/Db.php
Garp_Model_Db.getFieldConfiguration
public function getFieldConfiguration($column = null) { $fields = $this->getConfiguration('fields'); if (!$column) { return $fields; } foreach ($fields as $key => $value) { if ($value['name'] == $column) { return $value; } } return null; }
php
public function getFieldConfiguration($column = null) { $fields = $this->getConfiguration('fields'); if (!$column) { return $fields; } foreach ($fields as $key => $value) { if ($value['name'] == $column) { return $value; } } return null; }
[ "public", "function", "getFieldConfiguration", "(", "$", "column", "=", "null", ")", "{", "$", "fields", "=", "$", "this", "->", "getConfiguration", "(", "'fields'", ")", ";", "if", "(", "!", "$", "column", ")", "{", "return", "$", "fields", ";", "}", ...
Get field configuration @param string $column @return array
[ "Get", "field", "configuration" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db.php#L184-L195
train
grrr-amsterdam/garp3
library/Garp/Model/Db.php
Garp_Model_Db.filterColumns
public function filterColumns(array $data) { $testCols = array_fill_keys($this->info(Zend_Db_Table_Abstract::COLS), null); return array_intersect_key($data, $testCols); }
php
public function filterColumns(array $data) { $testCols = array_fill_keys($this->info(Zend_Db_Table_Abstract::COLS), null); return array_intersect_key($data, $testCols); }
[ "public", "function", "filterColumns", "(", "array", "$", "data", ")", "{", "$", "testCols", "=", "array_fill_keys", "(", "$", "this", "->", "info", "(", "Zend_Db_Table_Abstract", "::", "COLS", ")", ",", "null", ")", ";", "return", "array_intersect_key", "("...
Strip an array of columns that are not part of this model @param array $data @return array
[ "Strip", "an", "array", "of", "columns", "that", "are", "not", "part", "of", "this", "model" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db.php#L212-L215
train
grrr-amsterdam/garp3
library/Garp/Model/Db.php
Garp_Model_Db.arrayToWhereClause
public function arrayToWhereClause(array $data, $and = true) { $out = array(); $adapter = $this->getAdapter(); foreach ($data as $key => $value) { $quotedKey = $adapter->quoteIdentifier($key); $quotedValue = $adapter->quote($value); if (is_null($value)) { $out[] = "$quotedKey IS NULL"; } elseif (is_array($value)) { $out[] = "$quotedKey IN ($quotedValue)"; } else { $out[] = "$quotedKey = $quotedValue"; } } $glue = $and ? 'AND' : 'OR'; $out = implode(" $glue ", $out); return $out; }
php
public function arrayToWhereClause(array $data, $and = true) { $out = array(); $adapter = $this->getAdapter(); foreach ($data as $key => $value) { $quotedKey = $adapter->quoteIdentifier($key); $quotedValue = $adapter->quote($value); if (is_null($value)) { $out[] = "$quotedKey IS NULL"; } elseif (is_array($value)) { $out[] = "$quotedKey IN ($quotedValue)"; } else { $out[] = "$quotedKey = $quotedValue"; } } $glue = $and ? 'AND' : 'OR'; $out = implode(" $glue ", $out); return $out; }
[ "public", "function", "arrayToWhereClause", "(", "array", "$", "data", ",", "$", "and", "=", "true", ")", "{", "$", "out", "=", "array", "(", ")", ";", "$", "adapter", "=", "$", "this", "->", "getAdapter", "(", ")", ";", "foreach", "(", "$", "data"...
Convert array to WHERE clause @param array $data @param bool $and Wether to use AND or OR @return string
[ "Convert", "array", "to", "WHERE", "clause" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db.php#L224-L242
train
grrr-amsterdam/garp3
library/Garp/Model/Db.php
Garp_Model_Db.createSelect
public function createSelect($where = null, $order = null, $count = null, $offset = null) { $select = $this->select(); if ($where !== null) { $this->_where($select, $where); } if ($order !== null) { $this->_order($select, $order); } if ($count !== null || $offset !== null) { $select->limit($count, $offset); } return $select; }
php
public function createSelect($where = null, $order = null, $count = null, $offset = null) { $select = $this->select(); if ($where !== null) { $this->_where($select, $where); } if ($order !== null) { $this->_order($select, $order); } if ($count !== null || $offset !== null) { $select->limit($count, $offset); } return $select; }
[ "public", "function", "createSelect", "(", "$", "where", "=", "null", ",", "$", "order", "=", "null", ",", "$", "count", "=", "null", ",", "$", "offset", "=", "null", ")", "{", "$", "select", "=", "$", "this", "->", "select", "(", ")", ";", "if",...
Convenience method for creating SELECT objects @param string|array|Zend_Db_Table_Select $where OPTIONAL An SQL WHERE clause or Zend_Db_Table_Select object. @param string|array $order OPTIONAL An SQL ORDER clause. @param int $count OPTIONAL An SQL LIMIT count. @param int $offset OPTIONAL An SQL LIMIT offset. @return Zend_Db_Table_Select
[ "Convenience", "method", "for", "creating", "SELECT", "objects" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db.php#L254-L269
train
grrr-amsterdam/garp3
library/Garp/Model/Db.php
Garp_Model_Db.getBindingModelName
public function getBindingModelName($theOtherModel) { if (!$theOtherModel instanceof Garp_Model_Db) { $theOtherModel = new $theOtherModel(); } $modelNames = array( $this->getNameWithoutNamespace(), $theOtherModel->getNameWithoutNamespace() ); sort($modelNames); $namespace = 'Model_'; // The following makes sure the namespace used is the same as that of // the given models, but only if they both use the same namespace. $thisNamespace = $this->getNamespace(); $theOtherNamespace = $theOtherModel->getNamespace(); if ($thisNamespace === $theOtherNamespace && $thisNamespace !== 'Model') { $namespace = $thisNamespace . '_Model_'; } $bindingModelName = $namespace . implode('', $modelNames); return $bindingModelName; }
php
public function getBindingModelName($theOtherModel) { if (!$theOtherModel instanceof Garp_Model_Db) { $theOtherModel = new $theOtherModel(); } $modelNames = array( $this->getNameWithoutNamespace(), $theOtherModel->getNameWithoutNamespace() ); sort($modelNames); $namespace = 'Model_'; // The following makes sure the namespace used is the same as that of // the given models, but only if they both use the same namespace. $thisNamespace = $this->getNamespace(); $theOtherNamespace = $theOtherModel->getNamespace(); if ($thisNamespace === $theOtherNamespace && $thisNamespace !== 'Model') { $namespace = $thisNamespace . '_Model_'; } $bindingModelName = $namespace . implode('', $modelNames); return $bindingModelName; }
[ "public", "function", "getBindingModelName", "(", "$", "theOtherModel", ")", "{", "if", "(", "!", "$", "theOtherModel", "instanceof", "Garp_Model_Db", ")", "{", "$", "theOtherModel", "=", "new", "$", "theOtherModel", "(", ")", ";", "}", "$", "modelNames", "=...
Get bindingModel name @param string|Garp_Model_Db $theOtherModel @return string
[ "Get", "bindingModel", "name" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db.php#L297-L317
train
grrr-amsterdam/garp3
library/Garp/Model/Db.php
Garp_Model_Db.refMapToOnClause
public function refMapToOnClause($refModel, $thisAlias = null, $refAlias = null) { $thisAlias = $thisAlias ?: $this->getName(); $thisAdapter = $this->getAdapter(); $thisAlias = $thisAdapter->quoteIdentifier($thisAlias); $ref = $this->getReference($refModel); $refModel = new $refModel(); $refAdapter = $refModel->getAdapter(); $refAlias = $refAlias ?: $refModel->getName(); $refAlias = $refAdapter->quoteIdentifier($refAlias); $on = array(); foreach ($ref['columns'] as $i => $col) { $col = $thisAdapter->quoteIdentifier($col); $refCol = $refAdapter->quoteIdentifier($ref['refColumns'][$i]); $_on = "{$thisAlias}.{$col} = {$refAlias}.{$refCol}"; $on[] = $_on; } $on = implode(' AND ', $on); return $on; }
php
public function refMapToOnClause($refModel, $thisAlias = null, $refAlias = null) { $thisAlias = $thisAlias ?: $this->getName(); $thisAdapter = $this->getAdapter(); $thisAlias = $thisAdapter->quoteIdentifier($thisAlias); $ref = $this->getReference($refModel); $refModel = new $refModel(); $refAdapter = $refModel->getAdapter(); $refAlias = $refAlias ?: $refModel->getName(); $refAlias = $refAdapter->quoteIdentifier($refAlias); $on = array(); foreach ($ref['columns'] as $i => $col) { $col = $thisAdapter->quoteIdentifier($col); $refCol = $refAdapter->quoteIdentifier($ref['refColumns'][$i]); $_on = "{$thisAlias}.{$col} = {$refAlias}.{$refCol}"; $on[] = $_on; } $on = implode(' AND ', $on); return $on; }
[ "public", "function", "refMapToOnClause", "(", "$", "refModel", ",", "$", "thisAlias", "=", "null", ",", "$", "refAlias", "=", "null", ")", "{", "$", "thisAlias", "=", "$", "thisAlias", "?", ":", "$", "this", "->", "getName", "(", ")", ";", "$", "thi...
Generates an ON clause from a referenceMap, for use in a JOIN statement. @param string $refModel @param string $thisAlias @param string $refAlias @return string
[ "Generates", "an", "ON", "clause", "from", "a", "referenceMap", "for", "use", "in", "a", "JOIN", "statement", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db.php#L337-L358
train
grrr-amsterdam/garp3
library/Garp/Model/Db.php
Garp_Model_Db.bindModel
public function bindModel($alias, $options = array()) { if ($alias instanceof Garp_Model_Db) { $alias = get_class($alias); } if (!is_array($options) && !$options instanceof Garp_Util_Configuration) { throw new Exception('$options must be an array or Garp_Util_Configuration'); } if (empty($options['modelClass']) && empty($options['rule']) && substr($alias, 0, 6) !== 'Model_' ) { // Assume $alias is actually a rule and fetch the required info from // the reference. $referenceMap = $this->_getReferenceMapNormalized(); if (empty($referenceMap[$alias])) { throw new Exception( 'Not enough options given. Alias ' . $alias . ' is not usable as a rule.' ); } $reference = $referenceMap[$alias]; $options['modelClass'] = $reference['refTableClass']; $options['rule'] = $alias; } if (is_array($options)) { $options = new Garp_Util_Configuration($options); } $this->notifyObservers('beforeBindModel', array($this, $alias, &$options)); Garp_Model_Db_BindingManager::storeBinding(get_class($this), $alias, $options); return $this; }
php
public function bindModel($alias, $options = array()) { if ($alias instanceof Garp_Model_Db) { $alias = get_class($alias); } if (!is_array($options) && !$options instanceof Garp_Util_Configuration) { throw new Exception('$options must be an array or Garp_Util_Configuration'); } if (empty($options['modelClass']) && empty($options['rule']) && substr($alias, 0, 6) !== 'Model_' ) { // Assume $alias is actually a rule and fetch the required info from // the reference. $referenceMap = $this->_getReferenceMapNormalized(); if (empty($referenceMap[$alias])) { throw new Exception( 'Not enough options given. Alias ' . $alias . ' is not usable as a rule.' ); } $reference = $referenceMap[$alias]; $options['modelClass'] = $reference['refTableClass']; $options['rule'] = $alias; } if (is_array($options)) { $options = new Garp_Util_Configuration($options); } $this->notifyObservers('beforeBindModel', array($this, $alias, &$options)); Garp_Model_Db_BindingManager::storeBinding(get_class($this), $alias, $options); return $this; }
[ "public", "function", "bindModel", "(", "$", "alias", ",", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "$", "alias", "instanceof", "Garp_Model_Db", ")", "{", "$", "alias", "=", "get_class", "(", "$", "alias", ")", ";", "}", "if", "...
Bind model. This activates a relation between models. With the next fetch operation related records from these models will be fetched alongside the originally requested records. @param string|Garp_Model_Db $alias An alias for the relationship. This name is used in fetched rows to store the related records. If $options['modelClass'] is not set, the alias is also assumed to be the classname. @param Garp_Util_Configuration|array $options Various relation options. Note; for many-to-many relations the name of the binding model must be given in $options['bindingModel']. @return Garp_Model $this
[ "Bind", "model", ".", "This", "activates", "a", "relation", "between", "models", ".", "With", "the", "next", "fetch", "operation", "related", "records", "from", "these", "models", "will", "be", "fetched", "alongside", "the", "originally", "requested", "records",...
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db.php#L384-L416
train
grrr-amsterdam/garp3
library/Garp/Model/Db.php
Garp_Model_Db.unbindModel
public function unbindModel($alias) { $this->notifyObservers('beforeUnbindModel', array($this, &$alias)); Garp_Model_Db_BindingManager::removeBinding(get_class($this), $alias); return $this; }
php
public function unbindModel($alias) { $this->notifyObservers('beforeUnbindModel', array($this, &$alias)); Garp_Model_Db_BindingManager::removeBinding(get_class($this), $alias); return $this; }
[ "public", "function", "unbindModel", "(", "$", "alias", ")", "{", "$", "this", "->", "notifyObservers", "(", "'beforeUnbindModel'", ",", "array", "(", "$", "this", ",", "&", "$", "alias", ")", ")", ";", "Garp_Model_Db_BindingManager", "::", "removeBinding", ...
Unbind model. Deactivate a relationship between models. @param string $alias The alias or name of the model @return Garp_Model $this
[ "Unbind", "model", ".", "Deactivate", "a", "relationship", "between", "models", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db.php#L424-L428
train
grrr-amsterdam/garp3
library/Garp/Model/Db.php
Garp_Model_Db.unbindAllModels
public function unbindAllModels() { foreach ($this->getBindings() as $alias => $binding) { $this->unbindModel($alias); } return $this; }
php
public function unbindAllModels() { foreach ($this->getBindings() as $alias => $binding) { $this->unbindModel($alias); } return $this; }
[ "public", "function", "unbindAllModels", "(", ")", "{", "foreach", "(", "$", "this", "->", "getBindings", "(", ")", "as", "$", "alias", "=>", "$", "binding", ")", "{", "$", "this", "->", "unbindModel", "(", "$", "alias", ")", ";", "}", "return", "$",...
Unbind all models. @return Garp_Model $this
[ "Unbind", "all", "models", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db.php#L435-L440
train
grrr-amsterdam/garp3
library/Garp/Model/Db.php
Garp_Model_Db.fetchByAuthor
public function fetchByAuthor($authorId, Zend_Db_Select $select = null) { $select = $select ?: $this->select(); $select->where('author_id = ?', $authorId); $result = $this->fetchAll($select); return $result; }
php
public function fetchByAuthor($authorId, Zend_Db_Select $select = null) { $select = $select ?: $this->select(); $select->where('author_id = ?', $authorId); $result = $this->fetchAll($select); return $result; }
[ "public", "function", "fetchByAuthor", "(", "$", "authorId", ",", "Zend_Db_Select", "$", "select", "=", "null", ")", "{", "$", "select", "=", "$", "select", "?", ":", "$", "this", "->", "select", "(", ")", ";", "$", "select", "->", "where", "(", "'au...
Fetch all records created by a certain someone. @param int $authorId @param Zend_Db_Select $select @return Zend_Db_Table_Rowset_Abstract
[ "Fetch", "all", "records", "created", "by", "a", "certain", "someone", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db.php#L486-L492
train
grrr-amsterdam/garp3
library/Garp/Model/Db.php
Garp_Model_Db.fetchById
public function fetchById($id) { $select = $this->select()->where('id = ?', $id); return $this->fetchRow($select); }
php
public function fetchById($id) { $select = $this->select()->where('id = ?', $id); return $this->fetchRow($select); }
[ "public", "function", "fetchById", "(", "$", "id", ")", "{", "$", "select", "=", "$", "this", "->", "select", "(", ")", "->", "where", "(", "'id = ?'", ",", "$", "id", ")", ";", "return", "$", "this", "->", "fetchRow", "(", "$", "select", ")", ";...
Shortcut method for fetching record by id @param int $id @return Zend_Db_Table_Row
[ "Shortcut", "method", "for", "fetching", "record", "by", "id" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db.php#L500-L503
train
grrr-amsterdam/garp3
library/Garp/Model/Db.php
Garp_Model_Db.fetchBySlug
public function fetchBySlug($slug) { $select = $this->select()->where('slug = ?', $slug); return $this->fetchRow($select); }
php
public function fetchBySlug($slug) { $select = $this->select()->where('slug = ?', $slug); return $this->fetchRow($select); }
[ "public", "function", "fetchBySlug", "(", "$", "slug", ")", "{", "$", "select", "=", "$", "this", "->", "select", "(", ")", "->", "where", "(", "'slug = ?'", ",", "$", "slug", ")", ";", "return", "$", "this", "->", "fetchRow", "(", "$", "select", "...
Shortcut method for fetching record by slug @param string $slug @return Zend_Db_Table_Row
[ "Shortcut", "method", "for", "fetching", "record", "by", "slug" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db.php#L511-L514
train
grrr-amsterdam/garp3
library/Garp/Model/Db.php
Garp_Model_Db.quoteValues
public function quoteValues(array &$values) { $adapter = $this->getAdapter(); $quoteInto = function (&$item) use ($adapter) { $item = $adapter->quote($item); }; array_walk($values, $quoteInto); }
php
public function quoteValues(array &$values) { $adapter = $this->getAdapter(); $quoteInto = function (&$item) use ($adapter) { $item = $adapter->quote($item); }; array_walk($values, $quoteInto); }
[ "public", "function", "quoteValues", "(", "array", "&", "$", "values", ")", "{", "$", "adapter", "=", "$", "this", "->", "getAdapter", "(", ")", ";", "$", "quoteInto", "=", "function", "(", "&", "$", "item", ")", "use", "(", "$", "adapter", ")", "{...
Quote an array of values @param array $values @return void
[ "Quote", "an", "array", "of", "values" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db.php#L522-L528
train
grrr-amsterdam/garp3
library/Garp/Model/Db.php
Garp_Model_Db.fetchAll
public function fetchAll($where = null, $order = null, $count = null, $offset = null) { if (!($where instanceof Zend_Db_Table_Select)) { $select = $this->createSelect($where, $order, $count, $offset); } else { $select = $where; } return $this->_improvedFetch($select, 'fetchAll'); }
php
public function fetchAll($where = null, $order = null, $count = null, $offset = null) { if (!($where instanceof Zend_Db_Table_Select)) { $select = $this->createSelect($where, $order, $count, $offset); } else { $select = $where; } return $this->_improvedFetch($select, 'fetchAll'); }
[ "public", "function", "fetchAll", "(", "$", "where", "=", "null", ",", "$", "order", "=", "null", ",", "$", "count", "=", "null", ",", "$", "offset", "=", "null", ")", "{", "if", "(", "!", "(", "$", "where", "instanceof", "Zend_Db_Table_Select", ")",...
Fetches all rows. Honors the Zend_Db_Adapter fetch mode. @param string|array|Zend_Db_Table_Select $where OPTIONAL An SQL WHERE clause or Zend_Db_Table_Select object. @param string|array $order OPTIONAL An SQL ORDER clause. @param int $count OPTIONAL An SQL LIMIT count. @param int $offset OPTIONAL An SQL LIMIT offset. @return Zend_Db_Table_Rowset_Abstract The row results per the Zend_Db_Adapter fetch mode.
[ "Fetches", "all", "rows", ".", "Honors", "the", "Zend_Db_Adapter", "fetch", "mode", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db.php#L620-L627
train
grrr-amsterdam/garp3
library/Garp/Model/Db.php
Garp_Model_Db._improvedFetch
protected function _improvedFetch(Zend_Db_Select $select, $method) { if ($method != 'fetchRow' && $method != 'fetchAll') { throw new Garp_Model_Exception('\'method\' must be "fetchRow" or "fetchAll".'); } /** * Observers are allowed to set $results. This way, behaviors can swoop in * and use a different source when fetching records based on certain parameters. * For instance, the Cachable behavior might fetch data from the cache * instead of the database. */ $results = -1; $this->notifyObservers('beforeFetch', array($this, $select, &$results)); // Results was untouched, fetch a live result. if ($results === -1) { $results = parent::$method($select); $this->notifyObservers('afterFetch', array($this, &$results, $select)); } return $results; }
php
protected function _improvedFetch(Zend_Db_Select $select, $method) { if ($method != 'fetchRow' && $method != 'fetchAll') { throw new Garp_Model_Exception('\'method\' must be "fetchRow" or "fetchAll".'); } /** * Observers are allowed to set $results. This way, behaviors can swoop in * and use a different source when fetching records based on certain parameters. * For instance, the Cachable behavior might fetch data from the cache * instead of the database. */ $results = -1; $this->notifyObservers('beforeFetch', array($this, $select, &$results)); // Results was untouched, fetch a live result. if ($results === -1) { $results = parent::$method($select); $this->notifyObservers('afterFetch', array($this, &$results, $select)); } return $results; }
[ "protected", "function", "_improvedFetch", "(", "Zend_Db_Select", "$", "select", ",", "$", "method", ")", "{", "if", "(", "$", "method", "!=", "'fetchRow'", "&&", "$", "method", "!=", "'fetchAll'", ")", "{", "throw", "new", "Garp_Model_Exception", "(", "'\\'...
A utility method that extends both fetchRow and fetchAll. @param Zend_Db_Select $select Select object passed to either parent::fetchRow or parent::fetchAll @param String $method The real method, 'fetchRow' or 'fetchAll' @return Mixed
[ "A", "utility", "method", "that", "extends", "both", "fetchRow", "and", "fetchAll", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db.php#L657-L676
train
grrr-amsterdam/garp3
library/Garp/Model/Db.php
Garp_Model_Db.count
public function count(Zend_Db_Select $select = null) { if (!$select) { $select = $this->select(); } $select->from($this->getName(), array('count' => new Zend_Db_Expr('COUNT(*)'))); if ($row = $this->fetchRow($select)) { return (int)$row->count; } return 0; }
php
public function count(Zend_Db_Select $select = null) { if (!$select) { $select = $this->select(); } $select->from($this->getName(), array('count' => new Zend_Db_Expr('COUNT(*)'))); if ($row = $this->fetchRow($select)) { return (int)$row->count; } return 0; }
[ "public", "function", "count", "(", "Zend_Db_Select", "$", "select", "=", "null", ")", "{", "if", "(", "!", "$", "select", ")", "{", "$", "select", "=", "$", "this", "->", "select", "(", ")", ";", "}", "$", "select", "->", "from", "(", "$", "this...
Returns the number of records in the database, optionally limited by the provided select object. @param Zend_Db_Select $select @return Int Number of records
[ "Returns", "the", "number", "of", "records", "in", "the", "database", "optionally", "limited", "by", "the", "provided", "select", "object", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db.php#L685-L694
train
grrr-amsterdam/garp3
library/Garp/Model/Db.php
Garp_Model_Db.getObserver
public function getObserver($name) { return array_key_exists($name, $this->_observers) ? $this->_observers[$name] : null; }
php
public function getObserver($name) { return array_key_exists($name, $this->_observers) ? $this->_observers[$name] : null; }
[ "public", "function", "getObserver", "(", "$", "name", ")", "{", "return", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "_observers", ")", "?", "$", "this", "->", "_observers", "[", "$", "name", "]", ":", "null", ";", "}" ]
Return an observer @param string $name The name of the observer @return Garp_Util_Observer Or null if not found
[ "Return", "an", "observer" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db.php#L814-L816
train
grrr-amsterdam/garp3
library/Garp/Model/Db/AuthVimeo.php
Garp_Model_Db_AuthVimeo.createNew
public function createNew($vimeoId, Zend_Oauth_Token_Access $accessToken, array $props) { // first save the new user $userModel = new Model_User(); $userId = $userModel->insert($props); $userData = $userModel->find($userId)->current(); $this->insert(array( 'vimeo_id' => $vimeoId, 'access_token' => $accessToken->getToken(), 'access_token_secret' => $accessToken->getTokenSecret(), 'user_id' => $userId )); $this->getObserver('Authenticatable')->updateLoginStats($userId); return $userData; }
php
public function createNew($vimeoId, Zend_Oauth_Token_Access $accessToken, array $props) { // first save the new user $userModel = new Model_User(); $userId = $userModel->insert($props); $userData = $userModel->find($userId)->current(); $this->insert(array( 'vimeo_id' => $vimeoId, 'access_token' => $accessToken->getToken(), 'access_token_secret' => $accessToken->getTokenSecret(), 'user_id' => $userId )); $this->getObserver('Authenticatable')->updateLoginStats($userId); return $userData; }
[ "public", "function", "createNew", "(", "$", "vimeoId", ",", "Zend_Oauth_Token_Access", "$", "accessToken", ",", "array", "$", "props", ")", "{", "// first save the new user", "$", "userModel", "=", "new", "Model_User", "(", ")", ";", "$", "userId", "=", "$", ...
Store a new user. This creates a new AuthVimeo record, but also a new user record. @param String $vimeoId Vimeo user id @param Zend_Oauth_Token_Access $accessToken oAuth access token @param Array $props Properties received from Vimeo @return Garp_Db_Table_Row The new user data
[ "Store", "a", "new", "user", ".", "This", "creates", "a", "new", "AuthVimeo", "record", "but", "also", "a", "new", "user", "record", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db/AuthVimeo.php#L28-L42
train
grrr-amsterdam/garp3
library/Garp/Util/SimpleMail.php
Garp_Util_SimpleMail.setFrom
public function setFrom($from) { if (!is_array($from)) { $from = array($from, ''); } $this->_params['from'] = $from; return $this; }
php
public function setFrom($from) { if (!is_array($from)) { $from = array($from, ''); } $this->_params['from'] = $from; return $this; }
[ "public", "function", "setFrom", "(", "$", "from", ")", "{", "if", "(", "!", "is_array", "(", "$", "from", ")", ")", "{", "$", "from", "=", "array", "(", "$", "from", ",", "''", ")", ";", "}", "$", "this", "->", "_params", "[", "'from'", "]", ...
Set from address @param Mixed $from @return $this
[ "Set", "from", "address" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Util/SimpleMail.php#L131-L137
train
grrr-amsterdam/garp3
library/Garp/Util/SimpleMail.php
Garp_Util_SimpleMail.setTo
public function setTo($to) { if (!is_array($to)) { $to = array($to, ''); } $this->_params['to'] = $to; return $this; }
php
public function setTo($to) { if (!is_array($to)) { $to = array($to, ''); } $this->_params['to'] = $to; return $this; }
[ "public", "function", "setTo", "(", "$", "to", ")", "{", "if", "(", "!", "is_array", "(", "$", "to", ")", ")", "{", "$", "to", "=", "array", "(", "$", "to", ",", "''", ")", ";", "}", "$", "this", "->", "_params", "[", "'to'", "]", "=", "$",...
Set to address @param Mixed $to @return $this
[ "Set", "to", "address" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Util/SimpleMail.php#L154-L160
train
grrr-amsterdam/garp3
library/Garp/Util/SimpleMail.php
Garp_Util_SimpleMail.getAlias
public function getAlias($key) { return !empty($this->_aliases[$key]) ? $this->_aliases[$key] : ucfirst($key); }
php
public function getAlias($key) { return !empty($this->_aliases[$key]) ? $this->_aliases[$key] : ucfirst($key); }
[ "public", "function", "getAlias", "(", "$", "key", ")", "{", "return", "!", "empty", "(", "$", "this", "->", "_aliases", "[", "$", "key", "]", ")", "?", "$", "this", "->", "_aliases", "[", "$", "key", "]", ":", "ucfirst", "(", "$", "key", ")", ...
Get an alias for a certain posted key @param String $key @return String Alias
[ "Get", "an", "alias", "for", "a", "certain", "posted", "key" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Util/SimpleMail.php#L199-L201
train
grrr-amsterdam/garp3
library/Garp/Util/SimpleMail.php
Garp_Util_SimpleMail.isValid
public function isValid(array $requiredFields = array()) { // check if all values required to send the mail are set if (empty($this->_params['body']) || empty($this->_params['from']) || empty($this->_params['to']) || empty($this->_params['subject']) ) { $this->addError('Not all required mail parameters were given.'); return false; } // check that at least 1 second passed from form rendering to form submit if (array_key_exists(self::TIMESTAMP_KEY, $this->_postParams) && time()-$this->_postParams[self::TIMESTAMP_KEY] <= 1 ) { $this->addError('Timestamp difference is less than or equal to 1 second.'); return false; } // check if the honeypot was filled if (array_key_exists(self::HONEYPOT_KEY, $this->_postParams) && !empty($this->_postParams[self::HONEYPOT_KEY]) ) { $this->addError('Honeypot was filled.'); return false; } // check if all required fields were filled foreach ($requiredFields as $field) { if (empty($this->_postParams[$field])) { $this->addError('Required field ' . $field . ' is empty.'); return false; } } return true; }
php
public function isValid(array $requiredFields = array()) { // check if all values required to send the mail are set if (empty($this->_params['body']) || empty($this->_params['from']) || empty($this->_params['to']) || empty($this->_params['subject']) ) { $this->addError('Not all required mail parameters were given.'); return false; } // check that at least 1 second passed from form rendering to form submit if (array_key_exists(self::TIMESTAMP_KEY, $this->_postParams) && time()-$this->_postParams[self::TIMESTAMP_KEY] <= 1 ) { $this->addError('Timestamp difference is less than or equal to 1 second.'); return false; } // check if the honeypot was filled if (array_key_exists(self::HONEYPOT_KEY, $this->_postParams) && !empty($this->_postParams[self::HONEYPOT_KEY]) ) { $this->addError('Honeypot was filled.'); return false; } // check if all required fields were filled foreach ($requiredFields as $field) { if (empty($this->_postParams[$field])) { $this->addError('Required field ' . $field . ' is empty.'); return false; } } return true; }
[ "public", "function", "isValid", "(", "array", "$", "requiredFields", "=", "array", "(", ")", ")", "{", "// check if all values required to send the mail are set", "if", "(", "empty", "(", "$", "this", "->", "_params", "[", "'body'", "]", ")", "||", "empty", "...
Check if the submitted data is valid @param Array $requiredFields @return Boolean description
[ "Check", "if", "the", "submitted", "data", "is", "valid" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Util/SimpleMail.php#L229-L264
train
grrr-amsterdam/garp3
library/Garp/Util/SimpleMail.php
Garp_Util_SimpleMail.composeListFromPost
public function composeListFromPost(array $postParams) { $out = 'De volgende waardes zijn ingevuld:'; $out .= self::NEWLINE . self::NEWLINE; foreach ($postParams as $key => $value) { if (in_array($key, $this->_skippableKeys)) { continue; } if (is_numeric($value) && ($value == 1 || $value == 0)) { /** * @todo Do we have to internationalize this? */ $value = (int)$value ? 'ja' : 'nee'; } $out .= '- ' . $this->getAlias($key) . ': ' . $value . self::NEWLINE; } $out .= self::NEWLINE; return $out; }
php
public function composeListFromPost(array $postParams) { $out = 'De volgende waardes zijn ingevuld:'; $out .= self::NEWLINE . self::NEWLINE; foreach ($postParams as $key => $value) { if (in_array($key, $this->_skippableKeys)) { continue; } if (is_numeric($value) && ($value == 1 || $value == 0)) { /** * @todo Do we have to internationalize this? */ $value = (int)$value ? 'ja' : 'nee'; } $out .= '- ' . $this->getAlias($key) . ': ' . $value . self::NEWLINE; } $out .= self::NEWLINE; return $out; }
[ "public", "function", "composeListFromPost", "(", "array", "$", "postParams", ")", "{", "$", "out", "=", "'De volgende waardes zijn ingevuld:'", ";", "$", "out", ".=", "self", "::", "NEWLINE", ".", "self", "::", "NEWLINE", ";", "foreach", "(", "$", "postParams...
Create a list of values from posted variables @param Array $postParams @return String
[ "Create", "a", "list", "of", "values", "from", "posted", "variables" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Util/SimpleMail.php#L272-L289
train
grrr-amsterdam/garp3
library/Garp/Cli/Command/Env.php
Garp_Cli_Command_Env.setUnderConstruction
public function setUnderConstruction(array $args = array()) { $enabled = empty($args) ? true : !in_array(current($args), array(0, false, 'false', '0')); Garp_Cli::lineOut( Zend_Registry::get('config')->app->name . ' is' . ($enabled ? '' : ' no longer') . ' under construction' ); return Garp_Application::setUnderConstruction($enabled); }
php
public function setUnderConstruction(array $args = array()) { $enabled = empty($args) ? true : !in_array(current($args), array(0, false, 'false', '0')); Garp_Cli::lineOut( Zend_Registry::get('config')->app->name . ' is' . ($enabled ? '' : ' no longer') . ' under construction' ); return Garp_Application::setUnderConstruction($enabled); }
[ "public", "function", "setUnderConstruction", "(", "array", "$", "args", "=", "array", "(", ")", ")", "{", "$", "enabled", "=", "empty", "(", "$", "args", ")", "?", "true", ":", "!", "in_array", "(", "current", "(", "$", "args", ")", ",", "array", ...
Toggle wether the app is under construction @param array $args Accept "false", "0", 0, and false as disablers. @return bool
[ "Toggle", "wether", "the", "app", "is", "under", "construction" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Env.php#L28-L35
train
grrr-amsterdam/garp3
library/Garp/Util/FullUrl.php
Garp_Util_FullUrl._createFullUrl
protected function _createFullUrl($route) { $route = $this->_resolveRoute($route); $httpHost = $this->_getHttpHost(); $url = $this->_omitProtocol ? '' : $this->_getScheme() . ':'; $url .= '//' . $httpHost . $route; return $url; }
php
protected function _createFullUrl($route) { $route = $this->_resolveRoute($route); $httpHost = $this->_getHttpHost(); $url = $this->_omitProtocol ? '' : $this->_getScheme() . ':'; $url .= '//' . $httpHost . $route; return $url; }
[ "protected", "function", "_createFullUrl", "(", "$", "route", ")", "{", "$", "route", "=", "$", "this", "->", "_resolveRoute", "(", "$", "route", ")", ";", "$", "httpHost", "=", "$", "this", "->", "_getHttpHost", "(", ")", ";", "$", "url", "=", "$", ...
Create full URL @param string $route @return string
[ "Create", "full", "URL" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Util/FullUrl.php#L73-L80
train
grrr-amsterdam/garp3
library/Garp/Application/Bootstrap/Bootstrap.php
Garp_Application_Bootstrap_Bootstrap._initEssentialGarpHelpers
protected function _initEssentialGarpHelpers() { // Action helpers Zend_Controller_Action_HelperBroker::addPath( GARP_APPLICATION_PATH . '/../library/Garp/Controller/Helper', 'Garp_Controller_Helper' ); Zend_Controller_Action_HelperBroker::addPath( APPLICATION_PATH . '/../library/App/Controller/Helper', 'App_Controller_Helper' ); // View helpers $this->bootstrap('View'); $this->getResource('View')->addHelperPath( GARP_APPLICATION_PATH . '/modules/g/views/helpers', 'G_View_Helper' ); $this->getResource('View')->addHelperPath( APPLICATION_PATH . '/modules/default/views/helpers', 'App_View_Helper' ); }
php
protected function _initEssentialGarpHelpers() { // Action helpers Zend_Controller_Action_HelperBroker::addPath( GARP_APPLICATION_PATH . '/../library/Garp/Controller/Helper', 'Garp_Controller_Helper' ); Zend_Controller_Action_HelperBroker::addPath( APPLICATION_PATH . '/../library/App/Controller/Helper', 'App_Controller_Helper' ); // View helpers $this->bootstrap('View'); $this->getResource('View')->addHelperPath( GARP_APPLICATION_PATH . '/modules/g/views/helpers', 'G_View_Helper' ); $this->getResource('View')->addHelperPath( APPLICATION_PATH . '/modules/default/views/helpers', 'App_View_Helper' ); }
[ "protected", "function", "_initEssentialGarpHelpers", "(", ")", "{", "// Action helpers", "Zend_Controller_Action_HelperBroker", "::", "addPath", "(", "GARP_APPLICATION_PATH", ".", "'/../library/Garp/Controller/Helper'", ",", "'Garp_Controller_Helper'", ")", ";", "Zend_Controller...
Load essential Garp Helpers @return void
[ "Load", "essential", "Garp", "Helpers" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Application/Bootstrap/Bootstrap.php#L30-L51
train
grrr-amsterdam/garp3
library/Garp/Application/Bootstrap/Bootstrap.php
Garp_Application_Bootstrap_Bootstrap._initConfig
protected function _initConfig() { $this->bootstrap('db'); $this->bootstrap('locale'); if (!class_exists('Model_Info')) { return; } try { $staticConfig = Zend_Registry::get('config'); $infoModel = $this->_getInfoModel(); $dynamicConfig = $infoModel->fetchAsConfig(null, APPLICATION_ENV); // Very sneakily bypass 'readOnly' if ($staticConfig->readOnly()) { $staticConfig = new Zend_Config($staticConfig->toArray(), APPLICATION_ENV, true); } $staticConfig->merge($dynamicConfig); $staticConfig->setReadOnly(); Zend_Registry::set('config', $staticConfig); } catch(Exception $e) { $msg = $e->getMessage(); if (strpos($msg, 'Unknown database') === false && strpos($msg, "doesn't exist") === false ) { throw $e; } } }
php
protected function _initConfig() { $this->bootstrap('db'); $this->bootstrap('locale'); if (!class_exists('Model_Info')) { return; } try { $staticConfig = Zend_Registry::get('config'); $infoModel = $this->_getInfoModel(); $dynamicConfig = $infoModel->fetchAsConfig(null, APPLICATION_ENV); // Very sneakily bypass 'readOnly' if ($staticConfig->readOnly()) { $staticConfig = new Zend_Config($staticConfig->toArray(), APPLICATION_ENV, true); } $staticConfig->merge($dynamicConfig); $staticConfig->setReadOnly(); Zend_Registry::set('config', $staticConfig); } catch(Exception $e) { $msg = $e->getMessage(); if (strpos($msg, 'Unknown database') === false && strpos($msg, "doesn't exist") === false ) { throw $e; } } }
[ "protected", "function", "_initConfig", "(", ")", "{", "$", "this", "->", "bootstrap", "(", "'db'", ")", ";", "$", "this", "->", "bootstrap", "(", "'locale'", ")", ";", "if", "(", "!", "class_exists", "(", "'Model_Info'", ")", ")", "{", "return", ";", ...
Combine the static info found in application.ini with the dynamic info found in the Info table. @return void
[ "Combine", "the", "static", "info", "found", "in", "application", ".", "ini", "with", "the", "dynamic", "info", "found", "in", "the", "Info", "table", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Application/Bootstrap/Bootstrap.php#L59-L86
train
grrr-amsterdam/garp3
library/Garp/Assets/Minifier.php
Garp_Assets_Minifier.minifyJs
public function minifyJs($sourceFileList, $targetFile) { $sourceFileList = (array)$sourceFileList; $sourceFileList = array_map(array($this, '_createFullPath'), $sourceFileList); $sourceFileList = implode(' ', $sourceFileList); $targetFile = $this->_createFullPath($targetFile); $uglifyJsCommand = 'uglifyjs '.$sourceFileList.' -o '.$targetFile.' -c -m'; `$uglifyJsCommand`; }
php
public function minifyJs($sourceFileList, $targetFile) { $sourceFileList = (array)$sourceFileList; $sourceFileList = array_map(array($this, '_createFullPath'), $sourceFileList); $sourceFileList = implode(' ', $sourceFileList); $targetFile = $this->_createFullPath($targetFile); $uglifyJsCommand = 'uglifyjs '.$sourceFileList.' -o '.$targetFile.' -c -m'; `$uglifyJsCommand`; }
[ "public", "function", "minifyJs", "(", "$", "sourceFileList", ",", "$", "targetFile", ")", "{", "$", "sourceFileList", "=", "(", "array", ")", "$", "sourceFileList", ";", "$", "sourceFileList", "=", "array_map", "(", "array", "(", "$", "this", ",", "'_crea...
Minify and concat a bunch of Javascript files into one tiny little file. @param Array|String $sourceFileList The original files @param String $targetFile The target filename @return Boolean @todo Add option that suppresses output
[ "Minify", "and", "concat", "a", "bunch", "of", "Javascript", "files", "into", "one", "tiny", "little", "file", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Assets/Minifier.php#L54-L62
train
grrr-amsterdam/garp3
library/Garp/Browsebox/Factory.php
Garp_Browsebox_Factory.create
public final function create($id) { $method = 'create'.ucfirst($id); if (method_exists($this, $method)) { return $this->$method(); } throw new Garp_Browsebox_Exception('No initialization method for id "'.$id.'"'); }
php
public final function create($id) { $method = 'create'.ucfirst($id); if (method_exists($this, $method)) { return $this->$method(); } throw new Garp_Browsebox_Exception('No initialization method for id "'.$id.'"'); }
[ "public", "final", "function", "create", "(", "$", "id", ")", "{", "$", "method", "=", "'create'", ".", "ucfirst", "(", "$", "id", ")", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "return", "$", "this", "...
Return a Garp_Browsebox object based on App_Browsebox_Config. This factory assumes its existence, so an error will be thrown if it cannot be loaded. @param String $id The browsebox id @return Garp_Browsebox
[ "Return", "a", "Garp_Browsebox", "object", "based", "on", "App_Browsebox_Config", ".", "This", "factory", "assumes", "its", "existence", "so", "an", "error", "will", "be", "thrown", "if", "it", "cannot", "be", "loaded", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Browsebox/Factory.php#L20-L26
train
grrr-amsterdam/garp3
library/Garp/Spawn/Fields.php
Garp_Spawn_Fields.add
public function add($origin, $name, array $params = array()) { if (!$this->exists($name)) { $field = new Garp_Spawn_Field($origin, $name, $params); if ($origin === 'default') array_unshift($this->_fields, $field); else $this->_fields[] = $field; } else throw new Exception("The '{$name}' field is already registered for this model."); }
php
public function add($origin, $name, array $params = array()) { if (!$this->exists($name)) { $field = new Garp_Spawn_Field($origin, $name, $params); if ($origin === 'default') array_unshift($this->_fields, $field); else $this->_fields[] = $field; } else throw new Exception("The '{$name}' field is already registered for this model."); }
[ "public", "function", "add", "(", "$", "origin", ",", "$", "name", ",", "array", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "!", "$", "this", "->", "exists", "(", "$", "name", ")", ")", "{", "$", "field", "=", "new", "Garp_Spaw...
Add a field to the fields registry. @param String $origin Context in which this field is added. Can be 'config', 'default', 'relation' or 'behavior'. @param String $name Field name.
[ "Add", "a", "field", "to", "the", "fields", "registry", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Spawn/Fields.php#L41-L50
train
grrr-amsterdam/garp3
library/Garp/Spawn/Fields.php
Garp_Spawn_Fields.delete
public function delete($name) { if ($this->exists($name)) { foreach ($this->_fields as $i => $field) { if ($field->name === $name) { unset($this->_fields[$i]); break; } } } else throw new Exception("The '{$name}' field is not registered for this model."); }
php
public function delete($name) { if ($this->exists($name)) { foreach ($this->_fields as $i => $field) { if ($field->name === $name) { unset($this->_fields[$i]); break; } } } else throw new Exception("The '{$name}' field is not registered for this model."); }
[ "public", "function", "delete", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "exists", "(", "$", "name", ")", ")", "{", "foreach", "(", "$", "this", "->", "_fields", "as", "$", "i", "=>", "$", "field", ")", "{", "if", "(", "$", "...
Delete a field from the fields registry. @param String $name Field name.
[ "Delete", "a", "field", "from", "the", "fields", "registry", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Spawn/Fields.php#L57-L66
train
grrr-amsterdam/garp3
library/Garp/Spawn/Fields.php
Garp_Spawn_Fields.alter
public function alter($name, $prop, $value) { foreach ($this->_fields as &$field) { if ($field->name === $name) { $field->{$prop} = $value; } } }
php
public function alter($name, $prop, $value) { foreach ($this->_fields as &$field) { if ($field->name === $name) { $field->{$prop} = $value; } } }
[ "public", "function", "alter", "(", "$", "name", ",", "$", "prop", ",", "$", "value", ")", "{", "foreach", "(", "$", "this", "->", "_fields", "as", "&", "$", "field", ")", "{", "if", "(", "$", "field", "->", "name", "===", "$", "name", ")", "{"...
Alter a field in the fields registry. @param String $name Field name. @param String $prop Field property name, f.i. 'type' @param Mixed $value The new field value
[ "Alter", "a", "field", "in", "the", "fields", "registry", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Spawn/Fields.php#L75-L81
train
grrr-amsterdam/garp3
library/Garp/Spawn/Fields.php
Garp_Spawn_Fields.isSuitableListFieldName
public function isSuitableListFieldName($listFieldName) { try { $field = $this->getField($listFieldName); } catch (Exception $e) { return; } if ($field && $field->isSuitableAsLabel()) { return true; } }
php
public function isSuitableListFieldName($listFieldName) { try { $field = $this->getField($listFieldName); } catch (Exception $e) { return; } if ($field && $field->isSuitableAsLabel()) { return true; } }
[ "public", "function", "isSuitableListFieldName", "(", "$", "listFieldName", ")", "{", "try", "{", "$", "field", "=", "$", "this", "->", "getField", "(", "$", "listFieldName", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", ";", ...
Checks wether a field can be used as list field. @param String $listFieldName @return Boolean
[ "Checks", "wether", "a", "field", "can", "be", "used", "as", "list", "field", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Spawn/Fields.php#L165-L175
train
grrr-amsterdam/garp3
library/Garp/Cli/Command/Permissions.php
Garp_Cli_Command_Permissions.set
public function set(array $args = array()) { if (!file_exists('application/data/cache') || !file_exists('application/data/logs') || !file_exists('public/uploads') ) { Garp_Cli::lineOut( 'It looks like there are no directories for me to set permissions on.', Garp_Cli::YELLOW ); return true; } Garp_Cli::lineOut('Setting permissions on writable folders...'); passthru('chmod -R 777 application/data/cache'); passthru('chmod -R 777 application/data/logs'); passthru('chmod -R 777 public/uploads'); Garp_Cli::lineOut('Done.'); Garp_Cli::lineOut(''); return true; }
php
public function set(array $args = array()) { if (!file_exists('application/data/cache') || !file_exists('application/data/logs') || !file_exists('public/uploads') ) { Garp_Cli::lineOut( 'It looks like there are no directories for me to set permissions on.', Garp_Cli::YELLOW ); return true; } Garp_Cli::lineOut('Setting permissions on writable folders...'); passthru('chmod -R 777 application/data/cache'); passthru('chmod -R 777 application/data/logs'); passthru('chmod -R 777 public/uploads'); Garp_Cli::lineOut('Done.'); Garp_Cli::lineOut(''); return true; }
[ "public", "function", "set", "(", "array", "$", "args", "=", "array", "(", ")", ")", "{", "if", "(", "!", "file_exists", "(", "'application/data/cache'", ")", "||", "!", "file_exists", "(", "'application/data/logs'", ")", "||", "!", "file_exists", "(", "'p...
Set permissions on certain folders @param array $args @return bool
[ "Set", "permissions", "on", "certain", "folders" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Permissions.php#L16-L35
train
grrr-amsterdam/garp3
library/Garp/Adobe/InDesign/Storage.php
Garp_Adobe_InDesign_Storage.createTmpDir
public static function createTmpDir() { $tmpDir = sys_get_temp_dir(); $tmpDir .= $tmpDir[strlen($tmpDir) - 1] !== '/' ? '/' : ''; $tmpDir .= uniqid() . '/'; if (mkdir($tmpDir)) { return $tmpDir; } else { throw new Exception('Could not create directory ' . $tmpDir); } }
php
public static function createTmpDir() { $tmpDir = sys_get_temp_dir(); $tmpDir .= $tmpDir[strlen($tmpDir) - 1] !== '/' ? '/' : ''; $tmpDir .= uniqid() . '/'; if (mkdir($tmpDir)) { return $tmpDir; } else { throw new Exception('Could not create directory ' . $tmpDir); } }
[ "public", "static", "function", "createTmpDir", "(", ")", "{", "$", "tmpDir", "=", "sys_get_temp_dir", "(", ")", ";", "$", "tmpDir", ".=", "$", "tmpDir", "[", "strlen", "(", "$", "tmpDir", ")", "-", "1", "]", "!==", "'/'", "?", "'/'", ":", "''", ";...
Creates a temporary directory for .idml construction. @return string The path to this dir, including trailing slash.
[ "Creates", "a", "temporary", "directory", "for", ".", "idml", "construction", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Adobe/InDesign/Storage.php#L28-L37
train