From 427b5b1dc488c04bc8f29a6ae15fa488dea229ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Sat, 5 Jul 2014 21:15:24 +0200 Subject: [PATCH] Added proper Description Implementation and Layout for programs --- .idea/workspace.xml | 464 +++++++++++------- www/css/styles.css | 58 ++- ...ions.markdown => 01_Instructions.markdown} | 0 .../{Tricks.markdown => 02_Tricks.markdown} | 0 www/protected/components/MsHelper.php | 16 + www/protected/components/ProgramHelper.php | 70 +++ .../components/widgets/ProgDescription.php | 31 ++ .../widgets/views/progDescription.php | 16 + .../widgets/views/progDescription_tabbed.php | 20 + www/protected/models/Program.php | 44 +- www/protected/views/layouts/main.php | 63 +-- www/protected/views/log/index.php | 2 +- www/protected/views/programs/view.php | 43 +- 13 files changed, 600 insertions(+), 227 deletions(-) rename www/data/programs/desc/Crystal Grid/{Instructions.markdown => 01_Instructions.markdown} (100%) rename www/data/programs/desc/Crystal Grid/{Tricks.markdown => 02_Tricks.markdown} (100%) create mode 100644 www/protected/components/widgets/ProgDescription.php create mode 100644 www/protected/components/widgets/views/progDescription.php create mode 100644 www/protected/components/widgets/views/progDescription_tabbed.php diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 40046b6..d990ae7 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,13 +2,13 @@ - - - - + + + + @@ -63,73 +63,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - + @@ -148,14 +123,9 @@ @@ -345,6 +320,102 @@ + + - - - + @@ -541,12 +638,20 @@ - - - - - - + + + + + + + + + + + + + + @@ -609,24 +714,24 @@ - + - - + + - + - + @@ -650,62 +755,15 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -721,11 +779,6 @@ - - - - - @@ -750,11 +803,6 @@ - - - - - @@ -810,11 +858,6 @@ - - - - - @@ -862,13 +905,6 @@ - - - - - - - @@ -918,23 +954,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + - - - - - - - - + diff --git a/www/css/styles.css b/www/css/styles.css index 5f9d872..13e3951 100644 --- a/www/css/styles.css +++ b/www/css/styles.css @@ -1,8 +1,29 @@ +/* Basic +-------------------------------------------------- */ + +html, +body { + margin:0; + padding:0; + height:100%; +} + /* Footer -------------------------------------------------- */ +#fullbodywrapper { + min-height:100%; + position:relative; +} + .footer { - padding: 45px 0; + width:100%; + height:80px; + position:absolute; + bottom:0; + left:0; + + padding: 25px 0 0 0; margin-top: 70px; border-top: 1px solid #e5e5e5; background-color: #f5f5f5; @@ -574,3 +595,38 @@ ul.nav li.dropdown-append:hover > ul.dropdown-menu { padding-bottom: 10px; } +.progview_maincol > .tabbable > .tab-content { + background-color: #ECF0F1; + + margin: -20px 0px 0px 0px; + + padding: 0px 5px 0px 5px; + + border-radius: 0px 0px 6px 6px; +} + +.progview_maincol > .tabbable >.nav-tabs >.active > a { + background-color: #ECF0F1; +} + +.progview_maincol > .tabbable >.nav-tabs a:hover, +.progview_maincol > .tabbable >.nav-tabs a:active, +.progview_maincol > .tabbable >.nav-tabs a:focus { + outline: 0 !important; +} + +.well .progview_caption { + margin: -19px -19px 28px -19px; +} + +.progview_caption { + background-color: #2C3E50; + + color: #ECF0F1; + text-shadow: 0px 0px 4px #000; + + padding: 6px; + margin-bottom: 28px; + + border-radius: 6px 6px 0px 0px; +} \ No newline at end of file diff --git a/www/data/programs/desc/Crystal Grid/Instructions.markdown b/www/data/programs/desc/Crystal Grid/01_Instructions.markdown similarity index 100% rename from www/data/programs/desc/Crystal Grid/Instructions.markdown rename to www/data/programs/desc/Crystal Grid/01_Instructions.markdown diff --git a/www/data/programs/desc/Crystal Grid/Tricks.markdown b/www/data/programs/desc/Crystal Grid/02_Tricks.markdown similarity index 100% rename from www/data/programs/desc/Crystal Grid/Tricks.markdown rename to www/data/programs/desc/Crystal Grid/02_Tricks.markdown diff --git a/www/protected/components/MsHelper.php b/www/protected/components/MsHelper.php index 38b2f7a..cc5a6eb 100644 --- a/www/protected/components/MsHelper.php +++ b/www/protected/components/MsHelper.php @@ -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); + } } \ No newline at end of file diff --git a/www/protected/components/ProgramHelper.php b/www/protected/components/ProgramHelper.php index 9a9de8f..09e326d 100644 --- a/www/protected/components/ProgramHelper.php +++ b/www/protected/components/ProgramHelper.php @@ -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 = '

