Erste lauffähige Umgebung
This commit is contained in:
@@ -12,6 +12,7 @@ namespace Model;
|
||||
|
||||
|
||||
use Helper\Database;
|
||||
use Helper\Registry;
|
||||
|
||||
class NavigationModel extends Database
|
||||
{
|
||||
@@ -39,6 +40,8 @@ class NavigationModel extends Database
|
||||
|
||||
/**
|
||||
* Setzt später benötigte Variablen für den FrontendController, so dass die Datenmodelle und die Views instanziiert werden können
|
||||
* @author Christian Steinle
|
||||
*
|
||||
* @param array $routeParts
|
||||
* @param bool $isEditable
|
||||
*/
|
||||
@@ -56,6 +59,13 @@ class NavigationModel extends Database
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialisierung für das Backend ohne ModRewrite
|
||||
* @author Christian Steinle
|
||||
*
|
||||
* @param int $siteID
|
||||
* @param int $depth
|
||||
*/
|
||||
protected static function initBackend($siteID, $depth)
|
||||
{
|
||||
foreach (self::$data as $navID => $navItem)
|
||||
@@ -74,6 +84,9 @@ class NavigationModel extends Database
|
||||
}
|
||||
|
||||
/**
|
||||
* Umbau der Datenbank-Tabellenwerte in ein Mehrdimensionales Array
|
||||
* @author Christian Steinle
|
||||
*
|
||||
* @param string $navKeyVisual
|
||||
*/
|
||||
protected static function initKeyVisual($navKeyVisual)
|
||||
@@ -89,6 +102,9 @@ class NavigationModel extends Database
|
||||
}
|
||||
|
||||
/**
|
||||
* Umbau der Datenbank-Tabellenwerte in ein Mehrdimensionales Array
|
||||
* @author Christian Steinle
|
||||
*
|
||||
* @param string $navContents
|
||||
*/
|
||||
protected static function initContent($navContents)
|
||||
@@ -103,6 +119,11 @@ class NavigationModel extends Database
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Baut den Navigationspfad als Array
|
||||
* @author Christian Steinle
|
||||
*/
|
||||
protected static function buildNavigationPath()
|
||||
{
|
||||
$navStart = $navStartPath[] = self::$activeNavID;
|
||||
@@ -110,13 +131,22 @@ class NavigationModel extends Database
|
||||
{
|
||||
$navStart = $navStartPath[] = self::$data[$navStart]['navStart'];
|
||||
}
|
||||
$navStartPath[] = '0';
|
||||
array_pop($navStartPath);
|
||||
self::$navigationPath = array_reverse($navStartPath);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialisiert das Frontend unter Verwendung des ModRewrites
|
||||
* @author Christian Steinle
|
||||
*
|
||||
* @param array $routeParts
|
||||
*/
|
||||
protected static function initFrontend(array $routeParts)
|
||||
{
|
||||
$navStart = 0;
|
||||
self::$navigationPath[] = 0;
|
||||
foreach ($routeParts as $navLink)
|
||||
{
|
||||
foreach (self::$data as $navID => $navItem)
|
||||
@@ -134,7 +164,10 @@ class NavigationModel extends Database
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Liefert den Navigationspfad als Array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getNavigationPath()
|
||||
@@ -144,6 +177,8 @@ class NavigationModel extends Database
|
||||
|
||||
|
||||
/**
|
||||
* Liefert die NavigationsID des aktuellen gewählten Menüpunkts
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getActiveNavID()
|
||||
@@ -153,6 +188,7 @@ class NavigationModel extends Database
|
||||
|
||||
|
||||
/**
|
||||
* Liefert den Seiten-Titel
|
||||
* @return string
|
||||
*/
|
||||
public static function getTitle()
|
||||
@@ -162,6 +198,7 @@ class NavigationModel extends Database
|
||||
|
||||
|
||||
/**
|
||||
* Liefert das Array für das KeyVisual
|
||||
* @return array
|
||||
*/
|
||||
public static function getKeyVisual()
|
||||
@@ -171,6 +208,7 @@ class NavigationModel extends Database
|
||||
|
||||
|
||||
/**
|
||||
* Liefert die Überschrift der Seite
|
||||
* @return string
|
||||
*/
|
||||
public static function getHeadline()
|
||||
@@ -180,6 +218,7 @@ class NavigationModel extends Database
|
||||
|
||||
|
||||
/**
|
||||
* Liefert die Seiteninhalte
|
||||
* @return array
|
||||
*/
|
||||
public static function getContents()
|
||||
@@ -189,10 +228,145 @@ class NavigationModel extends Database
|
||||
|
||||
|
||||
/**
|
||||
* Liefert die Navigationsdaten als flaches Array
|
||||
* @return array
|
||||
*/
|
||||
public static function getData()
|
||||
{
|
||||
return self::$data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Liefert die Navigationsdaten, sortiert nach ihrem Elternknoten
|
||||
* @return array
|
||||
*/
|
||||
public static function getStructuredIndex()
|
||||
{
|
||||
$tmpData = self::getIndex();
|
||||
$structuredData = array();
|
||||
foreach ($tmpData as $navID => $navData)
|
||||
{
|
||||
$structuredData['navStart_' . $navData['navStart']]['navID_' . $navID] = $navData;
|
||||
}
|
||||
return $structuredData;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Liefert einen Link, der innerhalb des NavStarts unique ist
|
||||
* @author Christian Steinle
|
||||
*
|
||||
* @param int $navStart
|
||||
* @param string $navName
|
||||
* @return string
|
||||
*/
|
||||
public static function getUniqueNavLink($navStart, $navName)
|
||||
{
|
||||
$commonReplacements = array('ä' => 'ae', 'ö' => 'oe', 'ü' => 'ue', 'ß' => 'ss', ' ' => '_', '"', '', '\'' => '');
|
||||
$registry = Registry::getInstance();
|
||||
$replacements = $registry->editorConfig['linkReplacements'];
|
||||
$navLink = trim(str_replace($replacements, '', $navName));
|
||||
$navLink = mb_convert_case($navLink, MB_CASE_LOWER);
|
||||
$navLink = str_replace(array_keys($commonReplacements), array_values($commonReplacements), $navLink);
|
||||
|
||||
self::$filter = 'navStart = ' . $navStart;
|
||||
$existingNavLinks = 0;
|
||||
$tmpData = self::getIndex();
|
||||
|
||||
foreach ($tmpData as $navPoint)
|
||||
{
|
||||
if ($navPoint['navLink'] == $navLink)
|
||||
{
|
||||
++$existingNavLinks;
|
||||
}
|
||||
}
|
||||
|
||||
if ($existingNavLinks === 0)
|
||||
{
|
||||
return $navLink;
|
||||
}
|
||||
return $navLink . '_' . $existingNavLinks;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sortiert die Navigationspunkte eines übergebenen Elternelements
|
||||
* @author Christian Steinle
|
||||
*
|
||||
* @param array $navPointData
|
||||
* @return int
|
||||
*/
|
||||
public static function updateSortAfterInsert(array $navPointData)
|
||||
{
|
||||
if (!isset($navPointData['navStart']) || $navPointData['navStart'] === '')
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
self::$filter = 'navStart = ' . $navPointData['navStart'];
|
||||
$sortOrder = $navPointData['navSort'];
|
||||
$tmpData = self::getIndex();
|
||||
unset($tmpData[$navPointData['navID']]);
|
||||
if ($sortOrder != 0)
|
||||
{
|
||||
array_splice($tmpData, 0, $sortOrder);
|
||||
}
|
||||
|
||||
foreach($tmpData as $navData)
|
||||
{
|
||||
++$sortOrder;
|
||||
self::update(array('navID' => $navData['navID'], 'navSort' => $sortOrder));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sortiert die Navigationspunkte eines Elternelements um
|
||||
* @author Christian Steinle
|
||||
*
|
||||
* @param $sortData
|
||||
* @return int
|
||||
*/
|
||||
public static function updateSort($sortData)
|
||||
{
|
||||
foreach($sortData as $navSort => $navID)
|
||||
{
|
||||
self::update(array('navID' => $navID, 'navSort' => $navSort));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Legt die Bilddaten des Keyvisuals an, und liefert den passenden JSON-String für den Eintrag in die Datenbank-Tabelle
|
||||
* @author Christian Steinle
|
||||
*
|
||||
* @param array $request
|
||||
*/
|
||||
protected static function beforeInsert(&$request)
|
||||
{
|
||||
$registry = Registry::getInstance();
|
||||
$imageData = $registry->editorConfig['imageDimension']['keyVisual'];
|
||||
$standardImagePath = substr(str_replace(PATH_PREFIX, '', PATH_ROOT), 0, -1) . $imageData['standardImage'];
|
||||
|
||||
$filename = end(explode('/', $standardImagePath));
|
||||
$fileArray = ImageModel::filenameToArray($filename);
|
||||
$imageData = array();
|
||||
$imageData['imageOrigName'] = $fileArray['filename'];
|
||||
$imageData['imageExtension'] = $fileArray['extension'];
|
||||
$imageData['imageName'] = $fileArray['filename'];
|
||||
$imageData['imageTitle'] = $fileArray['filename'];
|
||||
list($width, $height) = getimagesize($standardImagePath);
|
||||
$imageData['imageTop'] = 0;
|
||||
$imageData['imageLeft'] = 0;
|
||||
$imageData['imageHeight'] = $height;
|
||||
$imageData['imageWidth'] = $width;
|
||||
|
||||
$imageID = ImageModel::insert($imageData);
|
||||
$request['navKeyVisual'] = json_encode(array('Controller' => 'KeyVisual', 'Type' => 'Single', 'IDs' => array($imageID)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user