public function getProductList($id, $title) { $this->addValue("parcourir.php", trad('Gestion_catalogue', 'admin')); foreach (CategoryAdmin::getInstance()->getBreadcrumbList($id) as $breadcrumb) { $this->addValue("parcourir.php?parent=" . $breadcrumb->rubrique, $breadcrumb->titre); } $this->addValue("", $title); return $this->getBreadcrumb(); }
/** * Prepares the environment before running a test. */ protected function setUp() { parent::setUp(); $this->categoryAdminController = new CategoryAdminController(); $this->container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); $this->categoryManager = $this->getMockBuilder('Sonata\\ClassificationBundle\\Entity\\CategoryManager')->disableOriginalConstructor()->getMock(); $categoryManager = $this->categoryManager; $this->contextManager = $this->getMockBuilder('Sonata\\ClassificationBundle\\Entity\\ContextManager')->disableOriginalConstructor()->getMock(); $contextManager = $this->contextManager; $this->view = $this->getMock('Symfony\\Component\\Form\\FormView'); $this->form = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock(); $this->form->expects($this->any())->method('createView')->will($this->returnValue($this->view)); $this->dataGrid = $this->getMock('\\Sonata\\AdminBundle\\Datagrid\\DatagridInterface'); $this->dataGrid->expects($this->any())->method('getForm')->will($this->returnValue($this->form)); $this->request = new Request(); $this->pool = new Pool($this->container, 'title', 'logo.png'); $this->pool->setAdminServiceIds(array('foo.admin')); $this->request->attributes->set('_sonata_admin', 'foo.admin'); $this->admin = $this->getMockBuilder('Sonata\\ClassificationBundle\\Admin\\CategoryAdmin')->disableOriginalConstructor()->getMock(); $this->admin->expects($this->any())->method('getPersistentParameter')->will($this->returnValue('persistentParameter')); $this->admin->expects($this->any())->method('getDataGrid')->will($this->returnValue($this->dataGrid)); $params = array(); $template = ''; $templating = $this->getMock('Symfony\\Bundle\\FrameworkBundle\\Templating\\DelegatingEngine', array(), array($this->container, array())); $templating->expects($this->any())->method('renderResponse')->will($this->returnCallback(function ($view, array $parameters = array(), Response $response = null) use(&$params, &$template) { $template = $view; if (null === $response) { $response = new Response(); } $params = $parameters; return $response; })); $twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock(); $twigRenderer = $this->getMock('Symfony\\Bridge\\Twig\\Form\\TwigRendererInterface'); $formExtension = new FormExtension($twigRenderer); $twig->expects($this->any())->method('getExtension')->will($this->returnCallback(function ($name) use($formExtension) { switch ($name) { case 'form': return $formExtension; } return; })); $this->csrfProvider = $this->getMock('Symfony\\Component\\Form\\Extension\\Csrf\\CsrfProvider\\CsrfProviderInterface'); $this->csrfProvider->expects($this->any())->method('generateCsrfToken')->will($this->returnCallback(function ($intention) { return 'csrf-token-123_' . $intention; })); $this->csrfProvider->expects($this->any())->method('isCsrfTokenValid')->will($this->returnCallback(function ($intention, $token) { if ($token == 'csrf-token-123_' . $intention) { return true; } return false; })); // php 5.3 BC $pool = $this->pool; $admin = $this->admin; $request = $this->request; $csrfProvider = $this->csrfProvider; $requestStack = null; if (Kernel::MINOR_VERSION > 3) { $requestStack = new \Symfony\Component\HttpFoundation\RequestStack(); $requestStack->push($request); } $this->container->expects($this->any())->method('get')->will($this->returnCallback(function ($id) use($pool, $admin, $request, $requestStack, $templating, $twig, $csrfProvider, $categoryManager, $contextManager) { switch ($id) { case 'sonata.admin.pool': return $pool; case 'foo.admin': return $admin; case 'request': return $request; case 'request_stack': return $requestStack; case 'templating': return $templating; case 'twig': return $twig; case 'form.csrf_provider': return $csrfProvider; case 'sonata.classification.manager.category': return $categoryManager; case 'sonata.classification.manager.context': return $contextManager; } return; })); $this->categoryAdminController->setContainer($this->container); }
?> </th> <th><?php echo trad('Classement', 'admin'); ?> </th> <th></th> <th><?php echo trad('Suppr', 'admin'); ?> </th> </tr> </thead> <tbody> <?php foreach (CategoryAdmin::getInstance()->getList($parent, 'classement', 'ASC', '') as $rubrique) { ?> <tr> <td><?php echo $rubrique["titre"]; ?> </td> <td><input type="checkbox" category-id="<?php echo $rubrique["id"]; ?> " class="categoryDisplay" <?php if ($rubrique["ligne"]) { echo 'checked="checked"'; } ?> ></td>
<?php require_once __DIR__ . '/../auth.php'; if (!est_autorise("acces_catalogue")) { exit; } $request = Symfony\Component\HttpFoundation\Request::createFromGlobals(); if ($request->isXmlHttpRequest() === false) { redirige("../accueil.php"); } switch ($request->query->get('action')) { case 'changeDisplay': CategoryAdmin::getInstance($request->query->get('category_id'))->display($request->query->get('display')); break; }
<div class="span6 offset4"> <?php for ($i = 1; $i <= CategoryAdmin::getInstance()->getDocumentFile()->getNumberUpload(); $i++) { ?> <input type="file" name="document_<?php echo $i; ?> " class="input-large"> <br > <?php } ?> </div> </div> <?php foreach (CategoryAdmin::getInstance($rubrique->id)->getDocumentList($lang) as $document) { ?> <div class="row-fluid js-bloc-document" js-document-id="<?php echo $document['id']; ?> "> <div class="span3" style="position: relative;"> <p class="js-document"> <a target="_blank" href="<?php echo $document["fichier"]; ?> "><?php echo $document["nomFichier"]; ?> </a> </p>
protected function getDocuments(Request $request, \CategoryAdmin $category) { $return = array(); if ($category->id == '') { return array(); } $query = "select id from " . Document::TABLE . ' where rubrique=' . $category->id; $return = $this->extractResult($request, $category->query_liste($query), array("titre" => "document_titre_", "chapo" => "document_chapo_", "description" => "document_description_", "toDelete" => "document_to_delete_", "rank" => "rank_"), 'request'); return $return; }
<?php require_once __DIR__ . "/../auth.php"; if (!est_autorise("acces_commandes")) { exit; } header('Content-Type: text/html; charset=utf-8'); $root = $_POST['root'] ?: 0; $retour = array(); //get breadcrumb $retour['breadcrumb'] = Breadcrumb::getInstance(false)->getFastBrowserCategoryList($root); //get categories $retour['categories'] = CategoryAdmin::getInstance()->getList($root, 'classement', 'ASC', ''); //get products $retour['products'] = ProductAdmin::getInstance()->getList($root, 'classement', 'ASC', ''); die(json_encode($retour));