Code Style and documentation
This commit is contained in:
@ -4,53 +4,90 @@ use Todaymade\Daux\DauxHelper;
|
||||
|
||||
abstract class Entry
|
||||
{
|
||||
/** @var string */
|
||||
protected $title;
|
||||
|
||||
/** @var string */
|
||||
protected $name;
|
||||
|
||||
/** @var Content */
|
||||
protected $index_page;
|
||||
|
||||
/** @var Content */
|
||||
protected $first_page;
|
||||
|
||||
/** @var string */
|
||||
protected $uri;
|
||||
|
||||
/** @var string */
|
||||
protected $local_path;
|
||||
|
||||
/** @var integer */
|
||||
protected $last_modified;
|
||||
|
||||
/** @var array */
|
||||
protected $parents;
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param array $parents
|
||||
*/
|
||||
public function __construct($path = '', $parents = array())
|
||||
{
|
||||
$this->setPath($path);
|
||||
$this->setParents($parents);
|
||||
$this->setPath($path);
|
||||
$this->setParents($parents);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUri()
|
||||
{
|
||||
return $this->uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $uri
|
||||
*/
|
||||
public function setUri($uri)
|
||||
{
|
||||
$this->uri = $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Content
|
||||
*/
|
||||
public function getIndexPage()
|
||||
{
|
||||
return $this->index_page;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Content $index_page
|
||||
*/
|
||||
public function setIndexPage($index_page)
|
||||
{
|
||||
$this->index_page = $index_page;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Entry
|
||||
* @return Content
|
||||
*/
|
||||
public function getFirstPage()
|
||||
{
|
||||
@ -65,7 +102,7 @@ abstract class Entry
|
||||
//the homepage should not count as first page
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$this->first_page = $node;
|
||||
return $node;
|
||||
}
|
||||
@ -80,38 +117,59 @@ abstract class Entry
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Content $first_page
|
||||
*/
|
||||
public function setFirstPage($first_page)
|
||||
{
|
||||
$this->first_page = $first_page;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $title
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getParents()
|
||||
{
|
||||
return $this->parents;
|
||||
}
|
||||
|
||||
public function setParents($parents)
|
||||
{
|
||||
$this->parents = $parents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $parents
|
||||
*/
|
||||
public function setParents($parents)
|
||||
{
|
||||
$this->parents = $parents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->local_path;
|
||||
}
|
||||
|
||||
public function setPath($path)
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*/
|
||||
public function setPath($path)
|
||||
{
|
||||
if (!isset($path) || $path == '' || !file_exists($path)) {
|
||||
return;
|
||||
}
|
||||
@ -121,8 +179,12 @@ abstract class Entry
|
||||
$this->title = $this->getTitleInternal($this->name);
|
||||
$this->uri = $this->getUrlInternal($this->getFilename($path));
|
||||
$this->index_page = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $content
|
||||
* @return bool
|
||||
*/
|
||||
public function write($content)
|
||||
{
|
||||
if (!is_writable($this->local_path)) {
|
||||
@ -132,7 +194,10 @@ abstract class Entry
|
||||
file_put_contents($this->local_path, $content);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
$url = '';
|
||||
@ -143,12 +208,20 @@ abstract class Entry
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string
|
||||
*/
|
||||
protected function getFilename($file)
|
||||
{
|
||||
$parts = explode('/', $file);
|
||||
return end($parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
* @return string
|
||||
*/
|
||||
protected function getTitleInternal($filename)
|
||||
{
|
||||
$filename = explode('_', $filename);
|
||||
@ -164,6 +237,10 @@ abstract class Entry
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
* @return string
|
||||
*/
|
||||
protected function getUrlInternal($filename)
|
||||
{
|
||||
$filename = explode('_', $filename);
|
||||
|
Reference in New Issue
Block a user