Skip to content

Commit

Permalink
Version 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mzeis committed Oct 4, 2015
2 parents 218bf19 + ff7a64a commit 575d543
Show file tree
Hide file tree
Showing 44 changed files with 1,450 additions and 193 deletions.
7 changes: 0 additions & 7 deletions CHANGELOG.md

This file was deleted.

107 changes: 5 additions & 102 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,115 +1,18 @@
Mzeis_Documentation
=====================
Create a documentation for your project in the backend.

Build Status
---
**Latest Release**

[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mzeis/Mzeis_Documentation/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mzeis/Mzeis_Documentation/?branch=master)

**Development Branch**

[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mzeis/Mzeis_Documentation/badges/quality-score.png?b=dev)](https://scrutinizer-ci.com/g/mzeis/Mzeis_Documentation/?branch=dev)


Facts
-----
- Composer key: `mzeis/mzeis_documentation`
- Version: 1.0.0
- [Extension on GitHub](https://github.com/mzeis/Mzeis_Documentation)

Compatibility
-------------
- Magento >= CE 1.9.1 (may also work in other versions)

Installation
------------
Install the extension using [Composer](https://getcomposer.org/) or
[modman](https://github.com/colinmollenhour/modman). The extension is listed on
[packages.firegento.com](http://packages.firegento.com).

Uninstallation
--------------
1. Remove the files.
2. Remove the following database tables:
* `mzeis_documentation_page`
3. Remove all entries in database table `core_config_data` starting with the path `admin/mzeis_documentation/`.

Usage
-----
Navigate to `System > Documentation`. Start editing the homepage of the documentation by clicking the `Edit` button.

###Permissions
You can define permissions for viewing, editing and deleting pages per admin user role (menu item
`System > Permissions > Users`, resource `System > Documentation`).

###Configuration
The configuration for this extension can be found in `System > Configuration > Advanced > Admin`. Alternatively you also
can click on the link `Configuration` in the documentation menu.

####Set another page as the documentation homepage
By default, the documentation homepage is "Home". If you want to set another page as the homepage, enter the name in
`System > Configuration > Advanced > Admin > Documentation > Homepage`.

###Editing a page
Go to `System > Documentation`, view any documentation page and click the `Edit` button
in the right top corner of the screen.

In the edit form, you can add content using the WYSIWYG editor.

You can insert images, variables and widgets. Note that widgets won't always display successfully
since you are viewing the page in the backend and not in the frontend which most widgets are made
for.

###Renaming a page
When viewing a page, click the `Rename` button in the top right corner. Choose a unique page name.
The links to the page will be renamed accordingly.

###Creating a new page
You create a new page by editing an existing page and adding a documentation link in this format:

[[My new page]]

After saving, you will see a link to the page `My new page`. When you click on it you will be told
that there is no content for this page yet. Edit the new page to fill it with content.

###Searching
You can search through the documentation by using the search form in the left top corner. The
search searches for your term in the name and content of the documentation pages. The search
results are returned in an alphabetical manner.
Manage your project and module documentation in the backend.

###Showing all pages
Click on the documentation menu link `All pages` to get an overview over all pages.

###Orphan pages
It might happen that an existing pages isn't linked to anymore by any other pages when these
pages are changed. The documentation menu link `Orphan pages` will show you all pages without
links pointing at them.

Changelog
---------
[CHANGELOG.md](CHANGELOG.md)

Support
-------
If you have any issues with this extension, please create an issue on GitHub.
Please provide error messages, debug information like output from the Magento
error logs and the exact steps / code to reproduce the issue.

Contribution
------------
Any contribution is highly appreciated. The best way to contribute code is to
open a [pull request on GitHub](https://help.github.com/articles/using-pull-requests).
Always create pull requests against the `dev` branch.
Find all information in the [documentation](src/app/code/community/Mzeis/Documentation/docs/README.md).

Author
------
Matthias Zeis ([matthias-zeis.com](http://www.matthias-zeis.com), [@mzeis](https://twitter.com/mzeis))

A big thank you to all [contributors](https://github.com/mzeis/Mzeis_Documentation/graphs/contributors)!

License
-------
[MIT License](LICENSE.md)
[MIT License](src/app/code/community/Mzeis/Documentation/docs/LICENSE.md)

Copyright
---------
Expand Down
23 changes: 13 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"name": "mzeis/mzeis_documentation",
"type": "magento-module",
"license": "MIT",
"description": "Create a documentation for your project in the backend.",
"authors": [
{
"name": "Matthias Zeis",
"homepage": "http://matthias-zeis.com"
}
]
"name": "mzeis/mzeis_documentation",
"type": "magento-module",
"require": {
"erusev/parsedown": "1.6.0"
},
"license": "MIT",
"description": "Create a documentation for your project in the backend.",
"authors": [
{
"name": "Matthias Zeis",
"homepage": "http://matthias-zeis.com"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public function __construct()
*/
protected function _prepareForm()
{
/**
* @var Mzeis_Documentation_Model_Page $model
*/
$model = Mage::registry('current_page');

$form = new Varien_Data_Form(array(
Expand All @@ -39,12 +42,25 @@ protected function _prepareForm()
'name' => 'name'
));

$fieldset->addField('content', 'editor', array(
$fieldset->addField('format', 'select', array(
'label' => $this->__('Format'),
'title' => $this->__('Format'),
'note' => $this->__('<strong>Caution</strong>: you may lose formatting when changing the format!'),
'name' => 'format',
'required' => true,
'options' => array(
Mzeis_Documentation_Model_Page::FORMAT_MAGE_CMS => $this->__('HTML'),
Mzeis_Documentation_Model_Page::FORMAT_MARKDOWN => $this->__('Markdown'),
),
));

$contentFieldType = $model->isFormatMarkdown() ? 'textarea' : 'editor';
$fieldset->addField('content', $contentFieldType, array(
'name' => 'content',
'label' => $this->__('Content'),
'title' => $this->__('Content'),
'style' => 'height:36em',
'required' => true,
'required' => false,
'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig()
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function __construct()
protected function _prepareForm()
{
$model = Mage::registry('current_page');
$model->setNewName($model->getName());

$form = new Varien_Data_Form(array(
'id' => 'rename_form',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

class Mzeis_Documentation_Block_Adminhtml_Page_Sidebar extends Mage_Adminhtml_Block_Template
{
/**
* @var Mzeis_Documentation_Model_Resource_Module_Collection
*/
protected $_moduleCollection = null;

/**
* Returns the URL of the "All pages" page.
*
Expand All @@ -27,7 +32,17 @@ public function getConfigurationUrl() {
*/
public function getHomepageUrl()
{
return Mage::helper('mzeis_documentation/page')->getViewUrl(Mage::helper('mzeis_documentation')->getHomepageName());
$homepage = Mage::getModel('mzeis_documentation/page');
$homepage->setName(Mage::helper('mzeis_documentation')->getHomepageName());
return Mage::helper('mzeis_documentation/page')->getViewUrl($homepage);
}

public function getModuleCollection()
{
if (is_null($this->_moduleCollection)) {
$this->_moduleCollection = Mage::getResourceModel('mzeis_documentation/module_collection');
}
return $this->_moduleCollection;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ class Mzeis_Documentation_Block_Adminhtml_Page_View extends Mage_Adminhtml_Block
protected function _beforeToHtml()
{
if ($this->isAllowedEdit()) {
$this->setChild('rename_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData(array(
'label' => Mage::helper('catalog')->__('Rename'),
'onclick' => 'window.location.href=\'' . Mage::helper('mzeis_documentation/page')->getRenameUrl($this->getPage()->getName()) . '\'',
'class' => 'edit'
))
);
if ($this->getPage()->getId()) {
$this->setChild('rename_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData(array(
'label' => Mage::helper('catalog')->__('Rename'),
'onclick' => 'window.location.href=\'' . Mage::helper('mzeis_documentation/page')->getRenameUrl($this->getPage()->getName()) . '\'',
'class' => 'edit'
))
);
}
$this->setChild('edit_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData(array(
Expand All @@ -28,11 +30,15 @@ protected function _beforeToHtml()
}

/**
* Returns whether the page can be edited.
*
* The page has to be a project documentation page and the user needs to have the privileges.
*
* @return bool
*/
public function isAllowedEdit()
{
return Mage::getSingleton('admin/session')->isAllowed('system/mzeis_documentation/edit');
return $this->getPage()->isProjectPage() && is_null($this->getPage()->getModule()) && Mage::getSingleton('admin/session')->isAllowed('system/mzeis_documentation/edit');
}

/**
Expand Down
13 changes: 13 additions & 0 deletions src/app/code/community/Mzeis/Documentation/Helper/Module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

class Mzeis_Documentation_Helper_Module extends Mage_Core_Helper_Abstract
{
/**
* @param string $name Module name
* @return bool True if it is an active, existing module
*/
public function isActiveModule($name)
{
return !is_null(Mage::getResourceSingleton('mzeis_documentation/module_collection')->getItemByColumnValue('name', $name));
}
}
22 changes: 19 additions & 3 deletions src/app/code/community/Mzeis/Documentation/Helper/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ public function getEditUrl($page)
return Mage::helper("adminhtml")->getUrl('adminhtml/mzeis_documentation/edit', array('_query' => array('page' => $page)));
}

/**
* Returns the link text for a page.
*
* @param Mzeis_Documentation_Model_Page $page
* @return string
*/
public function getLinkText(Mzeis_Documentation_Model_Page $page)
{
return ($page->getModule() ? $page->getModule() . ' > ' : '') . $page->getName();
}

/**
* Creates an rename URL for the backend.
*
Expand All @@ -27,11 +38,16 @@ public function getRenameUrl($page)
/**
* Creates a view URL for the backend.
*
* @param string $page
* @param Mzeis_Documentation_Model_Page $page
* @return string
*/
public function getViewUrl($page)
public function getViewUrl(Mzeis_Documentation_Model_Page $page)
{
return Mage::helper("adminhtml")->getUrl('adminhtml/mzeis_documentation/view', array('_query' => array('page' => $page)));
$params['page'] = $page->getName();
if ($page->hasModule()) {
$params['module'] = $page->getModule();
}

return Mage::helper("adminhtml")->getUrl('adminhtml/mzeis_documentation/view', array('_query' => $params));
}
}
14 changes: 14 additions & 0 deletions src/app/code/community/Mzeis/Documentation/Helper/Page/File.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

class Mzeis_Documentation_Helper_Page_File extends Mage_Core_Helper_Abstract
{
/**
* Returns the allowed extensions for page files.
*
* @return array
*/
public function getAllowedExtensions()
{
return array('md', 'markdown');
}
}
49 changes: 49 additions & 0 deletions src/app/code/community/Mzeis/Documentation/Model/Module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/**
* @method string getName()
* @method setName(string $value)
*/
class Mzeis_Documentation_Model_Module extends Varien_Object
{
/**
* @var Mzeis_Documentation_Model_Resource_Module_Page_Collection
*/
protected $_pageCollection = null;

/**
* Returns the URL to the overview page of the module.
*
* @return string
*/
public function getOverviewUrl()
{
return Mage::helper("adminhtml")->getUrl('adminhtml/mzeis_documentation_module/view', array('module' => $this->getName()));
}

/**
* @return Mzeis_Documentation_Model_Resource_Module_File_Collection
*/
public function getPageCollection()
{
if (is_null($this->_pageCollection)) {
$this->_pageCollection = Mage::getResourceModel('mzeis_documentation/page_collection');
$this->_pageCollection->addModuleFilter($this->getName());
}

return $this->_pageCollection;
}

/**
* Returns the URL to a specific page of the module.
*
* @param string $page
* @return string
*/
public function getPageUrl($page)
{
return Mage::helper('adminhtml')->getUrl('adminhtml/mzeis_documentation/view', array('_query' => array('page' => $page, 'module' => $this->getName())));
}


}
Loading

0 comments on commit 575d543

Please sign in to comment.