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
38,400
thecodingmachine/mouf
src/Mouf/MoufInstancePropertyDescriptor.php
MoufInstancePropertyDescriptor.toJson
public function toJson() { $result = array(); $value = $this->getValue(); if ($value instanceof MoufInstanceDescriptor) { $serializableValue = $value->getIdentifierName(); //$result['type'] = 'object'; } elseif (is_array($value)) { // We cannot match a PHP array to a JSON array! // The keys in a PHP array are ordered. The key in a JSON array are not ordered! // Therefore, we will be sending the arrays as JSON arrays of key/values to preserve order. $serializableValue = self::arrayToJson($value); //$result['type'] = 'scalar'; // Let's find the type: /*foreach ($value as $val) { if ($val instanceof MoufInstanceDescriptor) { //$result['type'] = 'object'; break; } }*/ } else { $serializableValue = $value; //$result['type'] = 'scalar'; } try { $type = $this->propertyDescriptor->getTypes()->getCompatibleTypeForInstance($value); } catch (\ReflectionException $e) { // If an error occurs here, let's silently continue with an error message added. $result['warning'] = $e->getMessage(); $type = null; } /*if ($type == null) { throw new MoufException("Error for property ".$this->propertyDescriptor->getName()." for instance ".$this->instanceDescriptor->getName()."."); }*/ if ($type == null) { $result['type'] = null; } else { $result['type'] = $type->toJson(); } $result['value'] = $serializableValue; $result['isset'] = $this->isValueSet(); $result['origin'] = $this->getOrigin(); $result['metadata'] = $this->getMetaData(); return $result; }
php
public function toJson() { $result = array(); $value = $this->getValue(); if ($value instanceof MoufInstanceDescriptor) { $serializableValue = $value->getIdentifierName(); //$result['type'] = 'object'; } elseif (is_array($value)) { // We cannot match a PHP array to a JSON array! // The keys in a PHP array are ordered. The key in a JSON array are not ordered! // Therefore, we will be sending the arrays as JSON arrays of key/values to preserve order. $serializableValue = self::arrayToJson($value); //$result['type'] = 'scalar'; // Let's find the type: /*foreach ($value as $val) { if ($val instanceof MoufInstanceDescriptor) { //$result['type'] = 'object'; break; } }*/ } else { $serializableValue = $value; //$result['type'] = 'scalar'; } try { $type = $this->propertyDescriptor->getTypes()->getCompatibleTypeForInstance($value); } catch (\ReflectionException $e) { // If an error occurs here, let's silently continue with an error message added. $result['warning'] = $e->getMessage(); $type = null; } /*if ($type == null) { throw new MoufException("Error for property ".$this->propertyDescriptor->getName()." for instance ".$this->instanceDescriptor->getName()."."); }*/ if ($type == null) { $result['type'] = null; } else { $result['type'] = $type->toJson(); } $result['value'] = $serializableValue; $result['isset'] = $this->isValueSet(); $result['origin'] = $this->getOrigin(); $result['metadata'] = $this->getMetaData(); return $result; }
[ "public", "function", "toJson", "(", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "value", "=", "$", "this", "->", "getValue", "(", ")", ";", "if", "(", "$", "value", "instanceof", "MoufInstanceDescriptor", ")", "{", "$", "serializableVal...
Serializes the mouf instance property into a PHP array @return array
[ "Serializes", "the", "mouf", "instance", "property", "into", "a", "PHP", "array" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/MoufInstancePropertyDescriptor.php#L409-L456
38,401
thecodingmachine/mouf
src-dev/Mouf/Controllers/AbstractMoufInstanceController.php
AbstractMoufInstanceController.initController
protected function initController($name, $selfedit) { $this->instanceName = $name; $this->selfedit = $selfedit; /*$this->instance = MoufManager::getMoufManager()->getInstance($name); $this->className = MoufManager::getMoufManager()->getInstanceType($this->instanceName);*/ if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->className = $this->moufManager->getInstanceType($this->instanceName); //$this->reflectionClass = MoufReflectionProxy::getClass($this->className, $selfedit=="true"); $this->weak = $this->moufManager->isInstanceWeak($this->instanceName); // Init the right menu: /*$extendedActions = $this->reflectionClass->getAnnotations("ExtendedAction"); if (!empty($extendedActions)) { $items = array(); foreach ($extendedActions as $extendedAction) { $menuItem = new MenuItem($extendedAction->getName(), ROOT_URL.$extendedAction->getUrl()); $menuItem->setPropagatedUrlParameters(array("selfedit", "name")); $items[] = $menuItem; } $specialActionsMenuItem = new MenuItem("Special actions", null, $items); //$menu = new Menu($items); \MoufAdmin::getSpecialActionsMenu()->addChild($specialActionsMenuItem); //$this->template->addRightHtmlElement($menuItems); }*/ $viewPropertiesMenuItem = new MenuItem("View properties", ROOT_URL."ajaxinstance/"); $viewPropertiesMenuItem->setPropagatedUrlParameters(array("selfedit", "name")); if (!$viewPropertiesMenuItem->isActive()) { // If the view is active, we might as well not display anything! \MoufAdmin::getInstanceMenu()->addChild($viewPropertiesMenuItem); } /*$viewDependencyGraphMenuItem = new MenuItem("View dependency graph", "mouf/displayGraph/"); $viewDependencyGraphMenuItem->setPropagatedUrlParameters(array("selfedit", "name"));*/ //$commonMenuItem = new MenuItem("<b>Common</b>", null, array($viewPropertiesMenuItem/*, $viewDependencyGraphMenuItem*/)); /*$this->template->addRightHtmlElement(new SplashMenu( array( new SplashMenuItem("<b>Common</b>", null, null), new SplashMenuItem("View properties", ROOT_URL."mouf/instance/?name=".$name, null, array("selfedit")), new SplashMenuItem("View dependency graph", "mouf/displayGraph/?name=".$name, null, array("selfedit"))))); $this->template->addRightFunction(array($this, "displayComponentParents")); */ // Let's find the documentation related to this class. // Note: the class name can be null in case of some instances declared via PHP code. if ($this->className) { $cache = new MoufCache(); $documentationMenuItem = $cache->get('documentationMenuForClass_'.$this->className); if ($documentationMenuItem === null) { $documentationMenuItem = new MenuItem("<b>Related documentation</b>"); // TODO: hit the documentation menu instead! if ($this->selfedit == "true") { $composerJsonFiles = DocumentationUtils::getRelatedPackages($this->className); } else { $documentationUtils = new ClassProxy('Mouf\\DocumentationUtils'); $composerJsonFiles = $documentationUtils->getRelatedPackages($this->className); } foreach ($composerJsonFiles as $composerJsonFile) { $parsedJsonFile = json_decode(file_get_contents($composerJsonFile), true); $extra = isset($parsedJsonFile['extra'])?$parsedJsonFile['extra']:array(); $docPages = DocumentationUtils::getDocPages($extra, dirname($composerJsonFile).'/'); if (isset($parsedJsonFile['name']) && $docPages) { $packageName = $parsedJsonFile['name']; $packageDocumentation = new MenuItem($packageName); $documentationMenuItem->addMenuItem($packageDocumentation); DocumentationUtils::fillMenu($packageDocumentation, $docPages, $packageName); } else { // This is probably the root package if it has no name. continue; } } // Short lived cache (3 minutes) $cache->set('documentationMenuForClass_'.$this->className, $documentationMenuItem, 180); } if ($documentationMenuItem->getChildren()) { \MoufAdmin::getInstanceMenu()->addChild($documentationMenuItem); } } //\MoufAdmin::getBlock_left()->addText("<div id='relatedDocumentation'><b>Related documentation:</b>".var_export($composerJsonFiles, true)."</div>"); $this->displayComponentParents(); }
php
protected function initController($name, $selfedit) { $this->instanceName = $name; $this->selfedit = $selfedit; /*$this->instance = MoufManager::getMoufManager()->getInstance($name); $this->className = MoufManager::getMoufManager()->getInstanceType($this->instanceName);*/ if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->className = $this->moufManager->getInstanceType($this->instanceName); //$this->reflectionClass = MoufReflectionProxy::getClass($this->className, $selfedit=="true"); $this->weak = $this->moufManager->isInstanceWeak($this->instanceName); // Init the right menu: /*$extendedActions = $this->reflectionClass->getAnnotations("ExtendedAction"); if (!empty($extendedActions)) { $items = array(); foreach ($extendedActions as $extendedAction) { $menuItem = new MenuItem($extendedAction->getName(), ROOT_URL.$extendedAction->getUrl()); $menuItem->setPropagatedUrlParameters(array("selfedit", "name")); $items[] = $menuItem; } $specialActionsMenuItem = new MenuItem("Special actions", null, $items); //$menu = new Menu($items); \MoufAdmin::getSpecialActionsMenu()->addChild($specialActionsMenuItem); //$this->template->addRightHtmlElement($menuItems); }*/ $viewPropertiesMenuItem = new MenuItem("View properties", ROOT_URL."ajaxinstance/"); $viewPropertiesMenuItem->setPropagatedUrlParameters(array("selfedit", "name")); if (!$viewPropertiesMenuItem->isActive()) { // If the view is active, we might as well not display anything! \MoufAdmin::getInstanceMenu()->addChild($viewPropertiesMenuItem); } /*$viewDependencyGraphMenuItem = new MenuItem("View dependency graph", "mouf/displayGraph/"); $viewDependencyGraphMenuItem->setPropagatedUrlParameters(array("selfedit", "name"));*/ //$commonMenuItem = new MenuItem("<b>Common</b>", null, array($viewPropertiesMenuItem/*, $viewDependencyGraphMenuItem*/)); /*$this->template->addRightHtmlElement(new SplashMenu( array( new SplashMenuItem("<b>Common</b>", null, null), new SplashMenuItem("View properties", ROOT_URL."mouf/instance/?name=".$name, null, array("selfedit")), new SplashMenuItem("View dependency graph", "mouf/displayGraph/?name=".$name, null, array("selfedit"))))); $this->template->addRightFunction(array($this, "displayComponentParents")); */ // Let's find the documentation related to this class. // Note: the class name can be null in case of some instances declared via PHP code. if ($this->className) { $cache = new MoufCache(); $documentationMenuItem = $cache->get('documentationMenuForClass_'.$this->className); if ($documentationMenuItem === null) { $documentationMenuItem = new MenuItem("<b>Related documentation</b>"); // TODO: hit the documentation menu instead! if ($this->selfedit == "true") { $composerJsonFiles = DocumentationUtils::getRelatedPackages($this->className); } else { $documentationUtils = new ClassProxy('Mouf\\DocumentationUtils'); $composerJsonFiles = $documentationUtils->getRelatedPackages($this->className); } foreach ($composerJsonFiles as $composerJsonFile) { $parsedJsonFile = json_decode(file_get_contents($composerJsonFile), true); $extra = isset($parsedJsonFile['extra'])?$parsedJsonFile['extra']:array(); $docPages = DocumentationUtils::getDocPages($extra, dirname($composerJsonFile).'/'); if (isset($parsedJsonFile['name']) && $docPages) { $packageName = $parsedJsonFile['name']; $packageDocumentation = new MenuItem($packageName); $documentationMenuItem->addMenuItem($packageDocumentation); DocumentationUtils::fillMenu($packageDocumentation, $docPages, $packageName); } else { // This is probably the root package if it has no name. continue; } } // Short lived cache (3 minutes) $cache->set('documentationMenuForClass_'.$this->className, $documentationMenuItem, 180); } if ($documentationMenuItem->getChildren()) { \MoufAdmin::getInstanceMenu()->addChild($documentationMenuItem); } } //\MoufAdmin::getBlock_left()->addText("<div id='relatedDocumentation'><b>Related documentation:</b>".var_export($composerJsonFiles, true)."</div>"); $this->displayComponentParents(); }
[ "protected", "function", "initController", "(", "$", "name", ",", "$", "selfedit", ")", "{", "$", "this", "->", "instanceName", "=", "$", "name", ";", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "/*$this->instance = MoufManager::getMoufManager()->g...
This function initiates the class variables of the controller according to the parameters passed. It will also configure the template to have the correct entry, especially in the right menu thazt is context dependent. @param string $name the name of the component to display @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only)
[ "This", "function", "initiates", "the", "class", "variables", "of", "the", "controller", "according", "to", "the", "parameters", "passed", ".", "It", "will", "also", "configure", "the", "template", "to", "have", "the", "correct", "entry", "especially", "in", "...
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/AbstractMoufInstanceController.php#L88-L190
38,402
thecodingmachine/mouf
src-dev/Mouf/Controllers/AbstractMoufInstanceController.php
AbstractMoufInstanceController.displayComponentParents
public function displayComponentParents() { $componentsList = $this->moufManager->getOwnerComponents($this->instanceName); $this->canBeWeak = false; if (!empty($componentsList)) { \MoufAdmin::getBlock_left()->addText("<div id='referredInstances'><b>Referred by:</b></div>"); $this->canBeWeak = true; //$children = array(); foreach ($componentsList as $component) { /*$child = new MenuItem($component, ROOT_URL.'ajaxinstance/?name='.urlencode($component)); $child->setPropagatedUrlParameters(array("selfedit")); $children[] = $child;*/ \MoufAdmin::getBlock_left()->addText("<script>MoufInstanceManager.getInstance('".addslashes($component)."').then(function(instance) { instance.render().appendTo(jQuery('#referredInstances')).click(function() { window.location.href=MoufInstanceManager.rootUrl+'ajaxinstance/?name='+encodeURIComponent(instance.getName())+'&selfedit='+MoufInstanceManager.selfEdit; }); });</script>"); } //$referredByMenuItem = new MenuItem('Referred by instances:', null, $children); //\MoufAdmin::getInstanceMenu()->addChild($referredByMenuItem); } }
php
public function displayComponentParents() { $componentsList = $this->moufManager->getOwnerComponents($this->instanceName); $this->canBeWeak = false; if (!empty($componentsList)) { \MoufAdmin::getBlock_left()->addText("<div id='referredInstances'><b>Referred by:</b></div>"); $this->canBeWeak = true; //$children = array(); foreach ($componentsList as $component) { /*$child = new MenuItem($component, ROOT_URL.'ajaxinstance/?name='.urlencode($component)); $child->setPropagatedUrlParameters(array("selfedit")); $children[] = $child;*/ \MoufAdmin::getBlock_left()->addText("<script>MoufInstanceManager.getInstance('".addslashes($component)."').then(function(instance) { instance.render().appendTo(jQuery('#referredInstances')).click(function() { window.location.href=MoufInstanceManager.rootUrl+'ajaxinstance/?name='+encodeURIComponent(instance.getName())+'&selfedit='+MoufInstanceManager.selfEdit; }); });</script>"); } //$referredByMenuItem = new MenuItem('Referred by instances:', null, $children); //\MoufAdmin::getInstanceMenu()->addChild($referredByMenuItem); } }
[ "public", "function", "displayComponentParents", "(", ")", "{", "$", "componentsList", "=", "$", "this", "->", "moufManager", "->", "getOwnerComponents", "(", "$", "this", "->", "instanceName", ")", ";", "$", "this", "->", "canBeWeak", "=", "false", ";", "if...
Displays the list of components directly referencing this component.
[ "Displays", "the", "list", "of", "components", "directly", "referencing", "this", "component", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/AbstractMoufInstanceController.php#L196-L218
38,403
thecodingmachine/mouf
src-dev/Mouf/Controllers/AbstractMoufInstanceController.php
AbstractMoufInstanceController.getValueForProperty
protected function getValueForProperty(MoufPropertyDescriptor $property) { if ($property->isPublicFieldProperty()) { $propertyName = $property->getName(); if ($this->moufManager->hasParameter($this->instanceName, $propertyName)) { $defaultValue = $this->moufManager->getParameter($this->instanceName, $propertyName); } else { $defaultValue = $this->reflectionClass->getProperty($propertyName)->getDefault(); } } else { // This is a setter. $propertyName = $property->getName(); if ($this->moufManager->hasParameterForSetter($this->instanceName, $property->getMethodName())) { $defaultValue = $this->moufManager->getParameterForSetter($this->instanceName, $property->getMethodName()); } else { // TODO: return a default value. We could try to find it using a getter maybe... // Or a default value for the setter? return null; } } return $defaultValue; }
php
protected function getValueForProperty(MoufPropertyDescriptor $property) { if ($property->isPublicFieldProperty()) { $propertyName = $property->getName(); if ($this->moufManager->hasParameter($this->instanceName, $propertyName)) { $defaultValue = $this->moufManager->getParameter($this->instanceName, $propertyName); } else { $defaultValue = $this->reflectionClass->getProperty($propertyName)->getDefault(); } } else { // This is a setter. $propertyName = $property->getName(); if ($this->moufManager->hasParameterForSetter($this->instanceName, $property->getMethodName())) { $defaultValue = $this->moufManager->getParameterForSetter($this->instanceName, $property->getMethodName()); } else { // TODO: return a default value. We could try to find it using a getter maybe... // Or a default value for the setter? return null; } } return $defaultValue; }
[ "protected", "function", "getValueForProperty", "(", "MoufPropertyDescriptor", "$", "property", ")", "{", "if", "(", "$", "property", "->", "isPublicFieldProperty", "(", ")", ")", "{", "$", "propertyName", "=", "$", "property", "->", "getName", "(", ")", ";", ...
Returns the value set for the instance passed in parameter... or the default value if the value is not set. @param MoufPropertyDescription $property @return mixed
[ "Returns", "the", "value", "set", "for", "the", "instance", "passed", "in", "parameter", "...", "or", "the", "default", "value", "if", "the", "value", "is", "not", "set", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/AbstractMoufInstanceController.php#L226-L247
38,404
thecodingmachine/mouf
src-dev/Mouf/Controllers/AbstractMoufInstanceController.php
AbstractMoufInstanceController.getTypeForProperty
protected function getTypeForProperty(MoufPropertyDescriptor $property) { if ($property->isPublicFieldProperty()) { $propertyName = $property->getName(); if ($this->moufManager->hasParameter($this->instanceName, $propertyName)) { $defaultValue = $this->moufManager->getParameterType($this->instanceName, $propertyName); } else { return "string"; } } else { // This is a setter. $propertyName = $property->getName(); if ($this->moufManager->hasParameterForSetter($this->instanceName, $property->getMethodName())) { $defaultValue = $this->moufManager->getParameterTypeForSetter($this->instanceName, $property->getMethodName()); } else { return "string"; } } return $defaultValue; }
php
protected function getTypeForProperty(MoufPropertyDescriptor $property) { if ($property->isPublicFieldProperty()) { $propertyName = $property->getName(); if ($this->moufManager->hasParameter($this->instanceName, $propertyName)) { $defaultValue = $this->moufManager->getParameterType($this->instanceName, $propertyName); } else { return "string"; } } else { // This is a setter. $propertyName = $property->getName(); if ($this->moufManager->hasParameterForSetter($this->instanceName, $property->getMethodName())) { $defaultValue = $this->moufManager->getParameterTypeForSetter($this->instanceName, $property->getMethodName()); } else { return "string"; } } return $defaultValue; }
[ "protected", "function", "getTypeForProperty", "(", "MoufPropertyDescriptor", "$", "property", ")", "{", "if", "(", "$", "property", "->", "isPublicFieldProperty", "(", ")", ")", "{", "$", "propertyName", "=", "$", "property", "->", "getName", "(", ")", ";", ...
Returns the type set for the instance passed in parameter. Type is one of string|config|request|session @param MoufPropertyDescription $property @return mixed
[ "Returns", "the", "type", "set", "for", "the", "instance", "passed", "in", "parameter", ".", "Type", "is", "one", "of", "string|config|request|session" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/AbstractMoufInstanceController.php#L256-L275
38,405
thecodingmachine/mouf
src-dev/Mouf/Controllers/AbstractMoufInstanceController.php
AbstractMoufInstanceController.getMetadataForProperty
protected function getMetadataForProperty(MoufPropertyDescriptor $property) { if ($property->isPublicFieldProperty()) { $propertyName = $property->getName(); if ($this->moufManager->hasParameter($this->instanceName, $propertyName)) { $defaultValue = $this->moufManager->getParameterMetadata($this->instanceName, $propertyName); } else { return array(); } } else { // This is a setter. $propertyName = $property->getName(); if ($this->moufManager->hasParameterForSetter($this->instanceName, $property->getMethodName())) { $defaultValue = $this->moufManager->getParameterMetadataForSetter($this->instanceName, $property->getMethodName()); } else { return array(); } } return $defaultValue; }
php
protected function getMetadataForProperty(MoufPropertyDescriptor $property) { if ($property->isPublicFieldProperty()) { $propertyName = $property->getName(); if ($this->moufManager->hasParameter($this->instanceName, $propertyName)) { $defaultValue = $this->moufManager->getParameterMetadata($this->instanceName, $propertyName); } else { return array(); } } else { // This is a setter. $propertyName = $property->getName(); if ($this->moufManager->hasParameterForSetter($this->instanceName, $property->getMethodName())) { $defaultValue = $this->moufManager->getParameterMetadataForSetter($this->instanceName, $property->getMethodName()); } else { return array(); } } return $defaultValue; }
[ "protected", "function", "getMetadataForProperty", "(", "MoufPropertyDescriptor", "$", "property", ")", "{", "if", "(", "$", "property", "->", "isPublicFieldProperty", "(", ")", ")", "{", "$", "propertyName", "=", "$", "property", "->", "getName", "(", ")", ";...
Returns the metadata for the instance passed in parameter. @param MoufPropertyDescription $property @return array
[ "Returns", "the", "metadata", "for", "the", "instance", "passed", "in", "parameter", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/AbstractMoufInstanceController.php#L283-L302
38,406
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufInstallController.php
MoufInstallController.htaccessNotDetected
public function htaccessNotDetected() { $this->contentBlock->addFile(dirname(__FILE__)."/../../views/mouf_installer/missing_htaccess.php", $this); $this->template->toHtml(); }
php
public function htaccessNotDetected() { $this->contentBlock->addFile(dirname(__FILE__)."/../../views/mouf_installer/missing_htaccess.php", $this); $this->template->toHtml(); }
[ "public", "function", "htaccessNotDetected", "(", ")", "{", "$", "this", "->", "contentBlock", "->", "addFile", "(", "dirname", "(", "__FILE__", ")", ".", "\"/../../views/mouf_installer/missing_htaccess.php\"", ",", "$", "this", ")", ";", "$", "this", "->", "tem...
This page displays an error saying the .htaccess file was ignored by Apache.
[ "This", "page", "displays", "an", "error", "saying", "the", ".", "htaccess", "file", "was", "ignored", "by", "Apache", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufInstallController.php#L76-L80
38,407
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufInstallController.php
MoufInstallController.install
public function install() { if (file_exists(__DIR__.'/../../../../../../mouf/no_commit/MoufUsers.php')) { $this->contentBlock->addFile(dirname(__FILE__)."/../../views/mouf_installer/moufusers_exists.php", $this); $this->template->toHtml(); return; } $oldUmask = umask(); umask(0); // Now, let's write the basic Mouf files: if (!file_exists(__DIR__."/../../../../../../mouf")) { mkdir(__DIR__."/../../../../../../mouf", 0775); } if (!file_exists(__DIR__."/../../../../../../mouf/no_commit")) { mkdir(__DIR__."/../../../../../../mouf/no_commit", 0775); } // Write Mouf.php (always): //if (!file_exists(__DIR__."/../../../../../../mouf/Mouf.php")) { $moufStr = "<?php define('ROOT_PATH', realpath(__DIR__.'/..').DIRECTORY_SEPARATOR); require_once __DIR__.'/../config.php'; if (defined('ROOT_URL')) { define('MOUF_URL', ROOT_URL.'vendor/mouf/mouf/'); } require_once __DIR__.'/../vendor/autoload.php'; require_once 'MoufComponents.php'; ?>"; file_put_contents(__DIR__."/../../../../../../mouf/Mouf.php", $moufStr); // Change rights on Mouf.php, but ignore errors (the file might be writable but still belong to someone else). @chmod(__DIR__."/../../../../../../mouf/Mouf.php", 0664); //} // Write MoufComponents.php: if (!file_exists(__DIR__."/../../../../../../mouf/MoufComponents.php")) { $moufComponentsStr = "<?php /** * This is a file automatically generated by the Mouf framework. Do not modify it, as it could be overwritten. */ use Mouf\MoufManager; MoufManager::initMoufManager(); \$moufManager = MoufManager::getMoufManager(); ?>"; file_put_contents(__DIR__."/../../../../../../mouf/MoufComponents.php", $moufComponentsStr); chmod(__DIR__."/../../../../../../mouf/MoufComponents.php", 0664); } // Finally, let's generate the MoufUI.php file: if (!file_exists(__DIR__."/../../../../../../mouf/MoufUI.php")) { $moufUIStr = "<?php /** * This is a file automatically generated by the Mouf framework. Do not modify it, as it could be overwritten. */ ?>"; file_put_contents(__DIR__."/../../../../../../mouf/MoufUI.php", $moufUIStr); chmod(__DIR__."/../../../../../../mouf/MoufUI.php", 0664); } // Finally 2, let's generate the config.php file: if (!file_exists(__DIR__."/../../../../../../config.php")) { $moufConfig = "<?php /** * This is a file automatically generated by the Mouf framework. Do not modify it, as it could be overwritten. * Use the UI to edit it instead. */ ?>"; file_put_contents(__DIR__."/../../../../../../config.php", $moufConfig); chmod(__DIR__."/../../../../../../config.php", 0664); } // Finally 3 :), let's generate the MoufUsers.php file: if (!file_exists(__DIR__."/../../../../../../mouf/no_commit/MoufUsers.php")) { $moufConfig = "<?php /** * This contains the users allowed to access the Mouf framework. */ \$users[".var_export(userinput_to_plainstring($_REQUEST['login']), true)."] = array('password'=>".var_export(sha1(userinput_to_plainstring($_REQUEST['password'])), true).", 'options'=>null); ?>"; file_put_contents(__DIR__."/../../../../../../mouf/no_commit/MoufUsers.php", $moufConfig); chmod(__DIR__."/../../../../../../mouf/no_commit/MoufUsers.php", 0664); } umask($oldUmask); header("Location: ".ROOT_URL); }
php
public function install() { if (file_exists(__DIR__.'/../../../../../../mouf/no_commit/MoufUsers.php')) { $this->contentBlock->addFile(dirname(__FILE__)."/../../views/mouf_installer/moufusers_exists.php", $this); $this->template->toHtml(); return; } $oldUmask = umask(); umask(0); // Now, let's write the basic Mouf files: if (!file_exists(__DIR__."/../../../../../../mouf")) { mkdir(__DIR__."/../../../../../../mouf", 0775); } if (!file_exists(__DIR__."/../../../../../../mouf/no_commit")) { mkdir(__DIR__."/../../../../../../mouf/no_commit", 0775); } // Write Mouf.php (always): //if (!file_exists(__DIR__."/../../../../../../mouf/Mouf.php")) { $moufStr = "<?php define('ROOT_PATH', realpath(__DIR__.'/..').DIRECTORY_SEPARATOR); require_once __DIR__.'/../config.php'; if (defined('ROOT_URL')) { define('MOUF_URL', ROOT_URL.'vendor/mouf/mouf/'); } require_once __DIR__.'/../vendor/autoload.php'; require_once 'MoufComponents.php'; ?>"; file_put_contents(__DIR__."/../../../../../../mouf/Mouf.php", $moufStr); // Change rights on Mouf.php, but ignore errors (the file might be writable but still belong to someone else). @chmod(__DIR__."/../../../../../../mouf/Mouf.php", 0664); //} // Write MoufComponents.php: if (!file_exists(__DIR__."/../../../../../../mouf/MoufComponents.php")) { $moufComponentsStr = "<?php /** * This is a file automatically generated by the Mouf framework. Do not modify it, as it could be overwritten. */ use Mouf\MoufManager; MoufManager::initMoufManager(); \$moufManager = MoufManager::getMoufManager(); ?>"; file_put_contents(__DIR__."/../../../../../../mouf/MoufComponents.php", $moufComponentsStr); chmod(__DIR__."/../../../../../../mouf/MoufComponents.php", 0664); } // Finally, let's generate the MoufUI.php file: if (!file_exists(__DIR__."/../../../../../../mouf/MoufUI.php")) { $moufUIStr = "<?php /** * This is a file automatically generated by the Mouf framework. Do not modify it, as it could be overwritten. */ ?>"; file_put_contents(__DIR__."/../../../../../../mouf/MoufUI.php", $moufUIStr); chmod(__DIR__."/../../../../../../mouf/MoufUI.php", 0664); } // Finally 2, let's generate the config.php file: if (!file_exists(__DIR__."/../../../../../../config.php")) { $moufConfig = "<?php /** * This is a file automatically generated by the Mouf framework. Do not modify it, as it could be overwritten. * Use the UI to edit it instead. */ ?>"; file_put_contents(__DIR__."/../../../../../../config.php", $moufConfig); chmod(__DIR__."/../../../../../../config.php", 0664); } // Finally 3 :), let's generate the MoufUsers.php file: if (!file_exists(__DIR__."/../../../../../../mouf/no_commit/MoufUsers.php")) { $moufConfig = "<?php /** * This contains the users allowed to access the Mouf framework. */ \$users[".var_export(userinput_to_plainstring($_REQUEST['login']), true)."] = array('password'=>".var_export(sha1(userinput_to_plainstring($_REQUEST['password'])), true).", 'options'=>null); ?>"; file_put_contents(__DIR__."/../../../../../../mouf/no_commit/MoufUsers.php", $moufConfig); chmod(__DIR__."/../../../../../../mouf/no_commit/MoufUsers.php", 0664); } umask($oldUmask); header("Location: ".ROOT_URL); }
[ "public", "function", "install", "(", ")", "{", "if", "(", "file_exists", "(", "__DIR__", ".", "'/../../../../../../mouf/no_commit/MoufUsers.php'", ")", ")", "{", "$", "this", "->", "contentBlock", "->", "addFile", "(", "dirname", "(", "__FILE__", ")", ".", "\...
Performs the installation by creating all required files. @URL install
[ "Performs", "the", "installation", "by", "creating", "all", "required", "files", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufInstallController.php#L87-L190
38,408
thecodingmachine/mouf
src/Mouf/Reflection/MoufXmlReflectionMethod.php
MoufXmlReflectionMethod.getParameter
public function getParameter($name) { foreach ($this->xmlRoot->parameter as $parameter) { if ($method['name'] == $name) { $moufRefParameter = new MoufXmlReflectionParameter($this, $parameter); return $moufRefParameter; } } return null; }
php
public function getParameter($name) { foreach ($this->xmlRoot->parameter as $parameter) { if ($method['name'] == $name) { $moufRefParameter = new MoufXmlReflectionParameter($this, $parameter); return $moufRefParameter; } } return null; }
[ "public", "function", "getParameter", "(", "$", "name", ")", "{", "foreach", "(", "$", "this", "->", "xmlRoot", "->", "parameter", "as", "$", "parameter", ")", "{", "if", "(", "$", "method", "[", "'name'", "]", "==", "$", "name", ")", "{", "$", "mo...
returns the specified parameter or null if it does not exist @param string $name name of parameter to return @return MoufXmlParameterMethod
[ "returns", "the", "specified", "parameter", "or", "null", "if", "it", "does", "not", "exist" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufXmlReflectionMethod.php#L219-L228
38,409
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufController.php
MoufController.getAnonymousInstanceName
private function getAnonymousInstanceName($instanceName) { // Let's find a name for this anonymous instance $anonInstanceName = $instanceName; // Let's find where the anonymous instance is used. do { $parents = $this->moufManager->getOwnerComponents($anonInstanceName); // There should be only one parent, since this is an anonymous instance $anonInstanceName = current($parents); } while ($this->moufManager->getInstanceDescriptor($anonInstanceName)->isAnonymous()); return "Anonymous (parent: ".$anonInstanceName.")"; }
php
private function getAnonymousInstanceName($instanceName) { // Let's find a name for this anonymous instance $anonInstanceName = $instanceName; // Let's find where the anonymous instance is used. do { $parents = $this->moufManager->getOwnerComponents($anonInstanceName); // There should be only one parent, since this is an anonymous instance $anonInstanceName = current($parents); } while ($this->moufManager->getInstanceDescriptor($anonInstanceName)->isAnonymous()); return "Anonymous (parent: ".$anonInstanceName.")"; }
[ "private", "function", "getAnonymousInstanceName", "(", "$", "instanceName", ")", "{", "// Let's find a name for this anonymous instance", "$", "anonInstanceName", "=", "$", "instanceName", ";", "// Let's find where the anonymous instance is used.", "do", "{", "$", "parents", ...
Returns a printable name for this anonymous instance. @param string $instanceName @return string
[ "Returns", "a", "printable", "name", "for", "this", "anonymous", "instance", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufController.php#L370-L381
38,410
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufController.php
MoufController.instancesByDate
public function instancesByDate($selfedit = "false") { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->contentBlock->addFile(dirname(__FILE__)."/../views/listComponents.php", $this); $this->template->toHtml(); }
php
public function instancesByDate($selfedit = "false") { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->contentBlock->addFile(dirname(__FILE__)."/../views/listComponents.php", $this); $this->template->toHtml(); }
[ "public", "function", "instancesByDate", "(", "$", "selfedit", "=", "\"false\"", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "if", "(", "$", "selfedit", "==", "\"true\"", ")", "{", "$", "this", "->", "moufManager", "=", "MoufManag...
Lists all the components available, ordered by creation date, in order to edit them. @Action @Logged
[ "Lists", "all", "the", "components", "available", "ordered", "by", "creation", "date", "in", "order", "to", "edit", "them", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufController.php#L389-L400
38,411
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufController.php
MoufController.refreshNewInstance
public function refreshNewInstance($selfedit = "false", $instanceName=null, $instanceClass=null) { $moufCache = new MoufCache(); $moufCache->purgeAll(); header("Location: newInstance2?selfedit=".$selfedit."&instanceName=".urlencode($instanceName)."&instanceClass=".urlencode($instanceClass)); }
php
public function refreshNewInstance($selfedit = "false", $instanceName=null, $instanceClass=null) { $moufCache = new MoufCache(); $moufCache->purgeAll(); header("Location: newInstance2?selfedit=".$selfedit."&instanceName=".urlencode($instanceName)."&instanceClass=".urlencode($instanceClass)); }
[ "public", "function", "refreshNewInstance", "(", "$", "selfedit", "=", "\"false\"", ",", "$", "instanceName", "=", "null", ",", "$", "instanceClass", "=", "null", ")", "{", "$", "moufCache", "=", "new", "MoufCache", "(", ")", ";", "$", "moufCache", "->", ...
Purge the cache and redisplays the screen allowing to create new instances. @Action @Logged
[ "Purge", "the", "cache", "and", "redisplays", "the", "screen", "allowing", "to", "create", "new", "instances", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufController.php#L441-L446
38,412
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufController.php
MoufController.createComponent
public function createComponent($instanceName, $instanceClass, $selfedit) { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->moufManager->declareComponent($instanceName, $instanceClass); $this->moufManager->rewriteMouf(); // Redirect to the display component page: $this->displayComponent($instanceName, $selfedit); }
php
public function createComponent($instanceName, $instanceClass, $selfedit) { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->moufManager->declareComponent($instanceName, $instanceClass); $this->moufManager->rewriteMouf(); // Redirect to the display component page: $this->displayComponent($instanceName, $selfedit); }
[ "public", "function", "createComponent", "(", "$", "instanceName", ",", "$", "instanceClass", ",", "$", "selfedit", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "if", "(", "$", "selfedit", "==", "\"true\"", ")", "{", "$", "this", ...
The action that creates a new component instance. @Action @Logged @param string $instanceName The name of the instance to create @param string $instanceClass The class of the component to create
[ "The", "action", "that", "creates", "a", "new", "component", "instance", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufController.php#L464-L479
38,413
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufController.php
MoufController.deleteInstance
public function deleteInstance($selfedit = "false", $instanceName=null, $returnurl = null) { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->moufManager->removeComponent($instanceName); $this->moufManager->rewriteMouf(); if ($returnurl) { header("Location:".$returnurl); } else { header("Location: .?selfedit=".$selfedit); } }
php
public function deleteInstance($selfedit = "false", $instanceName=null, $returnurl = null) { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->moufManager->removeComponent($instanceName); $this->moufManager->rewriteMouf(); if ($returnurl) { header("Location:".$returnurl); } else { header("Location: .?selfedit=".$selfedit); } }
[ "public", "function", "deleteInstance", "(", "$", "selfedit", "=", "\"false\"", ",", "$", "instanceName", "=", "null", ",", "$", "returnurl", "=", "null", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "if", "(", "$", "selfedit", "...
Removes the instance passed in parameter. @Action @Logged
[ "Removes", "the", "instance", "passed", "in", "parameter", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufController.php#L487-L504
38,414
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufController.php
MoufController.deleteInstances
public function deleteInstances($selfedit = "false", $instancesNames = array(), $returnurl = null) { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } if(!empty($instancesNames)) { foreach($instancesNames as $instanceName) { $this->moufManager->removeComponent($instanceName); } $this->moufManager->rewriteMouf(); } if ($returnurl) { header("Location:".$returnurl); } else { header("Location: .?selfedit=".$selfedit); } }
php
public function deleteInstances($selfedit = "false", $instancesNames = array(), $returnurl = null) { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } if(!empty($instancesNames)) { foreach($instancesNames as $instanceName) { $this->moufManager->removeComponent($instanceName); } $this->moufManager->rewriteMouf(); } if ($returnurl) { header("Location:".$returnurl); } else { header("Location: .?selfedit=".$selfedit); } }
[ "public", "function", "deleteInstances", "(", "$", "selfedit", "=", "\"false\"", ",", "$", "instancesNames", "=", "array", "(", ")", ",", "$", "returnurl", "=", "null", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "if", "(", "$",...
Removes all the instances passed in parameter @Action @Logged @param string $selfedit @param array $instancesNames @param string $returnurl @throws \Mouf\MoufException
[ "Removes", "all", "the", "instances", "passed", "in", "parameter" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufController.php#L515-L536
38,415
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufController.php
MoufController.newInstanceByCallback
public function newInstanceByCallback($selfedit = "false", $instanceName=null) { $this->instanceName = $instanceName; $this->selfedit = $selfedit; $this->contentBlock->addFile(dirname(__FILE__)."/../../views/instances/newInstanceByCallback.php", $this); $this->template->toHtml(); }
php
public function newInstanceByCallback($selfedit = "false", $instanceName=null) { $this->instanceName = $instanceName; $this->selfedit = $selfedit; $this->contentBlock->addFile(dirname(__FILE__)."/../../views/instances/newInstanceByCallback.php", $this); $this->template->toHtml(); }
[ "public", "function", "newInstanceByCallback", "(", "$", "selfedit", "=", "\"false\"", ",", "$", "instanceName", "=", "null", ")", "{", "$", "this", "->", "instanceName", "=", "$", "instanceName", ";", "$", "this", "->", "selfedit", "=", "$", "selfedit", "...
Displays the screen allowing to create a new instance by PHP code. @Action @Logged
[ "Displays", "the", "screen", "allowing", "to", "create", "a", "new", "instance", "by", "PHP", "code", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufController.php#L567-L573
38,416
thecodingmachine/mouf
src-dev/Mouf/Controllers/MoufController.php
MoufController.createInstanceByCode
public function createInstanceByCode($selfedit = "false", $instanceName=null) { if (!$instanceName) { $this->newInstanceByCallback(); return; } $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->moufManager->createInstanceByCode()->setName($instanceName); $this->moufManager->rewriteMouf(); header("Location: ".MOUF_URL."ajaxinstance/?name=".urlencode($instanceName)."&selfedit=".$selfedit); }
php
public function createInstanceByCode($selfedit = "false", $instanceName=null) { if (!$instanceName) { $this->newInstanceByCallback(); return; } $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->moufManager->createInstanceByCode()->setName($instanceName); $this->moufManager->rewriteMouf(); header("Location: ".MOUF_URL."ajaxinstance/?name=".urlencode($instanceName)."&selfedit=".$selfedit); }
[ "public", "function", "createInstanceByCode", "(", "$", "selfedit", "=", "\"false\"", ",", "$", "instanceName", "=", "null", ")", "{", "if", "(", "!", "$", "instanceName", ")", "{", "$", "this", "->", "newInstanceByCallback", "(", ")", ";", "return", ";", ...
Performs the action of creating a new instance. @Action @Logged
[ "Performs", "the", "action", "of", "creating", "a", "new", "instance", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/MoufController.php#L581-L598
38,417
thecodingmachine/mouf
src-dev/Mouf/Controllers/InstallController.php
InstallController.index
public function index($selfedit = false) { $this->selfedit = $selfedit; $this->installService = new ComposerInstaller($selfedit == 'true'); $this->installs = $this->installService->getInstallTasks(); //var_dump($this->installs);exit; $this->countNbTodo = 0; foreach ($this->installs as $installTask) { if ($installTask->getStatus() == AbstractInstallTask::STATUS_TODO) { $this->countNbTodo++; } } $this->contentBlock->addFile(dirname(__FILE__)."/../../views/installer/installTasksList.php", $this); $this->template->toHtml(); }
php
public function index($selfedit = false) { $this->selfedit = $selfedit; $this->installService = new ComposerInstaller($selfedit == 'true'); $this->installs = $this->installService->getInstallTasks(); //var_dump($this->installs);exit; $this->countNbTodo = 0; foreach ($this->installs as $installTask) { if ($installTask->getStatus() == AbstractInstallTask::STATUS_TODO) { $this->countNbTodo++; } } $this->contentBlock->addFile(dirname(__FILE__)."/../../views/installer/installTasksList.php", $this); $this->template->toHtml(); }
[ "public", "function", "index", "(", "$", "selfedit", "=", "false", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "$", "this", "->", "installService", "=", "new", "ComposerInstaller", "(", "$", "selfedit", "==", "'true'", ")", ";", ...
Displays the page to install packages @Action @Logged @param string $selfedit If true, we are in self-edit mode
[ "Displays", "the", "page", "to", "install", "packages" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/InstallController.php#L72-L86
38,418
thecodingmachine/mouf
src-dev/Mouf/Controllers/InstallController.php
InstallController.install
public function install($selfedit = 'false', $task = null) { $this->selfedit = $selfedit; $this->installService = new ComposerInstaller($selfedit == 'true'); if ($task !== null) { $taskArray = unserialize($task); } else { $taskArray = null; } if ($taskArray == null) { $this->installService->installAll(); } else { $this->installService->install($taskArray); } // The call to install or installAll redirects to printInstallationScreen. }
php
public function install($selfedit = 'false', $task = null) { $this->selfedit = $selfedit; $this->installService = new ComposerInstaller($selfedit == 'true'); if ($task !== null) { $taskArray = unserialize($task); } else { $taskArray = null; } if ($taskArray == null) { $this->installService->installAll(); } else { $this->installService->install($taskArray); } // The call to install or installAll redirects to printInstallationScreen. }
[ "public", "function", "install", "(", "$", "selfedit", "=", "'false'", ",", "$", "task", "=", "null", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "$", "this", "->", "installService", "=", "new", "ComposerInstaller", "(", "$", "s...
This page starts the install proces of one task or all tasks in "todo" state. @Action @Logged @param string $selfedit If true, we are in self-edit mode
[ "This", "page", "starts", "the", "install", "proces", "of", "one", "task", "or", "all", "tasks", "in", "todo", "state", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/InstallController.php#L98-L114
38,419
thecodingmachine/mouf
src-dev/Mouf/Controllers/InstallController.php
InstallController.printInstallationScreen
public function printInstallationScreen($selfedit = 'false') { $this->selfedit = $selfedit; $this->installService = new ComposerInstaller($selfedit == 'true'); $this->installs = $this->installService->getInstallTasks(); $this->contentBlock->addFile(dirname(__FILE__)."/../../views/installer/processing.php", $this); $this->template->toHtml(); }
php
public function printInstallationScreen($selfedit = 'false') { $this->selfedit = $selfedit; $this->installService = new ComposerInstaller($selfedit == 'true'); $this->installs = $this->installService->getInstallTasks(); $this->contentBlock->addFile(dirname(__FILE__)."/../../views/installer/processing.php", $this); $this->template->toHtml(); }
[ "public", "function", "printInstallationScreen", "(", "$", "selfedit", "=", "'false'", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "$", "this", "->", "installService", "=", "new", "ComposerInstaller", "(", "$", "selfedit", "==", "'tru...
Installation screen is displayed and the user is directly redirected via Javascript to the install page. @Action @param string $selfedit
[ "Installation", "screen", "is", "displayed", "and", "the", "user", "is", "directly", "redirected", "via", "Javascript", "to", "the", "install", "page", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/InstallController.php#L122-L129
38,420
thecodingmachine/mouf
src-dev/Mouf/Controllers/InstallController.php
InstallController.processInstall
public function processInstall($selfedit = 'false') { // Let's process install now by redirecting HERE! $this->selfedit = $selfedit; $this->installService = new ComposerInstaller($selfedit == 'true'); $installTask = $this->installService->getNextInstallTask(); header("Location: ".MOUF_URL.$installTask->getRedirectUrl($selfedit == 'true')); }
php
public function processInstall($selfedit = 'false') { // Let's process install now by redirecting HERE! $this->selfedit = $selfedit; $this->installService = new ComposerInstaller($selfedit == 'true'); $installTask = $this->installService->getNextInstallTask(); header("Location: ".MOUF_URL.$installTask->getRedirectUrl($selfedit == 'true')); }
[ "public", "function", "processInstall", "(", "$", "selfedit", "=", "'false'", ")", "{", "// Let's process install now by redirecting HERE!", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "$", "this", "->", "installService", "=", "new", "ComposerInstaller...
Starts the installation process for one package registered with install or installAll. @Action @param string $selfedit
[ "Starts", "the", "installation", "process", "for", "one", "package", "registered", "with", "install", "or", "installAll", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/InstallController.php#L137-L144
38,421
thecodingmachine/mouf
src-dev/Mouf/Controllers/InstallController.php
InstallController.installTaskDone
public function installTaskDone($selfedit = 'false') { $this->selfedit = $selfedit; $this->installService = new ComposerInstaller($selfedit == 'true'); $this->installService->validateCurrentInstall(); $installTask = $this->installService->getNextInstallTask(); if ($installTask) { $this->printInstallationScreen($selfedit); } else { set_user_message("Installation process succeeded!", UserMessageInterface::SUCCESS); header("Location: .?selfedit=".$selfedit); } }
php
public function installTaskDone($selfedit = 'false') { $this->selfedit = $selfedit; $this->installService = new ComposerInstaller($selfedit == 'true'); $this->installService->validateCurrentInstall(); $installTask = $this->installService->getNextInstallTask(); if ($installTask) { $this->printInstallationScreen($selfedit); } else { set_user_message("Installation process succeeded!", UserMessageInterface::SUCCESS); header("Location: .?selfedit=".$selfedit); } }
[ "public", "function", "installTaskDone", "(", "$", "selfedit", "=", "'false'", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "$", "this", "->", "installService", "=", "new", "ComposerInstaller", "(", "$", "selfedit", "==", "'true'", "...
Action called when a full install step has completed. @Action @param string $selfedit
[ "Action", "called", "when", "a", "full", "install", "step", "has", "completed", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/InstallController.php#L152-L166
38,422
thecodingmachine/mouf
src/Mouf/Composer/ChunckedUtils.php
ChunckedUtils.init
public static function init() { header("Transfer-Encoding: chunked"); @apache_setenv('no-gzip', 1); @ini_set('zlib.output_compression', 0); @ini_set('implicit_flush', 1); for ($i = 0; $i < ob_get_level(); $i++) ob_end_flush(); ob_implicit_flush(1); flush(); $pad = str_pad('',4096); echo dechex(strlen($pad))."\r\n"; echo $pad; echo "\r\n"; }
php
public static function init() { header("Transfer-Encoding: chunked"); @apache_setenv('no-gzip', 1); @ini_set('zlib.output_compression', 0); @ini_set('implicit_flush', 1); for ($i = 0; $i < ob_get_level(); $i++) ob_end_flush(); ob_implicit_flush(1); flush(); $pad = str_pad('',4096); echo dechex(strlen($pad))."\r\n"; echo $pad; echo "\r\n"; }
[ "public", "static", "function", "init", "(", ")", "{", "header", "(", "\"Transfer-Encoding: chunked\"", ")", ";", "@", "apache_setenv", "(", "'no-gzip'", ",", "1", ")", ";", "@", "ini_set", "(", "'zlib.output_compression'", ",", "0", ")", ";", "@", "ini_set"...
Sends the "chuncked" header to the browser announcing we will be sending chuncks.
[ "Sends", "the", "chuncked", "header", "to", "the", "browser", "announcing", "we", "will", "be", "sending", "chuncks", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Composer/ChunckedUtils.php#L15-L27
38,423
thecodingmachine/mouf
src/Mouf/Reflection/MoufXmlReflectionClass.php
MoufXmlReflectionClass.getMethodsByPattern
public function getMethodsByPattern($regex) { $methods = array(); foreach ($this->xmlRoot->method as $method) { if (preg_match("/$regex/", $method['name'])) { $moufRefMethod = new MoufXmlReflectionMethod($this, $method); $methods[] = $moufRefMethod; } } return $methods; }
php
public function getMethodsByPattern($regex) { $methods = array(); foreach ($this->xmlRoot->method as $method) { if (preg_match("/$regex/", $method['name'])) { $moufRefMethod = new MoufXmlReflectionMethod($this, $method); $methods[] = $moufRefMethod; } } return $methods; }
[ "public", "function", "getMethodsByPattern", "(", "$", "regex", ")", "{", "$", "methods", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "xmlRoot", "->", "method", "as", "$", "method", ")", "{", "if", "(", "preg_match", "(", "\"/$regex...
returns methods mathcing the given pattern @param string $regex the regular expression to match (without trailing slashes) @return array<MoufXmlReflectionMethod>
[ "returns", "methods", "mathcing", "the", "given", "pattern" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufXmlReflectionClass.php#L203-L213
38,424
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionParameter.php
MoufReflectionParameter.getDeclaringClass
public function getDeclaringClass() { if (is_array($this->routineName) === false) { return null; } $refClass = parent::getDeclaringClass(); $moufRefClass = new MoufReflectionClass($refClass->getName()); return $moufRefClass; }
php
public function getDeclaringClass() { if (is_array($this->routineName) === false) { return null; } $refClass = parent::getDeclaringClass(); $moufRefClass = new MoufReflectionClass($refClass->getName()); return $moufRefClass; }
[ "public", "function", "getDeclaringClass", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "routineName", ")", "===", "false", ")", "{", "return", "null", ";", "}", "$", "refClass", "=", "parent", "::", "getDeclaringClass", "(", ")", ";", ...
returns the class that declares this parameter @return stubReflectionClass
[ "returns", "the", "class", "that", "declares", "this", "parameter" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionParameter.php#L113-L122
38,425
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionParameter.php
MoufReflectionParameter.getClassName
function getClassName() { preg_match('/\[\s\<\w+?>\s([\w\\\\]+)/s', $this->__toString(), $matches); $class = isset($matches[1]) ? $matches[1] : null; if(in_array($class, [ 'array', 'string', 'char', 'bool', 'boolean', 'int', 'integer', 'double', 'float', 'real', 'mixed', 'number', 'null', 'callable', 'callback' ])) { return null; } return $class; }
php
function getClassName() { preg_match('/\[\s\<\w+?>\s([\w\\\\]+)/s', $this->__toString(), $matches); $class = isset($matches[1]) ? $matches[1] : null; if(in_array($class, [ 'array', 'string', 'char', 'bool', 'boolean', 'int', 'integer', 'double', 'float', 'real', 'mixed', 'number', 'null', 'callable', 'callback' ])) { return null; } return $class; }
[ "function", "getClassName", "(", ")", "{", "preg_match", "(", "'/\\[\\s\\<\\w+?>\\s([\\w\\\\\\\\]+)/s'", ",", "$", "this", "->", "__toString", "(", ")", ",", "$", "matches", ")", ";", "$", "class", "=", "isset", "(", "$", "matches", "[", "1", "]", ")", "...
Retrieve only the class name without requiring the class to exist @return string|null
[ "Retrieve", "only", "the", "class", "name", "without", "requiring", "the", "class", "to", "exist" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionParameter.php#L154-L161
38,426
thecodingmachine/mouf
src/Mouf/Reflection/MoufReflectionParameter.php
MoufReflectionParameter.toJson
public function toJson() { $result = array(); $result['name'] = $this->getName(); $result['hasDefault'] = $this->isDefaultValueAvailable(); try { if ($result['hasDefault']) { // In some cases, the call to getDefaultValue can log NOTICES // in particular if an undefined constant is used as default value. ob_start(); if ($this->isDefaultValueConstant() && !defined($this->getDefaultValueConstantName())) { throw new \Exception('Constant "'.$this->getDefaultValueConstantName().'" does not exist.'); } $result['default'] = $this->getDefaultValue(); $possibleError = ob_get_clean(); if ($possibleError) { throw new \Exception($possibleError); } } $result['isArray'] = $this->isArray(); // Let's export only the type if we are in a constructor... in order to save time. if ($this->getDeclaringFunction()->isConstructor()) { // TODO: is there a need to instanciate a MoufPropertyDescriptor? $moufPropertyDescriptor = new MoufPropertyDescriptor($this); $result['comment'] = $moufPropertyDescriptor->getDocCommentWithoutAnnotations(); $types = $moufPropertyDescriptor->getTypes(); $result['types'] = $types->toJson(); if ($types->getWarningMessage()) { $result['classinerror'] = $types->getWarningMessage(); } /*if ($moufPropertyDescriptor->isAssociativeArray()) { $result['keytype'] = $moufPropertyDescriptor->getKeyType(); } if ($moufPropertyDescriptor->isArray()) { $result['subtype'] = $moufPropertyDescriptor->getSubType(); }*/ } } catch (\Exception $e) { $result['classinerror'] = $e->getMessage(); } return $result; }
php
public function toJson() { $result = array(); $result['name'] = $this->getName(); $result['hasDefault'] = $this->isDefaultValueAvailable(); try { if ($result['hasDefault']) { // In some cases, the call to getDefaultValue can log NOTICES // in particular if an undefined constant is used as default value. ob_start(); if ($this->isDefaultValueConstant() && !defined($this->getDefaultValueConstantName())) { throw new \Exception('Constant "'.$this->getDefaultValueConstantName().'" does not exist.'); } $result['default'] = $this->getDefaultValue(); $possibleError = ob_get_clean(); if ($possibleError) { throw new \Exception($possibleError); } } $result['isArray'] = $this->isArray(); // Let's export only the type if we are in a constructor... in order to save time. if ($this->getDeclaringFunction()->isConstructor()) { // TODO: is there a need to instanciate a MoufPropertyDescriptor? $moufPropertyDescriptor = new MoufPropertyDescriptor($this); $result['comment'] = $moufPropertyDescriptor->getDocCommentWithoutAnnotations(); $types = $moufPropertyDescriptor->getTypes(); $result['types'] = $types->toJson(); if ($types->getWarningMessage()) { $result['classinerror'] = $types->getWarningMessage(); } /*if ($moufPropertyDescriptor->isAssociativeArray()) { $result['keytype'] = $moufPropertyDescriptor->getKeyType(); } if ($moufPropertyDescriptor->isArray()) { $result['subtype'] = $moufPropertyDescriptor->getSubType(); }*/ } } catch (\Exception $e) { $result['classinerror'] = $e->getMessage(); } return $result; }
[ "public", "function", "toJson", "(", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "result", "[", "'name'", "]", "=", "$", "this", "->", "getName", "(", ")", ";", "$", "result", "[", "'hasDefault'", "]", "=", "$", "this", "->", "isDe...
Returns a PHP array representing the parameter. @return array
[ "Returns", "a", "PHP", "array", "representing", "the", "parameter", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/MoufReflectionParameter.php#L201-L247
38,427
thecodingmachine/mouf
src/Mouf/Reflection/TypesDescriptor.php
TypesDescriptor.runLexer
public static function runLexer($line) { $tokens = array(); $offset = 0; while($offset < strlen($line)) { $result = static::_match($line, $offset); if($result === false) { throw new MoufException("Unable to parse line '".$line."'."); } $tokens[] = $result; $offset += strlen($result['match']); } return $tokens; }
php
public static function runLexer($line) { $tokens = array(); $offset = 0; while($offset < strlen($line)) { $result = static::_match($line, $offset); if($result === false) { throw new MoufException("Unable to parse line '".$line."'."); } $tokens[] = $result; $offset += strlen($result['match']); } return $tokens; }
[ "public", "static", "function", "runLexer", "(", "$", "line", ")", "{", "$", "tokens", "=", "array", "(", ")", ";", "$", "offset", "=", "0", ";", "while", "(", "$", "offset", "<", "strlen", "(", "$", "line", ")", ")", "{", "$", "result", "=", "...
Runs the analysis @param $line @throws MoufException @return array
[ "Runs", "the", "analysis" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/TypesDescriptor.php#L136-L149
38,428
thecodingmachine/mouf
src/Mouf/Reflection/TypesDescriptor.php
TypesDescriptor.toJson
public function toJson() { $array = array("types"=>array()); foreach ($this->types as $type) { $array["types"][] = $type->toJson(); } if ($this->warningMessage) { $array["warning"] = $this->warningMessage; } return $array; }
php
public function toJson() { $array = array("types"=>array()); foreach ($this->types as $type) { $array["types"][] = $type->toJson(); } if ($this->warningMessage) { $array["warning"] = $this->warningMessage; } return $array; }
[ "public", "function", "toJson", "(", ")", "{", "$", "array", "=", "array", "(", "\"types\"", "=>", "array", "(", ")", ")", ";", "foreach", "(", "$", "this", "->", "types", "as", "$", "type", ")", "{", "$", "array", "[", "\"types\"", "]", "[", "]"...
Returns a PHP array representing the TypesDescriptor @return array
[ "Returns", "a", "PHP", "array", "representing", "the", "TypesDescriptor" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/TypesDescriptor.php#L156-L165
38,429
thecodingmachine/mouf
src/Mouf/Reflection/TypesDescriptor.php
TypesDescriptor.getCompatibleTypeForInstance
public function getCompatibleTypeForInstance($value) { foreach ($this->types as $type) { if ($type->isCompatible($value)) { return $type; } } return null; }
php
public function getCompatibleTypeForInstance($value) { foreach ($this->types as $type) { if ($type->isCompatible($value)) { return $type; } } return null; }
[ "public", "function", "getCompatibleTypeForInstance", "(", "$", "value", ")", "{", "foreach", "(", "$", "this", "->", "types", "as", "$", "type", ")", "{", "if", "(", "$", "type", "->", "isCompatible", "(", "$", "value", ")", ")", "{", "return", "$", ...
Returns the TypeDescriptor that is part of these types that is the most likely to fit the propertyDescriptor's value passed in parameter. Returns null if no type is compatible. @param string|array|MoufInstanceDescriptor|MoufInstanceDescriptor[] $instanceDescriptor @return TypeDescriptor
[ "Returns", "the", "TypeDescriptor", "that", "is", "part", "of", "these", "types", "that", "is", "the", "most", "likely", "to", "fit", "the", "propertyDescriptor", "s", "value", "passed", "in", "parameter", ".", "Returns", "null", "if", "no", "type", "is", ...
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/TypesDescriptor.php#L196-L203
38,430
thecodingmachine/mouf
src-dev/Mouf/Validator/MoufBasicValidationProvider.php
MoufBasicValidationProvider.getUrl
public function getUrl() { $url = $this->url; $params = array(); // First, get the list of all parameters to be propagated if (is_array($this->propagatedUrlParameters)) { foreach ($this->propagatedUrlParameters as $parameter) { if (isset($_REQUEST[$parameter])) { $params[$parameter] = get($parameter); } } } if (!empty($params)) { if (strpos($url, "?") === FALSE) { $url .= "?"; } else { $url .= "&"; } $paramsAsStrArray = array(); foreach ($params as $key=>$value) { $paramsAsStrArray[] = urlencode($key).'='.urlencode($value); } $url .= implode("&", $paramsAsStrArray); } return $url; }
php
public function getUrl() { $url = $this->url; $params = array(); // First, get the list of all parameters to be propagated if (is_array($this->propagatedUrlParameters)) { foreach ($this->propagatedUrlParameters as $parameter) { if (isset($_REQUEST[$parameter])) { $params[$parameter] = get($parameter); } } } if (!empty($params)) { if (strpos($url, "?") === FALSE) { $url .= "?"; } else { $url .= "&"; } $paramsAsStrArray = array(); foreach ($params as $key=>$value) { $paramsAsStrArray[] = urlencode($key).'='.urlencode($value); } $url .= implode("&", $paramsAsStrArray); } return $url; }
[ "public", "function", "getUrl", "(", ")", "{", "$", "url", "=", "$", "this", "->", "url", ";", "$", "params", "=", "array", "(", ")", ";", "// First, get the list of all parameters to be propagated\r", "if", "(", "is_array", "(", "$", "this", "->", "propagat...
Returns the URL that will be called for that validator. The URL is relative to the ROOT_URL. The URL will return HTML code that will directly be displayed in the Mouf validation screen. @return string
[ "Returns", "the", "URL", "that", "will", "be", "called", "for", "that", "validator", ".", "The", "URL", "is", "relative", "to", "the", "ROOT_URL", ".", "The", "URL", "will", "return", "HTML", "code", "that", "will", "directly", "be", "displayed", "in", "...
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Validator/MoufBasicValidationProvider.php#L72-L99
38,431
Lecturize/Laravel-Taxonomies
src/Models/Term.php
Term.getDisplayName
public function getDisplayName($locale = '', $limit = 0) { $locale = $locale ?: app()->getLocale(); $property_with_locale = $locale === 'en' ? "name" : "name_$locale"; $name = property_exists($this, $property_with_locale) ? $this->{$property_with_locale} : $this->name; return $limit > 0 ? str_limit($name, $limit) : $name; }
php
public function getDisplayName($locale = '', $limit = 0) { $locale = $locale ?: app()->getLocale(); $property_with_locale = $locale === 'en' ? "name" : "name_$locale"; $name = property_exists($this, $property_with_locale) ? $this->{$property_with_locale} : $this->name; return $limit > 0 ? str_limit($name, $limit) : $name; }
[ "public", "function", "getDisplayName", "(", "$", "locale", "=", "''", ",", "$", "limit", "=", "0", ")", "{", "$", "locale", "=", "$", "locale", "?", ":", "app", "(", ")", "->", "getLocale", "(", ")", ";", "$", "property_with_locale", "=", "$", "lo...
Get display name. @param string $locale @param int $limit @return mixed
[ "Get", "display", "name", "." ]
46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be
https://github.com/Lecturize/Laravel-Taxonomies/blob/46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be/src/Models/Term.php#L75-L84
38,432
Lecturize/Laravel-Taxonomies
src/Models/Term.php
Term.getRouteParameters
public function getRouteParameters($taxonomy) { $taxonomy = Taxonomy::taxonomy($taxonomy) ->term($this->name) ->with('parent') ->first(); $parameters = $this->getParentSlugs($taxonomy); array_push($parameters, $taxonomy->taxonomy); return array_reverse($parameters); }
php
public function getRouteParameters($taxonomy) { $taxonomy = Taxonomy::taxonomy($taxonomy) ->term($this->name) ->with('parent') ->first(); $parameters = $this->getParentSlugs($taxonomy); array_push($parameters, $taxonomy->taxonomy); return array_reverse($parameters); }
[ "public", "function", "getRouteParameters", "(", "$", "taxonomy", ")", "{", "$", "taxonomy", "=", "Taxonomy", "::", "taxonomy", "(", "$", "taxonomy", ")", "->", "term", "(", "$", "this", "->", "name", ")", "->", "with", "(", "'parent'", ")", "->", "fir...
Get route parameters. @param string $taxonomy @return mixed
[ "Get", "route", "parameters", "." ]
46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be
https://github.com/Lecturize/Laravel-Taxonomies/blob/46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be/src/Models/Term.php#L92-L104
38,433
Lecturize/Laravel-Taxonomies
src/Models/Term.php
Term.getParentSlugs
function getParentSlugs(Taxonomy $taxonomy, $parameters = []) { array_push($parameters, $taxonomy->term->slug); if (($parents = $taxonomy->parent()) && ($parent = $parents->first())) return $this->getParentSlugs($parent, $parameters); return $parameters; }
php
function getParentSlugs(Taxonomy $taxonomy, $parameters = []) { array_push($parameters, $taxonomy->term->slug); if (($parents = $taxonomy->parent()) && ($parent = $parents->first())) return $this->getParentSlugs($parent, $parameters); return $parameters; }
[ "function", "getParentSlugs", "(", "Taxonomy", "$", "taxonomy", ",", "$", "parameters", "=", "[", "]", ")", "{", "array_push", "(", "$", "parameters", ",", "$", "taxonomy", "->", "term", "->", "slug", ")", ";", "if", "(", "(", "$", "parents", "=", "$...
Get slugs of parent terms. @param Taxonomy $taxonomy @param array $parameters @return array
[ "Get", "slugs", "of", "parent", "terms", "." ]
46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be
https://github.com/Lecturize/Laravel-Taxonomies/blob/46774dbfef61131cf8f3fd9a2ab5c2ef4fccd6be/src/Models/Term.php#L113-L121
38,434
thecodingmachine/mouf
src-dev/Mouf/Controllers/SearchController.php
SearchController.defaultAction
public function defaultAction($query, $selfedit = "false") { $this->selfedit = $selfedit; $this->query = $query; /*if ($selfedit == "true") {*/ $this->moufManager = MoufManager::getMoufManager(); /*} else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); }*/ $this->searchUrls = array(); foreach ($this->searchService->searchableServices as $service) { /* @var $service MoufSearchable */ $this->searchUrls[] = array("name"=>$service->getSearchModuleName(), "url"=>ROOT_URL.$this->moufManager->findInstanceName($service)."/search"); } $this->contentBlock->addFile(ROOT_PATH."src-dev/views/search/results.php", $this); $this->template->toHtml(); }
php
public function defaultAction($query, $selfedit = "false") { $this->selfedit = $selfedit; $this->query = $query; /*if ($selfedit == "true") {*/ $this->moufManager = MoufManager::getMoufManager(); /*} else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); }*/ $this->searchUrls = array(); foreach ($this->searchService->searchableServices as $service) { /* @var $service MoufSearchable */ $this->searchUrls[] = array("name"=>$service->getSearchModuleName(), "url"=>ROOT_URL.$this->moufManager->findInstanceName($service)."/search"); } $this->contentBlock->addFile(ROOT_PATH."src-dev/views/search/results.php", $this); $this->template->toHtml(); }
[ "public", "function", "defaultAction", "(", "$", "query", ",", "$", "selfedit", "=", "\"false\"", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "$", "this", "->", "query", "=", "$", "query", ";", "/*if ($selfedit == \"true\") {*/", "$...
Performs a full-text search in Mouf. @Action @Logged @param string $query The text to search. @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only)
[ "Performs", "a", "full", "-", "text", "search", "in", "Mouf", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/SearchController.php#L70-L88
38,435
thecodingmachine/mouf
src/Mouf/Validator/CheckConstructorLoopValidator.php
CheckConstructorLoopValidator.validateClass
public static function validateClass() { $moufManager = MoufManager::getMoufManager(); try { $moufManager->checkConstructorLoop(); return new MoufValidatorResult(MoufValidatorResult::SUCCESS, "No loop detected in constructor arguments."); } catch(MoufException $e) { return new MoufValidatorResult(MoufValidatorResult::ERROR, '<b>'.$e->getMessage().'</b><br /><br /> Please check yours instances to refactor your code and change your code architecture.<br /> The other ugly solution is to make a setter for one of this parameter to remove it from constructor argument'); } }
php
public static function validateClass() { $moufManager = MoufManager::getMoufManager(); try { $moufManager->checkConstructorLoop(); return new MoufValidatorResult(MoufValidatorResult::SUCCESS, "No loop detected in constructor arguments."); } catch(MoufException $e) { return new MoufValidatorResult(MoufValidatorResult::ERROR, '<b>'.$e->getMessage().'</b><br /><br /> Please check yours instances to refactor your code and change your code architecture.<br /> The other ugly solution is to make a setter for one of this parameter to remove it from constructor argument'); } }
[ "public", "static", "function", "validateClass", "(", ")", "{", "$", "moufManager", "=", "MoufManager", "::", "getMoufManager", "(", ")", ";", "try", "{", "$", "moufManager", "->", "checkConstructorLoop", "(", ")", ";", "return", "new", "MoufValidatorResult", ...
Check all constructor arguments to detect a loop @return MoufValidatorResult
[ "Check", "all", "constructor", "arguments", "to", "detect", "a", "loop" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Validator/CheckConstructorLoopValidator.php#L18-L30
38,436
thecodingmachine/mouf
src/Mouf/Reflection/TypeDescriptor.php
TypeDescriptor.isPrimitiveTypesOrRecursiveArrayOfPrimitiveTypes
public function isPrimitiveTypesOrRecursiveArrayOfPrimitiveTypes() { if ($this->isPrimitiveType()) { return true; } if ($this->subType) { return $this->subType->isPrimitiveTypesOrRecursiveArrayOfPrimitiveTypes(); } return false; }
php
public function isPrimitiveTypesOrRecursiveArrayOfPrimitiveTypes() { if ($this->isPrimitiveType()) { return true; } if ($this->subType) { return $this->subType->isPrimitiveTypesOrRecursiveArrayOfPrimitiveTypes(); } return false; }
[ "public", "function", "isPrimitiveTypesOrRecursiveArrayOfPrimitiveTypes", "(", ")", "{", "if", "(", "$", "this", "->", "isPrimitiveType", "(", ")", ")", "{", "return", "true", ";", "}", "if", "(", "$", "this", "->", "subType", ")", "{", "return", "$", "thi...
Returns true if the type passed in parameter is primitive or an array of primitive type or an array of array of primitive type, etc... @param string $type @return bool
[ "Returns", "true", "if", "the", "type", "passed", "in", "parameter", "is", "primitive", "or", "an", "array", "of", "primitive", "type", "or", "an", "array", "of", "array", "of", "primitive", "type", "etc", "..." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/TypeDescriptor.php#L246-L254
38,437
thecodingmachine/mouf
src/Mouf/Reflection/TypeDescriptor.php
TypeDescriptor.isCompatible
public function isCompatible($value) { // If null, we are compatible if ($value === null) { return true; } // If the value passed is an array if (is_array($value)) { // Let's check if this type is an array. if (!$this->isArray()) { return false; } if (!$this->isAssociativeArray()) { // Let's check if the array passed in parameter has string values as keys. foreach ($value as $key=>$val) { if (is_string($key)) { return false; } } } // Now, let's test each subkey for compatibility foreach ($value as $key=>$val) { if (!$this->subType->isCompatible($val)) { return false; } } return true; } elseif ($value instanceof MoufInstanceDescriptor) { // Let's check if the instance descriptor is compatible with our type. if ($this->isPrimitiveType()) { return false; } if ($this->type == "array") { return false; } $classDescriptor = $value->getClassDescriptor(); if (ltrim($this->type,'\\') == ltrim($classDescriptor->getName(), '\\')) { return true; } //$type = new MoufReflectionClass($this->getType()); $result = $classDescriptor->isSubclassOf($this->getType()); return $result; } else { // The value is a primitive type. if ($this->isPrimitiveType()) { return true; } else { return false; } } }
php
public function isCompatible($value) { // If null, we are compatible if ($value === null) { return true; } // If the value passed is an array if (is_array($value)) { // Let's check if this type is an array. if (!$this->isArray()) { return false; } if (!$this->isAssociativeArray()) { // Let's check if the array passed in parameter has string values as keys. foreach ($value as $key=>$val) { if (is_string($key)) { return false; } } } // Now, let's test each subkey for compatibility foreach ($value as $key=>$val) { if (!$this->subType->isCompatible($val)) { return false; } } return true; } elseif ($value instanceof MoufInstanceDescriptor) { // Let's check if the instance descriptor is compatible with our type. if ($this->isPrimitiveType()) { return false; } if ($this->type == "array") { return false; } $classDescriptor = $value->getClassDescriptor(); if (ltrim($this->type,'\\') == ltrim($classDescriptor->getName(), '\\')) { return true; } //$type = new MoufReflectionClass($this->getType()); $result = $classDescriptor->isSubclassOf($this->getType()); return $result; } else { // The value is a primitive type. if ($this->isPrimitiveType()) { return true; } else { return false; } } }
[ "public", "function", "isCompatible", "(", "$", "value", ")", "{", "// If null, we are compatible", "if", "(", "$", "value", "===", "null", ")", "{", "return", "true", ";", "}", "// If the value passed is an array", "if", "(", "is_array", "(", "$", "value", ")...
Returns true if this type is compatible with the propertyDescriptor's value passed in parameter. @param string|array|MoufInstanceDescriptor|MoufInstanceDescriptor[] $instanceDescriptor @return bool
[ "Returns", "true", "if", "this", "type", "is", "compatible", "with", "the", "propertyDescriptor", "s", "value", "passed", "in", "parameter", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src/Mouf/Reflection/TypeDescriptor.php#L263-L313
38,438
thecodingmachine/mouf
src-dev/Mouf/Controllers/ConfigController.php
ConfigController.index
public function index($selfedit = "false", $validation = null) { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } //$this->constantsList = $this->moufManager->getConfigManager()->getDefinedConstants(); $this->constantsList = $this->moufManager->getConfigManager()->getMergedConstants(); $this->contentBlock->addFile(ROOT_PATH."src-dev/views/constants/displayConstantsList.php", $this); $this->template->toHtml(); }
php
public function index($selfedit = "false", $validation = null) { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } //$this->constantsList = $this->moufManager->getConfigManager()->getDefinedConstants(); $this->constantsList = $this->moufManager->getConfigManager()->getMergedConstants(); $this->contentBlock->addFile(ROOT_PATH."src-dev/views/constants/displayConstantsList.php", $this); $this->template->toHtml(); }
[ "public", "function", "index", "(", "$", "selfedit", "=", "\"false\"", ",", "$", "validation", "=", "null", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "if", "(", "$", "selfedit", "==", "\"true\"", ")", "{", "$", "this", "->",...
Displays the list of defined parameters in config.php @Action @Logged @param string $selfedit If true, the name of the component must be a component from the Mouf framework itself (internal use only) @param string $validation The validation message to display (either null, or confirmok).
[ "Displays", "the", "list", "of", "defined", "parameters", "in", "config", ".", "php" ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/ConfigController.php#L73-L86
38,439
thecodingmachine/mouf
src-dev/Mouf/Controllers/ConfigController.php
ConfigController.saveConfig
public function saveConfig($selfedit = "false") { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->configManager = $this->moufManager->getConfigManager(); $this->constantsList = $this->configManager->getMergedConstants(); $constants = array(); foreach ($this->constantsList as $key=>$def) { if ($def['defined'] == true && $def['type'] == 'bool') { $constants[$key] = (get($key)=="true")?true:false; } else { $constants[$key] = get($key); } } $this->configManager->setDefinedConstants($constants); header("Location: .?selfedit=".$selfedit); }
php
public function saveConfig($selfedit = "false") { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->configManager = $this->moufManager->getConfigManager(); $this->constantsList = $this->configManager->getMergedConstants(); $constants = array(); foreach ($this->constantsList as $key=>$def) { if ($def['defined'] == true && $def['type'] == 'bool') { $constants[$key] = (get($key)=="true")?true:false; } else { $constants[$key] = get($key); } } $this->configManager->setDefinedConstants($constants); header("Location: .?selfedit=".$selfedit); }
[ "public", "function", "saveConfig", "(", "$", "selfedit", "=", "\"false\"", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "if", "(", "$", "selfedit", "==", "\"true\"", ")", "{", "$", "this", "->", "moufManager", "=", "MoufManager", ...
The action to save the configuration. @Action @Logged @Post
[ "The", "action", "to", "save", "the", "configuration", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/ConfigController.php#L95-L118
38,440
thecodingmachine/mouf
src-dev/Mouf/Controllers/ConfigController.php
ConfigController.register
public function register($name = null, $defaultvalue = null, $value = null, $type = null, $comment = null, $fetchFromEnv = null, $selfedit = "false") { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->configManager = $this->moufManager->getConfigManager(); $this->name = $name; $this->defaultvalue = $defaultvalue; $this->value = $value; $this->type = $type; $this->comment = $comment; $this->fetchFromEnv = $fetchFromEnv; if ($name != null) { $def = $this->configManager->getConstantDefinition($name); if ($def != null) { if ($this->comment == null) { $this->comment = $def['comment']; } if ($this->defaultvalue == null) { $this->defaultvalue = $def['defaultValue']; } if ($this->type == null) { $this->type = $def['type']; } if ($this->fetchFromEnv === null && isset($def['fetchFromEnv'])) { $this->fetchFromEnv = $def['fetchFromEnv']; } } if ($this->value == null) { $constants = $this->configManager->getDefinedConstants(); if (isset($constants[$name])) { $this->value = $constants[$name]; } } } else { $this->fetchFromEnv = true; } // TODO: manage type! //$this->type = $comment; $this->contentBlock->addFile(ROOT_PATH."src-dev/views/constants/registerConstant.php", $this); $this->template->toHtml(); }
php
public function register($name = null, $defaultvalue = null, $value = null, $type = null, $comment = null, $fetchFromEnv = null, $selfedit = "false") { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->configManager = $this->moufManager->getConfigManager(); $this->name = $name; $this->defaultvalue = $defaultvalue; $this->value = $value; $this->type = $type; $this->comment = $comment; $this->fetchFromEnv = $fetchFromEnv; if ($name != null) { $def = $this->configManager->getConstantDefinition($name); if ($def != null) { if ($this->comment == null) { $this->comment = $def['comment']; } if ($this->defaultvalue == null) { $this->defaultvalue = $def['defaultValue']; } if ($this->type == null) { $this->type = $def['type']; } if ($this->fetchFromEnv === null && isset($def['fetchFromEnv'])) { $this->fetchFromEnv = $def['fetchFromEnv']; } } if ($this->value == null) { $constants = $this->configManager->getDefinedConstants(); if (isset($constants[$name])) { $this->value = $constants[$name]; } } } else { $this->fetchFromEnv = true; } // TODO: manage type! //$this->type = $comment; $this->contentBlock->addFile(ROOT_PATH."src-dev/views/constants/registerConstant.php", $this); $this->template->toHtml(); }
[ "public", "function", "register", "(", "$", "name", "=", "null", ",", "$", "defaultvalue", "=", "null", ",", "$", "value", "=", "null", ",", "$", "type", "=", "null", ",", "$", "comment", "=", "null", ",", "$", "fetchFromEnv", "=", "null", ",", "$"...
Displays the screen to register a constant definition. @Action @Logged @param string $name @param string $selfedit
[ "Displays", "the", "screen", "to", "register", "a", "constant", "definition", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/ConfigController.php#L135-L184
38,441
thecodingmachine/mouf
src-dev/Mouf/Controllers/ConfigController.php
ConfigController.registerConstant
public function registerConstant($name, $comment, $type, $defaultvalue = "", $value = "", $selfedit = "false", $fetchFromEnv = "false") { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->configManager = $this->moufManager->getConfigManager(); if ($type == "int") { $value = $value !== '' ? (int) $value : ''; $defaultvalue = $defaultvalue !== '' ? (int) $defaultvalue : ''; } else if ($type == "float") { $value = (float) $value; $defaultvalue = (float) $defaultvalue; } else if ($type == "bool") { if ($value == "true") { $value = true; } else { $value = false; } if ($defaultvalue == "true") { $defaultvalue = true; } else { $defaultvalue = false; } } $this->configManager->registerConstant($name, $type, $defaultvalue, $comment, $fetchFromEnv === 'true'); $this->moufManager->rewriteMouf(); // Now, let's write the constant for our environment: $this->constantsList = $this->configManager->getDefinedConstants(); $this->constantsList[$name] = $value; $this->configManager->setDefinedConstants($this->constantsList); header("Location: .?selfedit=".$selfedit); }
php
public function registerConstant($name, $comment, $type, $defaultvalue = "", $value = "", $selfedit = "false", $fetchFromEnv = "false") { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->configManager = $this->moufManager->getConfigManager(); if ($type == "int") { $value = $value !== '' ? (int) $value : ''; $defaultvalue = $defaultvalue !== '' ? (int) $defaultvalue : ''; } else if ($type == "float") { $value = (float) $value; $defaultvalue = (float) $defaultvalue; } else if ($type == "bool") { if ($value == "true") { $value = true; } else { $value = false; } if ($defaultvalue == "true") { $defaultvalue = true; } else { $defaultvalue = false; } } $this->configManager->registerConstant($name, $type, $defaultvalue, $comment, $fetchFromEnv === 'true'); $this->moufManager->rewriteMouf(); // Now, let's write the constant for our environment: $this->constantsList = $this->configManager->getDefinedConstants(); $this->constantsList[$name] = $value; $this->configManager->setDefinedConstants($this->constantsList); header("Location: .?selfedit=".$selfedit); }
[ "public", "function", "registerConstant", "(", "$", "name", ",", "$", "comment", ",", "$", "type", ",", "$", "defaultvalue", "=", "\"\"", ",", "$", "value", "=", "\"\"", ",", "$", "selfedit", "=", "\"false\"", ",", "$", "fetchFromEnv", "=", "\"false\"", ...
Actually saves the new constant declared. @Action @Logged @param string $name @param string $defaultvalue @param string $value @param string $comment @param string $type @param string $selfedit
[ "Actually", "saves", "the", "new", "constant", "declared", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/ConfigController.php#L198-L236
38,442
thecodingmachine/mouf
src-dev/Mouf/Controllers/ConfigController.php
ConfigController.deleteConstant
public function deleteConstant($name, $selfedit = "false") { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->configManager = $this->moufManager->getConfigManager(); $this->configManager->unregisterConstant($name); $this->moufManager->rewriteMouf(); // Now, let's write the constant for our environment: $this->constantsList = $this->configManager->getDefinedConstants(); unset($this->constantsList[$name]); $this->configManager->setDefinedConstants($this->constantsList); header("Location: .?selfedit=".$selfedit); }
php
public function deleteConstant($name, $selfedit = "false") { $this->selfedit = $selfedit; if ($selfedit == "true") { $this->moufManager = MoufManager::getMoufManager(); } else { $this->moufManager = MoufManager::getMoufManagerHiddenInstance(); } $this->configManager = $this->moufManager->getConfigManager(); $this->configManager->unregisterConstant($name); $this->moufManager->rewriteMouf(); // Now, let's write the constant for our environment: $this->constantsList = $this->configManager->getDefinedConstants(); unset($this->constantsList[$name]); $this->configManager->setDefinedConstants($this->constantsList); header("Location: .?selfedit=".$selfedit); }
[ "public", "function", "deleteConstant", "(", "$", "name", ",", "$", "selfedit", "=", "\"false\"", ")", "{", "$", "this", "->", "selfedit", "=", "$", "selfedit", ";", "if", "(", "$", "selfedit", "==", "\"true\"", ")", "{", "$", "this", "->", "moufManage...
Deletes a constant. @Action @Logged @param string $name
[ "Deletes", "a", "constant", "." ]
b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b
https://github.com/thecodingmachine/mouf/blob/b6a11bfd4a93859c1014d5b3d54ee99314f5fc7b/src-dev/Mouf/Controllers/ConfigController.php#L245-L266
38,443
PatrickLouys/http
src/HttpResponse.php
HttpResponse.getHeaders
public function getHeaders() { $headers = array_merge( $this->getRequestLineHeaders(), $this->getStandardHeaders(), $this->getCookieHeaders() ); return $headers; }
php
public function getHeaders() { $headers = array_merge( $this->getRequestLineHeaders(), $this->getStandardHeaders(), $this->getCookieHeaders() ); return $headers; }
[ "public", "function", "getHeaders", "(", ")", "{", "$", "headers", "=", "array_merge", "(", "$", "this", "->", "getRequestLineHeaders", "(", ")", ",", "$", "this", "->", "getStandardHeaders", "(", ")", ",", "$", "this", "->", "getCookieHeaders", "(", ")", ...
Returns an array with the HTTP headers. @return array
[ "Returns", "an", "array", "with", "the", "HTTP", "headers", "." ]
6321602a8be45c5159f1f0099c60a72c8efdb825
https://github.com/PatrickLouys/http/blob/6321602a8be45c5159f1f0099c60a72c8efdb825/src/HttpResponse.php#L138-L147
38,444
PatrickLouys/http
src/HttpRequest.php
HttpRequest.getParameter
public function getParameter($key, $defaultValue = null) { if (array_key_exists($key, $this->postParameters)) { return $this->postParameters[$key]; } if (array_key_exists($key, $this->getParameters)) { return $this->getParameters[$key]; } return $defaultValue; }
php
public function getParameter($key, $defaultValue = null) { if (array_key_exists($key, $this->postParameters)) { return $this->postParameters[$key]; } if (array_key_exists($key, $this->getParameters)) { return $this->getParameters[$key]; } return $defaultValue; }
[ "public", "function", "getParameter", "(", "$", "key", ",", "$", "defaultValue", "=", "null", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "postParameters", ")", ")", "{", "return", "$", "this", "->", "postParameters"...
Returns a parameter value or a default value if none is set. @param string $key @param string $defaultValue (optional) @return string
[ "Returns", "a", "parameter", "value", "or", "a", "default", "value", "if", "none", "is", "set", "." ]
6321602a8be45c5159f1f0099c60a72c8efdb825
https://github.com/PatrickLouys/http/blob/6321602a8be45c5159f1f0099c60a72c8efdb825/src/HttpRequest.php#L36-L47
38,445
PatrickLouys/http
src/HttpRequest.php
HttpRequest.getQueryParameter
public function getQueryParameter($key, $defaultValue = null) { if (array_key_exists($key, $this->getParameters)) { return $this->getParameters[$key]; } return $defaultValue; }
php
public function getQueryParameter($key, $defaultValue = null) { if (array_key_exists($key, $this->getParameters)) { return $this->getParameters[$key]; } return $defaultValue; }
[ "public", "function", "getQueryParameter", "(", "$", "key", ",", "$", "defaultValue", "=", "null", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "getParameters", ")", ")", "{", "return", "$", "this", "->", "getParamete...
Returns a query parameter value or a default value if none is set. @param string $key @param string $defaultValue (optional) @return string
[ "Returns", "a", "query", "parameter", "value", "or", "a", "default", "value", "if", "none", "is", "set", "." ]
6321602a8be45c5159f1f0099c60a72c8efdb825
https://github.com/PatrickLouys/http/blob/6321602a8be45c5159f1f0099c60a72c8efdb825/src/HttpRequest.php#L56-L63
38,446
PatrickLouys/http
src/HttpRequest.php
HttpRequest.getBodyParameter
public function getBodyParameter($key, $defaultValue = null) { if (array_key_exists($key, $this->postParameters)) { return $this->postParameters[$key]; } return $defaultValue; }
php
public function getBodyParameter($key, $defaultValue = null) { if (array_key_exists($key, $this->postParameters)) { return $this->postParameters[$key]; } return $defaultValue; }
[ "public", "function", "getBodyParameter", "(", "$", "key", ",", "$", "defaultValue", "=", "null", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "postParameters", ")", ")", "{", "return", "$", "this", "->", "postParamet...
Returns a body parameter value or a default value if none is set. @param string $key @param string $defaultValue (optional) @return string
[ "Returns", "a", "body", "parameter", "value", "or", "a", "default", "value", "if", "none", "is", "set", "." ]
6321602a8be45c5159f1f0099c60a72c8efdb825
https://github.com/PatrickLouys/http/blob/6321602a8be45c5159f1f0099c60a72c8efdb825/src/HttpRequest.php#L72-L79
38,447
PatrickLouys/http
src/HttpRequest.php
HttpRequest.getCookie
public function getCookie($key, $defaultValue = null) { if (array_key_exists($key, $this->cookies)) { return $this->cookies[$key]; } return $defaultValue; }
php
public function getCookie($key, $defaultValue = null) { if (array_key_exists($key, $this->cookies)) { return $this->cookies[$key]; } return $defaultValue; }
[ "public", "function", "getCookie", "(", "$", "key", ",", "$", "defaultValue", "=", "null", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "cookies", ")", ")", "{", "return", "$", "this", "->", "cookies", "[", "$", ...
Returns a cookie value or a default value if none is set. @param string $key @param string $defaultValue (optional) @return string
[ "Returns", "a", "cookie", "value", "or", "a", "default", "value", "if", "none", "is", "set", "." ]
6321602a8be45c5159f1f0099c60a72c8efdb825
https://github.com/PatrickLouys/http/blob/6321602a8be45c5159f1f0099c60a72c8efdb825/src/HttpRequest.php#L104-L111
38,448
PatrickLouys/http
src/HttpCookie.php
HttpCookie.getHeaderString
public function getHeaderString() { $parts = [ $this->name . '=' . rawurlencode($this->value), $this->getMaxAgeString(), $this->getExpiresString(), $this->getDomainString(), $this->getPathString(), $this->getSecureString(), $this->getHttpOnlyString(), ]; $filteredParts = array_filter($parts); return implode('; ', $filteredParts); }
php
public function getHeaderString() { $parts = [ $this->name . '=' . rawurlencode($this->value), $this->getMaxAgeString(), $this->getExpiresString(), $this->getDomainString(), $this->getPathString(), $this->getSecureString(), $this->getHttpOnlyString(), ]; $filteredParts = array_filter($parts); return implode('; ', $filteredParts); }
[ "public", "function", "getHeaderString", "(", ")", "{", "$", "parts", "=", "[", "$", "this", "->", "name", ".", "'='", ".", "rawurlencode", "(", "$", "this", "->", "value", ")", ",", "$", "this", "->", "getMaxAgeString", "(", ")", ",", "$", "this", ...
Returns the cookie HTTP header string. @return string
[ "Returns", "the", "cookie", "HTTP", "header", "string", "." ]
6321602a8be45c5159f1f0099c60a72c8efdb825
https://github.com/PatrickLouys/http/blob/6321602a8be45c5159f1f0099c60a72c8efdb825/src/HttpCookie.php#L102-L117
38,449
zefy/php-simple-sso
docs/examples/Server.php
Server.redirect
protected function redirect(?string $url = null, array $parameters = [], int $httpResponseCode = 307) { if (!$url) { $url = urldecode($_GET['return_url']); } $query = ''; // Making URL query string if parameters given. if (!empty($parameters)) { $query = '?'; if (parse_url($url, PHP_URL_QUERY)) { $query = '&'; } $query .= http_build_query($parameters); } header('Location: ' . $url . $query); exit; }
php
protected function redirect(?string $url = null, array $parameters = [], int $httpResponseCode = 307) { if (!$url) { $url = urldecode($_GET['return_url']); } $query = ''; // Making URL query string if parameters given. if (!empty($parameters)) { $query = '?'; if (parse_url($url, PHP_URL_QUERY)) { $query = '&'; } $query .= http_build_query($parameters); } header('Location: ' . $url . $query); exit; }
[ "protected", "function", "redirect", "(", "?", "string", "$", "url", "=", "null", ",", "array", "$", "parameters", "=", "[", "]", ",", "int", "$", "httpResponseCode", "=", "307", ")", "{", "if", "(", "!", "$", "url", ")", "{", "$", "url", "=", "u...
Redirect to provided URL with query string. If $url is null, redirect to url which given in 'return_url'. @param string|null $url URL to be redirected. @param array $parameters HTTP query string. @param int $httpResponseCode HTTP response code for redirection. @return void
[ "Redirect", "to", "provided", "URL", "with", "query", "string", "." ]
f2eb2ef567615429966534af5f88cff7cdb00cca
https://github.com/zefy/php-simple-sso/blob/f2eb2ef567615429966534af5f88cff7cdb00cca/docs/examples/Server.php#L40-L56
38,450
zefy/php-simple-sso
docs/examples/Server.php
Server.getBrokerInfo
protected function getBrokerInfo(string $brokerId) { if (!isset($this->brokers[$brokerId])) { return null; } return $this->brokers[$brokerId]; }
php
protected function getBrokerInfo(string $brokerId) { if (!isset($this->brokers[$brokerId])) { return null; } return $this->brokers[$brokerId]; }
[ "protected", "function", "getBrokerInfo", "(", "string", "$", "brokerId", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "brokers", "[", "$", "brokerId", "]", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "broker...
Get the secret key and other info of a broker @param string $brokerId @return null|array
[ "Get", "the", "secret", "key", "and", "other", "info", "of", "a", "broker" ]
f2eb2ef567615429966534af5f88cff7cdb00cca
https://github.com/zefy/php-simple-sso/blob/f2eb2ef567615429966534af5f88cff7cdb00cca/docs/examples/Server.php#L96-L103
38,451
zefy/php-simple-sso
docs/examples/Server.php
Server.getUserInfo
protected function getUserInfo(string $username) { if (!isset($this->users[$username])) { return null; } return $this->users[$username]; }
php
protected function getUserInfo(string $username) { if (!isset($this->users[$username])) { return null; } return $this->users[$username]; }
[ "protected", "function", "getUserInfo", "(", "string", "$", "username", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "users", "[", "$", "username", "]", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "users", ...
Get the information about a user @param string $username @return array|object|null
[ "Get", "the", "information", "about", "a", "user" ]
f2eb2ef567615429966534af5f88cff7cdb00cca
https://github.com/zefy/php-simple-sso/blob/f2eb2ef567615429966534af5f88cff7cdb00cca/docs/examples/Server.php#L112-L119
38,452
zefy/php-simple-sso
docs/examples/Server.php
Server.getBrokerSessionId
protected function getBrokerSessionId() { $headers = getallheaders(); if (isset($headers['Authorization']) && strpos($headers['Authorization'], 'Bearer') === 0) { $headers['Authorization'] = substr($headers['Authorization'], 7); return $headers['Authorization']; } return null; }
php
protected function getBrokerSessionId() { $headers = getallheaders(); if (isset($headers['Authorization']) && strpos($headers['Authorization'], 'Bearer') === 0) { $headers['Authorization'] = substr($headers['Authorization'], 7); return $headers['Authorization']; } return null; }
[ "protected", "function", "getBrokerSessionId", "(", ")", "{", "$", "headers", "=", "getallheaders", "(", ")", ";", "if", "(", "isset", "(", "$", "headers", "[", "'Authorization'", "]", ")", "&&", "strpos", "(", "$", "headers", "[", "'Authorization'", "]", ...
Return session id sent from broker. @return null|string
[ "Return", "session", "id", "sent", "from", "broker", "." ]
f2eb2ef567615429966534af5f88cff7cdb00cca
https://github.com/zefy/php-simple-sso/blob/f2eb2ef567615429966534af5f88cff7cdb00cca/docs/examples/Server.php#L139-L149
38,453
zefy/php-simple-sso
docs/examples/Server.php
Server.saveBrokerSessionData
protected function saveBrokerSessionData(string $brokerSessionId, string $sessionData) { /** This is basic example and you should do something better. */ $cacheFile = fopen('broker_session_' . $brokerSessionId, 'w'); fwrite($cacheFile, $sessionData); fclose($cacheFile); }
php
protected function saveBrokerSessionData(string $brokerSessionId, string $sessionData) { /** This is basic example and you should do something better. */ $cacheFile = fopen('broker_session_' . $brokerSessionId, 'w'); fwrite($cacheFile, $sessionData); fclose($cacheFile); }
[ "protected", "function", "saveBrokerSessionData", "(", "string", "$", "brokerSessionId", ",", "string", "$", "sessionData", ")", "{", "/** This is basic example and you should do something better. */", "$", "cacheFile", "=", "fopen", "(", "'broker_session_'", ".", "$", "b...
Save broker session data to cache. @param string $brokerSessionId @param string $sessionData @return void
[ "Save", "broker", "session", "data", "to", "cache", "." ]
f2eb2ef567615429966534af5f88cff7cdb00cca
https://github.com/zefy/php-simple-sso/blob/f2eb2ef567615429966534af5f88cff7cdb00cca/docs/examples/Server.php#L222-L229
38,454
zefy/php-simple-sso
docs/examples/Server.php
Server.getBrokerSessionData
protected function getBrokerSessionData(string $brokerSessionId) { /** This is basic example and you should do something better. */ $cacheFileName = 'broker_session_' . $brokerSessionId; if (!file_exists($cacheFileName)) { return null; } if (time() - 3600 > filemtime($cacheFileName)) { unlink($cacheFileName); return null; } echo file_get_contents($cacheFileName); }
php
protected function getBrokerSessionData(string $brokerSessionId) { /** This is basic example and you should do something better. */ $cacheFileName = 'broker_session_' . $brokerSessionId; if (!file_exists($cacheFileName)) { return null; } if (time() - 3600 > filemtime($cacheFileName)) { unlink($cacheFileName); return null; } echo file_get_contents($cacheFileName); }
[ "protected", "function", "getBrokerSessionData", "(", "string", "$", "brokerSessionId", ")", "{", "/** This is basic example and you should do something better. */", "$", "cacheFileName", "=", "'broker_session_'", ".", "$", "brokerSessionId", ";", "if", "(", "!", "file_exis...
Get broker session data from cache. @param string $brokerSessionId @return null|string
[ "Get", "broker", "session", "data", "from", "cache", "." ]
f2eb2ef567615429966534af5f88cff7cdb00cca
https://github.com/zefy/php-simple-sso/blob/f2eb2ef567615429966534af5f88cff7cdb00cca/docs/examples/Server.php#L238-L255
38,455
zefy/php-simple-sso
src/SSOServer.php
SSOServer.attach
public function attach(?string $broker, ?string $token, ?string $checksum) { try { if (!$broker) { $this->fail('No broker id specified.', true); } if (!$token) { $this->fail('No token specified.', true); } if (!$checksum || $checksum != $this->generateAttachChecksum($broker, $token)) { $this->fail('Invalid checksum.', true); } $this->startUserSession(); $sessionId = $this->generateSessionId($broker, $token); $this->saveBrokerSessionData($sessionId, $this->getSessionData('id')); } catch (SSOServerException $e) { return $this->redirect(null, ['sso_error' => $e->getMessage()]); } $this->attachSuccess(); }
php
public function attach(?string $broker, ?string $token, ?string $checksum) { try { if (!$broker) { $this->fail('No broker id specified.', true); } if (!$token) { $this->fail('No token specified.', true); } if (!$checksum || $checksum != $this->generateAttachChecksum($broker, $token)) { $this->fail('Invalid checksum.', true); } $this->startUserSession(); $sessionId = $this->generateSessionId($broker, $token); $this->saveBrokerSessionData($sessionId, $this->getSessionData('id')); } catch (SSOServerException $e) { return $this->redirect(null, ['sso_error' => $e->getMessage()]); } $this->attachSuccess(); }
[ "public", "function", "attach", "(", "?", "string", "$", "broker", ",", "?", "string", "$", "token", ",", "?", "string", "$", "checksum", ")", "{", "try", "{", "if", "(", "!", "$", "broker", ")", "{", "$", "this", "->", "fail", "(", "'No broker id ...
Attach user's session to broker's session. @param string|null $broker Broker's name/id. @param string|null $token Token sent from broker. @param string|null $checksum Calculated broker+token checksum. @return string or redirect
[ "Attach", "user", "s", "session", "to", "broker", "s", "session", "." ]
f2eb2ef567615429966534af5f88cff7cdb00cca
https://github.com/zefy/php-simple-sso/blob/f2eb2ef567615429966534af5f88cff7cdb00cca/src/SSOServer.php#L30-L54
38,456
zefy/php-simple-sso
src/SSOServer.php
SSOServer.logout
public function logout() { try { $this->startBrokerSession(); $this->setSessionData('sso_user', null); } catch (SSOServerException $e) { return $this->returnJson(['error' => $e->getMessage()]); } return $this->returnJson(['success' => 'User has been successfully logged out.']); }
php
public function logout() { try { $this->startBrokerSession(); $this->setSessionData('sso_user', null); } catch (SSOServerException $e) { return $this->returnJson(['error' => $e->getMessage()]); } return $this->returnJson(['success' => 'User has been successfully logged out.']); }
[ "public", "function", "logout", "(", ")", "{", "try", "{", "$", "this", "->", "startBrokerSession", "(", ")", ";", "$", "this", "->", "setSessionData", "(", "'sso_user'", ",", "null", ")", ";", "}", "catch", "(", "SSOServerException", "$", "e", ")", "{...
Logging user out. @return string
[ "Logging", "user", "out", "." ]
f2eb2ef567615429966534af5f88cff7cdb00cca
https://github.com/zefy/php-simple-sso/blob/f2eb2ef567615429966534af5f88cff7cdb00cca/src/SSOServer.php#L88-L98
38,457
zefy/php-simple-sso
src/SSOServer.php
SSOServer.userInfo
public function userInfo() { try { $this->startBrokerSession(); $username = $this->getSessionData('sso_user'); if (!$username) { $this->fail('User not authenticated. Session ID: ' . $this->getSessionData('id')); } if (!$user = $this->getUserInfo($username)) { $this->fail('User not found.'); } } catch (SSOServerException $e) { return $this->returnJson(['error' => $e->getMessage()]); } return $this->returnUserInfo($user); }
php
public function userInfo() { try { $this->startBrokerSession(); $username = $this->getSessionData('sso_user'); if (!$username) { $this->fail('User not authenticated. Session ID: ' . $this->getSessionData('id')); } if (!$user = $this->getUserInfo($username)) { $this->fail('User not found.'); } } catch (SSOServerException $e) { return $this->returnJson(['error' => $e->getMessage()]); } return $this->returnUserInfo($user); }
[ "public", "function", "userInfo", "(", ")", "{", "try", "{", "$", "this", "->", "startBrokerSession", "(", ")", ";", "$", "username", "=", "$", "this", "->", "getSessionData", "(", "'sso_user'", ")", ";", "if", "(", "!", "$", "username", ")", "{", "$...
Returning user info for the broker. @return string
[ "Returning", "user", "info", "for", "the", "broker", "." ]
f2eb2ef567615429966534af5f88cff7cdb00cca
https://github.com/zefy/php-simple-sso/blob/f2eb2ef567615429966534af5f88cff7cdb00cca/src/SSOServer.php#L105-L124
38,458
zefy/php-simple-sso
src/SSOServer.php
SSOServer.startBrokerSession
protected function startBrokerSession() { if (isset($this->brokerId)) { return; } $sessionId = $this->getBrokerSessionId(); if (!$sessionId) { $this->fail('Missing session key from broker.'); } $savedSessionId = $this->getBrokerSessionData($sessionId); if (!$savedSessionId) { $this->fail('There is no saved session data associated with the broker session id.'); } $this->startSession($savedSessionId); $this->brokerId = $this->validateBrokerSessionId($sessionId); }
php
protected function startBrokerSession() { if (isset($this->brokerId)) { return; } $sessionId = $this->getBrokerSessionId(); if (!$sessionId) { $this->fail('Missing session key from broker.'); } $savedSessionId = $this->getBrokerSessionData($sessionId); if (!$savedSessionId) { $this->fail('There is no saved session data associated with the broker session id.'); } $this->startSession($savedSessionId); $this->brokerId = $this->validateBrokerSessionId($sessionId); }
[ "protected", "function", "startBrokerSession", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "brokerId", ")", ")", "{", "return", ";", "}", "$", "sessionId", "=", "$", "this", "->", "getBrokerSessionId", "(", ")", ";", "if", "(", "!", "$...
Resume broker session if saved session id exist. @throws SSOServerException @return void
[ "Resume", "broker", "session", "if", "saved", "session", "id", "exist", "." ]
f2eb2ef567615429966534af5f88cff7cdb00cca
https://github.com/zefy/php-simple-sso/blob/f2eb2ef567615429966534af5f88cff7cdb00cca/src/SSOServer.php#L133-L154
38,459
zefy/php-simple-sso
src/SSOServer.php
SSOServer.validateBrokerSessionId
protected function validateBrokerSessionId(string $sessionId) { $matches = null; if (!preg_match('/^SSO-(\w*+)-(\w*+)-([a-z0-9]*+)$/', $this->getBrokerSessionId(), $matches)) { $this->fail('Invalid session id'); } if ($this->generateSessionId($matches[1], $matches[2]) != $sessionId) { $this->fail('Checksum failed: Client IP address may have changed'); } return $matches[1]; }
php
protected function validateBrokerSessionId(string $sessionId) { $matches = null; if (!preg_match('/^SSO-(\w*+)-(\w*+)-([a-z0-9]*+)$/', $this->getBrokerSessionId(), $matches)) { $this->fail('Invalid session id'); } if ($this->generateSessionId($matches[1], $matches[2]) != $sessionId) { $this->fail('Checksum failed: Client IP address may have changed'); } return $matches[1]; }
[ "protected", "function", "validateBrokerSessionId", "(", "string", "$", "sessionId", ")", "{", "$", "matches", "=", "null", ";", "if", "(", "!", "preg_match", "(", "'/^SSO-(\\w*+)-(\\w*+)-([a-z0-9]*+)$/'", ",", "$", "this", "->", "getBrokerSessionId", "(", ")", ...
Check if broker session is valid. @param string $sessionId Session id from the broker. @throws SSOServerException @return string
[ "Check", "if", "broker", "session", "is", "valid", "." ]
f2eb2ef567615429966534af5f88cff7cdb00cca
https://github.com/zefy/php-simple-sso/blob/f2eb2ef567615429966534af5f88cff7cdb00cca/src/SSOServer.php#L165-L178
38,460
zefy/php-simple-sso
src/SSOServer.php
SSOServer.fail
protected function fail(?string $message, bool $isRedirect = false, ?string $url = null) { if (!$isRedirect) { throw new SSOServerException($message); } $this->redirect($url, ['sso_error' => $message]); }
php
protected function fail(?string $message, bool $isRedirect = false, ?string $url = null) { if (!$isRedirect) { throw new SSOServerException($message); } $this->redirect($url, ['sso_error' => $message]); }
[ "protected", "function", "fail", "(", "?", "string", "$", "message", ",", "bool", "$", "isRedirect", "=", "false", ",", "?", "string", "$", "url", "=", "null", ")", "{", "if", "(", "!", "$", "isRedirect", ")", "{", "throw", "new", "SSOServerException",...
If something failed, throw an Exception or redirect. @param null|string $message @param bool $isRedirect @param null|string $url @throws SSOServerException @return void
[ "If", "something", "failed", "throw", "an", "Exception", "or", "redirect", "." ]
f2eb2ef567615429966534af5f88cff7cdb00cca
https://github.com/zefy/php-simple-sso/blob/f2eb2ef567615429966534af5f88cff7cdb00cca/src/SSOServer.php#L243-L250
38,461
zefy/php-simple-sso
src/SSOBroker.php
SSOBroker.attach
public function attach() { $parameters = [ 'return_url' => $this->getCurrentUrl(), 'broker' => $this->brokerName, 'token' => $this->token, 'checksum' => hash('sha256', 'attach' . $this->token . $this->brokerSecret) ]; $attachUrl = $this->generateCommandUrl('attach', $parameters); $this->redirect($attachUrl); }
php
public function attach() { $parameters = [ 'return_url' => $this->getCurrentUrl(), 'broker' => $this->brokerName, 'token' => $this->token, 'checksum' => hash('sha256', 'attach' . $this->token . $this->brokerSecret) ]; $attachUrl = $this->generateCommandUrl('attach', $parameters); $this->redirect($attachUrl); }
[ "public", "function", "attach", "(", ")", "{", "$", "parameters", "=", "[", "'return_url'", "=>", "$", "this", "->", "getCurrentUrl", "(", ")", ",", "'broker'", "=>", "$", "this", "->", "brokerName", ",", "'token'", "=>", "$", "this", "->", "token", ",...
Attach client session to broker session in SSO server. @return void
[ "Attach", "client", "session", "to", "broker", "session", "in", "SSO", "server", "." ]
f2eb2ef567615429966534af5f88cff7cdb00cca
https://github.com/zefy/php-simple-sso/blob/f2eb2ef567615429966534af5f88cff7cdb00cca/src/SSOBroker.php#L63-L75
38,462
zefy/php-simple-sso
src/SSOBroker.php
SSOBroker.getUserInfo
public function getUserInfo() { if (!isset($this->userInfo) || empty($this->userInfo)) { $this->userInfo = $this->makeRequest('GET', 'userInfo'); } return $this->userInfo; }
php
public function getUserInfo() { if (!isset($this->userInfo) || empty($this->userInfo)) { $this->userInfo = $this->makeRequest('GET', 'userInfo'); } return $this->userInfo; }
[ "public", "function", "getUserInfo", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "userInfo", ")", "||", "empty", "(", "$", "this", "->", "userInfo", ")", ")", "{", "$", "this", "->", "userInfo", "=", "$", "this", "->", "makeRequ...
Getting user info from SSO based on client session. @return array
[ "Getting", "user", "info", "from", "SSO", "based", "on", "client", "session", "." ]
f2eb2ef567615429966534af5f88cff7cdb00cca
https://github.com/zefy/php-simple-sso/blob/f2eb2ef567615429966534af5f88cff7cdb00cca/src/SSOBroker.php#L82-L89
38,463
zefy/php-simple-sso
src/SSOBroker.php
SSOBroker.login
public function login(string $username, string $password) { $this->userInfo = $this->makeRequest('POST', 'login', compact('username', 'password')); if (!isset($this->userInfo['error']) && isset($this->userInfo['data']['id'])) { return true; } return false; }
php
public function login(string $username, string $password) { $this->userInfo = $this->makeRequest('POST', 'login', compact('username', 'password')); if (!isset($this->userInfo['error']) && isset($this->userInfo['data']['id'])) { return true; } return false; }
[ "public", "function", "login", "(", "string", "$", "username", ",", "string", "$", "password", ")", "{", "$", "this", "->", "userInfo", "=", "$", "this", "->", "makeRequest", "(", "'POST'", ",", "'login'", ",", "compact", "(", "'username'", ",", "'passwo...
Login client to SSO server with user credentials. @param string $username @param string $password @return bool
[ "Login", "client", "to", "SSO", "server", "with", "user", "credentials", "." ]
f2eb2ef567615429966534af5f88cff7cdb00cca
https://github.com/zefy/php-simple-sso/blob/f2eb2ef567615429966534af5f88cff7cdb00cca/src/SSOBroker.php#L99-L108
38,464
zefy/php-simple-sso
src/SSOBroker.php
SSOBroker.generateCommandUrl
protected function generateCommandUrl(string $command, array $parameters = []) { $query = ''; if (!empty($parameters)) { $query = '?' . http_build_query($parameters); } return $this->ssoServerUrl . '/sso/' . $command . $query; }
php
protected function generateCommandUrl(string $command, array $parameters = []) { $query = ''; if (!empty($parameters)) { $query = '?' . http_build_query($parameters); } return $this->ssoServerUrl . '/sso/' . $command . $query; }
[ "protected", "function", "generateCommandUrl", "(", "string", "$", "command", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "query", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "parameters", ")", ")", "{", "$", "query", "=", ...
Generate request url. @param string $command @param array $parameters @return string
[ "Generate", "request", "url", "." ]
f2eb2ef567615429966534af5f88cff7cdb00cca
https://github.com/zefy/php-simple-sso/blob/f2eb2ef567615429966534af5f88cff7cdb00cca/src/SSOBroker.php#L128-L136
38,465
zefy/php-simple-sso
docs/examples/Broker.php
Broker.saveToken
protected function saveToken() { if (isset($this->token) && $this->token) { return; } if ($this->token = $this->getCookie($this->getCookieName())) { return; } // If cookie token doesn't exist, we need to create it with unique token... $this->token = base_convert(md5(uniqid(rand(), true)), 16, 36); setcookie($this->getCookieName(), $this->token, time() + 60 * 60 * 12, '/'); // ... and attach it to broker session in SSO server. $this->attach(); }
php
protected function saveToken() { if (isset($this->token) && $this->token) { return; } if ($this->token = $this->getCookie($this->getCookieName())) { return; } // If cookie token doesn't exist, we need to create it with unique token... $this->token = base_convert(md5(uniqid(rand(), true)), 16, 36); setcookie($this->getCookieName(), $this->token, time() + 60 * 60 * 12, '/'); // ... and attach it to broker session in SSO server. $this->attach(); }
[ "protected", "function", "saveToken", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "token", ")", "&&", "$", "this", "->", "token", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "token", "=", "$", "this", "->", "getCook...
Somehow save random token for client. @return void
[ "Somehow", "save", "random", "token", "for", "client", "." ]
f2eb2ef567615429966534af5f88cff7cdb00cca
https://github.com/zefy/php-simple-sso/blob/f2eb2ef567615429966534af5f88cff7cdb00cca/docs/examples/Broker.php#L50-L66
38,466
zefy/php-simple-sso
docs/examples/Broker.php
Broker.makeRequest
protected function makeRequest(string $method, string $command, array $parameters = []) { $commandUrl = $this->generateCommandUrl($command); $headers = [ 'Accept' => 'application/json', 'Authorization' => 'Bearer '. $this->getSessionId(), ]; switch ($method) { case 'POST': $body = ['form_params' => $parameters]; break; case 'GET': $body = ['query' => $parameters]; break; default: $body = []; break; } $client = new GuzzleHttp\Client; $response = $client->request($method, $commandUrl, $body + ['headers' => $headers]); return json_decode($response->getBody(), true); }
php
protected function makeRequest(string $method, string $command, array $parameters = []) { $commandUrl = $this->generateCommandUrl($command); $headers = [ 'Accept' => 'application/json', 'Authorization' => 'Bearer '. $this->getSessionId(), ]; switch ($method) { case 'POST': $body = ['form_params' => $parameters]; break; case 'GET': $body = ['query' => $parameters]; break; default: $body = []; break; } $client = new GuzzleHttp\Client; $response = $client->request($method, $commandUrl, $body + ['headers' => $headers]); return json_decode($response->getBody(), true); }
[ "protected", "function", "makeRequest", "(", "string", "$", "method", ",", "string", "$", "command", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "commandUrl", "=", "$", "this", "->", "generateCommandUrl", "(", "$", "command", ")", ";",...
Make request to SSO server. @param string $method Request method 'post' or 'get'. @param string $command Request command name. @param array $parameters Parameters for URL query string if GET request and form parameters if it's POST request. @return array
[ "Make", "request", "to", "SSO", "server", "." ]
f2eb2ef567615429966534af5f88cff7cdb00cca
https://github.com/zefy/php-simple-sso/blob/f2eb2ef567615429966534af5f88cff7cdb00cca/docs/examples/Broker.php#L88-L109
38,467
zefy/php-simple-sso
docs/examples/Broker.php
Broker.redirect
protected function redirect(string $url, array $parameters = [], int $httpResponseCode = 307) { $query = ''; // Making URL query string if parameters given. if (!empty($parameters)) { $query = '?'; if (parse_url($url, PHP_URL_QUERY)) { $query = '&'; } $query .= http_build_query($parameters); } header('Location: ' . $url . $query, true, $httpResponseCode); exit; }
php
protected function redirect(string $url, array $parameters = [], int $httpResponseCode = 307) { $query = ''; // Making URL query string if parameters given. if (!empty($parameters)) { $query = '?'; if (parse_url($url, PHP_URL_QUERY)) { $query = '&'; } $query .= http_build_query($parameters); } header('Location: ' . $url . $query, true, $httpResponseCode); exit; }
[ "protected", "function", "redirect", "(", "string", "$", "url", ",", "array", "$", "parameters", "=", "[", "]", ",", "int", "$", "httpResponseCode", "=", "307", ")", "{", "$", "query", "=", "''", ";", "// Making URL query string if parameters given.", "if", ...
Redirect client to specified url. @param string $url URL to be redirected. @param array $parameters HTTP query string. @param int $httpResponseCode HTTP response code for redirection. @return void
[ "Redirect", "client", "to", "specified", "url", "." ]
f2eb2ef567615429966534af5f88cff7cdb00cca
https://github.com/zefy/php-simple-sso/blob/f2eb2ef567615429966534af5f88cff7cdb00cca/docs/examples/Broker.php#L120-L134
38,468
wasinger/jsonrpc-bundle
Controller/JsonRpcController.php
JsonRpcController.addMethod
public function addMethod($alias, $service, $method, $overwrite = false) { if (!isset($this->functions)) $this->functions = array(); if (isset($this->functions[$alias]) && !$overwrite) { throw new \InvalidArgumentException('JsonRpcController: The function "' . $alias . '" already exists.'); } $this->functions[$alias] = array( 'service' => $service, 'method' => $method ); }
php
public function addMethod($alias, $service, $method, $overwrite = false) { if (!isset($this->functions)) $this->functions = array(); if (isset($this->functions[$alias]) && !$overwrite) { throw new \InvalidArgumentException('JsonRpcController: The function "' . $alias . '" already exists.'); } $this->functions[$alias] = array( 'service' => $service, 'method' => $method ); }
[ "public", "function", "addMethod", "(", "$", "alias", ",", "$", "service", ",", "$", "method", ",", "$", "overwrite", "=", "false", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "functions", ")", ")", "$", "this", "->", "functions", "=...
Add a new function that can be called by RPC @param string $alias The function name used in the RPC call @param string $service The service name of the method to call @param string $method The method of $service @param bool $overwrite Whether to overwrite an existing function @throws \InvalidArgumentException
[ "Add", "a", "new", "function", "that", "can", "be", "called", "by", "RPC" ]
8c8ff13244a3c9c8f956de2ee074d615392ed354
https://github.com/wasinger/jsonrpc-bundle/blob/8c8ff13244a3c9c8f956de2ee074d615392ed354/Controller/JsonRpcController.php#L204-L214
38,469
wasinger/jsonrpc-bundle
Controller/JsonRpcController.php
JsonRpcController.getSerializationContext
protected function getSerializationContext(array $functionConfig) { if (isset($functionConfig['jms_serialization_context'])) { $serializationContext = \JMS\Serializer\SerializationContext::create(); if (isset($functionConfig['jms_serialization_context']['groups'])) { $serializationContext->setGroups($functionConfig['jms_serialization_context']['groups']); } if (isset($functionConfig['jms_serialization_context']['version'])) { $serializationContext->setVersion($functionConfig['jms_serialization_context']['version']); } if (isset($functionConfig['jms_serialization_context']['max_depth_checks'])) { $serializationContext->enableMaxDepthChecks($functionConfig['jms_serialization_context']['max_depth_checks']); } } else { $serializationContext = $this->serializationContext; } return $serializationContext; }
php
protected function getSerializationContext(array $functionConfig) { if (isset($functionConfig['jms_serialization_context'])) { $serializationContext = \JMS\Serializer\SerializationContext::create(); if (isset($functionConfig['jms_serialization_context']['groups'])) { $serializationContext->setGroups($functionConfig['jms_serialization_context']['groups']); } if (isset($functionConfig['jms_serialization_context']['version'])) { $serializationContext->setVersion($functionConfig['jms_serialization_context']['version']); } if (isset($functionConfig['jms_serialization_context']['max_depth_checks'])) { $serializationContext->enableMaxDepthChecks($functionConfig['jms_serialization_context']['max_depth_checks']); } } else { $serializationContext = $this->serializationContext; } return $serializationContext; }
[ "protected", "function", "getSerializationContext", "(", "array", "$", "functionConfig", ")", "{", "if", "(", "isset", "(", "$", "functionConfig", "[", "'jms_serialization_context'", "]", ")", ")", "{", "$", "serializationContext", "=", "\\", "JMS", "\\", "Seria...
Get SerializationContext or creates one if jms_serialization_context option is set @param array $functionConfig @return \JMS\Serializer\SerializationContext
[ "Get", "SerializationContext", "or", "creates", "one", "if", "jms_serialization_context", "option", "is", "set" ]
8c8ff13244a3c9c8f956de2ee074d615392ed354
https://github.com/wasinger/jsonrpc-bundle/blob/8c8ff13244a3c9c8f956de2ee074d615392ed354/Controller/JsonRpcController.php#L297-L318
38,470
kasp3r/link-preview
src/LinkPreview/LinkPreview.php
LinkPreview.getParsed
public function getParsed() { $parsed = []; $parsers = $this->getParsers(); if (0 === count($parsers)) { $this->addDefaultParsers(); } foreach ($this->getParsers() as $name => $parser) { $parser->getLink()->setUrl($this->getUrl()); if ($parser->isValidParser()) { $parsed[$name] = $parser->parseLink(); if (!$this->getPropagation()) { break; } } } return $parsed; }
php
public function getParsed() { $parsed = []; $parsers = $this->getParsers(); if (0 === count($parsers)) { $this->addDefaultParsers(); } foreach ($this->getParsers() as $name => $parser) { $parser->getLink()->setUrl($this->getUrl()); if ($parser->isValidParser()) { $parsed[$name] = $parser->parseLink(); if (!$this->getPropagation()) { break; } } } return $parsed; }
[ "public", "function", "getParsed", "(", ")", "{", "$", "parsed", "=", "[", "]", ";", "$", "parsers", "=", "$", "this", "->", "getParsers", "(", ")", ";", "if", "(", "0", "===", "count", "(", "$", "parsers", ")", ")", "{", "$", "this", "->", "ad...
Get parsed model array with parser name as a key @return LinkInterface[]
[ "Get", "parsed", "model", "array", "with", "parser", "name", "as", "a", "key" ]
468c0209f1640f270e62a13e5a41da1272e6098c
https://github.com/kasp3r/link-preview/blob/468c0209f1640f270e62a13e5a41da1272e6098c/src/LinkPreview/LinkPreview.php#L54-L76
38,471
guillermomartinez/filemanager-php
src/GuillermoMartinez/Filemanager/Filemanager.php
Filemanager.getLogTime
private function getLogTime() { $diff = $this->microtime_diff($this->init); $format = gmdate("H:i:s",(int)$diff); $diff = sprintf("%01.5f", $diff); $format .= substr($diff,strpos((string)$diff,'.')); return $format; }
php
private function getLogTime() { $diff = $this->microtime_diff($this->init); $format = gmdate("H:i:s",(int)$diff); $diff = sprintf("%01.5f", $diff); $format .= substr($diff,strpos((string)$diff,'.')); return $format; }
[ "private", "function", "getLogTime", "(", ")", "{", "$", "diff", "=", "$", "this", "->", "microtime_diff", "(", "$", "this", "->", "init", ")", ";", "$", "format", "=", "gmdate", "(", "\"H:i:s\"", ",", "(", "int", ")", "$", "diff", ")", ";", "$", ...
Devuelve la diferencia de tiempo formateada @return string
[ "Devuelve", "la", "diferencia", "de", "tiempo", "formateada" ]
5a0d1a68d17fe0dca0206958632a17d153f6389f
https://github.com/guillermomartinez/filemanager-php/blob/5a0d1a68d17fe0dca0206958632a17d153f6389f/src/GuillermoMartinez/Filemanager/Filemanager.php#L128-L135
38,472
guillermomartinez/filemanager-php
src/GuillermoMartinez/Filemanager/Filemanager.php
Filemanager.microtime_diff
private function microtime_diff($start, $end = null) { if (!$end) { $end = microtime(); } list($start_usec, $start_sec) = explode(" ", $start); list($end_usec, $end_sec) = explode(" ", $end); $diff_sec = intval($end_sec) - intval($start_sec); $diff_usec = floatval($end_usec) - floatval($start_usec); return floatval($diff_sec) + $diff_usec; }
php
private function microtime_diff($start, $end = null) { if (!$end) { $end = microtime(); } list($start_usec, $start_sec) = explode(" ", $start); list($end_usec, $end_sec) = explode(" ", $end); $diff_sec = intval($end_sec) - intval($start_sec); $diff_usec = floatval($end_usec) - floatval($start_usec); return floatval($diff_sec) + $diff_usec; }
[ "private", "function", "microtime_diff", "(", "$", "start", ",", "$", "end", "=", "null", ")", "{", "if", "(", "!", "$", "end", ")", "{", "$", "end", "=", "microtime", "(", ")", ";", "}", "list", "(", "$", "start_usec", ",", "$", "start_sec", ")"...
Diferencia de microtime @param string $start inicio @param microtime $end fin @return float
[ "Diferencia", "de", "microtime" ]
5a0d1a68d17fe0dca0206958632a17d153f6389f
https://github.com/guillermomartinez/filemanager-php/blob/5a0d1a68d17fe0dca0206958632a17d153f6389f/src/GuillermoMartinez/Filemanager/Filemanager.php#L143-L153
38,473
guillermomartinez/filemanager-php
src/GuillermoMartinez/Filemanager/Filemanager.php
Filemanager.validNameFile
public function validNameFile($filename,$ext=true){ $filename = trim($filename); if($filename!="." && $filename!=".." && $filename!=" " && preg_match_all("#^[a-zA-Z0-9-_.\s]+$#",$filename) > 0){ if($ext) return $this->validExt($filename); else return true; }else{ return false; } }
php
public function validNameFile($filename,$ext=true){ $filename = trim($filename); if($filename!="." && $filename!=".." && $filename!=" " && preg_match_all("#^[a-zA-Z0-9-_.\s]+$#",$filename) > 0){ if($ext) return $this->validExt($filename); else return true; }else{ return false; } }
[ "public", "function", "validNameFile", "(", "$", "filename", ",", "$", "ext", "=", "true", ")", "{", "$", "filename", "=", "trim", "(", "$", "filename", ")", ";", "if", "(", "$", "filename", "!=", "\".\"", "&&", "$", "filename", "!=", "\"..\"", "&&",...
Valida nombre de archivo @param string $filename @return boolean
[ "Valida", "nombre", "de", "archivo" ]
5a0d1a68d17fe0dca0206958632a17d153f6389f
https://github.com/guillermomartinez/filemanager-php/blob/5a0d1a68d17fe0dca0206958632a17d153f6389f/src/GuillermoMartinez/Filemanager/Filemanager.php#L194-L202
38,474
guillermomartinez/filemanager-php
src/GuillermoMartinez/Filemanager/Filemanager.php
Filemanager.validExt
public function validExt($filename){ $exts = $this->config['ext']; $ext = $this->getExtension($filename); if(array_search($ext,$exts)===false){ return false; }else{ return true; } }
php
public function validExt($filename){ $exts = $this->config['ext']; $ext = $this->getExtension($filename); if(array_search($ext,$exts)===false){ return false; }else{ return true; } }
[ "public", "function", "validExt", "(", "$", "filename", ")", "{", "$", "exts", "=", "$", "this", "->", "config", "[", "'ext'", "]", ";", "$", "ext", "=", "$", "this", "->", "getExtension", "(", "$", "filename", ")", ";", "if", "(", "array_search", ...
Valida extension de archivos @param string $filename @return boolean
[ "Valida", "extension", "de", "archivos" ]
5a0d1a68d17fe0dca0206958632a17d153f6389f
https://github.com/guillermomartinez/filemanager-php/blob/5a0d1a68d17fe0dca0206958632a17d153f6389f/src/GuillermoMartinez/Filemanager/Filemanager.php#L209-L219
38,475
guillermomartinez/filemanager-php
src/GuillermoMartinez/Filemanager/Filemanager.php
Filemanager.setInfo
public function setInfo($data=array()) { if(isset($data['data'])) $this->info['data'] = $data['data']; if(isset($data['status'])) $this->info['status'] = $data['status']; if(isset($data['msg'])) $this->info['msg'] = $data['msg']; }
php
public function setInfo($data=array()) { if(isset($data['data'])) $this->info['data'] = $data['data']; if(isset($data['status'])) $this->info['status'] = $data['status']; if(isset($data['msg'])) $this->info['msg'] = $data['msg']; }
[ "public", "function", "setInfo", "(", "$", "data", "=", "array", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "'data'", "]", ")", ")", "$", "this", "->", "info", "[", "'data'", "]", "=", "$", "data", "[", "'data'", "]", ";", ...
Agrega mensaje a cada peticion si se produce un error @param array $data @return void
[ "Agrega", "mensaje", "a", "cada", "peticion", "si", "se", "produce", "un", "error" ]
5a0d1a68d17fe0dca0206958632a17d153f6389f
https://github.com/guillermomartinez/filemanager-php/blob/5a0d1a68d17fe0dca0206958632a17d153f6389f/src/GuillermoMartinez/Filemanager/Filemanager.php#L226-L231
38,476
guillermomartinez/filemanager-php
src/GuillermoMartinez/Filemanager/Filemanager.php
Filemanager._log
public function _log($string,$type='info') { if($this->config['debug']){ $string = $this->getLogTime().": ".$string; } if($type=='info') $this->log->addInfo($string); elseif($type=='warning') $this->log->addWarning($string); elseif($type=='error') $this->log->addError($string); }
php
public function _log($string,$type='info') { if($this->config['debug']){ $string = $this->getLogTime().": ".$string; } if($type=='info') $this->log->addInfo($string); elseif($type=='warning') $this->log->addWarning($string); elseif($type=='error') $this->log->addError($string); }
[ "public", "function", "_log", "(", "$", "string", ",", "$", "type", "=", "'info'", ")", "{", "if", "(", "$", "this", "->", "config", "[", "'debug'", "]", ")", "{", "$", "string", "=", "$", "this", "->", "getLogTime", "(", ")", ".", "\": \"", ".",...
Si debug active permite logear informacion @param string $string Texto a mostrar @param string $type Tipo de mensaje @return void
[ "Si", "debug", "active", "permite", "logear", "informacion" ]
5a0d1a68d17fe0dca0206958632a17d153f6389f
https://github.com/guillermomartinez/filemanager-php/blob/5a0d1a68d17fe0dca0206958632a17d153f6389f/src/GuillermoMartinez/Filemanager/Filemanager.php#L239-L249
38,477
guillermomartinez/filemanager-php
src/GuillermoMartinez/Filemanager/Filemanager.php
Filemanager.sanitizeNameFolder
private function sanitizeNameFolder($var,$strict=false) { $sanitized = strip_tags($var); $sanitized = str_replace('.', '', $sanitized); $sanitized = preg_replace('@(\/)+@', '/', $sanitized); if($strict){ if(substr($sanitized,-1)=='/') $sanitized = substr($sanitized,0,-1); } return $sanitized; }
php
private function sanitizeNameFolder($var,$strict=false) { $sanitized = strip_tags($var); $sanitized = str_replace('.', '', $sanitized); $sanitized = preg_replace('@(\/)+@', '/', $sanitized); if($strict){ if(substr($sanitized,-1)=='/') $sanitized = substr($sanitized,0,-1); } return $sanitized; }
[ "private", "function", "sanitizeNameFolder", "(", "$", "var", ",", "$", "strict", "=", "false", ")", "{", "$", "sanitized", "=", "strip_tags", "(", "$", "var", ")", ";", "$", "sanitized", "=", "str_replace", "(", "'.'", ",", "''", ",", "$", "sanitized"...
Clear name folder @param string $var @return string
[ "Clear", "name", "folder" ]
5a0d1a68d17fe0dca0206958632a17d153f6389f
https://github.com/guillermomartinez/filemanager-php/blob/5a0d1a68d17fe0dca0206958632a17d153f6389f/src/GuillermoMartinez/Filemanager/Filemanager.php#L270-L278
38,478
guillermomartinez/filemanager-php
src/GuillermoMartinez/Filemanager/Filemanager.php
Filemanager.fileInfo
public function fileInfo($file,$path){ if($file->isReadable()){ $item = $this->fileDetails; $item["filename"] = $file->getFilename(); $item["filetype"] = $file->getExtension(); $item["lastmodified"] = $file->getMTime(); $item["size"] = $file->getSize(); if ($this->isImage($file)) { $thumb = $this->firstThumb($file,$path); if($thumb){ $item['preview'] = $this->config['url'].$this->config['source'].'/'.$this->config['folder_thumb'].$path.$thumb; } } $item['previewfull'] = $this->config['url'].$this->config['source'].$path.$item["filename"]; return $item; }else{ return ; } }
php
public function fileInfo($file,$path){ if($file->isReadable()){ $item = $this->fileDetails; $item["filename"] = $file->getFilename(); $item["filetype"] = $file->getExtension(); $item["lastmodified"] = $file->getMTime(); $item["size"] = $file->getSize(); if ($this->isImage($file)) { $thumb = $this->firstThumb($file,$path); if($thumb){ $item['preview'] = $this->config['url'].$this->config['source'].'/'.$this->config['folder_thumb'].$path.$thumb; } } $item['previewfull'] = $this->config['url'].$this->config['source'].$path.$item["filename"]; return $item; }else{ return ; } }
[ "public", "function", "fileInfo", "(", "$", "file", ",", "$", "path", ")", "{", "if", "(", "$", "file", "->", "isReadable", "(", ")", ")", "{", "$", "item", "=", "$", "this", "->", "fileDetails", ";", "$", "item", "[", "\"filename\"", "]", "=", "...
Todas las propiedades de un archivo o directorio @param SplFileInfo $file Object of SplFileInfo @param string $path Ruta de la carpeta o archivo @return array|null Lista de propiedades o null si no es leible
[ "Todas", "las", "propiedades", "de", "un", "archivo", "o", "directorio" ]
5a0d1a68d17fe0dca0206958632a17d153f6389f
https://github.com/guillermomartinez/filemanager-php/blob/5a0d1a68d17fe0dca0206958632a17d153f6389f/src/GuillermoMartinez/Filemanager/Filemanager.php#L338-L356
38,479
guillermomartinez/filemanager-php
src/GuillermoMartinez/Filemanager/Filemanager.php
Filemanager.dirInfo
public function dirInfo($file,$path){ if($file->isReadable()){ $item = $this->fileDetails; $item["filename"] = $file->getFilename(); $item["filetype"] = $file->getExtension(); $item["lastmodified"] = $file->getMTime(); $item["size"] = $file->getSize(); $item["filetype"] = ''; $item["isdir"] = true; $item["urlfolder"] = $path.$item["filename"].'/'; $item['preview'] = ''; return $item; }else{ return ; } }
php
public function dirInfo($file,$path){ if($file->isReadable()){ $item = $this->fileDetails; $item["filename"] = $file->getFilename(); $item["filetype"] = $file->getExtension(); $item["lastmodified"] = $file->getMTime(); $item["size"] = $file->getSize(); $item["filetype"] = ''; $item["isdir"] = true; $item["urlfolder"] = $path.$item["filename"].'/'; $item['preview'] = ''; return $item; }else{ return ; } }
[ "public", "function", "dirInfo", "(", "$", "file", ",", "$", "path", ")", "{", "if", "(", "$", "file", "->", "isReadable", "(", ")", ")", "{", "$", "item", "=", "$", "this", "->", "fileDetails", ";", "$", "item", "[", "\"filename\"", "]", "=", "$...
Informacion del directorio @param UploadedFile $file @param string $path ruta relativa @return array
[ "Informacion", "del", "directorio" ]
5a0d1a68d17fe0dca0206958632a17d153f6389f
https://github.com/guillermomartinez/filemanager-php/blob/5a0d1a68d17fe0dca0206958632a17d153f6389f/src/GuillermoMartinez/Filemanager/Filemanager.php#L364-L379
38,480
guillermomartinez/filemanager-php
src/GuillermoMartinez/Filemanager/Filemanager.php
Filemanager.firstThumb
public function firstThumb($file,$path){ $fullpath = $this->getFullPath().$path; $fullpaththumb = $this->getFullPath().'/'.$this->config['folder_thumb'].$path; $filename = $file->getFilename(); $filename_new_first = ''; foreach ($this->config['images']['resize'] as $key => $value) { $image_info = $this->imageSizeName($path,$filename,$value); if(file_exists($fullpaththumb.$image_info['name']) === false){ $this->resizeImage($fullpath.$filename,$fullpaththumb.$image_info['name'],$image_info,$value); } $filename_new_first = $image_info['name']; break; } return $filename_new_first; }
php
public function firstThumb($file,$path){ $fullpath = $this->getFullPath().$path; $fullpaththumb = $this->getFullPath().'/'.$this->config['folder_thumb'].$path; $filename = $file->getFilename(); $filename_new_first = ''; foreach ($this->config['images']['resize'] as $key => $value) { $image_info = $this->imageSizeName($path,$filename,$value); if(file_exists($fullpaththumb.$image_info['name']) === false){ $this->resizeImage($fullpath.$filename,$fullpaththumb.$image_info['name'],$image_info,$value); } $filename_new_first = $image_info['name']; break; } return $filename_new_first; }
[ "public", "function", "firstThumb", "(", "$", "file", ",", "$", "path", ")", "{", "$", "fullpath", "=", "$", "this", "->", "getFullPath", "(", ")", ".", "$", "path", ";", "$", "fullpaththumb", "=", "$", "this", "->", "getFullPath", "(", ")", ".", "...
Informacion de la primera miniatura @param UploadedFile $file @param string $path ruta relativa @return string
[ "Informacion", "de", "la", "primera", "miniatura" ]
5a0d1a68d17fe0dca0206958632a17d153f6389f
https://github.com/guillermomartinez/filemanager-php/blob/5a0d1a68d17fe0dca0206958632a17d153f6389f/src/GuillermoMartinez/Filemanager/Filemanager.php#L387-L401
38,481
guillermomartinez/filemanager-php
src/GuillermoMartinez/Filemanager/Filemanager.php
Filemanager.createThumb
public function createThumb($file,$path){ $ext = $file->getExtension(); $search = $this->config["images"]["images_ext"]; if(array_search($ext, $search) !== false){ $fullpath = $this->getFullPath().$path; $fullpaththumb = $this->getFullPath().'/'.$this->config['folder_thumb'].$path; $filename = $file->getFilename(); $filename_new_first = ''; $i=0; foreach ($this->config['images']['resize'] as $key => $value) { $i++; $image_info = $this->imageSizeName($path,$filename,$value); if(file_exists($fullpaththumb.$image_info['name']) === false){ $this->resizeImage($fullpath.$filename,$fullpaththumb.$image_info['name'],$image_info,$value); } if($i==1) $filename_new_first = $image_info['name']; } return $filename_new_first; }else{ if( $this->config['debug'] ) $this->_log(__METHOD__." - $ext"); } }
php
public function createThumb($file,$path){ $ext = $file->getExtension(); $search = $this->config["images"]["images_ext"]; if(array_search($ext, $search) !== false){ $fullpath = $this->getFullPath().$path; $fullpaththumb = $this->getFullPath().'/'.$this->config['folder_thumb'].$path; $filename = $file->getFilename(); $filename_new_first = ''; $i=0; foreach ($this->config['images']['resize'] as $key => $value) { $i++; $image_info = $this->imageSizeName($path,$filename,$value); if(file_exists($fullpaththumb.$image_info['name']) === false){ $this->resizeImage($fullpath.$filename,$fullpaththumb.$image_info['name'],$image_info,$value); } if($i==1) $filename_new_first = $image_info['name']; } return $filename_new_first; }else{ if( $this->config['debug'] ) $this->_log(__METHOD__." - $ext"); } }
[ "public", "function", "createThumb", "(", "$", "file", ",", "$", "path", ")", "{", "$", "ext", "=", "$", "file", "->", "getExtension", "(", ")", ";", "$", "search", "=", "$", "this", "->", "config", "[", "\"images\"", "]", "[", "\"images_ext\"", "]",...
Crea la miniatura de imagenes @param UploadedFile $file @param string $path @return string Nombre del nuevo archivo
[ "Crea", "la", "miniatura", "de", "imagenes" ]
5a0d1a68d17fe0dca0206958632a17d153f6389f
https://github.com/guillermomartinez/filemanager-php/blob/5a0d1a68d17fe0dca0206958632a17d153f6389f/src/GuillermoMartinez/Filemanager/Filemanager.php#L422-L443
38,482
guillermomartinez/filemanager-php
src/GuillermoMartinez/Filemanager/Filemanager.php
Filemanager.resizeImage
public function resizeImage($path_imagen,$path_imagen_new,$image_info=array(),$image_config=array()) { $imagen_ext = $this->getExtension($path_imagen); if ($image_config[2]===true && $image_config[3]===true) { Imagen::open($path_imagen)->zoomCrop($image_info['width'],$image_info['height'])->save($path_imagen_new,$imagen_ext,$this->config['images']['quality']); return true; }elseif ( $image_config[2]===true && $image_config[3]===null ) { Imagen::open($path_imagen)->scaleResize($image_info['width'],null)->save($path_imagen_new,$imagen_ext,$this->config['images']['quality']); return true; }elseif ( $image_config[2]===null && $image_config[3]===true ) { Imagen::open($path_imagen)->scaleResize(null,$image_info['height'])->save($path_imagen_new,$imagen_ext,$this->config['images']['quality']); return true; }else{ return false; } }
php
public function resizeImage($path_imagen,$path_imagen_new,$image_info=array(),$image_config=array()) { $imagen_ext = $this->getExtension($path_imagen); if ($image_config[2]===true && $image_config[3]===true) { Imagen::open($path_imagen)->zoomCrop($image_info['width'],$image_info['height'])->save($path_imagen_new,$imagen_ext,$this->config['images']['quality']); return true; }elseif ( $image_config[2]===true && $image_config[3]===null ) { Imagen::open($path_imagen)->scaleResize($image_info['width'],null)->save($path_imagen_new,$imagen_ext,$this->config['images']['quality']); return true; }elseif ( $image_config[2]===null && $image_config[3]===true ) { Imagen::open($path_imagen)->scaleResize(null,$image_info['height'])->save($path_imagen_new,$imagen_ext,$this->config['images']['quality']); return true; }else{ return false; } }
[ "public", "function", "resizeImage", "(", "$", "path_imagen", ",", "$", "path_imagen_new", ",", "$", "image_info", "=", "array", "(", ")", ",", "$", "image_config", "=", "array", "(", ")", ")", "{", "$", "imagen_ext", "=", "$", "this", "->", "getExtensio...
redimensiona una imagen @param string $path_imagen ruta de imagen origen @param string $path_imagen_new ruta de imagen nueva @param array $image_info info de imagen @param array $image_config dimensiones de imagenes @return boolean
[ "redimensiona", "una", "imagen" ]
5a0d1a68d17fe0dca0206958632a17d153f6389f
https://github.com/guillermomartinez/filemanager-php/blob/5a0d1a68d17fe0dca0206958632a17d153f6389f/src/GuillermoMartinez/Filemanager/Filemanager.php#L453-L468
38,483
guillermomartinez/filemanager-php
src/GuillermoMartinez/Filemanager/Filemanager.php
Filemanager.imageSizeName
public function imageSizeName($path,$imagen,$image_config) { $result = array("name"=>'',"width"=>0,"height"=>0); $imagen_ext = $this->getExtension($imagen); $imagen_name = $this->removeExtension($imagen); if ($image_config[2]===true && $image_config[3]===true) { $fullpath_new = $imagen_name.'-'.$image_config[0].'x'.$image_config[1].'.'.$imagen_ext; $result['name'] = $fullpath_new; $result['width'] = $image_config[0]; $result['height'] = $image_config[1]; }elseif ( $image_config[2]===true && $image_config[3]===null ) { $imagesize = getimagesize($this->getFullPath().$path.$imagen); $imagesize_new = $this->getImageCalSize(array($imagesize[0],$imagesize[1]),$image_config); $fullpath_new = $imagen_name.'-'.$imagesize_new[0].'x'.$imagesize_new[1].'.'.$imagen_ext; $result['name'] = $fullpath_new; $result['width'] = $imagesize_new[0]; $result['height'] = $imagesize_new[1]; }elseif ( $image_config[2]===null && $image_config[3]===true ) { $imagesize = getimagesize($this->getFullPath().$path.$imagen); $imagesize_new = $this->getImageCalSize(array($imagesize[0],$imagesize[1]),$image_config); $fullpath_new = $imagen_name.'-'.$imagesize_new[0].'x'.$imagesize_new[1].'.'.$imagen_ext; $result['name'] = $fullpath_new; $result['width'] = $imagesize_new[0]; $result['height'] = $imagesize_new[1]; } return $result; }
php
public function imageSizeName($path,$imagen,$image_config) { $result = array("name"=>'',"width"=>0,"height"=>0); $imagen_ext = $this->getExtension($imagen); $imagen_name = $this->removeExtension($imagen); if ($image_config[2]===true && $image_config[3]===true) { $fullpath_new = $imagen_name.'-'.$image_config[0].'x'.$image_config[1].'.'.$imagen_ext; $result['name'] = $fullpath_new; $result['width'] = $image_config[0]; $result['height'] = $image_config[1]; }elseif ( $image_config[2]===true && $image_config[3]===null ) { $imagesize = getimagesize($this->getFullPath().$path.$imagen); $imagesize_new = $this->getImageCalSize(array($imagesize[0],$imagesize[1]),$image_config); $fullpath_new = $imagen_name.'-'.$imagesize_new[0].'x'.$imagesize_new[1].'.'.$imagen_ext; $result['name'] = $fullpath_new; $result['width'] = $imagesize_new[0]; $result['height'] = $imagesize_new[1]; }elseif ( $image_config[2]===null && $image_config[3]===true ) { $imagesize = getimagesize($this->getFullPath().$path.$imagen); $imagesize_new = $this->getImageCalSize(array($imagesize[0],$imagesize[1]),$image_config); $fullpath_new = $imagen_name.'-'.$imagesize_new[0].'x'.$imagesize_new[1].'.'.$imagen_ext; $result['name'] = $fullpath_new; $result['width'] = $imagesize_new[0]; $result['height'] = $imagesize_new[1]; } return $result; }
[ "public", "function", "imageSizeName", "(", "$", "path", ",", "$", "imagen", ",", "$", "image_config", ")", "{", "$", "result", "=", "array", "(", "\"name\"", "=>", "''", ",", "\"width\"", "=>", "0", ",", "\"height\"", "=>", "0", ")", ";", "$", "imag...
Devuelva el nuevo nombre y dimesion de imagen @param string $path ruta relativa @param string $imagen nombre de imagen @param array $image_config dimensiones de imagenes @return array
[ "Devuelva", "el", "nuevo", "nombre", "y", "dimesion", "de", "imagen" ]
5a0d1a68d17fe0dca0206958632a17d153f6389f
https://github.com/guillermomartinez/filemanager-php/blob/5a0d1a68d17fe0dca0206958632a17d153f6389f/src/GuillermoMartinez/Filemanager/Filemanager.php#L477-L503
38,484
guillermomartinez/filemanager-php
src/GuillermoMartinez/Filemanager/Filemanager.php
Filemanager.getImageCalSize
public function getImageCalSize($imagesize=array(),$image_config=array()) { $r = array(); if(count($imagesize)>0 && isset($imagesize[0],$imagesize[1]) && count($image_config)>0){ if ($image_config[2]===true && $image_config[3]===null) { $por = $image_config[0] / $imagesize[0]; $height = round($imagesize[1] * $por); $r[0] = $image_config[0]; $r[1] = $height; }elseif ($image_config[2]===null && $image_config[3]===true) { $por = $image_config[1] / $imagesize[1]; $width = round($imagesize[0] * $por); $r[0] = $width; $r[1] = $image_config[1]; }else{ $r[0] = $image_config[0]; $r[1] = $image_config[1]; } } return $r; }
php
public function getImageCalSize($imagesize=array(),$image_config=array()) { $r = array(); if(count($imagesize)>0 && isset($imagesize[0],$imagesize[1]) && count($image_config)>0){ if ($image_config[2]===true && $image_config[3]===null) { $por = $image_config[0] / $imagesize[0]; $height = round($imagesize[1] * $por); $r[0] = $image_config[0]; $r[1] = $height; }elseif ($image_config[2]===null && $image_config[3]===true) { $por = $image_config[1] / $imagesize[1]; $width = round($imagesize[0] * $por); $r[0] = $width; $r[1] = $image_config[1]; }else{ $r[0] = $image_config[0]; $r[1] = $image_config[1]; } } return $r; }
[ "public", "function", "getImageCalSize", "(", "$", "imagesize", "=", "array", "(", ")", ",", "$", "image_config", "=", "array", "(", ")", ")", "{", "$", "r", "=", "array", "(", ")", ";", "if", "(", "count", "(", "$", "imagesize", ")", ">", "0", "...
Calcula las dimensiones de la imagen @param array $imagesize dimension de la imagen @param array $image_config dimensiones de la imagen @return array dimension de la nueva imagen
[ "Calcula", "las", "dimensiones", "de", "la", "imagen" ]
5a0d1a68d17fe0dca0206958632a17d153f6389f
https://github.com/guillermomartinez/filemanager-php/blob/5a0d1a68d17fe0dca0206958632a17d153f6389f/src/GuillermoMartinez/Filemanager/Filemanager.php#L511-L531
38,485
guillermomartinez/filemanager-php
src/GuillermoMartinez/Filemanager/Filemanager.php
Filemanager.upload
public function upload($file,$path){ if( $this->validExt($file->getClientOriginalName())){ if($file->getClientSize() > ($this->getMaxUploadFileSize() * 1024 * 1024) ){ $result = array("query"=>"BE_UPLOAD_FILE_SIZE_NOT_SERVER","params"=>array($file->getClientSize())); $this->setInfo(array("msg"=>$result)); if( $this->config['debug'] ) $this->_log(__METHOD__." - file size no permitido server: ".$file->getClientSize()); return ; }elseif($file->getClientSize() > ($this->config['upload']['size_max'] * 1024 * 1024) ){ $result = array("query"=>"BE_UPLOAD_FILE_SIZE_NOT_PERMITIDO","params"=>array($file->getClientSize())); $this->setInfo(array("msg"=>$result)); if( $this->config['debug'] ) $this->_log(__METHOD__." - file size no permitido: ".$file->getClientSize()); return ; }else{ if($file->isValid()){ $dir = $this->getFullPath().$path; $namefile = $file->getClientOriginalName(); $namefile = $this->clearNameFile($namefile); $nametemp = $namefile; if( $this->config["upload"]["overwrite"] ==false){ $ext = $this->getExtension($namefile); $i=0; while(true){ $pathnametemp = $dir.$nametemp; if(file_exists($pathnametemp)){ $i++; $nametemp = $this->removeExtension( $namefile ) . '_' . $i . '.' . $ext ; }else{ break; } } } $file->move($dir,$nametemp); $file = new \SplFileInfo($dir.$nametemp); return $file; } } }else{ if( $this->config['debug'] ) $this->_log(__METHOD__." - file extension no permitido: ".$file->getExtension()); } }
php
public function upload($file,$path){ if( $this->validExt($file->getClientOriginalName())){ if($file->getClientSize() > ($this->getMaxUploadFileSize() * 1024 * 1024) ){ $result = array("query"=>"BE_UPLOAD_FILE_SIZE_NOT_SERVER","params"=>array($file->getClientSize())); $this->setInfo(array("msg"=>$result)); if( $this->config['debug'] ) $this->_log(__METHOD__." - file size no permitido server: ".$file->getClientSize()); return ; }elseif($file->getClientSize() > ($this->config['upload']['size_max'] * 1024 * 1024) ){ $result = array("query"=>"BE_UPLOAD_FILE_SIZE_NOT_PERMITIDO","params"=>array($file->getClientSize())); $this->setInfo(array("msg"=>$result)); if( $this->config['debug'] ) $this->_log(__METHOD__." - file size no permitido: ".$file->getClientSize()); return ; }else{ if($file->isValid()){ $dir = $this->getFullPath().$path; $namefile = $file->getClientOriginalName(); $namefile = $this->clearNameFile($namefile); $nametemp = $namefile; if( $this->config["upload"]["overwrite"] ==false){ $ext = $this->getExtension($namefile); $i=0; while(true){ $pathnametemp = $dir.$nametemp; if(file_exists($pathnametemp)){ $i++; $nametemp = $this->removeExtension( $namefile ) . '_' . $i . '.' . $ext ; }else{ break; } } } $file->move($dir,$nametemp); $file = new \SplFileInfo($dir.$nametemp); return $file; } } }else{ if( $this->config['debug'] ) $this->_log(__METHOD__." - file extension no permitido: ".$file->getExtension()); } }
[ "public", "function", "upload", "(", "$", "file", ",", "$", "path", ")", "{", "if", "(", "$", "this", "->", "validExt", "(", "$", "file", "->", "getClientOriginalName", "(", ")", ")", ")", "{", "if", "(", "$", "file", "->", "getClientSize", "(", ")...
Mueve un arcivo subido @param UploadedFile $file @param string $path @return SplFileInfo|null
[ "Mueve", "un", "arcivo", "subido" ]
5a0d1a68d17fe0dca0206958632a17d153f6389f
https://github.com/guillermomartinez/filemanager-php/blob/5a0d1a68d17fe0dca0206958632a17d153f6389f/src/GuillermoMartinez/Filemanager/Filemanager.php#L600-L643
38,486
guillermomartinez/filemanager-php
src/GuillermoMartinez/Filemanager/Filemanager.php
Filemanager.uploadAll
public function uploadAll($files,$path){ if( is_array($files) && count($files) > 0 ){ $n = count($files); if( $n <= $this->config['upload']['number'] ){ $res = array(); $notresult = array(); foreach ($files as $key => $value) { $file = $this->upload($value,$path); if( $file ){ $this->createThumb($file,$path); $res[] = $file->getFilename(); }else{ $notresult[] = $value->getClientOriginalName(); } } $r = ''; $n2 = count($res); $result = array("query"=>"BE_UPLOADALL_UPLOADS %s / %s","params"=>array($n2,$n)); if(count($notresult)>0){ $result['query'] = $result['query'].' | BE_UPLOADALL_NOT_UPLOADS '; $i=0; $n = count($notresult); foreach ($notresult as $value) { $result['query'] = $result['query'] . ' %s'; if( $n - 1 > $i ){ $result['query'] = $result['query'] . ','; $value = $value.','; } $result['params'][] = $value; $i++; } $this->setInfo(array("status"=>0)); } $this->setInfo(array("msg"=>$result)); return $res; }else{ $result = array("query"=>"BE_UPLOAD_MAX_UPLOAD %s","params"=>array($this->config['upload']['number'])); $this->setInfo(array("msg"=>$result,"status"=>0)); } }else{ return ; } }
php
public function uploadAll($files,$path){ if( is_array($files) && count($files) > 0 ){ $n = count($files); if( $n <= $this->config['upload']['number'] ){ $res = array(); $notresult = array(); foreach ($files as $key => $value) { $file = $this->upload($value,$path); if( $file ){ $this->createThumb($file,$path); $res[] = $file->getFilename(); }else{ $notresult[] = $value->getClientOriginalName(); } } $r = ''; $n2 = count($res); $result = array("query"=>"BE_UPLOADALL_UPLOADS %s / %s","params"=>array($n2,$n)); if(count($notresult)>0){ $result['query'] = $result['query'].' | BE_UPLOADALL_NOT_UPLOADS '; $i=0; $n = count($notresult); foreach ($notresult as $value) { $result['query'] = $result['query'] . ' %s'; if( $n - 1 > $i ){ $result['query'] = $result['query'] . ','; $value = $value.','; } $result['params'][] = $value; $i++; } $this->setInfo(array("status"=>0)); } $this->setInfo(array("msg"=>$result)); return $res; }else{ $result = array("query"=>"BE_UPLOAD_MAX_UPLOAD %s","params"=>array($this->config['upload']['number'])); $this->setInfo(array("msg"=>$result,"status"=>0)); } }else{ return ; } }
[ "public", "function", "uploadAll", "(", "$", "files", ",", "$", "path", ")", "{", "if", "(", "is_array", "(", "$", "files", ")", "&&", "count", "(", "$", "files", ")", ">", "0", ")", "{", "$", "n", "=", "count", "(", "$", "files", ")", ";", "...
Upload all files @param array $files @param string $path @return array|null
[ "Upload", "all", "files" ]
5a0d1a68d17fe0dca0206958632a17d153f6389f
https://github.com/guillermomartinez/filemanager-php/blob/5a0d1a68d17fe0dca0206958632a17d153f6389f/src/GuillermoMartinez/Filemanager/Filemanager.php#L651-L694
38,487
guillermomartinez/filemanager-php
src/GuillermoMartinez/Filemanager/Filemanager.php
Filemanager.newFolder
public function newFolder($namefile,$path){ $fullpath = $this->getFullPath().$path; $namefile = $this->clearNameFile($namefile); $namefile = $this->sanitizeNameFolder($namefile); $dir = new Filesystem; if($dir->exists($fullpath.$namefile)){ $result = array("query"=>"BE_NEW_FOLDER_EXISTED %s","params"=>array($path.$namefile)); $this->setInfo(array("msg"=>$result,"status"=>0)); if( $this->config['debug'] ) $this->_log(__METHOD__." - Ya existe: ".$path.$namefile); return false; }else{ $dir->mkdir($fullpath.$namefile); $result = array("query"=>"BE_NEW_FOLDER_CREATED %s","params"=>array($path.$namefile)); $this->setInfo(array("msg"=>$result,"data"=>array( "path" => $path, "namefile" => $namefile ))); return true; } }
php
public function newFolder($namefile,$path){ $fullpath = $this->getFullPath().$path; $namefile = $this->clearNameFile($namefile); $namefile = $this->sanitizeNameFolder($namefile); $dir = new Filesystem; if($dir->exists($fullpath.$namefile)){ $result = array("query"=>"BE_NEW_FOLDER_EXISTED %s","params"=>array($path.$namefile)); $this->setInfo(array("msg"=>$result,"status"=>0)); if( $this->config['debug'] ) $this->_log(__METHOD__." - Ya existe: ".$path.$namefile); return false; }else{ $dir->mkdir($fullpath.$namefile); $result = array("query"=>"BE_NEW_FOLDER_CREATED %s","params"=>array($path.$namefile)); $this->setInfo(array("msg"=>$result,"data"=>array( "path" => $path, "namefile" => $namefile ))); return true; } }
[ "public", "function", "newFolder", "(", "$", "namefile", ",", "$", "path", ")", "{", "$", "fullpath", "=", "$", "this", "->", "getFullPath", "(", ")", ".", "$", "path", ";", "$", "namefile", "=", "$", "this", "->", "clearNameFile", "(", "$", "namefil...
Renombra una carpeta @param string $namefile @param string $path @return boolean
[ "Renombra", "una", "carpeta" ]
5a0d1a68d17fe0dca0206958632a17d153f6389f
https://github.com/guillermomartinez/filemanager-php/blob/5a0d1a68d17fe0dca0206958632a17d153f6389f/src/GuillermoMartinez/Filemanager/Filemanager.php#L702-L718
38,488
findbrok/php-watson-api-bridge
src/WatsonBridgeServiceProvider.php
WatsonBridgeServiceProvider.registerDefaultBridge
protected function registerDefaultBridge() { $this->app->bind(Bridge::class, function (Application $app) { /** @var Carpenter $carpenter */ $carpenter = $app->make(Carpenter::class); /** @var Repository $config */ $config = $app->make(Repository::class); return $carpenter->constructBridge( $config->get('watson-bridge.default_credentials'), null, $config->get('watson-bridge.default_auth_method') ); }); }
php
protected function registerDefaultBridge() { $this->app->bind(Bridge::class, function (Application $app) { /** @var Carpenter $carpenter */ $carpenter = $app->make(Carpenter::class); /** @var Repository $config */ $config = $app->make(Repository::class); return $carpenter->constructBridge( $config->get('watson-bridge.default_credentials'), null, $config->get('watson-bridge.default_auth_method') ); }); }
[ "protected", "function", "registerDefaultBridge", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "Bridge", "::", "class", ",", "function", "(", "Application", "$", "app", ")", "{", "/** @var Carpenter $carpenter */", "$", "carpenter", "=", "$", ...
Registers the Default Bridge.
[ "Registers", "the", "Default", "Bridge", "." ]
468da14e6b9fd4fef4f58cd32dd6533b7013f5ba
https://github.com/findbrok/php-watson-api-bridge/blob/468da14e6b9fd4fef4f58cd32dd6533b7013f5ba/src/WatsonBridgeServiceProvider.php#L53-L67
38,489
findbrok/php-watson-api-bridge
src/Support/Carpenter.php
Carpenter.constructBridge
public function constructBridge($credential, $service = null, $authMethod = 'credentials') { // Get credentials array. $credentials = $this->getCredentials($credential); // Make sure credentials information is available. if (! isset($credentials['username']) || ! isset($credentials['password']) || ! isset($credentials['gateway'])) { throw new WatsonBridgeException('Could not construct Bridge, missing some information in credentials.', 500); } // Make bridge. $bridge = $this->makeRawBridge() ->setUsername($credentials['username']) ->setPassword($credentials['password']) ->setEndPoint($credentials['gateway']) ->setClient($credentials['gateway']) ->appendHeaders(['X-Watson-Learning-Opt-Out' => config('watson-bridge.x_watson_learning_opt_out')]); // Add service. $bridge = $this->addServiceToBridge($bridge, $service); // Choose an auth method. $bridge = $this->chooseAuthMethodForBridge($bridge, $authMethod); return $bridge; }
php
public function constructBridge($credential, $service = null, $authMethod = 'credentials') { // Get credentials array. $credentials = $this->getCredentials($credential); // Make sure credentials information is available. if (! isset($credentials['username']) || ! isset($credentials['password']) || ! isset($credentials['gateway'])) { throw new WatsonBridgeException('Could not construct Bridge, missing some information in credentials.', 500); } // Make bridge. $bridge = $this->makeRawBridge() ->setUsername($credentials['username']) ->setPassword($credentials['password']) ->setEndPoint($credentials['gateway']) ->setClient($credentials['gateway']) ->appendHeaders(['X-Watson-Learning-Opt-Out' => config('watson-bridge.x_watson_learning_opt_out')]); // Add service. $bridge = $this->addServiceToBridge($bridge, $service); // Choose an auth method. $bridge = $this->chooseAuthMethodForBridge($bridge, $authMethod); return $bridge; }
[ "public", "function", "constructBridge", "(", "$", "credential", ",", "$", "service", "=", "null", ",", "$", "authMethod", "=", "'credentials'", ")", "{", "// Get credentials array.", "$", "credentials", "=", "$", "this", "->", "getCredentials", "(", "$", "cre...
Constructs a new Bridge. @param string $credential @param string $service @param string $authMethod @throws WatsonBridgeException @return Bridge
[ "Constructs", "a", "new", "Bridge", "." ]
468da14e6b9fd4fef4f58cd32dd6533b7013f5ba
https://github.com/findbrok/php-watson-api-bridge/blob/468da14e6b9fd4fef4f58cd32dd6533b7013f5ba/src/Support/Carpenter.php#L20-L46
38,490
findbrok/php-watson-api-bridge
src/Support/Carpenter.php
Carpenter.addServiceToBridge
protected function addServiceToBridge(Bridge $bridge, $service = null) { // Add a service if necessary. if (! is_null($service)) { $bridge->usingService($service); } return $bridge; }
php
protected function addServiceToBridge(Bridge $bridge, $service = null) { // Add a service if necessary. if (! is_null($service)) { $bridge->usingService($service); } return $bridge; }
[ "protected", "function", "addServiceToBridge", "(", "Bridge", "$", "bridge", ",", "$", "service", "=", "null", ")", "{", "// Add a service if necessary.", "if", "(", "!", "is_null", "(", "$", "service", ")", ")", "{", "$", "bridge", "->", "usingService", "("...
Adds a Service to the Bridge. @param Bridge $bridge @param string $service @return Bridge
[ "Adds", "a", "Service", "to", "the", "Bridge", "." ]
468da14e6b9fd4fef4f58cd32dd6533b7013f5ba
https://github.com/findbrok/php-watson-api-bridge/blob/468da14e6b9fd4fef4f58cd32dd6533b7013f5ba/src/Support/Carpenter.php#L66-L74
38,491
findbrok/php-watson-api-bridge
src/Support/Carpenter.php
Carpenter.chooseAuthMethodForBridge
protected function chooseAuthMethodForBridge(Bridge $bridge, $username, $authMethod = null) { // Check if an auth method is passed explicitly. if (! is_null($authMethod) && collect(config('watson-bridge.auth_methods'))->contains($authMethod)) { $bridge->useAuthMethodAs($authMethod); // Auth method is token so we need to set Token. if ($authMethod == 'token') { $bridge->setToken($username); } } return $bridge; }
php
protected function chooseAuthMethodForBridge(Bridge $bridge, $username, $authMethod = null) { // Check if an auth method is passed explicitly. if (! is_null($authMethod) && collect(config('watson-bridge.auth_methods'))->contains($authMethod)) { $bridge->useAuthMethodAs($authMethod); // Auth method is token so we need to set Token. if ($authMethod == 'token') { $bridge->setToken($username); } } return $bridge; }
[ "protected", "function", "chooseAuthMethodForBridge", "(", "Bridge", "$", "bridge", ",", "$", "username", ",", "$", "authMethod", "=", "null", ")", "{", "// Check if an auth method is passed explicitly.", "if", "(", "!", "is_null", "(", "$", "authMethod", ")", "&&...
Choose an Auth Method for the Bridge. @param Bridge $bridge @param string $username @param string $authMethod @return Bridge
[ "Choose", "an", "Auth", "Method", "for", "the", "Bridge", "." ]
468da14e6b9fd4fef4f58cd32dd6533b7013f5ba
https://github.com/findbrok/php-watson-api-bridge/blob/468da14e6b9fd4fef4f58cd32dd6533b7013f5ba/src/Support/Carpenter.php#L85-L98
38,492
findbrok/php-watson-api-bridge
src/Bridge.php
Bridge.setToken
public function setToken($username = null) { // Only set Token if Username is supplied. if (! is_null($username)) { $this->token = new Token($username); } return $this; }
php
public function setToken($username = null) { // Only set Token if Username is supplied. if (! is_null($username)) { $this->token = new Token($username); } return $this; }
[ "public", "function", "setToken", "(", "$", "username", "=", "null", ")", "{", "// Only set Token if Username is supplied.", "if", "(", "!", "is_null", "(", "$", "username", ")", ")", "{", "$", "this", "->", "token", "=", "new", "Token", "(", "$", "usernam...
Sets the Token. @param string $username @return $this
[ "Sets", "the", "Token", "." ]
468da14e6b9fd4fef4f58cd32dd6533b7013f5ba
https://github.com/findbrok/php-watson-api-bridge/blob/468da14e6b9fd4fef4f58cd32dd6533b7013f5ba/src/Bridge.php#L142-L150
38,493
findbrok/php-watson-api-bridge
src/Bridge.php
Bridge.cleanOptions
public function cleanOptions($options = []) { // If item is null or empty we will remove them. return collect($options)->reject(function ($item) { return empty($item) || is_null($item); })->all(); }
php
public function cleanOptions($options = []) { // If item is null or empty we will remove them. return collect($options)->reject(function ($item) { return empty($item) || is_null($item); })->all(); }
[ "public", "function", "cleanOptions", "(", "$", "options", "=", "[", "]", ")", "{", "// If item is null or empty we will remove them.", "return", "collect", "(", "$", "options", ")", "->", "reject", "(", "function", "(", "$", "item", ")", "{", "return", "empty...
Clean options by removing empty items. @param array $options @return array
[ "Clean", "options", "by", "removing", "empty", "items", "." ]
468da14e6b9fd4fef4f58cd32dd6533b7013f5ba
https://github.com/findbrok/php-watson-api-bridge/blob/468da14e6b9fd4fef4f58cd32dd6533b7013f5ba/src/Bridge.php#L178-L184
38,494
findbrok/php-watson-api-bridge
src/Bridge.php
Bridge.failedRequest
public function failedRequest(Response $response) { // Decode Response. $decodedResponse = json_decode($response->getBody()->getContents(), true); // Get error message. $errorMessage = (isset($decodedResponse['error_message']) && ! is_null($decodedResponse['error_message'])) ? $decodedResponse['error_message'] : $response->getReasonPhrase(); // ClientException. throw new WatsonBridgeException($errorMessage, $response->getStatusCode()); }
php
public function failedRequest(Response $response) { // Decode Response. $decodedResponse = json_decode($response->getBody()->getContents(), true); // Get error message. $errorMessage = (isset($decodedResponse['error_message']) && ! is_null($decodedResponse['error_message'])) ? $decodedResponse['error_message'] : $response->getReasonPhrase(); // ClientException. throw new WatsonBridgeException($errorMessage, $response->getStatusCode()); }
[ "public", "function", "failedRequest", "(", "Response", "$", "response", ")", "{", "// Decode Response.", "$", "decodedResponse", "=", "json_decode", "(", "$", "response", "->", "getBody", "(", ")", "->", "getContents", "(", ")", ",", "true", ")", ";", "// G...
Failed Request to Watson. @param Response $response @throws WatsonBridgeException
[ "Failed", "Request", "to", "Watson", "." ]
468da14e6b9fd4fef4f58cd32dd6533b7013f5ba
https://github.com/findbrok/php-watson-api-bridge/blob/468da14e6b9fd4fef4f58cd32dd6533b7013f5ba/src/Bridge.php#L218-L226
38,495
findbrok/php-watson-api-bridge
src/Bridge.php
Bridge.fetchToken
public function fetchToken($incrementThrottle = false) { // Increment throttle if needed. if ($incrementThrottle) { $this->incrementThrottle(); } // Reset Client. $this->setClient($this->getAuthorizationEndpoint()); // Get the token response. $response = $this->get('v1/token', [ 'url' => $this->endpoint, ]); // Extract. $token = json_decode($response->getBody()->getContents(), true); // Reset client. $this->setClient($this->endpoint); // Update token. $this->token->updateToken($token['token']); }
php
public function fetchToken($incrementThrottle = false) { // Increment throttle if needed. if ($incrementThrottle) { $this->incrementThrottle(); } // Reset Client. $this->setClient($this->getAuthorizationEndpoint()); // Get the token response. $response = $this->get('v1/token', [ 'url' => $this->endpoint, ]); // Extract. $token = json_decode($response->getBody()->getContents(), true); // Reset client. $this->setClient($this->endpoint); // Update token. $this->token->updateToken($token['token']); }
[ "public", "function", "fetchToken", "(", "$", "incrementThrottle", "=", "false", ")", "{", "// Increment throttle if needed.", "if", "(", "$", "incrementThrottle", ")", "{", "$", "this", "->", "incrementThrottle", "(", ")", ";", "}", "// Reset Client.", "$", "th...
Fetch token from Watson and Save it locally. @param bool $incrementThrottle @return void
[ "Fetch", "token", "from", "Watson", "and", "Save", "it", "locally", "." ]
468da14e6b9fd4fef4f58cd32dd6533b7013f5ba
https://github.com/findbrok/php-watson-api-bridge/blob/468da14e6b9fd4fef4f58cd32dd6533b7013f5ba/src/Bridge.php#L235-L253
38,496
findbrok/php-watson-api-bridge
src/Bridge.php
Bridge.getAuthorizationEndpoint
public function getAuthorizationEndpoint() { // Parse the endpoint. $parsedEndpoint = collect(parse_url($this->endpoint)); // Return auth url. return $parsedEndpoint->get('scheme').'://'.$parsedEndpoint->get('host').'/authorization/api/'; }
php
public function getAuthorizationEndpoint() { // Parse the endpoint. $parsedEndpoint = collect(parse_url($this->endpoint)); // Return auth url. return $parsedEndpoint->get('scheme').'://'.$parsedEndpoint->get('host').'/authorization/api/'; }
[ "public", "function", "getAuthorizationEndpoint", "(", ")", "{", "// Parse the endpoint.", "$", "parsedEndpoint", "=", "collect", "(", "parse_url", "(", "$", "this", "->", "endpoint", ")", ")", ";", "// Return auth url.", "return", "$", "parsedEndpoint", "->", "ge...
Get the authorization endpoint for getting tokens. @return string
[ "Get", "the", "authorization", "endpoint", "for", "getting", "tokens", "." ]
468da14e6b9fd4fef4f58cd32dd6533b7013f5ba
https://github.com/findbrok/php-watson-api-bridge/blob/468da14e6b9fd4fef4f58cd32dd6533b7013f5ba/src/Bridge.php#L285-L292
38,497
findbrok/php-watson-api-bridge
src/Bridge.php
Bridge.setClient
public function setClient($endpoint = null) { // Create client using API endpoint. $this->client = new Client([ 'base_uri' => ! is_null($endpoint) ? $endpoint : $this->endpoint, ]); return $this; }
php
public function setClient($endpoint = null) { // Create client using API endpoint. $this->client = new Client([ 'base_uri' => ! is_null($endpoint) ? $endpoint : $this->endpoint, ]); return $this; }
[ "public", "function", "setClient", "(", "$", "endpoint", "=", "null", ")", "{", "// Create client using API endpoint.", "$", "this", "->", "client", "=", "new", "Client", "(", "[", "'base_uri'", "=>", "!", "is_null", "(", "$", "endpoint", ")", "?", "$", "e...
Creates the http client. @param string $endpoint @return $this
[ "Creates", "the", "http", "client", "." ]
468da14e6b9fd4fef4f58cd32dd6533b7013f5ba
https://github.com/findbrok/php-watson-api-bridge/blob/468da14e6b9fd4fef4f58cd32dd6533b7013f5ba/src/Bridge.php#L301-L309
38,498
findbrok/php-watson-api-bridge
src/Bridge.php
Bridge.usingService
public function usingService($serviceName) { // Check if service exists first. if (! config()->has('watson-bridge.services.'.$serviceName)) { throw new WatsonBridgeException('Unknown service "'.$serviceName.'" try adding it to the list of services in watson-bridge config.'); } // Get service endpoint. $serviceUrl = config('watson-bridge.services.'.$serviceName); // Reset Client. $this->setClient(rtrim($this->endpoint, '/').'/'.ltrim($serviceUrl, '/')); return $this; }
php
public function usingService($serviceName) { // Check if service exists first. if (! config()->has('watson-bridge.services.'.$serviceName)) { throw new WatsonBridgeException('Unknown service "'.$serviceName.'" try adding it to the list of services in watson-bridge config.'); } // Get service endpoint. $serviceUrl = config('watson-bridge.services.'.$serviceName); // Reset Client. $this->setClient(rtrim($this->endpoint, '/').'/'.ltrim($serviceUrl, '/')); return $this; }
[ "public", "function", "usingService", "(", "$", "serviceName", ")", "{", "// Check if service exists first.", "if", "(", "!", "config", "(", ")", "->", "has", "(", "'watson-bridge.services.'", ".", "$", "serviceName", ")", ")", "{", "throw", "new", "WatsonBridge...
Set Watson service being used. @param string $serviceName @return $this
[ "Set", "Watson", "service", "being", "used", "." ]
468da14e6b9fd4fef4f58cd32dd6533b7013f5ba
https://github.com/findbrok/php-watson-api-bridge/blob/468da14e6b9fd4fef4f58cd32dd6533b7013f5ba/src/Bridge.php#L329-L343
38,499
findbrok/php-watson-api-bridge
src/Bridge.php
Bridge.getRequestOptions
public function getRequestOptions($initial = []) { // Define options. $options = collect($initial); // Define an auth option. if ($this->authMethod == 'credentials') { $options = $options->merge(['auth' => $this->getAuth()]); } elseif ($this->authMethod == 'token') { $this->appendHeaders(['X-Watson-Authorization-Token' => $this->getToken()]); } // Put Headers in options. $options = $options->merge(['headers' => $this->getHeaders()]); // Clean and return. return $this->cleanOptions($options->all()); }
php
public function getRequestOptions($initial = []) { // Define options. $options = collect($initial); // Define an auth option. if ($this->authMethod == 'credentials') { $options = $options->merge(['auth' => $this->getAuth()]); } elseif ($this->authMethod == 'token') { $this->appendHeaders(['X-Watson-Authorization-Token' => $this->getToken()]); } // Put Headers in options. $options = $options->merge(['headers' => $this->getHeaders()]); // Clean and return. return $this->cleanOptions($options->all()); }
[ "public", "function", "getRequestOptions", "(", "$", "initial", "=", "[", "]", ")", "{", "// Define options.", "$", "options", "=", "collect", "(", "$", "initial", ")", ";", "// Define an auth option.", "if", "(", "$", "this", "->", "authMethod", "==", "'cre...
Get Request options to pass along. @param array $initial @return array
[ "Get", "Request", "options", "to", "pass", "along", "." ]
468da14e6b9fd4fef4f58cd32dd6533b7013f5ba
https://github.com/findbrok/php-watson-api-bridge/blob/468da14e6b9fd4fef4f58cd32dd6533b7013f5ba/src/Bridge.php#L363-L380