Библиотека для cis, online, cms1
This commit is contained in:
commit
3c2e614d87
269 changed files with 39854 additions and 0 deletions
78
core/mapper/pathmapper.php
Normal file
78
core/mapper/pathmapper.php
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Îòîáðàæåíèå ñïèñêà ïàïîê ñ íàñòðîéêàìè íà îáüåêò
|
||||
*/
|
||||
class PathMapper
|
||||
{
|
||||
private $count;
|
||||
private $base = null;
|
||||
public $reference = null;
|
||||
|
||||
function plane (&$target, Collection $array)
|
||||
{
|
||||
$vars = get_class_vars(get_class($target));
|
||||
foreach ($vars as $name => $value) {
|
||||
$target->$name = $array->get($name);
|
||||
}
|
||||
}
|
||||
|
||||
function basePath ()
|
||||
{
|
||||
if ( ! $this->base) $this->base = $this->getBasePath();
|
||||
return $this->base;
|
||||
}
|
||||
|
||||
function findAll (Collection $request, $id = null)
|
||||
{
|
||||
require_once "core/settings.php";
|
||||
require_once "core/path.php";
|
||||
|
||||
$this->reference = $id;
|
||||
|
||||
$base = $this->basePath ();
|
||||
$path = new Path($base);
|
||||
$list = $path->getContent();
|
||||
|
||||
$result = array ();
|
||||
$this->count = 0;
|
||||
foreach ($list as $name) {
|
||||
if (is_dir (Path::join($this->basePath (), $name))
|
||||
&& $module = $this->findById ($name)) {
|
||||
$this->count++;
|
||||
$result [] = $module;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function findById ($name)
|
||||
{
|
||||
$file = Path::join($this->basePath(), $this->getSettingsFile ($name));
|
||||
if (file_exists($file)) {
|
||||
$settings = new Settings($file);
|
||||
$settings->read();
|
||||
return $this->settingsMap($name, $settings);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* ×èñëî ïàïîê
|
||||
*/
|
||||
function getCount ()
|
||||
{
|
||||
return $this->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Óäàëåíèå ñïèñêà ïàïîê
|
||||
*/
|
||||
function deleteList(array $list)
|
||||
{
|
||||
foreach ($list as $name)
|
||||
Path::delete(Path::join($this->getBasePath(), $name));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue