Skip to content

Commit 1a81b9b

Browse files
committed
Patch-B
1 parent 4f08b57 commit 1a81b9b

35 files changed

+983
-17
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ project(':develnext') {
134134
compile project(':jphp-gui-desktop-ext')
135135
compile project(':jphp-game-ext')
136136
compile project(':jphp-parser')
137+
compile project(':develnext-doc')
137138
compile project(':develnext-stdlib')
138139

139140
compile "org.develnext:jphp-xml-ext:$jphpVersion"

develnext-doc/build.gradle

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
repositories {
3+
mavenLocal()
4+
jcenter()
5+
mavenCentral()
6+
}
7+
8+
sourceSets {
9+
main.resources.srcDirs = ['src']
10+
}
11+
12+
dependencies {
13+
14+
}
15+

develnext-doc/src/.dn/extensions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ide\doc\DocExtension

develnext-doc/src/.dn/formats

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ide\doc\formats\DocFormat

develnext-doc/src/.dn/mainCommands

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ide\doc\commands\DocCommand
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
namespace ide\doc;
3+
4+
use ide\AbstractExtension;
5+
6+
class DocExtension extends AbstractExtension
7+
{
8+
public function onRegister()
9+
{
10+
11+
}
12+
13+
public function onIdeStart()
14+
{
15+
16+
}
17+
18+
public function onIdeShutdown()
19+
{
20+
21+
}
22+
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?php
2+
namespace ide\doc\account\api;
3+
4+
use ide\account\api\AbstractService;
5+
use ide\account\api\ServiceException;
6+
use ide\account\api\ServiceInvalidResponseException;
7+
use ide\account\api\ServiceNotAvailableException;
8+
use ide\account\api\ServiceResponse;
9+
use ide\account\api\ServiceResponseFuture;
10+
use ide\utils\Tree;
11+
12+
/**
13+
* Class DocService
14+
* @package ide\doc\account\api
15+
*
16+
* @method ServiceResponseFuture categoryTreeAsync(callable $callback = null)
17+
* @method ServiceResponseFuture categoryAsync($id, callable $callback = null)
18+
* @method ServiceResponseFuture categoriesAsync($parentCategoryId, callable $callback = null)
19+
* @method ServiceResponseFuture allCategoriesAsync(callable $callback = null)
20+
* @method ServiceResponseFuture entryAsync($id, callable $callback = null)
21+
* @method ServiceResponseFuture entriesAsync($categoryId, $offset, $limit, callable $callback = null)
22+
* @method ServiceResponseFuture allEntriesAsync($sort, $offset, $limit, callable $callback = null)
23+
* @method ServiceResponseFuture saveEntryAsync($data, callable $callback = null)
24+
* @method ServiceResponseFuture saveCategoryAsync($data, callable $callback = null)
25+
* @method ServiceResponseFuture deletedEntryAsync($id, callable $callback = null)
26+
* @method ServiceResponseFuture restoreEntryAsync($id, callable $callback = null)
27+
* @method ServiceResponseFuture deleteCategoryAsync($id, callable $callback = null)
28+
* @method ServiceResponseFuture restoreCategoryAsync($id, callable $callback = null)
29+
*/
30+
class DocService extends AbstractService
31+
{
32+
/**
33+
* Return full tree of categories.
34+
*/
35+
public function categoryTree()
36+
{
37+
$response = $this->allCategories();
38+
39+
if ($response->isSuccess()) {
40+
$data = $response->data();
41+
42+
return new ServiceResponse([
43+
'status' => $response->status(),
44+
'message' => $response->message(),
45+
'data' => new Tree($data, 'id', 'parentId')
46+
]);
47+
} else {
48+
return $response;
49+
}
50+
}
51+
52+
public function category($id)
53+
{
54+
return $this->execute('doc/category', ['id' => $id]);
55+
}
56+
57+
public function categories($parentCategoryId = null)
58+
{
59+
return $this->execute('doc/categories', ['parentId' => $parentCategoryId]);
60+
}
61+
62+
public function allCategories()
63+
{
64+
return $this->execute('doc/all-categories', []);
65+
}
66+
67+
public function entry($id)
68+
{
69+
return $this->execute('doc/entry', ['id' => $id]);
70+
}
71+
72+
public function entries($categoryId, $offset = 0, $limit = 40)
73+
{
74+
return $this->execute('doc/entries', ['categoryId' => $categoryId, 'offset' => $offset, 'limit' => $limit]);
75+
}
76+
77+
public function allEntries($sort = 'UPDATED_AT', $offset = 0, $limit = 40)
78+
{
79+
return $this->execute('doc/entries', ['categoryId' => $sort, 'offset' => $offset, 'limit' => $limit]);
80+
}
81+
82+
public function saveEntry($data)
83+
{
84+
return $this->execute('doc/save-entry', $data);
85+
}
86+
87+
public function saveCategory($data)
88+
{
89+
return $this->execute('doc/save-category', $data);
90+
}
91+
92+
public function deleteEntry($id)
93+
{
94+
return $this->saveEntry(['id' => $id, 'deleted' => true]);
95+
}
96+
97+
public function restoreEntry($id)
98+
{
99+
return $this->saveEntry(['id' => $id, 'deleted' => false]);
100+
}
101+
102+
public function deleteCategory($id)
103+
{
104+
return $this->saveCategory(['id' => $id, 'deleted' => true]);
105+
}
106+
107+
public function restoreCategory($id)
108+
{
109+
return $this->saveCategory(['id' => $id, 'deleted' => false]);
110+
}
111+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
namespace ide\doc\commands;
3+
4+
use ide\editors\AbstractEditor;
5+
use ide\misc\AbstractCommand;
6+
use ide\systems\FileSystem;
7+
use php\gui\UXSeparator;
8+
9+
class DocCommand extends AbstractCommand
10+
{
11+
public function isAlways()
12+
{
13+
return true;
14+
}
15+
16+
public function getName()
17+
{
18+
return 'Документация';
19+
}
20+
21+
public function getCategory()
22+
{
23+
return 'help';
24+
}
25+
26+
public function getIcon()
27+
{
28+
return 'icons/help16.png';
29+
}
30+
31+
/*public function makeUiForHead()
32+
{
33+
$button = parent::makeGlyphButton();
34+
$button->text = 'Документация';
35+
36+
return [$button, new UXSeparator('VERTICAL')];
37+
} */
38+
39+
public function onExecute($e = null, AbstractEditor $editor = null)
40+
{
41+
FileSystem::open('~doc');
42+
}
43+
}

0 commit comments

Comments
 (0)