-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad1bf76
commit bba60e3
Showing
8 changed files
with
137 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: smillernl | ||
* Date: 2-9-16 | ||
* Time: 15:21 | ||
*/ | ||
|
||
namespace PHPDraft\Model\Elements; | ||
|
||
|
||
use PHPDraft\Model\DataStructureElement; | ||
|
||
class ArrayStructureElement extends DataStructureElement | ||
{ | ||
|
||
public function parse($item, &$dependencies) | ||
{ | ||
$this->element = (isset($item->element)) ? $item->element : 'array'; | ||
$this->element = (isset($item->element)) ? $item->element : NULL; | ||
$this->value = (isset($item->content)) ? $item->content : NULL; | ||
|
||
if (isset($item->content)) | ||
{ | ||
foreach ($item->content as $key => $sub_item) | ||
{ | ||
$this->type[$key] = $sub_item->element; | ||
switch ($sub_item->element) | ||
{ | ||
case 'array': | ||
$value = new ArrayStructureElement(); | ||
$this->value[$key] = $value->parse($sub_item, $dependencies); | ||
break; | ||
case 'object': | ||
$value = new DataStructureElement(); | ||
$this->value[$key] = $value->parse($sub_item, $dependencies); | ||
break; | ||
default: | ||
$this->value[$key] = (isset($sub_item->content)) ? $sub_item->content : NULL; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
function __toString() | ||
{ | ||
if (!is_array($this->type)) | ||
{ | ||
return ''; | ||
} | ||
$return = '<ul class="list-group">'; | ||
foreach ($this->type as $key => $item) | ||
{ | ||
$type = | ||
(in_array($item, self::DEFAULTS)) ? $item : '<a href="#object-' . $item . '">' . $item . '</a>'; | ||
|
||
$value = | ||
(isset($this->value[$key])) ? ': <span class="example-value pull-right">' . json_encode($this->value[$key]) . '</span>' : NULL; | ||
|
||
$return .= '<li class="list-group-item">' . $type . $value . '</li>'; | ||
} | ||
$return .= '</ul>'; | ||
|
||
return $return; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.