diff --git a/core/lib/Thelia/Admin/Controller/CategoryController.php b/core/lib/Thelia/Admin/Controller/CategoryController.php new file mode 100644 index 000000000..6f64d2a1d --- /dev/null +++ b/core/lib/Thelia/Admin/Controller/CategoryController.php @@ -0,0 +1,63 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Admin\Controller; + +class CategoryController extends BaseAdminController { + + public function indexAction() + { + // Show top level categories and products + $args = array( + 'action' => 'browse', + 'current_category_id' => 0 + ); + + return $this->render('categories', $args); + } + + public function processAction($action) + { + list($action, $id) = explode('/', $action); + + $args = array( + 'action' => $action, + 'current_category_id' => $id + ); + + // Browe categories + if ($action == 'browse') { + return $this->render('categories', $args); + } + // Create a new category + else if ($action = 'create') { + return $this->render('edit_category', $args); + } + // Edit an existing category + else if ($action = 'edit') { + return $this->render('edit_category', $args); + } + + //return $this->render("categories"); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 58c0c8579..ac16fa216 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -82,7 +82,7 @@ - false + true %kernel.environment% %kernel.debug% diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index 7c9740ee0..1f26e86fb 100755 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -97,7 +97,8 @@ abstract class BaseLoop if (substr($name, 0, 3) == 'get') { - $argName = strtolower(substr($name, 3)); + // camelCase to underscore: getNotEmpty -> not_empty + $argName = strtolower(preg_replace('/([^A-Z])([A-Z])/', "$1_$2", substr($name, 3))); return $this->getArg($argName)->getValue(); } diff --git a/core/lib/Thelia/Core/Template/Loop/CategoryPath.php b/core/lib/Thelia/Core/Template/Loop/CategoryPath.php new file mode 100644 index 000000000..e1fa1fd30 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/CategoryPath.php @@ -0,0 +1,126 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\BaseLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Log\Tlog; + +use Thelia\Model\CategoryQuery; +use Thelia\Model\ConfigQuery; +use Thelia\Type\TypeCollection; +use Thelia\Type; + +/** + * + * Category path loop, to get the path to a given category. + * + * - category is the category id + * - depth is the maximum depth to go, default unlimited + * - level is the exact level to return. Example: if level = 2 and the path is c1 -> c2 -> c3 -> c4, the loop will return c2 + * - visible if true or missing, only visible categories will be displayed. If false, all categories (visible or not) are returned. + * + * example : + * + * + * #TITLE + * + * + * + * Class CategoryPath + * @package Thelia\Core\Template\Loop + * @author Franck Allimant + */ +class CategoryPath extends BaseLoop +{ + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntTypeArgument('category', null, true), + Argument::createIntTypeArgument('depth'), + Argument::createIntTypeArgument('level'), + Argument::createBooleanTypeArgument('visible', true, false) + ); + } + + /** + * @param $pagination (ignored) + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $id = $this->getCategory(); + $visible = $this->getVisible(); + + $search = CategoryQuery::create(); + $search->filterById($id); + if ($visible == true) $search->filterByVisible($visible); + + $results = array(); + + do { + $category = $search->findOne(); + + if ($category != null) { + + $loopResultRow = new LoopResultRow(); + + $loopResultRow + ->set("TITLE",$category->getTitle()) + ->set("URL", $category->getUrl()) + ->set("ID", $category->getId()) + ; + + $results[] = $loopResultRow; + + $parent = $category->getParent(); + + if ($parent > 0) { + $search = CategoryQuery::create(); + $search->filterById($parent); + if ($visible == true) $search->filterByVisible($visible); + } + } + } + while ($category != null && $parent > 0); + + // Reverse list and build the final result + $results = array_reverse($results); + + $loopResult = new LoopResult(); + + foreach($results as $result) $loopResult->addRow($result); + + return $loopResult; + } +} \ No newline at end of file diff --git a/templates/admin/default/assets/css/admin.less b/templates/admin/default/assets/css/admin.less index f93a1cdd6..0c6019d78 100755 --- a/templates/admin/default/assets/css/admin.less +++ b/templates/admin/default/assets/css/admin.less @@ -217,6 +217,16 @@ hr { height: @top-bar-height; } } + + .view-shop { + line-height: @top-bar-height; + margin-right: 20px; + float: right; + a { + color: #fff; + text-decoration: none; + } + } } // -- Brandbar ---------------------------------------------------------------- @@ -540,11 +550,95 @@ textarea:focus, input[type="text"]:focus, input[type="password"]:focus, input[ty border-color: #3a87ad; } +// -- General decoration of back-office boxes --------------------------------- + +.general-block-decorator { + background: none repeat scroll 0 0 white; + border: 1px solid rgba(0, 0, 0, 0.2); + border-radius: 4px 4px 4px 4px; + box-shadow: 0 -4px 0 rgba(0, 0, 0, 0.05) inset, 0 2px 3px rgba(0, 0, 0, 0.1); + padding: 1em; + margin-bottom: 20px; + + .title { + color: #5A6876; + text-transform: uppercase; + font-weight: bold; + padding-bottom: 0.5em; + + line-height: 30px; + } + + .actions { + text-align: right; + } +} + +// -- Admin forms tweaking ---------------------------------------------------- + +label { + font-weight: bold; + + &.checkbox { + font-weight: normal; + } +} + +// Information in field label +.label-help-block, .help-block { + color: lighten(#595959, 20); + display: block; + font-size: 80%; + font-style: italic; + line-height: 130%; + font-weight: normal; +} + +.form-horizontal input + .help-block, +.form-horizontal select + .help-block, +.form-horizontal textarea + .help-block, +.form-horizontal .uneditable-input + .help-block, +.form-horizontal .input-prepend + .help-block, +.form-horizontal .input-append + .help-block +.help-block, .form-horizontal .help-block { + margin-top: 0px; +} + +// Fix for append-fields shorter than others +// see http://stackoverflow.com/questions/13306670/bootstrap-prepended-and-appended-input-how-to-max-input-field-width +.input-append.input-block-level, +.input-prepend.input-block-level { + display: table; +} + +.input-append.input-block-level .add-on, +.input-prepend.input-block-level .add-on { + display: table-cell; + width: 1%; /* remove this if you want default bootstrap button width */ +} + +.input-append.input-block-level > input, +.input-prepend.input-block-level > input { + box-sizing: border-box; /* use bootstrap mixin or include vendor variants */ + display: table; /* table-cell is not working well in Chrome for small widths */ + min-height: inherit; + width: 100%; +} + +.input-append.input-block-level > input { + border-right: 0; +} + +.input-prepend.input-block-level > input { + border-left: 0; +} + // -- Catalog Tables ---------------------------------------------------------- .table-striped { background: white; + margin-bottom: 1em; caption { text-align: left; @@ -552,7 +646,7 @@ textarea:focus, input[type="text"]:focus, input[type="password"]:focus, input[ty text-transform: uppercase; font-weight: bold; background-color: #fff; - padding: 0.5em 0.5em 0.5em 1em; + padding-bottom: 0.5em; border-bottom: 2px solid #A5CED8; line-height: 30px; @@ -574,15 +668,5 @@ textarea:focus, input[type="text"]:focus, input[type="password"]:focus, input[ty td.message { // Center the alert box (20px bottom margin) in the table cell padding: 20px 20px 0 20px; - - // No border, nor background in alert blocks - .alert { - border: none; - background-color: transparent; - - &-info { - background-color: transparent; - } - } } } \ No newline at end of file diff --git a/templates/admin/default/assets/css/img/logout.png b/templates/admin/default/assets/css/img/logout.png new file mode 100644 index 000000000..af5e214cb Binary files /dev/null and b/templates/admin/default/assets/css/img/logout.png differ diff --git a/templates/admin/default/assets/css/img/title-header.png b/templates/admin/default/assets/css/img/title-header.png new file mode 100644 index 000000000..322076e65 Binary files /dev/null and b/templates/admin/default/assets/css/img/title-header.png differ diff --git a/templates/admin/default/categories.html b/templates/admin/default/categories.html new file mode 100644 index 000000000..2a43dd426 --- /dev/null +++ b/templates/admin/default/categories.html @@ -0,0 +1,170 @@ +{check_auth context="admin" roles="ADMIN" permissions="admin.catalog.view" login_tpl="/admin/login"} + +{$page_title={intl l='Catalog'}} + +{include file='includes/header.inc.html'} + +
+
+ + + + {module_include location='catalog_top'} + +
+
+
+ + + + {ifloop rel="category_list"} + + + + + {module_include location='category_list_header'} + + + + + + + + + {loop name="category_list" type="category" parent="{$current_category_id}" order="manual"} + + + + {module_include location='category_list_row'} + + + + + + + + {/loop} + + {/ifloop} + + {elseloop rel="category_list"} + + + + + + {/elseloop} +
+ {* display parent category name, and get current cat ID *} + {loop name="category_title" type="category" id="{$current_category_id}"} + {intl l="Categories in %cat" cat=$TITLE} + {$cat_id = $ID} + {/loop} + {elseloop rel="category_title"} + {intl l="Top level categories"} + {/elseloop} + + {module_include location='category_list_caption'} + + + + +
{intl l="Category title"}{intl l="Online"}{intl l="Position"}{intl l="Actions"}
{$TITLE} + + + + {$POSITION} + + + + + +
{intl l="This category has no sub-categories. To create a new one, click the + button above."}
+
+
+
+ +
+
+
+ + + + {ifloop rel="product_list"} + + + + + + + {module_include location='product_list_header'} + + + + + + + + + {loop name="product_list" type="product" category="{$current_category_id}" order="manual"} + + + + + + {module_include location='product_list_row'} + + + + + + + + {/loop} + + {/ifloop} + + {elseloop rel="product_list"} + + + + + + {/elseloop} +
+ {* display parent category name *} + {loop name="category_title" type="category" id="{$current_category_id}"} + {intl l="Products in %cat" cat=$TITLE} + {/loop} + {elseloop rel="category_title"} + {intl l="Top level Products"} + {/elseloop} + + {module_include location='product_list_caption'} + + + + +
{intl l="Image"}{intl l="Product title"}{intl l="Online"}{intl l="Position"}{intl l="Actions"}
Image !{$TITLE} + + + + {$POSITION} + + + + +
{intl l="This category doesn't have any products. To add a new product, click the + button above."}
+
+
+
+ + {module_include location='catalog_bottom'} +
+
+ +{include file='includes/js.inc.html'} + +{include file='includes/footer.inc.html'} \ No newline at end of file diff --git a/templates/admin/default/edit_category.html b/templates/admin/default/edit_category.html new file mode 100644 index 000000000..5ad547fa0 --- /dev/null +++ b/templates/admin/default/edit_category.html @@ -0,0 +1,195 @@ +{check_auth context="admin" roles="ADMIN" permissions="admin.catalog.view" login_tpl="/admin/login"} + +{if $action == 'create'} + {$page_title={intl l='Create a new category'}} +{else} + {$page_title={intl l='Edit category'}} +{/if} + +{include file='includes/header.inc.html'} + +
+
+ + +
+ +
+
+
+ {if $action == 'create'} + {intl l='Create a new category'} + {else} + {intl l='Edit category'} + {/if} +
+ +
+ + + {if $action != 'create'} + + + + {/if} +
+
+ +
+ + +
+
+
+
+
+
+
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ + +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
{intl l="The rewritten URL to the category page. Click \"Use Default\" button to use the default URL. Use only digits, letters, - and _ characters."}
+
+
+ +
+
+ +
+
+ +
+ + +
+ +
+
+
+ +
+
+ + +
+ +
+
+
+
+

aff Date creation ?

+

aff date modif ?

+
+
+
+ +
+

Infos générales

+
+
+

Images

+
+
+

Documents

+
+
+

Modules

+
+
+ +
+
+
+
+
+ +{include file='includes/js.inc.html'} + + + +{include file='includes/footer.inc.html'} \ No newline at end of file diff --git a/templates/admin/default/includes/category_breadcrumb.html b/templates/admin/default/includes/category_breadcrumb.html new file mode 100644 index 000000000..8bb6aa6ff --- /dev/null +++ b/templates/admin/default/includes/category_breadcrumb.html @@ -0,0 +1,28 @@ + +
  • Home /
  • +
  • Catalog +{ifloop rel="category_path"} + /
  • + + {loop name="category_path" type="category-path" category="{$current_category_id}"} + {if $ID == $current_category_id} +
  • + {if $action == 'edit'} + {intl l='Editing %cat' cat="{$TITLE}"} + {else} + {$TITLE} {intl l="(edit)"} + {/if} +
  • + {else} +
  • {$TITLE} /
  • + {/if} + {/loop} +{/ifloop} +{elseloop rel="category_path"} + {if $action == 'create'}/{/if} +{/elseloop} + +{if $action == 'create'} +
  • {intl l='Create a new category'}
  • +{/if} + diff --git a/templates/admin/default/includes/header.inc.html b/templates/admin/default/includes/header.inc.html index e0a6d983e..1f11208d9 100755 --- a/templates/admin/default/includes/header.inc.html +++ b/templates/admin/default/includes/header.inc.html @@ -58,6 +58,8 @@ {/loop} + + diff --git a/templates/admin/default/includes/js.inc.html b/templates/admin/default/includes/js.inc.html new file mode 100644 index 000000000..367d966ff --- /dev/null +++ b/templates/admin/default/includes/js.inc.html @@ -0,0 +1,13 @@ + +{* Include required JS files *} + +{javascripts file='../assets/js/jquery.min.js'} + +{/javascripts} + +{javascripts file='../assets/bootstrap/js/bootstrap.min.js'} + +{/javascripts} + +{* Modules scripts are included now *} +{module_include location='footer_js'} diff --git a/templates/admin/default/includes/thelia_news_feed.html b/templates/admin/default/includes/thelia_news_feed.html new file mode 100644 index 000000000..8ef8e2528 --- /dev/null +++ b/templates/admin/default/includes/thelia_news_feed.html @@ -0,0 +1,10 @@ +{* this temlate is loaded via Ajax in the login page, to prevent login page slowdown *} + +{loop type="feed" name="thelia_feeds" url="http://thelia.net/Flux-rss.html?id_rubrique=8" limit="3"} +
    +

    {$DATE}

    +

    {$TITLE|strip_tags}

    +

    {$DESCRIPTION|strip_tags|truncate:250:"...":true}

    +

    {intl l='Lire la suite »'}

    +
    +{/loop}