id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
222,100
symlex/input-validation
src/Form.php
Form.clearErrors
public function clearErrors() { $this->_validationDone = false; if (count($this->_errors) != 0) { $this->_errors = array(); } return $this; }
php
public function clearErrors() { $this->_validationDone = false; if (count($this->_errors) != 0) { $this->_errors = array(); } return $this; }
[ "public", "function", "clearErrors", "(", ")", "{", "$", "this", "->", "_validationDone", "=", "false", ";", "if", "(", "count", "(", "$", "this", "->", "_errors", ")", "!=", "0", ")", "{", "$", "this", "->", "_errors", "=", "array", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
Resets the validation and clears all errors
[ "Resets", "the", "validation", "and", "clears", "all", "errors" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form.php#L1092-L1101
222,101
claroline/CoreBundle
Manager/MaskManager.php
MaskManager.decodeMask
public function decodeMask($mask, ResourceType $type) { $decoders = $this->maskRepo->findBy(array('resourceType' => $type)); $perms = array(); foreach ($decoders as $decoder) { $perms[$decoder->getName()] = ($mask & $decoder->getValue()) ? true: false; } return $perms; }
php
public function decodeMask($mask, ResourceType $type) { $decoders = $this->maskRepo->findBy(array('resourceType' => $type)); $perms = array(); foreach ($decoders as $decoder) { $perms[$decoder->getName()] = ($mask & $decoder->getValue()) ? true: false; } return $perms; }
[ "public", "function", "decodeMask", "(", "$", "mask", ",", "ResourceType", "$", "type", ")", "{", "$", "decoders", "=", "$", "this", "->", "maskRepo", "->", "findBy", "(", "array", "(", "'resourceType'", "=>", "$", "type", ")", ")", ";", "$", "perms", "=", "array", "(", ")", ";", "foreach", "(", "$", "decoders", "as", "$", "decoder", ")", "{", "$", "perms", "[", "$", "decoder", "->", "getName", "(", ")", "]", "=", "(", "$", "mask", "&", "$", "decoder", "->", "getValue", "(", ")", ")", "?", "true", ":", "false", ";", "}", "return", "$", "perms", ";", "}" ]
Returns an array containing the permission for a mask and a resource type. @param integer $mask @param \Claroline\CoreBundle\Entity\Resource\ResourceType $type @return array
[ "Returns", "an", "array", "containing", "the", "permission", "for", "a", "mask", "and", "a", "resource", "type", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/MaskManager.php#L56-L66
222,102
claroline/CoreBundle
Manager/MaskManager.php
MaskManager.hasMenuAction
public function hasMenuAction(ResourceType $type) { $menuActions = $this->menuRepo->findBy( array('resourceType' => $type) ); return count($menuActions) > 0; }
php
public function hasMenuAction(ResourceType $type) { $menuActions = $this->menuRepo->findBy( array('resourceType' => $type) ); return count($menuActions) > 0; }
[ "public", "function", "hasMenuAction", "(", "ResourceType", "$", "type", ")", "{", "$", "menuActions", "=", "$", "this", "->", "menuRepo", "->", "findBy", "(", "array", "(", "'resourceType'", "=>", "$", "type", ")", ")", ";", "return", "count", "(", "$", "menuActions", ")", ">", "0", ";", "}" ]
Checks if a resource type has any menu actions. @param \Claroline\CoreBundle\Entity\Resource\ResourceType $type
[ "Checks", "if", "a", "resource", "type", "has", "any", "menu", "actions", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/MaskManager.php#L188-L195
222,103
claroline/CoreBundle
Manager/IconManager.php
IconManager.searchIcon
public function searchIcon($mimeType) { $mimeElements = explode('/', $mimeType); $icon = $this->repo->findOneByMimeType($mimeType); if ($icon === null) { $icon = $this->repo->findOneByMimeType($mimeElements[0]); if ($icon === null) { $icon = $this->repo->findOneByMimeType('custom/default'); } } return $icon; }
php
public function searchIcon($mimeType) { $mimeElements = explode('/', $mimeType); $icon = $this->repo->findOneByMimeType($mimeType); if ($icon === null) { $icon = $this->repo->findOneByMimeType($mimeElements[0]); if ($icon === null) { $icon = $this->repo->findOneByMimeType('custom/default'); } } return $icon; }
[ "public", "function", "searchIcon", "(", "$", "mimeType", ")", "{", "$", "mimeElements", "=", "explode", "(", "'/'", ",", "$", "mimeType", ")", ";", "$", "icon", "=", "$", "this", "->", "repo", "->", "findOneByMimeType", "(", "$", "mimeType", ")", ";", "if", "(", "$", "icon", "===", "null", ")", "{", "$", "icon", "=", "$", "this", "->", "repo", "->", "findOneByMimeType", "(", "$", "mimeElements", "[", "0", "]", ")", ";", "if", "(", "$", "icon", "===", "null", ")", "{", "$", "icon", "=", "$", "this", "->", "repo", "->", "findOneByMimeType", "(", "'custom/default'", ")", ";", "}", "}", "return", "$", "icon", ";", "}" ]
Return the icon of a specified mimeType. The most specific icon for the mime type will be returned. @param string $mimeType @return \Claroline\CoreBundle\Entity\Resource\ResourceIcon
[ "Return", "the", "icon", "of", "a", "specified", "mimeType", ".", "The", "most", "specific", "icon", "for", "the", "mime", "type", "will", "be", "returned", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/IconManager.php#L137-L152
222,104
claroline/CoreBundle
Manager/IconManager.php
IconManager.createShortcutIcon
public function createShortcutIcon(ResourceIcon $icon, Workspace $workspace = null) { $this->om->startFlushSuite(); $relativeUrl = $this->createShortcutFromRelativeUrl($icon->getRelativeUrl(), $workspace); $shortcutIcon = new ResourceIcon(); $shortcutIcon->setRelativeUrl($relativeUrl); $shortcutIcon->setMimeType($icon->getMimeType()); $shortcutIcon->setShortcut(true); $icon->setShortcutIcon($shortcutIcon); $shortcutIcon->setShortcutIcon($shortcutIcon); $this->om->persist($icon); $this->om->persist($shortcutIcon); $this->om->endFlushSuite(); return $shortcutIcon; }
php
public function createShortcutIcon(ResourceIcon $icon, Workspace $workspace = null) { $this->om->startFlushSuite(); $relativeUrl = $this->createShortcutFromRelativeUrl($icon->getRelativeUrl(), $workspace); $shortcutIcon = new ResourceIcon(); $shortcutIcon->setRelativeUrl($relativeUrl); $shortcutIcon->setMimeType($icon->getMimeType()); $shortcutIcon->setShortcut(true); $icon->setShortcutIcon($shortcutIcon); $shortcutIcon->setShortcutIcon($shortcutIcon); $this->om->persist($icon); $this->om->persist($shortcutIcon); $this->om->endFlushSuite(); return $shortcutIcon; }
[ "public", "function", "createShortcutIcon", "(", "ResourceIcon", "$", "icon", ",", "Workspace", "$", "workspace", "=", "null", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "relativeUrl", "=", "$", "this", "->", "createShortcutFromRelativeUrl", "(", "$", "icon", "->", "getRelativeUrl", "(", ")", ",", "$", "workspace", ")", ";", "$", "shortcutIcon", "=", "new", "ResourceIcon", "(", ")", ";", "$", "shortcutIcon", "->", "setRelativeUrl", "(", "$", "relativeUrl", ")", ";", "$", "shortcutIcon", "->", "setMimeType", "(", "$", "icon", "->", "getMimeType", "(", ")", ")", ";", "$", "shortcutIcon", "->", "setShortcut", "(", "true", ")", ";", "$", "icon", "->", "setShortcutIcon", "(", "$", "shortcutIcon", ")", ";", "$", "shortcutIcon", "->", "setShortcutIcon", "(", "$", "shortcutIcon", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "icon", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "shortcutIcon", ")", ";", "$", "this", "->", "om", "->", "endFlushSuite", "(", ")", ";", "return", "$", "shortcutIcon", ";", "}" ]
Creates the shortcut icon for an existing icon. @param \Claroline\CoreBundle\Entity\Resource\ResourceIcon $icon @return \Claroline\CoreBundle\Entity\Resource\ResourceIcon @throws \RuntimeException
[ "Creates", "the", "shortcut", "icon", "for", "an", "existing", "icon", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/IconManager.php#L163-L181
222,105
claroline/CoreBundle
Manager/IconManager.php
IconManager.replace
public function replace(ResourceNode $resource, ResourceIcon $icon) { $this->om->startFlushSuite(); $oldIcon = $resource->getIcon(); if (!$oldIcon->isShortcut()) { $oldShortcutIcon = $oldIcon->getShortcutIcon(); $shortcutIcon = $icon->getShortcutIcon(); if (!is_null($oldShortcutIcon) && !is_null($shortcutIcon)) { $nodes = $this->om->getRepository('ClarolineCoreBundle:Resource\ResourceNode') ->findBy(array('icon' => $oldShortcutIcon)); foreach ($nodes as $node) { $node->setIcon($shortcutIcon); $this->om->persist($node); } } } $this->delete($oldIcon); $resource->setIcon($icon); $this->om->persist($resource); $this->om->endFlushSuite(); return $resource; }
php
public function replace(ResourceNode $resource, ResourceIcon $icon) { $this->om->startFlushSuite(); $oldIcon = $resource->getIcon(); if (!$oldIcon->isShortcut()) { $oldShortcutIcon = $oldIcon->getShortcutIcon(); $shortcutIcon = $icon->getShortcutIcon(); if (!is_null($oldShortcutIcon) && !is_null($shortcutIcon)) { $nodes = $this->om->getRepository('ClarolineCoreBundle:Resource\ResourceNode') ->findBy(array('icon' => $oldShortcutIcon)); foreach ($nodes as $node) { $node->setIcon($shortcutIcon); $this->om->persist($node); } } } $this->delete($oldIcon); $resource->setIcon($icon); $this->om->persist($resource); $this->om->endFlushSuite(); return $resource; }
[ "public", "function", "replace", "(", "ResourceNode", "$", "resource", ",", "ResourceIcon", "$", "icon", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "oldIcon", "=", "$", "resource", "->", "getIcon", "(", ")", ";", "if", "(", "!", "$", "oldIcon", "->", "isShortcut", "(", ")", ")", "{", "$", "oldShortcutIcon", "=", "$", "oldIcon", "->", "getShortcutIcon", "(", ")", ";", "$", "shortcutIcon", "=", "$", "icon", "->", "getShortcutIcon", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "oldShortcutIcon", ")", "&&", "!", "is_null", "(", "$", "shortcutIcon", ")", ")", "{", "$", "nodes", "=", "$", "this", "->", "om", "->", "getRepository", "(", "'ClarolineCoreBundle:Resource\\ResourceNode'", ")", "->", "findBy", "(", "array", "(", "'icon'", "=>", "$", "oldShortcutIcon", ")", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "$", "node", "->", "setIcon", "(", "$", "shortcutIcon", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "node", ")", ";", "}", "}", "}", "$", "this", "->", "delete", "(", "$", "oldIcon", ")", ";", "$", "resource", "->", "setIcon", "(", "$", "icon", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "resource", ")", ";", "$", "this", "->", "om", "->", "endFlushSuite", "(", ")", ";", "return", "$", "resource", ";", "}" ]
Replace a node icon. @param \Claroline\CoreBundle\Entity\Resource\ResourceNode $resource @param \Claroline\CoreBundle\Entity\Resource\ResourceIcon $icon @return \Claroline\CoreBundle\Entity\Resource\ResourceNode
[ "Replace", "a", "node", "icon", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/IconManager.php#L295-L320
222,106
claroline/CoreBundle
Listener/Log/LogListener.php
LogListener.isARepeat
public function isARepeat(LogGenericEvent $event) { if ($this->tokenStorage->getToken() === null) { //Only if have a user session; return false; } if ($event instanceof LogNotRepeatableInterface) { $request = $this->container->get('request'); $session = $request->getSession(); $is = false; $pushInSession = true; $now = time(); //if ($session->get($event->getAction()) != null) { if ($session->get($event->getLogSignature()) != null) { //$oldArray = json_decode($session->get($event->getAction())); $oldArray = json_decode($session->get($event->getLogSignature())); $oldSignature = $oldArray->logSignature; $oldTime = $oldArray->time; if ($oldSignature == $event->getLogSignature()) { $diff = ($now - $oldTime); $notRepeatableLogTimeInSeconds = $this->container->getParameter( 'non_repeatable_log_time_in_seconds' ); if ($event->getIsWorkspaceEnterEvent()) { $notRepeatableLogTimeInSeconds = $notRepeatableLogTimeInSeconds * 3; } if ($diff > $notRepeatableLogTimeInSeconds) { $is = false; } else { $is = true; $pushInSession = false; } } } if ($pushInSession) { //Update last logSignature for this event category $array = array('logSignature' => $event->getLogSignature(), 'time' => $now); //$session->set($event->getAction(), json_encode($array)); $session->set($event->getLogSignature(), json_encode($array)); } return $is; } else { return false; } }
php
public function isARepeat(LogGenericEvent $event) { if ($this->tokenStorage->getToken() === null) { //Only if have a user session; return false; } if ($event instanceof LogNotRepeatableInterface) { $request = $this->container->get('request'); $session = $request->getSession(); $is = false; $pushInSession = true; $now = time(); //if ($session->get($event->getAction()) != null) { if ($session->get($event->getLogSignature()) != null) { //$oldArray = json_decode($session->get($event->getAction())); $oldArray = json_decode($session->get($event->getLogSignature())); $oldSignature = $oldArray->logSignature; $oldTime = $oldArray->time; if ($oldSignature == $event->getLogSignature()) { $diff = ($now - $oldTime); $notRepeatableLogTimeInSeconds = $this->container->getParameter( 'non_repeatable_log_time_in_seconds' ); if ($event->getIsWorkspaceEnterEvent()) { $notRepeatableLogTimeInSeconds = $notRepeatableLogTimeInSeconds * 3; } if ($diff > $notRepeatableLogTimeInSeconds) { $is = false; } else { $is = true; $pushInSession = false; } } } if ($pushInSession) { //Update last logSignature for this event category $array = array('logSignature' => $event->getLogSignature(), 'time' => $now); //$session->set($event->getAction(), json_encode($array)); $session->set($event->getLogSignature(), json_encode($array)); } return $is; } else { return false; } }
[ "public", "function", "isARepeat", "(", "LogGenericEvent", "$", "event", ")", "{", "if", "(", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", "===", "null", ")", "{", "//Only if have a user session;", "return", "false", ";", "}", "if", "(", "$", "event", "instanceof", "LogNotRepeatableInterface", ")", "{", "$", "request", "=", "$", "this", "->", "container", "->", "get", "(", "'request'", ")", ";", "$", "session", "=", "$", "request", "->", "getSession", "(", ")", ";", "$", "is", "=", "false", ";", "$", "pushInSession", "=", "true", ";", "$", "now", "=", "time", "(", ")", ";", "//if ($session->get($event->getAction()) != null) {", "if", "(", "$", "session", "->", "get", "(", "$", "event", "->", "getLogSignature", "(", ")", ")", "!=", "null", ")", "{", "//$oldArray = json_decode($session->get($event->getAction()));", "$", "oldArray", "=", "json_decode", "(", "$", "session", "->", "get", "(", "$", "event", "->", "getLogSignature", "(", ")", ")", ")", ";", "$", "oldSignature", "=", "$", "oldArray", "->", "logSignature", ";", "$", "oldTime", "=", "$", "oldArray", "->", "time", ";", "if", "(", "$", "oldSignature", "==", "$", "event", "->", "getLogSignature", "(", ")", ")", "{", "$", "diff", "=", "(", "$", "now", "-", "$", "oldTime", ")", ";", "$", "notRepeatableLogTimeInSeconds", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'non_repeatable_log_time_in_seconds'", ")", ";", "if", "(", "$", "event", "->", "getIsWorkspaceEnterEvent", "(", ")", ")", "{", "$", "notRepeatableLogTimeInSeconds", "=", "$", "notRepeatableLogTimeInSeconds", "*", "3", ";", "}", "if", "(", "$", "diff", ">", "$", "notRepeatableLogTimeInSeconds", ")", "{", "$", "is", "=", "false", ";", "}", "else", "{", "$", "is", "=", "true", ";", "$", "pushInSession", "=", "false", ";", "}", "}", "}", "if", "(", "$", "pushInSession", ")", "{", "//Update last logSignature for this event category", "$", "array", "=", "array", "(", "'logSignature'", "=>", "$", "event", "->", "getLogSignature", "(", ")", ",", "'time'", "=>", "$", "now", ")", ";", "//$session->set($event->getAction(), json_encode($array));", "$", "session", "->", "set", "(", "$", "event", "->", "getLogSignature", "(", ")", ",", "json_encode", "(", "$", "array", ")", ")", ";", "}", "return", "$", "is", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Is a repeat if the session contains a same logSignature for the same action category
[ "Is", "a", "repeat", "if", "the", "session", "contains", "a", "same", "logSignature", "for", "the", "same", "action", "category" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Listener/Log/LogListener.php#L209-L261
222,107
symlex/input-validation
src/Form/Factory.php
Factory.create
public function create(string $name, array $params = array()) { if (empty($name)) { throw new FactoryException ('create() requires a non-empty form name as first argument'); } $className = $this->getFactoryNamespace() . '\\' . $name . $this->getFactoryPostfix(); if (!class_exists($className)) { throw new FactoryException ('Form class "' . $className . '" does not exist'); } $result = $this->createFormInstance($className, $params); return $result; }
php
public function create(string $name, array $params = array()) { if (empty($name)) { throw new FactoryException ('create() requires a non-empty form name as first argument'); } $className = $this->getFactoryNamespace() . '\\' . $name . $this->getFactoryPostfix(); if (!class_exists($className)) { throw new FactoryException ('Form class "' . $className . '" does not exist'); } $result = $this->createFormInstance($className, $params); return $result; }
[ "public", "function", "create", "(", "string", "$", "name", ",", "array", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "throw", "new", "FactoryException", "(", "'create() requires a non-empty form name as first argument'", ")", ";", "}", "$", "className", "=", "$", "this", "->", "getFactoryNamespace", "(", ")", ".", "'\\\\'", ".", "$", "name", ".", "$", "this", "->", "getFactoryPostfix", "(", ")", ";", "if", "(", "!", "class_exists", "(", "$", "className", ")", ")", "{", "throw", "new", "FactoryException", "(", "'Form class \"'", ".", "$", "className", ".", "'\" does not exist'", ")", ";", "}", "$", "result", "=", "$", "this", "->", "createFormInstance", "(", "$", "className", ",", "$", "params", ")", ";", "return", "$", "result", ";", "}" ]
Returns a new form instance of the given name @param string $name Type of form @param array $params Optional config parameters for init() @throws FactoryException @return Form
[ "Returns", "a", "new", "form", "instance", "of", "the", "given", "name" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form/Factory.php#L66-L81
222,108
symlex/input-validation
src/Form/Factory.php
Factory.getFactoryNamespace
public function getFactoryNamespace() { $result = $this->_factoryNamespace; if ($result && strpos($result, '\\') !== 0) { $result = '\\' . $result; } return $result; }
php
public function getFactoryNamespace() { $result = $this->_factoryNamespace; if ($result && strpos($result, '\\') !== 0) { $result = '\\' . $result; } return $result; }
[ "public", "function", "getFactoryNamespace", "(", ")", "{", "$", "result", "=", "$", "this", "->", "_factoryNamespace", ";", "if", "(", "$", "result", "&&", "strpos", "(", "$", "result", ",", "'\\\\'", ")", "!==", "0", ")", "{", "$", "result", "=", "'\\\\'", ".", "$", "result", ";", "}", "return", "$", "result", ";", "}" ]
Returns absolute namespace @return string
[ "Returns", "absolute", "namespace" ]
a5f20c417d23eafd6be7acf9bad39bcbed24e9ff
https://github.com/symlex/input-validation/blob/a5f20c417d23eafd6be7acf9bad39bcbed24e9ff/src/Form/Factory.php#L113-L122
222,109
claroline/CoreBundle
Manager/ProfilePropertyManager.php
ProfilePropertyManager.addDefaultProperties
public function addDefaultProperties() { $properties = User::getEditableProperties(); $this->om->startFlushSuite(); foreach ($properties as $property => $editable) { $this->addProperties($property, $editable); } $this->om->endFlushSuite(); }
php
public function addDefaultProperties() { $properties = User::getEditableProperties(); $this->om->startFlushSuite(); foreach ($properties as $property => $editable) { $this->addProperties($property, $editable); } $this->om->endFlushSuite(); }
[ "public", "function", "addDefaultProperties", "(", ")", "{", "$", "properties", "=", "User", "::", "getEditableProperties", "(", ")", ";", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "foreach", "(", "$", "properties", "as", "$", "property", "=>", "$", "editable", ")", "{", "$", "this", "->", "addProperties", "(", "$", "property", ",", "$", "editable", ")", ";", "}", "$", "this", "->", "om", "->", "endFlushSuite", "(", ")", ";", "}" ]
Add the default properties accesses for each roles
[ "Add", "the", "default", "properties", "accesses", "for", "each", "roles" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ProfilePropertyManager.php#L57-L67
222,110
claroline/CoreBundle
Manager/ProfilePropertyManager.php
ProfilePropertyManager.addProperties
public function addProperties($property, $editable) { $platformRoles = $this->roleManager->getAllPlatformRoles(); foreach ($platformRoles as $role) { $prop = $this->profilePropertyRepo ->findBy(array('property' => $property, 'role' => $role)); if (count($prop) === 0) $this->addProperty($property, $editable, $role); } }
php
public function addProperties($property, $editable) { $platformRoles = $this->roleManager->getAllPlatformRoles(); foreach ($platformRoles as $role) { $prop = $this->profilePropertyRepo ->findBy(array('property' => $property, 'role' => $role)); if (count($prop) === 0) $this->addProperty($property, $editable, $role); } }
[ "public", "function", "addProperties", "(", "$", "property", ",", "$", "editable", ")", "{", "$", "platformRoles", "=", "$", "this", "->", "roleManager", "->", "getAllPlatformRoles", "(", ")", ";", "foreach", "(", "$", "platformRoles", "as", "$", "role", ")", "{", "$", "prop", "=", "$", "this", "->", "profilePropertyRepo", "->", "findBy", "(", "array", "(", "'property'", "=>", "$", "property", ",", "'role'", "=>", "$", "role", ")", ")", ";", "if", "(", "count", "(", "$", "prop", ")", "===", "0", ")", "$", "this", "->", "addProperty", "(", "$", "property", ",", "$", "editable", ",", "$", "role", ")", ";", "}", "}" ]
Public function add a property for each roles @param string $property @param boolean $editable
[ "Public", "function", "add", "a", "property", "for", "each", "roles" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ProfilePropertyManager.php#L75-L85
222,111
claroline/CoreBundle
Manager/ProfilePropertyManager.php
ProfilePropertyManager.addProperty
public function addProperty($property, $editable, Role $role) { $propertyEntity = new ProfileProperty(); $propertyEntity->setProperty($property); $propertyEntity->setIsEditable($editable); $propertyEntity->setRole($role); $this->om->persist($propertyEntity); $this->om->flush(); }
php
public function addProperty($property, $editable, Role $role) { $propertyEntity = new ProfileProperty(); $propertyEntity->setProperty($property); $propertyEntity->setIsEditable($editable); $propertyEntity->setRole($role); $this->om->persist($propertyEntity); $this->om->flush(); }
[ "public", "function", "addProperty", "(", "$", "property", ",", "$", "editable", ",", "Role", "$", "role", ")", "{", "$", "propertyEntity", "=", "new", "ProfileProperty", "(", ")", ";", "$", "propertyEntity", "->", "setProperty", "(", "$", "property", ")", ";", "$", "propertyEntity", "->", "setIsEditable", "(", "$", "editable", ")", ";", "$", "propertyEntity", "->", "setRole", "(", "$", "role", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "propertyEntity", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}" ]
Create a property entity @param string $property @param boolean $editable @param Role $role
[ "Create", "a", "property", "entity" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ProfilePropertyManager.php#L94-L102
222,112
claroline/CoreBundle
Controller/HomeController.php
HomeController.contentAction
public function contentAction(Content $content, Type $type, Content $father = null) { return $this->render( 'ClarolineCoreBundle:Home/types:'.(is_object($type) ? $type->getName() : 'home' ).'.html.twig', $this->manager->getContent($content, $type, $father), true ); }
php
public function contentAction(Content $content, Type $type, Content $father = null) { return $this->render( 'ClarolineCoreBundle:Home/types:'.(is_object($type) ? $type->getName() : 'home' ).'.html.twig', $this->manager->getContent($content, $type, $father), true ); }
[ "public", "function", "contentAction", "(", "Content", "$", "content", ",", "Type", "$", "type", ",", "Content", "$", "father", "=", "null", ")", "{", "return", "$", "this", "->", "render", "(", "'ClarolineCoreBundle:Home/types:'", ".", "(", "is_object", "(", "$", "type", ")", "?", "$", "type", "->", "getName", "(", ")", ":", "'home'", ")", ".", "'.html.twig'", ",", "$", "this", "->", "manager", "->", "getContent", "(", "$", "content", ",", "$", "type", ",", "$", "father", ")", ",", "true", ")", ";", "}" ]
Get content by id @Route( "/content/{content}/{type}/{father}", requirements={"content" = "\d+"}, name="claroline_get_content_by_id_and_type", defaults={"type" = "home", "father" = null}, options = {"expose" = true} ) @ParamConverter("content", class = "ClarolineCoreBundle:Content", options = {"id" = "content"}) @ParamConverter("father", class = "ClarolineCoreBundle:Content", options = {"id" = "father"}) @ParamConverter("type", class = "ClarolineCoreBundle:Home\Type", options = {"mapping" : {"type": "name"}}) @return \Symfony\Component\HttpFoundation\Response
[ "Get", "content", "by", "id" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Controller/HomeController.php#L92-L99
222,113
claroline/CoreBundle
Controller/HomeController.php
HomeController.homeAction
public function homeAction($type) { $typeEntity = $this->manager->getType($type); if (is_null($typeEntity)) { throw new NotFoundHttpException("Page not found"); } else { $typeTemplate = $typeEntity->getTemplate(); $template = is_null($typeTemplate) ? 'ClarolineCoreBundle:Home:home.html.twig' : 'ClarolineCoreBundle:Home\templates\custom:' . $typeTemplate; $response = $this->render( $template, array( 'type' => $type, 'region' => $this->renderRegions($this->manager->getRegionContents()), 'content' => $this->typeAction($type)->getContent() ) ); $response->headers->addCacheControlDirective('no-cache', true); $response->headers->addCacheControlDirective('max-age', 0); $response->headers->addCacheControlDirective('must-revalidate', true); $response->headers->addCacheControlDirective('no-store', true); $response->headers->addCacheControlDirective('expires', '-1'); return $response; } }
php
public function homeAction($type) { $typeEntity = $this->manager->getType($type); if (is_null($typeEntity)) { throw new NotFoundHttpException("Page not found"); } else { $typeTemplate = $typeEntity->getTemplate(); $template = is_null($typeTemplate) ? 'ClarolineCoreBundle:Home:home.html.twig' : 'ClarolineCoreBundle:Home\templates\custom:' . $typeTemplate; $response = $this->render( $template, array( 'type' => $type, 'region' => $this->renderRegions($this->manager->getRegionContents()), 'content' => $this->typeAction($type)->getContent() ) ); $response->headers->addCacheControlDirective('no-cache', true); $response->headers->addCacheControlDirective('max-age', 0); $response->headers->addCacheControlDirective('must-revalidate', true); $response->headers->addCacheControlDirective('no-store', true); $response->headers->addCacheControlDirective('expires', '-1'); return $response; } }
[ "public", "function", "homeAction", "(", "$", "type", ")", "{", "$", "typeEntity", "=", "$", "this", "->", "manager", "->", "getType", "(", "$", "type", ")", ";", "if", "(", "is_null", "(", "$", "typeEntity", ")", ")", "{", "throw", "new", "NotFoundHttpException", "(", "\"Page not found\"", ")", ";", "}", "else", "{", "$", "typeTemplate", "=", "$", "typeEntity", "->", "getTemplate", "(", ")", ";", "$", "template", "=", "is_null", "(", "$", "typeTemplate", ")", "?", "'ClarolineCoreBundle:Home:home.html.twig'", ":", "'ClarolineCoreBundle:Home\\templates\\custom:'", ".", "$", "typeTemplate", ";", "$", "response", "=", "$", "this", "->", "render", "(", "$", "template", ",", "array", "(", "'type'", "=>", "$", "type", ",", "'region'", "=>", "$", "this", "->", "renderRegions", "(", "$", "this", "->", "manager", "->", "getRegionContents", "(", ")", ")", ",", "'content'", "=>", "$", "this", "->", "typeAction", "(", "$", "type", ")", "->", "getContent", "(", ")", ")", ")", ";", "$", "response", "->", "headers", "->", "addCacheControlDirective", "(", "'no-cache'", ",", "true", ")", ";", "$", "response", "->", "headers", "->", "addCacheControlDirective", "(", "'max-age'", ",", "0", ")", ";", "$", "response", "->", "headers", "->", "addCacheControlDirective", "(", "'must-revalidate'", ",", "true", ")", ";", "$", "response", "->", "headers", "->", "addCacheControlDirective", "(", "'no-store'", ",", "true", ")", ";", "$", "response", "->", "headers", "->", "addCacheControlDirective", "(", "'expires'", ",", "'-1'", ")", ";", "return", "$", "response", ";", "}", "}" ]
Render the home page of the platform @Route("/type/{type}", name="claro_get_content_by_type", options = {"expose" = true}) @Route("/", name="claro_index", defaults={"type" = "home"}, options = {"expose" = true}) @return \Symfony\Component\HttpFoundation\Response
[ "Render", "the", "home", "page", "of", "the", "platform" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Controller/HomeController.php#L109-L137
222,114
claroline/CoreBundle
Controller/HomeController.php
HomeController.renameContentAction
public function renameContentAction($type, $name) { try { $this->manager->renameType($type, $name); return new Response('true'); } catch (\Exeption $e) { return new Response('false'); //useful in ajax } }
php
public function renameContentAction($type, $name) { try { $this->manager->renameType($type, $name); return new Response('true'); } catch (\Exeption $e) { return new Response('false'); //useful in ajax } }
[ "public", "function", "renameContentAction", "(", "$", "type", ",", "$", "name", ")", "{", "try", "{", "$", "this", "->", "manager", "->", "renameType", "(", "$", "type", ",", "$", "name", ")", ";", "return", "new", "Response", "(", "'true'", ")", ";", "}", "catch", "(", "\\", "Exeption", "$", "e", ")", "{", "return", "new", "Response", "(", "'false'", ")", ";", "//useful in ajax", "}", "}" ]
Rename a content form @Route("/rename/type/{type}/{name}", name="claro_content_rename_type", options = {"expose" = true}) @Secure(roles="ROLE_HOME_MANAGER") @ParamConverter("type", class = "ClarolineCoreBundle:home\Type", options = {"mapping" : {"type": "name"}}) @return \Symfony\Component\HttpFoundation\Response
[ "Rename", "a", "content", "form" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Controller/HomeController.php#L228-L237
222,115
claroline/CoreBundle
Controller/HomeController.php
HomeController.changeTemplateFormAction
public function changeTemplateFormAction(Type $type) { $form = $this->formFactory->create( new HomeTemplateType($this->templatesDirectory), $type ); return array('form' => $form->createView(), 'type' => $type); }
php
public function changeTemplateFormAction(Type $type) { $form = $this->formFactory->create( new HomeTemplateType($this->templatesDirectory), $type ); return array('form' => $form->createView(), 'type' => $type); }
[ "public", "function", "changeTemplateFormAction", "(", "Type", "$", "type", ")", "{", "$", "form", "=", "$", "this", "->", "formFactory", "->", "create", "(", "new", "HomeTemplateType", "(", "$", "this", "->", "templatesDirectory", ")", ",", "$", "type", ")", ";", "return", "array", "(", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", "'type'", "=>", "$", "type", ")", ";", "}" ]
Edit template form @Route( "/type/{type}/change/template/form", name="claro_content_change_template_form", options = {"expose" = true} ) @Secure(roles="ROLE_HOME_MANAGER") @Template("ClarolineCoreBundle:Home:changeTemplateModalForm.html.twig") @return \Symfony\Component\HttpFoundation\Response
[ "Edit", "template", "form" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Controller/HomeController.php#L253-L261
222,116
claroline/CoreBundle
Controller/HomeController.php
HomeController.collapseAction
public function collapseAction($content, $type) { try { $this->manager->collapse($content, $type); return new Response('true'); } catch (\Exeption $e) { return new Response('false'); } }
php
public function collapseAction($content, $type) { try { $this->manager->collapse($content, $type); return new Response('true'); } catch (\Exeption $e) { return new Response('false'); } }
[ "public", "function", "collapseAction", "(", "$", "content", ",", "$", "type", ")", "{", "try", "{", "$", "this", "->", "manager", "->", "collapse", "(", "$", "content", ",", "$", "type", ")", ";", "return", "new", "Response", "(", "'true'", ")", ";", "}", "catch", "(", "\\", "Exeption", "$", "e", ")", "{", "return", "new", "Response", "(", "'false'", ")", ";", "}", "}" ]
Update the collapse attribute of a content @Route( "/content/collapse/{content}/{type}", name="claroline_content_collapse", options = {"expose" = true} ) @Secure(roles="ROLE_HOME_MANAGER") @ParamConverter("content", class = "ClarolineCoreBundle:Content", options = {"id" = "content"}) @ParamConverter("type", class = "ClarolineCoreBundle:Home\Type", options = {"mapping" : {"type": "name"}}) @return \Symfony\Component\HttpFoundation\Response
[ "Update", "the", "collapse", "attribute", "of", "a", "content" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Controller/HomeController.php#L633-L642
222,117
claroline/CoreBundle
Controller/HomeController.php
HomeController.canGenerateContentAction
public function canGenerateContentAction() { if ($this->manager->isValidUrl($this->request->get('url'))) { $graph = $this->manager->getGraph($this->request->get('url')); if (isset($graph['type'])) { return $this->render( 'ClarolineCoreBundle:Home/graph:'.$graph['type'].'.html.twig', array('content' => $graph), true ); } } return new Response('false'); //in case is not valid URL }
php
public function canGenerateContentAction() { if ($this->manager->isValidUrl($this->request->get('url'))) { $graph = $this->manager->getGraph($this->request->get('url')); if (isset($graph['type'])) { return $this->render( 'ClarolineCoreBundle:Home/graph:'.$graph['type'].'.html.twig', array('content' => $graph), true ); } } return new Response('false'); //in case is not valid URL }
[ "public", "function", "canGenerateContentAction", "(", ")", "{", "if", "(", "$", "this", "->", "manager", "->", "isValidUrl", "(", "$", "this", "->", "request", "->", "get", "(", "'url'", ")", ")", ")", "{", "$", "graph", "=", "$", "this", "->", "manager", "->", "getGraph", "(", "$", "this", "->", "request", "->", "get", "(", "'url'", ")", ")", ";", "if", "(", "isset", "(", "$", "graph", "[", "'type'", "]", ")", ")", "{", "return", "$", "this", "->", "render", "(", "'ClarolineCoreBundle:Home/graph:'", ".", "$", "graph", "[", "'type'", "]", ".", "'.html.twig'", ",", "array", "(", "'content'", "=>", "$", "graph", ")", ",", "true", ")", ";", "}", "}", "return", "new", "Response", "(", "'false'", ")", ";", "//in case is not valid URL", "}" ]
Check if a string is a valid URL @Route("/cangeneratecontent", name="claroline_can_generate_content") @return \Symfony\Component\HttpFoundation\Response
[ "Check", "if", "a", "string", "is", "a", "valid", "URL" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Controller/HomeController.php#L651-L667
222,118
claroline/CoreBundle
Repository/OrderedToolRepository.php
OrderedToolRepository.findOrderedToolsLockedByAdmin
public function findOrderedToolsLockedByAdmin($orderedToolType = 0) { $dql = " SELECT ot FROM Claroline\CoreBundle\Entity\Tool\OrderedTool ot JOIN ot.tool t WHERE ot.user IS NULL AND ot.workspace IS NULL AND ot.type = :type AND ot.locked = true AND t.isDisplayableInDesktop = true ORDER BY ot.order "; $query = $this->_em->createQuery($dql); $query->setParameter('type', $orderedToolType); return $query->getResult(); }
php
public function findOrderedToolsLockedByAdmin($orderedToolType = 0) { $dql = " SELECT ot FROM Claroline\CoreBundle\Entity\Tool\OrderedTool ot JOIN ot.tool t WHERE ot.user IS NULL AND ot.workspace IS NULL AND ot.type = :type AND ot.locked = true AND t.isDisplayableInDesktop = true ORDER BY ot.order "; $query = $this->_em->createQuery($dql); $query->setParameter('type', $orderedToolType); return $query->getResult(); }
[ "public", "function", "findOrderedToolsLockedByAdmin", "(", "$", "orderedToolType", "=", "0", ")", "{", "$", "dql", "=", "\"\n SELECT ot\n FROM Claroline\\CoreBundle\\Entity\\Tool\\OrderedTool ot\n JOIN ot.tool t\n WHERE ot.user IS NULL\n AND ot.workspace IS NULL\n AND ot.type = :type\n AND ot.locked = true\n AND t.isDisplayableInDesktop = true\n ORDER BY ot.order\n \"", ";", "$", "query", "=", "$", "this", "->", "_em", "->", "createQuery", "(", "$", "dql", ")", ";", "$", "query", "->", "setParameter", "(", "'type'", ",", "$", "orderedToolType", ")", ";", "return", "$", "query", "->", "getResult", "(", ")", ";", "}" ]
Returns the ordered tools locked by admin. @return array[OrderedTool]
[ "Returns", "the", "ordered", "tools", "locked", "by", "admin", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/OrderedToolRepository.php#L309-L326
222,119
claroline/CoreBundle
Library/Workspace/Configuration.php
Configuration.extract
private function extract($extractPath, $archive) { $res = $archive->extractTo($extractPath); $archive->close(); $this->setExtractPath($extractPath); $resolver = new Resolver($extractPath); $this->data = $resolver->resolve(); }
php
private function extract($extractPath, $archive) { $res = $archive->extractTo($extractPath); $archive->close(); $this->setExtractPath($extractPath); $resolver = new Resolver($extractPath); $this->data = $resolver->resolve(); }
[ "private", "function", "extract", "(", "$", "extractPath", ",", "$", "archive", ")", "{", "$", "res", "=", "$", "archive", "->", "extractTo", "(", "$", "extractPath", ")", ";", "$", "archive", "->", "close", "(", ")", ";", "$", "this", "->", "setExtractPath", "(", "$", "extractPath", ")", ";", "$", "resolver", "=", "new", "Resolver", "(", "$", "extractPath", ")", ";", "$", "this", "->", "data", "=", "$", "resolver", "->", "resolve", "(", ")", ";", "}" ]
Assume the archive is already opened. @param $extractPath @param $archive
[ "Assume", "the", "archive", "is", "already", "opened", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Library/Workspace/Configuration.php#L67-L74
222,120
sam002/yii2-otp
src/widgets/OtpInit.php
OtpInit.renderWidget
private function renderWidget() { $img = $this->getImageSource(); echo "<div>$img</div>"; if ($this->link || is_string($this->link)) { echo Html::a($this->link, $this->otp->getProvisioningUri()); } if ($this->hasModel() && $this->model->hasProperty($this->attribute) && empty($this->model->{$this->attribute}) ) { $this->model->setAttributes([$this->attribute => $this->otp->getSecret()]); } echo Html::activeHiddenInput($this->model, $this->attribute, $this->options); }
php
private function renderWidget() { $img = $this->getImageSource(); echo "<div>$img</div>"; if ($this->link || is_string($this->link)) { echo Html::a($this->link, $this->otp->getProvisioningUri()); } if ($this->hasModel() && $this->model->hasProperty($this->attribute) && empty($this->model->{$this->attribute}) ) { $this->model->setAttributes([$this->attribute => $this->otp->getSecret()]); } echo Html::activeHiddenInput($this->model, $this->attribute, $this->options); }
[ "private", "function", "renderWidget", "(", ")", "{", "$", "img", "=", "$", "this", "->", "getImageSource", "(", ")", ";", "echo", "\"<div>$img</div>\"", ";", "if", "(", "$", "this", "->", "link", "||", "is_string", "(", "$", "this", "->", "link", ")", ")", "{", "echo", "Html", "::", "a", "(", "$", "this", "->", "link", ",", "$", "this", "->", "otp", "->", "getProvisioningUri", "(", ")", ")", ";", "}", "if", "(", "$", "this", "->", "hasModel", "(", ")", "&&", "$", "this", "->", "model", "->", "hasProperty", "(", "$", "this", "->", "attribute", ")", "&&", "empty", "(", "$", "this", "->", "model", "->", "{", "$", "this", "->", "attribute", "}", ")", ")", "{", "$", "this", "->", "model", "->", "setAttributes", "(", "[", "$", "this", "->", "attribute", "=>", "$", "this", "->", "otp", "->", "getSecret", "(", ")", "]", ")", ";", "}", "echo", "Html", "::", "activeHiddenInput", "(", "$", "this", "->", "model", ",", "$", "this", "->", "attribute", ",", "$", "this", "->", "options", ")", ";", "}" ]
Render Image and link block
[ "Render", "Image", "and", "link", "block" ]
d98b7398eb64c8ce25560c82c85f7116128c913f
https://github.com/sam002/yii2-otp/blob/d98b7398eb64c8ce25560c82c85f7116128c913f/src/widgets/OtpInit.php#L91-L108
222,121
claroline/CoreBundle
Repository/ProfilePropertyRepository.php
ProfilePropertyRepository.findAccessesByRoles
public function findAccessesByRoles(array $roles) { $dql = ' SELECT pp.property as property, MAX(pp.isEditable) as isEditable FROM Claroline\CoreBundle\Entity\ProfileProperty pp JOIN pp.role role WHERE role.name in (:roleNames) GROUP BY pp.property '; $query = $this->_em->createQuery($dql); $query->setParameter('roleNames', $roles); $results = $query->getResult(); $properties = array(); foreach ($results as $result) { $properties[$result['property']] = (boolean) $result['isEditable']; } return $properties; }
php
public function findAccessesByRoles(array $roles) { $dql = ' SELECT pp.property as property, MAX(pp.isEditable) as isEditable FROM Claroline\CoreBundle\Entity\ProfileProperty pp JOIN pp.role role WHERE role.name in (:roleNames) GROUP BY pp.property '; $query = $this->_em->createQuery($dql); $query->setParameter('roleNames', $roles); $results = $query->getResult(); $properties = array(); foreach ($results as $result) { $properties[$result['property']] = (boolean) $result['isEditable']; } return $properties; }
[ "public", "function", "findAccessesByRoles", "(", "array", "$", "roles", ")", "{", "$", "dql", "=", "'\n SELECT pp.property as property, MAX(pp.isEditable) as isEditable\n FROM Claroline\\CoreBundle\\Entity\\ProfileProperty pp\n JOIN pp.role role\n WHERE role.name in (:roleNames)\n GROUP BY pp.property\n '", ";", "$", "query", "=", "$", "this", "->", "_em", "->", "createQuery", "(", "$", "dql", ")", ";", "$", "query", "->", "setParameter", "(", "'roleNames'", ",", "$", "roles", ")", ";", "$", "results", "=", "$", "query", "->", "getResult", "(", ")", ";", "$", "properties", "=", "array", "(", ")", ";", "foreach", "(", "$", "results", "as", "$", "result", ")", "{", "$", "properties", "[", "$", "result", "[", "'property'", "]", "]", "=", "(", "boolean", ")", "$", "result", "[", "'isEditable'", "]", ";", "}", "return", "$", "properties", ";", "}" ]
Returns the accesses for a list of roles
[ "Returns", "the", "accesses", "for", "a", "list", "of", "roles" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/ProfilePropertyRepository.php#L21-L42
222,122
claroline/CoreBundle
Manager/WorkspaceTagManager.php
WorkspaceTagManager.insert
public function insert(WorkspaceTag $tag) { $this->om->persist($tag); $this->om->flush(); }
php
public function insert(WorkspaceTag $tag) { $this->om->persist($tag); $this->om->flush(); }
[ "public", "function", "insert", "(", "WorkspaceTag", "$", "tag", ")", "{", "$", "this", "->", "om", "->", "persist", "(", "$", "tag", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}" ]
Persists and flush a tag. @param \Claroline\CoreBundle\Entity\Workspace\WorkspaceTag $tag
[ "Persists", "and", "flush", "a", "tag", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/WorkspaceTagManager.php#L81-L85
222,123
claroline/CoreBundle
Manager/WorkspaceTagManager.php
WorkspaceTagManager.isTagDisplayable
private function isTagDisplayable(WorkspaceTag $tag, array $tagWorkspaces, array $hierarchy) { $displayable = false; $tagId = $tag->getId(); if ((isset($tagWorkspaces[$tagId]) && count($tagWorkspaces[$tagId]) > 0) || !is_null($tag->getWorkspace())) { $displayable = true; } else { if (isset($hierarchy[$tagId]) && count($hierarchy[$tagId]) > 0) { $children = $hierarchy[$tagId]; foreach ($children as $child) { $displayable = $this->isTagDisplayable($child, $tagWorkspaces, $hierarchy); if ($displayable) { break; } } } } return $displayable; }
php
private function isTagDisplayable(WorkspaceTag $tag, array $tagWorkspaces, array $hierarchy) { $displayable = false; $tagId = $tag->getId(); if ((isset($tagWorkspaces[$tagId]) && count($tagWorkspaces[$tagId]) > 0) || !is_null($tag->getWorkspace())) { $displayable = true; } else { if (isset($hierarchy[$tagId]) && count($hierarchy[$tagId]) > 0) { $children = $hierarchy[$tagId]; foreach ($children as $child) { $displayable = $this->isTagDisplayable($child, $tagWorkspaces, $hierarchy); if ($displayable) { break; } } } } return $displayable; }
[ "private", "function", "isTagDisplayable", "(", "WorkspaceTag", "$", "tag", ",", "array", "$", "tagWorkspaces", ",", "array", "$", "hierarchy", ")", "{", "$", "displayable", "=", "false", ";", "$", "tagId", "=", "$", "tag", "->", "getId", "(", ")", ";", "if", "(", "(", "isset", "(", "$", "tagWorkspaces", "[", "$", "tagId", "]", ")", "&&", "count", "(", "$", "tagWorkspaces", "[", "$", "tagId", "]", ")", ">", "0", ")", "||", "!", "is_null", "(", "$", "tag", "->", "getWorkspace", "(", ")", ")", ")", "{", "$", "displayable", "=", "true", ";", "}", "else", "{", "if", "(", "isset", "(", "$", "hierarchy", "[", "$", "tagId", "]", ")", "&&", "count", "(", "$", "hierarchy", "[", "$", "tagId", "]", ")", ">", "0", ")", "{", "$", "children", "=", "$", "hierarchy", "[", "$", "tagId", "]", ";", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "$", "displayable", "=", "$", "this", "->", "isTagDisplayable", "(", "$", "child", ",", "$", "tagWorkspaces", ",", "$", "hierarchy", ")", ";", "if", "(", "$", "displayable", ")", "{", "break", ";", "}", "}", "}", "}", "return", "$", "displayable", ";", "}" ]
Checks if given tag or at least one of its children is associated to a workspace @param integer $tagId @param array $tagWorkspaces @param array $hierarchy @return boolean
[ "Checks", "if", "given", "tag", "or", "at", "least", "one", "of", "its", "children", "is", "associated", "to", "a", "workspace" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/WorkspaceTagManager.php#L667-L693
222,124
claroline/CoreBundle
Manager/ResourceManager.php
ResourceManager.haveSameParents
public function haveSameParents(array $nodes) { $firstRes = array_pop($nodes); $tmp = $firstRes['parent_id']; foreach ($nodes as $node) { if ($tmp !== $node['parent_id']) { return false; } } return true; }
php
public function haveSameParents(array $nodes) { $firstRes = array_pop($nodes); $tmp = $firstRes['parent_id']; foreach ($nodes as $node) { if ($tmp !== $node['parent_id']) { return false; } } return true; }
[ "public", "function", "haveSameParents", "(", "array", "$", "nodes", ")", "{", "$", "firstRes", "=", "array_pop", "(", "$", "nodes", ")", ";", "$", "tmp", "=", "$", "firstRes", "[", "'parent_id'", "]", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "if", "(", "$", "tmp", "!==", "$", "node", "[", "'parent_id'", "]", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Checks if an array of serialized resources share the same parent. @param array nodes @return array
[ "Checks", "if", "an", "array", "of", "serialized", "resources", "share", "the", "same", "parent", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ResourceManager.php#L322-L334
222,125
claroline/CoreBundle
Manager/ResourceManager.php
ResourceManager.makeShortcut
public function makeShortcut(ResourceNode $target, ResourceNode $parent, User $creator, ResourceShortcut $shortcut) { $shortcut->setName($target->getName()); if (get_class($target) !== 'Claroline\CoreBundle\Entity\Resource\ResourceShortcut') { $shortcut->setTarget($target); } else { $shortcut->setTarget($target->getTarget()); } $shortcut = $this->create( $shortcut, $target->getResourceType(), $creator, $parent->getWorkspace(), $parent, $target->getIcon()->getShortcutIcon() ); $this->dispatcher->dispatch('log', 'Log\LogResourceCreate', array($shortcut->getResourceNode())); return $shortcut; }
php
public function makeShortcut(ResourceNode $target, ResourceNode $parent, User $creator, ResourceShortcut $shortcut) { $shortcut->setName($target->getName()); if (get_class($target) !== 'Claroline\CoreBundle\Entity\Resource\ResourceShortcut') { $shortcut->setTarget($target); } else { $shortcut->setTarget($target->getTarget()); } $shortcut = $this->create( $shortcut, $target->getResourceType(), $creator, $parent->getWorkspace(), $parent, $target->getIcon()->getShortcutIcon() ); $this->dispatcher->dispatch('log', 'Log\LogResourceCreate', array($shortcut->getResourceNode())); return $shortcut; }
[ "public", "function", "makeShortcut", "(", "ResourceNode", "$", "target", ",", "ResourceNode", "$", "parent", ",", "User", "$", "creator", ",", "ResourceShortcut", "$", "shortcut", ")", "{", "$", "shortcut", "->", "setName", "(", "$", "target", "->", "getName", "(", ")", ")", ";", "if", "(", "get_class", "(", "$", "target", ")", "!==", "'Claroline\\CoreBundle\\Entity\\Resource\\ResourceShortcut'", ")", "{", "$", "shortcut", "->", "setTarget", "(", "$", "target", ")", ";", "}", "else", "{", "$", "shortcut", "->", "setTarget", "(", "$", "target", "->", "getTarget", "(", ")", ")", ";", "}", "$", "shortcut", "=", "$", "this", "->", "create", "(", "$", "shortcut", ",", "$", "target", "->", "getResourceType", "(", ")", ",", "$", "creator", ",", "$", "parent", "->", "getWorkspace", "(", ")", ",", "$", "parent", ",", "$", "target", "->", "getIcon", "(", ")", "->", "getShortcutIcon", "(", ")", ")", ";", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "'log'", ",", "'Log\\LogResourceCreate'", ",", "array", "(", "$", "shortcut", "->", "getResourceNode", "(", ")", ")", ")", ";", "return", "$", "shortcut", ";", "}" ]
Creates a shortcut. @param \Claroline\CoreBundle\Entity\Resource\ResourceNode $target @param \Claroline\CoreBundle\Entity\Resource\ResourceNode $parent @param \Claroline\CoreBundle\Entity\User $creator @param \Claroline\CoreBundle\Entity\Resource\ResourceShortcut $shortcut @return \Claroline\CoreBundle\Entity\Resource\ResourceShortcut
[ "Creates", "a", "shortcut", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ResourceManager.php#L346-L368
222,126
claroline/CoreBundle
Manager/ResourceManager.php
ResourceManager.checkResourcePrepared
public function checkResourcePrepared(AbstractResource $resource) { $stringErrors = ''; //null or '' shouldn't be valid if ($resource->getName() == null) { $stringErrors .= 'The resource name is missing' . PHP_EOL; } if ($stringErrors !== '') { throw new MissingResourceNameException($stringErrors); } }
php
public function checkResourcePrepared(AbstractResource $resource) { $stringErrors = ''; //null or '' shouldn't be valid if ($resource->getName() == null) { $stringErrors .= 'The resource name is missing' . PHP_EOL; } if ($stringErrors !== '') { throw new MissingResourceNameException($stringErrors); } }
[ "public", "function", "checkResourcePrepared", "(", "AbstractResource", "$", "resource", ")", "{", "$", "stringErrors", "=", "''", ";", "//null or '' shouldn't be valid", "if", "(", "$", "resource", "->", "getName", "(", ")", "==", "null", ")", "{", "$", "stringErrors", ".=", "'The resource name is missing'", ".", "PHP_EOL", ";", "}", "if", "(", "$", "stringErrors", "!==", "''", ")", "{", "throw", "new", "MissingResourceNameException", "(", "$", "stringErrors", ")", ";", "}", "}" ]
Checks if a resource already has a name. @param \Claroline\CoreBundle\Entity\Resource\AbstractResource $resource @throws MissingResourceNameException
[ "Checks", "if", "a", "resource", "already", "has", "a", "name", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ResourceManager.php#L450-L462
222,127
claroline/CoreBundle
Manager/ResourceManager.php
ResourceManager.move
public function move(ResourceNode $child, ResourceNode $parent) { if ($parent === $child) { throw new ResourceMoveException("You cannot move a directory into itself"); } $this->om->startFlushSuite(); $this->setLastIndex($parent, $child); $child->setParent($parent); $child->setName($this->getUniqueName($child, $parent)); if ($child->getWorkspace()->getId() !== $parent->getWorkspace()->getId()) { $this->updateWorkspace($child, $parent->getWorkspace()); } $this->om->persist($child); $this->om->endFlushSuite(); $this->dispatcher->dispatch('log', 'Log\LogResourceMove', array($child, $parent)); return $child; }
php
public function move(ResourceNode $child, ResourceNode $parent) { if ($parent === $child) { throw new ResourceMoveException("You cannot move a directory into itself"); } $this->om->startFlushSuite(); $this->setLastIndex($parent, $child); $child->setParent($parent); $child->setName($this->getUniqueName($child, $parent)); if ($child->getWorkspace()->getId() !== $parent->getWorkspace()->getId()) { $this->updateWorkspace($child, $parent->getWorkspace()); } $this->om->persist($child); $this->om->endFlushSuite(); $this->dispatcher->dispatch('log', 'Log\LogResourceMove', array($child, $parent)); return $child; }
[ "public", "function", "move", "(", "ResourceNode", "$", "child", ",", "ResourceNode", "$", "parent", ")", "{", "if", "(", "$", "parent", "===", "$", "child", ")", "{", "throw", "new", "ResourceMoveException", "(", "\"You cannot move a directory into itself\"", ")", ";", "}", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "this", "->", "setLastIndex", "(", "$", "parent", ",", "$", "child", ")", ";", "$", "child", "->", "setParent", "(", "$", "parent", ")", ";", "$", "child", "->", "setName", "(", "$", "this", "->", "getUniqueName", "(", "$", "child", ",", "$", "parent", ")", ")", ";", "if", "(", "$", "child", "->", "getWorkspace", "(", ")", "->", "getId", "(", ")", "!==", "$", "parent", "->", "getWorkspace", "(", ")", "->", "getId", "(", ")", ")", "{", "$", "this", "->", "updateWorkspace", "(", "$", "child", ",", "$", "parent", "->", "getWorkspace", "(", ")", ")", ";", "}", "$", "this", "->", "om", "->", "persist", "(", "$", "child", ")", ";", "$", "this", "->", "om", "->", "endFlushSuite", "(", ")", ";", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "'log'", ",", "'Log\\LogResourceMove'", ",", "array", "(", "$", "child", ",", "$", "parent", ")", ")", ";", "return", "$", "child", ";", "}" ]
Moves a resource. @param ResourceNode $child currently treated node @param ResourceNode $parent old parent @throws ResourceMoveException @return ResourceNode
[ "Moves", "a", "resource", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ResourceManager.php#L601-L620
222,128
claroline/CoreBundle
Manager/ResourceManager.php
ResourceManager.hasLinkTo
public function hasLinkTo(ResourceNode $parent, ResourceNode $target) { $nodes = $this->resourceNodeRepo ->findBy(array('parent' => $parent, 'class' => 'Claroline\CoreBundle\Entity\Resource\ResourceShortcut')); foreach ($nodes as $node) { $shortcut = $this->getResourceFromNode($node); if ($shortcut->getTarget() == $target) { return true; } } return false; }
php
public function hasLinkTo(ResourceNode $parent, ResourceNode $target) { $nodes = $this->resourceNodeRepo ->findBy(array('parent' => $parent, 'class' => 'Claroline\CoreBundle\Entity\Resource\ResourceShortcut')); foreach ($nodes as $node) { $shortcut = $this->getResourceFromNode($node); if ($shortcut->getTarget() == $target) { return true; } } return false; }
[ "public", "function", "hasLinkTo", "(", "ResourceNode", "$", "parent", ",", "ResourceNode", "$", "target", ")", "{", "$", "nodes", "=", "$", "this", "->", "resourceNodeRepo", "->", "findBy", "(", "array", "(", "'parent'", "=>", "$", "parent", ",", "'class'", "=>", "'Claroline\\CoreBundle\\Entity\\Resource\\ResourceShortcut'", ")", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "$", "shortcut", "=", "$", "this", "->", "getResourceFromNode", "(", "$", "node", ")", ";", "if", "(", "$", "shortcut", "->", "getTarget", "(", ")", "==", "$", "target", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if a resource in a node has a link to the target with a shortcut. @param \Claroline\CoreBundle\Entity\Resource\ResourceNode $parent @param \Claroline\CoreBundle\Entity\Resource\ResourceNode $target @return boolean
[ "Checks", "if", "a", "resource", "in", "a", "node", "has", "a", "link", "to", "the", "target", "with", "a", "shortcut", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ResourceManager.php#L655-L668
222,129
claroline/CoreBundle
Manager/ResourceManager.php
ResourceManager.isPathValid
public function isPathValid(array $ancestors) { $continue = true; for ($i = 0, $size = count($ancestors); $i < $size; $i++) { if (isset($ancestors[$i + 1])) { if ($ancestors[$i + 1]->getParent() === $ancestors[$i]) { $continue = true; } else { $continue = $this->hasLinkTo($ancestors[$i], $ancestors[$i + 1]); } } if (!$continue) { return false; } } return true; }
php
public function isPathValid(array $ancestors) { $continue = true; for ($i = 0, $size = count($ancestors); $i < $size; $i++) { if (isset($ancestors[$i + 1])) { if ($ancestors[$i + 1]->getParent() === $ancestors[$i]) { $continue = true; } else { $continue = $this->hasLinkTo($ancestors[$i], $ancestors[$i + 1]); } } if (!$continue) { return false; } } return true; }
[ "public", "function", "isPathValid", "(", "array", "$", "ancestors", ")", "{", "$", "continue", "=", "true", ";", "for", "(", "$", "i", "=", "0", ",", "$", "size", "=", "count", "(", "$", "ancestors", ")", ";", "$", "i", "<", "$", "size", ";", "$", "i", "++", ")", "{", "if", "(", "isset", "(", "$", "ancestors", "[", "$", "i", "+", "1", "]", ")", ")", "{", "if", "(", "$", "ancestors", "[", "$", "i", "+", "1", "]", "->", "getParent", "(", ")", "===", "$", "ancestors", "[", "$", "i", "]", ")", "{", "$", "continue", "=", "true", ";", "}", "else", "{", "$", "continue", "=", "$", "this", "->", "hasLinkTo", "(", "$", "ancestors", "[", "$", "i", "]", ",", "$", "ancestors", "[", "$", "i", "+", "1", "]", ")", ";", "}", "}", "if", "(", "!", "$", "continue", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Checks if a path is valid. @param array $ancestors @return boolean
[ "Checks", "if", "a", "path", "is", "valid", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ResourceManager.php#L677-L696
222,130
claroline/CoreBundle
Manager/ResourceManager.php
ResourceManager.areAncestorsDirectory
public function areAncestorsDirectory(array $ancestors) { array_pop($ancestors); foreach ($ancestors as $ancestor) { if ($ancestor->getResourceType()->getName() !== 'directory') { return false; } } return true; }
php
public function areAncestorsDirectory(array $ancestors) { array_pop($ancestors); foreach ($ancestors as $ancestor) { if ($ancestor->getResourceType()->getName() !== 'directory') { return false; } } return true; }
[ "public", "function", "areAncestorsDirectory", "(", "array", "$", "ancestors", ")", "{", "array_pop", "(", "$", "ancestors", ")", ";", "foreach", "(", "$", "ancestors", "as", "$", "ancestor", ")", "{", "if", "(", "$", "ancestor", "->", "getResourceType", "(", ")", "->", "getName", "(", ")", "!==", "'directory'", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Checks if all the resource in the array are directories. @param \Claroline\CoreBundle\Entity\Resource\ResourceNode[] $ancestors @return boolean
[ "Checks", "if", "all", "the", "resource", "in", "the", "array", "are", "directories", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ResourceManager.php#L705-L716
222,131
claroline/CoreBundle
Manager/ResourceManager.php
ResourceManager.changeIcon
public function changeIcon(ResourceNode $node, File $file) { $this->om->startFlushSuite(); $icon = $this->iconManager->createCustomIcon($file, $node->getWorkspace()); $this->iconManager->replace($node, $icon); $this->logChangeSet($node); $this->om->endFlushSuite(); return $icon; }
php
public function changeIcon(ResourceNode $node, File $file) { $this->om->startFlushSuite(); $icon = $this->iconManager->createCustomIcon($file, $node->getWorkspace()); $this->iconManager->replace($node, $icon); $this->logChangeSet($node); $this->om->endFlushSuite(); return $icon; }
[ "public", "function", "changeIcon", "(", "ResourceNode", "$", "node", ",", "File", "$", "file", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "icon", "=", "$", "this", "->", "iconManager", "->", "createCustomIcon", "(", "$", "file", ",", "$", "node", "->", "getWorkspace", "(", ")", ")", ";", "$", "this", "->", "iconManager", "->", "replace", "(", "$", "node", ",", "$", "icon", ")", ";", "$", "this", "->", "logChangeSet", "(", "$", "node", ")", ";", "$", "this", "->", "om", "->", "endFlushSuite", "(", ")", ";", "return", "$", "icon", ";", "}" ]
Changes a node icon. @param \Claroline\CoreBundle\Entity\Resource\ResourceNode $node @param \Symfony\Component\HttpFoundation\File\File $file @return \Claroline\CoreBundle\Entity\Resource\ResourceIcon
[ "Changes", "a", "node", "icon", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ResourceManager.php#L1195-L1204
222,132
claroline/CoreBundle
Manager/ResourceManager.php
ResourceManager.logChangeSet
public function logChangeSet(ResourceNode $node) { $uow = $this->om->getUnitOfWork(); $uow->computeChangeSets(); $changeSet = $uow->getEntityChangeSet($node); if (count($changeSet) > 0) { $this->dispatcher->dispatch( 'log', 'Log\LogResourceUpdate', array($node, $changeSet) ); } }
php
public function logChangeSet(ResourceNode $node) { $uow = $this->om->getUnitOfWork(); $uow->computeChangeSets(); $changeSet = $uow->getEntityChangeSet($node); if (count($changeSet) > 0) { $this->dispatcher->dispatch( 'log', 'Log\LogResourceUpdate', array($node, $changeSet) ); } }
[ "public", "function", "logChangeSet", "(", "ResourceNode", "$", "node", ")", "{", "$", "uow", "=", "$", "this", "->", "om", "->", "getUnitOfWork", "(", ")", ";", "$", "uow", "->", "computeChangeSets", "(", ")", ";", "$", "changeSet", "=", "$", "uow", "->", "getEntityChangeSet", "(", "$", "node", ")", ";", "if", "(", "count", "(", "$", "changeSet", ")", ">", "0", ")", "{", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "'log'", ",", "'Log\\LogResourceUpdate'", ",", "array", "(", "$", "node", ",", "$", "changeSet", ")", ")", ";", "}", "}" ]
Logs every change on a node. @param \Claroline\CoreBundle\Entity\Resource\ResourceNode $node
[ "Logs", "every", "change", "on", "a", "node", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ResourceManager.php#L1211-L1224
222,133
claroline/CoreBundle
Manager/ResourceManager.php
ResourceManager.isWorkspaceOwnerOf
public function isWorkspaceOwnerOf(ResourceNode $node, TokenInterface $token) { $workspace = $node->getWorkspace(); $managerRoleName = 'ROLE_WS_MANAGER_' . $workspace->getGuid(); return in_array($managerRoleName, $this->secut->getRoles($token)) ? true: false; }
php
public function isWorkspaceOwnerOf(ResourceNode $node, TokenInterface $token) { $workspace = $node->getWorkspace(); $managerRoleName = 'ROLE_WS_MANAGER_' . $workspace->getGuid(); return in_array($managerRoleName, $this->secut->getRoles($token)) ? true: false; }
[ "public", "function", "isWorkspaceOwnerOf", "(", "ResourceNode", "$", "node", ",", "TokenInterface", "$", "token", ")", "{", "$", "workspace", "=", "$", "node", "->", "getWorkspace", "(", ")", ";", "$", "managerRoleName", "=", "'ROLE_WS_MANAGER_'", ".", "$", "workspace", "->", "getGuid", "(", ")", ";", "return", "in_array", "(", "$", "managerRoleName", ",", "$", "this", "->", "secut", "->", "getRoles", "(", "$", "token", ")", ")", "?", "true", ":", "false", ";", "}" ]
Returns true of the token owns the workspace of the resource node. @param ResourceNode $node @param TokenInterface $token @return boolean
[ "Returns", "true", "of", "the", "token", "owns", "the", "workspace", "of", "the", "resource", "node", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ResourceManager.php#L1523-L1529
222,134
claroline/CoreBundle
Manager/ResourceManager.php
ResourceManager.changeAccessibilityDate
public function changeAccessibilityDate( ResourceNode $node, $accessibleFrom, $accessibleUntil ) { if ($node->getResourceType()->getName() === 'directory') { $descendants = $this->resourceNodeRepo->findDescendants($node); foreach ($descendants as $descendant) { $descendant->setAccessibleFrom($accessibleFrom); $descendant->setAccessibleUntil($accessibleUntil); $this->om->persist($descendant); } $this->om->flush(); } }
php
public function changeAccessibilityDate( ResourceNode $node, $accessibleFrom, $accessibleUntil ) { if ($node->getResourceType()->getName() === 'directory') { $descendants = $this->resourceNodeRepo->findDescendants($node); foreach ($descendants as $descendant) { $descendant->setAccessibleFrom($accessibleFrom); $descendant->setAccessibleUntil($accessibleUntil); $this->om->persist($descendant); } $this->om->flush(); } }
[ "public", "function", "changeAccessibilityDate", "(", "ResourceNode", "$", "node", ",", "$", "accessibleFrom", ",", "$", "accessibleUntil", ")", "{", "if", "(", "$", "node", "->", "getResourceType", "(", ")", "->", "getName", "(", ")", "===", "'directory'", ")", "{", "$", "descendants", "=", "$", "this", "->", "resourceNodeRepo", "->", "findDescendants", "(", "$", "node", ")", ";", "foreach", "(", "$", "descendants", "as", "$", "descendant", ")", "{", "$", "descendant", "->", "setAccessibleFrom", "(", "$", "accessibleFrom", ")", ";", "$", "descendant", "->", "setAccessibleUntil", "(", "$", "accessibleUntil", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "descendant", ")", ";", "}", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}", "}" ]
Retrieves all descendants of given ResourceNode and updates their accessibility dates. @param ResourceNode $node A directory @param datetime $accessibleFrom @param datetime $accessibleUntil
[ "Retrieves", "all", "descendants", "of", "given", "ResourceNode", "and", "updates", "their", "accessibility", "dates", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ResourceManager.php#L1550-L1566
222,135
claroline/CoreBundle
Manager/ResourceManager.php
ResourceManager.isResourceActionImplemented
public function isResourceActionImplemented(ResourceType $resourceType = null, $actionName) { if ($resourceType) { $alwaysTrue = array('rename', 'edit-properties', 'edit-rights', 'open-tracking'); //first, directories can be downloaded even if there is no listener attached to it if ($resourceType->getName() === 'directory' && $actionName == 'download') return true; if (in_array($actionName, $alwaysTrue)) return true; $eventName = $actionName . '_' . $resourceType->getName(); } else { $eventName = 'resource_action_' . $actionName; } return $this->dispatcher->hasListeners($eventName); }
php
public function isResourceActionImplemented(ResourceType $resourceType = null, $actionName) { if ($resourceType) { $alwaysTrue = array('rename', 'edit-properties', 'edit-rights', 'open-tracking'); //first, directories can be downloaded even if there is no listener attached to it if ($resourceType->getName() === 'directory' && $actionName == 'download') return true; if (in_array($actionName, $alwaysTrue)) return true; $eventName = $actionName . '_' . $resourceType->getName(); } else { $eventName = 'resource_action_' . $actionName; } return $this->dispatcher->hasListeners($eventName); }
[ "public", "function", "isResourceActionImplemented", "(", "ResourceType", "$", "resourceType", "=", "null", ",", "$", "actionName", ")", "{", "if", "(", "$", "resourceType", ")", "{", "$", "alwaysTrue", "=", "array", "(", "'rename'", ",", "'edit-properties'", ",", "'edit-rights'", ",", "'open-tracking'", ")", ";", "//first, directories can be downloaded even if there is no listener attached to it", "if", "(", "$", "resourceType", "->", "getName", "(", ")", "===", "'directory'", "&&", "$", "actionName", "==", "'download'", ")", "return", "true", ";", "if", "(", "in_array", "(", "$", "actionName", ",", "$", "alwaysTrue", ")", ")", "return", "true", ";", "$", "eventName", "=", "$", "actionName", ".", "'_'", ".", "$", "resourceType", "->", "getName", "(", ")", ";", "}", "else", "{", "$", "eventName", "=", "'resource_action_'", ".", "$", "actionName", ";", "}", "return", "$", "this", "->", "dispatcher", "->", "hasListeners", "(", "$", "eventName", ")", ";", "}" ]
Returns true if the listener is implemented for a resourceType and an action @param ResourceType $resourceType @param string $actionName
[ "Returns", "true", "if", "the", "listener", "is", "implemented", "for", "a", "resourceType", "and", "an", "action" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ResourceManager.php#L1574-L1588
222,136
claroline/CoreBundle
Manager/ResourceManager.php
ResourceManager.addStorageExceededFormError
public function addStorageExceededFormError(Form $form, $fileSize, Workspace $workspace) { $filesize = $this->ut->getRealFileSize($fileSize); //we want how many bites and well... $maxSize = $this->ut->getRealFileSize($workspace->getMaxStorageSize()); //throw new \Exception($maxSize); $usedSize = $this->ut->getRealFileSize( $this->container->get('claroline.manager.workspace_manager')->getUsedStorage($workspace) ); $storageLeft = $maxSize - $usedSize; $fileSize = $this->ut->formatFileSize($fileSize); $storageLeft = $this->ut->formatFileSize($storageLeft); $translator = $this->container->get('translator'); $msg = $translator->trans( 'storage_limit_exceeded', array('%storageLeft%' => $storageLeft, '%fileSize%' => $fileSize), 'platform' ); $form->addError(new FormError($msg)); }
php
public function addStorageExceededFormError(Form $form, $fileSize, Workspace $workspace) { $filesize = $this->ut->getRealFileSize($fileSize); //we want how many bites and well... $maxSize = $this->ut->getRealFileSize($workspace->getMaxStorageSize()); //throw new \Exception($maxSize); $usedSize = $this->ut->getRealFileSize( $this->container->get('claroline.manager.workspace_manager')->getUsedStorage($workspace) ); $storageLeft = $maxSize - $usedSize; $fileSize = $this->ut->formatFileSize($fileSize); $storageLeft = $this->ut->formatFileSize($storageLeft); $translator = $this->container->get('translator'); $msg = $translator->trans( 'storage_limit_exceeded', array('%storageLeft%' => $storageLeft, '%fileSize%' => $fileSize), 'platform' ); $form->addError(new FormError($msg)); }
[ "public", "function", "addStorageExceededFormError", "(", "Form", "$", "form", ",", "$", "fileSize", ",", "Workspace", "$", "workspace", ")", "{", "$", "filesize", "=", "$", "this", "->", "ut", "->", "getRealFileSize", "(", "$", "fileSize", ")", ";", "//we want how many bites and well...", "$", "maxSize", "=", "$", "this", "->", "ut", "->", "getRealFileSize", "(", "$", "workspace", "->", "getMaxStorageSize", "(", ")", ")", ";", "//throw new \\Exception($maxSize);", "$", "usedSize", "=", "$", "this", "->", "ut", "->", "getRealFileSize", "(", "$", "this", "->", "container", "->", "get", "(", "'claroline.manager.workspace_manager'", ")", "->", "getUsedStorage", "(", "$", "workspace", ")", ")", ";", "$", "storageLeft", "=", "$", "maxSize", "-", "$", "usedSize", ";", "$", "fileSize", "=", "$", "this", "->", "ut", "->", "formatFileSize", "(", "$", "fileSize", ")", ";", "$", "storageLeft", "=", "$", "this", "->", "ut", "->", "formatFileSize", "(", "$", "storageLeft", ")", ";", "$", "translator", "=", "$", "this", "->", "container", "->", "get", "(", "'translator'", ")", ";", "$", "msg", "=", "$", "translator", "->", "trans", "(", "'storage_limit_exceeded'", ",", "array", "(", "'%storageLeft%'", "=>", "$", "storageLeft", ",", "'%fileSize%'", "=>", "$", "fileSize", ")", ",", "'platform'", ")", ";", "$", "form", "->", "addError", "(", "new", "FormError", "(", "$", "msg", ")", ")", ";", "}" ]
Adds the storage exceeded error in a form. @param Form $form @param integer $filesize
[ "Adds", "the", "storage", "exceeded", "error", "in", "a", "form", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ResourceManager.php#L1664-L1685
222,137
claroline/CoreBundle
Manager/ResourceManager.php
ResourceManager.getNodeScheduledForInsert
public function getNodeScheduledForInsert(Workspace $workspace, $name, $parent = null) { $scheduledForInsert = $this->om->getUnitOfWork()->getScheduledEntityInsertions(); $res = null; foreach ($scheduledForInsert as $entity) { if (get_class($entity) === 'Claroline\CoreBundle\Entity\Resource\ResourceNode') { if ($entity->getWorkspace()->getCode() === $workspace->getCode() && $entity->getName() === $name && $entity->getParent() == $parent) { return $entity; } } } return $res; }
php
public function getNodeScheduledForInsert(Workspace $workspace, $name, $parent = null) { $scheduledForInsert = $this->om->getUnitOfWork()->getScheduledEntityInsertions(); $res = null; foreach ($scheduledForInsert as $entity) { if (get_class($entity) === 'Claroline\CoreBundle\Entity\Resource\ResourceNode') { if ($entity->getWorkspace()->getCode() === $workspace->getCode() && $entity->getName() === $name && $entity->getParent() == $parent) { return $entity; } } } return $res; }
[ "public", "function", "getNodeScheduledForInsert", "(", "Workspace", "$", "workspace", ",", "$", "name", ",", "$", "parent", "=", "null", ")", "{", "$", "scheduledForInsert", "=", "$", "this", "->", "om", "->", "getUnitOfWork", "(", ")", "->", "getScheduledEntityInsertions", "(", ")", ";", "$", "res", "=", "null", ";", "foreach", "(", "$", "scheduledForInsert", "as", "$", "entity", ")", "{", "if", "(", "get_class", "(", "$", "entity", ")", "===", "'Claroline\\CoreBundle\\Entity\\Resource\\ResourceNode'", ")", "{", "if", "(", "$", "entity", "->", "getWorkspace", "(", ")", "->", "getCode", "(", ")", "===", "$", "workspace", "->", "getCode", "(", ")", "&&", "$", "entity", "->", "getName", "(", ")", "===", "$", "name", "&&", "$", "entity", "->", "getParent", "(", ")", "==", "$", "parent", ")", "{", "return", "$", "entity", ";", "}", "}", "}", "return", "$", "res", ";", "}" ]
Search a ResourceNode wich is persisted but not flushed yet @param Workspace $workspace @param $name @param ResourceNode $parent @return ResourceNode
[ "Search", "a", "ResourceNode", "wich", "is", "persisted", "but", "not", "flushed", "yet" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ResourceManager.php#L1696-L1713
222,138
claroline/CoreBundle
Manager/ResourceManager.php
ResourceManager.getDefaultUploadDestinations
public function getDefaultUploadDestinations() { $user = $this->container->get('security.token_storage')->getToken()->getUser(); if ($user == 'anon.') return array(); $pws = $user->getPersonalWorkspace(); $defaults = []; if ($pws) { $defaults = array_merge( $defaults, $this->directoryRepo->findDefaultUploadDirectories($pws) ); } $node = $this->container->get('request')->getSession()->get('current_resource_node'); if ($node && $node->getWorkspace()) { $root = $this->directoryRepo->findDefaultUploadDirectories($node->getWorkspace()); if ($this->container->get('security.authorization_checker')->isGranted('CREATE', $root)) { $defaults = array_merge($defaults, $root); } } return $defaults; }
php
public function getDefaultUploadDestinations() { $user = $this->container->get('security.token_storage')->getToken()->getUser(); if ($user == 'anon.') return array(); $pws = $user->getPersonalWorkspace(); $defaults = []; if ($pws) { $defaults = array_merge( $defaults, $this->directoryRepo->findDefaultUploadDirectories($pws) ); } $node = $this->container->get('request')->getSession()->get('current_resource_node'); if ($node && $node->getWorkspace()) { $root = $this->directoryRepo->findDefaultUploadDirectories($node->getWorkspace()); if ($this->container->get('security.authorization_checker')->isGranted('CREATE', $root)) { $defaults = array_merge($defaults, $root); } } return $defaults; }
[ "public", "function", "getDefaultUploadDestinations", "(", ")", "{", "$", "user", "=", "$", "this", "->", "container", "->", "get", "(", "'security.token_storage'", ")", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ";", "if", "(", "$", "user", "==", "'anon.'", ")", "return", "array", "(", ")", ";", "$", "pws", "=", "$", "user", "->", "getPersonalWorkspace", "(", ")", ";", "$", "defaults", "=", "[", "]", ";", "if", "(", "$", "pws", ")", "{", "$", "defaults", "=", "array_merge", "(", "$", "defaults", ",", "$", "this", "->", "directoryRepo", "->", "findDefaultUploadDirectories", "(", "$", "pws", ")", ")", ";", "}", "$", "node", "=", "$", "this", "->", "container", "->", "get", "(", "'request'", ")", "->", "getSession", "(", ")", "->", "get", "(", "'current_resource_node'", ")", ";", "if", "(", "$", "node", "&&", "$", "node", "->", "getWorkspace", "(", ")", ")", "{", "$", "root", "=", "$", "this", "->", "directoryRepo", "->", "findDefaultUploadDirectories", "(", "$", "node", "->", "getWorkspace", "(", ")", ")", ";", "if", "(", "$", "this", "->", "container", "->", "get", "(", "'security.authorization_checker'", ")", "->", "isGranted", "(", "'CREATE'", ",", "$", "root", ")", ")", "{", "$", "defaults", "=", "array_merge", "(", "$", "defaults", ",", "$", "root", ")", ";", "}", "}", "return", "$", "defaults", ";", "}" ]
Returns the list of file upload destination choices @return array
[ "Returns", "the", "list", "of", "file", "upload", "destination", "choices" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/ResourceManager.php#L1749-L1775
222,139
claroline/CoreBundle
Entity/Resource/ResourceNode.php
ResourceNode.setName
public function setName($name) { if (strpos(self::PATH_SEPARATOR, $name) !== false) { throw new \InvalidArgumentException( 'Invalid character "' . self::PATH_SEPARATOR . '" in resource name.' ); } $this->name = $name; }
php
public function setName($name) { if (strpos(self::PATH_SEPARATOR, $name) !== false) { throw new \InvalidArgumentException( 'Invalid character "' . self::PATH_SEPARATOR . '" in resource name.' ); } $this->name = $name; }
[ "public", "function", "setName", "(", "$", "name", ")", "{", "if", "(", "strpos", "(", "self", "::", "PATH_SEPARATOR", ",", "$", "name", ")", "!==", "false", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid character \"'", ".", "self", "::", "PATH_SEPARATOR", ".", "'\" in resource name.'", ")", ";", "}", "$", "this", "->", "name", "=", "$", "name", ";", "}" ]
Sets the resource name. @param string $name @throws an exception if the name contains the path separator ('/').
[ "Sets", "the", "resource", "name", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Entity/Resource/ResourceNode.php#L437-L446
222,140
vihuvac/recaptcha-bundle
src/Validator/Constraints/IsTrueValidator.php
IsTrueValidator.checkAnswer
private function checkAnswer($secretKey, $remoteip, $response) { if ($remoteip == null || $remoteip == "") { throw new ValidatorException("vihuvac_recaptcha.validator.remote_ip"); } // discard spam submissions if ($response == null || strlen($response) == 0) { return false; } $response = $this->httpGet(self::RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/siteverify", array( "secret" => $secretKey, "remoteip" => $remoteip, "response" => $response )); return json_decode($response, true); }
php
private function checkAnswer($secretKey, $remoteip, $response) { if ($remoteip == null || $remoteip == "") { throw new ValidatorException("vihuvac_recaptcha.validator.remote_ip"); } // discard spam submissions if ($response == null || strlen($response) == 0) { return false; } $response = $this->httpGet(self::RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/siteverify", array( "secret" => $secretKey, "remoteip" => $remoteip, "response" => $response )); return json_decode($response, true); }
[ "private", "function", "checkAnswer", "(", "$", "secretKey", ",", "$", "remoteip", ",", "$", "response", ")", "{", "if", "(", "$", "remoteip", "==", "null", "||", "$", "remoteip", "==", "\"\"", ")", "{", "throw", "new", "ValidatorException", "(", "\"vihuvac_recaptcha.validator.remote_ip\"", ")", ";", "}", "// discard spam submissions", "if", "(", "$", "response", "==", "null", "||", "strlen", "(", "$", "response", ")", "==", "0", ")", "{", "return", "false", ";", "}", "$", "response", "=", "$", "this", "->", "httpGet", "(", "self", "::", "RECAPTCHA_VERIFY_SERVER", ",", "\"/recaptcha/api/siteverify\"", ",", "array", "(", "\"secret\"", "=>", "$", "secretKey", ",", "\"remoteip\"", "=>", "$", "remoteip", ",", "\"response\"", "=>", "$", "response", ")", ")", ";", "return", "json_decode", "(", "$", "response", ",", "true", ")", ";", "}" ]
Calls an HTTP POST function to verify if the user's guess was correct. @param String $secretKey @param String $remoteip @param String $response @throws ValidatorException When missing remote ip @return Boolean
[ "Calls", "an", "HTTP", "POST", "function", "to", "verify", "if", "the", "user", "s", "guess", "was", "correct", "." ]
a9b796c6bcc53b106a5ba206c1d7b6b25472f1e6
https://github.com/vihuvac/recaptcha-bundle/blob/a9b796c6bcc53b106a5ba206c1d7b6b25472f1e6/src/Validator/Constraints/IsTrueValidator.php#L115-L134
222,141
vihuvac/recaptcha-bundle
src/Validator/Constraints/IsTrueValidator.php
IsTrueValidator.httpGet
private function httpGet($host, $path, $data) { $host = sprintf("%s%s?%s", $host, $path, http_build_query($data, null, "&")); $context = $this->getResourceContext(); return file_get_contents($host, false, $context); }
php
private function httpGet($host, $path, $data) { $host = sprintf("%s%s?%s", $host, $path, http_build_query($data, null, "&")); $context = $this->getResourceContext(); return file_get_contents($host, false, $context); }
[ "private", "function", "httpGet", "(", "$", "host", ",", "$", "path", ",", "$", "data", ")", "{", "$", "host", "=", "sprintf", "(", "\"%s%s?%s\"", ",", "$", "host", ",", "$", "path", ",", "http_build_query", "(", "$", "data", ",", "null", ",", "\"&\"", ")", ")", ";", "$", "context", "=", "$", "this", "->", "getResourceContext", "(", ")", ";", "return", "file_get_contents", "(", "$", "host", ",", "false", ",", "$", "context", ")", ";", "}" ]
Submits an HTTP POST to a reCAPTCHA server. @param String $host @param String $path @param Array $data @return Array response
[ "Submits", "an", "HTTP", "POST", "to", "a", "reCAPTCHA", "server", "." ]
a9b796c6bcc53b106a5ba206c1d7b6b25472f1e6
https://github.com/vihuvac/recaptcha-bundle/blob/a9b796c6bcc53b106a5ba206c1d7b6b25472f1e6/src/Validator/Constraints/IsTrueValidator.php#L145-L152
222,142
vihuvac/recaptcha-bundle
src/Validator/Constraints/IsTrueValidator.php
IsTrueValidator.getResourceContext
private function getResourceContext() { if (null === $this->httpProxy["host"] || null === $this->httpProxy["port"]) { return null; } $options = array(); foreach (array("http", "https") as $protocol) { $options[$protocol] = array( "method" => "GET", "proxy" => sprintf("tcp://%s:%s", $this->httpProxy["host"], $this->httpProxy["port"]), "request_fulluri" => true ); if (null !== $this->httpProxy["auth"]) { $options[$protocol]["header"] = sprintf("Proxy-Authorization: Basic %s", base64_encode($this->httpProxy["auth"])); } } return stream_context_create($options); }
php
private function getResourceContext() { if (null === $this->httpProxy["host"] || null === $this->httpProxy["port"]) { return null; } $options = array(); foreach (array("http", "https") as $protocol) { $options[$protocol] = array( "method" => "GET", "proxy" => sprintf("tcp://%s:%s", $this->httpProxy["host"], $this->httpProxy["port"]), "request_fulluri" => true ); if (null !== $this->httpProxy["auth"]) { $options[$protocol]["header"] = sprintf("Proxy-Authorization: Basic %s", base64_encode($this->httpProxy["auth"])); } } return stream_context_create($options); }
[ "private", "function", "getResourceContext", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "httpProxy", "[", "\"host\"", "]", "||", "null", "===", "$", "this", "->", "httpProxy", "[", "\"port\"", "]", ")", "{", "return", "null", ";", "}", "$", "options", "=", "array", "(", ")", ";", "foreach", "(", "array", "(", "\"http\"", ",", "\"https\"", ")", "as", "$", "protocol", ")", "{", "$", "options", "[", "$", "protocol", "]", "=", "array", "(", "\"method\"", "=>", "\"GET\"", ",", "\"proxy\"", "=>", "sprintf", "(", "\"tcp://%s:%s\"", ",", "$", "this", "->", "httpProxy", "[", "\"host\"", "]", ",", "$", "this", "->", "httpProxy", "[", "\"port\"", "]", ")", ",", "\"request_fulluri\"", "=>", "true", ")", ";", "if", "(", "null", "!==", "$", "this", "->", "httpProxy", "[", "\"auth\"", "]", ")", "{", "$", "options", "[", "$", "protocol", "]", "[", "\"header\"", "]", "=", "sprintf", "(", "\"Proxy-Authorization: Basic %s\"", ",", "base64_encode", "(", "$", "this", "->", "httpProxy", "[", "\"auth\"", "]", ")", ")", ";", "}", "}", "return", "stream_context_create", "(", "$", "options", ")", ";", "}" ]
Resource context. @return resource context for HTTP Proxy.
[ "Resource", "context", "." ]
a9b796c6bcc53b106a5ba206c1d7b6b25472f1e6
https://github.com/vihuvac/recaptcha-bundle/blob/a9b796c6bcc53b106a5ba206c1d7b6b25472f1e6/src/Validator/Constraints/IsTrueValidator.php#L159-L179
222,143
claroline/CoreBundle
Library/Utilities/ThumbnailCreator.php
ThumbnailCreator.resize
private function resize($newWidth, $newHeight, $srcImg, $filename) { $oldX = imagesx($srcImg); $oldY = imagesy($srcImg); if ($oldX > $oldY) { $thumbWidth = $newWidth; $thumbHeight = $oldY * ($newHeight / $oldX); } else { if ($oldX <= $oldY) { $thumbWidth = $oldX * ($newWidth / $oldY); $thumbHeight = $newHeight; } } //white background $dstImg = imagecreatetruecolor($thumbWidth, $thumbHeight); $bg = imagecolorallocate($dstImg, 255, 255, 255); imagefill($dstImg, 0, 0, $bg); //resizing imagecopyresampled($dstImg, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $oldX, $oldY); $srcImg = imagepng($dstImg, $filename); //free memory imagedestroy($dstImg); }
php
private function resize($newWidth, $newHeight, $srcImg, $filename) { $oldX = imagesx($srcImg); $oldY = imagesy($srcImg); if ($oldX > $oldY) { $thumbWidth = $newWidth; $thumbHeight = $oldY * ($newHeight / $oldX); } else { if ($oldX <= $oldY) { $thumbWidth = $oldX * ($newWidth / $oldY); $thumbHeight = $newHeight; } } //white background $dstImg = imagecreatetruecolor($thumbWidth, $thumbHeight); $bg = imagecolorallocate($dstImg, 255, 255, 255); imagefill($dstImg, 0, 0, $bg); //resizing imagecopyresampled($dstImg, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $oldX, $oldY); $srcImg = imagepng($dstImg, $filename); //free memory imagedestroy($dstImg); }
[ "private", "function", "resize", "(", "$", "newWidth", ",", "$", "newHeight", ",", "$", "srcImg", ",", "$", "filename", ")", "{", "$", "oldX", "=", "imagesx", "(", "$", "srcImg", ")", ";", "$", "oldY", "=", "imagesy", "(", "$", "srcImg", ")", ";", "if", "(", "$", "oldX", ">", "$", "oldY", ")", "{", "$", "thumbWidth", "=", "$", "newWidth", ";", "$", "thumbHeight", "=", "$", "oldY", "*", "(", "$", "newHeight", "/", "$", "oldX", ")", ";", "}", "else", "{", "if", "(", "$", "oldX", "<=", "$", "oldY", ")", "{", "$", "thumbWidth", "=", "$", "oldX", "*", "(", "$", "newWidth", "/", "$", "oldY", ")", ";", "$", "thumbHeight", "=", "$", "newHeight", ";", "}", "}", "//white background", "$", "dstImg", "=", "imagecreatetruecolor", "(", "$", "thumbWidth", ",", "$", "thumbHeight", ")", ";", "$", "bg", "=", "imagecolorallocate", "(", "$", "dstImg", ",", "255", ",", "255", ",", "255", ")", ";", "imagefill", "(", "$", "dstImg", ",", "0", ",", "0", ",", "$", "bg", ")", ";", "//resizing", "imagecopyresampled", "(", "$", "dstImg", ",", "$", "srcImg", ",", "0", ",", "0", ",", "0", ",", "0", ",", "$", "thumbWidth", ",", "$", "thumbHeight", ",", "$", "oldX", ",", "$", "oldY", ")", ";", "$", "srcImg", "=", "imagepng", "(", "$", "dstImg", ",", "$", "filename", ")", ";", "//free memory", "imagedestroy", "(", "$", "dstImg", ")", ";", "}" ]
Create a copy of a resized image according to the parameters. @param string $newWidth the new width @param string $newHeight the new heigth @param string $srcImg the path of the source @param string $filename the path of the copy
[ "Create", "a", "copy", "of", "a", "resized", "image", "according", "to", "the", "parameters", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Library/Utilities/ThumbnailCreator.php#L137-L163
222,144
claroline/CoreBundle
Manager/UserManager.php
UserManager.rename
public function rename(User $user, $username) { $userRole = $this->roleManager->getUserRoleByUser($user); if ($userRole) $this->roleManager->renameUserRole($userRole, $user->getUsername()); $user->setUsername($username); $personalWorkspaceName = $this->translator->trans('personal_workspace', array(), 'platform') . $user->getUsername(); $pws = $user->getPersonalWorkspace(); if ($pws) $this->workspaceManager->rename($pws, $personalWorkspaceName); $this->objectManager->persist($user); $this->objectManager->flush(); }
php
public function rename(User $user, $username) { $userRole = $this->roleManager->getUserRoleByUser($user); if ($userRole) $this->roleManager->renameUserRole($userRole, $user->getUsername()); $user->setUsername($username); $personalWorkspaceName = $this->translator->trans('personal_workspace', array(), 'platform') . $user->getUsername(); $pws = $user->getPersonalWorkspace(); if ($pws) $this->workspaceManager->rename($pws, $personalWorkspaceName); $this->objectManager->persist($user); $this->objectManager->flush(); }
[ "public", "function", "rename", "(", "User", "$", "user", ",", "$", "username", ")", "{", "$", "userRole", "=", "$", "this", "->", "roleManager", "->", "getUserRoleByUser", "(", "$", "user", ")", ";", "if", "(", "$", "userRole", ")", "$", "this", "->", "roleManager", "->", "renameUserRole", "(", "$", "userRole", ",", "$", "user", "->", "getUsername", "(", ")", ")", ";", "$", "user", "->", "setUsername", "(", "$", "username", ")", ";", "$", "personalWorkspaceName", "=", "$", "this", "->", "translator", "->", "trans", "(", "'personal_workspace'", ",", "array", "(", ")", ",", "'platform'", ")", ".", "$", "user", "->", "getUsername", "(", ")", ";", "$", "pws", "=", "$", "user", "->", "getPersonalWorkspace", "(", ")", ";", "if", "(", "$", "pws", ")", "$", "this", "->", "workspaceManager", "->", "rename", "(", "$", "pws", ",", "$", "personalWorkspaceName", ")", ";", "$", "this", "->", "objectManager", "->", "persist", "(", "$", "user", ")", ";", "$", "this", "->", "objectManager", "->", "flush", "(", ")", ";", "}" ]
Rename a user. @param User $user @param $username
[ "Rename", "a", "user", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/UserManager.php#L249-L259
222,145
claroline/CoreBundle
Manager/UserManager.php
UserManager.deleteUser
public function deleteUser(User $user) { /* When the api will identify a user, please uncomment this if ($this->container->get('security.token_storage')->getToken()->getUser()->getId() === $user->getId()) { throw new \Exception('A user cannot delete himself'); }*/ $userRole = $this->roleManager->getUserRoleByUser($user); //soft delete~ $user->setMail('mail#' . $user->getId()); $user->setFirstName('firstname#' . $user->getId()); $user->setLastName('lastname#' . $user->getId()); $user->setPlainPassword(uniqid()); $user->setUsername('username#' . $user->getId()); $user->setPublicUrl('removed#' . $user->getId()); $user->setAdministrativeCode('code#' . $user->getId()); $user->setIsEnabled(false); // keeping the user's workspace with its original code // would prevent creating a user with the same username // todo: workspace deletion should be an option $ws = $user->getPersonalWorkspace(); if ($ws) { $ws->setCode($ws->getCode() . '#deleted_user#' . $user->getId()); $ws->setDisplayable(false); $this->objectManager->persist($ws); } if ($userRole) { $this->objectManager->remove($userRole); } $this->objectManager->persist($user); $this->objectManager->flush(); $this->strictEventDispatcher->dispatch('claroline_users_delete', 'GenericDatas', array(array($user))); $this->strictEventDispatcher->dispatch('log', 'Log\LogUserDelete', array($user)); $this->strictEventDispatcher->dispatch('delete_user', 'DeleteUser', array($user)); }
php
public function deleteUser(User $user) { /* When the api will identify a user, please uncomment this if ($this->container->get('security.token_storage')->getToken()->getUser()->getId() === $user->getId()) { throw new \Exception('A user cannot delete himself'); }*/ $userRole = $this->roleManager->getUserRoleByUser($user); //soft delete~ $user->setMail('mail#' . $user->getId()); $user->setFirstName('firstname#' . $user->getId()); $user->setLastName('lastname#' . $user->getId()); $user->setPlainPassword(uniqid()); $user->setUsername('username#' . $user->getId()); $user->setPublicUrl('removed#' . $user->getId()); $user->setAdministrativeCode('code#' . $user->getId()); $user->setIsEnabled(false); // keeping the user's workspace with its original code // would prevent creating a user with the same username // todo: workspace deletion should be an option $ws = $user->getPersonalWorkspace(); if ($ws) { $ws->setCode($ws->getCode() . '#deleted_user#' . $user->getId()); $ws->setDisplayable(false); $this->objectManager->persist($ws); } if ($userRole) { $this->objectManager->remove($userRole); } $this->objectManager->persist($user); $this->objectManager->flush(); $this->strictEventDispatcher->dispatch('claroline_users_delete', 'GenericDatas', array(array($user))); $this->strictEventDispatcher->dispatch('log', 'Log\LogUserDelete', array($user)); $this->strictEventDispatcher->dispatch('delete_user', 'DeleteUser', array($user)); }
[ "public", "function", "deleteUser", "(", "User", "$", "user", ")", "{", "/* When the api will identify a user, please uncomment this\n if ($this->container->get('security.token_storage')->getToken()->getUser()->getId() === $user->getId()) {\n throw new \\Exception('A user cannot delete himself');\n }*/", "$", "userRole", "=", "$", "this", "->", "roleManager", "->", "getUserRoleByUser", "(", "$", "user", ")", ";", "//soft delete~", "$", "user", "->", "setMail", "(", "'mail#'", ".", "$", "user", "->", "getId", "(", ")", ")", ";", "$", "user", "->", "setFirstName", "(", "'firstname#'", ".", "$", "user", "->", "getId", "(", ")", ")", ";", "$", "user", "->", "setLastName", "(", "'lastname#'", ".", "$", "user", "->", "getId", "(", ")", ")", ";", "$", "user", "->", "setPlainPassword", "(", "uniqid", "(", ")", ")", ";", "$", "user", "->", "setUsername", "(", "'username#'", ".", "$", "user", "->", "getId", "(", ")", ")", ";", "$", "user", "->", "setPublicUrl", "(", "'removed#'", ".", "$", "user", "->", "getId", "(", ")", ")", ";", "$", "user", "->", "setAdministrativeCode", "(", "'code#'", ".", "$", "user", "->", "getId", "(", ")", ")", ";", "$", "user", "->", "setIsEnabled", "(", "false", ")", ";", "// keeping the user's workspace with its original code", "// would prevent creating a user with the same username", "// todo: workspace deletion should be an option", "$", "ws", "=", "$", "user", "->", "getPersonalWorkspace", "(", ")", ";", "if", "(", "$", "ws", ")", "{", "$", "ws", "->", "setCode", "(", "$", "ws", "->", "getCode", "(", ")", ".", "'#deleted_user#'", ".", "$", "user", "->", "getId", "(", ")", ")", ";", "$", "ws", "->", "setDisplayable", "(", "false", ")", ";", "$", "this", "->", "objectManager", "->", "persist", "(", "$", "ws", ")", ";", "}", "if", "(", "$", "userRole", ")", "{", "$", "this", "->", "objectManager", "->", "remove", "(", "$", "userRole", ")", ";", "}", "$", "this", "->", "objectManager", "->", "persist", "(", "$", "user", ")", ";", "$", "this", "->", "objectManager", "->", "flush", "(", ")", ";", "$", "this", "->", "strictEventDispatcher", "->", "dispatch", "(", "'claroline_users_delete'", ",", "'GenericDatas'", ",", "array", "(", "array", "(", "$", "user", ")", ")", ")", ";", "$", "this", "->", "strictEventDispatcher", "->", "dispatch", "(", "'log'", ",", "'Log\\LogUserDelete'", ",", "array", "(", "$", "user", ")", ")", ";", "$", "this", "->", "strictEventDispatcher", "->", "dispatch", "(", "'delete_user'", ",", "'DeleteUser'", ",", "array", "(", "$", "user", ")", ")", ";", "}" ]
Removes a user. @param \Claroline\CoreBundle\Entity\User $user
[ "Removes", "a", "user", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/UserManager.php#L273-L312
222,146
claroline/CoreBundle
Manager/UserManager.php
UserManager.convertUsersToArray
public function convertUsersToArray(array $users) { $content = array(); $i = 0; foreach ($users as $user) { $content[$i]['id'] = $user->getId(); $content[$i]['username'] = $user->getUsername(); $content[$i]['lastname'] = $user->getLastName(); $content[$i]['firstname'] = $user->getFirstName(); $content[$i]['administrativeCode'] = $user->getAdministrativeCode(); $rolesString = ''; $roles = $user->getEntityRoles(); $rolesCount = count($roles); $j = 0; foreach ($roles as $role) { $rolesString .= "{$this->translator->trans($role->getTranslationKey(), array(), 'platform')}"; if ($j < $rolesCount - 1) { $rolesString .= ' ,'; } $j++; } $content[$i]['roles'] = $rolesString; $i++; } return $content; }
php
public function convertUsersToArray(array $users) { $content = array(); $i = 0; foreach ($users as $user) { $content[$i]['id'] = $user->getId(); $content[$i]['username'] = $user->getUsername(); $content[$i]['lastname'] = $user->getLastName(); $content[$i]['firstname'] = $user->getFirstName(); $content[$i]['administrativeCode'] = $user->getAdministrativeCode(); $rolesString = ''; $roles = $user->getEntityRoles(); $rolesCount = count($roles); $j = 0; foreach ($roles as $role) { $rolesString .= "{$this->translator->trans($role->getTranslationKey(), array(), 'platform')}"; if ($j < $rolesCount - 1) { $rolesString .= ' ,'; } $j++; } $content[$i]['roles'] = $rolesString; $i++; } return $content; }
[ "public", "function", "convertUsersToArray", "(", "array", "$", "users", ")", "{", "$", "content", "=", "array", "(", ")", ";", "$", "i", "=", "0", ";", "foreach", "(", "$", "users", "as", "$", "user", ")", "{", "$", "content", "[", "$", "i", "]", "[", "'id'", "]", "=", "$", "user", "->", "getId", "(", ")", ";", "$", "content", "[", "$", "i", "]", "[", "'username'", "]", "=", "$", "user", "->", "getUsername", "(", ")", ";", "$", "content", "[", "$", "i", "]", "[", "'lastname'", "]", "=", "$", "user", "->", "getLastName", "(", ")", ";", "$", "content", "[", "$", "i", "]", "[", "'firstname'", "]", "=", "$", "user", "->", "getFirstName", "(", ")", ";", "$", "content", "[", "$", "i", "]", "[", "'administrativeCode'", "]", "=", "$", "user", "->", "getAdministrativeCode", "(", ")", ";", "$", "rolesString", "=", "''", ";", "$", "roles", "=", "$", "user", "->", "getEntityRoles", "(", ")", ";", "$", "rolesCount", "=", "count", "(", "$", "roles", ")", ";", "$", "j", "=", "0", ";", "foreach", "(", "$", "roles", "as", "$", "role", ")", "{", "$", "rolesString", ".=", "\"{$this->translator->trans($role->getTranslationKey(), array(), 'platform')}\"", ";", "if", "(", "$", "j", "<", "$", "rolesCount", "-", "1", ")", "{", "$", "rolesString", ".=", "' ,'", ";", "}", "$", "j", "++", ";", "}", "$", "content", "[", "$", "i", "]", "[", "'roles'", "]", "=", "$", "rolesString", ";", "$", "i", "++", ";", "}", "return", "$", "content", ";", "}" ]
Serialize a user. Use JMS serializer from entities instead @param array $users @return array @deprecated
[ "Serialize", "a", "user", ".", "Use", "JMS", "serializer", "from", "entities", "instead" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/UserManager.php#L508-L538
222,147
claroline/CoreBundle
Manager/UserManager.php
UserManager.logUser
public function logUser(User $user) { $this->strictEventDispatcher->dispatch('log', 'Log\LogUserLogin', array($user)); $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles()); $this->container->get('security.token_storage')->setToken($token); }
php
public function logUser(User $user) { $this->strictEventDispatcher->dispatch('log', 'Log\LogUserLogin', array($user)); $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles()); $this->container->get('security.token_storage')->setToken($token); }
[ "public", "function", "logUser", "(", "User", "$", "user", ")", "{", "$", "this", "->", "strictEventDispatcher", "->", "dispatch", "(", "'log'", ",", "'Log\\LogUserLogin'", ",", "array", "(", "$", "user", ")", ")", ";", "$", "token", "=", "new", "UsernamePasswordToken", "(", "$", "user", ",", "null", ",", "'main'", ",", "$", "user", "->", "getRoles", "(", ")", ")", ";", "$", "this", "->", "container", "->", "get", "(", "'security.token_storage'", ")", "->", "setToken", "(", "$", "token", ")", ";", "}" ]
Logs the current user
[ "Logs", "the", "current", "user" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/UserManager.php#L1264-L1269
222,148
claroline/CoreBundle
Controller/ResourceRightsController.php
ResourceRightsController.openPermsAction
public function openPermsAction(ResourceNode $node) { $collection = new ResourceCollection(array($node)); $this->checkAccess('ADMINISTRATE', $collection); $this->rightsManager->editPerms(1, $this->roleManager->getRoleByName('ROLE_USER'), $node, false); $this->rightsManager->editPerms(1, $this->roleManager->getRoleByName('ROLE_ANONYMOUS'), $node, false); return new Response('', 204, array('Content-Type' => 'application/json')); }
php
public function openPermsAction(ResourceNode $node) { $collection = new ResourceCollection(array($node)); $this->checkAccess('ADMINISTRATE', $collection); $this->rightsManager->editPerms(1, $this->roleManager->getRoleByName('ROLE_USER'), $node, false); $this->rightsManager->editPerms(1, $this->roleManager->getRoleByName('ROLE_ANONYMOUS'), $node, false); return new Response('', 204, array('Content-Type' => 'application/json')); }
[ "public", "function", "openPermsAction", "(", "ResourceNode", "$", "node", ")", "{", "$", "collection", "=", "new", "ResourceCollection", "(", "array", "(", "$", "node", ")", ")", ";", "$", "this", "->", "checkAccess", "(", "'ADMINISTRATE'", ",", "$", "collection", ")", ";", "$", "this", "->", "rightsManager", "->", "editPerms", "(", "1", ",", "$", "this", "->", "roleManager", "->", "getRoleByName", "(", "'ROLE_USER'", ")", ",", "$", "node", ",", "false", ")", ";", "$", "this", "->", "rightsManager", "->", "editPerms", "(", "1", ",", "$", "this", "->", "roleManager", "->", "getRoleByName", "(", "'ROLE_ANONYMOUS'", ")", ",", "$", "node", ",", "false", ")", ";", "return", "new", "Response", "(", "''", ",", "204", ",", "array", "(", "'Content-Type'", "=>", "'application/json'", ")", ")", ";", "}" ]
Use only when create a new resource @EXT\Route( "/perms/open/{node}", name="claro_resource_open_perms", options={"expose"=true} )
[ "Use", "only", "when", "create", "a", "new", "resource" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Controller/ResourceRightsController.php#L189-L197
222,149
claroline/CoreBundle
Manager/LocaleManager.php
LocaleManager.setUserLocale
public function setUserLocale($locale) { $locales = $this->getAvailableLocales(); $this->userManager->setLocale($this->getCurrentUser(), $locale); }
php
public function setUserLocale($locale) { $locales = $this->getAvailableLocales(); $this->userManager->setLocale($this->getCurrentUser(), $locale); }
[ "public", "function", "setUserLocale", "(", "$", "locale", ")", "{", "$", "locales", "=", "$", "this", "->", "getAvailableLocales", "(", ")", ";", "$", "this", "->", "userManager", "->", "setLocale", "(", "$", "this", "->", "getCurrentUser", "(", ")", ",", "$", "locale", ")", ";", "}" ]
Set locale setting for current user if this locale is present in the platform @param string $locale The locale string as en, fr, es, etc.
[ "Set", "locale", "setting", "for", "current", "user", "if", "this", "locale", "is", "present", "in", "the", "platform" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/LocaleManager.php#L113-L117
222,150
claroline/CoreBundle
Manager/LocaleManager.php
LocaleManager.getUserLocale
public function getUserLocale(Request $request) { $locales = $this->getAvailableLocales(); $preferred = explode('_', $request->getPreferredLanguage()); if ($request->attributes->get('_locale')) { $locale = $request->attributes->get('_locale'); } elseif (($user = $this->getCurrentUser()) && $user->getLocale()) { $locale = $user->getLocale(); } elseif ($request->getSession() && ($sessionLocale = $request->getSession()->get('_locale'))) { $locale = $sessionLocale; } elseif (count($preferred) > 0 && isset($locales[$preferred[0]])) { $locale = $preferred[0]; } else { $locale = $this->defaultLocale; } if ($session = $request->getSession()) { $session->set('_locale', $locale); } return $locale; }
php
public function getUserLocale(Request $request) { $locales = $this->getAvailableLocales(); $preferred = explode('_', $request->getPreferredLanguage()); if ($request->attributes->get('_locale')) { $locale = $request->attributes->get('_locale'); } elseif (($user = $this->getCurrentUser()) && $user->getLocale()) { $locale = $user->getLocale(); } elseif ($request->getSession() && ($sessionLocale = $request->getSession()->get('_locale'))) { $locale = $sessionLocale; } elseif (count($preferred) > 0 && isset($locales[$preferred[0]])) { $locale = $preferred[0]; } else { $locale = $this->defaultLocale; } if ($session = $request->getSession()) { $session->set('_locale', $locale); } return $locale; }
[ "public", "function", "getUserLocale", "(", "Request", "$", "request", ")", "{", "$", "locales", "=", "$", "this", "->", "getAvailableLocales", "(", ")", ";", "$", "preferred", "=", "explode", "(", "'_'", ",", "$", "request", "->", "getPreferredLanguage", "(", ")", ")", ";", "if", "(", "$", "request", "->", "attributes", "->", "get", "(", "'_locale'", ")", ")", "{", "$", "locale", "=", "$", "request", "->", "attributes", "->", "get", "(", "'_locale'", ")", ";", "}", "elseif", "(", "(", "$", "user", "=", "$", "this", "->", "getCurrentUser", "(", ")", ")", "&&", "$", "user", "->", "getLocale", "(", ")", ")", "{", "$", "locale", "=", "$", "user", "->", "getLocale", "(", ")", ";", "}", "elseif", "(", "$", "request", "->", "getSession", "(", ")", "&&", "(", "$", "sessionLocale", "=", "$", "request", "->", "getSession", "(", ")", "->", "get", "(", "'_locale'", ")", ")", ")", "{", "$", "locale", "=", "$", "sessionLocale", ";", "}", "elseif", "(", "count", "(", "$", "preferred", ")", ">", "0", "&&", "isset", "(", "$", "locales", "[", "$", "preferred", "[", "0", "]", "]", ")", ")", "{", "$", "locale", "=", "$", "preferred", "[", "0", "]", ";", "}", "else", "{", "$", "locale", "=", "$", "this", "->", "defaultLocale", ";", "}", "if", "(", "$", "session", "=", "$", "request", "->", "getSession", "(", ")", ")", "{", "$", "session", "->", "set", "(", "'_locale'", ",", "$", "locale", ")", ";", "}", "return", "$", "locale", ";", "}" ]
This method returns the user locale and store it in session, if there is no user this method return default language or the browser language if it is present in translations. @param \Symfony\Component\HttpFoundation\Request $request @return string The locale string as en, fr, es, etc.
[ "This", "method", "returns", "the", "user", "locale", "and", "store", "it", "in", "session", "if", "there", "is", "no", "user", "this", "method", "return", "default", "language", "or", "the", "browser", "language", "if", "it", "is", "present", "in", "translations", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/LocaleManager.php#L126-L148
222,151
claroline/CoreBundle
Listener/ToolListener.php
ToolListener.workspaceParameters
public function workspaceParameters($workspaceId) { $workspace = $this->workspaceManager->getWorkspaceById($workspaceId); $tools = $this->toolManager->getToolByCriterias( array('isConfigurableInWorkspace' => true, 'isDisplayableInWorkspace' => true) ); $canOpenResRights = true; if ($workspace->isPersonal() && !$this->rightsManager->canEditPwsPerm( $this->tokenStorage->getToken() )) { $canOpenResRights = false; } return $this->templating->render( 'ClarolineCoreBundle:Tool\workspace\parameters:parameters.html.twig', array('workspace' => $workspace, 'tools' => $tools, 'canOpenResRights' => $canOpenResRights) ); }
php
public function workspaceParameters($workspaceId) { $workspace = $this->workspaceManager->getWorkspaceById($workspaceId); $tools = $this->toolManager->getToolByCriterias( array('isConfigurableInWorkspace' => true, 'isDisplayableInWorkspace' => true) ); $canOpenResRights = true; if ($workspace->isPersonal() && !$this->rightsManager->canEditPwsPerm( $this->tokenStorage->getToken() )) { $canOpenResRights = false; } return $this->templating->render( 'ClarolineCoreBundle:Tool\workspace\parameters:parameters.html.twig', array('workspace' => $workspace, 'tools' => $tools, 'canOpenResRights' => $canOpenResRights) ); }
[ "public", "function", "workspaceParameters", "(", "$", "workspaceId", ")", "{", "$", "workspace", "=", "$", "this", "->", "workspaceManager", "->", "getWorkspaceById", "(", "$", "workspaceId", ")", ";", "$", "tools", "=", "$", "this", "->", "toolManager", "->", "getToolByCriterias", "(", "array", "(", "'isConfigurableInWorkspace'", "=>", "true", ",", "'isDisplayableInWorkspace'", "=>", "true", ")", ")", ";", "$", "canOpenResRights", "=", "true", ";", "if", "(", "$", "workspace", "->", "isPersonal", "(", ")", "&&", "!", "$", "this", "->", "rightsManager", "->", "canEditPwsPerm", "(", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", ")", ")", "{", "$", "canOpenResRights", "=", "false", ";", "}", "return", "$", "this", "->", "templating", "->", "render", "(", "'ClarolineCoreBundle:Tool\\workspace\\parameters:parameters.html.twig'", ",", "array", "(", "'workspace'", "=>", "$", "workspace", ",", "'tools'", "=>", "$", "tools", ",", "'canOpenResRights'", "=>", "$", "canOpenResRights", ")", ")", ";", "}" ]
Renders the workspace properties page. @param integer $workspaceId @return string
[ "Renders", "the", "workspace", "properties", "page", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Listener/ToolListener.php#L132-L151
222,152
claroline/CoreBundle
Listener/ToolListener.php
ToolListener.desktopParameters
public function desktopParameters() { $desktopTools = $this->toolManager->getToolByCriterias( array('isConfigurableInDesktop' => true, 'isDisplayableInDesktop' => true) ); $tools = array(); foreach ($desktopTools as $desktopTool) { $toolName = $desktopTool->getName(); if ($toolName !== 'home' && $toolName !== 'parameters') { $tools[] = $desktopTool; } } if (count($tools) > 1) { return $this->templating->render( 'ClarolineCoreBundle:Tool\desktop\parameters:parameters.html.twig', array('tools' => $tools) ); } //otherwise only parameters exists so we return the parameters page. $params['_controller'] = 'ClarolineCoreBundle:Tool\DesktopParameters:desktopParametersMenu'; $subRequest = $this->container->get('request')->duplicate( array(), null, $params ); $response = $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST); return $response->getContent(); }
php
public function desktopParameters() { $desktopTools = $this->toolManager->getToolByCriterias( array('isConfigurableInDesktop' => true, 'isDisplayableInDesktop' => true) ); $tools = array(); foreach ($desktopTools as $desktopTool) { $toolName = $desktopTool->getName(); if ($toolName !== 'home' && $toolName !== 'parameters') { $tools[] = $desktopTool; } } if (count($tools) > 1) { return $this->templating->render( 'ClarolineCoreBundle:Tool\desktop\parameters:parameters.html.twig', array('tools' => $tools) ); } //otherwise only parameters exists so we return the parameters page. $params['_controller'] = 'ClarolineCoreBundle:Tool\DesktopParameters:desktopParametersMenu'; $subRequest = $this->container->get('request')->duplicate( array(), null, $params ); $response = $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST); return $response->getContent(); }
[ "public", "function", "desktopParameters", "(", ")", "{", "$", "desktopTools", "=", "$", "this", "->", "toolManager", "->", "getToolByCriterias", "(", "array", "(", "'isConfigurableInDesktop'", "=>", "true", ",", "'isDisplayableInDesktop'", "=>", "true", ")", ")", ";", "$", "tools", "=", "array", "(", ")", ";", "foreach", "(", "$", "desktopTools", "as", "$", "desktopTool", ")", "{", "$", "toolName", "=", "$", "desktopTool", "->", "getName", "(", ")", ";", "if", "(", "$", "toolName", "!==", "'home'", "&&", "$", "toolName", "!==", "'parameters'", ")", "{", "$", "tools", "[", "]", "=", "$", "desktopTool", ";", "}", "}", "if", "(", "count", "(", "$", "tools", ")", ">", "1", ")", "{", "return", "$", "this", "->", "templating", "->", "render", "(", "'ClarolineCoreBundle:Tool\\desktop\\parameters:parameters.html.twig'", ",", "array", "(", "'tools'", "=>", "$", "tools", ")", ")", ";", "}", "//otherwise only parameters exists so we return the parameters page.", "$", "params", "[", "'_controller'", "]", "=", "'ClarolineCoreBundle:Tool\\DesktopParameters:desktopParametersMenu'", ";", "$", "subRequest", "=", "$", "this", "->", "container", "->", "get", "(", "'request'", ")", "->", "duplicate", "(", "array", "(", ")", ",", "null", ",", "$", "params", ")", ";", "$", "response", "=", "$", "this", "->", "httpKernel", "->", "handle", "(", "$", "subRequest", ",", "HttpKernelInterface", "::", "SUB_REQUEST", ")", ";", "return", "$", "response", "->", "getContent", "(", ")", ";", "}" ]
Displays the Info desktop tab. @return \Symfony\Component\HttpFoundation\Response
[ "Displays", "the", "Info", "desktop", "tab", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Listener/ToolListener.php#L158-L191
222,153
TransitScreen/php-heroku-client
src/Client.php
Client.execute
protected function execute($method, $path, $body = null, array $customHeaders = []) { // Clear state from the last call. $this->lastHttpRequest = null; $this->lastHttpResponse = null; // Build the request. $request = $this->buildRequest($method, $path, $body, $customHeaders); // Store the PSR-7 Request object for future examination and use. Redact the API key // so it isn't unwittingly propagated as a result of this feature. $this->lastHttpRequest = $request->withHeader('Authorization', 'Bearer {REDACTED}'); // Make the API call. $response = $this->httpClient->sendRequest($request); // Store the PSR-7 Response object for future examination and use. Heroku uses headers // as a secondary communication channel for range, rate limit, and caching information. $this->lastHttpResponse = $response; return $this->processResponse($response); }
php
protected function execute($method, $path, $body = null, array $customHeaders = []) { // Clear state from the last call. $this->lastHttpRequest = null; $this->lastHttpResponse = null; // Build the request. $request = $this->buildRequest($method, $path, $body, $customHeaders); // Store the PSR-7 Request object for future examination and use. Redact the API key // so it isn't unwittingly propagated as a result of this feature. $this->lastHttpRequest = $request->withHeader('Authorization', 'Bearer {REDACTED}'); // Make the API call. $response = $this->httpClient->sendRequest($request); // Store the PSR-7 Response object for future examination and use. Heroku uses headers // as a secondary communication channel for range, rate limit, and caching information. $this->lastHttpResponse = $response; return $this->processResponse($response); }
[ "protected", "function", "execute", "(", "$", "method", ",", "$", "path", ",", "$", "body", "=", "null", ",", "array", "$", "customHeaders", "=", "[", "]", ")", "{", "// Clear state from the last call.", "$", "this", "->", "lastHttpRequest", "=", "null", ";", "$", "this", "->", "lastHttpResponse", "=", "null", ";", "// Build the request.", "$", "request", "=", "$", "this", "->", "buildRequest", "(", "$", "method", ",", "$", "path", ",", "$", "body", ",", "$", "customHeaders", ")", ";", "// Store the PSR-7 Request object for future examination and use. Redact the API key", "// so it isn't unwittingly propagated as a result of this feature.", "$", "this", "->", "lastHttpRequest", "=", "$", "request", "->", "withHeader", "(", "'Authorization'", ",", "'Bearer {REDACTED}'", ")", ";", "// Make the API call.", "$", "response", "=", "$", "this", "->", "httpClient", "->", "sendRequest", "(", "$", "request", ")", ";", "// Store the PSR-7 Response object for future examination and use. Heroku uses headers", "// as a secondary communication channel for range, rate limit, and caching information.", "$", "this", "->", "lastHttpResponse", "=", "$", "response", ";", "return", "$", "this", "->", "processResponse", "(", "$", "response", ")", ";", "}" ]
Execute a call against the Heroku Platform API. @param string $method The HTTP method: DELETE|GET|HEAD|PATCH|POST @param string $path The API endpoint path @param array|object $body Optional array or object to be sent in the request body as JSON @param array $customHeaders Optional array of headers to be set on the request @return \stdClass JSON-decoded API result
[ "Execute", "a", "call", "against", "the", "Heroku", "Platform", "API", "." ]
49121e2351ded5b9ae00337cbdc865857d269aa5
https://github.com/TransitScreen/php-heroku-client/blob/49121e2351ded5b9ae00337cbdc865857d269aa5/src/Client.php#L157-L178
222,154
TransitScreen/php-heroku-client
src/Client.php
Client.buildRequest
protected function buildRequest($method, $path, $body = null, array $customHeaders = []) { $headers = []; // If a body was included, add it to the request. if (isset($body)) { $headers['Content-Type'] = 'application/json'; $body = json_encode($body); // Check for JSON encoding errors. if (json_last_error() !== JSON_ERROR_NONE) { throw new JsonEncodingException( 'JSON error while encoding Heroku API request: ' . json_last_error_msg() ); } } // Add required headers. $headers['Accept'] = 'application/vnd.heroku+json; version=3'; // Heroku specifies this. $headers['Authorization'] = 'Bearer ' . $this->apiKey; // Incorporate any custom headers, preferring them over our defaults. $headers = $customHeaders + $headers; return new Request($method, $this->baseUrl . $path, $headers, $body); }
php
protected function buildRequest($method, $path, $body = null, array $customHeaders = []) { $headers = []; // If a body was included, add it to the request. if (isset($body)) { $headers['Content-Type'] = 'application/json'; $body = json_encode($body); // Check for JSON encoding errors. if (json_last_error() !== JSON_ERROR_NONE) { throw new JsonEncodingException( 'JSON error while encoding Heroku API request: ' . json_last_error_msg() ); } } // Add required headers. $headers['Accept'] = 'application/vnd.heroku+json; version=3'; // Heroku specifies this. $headers['Authorization'] = 'Bearer ' . $this->apiKey; // Incorporate any custom headers, preferring them over our defaults. $headers = $customHeaders + $headers; return new Request($method, $this->baseUrl . $path, $headers, $body); }
[ "protected", "function", "buildRequest", "(", "$", "method", ",", "$", "path", ",", "$", "body", "=", "null", ",", "array", "$", "customHeaders", "=", "[", "]", ")", "{", "$", "headers", "=", "[", "]", ";", "// If a body was included, add it to the request.", "if", "(", "isset", "(", "$", "body", ")", ")", "{", "$", "headers", "[", "'Content-Type'", "]", "=", "'application/json'", ";", "$", "body", "=", "json_encode", "(", "$", "body", ")", ";", "// Check for JSON encoding errors.", "if", "(", "json_last_error", "(", ")", "!==", "JSON_ERROR_NONE", ")", "{", "throw", "new", "JsonEncodingException", "(", "'JSON error while encoding Heroku API request: '", ".", "json_last_error_msg", "(", ")", ")", ";", "}", "}", "// Add required headers.", "$", "headers", "[", "'Accept'", "]", "=", "'application/vnd.heroku+json; version=3'", ";", "// Heroku specifies this.", "$", "headers", "[", "'Authorization'", "]", "=", "'Bearer '", ".", "$", "this", "->", "apiKey", ";", "// Incorporate any custom headers, preferring them over our defaults.", "$", "headers", "=", "$", "customHeaders", "+", "$", "headers", ";", "return", "new", "Request", "(", "$", "method", ",", "$", "this", "->", "baseUrl", ".", "$", "path", ",", "$", "headers", ",", "$", "body", ")", ";", "}" ]
Build an API request. @see Client::execute() For parameter definitions @return RequestInterface PSR-7 Request object representing the desired interaction @throws JsonEncodingException
[ "Build", "an", "API", "request", "." ]
49121e2351ded5b9ae00337cbdc865857d269aa5
https://github.com/TransitScreen/php-heroku-client/blob/49121e2351ded5b9ae00337cbdc865857d269aa5/src/Client.php#L188-L212
222,155
TransitScreen/php-heroku-client
src/Client.php
Client.processResponse
protected function processResponse(ResponseInterface $httpResponse) { // Attempt to build the API response from the HTTP response body. $apiResponse = json_decode($httpResponse->getBody()->getContents()); $httpResponse->getBody()->rewind(); // Rewind the stream to make future access easier. // Check for API errors. // @see https://devcenter.heroku.com/articles/platform-api-reference#statuses // @see https://devcenter.heroku.com/articles/platform-api-reference#errors if ($httpResponse->getStatusCode() >= 400) { throw new BadHttpStatusException(sprintf( 'Heroku API error: HTTP code %s [%s] %s', $httpResponse->getStatusCode(), empty($apiResponse->id) ? 'no error ID found' : $apiResponse->id, empty($apiResponse->message) ? 'no error message found' : $apiResponse->message )); } // Check for JSON decoding errors. if (json_last_error() !== JSON_ERROR_NONE) { throw new JsonDecodingException( 'JSON error while decoding Heroku API response: ' . json_last_error_msg() ); } return $apiResponse; }
php
protected function processResponse(ResponseInterface $httpResponse) { // Attempt to build the API response from the HTTP response body. $apiResponse = json_decode($httpResponse->getBody()->getContents()); $httpResponse->getBody()->rewind(); // Rewind the stream to make future access easier. // Check for API errors. // @see https://devcenter.heroku.com/articles/platform-api-reference#statuses // @see https://devcenter.heroku.com/articles/platform-api-reference#errors if ($httpResponse->getStatusCode() >= 400) { throw new BadHttpStatusException(sprintf( 'Heroku API error: HTTP code %s [%s] %s', $httpResponse->getStatusCode(), empty($apiResponse->id) ? 'no error ID found' : $apiResponse->id, empty($apiResponse->message) ? 'no error message found' : $apiResponse->message )); } // Check for JSON decoding errors. if (json_last_error() !== JSON_ERROR_NONE) { throw new JsonDecodingException( 'JSON error while decoding Heroku API response: ' . json_last_error_msg() ); } return $apiResponse; }
[ "protected", "function", "processResponse", "(", "ResponseInterface", "$", "httpResponse", ")", "{", "// Attempt to build the API response from the HTTP response body.", "$", "apiResponse", "=", "json_decode", "(", "$", "httpResponse", "->", "getBody", "(", ")", "->", "getContents", "(", ")", ")", ";", "$", "httpResponse", "->", "getBody", "(", ")", "->", "rewind", "(", ")", ";", "// Rewind the stream to make future access easier.", "// Check for API errors.", "// @see https://devcenter.heroku.com/articles/platform-api-reference#statuses", "// @see https://devcenter.heroku.com/articles/platform-api-reference#errors", "if", "(", "$", "httpResponse", "->", "getStatusCode", "(", ")", ">=", "400", ")", "{", "throw", "new", "BadHttpStatusException", "(", "sprintf", "(", "'Heroku API error: HTTP code %s [%s] %s'", ",", "$", "httpResponse", "->", "getStatusCode", "(", ")", ",", "empty", "(", "$", "apiResponse", "->", "id", ")", "?", "'no error ID found'", ":", "$", "apiResponse", "->", "id", ",", "empty", "(", "$", "apiResponse", "->", "message", ")", "?", "'no error message found'", ":", "$", "apiResponse", "->", "message", ")", ")", ";", "}", "// Check for JSON decoding errors.", "if", "(", "json_last_error", "(", ")", "!==", "JSON_ERROR_NONE", ")", "{", "throw", "new", "JsonDecodingException", "(", "'JSON error while decoding Heroku API response: '", ".", "json_last_error_msg", "(", ")", ")", ";", "}", "return", "$", "apiResponse", ";", "}" ]
Build the final return object from the raw HTTP response. @see https://devcenter.heroku.com/articles/platform-api-reference#statuses @see https://devcenter.heroku.com/articles/platform-api-reference#errors @param ResponseInterface $httpResponse Heroku API response as a PSR-7 Response object @return \stdClass JSON-decoded API result @throws BadHttpStatusException @throws JsonDecodingException
[ "Build", "the", "final", "return", "object", "from", "the", "raw", "HTTP", "response", "." ]
49121e2351ded5b9ae00337cbdc865857d269aa5
https://github.com/TransitScreen/php-heroku-client/blob/49121e2351ded5b9ae00337cbdc865857d269aa5/src/Client.php#L226-L252
222,156
claroline/CoreBundle
Library/Security/Voter/UserVoter.php
UserVoter.isOrganizationManager
private function isOrganizationManager(TokenInterface $token, User $user) { $adminOrganizations = $token->getUser()->getAdministratedOrganizations(); $userOrganizations = $user->getOrganizations(); foreach ($adminOrganizations as $adminOrganization) { foreach ($userOrganizations as $userOrganization) { if ($userOrganization === $adminOrganization) return true; } } return false; }
php
private function isOrganizationManager(TokenInterface $token, User $user) { $adminOrganizations = $token->getUser()->getAdministratedOrganizations(); $userOrganizations = $user->getOrganizations(); foreach ($adminOrganizations as $adminOrganization) { foreach ($userOrganizations as $userOrganization) { if ($userOrganization === $adminOrganization) return true; } } return false; }
[ "private", "function", "isOrganizationManager", "(", "TokenInterface", "$", "token", ",", "User", "$", "user", ")", "{", "$", "adminOrganizations", "=", "$", "token", "->", "getUser", "(", ")", "->", "getAdministratedOrganizations", "(", ")", ";", "$", "userOrganizations", "=", "$", "user", "->", "getOrganizations", "(", ")", ";", "foreach", "(", "$", "adminOrganizations", "as", "$", "adminOrganization", ")", "{", "foreach", "(", "$", "userOrganizations", "as", "$", "userOrganization", ")", "{", "if", "(", "$", "userOrganization", "===", "$", "adminOrganization", ")", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
I should find a way to speed that up
[ "I", "should", "find", "a", "way", "to", "speed", "that", "up" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Library/Security/Voter/UserVoter.php#L111-L123
222,157
claroline/CoreBundle
DataFixtures/Required/Data/LoadWidgetData.php
LoadWidgetData.load
public function load(ObjectManager $manager) { $roles = $manager->getRepository('ClarolineCoreBundle:Role') ->findAllPlatformRoles(); //name, isConfigurable, isDisplayableInDesktop, isDisplayableInWorkspace $items = array( array('core_resource_logger', true, true, true), array('simple_text', true, true, true), array('my_workspaces', false, true, false), array('my_profile', false, true, false), ); foreach ($items as $item) { $widget = new Widget(); $widget->setName($item[0]); $widget->setConfigurable($item[1]); $widget->setPlugin(null); $widget->setExportable(false); $widget->setDisplayableInDesktop($item[2]); $widget->setDisplayableInWorkspace($item[3]); foreach ($roles as $role) { $widget->addRole($role); } $manager->persist($widget); } }
php
public function load(ObjectManager $manager) { $roles = $manager->getRepository('ClarolineCoreBundle:Role') ->findAllPlatformRoles(); //name, isConfigurable, isDisplayableInDesktop, isDisplayableInWorkspace $items = array( array('core_resource_logger', true, true, true), array('simple_text', true, true, true), array('my_workspaces', false, true, false), array('my_profile', false, true, false), ); foreach ($items as $item) { $widget = new Widget(); $widget->setName($item[0]); $widget->setConfigurable($item[1]); $widget->setPlugin(null); $widget->setExportable(false); $widget->setDisplayableInDesktop($item[2]); $widget->setDisplayableInWorkspace($item[3]); foreach ($roles as $role) { $widget->addRole($role); } $manager->persist($widget); } }
[ "public", "function", "load", "(", "ObjectManager", "$", "manager", ")", "{", "$", "roles", "=", "$", "manager", "->", "getRepository", "(", "'ClarolineCoreBundle:Role'", ")", "->", "findAllPlatformRoles", "(", ")", ";", "//name, isConfigurable, isDisplayableInDesktop, isDisplayableInWorkspace", "$", "items", "=", "array", "(", "array", "(", "'core_resource_logger'", ",", "true", ",", "true", ",", "true", ")", ",", "array", "(", "'simple_text'", ",", "true", ",", "true", ",", "true", ")", ",", "array", "(", "'my_workspaces'", ",", "false", ",", "true", ",", "false", ")", ",", "array", "(", "'my_profile'", ",", "false", ",", "true", ",", "false", ")", ",", ")", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "$", "widget", "=", "new", "Widget", "(", ")", ";", "$", "widget", "->", "setName", "(", "$", "item", "[", "0", "]", ")", ";", "$", "widget", "->", "setConfigurable", "(", "$", "item", "[", "1", "]", ")", ";", "$", "widget", "->", "setPlugin", "(", "null", ")", ";", "$", "widget", "->", "setExportable", "(", "false", ")", ";", "$", "widget", "->", "setDisplayableInDesktop", "(", "$", "item", "[", "2", "]", ")", ";", "$", "widget", "->", "setDisplayableInWorkspace", "(", "$", "item", "[", "3", "]", ")", ";", "foreach", "(", "$", "roles", "as", "$", "role", ")", "{", "$", "widget", "->", "addRole", "(", "$", "role", ")", ";", "}", "$", "manager", "->", "persist", "(", "$", "widget", ")", ";", "}", "}" ]
Loads the core widgets. @param ObjectManager $manager
[ "Loads", "the", "core", "widgets", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/DataFixtures/Required/Data/LoadWidgetData.php#L28-L55
222,158
claroline/CoreBundle
Manager/AuthenticationManager.php
AuthenticationManager.getDrivers
public function getDrivers() { $drivers = array(); $files = $this->finder->files()->in($this->driverPath)->name($this->fileTypes); foreach ($files as $file) { $driver = str_replace('.yml', '', $file->getRelativePathname()); $service = $this->getService($driver); if ($service and $servers = $service->getServers()) { foreach ($servers as $server) { $drivers[$driver . ':' . $server] = $driver . ':' . $server; } } } return $drivers; }
php
public function getDrivers() { $drivers = array(); $files = $this->finder->files()->in($this->driverPath)->name($this->fileTypes); foreach ($files as $file) { $driver = str_replace('.yml', '', $file->getRelativePathname()); $service = $this->getService($driver); if ($service and $servers = $service->getServers()) { foreach ($servers as $server) { $drivers[$driver . ':' . $server] = $driver . ':' . $server; } } } return $drivers; }
[ "public", "function", "getDrivers", "(", ")", "{", "$", "drivers", "=", "array", "(", ")", ";", "$", "files", "=", "$", "this", "->", "finder", "->", "files", "(", ")", "->", "in", "(", "$", "this", "->", "driverPath", ")", "->", "name", "(", "$", "this", "->", "fileTypes", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "driver", "=", "str_replace", "(", "'.yml'", ",", "''", ",", "$", "file", "->", "getRelativePathname", "(", ")", ")", ";", "$", "service", "=", "$", "this", "->", "getService", "(", "$", "driver", ")", ";", "if", "(", "$", "service", "and", "$", "servers", "=", "$", "service", "->", "getServers", "(", ")", ")", "{", "foreach", "(", "$", "servers", "as", "$", "server", ")", "{", "$", "drivers", "[", "$", "driver", ".", "':'", ".", "$", "server", "]", "=", "$", "driver", ".", "':'", ".", "$", "server", ";", "}", "}", "}", "return", "$", "drivers", ";", "}" ]
Get authentication drivers
[ "Get", "authentication", "drivers" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/AuthenticationManager.php#L45-L63
222,159
claroline/CoreBundle
Manager/AuthenticationManager.php
AuthenticationManager.getService
public function getService($driver) { if ($driver = explode(':', $driver) and isset($driver[0]) and $driver = explode('.', $driver[0]) and isset($driver[1]) ) { return $this->container->get($driver[0] . '.' . $driver[1] . '_bundle.manager.' . $driver[1] . '_manager'); } }
php
public function getService($driver) { if ($driver = explode(':', $driver) and isset($driver[0]) and $driver = explode('.', $driver[0]) and isset($driver[1]) ) { return $this->container->get($driver[0] . '.' . $driver[1] . '_bundle.manager.' . $driver[1] . '_manager'); } }
[ "public", "function", "getService", "(", "$", "driver", ")", "{", "if", "(", "$", "driver", "=", "explode", "(", "':'", ",", "$", "driver", ")", "and", "isset", "(", "$", "driver", "[", "0", "]", ")", "and", "$", "driver", "=", "explode", "(", "'.'", ",", "$", "driver", "[", "0", "]", ")", "and", "isset", "(", "$", "driver", "[", "1", "]", ")", ")", "{", "return", "$", "this", "->", "container", "->", "get", "(", "$", "driver", "[", "0", "]", ".", "'.'", ".", "$", "driver", "[", "1", "]", ".", "'_bundle.manager.'", ".", "$", "driver", "[", "1", "]", ".", "'_manager'", ")", ";", "}", "}" ]
Return authentication driver manager @param $driver The name of the driver including the server, example: claroline.ldap:server1
[ "Return", "authentication", "driver", "manager" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/AuthenticationManager.php#L91-L100
222,160
claroline/CoreBundle
Entity/AbstractRoleSubject.php
AbstractRoleSubject.getRoles
public function getRoles() { if (count($this->rolesStringAsArray) > 0) { return $this->rolesStringAsArray; } $roleNames = array(); foreach ($this->getEntityRoles(true) as $role) { $roleNames[] = $role->getName(); } return $roleNames; }
php
public function getRoles() { if (count($this->rolesStringAsArray) > 0) { return $this->rolesStringAsArray; } $roleNames = array(); foreach ($this->getEntityRoles(true) as $role) { $roleNames[] = $role->getName(); } return $roleNames; }
[ "public", "function", "getRoles", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "rolesStringAsArray", ")", ">", "0", ")", "{", "return", "$", "this", "->", "rolesStringAsArray", ";", "}", "$", "roleNames", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getEntityRoles", "(", "true", ")", "as", "$", "role", ")", "{", "$", "roleNames", "[", "]", "=", "$", "role", "->", "getName", "(", ")", ";", "}", "return", "$", "roleNames", ";", "}" ]
Returns the subject roles as an array of sting values
[ "Returns", "the", "subject", "roles", "as", "an", "array", "of", "sting", "values" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Entity/AbstractRoleSubject.php#L80-L93
222,161
claroline/CoreBundle
Controller/AuthenticationController.php
AuthenticationController.renderExternalAuthenticatonButtonAction
public function renderExternalAuthenticatonButtonAction() { $event = $this->dispatcher->dispatch('render_external_authentication_button', 'RenderAuthenticationButton'); $eventContent = $event->getContent(); if (!empty($eventContent)) { $eventContent = '<div class="external_authentication"><hr>' . $eventContent . '</div>'; } return new Response($eventContent); }
php
public function renderExternalAuthenticatonButtonAction() { $event = $this->dispatcher->dispatch('render_external_authentication_button', 'RenderAuthenticationButton'); $eventContent = $event->getContent(); if (!empty($eventContent)) { $eventContent = '<div class="external_authentication"><hr>' . $eventContent . '</div>'; } return new Response($eventContent); }
[ "public", "function", "renderExternalAuthenticatonButtonAction", "(", ")", "{", "$", "event", "=", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "'render_external_authentication_button'", ",", "'RenderAuthenticationButton'", ")", ";", "$", "eventContent", "=", "$", "event", "->", "getContent", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "eventContent", ")", ")", "{", "$", "eventContent", "=", "'<div class=\"external_authentication\"><hr>'", ".", "$", "eventContent", ".", "'</div>'", ";", "}", "return", "new", "Response", "(", "$", "eventContent", ")", ";", "}" ]
not routed...
[ "not", "routed", "..." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Controller/AuthenticationController.php#L370-L380
222,162
claroline/CoreBundle
Controller/WorkspaceController.php
WorkspaceController.createAction
public function createAction() { $this->assertIsGranted('ROLE_WS_CREATOR'); $user = $this->tokenStorage->getToken()->getUser(); $form = $this->formFactory->create(FormFactory::TYPE_WORKSPACE, array($user)); $form->handleRequest($this->request); $ds = DIRECTORY_SEPARATOR; $modelLog = $this->container->getParameter('kernel.root_dir') . '/logs/models.log'; $logger = FileLogger::get($modelLog); $this->workspaceManager->setLogger($logger); if ($form->isValid()) { $model = $form->get('model')->getData(); if (!is_null($model)) { $this->createWorkspaceFromModel($model, $form); } else { $config = Configuration::fromTemplate( $this->templateDir . $ds . 'default.zip' ); $config->setWorkspaceName($form->get('name')->getData()); $config->setWorkspaceCode($form->get('code')->getData()); $config->setDisplayable($form->get('displayable')->getData()); $config->setSelfRegistration($form->get('selfRegistration')->getData()); $config->setRegistrationValidation($form->get('registrationValidation')->getData()); $config->setSelfUnregistration($form->get('selfUnregistration')->getData()); $config->setWorkspaceDescription($form->get('description')->getData()); $user = $this->tokenStorage->getToken()->getUser(); $this->workspaceManager->create($config, $user); } $this->tokenUpdater->update($this->tokenStorage->getToken()); $route = $this->router->generate('claro_workspace_by_user'); $msg = $this->get('translator')->trans( 'successfull_workspace_creation', array('%name%' => $form->get('name')->getData()), 'platform' ); $this->get('request')->getSession()->getFlashBag()->add('success', $msg); return new RedirectResponse($route); } return array('form' => $form->createView()); }
php
public function createAction() { $this->assertIsGranted('ROLE_WS_CREATOR'); $user = $this->tokenStorage->getToken()->getUser(); $form = $this->formFactory->create(FormFactory::TYPE_WORKSPACE, array($user)); $form->handleRequest($this->request); $ds = DIRECTORY_SEPARATOR; $modelLog = $this->container->getParameter('kernel.root_dir') . '/logs/models.log'; $logger = FileLogger::get($modelLog); $this->workspaceManager->setLogger($logger); if ($form->isValid()) { $model = $form->get('model')->getData(); if (!is_null($model)) { $this->createWorkspaceFromModel($model, $form); } else { $config = Configuration::fromTemplate( $this->templateDir . $ds . 'default.zip' ); $config->setWorkspaceName($form->get('name')->getData()); $config->setWorkspaceCode($form->get('code')->getData()); $config->setDisplayable($form->get('displayable')->getData()); $config->setSelfRegistration($form->get('selfRegistration')->getData()); $config->setRegistrationValidation($form->get('registrationValidation')->getData()); $config->setSelfUnregistration($form->get('selfUnregistration')->getData()); $config->setWorkspaceDescription($form->get('description')->getData()); $user = $this->tokenStorage->getToken()->getUser(); $this->workspaceManager->create($config, $user); } $this->tokenUpdater->update($this->tokenStorage->getToken()); $route = $this->router->generate('claro_workspace_by_user'); $msg = $this->get('translator')->trans( 'successfull_workspace_creation', array('%name%' => $form->get('name')->getData()), 'platform' ); $this->get('request')->getSession()->getFlashBag()->add('success', $msg); return new RedirectResponse($route); } return array('form' => $form->createView()); }
[ "public", "function", "createAction", "(", ")", "{", "$", "this", "->", "assertIsGranted", "(", "'ROLE_WS_CREATOR'", ")", ";", "$", "user", "=", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ";", "$", "form", "=", "$", "this", "->", "formFactory", "->", "create", "(", "FormFactory", "::", "TYPE_WORKSPACE", ",", "array", "(", "$", "user", ")", ")", ";", "$", "form", "->", "handleRequest", "(", "$", "this", "->", "request", ")", ";", "$", "ds", "=", "DIRECTORY_SEPARATOR", ";", "$", "modelLog", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'kernel.root_dir'", ")", ".", "'/logs/models.log'", ";", "$", "logger", "=", "FileLogger", "::", "get", "(", "$", "modelLog", ")", ";", "$", "this", "->", "workspaceManager", "->", "setLogger", "(", "$", "logger", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "model", "=", "$", "form", "->", "get", "(", "'model'", ")", "->", "getData", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "model", ")", ")", "{", "$", "this", "->", "createWorkspaceFromModel", "(", "$", "model", ",", "$", "form", ")", ";", "}", "else", "{", "$", "config", "=", "Configuration", "::", "fromTemplate", "(", "$", "this", "->", "templateDir", ".", "$", "ds", ".", "'default.zip'", ")", ";", "$", "config", "->", "setWorkspaceName", "(", "$", "form", "->", "get", "(", "'name'", ")", "->", "getData", "(", ")", ")", ";", "$", "config", "->", "setWorkspaceCode", "(", "$", "form", "->", "get", "(", "'code'", ")", "->", "getData", "(", ")", ")", ";", "$", "config", "->", "setDisplayable", "(", "$", "form", "->", "get", "(", "'displayable'", ")", "->", "getData", "(", ")", ")", ";", "$", "config", "->", "setSelfRegistration", "(", "$", "form", "->", "get", "(", "'selfRegistration'", ")", "->", "getData", "(", ")", ")", ";", "$", "config", "->", "setRegistrationValidation", "(", "$", "form", "->", "get", "(", "'registrationValidation'", ")", "->", "getData", "(", ")", ")", ";", "$", "config", "->", "setSelfUnregistration", "(", "$", "form", "->", "get", "(", "'selfUnregistration'", ")", "->", "getData", "(", ")", ")", ";", "$", "config", "->", "setWorkspaceDescription", "(", "$", "form", "->", "get", "(", "'description'", ")", "->", "getData", "(", ")", ")", ";", "$", "user", "=", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ";", "$", "this", "->", "workspaceManager", "->", "create", "(", "$", "config", ",", "$", "user", ")", ";", "}", "$", "this", "->", "tokenUpdater", "->", "update", "(", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", ")", ";", "$", "route", "=", "$", "this", "->", "router", "->", "generate", "(", "'claro_workspace_by_user'", ")", ";", "$", "msg", "=", "$", "this", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "'successfull_workspace_creation'", ",", "array", "(", "'%name%'", "=>", "$", "form", "->", "get", "(", "'name'", ")", "->", "getData", "(", ")", ")", ",", "'platform'", ")", ";", "$", "this", "->", "get", "(", "'request'", ")", "->", "getSession", "(", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "$", "msg", ")", ";", "return", "new", "RedirectResponse", "(", "$", "route", ")", ";", "}", "return", "array", "(", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ")", ";", "}" ]
Creates a workspace from a form sent by POST. @EXT\Route( "/", name="claro_workspace_create" ) @EXT\Method("POST") @EXT\Template("ClarolineCoreBundle:Workspace:creationForm.html.twig") @return RedirectResponse | array
[ "Creates", "a", "workspace", "from", "a", "form", "sent", "by", "POST", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Controller/WorkspaceController.php#L345-L390
222,163
claroline/CoreBundle
Library/Transfert/RichTextFormatter.php
RichTextFormatter.setPlaceHolders
public function setPlaceHolders(array $files, &$_data) { $formattedFiles = []; foreach ($files as $key => $file) { $ext = pathinfo($file, PATHINFO_EXTENSION); $newFile = $file; if ($ext === 'txt') { $text = $this->setPlaceHolder($file, $_data, $formattedFiles); $newFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid() . 'txt'; file_put_contents($newFile, $text); } $formattedFiles[$key] = $newFile; } return $formattedFiles; }
php
public function setPlaceHolders(array $files, &$_data) { $formattedFiles = []; foreach ($files as $key => $file) { $ext = pathinfo($file, PATHINFO_EXTENSION); $newFile = $file; if ($ext === 'txt') { $text = $this->setPlaceHolder($file, $_data, $formattedFiles); $newFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid() . 'txt'; file_put_contents($newFile, $text); } $formattedFiles[$key] = $newFile; } return $formattedFiles; }
[ "public", "function", "setPlaceHolders", "(", "array", "$", "files", ",", "&", "$", "_data", ")", "{", "$", "formattedFiles", "=", "[", "]", ";", "foreach", "(", "$", "files", "as", "$", "key", "=>", "$", "file", ")", "{", "$", "ext", "=", "pathinfo", "(", "$", "file", ",", "PATHINFO_EXTENSION", ")", ";", "$", "newFile", "=", "$", "file", ";", "if", "(", "$", "ext", "===", "'txt'", ")", "{", "$", "text", "=", "$", "this", "->", "setPlaceHolder", "(", "$", "file", ",", "$", "_data", ",", "$", "formattedFiles", ")", ";", "$", "newFile", "=", "sys_get_temp_dir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "uniqid", "(", ")", ".", "'txt'", ";", "file_put_contents", "(", "$", "newFile", ",", "$", "text", ")", ";", "}", "$", "formattedFiles", "[", "$", "key", "]", "=", "$", "newFile", ";", "}", "return", "$", "formattedFiles", ";", "}" ]
For now we only look parse .txt. in the archive. It's way easier that way. @param $_data @param $files @return array
[ "For", "now", "we", "only", "look", "parse", ".", "txt", ".", "in", "the", "archive", ".", "It", "s", "way", "easier", "that", "way", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Library/Transfert/RichTextFormatter.php#L128-L146
222,164
claroline/CoreBundle
Library/Transfert/RichTextFormatter.php
RichTextFormatter.setPlaceHolder
private function setPlaceHolder($file, &$_data, &$_files) { //urls to be matched... //'/file/resource/media/([^']+)#' //'/resource/open/([^/]+)/([^']+)' $text = file_get_contents($file); $baseUrl = $this->router->getContext()->getBaseUrl(); //first regex $regex = '#' . $baseUrl . '/file/resource/media/([^\'"]+)#'; preg_match_all($regex, $text, $matches, PREG_SET_ORDER); if (count($matches) > 0) { foreach ($matches as $match) { if (!$this->getItemFromUid($match[1], $_data)) { $this->createDataFolder($_data); $node = $this->resourceManager->getNode($match[1]); if ($node && $node->getResourceType()->getName() === 'file') { $el = $this->getImporterByName('resource_manager')->getResourceElement( $node, $node->getWorkspace(), $_files, $_data, true ); $el['item']['parent'] = 'data_folder'; $el['item']['roles'] = array(array('role' => array( 'name' => 'ROLE_USER', 'rights' => $this->maskManager->decodeMask(7, $this->resourceManager->getResourceTypeByName('file')) ))); $_data['data']['items'][] = $el; } } $text = $this->replaceLink($text, $match[0], $match[1], $_data); } } //second regex $regex = '#' . $baseUrl . '/resource/open/([^/]+)/([^\'"]+)#'; preg_match_all($regex, $text, $matches, PREG_SET_ORDER); if (count($matches) > 0) { foreach ($matches as $match) { $text = $this->replaceLink($text, $match[0], $match[2]); } } $event = $this->eventDispatcher->dispatch('rich_text_format_event_export', 'RichTextFormat', array($text, $_data, $_files)); $text = $event->getText(); return $text; }
php
private function setPlaceHolder($file, &$_data, &$_files) { //urls to be matched... //'/file/resource/media/([^']+)#' //'/resource/open/([^/]+)/([^']+)' $text = file_get_contents($file); $baseUrl = $this->router->getContext()->getBaseUrl(); //first regex $regex = '#' . $baseUrl . '/file/resource/media/([^\'"]+)#'; preg_match_all($regex, $text, $matches, PREG_SET_ORDER); if (count($matches) > 0) { foreach ($matches as $match) { if (!$this->getItemFromUid($match[1], $_data)) { $this->createDataFolder($_data); $node = $this->resourceManager->getNode($match[1]); if ($node && $node->getResourceType()->getName() === 'file') { $el = $this->getImporterByName('resource_manager')->getResourceElement( $node, $node->getWorkspace(), $_files, $_data, true ); $el['item']['parent'] = 'data_folder'; $el['item']['roles'] = array(array('role' => array( 'name' => 'ROLE_USER', 'rights' => $this->maskManager->decodeMask(7, $this->resourceManager->getResourceTypeByName('file')) ))); $_data['data']['items'][] = $el; } } $text = $this->replaceLink($text, $match[0], $match[1], $_data); } } //second regex $regex = '#' . $baseUrl . '/resource/open/([^/]+)/([^\'"]+)#'; preg_match_all($regex, $text, $matches, PREG_SET_ORDER); if (count($matches) > 0) { foreach ($matches as $match) { $text = $this->replaceLink($text, $match[0], $match[2]); } } $event = $this->eventDispatcher->dispatch('rich_text_format_event_export', 'RichTextFormat', array($text, $_data, $_files)); $text = $event->getText(); return $text; }
[ "private", "function", "setPlaceHolder", "(", "$", "file", ",", "&", "$", "_data", ",", "&", "$", "_files", ")", "{", "//urls to be matched...", "//'/file/resource/media/([^']+)#'", "//'/resource/open/([^/]+)/([^']+)'", "$", "text", "=", "file_get_contents", "(", "$", "file", ")", ";", "$", "baseUrl", "=", "$", "this", "->", "router", "->", "getContext", "(", ")", "->", "getBaseUrl", "(", ")", ";", "//first regex", "$", "regex", "=", "'#'", ".", "$", "baseUrl", ".", "'/file/resource/media/([^\\'\"]+)#'", ";", "preg_match_all", "(", "$", "regex", ",", "$", "text", ",", "$", "matches", ",", "PREG_SET_ORDER", ")", ";", "if", "(", "count", "(", "$", "matches", ")", ">", "0", ")", "{", "foreach", "(", "$", "matches", "as", "$", "match", ")", "{", "if", "(", "!", "$", "this", "->", "getItemFromUid", "(", "$", "match", "[", "1", "]", ",", "$", "_data", ")", ")", "{", "$", "this", "->", "createDataFolder", "(", "$", "_data", ")", ";", "$", "node", "=", "$", "this", "->", "resourceManager", "->", "getNode", "(", "$", "match", "[", "1", "]", ")", ";", "if", "(", "$", "node", "&&", "$", "node", "->", "getResourceType", "(", ")", "->", "getName", "(", ")", "===", "'file'", ")", "{", "$", "el", "=", "$", "this", "->", "getImporterByName", "(", "'resource_manager'", ")", "->", "getResourceElement", "(", "$", "node", ",", "$", "node", "->", "getWorkspace", "(", ")", ",", "$", "_files", ",", "$", "_data", ",", "true", ")", ";", "$", "el", "[", "'item'", "]", "[", "'parent'", "]", "=", "'data_folder'", ";", "$", "el", "[", "'item'", "]", "[", "'roles'", "]", "=", "array", "(", "array", "(", "'role'", "=>", "array", "(", "'name'", "=>", "'ROLE_USER'", ",", "'rights'", "=>", "$", "this", "->", "maskManager", "->", "decodeMask", "(", "7", ",", "$", "this", "->", "resourceManager", "->", "getResourceTypeByName", "(", "'file'", ")", ")", ")", ")", ")", ";", "$", "_data", "[", "'data'", "]", "[", "'items'", "]", "[", "]", "=", "$", "el", ";", "}", "}", "$", "text", "=", "$", "this", "->", "replaceLink", "(", "$", "text", ",", "$", "match", "[", "0", "]", ",", "$", "match", "[", "1", "]", ",", "$", "_data", ")", ";", "}", "}", "//second regex", "$", "regex", "=", "'#'", ".", "$", "baseUrl", ".", "'/resource/open/([^/]+)/([^\\'\"]+)#'", ";", "preg_match_all", "(", "$", "regex", ",", "$", "text", ",", "$", "matches", ",", "PREG_SET_ORDER", ")", ";", "if", "(", "count", "(", "$", "matches", ")", ">", "0", ")", "{", "foreach", "(", "$", "matches", "as", "$", "match", ")", "{", "$", "text", "=", "$", "this", "->", "replaceLink", "(", "$", "text", ",", "$", "match", "[", "0", "]", ",", "$", "match", "[", "2", "]", ")", ";", "}", "}", "$", "event", "=", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "'rich_text_format_event_export'", ",", "'RichTextFormat'", ",", "array", "(", "$", "text", ",", "$", "_data", ",", "$", "_files", ")", ")", ";", "$", "text", "=", "$", "event", "->", "getText", "(", ")", ";", "return", "$", "text", ";", "}" ]
If we find an resource id wich is a file and not in the export yet, then we export is aswell. It's a link towards "something else".
[ "If", "we", "find", "an", "resource", "id", "wich", "is", "a", "file", "and", "not", "in", "the", "export", "yet", "then", "we", "export", "is", "aswell", ".", "It", "s", "a", "link", "towards", "something", "else", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Library/Transfert/RichTextFormatter.php#L152-L207
222,165
claroline/CoreBundle
Manager/GroupManager.php
GroupManager.removeAllUsersFromGroup
public function removeAllUsersFromGroup(Group $group) { $users = $group->getUsers(); foreach ($users as $user) { $group->removeUser($user); } $this->om->persist($group); $this->om->flush(); }
php
public function removeAllUsersFromGroup(Group $group) { $users = $group->getUsers(); foreach ($users as $user) { $group->removeUser($user); } $this->om->persist($group); $this->om->flush(); }
[ "public", "function", "removeAllUsersFromGroup", "(", "Group", "$", "group", ")", "{", "$", "users", "=", "$", "group", "->", "getUsers", "(", ")", ";", "foreach", "(", "$", "users", "as", "$", "user", ")", "{", "$", "group", "->", "removeUser", "(", "$", "user", ")", ";", "}", "$", "this", "->", "om", "->", "persist", "(", "$", "group", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}" ]
Removes all users from a group. @param \Claroline\CoreBundle\Entity\Group $group
[ "Removes", "all", "users", "from", "a", "group", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/GroupManager.php#L167-L177
222,166
claroline/CoreBundle
Manager/GroupManager.php
GroupManager.removeUsersFromGroup
public function removeUsersFromGroup(Group $group, array $users) { foreach ($users as $user) { $group->removeUser($user); $this->eventDispatcher->dispatch('log', 'Log\LogGroupRemoveUser', array($group, $user)); } $this->om->persist($group); $this->om->flush(); }
php
public function removeUsersFromGroup(Group $group, array $users) { foreach ($users as $user) { $group->removeUser($user); $this->eventDispatcher->dispatch('log', 'Log\LogGroupRemoveUser', array($group, $user)); } $this->om->persist($group); $this->om->flush(); }
[ "public", "function", "removeUsersFromGroup", "(", "Group", "$", "group", ",", "array", "$", "users", ")", "{", "foreach", "(", "$", "users", "as", "$", "user", ")", "{", "$", "group", "->", "removeUser", "(", "$", "user", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "'log'", ",", "'Log\\LogGroupRemoveUser'", ",", "array", "(", "$", "group", ",", "$", "user", ")", ")", ";", "}", "$", "this", "->", "om", "->", "persist", "(", "$", "group", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}" ]
Removes an array of user from a group. @param \Claroline\CoreBundle\Entity\Group $group @param User[] $users
[ "Removes", "an", "array", "of", "user", "from", "a", "group", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/GroupManager.php#L185-L194
222,167
claroline/CoreBundle
Manager/GroupManager.php
GroupManager.convertGroupsToArray
public function convertGroupsToArray(array $groups) { $content = array(); $i = 0; foreach ($groups as $group) { $content[$i]['id'] = $group->getId(); $content[$i]['name'] = $group->getName(); $rolesString = ''; $roles = $group->getEntityRoles(); $rolesCount = count($roles); $j = 0; foreach ($roles as $role) { $rolesString .= "{$this->translator->trans($role->getTranslationKey(), array(), 'platform')}"; if ($j < $rolesCount - 1) { $rolesString .= ' ,'; } $j++; } $content[$i]['roles'] = $rolesString; $i++; } return $content; }
php
public function convertGroupsToArray(array $groups) { $content = array(); $i = 0; foreach ($groups as $group) { $content[$i]['id'] = $group->getId(); $content[$i]['name'] = $group->getName(); $rolesString = ''; $roles = $group->getEntityRoles(); $rolesCount = count($roles); $j = 0; foreach ($roles as $role) { $rolesString .= "{$this->translator->trans($role->getTranslationKey(), array(), 'platform')}"; if ($j < $rolesCount - 1) { $rolesString .= ' ,'; } $j++; } $content[$i]['roles'] = $rolesString; $i++; } return $content; }
[ "public", "function", "convertGroupsToArray", "(", "array", "$", "groups", ")", "{", "$", "content", "=", "array", "(", ")", ";", "$", "i", "=", "0", ";", "foreach", "(", "$", "groups", "as", "$", "group", ")", "{", "$", "content", "[", "$", "i", "]", "[", "'id'", "]", "=", "$", "group", "->", "getId", "(", ")", ";", "$", "content", "[", "$", "i", "]", "[", "'name'", "]", "=", "$", "group", "->", "getName", "(", ")", ";", "$", "rolesString", "=", "''", ";", "$", "roles", "=", "$", "group", "->", "getEntityRoles", "(", ")", ";", "$", "rolesCount", "=", "count", "(", "$", "roles", ")", ";", "$", "j", "=", "0", ";", "foreach", "(", "$", "roles", "as", "$", "role", ")", "{", "$", "rolesString", ".=", "\"{$this->translator->trans($role->getTranslationKey(), array(), 'platform')}\"", ";", "if", "(", "$", "j", "<", "$", "rolesCount", "-", "1", ")", "{", "$", "rolesString", ".=", "' ,'", ";", "}", "$", "j", "++", ";", "}", "$", "content", "[", "$", "i", "]", "[", "'roles'", "]", "=", "$", "rolesString", ";", "$", "i", "++", ";", "}", "return", "$", "content", ";", "}" ]
Serialize a group array. @param Group[] $groups @return array
[ "Serialize", "a", "group", "array", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/GroupManager.php#L507-L529
222,168
claroline/CoreBundle
Manager/TransfertManager.php
TransfertManager.validate
public function validate(array $data, $validateProperties = true) { $groupsImporter = $this->getImporterByName('groups'); $rolesImporter = $this->getImporterByName('roles'); $toolsImporter = $this->getImporterByName('tools'); $importer = $this->getImporterByName('workspace_properties'); $usersImporter = $this->getImporterByName('user'); //properties if ($validateProperties) { if (isset($data['properties'])) { $properties['properties'] = $data['properties']; $importer->validate($properties); } } if (isset($data['roles'])) { $roles['roles'] = $data['roles']; $rolesImporter->validate($roles); } if (isset ($data['tools'])) { $tools['tools'] = $data['tools']; $toolsImporter->validate($tools); } }
php
public function validate(array $data, $validateProperties = true) { $groupsImporter = $this->getImporterByName('groups'); $rolesImporter = $this->getImporterByName('roles'); $toolsImporter = $this->getImporterByName('tools'); $importer = $this->getImporterByName('workspace_properties'); $usersImporter = $this->getImporterByName('user'); //properties if ($validateProperties) { if (isset($data['properties'])) { $properties['properties'] = $data['properties']; $importer->validate($properties); } } if (isset($data['roles'])) { $roles['roles'] = $data['roles']; $rolesImporter->validate($roles); } if (isset ($data['tools'])) { $tools['tools'] = $data['tools']; $toolsImporter->validate($tools); } }
[ "public", "function", "validate", "(", "array", "$", "data", ",", "$", "validateProperties", "=", "true", ")", "{", "$", "groupsImporter", "=", "$", "this", "->", "getImporterByName", "(", "'groups'", ")", ";", "$", "rolesImporter", "=", "$", "this", "->", "getImporterByName", "(", "'roles'", ")", ";", "$", "toolsImporter", "=", "$", "this", "->", "getImporterByName", "(", "'tools'", ")", ";", "$", "importer", "=", "$", "this", "->", "getImporterByName", "(", "'workspace_properties'", ")", ";", "$", "usersImporter", "=", "$", "this", "->", "getImporterByName", "(", "'user'", ")", ";", "//properties", "if", "(", "$", "validateProperties", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "'properties'", "]", ")", ")", "{", "$", "properties", "[", "'properties'", "]", "=", "$", "data", "[", "'properties'", "]", ";", "$", "importer", "->", "validate", "(", "$", "properties", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "data", "[", "'roles'", "]", ")", ")", "{", "$", "roles", "[", "'roles'", "]", "=", "$", "data", "[", "'roles'", "]", ";", "$", "rolesImporter", "->", "validate", "(", "$", "roles", ")", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "'tools'", "]", ")", ")", "{", "$", "tools", "[", "'tools'", "]", "=", "$", "data", "[", "'tools'", "]", ";", "$", "toolsImporter", "->", "validate", "(", "$", "tools", ")", ";", "}", "}" ]
Import a workspace
[ "Import", "a", "workspace" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/TransfertManager.php#L71-L97
222,169
claroline/CoreBundle
Manager/TransfertManager.php
TransfertManager.populateWorkspace
public function populateWorkspace( Workspace $workspace, Configuration $configuration, Directory $root, array $entityRoles, $isValidated = false, $importRoles = true ) { $this->om->startFlushSuite(); $data = $configuration->getData(); $data = $this->reorderData($data); //now we need to reorder the data because well... //refactor how workspace are created because this sucks $this->data = $configuration->getData(); $this->workspace = $workspace; $this->setImporters($configuration, $data); $this->setWorkspaceForImporter($workspace); if (!$isValidated) { $this->validate($data, false); } if ($importRoles) { $importedRoles = $this->getImporterByName('roles')->import($data['roles'], $workspace); $this->om->forceFlush(); } foreach ($entityRoles as $key => $entityRole) { $importedRoles[$key] = $entityRole; } $this->log('Importing tools...'); $tools = $this->getImporterByName('tools')->import($data['tools'], $workspace, $importedRoles, $root); $this->om->endFlushSuite(); }
php
public function populateWorkspace( Workspace $workspace, Configuration $configuration, Directory $root, array $entityRoles, $isValidated = false, $importRoles = true ) { $this->om->startFlushSuite(); $data = $configuration->getData(); $data = $this->reorderData($data); //now we need to reorder the data because well... //refactor how workspace are created because this sucks $this->data = $configuration->getData(); $this->workspace = $workspace; $this->setImporters($configuration, $data); $this->setWorkspaceForImporter($workspace); if (!$isValidated) { $this->validate($data, false); } if ($importRoles) { $importedRoles = $this->getImporterByName('roles')->import($data['roles'], $workspace); $this->om->forceFlush(); } foreach ($entityRoles as $key => $entityRole) { $importedRoles[$key] = $entityRole; } $this->log('Importing tools...'); $tools = $this->getImporterByName('tools')->import($data['tools'], $workspace, $importedRoles, $root); $this->om->endFlushSuite(); }
[ "public", "function", "populateWorkspace", "(", "Workspace", "$", "workspace", ",", "Configuration", "$", "configuration", ",", "Directory", "$", "root", ",", "array", "$", "entityRoles", ",", "$", "isValidated", "=", "false", ",", "$", "importRoles", "=", "true", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "data", "=", "$", "configuration", "->", "getData", "(", ")", ";", "$", "data", "=", "$", "this", "->", "reorderData", "(", "$", "data", ")", ";", "//now we need to reorder the data because well...", "//refactor how workspace are created because this sucks", "$", "this", "->", "data", "=", "$", "configuration", "->", "getData", "(", ")", ";", "$", "this", "->", "workspace", "=", "$", "workspace", ";", "$", "this", "->", "setImporters", "(", "$", "configuration", ",", "$", "data", ")", ";", "$", "this", "->", "setWorkspaceForImporter", "(", "$", "workspace", ")", ";", "if", "(", "!", "$", "isValidated", ")", "{", "$", "this", "->", "validate", "(", "$", "data", ",", "false", ")", ";", "}", "if", "(", "$", "importRoles", ")", "{", "$", "importedRoles", "=", "$", "this", "->", "getImporterByName", "(", "'roles'", ")", "->", "import", "(", "$", "data", "[", "'roles'", "]", ",", "$", "workspace", ")", ";", "$", "this", "->", "om", "->", "forceFlush", "(", ")", ";", "}", "foreach", "(", "$", "entityRoles", "as", "$", "key", "=>", "$", "entityRole", ")", "{", "$", "importedRoles", "[", "$", "key", "]", "=", "$", "entityRole", ";", "}", "$", "this", "->", "log", "(", "'Importing tools...'", ")", ";", "$", "tools", "=", "$", "this", "->", "getImporterByName", "(", "'tools'", ")", "->", "import", "(", "$", "data", "[", "'tools'", "]", ",", "$", "workspace", ",", "$", "importedRoles", ",", "$", "root", ")", ";", "$", "this", "->", "om", "->", "endFlushSuite", "(", ")", ";", "}" ]
Populates a workspace content with the content of an zip archive. In other words, it ignores the many properties of the configuration object and use an existing workspace as base. This will set the $this->data var This will set the $this->workspace var @param Workspace $workspace @param Confuguration $configuration @param Directory $root @param array $entityRoles @param bool $isValidated @param bool $importRoles
[ "Populates", "a", "workspace", "content", "with", "the", "content", "of", "an", "zip", "archive", ".", "In", "other", "words", "it", "ignores", "the", "many", "properties", "of", "the", "configuration", "object", "and", "use", "an", "existing", "workspace", "as", "base", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/TransfertManager.php#L130-L166
222,170
claroline/CoreBundle
Manager/TransfertManager.php
TransfertManager.importRichText
public function importRichText() { $this->log('Parsing rich texts...'); //now we have to parse everything in case there is a rich text //rich texts must be located in the tools section $data = $this->data; //@todo remove the line for claroline v6 $this->container->get('claroline.importer.rich_text_formatter')->setData($data); $this->container->get('claroline.importer.rich_text_formatter')->setWorkspace($this->workspace); foreach ($data['tools'] as $tool) { $importer = $this->getImporterByName($tool['tool']['type']); if (isset($tool['tool']['data']) && $importer instanceof RichTextInterface) { $data['data'] = $tool['tool']['data']; $importer->format($data); } } $this->om->flush(); }
php
public function importRichText() { $this->log('Parsing rich texts...'); //now we have to parse everything in case there is a rich text //rich texts must be located in the tools section $data = $this->data; //@todo remove the line for claroline v6 $this->container->get('claroline.importer.rich_text_formatter')->setData($data); $this->container->get('claroline.importer.rich_text_formatter')->setWorkspace($this->workspace); foreach ($data['tools'] as $tool) { $importer = $this->getImporterByName($tool['tool']['type']); if (isset($tool['tool']['data']) && $importer instanceof RichTextInterface) { $data['data'] = $tool['tool']['data']; $importer->format($data); } } $this->om->flush(); }
[ "public", "function", "importRichText", "(", ")", "{", "$", "this", "->", "log", "(", "'Parsing rich texts...'", ")", ";", "//now we have to parse everything in case there is a rich text", "//rich texts must be located in the tools section", "$", "data", "=", "$", "this", "->", "data", ";", "//@todo remove the line for claroline v6", "$", "this", "->", "container", "->", "get", "(", "'claroline.importer.rich_text_formatter'", ")", "->", "setData", "(", "$", "data", ")", ";", "$", "this", "->", "container", "->", "get", "(", "'claroline.importer.rich_text_formatter'", ")", "->", "setWorkspace", "(", "$", "this", "->", "workspace", ")", ";", "foreach", "(", "$", "data", "[", "'tools'", "]", "as", "$", "tool", ")", "{", "$", "importer", "=", "$", "this", "->", "getImporterByName", "(", "$", "tool", "[", "'tool'", "]", "[", "'type'", "]", ")", ";", "if", "(", "isset", "(", "$", "tool", "[", "'tool'", "]", "[", "'data'", "]", ")", "&&", "$", "importer", "instanceof", "RichTextInterface", ")", "{", "$", "data", "[", "'data'", "]", "=", "$", "tool", "[", "'tool'", "]", "[", "'data'", "]", ";", "$", "importer", "->", "format", "(", "$", "data", ")", ";", "}", "}", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}" ]
refactor how workspace are created because this sucks
[ "refactor", "how", "workspace", "are", "created", "because", "this", "sucks" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/TransfertManager.php#L277-L297
222,171
claroline/CoreBundle
Manager/TransfertManager.php
TransfertManager.export
public function export(Workspace $workspace) { foreach ($this->listImporters as $importer) { $importer->setListImporters($this->listImporters); } $data = []; $files = []; $data['roles'] = $this->getImporterByName('roles')->export($workspace, $files, null); $data['tools'] = $this->getImporterByName('tools')->export($workspace, $files, null); $_resManagerData = array(); foreach ($data['tools'] as &$_tool) { if ($_tool['tool']['type'] === 'resource_manager') { $_resManagerData = &$_tool['tool']; } } //then we parse and replace the text, we also add missing files in $resManagerData $files = $this->container->get('claroline.importer.rich_text_formatter') ->setPlaceHolders($files, $_resManagerData); //throw new \Exception(); //generate the archive in a temp dir $content = Yaml::dump($data, 10); //zip and returns the archive $archDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid(); $archPath = $archDir . DIRECTORY_SEPARATOR . 'archive.zip'; mkdir($archDir); $manifestPath = $archDir . DIRECTORY_SEPARATOR . 'manifest.yml'; file_put_contents($manifestPath, $content); $archive = new \ZipArchive(); $success = $archive->open($archPath, \ZipArchive::CREATE); if ($success === true) { $archive->addFile($manifestPath, 'manifest.yml'); foreach ($files as $uid => $file) { $archive->addFile($file, $uid); } $archive->close(); } else { throw new \Exception('Unable to create archive . ' . $archPath . ' (error ' . $success . ')'); } return $archPath; }
php
public function export(Workspace $workspace) { foreach ($this->listImporters as $importer) { $importer->setListImporters($this->listImporters); } $data = []; $files = []; $data['roles'] = $this->getImporterByName('roles')->export($workspace, $files, null); $data['tools'] = $this->getImporterByName('tools')->export($workspace, $files, null); $_resManagerData = array(); foreach ($data['tools'] as &$_tool) { if ($_tool['tool']['type'] === 'resource_manager') { $_resManagerData = &$_tool['tool']; } } //then we parse and replace the text, we also add missing files in $resManagerData $files = $this->container->get('claroline.importer.rich_text_formatter') ->setPlaceHolders($files, $_resManagerData); //throw new \Exception(); //generate the archive in a temp dir $content = Yaml::dump($data, 10); //zip and returns the archive $archDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid(); $archPath = $archDir . DIRECTORY_SEPARATOR . 'archive.zip'; mkdir($archDir); $manifestPath = $archDir . DIRECTORY_SEPARATOR . 'manifest.yml'; file_put_contents($manifestPath, $content); $archive = new \ZipArchive(); $success = $archive->open($archPath, \ZipArchive::CREATE); if ($success === true) { $archive->addFile($manifestPath, 'manifest.yml'); foreach ($files as $uid => $file) { $archive->addFile($file, $uid); } $archive->close(); } else { throw new \Exception('Unable to create archive . ' . $archPath . ' (error ' . $success . ')'); } return $archPath; }
[ "public", "function", "export", "(", "Workspace", "$", "workspace", ")", "{", "foreach", "(", "$", "this", "->", "listImporters", "as", "$", "importer", ")", "{", "$", "importer", "->", "setListImporters", "(", "$", "this", "->", "listImporters", ")", ";", "}", "$", "data", "=", "[", "]", ";", "$", "files", "=", "[", "]", ";", "$", "data", "[", "'roles'", "]", "=", "$", "this", "->", "getImporterByName", "(", "'roles'", ")", "->", "export", "(", "$", "workspace", ",", "$", "files", ",", "null", ")", ";", "$", "data", "[", "'tools'", "]", "=", "$", "this", "->", "getImporterByName", "(", "'tools'", ")", "->", "export", "(", "$", "workspace", ",", "$", "files", ",", "null", ")", ";", "$", "_resManagerData", "=", "array", "(", ")", ";", "foreach", "(", "$", "data", "[", "'tools'", "]", "as", "&", "$", "_tool", ")", "{", "if", "(", "$", "_tool", "[", "'tool'", "]", "[", "'type'", "]", "===", "'resource_manager'", ")", "{", "$", "_resManagerData", "=", "&", "$", "_tool", "[", "'tool'", "]", ";", "}", "}", "//then we parse and replace the text, we also add missing files in $resManagerData", "$", "files", "=", "$", "this", "->", "container", "->", "get", "(", "'claroline.importer.rich_text_formatter'", ")", "->", "setPlaceHolders", "(", "$", "files", ",", "$", "_resManagerData", ")", ";", "//throw new \\Exception();", "//generate the archive in a temp dir", "$", "content", "=", "Yaml", "::", "dump", "(", "$", "data", ",", "10", ")", ";", "//zip and returns the archive", "$", "archDir", "=", "sys_get_temp_dir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "uniqid", "(", ")", ";", "$", "archPath", "=", "$", "archDir", ".", "DIRECTORY_SEPARATOR", ".", "'archive.zip'", ";", "mkdir", "(", "$", "archDir", ")", ";", "$", "manifestPath", "=", "$", "archDir", ".", "DIRECTORY_SEPARATOR", ".", "'manifest.yml'", ";", "file_put_contents", "(", "$", "manifestPath", ",", "$", "content", ")", ";", "$", "archive", "=", "new", "\\", "ZipArchive", "(", ")", ";", "$", "success", "=", "$", "archive", "->", "open", "(", "$", "archPath", ",", "\\", "ZipArchive", "::", "CREATE", ")", ";", "if", "(", "$", "success", "===", "true", ")", "{", "$", "archive", "->", "addFile", "(", "$", "manifestPath", ",", "'manifest.yml'", ")", ";", "foreach", "(", "$", "files", "as", "$", "uid", "=>", "$", "file", ")", "{", "$", "archive", "->", "addFile", "(", "$", "file", ",", "$", "uid", ")", ";", "}", "$", "archive", "->", "close", "(", ")", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Unable to create archive . '", ".", "$", "archPath", ".", "' (error '", ".", "$", "success", ".", "')'", ")", ";", "}", "return", "$", "archPath", ";", "}" ]
Full workspace export
[ "Full", "workspace", "export" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/TransfertManager.php#L318-L364
222,172
claroline/CoreBundle
Manager/TransfertManager.php
TransfertManager.setImporters
private function setImporters(Configuration $configuration, array $data) { foreach ($this->listImporters as $importer) { $importer->setRootPath($configuration->getExtractPath()); if ($owner = $configuration->getOwner()) { $importer->setOwner($owner); } else { $importer->setOwner($this->container->get('security.token_storage')->getToken()->getUser()); } $importer->setConfiguration($data); $importer->setListImporters($this->listImporters); if ($this->logger) $importer->setLogger($this->logger); } }
php
private function setImporters(Configuration $configuration, array $data) { foreach ($this->listImporters as $importer) { $importer->setRootPath($configuration->getExtractPath()); if ($owner = $configuration->getOwner()) { $importer->setOwner($owner); } else { $importer->setOwner($this->container->get('security.token_storage')->getToken()->getUser()); } $importer->setConfiguration($data); $importer->setListImporters($this->listImporters); if ($this->logger) $importer->setLogger($this->logger); } }
[ "private", "function", "setImporters", "(", "Configuration", "$", "configuration", ",", "array", "$", "data", ")", "{", "foreach", "(", "$", "this", "->", "listImporters", "as", "$", "importer", ")", "{", "$", "importer", "->", "setRootPath", "(", "$", "configuration", "->", "getExtractPath", "(", ")", ")", ";", "if", "(", "$", "owner", "=", "$", "configuration", "->", "getOwner", "(", ")", ")", "{", "$", "importer", "->", "setOwner", "(", "$", "owner", ")", ";", "}", "else", "{", "$", "importer", "->", "setOwner", "(", "$", "this", "->", "container", "->", "get", "(", "'security.token_storage'", ")", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ")", ";", "}", "$", "importer", "->", "setConfiguration", "(", "$", "data", ")", ";", "$", "importer", "->", "setListImporters", "(", "$", "this", "->", "listImporters", ")", ";", "if", "(", "$", "this", "->", "logger", ")", "$", "importer", "->", "setLogger", "(", "$", "this", "->", "logger", ")", ";", "}", "}" ]
Inject the rootPath @param \Claroline\CoreBundle\Library\Workspace\Configuration $configuration @param array $data @param $isStrict
[ "Inject", "the", "rootPath" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Manager/TransfertManager.php#L431-L445
222,173
claroline/CoreBundle
Library/Installation/Plugin/DatabaseWriter.php
DatabaseWriter.insert
public function insert(PluginBundle $pluginBundle, array $pluginConfiguration) { $pluginEntity = new Plugin(); $pluginEntity->setVendorName($pluginBundle->getVendorName()); $pluginEntity->setBundleName($pluginBundle->getBundleName()); $pluginEntity->setHasOptions($pluginConfiguration['has_options']); $this->em->persist($pluginEntity); $this->persistConfiguration($pluginConfiguration, $pluginEntity, $pluginBundle); $this->em->flush(); }
php
public function insert(PluginBundle $pluginBundle, array $pluginConfiguration) { $pluginEntity = new Plugin(); $pluginEntity->setVendorName($pluginBundle->getVendorName()); $pluginEntity->setBundleName($pluginBundle->getBundleName()); $pluginEntity->setHasOptions($pluginConfiguration['has_options']); $this->em->persist($pluginEntity); $this->persistConfiguration($pluginConfiguration, $pluginEntity, $pluginBundle); $this->em->flush(); }
[ "public", "function", "insert", "(", "PluginBundle", "$", "pluginBundle", ",", "array", "$", "pluginConfiguration", ")", "{", "$", "pluginEntity", "=", "new", "Plugin", "(", ")", ";", "$", "pluginEntity", "->", "setVendorName", "(", "$", "pluginBundle", "->", "getVendorName", "(", ")", ")", ";", "$", "pluginEntity", "->", "setBundleName", "(", "$", "pluginBundle", "->", "getBundleName", "(", ")", ")", ";", "$", "pluginEntity", "->", "setHasOptions", "(", "$", "pluginConfiguration", "[", "'has_options'", "]", ")", ";", "$", "this", "->", "em", "->", "persist", "(", "$", "pluginEntity", ")", ";", "$", "this", "->", "persistConfiguration", "(", "$", "pluginConfiguration", ",", "$", "pluginEntity", ",", "$", "pluginBundle", ")", ";", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "}" ]
Persists a plugin in the database. @param PluginBundle $pluginBundle @param array $pluginConfiguration
[ "Persists", "a", "plugin", "in", "the", "database", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Library/Installation/Plugin/DatabaseWriter.php#L97-L107
222,174
claroline/CoreBundle
Library/Security/Utilities.php
Utilities.addMissingRights
private function addMissingRights(array $permissions, $target) { $expectedKeys = $target === 'resource' ? $this->expectedKeysForResource : $this->expectedKeysForWorkspace; foreach ($expectedKeys as $expected) { if (!isset($permissions[$expected])) { $permissions[$expected] = false; } } return $permissions; }
php
private function addMissingRights(array $permissions, $target) { $expectedKeys = $target === 'resource' ? $this->expectedKeysForResource : $this->expectedKeysForWorkspace; foreach ($expectedKeys as $expected) { if (!isset($permissions[$expected])) { $permissions[$expected] = false; } } return $permissions; }
[ "private", "function", "addMissingRights", "(", "array", "$", "permissions", ",", "$", "target", ")", "{", "$", "expectedKeys", "=", "$", "target", "===", "'resource'", "?", "$", "this", "->", "expectedKeysForResource", ":", "$", "this", "->", "expectedKeysForWorkspace", ";", "foreach", "(", "$", "expectedKeys", "as", "$", "expected", ")", "{", "if", "(", "!", "isset", "(", "$", "permissions", "[", "$", "expected", "]", ")", ")", "{", "$", "permissions", "[", "$", "expected", "]", "=", "false", ";", "}", "}", "return", "$", "permissions", ";", "}" ]
Adds the missing permissions to an array of permissions, setting missing ones to false. @param array $permissions The array of permissions @param string $target The target of the right ('resource' or 'workspace') @return array
[ "Adds", "the", "missing", "permissions", "to", "an", "array", "of", "permissions", "setting", "missing", "ones", "to", "false", "." ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Library/Security/Utilities.php#L112-L125
222,175
claroline/CoreBundle
Repository/WorkspaceTagRepository.php
WorkspaceTagRepository.findAdminChildrenFromTags
public function findAdminChildrenFromTags(array $tags) { if (count($tags) === 0) { throw new \InvalidArgumentException('Array argument cannot be empty'); } $index = 0; $eol = PHP_EOL; $tagsTest = '('; foreach ($tags as $tag) { $tagsTest .= $index > 0 ? ' OR ' : ' '; $tagsTest .= "p.id = {$tag}{$eol}"; $index++; } $tagsTest .= "){$eol}"; $dql = " SELECT DISTINCT t FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTag t WHERE t.user IS NULL AND EXISTS ( SELECT h FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTagHierarchy h JOIN h.parent p WHERE h.user IS NULL AND h.tag = t AND {$tagsTest} ) ORDER BY t.name "; $query = $this->_em->createQuery($dql); return $query->getResult(); }
php
public function findAdminChildrenFromTags(array $tags) { if (count($tags) === 0) { throw new \InvalidArgumentException('Array argument cannot be empty'); } $index = 0; $eol = PHP_EOL; $tagsTest = '('; foreach ($tags as $tag) { $tagsTest .= $index > 0 ? ' OR ' : ' '; $tagsTest .= "p.id = {$tag}{$eol}"; $index++; } $tagsTest .= "){$eol}"; $dql = " SELECT DISTINCT t FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTag t WHERE t.user IS NULL AND EXISTS ( SELECT h FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTagHierarchy h JOIN h.parent p WHERE h.user IS NULL AND h.tag = t AND {$tagsTest} ) ORDER BY t.name "; $query = $this->_em->createQuery($dql); return $query->getResult(); }
[ "public", "function", "findAdminChildrenFromTags", "(", "array", "$", "tags", ")", "{", "if", "(", "count", "(", "$", "tags", ")", "===", "0", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Array argument cannot be empty'", ")", ";", "}", "$", "index", "=", "0", ";", "$", "eol", "=", "PHP_EOL", ";", "$", "tagsTest", "=", "'('", ";", "foreach", "(", "$", "tags", "as", "$", "tag", ")", "{", "$", "tagsTest", ".=", "$", "index", ">", "0", "?", "' OR '", ":", "' '", ";", "$", "tagsTest", ".=", "\"p.id = {$tag}{$eol}\"", ";", "$", "index", "++", ";", "}", "$", "tagsTest", ".=", "\"){$eol}\"", ";", "$", "dql", "=", "\"\n SELECT DISTINCT t\n FROM Claroline\\CoreBundle\\Entity\\Workspace\\WorkspaceTag t\n WHERE t.user IS NULL\n AND EXISTS (\n SELECT h\n FROM Claroline\\CoreBundle\\Entity\\Workspace\\WorkspaceTagHierarchy h\n JOIN h.parent p\n WHERE h.user IS NULL\n AND h.tag = t\n AND {$tagsTest}\n )\n ORDER BY t.name\n \"", ";", "$", "query", "=", "$", "this", "->", "_em", "->", "createQuery", "(", "$", "dql", ")", ";", "return", "$", "query", "->", "getResult", "(", ")", ";", "}" ]
Find all admin tags that are children of given tags id Given admin tags are included
[ "Find", "all", "admin", "tags", "that", "are", "children", "of", "given", "tags", "id", "Given", "admin", "tags", "are", "included" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/WorkspaceTagRepository.php#L307-L341
222,176
claroline/CoreBundle
Repository/WorkspaceTagRepository.php
WorkspaceTagRepository.findChildrenFromTags
public function findChildrenFromTags(User $user, array $tags) { if (count($tags) === 0) { throw new \InvalidArgumentException('Array argument cannot be empty'); } $index = 0; $eol = PHP_EOL; $tagsTest = '('; foreach ($tags as $tag) { $tagsTest .= $index > 0 ? ' OR ' : ' '; $tagsTest .= "p.id = {$tag}{$eol}"; $index++; } $tagsTest .= "){$eol}"; $dql = " SELECT DISTINCT t FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTag t WHERE t.user = :user AND EXISTS ( SELECT h FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTagHierarchy h JOIN h.parent p WHERE h.user = :user AND h.tag = t AND {$tagsTest} ) ORDER BY t.name "; $query = $this->_em->createQuery($dql); $query->setParameter('user', $user); return $query->getResult(); }
php
public function findChildrenFromTags(User $user, array $tags) { if (count($tags) === 0) { throw new \InvalidArgumentException('Array argument cannot be empty'); } $index = 0; $eol = PHP_EOL; $tagsTest = '('; foreach ($tags as $tag) { $tagsTest .= $index > 0 ? ' OR ' : ' '; $tagsTest .= "p.id = {$tag}{$eol}"; $index++; } $tagsTest .= "){$eol}"; $dql = " SELECT DISTINCT t FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTag t WHERE t.user = :user AND EXISTS ( SELECT h FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTagHierarchy h JOIN h.parent p WHERE h.user = :user AND h.tag = t AND {$tagsTest} ) ORDER BY t.name "; $query = $this->_em->createQuery($dql); $query->setParameter('user', $user); return $query->getResult(); }
[ "public", "function", "findChildrenFromTags", "(", "User", "$", "user", ",", "array", "$", "tags", ")", "{", "if", "(", "count", "(", "$", "tags", ")", "===", "0", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Array argument cannot be empty'", ")", ";", "}", "$", "index", "=", "0", ";", "$", "eol", "=", "PHP_EOL", ";", "$", "tagsTest", "=", "'('", ";", "foreach", "(", "$", "tags", "as", "$", "tag", ")", "{", "$", "tagsTest", ".=", "$", "index", ">", "0", "?", "' OR '", ":", "' '", ";", "$", "tagsTest", ".=", "\"p.id = {$tag}{$eol}\"", ";", "$", "index", "++", ";", "}", "$", "tagsTest", ".=", "\"){$eol}\"", ";", "$", "dql", "=", "\"\n SELECT DISTINCT t\n FROM Claroline\\CoreBundle\\Entity\\Workspace\\WorkspaceTag t\n WHERE t.user = :user\n AND EXISTS (\n SELECT h\n FROM Claroline\\CoreBundle\\Entity\\Workspace\\WorkspaceTagHierarchy h\n JOIN h.parent p\n WHERE h.user = :user\n AND h.tag = t\n AND {$tagsTest}\n )\n ORDER BY t.name\n \"", ";", "$", "query", "=", "$", "this", "->", "_em", "->", "createQuery", "(", "$", "dql", ")", ";", "$", "query", "->", "setParameter", "(", "'user'", ",", "$", "user", ")", ";", "return", "$", "query", "->", "getResult", "(", ")", ";", "}" ]
Find all tags that are children of given tags id Given tags are included
[ "Find", "all", "tags", "that", "are", "children", "of", "given", "tags", "id", "Given", "tags", "are", "included" ]
dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3
https://github.com/claroline/CoreBundle/blob/dec7daea24ec201cd54bfc0d5dd7c7160bbbdef3/Repository/WorkspaceTagRepository.php#L373-L408
222,177
thedevsaddam/laravel-schema
src/Schema/BaseSchema.php
BaseSchema.getPaginatedData
public function getPaginatedData($tableName, $page = 1, $limit = 10, $orderAttribute = null, $order = 'ASC') { Paginator::currentPageResolver(function () use ($page) { return $page; }); $data = $this->database->table($tableName); if (null === $orderAttribute) { return $data->paginate($limit)->toArray(); } return $data->orderBy($orderAttribute, $order)->paginate($limit)->toArray(); }
php
public function getPaginatedData($tableName, $page = 1, $limit = 10, $orderAttribute = null, $order = 'ASC') { Paginator::currentPageResolver(function () use ($page) { return $page; }); $data = $this->database->table($tableName); if (null === $orderAttribute) { return $data->paginate($limit)->toArray(); } return $data->orderBy($orderAttribute, $order)->paginate($limit)->toArray(); }
[ "public", "function", "getPaginatedData", "(", "$", "tableName", ",", "$", "page", "=", "1", ",", "$", "limit", "=", "10", ",", "$", "orderAttribute", "=", "null", ",", "$", "order", "=", "'ASC'", ")", "{", "Paginator", "::", "currentPageResolver", "(", "function", "(", ")", "use", "(", "$", "page", ")", "{", "return", "$", "page", ";", "}", ")", ";", "$", "data", "=", "$", "this", "->", "database", "->", "table", "(", "$", "tableName", ")", ";", "if", "(", "null", "===", "$", "orderAttribute", ")", "{", "return", "$", "data", "->", "paginate", "(", "$", "limit", ")", "->", "toArray", "(", ")", ";", "}", "return", "$", "data", "->", "orderBy", "(", "$", "orderAttribute", ",", "$", "order", ")", "->", "paginate", "(", "$", "limit", ")", "->", "toArray", "(", ")", ";", "}" ]
Fetch data form table using pagination @param $tableName @param int $page @param int $limit @param null $orderAttribute @param string $order @return mixed
[ "Fetch", "data", "form", "table", "using", "pagination" ]
ce787b3b5d6f558cd5fb615f373beabb1939e724
https://github.com/thedevsaddam/laravel-schema/blob/ce787b3b5d6f558cd5fb615f373beabb1939e724/src/Schema/BaseSchema.php#L86-L96
222,178
yii2mod/yii2-cron-log
components/ErrorHandler.php
ErrorHandler.logException
public function logException($exception) { $category = get_class($exception); if ($exception instanceof HttpException) { $category = 'yii\\web\\HttpException:' . $exception->statusCode; } elseif ($exception instanceof \ErrorException) { $category .= ':' . $exception->getSeverity(); } if ($this->schedule) { $this->schedule->endCronSchedule(CronScheduleStatus::ERROR, (string)$exception); $this->schedule = null; } \Yii::error((string)$exception, $category); }
php
public function logException($exception) { $category = get_class($exception); if ($exception instanceof HttpException) { $category = 'yii\\web\\HttpException:' . $exception->statusCode; } elseif ($exception instanceof \ErrorException) { $category .= ':' . $exception->getSeverity(); } if ($this->schedule) { $this->schedule->endCronSchedule(CronScheduleStatus::ERROR, (string)$exception); $this->schedule = null; } \Yii::error((string)$exception, $category); }
[ "public", "function", "logException", "(", "$", "exception", ")", "{", "$", "category", "=", "get_class", "(", "$", "exception", ")", ";", "if", "(", "$", "exception", "instanceof", "HttpException", ")", "{", "$", "category", "=", "'yii\\\\web\\\\HttpException:'", ".", "$", "exception", "->", "statusCode", ";", "}", "elseif", "(", "$", "exception", "instanceof", "\\", "ErrorException", ")", "{", "$", "category", ".=", "':'", ".", "$", "exception", "->", "getSeverity", "(", ")", ";", "}", "if", "(", "$", "this", "->", "schedule", ")", "{", "$", "this", "->", "schedule", "->", "endCronSchedule", "(", "CronScheduleStatus", "::", "ERROR", ",", "(", "string", ")", "$", "exception", ")", ";", "$", "this", "->", "schedule", "=", "null", ";", "}", "\\", "Yii", "::", "error", "(", "(", "string", ")", "$", "exception", ",", "$", "category", ")", ";", "}" ]
Logs the given exception @param \Exception $exception the exception to be logged
[ "Logs", "the", "given", "exception" ]
488d5907d6f9b26320e44078b08a8b5b6ed9b49c
https://github.com/yii2mod/yii2-cron-log/blob/488d5907d6f9b26320e44078b08a8b5b6ed9b49c/components/ErrorHandler.php#L26-L39
222,179
peej/phpdoctor
classes/tag.php
tag.&
function &_getInlineTags($text) { $return = NULL; $tagStrings = preg_split('/{(@.+)}/sU', $text, -1, PREG_SPLIT_DELIM_CAPTURE); if ($tagStrings) { $inlineTags = NULL; $phpdoctor =& $this->_root->phpdoctor(); foreach ($tagStrings as $tag) { if (substr($tag, 0, 1) == '@') { $pos = strpos($tag, ' '); if ($pos !== FALSE) { $name = trim(substr($tag, 0, $pos)); $text = trim(substr($tag, $pos + 1)); } else { $name = $tag; $text = NULL; } } else { $name = '@text'; $text = $tag; } $data = NULL; $inlineTag =& $phpdoctor->createTag($name, $text, $data, $this->_root); $inlineTag->setParent($this->_parent); $inlineTags[] = $inlineTag; } $return =& $inlineTags; } return $return; }
php
function &_getInlineTags($text) { $return = NULL; $tagStrings = preg_split('/{(@.+)}/sU', $text, -1, PREG_SPLIT_DELIM_CAPTURE); if ($tagStrings) { $inlineTags = NULL; $phpdoctor =& $this->_root->phpdoctor(); foreach ($tagStrings as $tag) { if (substr($tag, 0, 1) == '@') { $pos = strpos($tag, ' '); if ($pos !== FALSE) { $name = trim(substr($tag, 0, $pos)); $text = trim(substr($tag, $pos + 1)); } else { $name = $tag; $text = NULL; } } else { $name = '@text'; $text = $tag; } $data = NULL; $inlineTag =& $phpdoctor->createTag($name, $text, $data, $this->_root); $inlineTag->setParent($this->_parent); $inlineTags[] = $inlineTag; } $return =& $inlineTags; } return $return; }
[ "function", "&", "_getInlineTags", "(", "$", "text", ")", "{", "$", "return", "=", "NULL", ";", "$", "tagStrings", "=", "preg_split", "(", "'/{(@.+)}/sU'", ",", "$", "text", ",", "-", "1", ",", "PREG_SPLIT_DELIM_CAPTURE", ")", ";", "if", "(", "$", "tagStrings", ")", "{", "$", "inlineTags", "=", "NULL", ";", "$", "phpdoctor", "=", "&", "$", "this", "->", "_root", "->", "phpdoctor", "(", ")", ";", "foreach", "(", "$", "tagStrings", "as", "$", "tag", ")", "{", "if", "(", "substr", "(", "$", "tag", ",", "0", ",", "1", ")", "==", "'@'", ")", "{", "$", "pos", "=", "strpos", "(", "$", "tag", ",", "' '", ")", ";", "if", "(", "$", "pos", "!==", "FALSE", ")", "{", "$", "name", "=", "trim", "(", "substr", "(", "$", "tag", ",", "0", ",", "$", "pos", ")", ")", ";", "$", "text", "=", "trim", "(", "substr", "(", "$", "tag", ",", "$", "pos", "+", "1", ")", ")", ";", "}", "else", "{", "$", "name", "=", "$", "tag", ";", "$", "text", "=", "NULL", ";", "}", "}", "else", "{", "$", "name", "=", "'@text'", ";", "$", "text", "=", "$", "tag", ";", "}", "$", "data", "=", "NULL", ";", "$", "inlineTag", "=", "&", "$", "phpdoctor", "->", "createTag", "(", "$", "name", ",", "$", "text", ",", "$", "data", ",", "$", "this", "->", "_root", ")", ";", "$", "inlineTag", "->", "setParent", "(", "$", "this", "->", "_parent", ")", ";", "$", "inlineTags", "[", "]", "=", "$", "inlineTag", ";", "}", "$", "return", "=", "&", "$", "inlineTags", ";", "}", "return", "$", "return", ";", "}" ]
Parse out inline tags from within a text string @param str text @return Tag[]
[ "Parse", "out", "inline", "tags", "from", "within", "a", "text", "string" ]
3eb646e3b93d411ba8faccd8e9691d6190a11379
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/tag.php#L176-L206
222,180
thedevsaddam/laravel-schema
src/Console/Commands/TableSchema.php
TableSchema.makeTableBody
private function makeTableBody($headers, $rows) { $body = []; $tableCellWidth = ($this->option('w')) ? $this->option('w') : 10; for ($i = 0; $i < count($rows); $i++) { $row = []; for ($j = 0; $j < count($headers); $j++) { $column = $headers[$j]; $row[$j] = str_limit($rows[$i]->$column, $tableCellWidth, ''); } $body[$i] = $row; } return $body; }
php
private function makeTableBody($headers, $rows) { $body = []; $tableCellWidth = ($this->option('w')) ? $this->option('w') : 10; for ($i = 0; $i < count($rows); $i++) { $row = []; for ($j = 0; $j < count($headers); $j++) { $column = $headers[$j]; $row[$j] = str_limit($rows[$i]->$column, $tableCellWidth, ''); } $body[$i] = $row; } return $body; }
[ "private", "function", "makeTableBody", "(", "$", "headers", ",", "$", "rows", ")", "{", "$", "body", "=", "[", "]", ";", "$", "tableCellWidth", "=", "(", "$", "this", "->", "option", "(", "'w'", ")", ")", "?", "$", "this", "->", "option", "(", "'w'", ")", ":", "10", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "rows", ")", ";", "$", "i", "++", ")", "{", "$", "row", "=", "[", "]", ";", "for", "(", "$", "j", "=", "0", ";", "$", "j", "<", "count", "(", "$", "headers", ")", ";", "$", "j", "++", ")", "{", "$", "column", "=", "$", "headers", "[", "$", "j", "]", ";", "$", "row", "[", "$", "j", "]", "=", "str_limit", "(", "$", "rows", "[", "$", "i", "]", "->", "$", "column", ",", "$", "tableCellWidth", ",", "''", ")", ";", "}", "$", "body", "[", "$", "i", "]", "=", "$", "row", ";", "}", "return", "$", "body", ";", "}" ]
Make formatted body for table @param $headers @param $rows @return array
[ "Make", "formatted", "body", "for", "table" ]
ce787b3b5d6f558cd5fb615f373beabb1939e724
https://github.com/thedevsaddam/laravel-schema/blob/ce787b3b5d6f558cd5fb615f373beabb1939e724/src/Console/Commands/TableSchema.php#L133-L146
222,181
petercoles/Betfair-Exchange
src/Api/BaseApi.php
BaseApi.execute
public function execute($params) { $this->method = array_shift($params); $this->prepare($params); return $this->httpClient ->setMethod('post') ->setEndPoint(static::ENDPOINT.$this->method.'/') ->authHeaders() ->addHeader([ 'Content-Type' => 'application/json' ]) ->setParams($this->params) ->send(); }
php
public function execute($params) { $this->method = array_shift($params); $this->prepare($params); return $this->httpClient ->setMethod('post') ->setEndPoint(static::ENDPOINT.$this->method.'/') ->authHeaders() ->addHeader([ 'Content-Type' => 'application/json' ]) ->setParams($this->params) ->send(); }
[ "public", "function", "execute", "(", "$", "params", ")", "{", "$", "this", "->", "method", "=", "array_shift", "(", "$", "params", ")", ";", "$", "this", "->", "prepare", "(", "$", "params", ")", ";", "return", "$", "this", "->", "httpClient", "->", "setMethod", "(", "'post'", ")", "->", "setEndPoint", "(", "static", "::", "ENDPOINT", ".", "$", "this", "->", "method", ".", "'/'", ")", "->", "authHeaders", "(", ")", "->", "addHeader", "(", "[", "'Content-Type'", "=>", "'application/json'", "]", ")", "->", "setParams", "(", "$", "this", "->", "params", ")", "->", "send", "(", ")", ";", "}" ]
Invoke the HTTP client to Execute the API request @param array $params @return mixed
[ "Invoke", "the", "HTTP", "client", "to", "Execute", "the", "API", "request" ]
58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2
https://github.com/petercoles/Betfair-Exchange/blob/58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2/src/Api/BaseApi.php#L41-L53
222,182
peej/phpdoctor
doclets/standard/packageIndexWriter.php
packageIndexWriter.packageIndexWriter
public function packageIndexWriter(&$doclet) { parent::htmlWriter($doclet); $phpdoctor =& $this->_doclet->phpdoctor(); $this->_sections[0] = array('title' => 'Overview', 'selected' => TRUE); $this->_sections[1] = array('title' => 'Namespace'); $this->_sections[2] = array('title' => 'Class'); //$this->_sections[3] = array('title' => 'Use'); if ($phpdoctor->getOption('tree')) $this->_sections[4] = array('title' => 'Tree', 'url' => 'overview-tree.html'); if ($doclet->includeSource()) $this->_sections[5] = array('title' => 'Files', 'url' => 'overview-files.html'); $this->_sections[6] = array('title' => 'Deprecated', 'url' => 'deprecated-list.html'); $this->_sections[7] = array('title' => 'Todo', 'url' => 'todo-list.html'); $this->_sections[8] = array('title' => 'Index', 'url' => 'index-all.html'); ob_start(); echo "<hr>\n\n"; echo '<h1>'.$this->_doclet->docTitle()."</h1>\n\n"; $rootDoc =& $this->_doclet->rootDoc(); $textTag =& $rootDoc->tags('@text'); if ($textTag) { $description = $this->_processInlineTags($textTag, TRUE); if ($description) { echo '<div class="comment">', $description, "</div>\n\n"; echo '<dl><dt>See:</dt><dd><b><a href="#overview_description">Description</a></b></dd></dl>'."\n\n"; } } echo '<table class="title">'."\n"; echo '<tr><th colspan="2" class="title">Namespaces</th></tr>'."\n"; $packages =& $rootDoc->packages(); ksort($packages); foreach ($packages as $name => $package) { $textTag =& $package->tags('@text'); echo '<tr><td class="name"><a href="'.$package->asPath().'/package-summary.html">'.$package->name().'</a></td>'; echo '<td class="description">'.strip_tags($this->_processInlineTags($textTag, TRUE), '<a><b><strong><u><em>').'</td></tr>'."\n"; } echo '</table>'."\n\n"; $textTag =& $rootDoc->tags('@text'); if ($textTag) { $description = $this->_processInlineTags($textTag); if ($description) { echo '<div class="comment" id="overview_description">', $description, "</div>\n\n"; } } echo "<hr>\n\n"; $this->_output = ob_get_contents(); ob_end_clean(); $this->_write('overview-summary.html', 'Overview', TRUE); }
php
public function packageIndexWriter(&$doclet) { parent::htmlWriter($doclet); $phpdoctor =& $this->_doclet->phpdoctor(); $this->_sections[0] = array('title' => 'Overview', 'selected' => TRUE); $this->_sections[1] = array('title' => 'Namespace'); $this->_sections[2] = array('title' => 'Class'); //$this->_sections[3] = array('title' => 'Use'); if ($phpdoctor->getOption('tree')) $this->_sections[4] = array('title' => 'Tree', 'url' => 'overview-tree.html'); if ($doclet->includeSource()) $this->_sections[5] = array('title' => 'Files', 'url' => 'overview-files.html'); $this->_sections[6] = array('title' => 'Deprecated', 'url' => 'deprecated-list.html'); $this->_sections[7] = array('title' => 'Todo', 'url' => 'todo-list.html'); $this->_sections[8] = array('title' => 'Index', 'url' => 'index-all.html'); ob_start(); echo "<hr>\n\n"; echo '<h1>'.$this->_doclet->docTitle()."</h1>\n\n"; $rootDoc =& $this->_doclet->rootDoc(); $textTag =& $rootDoc->tags('@text'); if ($textTag) { $description = $this->_processInlineTags($textTag, TRUE); if ($description) { echo '<div class="comment">', $description, "</div>\n\n"; echo '<dl><dt>See:</dt><dd><b><a href="#overview_description">Description</a></b></dd></dl>'."\n\n"; } } echo '<table class="title">'."\n"; echo '<tr><th colspan="2" class="title">Namespaces</th></tr>'."\n"; $packages =& $rootDoc->packages(); ksort($packages); foreach ($packages as $name => $package) { $textTag =& $package->tags('@text'); echo '<tr><td class="name"><a href="'.$package->asPath().'/package-summary.html">'.$package->name().'</a></td>'; echo '<td class="description">'.strip_tags($this->_processInlineTags($textTag, TRUE), '<a><b><strong><u><em>').'</td></tr>'."\n"; } echo '</table>'."\n\n"; $textTag =& $rootDoc->tags('@text'); if ($textTag) { $description = $this->_processInlineTags($textTag); if ($description) { echo '<div class="comment" id="overview_description">', $description, "</div>\n\n"; } } echo "<hr>\n\n"; $this->_output = ob_get_contents(); ob_end_clean(); $this->_write('overview-summary.html', 'Overview', TRUE); }
[ "public", "function", "packageIndexWriter", "(", "&", "$", "doclet", ")", "{", "parent", "::", "htmlWriter", "(", "$", "doclet", ")", ";", "$", "phpdoctor", "=", "&", "$", "this", "->", "_doclet", "->", "phpdoctor", "(", ")", ";", "$", "this", "->", "_sections", "[", "0", "]", "=", "array", "(", "'title'", "=>", "'Overview'", ",", "'selected'", "=>", "TRUE", ")", ";", "$", "this", "->", "_sections", "[", "1", "]", "=", "array", "(", "'title'", "=>", "'Namespace'", ")", ";", "$", "this", "->", "_sections", "[", "2", "]", "=", "array", "(", "'title'", "=>", "'Class'", ")", ";", "//$this->_sections[3] = array('title' => 'Use');", "if", "(", "$", "phpdoctor", "->", "getOption", "(", "'tree'", ")", ")", "$", "this", "->", "_sections", "[", "4", "]", "=", "array", "(", "'title'", "=>", "'Tree'", ",", "'url'", "=>", "'overview-tree.html'", ")", ";", "if", "(", "$", "doclet", "->", "includeSource", "(", ")", ")", "$", "this", "->", "_sections", "[", "5", "]", "=", "array", "(", "'title'", "=>", "'Files'", ",", "'url'", "=>", "'overview-files.html'", ")", ";", "$", "this", "->", "_sections", "[", "6", "]", "=", "array", "(", "'title'", "=>", "'Deprecated'", ",", "'url'", "=>", "'deprecated-list.html'", ")", ";", "$", "this", "->", "_sections", "[", "7", "]", "=", "array", "(", "'title'", "=>", "'Todo'", ",", "'url'", "=>", "'todo-list.html'", ")", ";", "$", "this", "->", "_sections", "[", "8", "]", "=", "array", "(", "'title'", "=>", "'Index'", ",", "'url'", "=>", "'index-all.html'", ")", ";", "ob_start", "(", ")", ";", "echo", "\"<hr>\\n\\n\"", ";", "echo", "'<h1>'", ".", "$", "this", "->", "_doclet", "->", "docTitle", "(", ")", ".", "\"</h1>\\n\\n\"", ";", "$", "rootDoc", "=", "&", "$", "this", "->", "_doclet", "->", "rootDoc", "(", ")", ";", "$", "textTag", "=", "&", "$", "rootDoc", "->", "tags", "(", "'@text'", ")", ";", "if", "(", "$", "textTag", ")", "{", "$", "description", "=", "$", "this", "->", "_processInlineTags", "(", "$", "textTag", ",", "TRUE", ")", ";", "if", "(", "$", "description", ")", "{", "echo", "'<div class=\"comment\">'", ",", "$", "description", ",", "\"</div>\\n\\n\"", ";", "echo", "'<dl><dt>See:</dt><dd><b><a href=\"#overview_description\">Description</a></b></dd></dl>'", ".", "\"\\n\\n\"", ";", "}", "}", "echo", "'<table class=\"title\">'", ".", "\"\\n\"", ";", "echo", "'<tr><th colspan=\"2\" class=\"title\">Namespaces</th></tr>'", ".", "\"\\n\"", ";", "$", "packages", "=", "&", "$", "rootDoc", "->", "packages", "(", ")", ";", "ksort", "(", "$", "packages", ")", ";", "foreach", "(", "$", "packages", "as", "$", "name", "=>", "$", "package", ")", "{", "$", "textTag", "=", "&", "$", "package", "->", "tags", "(", "'@text'", ")", ";", "echo", "'<tr><td class=\"name\"><a href=\"'", ".", "$", "package", "->", "asPath", "(", ")", ".", "'/package-summary.html\">'", ".", "$", "package", "->", "name", "(", ")", ".", "'</a></td>'", ";", "echo", "'<td class=\"description\">'", ".", "strip_tags", "(", "$", "this", "->", "_processInlineTags", "(", "$", "textTag", ",", "TRUE", ")", ",", "'<a><b><strong><u><em>'", ")", ".", "'</td></tr>'", ".", "\"\\n\"", ";", "}", "echo", "'</table>'", ".", "\"\\n\\n\"", ";", "$", "textTag", "=", "&", "$", "rootDoc", "->", "tags", "(", "'@text'", ")", ";", "if", "(", "$", "textTag", ")", "{", "$", "description", "=", "$", "this", "->", "_processInlineTags", "(", "$", "textTag", ")", ";", "if", "(", "$", "description", ")", "{", "echo", "'<div class=\"comment\" id=\"overview_description\">'", ",", "$", "description", ",", "\"</div>\\n\\n\"", ";", "}", "}", "echo", "\"<hr>\\n\\n\"", ";", "$", "this", "->", "_output", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "$", "this", "->", "_write", "(", "'overview-summary.html'", ",", "'Overview'", ",", "TRUE", ")", ";", "}" ]
Build the package index. @param Doclet doclet
[ "Build", "the", "package", "index", "." ]
3eb646e3b93d411ba8faccd8e9691d6190a11379
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/doclets/standard/packageIndexWriter.php#L33-L93
222,183
webtoucher/yii2-amqp
components/Amqp.php
Amqp.getChannel
public function getChannel($channel_id = null) { $index = $channel_id ?: 'default'; if (!array_key_exists($index, $this->channels)) { $this->channels[$index] = $this->connection->channel($channel_id); } return $this->channels[$index]; }
php
public function getChannel($channel_id = null) { $index = $channel_id ?: 'default'; if (!array_key_exists($index, $this->channels)) { $this->channels[$index] = $this->connection->channel($channel_id); } return $this->channels[$index]; }
[ "public", "function", "getChannel", "(", "$", "channel_id", "=", "null", ")", "{", "$", "index", "=", "$", "channel_id", "?", ":", "'default'", ";", "if", "(", "!", "array_key_exists", "(", "$", "index", ",", "$", "this", "->", "channels", ")", ")", "{", "$", "this", "->", "channels", "[", "$", "index", "]", "=", "$", "this", "->", "connection", "->", "channel", "(", "$", "channel_id", ")", ";", "}", "return", "$", "this", "->", "channels", "[", "$", "index", "]", ";", "}" ]
Returns AMQP connection. @param string $channel_id @return AMQPChannel
[ "Returns", "AMQP", "connection", "." ]
7a060ce88f2e31d7324b036a6b1d113a0d75bf02
https://github.com/webtoucher/yii2-amqp/blob/7a060ce88f2e31d7324b036a6b1d113a0d75bf02/components/Amqp.php#L105-L112
222,184
webtoucher/yii2-amqp
components/Amqp.php
Amqp.listen
public function listen($exchange, $routing_key, $callback, $type = self::TYPE_TOPIC) { list ($queueName) = $this->channel->queue_declare(); if ($type == Amqp::TYPE_DIRECT) { $this->channel->exchange_declare($exchange, $type, false, true, false); } $this->channel->queue_bind($queueName, $exchange, $routing_key); $this->channel->basic_consume($queueName, '', false, true, false, false, $callback); while (count($this->channel->callbacks)) { $this->channel->wait(); } $this->channel->close(); $this->connection->close(); }
php
public function listen($exchange, $routing_key, $callback, $type = self::TYPE_TOPIC) { list ($queueName) = $this->channel->queue_declare(); if ($type == Amqp::TYPE_DIRECT) { $this->channel->exchange_declare($exchange, $type, false, true, false); } $this->channel->queue_bind($queueName, $exchange, $routing_key); $this->channel->basic_consume($queueName, '', false, true, false, false, $callback); while (count($this->channel->callbacks)) { $this->channel->wait(); } $this->channel->close(); $this->connection->close(); }
[ "public", "function", "listen", "(", "$", "exchange", ",", "$", "routing_key", ",", "$", "callback", ",", "$", "type", "=", "self", "::", "TYPE_TOPIC", ")", "{", "list", "(", "$", "queueName", ")", "=", "$", "this", "->", "channel", "->", "queue_declare", "(", ")", ";", "if", "(", "$", "type", "==", "Amqp", "::", "TYPE_DIRECT", ")", "{", "$", "this", "->", "channel", "->", "exchange_declare", "(", "$", "exchange", ",", "$", "type", ",", "false", ",", "true", ",", "false", ")", ";", "}", "$", "this", "->", "channel", "->", "queue_bind", "(", "$", "queueName", ",", "$", "exchange", ",", "$", "routing_key", ")", ";", "$", "this", "->", "channel", "->", "basic_consume", "(", "$", "queueName", ",", "''", ",", "false", ",", "true", ",", "false", ",", "false", ",", "$", "callback", ")", ";", "while", "(", "count", "(", "$", "this", "->", "channel", "->", "callbacks", ")", ")", "{", "$", "this", "->", "channel", "->", "wait", "(", ")", ";", "}", "$", "this", "->", "channel", "->", "close", "(", ")", ";", "$", "this", "->", "connection", "->", "close", "(", ")", ";", "}" ]
Listens the exchange for messages. @param string $exchange @param string $routing_key @param callable $callback @param string $type
[ "Listens", "the", "exchange", "for", "messages", "." ]
7a060ce88f2e31d7324b036a6b1d113a0d75bf02
https://github.com/webtoucher/yii2-amqp/blob/7a060ce88f2e31d7324b036a6b1d113a0d75bf02/components/Amqp.php#L172-L187
222,185
webtoucher/yii2-amqp
components/Amqp.php
Amqp.prepareMessage
public function prepareMessage($message, $properties = null) { if (empty($message)) { throw new Exception('AMQP message can not be empty'); } if (is_array($message) || is_object($message)) { $message = Json::encode($message); } return new AMQPMessage($message, $properties); }
php
public function prepareMessage($message, $properties = null) { if (empty($message)) { throw new Exception('AMQP message can not be empty'); } if (is_array($message) || is_object($message)) { $message = Json::encode($message); } return new AMQPMessage($message, $properties); }
[ "public", "function", "prepareMessage", "(", "$", "message", ",", "$", "properties", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "message", ")", ")", "{", "throw", "new", "Exception", "(", "'AMQP message can not be empty'", ")", ";", "}", "if", "(", "is_array", "(", "$", "message", ")", "||", "is_object", "(", "$", "message", ")", ")", "{", "$", "message", "=", "Json", "::", "encode", "(", "$", "message", ")", ";", "}", "return", "new", "AMQPMessage", "(", "$", "message", ",", "$", "properties", ")", ";", "}" ]
Returns prepaired AMQP message. @param string|array|object $message @param array $properties @return AMQPMessage @throws Exception If message is empty.
[ "Returns", "prepaired", "AMQP", "message", "." ]
7a060ce88f2e31d7324b036a6b1d113a0d75bf02
https://github.com/webtoucher/yii2-amqp/blob/7a060ce88f2e31d7324b036a6b1d113a0d75bf02/components/Amqp.php#L197-L206
222,186
SmarchSoftware/watchtower
src/Controllers/RoleController.php
RoleController.editRolePermissions
public function editRolePermissions($id) { if ( Shinobi::can( config('watchtower.acl.role.permissions', false) ) ) { $role = Role::findOrFail($id); $permissions = $role->permissions; $available_permissions = Permission::whereDoesntHave('roles', function ($query) use ($id) { $query->where('role_id', $id); })->get(); return view( config('watchtower.views.roles.permission'), compact('role', 'permissions', 'available_permissions') ); } return view( config('watchtower.views.layouts.unauthorized'), [ 'message' => 'sync role permissions' ]); }
php
public function editRolePermissions($id) { if ( Shinobi::can( config('watchtower.acl.role.permissions', false) ) ) { $role = Role::findOrFail($id); $permissions = $role->permissions; $available_permissions = Permission::whereDoesntHave('roles', function ($query) use ($id) { $query->where('role_id', $id); })->get(); return view( config('watchtower.views.roles.permission'), compact('role', 'permissions', 'available_permissions') ); } return view( config('watchtower.views.layouts.unauthorized'), [ 'message' => 'sync role permissions' ]); }
[ "public", "function", "editRolePermissions", "(", "$", "id", ")", "{", "if", "(", "Shinobi", "::", "can", "(", "config", "(", "'watchtower.acl.role.permissions'", ",", "false", ")", ")", ")", "{", "$", "role", "=", "Role", "::", "findOrFail", "(", "$", "id", ")", ";", "$", "permissions", "=", "$", "role", "->", "permissions", ";", "$", "available_permissions", "=", "Permission", "::", "whereDoesntHave", "(", "'roles'", ",", "function", "(", "$", "query", ")", "use", "(", "$", "id", ")", "{", "$", "query", "->", "where", "(", "'role_id'", ",", "$", "id", ")", ";", "}", ")", "->", "get", "(", ")", ";", "return", "view", "(", "config", "(", "'watchtower.views.roles.permission'", ")", ",", "compact", "(", "'role'", ",", "'permissions'", ",", "'available_permissions'", ")", ")", ";", "}", "return", "view", "(", "config", "(", "'watchtower.views.layouts.unauthorized'", ")", ",", "[", "'message'", "=>", "'sync role permissions'", "]", ")", ";", "}" ]
Show the form for editing the role permissions. @param int $id @return Response
[ "Show", "the", "form", "for", "editing", "the", "role", "permissions", "." ]
4ac9368ff98dfa88d4a4c4c8ce1ff92e4d35b5da
https://github.com/SmarchSoftware/watchtower/blob/4ac9368ff98dfa88d4a4c4c8ce1ff92e4d35b5da/src/Controllers/RoleController.php#L190-L205
222,187
SmarchSoftware/watchtower
src/Controllers/RoleController.php
RoleController.updateRolePermissions
public function updateRolePermissions($id, Request $request) { $level = "danger"; $message = " You are not permitted to update role permissions."; if ( Shinobi::can ( config('watchtower.acl.role.permissions', false) ) ) { $role = Role::findOrFail($id); if ($request->has('slug')) { $role->permissions()->sync( $request->get('slug') ); } else { $role->permissions()->detach(); } $level = "success"; $message = "<i class='fa fa-check-square-o fa-1x'></i> Success! Role permissions updated."; } return redirect()->route( config('watchtower.route.as') .'role.index') ->with( ['flash' => ['message' => $message, 'level' => $level] ] ); }
php
public function updateRolePermissions($id, Request $request) { $level = "danger"; $message = " You are not permitted to update role permissions."; if ( Shinobi::can ( config('watchtower.acl.role.permissions', false) ) ) { $role = Role::findOrFail($id); if ($request->has('slug')) { $role->permissions()->sync( $request->get('slug') ); } else { $role->permissions()->detach(); } $level = "success"; $message = "<i class='fa fa-check-square-o fa-1x'></i> Success! Role permissions updated."; } return redirect()->route( config('watchtower.route.as') .'role.index') ->with( ['flash' => ['message' => $message, 'level' => $level] ] ); }
[ "public", "function", "updateRolePermissions", "(", "$", "id", ",", "Request", "$", "request", ")", "{", "$", "level", "=", "\"danger\"", ";", "$", "message", "=", "\" You are not permitted to update role permissions.\"", ";", "if", "(", "Shinobi", "::", "can", "(", "config", "(", "'watchtower.acl.role.permissions'", ",", "false", ")", ")", ")", "{", "$", "role", "=", "Role", "::", "findOrFail", "(", "$", "id", ")", ";", "if", "(", "$", "request", "->", "has", "(", "'slug'", ")", ")", "{", "$", "role", "->", "permissions", "(", ")", "->", "sync", "(", "$", "request", "->", "get", "(", "'slug'", ")", ")", ";", "}", "else", "{", "$", "role", "->", "permissions", "(", ")", "->", "detach", "(", ")", ";", "}", "$", "level", "=", "\"success\"", ";", "$", "message", "=", "\"<i class='fa fa-check-square-o fa-1x'></i> Success! Role permissions updated.\"", ";", "}", "return", "redirect", "(", ")", "->", "route", "(", "config", "(", "'watchtower.route.as'", ")", ".", "'role.index'", ")", "->", "with", "(", "[", "'flash'", "=>", "[", "'message'", "=>", "$", "message", ",", "'level'", "=>", "$", "level", "]", "]", ")", ";", "}" ]
Sync roles and permissions. @param int $id @return Response
[ "Sync", "roles", "and", "permissions", "." ]
4ac9368ff98dfa88d4a4c4c8ce1ff92e4d35b5da
https://github.com/SmarchSoftware/watchtower/blob/4ac9368ff98dfa88d4a4c4c8ce1ff92e4d35b5da/src/Controllers/RoleController.php#L213-L231
222,188
SmarchSoftware/watchtower
src/Controllers/RoleController.php
RoleController.editRoleUsers
public function editRoleUsers($id) { if ( Shinobi::can( config('watchtower.acl.role.users', false) ) ) { $role = Role::findOrFail($id); $users = $role->users; $available_users = User::whereDoesntHave('roles', function ($query) use ($id) { $query->where('role_id', $id); })->get(); return view( config('watchtower.views.roles.user'), compact('role', 'users', 'available_users') ); } return view( config('watchtower.views.layouts.unauthorized'), [ 'message' => 'sync role users' ]); }
php
public function editRoleUsers($id) { if ( Shinobi::can( config('watchtower.acl.role.users', false) ) ) { $role = Role::findOrFail($id); $users = $role->users; $available_users = User::whereDoesntHave('roles', function ($query) use ($id) { $query->where('role_id', $id); })->get(); return view( config('watchtower.views.roles.user'), compact('role', 'users', 'available_users') ); } return view( config('watchtower.views.layouts.unauthorized'), [ 'message' => 'sync role users' ]); }
[ "public", "function", "editRoleUsers", "(", "$", "id", ")", "{", "if", "(", "Shinobi", "::", "can", "(", "config", "(", "'watchtower.acl.role.users'", ",", "false", ")", ")", ")", "{", "$", "role", "=", "Role", "::", "findOrFail", "(", "$", "id", ")", ";", "$", "users", "=", "$", "role", "->", "users", ";", "$", "available_users", "=", "User", "::", "whereDoesntHave", "(", "'roles'", ",", "function", "(", "$", "query", ")", "use", "(", "$", "id", ")", "{", "$", "query", "->", "where", "(", "'role_id'", ",", "$", "id", ")", ";", "}", ")", "->", "get", "(", ")", ";", "return", "view", "(", "config", "(", "'watchtower.views.roles.user'", ")", ",", "compact", "(", "'role'", ",", "'users'", ",", "'available_users'", ")", ")", ";", "}", "return", "view", "(", "config", "(", "'watchtower.views.layouts.unauthorized'", ")", ",", "[", "'message'", "=>", "'sync role users'", "]", ")", ";", "}" ]
Show the form for editing the role users. @param int $id @return Response
[ "Show", "the", "form", "for", "editing", "the", "role", "users", "." ]
4ac9368ff98dfa88d4a4c4c8ce1ff92e4d35b5da
https://github.com/SmarchSoftware/watchtower/blob/4ac9368ff98dfa88d4a4c4c8ce1ff92e4d35b5da/src/Controllers/RoleController.php#L239-L254
222,189
SmarchSoftware/watchtower
src/Controllers/RoleController.php
RoleController.showRoleMatrix
public function showRoleMatrix() { if ( Shinobi::can( config('watchtower.acl.role.viewmatrix', false) ) ) { $roles = Role::all(); $perms = Permission::all(); $prs = DB::table('permission_role')->select('role_id as r_id','permission_id as p_id')->get(); $pivot = []; foreach($prs as $p) { $pivot[] = $p->r_id.":".$p->p_id; } return view( config('watchtower.views.roles.rolematrix'), compact('roles','perms','pivot') ); } return view( config('watchtower.views.layouts.unauthorized'), [ 'message' => 'view the role matrix' ]); }
php
public function showRoleMatrix() { if ( Shinobi::can( config('watchtower.acl.role.viewmatrix', false) ) ) { $roles = Role::all(); $perms = Permission::all(); $prs = DB::table('permission_role')->select('role_id as r_id','permission_id as p_id')->get(); $pivot = []; foreach($prs as $p) { $pivot[] = $p->r_id.":".$p->p_id; } return view( config('watchtower.views.roles.rolematrix'), compact('roles','perms','pivot') ); } return view( config('watchtower.views.layouts.unauthorized'), [ 'message' => 'view the role matrix' ]); }
[ "public", "function", "showRoleMatrix", "(", ")", "{", "if", "(", "Shinobi", "::", "can", "(", "config", "(", "'watchtower.acl.role.viewmatrix'", ",", "false", ")", ")", ")", "{", "$", "roles", "=", "Role", "::", "all", "(", ")", ";", "$", "perms", "=", "Permission", "::", "all", "(", ")", ";", "$", "prs", "=", "DB", "::", "table", "(", "'permission_role'", ")", "->", "select", "(", "'role_id as r_id'", ",", "'permission_id as p_id'", ")", "->", "get", "(", ")", ";", "$", "pivot", "=", "[", "]", ";", "foreach", "(", "$", "prs", "as", "$", "p", ")", "{", "$", "pivot", "[", "]", "=", "$", "p", "->", "r_id", ".", "\":\"", ".", "$", "p", "->", "p_id", ";", "}", "return", "view", "(", "config", "(", "'watchtower.views.roles.rolematrix'", ")", ",", "compact", "(", "'roles'", ",", "'perms'", ",", "'pivot'", ")", ")", ";", "}", "return", "view", "(", "config", "(", "'watchtower.views.layouts.unauthorized'", ")", ",", "[", "'message'", "=>", "'view the role matrix'", "]", ")", ";", "}" ]
A full matrix of roles and permissions. @return Response
[ "A", "full", "matrix", "of", "roles", "and", "permissions", "." ]
4ac9368ff98dfa88d4a4c4c8ce1ff92e4d35b5da
https://github.com/SmarchSoftware/watchtower/blob/4ac9368ff98dfa88d4a4c4c8ce1ff92e4d35b5da/src/Controllers/RoleController.php#L286-L302
222,190
peej/phpdoctor
classes/executableDoc.php
executableDoc.paramTags
public function paramTags() { if (isset($this->_tags['@param'])) { if (is_array($this->_tags['@param'])) { return $this->_tags['@param']; } else { return array($this->_tags['@param']); } } else { return NULL; } }
php
public function paramTags() { if (isset($this->_tags['@param'])) { if (is_array($this->_tags['@param'])) { return $this->_tags['@param']; } else { return array($this->_tags['@param']); } } else { return NULL; } }
[ "public", "function", "paramTags", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_tags", "[", "'@param'", "]", ")", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "_tags", "[", "'@param'", "]", ")", ")", "{", "return", "$", "this", "->", "_tags", "[", "'@param'", "]", ";", "}", "else", "{", "return", "array", "(", "$", "this", "->", "_tags", "[", "'@param'", "]", ")", ";", "}", "}", "else", "{", "return", "NULL", ";", "}", "}" ]
Return the param tags in this function. @return Tag[]
[ "Return", "the", "param", "tags", "in", "this", "function", "." ]
3eb646e3b93d411ba8faccd8e9691d6190a11379
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/executableDoc.php#L88-L99
222,191
peej/phpdoctor
classes/executableDoc.php
executableDoc.throwsTags
public function throwsTags() { if (isset($this->_tags['@throws'])) { if (is_array($this->_tags['@throws'])) { return $this->_tags['@throws']; } else { return array($this->_tags['@throws']); } } else { return NULL; } }
php
public function throwsTags() { if (isset($this->_tags['@throws'])) { if (is_array($this->_tags['@throws'])) { return $this->_tags['@throws']; } else { return array($this->_tags['@throws']); } } else { return NULL; } }
[ "public", "function", "throwsTags", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_tags", "[", "'@throws'", "]", ")", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "_tags", "[", "'@throws'", "]", ")", ")", "{", "return", "$", "this", "->", "_tags", "[", "'@throws'", "]", ";", "}", "else", "{", "return", "array", "(", "$", "this", "->", "_tags", "[", "'@throws'", "]", ")", ";", "}", "}", "else", "{", "return", "NULL", ";", "}", "}" ]
Return the throws tags in this function. @return Type
[ "Return", "the", "throws", "tags", "in", "this", "function", "." ]
3eb646e3b93d411ba8faccd8e9691d6190a11379
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/executableDoc.php#L105-L116
222,192
peej/phpdoctor
classes/executableDoc.php
executableDoc.signature
public function signature() { $signature = '('; $myPackage =& $this->containingPackage(); foreach ($this->_parameters as $param) { $type = $param->type(); $classDoc =& $type->asClassDoc(); if ($classDoc) { $packageDoc =& $classDoc->containingPackage(); $signature .= '<a href="'.str_repeat('../', $myPackage->depth() + 1).$classDoc->asPath().'">'.$classDoc->containingPackage().'.'.$classDoc->name().'</a> '.$param->name().$type->dimension().', '; } else { $signature .= $type->typeName().$type->dimension().', '; } } return substr($signature, 0, -2).')'; }
php
public function signature() { $signature = '('; $myPackage =& $this->containingPackage(); foreach ($this->_parameters as $param) { $type = $param->type(); $classDoc =& $type->asClassDoc(); if ($classDoc) { $packageDoc =& $classDoc->containingPackage(); $signature .= '<a href="'.str_repeat('../', $myPackage->depth() + 1).$classDoc->asPath().'">'.$classDoc->containingPackage().'.'.$classDoc->name().'</a> '.$param->name().$type->dimension().', '; } else { $signature .= $type->typeName().$type->dimension().', '; } } return substr($signature, 0, -2).')'; }
[ "public", "function", "signature", "(", ")", "{", "$", "signature", "=", "'('", ";", "$", "myPackage", "=", "&", "$", "this", "->", "containingPackage", "(", ")", ";", "foreach", "(", "$", "this", "->", "_parameters", "as", "$", "param", ")", "{", "$", "type", "=", "$", "param", "->", "type", "(", ")", ";", "$", "classDoc", "=", "&", "$", "type", "->", "asClassDoc", "(", ")", ";", "if", "(", "$", "classDoc", ")", "{", "$", "packageDoc", "=", "&", "$", "classDoc", "->", "containingPackage", "(", ")", ";", "$", "signature", ".=", "'<a href=\"'", ".", "str_repeat", "(", "'../'", ",", "$", "myPackage", "->", "depth", "(", ")", "+", "1", ")", ".", "$", "classDoc", "->", "asPath", "(", ")", ".", "'\">'", ".", "$", "classDoc", "->", "containingPackage", "(", ")", ".", "'.'", ".", "$", "classDoc", "->", "name", "(", ")", ".", "'</a> '", ".", "$", "param", "->", "name", "(", ")", ".", "$", "type", "->", "dimension", "(", ")", ".", "', '", ";", "}", "else", "{", "$", "signature", ".=", "$", "type", "->", "typeName", "(", ")", ".", "$", "type", "->", "dimension", "(", ")", ".", "', '", ";", "}", "}", "return", "substr", "(", "$", "signature", ",", "0", ",", "-", "2", ")", ".", "')'", ";", "}" ]
Get the signature. It is the parameter list, type is qualified. <pre>for a function mymethod(foo x, int y) it will return (bar.foo x, int y)</pre> Recognised types are turned into HTML anchor tags to the documentation page for the class defining them. @return str
[ "Get", "the", "signature", ".", "It", "is", "the", "parameter", "list", "type", "is", "qualified", "." ]
3eb646e3b93d411ba8faccd8e9691d6190a11379
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/executableDoc.php#L130-L146
222,193
petercoles/Betfair-Exchange
src/Http/Client.php
Client.authHeaders
public function authHeaders(array $headers = [ ]) { if (count($headers) == 0) { $headers = [ 'X-Application' => Auth::$appKey, 'X-Authentication' => Auth::$sessionToken ]; } $this->options[ 'headers' ] = array_merge($this->options[ 'headers' ], $headers); return $this; }
php
public function authHeaders(array $headers = [ ]) { if (count($headers) == 0) { $headers = [ 'X-Application' => Auth::$appKey, 'X-Authentication' => Auth::$sessionToken ]; } $this->options[ 'headers' ] = array_merge($this->options[ 'headers' ], $headers); return $this; }
[ "public", "function", "authHeaders", "(", "array", "$", "headers", "=", "[", "]", ")", "{", "if", "(", "count", "(", "$", "headers", ")", "==", "0", ")", "{", "$", "headers", "=", "[", "'X-Application'", "=>", "Auth", "::", "$", "appKey", ",", "'X-Authentication'", "=>", "Auth", "::", "$", "sessionToken", "]", ";", "}", "$", "this", "->", "options", "[", "'headers'", "]", "=", "array_merge", "(", "$", "this", "->", "options", "[", "'headers'", "]", ",", "$", "headers", ")", ";", "return", "$", "this", ";", "}" ]
Setter for authentication headers. @param array $headers @return Client
[ "Setter", "for", "authentication", "headers", "." ]
58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2
https://github.com/petercoles/Betfair-Exchange/blob/58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2/src/Http/Client.php#L74-L81
222,194
petercoles/Betfair-Exchange
src/Http/Client.php
Client.setParams
public function setParams($params) { if (!empty($params)) { foreach ($params as $key => $value) { $this->options[ 'json' ][ $key ] = $value; } } return $this; }
php
public function setParams($params) { if (!empty($params)) { foreach ($params as $key => $value) { $this->options[ 'json' ][ $key ] = $value; } } return $this; }
[ "public", "function", "setParams", "(", "$", "params", ")", "{", "if", "(", "!", "empty", "(", "$", "params", ")", ")", "{", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "options", "[", "'json'", "]", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "$", "this", ";", "}" ]
Setter for params. @param array $params @return Client
[ "Setter", "for", "params", "." ]
58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2
https://github.com/petercoles/Betfair-Exchange/blob/58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2/src/Http/Client.php#L101-L109
222,195
petercoles/Betfair-Exchange
src/Http/Client.php
Client.send
public function send() { try { $response = $this->guzzleClient->request($this->method, $this->uri, $this->options); } catch (ClientException $e) { $this->handleApiException($e->getResponse()->getBody()->getContents()); } return $this->getBody($response); }
php
public function send() { try { $response = $this->guzzleClient->request($this->method, $this->uri, $this->options); } catch (ClientException $e) { $this->handleApiException($e->getResponse()->getBody()->getContents()); } return $this->getBody($response); }
[ "public", "function", "send", "(", ")", "{", "try", "{", "$", "response", "=", "$", "this", "->", "guzzleClient", "->", "request", "(", "$", "this", "->", "method", ",", "$", "this", "->", "uri", ",", "$", "this", "->", "options", ")", ";", "}", "catch", "(", "ClientException", "$", "e", ")", "{", "$", "this", "->", "handleApiException", "(", "$", "e", "->", "getResponse", "(", ")", "->", "getBody", "(", ")", "->", "getContents", "(", ")", ")", ";", "}", "return", "$", "this", "->", "getBody", "(", "$", "response", ")", ";", "}" ]
Dispatch the request and provide hooks for error handling for the response. @return mixed
[ "Dispatch", "the", "request", "and", "provide", "hooks", "for", "error", "handling", "for", "the", "response", "." ]
58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2
https://github.com/petercoles/Betfair-Exchange/blob/58a3d9e1521861d17b26b8c9c8f1dfc74d52c0c2/src/Http/Client.php#L116-L125
222,196
peej/phpdoctor
classes/programElementDoc.php
programElementDoc.qualifiedName
public function qualifiedName() { $parent =& $this->containingClass(); if ($parent && $parent->name() != '' && $this->_package != $parent->name()) { return $this->_package.'\\'.$parent->name().'\\'.$this->_name; } else { return $this->_package.'\\'.$this->_name; } }
php
public function qualifiedName() { $parent =& $this->containingClass(); if ($parent && $parent->name() != '' && $this->_package != $parent->name()) { return $this->_package.'\\'.$parent->name().'\\'.$this->_name; } else { return $this->_package.'\\'.$this->_name; } }
[ "public", "function", "qualifiedName", "(", ")", "{", "$", "parent", "=", "&", "$", "this", "->", "containingClass", "(", ")", ";", "if", "(", "$", "parent", "&&", "$", "parent", "->", "name", "(", ")", "!=", "''", "&&", "$", "this", "->", "_package", "!=", "$", "parent", "->", "name", "(", ")", ")", "{", "return", "$", "this", "->", "_package", ".", "'\\\\'", ".", "$", "parent", "->", "name", "(", ")", ".", "'\\\\'", ".", "$", "this", "->", "_name", ";", "}", "else", "{", "return", "$", "this", "->", "_package", ".", "'\\\\'", ".", "$", "this", "->", "_name", ";", "}", "}" ]
Get the fully qualified name. <pre>Example: for the method bar() in class Foo in the package Baz, return: Baz\Foo\bar()</pre> @return str
[ "Get", "the", "fully", "qualified", "name", "." ]
3eb646e3b93d411ba8faccd8e9691d6190a11379
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/programElementDoc.php#L138-L146
222,197
peej/phpdoctor
classes/programElementDoc.php
programElementDoc.modifiers
public function modifiers($showPublic = TRUE) { $modifiers = ''; if ($showPublic || $this->_access != 'public') { $modifiers .= $this->_access.' '; } if ($this->_final) { $modifiers .= 'final '; } if (isset($this->_abstract) && $this->_abstract) { $modifiers .= 'abstract '; } if ($this->_static) { $modifiers .= 'static '; } return $modifiers; }
php
public function modifiers($showPublic = TRUE) { $modifiers = ''; if ($showPublic || $this->_access != 'public') { $modifiers .= $this->_access.' '; } if ($this->_final) { $modifiers .= 'final '; } if (isset($this->_abstract) && $this->_abstract) { $modifiers .= 'abstract '; } if ($this->_static) { $modifiers .= 'static '; } return $modifiers; }
[ "public", "function", "modifiers", "(", "$", "showPublic", "=", "TRUE", ")", "{", "$", "modifiers", "=", "''", ";", "if", "(", "$", "showPublic", "||", "$", "this", "->", "_access", "!=", "'public'", ")", "{", "$", "modifiers", ".=", "$", "this", "->", "_access", ".", "' '", ";", "}", "if", "(", "$", "this", "->", "_final", ")", "{", "$", "modifiers", ".=", "'final '", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "_abstract", ")", "&&", "$", "this", "->", "_abstract", ")", "{", "$", "modifiers", ".=", "'abstract '", ";", "}", "if", "(", "$", "this", "->", "_static", ")", "{", "$", "modifiers", ".=", "'static '", ";", "}", "return", "$", "modifiers", ";", "}" ]
Get modifiers string. <pre> Example, for: public abstract int foo() { ... } modifiers() would return: 'public abstract'</pre> @return str
[ "Get", "modifiers", "string", "." ]
3eb646e3b93d411ba8faccd8e9691d6190a11379
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/programElementDoc.php#L157-L174
222,198
peej/phpdoctor
classes/programElementDoc.php
programElementDoc.asPath
public function asPath() { if ($this->isClass() || $this->isInterface() || $this->isTrait() || $this->isException()) { return strtolower(str_replace('.', '/', str_replace('\\', '/', $this->_package)).'/'.$this->_name.'.html'); } elseif ($this->isField()) { $class =& $this->containingClass(); if ($class) { return strtolower(str_replace('.', '/', str_replace('\\', '/', $this->_package)).'/'.$class->name().'.html#').$this->_name; } else { return strtolower(str_replace('.', '/', str_replace('\\', '/', $this->_package)).'/package-globals.html#').$this->_name; } } elseif ($this->isConstructor() || $this->isMethod()) { $class =& $this->containingClass(); if ($class) { return strtolower(str_replace('.', '/', str_replace('\\', '/', $this->_package)).'/'.$class->name().'.html#').$this->_name.'()'; } else { return strtolower(str_replace('.', '/', str_replace('\\', '/', $this->_package)).'/package-functions.html#').$this->_name.'()'; } } elseif ($this->isGlobal()) { return strtolower(str_replace('.', '/', str_replace('\\', '/', $this->_package)).'/package-globals.html#').$this->_name; } elseif ($this->isFunction()) { return strtolower(str_replace('.', '/', str_replace('\\', '/', $this->_package)).'/package-functions.html#').$this->_name.'()'; } return NULL; }
php
public function asPath() { if ($this->isClass() || $this->isInterface() || $this->isTrait() || $this->isException()) { return strtolower(str_replace('.', '/', str_replace('\\', '/', $this->_package)).'/'.$this->_name.'.html'); } elseif ($this->isField()) { $class =& $this->containingClass(); if ($class) { return strtolower(str_replace('.', '/', str_replace('\\', '/', $this->_package)).'/'.$class->name().'.html#').$this->_name; } else { return strtolower(str_replace('.', '/', str_replace('\\', '/', $this->_package)).'/package-globals.html#').$this->_name; } } elseif ($this->isConstructor() || $this->isMethod()) { $class =& $this->containingClass(); if ($class) { return strtolower(str_replace('.', '/', str_replace('\\', '/', $this->_package)).'/'.$class->name().'.html#').$this->_name.'()'; } else { return strtolower(str_replace('.', '/', str_replace('\\', '/', $this->_package)).'/package-functions.html#').$this->_name.'()'; } } elseif ($this->isGlobal()) { return strtolower(str_replace('.', '/', str_replace('\\', '/', $this->_package)).'/package-globals.html#').$this->_name; } elseif ($this->isFunction()) { return strtolower(str_replace('.', '/', str_replace('\\', '/', $this->_package)).'/package-functions.html#').$this->_name.'()'; } return NULL; }
[ "public", "function", "asPath", "(", ")", "{", "if", "(", "$", "this", "->", "isClass", "(", ")", "||", "$", "this", "->", "isInterface", "(", ")", "||", "$", "this", "->", "isTrait", "(", ")", "||", "$", "this", "->", "isException", "(", ")", ")", "{", "return", "strtolower", "(", "str_replace", "(", "'.'", ",", "'/'", ",", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "this", "->", "_package", ")", ")", ".", "'/'", ".", "$", "this", "->", "_name", ".", "'.html'", ")", ";", "}", "elseif", "(", "$", "this", "->", "isField", "(", ")", ")", "{", "$", "class", "=", "&", "$", "this", "->", "containingClass", "(", ")", ";", "if", "(", "$", "class", ")", "{", "return", "strtolower", "(", "str_replace", "(", "'.'", ",", "'/'", ",", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "this", "->", "_package", ")", ")", ".", "'/'", ".", "$", "class", "->", "name", "(", ")", ".", "'.html#'", ")", ".", "$", "this", "->", "_name", ";", "}", "else", "{", "return", "strtolower", "(", "str_replace", "(", "'.'", ",", "'/'", ",", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "this", "->", "_package", ")", ")", ".", "'/package-globals.html#'", ")", ".", "$", "this", "->", "_name", ";", "}", "}", "elseif", "(", "$", "this", "->", "isConstructor", "(", ")", "||", "$", "this", "->", "isMethod", "(", ")", ")", "{", "$", "class", "=", "&", "$", "this", "->", "containingClass", "(", ")", ";", "if", "(", "$", "class", ")", "{", "return", "strtolower", "(", "str_replace", "(", "'.'", ",", "'/'", ",", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "this", "->", "_package", ")", ")", ".", "'/'", ".", "$", "class", "->", "name", "(", ")", ".", "'.html#'", ")", ".", "$", "this", "->", "_name", ".", "'()'", ";", "}", "else", "{", "return", "strtolower", "(", "str_replace", "(", "'.'", ",", "'/'", ",", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "this", "->", "_package", ")", ")", ".", "'/package-functions.html#'", ")", ".", "$", "this", "->", "_name", ".", "'()'", ";", "}", "}", "elseif", "(", "$", "this", "->", "isGlobal", "(", ")", ")", "{", "return", "strtolower", "(", "str_replace", "(", "'.'", ",", "'/'", ",", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "this", "->", "_package", ")", ")", ".", "'/package-globals.html#'", ")", ".", "$", "this", "->", "_name", ";", "}", "elseif", "(", "$", "this", "->", "isFunction", "(", ")", ")", "{", "return", "strtolower", "(", "str_replace", "(", "'.'", ",", "'/'", ",", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "this", "->", "_package", ")", ")", ".", "'/package-functions.html#'", ")", ".", "$", "this", "->", "_name", ".", "'()'", ";", "}", "return", "NULL", ";", "}" ]
Return the element path. @return str
[ "Return", "the", "element", "path", "." ]
3eb646e3b93d411ba8faccd8e9691d6190a11379
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/classes/programElementDoc.php#L258-L283
222,199
peej/phpdoctor
doclets/standard/packageFrameWriter.php
packageFrameWriter.&
function &_allItems(&$rootDoc) { ob_start(); echo '<body id="frame">', "\n\n"; echo "<h1>All Items</h1>\n\n"; $classes =& $rootDoc->classes(); if ($classes) { ksort($classes); echo "<h2>Classes</h2>\n"; echo "<ul>\n"; foreach ($classes as $name => $class) { $package =& $classes[$name]->containingPackage(); if ($class->isInterface()) { echo '<li><em><a href="', $classes[$name]->asPath(), '" title="', $classes[$name]->packageName(),'" target="main">', $classes[$name]->name(), "</a></em></li>\n"; } elseif ($class->isTrait()) { echo '<li><em><a href="', $classes[$name]->asPath(), '" title="', $classes[$name]->packageName(),'" target="main">', $classes[$name]->name(), "</a></em></li>\n"; } else { echo '<li><a href="', $classes[$name]->asPath(), '" title="', $classes[$name]->packageName(),'" target="main">', $classes[$name]->name(), "</a></li>\n"; } } echo "</ul>\n\n"; } $functions =& $rootDoc->functions(); if ($functions) { ksort($functions); echo "<h2>Functions</h2>\n"; echo "<ul>\n"; foreach ($functions as $name => $function) { $package =& $functions[$name]->containingPackage(); echo '<li><a href="', $package->asPath(), '/package-functions.html#', $functions[$name]->name(), '()" title="', $functions[$name]->packageName(),'" target="main">', $functions[$name]->name(), "</a></li>\n"; } echo "</ul>\n\n"; } $globals =& $rootDoc->globals(); if ($globals) { ksort($globals); echo "<h2>Globals</h2>\n"; echo "<ul>\n"; foreach ($globals as $name => $global) { $package =& $globals[$name]->containingPackage(); echo '<li><a href="', $package->asPath(), '/package-globals.html#', $globals[$name]->name(), '" title="', $globals[$name]->packageName(),'" target="main">', $globals[$name]->name(), "</a></li>\n"; } echo "</ul>\n\n"; } echo '</body>', "\n\n"; $output = ob_get_contents(); ob_end_clean(); return $output; }
php
function &_allItems(&$rootDoc) { ob_start(); echo '<body id="frame">', "\n\n"; echo "<h1>All Items</h1>\n\n"; $classes =& $rootDoc->classes(); if ($classes) { ksort($classes); echo "<h2>Classes</h2>\n"; echo "<ul>\n"; foreach ($classes as $name => $class) { $package =& $classes[$name]->containingPackage(); if ($class->isInterface()) { echo '<li><em><a href="', $classes[$name]->asPath(), '" title="', $classes[$name]->packageName(),'" target="main">', $classes[$name]->name(), "</a></em></li>\n"; } elseif ($class->isTrait()) { echo '<li><em><a href="', $classes[$name]->asPath(), '" title="', $classes[$name]->packageName(),'" target="main">', $classes[$name]->name(), "</a></em></li>\n"; } else { echo '<li><a href="', $classes[$name]->asPath(), '" title="', $classes[$name]->packageName(),'" target="main">', $classes[$name]->name(), "</a></li>\n"; } } echo "</ul>\n\n"; } $functions =& $rootDoc->functions(); if ($functions) { ksort($functions); echo "<h2>Functions</h2>\n"; echo "<ul>\n"; foreach ($functions as $name => $function) { $package =& $functions[$name]->containingPackage(); echo '<li><a href="', $package->asPath(), '/package-functions.html#', $functions[$name]->name(), '()" title="', $functions[$name]->packageName(),'" target="main">', $functions[$name]->name(), "</a></li>\n"; } echo "</ul>\n\n"; } $globals =& $rootDoc->globals(); if ($globals) { ksort($globals); echo "<h2>Globals</h2>\n"; echo "<ul>\n"; foreach ($globals as $name => $global) { $package =& $globals[$name]->containingPackage(); echo '<li><a href="', $package->asPath(), '/package-globals.html#', $globals[$name]->name(), '" title="', $globals[$name]->packageName(),'" target="main">', $globals[$name]->name(), "</a></li>\n"; } echo "</ul>\n\n"; } echo '</body>', "\n\n"; $output = ob_get_contents(); ob_end_clean(); return $output; }
[ "function", "&", "_allItems", "(", "&", "$", "rootDoc", ")", "{", "ob_start", "(", ")", ";", "echo", "'<body id=\"frame\">'", ",", "\"\\n\\n\"", ";", "echo", "\"<h1>All Items</h1>\\n\\n\"", ";", "$", "classes", "=", "&", "$", "rootDoc", "->", "classes", "(", ")", ";", "if", "(", "$", "classes", ")", "{", "ksort", "(", "$", "classes", ")", ";", "echo", "\"<h2>Classes</h2>\\n\"", ";", "echo", "\"<ul>\\n\"", ";", "foreach", "(", "$", "classes", "as", "$", "name", "=>", "$", "class", ")", "{", "$", "package", "=", "&", "$", "classes", "[", "$", "name", "]", "->", "containingPackage", "(", ")", ";", "if", "(", "$", "class", "->", "isInterface", "(", ")", ")", "{", "echo", "'<li><em><a href=\"'", ",", "$", "classes", "[", "$", "name", "]", "->", "asPath", "(", ")", ",", "'\" title=\"'", ",", "$", "classes", "[", "$", "name", "]", "->", "packageName", "(", ")", ",", "'\" target=\"main\">'", ",", "$", "classes", "[", "$", "name", "]", "->", "name", "(", ")", ",", "\"</a></em></li>\\n\"", ";", "}", "elseif", "(", "$", "class", "->", "isTrait", "(", ")", ")", "{", "echo", "'<li><em><a href=\"'", ",", "$", "classes", "[", "$", "name", "]", "->", "asPath", "(", ")", ",", "'\" title=\"'", ",", "$", "classes", "[", "$", "name", "]", "->", "packageName", "(", ")", ",", "'\" target=\"main\">'", ",", "$", "classes", "[", "$", "name", "]", "->", "name", "(", ")", ",", "\"</a></em></li>\\n\"", ";", "}", "else", "{", "echo", "'<li><a href=\"'", ",", "$", "classes", "[", "$", "name", "]", "->", "asPath", "(", ")", ",", "'\" title=\"'", ",", "$", "classes", "[", "$", "name", "]", "->", "packageName", "(", ")", ",", "'\" target=\"main\">'", ",", "$", "classes", "[", "$", "name", "]", "->", "name", "(", ")", ",", "\"</a></li>\\n\"", ";", "}", "}", "echo", "\"</ul>\\n\\n\"", ";", "}", "$", "functions", "=", "&", "$", "rootDoc", "->", "functions", "(", ")", ";", "if", "(", "$", "functions", ")", "{", "ksort", "(", "$", "functions", ")", ";", "echo", "\"<h2>Functions</h2>\\n\"", ";", "echo", "\"<ul>\\n\"", ";", "foreach", "(", "$", "functions", "as", "$", "name", "=>", "$", "function", ")", "{", "$", "package", "=", "&", "$", "functions", "[", "$", "name", "]", "->", "containingPackage", "(", ")", ";", "echo", "'<li><a href=\"'", ",", "$", "package", "->", "asPath", "(", ")", ",", "'/package-functions.html#'", ",", "$", "functions", "[", "$", "name", "]", "->", "name", "(", ")", ",", "'()\" title=\"'", ",", "$", "functions", "[", "$", "name", "]", "->", "packageName", "(", ")", ",", "'\" target=\"main\">'", ",", "$", "functions", "[", "$", "name", "]", "->", "name", "(", ")", ",", "\"</a></li>\\n\"", ";", "}", "echo", "\"</ul>\\n\\n\"", ";", "}", "$", "globals", "=", "&", "$", "rootDoc", "->", "globals", "(", ")", ";", "if", "(", "$", "globals", ")", "{", "ksort", "(", "$", "globals", ")", ";", "echo", "\"<h2>Globals</h2>\\n\"", ";", "echo", "\"<ul>\\n\"", ";", "foreach", "(", "$", "globals", "as", "$", "name", "=>", "$", "global", ")", "{", "$", "package", "=", "&", "$", "globals", "[", "$", "name", "]", "->", "containingPackage", "(", ")", ";", "echo", "'<li><a href=\"'", ",", "$", "package", "->", "asPath", "(", ")", ",", "'/package-globals.html#'", ",", "$", "globals", "[", "$", "name", "]", "->", "name", "(", ")", ",", "'\" title=\"'", ",", "$", "globals", "[", "$", "name", "]", "->", "packageName", "(", ")", ",", "'\" target=\"main\">'", ",", "$", "globals", "[", "$", "name", "]", "->", "name", "(", ")", ",", "\"</a></li>\\n\"", ";", "}", "echo", "\"</ul>\\n\\n\"", ";", "}", "echo", "'</body>'", ",", "\"\\n\\n\"", ";", "$", "output", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "return", "$", "output", ";", "}" ]
Build all items frame @return str
[ "Build", "all", "items", "frame" ]
3eb646e3b93d411ba8faccd8e9691d6190a11379
https://github.com/peej/phpdoctor/blob/3eb646e3b93d411ba8faccd8e9691d6190a11379/doclets/standard/packageFrameWriter.php#L148-L204