id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
46,500 | grrr-amsterdam/garp3 | application/modules/g/controllers/ExtController.php | G_ExtController._modifyAfterUpdate | protected function _modifyAfterUpdate($response, $request) {
if ($this->_methodFailed($response)) {
return $response;
}
$methodParts = explode('.', $request['method']);
$modelClass = Garp_Content_Api::modelAliasToClass(array_shift($methodParts));
$man = new Garp_Content_Manager($modelClass);
$rows = $man->fetch(
array(
'query' => array('id' => $request['params'][0]['rows']['id'])
)
);
$response['result'] = array(
'rows' => $rows
);
return $response;
} | php | protected function _modifyAfterUpdate($response, $request) {
if ($this->_methodFailed($response)) {
return $response;
}
$methodParts = explode('.', $request['method']);
$modelClass = Garp_Content_Api::modelAliasToClass(array_shift($methodParts));
$man = new Garp_Content_Manager($modelClass);
$rows = $man->fetch(
array(
'query' => array('id' => $request['params'][0]['rows']['id'])
)
);
$response['result'] = array(
'rows' => $rows
);
return $response;
} | [
"protected",
"function",
"_modifyAfterUpdate",
"(",
"$",
"response",
",",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_methodFailed",
"(",
"$",
"response",
")",
")",
"{",
"return",
"$",
"response",
";",
"}",
"$",
"methodParts",
"=",
"explode... | Modify results after update
@param Array $response The original response
@param Array $request The original request
@return String | [
"Modify",
"results",
"after",
"update"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/ExtController.php#L281-L297 |
46,501 | grrr-amsterdam/garp3 | library/Garp/Adobe/InDesign/SpreadNode.php | Garp_Adobe_InDesign_SpreadNode._getCoordinates | protected function _getCoordinates() {
$itemTransformString = (string)$this->_nodeConfig->attributes()->ItemTransform;
$itemTransformArray = explode(' ', $itemTransformString);
$coordinates = array(
'x' => $itemTransformArray[count($itemTransformArray) - 2],
'y' => $itemTransformArray[count($itemTransformArray) - 1]
);
return $coordinates;
} | php | protected function _getCoordinates() {
$itemTransformString = (string)$this->_nodeConfig->attributes()->ItemTransform;
$itemTransformArray = explode(' ', $itemTransformString);
$coordinates = array(
'x' => $itemTransformArray[count($itemTransformArray) - 2],
'y' => $itemTransformArray[count($itemTransformArray) - 1]
);
return $coordinates;
} | [
"protected",
"function",
"_getCoordinates",
"(",
")",
"{",
"$",
"itemTransformString",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"_nodeConfig",
"->",
"attributes",
"(",
")",
"->",
"ItemTransform",
";",
"$",
"itemTransformArray",
"=",
"explode",
"(",
"' '",
... | Get x- and y-coordinate of a node in a InDesign Spread that has an ItemTransform property.
@return array An associative array with keys 'x' and 'y'. | [
"Get",
"x",
"-",
"and",
"y",
"-",
"coordinate",
"of",
"a",
"node",
"in",
"a",
"InDesign",
"Spread",
"that",
"has",
"an",
"ItemTransform",
"property",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Adobe/InDesign/SpreadNode.php#L63-L72 |
46,502 | grrr-amsterdam/garp3 | application/modules/g/controllers/RestController.php | G_RestController._respondToError | protected function _respondToError($errorMessage, $httpCode) {
$this->_setHttpStatusCode($httpCode);
$this->view->result = array(
'success' => false,
'errorMessage' => $errorMessage
);
} | php | protected function _respondToError($errorMessage, $httpCode) {
$this->_setHttpStatusCode($httpCode);
$this->view->result = array(
'success' => false,
'errorMessage' => $errorMessage
);
} | [
"protected",
"function",
"_respondToError",
"(",
"$",
"errorMessage",
",",
"$",
"httpCode",
")",
"{",
"$",
"this",
"->",
"_setHttpStatusCode",
"(",
"$",
"httpCode",
")",
";",
"$",
"this",
"->",
"view",
"->",
"result",
"=",
"array",
"(",
"'success'",
"=>",
... | Format a response object for the view, and set the right error code
@param string $errorMessage
@param int $httpCode
@return void | [
"Format",
"a",
"response",
"object",
"for",
"the",
"view",
"and",
"set",
"the",
"right",
"error",
"code"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/RestController.php#L74-L80 |
46,503 | grrr-amsterdam/garp3 | application/modules/g/controllers/RestController.php | G_RestController._validateMethod | protected function _validateMethod($method) {
if (in_array(strtoupper($method), $this->_validMethods)) {
return true;
}
$exception = new Garp_Content_Api_Rest_Exception('Method not allowed');
$exception->setHttpStatusCode(405);
throw $exception;
} | php | protected function _validateMethod($method) {
if (in_array(strtoupper($method), $this->_validMethods)) {
return true;
}
$exception = new Garp_Content_Api_Rest_Exception('Method not allowed');
$exception->setHttpStatusCode(405);
throw $exception;
} | [
"protected",
"function",
"_validateMethod",
"(",
"$",
"method",
")",
"{",
"if",
"(",
"in_array",
"(",
"strtoupper",
"(",
"$",
"method",
")",
",",
"$",
"this",
"->",
"_validMethods",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"exception",
"=",
"new... | Wether the HTTP method is valid
@param string $method
@return bool | [
"Wether",
"the",
"HTTP",
"method",
"is",
"valid"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/RestController.php#L92-L99 |
46,504 | grrr-amsterdam/garp3 | application/modules/g/controllers/RestController.php | G_RestController._parsePostData | protected function _parsePostData() {
$postData = $this->getRequest()->getRawBody();
if (!$postData) {
return array();
}
try {
$postData = Zend_Json::decode($postData);
} catch (Zend_Json_Exception $e) {
throw new Garp_Content_Api_Rest_Exception(
sprintf(Garp_Content_Api_Rest::EXCEPTION_INVALID_JSON, $e->getMessage())
);
}
return $postData;
} | php | protected function _parsePostData() {
$postData = $this->getRequest()->getRawBody();
if (!$postData) {
return array();
}
try {
$postData = Zend_Json::decode($postData);
} catch (Zend_Json_Exception $e) {
throw new Garp_Content_Api_Rest_Exception(
sprintf(Garp_Content_Api_Rest::EXCEPTION_INVALID_JSON, $e->getMessage())
);
}
return $postData;
} | [
"protected",
"function",
"_parsePostData",
"(",
")",
"{",
"$",
"postData",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getRawBody",
"(",
")",
";",
"if",
"(",
"!",
"$",
"postData",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"try",
"... | Parses post data as json
@return array | [
"Parses",
"post",
"data",
"as",
"json"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/controllers/RestController.php#L117-L130 |
46,505 | grrr-amsterdam/garp3 | library/Garp/File/Unzipper.php | Garp_File_Unzipper.getUnpacked | public function getUnpacked() {
$tries = 0;
$obj = $this->_original;
while ($this->_dataLooksZipped($obj)) {
$unpacked = gzdecode($obj);
if (null === $unpacked || false === $unpacked) {
// If anything went wrong with decoding, return result of previous iteration
return $obj;
}
$obj = $unpacked;
$tries++;
if ($this->_maxDepthReached($tries)) {
// Zipped ridiculously deep? Screw that, return the original
return $this->_original;
}
}
return $obj;
} | php | public function getUnpacked() {
$tries = 0;
$obj = $this->_original;
while ($this->_dataLooksZipped($obj)) {
$unpacked = gzdecode($obj);
if (null === $unpacked || false === $unpacked) {
// If anything went wrong with decoding, return result of previous iteration
return $obj;
}
$obj = $unpacked;
$tries++;
if ($this->_maxDepthReached($tries)) {
// Zipped ridiculously deep? Screw that, return the original
return $this->_original;
}
}
return $obj;
} | [
"public",
"function",
"getUnpacked",
"(",
")",
"{",
"$",
"tries",
"=",
"0",
";",
"$",
"obj",
"=",
"$",
"this",
"->",
"_original",
";",
"while",
"(",
"$",
"this",
"->",
"_dataLooksZipped",
"(",
"$",
"obj",
")",
")",
"{",
"$",
"unpacked",
"=",
"gzdec... | Get unzipped data. Will recursively unpack data until it looks like it's no longer gzipped
@return string | [
"Get",
"unzipped",
"data",
".",
"Will",
"recursively",
"unpack",
"data",
"until",
"it",
"looks",
"like",
"it",
"s",
"no",
"longer",
"gzipped"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/File/Unzipper.php#L39-L59 |
46,506 | grrr-amsterdam/garp3 | library/Garp/Model/ReferenceMapLocalizer.php | Garp_Model_ReferenceMapLocalizer.populate | public function populate($relatedModel, $ruleKey = null) {
// Sanity check: does the model have a reference to the
// given model in the first place?
// This will throw an exception if not.
$relatedModel = $relatedModel instanceof Garp_Model_Db ? get_class($relatedModel) : $relatedModel;
$relatedModel = (substr($relatedModel, 0, 6) !== 'Model_' ? 'Model_' : '') . $relatedModel;
$ref = $this->_model->getReference($relatedModel, $ruleKey);
$locales = Garp_I18n::getLocales();
foreach ($locales as $locale) {
$factory = new Garp_I18n_ModelFactory($locale);
$localizedModel = $factory->getModel($relatedModel);
$localizedModelName = get_class($localizedModel);
$cleanLocalizedName = $localizedModel->getNameWithoutNamespace();
$this->_model->addReference(
$cleanLocalizedName,
$ref[Zend_Db_Table_Abstract::COLUMNS],
$localizedModelName,
$ref[Zend_Db_Table_Abstract::REF_COLUMNS]
);
}
return $this;
} | php | public function populate($relatedModel, $ruleKey = null) {
// Sanity check: does the model have a reference to the
// given model in the first place?
// This will throw an exception if not.
$relatedModel = $relatedModel instanceof Garp_Model_Db ? get_class($relatedModel) : $relatedModel;
$relatedModel = (substr($relatedModel, 0, 6) !== 'Model_' ? 'Model_' : '') . $relatedModel;
$ref = $this->_model->getReference($relatedModel, $ruleKey);
$locales = Garp_I18n::getLocales();
foreach ($locales as $locale) {
$factory = new Garp_I18n_ModelFactory($locale);
$localizedModel = $factory->getModel($relatedModel);
$localizedModelName = get_class($localizedModel);
$cleanLocalizedName = $localizedModel->getNameWithoutNamespace();
$this->_model->addReference(
$cleanLocalizedName,
$ref[Zend_Db_Table_Abstract::COLUMNS],
$localizedModelName,
$ref[Zend_Db_Table_Abstract::REF_COLUMNS]
);
}
return $this;
} | [
"public",
"function",
"populate",
"(",
"$",
"relatedModel",
",",
"$",
"ruleKey",
"=",
"null",
")",
"{",
"// Sanity check: does the model have a reference to the",
"// given model in the first place?",
"// This will throw an exception if not.",
"$",
"relatedModel",
"=",
"$",
"... | Populate the subject model's referenceMap with
localized versions of the given model.
@param String|Garp_Model_Db $relatedModel
@return Void | [
"Populate",
"the",
"subject",
"model",
"s",
"referenceMap",
"with",
"localized",
"versions",
"of",
"the",
"given",
"model",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/ReferenceMapLocalizer.php#L32-L53 |
46,507 | grrr-amsterdam/garp3 | library/Garp/Model/Db/Snippet.php | Garp_Model_Db_Snippet.fetchByIdentifier | public function fetchByIdentifier($identifier) {
if (!$identifier) {
throw new InvalidArgumentException('Snippet identifier is required');
}
$select = $this->select()->where('identifier = ?', $identifier);
if ($result = $this->fetchRow($select)) {
return $result;
}
$ignoreMissing = Zend_Registry::get('config')->snippets->ignoreMissing ?? false;
if (!$ignoreMissing) {
throw new Exception('Snippet not found: ' . $identifier);
}
// Return fallback row, where text is set to $identifier, in order to provide some fallback.
return $this->createRow([
'has_text' => 1,
'text' => $identifier,
]);
} | php | public function fetchByIdentifier($identifier) {
if (!$identifier) {
throw new InvalidArgumentException('Snippet identifier is required');
}
$select = $this->select()->where('identifier = ?', $identifier);
if ($result = $this->fetchRow($select)) {
return $result;
}
$ignoreMissing = Zend_Registry::get('config')->snippets->ignoreMissing ?? false;
if (!$ignoreMissing) {
throw new Exception('Snippet not found: ' . $identifier);
}
// Return fallback row, where text is set to $identifier, in order to provide some fallback.
return $this->createRow([
'has_text' => 1,
'text' => $identifier,
]);
} | [
"public",
"function",
"fetchByIdentifier",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"!",
"$",
"identifier",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Snippet identifier is required'",
")",
";",
"}",
"$",
"select",
"=",
"$",
"this",
"->",... | Fetch a snippet by its identifier
@param string $identifier
@return Garp_Db_Table_Row | [
"Fetch",
"a",
"snippet",
"by",
"its",
"identifier"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db/Snippet.php#L16-L33 |
46,508 | grrr-amsterdam/garp3 | library/Garp/Controller/Plugin/I18n.php | Garp_Controller_Plugin_I18n.routeShutdown | public function routeShutdown(Zend_Controller_Request_Abstract $request) {
$config = Zend_Registry::get('config');
$frontController = Zend_Controller_Front::getInstance();
$params = $request->getParams();
$registry = Zend_Registry::getInstance();
// Steps setting the locale.
// 1. Default language is set in config
// 2. TLD in host header
// 3. Locale params specified in request
$locale = $registry->get('Zend_Locale');
// Check host header TLD.
$tld = preg_replace('/^.*\./', '', $request->getHeader('Host'));
// Provide a list of tld's and their corresponding default languages
$tldLocales = $frontController->getParam('tldLocales');
if (is_array($tldLocales) && array_key_exists($tld, $tldLocales)) {
// The TLD in the request matches one of our specified TLD -> Locales
$locale->setLocale(strtolower($tldLocales[$tld]));
} elseif (isset($params['locale'])) {
// There is a locale specified in the request params.
$locale->setLocale(strtolower($params['locale']));
}
// Now that our locale is set, let's check which language has been selected
// and try to load a translation file for it.
$language = $locale->getLanguage();
$translate = Garp_I18n::getTranslateByLocale($locale);
Zend_Registry::set('Zend_Translate', $translate);
Zend_Form::setDefaultTranslator($translate);
if (!$config->resources->router->locale->enabled) {
return;
}
$path = '/' . ltrim($request->getPathInfo(), '/\\');
// If the language is in the path, then we will want to set the baseUrl
// to the specified language.
$langIsInUrl = preg_match('/^\/' . $language . '\/?/', $path);
$uiDefaultLangIsInUrl = false;
$uiDefaultLanguage = false;
if (isset($config->resources->locale->uiDefault)) {
$uiDefaultLanguage = $config->resources->locale->uiDefault;
$uiDefaultLangIsInUrl = preg_match('/^\/' . $uiDefaultLanguage . '\/?/', $path);
}
if ($langIsInUrl || $uiDefaultLangIsInUrl) {
if ($uiDefaultLangIsInUrl) {
$frontController->setBaseUrl(
$frontController->getBaseUrl() . '/' . $uiDefaultLanguage
);
} else {
$frontController->setBaseUrl($frontController->getBaseUrl() . '/' . $language);
}
} elseif (!empty($config->resources->router->locale->enabled)
&& $config->resources->router->locale->enabled
) {
$redirectUrl = '/' . $language . $path;
if ($frontController->getRouter()->getCurrentRouteName() === 'admin'
&& !empty($config->resources->locale->adminDefault)
) {
$adminDefaultLanguage = $config->resources->locale->adminDefault;
$redirectUrl = '/' . $adminDefaultLanguage . $path;
} elseif ($uiDefaultLanguage) {
$redirectUrl = '/' . $uiDefaultLanguage . $path;
}
if ($request->getQuery()) {
$redirectUrl .= '?' . http_build_query($request->getQuery());
}
$this->getResponse()
->setRedirect($redirectUrl, 301);
}
} | php | public function routeShutdown(Zend_Controller_Request_Abstract $request) {
$config = Zend_Registry::get('config');
$frontController = Zend_Controller_Front::getInstance();
$params = $request->getParams();
$registry = Zend_Registry::getInstance();
// Steps setting the locale.
// 1. Default language is set in config
// 2. TLD in host header
// 3. Locale params specified in request
$locale = $registry->get('Zend_Locale');
// Check host header TLD.
$tld = preg_replace('/^.*\./', '', $request->getHeader('Host'));
// Provide a list of tld's and their corresponding default languages
$tldLocales = $frontController->getParam('tldLocales');
if (is_array($tldLocales) && array_key_exists($tld, $tldLocales)) {
// The TLD in the request matches one of our specified TLD -> Locales
$locale->setLocale(strtolower($tldLocales[$tld]));
} elseif (isset($params['locale'])) {
// There is a locale specified in the request params.
$locale->setLocale(strtolower($params['locale']));
}
// Now that our locale is set, let's check which language has been selected
// and try to load a translation file for it.
$language = $locale->getLanguage();
$translate = Garp_I18n::getTranslateByLocale($locale);
Zend_Registry::set('Zend_Translate', $translate);
Zend_Form::setDefaultTranslator($translate);
if (!$config->resources->router->locale->enabled) {
return;
}
$path = '/' . ltrim($request->getPathInfo(), '/\\');
// If the language is in the path, then we will want to set the baseUrl
// to the specified language.
$langIsInUrl = preg_match('/^\/' . $language . '\/?/', $path);
$uiDefaultLangIsInUrl = false;
$uiDefaultLanguage = false;
if (isset($config->resources->locale->uiDefault)) {
$uiDefaultLanguage = $config->resources->locale->uiDefault;
$uiDefaultLangIsInUrl = preg_match('/^\/' . $uiDefaultLanguage . '\/?/', $path);
}
if ($langIsInUrl || $uiDefaultLangIsInUrl) {
if ($uiDefaultLangIsInUrl) {
$frontController->setBaseUrl(
$frontController->getBaseUrl() . '/' . $uiDefaultLanguage
);
} else {
$frontController->setBaseUrl($frontController->getBaseUrl() . '/' . $language);
}
} elseif (!empty($config->resources->router->locale->enabled)
&& $config->resources->router->locale->enabled
) {
$redirectUrl = '/' . $language . $path;
if ($frontController->getRouter()->getCurrentRouteName() === 'admin'
&& !empty($config->resources->locale->adminDefault)
) {
$adminDefaultLanguage = $config->resources->locale->adminDefault;
$redirectUrl = '/' . $adminDefaultLanguage . $path;
} elseif ($uiDefaultLanguage) {
$redirectUrl = '/' . $uiDefaultLanguage . $path;
}
if ($request->getQuery()) {
$redirectUrl .= '?' . http_build_query($request->getQuery());
}
$this->getResponse()
->setRedirect($redirectUrl, 301);
}
} | [
"public",
"function",
"routeShutdown",
"(",
"Zend_Controller_Request_Abstract",
"$",
"request",
")",
"{",
"$",
"config",
"=",
"Zend_Registry",
"::",
"get",
"(",
"'config'",
")",
";",
"$",
"frontController",
"=",
"Zend_Controller_Front",
"::",
"getInstance",
"(",
"... | Sets the application locale and translation based on the locale param, if
one is not provided it defaults to english
@param Zend_Controller_Request_Abstract $request
@return Void | [
"Sets",
"the",
"application",
"locale",
"and",
"translation",
"based",
"on",
"the",
"locale",
"param",
"if",
"one",
"is",
"not",
"provided",
"it",
"defaults",
"to",
"english"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Controller/Plugin/I18n.php#L21-L92 |
46,509 | grrr-amsterdam/garp3 | library/Garp/Browsebox/Filter/Where.php | Garp_Browsebox_Filter_Where.modifySelect | public function modifySelect(Zend_Db_Select &$select) {
foreach ($this->_config as $i => $condition) {
$select->where($condition, $this->_values[$i]);
}
} | php | public function modifySelect(Zend_Db_Select &$select) {
foreach ($this->_config as $i => $condition) {
$select->where($condition, $this->_values[$i]);
}
} | [
"public",
"function",
"modifySelect",
"(",
"Zend_Db_Select",
"&",
"$",
"select",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_config",
"as",
"$",
"i",
"=>",
"$",
"condition",
")",
"{",
"$",
"select",
"->",
"where",
"(",
"$",
"condition",
",",
"$",
... | Modify the Select object
@param Zend_Db_Select $select
@return Void | [
"Modify",
"the",
"Select",
"object"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Browsebox/Filter/Where.php#L47-L51 |
46,510 | grrr-amsterdam/garp3 | library/Garp/Model/Db/ClusterServer.php | Garp_Model_Db_ClusterServer.checkIn | public function checkIn() {
$now = date('Y-m-d H:i:s');
$serverRow = $this->_fetchServerRow();
if (!$serverRow) {
$serverRow = $this->createRow();
$serverRow->hostname = gethostname();
$lastCheckIn = $now;
} else {
$lastCheckIn = $serverRow->modified;
}
// set the modified date manually, to make sure the record is updated.
$serverRow->modified = $now;
$serverId = $serverRow->save();
return array(
$serverId,
$lastCheckIn
);
} | php | public function checkIn() {
$now = date('Y-m-d H:i:s');
$serverRow = $this->_fetchServerRow();
if (!$serverRow) {
$serverRow = $this->createRow();
$serverRow->hostname = gethostname();
$lastCheckIn = $now;
} else {
$lastCheckIn = $serverRow->modified;
}
// set the modified date manually, to make sure the record is updated.
$serverRow->modified = $now;
$serverId = $serverRow->save();
return array(
$serverId,
$lastCheckIn
);
} | [
"public",
"function",
"checkIn",
"(",
")",
"{",
"$",
"now",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
")",
";",
"$",
"serverRow",
"=",
"$",
"this",
"->",
"_fetchServerRow",
"(",
")",
";",
"if",
"(",
"!",
"$",
"serverRow",
")",
"{",
"$",
"serverRow",
"=",
... | Registers this server node in the ClusterServer table, and returns information about the current server.
@return Array Numeric array, containing the serverId and the last check-in time. | [
"Registers",
"this",
"server",
"node",
"in",
"the",
"ClusterServer",
"table",
"and",
"returns",
"information",
"about",
"the",
"current",
"server",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db/ClusterServer.php#L15-L35 |
46,511 | grrr-amsterdam/garp3 | application/modules/g/views/helpers/Image.php | G_View_Helper_Image.render | public function render($image, $template = null, $htmlAttribs = array(), $partial = null) {
if ($this->_isFilename($image)) {
// When calling for a static image, you can use the second param as $htmlAttribs.
$htmlAttribs = $template ?: array();
return $this->_renderStatic($image, $htmlAttribs);
}
if (!$template) {
throw new Exception(self::ERROR_SCALING_TEMPLATE_MISSING);
}
return $this->_renderUpload($image, $template, $htmlAttribs, $partial);
} | php | public function render($image, $template = null, $htmlAttribs = array(), $partial = null) {
if ($this->_isFilename($image)) {
// When calling for a static image, you can use the second param as $htmlAttribs.
$htmlAttribs = $template ?: array();
return $this->_renderStatic($image, $htmlAttribs);
}
if (!$template) {
throw new Exception(self::ERROR_SCALING_TEMPLATE_MISSING);
}
return $this->_renderUpload($image, $template, $htmlAttribs, $partial);
} | [
"public",
"function",
"render",
"(",
"$",
"image",
",",
"$",
"template",
"=",
"null",
",",
"$",
"htmlAttribs",
"=",
"array",
"(",
")",
",",
"$",
"partial",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_isFilename",
"(",
"$",
"image",
")",
... | Render an HTML img tag.
@param mixed $image Database id for uploads, or a filename
in case of a static image asset.
@param string $template The id of the scaling template as defined in application.ini.
For instance: 'cms_preview'
@param array $htmlAttribs HTML attributes on the image tag
@param string $partial Custom partial for rendering an upload
@return string | [
"Render",
"an",
"HTML",
"img",
"tag",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Image.php#L46-L56 |
46,512 | grrr-amsterdam/garp3 | application/modules/g/views/helpers/Image.php | G_View_Helper_Image.getUrl | public function getUrl($image, $template = null) {
if ($this->_isFilename($image)) {
return $this->getStaticUrl($image);
}
if (!$template) {
throw new Exception(self::ERROR_SCALING_TEMPLATE_MISSING);
}
return $this->getScaledUrl($image, $template);
} | php | public function getUrl($image, $template = null) {
if ($this->_isFilename($image)) {
return $this->getStaticUrl($image);
}
if (!$template) {
throw new Exception(self::ERROR_SCALING_TEMPLATE_MISSING);
}
return $this->getScaledUrl($image, $template);
} | [
"public",
"function",
"getUrl",
"(",
"$",
"image",
",",
"$",
"template",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_isFilename",
"(",
"$",
"image",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getStaticUrl",
"(",
"$",
"image",
")",
";",... | Return URL of scaled image
@param mixed $image Database id for uploads, or a filename
in case of a static image asset.
@param string $template The id of the scaling template as defined in application.ini.
For instance: 'cms_preview'
@return string | [
"Return",
"URL",
"of",
"scaled",
"image"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Image.php#L67-L75 |
46,513 | grrr-amsterdam/garp3 | application/modules/g/views/helpers/Image.php | G_View_Helper_Image.getSourceUrl | public function getSourceUrl($filename) {
if (!$this->_isFilename($filename)) {
throw new Exception(self::ERROR_ARGUMENT_IS_NOT_FILENAME);
}
$file = new Garp_Image_File();
return $file->getUrl($filename);
} | php | public function getSourceUrl($filename) {
if (!$this->_isFilename($filename)) {
throw new Exception(self::ERROR_ARGUMENT_IS_NOT_FILENAME);
}
$file = new Garp_Image_File();
return $file->getUrl($filename);
} | [
"public",
"function",
"getSourceUrl",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_isFilename",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"self",
"::",
"ERROR_ARGUMENT_IS_NOT_FILENAME",
")",
";",
"}",
... | Returns the url to the source file of an upload.
@param string $filename The filename of the upload, without the path.
@return string | [
"Returns",
"the",
"url",
"to",
"the",
"source",
"file",
"of",
"an",
"upload",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Image.php#L105-L111 |
46,514 | grrr-amsterdam/garp3 | application/modules/g/views/helpers/Image.php | G_View_Helper_Image.getSourceUrlById | public function getSourceUrlById($id) {
$image = instance(new Model_Image)->fetchById($id);
if (!$image) {
throw new InvalidArgumentException(self::ERROR_IMAGE_NOT_FOUND);
}
return $this->getSourceUrl($image['filename']);
} | php | public function getSourceUrlById($id) {
$image = instance(new Model_Image)->fetchById($id);
if (!$image) {
throw new InvalidArgumentException(self::ERROR_IMAGE_NOT_FOUND);
}
return $this->getSourceUrl($image['filename']);
} | [
"public",
"function",
"getSourceUrlById",
"(",
"$",
"id",
")",
"{",
"$",
"image",
"=",
"instance",
"(",
"new",
"Model_Image",
")",
"->",
"fetchById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"image",
")",
"{",
"throw",
"new",
"InvalidArgumentExce... | Returns the url to the source file of an upload by id
@param int $id The id of the upload
@return string | [
"Returns",
"the",
"url",
"to",
"the",
"source",
"file",
"of",
"an",
"upload",
"by",
"id"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Image.php#L119-L125 |
46,515 | grrr-amsterdam/garp3 | application/modules/g/views/helpers/Image.php | G_View_Helper_Image._renderStatic | protected function _renderStatic($filename, array $htmlAttribs = array()) {
$file = new Garp_Image_File(Garp_File::FILE_VARIANT_STATIC);
$src = $file->getUrl($filename);
if (!array_key_exists('alt', $htmlAttribs)) {
$htmlAttribs['alt'] = '';
}
return $this->view->htmlImage($src, $htmlAttribs);
} | php | protected function _renderStatic($filename, array $htmlAttribs = array()) {
$file = new Garp_Image_File(Garp_File::FILE_VARIANT_STATIC);
$src = $file->getUrl($filename);
if (!array_key_exists('alt', $htmlAttribs)) {
$htmlAttribs['alt'] = '';
}
return $this->view->htmlImage($src, $htmlAttribs);
} | [
"protected",
"function",
"_renderStatic",
"(",
"$",
"filename",
",",
"array",
"$",
"htmlAttribs",
"=",
"array",
"(",
")",
")",
"{",
"$",
"file",
"=",
"new",
"Garp_Image_File",
"(",
"Garp_File",
"::",
"FILE_VARIANT_STATIC",
")",
";",
"$",
"src",
"=",
"$",
... | Render a static image
@param string $filename
@param array $htmlAttribs
@return string | [
"Render",
"a",
"static",
"image"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Image.php#L144-L153 |
46,516 | grrr-amsterdam/garp3 | application/modules/g/views/helpers/Image.php | G_View_Helper_Image._renderUpload | protected function _renderUpload(
$imageIdOrRecord, $template = null, array $htmlAttribs = array(), $partial = ''
) {
if (!empty($template)) {
$scaler = $this->_getImageScaler();
$src = $scaler->getScaledUrl($imageIdOrRecord, $template);
$tplScalingParams = $scaler->getTemplateParameters($template);
$htmlAttribs = array_merge(
$htmlAttribs,
$this->_getHtmlAttribsFromSizeParams($tplScalingParams)
);
} else {
if ($imageIdOrRecord instanceof Garp_Db_Table_Row) {
$filename = $imageIdOrRecord->filename;
} else {
$imageModel = new Model_Image();
$filename = $imageModel->fetchFilenameById($imageIdOrRecord);
}
$file = new Garp_Image_File(Garp_File::FILE_VARIANT_UPLOAD);
$src = $file->getUrl($filename);
}
if (!array_key_exists('alt', $htmlAttribs)) {
$htmlAttribs['alt'] = '';
}
$htmlAttribs['src'] = $src;
$imgTag = '<img' . $this->_htmlAttribs($htmlAttribs) . '>';
if ($imageIdOrRecord instanceof Garp_Db_Table_Row) {
if ($partial) {
$module = 'default';
} else {
$partial = 'partials/image.phtml';
$module = 'g';
}
return $this->view->partial(
$partial,
$module,
array(
'imgTag' => $imgTag,
'imgObject' => $imageIdOrRecord
)
);
} else {
return $imgTag;
}
} | php | protected function _renderUpload(
$imageIdOrRecord, $template = null, array $htmlAttribs = array(), $partial = ''
) {
if (!empty($template)) {
$scaler = $this->_getImageScaler();
$src = $scaler->getScaledUrl($imageIdOrRecord, $template);
$tplScalingParams = $scaler->getTemplateParameters($template);
$htmlAttribs = array_merge(
$htmlAttribs,
$this->_getHtmlAttribsFromSizeParams($tplScalingParams)
);
} else {
if ($imageIdOrRecord instanceof Garp_Db_Table_Row) {
$filename = $imageIdOrRecord->filename;
} else {
$imageModel = new Model_Image();
$filename = $imageModel->fetchFilenameById($imageIdOrRecord);
}
$file = new Garp_Image_File(Garp_File::FILE_VARIANT_UPLOAD);
$src = $file->getUrl($filename);
}
if (!array_key_exists('alt', $htmlAttribs)) {
$htmlAttribs['alt'] = '';
}
$htmlAttribs['src'] = $src;
$imgTag = '<img' . $this->_htmlAttribs($htmlAttribs) . '>';
if ($imageIdOrRecord instanceof Garp_Db_Table_Row) {
if ($partial) {
$module = 'default';
} else {
$partial = 'partials/image.phtml';
$module = 'g';
}
return $this->view->partial(
$partial,
$module,
array(
'imgTag' => $imgTag,
'imgObject' => $imageIdOrRecord
)
);
} else {
return $imgTag;
}
} | [
"protected",
"function",
"_renderUpload",
"(",
"$",
"imageIdOrRecord",
",",
"$",
"template",
"=",
"null",
",",
"array",
"$",
"htmlAttribs",
"=",
"array",
"(",
")",
",",
"$",
"partial",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"template",... | Returns an HTML image tag, with the correct path to the image provided.
@param mixed $imageIdOrRecord Id of the image record, or a Garp_Db_Table_Row image record.
This can also be an instance of an Image model.
If so, the image will be rendered inside a partial that
includes its caption and other metadata.
@param array $template Template name.
@param array $htmlAttribs HTML attributes for this <img> tag, such as 'alt'.
@param string $partial Custom partial for rendering this image
@return string Full image tag string, containing attributes and full path | [
"Returns",
"an",
"HTML",
"image",
"tag",
"with",
"the",
"correct",
"path",
"to",
"the",
"image",
"provided",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Image.php#L167-L214 |
46,517 | grrr-amsterdam/garp3 | library/Garp/Service/Elasticsearch/Configuration.php | Garp_Service_Elasticsearch_Configuration._getDefaultIndex | protected function _getDefaultIndex() {
$config = Zend_Registry::get('config');
if (!isset($config->app->name)) {
throw new Exception(self::ERROR_NO_APP_NAME_CONFIGURED);
}
$appName = str_replace(' ', '', $config->app->name);
$appName = Garp_Util_String::camelcasedToDashed($appName);
if (!$appName) {
throw new Exception(self::ERROR_APP_NAME_EMPTY);
}
$indexName = $appName . '-' . APPLICATION_ENV;
return $indexName;
} | php | protected function _getDefaultIndex() {
$config = Zend_Registry::get('config');
if (!isset($config->app->name)) {
throw new Exception(self::ERROR_NO_APP_NAME_CONFIGURED);
}
$appName = str_replace(' ', '', $config->app->name);
$appName = Garp_Util_String::camelcasedToDashed($appName);
if (!$appName) {
throw new Exception(self::ERROR_APP_NAME_EMPTY);
}
$indexName = $appName . '-' . APPLICATION_ENV;
return $indexName;
} | [
"protected",
"function",
"_getDefaultIndex",
"(",
")",
"{",
"$",
"config",
"=",
"Zend_Registry",
"::",
"get",
"(",
"'config'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"->",
"app",
"->",
"name",
")",
")",
"{",
"throw",
"new",
"Exception",... | Returns the database name for this environment, to be used as the index name for Elasticsearch. | [
"Returns",
"the",
"database",
"name",
"for",
"this",
"environment",
"to",
"be",
"used",
"as",
"the",
"index",
"name",
"for",
"Elasticsearch",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Service/Elasticsearch/Configuration.php#L94-L111 |
46,518 | grrr-amsterdam/garp3 | library/Garp/Cli/Command/Shell.php | Garp_Cli_Command_Shell.main | public function main(array $args = array()) {
Garp_Cli::lineOut('Welcome to the Garp interactive shell.', Garp_Cli::YELLOW);
Garp_Cli::lineOut('Use Ctrl-C to quit.');
$this->_setErrorHandler();
$this->_tick();
} | php | public function main(array $args = array()) {
Garp_Cli::lineOut('Welcome to the Garp interactive shell.', Garp_Cli::YELLOW);
Garp_Cli::lineOut('Use Ctrl-C to quit.');
$this->_setErrorHandler();
$this->_tick();
} | [
"public",
"function",
"main",
"(",
"array",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"Garp_Cli",
"::",
"lineOut",
"(",
"'Welcome to the Garp interactive shell.'",
",",
"Garp_Cli",
"::",
"YELLOW",
")",
";",
"Garp_Cli",
"::",
"lineOut",
"(",
"'Use Ctrl-C t... | Main starting point
@param array $args
@return void | [
"Main",
"starting",
"point"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Shell.php#L39-L45 |
46,519 | grrr-amsterdam/garp3 | library/Garp/Cli/Command/Shell.php | Garp_Cli_Command_Shell.output | public function output($buffer) {
if (!$buffer && !$this->__result) {
return '';
}
$out = '';
// Always include the output generated by the expression first
if ($buffer) {
$out .= Garp_Cli::lineOut($buffer, null, true, false);
}
// And follow-up with the populated result, if any
if ($this->__result) {
// Try to format as user-friendly as possible
$isObjWithToArray = is_object($this->__result) &&
method_exists($this->__result, 'toArray');
$this->__result = $isObjWithToArray ? $this->__result->toArray() : $this->__result;
$this->__result = var_export($this->__result, true);
$out .= Garp_Cli::lineOut($this->__result, Garp_Cli::BLUE, true, false);
}
return $out;
} | php | public function output($buffer) {
if (!$buffer && !$this->__result) {
return '';
}
$out = '';
// Always include the output generated by the expression first
if ($buffer) {
$out .= Garp_Cli::lineOut($buffer, null, true, false);
}
// And follow-up with the populated result, if any
if ($this->__result) {
// Try to format as user-friendly as possible
$isObjWithToArray = is_object($this->__result) &&
method_exists($this->__result, 'toArray');
$this->__result = $isObjWithToArray ? $this->__result->toArray() : $this->__result;
$this->__result = var_export($this->__result, true);
$out .= Garp_Cli::lineOut($this->__result, Garp_Cli::BLUE, true, false);
}
return $out;
} | [
"public",
"function",
"output",
"(",
"$",
"buffer",
")",
"{",
"if",
"(",
"!",
"$",
"buffer",
"&&",
"!",
"$",
"this",
"->",
"__result",
")",
"{",
"return",
"''",
";",
"}",
"$",
"out",
"=",
"''",
";",
"// Always include the output generated by the expression... | Output the result of the eval'd expression
@param string $buffer Buffered input
@return String | [
"Output",
"the",
"result",
"of",
"the",
"eval",
"d",
"expression"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Shell.php#L53-L75 |
46,520 | grrr-amsterdam/garp3 | library/Garp/Cli/Command/Shell.php | Garp_Cli_Command_Shell._tick | protected function _tick() {
while (true) {
// Grab a line of PHP code from the prompt
$line = $this->_getInput();
/**
* Note that $this->__result will be populated, if no target variable is given
* in the expression. In other words, this will populate $this->__result:
* $someModel->fetchAll();
* But this won't:
* $rows = $someModel->fetchAll();
* ...because we assume the user wants to do something with the variable.
*/
if (!$this->_input && !preg_match('/^(\$\w+\s?\=)|print|echo/', $line)) {
$line = '$this->__result = ' . $line;
}
$this->_input .= $line;
// If no semicolon is found at the end, assume
// multi-line input. The user is therefore not finished,
// so we just continue here and wait for that semicolon.
if (substr($line, -1) !== ';') {
continue;
}
// Execute input, and grab its output
ob_start(array($this, 'output'));
eval($this->_input);
ob_end_flush();
// Clear result var
$this->__result = null;
// Reset input
$this->_input = '';
}
} | php | protected function _tick() {
while (true) {
// Grab a line of PHP code from the prompt
$line = $this->_getInput();
/**
* Note that $this->__result will be populated, if no target variable is given
* in the expression. In other words, this will populate $this->__result:
* $someModel->fetchAll();
* But this won't:
* $rows = $someModel->fetchAll();
* ...because we assume the user wants to do something with the variable.
*/
if (!$this->_input && !preg_match('/^(\$\w+\s?\=)|print|echo/', $line)) {
$line = '$this->__result = ' . $line;
}
$this->_input .= $line;
// If no semicolon is found at the end, assume
// multi-line input. The user is therefore not finished,
// so we just continue here and wait for that semicolon.
if (substr($line, -1) !== ';') {
continue;
}
// Execute input, and grab its output
ob_start(array($this, 'output'));
eval($this->_input);
ob_end_flush();
// Clear result var
$this->__result = null;
// Reset input
$this->_input = '';
}
} | [
"protected",
"function",
"_tick",
"(",
")",
"{",
"while",
"(",
"true",
")",
"{",
"// Grab a line of PHP code from the prompt",
"$",
"line",
"=",
"$",
"this",
"->",
"_getInput",
"(",
")",
";",
"/**\n * Note that $this->__result will be populated, if no target v... | One iteration in the main loop.
@return Void | [
"One",
"iteration",
"in",
"the",
"main",
"loop",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Shell.php#L82-L118 |
46,521 | grrr-amsterdam/garp3 | library/Garp/Cli/Command/Shell.php | Garp_Cli_Command_Shell._getInput | protected function _getInput() {
if (function_exists('readline') && function_exists('readline_add_history')) {
$line = readline($this->_getPrompt());
readline_add_history($line);
return $line;
}
echo $this->_getPrompt();
$line = Garp_Cli::prompt();
return $line;
} | php | protected function _getInput() {
if (function_exists('readline') && function_exists('readline_add_history')) {
$line = readline($this->_getPrompt());
readline_add_history($line);
return $line;
}
echo $this->_getPrompt();
$line = Garp_Cli::prompt();
return $line;
} | [
"protected",
"function",
"_getInput",
"(",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'readline'",
")",
"&&",
"function_exists",
"(",
"'readline_add_history'",
")",
")",
"{",
"$",
"line",
"=",
"readline",
"(",
"$",
"this",
"->",
"_getPrompt",
"(",
")",
... | Retrieve input from the user.
Prefer readline because it supports history.
@return String | [
"Retrieve",
"input",
"from",
"the",
"user",
".",
"Prefer",
"readline",
"because",
"it",
"supports",
"history",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Shell.php#L126-L135 |
46,522 | grrr-amsterdam/garp3 | library/Garp/Content/Import/Abstract.php | Garp_Content_Import_Abstract.rollback | public function rollback(Garp_Model $model, array $primaryKeys) {
if (empty($primaryKeys)) {
return;
}
$primaryCols = (array)$model->info(Zend_Db_Table::PRIMARY);
$where = array();
foreach ($primaryKeys as $pk) {
$recordWhere = array();
foreach ((array)$pk as $i => $key) {
$recordWhere[] = $model->getAdapter()->quoteIdentifier(current($primaryCols)).' = '.
$model->getAdapter()->quote($key);
}
$recordWhere = implode(' AND ', $recordWhere);
$recordWhere = '('.$recordWhere.')';
$where[] = $recordWhere;
reset($primaryCols);
}
$where = implode(' OR ', $where);
if (empty($where)) {
return;
}
$model->delete($where);
} | php | public function rollback(Garp_Model $model, array $primaryKeys) {
if (empty($primaryKeys)) {
return;
}
$primaryCols = (array)$model->info(Zend_Db_Table::PRIMARY);
$where = array();
foreach ($primaryKeys as $pk) {
$recordWhere = array();
foreach ((array)$pk as $i => $key) {
$recordWhere[] = $model->getAdapter()->quoteIdentifier(current($primaryCols)).' = '.
$model->getAdapter()->quote($key);
}
$recordWhere = implode(' AND ', $recordWhere);
$recordWhere = '('.$recordWhere.')';
$where[] = $recordWhere;
reset($primaryCols);
}
$where = implode(' OR ', $where);
if (empty($where)) {
return;
}
$model->delete($where);
} | [
"public",
"function",
"rollback",
"(",
"Garp_Model",
"$",
"model",
",",
"array",
"$",
"primaryKeys",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"primaryKeys",
")",
")",
"{",
"return",
";",
"}",
"$",
"primaryCols",
"=",
"(",
"array",
")",
"$",
"model",
"... | Rollback all inserts when the import throws an error halfway
@param Garp_Model $model
@param Array $primaryKeys Collection of primary keys
@return Void | [
"Rollback",
"all",
"inserts",
"when",
"the",
"import",
"throws",
"an",
"error",
"halfway"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Import/Abstract.php#L52-L74 |
46,523 | grrr-amsterdam/garp3 | library/Garp/Model/Behavior/Cachable.php | Garp_Model_Behavior_Cachable.beforeFetch | public function beforeFetch(&$args) {
$model = &$args[0];
$select = &$args[1];
// check if the cache is in use
if (!$model->getCacheQueries() || !Zend_Registry::get('readFromCache')) {
return;
}
$cacheKey = $this->createCacheKey($model, $select);
$results = Garp_Cache_Manager::readQueryCache($model, $cacheKey);
if ($results !== -1) {
$args[2] = $results;
} else {
$this->_openCacheKey = $cacheKey;
}
} | php | public function beforeFetch(&$args) {
$model = &$args[0];
$select = &$args[1];
// check if the cache is in use
if (!$model->getCacheQueries() || !Zend_Registry::get('readFromCache')) {
return;
}
$cacheKey = $this->createCacheKey($model, $select);
$results = Garp_Cache_Manager::readQueryCache($model, $cacheKey);
if ($results !== -1) {
$args[2] = $results;
} else {
$this->_openCacheKey = $cacheKey;
}
} | [
"public",
"function",
"beforeFetch",
"(",
"&",
"$",
"args",
")",
"{",
"$",
"model",
"=",
"&",
"$",
"args",
"[",
"0",
"]",
";",
"$",
"select",
"=",
"&",
"$",
"args",
"[",
"1",
"]",
";",
"// check if the cache is in use",
"if",
"(",
"!",
"$",
"model"... | Before fetch callback, checks the cache for valid data.
@param Array $args
@return Void | [
"Before",
"fetch",
"callback",
"checks",
"the",
"cache",
"for",
"valid",
"data",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/Cachable.php#L40-L54 |
46,524 | grrr-amsterdam/garp3 | library/Garp/Model/Behavior/Cachable.php | Garp_Model_Behavior_Cachable.afterFetch | public function afterFetch(&$args) {
if (!$this->_openCacheKey) {
return;
}
$model = $args[0];
$results = $args[1];
$cacheKey = $this->_openCacheKey;
Garp_Cache_Manager::writeQueryCache($model, $cacheKey, $results);
// reset the key
$this->_openCacheKey = '';
} | php | public function afterFetch(&$args) {
if (!$this->_openCacheKey) {
return;
}
$model = $args[0];
$results = $args[1];
$cacheKey = $this->_openCacheKey;
Garp_Cache_Manager::writeQueryCache($model, $cacheKey, $results);
// reset the key
$this->_openCacheKey = '';
} | [
"public",
"function",
"afterFetch",
"(",
"&",
"$",
"args",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_openCacheKey",
")",
"{",
"return",
";",
"}",
"$",
"model",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"$",
"results",
"=",
"$",
"args",
"[",
"1... | After fetch callback, writes data back to the cache.
@param Array $args
@return Void | [
"After",
"fetch",
"callback",
"writes",
"data",
"back",
"to",
"the",
"cache",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/Cachable.php#L61-L73 |
46,525 | grrr-amsterdam/garp3 | library/Garp/Model/Behavior/Cachable.php | Garp_Model_Behavior_Cachable.createCacheKey | public function createCacheKey(Garp_Model $model, Zend_Db_Select $select) {
$boundModels = serialize(Garp_Model_Db_BindingManager::getBindingTree(get_class($model)));
$hash = md5(
md5($select).
md5($boundModels)
);
return $hash;
} | php | public function createCacheKey(Garp_Model $model, Zend_Db_Select $select) {
$boundModels = serialize(Garp_Model_Db_BindingManager::getBindingTree(get_class($model)));
$hash = md5(
md5($select).
md5($boundModels)
);
return $hash;
} | [
"public",
"function",
"createCacheKey",
"(",
"Garp_Model",
"$",
"model",
",",
"Zend_Db_Select",
"$",
"select",
")",
"{",
"$",
"boundModels",
"=",
"serialize",
"(",
"Garp_Model_Db_BindingManager",
"::",
"getBindingTree",
"(",
"get_class",
"(",
"$",
"model",
")",
... | Create a unique hash for cache entries, based on the SELECT object,
but also on the registered bindings, because a query might be the same
with different results when bindings come into play.
@param Garp_Model $model
@param Zend_Db_Select $select
@return String | [
"Create",
"a",
"unique",
"hash",
"for",
"cache",
"entries",
"based",
"on",
"the",
"SELECT",
"object",
"but",
"also",
"on",
"the",
"registered",
"bindings",
"because",
"a",
"query",
"might",
"be",
"the",
"same",
"with",
"different",
"results",
"when",
"bindin... | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/Cachable.php#L115-L122 |
46,526 | grrr-amsterdam/garp3 | library/Garp/Adobe/InDesign/Spread.php | Garp_Adobe_InDesign_Spread._buildStories | protected function _buildStories() {
$storiesByPageNumber = array();
$storiesByTag = array();
$pagesCount = count($this->pages);
// Build an array with all textframe positions, divided into the accompanying story XML tags
foreach ($this->textFrames as $textFrame) {
$story = new Garp_Adobe_InDesign_Story($textFrame->storyId, $this->_workingDir);
if ($tag = $story->getTag()) {
$storiesByTag[$tag][] = array(
'storyId' => $textFrame->storyId,
'x' => $textFrame->x
);
}
}
// sort the stories by horizontal position
$sortFunction = function ($storyA, $storyB) {
if ($storyA['x'] == $storyB['x']) {
return 0;
}
return $storyA['x'] > $storyB['x'] ? 1 : -1;
};
foreach ($storiesByTag as &$stories) {
usort($stories, $sortFunction);
}
// now divide the stories in pages
foreach ($storiesByTag as $tagStories) {
$tagStoriesCount = count($tagStories);
$tagStoriesPerPage = $tagStoriesCount / $pagesCount;
foreach ($tagStories as $s => $tagStory) {
$page = floor($s / $tagStoriesPerPage);
$pageNumber = $this->pages[$page]->index;
$storiesByPageNumber[$pageNumber][] = $tagStory['storyId'];
}
}
return $storiesByPageNumber;
} | php | protected function _buildStories() {
$storiesByPageNumber = array();
$storiesByTag = array();
$pagesCount = count($this->pages);
// Build an array with all textframe positions, divided into the accompanying story XML tags
foreach ($this->textFrames as $textFrame) {
$story = new Garp_Adobe_InDesign_Story($textFrame->storyId, $this->_workingDir);
if ($tag = $story->getTag()) {
$storiesByTag[$tag][] = array(
'storyId' => $textFrame->storyId,
'x' => $textFrame->x
);
}
}
// sort the stories by horizontal position
$sortFunction = function ($storyA, $storyB) {
if ($storyA['x'] == $storyB['x']) {
return 0;
}
return $storyA['x'] > $storyB['x'] ? 1 : -1;
};
foreach ($storiesByTag as &$stories) {
usort($stories, $sortFunction);
}
// now divide the stories in pages
foreach ($storiesByTag as $tagStories) {
$tagStoriesCount = count($tagStories);
$tagStoriesPerPage = $tagStoriesCount / $pagesCount;
foreach ($tagStories as $s => $tagStory) {
$page = floor($s / $tagStoriesPerPage);
$pageNumber = $this->pages[$page]->index;
$storiesByPageNumber[$pageNumber][] = $tagStory['storyId'];
}
}
return $storiesByPageNumber;
} | [
"protected",
"function",
"_buildStories",
"(",
")",
"{",
"$",
"storiesByPageNumber",
"=",
"array",
"(",
")",
";",
"$",
"storiesByTag",
"=",
"array",
"(",
")",
";",
"$",
"pagesCount",
"=",
"count",
"(",
"$",
"this",
"->",
"pages",
")",
";",
"// Build an a... | This method retrieves the Stories referenced by TextFrame entries on the current Spread,
that geometrically map to this page.
This has be calculated by geometry, since a TextFrame is not directly linked to a Page,
but to a Spread.
@return array | [
"This",
"method",
"retrieves",
"the",
"Stories",
"referenced",
"by",
"TextFrame",
"entries",
"on",
"the",
"current",
"Spread",
"that",
"geometrically",
"map",
"to",
"this",
"page",
".",
"This",
"has",
"be",
"calculated",
"by",
"geometry",
"since",
"a",
"TextFr... | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Adobe/InDesign/Spread.php#L151-L192 |
46,527 | grrr-amsterdam/garp3 | library/Garp/Cli/Ui.php | Garp_Cli_Ui.advance | public function advance($newValue = null) {
if (!is_null($newValue)) {
$this->_currentValue = $newValue;
return;
}
$this->_currentValue++;
} | php | public function advance($newValue = null) {
if (!is_null($newValue)) {
$this->_currentValue = $newValue;
return;
}
$this->_currentValue++;
} | [
"public",
"function",
"advance",
"(",
"$",
"newValue",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"newValue",
")",
")",
"{",
"$",
"this",
"->",
"_currentValue",
"=",
"$",
"newValue",
";",
"return",
";",
"}",
"$",
"this",
"->",
"_cu... | Advances the progress bar by 1 step, if no argument is provided.
Otherwise, the progress bar is set to the provided value.
@param int $newValue The new value. Leave empty to advance 1 step.
This will be compared to $this->_totalValue.
@return void | [
"Advances",
"the",
"progress",
"bar",
"by",
"1",
"step",
"if",
"no",
"argument",
"is",
"provided",
".",
"Otherwise",
"the",
"progress",
"bar",
"is",
"set",
"to",
"the",
"provided",
"value",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Ui.php#L42-L49 |
46,528 | grrr-amsterdam/garp3 | library/Garp/3rdParty/facebook/src/base_facebook.php | BaseFacebook.getUserAccessToken | protected function getUserAccessToken() {
// first, consider a signed request if it's supplied.
// if there is a signed request, then it alone determines
// the access token.
$signed_request = $this->getSignedRequest();
if ($signed_request) {
// apps.facebook.com hands the access_token in the signed_request
if (array_key_exists('oauth_token', $signed_request)) {
$access_token = $signed_request['oauth_token'];
$this->setPersistentData('access_token', $access_token);
return $access_token;
}
// the JS SDK puts a code in with the redirect_uri of ''
if (array_key_exists('code', $signed_request)) {
$code = $signed_request['code'];
if ($code && $code == $this->getPersistentData('code')) {
// short-circuit if the code we have is the same as the one presented
return $this->getPersistentData('access_token');
}
$access_token = $this->getAccessTokenFromCode($code, '');
if ($access_token) {
$this->setPersistentData('code', $code);
$this->setPersistentData('access_token', $access_token);
return $access_token;
}
}
// signed request states there's no access token, so anything
// stored should be cleared.
$this->clearAllPersistentData();
return false; // respect the signed request's data, even
// if there's an authorization code or something else
}
$code = $this->getCode();
if ($code && $code != $this->getPersistentData('code')) {
$access_token = $this->getAccessTokenFromCode($code);
if ($access_token) {
$this->setPersistentData('code', $code);
$this->setPersistentData('access_token', $access_token);
return $access_token;
}
// code was bogus, so everything based on it should be invalidated.
$this->clearAllPersistentData();
return false;
}
// as a fallback, just return whatever is in the persistent
// store, knowing nothing explicit (signed request, authorization
// code, etc.) was present to shadow it (or we saw a code in $_REQUEST,
// but it's the same as what's in the persistent store)
return $this->getPersistentData('access_token');
} | php | protected function getUserAccessToken() {
// first, consider a signed request if it's supplied.
// if there is a signed request, then it alone determines
// the access token.
$signed_request = $this->getSignedRequest();
if ($signed_request) {
// apps.facebook.com hands the access_token in the signed_request
if (array_key_exists('oauth_token', $signed_request)) {
$access_token = $signed_request['oauth_token'];
$this->setPersistentData('access_token', $access_token);
return $access_token;
}
// the JS SDK puts a code in with the redirect_uri of ''
if (array_key_exists('code', $signed_request)) {
$code = $signed_request['code'];
if ($code && $code == $this->getPersistentData('code')) {
// short-circuit if the code we have is the same as the one presented
return $this->getPersistentData('access_token');
}
$access_token = $this->getAccessTokenFromCode($code, '');
if ($access_token) {
$this->setPersistentData('code', $code);
$this->setPersistentData('access_token', $access_token);
return $access_token;
}
}
// signed request states there's no access token, so anything
// stored should be cleared.
$this->clearAllPersistentData();
return false; // respect the signed request's data, even
// if there's an authorization code or something else
}
$code = $this->getCode();
if ($code && $code != $this->getPersistentData('code')) {
$access_token = $this->getAccessTokenFromCode($code);
if ($access_token) {
$this->setPersistentData('code', $code);
$this->setPersistentData('access_token', $access_token);
return $access_token;
}
// code was bogus, so everything based on it should be invalidated.
$this->clearAllPersistentData();
return false;
}
// as a fallback, just return whatever is in the persistent
// store, knowing nothing explicit (signed request, authorization
// code, etc.) was present to shadow it (or we saw a code in $_REQUEST,
// but it's the same as what's in the persistent store)
return $this->getPersistentData('access_token');
} | [
"protected",
"function",
"getUserAccessToken",
"(",
")",
"{",
"// first, consider a signed request if it's supplied.",
"// if there is a signed request, then it alone determines",
"// the access token.",
"$",
"signed_request",
"=",
"$",
"this",
"->",
"getSignedRequest",
"(",
")",
... | Determines and returns the user access token, first using
the signed request if present, and then falling back on
the authorization code if present. The intent is to
return a valid user access token, or false if one is determined
to not be available.
@return string A valid user access token, or false if one
could not be determined. | [
"Determines",
"and",
"returns",
"the",
"user",
"access",
"token",
"first",
"using",
"the",
"signed",
"request",
"if",
"present",
"and",
"then",
"falling",
"back",
"on",
"the",
"authorization",
"code",
"if",
"present",
".",
"The",
"intent",
"is",
"to",
"retur... | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/3rdParty/facebook/src/base_facebook.php#L426-L481 |
46,529 | grrr-amsterdam/garp3 | library/Garp/3rdParty/facebook/src/base_facebook.php | BaseFacebook.getSignedRequest | public function getSignedRequest() {
if (!$this->signedRequest) {
if (!empty($_REQUEST['signed_request'])) {
$this->signedRequest = $this->parseSignedRequest(
$_REQUEST['signed_request']);
} else if (!empty($_COOKIE[$this->getSignedRequestCookieName()])) {
$this->signedRequest = $this->parseSignedRequest(
$_COOKIE[$this->getSignedRequestCookieName()]);
}
}
return $this->signedRequest;
} | php | public function getSignedRequest() {
if (!$this->signedRequest) {
if (!empty($_REQUEST['signed_request'])) {
$this->signedRequest = $this->parseSignedRequest(
$_REQUEST['signed_request']);
} else if (!empty($_COOKIE[$this->getSignedRequestCookieName()])) {
$this->signedRequest = $this->parseSignedRequest(
$_COOKIE[$this->getSignedRequestCookieName()]);
}
}
return $this->signedRequest;
} | [
"public",
"function",
"getSignedRequest",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"signedRequest",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"_REQUEST",
"[",
"'signed_request'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"signedRequest",
"=",
... | Retrieve the signed request, either from a request parameter or,
if not present, from a cookie.
@return string the signed request, if available, or null otherwise. | [
"Retrieve",
"the",
"signed",
"request",
"either",
"from",
"a",
"request",
"parameter",
"or",
"if",
"not",
"present",
"from",
"a",
"cookie",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/3rdParty/facebook/src/base_facebook.php#L489-L500 |
46,530 | grrr-amsterdam/garp3 | library/Garp/3rdParty/facebook/src/base_facebook.php | BaseFacebook.getUser | public function getUser() {
if ($this->user !== null) {
// we've already determined this and cached the value.
return $this->user;
}
return $this->user = $this->getUserFromAvailableData();
} | php | public function getUser() {
if ($this->user !== null) {
// we've already determined this and cached the value.
return $this->user;
}
return $this->user = $this->getUserFromAvailableData();
} | [
"public",
"function",
"getUser",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"user",
"!==",
"null",
")",
"{",
"// we've already determined this and cached the value.",
"return",
"$",
"this",
"->",
"user",
";",
"}",
"return",
"$",
"this",
"->",
"user",
"=",
... | Get the UID of the connected user, or 0
if the Facebook user is not connected.
@return string the UID if available. | [
"Get",
"the",
"UID",
"of",
"the",
"connected",
"user",
"or",
"0",
"if",
"the",
"Facebook",
"user",
"is",
"not",
"connected",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/3rdParty/facebook/src/base_facebook.php#L508-L515 |
46,531 | grrr-amsterdam/garp3 | library/Garp/3rdParty/facebook/src/base_facebook.php | BaseFacebook.getUserFromAvailableData | protected function getUserFromAvailableData() {
// if a signed request is supplied, then it solely determines
// who the user is.
$signed_request = $this->getSignedRequest();
if ($signed_request) {
if (array_key_exists('user_id', $signed_request)) {
$user = $signed_request['user_id'];
if($user != $this->getPersistentData('user_id')){
$this->clearAllPersistentData();
}
$this->setPersistentData('user_id', $signed_request['user_id']);
return $user;
}
// if the signed request didn't present a user id, then invalidate
// all entries in any persistent store.
$this->clearAllPersistentData();
return 0;
}
$user = $this->getPersistentData('user_id', $default = 0);
$persisted_access_token = $this->getPersistentData('access_token');
// use access_token to fetch user id if we have a user access_token, or if
// the cached access token has changed.
$access_token = $this->getAccessToken();
if ($access_token &&
$access_token != $this->getApplicationAccessToken() &&
!($user && $persisted_access_token == $access_token)) {
$user = $this->getUserFromAccessToken();
if ($user) {
$this->setPersistentData('user_id', $user);
} else {
$this->clearAllPersistentData();
}
}
return $user;
} | php | protected function getUserFromAvailableData() {
// if a signed request is supplied, then it solely determines
// who the user is.
$signed_request = $this->getSignedRequest();
if ($signed_request) {
if (array_key_exists('user_id', $signed_request)) {
$user = $signed_request['user_id'];
if($user != $this->getPersistentData('user_id')){
$this->clearAllPersistentData();
}
$this->setPersistentData('user_id', $signed_request['user_id']);
return $user;
}
// if the signed request didn't present a user id, then invalidate
// all entries in any persistent store.
$this->clearAllPersistentData();
return 0;
}
$user = $this->getPersistentData('user_id', $default = 0);
$persisted_access_token = $this->getPersistentData('access_token');
// use access_token to fetch user id if we have a user access_token, or if
// the cached access token has changed.
$access_token = $this->getAccessToken();
if ($access_token &&
$access_token != $this->getApplicationAccessToken() &&
!($user && $persisted_access_token == $access_token)) {
$user = $this->getUserFromAccessToken();
if ($user) {
$this->setPersistentData('user_id', $user);
} else {
$this->clearAllPersistentData();
}
}
return $user;
} | [
"protected",
"function",
"getUserFromAvailableData",
"(",
")",
"{",
"// if a signed request is supplied, then it solely determines",
"// who the user is.",
"$",
"signed_request",
"=",
"$",
"this",
"->",
"getSignedRequest",
"(",
")",
";",
"if",
"(",
"$",
"signed_request",
... | Determines the connected user by first examining any signed
requests, then considering an authorization code, and then
falling back to any persistent store storing the user.
@return integer The id of the connected Facebook user,
or 0 if no such user exists. | [
"Determines",
"the",
"connected",
"user",
"by",
"first",
"examining",
"any",
"signed",
"requests",
"then",
"considering",
"an",
"authorization",
"code",
"and",
"then",
"falling",
"back",
"to",
"any",
"persistent",
"store",
"storing",
"the",
"user",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/3rdParty/facebook/src/base_facebook.php#L525-L565 |
46,532 | grrr-amsterdam/garp3 | library/Garp/3rdParty/facebook/src/base_facebook.php | BaseFacebook.getLoginStatusUrl | public function getLoginStatusUrl($params=array()) {
return $this->getUrl(
'www',
'extern/login_status.php',
array_merge(array(
'api_key' => $this->getAppId(),
'no_session' => $this->getCurrentUrl(),
'no_user' => $this->getCurrentUrl(),
'ok_session' => $this->getCurrentUrl(),
'session_version' => 3,
), $params)
);
} | php | public function getLoginStatusUrl($params=array()) {
return $this->getUrl(
'www',
'extern/login_status.php',
array_merge(array(
'api_key' => $this->getAppId(),
'no_session' => $this->getCurrentUrl(),
'no_user' => $this->getCurrentUrl(),
'ok_session' => $this->getCurrentUrl(),
'session_version' => 3,
), $params)
);
} | [
"public",
"function",
"getLoginStatusUrl",
"(",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getUrl",
"(",
"'www'",
",",
"'extern/login_status.php'",
",",
"array_merge",
"(",
"array",
"(",
"'api_key'",
"=>",
"$",
"this",
"... | Get a login status URL to fetch the status from Facebook.
The parameters:
- ok_session: the URL to go to if a session is found
- no_session: the URL to go to if the user is not connected
- no_user: the URL to go to if the user is not signed into facebook
@param array $params Provide custom parameters
@return string The URL for the logout flow | [
"Get",
"a",
"login",
"status",
"URL",
"to",
"fetch",
"the",
"status",
"from",
"Facebook",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/3rdParty/facebook/src/base_facebook.php#L630-L642 |
46,533 | grrr-amsterdam/garp3 | library/Garp/3rdParty/facebook/src/base_facebook.php | BaseFacebook.getCode | protected function getCode() {
if (isset($_REQUEST['code'])) {
if ($this->state !== null &&
isset($_REQUEST['state']) &&
$this->state === $_REQUEST['state']) {
// CSRF state has done its job, so clear it
$this->state = null;
$this->clearPersistentData('state');
return $_REQUEST['code'];
} else {
self::errorLog('CSRF state token does not match one provided.');
return false;
}
}
return false;
} | php | protected function getCode() {
if (isset($_REQUEST['code'])) {
if ($this->state !== null &&
isset($_REQUEST['state']) &&
$this->state === $_REQUEST['state']) {
// CSRF state has done its job, so clear it
$this->state = null;
$this->clearPersistentData('state');
return $_REQUEST['code'];
} else {
self::errorLog('CSRF state token does not match one provided.');
return false;
}
}
return false;
} | [
"protected",
"function",
"getCode",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_REQUEST",
"[",
"'code'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"state",
"!==",
"null",
"&&",
"isset",
"(",
"$",
"_REQUEST",
"[",
"'state'",
"]",
")",
"... | Get the authorization code from the query parameters, if it exists,
and otherwise return false to signal no authorization code was
discoverable.
@return mixed The authorization code, or false if the authorization
code could not be determined. | [
"Get",
"the",
"authorization",
"code",
"from",
"the",
"query",
"parameters",
"if",
"it",
"exists",
"and",
"otherwise",
"return",
"false",
"to",
"signal",
"no",
"authorization",
"code",
"was",
"discoverable",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/3rdParty/facebook/src/base_facebook.php#L690-L707 |
46,534 | grrr-amsterdam/garp3 | library/Garp/3rdParty/facebook/src/base_facebook.php | BaseFacebook.makeRequest | protected function makeRequest($url, $params, $ch=null) {
if (!$ch) {
$ch = curl_init();
}
$opts = self::$CURL_OPTS;
if ($this->getFileUploadSupport()) {
$opts[CURLOPT_POSTFIELDS] = $params;
} else {
$opts[CURLOPT_POSTFIELDS] = http_build_query($params, null, '&');
}
$opts[CURLOPT_URL] = $url;
// disable the 'Expect: 100-continue' behaviour. This causes CURL to wait
// for 2 seconds if the server does not support this header.
if (isset($opts[CURLOPT_HTTPHEADER])) {
$existing_headers = $opts[CURLOPT_HTTPHEADER];
$existing_headers[] = 'Expect:';
$opts[CURLOPT_HTTPHEADER] = $existing_headers;
} else {
$opts[CURLOPT_HTTPHEADER] = array('Expect:');
}
curl_setopt_array($ch, $opts);
$result = curl_exec($ch);
if (curl_errno($ch) == 60) { // CURLE_SSL_CACERT
self::errorLog('Invalid or no certificate authority found, '.
'using bundled information');
curl_setopt($ch, CURLOPT_CAINFO,
dirname(__FILE__) . '/fb_ca_chain_bundle.crt');
$result = curl_exec($ch);
}
// With dual stacked DNS responses, it's possible for a server to
// have IPv6 enabled but not have IPv6 connectivity. If this is
// the case, curl will try IPv4 first and if that fails, then it will
// fall back to IPv6 and the error EHOSTUNREACH is returned by the
// operating system.
if ($result === false && empty($opts[CURLOPT_IPRESOLVE])) {
$matches = array();
$regex = '/Failed to connect to ([^:].*): Network is unreachable/';
if (preg_match($regex, curl_error($ch), $matches)) {
if (strlen(@inet_pton($matches[1])) === 16) {
self::errorLog('Invalid IPv6 configuration on server, '.
'Please disable or get native IPv6 on your server.');
self::$CURL_OPTS[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4;
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$result = curl_exec($ch);
}
}
}
if ($result === false) {
$e = new FacebookApiException(array(
'error_code' => curl_errno($ch),
'error' => array(
'message' => curl_error($ch),
'type' => 'CurlException',
),
));
curl_close($ch);
throw $e;
}
curl_close($ch);
return $result;
} | php | protected function makeRequest($url, $params, $ch=null) {
if (!$ch) {
$ch = curl_init();
}
$opts = self::$CURL_OPTS;
if ($this->getFileUploadSupport()) {
$opts[CURLOPT_POSTFIELDS] = $params;
} else {
$opts[CURLOPT_POSTFIELDS] = http_build_query($params, null, '&');
}
$opts[CURLOPT_URL] = $url;
// disable the 'Expect: 100-continue' behaviour. This causes CURL to wait
// for 2 seconds if the server does not support this header.
if (isset($opts[CURLOPT_HTTPHEADER])) {
$existing_headers = $opts[CURLOPT_HTTPHEADER];
$existing_headers[] = 'Expect:';
$opts[CURLOPT_HTTPHEADER] = $existing_headers;
} else {
$opts[CURLOPT_HTTPHEADER] = array('Expect:');
}
curl_setopt_array($ch, $opts);
$result = curl_exec($ch);
if (curl_errno($ch) == 60) { // CURLE_SSL_CACERT
self::errorLog('Invalid or no certificate authority found, '.
'using bundled information');
curl_setopt($ch, CURLOPT_CAINFO,
dirname(__FILE__) . '/fb_ca_chain_bundle.crt');
$result = curl_exec($ch);
}
// With dual stacked DNS responses, it's possible for a server to
// have IPv6 enabled but not have IPv6 connectivity. If this is
// the case, curl will try IPv4 first and if that fails, then it will
// fall back to IPv6 and the error EHOSTUNREACH is returned by the
// operating system.
if ($result === false && empty($opts[CURLOPT_IPRESOLVE])) {
$matches = array();
$regex = '/Failed to connect to ([^:].*): Network is unreachable/';
if (preg_match($regex, curl_error($ch), $matches)) {
if (strlen(@inet_pton($matches[1])) === 16) {
self::errorLog('Invalid IPv6 configuration on server, '.
'Please disable or get native IPv6 on your server.');
self::$CURL_OPTS[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4;
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$result = curl_exec($ch);
}
}
}
if ($result === false) {
$e = new FacebookApiException(array(
'error_code' => curl_errno($ch),
'error' => array(
'message' => curl_error($ch),
'type' => 'CurlException',
),
));
curl_close($ch);
throw $e;
}
curl_close($ch);
return $result;
} | [
"protected",
"function",
"makeRequest",
"(",
"$",
"url",
",",
"$",
"params",
",",
"$",
"ch",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"ch",
")",
"{",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"}",
"$",
"opts",
"=",
"self",
"::",
"$",
"CU... | Makes an HTTP request. This method can be overridden by subclasses if
developers want to do fancier things or use something other than curl to
make the request.
@param string $url The URL to make the request to
@param array $params The parameters to use for the POST body
@param CurlHandler $ch Initialized curl handle
@return string The response text | [
"Makes",
"an",
"HTTP",
"request",
".",
"This",
"method",
"can",
"be",
"overridden",
"by",
"subclasses",
"if",
"developers",
"want",
"to",
"do",
"fancier",
"things",
"or",
"use",
"something",
"other",
"than",
"curl",
"to",
"make",
"the",
"request",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/3rdParty/facebook/src/base_facebook.php#L923-L989 |
46,535 | grrr-amsterdam/garp3 | library/Garp/3rdParty/facebook/src/base_facebook.php | BaseFacebook.makeSignedRequest | protected function makeSignedRequest($data) {
if (!is_array($data)) {
throw new InvalidArgumentException(
'makeSignedRequest expects an array. Got: ' . print_r($data, true));
}
$data['algorithm'] = self::SIGNED_REQUEST_ALGORITHM;
$data['issued_at'] = time();
$json = json_encode($data);
$b64 = self::base64UrlEncode($json);
$raw_sig = hash_hmac('sha256', $b64, $this->getAppSecret(), $raw = true);
$sig = self::base64UrlEncode($raw_sig);
return $sig.'.'.$b64;
} | php | protected function makeSignedRequest($data) {
if (!is_array($data)) {
throw new InvalidArgumentException(
'makeSignedRequest expects an array. Got: ' . print_r($data, true));
}
$data['algorithm'] = self::SIGNED_REQUEST_ALGORITHM;
$data['issued_at'] = time();
$json = json_encode($data);
$b64 = self::base64UrlEncode($json);
$raw_sig = hash_hmac('sha256', $b64, $this->getAppSecret(), $raw = true);
$sig = self::base64UrlEncode($raw_sig);
return $sig.'.'.$b64;
} | [
"protected",
"function",
"makeSignedRequest",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'makeSignedRequest expects an array. Got: '",
".",
"print_r",
"(",
"$",
"data... | Makes a signed_request blob using the given data.
@param array The data array.
@return string The signed request. | [
"Makes",
"a",
"signed_request",
"blob",
"using",
"the",
"given",
"data",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/3rdParty/facebook/src/base_facebook.php#L1027-L1039 |
46,536 | grrr-amsterdam/garp3 | library/Garp/3rdParty/facebook/src/base_facebook.php | BaseFacebook.getApiUrl | protected function getApiUrl($method) {
static $READ_ONLY_CALLS =
array('admin.getallocation' => 1,
'admin.getappproperties' => 1,
'admin.getbannedusers' => 1,
'admin.getlivestreamvialink' => 1,
'admin.getmetrics' => 1,
'admin.getrestrictioninfo' => 1,
'application.getpublicinfo' => 1,
'auth.getapppublickey' => 1,
'auth.getsession' => 1,
'auth.getsignedpublicsessiondata' => 1,
'comments.get' => 1,
'connect.getunconnectedfriendscount' => 1,
'dashboard.getactivity' => 1,
'dashboard.getcount' => 1,
'dashboard.getglobalnews' => 1,
'dashboard.getnews' => 1,
'dashboard.multigetcount' => 1,
'dashboard.multigetnews' => 1,
'data.getcookies' => 1,
'events.get' => 1,
'events.getmembers' => 1,
'fbml.getcustomtags' => 1,
'feed.getappfriendstories' => 1,
'feed.getregisteredtemplatebundlebyid' => 1,
'feed.getregisteredtemplatebundles' => 1,
'fql.multiquery' => 1,
'fql.query' => 1,
'friends.arefriends' => 1,
'friends.get' => 1,
'friends.getappusers' => 1,
'friends.getlists' => 1,
'friends.getmutualfriends' => 1,
'gifts.get' => 1,
'groups.get' => 1,
'groups.getmembers' => 1,
'intl.gettranslations' => 1,
'links.get' => 1,
'notes.get' => 1,
'notifications.get' => 1,
'pages.getinfo' => 1,
'pages.isadmin' => 1,
'pages.isappadded' => 1,
'pages.isfan' => 1,
'permissions.checkavailableapiaccess' => 1,
'permissions.checkgrantedapiaccess' => 1,
'photos.get' => 1,
'photos.getalbums' => 1,
'photos.gettags' => 1,
'profile.getinfo' => 1,
'profile.getinfooptions' => 1,
'stream.get' => 1,
'stream.getcomments' => 1,
'stream.getfilters' => 1,
'users.getinfo' => 1,
'users.getloggedinuser' => 1,
'users.getstandardinfo' => 1,
'users.hasapppermission' => 1,
'users.isappuser' => 1,
'users.isverified' => 1,
'video.getuploadlimits' => 1);
$name = 'api';
if (isset($READ_ONLY_CALLS[strtolower($method)])) {
$name = 'api_read';
} else if (strtolower($method) == 'video.upload') {
$name = 'api_video';
}
return self::getUrl($name, 'restserver.php');
} | php | protected function getApiUrl($method) {
static $READ_ONLY_CALLS =
array('admin.getallocation' => 1,
'admin.getappproperties' => 1,
'admin.getbannedusers' => 1,
'admin.getlivestreamvialink' => 1,
'admin.getmetrics' => 1,
'admin.getrestrictioninfo' => 1,
'application.getpublicinfo' => 1,
'auth.getapppublickey' => 1,
'auth.getsession' => 1,
'auth.getsignedpublicsessiondata' => 1,
'comments.get' => 1,
'connect.getunconnectedfriendscount' => 1,
'dashboard.getactivity' => 1,
'dashboard.getcount' => 1,
'dashboard.getglobalnews' => 1,
'dashboard.getnews' => 1,
'dashboard.multigetcount' => 1,
'dashboard.multigetnews' => 1,
'data.getcookies' => 1,
'events.get' => 1,
'events.getmembers' => 1,
'fbml.getcustomtags' => 1,
'feed.getappfriendstories' => 1,
'feed.getregisteredtemplatebundlebyid' => 1,
'feed.getregisteredtemplatebundles' => 1,
'fql.multiquery' => 1,
'fql.query' => 1,
'friends.arefriends' => 1,
'friends.get' => 1,
'friends.getappusers' => 1,
'friends.getlists' => 1,
'friends.getmutualfriends' => 1,
'gifts.get' => 1,
'groups.get' => 1,
'groups.getmembers' => 1,
'intl.gettranslations' => 1,
'links.get' => 1,
'notes.get' => 1,
'notifications.get' => 1,
'pages.getinfo' => 1,
'pages.isadmin' => 1,
'pages.isappadded' => 1,
'pages.isfan' => 1,
'permissions.checkavailableapiaccess' => 1,
'permissions.checkgrantedapiaccess' => 1,
'photos.get' => 1,
'photos.getalbums' => 1,
'photos.gettags' => 1,
'profile.getinfo' => 1,
'profile.getinfooptions' => 1,
'stream.get' => 1,
'stream.getcomments' => 1,
'stream.getfilters' => 1,
'users.getinfo' => 1,
'users.getloggedinuser' => 1,
'users.getstandardinfo' => 1,
'users.hasapppermission' => 1,
'users.isappuser' => 1,
'users.isverified' => 1,
'video.getuploadlimits' => 1);
$name = 'api';
if (isset($READ_ONLY_CALLS[strtolower($method)])) {
$name = 'api_read';
} else if (strtolower($method) == 'video.upload') {
$name = 'api_video';
}
return self::getUrl($name, 'restserver.php');
} | [
"protected",
"function",
"getApiUrl",
"(",
"$",
"method",
")",
"{",
"static",
"$",
"READ_ONLY_CALLS",
"=",
"array",
"(",
"'admin.getallocation'",
"=>",
"1",
",",
"'admin.getappproperties'",
"=>",
"1",
",",
"'admin.getbannedusers'",
"=>",
"1",
",",
"'admin.getlives... | Build the URL for api given parameters.
@param $method String the method name.
@return string The URL for the given parameters | [
"Build",
"the",
"URL",
"for",
"api",
"given",
"parameters",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/3rdParty/facebook/src/base_facebook.php#L1047-L1116 |
46,537 | grrr-amsterdam/garp3 | library/Garp/3rdParty/facebook/src/base_facebook.php | BaseFacebook.getUrl | protected function getUrl($name, $path='', $params=array()) {
$url = self::$DOMAIN_MAP[$name];
if ($path) {
if ($path[0] === '/') {
$path = substr($path, 1);
}
$url .= $path;
}
if ($params) {
$url .= '?' . http_build_query($params, null, '&');
}
return $url;
} | php | protected function getUrl($name, $path='', $params=array()) {
$url = self::$DOMAIN_MAP[$name];
if ($path) {
if ($path[0] === '/') {
$path = substr($path, 1);
}
$url .= $path;
}
if ($params) {
$url .= '?' . http_build_query($params, null, '&');
}
return $url;
} | [
"protected",
"function",
"getUrl",
"(",
"$",
"name",
",",
"$",
"path",
"=",
"''",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"$",
"DOMAIN_MAP",
"[",
"$",
"name",
"]",
";",
"if",
"(",
"$",
"path",
")",
... | Build the URL for given domain alias, path and parameters.
@param $name string The name of the domain
@param $path string Optional path (without a leading slash)
@param $params array Optional query parameters
@return string The URL for the given parameters | [
"Build",
"the",
"URL",
"for",
"given",
"domain",
"alias",
"path",
"and",
"parameters",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/3rdParty/facebook/src/base_facebook.php#L1127-L1140 |
46,538 | grrr-amsterdam/garp3 | library/Garp/3rdParty/facebook/src/base_facebook.php | BaseFacebook.getBaseDomain | protected function getBaseDomain() {
// The base domain is stored in the metadata cookie if not we fallback
// to the current hostname
$metadata = $this->getMetadataCookie();
if (array_key_exists('base_domain', $metadata) &&
!empty($metadata['base_domain'])) {
return trim($metadata['base_domain'], '.');
}
return $this->getHttpHost();
} | php | protected function getBaseDomain() {
// The base domain is stored in the metadata cookie if not we fallback
// to the current hostname
$metadata = $this->getMetadataCookie();
if (array_key_exists('base_domain', $metadata) &&
!empty($metadata['base_domain'])) {
return trim($metadata['base_domain'], '.');
}
return $this->getHttpHost();
} | [
"protected",
"function",
"getBaseDomain",
"(",
")",
"{",
"// The base domain is stored in the metadata cookie if not we fallback",
"// to the current hostname",
"$",
"metadata",
"=",
"$",
"this",
"->",
"getMetadataCookie",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
... | Get the base domain used for the cookie. | [
"Get",
"the",
"base",
"domain",
"used",
"for",
"the",
"cookie",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/3rdParty/facebook/src/base_facebook.php#L1172-L1181 |
46,539 | grrr-amsterdam/garp3 | library/Garp/3rdParty/facebook/src/base_facebook.php | BaseFacebook.throwAPIException | protected function throwAPIException($result) {
$e = new FacebookApiException($result);
switch ($e->getType()) {
// OAuth 2.0 Draft 00 style
case 'OAuthException':
// OAuth 2.0 Draft 10 style
case 'invalid_token':
// REST server errors are just Exceptions
case 'Exception':
$message = $e->getMessage();
if ((strpos($message, 'Error validating access token') !== false) ||
(strpos($message, 'Invalid OAuth access token') !== false) ||
(strpos($message, 'An active access token must be used') !== false)
) {
$this->destroySession();
}
break;
}
throw $e;
} | php | protected function throwAPIException($result) {
$e = new FacebookApiException($result);
switch ($e->getType()) {
// OAuth 2.0 Draft 00 style
case 'OAuthException':
// OAuth 2.0 Draft 10 style
case 'invalid_token':
// REST server errors are just Exceptions
case 'Exception':
$message = $e->getMessage();
if ((strpos($message, 'Error validating access token') !== false) ||
(strpos($message, 'Invalid OAuth access token') !== false) ||
(strpos($message, 'An active access token must be used') !== false)
) {
$this->destroySession();
}
break;
}
throw $e;
} | [
"protected",
"function",
"throwAPIException",
"(",
"$",
"result",
")",
"{",
"$",
"e",
"=",
"new",
"FacebookApiException",
"(",
"$",
"result",
")",
";",
"switch",
"(",
"$",
"e",
"->",
"getType",
"(",
")",
")",
"{",
"// OAuth 2.0 Draft 00 style",
"case",
"'O... | Analyzes the supplied result to see if it was thrown
because the access token is no longer valid. If that is
the case, then we destroy the session.
@param $result array A record storing the error message returned
by a failed API call. | [
"Analyzes",
"the",
"supplied",
"result",
"to",
"see",
"if",
"it",
"was",
"thrown",
"because",
"the",
"access",
"token",
"is",
"no",
"longer",
"valid",
".",
"If",
"that",
"is",
"the",
"case",
"then",
"we",
"destroy",
"the",
"session",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/3rdParty/facebook/src/base_facebook.php#L1253-L1273 |
46,540 | grrr-amsterdam/garp3 | library/Garp/3rdParty/facebook/src/base_facebook.php | BaseFacebook.destroySession | public function destroySession() {
$this->accessToken = null;
$this->signedRequest = null;
$this->user = null;
$this->clearAllPersistentData();
// Javascript sets a cookie that will be used in getSignedRequest that we
// need to clear if we can
$cookie_name = $this->getSignedRequestCookieName();
if (array_key_exists($cookie_name, $_COOKIE)) {
unset($_COOKIE[$cookie_name]);
if (!headers_sent()) {
$base_domain = $this->getBaseDomain();
setcookie($cookie_name, '', 1, '/', '.'.$base_domain);
} else {
// @codeCoverageIgnoreStart
self::errorLog(
'There exists a cookie that we wanted to clear that we couldn\'t '.
'clear because headers was already sent. Make sure to do the first '.
'API call before outputing anything.'
);
// @codeCoverageIgnoreEnd
}
}
} | php | public function destroySession() {
$this->accessToken = null;
$this->signedRequest = null;
$this->user = null;
$this->clearAllPersistentData();
// Javascript sets a cookie that will be used in getSignedRequest that we
// need to clear if we can
$cookie_name = $this->getSignedRequestCookieName();
if (array_key_exists($cookie_name, $_COOKIE)) {
unset($_COOKIE[$cookie_name]);
if (!headers_sent()) {
$base_domain = $this->getBaseDomain();
setcookie($cookie_name, '', 1, '/', '.'.$base_domain);
} else {
// @codeCoverageIgnoreStart
self::errorLog(
'There exists a cookie that we wanted to clear that we couldn\'t '.
'clear because headers was already sent. Make sure to do the first '.
'API call before outputing anything.'
);
// @codeCoverageIgnoreEnd
}
}
} | [
"public",
"function",
"destroySession",
"(",
")",
"{",
"$",
"this",
"->",
"accessToken",
"=",
"null",
";",
"$",
"this",
"->",
"signedRequest",
"=",
"null",
";",
"$",
"this",
"->",
"user",
"=",
"null",
";",
"$",
"this",
"->",
"clearAllPersistentData",
"("... | Destroy the current session | [
"Destroy",
"the",
"current",
"session"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/3rdParty/facebook/src/base_facebook.php#L1324-L1348 |
46,541 | grrr-amsterdam/garp3 | library/Garp/3rdParty/facebook/src/base_facebook.php | BaseFacebook.getMetadataCookie | protected function getMetadataCookie() {
$cookie_name = $this->getMetadataCookieName();
if (!array_key_exists($cookie_name, $_COOKIE)) {
return array();
}
// The cookie value can be wrapped in "-characters so remove them
$cookie_value = trim($_COOKIE[$cookie_name], '"');
if (empty($cookie_value)) {
return array();
}
$parts = explode('&', $cookie_value);
$metadata = array();
foreach ($parts as $part) {
$pair = explode('=', $part, 2);
if (!empty($pair[0])) {
$metadata[urldecode($pair[0])] =
(count($pair) > 1) ? urldecode($pair[1]) : '';
}
}
return $metadata;
} | php | protected function getMetadataCookie() {
$cookie_name = $this->getMetadataCookieName();
if (!array_key_exists($cookie_name, $_COOKIE)) {
return array();
}
// The cookie value can be wrapped in "-characters so remove them
$cookie_value = trim($_COOKIE[$cookie_name], '"');
if (empty($cookie_value)) {
return array();
}
$parts = explode('&', $cookie_value);
$metadata = array();
foreach ($parts as $part) {
$pair = explode('=', $part, 2);
if (!empty($pair[0])) {
$metadata[urldecode($pair[0])] =
(count($pair) > 1) ? urldecode($pair[1]) : '';
}
}
return $metadata;
} | [
"protected",
"function",
"getMetadataCookie",
"(",
")",
"{",
"$",
"cookie_name",
"=",
"$",
"this",
"->",
"getMetadataCookieName",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"cookie_name",
",",
"$",
"_COOKIE",
")",
")",
"{",
"return",
"arr... | Parses the metadata cookie that our Javascript API set
@return an array mapping key to value | [
"Parses",
"the",
"metadata",
"cookie",
"that",
"our",
"Javascript",
"API",
"set"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/3rdParty/facebook/src/base_facebook.php#L1355-L1379 |
46,542 | grrr-amsterdam/garp3 | library/Garp/Model/Behavior/ImageScalable.php | Garp_Model_Behavior_ImageScalable.scale | public function scale($filename, $id) {
$templates = instance(new Garp_Image_Scaler)->getTemplateNames();
// Divide templates into sync ones and async ones
$syncTemplates = array_intersect($templates, $this->_synchronouslyScaledTemplates);
$asyncTemplates = array_diff($templates, $this->_synchronouslyScaledTemplates);
foreach ($syncTemplates as $template) {
$this->_scaleSync($filename, $id, $template);
}
$this->_scaleAsync($filename, $id);
} | php | public function scale($filename, $id) {
$templates = instance(new Garp_Image_Scaler)->getTemplateNames();
// Divide templates into sync ones and async ones
$syncTemplates = array_intersect($templates, $this->_synchronouslyScaledTemplates);
$asyncTemplates = array_diff($templates, $this->_synchronouslyScaledTemplates);
foreach ($syncTemplates as $template) {
$this->_scaleSync($filename, $id, $template);
}
$this->_scaleAsync($filename, $id);
} | [
"public",
"function",
"scale",
"(",
"$",
"filename",
",",
"$",
"id",
")",
"{",
"$",
"templates",
"=",
"instance",
"(",
"new",
"Garp_Image_Scaler",
")",
"->",
"getTemplateNames",
"(",
")",
";",
"// Divide templates into sync ones and async ones",
"$",
"syncTemplate... | Perform the scaling | [
"Perform",
"the",
"scaling"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/ImageScalable.php#L65-L77 |
46,543 | grrr-amsterdam/garp3 | library/Garp/Browsebox/Filter/Related.php | Garp_Browsebox_Filter_Related.fetchMaxChunks | public function fetchMaxChunks(Zend_Db_Select $select, Garp_Browsebox $browsebox) {
if (!empty($this->_params)) {
$model = $browsebox->getModel();
$filterModel = new $this->_config['model']();
$bindingModel = new $this->_config['bindingOptions']['bindingModel']();
$rule1 = !empty($this->_config['bindingOptions']['rule']) ? $this->_config['bindingOptions']['rule'] : null;
$rule2 = !empty($this->_config['bindingOptions']['rule2']) ? $this->_config['bindingOptions']['rule2'] : null;
$modelReference = $bindingModel->getReference(get_class($model), $rule1);
$filterModelReference = $bindingModel->getReference($this->_config['model'], $rule2);
$joinConditions = array();
foreach ($modelReference['refColumns'] as $i => $refColumn) {
$column = $modelReference['columns'][$i];
$joinCondition = '';
$joinCondition .= $bindingModel->getAdapter()->quoteIdentifier($refColumn);
$joinCondition .= ' = ';
$joinCondition .= $bindingModel->getAdapter()->quoteIdentifier($column);
$joinConditions[] = $joinCondition;
}
$joinConditions = implode(' AND ', $joinConditions);
$countSelect = $model->select()
->from($model->getName(), array('c' => 'COUNT(*)'))
->join($bindingModel->getName(), $joinConditions, array());
if ($where = $browsebox->getOption('conditions')) {
$countSelect->where($where);
}
foreach ($filterModelReference['columns'] as $i => $foreignKey) {
$countSelect->where($bindingModel->getAdapter()->quoteIdentifier($foreignKey).' = ?', $this->_params[$i]);
}
$result = $model->fetchRow($countSelect);
return $result->c;
} else {
throw new Garp_Browsebox_Filter_Exception_NotApplicable();
}
} | php | public function fetchMaxChunks(Zend_Db_Select $select, Garp_Browsebox $browsebox) {
if (!empty($this->_params)) {
$model = $browsebox->getModel();
$filterModel = new $this->_config['model']();
$bindingModel = new $this->_config['bindingOptions']['bindingModel']();
$rule1 = !empty($this->_config['bindingOptions']['rule']) ? $this->_config['bindingOptions']['rule'] : null;
$rule2 = !empty($this->_config['bindingOptions']['rule2']) ? $this->_config['bindingOptions']['rule2'] : null;
$modelReference = $bindingModel->getReference(get_class($model), $rule1);
$filterModelReference = $bindingModel->getReference($this->_config['model'], $rule2);
$joinConditions = array();
foreach ($modelReference['refColumns'] as $i => $refColumn) {
$column = $modelReference['columns'][$i];
$joinCondition = '';
$joinCondition .= $bindingModel->getAdapter()->quoteIdentifier($refColumn);
$joinCondition .= ' = ';
$joinCondition .= $bindingModel->getAdapter()->quoteIdentifier($column);
$joinConditions[] = $joinCondition;
}
$joinConditions = implode(' AND ', $joinConditions);
$countSelect = $model->select()
->from($model->getName(), array('c' => 'COUNT(*)'))
->join($bindingModel->getName(), $joinConditions, array());
if ($where = $browsebox->getOption('conditions')) {
$countSelect->where($where);
}
foreach ($filterModelReference['columns'] as $i => $foreignKey) {
$countSelect->where($bindingModel->getAdapter()->quoteIdentifier($foreignKey).' = ?', $this->_params[$i]);
}
$result = $model->fetchRow($countSelect);
return $result->c;
} else {
throw new Garp_Browsebox_Filter_Exception_NotApplicable();
}
} | [
"public",
"function",
"fetchMaxChunks",
"(",
"Zend_Db_Select",
"$",
"select",
",",
"Garp_Browsebox",
"$",
"browsebox",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_params",
")",
")",
"{",
"$",
"model",
"=",
"$",
"browsebox",
"->",
"getMod... | Fetch max amount of chunks.
@param Zend_Db_Select $select The specific select for this instance.
@param Garp_Browsebox $browsebox The browsebox, made available to fetch metadata from.
@return Void | [
"Fetch",
"max",
"amount",
"of",
"chunks",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Browsebox/Filter/Related.php#L89-L125 |
46,544 | grrr-amsterdam/garp3 | library/Garp/Cli/Command/Image.php | Garp_Cli_Command_Image.generateScaled | public function generateScaled($args) {
$overwrite = array_key_exists('overwrite', $args) || array_key_exists('force', $args);
if (array_key_exists('template', $args)
&& !empty($args['template'])
) {
return $this->_generateScaledImagesForTemplate($args['template'], $overwrite);
} elseif (array_key_exists('filename', $args)
&& !empty($args['filename'])
) {
return $this->_generateScaledImagesForFilename($args['filename'], $overwrite);
} elseif (array_key_exists('id', $args)
&& !empty($args['id'])
) {
return $this->_generateScaledImagesForId($args['id'], $overwrite);
}
return $this->_generateAllScaledImages($overwrite);
} | php | public function generateScaled($args) {
$overwrite = array_key_exists('overwrite', $args) || array_key_exists('force', $args);
if (array_key_exists('template', $args)
&& !empty($args['template'])
) {
return $this->_generateScaledImagesForTemplate($args['template'], $overwrite);
} elseif (array_key_exists('filename', $args)
&& !empty($args['filename'])
) {
return $this->_generateScaledImagesForFilename($args['filename'], $overwrite);
} elseif (array_key_exists('id', $args)
&& !empty($args['id'])
) {
return $this->_generateScaledImagesForId($args['id'], $overwrite);
}
return $this->_generateAllScaledImages($overwrite);
} | [
"public",
"function",
"generateScaled",
"(",
"$",
"args",
")",
"{",
"$",
"overwrite",
"=",
"array_key_exists",
"(",
"'overwrite'",
",",
"$",
"args",
")",
"||",
"array_key_exists",
"(",
"'force'",
",",
"$",
"args",
")",
";",
"if",
"(",
"array_key_exists",
"... | Generate scaled versions of uploaded images
@param array $args
@return bool | [
"Generate",
"scaled",
"versions",
"of",
"uploaded",
"images"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Image.php#L15-L31 |
46,545 | grrr-amsterdam/garp3 | library/Garp/Cli/Command/Image.php | Garp_Cli_Command_Image._generateAllScaledImages | protected function _generateAllScaledImages($overwrite = false) {
$imageScaler = new Garp_Image_Scaler();
$templates = $imageScaler->getTemplateNames();
$success = 0;
foreach ($templates as $t) {
$success += (int)$this->_generateScaledImagesForTemplate($t, $overwrite);
}
return $success == count($templates);
} | php | protected function _generateAllScaledImages($overwrite = false) {
$imageScaler = new Garp_Image_Scaler();
$templates = $imageScaler->getTemplateNames();
$success = 0;
foreach ($templates as $t) {
$success += (int)$this->_generateScaledImagesForTemplate($t, $overwrite);
}
return $success == count($templates);
} | [
"protected",
"function",
"_generateAllScaledImages",
"(",
"$",
"overwrite",
"=",
"false",
")",
"{",
"$",
"imageScaler",
"=",
"new",
"Garp_Image_Scaler",
"(",
")",
";",
"$",
"templates",
"=",
"$",
"imageScaler",
"->",
"getTemplateNames",
"(",
")",
";",
"$",
"... | Generate scaled versions of all images in all templates.
@param bool $overwrite
@return bool | [
"Generate",
"scaled",
"versions",
"of",
"all",
"images",
"in",
"all",
"templates",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Image.php#L89-L99 |
46,546 | grrr-amsterdam/garp3 | library/Garp/Cli/Command/Image.php | Garp_Cli_Command_Image._generateScaledImagesForTemplate | protected function _generateScaledImagesForTemplate($template, $overwrite = false) {
Garp_Cli::lineOut('Generating scaled images for template "' . $template . '".');
$imageModel = new Model_Image();
$records = $imageModel->fetchAll();
$file = new Garp_Image_File(Garp_File::FILE_VARIANT_UPLOAD);
$scaler = new Garp_Image_Scaler();
$success = 0;
foreach ($records as $record) {
$success += (int)$this->_scaleDatabaseImage(
$record, $file, $scaler, $template, $overwrite
);
}
Garp_Cli::lineOut('Done scaling images for template "' . $template . '".');
return $success == count($records);
} | php | protected function _generateScaledImagesForTemplate($template, $overwrite = false) {
Garp_Cli::lineOut('Generating scaled images for template "' . $template . '".');
$imageModel = new Model_Image();
$records = $imageModel->fetchAll();
$file = new Garp_Image_File(Garp_File::FILE_VARIANT_UPLOAD);
$scaler = new Garp_Image_Scaler();
$success = 0;
foreach ($records as $record) {
$success += (int)$this->_scaleDatabaseImage(
$record, $file, $scaler, $template, $overwrite
);
}
Garp_Cli::lineOut('Done scaling images for template "' . $template . '".');
return $success == count($records);
} | [
"protected",
"function",
"_generateScaledImagesForTemplate",
"(",
"$",
"template",
",",
"$",
"overwrite",
"=",
"false",
")",
"{",
"Garp_Cli",
"::",
"lineOut",
"(",
"'Generating scaled images for template \"'",
".",
"$",
"template",
".",
"'\".'",
")",
";",
"$",
"im... | Generate scaled versions of all source files, along given template.
@param string $template Template name, as it appears in configuration.
@param bool $overwrite
@return bool | [
"Generate",
"scaled",
"versions",
"of",
"all",
"source",
"files",
"along",
"given",
"template",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Image.php#L164-L181 |
46,547 | grrr-amsterdam/garp3 | library/Garp/Service/HTMLPurifier/Filter/MyEmbed.php | Garp_Service_HTMLPurifier_Filter_MyEmbed.preFilter | public function preFilter($html, $config, $context) {
$regexp = '/<(\/?)embed( ?)([^>]+)?>/i';
$replace = '~$1embed$2$3~';
return preg_replace($regexp, $replace, $html);
} | php | public function preFilter($html, $config, $context) {
$regexp = '/<(\/?)embed( ?)([^>]+)?>/i';
$replace = '~$1embed$2$3~';
return preg_replace($regexp, $replace, $html);
} | [
"public",
"function",
"preFilter",
"(",
"$",
"html",
",",
"$",
"config",
",",
"$",
"context",
")",
"{",
"$",
"regexp",
"=",
"'/<(\\/?)embed( ?)([^>]+)?>/i'",
";",
"$",
"replace",
"=",
"'~$1embed$2$3~'",
";",
"return",
"preg_replace",
"(",
"$",
"regexp",
",",... | Pre-processor function, handles HTML before HTML Purifier
@param string $html
@param object $config
@param object $context
@return string | [
"Pre",
"-",
"processor",
"function",
"handles",
"HTML",
"before",
"HTML",
"Purifier"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Service/HTMLPurifier/Filter/MyEmbed.php#L25-L29 |
46,548 | grrr-amsterdam/garp3 | library/Garp/Service/HTMLPurifier/Filter/MyEmbed.php | Garp_Service_HTMLPurifier_Filter_MyEmbed.postFilter | public function postFilter($html, $config, $context) {
$regexp = '/~(\/?)embed( ?)([^~]+)?~/i';
$replace = '<$1embed$2$3>';
return preg_replace($regexp, $replace, $html);
} | php | public function postFilter($html, $config, $context) {
$regexp = '/~(\/?)embed( ?)([^~]+)?~/i';
$replace = '<$1embed$2$3>';
return preg_replace($regexp, $replace, $html);
} | [
"public",
"function",
"postFilter",
"(",
"$",
"html",
",",
"$",
"config",
",",
"$",
"context",
")",
"{",
"$",
"regexp",
"=",
"'/~(\\/?)embed( ?)([^~]+)?~/i'",
";",
"$",
"replace",
"=",
"'<$1embed$2$3>'",
";",
"return",
"preg_replace",
"(",
"$",
"regexp",
","... | Post-processor function, handles HTML after HTML Purifier
@param string $html
@param object $config
@param object $context
@return string | [
"Post",
"-",
"processor",
"function",
"handles",
"HTML",
"after",
"HTML",
"Purifier"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Service/HTMLPurifier/Filter/MyEmbed.php#L39-L43 |
46,549 | grrr-amsterdam/garp3 | library/Garp/Model/Behavior/Sluggable.php | Garp_Model_Behavior_Sluggable._addSlugFromMultiple | protected function _addSlugFromMultiple(Garp_Model_Db $model, array &$targetData, array $referenceData) {
$baseFields = $this->_config['baseField'];
$slugField = $this->_config['slugField'][0];
$baseData = array();
if (!empty($targetData[$slugField])) {
return;
}
$lang = null;
if (isset($referenceData[Garp_Model_Behavior_Translatable::LANG_COLUMN])) {
$lang = $referenceData[Garp_Model_Behavior_Translatable::LANG_COLUMN];
}
foreach ((array)$baseFields as $baseColumn) {
$baseData[] = $this->_getBaseString($baseColumn, $referenceData);
}
$baseData = implode(' ', $baseData);
$targetData[$slugField] = $this->generateUniqueSlug($baseData, $model, $slugField, $lang);
} | php | protected function _addSlugFromMultiple(Garp_Model_Db $model, array &$targetData, array $referenceData) {
$baseFields = $this->_config['baseField'];
$slugField = $this->_config['slugField'][0];
$baseData = array();
if (!empty($targetData[$slugField])) {
return;
}
$lang = null;
if (isset($referenceData[Garp_Model_Behavior_Translatable::LANG_COLUMN])) {
$lang = $referenceData[Garp_Model_Behavior_Translatable::LANG_COLUMN];
}
foreach ((array)$baseFields as $baseColumn) {
$baseData[] = $this->_getBaseString($baseColumn, $referenceData);
}
$baseData = implode(' ', $baseData);
$targetData[$slugField] = $this->generateUniqueSlug($baseData, $model, $slugField, $lang);
} | [
"protected",
"function",
"_addSlugFromMultiple",
"(",
"Garp_Model_Db",
"$",
"model",
",",
"array",
"&",
"$",
"targetData",
",",
"array",
"$",
"referenceData",
")",
"{",
"$",
"baseFields",
"=",
"$",
"this",
"->",
"_config",
"[",
"'baseField'",
"]",
";",
"$",
... | Add single slug from multiple sources
@param Garp_Model_Db $model
@param Array $data Data that will be inserted: should receive the slug
@param Array $referenceData Data to base the slug on
@return Void | [
"Add",
"single",
"slug",
"from",
"multiple",
"sources"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/Sluggable.php#L152-L168 |
46,550 | grrr-amsterdam/garp3 | library/Garp/Model/Behavior/Sluggable.php | Garp_Model_Behavior_Sluggable._getBaseString | protected function _getBaseString($baseField, $data) {
$type = $baseField['type'];
$method = '_getBaseStringFrom' . ucfirst($type);
return $this->{$method}($data, $baseField);
} | php | protected function _getBaseString($baseField, $data) {
$type = $baseField['type'];
$method = '_getBaseStringFrom' . ucfirst($type);
return $this->{$method}($data, $baseField);
} | [
"protected",
"function",
"_getBaseString",
"(",
"$",
"baseField",
",",
"$",
"data",
")",
"{",
"$",
"type",
"=",
"$",
"baseField",
"[",
"'type'",
"]",
";",
"$",
"method",
"=",
"'_getBaseStringFrom'",
".",
"ucfirst",
"(",
"$",
"type",
")",
";",
"return",
... | Construct base string on which the slug will be based.
@param Array $baseFields Basefield configuration (per field)
@param Array $data Submitted data
@return String | [
"Construct",
"base",
"string",
"on",
"which",
"the",
"slug",
"will",
"be",
"based",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/Sluggable.php#L200-L204 |
46,551 | grrr-amsterdam/garp3 | library/Garp/Model/Behavior/Sluggable.php | Garp_Model_Behavior_Sluggable._getBaseStringFromText | protected function _getBaseStringFromText(array $data, array $baseField) {
$col = $baseField['column'];
if (!array_key_exists($col, $data)) {
return '';
}
return $data[$col];
} | php | protected function _getBaseStringFromText(array $data, array $baseField) {
$col = $baseField['column'];
if (!array_key_exists($col, $data)) {
return '';
}
return $data[$col];
} | [
"protected",
"function",
"_getBaseStringFromText",
"(",
"array",
"$",
"data",
",",
"array",
"$",
"baseField",
")",
"{",
"$",
"col",
"=",
"$",
"baseField",
"[",
"'column'",
"]",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"col",
",",
"$",
"data",
... | Get base string from text column.
@param Array $data
@param Array $baseField Base field config
@return String | [
"Get",
"base",
"string",
"from",
"text",
"column",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/Sluggable.php#L212-L218 |
46,552 | grrr-amsterdam/garp3 | library/Garp/Model/Behavior/Sluggable.php | Garp_Model_Behavior_Sluggable._getBaseStringFromDate | protected function _getBaseStringFromDate(array $data, array $baseField) {
$col = $baseField['column'];
$format = $baseField['format'] ?: 'd-m-Y';
if (!array_key_exists($col, $data)) {
return '';
}
return date($format, strtotime($data[$col]));
} | php | protected function _getBaseStringFromDate(array $data, array $baseField) {
$col = $baseField['column'];
$format = $baseField['format'] ?: 'd-m-Y';
if (!array_key_exists($col, $data)) {
return '';
}
return date($format, strtotime($data[$col]));
} | [
"protected",
"function",
"_getBaseStringFromDate",
"(",
"array",
"$",
"data",
",",
"array",
"$",
"baseField",
")",
"{",
"$",
"col",
"=",
"$",
"baseField",
"[",
"'column'",
"]",
";",
"$",
"format",
"=",
"$",
"baseField",
"[",
"'format'",
"]",
"?",
":",
... | Get base string from date column.
@param Array $data
@param Array $baseField Base field config
@return String | [
"Get",
"base",
"string",
"from",
"date",
"column",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/Sluggable.php#L226-L233 |
46,553 | grrr-amsterdam/garp3 | library/Garp/Model/Behavior/Sluggable.php | Garp_Model_Behavior_Sluggable.generateUniqueSlug | public function generateUniqueSlug($base, $model, $slugField, $lang = null) {
$slug = $this->generateSlug($base);
$select = $model->getAdapter()->select()
->from($model->getName(), 'COUNT(*)')
;
$this->_setWhereClause($select, $slugField, $slug, $model, $lang);
$n = 1;
while ($this->_rowsExist($select)) {
$this->_incrementSlug($slug, ++$n, $base);
$this->_setWhereClause($select, $slugField, $slug, $model, $lang);
}
return $slug;
} | php | public function generateUniqueSlug($base, $model, $slugField, $lang = null) {
$slug = $this->generateSlug($base);
$select = $model->getAdapter()->select()
->from($model->getName(), 'COUNT(*)')
;
$this->_setWhereClause($select, $slugField, $slug, $model, $lang);
$n = 1;
while ($this->_rowsExist($select)) {
$this->_incrementSlug($slug, ++$n, $base);
$this->_setWhereClause($select, $slugField, $slug, $model, $lang);
}
return $slug;
} | [
"public",
"function",
"generateUniqueSlug",
"(",
"$",
"base",
",",
"$",
"model",
",",
"$",
"slugField",
",",
"$",
"lang",
"=",
"null",
")",
"{",
"$",
"slug",
"=",
"$",
"this",
"->",
"generateSlug",
"(",
"$",
"base",
")",
";",
"$",
"select",
"=",
"$... | Generate a slug from a base string that is unique in the database
@param String $base
@param Model $model Model object of this record
@param String $slugField Name of the slug column in the database
@param String $lang Optional language. Used with internationalized models
@return String $slug The generated unique slug | [
"Generate",
"a",
"slug",
"from",
"a",
"base",
"string",
"that",
"is",
"unique",
"in",
"the",
"database"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/Sluggable.php#L252-L264 |
46,554 | grrr-amsterdam/garp3 | library/Garp/Model/Behavior/Sluggable.php | Garp_Model_Behavior_Sluggable._setWhereClause | protected function _setWhereClause(Zend_Db_Select &$select, $slugField, $slug, Garp_Model_Db $model, $lang = null) {
$slugField = $model->getAdapter()->quoteIdentifier($slugField);
$select->reset(Zend_Db_Select::WHERE)
->where($slugField . ' = ?', $slug);
if ($lang) {
$select->where(Garp_Model_Behavior_Translatable::LANG_COLUMN . ' = ?', $lang);
}
} | php | protected function _setWhereClause(Zend_Db_Select &$select, $slugField, $slug, Garp_Model_Db $model, $lang = null) {
$slugField = $model->getAdapter()->quoteIdentifier($slugField);
$select->reset(Zend_Db_Select::WHERE)
->where($slugField . ' = ?', $slug);
if ($lang) {
$select->where(Garp_Model_Behavior_Translatable::LANG_COLUMN . ' = ?', $lang);
}
} | [
"protected",
"function",
"_setWhereClause",
"(",
"Zend_Db_Select",
"&",
"$",
"select",
",",
"$",
"slugField",
",",
"$",
"slug",
",",
"Garp_Model_Db",
"$",
"model",
",",
"$",
"lang",
"=",
"null",
")",
"{",
"$",
"slugField",
"=",
"$",
"model",
"->",
"getAd... | Set WHERE clause that checks for slug existence.
@param Zend_Db_Select $select
@param String $slugField
@param String $slug
@param Garp_Model_Db $model
@param String $lang
@return Void | [
"Set",
"WHERE",
"clause",
"that",
"checks",
"for",
"slug",
"existence",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/Sluggable.php#L275-L282 |
46,555 | grrr-amsterdam/garp3 | library/Garp/Model/Behavior/Sluggable.php | Garp_Model_Behavior_Sluggable._incrementSlug | protected function _incrementSlug(&$slug, $n, $original_input) {
$original_slug = $this->generateSlug($original_input);
$slug = $original_slug . static::VERSION_SEPARATOR . $n;
return;
} | php | protected function _incrementSlug(&$slug, $n, $original_input) {
$original_slug = $this->generateSlug($original_input);
$slug = $original_slug . static::VERSION_SEPARATOR . $n;
return;
} | [
"protected",
"function",
"_incrementSlug",
"(",
"&",
"$",
"slug",
",",
"$",
"n",
",",
"$",
"original_input",
")",
"{",
"$",
"original_slug",
"=",
"$",
"this",
"->",
"generateSlug",
"(",
"$",
"original_input",
")",
";",
"$",
"slug",
"=",
"$",
"original_sl... | Increment the version number in a slug
@param String $slug
@param Int $n Version number
@param String $original_input The original base string
@return Void Edits slug reference | [
"Increment",
"the",
"version",
"number",
"in",
"a",
"slug"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/Sluggable.php#L301-L305 |
46,556 | grrr-amsterdam/garp3 | library/Garp/Model/Behavior/Sluggable.php | Garp_Model_Behavior_Sluggable._normalizeBaseFieldConfiguration | protected function _normalizeBaseFieldConfiguration(&$config) {
$bf_config = (array)$config['baseField'];
$nbf_config = array();
$defaults = array(
'type' => 'text',
'format' => null
);
foreach ($bf_config as $bf) {
$bf = is_string($bf) ? array('column' => $bf) : $bf;
$bf = array_merge($defaults, $bf);
$nbf_config[] = $bf;
}
$config['baseField'] = $nbf_config;
} | php | protected function _normalizeBaseFieldConfiguration(&$config) {
$bf_config = (array)$config['baseField'];
$nbf_config = array();
$defaults = array(
'type' => 'text',
'format' => null
);
foreach ($bf_config as $bf) {
$bf = is_string($bf) ? array('column' => $bf) : $bf;
$bf = array_merge($defaults, $bf);
$nbf_config[] = $bf;
}
$config['baseField'] = $nbf_config;
} | [
"protected",
"function",
"_normalizeBaseFieldConfiguration",
"(",
"&",
"$",
"config",
")",
"{",
"$",
"bf_config",
"=",
"(",
"array",
")",
"$",
"config",
"[",
"'baseField'",
"]",
";",
"$",
"nbf_config",
"=",
"array",
"(",
")",
";",
"$",
"defaults",
"=",
"... | Normalize baseField configuration
@param Array $config
@return Void | [
"Normalize",
"baseField",
"configuration"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/Sluggable.php#L312-L325 |
46,557 | grrr-amsterdam/garp3 | library/Garp/Mailer.php | Garp_Mailer.getDefaultAttachments | public function getDefaultAttachments() {
$config = Zend_Registry::get('config');
if (!isset($config->mailer->attachments)) {
return array();
}
return $config->mailer->attachments->toArray();
} | php | public function getDefaultAttachments() {
$config = Zend_Registry::get('config');
if (!isset($config->mailer->attachments)) {
return array();
}
return $config->mailer->attachments->toArray();
} | [
"public",
"function",
"getDefaultAttachments",
"(",
")",
"{",
"$",
"config",
"=",
"Zend_Registry",
"::",
"get",
"(",
"'config'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"->",
"mailer",
"->",
"attachments",
")",
")",
"{",
"return",
"array",... | Read default attachments from config. Handy if you use images in your HTML template that are
in every mail.
@return array | [
"Read",
"default",
"attachments",
"from",
"config",
".",
"Handy",
"if",
"you",
"use",
"images",
"in",
"your",
"HTML",
"template",
"that",
"are",
"in",
"every",
"mail",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Mailer.php#L162-L168 |
46,558 | grrr-amsterdam/garp3 | library/Garp/Mailer.php | Garp_Mailer._isMailingDisabled | protected function _isMailingDisabled() {
$config = Zend_Registry::get('config');
return (isset($config->mailer->sendMail) && !$config->mailer->sendMail) ||
($this->_isAmazonSesConfigured() &&
(isset($config->amazon->ses->sendMail) && !$config->amazon->ses->sendMail));
} | php | protected function _isMailingDisabled() {
$config = Zend_Registry::get('config');
return (isset($config->mailer->sendMail) && !$config->mailer->sendMail) ||
($this->_isAmazonSesConfigured() &&
(isset($config->amazon->ses->sendMail) && !$config->amazon->ses->sendMail));
} | [
"protected",
"function",
"_isMailingDisabled",
"(",
")",
"{",
"$",
"config",
"=",
"Zend_Registry",
"::",
"get",
"(",
"'config'",
")",
";",
"return",
"(",
"isset",
"(",
"$",
"config",
"->",
"mailer",
"->",
"sendMail",
")",
"&&",
"!",
"$",
"config",
"->",
... | For legacy reasons, mailing can be disabled both thru the mailer key or thru amazon ses
configuration.
@return void | [
"For",
"legacy",
"reasons",
"mailing",
"can",
"be",
"disabled",
"both",
"thru",
"the",
"mailer",
"key",
"or",
"thru",
"amazon",
"ses",
"configuration",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Mailer.php#L281-L286 |
46,559 | grrr-amsterdam/garp3 | library/Garp/Store/Cookie.php | Garp_Store_Cookie.writeCookie | public function writeCookie() {
/**
* When Garp is used from the commandline, writing cookies is impossible.
* And that's okay.
*/
if (Zend_Registry::isRegistered('CLI') && Zend_Registry::get('CLI')) {
return true;
}
if (headers_sent($file, $line)) {
throw new Garp_Store_Exception(
'Error: headers are already sent, cannot set cookie. ' . "\n" .
'Output already started at: ' . $file . '::' . $line
);
}
$data = is_array($this->_data) ?
json_encode($this->_data, JSON_FORCE_OBJECT) :
$this->_data;
setcookie(
$this->_namespace,
$data,
time()+$this->_cookieDuration,
$this->_cookiePath,
$this->_cookieDomain
);
$this->_modified = false;
} | php | public function writeCookie() {
/**
* When Garp is used from the commandline, writing cookies is impossible.
* And that's okay.
*/
if (Zend_Registry::isRegistered('CLI') && Zend_Registry::get('CLI')) {
return true;
}
if (headers_sent($file, $line)) {
throw new Garp_Store_Exception(
'Error: headers are already sent, cannot set cookie. ' . "\n" .
'Output already started at: ' . $file . '::' . $line
);
}
$data = is_array($this->_data) ?
json_encode($this->_data, JSON_FORCE_OBJECT) :
$this->_data;
setcookie(
$this->_namespace,
$data,
time()+$this->_cookieDuration,
$this->_cookiePath,
$this->_cookieDomain
);
$this->_modified = false;
} | [
"public",
"function",
"writeCookie",
"(",
")",
"{",
"/**\n * When Garp is used from the commandline, writing cookies is impossible.\n * And that's okay.\n */",
"if",
"(",
"Zend_Registry",
"::",
"isRegistered",
"(",
"'CLI'",
")",
"&&",
"Zend_Registry",
"::",
... | Write internal array to actual cookie.
@return void | [
"Write",
"internal",
"array",
"to",
"actual",
"cookie",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Store/Cookie.php#L128-L155 |
46,560 | grrr-amsterdam/garp3 | library/Garp/Store/Cookie.php | Garp_Store_Cookie.setFromArray | public function setFromArray(array $values) {
foreach ($values as $key => $val) {
$this->set($key, $val);
}
return $this;
} | php | public function setFromArray(array $values) {
foreach ($values as $key => $val) {
$this->set($key, $val);
}
return $this;
} | [
"public",
"function",
"setFromArray",
"(",
"array",
"$",
"values",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"val",
")",
";",
"}",
"return",
"$",
... | Store a bunch of values all at once
@param array $values
@return $this | [
"Store",
"a",
"bunch",
"of",
"values",
"all",
"at",
"once"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Store/Cookie.php#L194-L199 |
46,561 | grrr-amsterdam/garp3 | library/Garp/Util/Memory.php | Garp_Util_Memory.useHighMemory | public function useHighMemory($mem = null) {
$ini = Zend_Registry::get('config');
if (empty($ini->app->highMemory)) {
return;
}
$highMemory = $ini->app->highMemory;
$currentMemoryLimit = $this->getCurrentMemoryLimit();
if (!empty($currentMemoryLimit)) {
$megs = (int)substr($currentMemoryLimit, 0, -1);
if ($megs < $highMemory) {
ini_set('memory_limit', $highMemory . 'M');
}
} else {
ini_set('memory_limit', $highMemory . 'M');
}
} | php | public function useHighMemory($mem = null) {
$ini = Zend_Registry::get('config');
if (empty($ini->app->highMemory)) {
return;
}
$highMemory = $ini->app->highMemory;
$currentMemoryLimit = $this->getCurrentMemoryLimit();
if (!empty($currentMemoryLimit)) {
$megs = (int)substr($currentMemoryLimit, 0, -1);
if ($megs < $highMemory) {
ini_set('memory_limit', $highMemory . 'M');
}
} else {
ini_set('memory_limit', $highMemory . 'M');
}
} | [
"public",
"function",
"useHighMemory",
"(",
"$",
"mem",
"=",
"null",
")",
"{",
"$",
"ini",
"=",
"Zend_Registry",
"::",
"get",
"(",
"'config'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ini",
"->",
"app",
"->",
"highMemory",
")",
")",
"{",
"return",
... | Raises PHP's RAM limit for extensive operations.
Takes its value from application.ini if not provided.
@param int $mem In MBs.
@return Void | [
"Raises",
"PHP",
"s",
"RAM",
"limit",
"for",
"extensive",
"operations",
".",
"Takes",
"its",
"value",
"from",
"application",
".",
"ini",
"if",
"not",
"provided",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Util/Memory.php#L17-L32 |
46,562 | grrr-amsterdam/garp3 | application/modules/g/views/helpers/I18n.php | G_View_Helper_I18n.getAlternateUrl | public function getAlternateUrl(
$language, array $routeParams = array(), $route = null, $defaultToHome = true
) {
if (!$route) {
$router = Zend_Controller_Front::getInstance()->getRouter();
$route = $router->getCurrentRouteName();
}
if (empty($this->view->config()->resources->router->routesFile->{$language})) {
return null;
}
$routes = $this->_getRoutesWithFallback($language);
$localizedRoutes = Garp_I18n::getLocalizedRoutes($routes, array($language));
$router = new Zend_Controller_Router_Rewrite();
$router->addConfig(new Zend_Config($localizedRoutes));
$routeParams['locale'] = $language;
// @todo Also add existing GET params in the form of ?foo=bar
try {
$alternateRoute = $router->assemble($routeParams, $route);
} catch (Exception $e) {
// try to default to 'home'
if (!$defaultToHome) {
throw $e;
}
return $this->_constructHomeFallbackUrl($language);
}
// Remove the baseURl because it contains the current language
$alternateRoute = $this->view->string()->strReplaceOnce(
$this->view->baseUrl(), '', $alternateRoute
);
// Always use explicit localization
if ($alternateRoute == '/') {
$alternateRoute = '/' . $language;
}
return $alternateRoute;
} | php | public function getAlternateUrl(
$language, array $routeParams = array(), $route = null, $defaultToHome = true
) {
if (!$route) {
$router = Zend_Controller_Front::getInstance()->getRouter();
$route = $router->getCurrentRouteName();
}
if (empty($this->view->config()->resources->router->routesFile->{$language})) {
return null;
}
$routes = $this->_getRoutesWithFallback($language);
$localizedRoutes = Garp_I18n::getLocalizedRoutes($routes, array($language));
$router = new Zend_Controller_Router_Rewrite();
$router->addConfig(new Zend_Config($localizedRoutes));
$routeParams['locale'] = $language;
// @todo Also add existing GET params in the form of ?foo=bar
try {
$alternateRoute = $router->assemble($routeParams, $route);
} catch (Exception $e) {
// try to default to 'home'
if (!$defaultToHome) {
throw $e;
}
return $this->_constructHomeFallbackUrl($language);
}
// Remove the baseURl because it contains the current language
$alternateRoute = $this->view->string()->strReplaceOnce(
$this->view->baseUrl(), '', $alternateRoute
);
// Always use explicit localization
if ($alternateRoute == '/') {
$alternateRoute = '/' . $language;
}
return $alternateRoute;
} | [
"public",
"function",
"getAlternateUrl",
"(",
"$",
"language",
",",
"array",
"$",
"routeParams",
"=",
"array",
"(",
")",
",",
"$",
"route",
"=",
"null",
",",
"$",
"defaultToHome",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"route",
")",
"{",
"$",
... | Get a route in a different language.
@param string $language
@param array $routeParams Parameters used in assembling the alternate route
@param string $route Which route to use. Defaults to current route.
@param bool $defaultToHome Wether to use home as a fallback alt route
@return string | [
"Get",
"a",
"route",
"in",
"a",
"different",
"language",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/I18n.php#L29-L66 |
46,563 | grrr-amsterdam/garp3 | application/modules/g/views/helpers/I18n.php | G_View_Helper_I18n._getRoutesWithFallback | protected function _getRoutesWithFallback($language) {
$routesFile = $this->view->config()->resources->router->routesFile->{$language};
$config = new Garp_Config_Ini($routesFile, APPLICATION_ENV);
if ($config->routes) {
return $config->routes->toArray();
}
$routesFile = $this->view->config()->resources->router->routesFile->generic;
$config = new Garp_Config_Ini($routesFile, APPLICATION_ENV);
return $config->routes->toArray();
} | php | protected function _getRoutesWithFallback($language) {
$routesFile = $this->view->config()->resources->router->routesFile->{$language};
$config = new Garp_Config_Ini($routesFile, APPLICATION_ENV);
if ($config->routes) {
return $config->routes->toArray();
}
$routesFile = $this->view->config()->resources->router->routesFile->generic;
$config = new Garp_Config_Ini($routesFile, APPLICATION_ENV);
return $config->routes->toArray();
} | [
"protected",
"function",
"_getRoutesWithFallback",
"(",
"$",
"language",
")",
"{",
"$",
"routesFile",
"=",
"$",
"this",
"->",
"view",
"->",
"config",
"(",
")",
"->",
"resources",
"->",
"router",
"->",
"routesFile",
"->",
"{",
"$",
"language",
"}",
";",
"... | Return generic routes if routes file from language is empty
@param string $language
@return array | [
"Return",
"generic",
"routes",
"if",
"routes",
"file",
"from",
"language",
"is",
"empty"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/I18n.php#L103-L114 |
46,564 | grrr-amsterdam/garp3 | library/Garp/Service/MailChimp.php | Garp_Service_MailChimp.listSubscribe | public function listSubscribe($options) {
if (!$options instanceof Garp_Util_Configuration) {
$options = new Garp_Util_Configuration($options);
}
$options->obligate('email_address')
->obligate('id')
->setDefault('merge_vars', array('LNAME' => '', 'FNAME' => ''))
;
$options['method'] = 'listSubscribe';
return $this->_send((array)$options);
} | php | public function listSubscribe($options) {
if (!$options instanceof Garp_Util_Configuration) {
$options = new Garp_Util_Configuration($options);
}
$options->obligate('email_address')
->obligate('id')
->setDefault('merge_vars', array('LNAME' => '', 'FNAME' => ''))
;
$options['method'] = 'listSubscribe';
return $this->_send((array)$options);
} | [
"public",
"function",
"listSubscribe",
"(",
"$",
"options",
")",
"{",
"if",
"(",
"!",
"$",
"options",
"instanceof",
"Garp_Util_Configuration",
")",
"{",
"$",
"options",
"=",
"new",
"Garp_Util_Configuration",
"(",
"$",
"options",
")",
";",
"}",
"$",
"options"... | Subscribe the provided email to a list.
@param Array|Garp_Util_Configuration $options
@return StdClass | [
"Subscribe",
"the",
"provided",
"email",
"to",
"a",
"list",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Service/MailChimp.php#L56-L66 |
46,565 | grrr-amsterdam/garp3 | library/Garp/Service/MailChimp.php | Garp_Service_MailChimp._getApiKey | protected function _getApiKey() {
$ini = Zend_Registry::get('config');
if (!$apiKey = $ini->mailchimp->apiKey) {
throw new Garp_Service_MailChimp_Exception('No API key was given, nor found in application.ini');
}
return $apiKey;
} | php | protected function _getApiKey() {
$ini = Zend_Registry::get('config');
if (!$apiKey = $ini->mailchimp->apiKey) {
throw new Garp_Service_MailChimp_Exception('No API key was given, nor found in application.ini');
}
return $apiKey;
} | [
"protected",
"function",
"_getApiKey",
"(",
")",
"{",
"$",
"ini",
"=",
"Zend_Registry",
"::",
"get",
"(",
"'config'",
")",
";",
"if",
"(",
"!",
"$",
"apiKey",
"=",
"$",
"ini",
"->",
"mailchimp",
"->",
"apiKey",
")",
"{",
"throw",
"new",
"Garp_Service_M... | Get API key from ini file
@return String | [
"Get",
"API",
"key",
"from",
"ini",
"file"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Service/MailChimp.php#L128-L134 |
46,566 | grrr-amsterdam/garp3 | library/Garp/Service/Vimeo/Pro/Method/Videos.php | Garp_Service_Vimeo_Pro_Method_Videos.addCast | public function addCast($user_id, $video_id, $role = null) {
if (!$this->getAccessToken()) {
throw new Garp_Service_Vimeo_Exception('This method requires an authenticated user. '.
'Please provide an access token.');
}
$params = array('user_id' => $user_id, 'video_id' => $video_id);
if ($role) {
$params['role'] = $role;
}
$response = $this->request('videos.addCast', $params);
return $response;
} | php | public function addCast($user_id, $video_id, $role = null) {
if (!$this->getAccessToken()) {
throw new Garp_Service_Vimeo_Exception('This method requires an authenticated user. '.
'Please provide an access token.');
}
$params = array('user_id' => $user_id, 'video_id' => $video_id);
if ($role) {
$params['role'] = $role;
}
$response = $this->request('videos.addCast', $params);
return $response;
} | [
"public",
"function",
"addCast",
"(",
"$",
"user_id",
",",
"$",
"video_id",
",",
"$",
"role",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
")",
"{",
"throw",
"new",
"Garp_Service_Vimeo_Exception",
"(",
"'This meth... | Add a specified user as a cast member to the video.
@param String $user_id The user to add as a cast member.
@param String $video_id The video to add the cast member to.
@param String $role The role of the user in the video.
@return Array | [
"Add",
"a",
"specified",
"user",
"as",
"a",
"cast",
"member",
"to",
"the",
"video",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Service/Vimeo/Pro/Method/Videos.php#L20-L31 |
46,567 | grrr-amsterdam/garp3 | library/Garp/Validate/GreaterThanOrEqualTo.php | Garp_Validate_GreaterThanOrEqualTo.isValid | public function isValid($value)
{
$this->_setValue($value);
if ($this->_min > $value) {
$this->_error(self::NOT_GREATER_OR_EQUAL_TO);
return false;
}
return true;
} | php | public function isValid($value)
{
$this->_setValue($value);
if ($this->_min > $value) {
$this->_error(self::NOT_GREATER_OR_EQUAL_TO);
return false;
}
return true;
} | [
"public",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"_setValue",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_min",
">",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"_error",
"(",
"self",
"::",
"NOT_GRE... | Defined by Zend_Validate_Interface
Overwrites the function in Zend_Validate_GreaterThan to deal with equal to
Returns true if $value is greater than or equal to min option
@param mixed $value
@return boolean | [
"Defined",
"by",
"Zend_Validate_Interface",
"Overwrites",
"the",
"function",
"in",
"Zend_Validate_GreaterThan",
"to",
"deal",
"with",
"equal",
"to"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Validate/GreaterThanOrEqualTo.php#L30-L39 |
46,568 | grrr-amsterdam/garp3 | library/Garp/Model/Validator/MinLength.php | Garp_Model_Validator_MinLength.validate | public function validate(array $data, Garp_Model_Db $model, $onlyIfAvailable = true) {
$theFields = $this->_fields;
$applicableFields = array_keys(array_get_subset($data, array_keys($theFields)));
$tooShortFields = array_filter(
$applicableFields,
function ($field) use ($theFields, $data) {
return !is_null($data[$field]) && strlen($data[$field]) < $theFields[$field];
}
);
if (count($tooShortFields)) {
$first = current($tooShortFields);
throw new Garp_Model_Validator_Exception(
Garp_Util_String::interpolate(
__(self::ERROR_MESSAGE),
array(
'value' => $first,
'min' => $theFields[$first]
)
)
);
}
} | php | public function validate(array $data, Garp_Model_Db $model, $onlyIfAvailable = true) {
$theFields = $this->_fields;
$applicableFields = array_keys(array_get_subset($data, array_keys($theFields)));
$tooShortFields = array_filter(
$applicableFields,
function ($field) use ($theFields, $data) {
return !is_null($data[$field]) && strlen($data[$field]) < $theFields[$field];
}
);
if (count($tooShortFields)) {
$first = current($tooShortFields);
throw new Garp_Model_Validator_Exception(
Garp_Util_String::interpolate(
__(self::ERROR_MESSAGE),
array(
'value' => $first,
'min' => $theFields[$first]
)
)
);
}
} | [
"public",
"function",
"validate",
"(",
"array",
"$",
"data",
",",
"Garp_Model_Db",
"$",
"model",
",",
"$",
"onlyIfAvailable",
"=",
"true",
")",
"{",
"$",
"theFields",
"=",
"$",
"this",
"->",
"_fields",
";",
"$",
"applicableFields",
"=",
"array_keys",
"(",
... | Validate wether the given columns are long enough
@param array $data The data to validate
@param Garp_Model_Db $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",
"long",
"enough"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Validator/MinLength.php#L38-L61 |
46,569 | grrr-amsterdam/garp3 | library/Garp/Model/Behavior/Draftable.php | Garp_Model_Behavior_Draftable.beforeFetch | public function beforeFetch(&$args) {
$model = $args[0];
$is_cms = $model->isCmsContext();
$is_preview = $this->_isPreview() && Garp_Auth::getInstance()->isLoggedIn();
$force = $this->_force;
if (($is_cms || $is_preview) && !$force) {
// don't use in the CMS, or in preview mode
return;
}
$model = &$args[0];
$select = &$args[1];
if ($this->_blockOfflineItems) {
$this->addWhereClause($model, $select);
}
} | php | public function beforeFetch(&$args) {
$model = $args[0];
$is_cms = $model->isCmsContext();
$is_preview = $this->_isPreview() && Garp_Auth::getInstance()->isLoggedIn();
$force = $this->_force;
if (($is_cms || $is_preview) && !$force) {
// don't use in the CMS, or in preview mode
return;
}
$model = &$args[0];
$select = &$args[1];
if ($this->_blockOfflineItems) {
$this->addWhereClause($model, $select);
}
} | [
"public",
"function",
"beforeFetch",
"(",
"&",
"$",
"args",
")",
"{",
"$",
"model",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"$",
"is_cms",
"=",
"$",
"model",
"->",
"isCmsContext",
"(",
")",
";",
"$",
"is_preview",
"=",
"$",
"this",
"->",
"_isPreview"... | Before fetch callback.
Adds the WHERE clause.
@param array $args
@return void | [
"Before",
"fetch",
"callback",
".",
"Adds",
"the",
"WHERE",
"clause",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/Draftable.php#L80-L97 |
46,570 | grrr-amsterdam/garp3 | library/Garp/Model/Behavior/Draftable.php | Garp_Model_Behavior_Draftable.addWhereClause | public function addWhereClause(&$model, Zend_Db_Select &$select) {
$statusColumn = $model->getAdapter()->quoteIdentifier(self::STATUS_COLUMN);
$publishedColumn = $model->getAdapter()->quoteIdentifier(self::PUBLISHED_COLUMN);
if ($this->_modelAlias) {
$modelAlias = $this->_modelAlias;
$modelAlias = $model->getAdapter()->quoteIdentifier($modelAlias);
$statusColumn = "$modelAlias.$statusColumn";
$publishedColumn = "$modelAlias.$publishedColumn";
}
// Add online_status check
$select->where($statusColumn . ' = ?', self::ONLINE);
// Add published check
if ($this->_config['draft_only']) {
return;
}
$ini = Zend_Registry::get('config');
$timezone = !empty($ini->resources->db->params->timezone) ?
$ini->resources->db->params->timezone : null;
$timecalc = '';
if ($timezone == 'GMT' || $timezone == 'UTC') {
$dstStart = strtotime('Last Sunday of March');
$dstEnd = strtotime('Last Sunday of October');
$now = time();
$daylightSavingsTime = $now > $dstStart && $now < $dstEnd;
$timecalc = '+ INTERVAL';
if ($daylightSavingsTime) {
$timecalc .= ' 2 HOUR';
} else {
$timecalc .= ' 1 HOUR';
}
}
$select->where(
$publishedColumn . ' IS NULL OR ' . $publishedColumn . ' <= NOW() ' . $timecalc
);
} | php | public function addWhereClause(&$model, Zend_Db_Select &$select) {
$statusColumn = $model->getAdapter()->quoteIdentifier(self::STATUS_COLUMN);
$publishedColumn = $model->getAdapter()->quoteIdentifier(self::PUBLISHED_COLUMN);
if ($this->_modelAlias) {
$modelAlias = $this->_modelAlias;
$modelAlias = $model->getAdapter()->quoteIdentifier($modelAlias);
$statusColumn = "$modelAlias.$statusColumn";
$publishedColumn = "$modelAlias.$publishedColumn";
}
// Add online_status check
$select->where($statusColumn . ' = ?', self::ONLINE);
// Add published check
if ($this->_config['draft_only']) {
return;
}
$ini = Zend_Registry::get('config');
$timezone = !empty($ini->resources->db->params->timezone) ?
$ini->resources->db->params->timezone : null;
$timecalc = '';
if ($timezone == 'GMT' || $timezone == 'UTC') {
$dstStart = strtotime('Last Sunday of March');
$dstEnd = strtotime('Last Sunday of October');
$now = time();
$daylightSavingsTime = $now > $dstStart && $now < $dstEnd;
$timecalc = '+ INTERVAL';
if ($daylightSavingsTime) {
$timecalc .= ' 2 HOUR';
} else {
$timecalc .= ' 1 HOUR';
}
}
$select->where(
$publishedColumn . ' IS NULL OR ' . $publishedColumn . ' <= NOW() ' . $timecalc
);
} | [
"public",
"function",
"addWhereClause",
"(",
"&",
"$",
"model",
",",
"Zend_Db_Select",
"&",
"$",
"select",
")",
"{",
"$",
"statusColumn",
"=",
"$",
"model",
"->",
"getAdapter",
"(",
")",
"->",
"quoteIdentifier",
"(",
"self",
"::",
"STATUS_COLUMN",
")",
";"... | Add the WHERE clause that keeps offline items from appearing in the results
@param Garp_Model_Db $model
@param Zend_Db_Select $select
@return void | [
"Add",
"the",
"WHERE",
"clause",
"that",
"keeps",
"offline",
"items",
"from",
"appearing",
"in",
"the",
"results"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/Draftable.php#L106-L145 |
46,571 | grrr-amsterdam/garp3 | library/Garp/Model/Behavior/Draftable.php | Garp_Model_Behavior_Draftable.afterInsert | public function afterInsert(&$args) {
$model = $args[0];
$data = $args[1];
$this->afterSave($model, $data);
} | php | public function afterInsert(&$args) {
$model = $args[0];
$data = $args[1];
$this->afterSave($model, $data);
} | [
"public",
"function",
"afterInsert",
"(",
"&",
"$",
"args",
")",
"{",
"$",
"model",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"$",
"data",
"=",
"$",
"args",
"[",
"1",
"]",
";",
"$",
"this",
"->",
"afterSave",
"(",
"$",
"model",
",",
"$",
"data",
... | After insert callback.
@param array $args
@return void | [
"After",
"insert",
"callback",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/Draftable.php#L153-L157 |
46,572 | grrr-amsterdam/garp3 | library/Garp/Model/Behavior/Draftable.php | Garp_Model_Behavior_Draftable.afterSave | public function afterSave($model, $data) {
// Check if the 'published column' is filled...
if (empty($data[self::PUBLISHED_COLUMN])) {
return;
}
// ...and that it's in the future
$publishTime = strtotime($data[self::PUBLISHED_COLUMN]);
if ($publishTime <= time()) {
return;
}
$tags = array(get_class($model));
$tags = array_merge($tags, $model->getBindableModels());
$tags = array_unique($tags);
Garp_Cache_Manager::scheduleClear($publishTime, $tags);
} | php | public function afterSave($model, $data) {
// Check if the 'published column' is filled...
if (empty($data[self::PUBLISHED_COLUMN])) {
return;
}
// ...and that it's in the future
$publishTime = strtotime($data[self::PUBLISHED_COLUMN]);
if ($publishTime <= time()) {
return;
}
$tags = array(get_class($model));
$tags = array_merge($tags, $model->getBindableModels());
$tags = array_unique($tags);
Garp_Cache_Manager::scheduleClear($publishTime, $tags);
} | [
"public",
"function",
"afterSave",
"(",
"$",
"model",
",",
"$",
"data",
")",
"{",
"// Check if the 'published column' is filled...",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"self",
"::",
"PUBLISHED_COLUMN",
"]",
")",
")",
"{",
"return",
";",
"}",
"// ...a... | After save callback, called by afterInsert and afterUpdate.
Sets an `at` job that clears the Static Page cache at the exact moment of the Published date.
@param Garp_Model_Db $model
@param array $data
@return void | [
"After",
"save",
"callback",
"called",
"by",
"afterInsert",
"and",
"afterUpdate",
".",
"Sets",
"an",
"at",
"job",
"that",
"clears",
"the",
"Static",
"Page",
"cache",
"at",
"the",
"exact",
"moment",
"of",
"the",
"Published",
"date",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/Draftable.php#L179-L195 |
46,573 | grrr-amsterdam/garp3 | library/Garp/Model/Behavior/Bindable.php | Garp_Model_Behavior_Bindable.afterFetch | public function afterFetch(&$args) {
$model = $args[0];
$data = $args[1];
$this->_combineResultsWithBindings($model, $data);
} | php | public function afterFetch(&$args) {
$model = $args[0];
$data = $args[1];
$this->_combineResultsWithBindings($model, $data);
} | [
"public",
"function",
"afterFetch",
"(",
"&",
"$",
"args",
")",
"{",
"$",
"model",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"$",
"data",
"=",
"$",
"args",
"[",
"1",
"]",
";",
"$",
"this",
"->",
"_combineResultsWithBindings",
"(",
"$",
"model",
",",
... | AfterFetch callback, combines results with related records.
@param array $args
@return void | [
"AfterFetch",
"callback",
"combines",
"results",
"with",
"related",
"records",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/Bindable.php#L32-L36 |
46,574 | grrr-amsterdam/garp3 | library/Garp/Model/Behavior/Bindable.php | Garp_Model_Behavior_Bindable._combineResultsWithBindings | protected function _combineResultsWithBindings(Garp_Model $model, $data) {
if (!$data) {
return;
}
$tableName = $model->getName();
$bindings = $model->getBindings();
if (empty($bindings)) {
return;
}
// check if it's a rowset or a single row
if (!$data instanceof Garp_Db_Table_Rowset) {
$data = array($data);
}
foreach ($bindings as $binding => $bindOptions) {
/**
* We keep tabs on the outer call to fetch() by checking getRecursion.
* If it is 0, this is the first call in the chain. That way we can
* clean up the recursion when we're done, since all subsequent fetch() calls
* will happen within this one and the if ($cleanup) line ahead will only
* fire on the first fetch(). Look at it like this:
*
* ```
* fetch()
* cleanup = 1
* fetch()
* fetch()
* fetch()
* fetch()
* fetch()
* fetch()
* if (cleanup) resetRecursion()
* ```
*/
$cleanup = false;
if (Garp_Model_Db_BindingManager::getRecursion(get_class($model), $binding) == 0) {
$cleanup = true;
}
if (Garp_Model_Db_BindingManager::isAllowedFetch(get_class($model), $binding)) {
Garp_Model_Db_BindingManager::registerFetch(get_class($model), $binding);
foreach ($data as $datum) {
// There's no relation possible if the primary key is not
// among the fetched columns.
$prim = (array)$model->info(Zend_Db_Table::PRIMARY);
foreach ($prim as $key) {
try {
$datum->$key;
} catch (Exception $e) {
break 2;
}
}
$relatedRowset = $this->_getRelatedRowset($model, $datum, $bindOptions);
$datum->setRelated($binding, $relatedRowset);
}
}
if ($cleanup) {
Garp_Model_Db_BindingManager::resetRecursion(get_class($model), $binding);
}
}
// return the pointer to 0
if ($data instanceof Garp_Db_Table_Rowset) {
$data->rewind();
}
} | php | protected function _combineResultsWithBindings(Garp_Model $model, $data) {
if (!$data) {
return;
}
$tableName = $model->getName();
$bindings = $model->getBindings();
if (empty($bindings)) {
return;
}
// check if it's a rowset or a single row
if (!$data instanceof Garp_Db_Table_Rowset) {
$data = array($data);
}
foreach ($bindings as $binding => $bindOptions) {
/**
* We keep tabs on the outer call to fetch() by checking getRecursion.
* If it is 0, this is the first call in the chain. That way we can
* clean up the recursion when we're done, since all subsequent fetch() calls
* will happen within this one and the if ($cleanup) line ahead will only
* fire on the first fetch(). Look at it like this:
*
* ```
* fetch()
* cleanup = 1
* fetch()
* fetch()
* fetch()
* fetch()
* fetch()
* fetch()
* if (cleanup) resetRecursion()
* ```
*/
$cleanup = false;
if (Garp_Model_Db_BindingManager::getRecursion(get_class($model), $binding) == 0) {
$cleanup = true;
}
if (Garp_Model_Db_BindingManager::isAllowedFetch(get_class($model), $binding)) {
Garp_Model_Db_BindingManager::registerFetch(get_class($model), $binding);
foreach ($data as $datum) {
// There's no relation possible if the primary key is not
// among the fetched columns.
$prim = (array)$model->info(Zend_Db_Table::PRIMARY);
foreach ($prim as $key) {
try {
$datum->$key;
} catch (Exception $e) {
break 2;
}
}
$relatedRowset = $this->_getRelatedRowset($model, $datum, $bindOptions);
$datum->setRelated($binding, $relatedRowset);
}
}
if ($cleanup) {
Garp_Model_Db_BindingManager::resetRecursion(get_class($model), $binding);
}
}
// return the pointer to 0
if ($data instanceof Garp_Db_Table_Rowset) {
$data->rewind();
}
} | [
"protected",
"function",
"_combineResultsWithBindings",
"(",
"Garp_Model",
"$",
"model",
",",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"$",
"data",
")",
"{",
"return",
";",
"}",
"$",
"tableName",
"=",
"$",
"model",
"->",
"getName",
"(",
")",
";",
"$",
... | Check if there are bindings to fetch related records and
start the related rowset fetching.
@param Garp_Model $model The model that spawned this data
@param Garp_Db_Table_Row|Garp_Db_Table_Rowset $data The fetched root data
@return void | [
"Check",
"if",
"there",
"are",
"bindings",
"to",
"fetch",
"related",
"records",
"and",
"start",
"the",
"related",
"rowset",
"fetching",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/Bindable.php#L46-L112 |
46,575 | grrr-amsterdam/garp3 | library/Garp/Model/Behavior/Bindable.php | Garp_Model_Behavior_Bindable._getRelatedRowset | protected function _getRelatedRowset(
Garp_Model $model, Garp_Db_Table_Row $row, Garp_Util_Configuration $options
) {
/**
* An optional passed SELECT object will be passed by reference after every query.
* This results in an error when 'clone' is not used, because correlation names will be
* used twice (since they were set during the first iteration). Using 'clone' makes sure
* a brand new SELECT object is used every time that hasn't been soiled by a possible
* previous query.
*/
$conditions = is_null($options['conditions']) ? null : clone $options['conditions'];
$otherModel = $options['modelClass'];
if (!$otherModel instanceof Zend_Db_Table_Abstract) {
$otherModel = new $otherModel();
}
// Bound models should respect the CMS context settings of the root model
$otherModel->setCmsContext($model->isCmsContext());
/**
* Do not cache related queries. The "outside" query should be the only
* query that's cached.
*/
$originalCacheQueriesFlag = $otherModel->getCacheQueries();
$otherModel->setCacheQueries(false);
$modelName = get_class($otherModel);
$relatedRowset = null;
// many to many
if (!empty($options['bindingModel'])) {
$relatedRowset = $row->findManyToManyRowset(
$otherModel,
$options['bindingModel'],
$options['rule2'],
$options['rule'],
$conditions
);
} else {
/**
* 'mode' is used to clear ambiguity with homophilic relationships. For example,
* a Model_Doc can have have child Docs and one parent Doc.
* The conditionals below can never tell which method to call
* (findParentRow or findDependentRowset) from the referenceMap.
*
* Therefore, we can help the decision-making by passing "mode". This can either be
* "parent" or "dependent", which will then force a call to
* findParentRow and findDependentRowset, respectively.
*/
if (is_null($options['mode'])) {
// belongs to
try {
$model->getReference($modelName, $options['rule']);
$relatedRowset = $row->findParentRow(
$otherModel, $options['rule'], $conditions
);
} catch(Exception $e) {
if (!Garp_Content_Relation_Manager::isInvalidReferenceException($e)) {
throw $e;
}
try {
// one to many - one to one
// The following line triggers an exception if no reference is available
$otherModel->getReference(get_class($model), $options['rule']);
$relatedRowset = $row->findDependentRowset(
$otherModel,
$options['rule'],
$conditions
);
} catch (Exception $e) {
if (!Garp_Content_Relation_Manager::isInvalidReferenceException($e)) {
throw $e;
}
$bindingModel = $model->getBindingModel($modelName);
$relatedRowset = $row->findManyToManyRowset(
$otherModel,
$bindingModel,
$options['rule2'],
$options['rule'],
$conditions
);
}
}
} else {
switch ($options['mode']) {
case 'parent':
$relatedRowset = $row->findParentRow(
$otherModel,
$options['rule'],
$conditions
);
break;
case 'dependent':
$relatedRowset = $row->findDependentRowset(
$otherModel,
$options['rule'],
$conditions
);
break;
default:
throw new Garp_Model_Exception(
'Invalid value for "mode" given. Must be either "parent" or ' .
'"dependent", but "' . $options['mode'] . '" was given.'
);
break;
}
}
}
// Reset the cacheQueries value. It's a static property,
// so leaving it FALSE will affect all future fetch() calls to this
// model. Not good.
$otherModel->setCacheQueries($originalCacheQueriesFlag);
return $relatedRowset;
} | php | protected function _getRelatedRowset(
Garp_Model $model, Garp_Db_Table_Row $row, Garp_Util_Configuration $options
) {
/**
* An optional passed SELECT object will be passed by reference after every query.
* This results in an error when 'clone' is not used, because correlation names will be
* used twice (since they were set during the first iteration). Using 'clone' makes sure
* a brand new SELECT object is used every time that hasn't been soiled by a possible
* previous query.
*/
$conditions = is_null($options['conditions']) ? null : clone $options['conditions'];
$otherModel = $options['modelClass'];
if (!$otherModel instanceof Zend_Db_Table_Abstract) {
$otherModel = new $otherModel();
}
// Bound models should respect the CMS context settings of the root model
$otherModel->setCmsContext($model->isCmsContext());
/**
* Do not cache related queries. The "outside" query should be the only
* query that's cached.
*/
$originalCacheQueriesFlag = $otherModel->getCacheQueries();
$otherModel->setCacheQueries(false);
$modelName = get_class($otherModel);
$relatedRowset = null;
// many to many
if (!empty($options['bindingModel'])) {
$relatedRowset = $row->findManyToManyRowset(
$otherModel,
$options['bindingModel'],
$options['rule2'],
$options['rule'],
$conditions
);
} else {
/**
* 'mode' is used to clear ambiguity with homophilic relationships. For example,
* a Model_Doc can have have child Docs and one parent Doc.
* The conditionals below can never tell which method to call
* (findParentRow or findDependentRowset) from the referenceMap.
*
* Therefore, we can help the decision-making by passing "mode". This can either be
* "parent" or "dependent", which will then force a call to
* findParentRow and findDependentRowset, respectively.
*/
if (is_null($options['mode'])) {
// belongs to
try {
$model->getReference($modelName, $options['rule']);
$relatedRowset = $row->findParentRow(
$otherModel, $options['rule'], $conditions
);
} catch(Exception $e) {
if (!Garp_Content_Relation_Manager::isInvalidReferenceException($e)) {
throw $e;
}
try {
// one to many - one to one
// The following line triggers an exception if no reference is available
$otherModel->getReference(get_class($model), $options['rule']);
$relatedRowset = $row->findDependentRowset(
$otherModel,
$options['rule'],
$conditions
);
} catch (Exception $e) {
if (!Garp_Content_Relation_Manager::isInvalidReferenceException($e)) {
throw $e;
}
$bindingModel = $model->getBindingModel($modelName);
$relatedRowset = $row->findManyToManyRowset(
$otherModel,
$bindingModel,
$options['rule2'],
$options['rule'],
$conditions
);
}
}
} else {
switch ($options['mode']) {
case 'parent':
$relatedRowset = $row->findParentRow(
$otherModel,
$options['rule'],
$conditions
);
break;
case 'dependent':
$relatedRowset = $row->findDependentRowset(
$otherModel,
$options['rule'],
$conditions
);
break;
default:
throw new Garp_Model_Exception(
'Invalid value for "mode" given. Must be either "parent" or ' .
'"dependent", but "' . $options['mode'] . '" was given.'
);
break;
}
}
}
// Reset the cacheQueries value. It's a static property,
// so leaving it FALSE will affect all future fetch() calls to this
// model. Not good.
$otherModel->setCacheQueries($originalCacheQueriesFlag);
return $relatedRowset;
} | [
"protected",
"function",
"_getRelatedRowset",
"(",
"Garp_Model",
"$",
"model",
",",
"Garp_Db_Table_Row",
"$",
"row",
",",
"Garp_Util_Configuration",
"$",
"options",
")",
"{",
"/**\n * An optional passed SELECT object will be passed by reference after every query.\n ... | Find a related recordset.
@param Garp_Model $model The model that spawned this data
@param Garp_Db_Row $row The row object
@param Garp_Util_Configuration $options Various relation options
@return string The name of the method. | [
"Find",
"a",
"related",
"recordset",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Behavior/Bindable.php#L122-L232 |
46,576 | grrr-amsterdam/garp3 | library/Garp/Model/Db/AuthLocal.php | Garp_Model_Db_AuthLocal.tryLogin | public function tryLogin($identity, $credential, Garp_Util_Configuration $authVars, $sessionColumns = null) {
$theOtherModel = new $authVars['model']();
$theOtherTable = $theOtherModel->getName();
if (is_null($sessionColumns)) {
$sessionColumns = Zend_Db_Select::SQL_WILDCARD;
}
$select = $this->select()
->setIntegrityCheck(false)
->from($this->_name, array($authVars['credentialColumn']))
->joinInner($theOtherTable, $this->_name.'.user_id = '.$theOtherTable.'.id', $sessionColumns)
->where($theOtherTable.'.'.$authVars['identityColumn'].' = ?', $identity)
->order($this->_name.'.id')
;
$result = $this->fetchRow($select);
// update stats if we found a match
if (!$result) {
throw new Garp_Auth_Adapter_Db_UserNotFoundException();
return null;
}
$foundCredential = $result->{$authVars['credentialColumn']};
$testCredential = $authVars['hashMethod']($credential.$authVars['salt']);
if ($foundCredential != $testCredential) {
throw new Garp_Auth_Adapter_Db_InvalidPasswordException();
}
$this->getObserver('Authenticatable')->updateLoginStats($result->id);
unset($result->{$authVars['credentialColumn']});
return $result;
} | php | public function tryLogin($identity, $credential, Garp_Util_Configuration $authVars, $sessionColumns = null) {
$theOtherModel = new $authVars['model']();
$theOtherTable = $theOtherModel->getName();
if (is_null($sessionColumns)) {
$sessionColumns = Zend_Db_Select::SQL_WILDCARD;
}
$select = $this->select()
->setIntegrityCheck(false)
->from($this->_name, array($authVars['credentialColumn']))
->joinInner($theOtherTable, $this->_name.'.user_id = '.$theOtherTable.'.id', $sessionColumns)
->where($theOtherTable.'.'.$authVars['identityColumn'].' = ?', $identity)
->order($this->_name.'.id')
;
$result = $this->fetchRow($select);
// update stats if we found a match
if (!$result) {
throw new Garp_Auth_Adapter_Db_UserNotFoundException();
return null;
}
$foundCredential = $result->{$authVars['credentialColumn']};
$testCredential = $authVars['hashMethod']($credential.$authVars['salt']);
if ($foundCredential != $testCredential) {
throw new Garp_Auth_Adapter_Db_InvalidPasswordException();
}
$this->getObserver('Authenticatable')->updateLoginStats($result->id);
unset($result->{$authVars['credentialColumn']});
return $result;
} | [
"public",
"function",
"tryLogin",
"(",
"$",
"identity",
",",
"$",
"credential",
",",
"Garp_Util_Configuration",
"$",
"authVars",
",",
"$",
"sessionColumns",
"=",
"null",
")",
"{",
"$",
"theOtherModel",
"=",
"new",
"$",
"authVars",
"[",
"'model'",
"]",
"(",
... | Try to log a user in.
@param String $identity
@param String $credential
@param Garp_Util_Configuration $authVars
@param Array $sessionColumns Which columns to retrieve for storage in the session.
@return Garp_Db_Table_Row
@throws Garp_Auth_Adapter_Db_UserNotFoundException When the user is not found
@throws Garp_Auth_Adapter_Db_InvalidPasswordException When the password does not match | [
"Try",
"to",
"log",
"a",
"user",
"in",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db/AuthLocal.php#L30-L59 |
46,577 | grrr-amsterdam/garp3 | library/Garp/Model/Db/AuthLocal.php | Garp_Model_Db_AuthLocal._hashPassword | protected function _hashPassword(array $data) {
$config = Zend_Registry::get('config');
if (!empty($config->auth->adapters->db)) {
$authVars = $config->auth->adapters->db;
$credentialColumn = $authVars->credentialColumn;
$hashMethod = $authVars->hashMethod;
$salt = $authVars->salt;
if (!empty($data[$credentialColumn])) {
$data[$credentialColumn] = new Zend_Db_Expr($hashMethod.'(CONCAT('.
$this->getAdapter()->quoteInto('?', $data[$credentialColumn]).
', '.$this->getAdapter()->quoteInto('?', $salt).'))');
}
}
return $data;
} | php | protected function _hashPassword(array $data) {
$config = Zend_Registry::get('config');
if (!empty($config->auth->adapters->db)) {
$authVars = $config->auth->adapters->db;
$credentialColumn = $authVars->credentialColumn;
$hashMethod = $authVars->hashMethod;
$salt = $authVars->salt;
if (!empty($data[$credentialColumn])) {
$data[$credentialColumn] = new Zend_Db_Expr($hashMethod.'(CONCAT('.
$this->getAdapter()->quoteInto('?', $data[$credentialColumn]).
', '.$this->getAdapter()->quoteInto('?', $salt).'))');
}
}
return $data;
} | [
"protected",
"function",
"_hashPassword",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"config",
"=",
"Zend_Registry",
"::",
"get",
"(",
"'config'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"config",
"->",
"auth",
"->",
"adapters",
"->",
"db",
")",
... | Hash an incoming password
@param Array $data The new userdata
@return Array The modified userdata | [
"Hash",
"an",
"incoming",
"password"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db/AuthLocal.php#L89-L103 |
46,578 | grrr-amsterdam/garp3 | library/Garp/Controller/Helper/Cache.php | Garp_Controller_Helper_Cache.setCacheHeaders | public function setCacheHeaders($expirationTimeInSeconds = 300) {
$expirationString = strtotime("+{$expirationTimeInSeconds} seconds");
$gmtDate = gmdate(DATE_RFC1123, $expirationString);
$this->getResponse()
->setHeader('Cache-Control', 'public', true)
->setHeader('Pragma', 'cache', true)
->setHeader('Expires', $gmtDate, true);
} | php | public function setCacheHeaders($expirationTimeInSeconds = 300) {
$expirationString = strtotime("+{$expirationTimeInSeconds} seconds");
$gmtDate = gmdate(DATE_RFC1123, $expirationString);
$this->getResponse()
->setHeader('Cache-Control', 'public', true)
->setHeader('Pragma', 'cache', true)
->setHeader('Expires', $gmtDate, true);
} | [
"public",
"function",
"setCacheHeaders",
"(",
"$",
"expirationTimeInSeconds",
"=",
"300",
")",
"{",
"$",
"expirationString",
"=",
"strtotime",
"(",
"\"+{$expirationTimeInSeconds} seconds\"",
")",
";",
"$",
"gmtDate",
"=",
"gmdate",
"(",
"DATE_RFC1123",
",",
"$",
"... | Sets the required HTTP headers to specify an expiration time.
@param int $expirationTimeInSeconds
@return void | [
"Sets",
"the",
"required",
"HTTP",
"headers",
"to",
"specify",
"an",
"expiration",
"time",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Controller/Helper/Cache.php#L32-L40 |
46,579 | grrr-amsterdam/garp3 | library/Garp/Controller/Helper/Cache.php | Garp_Controller_Helper_Cache.setNoCacheHeaders | public function setNoCacheHeaders(Zend_Controller_Response_Http $response) {
$this->getResponse()
->setHeader('Cache-Control', 'no-cache', true)
->setHeader('Pragma', 'no-cache', true)
->setHeader('Expires', date(DATE_RFC1123, strtotime('-1 year')), true);
} | php | public function setNoCacheHeaders(Zend_Controller_Response_Http $response) {
$this->getResponse()
->setHeader('Cache-Control', 'no-cache', true)
->setHeader('Pragma', 'no-cache', true)
->setHeader('Expires', date(DATE_RFC1123, strtotime('-1 year')), true);
} | [
"public",
"function",
"setNoCacheHeaders",
"(",
"Zend_Controller_Response_Http",
"$",
"response",
")",
"{",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"setHeader",
"(",
"'Cache-Control'",
",",
"'no-cache'",
",",
"true",
")",
"->",
"setHeader",
"(",
"'Prag... | Sets the required HTTP headers to prevent this request from being cached by the browser.
@param Zend_Controller_Response_Http $response The HTTP response object.
Use $this->getResponse() from a controller.
@return void | [
"Sets",
"the",
"required",
"HTTP",
"headers",
"to",
"prevent",
"this",
"request",
"from",
"being",
"cached",
"by",
"the",
"browser",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Controller/Helper/Cache.php#L49-L54 |
46,580 | grrr-amsterdam/garp3 | library/Garp/Controller/Helper/Cache.php | Garp_Controller_Helper_Cache.preDispatch | public function preDispatch() {
if ($this->getResponse()->isRedirect() || !$this->isEnabled() || $this->_requestUriTooLong()
) {
return true;
}
return parent::preDispatch();
} | php | public function preDispatch() {
if ($this->getResponse()->isRedirect() || !$this->isEnabled() || $this->_requestUriTooLong()
) {
return true;
}
return parent::preDispatch();
} | [
"public",
"function",
"preDispatch",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"isRedirect",
"(",
")",
"||",
"!",
"$",
"this",
"->",
"isEnabled",
"(",
")",
"||",
"$",
"this",
"->",
"_requestUriTooLong",
"(",
")",
")"... | Commence page caching for any cacheable actions
@return void | [
"Commence",
"page",
"caching",
"for",
"any",
"cacheable",
"actions"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Controller/Helper/Cache.php#L75-L81 |
46,581 | grrr-amsterdam/garp3 | library/Garp/Model/Db/User.php | Garp_Model_Db_User.fetchUserForSession | public function fetchUserForSession($userId) {
$select = $this->select()
->from($this->getName(), Garp_Auth::getInstance()->getSessionColumns())
->where('id = ?', $userId);
return $this->fetchRow($select);
} | php | public function fetchUserForSession($userId) {
$select = $this->select()
->from($this->getName(), Garp_Auth::getInstance()->getSessionColumns())
->where('id = ?', $userId);
return $this->fetchRow($select);
} | [
"public",
"function",
"fetchUserForSession",
"(",
"$",
"userId",
")",
"{",
"$",
"select",
"=",
"$",
"this",
"->",
"select",
"(",
")",
"->",
"from",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"Garp_Auth",
"::",
"getInstance",
"(",
")",
"->",
"g... | Grab only session columns by userid
@param int $userId
@return Garp_Db_Table_Row | [
"Grab",
"only",
"session",
"columns",
"by",
"userid"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db/User.php#L50-L55 |
46,582 | grrr-amsterdam/garp3 | library/Garp/Model/Db/User.php | Garp_Model_Db_User.updateUserWithActivationCode | public function updateUserWithActivationCode($userId, $activationCode, $activationExpiry) {
$authVars = Garp_Auth::getInstance()->getConfigValues('forgotpassword');
$expiresColumn = $authVars['activation_code_expiration_date_column'];
$tokenColumn = $authVars['activation_token_column'];
$quotedUserId = $this->getAdapter()->quote($userId);
return $this->update(
array(
$expiresColumn => $activationExpiry,
$tokenColumn => $activationCode
), "id = $quotedUserId"
);
} | php | public function updateUserWithActivationCode($userId, $activationCode, $activationExpiry) {
$authVars = Garp_Auth::getInstance()->getConfigValues('forgotpassword');
$expiresColumn = $authVars['activation_code_expiration_date_column'];
$tokenColumn = $authVars['activation_token_column'];
$quotedUserId = $this->getAdapter()->quote($userId);
return $this->update(
array(
$expiresColumn => $activationExpiry,
$tokenColumn => $activationCode
), "id = $quotedUserId"
);
} | [
"public",
"function",
"updateUserWithActivationCode",
"(",
"$",
"userId",
",",
"$",
"activationCode",
",",
"$",
"activationExpiry",
")",
"{",
"$",
"authVars",
"=",
"Garp_Auth",
"::",
"getInstance",
"(",
")",
"->",
"getConfigValues",
"(",
"'forgotpassword'",
")",
... | Update user with activation code and expire time.
Used when forgot password
@param int $userId
@param string $activationCode
@param string $activationExpiry
@return int updated rows | [
"Update",
"user",
"with",
"activation",
"code",
"and",
"expire",
"time",
".",
"Used",
"when",
"forgot",
"password"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db/User.php#L66-L78 |
46,583 | grrr-amsterdam/garp3 | library/Garp/Model/Db/User.php | Garp_Model_Db_User._onEmailChange | protected function _onEmailChange($email, $updateOrInsert = 'insert') {
$authVars = Garp_Auth::getInstance()->getConfigValues('validateemail');
// See if validation of email is enabled
if (empty($authVars['enabled']) || !$authVars['enabled']) {
return;
}
$validationTokenColumn = $authVars['token_column'];
$emailValidColumn = $authVars['email_valid_column'];
// Fetch fresh user data by email
$users = $this->fetchAll(
$this->select()->from(
$this->getName(),
array('id', 'email', $validationTokenColumn, $emailValidColumn)
)
->where('email = ?', $email)
);
// Generate validation token for all the found users
foreach ($users as $user) {
$this->invalidateEmailAddress($user, $updateOrInsert);
}
} | php | protected function _onEmailChange($email, $updateOrInsert = 'insert') {
$authVars = Garp_Auth::getInstance()->getConfigValues('validateemail');
// See if validation of email is enabled
if (empty($authVars['enabled']) || !$authVars['enabled']) {
return;
}
$validationTokenColumn = $authVars['token_column'];
$emailValidColumn = $authVars['email_valid_column'];
// Fetch fresh user data by email
$users = $this->fetchAll(
$this->select()->from(
$this->getName(),
array('id', 'email', $validationTokenColumn, $emailValidColumn)
)
->where('email = ?', $email)
);
// Generate validation token for all the found users
foreach ($users as $user) {
$this->invalidateEmailAddress($user, $updateOrInsert);
}
} | [
"protected",
"function",
"_onEmailChange",
"(",
"$",
"email",
",",
"$",
"updateOrInsert",
"=",
"'insert'",
")",
"{",
"$",
"authVars",
"=",
"Garp_Auth",
"::",
"getInstance",
"(",
")",
"->",
"getConfigValues",
"(",
"'validateemail'",
")",
";",
"// See if validatio... | Respond to change in email address
@param String $email The new email address
@param String $updateOrInsert Wether this was caused by an insert or an update
@return Void | [
"Respond",
"to",
"change",
"in",
"email",
"address"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db/User.php#L264-L287 |
46,584 | grrr-amsterdam/garp3 | library/Garp/Model/Db/User.php | Garp_Model_Db_User.invalidateEmailAddress | public function invalidateEmailAddress(Garp_Db_Table_Row $user, $updateOrInsert = 'insert') {
$authVars = Garp_Auth::getInstance()->getConfigValues('validateemail');
$validationTokenColumn = $authVars['token_column'];
$emailValidColumn = $authVars['email_valid_column'];
if ($updateOrInsert == 'insert' && array_get($user, $emailValidColumn)) {
return true;
}
// Generate the validation code
$validationToken = uniqid();
$validationCode = $this->generateEmailValidationCode($user, $validationToken);
if (!$user->isConnected()) {
$user->setTable($this);
}
// Store the token in the user record
$user->{$validationTokenColumn} = $validationToken;
// Invalidate the user's email
$user->{$emailValidColumn} = 0;
if ($user->save()) {
return $this->sendEmailValidationEmail($user, $validationCode, $updateOrInsert);
}
return false;
} | php | public function invalidateEmailAddress(Garp_Db_Table_Row $user, $updateOrInsert = 'insert') {
$authVars = Garp_Auth::getInstance()->getConfigValues('validateemail');
$validationTokenColumn = $authVars['token_column'];
$emailValidColumn = $authVars['email_valid_column'];
if ($updateOrInsert == 'insert' && array_get($user, $emailValidColumn)) {
return true;
}
// Generate the validation code
$validationToken = uniqid();
$validationCode = $this->generateEmailValidationCode($user, $validationToken);
if (!$user->isConnected()) {
$user->setTable($this);
}
// Store the token in the user record
$user->{$validationTokenColumn} = $validationToken;
// Invalidate the user's email
$user->{$emailValidColumn} = 0;
if ($user->save()) {
return $this->sendEmailValidationEmail($user, $validationCode, $updateOrInsert);
}
return false;
} | [
"public",
"function",
"invalidateEmailAddress",
"(",
"Garp_Db_Table_Row",
"$",
"user",
",",
"$",
"updateOrInsert",
"=",
"'insert'",
")",
"{",
"$",
"authVars",
"=",
"Garp_Auth",
"::",
"getInstance",
"(",
")",
"->",
"getConfigValues",
"(",
"'validateemail'",
")",
... | Start the email validation procedure
@param Garp_Db_Table_Row $user
@param String $updateOrInsert Wether this was caused by an insert or an update
@return Boolean Wether the procedure succeeded | [
"Start",
"the",
"email",
"validation",
"procedure"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db/User.php#L296-L322 |
46,585 | grrr-amsterdam/garp3 | library/Garp/Model/Db/User.php | Garp_Model_Db_User.generateEmailValidationCode | public function generateEmailValidationCode(Garp_Db_Table_Row $user, $validationToken) {
$authVars = Garp_Auth::getInstance()->getConfigValues();
$validationCode = '';
$validationCode .= $validationToken;
$validationCode .= md5($user->email);
$validationCode .= md5($authVars['salt']);
$validationCode .= md5($user->id);
$validationCode = md5($validationCode);
return $validationCode;
} | php | public function generateEmailValidationCode(Garp_Db_Table_Row $user, $validationToken) {
$authVars = Garp_Auth::getInstance()->getConfigValues();
$validationCode = '';
$validationCode .= $validationToken;
$validationCode .= md5($user->email);
$validationCode .= md5($authVars['salt']);
$validationCode .= md5($user->id);
$validationCode = md5($validationCode);
return $validationCode;
} | [
"public",
"function",
"generateEmailValidationCode",
"(",
"Garp_Db_Table_Row",
"$",
"user",
",",
"$",
"validationToken",
")",
"{",
"$",
"authVars",
"=",
"Garp_Auth",
"::",
"getInstance",
"(",
")",
"->",
"getConfigValues",
"(",
")",
";",
"$",
"validationCode",
"=... | Generate unique email validation code for a user
@param Garp_Db_Table_Row $user
@param String $validationToken Unique random value
@return String | [
"Generate",
"unique",
"email",
"validation",
"code",
"for",
"a",
"user"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db/User.php#L331-L341 |
46,586 | grrr-amsterdam/garp3 | library/Garp/Model/Db/User.php | Garp_Model_Db_User.sendEmailValidationEmail | public function sendEmailValidationEmail(
Garp_Db_Table_Row $user, $code, $updateOrInsert = 'insert'
) {
$authVars = Garp_Auth::getInstance()->getConfigValues('validateemail');
// Render the email message
$activationUrl = '/g/auth/validateemail/c/' . $code . '/e/' . md5($user->email) . '/';
if (!empty($authVars['email_partial'])) {
$view = Zend_Registry::get('application')->getBootstrap()
->getResource('view');
$emailMessage = $view->partial(
$authVars['email_partial'], 'default', array(
'user' => $user,
'activationUrl' => $activationUrl,
'updateOrInsert' => $updateOrInsert
)
);
$messageParam = 'htmlMessage';
} else {
$snippetId = 'validate email ';
$snippetId .= $updateOrInsert == 'insert' ? 'new user' : 'existing user';
$snippetId .= ' email';
$emailMessage = __($snippetId);
$emailMessage = Garp_Util_String::interpolate(
$emailMessage, array(
'USERNAME' => (string)new Garp_Util_FullName($user),
'ACTIVATION_URL' => (string)new Garp_Util_FullUrl($activationUrl)
)
);
$messageParam = 'message';
}
$mailer = new Garp_Mailer();
return $mailer->send(
array(
'to' => $user->email,
'subject' => __($authVars['email_subject']),
$messageParam => $emailMessage
)
);
} | php | public function sendEmailValidationEmail(
Garp_Db_Table_Row $user, $code, $updateOrInsert = 'insert'
) {
$authVars = Garp_Auth::getInstance()->getConfigValues('validateemail');
// Render the email message
$activationUrl = '/g/auth/validateemail/c/' . $code . '/e/' . md5($user->email) . '/';
if (!empty($authVars['email_partial'])) {
$view = Zend_Registry::get('application')->getBootstrap()
->getResource('view');
$emailMessage = $view->partial(
$authVars['email_partial'], 'default', array(
'user' => $user,
'activationUrl' => $activationUrl,
'updateOrInsert' => $updateOrInsert
)
);
$messageParam = 'htmlMessage';
} else {
$snippetId = 'validate email ';
$snippetId .= $updateOrInsert == 'insert' ? 'new user' : 'existing user';
$snippetId .= ' email';
$emailMessage = __($snippetId);
$emailMessage = Garp_Util_String::interpolate(
$emailMessage, array(
'USERNAME' => (string)new Garp_Util_FullName($user),
'ACTIVATION_URL' => (string)new Garp_Util_FullUrl($activationUrl)
)
);
$messageParam = 'message';
}
$mailer = new Garp_Mailer();
return $mailer->send(
array(
'to' => $user->email,
'subject' => __($authVars['email_subject']),
$messageParam => $emailMessage
)
);
} | [
"public",
"function",
"sendEmailValidationEmail",
"(",
"Garp_Db_Table_Row",
"$",
"user",
",",
"$",
"code",
",",
"$",
"updateOrInsert",
"=",
"'insert'",
")",
"{",
"$",
"authVars",
"=",
"Garp_Auth",
"::",
"getInstance",
"(",
")",
"->",
"getConfigValues",
"(",
"'... | Send validation email to the user
@param Garp_Db_Table_Row $user The user
@param String $code The validation code
@param String $updateOrInsert Wether this was caused by an insert or an update
@return Boolean | [
"Send",
"validation",
"email",
"to",
"the",
"user"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Model/Db/User.php#L351-L393 |
46,587 | grrr-amsterdam/garp3 | library/Garp/Cli/Command/Slugs.php | Garp_Cli_Command_Slugs.generate | public function generate(array $args = array()) {
if (empty($args)) {
$this->help();
return false;
}
$modelName = $args[0];
if (strpos($modelName, '_') === false) {
$modelName = 'Model_' . $modelName;
}
$overwrite = !empty($args[1]) ? $args[1] : false;
$model = new $modelName();
// No reason to cache queries. Use live data.
$model->setCacheQueries(false);
// Fetch Sluggable thru the model as to use the right slug-configuration
list($sluggable, $model) = $this->_resolveSluggableBehavior($model);
if (is_null($sluggable)) {
Garp_Cli::errorOut('This model is not sluggable.');
return false;
}
// Array to record fails
$fails = array();
$records = $model->fetchAll();
foreach ($records as $record) {
if (!$overwrite && $record->slug) {
continue;
}
// Mimic a beforeInsert to create the slug in a separate array $data
$args = array($model, $record->toArray());
$sluggable->beforeInsert($args);
// Since there might be more than one changed column, we use this loop
// to append those columns to the record
foreach ($args[1] as $key => $value) {
if ($value != $record->{$key}) {
$record->{$key} = $value;
}
}
// Save the record with its slug
if (!$record->save()) {
$pk = implode(', ', (array)$record->getPrimaryKey());
$fails[] = $pk;
}
}
Garp_Cli::lineOut('Done.');
if (count($fails)) {
Garp_Cli::errorOut(
'There were some failures. ' .
'Please perform a manual check on records with the following primary keys:'
);
Garp_Cli::lineOut(implode("\n-", $fails));
}
return true;
} | php | public function generate(array $args = array()) {
if (empty($args)) {
$this->help();
return false;
}
$modelName = $args[0];
if (strpos($modelName, '_') === false) {
$modelName = 'Model_' . $modelName;
}
$overwrite = !empty($args[1]) ? $args[1] : false;
$model = new $modelName();
// No reason to cache queries. Use live data.
$model->setCacheQueries(false);
// Fetch Sluggable thru the model as to use the right slug-configuration
list($sluggable, $model) = $this->_resolveSluggableBehavior($model);
if (is_null($sluggable)) {
Garp_Cli::errorOut('This model is not sluggable.');
return false;
}
// Array to record fails
$fails = array();
$records = $model->fetchAll();
foreach ($records as $record) {
if (!$overwrite && $record->slug) {
continue;
}
// Mimic a beforeInsert to create the slug in a separate array $data
$args = array($model, $record->toArray());
$sluggable->beforeInsert($args);
// Since there might be more than one changed column, we use this loop
// to append those columns to the record
foreach ($args[1] as $key => $value) {
if ($value != $record->{$key}) {
$record->{$key} = $value;
}
}
// Save the record with its slug
if (!$record->save()) {
$pk = implode(', ', (array)$record->getPrimaryKey());
$fails[] = $pk;
}
}
Garp_Cli::lineOut('Done.');
if (count($fails)) {
Garp_Cli::errorOut(
'There were some failures. ' .
'Please perform a manual check on records with the following primary keys:'
);
Garp_Cli::lineOut(implode("\n-", $fails));
}
return true;
} | [
"public",
"function",
"generate",
"(",
"array",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"args",
")",
")",
"{",
"$",
"this",
"->",
"help",
"(",
")",
";",
"return",
"false",
";",
"}",
"$",
"modelName",
"=",
"$... | Generate the slugs
@param array $args
@return bool | [
"Generate",
"the",
"slugs"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Cli/Command/Slugs.php#L16-L73 |
46,588 | grrr-amsterdam/garp3 | library/Garp/File/Storage/S3.php | Garp_File_Storage_S3.getList | public function getList(): array {
$this->_verifyPath();
// strip off preceding slash, add trailing one.
$path = substr($this->_config['path'], 1) . '/';
return $this->_getApi()->listObjects([
'Bucket' => $this->_config['bucket'],
'Prefix' => $path
])->get('Contents');
} | php | public function getList(): array {
$this->_verifyPath();
// strip off preceding slash, add trailing one.
$path = substr($this->_config['path'], 1) . '/';
return $this->_getApi()->listObjects([
'Bucket' => $this->_config['bucket'],
'Prefix' => $path
])->get('Contents');
} | [
"public",
"function",
"getList",
"(",
")",
":",
"array",
"{",
"$",
"this",
"->",
"_verifyPath",
"(",
")",
";",
"// strip off preceding slash, add trailing one.",
"$",
"path",
"=",
"substr",
"(",
"$",
"this",
"->",
"_config",
"[",
"'path'",
"]",
",",
"1",
"... | Lists all files in the upload directory.
@return array | [
"Lists",
"all",
"files",
"in",
"the",
"upload",
"directory",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/File/Storage/S3.php#L104-L113 |
46,589 | grrr-amsterdam/garp3 | library/Garp/File/Storage/S3.php | Garp_File_Storage_S3._getUri | protected function _getUri($filename): string {
$this->_verifyPath();
// Note: AWS SDK does not want the URI to start with a slash, as opposed to the old Zend
// Framework implementation.
$path = trim($this->_config['path'], '/');
return $path . '/' . $filename;
} | php | protected function _getUri($filename): string {
$this->_verifyPath();
// Note: AWS SDK does not want the URI to start with a slash, as opposed to the old Zend
// Framework implementation.
$path = trim($this->_config['path'], '/');
return $path . '/' . $filename;
} | [
"protected",
"function",
"_getUri",
"(",
"$",
"filename",
")",
":",
"string",
"{",
"$",
"this",
"->",
"_verifyPath",
"(",
")",
";",
"// Note: AWS SDK does not want the URI to start with a slash, as opposed to the old Zend",
"// Framework implementation.",
"$",
"path",
"=",
... | Returns the uri for internal Zend_Service_Amazon_S3 use.
@param string $filename
@return string | [
"Returns",
"the",
"uri",
"for",
"internal",
"Zend_Service_Amazon_S3",
"use",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/File/Storage/S3.php#L235-L241 |
46,590 | grrr-amsterdam/garp3 | library/Garp/Image/File.php | Garp_Image_File.show | public function show($path, $timestamp = null, $mime = null) {
$headers = function_exists('apache_request_headers') ?
apache_request_headers() :
array();
if (is_null($timestamp))
$timestamp = $this->_readTimestampFromFile($path);
if (is_null($mime)) {
$mime = $this->_readMimeTypeFromFile($path);
}
header("Content-Type: $mime");
header("Cache-Control: maxage=".(24*60*60).', must-revalidate'); //In seconds
header("Pragma: public");
// Checking if the client is validating his cache and if it is current.
if (
isset($headers['If-Modified-Since']) &&
strtotime($headers['If-Modified-Since']) == $timestamp
) {
// Client's cache IS current, so we just respond '304 Not Modified'.
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $timestamp).' GMT', true, 304);
} else {
// Image not cached or cache outdated, we respond '200 OK' and output the image.
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $timestamp).' GMT', true, 200);
header('Content-Length: '.filesize($path));
$resource = fopen($path, 'rb');
rewind($resource);
fpassthru($resource);
fclose($resource);
}
} | php | public function show($path, $timestamp = null, $mime = null) {
$headers = function_exists('apache_request_headers') ?
apache_request_headers() :
array();
if (is_null($timestamp))
$timestamp = $this->_readTimestampFromFile($path);
if (is_null($mime)) {
$mime = $this->_readMimeTypeFromFile($path);
}
header("Content-Type: $mime");
header("Cache-Control: maxage=".(24*60*60).', must-revalidate'); //In seconds
header("Pragma: public");
// Checking if the client is validating his cache and if it is current.
if (
isset($headers['If-Modified-Since']) &&
strtotime($headers['If-Modified-Since']) == $timestamp
) {
// Client's cache IS current, so we just respond '304 Not Modified'.
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $timestamp).' GMT', true, 304);
} else {
// Image not cached or cache outdated, we respond '200 OK' and output the image.
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $timestamp).' GMT', true, 200);
header('Content-Length: '.filesize($path));
$resource = fopen($path, 'rb');
rewind($resource);
fpassthru($resource);
fclose($resource);
}
} | [
"public",
"function",
"show",
"(",
"$",
"path",
",",
"$",
"timestamp",
"=",
"null",
",",
"$",
"mime",
"=",
"null",
")",
"{",
"$",
"headers",
"=",
"function_exists",
"(",
"'apache_request_headers'",
")",
"?",
"apache_request_headers",
"(",
")",
":",
"array"... | Lets the browser render an image file
@param String $path The path to the image file
@param String $timestamp Cache timestamp - if not provided, this will have to be found out (at the cost of disk access)
@param String $mime The image mimetype - if not provided, this will have to be found out (at the cost of disk access)
@return Void | [
"Lets",
"the",
"browser",
"render",
"an",
"image",
"file"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Image/File.php#L51-L82 |
46,591 | grrr-amsterdam/garp3 | library/Garp/Controller/Helper/Download.php | Garp_Controller_Helper_Download.force | public function force($bytes, $filename, Zend_Controller_Response_Abstract $response) {
if (!strlen($bytes)) {
$response->setBody('Sorry, we could not find the requested file.');
} else {
// Disable view and layout rendering
Zend_Controller_Action_HelperBroker::getExistingHelper('viewRenderer')->setNoRender();
Zend_Controller_Action_HelperBroker::getExistingHelper('layout')->disableLayout();
// Process the download
$this->_setHeaders($bytes, $filename, $response);
$response->setBody($bytes);
}
} | php | public function force($bytes, $filename, Zend_Controller_Response_Abstract $response) {
if (!strlen($bytes)) {
$response->setBody('Sorry, we could not find the requested file.');
} else {
// Disable view and layout rendering
Zend_Controller_Action_HelperBroker::getExistingHelper('viewRenderer')->setNoRender();
Zend_Controller_Action_HelperBroker::getExistingHelper('layout')->disableLayout();
// Process the download
$this->_setHeaders($bytes, $filename, $response);
$response->setBody($bytes);
}
} | [
"public",
"function",
"force",
"(",
"$",
"bytes",
",",
"$",
"filename",
",",
"Zend_Controller_Response_Abstract",
"$",
"response",
")",
"{",
"if",
"(",
"!",
"strlen",
"(",
"$",
"bytes",
")",
")",
"{",
"$",
"response",
"->",
"setBody",
"(",
"'Sorry, we coul... | Force download dialog
@param String $bytes The bytes that are to be downloaded
@param String $filename The filename of the downloaded file
@param Zend_Controller_Response_Abstract $response The response object
@return Void | [
"Force",
"download",
"dialog"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Controller/Helper/Download.php#L22-L34 |
46,592 | grrr-amsterdam/garp3 | library/Garp/Controller/Helper/Download.php | Garp_Controller_Helper_Download._setHeaders | protected function _setHeaders($bytes, $filename, Zend_Controller_Response_Abstract $response) {
// fix for IE catching or PHP bug issue
$response->setHeader('Pragma', 'public');
// set expiration time
$response->setHeader('Expires', '0');
// browser must download file from server instead of cache
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
// force download dialog
$response->setHeader('Content-Type', 'application/octet-stream');
// use the Content-Disposition header to supply a recommended filename and
// force the browser to display the save dialog.
$response->setHeader(
'Content-Disposition',
'attachment; filename="'.basename($filename).'"'
);
/*
The Content-transfer-encoding header should be binary, since the file will be read
directly from the disk and the raw bytes passed to the downloading computer.
The Content-length header is useful to set for downloads. The browser will be able to
show a progress meter as a file downloads. The content-length can be determined by
filesize function returns the size of a file.
*/
$response->setHeader('Content-Transfer-Encoding', 'binary');
$response->setHeader('Content-Length', strlen($bytes));
} | php | protected function _setHeaders($bytes, $filename, Zend_Controller_Response_Abstract $response) {
// fix for IE catching or PHP bug issue
$response->setHeader('Pragma', 'public');
// set expiration time
$response->setHeader('Expires', '0');
// browser must download file from server instead of cache
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
// force download dialog
$response->setHeader('Content-Type', 'application/octet-stream');
// use the Content-Disposition header to supply a recommended filename and
// force the browser to display the save dialog.
$response->setHeader(
'Content-Disposition',
'attachment; filename="'.basename($filename).'"'
);
/*
The Content-transfer-encoding header should be binary, since the file will be read
directly from the disk and the raw bytes passed to the downloading computer.
The Content-length header is useful to set for downloads. The browser will be able to
show a progress meter as a file downloads. The content-length can be determined by
filesize function returns the size of a file.
*/
$response->setHeader('Content-Transfer-Encoding', 'binary');
$response->setHeader('Content-Length', strlen($bytes));
} | [
"protected",
"function",
"_setHeaders",
"(",
"$",
"bytes",
",",
"$",
"filename",
",",
"Zend_Controller_Response_Abstract",
"$",
"response",
")",
"{",
"// fix for IE catching or PHP bug issue",
"$",
"response",
"->",
"setHeader",
"(",
"'Pragma'",
",",
"'public'",
")",
... | Set the neccessary headers for forcing the download dialog
@param String $bytes The bytes that are to be downloaded
@param String $filename The filename of the downloaded file
@param Zend_Controller_Response_Abstract $response The response object
@return Void | [
"Set",
"the",
"neccessary",
"headers",
"for",
"forcing",
"the",
"download",
"dialog"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Controller/Helper/Download.php#L45-L72 |
46,593 | grrr-amsterdam/garp3 | application/modules/g/views/helpers/Social.php | G_View_Helper_Social.tweetUrl | public function tweetUrl($msg, $shortenUrls = false) {
$url = 'http://twitter.com/?status=';
if ($shortenUrls) {
$msg = preg_replace_callback(
'~https?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?~i',
function ($matches) {
$_this = new G_View_Helper_Social();
return $_this->tinyUrl($matches[0]);
},
$msg
);
}
$url .= urlencode($msg);
return $url;
} | php | public function tweetUrl($msg, $shortenUrls = false) {
$url = 'http://twitter.com/?status=';
if ($shortenUrls) {
$msg = preg_replace_callback(
'~https?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?~i',
function ($matches) {
$_this = new G_View_Helper_Social();
return $_this->tinyUrl($matches[0]);
},
$msg
);
}
$url .= urlencode($msg);
return $url;
} | [
"public",
"function",
"tweetUrl",
"(",
"$",
"msg",
",",
"$",
"shortenUrls",
"=",
"false",
")",
"{",
"$",
"url",
"=",
"'http://twitter.com/?status='",
";",
"if",
"(",
"$",
"shortenUrls",
")",
"{",
"$",
"msg",
"=",
"preg_replace_callback",
"(",
"'~https?://([\... | Generate a "Tweet this!" URL.
Note that the status is automatically cut off at 140 characters.
@param string $msg The tweet
@param bool $shortenUrls Wether to shorten the URLs
@return string | [
"Generate",
"a",
"Tweet",
"this!",
"URL",
".",
"Note",
"that",
"the",
"status",
"is",
"automatically",
"cut",
"off",
"at",
"140",
"characters",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Social.php#L40-L54 |
46,594 | grrr-amsterdam/garp3 | application/modules/g/views/helpers/Social.php | G_View_Helper_Social.tweetButton | public function tweetButton(array $params = array()) {
$params = new Garp_Util_Configuration($params);
$params->setDefault('url', null)
->setDefault('text', null)
->setDefault('via', null)
->setDefault('related', null)
->setDefault('lang', null)
->setDefault('count', 'horizontal')
->setDefault('loadScript', true);
// set required parameters
$attributes = array(
'class' => 'twitter-share-button',
'data-count' => $params['count']
);
// set optional attributes
$params['url'] && $attributes['data-url'] = $params['url'];
$params['text'] && $attributes['data-text'] = $params['text'];
$params['via'] && $attributes['data-via'] = $params['via'];
$params['related'] && $attributes['data-related'] = $params['related'];
$params['lang'] && $attributes['data-lang'] = $params['lang'];
$html = $this->view->htmlLink(
'http://twitter.com/share',
'Tweet',
$attributes
);
if ($params['loadScript']) {
// Add the Twitter Javascript to the stack
// Must be rendered in the view using "$this->script()->render()"
$this->view->script()->src('http://platform.twitter.com/widgets.js');
}
return $html;
} | php | public function tweetButton(array $params = array()) {
$params = new Garp_Util_Configuration($params);
$params->setDefault('url', null)
->setDefault('text', null)
->setDefault('via', null)
->setDefault('related', null)
->setDefault('lang', null)
->setDefault('count', 'horizontal')
->setDefault('loadScript', true);
// set required parameters
$attributes = array(
'class' => 'twitter-share-button',
'data-count' => $params['count']
);
// set optional attributes
$params['url'] && $attributes['data-url'] = $params['url'];
$params['text'] && $attributes['data-text'] = $params['text'];
$params['via'] && $attributes['data-via'] = $params['via'];
$params['related'] && $attributes['data-related'] = $params['related'];
$params['lang'] && $attributes['data-lang'] = $params['lang'];
$html = $this->view->htmlLink(
'http://twitter.com/share',
'Tweet',
$attributes
);
if ($params['loadScript']) {
// Add the Twitter Javascript to the stack
// Must be rendered in the view using "$this->script()->render()"
$this->view->script()->src('http://platform.twitter.com/widgets.js');
}
return $html;
} | [
"public",
"function",
"tweetButton",
"(",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"new",
"Garp_Util_Configuration",
"(",
"$",
"params",
")",
";",
"$",
"params",
"->",
"setDefault",
"(",
"'url'",
",",
"null",
")",
"... | Create a Tweet button.
@param array $params
@return string
@see http://twitter.com/about/resources/tweetbutton | [
"Create",
"a",
"Tweet",
"button",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Social.php#L87-L122 |
46,595 | grrr-amsterdam/garp3 | application/modules/g/views/helpers/Social.php | G_View_Helper_Social.hyvesTipUrl | public function hyvesTipUrl($title, $body, $categoryId = 12, $rating = 5) {
$url = 'http://www.hyves-share.nl/button/tip/?tipcategoryid=%s&rating=%s&title=%s&body=%s';
$title = $title;
$body = $body;
return sprintf($url, $categoryId, $rating, $title, $body);
} | php | public function hyvesTipUrl($title, $body, $categoryId = 12, $rating = 5) {
$url = 'http://www.hyves-share.nl/button/tip/?tipcategoryid=%s&rating=%s&title=%s&body=%s';
$title = $title;
$body = $body;
return sprintf($url, $categoryId, $rating, $title, $body);
} | [
"public",
"function",
"hyvesTipUrl",
"(",
"$",
"title",
",",
"$",
"body",
",",
"$",
"categoryId",
"=",
"12",
",",
"$",
"rating",
"=",
"5",
")",
"{",
"$",
"url",
"=",
"'http://www.hyves-share.nl/button/tip/?tipcategoryid=%s&rating=%s&title=%s&body=%s'",
";",
"$",
... | Generate a Hyves "Smart button" URL.
@param string $title
@param string $body
@param int $categoryId
@param int $rating
@return string | [
"Generate",
"a",
"Hyves",
"Smart",
"button",
"URL",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Social.php#L133-L139 |
46,596 | grrr-amsterdam/garp3 | application/modules/g/views/helpers/Social.php | G_View_Helper_Social.facebookShareUrl | public function facebookShareUrl($url = null, $text = null) {
$shareUrl = is_null($url) ? $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] : $url;
$url = 'http://facebook.com/sharer.php?u=' . urlencode($shareUrl);
if (!is_null($text)) {
$url .= '&t=' . $text;
}
return $url;
} | php | public function facebookShareUrl($url = null, $text = null) {
$shareUrl = is_null($url) ? $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] : $url;
$url = 'http://facebook.com/sharer.php?u=' . urlencode($shareUrl);
if (!is_null($text)) {
$url .= '&t=' . $text;
}
return $url;
} | [
"public",
"function",
"facebookShareUrl",
"(",
"$",
"url",
"=",
"null",
",",
"$",
"text",
"=",
"null",
")",
"{",
"$",
"shareUrl",
"=",
"is_null",
"(",
"$",
"url",
")",
"?",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
".",
"$",
"_SERVER",
"[",
"'REQUEST_... | Generate a Facebook share URL
@param string $url Defaults to $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
@param string $text
@return string | [
"Generate",
"a",
"Facebook",
"share",
"URL"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Social.php#L192-L199 |
46,597 | grrr-amsterdam/garp3 | application/modules/g/views/helpers/Social.php | G_View_Helper_Social.facebookComments | public function facebookComments(array $params = array()) {
$this->_needsFacebookInit = true;
$params = new Garp_Util_Configuration($params);
$params->setDefault(
'href',
array_key_exists('href', $params) && $params['href'] ?
$params['href'] :
$this->view->fullUrl($this->view->url())
)
->setDefault('width', 400) /* Minimum recommended width: 400 */
->setDefault('num_posts', 10)
->setDefault('colorscheme', 'light');
$html = '<fb:comments ' . $this->_renderHtmlAttribs($params) . '></fb:comments>';
return $html;
} | php | public function facebookComments(array $params = array()) {
$this->_needsFacebookInit = true;
$params = new Garp_Util_Configuration($params);
$params->setDefault(
'href',
array_key_exists('href', $params) && $params['href'] ?
$params['href'] :
$this->view->fullUrl($this->view->url())
)
->setDefault('width', 400) /* Minimum recommended width: 400 */
->setDefault('num_posts', 10)
->setDefault('colorscheme', 'light');
$html = '<fb:comments ' . $this->_renderHtmlAttribs($params) . '></fb:comments>';
return $html;
} | [
"public",
"function",
"facebookComments",
"(",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_needsFacebookInit",
"=",
"true",
";",
"$",
"params",
"=",
"new",
"Garp_Util_Configuration",
"(",
"$",
"params",
")",
";",
"$",
"... | Display Facebook comments widget
@param array $params Various Facebook URL parameters
@return string | [
"Display",
"Facebook",
"comments",
"widget"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Social.php#L254-L269 |
46,598 | grrr-amsterdam/garp3 | application/modules/g/views/helpers/Social.php | G_View_Helper_Social.facebookFacepile | public function facebookFacepile(array $params = array(), $useFacebookPageAsUrl = false) {
$this->_needsFacebookInit = true;
$params = new Garp_Util_Configuration($params);
$params->setDefault(
'href', array_key_exists('href', $params) && $params['href'] ?
$params['href'] :
$this->_getCurrentUrl()
)
->setDefault('max_rows', 1)
->setDefault('width', 450)
->setDefault('colorscheme', 'light');
if ($useFacebookPageAsUrl) {
$this->_setFacebookPageUrlAsHref($params);
}
$html = '<fb:facepile ' . $this->_renderHtmlAttribs($params) . '></fb:facepile>';
return $html;
} | php | public function facebookFacepile(array $params = array(), $useFacebookPageAsUrl = false) {
$this->_needsFacebookInit = true;
$params = new Garp_Util_Configuration($params);
$params->setDefault(
'href', array_key_exists('href', $params) && $params['href'] ?
$params['href'] :
$this->_getCurrentUrl()
)
->setDefault('max_rows', 1)
->setDefault('width', 450)
->setDefault('colorscheme', 'light');
if ($useFacebookPageAsUrl) {
$this->_setFacebookPageUrlAsHref($params);
}
$html = '<fb:facepile ' . $this->_renderHtmlAttribs($params) . '></fb:facepile>';
return $html;
} | [
"public",
"function",
"facebookFacepile",
"(",
"array",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"useFacebookPageAsUrl",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"_needsFacebookInit",
"=",
"true",
";",
"$",
"params",
"=",
"new",
"Garp_Util_Configur... | Generate a Facebook facepile.
@param array $params Various Facebook URL parameters
@param bool $useFacebookPageAsUrl
@return string | [
"Generate",
"a",
"Facebook",
"facepile",
"."
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Social.php#L278-L296 |
46,599 | grrr-amsterdam/garp3 | application/modules/g/views/helpers/Social.php | G_View_Helper_Social.linkedinShareButton | public function linkedinShareButton(array $params = array()) {
$html = '<script type="in/share" ';
if (!empty($params['url'])) {
$html .= 'data-url="' . $this->view->escape($params['url']) . '" ';
}
if (!empty($params['counter'])) {
$html .= 'data-counter="' . $this->view->escape($params['counter']) . '" ';
}
$html .= '></script>';
// Add the LinkedIn Javascript to the stack
// Must be rendered in the view using "$this->script()->render()"
$this->view->script()->src('http://platform.linkedin.com/in.js');
return $html;
} | php | public function linkedinShareButton(array $params = array()) {
$html = '<script type="in/share" ';
if (!empty($params['url'])) {
$html .= 'data-url="' . $this->view->escape($params['url']) . '" ';
}
if (!empty($params['counter'])) {
$html .= 'data-counter="' . $this->view->escape($params['counter']) . '" ';
}
$html .= '></script>';
// Add the LinkedIn Javascript to the stack
// Must be rendered in the view using "$this->script()->render()"
$this->view->script()->src('http://platform.linkedin.com/in.js');
return $html;
} | [
"public",
"function",
"linkedinShareButton",
"(",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"html",
"=",
"'<script type=\"in/share\" '",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"params",
"[",
"'url'",
"]",
")",
")",
"{",
"$",
"html... | Generate a LinkedIn share button
@param array $params
@return string
@see http://www.linkedin.com/publishers | [
"Generate",
"a",
"LinkedIn",
"share",
"button"
] | ee6fa716406047568bc5227670748d3b1dd7290d | https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Social.php#L390-L404 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.