Skip to content

Commit

Permalink
Templates cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyklay committed Nov 2, 2019
1 parent b0df0a6 commit 24b5f36
Show file tree
Hide file tree
Showing 15 changed files with 118 additions and 118 deletions.
18 changes: 9 additions & 9 deletions Library/Documentation/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ class Template
/**
* Template constructor.
*
* @param Theme $theme
* @param $data
* @param $template
* @param int $nestedLevel
* @param Theme $theme
* @param array $data
* @param string $template
* @param int $nestedLevel
*
* @throws Exception
*/
public function __construct(Theme $theme, $data, $template, $nestedLevel = 0)
public function __construct(Theme $theme, array $data, string $template, int $nestedLevel = 0)
{
// todo clean buffer before exception
if ($nestedLevel > 800) {
Expand All @@ -53,7 +53,7 @@ public function __construct(Theme $theme, $data, $template, $nestedLevel = 0)
$this->nestedLevel = $nestedLevel;
}

private function __getTemplatePath($fileName)
private function getTemplatePath($fileName)
{
if ('/' == $fileName[0] || 0 === strpos($fileName, 'phar://')) {
return $fileName;
Expand All @@ -69,7 +69,7 @@ private function __getTemplatePath($fileName)
}

/**
* set a variable that will be accessible in the template.
* Set a variable that will be accessible in the template.
*
* @param $name
* @param $value
Expand Down Expand Up @@ -207,15 +207,15 @@ public function parse()
foreach ($this->data as $name => $value) {
$$name = $value;
}
$path = $this->__getTemplatePath($this->template);
$path = $this->getTemplatePath($this->template);
ob_start();
include $path;
$content = ob_get_clean();

return $content;
}

public function partial($fileName, array $data = [])
public function partial(string $fileName, array $data = [])
{
$newLevel = $this->nestedLevel + 1;

Expand Down
2 changes: 1 addition & 1 deletion templates/Api/themes/api-base/class.phtml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?= $this->partial("layout/layout.phtml",array("contentPartial"=>"partials/class/content.phtml")) ?>
<?= $this->partial('layout/layout.phtml', ['contentPartial' => 'partials/class/content.phtml']) ?>
2 changes: 1 addition & 1 deletion templates/Api/themes/api-base/classes.phtml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?= $this->partial("layout/layout.phtml",array("contentPartial"=>"partials/classes.phtml")) ?>
<?= $this->partial('layout/layout.phtml', ['contentPartial' => 'partials/classes.phtml']) ?>
2 changes: 1 addition & 1 deletion templates/Api/themes/api-base/index.phtml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?= $this->partial("layout/layout.phtml",array("contentPartial"=>"partials/index.phtml")) ?>
<?= $this->partial('layout/layout.phtml', ['contentPartial' => 'partials/index.phtml']) ?>
2 changes: 1 addition & 1 deletion templates/Api/themes/api-base/namespace.phtml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?= $this->partial("layout/layout.phtml",array("contentPartial"=>"partials/namespace/content.phtml")) ?>
<?= $this->partial('layout/layout.phtml', ['contentPartial' => 'partials/namespace/content.phtml']) ?>
2 changes: 1 addition & 1 deletion templates/Api/themes/api-base/namespaces.phtml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?= $this->partial("layout/layout.phtml",array("contentPartial"=>"partials/namespaces.phtml")) ?>
<?= $this->partial('layout/layout.phtml', ['contentPartial' => 'partials/namespaces.phtml']) ?>
2 changes: 1 addition & 1 deletion templates/Api/themes/api-base/source.phtml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?= $this->partial("layout/layout.phtml",array("contentPartial"=>"partials/source.phtml")) ?>
<?= $this->partial('layout/layout.phtml', ['contentPartial' => 'partials/source.phtml']) ?>
6 changes: 3 additions & 3 deletions templates/Api/themes/zephir/layout/layout.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
<?php echo $this->projectConfig("name") ?> API Documentation
<?php endif; ?>
</title>
<?php echo $this->partial("partials/assets.phtml") ?>
<script>var ZepCurrentPath = '<?php echo $this->url("/")?>'</script>
<?php echo $this->partial("partials/analytics.phtml") ?>
<?php echo $this->partial('partials/assets.phtml') ?>
<script type="application/javascript">let ZepCurrentPath = '<?php echo $this->url("/")?>'</script>
<?php echo $this->partial('partials/analytics.phtml') ?>
</head>
<body onload="prettyPrint()">
<div id="top-bar">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $docblock = $method->getParsedDocblock();
<span class="method-name">
<a href="#method-details-<?= $method->getName() ?>"><?= $method->getName() ?></a><!--
--></span><!--
-->(<?= $this->partial("partials/class/method-summary-params.phtml" ) ?>)<!--
-->(<?= $this->partial('partials/class/method-summary-params.phtml') ?>)<!--
--><span class="method-return">
<strong>:</strong>
<?php if (!empty($allTypes)):?>
Expand Down
24 changes: 12 additions & 12 deletions templates/Api/themes/zephir/partials/index.phtml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?php
$items = array(
);
/**
* @var array $namespaces
*/
?>
<?= $this->partial("partials/breadcrumb.phtml",array("items"=> $items)) ?>

<?= $this->partial('partials/breadcrumb.phtml', ['items'=> []]) ?>

<div class="namespace-list">

<ul>
<?php foreach($namespaces as $namesapceName => $ns){ ?>

<li> <a href="<?= $this->url(Zephir\Documentation::namespaceUrl($namesapceName)) ?>"><?= $namesapceName ?></a></li>

<?php } ?>
<?php foreach($namespaces as $namespaceName => $ns): ?>
<li>
<a href="<?= $this->url(Zephir\Documentation::namespaceUrl($namespaceName)) ?>">
<?= $namespaceName ?>
</a>
</li>
<?php endforeach; ?>
</ul>

</div>
</div>
55 changes: 29 additions & 26 deletions templates/Api/themes/zephir/partials/namespace/content.phtml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<?php

$items = array(
array("name" => "Namespaces" , "url" => "/namespaces.html" ),
$items[] = array("name" => $namespaceHelper->getFullNamespace())
);
/**
* @var array $subNamespaces
* @var array $subClasses
* @var Zephir\Documentation\NamespaceHelper $namespaceHelper
*/

$items = [
['name' => 'Namespaces' , 'url' => '/namespaces.html'],
$items[] = ['name' => $namespaceHelper->getFullNamespace()]
];
?>

<?= $this->partial("partials/breadcrumb.phtml",array("items"=> $items)) ?>


<?= $this->partial('partials/breadcrumb.phtml', ['items'=> $items]) ?>

<div class="namespace-header">
<div class="namespace-full-name">
Expand All @@ -18,36 +21,36 @@
</div>
</div>


<?php if( count($subNamespaces)>0 ){ ?>

<?php if (count($subNamespaces) > 0 ): ?>
<div class="subnamespaces">
<h2 class="standard-bandeau">Sub Namespaces</h2>

<ul>
<?php foreach ($subNamespaces as $ns){ ?>
<li><a href="<?= $this->url(Zephir\Documentation::namespaceUrl($ns->getFullNamespace())) ?>"><?= $ns->getFullNamespace() ?></a></li>
<?php } ?>

<?php foreach ($subNamespaces as $ns): ?>
<li>
<a href="<?= $this->url(Zephir\Documentation::namespaceUrl($ns->getFullNamespace())) ?>">
<?= $ns->getFullNamespace() ?>
</a>
</li>
<?php endforeach; ?>
</ul>

</div>
<?php } ?>


<?php if( count($subClasses)>0 ){ ?>
<?php endif; ?>

<?php if (count($subClasses) > 0): ?>
<div class="subclasses">
<h2 class="standard-bandeau">Sub Classes</h2>

<ul>
<?php foreach ($subClasses as $sc){ ?>
<li><a href="<?= $this->url($sc) ?>"><?= $sc->getClassDefinition()->getName() ?></a></li>
<?php } ?>

<?php foreach ($subClasses as $sc): ?>
<li>
<a href="<?= $this->url($sc) ?>">
<?= $sc->getClassDefinition()->getName() ?>
</a>
</li>
<?php endforeach; ?>
</ul>

</div>
<?php } ?>


<?php endif; ?>
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
<?php

/* @var $method \Zephir\ClassMethod */
/* @var $method Zephir\ClassMethod */

?>

<li class="class-method clearfix">

<div class="hidden-anchor" id="method-details-<?= $method->getName() ?>"></div>

<div class="method-details">


<h3 class="method-name"><?= $method->getName() ?></h3>

<div class="method-details-details">
<div class="method-signature">

<?= $method->isAbstract() ? "abstract" : "" ?>
<?= $method->isStatic() ? "static" : "" ?>
<?= $method->isFinal() ? "final" : "" ?>
<?= $method->isAbstract() ? 'abstract' : '' ?>
<?= $method->isStatic() ? 'static' : '' ?>
<?= $method->isFinal() ? 'final' : '' ?>
<?= implode(" ",$method->getVisibility()) ?>
function <span class="method-name"><?= $method->getName() ?></span>(<?= $this->partial("partials/class/method-summary-params.phtml" ) ?>)
function <span class="method-name"><?= $method->getName() ?></span>(<?= $this->partial('partials/class/method-summary-params.phtml' ) ?>)

<div>
<?= $method->getDocBlock() ?>
Expand All @@ -29,5 +24,4 @@
</div>

</div>

</li>
</li>
36 changes: 13 additions & 23 deletions templates/Api/themes/zephir/partials/namespace/method-summary.phtml
Original file line number Diff line number Diff line change
@@ -1,42 +1,32 @@
<?php

/* @var $method \Zephir\ClassMethod */

/**
* @var $method Zephir\ClassMethod
*/
?>

<li class="class-method clearfix">

<div class="method-return">

<?php
$allTypes = [];

$allTypes = array();

if($method->getReturnClassTypes()){
if ($method->getReturnClassTypes()) {
$allTypes = array_merge($allTypes,$method->getReturnClassTypes());

}


$types = $method->getReturnTypes();

if($types && count($types)>0 ){

foreach($types as $type){

if($type && isset($type["data-type"]))
$allTypes[] = $type["data-type"];
if ($types && count($types) > 0) {
foreach ($types as $type) {
if ($type && isset($type['data-type'])) {
$allTypes[] = $type['data-type'];
}
}
}

echo implode("|",$allTypes);

echo implode('|', $allTypes);
?>

</div>
<div class="method-summary">
<span class="method-name"><a href="#method-details-<?= $method->getName() ?>"><?= $method->getName() ?></a></span>(<?= $this->partial("partials/class/method-summary-params.phtml" ) ?>)

<span class="method-name"><a href="#method-details-<?= $method->getName() ?>"><?= $method->getName() ?></a></span>(<?= $this->partial('partials/class/method-summary-params.phtml') ?>)
</div>

</li>
</li>
26 changes: 14 additions & 12 deletions templates/Api/themes/zephir/partials/namespaces.phtml
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<?php
$items = array(
array("name" => "Namespaces" ),
);
/**
* @var array $namespaces
*/

$items = [['name' => 'Namespaces']];
?>
<?= $this->partial("partials/breadcrumb.phtml",array("items"=> $items)) ?>

<?= $this->partial('partials/breadcrumb.phtml', ['items'=> $items]) ?>

<div class="namespace-list">

<ul>
<?php foreach($namespaces as $namesapceName => $ns){ ?>

<li> <a href="<?= $this->url(Zephir\Documentation::namespaceUrl($namesapceName)) ?>"><?= $namesapceName ?></a></li>

<?php } ?>
<?php foreach ($namespaces as $namespaceName => $ns): ?>
<li>
<a href="<?= $this->url(Zephir\Documentation::namespaceUrl($namespaceName)) ?>">
<?= $namespaceName ?>
</a>
</li>
<?php endforeach; ?>
</ul>

</div>
</div>
Loading

0 comments on commit 24b5f36

Please sign in to comment.