first commit
This commit is contained in:
673
apps/backend/modules/stCategory/actions/actions.class.php
Normal file
673
apps/backend/modules/stCategory/actions/actions.class.php
Normal file
@@ -0,0 +1,673 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SOTESHOP/stCategory
|
||||
*
|
||||
* Ten plik należy do aplikacji stCategory opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stCategory
|
||||
* @subpackage actions
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
|
||||
* @version $Id: actions.class.php 10063 2010-12-30 12:57:19Z marcin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Akcje kategorii
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
*
|
||||
* @package stCategory
|
||||
* @subpackage actions
|
||||
*/
|
||||
class stCategoryActions extends autostCategoryActions
|
||||
{
|
||||
public function executeList()
|
||||
{
|
||||
return $this->redirect('@stCategory?action=manager');
|
||||
}
|
||||
|
||||
public function executeAjaxJstreeJson()
|
||||
{
|
||||
$results = CategoryPeer::doSelectByParentIdAsJsTreeFormat($this->getRequestParameter('id'));
|
||||
|
||||
return $this->renderJSON($results);
|
||||
}
|
||||
public function executeAjaxCategoryFilterChildren()
|
||||
{
|
||||
$url = $this->getRequestParameter('url');
|
||||
$id = $this->getRequestParameter('id');
|
||||
$parent = CategoryPeer::retrieveByPK($id);
|
||||
|
||||
if (null === $parent)
|
||||
{
|
||||
return sfView::HEADER_ONLY;
|
||||
}
|
||||
|
||||
$result = $this->getRenderPartial('stCategory/categories', array('parent' => $parent, 'expanded' => array(), 'selected' => null, 'url' => $url));
|
||||
|
||||
return $this->renderText($result);
|
||||
}
|
||||
|
||||
public function executeAjaxCategoryTree()
|
||||
{
|
||||
$roots = CategoryPeer::doSelectRoots(new Criteria());
|
||||
|
||||
$html_data = '';
|
||||
|
||||
$this->default = $this->getRequestParameter('default');
|
||||
$this->show_default = $this->getRequestParameter('show_default', true);
|
||||
$this->allow_assign_leaf_only = $this->getRequestParameter('allow_assign_leaf_only', false);
|
||||
$this->tree_id = $this->getRequestParameter('tree_id');
|
||||
$this->limit = $this->getRequestParameter('limit');
|
||||
|
||||
$allow_assign_root = $this->getRequestParameter('allow_assign_root', false);
|
||||
|
||||
$path = array();
|
||||
|
||||
$assigned = $this->getRequestParameter('assigned');
|
||||
|
||||
$this->assigned = $assigned ? array_flip(explode(',', $assigned)) : array();
|
||||
|
||||
|
||||
if ($this->assigned)
|
||||
{
|
||||
foreach (CategoryPeer::retrieveByPKs(array_keys($this->assigned)) as $cat)
|
||||
{
|
||||
foreach ($cat->getPath('doSelectIds') as $p)
|
||||
{
|
||||
$path[] = $p;
|
||||
}
|
||||
}
|
||||
|
||||
$path = array_flip($path);
|
||||
}
|
||||
|
||||
|
||||
if (!$path && $roots)
|
||||
{
|
||||
$path[$roots[0]->getId()] = $roots[0]->getId();
|
||||
}
|
||||
|
||||
|
||||
foreach ($roots as $root)
|
||||
{
|
||||
$id = $root->getId();
|
||||
|
||||
$assigned = isset($this->assigned[$id]);
|
||||
|
||||
if (isset($path[$root->getId()]))
|
||||
{
|
||||
$params = array('status' => 'open', 'children' => $this->getAjaxTreeChildren($root, $path));
|
||||
}
|
||||
else
|
||||
{
|
||||
$params = array('status' => $root->hasChildren() ? 'closed' : 'leaf');
|
||||
}
|
||||
|
||||
if ($allow_assign_root && !$this->allow_assign_leaf_only)
|
||||
{
|
||||
if (1 == $this->limit)
|
||||
{
|
||||
$content = stJQueryToolsHelper::getJsTreeHtmlSingleAssignedControl('jstree_category', $id, $assigned, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
$content = stJQueryToolsHelper::getJsTreeHtmlAssignedControl('jstree_category', $id, $assigned, false);
|
||||
}
|
||||
|
||||
$params['content'] = $content;
|
||||
}
|
||||
|
||||
$params['scope'] = $this->tree_id;
|
||||
|
||||
$html_data .= stJQueryToolsHelper::getJsTreeHtmlRow($root->getId(), htmlspecialchars(strtr($root->getOptName(), array("\n" => "", "\r" => "")), ENT_QUOTES), $params);
|
||||
}
|
||||
|
||||
$this->html_data = $html_data;
|
||||
}
|
||||
|
||||
public function executeAjaxCategoryChildren()
|
||||
{
|
||||
$id = $this->getRequestParameter('id');
|
||||
|
||||
$assigned = $this->getRequestParameter('assigned');
|
||||
|
||||
$this->default = $this->getRequestParameter('default');
|
||||
$this->show_default = $this->getRequestParameter('show_default');
|
||||
$this->allow_assign_leaf_only = $this->getRequestParameter('allow_assign_leaf_only', false);
|
||||
$this->tree_id = $this->getRequestParameter('tree_id');
|
||||
$this->limit = $this->getRequestParameter('limit');
|
||||
|
||||
if ($assigned)
|
||||
{
|
||||
$this->assigned = array_flip(explode(',', $assigned));
|
||||
}
|
||||
|
||||
$parent = CategoryPeer::retrieveByPK($id);
|
||||
|
||||
if (!$parent)
|
||||
{
|
||||
return sfView::NONE;
|
||||
}
|
||||
|
||||
$html_data = $this->getAjaxTreeChildren($parent);
|
||||
|
||||
return $this->renderText($html_data);
|
||||
}
|
||||
|
||||
public function executeSetRootPosition()
|
||||
{
|
||||
$id = $this->getRequestParameter("id");
|
||||
|
||||
$move = $this->getRequestParameter('move');
|
||||
|
||||
$node = CategoryPeer::retrieveByPK($id);
|
||||
|
||||
if ($node->isRoot())
|
||||
{
|
||||
if ($move == 'up')
|
||||
{
|
||||
$this->treeMoveUp($node);
|
||||
}
|
||||
elseif ($move == 'down')
|
||||
{
|
||||
$this->treeMoveDown($node);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->redirect('stCategory/manager');
|
||||
}
|
||||
|
||||
public function executeIndex()
|
||||
{
|
||||
$this->redirect('category/manager');
|
||||
}
|
||||
|
||||
/**
|
||||
* Wyświetla zarządzanie kategoriami
|
||||
*/
|
||||
public function executeManager()
|
||||
{
|
||||
$category_id = $this->getRequestParameter('category_id');
|
||||
$i18n = $this->getContext()->getI18N();
|
||||
$selected = array();
|
||||
|
||||
if ($category_id)
|
||||
{
|
||||
$category = CategoryPeer::retrieveByPK($category_id);
|
||||
|
||||
if ($category && $category->getLevel() > 1)
|
||||
{
|
||||
foreach ($category->getPath() as $current)
|
||||
{
|
||||
$selected[] = $current->getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->roots = CategoryPeer::doSelectByParentIdAsJsTreeFormat(null, $selected);
|
||||
$this->maxRootPosition = CategoryPeer::getMaxRootPosition();
|
||||
|
||||
$this->setFlash('info', $i18n->__('Aby dodać/usunąć/edytować kategorię należy kliknąć prawym przyciskiem myszy na nazwę kategorii.'), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dodaje nowe drzewo kategorii
|
||||
*/
|
||||
public function executeAddTree()
|
||||
{
|
||||
stAuthUsersListener::checkModificationCredentials($this, $this->getRequest(), 'stCategory', false);
|
||||
|
||||
$name = $this->getRequestParameter("category_tree_name");
|
||||
|
||||
$tree = new Category();
|
||||
|
||||
$tree->setCulture(stLanguage::getOptLanguage());
|
||||
|
||||
$tree->setName($name);
|
||||
|
||||
$tree->makeRoot();
|
||||
|
||||
$tree->save();
|
||||
|
||||
$tree->setScope($tree->getId());
|
||||
|
||||
$tree->save();
|
||||
|
||||
$this->redirect('category/manager');
|
||||
}
|
||||
|
||||
/**
|
||||
* Dodaje nową kategorię do drzewa
|
||||
*/
|
||||
public function executeAjaxAdd()
|
||||
{
|
||||
stAuthUsersListener::checkModificationCredentials($this, $this->getRequest(), 'stCategory', false);
|
||||
|
||||
$name = $this->getRequestParameter("name");
|
||||
|
||||
$parentId = $this->getRequestParameter("parent_id");
|
||||
|
||||
$c = new Criteria();
|
||||
|
||||
$parent = CategoryPeer::retrieveByPK($parentId);
|
||||
|
||||
$category = new Category();
|
||||
|
||||
$category->setCulture(stLanguage::getHydrateCulture());
|
||||
|
||||
$category->setName($name);
|
||||
|
||||
$category->insertAsLastChildOf($parent);
|
||||
|
||||
$category->save();
|
||||
|
||||
return $this->renderJSON(array('id' => $category->getId(), 'name' => $category->getName()));
|
||||
}
|
||||
|
||||
public function executeAjaxDelete()
|
||||
{
|
||||
$id = $this->getRequestParameter("id");
|
||||
|
||||
$category = CategoryPeer::retrieveByPK($id);
|
||||
|
||||
if ($category)
|
||||
{
|
||||
$i18n = $this->getContext()->getI18N();
|
||||
if (stConfig::getInstance('stCategory')->get('check_for_product_before_delete') && $category->hasProducts())
|
||||
{
|
||||
return $this->renderJSON(array("error" => $i18n->__('Kategoria nie może być usunięta dopóki ma przypisane produkty', null, 'stCategory')));
|
||||
}
|
||||
|
||||
$category->delete();
|
||||
}
|
||||
|
||||
return sfView::HEADER_ONLY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktualizuje nazwę kategorii i zwraca jej nazwę jako odpowiedź na wywołanie Ajax
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function executeAjaxRename()
|
||||
{
|
||||
stAuthUsersListener::checkModificationCredentials($this, $this->getRequest(), 'stCategory', false);
|
||||
|
||||
$name = $this->getRequestParameter("name");
|
||||
$id = $this->getRequestParameter("id");
|
||||
|
||||
$category = CategoryPeer::retrieveByPK($id);
|
||||
|
||||
if ($category)
|
||||
{
|
||||
$category->setCulture(stLanguage::getHydrateCulture());
|
||||
|
||||
$category->setName($name);
|
||||
|
||||
$category->save();
|
||||
|
||||
return $this->renderJSON(array('id' => $category->getId(), 'name' => $name));
|
||||
}
|
||||
|
||||
return sfView::HEADER_ONLY;
|
||||
}
|
||||
|
||||
public function executeAjaxMove()
|
||||
{
|
||||
stAuthUsersListener::checkModificationCredentials($this, $this->getRequest(), 'stCategory', false);
|
||||
|
||||
$category_id = $this->getRequestParameter('id');
|
||||
|
||||
$sibling_id = $this->getRequestParameter('sibling_id');
|
||||
|
||||
$parent_id = $this->getRequestParameter('parent_id');
|
||||
|
||||
$category = CategoryPeer::retrieveByPK($category_id);
|
||||
|
||||
if ($category)
|
||||
{
|
||||
if ($sibling_id)
|
||||
{
|
||||
$category->moveToPrevSiblingOf(CategoryPeer::retrieveByPK($sibling_id));
|
||||
}
|
||||
else
|
||||
{
|
||||
$category->moveToLastChildOf(CategoryPeer::retrieveByPK($parent_id));
|
||||
}
|
||||
|
||||
$category->save();
|
||||
|
||||
ProductHasCategoryPeer::cleanCache();
|
||||
}
|
||||
|
||||
return sfView::HEADER_ONLY;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Usuwa całe drzewo lub gałąź kategorii
|
||||
*/
|
||||
public function executeDelete()
|
||||
{
|
||||
stAuthUsersListener::checkModificationCredentials($this, $this->getRequest(), 'stCategory', false);
|
||||
|
||||
$category = CategoryPeer::retrieveByPK($this->getRequestParameter("id"));
|
||||
|
||||
|
||||
if ($category)
|
||||
{
|
||||
if (stConfig::getInstance('stCategory')->get('check_for_product_before_delete') && $category->hasProducts())
|
||||
{
|
||||
$i18n = $this->getContext()->getI18N();
|
||||
$this->setFlash('warning', $i18n->__('Drzewo nie może być usuniętę dopóki ma przypisane produkty', null, 'stCategory'));
|
||||
return $this->redirect($this->getRequest()->getReferer());
|
||||
}
|
||||
|
||||
$category->delete();
|
||||
}
|
||||
|
||||
$this->redirect('category/manager');
|
||||
}
|
||||
|
||||
/**
|
||||
* Wiąże produkt z wybranymi kategoriami
|
||||
*/
|
||||
public function executeAddToManager()
|
||||
{
|
||||
$this->product_id = $this->getRequestParameter('product_id');
|
||||
|
||||
if ($this->getRequest()->getMethod() == sfRequest::POST)
|
||||
{
|
||||
|
||||
$categories = $this->getRequestParameter('category');
|
||||
|
||||
CategoryPeer::addProduct($this->product_id, $categories);
|
||||
}
|
||||
}
|
||||
|
||||
public function validateAddTree()
|
||||
{
|
||||
$ok = true;
|
||||
|
||||
if ($this->getRequest()->getMethod() == sfRequest::POST)
|
||||
{
|
||||
$name = $this->getRequestParameter('category_tree_name');
|
||||
|
||||
if (empty($name))
|
||||
{
|
||||
$this->getRequest()->setError('category_tree_name', 'Musisz podać nazwę drzewa');
|
||||
|
||||
$ok = false;
|
||||
}
|
||||
elseif (CategoryPeer::checkByName($name))
|
||||
{
|
||||
$this->getRequest()->setError('category_tree_name', 'Nazwa już istnieje');
|
||||
|
||||
$ok = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$ok = false;
|
||||
}
|
||||
|
||||
return $ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* Informuje o błędzie dodania drzewa kategorii
|
||||
*/
|
||||
public function handleErrorAddTree()
|
||||
{
|
||||
return $this->forward('stCategory', 'manager');
|
||||
}
|
||||
|
||||
/**
|
||||
* Dodaje zdjęcie do produktu
|
||||
*
|
||||
* @param Product $product Produkt
|
||||
*/
|
||||
protected function saveCategoryImage($category)
|
||||
{
|
||||
$category_images = $this->getRequestParameter('category_images');
|
||||
$plupload = stJQueryToolsHelper::parsePluploadFromRequest($category_images);
|
||||
|
||||
if ($plupload['delete'])
|
||||
{
|
||||
$category->destroyAsset();
|
||||
}
|
||||
|
||||
if ($plupload['modified'])
|
||||
{
|
||||
foreach ($plupload['modified'] as $filename)
|
||||
{
|
||||
$ext = sfAssetsLibraryTools::getFileExtension($filename);
|
||||
$category->createAsset($category->getId() . '.' . $ext, $plupload['dir'].'/'.$filename);
|
||||
$category->save();
|
||||
}
|
||||
}
|
||||
|
||||
stJQueryToolsHelper::pluploadCleanup($plupload);
|
||||
}
|
||||
|
||||
protected function processDelete($id)
|
||||
{
|
||||
$category = CategoryPeer::retrieveByPK($id);
|
||||
|
||||
if (stConfig::getInstance('stCategory')->get('check_for_product_before_delete') && $category->hasProducts())
|
||||
{
|
||||
$i18n = $this->getContext()->getI18N();
|
||||
$this->setFlash('warning', $i18n->__('Kategoria nie może być usunięta dopóki ma przypisane produkty', null, 'stCategory'));
|
||||
return $this->redirect($this->getRequest()->getReferer());
|
||||
}
|
||||
|
||||
return parent::processDelete($id);
|
||||
}
|
||||
|
||||
protected function saveCategory($category)
|
||||
{
|
||||
$v = strip_tags($category->getName());
|
||||
|
||||
$category->setName($v);
|
||||
|
||||
parent::saveCategory($category);
|
||||
|
||||
$this->saveCategoryImage($category);
|
||||
}
|
||||
|
||||
protected function saveConfig()
|
||||
{
|
||||
|
||||
parent::saveConfig();
|
||||
|
||||
appCategoryHorizontalListener::clearCache();
|
||||
|
||||
$fc = new stFunctionCache('stCategoryTree');
|
||||
|
||||
$fc->removeAll();
|
||||
|
||||
stTheme::clearSmartyCache(true);
|
||||
|
||||
stFastCacheManager::clearCache();
|
||||
|
||||
}
|
||||
|
||||
protected function treeMoveUp(Category $node, $by = 1)
|
||||
{
|
||||
stAuthUsersListener::checkModificationCredentials($this, $this->getRequest(), 'stCategory', false);
|
||||
|
||||
$position = $node->getRootPosition();
|
||||
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(CategoryPeer::ROOT_POSITION, $position - $by);
|
||||
|
||||
$prev = CategoryPeer::doSelectOne($c);
|
||||
|
||||
if ($prev)
|
||||
{
|
||||
$node->setRootPosition($prev->getRootPosition());
|
||||
|
||||
$prev->setRootPosition($position);
|
||||
|
||||
$node->save();
|
||||
|
||||
$prev->save();
|
||||
}
|
||||
}
|
||||
|
||||
protected function treeMoveDown(Category $node, $by = 1)
|
||||
{
|
||||
stAuthUsersListener::checkModificationCredentials($this, $this->getRequest(), 'stCategory', false);
|
||||
|
||||
$position = $node->getRootPosition();
|
||||
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(CategoryPeer::ROOT_POSITION, $position + $by);
|
||||
|
||||
$next = CategoryPeer::doSelectOne($c);
|
||||
|
||||
if ($next)
|
||||
{
|
||||
$node->setRootPosition($next->getRootPosition());
|
||||
|
||||
$next->setRootPosition($position);
|
||||
|
||||
$node->save();
|
||||
|
||||
$next->save();
|
||||
}
|
||||
}
|
||||
|
||||
protected function getAjaxTreeChildren(Category $parent, $path = array())
|
||||
{
|
||||
$html_data = '';
|
||||
|
||||
foreach ($parent->getChildren() as $child)
|
||||
{
|
||||
$id = $child->getId();
|
||||
|
||||
$assigned = isset($this->assigned[$id]);
|
||||
|
||||
$content = '';
|
||||
|
||||
if (!$this->allow_assign_leaf_only || $child->isLeaf())
|
||||
{
|
||||
if (1 == $this->limit)
|
||||
{
|
||||
$content = stJQueryToolsHelper::getJsTreeHtmlSingleAssignedControl('jstree_category', $id, $assigned, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
$content = stJQueryToolsHelper::getJsTreeHtmlAssignedControl('jstree_category', $id, $assigned, false);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->show_default)
|
||||
{
|
||||
$content .= stJQueryToolsHelper::getJsTreeHtmlDefaultControl('jstree_category', $id, $this->default == $id, !$assigned);
|
||||
}
|
||||
|
||||
if (isset($path[$id]))
|
||||
{
|
||||
$params = array(
|
||||
'status' => 'open',
|
||||
'content' => $content,
|
||||
'children' => $this->getAjaxTreeChildren($child, $path, $this->assigned),
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$params = array(
|
||||
'status' => $child->hasChildren() ? 'closed' : 'leaf',
|
||||
'content' => $content,
|
||||
);
|
||||
}
|
||||
|
||||
$params['scope'] = $this->tree_id;
|
||||
|
||||
$html_data .= stJQueryToolsHelper::getJsTreeHtmlRow($child->getId(), htmlspecialchars(strtr($child->getOptName(), array("\n" => "", "\r" => "")), ENT_QUOTES), $params);
|
||||
}
|
||||
|
||||
return $html_data;
|
||||
}
|
||||
|
||||
public function executeProductAddGroup()
|
||||
{
|
||||
stAuthUsersListener::checkModificationCredentials($this, $this->getRequest(), $this->getModuleName());
|
||||
|
||||
$ids = $this->getRequestParameter('product[selected]', array($this->getRequestParameter('id')));
|
||||
$related_id = $this->getRequestParameter('forward_parameters[category_id]');
|
||||
$forward_parameters = $this->getUser()->getAttributeHolder()->getAll('sf_admin/autoStCategory/product_forward_parameters');
|
||||
|
||||
$langages = LanguagePeer::doSelectActive(new Criteria());
|
||||
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->add(ProductHasCategoryPeer::CATEGORY_ID, $related_id);
|
||||
$c->add(ProductHasCategoryPeer::PRODUCT_ID, $id);
|
||||
|
||||
if (!ProductHasCategoryPeer::doCount($c))
|
||||
{
|
||||
$product_has_category = new ProductHasCategory();
|
||||
$product_has_category->setCategoryId($related_id);
|
||||
$product_has_category->setProductId($id);
|
||||
$product_has_category->save();
|
||||
$product = $product_has_category->getProduct();
|
||||
foreach ($langages as $lang)
|
||||
{
|
||||
$product->setCulture($lang->getOriginalLanguage());
|
||||
stNewSearch::buildIndex($product, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->redirect('stCategory/productList?page='.$this->getRequestParameter('page', 1).'&category_id='.$forward_parameters['category_id']);
|
||||
}
|
||||
|
||||
|
||||
public function executeProductRemoveGroup()
|
||||
{
|
||||
stAuthUsersListener::checkModificationCredentials($this, $this->getRequest(), $this->getModuleName());
|
||||
|
||||
$ids = $this->getRequestParameter('product[selected]', array($this->getRequestParameter('id')));
|
||||
$related_id = $this->getRequestParameter('forward_parameters[category_id]');
|
||||
$forward_parameters = $this->getUser()->getAttributeHolder()->getAll('sf_admin/autoStCategory/product_forward_parameters');
|
||||
|
||||
$c = new Criteria();
|
||||
$c->add(ProductHasCategoryPeer::CATEGORY_ID, $related_id);
|
||||
$c->add(ProductHasCategoryPeer::PRODUCT_ID, array_values($ids), Criteria::IN);
|
||||
|
||||
$langages = LanguagePeer::doSelectActive(new Criteria());
|
||||
|
||||
foreach (ProductHasCategoryPeer::doSelectJoinProduct($c) as $product_has_category)
|
||||
{
|
||||
$product = $product_has_category->getProduct();
|
||||
$product_has_category->delete();
|
||||
foreach ($langages as $lang)
|
||||
{
|
||||
$product->setCulture($lang->getOriginalLanguage());
|
||||
stNewSearch::buildIndex($product, true);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->redirect('stCategory/productList?page='.$this->getRequestParameter('page', 1).'&category_id='.$forward_parameters['category_id']);
|
||||
}
|
||||
|
||||
public function addProductFiltersCriteria($c){
|
||||
|
||||
parent::addProductFiltersCriteria($c);
|
||||
|
||||
if (isset($this->filters['list_image']) && $this->filters['list_image'] !== ''){
|
||||
$c->add(ProductPeer::OPT_IMAGE, null, $this->filters['list_image'] ? Criteria::ISNOTNULL : Criteria::ISNULL);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
80
apps/backend/modules/stCategory/actions/components.class.php
Normal file
80
apps/backend/modules/stCategory/actions/components.class.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SOTESHOP/stCategory
|
||||
*
|
||||
* Ten plik należy do aplikacji stCategory opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stCategory
|
||||
* @subpackage actions
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
|
||||
* @version $Id: components.class.php 318 2009-09-07 12:39:29Z michal $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Komponenty aplikacji stCategory
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
*
|
||||
* @package stCategory
|
||||
* @subpackage actions
|
||||
*/
|
||||
class stCategoryComponents extends autoStCategoryComponents
|
||||
{
|
||||
/**
|
||||
* Wyświetla komponent umożliwiający dodanie dowolnego modelu do kategorii
|
||||
*/
|
||||
public function executeAddToManager()
|
||||
{
|
||||
$this->iterators = stNestedIterator::retrieveTree();
|
||||
}
|
||||
|
||||
public function executeTree()
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(CategoryPeer::RGT, 2, Criteria::GREATER_THAN);
|
||||
|
||||
$c->addAscendingOrderByColumn(CategoryPeer::ROOT_POSITION);
|
||||
|
||||
$this->roots = CategoryPeer::doSelectRootsWithI18n($c);
|
||||
|
||||
if (!isset($this->selected))
|
||||
{
|
||||
$this->selected = $this->getUser()->getAttribute('category_filter', null, 'soteshop/stProduct');
|
||||
}
|
||||
|
||||
$this->expanded = CategoryPeer::doSelectExpanded($this->selected);
|
||||
|
||||
if (!isset($this->url))
|
||||
{
|
||||
$this->url = $this->getController()->genUrl('@stProductDefault');
|
||||
}
|
||||
}
|
||||
|
||||
public function executeTreeBreadcrumbs()
|
||||
{
|
||||
if (!$this->selected)
|
||||
{
|
||||
return sfView::NONE;
|
||||
}
|
||||
|
||||
$this->breadcrumbs = CategoryPeer::doSelectExpanded($this->selected) ;
|
||||
|
||||
if (!$this->breadcrumbs)
|
||||
{
|
||||
return sfView::NONE;
|
||||
}
|
||||
|
||||
if (!isset($this->url))
|
||||
{
|
||||
$this->url = $this->getController()->genUrl('@stProductDefault');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
29
apps/backend/modules/stCategory/config/config.php
Normal file
29
apps/backend/modules/stCategory/config/config.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stCategory
|
||||
*
|
||||
* Ten plik należy do aplikacji stCategory opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stCategory
|
||||
* @subpackage configs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
|
||||
* @version $Id: config.php 318 2009-09-07 12:39:29Z michal $
|
||||
*/
|
||||
|
||||
stPluginHelper::addRouting('stCategory', '/category/:action/*', 'stCategory', 'index', 'backend');
|
||||
|
||||
stPluginHelper::addRouting('stCategoryAction', '/category/:action', 'stCategory', 'index', 'backend');
|
||||
|
||||
|
||||
// pobieramy instancję obiektu sfEventDispatcher
|
||||
$dispatcher = stEventDispatcher::getInstance();
|
||||
|
||||
// dodajemy sluchacza dla zdarzenia generator.generate
|
||||
$dispatcher->connect('stAdminGenerator.generateStProduct', array('stCategoryInProductImportExportListener', 'generate'));
|
||||
|
||||
stPluginHelper::addRouting('stCategory', '/category/:action/*', 'stCategory', 'manager', 'backend');
|
||||
?>
|
||||
131
apps/backend/modules/stCategory/config/generator.yml
Normal file
131
apps/backend/modules/stCategory/config/generator.yml
Normal file
@@ -0,0 +1,131 @@
|
||||
generator:
|
||||
class: stAdminGenerator
|
||||
param:
|
||||
model_class: Category
|
||||
product_model_class: Product
|
||||
theme: simple
|
||||
custom_actions:
|
||||
list: [product]
|
||||
head:
|
||||
package: stCategory
|
||||
|
||||
documentation:
|
||||
pl: "https://www.sote.pl/docs/kategorie"
|
||||
en: "https://www.soteshop.com/docs/categories"
|
||||
|
||||
list:
|
||||
menu:
|
||||
display: [manager]
|
||||
fields:
|
||||
manager: {name: Menedżer kategorii, action: "@stCategory?action=manager"}
|
||||
config: {name: Konfiguracja, action: "@stCategory?action=config"}
|
||||
edit:
|
||||
title: Edycja podstawowa
|
||||
menu:
|
||||
display: [product]
|
||||
fields:
|
||||
product: {name: Przypisz produkty, action: "@stCategory?action=productList&category_id=%%id%%"}
|
||||
display:
|
||||
"NONE": [_is_active, is_hidden, _show_children_products, _main_page, name, _image, description]
|
||||
fields:
|
||||
is_active: {name: Aktywna, required: false}
|
||||
is_hidden: {name: Ukryj w drzewie kategorii, required: false}
|
||||
show_children_products: {name: Pokaż produkty z podkategorii, required: false}
|
||||
name: {name: Nazwa kategorii, params: disabled=false, required: true}
|
||||
description: {name: Opis, type: textarea_tag, params: size=90x20 rich=true tinymce_options='height:400,width:600' disabled=false}
|
||||
image: {name: Załącz/Zmień zdjęcie}
|
||||
main_page: {name: Pokaż na stronie głównej}
|
||||
actions:
|
||||
_list: {name: Menedżer kategorii, action: @stCategory?action=manager&category_id=%%id%%, i18n: stCategory}
|
||||
_save: {name: Zapisz}
|
||||
|
||||
product_list:
|
||||
use_stylesheet: [backend/stProductList.css]
|
||||
use_helper: [stProduct/stProduct]
|
||||
forward_parameters: [category_id]
|
||||
title: Przypisz produkty
|
||||
filters:
|
||||
list_image: {partial: filter_list_image, module: stProduct}
|
||||
display: [list_image, opt_name, code, opt_price_brutto, active, list_stock]
|
||||
fields:
|
||||
code: {name: Kod, width: 1%}
|
||||
opt_name: {name: Nazwa, params: truncate_text=true}
|
||||
list_image: {name: Zdjęcie, width: 1%, callback: list_product_image}
|
||||
opt_price_brutto: {name: Cena, width: 1%, callback: list_product_price, label_callback: list_product_price_label}
|
||||
active: {name: Aktywny, width: 1%, align: center}
|
||||
list_stock: {name: Magazyn, align: right, width: 1%, i18n: stDepositoryBackend, callback: list_stock, sort_field: product.stock}
|
||||
build_options:
|
||||
related_id: forward_parameters.category_id
|
||||
through_class: ProductHasCategory
|
||||
select_actions:
|
||||
actions:
|
||||
_add_group: {name: Dodaj do kategorii}
|
||||
_remove_group: {name: Usuń z kategorii}
|
||||
menu: {use: edit.menu}
|
||||
object_actions: []
|
||||
actions: []
|
||||
|
||||
config:
|
||||
old_config:
|
||||
"Drzewo kategorii": true
|
||||
"Konfiguracja wyświetlania poziomych kategorii": true
|
||||
description: Zarządzanie kategoriami w sklepie.
|
||||
title: Konfiguracja
|
||||
display:
|
||||
"NONE": [show_children_products, hide_categories_without_products, show_image_category_description]
|
||||
"Drzewo kategorii": [tree_type, hide_root, expand_root, expand_always, show_product_count]
|
||||
"Podkategorie": [show_subcategories, cut_subcategories_name, cut_subcategories_name_num]
|
||||
"Kategorie na stronie głównej": [category_main_menu_all_depths, show_category_main_menu, subcategory_main_menu_num, cut_tree_cat_name, cut_tree_cat_name_num, cut_tree_subcat_name, cut_tree_subcat_name_num, show_category_main_menu_desc_mobile, show_category_main_menu_desc, cut_main_description, cut_main_description_num, show_category_main_menu_btn_mobile, show_category_main_menu_btn]
|
||||
"Konfiguracja wyświetlania poziomych kategorii": [menu_on, _cathor_tree, image_on, description_on]
|
||||
fields:
|
||||
hide_categories_without_products: {name: Ukrywaj kategorie bez produktów, type: checkbox}
|
||||
show_children_products: {name: Pokaż produkty z podkategorii, type: checkbox}
|
||||
show_image_category_description: {name: Pokaż zdjęcie przy opisie kategorii, type: checkbox}
|
||||
show_subcategories: {name: Pokaż podkategorie po kliknięciu w kategorię, type: checkbox}
|
||||
show_category_main_menu: {name: Pokaż menu kategorii na stronie głównej, type: checkbox}
|
||||
category_main_menu_all_depths: {name: Zezwalaj na pokazywanie kategorii ze wszystkich poziomów, type: checkbox}
|
||||
main_page: {name: Strona główna}
|
||||
image: {name: Zdjęcie}
|
||||
hide_root: {name: Ukryj nazwę drzew kategorii, type: checkbox}
|
||||
show_product_count: {name: Pokaż ilość produktów w kategorii, type: checkbox}
|
||||
expand_always: {name: Zawsze rozwinięte, type: checkbox, help: Niezależnie od wybranej kategorii drzewo zawsze jest rozwinięte do wybranego poziomu w "Prezentacja drzewa kategorii"}
|
||||
tree_type:
|
||||
name: Rodzaj drzewa
|
||||
type: select
|
||||
display: [default, ajax]
|
||||
options:
|
||||
default: {name: Domyślne, value: default}
|
||||
ajax: {name: Dynamiczne (zalecane przy dużej liczbie kategorii), value: ajaxTree}
|
||||
expand_root:
|
||||
name: Prezentacja drzewa kategorii
|
||||
type: select
|
||||
display: [never, level_1, level_2, level_3, level_4, level_5, always]
|
||||
options:
|
||||
never: {name: Zwinięte, value: -1}
|
||||
level_1: {name: Rozwinięte do 1 poziomu, value: 0}
|
||||
level_2: {name: Rozwinięte do 2 poziomu, value: 1}
|
||||
level_3: {name: Rozwinięte do 3 poziomu, value: 2}
|
||||
level_4: {name: Rozwinięte do 4 poziomu, value: 3}
|
||||
level_5: {name: Rozwinięte do 5 poziomu, value: 4}
|
||||
always: {name: Rozwinięte bez ograniczeń, value: 10000}
|
||||
subcategory_main_menu_num: {name: Ilość wyświetlanych podkategorii, params: size=2}
|
||||
cut_subcategories_name: {name: Skracaj nazwę podkategorii, type: checkbox, old_config: true}
|
||||
cut_subcategories_name_num: {name: Ile znaków skracać nazwę podkategorii, params: size=2, old_config: true}
|
||||
cut_tree_cat_name: {name: Skracaj nazwę kategorii, type: checkbox}
|
||||
cut_tree_cat_name_num: {name: Ile znaków skracać nazwę kategorii, params: size=2}
|
||||
cut_tree_subcat_name: {name: Skracaj nazwę podkategorii, type: checkbox}
|
||||
cut_tree_subcat_name_num: {name: Ile znaków skracać nazwę podkategorii, params: size=2}
|
||||
show_category_main_menu_btn_mobile: {name: Pokaż przycisk (mobile), type: checkbox}
|
||||
show_category_main_menu_btn: {name: Pokaż przycisk (desktop), type: checkbox}
|
||||
show_category_main_menu_desc_mobile: {name: Pokaż opis kategorii (mobile), type: checkbox}
|
||||
show_category_main_menu_desc: {name: Pokaż opis kategorii (desktop), type: checkbox}
|
||||
cut_main_description: {name: Skracaj opis kategorii, type: checkbox}
|
||||
cut_main_description_num: {name: Ile znaków skracać opis kategorii, params: size=3}
|
||||
menu_on: {name: Włącz poziome kategorie, type: checkbox}
|
||||
cathor_tree: {name: Drzewo kategorii, hide_label: true}
|
||||
image_on: {name: Pokaż obrazek kategorii, type: checkbox}
|
||||
description_on: {name: Pokaż opis kategorii, type: checkbox}
|
||||
|
||||
actions:
|
||||
_list: {name: Menedżer kategorii, action: manager, i18n: stCategory}
|
||||
_save: {name: Zapisz}
|
||||
@@ -0,0 +1,8 @@
|
||||
export:
|
||||
fields:
|
||||
product_categories: {name: Kategorie, class: CategoryPeer, md5hash: true }
|
||||
|
||||
import:
|
||||
fields:
|
||||
product_categories: {class: CategoryPeer, md5hash: true }
|
||||
|
||||
2
apps/backend/modules/stCategory/config/security.yml
Normal file
2
apps/backend/modules/stCategory/config/security.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
soap:
|
||||
is_secure: off
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
class stCategoryBreadcrumbsBuilder extends autoStCategoryBreadcrumbsBuilder
|
||||
{
|
||||
}
|
||||
290
apps/backend/modules/stCategory/lib/stModuleWebApi.class.php
Normal file
290
apps/backend/modules/stCategory/lib/stModuleWebApi.class.php
Normal file
@@ -0,0 +1,290 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stWebApiPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stWebApiPlugin opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stWebApiPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
|
||||
* @version $Id: stModuleWebApi.class.php 16947 2012-02-01 14:10:42Z piotr $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Komponenty aplikacji stCategory
|
||||
*
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
*
|
||||
* @package stWebApiPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stCategoryWebApi extends autoStCategoryWebApi
|
||||
{
|
||||
public static function getLink(Category $category, StCategoryWebApi $api)
|
||||
{
|
||||
return $api->__getCategoryUrl($category);
|
||||
}
|
||||
|
||||
public function AddCategory($object)
|
||||
{
|
||||
if (isset($object->_culture))
|
||||
$this->__setCulture($object->_culture);
|
||||
|
||||
stWebApi::getLogin($object->_session_hash, 'webapi_write');
|
||||
$this->TestAndValidateAddCategoryFields($object);
|
||||
|
||||
if (!$object->parent_id)
|
||||
{
|
||||
$item = new Category();
|
||||
$item->setCulture(stLanguage::getHydrateCulture());
|
||||
|
||||
$item->makeRoot();
|
||||
$item->setName($object->name);
|
||||
$item->save();
|
||||
|
||||
$item->setScope($item->getId());
|
||||
$item->save();
|
||||
}
|
||||
else
|
||||
{
|
||||
$parent = CategoryPeer::retrieveByPK($object->parent_id);
|
||||
|
||||
if (!is_object($parent))
|
||||
throw new SoapFault('2', sprintf($this->__(WEBAPI_ADD_ERROR), $this->__('niepoprawny parametr parent_id')));
|
||||
|
||||
$parent->setCulture(stLanguage::getHydrateCulture());
|
||||
|
||||
$item = new Category();
|
||||
$item->setCulture(stLanguage::getHydrateCulture());
|
||||
$item->setName($object->name);
|
||||
$item->insertAsLastChildOf($parent);
|
||||
$item->save();
|
||||
}
|
||||
|
||||
if ($item)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (isset($object->main_page))
|
||||
$item->setMainPage($object->main_page);
|
||||
|
||||
if (isset($object->description))
|
||||
$item->setDescription($object->description);
|
||||
|
||||
if (isset($object->is_active))
|
||||
$item->setIsActive($object->is_active);
|
||||
|
||||
if (isset($object->is_hidden))
|
||||
$item->setIsHidden($object->is_hidden);
|
||||
|
||||
if (isset($object->show_children_products))
|
||||
$item->setShowChildrenProducts($object->show_children_products);
|
||||
|
||||
$item->save();
|
||||
|
||||
if (isset($object->image) && isset($object->image_filename))
|
||||
$this->setCategoryImage($item, $object->image_filename, $object->image);
|
||||
|
||||
if (isset($object->url))
|
||||
{
|
||||
$item->setUrl($object->url);
|
||||
$item->save();
|
||||
}
|
||||
} catch (Exception $e)
|
||||
{
|
||||
throw new SoapFault('2', $this->__(WEBAPI_ADD_ERROR));
|
||||
}
|
||||
|
||||
ProductHasCategoryPeer::cleanCache();
|
||||
|
||||
$object = new StdClass();
|
||||
$this->getFieldsForAddCategory($object, $item);
|
||||
ProductHasCategoryPeer::cleanCache();
|
||||
return $object;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new SoapFault('1', $this->__(WEBAPI_ADD_ERROR));
|
||||
}
|
||||
}
|
||||
|
||||
public function setCategoryImage($item, $filename, $image)
|
||||
{
|
||||
$tmpFile = sfConfig::get('sf_cache_dir') . '/webapi_category.tmp';
|
||||
|
||||
if (is_object($item->getSfAsset()))
|
||||
{
|
||||
$item->getSfAsset()->delete();
|
||||
$item->setSfAsset(null);
|
||||
}
|
||||
|
||||
file_put_contents($tmpFile, base64_decode($image));
|
||||
$item->createAsset($item->getId() . '.' . pathinfo($filename, PATHINFO_EXTENSION), $tmpFile);
|
||||
$item->save();
|
||||
}
|
||||
|
||||
public function UpdateCategory($object)
|
||||
{
|
||||
if (isset($object->_culture))
|
||||
$this->__setCulture($object->_culture);
|
||||
|
||||
stWebApi::getLogin($object->_session_hash, 'webapi_write');
|
||||
$this->TestAndValidateUpdateCategoryFields($object);
|
||||
|
||||
$item = CategoryPeer::retrieveByPk($object->id);
|
||||
if ($item)
|
||||
{
|
||||
try
|
||||
{
|
||||
$item->setCulture(sfContext::getInstance()->getUser()->getCulture());
|
||||
|
||||
if (isset($object->name))
|
||||
$item->setName($object->name);
|
||||
|
||||
if (isset($object->main_page))
|
||||
$item->setMainPage($object->main_page);
|
||||
|
||||
if (isset($object->description))
|
||||
$item->setDescription($object->description);
|
||||
|
||||
if (isset($object->is_active))
|
||||
$item->setIsActive($object->is_active);
|
||||
|
||||
if (isset($object->is_hidden))
|
||||
$item->setIsHidden($object->is_hidden);
|
||||
|
||||
if (isset($object->show_children_products))
|
||||
$item->setShowChildrenProducts($object->show_children_products);
|
||||
|
||||
if (isset($object->url))
|
||||
$item->setUrl($object->url);
|
||||
|
||||
$item->save();
|
||||
|
||||
if (isset($object->image) && isset($object->image_filename))
|
||||
$this->setCategoryImage($item, $object->image_filename, $object->image);
|
||||
|
||||
} catch (Exception $e)
|
||||
{
|
||||
throw new SoapFault('2', sprintf($this->__(WEBAPI_UPDATE_ERROR), $e->getMessage()));
|
||||
}
|
||||
|
||||
ProductHasCategoryPeer::cleanCache();
|
||||
|
||||
$object = new StdClass();
|
||||
$object->_update = 1;
|
||||
return $object;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new SoapFault('1', $this->__(WEBAPI_INCORRECT_ID));
|
||||
}
|
||||
}
|
||||
|
||||
public function getFieldsForGetCategory($object, $item)
|
||||
{
|
||||
parent::getFieldsForGetCategory($object, $item);
|
||||
$this->addCustomFields($object, $item);
|
||||
}
|
||||
|
||||
public function getFieldsForGetCategoryList($object, $item)
|
||||
{
|
||||
parent::getFieldsForGetCategoryList($object, $item);
|
||||
$this->addCustomFields($object, $item);
|
||||
}
|
||||
|
||||
public function getFieldsForGetCategoryChildrens($object, $item)
|
||||
{
|
||||
parent::getFieldsForGetCategoryChildrens($object, $item);
|
||||
$this->addCustomFields($object, $item);
|
||||
}
|
||||
|
||||
public function getGetCategoryChildrensCriteria($object)
|
||||
{
|
||||
$c = parent::getGetCategoryChildrensCriteria($object);
|
||||
|
||||
if ($object->parent_id != 0) {
|
||||
$c->add(CategoryPeer::PARENT_ID, $object->parent_id);
|
||||
} else {
|
||||
$c->add(CategoryPeer::PARENT_ID, null, Criteria::ISNULL);
|
||||
}
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
public function getGetProductCategoryListCriteria($object)
|
||||
{
|
||||
$c = parent::getGetProductCategoryListCriteria($object);
|
||||
$c->add(ProductHasCategoryPeer::PRODUCT_ID, $object->id);
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
public function getGetCategoryListCriteria($object)
|
||||
{
|
||||
$c = parent::getGetCategoryListCriteria($object);
|
||||
|
||||
if (isset($object->parent_id))
|
||||
{
|
||||
$c->add(CategoryPeer::PARENT_ID, $object->parent_id);
|
||||
}
|
||||
|
||||
if (isset($object->product_id))
|
||||
{
|
||||
$c->addJoin(ProductHasCategoryPeer::CATEGORY_ID, CategoryPeer::ID);
|
||||
$c->add(ProductHasCategoryPeer::PRODUCT_ID, $object->product_id);
|
||||
}
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
public function getProductCategoryList($object)
|
||||
{
|
||||
if (isset($object->_culture))
|
||||
{
|
||||
$this->__setCulture($object->_culture);
|
||||
}
|
||||
stWebApi::getLogin($object->_session_hash, 'webapi_read');
|
||||
$this->TestAndValidategetProductCategoryListFields($object);
|
||||
$c = $this->getGetProductCategoryListCriteria($object);
|
||||
|
||||
if (!isset($object->_limit))
|
||||
$object->_limit = 20;
|
||||
|
||||
// ustawiamy kryteria wyboru
|
||||
$c->setLimit($object->_limit);
|
||||
$c->setOffset($object->_offset);
|
||||
|
||||
$items = ProductHasCategoryPeer::doSelect($c);
|
||||
|
||||
if ($items)
|
||||
{
|
||||
// Zwracanie wyniku, dla wszystkich pol z tablicy 'out'
|
||||
$items_array = array();
|
||||
foreach ($items as $item)
|
||||
{
|
||||
$object = new StdClass();
|
||||
$this->getFieldsForgetProductCategoryList($object, $item);
|
||||
$items_array[] = $object;
|
||||
}
|
||||
return $items_array;
|
||||
}
|
||||
else
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
protected function addCustomFields($object, Category $category)
|
||||
{
|
||||
if (is_object($category->getSfAsset()))
|
||||
{
|
||||
$object->image_filename = basename($category->getSfAsset()->getPath());
|
||||
$object->image = base64_encode(file_get_contents(sfConfig::get('sf_web_dir') . '/' . $category->getSfAsset()->getPath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
17
apps/backend/modules/stCategory/templates/_addToManager.php
Normal file
17
apps/backend/modules/stCategory/templates/_addToManager.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php use_helper('stAdminGenerator') ?>
|
||||
<?php use_stylesheet('backend/stCategory.css') ?>
|
||||
<?php foreach ($iterators as $iterator): ?>
|
||||
<h3>
|
||||
<?php echo $iterator->getRoot()->getName() ?>
|
||||
</h3>
|
||||
<ul id="st_category_tree-list">
|
||||
<?php foreach ($iterator->getDescendants() as $descendat): ?>
|
||||
<li style="margin-left: <?php echo $descendat->getLevel()*20 ?>px">
|
||||
<?php echo checkbox_tag('category['.$descendat->getId().']', $descendat->getId(), $descendat->hasDatabaseRecord($object) || $sf_request->getParameter('category['.$descendat->getId().']')) ?>
|
||||
<?php echo label_for('category['.$descendat->getId().']', $descendat->getName()) ?>
|
||||
<br class="st_clear_all" />
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<br class="st_clear_all" />
|
||||
<?php endforeach; ?>
|
||||
12
apps/backend/modules/stCategory/templates/_categories.php
Normal file
12
apps/backend/modules/stCategory/templates/_categories.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<ul class="open">
|
||||
<?php foreach ($parent->getChildren('doSelectWithI18n') as $child): ?>
|
||||
|
||||
<li class="<?php echo isset($expanded[$child->getId()]) ? ' selected' : '' ?> children">
|
||||
<?php if ($child->hasChildren()): ?><span class="expandable<?php echo isset($expanded[$child->getId()]) ? ' open' : '' ?>" style="padding-left: <?php echo ($child->getDepth() - 1) * 9 ?>px"></span><?php else: ?><span class="leaf"></span><?php endif; ?><a href="<?php echo $url ?>?category_id=<?php echo $child->getId() ?>" data-id="<?php echo $child->getId() ?>" style="padding-left: <?php echo ($child->getDepth() - 1) * 10 + 27 ?>px"><?php echo $child->getName() ?></a>
|
||||
<?php if ($child->hasChildren() && isset($expanded[$child->getId()])): ?>
|
||||
<?php echo st_get_partial('stCategory/categories', array('parent' => $child, 'expanded' => $expanded, 'selected' => $selected, 'url' => $url)) ?>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
22
apps/backend/modules/stCategory/templates/_categoryRow.php
Normal file
22
apps/backend/modules/stCategory/templates/_categoryRow.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* Szablon pomocniczy prezentujący pojedynczy element kategorii
|
||||
*/
|
||||
?>
|
||||
<span class="st_category_tree-<?php echo $categoryTree->getLevel() > 1 ? 'child' : 'parent' ?>">
|
||||
<?php if (!$categoryTree->isRoot()): ?>
|
||||
<span class="st_category_tree-nest-number">
|
||||
<?php echo stNestedIterator::getDepthNumber($categoryTree) ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<span class="st_category_tree-name" id="category_<?php echo $categoryTree->getId() ?>">
|
||||
<?php echo $categoryTree->getName() ?>
|
||||
</span>
|
||||
</span>
|
||||
<?php st_include_partial('category_menu', array('categoryTree' => $categoryTree)) ?>
|
||||
<br style="clear: both" />
|
||||
<?php echo input_in_place_editor_tag('category_'.$categoryTree->getId(),'category/categoryEdit?id='.$categoryTree->getId(), array(
|
||||
'cols' => 20,
|
||||
'rows' => 1,
|
||||
'complete' => " { var options = \$A($('st_tree_list').options); options.each(function(option) { if (option.value == {$categoryTree->getId()}) option.text = $('category_{$categoryTree->getId()}').innerHTML; }); }",
|
||||
)) ?>
|
||||
26
apps/backend/modules/stCategory/templates/_category_menu.php
Normal file
26
apps/backend/modules/stCategory/templates/_category_menu.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php if (!$categoryTree->isRoot()): ?>
|
||||
<ul class="st_category_tree-menu">
|
||||
<li <?php echo get_tooltip('Awansuj kategorię') ?>>
|
||||
<?php echo link_to(image_tag('/images/backend/category_tree/arrows/arrow_left.png'), 'category/promote?id='.$categoryTree->getId()) ?>
|
||||
</li>
|
||||
<li <?php echo get_tooltip('Przesuń kategorię w górę') ?>>
|
||||
<?php echo link_to(image_tag('/images/backend/category_tree/arrows/arrow_up.png'), 'category/moveUp?id='.$categoryTree->getId()) ?>
|
||||
</li>
|
||||
<li <?php echo get_tooltip('Przesuń kategorię w dół') ?>>
|
||||
<?php echo link_to(image_tag('/images/backend/category_tree/arrows/arrow_down.png'), 'category/moveDown?id='.$categoryTree->getId()) ?>
|
||||
</li>
|
||||
<li <?php echo get_tooltip('Degraduj kategorię') ?>>
|
||||
<?php echo link_to(image_tag('/images/backend/category_tree/arrows/arrow_right.png'), 'category/degrade?id='.$categoryTree->getId()) ?>
|
||||
</li>
|
||||
<li <?php echo get_tooltip('Przejdź do edycji kategorii') ?>>
|
||||
<?php echo link_to(image_tag('backend/icons/edit.png'), 'category/edit?id='.$categoryTree->getId()) ?>
|
||||
</li>
|
||||
<li <?php echo get_tooltip('Usuń kategorię - usuwa daną kategorię wraz z jej podkategoriami') ?>>
|
||||
<?php echo link_to(image_tag('backend/icons/delete.png'), 'category/delete?id='.$categoryTree->getId()) ?>
|
||||
</li>
|
||||
</ul>
|
||||
<?php else: ?>
|
||||
<ul class="st_category_tree-menu">
|
||||
<li <?php echo get_tooltip('Usuń drzewo') ?>><?php echo link_to(image_tag('backend/icons/delete.png'), 'category/delete?id='.$categoryTree->getId()) ?></li>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,10 @@
|
||||
<div id="category_tree_name">
|
||||
<div>
|
||||
<?php echo input_tag($name, null) ?>
|
||||
</div>
|
||||
<div>
|
||||
<?php echo st_get_admin_actions(array(
|
||||
array("label" => __("Dodaj"), "type" => "create")
|
||||
)) ?>
|
||||
</div>
|
||||
</div>
|
||||
15
apps/backend/modules/stCategory/templates/_category_url.php
Normal file
15
apps/backend/modules/stCategory/templates/_category_url.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php $category = $category_has_positioning->getCategory();?>
|
||||
|
||||
<?php echo input_tag('category_has_positioning[category_url]', $category->getFriendlyUrl(), array('size' => '80')) ?>
|
||||
|
||||
<?php list($culture) = explode('_', $category->getCulture()); ?>
|
||||
|
||||
<p>
|
||||
<?php echo st_link_to(null, 'stProduct/frontendList?url=' . $category->getFriendlyUrl(), array(
|
||||
'absolute' => true,
|
||||
'for_app' => 'frontend',
|
||||
'for_lang' => $culture,
|
||||
'no_script_name' => true,
|
||||
'class' => 'st_admin_external_link',
|
||||
'target' => '_blank')) ?>
|
||||
</p>
|
||||
28
apps/backend/modules/stCategory/templates/_cathor_tree.php
Normal file
28
apps/backend/modules/stCategory/templates/_cathor_tree.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
$c = new Criteria();
|
||||
$c->add(CategoryPeer::PARENT_ID, NULL);
|
||||
$categories = CategoryPeer::doSelect($c);
|
||||
|
||||
if($categories)
|
||||
{
|
||||
foreach ($categories as $category)
|
||||
{
|
||||
$select[$category->getId()] = $category->getOptName();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$select = 0;
|
||||
}
|
||||
?>
|
||||
<label><?php echo __('Drzewo kategorii') ?></label>
|
||||
<div class="content">
|
||||
<?php if($select!=0): ?>
|
||||
<?php echo select_tag('config[cathor_tree]', options_for_select($select,
|
||||
array($config->get('cathor_tree'))
|
||||
)) ?>
|
||||
<?php else: ?>
|
||||
<?php echo __('Brak drzew kategorii'); ?>
|
||||
<?php endif; ?>
|
||||
<br class="st_clear_all">
|
||||
</div>
|
||||
@@ -0,0 +1 @@
|
||||
<?php use_javascript('backend/stCategory.js?version=1') ?>
|
||||
4
apps/backend/modules/stCategory/templates/_edit_url.php
Normal file
4
apps/backend/modules/stCategory/templates/_edit_url.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php echo input_tag('category[edit_url]', $category->getUrl(), array('disabled' => $category->getAutoGenerateUrl(), 'size' => '64')) ?>
|
||||
|
||||
<?php echo checkbox_tag('category[auto_generate_url]', true, $category->getAutoGenerateUrl(), array('onchange' => "$('category_edit_url').disabled = this.checked")) ?>
|
||||
<?php echo label_for('category_auto_generate_url', __('Generuj automatycznie'), array('style' => 'float: none; display: inline; padding: 0px')) ?>
|
||||
12
apps/backend/modules/stCategory/templates/_image.php
Normal file
12
apps/backend/modules/stCategory/templates/_image.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
use_helper('stCategoryImage', 'stJQueryTools');
|
||||
|
||||
$images = array();
|
||||
|
||||
if (!$category->isNew() && $category->getSfAsset())
|
||||
{
|
||||
$images[$category->getSfAssetId()] = st_category_image_path($category, 'full');
|
||||
}
|
||||
|
||||
echo plupload_images_tag('category_images', $images, array('crop' => 'category', 'limit' => 1));
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
<?php echo image_tag('/'.sfConfig::get('sf_upload_dir_name')."/photos/".$category->getImage())?>
|
||||
8
apps/backend/modules/stCategory/templates/_is_active.php
Normal file
8
apps/backend/modules/stCategory/templates/_is_active.php
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
<?php echo st_admin_checkbox_tag('category[is_active]', 1, $category->getIsActive(), array (
|
||||
'disabled' => $category->hasParent() && $category->getParent() && !$category->getParent()->getIsActive()
|
||||
)); ?>
|
||||
|
||||
<?php if ($category->hasParent() && $category->getParent() && !$category->getParent()->getIsActive()): ?>
|
||||
<a href="#" class="help" style="vertical-align: middle" title="<?php echo __('Nie możesz aktywować kategorii w przypadku, gdy kategoria narzędna jest nieaktywna') ?>"></a>
|
||||
<?php endif ?>
|
||||
1
apps/backend/modules/stCategory/templates/_lang.php
Normal file
1
apps/backend/modules/stCategory/templates/_lang.php
Normal file
@@ -0,0 +1 @@
|
||||
<?php st_include_component('stLanguageBackend', 'showLanguages')?>
|
||||
3
apps/backend/modules/stCategory/templates/_main_page.php
Normal file
3
apps/backend/modules/stCategory/templates/_main_page.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php echo st_admin_checkbox_tag('category[main_page]', 1, $category->getMainPage(), array (
|
||||
'disabled' => $category->isRoot(),
|
||||
)); ?>
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php echo st_admin_checkbox_tag('category[show_children_products]', 1, $category->getShowChildrenProducts(), array (
|
||||
'disabled' => stConfig::getInstance('stCategory')->get('show_children_products'),
|
||||
)); ?>
|
||||
40
apps/backend/modules/stCategory/templates/_tree.php
Normal file
40
apps/backend/modules/stCategory/templates/_tree.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<ul style="--menu-items: <?php echo count($roots) ?>">
|
||||
<li>
|
||||
<ul id="st_category_tree_filter" class="st_category_tree_filter">
|
||||
<?php foreach ($roots as $root): ?>
|
||||
<li class="category_tree">
|
||||
<div class="preloader cover" style="display: none; height: 100%; width: 100%"></div>
|
||||
<ul>
|
||||
<li>
|
||||
<span class="name-tree"><?php echo $root->getName() ?></span>
|
||||
<?php echo st_get_partial('stCategory/categories', array('parent' => $root, 'expanded' => $expanded, 'selected' => $selected, 'url' => $url)) ?>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
$('#st_category_tree_filter').on('click', '.expandable', function() {
|
||||
let image = $(this);
|
||||
let link = image.next();
|
||||
let preloader = link.closest('.category_tree').find('.preloader');
|
||||
|
||||
if (!link.next('ul').length) {
|
||||
preloader.show();
|
||||
$.post("<?php echo st_url_for('@stCategory?action=ajaxCategoryFilterChildren') ?>?id="+link.data('id'), { url: "<?php echo $url ?>" }, function(data) {
|
||||
link.after(data);
|
||||
image.addClass('open');
|
||||
link.next().addClass('open');
|
||||
preloader.hide();
|
||||
});
|
||||
} else {
|
||||
image.toggleClass('open');
|
||||
link.next().toggleClass('open');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,19 @@
|
||||
<ul class="category_breadcrumbs">
|
||||
<li><a href="<?php echo $url ?>?filters[category]="><?php echo __('Wszystkie') ?></a></li>
|
||||
<?php foreach ($breadcrumbs as $category): $id = $category->getId(); ?>
|
||||
<li>›</li>
|
||||
<?php if ($category->isRoot()): ?>
|
||||
<li>
|
||||
<?php echo $category->getName() ?>
|
||||
</li>
|
||||
<?php elseif ($category->getId() == $selected): ?>
|
||||
<li>
|
||||
<?php echo $category->getName() ?>
|
||||
</li>
|
||||
<?php else: ?>
|
||||
<li>
|
||||
<a href="<?php echo $url ?>?filters[category]=<?php echo $category->getId() ?>"><?php echo $category->getName() ?></a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
4
apps/backend/modules/stCategory/templates/addSuccess.php
Normal file
4
apps/backend/modules/stCategory/templates/addSuccess.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php use_helper('Javascript'); ?>
|
||||
<li style="margin-left: <?php echo $categoryTree->getLevel() * 20 ?>px">
|
||||
<?php st_include_partial('categoryRow', array('categoryTree' => $categoryTree)); ?>
|
||||
</li>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php use_helper('stAdminGenerator') ?>
|
||||
<?php echo st_get_admin_head('stCategory', 'Test dodawania produktu', '') ?>
|
||||
<?php st_include_component('stCategory', 'addToManager', array('product_id' => $product_id)) ?>
|
||||
<?php echo st_get_admin_foot() ?>
|
||||
@@ -0,0 +1,90 @@
|
||||
<div id="<?php echo $tree_id ?>" style="padding: 0px 10px 10px 0px">
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
|
||||
jQuery(function($) {
|
||||
$.getScript('/jQueryTools/jstree/js/jstree.min.js?v1', function() {
|
||||
var jstree = $("#<?php echo $tree_id ?>");
|
||||
var limit = <?php echo $limit ?>;
|
||||
jstree.jstree({
|
||||
themes: {
|
||||
url: "/jQueryTools/jstree/themes/default/style.css",
|
||||
theme: 'default'
|
||||
},
|
||||
html_data: {
|
||||
ajax: {
|
||||
url: function(node) {
|
||||
var id = node ? node.attr('id').replace('<?php echo $tree_id ?>-', '') : 0;
|
||||
return "<?php echo st_url_for('@stCategoryAction?action=ajaxCategoryChildren') ?>?id="+id+"&default=<?php echo $default ?>&tree_id=<?php echo $tree_id ?>";
|
||||
},
|
||||
data: { assigned: "<?php echo $sf_request->getParameter('assigned') ?>", show_default: <?php echo $show_default ?>, 'limit': <?php echo $limit ?> },
|
||||
type: 'POST'
|
||||
},
|
||||
data: '<?php echo $html_data ?>'
|
||||
},
|
||||
plugins: ["themes", "html_data"]
|
||||
});
|
||||
|
||||
jstree.data('assigned', <?php echo json_encode(explode(',', $sf_request->getParameter('assigned'))) ?>);
|
||||
jstree.change(function(event) {
|
||||
var target = $(event.target).filter('input.assigned');
|
||||
|
||||
if (target.length) {
|
||||
var id = event.target.value;
|
||||
|
||||
console.log("input_id: " + id);
|
||||
|
||||
var instance = $.jstree._reference(jstree);
|
||||
|
||||
var settings = instance.get_settings();
|
||||
|
||||
var added = jstree.data('added') ? jstree.data('added') : [];
|
||||
|
||||
var removed = jstree.data('removed') ? jstree.data('removed') : [];
|
||||
|
||||
var assigned = jstree.data('assigned');
|
||||
|
||||
var input = $(event.target).next('input');
|
||||
|
||||
input.attr('disabled', !event.target.checked);
|
||||
|
||||
if (event.target.checked) {
|
||||
if (1 == limit) {
|
||||
added = [id];
|
||||
} else if (added.indexOf(id) < 0 && assigned.indexOf(id) < 0) {
|
||||
added.push(id);
|
||||
}
|
||||
|
||||
var tmp = removed.indexOf(id);
|
||||
|
||||
if (tmp > -1) {
|
||||
removed.splice(tmp, 1);
|
||||
}
|
||||
} else {
|
||||
if (removed.indexOf(id) < 0) {
|
||||
removed.push(id);
|
||||
}
|
||||
|
||||
var tmp = added.indexOf(id);
|
||||
|
||||
if (tmp > -1) {
|
||||
added.splice(tmp, 1);
|
||||
}
|
||||
}
|
||||
console.log(added);
|
||||
|
||||
jstree.data('added', added);
|
||||
|
||||
jstree.data('removed', removed);
|
||||
|
||||
if (event.target.checked) {
|
||||
if (jstree.find('input.default-assigned:enabled:checked').length == 0) {
|
||||
input.attr('checked', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,7 @@
|
||||
<ul>
|
||||
<?php foreach ($roots as $root): ?>
|
||||
<li>
|
||||
<a href="#"><?php echo $root->getOptName() ?></a>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
204
apps/backend/modules/stCategory/templates/managerSuccess.php
Normal file
204
apps/backend/modules/stCategory/templates/managerSuccess.php
Normal file
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
use_helper("stAdminGenerator");
|
||||
use_stylesheet("backend/stCategory.css?v4");
|
||||
use_javascript("/jQueryTools/jstree/js/jstree.min.js?v1");
|
||||
?>
|
||||
|
||||
<?php st_include_partial("stCategory/header", array("title" => __("Menedżer kategorii"), 'favorite' => array('add_title' => false))) ?>
|
||||
<?php st_include_partial('stCategory/list_menu'); ?>
|
||||
<?php st_include_partial('stAdminGenerator/message'); ?>
|
||||
|
||||
<div>
|
||||
|
||||
<form id="category_tree_form" class="admin_form" action="<?php echo st_url_for("stCategory/addTree") ?>" method="post">
|
||||
<?php echo st_admin_section_start(); ?>
|
||||
<?php echo st_admin_get_form_field('category_tree_name', __("Nazwa drzewa"), $sf_request->getParameter("category_tree_name"), '_category_tree_name') ?>
|
||||
<?php echo st_admin_section_end() ?>
|
||||
</form>
|
||||
|
||||
<div id="category_tree_container">
|
||||
<?php foreach ($roots as $root): $id = $root["metadata"]["id"]; ?>
|
||||
<div class="category_tree">
|
||||
<div class="category_tree_actions">
|
||||
<a class="category_tree_action help" href="<?php echo st_url_for("@stCategory?action=delete&id=".$id) ?>" title="<?php echo __("Usuń drzewo", null, "stCategoryTree") ?>" data-admin-confirm="<?php echo __("Zamierzasz usunąć całe drzewo kategorii. Jesteś pewien, że chcesz kontynuować?", null, "stCategoryTree") ?>" data-admin-action="delete"><?php echo st_admin_get_icon('delete') ?></a>
|
||||
<a class="category_tree_action help" <?php echo $root["metadata"]["root-position"] <= 1 ? " disabled" : "" ?>" href="<?php echo st_url_for("@stCategory?action=setRootPosition&move=up&id=".$id) ?>" title="<?php echo __("Przenieś drzewo do góry", null, "stCategoryTree") ?>"><?php echo st_admin_get_icon('prev') ?></a>
|
||||
<a class="category_tree_action help" <?php echo $root["metadata"]["root-position"] >= $maxRootPosition ? " disabled" : "" ?>" href="<?php echo st_url_for("@stCategory?action=setRootPosition&move=down&id=".$id) ?>" title="<?php echo __("Przenieś drzewo w dół", null, "stCategoryTree") ?>"><?php echo st_admin_get_icon('next') ?></a>
|
||||
</div>
|
||||
<div id="category_tree_<?php echo $id ?>"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
jQuery(function($) {
|
||||
$("#category_tree_<?php echo $id ?>").jstree({
|
||||
"core": {
|
||||
"animation": 100
|
||||
},
|
||||
"plugins": ["themes", "json_data", "dnd", "ui", "crrm", "contextmenu"],
|
||||
"themes": {
|
||||
"url": "/jQueryTools/jstree/themes/default/style.css",
|
||||
"theme": "default"
|
||||
},
|
||||
"crrm": {
|
||||
"move": {
|
||||
"check_move": function(m) {
|
||||
if (("after" == m.p || "before" == m.p) && this._get_parent(m.r) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this._get_parent(m.o) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
},
|
||||
"json_data": {
|
||||
"progressive_render": true,
|
||||
"progressive_unload": true,
|
||||
"data": function(node, cb) {
|
||||
if (node == -1) {
|
||||
cb(<?php echo json_encode($root) ?>);
|
||||
} else {
|
||||
$.get("<?php echo st_url_for("@stCategory?action=ajaxJstreeJson") ?>", { "id": node.data("id") } , function(response) {
|
||||
cb(response);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
"ui": {
|
||||
"select_limit": 1,
|
||||
"initially_select": ["<?php echo $sf_request->getParameter('category_id') ? "category-".$sf_request->getParameter('category_id') : "" ?>"]
|
||||
},
|
||||
"contextmenu": {
|
||||
"select_node": true,
|
||||
"items": function(node) {
|
||||
var items = {
|
||||
"create": {
|
||||
"label": "<?php echo __("Dodaj", null, "stCategoryTree") ?>",
|
||||
"action": function(node) {
|
||||
this.create(node, "last", {
|
||||
data: "<?php echo __("Nowa kategoria", null, "stCategoryTree") ?>",
|
||||
});
|
||||
},
|
||||
"separator_after": true,
|
||||
},
|
||||
rename: {
|
||||
"label": "<?php echo __("Zmień nazwę", null, "stCategoryTree") ?>",
|
||||
"action": function(node) {
|
||||
this.rename(node);
|
||||
}
|
||||
},
|
||||
"remove": {
|
||||
"label": "<?php echo __("Usuń", null, "stCategoryTree") ?>",
|
||||
"action": function(node) {
|
||||
if (window.confirm("<?php echo __("Zamierzasz usunąć kategorię z drzewa. Jesteś pewien, że chcesz kontynuować?", null, "stCategoryTree") ?>")) {
|
||||
var tree = this;
|
||||
$(document).trigger("preloader", "show");
|
||||
$.post("<?php echo st_url_for("@stCategory?action=ajaxDelete") ?>", { "id": node.data("id") }, function(response) {
|
||||
$(document).trigger("preloader", "close");
|
||||
|
||||
if (!response.error)
|
||||
{
|
||||
tree.delete_node(node);
|
||||
}
|
||||
else
|
||||
{
|
||||
window.alert(response.error);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
"_disabled": node.data('is-root'),
|
||||
"separator_after": true,
|
||||
},
|
||||
"edit": {
|
||||
"label": "<?php echo __("Edytuj", null, "stCategoryTree") ?>",
|
||||
"action": function(node) {
|
||||
$(document).trigger("preloader", "show");
|
||||
var location = "<?php echo st_url_for("@stCategory?action=edit&id=__id__") ?>";
|
||||
window.location = location.replace("__id__", node.data("id"));
|
||||
},
|
||||
"submenu": false,
|
||||
},
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
}).on("rename_node.jstree", function(e, data) {
|
||||
$(document).trigger("preloader", "show");
|
||||
var node = data.rslt.obj;
|
||||
if (node.data("id")) {
|
||||
$.post("<?php echo st_url_for("@stCategory?action=ajaxRename") ?>", { "id": node.data("id"), "name": data.rslt.name }, function() {
|
||||
$(document).trigger("preloader", "close");
|
||||
});
|
||||
} else {
|
||||
var parent = data.inst._get_parent(node);
|
||||
$.post("<?php echo st_url_for("@stCategory?action=ajaxAdd") ?>", { "parent_id": parent.data("id"), "name": data.rslt.name }, function(response) {
|
||||
node.data("id", response.id);
|
||||
$(document).trigger("preloader", "close");
|
||||
});
|
||||
}
|
||||
}).on("move_node.jstree", function(e, data) {
|
||||
var tree = data.inst;
|
||||
var node = data.rslt.o;
|
||||
var target = data.rslt.r;
|
||||
var type = data.rslt.p;
|
||||
|
||||
var params = { "id": node.data("id") };
|
||||
|
||||
switch (type) {
|
||||
case "after":
|
||||
var next = tree._get_next(node, true);
|
||||
|
||||
if (!next) {
|
||||
var parent = tree._get_parent(target);
|
||||
params.parent_id = parent.data("id");
|
||||
} else {
|
||||
params.sibling_id = next.data("id");
|
||||
}
|
||||
break;
|
||||
|
||||
case "last":
|
||||
params.parent_id = target.data("id");
|
||||
break;
|
||||
|
||||
case "before":
|
||||
params.sibling_id = target.data("id");
|
||||
break;
|
||||
}
|
||||
|
||||
$(document).trigger("preloader", "show");
|
||||
$.post("<?php echo st_url_for("@stCategory?action=ajaxMove") ?>", params, function(response) {
|
||||
$(document).trigger("preloader", "close");
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
jQuery(function($) {
|
||||
$("#category_tree_container .category_tree_action").click(function() {
|
||||
var action = $(this);
|
||||
|
||||
if (action.hasClass("disabled")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (action.data("admin-confirm") && !window.confirm(action.data('admin-confirm'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!action.data("admin-confirm")) {
|
||||
$(document).trigger("preloader", "show");
|
||||
}
|
||||
|
||||
window.location = action.prop('href');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php st_include_partial("stCategory/footer") ?>
|
||||
20
apps/backend/modules/stCategory/validate/config.yml
Normal file
20
apps/backend/modules/stCategory/validate/config.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
fields:
|
||||
config{subcategory_main_menu_num}:
|
||||
required:
|
||||
msg: Podaj liczbę wyświetlanych podkategorii
|
||||
sfNumberValidator:
|
||||
min: 0
|
||||
min_error: Minimalna wartość to 0.
|
||||
type: integer
|
||||
type_error: Podaj liczbę całkowitą
|
||||
nan_error: Podaj liczbę całkowitą
|
||||
config{cut_subcategories_name_num}:
|
||||
old_config: true
|
||||
required:
|
||||
msg: Podaj liczbę znaków po, których ma być skracana nazwa kategorii
|
||||
sfNumberValidator:
|
||||
min: 1
|
||||
min_error: Minimalna liczba znaków to 1.
|
||||
type: integer
|
||||
type_error: Podaj liczbę całkowitą
|
||||
nan_error: Podaj liczbę całkowitą
|
||||
8
apps/backend/modules/stCategory/validate/edit.yml
Normal file
8
apps/backend/modules/stCategory/validate/edit.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
fields:
|
||||
category{name}:
|
||||
required:
|
||||
msg: Podaj nazwę kategorii
|
||||
category{image}:
|
||||
file: True
|
||||
stAssetFileValidator:
|
||||
mime_types: "@web_images"
|
||||
18
apps/backend/modules/stCategory/validate/positioningEdit.yml
Normal file
18
apps/backend/modules/stCategory/validate/positioningEdit.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
fields:
|
||||
category_has_positioning{title}:
|
||||
sfStringValidator:
|
||||
max: 255
|
||||
max_error: Tytuł strony jest niepoprawny. Maksymalna długość to 255 znaków.
|
||||
category_has_positioning{keywords}:
|
||||
sfStringValidator:
|
||||
max: 255
|
||||
max_error: Słowa kluczowe są niepoprawne. Maksymalna długość to 255 znaków.
|
||||
category_has_positioning{description}:
|
||||
sfStringValidator:
|
||||
max: 65000
|
||||
max_error: Opis strony jest niepoprawny. Maksymalna długość to 65000 znaków.
|
||||
category_has_positioning{category_url}:
|
||||
required:
|
||||
msg: Wprowadź nazwę dla przyjaznego linku
|
||||
stPropelSeoUrlValidator:
|
||||
auto_fillin_field: "category_has_positioning[category_url]"
|
||||
Reference in New Issue
Block a user