1
0
mirror of https://github.com/typemill/typemill.git synced 2025-08-06 06:07:31 +02:00

Version 1.3.2: Rename and Hide navigation

This commit is contained in:
trendschau
2020-01-20 18:52:57 +01:00
parent 00368397ce
commit 53f17927fd
26 changed files with 443 additions and 85 deletions

View File

@@ -16,7 +16,7 @@ class Folder
{
$folderItems = scandir($folderPath);
$folderContent = array();
foreach ($folderItems as $key => $item)
{
if (!in_array($item, array(".","..")))
@@ -96,8 +96,8 @@ class Folder
* vars: multidimensional array with folder- and file-names
* returns: array of objects. Each object contains information about an item (file or folder).
*/
public static function getFolderContentDetails(array $folderContent, $baseUrl, $fullSlugWithFolder = NULL, $fullSlugWithoutFolder = NULL, $fullPath = NULL, $keyPath = NULL, $chapter = NULL)
{
public static function getFolderContentDetails(array $folderContent, $extended, $baseUrl, $fullSlugWithFolder = NULL, $fullSlugWithoutFolder = NULL, $fullPath = NULL, $keyPath = NULL, $chapter = NULL)
{
$contentDetails = [];
$iteration = 0;
$chapternr = 1;
@@ -147,8 +147,16 @@ class Folder
$item->chapter = $chapter ? $chapter . '.' . $chapternr : $chapternr;
$item->active = false;
$item->activeParent = false;
$item->hide = false;
$item->folderContent = self::getFolderContentDetails($name, $baseUrl, $item->urlRel, $item->urlRelWoF, $item->path, $item->keyPath, $item->chapter);
# check if there are extended information
if($extended && isset($extended[$item->urlRelWoF]))
{
$item->name = ($extended[$item->urlRelWoF]['navtitle'] != '') ? $extended[$item->urlRelWoF]['navtitle'] : $item->name;
$item->hide = ($extended[$item->urlRelWoF]['hide'] === true) ? true : false;
}
$item->folderContent = self::getFolderContentDetails($name, $extended, $baseUrl, $item->urlRel, $item->urlRelWoF, $item->path, $item->keyPath, $item->chapter);
}
else
{
@@ -196,6 +204,14 @@ class Folder
$item->urlAbs = $baseUrl . $fullSlugWithoutFolder . '/' . $item->slug;
$item->active = false;
$item->activeParent = false;
$item->hide = false;
# check if there are extended information
if($extended && isset($extended[$item->urlRelWoF]))
{
$item->name = ($extended[$item->urlRelWoF]['navtitle'] != '') ? $extended[$item->urlRelWoF]['navtitle'] : $item->name;
$item->hide = ($extended[$item->urlRelWoF]['hide'] === true) ? true : false;
}
}
$iteration++;
@@ -223,9 +239,9 @@ class Folder
foreach($folderContentDetails as $key => $item)
{
# set item active, needed to move item in navigation
if($item->urlRel === $url)
{
# set item active, needed for move item in navigation
$item->active = true;
$result = $item;
}
@@ -234,6 +250,7 @@ class Folder
$result = self::getItemForUrl($item->folderContent, $url, $baseUrl, $result);
}
}
return $result;
}
@@ -378,6 +395,30 @@ class Folder
return array('structure' => $structure, 'item' => $item);
}
# NOT IN USE
public static function deleteItemWithKeyPath($structure, array $keys)
{
$result = &$structure;
$last = array_pop($keys);
foreach ($keys as $key)
{
if(isset($result[$key]->folderContent))
{
$result = &$result[$key]->folderContent;
}
else
{
$result = &$result[$key];
}
}
$item = $result[$last];
unset($result[$last]);
return $structure;
}
/* get breadcrumb as copied array, set elements active in original and mark parent element in original */
public static function getBreadcrumb($content, $searchArray, $i = NULL, $breadcrumb = NULL)

View File

@@ -23,6 +23,5 @@ class Helpers{
}
$table .= '</table></body></html>';
echo $table;
exit;
}
}

View File

@@ -41,7 +41,7 @@ class Write
return true;
}
protected function checkFile($folder, $file)
public function checkFile($folder, $file)
{
if(!file_exists($this->basePath . $folder . DIRECTORY_SEPARATOR . $file))
{
@@ -50,7 +50,7 @@ class Write
return true;
}
protected function checkFileWithPath($filepath)
public function checkFileWithPath($filepath)
{
if(!file_exists($this->basePath . $filepath))
{
@@ -62,7 +62,7 @@ class Write
public function writeFile($folder, $file, $data)
{
if($this->checkPath($folder))
{
{
$filePath = $this->basePath . $folder . DIRECTORY_SEPARATOR . $file;
$openFile = @fopen($filePath, "w");
@@ -70,11 +70,11 @@ class Write
if(!$openFile)
{
return false;
}
}
fwrite($openFile, $data);
fclose($openFile);
return true;
}
return false;
@@ -118,8 +118,10 @@ class Write
$newOrder = ($index < 10) ? '0' . $index : $index;
# create new path with foldername or filename but without file-type
$newPath = $this->basePath . 'content' . $folderPath . DIRECTORY_SEPARATOR . $newOrder . '-' . str_replace(" ", "-", $item->name);
# $newPath = $this->basePath . 'content' . $folderPath . DIRECTORY_SEPARATOR . $newOrder . '-' . str_replace(" ", "-", $item->name);
$newPath = $this->basePath . 'content' . $folderPath . DIRECTORY_SEPARATOR . $newOrder . '-' . $item->slug;
if($item->elementType == 'folder')
{
$oldPath = $this->basePath . 'content' . $item->path;

View File

@@ -10,7 +10,7 @@ class WriteCache extends Write
* @return boolean for an invalid cache (false) and for a valid cache (true).
*/
public function validate($folderName, $fileName, $duration)
{
{
if(isset($_SERVER['HTTP_CACHE_CONTROL']) && $_SERVER['HTTP_CACHE_CONTROL'] == 'max-age=0')
{
return false;
@@ -28,7 +28,7 @@ class WriteCache extends Write
}
$lastRefresh = file_get_contents($folderName . DIRECTORY_SEPARATOR . $fileName);
if(time() - $lastRefresh > $duration)
{
return false;

View File

@@ -48,6 +48,14 @@ class WriteYaml extends Write
return false;
}
# compare with meta that are in use right now (e.g. changed theme, disabled plugin)
$metascheme = $this->getYaml('cache', 'metatabs.yaml');
if($metascheme)
{
$meta = $this->whitelistMeta($meta,$metascheme);
}
$meta = $this->addFileTimeToMeta($meta, $item, $settings);
return $meta;
@@ -117,6 +125,27 @@ class WriteYaml extends Write
return $meta;
}
private function whitelistMeta($meta, $metascheme)
{
# we have only 2 dimensions, so no recursive needed
foreach($meta as $tab => $values)
{
if(!isset($metascheme[$tab]))
{
unset($meta[$tab]);
}
foreach($values as $key => $value)
{
if(!isset($metascheme[$tab][$key]))
{
unset($meta[$tab][$key]);
}
}
}
return $meta;
}
private function addFileTimeToMeta($meta, $item, $settings)
{
$filePath = $settings['contentFolder'] . $item->path;