Added proper Description Implementation and Layout for programs
This commit is contained in:
@@ -20,4 +20,20 @@ class MsHelper {
|
||||
|
||||
return $val;
|
||||
}
|
||||
|
||||
public static function startsWith($haystack, $needle)
|
||||
{
|
||||
$length = strlen($needle);
|
||||
return (substr($haystack, 0, $length) === $needle);
|
||||
}
|
||||
|
||||
public static function endsWith($haystack, $needle)
|
||||
{
|
||||
$length = strlen($needle);
|
||||
if ($length == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (substr($haystack, -$length) === $needle);
|
||||
}
|
||||
}
|
||||
@@ -99,4 +99,74 @@ class ProgramHelper {
|
||||
return $progDropDown;
|
||||
}
|
||||
|
||||
public static function convertDescriptionListToTabs($descriptions, $name) {
|
||||
$tabs = array();
|
||||
|
||||
foreach($descriptions as $desc)
|
||||
{
|
||||
if ($desc['type'] === 0)
|
||||
{
|
||||
$tabs[] =
|
||||
[
|
||||
'label' => $desc['name'],
|
||||
'items' => self::convertDescriptionListToTabs($desc['items'], $name),
|
||||
];
|
||||
}
|
||||
else if (strcasecmp($desc['name'], 'index') == 0) // == 0 : true
|
||||
{
|
||||
$tabs[] =
|
||||
[
|
||||
'label' => $name,
|
||||
'content' => self::getDescriptionMarkdownTab($desc['path']),
|
||||
'active' => true,
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
$tabs[] =
|
||||
[
|
||||
'label' => $desc['name'],
|
||||
'content' => self::getDescriptionMarkdownTab($desc['path']),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
public static function getDescriptionMarkdownTab($path)
|
||||
{
|
||||
$md = new CMarkdown;
|
||||
|
||||
$content = file_get_contents($path);
|
||||
|
||||
$result = '<div class="markdownOwner"><div><p>';
|
||||
$result .= $md->transform($content);
|
||||
$result .= '</p></div></div>';
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $filename
|
||||
* @param $number
|
||||
* @return string
|
||||
*/
|
||||
public static function getIndexedFilename($filename, &$number)
|
||||
{
|
||||
$bn = basename($filename, '.markdown');
|
||||
|
||||
if ($bn[0] >= '0' && $bn[0] <= '9' && $bn[1] >= '0' && $bn[1] <= '9' && $bn[2] == '_')
|
||||
{
|
||||
$name = substr($bn, 3);
|
||||
$number = substr($bn, 0, 2) + 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$name = $bn;
|
||||
$number = -1;
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
31
www/protected/components/widgets/ProgDescription.php
Normal file
31
www/protected/components/widgets/ProgDescription.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
class ProgDescription extends CWidget {
|
||||
/**
|
||||
* @var $program Program
|
||||
*/
|
||||
public $program;
|
||||
|
||||
public function run() {
|
||||
$descriptions = $this->program->getDescriptions();
|
||||
|
||||
if (count($descriptions) === 1)
|
||||
{
|
||||
$this->render('progDescription',
|
||||
[
|
||||
'name' => $this->program->Name,
|
||||
'descriptions' => $descriptions,
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->render('progDescription_tabbed',
|
||||
[
|
||||
'name' => $this->program->Name,
|
||||
'descriptions' => $descriptions,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
16
www/protected/components/widgets/views/progDescription.php
Normal file
16
www/protected/components/widgets/views/progDescription.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/* @var $this ProgDescription */
|
||||
/* @var $name string */
|
||||
/* @var $descriptions array() */
|
||||
?>
|
||||
|
||||
|
||||
<div class="well progview_maincol">
|
||||
<div class="progview_caption" >
|
||||
<h1 class="text-center"><?php echo $name; ?></h1>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
echo ProgramHelper::getDescriptionMarkdownTab($descriptions[0]['path']);
|
||||
?>
|
||||
</div>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/* @var $this ProgDescription */
|
||||
/* @var $name string */
|
||||
/* @var $descriptions array() */
|
||||
?>
|
||||
|
||||
|
||||
<div class="progview_maincol">
|
||||
<div class="progview_caption" >
|
||||
<h1 class="text-center"><?php echo $name; ?></h1>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$this->widget('bootstrap.widgets.TbTabs',
|
||||
[
|
||||
'tabs' => ProgramHelper::convertDescriptionListToTabs($descriptions, $name),
|
||||
]
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
@@ -50,7 +50,6 @@ class Program extends CActiveRecord
|
||||
array('update_identifier', 'length', 'max'=>64),
|
||||
array('programming_lang', 'length', 'max'=>16),
|
||||
// The following rule is used by search().
|
||||
// @TODO-MS Please remove those attributes that should not be searched.
|
||||
array('ID, Name, Thumbnailname, Downloads, Kategorie, Sterne, enabled, visible, Language, programming_lang, Description, add_date, download_url, sourceforge_url, homepage_url, github_url, uses_absCanv, update_identifier, highscore_gid', 'safe', 'on'=>'search'),
|
||||
);
|
||||
}
|
||||
@@ -204,4 +203,47 @@ class Program extends CActiveRecord
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array()
|
||||
*/
|
||||
public function getDescriptions()
|
||||
{
|
||||
$result = array();
|
||||
|
||||
$path = "data/programs/desc/" . $this->Name . "/*";
|
||||
|
||||
$tl_paths = glob($path, GLOB_MARK);
|
||||
|
||||
foreach ($tl_paths as $fn)
|
||||
{
|
||||
if (MsHelper::endsWith($fn, "\\"))
|
||||
{
|
||||
$bl_paths = glob($fn . '*.markdown');
|
||||
|
||||
$bl_arr = array();
|
||||
foreach ($bl_paths as $bl_fn)
|
||||
{
|
||||
$bl_arr[] = ['type' => 1, 'name' => ProgramHelper::getIndexedFilename($bl_fn, $num), 'path' => $bl_fn];
|
||||
}
|
||||
|
||||
$result[] = ['type' => 0,'name' => ProgramHelper::getIndexedFilename($fn, $num), 'items' => $bl_arr];
|
||||
}
|
||||
else if (MsHelper::endsWith($fn, ".markdown"))
|
||||
{
|
||||
$ifn = ProgramHelper::getIndexedFilename($fn, $num);
|
||||
|
||||
if (strcasecmp($ifn, "index") == 0) // == 0 : true
|
||||
{
|
||||
array_unshift($result, ['type' => 1,'name' => $ifn, 'path' => $fn]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result[] = ['type' => 1,'name' => $ifn, 'path' => $fn];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,14 +13,14 @@
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title><?php
|
||||
echo $this->pageTitle; ?></title>
|
||||
echo $this->pageTitle; ?></title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
|
||||
<link rel="icon" type="image/png" href="/images/favicon.png" /> <?php //TODO-MS Add nice favicon ?>
|
||||
<link rel="icon" type="image/png" href="/images/favicon.png"/> <?php //TODO-MS Add nice favicon ?>
|
||||
|
||||
<?php Yii::app()->bootstrap->register(); ?>
|
||||
<link rel="stylesheet" type="text/css" href="/css/styles.css" />
|
||||
<link rel="stylesheet" type="text/css" href="/css/styles.css"/>
|
||||
|
||||
<title><?php echo CHtml::encode($this->pageTitle); ?></title>
|
||||
</head>
|
||||
@@ -29,13 +29,15 @@
|
||||
<p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
|
||||
<!endif]-->
|
||||
|
||||
<?php
|
||||
if (! isset($this->selectedNav)) $this->selectedNav = "";
|
||||
<div id="fullbodywrapper">
|
||||
|
||||
<?php
|
||||
if (!isset($this->selectedNav)) $this->selectedNav = "";
|
||||
|
||||
$this->widget('bootstrap.widgets.TbNavbar',
|
||||
[
|
||||
'brandLabel'=>'<img src="/images/logo_static.png" class="brandLogo"/>',
|
||||
'brandUrl'=>'/',
|
||||
'brandLabel' => '<img src="/images/logo_static.png" class="brandLogo"/>',
|
||||
'brandUrl' => '/',
|
||||
'display' => null,
|
||||
'htmlOptions' =>
|
||||
[
|
||||
@@ -47,12 +49,12 @@
|
||||
'class' => 'bootstrap.widgets.TbNav',
|
||||
'items' =>
|
||||
[
|
||||
['label' => 'Home', 'url' => '/', 'active' => ($this->selectedNav === 'index')],
|
||||
['label' => 'Blog', 'url' => '#', 'active' => ($this->selectedNav === 'blog')],
|
||||
['label' => 'Programs', 'url' => '/programs/', 'active' => ($this->selectedNav === 'prog')],
|
||||
['label' => '', 'items' => ProgramHelper::GetProgDropDownList(), 'htmlOptions' => ['class' => 'dropdown-append']],
|
||||
['label' => 'About', 'url' => '/about', 'active' => ($this->selectedNav === 'about')],
|
||||
['label' => '[[Log "'.Yii::app()->user->name.'" out]]', 'url' => '/logout', 'visible' => !Yii::app()->user->isGuest, 'htmlOptions' => ['class' => 'cstm-main-navbar-highlight']]
|
||||
['label' => 'Home', 'url' => '/', 'active' => ($this->selectedNav === 'index')],
|
||||
['label' => 'Blog', 'url' => '#', 'active' => ($this->selectedNav === 'blog')],
|
||||
['label' => 'Programs', 'url' => '/programs/', 'active' => ($this->selectedNav === 'prog')],
|
||||
['label' => '', 'items' => ProgramHelper::GetProgDropDownList(), 'htmlOptions' => ['class' => 'dropdown-append']],
|
||||
['label' => 'About', 'url' => '/about', 'active' => ($this->selectedNav === 'about')],
|
||||
['label' => '[[Log "' . Yii::app()->user->name . '" out]]', 'url' => '/logout', 'visible' => !Yii::app()->user->isGuest, 'htmlOptions' => ['class' => 'cstm-main-navbar-highlight']]
|
||||
],
|
||||
],
|
||||
MsHtml::navbarSearchForm('/search', '',
|
||||
@@ -71,37 +73,38 @@
|
||||
]),
|
||||
],
|
||||
]);
|
||||
?>
|
||||
?>
|
||||
|
||||
<?php
|
||||
if(isset($this->breadcrumbs))
|
||||
{
|
||||
<?php
|
||||
if (isset($this->breadcrumbs)) {
|
||||
$this->widget('bootstrap.widgets.TbBreadcrumb',
|
||||
[
|
||||
'links'=>$this->breadcrumbs,
|
||||
'links' => $this->breadcrumbs,
|
||||
]);
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
<?php
|
||||
<?php
|
||||
echo $content;
|
||||
?>
|
||||
?>
|
||||
|
||||
<div class="footer">
|
||||
Copyright © <?php echo date('Y'); ?> by Mike Schwörer · <i><a href="/admin">{{admin}}</a></i><br/>
|
||||
All Rights Reserved.<br/>
|
||||
<?php echo Yii::powered(); ?>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
Copyright © <?php echo date('Y'); ?> by Mike Schwörer · <a href="/admin">admin</a><br/>
|
||||
All Rights Reserved.<br/>
|
||||
<?php echo Yii::powered(); ?>
|
||||
</div>
|
||||
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
||||
<script src="/javascript/scripts.js"></script>
|
||||
|
||||
<?php
|
||||
foreach($this->js_scripts as $script ) {
|
||||
echo '<script type="text/javascript" language="JavaScript">', PHP_EOL;
|
||||
echo $script;
|
||||
echo '</script>', PHP_EOL;
|
||||
}
|
||||
foreach ($this->js_scripts as $script) {
|
||||
echo '<script type="text/javascript" language="JavaScript">', PHP_EOL;
|
||||
echo $script;
|
||||
echo '</script>', PHP_EOL;
|
||||
}
|
||||
?>
|
||||
|
||||
</body>
|
||||
|
||||
@@ -21,7 +21,7 @@ $this->selectedNav = '';
|
||||
<div class="accordion" id="lca">
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach($logs as $logelem) { //TODO-MS Translate all log things to eng
|
||||
foreach($logs as $logelem) {
|
||||
$i++;
|
||||
|
||||
$this->widget('ExpandedLogHeader',
|
||||
|
||||
@@ -20,8 +20,8 @@ if (!$model->visible && Yii::app()->user->name != 'admin') {
|
||||
?>
|
||||
|
||||
<div class="container">
|
||||
<?php if (! $model->enabled) echo TbHtml::alert(TbHtml::ALERT_COLOR_WARNING, TbHtml::b('Warning!') . ' This programm is for normal users disabled'); ?>
|
||||
<?php if (! $model->visible) echo TbHtml::alert(TbHtml::ALERT_COLOR_WARNING, TbHtml::b('Warning!') . ' This programm is for normal users invisible'); ?>
|
||||
<?php if (!$model->enabled) echo TbHtml::alert(TbHtml::ALERT_COLOR_WARNING, TbHtml::b('Warning!') . ' This programm is for normal users disabled'); ?>
|
||||
<?php if (!$model->visible) echo TbHtml::alert(TbHtml::ALERT_COLOR_WARNING, TbHtml::b('Warning!') . ' This programm is for normal users invisible'); ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="span3">
|
||||
@@ -63,7 +63,7 @@ if (!$model->visible && Yii::app()->user->name != 'admin') {
|
||||
<div class="text-right progview_inforow">
|
||||
<?php if ($model->uses_absCanv): ?>
|
||||
<a href="/programs/view/AbsCanvas">
|
||||
<?php echo TbHtml::badge('AbsCanvas', array('color' => TbHtml::BADGE_COLOR_WARNING)); ?>
|
||||
<?php echo TbHtml::badge('AbsCanvas', array('color' => TbHtml::BADGE_COLOR_WARNING)); ?>
|
||||
</a>
|
||||
<?php endif ?>
|
||||
|
||||
@@ -73,28 +73,15 @@ if (!$model->visible && Yii::app()->user->name != 'admin') {
|
||||
</div>
|
||||
|
||||
<div class="span6">
|
||||
<div class="well">
|
||||
<h1 class="text-center"><?php echo $model->Name; ?></h1>
|
||||
<hr/>
|
||||
|
||||
<div class="markdownOwner">
|
||||
<div>
|
||||
<p>
|
||||
<?php
|
||||
$this->beginWidget('CMarkdown');
|
||||
|
||||
for ($i = 0; $i < 24; $i++)
|
||||
echo $model->Description . '<br>';
|
||||
|
||||
$this->endWidget();
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$this->widget('ProgDescription',
|
||||
[
|
||||
'program' => $model,
|
||||
]
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="span3">
|
||||
<div class="well">
|
||||
<img src="<?php echo $model->getImagePath(); ?>" class="progview_image"/>
|
||||
@@ -106,12 +93,12 @@ if (!$model->visible && Yii::app()->user->name != 'admin') {
|
||||
'block' => true,
|
||||
'color' => TbHtml::BUTTON_COLOR_PRIMARY,
|
||||
'size' => TbHtml::BUTTON_SIZE_DEFAULT,
|
||||
'url' => '#',
|
||||
'url' => '#', //TODO-MS Add Download link
|
||||
]);
|
||||
?>
|
||||
|
||||
<?php
|
||||
if (! empty($model->github_url))
|
||||
if (!empty($model->github_url))
|
||||
echo TbHtml::linkbutton('Github',
|
||||
[
|
||||
'block' => true,
|
||||
@@ -122,7 +109,7 @@ if (!$model->visible && Yii::app()->user->name != 'admin') {
|
||||
?>
|
||||
|
||||
<?php
|
||||
if (! empty($model->sourceforge_url))
|
||||
if (!empty($model->sourceforge_url))
|
||||
echo TbHtml::linkbutton('Sourceforge',
|
||||
[
|
||||
'block' => true,
|
||||
@@ -133,7 +120,7 @@ if (!$model->visible && Yii::app()->user->name != 'admin') {
|
||||
?>
|
||||
|
||||
<?php
|
||||
if (! empty($model->homepage_url))
|
||||
if (!empty($model->homepage_url))
|
||||
echo TbHtml::linkbutton('Homepage',
|
||||
[
|
||||
'block' => true,
|
||||
@@ -150,7 +137,7 @@ if (!$model->visible && Yii::app()->user->name != 'admin') {
|
||||
'block' => true,
|
||||
'color' => TbHtml::BUTTON_COLOR_SUCCESS,
|
||||
'size' => TbHtml::BUTTON_SIZE_DEFAULT,
|
||||
'url' => '#',
|
||||
'url' => '#', //TODO-MS Add Highscore link
|
||||
]);
|
||||
?>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user