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/blocks/form/controller.php
Controller.view
public function view() { if ($this->viewRequiresJqueryUI()) { $this->requireAsset('jquery/ui'); } $this->requireAsset('css', 'core/frontend/errors'); if ($this->displayCaptcha) { $this->requireAsset('css', 'core/frontend/captcha'); } }
php
public function view() { if ($this->viewRequiresJqueryUI()) { $this->requireAsset('jquery/ui'); } $this->requireAsset('css', 'core/frontend/errors'); if ($this->displayCaptcha) { $this->requireAsset('css', 'core/frontend/captcha'); } }
[ "public", "function", "view", "(", ")", "{", "if", "(", "$", "this", "->", "viewRequiresJqueryUI", "(", ")", ")", "{", "$", "this", "->", "requireAsset", "(", "'jquery/ui'", ")", ";", "}", "$", "this", "->", "requireAsset", "(", "'css'", ",", "'core/frontend/errors'", ")", ";", "if", "(", "$", "this", "->", "displayCaptcha", ")", "{", "$", "this", "->", "requireAsset", "(", "'css'", ",", "'core/frontend/captcha'", ")", ";", "}", "}" ]
and we have some block record things we need to check.
[ "and", "we", "have", "some", "block", "record", "things", "we", "need", "to", "check", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/blocks/form/controller.php#L115-L124
train
concrete5/concrete5
concrete/blocks/form/controller.php
Controller.questionVersioning
protected function questionVersioning($data = []) { $data += [ 'ignoreQuestionIDs' => '', 'pendingDeleteIDs' => '', ]; $db = Database::connection(); $oldBID = intval($data['bID']); //if this block is being edited a second time, remove edited questions with the current bID that are pending replacement //if( intval($oldBID) == intval($this->bID) ){ $vals = [intval($data['oldQsID'])]; $pendingQuestions = $db->getAll('SELECT msqID FROM btFormQuestions WHERE bID=0 && questionSetId=?', $vals); foreach ($pendingQuestions as $pendingQuestion) { $vals = [intval($this->bID), intval($pendingQuestion['msqID'])]; $db->query('DELETE FROM btFormQuestions WHERE bID=? AND msqID=?', $vals); } //} //assign any new questions the new block id $vals = [intval($data['bID']), intval($data['qsID']), intval($data['oldQsID'])]; $rs = $db->query('UPDATE btFormQuestions SET bID=?, questionSetId=? WHERE bID=0 && questionSetId=?', $vals); //These are deleted or edited questions. (edited questions have already been created with the new bID). $ignoreQuestionIDsDirty = explode(',', $data['ignoreQuestionIDs']); $ignoreQuestionIDs = [0]; foreach ($ignoreQuestionIDsDirty as $msqID) { $ignoreQuestionIDs[] = intval($msqID); } $ignoreQuestionIDstr = implode(',', $ignoreQuestionIDs); //remove any questions that are pending deletion, that already have this current bID $pendingDeleteQIDsDirty = explode(',', $data['pendingDeleteIDs']); $pendingDeleteQIDs = []; foreach ($pendingDeleteQIDsDirty as $msqID) { $pendingDeleteQIDs[] = intval($msqID); } $vals = [$this->bID, intval($data['qsID'])]; $pendingDeleteQIDs = implode(',', $pendingDeleteQIDs); $unchangedQuestions = $db->query('DELETE FROM btFormQuestions WHERE bID=? AND questionSetId=? AND msqID IN (' . $pendingDeleteQIDs . ')', $vals); }
php
protected function questionVersioning($data = []) { $data += [ 'ignoreQuestionIDs' => '', 'pendingDeleteIDs' => '', ]; $db = Database::connection(); $oldBID = intval($data['bID']); //if this block is being edited a second time, remove edited questions with the current bID that are pending replacement //if( intval($oldBID) == intval($this->bID) ){ $vals = [intval($data['oldQsID'])]; $pendingQuestions = $db->getAll('SELECT msqID FROM btFormQuestions WHERE bID=0 && questionSetId=?', $vals); foreach ($pendingQuestions as $pendingQuestion) { $vals = [intval($this->bID), intval($pendingQuestion['msqID'])]; $db->query('DELETE FROM btFormQuestions WHERE bID=? AND msqID=?', $vals); } //} //assign any new questions the new block id $vals = [intval($data['bID']), intval($data['qsID']), intval($data['oldQsID'])]; $rs = $db->query('UPDATE btFormQuestions SET bID=?, questionSetId=? WHERE bID=0 && questionSetId=?', $vals); //These are deleted or edited questions. (edited questions have already been created with the new bID). $ignoreQuestionIDsDirty = explode(',', $data['ignoreQuestionIDs']); $ignoreQuestionIDs = [0]; foreach ($ignoreQuestionIDsDirty as $msqID) { $ignoreQuestionIDs[] = intval($msqID); } $ignoreQuestionIDstr = implode(',', $ignoreQuestionIDs); //remove any questions that are pending deletion, that already have this current bID $pendingDeleteQIDsDirty = explode(',', $data['pendingDeleteIDs']); $pendingDeleteQIDs = []; foreach ($pendingDeleteQIDsDirty as $msqID) { $pendingDeleteQIDs[] = intval($msqID); } $vals = [$this->bID, intval($data['qsID'])]; $pendingDeleteQIDs = implode(',', $pendingDeleteQIDs); $unchangedQuestions = $db->query('DELETE FROM btFormQuestions WHERE bID=? AND questionSetId=? AND msqID IN (' . $pendingDeleteQIDs . ')', $vals); }
[ "protected", "function", "questionVersioning", "(", "$", "data", "=", "[", "]", ")", "{", "$", "data", "+=", "[", "'ignoreQuestionIDs'", "=>", "''", ",", "'pendingDeleteIDs'", "=>", "''", ",", "]", ";", "$", "db", "=", "Database", "::", "connection", "(", ")", ";", "$", "oldBID", "=", "intval", "(", "$", "data", "[", "'bID'", "]", ")", ";", "//if this block is being edited a second time, remove edited questions with the current bID that are pending replacement", "//if( intval($oldBID) == intval($this->bID) ){", "$", "vals", "=", "[", "intval", "(", "$", "data", "[", "'oldQsID'", "]", ")", "]", ";", "$", "pendingQuestions", "=", "$", "db", "->", "getAll", "(", "'SELECT msqID FROM btFormQuestions WHERE bID=0 && questionSetId=?'", ",", "$", "vals", ")", ";", "foreach", "(", "$", "pendingQuestions", "as", "$", "pendingQuestion", ")", "{", "$", "vals", "=", "[", "intval", "(", "$", "this", "->", "bID", ")", ",", "intval", "(", "$", "pendingQuestion", "[", "'msqID'", "]", ")", "]", ";", "$", "db", "->", "query", "(", "'DELETE FROM btFormQuestions WHERE bID=? AND msqID=?'", ",", "$", "vals", ")", ";", "}", "//}", "//assign any new questions the new block id", "$", "vals", "=", "[", "intval", "(", "$", "data", "[", "'bID'", "]", ")", ",", "intval", "(", "$", "data", "[", "'qsID'", "]", ")", ",", "intval", "(", "$", "data", "[", "'oldQsID'", "]", ")", "]", ";", "$", "rs", "=", "$", "db", "->", "query", "(", "'UPDATE btFormQuestions SET bID=?, questionSetId=? WHERE bID=0 && questionSetId=?'", ",", "$", "vals", ")", ";", "//These are deleted or edited questions. (edited questions have already been created with the new bID).", "$", "ignoreQuestionIDsDirty", "=", "explode", "(", "','", ",", "$", "data", "[", "'ignoreQuestionIDs'", "]", ")", ";", "$", "ignoreQuestionIDs", "=", "[", "0", "]", ";", "foreach", "(", "$", "ignoreQuestionIDsDirty", "as", "$", "msqID", ")", "{", "$", "ignoreQuestionIDs", "[", "]", "=", "intval", "(", "$", "msqID", ")", ";", "}", "$", "ignoreQuestionIDstr", "=", "implode", "(", "','", ",", "$", "ignoreQuestionIDs", ")", ";", "//remove any questions that are pending deletion, that already have this current bID", "$", "pendingDeleteQIDsDirty", "=", "explode", "(", "','", ",", "$", "data", "[", "'pendingDeleteIDs'", "]", ")", ";", "$", "pendingDeleteQIDs", "=", "[", "]", ";", "foreach", "(", "$", "pendingDeleteQIDsDirty", "as", "$", "msqID", ")", "{", "$", "pendingDeleteQIDs", "[", "]", "=", "intval", "(", "$", "msqID", ")", ";", "}", "$", "vals", "=", "[", "$", "this", "->", "bID", ",", "intval", "(", "$", "data", "[", "'qsID'", "]", ")", "]", ";", "$", "pendingDeleteQIDs", "=", "implode", "(", "','", ",", "$", "pendingDeleteQIDs", ")", ";", "$", "unchangedQuestions", "=", "$", "db", "->", "query", "(", "'DELETE FROM btFormQuestions WHERE bID=? AND questionSetId=? AND msqID IN ('", ".", "$", "pendingDeleteQIDs", ".", "')'", ",", "$", "vals", ")", ";", "}" ]
Ties the new or edited questions to the new block number. New and edited questions are temporarily given bID=0, until the block is saved... painfully complicated. @param array $data
[ "Ties", "the", "new", "or", "edited", "questions", "to", "the", "new", "block", "number", ".", "New", "and", "edited", "questions", "are", "temporarily", "given", "bID", "=", "0", "until", "the", "block", "is", "saved", "...", "painfully", "complicated", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/blocks/form/controller.php#L241-L281
train
concrete5/concrete5
concrete/src/Page/Statistics.php
Statistics.incrementParents
public static function incrementParents($cID) { $db = Loader::db(); $cParentID = $db->GetOne("select cParentID from Pages where cID = ?", array($cID)); $q = "update Pages set cChildren = cChildren+1 where cID = ?"; $cpc = Page::getByID($cParentID); $cpc->refreshCache(); $r = $db->query($q, array($cParentID)); }
php
public static function incrementParents($cID) { $db = Loader::db(); $cParentID = $db->GetOne("select cParentID from Pages where cID = ?", array($cID)); $q = "update Pages set cChildren = cChildren+1 where cID = ?"; $cpc = Page::getByID($cParentID); $cpc->refreshCache(); $r = $db->query($q, array($cParentID)); }
[ "public", "static", "function", "incrementParents", "(", "$", "cID", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "cParentID", "=", "$", "db", "->", "GetOne", "(", "\"select cParentID from Pages where cID = ?\"", ",", "array", "(", "$", "cID", ")", ")", ";", "$", "q", "=", "\"update Pages set cChildren = cChildren+1 where cID = ?\"", ";", "$", "cpc", "=", "Page", "::", "getByID", "(", "$", "cParentID", ")", ";", "$", "cpc", "->", "refreshCache", "(", ")", ";", "$", "r", "=", "$", "db", "->", "query", "(", "$", "q", ",", "array", "(", "$", "cParentID", ")", ")", ";", "}" ]
For a particular page ID, grabs all the pages of this page, and increments the cTotalChildren number for them.
[ "For", "a", "particular", "page", "ID", "grabs", "all", "the", "pages", "of", "this", "page", "and", "increments", "the", "cTotalChildren", "number", "for", "them", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Statistics.php#L47-L58
train
concrete5/concrete5
concrete/src/Page/Statistics.php
Statistics.decrementParents
public static function decrementParents($cID) { $db = Loader::db(); $cParentID = $db->GetOne("select cParentID from Pages where cID = ?", array($cID)); $cChildren = $db->GetOne("select cChildren from Pages where cID = ?", array($cParentID)); --$cChildren; if ($cChildren < 0) { $cChildren = 0; } $q = "update Pages set cChildren = ? where cID = ?"; $cpc = Page::getByID($cParentID); $cpc->refreshCache(); $r = $db->query($q, array($cChildren, $cParentID)); }
php
public static function decrementParents($cID) { $db = Loader::db(); $cParentID = $db->GetOne("select cParentID from Pages where cID = ?", array($cID)); $cChildren = $db->GetOne("select cChildren from Pages where cID = ?", array($cParentID)); --$cChildren; if ($cChildren < 0) { $cChildren = 0; } $q = "update Pages set cChildren = ? where cID = ?"; $cpc = Page::getByID($cParentID); $cpc->refreshCache(); $r = $db->query($q, array($cChildren, $cParentID)); }
[ "public", "static", "function", "decrementParents", "(", "$", "cID", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "cParentID", "=", "$", "db", "->", "GetOne", "(", "\"select cParentID from Pages where cID = ?\"", ",", "array", "(", "$", "cID", ")", ")", ";", "$", "cChildren", "=", "$", "db", "->", "GetOne", "(", "\"select cChildren from Pages where cID = ?\"", ",", "array", "(", "$", "cParentID", ")", ")", ";", "--", "$", "cChildren", ";", "if", "(", "$", "cChildren", "<", "0", ")", "{", "$", "cChildren", "=", "0", ";", "}", "$", "q", "=", "\"update Pages set cChildren = ? where cID = ?\"", ";", "$", "cpc", "=", "Page", "::", "getByID", "(", "$", "cParentID", ")", ";", "$", "cpc", "->", "refreshCache", "(", ")", ";", "$", "r", "=", "$", "db", "->", "query", "(", "$", "q", ",", "array", "(", "$", "cChildren", ",", "$", "cParentID", ")", ")", ";", "}" ]
For a particular page ID, grabs all the pages of this page, and decrements the cTotalChildren number for them.
[ "For", "a", "particular", "page", "ID", "grabs", "all", "the", "pages", "of", "this", "page", "and", "decrements", "the", "cTotalChildren", "number", "for", "them", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Statistics.php#L63-L79
train
concrete5/concrete5
concrete/src/Page/Statistics.php
Statistics.getTotalPagesCreated
public static function getTotalPagesCreated($date) { $db = Loader::db(); $num = $db->GetOne('select count(Pages.cID) from Pages inner join Collections on Pages.cID = Collections.cID where cDateAdded >= ? and cDateAdded <= ? and siteTreeID > 0 and cIsTemplate = 0', array($date . ' 00:00:00', $date . ' 23:59:59')); return $num; }
php
public static function getTotalPagesCreated($date) { $db = Loader::db(); $num = $db->GetOne('select count(Pages.cID) from Pages inner join Collections on Pages.cID = Collections.cID where cDateAdded >= ? and cDateAdded <= ? and siteTreeID > 0 and cIsTemplate = 0', array($date . ' 00:00:00', $date . ' 23:59:59')); return $num; }
[ "public", "static", "function", "getTotalPagesCreated", "(", "$", "date", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "num", "=", "$", "db", "->", "GetOne", "(", "'select count(Pages.cID) from Pages inner join Collections on Pages.cID = Collections.cID where cDateAdded >= ? and cDateAdded <= ? and siteTreeID > 0 and cIsTemplate = 0'", ",", "array", "(", "$", "date", ".", "' 00:00:00'", ",", "$", "date", ".", "' 23:59:59'", ")", ")", ";", "return", "$", "num", ";", "}" ]
Returns the total number of pages created for a given date.
[ "Returns", "the", "total", "number", "of", "pages", "created", "for", "a", "given", "date", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Statistics.php#L84-L90
train
concrete5/concrete5
concrete/src/Entity/Geolocator.php
Geolocator.create
public static function create($handle, $name, Package $package = null) { $result = new static(); $result ->setGeolocatorHandle($handle) ->setGeolocatorName($name) ->setGeolocatorDescription('') ->setGeolocatorConfiguration([]) ->setGeolocatorPackage($package) ->setIsActive(false) ; return $result; }
php
public static function create($handle, $name, Package $package = null) { $result = new static(); $result ->setGeolocatorHandle($handle) ->setGeolocatorName($name) ->setGeolocatorDescription('') ->setGeolocatorConfiguration([]) ->setGeolocatorPackage($package) ->setIsActive(false) ; return $result; }
[ "public", "static", "function", "create", "(", "$", "handle", ",", "$", "name", ",", "Package", "$", "package", "=", "null", ")", "{", "$", "result", "=", "new", "static", "(", ")", ";", "$", "result", "->", "setGeolocatorHandle", "(", "$", "handle", ")", "->", "setGeolocatorName", "(", "$", "name", ")", "->", "setGeolocatorDescription", "(", "''", ")", "->", "setGeolocatorConfiguration", "(", "[", "]", ")", "->", "setGeolocatorPackage", "(", "$", "package", ")", "->", "setIsActive", "(", "false", ")", ";", "return", "$", "result", ";", "}" ]
Create a new Geolocator instance.
[ "Create", "a", "new", "Geolocator", "instance", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/Geolocator.php#L22-L35
train
concrete5/concrete5
concrete/src/Entity/Geolocator.php
Geolocator.getGeolocatorDisplayName
public function getGeolocatorDisplayName($format = 'html') { $value = tc('GeolocatorName', $this->getGeolocatorName()); switch ($format) { case 'html': return h($value); case 'text': default: return $value; } }
php
public function getGeolocatorDisplayName($format = 'html') { $value = tc('GeolocatorName', $this->getGeolocatorName()); switch ($format) { case 'html': return h($value); case 'text': default: return $value; } }
[ "public", "function", "getGeolocatorDisplayName", "(", "$", "format", "=", "'html'", ")", "{", "$", "value", "=", "tc", "(", "'GeolocatorName'", ",", "$", "this", "->", "getGeolocatorName", "(", ")", ")", ";", "switch", "(", "$", "format", ")", "{", "case", "'html'", ":", "return", "h", "(", "$", "value", ")", ";", "case", "'text'", ":", "default", ":", "return", "$", "value", ";", "}", "}" ]
Get the Geolocator display name. @param string $format = 'html' Escape the result in html format (if $format is 'html'). If $format is 'text' or any other value, the display name won't be escaped. @return string
[ "Get", "the", "Geolocator", "display", "name", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/Geolocator.php#L124-L134
train
concrete5/concrete5
concrete/src/Entity/Geolocator.php
Geolocator.getGeolocatorDisplayDescription
public function getGeolocatorDisplayDescription($format = 'html') { $value = tc('GeolocatorDescription', $this->getGeolocatorDescription()); switch ($format) { case 'html': return nl2br(h($value)); case 'text': default: return $value; } }
php
public function getGeolocatorDisplayDescription($format = 'html') { $value = tc('GeolocatorDescription', $this->getGeolocatorDescription()); switch ($format) { case 'html': return nl2br(h($value)); case 'text': default: return $value; } }
[ "public", "function", "getGeolocatorDisplayDescription", "(", "$", "format", "=", "'html'", ")", "{", "$", "value", "=", "tc", "(", "'GeolocatorDescription'", ",", "$", "this", "->", "getGeolocatorDescription", "(", ")", ")", ";", "switch", "(", "$", "format", ")", "{", "case", "'html'", ":", "return", "nl2br", "(", "h", "(", "$", "value", ")", ")", ";", "case", "'text'", ":", "default", ":", "return", "$", "value", ";", "}", "}" ]
Get the Geolocator display description. @param string $format = 'html' Escape the result in html format (if $format is 'html'). If $format is 'text' or any other value, the display description won't be escaped. @return string
[ "Get", "the", "Geolocator", "display", "description", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/Geolocator.php#L176-L186
train
concrete5/concrete5
concrete/src/Entity/Express/Entry.php
Entry.getEntryAssociation
public function getEntryAssociation(Association $association) { $id = $association->getId(); /** * @var EntryAssociation $entryAssociation */ foreach ($this->associations as $entryAssociation) { if ($entryAssociation->getAssociation()->getId() === $id) { return $entryAssociation; } } return null; }
php
public function getEntryAssociation(Association $association) { $id = $association->getId(); /** * @var EntryAssociation $entryAssociation */ foreach ($this->associations as $entryAssociation) { if ($entryAssociation->getAssociation()->getId() === $id) { return $entryAssociation; } } return null; }
[ "public", "function", "getEntryAssociation", "(", "Association", "$", "association", ")", "{", "$", "id", "=", "$", "association", "->", "getId", "(", ")", ";", "/**\n * @var EntryAssociation $entryAssociation\n */", "foreach", "(", "$", "this", "->", "associations", "as", "$", "entryAssociation", ")", "{", "if", "(", "$", "entryAssociation", "->", "getAssociation", "(", ")", "->", "getId", "(", ")", "===", "$", "id", ")", "{", "return", "$", "entryAssociation", ";", "}", "}", "return", "null", ";", "}" ]
Get the EntryAssociation for a given association. @param \Concrete\Core\Entity\Express\Association $association @return \Concrete\Core\Entity\Express\Entry\Association|null
[ "Get", "the", "EntryAssociation", "for", "a", "given", "association", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/Express/Entry.php#L312-L326
train
concrete5/concrete5
concrete/src/StyleCustomizer/Style/Style.php
Style.getFormElementPath
public function getFormElementPath() { $className = implode('', array_slice(explode('\\', get_called_class()), -1)); $segment = substr($className, 0, strpos($className, 'Style')); $element = uncamelcase($segment); $env = Environment::get(); return $env->getPath(DIRNAME_ELEMENTS . '/' . DIRNAME_STYLE_CUSTOMIZER . '/' . DIRNAME_STYLE_CUSTOMIZER_TYPES . '/' . $element . '.php'); }
php
public function getFormElementPath() { $className = implode('', array_slice(explode('\\', get_called_class()), -1)); $segment = substr($className, 0, strpos($className, 'Style')); $element = uncamelcase($segment); $env = Environment::get(); return $env->getPath(DIRNAME_ELEMENTS . '/' . DIRNAME_STYLE_CUSTOMIZER . '/' . DIRNAME_STYLE_CUSTOMIZER_TYPES . '/' . $element . '.php'); }
[ "public", "function", "getFormElementPath", "(", ")", "{", "$", "className", "=", "implode", "(", "''", ",", "array_slice", "(", "explode", "(", "'\\\\'", ",", "get_called_class", "(", ")", ")", ",", "-", "1", ")", ")", ";", "$", "segment", "=", "substr", "(", "$", "className", ",", "0", ",", "strpos", "(", "$", "className", ",", "'Style'", ")", ")", ";", "$", "element", "=", "uncamelcase", "(", "$", "segment", ")", ";", "$", "env", "=", "Environment", "::", "get", "(", ")", ";", "return", "$", "env", "->", "getPath", "(", "DIRNAME_ELEMENTS", ".", "'/'", ".", "DIRNAME_STYLE_CUSTOMIZER", ".", "'/'", ".", "DIRNAME_STYLE_CUSTOMIZER_TYPES", ".", "'/'", ".", "$", "element", ".", "'.php'", ")", ";", "}" ]
Returns a path to an elements directory for this Style. Might not be used by all styles. @return string
[ "Returns", "a", "path", "to", "an", "elements", "directory", "for", "this", "Style", ".", "Might", "not", "be", "used", "by", "all", "styles", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/StyleCustomizer/Style/Style.php#L85-L93
train
concrete5/concrete5
concrete/src/Calendar/Event/EventOccurrenceService.php
EventOccurrenceService.getByOccurrenceID
public function getByOccurrenceID($occurrenceID, $retrieveVersion = EventService::EVENT_VERSION_APPROVED) { if ($retrieveVersion == EventService::EVENT_VERSION_RECENT) { $query = $this->entityManager->createQuery('select vo from calendar:CalendarEventVersionOccurrence vo JOIN vo.version v JOIN vo.occurrence o where o.occurrenceID = :occurrenceID order by v.evDateAdded DESC'); } else { $query = $this->entityManager->createQuery('select vo from calendar:CalendarEventVersionOccurrence vo JOIN vo.version v JOIN vo.occurrence o where o.occurrenceID = :occurrenceID and v.evIsApproved = 1'); } $query->setMaxResults(1); $query->setParameter('occurrenceID', $occurrenceID); $object = $query->getOneOrNullResult(); return $object; }
php
public function getByOccurrenceID($occurrenceID, $retrieveVersion = EventService::EVENT_VERSION_APPROVED) { if ($retrieveVersion == EventService::EVENT_VERSION_RECENT) { $query = $this->entityManager->createQuery('select vo from calendar:CalendarEventVersionOccurrence vo JOIN vo.version v JOIN vo.occurrence o where o.occurrenceID = :occurrenceID order by v.evDateAdded DESC'); } else { $query = $this->entityManager->createQuery('select vo from calendar:CalendarEventVersionOccurrence vo JOIN vo.version v JOIN vo.occurrence o where o.occurrenceID = :occurrenceID and v.evIsApproved = 1'); } $query->setMaxResults(1); $query->setParameter('occurrenceID', $occurrenceID); $object = $query->getOneOrNullResult(); return $object; }
[ "public", "function", "getByOccurrenceID", "(", "$", "occurrenceID", ",", "$", "retrieveVersion", "=", "EventService", "::", "EVENT_VERSION_APPROVED", ")", "{", "if", "(", "$", "retrieveVersion", "==", "EventService", "::", "EVENT_VERSION_RECENT", ")", "{", "$", "query", "=", "$", "this", "->", "entityManager", "->", "createQuery", "(", "'select vo from calendar:CalendarEventVersionOccurrence vo JOIN\n vo.version v JOIN vo.occurrence o where o.occurrenceID = :occurrenceID order by v.evDateAdded DESC'", ")", ";", "}", "else", "{", "$", "query", "=", "$", "this", "->", "entityManager", "->", "createQuery", "(", "'select vo from calendar:CalendarEventVersionOccurrence vo JOIN\n vo.version v JOIN vo.occurrence o where o.occurrenceID = :occurrenceID and v.evIsApproved = 1'", ")", ";", "}", "$", "query", "->", "setMaxResults", "(", "1", ")", ";", "$", "query", "->", "setParameter", "(", "'occurrenceID'", ",", "$", "occurrenceID", ")", ";", "$", "object", "=", "$", "query", "->", "getOneOrNullResult", "(", ")", ";", "return", "$", "object", ";", "}" ]
This code below retrieves based on the occurrence ID which can remain the same across versions.
[ "This", "code", "below", "retrieves", "based", "on", "the", "occurrence", "ID", "which", "can", "remain", "the", "same", "across", "versions", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Calendar/Event/EventOccurrenceService.php#L31-L44
train
concrete5/concrete5
concrete/src/Html/Service/Html.php
Html.noFollowHref
public function noFollowHref($input) { return preg_replace_callback( '/(?:<a(.*?href.*?)>)/i', function ($matches) { if (strpos($matches[1], 'rel="nofollow"') === false) { //if there is no nofollow add it return '<a' . $matches[1] . ' rel="nofollow">'; } else { //if there is already a nofollow take no action return $matches[0]; } }, $input ); }
php
public function noFollowHref($input) { return preg_replace_callback( '/(?:<a(.*?href.*?)>)/i', function ($matches) { if (strpos($matches[1], 'rel="nofollow"') === false) { //if there is no nofollow add it return '<a' . $matches[1] . ' rel="nofollow">'; } else { //if there is already a nofollow take no action return $matches[0]; } }, $input ); }
[ "public", "function", "noFollowHref", "(", "$", "input", ")", "{", "return", "preg_replace_callback", "(", "'/(?:<a(.*?href.*?)>)/i'", ",", "function", "(", "$", "matches", ")", "{", "if", "(", "strpos", "(", "$", "matches", "[", "1", "]", ",", "'rel=\"nofollow\"'", ")", "===", "false", ")", "{", "//if there is no nofollow add it", "return", "'<a'", ".", "$", "matches", "[", "1", "]", ".", "' rel=\"nofollow\">'", ";", "}", "else", "{", "//if there is already a nofollow take no action", "return", "$", "matches", "[", "0", "]", ";", "}", "}", ",", "$", "input", ")", ";", "}" ]
Takes in a string, and adds rel="nofollow" to any a tags that contain an href attribute. @param string $input @return string
[ "Takes", "in", "a", "string", "and", "adds", "rel", "=", "nofollow", "to", "any", "a", "tags", "that", "contain", "an", "href", "attribute", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Html/Service/Html.php#L158-L173
train
concrete5/concrete5
concrete/src/Entity/OAuth/ScopeRepository.php
ScopeRepository.finalizeScopes
public function finalizeScopes( array $scopes, $grantType, ClientEntityInterface $clientEntity, $userIdentifier = null ) { $app = Facade::getFacadeApplication(); $allowedScopes = $app->make('config')->get('app.api.scopes'); $winnowed = []; foreach ($scopes as $scope) { if (in_array($scope->getIdentifier(), $allowedScopes)) { $winnowed[] = $scope; } } return $winnowed; }
php
public function finalizeScopes( array $scopes, $grantType, ClientEntityInterface $clientEntity, $userIdentifier = null ) { $app = Facade::getFacadeApplication(); $allowedScopes = $app->make('config')->get('app.api.scopes'); $winnowed = []; foreach ($scopes as $scope) { if (in_array($scope->getIdentifier(), $allowedScopes)) { $winnowed[] = $scope; } } return $winnowed; }
[ "public", "function", "finalizeScopes", "(", "array", "$", "scopes", ",", "$", "grantType", ",", "ClientEntityInterface", "$", "clientEntity", ",", "$", "userIdentifier", "=", "null", ")", "{", "$", "app", "=", "Facade", "::", "getFacadeApplication", "(", ")", ";", "$", "allowedScopes", "=", "$", "app", "->", "make", "(", "'config'", ")", "->", "get", "(", "'app.api.scopes'", ")", ";", "$", "winnowed", "=", "[", "]", ";", "foreach", "(", "$", "scopes", "as", "$", "scope", ")", "{", "if", "(", "in_array", "(", "$", "scope", "->", "getIdentifier", "(", ")", ",", "$", "allowedScopes", ")", ")", "{", "$", "winnowed", "[", "]", "=", "$", "scope", ";", "}", "}", "return", "$", "winnowed", ";", "}" ]
Given a client, grant type and optional user identifier validate the set of scopes requested are valid and optionally append additional scopes or remove requested scopes. @param ScopeEntityInterface[] $scopes @param string $grantType @param ClientEntityInterface $clientEntity @param null|string $userIdentifier @return ScopeEntityInterface[]
[ "Given", "a", "client", "grant", "type", "and", "optional", "user", "identifier", "validate", "the", "set", "of", "scopes", "requested", "are", "valid", "and", "optionally", "append", "additional", "scopes", "or", "remove", "requested", "scopes", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/OAuth/ScopeRepository.php#L37-L53
train
concrete5/concrete5
concrete/src/Console/ServiceProvider.php
ServiceProvider.add
private function add($param, $requireInstall = false, callable $callback = null) { // Handle array input if (is_array($param)) { foreach ($param as $item) { $this->add($item, $requireInstall, $callback); } return null; } // If we're not installed, only register commands that are marked to handle that if ($requireInstall && !$this->installed()) { return null; } // Inflate the passed command $command = is_string($param) ? $this->app->make($param) : $param; // Make sure we have a command instance if (!$command || !$command instanceof SymfonyCommand) { throw new \InvalidArgumentException('Invalid command provided.'); } // Handle callback function if ($callback) { $command = $callback($command); if (!$command) { return null; } } // Add the cli command return $this->cli->add($command); }
php
private function add($param, $requireInstall = false, callable $callback = null) { // Handle array input if (is_array($param)) { foreach ($param as $item) { $this->add($item, $requireInstall, $callback); } return null; } // If we're not installed, only register commands that are marked to handle that if ($requireInstall && !$this->installed()) { return null; } // Inflate the passed command $command = is_string($param) ? $this->app->make($param) : $param; // Make sure we have a command instance if (!$command || !$command instanceof SymfonyCommand) { throw new \InvalidArgumentException('Invalid command provided.'); } // Handle callback function if ($callback) { $command = $callback($command); if (!$command) { return null; } } // Add the cli command return $this->cli->add($command); }
[ "private", "function", "add", "(", "$", "param", ",", "$", "requireInstall", "=", "false", ",", "callable", "$", "callback", "=", "null", ")", "{", "// Handle array input", "if", "(", "is_array", "(", "$", "param", ")", ")", "{", "foreach", "(", "$", "param", "as", "$", "item", ")", "{", "$", "this", "->", "add", "(", "$", "item", ",", "$", "requireInstall", ",", "$", "callback", ")", ";", "}", "return", "null", ";", "}", "// If we're not installed, only register commands that are marked to handle that", "if", "(", "$", "requireInstall", "&&", "!", "$", "this", "->", "installed", "(", ")", ")", "{", "return", "null", ";", "}", "// Inflate the passed command", "$", "command", "=", "is_string", "(", "$", "param", ")", "?", "$", "this", "->", "app", "->", "make", "(", "$", "param", ")", ":", "$", "param", ";", "// Make sure we have a command instance", "if", "(", "!", "$", "command", "||", "!", "$", "command", "instanceof", "SymfonyCommand", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid command provided.'", ")", ";", "}", "// Handle callback function", "if", "(", "$", "callback", ")", "{", "$", "command", "=", "$", "callback", "(", "$", "command", ")", ";", "if", "(", "!", "$", "command", ")", "{", "return", "null", ";", "}", "}", "// Add the cli command", "return", "$", "this", "->", "cli", "->", "add", "(", "$", "command", ")", ";", "}" ]
Add a class to the CLI application @param $param @return null|\Symfony\Component\Console\Command\Command
[ "Add", "a", "class", "to", "the", "CLI", "application" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Console/ServiceProvider.php#L138-L173
train
concrete5/concrete5
concrete/src/Console/ServiceProvider.php
ServiceProvider.installed
private function installed() { if ($this->installed === null) { $this->installed = $this->app->isInstalled(); } return $this->installed; }
php
private function installed() { if ($this->installed === null) { $this->installed = $this->app->isInstalled(); } return $this->installed; }
[ "private", "function", "installed", "(", ")", "{", "if", "(", "$", "this", "->", "installed", "===", "null", ")", "{", "$", "this", "->", "installed", "=", "$", "this", "->", "app", "->", "isInstalled", "(", ")", ";", "}", "return", "$", "this", "->", "installed", ";", "}" ]
Determine if the app is currently installed @return bool
[ "Determine", "if", "the", "app", "is", "currently", "installed" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Console/ServiceProvider.php#L180-L187
train
concrete5/concrete5
concrete/src/Support/Symbol/SymbolGenerator.php
SymbolGenerator.registerClass
public function registerClass($alias, $class) { $classSymbol = new ClassSymbol($alias, $class); $this->classes[$alias] = $classSymbol; $aliasNamespace = $classSymbol->getAliasNamespace(); if (!in_array($aliasNamespace, $this->aliasNamespaces, true)) { $this->aliasNamespaces[] = $aliasNamespace; } }
php
public function registerClass($alias, $class) { $classSymbol = new ClassSymbol($alias, $class); $this->classes[$alias] = $classSymbol; $aliasNamespace = $classSymbol->getAliasNamespace(); if (!in_array($aliasNamespace, $this->aliasNamespaces, true)) { $this->aliasNamespaces[] = $aliasNamespace; } }
[ "public", "function", "registerClass", "(", "$", "alias", ",", "$", "class", ")", "{", "$", "classSymbol", "=", "new", "ClassSymbol", "(", "$", "alias", ",", "$", "class", ")", ";", "$", "this", "->", "classes", "[", "$", "alias", "]", "=", "$", "classSymbol", ";", "$", "aliasNamespace", "=", "$", "classSymbol", "->", "getAliasNamespace", "(", ")", ";", "if", "(", "!", "in_array", "(", "$", "aliasNamespace", ",", "$", "this", "->", "aliasNamespaces", ",", "true", ")", ")", "{", "$", "this", "->", "aliasNamespaces", "[", "]", "=", "$", "aliasNamespace", ";", "}", "}" ]
Register a class alias, and store it in the classes array. @param $alias string @param $class string
[ "Register", "a", "class", "alias", "and", "store", "it", "in", "the", "classes", "array", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Support/Symbol/SymbolGenerator.php#L47-L55
train
concrete5/concrete5
concrete/src/Support/Symbol/SymbolGenerator.php
SymbolGenerator.render
public function render($eol = "\n", $padding = ' ', $methodFilter = null) { $lines = []; $lines[] = '<?php'; $lines[] = ''; $lines[] = '// Generated on ' . date('c'); foreach ($this->aliasNamespaces as $namespace) { $lines[] = ''; $lines[] = rtrim("namespace {$namespace}"); $lines[] = '{'; $addNewline = false; if ($namespace === '') { $lines[] = "{$padding}die('Access Denied.');"; $addNewline = true; } foreach ($this->classes as $class) { if ($class->getAliasNamespace() === $namespace) { $rendered_class = $class->render($eol, $padding, $methodFilter); if ($rendered_class !== '') { if ($addNewline === true) { $lines[] = ''; } else { $addNewline = true; } $lines[] = $padding . str_replace($eol, $eol . $padding, rtrim($rendered_class)); } } } $lines[] = '}'; } $lines[] = ''; return implode($eol, $lines); }
php
public function render($eol = "\n", $padding = ' ', $methodFilter = null) { $lines = []; $lines[] = '<?php'; $lines[] = ''; $lines[] = '// Generated on ' . date('c'); foreach ($this->aliasNamespaces as $namespace) { $lines[] = ''; $lines[] = rtrim("namespace {$namespace}"); $lines[] = '{'; $addNewline = false; if ($namespace === '') { $lines[] = "{$padding}die('Access Denied.');"; $addNewline = true; } foreach ($this->classes as $class) { if ($class->getAliasNamespace() === $namespace) { $rendered_class = $class->render($eol, $padding, $methodFilter); if ($rendered_class !== '') { if ($addNewline === true) { $lines[] = ''; } else { $addNewline = true; } $lines[] = $padding . str_replace($eol, $eol . $padding, rtrim($rendered_class)); } } } $lines[] = '}'; } $lines[] = ''; return implode($eol, $lines); }
[ "public", "function", "render", "(", "$", "eol", "=", "\"\\n\"", ",", "$", "padding", "=", "' '", ",", "$", "methodFilter", "=", "null", ")", "{", "$", "lines", "=", "[", "]", ";", "$", "lines", "[", "]", "=", "'<?php'", ";", "$", "lines", "[", "]", "=", "''", ";", "$", "lines", "[", "]", "=", "'// Generated on '", ".", "date", "(", "'c'", ")", ";", "foreach", "(", "$", "this", "->", "aliasNamespaces", "as", "$", "namespace", ")", "{", "$", "lines", "[", "]", "=", "''", ";", "$", "lines", "[", "]", "=", "rtrim", "(", "\"namespace {$namespace}\"", ")", ";", "$", "lines", "[", "]", "=", "'{'", ";", "$", "addNewline", "=", "false", ";", "if", "(", "$", "namespace", "===", "''", ")", "{", "$", "lines", "[", "]", "=", "\"{$padding}die('Access Denied.');\"", ";", "$", "addNewline", "=", "true", ";", "}", "foreach", "(", "$", "this", "->", "classes", "as", "$", "class", ")", "{", "if", "(", "$", "class", "->", "getAliasNamespace", "(", ")", "===", "$", "namespace", ")", "{", "$", "rendered_class", "=", "$", "class", "->", "render", "(", "$", "eol", ",", "$", "padding", ",", "$", "methodFilter", ")", ";", "if", "(", "$", "rendered_class", "!==", "''", ")", "{", "if", "(", "$", "addNewline", "===", "true", ")", "{", "$", "lines", "[", "]", "=", "''", ";", "}", "else", "{", "$", "addNewline", "=", "true", ";", "}", "$", "lines", "[", "]", "=", "$", "padding", ".", "str_replace", "(", "$", "eol", ",", "$", "eol", ".", "$", "padding", ",", "rtrim", "(", "$", "rendered_class", ")", ")", ";", "}", "}", "}", "$", "lines", "[", "]", "=", "'}'", ";", "}", "$", "lines", "[", "]", "=", "''", ";", "return", "implode", "(", "$", "eol", ",", "$", "lines", ")", ";", "}" ]
Render the classes. @param string $eol @param string $padding @param callable|null $methodFilter @return mixed|string
[ "Render", "the", "classes", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Support/Symbol/SymbolGenerator.php#L66-L99
train
concrete5/concrete5
concrete/authentication/concrete/controller.php
Controller.required_password_upgrade
public function required_password_upgrade() { $email = $this->post('uEmail'); $token = $this->app->make(Token::class); $this->set('token', $token); if ($email) { $errorValidator = Core::make('helper/validation/error'); $userInfo = Core::make('Concrete\Core\User\UserInfoRepository')->getByName(Session::get('uPasswordResetUserName')); try { if ($userInfo && $email != $userInfo->getUserEmail()) { throw new \Exception(t(sprintf('Invalid email address %s provided resetting a password', $email))); } } catch (\Exception $e) { $errorValidator->add($e); } $this->forgot_password(); } else { $this->set('authType', $this->getAuthenticationType()); $this->set('intro_msg', Core::make('config/database')->get('concrete.password.reset.message')); } }
php
public function required_password_upgrade() { $email = $this->post('uEmail'); $token = $this->app->make(Token::class); $this->set('token', $token); if ($email) { $errorValidator = Core::make('helper/validation/error'); $userInfo = Core::make('Concrete\Core\User\UserInfoRepository')->getByName(Session::get('uPasswordResetUserName')); try { if ($userInfo && $email != $userInfo->getUserEmail()) { throw new \Exception(t(sprintf('Invalid email address %s provided resetting a password', $email))); } } catch (\Exception $e) { $errorValidator->add($e); } $this->forgot_password(); } else { $this->set('authType', $this->getAuthenticationType()); $this->set('intro_msg', Core::make('config/database')->get('concrete.password.reset.message')); } }
[ "public", "function", "required_password_upgrade", "(", ")", "{", "$", "email", "=", "$", "this", "->", "post", "(", "'uEmail'", ")", ";", "$", "token", "=", "$", "this", "->", "app", "->", "make", "(", "Token", "::", "class", ")", ";", "$", "this", "->", "set", "(", "'token'", ",", "$", "token", ")", ";", "if", "(", "$", "email", ")", "{", "$", "errorValidator", "=", "Core", "::", "make", "(", "'helper/validation/error'", ")", ";", "$", "userInfo", "=", "Core", "::", "make", "(", "'Concrete\\Core\\User\\UserInfoRepository'", ")", "->", "getByName", "(", "Session", "::", "get", "(", "'uPasswordResetUserName'", ")", ")", ";", "try", "{", "if", "(", "$", "userInfo", "&&", "$", "email", "!=", "$", "userInfo", "->", "getUserEmail", "(", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "t", "(", "sprintf", "(", "'Invalid email address %s provided resetting a password'", ",", "$", "email", ")", ")", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "errorValidator", "->", "add", "(", "$", "e", ")", ";", "}", "$", "this", "->", "forgot_password", "(", ")", ";", "}", "else", "{", "$", "this", "->", "set", "(", "'authType'", ",", "$", "this", "->", "getAuthenticationType", "(", ")", ")", ";", "$", "this", "->", "set", "(", "'intro_msg'", ",", "Core", "::", "make", "(", "'config/database'", ")", "->", "get", "(", "'concrete.password.reset.message'", ")", ")", ";", "}", "}" ]
Called when a user tries to log in after his password has been reset by "Global Password Reset".
[ "Called", "when", "a", "user", "tries", "to", "log", "in", "after", "his", "password", "has", "been", "reset", "by", "Global", "Password", "Reset", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/authentication/concrete/controller.php#L152-L175
train
concrete5/concrete5
concrete/src/Express/Entry/Formatter/LabelFormatter.php
LabelFormatter.format
public function format($mask, Entry $entry) { return $this->formatter->format($mask, function ($key) use ($entry) { if ($key === 'id') { return $entry->getID(); } $attribute = $entry->getAttribute($key); if ($attribute) { return $attribute; } $association = $entry->getAssociation($key); if (is_object($association)) { return $association->getSelectedEntry()->getLabel(); } }); }
php
public function format($mask, Entry $entry) { return $this->formatter->format($mask, function ($key) use ($entry) { if ($key === 'id') { return $entry->getID(); } $attribute = $entry->getAttribute($key); if ($attribute) { return $attribute; } $association = $entry->getAssociation($key); if (is_object($association)) { return $association->getSelectedEntry()->getLabel(); } }); }
[ "public", "function", "format", "(", "$", "mask", ",", "Entry", "$", "entry", ")", "{", "return", "$", "this", "->", "formatter", "->", "format", "(", "$", "mask", ",", "function", "(", "$", "key", ")", "use", "(", "$", "entry", ")", "{", "if", "(", "$", "key", "===", "'id'", ")", "{", "return", "$", "entry", "->", "getID", "(", ")", ";", "}", "$", "attribute", "=", "$", "entry", "->", "getAttribute", "(", "$", "key", ")", ";", "if", "(", "$", "attribute", ")", "{", "return", "$", "attribute", ";", "}", "$", "association", "=", "$", "entry", "->", "getAssociation", "(", "$", "key", ")", ";", "if", "(", "is_object", "(", "$", "association", ")", ")", "{", "return", "$", "association", "->", "getSelectedEntry", "(", ")", "->", "getLabel", "(", ")", ";", "}", "}", ")", ";", "}" ]
Format a mask given an entry @param string $mask @param \Concrete\Core\Entity\Express\Entry $entry @return string|null
[ "Format", "a", "mask", "given", "an", "entry" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Express/Entry/Formatter/LabelFormatter.php#L25-L42
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.getByName
public static function getByName($blockName) { if (!$blockName) { return; } $app = Application::getFacadeApplication(); $now = $app->make('date')->getOverridableNow(); $db = Loader::db(); $sql = <<<'EOT' SELECT b.bID, cvb.arHandle, cvb.cID FROM Blocks AS b INNER JOIN CollectionVersionBlocks AS cvb ON b.bID = cvb.bID INNER JOIN CollectionVersions AS cv ON cvb.cID = cv.cID AND cvb.cvID = cv.cvID WHERE b.bName = ? AND cv.cvIsApproved = 1 AND (cv.cvPublishDate IS NULL or cv.cvPublishDate <= ?) AND (cv.cvPublishEndDate IS NULL or cv.cvPublishEndDate >= ?) ORDER BY cvb.cvID DESC LIMIT 1 EOT ; $vals = [$blockName, $now, $now]; $row = $db->getRow($sql, $vals); if ($row != false && isset($row['bID']) && $row['bID'] > 0) { return self::getByID($row['bID'], Page::getByID($row['cID']), $row['arHandle']); } else { return new self(); } }
php
public static function getByName($blockName) { if (!$blockName) { return; } $app = Application::getFacadeApplication(); $now = $app->make('date')->getOverridableNow(); $db = Loader::db(); $sql = <<<'EOT' SELECT b.bID, cvb.arHandle, cvb.cID FROM Blocks AS b INNER JOIN CollectionVersionBlocks AS cvb ON b.bID = cvb.bID INNER JOIN CollectionVersions AS cv ON cvb.cID = cv.cID AND cvb.cvID = cv.cvID WHERE b.bName = ? AND cv.cvIsApproved = 1 AND (cv.cvPublishDate IS NULL or cv.cvPublishDate <= ?) AND (cv.cvPublishEndDate IS NULL or cv.cvPublishEndDate >= ?) ORDER BY cvb.cvID DESC LIMIT 1 EOT ; $vals = [$blockName, $now, $now]; $row = $db->getRow($sql, $vals); if ($row != false && isset($row['bID']) && $row['bID'] > 0) { return self::getByID($row['bID'], Page::getByID($row['cID']), $row['arHandle']); } else { return new self(); } }
[ "public", "static", "function", "getByName", "(", "$", "blockName", ")", "{", "if", "(", "!", "$", "blockName", ")", "{", "return", ";", "}", "$", "app", "=", "Application", "::", "getFacadeApplication", "(", ")", ";", "$", "now", "=", "$", "app", "->", "make", "(", "'date'", ")", "->", "getOverridableNow", "(", ")", ";", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "sql", "=", " <<<'EOT'\nSELECT\n b.bID,\n cvb.arHandle,\n cvb.cID\nFROM\n Blocks AS b\n INNER JOIN CollectionVersionBlocks AS cvb\n ON b.bID = cvb.bID\n INNER JOIN CollectionVersions AS cv\n ON cvb.cID = cv.cID AND cvb.cvID = cv.cvID\nWHERE\n b.bName = ?\n AND cv.cvIsApproved = 1 AND (cv.cvPublishDate IS NULL or cv.cvPublishDate <= ?) AND (cv.cvPublishEndDate IS NULL or cv.cvPublishEndDate >= ?)\nORDER BY\n cvb.cvID DESC\nLIMIT 1\nEOT", ";", "$", "vals", "=", "[", "$", "blockName", ",", "$", "now", ",", "$", "now", "]", ";", "$", "row", "=", "$", "db", "->", "getRow", "(", "$", "sql", ",", "$", "vals", ")", ";", "if", "(", "$", "row", "!=", "false", "&&", "isset", "(", "$", "row", "[", "'bID'", "]", ")", "&&", "$", "row", "[", "'bID'", "]", ">", "0", ")", "{", "return", "self", "::", "getByID", "(", "$", "row", "[", "'bID'", "]", ",", "Page", "::", "getByID", "(", "$", "row", "[", "'cID'", "]", ")", ",", "$", "row", "[", "'arHandle'", "]", ")", ";", "}", "else", "{", "return", "new", "self", "(", ")", ";", "}", "}" ]
Get a block instance given its name. @param string $blockName @return \Concrete\Core\Block\Block|null returns NULL if $blockName is empty; a Block instance otherwise (the getBlockID() method will return NULL if the block was not found)
[ "Get", "a", "block", "instance", "given", "its", "name", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L206-L240
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.populateManually
public static function populateManually($blockInfo, $c, $a) { $b = new self(); $b->setPropertiesFromArray($blockInfo); if (is_object($a)) { $b->a = $a; $b->arHandle = $a->getAreaHandle(); } else { if ($a != null) { $b->arHandle = $a; // passing the area name. We only pass the object when we're adding from the front-end } } $b->cID = $c->getCollectionID(); $b->c = $c; return $b; }
php
public static function populateManually($blockInfo, $c, $a) { $b = new self(); $b->setPropertiesFromArray($blockInfo); if (is_object($a)) { $b->a = $a; $b->arHandle = $a->getAreaHandle(); } else { if ($a != null) { $b->arHandle = $a; // passing the area name. We only pass the object when we're adding from the front-end } } $b->cID = $c->getCollectionID(); $b->c = $c; return $b; }
[ "public", "static", "function", "populateManually", "(", "$", "blockInfo", ",", "$", "c", ",", "$", "a", ")", "{", "$", "b", "=", "new", "self", "(", ")", ";", "$", "b", "->", "setPropertiesFromArray", "(", "$", "blockInfo", ")", ";", "if", "(", "is_object", "(", "$", "a", ")", ")", "{", "$", "b", "->", "a", "=", "$", "a", ";", "$", "b", "->", "arHandle", "=", "$", "a", "->", "getAreaHandle", "(", ")", ";", "}", "else", "{", "if", "(", "$", "a", "!=", "null", ")", "{", "$", "b", "->", "arHandle", "=", "$", "a", ";", "// passing the area name. We only pass the object when we're adding from the front-end", "}", "}", "$", "b", "->", "cID", "=", "$", "c", "->", "getCollectionID", "(", ")", ";", "$", "b", "->", "c", "=", "$", "c", ";", "return", "$", "b", ";", "}" ]
Initialize the instance by manually specifying the data. @param array|\Iterator $blockInfo A set key-value pairs used to initialize the instance @param \Concrete\Core\Page\Collection\Collection $c The collection containing the block @param \Concrete\Core\Area\Area|string|null $a the area containing the block (or its handle) @return \Concrete\Core\Block\Block
[ "Initialize", "the", "instance", "by", "manually", "specifying", "the", "data", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L251-L269
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.getCollectionList
public function getCollectionList() { $cArray = []; $bID = $this->getBlockID(); if ($bID) { $db = Loader::db(); $q = 'select DISTINCT Pages.cID from CollectionVersionBlocks inner join Pages on (CollectionVersionBlocks.cID = Pages.cID) inner join CollectionVersions on (CollectionVersions.cID = Pages.cID) where CollectionVersionBlocks.bID = ?'; $r = $db->query($q, [$bID]); if ($r) { while ($row = $r->fetchRow()) { $cArray[] = Page::getByID($row['cID'], 'RECENT'); } $r->free(); } } return $cArray; }
php
public function getCollectionList() { $cArray = []; $bID = $this->getBlockID(); if ($bID) { $db = Loader::db(); $q = 'select DISTINCT Pages.cID from CollectionVersionBlocks inner join Pages on (CollectionVersionBlocks.cID = Pages.cID) inner join CollectionVersions on (CollectionVersions.cID = Pages.cID) where CollectionVersionBlocks.bID = ?'; $r = $db->query($q, [$bID]); if ($r) { while ($row = $r->fetchRow()) { $cArray[] = Page::getByID($row['cID'], 'RECENT'); } $r->free(); } } return $cArray; }
[ "public", "function", "getCollectionList", "(", ")", "{", "$", "cArray", "=", "[", "]", ";", "$", "bID", "=", "$", "this", "->", "getBlockID", "(", ")", ";", "if", "(", "$", "bID", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "q", "=", "'select DISTINCT Pages.cID from CollectionVersionBlocks inner join Pages on (CollectionVersionBlocks.cID = Pages.cID) inner join CollectionVersions on (CollectionVersions.cID = Pages.cID) where CollectionVersionBlocks.bID = ?'", ";", "$", "r", "=", "$", "db", "->", "query", "(", "$", "q", ",", "[", "$", "bID", "]", ")", ";", "if", "(", "$", "r", ")", "{", "while", "(", "$", "row", "=", "$", "r", "->", "fetchRow", "(", ")", ")", "{", "$", "cArray", "[", "]", "=", "Page", "::", "getByID", "(", "$", "row", "[", "'cID'", "]", ",", "'RECENT'", ")", ";", "}", "$", "r", "->", "free", "(", ")", ";", "}", "}", "return", "$", "cArray", ";", "}" ]
Gets a list of collections that include this block, along with area name, etc... used in the block_details.php page in the admin control panel. @return \Concrete\Core\Page\Page[]
[ "Gets", "a", "list", "of", "collections", "that", "include", "this", "block", "along", "with", "area", "name", "etc", "...", "used", "in", "the", "block_details", ".", "php", "page", "in", "the", "admin", "control", "panel", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L494-L511
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.setBlockCollectionObject
public function setBlockCollectionObject($c) { $this->c = $c; $this->cID = $c ? $c->getCollectionID() : null; }
php
public function setBlockCollectionObject($c) { $this->c = $c; $this->cID = $c ? $c->getCollectionID() : null; }
[ "public", "function", "setBlockCollectionObject", "(", "$", "c", ")", "{", "$", "this", "->", "c", "=", "$", "c", ";", "$", "this", "->", "cID", "=", "$", "c", "?", "$", "c", "->", "getCollectionID", "(", ")", ":", "null", ";", "}" ]
Set the collection instance containing the block. @param \Concrete\Core\Page\Collection\Collection $c
[ "Set", "the", "collection", "instance", "containing", "the", "block", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L518-L522
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.setBlockAreaObject
public function setBlockAreaObject(&$a) { $this->a = $a; $this->arHandle = $a ? $a->getAreaHandle() : null; }
php
public function setBlockAreaObject(&$a) { $this->a = $a; $this->arHandle = $a ? $a->getAreaHandle() : null; }
[ "public", "function", "setBlockAreaObject", "(", "&", "$", "a", ")", "{", "$", "this", "->", "a", "=", "$", "a", ";", "$", "this", "->", "arHandle", "=", "$", "a", "?", "$", "a", "->", "getAreaHandle", "(", ")", ":", "null", ";", "}" ]
Set the area containing the block. @param \Concrete\Core\Area\Area $a
[ "Set", "the", "area", "containing", "the", "block", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L551-L555
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.setAbsoluteBlockDisplayOrder
public function setAbsoluteBlockDisplayOrder($do) { $db = Loader::db(); $cID = $this->getBlockCollectionID(); $bID = $this->getBlockID(); $arHandle = $this->getAreaHandle(); $c = $this->getBlockCollectionObject(); $cvID = $c->getVersionID(); $q = 'update CollectionVersionBlocks set cbDisplayOrder = ? where bID = ? and cID = ? and (cvID = ? or cbIncludeAll=1) and arHandle = ?'; $r = $db->query($q, [$do, $bID, $cID, $cvID, $arHandle]); }
php
public function setAbsoluteBlockDisplayOrder($do) { $db = Loader::db(); $cID = $this->getBlockCollectionID(); $bID = $this->getBlockID(); $arHandle = $this->getAreaHandle(); $c = $this->getBlockCollectionObject(); $cvID = $c->getVersionID(); $q = 'update CollectionVersionBlocks set cbDisplayOrder = ? where bID = ? and cID = ? and (cvID = ? or cbIncludeAll=1) and arHandle = ?'; $r = $db->query($q, [$do, $bID, $cID, $cvID, $arHandle]); }
[ "public", "function", "setAbsoluteBlockDisplayOrder", "(", "$", "do", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "cID", "=", "$", "this", "->", "getBlockCollectionID", "(", ")", ";", "$", "bID", "=", "$", "this", "->", "getBlockID", "(", ")", ";", "$", "arHandle", "=", "$", "this", "->", "getAreaHandle", "(", ")", ";", "$", "c", "=", "$", "this", "->", "getBlockCollectionObject", "(", ")", ";", "$", "cvID", "=", "$", "c", "->", "getVersionID", "(", ")", ";", "$", "q", "=", "'update CollectionVersionBlocks set cbDisplayOrder = ? where bID = ? and cID = ? and (cvID = ? or cbIncludeAll=1) and arHandle = ?'", ";", "$", "r", "=", "$", "db", "->", "query", "(", "$", "q", ",", "[", "$", "do", ",", "$", "bID", ",", "$", "cID", ",", "$", "cvID", ",", "$", "arHandle", "]", ")", ";", "}" ]
Set the absolute position of this block, regardless other blocks in the same page & area. @param int $do the new absolute position of the block (starting from 0)
[ "Set", "the", "absolute", "position", "of", "this", "block", "regardless", "other", "blocks", "in", "the", "same", "page", "&", "area", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L613-L626
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.isEditable
public function isEditable() { $bv = new BlockView($this); $path = $bv->getBlockPath(FILENAME_BLOCK_EDIT); if (file_exists($path . '/' . FILENAME_BLOCK_EDIT)) { return true; } return false; }
php
public function isEditable() { $bv = new BlockView($this); $path = $bv->getBlockPath(FILENAME_BLOCK_EDIT); if (file_exists($path . '/' . FILENAME_BLOCK_EDIT)) { return true; } return false; }
[ "public", "function", "isEditable", "(", ")", "{", "$", "bv", "=", "new", "BlockView", "(", "$", "this", ")", ";", "$", "path", "=", "$", "bv", "->", "getBlockPath", "(", "FILENAME_BLOCK_EDIT", ")", ";", "if", "(", "file_exists", "(", "$", "path", ".", "'/'", ".", "FILENAME_BLOCK_EDIT", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Does this block have an edit user interface? @return bool
[ "Does", "this", "block", "have", "an", "edit", "user", "interface?" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L707-L716
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.deactivate
public function deactivate() { $db = Loader::db(); $q = 'update Blocks set bIsActive = 0 where bID = ?'; $db->query($q, [$this->getBlockID()]); }
php
public function deactivate() { $db = Loader::db(); $q = 'update Blocks set bIsActive = 0 where bID = ?'; $db->query($q, [$this->getBlockID()]); }
[ "public", "function", "deactivate", "(", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "q", "=", "'update Blocks set bIsActive = 0 where bID = ?'", ";", "$", "db", "->", "query", "(", "$", "q", ",", "[", "$", "this", "->", "getBlockID", "(", ")", "]", ")", ";", "}" ]
Deactivate the block.
[ "Deactivate", "the", "block", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L731-L736
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.activate
public function activate() { $db = Loader::db(); $q = 'update Blocks set bIsActive = 1 where bID = ?'; $db->query($q, [$this->getBlockID()]); }
php
public function activate() { $db = Loader::db(); $q = 'update Blocks set bIsActive = 1 where bID = ?'; $db->query($q, [$this->getBlockID()]); }
[ "public", "function", "activate", "(", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "q", "=", "'update Blocks set bIsActive = 1 where bID = ?'", ";", "$", "db", "->", "query", "(", "$", "q", ",", "[", "$", "this", "->", "getBlockID", "(", ")", "]", ")", ";", "}" ]
Activate the block.
[ "Activate", "the", "block", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L741-L746
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.isAlias
public function isAlias($c = null) { if ($c) { $db = Loader::db(); $cID = $c->getCollectionID(); $vo = $c->getVersionObject(); $cvID = $vo->getVersionID(); $q = 'select bID from CollectionVersionBlocks where bID = ? and cID=? and isOriginal = 0 and cvID = ?'; $r = $db->query($q, [$this->getBlockID(), $cID, $cvID]); if ($r) { return $r->numRows() > 0; } } else { return isset($this->isOriginal) ? (!$this->isOriginal) : false; } }
php
public function isAlias($c = null) { if ($c) { $db = Loader::db(); $cID = $c->getCollectionID(); $vo = $c->getVersionObject(); $cvID = $vo->getVersionID(); $q = 'select bID from CollectionVersionBlocks where bID = ? and cID=? and isOriginal = 0 and cvID = ?'; $r = $db->query($q, [$this->getBlockID(), $cID, $cvID]); if ($r) { return $r->numRows() > 0; } } else { return isset($this->isOriginal) ? (!$this->isOriginal) : false; } }
[ "public", "function", "isAlias", "(", "$", "c", "=", "null", ")", "{", "if", "(", "$", "c", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "cID", "=", "$", "c", "->", "getCollectionID", "(", ")", ";", "$", "vo", "=", "$", "c", "->", "getVersionObject", "(", ")", ";", "$", "cvID", "=", "$", "vo", "->", "getVersionID", "(", ")", ";", "$", "q", "=", "'select bID from CollectionVersionBlocks where bID = ? and cID=? and isOriginal = 0 and cvID = ?'", ";", "$", "r", "=", "$", "db", "->", "query", "(", "$", "q", ",", "[", "$", "this", "->", "getBlockID", "(", ")", ",", "$", "cID", ",", "$", "cvID", "]", ")", ";", "if", "(", "$", "r", ")", "{", "return", "$", "r", "->", "numRows", "(", ")", ">", "0", ";", "}", "}", "else", "{", "return", "isset", "(", "$", "this", "->", "isOriginal", ")", "?", "(", "!", "$", "this", "->", "isOriginal", ")", ":", "false", ";", "}", "}" ]
Check if this block instance is an alias. @param \Concrete\Core\Page\Collection\Collection|null $c if specified, check if the block with the ID of this instance is an alias in that page (otherwise the check is done agains this specific block instance) @return bool|null return NULL if $c is specified but there's no block with the same ID in that page
[ "Check", "if", "this", "block", "instance", "is", "an", "alias", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L765-L780
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.getNumChildren
public function getNumChildren() { $db = Loader::db(); $q = 'select count(*) as total from CollectionVersionBlocks where bID = ? and isOriginal = 0'; $total = $db->getOne($q, [$this->getBlockID()]); return $total; }
php
public function getNumChildren() { $db = Loader::db(); $q = 'select count(*) as total from CollectionVersionBlocks where bID = ? and isOriginal = 0'; $total = $db->getOne($q, [$this->getBlockID()]); return $total; }
[ "public", "function", "getNumChildren", "(", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "q", "=", "'select count(*) as total from CollectionVersionBlocks where bID = ? and isOriginal = 0'", ";", "$", "total", "=", "$", "db", "->", "getOne", "(", "$", "q", ",", "[", "$", "this", "->", "getBlockID", "(", ")", "]", ")", ";", "return", "$", "total", ";", "}" ]
Get the number of alias of this block. @return int
[ "Get", "the", "number", "of", "alias", "of", "this", "block", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L797-L804
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.isBlockInStack
public function isBlockInStack() { $co = $this->getBlockCollectionObject(); if (is_object($co)) { if ($co->getPageTypeHandle() == STACKS_PAGE_TYPE) { return true; } } return false; }
php
public function isBlockInStack() { $co = $this->getBlockCollectionObject(); if (is_object($co)) { if ($co->getPageTypeHandle() == STACKS_PAGE_TYPE) { return true; } } return false; }
[ "public", "function", "isBlockInStack", "(", ")", "{", "$", "co", "=", "$", "this", "->", "getBlockCollectionObject", "(", ")", ";", "if", "(", "is_object", "(", "$", "co", ")", ")", "{", "if", "(", "$", "co", "->", "getPageTypeHandle", "(", ")", "==", "STACKS_PAGE_TYPE", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Is this block inside a stack? @return bool
[ "Is", "this", "block", "inside", "a", "stack?" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L811-L821
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.getCustomStyleSetID
public function getCustomStyleSetID() { $db = Loader::db(); if (!isset($this->issID)) { $co = $this->getBlockCollectionObject(); $arHandle = $this->getAreaHandle(); if ($arHandle) { $a = $this->getBlockAreaObject(); if ($a->isGlobalArea()) { // then we need to check against the global area name. We currently have the wrong area handle passed in $arHandle = STACKS_AREA_NAME; } $v = [ $co->getCollectionID(), $co->getVersionID(), $arHandle, $this->getBlockID(), ]; $this->issID = (int) $db->GetOne( 'select issID from CollectionVersionBlockStyles where cID = ? and cvID = ? and arHandle = ? and bID = ?', $v ); } else { $this->issID = 0; } } return $this->issID; }
php
public function getCustomStyleSetID() { $db = Loader::db(); if (!isset($this->issID)) { $co = $this->getBlockCollectionObject(); $arHandle = $this->getAreaHandle(); if ($arHandle) { $a = $this->getBlockAreaObject(); if ($a->isGlobalArea()) { // then we need to check against the global area name. We currently have the wrong area handle passed in $arHandle = STACKS_AREA_NAME; } $v = [ $co->getCollectionID(), $co->getVersionID(), $arHandle, $this->getBlockID(), ]; $this->issID = (int) $db->GetOne( 'select issID from CollectionVersionBlockStyles where cID = ? and cvID = ? and arHandle = ? and bID = ?', $v ); } else { $this->issID = 0; } } return $this->issID; }
[ "public", "function", "getCustomStyleSetID", "(", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "issID", ")", ")", "{", "$", "co", "=", "$", "this", "->", "getBlockCollectionObject", "(", ")", ";", "$", "arHandle", "=", "$", "this", "->", "getAreaHandle", "(", ")", ";", "if", "(", "$", "arHandle", ")", "{", "$", "a", "=", "$", "this", "->", "getBlockAreaObject", "(", ")", ";", "if", "(", "$", "a", "->", "isGlobalArea", "(", ")", ")", "{", "// then we need to check against the global area name. We currently have the wrong area handle passed in", "$", "arHandle", "=", "STACKS_AREA_NAME", ";", "}", "$", "v", "=", "[", "$", "co", "->", "getCollectionID", "(", ")", ",", "$", "co", "->", "getVersionID", "(", ")", ",", "$", "arHandle", ",", "$", "this", "->", "getBlockID", "(", ")", ",", "]", ";", "$", "this", "->", "issID", "=", "(", "int", ")", "$", "db", "->", "GetOne", "(", "'select issID from CollectionVersionBlockStyles where cID = ? and cvID = ? and arHandle = ? and bID = ?'", ",", "$", "v", ")", ";", "}", "else", "{", "$", "this", "->", "issID", "=", "0", ";", "}", "}", "return", "$", "this", "->", "issID", ";", "}" ]
Get the ID of the custom style set. @return int returns 0 or false if the block does not have custom styles
[ "Get", "the", "ID", "of", "the", "custom", "style", "set", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L828-L859
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.getCustomStyle
public function getCustomStyle($force = false) { if ($this->getCustomStyleSetID() > 0 || $force) { $csr = StyleSet::getByID($this->getCustomStyleSetID()); $theme = $this->c->getCollectionThemeObject(); switch ($this->getBlockTypeHandle()) { case BLOCK_HANDLE_LAYOUT_PROXY: $bs = new CoreAreaLayoutCustomStyle($csr, $this, $theme); break; default: $bs = new CustomStyle($csr, $this, $theme); break; } return $bs; } }
php
public function getCustomStyle($force = false) { if ($this->getCustomStyleSetID() > 0 || $force) { $csr = StyleSet::getByID($this->getCustomStyleSetID()); $theme = $this->c->getCollectionThemeObject(); switch ($this->getBlockTypeHandle()) { case BLOCK_HANDLE_LAYOUT_PROXY: $bs = new CoreAreaLayoutCustomStyle($csr, $this, $theme); break; default: $bs = new CustomStyle($csr, $this, $theme); break; } return $bs; } }
[ "public", "function", "getCustomStyle", "(", "$", "force", "=", "false", ")", "{", "if", "(", "$", "this", "->", "getCustomStyleSetID", "(", ")", ">", "0", "||", "$", "force", ")", "{", "$", "csr", "=", "StyleSet", "::", "getByID", "(", "$", "this", "->", "getCustomStyleSetID", "(", ")", ")", ";", "$", "theme", "=", "$", "this", "->", "c", "->", "getCollectionThemeObject", "(", ")", ";", "switch", "(", "$", "this", "->", "getBlockTypeHandle", "(", ")", ")", "{", "case", "BLOCK_HANDLE_LAYOUT_PROXY", ":", "$", "bs", "=", "new", "CoreAreaLayoutCustomStyle", "(", "$", "csr", ",", "$", "this", ",", "$", "theme", ")", ";", "break", ";", "default", ":", "$", "bs", "=", "new", "CustomStyle", "(", "$", "csr", ",", "$", "this", ",", "$", "theme", ")", ";", "break", ";", "}", "return", "$", "bs", ";", "}", "}" ]
Get the custom style object associated to this block. @param bool $force Do you want a CustomStyle instance even if the block does not have custom styles? @return \Concrete\Core\Block\CustomStyle|null
[ "Get", "the", "custom", "style", "object", "associated", "to", "this", "block", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L868-L884
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.setCustomStyleSet
public function setCustomStyleSet(\Concrete\Core\Entity\StyleCustomizer\Inline\StyleSet $set) { $db = Loader::db(); $c = $this->getBlockCollectionObject(); $cvID = $c->getVersionID(); $db->Replace( 'CollectionVersionBlockStyles', [ 'cID' => $this->getBlockCollectionID(), 'cvID' => $cvID, 'arHandle' => $this->getAreaHandle(), 'bID' => $this->getBlockID(), 'issID' => $set->getID(), ], [ 'cID', 'cvID', 'bID', 'arHandle', ], true ); $this->issID = (int) $set->getID(); }
php
public function setCustomStyleSet(\Concrete\Core\Entity\StyleCustomizer\Inline\StyleSet $set) { $db = Loader::db(); $c = $this->getBlockCollectionObject(); $cvID = $c->getVersionID(); $db->Replace( 'CollectionVersionBlockStyles', [ 'cID' => $this->getBlockCollectionID(), 'cvID' => $cvID, 'arHandle' => $this->getAreaHandle(), 'bID' => $this->getBlockID(), 'issID' => $set->getID(), ], [ 'cID', 'cvID', 'bID', 'arHandle', ], true ); $this->issID = (int) $set->getID(); }
[ "public", "function", "setCustomStyleSet", "(", "\\", "Concrete", "\\", "Core", "\\", "Entity", "\\", "StyleCustomizer", "\\", "Inline", "\\", "StyleSet", "$", "set", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "c", "=", "$", "this", "->", "getBlockCollectionObject", "(", ")", ";", "$", "cvID", "=", "$", "c", "->", "getVersionID", "(", ")", ";", "$", "db", "->", "Replace", "(", "'CollectionVersionBlockStyles'", ",", "[", "'cID'", "=>", "$", "this", "->", "getBlockCollectionID", "(", ")", ",", "'cvID'", "=>", "$", "cvID", ",", "'arHandle'", "=>", "$", "this", "->", "getAreaHandle", "(", ")", ",", "'bID'", "=>", "$", "this", "->", "getBlockID", "(", ")", ",", "'issID'", "=>", "$", "set", "->", "getID", "(", ")", ",", "]", ",", "[", "'cID'", ",", "'cvID'", ",", "'bID'", ",", "'arHandle'", ",", "]", ",", "true", ")", ";", "$", "this", "->", "issID", "=", "(", "int", ")", "$", "set", "->", "getID", "(", ")", ";", "}" ]
Set the block custom styles. @param \Concrete\Core\Entity\StyleCustomizer\Inline\StyleSet $set
[ "Set", "the", "block", "custom", "styles", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L891-L914
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.resetCustomStyle
public function resetCustomStyle() { $db = Loader::db(); $c = $this->getBlockCollectionObject(); $cvID = $c->getVersionID(); $db->Execute( 'delete from CollectionVersionBlockStyles where cID = ? and cvID = ? and arHandle = ? and bID = ?', [ $this->getBlockCollectionID(), $cvID, $this->getAreaHandle(), $this->getBlockID(), ] ); $this->issID = 0; }
php
public function resetCustomStyle() { $db = Loader::db(); $c = $this->getBlockCollectionObject(); $cvID = $c->getVersionID(); $db->Execute( 'delete from CollectionVersionBlockStyles where cID = ? and cvID = ? and arHandle = ? and bID = ?', [ $this->getBlockCollectionID(), $cvID, $this->getAreaHandle(), $this->getBlockID(), ] ); $this->issID = 0; }
[ "public", "function", "resetCustomStyle", "(", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "c", "=", "$", "this", "->", "getBlockCollectionObject", "(", ")", ";", "$", "cvID", "=", "$", "c", "->", "getVersionID", "(", ")", ";", "$", "db", "->", "Execute", "(", "'delete from CollectionVersionBlockStyles where cID = ? and cvID = ? and arHandle = ? and bID = ?'", ",", "[", "$", "this", "->", "getBlockCollectionID", "(", ")", ",", "$", "cvID", ",", "$", "this", "->", "getAreaHandle", "(", ")", ",", "$", "this", "->", "getBlockID", "(", ")", ",", "]", ")", ";", "$", "this", "->", "issID", "=", "0", ";", "}" ]
Remove the block custom styles.
[ "Remove", "the", "block", "custom", "styles", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L919-L934
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.getBlockCacheSettingsObject
public function getBlockCacheSettingsObject() { if ($this->cacheSettings === null) { $this->cacheSettings = CacheSettings::get($this); } return $this->cacheSettings; }
php
public function getBlockCacheSettingsObject() { if ($this->cacheSettings === null) { $this->cacheSettings = CacheSettings::get($this); } return $this->cacheSettings; }
[ "public", "function", "getBlockCacheSettingsObject", "(", ")", "{", "if", "(", "$", "this", "->", "cacheSettings", "===", "null", ")", "{", "$", "this", "->", "cacheSettings", "=", "CacheSettings", "::", "get", "(", "$", "this", ")", ";", "}", "return", "$", "this", "->", "cacheSettings", ";", "}" ]
Get the cache settings instance. @return \Concrete\Core\Block\CacheSettings
[ "Get", "the", "cache", "settings", "instance", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L941-L948
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.setCustomCacheSettings
public function setCustomCacheSettings($enabled, $enabledOnPost, $enabledForRegistered, $lifetime) { $db = Loader::db(); $c = $this->getBlockCollectionObject(); $cvID = $c->getVersionID(); $enabled = (bool) $enabled; $enabledOnPost = (bool) $enabledOnPost; $enabledForRegistered = (bool) $enabledForRegistered; $lifetime = (int) $lifetime; $db->Replace( 'CollectionVersionBlocksCacheSettings', [ 'cID' => $this->getBlockCollectionID(), 'cvID' => $cvID, 'arHandle' => $this->getAreaHandle(), 'bID' => $this->getBlockID(), 'btCacheBlockOutput' => (int) $enabled, 'btCacheBlockOutputOnPost' => (int) $enabledOnPost, 'btCacheBlockOutputForRegisteredUsers' => (int) $enabledForRegistered, 'btCacheBlockOutputLifetime' => (int) $lifetime, ], [ 'cID', 'cvID', 'bID', 'arHandle', ], true ); $db->update( 'CollectionVersionBlocks', ['cbOverrideBlockTypeCacheSettings' => 1], [ 'cID' => $this->getBlockCollectionID(), 'cvID' => $cvID, 'arHandle' => $this->getAreaHandle(), 'bID' => $this->getBlockID(), ] ); }
php
public function setCustomCacheSettings($enabled, $enabledOnPost, $enabledForRegistered, $lifetime) { $db = Loader::db(); $c = $this->getBlockCollectionObject(); $cvID = $c->getVersionID(); $enabled = (bool) $enabled; $enabledOnPost = (bool) $enabledOnPost; $enabledForRegistered = (bool) $enabledForRegistered; $lifetime = (int) $lifetime; $db->Replace( 'CollectionVersionBlocksCacheSettings', [ 'cID' => $this->getBlockCollectionID(), 'cvID' => $cvID, 'arHandle' => $this->getAreaHandle(), 'bID' => $this->getBlockID(), 'btCacheBlockOutput' => (int) $enabled, 'btCacheBlockOutputOnPost' => (int) $enabledOnPost, 'btCacheBlockOutputForRegisteredUsers' => (int) $enabledForRegistered, 'btCacheBlockOutputLifetime' => (int) $lifetime, ], [ 'cID', 'cvID', 'bID', 'arHandle', ], true ); $db->update( 'CollectionVersionBlocks', ['cbOverrideBlockTypeCacheSettings' => 1], [ 'cID' => $this->getBlockCollectionID(), 'cvID' => $cvID, 'arHandle' => $this->getAreaHandle(), 'bID' => $this->getBlockID(), ] ); }
[ "public", "function", "setCustomCacheSettings", "(", "$", "enabled", ",", "$", "enabledOnPost", ",", "$", "enabledForRegistered", ",", "$", "lifetime", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "c", "=", "$", "this", "->", "getBlockCollectionObject", "(", ")", ";", "$", "cvID", "=", "$", "c", "->", "getVersionID", "(", ")", ";", "$", "enabled", "=", "(", "bool", ")", "$", "enabled", ";", "$", "enabledOnPost", "=", "(", "bool", ")", "$", "enabledOnPost", ";", "$", "enabledForRegistered", "=", "(", "bool", ")", "$", "enabledForRegistered", ";", "$", "lifetime", "=", "(", "int", ")", "$", "lifetime", ";", "$", "db", "->", "Replace", "(", "'CollectionVersionBlocksCacheSettings'", ",", "[", "'cID'", "=>", "$", "this", "->", "getBlockCollectionID", "(", ")", ",", "'cvID'", "=>", "$", "cvID", ",", "'arHandle'", "=>", "$", "this", "->", "getAreaHandle", "(", ")", ",", "'bID'", "=>", "$", "this", "->", "getBlockID", "(", ")", ",", "'btCacheBlockOutput'", "=>", "(", "int", ")", "$", "enabled", ",", "'btCacheBlockOutputOnPost'", "=>", "(", "int", ")", "$", "enabledOnPost", ",", "'btCacheBlockOutputForRegisteredUsers'", "=>", "(", "int", ")", "$", "enabledForRegistered", ",", "'btCacheBlockOutputLifetime'", "=>", "(", "int", ")", "$", "lifetime", ",", "]", ",", "[", "'cID'", ",", "'cvID'", ",", "'bID'", ",", "'arHandle'", ",", "]", ",", "true", ")", ";", "$", "db", "->", "update", "(", "'CollectionVersionBlocks'", ",", "[", "'cbOverrideBlockTypeCacheSettings'", "=>", "1", "]", ",", "[", "'cID'", "=>", "$", "this", "->", "getBlockCollectionID", "(", ")", ",", "'cvID'", "=>", "$", "cvID", ",", "'arHandle'", "=>", "$", "this", "->", "getAreaHandle", "(", ")", ",", "'bID'", "=>", "$", "this", "->", "getBlockID", "(", ")", ",", "]", ")", ";", "}" ]
Customize the cache settings, overriding the values of the block type controller. @param bool $enabled Should the block output be cached? @param bool $enabledOnPost Should the block output be cached upon POST requests? @param bool $enabledForRegistered Should the block output be cached when site visitors are registered users? @param int $lifetime cache lifetime (in seconds); if empty we'll assume 5 years
[ "Customize", "the", "cache", "settings", "overriding", "the", "values", "of", "the", "block", "type", "controller", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L972-L1013
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.resetCustomCacheSettings
public function resetCustomCacheSettings() { $db = Loader::db(); $c = $this->getBlockCollectionObject(); $cvID = $c->getVersionID(); $db->update( 'CollectionVersionBlocks', ['cbOverrideBlockTypeCacheSettings' => 0], [ 'cID' => $this->getBlockCollectionID(), 'cvID' => $cvID, 'arHandle' => $this->getAreaHandle(), 'bID' => $this->getBlockID(), ] ); $db->delete( 'CollectionVersionBlocksCacheSettings', [ 'cID' => $this->getBlockCollectionID(), 'cvID' => $cvID, 'arHandle' => $this->getAreaHandle(), 'bID' => $this->getBlockID(), ] ); }
php
public function resetCustomCacheSettings() { $db = Loader::db(); $c = $this->getBlockCollectionObject(); $cvID = $c->getVersionID(); $db->update( 'CollectionVersionBlocks', ['cbOverrideBlockTypeCacheSettings' => 0], [ 'cID' => $this->getBlockCollectionID(), 'cvID' => $cvID, 'arHandle' => $this->getAreaHandle(), 'bID' => $this->getBlockID(), ] ); $db->delete( 'CollectionVersionBlocksCacheSettings', [ 'cID' => $this->getBlockCollectionID(), 'cvID' => $cvID, 'arHandle' => $this->getAreaHandle(), 'bID' => $this->getBlockID(), ] ); }
[ "public", "function", "resetCustomCacheSettings", "(", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "c", "=", "$", "this", "->", "getBlockCollectionObject", "(", ")", ";", "$", "cvID", "=", "$", "c", "->", "getVersionID", "(", ")", ";", "$", "db", "->", "update", "(", "'CollectionVersionBlocks'", ",", "[", "'cbOverrideBlockTypeCacheSettings'", "=>", "0", "]", ",", "[", "'cID'", "=>", "$", "this", "->", "getBlockCollectionID", "(", ")", ",", "'cvID'", "=>", "$", "cvID", ",", "'arHandle'", "=>", "$", "this", "->", "getAreaHandle", "(", ")", ",", "'bID'", "=>", "$", "this", "->", "getBlockID", "(", ")", ",", "]", ")", ";", "$", "db", "->", "delete", "(", "'CollectionVersionBlocksCacheSettings'", ",", "[", "'cID'", "=>", "$", "this", "->", "getBlockCollectionID", "(", ")", ",", "'cvID'", "=>", "$", "cvID", ",", "'arHandle'", "=>", "$", "this", "->", "getAreaHandle", "(", ")", ",", "'bID'", "=>", "$", "this", "->", "getBlockID", "(", ")", ",", "]", ")", ";", "}" ]
Reset the cache settings, so that concrete5 will use the values of the block type controller.
[ "Reset", "the", "cache", "settings", "so", "that", "concrete5", "will", "use", "the", "values", "of", "the", "block", "type", "controller", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L1018-L1042
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.setBlockCachedOutput
public function setBlockCachedOutput($content, $lifetime, $area) { $db = Loader::db(); $c = $this->getBlockCollectionObject(); $btCachedBlockOutputExpires = strtotime('+5 years'); if ($lifetime > 0) { $btCachedBlockOutputExpires = time() + $lifetime; } $arHandle = $this->getAreaHandle(); $cID = $c->getCollectionID(); $cvID = $c->getVersionID(); if ($this->isBlockInStack() && is_object($area)) { $arHandle = $area->getAreaHandle(); $cx = Page::getCurrentPage(); $cID = $cx->getCollectioniD(); $cvID = $cx->getVersionID(); } if ($arHandle && $cID && $cvID) { $db->Replace( 'CollectionVersionBlocksOutputCache', [ 'cID' => $cID, 'cvID' => $cvID, 'bID' => $this->getBlockID(), 'arHandle' => $arHandle, 'btCachedBlockOutput' => $content, 'btCachedBlockOutputExpires' => $btCachedBlockOutputExpires, ], [ 'cID', 'cvID', 'arHandle', 'bID', ], true ); } }
php
public function setBlockCachedOutput($content, $lifetime, $area) { $db = Loader::db(); $c = $this->getBlockCollectionObject(); $btCachedBlockOutputExpires = strtotime('+5 years'); if ($lifetime > 0) { $btCachedBlockOutputExpires = time() + $lifetime; } $arHandle = $this->getAreaHandle(); $cID = $c->getCollectionID(); $cvID = $c->getVersionID(); if ($this->isBlockInStack() && is_object($area)) { $arHandle = $area->getAreaHandle(); $cx = Page::getCurrentPage(); $cID = $cx->getCollectioniD(); $cvID = $cx->getVersionID(); } if ($arHandle && $cID && $cvID) { $db->Replace( 'CollectionVersionBlocksOutputCache', [ 'cID' => $cID, 'cvID' => $cvID, 'bID' => $this->getBlockID(), 'arHandle' => $arHandle, 'btCachedBlockOutput' => $content, 'btCachedBlockOutputExpires' => $btCachedBlockOutputExpires, ], [ 'cID', 'cvID', 'arHandle', 'bID', ], true ); } }
[ "public", "function", "setBlockCachedOutput", "(", "$", "content", ",", "$", "lifetime", ",", "$", "area", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "c", "=", "$", "this", "->", "getBlockCollectionObject", "(", ")", ";", "$", "btCachedBlockOutputExpires", "=", "strtotime", "(", "'+5 years'", ")", ";", "if", "(", "$", "lifetime", ">", "0", ")", "{", "$", "btCachedBlockOutputExpires", "=", "time", "(", ")", "+", "$", "lifetime", ";", "}", "$", "arHandle", "=", "$", "this", "->", "getAreaHandle", "(", ")", ";", "$", "cID", "=", "$", "c", "->", "getCollectionID", "(", ")", ";", "$", "cvID", "=", "$", "c", "->", "getVersionID", "(", ")", ";", "if", "(", "$", "this", "->", "isBlockInStack", "(", ")", "&&", "is_object", "(", "$", "area", ")", ")", "{", "$", "arHandle", "=", "$", "area", "->", "getAreaHandle", "(", ")", ";", "$", "cx", "=", "Page", "::", "getCurrentPage", "(", ")", ";", "$", "cID", "=", "$", "cx", "->", "getCollectioniD", "(", ")", ";", "$", "cvID", "=", "$", "cx", "->", "getVersionID", "(", ")", ";", "}", "if", "(", "$", "arHandle", "&&", "$", "cID", "&&", "$", "cvID", ")", "{", "$", "db", "->", "Replace", "(", "'CollectionVersionBlocksOutputCache'", ",", "[", "'cID'", "=>", "$", "cID", ",", "'cvID'", "=>", "$", "cvID", ",", "'bID'", "=>", "$", "this", "->", "getBlockID", "(", ")", ",", "'arHandle'", "=>", "$", "arHandle", ",", "'btCachedBlockOutput'", "=>", "$", "content", ",", "'btCachedBlockOutputExpires'", "=>", "$", "btCachedBlockOutputExpires", ",", "]", ",", "[", "'cID'", ",", "'cvID'", ",", "'arHandle'", ",", "'bID'", ",", "]", ",", "true", ")", ";", "}", "}" ]
Set the output cache. @param string $content the block output to be placed in the cache @param int|null $lifetime The cache life time (in seconds). If empty we'll assume 5 years. @param \Concrete\Core\Area\Area|null $area the stack area containing the block
[ "Set", "the", "output", "cache", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L1109-L1149
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.refreshBlockOutputCache
public function refreshBlockOutputCache() { $db = Loader::db(); $cID = $this->getBlockCollectionID(); $bID = $this->getBlockID(); $c = $this->getBlockCollectionObject(); $v = [$c->getCollectionID(), $c->getVersionID(), $this->getAreaHandle(), $bID]; $db->Execute( 'update CollectionVersionBlocksOutputCache set btCachedBlockOutputExpires = 0 where cID = ? and cvID = ? and arHandle = ? and bID = ?', $v ); }
php
public function refreshBlockOutputCache() { $db = Loader::db(); $cID = $this->getBlockCollectionID(); $bID = $this->getBlockID(); $c = $this->getBlockCollectionObject(); $v = [$c->getCollectionID(), $c->getVersionID(), $this->getAreaHandle(), $bID]; $db->Execute( 'update CollectionVersionBlocksOutputCache set btCachedBlockOutputExpires = 0 where cID = ? and cvID = ? and arHandle = ? and bID = ?', $v ); }
[ "public", "function", "refreshBlockOutputCache", "(", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "cID", "=", "$", "this", "->", "getBlockCollectionID", "(", ")", ";", "$", "bID", "=", "$", "this", "->", "getBlockID", "(", ")", ";", "$", "c", "=", "$", "this", "->", "getBlockCollectionObject", "(", ")", ";", "$", "v", "=", "[", "$", "c", "->", "getCollectionID", "(", ")", ",", "$", "c", "->", "getVersionID", "(", ")", ",", "$", "this", "->", "getAreaHandle", "(", ")", ",", "$", "bID", "]", ";", "$", "db", "->", "Execute", "(", "'update CollectionVersionBlocksOutputCache set btCachedBlockOutputExpires = 0 where cID = ? and cvID = ? and arHandle = ? and bID = ?'", ",", "$", "v", ")", ";", "}" ]
Mark the output cache as expired.
[ "Mark", "the", "output", "cache", "as", "expired", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L1194-L1205
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.refreshBlockRecordCache
public function refreshBlockRecordCache() { $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $db->executeQuery('UPDATE Blocks SET btCachedBlockRecord = NULL WHERE bID = ?', [ $this->getBlockID(), ]); }
php
public function refreshBlockRecordCache() { $app = Application::getFacadeApplication(); $db = $app->make(Connection::class); $db->executeQuery('UPDATE Blocks SET btCachedBlockRecord = NULL WHERE bID = ?', [ $this->getBlockID(), ]); }
[ "public", "function", "refreshBlockRecordCache", "(", ")", "{", "$", "app", "=", "Application", "::", "getFacadeApplication", "(", ")", ";", "$", "db", "=", "$", "app", "->", "make", "(", "Connection", "::", "class", ")", ";", "$", "db", "->", "executeQuery", "(", "'UPDATE Blocks SET btCachedBlockRecord = NULL WHERE bID = ?'", ",", "[", "$", "this", "->", "getBlockID", "(", ")", ",", "]", ")", ";", "}" ]
Refreshes the block record cache The block record contains information from the block's $btTable. @since 8.4.1
[ "Refreshes", "the", "block", "record", "cache" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L1214-L1222
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.overrideAreaPermissions
public function overrideAreaPermissions() { if (!isset($this->cbOverrideAreaPermissions) || !$this->cbOverrideAreaPermissions) { $this->cbOverrideAreaPermissions = 0; } return $this->cbOverrideAreaPermissions; }
php
public function overrideAreaPermissions() { if (!isset($this->cbOverrideAreaPermissions) || !$this->cbOverrideAreaPermissions) { $this->cbOverrideAreaPermissions = 0; } return $this->cbOverrideAreaPermissions; }
[ "public", "function", "overrideAreaPermissions", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "cbOverrideAreaPermissions", ")", "||", "!", "$", "this", "->", "cbOverrideAreaPermissions", ")", "{", "$", "this", "->", "cbOverrideAreaPermissions", "=", "0", ";", "}", "return", "$", "this", "->", "cbOverrideAreaPermissions", ";", "}" ]
Area permissions are overridden? @var int|null 1 for true; 0/null for false
[ "Area", "permissions", "are", "overridden?" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L1229-L1236
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.revertToAreaPermissions
public function revertToAreaPermissions() { $c = $this->getBlockCollectionObject(); $db = Loader::db(); $v = [$c->getCollectionID(), $c->getVersionID(), $this->getBlockID()]; $db->query('delete from BlockPermissionAssignments where cID = ? and cvID = ? and bID = ?', $v); $v[] = $this->getAreaHandle(); $db->query( 'update CollectionVersionBlocks set cbOverrideAreaPermissions = 0 where cID = ? and (cvID = ? or cbIncludeAll=1) and bID = ? and arHandle = ?', $v ); }
php
public function revertToAreaPermissions() { $c = $this->getBlockCollectionObject(); $db = Loader::db(); $v = [$c->getCollectionID(), $c->getVersionID(), $this->getBlockID()]; $db->query('delete from BlockPermissionAssignments where cID = ? and cvID = ? and bID = ?', $v); $v[] = $this->getAreaHandle(); $db->query( 'update CollectionVersionBlocks set cbOverrideAreaPermissions = 0 where cID = ? and (cvID = ? or cbIncludeAll=1) and bID = ? and arHandle = ?', $v ); }
[ "public", "function", "revertToAreaPermissions", "(", ")", "{", "$", "c", "=", "$", "this", "->", "getBlockCollectionObject", "(", ")", ";", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "v", "=", "[", "$", "c", "->", "getCollectionID", "(", ")", ",", "$", "c", "->", "getVersionID", "(", ")", ",", "$", "this", "->", "getBlockID", "(", ")", "]", ";", "$", "db", "->", "query", "(", "'delete from BlockPermissionAssignments where cID = ? and cvID = ? and bID = ?'", ",", "$", "v", ")", ";", "$", "v", "[", "]", "=", "$", "this", "->", "getAreaHandle", "(", ")", ";", "$", "db", "->", "query", "(", "'update CollectionVersionBlocks set cbOverrideAreaPermissions = 0 where cID = ? and (cvID = ? or cbIncludeAll=1) and bID = ? and arHandle = ?'", ",", "$", "v", ")", ";", "}" ]
Revert the permission of the object to the one of the area that contains the block.
[ "Revert", "the", "permission", "of", "the", "object", "to", "the", "one", "of", "the", "area", "that", "contains", "the", "block", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L1264-L1277
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.ignorePageThemeGridFrameworkContainer
public function ignorePageThemeGridFrameworkContainer() { if ($this->overrideBlockTypeContainerSettings()) { return !$this->enableBlockContainer(); } $controller = $this->getController(); return $controller->ignorePageThemeGridFrameworkContainer(); }
php
public function ignorePageThemeGridFrameworkContainer() { if ($this->overrideBlockTypeContainerSettings()) { return !$this->enableBlockContainer(); } $controller = $this->getController(); return $controller->ignorePageThemeGridFrameworkContainer(); }
[ "public", "function", "ignorePageThemeGridFrameworkContainer", "(", ")", "{", "if", "(", "$", "this", "->", "overrideBlockTypeContainerSettings", "(", ")", ")", "{", "return", "!", "$", "this", "->", "enableBlockContainer", "(", ")", ";", "}", "$", "controller", "=", "$", "this", "->", "getController", "(", ")", ";", "return", "$", "controller", "->", "ignorePageThemeGridFrameworkContainer", "(", ")", ";", "}" ]
Should the view ignore the grid container? @return bool
[ "Should", "the", "view", "ignore", "the", "grid", "container?" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L1294-L1302
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.overrideBlockTypeContainerSettings
public function overrideBlockTypeContainerSettings() { if (!isset($this->cbOverrideBlockTypeContainerSettings) || !$this->cbOverrideBlockTypeContainerSettings) { $this->cbOverrideBlockTypeContainerSettings = 0; } return $this->cbOverrideBlockTypeContainerSettings; }
php
public function overrideBlockTypeContainerSettings() { if (!isset($this->cbOverrideBlockTypeContainerSettings) || !$this->cbOverrideBlockTypeContainerSettings) { $this->cbOverrideBlockTypeContainerSettings = 0; } return $this->cbOverrideBlockTypeContainerSettings; }
[ "public", "function", "overrideBlockTypeContainerSettings", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "cbOverrideBlockTypeContainerSettings", ")", "||", "!", "$", "this", "->", "cbOverrideBlockTypeContainerSettings", ")", "{", "$", "this", "->", "cbOverrideBlockTypeContainerSettings", "=", "0", ";", "}", "return", "$", "this", "->", "cbOverrideBlockTypeContainerSettings", ";", "}" ]
Should this instance override the grid container settings of the block controller? @return int 0/false: false, 1/true: true
[ "Should", "this", "instance", "override", "the", "grid", "container", "settings", "of", "the", "block", "controller?" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L1309-L1316
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.getController
public function getController() { if ( Config::get('concrete.cache.blocks') && isset($this->instance) && $this->instance->cacheBlockRecord() && is_object($this->instance->getBlockControllerData()) ) { $this->instance->__construct(); } else { $bt = $this->getBlockTypeObject(); $class = $bt->getBlockTypeClass(); $app = Facade::getFacadeApplication(); $this->instance = $app->build($class, [$this]); } $this->instance->setBlockObject($this); $this->instance->setAreaObject($this->getBlockAreaObject()); return $this->instance; }
php
public function getController() { if ( Config::get('concrete.cache.blocks') && isset($this->instance) && $this->instance->cacheBlockRecord() && is_object($this->instance->getBlockControllerData()) ) { $this->instance->__construct(); } else { $bt = $this->getBlockTypeObject(); $class = $bt->getBlockTypeClass(); $app = Facade::getFacadeApplication(); $this->instance = $app->build($class, [$this]); } $this->instance->setBlockObject($this); $this->instance->setAreaObject($this->getBlockAreaObject()); return $this->instance; }
[ "public", "function", "getController", "(", ")", "{", "if", "(", "Config", "::", "get", "(", "'concrete.cache.blocks'", ")", "&&", "isset", "(", "$", "this", "->", "instance", ")", "&&", "$", "this", "->", "instance", "->", "cacheBlockRecord", "(", ")", "&&", "is_object", "(", "$", "this", "->", "instance", "->", "getBlockControllerData", "(", ")", ")", ")", "{", "$", "this", "->", "instance", "->", "__construct", "(", ")", ";", "}", "else", "{", "$", "bt", "=", "$", "this", "->", "getBlockTypeObject", "(", ")", ";", "$", "class", "=", "$", "bt", "->", "getBlockTypeClass", "(", ")", ";", "$", "app", "=", "Facade", "::", "getFacadeApplication", "(", ")", ";", "$", "this", "->", "instance", "=", "$", "app", "->", "build", "(", "$", "class", ",", "[", "$", "this", "]", ")", ";", "}", "$", "this", "->", "instance", "->", "setBlockObject", "(", "$", "this", ")", ";", "$", "this", "->", "instance", "->", "setAreaObject", "(", "$", "this", "->", "getBlockAreaObject", "(", ")", ")", ";", "return", "$", "this", "->", "instance", ";", "}" ]
Get the block type controller. @return \Concrete\Core\Block\BlockController
[ "Get", "the", "block", "type", "controller", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L1418-L1437
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.display
public function display($view = 'view') { if ($this->getBlockTypeID() < 1) { return; } $bv = new BlockView($this); $bv->render($view); }
php
public function display($view = 'view') { if ($this->getBlockTypeID() < 1) { return; } $bv = new BlockView($this); $bv->render($view); }
[ "public", "function", "display", "(", "$", "view", "=", "'view'", ")", "{", "if", "(", "$", "this", "->", "getBlockTypeID", "(", ")", "<", "1", ")", "{", "return", ";", "}", "$", "bv", "=", "new", "BlockView", "(", "$", "this", ")", ";", "$", "bv", "->", "render", "(", "$", "view", ")", ";", "}" ]
Render the block display. @param string $view
[ "Render", "the", "block", "display", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L1444-L1452
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.update
public function update($data) { $db = Loader::db(); $dh = Loader::helper('date'); $bDateModified = $dh->getOverridableNow(); $bID = $this->getBlockID(); $v = [$bDateModified, $bID]; $q = 'update Blocks set bDateModified = ? where bID = ?'; $r = $db->prepare($q); $res = $db->execute($r, $v); $this->refreshBlockOutputCache(); $btID = $this->getBlockTypeID(); $bt = BlockType::getByID($btID); $class = $bt->getBlockTypeClass(); $app = Facade::getFacadeApplication(); $bc = $app->build($class, [$this]); $bc->save($data); }
php
public function update($data) { $db = Loader::db(); $dh = Loader::helper('date'); $bDateModified = $dh->getOverridableNow(); $bID = $this->getBlockID(); $v = [$bDateModified, $bID]; $q = 'update Blocks set bDateModified = ? where bID = ?'; $r = $db->prepare($q); $res = $db->execute($r, $v); $this->refreshBlockOutputCache(); $btID = $this->getBlockTypeID(); $bt = BlockType::getByID($btID); $class = $bt->getBlockTypeClass(); $app = Facade::getFacadeApplication(); $bc = $app->build($class, [$this]); $bc->save($data); }
[ "public", "function", "update", "(", "$", "data", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "dh", "=", "Loader", "::", "helper", "(", "'date'", ")", ";", "$", "bDateModified", "=", "$", "dh", "->", "getOverridableNow", "(", ")", ";", "$", "bID", "=", "$", "this", "->", "getBlockID", "(", ")", ";", "$", "v", "=", "[", "$", "bDateModified", ",", "$", "bID", "]", ";", "$", "q", "=", "'update Blocks set bDateModified = ? where bID = ?'", ";", "$", "r", "=", "$", "db", "->", "prepare", "(", "$", "q", ")", ";", "$", "res", "=", "$", "db", "->", "execute", "(", "$", "r", ",", "$", "v", ")", ";", "$", "this", "->", "refreshBlockOutputCache", "(", ")", ";", "$", "btID", "=", "$", "this", "->", "getBlockTypeID", "(", ")", ";", "$", "bt", "=", "BlockType", "::", "getByID", "(", "$", "btID", ")", ";", "$", "class", "=", "$", "bt", "->", "getBlockTypeClass", "(", ")", ";", "$", "app", "=", "Facade", "::", "getFacadeApplication", "(", ")", ";", "$", "bc", "=", "$", "app", "->", "build", "(", "$", "class", ",", "[", "$", "this", "]", ")", ";", "$", "bc", "->", "save", "(", "$", "data", ")", ";", "}" ]
Updates fields common to every block. @param array $data the block type-specific data to be saved
[ "Updates", "fields", "common", "to", "every", "block", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L1472-L1493
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.updateBlockInformation
public function updateBlockInformation($data) { // this is the function that $db = Loader::db(); $dh = Loader::helper('date'); $dt = $dh->getOverridableNow(); $bName = $this->getBlockName(); $bFilename = $this->getBlockFilename(); if (isset($data['bName'])) { $bName = $data['bName']; } if (isset($data['bFilename'])) { $bFilename = $data['bFilename']; } $v = [$bName, $bFilename, $dt, $this->getBlockID()]; $q = 'update Blocks set bName = ?, bFilename = ?, bDateModified = ? where bID = ?'; $r = $db->prepare($q); $res = $db->execute($r, $v); $this->refreshBlockOutputCache(); }
php
public function updateBlockInformation($data) { // this is the function that $db = Loader::db(); $dh = Loader::helper('date'); $dt = $dh->getOverridableNow(); $bName = $this->getBlockName(); $bFilename = $this->getBlockFilename(); if (isset($data['bName'])) { $bName = $data['bName']; } if (isset($data['bFilename'])) { $bFilename = $data['bFilename']; } $v = [$bName, $bFilename, $dt, $this->getBlockID()]; $q = 'update Blocks set bName = ?, bFilename = ?, bDateModified = ? where bID = ?'; $r = $db->prepare($q); $res = $db->execute($r, $v); $this->refreshBlockOutputCache(); }
[ "public", "function", "updateBlockInformation", "(", "$", "data", ")", "{", "// this is the function that", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "dh", "=", "Loader", "::", "helper", "(", "'date'", ")", ";", "$", "dt", "=", "$", "dh", "->", "getOverridableNow", "(", ")", ";", "$", "bName", "=", "$", "this", "->", "getBlockName", "(", ")", ";", "$", "bFilename", "=", "$", "this", "->", "getBlockFilename", "(", ")", ";", "if", "(", "isset", "(", "$", "data", "[", "'bName'", "]", ")", ")", "{", "$", "bName", "=", "$", "data", "[", "'bName'", "]", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "'bFilename'", "]", ")", ")", "{", "$", "bFilename", "=", "$", "data", "[", "'bFilename'", "]", ";", "}", "$", "v", "=", "[", "$", "bName", ",", "$", "bFilename", ",", "$", "dt", ",", "$", "this", "->", "getBlockID", "(", ")", "]", ";", "$", "q", "=", "'update Blocks set bName = ?, bFilename = ?, bDateModified = ? where bID = ?'", ";", "$", "r", "=", "$", "db", "->", "prepare", "(", "$", "q", ")", ";", "$", "res", "=", "$", "db", "->", "execute", "(", "$", "r", ",", "$", "v", ")", ";", "$", "this", "->", "refreshBlockOutputCache", "(", ")", ";", "}" ]
Update the block information, like its block filename, and block name. @param array $data Valid keys: - 'bName' to update the block name - 'bFilename' to update the block custom template
[ "Update", "the", "block", "information", "like", "its", "block", "filename", "and", "block", "name", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L1502-L1524
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.alias
public function alias($c) { $app = Application::getFacadeApplication(); $cloner = $app->make(Cloner::class); $cloner->cloneBlock($this, $c); }
php
public function alias($c) { $app = Application::getFacadeApplication(); $cloner = $app->make(Cloner::class); $cloner->cloneBlock($this, $c); }
[ "public", "function", "alias", "(", "$", "c", ")", "{", "$", "app", "=", "Application", "::", "getFacadeApplication", "(", ")", ";", "$", "cloner", "=", "$", "app", "->", "make", "(", "Cloner", "::", "class", ")", ";", "$", "cloner", "->", "cloneBlock", "(", "$", "this", ",", "$", "c", ")", ";", "}" ]
Create an alias of the block, attached to this collection, within the CollectionVersionBlocks table. Additionally, this command grabs the permissions from the original record in the CollectionVersionBlocks table, and attaches them to the new one. @param \Concrete\Core\Page\Collection\Collection $c The collection to add the block alias to
[ "Create", "an", "alias", "of", "the", "block", "attached", "to", "this", "collection", "within", "the", "CollectionVersionBlocks", "table", ".", "Additionally", "this", "command", "grabs", "the", "permissions", "from", "the", "original", "record", "in", "the", "CollectionVersionBlocks", "table", "and", "attaches", "them", "to", "the", "new", "one", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L1704-L1709
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.export
public function export($node, $exportType = 'full') { if (!$this->isAliasOfMasterCollection() || (($this->c instanceof Page) && $this->c->isMasterCollection())) { // We have the OR up here so that master collections that you have duplicated from other // master collections export properly. $blockNode = $node->addChild('block'); $blockNode->addAttribute('type', $this->getBlockTypeHandle()); $blockNode->addAttribute('name', $this->getBlockName()); if ($this->getBlockFilename() != '') { $blockNode->addAttribute('custom-template', $this->getBlockFilename()); } if ($this->overrideBlockTypeContainerSettings()) { $blockNode->addAttribute('custom-container-settings', $this->enableBlockContainer() ? 1 : 0); } if (($this->c instanceof Page) && $this->c->isMasterCollection()) { $mcBlockID = Loader::helper('validation/identifier')->getString(8); ContentExporter::addMasterCollectionBlockID($this, $mcBlockID); $blockNode->addAttribute('mc-block-id', $mcBlockID); } if ($exportType == 'full') { $style = $this->getCustomStyle(); if (is_object($style)) { $set = $style->getStyleSet(); $set->export($blockNode); } if ($this->overrideBlockTypeCacheSettings()) { $settings = $this->getBlockCacheSettingsObject(); $blockNode['cache-output'] = $settings->cacheBlockOutput(); $blockNode['cache-output-lifetime'] = $settings->getBlockOutputCacheLifetime(); $blockNode['cache-output-on-post'] = $settings->cacheBlockOutputOnPost(); $blockNode['cache-output-for-registered-users'] = $settings->cacheBlockOutputForRegisteredUsers(); } $bc = $this->getController(); $bc->export($blockNode); } } else { $blockNode = $node->addChild('block'); $blockNode->addAttribute('mc-block-id', ContentExporter::getMasterCollectionTemporaryBlockID($this)); } }
php
public function export($node, $exportType = 'full') { if (!$this->isAliasOfMasterCollection() || (($this->c instanceof Page) && $this->c->isMasterCollection())) { // We have the OR up here so that master collections that you have duplicated from other // master collections export properly. $blockNode = $node->addChild('block'); $blockNode->addAttribute('type', $this->getBlockTypeHandle()); $blockNode->addAttribute('name', $this->getBlockName()); if ($this->getBlockFilename() != '') { $blockNode->addAttribute('custom-template', $this->getBlockFilename()); } if ($this->overrideBlockTypeContainerSettings()) { $blockNode->addAttribute('custom-container-settings', $this->enableBlockContainer() ? 1 : 0); } if (($this->c instanceof Page) && $this->c->isMasterCollection()) { $mcBlockID = Loader::helper('validation/identifier')->getString(8); ContentExporter::addMasterCollectionBlockID($this, $mcBlockID); $blockNode->addAttribute('mc-block-id', $mcBlockID); } if ($exportType == 'full') { $style = $this->getCustomStyle(); if (is_object($style)) { $set = $style->getStyleSet(); $set->export($blockNode); } if ($this->overrideBlockTypeCacheSettings()) { $settings = $this->getBlockCacheSettingsObject(); $blockNode['cache-output'] = $settings->cacheBlockOutput(); $blockNode['cache-output-lifetime'] = $settings->getBlockOutputCacheLifetime(); $blockNode['cache-output-on-post'] = $settings->cacheBlockOutputOnPost(); $blockNode['cache-output-for-registered-users'] = $settings->cacheBlockOutputForRegisteredUsers(); } $bc = $this->getController(); $bc->export($blockNode); } } else { $blockNode = $node->addChild('block'); $blockNode->addAttribute('mc-block-id', ContentExporter::getMasterCollectionTemporaryBlockID($this)); } }
[ "public", "function", "export", "(", "$", "node", ",", "$", "exportType", "=", "'full'", ")", "{", "if", "(", "!", "$", "this", "->", "isAliasOfMasterCollection", "(", ")", "||", "(", "(", "$", "this", "->", "c", "instanceof", "Page", ")", "&&", "$", "this", "->", "c", "->", "isMasterCollection", "(", ")", ")", ")", "{", "// We have the OR up here so that master collections that you have duplicated from other", "// master collections export properly.", "$", "blockNode", "=", "$", "node", "->", "addChild", "(", "'block'", ")", ";", "$", "blockNode", "->", "addAttribute", "(", "'type'", ",", "$", "this", "->", "getBlockTypeHandle", "(", ")", ")", ";", "$", "blockNode", "->", "addAttribute", "(", "'name'", ",", "$", "this", "->", "getBlockName", "(", ")", ")", ";", "if", "(", "$", "this", "->", "getBlockFilename", "(", ")", "!=", "''", ")", "{", "$", "blockNode", "->", "addAttribute", "(", "'custom-template'", ",", "$", "this", "->", "getBlockFilename", "(", ")", ")", ";", "}", "if", "(", "$", "this", "->", "overrideBlockTypeContainerSettings", "(", ")", ")", "{", "$", "blockNode", "->", "addAttribute", "(", "'custom-container-settings'", ",", "$", "this", "->", "enableBlockContainer", "(", ")", "?", "1", ":", "0", ")", ";", "}", "if", "(", "(", "$", "this", "->", "c", "instanceof", "Page", ")", "&&", "$", "this", "->", "c", "->", "isMasterCollection", "(", ")", ")", "{", "$", "mcBlockID", "=", "Loader", "::", "helper", "(", "'validation/identifier'", ")", "->", "getString", "(", "8", ")", ";", "ContentExporter", "::", "addMasterCollectionBlockID", "(", "$", "this", ",", "$", "mcBlockID", ")", ";", "$", "blockNode", "->", "addAttribute", "(", "'mc-block-id'", ",", "$", "mcBlockID", ")", ";", "}", "if", "(", "$", "exportType", "==", "'full'", ")", "{", "$", "style", "=", "$", "this", "->", "getCustomStyle", "(", ")", ";", "if", "(", "is_object", "(", "$", "style", ")", ")", "{", "$", "set", "=", "$", "style", "->", "getStyleSet", "(", ")", ";", "$", "set", "->", "export", "(", "$", "blockNode", ")", ";", "}", "if", "(", "$", "this", "->", "overrideBlockTypeCacheSettings", "(", ")", ")", "{", "$", "settings", "=", "$", "this", "->", "getBlockCacheSettingsObject", "(", ")", ";", "$", "blockNode", "[", "'cache-output'", "]", "=", "$", "settings", "->", "cacheBlockOutput", "(", ")", ";", "$", "blockNode", "[", "'cache-output-lifetime'", "]", "=", "$", "settings", "->", "getBlockOutputCacheLifetime", "(", ")", ";", "$", "blockNode", "[", "'cache-output-on-post'", "]", "=", "$", "settings", "->", "cacheBlockOutputOnPost", "(", ")", ";", "$", "blockNode", "[", "'cache-output-for-registered-users'", "]", "=", "$", "settings", "->", "cacheBlockOutputForRegisteredUsers", "(", ")", ";", "}", "$", "bc", "=", "$", "this", "->", "getController", "(", ")", ";", "$", "bc", "->", "export", "(", "$", "blockNode", ")", ";", "}", "}", "else", "{", "$", "blockNode", "=", "$", "node", "->", "addChild", "(", "'block'", ")", ";", "$", "blockNode", "->", "addAttribute", "(", "'mc-block-id'", ",", "ContentExporter", "::", "getMasterCollectionTemporaryBlockID", "(", "$", "this", ")", ")", ";", "}", "}" ]
Export the data associated to this block to an XML node. @param \SimpleXMLElement $node the parent node where we'll append the XML node to @param string $exportType set to 'full' to export cache and custom style settings too
[ "Export", "the", "data", "associated", "to", "this", "block", "to", "an", "XML", "node", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L1819-L1859
train
concrete5/concrete5
concrete/src/Block/Block.php
Block.queueForDefaultsUpdate
public function queueForDefaultsUpdate($data, $queue, $includeThisBlock = true) { $blocks = []; $db = \Database::connection(); $rows = $db->GetAll('select cID, max(cvID) as cvID, cbRelationID from CollectionVersionBlocks where cbRelationID = ? group by cID order by cID', [$this->getBlockRelationID()]); $oc = $this->getBlockCollectionObject(); $ocID = $oc->getCollectionID(); $ocvID = $oc->getVersionID(); foreach ($rows as $row) { $row2 = $db->GetRow('select bID, arHandle from CollectionVersionBlocks where cID = ? and cvID = ? and cbRelationID = ?', [ $row['cID'], $row['cvID'], $row['cbRelationID'], ]); if ($includeThisBlock || ($row['cID'] != $ocID || $row['cvID'] != $ocvID || $row2['arHandle'] != $this->getAreaHandle() || $row2['bID'] != $this->getBlockID())) { $blocks[] = [ 'cID' => $row['cID'], 'cvID' => $row['cvID'], 'cbRelationID' => $row['cbRelationID'], 'bID' => $row2['bID'], 'arHandle' => $row2['arHandle'], 'data' => $data, ]; } } $name = $queue->getName(); $queue->deleteQueue(); $queue = Queue::get($name); foreach ($blocks as $block) { $queue->send(serialize($block)); } return $queue; }
php
public function queueForDefaultsUpdate($data, $queue, $includeThisBlock = true) { $blocks = []; $db = \Database::connection(); $rows = $db->GetAll('select cID, max(cvID) as cvID, cbRelationID from CollectionVersionBlocks where cbRelationID = ? group by cID order by cID', [$this->getBlockRelationID()]); $oc = $this->getBlockCollectionObject(); $ocID = $oc->getCollectionID(); $ocvID = $oc->getVersionID(); foreach ($rows as $row) { $row2 = $db->GetRow('select bID, arHandle from CollectionVersionBlocks where cID = ? and cvID = ? and cbRelationID = ?', [ $row['cID'], $row['cvID'], $row['cbRelationID'], ]); if ($includeThisBlock || ($row['cID'] != $ocID || $row['cvID'] != $ocvID || $row2['arHandle'] != $this->getAreaHandle() || $row2['bID'] != $this->getBlockID())) { $blocks[] = [ 'cID' => $row['cID'], 'cvID' => $row['cvID'], 'cbRelationID' => $row['cbRelationID'], 'bID' => $row2['bID'], 'arHandle' => $row2['arHandle'], 'data' => $data, ]; } } $name = $queue->getName(); $queue->deleteQueue(); $queue = Queue::get($name); foreach ($blocks as $block) { $queue->send(serialize($block)); } return $queue; }
[ "public", "function", "queueForDefaultsUpdate", "(", "$", "data", ",", "$", "queue", ",", "$", "includeThisBlock", "=", "true", ")", "{", "$", "blocks", "=", "[", "]", ";", "$", "db", "=", "\\", "Database", "::", "connection", "(", ")", ";", "$", "rows", "=", "$", "db", "->", "GetAll", "(", "'select cID, max(cvID) as cvID, cbRelationID from CollectionVersionBlocks where cbRelationID = ? group by cID order by cID'", ",", "[", "$", "this", "->", "getBlockRelationID", "(", ")", "]", ")", ";", "$", "oc", "=", "$", "this", "->", "getBlockCollectionObject", "(", ")", ";", "$", "ocID", "=", "$", "oc", "->", "getCollectionID", "(", ")", ";", "$", "ocvID", "=", "$", "oc", "->", "getVersionID", "(", ")", ";", "foreach", "(", "$", "rows", "as", "$", "row", ")", "{", "$", "row2", "=", "$", "db", "->", "GetRow", "(", "'select bID, arHandle from CollectionVersionBlocks where cID = ? and cvID = ? and cbRelationID = ?'", ",", "[", "$", "row", "[", "'cID'", "]", ",", "$", "row", "[", "'cvID'", "]", ",", "$", "row", "[", "'cbRelationID'", "]", ",", "]", ")", ";", "if", "(", "$", "includeThisBlock", "||", "(", "$", "row", "[", "'cID'", "]", "!=", "$", "ocID", "||", "$", "row", "[", "'cvID'", "]", "!=", "$", "ocvID", "||", "$", "row2", "[", "'arHandle'", "]", "!=", "$", "this", "->", "getAreaHandle", "(", ")", "||", "$", "row2", "[", "'bID'", "]", "!=", "$", "this", "->", "getBlockID", "(", ")", ")", ")", "{", "$", "blocks", "[", "]", "=", "[", "'cID'", "=>", "$", "row", "[", "'cID'", "]", ",", "'cvID'", "=>", "$", "row", "[", "'cvID'", "]", ",", "'cbRelationID'", "=>", "$", "row", "[", "'cbRelationID'", "]", ",", "'bID'", "=>", "$", "row2", "[", "'bID'", "]", ",", "'arHandle'", "=>", "$", "row2", "[", "'arHandle'", "]", ",", "'data'", "=>", "$", "data", ",", "]", ";", "}", "}", "$", "name", "=", "$", "queue", "->", "getName", "(", ")", ";", "$", "queue", "->", "deleteQueue", "(", ")", ";", "$", "queue", "=", "Queue", "::", "get", "(", "$", "name", ")", ";", "foreach", "(", "$", "blocks", "as", "$", "block", ")", "{", "$", "queue", "->", "send", "(", "serialize", "(", "$", "block", ")", ")", ";", "}", "return", "$", "queue", ";", "}" ]
Populate the queue to be used to work on the block and it aliases. @param mixed $data Custom data to be added to the queue messages @param \ZendQueue\Queue $queue The queue to add the messages too (it will be emptied before adding the new messages) @param bool $includeThisBlock Include this block instance in the queue? @return \ZendQueue\Queue
[ "Populate", "the", "queue", "to", "be", "used", "to", "work", "on", "the", "block", "and", "it", "aliases", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Block/Block.php#L1949-L1985
train
concrete5/concrete5
concrete/src/Page/Collection/Version/Version.php
Version.refreshCache
public function refreshCache() { $app = Facade::getFacadeApplication(); $cache = $app->make('cache/request'); if ($cache->isEnabled()) { $cache->delete('page/'.$this->getCollectionID()); } }
php
public function refreshCache() { $app = Facade::getFacadeApplication(); $cache = $app->make('cache/request'); if ($cache->isEnabled()) { $cache->delete('page/'.$this->getCollectionID()); } }
[ "public", "function", "refreshCache", "(", ")", "{", "$", "app", "=", "Facade", "::", "getFacadeApplication", "(", ")", ";", "$", "cache", "=", "$", "app", "->", "make", "(", "'cache/request'", ")", ";", "if", "(", "$", "cache", "->", "isEnabled", "(", ")", ")", "{", "$", "cache", "->", "delete", "(", "'page/'", ".", "$", "this", "->", "getCollectionID", "(", ")", ")", ";", "}", "}" ]
Clear the cache for this collection.
[ "Clear", "the", "cache", "for", "this", "collection", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Version/Version.php#L217-L224
train
concrete5/concrete5
concrete/src/Page/Collection/Version/Version.php
Version.get
public static function get($c, $cvID) { $app = Facade::getFacadeApplication(); $db = $app->make('database')->connection(); $now = $app->make('date')->getOverridableNow(); $cID = false; if ($c instanceof \Concrete\Core\Page\Page) { $cID = $c->getCollectionPointerID(); } if (!$cID) { $cID = $c->getCollectionID(); } $v = array($cID); $q = "select * from CollectionVersions where cID = ?"; switch ($cvID) { case 'ACTIVE': $q .= ' and cvIsApproved = 1 and (cvPublishDate is null or cvPublishDate <= ?) and (cvPublishEndDate is null or cvPublishEndDate >= ?) order by cvPublishDate desc limit 1'; $v[] = $now; $v[] = $now; break; case 'SCHEDULED': $q .= ' and cvIsApproved = 1 and (cvPublishDate is not null and cvPublishDate > ?) order by cvPublishDate limit 1'; $v[] = $now; break; case 'RECENT': $q .= ' order by cvID desc limit 1'; break; case 'RECENT_UNAPPROVED': $q .= 'and (cvIsApproved = 0 or cvIsApproved IS NULL) order by cvID desc limit 1'; break; default: $v[] = $cvID; $q .= ' and cvID = ?'; break; } $row = $db->fetchAssoc($q, $v); $cv = new static(); if ($row !== false) { $cv->setPropertiesFromArray($row); } $cv->cID = $c->getCollectionID(); return $cv; }
php
public static function get($c, $cvID) { $app = Facade::getFacadeApplication(); $db = $app->make('database')->connection(); $now = $app->make('date')->getOverridableNow(); $cID = false; if ($c instanceof \Concrete\Core\Page\Page) { $cID = $c->getCollectionPointerID(); } if (!$cID) { $cID = $c->getCollectionID(); } $v = array($cID); $q = "select * from CollectionVersions where cID = ?"; switch ($cvID) { case 'ACTIVE': $q .= ' and cvIsApproved = 1 and (cvPublishDate is null or cvPublishDate <= ?) and (cvPublishEndDate is null or cvPublishEndDate >= ?) order by cvPublishDate desc limit 1'; $v[] = $now; $v[] = $now; break; case 'SCHEDULED': $q .= ' and cvIsApproved = 1 and (cvPublishDate is not null and cvPublishDate > ?) order by cvPublishDate limit 1'; $v[] = $now; break; case 'RECENT': $q .= ' order by cvID desc limit 1'; break; case 'RECENT_UNAPPROVED': $q .= 'and (cvIsApproved = 0 or cvIsApproved IS NULL) order by cvID desc limit 1'; break; default: $v[] = $cvID; $q .= ' and cvID = ?'; break; } $row = $db->fetchAssoc($q, $v); $cv = new static(); if ($row !== false) { $cv->setPropertiesFromArray($row); } $cv->cID = $c->getCollectionID(); return $cv; }
[ "public", "static", "function", "get", "(", "$", "c", ",", "$", "cvID", ")", "{", "$", "app", "=", "Facade", "::", "getFacadeApplication", "(", ")", ";", "$", "db", "=", "$", "app", "->", "make", "(", "'database'", ")", "->", "connection", "(", ")", ";", "$", "now", "=", "$", "app", "->", "make", "(", "'date'", ")", "->", "getOverridableNow", "(", ")", ";", "$", "cID", "=", "false", ";", "if", "(", "$", "c", "instanceof", "\\", "Concrete", "\\", "Core", "\\", "Page", "\\", "Page", ")", "{", "$", "cID", "=", "$", "c", "->", "getCollectionPointerID", "(", ")", ";", "}", "if", "(", "!", "$", "cID", ")", "{", "$", "cID", "=", "$", "c", "->", "getCollectionID", "(", ")", ";", "}", "$", "v", "=", "array", "(", "$", "cID", ")", ";", "$", "q", "=", "\"select * from CollectionVersions where cID = ?\"", ";", "switch", "(", "$", "cvID", ")", "{", "case", "'ACTIVE'", ":", "$", "q", ".=", "' and cvIsApproved = 1 and (cvPublishDate is null or cvPublishDate <= ?) and (cvPublishEndDate is null or cvPublishEndDate >= ?) order by cvPublishDate desc limit 1'", ";", "$", "v", "[", "]", "=", "$", "now", ";", "$", "v", "[", "]", "=", "$", "now", ";", "break", ";", "case", "'SCHEDULED'", ":", "$", "q", ".=", "' and cvIsApproved = 1 and (cvPublishDate is not null and cvPublishDate > ?) order by cvPublishDate limit 1'", ";", "$", "v", "[", "]", "=", "$", "now", ";", "break", ";", "case", "'RECENT'", ":", "$", "q", ".=", "' order by cvID desc limit 1'", ";", "break", ";", "case", "'RECENT_UNAPPROVED'", ":", "$", "q", ".=", "'and (cvIsApproved = 0 or cvIsApproved IS NULL) order by cvID desc limit 1'", ";", "break", ";", "default", ":", "$", "v", "[", "]", "=", "$", "cvID", ";", "$", "q", ".=", "' and cvID = ?'", ";", "break", ";", "}", "$", "row", "=", "$", "db", "->", "fetchAssoc", "(", "$", "q", ",", "$", "v", ")", ";", "$", "cv", "=", "new", "static", "(", ")", ";", "if", "(", "$", "row", "!==", "false", ")", "{", "$", "cv", "->", "setPropertiesFromArray", "(", "$", "row", ")", ";", "}", "$", "cv", "->", "cID", "=", "$", "c", "->", "getCollectionID", "(", ")", ";", "return", "$", "cv", ";", "}" ]
Get a Version instance given the Collection and a version identifier. @param \Concrete\Core\Page\Collection\Collection $c the collection for which you want the version @param int|string $cvID the specific version ID (or 'ACTIVE', 'SCHEDULED', 'RECENT') @return static
[ "Get", "a", "Version", "instance", "given", "the", "Collection", "and", "a", "version", "identifier", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Version/Version.php#L234-L283
train
concrete5/concrete5
concrete/src/Page/Collection/Version/Version.php
Version.isApprovedNow
public function isApprovedNow($when = null) { if (!$this->isApproved()) { return false; } $start = $this->getPublishDate(); $end = $this->getPublishEndDate(); if (!$start && !$end) { return true; } $dh = Facade::getFacadeApplication()->make('date'); if ($when) { $when = $dh->toDB($when); } if (!$when) { $when = $dh->getOverridableNow(); } if ($start && $start > $when) { return false; } if ($end && $end < $when) { return false; } return true; }
php
public function isApprovedNow($when = null) { if (!$this->isApproved()) { return false; } $start = $this->getPublishDate(); $end = $this->getPublishEndDate(); if (!$start && !$end) { return true; } $dh = Facade::getFacadeApplication()->make('date'); if ($when) { $when = $dh->toDB($when); } if (!$when) { $when = $dh->getOverridableNow(); } if ($start && $start > $when) { return false; } if ($end && $end < $when) { return false; } return true; }
[ "public", "function", "isApprovedNow", "(", "$", "when", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "isApproved", "(", ")", ")", "{", "return", "false", ";", "}", "$", "start", "=", "$", "this", "->", "getPublishDate", "(", ")", ";", "$", "end", "=", "$", "this", "->", "getPublishEndDate", "(", ")", ";", "if", "(", "!", "$", "start", "&&", "!", "$", "end", ")", "{", "return", "true", ";", "}", "$", "dh", "=", "Facade", "::", "getFacadeApplication", "(", ")", "->", "make", "(", "'date'", ")", ";", "if", "(", "$", "when", ")", "{", "$", "when", "=", "$", "dh", "->", "toDB", "(", "$", "when", ")", ";", "}", "if", "(", "!", "$", "when", ")", "{", "$", "when", "=", "$", "dh", "->", "getOverridableNow", "(", ")", ";", "}", "if", "(", "$", "start", "&&", "$", "start", ">", "$", "when", ")", "{", "return", "false", ";", "}", "if", "(", "$", "end", "&&", "$", "end", "<", "$", "when", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Is this version approved and in the publish interval? @var string|int|\DateTime|null $when a date/time representation (empty: now) @return bool
[ "Is", "this", "version", "approved", "and", "in", "the", "publish", "interval?" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Version/Version.php#L346-L371
train
concrete5/concrete5
concrete/src/Page/Collection/Version/Version.php
Version.isMostRecent
public function isMostRecent() { if (!isset($this->isMostRecent)) { $app = Facade::getFacadeApplication(); $db = $app->make('database')->connection(); $cvID = $db->fetchColumn('select cvID from CollectionVersions where cID = ? order by cvID desc', array($this->cID)); $this->isMostRecent = ($cvID == $this->cvID); } return $this->isMostRecent; }
php
public function isMostRecent() { if (!isset($this->isMostRecent)) { $app = Facade::getFacadeApplication(); $db = $app->make('database')->connection(); $cvID = $db->fetchColumn('select cvID from CollectionVersions where cID = ? order by cvID desc', array($this->cID)); $this->isMostRecent = ($cvID == $this->cvID); } return $this->isMostRecent; }
[ "public", "function", "isMostRecent", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "isMostRecent", ")", ")", "{", "$", "app", "=", "Facade", "::", "getFacadeApplication", "(", ")", ";", "$", "db", "=", "$", "app", "->", "make", "(", "'database'", ")", "->", "connection", "(", ")", ";", "$", "cvID", "=", "$", "db", "->", "fetchColumn", "(", "'select cvID from CollectionVersions where cID = ? order by cvID desc'", ",", "array", "(", "$", "this", "->", "cID", ")", ")", ";", "$", "this", "->", "isMostRecent", "=", "(", "$", "cvID", "==", "$", "this", "->", "cvID", ")", ";", "}", "return", "$", "this", "->", "isMostRecent", ";", "}" ]
Is this the most recent version? @return bool
[ "Is", "this", "the", "most", "recent", "version?" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Version/Version.php#L402-L412
train
concrete5/concrete5
concrete/src/Page/Collection/Version/Version.php
Version.getCustomAreaStyles
public function getCustomAreaStyles() { if (!isset($this->customAreaStyles)) { $app = Facade::getFacadeApplication(); $db = $app->make('database')->connection(); $r = $db->fetchAll('select issID, arHandle from CollectionVersionAreaStyles where cID = ? and cvID = ?', array( $this->getCollectionID(), $this->cvID, )); $this->customAreaStyles = array(); foreach ($r as $styles) { $this->customAreaStyles[$styles['arHandle']] = $styles['issID']; } } return $this->customAreaStyles; }
php
public function getCustomAreaStyles() { if (!isset($this->customAreaStyles)) { $app = Facade::getFacadeApplication(); $db = $app->make('database')->connection(); $r = $db->fetchAll('select issID, arHandle from CollectionVersionAreaStyles where cID = ? and cvID = ?', array( $this->getCollectionID(), $this->cvID, )); $this->customAreaStyles = array(); foreach ($r as $styles) { $this->customAreaStyles[$styles['arHandle']] = $styles['issID']; } } return $this->customAreaStyles; }
[ "public", "function", "getCustomAreaStyles", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "customAreaStyles", ")", ")", "{", "$", "app", "=", "Facade", "::", "getFacadeApplication", "(", ")", ";", "$", "db", "=", "$", "app", "->", "make", "(", "'database'", ")", "->", "connection", "(", ")", ";", "$", "r", "=", "$", "db", "->", "fetchAll", "(", "'select issID, arHandle from CollectionVersionAreaStyles where cID = ? and cvID = ?'", ",", "array", "(", "$", "this", "->", "getCollectionID", "(", ")", ",", "$", "this", "->", "cvID", ",", ")", ")", ";", "$", "this", "->", "customAreaStyles", "=", "array", "(", ")", ";", "foreach", "(", "$", "r", "as", "$", "styles", ")", "{", "$", "this", "->", "customAreaStyles", "[", "$", "styles", "[", "'arHandle'", "]", "]", "=", "$", "styles", "[", "'issID'", "]", ";", "}", "}", "return", "$", "this", "->", "customAreaStyles", ";", "}" ]
Get the custom area style IDs. @return array key: area handle, value: the inline stle set ID
[ "Get", "the", "custom", "area", "style", "IDs", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Version/Version.php#L523-L539
train
concrete5/concrete5
concrete/src/Page/Collection/Version/Version.php
Version.setComment
public function setComment($comment) { $thisCVID = $this->getVersionID(); $comment = ($comment != null) ? $comment : "Version {$thisCVID}"; $v = array( $comment, $thisCVID, $this->cID, ); $app = Facade::getFacadeApplication(); $db = $app->make('database')->connection(); $q = "update CollectionVersions set cvComments = ? where cvID = ? and cID = ?"; $db->executeQuery($q, $v); $this->cvComments = $comment; }
php
public function setComment($comment) { $thisCVID = $this->getVersionID(); $comment = ($comment != null) ? $comment : "Version {$thisCVID}"; $v = array( $comment, $thisCVID, $this->cID, ); $app = Facade::getFacadeApplication(); $db = $app->make('database')->connection(); $q = "update CollectionVersions set cvComments = ? where cvID = ? and cID = ?"; $db->executeQuery($q, $v); $this->cvComments = $comment; }
[ "public", "function", "setComment", "(", "$", "comment", ")", "{", "$", "thisCVID", "=", "$", "this", "->", "getVersionID", "(", ")", ";", "$", "comment", "=", "(", "$", "comment", "!=", "null", ")", "?", "$", "comment", ":", "\"Version {$thisCVID}\"", ";", "$", "v", "=", "array", "(", "$", "comment", ",", "$", "thisCVID", ",", "$", "this", "->", "cID", ",", ")", ";", "$", "app", "=", "Facade", "::", "getFacadeApplication", "(", ")", ";", "$", "db", "=", "$", "app", "->", "make", "(", "'database'", ")", "->", "connection", "(", ")", ";", "$", "q", "=", "\"update CollectionVersions set cvComments = ? where cvID = ? and cID = ?\"", ";", "$", "db", "->", "executeQuery", "(", "$", "q", ",", "$", "v", ")", ";", "$", "this", "->", "cvComments", "=", "$", "comment", ";", "}" ]
Set the collection version comments. @param string $comment
[ "Set", "the", "collection", "version", "comments", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Version/Version.php#L570-L584
train
concrete5/concrete5
concrete/src/Page/Collection/Version/Version.php
Version.createNew
public function createNew($versionComments) { $app = Facade::getFacadeApplication(); $cloner = $app->make(Cloner::class); $clonerOptions = $app->build(ClonerOptions::class) ->setCopyContents(false) ->setVersionComments($versionComments) ; $myCollection = Page::getByID($this->getCollectionID()); $newVersion = $cloner->cloneCollectionVersion($this, $myCollection, $clonerOptions); return $newVersion; }
php
public function createNew($versionComments) { $app = Facade::getFacadeApplication(); $cloner = $app->make(Cloner::class); $clonerOptions = $app->build(ClonerOptions::class) ->setCopyContents(false) ->setVersionComments($versionComments) ; $myCollection = Page::getByID($this->getCollectionID()); $newVersion = $cloner->cloneCollectionVersion($this, $myCollection, $clonerOptions); return $newVersion; }
[ "public", "function", "createNew", "(", "$", "versionComments", ")", "{", "$", "app", "=", "Facade", "::", "getFacadeApplication", "(", ")", ";", "$", "cloner", "=", "$", "app", "->", "make", "(", "Cloner", "::", "class", ")", ";", "$", "clonerOptions", "=", "$", "app", "->", "build", "(", "ClonerOptions", "::", "class", ")", "->", "setCopyContents", "(", "false", ")", "->", "setVersionComments", "(", "$", "versionComments", ")", ";", "$", "myCollection", "=", "Page", "::", "getByID", "(", "$", "this", "->", "getCollectionID", "(", ")", ")", ";", "$", "newVersion", "=", "$", "cloner", "->", "cloneCollectionVersion", "(", "$", "this", ",", "$", "myCollection", ",", "$", "clonerOptions", ")", ";", "return", "$", "newVersion", ";", "}" ]
Create a new version for the same collection as this collection version. @param string $versionComments the new collection version comments @return \Concrete\Core\Page\Collection\Version\Version
[ "Create", "a", "new", "version", "for", "the", "same", "collection", "as", "this", "collection", "version", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Version/Version.php#L651-L663
train
concrete5/concrete5
concrete/src/Page/Collection/Version/Version.php
Version.discard
public function discard() { if ($this->isNew()) { $app = Facade::getFacadeApplication(); $db = $app->make('database')->connection(); // check for related version edits. This only gets applied when we edit global areas. $r = $db->executeQuery('select cRelationID, cvRelationID from CollectionVersionRelatedEdits where cID = ? and cvID = ?', array( $this->cID, $this->cvID, )); while ($row = $r->fetch()) { $cn = Page::getByID($row['cRelationID'], $row['cvRelationID']); $cnp = new Permissions($cn); if ($cnp->canApprovePageVersions()) { $v = $cn->getVersionObject(); $v->delete(); $db->executeQuery('delete from CollectionVersionRelatedEdits where cID = ? and cvID = ? and cRelationID = ? and cvRelationID = ?', array( $this->cID, $this->cvID, $row['cRelationID'], $row['cvRelationID'], )); } } $this->delete(); } $this->refreshCache(); }
php
public function discard() { if ($this->isNew()) { $app = Facade::getFacadeApplication(); $db = $app->make('database')->connection(); // check for related version edits. This only gets applied when we edit global areas. $r = $db->executeQuery('select cRelationID, cvRelationID from CollectionVersionRelatedEdits where cID = ? and cvID = ?', array( $this->cID, $this->cvID, )); while ($row = $r->fetch()) { $cn = Page::getByID($row['cRelationID'], $row['cvRelationID']); $cnp = new Permissions($cn); if ($cnp->canApprovePageVersions()) { $v = $cn->getVersionObject(); $v->delete(); $db->executeQuery('delete from CollectionVersionRelatedEdits where cID = ? and cvID = ? and cRelationID = ? and cvRelationID = ?', array( $this->cID, $this->cvID, $row['cRelationID'], $row['cvRelationID'], )); } } $this->delete(); } $this->refreshCache(); }
[ "public", "function", "discard", "(", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", ")", "{", "$", "app", "=", "Facade", "::", "getFacadeApplication", "(", ")", ";", "$", "db", "=", "$", "app", "->", "make", "(", "'database'", ")", "->", "connection", "(", ")", ";", "// check for related version edits. This only gets applied when we edit global areas.", "$", "r", "=", "$", "db", "->", "executeQuery", "(", "'select cRelationID, cvRelationID from CollectionVersionRelatedEdits where cID = ? and cvID = ?'", ",", "array", "(", "$", "this", "->", "cID", ",", "$", "this", "->", "cvID", ",", ")", ")", ";", "while", "(", "$", "row", "=", "$", "r", "->", "fetch", "(", ")", ")", "{", "$", "cn", "=", "Page", "::", "getByID", "(", "$", "row", "[", "'cRelationID'", "]", ",", "$", "row", "[", "'cvRelationID'", "]", ")", ";", "$", "cnp", "=", "new", "Permissions", "(", "$", "cn", ")", ";", "if", "(", "$", "cnp", "->", "canApprovePageVersions", "(", ")", ")", "{", "$", "v", "=", "$", "cn", "->", "getVersionObject", "(", ")", ";", "$", "v", "->", "delete", "(", ")", ";", "$", "db", "->", "executeQuery", "(", "'delete from CollectionVersionRelatedEdits where cID = ? and cvID = ? and cRelationID = ? and cvRelationID = ?'", ",", "array", "(", "$", "this", "->", "cID", ",", "$", "this", "->", "cvID", ",", "$", "row", "[", "'cRelationID'", "]", ",", "$", "row", "[", "'cvRelationID'", "]", ",", ")", ")", ";", "}", "}", "$", "this", "->", "delete", "(", ")", ";", "}", "$", "this", "->", "refreshCache", "(", ")", ";", "}" ]
Discard my most recent edit that is pending.
[ "Discard", "my", "most", "recent", "edit", "that", "is", "pending", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Version/Version.php#L780-L807
train
concrete5/concrete5
concrete/src/Page/Collection/Version/Version.php
Version.canDiscard
public function canDiscard() { $result = false; if ($this->isNew()) { $app = Facade::getFacadeApplication(); $db = $app->make('database')->connection(); $total = $db->fetchColumn('select count(cvID) from CollectionVersions where cID = ?', array( $this->cID, )); if ($total > 1) { $result = true; } } return $result; }
php
public function canDiscard() { $result = false; if ($this->isNew()) { $app = Facade::getFacadeApplication(); $db = $app->make('database')->connection(); $total = $db->fetchColumn('select count(cvID) from CollectionVersions where cID = ?', array( $this->cID, )); if ($total > 1) { $result = true; } } return $result; }
[ "public", "function", "canDiscard", "(", ")", "{", "$", "result", "=", "false", ";", "if", "(", "$", "this", "->", "isNew", "(", ")", ")", "{", "$", "app", "=", "Facade", "::", "getFacadeApplication", "(", ")", ";", "$", "db", "=", "$", "app", "->", "make", "(", "'database'", ")", "->", "connection", "(", ")", ";", "$", "total", "=", "$", "db", "->", "fetchColumn", "(", "'select count(cvID) from CollectionVersions where cID = ?'", ",", "array", "(", "$", "this", "->", "cID", ",", ")", ")", ";", "if", "(", "$", "total", ">", "1", ")", "{", "$", "result", "=", "true", ";", "}", "}", "return", "$", "result", ";", "}" ]
Check if this collection version can be discarded. @return bool
[ "Check", "if", "this", "collection", "version", "can", "be", "discarded", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Version/Version.php#L814-L829
train
concrete5/concrete5
concrete/src/Page/Collection/Version/Version.php
Version.removeNewStatus
public function removeNewStatus() { $app = Facade::getFacadeApplication(); $db = $app->make('database')->connection(); $db->executeQuery("update CollectionVersions set cvIsNew = 0 where cID = ? and cvID = ?", array( $this->cID, $this->cvID, )); $this->refreshCache(); }
php
public function removeNewStatus() { $app = Facade::getFacadeApplication(); $db = $app->make('database')->connection(); $db->executeQuery("update CollectionVersions set cvIsNew = 0 where cID = ? and cvID = ?", array( $this->cID, $this->cvID, )); $this->refreshCache(); }
[ "public", "function", "removeNewStatus", "(", ")", "{", "$", "app", "=", "Facade", "::", "getFacadeApplication", "(", ")", ";", "$", "db", "=", "$", "app", "->", "make", "(", "'database'", ")", "->", "connection", "(", ")", ";", "$", "db", "->", "executeQuery", "(", "\"update CollectionVersions set cvIsNew = 0 where cID = ? and cvID = ?\"", ",", "array", "(", "$", "this", "->", "cID", ",", "$", "this", "->", "cvID", ",", ")", ")", ";", "$", "this", "->", "refreshCache", "(", ")", ";", "}" ]
Mark this collection version as not new.
[ "Mark", "this", "collection", "version", "as", "not", "new", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Version/Version.php#L834-L843
train
concrete5/concrete5
concrete/src/Page/Collection/Version/Version.php
Version.deny
public function deny() { $app = Facade::getFacadeApplication(); $db = $app->make('database')->connection(); $cvID = $this->cvID; $cID = $this->cID; // first we update a collection updated record $dh = $app->make('helper/date'); $db->executeQuery('update Collections set cDateModified = ? where cID = ?', array( $dh->getOverridableNow(), $cID, )); // first we remove approval for all versions of this collection $v = array( $cID, ); $q = "update CollectionVersions set cvIsApproved = 0 where cID = ?"; $db->executeQuery($q, $v); $this->cvIsApproved = 0; // now we deny our version $v2 = array( $cID, $cvID, ); $q2 = "update CollectionVersions set cvIsApproved = 0, cvApproverUID = 0 where cID = ? and cvID = ?"; $db->executeQuery($q2, $v2); $this->refreshCache(); }
php
public function deny() { $app = Facade::getFacadeApplication(); $db = $app->make('database')->connection(); $cvID = $this->cvID; $cID = $this->cID; // first we update a collection updated record $dh = $app->make('helper/date'); $db->executeQuery('update Collections set cDateModified = ? where cID = ?', array( $dh->getOverridableNow(), $cID, )); // first we remove approval for all versions of this collection $v = array( $cID, ); $q = "update CollectionVersions set cvIsApproved = 0 where cID = ?"; $db->executeQuery($q, $v); $this->cvIsApproved = 0; // now we deny our version $v2 = array( $cID, $cvID, ); $q2 = "update CollectionVersions set cvIsApproved = 0, cvApproverUID = 0 where cID = ? and cvID = ?"; $db->executeQuery($q2, $v2); $this->refreshCache(); }
[ "public", "function", "deny", "(", ")", "{", "$", "app", "=", "Facade", "::", "getFacadeApplication", "(", ")", ";", "$", "db", "=", "$", "app", "->", "make", "(", "'database'", ")", "->", "connection", "(", ")", ";", "$", "cvID", "=", "$", "this", "->", "cvID", ";", "$", "cID", "=", "$", "this", "->", "cID", ";", "// first we update a collection updated record", "$", "dh", "=", "$", "app", "->", "make", "(", "'helper/date'", ")", ";", "$", "db", "->", "executeQuery", "(", "'update Collections set cDateModified = ? where cID = ?'", ",", "array", "(", "$", "dh", "->", "getOverridableNow", "(", ")", ",", "$", "cID", ",", ")", ")", ";", "// first we remove approval for all versions of this collection", "$", "v", "=", "array", "(", "$", "cID", ",", ")", ";", "$", "q", "=", "\"update CollectionVersions set cvIsApproved = 0 where cID = ?\"", ";", "$", "db", "->", "executeQuery", "(", "$", "q", ",", "$", "v", ")", ";", "$", "this", "->", "cvIsApproved", "=", "0", ";", "// now we deny our version", "$", "v2", "=", "array", "(", "$", "cID", ",", "$", "cvID", ",", ")", ";", "$", "q2", "=", "\"update CollectionVersions set cvIsApproved = 0, cvApproverUID = 0 where cID = ? and cvID = ?\"", ";", "$", "db", "->", "executeQuery", "(", "$", "q2", ",", "$", "v2", ")", ";", "$", "this", "->", "refreshCache", "(", ")", ";", "}" ]
Mark this collection version as not approved.
[ "Mark", "this", "collection", "version", "as", "not", "approved", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Collection/Version/Version.php#L848-L878
train
concrete5/concrete5
concrete/src/Page/Sitemap/SitemapWriter.php
SitemapWriter.getSitemapGenerator
public function getSitemapGenerator() { if ($this->sitemapGenerator === null) { $this->sitemapGenerator = $this->app->make(SitemapGenerator::class); } return $this->sitemapGenerator; }
php
public function getSitemapGenerator() { if ($this->sitemapGenerator === null) { $this->sitemapGenerator = $this->app->make(SitemapGenerator::class); } return $this->sitemapGenerator; }
[ "public", "function", "getSitemapGenerator", "(", ")", "{", "if", "(", "$", "this", "->", "sitemapGenerator", "===", "null", ")", "{", "$", "this", "->", "sitemapGenerator", "=", "$", "this", "->", "app", "->", "make", "(", "SitemapGenerator", "::", "class", ")", ";", "}", "return", "$", "this", "->", "sitemapGenerator", ";", "}" ]
Get the SitemapGenerator instance to be used. @return \Concrete\Core\Page\Sitemap\SitemapGenerator
[ "Get", "the", "SitemapGenerator", "instance", "to", "be", "used", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Sitemap/SitemapWriter.php#L187-L194
train
concrete5/concrete5
concrete/src/Page/Sitemap/SitemapWriter.php
SitemapWriter.getOutputFilename
public function getOutputFilename() { $result = $this->outputFilename; if ($result === '') { $config = $this->app->make('config'); $relativeName = '/' . ltrim(str_replace(DIRECTORY_SEPARATOR, '/', (string) $config->get('concrete.sitemap_xml.file')), '/'); if ($relativeName === '/') { $relativeName = '/sitemap.xml'; } $result = rtrim(DIR_BASE, '/') . $relativeName; } return $result; }
php
public function getOutputFilename() { $result = $this->outputFilename; if ($result === '') { $config = $this->app->make('config'); $relativeName = '/' . ltrim(str_replace(DIRECTORY_SEPARATOR, '/', (string) $config->get('concrete.sitemap_xml.file')), '/'); if ($relativeName === '/') { $relativeName = '/sitemap.xml'; } $result = rtrim(DIR_BASE, '/') . $relativeName; } return $result; }
[ "public", "function", "getOutputFilename", "(", ")", "{", "$", "result", "=", "$", "this", "->", "outputFilename", ";", "if", "(", "$", "result", "===", "''", ")", "{", "$", "config", "=", "$", "this", "->", "app", "->", "make", "(", "'config'", ")", ";", "$", "relativeName", "=", "'/'", ".", "ltrim", "(", "str_replace", "(", "DIRECTORY_SEPARATOR", ",", "'/'", ",", "(", "string", ")", "$", "config", "->", "get", "(", "'concrete.sitemap_xml.file'", ")", ")", ",", "'/'", ")", ";", "if", "(", "$", "relativeName", "===", "'/'", ")", "{", "$", "relativeName", "=", "'/sitemap.xml'", ";", "}", "$", "result", "=", "rtrim", "(", "DIR_BASE", ",", "'/'", ")", ".", "$", "relativeName", ";", "}", "return", "$", "result", ";", "}" ]
Get the path to the sitemap to be generated. @return string
[ "Get", "the", "path", "to", "the", "sitemap", "to", "be", "generated", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Sitemap/SitemapWriter.php#L229-L242
train
concrete5/concrete5
concrete/src/Page/Sitemap/SitemapWriter.php
SitemapWriter.getSitemapUrl
public function getSitemapUrl() { $outputFilename = $this->getOutputFilename(); if (strpos($outputFilename, DIR_BASE . '/') === 0) { $result = (string) $this->getSitemapGenerator()->resolveUrl([substr($outputFilename, strlen(DIR_BASE))]); } else { $result = ''; } return $result; }
php
public function getSitemapUrl() { $outputFilename = $this->getOutputFilename(); if (strpos($outputFilename, DIR_BASE . '/') === 0) { $result = (string) $this->getSitemapGenerator()->resolveUrl([substr($outputFilename, strlen(DIR_BASE))]); } else { $result = ''; } return $result; }
[ "public", "function", "getSitemapUrl", "(", ")", "{", "$", "outputFilename", "=", "$", "this", "->", "getOutputFilename", "(", ")", ";", "if", "(", "strpos", "(", "$", "outputFilename", ",", "DIR_BASE", ".", "'/'", ")", "===", "0", ")", "{", "$", "result", "=", "(", "string", ")", "$", "this", "->", "getSitemapGenerator", "(", ")", "->", "resolveUrl", "(", "[", "substr", "(", "$", "outputFilename", ",", "strlen", "(", "DIR_BASE", ")", ")", "]", ")", ";", "}", "else", "{", "$", "result", "=", "''", ";", "}", "return", "$", "result", ";", "}" ]
Get the URL of the sitemap corresponding to the output file name. @return string returns an empty string if the output file name is not under the web root
[ "Get", "the", "URL", "of", "the", "sitemap", "corresponding", "to", "the", "output", "file", "name", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Sitemap/SitemapWriter.php#L249-L259
train
concrete5/concrete5
concrete/src/Page/Sitemap/SitemapWriter.php
SitemapWriter.getTemporaryDirectory
protected function getTemporaryDirectory() { $result = $this->temporaryDirectory; if ($result === '') { $fileHelper = $this->app->make('helper/file'); $temporaryDirectory = (string) $fileHelper->getTemporaryDirectory(); if ($temporaryDirectory === '' || !$this->filesystem->isDirectory($temporaryDirectory)) { throw new UserMessageException(t('Unable to determine the temporary directory.')); } $this->temporaryDirectory = $temporaryDirectory; } return $this->temporaryDirectory; }
php
protected function getTemporaryDirectory() { $result = $this->temporaryDirectory; if ($result === '') { $fileHelper = $this->app->make('helper/file'); $temporaryDirectory = (string) $fileHelper->getTemporaryDirectory(); if ($temporaryDirectory === '' || !$this->filesystem->isDirectory($temporaryDirectory)) { throw new UserMessageException(t('Unable to determine the temporary directory.')); } $this->temporaryDirectory = $temporaryDirectory; } return $this->temporaryDirectory; }
[ "protected", "function", "getTemporaryDirectory", "(", ")", "{", "$", "result", "=", "$", "this", "->", "temporaryDirectory", ";", "if", "(", "$", "result", "===", "''", ")", "{", "$", "fileHelper", "=", "$", "this", "->", "app", "->", "make", "(", "'helper/file'", ")", ";", "$", "temporaryDirectory", "=", "(", "string", ")", "$", "fileHelper", "->", "getTemporaryDirectory", "(", ")", ";", "if", "(", "$", "temporaryDirectory", "===", "''", "||", "!", "$", "this", "->", "filesystem", "->", "isDirectory", "(", "$", "temporaryDirectory", ")", ")", "{", "throw", "new", "UserMessageException", "(", "t", "(", "'Unable to determine the temporary directory.'", ")", ")", ";", "}", "$", "this", "->", "temporaryDirectory", "=", "$", "temporaryDirectory", ";", "}", "return", "$", "this", "->", "temporaryDirectory", ";", "}" ]
Get the temporary directory to be used during the sitemap generation. @return string
[ "Get", "the", "temporary", "directory", "to", "be", "used", "during", "the", "sitemap", "generation", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Page/Sitemap/SitemapWriter.php#L374-L387
train
concrete5/concrete5
concrete/src/Express/Association/Formatter/AbstractFormatter.php
AbstractFormatter.getEntryDisplayName
public function getEntryDisplayName(AssociationControl $control, Entry $entry) { $formatter = $this->getEntryFormatter(); $name = null; // Do we have a custom display mask? If so, we try to use that if ($mask = $control->getAssociationEntityLabelMask()) { $name = $formatter->format($mask, $entry); } $name = $entry->getLabel(); if ($name = trim($name)) { return $name; } return $entry->getID(); }
php
public function getEntryDisplayName(AssociationControl $control, Entry $entry) { $formatter = $this->getEntryFormatter(); $name = null; // Do we have a custom display mask? If so, we try to use that if ($mask = $control->getAssociationEntityLabelMask()) { $name = $formatter->format($mask, $entry); } $name = $entry->getLabel(); if ($name = trim($name)) { return $name; } return $entry->getID(); }
[ "public", "function", "getEntryDisplayName", "(", "AssociationControl", "$", "control", ",", "Entry", "$", "entry", ")", "{", "$", "formatter", "=", "$", "this", "->", "getEntryFormatter", "(", ")", ";", "$", "name", "=", "null", ";", "// Do we have a custom display mask? If so, we try to use that", "if", "(", "$", "mask", "=", "$", "control", "->", "getAssociationEntityLabelMask", "(", ")", ")", "{", "$", "name", "=", "$", "formatter", "->", "format", "(", "$", "mask", ",", "$", "entry", ")", ";", "}", "$", "name", "=", "$", "entry", "->", "getLabel", "(", ")", ";", "if", "(", "$", "name", "=", "trim", "(", "$", "name", ")", ")", "{", "return", "$", "name", ";", "}", "return", "$", "entry", "->", "getID", "(", ")", ";", "}" ]
Get the display label for an entry @param \Concrete\Core\Entity\Express\Control\AssociationControl $control @param \Concrete\Core\Entity\Express\Entry $entry @return null|string
[ "Get", "the", "display", "label", "for", "an", "entry" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Express/Association/Formatter/AbstractFormatter.php#L26-L43
train
concrete5/concrete5
concrete/src/Express/Association/Formatter/AbstractFormatter.php
AbstractFormatter.getEntryFormatter
protected function getEntryFormatter() { if (!$this->entryFormatter) { $this->entryFormatter = Application::getFacadeApplication()->make(EntryFormatterInterface::class); } return $this->entryFormatter; }
php
protected function getEntryFormatter() { if (!$this->entryFormatter) { $this->entryFormatter = Application::getFacadeApplication()->make(EntryFormatterInterface::class); } return $this->entryFormatter; }
[ "protected", "function", "getEntryFormatter", "(", ")", "{", "if", "(", "!", "$", "this", "->", "entryFormatter", ")", "{", "$", "this", "->", "entryFormatter", "=", "Application", "::", "getFacadeApplication", "(", ")", "->", "make", "(", "EntryFormatterInterface", "::", "class", ")", ";", "}", "return", "$", "this", "->", "entryFormatter", ";", "}" ]
Get the entry formatter to use @return \Concrete\Core\Express\Entry\Formatter\EntryFormatterInterface
[ "Get", "the", "entry", "formatter", "to", "use" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Express/Association/Formatter/AbstractFormatter.php#L58-L65
train
concrete5/concrete5
concrete/src/Database/EntityManager/Driver/CoreDriver.php
CoreDriver.getDriver
public function getDriver() { $annotationDriver = new AnnotationDriver($this->app->make('orm/cachedAnnotationReader'), [ DIR_BASE_CORE . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES, ]); return $annotationDriver; }
php
public function getDriver() { $annotationDriver = new AnnotationDriver($this->app->make('orm/cachedAnnotationReader'), [ DIR_BASE_CORE . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES, ]); return $annotationDriver; }
[ "public", "function", "getDriver", "(", ")", "{", "$", "annotationDriver", "=", "new", "AnnotationDriver", "(", "$", "this", "->", "app", "->", "make", "(", "'orm/cachedAnnotationReader'", ")", ",", "[", "DIR_BASE_CORE", ".", "'/'", ".", "DIRNAME_CLASSES", ".", "'/'", ".", "DIRNAME_ENTITIES", ",", "]", ")", ";", "return", "$", "annotationDriver", ";", "}" ]
Get the AnnotationDriver @return AnnotationDriver
[ "Get", "the", "AnnotationDriver" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Database/EntityManager/Driver/CoreDriver.php#L29-L35
train
concrete5/concrete5
concrete/src/Authentication/AuthenticationType.php
AuthenticationType.getList
public static function getList($sorted = false, $activeOnly = false) { $list = []; $db = Loader::db(); $q = $db->query('SELECT * FROM AuthenticationTypes' . ($activeOnly ? ' WHERE authTypeIsEnabled=1 ' : '') . ' ORDER BY ' . ($sorted ? 'authTypeDisplayOrder' : 'authTypeID')); while ($row = $q->fetchRow()) { $list[] = self::load($row); } return $list; }
php
public static function getList($sorted = false, $activeOnly = false) { $list = []; $db = Loader::db(); $q = $db->query('SELECT * FROM AuthenticationTypes' . ($activeOnly ? ' WHERE authTypeIsEnabled=1 ' : '') . ' ORDER BY ' . ($sorted ? 'authTypeDisplayOrder' : 'authTypeID')); while ($row = $q->fetchRow()) { $list[] = self::load($row); } return $list; }
[ "public", "static", "function", "getList", "(", "$", "sorted", "=", "false", ",", "$", "activeOnly", "=", "false", ")", "{", "$", "list", "=", "[", "]", ";", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "q", "=", "$", "db", "->", "query", "(", "'SELECT * FROM AuthenticationTypes'", ".", "(", "$", "activeOnly", "?", "' WHERE authTypeIsEnabled=1 '", ":", "''", ")", ".", "' ORDER BY '", ".", "(", "$", "sorted", "?", "'authTypeDisplayOrder'", ":", "'authTypeID'", ")", ")", ";", "while", "(", "$", "row", "=", "$", "q", "->", "fetchRow", "(", ")", ")", "{", "$", "list", "[", "]", "=", "self", "::", "load", "(", "$", "row", ")", ";", "}", "return", "$", "list", ";", "}" ]
Return a raw list of authentication types. @param bool $sorted true: Sort by display order, false: sort by install order @param bool $activeOnly true: include only active types, false: include active and inactive types @return AuthenticationType[]
[ "Return", "a", "raw", "list", "of", "authentication", "types", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Authentication/AuthenticationType.php#L37-L49
train
concrete5/concrete5
concrete/src/Authentication/AuthenticationType.php
AuthenticationType.load
public static function load($arr) { $extract = [ 'authTypeID', 'authTypeName', 'authTypeHandle', 'authTypeDisplayOrder', 'authTypeIsEnabled', 'pkgID', ]; $obj = new self(); foreach ($extract as $key) { if (!isset($arr[$key])) { return false; } $obj->{$key} = $arr[$key]; } $obj->loadController(); return $obj; }
php
public static function load($arr) { $extract = [ 'authTypeID', 'authTypeName', 'authTypeHandle', 'authTypeDisplayOrder', 'authTypeIsEnabled', 'pkgID', ]; $obj = new self(); foreach ($extract as $key) { if (!isset($arr[$key])) { return false; } $obj->{$key} = $arr[$key]; } $obj->loadController(); return $obj; }
[ "public", "static", "function", "load", "(", "$", "arr", ")", "{", "$", "extract", "=", "[", "'authTypeID'", ",", "'authTypeName'", ",", "'authTypeHandle'", ",", "'authTypeDisplayOrder'", ",", "'authTypeIsEnabled'", ",", "'pkgID'", ",", "]", ";", "$", "obj", "=", "new", "self", "(", ")", ";", "foreach", "(", "$", "extract", "as", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "arr", "[", "$", "key", "]", ")", ")", "{", "return", "false", ";", "}", "$", "obj", "->", "{", "$", "key", "}", "=", "$", "arr", "[", "$", "key", "]", ";", "}", "$", "obj", "->", "loadController", "(", ")", ";", "return", "$", "obj", ";", "}" ]
Load an AuthenticationType from an array. @param array $arr should be an array of the following key/value pairs to create an object from: <pre> array( 'authTypeID' => int, 'authTypeHandle' => string, 'authTypeName' => string, 'authTypeDisplayOrder' => int, 'authTypeIsEnabled' => tinyint, 'pkgID' => int ) </pre> @return bool|\Concrete\Core\Authentication\AuthenticationType
[ "Load", "an", "AuthenticationType", "from", "an", "array", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Authentication/AuthenticationType.php#L68-L88
train
concrete5/concrete5
concrete/src/Authentication/AuthenticationType.php
AuthenticationType.loadController
protected function loadController() { $env = Environment::get(); $r = $env->getRecord(DIRNAME_AUTHENTICATION . '/' . $this->authTypeHandle . '/' . FILENAME_CONTROLLER); $prefix = $r->override ? true : $this->getPackageHandle(); $authTypeHandle = Core::make('helper/text')->camelcase($this->authTypeHandle); $class = core_class('Authentication\\' . $authTypeHandle . '\\Controller', $prefix); $this->controller = Core::make($class, [$this]); }
php
protected function loadController() { $env = Environment::get(); $r = $env->getRecord(DIRNAME_AUTHENTICATION . '/' . $this->authTypeHandle . '/' . FILENAME_CONTROLLER); $prefix = $r->override ? true : $this->getPackageHandle(); $authTypeHandle = Core::make('helper/text')->camelcase($this->authTypeHandle); $class = core_class('Authentication\\' . $authTypeHandle . '\\Controller', $prefix); $this->controller = Core::make($class, [$this]); }
[ "protected", "function", "loadController", "(", ")", "{", "$", "env", "=", "Environment", "::", "get", "(", ")", ";", "$", "r", "=", "$", "env", "->", "getRecord", "(", "DIRNAME_AUTHENTICATION", ".", "'/'", ".", "$", "this", "->", "authTypeHandle", ".", "'/'", ".", "FILENAME_CONTROLLER", ")", ";", "$", "prefix", "=", "$", "r", "->", "override", "?", "true", ":", "$", "this", "->", "getPackageHandle", "(", ")", ";", "$", "authTypeHandle", "=", "Core", "::", "make", "(", "'helper/text'", ")", "->", "camelcase", "(", "$", "this", "->", "authTypeHandle", ")", ";", "$", "class", "=", "core_class", "(", "'Authentication\\\\'", ".", "$", "authTypeHandle", ".", "'\\\\Controller'", ",", "$", "prefix", ")", ";", "$", "this", "->", "controller", "=", "Core", "::", "make", "(", "$", "class", ",", "[", "$", "this", "]", ")", ";", "}" ]
Load the AuthenticationTypeController into the AuthenticationType.
[ "Load", "the", "AuthenticationTypeController", "into", "the", "AuthenticationType", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Authentication/AuthenticationType.php#L93-L101
train
concrete5/concrete5
concrete/src/Authentication/AuthenticationType.php
AuthenticationType.getByHandle
public static function getByHandle($atHandle) { $db = Loader::db(); $row = $db->GetRow('SELECT * FROM AuthenticationTypes WHERE authTypeHandle=?', [$atHandle]); if (!$row) { throw new Exception(t('Invalid Authentication Type Handle')); } $at = self::load($row); return $at; }
php
public static function getByHandle($atHandle) { $db = Loader::db(); $row = $db->GetRow('SELECT * FROM AuthenticationTypes WHERE authTypeHandle=?', [$atHandle]); if (!$row) { throw new Exception(t('Invalid Authentication Type Handle')); } $at = self::load($row); return $at; }
[ "public", "static", "function", "getByHandle", "(", "$", "atHandle", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "row", "=", "$", "db", "->", "GetRow", "(", "'SELECT * FROM AuthenticationTypes WHERE authTypeHandle=?'", ",", "[", "$", "atHandle", "]", ")", ";", "if", "(", "!", "$", "row", ")", "{", "throw", "new", "Exception", "(", "t", "(", "'Invalid Authentication Type Handle'", ")", ")", ";", "}", "$", "at", "=", "self", "::", "load", "(", "$", "row", ")", ";", "return", "$", "at", ";", "}" ]
Return loaded AuthenticationType with the given handle. @param string $atHandle authenticationType handle @throws \Exception when an invalid handle is provided @return AuthenticationType
[ "Return", "loaded", "AuthenticationType", "with", "the", "given", "handle", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Authentication/AuthenticationType.php#L180-L190
train
concrete5/concrete5
concrete/src/Authentication/AuthenticationType.php
AuthenticationType.getByID
public static function getByID($authTypeID) { $db = Loader::db(); $row = $db->GetRow('SELECT * FROM AuthenticationTypes where authTypeID=?', [$authTypeID]); if (!$row) { throw new Exception(t('Invalid Authentication Type ID')); } $at = self::load($row); $at->loadController(); return $at; }
php
public static function getByID($authTypeID) { $db = Loader::db(); $row = $db->GetRow('SELECT * FROM AuthenticationTypes where authTypeID=?', [$authTypeID]); if (!$row) { throw new Exception(t('Invalid Authentication Type ID')); } $at = self::load($row); $at->loadController(); return $at; }
[ "public", "static", "function", "getByID", "(", "$", "authTypeID", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "row", "=", "$", "db", "->", "GetRow", "(", "'SELECT * FROM AuthenticationTypes where authTypeID=?'", ",", "[", "$", "authTypeID", "]", ")", ";", "if", "(", "!", "$", "row", ")", "{", "throw", "new", "Exception", "(", "t", "(", "'Invalid Authentication Type ID'", ")", ")", ";", "}", "$", "at", "=", "self", "::", "load", "(", "$", "row", ")", ";", "$", "at", "->", "loadController", "(", ")", ";", "return", "$", "at", ";", "}" ]
Return loaded AuthenticationType with the given ID. @param int $authTypeID @throws \Exception @return AuthenticationType
[ "Return", "loaded", "AuthenticationType", "with", "the", "given", "ID", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Authentication/AuthenticationType.php#L201-L212
train
concrete5/concrete5
concrete/src/Authentication/AuthenticationType.php
AuthenticationType.setAuthenticationTypeName
public function setAuthenticationTypeName($authTypeName) { $db = Loader::db(); $db->Execute( 'UPDATE AuthenticationTypes SET authTypeName=? WHERE authTypeID=?', [$authTypeName, $this->getAuthenticationTypeID()]); }
php
public function setAuthenticationTypeName($authTypeName) { $db = Loader::db(); $db->Execute( 'UPDATE AuthenticationTypes SET authTypeName=? WHERE authTypeID=?', [$authTypeName, $this->getAuthenticationTypeID()]); }
[ "public", "function", "setAuthenticationTypeName", "(", "$", "authTypeName", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "db", "->", "Execute", "(", "'UPDATE AuthenticationTypes SET authTypeName=? WHERE authTypeID=?'", ",", "[", "$", "authTypeName", ",", "$", "this", "->", "getAuthenticationTypeID", "(", ")", "]", ")", ";", "}" ]
Update the name. @param string $authTypeName
[ "Update", "the", "name", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Authentication/AuthenticationType.php#L263-L269
train
concrete5/concrete5
concrete/src/Authentication/AuthenticationType.php
AuthenticationType.getAuthenticationTypeFilePath
public function getAuthenticationTypeFilePath($_file) { $f = $this->mapAuthenticationTypeFilePath($_file); if ($f->exists()) { return $f->url; } return false; }
php
public function getAuthenticationTypeFilePath($_file) { $f = $this->mapAuthenticationTypeFilePath($_file); if ($f->exists()) { return $f->url; } return false; }
[ "public", "function", "getAuthenticationTypeFilePath", "(", "$", "_file", ")", "{", "$", "f", "=", "$", "this", "->", "mapAuthenticationTypeFilePath", "(", "$", "_file", ")", ";", "if", "(", "$", "f", "->", "exists", "(", ")", ")", "{", "return", "$", "f", "->", "url", ";", "}", "return", "false", ";", "}" ]
Return the path to a file. @param string $_file the relative path to the file @return bool|string
[ "Return", "the", "path", "to", "a", "file", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Authentication/AuthenticationType.php#L357-L365
train
concrete5/concrete5
concrete/src/Authentication/AuthenticationType.php
AuthenticationType.renderForm
public function renderForm($element = 'form', $params = []) { $this->controller->requireAsset('javascript', 'backstretch'); $form_element = $this->mapAuthenticationTypeFilePath($element . '.php'); if (!$form_element->exists()) { $form_element = $this->mapAuthenticationTypeFilePath('form.php'); if (method_exists($this->controller, 'form')) { call_user_func_array([$this->controller, 'form'], $params); } } ob_start(); if (method_exists($this->controller, $element)) { call_user_func_array([$this->controller, $element], $params); } else { $this->controller->view(); } extract(array_merge($params, $this->controller->getSets())); require $form_element->file; $out = ob_get_contents(); ob_end_clean(); echo $out; }
php
public function renderForm($element = 'form', $params = []) { $this->controller->requireAsset('javascript', 'backstretch'); $form_element = $this->mapAuthenticationTypeFilePath($element . '.php'); if (!$form_element->exists()) { $form_element = $this->mapAuthenticationTypeFilePath('form.php'); if (method_exists($this->controller, 'form')) { call_user_func_array([$this->controller, 'form'], $params); } } ob_start(); if (method_exists($this->controller, $element)) { call_user_func_array([$this->controller, $element], $params); } else { $this->controller->view(); } extract(array_merge($params, $this->controller->getSets())); require $form_element->file; $out = ob_get_contents(); ob_end_clean(); echo $out; }
[ "public", "function", "renderForm", "(", "$", "element", "=", "'form'", ",", "$", "params", "=", "[", "]", ")", "{", "$", "this", "->", "controller", "->", "requireAsset", "(", "'javascript'", ",", "'backstretch'", ")", ";", "$", "form_element", "=", "$", "this", "->", "mapAuthenticationTypeFilePath", "(", "$", "element", ".", "'.php'", ")", ";", "if", "(", "!", "$", "form_element", "->", "exists", "(", ")", ")", "{", "$", "form_element", "=", "$", "this", "->", "mapAuthenticationTypeFilePath", "(", "'form.php'", ")", ";", "if", "(", "method_exists", "(", "$", "this", "->", "controller", ",", "'form'", ")", ")", "{", "call_user_func_array", "(", "[", "$", "this", "->", "controller", ",", "'form'", "]", ",", "$", "params", ")", ";", "}", "}", "ob_start", "(", ")", ";", "if", "(", "method_exists", "(", "$", "this", "->", "controller", ",", "$", "element", ")", ")", "{", "call_user_func_array", "(", "[", "$", "this", "->", "controller", ",", "$", "element", "]", ",", "$", "params", ")", ";", "}", "else", "{", "$", "this", "->", "controller", "->", "view", "(", ")", ";", "}", "extract", "(", "array_merge", "(", "$", "params", ",", "$", "this", "->", "controller", "->", "getSets", "(", ")", ")", ")", ";", "require", "$", "form_element", "->", "file", ";", "$", "out", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "echo", "$", "out", ";", "}" ]
Render the login form for this authentication type. @param string $element @param array $params
[ "Render", "the", "login", "form", "for", "this", "authentication", "type", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Authentication/AuthenticationType.php#L421-L443
train
concrete5/concrete5
concrete/src/Authentication/AuthenticationType.php
AuthenticationType.renderHook
public function renderHook() { $form_hook = $this->mapAuthenticationTypeFilePath('hook.php'); if (method_exists($this->controller, 'hook') || $form_hook->exists()) { ob_start(); if (method_exists($this->controller, 'hook')) { $this->controller->hook(); } if ($form_hook->exists()) { $controller = $this->controller; extract($this->controller->getSets()); require_once $form_hook->file; } $out = ob_get_contents(); ob_end_clean(); echo $out; } }
php
public function renderHook() { $form_hook = $this->mapAuthenticationTypeFilePath('hook.php'); if (method_exists($this->controller, 'hook') || $form_hook->exists()) { ob_start(); if (method_exists($this->controller, 'hook')) { $this->controller->hook(); } if ($form_hook->exists()) { $controller = $this->controller; extract($this->controller->getSets()); require_once $form_hook->file; } $out = ob_get_contents(); ob_end_clean(); echo $out; } }
[ "public", "function", "renderHook", "(", ")", "{", "$", "form_hook", "=", "$", "this", "->", "mapAuthenticationTypeFilePath", "(", "'hook.php'", ")", ";", "if", "(", "method_exists", "(", "$", "this", "->", "controller", ",", "'hook'", ")", "||", "$", "form_hook", "->", "exists", "(", ")", ")", "{", "ob_start", "(", ")", ";", "if", "(", "method_exists", "(", "$", "this", "->", "controller", ",", "'hook'", ")", ")", "{", "$", "this", "->", "controller", "->", "hook", "(", ")", ";", "}", "if", "(", "$", "form_hook", "->", "exists", "(", ")", ")", "{", "$", "controller", "=", "$", "this", "->", "controller", ";", "extract", "(", "$", "this", "->", "controller", "->", "getSets", "(", ")", ")", ";", "require_once", "$", "form_hook", "->", "file", ";", "}", "$", "out", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "echo", "$", "out", ";", "}", "}" ]
Render the hook form for saving the profile settings. All settings are expected to be saved by each individual authentication type.
[ "Render", "the", "hook", "form", "for", "saving", "the", "profile", "settings", ".", "All", "settings", "are", "expected", "to", "be", "saved", "by", "each", "individual", "authentication", "type", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Authentication/AuthenticationType.php#L449-L466
train
concrete5/concrete5
concrete/src/Authentication/AuthenticationType.php
AuthenticationType.renderHooked
public function renderHooked() { $form_hooked = $this->mapAuthenticationTypeFilePath('hooked.php'); if (method_exists($this->controller, 'hooked') || $form_hooked->exists()) { ob_start(); if (method_exists($this->controller, 'hooked')) { $this->controller->hooked(); } if ($form_hooked->exists()) { $controller = $this->controller; extract($this->controller->getSets()); require_once $form_hooked->file; } $out = ob_get_contents(); ob_end_clean(); echo $out; } }
php
public function renderHooked() { $form_hooked = $this->mapAuthenticationTypeFilePath('hooked.php'); if (method_exists($this->controller, 'hooked') || $form_hooked->exists()) { ob_start(); if (method_exists($this->controller, 'hooked')) { $this->controller->hooked(); } if ($form_hooked->exists()) { $controller = $this->controller; extract($this->controller->getSets()); require_once $form_hooked->file; } $out = ob_get_contents(); ob_end_clean(); echo $out; } }
[ "public", "function", "renderHooked", "(", ")", "{", "$", "form_hooked", "=", "$", "this", "->", "mapAuthenticationTypeFilePath", "(", "'hooked.php'", ")", ";", "if", "(", "method_exists", "(", "$", "this", "->", "controller", ",", "'hooked'", ")", "||", "$", "form_hooked", "->", "exists", "(", ")", ")", "{", "ob_start", "(", ")", ";", "if", "(", "method_exists", "(", "$", "this", "->", "controller", ",", "'hooked'", ")", ")", "{", "$", "this", "->", "controller", "->", "hooked", "(", ")", ";", "}", "if", "(", "$", "form_hooked", "->", "exists", "(", ")", ")", "{", "$", "controller", "=", "$", "this", "->", "controller", ";", "extract", "(", "$", "this", "->", "controller", "->", "getSets", "(", ")", ")", ";", "require_once", "$", "form_hooked", "->", "file", ";", "}", "$", "out", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "echo", "$", "out", ";", "}", "}" ]
Render the a form to be displayed when the authentication type is already hooked. All settings are expected to be saved by each individual authentication type.
[ "Render", "the", "a", "form", "to", "be", "displayed", "when", "the", "authentication", "type", "is", "already", "hooked", ".", "All", "settings", "are", "expected", "to", "be", "saved", "by", "each", "individual", "authentication", "type", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Authentication/AuthenticationType.php#L479-L496
train
concrete5/concrete5
concrete/src/Authentication/AuthenticationType.php
AuthenticationType.isHooked
public function isHooked($user) { $result = null; if (is_callable([$this->controller, 'getBindingForUser'])) { $result = $this->controller->getBindingForUser($user) !== null; } else { $result = null; } return $result; }
php
public function isHooked($user) { $result = null; if (is_callable([$this->controller, 'getBindingForUser'])) { $result = $this->controller->getBindingForUser($user) !== null; } else { $result = null; } return $result; }
[ "public", "function", "isHooked", "(", "$", "user", ")", "{", "$", "result", "=", "null", ";", "if", "(", "is_callable", "(", "[", "$", "this", "->", "controller", ",", "'getBindingForUser'", "]", ")", ")", "{", "$", "result", "=", "$", "this", "->", "controller", "->", "getBindingForUser", "(", "$", "user", ")", "!==", "null", ";", "}", "else", "{", "$", "result", "=", "null", ";", "}", "return", "$", "result", ";", "}" ]
Is this authentication type already hooked for a specific user? @param \Concrete\Core\User\User|\Concrete\Core\User\UserInfo|\Concrete\Core\Entity\User\User|int $user @return bool|null returns null if the controller does not implement a way to determine if a user is already hooked or not
[ "Is", "this", "authentication", "type", "already", "hooked", "for", "a", "specific", "user?" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Authentication/AuthenticationType.php#L517-L527
train
concrete5/concrete5
concrete/src/Entity/File/Image/Thumbnail/Type/Type.php
Type.save
public function save() { $em = Application::getFacadeApplication()->make(EntityManagerInterface::class); $em->persist($this); $em->flush(); }
php
public function save() { $em = Application::getFacadeApplication()->make(EntityManagerInterface::class); $em->persist($this); $em->flush(); }
[ "public", "function", "save", "(", ")", "{", "$", "em", "=", "Application", "::", "getFacadeApplication", "(", ")", "->", "make", "(", "EntityManagerInterface", "::", "class", ")", ";", "$", "em", "->", "persist", "(", "$", "this", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "}" ]
Save this instance to the database.
[ "Save", "this", "instance", "to", "the", "database", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Entity/File/Image/Thumbnail/Type/Type.php#L413-L418
train
concrete5/concrete5
concrete/src/Database/EntityManager/Driver/ApplicationDriver.php
ApplicationDriver.getDriver
public function getDriver() { $config = $this->config; if ($this->isLegacy()) { $appEntityPath = DIR_APPLICATION . '/' . DIRNAME_CLASSES; $reader = $this->app->make('orm/cachedSimpleAnnotationReader'); } else { $appEntityPath = DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES; $reader = $this->app->make('orm/cachedAnnotationReader'); } $appDriverSettings = $config->get(CONFIG_ORM_METADATA_APPLICATION); $xmlConfig = DIR_APPLICATION . '/' . REL_DIR_METADATA_XML; $ymlConfig = DIR_APPLICATION . '/' . REL_DIR_METADATA_YAML; // Default setting so it comes first if (empty($appDriverSettings) && is_dir($appEntityPath)) { return new AnnotationDriver($reader, $appEntityPath); } else { if ($appDriverSettings === 'xml') { if (is_dir($xmlConfig)) { return new XmlDriver($xmlConfig); } else { // Fallback to default return new AnnotationDriver($reader, $appEntityPath); } } else { if ($appDriverSettings === 'yaml' || $appDriverSettings === 'yml') { if (is_dir($ymlConfig)) { return new YamlDriver($ymlConfig); } else { // Fallback to default return new AnnotationDriver($reader, $appEntityPath); } } } } }
php
public function getDriver() { $config = $this->config; if ($this->isLegacy()) { $appEntityPath = DIR_APPLICATION . '/' . DIRNAME_CLASSES; $reader = $this->app->make('orm/cachedSimpleAnnotationReader'); } else { $appEntityPath = DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/' . DIRNAME_ENTITIES; $reader = $this->app->make('orm/cachedAnnotationReader'); } $appDriverSettings = $config->get(CONFIG_ORM_METADATA_APPLICATION); $xmlConfig = DIR_APPLICATION . '/' . REL_DIR_METADATA_XML; $ymlConfig = DIR_APPLICATION . '/' . REL_DIR_METADATA_YAML; // Default setting so it comes first if (empty($appDriverSettings) && is_dir($appEntityPath)) { return new AnnotationDriver($reader, $appEntityPath); } else { if ($appDriverSettings === 'xml') { if (is_dir($xmlConfig)) { return new XmlDriver($xmlConfig); } else { // Fallback to default return new AnnotationDriver($reader, $appEntityPath); } } else { if ($appDriverSettings === 'yaml' || $appDriverSettings === 'yml') { if (is_dir($ymlConfig)) { return new YamlDriver($ymlConfig); } else { // Fallback to default return new AnnotationDriver($reader, $appEntityPath); } } } } }
[ "public", "function", "getDriver", "(", ")", "{", "$", "config", "=", "$", "this", "->", "config", ";", "if", "(", "$", "this", "->", "isLegacy", "(", ")", ")", "{", "$", "appEntityPath", "=", "DIR_APPLICATION", ".", "'/'", ".", "DIRNAME_CLASSES", ";", "$", "reader", "=", "$", "this", "->", "app", "->", "make", "(", "'orm/cachedSimpleAnnotationReader'", ")", ";", "}", "else", "{", "$", "appEntityPath", "=", "DIR_APPLICATION", ".", "'/'", ".", "DIRNAME_CLASSES", ".", "'/'", ".", "DIRNAME_ENTITIES", ";", "$", "reader", "=", "$", "this", "->", "app", "->", "make", "(", "'orm/cachedAnnotationReader'", ")", ";", "}", "$", "appDriverSettings", "=", "$", "config", "->", "get", "(", "CONFIG_ORM_METADATA_APPLICATION", ")", ";", "$", "xmlConfig", "=", "DIR_APPLICATION", ".", "'/'", ".", "REL_DIR_METADATA_XML", ";", "$", "ymlConfig", "=", "DIR_APPLICATION", ".", "'/'", ".", "REL_DIR_METADATA_YAML", ";", "// Default setting so it comes first", "if", "(", "empty", "(", "$", "appDriverSettings", ")", "&&", "is_dir", "(", "$", "appEntityPath", ")", ")", "{", "return", "new", "AnnotationDriver", "(", "$", "reader", ",", "$", "appEntityPath", ")", ";", "}", "else", "{", "if", "(", "$", "appDriverSettings", "===", "'xml'", ")", "{", "if", "(", "is_dir", "(", "$", "xmlConfig", ")", ")", "{", "return", "new", "XmlDriver", "(", "$", "xmlConfig", ")", ";", "}", "else", "{", "// Fallback to default", "return", "new", "AnnotationDriver", "(", "$", "reader", ",", "$", "appEntityPath", ")", ";", "}", "}", "else", "{", "if", "(", "$", "appDriverSettings", "===", "'yaml'", "||", "$", "appDriverSettings", "===", "'yml'", ")", "{", "if", "(", "is_dir", "(", "$", "ymlConfig", ")", ")", "{", "return", "new", "YamlDriver", "(", "$", "ymlConfig", ")", ";", "}", "else", "{", "// Fallback to default", "return", "new", "AnnotationDriver", "(", "$", "reader", ",", "$", "appEntityPath", ")", ";", "}", "}", "}", "}", "}" ]
Return the correct MappingDriver base on the application config @return XmlDriver|YamlDriver|AnnotationDriver
[ "Return", "the", "correct", "MappingDriver", "base", "on", "the", "application", "config" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Database/EntityManager/Driver/ApplicationDriver.php#L50-L87
train
concrete5/concrete5
concrete/src/File/Service/Zip.php
Zip.isNativeCommandAvailable
public function isNativeCommandAvailable($command) { switch ($command) { case 'zip': case 'unzip': break; default: return false; } if (!isset($this->availableNativeCommands[$command])) { $this->availableNativeCommands[$command] = false; if ($this->functionInspector->functionAvailable('exec')) { $rc = 1; $output = []; @exec($command . ' -v 2>&1', $output, $rc); if ($rc === 0) { $stdOut = implode("\n", $output); if (stripos($stdOut, 'info-zip') !== false || stripos($stdOut, 'infozip') !== false) { $this->availableNativeCommands[$command] = true; } } } } return $this->availableNativeCommands[$command]; }
php
public function isNativeCommandAvailable($command) { switch ($command) { case 'zip': case 'unzip': break; default: return false; } if (!isset($this->availableNativeCommands[$command])) { $this->availableNativeCommands[$command] = false; if ($this->functionInspector->functionAvailable('exec')) { $rc = 1; $output = []; @exec($command . ' -v 2>&1', $output, $rc); if ($rc === 0) { $stdOut = implode("\n", $output); if (stripos($stdOut, 'info-zip') !== false || stripos($stdOut, 'infozip') !== false) { $this->availableNativeCommands[$command] = true; } } } } return $this->availableNativeCommands[$command]; }
[ "public", "function", "isNativeCommandAvailable", "(", "$", "command", ")", "{", "switch", "(", "$", "command", ")", "{", "case", "'zip'", ":", "case", "'unzip'", ":", "break", ";", "default", ":", "return", "false", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "availableNativeCommands", "[", "$", "command", "]", ")", ")", "{", "$", "this", "->", "availableNativeCommands", "[", "$", "command", "]", "=", "false", ";", "if", "(", "$", "this", "->", "functionInspector", "->", "functionAvailable", "(", "'exec'", ")", ")", "{", "$", "rc", "=", "1", ";", "$", "output", "=", "[", "]", ";", "@", "exec", "(", "$", "command", ".", "' -v 2>&1'", ",", "$", "output", ",", "$", "rc", ")", ";", "if", "(", "$", "rc", "===", "0", ")", "{", "$", "stdOut", "=", "implode", "(", "\"\\n\"", ",", "$", "output", ")", ";", "if", "(", "stripos", "(", "$", "stdOut", ",", "'info-zip'", ")", "!==", "false", "||", "stripos", "(", "$", "stdOut", ",", "'infozip'", ")", "!==", "false", ")", "{", "$", "this", "->", "availableNativeCommands", "[", "$", "command", "]", "=", "true", ";", "}", "}", "}", "}", "return", "$", "this", "->", "availableNativeCommands", "[", "$", "command", "]", ";", "}" ]
Check if a native command is available. @param string $command @return bool
[ "Check", "if", "a", "native", "command", "is", "available", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/File/Service/Zip.php#L108-L133
train
concrete5/concrete5
concrete/src/File/Service/Zip.php
Zip.unzip
public function unzip($zipFile, $destinationDirectory, array $options = []) { $fs = $this->getFilesystem(); $normalized = @realpath($zipFile); if ($normalized === false || !$fs->isFile($normalized)) { throw new Exception(t('Unable to find the ZIP file %s', $zipFile)); } $zipFile = str_replace(DIRECTORY_SEPARATOR, '/', $normalized); $normalized = @realpath($destinationDirectory); if ($normalized === false || !$fs->isDirectory($normalized)) { throw new Exception(t('Unable to find the directory %s', $destinationDirectory)); } if (!$fs->isWritable($normalized)) { throw new Exception(t('The directory "%s" is not writable', $destinationDirectory)); } $destinationDirectory = str_replace(DIRECTORY_SEPARATOR, '/', $normalized); $options += [ 'skipCheck' => false, ]; if ($this->mayUseNativeCommand('unzip')) { $this->unzipNative($zipFile, $destinationDirectory, $options); } else { $this->unzipPHP($zipFile, $destinationDirectory, $options); } }
php
public function unzip($zipFile, $destinationDirectory, array $options = []) { $fs = $this->getFilesystem(); $normalized = @realpath($zipFile); if ($normalized === false || !$fs->isFile($normalized)) { throw new Exception(t('Unable to find the ZIP file %s', $zipFile)); } $zipFile = str_replace(DIRECTORY_SEPARATOR, '/', $normalized); $normalized = @realpath($destinationDirectory); if ($normalized === false || !$fs->isDirectory($normalized)) { throw new Exception(t('Unable to find the directory %s', $destinationDirectory)); } if (!$fs->isWritable($normalized)) { throw new Exception(t('The directory "%s" is not writable', $destinationDirectory)); } $destinationDirectory = str_replace(DIRECTORY_SEPARATOR, '/', $normalized); $options += [ 'skipCheck' => false, ]; if ($this->mayUseNativeCommand('unzip')) { $this->unzipNative($zipFile, $destinationDirectory, $options); } else { $this->unzipPHP($zipFile, $destinationDirectory, $options); } }
[ "public", "function", "unzip", "(", "$", "zipFile", ",", "$", "destinationDirectory", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "fs", "=", "$", "this", "->", "getFilesystem", "(", ")", ";", "$", "normalized", "=", "@", "realpath", "(", "$", "zipFile", ")", ";", "if", "(", "$", "normalized", "===", "false", "||", "!", "$", "fs", "->", "isFile", "(", "$", "normalized", ")", ")", "{", "throw", "new", "Exception", "(", "t", "(", "'Unable to find the ZIP file %s'", ",", "$", "zipFile", ")", ")", ";", "}", "$", "zipFile", "=", "str_replace", "(", "DIRECTORY_SEPARATOR", ",", "'/'", ",", "$", "normalized", ")", ";", "$", "normalized", "=", "@", "realpath", "(", "$", "destinationDirectory", ")", ";", "if", "(", "$", "normalized", "===", "false", "||", "!", "$", "fs", "->", "isDirectory", "(", "$", "normalized", ")", ")", "{", "throw", "new", "Exception", "(", "t", "(", "'Unable to find the directory %s'", ",", "$", "destinationDirectory", ")", ")", ";", "}", "if", "(", "!", "$", "fs", "->", "isWritable", "(", "$", "normalized", ")", ")", "{", "throw", "new", "Exception", "(", "t", "(", "'The directory \"%s\" is not writable'", ",", "$", "destinationDirectory", ")", ")", ";", "}", "$", "destinationDirectory", "=", "str_replace", "(", "DIRECTORY_SEPARATOR", ",", "'/'", ",", "$", "normalized", ")", ";", "$", "options", "+=", "[", "'skipCheck'", "=>", "false", ",", "]", ";", "if", "(", "$", "this", "->", "mayUseNativeCommand", "(", "'unzip'", ")", ")", "{", "$", "this", "->", "unzipNative", "(", "$", "zipFile", ",", "$", "destinationDirectory", ",", "$", "options", ")", ";", "}", "else", "{", "$", "this", "->", "unzipPHP", "(", "$", "zipFile", ",", "$", "destinationDirectory", ",", "$", "options", ")", ";", "}", "}" ]
Decompress a ZIP archive to a directory. @param string $zipFile the source ZIP archive @param string $destinationDirectory the destination folder @param array $options { @var bool $skipCheck Skip test compressed archive data } @throws Exception
[ "Decompress", "a", "ZIP", "archive", "to", "a", "directory", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/File/Service/Zip.php#L158-L182
train
concrete5/concrete5
concrete/src/File/Service/Zip.php
Zip.zip
public function zip($sourceDirectory, $zipFile, array $options = []) { $fs = $this->getFilesystem(); $normalized = @realpath($sourceDirectory); if ($normalized === false || !$fs->isDirectory($normalized)) { throw new Exception(t('Unable to find the directory %s', $sourceDirectory)); } $sourceDirectory = $normalized; $zipFile = str_replace('/', DIRECTORY_SEPARATOR, $zipFile); if ($fs->exists($zipFile)) { if ($fs->isDirectory($zipFile)) { throw new Exception(t('The specified path of the ZIP archive (%s) is a directory, not a file', $zipFile)); } $options['append'] = isset($options['append']) ? (bool) $options['append'] : false; if (!$options['append']) { if (@$fs->delete([$zipFile]) === false) { throw new Exception(t('Failed to delete file %s', $zipFile)); } } } else { $options['append'] = false; } $options += [ 'includeDotFiles' => false, 'skipCheck' => false, 'level' => 9, ]; if ($this->mayUseNativeCommand('zip')) { $this->zipNative($sourceDirectory, $zipFile, $options); } else { $this->zipPHP($sourceDirectory, $zipFile, $options); } }
php
public function zip($sourceDirectory, $zipFile, array $options = []) { $fs = $this->getFilesystem(); $normalized = @realpath($sourceDirectory); if ($normalized === false || !$fs->isDirectory($normalized)) { throw new Exception(t('Unable to find the directory %s', $sourceDirectory)); } $sourceDirectory = $normalized; $zipFile = str_replace('/', DIRECTORY_SEPARATOR, $zipFile); if ($fs->exists($zipFile)) { if ($fs->isDirectory($zipFile)) { throw new Exception(t('The specified path of the ZIP archive (%s) is a directory, not a file', $zipFile)); } $options['append'] = isset($options['append']) ? (bool) $options['append'] : false; if (!$options['append']) { if (@$fs->delete([$zipFile]) === false) { throw new Exception(t('Failed to delete file %s', $zipFile)); } } } else { $options['append'] = false; } $options += [ 'includeDotFiles' => false, 'skipCheck' => false, 'level' => 9, ]; if ($this->mayUseNativeCommand('zip')) { $this->zipNative($sourceDirectory, $zipFile, $options); } else { $this->zipPHP($sourceDirectory, $zipFile, $options); } }
[ "public", "function", "zip", "(", "$", "sourceDirectory", ",", "$", "zipFile", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "fs", "=", "$", "this", "->", "getFilesystem", "(", ")", ";", "$", "normalized", "=", "@", "realpath", "(", "$", "sourceDirectory", ")", ";", "if", "(", "$", "normalized", "===", "false", "||", "!", "$", "fs", "->", "isDirectory", "(", "$", "normalized", ")", ")", "{", "throw", "new", "Exception", "(", "t", "(", "'Unable to find the directory %s'", ",", "$", "sourceDirectory", ")", ")", ";", "}", "$", "sourceDirectory", "=", "$", "normalized", ";", "$", "zipFile", "=", "str_replace", "(", "'/'", ",", "DIRECTORY_SEPARATOR", ",", "$", "zipFile", ")", ";", "if", "(", "$", "fs", "->", "exists", "(", "$", "zipFile", ")", ")", "{", "if", "(", "$", "fs", "->", "isDirectory", "(", "$", "zipFile", ")", ")", "{", "throw", "new", "Exception", "(", "t", "(", "'The specified path of the ZIP archive (%s) is a directory, not a file'", ",", "$", "zipFile", ")", ")", ";", "}", "$", "options", "[", "'append'", "]", "=", "isset", "(", "$", "options", "[", "'append'", "]", ")", "?", "(", "bool", ")", "$", "options", "[", "'append'", "]", ":", "false", ";", "if", "(", "!", "$", "options", "[", "'append'", "]", ")", "{", "if", "(", "@", "$", "fs", "->", "delete", "(", "[", "$", "zipFile", "]", ")", "===", "false", ")", "{", "throw", "new", "Exception", "(", "t", "(", "'Failed to delete file %s'", ",", "$", "zipFile", ")", ")", ";", "}", "}", "}", "else", "{", "$", "options", "[", "'append'", "]", "=", "false", ";", "}", "$", "options", "+=", "[", "'includeDotFiles'", "=>", "false", ",", "'skipCheck'", "=>", "false", ",", "'level'", "=>", "9", ",", "]", ";", "if", "(", "$", "this", "->", "mayUseNativeCommand", "(", "'zip'", ")", ")", "{", "$", "this", "->", "zipNative", "(", "$", "sourceDirectory", ",", "$", "zipFile", ",", "$", "options", ")", ";", "}", "else", "{", "$", "this", "->", "zipPHP", "(", "$", "sourceDirectory", ",", "$", "zipFile", ",", "$", "options", ")", ";", "}", "}" ]
Compress the contents of a directory to a ZIP archive. @param string $sourceDirectory the directory to compress @param string $zipFile the ZIP file to create (it will be deleted if already existing, unless the 'append' option is set to true) @param array $options { @var bool $includeDotFiles Shall the zip file include files and folders whose name starts with a dot? @var bool $skipCheck Skip test compressed archive data @var int $level Compression level (0 to 9) @var bool $append Append to an existing archive instead of overwriting it? } @throws Exception
[ "Compress", "the", "contents", "of", "a", "directory", "to", "a", "ZIP", "archive", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/File/Service/Zip.php#L198-L230
train
concrete5/concrete5
concrete/src/File/Service/Zip.php
Zip.listContents
public function listContents($zipFile, array $options = []) { $fs = $this->getFilesystem(); if (!$fs->isFile($zipFile)) { throw new Exception(t('Unable to find the ZIP file %s', $zipFile)); } $options += [ 'skipCheck' => false, 'excludeDirs' => false, 'excludeFiles' => false, ]; $result = []; $zip = new ZipArchive(); try { $flags = 0; if (!$options['skipCheck']) { $flags |= ZipArchive::CHECKCONS; } $zipErr = @$zip->open($zipFile, $flags); if ($zipErr !== true) { throw new Exception($this->describeZipArchiveError($zip, $zipErr)); } for ($index = 0; $index < $zip->numFiles; ++$index) { $stat = @$zip->statIndex($index); if ($stat === false) { throw new Exception(t('Failed to retrieve the details of a ZIP archive entry.')); } $isDir = substr($stat['name'], -1) === '/' || substr($stat['name'], -1) === '\\'; if ($isDir) { if ($options['excludeDirs']) { continue; } } else { if ($options['excludeFiles']) { continue; } } $item = [ 'type' => $isDir ? 'D' : 'F', 'date' => (isset($stat['mtime']) && $stat['mtime']) ? DateTime::createFromFormat('U', $stat['mtime']) : null, ]; if (!$isDir) { $item += [ 'originalSize' => isset($stat['size']) ? (int) $stat['size'] : null, 'compressedSize' => isset($stat['comp_size']) ? (int) $stat['comp_size'] : null, ]; } $result[trim($stat['name'], '/\\')] = $item; } @$zip->close(); $zip = null; } catch (Exception $x) { if ($zip !== null) { try { @$zip->close(); } catch (\Exception $foo) { } $zip = null; } throw $x; } return $result; }
php
public function listContents($zipFile, array $options = []) { $fs = $this->getFilesystem(); if (!$fs->isFile($zipFile)) { throw new Exception(t('Unable to find the ZIP file %s', $zipFile)); } $options += [ 'skipCheck' => false, 'excludeDirs' => false, 'excludeFiles' => false, ]; $result = []; $zip = new ZipArchive(); try { $flags = 0; if (!$options['skipCheck']) { $flags |= ZipArchive::CHECKCONS; } $zipErr = @$zip->open($zipFile, $flags); if ($zipErr !== true) { throw new Exception($this->describeZipArchiveError($zip, $zipErr)); } for ($index = 0; $index < $zip->numFiles; ++$index) { $stat = @$zip->statIndex($index); if ($stat === false) { throw new Exception(t('Failed to retrieve the details of a ZIP archive entry.')); } $isDir = substr($stat['name'], -1) === '/' || substr($stat['name'], -1) === '\\'; if ($isDir) { if ($options['excludeDirs']) { continue; } } else { if ($options['excludeFiles']) { continue; } } $item = [ 'type' => $isDir ? 'D' : 'F', 'date' => (isset($stat['mtime']) && $stat['mtime']) ? DateTime::createFromFormat('U', $stat['mtime']) : null, ]; if (!$isDir) { $item += [ 'originalSize' => isset($stat['size']) ? (int) $stat['size'] : null, 'compressedSize' => isset($stat['comp_size']) ? (int) $stat['comp_size'] : null, ]; } $result[trim($stat['name'], '/\\')] = $item; } @$zip->close(); $zip = null; } catch (Exception $x) { if ($zip !== null) { try { @$zip->close(); } catch (\Exception $foo) { } $zip = null; } throw $x; } return $result; }
[ "public", "function", "listContents", "(", "$", "zipFile", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "fs", "=", "$", "this", "->", "getFilesystem", "(", ")", ";", "if", "(", "!", "$", "fs", "->", "isFile", "(", "$", "zipFile", ")", ")", "{", "throw", "new", "Exception", "(", "t", "(", "'Unable to find the ZIP file %s'", ",", "$", "zipFile", ")", ")", ";", "}", "$", "options", "+=", "[", "'skipCheck'", "=>", "false", ",", "'excludeDirs'", "=>", "false", ",", "'excludeFiles'", "=>", "false", ",", "]", ";", "$", "result", "=", "[", "]", ";", "$", "zip", "=", "new", "ZipArchive", "(", ")", ";", "try", "{", "$", "flags", "=", "0", ";", "if", "(", "!", "$", "options", "[", "'skipCheck'", "]", ")", "{", "$", "flags", "|=", "ZipArchive", "::", "CHECKCONS", ";", "}", "$", "zipErr", "=", "@", "$", "zip", "->", "open", "(", "$", "zipFile", ",", "$", "flags", ")", ";", "if", "(", "$", "zipErr", "!==", "true", ")", "{", "throw", "new", "Exception", "(", "$", "this", "->", "describeZipArchiveError", "(", "$", "zip", ",", "$", "zipErr", ")", ")", ";", "}", "for", "(", "$", "index", "=", "0", ";", "$", "index", "<", "$", "zip", "->", "numFiles", ";", "++", "$", "index", ")", "{", "$", "stat", "=", "@", "$", "zip", "->", "statIndex", "(", "$", "index", ")", ";", "if", "(", "$", "stat", "===", "false", ")", "{", "throw", "new", "Exception", "(", "t", "(", "'Failed to retrieve the details of a ZIP archive entry.'", ")", ")", ";", "}", "$", "isDir", "=", "substr", "(", "$", "stat", "[", "'name'", "]", ",", "-", "1", ")", "===", "'/'", "||", "substr", "(", "$", "stat", "[", "'name'", "]", ",", "-", "1", ")", "===", "'\\\\'", ";", "if", "(", "$", "isDir", ")", "{", "if", "(", "$", "options", "[", "'excludeDirs'", "]", ")", "{", "continue", ";", "}", "}", "else", "{", "if", "(", "$", "options", "[", "'excludeFiles'", "]", ")", "{", "continue", ";", "}", "}", "$", "item", "=", "[", "'type'", "=>", "$", "isDir", "?", "'D'", ":", "'F'", ",", "'date'", "=>", "(", "isset", "(", "$", "stat", "[", "'mtime'", "]", ")", "&&", "$", "stat", "[", "'mtime'", "]", ")", "?", "DateTime", "::", "createFromFormat", "(", "'U'", ",", "$", "stat", "[", "'mtime'", "]", ")", ":", "null", ",", "]", ";", "if", "(", "!", "$", "isDir", ")", "{", "$", "item", "+=", "[", "'originalSize'", "=>", "isset", "(", "$", "stat", "[", "'size'", "]", ")", "?", "(", "int", ")", "$", "stat", "[", "'size'", "]", ":", "null", ",", "'compressedSize'", "=>", "isset", "(", "$", "stat", "[", "'comp_size'", "]", ")", "?", "(", "int", ")", "$", "stat", "[", "'comp_size'", "]", ":", "null", ",", "]", ";", "}", "$", "result", "[", "trim", "(", "$", "stat", "[", "'name'", "]", ",", "'/\\\\'", ")", "]", "=", "$", "item", ";", "}", "@", "$", "zip", "->", "close", "(", ")", ";", "$", "zip", "=", "null", ";", "}", "catch", "(", "Exception", "$", "x", ")", "{", "if", "(", "$", "zip", "!==", "null", ")", "{", "try", "{", "@", "$", "zip", "->", "close", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "foo", ")", "{", "}", "$", "zip", "=", "null", ";", "}", "throw", "$", "x", ";", "}", "return", "$", "result", ";", "}" ]
List the contents of a ZIP archive. @param string $zipFile the ZIP file to inspect @param array $options { @var bool $skipCheck Skip test compressed archive data @var bool $excludeDirs Don't include directories @var bool $excludeFiles Don't include files } @throws Exception @return array The keys of the resulting array contain the paths to the items, and the values will be arrays, whose keys are: - string 'type' For directories it will be 'D', for files it will be 'F' - \DateTime 'date' Last modification date/time - int 'originalSize' (only for files) Uncompressed size of the file - int 'compressedSize' (only for files) Compressed size of the file
[ "List", "the", "contents", "of", "a", "ZIP", "archive", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/File/Service/Zip.php#L250-L313
train
concrete5/concrete5
concrete/src/File/Service/Zip.php
Zip.unzipNative
protected function unzipNative($zipFile, $destinationDirectory, array $options) { $cmd = 'unzip'; $cmd .= ' -o'; // overwrite files WITHOUT prompting $cmd .= ' -q'; // quiet mode, to avoid overflow of stdout $cmd .= ' ' . escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $zipFile)); // file to extract $cmd .= ' -d ' . escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $destinationDirectory)); // destination directory $rc = 1; $output = []; @exec($cmd . ' 2>&1', $output, $rc); if ($rc !== 0) { $error = trim(implode("\n", $output)) ?: t('Unknown error decompressing a ZIP archive'); throw new Exception($error); } }
php
protected function unzipNative($zipFile, $destinationDirectory, array $options) { $cmd = 'unzip'; $cmd .= ' -o'; // overwrite files WITHOUT prompting $cmd .= ' -q'; // quiet mode, to avoid overflow of stdout $cmd .= ' ' . escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $zipFile)); // file to extract $cmd .= ' -d ' . escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $destinationDirectory)); // destination directory $rc = 1; $output = []; @exec($cmd . ' 2>&1', $output, $rc); if ($rc !== 0) { $error = trim(implode("\n", $output)) ?: t('Unknown error decompressing a ZIP archive'); throw new Exception($error); } }
[ "protected", "function", "unzipNative", "(", "$", "zipFile", ",", "$", "destinationDirectory", ",", "array", "$", "options", ")", "{", "$", "cmd", "=", "'unzip'", ";", "$", "cmd", ".=", "' -o'", ";", "// overwrite files WITHOUT prompting", "$", "cmd", ".=", "' -q'", ";", "// quiet mode, to avoid overflow of stdout", "$", "cmd", ".=", "' '", ".", "escapeshellarg", "(", "str_replace", "(", "'/'", ",", "DIRECTORY_SEPARATOR", ",", "$", "zipFile", ")", ")", ";", "// file to extract", "$", "cmd", ".=", "' -d '", ".", "escapeshellarg", "(", "str_replace", "(", "'/'", ",", "DIRECTORY_SEPARATOR", ",", "$", "destinationDirectory", ")", ")", ";", "// destination directory", "$", "rc", "=", "1", ";", "$", "output", "=", "[", "]", ";", "@", "exec", "(", "$", "cmd", ".", "' 2>&1'", ",", "$", "output", ",", "$", "rc", ")", ";", "if", "(", "$", "rc", "!==", "0", ")", "{", "$", "error", "=", "trim", "(", "implode", "(", "\"\\n\"", ",", "$", "output", ")", ")", "?", ":", "t", "(", "'Unknown error decompressing a ZIP archive'", ")", ";", "throw", "new", "Exception", "(", "$", "error", ")", ";", "}", "}" ]
Decompress a ZIP archive to a directory using the native 'unzip' command. @param string $zipFile @param string $destinationDirectory @param array $options @throws Exception
[ "Decompress", "a", "ZIP", "archive", "to", "a", "directory", "using", "the", "native", "unzip", "command", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/File/Service/Zip.php#L427-L441
train
concrete5/concrete5
concrete/src/File/Service/Zip.php
Zip.unzipPHP
protected function unzipPHP($zipFile, $destinationDirectory, array $options) { if (!class_exists('ZipArchive')) { throw new Exception('Unable to unzip files using ZipArchive. Please ensure the Zip extension is installed.'); } $zip = new ZipArchive(); try { $flags = 0; if (!$options['skipCheck']) { $flags |= ZipArchive::CHECKCONS; } $zipErr = @$zip->open($zipFile, $flags); if ($zipErr !== true) { throw new Exception($this->describeZipArchiveError($zip, $zipErr)); } if (@$zip->extractTo($destinationDirectory) !== true) { throw new Exception($this->describeZipArchiveError($zip, ZipArchive::ER_OK)); } @$zip->close(); $zip = null; } catch (Exception $x) { if ($zip !== null) { try { @$zip->close(); } catch (\Exception $foo) { } $zip = null; } throw $x; } }
php
protected function unzipPHP($zipFile, $destinationDirectory, array $options) { if (!class_exists('ZipArchive')) { throw new Exception('Unable to unzip files using ZipArchive. Please ensure the Zip extension is installed.'); } $zip = new ZipArchive(); try { $flags = 0; if (!$options['skipCheck']) { $flags |= ZipArchive::CHECKCONS; } $zipErr = @$zip->open($zipFile, $flags); if ($zipErr !== true) { throw new Exception($this->describeZipArchiveError($zip, $zipErr)); } if (@$zip->extractTo($destinationDirectory) !== true) { throw new Exception($this->describeZipArchiveError($zip, ZipArchive::ER_OK)); } @$zip->close(); $zip = null; } catch (Exception $x) { if ($zip !== null) { try { @$zip->close(); } catch (\Exception $foo) { } $zip = null; } throw $x; } }
[ "protected", "function", "unzipPHP", "(", "$", "zipFile", ",", "$", "destinationDirectory", ",", "array", "$", "options", ")", "{", "if", "(", "!", "class_exists", "(", "'ZipArchive'", ")", ")", "{", "throw", "new", "Exception", "(", "'Unable to unzip files using ZipArchive. Please ensure the Zip extension is installed.'", ")", ";", "}", "$", "zip", "=", "new", "ZipArchive", "(", ")", ";", "try", "{", "$", "flags", "=", "0", ";", "if", "(", "!", "$", "options", "[", "'skipCheck'", "]", ")", "{", "$", "flags", "|=", "ZipArchive", "::", "CHECKCONS", ";", "}", "$", "zipErr", "=", "@", "$", "zip", "->", "open", "(", "$", "zipFile", ",", "$", "flags", ")", ";", "if", "(", "$", "zipErr", "!==", "true", ")", "{", "throw", "new", "Exception", "(", "$", "this", "->", "describeZipArchiveError", "(", "$", "zip", ",", "$", "zipErr", ")", ")", ";", "}", "if", "(", "@", "$", "zip", "->", "extractTo", "(", "$", "destinationDirectory", ")", "!==", "true", ")", "{", "throw", "new", "Exception", "(", "$", "this", "->", "describeZipArchiveError", "(", "$", "zip", ",", "ZipArchive", "::", "ER_OK", ")", ")", ";", "}", "@", "$", "zip", "->", "close", "(", ")", ";", "$", "zip", "=", "null", ";", "}", "catch", "(", "Exception", "$", "x", ")", "{", "if", "(", "$", "zip", "!==", "null", ")", "{", "try", "{", "@", "$", "zip", "->", "close", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "foo", ")", "{", "}", "$", "zip", "=", "null", ";", "}", "throw", "$", "x", ";", "}", "}" ]
Decompress a ZIP archive to a directory using the PHP functions. @param string $zipFile @param string $destinationDirectory @param array $options @throws Exception
[ "Decompress", "a", "ZIP", "archive", "to", "a", "directory", "using", "the", "PHP", "functions", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/File/Service/Zip.php#L452-L482
train
concrete5/concrete5
concrete/src/File/Service/Zip.php
Zip.zipPHP
protected function zipPHP($sourceDirectory, $zipFile, array $options) { if (!class_exists('ZipArchive')) { throw new Exception('Unable to zip files using ZipArchive. Please ensure the Zip extension is installed.'); } $zip = new ZipArchive(); try { $flags = ZipArchive::CREATE; if (!$options['skipCheck']) { $flags |= ZipArchive::CHECKCONS; } $zipErr = @$zip->open($zipFile, $flags); if ($zipErr !== true) { throw new Exception($this->describeZipArchiveError($zip, $zipErr)); } $skipPathLength = strlen(rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $sourceDirectory), '/')) + 1; $contents = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($sourceDirectory), \RecursiveIteratorIterator::SELF_FIRST ); foreach ($contents as $item) { switch ($item->getFilename()) { case '.': case '..': break; default: $itemFullPath = $item->getRealPath(); $itemRelPath = substr(str_replace(DIRECTORY_SEPARATOR, '/', $itemFullPath), $skipPathLength); if ( $options['includeDotFiles'] || ( strpos($itemRelPath, '.') !== 0 && strpos($itemRelPath, '/.') === false ) ) { if ($item->isDir()) { $added = @$zip->addEmptyDir($itemRelPath); } else { $added = @$zip->addFile($itemFullPath, $itemRelPath); } if ($added !== true) { throw new Exception($this->describeZipArchiveError($zip, ZipArchive::ER_OK)); } } break; } } if (@$zip->close() !== true) { throw new Exception($this->describeZipArchiveError($zip, ZipArchive::ER_OK)); } $zip = null; } catch (Exception $x) { if ($zip !== null) { try { @$zip->close(); } catch (\Exception $foo) { } $zip = null; } @$this->getFilesystem()->delete([$zipFile]); throw $x; } }
php
protected function zipPHP($sourceDirectory, $zipFile, array $options) { if (!class_exists('ZipArchive')) { throw new Exception('Unable to zip files using ZipArchive. Please ensure the Zip extension is installed.'); } $zip = new ZipArchive(); try { $flags = ZipArchive::CREATE; if (!$options['skipCheck']) { $flags |= ZipArchive::CHECKCONS; } $zipErr = @$zip->open($zipFile, $flags); if ($zipErr !== true) { throw new Exception($this->describeZipArchiveError($zip, $zipErr)); } $skipPathLength = strlen(rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $sourceDirectory), '/')) + 1; $contents = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($sourceDirectory), \RecursiveIteratorIterator::SELF_FIRST ); foreach ($contents as $item) { switch ($item->getFilename()) { case '.': case '..': break; default: $itemFullPath = $item->getRealPath(); $itemRelPath = substr(str_replace(DIRECTORY_SEPARATOR, '/', $itemFullPath), $skipPathLength); if ( $options['includeDotFiles'] || ( strpos($itemRelPath, '.') !== 0 && strpos($itemRelPath, '/.') === false ) ) { if ($item->isDir()) { $added = @$zip->addEmptyDir($itemRelPath); } else { $added = @$zip->addFile($itemFullPath, $itemRelPath); } if ($added !== true) { throw new Exception($this->describeZipArchiveError($zip, ZipArchive::ER_OK)); } } break; } } if (@$zip->close() !== true) { throw new Exception($this->describeZipArchiveError($zip, ZipArchive::ER_OK)); } $zip = null; } catch (Exception $x) { if ($zip !== null) { try { @$zip->close(); } catch (\Exception $foo) { } $zip = null; } @$this->getFilesystem()->delete([$zipFile]); throw $x; } }
[ "protected", "function", "zipPHP", "(", "$", "sourceDirectory", ",", "$", "zipFile", ",", "array", "$", "options", ")", "{", "if", "(", "!", "class_exists", "(", "'ZipArchive'", ")", ")", "{", "throw", "new", "Exception", "(", "'Unable to zip files using ZipArchive. Please ensure the Zip extension is installed.'", ")", ";", "}", "$", "zip", "=", "new", "ZipArchive", "(", ")", ";", "try", "{", "$", "flags", "=", "ZipArchive", "::", "CREATE", ";", "if", "(", "!", "$", "options", "[", "'skipCheck'", "]", ")", "{", "$", "flags", "|=", "ZipArchive", "::", "CHECKCONS", ";", "}", "$", "zipErr", "=", "@", "$", "zip", "->", "open", "(", "$", "zipFile", ",", "$", "flags", ")", ";", "if", "(", "$", "zipErr", "!==", "true", ")", "{", "throw", "new", "Exception", "(", "$", "this", "->", "describeZipArchiveError", "(", "$", "zip", ",", "$", "zipErr", ")", ")", ";", "}", "$", "skipPathLength", "=", "strlen", "(", "rtrim", "(", "str_replace", "(", "DIRECTORY_SEPARATOR", ",", "'/'", ",", "$", "sourceDirectory", ")", ",", "'/'", ")", ")", "+", "1", ";", "$", "contents", "=", "new", "\\", "RecursiveIteratorIterator", "(", "new", "\\", "RecursiveDirectoryIterator", "(", "$", "sourceDirectory", ")", ",", "\\", "RecursiveIteratorIterator", "::", "SELF_FIRST", ")", ";", "foreach", "(", "$", "contents", "as", "$", "item", ")", "{", "switch", "(", "$", "item", "->", "getFilename", "(", ")", ")", "{", "case", "'.'", ":", "case", "'..'", ":", "break", ";", "default", ":", "$", "itemFullPath", "=", "$", "item", "->", "getRealPath", "(", ")", ";", "$", "itemRelPath", "=", "substr", "(", "str_replace", "(", "DIRECTORY_SEPARATOR", ",", "'/'", ",", "$", "itemFullPath", ")", ",", "$", "skipPathLength", ")", ";", "if", "(", "$", "options", "[", "'includeDotFiles'", "]", "||", "(", "strpos", "(", "$", "itemRelPath", ",", "'.'", ")", "!==", "0", "&&", "strpos", "(", "$", "itemRelPath", ",", "'/.'", ")", "===", "false", ")", ")", "{", "if", "(", "$", "item", "->", "isDir", "(", ")", ")", "{", "$", "added", "=", "@", "$", "zip", "->", "addEmptyDir", "(", "$", "itemRelPath", ")", ";", "}", "else", "{", "$", "added", "=", "@", "$", "zip", "->", "addFile", "(", "$", "itemFullPath", ",", "$", "itemRelPath", ")", ";", "}", "if", "(", "$", "added", "!==", "true", ")", "{", "throw", "new", "Exception", "(", "$", "this", "->", "describeZipArchiveError", "(", "$", "zip", ",", "ZipArchive", "::", "ER_OK", ")", ")", ";", "}", "}", "break", ";", "}", "}", "if", "(", "@", "$", "zip", "->", "close", "(", ")", "!==", "true", ")", "{", "throw", "new", "Exception", "(", "$", "this", "->", "describeZipArchiveError", "(", "$", "zip", ",", "ZipArchive", "::", "ER_OK", ")", ")", ";", "}", "$", "zip", "=", "null", ";", "}", "catch", "(", "Exception", "$", "x", ")", "{", "if", "(", "$", "zip", "!==", "null", ")", "{", "try", "{", "@", "$", "zip", "->", "close", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "foo", ")", "{", "}", "$", "zip", "=", "null", ";", "}", "@", "$", "this", "->", "getFilesystem", "(", ")", "->", "delete", "(", "[", "$", "zipFile", "]", ")", ";", "throw", "$", "x", ";", "}", "}" ]
Compress the contents of a directory to a ZIP archive using the PHP functions. @param string $sourceDirectory @param string $zipFile @param array $options @throws Exception
[ "Compress", "the", "contents", "of", "a", "directory", "to", "a", "ZIP", "archive", "using", "the", "PHP", "functions", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/File/Service/Zip.php#L574-L638
train
concrete5/concrete5
concrete/src/System/Mutex/MutexTrait.php
MutexTrait.getFilenameForMutexKey
protected function getFilenameForMutexKey($mutexKey) { $mutexKeyString = (is_string($mutexKey) || is_int($mutexKey)) ? (string) $mutexKey : ''; if ($mutexKeyString === '') { throw new InvalidMutexKeyException($mutexKey); } if (preg_match('/^[a-zA-Z0-9_\-]{1,50}$/', $mutexKeyString)) { $filenameChunk = $mutexKeyString; } else { $filenameChunk = sha1($mutexKeyString); } return $this->temporaryDirectory . '/mutex-' . md5(DIR_APPLICATION) . '-' . $filenameChunk . '.lock'; }
php
protected function getFilenameForMutexKey($mutexKey) { $mutexKeyString = (is_string($mutexKey) || is_int($mutexKey)) ? (string) $mutexKey : ''; if ($mutexKeyString === '') { throw new InvalidMutexKeyException($mutexKey); } if (preg_match('/^[a-zA-Z0-9_\-]{1,50}$/', $mutexKeyString)) { $filenameChunk = $mutexKeyString; } else { $filenameChunk = sha1($mutexKeyString); } return $this->temporaryDirectory . '/mutex-' . md5(DIR_APPLICATION) . '-' . $filenameChunk . '.lock'; }
[ "protected", "function", "getFilenameForMutexKey", "(", "$", "mutexKey", ")", "{", "$", "mutexKeyString", "=", "(", "is_string", "(", "$", "mutexKey", ")", "||", "is_int", "(", "$", "mutexKey", ")", ")", "?", "(", "string", ")", "$", "mutexKey", ":", "''", ";", "if", "(", "$", "mutexKeyString", "===", "''", ")", "{", "throw", "new", "InvalidMutexKeyException", "(", "$", "mutexKey", ")", ";", "}", "if", "(", "preg_match", "(", "'/^[a-zA-Z0-9_\\-]{1,50}$/'", ",", "$", "mutexKeyString", ")", ")", "{", "$", "filenameChunk", "=", "$", "mutexKeyString", ";", "}", "else", "{", "$", "filenameChunk", "=", "sha1", "(", "$", "mutexKeyString", ")", ";", "}", "return", "$", "this", "->", "temporaryDirectory", ".", "'/mutex-'", ".", "md5", "(", "DIR_APPLICATION", ")", ".", "'-'", ".", "$", "filenameChunk", ".", "'.lock'", ";", "}" ]
Get the full path of a temporary file that's unique for the concrete5 application and for the specified mutex key. @param string $key The mutex key @param mixed $mutexKey @throws InvalidMutexKeyException @return string
[ "Get", "the", "full", "path", "of", "a", "temporary", "file", "that", "s", "unique", "for", "the", "concrete5", "application", "and", "for", "the", "specified", "mutex", "key", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/System/Mutex/MutexTrait.php#L38-L51
train
concrete5/concrete5
concrete/src/Legacy/FileList.php
FileList.filterByTag
public function filterByTag($tag = '') { $db = Loader::db(); $this->filter(false, "( fv.fvTags like ".$db->qstr("%\n".$tag."\n%")." )"); }
php
public function filterByTag($tag = '') { $db = Loader::db(); $this->filter(false, "( fv.fvTags like ".$db->qstr("%\n".$tag."\n%")." )"); }
[ "public", "function", "filterByTag", "(", "$", "tag", "=", "''", ")", "{", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "this", "->", "filter", "(", "false", ",", "\"( fv.fvTags like \"", ".", "$", "db", "->", "qstr", "(", "\"%\\n\"", ".", "$", "tag", ".", "\"\\n%\"", ")", ".", "\" )\"", ")", ";", "}" ]
Filters by tag. @param string $tag
[ "Filters", "by", "tag", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Legacy/FileList.php#L229-L233
train
concrete5/concrete5
concrete/src/Legacy/FileList.php
FileList.get
public function get($itemsToGet = 0, $offset = 0) { $files = array(); $this->createQuery(); $r = parent::get($itemsToGet, $offset); foreach ($r as $row) { $f = ConcreteFile::getByID($row['fID']); $files[] = $f; } return $files; }
php
public function get($itemsToGet = 0, $offset = 0) { $files = array(); $this->createQuery(); $r = parent::get($itemsToGet, $offset); foreach ($r as $row) { $f = ConcreteFile::getByID($row['fID']); $files[] = $f; } return $files; }
[ "public", "function", "get", "(", "$", "itemsToGet", "=", "0", ",", "$", "offset", "=", "0", ")", "{", "$", "files", "=", "array", "(", ")", ";", "$", "this", "->", "createQuery", "(", ")", ";", "$", "r", "=", "parent", "::", "get", "(", "$", "itemsToGet", ",", "$", "offset", ")", ";", "foreach", "(", "$", "r", "as", "$", "row", ")", "{", "$", "f", "=", "ConcreteFile", "::", "getByID", "(", "$", "row", "[", "'fID'", "]", ")", ";", "$", "files", "[", "]", "=", "$", "f", ";", "}", "return", "$", "files", ";", "}" ]
Returns an array of file objects based on current settings.
[ "Returns", "an", "array", "of", "file", "objects", "based", "on", "current", "settings", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Legacy/FileList.php#L362-L373
train
concrete5/concrete5
concrete/src/Editor/PluginManager.php
PluginManager.register
public function register($plugin, $name = null) { if ($plugin instanceof Plugin) { $key = $plugin->getKey(); $p = $plugin; } else { if (!$name) { throw new Exception(t('You must specify a plugin key and name.')); } $key = $plugin; $p = new Plugin(); $p->setKey($key); $p->setName($name); } $this->plugins[$key] = $p; }
php
public function register($plugin, $name = null) { if ($plugin instanceof Plugin) { $key = $plugin->getKey(); $p = $plugin; } else { if (!$name) { throw new Exception(t('You must specify a plugin key and name.')); } $key = $plugin; $p = new Plugin(); $p->setKey($key); $p->setName($name); } $this->plugins[$key] = $p; }
[ "public", "function", "register", "(", "$", "plugin", ",", "$", "name", "=", "null", ")", "{", "if", "(", "$", "plugin", "instanceof", "Plugin", ")", "{", "$", "key", "=", "$", "plugin", "->", "getKey", "(", ")", ";", "$", "p", "=", "$", "plugin", ";", "}", "else", "{", "if", "(", "!", "$", "name", ")", "{", "throw", "new", "Exception", "(", "t", "(", "'You must specify a plugin key and name.'", ")", ")", ";", "}", "$", "key", "=", "$", "plugin", ";", "$", "p", "=", "new", "Plugin", "(", ")", ";", "$", "p", "->", "setKey", "(", "$", "key", ")", ";", "$", "p", "->", "setName", "(", "$", "name", ")", ";", "}", "$", "this", "->", "plugins", "[", "$", "key", "]", "=", "$", "p", ";", "}" ]
Register a new plugin, adding it to the list of available plugins. @param \Concrete\Core\Editor\Plugin|string $plugin the plugin to register (or its handle) @param string|null $name the name of the plugin (if $plugin is the plugin handle @throws \Exception throws an Exception if $plugin is the plugin handle, but $name is empty
[ "Register", "a", "new", "plugin", "adding", "it", "to", "the", "list", "of", "available", "plugins", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Editor/PluginManager.php#L31-L46
train
concrete5/concrete5
concrete/controllers/backend/tree/node.php
Node.load_starting
public function load_starting() { $node = $this->loadNode(); $r = array(); foreach ($node->getChildNodes() as $childnode) { $json = $childnode->getTreeNodeJSON(); if ($json) { $r[] = $json; } } $node = $node->getTreeNodeJSON(); $node->children = $r; return new JsonResponse([$node]); }
php
public function load_starting() { $node = $this->loadNode(); $r = array(); foreach ($node->getChildNodes() as $childnode) { $json = $childnode->getTreeNodeJSON(); if ($json) { $r[] = $json; } } $node = $node->getTreeNodeJSON(); $node->children = $r; return new JsonResponse([$node]); }
[ "public", "function", "load_starting", "(", ")", "{", "$", "node", "=", "$", "this", "->", "loadNode", "(", ")", ";", "$", "r", "=", "array", "(", ")", ";", "foreach", "(", "$", "node", "->", "getChildNodes", "(", ")", "as", "$", "childnode", ")", "{", "$", "json", "=", "$", "childnode", "->", "getTreeNodeJSON", "(", ")", ";", "if", "(", "$", "json", ")", "{", "$", "r", "[", "]", "=", "$", "json", ";", "}", "}", "$", "node", "=", "$", "node", "->", "getTreeNodeJSON", "(", ")", ";", "$", "node", "->", "children", "=", "$", "r", ";", "return", "new", "JsonResponse", "(", "[", "$", "node", "]", ")", ";", "}" ]
This endpoint is meant to be called when we are starting from a particular spot in the tree. It will include the current node, and the children, while normally loading the node will only return the children. @return JsonResponse
[ "This", "endpoint", "is", "meant", "to", "be", "called", "when", "we", "are", "starting", "from", "a", "particular", "spot", "in", "the", "tree", ".", "It", "will", "include", "the", "current", "node", "and", "the", "children", "while", "normally", "loading", "the", "node", "will", "only", "return", "the", "children", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/controllers/backend/tree/node.php#L53-L67
train
concrete5/concrete5
concrete/controllers/backend/tree/node.php
Node.load
public function load() { $node = $this->loadNode(); $r = array(); foreach ($node->getChildNodes() as $childnode) { $json = $childnode->getTreeNodeJSON(); if ($json) { $r[] = $json; } } return new JsonResponse($r); }
php
public function load() { $node = $this->loadNode(); $r = array(); foreach ($node->getChildNodes() as $childnode) { $json = $childnode->getTreeNodeJSON(); if ($json) { $r[] = $json; } } return new JsonResponse($r); }
[ "public", "function", "load", "(", ")", "{", "$", "node", "=", "$", "this", "->", "loadNode", "(", ")", ";", "$", "r", "=", "array", "(", ")", ";", "foreach", "(", "$", "node", "->", "getChildNodes", "(", ")", "as", "$", "childnode", ")", "{", "$", "json", "=", "$", "childnode", "->", "getTreeNodeJSON", "(", ")", ";", "if", "(", "$", "json", ")", "{", "$", "r", "[", "]", "=", "$", "json", ";", "}", "}", "return", "new", "JsonResponse", "(", "$", "r", ")", ";", "}" ]
Returns the child nodes of the current node. @return JsonResponse
[ "Returns", "the", "child", "nodes", "of", "the", "current", "node", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/controllers/backend/tree/node.php#L73-L84
train
concrete5/concrete5
concrete/src/Http/Middleware/ApplicationMiddleware.php
ApplicationMiddleware.process
public function process(Request $request, DelegateInterface $frame) { \Concrete\Core\Http\Request::setInstance($request); $this->app->instance('Concrete\Core\Http\Request', $request); return $frame->next($request); }
php
public function process(Request $request, DelegateInterface $frame) { \Concrete\Core\Http\Request::setInstance($request); $this->app->instance('Concrete\Core\Http\Request', $request); return $frame->next($request); }
[ "public", "function", "process", "(", "Request", "$", "request", ",", "DelegateInterface", "$", "frame", ")", "{", "\\", "Concrete", "\\", "Core", "\\", "Http", "\\", "Request", "::", "setInstance", "(", "$", "request", ")", ";", "$", "this", "->", "app", "->", "instance", "(", "'Concrete\\Core\\Http\\Request'", ",", "$", "request", ")", ";", "return", "$", "frame", "->", "next", "(", "$", "request", ")", ";", "}" ]
Apply the request instance to the request singleton @param \Symfony\Component\HttpFoundation\Request $request @param \Concrete\Core\Http\Middleware\DelegateInterface $frame @return \Symfony\Component\HttpFoundation\Response
[ "Apply", "the", "request", "instance", "to", "the", "request", "singleton" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Http/Middleware/ApplicationMiddleware.php#L24-L30
train
concrete5/concrete5
concrete/src/User/Group/GroupList.php
GroupList.filterByAssignable
public function filterByAssignable() { if (Config::get('concrete.permissions.model') != 'simple') { // there's gotta be a more reasonable way than this but right now i'm not sure what that is. $excludeGroupIDs = [GUEST_GROUP_ID, REGISTERED_GROUP_ID]; $db = Loader::db(); $r = $db->executeQuery('select gID from ' . $db->getDatabasePlatform()->quoteSingleIdentifier('Groups') . ' where gID > ?', [REGISTERED_GROUP_ID]); while ($row = $r->FetchRow()) { $g = Group::getByID($row['gID']); $gp = new Permissions($g); if (!$gp->canAssignGroup()) { $excludeGroupIDs[] = $row['gID']; } } $this->query->andWhere( $this->query->expr()->notIn('g.gId', array_map([$db, 'quote'], $excludeGroupIDs)) ); } }
php
public function filterByAssignable() { if (Config::get('concrete.permissions.model') != 'simple') { // there's gotta be a more reasonable way than this but right now i'm not sure what that is. $excludeGroupIDs = [GUEST_GROUP_ID, REGISTERED_GROUP_ID]; $db = Loader::db(); $r = $db->executeQuery('select gID from ' . $db->getDatabasePlatform()->quoteSingleIdentifier('Groups') . ' where gID > ?', [REGISTERED_GROUP_ID]); while ($row = $r->FetchRow()) { $g = Group::getByID($row['gID']); $gp = new Permissions($g); if (!$gp->canAssignGroup()) { $excludeGroupIDs[] = $row['gID']; } } $this->query->andWhere( $this->query->expr()->notIn('g.gId', array_map([$db, 'quote'], $excludeGroupIDs)) ); } }
[ "public", "function", "filterByAssignable", "(", ")", "{", "if", "(", "Config", "::", "get", "(", "'concrete.permissions.model'", ")", "!=", "'simple'", ")", "{", "// there's gotta be a more reasonable way than this but right now i'm not sure what that is.", "$", "excludeGroupIDs", "=", "[", "GUEST_GROUP_ID", ",", "REGISTERED_GROUP_ID", "]", ";", "$", "db", "=", "Loader", "::", "db", "(", ")", ";", "$", "r", "=", "$", "db", "->", "executeQuery", "(", "'select gID from '", ".", "$", "db", "->", "getDatabasePlatform", "(", ")", "->", "quoteSingleIdentifier", "(", "'Groups'", ")", ".", "' where gID > ?'", ",", "[", "REGISTERED_GROUP_ID", "]", ")", ";", "while", "(", "$", "row", "=", "$", "r", "->", "FetchRow", "(", ")", ")", "{", "$", "g", "=", "Group", "::", "getByID", "(", "$", "row", "[", "'gID'", "]", ")", ";", "$", "gp", "=", "new", "Permissions", "(", "$", "g", ")", ";", "if", "(", "!", "$", "gp", "->", "canAssignGroup", "(", ")", ")", "{", "$", "excludeGroupIDs", "[", "]", "=", "$", "row", "[", "'gID'", "]", ";", "}", "}", "$", "this", "->", "query", "->", "andWhere", "(", "$", "this", "->", "query", "->", "expr", "(", ")", "->", "notIn", "(", "'g.gId'", ",", "array_map", "(", "[", "$", "db", ",", "'quote'", "]", ",", "$", "excludeGroupIDs", ")", ")", ")", ";", "}", "}" ]
Only return groups the user has the ability to assign.
[ "Only", "return", "groups", "the", "user", "has", "the", "ability", "to", "assign", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/User/Group/GroupList.php#L55-L73
train
concrete5/concrete5
concrete/src/Application/EditResponse.php
EditResponse.hasError
public function hasError() { $error = $this->getError(); if ($error instanceof ErrorList) { return $error->has(); } if ($error instanceof Exception) { return true; } return (string) $error !== ''; }
php
public function hasError() { $error = $this->getError(); if ($error instanceof ErrorList) { return $error->has(); } if ($error instanceof Exception) { return true; } return (string) $error !== ''; }
[ "public", "function", "hasError", "(", ")", "{", "$", "error", "=", "$", "this", "->", "getError", "(", ")", ";", "if", "(", "$", "error", "instanceof", "ErrorList", ")", "{", "return", "$", "error", "->", "has", "(", ")", ";", "}", "if", "(", "$", "error", "instanceof", "Exception", ")", "{", "return", "true", ";", "}", "return", "(", "string", ")", "$", "error", "!==", "''", ";", "}" ]
Does this response contain an error? @return bool
[ "Does", "this", "response", "contain", "an", "error?" ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Application/EditResponse.php#L122-L133
train
concrete5/concrete5
concrete/src/Application/EditResponse.php
EditResponse.getBaseJSONObject
public function getBaseJSONObject() { $o = new stdClass(); $error = $this->getError(); if ($error instanceof Exception) { $o->error = true; $o->errors = [$error->getMessage()]; } elseif ($error instanceof ErrorList && $error->has()) { $o->error = true; $o->errors = []; foreach ($error->getList() as $e) { $o->errors[] = (string) $e; } } else { $error = (string) $error; if ($error !== '') { $o->error = true; $o->errors = [$error]; } } $o->time = $this->getTime(); $o->message = $this->getMessage(); $o->title = $this->getTitle(); $o->redirectURL = (string) $this->getRedirectURL(); foreach ($this->additionalData as $key => $value) { $o->{$key} = $value; } return $o; }
php
public function getBaseJSONObject() { $o = new stdClass(); $error = $this->getError(); if ($error instanceof Exception) { $o->error = true; $o->errors = [$error->getMessage()]; } elseif ($error instanceof ErrorList && $error->has()) { $o->error = true; $o->errors = []; foreach ($error->getList() as $e) { $o->errors[] = (string) $e; } } else { $error = (string) $error; if ($error !== '') { $o->error = true; $o->errors = [$error]; } } $o->time = $this->getTime(); $o->message = $this->getMessage(); $o->title = $this->getTitle(); $o->redirectURL = (string) $this->getRedirectURL(); foreach ($this->additionalData as $key => $value) { $o->{$key} = $value; } return $o; }
[ "public", "function", "getBaseJSONObject", "(", ")", "{", "$", "o", "=", "new", "stdClass", "(", ")", ";", "$", "error", "=", "$", "this", "->", "getError", "(", ")", ";", "if", "(", "$", "error", "instanceof", "Exception", ")", "{", "$", "o", "->", "error", "=", "true", ";", "$", "o", "->", "errors", "=", "[", "$", "error", "->", "getMessage", "(", ")", "]", ";", "}", "elseif", "(", "$", "error", "instanceof", "ErrorList", "&&", "$", "error", "->", "has", "(", ")", ")", "{", "$", "o", "->", "error", "=", "true", ";", "$", "o", "->", "errors", "=", "[", "]", ";", "foreach", "(", "$", "error", "->", "getList", "(", ")", "as", "$", "e", ")", "{", "$", "o", "->", "errors", "[", "]", "=", "(", "string", ")", "$", "e", ";", "}", "}", "else", "{", "$", "error", "=", "(", "string", ")", "$", "error", ";", "if", "(", "$", "error", "!==", "''", ")", "{", "$", "o", "->", "error", "=", "true", ";", "$", "o", "->", "errors", "=", "[", "$", "error", "]", ";", "}", "}", "$", "o", "->", "time", "=", "$", "this", "->", "getTime", "(", ")", ";", "$", "o", "->", "message", "=", "$", "this", "->", "getMessage", "(", ")", ";", "$", "o", "->", "title", "=", "$", "this", "->", "getTitle", "(", ")", ";", "$", "o", "->", "redirectURL", "=", "(", "string", ")", "$", "this", "->", "getRedirectURL", "(", ")", ";", "foreach", "(", "$", "this", "->", "additionalData", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "o", "->", "{", "$", "key", "}", "=", "$", "value", ";", "}", "return", "$", "o", ";", "}" ]
Get an stdClass instance containing the serialized data of this instance. @return \stdClass
[ "Get", "an", "stdClass", "instance", "containing", "the", "serialized", "data", "of", "this", "instance", "." ]
c54c94e4eb6d45696fed85a5b8b415f70ea677b8
https://github.com/concrete5/concrete5/blob/c54c94e4eb6d45696fed85a5b8b415f70ea677b8/concrete/src/Application/EditResponse.php#L255-L284
train