'; + $result .= $md->transform($content); + $result .= '

'; + + 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; + } } \ No newline at end of file diff --git a/www/protected/components/widgets/ProgDescription.php b/www/protected/components/widgets/ProgDescription.php new file mode 100644 index 0000000..b99cd3a --- /dev/null +++ b/www/protected/components/widgets/ProgDescription.php @@ -0,0 +1,31 @@ +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, + ]); + } + + + } +} \ No newline at end of file diff --git a/www/protected/components/widgets/views/progDescription.php b/www/protected/components/widgets/views/progDescription.php new file mode 100644 index 0000000..aef4753 --- /dev/null +++ b/www/protected/components/widgets/views/progDescription.php @@ -0,0 +1,16 @@ + + + +
+
+

+
+ + +
\ No newline at end of file diff --git a/www/protected/components/widgets/views/progDescription_tabbed.php b/www/protected/components/widgets/views/progDescription_tabbed.php new file mode 100644 index 0000000..d7fc387 --- /dev/null +++ b/www/protected/components/widgets/views/progDescription_tabbed.php @@ -0,0 +1,20 @@ + + + +
+
+

+
+ + widget('bootstrap.widgets.TbTabs', + [ + 'tabs' => ProgramHelper::convertDescriptionListToTabs($descriptions, $name), + ] + ); + ?> +
\ No newline at end of file diff --git a/www/protected/models/Program.php b/www/protected/models/Program.php index b7b2a7c..b09b8cd 100644 --- a/www/protected/models/Program.php +++ b/www/protected/models/Program.php @@ -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; + } } diff --git a/www/protected/views/layouts/main.php b/www/protected/views/layouts/main.php index a3caf28..0e702f0 100644 --- a/www/protected/views/layouts/main.php +++ b/www/protected/views/layouts/main.php @@ -13,14 +13,14 @@ <?php - echo $this->pageTitle; ?> + echo $this->pageTitle; ?> - + bootstrap->register(); ?> - + <?php echo CHtml::encode($this->pageTitle); ?> @@ -29,13 +29,15 @@

You are using an outdated browser. Please upgrade your browser or activate Google Chrome Frame to improve your experience.

-selectedNav)) $this->selectedNav = ""; +
+ + selectedNav)) $this->selectedNav = ""; $this->widget('bootstrap.widgets.TbNavbar', [ - 'brandLabel'=>'', - 'brandUrl'=>'/', + 'brandLabel' => '', + '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 @@ ]), ], ]); -?> + ?> -breadcrumbs)) - { + breadcrumbs)) { $this->widget('bootstrap.widgets.TbBreadcrumb', [ - 'links'=>$this->breadcrumbs, + 'links' => $this->breadcrumbs, ]); } -?> + ?> - + ?> + + - js_scripts as $script ) { - echo '', PHP_EOL; - } +foreach ($this->js_scripts as $script) { + echo '', PHP_EOL; +} ?> diff --git a/www/protected/views/log/index.php b/www/protected/views/log/index.php index 713ef03..b6c1716 100644 --- a/www/protected/views/log/index.php +++ b/www/protected/views/log/index.php @@ -21,7 +21,7 @@ $this->selectedNav = '';
widget('ExpandedLogHeader', diff --git a/www/protected/views/programs/view.php b/www/protected/views/programs/view.php index fe39e5b..155f905 100644 --- a/www/protected/views/programs/view.php +++ b/www/protected/views/programs/view.php @@ -20,8 +20,8 @@ if (!$model->visible && Yii::app()->user->name != 'admin') { ?>
- enabled) echo TbHtml::alert(TbHtml::ALERT_COLOR_WARNING, TbHtml::b('Warning!') . ' This programm is for normal users disabled'); ?> - visible) echo TbHtml::alert(TbHtml::ALERT_COLOR_WARNING, TbHtml::b('Warning!') . ' This programm is for normal users invisible'); ?> + enabled) echo TbHtml::alert(TbHtml::ALERT_COLOR_WARNING, TbHtml::b('Warning!') . ' This programm is for normal users disabled'); ?> + visible) echo TbHtml::alert(TbHtml::ALERT_COLOR_WARNING, TbHtml::b('Warning!') . ' This programm is for normal users invisible'); ?>
@@ -63,7 +63,7 @@ if (!$model->visible && Yii::app()->user->name != 'admin') {
uses_absCanv): ?> - TbHtml::BADGE_COLOR_WARNING)); ?> + TbHtml::BADGE_COLOR_WARNING)); ?> @@ -73,28 +73,15 @@ if (!$model->visible && Yii::app()->user->name != 'admin') {
-
-

Name; ?>

-
- -
-
-

- beginWidget('CMarkdown'); - - for ($i = 0; $i < 24; $i++) - echo $model->Description . '
'; - - $this->endWidget(); - ?> -

-
-
-
+ widget('ProgDescription', + [ + 'program' => $model, + ] + ); + ?>
-
@@ -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 ]); ?> 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') { ?> 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') { ?> 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 ]); ?>