repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
concrete5/concrete5
concrete/src/Captcha/Library.php
Library.export
public function export(\SimpleXMLElement $xml) { $type = $xml->addChild('library'); $type->addAttribute('handle', $this->getSystemCaptchaLibraryHandle()); $type->addAttribute('name', $this->getSystemCaptchaLibraryName()); $type->addAttribute('package', $this->getPackageHandle()); $type->addAttribute('activated', $this->isSystemCaptchaLibraryActive() ? '1' : '0'); }
php
public function export(\SimpleXMLElement $xml) { $type = $xml->addChild('library'); $type->addAttribute('handle', $this->getSystemCaptchaLibraryHandle()); $type->addAttribute('name', $this->getSystemCaptchaLibraryName()); $type->addAttribute('package', $this->getPackageHandle()); $type->addAttribute('activated', $this->isSystemCaptchaLibraryActive() ? '1' : '0'); }
[ "public", "function", "export", "(", "\\", "SimpleXMLElement", "$", "xml", ")", "{", "$", "type", "=", "$", "xml", "->", "addChild", "(", "'library'", ")", ";", "$", "type", "->", "addAttribute", "(", "'handle'", ",", "$", "this", "->", "getSystemCaptchaLibraryHandle", "(", ")", ")", ";", "$", "type", "->", "addAttribute", "(", "'name'", ",", "$", "this", "->", "getSystemCaptchaLibraryName", "(", ")", ")", ";", "$", "type", "->", "addAttribute", "(", "'package'", ",", "$", "this", "->", "getPackageHandle", "(", ")", ")", ";", "$", "type", "->", "addAttribute", "(", "'activated'", ",", "$", "this", "->", "isSystemCaptchaLibraryActive", "(", ")", "?", "'1'", ":", "'0'", ")", ";", "}" ]
Export the data of this library. @param \SimpleXMLElement $xml the parent XML element
[ "Export", "the", "data", "of", "this", "library", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Captcha/Library.php#L239-L246
train
concrete5/concrete5
concrete/src/Captcha/Library.php
Library.exportList
public static function exportList(\SimpleXMLElement $xml) { $list = self::getList(); $nxml = $xml->addChild('systemcaptcha'); foreach ($list as $sc) { $sc->export($nxml); } }
php
public static function exportList(\SimpleXMLElement $xml) { $list = self::getList(); $nxml = $xml->addChild('systemcaptcha'); foreach ($list as $sc) { $sc->export($nxml); } }
[ "public", "static", "function", "exportList", "(", "\\", "SimpleXMLElement", "$", "xml", ")", "{", "$", "list", "=", "self", "::", "getList", "(", ")", ";", "$", "nxml", "=", "$", "xml", "->", "addChild", "(", "'systemcaptcha'", ")", ";", "foreach", "(", "$", "list", "as", "$", "sc", ")", "{", "$", "sc", "->", "export", "(", "$", "nxml", ")", ";", "}", "}" ]
Export the data of all the libraries. @param \SimpleXMLElement $xml the parent XML element
[ "Export", "the", "data", "of", "all", "the", "libraries", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Captcha/Library.php#L253-L261
train
concrete5/concrete5
concrete/src/Captcha/Library.php
Library.hasOptionsForm
public function hasOptionsForm() { $path = DIRNAME_SYSTEM . '/' . DIRNAME_SYSTEM_CAPTCHA . '/' . $this->sclHandle . '/' . FILENAME_FORM; if (file_exists(DIR_FILES_ELEMENTS . '/' . $path)) { return true; } elseif ($this->pkgID > 0) { $pkgHandle = $this->getPackageHandle(); $dp = DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_ELEMENTS . '/' . $path; $dpc = DIR_PACKAGES_CORE . '/' . $pkgHandle . '/' . DIRNAME_ELEMENTS . '/' . $path; if (file_exists($dp)) { return true; } elseif (file_exists($dpc)) { return true; } } else { return file_exists(DIR_FILES_ELEMENTS_CORE . '/' . $path); } }
php
public function hasOptionsForm() { $path = DIRNAME_SYSTEM . '/' . DIRNAME_SYSTEM_CAPTCHA . '/' . $this->sclHandle . '/' . FILENAME_FORM; if (file_exists(DIR_FILES_ELEMENTS . '/' . $path)) { return true; } elseif ($this->pkgID > 0) { $pkgHandle = $this->getPackageHandle(); $dp = DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_ELEMENTS . '/' . $path; $dpc = DIR_PACKAGES_CORE . '/' . $pkgHandle . '/' . DIRNAME_ELEMENTS . '/' . $path; if (file_exists($dp)) { return true; } elseif (file_exists($dpc)) { return true; } } else { return file_exists(DIR_FILES_ELEMENTS_CORE . '/' . $path); } }
[ "public", "function", "hasOptionsForm", "(", ")", "{", "$", "path", "=", "DIRNAME_SYSTEM", ".", "'/'", ".", "DIRNAME_SYSTEM_CAPTCHA", ".", "'/'", ".", "$", "this", "->", "sclHandle", ".", "'/'", ".", "FILENAME_FORM", ";", "if", "(", "file_exists", "(", "DIR_FILES_ELEMENTS", ".", "'/'", ".", "$", "path", ")", ")", "{", "return", "true", ";", "}", "elseif", "(", "$", "this", "->", "pkgID", ">", "0", ")", "{", "$", "pkgHandle", "=", "$", "this", "->", "getPackageHandle", "(", ")", ";", "$", "dp", "=", "DIR_PACKAGES", ".", "'/'", ".", "$", "pkgHandle", ".", "'/'", ".", "DIRNAME_ELEMENTS", ".", "'/'", ".", "$", "path", ";", "$", "dpc", "=", "DIR_PACKAGES_CORE", ".", "'/'", ".", "$", "pkgHandle", ".", "'/'", ".", "DIRNAME_ELEMENTS", ".", "'/'", ".", "$", "path", ";", "if", "(", "file_exists", "(", "$", "dp", ")", ")", "{", "return", "true", ";", "}", "elseif", "(", "file_exists", "(", "$", "dpc", ")", ")", "{", "return", "true", ";", "}", "}", "else", "{", "return", "file_exists", "(", "DIR_FILES_ELEMENTS_CORE", ".", "'/'", ".", "$", "path", ")", ";", "}", "}" ]
Does this library has an option form? @return bool
[ "Does", "this", "library", "has", "an", "option", "form?" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Captcha/Library.php#L268-L285
train
concrete5/concrete5
concrete/src/Localization/Translation/Remote/CommunityStoreTranslationProvider.php
CommunityStoreTranslationProvider.getEntryPoint
public function getEntryPoint() { if ($this->entryPoint === null) { $this->setEntryPoint($this->config->get('concrete.i18n.community_translation.entry_point', '')); } return $this->entryPoint; }
php
public function getEntryPoint() { if ($this->entryPoint === null) { $this->setEntryPoint($this->config->get('concrete.i18n.community_translation.entry_point', '')); } return $this->entryPoint; }
[ "public", "function", "getEntryPoint", "(", ")", "{", "if", "(", "$", "this", "->", "entryPoint", "===", "null", ")", "{", "$", "this", "->", "setEntryPoint", "(", "$", "this", "->", "config", "->", "get", "(", "'concrete.i18n.community_translation.entry_point'", ",", "''", ")", ")", ";", "}", "return", "$", "this", "->", "entryPoint", ";", "}" ]
Get the API entry point. @return string
[ "Get", "the", "API", "entry", "point", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Localization/Translation/Remote/CommunityStoreTranslationProvider.php#L79-L86
train
concrete5/concrete5
concrete/src/Localization/Translation/Remote/CommunityStoreTranslationProvider.php
CommunityStoreTranslationProvider.getApiToken
public function getApiToken() { if ($this->apiToken === null) { $this->apiToken = (string) $this->config->get('concrete.i18n.community_translation.api_token', ''); } return $this->apiToken; }
php
public function getApiToken() { if ($this->apiToken === null) { $this->apiToken = (string) $this->config->get('concrete.i18n.community_translation.api_token', ''); } return $this->apiToken; }
[ "public", "function", "getApiToken", "(", ")", "{", "if", "(", "$", "this", "->", "apiToken", "===", "null", ")", "{", "$", "this", "->", "apiToken", "=", "(", "string", ")", "$", "this", "->", "config", "->", "get", "(", "'concrete.i18n.community_translation.api_token'", ",", "''", ")", ";", "}", "return", "$", "this", "->", "apiToken", ";", "}" ]
Get the API token. @return string
[ "Get", "the", "API", "token", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Localization/Translation/Remote/CommunityStoreTranslationProvider.php#L114-L121
train
concrete5/concrete5
concrete/src/Localization/Translation/Remote/CommunityStoreTranslationProvider.php
CommunityStoreTranslationProvider.getProgressLimit
public function getProgressLimit() { if ($this->progressLimit === null) { $this->setProgressLimit($this->config->get('concrete.i18n.community_translation.progress_limit', 90)); } return $this->progressLimit; }
php
public function getProgressLimit() { if ($this->progressLimit === null) { $this->setProgressLimit($this->config->get('concrete.i18n.community_translation.progress_limit', 90)); } return $this->progressLimit; }
[ "public", "function", "getProgressLimit", "(", ")", "{", "if", "(", "$", "this", "->", "progressLimit", "===", "null", ")", "{", "$", "this", "->", "setProgressLimit", "(", "$", "this", "->", "config", "->", "get", "(", "'concrete.i18n.community_translation.progress_limit'", ",", "90", ")", ")", ";", "}", "return", "$", "this", "->", "progressLimit", ";", "}" ]
Get the default progress limit. @return int
[ "Get", "the", "default", "progress", "limit", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Localization/Translation/Remote/CommunityStoreTranslationProvider.php#L149-L156
train
concrete5/concrete5
concrete/src/Updater/Migrations/Migrations/Version20181116072400.php
Version20181116072400.fixOverlappingStartEndDates
protected function fixOverlappingStartEndDates() { $rs = $this->connection->executeQuery(<<<'EOT' select cv1.cID, cv1.cvID from CollectionVersions as cv1 inner join CollectionVersions as cv2 on cv1.cID = cv2.cID and cv1.cvID <> cv2.cvID and cv1.cvIsApproved = cv2.cvIsApproved where cv1.cvIsApproved = 1 and ifnull(cv1.cvPublishDate, '0000-00-00 00:00:00') <= ifnull(cv1.cvPublishEndDate, '9999-99-99 99:99:99') and ifnull(cv1.cvPublishEndDate, '9999-99-99 99:99:99') >= ifnull(cv2.cvPublishDate, '0000-00-00 00:00:00') order by cv1.cID, cv1.cvID desc EOT ); $page = null; while (($row = $rs->fetch(PDO::FETCH_ASSOC)) !== false) { if ($page === null || $page->getCollectionID() != $row['cID']) { $page = Page::getByID($row['cID'], $row['cvID']); } else { $page->loadVersionObject($row['cvID']); } $version = $page->getVersionObject(); // Force fixing other collection version publish date/time interval $version->setPublishInterval($version->getPublishDate(), $version->getPublishDate()); } }
php
protected function fixOverlappingStartEndDates() { $rs = $this->connection->executeQuery(<<<'EOT' select cv1.cID, cv1.cvID from CollectionVersions as cv1 inner join CollectionVersions as cv2 on cv1.cID = cv2.cID and cv1.cvID <> cv2.cvID and cv1.cvIsApproved = cv2.cvIsApproved where cv1.cvIsApproved = 1 and ifnull(cv1.cvPublishDate, '0000-00-00 00:00:00') <= ifnull(cv1.cvPublishEndDate, '9999-99-99 99:99:99') and ifnull(cv1.cvPublishEndDate, '9999-99-99 99:99:99') >= ifnull(cv2.cvPublishDate, '0000-00-00 00:00:00') order by cv1.cID, cv1.cvID desc EOT ); $page = null; while (($row = $rs->fetch(PDO::FETCH_ASSOC)) !== false) { if ($page === null || $page->getCollectionID() != $row['cID']) { $page = Page::getByID($row['cID'], $row['cvID']); } else { $page->loadVersionObject($row['cvID']); } $version = $page->getVersionObject(); // Force fixing other collection version publish date/time interval $version->setPublishInterval($version->getPublishDate(), $version->getPublishDate()); } }
[ "protected", "function", "fixOverlappingStartEndDates", "(", ")", "{", "$", "rs", "=", "$", "this", "->", "connection", "->", "executeQuery", "(", "<<<'EOT'\nselect\n cv1.cID,\n cv1.cvID\nfrom\n CollectionVersions as cv1\n inner join CollectionVersions as cv2\n on cv1.cID = cv2.cID\n and cv1.cvID <> cv2.cvID\n and cv1.cvIsApproved = cv2.cvIsApproved\nwhere\n cv1.cvIsApproved = 1\n and ifnull(cv1.cvPublishDate, '0000-00-00 00:00:00') <= ifnull(cv1.cvPublishEndDate, '9999-99-99 99:99:99')\n and ifnull(cv1.cvPublishEndDate, '9999-99-99 99:99:99') >= ifnull(cv2.cvPublishDate, '0000-00-00 00:00:00')\norder by\n cv1.cID,\n cv1.cvID desc\nEOT", ")", ";", "$", "page", "=", "null", ";", "while", "(", "(", "$", "row", "=", "$", "rs", "->", "fetch", "(", "PDO", "::", "FETCH_ASSOC", ")", ")", "!==", "false", ")", "{", "if", "(", "$", "page", "===", "null", "||", "$", "page", "->", "getCollectionID", "(", ")", "!=", "$", "row", "[", "'cID'", "]", ")", "{", "$", "page", "=", "Page", "::", "getByID", "(", "$", "row", "[", "'cID'", "]", ",", "$", "row", "[", "'cvID'", "]", ")", ";", "}", "else", "{", "$", "page", "->", "loadVersionObject", "(", "$", "row", "[", "'cvID'", "]", ")", ";", "}", "$", "version", "=", "$", "page", "->", "getVersionObject", "(", ")", ";", "// Force fixing other collection version publish date/time interval", "$", "version", "->", "setPublishInterval", "(", "$", "version", "->", "getPublishDate", "(", ")", ",", "$", "version", "->", "getPublishDate", "(", ")", ")", ";", "}", "}" ]
Be sure that there are not approved collection versions with overlapping publish dates.
[ "Be", "sure", "that", "there", "are", "not", "approved", "collection", "versions", "with", "overlapping", "publish", "dates", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Updater/Migrations/Migrations/Version20181116072400.php#L51-L83
train
concrete5/concrete5
concrete/src/Search/ItemList/Database/AttributedItemList.php
AttributedItemList.filterByAttribute
public function filterByAttribute($handle, $value, $comparison = '=') { $ak = call_user_func_array(array($this->getAttributeKeyClassName(), 'getByHandle'), array($handle)); if (!is_object($ak)) { throw new \Exception(t('Unable to find attribute %s', $handle)); } $ak->getController()->filterByAttribute($this, $value, $comparison); }
php
public function filterByAttribute($handle, $value, $comparison = '=') { $ak = call_user_func_array(array($this->getAttributeKeyClassName(), 'getByHandle'), array($handle)); if (!is_object($ak)) { throw new \Exception(t('Unable to find attribute %s', $handle)); } $ak->getController()->filterByAttribute($this, $value, $comparison); }
[ "public", "function", "filterByAttribute", "(", "$", "handle", ",", "$", "value", ",", "$", "comparison", "=", "'='", ")", "{", "$", "ak", "=", "call_user_func_array", "(", "array", "(", "$", "this", "->", "getAttributeKeyClassName", "(", ")", ",", "'getByHandle'", ")", ",", "array", "(", "$", "handle", ")", ")", ";", "if", "(", "!", "is_object", "(", "$", "ak", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "t", "(", "'Unable to find attribute %s'", ",", "$", "handle", ")", ")", ";", "}", "$", "ak", "->", "getController", "(", ")", "->", "filterByAttribute", "(", "$", "this", ",", "$", "value", ",", "$", "comparison", ")", ";", "}" ]
Filters by a attribute.
[ "Filters", "by", "a", "attribute", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Search/ItemList/Database/AttributedItemList.php#L13-L20
train
concrete5/concrete5
concrete/src/File/ImportProcessor/SvgSanitizerProcessor.php
SvgSanitizerProcessor.process
public function process(Version $version) { $resource = $version->getFileResource(); $originalData = $resource->read(); $sanitizedData = $this->sanitizer->sanitizeData($originalData, $this->sanitizerOptions); if ($sanitizedData !== $originalData) { $version->updateContents($sanitizedData); } }
php
public function process(Version $version) { $resource = $version->getFileResource(); $originalData = $resource->read(); $sanitizedData = $this->sanitizer->sanitizeData($originalData, $this->sanitizerOptions); if ($sanitizedData !== $originalData) { $version->updateContents($sanitizedData); } }
[ "public", "function", "process", "(", "Version", "$", "version", ")", "{", "$", "resource", "=", "$", "version", "->", "getFileResource", "(", ")", ";", "$", "originalData", "=", "$", "resource", "->", "read", "(", ")", ";", "$", "sanitizedData", "=", "$", "this", "->", "sanitizer", "->", "sanitizeData", "(", "$", "originalData", ",", "$", "this", "->", "sanitizerOptions", ")", ";", "if", "(", "$", "sanitizedData", "!==", "$", "originalData", ")", "{", "$", "version", "->", "updateContents", "(", "$", "sanitizedData", ")", ";", "}", "}" ]
Remove potentially harmful elements and attributes from the SVG image. {@inheritdoc} @see \Concrete\Core\File\ImportProcessor\ProcessorInterface::process()
[ "Remove", "potentially", "harmful", "elements", "and", "attributes", "from", "the", "SVG", "image", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/File/ImportProcessor/SvgSanitizerProcessor.php#L59-L67
train
concrete5/concrete5
concrete/src/Legacy/PageList.php
PageList.filterByParentID
public function filterByParentID($cParentID) { $db = Loader::db(); if (is_array($cParentID)) { $cth = '('; for ($i = 0; $i < count($cParentID); ++$i) { if ($i > 0) { $cth .= ','; } $cth .= $db->quote($cParentID[$i]); } $cth .= ')'; $this->filter(false, "(p1.cParentID in {$cth})"); } else { $this->filterByCParentID = $cParentID; $this->filter('p1.cParentID', $cParentID); } }
php
public function filterByParentID($cParentID) { $db = Loader::db(); if (is_array($cParentID)) { $cth = '('; for ($i = 0; $i < count($cParentID); ++$i) { if ($i > 0) { $cth .= ','; } $cth .= $db->quote($cParentID[$i]); } $cth .= ')'; $this->filter(false, "(p1.cParentID in {$cth})"); } else { $this->filterByCParentID = $cParentID; $this->filter('p1.cParentID', $cParentID); } }
[ "public", "function", "filterByParentID", "(", "$", "cParentID", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "if", "(", "is_array", "(", "$", "cParentID", ")", ")", "{", "$", "cth", "=", "'('", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "cParentID", ")", ";", "++", "$", "i", ")", "{", "if", "(", "$", "i", ">", "0", ")", "{", "$", "cth", ".=", "','", ";", "}", "$", "cth", ".=", "$", "db", "->", "quote", "(", "$", "cParentID", "[", "$", "i", "]", ")", ";", "}", "$", "cth", ".=", "')'", ";", "$", "this", "->", "filter", "(", "false", ",", "\"(p1.cParentID in {$cth})\"", ")", ";", "}", "else", "{", "$", "this", "->", "filterByCParentID", "=", "$", "cParentID", ";", "$", "this", "->", "filter", "(", "'p1.cParentID'", ",", "$", "cParentID", ")", ";", "}", "}" ]
Sets the parent ID that we will grab pages from. @param mixed $cParentID
[ "Sets", "the", "parent", "ID", "that", "we", "will", "grab", "pages", "from", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Legacy/PageList.php#L276-L293
train
concrete5/concrete5
concrete/src/Legacy/PageList.php
PageList.get
public function get($itemsToGet = 0, $offset = 0) { $pages = []; if ($this->getQuery() == '') { $this->setBaseQuery(); } $this->setItemsPerPage($itemsToGet); $r = parent::get($itemsToGet, $offset); foreach ($r as $row) { $nc = $this->loadPageID($row['cID'], 'ACTIVE'); if (!$this->displayOnlyApprovedPages) { $cp = new Permissions($nc); if ($cp->canViewPageVersions()) { $nc->loadVersionObject('RECENT'); } } $nc->setPageIndexScore($row['cIndexScore']); $pages[] = $nc; } return $pages; }
php
public function get($itemsToGet = 0, $offset = 0) { $pages = []; if ($this->getQuery() == '') { $this->setBaseQuery(); } $this->setItemsPerPage($itemsToGet); $r = parent::get($itemsToGet, $offset); foreach ($r as $row) { $nc = $this->loadPageID($row['cID'], 'ACTIVE'); if (!$this->displayOnlyApprovedPages) { $cp = new Permissions($nc); if ($cp->canViewPageVersions()) { $nc->loadVersionObject('RECENT'); } } $nc->setPageIndexScore($row['cIndexScore']); $pages[] = $nc; } return $pages; }
[ "public", "function", "get", "(", "$", "itemsToGet", "=", "0", ",", "$", "offset", "=", "0", ")", "{", "$", "pages", "=", "[", "]", ";", "if", "(", "$", "this", "->", "getQuery", "(", ")", "==", "''", ")", "{", "$", "this", "->", "setBaseQuery", "(", ")", ";", "}", "$", "this", "->", "setItemsPerPage", "(", "$", "itemsToGet", ")", ";", "$", "r", "=", "parent", "::", "get", "(", "$", "itemsToGet", ",", "$", "offset", ")", ";", "foreach", "(", "$", "r", "as", "$", "row", ")", "{", "$", "nc", "=", "$", "this", "->", "loadPageID", "(", "$", "row", "[", "'cID'", "]", ",", "'ACTIVE'", ")", ";", "if", "(", "!", "$", "this", "->", "displayOnlyApprovedPages", ")", "{", "$", "cp", "=", "new", "Permissions", "(", "$", "nc", ")", ";", "if", "(", "$", "cp", "->", "canViewPageVersions", "(", ")", ")", "{", "$", "nc", "->", "loadVersionObject", "(", "'RECENT'", ")", ";", "}", "}", "$", "nc", "->", "setPageIndexScore", "(", "$", "row", "[", "'cIndexScore'", "]", ")", ";", "$", "pages", "[", "]", "=", "$", "nc", ";", "}", "return", "$", "pages", ";", "}" ]
Returns an array of page objects based on current settings.
[ "Returns", "an", "array", "of", "page", "objects", "based", "on", "current", "settings", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Legacy/PageList.php#L573-L596
train
concrete5/concrete5
concrete/src/Updater/Migrations/AbstractMigration.php
AbstractMigration.nullifyInvalidForeignKey
protected function nullifyInvalidForeignKey($table, $field, $linkedTable, $linkedField) { $platform = $this->connection->getDatabasePlatform(); $sqlTable = $platform->quoteSingleIdentifier($table); $sqlField = $platform->quoteSingleIdentifier($field); $sqlLinkedTable = $platform->quoteSingleIdentifier($linkedTable); $sqlLinkedField = $platform->quoteSingleIdentifier($linkedField); $this->connection->executeQuery(" update {$sqlTable} left join {$sqlLinkedTable} on {$sqlTable}.{$sqlField} = {$sqlLinkedTable}.{$sqlLinkedField} set {$sqlTable}.{$sqlField} = null where {$sqlLinkedTable}.{$sqlLinkedField} is null "); }
php
protected function nullifyInvalidForeignKey($table, $field, $linkedTable, $linkedField) { $platform = $this->connection->getDatabasePlatform(); $sqlTable = $platform->quoteSingleIdentifier($table); $sqlField = $platform->quoteSingleIdentifier($field); $sqlLinkedTable = $platform->quoteSingleIdentifier($linkedTable); $sqlLinkedField = $platform->quoteSingleIdentifier($linkedField); $this->connection->executeQuery(" update {$sqlTable} left join {$sqlLinkedTable} on {$sqlTable}.{$sqlField} = {$sqlLinkedTable}.{$sqlLinkedField} set {$sqlTable}.{$sqlField} = null where {$sqlLinkedTable}.{$sqlLinkedField} is null "); }
[ "protected", "function", "nullifyInvalidForeignKey", "(", "$", "table", ",", "$", "field", ",", "$", "linkedTable", ",", "$", "linkedField", ")", "{", "$", "platform", "=", "$", "this", "->", "connection", "->", "getDatabasePlatform", "(", ")", ";", "$", "sqlTable", "=", "$", "platform", "->", "quoteSingleIdentifier", "(", "$", "table", ")", ";", "$", "sqlField", "=", "$", "platform", "->", "quoteSingleIdentifier", "(", "$", "field", ")", ";", "$", "sqlLinkedTable", "=", "$", "platform", "->", "quoteSingleIdentifier", "(", "$", "linkedTable", ")", ";", "$", "sqlLinkedField", "=", "$", "platform", "->", "quoteSingleIdentifier", "(", "$", "linkedField", ")", ";", "$", "this", "->", "connection", "->", "executeQuery", "(", "\"\n update {$sqlTable}\n left join {$sqlLinkedTable} on {$sqlTable}.{$sqlField} = {$sqlLinkedTable}.{$sqlLinkedField}\n set {$sqlTable}.{$sqlField} = null\n where {$sqlLinkedTable}.{$sqlLinkedField} is null\n \"", ")", ";", "}" ]
Set to NULL the fields in a table that reference not existing values of another table. @param string $table The table containing the problematic field @param string $field The problematic field @param string $linkedTable The referenced table @param string $linkedField The referenced field
[ "Set", "to", "NULL", "the", "fields", "in", "a", "table", "that", "reference", "not", "existing", "values", "of", "another", "table", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Updater/Migrations/AbstractMigration.php#L151-L164
train
concrete5/concrete5
concrete/src/Console/ConsoleAwareTrait.php
ConsoleAwareTrait.setConsole
public function setConsole(SymfonyApplication $console, OutputInterface $output = null, InputInterface $input = null) { $this->traitConsole = $console; if ($output) { $this->setOutput($output); } if ($input) { $this->setInput($input); } return $this; }
php
public function setConsole(SymfonyApplication $console, OutputInterface $output = null, InputInterface $input = null) { $this->traitConsole = $console; if ($output) { $this->setOutput($output); } if ($input) { $this->setInput($input); } return $this; }
[ "public", "function", "setConsole", "(", "SymfonyApplication", "$", "console", ",", "OutputInterface", "$", "output", "=", "null", ",", "InputInterface", "$", "input", "=", "null", ")", "{", "$", "this", "->", "traitConsole", "=", "$", "console", ";", "if", "(", "$", "output", ")", "{", "$", "this", "->", "setOutput", "(", "$", "output", ")", ";", "}", "if", "(", "$", "input", ")", "{", "$", "this", "->", "setInput", "(", "$", "input", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the console object @param \Symfony\Component\Console\Application $console @param \Symfony\Component\Console\Output\OutputInterface|null $output @param \Symfony\Component\Console\Input\InputInterface|null $input @return static
[ "Set", "the", "console", "object" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Console/ConsoleAwareTrait.php#L34-L45
train
concrete5/concrete5
concrete/src/Page/Cloner.php
Cloner.cloneCollection
public function cloneCollection(Collection $c, ClonerOptions $options) { $cDate = $this->dateHelper->getOverridableNow(); $this->connection->insert('Collections', [ 'cDateAdded' => $cDate, 'cDateModified' => $cDate, 'cHandle' => $c->getCollectionHandle(), ]); $cID = $c->getCollectionID(); $newCID = $this->connection->lastInsertId(); $rs = $this->connection->executeQuery('select * from CollectionVersions where cID = ? order by cvDateCreated asc', [$cID]); while (($row = $rs->fetch(PDO::FETCH_ASSOC)) !== false) { $cDate = date('Y-m-d H:i:s', strtotime($cDate) + 1); $this->connection->insert('CollectionVersions', [ 'cID' => $newCID, 'cvID' => $row['cvID'], 'cvName' => $row['cvName'], 'cvHandle' => $row['cvHandle'], 'cvDescription' => $row['cvDescription'], 'cvDatePublic' => $row['cvDatePublic'], 'cvDateCreated' => $cDate, 'cvComments' => $row['cvComments'], 'cvAuthorUID' => $options->keepOriginalAuthor() ? $row['cvAuthorUID'] : $options->getCurrentUser()->getUserID(), 'cvIsApproved' => $options->forceUnapproved() ? 0 : $row['cvIsApproved'], 'pThemeID' => $row['pThemeID'], 'pTemplateID' => $row['pTemplateID'], ]); } $this->copyData($options, [$cID, $newCID]); return Collection::getByID($newCID); }
php
public function cloneCollection(Collection $c, ClonerOptions $options) { $cDate = $this->dateHelper->getOverridableNow(); $this->connection->insert('Collections', [ 'cDateAdded' => $cDate, 'cDateModified' => $cDate, 'cHandle' => $c->getCollectionHandle(), ]); $cID = $c->getCollectionID(); $newCID = $this->connection->lastInsertId(); $rs = $this->connection->executeQuery('select * from CollectionVersions where cID = ? order by cvDateCreated asc', [$cID]); while (($row = $rs->fetch(PDO::FETCH_ASSOC)) !== false) { $cDate = date('Y-m-d H:i:s', strtotime($cDate) + 1); $this->connection->insert('CollectionVersions', [ 'cID' => $newCID, 'cvID' => $row['cvID'], 'cvName' => $row['cvName'], 'cvHandle' => $row['cvHandle'], 'cvDescription' => $row['cvDescription'], 'cvDatePublic' => $row['cvDatePublic'], 'cvDateCreated' => $cDate, 'cvComments' => $row['cvComments'], 'cvAuthorUID' => $options->keepOriginalAuthor() ? $row['cvAuthorUID'] : $options->getCurrentUser()->getUserID(), 'cvIsApproved' => $options->forceUnapproved() ? 0 : $row['cvIsApproved'], 'pThemeID' => $row['pThemeID'], 'pTemplateID' => $row['pTemplateID'], ]); } $this->copyData($options, [$cID, $newCID]); return Collection::getByID($newCID); }
[ "public", "function", "cloneCollection", "(", "Collection", "$", "c", ",", "ClonerOptions", "$", "options", ")", "{", "$", "cDate", "=", "$", "this", "->", "dateHelper", "->", "getOverridableNow", "(", ")", ";", "$", "this", "->", "connection", "->", "insert", "(", "'Collections'", ",", "[", "'cDateAdded'", "=>", "$", "cDate", ",", "'cDateModified'", "=>", "$", "cDate", ",", "'cHandle'", "=>", "$", "c", "->", "getCollectionHandle", "(", ")", ",", "]", ")", ";", "$", "cID", "=", "$", "c", "->", "getCollectionID", "(", ")", ";", "$", "newCID", "=", "$", "this", "->", "connection", "->", "lastInsertId", "(", ")", ";", "$", "rs", "=", "$", "this", "->", "connection", "->", "executeQuery", "(", "'select * from CollectionVersions where cID = ? order by cvDateCreated asc'", ",", "[", "$", "cID", "]", ")", ";", "while", "(", "(", "$", "row", "=", "$", "rs", "->", "fetch", "(", "PDO", "::", "FETCH_ASSOC", ")", ")", "!==", "false", ")", "{", "$", "cDate", "=", "date", "(", "'Y-m-d H:i:s'", ",", "strtotime", "(", "$", "cDate", ")", "+", "1", ")", ";", "$", "this", "->", "connection", "->", "insert", "(", "'CollectionVersions'", ",", "[", "'cID'", "=>", "$", "newCID", ",", "'cvID'", "=>", "$", "row", "[", "'cvID'", "]", ",", "'cvName'", "=>", "$", "row", "[", "'cvName'", "]", ",", "'cvHandle'", "=>", "$", "row", "[", "'cvHandle'", "]", ",", "'cvDescription'", "=>", "$", "row", "[", "'cvDescription'", "]", ",", "'cvDatePublic'", "=>", "$", "row", "[", "'cvDatePublic'", "]", ",", "'cvDateCreated'", "=>", "$", "cDate", ",", "'cvComments'", "=>", "$", "row", "[", "'cvComments'", "]", ",", "'cvAuthorUID'", "=>", "$", "options", "->", "keepOriginalAuthor", "(", ")", "?", "$", "row", "[", "'cvAuthorUID'", "]", ":", "$", "options", "->", "getCurrentUser", "(", ")", "->", "getUserID", "(", ")", ",", "'cvIsApproved'", "=>", "$", "options", "->", "forceUnapproved", "(", ")", "?", "0", ":", "$", "row", "[", "'cvIsApproved'", "]", ",", "'pThemeID'", "=>", "$", "row", "[", "'pThemeID'", "]", ",", "'pTemplateID'", "=>", "$", "row", "[", "'pTemplateID'", "]", ",", "]", ")", ";", "}", "$", "this", "->", "copyData", "(", "$", "options", ",", "[", "$", "cID", ",", "$", "newCID", "]", ")", ";", "return", "Collection", "::", "getByID", "(", "$", "newCID", ")", ";", "}" ]
Create a clone of a collection, and all its versions, contents and attributes. @param \Concrete\Core\Page\Collection\Collection $c the collection to be cloned @param \Concrete\Core\Page\ClonerOptions $options the options for the cloning process @return \Concrete\Core\Page\Collection\Collection
[ "Create", "a", "clone", "of", "a", "collection", "and", "all", "its", "versions", "contents", "and", "attributes", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Cloner.php#L187-L218
train
concrete5/concrete5
concrete/src/Page/Cloner.php
Cloner.cloneCollectionVersion
public function cloneCollectionVersion(Version $cvSource, Collection $cDestination, ClonerOptions $options) { $cSourceID = $cvSource->getCollectionID(); $cvSourceID = $cvSource->getVersionID(); $cSource = Page::getByID($cSourceID, $cvSourceID); $cDestinationID = $cDestination->getCollectionID(); $cvDestinationID = 1 + (int) $this->connection->fetchColumn('select max(cvID) from CollectionVersions where cID = ?', [$cDestinationID]); $versionComments = $options->getVersionComments(); if ($versionComments === '') { $versionComments = t('New Version %s', $cvDestinationID); } if ($cSourceID == $cDestinationID) { $cvIsNew = 1; if ($cSource->getPageTypeHandle() === STACKS_PAGE_TYPE) { $cvIsNew = 0; } } else { $cvIsNew = 0; } $this->connection->insert('CollectionVersions', [ 'cID' => $cDestinationID, 'cvID' => $cvDestinationID, 'cvName' => $cvSource->getVersionName(), 'cvHandle' => $cDestination->getCollectionHandle(), 'cvDescription' => $cvSource->cvDescription, 'cvDatePublic' => $cvSource->cvDatePublic, 'cvDateCreated' => $this->dateHelper->getOverridableNow(), 'cvComments' => $versionComments, 'cvAuthorUID' => $options->keepOriginalAuthor() ? $cvSource->getVersionAuthorUserID() : $options->getCurrentUser()->getUserID(), 'cvIsNew' => $cvIsNew, 'pThemeID' => $cvSource->pThemeID, 'pTemplateID' => $cvSource->pTemplateID, // important: cvPublishDate used to be the same for the new version as it is for the current, // but it made it impossible to create a version that wasn't scheduled once you scheduled a version // so I'm turning it off for now - AE 'cvPublishDate' => null, ]); $this->copyData($options, [$cSourceID, $cDestinationID], [$cvSourceID, $cvDestinationID]); $cvDestination = Version::get($cSource, $cvDestinationID); $ev = new CollectionVersionEvent($cSource); $ev->setCollectionVersionObject($cvDestination); $this->eventDispatcher->dispatch('on_page_version_add', $ev); $cvDestination->refreshCache(); return $cvDestination; }
php
public function cloneCollectionVersion(Version $cvSource, Collection $cDestination, ClonerOptions $options) { $cSourceID = $cvSource->getCollectionID(); $cvSourceID = $cvSource->getVersionID(); $cSource = Page::getByID($cSourceID, $cvSourceID); $cDestinationID = $cDestination->getCollectionID(); $cvDestinationID = 1 + (int) $this->connection->fetchColumn('select max(cvID) from CollectionVersions where cID = ?', [$cDestinationID]); $versionComments = $options->getVersionComments(); if ($versionComments === '') { $versionComments = t('New Version %s', $cvDestinationID); } if ($cSourceID == $cDestinationID) { $cvIsNew = 1; if ($cSource->getPageTypeHandle() === STACKS_PAGE_TYPE) { $cvIsNew = 0; } } else { $cvIsNew = 0; } $this->connection->insert('CollectionVersions', [ 'cID' => $cDestinationID, 'cvID' => $cvDestinationID, 'cvName' => $cvSource->getVersionName(), 'cvHandle' => $cDestination->getCollectionHandle(), 'cvDescription' => $cvSource->cvDescription, 'cvDatePublic' => $cvSource->cvDatePublic, 'cvDateCreated' => $this->dateHelper->getOverridableNow(), 'cvComments' => $versionComments, 'cvAuthorUID' => $options->keepOriginalAuthor() ? $cvSource->getVersionAuthorUserID() : $options->getCurrentUser()->getUserID(), 'cvIsNew' => $cvIsNew, 'pThemeID' => $cvSource->pThemeID, 'pTemplateID' => $cvSource->pTemplateID, // important: cvPublishDate used to be the same for the new version as it is for the current, // but it made it impossible to create a version that wasn't scheduled once you scheduled a version // so I'm turning it off for now - AE 'cvPublishDate' => null, ]); $this->copyData($options, [$cSourceID, $cDestinationID], [$cvSourceID, $cvDestinationID]); $cvDestination = Version::get($cSource, $cvDestinationID); $ev = new CollectionVersionEvent($cSource); $ev->setCollectionVersionObject($cvDestination); $this->eventDispatcher->dispatch('on_page_version_add', $ev); $cvDestination->refreshCache(); return $cvDestination; }
[ "public", "function", "cloneCollectionVersion", "(", "Version", "$", "cvSource", ",", "Collection", "$", "cDestination", ",", "ClonerOptions", "$", "options", ")", "{", "$", "cSourceID", "=", "$", "cvSource", "->", "getCollectionID", "(", ")", ";", "$", "cvSourceID", "=", "$", "cvSource", "->", "getVersionID", "(", ")", ";", "$", "cSource", "=", "Page", "::", "getByID", "(", "$", "cSourceID", ",", "$", "cvSourceID", ")", ";", "$", "cDestinationID", "=", "$", "cDestination", "->", "getCollectionID", "(", ")", ";", "$", "cvDestinationID", "=", "1", "+", "(", "int", ")", "$", "this", "->", "connection", "->", "fetchColumn", "(", "'select max(cvID) from CollectionVersions where cID = ?'", ",", "[", "$", "cDestinationID", "]", ")", ";", "$", "versionComments", "=", "$", "options", "->", "getVersionComments", "(", ")", ";", "if", "(", "$", "versionComments", "===", "''", ")", "{", "$", "versionComments", "=", "t", "(", "'New Version %s'", ",", "$", "cvDestinationID", ")", ";", "}", "if", "(", "$", "cSourceID", "==", "$", "cDestinationID", ")", "{", "$", "cvIsNew", "=", "1", ";", "if", "(", "$", "cSource", "->", "getPageTypeHandle", "(", ")", "===", "STACKS_PAGE_TYPE", ")", "{", "$", "cvIsNew", "=", "0", ";", "}", "}", "else", "{", "$", "cvIsNew", "=", "0", ";", "}", "$", "this", "->", "connection", "->", "insert", "(", "'CollectionVersions'", ",", "[", "'cID'", "=>", "$", "cDestinationID", ",", "'cvID'", "=>", "$", "cvDestinationID", ",", "'cvName'", "=>", "$", "cvSource", "->", "getVersionName", "(", ")", ",", "'cvHandle'", "=>", "$", "cDestination", "->", "getCollectionHandle", "(", ")", ",", "'cvDescription'", "=>", "$", "cvSource", "->", "cvDescription", ",", "'cvDatePublic'", "=>", "$", "cvSource", "->", "cvDatePublic", ",", "'cvDateCreated'", "=>", "$", "this", "->", "dateHelper", "->", "getOverridableNow", "(", ")", ",", "'cvComments'", "=>", "$", "versionComments", ",", "'cvAuthorUID'", "=>", "$", "options", "->", "keepOriginalAuthor", "(", ")", "?", "$", "cvSource", "->", "getVersionAuthorUserID", "(", ")", ":", "$", "options", "->", "getCurrentUser", "(", ")", "->", "getUserID", "(", ")", ",", "'cvIsNew'", "=>", "$", "cvIsNew", ",", "'pThemeID'", "=>", "$", "cvSource", "->", "pThemeID", ",", "'pTemplateID'", "=>", "$", "cvSource", "->", "pTemplateID", ",", "// important: cvPublishDate used to be the same for the new version as it is for the current,", "// but it made it impossible to create a version that wasn't scheduled once you scheduled a version", "// so I'm turning it off for now - AE", "'cvPublishDate'", "=>", "null", ",", "]", ")", ";", "$", "this", "->", "copyData", "(", "$", "options", ",", "[", "$", "cSourceID", ",", "$", "cDestinationID", "]", ",", "[", "$", "cvSourceID", ",", "$", "cvDestinationID", "]", ")", ";", "$", "cvDestination", "=", "Version", "::", "get", "(", "$", "cSource", ",", "$", "cvDestinationID", ")", ";", "$", "ev", "=", "new", "CollectionVersionEvent", "(", "$", "cSource", ")", ";", "$", "ev", "->", "setCollectionVersionObject", "(", "$", "cvDestination", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "'on_page_version_add'", ",", "$", "ev", ")", ";", "$", "cvDestination", "->", "refreshCache", "(", ")", ";", "return", "$", "cvDestination", ";", "}" ]
Create a copy of a collection version to another collection. @param \Concrete\Core\Page\Collection\Version\Version $cvSource @param \Concrete\Core\Page\Collection\Collection $cDestination @param \Concrete\Core\Page\ClonerOptions $options the options for the cloning process @return \Concrete\Core\Page\Collection\Version\Version
[ "Create", "a", "copy", "of", "a", "collection", "version", "to", "another", "collection", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Cloner.php#L229-L281
train
concrete5/concrete5
concrete/src/Page/Cloner.php
Cloner.cloneBlock
public function cloneBlock(Block $block, Collection $destinationCollection) { $bID = $block->getBlockID(); $aHandle = $block->getAreaHandle(); $toID = $destinationCollection->getCollectionID(); $toCVID = $destinationCollection->getVersionID(); $already = $this->connection->fetchColumn( 'select bID from CollectionVersionBlocks where cID = ? and cvID = ? and bID = ? and arHandle = ? limit 1', [$toID, $toCVID, $bID, $aHandle] ); if ($already !== false) { return false; } $newBlockDisplayOrder = (int) $destinationCollection->getCollectionAreaDisplayOrder($aHandle); $sourceCollection = $block->getBlockCollectionID() ? $block->getBlockCollectionObject() : null; if ($sourceCollection) { $this->copyBlocks( [$sourceCollection->getCollectionID(), $destinationCollection->getCollectionID()], [$sourceCollection->getVersionID(), $destinationCollection->getVersionID()], [$bID, $bID], $newBlockDisplayOrder ); } else { $this->connection->insert( 'CollectionVersionBlocks', [ 'cID' => $toID, 'cvID' => $toCVID, 'bID' => $bID, 'arHandle' => $aHandle, 'cbRelationID' => $block->getBlockRelationID(), 'cbDisplayOrder' => $newBlockDisplayOrder, 'isOriginal' => 0, 'cbOverrideAreaPermissions' => $block->overrideAreaPermissions(), 'cbOverrideBlockTypeCacheSettings' => $block->overrideBlockTypeCacheSettings(), 'cbOverrideBlockTypeContainerSettings' => $block->overrideBlockTypeContainerSettings(), 'cbEnableBlockContainer' => $block->enableBlockContainer() ? 1 : 0, ] ); } return true; }
php
public function cloneBlock(Block $block, Collection $destinationCollection) { $bID = $block->getBlockID(); $aHandle = $block->getAreaHandle(); $toID = $destinationCollection->getCollectionID(); $toCVID = $destinationCollection->getVersionID(); $already = $this->connection->fetchColumn( 'select bID from CollectionVersionBlocks where cID = ? and cvID = ? and bID = ? and arHandle = ? limit 1', [$toID, $toCVID, $bID, $aHandle] ); if ($already !== false) { return false; } $newBlockDisplayOrder = (int) $destinationCollection->getCollectionAreaDisplayOrder($aHandle); $sourceCollection = $block->getBlockCollectionID() ? $block->getBlockCollectionObject() : null; if ($sourceCollection) { $this->copyBlocks( [$sourceCollection->getCollectionID(), $destinationCollection->getCollectionID()], [$sourceCollection->getVersionID(), $destinationCollection->getVersionID()], [$bID, $bID], $newBlockDisplayOrder ); } else { $this->connection->insert( 'CollectionVersionBlocks', [ 'cID' => $toID, 'cvID' => $toCVID, 'bID' => $bID, 'arHandle' => $aHandle, 'cbRelationID' => $block->getBlockRelationID(), 'cbDisplayOrder' => $newBlockDisplayOrder, 'isOriginal' => 0, 'cbOverrideAreaPermissions' => $block->overrideAreaPermissions(), 'cbOverrideBlockTypeCacheSettings' => $block->overrideBlockTypeCacheSettings(), 'cbOverrideBlockTypeContainerSettings' => $block->overrideBlockTypeContainerSettings(), 'cbEnableBlockContainer' => $block->enableBlockContainer() ? 1 : 0, ] ); } return true; }
[ "public", "function", "cloneBlock", "(", "Block", "$", "block", ",", "Collection", "$", "destinationCollection", ")", "{", "$", "bID", "=", "$", "block", "->", "getBlockID", "(", ")", ";", "$", "aHandle", "=", "$", "block", "->", "getAreaHandle", "(", ")", ";", "$", "toID", "=", "$", "destinationCollection", "->", "getCollectionID", "(", ")", ";", "$", "toCVID", "=", "$", "destinationCollection", "->", "getVersionID", "(", ")", ";", "$", "already", "=", "$", "this", "->", "connection", "->", "fetchColumn", "(", "'select bID from CollectionVersionBlocks where cID = ? and cvID = ? and bID = ? and arHandle = ? limit 1'", ",", "[", "$", "toID", ",", "$", "toCVID", ",", "$", "bID", ",", "$", "aHandle", "]", ")", ";", "if", "(", "$", "already", "!==", "false", ")", "{", "return", "false", ";", "}", "$", "newBlockDisplayOrder", "=", "(", "int", ")", "$", "destinationCollection", "->", "getCollectionAreaDisplayOrder", "(", "$", "aHandle", ")", ";", "$", "sourceCollection", "=", "$", "block", "->", "getBlockCollectionID", "(", ")", "?", "$", "block", "->", "getBlockCollectionObject", "(", ")", ":", "null", ";", "if", "(", "$", "sourceCollection", ")", "{", "$", "this", "->", "copyBlocks", "(", "[", "$", "sourceCollection", "->", "getCollectionID", "(", ")", ",", "$", "destinationCollection", "->", "getCollectionID", "(", ")", "]", ",", "[", "$", "sourceCollection", "->", "getVersionID", "(", ")", ",", "$", "destinationCollection", "->", "getVersionID", "(", ")", "]", ",", "[", "$", "bID", ",", "$", "bID", "]", ",", "$", "newBlockDisplayOrder", ")", ";", "}", "else", "{", "$", "this", "->", "connection", "->", "insert", "(", "'CollectionVersionBlocks'", ",", "[", "'cID'", "=>", "$", "toID", ",", "'cvID'", "=>", "$", "toCVID", ",", "'bID'", "=>", "$", "bID", ",", "'arHandle'", "=>", "$", "aHandle", ",", "'cbRelationID'", "=>", "$", "block", "->", "getBlockRelationID", "(", ")", ",", "'cbDisplayOrder'", "=>", "$", "newBlockDisplayOrder", ",", "'isOriginal'", "=>", "0", ",", "'cbOverrideAreaPermissions'", "=>", "$", "block", "->", "overrideAreaPermissions", "(", ")", ",", "'cbOverrideBlockTypeCacheSettings'", "=>", "$", "block", "->", "overrideBlockTypeCacheSettings", "(", ")", ",", "'cbOverrideBlockTypeContainerSettings'", "=>", "$", "block", "->", "overrideBlockTypeContainerSettings", "(", ")", ",", "'cbEnableBlockContainer'", "=>", "$", "block", "->", "enableBlockContainer", "(", ")", "?", "1", ":", "0", ",", "]", ")", ";", "}", "return", "true", ";", "}" ]
Create an alias of a block to another collection. @param \Concrete\Core\Block\Block $block @param \Concrete\Core\Page\Collection\Collection $destinationCollection @return bool returns FALSE if $block is not cloned because it's already present in $destinationCollection, TRUE otherwise
[ "Create", "an", "alias", "of", "a", "block", "to", "another", "collection", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Cloner.php#L291-L333
train
concrete5/concrete5
concrete/src/Page/Cloner.php
Cloner.getUniquePageName
protected function getUniquePageName($pageName, $parentID) { $uniquePageName = $pageName; $parentID = (int) $parentID; $index = 1; for (; ;) { $pageWithSameName = $this->connection->fetchColumn( 'select Pages.cID from CollectionVersions inner join Pages on (CollectionVersions.cID = Pages.cID and CollectionVersions.cvIsApproved = 1) where Pages.cParentID = ? and CollectionVersions.cvName = ? limit 1', [$parentID, $uniquePageName] ); if ($pageWithSameName === false) { return $uniquePageName; } ++$index; $uniquePageName = $pageName . ' ' . $index; } }
php
protected function getUniquePageName($pageName, $parentID) { $uniquePageName = $pageName; $parentID = (int) $parentID; $index = 1; for (; ;) { $pageWithSameName = $this->connection->fetchColumn( 'select Pages.cID from CollectionVersions inner join Pages on (CollectionVersions.cID = Pages.cID and CollectionVersions.cvIsApproved = 1) where Pages.cParentID = ? and CollectionVersions.cvName = ? limit 1', [$parentID, $uniquePageName] ); if ($pageWithSameName === false) { return $uniquePageName; } ++$index; $uniquePageName = $pageName . ' ' . $index; } }
[ "protected", "function", "getUniquePageName", "(", "$", "pageName", ",", "$", "parentID", ")", "{", "$", "uniquePageName", "=", "$", "pageName", ";", "$", "parentID", "=", "(", "int", ")", "$", "parentID", ";", "$", "index", "=", "1", ";", "for", "(", ";", ";", ")", "{", "$", "pageWithSameName", "=", "$", "this", "->", "connection", "->", "fetchColumn", "(", "'select Pages.cID from CollectionVersions inner join Pages on (CollectionVersions.cID = Pages.cID and CollectionVersions.cvIsApproved = 1) where Pages.cParentID = ? and CollectionVersions.cvName = ? limit 1'", ",", "[", "$", "parentID", ",", "$", "uniquePageName", "]", ")", ";", "if", "(", "$", "pageWithSameName", "===", "false", ")", "{", "return", "$", "uniquePageName", ";", "}", "++", "$", "index", ";", "$", "uniquePageName", "=", "$", "pageName", ".", "' '", ".", "$", "index", ";", "}", "}" ]
Get the name of a page that's unique for the parent. @param string $pageName @param int $parentID @return string
[ "Get", "the", "name", "of", "a", "page", "that", "s", "unique", "for", "the", "parent", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Cloner.php#L343-L359
train
concrete5/concrete5
concrete/src/Page/Cloner.php
Cloner.getUniquePageHandle
protected function getUniquePageHandle($handle, $parentID) { $uniqueHandle = $handle; $parentID = (int) $parentID; $index = 1; for (; ;) { $pageWithSameHandle = $this->connection->fetchColumn( 'select Pages.cID from CollectionVersions inner join Pages on (CollectionVersions.cID = Pages.cID and CollectionVersions.cvIsApproved = 1) where Pages.cParentID = ? and CollectionVersions.cvHandle = ? limit 1', [$parentID, $uniqueHandle] ); if ($pageWithSameHandle === false) { return $uniqueHandle; } ++$index; $uniqueHandle = $handle . '-' . $index; } }
php
protected function getUniquePageHandle($handle, $parentID) { $uniqueHandle = $handle; $parentID = (int) $parentID; $index = 1; for (; ;) { $pageWithSameHandle = $this->connection->fetchColumn( 'select Pages.cID from CollectionVersions inner join Pages on (CollectionVersions.cID = Pages.cID and CollectionVersions.cvIsApproved = 1) where Pages.cParentID = ? and CollectionVersions.cvHandle = ? limit 1', [$parentID, $uniqueHandle] ); if ($pageWithSameHandle === false) { return $uniqueHandle; } ++$index; $uniqueHandle = $handle . '-' . $index; } }
[ "protected", "function", "getUniquePageHandle", "(", "$", "handle", ",", "$", "parentID", ")", "{", "$", "uniqueHandle", "=", "$", "handle", ";", "$", "parentID", "=", "(", "int", ")", "$", "parentID", ";", "$", "index", "=", "1", ";", "for", "(", ";", ";", ")", "{", "$", "pageWithSameHandle", "=", "$", "this", "->", "connection", "->", "fetchColumn", "(", "'select Pages.cID from CollectionVersions inner join Pages on (CollectionVersions.cID = Pages.cID and CollectionVersions.cvIsApproved = 1) where Pages.cParentID = ? and CollectionVersions.cvHandle = ? limit 1'", ",", "[", "$", "parentID", ",", "$", "uniqueHandle", "]", ")", ";", "if", "(", "$", "pageWithSameHandle", "===", "false", ")", "{", "return", "$", "uniqueHandle", ";", "}", "++", "$", "index", ";", "$", "uniqueHandle", "=", "$", "handle", ".", "'-'", ".", "$", "index", ";", "}", "}" ]
Get the handle of a page that's unique for the parent. @param string $handle @param int $parentID @return string
[ "Get", "the", "handle", "of", "a", "page", "that", "s", "unique", "for", "the", "parent", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Cloner.php#L369-L385
train
concrete5/concrete5
concrete/src/Page/Sitemap/DragRequestData.php
DragRequestData.canDoAnyOf
public function canDoAnyOf(array $operations) { foreach ($operations as $operation) { if ($this->canDo($operation)) { return true; } } return false; }
php
public function canDoAnyOf(array $operations) { foreach ($operations as $operation) { if ($this->canDo($operation)) { return true; } } return false; }
[ "public", "function", "canDoAnyOf", "(", "array", "$", "operations", ")", "{", "foreach", "(", "$", "operations", "as", "$", "operation", ")", "{", "if", "(", "$", "this", "->", "canDo", "(", "$", "operation", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if at least one operation can be performed. @param string[] $operations The values of one of the OPERATION_... constants @return bool
[ "Check", "if", "at", "least", "one", "operation", "can", "be", "performed", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Sitemap/DragRequestData.php#L208-L217
train
concrete5/concrete5
concrete/src/Page/Sitemap/DragRequestData.php
DragRequestData.whyCantDo
public function whyCantDo($operation) { if (!is_string($operation)) { return 'Invalid $operation'; } if (!isset($this->operationErrors[$operation])) { switch ($operation) { case static::OPERATION_MOVE: $error = $this->whyCantMove(); break; case static::OPERATION_ALIAS: $error = $this->whyCantAlias(); break; case static::OPERATION_COPY: $error = $this->whyCantCopy(); break; case static::OPERATION_COPYALL: $error = $this->whyCantDo(static::OPERATION_COPY); if ($error === '') { $error = $this->whyCantCopyAll(); } break; case static::OPERATION_COPYVERSION: $error = $this->whyCantCopyVersion(); break; default: return 'Invalid $operation'; } $this->operationErrors[$operation] = $error; } return $this->operationErrors[$operation]; }
php
public function whyCantDo($operation) { if (!is_string($operation)) { return 'Invalid $operation'; } if (!isset($this->operationErrors[$operation])) { switch ($operation) { case static::OPERATION_MOVE: $error = $this->whyCantMove(); break; case static::OPERATION_ALIAS: $error = $this->whyCantAlias(); break; case static::OPERATION_COPY: $error = $this->whyCantCopy(); break; case static::OPERATION_COPYALL: $error = $this->whyCantDo(static::OPERATION_COPY); if ($error === '') { $error = $this->whyCantCopyAll(); } break; case static::OPERATION_COPYVERSION: $error = $this->whyCantCopyVersion(); break; default: return 'Invalid $operation'; } $this->operationErrors[$operation] = $error; } return $this->operationErrors[$operation]; }
[ "public", "function", "whyCantDo", "(", "$", "operation", ")", "{", "if", "(", "!", "is_string", "(", "$", "operation", ")", ")", "{", "return", "'Invalid $operation'", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "operationErrors", "[", "$", "operation", "]", ")", ")", "{", "switch", "(", "$", "operation", ")", "{", "case", "static", "::", "OPERATION_MOVE", ":", "$", "error", "=", "$", "this", "->", "whyCantMove", "(", ")", ";", "break", ";", "case", "static", "::", "OPERATION_ALIAS", ":", "$", "error", "=", "$", "this", "->", "whyCantAlias", "(", ")", ";", "break", ";", "case", "static", "::", "OPERATION_COPY", ":", "$", "error", "=", "$", "this", "->", "whyCantCopy", "(", ")", ";", "break", ";", "case", "static", "::", "OPERATION_COPYALL", ":", "$", "error", "=", "$", "this", "->", "whyCantDo", "(", "static", "::", "OPERATION_COPY", ")", ";", "if", "(", "$", "error", "===", "''", ")", "{", "$", "error", "=", "$", "this", "->", "whyCantCopyAll", "(", ")", ";", "}", "break", ";", "case", "static", "::", "OPERATION_COPYVERSION", ":", "$", "error", "=", "$", "this", "->", "whyCantCopyVersion", "(", ")", ";", "break", ";", "default", ":", "return", "'Invalid $operation'", ";", "}", "$", "this", "->", "operationErrors", "[", "$", "operation", "]", "=", "$", "error", ";", "}", "return", "$", "this", "->", "operationErrors", "[", "$", "operation", "]", ";", "}" ]
Get the reason why an operation can't be performed. @param string $operation The value of one of the OPERATION_... constants. @return string empty string if the operation CAN be performed
[ "Get", "the", "reason", "why", "an", "operation", "can", "t", "be", "performed", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Sitemap/DragRequestData.php#L226-L258
train
concrete5/concrete5
concrete/src/Page/Sitemap/DragRequestData.php
DragRequestData.whyCantMove
protected function whyCantMove() { $destinationPageChecker = new Checker($this->getDestinationPage()); $destinationPageID = $this->getDestinationPage()->getCollectionID(); foreach ($this->getOriginalPages() as $originalPage) { if ($originalPage->getCollectionParentID() == $destinationPageID) { return t('"%1$s" is already the parent page of "%2$s".', $this->getDestinationPage()->getCollectionName(), $originalPage->getCollectionName()); } $originalPageChecker = new Checker($originalPage); if (!$originalPageChecker->canMoveOrCopyPage()) { return t('You don\'t have the permission move the page "%s".', $originalPage->getCollectionName()); } if ($originalPage->getCollectionID() == $destinationPageID) { return t('It\'s not possible to move the page "%s" under itself.', $originalPage->getCollectionName()); } if (in_array($destinationPageID, $originalPage->getCollectionChildrenArray())) { return t('It\'s not possible to move the page "%s" under one of its child pages.', $originalPage->getCollectionName()); } $originalPageType = $originalPage->getPageTypeObject(); if (!$destinationPageChecker->canAddSubpage($originalPageType)) { return t('You do not have sufficient privileges to move the page "%1$s" under "%2$s".', $originalPage->getCollectionName(), $this->getDestinationPage()->getCollectionName()); } } return ''; }
php
protected function whyCantMove() { $destinationPageChecker = new Checker($this->getDestinationPage()); $destinationPageID = $this->getDestinationPage()->getCollectionID(); foreach ($this->getOriginalPages() as $originalPage) { if ($originalPage->getCollectionParentID() == $destinationPageID) { return t('"%1$s" is already the parent page of "%2$s".', $this->getDestinationPage()->getCollectionName(), $originalPage->getCollectionName()); } $originalPageChecker = new Checker($originalPage); if (!$originalPageChecker->canMoveOrCopyPage()) { return t('You don\'t have the permission move the page "%s".', $originalPage->getCollectionName()); } if ($originalPage->getCollectionID() == $destinationPageID) { return t('It\'s not possible to move the page "%s" under itself.', $originalPage->getCollectionName()); } if (in_array($destinationPageID, $originalPage->getCollectionChildrenArray())) { return t('It\'s not possible to move the page "%s" under one of its child pages.', $originalPage->getCollectionName()); } $originalPageType = $originalPage->getPageTypeObject(); if (!$destinationPageChecker->canAddSubpage($originalPageType)) { return t('You do not have sufficient privileges to move the page "%1$s" under "%2$s".', $originalPage->getCollectionName(), $this->getDestinationPage()->getCollectionName()); } } return ''; }
[ "protected", "function", "whyCantMove", "(", ")", "{", "$", "destinationPageChecker", "=", "new", "Checker", "(", "$", "this", "->", "getDestinationPage", "(", ")", ")", ";", "$", "destinationPageID", "=", "$", "this", "->", "getDestinationPage", "(", ")", "->", "getCollectionID", "(", ")", ";", "foreach", "(", "$", "this", "->", "getOriginalPages", "(", ")", "as", "$", "originalPage", ")", "{", "if", "(", "$", "originalPage", "->", "getCollectionParentID", "(", ")", "==", "$", "destinationPageID", ")", "{", "return", "t", "(", "'\"%1$s\" is already the parent page of \"%2$s\".'", ",", "$", "this", "->", "getDestinationPage", "(", ")", "->", "getCollectionName", "(", ")", ",", "$", "originalPage", "->", "getCollectionName", "(", ")", ")", ";", "}", "$", "originalPageChecker", "=", "new", "Checker", "(", "$", "originalPage", ")", ";", "if", "(", "!", "$", "originalPageChecker", "->", "canMoveOrCopyPage", "(", ")", ")", "{", "return", "t", "(", "'You don\\'t have the permission move the page \"%s\".'", ",", "$", "originalPage", "->", "getCollectionName", "(", ")", ")", ";", "}", "if", "(", "$", "originalPage", "->", "getCollectionID", "(", ")", "==", "$", "destinationPageID", ")", "{", "return", "t", "(", "'It\\'s not possible to move the page \"%s\" under itself.'", ",", "$", "originalPage", "->", "getCollectionName", "(", ")", ")", ";", "}", "if", "(", "in_array", "(", "$", "destinationPageID", ",", "$", "originalPage", "->", "getCollectionChildrenArray", "(", ")", ")", ")", "{", "return", "t", "(", "'It\\'s not possible to move the page \"%s\" under one of its child pages.'", ",", "$", "originalPage", "->", "getCollectionName", "(", ")", ")", ";", "}", "$", "originalPageType", "=", "$", "originalPage", "->", "getPageTypeObject", "(", ")", ";", "if", "(", "!", "$", "destinationPageChecker", "->", "canAddSubpage", "(", "$", "originalPageType", ")", ")", "{", "return", "t", "(", "'You do not have sufficient privileges to move the page \"%1$s\" under \"%2$s\".'", ",", "$", "originalPage", "->", "getCollectionName", "(", ")", ",", "$", "this", "->", "getDestinationPage", "(", ")", "->", "getCollectionName", "(", ")", ")", ";", "}", "}", "return", "''", ";", "}" ]
Get the reason why the move operation can't be performed. @return string empty string if the operation CAN be performed
[ "Get", "the", "reason", "why", "the", "move", "operation", "can", "t", "be", "performed", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Sitemap/DragRequestData.php#L383-L408
train
concrete5/concrete5
concrete/src/Page/Sitemap/DragRequestData.php
DragRequestData.whyCantAlias
protected function whyCantAlias() { if ($this->isSomeOriginalPageAnAlias()) { return t('It\'s not possible to create aliases of aliases.'); } $destinationPageChecker = new Checker($this->getDestinationPage()); foreach ($this->getOriginalPages() as $originalPage) { $originalPageChecker = new Checker($originalPage); if (!$originalPageChecker->canMoveOrCopyPage()) { return t('You don\'t have the permission to create an alias of the page "%s".', $originalPage->getCollectionName()); } $originalPageType = $originalPage->getPageTypeObject(); if (!$destinationPageChecker->canAddSubpage($originalPageType)) { return t('You do not have sufficient privileges to alias the page "%1$s" under "%2$s".', $originalPage->getCollectionName(), $this->getDestinationPage()->getCollectionName()); } } return ''; }
php
protected function whyCantAlias() { if ($this->isSomeOriginalPageAnAlias()) { return t('It\'s not possible to create aliases of aliases.'); } $destinationPageChecker = new Checker($this->getDestinationPage()); foreach ($this->getOriginalPages() as $originalPage) { $originalPageChecker = new Checker($originalPage); if (!$originalPageChecker->canMoveOrCopyPage()) { return t('You don\'t have the permission to create an alias of the page "%s".', $originalPage->getCollectionName()); } $originalPageType = $originalPage->getPageTypeObject(); if (!$destinationPageChecker->canAddSubpage($originalPageType)) { return t('You do not have sufficient privileges to alias the page "%1$s" under "%2$s".', $originalPage->getCollectionName(), $this->getDestinationPage()->getCollectionName()); } } return ''; }
[ "protected", "function", "whyCantAlias", "(", ")", "{", "if", "(", "$", "this", "->", "isSomeOriginalPageAnAlias", "(", ")", ")", "{", "return", "t", "(", "'It\\'s not possible to create aliases of aliases.'", ")", ";", "}", "$", "destinationPageChecker", "=", "new", "Checker", "(", "$", "this", "->", "getDestinationPage", "(", ")", ")", ";", "foreach", "(", "$", "this", "->", "getOriginalPages", "(", ")", "as", "$", "originalPage", ")", "{", "$", "originalPageChecker", "=", "new", "Checker", "(", "$", "originalPage", ")", ";", "if", "(", "!", "$", "originalPageChecker", "->", "canMoveOrCopyPage", "(", ")", ")", "{", "return", "t", "(", "'You don\\'t have the permission to create an alias of the page \"%s\".'", ",", "$", "originalPage", "->", "getCollectionName", "(", ")", ")", ";", "}", "$", "originalPageType", "=", "$", "originalPage", "->", "getPageTypeObject", "(", ")", ";", "if", "(", "!", "$", "destinationPageChecker", "->", "canAddSubpage", "(", "$", "originalPageType", ")", ")", "{", "return", "t", "(", "'You do not have sufficient privileges to alias the page \"%1$s\" under \"%2$s\".'", ",", "$", "originalPage", "->", "getCollectionName", "(", ")", ",", "$", "this", "->", "getDestinationPage", "(", ")", "->", "getCollectionName", "(", ")", ")", ";", "}", "}", "return", "''", ";", "}" ]
Get the reason why the alias operation can't be performed. @return string empty string if the operation CAN be performed
[ "Get", "the", "reason", "why", "the", "alias", "operation", "can", "t", "be", "performed", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Sitemap/DragRequestData.php#L415-L433
train
concrete5/concrete5
concrete/src/Page/Sitemap/DragRequestData.php
DragRequestData.whyCantCopyVersion
protected function whyCantCopyVersion() { $originalPage = $this->getSingleOriginalPage(); if ($originalPage === null) { return t("It's possible to copy just one page version at a time."); } if ($originalPage->isExternalLink()) { return t("It's not possible to copy the page version of an external URL."); } if ($originalPage->isAliasPage()) { return t("It's not possible to copy the page version of aliases."); } $destinationPage = $this->getDestinationPage(); if ($destinationPage->getCollectionID() == $originalPage->getCollectionID()) { return t("It's not possible to copy the page version of a page to the page itself."); } $pc = new Checker($destinationPage); if (!$pc->canWrite()) { return t('You don\'t have the permission to edit the contents of "%s".', $destinationPage->getCollectionName()); } return ''; }
php
protected function whyCantCopyVersion() { $originalPage = $this->getSingleOriginalPage(); if ($originalPage === null) { return t("It's possible to copy just one page version at a time."); } if ($originalPage->isExternalLink()) { return t("It's not possible to copy the page version of an external URL."); } if ($originalPage->isAliasPage()) { return t("It's not possible to copy the page version of aliases."); } $destinationPage = $this->getDestinationPage(); if ($destinationPage->getCollectionID() == $originalPage->getCollectionID()) { return t("It's not possible to copy the page version of a page to the page itself."); } $pc = new Checker($destinationPage); if (!$pc->canWrite()) { return t('You don\'t have the permission to edit the contents of "%s".', $destinationPage->getCollectionName()); } return ''; }
[ "protected", "function", "whyCantCopyVersion", "(", ")", "{", "$", "originalPage", "=", "$", "this", "->", "getSingleOriginalPage", "(", ")", ";", "if", "(", "$", "originalPage", "===", "null", ")", "{", "return", "t", "(", "\"It's possible to copy just one page version at a time.\"", ")", ";", "}", "if", "(", "$", "originalPage", "->", "isExternalLink", "(", ")", ")", "{", "return", "t", "(", "\"It's not possible to copy the page version of an external URL.\"", ")", ";", "}", "if", "(", "$", "originalPage", "->", "isAliasPage", "(", ")", ")", "{", "return", "t", "(", "\"It's not possible to copy the page version of aliases.\"", ")", ";", "}", "$", "destinationPage", "=", "$", "this", "->", "getDestinationPage", "(", ")", ";", "if", "(", "$", "destinationPage", "->", "getCollectionID", "(", ")", "==", "$", "originalPage", "->", "getCollectionID", "(", ")", ")", "{", "return", "t", "(", "\"It's not possible to copy the page version of a page to the page itself.\"", ")", ";", "}", "$", "pc", "=", "new", "Checker", "(", "$", "destinationPage", ")", ";", "if", "(", "!", "$", "pc", "->", "canWrite", "(", ")", ")", "{", "return", "t", "(", "'You don\\'t have the permission to edit the contents of \"%s\".'", ",", "$", "destinationPage", "->", "getCollectionName", "(", ")", ")", ";", "}", "return", "''", ";", "}" ]
Get the reason why the copy-version operation can't be performed. @return string empty string if the operation CAN be performed
[ "Get", "the", "reason", "why", "the", "copy", "-", "version", "operation", "can", "t", "be", "performed", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Sitemap/DragRequestData.php#L493-L515
train
concrete5/concrete5
concrete/src/Tree/Type/FileManager.php
FileManager.get
public static function get() { $db = Database::connection(); $treeID = $db->fetchColumn('select Trees.treeID from TreeTypes inner join Trees on TreeTypes.treeTypeID = Trees.treeTypeID where TreeTypes.treeTypeHandle = ?', ['file_manager']); return $treeID ? Tree::getByID($treeID) : null; }
php
public static function get() { $db = Database::connection(); $treeID = $db->fetchColumn('select Trees.treeID from TreeTypes inner join Trees on TreeTypes.treeTypeID = Trees.treeTypeID where TreeTypes.treeTypeHandle = ?', ['file_manager']); return $treeID ? Tree::getByID($treeID) : null; }
[ "public", "static", "function", "get", "(", ")", "{", "$", "db", "=", "Database", "::", "connection", "(", ")", ";", "$", "treeID", "=", "$", "db", "->", "fetchColumn", "(", "'select Trees.treeID from TreeTypes inner join Trees on TreeTypes.treeTypeID = Trees.treeTypeID where TreeTypes.treeTypeHandle = ?'", ",", "[", "'file_manager'", "]", ")", ";", "return", "$", "treeID", "?", "Tree", "::", "getByID", "(", "$", "treeID", ")", ":", "null", ";", "}" ]
Get the FileManager instance. @return FileManager|null
[ "Get", "the", "FileManager", "instance", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Tree/Type/FileManager.php#L45-L51
train
concrete5/concrete5
concrete/src/Conversation/Conversation.php
Conversation.getConversationUsersToEmail
public function getConversationUsersToEmail() { $db = Loader::db(); $ids = array(); if (!$this->getConversationNotificationOverridesEnabled() > 0) { $ids = $db->GetCol('select uID from ConversationSubscriptions where cnvID = 0'); } $r = $db->Execute('select uID, type from ConversationSubscriptions where cnvID = ?', array($this->getConversationID())); while ($row = $r->FetchRow()) { if ($row['type'] == 'U' && in_array($row['uID'], $ids)) { $ids = array_diff($ids, array($row['uID'])); } else { $ids[] = $row['uID']; } } $ids = array_unique($ids); $users = array(); foreach ($ids as $uID) { $ui = \UserInfo::getByID($uID); if (is_object($ui)) { $users[] = $ui; } } return $users; }
php
public function getConversationUsersToEmail() { $db = Loader::db(); $ids = array(); if (!$this->getConversationNotificationOverridesEnabled() > 0) { $ids = $db->GetCol('select uID from ConversationSubscriptions where cnvID = 0'); } $r = $db->Execute('select uID, type from ConversationSubscriptions where cnvID = ?', array($this->getConversationID())); while ($row = $r->FetchRow()) { if ($row['type'] == 'U' && in_array($row['uID'], $ids)) { $ids = array_diff($ids, array($row['uID'])); } else { $ids[] = $row['uID']; } } $ids = array_unique($ids); $users = array(); foreach ($ids as $uID) { $ui = \UserInfo::getByID($uID); if (is_object($ui)) { $users[] = $ui; } } return $users; }
[ "public", "function", "getConversationUsersToEmail", "(", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "ids", "=", "array", "(", ")", ";", "if", "(", "!", "$", "this", "->", "getConversationNotificationOverridesEnabled", "(", ")", ">", "0", ")", "{", "$", "ids", "=", "$", "db", "->", "GetCol", "(", "'select uID from ConversationSubscriptions where cnvID = 0'", ")", ";", "}", "$", "r", "=", "$", "db", "->", "Execute", "(", "'select uID, type from ConversationSubscriptions where cnvID = ?'", ",", "array", "(", "$", "this", "->", "getConversationID", "(", ")", ")", ")", ";", "while", "(", "$", "row", "=", "$", "r", "->", "FetchRow", "(", ")", ")", "{", "if", "(", "$", "row", "[", "'type'", "]", "==", "'U'", "&&", "in_array", "(", "$", "row", "[", "'uID'", "]", ",", "$", "ids", ")", ")", "{", "$", "ids", "=", "array_diff", "(", "$", "ids", ",", "array", "(", "$", "row", "[", "'uID'", "]", ")", ")", ";", "}", "else", "{", "$", "ids", "[", "]", "=", "$", "row", "[", "'uID'", "]", ";", "}", "}", "$", "ids", "=", "array_unique", "(", "$", "ids", ")", ";", "$", "users", "=", "array", "(", ")", ";", "foreach", "(", "$", "ids", "as", "$", "uID", ")", "{", "$", "ui", "=", "\\", "UserInfo", "::", "getByID", "(", "$", "uID", ")", ";", "if", "(", "is_object", "(", "$", "ui", ")", ")", "{", "$", "users", "[", "]", "=", "$", "ui", ";", "}", "}", "return", "$", "users", ";", "}" ]
Similar to the method below, but excludes global subscribers who have opted out of conversations, etc... This method should be used any time we actually act on subscriptions, send emails, etc...
[ "Similar", "to", "the", "method", "below", "but", "excludes", "global", "subscribers", "who", "have", "opted", "out", "of", "conversations", "etc", "...", "This", "method", "should", "be", "used", "any", "time", "we", "actually", "act", "on", "subscriptions", "send", "emails", "etc", "..." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Conversation/Conversation.php#L302-L332
train
concrete5/concrete5
concrete/src/Permission/Response/FileFolderResponse.php
FileFolderResponse.getAllowedFileExtensions
public function getAllowedFileExtensions() { $pk = $this->category->getPermissionKeyByHandle('add_file'); $pk->setPermissionObject($this->object); $r = $pk->getAllowedFileExtensions(); return $r; }
php
public function getAllowedFileExtensions() { $pk = $this->category->getPermissionKeyByHandle('add_file'); $pk->setPermissionObject($this->object); $r = $pk->getAllowedFileExtensions(); return $r; }
[ "public", "function", "getAllowedFileExtensions", "(", ")", "{", "$", "pk", "=", "$", "this", "->", "category", "->", "getPermissionKeyByHandle", "(", "'add_file'", ")", ";", "$", "pk", "->", "setPermissionObject", "(", "$", "this", "->", "object", ")", ";", "$", "r", "=", "$", "pk", "->", "getAllowedFileExtensions", "(", ")", ";", "return", "$", "r", ";", "}" ]
Returns all file extensions this user can add.
[ "Returns", "all", "file", "extensions", "this", "user", "can", "add", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Permission/Response/FileFolderResponse.php#L61-L68
train
concrete5/concrete5
concrete/src/Html/Object/HeadLink.php
HeadLink.create
public static function create($href = '#', $rel = null, $type = null, $media = null) { return new static($href, $rel, $type, $media); }
php
public static function create($href = '#', $rel = null, $type = null, $media = null) { return new static($href, $rel, $type, $media); }
[ "public", "static", "function", "create", "(", "$", "href", "=", "'#'", ",", "$", "rel", "=", "null", ",", "$", "type", "=", "null", ",", "$", "media", "=", "null", ")", "{", "return", "new", "static", "(", "$", "href", ",", "$", "rel", ",", "$", "type", ",", "$", "media", ")", ";", "}" ]
Static alias for constructor. @param string $href Link url @param string $rel Link relation (stylesheet) @param string $type Link type (text/css) @param string $media Link media (screen, print, etc) @return HeadLink
[ "Static", "alias", "for", "constructor", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Html/Object/HeadLink.php#L53-L56
train
concrete5/concrete5
concrete/src/Api/ApiServiceProvider.php
ApiServiceProvider.register
public function register() { $config = $this->app->make("config"); if ($this->app->isInstalled() && $config->get('concrete.api.enabled')) { $router = $this->app->make(Router::class); $list = new ApiRouteList(); $list->loadRoutes($router); $this->registerAuthorizationServer(); } }
php
public function register() { $config = $this->app->make("config"); if ($this->app->isInstalled() && $config->get('concrete.api.enabled')) { $router = $this->app->make(Router::class); $list = new ApiRouteList(); $list->loadRoutes($router); $this->registerAuthorizationServer(); } }
[ "public", "function", "register", "(", ")", "{", "$", "config", "=", "$", "this", "->", "app", "->", "make", "(", "\"config\"", ")", ";", "if", "(", "$", "this", "->", "app", "->", "isInstalled", "(", ")", "&&", "$", "config", "->", "get", "(", "'concrete.api.enabled'", ")", ")", "{", "$", "router", "=", "$", "this", "->", "app", "->", "make", "(", "Router", "::", "class", ")", ";", "$", "list", "=", "new", "ApiRouteList", "(", ")", ";", "$", "list", "->", "loadRoutes", "(", "$", "router", ")", ";", "$", "this", "->", "registerAuthorizationServer", "(", ")", ";", "}", "}" ]
Register API related stuff @return void
[ "Register", "API", "related", "stuff" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Api/ApiServiceProvider.php#L45-L54
train
concrete5/concrete5
concrete/src/Api/ApiServiceProvider.php
ApiServiceProvider.getKeyPair
private function getKeyPair() { $config = $this->app->make('config/database'); // Seee if we already have a kypair $keyPair = $config->get('api.keypair'); if (!$keyPair) { $rsa = $this->app->make(RSA::class); // Generate a new RSA key $keyPair = $rsa->createKey(2048); foreach ($keyPair as &$item) { $item = str_replace("\r\n", "\n", $item); } // Save the keypair $config->save('api.keypair', $keyPair); } return $keyPair; }
php
private function getKeyPair() { $config = $this->app->make('config/database'); // Seee if we already have a kypair $keyPair = $config->get('api.keypair'); if (!$keyPair) { $rsa = $this->app->make(RSA::class); // Generate a new RSA key $keyPair = $rsa->createKey(2048); foreach ($keyPair as &$item) { $item = str_replace("\r\n", "\n", $item); } // Save the keypair $config->save('api.keypair', $keyPair); } return $keyPair; }
[ "private", "function", "getKeyPair", "(", ")", "{", "$", "config", "=", "$", "this", "->", "app", "->", "make", "(", "'config/database'", ")", ";", "// Seee if we already have a kypair", "$", "keyPair", "=", "$", "config", "->", "get", "(", "'api.keypair'", ")", ";", "if", "(", "!", "$", "keyPair", ")", "{", "$", "rsa", "=", "$", "this", "->", "app", "->", "make", "(", "RSA", "::", "class", ")", ";", "// Generate a new RSA key", "$", "keyPair", "=", "$", "rsa", "->", "createKey", "(", "2048", ")", ";", "foreach", "(", "$", "keyPair", "as", "&", "$", "item", ")", "{", "$", "item", "=", "str_replace", "(", "\"\\r\\n\"", ",", "\"\\n\"", ",", "$", "item", ")", ";", "}", "// Save the keypair", "$", "config", "->", "save", "(", "'api.keypair'", ",", "$", "keyPair", ")", ";", "}", "return", "$", "keyPair", ";", "}" ]
Generate new RSA keys if needed @return string[] ['privatekey' => '...', 'publickey' => '...']
[ "Generate", "new", "RSA", "keys", "if", "needed" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Api/ApiServiceProvider.php#L81-L103
train
concrete5/concrete5
concrete/src/Api/ApiServiceProvider.php
ApiServiceProvider.getKey
private function getKey($handle) { if (!$this->keyPair) { $this->keyPair = $this->getKeyPair(); } return isset($this->keyPair[$handle]) ? $this->keyPair[$handle] : null; }
php
private function getKey($handle) { if (!$this->keyPair) { $this->keyPair = $this->getKeyPair(); } return isset($this->keyPair[$handle]) ? $this->keyPair[$handle] : null; }
[ "private", "function", "getKey", "(", "$", "handle", ")", "{", "if", "(", "!", "$", "this", "->", "keyPair", ")", "{", "$", "this", "->", "keyPair", "=", "$", "this", "->", "getKeyPair", "(", ")", ";", "}", "return", "isset", "(", "$", "this", "->", "keyPair", "[", "$", "handle", "]", ")", "?", "$", "this", "->", "keyPair", "[", "$", "handle", "]", ":", "null", ";", "}" ]
Get a key by handle @param $handle privatekey | publickey @return string|null
[ "Get", "a", "key", "by", "handle" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Api/ApiServiceProvider.php#L110-L117
train
concrete5/concrete5
concrete/src/Http/Middleware/OAuthErrorMiddleware.php
OAuthErrorMiddleware.process
public function process(Request $request, DelegateInterface $frame) { try { // Try returning the response normally return $frame->next($request); } catch (OAuthServerException $e) { // Generate an error based on the exception return $e->generateHttpResponse(new Response()); } }
php
public function process(Request $request, DelegateInterface $frame) { try { // Try returning the response normally return $frame->next($request); } catch (OAuthServerException $e) { // Generate an error based on the exception return $e->generateHttpResponse(new Response()); } }
[ "public", "function", "process", "(", "Request", "$", "request", ",", "DelegateInterface", "$", "frame", ")", "{", "try", "{", "// Try returning the response normally", "return", "$", "frame", "->", "next", "(", "$", "request", ")", ";", "}", "catch", "(", "OAuthServerException", "$", "e", ")", "{", "// Generate an error based on the exception", "return", "$", "e", "->", "generateHttpResponse", "(", "new", "Response", "(", ")", ")", ";", "}", "}" ]
Process the request and return a PSR7 error response if needed @param \Symfony\Component\HttpFoundation\Request $request @param DelegateInterface $frame @return \Psr\Http\Message\ResponseInterface
[ "Process", "the", "request", "and", "return", "a", "PSR7", "error", "response", "if", "needed" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Http/Middleware/OAuthErrorMiddleware.php#L21-L30
train
concrete5/concrete5
concrete/src/Mail/Service.php
Service.addAttachmentWithHeaders
public function addAttachmentWithHeaders(File $file, array $headers) { $fileVersion = $file->getVersion(); $resource = $fileVersion->getFileResource(); if (array_key_exists('filename', $headers)) { $filename = $headers['filename']; unset($headers['filename']); } else { $filename = $fileVersion->getFilename(); } if (!array_key_exists('mimetype', $headers)) { $headers['mimetype'] = $resource->getMimetype(); } $this->addRawAttachmentWithHeaders( $resource->read(), $filename, $headers ); }
php
public function addAttachmentWithHeaders(File $file, array $headers) { $fileVersion = $file->getVersion(); $resource = $fileVersion->getFileResource(); if (array_key_exists('filename', $headers)) { $filename = $headers['filename']; unset($headers['filename']); } else { $filename = $fileVersion->getFilename(); } if (!array_key_exists('mimetype', $headers)) { $headers['mimetype'] = $resource->getMimetype(); } $this->addRawAttachmentWithHeaders( $resource->read(), $filename, $headers ); }
[ "public", "function", "addAttachmentWithHeaders", "(", "File", "$", "file", ",", "array", "$", "headers", ")", "{", "$", "fileVersion", "=", "$", "file", "->", "getVersion", "(", ")", ";", "$", "resource", "=", "$", "fileVersion", "->", "getFileResource", "(", ")", ";", "if", "(", "array_key_exists", "(", "'filename'", ",", "$", "headers", ")", ")", "{", "$", "filename", "=", "$", "headers", "[", "'filename'", "]", ";", "unset", "(", "$", "headers", "[", "'filename'", "]", ")", ";", "}", "else", "{", "$", "filename", "=", "$", "fileVersion", "->", "getFilename", "(", ")", ";", "}", "if", "(", "!", "array_key_exists", "(", "'mimetype'", ",", "$", "headers", ")", ")", "{", "$", "headers", "[", "'mimetype'", "]", "=", "$", "resource", "->", "getMimetype", "(", ")", ";", "}", "$", "this", "->", "addRawAttachmentWithHeaders", "(", "$", "resource", "->", "read", "(", ")", ",", "$", "filename", ",", "$", "headers", ")", ";", "}" ]
Add a File entity as an attachment of the message, specifying the headers of the mail MIME part. @param File $file The file to attach to the message @param array $headers Additional headers fo the MIME part. Valid values are: - filename: The name to give to the attachment (it will be used as the filename part of the Content-Disposition header) [default: the filename of the File instance] - mimetype: the main value of the Content-Type header [default: the content type of the file] - disposition: the main value of the Content-Disposition header [default: attachment] - encoding: the value of the Content-Transfer-Encoding header [default: base64] - charset: the charset value of the Content-Type header - boundary: the boundary value of the Content-Type header - id: the value of the Content-ID header (without angular brackets) - description: the value of the Content-Description header - location: the value of the Content-Location header - language: the value of the Content-Language header
[ "Add", "a", "File", "entity", "as", "an", "attachment", "of", "the", "message", "specifying", "the", "headers", "of", "the", "mail", "MIME", "part", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Mail/Service.php#L205-L223
train
concrete5/concrete5
concrete/src/Mail/Service.php
Service.addRawAttachmentWithHeaders
public function addRawAttachmentWithHeaders($content, $filename, array $headers = []) { $headers += [ 'mimetype' => 'application/octet-stream', 'disposition' => Mime::DISPOSITION_ATTACHMENT, 'encoding' => Mime::ENCODING_BASE64, 'charset' => '', 'boundary' => '', 'id' => '', 'description' => '', 'location' => '', 'language' => '', ]; $mp = new MimePart($content); $mp ->setFileName($filename) ->setType($headers['mimetype']) ->setDisposition($headers['disposition']) ->setEncoding($headers['encoding']) ->setCharset($headers['charset']) ->setBoundary($headers['boundary']) ->setId($headers['id']) ->setDescription($headers['description']) ->setLocation($headers['location']) ->setLanguage($headers['language']) ; $this->attachments[] = $mp; }
php
public function addRawAttachmentWithHeaders($content, $filename, array $headers = []) { $headers += [ 'mimetype' => 'application/octet-stream', 'disposition' => Mime::DISPOSITION_ATTACHMENT, 'encoding' => Mime::ENCODING_BASE64, 'charset' => '', 'boundary' => '', 'id' => '', 'description' => '', 'location' => '', 'language' => '', ]; $mp = new MimePart($content); $mp ->setFileName($filename) ->setType($headers['mimetype']) ->setDisposition($headers['disposition']) ->setEncoding($headers['encoding']) ->setCharset($headers['charset']) ->setBoundary($headers['boundary']) ->setId($headers['id']) ->setDescription($headers['description']) ->setLocation($headers['location']) ->setLanguage($headers['language']) ; $this->attachments[] = $mp; }
[ "public", "function", "addRawAttachmentWithHeaders", "(", "$", "content", ",", "$", "filename", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "$", "headers", "+=", "[", "'mimetype'", "=>", "'application/octet-stream'", ",", "'disposition'", "=>", "Mime", "::", "DISPOSITION_ATTACHMENT", ",", "'encoding'", "=>", "Mime", "::", "ENCODING_BASE64", ",", "'charset'", "=>", "''", ",", "'boundary'", "=>", "''", ",", "'id'", "=>", "''", ",", "'description'", "=>", "''", ",", "'location'", "=>", "''", ",", "'language'", "=>", "''", ",", "]", ";", "$", "mp", "=", "new", "MimePart", "(", "$", "content", ")", ";", "$", "mp", "->", "setFileName", "(", "$", "filename", ")", "->", "setType", "(", "$", "headers", "[", "'mimetype'", "]", ")", "->", "setDisposition", "(", "$", "headers", "[", "'disposition'", "]", ")", "->", "setEncoding", "(", "$", "headers", "[", "'encoding'", "]", ")", "->", "setCharset", "(", "$", "headers", "[", "'charset'", "]", ")", "->", "setBoundary", "(", "$", "headers", "[", "'boundary'", "]", ")", "->", "setId", "(", "$", "headers", "[", "'id'", "]", ")", "->", "setDescription", "(", "$", "headers", "[", "'description'", "]", ")", "->", "setLocation", "(", "$", "headers", "[", "'location'", "]", ")", "->", "setLanguage", "(", "$", "headers", "[", "'language'", "]", ")", ";", "$", "this", "->", "attachments", "[", "]", "=", "$", "mp", ";", "}" ]
Add a mail attachment by specifying its raw binary data, specifying the headers of the mail MIME part. @param string $content The binary data of the attachemt @param string $filename The name to give to the attachment (it will be used as the filename part of the Content-Disposition header) @param array $headers Additional headers fo the MIME part. Valid values are: - mimetype: the main value of the Content-Type header [default: application/octet-stream] - disposition: the main value of the Content-Disposition header [default: attachment] - encoding: the value of the Content-Transfer-Encoding header [default: base64] - charset: the charset value of the Content-Type header - boundary: the boundary value of the Content-Type header - id: the value of the Content-ID header (without angular brackets) - description: the value of the Content-Description header - location: the value of the Content-Location header - language: the value of the Content-Language header
[ "Add", "a", "mail", "attachment", "by", "specifying", "its", "raw", "binary", "data", "specifying", "the", "headers", "of", "the", "mail", "MIME", "part", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Mail/Service.php#L259-L286
train
concrete5/concrete5
concrete/src/Mail/Service.php
Service.to
public function to($email, $name = null) { if (strpos($email, ',') > 0) { $email = explode(',', $email); foreach ($email as $em) { $this->to[] = [$em, $name]; } } else { $this->to[] = [$email, $name]; } }
php
public function to($email, $name = null) { if (strpos($email, ',') > 0) { $email = explode(',', $email); foreach ($email as $em) { $this->to[] = [$em, $name]; } } else { $this->to[] = [$email, $name]; } }
[ "public", "function", "to", "(", "$", "email", ",", "$", "name", "=", "null", ")", "{", "if", "(", "strpos", "(", "$", "email", ",", "','", ")", ">", "0", ")", "{", "$", "email", "=", "explode", "(", "','", ",", "$", "email", ")", ";", "foreach", "(", "$", "email", "as", "$", "em", ")", "{", "$", "this", "->", "to", "[", "]", "=", "[", "$", "em", ",", "$", "name", "]", ";", "}", "}", "else", "{", "$", "this", "->", "to", "[", "]", "=", "[", "$", "email", ",", "$", "name", "]", ";", "}", "}" ]
Add one or more "To" recipients to the message. @param string $email (separate multiple email addresses with commas) @param string|null $name The name to associate to the email address
[ "Add", "one", "or", "more", "To", "recipients", "to", "the", "message", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Mail/Service.php#L411-L421
train
concrete5/concrete5
concrete/src/Mail/Service.php
Service.generateEmailStrings
protected function generateEmailStrings($arr) { $str = ''; for ($i = 0; $i < count($arr); ++$i) { $v = $arr[$i]; if (isset($v[1])) { $str .= '"' . $v[1] . '" <' . $v[0] . '>'; } elseif (isset($v[0])) { $str .= $v[0]; } if (($i + 1) < count($arr)) { $str .= ', '; } } return $str; }
php
protected function generateEmailStrings($arr) { $str = ''; for ($i = 0; $i < count($arr); ++$i) { $v = $arr[$i]; if (isset($v[1])) { $str .= '"' . $v[1] . '" <' . $v[0] . '>'; } elseif (isset($v[0])) { $str .= $v[0]; } if (($i + 1) < count($arr)) { $str .= ', '; } } return $str; }
[ "protected", "function", "generateEmailStrings", "(", "$", "arr", ")", "{", "$", "str", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "arr", ")", ";", "++", "$", "i", ")", "{", "$", "v", "=", "$", "arr", "[", "$", "i", "]", ";", "if", "(", "isset", "(", "$", "v", "[", "1", "]", ")", ")", "{", "$", "str", ".=", "'\"'", ".", "$", "v", "[", "1", "]", ".", "'\" <'", ".", "$", "v", "[", "0", "]", ".", "'>'", ";", "}", "elseif", "(", "isset", "(", "$", "v", "[", "0", "]", ")", ")", "{", "$", "str", ".=", "$", "v", "[", "0", "]", ";", "}", "if", "(", "(", "$", "i", "+", "1", ")", "<", "count", "(", "$", "arr", ")", ")", "{", "$", "str", ".=", "', '", ";", "}", "}", "return", "$", "str", ";", "}" ]
Convert a list of email addresses to a string. @param array $arr @return string
[ "Convert", "a", "list", "of", "email", "addresses", "to", "a", "string", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Mail/Service.php#L713-L729
train
concrete5/concrete5
concrete/src/Mail/Service.php
Service.isInlineAttachment
protected function isInlineAttachment(MimePart $attachment) { return $this->bodyHTML !== false && $attachment->getId() && in_array((string) $attachment->getDisposition(), ['', Mime::DISPOSITION_INLINE], true) ; }
php
protected function isInlineAttachment(MimePart $attachment) { return $this->bodyHTML !== false && $attachment->getId() && in_array((string) $attachment->getDisposition(), ['', Mime::DISPOSITION_INLINE], true) ; }
[ "protected", "function", "isInlineAttachment", "(", "MimePart", "$", "attachment", ")", "{", "return", "$", "this", "->", "bodyHTML", "!==", "false", "&&", "$", "attachment", "->", "getId", "(", ")", "&&", "in_array", "(", "(", "string", ")", "$", "attachment", "->", "getDisposition", "(", ")", ",", "[", "''", ",", "Mime", "::", "DISPOSITION_INLINE", "]", ",", "true", ")", ";", "}" ]
Determine if an attachment should be used as an inline attachment associated to the HTML body. @param MimePart $attachment @return bool
[ "Determine", "if", "an", "attachment", "should", "be", "used", "as", "an", "inline", "attachment", "associated", "to", "the", "HTML", "body", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Mail/Service.php#L756-L762
train
concrete5/concrete5
concrete/src/Validator/String/ReuseValidator.php
ReuseValidator.hasBeenUsed
private function hasBeenUsed($string, $id) { $repository = $this->entityManager->getRepository(UsedString::class); $allUses = $repository->findBy(['subject' => $id], ['id' => 'desc'], $this->maxReuse); foreach ($allUses as $use) { if ($this->matches($string, $use)) { return true; } } return false; }
php
private function hasBeenUsed($string, $id) { $repository = $this->entityManager->getRepository(UsedString::class); $allUses = $repository->findBy(['subject' => $id], ['id' => 'desc'], $this->maxReuse); foreach ($allUses as $use) { if ($this->matches($string, $use)) { return true; } } return false; }
[ "private", "function", "hasBeenUsed", "(", "$", "string", ",", "$", "id", ")", "{", "$", "repository", "=", "$", "this", "->", "entityManager", "->", "getRepository", "(", "UsedString", "::", "class", ")", ";", "$", "allUses", "=", "$", "repository", "->", "findBy", "(", "[", "'subject'", "=>", "$", "id", "]", ",", "[", "'id'", "=>", "'desc'", "]", ",", "$", "this", "->", "maxReuse", ")", ";", "foreach", "(", "$", "allUses", "as", "$", "use", ")", "{", "if", "(", "$", "this", "->", "matches", "(", "$", "string", ",", "$", "use", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check whether a string has been used against an id @param string $string @param int$id @return bool
[ "Check", "whether", "a", "string", "has", "been", "used", "against", "an", "id" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Validator/String/ReuseValidator.php#L86-L98
train
concrete5/concrete5
concrete/src/Conversation/ConversationService.php
ConversationService.trackReview
public function trackReview(Message $message, Block $block) { $average = $this->fetchConversationAverage($message->getConversationID()); $this->assignAverage($block, $average); }
php
public function trackReview(Message $message, Block $block) { $average = $this->fetchConversationAverage($message->getConversationID()); $this->assignAverage($block, $average); }
[ "public", "function", "trackReview", "(", "Message", "$", "message", ",", "Block", "$", "block", ")", "{", "$", "average", "=", "$", "this", "->", "fetchConversationAverage", "(", "$", "message", "->", "getConversationID", "(", ")", ")", ";", "$", "this", "->", "assignAverage", "(", "$", "block", ",", "$", "average", ")", ";", "}" ]
Track a review on a message @param \Concrete\Core\Conversation\Message\Message $message @param \Concrete\Core\Block\Block $block
[ "Track", "a", "review", "on", "a", "message" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Conversation/ConversationService.php#L44-L48
train
concrete5/concrete5
concrete/src/Tree/Node/Node.php
Node.transformNode
public function transformNode($treeNodeType) { $class = self::getClassByType($treeNodeType); $node = new $class(); $node->setPropertiesFromArray($this); return $node; }
php
public function transformNode($treeNodeType) { $class = self::getClassByType($treeNodeType); $node = new $class(); $node->setPropertiesFromArray($this); return $node; }
[ "public", "function", "transformNode", "(", "$", "treeNodeType", ")", "{", "$", "class", "=", "self", "::", "getClassByType", "(", "$", "treeNodeType", ")", ";", "$", "node", "=", "new", "$", "class", "(", ")", ";", "$", "node", "->", "setPropertiesFromArray", "(", "$", "this", ")", ";", "return", "$", "node", ";", "}" ]
Transforms a node to another node. @param mixed $treeNodeType
[ "Transforms", "a", "node", "to", "another", "node", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Tree/Node/Node.php#L189-L196
train
concrete5/concrete5
concrete/src/Tree/Node/Node.php
Node.getTreeNodeParentArray
public function getTreeNodeParentArray() { $db = Database::connection(); $nodeArray = []; $currentNodeParentID = $this->getTreeNodeParentID(); if ($currentNodeParentID > 0) { while (is_numeric($currentNodeParentID) && $currentNodeParentID > 0 && $currentNodeParentID) { $row = $db->fetchAssoc('select treeNodeID, treeNodeParentID from TreeNodes where treeNodeID = ?', [$currentNodeParentID]); if ($row && $row['treeNodeID']) { $nodeArray[] = self::getByID($row['treeNodeID']); } $currentNodeParentID = $row['treeNodeParentID']; // moving up the tree until we hit 1 } } return $nodeArray; }
php
public function getTreeNodeParentArray() { $db = Database::connection(); $nodeArray = []; $currentNodeParentID = $this->getTreeNodeParentID(); if ($currentNodeParentID > 0) { while (is_numeric($currentNodeParentID) && $currentNodeParentID > 0 && $currentNodeParentID) { $row = $db->fetchAssoc('select treeNodeID, treeNodeParentID from TreeNodes where treeNodeID = ?', [$currentNodeParentID]); if ($row && $row['treeNodeID']) { $nodeArray[] = self::getByID($row['treeNodeID']); } $currentNodeParentID = $row['treeNodeParentID']; // moving up the tree until we hit 1 } } return $nodeArray; }
[ "public", "function", "getTreeNodeParentArray", "(", ")", "{", "$", "db", "=", "Database", "::", "connection", "(", ")", ";", "$", "nodeArray", "=", "[", "]", ";", "$", "currentNodeParentID", "=", "$", "this", "->", "getTreeNodeParentID", "(", ")", ";", "if", "(", "$", "currentNodeParentID", ">", "0", ")", "{", "while", "(", "is_numeric", "(", "$", "currentNodeParentID", ")", "&&", "$", "currentNodeParentID", ">", "0", "&&", "$", "currentNodeParentID", ")", "{", "$", "row", "=", "$", "db", "->", "fetchAssoc", "(", "'select treeNodeID, treeNodeParentID from TreeNodes where treeNodeID = ?'", ",", "[", "$", "currentNodeParentID", "]", ")", ";", "if", "(", "$", "row", "&&", "$", "row", "[", "'treeNodeID'", "]", ")", "{", "$", "nodeArray", "[", "]", "=", "self", "::", "getByID", "(", "$", "row", "[", "'treeNodeID'", "]", ")", ";", "}", "$", "currentNodeParentID", "=", "$", "row", "[", "'treeNodeParentID'", "]", ";", "// moving up the tree until we hit 1", "}", "}", "return", "$", "nodeArray", ";", "}" ]
Returns an array of all parents of this tree node.
[ "Returns", "an", "array", "of", "all", "parents", "of", "this", "tree", "node", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Tree/Node/Node.php#L201-L218
train
concrete5/concrete5
concrete/src/Tree/Node/Node.php
Node.selectChildrenNodesByID
public function selectChildrenNodesByID($nodeID, $loadMissingChildren = false) { if ($this->getTreeNodeID() == $nodeID) { $this->treeNodeIsSelected = true; } else { foreach ($this->getChildNodes() as $childnode) { if ($loadMissingChildren && !$childnode->getChildNodesLoaded()) { $childnode->populateDirectChildrenOnly(); } $childnode->selectChildrenNodesByID($nodeID, $loadMissingChildren); } } }
php
public function selectChildrenNodesByID($nodeID, $loadMissingChildren = false) { if ($this->getTreeNodeID() == $nodeID) { $this->treeNodeIsSelected = true; } else { foreach ($this->getChildNodes() as $childnode) { if ($loadMissingChildren && !$childnode->getChildNodesLoaded()) { $childnode->populateDirectChildrenOnly(); } $childnode->selectChildrenNodesByID($nodeID, $loadMissingChildren); } } }
[ "public", "function", "selectChildrenNodesByID", "(", "$", "nodeID", ",", "$", "loadMissingChildren", "=", "false", ")", "{", "if", "(", "$", "this", "->", "getTreeNodeID", "(", ")", "==", "$", "nodeID", ")", "{", "$", "this", "->", "treeNodeIsSelected", "=", "true", ";", "}", "else", "{", "foreach", "(", "$", "this", "->", "getChildNodes", "(", ")", "as", "$", "childnode", ")", "{", "if", "(", "$", "loadMissingChildren", "&&", "!", "$", "childnode", "->", "getChildNodesLoaded", "(", ")", ")", "{", "$", "childnode", "->", "populateDirectChildrenOnly", "(", ")", ";", "}", "$", "childnode", "->", "selectChildrenNodesByID", "(", "$", "nodeID", ",", "$", "loadMissingChildren", ")", ";", "}", "}", "}" ]
Recursively searches for a children node and marks it as selected. @param int $nodeID ID of the children to be selected @param bool $loadMissingChildren if set to true, it will fetch, as needed, the children of the current node, that have not been loaded yet
[ "Recursively", "searches", "for", "a", "children", "node", "and", "marks", "it", "as", "selected", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Tree/Node/Node.php#L226-L239
train
concrete5/concrete5
concrete/src/Tree/Node/Node.php
Node.checkMove
public function checkMove(Node $newParent) { $result = null; if ($this->getTreeNodeParentID() != $newParent->getTreeNodeID()) { if ($this->getTreeNodeID() == $newParent->getTreeNodeID()) { $result = new MoveException(t("It's not possible to move a node under itself")); } else { foreach ($newParent->getTreeNodeParentArray() as $newParentAncestor) { if ($newParentAncestor->getTreeNodeID() == $this->getTreeNodeID()) { $result = MoveException(t("It's not possible to move a node under one of its descending nodes")); break; } } } } return $result; }
php
public function checkMove(Node $newParent) { $result = null; if ($this->getTreeNodeParentID() != $newParent->getTreeNodeID()) { if ($this->getTreeNodeID() == $newParent->getTreeNodeID()) { $result = new MoveException(t("It's not possible to move a node under itself")); } else { foreach ($newParent->getTreeNodeParentArray() as $newParentAncestor) { if ($newParentAncestor->getTreeNodeID() == $this->getTreeNodeID()) { $result = MoveException(t("It's not possible to move a node under one of its descending nodes")); break; } } } } return $result; }
[ "public", "function", "checkMove", "(", "Node", "$", "newParent", ")", "{", "$", "result", "=", "null", ";", "if", "(", "$", "this", "->", "getTreeNodeParentID", "(", ")", "!=", "$", "newParent", "->", "getTreeNodeID", "(", ")", ")", "{", "if", "(", "$", "this", "->", "getTreeNodeID", "(", ")", "==", "$", "newParent", "->", "getTreeNodeID", "(", ")", ")", "{", "$", "result", "=", "new", "MoveException", "(", "t", "(", "\"It's not possible to move a node under itself\"", ")", ")", ";", "}", "else", "{", "foreach", "(", "$", "newParent", "->", "getTreeNodeParentArray", "(", ")", "as", "$", "newParentAncestor", ")", "{", "if", "(", "$", "newParentAncestor", "->", "getTreeNodeID", "(", ")", "==", "$", "this", "->", "getTreeNodeID", "(", ")", ")", "{", "$", "result", "=", "MoveException", "(", "t", "(", "\"It's not possible to move a node under one of its descending nodes\"", ")", ")", ";", "break", ";", "}", "}", "}", "}", "return", "$", "result", ";", "}" ]
Check if this node can be moved under another parent. @param Node $newParent the new parent node @return MoveException|null return a MoveException in case of problems, null in case of success
[ "Check", "if", "this", "node", "can", "be", "moved", "under", "another", "parent", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Tree/Node/Node.php#L441-L458
train
concrete5/concrete5
concrete/src/Tree/Node/Node.php
Node.move
public function move(Node $newParent) { $error = $this->checkMove($newParent); if ($error !== null) { throw $error; } if ($this->getTreeNodeParentID() != $newParent->getTreeNodeID()) { $db = Database::connection(); $existingDisplayOrder = $this->treeNodeDisplayOrder; $treeNodeDisplayOrder = (int) $db->fetchColumn('select count(treeNodeDisplayOrder) from TreeNodes where treeNodeParentID = ?', [$newParent->getTreeNodeID()]); $db->executeQuery('update TreeNodes set treeNodeParentID = ?, treeNodeDisplayOrder = ? where treeNodeID = ?', [$newParent->getTreeNodeID(), $treeNodeDisplayOrder, $this->treeNodeID]); if (!$this->overrideParentTreeNodePermissions()) { $db->executeQuery('update TreeNodes set inheritPermissionsFromTreeNodeID = ? where treeNodeID = ?', [$newParent->getTreeNodePermissionsNodeID(), $this->treeNodeID]); } $oldParent = $this->getTreeNodeParentObject(); if (is_object($oldParent)) { // Instead of just rescanning all the nodes (which could take a long time), // let's just update all the nodes with display order above this one to be their current // order - 1 $db->executeQuery( 'update TreeNodes set treeNodeDisplayOrder = (treeNodeDisplayOrder - 1) where treeNodeDisplayOrder > ? and treeNodeParentID = ?', [$existingDisplayOrder, $oldParent->getTreeNodeID()] ); //$oldParent->rescanChildrenDisplayOrder(); $oldParent->updateDateModified(); } $newParent->updateDateModified(); $this->treeNodeParentID = $newParent->getTreeNodeID(); $this->treeNodeDisplayOrder = $treeNodeDisplayOrder; } }
php
public function move(Node $newParent) { $error = $this->checkMove($newParent); if ($error !== null) { throw $error; } if ($this->getTreeNodeParentID() != $newParent->getTreeNodeID()) { $db = Database::connection(); $existingDisplayOrder = $this->treeNodeDisplayOrder; $treeNodeDisplayOrder = (int) $db->fetchColumn('select count(treeNodeDisplayOrder) from TreeNodes where treeNodeParentID = ?', [$newParent->getTreeNodeID()]); $db->executeQuery('update TreeNodes set treeNodeParentID = ?, treeNodeDisplayOrder = ? where treeNodeID = ?', [$newParent->getTreeNodeID(), $treeNodeDisplayOrder, $this->treeNodeID]); if (!$this->overrideParentTreeNodePermissions()) { $db->executeQuery('update TreeNodes set inheritPermissionsFromTreeNodeID = ? where treeNodeID = ?', [$newParent->getTreeNodePermissionsNodeID(), $this->treeNodeID]); } $oldParent = $this->getTreeNodeParentObject(); if (is_object($oldParent)) { // Instead of just rescanning all the nodes (which could take a long time), // let's just update all the nodes with display order above this one to be their current // order - 1 $db->executeQuery( 'update TreeNodes set treeNodeDisplayOrder = (treeNodeDisplayOrder - 1) where treeNodeDisplayOrder > ? and treeNodeParentID = ?', [$existingDisplayOrder, $oldParent->getTreeNodeID()] ); //$oldParent->rescanChildrenDisplayOrder(); $oldParent->updateDateModified(); } $newParent->updateDateModified(); $this->treeNodeParentID = $newParent->getTreeNodeID(); $this->treeNodeDisplayOrder = $treeNodeDisplayOrder; } }
[ "public", "function", "move", "(", "Node", "$", "newParent", ")", "{", "$", "error", "=", "$", "this", "->", "checkMove", "(", "$", "newParent", ")", ";", "if", "(", "$", "error", "!==", "null", ")", "{", "throw", "$", "error", ";", "}", "if", "(", "$", "this", "->", "getTreeNodeParentID", "(", ")", "!=", "$", "newParent", "->", "getTreeNodeID", "(", ")", ")", "{", "$", "db", "=", "Database", "::", "connection", "(", ")", ";", "$", "existingDisplayOrder", "=", "$", "this", "->", "treeNodeDisplayOrder", ";", "$", "treeNodeDisplayOrder", "=", "(", "int", ")", "$", "db", "->", "fetchColumn", "(", "'select count(treeNodeDisplayOrder) from TreeNodes where treeNodeParentID = ?'", ",", "[", "$", "newParent", "->", "getTreeNodeID", "(", ")", "]", ")", ";", "$", "db", "->", "executeQuery", "(", "'update TreeNodes set treeNodeParentID = ?, treeNodeDisplayOrder = ? where treeNodeID = ?'", ",", "[", "$", "newParent", "->", "getTreeNodeID", "(", ")", ",", "$", "treeNodeDisplayOrder", ",", "$", "this", "->", "treeNodeID", "]", ")", ";", "if", "(", "!", "$", "this", "->", "overrideParentTreeNodePermissions", "(", ")", ")", "{", "$", "db", "->", "executeQuery", "(", "'update TreeNodes set inheritPermissionsFromTreeNodeID = ? where treeNodeID = ?'", ",", "[", "$", "newParent", "->", "getTreeNodePermissionsNodeID", "(", ")", ",", "$", "this", "->", "treeNodeID", "]", ")", ";", "}", "$", "oldParent", "=", "$", "this", "->", "getTreeNodeParentObject", "(", ")", ";", "if", "(", "is_object", "(", "$", "oldParent", ")", ")", "{", "// Instead of just rescanning all the nodes (which could take a long time),", "// let's just update all the nodes with display order above this one to be their current", "// order - 1", "$", "db", "->", "executeQuery", "(", "'update TreeNodes set treeNodeDisplayOrder = (treeNodeDisplayOrder - 1) \nwhere treeNodeDisplayOrder > ? and treeNodeParentID = ?'", ",", "[", "$", "existingDisplayOrder", ",", "$", "oldParent", "->", "getTreeNodeID", "(", ")", "]", ")", ";", "//$oldParent->rescanChildrenDisplayOrder();", "$", "oldParent", "->", "updateDateModified", "(", ")", ";", "}", "$", "newParent", "->", "updateDateModified", "(", ")", ";", "$", "this", "->", "treeNodeParentID", "=", "$", "newParent", "->", "getTreeNodeID", "(", ")", ";", "$", "this", "->", "treeNodeDisplayOrder", "=", "$", "treeNodeDisplayOrder", ";", "}", "}" ]
Move this node under another node. @param Node $newParent The new parent node @throws MoveException throws a MoveException in case of errors
[ "Move", "this", "node", "under", "another", "node", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Tree/Node/Node.php#L467-L498
train
concrete5/concrete5
concrete/src/Tree/Node/Node.php
Node.updateDateModified
public function updateDateModified() { $dateModified = Core::make('date')->toDB(); $db = Database::connection(); $db->update('TreeNodes', ['dateModified' => $dateModified], ['treeNodeID' => $this->getTreeNodeID()]); }
php
public function updateDateModified() { $dateModified = Core::make('date')->toDB(); $db = Database::connection(); $db->update('TreeNodes', ['dateModified' => $dateModified], ['treeNodeID' => $this->getTreeNodeID()]); }
[ "public", "function", "updateDateModified", "(", ")", "{", "$", "dateModified", "=", "Core", "::", "make", "(", "'date'", ")", "->", "toDB", "(", ")", ";", "$", "db", "=", "Database", "::", "connection", "(", ")", ";", "$", "db", "->", "update", "(", "'TreeNodes'", ",", "[", "'dateModified'", "=>", "$", "dateModified", "]", ",", "[", "'treeNodeID'", "=>", "$", "this", "->", "getTreeNodeID", "(", ")", "]", ")", ";", "}" ]
Update the Date Modified to the current time.
[ "Update", "the", "Date", "Modified", "to", "the", "current", "time", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Tree/Node/Node.php#L503-L508
train
concrete5/concrete5
concrete/src/Tree/Node/Node.php
Node.add
public static function add($parent = false) { $db = Database::connection(); $treeNodeParentID = 0; $treeID = 0; $treeNodeDisplayOrder = 0; $inheritPermissionsFromTreeNodeID = 0; if (is_object($parent)) { $treeNodeParentID = $parent->getTreeNodeID(); $treeID = $parent->getTreeID(); $inheritPermissionsFromTreeNodeID = $parent->getTreeNodePermissionsNodeID(); $treeNodeDisplayOrder = (int) $db->fetchColumn('select count(treeNodeDisplayOrder) from TreeNodes where treeNodeParentID = ?', [$treeNodeParentID]); $parent->updateDateModified(); } else { $parent = null; } $treeNodeTypeHandle = uncamelcase(strrchr(get_called_class(), '\\')); $dateModified = Core::make('date')->toDB(); $dateCreated = Core::make('date')->toDB(); $type = TreeNodeType::getByHandle($treeNodeTypeHandle); $db->executeQuery( 'insert into TreeNodes (treeNodeTypeID, treeNodeParentID, treeNodeDisplayOrder, inheritPermissionsFromTreeNodeID, dateModified, dateCreated, treeID) values (?, ?, ?, ?, ?, ?, ?)', [ $type->getTreeNodeTypeID(), $treeNodeParentID, $treeNodeDisplayOrder, $inheritPermissionsFromTreeNodeID, $dateModified, $dateCreated, $treeID, ] ); $id = $db->lastInsertId(); $node = self::getByID($id); if (!$inheritPermissionsFromTreeNodeID) { $node->setTreeNodePermissionsToOverride(); } if ($parent !== null && $parent->childNodesLoaded) { $parent->childNodes[] = $node; } return $node; }
php
public static function add($parent = false) { $db = Database::connection(); $treeNodeParentID = 0; $treeID = 0; $treeNodeDisplayOrder = 0; $inheritPermissionsFromTreeNodeID = 0; if (is_object($parent)) { $treeNodeParentID = $parent->getTreeNodeID(); $treeID = $parent->getTreeID(); $inheritPermissionsFromTreeNodeID = $parent->getTreeNodePermissionsNodeID(); $treeNodeDisplayOrder = (int) $db->fetchColumn('select count(treeNodeDisplayOrder) from TreeNodes where treeNodeParentID = ?', [$treeNodeParentID]); $parent->updateDateModified(); } else { $parent = null; } $treeNodeTypeHandle = uncamelcase(strrchr(get_called_class(), '\\')); $dateModified = Core::make('date')->toDB(); $dateCreated = Core::make('date')->toDB(); $type = TreeNodeType::getByHandle($treeNodeTypeHandle); $db->executeQuery( 'insert into TreeNodes (treeNodeTypeID, treeNodeParentID, treeNodeDisplayOrder, inheritPermissionsFromTreeNodeID, dateModified, dateCreated, treeID) values (?, ?, ?, ?, ?, ?, ?)', [ $type->getTreeNodeTypeID(), $treeNodeParentID, $treeNodeDisplayOrder, $inheritPermissionsFromTreeNodeID, $dateModified, $dateCreated, $treeID, ] ); $id = $db->lastInsertId(); $node = self::getByID($id); if (!$inheritPermissionsFromTreeNodeID) { $node->setTreeNodePermissionsToOverride(); } if ($parent !== null && $parent->childNodesLoaded) { $parent->childNodes[] = $node; } return $node; }
[ "public", "static", "function", "add", "(", "$", "parent", "=", "false", ")", "{", "$", "db", "=", "Database", "::", "connection", "(", ")", ";", "$", "treeNodeParentID", "=", "0", ";", "$", "treeID", "=", "0", ";", "$", "treeNodeDisplayOrder", "=", "0", ";", "$", "inheritPermissionsFromTreeNodeID", "=", "0", ";", "if", "(", "is_object", "(", "$", "parent", ")", ")", "{", "$", "treeNodeParentID", "=", "$", "parent", "->", "getTreeNodeID", "(", ")", ";", "$", "treeID", "=", "$", "parent", "->", "getTreeID", "(", ")", ";", "$", "inheritPermissionsFromTreeNodeID", "=", "$", "parent", "->", "getTreeNodePermissionsNodeID", "(", ")", ";", "$", "treeNodeDisplayOrder", "=", "(", "int", ")", "$", "db", "->", "fetchColumn", "(", "'select count(treeNodeDisplayOrder) from TreeNodes where treeNodeParentID = ?'", ",", "[", "$", "treeNodeParentID", "]", ")", ";", "$", "parent", "->", "updateDateModified", "(", ")", ";", "}", "else", "{", "$", "parent", "=", "null", ";", "}", "$", "treeNodeTypeHandle", "=", "uncamelcase", "(", "strrchr", "(", "get_called_class", "(", ")", ",", "'\\\\'", ")", ")", ";", "$", "dateModified", "=", "Core", "::", "make", "(", "'date'", ")", "->", "toDB", "(", ")", ";", "$", "dateCreated", "=", "Core", "::", "make", "(", "'date'", ")", "->", "toDB", "(", ")", ";", "$", "type", "=", "TreeNodeType", "::", "getByHandle", "(", "$", "treeNodeTypeHandle", ")", ";", "$", "db", "->", "executeQuery", "(", "'insert into TreeNodes (treeNodeTypeID, treeNodeParentID, treeNodeDisplayOrder, inheritPermissionsFromTreeNodeID, dateModified, dateCreated, treeID) values (?, ?, ?, ?, ?, ?, ?)'", ",", "[", "$", "type", "->", "getTreeNodeTypeID", "(", ")", ",", "$", "treeNodeParentID", ",", "$", "treeNodeDisplayOrder", ",", "$", "inheritPermissionsFromTreeNodeID", ",", "$", "dateModified", ",", "$", "dateCreated", ",", "$", "treeID", ",", "]", ")", ";", "$", "id", "=", "$", "db", "->", "lastInsertId", "(", ")", ";", "$", "node", "=", "self", "::", "getByID", "(", "$", "id", ")", ";", "if", "(", "!", "$", "inheritPermissionsFromTreeNodeID", ")", "{", "$", "node", "->", "setTreeNodePermissionsToOverride", "(", ")", ";", "}", "if", "(", "$", "parent", "!==", "null", "&&", "$", "parent", "->", "childNodesLoaded", ")", "{", "$", "parent", "->", "childNodes", "[", "]", "=", "$", "node", ";", "}", "return", "$", "node", ";", "}" ]
Add a new node. @param Node|null|false $parent the parent node @return Node
[ "Add", "a", "new", "node", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Tree/Node/Node.php#L529-L576
train
concrete5/concrete5
concrete/src/Config/Repository/Repository.php
Repository.hasGroup
public function hasGroup($key) { list($namespace, $group) = $this->parseKey($key); return $this->loader->exists($group, $namespace); }
php
public function hasGroup($key) { list($namespace, $group) = $this->parseKey($key); return $this->loader->exists($group, $namespace); }
[ "public", "function", "hasGroup", "(", "$", "key", ")", "{", "list", "(", "$", "namespace", ",", "$", "group", ")", "=", "$", "this", "->", "parseKey", "(", "$", "key", ")", ";", "return", "$", "this", "->", "loader", "->", "exists", "(", "$", "group", ",", "$", "namespace", ")", ";", "}" ]
Determine if a configuration group exists. @param string $key @return bool
[ "Determine", "if", "a", "configuration", "group", "exists", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Config/Repository/Repository.php#L95-L100
train
concrete5/concrete5
concrete/src/Config/Repository/Repository.php
Repository.save
public function save($key, $value) { list($namespace, $group, $item) = $this->parseKey($key); $collection = $this->getCollection($group, $namespace); unset($this->items[$collection]); if ($this->saver->save($item, $value, $this->environment, $group, $namespace)) { $this->load($group, $namespace, $this->getCollection($group, $namespace)); return true; } return false; }
php
public function save($key, $value) { list($namespace, $group, $item) = $this->parseKey($key); $collection = $this->getCollection($group, $namespace); unset($this->items[$collection]); if ($this->saver->save($item, $value, $this->environment, $group, $namespace)) { $this->load($group, $namespace, $this->getCollection($group, $namespace)); return true; } return false; }
[ "public", "function", "save", "(", "$", "key", ",", "$", "value", ")", "{", "list", "(", "$", "namespace", ",", "$", "group", ",", "$", "item", ")", "=", "$", "this", "->", "parseKey", "(", "$", "key", ")", ";", "$", "collection", "=", "$", "this", "->", "getCollection", "(", "$", "group", ",", "$", "namespace", ")", ";", "unset", "(", "$", "this", "->", "items", "[", "$", "collection", "]", ")", ";", "if", "(", "$", "this", "->", "saver", "->", "save", "(", "$", "item", ",", "$", "value", ",", "$", "this", "->", "environment", ",", "$", "group", ",", "$", "namespace", ")", ")", "{", "$", "this", "->", "load", "(", "$", "group", ",", "$", "namespace", ",", "$", "this", "->", "getCollection", "(", "$", "group", ",", "$", "namespace", ")", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Save a key. @param string $key @param mixed $value @return bool
[ "Save", "a", "key", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Config/Repository/Repository.php#L156-L169
train
concrete5/concrete5
concrete/src/Config/Repository/Repository.php
Repository.withKey
public function withKey($key, $value, callable $callable) { $initialValue = $this->get($key); try { $this->set($key, $value); return $callable(); } finally { $this->set($key, $initialValue); } }
php
public function withKey($key, $value, callable $callable) { $initialValue = $this->get($key); try { $this->set($key, $value); return $callable(); } finally { $this->set($key, $initialValue); } }
[ "public", "function", "withKey", "(", "$", "key", ",", "$", "value", ",", "callable", "$", "callable", ")", "{", "$", "initialValue", "=", "$", "this", "->", "get", "(", "$", "key", ")", ";", "try", "{", "$", "this", "->", "set", "(", "$", "key", ",", "$", "value", ")", ";", "return", "$", "callable", "(", ")", ";", "}", "finally", "{", "$", "this", "->", "set", "(", "$", "key", ",", "$", "initialValue", ")", ";", "}", "}" ]
Execute a callable using a specific key value. @param string $key @param mixed $value @param callable $callable @return mixed returns the result of $callable
[ "Execute", "a", "callable", "using", "a", "specific", "key", "value", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Config/Repository/Repository.php#L370-L380
train
concrete5/concrete5
concrete/src/Validator/PasswordValidatorServiceProvider.php
PasswordValidatorServiceProvider.applyLengthValidators
protected function applyLengthValidators(ValidatorManagerInterface $manager) { $minimum = $this->getMinimumRequirement(); $maximum = $this->getMaximumRequirement(); $this->applyMinMaxStrings($minimum, $maximum); // Set validators if ($maximum) { $manager->setValidator('maximum_length', $maximum); } if ($minimum) { $manager->setValidator('minimum_length', $minimum); } }
php
protected function applyLengthValidators(ValidatorManagerInterface $manager) { $minimum = $this->getMinimumRequirement(); $maximum = $this->getMaximumRequirement(); $this->applyMinMaxStrings($minimum, $maximum); // Set validators if ($maximum) { $manager->setValidator('maximum_length', $maximum); } if ($minimum) { $manager->setValidator('minimum_length', $minimum); } }
[ "protected", "function", "applyLengthValidators", "(", "ValidatorManagerInterface", "$", "manager", ")", "{", "$", "minimum", "=", "$", "this", "->", "getMinimumRequirement", "(", ")", ";", "$", "maximum", "=", "$", "this", "->", "getMaximumRequirement", "(", ")", ";", "$", "this", "->", "applyMinMaxStrings", "(", "$", "minimum", ",", "$", "maximum", ")", ";", "// Set validators", "if", "(", "$", "maximum", ")", "{", "$", "manager", "->", "setValidator", "(", "'maximum_length'", ",", "$", "maximum", ")", ";", "}", "if", "(", "$", "minimum", ")", "{", "$", "manager", "->", "setValidator", "(", "'minimum_length'", ",", "$", "minimum", ")", ";", "}", "}" ]
Apply configured password length validators @param $manager
[ "Apply", "configured", "password", "length", "validators" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Validator/PasswordValidatorServiceProvider.php#L66-L79
train
concrete5/concrete5
concrete/src/Validator/PasswordValidatorServiceProvider.php
PasswordValidatorServiceProvider.getMaximumRequirement
protected function getMaximumRequirement() { $maximumLength = $this->config->get('concrete.user.password.maximum'); return $maximumLength ? $this->app->make(MaximumLengthValidator::class, [$maximumLength]) : null; }
php
protected function getMaximumRequirement() { $maximumLength = $this->config->get('concrete.user.password.maximum'); return $maximumLength ? $this->app->make(MaximumLengthValidator::class, [$maximumLength]) : null; }
[ "protected", "function", "getMaximumRequirement", "(", ")", "{", "$", "maximumLength", "=", "$", "this", "->", "config", "->", "get", "(", "'concrete.user.password.maximum'", ")", ";", "return", "$", "maximumLength", "?", "$", "this", "->", "app", "->", "make", "(", "MaximumLengthValidator", "::", "class", ",", "[", "$", "maximumLength", "]", ")", ":", "null", ";", "}" ]
Get maximum length validator @return \Concrete\Core\Validator\String\MaximumLengthValidator|null
[ "Get", "maximum", "length", "validator" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Validator/PasswordValidatorServiceProvider.php#L86-L91
train
concrete5/concrete5
concrete/src/Validator/PasswordValidatorServiceProvider.php
PasswordValidatorServiceProvider.getMinimumRequirement
protected function getMinimumRequirement() { $minimumLength = $this->config->get('concrete.user.password.minimum', 8); return $minimumLength ? $this->app->make(MinimumLengthValidator::class, [$minimumLength]) : null; }
php
protected function getMinimumRequirement() { $minimumLength = $this->config->get('concrete.user.password.minimum', 8); return $minimumLength ? $this->app->make(MinimumLengthValidator::class, [$minimumLength]) : null; }
[ "protected", "function", "getMinimumRequirement", "(", ")", "{", "$", "minimumLength", "=", "$", "this", "->", "config", "->", "get", "(", "'concrete.user.password.minimum'", ",", "8", ")", ";", "return", "$", "minimumLength", "?", "$", "this", "->", "app", "->", "make", "(", "MinimumLengthValidator", "::", "class", ",", "[", "$", "minimumLength", "]", ")", ":", "null", ";", "}" ]
Get minimum length validator @return \Concrete\Core\Validator\String\MinimumLengthValidator|null
[ "Get", "minimum", "length", "validator" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Validator/PasswordValidatorServiceProvider.php#L98-L102
train
concrete5/concrete5
concrete/src/Validator/PasswordValidatorServiceProvider.php
PasswordValidatorServiceProvider.applyMinMaxStrings
protected function applyMinMaxStrings($minimum, $maximum) { if ($minimum && $maximum) { $errorString = t('A password must be between %s and %s characters long.', $minimum->getMinimumLength(), $maximum->getMaximumLength()); $requirement = t('Must be between %s and %s characters long.', $minimum->getMinimumLength(), $maximum->getMaximumLength()); } elseif ($minimum) { $errorString = t('Must be at least %s characters long.', $minimum->getMinimumLength()); $requirement = t('A password must be at least %s characters long.', $minimum->getMinimumLength()); } elseif ($maximum) { $errorString = t('A password must be at most %s characters long.', $maximum->getMaximumLength()); $requirement = t('Must be at most %s characters long.', $maximum->getMaximumLength()); } else { $errorString = t('Invalid Password.'); $requirement = ''; } $errorHandler = function ($validator, $code, $password) use ($errorString) { return $errorString; }; $requirementHandler = function ($validator, $code) use (&$requirement) { return $requirement; }; $minimum->setRequirementString($minimum::E_TOO_SHORT, $requirementHandler); $minimum->setErrorString($minimum::E_TOO_SHORT, $errorHandler); $maximum->setRequirementString($maximum::E_TOO_LONG, $requirementHandler); $maximum->setErrorString($maximum::E_TOO_LONG, $errorHandler); }
php
protected function applyMinMaxStrings($minimum, $maximum) { if ($minimum && $maximum) { $errorString = t('A password must be between %s and %s characters long.', $minimum->getMinimumLength(), $maximum->getMaximumLength()); $requirement = t('Must be between %s and %s characters long.', $minimum->getMinimumLength(), $maximum->getMaximumLength()); } elseif ($minimum) { $errorString = t('Must be at least %s characters long.', $minimum->getMinimumLength()); $requirement = t('A password must be at least %s characters long.', $minimum->getMinimumLength()); } elseif ($maximum) { $errorString = t('A password must be at most %s characters long.', $maximum->getMaximumLength()); $requirement = t('Must be at most %s characters long.', $maximum->getMaximumLength()); } else { $errorString = t('Invalid Password.'); $requirement = ''; } $errorHandler = function ($validator, $code, $password) use ($errorString) { return $errorString; }; $requirementHandler = function ($validator, $code) use (&$requirement) { return $requirement; }; $minimum->setRequirementString($minimum::E_TOO_SHORT, $requirementHandler); $minimum->setErrorString($minimum::E_TOO_SHORT, $errorHandler); $maximum->setRequirementString($maximum::E_TOO_LONG, $requirementHandler); $maximum->setErrorString($maximum::E_TOO_LONG, $errorHandler); }
[ "protected", "function", "applyMinMaxStrings", "(", "$", "minimum", ",", "$", "maximum", ")", "{", "if", "(", "$", "minimum", "&&", "$", "maximum", ")", "{", "$", "errorString", "=", "t", "(", "'A password must be between %s and %s characters long.'", ",", "$", "minimum", "->", "getMinimumLength", "(", ")", ",", "$", "maximum", "->", "getMaximumLength", "(", ")", ")", ";", "$", "requirement", "=", "t", "(", "'Must be between %s and %s characters long.'", ",", "$", "minimum", "->", "getMinimumLength", "(", ")", ",", "$", "maximum", "->", "getMaximumLength", "(", ")", ")", ";", "}", "elseif", "(", "$", "minimum", ")", "{", "$", "errorString", "=", "t", "(", "'Must be at least %s characters long.'", ",", "$", "minimum", "->", "getMinimumLength", "(", ")", ")", ";", "$", "requirement", "=", "t", "(", "'A password must be at least %s characters long.'", ",", "$", "minimum", "->", "getMinimumLength", "(", ")", ")", ";", "}", "elseif", "(", "$", "maximum", ")", "{", "$", "errorString", "=", "t", "(", "'A password must be at most %s characters long.'", ",", "$", "maximum", "->", "getMaximumLength", "(", ")", ")", ";", "$", "requirement", "=", "t", "(", "'Must be at most %s characters long.'", ",", "$", "maximum", "->", "getMaximumLength", "(", ")", ")", ";", "}", "else", "{", "$", "errorString", "=", "t", "(", "'Invalid Password.'", ")", ";", "$", "requirement", "=", "''", ";", "}", "$", "errorHandler", "=", "function", "(", "$", "validator", ",", "$", "code", ",", "$", "password", ")", "use", "(", "$", "errorString", ")", "{", "return", "$", "errorString", ";", "}", ";", "$", "requirementHandler", "=", "function", "(", "$", "validator", ",", "$", "code", ")", "use", "(", "&", "$", "requirement", ")", "{", "return", "$", "requirement", ";", "}", ";", "$", "minimum", "->", "setRequirementString", "(", "$", "minimum", "::", "E_TOO_SHORT", ",", "$", "requirementHandler", ")", ";", "$", "minimum", "->", "setErrorString", "(", "$", "minimum", "::", "E_TOO_SHORT", ",", "$", "errorHandler", ")", ";", "$", "maximum", "->", "setRequirementString", "(", "$", "maximum", "::", "E_TOO_LONG", ",", "$", "requirementHandler", ")", ";", "$", "maximum", "->", "setErrorString", "(", "$", "maximum", "::", "E_TOO_LONG", ",", "$", "errorHandler", ")", ";", "}" ]
Apply translatable strings to minimum and maximum requirements @param $minimum @param $maximum
[ "Apply", "translatable", "strings", "to", "minimum", "and", "maximum", "requirements" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Validator/PasswordValidatorServiceProvider.php#L110-L133
train
concrete5/concrete5
concrete/src/Validator/PasswordValidatorServiceProvider.php
PasswordValidatorServiceProvider.applyStringRequirementValidators
protected function applyStringRequirementValidators(ValidatorManagerInterface $manager) { $specialCharacters = (int) $this->config->get('concrete.user.password.required_special_characters', 0); $lowerCase = (int) $this->config->get('concrete.user.password.required_lower_case', 0); $upperCase = (int) $this->config->get('concrete.user.password.required_upper_case', 0); if ($specialCharacters) { $regex = "/([^a-zA-Z0-9].*){{$specialCharacters},}/"; $requirement = t2('Must contain at least %d special character.', 'Must contain at least %d special characters.', $specialCharacters); $manager->setValidator('required_special_characters', $this->regexValidator($regex, $requirement)); } if ($lowerCase) { $regex = "/([a-z].*){{$lowerCase},}/"; $requirement = t2('Must contain at least %d lowercase character.', 'Must contain at least %d lowercase characters.', $lowerCase); $manager->setValidator('required_lower_case', $this->regexValidator($regex, $requirement)); } if ($upperCase) { $regex = "/([A-Z].*){{$upperCase},}/"; $requirement = t2('Must contain at least %d uppercase character.', 'Must contain at least %d uppercase characters.', $upperCase); $manager->setValidator('required_upper_case', $this->regexValidator($regex, $requirement)); } }
php
protected function applyStringRequirementValidators(ValidatorManagerInterface $manager) { $specialCharacters = (int) $this->config->get('concrete.user.password.required_special_characters', 0); $lowerCase = (int) $this->config->get('concrete.user.password.required_lower_case', 0); $upperCase = (int) $this->config->get('concrete.user.password.required_upper_case', 0); if ($specialCharacters) { $regex = "/([^a-zA-Z0-9].*){{$specialCharacters},}/"; $requirement = t2('Must contain at least %d special character.', 'Must contain at least %d special characters.', $specialCharacters); $manager->setValidator('required_special_characters', $this->regexValidator($regex, $requirement)); } if ($lowerCase) { $regex = "/([a-z].*){{$lowerCase},}/"; $requirement = t2('Must contain at least %d lowercase character.', 'Must contain at least %d lowercase characters.', $lowerCase); $manager->setValidator('required_lower_case', $this->regexValidator($regex, $requirement)); } if ($upperCase) { $regex = "/([A-Z].*){{$upperCase},}/"; $requirement = t2('Must contain at least %d uppercase character.', 'Must contain at least %d uppercase characters.', $upperCase); $manager->setValidator('required_upper_case', $this->regexValidator($regex, $requirement)); } }
[ "protected", "function", "applyStringRequirementValidators", "(", "ValidatorManagerInterface", "$", "manager", ")", "{", "$", "specialCharacters", "=", "(", "int", ")", "$", "this", "->", "config", "->", "get", "(", "'concrete.user.password.required_special_characters'", ",", "0", ")", ";", "$", "lowerCase", "=", "(", "int", ")", "$", "this", "->", "config", "->", "get", "(", "'concrete.user.password.required_lower_case'", ",", "0", ")", ";", "$", "upperCase", "=", "(", "int", ")", "$", "this", "->", "config", "->", "get", "(", "'concrete.user.password.required_upper_case'", ",", "0", ")", ";", "if", "(", "$", "specialCharacters", ")", "{", "$", "regex", "=", "\"/([^a-zA-Z0-9].*){{$specialCharacters},}/\"", ";", "$", "requirement", "=", "t2", "(", "'Must contain at least %d special character.'", ",", "'Must contain at least %d special characters.'", ",", "$", "specialCharacters", ")", ";", "$", "manager", "->", "setValidator", "(", "'required_special_characters'", ",", "$", "this", "->", "regexValidator", "(", "$", "regex", ",", "$", "requirement", ")", ")", ";", "}", "if", "(", "$", "lowerCase", ")", "{", "$", "regex", "=", "\"/([a-z].*){{$lowerCase},}/\"", ";", "$", "requirement", "=", "t2", "(", "'Must contain at least %d lowercase character.'", ",", "'Must contain at least %d lowercase characters.'", ",", "$", "lowerCase", ")", ";", "$", "manager", "->", "setValidator", "(", "'required_lower_case'", ",", "$", "this", "->", "regexValidator", "(", "$", "regex", ",", "$", "requirement", ")", ")", ";", "}", "if", "(", "$", "upperCase", ")", "{", "$", "regex", "=", "\"/([A-Z].*){{$upperCase},}/\"", ";", "$", "requirement", "=", "t2", "(", "'Must contain at least %d uppercase character.'", ",", "'Must contain at least %d uppercase characters.'", ",", "$", "upperCase", ")", ";", "$", "manager", "->", "setValidator", "(", "'required_upper_case'", ",", "$", "this", "->", "regexValidator", "(", "$", "regex", ",", "$", "requirement", ")", ")", ";", "}", "}" ]
Apply validators that require specific substrings @param \Concrete\Core\Validator\ValidatorManagerInterface $manager
[ "Apply", "validators", "that", "require", "specific", "substrings" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Validator/PasswordValidatorServiceProvider.php#L140-L166
train
concrete5/concrete5
concrete/src/Validator/PasswordValidatorServiceProvider.php
PasswordValidatorServiceProvider.regexValidator
protected function regexValidator($regex, $requirement) { $validator = $this->app->make(RegexValidator::class, [$regex]); $validator->setRequirementString(RegexValidator::E_DOES_NOT_MATCH, $requirement); $validator->setErrorString(RegexValidator::E_DOES_NOT_MATCH, $requirement); return $validator; }
php
protected function regexValidator($regex, $requirement) { $validator = $this->app->make(RegexValidator::class, [$regex]); $validator->setRequirementString(RegexValidator::E_DOES_NOT_MATCH, $requirement); $validator->setErrorString(RegexValidator::E_DOES_NOT_MATCH, $requirement); return $validator; }
[ "protected", "function", "regexValidator", "(", "$", "regex", ",", "$", "requirement", ")", "{", "$", "validator", "=", "$", "this", "->", "app", "->", "make", "(", "RegexValidator", "::", "class", ",", "[", "$", "regex", "]", ")", ";", "$", "validator", "->", "setRequirementString", "(", "RegexValidator", "::", "E_DOES_NOT_MATCH", ",", "$", "requirement", ")", ";", "$", "validator", "->", "setErrorString", "(", "RegexValidator", "::", "E_DOES_NOT_MATCH", ",", "$", "requirement", ")", ";", "return", "$", "validator", ";", "}" ]
Create a regex validator @param string $regex @param string $requirement @return RegexValidator
[ "Create", "a", "regex", "validator" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Validator/PasswordValidatorServiceProvider.php#L176-L183
train
concrete5/concrete5
concrete/src/Validator/PasswordValidatorServiceProvider.php
PasswordValidatorServiceProvider.wrappedRegexValidator
protected function wrappedRegexValidator($regex, $requirementString) { $regexValidator = $this->regexValidator($regex, $requirementString); $validator = $this->app->make(ClosureValidator::class, [ function (ClosureValidator $validator, $string, ArrayAccess $error = null) use ($regexValidator) { try { $regexValidator->isValid($string, $error); } catch (\RuntimeException $e) { if ($error) { $error[] = $regexValidator::E_DOES_NOT_MATCH; } return false; } }, function () use ($regexValidator, $requirementString) { return [ $regexValidator::E_DOES_NOT_MATCH => $requirementString ]; } ]); return $validator; }
php
protected function wrappedRegexValidator($regex, $requirementString) { $regexValidator = $this->regexValidator($regex, $requirementString); $validator = $this->app->make(ClosureValidator::class, [ function (ClosureValidator $validator, $string, ArrayAccess $error = null) use ($regexValidator) { try { $regexValidator->isValid($string, $error); } catch (\RuntimeException $e) { if ($error) { $error[] = $regexValidator::E_DOES_NOT_MATCH; } return false; } }, function () use ($regexValidator, $requirementString) { return [ $regexValidator::E_DOES_NOT_MATCH => $requirementString ]; } ]); return $validator; }
[ "protected", "function", "wrappedRegexValidator", "(", "$", "regex", ",", "$", "requirementString", ")", "{", "$", "regexValidator", "=", "$", "this", "->", "regexValidator", "(", "$", "regex", ",", "$", "requirementString", ")", ";", "$", "validator", "=", "$", "this", "->", "app", "->", "make", "(", "ClosureValidator", "::", "class", ",", "[", "function", "(", "ClosureValidator", "$", "validator", ",", "$", "string", ",", "ArrayAccess", "$", "error", "=", "null", ")", "use", "(", "$", "regexValidator", ")", "{", "try", "{", "$", "regexValidator", "->", "isValid", "(", "$", "string", ",", "$", "error", ")", ";", "}", "catch", "(", "\\", "RuntimeException", "$", "e", ")", "{", "if", "(", "$", "error", ")", "{", "$", "error", "[", "]", "=", "$", "regexValidator", "::", "E_DOES_NOT_MATCH", ";", "}", "return", "false", ";", "}", "}", ",", "function", "(", ")", "use", "(", "$", "regexValidator", ",", "$", "requirementString", ")", "{", "return", "[", "$", "regexValidator", "::", "E_DOES_NOT_MATCH", "=>", "$", "requirementString", "]", ";", "}", "]", ")", ";", "return", "$", "validator", ";", "}" ]
Create a closure validator that wraps a regex validator and handles all errors If the given regex is invalid, we will deny all passwords! @param $regex @param $requirementString @return \Concrete\Core\Validator\ClosureValidator|mixed
[ "Create", "a", "closure", "validator", "that", "wraps", "a", "regex", "validator", "and", "handles", "all", "errors", "If", "the", "given", "regex", "is", "invalid", "we", "will", "deny", "all", "passwords!" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Validator/PasswordValidatorServiceProvider.php#L207-L231
train
concrete5/concrete5
concrete/src/Application/Service/UserInterface/Menu.php
Menu.getPageHeaderMenuItems
public function getPageHeaderMenuItems($position = false) { if ($position) { $tmpItems = array(); foreach ($this->pageHeaderMenuItems as $mi) { if ($mi->getPosition() == $position) { $tmpItems[] = $mi; } } return $tmpItems; } else { return $this->pageHeaderMenuItems; } }
php
public function getPageHeaderMenuItems($position = false) { if ($position) { $tmpItems = array(); foreach ($this->pageHeaderMenuItems as $mi) { if ($mi->getPosition() == $position) { $tmpItems[] = $mi; } } return $tmpItems; } else { return $this->pageHeaderMenuItems; } }
[ "public", "function", "getPageHeaderMenuItems", "(", "$", "position", "=", "false", ")", "{", "if", "(", "$", "position", ")", "{", "$", "tmpItems", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "pageHeaderMenuItems", "as", "$", "mi", ")", "{", "if", "(", "$", "mi", "->", "getPosition", "(", ")", "==", "$", "position", ")", "{", "$", "tmpItems", "[", "]", "=", "$", "mi", ";", "}", "}", "return", "$", "tmpItems", ";", "}", "else", "{", "return", "$", "this", "->", "pageHeaderMenuItems", ";", "}", "}" ]
Returns current menu items. @param bool $position @return ItemInterface[]
[ "Returns", "current", "menu", "items", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Application/Service/UserInterface/Menu.php#L64-L78
train
concrete5/concrete5
concrete/controllers/dialog/file/replace.php
Replace.getReplacingFile
protected function getReplacingFile() { if ($this->replacingFile === false) { $replacingFile = null; $fID = $this->request->request->get('fID', $this->request->query->get('fID')); if ($fID && is_scalar($fID)) { $fID = (int) $fID; if ($fID !== 0) { $replacingFile = $this->app->make(EntityManagerInterface::class)->find(File::class, $fID); } } $this->setReplacingFile($replacingFile); } return $this->replacingFile; }
php
protected function getReplacingFile() { if ($this->replacingFile === false) { $replacingFile = null; $fID = $this->request->request->get('fID', $this->request->query->get('fID')); if ($fID && is_scalar($fID)) { $fID = (int) $fID; if ($fID !== 0) { $replacingFile = $this->app->make(EntityManagerInterface::class)->find(File::class, $fID); } } $this->setReplacingFile($replacingFile); } return $this->replacingFile; }
[ "protected", "function", "getReplacingFile", "(", ")", "{", "if", "(", "$", "this", "->", "replacingFile", "===", "false", ")", "{", "$", "replacingFile", "=", "null", ";", "$", "fID", "=", "$", "this", "->", "request", "->", "request", "->", "get", "(", "'fID'", ",", "$", "this", "->", "request", "->", "query", "->", "get", "(", "'fID'", ")", ")", ";", "if", "(", "$", "fID", "&&", "is_scalar", "(", "$", "fID", ")", ")", "{", "$", "fID", "=", "(", "int", ")", "$", "fID", ";", "if", "(", "$", "fID", "!==", "0", ")", "{", "$", "replacingFile", "=", "$", "this", "->", "app", "->", "make", "(", "EntityManagerInterface", "::", "class", ")", "->", "find", "(", "File", "::", "class", ",", "$", "fID", ")", ";", "}", "}", "$", "this", "->", "setReplacingFile", "(", "$", "replacingFile", ")", ";", "}", "return", "$", "this", "->", "replacingFile", ";", "}" ]
Get the file being replaced. @return \Concrete\Core\Entity\File\File|null null if not found, a File instance otherwise
[ "Get", "the", "file", "being", "replaced", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/controllers/dialog/file/replace.php#L34-L49
train
concrete5/concrete5
concrete/controllers/dialog/file/replace.php
Replace.setReplacingFile
protected function setReplacingFile(File $value = null) { if ($value !== $this->replacingFile) { $this->replacingFile = $value; } return $this; }
php
protected function setReplacingFile(File $value = null) { if ($value !== $this->replacingFile) { $this->replacingFile = $value; } return $this; }
[ "protected", "function", "setReplacingFile", "(", "File", "$", "value", "=", "null", ")", "{", "if", "(", "$", "value", "!==", "$", "this", "->", "replacingFile", ")", "{", "$", "this", "->", "replacingFile", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Set the file being replaced. @param \Concrete\Core\Entity\File\File|null $value null if not found, a File instance otherwise @return $this
[ "Set", "the", "file", "being", "replaced", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/controllers/dialog/file/replace.php#L58-L65
train
concrete5/concrete5
concrete/src/Foundation/Processor/ProcessorQueue.php
ProcessorQueue.process
public function process() { $queue = $this->getQueue(); $tasks = $this->getTasks(); foreach ($this->target->getItems() as $targetItem) { foreach ($tasks as $task) { $action = new QueueAction($this, $this->target, $task[1], $targetItem); $queue->send(serialize($action)); } } }
php
public function process() { $queue = $this->getQueue(); $tasks = $this->getTasks(); foreach ($this->target->getItems() as $targetItem) { foreach ($tasks as $task) { $action = new QueueAction($this, $this->target, $task[1], $targetItem); $queue->send(serialize($action)); } } }
[ "public", "function", "process", "(", ")", "{", "$", "queue", "=", "$", "this", "->", "getQueue", "(", ")", ";", "$", "tasks", "=", "$", "this", "->", "getTasks", "(", ")", ";", "foreach", "(", "$", "this", "->", "target", "->", "getItems", "(", ")", "as", "$", "targetItem", ")", "{", "foreach", "(", "$", "tasks", "as", "$", "task", ")", "{", "$", "action", "=", "new", "QueueAction", "(", "$", "this", ",", "$", "this", "->", "target", ",", "$", "task", "[", "1", "]", ",", "$", "targetItem", ")", ";", "$", "queue", "->", "send", "(", "serialize", "(", "$", "action", ")", ")", ";", "}", "}", "}" ]
Takes the current queue, and fills it based on the currently registered tasks and the registered processor.
[ "Takes", "the", "current", "queue", "and", "fills", "it", "based", "on", "the", "currently", "registered", "tasks", "and", "the", "registered", "processor", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Foundation/Processor/ProcessorQueue.php#L82-L92
train
concrete5/concrete5
concrete/src/Entity/Site/Site.php
Site.getConfigRepository
public function getConfigRepository() { if (!$this->siteConfig) { $app = Application::getFacadeApplication(); $this->updateSiteConfigRepository($app->make('config'), $this); } return $this->siteConfig; }
php
public function getConfigRepository() { if (!$this->siteConfig) { $app = Application::getFacadeApplication(); $this->updateSiteConfigRepository($app->make('config'), $this); } return $this->siteConfig; }
[ "public", "function", "getConfigRepository", "(", ")", "{", "if", "(", "!", "$", "this", "->", "siteConfig", ")", "{", "$", "app", "=", "Application", "::", "getFacadeApplication", "(", ")", ";", "$", "this", "->", "updateSiteConfigRepository", "(", "$", "app", "->", "make", "(", "'config'", ")", ",", "$", "this", ")", ";", "}", "return", "$", "this", "->", "siteConfig", ";", "}" ]
Get the site configuration repository. @return \Concrete\Core\Site\Config\Liaison
[ "Get", "the", "site", "configuration", "repository", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/Site/Site.php#L203-L211
train
concrete5/concrete5
concrete/src/Entity/Site/Site.php
Site.getSiteHomePageObject
public function getSiteHomePageObject($version = 'RECENT') { $tree = $this->getSiteTreeObject(); return $tree === null ? null : $tree->getSiteHomePageObject($version); }
php
public function getSiteHomePageObject($version = 'RECENT') { $tree = $this->getSiteTreeObject(); return $tree === null ? null : $tree->getSiteHomePageObject($version); }
[ "public", "function", "getSiteHomePageObject", "(", "$", "version", "=", "'RECENT'", ")", "{", "$", "tree", "=", "$", "this", "->", "getSiteTreeObject", "(", ")", ";", "return", "$", "tree", "===", "null", "?", "null", ":", "$", "tree", "->", "getSiteHomePageObject", "(", "$", "version", ")", ";", "}" ]
Get the home page of the default language. @param string|int $version 'ACTIVE', 'RECENT' or a specific page version ID @return \Concrete\Core\Page\Page|null
[ "Get", "the", "home", "page", "of", "the", "default", "language", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/Site/Site.php#L314-L319
train
concrete5/concrete5
concrete/src/Entity/Site/Site.php
Site.getTimezone
public function getTimezone() { $timezone = null; $config = $this->getConfigRepository(); if ($config) { $timezone = $config->get('timezone'); } if (!$timezone) { $timezone = date_default_timezone_get(); } return $timezone; }
php
public function getTimezone() { $timezone = null; $config = $this->getConfigRepository(); if ($config) { $timezone = $config->get('timezone'); } if (!$timezone) { $timezone = date_default_timezone_get(); } return $timezone; }
[ "public", "function", "getTimezone", "(", ")", "{", "$", "timezone", "=", "null", ";", "$", "config", "=", "$", "this", "->", "getConfigRepository", "(", ")", ";", "if", "(", "$", "config", ")", "{", "$", "timezone", "=", "$", "config", "->", "get", "(", "'timezone'", ")", ";", "}", "if", "(", "!", "$", "timezone", ")", "{", "$", "timezone", "=", "date_default_timezone_get", "(", ")", ";", "}", "return", "$", "timezone", ";", "}" ]
Get the site time zone identifier. @return string
[ "Get", "the", "site", "time", "zone", "identifier", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/Site/Site.php#L439-L451
train
concrete5/concrete5
concrete/src/Entity/File/File.php
File.reindex
public function reindex() { $category = \Core::make('Concrete\Core\Attribute\Category\FileCategory'); $indexer = $category->getSearchIndexer(); $values = $category->getAttributeValues($this); foreach ($values as $value) { $indexer->indexEntry($category, $value, $this); } }
php
public function reindex() { $category = \Core::make('Concrete\Core\Attribute\Category\FileCategory'); $indexer = $category->getSearchIndexer(); $values = $category->getAttributeValues($this); foreach ($values as $value) { $indexer->indexEntry($category, $value, $this); } }
[ "public", "function", "reindex", "(", ")", "{", "$", "category", "=", "\\", "Core", "::", "make", "(", "'Concrete\\Core\\Attribute\\Category\\FileCategory'", ")", ";", "$", "indexer", "=", "$", "category", "->", "getSearchIndexer", "(", ")", ";", "$", "values", "=", "$", "category", "->", "getAttributeValues", "(", "$", "this", ")", ";", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", "indexer", "->", "indexEntry", "(", "$", "category", ",", "$", "value", ",", "$", "this", ")", ";", "}", "}" ]
Reindex the attributes on this file.
[ "Reindex", "the", "attributes", "on", "this", "file", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/File/File.php#L176-L184
train
concrete5/concrete5
concrete/src/Entity/File/File.php
File.setFileStorageLocation
public function setFileStorageLocation(\Concrete\Core\Entity\File\StorageLocation\StorageLocation $newLocation) { $fh = Loader::helper('concrete/file'); $currentLocation = $this->getFileStorageLocationObject(); if ($newLocation->getID() == $currentLocation->getID()) { return false; } $currentFilesystem = $currentLocation->getFileSystemObject(); $newFileSystem = $newLocation->getFileSystemObject(); $list = $this->getVersionList(); try { foreach ($list as $fv) { $manager = new \League\Flysystem\MountManager([ 'current' => $currentFilesystem, 'new' => $newFileSystem, ]); $fp = $fh->prefix($fv->getPrefix(), $fv->getFilename()); $manager->move('current://' . $fp, 'new://' . $fp); $thumbs = Type::getVersionList(); foreach ($thumbs as $type) { $fv->updateThumbnailStorageLocation($type, $newLocation); } } } catch (\Exception $e) { throw new \Exception($e->getMessage()); } $this->setStorageLocation($newLocation); $this->save(); }
php
public function setFileStorageLocation(\Concrete\Core\Entity\File\StorageLocation\StorageLocation $newLocation) { $fh = Loader::helper('concrete/file'); $currentLocation = $this->getFileStorageLocationObject(); if ($newLocation->getID() == $currentLocation->getID()) { return false; } $currentFilesystem = $currentLocation->getFileSystemObject(); $newFileSystem = $newLocation->getFileSystemObject(); $list = $this->getVersionList(); try { foreach ($list as $fv) { $manager = new \League\Flysystem\MountManager([ 'current' => $currentFilesystem, 'new' => $newFileSystem, ]); $fp = $fh->prefix($fv->getPrefix(), $fv->getFilename()); $manager->move('current://' . $fp, 'new://' . $fp); $thumbs = Type::getVersionList(); foreach ($thumbs as $type) { $fv->updateThumbnailStorageLocation($type, $newLocation); } } } catch (\Exception $e) { throw new \Exception($e->getMessage()); } $this->setStorageLocation($newLocation); $this->save(); }
[ "public", "function", "setFileStorageLocation", "(", "\\", "Concrete", "\\", "Core", "\\", "Entity", "\\", "File", "\\", "StorageLocation", "\\", "StorageLocation", "$", "newLocation", ")", "{", "$", "fh", "=", "Loader", "::", "helper", "(", "'concrete/file'", ")", ";", "$", "currentLocation", "=", "$", "this", "->", "getFileStorageLocationObject", "(", ")", ";", "if", "(", "$", "newLocation", "->", "getID", "(", ")", "==", "$", "currentLocation", "->", "getID", "(", ")", ")", "{", "return", "false", ";", "}", "$", "currentFilesystem", "=", "$", "currentLocation", "->", "getFileSystemObject", "(", ")", ";", "$", "newFileSystem", "=", "$", "newLocation", "->", "getFileSystemObject", "(", ")", ";", "$", "list", "=", "$", "this", "->", "getVersionList", "(", ")", ";", "try", "{", "foreach", "(", "$", "list", "as", "$", "fv", ")", "{", "$", "manager", "=", "new", "\\", "League", "\\", "Flysystem", "\\", "MountManager", "(", "[", "'current'", "=>", "$", "currentFilesystem", ",", "'new'", "=>", "$", "newFileSystem", ",", "]", ")", ";", "$", "fp", "=", "$", "fh", "->", "prefix", "(", "$", "fv", "->", "getPrefix", "(", ")", ",", "$", "fv", "->", "getFilename", "(", ")", ")", ";", "$", "manager", "->", "move", "(", "'current://'", ".", "$", "fp", ",", "'new://'", ".", "$", "fp", ")", ";", "$", "thumbs", "=", "Type", "::", "getVersionList", "(", ")", ";", "foreach", "(", "$", "thumbs", "as", "$", "type", ")", "{", "$", "fv", "->", "updateThumbnailStorageLocation", "(", "$", "type", ",", "$", "newLocation", ")", ";", "}", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "\\", "Exception", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "$", "this", "->", "setStorageLocation", "(", "$", "newLocation", ")", ";", "$", "this", "->", "save", "(", ")", ";", "}" ]
Move a file from its current FSL to a new FSL. @param StorageLocation\StorageLocation $newLocation @return bool false if the storage location is the same @throws \Exception
[ "Move", "a", "file", "from", "its", "current", "FSL", "to", "a", "new", "FSL", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/File/File.php#L217-L250
train
concrete5/concrete5
concrete/src/Entity/File/File.php
File.setPassword
public function setPassword($pw) { $fe = new \Concrete\Core\File\Event\FileWithPassword($this); $fe->setFilePassword($pw); Events::dispatch('on_file_set_password', $fe); $this->fPassword = $pw; $this->save(); }
php
public function setPassword($pw) { $fe = new \Concrete\Core\File\Event\FileWithPassword($this); $fe->setFilePassword($pw); Events::dispatch('on_file_set_password', $fe); $this->fPassword = $pw; $this->save(); }
[ "public", "function", "setPassword", "(", "$", "pw", ")", "{", "$", "fe", "=", "new", "\\", "Concrete", "\\", "Core", "\\", "File", "\\", "Event", "\\", "FileWithPassword", "(", "$", "this", ")", ";", "$", "fe", "->", "setFilePassword", "(", "$", "pw", ")", ";", "Events", "::", "dispatch", "(", "'on_file_set_password'", ",", "$", "fe", ")", ";", "$", "this", "->", "fPassword", "=", "$", "pw", ";", "$", "this", "->", "save", "(", ")", ";", "}" ]
Sets the access password on a file. @param $pw string
[ "Sets", "the", "access", "password", "on", "a", "file", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/File/File.php#L257-L265
train
concrete5/concrete5
concrete/src/Entity/File/File.php
File.setUser
public function setUser(\Concrete\Core\Entity\User\User $user) { $this->author = $user; $this->save(); }
php
public function setUser(\Concrete\Core\Entity\User\User $user) { $this->author = $user; $this->save(); }
[ "public", "function", "setUser", "(", "\\", "Concrete", "\\", "Core", "\\", "Entity", "\\", "User", "\\", "User", "$", "user", ")", "{", "$", "this", "->", "author", "=", "$", "user", ";", "$", "this", "->", "save", "(", ")", ";", "}" ]
Set the user who authored the file. @param \Concrete\Core\Entity\User\User $user
[ "Set", "the", "user", "who", "authored", "the", "file", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/File/File.php#L324-L328
train
concrete5/concrete5
concrete/src/Entity/File/File.php
File.getFileSetIDs
public function getFileSetIDs() { $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $rows = $db->fetchAll('select fsID from FileSetFiles where fID = ?', [$this->getFileID()]); $ids = array_map('intval', array_map('array_pop', $rows)); return $ids; }
php
public function getFileSetIDs() { $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $rows = $db->fetchAll('select fsID from FileSetFiles where fID = ?', [$this->getFileID()]); $ids = array_map('intval', array_map('array_pop', $rows)); return $ids; }
[ "public", "function", "getFileSetIDs", "(", ")", "{", "$", "app", "=", "Application", "::", "getFacadeApplication", "(", ")", ";", "$", "db", "=", "$", "app", "->", "make", "(", "Connection", "::", "class", ")", ";", "$", "rows", "=", "$", "db", "->", "fetchAll", "(", "'select fsID from FileSetFiles where fID = ?'", ",", "[", "$", "this", "->", "getFileID", "(", ")", "]", ")", ";", "$", "ids", "=", "array_map", "(", "'intval'", ",", "array_map", "(", "'array_pop'", ",", "$", "rows", ")", ")", ";", "return", "$", "ids", ";", "}" ]
Get the IDs of the file sets that this file belongs to. @return int[]
[ "Get", "the", "IDs", "of", "the", "file", "sets", "that", "this", "file", "belongs", "to", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/File/File.php#L335-L343
train
concrete5/concrete5
concrete/src/Entity/File/File.php
File.getFileSets
public function getFileSets() { $filesets = []; foreach ($this->getFileSetIDs() as $fsID) { $fs = FileSet::getByID($fsID); if ($fs !== null) { $filesets[] = $fs; } } return $filesets; }
php
public function getFileSets() { $filesets = []; foreach ($this->getFileSetIDs() as $fsID) { $fs = FileSet::getByID($fsID); if ($fs !== null) { $filesets[] = $fs; } } return $filesets; }
[ "public", "function", "getFileSets", "(", ")", "{", "$", "filesets", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getFileSetIDs", "(", ")", "as", "$", "fsID", ")", "{", "$", "fs", "=", "FileSet", "::", "getByID", "(", "$", "fsID", ")", ";", "if", "(", "$", "fs", "!==", "null", ")", "{", "$", "filesets", "[", "]", "=", "$", "fs", ";", "}", "}", "return", "$", "filesets", ";", "}" ]
Get the file sets that this file belongs to. @return FileSet[]
[ "Get", "the", "file", "sets", "that", "this", "file", "belongs", "to", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/File/File.php#L350-L361
train
concrete5/concrete5
concrete/src/Entity/File/File.php
File.isStarred
public function isStarred($u = false) { if (!$u) { $u = new User(); } $db = Loader::db(); $r = $db->GetOne( 'select fsfID from FileSetFiles fsf inner join FileSets fs on fs.fsID = fsf.fsID where fsf.fID = ? and fs.uID = ? and fs.fsType = ?', [$this->getFileID(), $u->getUserID(), FileSet::TYPE_STARRED] ); return $r > 0; }
php
public function isStarred($u = false) { if (!$u) { $u = new User(); } $db = Loader::db(); $r = $db->GetOne( 'select fsfID from FileSetFiles fsf inner join FileSets fs on fs.fsID = fsf.fsID where fsf.fID = ? and fs.uID = ? and fs.fsType = ?', [$this->getFileID(), $u->getUserID(), FileSet::TYPE_STARRED] ); return $r > 0; }
[ "public", "function", "isStarred", "(", "$", "u", "=", "false", ")", "{", "if", "(", "!", "$", "u", ")", "{", "$", "u", "=", "new", "User", "(", ")", ";", "}", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "r", "=", "$", "db", "->", "GetOne", "(", "'select fsfID from FileSetFiles fsf inner join FileSets fs on fs.fsID = fsf.fsID where fsf.fID = ? and fs.uID = ? and fs.fsType = ?'", ",", "[", "$", "this", "->", "getFileID", "(", ")", ",", "$", "u", "->", "getUserID", "(", ")", ",", "FileSet", "::", "TYPE_STARRED", "]", ")", ";", "return", "$", "r", ">", "0", ";", "}" ]
Tell if a file is starred by a user. @param bool|User $u User to check against if they starred a file, If no user is provided we used the current user @return bool true if the user starred
[ "Tell", "if", "a", "file", "is", "starred", "by", "a", "user", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/File/File.php#L370-L382
train
concrete5/concrete5
concrete/src/Entity/File/File.php
File.createNewVersion
public function createNewVersion($copyUnderlyingFile = false) { $fv = $this->getRecentVersion(); $fav = $this->getApprovedVersion(); $fv2 = $fv->duplicate(); if ($fv->getFileVersionID() == $fav->getFileVersionID()) { $fv2->approve(); } if ($copyUnderlyingFile) { $fv2->duplicateUnderlyingFile(); } return $fv2; }
php
public function createNewVersion($copyUnderlyingFile = false) { $fv = $this->getRecentVersion(); $fav = $this->getApprovedVersion(); $fv2 = $fv->duplicate(); if ($fv->getFileVersionID() == $fav->getFileVersionID()) { $fv2->approve(); } if ($copyUnderlyingFile) { $fv2->duplicateUnderlyingFile(); } return $fv2; }
[ "public", "function", "createNewVersion", "(", "$", "copyUnderlyingFile", "=", "false", ")", "{", "$", "fv", "=", "$", "this", "->", "getRecentVersion", "(", ")", ";", "$", "fav", "=", "$", "this", "->", "getApprovedVersion", "(", ")", ";", "$", "fv2", "=", "$", "fv", "->", "duplicate", "(", ")", ";", "if", "(", "$", "fv", "->", "getFileVersionID", "(", ")", "==", "$", "fav", "->", "getFileVersionID", "(", ")", ")", "{", "$", "fv2", "->", "approve", "(", ")", ";", "}", "if", "(", "$", "copyUnderlyingFile", ")", "{", "$", "fv2", "->", "duplicateUnderlyingFile", "(", ")", ";", "}", "return", "$", "fv2", ";", "}" ]
Create a new version of a file. @param bool $copyUnderlyingFile If we should copy the underlying file, or reference the original @return Version
[ "Create", "a", "new", "version", "of", "a", "file", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/File/File.php#L407-L422
train
concrete5/concrete5
concrete/src/Entity/File/File.php
File.getVersionToModify
public function getVersionToModify($forceCreateNew = false) { $u = new User(); $createNew = false; $fv = $this->getRecentVersion(); $fav = $this->getApprovedVersion(); // first test. Does the user ID of the most recent version match ours? If not, then we create new if ($u->getUserID() != $fv->getAuthorUserID()) { $createNew = true; } // second test. If the date the version was added is older than File::CREATE_NEW_VERSION_THRESHOLD, we create new $diff = time() - $fv->getDateAdded()->getTimestamp(); if ($diff > self::CREATE_NEW_VERSION_THRESHOLD) { $createNew = true; } if ($forceCreateNew) { $createNew = true; } if ($createNew) { $fv2 = $fv->duplicate(); // Are the recent and active versions the same? If so, we approve this new version we just made if ($fv->getFileVersionID() == $fav->getFileVersionID()) { $fv2->approve(); } return $fv2; } else { return $fv; } }
php
public function getVersionToModify($forceCreateNew = false) { $u = new User(); $createNew = false; $fv = $this->getRecentVersion(); $fav = $this->getApprovedVersion(); // first test. Does the user ID of the most recent version match ours? If not, then we create new if ($u->getUserID() != $fv->getAuthorUserID()) { $createNew = true; } // second test. If the date the version was added is older than File::CREATE_NEW_VERSION_THRESHOLD, we create new $diff = time() - $fv->getDateAdded()->getTimestamp(); if ($diff > self::CREATE_NEW_VERSION_THRESHOLD) { $createNew = true; } if ($forceCreateNew) { $createNew = true; } if ($createNew) { $fv2 = $fv->duplicate(); // Are the recent and active versions the same? If so, we approve this new version we just made if ($fv->getFileVersionID() == $fav->getFileVersionID()) { $fv2->approve(); } return $fv2; } else { return $fv; } }
[ "public", "function", "getVersionToModify", "(", "$", "forceCreateNew", "=", "false", ")", "{", "$", "u", "=", "new", "User", "(", ")", ";", "$", "createNew", "=", "false", ";", "$", "fv", "=", "$", "this", "->", "getRecentVersion", "(", ")", ";", "$", "fav", "=", "$", "this", "->", "getApprovedVersion", "(", ")", ";", "// first test. Does the user ID of the most recent version match ours? If not, then we create new", "if", "(", "$", "u", "->", "getUserID", "(", ")", "!=", "$", "fv", "->", "getAuthorUserID", "(", ")", ")", "{", "$", "createNew", "=", "true", ";", "}", "// second test. If the date the version was added is older than File::CREATE_NEW_VERSION_THRESHOLD, we create new", "$", "diff", "=", "time", "(", ")", "-", "$", "fv", "->", "getDateAdded", "(", ")", "->", "getTimestamp", "(", ")", ";", "if", "(", "$", "diff", ">", "self", "::", "CREATE_NEW_VERSION_THRESHOLD", ")", "{", "$", "createNew", "=", "true", ";", "}", "if", "(", "$", "forceCreateNew", ")", "{", "$", "createNew", "=", "true", ";", "}", "if", "(", "$", "createNew", ")", "{", "$", "fv2", "=", "$", "fv", "->", "duplicate", "(", ")", ";", "// Are the recent and active versions the same? If so, we approve this new version we just made", "if", "(", "$", "fv", "->", "getFileVersionID", "(", ")", "==", "$", "fav", "->", "getFileVersionID", "(", ")", ")", "{", "$", "fv2", "->", "approve", "(", ")", ";", "}", "return", "$", "fv2", ";", "}", "else", "{", "return", "$", "fv", ";", "}", "}" ]
Returns a file version object that is to be written to. Computes whether we can use the current most recent version, OR a new one should be created. @param bool $forceCreateNew If we should always create a new version even if we are below the threshold @return Version
[ "Returns", "a", "file", "version", "object", "that", "is", "to", "be", "written", "to", ".", "Computes", "whether", "we", "can", "use", "the", "current", "most", "recent", "version", "OR", "a", "new", "one", "should", "be", "created", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/File/File.php#L431-L466
train
concrete5/concrete5
concrete/src/Entity/File/File.php
File.setFileFolder
public function setFileFolder(FileFolder $folder) { $em = \ORM::entityManager('core'); $this->folderTreeNodeID = $folder->getTreeNodeID(); $em->persist($this); $em->flush(); }
php
public function setFileFolder(FileFolder $folder) { $em = \ORM::entityManager('core'); $this->folderTreeNodeID = $folder->getTreeNodeID(); $em->persist($this); $em->flush(); }
[ "public", "function", "setFileFolder", "(", "FileFolder", "$", "folder", ")", "{", "$", "em", "=", "\\", "ORM", "::", "entityManager", "(", "'core'", ")", ";", "$", "this", "->", "folderTreeNodeID", "=", "$", "folder", "->", "getTreeNodeID", "(", ")", ";", "$", "em", "->", "persist", "(", "$", "this", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "}" ]
Folder to put the file in. @param FileFolder $folder
[ "Folder", "to", "put", "the", "file", "in", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/File/File.php#L483-L491
train
concrete5/concrete5
concrete/src/Entity/File/File.php
File.inFileSet
public function inFileSet(Set $fs) { $db = Loader::db(); $r = $db->GetOne( 'select fsfID from FileSetFiles where fID = ? and fsID = ?', [$this->getFileID(), $fs->getFileSetID()] ); return $r > 0; }
php
public function inFileSet(Set $fs) { $db = Loader::db(); $r = $db->GetOne( 'select fsfID from FileSetFiles where fID = ? and fsID = ?', [$this->getFileID(), $fs->getFileSetID()] ); return $r > 0; }
[ "public", "function", "inFileSet", "(", "Set", "$", "fs", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "r", "=", "$", "db", "->", "GetOne", "(", "'select fsfID from FileSetFiles where fID = ? and fsID = ?'", ",", "[", "$", "this", "->", "getFileID", "(", ")", ",", "$", "fs", "->", "getFileSetID", "(", ")", "]", ")", ";", "return", "$", "r", ">", "0", ";", "}" ]
If a file is in a particular file set. @param Set $fs @return bool true if its in the set
[ "If", "a", "file", "is", "in", "a", "particular", "file", "set", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/File/File.php#L625-L634
train
concrete5/concrete5
concrete/src/Entity/File/File.php
File.delete
public function delete($removeNode = true) { // first, we remove all files from the drive $db = Core::make(Connection::class); $em = $db->getEntityManager(); $em->beginTransaction(); try { // fire an on_page_delete event $fve = new \Concrete\Core\File\Event\DeleteFile($this); $fve = Events::dispatch('on_file_delete', $fve); if (!$fve->proceed()) { return false; } // Delete the tree node for the file. if ($removeNode) { $nodeID = $db->fetchColumn('select treeNodeID from TreeFileNodes where fID = ?', [$this->getFileID()]); if ($nodeID) { $node = Node::getByID($nodeID); $node->delete(); } } $versions = $this->getVersionList(); foreach ($versions as $fv) { $fv->delete(true); } $db->Execute('delete from FileSetFiles where fID = ?', [$this->fID]); $db->Execute('delete from FileSearchIndexAttributes where fID = ?', [$this->fID]); $db->Execute('delete from DownloadStatistics where fID = ?', [$this->fID]); $db->Execute('delete from FilePermissionAssignments where fID = ?', [$this->fID]); $db->Execute('delete from FileImageThumbnailPaths where fileID = ?', [$this->fID]); $db->Execute('delete from Files where fID = ?', [$this->fID]); $em->commit(); } catch (\Exception $e) { $em->rollback(); throw $e; } return true; }
php
public function delete($removeNode = true) { // first, we remove all files from the drive $db = Core::make(Connection::class); $em = $db->getEntityManager(); $em->beginTransaction(); try { // fire an on_page_delete event $fve = new \Concrete\Core\File\Event\DeleteFile($this); $fve = Events::dispatch('on_file_delete', $fve); if (!$fve->proceed()) { return false; } // Delete the tree node for the file. if ($removeNode) { $nodeID = $db->fetchColumn('select treeNodeID from TreeFileNodes where fID = ?', [$this->getFileID()]); if ($nodeID) { $node = Node::getByID($nodeID); $node->delete(); } } $versions = $this->getVersionList(); foreach ($versions as $fv) { $fv->delete(true); } $db->Execute('delete from FileSetFiles where fID = ?', [$this->fID]); $db->Execute('delete from FileSearchIndexAttributes where fID = ?', [$this->fID]); $db->Execute('delete from DownloadStatistics where fID = ?', [$this->fID]); $db->Execute('delete from FilePermissionAssignments where fID = ?', [$this->fID]); $db->Execute('delete from FileImageThumbnailPaths where fileID = ?', [$this->fID]); $db->Execute('delete from Files where fID = ?', [$this->fID]); $em->commit(); } catch (\Exception $e) { $em->rollback(); throw $e; } return true; }
[ "public", "function", "delete", "(", "$", "removeNode", "=", "true", ")", "{", "// first, we remove all files from the drive", "$", "db", "=", "Core", "::", "make", "(", "Connection", "::", "class", ")", ";", "$", "em", "=", "$", "db", "->", "getEntityManager", "(", ")", ";", "$", "em", "->", "beginTransaction", "(", ")", ";", "try", "{", "// fire an on_page_delete event", "$", "fve", "=", "new", "\\", "Concrete", "\\", "Core", "\\", "File", "\\", "Event", "\\", "DeleteFile", "(", "$", "this", ")", ";", "$", "fve", "=", "Events", "::", "dispatch", "(", "'on_file_delete'", ",", "$", "fve", ")", ";", "if", "(", "!", "$", "fve", "->", "proceed", "(", ")", ")", "{", "return", "false", ";", "}", "// Delete the tree node for the file.", "if", "(", "$", "removeNode", ")", "{", "$", "nodeID", "=", "$", "db", "->", "fetchColumn", "(", "'select treeNodeID from TreeFileNodes where fID = ?'", ",", "[", "$", "this", "->", "getFileID", "(", ")", "]", ")", ";", "if", "(", "$", "nodeID", ")", "{", "$", "node", "=", "Node", "::", "getByID", "(", "$", "nodeID", ")", ";", "$", "node", "->", "delete", "(", ")", ";", "}", "}", "$", "versions", "=", "$", "this", "->", "getVersionList", "(", ")", ";", "foreach", "(", "$", "versions", "as", "$", "fv", ")", "{", "$", "fv", "->", "delete", "(", "true", ")", ";", "}", "$", "db", "->", "Execute", "(", "'delete from FileSetFiles where fID = ?'", ",", "[", "$", "this", "->", "fID", "]", ")", ";", "$", "db", "->", "Execute", "(", "'delete from FileSearchIndexAttributes where fID = ?'", ",", "[", "$", "this", "->", "fID", "]", ")", ";", "$", "db", "->", "Execute", "(", "'delete from DownloadStatistics where fID = ?'", ",", "[", "$", "this", "->", "fID", "]", ")", ";", "$", "db", "->", "Execute", "(", "'delete from FilePermissionAssignments where fID = ?'", ",", "[", "$", "this", "->", "fID", "]", ")", ";", "$", "db", "->", "Execute", "(", "'delete from FileImageThumbnailPaths where fileID = ?'", ",", "[", "$", "this", "->", "fID", "]", ")", ";", "$", "db", "->", "Execute", "(", "'delete from Files where fID = ?'", ",", "[", "$", "this", "->", "fID", "]", ")", ";", "$", "em", "->", "commit", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "em", "->", "rollback", "(", ")", ";", "throw", "$", "e", ";", "}", "return", "true", ";", "}" ]
Removes a file, including all of its versions. @return bool returns false if the on_file_delete event says not to proceed, returns true on success @throws \Exception contains the exception type and message of why the deletion fails
[ "Removes", "a", "file", "including", "all", "of", "its", "versions", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/File/File.php#L643-L685
train
concrete5/concrete5
concrete/src/Entity/File/File.php
File.getRecentVersion
public function getRecentVersion() { $em = \ORM::entityManager(); $r = $em->getRepository('\Concrete\Core\Entity\File\Version'); return $r->findOneBy( ['file' => $this], ['fvID' => 'desc'] ); }
php
public function getRecentVersion() { $em = \ORM::entityManager(); $r = $em->getRepository('\Concrete\Core\Entity\File\Version'); return $r->findOneBy( ['file' => $this], ['fvID' => 'desc'] ); }
[ "public", "function", "getRecentVersion", "(", ")", "{", "$", "em", "=", "\\", "ORM", "::", "entityManager", "(", ")", ";", "$", "r", "=", "$", "em", "->", "getRepository", "(", "'\\Concrete\\Core\\Entity\\File\\Version'", ")", ";", "return", "$", "r", "->", "findOneBy", "(", "[", "'file'", "=>", "$", "this", "]", ",", "[", "'fvID'", "=>", "'desc'", "]", ")", ";", "}" ]
Returns the most recent FileVersion object. @return Version
[ "Returns", "the", "most", "recent", "FileVersion", "object", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/File/File.php#L692-L701
train
concrete5/concrete5
concrete/src/Entity/File/File.php
File.getVersion
public function getVersion($fvID = null) { if (!$fvID) { return $this->getApprovedVersion(); } $em = \ORM::entityManager(); $r = $em->getRepository('\Concrete\Core\Entity\File\Version'); return $r->findOneBy(['file' => $this, 'fvID' => $fvID]); }
php
public function getVersion($fvID = null) { if (!$fvID) { return $this->getApprovedVersion(); } $em = \ORM::entityManager(); $r = $em->getRepository('\Concrete\Core\Entity\File\Version'); return $r->findOneBy(['file' => $this, 'fvID' => $fvID]); }
[ "public", "function", "getVersion", "(", "$", "fvID", "=", "null", ")", "{", "if", "(", "!", "$", "fvID", ")", "{", "return", "$", "this", "->", "getApprovedVersion", "(", ")", ";", "}", "$", "em", "=", "\\", "ORM", "::", "entityManager", "(", ")", ";", "$", "r", "=", "$", "em", "->", "getRepository", "(", "'\\Concrete\\Core\\Entity\\File\\Version'", ")", ";", "return", "$", "r", "->", "findOneBy", "(", "[", "'file'", "=>", "$", "this", ",", "'fvID'", "=>", "$", "fvID", "]", ")", ";", "}" ]
returns the FileVersion object for the provided fvID if none provided returns the approved version. @param int $fvID @return Version
[ "returns", "the", "FileVersion", "object", "for", "the", "provided", "fvID", "if", "none", "provided", "returns", "the", "approved", "version", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/File/File.php#L711-L721
train
concrete5/concrete5
concrete/src/Entity/File/File.php
File.getDownloadStatistics
public function getDownloadStatistics($limit = 20) { $db = Loader::db(); $limitString = ''; if ($limit != false) { $limitString = 'limit ' . intval($limit); } if (is_object($this) && $this instanceof self) { return $db->getAll( "SELECT * FROM DownloadStatistics WHERE fID = ? ORDER BY timestamp desc {$limitString}", [$this->getFileID()] ); } else { return $db->getAll("SELECT * FROM DownloadStatistics ORDER BY timestamp desc {$limitString}"); } }
php
public function getDownloadStatistics($limit = 20) { $db = Loader::db(); $limitString = ''; if ($limit != false) { $limitString = 'limit ' . intval($limit); } if (is_object($this) && $this instanceof self) { return $db->getAll( "SELECT * FROM DownloadStatistics WHERE fID = ? ORDER BY timestamp desc {$limitString}", [$this->getFileID()] ); } else { return $db->getAll("SELECT * FROM DownloadStatistics ORDER BY timestamp desc {$limitString}"); } }
[ "public", "function", "getDownloadStatistics", "(", "$", "limit", "=", "20", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "limitString", "=", "''", ";", "if", "(", "$", "limit", "!=", "false", ")", "{", "$", "limitString", "=", "'limit '", ".", "intval", "(", "$", "limit", ")", ";", "}", "if", "(", "is_object", "(", "$", "this", ")", "&&", "$", "this", "instanceof", "self", ")", "{", "return", "$", "db", "->", "getAll", "(", "\"SELECT * FROM DownloadStatistics WHERE fID = ? ORDER BY timestamp desc {$limitString}\"", ",", "[", "$", "this", "->", "getFileID", "(", ")", "]", ")", ";", "}", "else", "{", "return", "$", "db", "->", "getAll", "(", "\"SELECT * FROM DownloadStatistics ORDER BY timestamp desc {$limitString}\"", ")", ";", "}", "}" ]
Get the download statistics for the current file. @param int $limit max number of stats to retrieve @return array
[ "Get", "the", "download", "statistics", "for", "the", "current", "file", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/File/File.php#L752-L768
train
concrete5/concrete5
concrete/src/Entity/File/File.php
File.trackDownload
public function trackDownload($rcID = null) { $u = new User(); $uID = intval($u->getUserID()); $fv = $this->getApprovedVersion(); $fvID = $fv->getFileVersionID(); if (!isset($rcID) || !is_numeric($rcID)) { $rcID = 0; } $fve = new \Concrete\Core\File\Event\FileAccess($fv); Events::dispatch('on_file_download', $fve); $config = Core::make('config'); if ($config->get('concrete.statistics.track_downloads')) { $db = Loader::db(); $db->Execute( 'insert into DownloadStatistics (fID, fvID, uID, rcID) values (?, ?, ?, ?)', [$this->fID, intval($fvID), $uID, $rcID] ); } }
php
public function trackDownload($rcID = null) { $u = new User(); $uID = intval($u->getUserID()); $fv = $this->getApprovedVersion(); $fvID = $fv->getFileVersionID(); if (!isset($rcID) || !is_numeric($rcID)) { $rcID = 0; } $fve = new \Concrete\Core\File\Event\FileAccess($fv); Events::dispatch('on_file_download', $fve); $config = Core::make('config'); if ($config->get('concrete.statistics.track_downloads')) { $db = Loader::db(); $db->Execute( 'insert into DownloadStatistics (fID, fvID, uID, rcID) values (?, ?, ?, ?)', [$this->fID, intval($fvID), $uID, $rcID] ); } }
[ "public", "function", "trackDownload", "(", "$", "rcID", "=", "null", ")", "{", "$", "u", "=", "new", "User", "(", ")", ";", "$", "uID", "=", "intval", "(", "$", "u", "->", "getUserID", "(", ")", ")", ";", "$", "fv", "=", "$", "this", "->", "getApprovedVersion", "(", ")", ";", "$", "fvID", "=", "$", "fv", "->", "getFileVersionID", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "rcID", ")", "||", "!", "is_numeric", "(", "$", "rcID", ")", ")", "{", "$", "rcID", "=", "0", ";", "}", "$", "fve", "=", "new", "\\", "Concrete", "\\", "Core", "\\", "File", "\\", "Event", "\\", "FileAccess", "(", "$", "fv", ")", ";", "Events", "::", "dispatch", "(", "'on_file_download'", ",", "$", "fve", ")", ";", "$", "config", "=", "Core", "::", "make", "(", "'config'", ")", ";", "if", "(", "$", "config", "->", "get", "(", "'concrete.statistics.track_downloads'", ")", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "db", "->", "Execute", "(", "'insert into DownloadStatistics (fID, fvID, uID, rcID) values (?, ?, ?, ?)'", ",", "[", "$", "this", "->", "fID", ",", "intval", "(", "$", "fvID", ")", ",", "$", "uID", ",", "$", "rcID", "]", ")", ";", "}", "}" ]
Tracks File Download, takes the cID of the page that the file was downloaded from. @param int $rcID
[ "Tracks", "File", "Download", "takes", "the", "cID", "of", "the", "page", "that", "the", "file", "was", "downloaded", "from", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/File/File.php#L775-L796
train
concrete5/concrete5
concrete/src/Entity/File/StorageLocation/Type/Type.php
Type.delete
public function delete() { $list = StorageLocation::getList(); foreach ($list as $item) { if ($item->getTypeObject()->getHandle() == $this->getHandle()) { throw new \Exception(t('Please remove all storage locations using this storage type.')); } } $em = \ORM::entityManager(); $em->remove($this); $em->flush(); return true; }
php
public function delete() { $list = StorageLocation::getList(); foreach ($list as $item) { if ($item->getTypeObject()->getHandle() == $this->getHandle()) { throw new \Exception(t('Please remove all storage locations using this storage type.')); } } $em = \ORM::entityManager(); $em->remove($this); $em->flush(); return true; }
[ "public", "function", "delete", "(", ")", "{", "$", "list", "=", "StorageLocation", "::", "getList", "(", ")", ";", "foreach", "(", "$", "list", "as", "$", "item", ")", "{", "if", "(", "$", "item", "->", "getTypeObject", "(", ")", "->", "getHandle", "(", ")", "==", "$", "this", "->", "getHandle", "(", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "t", "(", "'Please remove all storage locations using this storage type.'", ")", ")", ";", "}", "}", "$", "em", "=", "\\", "ORM", "::", "entityManager", "(", ")", ";", "$", "em", "->", "remove", "(", "$", "this", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "return", "true", ";", "}" ]
Removes the storage type if no configurations exist. @throws \Exception @return bool
[ "Removes", "the", "storage", "type", "if", "no", "configurations", "exist", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/File/StorageLocation/Type/Type.php#L126-L140
train
concrete5/concrete5
concrete/src/StyleCustomizer/Preset.php
Preset.getStyleValueList
public function getStyleValueList() { if (!isset($this->styleValueList)) { $this->styleValueList = \Concrete\Core\StyleCustomizer\Style\ValueList::loadFromLessFile($this->file, $this->urlroot); } return $this->styleValueList; }
php
public function getStyleValueList() { if (!isset($this->styleValueList)) { $this->styleValueList = \Concrete\Core\StyleCustomizer\Style\ValueList::loadFromLessFile($this->file, $this->urlroot); } return $this->styleValueList; }
[ "public", "function", "getStyleValueList", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "styleValueList", ")", ")", "{", "$", "this", "->", "styleValueList", "=", "\\", "Concrete", "\\", "Core", "\\", "StyleCustomizer", "\\", "Style", "\\", "ValueList", "::", "loadFromLessFile", "(", "$", "this", "->", "file", ",", "$", "this", "->", "urlroot", ")", ";", "}", "return", "$", "this", "->", "styleValueList", ";", "}" ]
Gets the style value list object for this preset. @return \Concrete\Core\StyleCustomizer\Style\ValueList
[ "Gets", "the", "style", "value", "list", "object", "for", "this", "preset", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/StyleCustomizer/Preset.php#L64-L71
train
concrete5/concrete5
concrete/src/Page/Collection/Collection.php
Collection.getByID
public static function getByID($cID, $version = 'RECENT') { $db = Loader::db(); $q = 'select Collections.cDateAdded, Collections.cDateModified, Collections.cID from Collections where cID = ?'; $row = $db->getRow($q, [$cID]); $c = new self(); $c->setPropertiesFromArray($row); if ($version != false) { // we don't do this on the front page $c->loadVersionObject($version); } return $c; }
php
public static function getByID($cID, $version = 'RECENT') { $db = Loader::db(); $q = 'select Collections.cDateAdded, Collections.cDateModified, Collections.cID from Collections where cID = ?'; $row = $db->getRow($q, [$cID]); $c = new self(); $c->setPropertiesFromArray($row); if ($version != false) { // we don't do this on the front page $c->loadVersionObject($version); } return $c; }
[ "public", "static", "function", "getByID", "(", "$", "cID", ",", "$", "version", "=", "'RECENT'", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "q", "=", "'select Collections.cDateAdded, Collections.cDateModified, Collections.cID from Collections where cID = ?'", ";", "$", "row", "=", "$", "db", "->", "getRow", "(", "$", "q", ",", "[", "$", "cID", "]", ")", ";", "$", "c", "=", "new", "self", "(", ")", ";", "$", "c", "->", "setPropertiesFromArray", "(", "$", "row", ")", ";", "if", "(", "$", "version", "!=", "false", ")", "{", "// we don't do this on the front page", "$", "c", "->", "loadVersionObject", "(", "$", "version", ")", ";", "}", "return", "$", "c", ";", "}" ]
Get a collection by ID. @param int $cID The collection ID @param string|int|false $version the collection version ('RECENT' for the most recent version, 'ACTIVE' for the currently published version, 'SCHEDULED' for the currently scheduled version, a falsy value to not load the collection version, or an integer to retrieve a specific version ID) @return \Concrete\Core\Page\Collection\Collection If the collection is not found, you'll get an empty Collection instance
[ "Get", "a", "collection", "by", "ID", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Collection.php#L99-L114
train
concrete5/concrete5
concrete/src/Page/Collection/Collection.php
Collection.createCollection
public static function createCollection($data) { $db = Loader::db(); $dh = Loader::helper('date'); $cDate = $dh->getOverridableNow(); $data = array_merge( [ 'name' => '', 'pTemplateID' => 0, 'handle' => null, 'uID' => null, 'cDatePublic' => $cDate, 'cDescription' => null, ], $data ); $cDatePublic = ($data['cDatePublic']) ? $data['cDatePublic'] : $cDate; if (isset($data['cID'])) { $res = $db->query( 'insert into Collections (cID, cHandle, cDateAdded, cDateModified) values (?, ?, ?, ?)', [$data['cID'], $data['handle'], $cDate, $cDate] ); $newCID = $data['cID']; } else { $res = $db->query( 'insert into Collections (cHandle, cDateAdded, cDateModified) values (?, ?, ?)', [$data['handle'], $cDate, $cDate] ); $newCID = $db->Insert_ID(); } $cvIsApproved = (isset($data['cvIsApproved']) && $data['cvIsApproved'] == 0) ? 0 : 1; $cvIsNew = 1; if ($cvIsApproved) { $cvIsNew = 0; } if (isset($data['cvIsNew'])) { $cvIsNew = $data['cvIsNew']; } $data['name'] = Loader::helper('text')->sanitize($data['name']); $pThemeID = 0; if (isset($data['pThemeID']) && $data['pThemeID']) { $pThemeID = $data['pThemeID']; } $pTemplateID = 0; if ($data['pTemplateID']) { $pTemplateID = $data['pTemplateID']; } if ($res) { // now we add a pending version to the collectionversions table $v2 = [ $newCID, 1, $pTemplateID, $data['name'], $data['handle'], $data['cDescription'], $cDatePublic, $cDate, t(VERSION_INITIAL_COMMENT), $data['uID'], $cvIsApproved, $cvIsNew, $pThemeID, ]; $q2 = 'insert into CollectionVersions (cID, cvID, pTemplateID, cvName, cvHandle, cvDescription, cvDatePublic, cvDateCreated, cvComments, cvAuthorUID, cvIsApproved, cvIsNew, pThemeID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; $r2 = $db->prepare($q2); $res2 = $db->execute($r2, $v2); } $nc = self::getByID($newCID); return $nc; }
php
public static function createCollection($data) { $db = Loader::db(); $dh = Loader::helper('date'); $cDate = $dh->getOverridableNow(); $data = array_merge( [ 'name' => '', 'pTemplateID' => 0, 'handle' => null, 'uID' => null, 'cDatePublic' => $cDate, 'cDescription' => null, ], $data ); $cDatePublic = ($data['cDatePublic']) ? $data['cDatePublic'] : $cDate; if (isset($data['cID'])) { $res = $db->query( 'insert into Collections (cID, cHandle, cDateAdded, cDateModified) values (?, ?, ?, ?)', [$data['cID'], $data['handle'], $cDate, $cDate] ); $newCID = $data['cID']; } else { $res = $db->query( 'insert into Collections (cHandle, cDateAdded, cDateModified) values (?, ?, ?)', [$data['handle'], $cDate, $cDate] ); $newCID = $db->Insert_ID(); } $cvIsApproved = (isset($data['cvIsApproved']) && $data['cvIsApproved'] == 0) ? 0 : 1; $cvIsNew = 1; if ($cvIsApproved) { $cvIsNew = 0; } if (isset($data['cvIsNew'])) { $cvIsNew = $data['cvIsNew']; } $data['name'] = Loader::helper('text')->sanitize($data['name']); $pThemeID = 0; if (isset($data['pThemeID']) && $data['pThemeID']) { $pThemeID = $data['pThemeID']; } $pTemplateID = 0; if ($data['pTemplateID']) { $pTemplateID = $data['pTemplateID']; } if ($res) { // now we add a pending version to the collectionversions table $v2 = [ $newCID, 1, $pTemplateID, $data['name'], $data['handle'], $data['cDescription'], $cDatePublic, $cDate, t(VERSION_INITIAL_COMMENT), $data['uID'], $cvIsApproved, $cvIsNew, $pThemeID, ]; $q2 = 'insert into CollectionVersions (cID, cvID, pTemplateID, cvName, cvHandle, cvDescription, cvDatePublic, cvDateCreated, cvComments, cvAuthorUID, cvIsApproved, cvIsNew, pThemeID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; $r2 = $db->prepare($q2); $res2 = $db->execute($r2, $v2); } $nc = self::getByID($newCID); return $nc; }
[ "public", "static", "function", "createCollection", "(", "$", "data", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "dh", "=", "Loader", "::", "helper", "(", "'date'", ")", ";", "$", "cDate", "=", "$", "dh", "->", "getOverridableNow", "(", ")", ";", "$", "data", "=", "array_merge", "(", "[", "'name'", "=>", "''", ",", "'pTemplateID'", "=>", "0", ",", "'handle'", "=>", "null", ",", "'uID'", "=>", "null", ",", "'cDatePublic'", "=>", "$", "cDate", ",", "'cDescription'", "=>", "null", ",", "]", ",", "$", "data", ")", ";", "$", "cDatePublic", "=", "(", "$", "data", "[", "'cDatePublic'", "]", ")", "?", "$", "data", "[", "'cDatePublic'", "]", ":", "$", "cDate", ";", "if", "(", "isset", "(", "$", "data", "[", "'cID'", "]", ")", ")", "{", "$", "res", "=", "$", "db", "->", "query", "(", "'insert into Collections (cID, cHandle, cDateAdded, cDateModified) values (?, ?, ?, ?)'", ",", "[", "$", "data", "[", "'cID'", "]", ",", "$", "data", "[", "'handle'", "]", ",", "$", "cDate", ",", "$", "cDate", "]", ")", ";", "$", "newCID", "=", "$", "data", "[", "'cID'", "]", ";", "}", "else", "{", "$", "res", "=", "$", "db", "->", "query", "(", "'insert into Collections (cHandle, cDateAdded, cDateModified) values (?, ?, ?)'", ",", "[", "$", "data", "[", "'handle'", "]", ",", "$", "cDate", ",", "$", "cDate", "]", ")", ";", "$", "newCID", "=", "$", "db", "->", "Insert_ID", "(", ")", ";", "}", "$", "cvIsApproved", "=", "(", "isset", "(", "$", "data", "[", "'cvIsApproved'", "]", ")", "&&", "$", "data", "[", "'cvIsApproved'", "]", "==", "0", ")", "?", "0", ":", "1", ";", "$", "cvIsNew", "=", "1", ";", "if", "(", "$", "cvIsApproved", ")", "{", "$", "cvIsNew", "=", "0", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "'cvIsNew'", "]", ")", ")", "{", "$", "cvIsNew", "=", "$", "data", "[", "'cvIsNew'", "]", ";", "}", "$", "data", "[", "'name'", "]", "=", "Loader", "::", "helper", "(", "'text'", ")", "->", "sanitize", "(", "$", "data", "[", "'name'", "]", ")", ";", "$", "pThemeID", "=", "0", ";", "if", "(", "isset", "(", "$", "data", "[", "'pThemeID'", "]", ")", "&&", "$", "data", "[", "'pThemeID'", "]", ")", "{", "$", "pThemeID", "=", "$", "data", "[", "'pThemeID'", "]", ";", "}", "$", "pTemplateID", "=", "0", ";", "if", "(", "$", "data", "[", "'pTemplateID'", "]", ")", "{", "$", "pTemplateID", "=", "$", "data", "[", "'pTemplateID'", "]", ";", "}", "if", "(", "$", "res", ")", "{", "// now we add a pending version to the collectionversions table", "$", "v2", "=", "[", "$", "newCID", ",", "1", ",", "$", "pTemplateID", ",", "$", "data", "[", "'name'", "]", ",", "$", "data", "[", "'handle'", "]", ",", "$", "data", "[", "'cDescription'", "]", ",", "$", "cDatePublic", ",", "$", "cDate", ",", "t", "(", "VERSION_INITIAL_COMMENT", ")", ",", "$", "data", "[", "'uID'", "]", ",", "$", "cvIsApproved", ",", "$", "cvIsNew", ",", "$", "pThemeID", ",", "]", ";", "$", "q2", "=", "'insert into CollectionVersions (cID, cvID, pTemplateID, cvName, cvHandle, cvDescription, cvDatePublic, cvDateCreated, cvComments, cvAuthorUID, cvIsApproved, cvIsNew, pThemeID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'", ";", "$", "r2", "=", "$", "db", "->", "prepare", "(", "$", "q2", ")", ";", "$", "res2", "=", "$", "db", "->", "execute", "(", "$", "r2", ",", "$", "v2", ")", ";", "}", "$", "nc", "=", "self", "::", "getByID", "(", "$", "newCID", ")", ";", "return", "$", "nc", ";", "}" ]
Create a new Collection instance. @param array $data { @var int|null $cID The ID of the collection to create (if unspecified or NULL: database autoincrement value) @var string $handle The collection handle (default: NULL) @var string $name The collection name (default: empty string) @var string $cDescription The collection description (default: NULL) @var string $cDatePublic The collection publish date/time in format 'YYYY-MM-DD hh:mm:ss' (default: now) @var bool $cvIsApproved Is the collection version approved (default: true) @var bool $cvIsNew Is the collection to be considered "new"? (default: true if $cvIsApproved is false, false if $cvIsApproved is true) @var int|null $pThemeID The collection theme ID (default: NULL) @var int|null $pTemplateID The collection template ID (default: NULL) @var int|null $uID The ID of the collection author (default: NULL) } @return \Concrete\Core\Page\Collection\Collection
[ "Create", "a", "new", "Collection", "instance", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Collection.php#L194-L272
train
concrete5/concrete5
concrete/src/Page/Collection/Collection.php
Collection.getNextVersionComments
public function getNextVersionComments() { $c = Page::getByID($this->getCollectionID(), 'ACTIVE'); $cvID = $c->getVersionID(); return t('Version %d', $cvID + 1); }
php
public function getNextVersionComments() { $c = Page::getByID($this->getCollectionID(), 'ACTIVE'); $cvID = $c->getVersionID(); return t('Version %d', $cvID + 1); }
[ "public", "function", "getNextVersionComments", "(", ")", "{", "$", "c", "=", "Page", "::", "getByID", "(", "$", "this", "->", "getCollectionID", "(", ")", ",", "'ACTIVE'", ")", ";", "$", "cvID", "=", "$", "c", "->", "getVersionID", "(", ")", ";", "return", "t", "(", "'Version %d'", ",", "$", "cvID", "+", "1", ")", ";", "}" ]
Get the automatic comment for the next collection version. @return string Example: 'Version 2'
[ "Get", "the", "automatic", "comment", "for", "the", "next", "collection", "version", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Collection.php#L399-L405
train
concrete5/concrete5
concrete/src/Page/Collection/Collection.php
Collection.clearCollectionAttributes
public function clearCollectionAttributes($retainAKIDs = []) { $db = Loader::db(); if (count($retainAKIDs) > 0) { $cleanAKIDs = []; foreach ($retainAKIDs as $akID) { $cleanAKIDs[] = (int) $akID; } $akIDStr = implode(',', $cleanAKIDs); $v2 = [$this->getCollectionID(), $this->getVersionID()]; $db->query( "delete from CollectionAttributeValues where cID = ? and cvID = ? and akID not in ({$akIDStr})", $v2 ); } else { $v2 = [$this->getCollectionID(), $this->getVersionID()]; $db->query('delete from CollectionAttributeValues where cID = ? and cvID = ?', $v2); } $this->reindex(); }
php
public function clearCollectionAttributes($retainAKIDs = []) { $db = Loader::db(); if (count($retainAKIDs) > 0) { $cleanAKIDs = []; foreach ($retainAKIDs as $akID) { $cleanAKIDs[] = (int) $akID; } $akIDStr = implode(',', $cleanAKIDs); $v2 = [$this->getCollectionID(), $this->getVersionID()]; $db->query( "delete from CollectionAttributeValues where cID = ? and cvID = ? and akID not in ({$akIDStr})", $v2 ); } else { $v2 = [$this->getCollectionID(), $this->getVersionID()]; $db->query('delete from CollectionAttributeValues where cID = ? and cvID = ?', $v2); } $this->reindex(); }
[ "public", "function", "clearCollectionAttributes", "(", "$", "retainAKIDs", "=", "[", "]", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "if", "(", "count", "(", "$", "retainAKIDs", ")", ">", "0", ")", "{", "$", "cleanAKIDs", "=", "[", "]", ";", "foreach", "(", "$", "retainAKIDs", "as", "$", "akID", ")", "{", "$", "cleanAKIDs", "[", "]", "=", "(", "int", ")", "$", "akID", ";", "}", "$", "akIDStr", "=", "implode", "(", "','", ",", "$", "cleanAKIDs", ")", ";", "$", "v2", "=", "[", "$", "this", "->", "getCollectionID", "(", ")", ",", "$", "this", "->", "getVersionID", "(", ")", "]", ";", "$", "db", "->", "query", "(", "\"delete from CollectionAttributeValues where cID = ? and cvID = ? and akID not in ({$akIDStr})\"", ",", "$", "v2", ")", ";", "}", "else", "{", "$", "v2", "=", "[", "$", "this", "->", "getCollectionID", "(", ")", ",", "$", "this", "->", "getVersionID", "(", ")", "]", ";", "$", "db", "->", "query", "(", "'delete from CollectionAttributeValues where cID = ? and cvID = ?'", ",", "$", "v2", ")", ";", "}", "$", "this", "->", "reindex", "(", ")", ";", "}" ]
Delete the values of the attributes associated to the currently loaded collection version. @param int[] $retainAKIDs a list of attribute key IDs to keep (their values won't be deleted)
[ "Delete", "the", "values", "of", "the", "attributes", "associated", "to", "the", "currently", "loaded", "collection", "version", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Collection.php#L525-L544
train
concrete5/concrete5
concrete/src/Page/Collection/Collection.php
Collection.getSetCollectionAttributes
public function getSetCollectionAttributes() { $category = $this->vObj->getObjectAttributeCategory(); $values = $category->getAttributeValues($this->vObj); $attribs = []; foreach ($values as $value) { $attribs[] = $value->getAttributeKey(); } return $attribs; }
php
public function getSetCollectionAttributes() { $category = $this->vObj->getObjectAttributeCategory(); $values = $category->getAttributeValues($this->vObj); $attribs = []; foreach ($values as $value) { $attribs[] = $value->getAttributeKey(); } return $attribs; }
[ "public", "function", "getSetCollectionAttributes", "(", ")", "{", "$", "category", "=", "$", "this", "->", "vObj", "->", "getObjectAttributeCategory", "(", ")", ";", "$", "values", "=", "$", "category", "->", "getAttributeValues", "(", "$", "this", "->", "vObj", ")", ";", "$", "attribs", "=", "[", "]", ";", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", "attribs", "[", "]", "=", "$", "value", "->", "getAttributeKey", "(", ")", ";", "}", "return", "$", "attribs", ";", "}" ]
Get the list of attribute keys for which the currently loaded collection version has values. @return \Concrete\Core\Entity\Attribute\Key\PageKey[]
[ "Get", "the", "list", "of", "attribute", "keys", "for", "which", "the", "currently", "loaded", "collection", "version", "has", "values", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Collection.php#L561-L571
train
concrete5/concrete5
concrete/src/Page/Collection/Collection.php
Collection.hasAliasedContent
public function hasAliasedContent() { $db = Loader::db(); // aliased content is content on the particular page that is being // used elsewhere - but the content on the PAGE is the original version $v = [$this->cID]; $q = 'select bID from CollectionVersionBlocks where cID = ? and isOriginal = 1'; $r = $db->query($q, $v); $bIDArray = []; if ($r) { while ($row = $r->fetchRow()) { $bIDArray[] = $row['bID']; } if (count($bIDArray) > 0) { $bIDList = implode(',', $bIDArray); $v2 = [$bIDList, $this->cID]; $q2 = 'select cID from CollectionVersionBlocks where bID in (?) and cID <> ? limit 1'; $aliasedCID = $db->getOne($q2, $v2); if ($aliasedCID > 0) { return true; } } } return false; }
php
public function hasAliasedContent() { $db = Loader::db(); // aliased content is content on the particular page that is being // used elsewhere - but the content on the PAGE is the original version $v = [$this->cID]; $q = 'select bID from CollectionVersionBlocks where cID = ? and isOriginal = 1'; $r = $db->query($q, $v); $bIDArray = []; if ($r) { while ($row = $r->fetchRow()) { $bIDArray[] = $row['bID']; } if (count($bIDArray) > 0) { $bIDList = implode(',', $bIDArray); $v2 = [$bIDList, $this->cID]; $q2 = 'select cID from CollectionVersionBlocks where bID in (?) and cID <> ? limit 1'; $aliasedCID = $db->getOne($q2, $v2); if ($aliasedCID > 0) { return true; } } } return false; }
[ "public", "function", "hasAliasedContent", "(", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "// aliased content is content on the particular page that is being", "// used elsewhere - but the content on the PAGE is the original version", "$", "v", "=", "[", "$", "this", "->", "cID", "]", ";", "$", "q", "=", "'select bID from CollectionVersionBlocks where cID = ? and isOriginal = 1'", ";", "$", "r", "=", "$", "db", "->", "query", "(", "$", "q", ",", "$", "v", ")", ";", "$", "bIDArray", "=", "[", "]", ";", "if", "(", "$", "r", ")", "{", "while", "(", "$", "row", "=", "$", "r", "->", "fetchRow", "(", ")", ")", "{", "$", "bIDArray", "[", "]", "=", "$", "row", "[", "'bID'", "]", ";", "}", "if", "(", "count", "(", "$", "bIDArray", ")", ">", "0", ")", "{", "$", "bIDList", "=", "implode", "(", "','", ",", "$", "bIDArray", ")", ";", "$", "v2", "=", "[", "$", "bIDList", ",", "$", "this", "->", "cID", "]", ";", "$", "q2", "=", "'select cID from CollectionVersionBlocks where bID in (?) and cID <> ? limit 1'", ";", "$", "aliasedCID", "=", "$", "db", "->", "getOne", "(", "$", "q2", ",", "$", "v2", ")", ";", "if", "(", "$", "aliasedCID", ">", "0", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Does this collection contain blocks that are aliased in other pages? @return bool
[ "Does", "this", "collection", "contain", "blocks", "that", "are", "aliased", "in", "other", "pages?" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Collection.php#L590-L615
train
concrete5/concrete5
concrete/src/Page/Collection/Collection.php
Collection.getAreaCustomStyle
public function getAreaCustomStyle($area, $force = false) { $areac = $area->getAreaCollectionObject(); if ($areac instanceof Stack) { // this fixes the problem of users applying design to the main area on the page, and then that trickling into any // stacks that have been added to other areas of the page. return null; } $result = null; $styles = $this->vObj->getCustomAreaStyles(); $areaHandle = $area->getAreaHandle(); if ($force || isset($styles[$areaHandle])) { $pss = isset($styles[$areaHandle]) ? StyleSet::getByID($styles[$areaHandle]) : null; $result = new AreaCustomStyle($pss, $area, $this->getCollectionThemeObject()); } return $result; }
php
public function getAreaCustomStyle($area, $force = false) { $areac = $area->getAreaCollectionObject(); if ($areac instanceof Stack) { // this fixes the problem of users applying design to the main area on the page, and then that trickling into any // stacks that have been added to other areas of the page. return null; } $result = null; $styles = $this->vObj->getCustomAreaStyles(); $areaHandle = $area->getAreaHandle(); if ($force || isset($styles[$areaHandle])) { $pss = isset($styles[$areaHandle]) ? StyleSet::getByID($styles[$areaHandle]) : null; $result = new AreaCustomStyle($pss, $area, $this->getCollectionThemeObject()); } return $result; }
[ "public", "function", "getAreaCustomStyle", "(", "$", "area", ",", "$", "force", "=", "false", ")", "{", "$", "areac", "=", "$", "area", "->", "getAreaCollectionObject", "(", ")", ";", "if", "(", "$", "areac", "instanceof", "Stack", ")", "{", "// this fixes the problem of users applying design to the main area on the page, and then that trickling into any", "// stacks that have been added to other areas of the page.", "return", "null", ";", "}", "$", "result", "=", "null", ";", "$", "styles", "=", "$", "this", "->", "vObj", "->", "getCustomAreaStyles", "(", ")", ";", "$", "areaHandle", "=", "$", "area", "->", "getAreaHandle", "(", ")", ";", "if", "(", "$", "force", "||", "isset", "(", "$", "styles", "[", "$", "areaHandle", "]", ")", ")", "{", "$", "pss", "=", "isset", "(", "$", "styles", "[", "$", "areaHandle", "]", ")", "?", "StyleSet", "::", "getByID", "(", "$", "styles", "[", "$", "areaHandle", "]", ")", ":", "null", ";", "$", "result", "=", "new", "AreaCustomStyle", "(", "$", "pss", ",", "$", "area", ",", "$", "this", "->", "getCollectionThemeObject", "(", ")", ")", ";", "}", "return", "$", "result", ";", "}" ]
Get the custom style of an area in the currently loaded collection version. @param \Concrete\Core\Area\Area $area the area for which you want the custom styles @param bool $force Set to true to retrieve a CustomStyle even if the area does not define any custom style @return \Concrete\Core\Area\CustomStyle|null return NULL if the area does not have any custom style and $force is false, a CustomStyle instance otherwise
[ "Get", "the", "custom", "style", "of", "an", "area", "in", "the", "currently", "loaded", "collection", "version", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Collection.php#L625-L642
train
concrete5/concrete5
concrete/src/Page/Collection/Collection.php
Collection.setCustomStyleSet
public function setCustomStyleSet($area, $set) { $db = Loader::db(); $db->Replace( 'CollectionVersionAreaStyles', [ 'cID' => $this->getCollectionID(), 'cvID' => $this->getVersionID(), 'arHandle' => $area->getAreaHandle(), 'issID' => $set->getID(), ], ['cID', 'cvID', 'arHandle'], true ); }
php
public function setCustomStyleSet($area, $set) { $db = Loader::db(); $db->Replace( 'CollectionVersionAreaStyles', [ 'cID' => $this->getCollectionID(), 'cvID' => $this->getVersionID(), 'arHandle' => $area->getAreaHandle(), 'issID' => $set->getID(), ], ['cID', 'cvID', 'arHandle'], true ); }
[ "public", "function", "setCustomStyleSet", "(", "$", "area", ",", "$", "set", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "db", "->", "Replace", "(", "'CollectionVersionAreaStyles'", ",", "[", "'cID'", "=>", "$", "this", "->", "getCollectionID", "(", ")", ",", "'cvID'", "=>", "$", "this", "->", "getVersionID", "(", ")", ",", "'arHandle'", "=>", "$", "area", "->", "getAreaHandle", "(", ")", ",", "'issID'", "=>", "$", "set", "->", "getID", "(", ")", ",", "]", ",", "[", "'cID'", ",", "'cvID'", ",", "'arHandle'", "]", ",", "true", ")", ";", "}" ]
Set the custom style of an area in the currently loaded collection version. @param \Concrete\Core\Area\Area $area @param \Concrete\Core\Entity\StyleCustomizer\Inline\StyleSet $set
[ "Set", "the", "custom", "style", "of", "an", "area", "in", "the", "currently", "loaded", "collection", "version", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Collection.php#L650-L664
train
concrete5/concrete5
concrete/src/Page/Collection/Collection.php
Collection.resetAreaCustomStyle
public function resetAreaCustomStyle($area) { $db = Loader::db(); $db->Execute( 'delete from CollectionVersionAreaStyles where cID = ? and cvID = ? and arHandle = ?', [ $this->getCollectionID(), $this->getVersionID(), $area->getAreaHandle(), ] ); }
php
public function resetAreaCustomStyle($area) { $db = Loader::db(); $db->Execute( 'delete from CollectionVersionAreaStyles where cID = ? and cvID = ? and arHandle = ?', [ $this->getCollectionID(), $this->getVersionID(), $area->getAreaHandle(), ] ); }
[ "public", "function", "resetAreaCustomStyle", "(", "$", "area", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "db", "->", "Execute", "(", "'delete from CollectionVersionAreaStyles where cID = ? and cvID = ? and arHandle = ?'", ",", "[", "$", "this", "->", "getCollectionID", "(", ")", ",", "$", "this", "->", "getVersionID", "(", ")", ",", "$", "area", "->", "getAreaHandle", "(", ")", ",", "]", ")", ";", "}" ]
Delete all the custom styles of an area of the currently loaded collection version. @param \Concrete\Core\Area\Area $area
[ "Delete", "all", "the", "custom", "styles", "of", "an", "area", "of", "the", "currently", "loaded", "collection", "version", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Collection.php#L671-L682
train
concrete5/concrete5
concrete/src/Page/Collection/Collection.php
Collection.relateVersionEdits
public function relateVersionEdits($oc) { $db = Loader::db(); $v = [ $this->getCollectionID(), $this->getVersionID(), $oc->getCollectionID(), $oc->getVersionID(), ]; $r = $db->GetOne( 'select count(*) from CollectionVersionRelatedEdits where cID = ? and cvID = ? and cRelationID = ? and cvRelationID = ?', $v ); if ($r > 0) { return false; } else { $db->Execute( 'insert into CollectionVersionRelatedEdits (cID, cvID, cRelationID, cvRelationID) values (?, ?, ?, ?)', $v ); } }
php
public function relateVersionEdits($oc) { $db = Loader::db(); $v = [ $this->getCollectionID(), $this->getVersionID(), $oc->getCollectionID(), $oc->getVersionID(), ]; $r = $db->GetOne( 'select count(*) from CollectionVersionRelatedEdits where cID = ? and cvID = ? and cRelationID = ? and cvRelationID = ?', $v ); if ($r > 0) { return false; } else { $db->Execute( 'insert into CollectionVersionRelatedEdits (cID, cvID, cRelationID, cvRelationID) values (?, ?, ?, ?)', $v ); } }
[ "public", "function", "relateVersionEdits", "(", "$", "oc", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "v", "=", "[", "$", "this", "->", "getCollectionID", "(", ")", ",", "$", "this", "->", "getVersionID", "(", ")", ",", "$", "oc", "->", "getCollectionID", "(", ")", ",", "$", "oc", "->", "getVersionID", "(", ")", ",", "]", ";", "$", "r", "=", "$", "db", "->", "GetOne", "(", "'select count(*) from CollectionVersionRelatedEdits where cID = ? and cvID = ? and cRelationID = ? and cvRelationID = ?'", ",", "$", "v", ")", ";", "if", "(", "$", "r", ">", "0", ")", "{", "return", "false", ";", "}", "else", "{", "$", "db", "->", "Execute", "(", "'insert into CollectionVersionRelatedEdits (cID, cvID, cRelationID, cvRelationID) values (?, ?, ?, ?)'", ",", "$", "v", ")", ";", "}", "}" ]
Associate the edits of another collection to this collection. @param \Concrete\Core\Page\Collection\Collection $oc the collection that has been modified @return null|false return false if the other collection is already associated to this collection, NULL otherwise @example If a global area is modified inside this collection, you need to call $page->relateVersionEdits($globalArea)
[ "Associate", "the", "edits", "of", "another", "collection", "to", "this", "collection", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Collection.php#L812-L833
train
concrete5/concrete5
concrete/src/Page/Collection/Collection.php
Collection.getGlobalBlocks
public function getGlobalBlocks() { $db = Loader::db(); $v = [Stack::ST_TYPE_GLOBAL_AREA]; $rs = $db->GetCol('select stName from Stacks where Stacks.stType = ?', $v); $blocks = []; if (count($rs) > 0) { $pcp = new Permissions($this); foreach ($rs as $garHandle) { if ($pcp->canViewPageVersions()) { $s = Stack::getByName($garHandle, 'RECENT'); } else { $s = Stack::getByName($garHandle, 'ACTIVE'); } if (is_object($s)) { $blocksTmp = $s->getBlocks(STACKS_AREA_NAME); $blocks = array_merge($blocks, $blocksTmp); } } } return $blocks; }
php
public function getGlobalBlocks() { $db = Loader::db(); $v = [Stack::ST_TYPE_GLOBAL_AREA]; $rs = $db->GetCol('select stName from Stacks where Stacks.stType = ?', $v); $blocks = []; if (count($rs) > 0) { $pcp = new Permissions($this); foreach ($rs as $garHandle) { if ($pcp->canViewPageVersions()) { $s = Stack::getByName($garHandle, 'RECENT'); } else { $s = Stack::getByName($garHandle, 'ACTIVE'); } if (is_object($s)) { $blocksTmp = $s->getBlocks(STACKS_AREA_NAME); $blocks = array_merge($blocks, $blocksTmp); } } } return $blocks; }
[ "public", "function", "getGlobalBlocks", "(", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "v", "=", "[", "Stack", "::", "ST_TYPE_GLOBAL_AREA", "]", ";", "$", "rs", "=", "$", "db", "->", "GetCol", "(", "'select stName from Stacks where Stacks.stType = ?'", ",", "$", "v", ")", ";", "$", "blocks", "=", "[", "]", ";", "if", "(", "count", "(", "$", "rs", ")", ">", "0", ")", "{", "$", "pcp", "=", "new", "Permissions", "(", "$", "this", ")", ";", "foreach", "(", "$", "rs", "as", "$", "garHandle", ")", "{", "if", "(", "$", "pcp", "->", "canViewPageVersions", "(", ")", ")", "{", "$", "s", "=", "Stack", "::", "getByName", "(", "$", "garHandle", ",", "'RECENT'", ")", ";", "}", "else", "{", "$", "s", "=", "Stack", "::", "getByName", "(", "$", "garHandle", ",", "'ACTIVE'", ")", ";", "}", "if", "(", "is_object", "(", "$", "s", ")", ")", "{", "$", "blocksTmp", "=", "$", "s", "->", "getBlocks", "(", "STACKS_AREA_NAME", ")", ";", "$", "blocks", "=", "array_merge", "(", "$", "blocks", ",", "$", "blocksTmp", ")", ";", "}", "}", "}", "return", "$", "blocks", ";", "}" ]
Get the blocks contained in the all the global areas. @return \Concrete\Core\Block\Block[]
[ "Get", "the", "blocks", "contained", "in", "the", "all", "the", "global", "areas", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Collection.php#L858-L880
train
concrete5/concrete5
concrete/src/Page/Collection/Collection.php
Collection.addBlock
public function addBlock($bt, $a, $data) { $db = Loader::db(); // first we add the block to the system $nb = $bt->add($data, $this, $a); // now that we have a block, we add it to the collectionversions table $arHandle = (is_object($a)) ? $a->getAreaHandle() : $a; $cID = $this->getCollectionID(); $vObj = $this->getVersionObject(); if ($bt->includeAll()) { // normally, display order is dependant on a per area, per version basis. However, since this block // is not aliased across versions, then we want to get display order simply based on area, NOT based // on area + version $newBlockDisplayOrder = $this->getCollectionAreaDisplayOrder( $arHandle, true ); // second argument is "ignoreVersions" } else { $newBlockDisplayOrder = $this->getCollectionAreaDisplayOrder($arHandle); } $cbRelationID = $db->GetOne('select max(cbRelationID) as cbRelationID from CollectionVersionBlocks'); if (!$cbRelationID) { $cbRelationID = 1; } else { ++$cbRelationID; } $v = [ $cID, $vObj->getVersionID(), $nb->getBlockID(), $arHandle, $cbRelationID, $newBlockDisplayOrder, 1, (int) ($bt->includeAll()), ]; $q = 'insert into CollectionVersionBlocks (cID, cvID, bID, arHandle, cbRelationID, cbDisplayOrder, isOriginal, cbIncludeAll) values (?, ?, ?, ?, ?, ?, ?, ?)'; $res = $db->Execute($q, $v); $controller = $nb->getController(); $features = $controller->getBlockTypeFeatureObjects(); if (count($features) > 0) { foreach ($features as $fe) { $fd = $fe->getFeatureDetailObject($controller); $fa = CollectionVersionFeatureAssignment::add($fe, $fd, $this); $db->Execute( 'insert into BlockFeatureAssignments (cID, cvID, bID, faID) values (?, ?, ?, ?)', [ $this->getCollectionID(), $this->getVersionID(), $nb->getBlockID(), $fa->getFeatureAssignmentID(), ] ); } } return Block::getByID($nb->getBlockID(), $this, $a); }
php
public function addBlock($bt, $a, $data) { $db = Loader::db(); // first we add the block to the system $nb = $bt->add($data, $this, $a); // now that we have a block, we add it to the collectionversions table $arHandle = (is_object($a)) ? $a->getAreaHandle() : $a; $cID = $this->getCollectionID(); $vObj = $this->getVersionObject(); if ($bt->includeAll()) { // normally, display order is dependant on a per area, per version basis. However, since this block // is not aliased across versions, then we want to get display order simply based on area, NOT based // on area + version $newBlockDisplayOrder = $this->getCollectionAreaDisplayOrder( $arHandle, true ); // second argument is "ignoreVersions" } else { $newBlockDisplayOrder = $this->getCollectionAreaDisplayOrder($arHandle); } $cbRelationID = $db->GetOne('select max(cbRelationID) as cbRelationID from CollectionVersionBlocks'); if (!$cbRelationID) { $cbRelationID = 1; } else { ++$cbRelationID; } $v = [ $cID, $vObj->getVersionID(), $nb->getBlockID(), $arHandle, $cbRelationID, $newBlockDisplayOrder, 1, (int) ($bt->includeAll()), ]; $q = 'insert into CollectionVersionBlocks (cID, cvID, bID, arHandle, cbRelationID, cbDisplayOrder, isOriginal, cbIncludeAll) values (?, ?, ?, ?, ?, ?, ?, ?)'; $res = $db->Execute($q, $v); $controller = $nb->getController(); $features = $controller->getBlockTypeFeatureObjects(); if (count($features) > 0) { foreach ($features as $fe) { $fd = $fe->getFeatureDetailObject($controller); $fa = CollectionVersionFeatureAssignment::add($fe, $fd, $this); $db->Execute( 'insert into BlockFeatureAssignments (cID, cvID, bID, faID) values (?, ?, ?, ?)', [ $this->getCollectionID(), $this->getVersionID(), $nb->getBlockID(), $fa->getFeatureAssignmentID(), ] ); } } return Block::getByID($nb->getBlockID(), $this, $a); }
[ "public", "function", "addBlock", "(", "$", "bt", ",", "$", "a", ",", "$", "data", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "// first we add the block to the system", "$", "nb", "=", "$", "bt", "->", "add", "(", "$", "data", ",", "$", "this", ",", "$", "a", ")", ";", "// now that we have a block, we add it to the collectionversions table", "$", "arHandle", "=", "(", "is_object", "(", "$", "a", ")", ")", "?", "$", "a", "->", "getAreaHandle", "(", ")", ":", "$", "a", ";", "$", "cID", "=", "$", "this", "->", "getCollectionID", "(", ")", ";", "$", "vObj", "=", "$", "this", "->", "getVersionObject", "(", ")", ";", "if", "(", "$", "bt", "->", "includeAll", "(", ")", ")", "{", "// normally, display order is dependant on a per area, per version basis. However, since this block", "// is not aliased across versions, then we want to get display order simply based on area, NOT based", "// on area + version", "$", "newBlockDisplayOrder", "=", "$", "this", "->", "getCollectionAreaDisplayOrder", "(", "$", "arHandle", ",", "true", ")", ";", "// second argument is \"ignoreVersions\"", "}", "else", "{", "$", "newBlockDisplayOrder", "=", "$", "this", "->", "getCollectionAreaDisplayOrder", "(", "$", "arHandle", ")", ";", "}", "$", "cbRelationID", "=", "$", "db", "->", "GetOne", "(", "'select max(cbRelationID) as cbRelationID from CollectionVersionBlocks'", ")", ";", "if", "(", "!", "$", "cbRelationID", ")", "{", "$", "cbRelationID", "=", "1", ";", "}", "else", "{", "++", "$", "cbRelationID", ";", "}", "$", "v", "=", "[", "$", "cID", ",", "$", "vObj", "->", "getVersionID", "(", ")", ",", "$", "nb", "->", "getBlockID", "(", ")", ",", "$", "arHandle", ",", "$", "cbRelationID", ",", "$", "newBlockDisplayOrder", ",", "1", ",", "(", "int", ")", "(", "$", "bt", "->", "includeAll", "(", ")", ")", ",", "]", ";", "$", "q", "=", "'insert into CollectionVersionBlocks (cID, cvID, bID, arHandle, cbRelationID, cbDisplayOrder, isOriginal, cbIncludeAll) values (?, ?, ?, ?, ?, ?, ?, ?)'", ";", "$", "res", "=", "$", "db", "->", "Execute", "(", "$", "q", ",", "$", "v", ")", ";", "$", "controller", "=", "$", "nb", "->", "getController", "(", ")", ";", "$", "features", "=", "$", "controller", "->", "getBlockTypeFeatureObjects", "(", ")", ";", "if", "(", "count", "(", "$", "features", ")", ">", "0", ")", "{", "foreach", "(", "$", "features", "as", "$", "fe", ")", "{", "$", "fd", "=", "$", "fe", "->", "getFeatureDetailObject", "(", "$", "controller", ")", ";", "$", "fa", "=", "CollectionVersionFeatureAssignment", "::", "add", "(", "$", "fe", ",", "$", "fd", ",", "$", "this", ")", ";", "$", "db", "->", "Execute", "(", "'insert into BlockFeatureAssignments (cID, cvID, bID, faID) values (?, ?, ?, ?)'", ",", "[", "$", "this", "->", "getCollectionID", "(", ")", ",", "$", "this", "->", "getVersionID", "(", ")", ",", "$", "nb", "->", "getBlockID", "(", ")", ",", "$", "fa", "->", "getFeatureAssignmentID", "(", ")", ",", "]", ")", ";", "}", "}", "return", "Block", "::", "getByID", "(", "$", "nb", "->", "getBlockID", "(", ")", ",", "$", "this", ",", "$", "a", ")", ";", "}" ]
Add a new block to a specific area of the currently loaded collection version. @param \Concrete\Core\Entity\Block\BlockType\BlockType $bt the type of block to be added @param string|\Concrete\Core\Area\Area $a the area instance (or its handle) to which the block should be added to @param array $data The data of the block. This data depends on the specific block type. Common values are: 'uID' to specify the ID of the author (if not specified: we'll use the current user), 'bName' to specify the block name. @return \Concrete\Core\Block\Block
[ "Add", "a", "new", "block", "to", "a", "specific", "area", "of", "the", "currently", "loaded", "collection", "version", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Collection.php#L962-L1027
train
concrete5/concrete5
concrete/src/Page/Collection/Collection.php
Collection.addFeature
public function addFeature(Feature $fe) { $db = Loader::db(); $db->Replace( 'CollectionVersionFeatures', ['cID' => $this->getCollectionID(), 'cvID' => $this->getVersionID(), 'feID' => $fe->getFeatureID()], ['cID', 'cvID', 'feID'], true ); }
php
public function addFeature(Feature $fe) { $db = Loader::db(); $db->Replace( 'CollectionVersionFeatures', ['cID' => $this->getCollectionID(), 'cvID' => $this->getVersionID(), 'feID' => $fe->getFeatureID()], ['cID', 'cvID', 'feID'], true ); }
[ "public", "function", "addFeature", "(", "Feature", "$", "fe", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "db", "->", "Replace", "(", "'CollectionVersionFeatures'", ",", "[", "'cID'", "=>", "$", "this", "->", "getCollectionID", "(", ")", ",", "'cvID'", "=>", "$", "this", "->", "getVersionID", "(", ")", ",", "'feID'", "=>", "$", "fe", "->", "getFeatureID", "(", ")", "]", ",", "[", "'cID'", ",", "'cvID'", ",", "'feID'", "]", ",", "true", ")", ";", "}" ]
Associate a feature to the currently loaded collection version. @param Feature $fe
[ "Associate", "a", "feature", "to", "the", "currently", "loaded", "collection", "version", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Collection.php#L1101-L1110
train
concrete5/concrete5
concrete/src/Page/Collection/Collection.php
Collection.delete
public function delete() { if ($this->cID > 0) { $db = Loader::db(); // First we delete all versions $vl = new VersionList($this); $vl->setItemsPerPage(-1); $vlArray = $vl->getPage(); foreach ($vlArray as $v) { $v->delete(); } $cID = $this->getCollectionID(); $q = "delete from CollectionAttributeValues where cID = {$cID}"; $db->query($q); $q = "delete from Collections where cID = '{$cID}'"; $r = $db->query($q); try { $q = "delete from CollectionSearchIndexAttributes where cID = {$cID}"; $db->query($q); } catch (\Exception $e) { } } }
php
public function delete() { if ($this->cID > 0) { $db = Loader::db(); // First we delete all versions $vl = new VersionList($this); $vl->setItemsPerPage(-1); $vlArray = $vl->getPage(); foreach ($vlArray as $v) { $v->delete(); } $cID = $this->getCollectionID(); $q = "delete from CollectionAttributeValues where cID = {$cID}"; $db->query($q); $q = "delete from Collections where cID = '{$cID}'"; $r = $db->query($q); try { $q = "delete from CollectionSearchIndexAttributes where cID = {$cID}"; $db->query($q); } catch (\Exception $e) { } } }
[ "public", "function", "delete", "(", ")", "{", "if", "(", "$", "this", "->", "cID", ">", "0", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "// First we delete all versions", "$", "vl", "=", "new", "VersionList", "(", "$", "this", ")", ";", "$", "vl", "->", "setItemsPerPage", "(", "-", "1", ")", ";", "$", "vlArray", "=", "$", "vl", "->", "getPage", "(", ")", ";", "foreach", "(", "$", "vlArray", "as", "$", "v", ")", "{", "$", "v", "->", "delete", "(", ")", ";", "}", "$", "cID", "=", "$", "this", "->", "getCollectionID", "(", ")", ";", "$", "q", "=", "\"delete from CollectionAttributeValues where cID = {$cID}\"", ";", "$", "db", "->", "query", "(", "$", "q", ")", ";", "$", "q", "=", "\"delete from Collections where cID = '{$cID}'\"", ";", "$", "r", "=", "$", "db", "->", "query", "(", "$", "q", ")", ";", "try", "{", "$", "q", "=", "\"delete from CollectionSearchIndexAttributes where cID = {$cID}\"", ";", "$", "db", "->", "query", "(", "$", "q", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "}", "}", "}" ]
Delete this collection, and all its versions, contents and attributes.
[ "Delete", "this", "collection", "and", "all", "its", "versions", "contents", "and", "attributes", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Collection.php#L1145-L1173
train
concrete5/concrete5
concrete/src/Page/Collection/Collection.php
Collection.duplicateCollection
public function duplicateCollection() { $app = Application::getFacadeApplication(); $cloner = $app->make(Cloner::class); $clonerOptions = $app->build(ClonerOptions::class)->setKeepOriginalAuthor(true); $newCollection = $cloner->cloneCollection($this, $clonerOptions); return $newCollection; }
php
public function duplicateCollection() { $app = Application::getFacadeApplication(); $cloner = $app->make(Cloner::class); $clonerOptions = $app->build(ClonerOptions::class)->setKeepOriginalAuthor(true); $newCollection = $cloner->cloneCollection($this, $clonerOptions); return $newCollection; }
[ "public", "function", "duplicateCollection", "(", ")", "{", "$", "app", "=", "Application", "::", "getFacadeApplication", "(", ")", ";", "$", "cloner", "=", "$", "app", "->", "make", "(", "Cloner", "::", "class", ")", ";", "$", "clonerOptions", "=", "$", "app", "->", "build", "(", "ClonerOptions", "::", "class", ")", "->", "setKeepOriginalAuthor", "(", "true", ")", ";", "$", "newCollection", "=", "$", "cloner", "->", "cloneCollection", "(", "$", "this", ",", "$", "clonerOptions", ")", ";", "return", "$", "newCollection", ";", "}" ]
Create a clone of this collection, and all its versions, contents and attributes. @return \Concrete\Core\Page\Collection\Collection
[ "Create", "a", "clone", "of", "this", "collection", "and", "all", "its", "versions", "contents", "and", "attributes", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Collection.php#L1180-L1188
train
concrete5/concrete5
concrete/src/Page/Collection/Collection.php
Collection.cloneVersion
public function cloneVersion($versionComments, $createEmpty = false) { $app = Application::getFacadeApplication(); $cloner = $app->make(Cloner::class); $clonerOptions = $app->make(ClonerOptions::class) ->setVersionComments($versionComments) ->setCopyContents($createEmpty ? false : true) ; $newVersion = $cloner->cloneCollectionVersion($this->getVersionObject(), $this, $clonerOptions); return Page::getByID($newVersion->getCollectionID(), $newVersion->getVersionID()); }
php
public function cloneVersion($versionComments, $createEmpty = false) { $app = Application::getFacadeApplication(); $cloner = $app->make(Cloner::class); $clonerOptions = $app->make(ClonerOptions::class) ->setVersionComments($versionComments) ->setCopyContents($createEmpty ? false : true) ; $newVersion = $cloner->cloneCollectionVersion($this->getVersionObject(), $this, $clonerOptions); return Page::getByID($newVersion->getCollectionID(), $newVersion->getVersionID()); }
[ "public", "function", "cloneVersion", "(", "$", "versionComments", ",", "$", "createEmpty", "=", "false", ")", "{", "$", "app", "=", "Application", "::", "getFacadeApplication", "(", ")", ";", "$", "cloner", "=", "$", "app", "->", "make", "(", "Cloner", "::", "class", ")", ";", "$", "clonerOptions", "=", "$", "app", "->", "make", "(", "ClonerOptions", "::", "class", ")", "->", "setVersionComments", "(", "$", "versionComments", ")", "->", "setCopyContents", "(", "$", "createEmpty", "?", "false", ":", "true", ")", ";", "$", "newVersion", "=", "$", "cloner", "->", "cloneCollectionVersion", "(", "$", "this", "->", "getVersionObject", "(", ")", ",", "$", "this", ",", "$", "clonerOptions", ")", ";", "return", "Page", "::", "getByID", "(", "$", "newVersion", "->", "getCollectionID", "(", ")", ",", "$", "newVersion", "->", "getVersionID", "(", ")", ")", ";", "}" ]
Clone the currently loaded version and returns a Page instance containing the new version. @param string|null $versionComments the comments to be associated to the new Version @param bool $createEmpty set to true to create a Version without any blocks/area styles, false to clone them too @return \Concrete\Core\Page\Page
[ "Clone", "the", "currently", "loaded", "version", "and", "returns", "a", "Page", "instance", "containing", "the", "new", "version", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Collection.php#L1198-L1209
train
concrete5/concrete5
concrete/src/Package/Event/PackageEntities.php
PackageEntities.addEntityManager
public function addEntityManager(EntityManagerInterface $em) { if (!in_array($em, $this->entityManagers, true)) { $this->entityManagers[] = $em; } return $this; }
php
public function addEntityManager(EntityManagerInterface $em) { if (!in_array($em, $this->entityManagers, true)) { $this->entityManagers[] = $em; } return $this; }
[ "public", "function", "addEntityManager", "(", "EntityManagerInterface", "$", "em", ")", "{", "if", "(", "!", "in_array", "(", "$", "em", ",", "$", "this", "->", "entityManagers", ",", "true", ")", ")", "{", "$", "this", "->", "entityManagers", "[", "]", "=", "$", "em", ";", "}", "return", "$", "this", ";", "}" ]
Add an EntityManagerInterface instance to the list. @param EntityManagerInterface $em @return $this
[ "Add", "an", "EntityManagerInterface", "instance", "to", "the", "list", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Package/Event/PackageEntities.php#L21-L28
train
concrete5/concrete5
concrete/src/File/ValidationService.php
ValidationService.image
public function image($pathToImage) { /* compatibility if exif functions not available (--enable-exif) */ if (!function_exists('exif_imagetype')) { function exif_imagetype($filename) { if ((list($width, $height, $type, $attr) = getimagesize($filename)) !== false) { return $type; } return false; } } $val = @exif_imagetype($pathToImage); return in_array($val, array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)); }
php
public function image($pathToImage) { /* compatibility if exif functions not available (--enable-exif) */ if (!function_exists('exif_imagetype')) { function exif_imagetype($filename) { if ((list($width, $height, $type, $attr) = getimagesize($filename)) !== false) { return $type; } return false; } } $val = @exif_imagetype($pathToImage); return in_array($val, array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)); }
[ "public", "function", "image", "(", "$", "pathToImage", ")", "{", "/* compatibility if exif functions not available (--enable-exif) */", "if", "(", "!", "function_exists", "(", "'exif_imagetype'", ")", ")", "{", "function", "exif_imagetype", "(", "$", "filename", ")", "{", "if", "(", "(", "list", "(", "$", "width", ",", "$", "height", ",", "$", "type", ",", "$", "attr", ")", "=", "getimagesize", "(", "$", "filename", ")", ")", "!==", "false", ")", "{", "return", "$", "type", ";", "}", "return", "false", ";", "}", "}", "$", "val", "=", "@", "exif_imagetype", "(", "$", "pathToImage", ")", ";", "return", "in_array", "(", "$", "val", ",", "array", "(", "IMAGETYPE_GIF", ",", "IMAGETYPE_JPEG", ",", "IMAGETYPE_PNG", ")", ")", ";", "}" ]
Tests whether the passed item a valid image. @param $pathToImage @return bool
[ "Tests", "whether", "the", "passed", "item", "a", "valid", "image", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/File/ValidationService.php#L35-L53
train
concrete5/concrete5
concrete/src/File/ValidationService.php
ValidationService.extension
public function extension($filename, $extensions = null) { $f = Loader::helper('file'); $ext = strtolower($f->getExtension($filename)); if (isset($extensions) && is_array($extensions) && count($extensions)) { $allowed_extensions = $extensions; } else { // pull from constants $extensions_string = strtolower(str_replace(array("*", "."), "", Config::get('concrete.upload.extensions'))); $allowed_extensions = explode(";", $extensions_string); } return in_array($ext, $allowed_extensions); }
php
public function extension($filename, $extensions = null) { $f = Loader::helper('file'); $ext = strtolower($f->getExtension($filename)); if (isset($extensions) && is_array($extensions) && count($extensions)) { $allowed_extensions = $extensions; } else { // pull from constants $extensions_string = strtolower(str_replace(array("*", "."), "", Config::get('concrete.upload.extensions'))); $allowed_extensions = explode(";", $extensions_string); } return in_array($ext, $allowed_extensions); }
[ "public", "function", "extension", "(", "$", "filename", ",", "$", "extensions", "=", "null", ")", "{", "$", "f", "=", "Loader", "::", "helper", "(", "'file'", ")", ";", "$", "ext", "=", "strtolower", "(", "$", "f", "->", "getExtension", "(", "$", "filename", ")", ")", ";", "if", "(", "isset", "(", "$", "extensions", ")", "&&", "is_array", "(", "$", "extensions", ")", "&&", "count", "(", "$", "extensions", ")", ")", "{", "$", "allowed_extensions", "=", "$", "extensions", ";", "}", "else", "{", "// pull from constants", "$", "extensions_string", "=", "strtolower", "(", "str_replace", "(", "array", "(", "\"*\"", ",", "\".\"", ")", ",", "\"\"", ",", "Config", "::", "get", "(", "'concrete.upload.extensions'", ")", ")", ")", ";", "$", "allowed_extensions", "=", "explode", "(", "\";\"", ",", "$", "extensions_string", ")", ";", "}", "return", "in_array", "(", "$", "ext", ",", "$", "allowed_extensions", ")", ";", "}" ]
Parses the file extension for a given file name, checks it to see if it's in the the extension array if provided if not, it checks to see if it's in the concrete.upload.extensions configuration option. @param string $filename @param array $extensions @return bool
[ "Parses", "the", "file", "extension", "for", "a", "given", "file", "name", "checks", "it", "to", "see", "if", "it", "s", "in", "the", "the", "extension", "array", "if", "provided", "if", "not", "it", "checks", "to", "see", "if", "it", "s", "in", "the", "concrete", ".", "upload", ".", "extensions", "configuration", "option", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/File/ValidationService.php#L76-L88
train
concrete5/concrete5
concrete/src/Cookie/ResponseCookieJar.php
ResponseCookieJar.addCookie
public function addCookie($name, $value = null, $expire = 0, $path = '/', $domain = null, $secure = false, $httpOnly = true) { $cookie = new Cookie($name, $value, $expire, $path, $domain, $secure, $httpOnly); $this->addCookieObject($cookie); return $cookie; }
php
public function addCookie($name, $value = null, $expire = 0, $path = '/', $domain = null, $secure = false, $httpOnly = true) { $cookie = new Cookie($name, $value, $expire, $path, $domain, $secure, $httpOnly); $this->addCookieObject($cookie); return $cookie; }
[ "public", "function", "addCookie", "(", "$", "name", ",", "$", "value", "=", "null", ",", "$", "expire", "=", "0", ",", "$", "path", "=", "'/'", ",", "$", "domain", "=", "null", ",", "$", "secure", "=", "false", ",", "$", "httpOnly", "=", "true", ")", "{", "$", "cookie", "=", "new", "Cookie", "(", "$", "name", ",", "$", "value", ",", "$", "expire", ",", "$", "path", ",", "$", "domain", ",", "$", "secure", ",", "$", "httpOnly", ")", ";", "$", "this", "->", "addCookieObject", "(", "$", "cookie", ")", ";", "return", "$", "cookie", ";", "}" ]
Adds a Cookie object to the cookie pantry. @param string $name The cookie name @param string|null $value The value of the cookie @param int $expire The number of seconds until the cookie expires @param string $path The path for the cookie @param null|string $domain The domain the cookie is available to @param bool $secure whether the cookie should only be transmitted over a HTTPS connection from the client @param bool $httpOnly Whether the cookie will be made accessible only through the HTTP protocol @return \Symfony\Component\HttpFoundation\Cookie
[ "Adds", "a", "Cookie", "object", "to", "the", "cookie", "pantry", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Cookie/ResponseCookieJar.php#L36-L42
train