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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
32,100 | chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsNotifications/Model/CaptureNotification.php | OffAmazonPaymentsNotifications_Model_CaptureNotification.fromXML | public static function fromXML($xml)
{
$dom = new DOMDocument();
$dom->loadXML($xml);
$xpath = new DOMXPath($dom);
$xpath->registerNamespace('a', self::getNamespace());
$response = $xpath->query('//a:CaptureNotification');
if ($response->length == 1) {
return
new OffAmazonPaymentsNotifications_Model_CaptureNotification(
$response->item(0)
);
} else {
throw new Exception(
"Unable to construct " .
"OffAmazonPaymentsNotifications_Model_CaptureNotification" .
"from provided XML. Make sure that CaptureNotification" .
"is a root element"
);
}
} | php | public static function fromXML($xml)
{
$dom = new DOMDocument();
$dom->loadXML($xml);
$xpath = new DOMXPath($dom);
$xpath->registerNamespace('a', self::getNamespace());
$response = $xpath->query('//a:CaptureNotification');
if ($response->length == 1) {
return
new OffAmazonPaymentsNotifications_Model_CaptureNotification(
$response->item(0)
);
} else {
throw new Exception(
"Unable to construct " .
"OffAmazonPaymentsNotifications_Model_CaptureNotification" .
"from provided XML. Make sure that CaptureNotification" .
"is a root element"
);
}
} | [
"public",
"static",
"function",
"fromXML",
"(",
"$",
"xml",
")",
"{",
"$",
"dom",
"=",
"new",
"DOMDocument",
"(",
")",
";",
"$",
"dom",
"->",
"loadXML",
"(",
"$",
"xml",
")",
";",
"$",
"xpath",
"=",
"new",
"DOMXPath",
"(",
"$",
"dom",
")",
";",
"$",
"xpath",
"->",
"registerNamespace",
"(",
"'a'",
",",
"self",
"::",
"getNamespace",
"(",
")",
")",
";",
"$",
"response",
"=",
"$",
"xpath",
"->",
"query",
"(",
"'//a:CaptureNotification'",
")",
";",
"if",
"(",
"$",
"response",
"->",
"length",
"==",
"1",
")",
"{",
"return",
"new",
"OffAmazonPaymentsNotifications_Model_CaptureNotification",
"(",
"$",
"response",
"->",
"item",
"(",
"0",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"\"Unable to construct \"",
".",
"\"OffAmazonPaymentsNotifications_Model_CaptureNotification\"",
".",
"\"from provided XML. Make sure that CaptureNotification\"",
".",
"\"is a root element\"",
")",
";",
"}",
"}"
] | Construct OffAmazonPaymentsNotifications_Model_CaptureNotification
from XML string
@param string $xml XML string to construct from
@return OffAmazonPaymentsNotifications_Model_CaptureNotification | [
"Construct",
"OffAmazonPaymentsNotifications_Model_CaptureNotification",
"from",
"XML",
"string"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsNotifications/Model/CaptureNotification.php#L74-L94 |
32,101 | chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsNotifications/Model/CaptureNotification.php | OffAmazonPaymentsNotifications_Model_CaptureNotification.toXML | public function toXML()
{
$xml = "";
$xml .= "<CaptureNotification xmlns=\"";
$xml .= self::getNamespace();
$xml .= "\">";
$xml .= $this->_toXMLFragment();
$xml .= "</CaptureNotification>";
return $xml;
} | php | public function toXML()
{
$xml = "";
$xml .= "<CaptureNotification xmlns=\"";
$xml .= self::getNamespace();
$xml .= "\">";
$xml .= $this->_toXMLFragment();
$xml .= "</CaptureNotification>";
return $xml;
} | [
"public",
"function",
"toXML",
"(",
")",
"{",
"$",
"xml",
"=",
"\"\"",
";",
"$",
"xml",
".=",
"\"<CaptureNotification xmlns=\\\"\"",
";",
"$",
"xml",
".=",
"self",
"::",
"getNamespace",
"(",
")",
";",
"$",
"xml",
".=",
"\"\\\">\"",
";",
"$",
"xml",
".=",
"$",
"this",
"->",
"_toXMLFragment",
"(",
")",
";",
"$",
"xml",
".=",
"\"</CaptureNotification>\"",
";",
"return",
"$",
"xml",
";",
"}"
] | XML Representation for this object
@return string XML for this object | [
"XML",
"Representation",
"for",
"this",
"object"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsNotifications/Model/CaptureNotification.php#L148-L157 |
32,102 | PGB-LIV/php-ms | src/Reader/MgfReader.php | MgfReader.getLine | private function getLine()
{
if ($this->filePeek == null) {
return fgets($this->fileHandle);
}
$ret = $this->filePeek;
$this->filePeek = null;
return $ret;
} | php | private function getLine()
{
if ($this->filePeek == null) {
return fgets($this->fileHandle);
}
$ret = $this->filePeek;
$this->filePeek = null;
return $ret;
} | [
"private",
"function",
"getLine",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"filePeek",
"==",
"null",
")",
"{",
"return",
"fgets",
"(",
"$",
"this",
"->",
"fileHandle",
")",
";",
"}",
"$",
"ret",
"=",
"$",
"this",
"->",
"filePeek",
";",
"$",
"this",
"->",
"filePeek",
"=",
"null",
";",
"return",
"$",
"ret",
";",
"}"
] | Gets the next line and increments the file iterator
@return string The next line in the file | [
"Gets",
"the",
"next",
"line",
"and",
"increments",
"the",
"file",
"iterator"
] | 091751eb12512f4bc6ada07bda745ce49331e24f | https://github.com/PGB-LIV/php-ms/blob/091751eb12512f4bc6ada07bda745ce49331e24f/src/Reader/MgfReader.php#L94-L104 |
32,103 | PGB-LIV/php-ms | src/Reader/MgfReader.php | MgfReader.peekLine | private function peekLine()
{
if ($this->filePeek == null) {
$this->filePeek = fgets($this->fileHandle);
}
return $this->filePeek;
} | php | private function peekLine()
{
if ($this->filePeek == null) {
$this->filePeek = fgets($this->fileHandle);
}
return $this->filePeek;
} | [
"private",
"function",
"peekLine",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"filePeek",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"filePeek",
"=",
"fgets",
"(",
"$",
"this",
"->",
"fileHandle",
")",
";",
"}",
"return",
"$",
"this",
"->",
"filePeek",
";",
"}"
] | Gets the next line, though does not move the file iterator
@return string The next line in the file | [
"Gets",
"the",
"next",
"line",
"though",
"does",
"not",
"move",
"the",
"file",
"iterator"
] | 091751eb12512f4bc6ada07bda745ce49331e24f | https://github.com/PGB-LIV/php-ms/blob/091751eb12512f4bc6ada07bda745ce49331e24f/src/Reader/MgfReader.php#L111-L118 |
32,104 | PGB-LIV/php-ms | src/Reader/MgfReader.php | MgfReader.parseMeta | private function parseMeta(PrecursorIon $precursor)
{
$line = trim($this->getLine());
$pair = explode('=', $line, 2);
$value = $pair[1];
if (is_numeric($value)) {
$value += 0;
}
if ($pair[0] == 'TITLE') {
$precursor->setTitle($pair[1]);
} elseif ($pair[0] == 'PEPMASS') {
$chunks = explode(' ', $pair[1]);
if (count($chunks) > 1) {
$precursor->setIntensity((float) $chunks[1] + 0);
}
$this->massCharge = (float) $chunks[0] + 0;
} elseif ($pair[0] == 'CHARGE') {
$this->charge = (int) $pair[1];
} elseif ($pair[0] == 'SCANS') {
$precursor->setScan((int) $pair[1] + 0);
} elseif ($pair[0] == 'RTINSECONDS') {
$window = explode(',', $pair[1]);
if (count($window) == 1) {
$precursor->setRetentionTime((float) $window[0] + 0);
} else {
$precursor->setRetentionTimeWindow((float) $window[0] + 0, (float) $window[1] + 0);
}
}
} | php | private function parseMeta(PrecursorIon $precursor)
{
$line = trim($this->getLine());
$pair = explode('=', $line, 2);
$value = $pair[1];
if (is_numeric($value)) {
$value += 0;
}
if ($pair[0] == 'TITLE') {
$precursor->setTitle($pair[1]);
} elseif ($pair[0] == 'PEPMASS') {
$chunks = explode(' ', $pair[1]);
if (count($chunks) > 1) {
$precursor->setIntensity((float) $chunks[1] + 0);
}
$this->massCharge = (float) $chunks[0] + 0;
} elseif ($pair[0] == 'CHARGE') {
$this->charge = (int) $pair[1];
} elseif ($pair[0] == 'SCANS') {
$precursor->setScan((int) $pair[1] + 0);
} elseif ($pair[0] == 'RTINSECONDS') {
$window = explode(',', $pair[1]);
if (count($window) == 1) {
$precursor->setRetentionTime((float) $window[0] + 0);
} else {
$precursor->setRetentionTimeWindow((float) $window[0] + 0, (float) $window[1] + 0);
}
}
} | [
"private",
"function",
"parseMeta",
"(",
"PrecursorIon",
"$",
"precursor",
")",
"{",
"$",
"line",
"=",
"trim",
"(",
"$",
"this",
"->",
"getLine",
"(",
")",
")",
";",
"$",
"pair",
"=",
"explode",
"(",
"'='",
",",
"$",
"line",
",",
"2",
")",
";",
"$",
"value",
"=",
"$",
"pair",
"[",
"1",
"]",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"+=",
"0",
";",
"}",
"if",
"(",
"$",
"pair",
"[",
"0",
"]",
"==",
"'TITLE'",
")",
"{",
"$",
"precursor",
"->",
"setTitle",
"(",
"$",
"pair",
"[",
"1",
"]",
")",
";",
"}",
"elseif",
"(",
"$",
"pair",
"[",
"0",
"]",
"==",
"'PEPMASS'",
")",
"{",
"$",
"chunks",
"=",
"explode",
"(",
"' '",
",",
"$",
"pair",
"[",
"1",
"]",
")",
";",
"if",
"(",
"count",
"(",
"$",
"chunks",
")",
">",
"1",
")",
"{",
"$",
"precursor",
"->",
"setIntensity",
"(",
"(",
"float",
")",
"$",
"chunks",
"[",
"1",
"]",
"+",
"0",
")",
";",
"}",
"$",
"this",
"->",
"massCharge",
"=",
"(",
"float",
")",
"$",
"chunks",
"[",
"0",
"]",
"+",
"0",
";",
"}",
"elseif",
"(",
"$",
"pair",
"[",
"0",
"]",
"==",
"'CHARGE'",
")",
"{",
"$",
"this",
"->",
"charge",
"=",
"(",
"int",
")",
"$",
"pair",
"[",
"1",
"]",
";",
"}",
"elseif",
"(",
"$",
"pair",
"[",
"0",
"]",
"==",
"'SCANS'",
")",
"{",
"$",
"precursor",
"->",
"setScan",
"(",
"(",
"int",
")",
"$",
"pair",
"[",
"1",
"]",
"+",
"0",
")",
";",
"}",
"elseif",
"(",
"$",
"pair",
"[",
"0",
"]",
"==",
"'RTINSECONDS'",
")",
"{",
"$",
"window",
"=",
"explode",
"(",
"','",
",",
"$",
"pair",
"[",
"1",
"]",
")",
";",
"if",
"(",
"count",
"(",
"$",
"window",
")",
"==",
"1",
")",
"{",
"$",
"precursor",
"->",
"setRetentionTime",
"(",
"(",
"float",
")",
"$",
"window",
"[",
"0",
"]",
"+",
"0",
")",
";",
"}",
"else",
"{",
"$",
"precursor",
"->",
"setRetentionTimeWindow",
"(",
"(",
"float",
")",
"$",
"window",
"[",
"0",
"]",
"+",
"0",
",",
"(",
"float",
")",
"$",
"window",
"[",
"1",
"]",
"+",
"0",
")",
";",
"}",
"}",
"}"
] | Parses the meta information from the scan and writes it to the precursor entry
@param PrecursorIon $precursor
The precursor to append to | [
"Parses",
"the",
"meta",
"information",
"from",
"the",
"scan",
"and",
"writes",
"it",
"to",
"the",
"precursor",
"entry"
] | 091751eb12512f4bc6ada07bda745ce49331e24f | https://github.com/PGB-LIV/php-ms/blob/091751eb12512f4bc6ada07bda745ce49331e24f/src/Reader/MgfReader.php#L179-L210 |
32,105 | PGB-LIV/php-ms | src/Reader/MgfReader.php | MgfReader.parseFragments | private function parseFragments(PrecursorIon $precursor)
{
$line = trim($this->getLine());
if (strlen($line) == 0) {
return;
}
$pair = preg_split('/\\s/', $line, 3);
$ion = new FragmentIon();
$fragmentMz = (float) $pair[0];
$fragmentCharge = 1;
if (count($pair) > 1) {
$ion->setIntensity((float) $pair[1]);
}
if (count($pair) > 2) {
$fragmentCharge = (int) $pair[2];
}
$ion->setMonoisotopicMassCharge($fragmentMz, $fragmentCharge);
$precursor->addFragmentIon($ion);
} | php | private function parseFragments(PrecursorIon $precursor)
{
$line = trim($this->getLine());
if (strlen($line) == 0) {
return;
}
$pair = preg_split('/\\s/', $line, 3);
$ion = new FragmentIon();
$fragmentMz = (float) $pair[0];
$fragmentCharge = 1;
if (count($pair) > 1) {
$ion->setIntensity((float) $pair[1]);
}
if (count($pair) > 2) {
$fragmentCharge = (int) $pair[2];
}
$ion->setMonoisotopicMassCharge($fragmentMz, $fragmentCharge);
$precursor->addFragmentIon($ion);
} | [
"private",
"function",
"parseFragments",
"(",
"PrecursorIon",
"$",
"precursor",
")",
"{",
"$",
"line",
"=",
"trim",
"(",
"$",
"this",
"->",
"getLine",
"(",
")",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"line",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
"$",
"pair",
"=",
"preg_split",
"(",
"'/\\\\s/'",
",",
"$",
"line",
",",
"3",
")",
";",
"$",
"ion",
"=",
"new",
"FragmentIon",
"(",
")",
";",
"$",
"fragmentMz",
"=",
"(",
"float",
")",
"$",
"pair",
"[",
"0",
"]",
";",
"$",
"fragmentCharge",
"=",
"1",
";",
"if",
"(",
"count",
"(",
"$",
"pair",
")",
">",
"1",
")",
"{",
"$",
"ion",
"->",
"setIntensity",
"(",
"(",
"float",
")",
"$",
"pair",
"[",
"1",
"]",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"pair",
")",
">",
"2",
")",
"{",
"$",
"fragmentCharge",
"=",
"(",
"int",
")",
"$",
"pair",
"[",
"2",
"]",
";",
"}",
"$",
"ion",
"->",
"setMonoisotopicMassCharge",
"(",
"$",
"fragmentMz",
",",
"$",
"fragmentCharge",
")",
";",
"$",
"precursor",
"->",
"addFragmentIon",
"(",
"$",
"ion",
")",
";",
"}"
] | Parses the fragment information from the scan and writes it to the precursor entry
@param PrecursorIon $precursor
The precursor to append to | [
"Parses",
"the",
"fragment",
"information",
"from",
"the",
"scan",
"and",
"writes",
"it",
"to",
"the",
"precursor",
"entry"
] | 091751eb12512f4bc6ada07bda745ce49331e24f | https://github.com/PGB-LIV/php-ms/blob/091751eb12512f4bc6ada07bda745ce49331e24f/src/Reader/MgfReader.php#L218-L243 |
32,106 | comporu/compo-core | src/Compo/FaqBundle/Controller/FaqController.php | FaqController.indexAction | public function indexAction(Request $request)
{
$manager = $this->get('compo_faq.manager.faq');
$page = $request->get('page', 1);
$pager = $manager->getPager([], $page);
$totalPages = $pager->getPageCount();
$seoPage = $this->get('sonata.seo.page');
$seoPage->setContext('faq_list');
$seoPage->addVar('page', $page);
$seoPage->addVar('total_pages', $pager->getPageCount());
if (1 !== $page) {
$seoPage->setLinkCanonical($manager->getFaqIndexPermalink(['page' => $page], 0));
$metas = $seoPage->getMetas();
$metas['name']['robots'] = 'noindex, follow';
$seoPage->setMetas($metas);
} else {
$seoPage->setLinkCanonical($manager->getFaqIndexPermalink([], 0));
}
if ($totalPages > 1 && $page < $totalPages) {
$seoPage->setLinkNext($manager->getFaqIndexPermalink(['page' => $page + 1], 0));
}
if ($totalPages > 1 && $page > 1) {
$seoPage->setLinkPrev($manager->getFaqIndexPermalink(['page' => $page - 1], 0));
}
$seoPage->build();
return $this->render(
'CompoFaqBundle:Faq:index.html.twig',
[
'pager' => $pager,
]
);
} | php | public function indexAction(Request $request)
{
$manager = $this->get('compo_faq.manager.faq');
$page = $request->get('page', 1);
$pager = $manager->getPager([], $page);
$totalPages = $pager->getPageCount();
$seoPage = $this->get('sonata.seo.page');
$seoPage->setContext('faq_list');
$seoPage->addVar('page', $page);
$seoPage->addVar('total_pages', $pager->getPageCount());
if (1 !== $page) {
$seoPage->setLinkCanonical($manager->getFaqIndexPermalink(['page' => $page], 0));
$metas = $seoPage->getMetas();
$metas['name']['robots'] = 'noindex, follow';
$seoPage->setMetas($metas);
} else {
$seoPage->setLinkCanonical($manager->getFaqIndexPermalink([], 0));
}
if ($totalPages > 1 && $page < $totalPages) {
$seoPage->setLinkNext($manager->getFaqIndexPermalink(['page' => $page + 1], 0));
}
if ($totalPages > 1 && $page > 1) {
$seoPage->setLinkPrev($manager->getFaqIndexPermalink(['page' => $page - 1], 0));
}
$seoPage->build();
return $this->render(
'CompoFaqBundle:Faq:index.html.twig',
[
'pager' => $pager,
]
);
} | [
"public",
"function",
"indexAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"manager",
"=",
"$",
"this",
"->",
"get",
"(",
"'compo_faq.manager.faq'",
")",
";",
"$",
"page",
"=",
"$",
"request",
"->",
"get",
"(",
"'page'",
",",
"1",
")",
";",
"$",
"pager",
"=",
"$",
"manager",
"->",
"getPager",
"(",
"[",
"]",
",",
"$",
"page",
")",
";",
"$",
"totalPages",
"=",
"$",
"pager",
"->",
"getPageCount",
"(",
")",
";",
"$",
"seoPage",
"=",
"$",
"this",
"->",
"get",
"(",
"'sonata.seo.page'",
")",
";",
"$",
"seoPage",
"->",
"setContext",
"(",
"'faq_list'",
")",
";",
"$",
"seoPage",
"->",
"addVar",
"(",
"'page'",
",",
"$",
"page",
")",
";",
"$",
"seoPage",
"->",
"addVar",
"(",
"'total_pages'",
",",
"$",
"pager",
"->",
"getPageCount",
"(",
")",
")",
";",
"if",
"(",
"1",
"!==",
"$",
"page",
")",
"{",
"$",
"seoPage",
"->",
"setLinkCanonical",
"(",
"$",
"manager",
"->",
"getFaqIndexPermalink",
"(",
"[",
"'page'",
"=>",
"$",
"page",
"]",
",",
"0",
")",
")",
";",
"$",
"metas",
"=",
"$",
"seoPage",
"->",
"getMetas",
"(",
")",
";",
"$",
"metas",
"[",
"'name'",
"]",
"[",
"'robots'",
"]",
"=",
"'noindex, follow'",
";",
"$",
"seoPage",
"->",
"setMetas",
"(",
"$",
"metas",
")",
";",
"}",
"else",
"{",
"$",
"seoPage",
"->",
"setLinkCanonical",
"(",
"$",
"manager",
"->",
"getFaqIndexPermalink",
"(",
"[",
"]",
",",
"0",
")",
")",
";",
"}",
"if",
"(",
"$",
"totalPages",
">",
"1",
"&&",
"$",
"page",
"<",
"$",
"totalPages",
")",
"{",
"$",
"seoPage",
"->",
"setLinkNext",
"(",
"$",
"manager",
"->",
"getFaqIndexPermalink",
"(",
"[",
"'page'",
"=>",
"$",
"page",
"+",
"1",
"]",
",",
"0",
")",
")",
";",
"}",
"if",
"(",
"$",
"totalPages",
">",
"1",
"&&",
"$",
"page",
">",
"1",
")",
"{",
"$",
"seoPage",
"->",
"setLinkPrev",
"(",
"$",
"manager",
"->",
"getFaqIndexPermalink",
"(",
"[",
"'page'",
"=>",
"$",
"page",
"-",
"1",
"]",
",",
"0",
")",
")",
";",
"}",
"$",
"seoPage",
"->",
"build",
"(",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'CompoFaqBundle:Faq:index.html.twig'",
",",
"[",
"'pager'",
"=>",
"$",
"pager",
",",
"]",
")",
";",
"}"
] | Lists all article entities.
@param Request $request
@throws \Throwable
@return \Symfony\Component\HttpFoundation\Response | [
"Lists",
"all",
"article",
"entities",
"."
] | ebaa9fe8a4b831506c78fdf637da6b4deadec1e2 | https://github.com/comporu/compo-core/blob/ebaa9fe8a4b831506c78fdf637da6b4deadec1e2/src/Compo/FaqBundle/Controller/FaqController.php#L29-L68 |
32,107 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopOrderStep/TShopStepOrderCompletedCore.class.php | TShopStepOrderCompletedCore.GetDescriptionVariables | protected function GetDescriptionVariables()
{
$aParameter = parent::GetDescriptionVariables();
// add some data about the order so that we can display the details on the closing page
$oUserOrder = &TShopBasket::GetLastCreatedOrder();
if (!is_null($oUserOrder)) {
foreach ($oUserOrder as $sProperty => $sPropertyValue) {
if ('field' == substr($sProperty, 0, 5)) {
$aParameter[$sProperty] = $sPropertyValue;
}
}
$aParameter['sOrderNumber'] = $oUserOrder->fieldOrdernumber;
}
$oShop = TdbShop::GetInstance();
// add link to display a printable version of the order
$aParameter['sLinkPrintableVersion'] = $oShop->GetLinkToSystemPage('print-order', array('id' => $oUserOrder->id));
$aParameter[strtolower('sLinkPrintableVersion')] = $aParameter['sLinkPrintableVersion']; // links should be all lowercase - some customers force this (and some wysiwyg may require this as well) so we provide both variations
$aParameter['oLastOrder'] = $oUserOrder;
return $aParameter;
} | php | protected function GetDescriptionVariables()
{
$aParameter = parent::GetDescriptionVariables();
// add some data about the order so that we can display the details on the closing page
$oUserOrder = &TShopBasket::GetLastCreatedOrder();
if (!is_null($oUserOrder)) {
foreach ($oUserOrder as $sProperty => $sPropertyValue) {
if ('field' == substr($sProperty, 0, 5)) {
$aParameter[$sProperty] = $sPropertyValue;
}
}
$aParameter['sOrderNumber'] = $oUserOrder->fieldOrdernumber;
}
$oShop = TdbShop::GetInstance();
// add link to display a printable version of the order
$aParameter['sLinkPrintableVersion'] = $oShop->GetLinkToSystemPage('print-order', array('id' => $oUserOrder->id));
$aParameter[strtolower('sLinkPrintableVersion')] = $aParameter['sLinkPrintableVersion']; // links should be all lowercase - some customers force this (and some wysiwyg may require this as well) so we provide both variations
$aParameter['oLastOrder'] = $oUserOrder;
return $aParameter;
} | [
"protected",
"function",
"GetDescriptionVariables",
"(",
")",
"{",
"$",
"aParameter",
"=",
"parent",
"::",
"GetDescriptionVariables",
"(",
")",
";",
"// add some data about the order so that we can display the details on the closing page",
"$",
"oUserOrder",
"=",
"&",
"TShopBasket",
"::",
"GetLastCreatedOrder",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"oUserOrder",
")",
")",
"{",
"foreach",
"(",
"$",
"oUserOrder",
"as",
"$",
"sProperty",
"=>",
"$",
"sPropertyValue",
")",
"{",
"if",
"(",
"'field'",
"==",
"substr",
"(",
"$",
"sProperty",
",",
"0",
",",
"5",
")",
")",
"{",
"$",
"aParameter",
"[",
"$",
"sProperty",
"]",
"=",
"$",
"sPropertyValue",
";",
"}",
"}",
"$",
"aParameter",
"[",
"'sOrderNumber'",
"]",
"=",
"$",
"oUserOrder",
"->",
"fieldOrdernumber",
";",
"}",
"$",
"oShop",
"=",
"TdbShop",
"::",
"GetInstance",
"(",
")",
";",
"// add link to display a printable version of the order",
"$",
"aParameter",
"[",
"'sLinkPrintableVersion'",
"]",
"=",
"$",
"oShop",
"->",
"GetLinkToSystemPage",
"(",
"'print-order'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"oUserOrder",
"->",
"id",
")",
")",
";",
"$",
"aParameter",
"[",
"strtolower",
"(",
"'sLinkPrintableVersion'",
")",
"]",
"=",
"$",
"aParameter",
"[",
"'sLinkPrintableVersion'",
"]",
";",
"// links should be all lowercase - some customers force this (and some wysiwyg may require this as well) so we provide both variations",
"$",
"aParameter",
"[",
"'oLastOrder'",
"]",
"=",
"$",
"oUserOrder",
";",
"return",
"$",
"aParameter",
";",
"}"
] | method should return any variables that should be replaced in the description field.
@return array | [
"method",
"should",
"return",
"any",
"variables",
"that",
"should",
"be",
"replaced",
"in",
"the",
"description",
"field",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopOrderStep/TShopStepOrderCompletedCore.class.php#L50-L72 |
32,108 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopOrderStep/TShopStepOrderCompletedCore.class.php | TShopStepOrderCompletedCore.Render | public function Render($sSpotName = null, $aCallTimeVars = array())
{
$oUser = TdbDataExtranetUser::GetInstance();
if (!is_null($oUser->fieldName) && !$oUser->IsLoggedIn()) {
$this->SetLastUserBoughtToSession($oUser);
}
$sHTML = parent::Render($sSpotName, $aCallTimeVars);
TdbShopOrderStep::ResetMarkOrderProcessAsCompleted();
// if the user is not logged in, we need to clear the user object
if (empty($oUser->id) || false == $oUser->IsLoggedIn()) {
$tmp = $oUser->GetInstance(true);
}
return $sHTML;
} | php | public function Render($sSpotName = null, $aCallTimeVars = array())
{
$oUser = TdbDataExtranetUser::GetInstance();
if (!is_null($oUser->fieldName) && !$oUser->IsLoggedIn()) {
$this->SetLastUserBoughtToSession($oUser);
}
$sHTML = parent::Render($sSpotName, $aCallTimeVars);
TdbShopOrderStep::ResetMarkOrderProcessAsCompleted();
// if the user is not logged in, we need to clear the user object
if (empty($oUser->id) || false == $oUser->IsLoggedIn()) {
$tmp = $oUser->GetInstance(true);
}
return $sHTML;
} | [
"public",
"function",
"Render",
"(",
"$",
"sSpotName",
"=",
"null",
",",
"$",
"aCallTimeVars",
"=",
"array",
"(",
")",
")",
"{",
"$",
"oUser",
"=",
"TdbDataExtranetUser",
"::",
"GetInstance",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"oUser",
"->",
"fieldName",
")",
"&&",
"!",
"$",
"oUser",
"->",
"IsLoggedIn",
"(",
")",
")",
"{",
"$",
"this",
"->",
"SetLastUserBoughtToSession",
"(",
"$",
"oUser",
")",
";",
"}",
"$",
"sHTML",
"=",
"parent",
"::",
"Render",
"(",
"$",
"sSpotName",
",",
"$",
"aCallTimeVars",
")",
";",
"TdbShopOrderStep",
"::",
"ResetMarkOrderProcessAsCompleted",
"(",
")",
";",
"// if the user is not logged in, we need to clear the user object",
"if",
"(",
"empty",
"(",
"$",
"oUser",
"->",
"id",
")",
"||",
"false",
"==",
"$",
"oUser",
"->",
"IsLoggedIn",
"(",
")",
")",
"{",
"$",
"tmp",
"=",
"$",
"oUser",
"->",
"GetInstance",
"(",
"true",
")",
";",
"}",
"return",
"$",
"sHTML",
";",
"}"
] | used to display the step.
@param array $aCallTimeVars - place any custom vars that you want to pass through the call here
@return string | [
"used",
"to",
"display",
"the",
"step",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopOrderStep/TShopStepOrderCompletedCore.class.php#L81-L96 |
32,109 | edmondscommerce/doctrine-static-meta | src/EntityManager/RetryConnection/Statement.php | Statement.createStatement | private function createStatement()
{
$this->wrappedStatement = $this->connection->prepareUnwrapped($this->sql);
foreach ($this->params as $params) {
$this->bindParam(...$params);
}
$this->params = [];
foreach ($this->values as $values) {
$this->bindValue(...$values);
}
$this->values = [];
} | php | private function createStatement()
{
$this->wrappedStatement = $this->connection->prepareUnwrapped($this->sql);
foreach ($this->params as $params) {
$this->bindParam(...$params);
}
$this->params = [];
foreach ($this->values as $values) {
$this->bindValue(...$values);
}
$this->values = [];
} | [
"private",
"function",
"createStatement",
"(",
")",
"{",
"$",
"this",
"->",
"wrappedStatement",
"=",
"$",
"this",
"->",
"connection",
"->",
"prepareUnwrapped",
"(",
"$",
"this",
"->",
"sql",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"params",
"as",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"bindParam",
"(",
"...",
"$",
"params",
")",
";",
"}",
"$",
"this",
"->",
"params",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"values",
"as",
"$",
"values",
")",
"{",
"$",
"this",
"->",
"bindValue",
"(",
"...",
"$",
"values",
")",
";",
"}",
"$",
"this",
"->",
"values",
"=",
"[",
"]",
";",
"}"
] | Create Statement. | [
"Create",
"Statement",
"."
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/EntityManager/RetryConnection/Statement.php#L52-L63 |
32,110 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopShippingGroupList.class.php | TShopShippingGroupList.& | public static function &GetAvailableShippingGroups()
{
$oList = &TdbShopShippingGroupList::GetList();
$oList->bAllowItemCache = true;
$oList->RemoveInvalidItems();
$oList->GoToStart();
return $oList;
} | php | public static function &GetAvailableShippingGroups()
{
$oList = &TdbShopShippingGroupList::GetList();
$oList->bAllowItemCache = true;
$oList->RemoveInvalidItems();
$oList->GoToStart();
return $oList;
} | [
"public",
"static",
"function",
"&",
"GetAvailableShippingGroups",
"(",
")",
"{",
"$",
"oList",
"=",
"&",
"TdbShopShippingGroupList",
"::",
"GetList",
"(",
")",
";",
"$",
"oList",
"->",
"bAllowItemCache",
"=",
"true",
";",
"$",
"oList",
"->",
"RemoveInvalidItems",
"(",
")",
";",
"$",
"oList",
"->",
"GoToStart",
"(",
")",
";",
"return",
"$",
"oList",
";",
"}"
] | return all shipping groups available to the current user with the current basket.
@return TdbShopShippingGroupList | [
"return",
"all",
"shipping",
"groups",
"available",
"to",
"the",
"current",
"user",
"with",
"the",
"current",
"basket",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopShippingGroupList.class.php#L19-L27 |
32,111 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopShippingGroupList.class.php | TShopShippingGroupList.& | public static function &GetShippingGroupsThatAllowPaymentWith($sPaymentInternalName)
{
$oList = &TdbShopShippingGroupList::GetAvailableShippingGroups();
$bFound = false;
$oShippingGroup = null;
while (!$bFound && ($oShippingGroup = &$oList->Next())) {
$oPaymentMethods = &$oShippingGroup->GetValidPaymentMethods();
$oPayPal = $oPaymentMethods->FindItemWithProperty('fieldNameInternal', $sPaymentInternalName);
if ($oPayPal) {
$bFound = true;
}
}
if (!$bFound) {
$oShippingGroup = false;
}
return $oShippingGroup;
} | php | public static function &GetShippingGroupsThatAllowPaymentWith($sPaymentInternalName)
{
$oList = &TdbShopShippingGroupList::GetAvailableShippingGroups();
$bFound = false;
$oShippingGroup = null;
while (!$bFound && ($oShippingGroup = &$oList->Next())) {
$oPaymentMethods = &$oShippingGroup->GetValidPaymentMethods();
$oPayPal = $oPaymentMethods->FindItemWithProperty('fieldNameInternal', $sPaymentInternalName);
if ($oPayPal) {
$bFound = true;
}
}
if (!$bFound) {
$oShippingGroup = false;
}
return $oShippingGroup;
} | [
"public",
"static",
"function",
"&",
"GetShippingGroupsThatAllowPaymentWith",
"(",
"$",
"sPaymentInternalName",
")",
"{",
"$",
"oList",
"=",
"&",
"TdbShopShippingGroupList",
"::",
"GetAvailableShippingGroups",
"(",
")",
";",
"$",
"bFound",
"=",
"false",
";",
"$",
"oShippingGroup",
"=",
"null",
";",
"while",
"(",
"!",
"$",
"bFound",
"&&",
"(",
"$",
"oShippingGroup",
"=",
"&",
"$",
"oList",
"->",
"Next",
"(",
")",
")",
")",
"{",
"$",
"oPaymentMethods",
"=",
"&",
"$",
"oShippingGroup",
"->",
"GetValidPaymentMethods",
"(",
")",
";",
"$",
"oPayPal",
"=",
"$",
"oPaymentMethods",
"->",
"FindItemWithProperty",
"(",
"'fieldNameInternal'",
",",
"$",
"sPaymentInternalName",
")",
";",
"if",
"(",
"$",
"oPayPal",
")",
"{",
"$",
"bFound",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"bFound",
")",
"{",
"$",
"oShippingGroup",
"=",
"false",
";",
"}",
"return",
"$",
"oShippingGroup",
";",
"}"
] | search for a shipping group that supports the given payment type
returns false if nothing is found.
@param string $sPaymentInternalName
@return bool | [
"search",
"for",
"a",
"shipping",
"group",
"that",
"supports",
"the",
"given",
"payment",
"type",
"returns",
"false",
"if",
"nothing",
"is",
"found",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopShippingGroupList.class.php#L37-L55 |
32,112 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopShippingGroupList.class.php | TShopShippingGroupList.& | public static function &GetPublicShippingGroups()
{
$oList = &TdbShopShippingGroupList::GetList();
$oList->bAllowItemCache = true;
$oList->RemoveRestrictedItems();
return $oList;
} | php | public static function &GetPublicShippingGroups()
{
$oList = &TdbShopShippingGroupList::GetList();
$oList->bAllowItemCache = true;
$oList->RemoveRestrictedItems();
return $oList;
} | [
"public",
"static",
"function",
"&",
"GetPublicShippingGroups",
"(",
")",
"{",
"$",
"oList",
"=",
"&",
"TdbShopShippingGroupList",
"::",
"GetList",
"(",
")",
";",
"$",
"oList",
"->",
"bAllowItemCache",
"=",
"true",
";",
"$",
"oList",
"->",
"RemoveRestrictedItems",
"(",
")",
";",
"return",
"$",
"oList",
";",
"}"
] | return all shipping groups that have no user restriction.
@return TdbShopShippingGroupList | [
"return",
"all",
"shipping",
"groups",
"that",
"have",
"no",
"user",
"restriction",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopShippingGroupList.class.php#L62-L69 |
32,113 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopShippingGroupList.class.php | TShopShippingGroupList.RemoveInvalidItems | public function RemoveInvalidItems()
{
// since this is a tcmsrecord list, we need to collect all valid ids, and the reload the list with them
$oBasket = TShopBasket::GetInstance();
$aValidIds = array();
$this->GoToStart();
$aValidShippingGroupItems = array();
while ($oItem = &$this->Next()) {
$oBasket->ResetAllShippingMarkers(); // we need to reset the shipping marker on every group call - since we want
// to consider every single item in the basket
if ($oItem->isAvailableIgnoreGroupRestriction()) {
$aValidIds[] = MySqlLegacySupport::getInstance()->real_escape_string($oItem->id);
$aValidShippingGroupItems['x'.$oItem->id] = $oItem;
}
}
$oBasket->ResetAllShippingMarkers(); // once we are done, we want to clear the marker again
// remove any shipping groups that are not allowed to be shown when other shipping groups are available
$aRealValidIds = array();
foreach ($aValidIds as $sShippingGroupId) {
/** @var $oItem TdbShopShippingGroup */
$oItem = $aValidShippingGroupItems['x'.$sShippingGroupId];
if ($oItem->allowedForShippingGroupList($aValidIds)) {
$aRealValidIds[] = $sShippingGroupId;
}
}
$aValidIds = $aRealValidIds;
unset($aRealValidIds);
$query = 'SELECT `shop_shipping_group`.*
FROM `shop_shipping_group`
WHERE ';
if (count($aValidIds) > 0) {
$query .= " `shop_shipping_group`.`id` IN ('".implode("','", $aValidIds)."') ";
} else {
$query .= ' 1 = 0 ';
}
$query .= ' ORDER BY `shop_shipping_group`.`position`';
$this->Load($query);
} | php | public function RemoveInvalidItems()
{
// since this is a tcmsrecord list, we need to collect all valid ids, and the reload the list with them
$oBasket = TShopBasket::GetInstance();
$aValidIds = array();
$this->GoToStart();
$aValidShippingGroupItems = array();
while ($oItem = &$this->Next()) {
$oBasket->ResetAllShippingMarkers(); // we need to reset the shipping marker on every group call - since we want
// to consider every single item in the basket
if ($oItem->isAvailableIgnoreGroupRestriction()) {
$aValidIds[] = MySqlLegacySupport::getInstance()->real_escape_string($oItem->id);
$aValidShippingGroupItems['x'.$oItem->id] = $oItem;
}
}
$oBasket->ResetAllShippingMarkers(); // once we are done, we want to clear the marker again
// remove any shipping groups that are not allowed to be shown when other shipping groups are available
$aRealValidIds = array();
foreach ($aValidIds as $sShippingGroupId) {
/** @var $oItem TdbShopShippingGroup */
$oItem = $aValidShippingGroupItems['x'.$sShippingGroupId];
if ($oItem->allowedForShippingGroupList($aValidIds)) {
$aRealValidIds[] = $sShippingGroupId;
}
}
$aValidIds = $aRealValidIds;
unset($aRealValidIds);
$query = 'SELECT `shop_shipping_group`.*
FROM `shop_shipping_group`
WHERE ';
if (count($aValidIds) > 0) {
$query .= " `shop_shipping_group`.`id` IN ('".implode("','", $aValidIds)."') ";
} else {
$query .= ' 1 = 0 ';
}
$query .= ' ORDER BY `shop_shipping_group`.`position`';
$this->Load($query);
} | [
"public",
"function",
"RemoveInvalidItems",
"(",
")",
"{",
"// since this is a tcmsrecord list, we need to collect all valid ids, and the reload the list with them",
"$",
"oBasket",
"=",
"TShopBasket",
"::",
"GetInstance",
"(",
")",
";",
"$",
"aValidIds",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"GoToStart",
"(",
")",
";",
"$",
"aValidShippingGroupItems",
"=",
"array",
"(",
")",
";",
"while",
"(",
"$",
"oItem",
"=",
"&",
"$",
"this",
"->",
"Next",
"(",
")",
")",
"{",
"$",
"oBasket",
"->",
"ResetAllShippingMarkers",
"(",
")",
";",
"// we need to reset the shipping marker on every group call - since we want",
"// to consider every single item in the basket",
"if",
"(",
"$",
"oItem",
"->",
"isAvailableIgnoreGroupRestriction",
"(",
")",
")",
"{",
"$",
"aValidIds",
"[",
"]",
"=",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"real_escape_string",
"(",
"$",
"oItem",
"->",
"id",
")",
";",
"$",
"aValidShippingGroupItems",
"[",
"'x'",
".",
"$",
"oItem",
"->",
"id",
"]",
"=",
"$",
"oItem",
";",
"}",
"}",
"$",
"oBasket",
"->",
"ResetAllShippingMarkers",
"(",
")",
";",
"// once we are done, we want to clear the marker again",
"// remove any shipping groups that are not allowed to be shown when other shipping groups are available",
"$",
"aRealValidIds",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"aValidIds",
"as",
"$",
"sShippingGroupId",
")",
"{",
"/** @var $oItem TdbShopShippingGroup */",
"$",
"oItem",
"=",
"$",
"aValidShippingGroupItems",
"[",
"'x'",
".",
"$",
"sShippingGroupId",
"]",
";",
"if",
"(",
"$",
"oItem",
"->",
"allowedForShippingGroupList",
"(",
"$",
"aValidIds",
")",
")",
"{",
"$",
"aRealValidIds",
"[",
"]",
"=",
"$",
"sShippingGroupId",
";",
"}",
"}",
"$",
"aValidIds",
"=",
"$",
"aRealValidIds",
";",
"unset",
"(",
"$",
"aRealValidIds",
")",
";",
"$",
"query",
"=",
"'SELECT `shop_shipping_group`.*\n FROM `shop_shipping_group`\n WHERE '",
";",
"if",
"(",
"count",
"(",
"$",
"aValidIds",
")",
">",
"0",
")",
"{",
"$",
"query",
".=",
"\" `shop_shipping_group`.`id` IN ('\"",
".",
"implode",
"(",
"\"','\"",
",",
"$",
"aValidIds",
")",
".",
"\"') \"",
";",
"}",
"else",
"{",
"$",
"query",
".=",
"' 1 = 0 '",
";",
"}",
"$",
"query",
".=",
"' ORDER BY `shop_shipping_group`.`position`'",
";",
"$",
"this",
"->",
"Load",
"(",
"$",
"query",
")",
";",
"}"
] | remove list items that are not permited for the current user or basket. | [
"remove",
"list",
"items",
"that",
"are",
"not",
"permited",
"for",
"the",
"current",
"user",
"or",
"basket",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopShippingGroupList.class.php#L74-L114 |
32,114 | MetaModels/filter_checkbox | src/FilterSetting/Checkbox.php | Checkbox.getAvailableLanguages | private function getAvailableLanguages(IMetaModel $objMetaModel)
{
return ($objMetaModel->isTranslated() && $this->get('all_langs'))
? $objMetaModel->getAvailableLanguages()
: array($objMetaModel->getActiveLanguage());
} | php | private function getAvailableLanguages(IMetaModel $objMetaModel)
{
return ($objMetaModel->isTranslated() && $this->get('all_langs'))
? $objMetaModel->getAvailableLanguages()
: array($objMetaModel->getActiveLanguage());
} | [
"private",
"function",
"getAvailableLanguages",
"(",
"IMetaModel",
"$",
"objMetaModel",
")",
"{",
"return",
"(",
"$",
"objMetaModel",
"->",
"isTranslated",
"(",
")",
"&&",
"$",
"this",
"->",
"get",
"(",
"'all_langs'",
")",
")",
"?",
"$",
"objMetaModel",
"->",
"getAvailableLanguages",
"(",
")",
":",
"array",
"(",
"$",
"objMetaModel",
"->",
"getActiveLanguage",
"(",
")",
")",
";",
"}"
] | Get available langauges.
@param IMetaModel $objMetaModel The metamodel.
@return array|null|\string[] | [
"Get",
"available",
"langauges",
"."
] | 613512934656b17a545a45a231e940e26fbd7b6c | https://github.com/MetaModels/filter_checkbox/blob/613512934656b17a545a45a231e940e26fbd7b6c/src/FilterSetting/Checkbox.php#L191-L196 |
32,115 | MetaModels/filter_checkbox | src/FilterSetting/Checkbox.php | Checkbox.prepareLabel | private function prepareLabel(IAttribute $objAttribute)
{
return ($this->get('ynmode') == 'radio' || $this->get('ynfield') ?
array(
($this->get('label') ?: $objAttribute->getName()),
($this->get('ynmode') == 'yes'
? $GLOBALS['TL_LANG']['MSC']['yes']
: $GLOBALS['TL_LANG']['MSC']['no']
)
)
:
array(
($this->get('label') ?: $objAttribute->getName()),
($this->get('ynmode') == 'no'
? sprintf(
$GLOBALS['TL_LANG']['MSC']['extended_no'],
($this->get('label') ?: $objAttribute->getName())
)
: ($this->get('label') ?: $objAttribute->getName())
)
)
);
} | php | private function prepareLabel(IAttribute $objAttribute)
{
return ($this->get('ynmode') == 'radio' || $this->get('ynfield') ?
array(
($this->get('label') ?: $objAttribute->getName()),
($this->get('ynmode') == 'yes'
? $GLOBALS['TL_LANG']['MSC']['yes']
: $GLOBALS['TL_LANG']['MSC']['no']
)
)
:
array(
($this->get('label') ?: $objAttribute->getName()),
($this->get('ynmode') == 'no'
? sprintf(
$GLOBALS['TL_LANG']['MSC']['extended_no'],
($this->get('label') ?: $objAttribute->getName())
)
: ($this->get('label') ?: $objAttribute->getName())
)
)
);
} | [
"private",
"function",
"prepareLabel",
"(",
"IAttribute",
"$",
"objAttribute",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"get",
"(",
"'ynmode'",
")",
"==",
"'radio'",
"||",
"$",
"this",
"->",
"get",
"(",
"'ynfield'",
")",
"?",
"array",
"(",
"(",
"$",
"this",
"->",
"get",
"(",
"'label'",
")",
"?",
":",
"$",
"objAttribute",
"->",
"getName",
"(",
")",
")",
",",
"(",
"$",
"this",
"->",
"get",
"(",
"'ynmode'",
")",
"==",
"'yes'",
"?",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"'MSC'",
"]",
"[",
"'yes'",
"]",
":",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"'MSC'",
"]",
"[",
"'no'",
"]",
")",
")",
":",
"array",
"(",
"(",
"$",
"this",
"->",
"get",
"(",
"'label'",
")",
"?",
":",
"$",
"objAttribute",
"->",
"getName",
"(",
")",
")",
",",
"(",
"$",
"this",
"->",
"get",
"(",
"'ynmode'",
")",
"==",
"'no'",
"?",
"sprintf",
"(",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"'MSC'",
"]",
"[",
"'extended_no'",
"]",
",",
"(",
"$",
"this",
"->",
"get",
"(",
"'label'",
")",
"?",
":",
"$",
"objAttribute",
"->",
"getName",
"(",
")",
")",
")",
":",
"(",
"$",
"this",
"->",
"get",
"(",
"'label'",
")",
"?",
":",
"$",
"objAttribute",
"->",
"getName",
"(",
")",
")",
")",
")",
")",
";",
"}"
] | Prepare the label depending on yes no mode.
@param IAttribute $objAttribute The metamodel attribute.
@return array
@SuppressWarnings(PHPMD.Superglobals) | [
"Prepare",
"the",
"label",
"depending",
"on",
"yes",
"no",
"mode",
"."
] | 613512934656b17a545a45a231e940e26fbd7b6c | https://github.com/MetaModels/filter_checkbox/blob/613512934656b17a545a45a231e940e26fbd7b6c/src/FilterSetting/Checkbox.php#L207-L229 |
32,116 | symbiote/silverstripe-cdncontent | code/extensions/CDNFile.php | CDNFile.targetStore | public function targetStore() {
if ($this->owner->ParentID) {
$store = $this->owner->Parent()->getCDNStore();
return $store;
}
return $this->contentService->getDefaultStore();
} | php | public function targetStore() {
if ($this->owner->ParentID) {
$store = $this->owner->Parent()->getCDNStore();
return $store;
}
return $this->contentService->getDefaultStore();
} | [
"public",
"function",
"targetStore",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"ParentID",
")",
"{",
"$",
"store",
"=",
"$",
"this",
"->",
"owner",
"->",
"Parent",
"(",
")",
"->",
"getCDNStore",
"(",
")",
";",
"return",
"$",
"store",
";",
"}",
"return",
"$",
"this",
"->",
"contentService",
"->",
"getDefaultStore",
"(",
")",
";",
"}"
] | Return the CDN store that this file should be stored into, based on its
parent setting, if no parent is found the ContentService default is returned | [
"Return",
"the",
"CDN",
"store",
"that",
"this",
"file",
"should",
"be",
"stored",
"into",
"based",
"on",
"its",
"parent",
"setting",
"if",
"no",
"parent",
"is",
"found",
"the",
"ContentService",
"default",
"is",
"returned"
] | a5f82e802e9addaf98d506cf305a621b873a5c9b | https://github.com/symbiote/silverstripe-cdncontent/blob/a5f82e802e9addaf98d506cf305a621b873a5c9b/code/extensions/CDNFile.php#L154-L161 |
32,117 | symbiote/silverstripe-cdncontent | code/extensions/CDNFile.php | CDNFile.updateURL | public function updateURL(&$url) {
if($this->owner instanceof \Image_Cached || $this->owner instanceof \CdnImage_Cached) {
return; /** handled in @link ImageCachedExtension */
}
// in the CMS, we do _not_ change the asset
$controller = Controller::has_curr() ? Controller::curr() : null;
if ($controller instanceof LeftAndMain) {
return;
}
if ($this->owner->CanViewType && $this->owner->getViewType() != CDNFile::ANYONE_PERM) {
return;
}
$cdnLink = $this->getCdnLink();
if ($cdnLink) {
$url = $cdnLink;
}
} | php | public function updateURL(&$url) {
if($this->owner instanceof \Image_Cached || $this->owner instanceof \CdnImage_Cached) {
return; /** handled in @link ImageCachedExtension */
}
// in the CMS, we do _not_ change the asset
$controller = Controller::has_curr() ? Controller::curr() : null;
if ($controller instanceof LeftAndMain) {
return;
}
if ($this->owner->CanViewType && $this->owner->getViewType() != CDNFile::ANYONE_PERM) {
return;
}
$cdnLink = $this->getCdnLink();
if ($cdnLink) {
$url = $cdnLink;
}
} | [
"public",
"function",
"updateURL",
"(",
"&",
"$",
"url",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"owner",
"instanceof",
"\\",
"Image_Cached",
"||",
"$",
"this",
"->",
"owner",
"instanceof",
"\\",
"CdnImage_Cached",
")",
"{",
"return",
";",
"/** handled in @link ImageCachedExtension */",
"}",
"// in the CMS, we do _not_ change the asset",
"$",
"controller",
"=",
"Controller",
"::",
"has_curr",
"(",
")",
"?",
"Controller",
"::",
"curr",
"(",
")",
":",
"null",
";",
"if",
"(",
"$",
"controller",
"instanceof",
"LeftAndMain",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"CanViewType",
"&&",
"$",
"this",
"->",
"owner",
"->",
"getViewType",
"(",
")",
"!=",
"CDNFile",
"::",
"ANYONE_PERM",
")",
"{",
"return",
";",
"}",
"$",
"cdnLink",
"=",
"$",
"this",
"->",
"getCdnLink",
"(",
")",
";",
"if",
"(",
"$",
"cdnLink",
")",
"{",
"$",
"url",
"=",
"$",
"cdnLink",
";",
"}",
"}"
] | Update the URL used for a file in various locations
@param type $url
@return null | [
"Update",
"the",
"URL",
"used",
"for",
"a",
"file",
"in",
"various",
"locations"
] | a5f82e802e9addaf98d506cf305a621b873a5c9b | https://github.com/symbiote/silverstripe-cdncontent/blob/a5f82e802e9addaf98d506cf305a621b873a5c9b/code/extensions/CDNFile.php#L189-L208 |
32,118 | symbiote/silverstripe-cdncontent | code/extensions/CDNFile.php | CDNFile.getSecureURL | public function getSecureURL($expires = 60) {
if($this->owner instanceof \Image_Cached || $this->owner instanceof \CdnImage_Cached) {
return;
}
/** @var \FileContent $pointer */
$pointer = $this->owner->obj('CDNFile');
if($pointer->exists()) {
$reader = $this->reader();
if ($reader && $this->owner->canView() && method_exists($reader, 'getSecureURL')) {
return $reader->getSecureURL($expires);
}
}
} | php | public function getSecureURL($expires = 60) {
if($this->owner instanceof \Image_Cached || $this->owner instanceof \CdnImage_Cached) {
return;
}
/** @var \FileContent $pointer */
$pointer = $this->owner->obj('CDNFile');
if($pointer->exists()) {
$reader = $this->reader();
if ($reader && $this->owner->canView() && method_exists($reader, 'getSecureURL')) {
return $reader->getSecureURL($expires);
}
}
} | [
"public",
"function",
"getSecureURL",
"(",
"$",
"expires",
"=",
"60",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"owner",
"instanceof",
"\\",
"Image_Cached",
"||",
"$",
"this",
"->",
"owner",
"instanceof",
"\\",
"CdnImage_Cached",
")",
"{",
"return",
";",
"}",
"/** @var \\FileContent $pointer */",
"$",
"pointer",
"=",
"$",
"this",
"->",
"owner",
"->",
"obj",
"(",
"'CDNFile'",
")",
";",
"if",
"(",
"$",
"pointer",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"reader",
"=",
"$",
"this",
"->",
"reader",
"(",
")",
";",
"if",
"(",
"$",
"reader",
"&&",
"$",
"this",
"->",
"owner",
"->",
"canView",
"(",
")",
"&&",
"method_exists",
"(",
"$",
"reader",
",",
"'getSecureURL'",
")",
")",
"{",
"return",
"$",
"reader",
"->",
"getSecureURL",
"(",
"$",
"expires",
")",
";",
"}",
"}",
"}"
] | Return a secure url for the file. Currently we expect all secure urls are time limited but other limiting methods
nay be supported in the future
@param Int $expires number of second the URL will remain valid
@return String URL pointing the the resource | [
"Return",
"a",
"secure",
"url",
"for",
"the",
"file",
".",
"Currently",
"we",
"expect",
"all",
"secure",
"urls",
"are",
"time",
"limited",
"but",
"other",
"limiting",
"methods",
"nay",
"be",
"supported",
"in",
"the",
"future"
] | a5f82e802e9addaf98d506cf305a621b873a5c9b | https://github.com/symbiote/silverstripe-cdncontent/blob/a5f82e802e9addaf98d506cf305a621b873a5c9b/code/extensions/CDNFile.php#L236-L250 |
32,119 | symbiote/silverstripe-cdncontent | code/extensions/CDNFile.php | CDNFile.getViewType | public function getViewType() {
$perm = null;
if ($this->owner->CanViewType == 'Inherit') {
if ($this->owner->ParentID) {
$perm = $this->owner->Parent()->getViewType();
} else {
$member = Member::currentUser();
$perm = $this->owner->defaultPermissions($member);
}
} else {
$perm = $this->owner->CanViewType;
}
$default = Config::inst()->get('SecureAssets', 'Defaults');
$default = isset($default['Permission']) ? $default['Permission'] : CDNFile::ANYONE_PERM;
return $perm ? $perm : $default;
} | php | public function getViewType() {
$perm = null;
if ($this->owner->CanViewType == 'Inherit') {
if ($this->owner->ParentID) {
$perm = $this->owner->Parent()->getViewType();
} else {
$member = Member::currentUser();
$perm = $this->owner->defaultPermissions($member);
}
} else {
$perm = $this->owner->CanViewType;
}
$default = Config::inst()->get('SecureAssets', 'Defaults');
$default = isset($default['Permission']) ? $default['Permission'] : CDNFile::ANYONE_PERM;
return $perm ? $perm : $default;
} | [
"public",
"function",
"getViewType",
"(",
")",
"{",
"$",
"perm",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"CanViewType",
"==",
"'Inherit'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"ParentID",
")",
"{",
"$",
"perm",
"=",
"$",
"this",
"->",
"owner",
"->",
"Parent",
"(",
")",
"->",
"getViewType",
"(",
")",
";",
"}",
"else",
"{",
"$",
"member",
"=",
"Member",
"::",
"currentUser",
"(",
")",
";",
"$",
"perm",
"=",
"$",
"this",
"->",
"owner",
"->",
"defaultPermissions",
"(",
"$",
"member",
")",
";",
"}",
"}",
"else",
"{",
"$",
"perm",
"=",
"$",
"this",
"->",
"owner",
"->",
"CanViewType",
";",
"}",
"$",
"default",
"=",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"'SecureAssets'",
",",
"'Defaults'",
")",
";",
"$",
"default",
"=",
"isset",
"(",
"$",
"default",
"[",
"'Permission'",
"]",
")",
"?",
"$",
"default",
"[",
"'Permission'",
"]",
":",
"CDNFile",
"::",
"ANYONE_PERM",
";",
"return",
"$",
"perm",
"?",
"$",
"perm",
":",
"$",
"default",
";",
"}"
] | Climbs the folder hierarchy until there's a CanViewType that does not equal Inherit
@return String The first valid CanViewType of this File | [
"Climbs",
"the",
"folder",
"hierarchy",
"until",
"there",
"s",
"a",
"CanViewType",
"that",
"does",
"not",
"equal",
"Inherit"
] | a5f82e802e9addaf98d506cf305a621b873a5c9b | https://github.com/symbiote/silverstripe-cdncontent/blob/a5f82e802e9addaf98d506cf305a621b873a5c9b/code/extensions/CDNFile.php#L257-L276 |
32,120 | symbiote/silverstripe-cdncontent | code/extensions/CDNFile.php | CDNFile.onBeforeDelete | public function onBeforeDelete() {
$store = $this->targetStore();
if (strlen($store)) {
Config::inst()->update('File', 'update_filesystem', false);
}
parent::onBeforeDelete();
} | php | public function onBeforeDelete() {
$store = $this->targetStore();
if (strlen($store)) {
Config::inst()->update('File', 'update_filesystem', false);
}
parent::onBeforeDelete();
} | [
"public",
"function",
"onBeforeDelete",
"(",
")",
"{",
"$",
"store",
"=",
"$",
"this",
"->",
"targetStore",
"(",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"store",
")",
")",
"{",
"Config",
"::",
"inst",
"(",
")",
"->",
"update",
"(",
"'File'",
",",
"'update_filesystem'",
",",
"false",
")",
";",
"}",
"parent",
"::",
"onBeforeDelete",
"(",
")",
";",
"}"
] | And if deleting don't do so | [
"And",
"if",
"deleting",
"don",
"t",
"do",
"so"
] | a5f82e802e9addaf98d506cf305a621b873a5c9b | https://github.com/symbiote/silverstripe-cdncontent/blob/a5f82e802e9addaf98d506cf305a621b873a5c9b/code/extensions/CDNFile.php#L327-L334 |
32,121 | symbiote/silverstripe-cdncontent | code/extensions/CDNFile.php | CDNFile.uploadToContentService | public function uploadToContentService() {
/** @var \File $file */
$file = $this->owner;
$writer = $this->writer();
if (!$writer) {
return;
}
$path = $file->getFullPath();
if (strlen($path) && is_file($path) && file_exists($path)) {
$mtime = @filemtime($path);
$name = trim($file->getFilename(), '/');
if (!$mtime) {
$mtime = '0';
}
//Insert the file modified time to make file unique-ish
if ($lastPos = strrpos($name, '/')) {
// Add in at as last folder name
$name = substr($name, 0, $lastPos) . '/' . $mtime . substr($name, $lastPos);
} else {
//No folder found create one for the mtime
$name = $mtime . '/' . $name;
}
$fileKeyLength = strlen($name);
if ($fileKeyLength > CDNFile::MAX_FILE_PATH_LENGTH) {
$lastPos = strrpos($name, '/');
$ext = '';
$filename = substr($name, $lastPos + 1);
// Try and find a file extension
if (strrpos($name, '.') !== false) {
// Store and trim extension for later replacement
$ext = substr($name, strrpos($name, '.'));
$filename = substr($filename, 0, strrpos($filename, '.'));
}
// add 1 here so we can add in a ~ to indictate truncation
$truncateLength = ($fileKeyLength + strlen($ext) + 1) - CDNFile::MAX_FILE_PATH_LENGTH;
if (strlen($filename) <= $truncateLength) {
// Folder length exceeds CDNFile::MAX_FILE_PATH_LENGTH. MD5 file to prevent file loss log error
SS_Log::log("CDNFile: Total file length (folders + name) exceeds " . CDNFile::MAX_FILE_PATH_LENGTH . " characters and can't be "
. "trimmed. File key has been MD5 encoded. File key: " . md5($name) . $ext . " Filename: "
. "$name", SS_Log::ERR);
$name = md5($name) . $ext;
} else {
// Recombine folder and file name while truncating the filename and appending a ~ then extension
$name = substr($name, 0, $lastPos) . '/' . substr($filename, 0, (0 - $truncateLength)) . '~' . $ext;
}
}
$writer->write(fopen($path, 'r'), $name);
// writer should now have an id
$file->CDNFile = $writer->getContentId();
$file->FileSize = @filesize($path);
// check whether it's an image, and handle its dimensions
if ($file instanceof CdnImage) {
$file->storeDimensions();
}
$file->write();
// confirm the remote upload is there, and delete the local file
// Oct 2016 - UNLESS the versioned files extension is on, we have to treat it slightly different
$this->deleteLocalIfExistsOnContentService();
}
} | php | public function uploadToContentService() {
/** @var \File $file */
$file = $this->owner;
$writer = $this->writer();
if (!$writer) {
return;
}
$path = $file->getFullPath();
if (strlen($path) && is_file($path) && file_exists($path)) {
$mtime = @filemtime($path);
$name = trim($file->getFilename(), '/');
if (!$mtime) {
$mtime = '0';
}
//Insert the file modified time to make file unique-ish
if ($lastPos = strrpos($name, '/')) {
// Add in at as last folder name
$name = substr($name, 0, $lastPos) . '/' . $mtime . substr($name, $lastPos);
} else {
//No folder found create one for the mtime
$name = $mtime . '/' . $name;
}
$fileKeyLength = strlen($name);
if ($fileKeyLength > CDNFile::MAX_FILE_PATH_LENGTH) {
$lastPos = strrpos($name, '/');
$ext = '';
$filename = substr($name, $lastPos + 1);
// Try and find a file extension
if (strrpos($name, '.') !== false) {
// Store and trim extension for later replacement
$ext = substr($name, strrpos($name, '.'));
$filename = substr($filename, 0, strrpos($filename, '.'));
}
// add 1 here so we can add in a ~ to indictate truncation
$truncateLength = ($fileKeyLength + strlen($ext) + 1) - CDNFile::MAX_FILE_PATH_LENGTH;
if (strlen($filename) <= $truncateLength) {
// Folder length exceeds CDNFile::MAX_FILE_PATH_LENGTH. MD5 file to prevent file loss log error
SS_Log::log("CDNFile: Total file length (folders + name) exceeds " . CDNFile::MAX_FILE_PATH_LENGTH . " characters and can't be "
. "trimmed. File key has been MD5 encoded. File key: " . md5($name) . $ext . " Filename: "
. "$name", SS_Log::ERR);
$name = md5($name) . $ext;
} else {
// Recombine folder and file name while truncating the filename and appending a ~ then extension
$name = substr($name, 0, $lastPos) . '/' . substr($filename, 0, (0 - $truncateLength)) . '~' . $ext;
}
}
$writer->write(fopen($path, 'r'), $name);
// writer should now have an id
$file->CDNFile = $writer->getContentId();
$file->FileSize = @filesize($path);
// check whether it's an image, and handle its dimensions
if ($file instanceof CdnImage) {
$file->storeDimensions();
}
$file->write();
// confirm the remote upload is there, and delete the local file
// Oct 2016 - UNLESS the versioned files extension is on, we have to treat it slightly different
$this->deleteLocalIfExistsOnContentService();
}
} | [
"public",
"function",
"uploadToContentService",
"(",
")",
"{",
"/** @var \\File $file */",
"$",
"file",
"=",
"$",
"this",
"->",
"owner",
";",
"$",
"writer",
"=",
"$",
"this",
"->",
"writer",
"(",
")",
";",
"if",
"(",
"!",
"$",
"writer",
")",
"{",
"return",
";",
"}",
"$",
"path",
"=",
"$",
"file",
"->",
"getFullPath",
"(",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"path",
")",
"&&",
"is_file",
"(",
"$",
"path",
")",
"&&",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"$",
"mtime",
"=",
"@",
"filemtime",
"(",
"$",
"path",
")",
";",
"$",
"name",
"=",
"trim",
"(",
"$",
"file",
"->",
"getFilename",
"(",
")",
",",
"'/'",
")",
";",
"if",
"(",
"!",
"$",
"mtime",
")",
"{",
"$",
"mtime",
"=",
"'0'",
";",
"}",
"//Insert the file modified time to make file unique-ish",
"if",
"(",
"$",
"lastPos",
"=",
"strrpos",
"(",
"$",
"name",
",",
"'/'",
")",
")",
"{",
"// Add in at as last folder name",
"$",
"name",
"=",
"substr",
"(",
"$",
"name",
",",
"0",
",",
"$",
"lastPos",
")",
".",
"'/'",
".",
"$",
"mtime",
".",
"substr",
"(",
"$",
"name",
",",
"$",
"lastPos",
")",
";",
"}",
"else",
"{",
"//No folder found create one for the mtime",
"$",
"name",
"=",
"$",
"mtime",
".",
"'/'",
".",
"$",
"name",
";",
"}",
"$",
"fileKeyLength",
"=",
"strlen",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"fileKeyLength",
">",
"CDNFile",
"::",
"MAX_FILE_PATH_LENGTH",
")",
"{",
"$",
"lastPos",
"=",
"strrpos",
"(",
"$",
"name",
",",
"'/'",
")",
";",
"$",
"ext",
"=",
"''",
";",
"$",
"filename",
"=",
"substr",
"(",
"$",
"name",
",",
"$",
"lastPos",
"+",
"1",
")",
";",
"// Try and find a file extension",
"if",
"(",
"strrpos",
"(",
"$",
"name",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"// Store and trim extension for later replacement",
"$",
"ext",
"=",
"substr",
"(",
"$",
"name",
",",
"strrpos",
"(",
"$",
"name",
",",
"'.'",
")",
")",
";",
"$",
"filename",
"=",
"substr",
"(",
"$",
"filename",
",",
"0",
",",
"strrpos",
"(",
"$",
"filename",
",",
"'.'",
")",
")",
";",
"}",
"// add 1 here so we can add in a ~ to indictate truncation",
"$",
"truncateLength",
"=",
"(",
"$",
"fileKeyLength",
"+",
"strlen",
"(",
"$",
"ext",
")",
"+",
"1",
")",
"-",
"CDNFile",
"::",
"MAX_FILE_PATH_LENGTH",
";",
"if",
"(",
"strlen",
"(",
"$",
"filename",
")",
"<=",
"$",
"truncateLength",
")",
"{",
"// Folder length exceeds CDNFile::MAX_FILE_PATH_LENGTH. MD5 file to prevent file loss log error",
"SS_Log",
"::",
"log",
"(",
"\"CDNFile: Total file length (folders + name) exceeds \"",
".",
"CDNFile",
"::",
"MAX_FILE_PATH_LENGTH",
".",
"\" characters and can't be \"",
".",
"\"trimmed. File key has been MD5 encoded. File key: \"",
".",
"md5",
"(",
"$",
"name",
")",
".",
"$",
"ext",
".",
"\" Filename: \"",
".",
"\"$name\"",
",",
"SS_Log",
"::",
"ERR",
")",
";",
"$",
"name",
"=",
"md5",
"(",
"$",
"name",
")",
".",
"$",
"ext",
";",
"}",
"else",
"{",
"// Recombine folder and file name while truncating the filename and appending a ~ then extension",
"$",
"name",
"=",
"substr",
"(",
"$",
"name",
",",
"0",
",",
"$",
"lastPos",
")",
".",
"'/'",
".",
"substr",
"(",
"$",
"filename",
",",
"0",
",",
"(",
"0",
"-",
"$",
"truncateLength",
")",
")",
".",
"'~'",
".",
"$",
"ext",
";",
"}",
"}",
"$",
"writer",
"->",
"write",
"(",
"fopen",
"(",
"$",
"path",
",",
"'r'",
")",
",",
"$",
"name",
")",
";",
"// writer should now have an id",
"$",
"file",
"->",
"CDNFile",
"=",
"$",
"writer",
"->",
"getContentId",
"(",
")",
";",
"$",
"file",
"->",
"FileSize",
"=",
"@",
"filesize",
"(",
"$",
"path",
")",
";",
"// check whether it's an image, and handle its dimensions",
"if",
"(",
"$",
"file",
"instanceof",
"CdnImage",
")",
"{",
"$",
"file",
"->",
"storeDimensions",
"(",
")",
";",
"}",
"$",
"file",
"->",
"write",
"(",
")",
";",
"// confirm the remote upload is there, and delete the local file",
"// Oct 2016 - UNLESS the versioned files extension is on, we have to treat it slightly different",
"$",
"this",
"->",
"deleteLocalIfExistsOnContentService",
"(",
")",
";",
"}",
"}"
] | Upload this content asset to the configured CDN | [
"Upload",
"this",
"content",
"asset",
"to",
"the",
"configured",
"CDN"
] | a5f82e802e9addaf98d506cf305a621b873a5c9b | https://github.com/symbiote/silverstripe-cdncontent/blob/a5f82e802e9addaf98d506cf305a621b873a5c9b/code/extensions/CDNFile.php#L403-L471 |
32,122 | symbiote/silverstripe-cdncontent | code/extensions/CDNFile.php | CDNFile.moveToCdn | public function moveToCdn($newCdn) {
$reader = $this->reader();
// gets the _new_ writer
$writer = $this->getCDNWriter();
// hooking it to match the current cdn path.
$writer->setId($reader->getId());
$writer->write($reader);
$this->owner->CDNFile = $writer->getContentId();
$this->owner->write();
// do the same for all versions
if ($this->owner->hasExtension('VersionedFileExtension')) {
foreach ($this->owner->Versions() as $version) {
if ($version->hasMethod('moveToCdn')) {
try {
$version->moveToCdn($newCdn);
} catch (Exception $ex) {
}
}
}
}
// delete source
$newReader = $writer->getReader();
if ($newReader->exists() && $newReader->getContentId() != $reader->getContentId()) {
$oldWriter = $reader->getWriter();
$oldWriter->delete();
}
} | php | public function moveToCdn($newCdn) {
$reader = $this->reader();
// gets the _new_ writer
$writer = $this->getCDNWriter();
// hooking it to match the current cdn path.
$writer->setId($reader->getId());
$writer->write($reader);
$this->owner->CDNFile = $writer->getContentId();
$this->owner->write();
// do the same for all versions
if ($this->owner->hasExtension('VersionedFileExtension')) {
foreach ($this->owner->Versions() as $version) {
if ($version->hasMethod('moveToCdn')) {
try {
$version->moveToCdn($newCdn);
} catch (Exception $ex) {
}
}
}
}
// delete source
$newReader = $writer->getReader();
if ($newReader->exists() && $newReader->getContentId() != $reader->getContentId()) {
$oldWriter = $reader->getWriter();
$oldWriter->delete();
}
} | [
"public",
"function",
"moveToCdn",
"(",
"$",
"newCdn",
")",
"{",
"$",
"reader",
"=",
"$",
"this",
"->",
"reader",
"(",
")",
";",
"// gets the _new_ writer",
"$",
"writer",
"=",
"$",
"this",
"->",
"getCDNWriter",
"(",
")",
";",
"// hooking it to match the current cdn path.",
"$",
"writer",
"->",
"setId",
"(",
"$",
"reader",
"->",
"getId",
"(",
")",
")",
";",
"$",
"writer",
"->",
"write",
"(",
"$",
"reader",
")",
";",
"$",
"this",
"->",
"owner",
"->",
"CDNFile",
"=",
"$",
"writer",
"->",
"getContentId",
"(",
")",
";",
"$",
"this",
"->",
"owner",
"->",
"write",
"(",
")",
";",
"// do the same for all versions",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"hasExtension",
"(",
"'VersionedFileExtension'",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"owner",
"->",
"Versions",
"(",
")",
"as",
"$",
"version",
")",
"{",
"if",
"(",
"$",
"version",
"->",
"hasMethod",
"(",
"'moveToCdn'",
")",
")",
"{",
"try",
"{",
"$",
"version",
"->",
"moveToCdn",
"(",
"$",
"newCdn",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"}",
"}",
"}",
"}",
"// delete source",
"$",
"newReader",
"=",
"$",
"writer",
"->",
"getReader",
"(",
")",
";",
"if",
"(",
"$",
"newReader",
"->",
"exists",
"(",
")",
"&&",
"$",
"newReader",
"->",
"getContentId",
"(",
")",
"!=",
"$",
"reader",
"->",
"getContentId",
"(",
")",
")",
"{",
"$",
"oldWriter",
"=",
"$",
"reader",
"->",
"getWriter",
"(",
")",
";",
"$",
"oldWriter",
"->",
"delete",
"(",
")",
";",
"}",
"}"
] | Moves this file to its same path on the named CDN
@param string $newCdn | [
"Moves",
"this",
"file",
"to",
"its",
"same",
"path",
"on",
"the",
"named",
"CDN"
] | a5f82e802e9addaf98d506cf305a621b873a5c9b | https://github.com/symbiote/silverstripe-cdncontent/blob/a5f82e802e9addaf98d506cf305a621b873a5c9b/code/extensions/CDNFile.php#L518-L550 |
32,123 | comporu/compo-core | src/Compo/Sonata/AdminBundle/Admin/BreadcrumbsBuilder.php | BreadcrumbsBuilder.createMenuItem | private function createMenuItem(
AdminInterface $admin,
ItemInterface $menu,
$name,
$translationDomain = null,
array $options = []
) {
$options = array_merge([
'extras' => [
'translation_domain' => $translationDomain,
],
], $options);
return $menu->addChild(
$admin->getLabelTranslatorStrategy()->getLabel(
$name,
'breadcrumb',
'link'
),
$options
);
} | php | private function createMenuItem(
AdminInterface $admin,
ItemInterface $menu,
$name,
$translationDomain = null,
array $options = []
) {
$options = array_merge([
'extras' => [
'translation_domain' => $translationDomain,
],
], $options);
return $menu->addChild(
$admin->getLabelTranslatorStrategy()->getLabel(
$name,
'breadcrumb',
'link'
),
$options
);
} | [
"private",
"function",
"createMenuItem",
"(",
"AdminInterface",
"$",
"admin",
",",
"ItemInterface",
"$",
"menu",
",",
"$",
"name",
",",
"$",
"translationDomain",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"array_merge",
"(",
"[",
"'extras'",
"=>",
"[",
"'translation_domain'",
"=>",
"$",
"translationDomain",
",",
"]",
",",
"]",
",",
"$",
"options",
")",
";",
"return",
"$",
"menu",
"->",
"addChild",
"(",
"$",
"admin",
"->",
"getLabelTranslatorStrategy",
"(",
")",
"->",
"getLabel",
"(",
"$",
"name",
",",
"'breadcrumb'",
",",
"'link'",
")",
",",
"$",
"options",
")",
";",
"}"
] | Creates a new menu item from a simple name. The name is normalized and
translated with the specified translation domain.
@param AdminInterface $admin used for translation
@param ItemInterface $menu will be modified and returned
@param string $name the source of the final label
@param string $translationDomain for label translation
@param array $options menu item options
@return ItemInterface | [
"Creates",
"a",
"new",
"menu",
"item",
"from",
"a",
"simple",
"name",
".",
"The",
"name",
"is",
"normalized",
"and",
"translated",
"with",
"the",
"specified",
"translation",
"domain",
"."
] | ebaa9fe8a4b831506c78fdf637da6b4deadec1e2 | https://github.com/comporu/compo-core/blob/ebaa9fe8a4b831506c78fdf637da6b4deadec1e2/src/Compo/Sonata/AdminBundle/Admin/BreadcrumbsBuilder.php#L182-L203 |
32,124 | edmondscommerce/doctrine-static-meta | src/CodeGeneration/Creation/Process/ReplaceEntityIdFieldProcess.php | ReplaceEntityIdFieldProcess.getUseStatement | private function getUseStatement(): string
{
switch ($this->idTraitFqn) {
case IdFieldTrait::class:
$useStatement = 'use DSM\Fields\Traits\PrimaryKey\IdFieldTrait;';
break;
case NonBinaryUuidFieldTrait::class:
$useStatement = 'use DSM\Fields\Traits\PrimaryKey\NonBinaryUuidFieldTrait;';
break;
case UuidFieldTrait::class:
$useStatement = 'use DSM\Fields\Traits\PrimaryKey\UuidFieldTrait;';
break;
default:
throw new \LogicException('Unknown trait selected ' . $this->idTraitFqn);
}
return $useStatement;
} | php | private function getUseStatement(): string
{
switch ($this->idTraitFqn) {
case IdFieldTrait::class:
$useStatement = 'use DSM\Fields\Traits\PrimaryKey\IdFieldTrait;';
break;
case NonBinaryUuidFieldTrait::class:
$useStatement = 'use DSM\Fields\Traits\PrimaryKey\NonBinaryUuidFieldTrait;';
break;
case UuidFieldTrait::class:
$useStatement = 'use DSM\Fields\Traits\PrimaryKey\UuidFieldTrait;';
break;
default:
throw new \LogicException('Unknown trait selected ' . $this->idTraitFqn);
}
return $useStatement;
} | [
"private",
"function",
"getUseStatement",
"(",
")",
":",
"string",
"{",
"switch",
"(",
"$",
"this",
"->",
"idTraitFqn",
")",
"{",
"case",
"IdFieldTrait",
"::",
"class",
":",
"$",
"useStatement",
"=",
"'use DSM\\Fields\\Traits\\PrimaryKey\\IdFieldTrait;'",
";",
"break",
";",
"case",
"NonBinaryUuidFieldTrait",
"::",
"class",
":",
"$",
"useStatement",
"=",
"'use DSM\\Fields\\Traits\\PrimaryKey\\NonBinaryUuidFieldTrait;'",
";",
"break",
";",
"case",
"UuidFieldTrait",
"::",
"class",
":",
"$",
"useStatement",
"=",
"'use DSM\\Fields\\Traits\\PrimaryKey\\UuidFieldTrait;'",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Unknown trait selected '",
".",
"$",
"this",
"->",
"idTraitFqn",
")",
";",
"}",
"return",
"$",
"useStatement",
";",
"}"
] | Get the use statement to replace it with
@return string | [
"Get",
"the",
"use",
"statement",
"to",
"replace",
"it",
"with"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Creation/Process/ReplaceEntityIdFieldProcess.php#L47-L64 |
32,125 | Erebot/Erebot | src/Patches.php | Patches.patch | public static function patch()
{
set_error_handler(
function ($errno, $errstr, $errfile, $errline) {
if (($errno & error_reporting()) !== $errno) {
return false;
}
throw new \Erebot\ErrorReportingException(
$errstr,
$errno,
$errfile,
$errline
);
},
E_ALL
);
// The name "glob" is already used internally as of PHP 5.3.0.
// Moreover, the wrapper returns an XML document, hence "xglob".
if (!in_array("xglob", stream_get_wrappers())) {
stream_wrapper_register('xglob', '\\Erebot\\XGlobStream', STREAM_IS_URL);
}
/* Needed to prevent libxml from trying to magically "fix" URLs
* included with XInclude as this breaks a lot of things.
* This requires libxml >= 2.6.20 (which was released in 2005). */
if (!defined('LIBXML_NOBASEFIX')) {
define('LIBXML_NOBASEFIX', 1 << 18);
}
} | php | public static function patch()
{
set_error_handler(
function ($errno, $errstr, $errfile, $errline) {
if (($errno & error_reporting()) !== $errno) {
return false;
}
throw new \Erebot\ErrorReportingException(
$errstr,
$errno,
$errfile,
$errline
);
},
E_ALL
);
// The name "glob" is already used internally as of PHP 5.3.0.
// Moreover, the wrapper returns an XML document, hence "xglob".
if (!in_array("xglob", stream_get_wrappers())) {
stream_wrapper_register('xglob', '\\Erebot\\XGlobStream', STREAM_IS_URL);
}
/* Needed to prevent libxml from trying to magically "fix" URLs
* included with XInclude as this breaks a lot of things.
* This requires libxml >= 2.6.20 (which was released in 2005). */
if (!defined('LIBXML_NOBASEFIX')) {
define('LIBXML_NOBASEFIX', 1 << 18);
}
} | [
"public",
"static",
"function",
"patch",
"(",
")",
"{",
"set_error_handler",
"(",
"function",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
"{",
"if",
"(",
"(",
"$",
"errno",
"&",
"error_reporting",
"(",
")",
")",
"!==",
"$",
"errno",
")",
"{",
"return",
"false",
";",
"}",
"throw",
"new",
"\\",
"Erebot",
"\\",
"ErrorReportingException",
"(",
"$",
"errstr",
",",
"$",
"errno",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
";",
"}",
",",
"E_ALL",
")",
";",
"// The name \"glob\" is already used internally as of PHP 5.3.0.",
"// Moreover, the wrapper returns an XML document, hence \"xglob\".",
"if",
"(",
"!",
"in_array",
"(",
"\"xglob\"",
",",
"stream_get_wrappers",
"(",
")",
")",
")",
"{",
"stream_wrapper_register",
"(",
"'xglob'",
",",
"'\\\\Erebot\\\\XGlobStream'",
",",
"STREAM_IS_URL",
")",
";",
"}",
"/* Needed to prevent libxml from trying to magically \"fix\" URLs\n * included with XInclude as this breaks a lot of things.\n * This requires libxml >= 2.6.20 (which was released in 2005). */",
"if",
"(",
"!",
"defined",
"(",
"'LIBXML_NOBASEFIX'",
")",
")",
"{",
"define",
"(",
"'LIBXML_NOBASEFIX'",
",",
"1",
"<<",
"18",
")",
";",
"}",
"}"
] | Apply a few patches to PHP.
\return
This method does not return anything. | [
"Apply",
"a",
"few",
"patches",
"to",
"PHP",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/Patches.php#L36-L66 |
32,126 | chameleon-system/chameleon-shop | src/ShopDhlPackstationBundle/pkgShop/objects/db/TShopOrderStep/TPkgShopDhlPackstation_ShopStepUserDataV2.class.php | TPkgShopDhlPackstation_ShopStepUserDataV2.ChangeShippingAddressIsPackstationState | public function ChangeShippingAddressIsPackstationState()
{
$this->SetPreventProcessStepMethodFromExecuting(true);
$bIsDhlPackstation = false;
$aShipping = $this->GetShippingAddressData();
if (is_array($aShipping) && array_key_exists('is_dhl_packstation', $aShipping)) {
$bIsDhlPackstation = ('1' == $aShipping['is_dhl_packstation']) ? (true) : (false);
}
$sShippingAdrId = '';
if (is_array($aShipping) && array_key_exists('id', $aShipping)) {
$sShippingAdrId = $aShipping['id'];
}
$oUser = TdbDataExtranetUser::GetInstance();
if (!empty($sShippingAdrId)) {
$oAdr = TdbDataExtranetUserAddress::GetNewInstance();
if ($oAdr->LoadFromFields(array('data_extranet_user_id' => $oUser->id, 'id' => $sShippingAdrId))) {
$oAdr->SetIsDhlPackstation($bIsDhlPackstation);
$this->SetShippingAddressData($oAdr->sqlData);
$oUser->GetShippingAddress(true);
}
} else {
$oAdr = TdbDataExtranetUserAddress::GetNewInstance();
$oAdr->LoadFromRowProtected($aShipping);
$oAdr->SetIsDhlPackstation($bIsDhlPackstation);
$this->SetShippingAddressData($oAdr->sqlData);
$oUser->GetShippingAddress(true, true);
}
if ($bIsDhlPackstation) {
$bChangedBillingAddress = false;
if ('0' != $this->GetShipToBillingAddress()) {
$this->SetShipToBillingAddress('0');
$bChangedBillingAddress = true;
}
// if the shipping address is also the billing address, then we need to change the billing address
$sBillingAdrId = '';
$aBilling = $this->GetBillingAddressData();
if (is_array($aBilling) && array_key_exists('id', $aBilling)) {
$sBillingAdrId = $aBilling['id'];
}
if (!empty($sBillingAdrId) && !empty($aShipping) && 0 == strcmp($sBillingAdrId, $sShippingAdrId)) {
$bChangedBillingAddress = true;
$aNewBilling = array('selectedAddressId' => $this->GetAnotherAddressFromUser($sBillingAdrId, TdbDataExtranetUserAddress::FORM_DATA_NAME_BILLING));
$this->SetBillingAddressData($aNewBilling);
}
if ($bChangedBillingAddress) {
$oMsgManager = TCMSMessageManager::GetInstance();
$oMsgManager->AddMessage(TdbDataExtranetUserAddress::FORM_DATA_NAME_BILLING, 'PkgShopDhlPackstation-ERROR-BILLING-MAY-NOT-BE-PACKSTATION');
}
}
} | php | public function ChangeShippingAddressIsPackstationState()
{
$this->SetPreventProcessStepMethodFromExecuting(true);
$bIsDhlPackstation = false;
$aShipping = $this->GetShippingAddressData();
if (is_array($aShipping) && array_key_exists('is_dhl_packstation', $aShipping)) {
$bIsDhlPackstation = ('1' == $aShipping['is_dhl_packstation']) ? (true) : (false);
}
$sShippingAdrId = '';
if (is_array($aShipping) && array_key_exists('id', $aShipping)) {
$sShippingAdrId = $aShipping['id'];
}
$oUser = TdbDataExtranetUser::GetInstance();
if (!empty($sShippingAdrId)) {
$oAdr = TdbDataExtranetUserAddress::GetNewInstance();
if ($oAdr->LoadFromFields(array('data_extranet_user_id' => $oUser->id, 'id' => $sShippingAdrId))) {
$oAdr->SetIsDhlPackstation($bIsDhlPackstation);
$this->SetShippingAddressData($oAdr->sqlData);
$oUser->GetShippingAddress(true);
}
} else {
$oAdr = TdbDataExtranetUserAddress::GetNewInstance();
$oAdr->LoadFromRowProtected($aShipping);
$oAdr->SetIsDhlPackstation($bIsDhlPackstation);
$this->SetShippingAddressData($oAdr->sqlData);
$oUser->GetShippingAddress(true, true);
}
if ($bIsDhlPackstation) {
$bChangedBillingAddress = false;
if ('0' != $this->GetShipToBillingAddress()) {
$this->SetShipToBillingAddress('0');
$bChangedBillingAddress = true;
}
// if the shipping address is also the billing address, then we need to change the billing address
$sBillingAdrId = '';
$aBilling = $this->GetBillingAddressData();
if (is_array($aBilling) && array_key_exists('id', $aBilling)) {
$sBillingAdrId = $aBilling['id'];
}
if (!empty($sBillingAdrId) && !empty($aShipping) && 0 == strcmp($sBillingAdrId, $sShippingAdrId)) {
$bChangedBillingAddress = true;
$aNewBilling = array('selectedAddressId' => $this->GetAnotherAddressFromUser($sBillingAdrId, TdbDataExtranetUserAddress::FORM_DATA_NAME_BILLING));
$this->SetBillingAddressData($aNewBilling);
}
if ($bChangedBillingAddress) {
$oMsgManager = TCMSMessageManager::GetInstance();
$oMsgManager->AddMessage(TdbDataExtranetUserAddress::FORM_DATA_NAME_BILLING, 'PkgShopDhlPackstation-ERROR-BILLING-MAY-NOT-BE-PACKSTATION');
}
}
} | [
"public",
"function",
"ChangeShippingAddressIsPackstationState",
"(",
")",
"{",
"$",
"this",
"->",
"SetPreventProcessStepMethodFromExecuting",
"(",
"true",
")",
";",
"$",
"bIsDhlPackstation",
"=",
"false",
";",
"$",
"aShipping",
"=",
"$",
"this",
"->",
"GetShippingAddressData",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"aShipping",
")",
"&&",
"array_key_exists",
"(",
"'is_dhl_packstation'",
",",
"$",
"aShipping",
")",
")",
"{",
"$",
"bIsDhlPackstation",
"=",
"(",
"'1'",
"==",
"$",
"aShipping",
"[",
"'is_dhl_packstation'",
"]",
")",
"?",
"(",
"true",
")",
":",
"(",
"false",
")",
";",
"}",
"$",
"sShippingAdrId",
"=",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"aShipping",
")",
"&&",
"array_key_exists",
"(",
"'id'",
",",
"$",
"aShipping",
")",
")",
"{",
"$",
"sShippingAdrId",
"=",
"$",
"aShipping",
"[",
"'id'",
"]",
";",
"}",
"$",
"oUser",
"=",
"TdbDataExtranetUser",
"::",
"GetInstance",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"sShippingAdrId",
")",
")",
"{",
"$",
"oAdr",
"=",
"TdbDataExtranetUserAddress",
"::",
"GetNewInstance",
"(",
")",
";",
"if",
"(",
"$",
"oAdr",
"->",
"LoadFromFields",
"(",
"array",
"(",
"'data_extranet_user_id'",
"=>",
"$",
"oUser",
"->",
"id",
",",
"'id'",
"=>",
"$",
"sShippingAdrId",
")",
")",
")",
"{",
"$",
"oAdr",
"->",
"SetIsDhlPackstation",
"(",
"$",
"bIsDhlPackstation",
")",
";",
"$",
"this",
"->",
"SetShippingAddressData",
"(",
"$",
"oAdr",
"->",
"sqlData",
")",
";",
"$",
"oUser",
"->",
"GetShippingAddress",
"(",
"true",
")",
";",
"}",
"}",
"else",
"{",
"$",
"oAdr",
"=",
"TdbDataExtranetUserAddress",
"::",
"GetNewInstance",
"(",
")",
";",
"$",
"oAdr",
"->",
"LoadFromRowProtected",
"(",
"$",
"aShipping",
")",
";",
"$",
"oAdr",
"->",
"SetIsDhlPackstation",
"(",
"$",
"bIsDhlPackstation",
")",
";",
"$",
"this",
"->",
"SetShippingAddressData",
"(",
"$",
"oAdr",
"->",
"sqlData",
")",
";",
"$",
"oUser",
"->",
"GetShippingAddress",
"(",
"true",
",",
"true",
")",
";",
"}",
"if",
"(",
"$",
"bIsDhlPackstation",
")",
"{",
"$",
"bChangedBillingAddress",
"=",
"false",
";",
"if",
"(",
"'0'",
"!=",
"$",
"this",
"->",
"GetShipToBillingAddress",
"(",
")",
")",
"{",
"$",
"this",
"->",
"SetShipToBillingAddress",
"(",
"'0'",
")",
";",
"$",
"bChangedBillingAddress",
"=",
"true",
";",
"}",
"// if the shipping address is also the billing address, then we need to change the billing address",
"$",
"sBillingAdrId",
"=",
"''",
";",
"$",
"aBilling",
"=",
"$",
"this",
"->",
"GetBillingAddressData",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"aBilling",
")",
"&&",
"array_key_exists",
"(",
"'id'",
",",
"$",
"aBilling",
")",
")",
"{",
"$",
"sBillingAdrId",
"=",
"$",
"aBilling",
"[",
"'id'",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"sBillingAdrId",
")",
"&&",
"!",
"empty",
"(",
"$",
"aShipping",
")",
"&&",
"0",
"==",
"strcmp",
"(",
"$",
"sBillingAdrId",
",",
"$",
"sShippingAdrId",
")",
")",
"{",
"$",
"bChangedBillingAddress",
"=",
"true",
";",
"$",
"aNewBilling",
"=",
"array",
"(",
"'selectedAddressId'",
"=>",
"$",
"this",
"->",
"GetAnotherAddressFromUser",
"(",
"$",
"sBillingAdrId",
",",
"TdbDataExtranetUserAddress",
"::",
"FORM_DATA_NAME_BILLING",
")",
")",
";",
"$",
"this",
"->",
"SetBillingAddressData",
"(",
"$",
"aNewBilling",
")",
";",
"}",
"if",
"(",
"$",
"bChangedBillingAddress",
")",
"{",
"$",
"oMsgManager",
"=",
"TCMSMessageManager",
"::",
"GetInstance",
"(",
")",
";",
"$",
"oMsgManager",
"->",
"AddMessage",
"(",
"TdbDataExtranetUserAddress",
"::",
"FORM_DATA_NAME_BILLING",
",",
"'PkgShopDhlPackstation-ERROR-BILLING-MAY-NOT-BE-PACKSTATION'",
")",
";",
"}",
"}",
"}"
] | switch the current shipping address from being a packstation address to a normal address and back. | [
"switch",
"the",
"current",
"shipping",
"address",
"from",
"being",
"a",
"packstation",
"address",
"to",
"a",
"normal",
"address",
"and",
"back",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopDhlPackstationBundle/pkgShop/objects/db/TShopOrderStep/TPkgShopDhlPackstation_ShopStepUserDataV2.class.php#L32-L86 |
32,127 | chameleon-system/chameleon-shop | src/ShopDhlPackstationBundle/pkgShop/objects/db/TShopOrderStep/TPkgShopDhlPackstation_ShopStepUserDataV2.class.php | TPkgShopDhlPackstation_ShopStepUserDataV2.ChangeSelectedAddress | public function ChangeSelectedAddress()
{
$oUser = self::getExtranetUserProvider()->getActiveUser();
if ($oUser->IsLoggedIn()) {
$newShippingAddressId = $this->GetShippingAddressData('selectedAddressId');
$newBillingAddressId = $this->GetBillingAddressData('selectedAddressId');
if ('new' !== $newShippingAddressId) {
$this->updateStepAddressDataForAddressId($newShippingAddressId, $newBillingAddressId);
if ($newShippingAddressId === $newBillingAddressId &&
true === $this->isShipToBillingAddressAndBillingAddressIsPackstation()
) {
$this->SetShipToBillingAddress('0');
$newBillingAddress = $oUser->GetBillingAddress();
$this->SetBillingAddressData($newBillingAddress->sqlData);
$this->getFlashMessageService()->addMessage(
TdbDataExtranetUserAddress::FORM_DATA_NAME_BILLING,
'PkgShopDhlPackstation-ERROR-BILLING-MAY-NOT-BE-PACKSTATION'
);
}
}
}
parent::ChangeSelectedAddress();
} | php | public function ChangeSelectedAddress()
{
$oUser = self::getExtranetUserProvider()->getActiveUser();
if ($oUser->IsLoggedIn()) {
$newShippingAddressId = $this->GetShippingAddressData('selectedAddressId');
$newBillingAddressId = $this->GetBillingAddressData('selectedAddressId');
if ('new' !== $newShippingAddressId) {
$this->updateStepAddressDataForAddressId($newShippingAddressId, $newBillingAddressId);
if ($newShippingAddressId === $newBillingAddressId &&
true === $this->isShipToBillingAddressAndBillingAddressIsPackstation()
) {
$this->SetShipToBillingAddress('0');
$newBillingAddress = $oUser->GetBillingAddress();
$this->SetBillingAddressData($newBillingAddress->sqlData);
$this->getFlashMessageService()->addMessage(
TdbDataExtranetUserAddress::FORM_DATA_NAME_BILLING,
'PkgShopDhlPackstation-ERROR-BILLING-MAY-NOT-BE-PACKSTATION'
);
}
}
}
parent::ChangeSelectedAddress();
} | [
"public",
"function",
"ChangeSelectedAddress",
"(",
")",
"{",
"$",
"oUser",
"=",
"self",
"::",
"getExtranetUserProvider",
"(",
")",
"->",
"getActiveUser",
"(",
")",
";",
"if",
"(",
"$",
"oUser",
"->",
"IsLoggedIn",
"(",
")",
")",
"{",
"$",
"newShippingAddressId",
"=",
"$",
"this",
"->",
"GetShippingAddressData",
"(",
"'selectedAddressId'",
")",
";",
"$",
"newBillingAddressId",
"=",
"$",
"this",
"->",
"GetBillingAddressData",
"(",
"'selectedAddressId'",
")",
";",
"if",
"(",
"'new'",
"!==",
"$",
"newShippingAddressId",
")",
"{",
"$",
"this",
"->",
"updateStepAddressDataForAddressId",
"(",
"$",
"newShippingAddressId",
",",
"$",
"newBillingAddressId",
")",
";",
"if",
"(",
"$",
"newShippingAddressId",
"===",
"$",
"newBillingAddressId",
"&&",
"true",
"===",
"$",
"this",
"->",
"isShipToBillingAddressAndBillingAddressIsPackstation",
"(",
")",
")",
"{",
"$",
"this",
"->",
"SetShipToBillingAddress",
"(",
"'0'",
")",
";",
"$",
"newBillingAddress",
"=",
"$",
"oUser",
"->",
"GetBillingAddress",
"(",
")",
";",
"$",
"this",
"->",
"SetBillingAddressData",
"(",
"$",
"newBillingAddress",
"->",
"sqlData",
")",
";",
"$",
"this",
"->",
"getFlashMessageService",
"(",
")",
"->",
"addMessage",
"(",
"TdbDataExtranetUserAddress",
"::",
"FORM_DATA_NAME_BILLING",
",",
"'PkgShopDhlPackstation-ERROR-BILLING-MAY-NOT-BE-PACKSTATION'",
")",
";",
"}",
"}",
"}",
"parent",
"::",
"ChangeSelectedAddress",
"(",
")",
";",
"}"
] | Set correct billing address if new selected shipping address is packstation.
{@inheritdoc} | [
"Set",
"correct",
"billing",
"address",
"if",
"new",
"selected",
"shipping",
"address",
"is",
"packstation",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopDhlPackstationBundle/pkgShop/objects/db/TShopOrderStep/TPkgShopDhlPackstation_ShopStepUserDataV2.class.php#L179-L202 |
32,128 | chameleon-system/chameleon-shop | src/ShopDhlPackstationBundle/pkgShop/objects/db/TShopOrderStep/TPkgShopDhlPackstation_ShopStepUserDataV2.class.php | TPkgShopDhlPackstation_ShopStepUserDataV2.updateStepAddressDataForAddressId | private function updateStepAddressDataForAddressId($newShippingAddressId, $newBillingAddressId)
{
$newBillingAddress = TdbDataExtranetUserAddress::GetNewInstance();
if (true === $newBillingAddress->Load($newBillingAddressId)) {
$this->SetBillingAddressData($newBillingAddress->sqlData);
}
if ($newShippingAddressId === $newBillingAddressId) {
$this->SetShippingAddressData($newBillingAddress->sqlData);
} else {
$newShippingAddress = TdbDataExtranetUserAddress::GetNewInstance();
if (true === $newShippingAddress->Load($newShippingAddressId)) {
$this->SetShippingAddressData($newShippingAddress->sqlData);
}
}
} | php | private function updateStepAddressDataForAddressId($newShippingAddressId, $newBillingAddressId)
{
$newBillingAddress = TdbDataExtranetUserAddress::GetNewInstance();
if (true === $newBillingAddress->Load($newBillingAddressId)) {
$this->SetBillingAddressData($newBillingAddress->sqlData);
}
if ($newShippingAddressId === $newBillingAddressId) {
$this->SetShippingAddressData($newBillingAddress->sqlData);
} else {
$newShippingAddress = TdbDataExtranetUserAddress::GetNewInstance();
if (true === $newShippingAddress->Load($newShippingAddressId)) {
$this->SetShippingAddressData($newShippingAddress->sqlData);
}
}
} | [
"private",
"function",
"updateStepAddressDataForAddressId",
"(",
"$",
"newShippingAddressId",
",",
"$",
"newBillingAddressId",
")",
"{",
"$",
"newBillingAddress",
"=",
"TdbDataExtranetUserAddress",
"::",
"GetNewInstance",
"(",
")",
";",
"if",
"(",
"true",
"===",
"$",
"newBillingAddress",
"->",
"Load",
"(",
"$",
"newBillingAddressId",
")",
")",
"{",
"$",
"this",
"->",
"SetBillingAddressData",
"(",
"$",
"newBillingAddress",
"->",
"sqlData",
")",
";",
"}",
"if",
"(",
"$",
"newShippingAddressId",
"===",
"$",
"newBillingAddressId",
")",
"{",
"$",
"this",
"->",
"SetShippingAddressData",
"(",
"$",
"newBillingAddress",
"->",
"sqlData",
")",
";",
"}",
"else",
"{",
"$",
"newShippingAddress",
"=",
"TdbDataExtranetUserAddress",
"::",
"GetNewInstance",
"(",
")",
";",
"if",
"(",
"true",
"===",
"$",
"newShippingAddress",
"->",
"Load",
"(",
"$",
"newShippingAddressId",
")",
")",
"{",
"$",
"this",
"->",
"SetShippingAddressData",
"(",
"$",
"newShippingAddress",
"->",
"sqlData",
")",
";",
"}",
"}",
"}"
] | Loads given addresses and updates step address data.
Needed for address selection to load the new selected address.
@param string $newShippingAddressId
@param string $newBillingAddressId | [
"Loads",
"given",
"addresses",
"and",
"updates",
"step",
"address",
"data",
".",
"Needed",
"for",
"address",
"selection",
"to",
"load",
"the",
"new",
"selected",
"address",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopDhlPackstationBundle/pkgShop/objects/db/TShopOrderStep/TPkgShopDhlPackstation_ShopStepUserDataV2.class.php#L220-L234 |
32,129 | Firesphere/silverstripe-bootstrapmfa | src/Handlers/BootstrapMFALoginHandler.php | BootstrapMFALoginHandler.doLogin | public function doLogin($data, MemberLoginForm $form, HTTPRequest $request)
{
/**
* @var ValidationResult $message
* @var Member|MemberExtension $member
*/
$member = $this->checkLogin($data, $request, $message);
if (!$member) {
return $this->redirectBack();
}
// If we're in grace period, continue to the parent
if ($member->isInGracePeriod()) {
return parent::doLogin($data, $form, $request);
}
if ($message->isValid()) {
/** @var Session $session */
$session = $request->getSession();
$session->set(BootstrapMFAAuthenticator::SESSION_KEY . '.MemberID', $member->ID);
$session->set(BootstrapMFAAuthenticator::SESSION_KEY . '.Data', $data);
if (!empty($data['BackURL'])) {
$session->set(BootstrapMFAAuthenticator::SESSION_KEY . '.BackURL', $data['BackURL']);
}
return $this->redirect($this->link('verify'));
}
return $this->redirectBack();
} | php | public function doLogin($data, MemberLoginForm $form, HTTPRequest $request)
{
/**
* @var ValidationResult $message
* @var Member|MemberExtension $member
*/
$member = $this->checkLogin($data, $request, $message);
if (!$member) {
return $this->redirectBack();
}
// If we're in grace period, continue to the parent
if ($member->isInGracePeriod()) {
return parent::doLogin($data, $form, $request);
}
if ($message->isValid()) {
/** @var Session $session */
$session = $request->getSession();
$session->set(BootstrapMFAAuthenticator::SESSION_KEY . '.MemberID', $member->ID);
$session->set(BootstrapMFAAuthenticator::SESSION_KEY . '.Data', $data);
if (!empty($data['BackURL'])) {
$session->set(BootstrapMFAAuthenticator::SESSION_KEY . '.BackURL', $data['BackURL']);
}
return $this->redirect($this->link('verify'));
}
return $this->redirectBack();
} | [
"public",
"function",
"doLogin",
"(",
"$",
"data",
",",
"MemberLoginForm",
"$",
"form",
",",
"HTTPRequest",
"$",
"request",
")",
"{",
"/**\n * @var ValidationResult $message\n * @var Member|MemberExtension $member\n */",
"$",
"member",
"=",
"$",
"this",
"->",
"checkLogin",
"(",
"$",
"data",
",",
"$",
"request",
",",
"$",
"message",
")",
";",
"if",
"(",
"!",
"$",
"member",
")",
"{",
"return",
"$",
"this",
"->",
"redirectBack",
"(",
")",
";",
"}",
"// If we're in grace period, continue to the parent",
"if",
"(",
"$",
"member",
"->",
"isInGracePeriod",
"(",
")",
")",
"{",
"return",
"parent",
"::",
"doLogin",
"(",
"$",
"data",
",",
"$",
"form",
",",
"$",
"request",
")",
";",
"}",
"if",
"(",
"$",
"message",
"->",
"isValid",
"(",
")",
")",
"{",
"/** @var Session $session */",
"$",
"session",
"=",
"$",
"request",
"->",
"getSession",
"(",
")",
";",
"$",
"session",
"->",
"set",
"(",
"BootstrapMFAAuthenticator",
"::",
"SESSION_KEY",
".",
"'.MemberID'",
",",
"$",
"member",
"->",
"ID",
")",
";",
"$",
"session",
"->",
"set",
"(",
"BootstrapMFAAuthenticator",
"::",
"SESSION_KEY",
".",
"'.Data'",
",",
"$",
"data",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"'BackURL'",
"]",
")",
")",
"{",
"$",
"session",
"->",
"set",
"(",
"BootstrapMFAAuthenticator",
"::",
"SESSION_KEY",
".",
"'.BackURL'",
",",
"$",
"data",
"[",
"'BackURL'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"link",
"(",
"'verify'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirectBack",
"(",
")",
";",
"}"
] | Override the doLogin method to do our own work here
@param array $data
@param MemberLoginForm $form
@param HTTPRequest $request
@return HTTPResponse | [
"Override",
"the",
"doLogin",
"method",
"to",
"do",
"our",
"own",
"work",
"here"
] | 8d2d6c6f2f918c8fa157da91550b897816495a4b | https://github.com/Firesphere/silverstripe-bootstrapmfa/blob/8d2d6c6f2f918c8fa157da91550b897816495a4b/src/Handlers/BootstrapMFALoginHandler.php#L91-L121 |
32,130 | Firesphere/silverstripe-bootstrapmfa | src/Handlers/BootstrapMFALoginHandler.php | BootstrapMFALoginHandler.secondFactor | public function secondFactor(HTTPRequest $request)
{
$memberID = $request->getSession()->get(BootstrapMFAAuthenticator::SESSION_KEY . '.MemberID');
/** @var Member|MemberExtension $member */
$member = Member::get()->byID($memberID);
if (!$member) {
// Assume the session has gone state...
return $this->redirectBack();
}
$primary = $member->PrimaryMFA;
$formList = $this->getFormList();
$view = ArrayData::create(['Forms' => ArrayList::create($formList)]);
$rendered = [
'Forms' => $formList,
'Form' => $view->renderWith(self::class . '_MFAForms'),
'Primary' => $primary
];
$this->extend('onBeforeSecondFactor', $rendered, $view);
return $rendered;
} | php | public function secondFactor(HTTPRequest $request)
{
$memberID = $request->getSession()->get(BootstrapMFAAuthenticator::SESSION_KEY . '.MemberID');
/** @var Member|MemberExtension $member */
$member = Member::get()->byID($memberID);
if (!$member) {
// Assume the session has gone state...
return $this->redirectBack();
}
$primary = $member->PrimaryMFA;
$formList = $this->getFormList();
$view = ArrayData::create(['Forms' => ArrayList::create($formList)]);
$rendered = [
'Forms' => $formList,
'Form' => $view->renderWith(self::class . '_MFAForms'),
'Primary' => $primary
];
$this->extend('onBeforeSecondFactor', $rendered, $view);
return $rendered;
} | [
"public",
"function",
"secondFactor",
"(",
"HTTPRequest",
"$",
"request",
")",
"{",
"$",
"memberID",
"=",
"$",
"request",
"->",
"getSession",
"(",
")",
"->",
"get",
"(",
"BootstrapMFAAuthenticator",
"::",
"SESSION_KEY",
".",
"'.MemberID'",
")",
";",
"/** @var Member|MemberExtension $member */",
"$",
"member",
"=",
"Member",
"::",
"get",
"(",
")",
"->",
"byID",
"(",
"$",
"memberID",
")",
";",
"if",
"(",
"!",
"$",
"member",
")",
"{",
"// Assume the session has gone state...",
"return",
"$",
"this",
"->",
"redirectBack",
"(",
")",
";",
"}",
"$",
"primary",
"=",
"$",
"member",
"->",
"PrimaryMFA",
";",
"$",
"formList",
"=",
"$",
"this",
"->",
"getFormList",
"(",
")",
";",
"$",
"view",
"=",
"ArrayData",
"::",
"create",
"(",
"[",
"'Forms'",
"=>",
"ArrayList",
"::",
"create",
"(",
"$",
"formList",
")",
"]",
")",
";",
"$",
"rendered",
"=",
"[",
"'Forms'",
"=>",
"$",
"formList",
",",
"'Form'",
"=>",
"$",
"view",
"->",
"renderWith",
"(",
"self",
"::",
"class",
".",
"'_MFAForms'",
")",
",",
"'Primary'",
"=>",
"$",
"primary",
"]",
";",
"$",
"this",
"->",
"extend",
"(",
"'onBeforeSecondFactor'",
",",
"$",
"rendered",
",",
"$",
"view",
")",
";",
"return",
"$",
"rendered",
";",
"}"
] | Render the second factor forms for displaying at the frontend
@param HTTPRequest $request
@return array
@throws \Exception | [
"Render",
"the",
"second",
"factor",
"forms",
"for",
"displaying",
"at",
"the",
"frontend"
] | 8d2d6c6f2f918c8fa157da91550b897816495a4b | https://github.com/Firesphere/silverstripe-bootstrapmfa/blob/8d2d6c6f2f918c8fa157da91550b897816495a4b/src/Handlers/BootstrapMFALoginHandler.php#L130-L154 |
32,131 | Firesphere/silverstripe-bootstrapmfa | src/Handlers/BootstrapMFALoginHandler.php | BootstrapMFALoginHandler.getFormList | protected function getFormList()
{
$formList = [];
foreach ($this->availableAuthenticators as $key => $className) {
/** @var BootstrapMFAAuthenticator $class */
$class = Injector::inst()->get($className);
$formList[] = $class->getMFAForm($this, static::VERIFICATION_METHOD);
}
return $formList;
} | php | protected function getFormList()
{
$formList = [];
foreach ($this->availableAuthenticators as $key => $className) {
/** @var BootstrapMFAAuthenticator $class */
$class = Injector::inst()->get($className);
$formList[] = $class->getMFAForm($this, static::VERIFICATION_METHOD);
}
return $formList;
} | [
"protected",
"function",
"getFormList",
"(",
")",
"{",
"$",
"formList",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"availableAuthenticators",
"as",
"$",
"key",
"=>",
"$",
"className",
")",
"{",
"/** @var BootstrapMFAAuthenticator $class */",
"$",
"class",
"=",
"Injector",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"$",
"className",
")",
";",
"$",
"formList",
"[",
"]",
"=",
"$",
"class",
"->",
"getMFAForm",
"(",
"$",
"this",
",",
"static",
"::",
"VERIFICATION_METHOD",
")",
";",
"}",
"return",
"$",
"formList",
";",
"}"
] | Get all MFA forms from the enabled authenticators
@return array | [
"Get",
"all",
"MFA",
"forms",
"from",
"the",
"enabled",
"authenticators"
] | 8d2d6c6f2f918c8fa157da91550b897816495a4b | https://github.com/Firesphere/silverstripe-bootstrapmfa/blob/8d2d6c6f2f918c8fa157da91550b897816495a4b/src/Handlers/BootstrapMFALoginHandler.php#L161-L171 |
32,132 | chameleon-system/chameleon-shop | src/ShopArticlePreorderBundle/objects/db/TPkgShopArticlePreorder.class.php | TPkgShopArticlePreorder.SendMail | public function SendMail($oArticle = null, $sEmail = '')
{
// ------------------------------------------------------------------------
static $aPortals = array();
if (null === $oArticle) {
$oArticle = $this->GetFieldShopArticle();
}
if ('' === $sEmail) {
$sEmail = $this->fieldPreorderUserEmail;
}
if (!is_null($oArticle) && !empty($sEmail)) {
$oMail = TdbDataMailProfile::GetProfile('preorder-available');
$sArticleDetailLink = $oArticle->GetDetailLink(true);
if (!array_key_exists($this->fieldCmsPortalId, $aPortals)) {
$oCMSPortal = TdbCmsPortal::GetNewInstance();
if ($oCMSPortal->Load($this->fieldCmsPortalId)) {
$aPortals[$this->fieldCmsPortalId] = $oCMSPortal;
}
}
$sArticleBasketLink = '';
if (array_key_exists($this->fieldCmsPortalId, $aPortals)) {
$sArticleBasketLink = 'http://'.$aPortals[$this->fieldCmsPortalId]->GetPrimaryDomain().'/'.TdbShopArticle::URL_EXTERNAL_TO_BASKET_REQUEST.'/id/'.urlencode($oArticle->id);
}
$oMail->AddData('sUserEmail', $sEmail);
$oMail->AddData('sArticleName', $oArticle->GetName());
$oMail->AddData('sArticleDetailLink', $sArticleDetailLink);
$oMail->AddData('sArticleBasketLink', $sArticleBasketLink);
$oMail->ChangeToAddress($sEmail);
$oMail->SendUsingObjectView('emails', 'Customer');
$this->AllowEditByAll(true);
$this->Delete();
$this->AllowEditByAll(false);
return true;
} else {
return false;
}
} | php | public function SendMail($oArticle = null, $sEmail = '')
{
// ------------------------------------------------------------------------
static $aPortals = array();
if (null === $oArticle) {
$oArticle = $this->GetFieldShopArticle();
}
if ('' === $sEmail) {
$sEmail = $this->fieldPreorderUserEmail;
}
if (!is_null($oArticle) && !empty($sEmail)) {
$oMail = TdbDataMailProfile::GetProfile('preorder-available');
$sArticleDetailLink = $oArticle->GetDetailLink(true);
if (!array_key_exists($this->fieldCmsPortalId, $aPortals)) {
$oCMSPortal = TdbCmsPortal::GetNewInstance();
if ($oCMSPortal->Load($this->fieldCmsPortalId)) {
$aPortals[$this->fieldCmsPortalId] = $oCMSPortal;
}
}
$sArticleBasketLink = '';
if (array_key_exists($this->fieldCmsPortalId, $aPortals)) {
$sArticleBasketLink = 'http://'.$aPortals[$this->fieldCmsPortalId]->GetPrimaryDomain().'/'.TdbShopArticle::URL_EXTERNAL_TO_BASKET_REQUEST.'/id/'.urlencode($oArticle->id);
}
$oMail->AddData('sUserEmail', $sEmail);
$oMail->AddData('sArticleName', $oArticle->GetName());
$oMail->AddData('sArticleDetailLink', $sArticleDetailLink);
$oMail->AddData('sArticleBasketLink', $sArticleBasketLink);
$oMail->ChangeToAddress($sEmail);
$oMail->SendUsingObjectView('emails', 'Customer');
$this->AllowEditByAll(true);
$this->Delete();
$this->AllowEditByAll(false);
return true;
} else {
return false;
}
} | [
"public",
"function",
"SendMail",
"(",
"$",
"oArticle",
"=",
"null",
",",
"$",
"sEmail",
"=",
"''",
")",
"{",
"// ------------------------------------------------------------------------",
"static",
"$",
"aPortals",
"=",
"array",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"oArticle",
")",
"{",
"$",
"oArticle",
"=",
"$",
"this",
"->",
"GetFieldShopArticle",
"(",
")",
";",
"}",
"if",
"(",
"''",
"===",
"$",
"sEmail",
")",
"{",
"$",
"sEmail",
"=",
"$",
"this",
"->",
"fieldPreorderUserEmail",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"oArticle",
")",
"&&",
"!",
"empty",
"(",
"$",
"sEmail",
")",
")",
"{",
"$",
"oMail",
"=",
"TdbDataMailProfile",
"::",
"GetProfile",
"(",
"'preorder-available'",
")",
";",
"$",
"sArticleDetailLink",
"=",
"$",
"oArticle",
"->",
"GetDetailLink",
"(",
"true",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"this",
"->",
"fieldCmsPortalId",
",",
"$",
"aPortals",
")",
")",
"{",
"$",
"oCMSPortal",
"=",
"TdbCmsPortal",
"::",
"GetNewInstance",
"(",
")",
";",
"if",
"(",
"$",
"oCMSPortal",
"->",
"Load",
"(",
"$",
"this",
"->",
"fieldCmsPortalId",
")",
")",
"{",
"$",
"aPortals",
"[",
"$",
"this",
"->",
"fieldCmsPortalId",
"]",
"=",
"$",
"oCMSPortal",
";",
"}",
"}",
"$",
"sArticleBasketLink",
"=",
"''",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"this",
"->",
"fieldCmsPortalId",
",",
"$",
"aPortals",
")",
")",
"{",
"$",
"sArticleBasketLink",
"=",
"'http://'",
".",
"$",
"aPortals",
"[",
"$",
"this",
"->",
"fieldCmsPortalId",
"]",
"->",
"GetPrimaryDomain",
"(",
")",
".",
"'/'",
".",
"TdbShopArticle",
"::",
"URL_EXTERNAL_TO_BASKET_REQUEST",
".",
"'/id/'",
".",
"urlencode",
"(",
"$",
"oArticle",
"->",
"id",
")",
";",
"}",
"$",
"oMail",
"->",
"AddData",
"(",
"'sUserEmail'",
",",
"$",
"sEmail",
")",
";",
"$",
"oMail",
"->",
"AddData",
"(",
"'sArticleName'",
",",
"$",
"oArticle",
"->",
"GetName",
"(",
")",
")",
";",
"$",
"oMail",
"->",
"AddData",
"(",
"'sArticleDetailLink'",
",",
"$",
"sArticleDetailLink",
")",
";",
"$",
"oMail",
"->",
"AddData",
"(",
"'sArticleBasketLink'",
",",
"$",
"sArticleBasketLink",
")",
";",
"$",
"oMail",
"->",
"ChangeToAddress",
"(",
"$",
"sEmail",
")",
";",
"$",
"oMail",
"->",
"SendUsingObjectView",
"(",
"'emails'",
",",
"'Customer'",
")",
";",
"$",
"this",
"->",
"AllowEditByAll",
"(",
"true",
")",
";",
"$",
"this",
"->",
"Delete",
"(",
")",
";",
"$",
"this",
"->",
"AllowEditByAll",
"(",
"false",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | send email to users email for the given article.
@param TShopArticle $oArticle
@param string $sEmail
@return bool | [
"send",
"email",
"to",
"users",
"email",
"for",
"the",
"given",
"article",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopArticlePreorderBundle/objects/db/TPkgShopArticlePreorder.class.php#L24-L66 |
32,133 | chameleon-system/chameleon-shop | src/ShopArticlePreorderBundle/objects/db/TPkgShopArticlePreorder.class.php | TPkgShopArticlePreorder.SaveNewPreorder | public function SaveNewPreorder($sArticleId = '')
{
// ------------------------------------------------------------------------
$oGlobal = TGlobal::instance();
$oMsgManager = TCMSMessageManager::GetInstance();
if ($oGlobal->userDataExists('eMail') && TTools::IsValidEMail($oGlobal->GetuserData('eMail')) && !$oShopArticlePreorder = TdbShopArticlePreorder::LoadFromFields(array('shop_article_id' => $sArticleId, 'preorder_user_email' => $oGlobal->GetuserData('eMail')))) {
$activePortal = $this->getPortalDomainService()->getActivePortal();
$aPostData = array('shop_article_id' => $sArticleId, 'preorder_user_email' => $oGlobal->GetuserData('eMail'), 'preorder_date' => date('Y-m-d H:i:s'), 'cms_portal_id' => $activePortal->id);
$this->LoadFromRow($aPostData);
$this->AllowEditByAll(true);
$this->Save();
$this->AllowEditByAll(false);
$oMsgManager->AddMessage('mail-preorder-form-eMail', 'SUCCESS-USER-SIGNUP-PREORDER-ARTICLE');
return true;
} else {
if (!TTools::IsValidEMail($oGlobal->GetuserData('eMail'))) {
$oMsgManager->AddMessage('mail-preorder-form-eMail', 'ERROR-E-MAIL-INVALID-INPUT');
return false;
} else {
if ($oShopArticlePreorder = TdbShopArticlePreorder::LoadFromFields(array('shop_article_id' => $sArticleId, 'preorder_user_email' => $oGlobal->GetuserData('eMail')))) {
$oMsgManager->AddMessage('mail-preorder-form-eMail', 'ERROR-USER-SIGNUP-PREORDER-ARTICLE');
return false;
} else {
return false;
}
}
}
} | php | public function SaveNewPreorder($sArticleId = '')
{
// ------------------------------------------------------------------------
$oGlobal = TGlobal::instance();
$oMsgManager = TCMSMessageManager::GetInstance();
if ($oGlobal->userDataExists('eMail') && TTools::IsValidEMail($oGlobal->GetuserData('eMail')) && !$oShopArticlePreorder = TdbShopArticlePreorder::LoadFromFields(array('shop_article_id' => $sArticleId, 'preorder_user_email' => $oGlobal->GetuserData('eMail')))) {
$activePortal = $this->getPortalDomainService()->getActivePortal();
$aPostData = array('shop_article_id' => $sArticleId, 'preorder_user_email' => $oGlobal->GetuserData('eMail'), 'preorder_date' => date('Y-m-d H:i:s'), 'cms_portal_id' => $activePortal->id);
$this->LoadFromRow($aPostData);
$this->AllowEditByAll(true);
$this->Save();
$this->AllowEditByAll(false);
$oMsgManager->AddMessage('mail-preorder-form-eMail', 'SUCCESS-USER-SIGNUP-PREORDER-ARTICLE');
return true;
} else {
if (!TTools::IsValidEMail($oGlobal->GetuserData('eMail'))) {
$oMsgManager->AddMessage('mail-preorder-form-eMail', 'ERROR-E-MAIL-INVALID-INPUT');
return false;
} else {
if ($oShopArticlePreorder = TdbShopArticlePreorder::LoadFromFields(array('shop_article_id' => $sArticleId, 'preorder_user_email' => $oGlobal->GetuserData('eMail')))) {
$oMsgManager->AddMessage('mail-preorder-form-eMail', 'ERROR-USER-SIGNUP-PREORDER-ARTICLE');
return false;
} else {
return false;
}
}
}
} | [
"public",
"function",
"SaveNewPreorder",
"(",
"$",
"sArticleId",
"=",
"''",
")",
"{",
"// ------------------------------------------------------------------------",
"$",
"oGlobal",
"=",
"TGlobal",
"::",
"instance",
"(",
")",
";",
"$",
"oMsgManager",
"=",
"TCMSMessageManager",
"::",
"GetInstance",
"(",
")",
";",
"if",
"(",
"$",
"oGlobal",
"->",
"userDataExists",
"(",
"'eMail'",
")",
"&&",
"TTools",
"::",
"IsValidEMail",
"(",
"$",
"oGlobal",
"->",
"GetuserData",
"(",
"'eMail'",
")",
")",
"&&",
"!",
"$",
"oShopArticlePreorder",
"=",
"TdbShopArticlePreorder",
"::",
"LoadFromFields",
"(",
"array",
"(",
"'shop_article_id'",
"=>",
"$",
"sArticleId",
",",
"'preorder_user_email'",
"=>",
"$",
"oGlobal",
"->",
"GetuserData",
"(",
"'eMail'",
")",
")",
")",
")",
"{",
"$",
"activePortal",
"=",
"$",
"this",
"->",
"getPortalDomainService",
"(",
")",
"->",
"getActivePortal",
"(",
")",
";",
"$",
"aPostData",
"=",
"array",
"(",
"'shop_article_id'",
"=>",
"$",
"sArticleId",
",",
"'preorder_user_email'",
"=>",
"$",
"oGlobal",
"->",
"GetuserData",
"(",
"'eMail'",
")",
",",
"'preorder_date'",
"=>",
"date",
"(",
"'Y-m-d H:i:s'",
")",
",",
"'cms_portal_id'",
"=>",
"$",
"activePortal",
"->",
"id",
")",
";",
"$",
"this",
"->",
"LoadFromRow",
"(",
"$",
"aPostData",
")",
";",
"$",
"this",
"->",
"AllowEditByAll",
"(",
"true",
")",
";",
"$",
"this",
"->",
"Save",
"(",
")",
";",
"$",
"this",
"->",
"AllowEditByAll",
"(",
"false",
")",
";",
"$",
"oMsgManager",
"->",
"AddMessage",
"(",
"'mail-preorder-form-eMail'",
",",
"'SUCCESS-USER-SIGNUP-PREORDER-ARTICLE'",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"TTools",
"::",
"IsValidEMail",
"(",
"$",
"oGlobal",
"->",
"GetuserData",
"(",
"'eMail'",
")",
")",
")",
"{",
"$",
"oMsgManager",
"->",
"AddMessage",
"(",
"'mail-preorder-form-eMail'",
",",
"'ERROR-E-MAIL-INVALID-INPUT'",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"oShopArticlePreorder",
"=",
"TdbShopArticlePreorder",
"::",
"LoadFromFields",
"(",
"array",
"(",
"'shop_article_id'",
"=>",
"$",
"sArticleId",
",",
"'preorder_user_email'",
"=>",
"$",
"oGlobal",
"->",
"GetuserData",
"(",
"'eMail'",
")",
")",
")",
")",
"{",
"$",
"oMsgManager",
"->",
"AddMessage",
"(",
"'mail-preorder-form-eMail'",
",",
"'ERROR-USER-SIGNUP-PREORDER-ARTICLE'",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"}"
] | save new preorder to the DB.
@param string $sArticleId
@return bool | [
"save",
"new",
"preorder",
"to",
"the",
"DB",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopArticlePreorderBundle/objects/db/TPkgShopArticlePreorder.class.php#L79-L109 |
32,134 | chameleon-system/chameleon-shop | src/ShopDhlPackstationBundle/pkgExtranet/objects/WebModules/MTExtranet_PkgShopDhlPackstation.class.php | MTExtranet_PkgShopDhlPackstation.UpdateShippingAddress | protected function UpdateShippingAddress($aAddress)
{
$oUser = TdbDataExtranetUser::GetInstance();
if ($oUser->DHLPackStationStatusChanged($aAddress)) {
$aAddress = $oUser->fillPackStationFieldValue($aAddress);
if (true === $this->isAddressBillingAddress($aAddress, $oUser) &&
true === $this->isAddressPackstation($aAddress)
) {
$this->getFlashMessage()->addMessage(
TdbDataExtranetUserAddress::FORM_DATA_NAME_SHIPPING,
'PkgShopDhlPackstation-ERROR-SHIPPING-IS-BILLING-MAY-NOT-BE-PACKSTATION'
);
return false;
}
$bUpdateOk = $oUser->UpdateShippingAddress($aAddress);
$oShippingAddress = $oUser->GetShippingAddress();
if ($oShippingAddress) {
$bUpdateOk = $oShippingAddress->ValidateData(TdbDataExtranetUserAddress::FORM_DATA_NAME_SHIPPING);
}
} else {
$bUpdateOk = parent::UpdateShippingAddress($aAddress);
}
return $bUpdateOk;
} | php | protected function UpdateShippingAddress($aAddress)
{
$oUser = TdbDataExtranetUser::GetInstance();
if ($oUser->DHLPackStationStatusChanged($aAddress)) {
$aAddress = $oUser->fillPackStationFieldValue($aAddress);
if (true === $this->isAddressBillingAddress($aAddress, $oUser) &&
true === $this->isAddressPackstation($aAddress)
) {
$this->getFlashMessage()->addMessage(
TdbDataExtranetUserAddress::FORM_DATA_NAME_SHIPPING,
'PkgShopDhlPackstation-ERROR-SHIPPING-IS-BILLING-MAY-NOT-BE-PACKSTATION'
);
return false;
}
$bUpdateOk = $oUser->UpdateShippingAddress($aAddress);
$oShippingAddress = $oUser->GetShippingAddress();
if ($oShippingAddress) {
$bUpdateOk = $oShippingAddress->ValidateData(TdbDataExtranetUserAddress::FORM_DATA_NAME_SHIPPING);
}
} else {
$bUpdateOk = parent::UpdateShippingAddress($aAddress);
}
return $bUpdateOk;
} | [
"protected",
"function",
"UpdateShippingAddress",
"(",
"$",
"aAddress",
")",
"{",
"$",
"oUser",
"=",
"TdbDataExtranetUser",
"::",
"GetInstance",
"(",
")",
";",
"if",
"(",
"$",
"oUser",
"->",
"DHLPackStationStatusChanged",
"(",
"$",
"aAddress",
")",
")",
"{",
"$",
"aAddress",
"=",
"$",
"oUser",
"->",
"fillPackStationFieldValue",
"(",
"$",
"aAddress",
")",
";",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"isAddressBillingAddress",
"(",
"$",
"aAddress",
",",
"$",
"oUser",
")",
"&&",
"true",
"===",
"$",
"this",
"->",
"isAddressPackstation",
"(",
"$",
"aAddress",
")",
")",
"{",
"$",
"this",
"->",
"getFlashMessage",
"(",
")",
"->",
"addMessage",
"(",
"TdbDataExtranetUserAddress",
"::",
"FORM_DATA_NAME_SHIPPING",
",",
"'PkgShopDhlPackstation-ERROR-SHIPPING-IS-BILLING-MAY-NOT-BE-PACKSTATION'",
")",
";",
"return",
"false",
";",
"}",
"$",
"bUpdateOk",
"=",
"$",
"oUser",
"->",
"UpdateShippingAddress",
"(",
"$",
"aAddress",
")",
";",
"$",
"oShippingAddress",
"=",
"$",
"oUser",
"->",
"GetShippingAddress",
"(",
")",
";",
"if",
"(",
"$",
"oShippingAddress",
")",
"{",
"$",
"bUpdateOk",
"=",
"$",
"oShippingAddress",
"->",
"ValidateData",
"(",
"TdbDataExtranetUserAddress",
"::",
"FORM_DATA_NAME_SHIPPING",
")",
";",
"}",
"}",
"else",
"{",
"$",
"bUpdateOk",
"=",
"parent",
"::",
"UpdateShippingAddress",
"(",
"$",
"aAddress",
")",
";",
"}",
"return",
"$",
"bUpdateOk",
";",
"}"
] | update the shipping address with the data passed.
Set new pack station type before validating
@param array $aAddress
@return bool | [
"update",
"the",
"shipping",
"address",
"with",
"the",
"data",
"passed",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopDhlPackstationBundle/pkgExtranet/objects/WebModules/MTExtranet_PkgShopDhlPackstation.class.php#L25-L50 |
32,135 | chameleon-system/chameleon-shop | src/ShopBundle/objects/WebModules/MTShopManufacturerArticleCatalogCore/MTShopManufacturerArticleCatalogCore.class.php | MTShopManufacturerArticleCatalogCore.LoadManufacturer | protected function LoadManufacturer()
{
if (is_null($this->oActiveManufacturer) && !is_null($this->iActiveManufacturerId)) {
$this->oActiveManufacturer = TdbShopManufacturer::GetNewInstance();
if (!$this->oActiveManufacturer->Load($this->iActiveManufacturerId)) {
$this->oActiveManufacturer = null;
// unable to find manufacturer - redirect to not found page
$this->getRedirect()->redirect($this->getPortalDomainService()->getActivePortal()->GetFieldPageNotFoundNodePageURL());
}
}
} | php | protected function LoadManufacturer()
{
if (is_null($this->oActiveManufacturer) && !is_null($this->iActiveManufacturerId)) {
$this->oActiveManufacturer = TdbShopManufacturer::GetNewInstance();
if (!$this->oActiveManufacturer->Load($this->iActiveManufacturerId)) {
$this->oActiveManufacturer = null;
// unable to find manufacturer - redirect to not found page
$this->getRedirect()->redirect($this->getPortalDomainService()->getActivePortal()->GetFieldPageNotFoundNodePageURL());
}
}
} | [
"protected",
"function",
"LoadManufacturer",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"oActiveManufacturer",
")",
"&&",
"!",
"is_null",
"(",
"$",
"this",
"->",
"iActiveManufacturerId",
")",
")",
"{",
"$",
"this",
"->",
"oActiveManufacturer",
"=",
"TdbShopManufacturer",
"::",
"GetNewInstance",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"oActiveManufacturer",
"->",
"Load",
"(",
"$",
"this",
"->",
"iActiveManufacturerId",
")",
")",
"{",
"$",
"this",
"->",
"oActiveManufacturer",
"=",
"null",
";",
"// unable to find manufacturer - redirect to not found page",
"$",
"this",
"->",
"getRedirect",
"(",
")",
"->",
"redirect",
"(",
"$",
"this",
"->",
"getPortalDomainService",
"(",
")",
"->",
"getActivePortal",
"(",
")",
"->",
"GetFieldPageNotFoundNodePageURL",
"(",
")",
")",
";",
"}",
"}",
"}"
] | load manufacturer and related data. | [
"load",
"manufacturer",
"and",
"related",
"data",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/WebModules/MTShopManufacturerArticleCatalogCore/MTShopManufacturerArticleCatalogCore.class.php#L43-L53 |
32,136 | chameleon-system/chameleon-shop | src/ShopBundle/objects/WebModules/MTShopArticleCatalogCore/MTShopArticleCatalogCoreEndPoint.class.php | MTShopArticleCatalogCoreEndPoint.ChangePageAjax | public function ChangePageAjax($iListIdent = null)
{
$oResponse = new MTShopArticleListResponse();
/** @var $oResponse MTShopArticleListResponse */
if (null === $iListIdent) {
$oGlobal = TGlobal::instance();
$iListIdent = $oGlobal->GetUserData(TdbShopArticleList::URL_LIST_KEY_NAME);
}
$oListItem = $this->oList;
if (null !== $oListItem) {
$bViewNameExists = false;
$bViewTypeExists = false;
$bCallTimeVarsExists = false;
$aItemRawData = TdbShopArticleList::GetInstanceDataFromSession($iListIdent);
if (is_array($aItemRawData)) {
$bViewNameExists = (array_key_exists('sViewName', $aItemRawData));
$bViewTypeExists = (array_key_exists('sViewType', $aItemRawData));
$bCallTimeVarsExists = (array_key_exists('aCallTimeVars', $aItemRawData));
}
if ($bViewNameExists && $bViewTypeExists && $bCallTimeVarsExists) {
// fetch data for requested item
$oResponse->iNumberOfResults = $oListItem->GetNumberOfRecordsForCurrentPage();
$oResponse->bHasNextPage = $oListItem->HasNextPage();
$oResponse->bHasPreviousPage = $oListItem->HasPreviousPage();
$oResponse->sItemPage = $oListItem->Render($aItemRawData['sViewName'], $aItemRawData['sViewType'], $aItemRawData['aCallTimeVars']);
$oResponse->iListKey = $iListIdent;
}
}
$_SESSION['iLastPageNumber'] = $oListItem->GetCurrentPageNumber() - 1;
return $oResponse;
} | php | public function ChangePageAjax($iListIdent = null)
{
$oResponse = new MTShopArticleListResponse();
/** @var $oResponse MTShopArticleListResponse */
if (null === $iListIdent) {
$oGlobal = TGlobal::instance();
$iListIdent = $oGlobal->GetUserData(TdbShopArticleList::URL_LIST_KEY_NAME);
}
$oListItem = $this->oList;
if (null !== $oListItem) {
$bViewNameExists = false;
$bViewTypeExists = false;
$bCallTimeVarsExists = false;
$aItemRawData = TdbShopArticleList::GetInstanceDataFromSession($iListIdent);
if (is_array($aItemRawData)) {
$bViewNameExists = (array_key_exists('sViewName', $aItemRawData));
$bViewTypeExists = (array_key_exists('sViewType', $aItemRawData));
$bCallTimeVarsExists = (array_key_exists('aCallTimeVars', $aItemRawData));
}
if ($bViewNameExists && $bViewTypeExists && $bCallTimeVarsExists) {
// fetch data for requested item
$oResponse->iNumberOfResults = $oListItem->GetNumberOfRecordsForCurrentPage();
$oResponse->bHasNextPage = $oListItem->HasNextPage();
$oResponse->bHasPreviousPage = $oListItem->HasPreviousPage();
$oResponse->sItemPage = $oListItem->Render($aItemRawData['sViewName'], $aItemRawData['sViewType'], $aItemRawData['aCallTimeVars']);
$oResponse->iListKey = $iListIdent;
}
}
$_SESSION['iLastPageNumber'] = $oListItem->GetCurrentPageNumber() - 1;
return $oResponse;
} | [
"public",
"function",
"ChangePageAjax",
"(",
"$",
"iListIdent",
"=",
"null",
")",
"{",
"$",
"oResponse",
"=",
"new",
"MTShopArticleListResponse",
"(",
")",
";",
"/** @var $oResponse MTShopArticleListResponse */",
"if",
"(",
"null",
"===",
"$",
"iListIdent",
")",
"{",
"$",
"oGlobal",
"=",
"TGlobal",
"::",
"instance",
"(",
")",
";",
"$",
"iListIdent",
"=",
"$",
"oGlobal",
"->",
"GetUserData",
"(",
"TdbShopArticleList",
"::",
"URL_LIST_KEY_NAME",
")",
";",
"}",
"$",
"oListItem",
"=",
"$",
"this",
"->",
"oList",
";",
"if",
"(",
"null",
"!==",
"$",
"oListItem",
")",
"{",
"$",
"bViewNameExists",
"=",
"false",
";",
"$",
"bViewTypeExists",
"=",
"false",
";",
"$",
"bCallTimeVarsExists",
"=",
"false",
";",
"$",
"aItemRawData",
"=",
"TdbShopArticleList",
"::",
"GetInstanceDataFromSession",
"(",
"$",
"iListIdent",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"aItemRawData",
")",
")",
"{",
"$",
"bViewNameExists",
"=",
"(",
"array_key_exists",
"(",
"'sViewName'",
",",
"$",
"aItemRawData",
")",
")",
";",
"$",
"bViewTypeExists",
"=",
"(",
"array_key_exists",
"(",
"'sViewType'",
",",
"$",
"aItemRawData",
")",
")",
";",
"$",
"bCallTimeVarsExists",
"=",
"(",
"array_key_exists",
"(",
"'aCallTimeVars'",
",",
"$",
"aItemRawData",
")",
")",
";",
"}",
"if",
"(",
"$",
"bViewNameExists",
"&&",
"$",
"bViewTypeExists",
"&&",
"$",
"bCallTimeVarsExists",
")",
"{",
"// fetch data for requested item",
"$",
"oResponse",
"->",
"iNumberOfResults",
"=",
"$",
"oListItem",
"->",
"GetNumberOfRecordsForCurrentPage",
"(",
")",
";",
"$",
"oResponse",
"->",
"bHasNextPage",
"=",
"$",
"oListItem",
"->",
"HasNextPage",
"(",
")",
";",
"$",
"oResponse",
"->",
"bHasPreviousPage",
"=",
"$",
"oListItem",
"->",
"HasPreviousPage",
"(",
")",
";",
"$",
"oResponse",
"->",
"sItemPage",
"=",
"$",
"oListItem",
"->",
"Render",
"(",
"$",
"aItemRawData",
"[",
"'sViewName'",
"]",
",",
"$",
"aItemRawData",
"[",
"'sViewType'",
"]",
",",
"$",
"aItemRawData",
"[",
"'aCallTimeVars'",
"]",
")",
";",
"$",
"oResponse",
"->",
"iListKey",
"=",
"$",
"iListIdent",
";",
"}",
"}",
"$",
"_SESSION",
"[",
"'iLastPageNumber'",
"]",
"=",
"$",
"oListItem",
"->",
"GetCurrentPageNumber",
"(",
")",
"-",
"1",
";",
"return",
"$",
"oResponse",
";",
"}"
] | send a paging signal to the list with iListIdent
since we changed the list to act on the signal on its own, we only need to return the
result here.
@param string $iListIdent
@return | [
"send",
"a",
"paging",
"signal",
"to",
"the",
"list",
"with",
"iListIdent",
"since",
"we",
"changed",
"the",
"list",
"to",
"act",
"on",
"the",
"signal",
"on",
"its",
"own",
"we",
"only",
"need",
"to",
"return",
"the",
"result",
"here",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/WebModules/MTShopArticleCatalogCore/MTShopArticleCatalogCoreEndPoint.class.php#L144-L178 |
32,137 | chameleon-system/chameleon-shop | src/ShopBundle/objects/WebModules/MTShopArticleCatalogCore/MTShopArticleCatalogCoreEndPoint.class.php | MTShopArticleCatalogCoreEndPoint.WriteReview | public function WriteReview()
{
// validate user input...
$bDataValide = false;
$oMsgManager = TCMSMessageManager::GetInstance();
$oGlobal = TGlobal::instance();
$aUserData = $oGlobal->GetUserData(TdbShopArticleReview::INPUT_BASE_NAME);
if (is_array($aUserData)) {
$bDataValide = true;
$sCaptcha = '';
if (array_key_exists('captcha', $aUserData)) {
$sCaptcha = trim($aUserData['captcha']);
}
if (empty($sCaptcha) || $sCaptcha != $this->GetCaptchaValue()) {
$bDataValide = false;
$oMsgManager->AddMessage(
TdbShopArticleReview::MSG_CONSUMER_BASE_NAME.'-captcha',
'INPUT-ERROR-INVALID-CAPTCHA'
);
}
$aRequiredFields = array('rating', 'author_name', 'author_email');
foreach ($aRequiredFields as $sFieldName) {
$sVal = '';
if (array_key_exists($sFieldName, $aUserData)) {
$sVal = trim($aUserData[$sFieldName]);
}
if (empty($sVal)) {
$bDataValide = false;
$oMsgManager->AddMessage(
TdbShopArticleReview::MSG_CONSUMER_BASE_NAME.'-'.$sFieldName,
'ERROR-USER-REQUIRED-FIELD-MISSING'
);
}
}
}
if ($bDataValide) {
if (!preg_match('#^[0-5]$#', $aUserData['rating'])) {
$oMsgManager->AddMessage(
TdbShopArticleReview::MSG_CONSUMER_BASE_NAME.'-rating',
'ERROR-INVALID-FIELD-VALUE-RATING'
);
$bDataValide = false;
}
}
if ($bDataValide) {
// save item
$oReviewItem = TdbShopArticleReview::GetNewInstance();
/** @var $oReviewItem TdbShopArticleReview */
$aUserData['shop_article_id'] = $this->iItemId;
$oReviewItem->LoadFromRowProtected($aUserData);
$oReviewItem->AllowEditByAll(true);
$oReviewItem->Save();
// notify the shop owner
$oReviewItem->SendNewReviewNotification();
$oMsgManager->AddMessage(self::MSG_CONSUMER_NAME, 'ARTICLE-REVIEW-SUBMITTED', $aUserData);
$oActiveItm = static::GetActiveItem();
$oActiveCategory = static::GetActiveCategory();
$iActiveCategoryId = null;
if (is_object($oActiveCategory)) {
$iActiveCategoryId = $oActiveCategory->id;
}
$sURL = $oActiveItm->GetDetailLink(true, $iActiveCategoryId);
$this->controller->HeaderURLRedirect($sURL);
}
} | php | public function WriteReview()
{
// validate user input...
$bDataValide = false;
$oMsgManager = TCMSMessageManager::GetInstance();
$oGlobal = TGlobal::instance();
$aUserData = $oGlobal->GetUserData(TdbShopArticleReview::INPUT_BASE_NAME);
if (is_array($aUserData)) {
$bDataValide = true;
$sCaptcha = '';
if (array_key_exists('captcha', $aUserData)) {
$sCaptcha = trim($aUserData['captcha']);
}
if (empty($sCaptcha) || $sCaptcha != $this->GetCaptchaValue()) {
$bDataValide = false;
$oMsgManager->AddMessage(
TdbShopArticleReview::MSG_CONSUMER_BASE_NAME.'-captcha',
'INPUT-ERROR-INVALID-CAPTCHA'
);
}
$aRequiredFields = array('rating', 'author_name', 'author_email');
foreach ($aRequiredFields as $sFieldName) {
$sVal = '';
if (array_key_exists($sFieldName, $aUserData)) {
$sVal = trim($aUserData[$sFieldName]);
}
if (empty($sVal)) {
$bDataValide = false;
$oMsgManager->AddMessage(
TdbShopArticleReview::MSG_CONSUMER_BASE_NAME.'-'.$sFieldName,
'ERROR-USER-REQUIRED-FIELD-MISSING'
);
}
}
}
if ($bDataValide) {
if (!preg_match('#^[0-5]$#', $aUserData['rating'])) {
$oMsgManager->AddMessage(
TdbShopArticleReview::MSG_CONSUMER_BASE_NAME.'-rating',
'ERROR-INVALID-FIELD-VALUE-RATING'
);
$bDataValide = false;
}
}
if ($bDataValide) {
// save item
$oReviewItem = TdbShopArticleReview::GetNewInstance();
/** @var $oReviewItem TdbShopArticleReview */
$aUserData['shop_article_id'] = $this->iItemId;
$oReviewItem->LoadFromRowProtected($aUserData);
$oReviewItem->AllowEditByAll(true);
$oReviewItem->Save();
// notify the shop owner
$oReviewItem->SendNewReviewNotification();
$oMsgManager->AddMessage(self::MSG_CONSUMER_NAME, 'ARTICLE-REVIEW-SUBMITTED', $aUserData);
$oActiveItm = static::GetActiveItem();
$oActiveCategory = static::GetActiveCategory();
$iActiveCategoryId = null;
if (is_object($oActiveCategory)) {
$iActiveCategoryId = $oActiveCategory->id;
}
$sURL = $oActiveItm->GetDetailLink(true, $iActiveCategoryId);
$this->controller->HeaderURLRedirect($sURL);
}
} | [
"public",
"function",
"WriteReview",
"(",
")",
"{",
"// validate user input...",
"$",
"bDataValide",
"=",
"false",
";",
"$",
"oMsgManager",
"=",
"TCMSMessageManager",
"::",
"GetInstance",
"(",
")",
";",
"$",
"oGlobal",
"=",
"TGlobal",
"::",
"instance",
"(",
")",
";",
"$",
"aUserData",
"=",
"$",
"oGlobal",
"->",
"GetUserData",
"(",
"TdbShopArticleReview",
"::",
"INPUT_BASE_NAME",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"aUserData",
")",
")",
"{",
"$",
"bDataValide",
"=",
"true",
";",
"$",
"sCaptcha",
"=",
"''",
";",
"if",
"(",
"array_key_exists",
"(",
"'captcha'",
",",
"$",
"aUserData",
")",
")",
"{",
"$",
"sCaptcha",
"=",
"trim",
"(",
"$",
"aUserData",
"[",
"'captcha'",
"]",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"sCaptcha",
")",
"||",
"$",
"sCaptcha",
"!=",
"$",
"this",
"->",
"GetCaptchaValue",
"(",
")",
")",
"{",
"$",
"bDataValide",
"=",
"false",
";",
"$",
"oMsgManager",
"->",
"AddMessage",
"(",
"TdbShopArticleReview",
"::",
"MSG_CONSUMER_BASE_NAME",
".",
"'-captcha'",
",",
"'INPUT-ERROR-INVALID-CAPTCHA'",
")",
";",
"}",
"$",
"aRequiredFields",
"=",
"array",
"(",
"'rating'",
",",
"'author_name'",
",",
"'author_email'",
")",
";",
"foreach",
"(",
"$",
"aRequiredFields",
"as",
"$",
"sFieldName",
")",
"{",
"$",
"sVal",
"=",
"''",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"sFieldName",
",",
"$",
"aUserData",
")",
")",
"{",
"$",
"sVal",
"=",
"trim",
"(",
"$",
"aUserData",
"[",
"$",
"sFieldName",
"]",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"sVal",
")",
")",
"{",
"$",
"bDataValide",
"=",
"false",
";",
"$",
"oMsgManager",
"->",
"AddMessage",
"(",
"TdbShopArticleReview",
"::",
"MSG_CONSUMER_BASE_NAME",
".",
"'-'",
".",
"$",
"sFieldName",
",",
"'ERROR-USER-REQUIRED-FIELD-MISSING'",
")",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"bDataValide",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'#^[0-5]$#'",
",",
"$",
"aUserData",
"[",
"'rating'",
"]",
")",
")",
"{",
"$",
"oMsgManager",
"->",
"AddMessage",
"(",
"TdbShopArticleReview",
"::",
"MSG_CONSUMER_BASE_NAME",
".",
"'-rating'",
",",
"'ERROR-INVALID-FIELD-VALUE-RATING'",
")",
";",
"$",
"bDataValide",
"=",
"false",
";",
"}",
"}",
"if",
"(",
"$",
"bDataValide",
")",
"{",
"// save item",
"$",
"oReviewItem",
"=",
"TdbShopArticleReview",
"::",
"GetNewInstance",
"(",
")",
";",
"/** @var $oReviewItem TdbShopArticleReview */",
"$",
"aUserData",
"[",
"'shop_article_id'",
"]",
"=",
"$",
"this",
"->",
"iItemId",
";",
"$",
"oReviewItem",
"->",
"LoadFromRowProtected",
"(",
"$",
"aUserData",
")",
";",
"$",
"oReviewItem",
"->",
"AllowEditByAll",
"(",
"true",
")",
";",
"$",
"oReviewItem",
"->",
"Save",
"(",
")",
";",
"// notify the shop owner",
"$",
"oReviewItem",
"->",
"SendNewReviewNotification",
"(",
")",
";",
"$",
"oMsgManager",
"->",
"AddMessage",
"(",
"self",
"::",
"MSG_CONSUMER_NAME",
",",
"'ARTICLE-REVIEW-SUBMITTED'",
",",
"$",
"aUserData",
")",
";",
"$",
"oActiveItm",
"=",
"static",
"::",
"GetActiveItem",
"(",
")",
";",
"$",
"oActiveCategory",
"=",
"static",
"::",
"GetActiveCategory",
"(",
")",
";",
"$",
"iActiveCategoryId",
"=",
"null",
";",
"if",
"(",
"is_object",
"(",
"$",
"oActiveCategory",
")",
")",
"{",
"$",
"iActiveCategoryId",
"=",
"$",
"oActiveCategory",
"->",
"id",
";",
"}",
"$",
"sURL",
"=",
"$",
"oActiveItm",
"->",
"GetDetailLink",
"(",
"true",
",",
"$",
"iActiveCategoryId",
")",
";",
"$",
"this",
"->",
"controller",
"->",
"HeaderURLRedirect",
"(",
"$",
"sURL",
")",
";",
"}",
"}"
] | write a review. | [
"write",
"a",
"review",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/WebModules/MTShopArticleCatalogCore/MTShopArticleCatalogCoreEndPoint.class.php#L317-L386 |
32,138 | chameleon-system/chameleon-shop | src/ShopBundle/objects/WebModules/MTShopArticleCatalogCore/MTShopArticleCatalogCoreEndPoint.class.php | MTShopArticleCatalogCoreEndPoint.ViewArticleHook | protected function ViewArticleHook()
{
$this->SetTemplate('MTShopArticleCatalog', 'system/article');
// add review item and fill with user data
$oReviewItem = TdbShopArticleReview::GetNewInstance();
/** @var $oReviewItem TdbShopArticleReview */
$oGlobal = TGlobal::instance();
$aReviewData = array();
if ($oGlobal->UserDataExists(TdbShopArticleReview::INPUT_BASE_NAME)) {
$aReviewData = $oGlobal->GetUserData(TdbShopArticleReview::INPUT_BASE_NAME);
} else {
$oUser = TdbDataExtranetUser::GetInstance();
if ($oUser->IsLoggedIn()) {
$aReviewData['author_name'] = $oUser->GetUserAlias();
$aReviewData['author_email'] = $oUser->GetUserEMail();
}
}
$aReviewData['captcha-question'] = $this->GenerateCaptcha();
if (is_array($aReviewData)) {
$oReviewItem->LoadFromRowProtected($aReviewData);
}
$this->data['oReviewEntryItem'] = &$oReviewItem;
} | php | protected function ViewArticleHook()
{
$this->SetTemplate('MTShopArticleCatalog', 'system/article');
// add review item and fill with user data
$oReviewItem = TdbShopArticleReview::GetNewInstance();
/** @var $oReviewItem TdbShopArticleReview */
$oGlobal = TGlobal::instance();
$aReviewData = array();
if ($oGlobal->UserDataExists(TdbShopArticleReview::INPUT_BASE_NAME)) {
$aReviewData = $oGlobal->GetUserData(TdbShopArticleReview::INPUT_BASE_NAME);
} else {
$oUser = TdbDataExtranetUser::GetInstance();
if ($oUser->IsLoggedIn()) {
$aReviewData['author_name'] = $oUser->GetUserAlias();
$aReviewData['author_email'] = $oUser->GetUserEMail();
}
}
$aReviewData['captcha-question'] = $this->GenerateCaptcha();
if (is_array($aReviewData)) {
$oReviewItem->LoadFromRowProtected($aReviewData);
}
$this->data['oReviewEntryItem'] = &$oReviewItem;
} | [
"protected",
"function",
"ViewArticleHook",
"(",
")",
"{",
"$",
"this",
"->",
"SetTemplate",
"(",
"'MTShopArticleCatalog'",
",",
"'system/article'",
")",
";",
"// add review item and fill with user data",
"$",
"oReviewItem",
"=",
"TdbShopArticleReview",
"::",
"GetNewInstance",
"(",
")",
";",
"/** @var $oReviewItem TdbShopArticleReview */",
"$",
"oGlobal",
"=",
"TGlobal",
"::",
"instance",
"(",
")",
";",
"$",
"aReviewData",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"oGlobal",
"->",
"UserDataExists",
"(",
"TdbShopArticleReview",
"::",
"INPUT_BASE_NAME",
")",
")",
"{",
"$",
"aReviewData",
"=",
"$",
"oGlobal",
"->",
"GetUserData",
"(",
"TdbShopArticleReview",
"::",
"INPUT_BASE_NAME",
")",
";",
"}",
"else",
"{",
"$",
"oUser",
"=",
"TdbDataExtranetUser",
"::",
"GetInstance",
"(",
")",
";",
"if",
"(",
"$",
"oUser",
"->",
"IsLoggedIn",
"(",
")",
")",
"{",
"$",
"aReviewData",
"[",
"'author_name'",
"]",
"=",
"$",
"oUser",
"->",
"GetUserAlias",
"(",
")",
";",
"$",
"aReviewData",
"[",
"'author_email'",
"]",
"=",
"$",
"oUser",
"->",
"GetUserEMail",
"(",
")",
";",
"}",
"}",
"$",
"aReviewData",
"[",
"'captcha-question'",
"]",
"=",
"$",
"this",
"->",
"GenerateCaptcha",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"aReviewData",
")",
")",
"{",
"$",
"oReviewItem",
"->",
"LoadFromRowProtected",
"(",
"$",
"aReviewData",
")",
";",
"}",
"$",
"this",
"->",
"data",
"[",
"'oReviewEntryItem'",
"]",
"=",
"&",
"$",
"oReviewItem",
";",
"}"
] | called if the user requested to view an item. | [
"called",
"if",
"the",
"user",
"requested",
"to",
"view",
"an",
"item",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/WebModules/MTShopArticleCatalogCore/MTShopArticleCatalogCoreEndPoint.class.php#L413-L437 |
32,139 | chameleon-system/chameleon-shop | src/ShopBundle/objects/WebModules/MTShopArticleCatalogCore/MTShopArticleCatalogCoreEndPoint.class.php | MTShopArticleCatalogCoreEndPoint.& | protected function &GetOrderByFilterList()
{
$aFilterIds = $this->oModuleConf->GetMLTIdList('shop_module_articlelist_orderby');
$oList = TdbShopModuleArticlelistOrderbyList::GetListForIds($aFilterIds);
$oList->bAllowItemCache = true;
// fill item cache
$i = 0;
while ($oItem = $oList->Next()) {
++$i;
}
$oList->GoToStart();
return $oList;
} | php | protected function &GetOrderByFilterList()
{
$aFilterIds = $this->oModuleConf->GetMLTIdList('shop_module_articlelist_orderby');
$oList = TdbShopModuleArticlelistOrderbyList::GetListForIds($aFilterIds);
$oList->bAllowItemCache = true;
// fill item cache
$i = 0;
while ($oItem = $oList->Next()) {
++$i;
}
$oList->GoToStart();
return $oList;
} | [
"protected",
"function",
"&",
"GetOrderByFilterList",
"(",
")",
"{",
"$",
"aFilterIds",
"=",
"$",
"this",
"->",
"oModuleConf",
"->",
"GetMLTIdList",
"(",
"'shop_module_articlelist_orderby'",
")",
";",
"$",
"oList",
"=",
"TdbShopModuleArticlelistOrderbyList",
"::",
"GetListForIds",
"(",
"$",
"aFilterIds",
")",
";",
"$",
"oList",
"->",
"bAllowItemCache",
"=",
"true",
";",
"// fill item cache",
"$",
"i",
"=",
"0",
";",
"while",
"(",
"$",
"oItem",
"=",
"$",
"oList",
"->",
"Next",
"(",
")",
")",
"{",
"++",
"$",
"i",
";",
"}",
"$",
"oList",
"->",
"GoToStart",
"(",
")",
";",
"return",
"$",
"oList",
";",
"}"
] | return order by list for category view.
@return TdbShopModuleArticlelistOrderbyList | [
"return",
"order",
"by",
"list",
"for",
"category",
"view",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/WebModules/MTShopArticleCatalogCore/MTShopArticleCatalogCoreEndPoint.class.php#L494-L507 |
32,140 | chameleon-system/chameleon-shop | src/ShopBundle/objects/WebModules/MTShopArticleCatalogCore/MTShopArticleCatalogCoreEndPoint.class.php | MTShopArticleCatalogCoreEndPoint.GetActiveShopModuleArticlelistOrderbyId | public function GetActiveShopModuleArticlelistOrderbyId($sInstanceId = '')
{
$iActiveShopModuleArticlelistOrderbyId = null;
$oGlobal = TGlobal::instance();
if ($oGlobal->UserDataExists(self::URL_ORDER_BY)) {
$iActiveShopModuleArticlelistOrderbyId = $oGlobal->GetUserData(self::URL_ORDER_BY);
} else {
if (array_key_exists(self::SESSION_ACTIVE_ORDER_BY.$sInstanceId, $_SESSION)) {
$iActiveShopModuleArticlelistOrderbyId = $_SESSION[self::SESSION_ACTIVE_ORDER_BY.$sInstanceId];
}
}
return $iActiveShopModuleArticlelistOrderbyId;
} | php | public function GetActiveShopModuleArticlelistOrderbyId($sInstanceId = '')
{
$iActiveShopModuleArticlelistOrderbyId = null;
$oGlobal = TGlobal::instance();
if ($oGlobal->UserDataExists(self::URL_ORDER_BY)) {
$iActiveShopModuleArticlelistOrderbyId = $oGlobal->GetUserData(self::URL_ORDER_BY);
} else {
if (array_key_exists(self::SESSION_ACTIVE_ORDER_BY.$sInstanceId, $_SESSION)) {
$iActiveShopModuleArticlelistOrderbyId = $_SESSION[self::SESSION_ACTIVE_ORDER_BY.$sInstanceId];
}
}
return $iActiveShopModuleArticlelistOrderbyId;
} | [
"public",
"function",
"GetActiveShopModuleArticlelistOrderbyId",
"(",
"$",
"sInstanceId",
"=",
"''",
")",
"{",
"$",
"iActiveShopModuleArticlelistOrderbyId",
"=",
"null",
";",
"$",
"oGlobal",
"=",
"TGlobal",
"::",
"instance",
"(",
")",
";",
"if",
"(",
"$",
"oGlobal",
"->",
"UserDataExists",
"(",
"self",
"::",
"URL_ORDER_BY",
")",
")",
"{",
"$",
"iActiveShopModuleArticlelistOrderbyId",
"=",
"$",
"oGlobal",
"->",
"GetUserData",
"(",
"self",
"::",
"URL_ORDER_BY",
")",
";",
"}",
"else",
"{",
"if",
"(",
"array_key_exists",
"(",
"self",
"::",
"SESSION_ACTIVE_ORDER_BY",
".",
"$",
"sInstanceId",
",",
"$",
"_SESSION",
")",
")",
"{",
"$",
"iActiveShopModuleArticlelistOrderbyId",
"=",
"$",
"_SESSION",
"[",
"self",
"::",
"SESSION_ACTIVE_ORDER_BY",
".",
"$",
"sInstanceId",
"]",
";",
"}",
"}",
"return",
"$",
"iActiveShopModuleArticlelistOrderbyId",
";",
"}"
] | return the active order by id based on session or url parameter.
@return int | [
"return",
"the",
"active",
"order",
"by",
"id",
"based",
"on",
"session",
"or",
"url",
"parameter",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/WebModules/MTShopArticleCatalogCore/MTShopArticleCatalogCoreEndPoint.class.php#L514-L527 |
32,141 | chameleon-system/chameleon-shop | src/ShopBundle/objects/WebModules/MTShopArticleCatalogCore/MTShopArticleCatalogCoreEndPoint.class.php | MTShopArticleCatalogCoreEndPoint.GetActiveOrderByString | public function GetActiveOrderByString($sDefaultActiveShopModuleArticlelistOrderbyId = null, $sInstanceId = '')
{
static $oOrderBy = null;
if (is_null($oOrderBy)) {
// remove default order by - for performance reason we should be allowed to sort by nothing
$sOrder = ''; //`shop_article`.`list_rank` DESC, `shop_article`.`name` ASC';
$iActiveShopModuleArticlelistOrderbyId = $this->GetActiveShopModuleArticlelistOrderbyId($sInstanceId);
if (is_null($iActiveShopModuleArticlelistOrderbyId)) {
$iActiveShopModuleArticlelistOrderbyId = $sDefaultActiveShopModuleArticlelistOrderbyId;
}
if (!is_null($iActiveShopModuleArticlelistOrderbyId)) {
$oOrderBy = TdbShopModuleArticlelistOrderby::GetNewInstance();
/** @var $oOrderBy TdbShopModuleArticlelistOrderby */
if (!$oOrderBy->Load($iActiveShopModuleArticlelistOrderbyId)) {
$oOrderBy = null;
}
}
if (is_null($oOrderBy)) {
$oShop = TdbShop::GetInstance();
$oOrderBy = &$oShop->GetFieldShopModuleArticlelistOrderby();
}
if (!is_null($oOrderBy)) {
$sOrder = $oOrderBy->GetOrderByString();
$_SESSION[self::SESSION_ACTIVE_ORDER_BY.$sInstanceId] = $iActiveShopModuleArticlelistOrderbyId;
}
} else {
$sOrder = $oOrderBy->GetOrderByString();
}
return $sOrder;
} | php | public function GetActiveOrderByString($sDefaultActiveShopModuleArticlelistOrderbyId = null, $sInstanceId = '')
{
static $oOrderBy = null;
if (is_null($oOrderBy)) {
// remove default order by - for performance reason we should be allowed to sort by nothing
$sOrder = ''; //`shop_article`.`list_rank` DESC, `shop_article`.`name` ASC';
$iActiveShopModuleArticlelistOrderbyId = $this->GetActiveShopModuleArticlelistOrderbyId($sInstanceId);
if (is_null($iActiveShopModuleArticlelistOrderbyId)) {
$iActiveShopModuleArticlelistOrderbyId = $sDefaultActiveShopModuleArticlelistOrderbyId;
}
if (!is_null($iActiveShopModuleArticlelistOrderbyId)) {
$oOrderBy = TdbShopModuleArticlelistOrderby::GetNewInstance();
/** @var $oOrderBy TdbShopModuleArticlelistOrderby */
if (!$oOrderBy->Load($iActiveShopModuleArticlelistOrderbyId)) {
$oOrderBy = null;
}
}
if (is_null($oOrderBy)) {
$oShop = TdbShop::GetInstance();
$oOrderBy = &$oShop->GetFieldShopModuleArticlelistOrderby();
}
if (!is_null($oOrderBy)) {
$sOrder = $oOrderBy->GetOrderByString();
$_SESSION[self::SESSION_ACTIVE_ORDER_BY.$sInstanceId] = $iActiveShopModuleArticlelistOrderbyId;
}
} else {
$sOrder = $oOrderBy->GetOrderByString();
}
return $sOrder;
} | [
"public",
"function",
"GetActiveOrderByString",
"(",
"$",
"sDefaultActiveShopModuleArticlelistOrderbyId",
"=",
"null",
",",
"$",
"sInstanceId",
"=",
"''",
")",
"{",
"static",
"$",
"oOrderBy",
"=",
"null",
";",
"if",
"(",
"is_null",
"(",
"$",
"oOrderBy",
")",
")",
"{",
"// remove default order by - for performance reason we should be allowed to sort by nothing",
"$",
"sOrder",
"=",
"''",
";",
"//`shop_article`.`list_rank` DESC, `shop_article`.`name` ASC';",
"$",
"iActiveShopModuleArticlelistOrderbyId",
"=",
"$",
"this",
"->",
"GetActiveShopModuleArticlelistOrderbyId",
"(",
"$",
"sInstanceId",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"iActiveShopModuleArticlelistOrderbyId",
")",
")",
"{",
"$",
"iActiveShopModuleArticlelistOrderbyId",
"=",
"$",
"sDefaultActiveShopModuleArticlelistOrderbyId",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"iActiveShopModuleArticlelistOrderbyId",
")",
")",
"{",
"$",
"oOrderBy",
"=",
"TdbShopModuleArticlelistOrderby",
"::",
"GetNewInstance",
"(",
")",
";",
"/** @var $oOrderBy TdbShopModuleArticlelistOrderby */",
"if",
"(",
"!",
"$",
"oOrderBy",
"->",
"Load",
"(",
"$",
"iActiveShopModuleArticlelistOrderbyId",
")",
")",
"{",
"$",
"oOrderBy",
"=",
"null",
";",
"}",
"}",
"if",
"(",
"is_null",
"(",
"$",
"oOrderBy",
")",
")",
"{",
"$",
"oShop",
"=",
"TdbShop",
"::",
"GetInstance",
"(",
")",
";",
"$",
"oOrderBy",
"=",
"&",
"$",
"oShop",
"->",
"GetFieldShopModuleArticlelistOrderby",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"oOrderBy",
")",
")",
"{",
"$",
"sOrder",
"=",
"$",
"oOrderBy",
"->",
"GetOrderByString",
"(",
")",
";",
"$",
"_SESSION",
"[",
"self",
"::",
"SESSION_ACTIVE_ORDER_BY",
".",
"$",
"sInstanceId",
"]",
"=",
"$",
"iActiveShopModuleArticlelistOrderbyId",
";",
"}",
"}",
"else",
"{",
"$",
"sOrder",
"=",
"$",
"oOrderBy",
"->",
"GetOrderByString",
"(",
")",
";",
"}",
"return",
"$",
"sOrder",
";",
"}"
] | return the current order string for the article lists.
@return string | [
"return",
"the",
"current",
"order",
"string",
"for",
"the",
"article",
"lists",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/WebModules/MTShopArticleCatalogCore/MTShopArticleCatalogCoreEndPoint.class.php#L534-L565 |
32,142 | edmondscommerce/doctrine-static-meta | src/CodeGeneration/Generator/FileCreationTransaction.php | FileCreationTransaction.registerShutdownFunction | private static function registerShutdownFunction(): bool
{
self::$startTime = microtime(true);
register_shutdown_function(
function () {
$error = error_get_last();
if ($error === E_ERROR && count(self::$pathsCreated) > 0) {
self::echoDirtyTransactionCleanupCommands();
}
}
);
return true;
} | php | private static function registerShutdownFunction(): bool
{
self::$startTime = microtime(true);
register_shutdown_function(
function () {
$error = error_get_last();
if ($error === E_ERROR && count(self::$pathsCreated) > 0) {
self::echoDirtyTransactionCleanupCommands();
}
}
);
return true;
} | [
"private",
"static",
"function",
"registerShutdownFunction",
"(",
")",
":",
"bool",
"{",
"self",
"::",
"$",
"startTime",
"=",
"microtime",
"(",
"true",
")",
";",
"register_shutdown_function",
"(",
"function",
"(",
")",
"{",
"$",
"error",
"=",
"error_get_last",
"(",
")",
";",
"if",
"(",
"$",
"error",
"===",
"E_ERROR",
"&&",
"count",
"(",
"self",
"::",
"$",
"pathsCreated",
")",
">",
"0",
")",
"{",
"self",
"::",
"echoDirtyTransactionCleanupCommands",
"(",
")",
";",
"}",
"}",
")",
";",
"return",
"true",
";",
"}"
] | Registers our shutdown function. Will attempt to echo out the dirty file clean up commands on a fatal error
@return bool | [
"Registers",
"our",
"shutdown",
"function",
".",
"Will",
"attempt",
"to",
"echo",
"out",
"the",
"dirty",
"file",
"clean",
"up",
"commands",
"on",
"a",
"fatal",
"error"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Generator/FileCreationTransaction.php#L59-L72 |
32,143 | edmondscommerce/doctrine-static-meta | src/CodeGeneration/Generator/FileCreationTransaction.php | FileCreationTransaction.echoDirtyTransactionCleanupCommands | public static function echoDirtyTransactionCleanupCommands($handle = STDERR): void
{
if (0 === count(self::$pathsCreated)) {
return;
}
$sinceTimeSeconds = ceil(microtime(true) - self::$startTime);
// why, because of xdebug break - you could easily spend over 1 minute stepping through
$sinceTimeMinutes = ceil($sinceTimeSeconds / 60);
$pathsToSearch = [];
foreach (self::$pathsCreated as $path) {
$realPath = realpath($path);
if ($realPath) {
$pathsToSearch[$realPath] = $realPath;
}
}
if (0 === count($pathsToSearch)) {
return;
}
$findCommand = 'find ' . implode(' ', $pathsToSearch) . " -mmin -$sinceTimeMinutes";
$line = str_repeat('-', 15);
$deleteCommand = "$findCommand -exec rm -rf";
fwrite(
$handle,
"\n$line\n"
. "\n\nUnclean File Creation Transaction:"
. "\n\nTo find created files:\n$findCommand"
. "\n\nTo remove created files:\n$deleteCommand"
. "\n\n$line\n\n"
);
} | php | public static function echoDirtyTransactionCleanupCommands($handle = STDERR): void
{
if (0 === count(self::$pathsCreated)) {
return;
}
$sinceTimeSeconds = ceil(microtime(true) - self::$startTime);
// why, because of xdebug break - you could easily spend over 1 minute stepping through
$sinceTimeMinutes = ceil($sinceTimeSeconds / 60);
$pathsToSearch = [];
foreach (self::$pathsCreated as $path) {
$realPath = realpath($path);
if ($realPath) {
$pathsToSearch[$realPath] = $realPath;
}
}
if (0 === count($pathsToSearch)) {
return;
}
$findCommand = 'find ' . implode(' ', $pathsToSearch) . " -mmin -$sinceTimeMinutes";
$line = str_repeat('-', 15);
$deleteCommand = "$findCommand -exec rm -rf";
fwrite(
$handle,
"\n$line\n"
. "\n\nUnclean File Creation Transaction:"
. "\n\nTo find created files:\n$findCommand"
. "\n\nTo remove created files:\n$deleteCommand"
. "\n\n$line\n\n"
);
} | [
"public",
"static",
"function",
"echoDirtyTransactionCleanupCommands",
"(",
"$",
"handle",
"=",
"STDERR",
")",
":",
"void",
"{",
"if",
"(",
"0",
"===",
"count",
"(",
"self",
"::",
"$",
"pathsCreated",
")",
")",
"{",
"return",
";",
"}",
"$",
"sinceTimeSeconds",
"=",
"ceil",
"(",
"microtime",
"(",
"true",
")",
"-",
"self",
"::",
"$",
"startTime",
")",
";",
"// why, because of xdebug break - you could easily spend over 1 minute stepping through",
"$",
"sinceTimeMinutes",
"=",
"ceil",
"(",
"$",
"sinceTimeSeconds",
"/",
"60",
")",
";",
"$",
"pathsToSearch",
"=",
"[",
"]",
";",
"foreach",
"(",
"self",
"::",
"$",
"pathsCreated",
"as",
"$",
"path",
")",
"{",
"$",
"realPath",
"=",
"realpath",
"(",
"$",
"path",
")",
";",
"if",
"(",
"$",
"realPath",
")",
"{",
"$",
"pathsToSearch",
"[",
"$",
"realPath",
"]",
"=",
"$",
"realPath",
";",
"}",
"}",
"if",
"(",
"0",
"===",
"count",
"(",
"$",
"pathsToSearch",
")",
")",
"{",
"return",
";",
"}",
"$",
"findCommand",
"=",
"'find '",
".",
"implode",
"(",
"' '",
",",
"$",
"pathsToSearch",
")",
".",
"\" -mmin -$sinceTimeMinutes\"",
";",
"$",
"line",
"=",
"str_repeat",
"(",
"'-'",
",",
"15",
")",
";",
"$",
"deleteCommand",
"=",
"\"$findCommand -exec rm -rf\"",
";",
"fwrite",
"(",
"$",
"handle",
",",
"\"\\n$line\\n\"",
".",
"\"\\n\\nUnclean File Creation Transaction:\"",
".",
"\"\\n\\nTo find created files:\\n$findCommand\"",
".",
"\"\\n\\nTo remove created files:\\n$deleteCommand\"",
".",
"\"\\n\\n$line\\n\\n\"",
")",
";",
"}"
] | Echos out bash find commands to find and delete created paths
@param bool|resource $handle | [
"Echos",
"out",
"bash",
"find",
"commands",
"to",
"find",
"and",
"delete",
"created",
"paths"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Generator/FileCreationTransaction.php#L79-L108 |
32,144 | PGB-LIV/php-ms | src/experimental/MzMlMerge.php | MzMlMerge.merge | public function merge()
{
// TODO: verify analysis phase run
foreach ($this->dataFiles as $replicate => $fractions) {
$firstFile = current($fractions);
// Write header
$this->writeHeader($firstFile['path'], $this->spectrumCount[$replicate], $this->outputFiles[$replicate]);
// Resets vars
$this->spectrumIdRef = array();
$this->timeOffset = 0;
$this->indexOffset = 0;
$this->idOffset = 0;
foreach ($fractions as $fractionIndex => $file) {
$this->writeSpectrum($file['path'], $this->outputFiles[$replicate],
$this->fractionOffsets[$fractionIndex]);
}
$this->writeFooter($firstFile['path'], $this->outputFiles[$replicate]);
}
} | php | public function merge()
{
// TODO: verify analysis phase run
foreach ($this->dataFiles as $replicate => $fractions) {
$firstFile = current($fractions);
// Write header
$this->writeHeader($firstFile['path'], $this->spectrumCount[$replicate], $this->outputFiles[$replicate]);
// Resets vars
$this->spectrumIdRef = array();
$this->timeOffset = 0;
$this->indexOffset = 0;
$this->idOffset = 0;
foreach ($fractions as $fractionIndex => $file) {
$this->writeSpectrum($file['path'], $this->outputFiles[$replicate],
$this->fractionOffsets[$fractionIndex]);
}
$this->writeFooter($firstFile['path'], $this->outputFiles[$replicate]);
}
} | [
"public",
"function",
"merge",
"(",
")",
"{",
"// TODO: verify analysis phase run",
"foreach",
"(",
"$",
"this",
"->",
"dataFiles",
"as",
"$",
"replicate",
"=>",
"$",
"fractions",
")",
"{",
"$",
"firstFile",
"=",
"current",
"(",
"$",
"fractions",
")",
";",
"// Write header",
"$",
"this",
"->",
"writeHeader",
"(",
"$",
"firstFile",
"[",
"'path'",
"]",
",",
"$",
"this",
"->",
"spectrumCount",
"[",
"$",
"replicate",
"]",
",",
"$",
"this",
"->",
"outputFiles",
"[",
"$",
"replicate",
"]",
")",
";",
"// Resets vars",
"$",
"this",
"->",
"spectrumIdRef",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"timeOffset",
"=",
"0",
";",
"$",
"this",
"->",
"indexOffset",
"=",
"0",
";",
"$",
"this",
"->",
"idOffset",
"=",
"0",
";",
"foreach",
"(",
"$",
"fractions",
"as",
"$",
"fractionIndex",
"=>",
"$",
"file",
")",
"{",
"$",
"this",
"->",
"writeSpectrum",
"(",
"$",
"file",
"[",
"'path'",
"]",
",",
"$",
"this",
"->",
"outputFiles",
"[",
"$",
"replicate",
"]",
",",
"$",
"this",
"->",
"fractionOffsets",
"[",
"$",
"fractionIndex",
"]",
")",
";",
"}",
"$",
"this",
"->",
"writeFooter",
"(",
"$",
"firstFile",
"[",
"'path'",
"]",
",",
"$",
"this",
"->",
"outputFiles",
"[",
"$",
"replicate",
"]",
")",
";",
"}",
"}"
] | Merges the MzML files specified in the constructor into a single MzML file and writes the data to the output file specified in the constructor | [
"Merges",
"the",
"MzML",
"files",
"specified",
"in",
"the",
"constructor",
"into",
"a",
"single",
"MzML",
"file",
"and",
"writes",
"the",
"data",
"to",
"the",
"output",
"file",
"specified",
"in",
"the",
"constructor"
] | 091751eb12512f4bc6ada07bda745ce49331e24f | https://github.com/PGB-LIV/php-ms/blob/091751eb12512f4bc6ada07bda745ce49331e24f/src/experimental/MzMlMerge.php#L193-L214 |
32,145 | edmondscommerce/doctrine-static-meta | src/DoctrineStaticMeta.php | DoctrineStaticMeta.getStaticMethods | public function getStaticMethods(): array
{
if (null !== $this->staticMethods) {
return $this->staticMethods;
}
$this->staticMethods = $this->reflectionClass->getMethods(
\ReflectionMethod::IS_STATIC
);
return $this->staticMethods;
} | php | public function getStaticMethods(): array
{
if (null !== $this->staticMethods) {
return $this->staticMethods;
}
$this->staticMethods = $this->reflectionClass->getMethods(
\ReflectionMethod::IS_STATIC
);
return $this->staticMethods;
} | [
"public",
"function",
"getStaticMethods",
"(",
")",
":",
"array",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"staticMethods",
")",
"{",
"return",
"$",
"this",
"->",
"staticMethods",
";",
"}",
"$",
"this",
"->",
"staticMethods",
"=",
"$",
"this",
"->",
"reflectionClass",
"->",
"getMethods",
"(",
"\\",
"ReflectionMethod",
"::",
"IS_STATIC",
")",
";",
"return",
"$",
"this",
"->",
"staticMethods",
";",
"}"
] | Get an array of all static methods implemented by the current class
Merges trait methods
Filters out this trait
@return array|ReflectionMethod[]
@throws \ReflectionException | [
"Get",
"an",
"array",
"of",
"all",
"static",
"methods",
"implemented",
"by",
"the",
"current",
"class"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/DoctrineStaticMeta.php#L149-L159 |
32,146 | edmondscommerce/doctrine-static-meta | src/DoctrineStaticMeta.php | DoctrineStaticMeta.setTableName | private function setTableName(ClassMetadataBuilder $builder): void
{
$tableName = MappingHelper::getTableNameForEntityFqn($this->reflectionClass->getName());
$builder->setTable($tableName);
} | php | private function setTableName(ClassMetadataBuilder $builder): void
{
$tableName = MappingHelper::getTableNameForEntityFqn($this->reflectionClass->getName());
$builder->setTable($tableName);
} | [
"private",
"function",
"setTableName",
"(",
"ClassMetadataBuilder",
"$",
"builder",
")",
":",
"void",
"{",
"$",
"tableName",
"=",
"MappingHelper",
"::",
"getTableNameForEntityFqn",
"(",
"$",
"this",
"->",
"reflectionClass",
"->",
"getName",
"(",
")",
")",
";",
"$",
"builder",
"->",
"setTable",
"(",
"$",
"tableName",
")",
";",
"}"
] | Sets the table name for the class
@param ClassMetadataBuilder $builder
@SuppressWarnings(PHPMD.StaticAccess) | [
"Sets",
"the",
"table",
"name",
"for",
"the",
"class"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/DoctrineStaticMeta.php#L168-L172 |
32,147 | edmondscommerce/doctrine-static-meta | src/DoctrineStaticMeta.php | DoctrineStaticMeta.getRequiredRelationProperties | public function getRequiredRelationProperties(): array
{
if (null !== $this->requiredRelationProperties) {
return $this->requiredRelationProperties;
}
$traits = $this->reflectionClass->getTraits();
$return = [];
foreach ($traits as $traitName => $traitReflection) {
if (false === \ts\stringContains($traitName, '\\HasRequired')) {
continue;
}
if (false === \ts\stringContains($traitName, '\\Entity\\Relations\\')) {
continue;
}
$property = $traitReflection->getProperties()[0]->getName();
$return[$property] = $this->getTypesFromVarComment(
$property,
$this->getReflectionHelper()->getTraitProvidingProperty($traitReflection, $property)
);
}
$this->requiredRelationProperties = $return;
return $return;
} | php | public function getRequiredRelationProperties(): array
{
if (null !== $this->requiredRelationProperties) {
return $this->requiredRelationProperties;
}
$traits = $this->reflectionClass->getTraits();
$return = [];
foreach ($traits as $traitName => $traitReflection) {
if (false === \ts\stringContains($traitName, '\\HasRequired')) {
continue;
}
if (false === \ts\stringContains($traitName, '\\Entity\\Relations\\')) {
continue;
}
$property = $traitReflection->getProperties()[0]->getName();
$return[$property] = $this->getTypesFromVarComment(
$property,
$this->getReflectionHelper()->getTraitProvidingProperty($traitReflection, $property)
);
}
$this->requiredRelationProperties = $return;
return $return;
} | [
"public",
"function",
"getRequiredRelationProperties",
"(",
")",
":",
"array",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"requiredRelationProperties",
")",
"{",
"return",
"$",
"this",
"->",
"requiredRelationProperties",
";",
"}",
"$",
"traits",
"=",
"$",
"this",
"->",
"reflectionClass",
"->",
"getTraits",
"(",
")",
";",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"traits",
"as",
"$",
"traitName",
"=>",
"$",
"traitReflection",
")",
"{",
"if",
"(",
"false",
"===",
"\\",
"ts",
"\\",
"stringContains",
"(",
"$",
"traitName",
",",
"'\\\\HasRequired'",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"false",
"===",
"\\",
"ts",
"\\",
"stringContains",
"(",
"$",
"traitName",
",",
"'\\\\Entity\\\\Relations\\\\'",
")",
")",
"{",
"continue",
";",
"}",
"$",
"property",
"=",
"$",
"traitReflection",
"->",
"getProperties",
"(",
")",
"[",
"0",
"]",
"->",
"getName",
"(",
")",
";",
"$",
"return",
"[",
"$",
"property",
"]",
"=",
"$",
"this",
"->",
"getTypesFromVarComment",
"(",
"$",
"property",
",",
"$",
"this",
"->",
"getReflectionHelper",
"(",
")",
"->",
"getTraitProvidingProperty",
"(",
"$",
"traitReflection",
",",
"$",
"property",
")",
")",
";",
"}",
"$",
"this",
"->",
"requiredRelationProperties",
"=",
"$",
"return",
";",
"return",
"$",
"return",
";",
"}"
] | Get an array of required relation properties, keyed by the property name and the value being an array of FQNs
for the declared types
@return array [ propertyName => [...types]]
@throws \ReflectionException | [
"Get",
"an",
"array",
"of",
"required",
"relation",
"properties",
"keyed",
"by",
"the",
"property",
"name",
"and",
"the",
"value",
"being",
"an",
"array",
"of",
"FQNs",
"for",
"the",
"declared",
"types"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/DoctrineStaticMeta.php#L199-L223 |
32,148 | edmondscommerce/doctrine-static-meta | src/DoctrineStaticMeta.php | DoctrineStaticMeta.getTypesFromVarComment | private function getTypesFromVarComment(string $property, ReflectionClass $traitReflection): array
{
$docComment = $this->reflectionClass->getProperty($property)->getDocComment();
\preg_match('%@var\s*?(.+)%', $docComment, $matches);
$traitCode = \ts\file_get_contents($traitReflection->getFileName());
$types = \explode('|', $matches[1]);
$return = [];
foreach ($types as $type) {
$type = \trim($type);
if ('null' === $type) {
continue;
}
if ('ArrayCollection' === $type) {
continue;
}
$arrayNotation = '';
if ('[]' === substr($type, -2)) {
$type = substr($type, 0, -2);
$arrayNotation = '[]';
}
$pattern = "%^use (.+?)\\\\${type}(;| |\[)%m";
\preg_match($pattern, $traitCode, $matches);
if (!isset($matches[1])) {
throw new \RuntimeException(
'Failed finding match for type ' . $type . ' in ' . $traitReflection->getFileName()
);
}
$return[] = $matches[1] . '\\' . $type . $arrayNotation;
}
return $return;
} | php | private function getTypesFromVarComment(string $property, ReflectionClass $traitReflection): array
{
$docComment = $this->reflectionClass->getProperty($property)->getDocComment();
\preg_match('%@var\s*?(.+)%', $docComment, $matches);
$traitCode = \ts\file_get_contents($traitReflection->getFileName());
$types = \explode('|', $matches[1]);
$return = [];
foreach ($types as $type) {
$type = \trim($type);
if ('null' === $type) {
continue;
}
if ('ArrayCollection' === $type) {
continue;
}
$arrayNotation = '';
if ('[]' === substr($type, -2)) {
$type = substr($type, 0, -2);
$arrayNotation = '[]';
}
$pattern = "%^use (.+?)\\\\${type}(;| |\[)%m";
\preg_match($pattern, $traitCode, $matches);
if (!isset($matches[1])) {
throw new \RuntimeException(
'Failed finding match for type ' . $type . ' in ' . $traitReflection->getFileName()
);
}
$return[] = $matches[1] . '\\' . $type . $arrayNotation;
}
return $return;
} | [
"private",
"function",
"getTypesFromVarComment",
"(",
"string",
"$",
"property",
",",
"ReflectionClass",
"$",
"traitReflection",
")",
":",
"array",
"{",
"$",
"docComment",
"=",
"$",
"this",
"->",
"reflectionClass",
"->",
"getProperty",
"(",
"$",
"property",
")",
"->",
"getDocComment",
"(",
")",
";",
"\\",
"preg_match",
"(",
"'%@var\\s*?(.+)%'",
",",
"$",
"docComment",
",",
"$",
"matches",
")",
";",
"$",
"traitCode",
"=",
"\\",
"ts",
"\\",
"file_get_contents",
"(",
"$",
"traitReflection",
"->",
"getFileName",
"(",
")",
")",
";",
"$",
"types",
"=",
"\\",
"explode",
"(",
"'|'",
",",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"types",
"as",
"$",
"type",
")",
"{",
"$",
"type",
"=",
"\\",
"trim",
"(",
"$",
"type",
")",
";",
"if",
"(",
"'null'",
"===",
"$",
"type",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"'ArrayCollection'",
"===",
"$",
"type",
")",
"{",
"continue",
";",
"}",
"$",
"arrayNotation",
"=",
"''",
";",
"if",
"(",
"'[]'",
"===",
"substr",
"(",
"$",
"type",
",",
"-",
"2",
")",
")",
"{",
"$",
"type",
"=",
"substr",
"(",
"$",
"type",
",",
"0",
",",
"-",
"2",
")",
";",
"$",
"arrayNotation",
"=",
"'[]'",
";",
"}",
"$",
"pattern",
"=",
"\"%^use (.+?)\\\\\\\\${type}(;| |\\[)%m\"",
";",
"\\",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"traitCode",
",",
"$",
"matches",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Failed finding match for type '",
".",
"$",
"type",
".",
"' in '",
".",
"$",
"traitReflection",
"->",
"getFileName",
"(",
")",
")",
";",
"}",
"$",
"return",
"[",
"]",
"=",
"$",
"matches",
"[",
"1",
"]",
".",
"'\\\\'",
".",
"$",
"type",
".",
"$",
"arrayNotation",
";",
"}",
"return",
"$",
"return",
";",
"}"
] | Parse the docblock for a property and get the type, then read the source code to resolve the short type to the
FQN of the type. Roll on PHP 7.3
@param string $property
@param ReflectionClass $traitReflection
@return array | [
"Parse",
"the",
"docblock",
"for",
"a",
"property",
"and",
"get",
"the",
"type",
"then",
"read",
"the",
"source",
"code",
"to",
"resolve",
"the",
"short",
"type",
"to",
"the",
"FQN",
"of",
"the",
"type",
".",
"Roll",
"on",
"PHP",
"7",
".",
"3"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/DoctrineStaticMeta.php#L235-L266 |
32,149 | edmondscommerce/doctrine-static-meta | src/DoctrineStaticMeta.php | DoctrineStaticMeta.getEmbeddableProperties | public function getEmbeddableProperties(): array
{
if (null !== $this->embeddableProperties) {
return $this->embeddableProperties;
}
$traits = $this->reflectionClass->getTraits();
$return = [];
foreach ($traits as $traitName => $traitReflection) {
if (\ts\stringContains($traitName, '\\Entity\\Embeddable\\Traits')) {
$property = $traitReflection->getProperties()[0]->getName();
$embeddableObjectInterfaceFqn = $this->getTypesFromVarComment(
$property,
$this->getReflectionHelper()->getTraitProvidingProperty($traitReflection, $property)
)[0];
$embeddableObject = $this->getNamespaceHelper()
->getEmbeddableObjectFqnFromEmbeddableObjectInterfaceFqn(
$embeddableObjectInterfaceFqn
);
$return[$property] = $embeddableObject;
}
}
return $return;
} | php | public function getEmbeddableProperties(): array
{
if (null !== $this->embeddableProperties) {
return $this->embeddableProperties;
}
$traits = $this->reflectionClass->getTraits();
$return = [];
foreach ($traits as $traitName => $traitReflection) {
if (\ts\stringContains($traitName, '\\Entity\\Embeddable\\Traits')) {
$property = $traitReflection->getProperties()[0]->getName();
$embeddableObjectInterfaceFqn = $this->getTypesFromVarComment(
$property,
$this->getReflectionHelper()->getTraitProvidingProperty($traitReflection, $property)
)[0];
$embeddableObject = $this->getNamespaceHelper()
->getEmbeddableObjectFqnFromEmbeddableObjectInterfaceFqn(
$embeddableObjectInterfaceFqn
);
$return[$property] = $embeddableObject;
}
}
return $return;
} | [
"public",
"function",
"getEmbeddableProperties",
"(",
")",
":",
"array",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"embeddableProperties",
")",
"{",
"return",
"$",
"this",
"->",
"embeddableProperties",
";",
"}",
"$",
"traits",
"=",
"$",
"this",
"->",
"reflectionClass",
"->",
"getTraits",
"(",
")",
";",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"traits",
"as",
"$",
"traitName",
"=>",
"$",
"traitReflection",
")",
"{",
"if",
"(",
"\\",
"ts",
"\\",
"stringContains",
"(",
"$",
"traitName",
",",
"'\\\\Entity\\\\Embeddable\\\\Traits'",
")",
")",
"{",
"$",
"property",
"=",
"$",
"traitReflection",
"->",
"getProperties",
"(",
")",
"[",
"0",
"]",
"->",
"getName",
"(",
")",
";",
"$",
"embeddableObjectInterfaceFqn",
"=",
"$",
"this",
"->",
"getTypesFromVarComment",
"(",
"$",
"property",
",",
"$",
"this",
"->",
"getReflectionHelper",
"(",
")",
"->",
"getTraitProvidingProperty",
"(",
"$",
"traitReflection",
",",
"$",
"property",
")",
")",
"[",
"0",
"]",
";",
"$",
"embeddableObject",
"=",
"$",
"this",
"->",
"getNamespaceHelper",
"(",
")",
"->",
"getEmbeddableObjectFqnFromEmbeddableObjectInterfaceFqn",
"(",
"$",
"embeddableObjectInterfaceFqn",
")",
";",
"$",
"return",
"[",
"$",
"property",
"]",
"=",
"$",
"embeddableObject",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] | Get an array of property names that contain embeddable objects
@return array
@throws \ReflectionException | [
"Get",
"an",
"array",
"of",
"property",
"names",
"that",
"contain",
"embeddable",
"objects"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/DoctrineStaticMeta.php#L292-L315 |
32,150 | edmondscommerce/doctrine-static-meta | src/DoctrineStaticMeta.php | DoctrineStaticMeta.getPlural | public function getPlural(): string
{
try {
if (null === $this->plural) {
$singular = $this->getSingular();
$this->plural = Inflector::pluralize($singular);
}
return $this->plural;
} catch (\Exception $e) {
throw new DoctrineStaticMetaException(
'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
} | php | public function getPlural(): string
{
try {
if (null === $this->plural) {
$singular = $this->getSingular();
$this->plural = Inflector::pluralize($singular);
}
return $this->plural;
} catch (\Exception $e) {
throw new DoctrineStaticMetaException(
'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
} | [
"public",
"function",
"getPlural",
"(",
")",
":",
"string",
"{",
"try",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"plural",
")",
"{",
"$",
"singular",
"=",
"$",
"this",
"->",
"getSingular",
"(",
")",
";",
"$",
"this",
"->",
"plural",
"=",
"Inflector",
"::",
"pluralize",
"(",
"$",
"singular",
")",
";",
"}",
"return",
"$",
"this",
"->",
"plural",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"DoctrineStaticMetaException",
"(",
"'Exception in '",
".",
"__METHOD__",
".",
"': '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Get the property name the Entity is mapped by when plural
Override it in your entity class if you are using an Entity class name that doesn't pluralize nicely
@return string
@throws DoctrineStaticMetaException
@SuppressWarnings(PHPMD.StaticAccess) | [
"Get",
"the",
"property",
"name",
"the",
"Entity",
"is",
"mapped",
"by",
"when",
"plural"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/DoctrineStaticMeta.php#L326-L342 |
32,151 | edmondscommerce/doctrine-static-meta | src/DoctrineStaticMeta.php | DoctrineStaticMeta.getSingular | public function getSingular(): string
{
try {
if (null === $this->singular) {
$reflectionClass = $this->getReflectionClass();
$shortName = $reflectionClass->getShortName();
$singularShortName = MappingHelper::singularize($shortName);
$namespaceName = $reflectionClass->getNamespaceName();
$namespaceParts = \explode(AbstractGenerator::ENTITIES_FOLDER_NAME, $namespaceName);
$entityNamespace = \array_pop($namespaceParts);
$namespacedShortName = \preg_replace(
'/\\\\/',
'',
$entityNamespace . $singularShortName
);
$this->singular = \lcfirst($namespacedShortName);
}
return $this->singular;
} catch (\Exception $e) {
throw new DoctrineStaticMetaException(
'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
} | php | public function getSingular(): string
{
try {
if (null === $this->singular) {
$reflectionClass = $this->getReflectionClass();
$shortName = $reflectionClass->getShortName();
$singularShortName = MappingHelper::singularize($shortName);
$namespaceName = $reflectionClass->getNamespaceName();
$namespaceParts = \explode(AbstractGenerator::ENTITIES_FOLDER_NAME, $namespaceName);
$entityNamespace = \array_pop($namespaceParts);
$namespacedShortName = \preg_replace(
'/\\\\/',
'',
$entityNamespace . $singularShortName
);
$this->singular = \lcfirst($namespacedShortName);
}
return $this->singular;
} catch (\Exception $e) {
throw new DoctrineStaticMetaException(
'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
} | [
"public",
"function",
"getSingular",
"(",
")",
":",
"string",
"{",
"try",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"singular",
")",
"{",
"$",
"reflectionClass",
"=",
"$",
"this",
"->",
"getReflectionClass",
"(",
")",
";",
"$",
"shortName",
"=",
"$",
"reflectionClass",
"->",
"getShortName",
"(",
")",
";",
"$",
"singularShortName",
"=",
"MappingHelper",
"::",
"singularize",
"(",
"$",
"shortName",
")",
";",
"$",
"namespaceName",
"=",
"$",
"reflectionClass",
"->",
"getNamespaceName",
"(",
")",
";",
"$",
"namespaceParts",
"=",
"\\",
"explode",
"(",
"AbstractGenerator",
"::",
"ENTITIES_FOLDER_NAME",
",",
"$",
"namespaceName",
")",
";",
"$",
"entityNamespace",
"=",
"\\",
"array_pop",
"(",
"$",
"namespaceParts",
")",
";",
"$",
"namespacedShortName",
"=",
"\\",
"preg_replace",
"(",
"'/\\\\\\\\/'",
",",
"''",
",",
"$",
"entityNamespace",
".",
"$",
"singularShortName",
")",
";",
"$",
"this",
"->",
"singular",
"=",
"\\",
"lcfirst",
"(",
"$",
"namespacedShortName",
")",
";",
"}",
"return",
"$",
"this",
"->",
"singular",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"DoctrineStaticMetaException",
"(",
"'Exception in '",
".",
"__METHOD__",
".",
"': '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Get the property the name the Entity is mapped by when singular
@return string
@throws DoctrineStaticMetaException
@SuppressWarnings(PHPMD.StaticAccess) | [
"Get",
"the",
"property",
"the",
"name",
"the",
"Entity",
"is",
"mapped",
"by",
"when",
"singular"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/DoctrineStaticMeta.php#L351-L381 |
32,152 | edmondscommerce/doctrine-static-meta | src/DoctrineStaticMeta.php | DoctrineStaticMeta.getSetters | public function getSetters(): array
{
if (null !== $this->setters) {
return $this->setters;
}
$skip = [
'addPropertyChangedListener' => true,
'setEntityCollectionAndNotify' => true,
'addToEntityCollectionAndNotify' => true,
'setEntityAndNotify' => true,
];
$this->setters = [];
$reflectionClass = $this->getReflectionClass();
foreach ($reflectionClass->getMethods(
\ReflectionMethod::IS_PRIVATE | \ReflectionMethod::IS_PUBLIC
) as $method) {
$methodName = $method->getName();
if (isset($skip[$methodName])) {
continue;
}
if (\ts\stringStartsWith($methodName, 'set')) {
$this->setters[$this->getGetterForSetter($methodName)] = $methodName;
continue;
}
}
return $this->setters;
} | php | public function getSetters(): array
{
if (null !== $this->setters) {
return $this->setters;
}
$skip = [
'addPropertyChangedListener' => true,
'setEntityCollectionAndNotify' => true,
'addToEntityCollectionAndNotify' => true,
'setEntityAndNotify' => true,
];
$this->setters = [];
$reflectionClass = $this->getReflectionClass();
foreach ($reflectionClass->getMethods(
\ReflectionMethod::IS_PRIVATE | \ReflectionMethod::IS_PUBLIC
) as $method) {
$methodName = $method->getName();
if (isset($skip[$methodName])) {
continue;
}
if (\ts\stringStartsWith($methodName, 'set')) {
$this->setters[$this->getGetterForSetter($methodName)] = $methodName;
continue;
}
}
return $this->setters;
} | [
"public",
"function",
"getSetters",
"(",
")",
":",
"array",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"setters",
")",
"{",
"return",
"$",
"this",
"->",
"setters",
";",
"}",
"$",
"skip",
"=",
"[",
"'addPropertyChangedListener'",
"=>",
"true",
",",
"'setEntityCollectionAndNotify'",
"=>",
"true",
",",
"'addToEntityCollectionAndNotify'",
"=>",
"true",
",",
"'setEntityAndNotify'",
"=>",
"true",
",",
"]",
";",
"$",
"this",
"->",
"setters",
"=",
"[",
"]",
";",
"$",
"reflectionClass",
"=",
"$",
"this",
"->",
"getReflectionClass",
"(",
")",
";",
"foreach",
"(",
"$",
"reflectionClass",
"->",
"getMethods",
"(",
"\\",
"ReflectionMethod",
"::",
"IS_PRIVATE",
"|",
"\\",
"ReflectionMethod",
"::",
"IS_PUBLIC",
")",
"as",
"$",
"method",
")",
"{",
"$",
"methodName",
"=",
"$",
"method",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"skip",
"[",
"$",
"methodName",
"]",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"\\",
"ts",
"\\",
"stringStartsWith",
"(",
"$",
"methodName",
",",
"'set'",
")",
")",
"{",
"$",
"this",
"->",
"setters",
"[",
"$",
"this",
"->",
"getGetterForSetter",
"(",
"$",
"methodName",
")",
"]",
"=",
"$",
"methodName",
";",
"continue",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"setters",
";",
"}"
] | Get an array of setters by name
@return array|string[] | [
"Get",
"an",
"array",
"of",
"setters",
"by",
"name"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/DoctrineStaticMeta.php#L407-L434 |
32,153 | edmondscommerce/doctrine-static-meta | src/DoctrineStaticMeta.php | DoctrineStaticMeta.getGetters | public function getGetters(): array
{
if (null !== $this->getters) {
return $this->getters;
}
$skip = [
'getEntityFqn' => true,
'getDoctrineStaticMeta' => true,
'isValid' => true,
'getValidator' => true,
];
$this->getters = [];
$reflectionClass = $this->getReflectionClass();
foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
$methodName = $method->getName();
if (isset($skip[$methodName])) {
continue;
}
if (\ts\stringStartsWith($methodName, 'get')) {
$this->getters[] = $methodName;
continue;
}
if (\ts\stringStartsWith($methodName, 'is')) {
$this->getters[] = $methodName;
continue;
}
if (\ts\stringStartsWith($methodName, 'has')) {
$this->getters[] = $methodName;
continue;
}
}
return $this->getters;
} | php | public function getGetters(): array
{
if (null !== $this->getters) {
return $this->getters;
}
$skip = [
'getEntityFqn' => true,
'getDoctrineStaticMeta' => true,
'isValid' => true,
'getValidator' => true,
];
$this->getters = [];
$reflectionClass = $this->getReflectionClass();
foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
$methodName = $method->getName();
if (isset($skip[$methodName])) {
continue;
}
if (\ts\stringStartsWith($methodName, 'get')) {
$this->getters[] = $methodName;
continue;
}
if (\ts\stringStartsWith($methodName, 'is')) {
$this->getters[] = $methodName;
continue;
}
if (\ts\stringStartsWith($methodName, 'has')) {
$this->getters[] = $methodName;
continue;
}
}
return $this->getters;
} | [
"public",
"function",
"getGetters",
"(",
")",
":",
"array",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"getters",
")",
"{",
"return",
"$",
"this",
"->",
"getters",
";",
"}",
"$",
"skip",
"=",
"[",
"'getEntityFqn'",
"=>",
"true",
",",
"'getDoctrineStaticMeta'",
"=>",
"true",
",",
"'isValid'",
"=>",
"true",
",",
"'getValidator'",
"=>",
"true",
",",
"]",
";",
"$",
"this",
"->",
"getters",
"=",
"[",
"]",
";",
"$",
"reflectionClass",
"=",
"$",
"this",
"->",
"getReflectionClass",
"(",
")",
";",
"foreach",
"(",
"$",
"reflectionClass",
"->",
"getMethods",
"(",
"\\",
"ReflectionMethod",
"::",
"IS_PUBLIC",
")",
"as",
"$",
"method",
")",
"{",
"$",
"methodName",
"=",
"$",
"method",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"skip",
"[",
"$",
"methodName",
"]",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"\\",
"ts",
"\\",
"stringStartsWith",
"(",
"$",
"methodName",
",",
"'get'",
")",
")",
"{",
"$",
"this",
"->",
"getters",
"[",
"]",
"=",
"$",
"methodName",
";",
"continue",
";",
"}",
"if",
"(",
"\\",
"ts",
"\\",
"stringStartsWith",
"(",
"$",
"methodName",
",",
"'is'",
")",
")",
"{",
"$",
"this",
"->",
"getters",
"[",
"]",
"=",
"$",
"methodName",
";",
"continue",
";",
"}",
"if",
"(",
"\\",
"ts",
"\\",
"stringStartsWith",
"(",
"$",
"methodName",
",",
"'has'",
")",
")",
"{",
"$",
"this",
"->",
"getters",
"[",
"]",
"=",
"$",
"methodName",
";",
"continue",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"getters",
";",
"}"
] | Get an array of getters by name
@return array|string[]
@throws \ReflectionException | [
"Get",
"an",
"array",
"of",
"getters",
"by",
"name"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/DoctrineStaticMeta.php#L471-L505 |
32,154 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopDiscount.class.php | TShopDiscount.IsActive | public function IsActive()
{
$sToday = date('Y-m-d H:i:s');
$bIsActive = ($this->fieldActive && ($this->fieldActiveFrom <= $sToday && ($this->fieldActiveTo >= $sToday || '0000-00-00 00:00:00' == $this->fieldActiveTo)));
return $bIsActive;
} | php | public function IsActive()
{
$sToday = date('Y-m-d H:i:s');
$bIsActive = ($this->fieldActive && ($this->fieldActiveFrom <= $sToday && ($this->fieldActiveTo >= $sToday || '0000-00-00 00:00:00' == $this->fieldActiveTo)));
return $bIsActive;
} | [
"public",
"function",
"IsActive",
"(",
")",
"{",
"$",
"sToday",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
")",
";",
"$",
"bIsActive",
"=",
"(",
"$",
"this",
"->",
"fieldActive",
"&&",
"(",
"$",
"this",
"->",
"fieldActiveFrom",
"<=",
"$",
"sToday",
"&&",
"(",
"$",
"this",
"->",
"fieldActiveTo",
">=",
"$",
"sToday",
"||",
"'0000-00-00 00:00:00'",
"==",
"$",
"this",
"->",
"fieldActiveTo",
")",
")",
")",
";",
"return",
"$",
"bIsActive",
";",
"}"
] | return true if the discount is active.
@return bool | [
"return",
"true",
"if",
"the",
"discount",
"is",
"active",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopDiscount.class.php#L70-L76 |
32,155 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopDiscount.class.php | TShopDiscount.GetValue | public function GetValue()
{
$dValue = $this->fieldValue;
$oBasket = TShopBasket::GetInstance();
$dBasketValueApplicableForDiscount = $oBasket->GetBasketSumForDiscount($this);
$dValue = $this->GetValueForBasketValue($dBasketValueApplicableForDiscount);
return $dValue;
} | php | public function GetValue()
{
$dValue = $this->fieldValue;
$oBasket = TShopBasket::GetInstance();
$dBasketValueApplicableForDiscount = $oBasket->GetBasketSumForDiscount($this);
$dValue = $this->GetValueForBasketValue($dBasketValueApplicableForDiscount);
return $dValue;
} | [
"public",
"function",
"GetValue",
"(",
")",
"{",
"$",
"dValue",
"=",
"$",
"this",
"->",
"fieldValue",
";",
"$",
"oBasket",
"=",
"TShopBasket",
"::",
"GetInstance",
"(",
")",
";",
"$",
"dBasketValueApplicableForDiscount",
"=",
"$",
"oBasket",
"->",
"GetBasketSumForDiscount",
"(",
"$",
"this",
")",
";",
"$",
"dValue",
"=",
"$",
"this",
"->",
"GetValueForBasketValue",
"(",
"$",
"dBasketValueApplicableForDiscount",
")",
";",
"return",
"$",
"dValue",
";",
"}"
] | Returns the value of the discount - takes the current basket and user into consideration.
@return float | [
"Returns",
"the",
"value",
"of",
"the",
"discount",
"-",
"takes",
"the",
"current",
"basket",
"and",
"user",
"into",
"consideration",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopDiscount.class.php#L173-L181 |
32,156 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopDiscount.class.php | TShopDiscount.AllowDiscountForArticle | public function AllowDiscountForArticle(TdbShopArticle $oArticle)
{
$bMayBeUsed = true;
if ($oArticle->fieldExcludeFromDiscounts) {
$bMayBeUsed = false;
}
// check article restrictions
if ($bMayBeUsed) {
$aArticleRestrictions = $this->GetFieldShopArticleWithInverseEmptySelectionLogicIdList();
if (null === $aArticleRestrictions || (count($aArticleRestrictions) > 0 && !in_array($oArticle->id, $aArticleRestrictions))) {
$bMayBeUsed = false;
}
}
// check category restrictions
if ($bMayBeUsed) {
$aCategoryRestrictions = $this->GetFieldShopCategoryWithInverseEmptySelectionLogicIdList();
if (null === $aCategoryRestrictions || (count($aCategoryRestrictions) > 0 && !$oArticle->IsInCategory($aCategoryRestrictions))) {
$bMayBeUsed = false;
}
}
return $bMayBeUsed;
} | php | public function AllowDiscountForArticle(TdbShopArticle $oArticle)
{
$bMayBeUsed = true;
if ($oArticle->fieldExcludeFromDiscounts) {
$bMayBeUsed = false;
}
// check article restrictions
if ($bMayBeUsed) {
$aArticleRestrictions = $this->GetFieldShopArticleWithInverseEmptySelectionLogicIdList();
if (null === $aArticleRestrictions || (count($aArticleRestrictions) > 0 && !in_array($oArticle->id, $aArticleRestrictions))) {
$bMayBeUsed = false;
}
}
// check category restrictions
if ($bMayBeUsed) {
$aCategoryRestrictions = $this->GetFieldShopCategoryWithInverseEmptySelectionLogicIdList();
if (null === $aCategoryRestrictions || (count($aCategoryRestrictions) > 0 && !$oArticle->IsInCategory($aCategoryRestrictions))) {
$bMayBeUsed = false;
}
}
return $bMayBeUsed;
} | [
"public",
"function",
"AllowDiscountForArticle",
"(",
"TdbShopArticle",
"$",
"oArticle",
")",
"{",
"$",
"bMayBeUsed",
"=",
"true",
";",
"if",
"(",
"$",
"oArticle",
"->",
"fieldExcludeFromDiscounts",
")",
"{",
"$",
"bMayBeUsed",
"=",
"false",
";",
"}",
"// check article restrictions",
"if",
"(",
"$",
"bMayBeUsed",
")",
"{",
"$",
"aArticleRestrictions",
"=",
"$",
"this",
"->",
"GetFieldShopArticleWithInverseEmptySelectionLogicIdList",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"aArticleRestrictions",
"||",
"(",
"count",
"(",
"$",
"aArticleRestrictions",
")",
">",
"0",
"&&",
"!",
"in_array",
"(",
"$",
"oArticle",
"->",
"id",
",",
"$",
"aArticleRestrictions",
")",
")",
")",
"{",
"$",
"bMayBeUsed",
"=",
"false",
";",
"}",
"}",
"// check category restrictions",
"if",
"(",
"$",
"bMayBeUsed",
")",
"{",
"$",
"aCategoryRestrictions",
"=",
"$",
"this",
"->",
"GetFieldShopCategoryWithInverseEmptySelectionLogicIdList",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"aCategoryRestrictions",
"||",
"(",
"count",
"(",
"$",
"aCategoryRestrictions",
")",
">",
"0",
"&&",
"!",
"$",
"oArticle",
"->",
"IsInCategory",
"(",
"$",
"aCategoryRestrictions",
")",
")",
")",
"{",
"$",
"bMayBeUsed",
"=",
"false",
";",
"}",
"}",
"return",
"$",
"bMayBeUsed",
";",
"}"
] | return true if the discount may be used for the article.
@param TdbShopArticle $oArticle
@return bool | [
"return",
"true",
"if",
"the",
"discount",
"may",
"be",
"used",
"for",
"the",
"article",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopDiscount.class.php#L212-L236 |
32,157 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopDiscount.class.php | TShopDiscount.ClearCacheOnAllAffectedArticles | public function ClearCacheOnAllAffectedArticles()
{
$iStartOperation = time();
$aArticleRestrictions = $this->GetMLTIdList('shop_article_mlt');
foreach ($aArticleRestrictions as $sArticelId) {
TCacheManager::PerformeTableChange('shop_article', $sArticelId);
}
$aCategoryRestrictons = $this->GetMLTIdList('shop_category_mlt');
$databaseConnection = $this->getDatabaseConnection();
if (count($aCategoryRestrictons) > 0) {
$quotedCategoryRestrictions = implode(',', array_map(array($databaseConnection, 'quote'), $aCategoryRestrictons));
$query = "SELECT `shop_article`.`id`
FROM `shop_article`
LEFT JOIN `shop_article_shop_category_mlt` ON `shop_article`.`id` = `shop_article_shop_category_mlt`.`source_id`
WHERE `shop_article`.`shop_category_id` IN ($quotedCategoryRestrictions)
OR `shop_article_shop_category_mlt`.`target_id` IN ($quotedCategoryRestrictions)
GROUP BY `shop_article`.`id`
";
$tRes = MySqlLegacySupport::getInstance()->query($query);
while ($aRes = MySqlLegacySupport::getInstance()->fetch_assoc($tRes)) {
TCacheManager::PerformeTableChange('shop_article', $aRes['id']);
}
}
if (0 === count($aArticleRestrictions) && 0 === count($aCategoryRestrictons)) {
TCacheManager::PerformeTableChange('shop_article', null);
}
$databaseConnection->update($this->table, array(
'cache_clear_last_executed' => date('Y-m-d H:i:s', $iStartOperation),
), array(
'id' => $this->id,
));
} | php | public function ClearCacheOnAllAffectedArticles()
{
$iStartOperation = time();
$aArticleRestrictions = $this->GetMLTIdList('shop_article_mlt');
foreach ($aArticleRestrictions as $sArticelId) {
TCacheManager::PerformeTableChange('shop_article', $sArticelId);
}
$aCategoryRestrictons = $this->GetMLTIdList('shop_category_mlt');
$databaseConnection = $this->getDatabaseConnection();
if (count($aCategoryRestrictons) > 0) {
$quotedCategoryRestrictions = implode(',', array_map(array($databaseConnection, 'quote'), $aCategoryRestrictons));
$query = "SELECT `shop_article`.`id`
FROM `shop_article`
LEFT JOIN `shop_article_shop_category_mlt` ON `shop_article`.`id` = `shop_article_shop_category_mlt`.`source_id`
WHERE `shop_article`.`shop_category_id` IN ($quotedCategoryRestrictions)
OR `shop_article_shop_category_mlt`.`target_id` IN ($quotedCategoryRestrictions)
GROUP BY `shop_article`.`id`
";
$tRes = MySqlLegacySupport::getInstance()->query($query);
while ($aRes = MySqlLegacySupport::getInstance()->fetch_assoc($tRes)) {
TCacheManager::PerformeTableChange('shop_article', $aRes['id']);
}
}
if (0 === count($aArticleRestrictions) && 0 === count($aCategoryRestrictons)) {
TCacheManager::PerformeTableChange('shop_article', null);
}
$databaseConnection->update($this->table, array(
'cache_clear_last_executed' => date('Y-m-d H:i:s', $iStartOperation),
), array(
'id' => $this->id,
));
} | [
"public",
"function",
"ClearCacheOnAllAffectedArticles",
"(",
")",
"{",
"$",
"iStartOperation",
"=",
"time",
"(",
")",
";",
"$",
"aArticleRestrictions",
"=",
"$",
"this",
"->",
"GetMLTIdList",
"(",
"'shop_article_mlt'",
")",
";",
"foreach",
"(",
"$",
"aArticleRestrictions",
"as",
"$",
"sArticelId",
")",
"{",
"TCacheManager",
"::",
"PerformeTableChange",
"(",
"'shop_article'",
",",
"$",
"sArticelId",
")",
";",
"}",
"$",
"aCategoryRestrictons",
"=",
"$",
"this",
"->",
"GetMLTIdList",
"(",
"'shop_category_mlt'",
")",
";",
"$",
"databaseConnection",
"=",
"$",
"this",
"->",
"getDatabaseConnection",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"aCategoryRestrictons",
")",
">",
"0",
")",
"{",
"$",
"quotedCategoryRestrictions",
"=",
"implode",
"(",
"','",
",",
"array_map",
"(",
"array",
"(",
"$",
"databaseConnection",
",",
"'quote'",
")",
",",
"$",
"aCategoryRestrictons",
")",
")",
";",
"$",
"query",
"=",
"\"SELECT `shop_article`.`id`\n FROM `shop_article`\n LEFT JOIN `shop_article_shop_category_mlt` ON `shop_article`.`id` = `shop_article_shop_category_mlt`.`source_id`\n WHERE `shop_article`.`shop_category_id` IN ($quotedCategoryRestrictions)\n OR `shop_article_shop_category_mlt`.`target_id` IN ($quotedCategoryRestrictions)\n GROUP BY `shop_article`.`id`\n \"",
";",
"$",
"tRes",
"=",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"query",
"(",
"$",
"query",
")",
";",
"while",
"(",
"$",
"aRes",
"=",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"fetch_assoc",
"(",
"$",
"tRes",
")",
")",
"{",
"TCacheManager",
"::",
"PerformeTableChange",
"(",
"'shop_article'",
",",
"$",
"aRes",
"[",
"'id'",
"]",
")",
";",
"}",
"}",
"if",
"(",
"0",
"===",
"count",
"(",
"$",
"aArticleRestrictions",
")",
"&&",
"0",
"===",
"count",
"(",
"$",
"aCategoryRestrictons",
")",
")",
"{",
"TCacheManager",
"::",
"PerformeTableChange",
"(",
"'shop_article'",
",",
"null",
")",
";",
"}",
"$",
"databaseConnection",
"->",
"update",
"(",
"$",
"this",
"->",
"table",
",",
"array",
"(",
"'cache_clear_last_executed'",
"=>",
"date",
"(",
"'Y-m-d H:i:s'",
",",
"$",
"iStartOperation",
")",
",",
")",
",",
"array",
"(",
"'id'",
"=>",
"$",
"this",
"->",
"id",
",",
")",
")",
";",
"}"
] | trigger a clear cache on all related articles. | [
"trigger",
"a",
"clear",
"cache",
"on",
"all",
"related",
"articles",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopDiscount.class.php#L345-L379 |
32,158 | chameleon-system/chameleon-shop | src/ShopBundle/mappers/order/TPkgShopMapper_OrderArticleList.class.php | TPkgShopMapper_OrderArticleList.getArticleImageId | protected function getArticleImageId(TdbShopArticle $oArticle, IMapperCacheTriggerRestricted $oCacheTriggerManager, $bCachingEnabled, $sImageSizeName = 'basket')
{
$sImageId = '';
if (null !== $oArticle) {
$oImage = $oArticle->GetImagePreviewObject($sImageSizeName);
if (null !== $oImage) {
$sImageId = $oImage->fieldCmsMediaId;
}
if (empty($sImageId) || (is_numeric($sImageId) && $sImageId < 100)) {
$oPrimaryImage = $oArticle->GetPrimaryImage();
if (null !== $oPrimaryImage) {
$oImage = $oPrimaryImage->GetImage(0, 'images', true);
if (null !== $oImage) {
$sImageId = $oImage->id;
if ($bCachingEnabled) {
$oCacheTriggerManager->addTrigger('cms_media', $sImageId);
}
}
}
} else {
if ($bCachingEnabled) {
$oCacheTriggerManager->addTrigger('cms_media', $sImageId);
}
}
}
return $sImageId;
} | php | protected function getArticleImageId(TdbShopArticle $oArticle, IMapperCacheTriggerRestricted $oCacheTriggerManager, $bCachingEnabled, $sImageSizeName = 'basket')
{
$sImageId = '';
if (null !== $oArticle) {
$oImage = $oArticle->GetImagePreviewObject($sImageSizeName);
if (null !== $oImage) {
$sImageId = $oImage->fieldCmsMediaId;
}
if (empty($sImageId) || (is_numeric($sImageId) && $sImageId < 100)) {
$oPrimaryImage = $oArticle->GetPrimaryImage();
if (null !== $oPrimaryImage) {
$oImage = $oPrimaryImage->GetImage(0, 'images', true);
if (null !== $oImage) {
$sImageId = $oImage->id;
if ($bCachingEnabled) {
$oCacheTriggerManager->addTrigger('cms_media', $sImageId);
}
}
}
} else {
if ($bCachingEnabled) {
$oCacheTriggerManager->addTrigger('cms_media', $sImageId);
}
}
}
return $sImageId;
} | [
"protected",
"function",
"getArticleImageId",
"(",
"TdbShopArticle",
"$",
"oArticle",
",",
"IMapperCacheTriggerRestricted",
"$",
"oCacheTriggerManager",
",",
"$",
"bCachingEnabled",
",",
"$",
"sImageSizeName",
"=",
"'basket'",
")",
"{",
"$",
"sImageId",
"=",
"''",
";",
"if",
"(",
"null",
"!==",
"$",
"oArticle",
")",
"{",
"$",
"oImage",
"=",
"$",
"oArticle",
"->",
"GetImagePreviewObject",
"(",
"$",
"sImageSizeName",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"oImage",
")",
"{",
"$",
"sImageId",
"=",
"$",
"oImage",
"->",
"fieldCmsMediaId",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"sImageId",
")",
"||",
"(",
"is_numeric",
"(",
"$",
"sImageId",
")",
"&&",
"$",
"sImageId",
"<",
"100",
")",
")",
"{",
"$",
"oPrimaryImage",
"=",
"$",
"oArticle",
"->",
"GetPrimaryImage",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"oPrimaryImage",
")",
"{",
"$",
"oImage",
"=",
"$",
"oPrimaryImage",
"->",
"GetImage",
"(",
"0",
",",
"'images'",
",",
"true",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"oImage",
")",
"{",
"$",
"sImageId",
"=",
"$",
"oImage",
"->",
"id",
";",
"if",
"(",
"$",
"bCachingEnabled",
")",
"{",
"$",
"oCacheTriggerManager",
"->",
"addTrigger",
"(",
"'cms_media'",
",",
"$",
"sImageId",
")",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"bCachingEnabled",
")",
"{",
"$",
"oCacheTriggerManager",
"->",
"addTrigger",
"(",
"'cms_media'",
",",
"$",
"sImageId",
")",
";",
"}",
"}",
"}",
"return",
"$",
"sImageId",
";",
"}"
] | get the image id of connected article for given order item in the dimensions defined by the given image size identifier.
@param TdbShopArticle $oArticle
@param IMapperCacheTriggerRestricted $oCacheTriggerManager
@param bool $bCachingEnabled
@param string $sImageSizeName
@return string empty string or image id | [
"get",
"the",
"image",
"id",
"of",
"connected",
"article",
"for",
"given",
"order",
"item",
"in",
"the",
"dimensions",
"defined",
"by",
"the",
"given",
"image",
"size",
"identifier",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/mappers/order/TPkgShopMapper_OrderArticleList.class.php#L109-L136 |
32,159 | Erebot/Erebot | src/Config/Proxy.php | Proxy.parseBoolHelper | public static function parseBoolHelper($value)
{
$value = strtolower($value);
if (in_array($value, array('true', '1', 'on', 'yes'), true)) {
return true;
}
if (in_array($value, array('false', '0', 'off', 'no'), true)) {
return false;
}
return null;
} | php | public static function parseBoolHelper($value)
{
$value = strtolower($value);
if (in_array($value, array('true', '1', 'on', 'yes'), true)) {
return true;
}
if (in_array($value, array('false', '0', 'off', 'no'), true)) {
return false;
}
return null;
} | [
"public",
"static",
"function",
"parseBoolHelper",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"strtolower",
"(",
"$",
"value",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"value",
",",
"array",
"(",
"'true'",
",",
"'1'",
",",
"'on'",
",",
"'yes'",
")",
",",
"true",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"value",
",",
"array",
"(",
"'false'",
",",
"'0'",
",",
"'off'",
",",
"'no'",
")",
",",
"true",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"null",
";",
"}"
] | Parses a text and tries to extract a boolean value.
\param string $value
The text from which a boolean should be extracted.
\retval bool
If a boolean could be extracted from the $value provided,
it is returned as the corresponding PHP boolean value
(either \b true or \b false).
\retval null
No boolean could be extracted.
\note
Currently, the following texts are recognized as \b true:
"true", "1", "on" & "yes", while the values
"false", "0", "off" & "no" are recognized as \b false.
The comparison is case-insensitive (ie. "true" == "TrUe"). | [
"Parses",
"a",
"text",
"and",
"tries",
"to",
"extract",
"a",
"boolean",
"value",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/Config/Proxy.php#L203-L213 |
32,160 | Erebot/Erebot | src/Config/Proxy.php | Proxy.parseIntHelper | public static function parseIntHelper($value)
{
if ($value == '') {
return null;
}
if (is_int($value)) {
return $value;
}
if (ctype_digit($value)) {
return (int) $value;
}
if (strpos('+-', $value[0]) !== false && ctype_digit(substr($value, 1))) {
return (int) $value;
}
return null;
} | php | public static function parseIntHelper($value)
{
if ($value == '') {
return null;
}
if (is_int($value)) {
return $value;
}
if (ctype_digit($value)) {
return (int) $value;
}
if (strpos('+-', $value[0]) !== false && ctype_digit(substr($value, 1))) {
return (int) $value;
}
return null;
} | [
"public",
"static",
"function",
"parseIntHelper",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"==",
"''",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"is_int",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"ctype_digit",
"(",
"$",
"value",
")",
")",
"{",
"return",
"(",
"int",
")",
"$",
"value",
";",
"}",
"if",
"(",
"strpos",
"(",
"'+-'",
",",
"$",
"value",
"[",
"0",
"]",
")",
"!==",
"false",
"&&",
"ctype_digit",
"(",
"substr",
"(",
"$",
"value",
",",
"1",
")",
")",
")",
"{",
"return",
"(",
"int",
")",
"$",
"value",
";",
"}",
"return",
"null",
";",
"}"
] | Parses a text and tries to extract an integer value.
\param string $value
The text from which an integer should be extracted.
\retval int
If an integer could be extracted from the $value provided,
it is returned as the corresponding PHP (signed) integer value.
\retval null
If no integer could be extracted. | [
"Parses",
"a",
"text",
"and",
"tries",
"to",
"extract",
"an",
"integer",
"value",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/Config/Proxy.php#L228-L247 |
32,161 | Erebot/Erebot | src/Config/Proxy.php | Proxy.parseSomething | protected function parseSomething(
$module,
$param,
$default,
callable $parser,
$origin,
callable $checker
) {
try {
if (!isset($this->modules[$module])) {
throw new \Erebot\NotFoundException('No such module');
}
$value = $this->modules[$module]->getParam($param);
$value = $parser($value);
if ($value !== null) {
return $value;
}
throw new \Erebot\InvalidValueException(
'Bad value in configuration'
);
} catch (\Erebot\NotFoundException $e) {
if ($this->proxified !== $this) {
return $this->proxified->$origin($module, $param, $default);
}
if ($default === null) {
throw new \Erebot\NotFoundException('No such parameter "' .
$param . '" for module "' .
$module . '"');
}
if ($checker($default)) {
return $default;
}
throw new \Erebot\InvalidValueException('Bad default value');
}
} | php | protected function parseSomething(
$module,
$param,
$default,
callable $parser,
$origin,
callable $checker
) {
try {
if (!isset($this->modules[$module])) {
throw new \Erebot\NotFoundException('No such module');
}
$value = $this->modules[$module]->getParam($param);
$value = $parser($value);
if ($value !== null) {
return $value;
}
throw new \Erebot\InvalidValueException(
'Bad value in configuration'
);
} catch (\Erebot\NotFoundException $e) {
if ($this->proxified !== $this) {
return $this->proxified->$origin($module, $param, $default);
}
if ($default === null) {
throw new \Erebot\NotFoundException('No such parameter "' .
$param . '" for module "' .
$module . '"');
}
if ($checker($default)) {
return $default;
}
throw new \Erebot\InvalidValueException('Bad default value');
}
} | [
"protected",
"function",
"parseSomething",
"(",
"$",
"module",
",",
"$",
"param",
",",
"$",
"default",
",",
"callable",
"$",
"parser",
",",
"$",
"origin",
",",
"callable",
"$",
"checker",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"modules",
"[",
"$",
"module",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Erebot",
"\\",
"NotFoundException",
"(",
"'No such module'",
")",
";",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"modules",
"[",
"$",
"module",
"]",
"->",
"getParam",
"(",
"$",
"param",
")",
";",
"$",
"value",
"=",
"$",
"parser",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"value",
"!==",
"null",
")",
"{",
"return",
"$",
"value",
";",
"}",
"throw",
"new",
"\\",
"Erebot",
"\\",
"InvalidValueException",
"(",
"'Bad value in configuration'",
")",
";",
"}",
"catch",
"(",
"\\",
"Erebot",
"\\",
"NotFoundException",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"proxified",
"!==",
"$",
"this",
")",
"{",
"return",
"$",
"this",
"->",
"proxified",
"->",
"$",
"origin",
"(",
"$",
"module",
",",
"$",
"param",
",",
"$",
"default",
")",
";",
"}",
"if",
"(",
"$",
"default",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"Erebot",
"\\",
"NotFoundException",
"(",
"'No such parameter \"'",
".",
"$",
"param",
".",
"'\" for module \"'",
".",
"$",
"module",
".",
"'\"'",
")",
";",
"}",
"if",
"(",
"$",
"checker",
"(",
"$",
"default",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"throw",
"new",
"\\",
"Erebot",
"\\",
"InvalidValueException",
"(",
"'Bad default value'",
")",
";",
"}",
"}"
] | Returns the typed value for a module's parameter.
\param string $module
The name of the module.
\param string $param
The name of the parameter to fetch
from the module's settings.
\param mixed $default
Default value if no value has been
defined in the module's settings,
or \b null if there is no default value.
\param callable $parser
Object that will be used to parse the parameter.
It will receive the value of that parameter as a
string and should convert it to the proper type.
\param string $origin
Name of the method the request to parse
the parameter originated from.
\param callable $checker
Object that will be passed the parsed value
and should return \b true if it respects the
type constraints defined by this checker,
or \b false if it does not.
\retval mixed
Value as parsed from the module's settings,
or the default value if no value existed in
the settings and it passed the type check.
\throw Erebot::InvalidValueException
The value parsed or the default value did not
pass the type check.
\throw Erebot::NotFoundException | [
"Returns",
"the",
"typed",
"value",
"for",
"a",
"module",
"s",
"parameter",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/Config/Proxy.php#L313-L349 |
32,162 | CHH/sirel | lib/Sirel/InsertManager.php | InsertManager.values | function values(array $values)
{
$cols = array();
$vals = array();
foreach ($values as $col => $val) {
if (null !== $val) {
$cols[] = $col;
$vals[] = $val;
}
}
foreach ($cols as &$col) {
$this->nodes->columns[] = new UnqualifiedColumn($col);
}
$this->nodes->values = array_merge($this->nodes->values, $vals);
return $this;
} | php | function values(array $values)
{
$cols = array();
$vals = array();
foreach ($values as $col => $val) {
if (null !== $val) {
$cols[] = $col;
$vals[] = $val;
}
}
foreach ($cols as &$col) {
$this->nodes->columns[] = new UnqualifiedColumn($col);
}
$this->nodes->values = array_merge($this->nodes->values, $vals);
return $this;
} | [
"function",
"values",
"(",
"array",
"$",
"values",
")",
"{",
"$",
"cols",
"=",
"array",
"(",
")",
";",
"$",
"vals",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"col",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"val",
")",
"{",
"$",
"cols",
"[",
"]",
"=",
"$",
"col",
";",
"$",
"vals",
"[",
"]",
"=",
"$",
"val",
";",
"}",
"}",
"foreach",
"(",
"$",
"cols",
"as",
"&",
"$",
"col",
")",
"{",
"$",
"this",
"->",
"nodes",
"->",
"columns",
"[",
"]",
"=",
"new",
"UnqualifiedColumn",
"(",
"$",
"col",
")",
";",
"}",
"$",
"this",
"->",
"nodes",
"->",
"values",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"nodes",
"->",
"values",
",",
"$",
"vals",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Column-Value-Pairs
@param array $values
@return InsertManager | [
"Column",
"-",
"Value",
"-",
"Pairs"
] | 7c32b8ed3b975dc18c0e5e257edfd11207e5c8a8 | https://github.com/CHH/sirel/blob/7c32b8ed3b975dc18c0e5e257edfd11207e5c8a8/lib/Sirel/InsertManager.php#L45-L63 |
32,163 | CHH/sirel | lib/Sirel/InsertManager.php | InsertManager.columns | function columns(array $columns)
{
foreach ($columns as &$col) {
if (!$col instanceof Attribute) {
$col = new UnqualifiedColumn($col);
}
}
$this->nodes->columns = $columns;
return $this;
} | php | function columns(array $columns)
{
foreach ($columns as &$col) {
if (!$col instanceof Attribute) {
$col = new UnqualifiedColumn($col);
}
}
$this->nodes->columns = $columns;
return $this;
} | [
"function",
"columns",
"(",
"array",
"$",
"columns",
")",
"{",
"foreach",
"(",
"$",
"columns",
"as",
"&",
"$",
"col",
")",
"{",
"if",
"(",
"!",
"$",
"col",
"instanceof",
"Attribute",
")",
"{",
"$",
"col",
"=",
"new",
"UnqualifiedColumn",
"(",
"$",
"col",
")",
";",
"}",
"}",
"$",
"this",
"->",
"nodes",
"->",
"columns",
"=",
"$",
"columns",
";",
"return",
"$",
"this",
";",
"}"
] | Sets columns for this insert
@param array $columns
@return InsertManager | [
"Sets",
"columns",
"for",
"this",
"insert"
] | 7c32b8ed3b975dc18c0e5e257edfd11207e5c8a8 | https://github.com/CHH/sirel/blob/7c32b8ed3b975dc18c0e5e257edfd11207e5c8a8/lib/Sirel/InsertManager.php#L71-L80 |
32,164 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans_SwissPostFinance.class.php | TShopPaymentHandlerDataTrans_SwissPostFinance.GetPaymentParameter | protected function GetPaymentParameter()
{
$aParameter = parent::GetPaymentParameter();
$aParameter['paymentmethod'] = 'POS';
$aParameter['paymenttype'] = self::PAYMENT_TYPE;
$aParameter['currency'] = 'CHF';
return $aParameter;
} | php | protected function GetPaymentParameter()
{
$aParameter = parent::GetPaymentParameter();
$aParameter['paymentmethod'] = 'POS';
$aParameter['paymenttype'] = self::PAYMENT_TYPE;
$aParameter['currency'] = 'CHF';
return $aParameter;
} | [
"protected",
"function",
"GetPaymentParameter",
"(",
")",
"{",
"$",
"aParameter",
"=",
"parent",
"::",
"GetPaymentParameter",
"(",
")",
";",
"$",
"aParameter",
"[",
"'paymentmethod'",
"]",
"=",
"'POS'",
";",
"$",
"aParameter",
"[",
"'paymenttype'",
"]",
"=",
"self",
"::",
"PAYMENT_TYPE",
";",
"$",
"aParameter",
"[",
"'currency'",
"]",
"=",
"'CHF'",
";",
"return",
"$",
"aParameter",
";",
"}"
] | Get hidden field parameter needed for payment.
Add payment type to hidden parameter to. was needed to check correct
payment method in authorisation response.
@return array | [
"Get",
"hidden",
"field",
"parameter",
"needed",
"for",
"payment",
".",
"Add",
"payment",
"type",
"to",
"hidden",
"parameter",
"to",
".",
"was",
"needed",
"to",
"check",
"correct",
"payment",
"method",
"in",
"authorisation",
"response",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans_SwissPostFinance.class.php#L90-L98 |
32,165 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans_SwissPostFinance.class.php | TShopPaymentHandlerDataTrans_SwissPostFinance.AllowUse | public function AllowUse(TdbShopPaymentMethod &$oPaymentMethod)
{
$bAllowUse = parent::AllowUse($oPaymentMethod);
if ($bAllowUse) {
if (preg_match('/Chrome/i', $_SERVER['HTTP_USER_AGENT']) || preg_match('/Opera/i', $_SERVER['HTTP_USER_AGENT'])) {
$bAllowUse = false;
}
}
return $bAllowUse;
} | php | public function AllowUse(TdbShopPaymentMethod &$oPaymentMethod)
{
$bAllowUse = parent::AllowUse($oPaymentMethod);
if ($bAllowUse) {
if (preg_match('/Chrome/i', $_SERVER['HTTP_USER_AGENT']) || preg_match('/Opera/i', $_SERVER['HTTP_USER_AGENT'])) {
$bAllowUse = false;
}
}
return $bAllowUse;
} | [
"public",
"function",
"AllowUse",
"(",
"TdbShopPaymentMethod",
"&",
"$",
"oPaymentMethod",
")",
"{",
"$",
"bAllowUse",
"=",
"parent",
"::",
"AllowUse",
"(",
"$",
"oPaymentMethod",
")",
";",
"if",
"(",
"$",
"bAllowUse",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/Chrome/i'",
",",
"$",
"_SERVER",
"[",
"'HTTP_USER_AGENT'",
"]",
")",
"||",
"preg_match",
"(",
"'/Opera/i'",
",",
"$",
"_SERVER",
"[",
"'HTTP_USER_AGENT'",
"]",
")",
")",
"{",
"$",
"bAllowUse",
"=",
"false",
";",
"}",
"}",
"return",
"$",
"bAllowUse",
";",
"}"
] | return true if the the payment handler may be used by the payment method passed.
you can use this hook to disable payment methods based on basket contents, payment method, user data, ...
Don't show payment PostFinance if user browser is Chrome or Opera. because PostFinance wont work with them.
@param TdbShopPaymentMethod $oPaymentMethod
@return bool | [
"return",
"true",
"if",
"the",
"the",
"payment",
"handler",
"may",
"be",
"used",
"by",
"the",
"payment",
"method",
"passed",
".",
"you",
"can",
"use",
"this",
"hook",
"to",
"disable",
"payment",
"methods",
"based",
"on",
"basket",
"contents",
"payment",
"method",
"user",
"data",
"..."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopPaymentHandler/TShopPaymentHandlerDataTrans_SwissPostFinance.class.php#L142-L152 |
32,166 | Firesphere/silverstripe-bootstrapmfa | src/Generators/CodeGenerator.php | CodeGenerator.generate | public function generate()
{
$chars = $this->validChars();
$numChars = strlen($chars) - 1;
$length = $this->getLength();
$code = array();
for ($i = 0; $i < $length; ++$i) {
$code[] = $chars[random_int(0, $numChars)];
}
return implode('', $code);
} | php | public function generate()
{
$chars = $this->validChars();
$numChars = strlen($chars) - 1;
$length = $this->getLength();
$code = array();
for ($i = 0; $i < $length; ++$i) {
$code[] = $chars[random_int(0, $numChars)];
}
return implode('', $code);
} | [
"public",
"function",
"generate",
"(",
")",
"{",
"$",
"chars",
"=",
"$",
"this",
"->",
"validChars",
"(",
")",
";",
"$",
"numChars",
"=",
"strlen",
"(",
"$",
"chars",
")",
"-",
"1",
";",
"$",
"length",
"=",
"$",
"this",
"->",
"getLength",
"(",
")",
";",
"$",
"code",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"length",
";",
"++",
"$",
"i",
")",
"{",
"$",
"code",
"[",
"]",
"=",
"$",
"chars",
"[",
"random_int",
"(",
"0",
",",
"$",
"numChars",
")",
"]",
";",
"}",
"return",
"implode",
"(",
"''",
",",
"$",
"code",
")",
";",
"}"
] | Generate a random resulting string
@return string | [
"Generate",
"a",
"random",
"resulting",
"string"
] | 8d2d6c6f2f918c8fa157da91550b897816495a4b | https://github.com/Firesphere/silverstripe-bootstrapmfa/blob/8d2d6c6f2f918c8fa157da91550b897816495a4b/src/Generators/CodeGenerator.php#L127-L138 |
32,167 | chameleon-system/chameleon-shop | src/ShopWishlistBundle/objects/db/TPkgShopWishlistArticle.class.php | TPkgShopWishlistArticle.GetCommentAsHTML | public function GetCommentAsHTML()
{
$sText = trim($this->fieldComment);
$sText = TGlobal::OutHTML($sText);
$sText = nl2br($sText);
return $sText;
} | php | public function GetCommentAsHTML()
{
$sText = trim($this->fieldComment);
$sText = TGlobal::OutHTML($sText);
$sText = nl2br($sText);
return $sText;
} | [
"public",
"function",
"GetCommentAsHTML",
"(",
")",
"{",
"$",
"sText",
"=",
"trim",
"(",
"$",
"this",
"->",
"fieldComment",
")",
";",
"$",
"sText",
"=",
"TGlobal",
"::",
"OutHTML",
"(",
"$",
"sText",
")",
";",
"$",
"sText",
"=",
"nl2br",
"(",
"$",
"sText",
")",
";",
"return",
"$",
"sText",
";",
"}"
] | return comment text as html.
@return string | [
"return",
"comment",
"text",
"as",
"html",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopWishlistBundle/objects/db/TPkgShopWishlistArticle.class.php#L21-L28 |
32,168 | chameleon-system/chameleon-shop | src/ShopWishlistBundle/objects/db/TPkgShopWishlistArticle.class.php | TPkgShopWishlistArticle.GetRemoveFromWishlistLink | public function GetRemoveFromWishlistLink($bIncludePortalLink = false)
{
$oShopConfig = TdbShop::GetInstance();
$aParameters = array('module_fnc['.$oShopConfig->GetBasketModuleSpotName().']' => 'RemoveFromWishlist', MTShopBasketCore::URL_ITEM_ID => $this->id, MTShopBasketCore::URL_MESSAGE_CONSUMER => MTShopBasketCore::MSG_CONSUMER_NAME);
return $this->getActivePageService()->getLinkToActivePageRelative($aParameters);
} | php | public function GetRemoveFromWishlistLink($bIncludePortalLink = false)
{
$oShopConfig = TdbShop::GetInstance();
$aParameters = array('module_fnc['.$oShopConfig->GetBasketModuleSpotName().']' => 'RemoveFromWishlist', MTShopBasketCore::URL_ITEM_ID => $this->id, MTShopBasketCore::URL_MESSAGE_CONSUMER => MTShopBasketCore::MSG_CONSUMER_NAME);
return $this->getActivePageService()->getLinkToActivePageRelative($aParameters);
} | [
"public",
"function",
"GetRemoveFromWishlistLink",
"(",
"$",
"bIncludePortalLink",
"=",
"false",
")",
"{",
"$",
"oShopConfig",
"=",
"TdbShop",
"::",
"GetInstance",
"(",
")",
";",
"$",
"aParameters",
"=",
"array",
"(",
"'module_fnc['",
".",
"$",
"oShopConfig",
"->",
"GetBasketModuleSpotName",
"(",
")",
".",
"']'",
"=>",
"'RemoveFromWishlist'",
",",
"MTShopBasketCore",
"::",
"URL_ITEM_ID",
"=>",
"$",
"this",
"->",
"id",
",",
"MTShopBasketCore",
"::",
"URL_MESSAGE_CONSUMER",
"=>",
"MTShopBasketCore",
"::",
"MSG_CONSUMER_NAME",
")",
";",
"return",
"$",
"this",
"->",
"getActivePageService",
"(",
")",
"->",
"getLinkToActivePageRelative",
"(",
"$",
"aParameters",
")",
";",
"}"
] | get link to remove item from wishlist.
@param bool $bIncludePortalLink
@return string | [
"get",
"link",
"to",
"remove",
"item",
"from",
"wishlist",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopWishlistBundle/objects/db/TPkgShopWishlistArticle.class.php#L37-L43 |
32,169 | edmondscommerce/doctrine-static-meta | src/CodeGeneration/Action/CreateEmbeddableAction.php | CreateEmbeddableAction.run | public function run(): void
{
if ('' === (string)$this->catName) {
throw new \RuntimeException('You must call setCatName before running this action');
}
if ('' === (string)$this->name) {
throw new \RuntimeException('You must call setName before running this action');
}
$this->fakerDataCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
$this->interfaceCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
$this->hasInterfaceCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
$this->embeddableCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
$this->hasCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
} | php | public function run(): void
{
if ('' === (string)$this->catName) {
throw new \RuntimeException('You must call setCatName before running this action');
}
if ('' === (string)$this->name) {
throw new \RuntimeException('You must call setName before running this action');
}
$this->fakerDataCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
$this->interfaceCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
$this->hasInterfaceCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
$this->embeddableCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
$this->hasCreator->setCatName($this->catName)->setName($this->name)->createTargetFileObject()->write();
} | [
"public",
"function",
"run",
"(",
")",
":",
"void",
"{",
"if",
"(",
"''",
"===",
"(",
"string",
")",
"$",
"this",
"->",
"catName",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'You must call setCatName before running this action'",
")",
";",
"}",
"if",
"(",
"''",
"===",
"(",
"string",
")",
"$",
"this",
"->",
"name",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'You must call setName before running this action'",
")",
";",
"}",
"$",
"this",
"->",
"fakerDataCreator",
"->",
"setCatName",
"(",
"$",
"this",
"->",
"catName",
")",
"->",
"setName",
"(",
"$",
"this",
"->",
"name",
")",
"->",
"createTargetFileObject",
"(",
")",
"->",
"write",
"(",
")",
";",
"$",
"this",
"->",
"interfaceCreator",
"->",
"setCatName",
"(",
"$",
"this",
"->",
"catName",
")",
"->",
"setName",
"(",
"$",
"this",
"->",
"name",
")",
"->",
"createTargetFileObject",
"(",
")",
"->",
"write",
"(",
")",
";",
"$",
"this",
"->",
"hasInterfaceCreator",
"->",
"setCatName",
"(",
"$",
"this",
"->",
"catName",
")",
"->",
"setName",
"(",
"$",
"this",
"->",
"name",
")",
"->",
"createTargetFileObject",
"(",
")",
"->",
"write",
"(",
")",
";",
"$",
"this",
"->",
"embeddableCreator",
"->",
"setCatName",
"(",
"$",
"this",
"->",
"catName",
")",
"->",
"setName",
"(",
"$",
"this",
"->",
"name",
")",
"->",
"createTargetFileObject",
"(",
")",
"->",
"write",
"(",
")",
";",
"$",
"this",
"->",
"hasCreator",
"->",
"setCatName",
"(",
"$",
"this",
"->",
"catName",
")",
"->",
"setName",
"(",
"$",
"this",
"->",
"name",
")",
"->",
"createTargetFileObject",
"(",
")",
"->",
"write",
"(",
")",
";",
"}"
] | This must be the method that actually performs the action
All your requirements, configuration and dependencies must be called with individual setters | [
"This",
"must",
"be",
"the",
"method",
"that",
"actually",
"performs",
"the",
"action"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Action/CreateEmbeddableAction.php#L65-L78 |
32,170 | chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/SimpleCheckoutExample.php | SimpleCheckoutExample.calculateOrderTotalBasedOnBuyerDetails | public function calculateOrderTotalBasedOnBuyerDetails($orderReferenceDetails, $orderAmountPreTaxAndShipping, $shippingType)
{
return $this->_shippingAndTaxCostHelper->calculateTotalAmount($orderReferenceDetails,
$orderAmountPreTaxAndShipping, $shippingType);
} | php | public function calculateOrderTotalBasedOnBuyerDetails($orderReferenceDetails, $orderAmountPreTaxAndShipping, $shippingType)
{
return $this->_shippingAndTaxCostHelper->calculateTotalAmount($orderReferenceDetails,
$orderAmountPreTaxAndShipping, $shippingType);
} | [
"public",
"function",
"calculateOrderTotalBasedOnBuyerDetails",
"(",
"$",
"orderReferenceDetails",
",",
"$",
"orderAmountPreTaxAndShipping",
",",
"$",
"shippingType",
")",
"{",
"return",
"$",
"this",
"->",
"_shippingAndTaxCostHelper",
"->",
"calculateTotalAmount",
"(",
"$",
"orderReferenceDetails",
",",
"$",
"orderAmountPreTaxAndShipping",
",",
"$",
"shippingType",
")",
";",
"}"
] | Calculate the total amount to charge the buyer for this order,
based on the buyer destination address
Note that until the order is confirmed, the name & address fields will
not be returned to the client
@param OffAmazonPaymentsService_Model_OrderReferenceDetails $orderReferenceDetails response
@param string $orderAmountPreTaxAndShipping order amount
@param int $shippingType shipping type
@return float total amount for the order, with shipping and tax included | [
"Calculate",
"the",
"total",
"amount",
"to",
"charge",
"the",
"buyer",
"for",
"this",
"order",
"based",
"on",
"the",
"buyer",
"destination",
"address"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/SimpleCheckoutExample.php#L115-L119 |
32,171 | chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/SimpleCheckoutExample.php | SimpleCheckoutExample.confirmOrderReference | public function confirmOrderReference()
{
$confirmOrderReferenceRequest
= new OffAmazonPaymentsService_Model_ConfirmOrderReferenceRequest();
$confirmOrderReferenceRequest
->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
$confirmOrderReferenceRequest->setSellerId($this->_sellerId);
return $this->_service->confirmOrderReference($confirmOrderReferenceRequest);
} | php | public function confirmOrderReference()
{
$confirmOrderReferenceRequest
= new OffAmazonPaymentsService_Model_ConfirmOrderReferenceRequest();
$confirmOrderReferenceRequest
->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
$confirmOrderReferenceRequest->setSellerId($this->_sellerId);
return $this->_service->confirmOrderReference($confirmOrderReferenceRequest);
} | [
"public",
"function",
"confirmOrderReference",
"(",
")",
"{",
"$",
"confirmOrderReferenceRequest",
"=",
"new",
"OffAmazonPaymentsService_Model_ConfirmOrderReferenceRequest",
"(",
")",
";",
"$",
"confirmOrderReferenceRequest",
"->",
"setAmazonOrderReferenceId",
"(",
"$",
"this",
"->",
"_amazonOrderReferenceId",
")",
";",
"$",
"confirmOrderReferenceRequest",
"->",
"setSellerId",
"(",
"$",
"this",
"->",
"_sellerId",
")",
";",
"return",
"$",
"this",
"->",
"_service",
"->",
"confirmOrderReference",
"(",
"$",
"confirmOrderReferenceRequest",
")",
";",
"}"
] | Confirm the order reference information, allowing for
authorizations and captures to be created
@return OffAmazonPaymentsService_Model_ConfirmOrderReferenceResponse service response | [
"Confirm",
"the",
"order",
"reference",
"information",
"allowing",
"for",
"authorizations",
"and",
"captures",
"to",
"be",
"created"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/SimpleCheckoutExample.php#L157-L166 |
32,172 | chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/SimpleCheckoutExample.php | SimpleCheckoutExample.captureOrderAmount | public function captureOrderAmount($captureAmount, $amazonAuthorizationId)
{
$captureRequest = new OffAmazonPaymentsService_Model_CaptureRequest();
$captureRequest->setSellerId($this->_sellerId);
$captureRequest->setAmazonAuthorizationId($amazonAuthorizationId);
$captureRequest->setCaptureReferenceId($this->_captureReferenceId);
$captureRequest->setCaptureAmount(new OffAmazonPaymentsService_Model_Price());
$captureRequest->getCaptureAmount()->setAmount($captureAmount);
$captureRequest->getCaptureAmount()->setCurrencyCode($this->_service->getMerchantValues()->getCurrency());
return $this->_service->capture($captureRequest);
} | php | public function captureOrderAmount($captureAmount, $amazonAuthorizationId)
{
$captureRequest = new OffAmazonPaymentsService_Model_CaptureRequest();
$captureRequest->setSellerId($this->_sellerId);
$captureRequest->setAmazonAuthorizationId($amazonAuthorizationId);
$captureRequest->setCaptureReferenceId($this->_captureReferenceId);
$captureRequest->setCaptureAmount(new OffAmazonPaymentsService_Model_Price());
$captureRequest->getCaptureAmount()->setAmount($captureAmount);
$captureRequest->getCaptureAmount()->setCurrencyCode($this->_service->getMerchantValues()->getCurrency());
return $this->_service->capture($captureRequest);
} | [
"public",
"function",
"captureOrderAmount",
"(",
"$",
"captureAmount",
",",
"$",
"amazonAuthorizationId",
")",
"{",
"$",
"captureRequest",
"=",
"new",
"OffAmazonPaymentsService_Model_CaptureRequest",
"(",
")",
";",
"$",
"captureRequest",
"->",
"setSellerId",
"(",
"$",
"this",
"->",
"_sellerId",
")",
";",
"$",
"captureRequest",
"->",
"setAmazonAuthorizationId",
"(",
"$",
"amazonAuthorizationId",
")",
";",
"$",
"captureRequest",
"->",
"setCaptureReferenceId",
"(",
"$",
"this",
"->",
"_captureReferenceId",
")",
";",
"$",
"captureRequest",
"->",
"setCaptureAmount",
"(",
"new",
"OffAmazonPaymentsService_Model_Price",
"(",
")",
")",
";",
"$",
"captureRequest",
"->",
"getCaptureAmount",
"(",
")",
"->",
"setAmount",
"(",
"$",
"captureAmount",
")",
";",
"$",
"captureRequest",
"->",
"getCaptureAmount",
"(",
")",
"->",
"setCurrencyCode",
"(",
"$",
"this",
"->",
"_service",
"->",
"getMerchantValues",
"(",
")",
"->",
"getCurrency",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"_service",
"->",
"capture",
"(",
"$",
"captureRequest",
")",
";",
"}"
] | Perform the capture call for the order
@param float $captureAmount amount to capture from the buyer
@param string $amazonAuthorizationId auth id to perform the capture on
@return OffAmazonPaymentsService_Model_CaptureResponse service response | [
"Perform",
"the",
"capture",
"call",
"for",
"the",
"order"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/SimpleCheckoutExample.php#L248-L259 |
32,173 | chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/SimpleCheckoutExample.php | SimpleCheckoutExample.closeOrderReference | public function closeOrderReference()
{
$closeOrderReferenceRequest = new OffAmazonPaymentsService_Model_CloseOrderReferenceRequest();
$closeOrderReferenceRequest->setSellerId($this->_sellerId);
$closeOrderReferenceRequest->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
$closeOrderReferenceRequest->setClosureReason("Order complete");
return $this->_service->closeOrderReference($closeOrderReferenceRequest);
} | php | public function closeOrderReference()
{
$closeOrderReferenceRequest = new OffAmazonPaymentsService_Model_CloseOrderReferenceRequest();
$closeOrderReferenceRequest->setSellerId($this->_sellerId);
$closeOrderReferenceRequest->setAmazonOrderReferenceId($this->_amazonOrderReferenceId);
$closeOrderReferenceRequest->setClosureReason("Order complete");
return $this->_service->closeOrderReference($closeOrderReferenceRequest);
} | [
"public",
"function",
"closeOrderReference",
"(",
")",
"{",
"$",
"closeOrderReferenceRequest",
"=",
"new",
"OffAmazonPaymentsService_Model_CloseOrderReferenceRequest",
"(",
")",
";",
"$",
"closeOrderReferenceRequest",
"->",
"setSellerId",
"(",
"$",
"this",
"->",
"_sellerId",
")",
";",
"$",
"closeOrderReferenceRequest",
"->",
"setAmazonOrderReferenceId",
"(",
"$",
"this",
"->",
"_amazonOrderReferenceId",
")",
";",
"$",
"closeOrderReferenceRequest",
"->",
"setClosureReason",
"(",
"\"Order complete\"",
")",
";",
"return",
"$",
"this",
"->",
"_service",
"->",
"closeOrderReference",
"(",
"$",
"closeOrderReferenceRequest",
")",
";",
"}"
] | Close this order reference to indicate that the order is complete, and
no further authorizations and captures will be performed on this order
@return OffAmazonPaymentsService_Model_CloseOrderReferenceResponse service response | [
"Close",
"this",
"order",
"reference",
"to",
"indicate",
"that",
"the",
"order",
"is",
"complete",
"and",
"no",
"further",
"authorizations",
"and",
"captures",
"will",
"be",
"performed",
"on",
"this",
"order"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/Samples/SimpleCheckoutExample.php#L285-L293 |
32,174 | chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php | OffAmazonPaymentsService_RegionSpecificProperties.getWidgetUrlFor | public function getWidgetUrlFor($region, $environment, $merchantId, $overrideUrl)
{
return sprintf(self::WIDGET_FORMAT_STRING,
$this->_getWidgetHostFor($region, $overrideUrl),
$this->_getWidgetRegionFor($region),
$this->_getWidgetEnvironmentFor($environment),
urlencode($merchantId));
} | php | public function getWidgetUrlFor($region, $environment, $merchantId, $overrideUrl)
{
return sprintf(self::WIDGET_FORMAT_STRING,
$this->_getWidgetHostFor($region, $overrideUrl),
$this->_getWidgetRegionFor($region),
$this->_getWidgetEnvironmentFor($environment),
urlencode($merchantId));
} | [
"public",
"function",
"getWidgetUrlFor",
"(",
"$",
"region",
",",
"$",
"environment",
",",
"$",
"merchantId",
",",
"$",
"overrideUrl",
")",
"{",
"return",
"sprintf",
"(",
"self",
"::",
"WIDGET_FORMAT_STRING",
",",
"$",
"this",
"->",
"_getWidgetHostFor",
"(",
"$",
"region",
",",
"$",
"overrideUrl",
")",
",",
"$",
"this",
"->",
"_getWidgetRegionFor",
"(",
"$",
"region",
")",
",",
"$",
"this",
"->",
"_getWidgetEnvironmentFor",
"(",
"$",
"environment",
")",
",",
"urlencode",
"(",
"$",
"merchantId",
")",
")",
";",
"}"
] | Return the correct widget url for the javascript widget
@param string $region
@param string $environment
@param string $merchantId
@param string $overrideUrl
@return string widgetUrl | [
"Return",
"the",
"correct",
"widget",
"url",
"for",
"the",
"javascript",
"widget"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php#L69-L76 |
32,175 | chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php | OffAmazonPaymentsService_RegionSpecificProperties.getServiceUrlFor | public function getServiceUrlFor($region, $environment, $overrideUrl)
{
return sprintf(self::SERVICE_FORMAT_STRING,
$this->_getServiceHostFor($region, $overrideUrl),
$this->_getSectionNameFor($environment),
OffAmazonPaymentsService_Client::SERVICE_VERSION);
} | php | public function getServiceUrlFor($region, $environment, $overrideUrl)
{
return sprintf(self::SERVICE_FORMAT_STRING,
$this->_getServiceHostFor($region, $overrideUrl),
$this->_getSectionNameFor($environment),
OffAmazonPaymentsService_Client::SERVICE_VERSION);
} | [
"public",
"function",
"getServiceUrlFor",
"(",
"$",
"region",
",",
"$",
"environment",
",",
"$",
"overrideUrl",
")",
"{",
"return",
"sprintf",
"(",
"self",
"::",
"SERVICE_FORMAT_STRING",
",",
"$",
"this",
"->",
"_getServiceHostFor",
"(",
"$",
"region",
",",
"$",
"overrideUrl",
")",
",",
"$",
"this",
"->",
"_getSectionNameFor",
"(",
"$",
"environment",
")",
",",
"OffAmazonPaymentsService_Client",
"::",
"SERVICE_VERSION",
")",
";",
"}"
] | Return the mws service for this region
@param string $region merchant region - us, na, uk, de
@param string $environment service - live, sandbox
@param string $overrideUrl override url
@return string mws service url | [
"Return",
"the",
"mws",
"service",
"for",
"this",
"region"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php#L87-L93 |
32,176 | chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php | OffAmazonPaymentsService_RegionSpecificProperties.getCurrencyFor | public function getCurrencyFor($region)
{
$this->_validateRegionIsDefined($region, $this->_currencyCodes);
return $this->_currencyCodes[$region];
} | php | public function getCurrencyFor($region)
{
$this->_validateRegionIsDefined($region, $this->_currencyCodes);
return $this->_currencyCodes[$region];
} | [
"public",
"function",
"getCurrencyFor",
"(",
"$",
"region",
")",
"{",
"$",
"this",
"->",
"_validateRegionIsDefined",
"(",
"$",
"region",
",",
"$",
"this",
"->",
"_currencyCodes",
")",
";",
"return",
"$",
"this",
"->",
"_currencyCodes",
"[",
"$",
"region",
"]",
";",
"}"
] | Get the currency code for the given region
@param string $region us,uk,de,na
@return string currency code | [
"Get",
"the",
"currency",
"code",
"for",
"the",
"given",
"region"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php#L102-L106 |
32,177 | chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php | OffAmazonPaymentsService_RegionSpecificProperties._getWidgetHostFor | private function _getWidgetHostFor($region, $overrideUrl)
{
if (empty($overrideUrl)) {
return $this->_getRegionPropertyFor($region, $this->_widgetUrls);
}
return $overrideUrl;
} | php | private function _getWidgetHostFor($region, $overrideUrl)
{
if (empty($overrideUrl)) {
return $this->_getRegionPropertyFor($region, $this->_widgetUrls);
}
return $overrideUrl;
} | [
"private",
"function",
"_getWidgetHostFor",
"(",
"$",
"region",
",",
"$",
"overrideUrl",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"overrideUrl",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_getRegionPropertyFor",
"(",
"$",
"region",
",",
"$",
"this",
"->",
"_widgetUrls",
")",
";",
"}",
"return",
"$",
"overrideUrl",
";",
"}"
] | Return the correct host for the widget url based on the region
@param string $region us,uk,de,na
@param string $overrideUrl override string for widget host
@return string widget host | [
"Return",
"the",
"correct",
"host",
"for",
"the",
"widget",
"url",
"based",
"on",
"the",
"region"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php#L116-L123 |
32,178 | chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php | OffAmazonPaymentsService_RegionSpecificProperties._getServiceHostFor | private function _getServiceHostFor($region, $overrideUrl)
{
if (empty($overrideUrl)) {
return $this->_getRegionPropertyFor($region, $this->_serviceUrls);
}
return $overrideUrl;
} | php | private function _getServiceHostFor($region, $overrideUrl)
{
if (empty($overrideUrl)) {
return $this->_getRegionPropertyFor($region, $this->_serviceUrls);
}
return $overrideUrl;
} | [
"private",
"function",
"_getServiceHostFor",
"(",
"$",
"region",
",",
"$",
"overrideUrl",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"overrideUrl",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_getRegionPropertyFor",
"(",
"$",
"region",
",",
"$",
"this",
"->",
"_serviceUrls",
")",
";",
"}",
"return",
"$",
"overrideUrl",
";",
"}"
] | Return the correct host for the service url based on the region
@param string $region us,uk,de,na
@param string $overrideUrl override string for service host
@return string mws host | [
"Return",
"the",
"correct",
"host",
"for",
"the",
"service",
"url",
"based",
"on",
"the",
"region"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php#L133-L140 |
32,179 | chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php | OffAmazonPaymentsService_RegionSpecificProperties._getRegionPropertyFor | private function _getRegionPropertyFor($region, $properties)
{
$this->_validateRegionIsDefined($region, $this->_regionMappings);
return $properties[$this->_regionMappings[$region]];
} | php | private function _getRegionPropertyFor($region, $properties)
{
$this->_validateRegionIsDefined($region, $this->_regionMappings);
return $properties[$this->_regionMappings[$region]];
} | [
"private",
"function",
"_getRegionPropertyFor",
"(",
"$",
"region",
",",
"$",
"properties",
")",
"{",
"$",
"this",
"->",
"_validateRegionIsDefined",
"(",
"$",
"region",
",",
"$",
"this",
"->",
"_regionMappings",
")",
";",
"return",
"$",
"properties",
"[",
"$",
"this",
"->",
"_regionMappings",
"[",
"$",
"region",
"]",
"]",
";",
"}"
] | Return the correct value for this region from an
associate array keyed by realms
@param string $region us,uk,de,na
@param array $properties associate array of realms to property values
@return string property for region | [
"Return",
"the",
"correct",
"value",
"for",
"this",
"region",
"from",
"an",
"associate",
"array",
"keyed",
"by",
"realms"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsService/RegionSpecificProperties.php#L151-L155 |
32,180 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopShippingGroup.class.php | TShopShippingGroup.& | public function &GetValidPaymentMethods($bRefresh = false)
{
if (is_null($this->oValidPaymentMethods) || $bRefresh) {
$this->oValidPaymentMethods = &TdbShopPaymentMethodList::GetAvailableMethods($this->id);
$this->oValidPaymentMethods->bAllowItemCache = true;
}
if (!is_null($this->oValidPaymentMethods)) {
$this->oValidPaymentMethods->GoToStart();
}
return $this->oValidPaymentMethods;
} | php | public function &GetValidPaymentMethods($bRefresh = false)
{
if (is_null($this->oValidPaymentMethods) || $bRefresh) {
$this->oValidPaymentMethods = &TdbShopPaymentMethodList::GetAvailableMethods($this->id);
$this->oValidPaymentMethods->bAllowItemCache = true;
}
if (!is_null($this->oValidPaymentMethods)) {
$this->oValidPaymentMethods->GoToStart();
}
return $this->oValidPaymentMethods;
} | [
"public",
"function",
"&",
"GetValidPaymentMethods",
"(",
"$",
"bRefresh",
"=",
"false",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"oValidPaymentMethods",
")",
"||",
"$",
"bRefresh",
")",
"{",
"$",
"this",
"->",
"oValidPaymentMethods",
"=",
"&",
"TdbShopPaymentMethodList",
"::",
"GetAvailableMethods",
"(",
"$",
"this",
"->",
"id",
")",
";",
"$",
"this",
"->",
"oValidPaymentMethods",
"->",
"bAllowItemCache",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"oValidPaymentMethods",
")",
")",
"{",
"$",
"this",
"->",
"oValidPaymentMethods",
"->",
"GoToStart",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"oValidPaymentMethods",
";",
"}"
] | return list of valid payment methods.
@param bool $bRefresh - set to true to force a regeneration of the list
@return TdbShopPaymentMethodList | [
"return",
"list",
"of",
"valid",
"payment",
"methods",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopShippingGroup.class.php#L340-L351 |
32,181 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopShippingGroup.class.php | TShopShippingGroup.GetVat | public function GetVat()
{
$oVat = $this->GetFromInternalCache('ovat');
if (is_null($oVat)) {
$oVat = null;
$oShopConf = TdbShop::GetInstance();
if (!$oShopConf->fieldShippingVatDependsOnBasketContents) {
$oVat = $this->GetFieldShopVat();
if (is_null($oVat)) {
$oShopConf = TdbShop::GetInstance();
$oVat = $oShopConf->GetVat();
}
$this->SetInternalCache('ovat', $oVat);
} else {
// use max vat in basket... if we have contents
$oBasket = TShopBasket::GetInstance();
$oVat = $oBasket->GetLargestVATObject();
}
}
return $oVat;
} | php | public function GetVat()
{
$oVat = $this->GetFromInternalCache('ovat');
if (is_null($oVat)) {
$oVat = null;
$oShopConf = TdbShop::GetInstance();
if (!$oShopConf->fieldShippingVatDependsOnBasketContents) {
$oVat = $this->GetFieldShopVat();
if (is_null($oVat)) {
$oShopConf = TdbShop::GetInstance();
$oVat = $oShopConf->GetVat();
}
$this->SetInternalCache('ovat', $oVat);
} else {
// use max vat in basket... if we have contents
$oBasket = TShopBasket::GetInstance();
$oVat = $oBasket->GetLargestVATObject();
}
}
return $oVat;
} | [
"public",
"function",
"GetVat",
"(",
")",
"{",
"$",
"oVat",
"=",
"$",
"this",
"->",
"GetFromInternalCache",
"(",
"'ovat'",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"oVat",
")",
")",
"{",
"$",
"oVat",
"=",
"null",
";",
"$",
"oShopConf",
"=",
"TdbShop",
"::",
"GetInstance",
"(",
")",
";",
"if",
"(",
"!",
"$",
"oShopConf",
"->",
"fieldShippingVatDependsOnBasketContents",
")",
"{",
"$",
"oVat",
"=",
"$",
"this",
"->",
"GetFieldShopVat",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"oVat",
")",
")",
"{",
"$",
"oShopConf",
"=",
"TdbShop",
"::",
"GetInstance",
"(",
")",
";",
"$",
"oVat",
"=",
"$",
"oShopConf",
"->",
"GetVat",
"(",
")",
";",
"}",
"$",
"this",
"->",
"SetInternalCache",
"(",
"'ovat'",
",",
"$",
"oVat",
")",
";",
"}",
"else",
"{",
"// use max vat in basket... if we have contents",
"$",
"oBasket",
"=",
"TShopBasket",
"::",
"GetInstance",
"(",
")",
";",
"$",
"oVat",
"=",
"$",
"oBasket",
"->",
"GetLargestVATObject",
"(",
")",
";",
"}",
"}",
"return",
"$",
"oVat",
";",
"}"
] | return the vat group for this shipping group.
@return TdbShopVat | [
"return",
"the",
"vat",
"group",
"for",
"this",
"shipping",
"group",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopShippingGroup.class.php#L420-L441 |
32,182 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopShippingGroup.class.php | TShopShippingGroup.GetValidPaymentMethodsSelectableByTheUser | public function GetValidPaymentMethodsSelectableByTheUser()
{
$oPaymentMethods = clone $this->GetValidPaymentMethods(true);
$aInvalidMethods = array();
$oPaymentMethods->GoToStart();
while ($oPaymentMethod = $oPaymentMethods->Next()) {
$oHandler = $oPaymentMethod->GetFieldShopPaymentHandler();
if ($oHandler && $oHandler->isBlockForUserSelection()) {
$aInvalidMethods[] = MySqlLegacySupport::getInstance()->real_escape_string($oPaymentMethod->id);
}
}
if (count($aInvalidMethods) > 0) {
$oPaymentMethods->AddFilterString("`shop_payment_method`.`id` NOT IN ('".implode("','", $aInvalidMethods)."')");
}
$oPaymentMethods->GoToStart();
return $oPaymentMethods;
} | php | public function GetValidPaymentMethodsSelectableByTheUser()
{
$oPaymentMethods = clone $this->GetValidPaymentMethods(true);
$aInvalidMethods = array();
$oPaymentMethods->GoToStart();
while ($oPaymentMethod = $oPaymentMethods->Next()) {
$oHandler = $oPaymentMethod->GetFieldShopPaymentHandler();
if ($oHandler && $oHandler->isBlockForUserSelection()) {
$aInvalidMethods[] = MySqlLegacySupport::getInstance()->real_escape_string($oPaymentMethod->id);
}
}
if (count($aInvalidMethods) > 0) {
$oPaymentMethods->AddFilterString("`shop_payment_method`.`id` NOT IN ('".implode("','", $aInvalidMethods)."')");
}
$oPaymentMethods->GoToStart();
return $oPaymentMethods;
} | [
"public",
"function",
"GetValidPaymentMethodsSelectableByTheUser",
"(",
")",
"{",
"$",
"oPaymentMethods",
"=",
"clone",
"$",
"this",
"->",
"GetValidPaymentMethods",
"(",
"true",
")",
";",
"$",
"aInvalidMethods",
"=",
"array",
"(",
")",
";",
"$",
"oPaymentMethods",
"->",
"GoToStart",
"(",
")",
";",
"while",
"(",
"$",
"oPaymentMethod",
"=",
"$",
"oPaymentMethods",
"->",
"Next",
"(",
")",
")",
"{",
"$",
"oHandler",
"=",
"$",
"oPaymentMethod",
"->",
"GetFieldShopPaymentHandler",
"(",
")",
";",
"if",
"(",
"$",
"oHandler",
"&&",
"$",
"oHandler",
"->",
"isBlockForUserSelection",
"(",
")",
")",
"{",
"$",
"aInvalidMethods",
"[",
"]",
"=",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"real_escape_string",
"(",
"$",
"oPaymentMethod",
"->",
"id",
")",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"aInvalidMethods",
")",
">",
"0",
")",
"{",
"$",
"oPaymentMethods",
"->",
"AddFilterString",
"(",
"\"`shop_payment_method`.`id` NOT IN ('\"",
".",
"implode",
"(",
"\"','\"",
",",
"$",
"aInvalidMethods",
")",
".",
"\"')\"",
")",
";",
"}",
"$",
"oPaymentMethods",
"->",
"GoToStart",
"(",
")",
";",
"return",
"$",
"oPaymentMethods",
";",
"}"
] | return a the active list of payment handlers reduced to those, that the user may select in the payment step.
@return TdbShopPaymentMethodList | [
"return",
"a",
"the",
"active",
"list",
"of",
"payment",
"handlers",
"reduced",
"to",
"those",
"that",
"the",
"user",
"may",
"select",
"in",
"the",
"payment",
"step",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopShippingGroup.class.php#L472-L489 |
32,183 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopShippingGroup.class.php | TShopShippingGroup.GetValidShippingTypesForBasketArticleListAndCountry | public function GetValidShippingTypesForBasketArticleListAndCountry($oBasketArticleList, $sDataCountryId)
{
$oValidShippingTypes = new TIterator();
/** @var $oValidShippingTypes TIterator* */
$oShippingTypes = $this->GetFieldShopShippingTypeList('position');
while ($oShippingType = $oShippingTypes->Next()) {
$bIsValid = $oShippingType->IsActive();
$bIsValid = $bIsValid && $oShippingType->isValidForCurrentPortal();
$bIsValid = $bIsValid && $oShippingType->IsValidForCurrentUser(false);
$bIsValid = $bIsValid && $oShippingType->IsValidForCountry($sDataCountryId);
if ($bIsValid) {
$oAffectedArticles = $oBasketArticleList->GetArticlesAffectedByShippingType($oShippingType);
$bIsValid = ($oAffectedArticles->Length() > 0);
}
if ($bIsValid) {
$oValidShippingTypes->AddItem($oShippingType);
}
}
return $oValidShippingTypes;
} | php | public function GetValidShippingTypesForBasketArticleListAndCountry($oBasketArticleList, $sDataCountryId)
{
$oValidShippingTypes = new TIterator();
/** @var $oValidShippingTypes TIterator* */
$oShippingTypes = $this->GetFieldShopShippingTypeList('position');
while ($oShippingType = $oShippingTypes->Next()) {
$bIsValid = $oShippingType->IsActive();
$bIsValid = $bIsValid && $oShippingType->isValidForCurrentPortal();
$bIsValid = $bIsValid && $oShippingType->IsValidForCurrentUser(false);
$bIsValid = $bIsValid && $oShippingType->IsValidForCountry($sDataCountryId);
if ($bIsValid) {
$oAffectedArticles = $oBasketArticleList->GetArticlesAffectedByShippingType($oShippingType);
$bIsValid = ($oAffectedArticles->Length() > 0);
}
if ($bIsValid) {
$oValidShippingTypes->AddItem($oShippingType);
}
}
return $oValidShippingTypes;
} | [
"public",
"function",
"GetValidShippingTypesForBasketArticleListAndCountry",
"(",
"$",
"oBasketArticleList",
",",
"$",
"sDataCountryId",
")",
"{",
"$",
"oValidShippingTypes",
"=",
"new",
"TIterator",
"(",
")",
";",
"/** @var $oValidShippingTypes TIterator* */",
"$",
"oShippingTypes",
"=",
"$",
"this",
"->",
"GetFieldShopShippingTypeList",
"(",
"'position'",
")",
";",
"while",
"(",
"$",
"oShippingType",
"=",
"$",
"oShippingTypes",
"->",
"Next",
"(",
")",
")",
"{",
"$",
"bIsValid",
"=",
"$",
"oShippingType",
"->",
"IsActive",
"(",
")",
";",
"$",
"bIsValid",
"=",
"$",
"bIsValid",
"&&",
"$",
"oShippingType",
"->",
"isValidForCurrentPortal",
"(",
")",
";",
"$",
"bIsValid",
"=",
"$",
"bIsValid",
"&&",
"$",
"oShippingType",
"->",
"IsValidForCurrentUser",
"(",
"false",
")",
";",
"$",
"bIsValid",
"=",
"$",
"bIsValid",
"&&",
"$",
"oShippingType",
"->",
"IsValidForCountry",
"(",
"$",
"sDataCountryId",
")",
";",
"if",
"(",
"$",
"bIsValid",
")",
"{",
"$",
"oAffectedArticles",
"=",
"$",
"oBasketArticleList",
"->",
"GetArticlesAffectedByShippingType",
"(",
"$",
"oShippingType",
")",
";",
"$",
"bIsValid",
"=",
"(",
"$",
"oAffectedArticles",
"->",
"Length",
"(",
")",
">",
"0",
")",
";",
"}",
"if",
"(",
"$",
"bIsValid",
")",
"{",
"$",
"oValidShippingTypes",
"->",
"AddItem",
"(",
"$",
"oShippingType",
")",
";",
"}",
"}",
"return",
"$",
"oValidShippingTypes",
";",
"}"
] | Get a list of shipping types based on a basket article list and the desired shipping country id.
@param TShopBasketArticleList $oBasketArticleList
@param string $sDataCountryId
@return TIterator | [
"Get",
"a",
"list",
"of",
"shipping",
"types",
"based",
"on",
"a",
"basket",
"article",
"list",
"and",
"the",
"desired",
"shipping",
"country",
"id",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopShippingGroup.class.php#L515-L535 |
32,184 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopShippingGroup.class.php | TShopShippingGroup.GetShippingCostsForBasketArticleListAndCountry | public function GetShippingCostsForBasketArticleListAndCountry($oBasketArticleList, $sDataCountryId)
{
/** @var Request $request */
$request = \ChameleonSystem\CoreBundle\ServiceLocator::get('request_stack')->getCurrentRequest();
$oBasketArticleList->GoToStart();
$oOldBasket = clone TShopBasket::GetInstance();
$oOldUser = clone TdbDataExtranetUser::GetInstance();
$oTmpBasket = new TShopBasket();
$request->getSession()->set(TShopBasket::SESSION_KEY_NAME, $oTmpBasket);
$oTmpUser = TdbDataExtranetUser::GetNewInstance();
$oTmpShippingAddress = TdbDataExtranetUserAddress::GetNewInstance();
$oTmpShippingAddress->fieldDataCountryId = $sDataCountryId;
$oTmpShippingAddress->sqlData['data_country_id'] = $sDataCountryId;
$oTmpShippingAddress->sqlData['lastname'] = 'Dummy';
$oTmpShippingAddress->fieldLastname = 'Dummy';
$oTmpShippingAddress->sqlData['city'] = 'Dummy';
$oTmpUser->setFakedShippingAddressForUser($oTmpShippingAddress);
$oTmpUser->fieldDataCountryId = $sDataCountryId;
$oTmpUser->sqlData['data_country_id'] = $sDataCountryId;
$oTmpUser->sqlData['lastname'] = 'Dummy';
$oTmpUser->sqlData['city'] = 'Dummy';
$request->getSession()->set(TdbDataExtranetUser::SESSION_KEY_NAME, $oTmpUser);
while ($oBasketArticle = $oBasketArticleList->Next()) {
$oTmpBasket->AddItem($oBasketArticle);
}
$oTmpBasket->SetActiveShippingGroup($this);
$oTmpBasket->RecalculateBasket();
$oTmpBasket->ResetAllShippingMarkers();
$dShippingCosts = $oTmpBasket->dCostShipping;
$request->getSession()->set(TShopBasket::SESSION_KEY_NAME, $oOldBasket);
$request->getSession()->set(TdbDataExtranetUser::SESSION_KEY_NAME, $oOldUser);
return $dShippingCosts;
} | php | public function GetShippingCostsForBasketArticleListAndCountry($oBasketArticleList, $sDataCountryId)
{
/** @var Request $request */
$request = \ChameleonSystem\CoreBundle\ServiceLocator::get('request_stack')->getCurrentRequest();
$oBasketArticleList->GoToStart();
$oOldBasket = clone TShopBasket::GetInstance();
$oOldUser = clone TdbDataExtranetUser::GetInstance();
$oTmpBasket = new TShopBasket();
$request->getSession()->set(TShopBasket::SESSION_KEY_NAME, $oTmpBasket);
$oTmpUser = TdbDataExtranetUser::GetNewInstance();
$oTmpShippingAddress = TdbDataExtranetUserAddress::GetNewInstance();
$oTmpShippingAddress->fieldDataCountryId = $sDataCountryId;
$oTmpShippingAddress->sqlData['data_country_id'] = $sDataCountryId;
$oTmpShippingAddress->sqlData['lastname'] = 'Dummy';
$oTmpShippingAddress->fieldLastname = 'Dummy';
$oTmpShippingAddress->sqlData['city'] = 'Dummy';
$oTmpUser->setFakedShippingAddressForUser($oTmpShippingAddress);
$oTmpUser->fieldDataCountryId = $sDataCountryId;
$oTmpUser->sqlData['data_country_id'] = $sDataCountryId;
$oTmpUser->sqlData['lastname'] = 'Dummy';
$oTmpUser->sqlData['city'] = 'Dummy';
$request->getSession()->set(TdbDataExtranetUser::SESSION_KEY_NAME, $oTmpUser);
while ($oBasketArticle = $oBasketArticleList->Next()) {
$oTmpBasket->AddItem($oBasketArticle);
}
$oTmpBasket->SetActiveShippingGroup($this);
$oTmpBasket->RecalculateBasket();
$oTmpBasket->ResetAllShippingMarkers();
$dShippingCosts = $oTmpBasket->dCostShipping;
$request->getSession()->set(TShopBasket::SESSION_KEY_NAME, $oOldBasket);
$request->getSession()->set(TdbDataExtranetUser::SESSION_KEY_NAME, $oOldUser);
return $dShippingCosts;
} | [
"public",
"function",
"GetShippingCostsForBasketArticleListAndCountry",
"(",
"$",
"oBasketArticleList",
",",
"$",
"sDataCountryId",
")",
"{",
"/** @var Request $request */",
"$",
"request",
"=",
"\\",
"ChameleonSystem",
"\\",
"CoreBundle",
"\\",
"ServiceLocator",
"::",
"get",
"(",
"'request_stack'",
")",
"->",
"getCurrentRequest",
"(",
")",
";",
"$",
"oBasketArticleList",
"->",
"GoToStart",
"(",
")",
";",
"$",
"oOldBasket",
"=",
"clone",
"TShopBasket",
"::",
"GetInstance",
"(",
")",
";",
"$",
"oOldUser",
"=",
"clone",
"TdbDataExtranetUser",
"::",
"GetInstance",
"(",
")",
";",
"$",
"oTmpBasket",
"=",
"new",
"TShopBasket",
"(",
")",
";",
"$",
"request",
"->",
"getSession",
"(",
")",
"->",
"set",
"(",
"TShopBasket",
"::",
"SESSION_KEY_NAME",
",",
"$",
"oTmpBasket",
")",
";",
"$",
"oTmpUser",
"=",
"TdbDataExtranetUser",
"::",
"GetNewInstance",
"(",
")",
";",
"$",
"oTmpShippingAddress",
"=",
"TdbDataExtranetUserAddress",
"::",
"GetNewInstance",
"(",
")",
";",
"$",
"oTmpShippingAddress",
"->",
"fieldDataCountryId",
"=",
"$",
"sDataCountryId",
";",
"$",
"oTmpShippingAddress",
"->",
"sqlData",
"[",
"'data_country_id'",
"]",
"=",
"$",
"sDataCountryId",
";",
"$",
"oTmpShippingAddress",
"->",
"sqlData",
"[",
"'lastname'",
"]",
"=",
"'Dummy'",
";",
"$",
"oTmpShippingAddress",
"->",
"fieldLastname",
"=",
"'Dummy'",
";",
"$",
"oTmpShippingAddress",
"->",
"sqlData",
"[",
"'city'",
"]",
"=",
"'Dummy'",
";",
"$",
"oTmpUser",
"->",
"setFakedShippingAddressForUser",
"(",
"$",
"oTmpShippingAddress",
")",
";",
"$",
"oTmpUser",
"->",
"fieldDataCountryId",
"=",
"$",
"sDataCountryId",
";",
"$",
"oTmpUser",
"->",
"sqlData",
"[",
"'data_country_id'",
"]",
"=",
"$",
"sDataCountryId",
";",
"$",
"oTmpUser",
"->",
"sqlData",
"[",
"'lastname'",
"]",
"=",
"'Dummy'",
";",
"$",
"oTmpUser",
"->",
"sqlData",
"[",
"'city'",
"]",
"=",
"'Dummy'",
";",
"$",
"request",
"->",
"getSession",
"(",
")",
"->",
"set",
"(",
"TdbDataExtranetUser",
"::",
"SESSION_KEY_NAME",
",",
"$",
"oTmpUser",
")",
";",
"while",
"(",
"$",
"oBasketArticle",
"=",
"$",
"oBasketArticleList",
"->",
"Next",
"(",
")",
")",
"{",
"$",
"oTmpBasket",
"->",
"AddItem",
"(",
"$",
"oBasketArticle",
")",
";",
"}",
"$",
"oTmpBasket",
"->",
"SetActiveShippingGroup",
"(",
"$",
"this",
")",
";",
"$",
"oTmpBasket",
"->",
"RecalculateBasket",
"(",
")",
";",
"$",
"oTmpBasket",
"->",
"ResetAllShippingMarkers",
"(",
")",
";",
"$",
"dShippingCosts",
"=",
"$",
"oTmpBasket",
"->",
"dCostShipping",
";",
"$",
"request",
"->",
"getSession",
"(",
")",
"->",
"set",
"(",
"TShopBasket",
"::",
"SESSION_KEY_NAME",
",",
"$",
"oOldBasket",
")",
";",
"$",
"request",
"->",
"getSession",
"(",
")",
"->",
"set",
"(",
"TdbDataExtranetUser",
"::",
"SESSION_KEY_NAME",
",",
"$",
"oOldUser",
")",
";",
"return",
"$",
"dShippingCosts",
";",
"}"
] | Calculate the shipping costs for a basket article list to be expected for a certain shipping country id.
@param TShopBasketArticleList $oBasketArticleList
@param string $sDataCountryId
@return float | [
"Calculate",
"the",
"shipping",
"costs",
"for",
"a",
"basket",
"article",
"list",
"to",
"be",
"expected",
"for",
"a",
"certain",
"shipping",
"country",
"id",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopShippingGroup.class.php#L545-L591 |
32,185 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopVoucherSeries.class.php | TShopVoucherSeries.NumberOfTimesUsedByUser | public function NumberOfTimesUsedByUser($iDataExtranetUserId = null, $aExcludeVouchers = array())
{
$iNumberOfVouchersUsed = 0;
if (is_null($iDataExtranetUserId)) {
$oUser = TdbDataExtranetUser::GetInstance();
$iDataExtranetUserId = $oUser->id;
}
$sRestriction = '';
if (count($aExcludeVouchers) > 0) {
$aExcludeVouchers = TTools::MysqlRealEscapeArray($aExcludeVouchers);
$sRestriction = "AND `shop_voucher`.`id` NOT IN ('".implode("','", $aExcludeVouchers)."')";
}
$query = "SELECT COUNT(DISTINCT `shop_voucher`.`id`) AS number_of_vouchers
FROM `shop_voucher_use`
INNER JOIN `shop_voucher` ON `shop_voucher_use`.`shop_voucher_id` = `shop_voucher`.`id`
INNER JOIN `shop_order` ON `shop_voucher_use`.`shop_order_id` = `shop_order`.`id`
WHERE `shop_order`.`data_extranet_user_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($iDataExtranetUserId)."'
AND `shop_voucher`.`shop_voucher_series_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($this->id)."'
{$sRestriction}
GROUP BY `shop_voucher`.`shop_voucher_series_id`
";
if ($aTmpRow = MySqlLegacySupport::getInstance()->fetch_assoc(MySqlLegacySupport::getInstance()->query($query))) {
$iNumberOfVouchersUsed = $aTmpRow['number_of_vouchers'];
}
return $iNumberOfVouchersUsed;
} | php | public function NumberOfTimesUsedByUser($iDataExtranetUserId = null, $aExcludeVouchers = array())
{
$iNumberOfVouchersUsed = 0;
if (is_null($iDataExtranetUserId)) {
$oUser = TdbDataExtranetUser::GetInstance();
$iDataExtranetUserId = $oUser->id;
}
$sRestriction = '';
if (count($aExcludeVouchers) > 0) {
$aExcludeVouchers = TTools::MysqlRealEscapeArray($aExcludeVouchers);
$sRestriction = "AND `shop_voucher`.`id` NOT IN ('".implode("','", $aExcludeVouchers)."')";
}
$query = "SELECT COUNT(DISTINCT `shop_voucher`.`id`) AS number_of_vouchers
FROM `shop_voucher_use`
INNER JOIN `shop_voucher` ON `shop_voucher_use`.`shop_voucher_id` = `shop_voucher`.`id`
INNER JOIN `shop_order` ON `shop_voucher_use`.`shop_order_id` = `shop_order`.`id`
WHERE `shop_order`.`data_extranet_user_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($iDataExtranetUserId)."'
AND `shop_voucher`.`shop_voucher_series_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($this->id)."'
{$sRestriction}
GROUP BY `shop_voucher`.`shop_voucher_series_id`
";
if ($aTmpRow = MySqlLegacySupport::getInstance()->fetch_assoc(MySqlLegacySupport::getInstance()->query($query))) {
$iNumberOfVouchersUsed = $aTmpRow['number_of_vouchers'];
}
return $iNumberOfVouchersUsed;
} | [
"public",
"function",
"NumberOfTimesUsedByUser",
"(",
"$",
"iDataExtranetUserId",
"=",
"null",
",",
"$",
"aExcludeVouchers",
"=",
"array",
"(",
")",
")",
"{",
"$",
"iNumberOfVouchersUsed",
"=",
"0",
";",
"if",
"(",
"is_null",
"(",
"$",
"iDataExtranetUserId",
")",
")",
"{",
"$",
"oUser",
"=",
"TdbDataExtranetUser",
"::",
"GetInstance",
"(",
")",
";",
"$",
"iDataExtranetUserId",
"=",
"$",
"oUser",
"->",
"id",
";",
"}",
"$",
"sRestriction",
"=",
"''",
";",
"if",
"(",
"count",
"(",
"$",
"aExcludeVouchers",
")",
">",
"0",
")",
"{",
"$",
"aExcludeVouchers",
"=",
"TTools",
"::",
"MysqlRealEscapeArray",
"(",
"$",
"aExcludeVouchers",
")",
";",
"$",
"sRestriction",
"=",
"\"AND `shop_voucher`.`id` NOT IN ('\"",
".",
"implode",
"(",
"\"','\"",
",",
"$",
"aExcludeVouchers",
")",
".",
"\"')\"",
";",
"}",
"$",
"query",
"=",
"\"SELECT COUNT(DISTINCT `shop_voucher`.`id`) AS number_of_vouchers\n FROM `shop_voucher_use`\n INNER JOIN `shop_voucher` ON `shop_voucher_use`.`shop_voucher_id` = `shop_voucher`.`id`\n INNER JOIN `shop_order` ON `shop_voucher_use`.`shop_order_id` = `shop_order`.`id`\n WHERE `shop_order`.`data_extranet_user_id` = '\"",
".",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"real_escape_string",
"(",
"$",
"iDataExtranetUserId",
")",
".",
"\"'\n AND `shop_voucher`.`shop_voucher_series_id` = '\"",
".",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"real_escape_string",
"(",
"$",
"this",
"->",
"id",
")",
".",
"\"'\n {$sRestriction}\n GROUP BY `shop_voucher`.`shop_voucher_series_id`\n \"",
";",
"if",
"(",
"$",
"aTmpRow",
"=",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"fetch_assoc",
"(",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"query",
"(",
"$",
"query",
")",
")",
")",
"{",
"$",
"iNumberOfVouchersUsed",
"=",
"$",
"aTmpRow",
"[",
"'number_of_vouchers'",
"]",
";",
"}",
"return",
"$",
"iNumberOfVouchersUsed",
";",
"}"
] | returns the number of vouchers from that series that have been used by the user (note, we count
also the vouchers that have been used in part only.
@param int $iDataExtranetUserId (if null, use the current user)
@param array $aExcludeVouchers - the voucher ids to exclude from the count
@return int | [
"returns",
"the",
"number",
"of",
"vouchers",
"from",
"that",
"series",
"that",
"have",
"been",
"used",
"by",
"the",
"user",
"(",
"note",
"we",
"count",
"also",
"the",
"vouchers",
"that",
"have",
"been",
"used",
"in",
"part",
"only",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopVoucherSeries.class.php#L44-L73 |
32,186 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopVoucherSeries.class.php | TShopVoucherSeries.CreateNewVoucher | public function CreateNewVoucher($sCode = null)
{
if (is_null($sCode)) {
$bCodeUnique = false;
$dMaxTry = 15;
$sCode = '';
while (!$bCodeUnique && $dMaxTry > 0) {
--$dMaxTry;
$sCode = TdbShopVoucher::GenerateVoucherCode();
$query = "SELECT * FROM `shop_voucher` WHERE `code` = '".MySqlLegacySupport::getInstance()->real_escape_string($sCode)."'";
$tRes = MySqlLegacySupport::getInstance()->query($query);
if (0 == MySqlLegacySupport::getInstance()->num_rows($tRes)) {
$bCodeUnique = true;
}
}
}
$aData = array('shop_voucher_series_id' => $this->id, 'code' => $sCode, 'datecreated' => date('Y-m-d H:i:s'));
$oVoucher = TdbShopVoucher::GetNewInstance();
$oVoucher->LoadFromRow($aData);
$oVoucher->AllowEditByAll();
$oVoucher->Save();
return $oVoucher;
} | php | public function CreateNewVoucher($sCode = null)
{
if (is_null($sCode)) {
$bCodeUnique = false;
$dMaxTry = 15;
$sCode = '';
while (!$bCodeUnique && $dMaxTry > 0) {
--$dMaxTry;
$sCode = TdbShopVoucher::GenerateVoucherCode();
$query = "SELECT * FROM `shop_voucher` WHERE `code` = '".MySqlLegacySupport::getInstance()->real_escape_string($sCode)."'";
$tRes = MySqlLegacySupport::getInstance()->query($query);
if (0 == MySqlLegacySupport::getInstance()->num_rows($tRes)) {
$bCodeUnique = true;
}
}
}
$aData = array('shop_voucher_series_id' => $this->id, 'code' => $sCode, 'datecreated' => date('Y-m-d H:i:s'));
$oVoucher = TdbShopVoucher::GetNewInstance();
$oVoucher->LoadFromRow($aData);
$oVoucher->AllowEditByAll();
$oVoucher->Save();
return $oVoucher;
} | [
"public",
"function",
"CreateNewVoucher",
"(",
"$",
"sCode",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"sCode",
")",
")",
"{",
"$",
"bCodeUnique",
"=",
"false",
";",
"$",
"dMaxTry",
"=",
"15",
";",
"$",
"sCode",
"=",
"''",
";",
"while",
"(",
"!",
"$",
"bCodeUnique",
"&&",
"$",
"dMaxTry",
">",
"0",
")",
"{",
"--",
"$",
"dMaxTry",
";",
"$",
"sCode",
"=",
"TdbShopVoucher",
"::",
"GenerateVoucherCode",
"(",
")",
";",
"$",
"query",
"=",
"\"SELECT * FROM `shop_voucher` WHERE `code` = '\"",
".",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"real_escape_string",
"(",
"$",
"sCode",
")",
".",
"\"'\"",
";",
"$",
"tRes",
"=",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"query",
"(",
"$",
"query",
")",
";",
"if",
"(",
"0",
"==",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"num_rows",
"(",
"$",
"tRes",
")",
")",
"{",
"$",
"bCodeUnique",
"=",
"true",
";",
"}",
"}",
"}",
"$",
"aData",
"=",
"array",
"(",
"'shop_voucher_series_id'",
"=>",
"$",
"this",
"->",
"id",
",",
"'code'",
"=>",
"$",
"sCode",
",",
"'datecreated'",
"=>",
"date",
"(",
"'Y-m-d H:i:s'",
")",
")",
";",
"$",
"oVoucher",
"=",
"TdbShopVoucher",
"::",
"GetNewInstance",
"(",
")",
";",
"$",
"oVoucher",
"->",
"LoadFromRow",
"(",
"$",
"aData",
")",
";",
"$",
"oVoucher",
"->",
"AllowEditByAll",
"(",
")",
";",
"$",
"oVoucher",
"->",
"Save",
"(",
")",
";",
"return",
"$",
"oVoucher",
";",
"}"
] | create a new voucher.
@param string $sCode - code to create
@return TdbShopVoucher | [
"create",
"a",
"new",
"voucher",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopVoucherSeries.class.php#L82-L105 |
32,187 | Erebot/Erebot | src/CLI.php | CLI.cleanupPidfile | public static function cleanupPidfile($handle, $pidfile)
{
flock($handle, LOCK_UN);
@unlink($pidfile);
$logger = \Plop\Plop::getInstance();
$logger->debug(
'Removed lock on pidfile (%(pidfile)s)',
array('pidfile' => $pidfile)
);
} | php | public static function cleanupPidfile($handle, $pidfile)
{
flock($handle, LOCK_UN);
@unlink($pidfile);
$logger = \Plop\Plop::getInstance();
$logger->debug(
'Removed lock on pidfile (%(pidfile)s)',
array('pidfile' => $pidfile)
);
} | [
"public",
"static",
"function",
"cleanupPidfile",
"(",
"$",
"handle",
",",
"$",
"pidfile",
")",
"{",
"flock",
"(",
"$",
"handle",
",",
"LOCK_UN",
")",
";",
"@",
"unlink",
"(",
"$",
"pidfile",
")",
";",
"$",
"logger",
"=",
"\\",
"Plop",
"\\",
"Plop",
"::",
"getInstance",
"(",
")",
";",
"$",
"logger",
"->",
"debug",
"(",
"'Removed lock on pidfile (%(pidfile)s)'",
",",
"array",
"(",
"'pidfile'",
"=>",
"$",
"pidfile",
")",
")",
";",
"}"
] | Called after the bot has finished its execution
to perform cleanup tasks.
\param resource $handle
Open file handle on the pidfile.
\param string $pidfile
Name of the pidfile.
\return
This method does not return anything. | [
"Called",
"after",
"the",
"bot",
"has",
"finished",
"its",
"execution",
"to",
"perform",
"cleanup",
"tasks",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/CLI.php#L68-L77 |
32,188 | chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsNotifications/Impl/OpenSslVerifySignature.php | OpenSslVerifySignature.verifySignatureIsCorrect | public function verifySignatureIsCorrect($data, $signature, $certificatePath)
{
$cert = $this->_getCertificateFromCertifcatePath($certificatePath);
$certKey = openssl_get_publickey($cert);
if ($certKey === False) {
throw new OffAmazonPaymentsNotifications_InvalidMessageException(
"Unable to extract public key from cert " . $cert);
}
$result = -1;
try {
$result = openssl_verify($data, $signature, $certKey, OPENSSL_ALGO_SHA1);
} catch (Exception $ex) {
throw new OffAmazonPaymentsNotifications_InvalidMessageException(
"Unable to verify signature - error with the verification algorithm",
null, $ex
);
}
return ($result > 0);
} | php | public function verifySignatureIsCorrect($data, $signature, $certificatePath)
{
$cert = $this->_getCertificateFromCertifcatePath($certificatePath);
$certKey = openssl_get_publickey($cert);
if ($certKey === False) {
throw new OffAmazonPaymentsNotifications_InvalidMessageException(
"Unable to extract public key from cert " . $cert);
}
$result = -1;
try {
$result = openssl_verify($data, $signature, $certKey, OPENSSL_ALGO_SHA1);
} catch (Exception $ex) {
throw new OffAmazonPaymentsNotifications_InvalidMessageException(
"Unable to verify signature - error with the verification algorithm",
null, $ex
);
}
return ($result > 0);
} | [
"public",
"function",
"verifySignatureIsCorrect",
"(",
"$",
"data",
",",
"$",
"signature",
",",
"$",
"certificatePath",
")",
"{",
"$",
"cert",
"=",
"$",
"this",
"->",
"_getCertificateFromCertifcatePath",
"(",
"$",
"certificatePath",
")",
";",
"$",
"certKey",
"=",
"openssl_get_publickey",
"(",
"$",
"cert",
")",
";",
"if",
"(",
"$",
"certKey",
"===",
"False",
")",
"{",
"throw",
"new",
"OffAmazonPaymentsNotifications_InvalidMessageException",
"(",
"\"Unable to extract public key from cert \"",
".",
"$",
"cert",
")",
";",
"}",
"$",
"result",
"=",
"-",
"1",
";",
"try",
"{",
"$",
"result",
"=",
"openssl_verify",
"(",
"$",
"data",
",",
"$",
"signature",
",",
"$",
"certKey",
",",
"OPENSSL_ALGO_SHA1",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"throw",
"new",
"OffAmazonPaymentsNotifications_InvalidMessageException",
"(",
"\"Unable to verify signature - error with the verification algorithm\"",
",",
"null",
",",
"$",
"ex",
")",
";",
"}",
"return",
"(",
"$",
"result",
">",
"0",
")",
";",
"}"
] | Verify that the signature is correct for the given data and
public key
@param string $data data to validate
@param string $signature decoded signature to compare against
@param string $certificatePath path to certificate, can be file or url
@throws OffAmazonPaymentsNotifications_InvalidMessageException if there
is an error
with the call
@return bool true if valid | [
"Verify",
"that",
"the",
"signature",
"is",
"correct",
"for",
"the",
"given",
"data",
"and",
"public",
"key"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsNotifications/Impl/OpenSslVerifySignature.php#L53-L75 |
32,189 | chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsNotifications/Impl/OpenSslVerifySignature.php | OpenSslVerifySignature._getCertificateFromCertifcatePath | private function _getCertificateFromCertifcatePath($certificatePath)
{
$this->_validateUrl($certificatePath); //ADDED EXTRA CHECK
try {
$cert = file_get_contents($certificatePath);
} catch (Exception $ex) {
throw new OffAmazonPaymentsNotifications_InvalidMessageException(
"Error with signature validation - unable to request signing ".
"certificate at " . $certificatePath, null, $ex
);
}
if ($cert === false) {
throw new OffAmazonPaymentsNotifications_InvalidMessageException(
"Error with signature validation - unable to request signing ".
"certificate at " . $certificatePath
);
}
return $cert;
} | php | private function _getCertificateFromCertifcatePath($certificatePath)
{
$this->_validateUrl($certificatePath); //ADDED EXTRA CHECK
try {
$cert = file_get_contents($certificatePath);
} catch (Exception $ex) {
throw new OffAmazonPaymentsNotifications_InvalidMessageException(
"Error with signature validation - unable to request signing ".
"certificate at " . $certificatePath, null, $ex
);
}
if ($cert === false) {
throw new OffAmazonPaymentsNotifications_InvalidMessageException(
"Error with signature validation - unable to request signing ".
"certificate at " . $certificatePath
);
}
return $cert;
} | [
"private",
"function",
"_getCertificateFromCertifcatePath",
"(",
"$",
"certificatePath",
")",
"{",
"$",
"this",
"->",
"_validateUrl",
"(",
"$",
"certificatePath",
")",
";",
"//ADDED EXTRA CHECK",
"try",
"{",
"$",
"cert",
"=",
"file_get_contents",
"(",
"$",
"certificatePath",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"throw",
"new",
"OffAmazonPaymentsNotifications_InvalidMessageException",
"(",
"\"Error with signature validation - unable to request signing \"",
".",
"\"certificate at \"",
".",
"$",
"certificatePath",
",",
"null",
",",
"$",
"ex",
")",
";",
"}",
"if",
"(",
"$",
"cert",
"===",
"false",
")",
"{",
"throw",
"new",
"OffAmazonPaymentsNotifications_InvalidMessageException",
"(",
"\"Error with signature validation - unable to request signing \"",
".",
"\"certificate at \"",
".",
"$",
"certificatePath",
")",
";",
"}",
"return",
"$",
"cert",
";",
"}"
] | Request the signing certificate from the given path, in order to
get the public key
@param string $certificatePath certificate path to retreive
@throws OffAmazonPaymentsNotifications_InvalidMessageException
@return void | [
"Request",
"the",
"signing",
"certificate",
"from",
"the",
"given",
"path",
"in",
"order",
"to",
"get",
"the",
"public",
"key"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsNotifications/Impl/OpenSslVerifySignature.php#L87-L107 |
32,190 | edmondscommerce/doctrine-static-meta | src/Entity/Savers/EntitySaverFactory.php | EntitySaverFactory.getSaverForEntity | public function getSaverForEntity(
EntityInterface $entity
): EntitySaverInterface {
$fqn = $this->getEntityNamespace($entity);
return $this->getSaverForEntityFqn($fqn);
} | php | public function getSaverForEntity(
EntityInterface $entity
): EntitySaverInterface {
$fqn = $this->getEntityNamespace($entity);
return $this->getSaverForEntityFqn($fqn);
} | [
"public",
"function",
"getSaverForEntity",
"(",
"EntityInterface",
"$",
"entity",
")",
":",
"EntitySaverInterface",
"{",
"$",
"fqn",
"=",
"$",
"this",
"->",
"getEntityNamespace",
"(",
"$",
"entity",
")",
";",
"return",
"$",
"this",
"->",
"getSaverForEntityFqn",
"(",
"$",
"fqn",
")",
";",
"}"
] | Gets the Entity Specific Saver if one is defined, otherwise the standard Entity Saver
@param EntityInterface $entity
@return EntitySaverInterface | [
"Gets",
"the",
"Entity",
"Specific",
"Saver",
"if",
"one",
"is",
"defined",
"otherwise",
"the",
"standard",
"Entity",
"Saver"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Entity/Savers/EntitySaverFactory.php#L47-L53 |
32,191 | edmondscommerce/doctrine-static-meta | src/Entity/Savers/EntitySaverFactory.php | EntitySaverFactory.getEntityNamespace | private function getEntityNamespace(EntityInterface $entity): string
{
if ($entity instanceof Proxy) {
$proxyFqn = \get_class($entity);
$namespace = $this->entityManager->getConfiguration()->getProxyNamespace();
$marker = \Doctrine\Common\Persistence\Proxy::MARKER;
return str_replace($namespace . '\\' . $marker . '\\', '', $proxyFqn);
}
return $this->namespaceHelper->getObjectFqn($entity);
} | php | private function getEntityNamespace(EntityInterface $entity): string
{
if ($entity instanceof Proxy) {
$proxyFqn = \get_class($entity);
$namespace = $this->entityManager->getConfiguration()->getProxyNamespace();
$marker = \Doctrine\Common\Persistence\Proxy::MARKER;
return str_replace($namespace . '\\' . $marker . '\\', '', $proxyFqn);
}
return $this->namespaceHelper->getObjectFqn($entity);
} | [
"private",
"function",
"getEntityNamespace",
"(",
"EntityInterface",
"$",
"entity",
")",
":",
"string",
"{",
"if",
"(",
"$",
"entity",
"instanceof",
"Proxy",
")",
"{",
"$",
"proxyFqn",
"=",
"\\",
"get_class",
"(",
"$",
"entity",
")",
";",
"$",
"namespace",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getConfiguration",
"(",
")",
"->",
"getProxyNamespace",
"(",
")",
";",
"$",
"marker",
"=",
"\\",
"Doctrine",
"\\",
"Common",
"\\",
"Persistence",
"\\",
"Proxy",
"::",
"MARKER",
";",
"return",
"str_replace",
"(",
"$",
"namespace",
".",
"'\\\\'",
".",
"$",
"marker",
".",
"'\\\\'",
",",
"''",
",",
"$",
"proxyFqn",
")",
";",
"}",
"return",
"$",
"this",
"->",
"namespaceHelper",
"->",
"getObjectFqn",
"(",
"$",
"entity",
")",
";",
"}"
] | It is possible to pass a proxy to the class which will trigger a fatal error due to autoloading problems.
This will resolve the namespace to that of the entity, rather than the proxy. May need to update this to handle
other cases
@param EntityInterface $entity
@return string | [
"It",
"is",
"possible",
"to",
"pass",
"a",
"proxy",
"to",
"the",
"class",
"which",
"will",
"trigger",
"a",
"fatal",
"error",
"due",
"to",
"autoloading",
"problems",
"."
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Entity/Savers/EntitySaverFactory.php#L65-L76 |
32,192 | chameleon-system/chameleon-shop | src/ShopBundle/objects/TCMSTableEditor/TCMSTableEditorShopArticleReview.class.php | TCMSTableEditorShopArticleReview.UpdateArticleReviewStats | protected function UpdateArticleReviewStats($iArticleId)
{
$oArticle = TdbShopArticle::GetNewInstance();
/** @var $oArticle TdbShopArticle */
if ($oArticle->Load($iArticleId)) {
$oArticle->UpdateStatsReviews();
}
} | php | protected function UpdateArticleReviewStats($iArticleId)
{
$oArticle = TdbShopArticle::GetNewInstance();
/** @var $oArticle TdbShopArticle */
if ($oArticle->Load($iArticleId)) {
$oArticle->UpdateStatsReviews();
}
} | [
"protected",
"function",
"UpdateArticleReviewStats",
"(",
"$",
"iArticleId",
")",
"{",
"$",
"oArticle",
"=",
"TdbShopArticle",
"::",
"GetNewInstance",
"(",
")",
";",
"/** @var $oArticle TdbShopArticle */",
"if",
"(",
"$",
"oArticle",
"->",
"Load",
"(",
"$",
"iArticleId",
")",
")",
"{",
"$",
"oArticle",
"->",
"UpdateStatsReviews",
"(",
")",
";",
"}",
"}"
] | updates the review stats for the article connected to the review item. | [
"updates",
"the",
"review",
"stats",
"for",
"the",
"article",
"connected",
"to",
"the",
"review",
"item",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TCMSTableEditor/TCMSTableEditorShopArticleReview.class.php#L29-L36 |
32,193 | symbiote/silverstripe-cdncontent | code/dataobjects/CdnImage.php | CdnImage.createResampledAsset | protected function createResampledAsset($filename) {
$fullpath = Director::baseFolder() . '/' . $filename;
$asset = ContentServiceAsset::get()->filter('Filename', $filename)->first();
if(!$asset) {
$asset = new ContentServiceAsset();
}
$this->service = singleton('ContentService');
$asset->Filename = $filename;
$asset->SourceID = $this->ID;
$asset->ParentID = $this->ParentID;
$mtime = time();
$writer = $this->service->getWriterFor($asset, 'FilePointer', $this->targetStore());
if ($writer) {
if (file_exists($fullpath)) {
// likely that cached image never got built correctly.
$name = \Controller::join_links(dirname($filename), $mtime, basename($filename));
$writer->write(fopen($fullpath, 'r'), $name);
$asset->FilePointer = $writer->getContentId();
$asset->write();
$reader = $writer->getReader();
if ($reader && $reader->exists()) {
singleton('ContentDeliveryService')->removeLocalFile($fullpath);
}
} else {
$asset = null;
}
} else {
$asset = null;
}
return $asset;
} | php | protected function createResampledAsset($filename) {
$fullpath = Director::baseFolder() . '/' . $filename;
$asset = ContentServiceAsset::get()->filter('Filename', $filename)->first();
if(!$asset) {
$asset = new ContentServiceAsset();
}
$this->service = singleton('ContentService');
$asset->Filename = $filename;
$asset->SourceID = $this->ID;
$asset->ParentID = $this->ParentID;
$mtime = time();
$writer = $this->service->getWriterFor($asset, 'FilePointer', $this->targetStore());
if ($writer) {
if (file_exists($fullpath)) {
// likely that cached image never got built correctly.
$name = \Controller::join_links(dirname($filename), $mtime, basename($filename));
$writer->write(fopen($fullpath, 'r'), $name);
$asset->FilePointer = $writer->getContentId();
$asset->write();
$reader = $writer->getReader();
if ($reader && $reader->exists()) {
singleton('ContentDeliveryService')->removeLocalFile($fullpath);
}
} else {
$asset = null;
}
} else {
$asset = null;
}
return $asset;
} | [
"protected",
"function",
"createResampledAsset",
"(",
"$",
"filename",
")",
"{",
"$",
"fullpath",
"=",
"Director",
"::",
"baseFolder",
"(",
")",
".",
"'/'",
".",
"$",
"filename",
";",
"$",
"asset",
"=",
"ContentServiceAsset",
"::",
"get",
"(",
")",
"->",
"filter",
"(",
"'Filename'",
",",
"$",
"filename",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"$",
"asset",
")",
"{",
"$",
"asset",
"=",
"new",
"ContentServiceAsset",
"(",
")",
";",
"}",
"$",
"this",
"->",
"service",
"=",
"singleton",
"(",
"'ContentService'",
")",
";",
"$",
"asset",
"->",
"Filename",
"=",
"$",
"filename",
";",
"$",
"asset",
"->",
"SourceID",
"=",
"$",
"this",
"->",
"ID",
";",
"$",
"asset",
"->",
"ParentID",
"=",
"$",
"this",
"->",
"ParentID",
";",
"$",
"mtime",
"=",
"time",
"(",
")",
";",
"$",
"writer",
"=",
"$",
"this",
"->",
"service",
"->",
"getWriterFor",
"(",
"$",
"asset",
",",
"'FilePointer'",
",",
"$",
"this",
"->",
"targetStore",
"(",
")",
")",
";",
"if",
"(",
"$",
"writer",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"fullpath",
")",
")",
"{",
"// likely that cached image never got built correctly.",
"$",
"name",
"=",
"\\",
"Controller",
"::",
"join_links",
"(",
"dirname",
"(",
"$",
"filename",
")",
",",
"$",
"mtime",
",",
"basename",
"(",
"$",
"filename",
")",
")",
";",
"$",
"writer",
"->",
"write",
"(",
"fopen",
"(",
"$",
"fullpath",
",",
"'r'",
")",
",",
"$",
"name",
")",
";",
"$",
"asset",
"->",
"FilePointer",
"=",
"$",
"writer",
"->",
"getContentId",
"(",
")",
";",
"$",
"asset",
"->",
"write",
"(",
")",
";",
"$",
"reader",
"=",
"$",
"writer",
"->",
"getReader",
"(",
")",
";",
"if",
"(",
"$",
"reader",
"&&",
"$",
"reader",
"->",
"exists",
"(",
")",
")",
"{",
"singleton",
"(",
"'ContentDeliveryService'",
")",
"->",
"removeLocalFile",
"(",
"$",
"fullpath",
")",
";",
"}",
"}",
"else",
"{",
"$",
"asset",
"=",
"null",
";",
"}",
"}",
"else",
"{",
"$",
"asset",
"=",
"null",
";",
"}",
"return",
"$",
"asset",
";",
"}"
] | Creates a content service asset object based on a given resampled file path
@param type $filename
@return ContentServiceAsset | [
"Creates",
"a",
"content",
"service",
"asset",
"object",
"based",
"on",
"a",
"given",
"resampled",
"file",
"path"
] | a5f82e802e9addaf98d506cf305a621b873a5c9b | https://github.com/symbiote/silverstripe-cdncontent/blob/a5f82e802e9addaf98d506cf305a621b873a5c9b/code/dataobjects/CdnImage.php#L103-L141 |
32,194 | symbiote/silverstripe-cdncontent | code/dataobjects/CdnImage.php | CdnImage.deleteResamplings | protected function deleteResamplings() {
$children = ContentServiceAsset::get()->filter('SourceID', $this->ID);
$numDeleted = 0;
foreach ($children as $child) {
$child->SourceID = -1;
// we _DONT_ do a hard delete; if content has this image cached, it should be able to
// hold it for a while. Instead, mark deleted and allow a cleanup job to collect it later
$child->Filename = 'deleted';
$child->write();
$numDeleted++;
}
$this->Resamplings = array();
return $numDeleted;
} | php | protected function deleteResamplings() {
$children = ContentServiceAsset::get()->filter('SourceID', $this->ID);
$numDeleted = 0;
foreach ($children as $child) {
$child->SourceID = -1;
// we _DONT_ do a hard delete; if content has this image cached, it should be able to
// hold it for a while. Instead, mark deleted and allow a cleanup job to collect it later
$child->Filename = 'deleted';
$child->write();
$numDeleted++;
}
$this->Resamplings = array();
return $numDeleted;
} | [
"protected",
"function",
"deleteResamplings",
"(",
")",
"{",
"$",
"children",
"=",
"ContentServiceAsset",
"::",
"get",
"(",
")",
"->",
"filter",
"(",
"'SourceID'",
",",
"$",
"this",
"->",
"ID",
")",
";",
"$",
"numDeleted",
"=",
"0",
";",
"foreach",
"(",
"$",
"children",
"as",
"$",
"child",
")",
"{",
"$",
"child",
"->",
"SourceID",
"=",
"-",
"1",
";",
"// we _DONT_ do a hard delete; if content has this image cached, it should be able to",
"// hold it for a while. Instead, mark deleted and allow a cleanup job to collect it later",
"$",
"child",
"->",
"Filename",
"=",
"'deleted'",
";",
"$",
"child",
"->",
"write",
"(",
")",
";",
"$",
"numDeleted",
"++",
";",
"}",
"$",
"this",
"->",
"Resamplings",
"=",
"array",
"(",
")",
";",
"return",
"$",
"numDeleted",
";",
"}"
] | Mark content service assets as being deleted, and reset our Resamplings value
for update later
@return int | [
"Mark",
"content",
"service",
"assets",
"as",
"being",
"deleted",
"and",
"reset",
"our",
"Resamplings",
"value",
"for",
"update",
"later"
] | a5f82e802e9addaf98d506cf305a621b873a5c9b | https://github.com/symbiote/silverstripe-cdncontent/blob/a5f82e802e9addaf98d506cf305a621b873a5c9b/code/dataobjects/CdnImage.php#L175-L191 |
32,195 | symbiote/silverstripe-cdncontent | code/dataobjects/CdnImage.php | CdnImage.getDimensions | public function getDimensions($dim = "string") {
if(!$this->getField('Filename')) {
return null;
}
$imageDimensions = $this->getDimensionsFromDB($dim);
if ($imageDimensions !== null) {
return $imageDimensions;
}
// Download file from S3/CDN if we do not have dimensions stored in the DB
$pointer = $this->obj('CDNFile');
if($this->ID && $pointer->exists()) {
$this->ensureLocalFile();
}
if (!$this->localFileExists()) {
return null;
}
// Store in 'ImageDim' field and write if they've changed.
$this->storeDimensions();
if ($this->isChanged('ImageDim', \DataObject::CHANGE_VALUE)) {
$this->write();
}
// Load dimensions
return $this->getDimensionsFromDB($dim);
} | php | public function getDimensions($dim = "string") {
if(!$this->getField('Filename')) {
return null;
}
$imageDimensions = $this->getDimensionsFromDB($dim);
if ($imageDimensions !== null) {
return $imageDimensions;
}
// Download file from S3/CDN if we do not have dimensions stored in the DB
$pointer = $this->obj('CDNFile');
if($this->ID && $pointer->exists()) {
$this->ensureLocalFile();
}
if (!$this->localFileExists()) {
return null;
}
// Store in 'ImageDim' field and write if they've changed.
$this->storeDimensions();
if ($this->isChanged('ImageDim', \DataObject::CHANGE_VALUE)) {
$this->write();
}
// Load dimensions
return $this->getDimensionsFromDB($dim);
} | [
"public",
"function",
"getDimensions",
"(",
"$",
"dim",
"=",
"\"string\"",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getField",
"(",
"'Filename'",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"imageDimensions",
"=",
"$",
"this",
"->",
"getDimensionsFromDB",
"(",
"$",
"dim",
")",
";",
"if",
"(",
"$",
"imageDimensions",
"!==",
"null",
")",
"{",
"return",
"$",
"imageDimensions",
";",
"}",
"// Download file from S3/CDN if we do not have dimensions stored in the DB",
"$",
"pointer",
"=",
"$",
"this",
"->",
"obj",
"(",
"'CDNFile'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"ID",
"&&",
"$",
"pointer",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"this",
"->",
"ensureLocalFile",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"localFileExists",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"// Store in 'ImageDim' field and write if they've changed.",
"$",
"this",
"->",
"storeDimensions",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isChanged",
"(",
"'ImageDim'",
",",
"\\",
"DataObject",
"::",
"CHANGE_VALUE",
")",
")",
"{",
"$",
"this",
"->",
"write",
"(",
")",
";",
"}",
"// Load dimensions",
"return",
"$",
"this",
"->",
"getDimensionsFromDB",
"(",
"$",
"dim",
")",
";",
"}"
] | Captures the image dimensions in a db field to avoid needing to download the file all the time
@param type $dim
@return int|string | [
"Captures",
"the",
"image",
"dimensions",
"in",
"a",
"db",
"field",
"to",
"avoid",
"needing",
"to",
"download",
"the",
"file",
"all",
"the",
"time"
] | a5f82e802e9addaf98d506cf305a621b873a5c9b | https://github.com/symbiote/silverstripe-cdncontent/blob/a5f82e802e9addaf98d506cf305a621b873a5c9b/code/dataobjects/CdnImage.php#L199-L226 |
32,196 | symbiote/silverstripe-cdncontent | code/dataobjects/CdnImage.php | CdnImage.getDimensionsFromDB | private function getDimensionsFromDB($dim = "string") {
$imageDimensions = $this->ImageDim;
if (!$imageDimensions) {
return null;
}
if ($dim === 'string') {
return $imageDimensions;
}
$widthAndHeight = explode('x', $imageDimensions);
if (!isset($widthAndHeight[$dim])) {
return null;
}
return (int)$widthAndHeight[$dim];
} | php | private function getDimensionsFromDB($dim = "string") {
$imageDimensions = $this->ImageDim;
if (!$imageDimensions) {
return null;
}
if ($dim === 'string') {
return $imageDimensions;
}
$widthAndHeight = explode('x', $imageDimensions);
if (!isset($widthAndHeight[$dim])) {
return null;
}
return (int)$widthAndHeight[$dim];
} | [
"private",
"function",
"getDimensionsFromDB",
"(",
"$",
"dim",
"=",
"\"string\"",
")",
"{",
"$",
"imageDimensions",
"=",
"$",
"this",
"->",
"ImageDim",
";",
"if",
"(",
"!",
"$",
"imageDimensions",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"dim",
"===",
"'string'",
")",
"{",
"return",
"$",
"imageDimensions",
";",
"}",
"$",
"widthAndHeight",
"=",
"explode",
"(",
"'x'",
",",
"$",
"imageDimensions",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"widthAndHeight",
"[",
"$",
"dim",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"(",
"int",
")",
"$",
"widthAndHeight",
"[",
"$",
"dim",
"]",
";",
"}"
] | Get the dimensions of this Image.
@param string $dim If this is equal to "string", return the dimensions in string form,
if it is 0 return the height, if it is 1 return the width.
@return string|int|null | [
"Get",
"the",
"dimensions",
"of",
"this",
"Image",
"."
] | a5f82e802e9addaf98d506cf305a621b873a5c9b | https://github.com/symbiote/silverstripe-cdncontent/blob/a5f82e802e9addaf98d506cf305a621b873a5c9b/code/dataobjects/CdnImage.php#L235-L248 |
32,197 | symbiote/silverstripe-cdncontent | code/dataobjects/CdnImage.php | CdnImage.getCMSFields | public function getCMSFields() {
$fields = parent::getCMSFields();
$previewField = new LiteralField("SecureImageFull",
"<img id='thumbnailImage' class='thumbnail-preview' src='".$this->Link()."' alt='Secured File' />\n"
);
$url = $this->Link();// 5 minute link expire
$link = ReadonlyField::create('CDNUrl', 'CDN reference', $this->CDNFile);
$link->dontEscape = true;
if ($top = $fields->fieldByName('Root.Main.FilePreview')) {
$field = $top->fieldByName('FilePreviewImage');
$field->insertBefore($previewField, 'ImageFull');
$field->removeByName('ImageFull');
$top->replaceField('CDNUrl', $link);
}
return $fields;
} | php | public function getCMSFields() {
$fields = parent::getCMSFields();
$previewField = new LiteralField("SecureImageFull",
"<img id='thumbnailImage' class='thumbnail-preview' src='".$this->Link()."' alt='Secured File' />\n"
);
$url = $this->Link();// 5 minute link expire
$link = ReadonlyField::create('CDNUrl', 'CDN reference', $this->CDNFile);
$link->dontEscape = true;
if ($top = $fields->fieldByName('Root.Main.FilePreview')) {
$field = $top->fieldByName('FilePreviewImage');
$field->insertBefore($previewField, 'ImageFull');
$field->removeByName('ImageFull');
$top->replaceField('CDNUrl', $link);
}
return $fields;
} | [
"public",
"function",
"getCMSFields",
"(",
")",
"{",
"$",
"fields",
"=",
"parent",
"::",
"getCMSFields",
"(",
")",
";",
"$",
"previewField",
"=",
"new",
"LiteralField",
"(",
"\"SecureImageFull\"",
",",
"\"<img id='thumbnailImage' class='thumbnail-preview' src='\"",
".",
"$",
"this",
"->",
"Link",
"(",
")",
".",
"\"' alt='Secured File' />\\n\"",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"Link",
"(",
")",
";",
"// 5 minute link expire",
"$",
"link",
"=",
"ReadonlyField",
"::",
"create",
"(",
"'CDNUrl'",
",",
"'CDN reference'",
",",
"$",
"this",
"->",
"CDNFile",
")",
";",
"$",
"link",
"->",
"dontEscape",
"=",
"true",
";",
"if",
"(",
"$",
"top",
"=",
"$",
"fields",
"->",
"fieldByName",
"(",
"'Root.Main.FilePreview'",
")",
")",
"{",
"$",
"field",
"=",
"$",
"top",
"->",
"fieldByName",
"(",
"'FilePreviewImage'",
")",
";",
"$",
"field",
"->",
"insertBefore",
"(",
"$",
"previewField",
",",
"'ImageFull'",
")",
";",
"$",
"field",
"->",
"removeByName",
"(",
"'ImageFull'",
")",
";",
"$",
"top",
"->",
"replaceField",
"(",
"'CDNUrl'",
",",
"$",
"link",
")",
";",
"}",
"return",
"$",
"fields",
";",
"}"
] | Replaces the Preview Image and Link with secured links if the file is secured.
@return FieldList | [
"Replaces",
"the",
"Preview",
"Image",
"and",
"Link",
"with",
"secured",
"links",
"if",
"the",
"file",
"is",
"secured",
"."
] | a5f82e802e9addaf98d506cf305a621b873a5c9b | https://github.com/symbiote/silverstripe-cdncontent/blob/a5f82e802e9addaf98d506cf305a621b873a5c9b/code/dataobjects/CdnImage.php#L262-L282 |
32,198 | chameleon-system/chameleon-shop | src/ShopBundle/objects/TShopBasket/TShopBasketVoucherCoreList.class.php | TShopBasketVoucherCoreList.GetUniqueItemKey | protected function GetUniqueItemKey()
{
$iCurrentPointer = $this->getItemPointer();
$this->GoToStart();
$aItemKeyList = array();
while ($oItem = $this->Next()) {
$aItemKeyList[] = $oItem->sBasketVoucherKey;
}
// now generate a key
do {
$sKey = md5(uniqid(rand(), true));
} while (in_array($sKey, $aItemKeyList));
return $sKey;
} | php | protected function GetUniqueItemKey()
{
$iCurrentPointer = $this->getItemPointer();
$this->GoToStart();
$aItemKeyList = array();
while ($oItem = $this->Next()) {
$aItemKeyList[] = $oItem->sBasketVoucherKey;
}
// now generate a key
do {
$sKey = md5(uniqid(rand(), true));
} while (in_array($sKey, $aItemKeyList));
return $sKey;
} | [
"protected",
"function",
"GetUniqueItemKey",
"(",
")",
"{",
"$",
"iCurrentPointer",
"=",
"$",
"this",
"->",
"getItemPointer",
"(",
")",
";",
"$",
"this",
"->",
"GoToStart",
"(",
")",
";",
"$",
"aItemKeyList",
"=",
"array",
"(",
")",
";",
"while",
"(",
"$",
"oItem",
"=",
"$",
"this",
"->",
"Next",
"(",
")",
")",
"{",
"$",
"aItemKeyList",
"[",
"]",
"=",
"$",
"oItem",
"->",
"sBasketVoucherKey",
";",
"}",
"// now generate a key",
"do",
"{",
"$",
"sKey",
"=",
"md5",
"(",
"uniqid",
"(",
"rand",
"(",
")",
",",
"true",
")",
")",
";",
"}",
"while",
"(",
"in_array",
"(",
"$",
"sKey",
",",
"$",
"aItemKeyList",
")",
")",
";",
"return",
"$",
"sKey",
";",
"}"
] | return a unique sBasketVoucherKey for the current list.
@return string | [
"return",
"a",
"unique",
"sBasketVoucherKey",
"for",
"the",
"current",
"list",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TShopBasket/TShopBasketVoucherCoreList.class.php#L33-L48 |
32,199 | chameleon-system/chameleon-shop | src/ShopBundle/objects/TShopBasket/TShopBasketVoucherCoreList.class.php | TShopBasketVoucherCoreList.GetVoucherValue | public function GetVoucherValue($bSponsoredVouchers = false)
{
$dValue = 0;
$oBasket = TShopBasket::GetInstance();
$iTmpPointer = $this->getItemPointer();
$this->GoToStart();
$maxValueShippingCostAdjustment = true === $bSponsoredVouchers ? $oBasket->dCostShipping : 0;
while ($oVoucher = $this->Next()) {
if (($bSponsoredVouchers && $oVoucher->IsSponsored()) || (false == $bSponsoredVouchers && false == $oVoucher->IsSponsored())) {
$dMaxValue = ($oBasket->dCostArticlesTotalAfterDiscounts + $maxValueShippingCostAdjustment) - $dValue;
$dValue += $oVoucher->GetValue(true, $dMaxValue, $bSponsoredVouchers);
}
}
$this->setItemPointer($iTmpPointer);
return $dValue;
} | php | public function GetVoucherValue($bSponsoredVouchers = false)
{
$dValue = 0;
$oBasket = TShopBasket::GetInstance();
$iTmpPointer = $this->getItemPointer();
$this->GoToStart();
$maxValueShippingCostAdjustment = true === $bSponsoredVouchers ? $oBasket->dCostShipping : 0;
while ($oVoucher = $this->Next()) {
if (($bSponsoredVouchers && $oVoucher->IsSponsored()) || (false == $bSponsoredVouchers && false == $oVoucher->IsSponsored())) {
$dMaxValue = ($oBasket->dCostArticlesTotalAfterDiscounts + $maxValueShippingCostAdjustment) - $dValue;
$dValue += $oVoucher->GetValue(true, $dMaxValue, $bSponsoredVouchers);
}
}
$this->setItemPointer($iTmpPointer);
return $dValue;
} | [
"public",
"function",
"GetVoucherValue",
"(",
"$",
"bSponsoredVouchers",
"=",
"false",
")",
"{",
"$",
"dValue",
"=",
"0",
";",
"$",
"oBasket",
"=",
"TShopBasket",
"::",
"GetInstance",
"(",
")",
";",
"$",
"iTmpPointer",
"=",
"$",
"this",
"->",
"getItemPointer",
"(",
")",
";",
"$",
"this",
"->",
"GoToStart",
"(",
")",
";",
"$",
"maxValueShippingCostAdjustment",
"=",
"true",
"===",
"$",
"bSponsoredVouchers",
"?",
"$",
"oBasket",
"->",
"dCostShipping",
":",
"0",
";",
"while",
"(",
"$",
"oVoucher",
"=",
"$",
"this",
"->",
"Next",
"(",
")",
")",
"{",
"if",
"(",
"(",
"$",
"bSponsoredVouchers",
"&&",
"$",
"oVoucher",
"->",
"IsSponsored",
"(",
")",
")",
"||",
"(",
"false",
"==",
"$",
"bSponsoredVouchers",
"&&",
"false",
"==",
"$",
"oVoucher",
"->",
"IsSponsored",
"(",
")",
")",
")",
"{",
"$",
"dMaxValue",
"=",
"(",
"$",
"oBasket",
"->",
"dCostArticlesTotalAfterDiscounts",
"+",
"$",
"maxValueShippingCostAdjustment",
")",
"-",
"$",
"dValue",
";",
"$",
"dValue",
"+=",
"$",
"oVoucher",
"->",
"GetValue",
"(",
"true",
",",
"$",
"dMaxValue",
",",
"$",
"bSponsoredVouchers",
")",
";",
"}",
"}",
"$",
"this",
"->",
"setItemPointer",
"(",
"$",
"iTmpPointer",
")",
";",
"return",
"$",
"dValue",
";",
"}"
] | return the total voucher value for all active vouchers. note that the method will fetch the current basket
using the baskets singleton factory.
@param bool $bSponsoredVouchers - set to true: only sponsored vouchers, false only none sponsored vouchers
@return float | [
"return",
"the",
"total",
"voucher",
"value",
"for",
"all",
"active",
"vouchers",
".",
"note",
"that",
"the",
"method",
"will",
"fetch",
"the",
"current",
"basket",
"using",
"the",
"baskets",
"singleton",
"factory",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TShopBasket/TShopBasketVoucherCoreList.class.php#L68-L86 |
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.