{@inheritDoc}

Exemplos de métodos

visualizar => Visualizar
visualizar-itens => VisualizarItens
visualizaritens => Visualizaritens
766849
public function uriToMethodName(string $uri): string 
    {
        $string_parts = explode("-", $uri);
        $string = array_map('ucfirst', $string_parts);
        $string[0] = strtolower($string[0]);
        $string = implode("", $string); 
        return preg_replace("/[^a-zA-Z0-9\-]/", "", $string);
    }
1292869
public function index() {
        $wt_tree = Globals::getTree();
        Theme::theme(new AdministrationTheme)->init($wt_tree);
        $controller = new PageController();
        $controller
            ->restrictAccess(Auth::isManager($wt_tree))
            ->setPageTitle($this->module->getTitle());
        
        $data = new ViewBag();
        $data->set('title', $controller->getPageTitle());
        $data->set('tree', $wt_tree);
        
        $data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig');
                
        $table_id = 'table-geoanalysis-' . Uuid::uuid4();
        $data->set('table_id', $table_id);
        
        $other_trees = array();
        foreach (Tree::getAll() as $tree) {
            if($tree->getTreeId() != $wt_tree->getTreeId()) $other_trees[] = $tree;
        }      
        $data->set('other_trees', $other_trees);
        
        $data->set('places_hierarchy', $this->provider->getPlacesHierarchy());
        
        $controller
            ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
            ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)
            ->addInlineJavascript('
				jQuery.fn.dataTableExt.oSort["text-asc"] = textCompareAsc;
				jQuery.fn.dataTableExt.oSort["text-desc"] = textCompareDesc;
                
				var geoAnalysisTable = jQuery("#'.$table_id.'")
                .on("draw.dt", function ( e, settings, json, xhr ) {
                    jQuery("[data-toggle=\'tooltip\']").tooltip();
                }).DataTable({
					'.I18N::datatablesI18N().',			
					sorting: [[3, "asc"], [4, "asc"]],
					pageLength: 10,
                    processing: true,
                    serverSide : true,
					ajax : {
						url : "module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@jsonGeoAnalysisList&ged='. $wt_tree->getNameUrl().'",
                        type : "POST"
					},
                    columns: [
						/* 0 Edit		 	*/ { sortable: false, className: "text-center"},
                        /* 1 ID             */ { sortable: false, visible: false},
						/* 2 Enabled 		*/ { sortable: false, className: "text-center"  },
						/* 3 Description	*/ { type: "text" },
						/* 4 Analysis Level	*/ { type: "text", dataSort: 5, className: "text-center" },
						/* 5 ANAL_LEVEL_SORT*/ { type: "num", visible: false },
						/* 6 Map 	        */ { type: "text", sortable: false, className: "text-center" },
						/* 7 Map Top Level 	*/ { type: "text", sortable: false, className: "text-center" },
						/* 8 Use Flags     	*/ { type: "text", sortable: false, className: "text-center" },					
						/* 9 Place Details	*/ { type: "text", sortable: false, className: "text-center" }
					],
				});
                
                ')
                ->addInlineJavascript('				
                    function set_geoanalysis_status(ga_id, status, gedcom) {
                		jQuery.ajax({
                            url: "module.php", 
                            type: "GET",
                            data: {
                			    mod: "' . $this->module->getName() .'",
                                mod_action:  "GeoAnalysis@setStatus",
                			    ga_id: ga_id,
                			    ged: typeof gedcom === "undefined" ? WT_GEDCOM : gedcom,
                                status: status
                            },
                            error: function(result, stat, error) {
                                var err = typeof result.responseJSON === "undefined" ? error : result.responseJSON.error;
                                alert("' . I18N::translate('An error occured while editing this analysis:') . '" + err);
                            },
                            complete: function(result, stat) {
                                geoAnalysisTable.ajax.reload(null, false);
                            }                            
                		});
                    }
                    
                    function delete_geoanalysis(ga_id, status, gedcom) {
                		jQuery.ajax({
                            url: "module.php", 
                            type: "GET",
                            data: {
                			    mod: "' . $this->module->getName() .'",
                                mod_action:  "GeoAnalysis@delete",
                			    ga_id: ga_id,
                			    ged: typeof gedcom === "undefined" ? WT_GEDCOM : gedcom
                            },
                            error: function(result, stat, error) {
                                var err = typeof result.responseJSON === "undefined" ? error : result.responseJSON.error;
                                alert("' . I18N::translate('An error occured while deleting this analysis:') . '" + err);
                            },
                            complete: function(result, stat) {
                                geoAnalysisTable.ajax.reload(null, false);
                            }                            
                		});
                    }
                ');
        
        
        ViewFactory::make('AdminConfig', $this, $controller, $data)->render();
    }
55520
private function createInstance()
    {
        if ($this->arguments === null) {
            $this->arguments = [];

            if (null !== ($method = $this->getReflection()->getConstructor())) {
                $this->arguments = $this->getArguments($method);
            }
        }

        return $this->getReflection()->newInstanceArgs($this->arguments);
    }
157246
public function compile()
    {
        $indent    = '    ';
        $getters   = array();
        $instances = $this->dumper->getAllInjectedDefinitions();

        /* @var $instance GeneratorInstance */
        foreach ($instances as $name => $instance) {
            $constructor = $instance->getConstructor();
            $instantiatorParams = $this->buildParams($instance->getParams());

            if ('__construct' !== $constructor) {
                // Constructor callback
                if (is_callable($constructor)) {
                    $callback = $constructor;

                    if (is_array($callback)) {
                        $class = (is_object($callback[0])) ? get_class($callback[0]) : $callback[0];
                        $method = $callback[1];
                    } elseif (is_string($callback) && strpos($callback, '::') !== false) {
                        list($class, $method) = explode('::', $callback, 2);
                    }

                    $callback = var_export(array($class, $method), true);

                    if (count($instantiatorParams)) {
                        $creation = sprintf('$object = call_user_func(%s, %s);', $callback, implode(', ', $instantiatorParams));
                    } else {
                        $creation = sprintf('$object = call_user_func(%s);', $callback);
                    }
                } else if (is_string($constructor) && strpos($constructor, '->') !== false) {
                    list($class, $method) = explode('->', $constructor, 2);

                    if (!class_exists($class)) {
                        throw new InvalidArgumentException('No class found: ' . $class);
                    }

                    if (count($instantiatorParams)) {
                        $creation = sprintf(
                            '$object = $di->get(%s)->%s(%s);',
                            var_export($class, true),
                            $method,
                            implode(', ', $instantiatorParams)
                        );
                    } else {
                        $creation = sprintf('$object = $di->get(%s)->%s();', var_export($class, true), $method);
                    }
                } else {
                    throw new InvalidArgumentException('Invalid instantiator supplied for class: ' . $name);
                }
            } else {
                $className = '\\' . trim($this->reduceAlias($name), '\\');

                if (count($instantiatorParams)) {
                    $creation = sprintf('$object = new %s(%s);', $className, implode(', ', $instantiatorParams));
                } else {
                    $creation = sprintf('$object = new %s();', $className);
                }
            }


            // Create method call code
            if ($instance->isShared()) {
                $creation .= "\n\nif (\$isShared) {\n" . $indent
                    . '$di->instanceManager()->addSharedInstance($object, \'' . $instance->getName() . '\');'
                    . "\n}\n";
            }

            $methods = '';

            foreach ($instance->getMethods() as $methodData) {
                $methodName   = $methodData['method'];
                $methodParams = $methodData['params'];
                // Create method parameter representation
                $params = $this->buildParams($methodParams);

                if (count($params)) {
                    $methods .= sprintf("\$object->%s(%s);\n", $methodName, implode(', ', $params));
                }
            }

            // Start creating getter
            $getterBody = "function (\\Zend\\Di\\Di \$di, \$isShared) {\n";

            // Creation and method calls
            $getterBody .= $indent . str_replace("\n", "\n" . $indent, $creation) . "\n";
            $getterBody .= $indent . str_replace("\n", "\n" . $indent, $methods);

            // End getter body
            $getterBody .= "\n" . $indent . "return \$object;\n}";

            $getters[$name] = $getterBody;
        }

        $fileBody = "return array(\n";

        foreach ($getters as $name => $getterBody) {
            $fileBody .= $indent . var_export($name, true);
            $fileBody .= ' => ' . str_replace("\n", "\n" . $indent, $getterBody) . ",\n\n";
        }

        $fileBody .= ");\n";

        // Create PHP file code generation object
        $generator = $this->getFileGenerator();
        $generator->setBody($fileBody);

        return $generator;
    }
1072892
private static function view()
    {
        $files = ['View'];
        $folder = static::$root.'MVC/View'.'/';

        self::call($files, $folder);

        $files = ['Template', 'Views'];
        $folder = static::$root.'MVC/View/Libs'.'/';

        self::call($files, $folder);

        $files = ['ViewNotFoundException'];
        $folder = static::$root.'MVC/View/Exceptions'.'/';

        self::call($files, $folder);
    }
235350
public function exposed(): MapInterface
    {
        return $this->exposed->reduce(
            new Map(Name::class, Constructor::class),
            static function(Map $exposed, string $name, Service $service): Map {
                return $exposed->put(
                    $service->exposedAs(),
                    $service->constructor()
                );
            }
        );
    }
808301
protected static function initialize()
    {
        $class = static::class;

        if (static::$constants === null) {
            static::$constants = (new \ReflectionClass($class))->getConstants();

            foreach (static::names() as $name) {
                static::$lcKeyMap[strtolower($name)] = $name;
            }
        }
    }
397544
private function getMappings(): Iterator
    {
        if ($this->mappings === null) {
            $filePaths = [];

            foreach ($this->mappingFilePaths as $mappingFilePath) {
                $newFilePaths = iterator_to_array(new SplFileObject($mappingFilePath, 'r'));
                $filePaths    = array_merge($filePaths, $newFilePaths);
            }

            $this->mappings = new ArrayIterator(
                array_map(
                    function (string $mapping) : FileMappingInterface {
                        return new UnixFileMapping(
                            $this->sourceDirectory,
                            $this->targetDirectory,
                            trim($mapping)
                        );
                    },
                    // Filter out empty lines.
                    array_filter(
                        $filePaths
                    )
                )
            );
        }

        return $this->mappings;
    }
1319567
public function view($data)
    {
        //align
        switch ($this->align) {
            case 'center': $a = ['text-align'=>'center']; break;
            case 'right': $a = ['text-align'=>'right']; break;
            case 'left':
            default: $a = ['text-align'=>'left'];
        }
        $this->styles['list_div'] = array_merge($this->styles['list_div'], $a);
        //width
        $wid = floor(100 / $this->columns) - 1;
        //data and formatter
        $this->styles['list_item'] = array_merge($this->styles['list_item'], ['width'=>"$wid%"]);
        if (array_key_exists('data', $data)) {
            $d = $data['data'];
        } else {
            $d = $data;
        }
        if (array_key_exists('label_formatter', $data)) {
            $lf = $data['label_formatter'];
        }
        if (array_key_exists('text_formatter', $data)) {
            $tf = $data['text_formatter'];
        }
        foreach ($d as $k => $v) {
            $ltext = $k;
            if(isset($lf) && is_callable($lf)) {
                $ltext = $lf($k);
            }
            $label = new Element('label', new Text($ltext));
            $label->addClass($this->getClass('list_label'))->setAttribute('style', $this->getStyle('list_label'));
            $ttext = $v;
            if(isset($tf) && is_callable($tf)) {
                $ttext = $tf($v);
            }
            $text = new Element('span', new Text($ttext));
            $text->addClass($this->getClass('list_text'))->setAttribute('style', $this->getStyle('list_text'));
            $item = new Element('div');
            $item->addClass('list_item')->setAttribute('style', $this->getStyle('list_item'));
            $item->appendChild($label)->appendChild($text);
            $this->appendChild($item);
            $this->addClass('list_div')->setAttribute('style', $this->getStyle('list_div'));
        }
        return $this->render();
    }
428471
protected function initRenderer()
    {
        $renderer = new PhpRenderer();

        $plugins = $renderer->getHelperPluginManager();
        $config  = new \Zend\Form\View\HelperConfig;
        $config->configureServiceManager($plugins);

        $resolver = new Resolver\AggregateResolver();
        $map = new Resolver\TemplateMapResolver($this->getTable()->getOptions()->getTemplateMap());
        $resolver->attach($map);

        $renderer->setResolver($resolver);
        $this->renderer = $renderer;
    }
1275989
public function getModifiers()
    {
        $modifiers = 0;

        if ($this->isFinal()) {
            $modifiers += \ReflectionClass::IS_FINAL;
        }

        if (PHP_VERSION_ID < 70000 && $this->isTrait()) {
            $modifiers += \ReflectionClass::IS_EXPLICIT_ABSTRACT;
        }

        if ($this->classLikeNode instanceof Class_ && $this->classLikeNode->isAbstract()) {
            $modifiers += \ReflectionClass::IS_EXPLICIT_ABSTRACT;
        }

        if ($this->isInterface()) {
            $abstractMethods = $this->getMethods();
        } else {
            $abstractMethods = $this->getMethods(\ReflectionMethod::IS_ABSTRACT);
        }
        if (!empty($abstractMethods)) {
            $modifiers += \ReflectionClass::IS_IMPLICIT_ABSTRACT;
        }

        return $modifiers;
    }
1201765
public function index() : ColumnMappingDefiner
    {
        return new ColumnMappingDefiner(
            function (IColumn $column) {
                $this->column($column);
                $this->indexComponentIdMap[] = $column->getComponentId();
            },
            function (string $componentId) {
                $this->indexComponentIdMap[] = $componentId;
            }
        );
    }
933141
public function setVisibility($visibility)
    {
        switch ($visibility) {
            case Modifiers::VISIBILITY_PUBLIC:
                $this->removeModifier(Modifiers::MODIFIER_PRIVATE | Modifiers::MODIFIER_PROTECTED);
                $this->addModifier(Modifiers::MODIFIER_PUBLIC);
                break;
            case Modifiers::VISIBILITY_PROTECTED:
                $this->removeModifier(Modifiers::MODIFIER_PRIVATE | Modifiers::MODIFIER_PUBLIC);
                $this->addModifier(Modifiers::MODIFIER_PROTECTED);
                break;
            case Modifiers::VISIBILITY_PRIVATE:
                $this->removeModifier(Modifiers::MODIFIER_PUBLIC | Modifiers::MODIFIER_PROTECTED);
                $this->addModifier(Modifiers::MODIFIER_PRIVATE);
                break;
            default:
                throw new InvalidArgumentException('Unknown visibility to set.');
        }
    }
254795
protected function buildMethodMaps()
    {

        $getterMap = [];
        $setterMap = [];

        $methods = (new ReflectionObject($this))->getMethods(ReflectionMethod::IS_PUBLIC);

        foreach ($methods as $method) {

            if ($this->isGetter($method)) {
                $getterMap[$this->toPropertyName($method->getName())] = $method->getName();
                continue;
            }

            if ($this->isSetter($method)) {
                $setterMap[$this->toPropertyName($method->getName())] = $method->getName();
                continue;
            }


        }

        return [$getterMap, $setterMap];
    }
43756
public function exposed(): MapInterface
    {
        return $this->dependencies->reduce(
            new Map(Name::class, MapInterface::class),
            static function(Map $exposed, string $name, Dependency $dependency): Map {
                return $exposed->put(
                    $dependency->name(),
                    $dependency->exposed()
                );
            }
        );
    }
889093
public function render(array $options = array())
    {
        $options = $this->optionsTratament($options);
        $this->_pdf = new ZfPdf\PdfDocument();
        $this->_font = ZfPdf\Font::fontWithName(ZfPdf\Font::FONT_HELVETICA);

        //$options['colors'] = array_merge($colors, (array) $options['colors']);

        $this->_la = '';
        $larg = $this->calculateCellSize();
        $this->_cellFontSize = 8;

        // Define os estilos do documento
        $this->defineStyles($options);

        // Pega o total de páginas
        $this->getTotalPages($options);

        // Adiciona página ao documento PDF
        $this->addPage($options);

        // Adicionar logomarca se definido nas opções
        $this->addLogo($options);

        // Adiciona Titulo e Subtitulo de acordo com as opções definidas
        $this->addTitle($options);

        //Iniciar a contagem de paginas
        $pagina = 1;

        // Desenha o rodapé do documento
        $this->drawFooter($pagina, $options);

        $this->_page->setFont($this->_font, $this->_cellFontSize);

        $iLarg = 0;
        foreach ($larg as $final) {
            $this->_cell[$iLarg] = round($final * ($this->_page->getWidth() - 80) / array_sum($larg));
            $iLarg++;
        }

        $cellsCount = count($this->_arrayForm['gridfieldsconfig']);
        $this->_largura = ($this->_page->getWidth() - 80) / $cellsCount;
        $this->_altura = $this->_page->getHeight() - 120;

        // Desenha os nomes dos campos
        $this->drawFieldName($this->_topo, $this->_styleText);

        $this->_page->setStyle($this->_style);

        if (is_array($this->_arrayData) and !empty($this->_arrayData)) {

            $ia = 0;
            $aa = 0;
            foreach ($this->_arrayData as $value) {
                if ($this->_altura <= 80) {

                    // Adiciona página ao documento PDF
                    $this->addPage($options);

                    $pagina++;

                    // Adicionar logomarca se definido nas opções
                    $this->addLogo($options);

                    // Adiciona Titulo e Subtitulo de acordo com as opções definidas
                    $this->addTitle($options);

                    //set font
                    $this->_altura = $this->_page->getHeight() - 120;

                    // Desenha o rodapé do documento
                    $this->drawFooter($pagina, $options);

                    //
                    $this->_largura1 = 40;
                    $this->_page->setFont($this->_font, $this->_cellFontSize + 1);

                    // Desenha os nomes dos campos
                    $this->drawFieldName($this->_topo, $this->_styleText);
                }

                $this->_la = 0;
                $this->_altura = $this->_altura - 16;
                $i = 0;
                $tdf = $ia % 2 ? $this->td : $this->td2;
                $a = 1;

                //A linha horizontal
                //$centrar = round(($this->_page->getWidth() - 80) / 2) + 30;
                if ((int) $this->_la == 0) {
                    $this->_largura1 = 40;
                } else {
                    $this->_largura1 = $this->_cell[$i - 1] + $this->_largura1;
                }
                $this->_la = 0;

                ////////////
                //Vamos saber quantas linhas tem este registo
                $nlines = array();
                $nl = 0;
                foreach ($value as $value2) {
                    $line = $this->widthForStringUsingFontSize(strip_tags(trim($value2)), $this->_font, 8);
                    $nlines[] = ceil($line / $this->_cell[$nl]);
                    $nl++;
                }

                sort($nlines);
                foreach ($value as $value1) {
                    $value1 = strip_tags(trim($value1));
                    if ((int) $this->_la == 0) {
                        $this->_largura1 = 40;
                    } else {
                        $this->_largura1 = $this->_cell[$i - 1] + $this->_largura1;
                    }

                    $this->_page->setStyle($tdf);
                    $this->_page->drawRectangle($this->_largura1, $this->_altura - 4, $this->_largura1 + $this->_cell[$i] + 1, $this->_altura + 12);
                    $this->_page->setStyle($this->_styleText);
                    $this->_page->drawText($value1, $this->_largura1 + 2, $this->_altura, 'UTF-8');
                    $this->_la = $this->_largura1;
                    $i++;
                    $a++;
                }

                $aa++;
                $ia++;
            }
        }
        header('Content-Description: File Transfer');
        header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
        header('Pragma: public');
        header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header("Content-Type: application/pdf");
        header('Content-Disposition: attachment; filename="' . $options['name'] . '.pdf"');
        header('Content-Transfer-Encoding: binary');

        echo $this->_pdf->render();
        die();
    }
1356945
public function visit($value, ?VisitorInterface $subVisitor = null)
    {
        if ($subVisitor === null) {
            throw new RuntimeException('Implementation requires sub-visitor');
        }

        return [
            'id' => $value->getId(),
            'offset' => $value->getOffset(),
            'limit' => $value->getLimit(),
            'is_translatable' => $value->isTranslatable(),
            'is_always_available' => $value->isAlwaysAvailable(),
            'main_locale' => $value->getMainLocale(),
            'available_locales' => $value->getAvailableLocales(),
            'items' => iterator_to_array($this->visitItems($value->getItems(), $subVisitor)),
            'query' => $this->visitQuery($value, $subVisitor),
        ];
    }