Initial commit
This commit is contained in:
21
local/modules/Shortcuts/Config/config.xml
Normal file
21
local/modules/Shortcuts/Config/config.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<config xmlns="http://thelia.net/schema/dic/config"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
|
||||
|
||||
<loops>
|
||||
<loop name="shortcuts" class="Shortcuts\Loop\ShortcutsLoop" />
|
||||
</loops>
|
||||
|
||||
<forms>
|
||||
<form name="thelia.admin.shortcut.creation" class="Shortcuts\Form\ShortcutForm" />
|
||||
</forms>
|
||||
|
||||
<hooks>
|
||||
<hook id="shortcuts.hook" class="Shortcuts\Hook\Shortcuts" scope="request">
|
||||
<tag name="hook.event_listener" event="main.topbar-top" active="1" type="back" method="onMainTopbarTop" />
|
||||
</hook>
|
||||
</hooks>
|
||||
|
||||
</config>
|
||||
50
local/modules/Shortcuts/Config/config_dev.xml
Normal file
50
local/modules/Shortcuts/Config/config_dev.xml
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<config xmlns="http://thelia.net/schema/dic/config"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
|
||||
|
||||
<loops>
|
||||
<!-- sample definition
|
||||
<loop name="MySuperLoop" class="Shortcuts\Loop\MySuperLoop" />
|
||||
-->
|
||||
</loops>
|
||||
|
||||
<forms>
|
||||
<!--
|
||||
<form name="MyFormName" class="Shortcuts\Form\MySuperForm" />
|
||||
-->
|
||||
</forms>
|
||||
|
||||
<commands>
|
||||
<!--
|
||||
<command class="Shortcuts\Command\MySuperCommand" />
|
||||
-->
|
||||
</commands>
|
||||
|
||||
<!--
|
||||
<services>
|
||||
|
||||
</services>
|
||||
-->
|
||||
|
||||
<!--
|
||||
<hooks>
|
||||
<hook id="shortcuts.hook" class="Shortcuts\Hook\MySuperHook">
|
||||
<tag name="hook.event_listener" event="main.body.bottom" type="front|back|pdf|email" method="onMainBodyBottom" />
|
||||
</hook>
|
||||
</hooks>
|
||||
-->
|
||||
|
||||
<!--
|
||||
<exports>
|
||||
|
||||
</exports>
|
||||
-->
|
||||
|
||||
<!--
|
||||
<imports>
|
||||
|
||||
</imports>
|
||||
-->
|
||||
</config>
|
||||
50
local/modules/Shortcuts/Config/config_prod.xml
Normal file
50
local/modules/Shortcuts/Config/config_prod.xml
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<config xmlns="http://thelia.net/schema/dic/config"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
|
||||
|
||||
<loops>
|
||||
<!-- sample definition
|
||||
<loop name="MySuperLoop" class="Shortcuts\Loop\MySuperLoop" />
|
||||
-->
|
||||
</loops>
|
||||
|
||||
<forms>
|
||||
<!--
|
||||
<form name="MyFormName" class="Shortcuts\Form\MySuperForm" />
|
||||
-->
|
||||
</forms>
|
||||
|
||||
<commands>
|
||||
<!--
|
||||
<command class="Shortcuts\Command\MySuperCommand" />
|
||||
-->
|
||||
</commands>
|
||||
|
||||
<!--
|
||||
<services>
|
||||
|
||||
</services>
|
||||
-->
|
||||
|
||||
<!--
|
||||
<hooks>
|
||||
<hook id="shortcuts.hook" class="Shortcuts\Hook\MySuperHook">
|
||||
<tag name="hook.event_listener" event="main.body.bottom" type="front|back|pdf|email" method="onMainBodyBottom" />
|
||||
</hook>
|
||||
</hooks>
|
||||
-->
|
||||
|
||||
<!--
|
||||
<exports>
|
||||
|
||||
</exports>
|
||||
-->
|
||||
|
||||
<!--
|
||||
<imports>
|
||||
|
||||
</imports>
|
||||
-->
|
||||
</config>
|
||||
50
local/modules/Shortcuts/Config/config_test.xml
Normal file
50
local/modules/Shortcuts/Config/config_test.xml
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<config xmlns="http://thelia.net/schema/dic/config"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
|
||||
|
||||
<loops>
|
||||
<!-- sample definition
|
||||
<loop name="MySuperLoop" class="Shortcuts\Loop\MySuperLoop" />
|
||||
-->
|
||||
</loops>
|
||||
|
||||
<forms>
|
||||
<!--
|
||||
<form name="MyFormName" class="Shortcuts\Form\MySuperForm" />
|
||||
-->
|
||||
</forms>
|
||||
|
||||
<commands>
|
||||
<!--
|
||||
<command class="Shortcuts\Command\MySuperCommand" />
|
||||
-->
|
||||
</commands>
|
||||
|
||||
<!--
|
||||
<services>
|
||||
|
||||
</services>
|
||||
-->
|
||||
|
||||
<!--
|
||||
<hooks>
|
||||
<hook id="shortcuts.hook" class="Shortcuts\Hook\MySuperHook">
|
||||
<tag name="hook.event_listener" event="main.body.bottom" type="front|back|pdf|email" method="onMainBodyBottom" />
|
||||
</hook>
|
||||
</hooks>
|
||||
-->
|
||||
|
||||
<!--
|
||||
<exports>
|
||||
|
||||
</exports>
|
||||
-->
|
||||
|
||||
<!--
|
||||
<imports>
|
||||
|
||||
</imports>
|
||||
-->
|
||||
</config>
|
||||
28
local/modules/Shortcuts/Config/module.xml
Normal file
28
local/modules/Shortcuts/Config/module.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module xmlns="http://thelia.net/schema/dic/module"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://thelia.net/schema/dic/module http://thelia.net/schema/dic/module/module-2_2.xsd">
|
||||
<fullnamespace>Shortcuts\Shortcuts</fullnamespace>
|
||||
<descriptive locale="en_US">
|
||||
<title>Shortcuts</title>
|
||||
<description>Fast access to the backoffice pages you use the most</description>
|
||||
</descriptive>
|
||||
<descriptive locale="fr_FR">
|
||||
<title>Raccourcis</title>
|
||||
<description>Accédez rapidement aux pages du backoffice que vous utilisez le plus</description>
|
||||
</descriptive>
|
||||
<!-- <logo></logo> -->
|
||||
<!--<images-folder>images</images-folder>-->
|
||||
<languages>
|
||||
<language>en_US</language>
|
||||
<language>fr_FR</language>
|
||||
</languages>
|
||||
<version>0.2.0</version>
|
||||
<author>
|
||||
<name>Nicolas Léon</name>
|
||||
<email>nicolas@omnitic.com</email>
|
||||
</author>
|
||||
<type>classic</type>
|
||||
<thelia>2.0.0</thelia>
|
||||
<stability>alpha</stability>
|
||||
</module>
|
||||
40
local/modules/Shortcuts/Config/routing.xml
Normal file
40
local/modules/Shortcuts/Config/routing.xml
Normal file
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<!--
|
||||
|
||||
if a /admin/module/shortcuts/ route is provided, a "Configuration" button will be displayed
|
||||
for the module in the module list. Clicking this button will invoke this route.
|
||||
|
||||
<route id="my_route_id" path="/admin/module/shortcuts">
|
||||
<default key="_controller">Shortcuts\Full\Class\Name\Of\YourConfigurationController::methodName</default>
|
||||
</route>
|
||||
|
||||
<route id="my_route_id" path="/admin/module/shortcuts/route-name">
|
||||
<default key="_controller">Shortcuts\Full\Class\Name\Of\YourAdminController::methodName</default>
|
||||
</route>
|
||||
|
||||
<route id="my_route_id" path="/my/route/name">
|
||||
<default key="_controller">Shortcuts\Full\Class\Name\Of\YourOtherController::methodName</default>
|
||||
</route>
|
||||
|
||||
...add as many routes as required.
|
||||
|
||||
<route>
|
||||
...
|
||||
</route>
|
||||
-->
|
||||
<route id="shortcuts-settings" path="/admin/module/Shortcuts">
|
||||
<default key="_controller">Shortcuts:Shortcuts:index</default>
|
||||
</route>
|
||||
<route id="shortcuts.create-shortcut" path="/admin/module/Shortcuts/create">
|
||||
<default key="_controller">Shortcuts:Shortcuts:create</default>
|
||||
</route>
|
||||
<route id="shortcuts.delete-shortcut" path="/admin/module/Shortcuts/delete">
|
||||
<default key="_controller">Shortcuts:Shortcuts:delete</default>
|
||||
</route>
|
||||
|
||||
</routes>
|
||||
24
local/modules/Shortcuts/Config/schema.xml
Normal file
24
local/modules/Shortcuts/Config/schema.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<database defaultIdMethod="native" name="thelia"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../vendor/propel/propel/resources/xsd/database.xsd" >
|
||||
|
||||
<!-- See propel documentation on http://propelorm.org for all information about schema file -->
|
||||
|
||||
<table name="shortcuts" namespace="Shortcuts\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="title" size="255" type="VARCHAR" required="true"/>
|
||||
<column defaultValue="0" name="position" required="true" type="INTEGER" />
|
||||
<column name="url" required="true" type="VARCHAR" />
|
||||
<column name="admin_id" required="false" type="INTEGER" />
|
||||
<behavior name="i18n">
|
||||
<parameter name="i18n_columns" value="title"/>
|
||||
</behavior>
|
||||
<foreign-key foreignTable="admin" name="fk_admin_id" onDelete="CASCADE" onUpdate="RESTRICT">
|
||||
<reference foreign="id" local="admin_id" />
|
||||
</foreign-key>
|
||||
<!-- <behavior name="timestampable" /> -->
|
||||
</table>
|
||||
|
||||
<external-schema filename="local/config/schema.xml" referenceOnly="true" />
|
||||
</database>
|
||||
6
local/modules/Shortcuts/Config/shortcuts.sql
Normal file
6
local/modules/Shortcuts/Config/shortcuts.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
-- Shotcuts inception
|
||||
INSERT INTO `shortcuts` (`id`, `position`, `url`, `visible`, `admin_id`) VALUES
|
||||
(1, 1, '/admin/module/Shortcuts', 1, 1);
|
||||
INSERT INTO `shortcuts_i18n` (`id`, `locale`, `title`) VALUES
|
||||
(1, 'en_US', 'Shortcuts'),
|
||||
(1, 'fr_FR', 'Raccourcis');
|
||||
2
local/modules/Shortcuts/Config/sqldb.map
Normal file
2
local/modules/Shortcuts/Config/sqldb.map
Normal file
@@ -0,0 +1,2 @@
|
||||
# Sqlfile -> Database map
|
||||
thelia.sql=thelia
|
||||
46
local/modules/Shortcuts/Config/thelia.sql
Normal file
46
local/modules/Shortcuts/Config/thelia.sql
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
# This is a fix for InnoDB in MySQL >= 4.1.x
|
||||
# It "suspends judgement" for fkey relationships until are tables are set.
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- shortcuts
|
||||
-- ---------------------------------------------------------------------
|
||||
|
||||
DROP TABLE IF EXISTS `shortcuts`;
|
||||
|
||||
CREATE TABLE `shortcuts`
|
||||
(
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`position` INTEGER DEFAULT 0 NOT NULL,
|
||||
`url` VARCHAR(255) NOT NULL,
|
||||
`admin_id` INTEGER,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `FI_admin_id` (`admin_id`),
|
||||
CONSTRAINT `fk_admin_id`
|
||||
FOREIGN KEY (`admin_id`)
|
||||
REFERENCES `admin` (`id`)
|
||||
ON UPDATE RESTRICT
|
||||
ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- shortcuts_i18n
|
||||
-- ---------------------------------------------------------------------
|
||||
|
||||
DROP TABLE IF EXISTS `shortcuts_i18n`;
|
||||
|
||||
CREATE TABLE `shortcuts_i18n`
|
||||
(
|
||||
`id` INTEGER NOT NULL,
|
||||
`locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL,
|
||||
`title` VARCHAR(255) NOT NULL,
|
||||
PRIMARY KEY (`id`,`locale`),
|
||||
CONSTRAINT `shortcuts_i18n_FK_1`
|
||||
FOREIGN KEY (`id`)
|
||||
REFERENCES `shortcuts` (`id`)
|
||||
ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
# This restores the fkey checks, after having unset them earlier
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
96
local/modules/Shortcuts/Controller/ShortcutsController.php
Normal file
96
local/modules/Shortcuts/Controller/ShortcutsController.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Shortcuts Module */
|
||||
/* */
|
||||
/* Copyright (c) Omnitic */
|
||||
/* email : nicolas@omnitic.com */
|
||||
/* web : http://www.omnitic.com */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Shortcuts\Controller;
|
||||
|
||||
use Shortcuts\Model\Shortcuts;
|
||||
use Shortcuts\Model\ShortcutsQuery;
|
||||
use Shortcuts\Model\ShortcutsI18n;
|
||||
use Shortcuts\Model\ShortcutsQueryI18n;
|
||||
use Shortcuts\Form\ShortcutForm;
|
||||
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
|
||||
use Thelia\Controller\Admin\BaseAdminController;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
|
||||
/**
|
||||
* Class ShortcutsAdminController
|
||||
* @package Shortcuts\Controller
|
||||
* @author Nicolas Léon <nicolas@omnitic.com>
|
||||
*/
|
||||
class ShortcutsController extends BaseAdminController
|
||||
{
|
||||
|
||||
// private $img_folder;
|
||||
// private $src_folder;
|
||||
// protected $currentRouter = "router.shortcuts";
|
||||
|
||||
protected $request;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm a Shortcuts
|
||||
*
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
// die('ooops');
|
||||
return $this->render("shortcuts.index", array(
|
||||
'shortcuts' => array(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a shortcut
|
||||
*
|
||||
*/
|
||||
public function createAction()
|
||||
{
|
||||
$shortcut_form = new ShortcutForm($this->getRequest());
|
||||
$shortcutForm = $this->validateForm($shortcut_form, "POST");
|
||||
|
||||
// Get the current admin user
|
||||
$currentAdmin = $this->getSecurityContext()->getAdminUser();
|
||||
|
||||
$shortcut = new Shortcuts();
|
||||
$shortcut->setLocale($shortcutForm->get('locale')->getData());
|
||||
$shortcut->setTitle($shortcutForm->get('title')->getData());
|
||||
$shortcut->setUrl($shortcutForm->get('shortcut_url')->getData());
|
||||
$shortcut->setAdminId($currentAdmin->getId());
|
||||
$shortcut->save();
|
||||
|
||||
return new RedirectResponse(URL::getInstance()->absoluteUrl("/admin/module/Shortcuts"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a Shortcuts
|
||||
*
|
||||
*/
|
||||
public function deleteAction()
|
||||
{
|
||||
$shortcut_id = $_POST['shortcut_id'];
|
||||
|
||||
$shortcut = ShortcutsQuery::create()->findPK($shortcut_id);
|
||||
|
||||
$shortcut->delete();
|
||||
|
||||
return new RedirectResponse(URL::getInstance()->absoluteUrl("/admin/module/Shortcuts"));
|
||||
}
|
||||
}
|
||||
59
local/modules/Shortcuts/Form/ShortcutForm.php
Normal file
59
local/modules/Shortcuts/Form/ShortcutForm.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Booking Module */
|
||||
/* */
|
||||
/* Copyright (c) Omnitic */
|
||||
/* email : bonjour@omnitic.com */
|
||||
/* web : http://www.omnitic.com */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
namespace Shortcuts\Form;
|
||||
|
||||
use Shortcuts\Shortcuts;
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Form\BaseForm;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
// use Shortcuts\Model\ShortcutsVehiclesQuery;
|
||||
use Shortcuts\Model\BookingVehiclesQuery;
|
||||
|
||||
class ShortcutForm extends BaseForm
|
||||
{
|
||||
|
||||
protected function buildForm()
|
||||
{
|
||||
|
||||
$this->formBuilder
|
||||
|
||||
->add("title", "text", array(
|
||||
'constraints' => array(
|
||||
new Constraints\NotBlank()
|
||||
),
|
||||
'attr' => ['id' => "title", 'class' => "normal form-control"],
|
||||
'label' => Translator::getInstance()->trans("Shortcut title", array(), Shortcuts::MODULE_DOMAIN)
|
||||
))
|
||||
->add("shortcut_url", "text", array(
|
||||
'constraints' => array(
|
||||
new Constraints\NotBlank()
|
||||
),
|
||||
'attr' => ['id' => "url", 'class' => "normal form-control"],
|
||||
'label' => Translator::getInstance()->trans("Shortcut url", array(), Shortcuts::MODULE_DOMAIN)
|
||||
))
|
||||
->add("locale", "hidden", array(
|
||||
'constraints' => array(
|
||||
new Constraints\NotBlank()
|
||||
),
|
||||
'label' => Translator::getInstance()->trans("Locale", array(), Shortcuts::MODULE_DOMAIN)
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "shortcut_form";
|
||||
}
|
||||
}
|
||||
21
local/modules/Shortcuts/Hook/Shortcuts.php
Normal file
21
local/modules/Shortcuts/Hook/Shortcuts.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Shortcuts\Hook;
|
||||
|
||||
use Thelia\Core\Event\Hook\HookRenderEvent;
|
||||
// use Thelia\Core\Event\Hook\HookRenderBlockEvent;
|
||||
use Thelia\Core\Hook\BaseHook;
|
||||
|
||||
/**
|
||||
* Class Shortcuts
|
||||
* @package Shortcuts\Hook
|
||||
* @author Julien Chanséaume <jchanseaume@openstudio.fr>
|
||||
*/
|
||||
class Shortcuts extends BaseHook
|
||||
{
|
||||
|
||||
public function onMainTopbarTop(HookRenderEvent $event)
|
||||
{
|
||||
$event->add($this->render("shortcuts.hook.html", $event->getArguments()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return array(
|
||||
// 'an english string' => 'The displayed english string',
|
||||
);
|
||||
17
local/modules/Shortcuts/I18n/backOffice/default/fr_FR.php
Normal file
17
local/modules/Shortcuts/I18n/backOffice/default/fr_FR.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
"Shortcuts settings" => "Paramètres des raccourcis",
|
||||
"Shortcuts" => "Raccourcis",
|
||||
"Shortcut title" => "Titre du raccourci",
|
||||
"Shortcut url" => "L'url du raccourci",
|
||||
"Add shortcut" => "Ajouter le raccourci",
|
||||
"Delete shortcut" => "Supprimer le raccourci",
|
||||
"Create a shortcut" => "Créer un raccourci",
|
||||
"Existing shortcuts" => "Raccourcis existants",
|
||||
"No shortcuts found" => "Aucun raccourcis",
|
||||
"Do you really want to delete this shortcut?" => "Voulez-vous vraiment supprimer ce raccourci ?",
|
||||
"Yes" => "Oui",
|
||||
"No" => "Non",
|
||||
"No shortcuts found. To create a new one, click the + button above." => "Aucun racourcis trouvés. Pour ajouter un raccourci cliquez sur le bouton + ci-dessus",
|
||||
);
|
||||
91
local/modules/Shortcuts/Loop/ShortcutsLoop.php
Normal file
91
local/modules/Shortcuts/Loop/ShortcutsLoop.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Shortcuts Module */
|
||||
/* */
|
||||
/* Copyright (c) Omnitic */
|
||||
/* email : nicolas@omnitic.com */
|
||||
/* web : http://www.omnitic.com */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Shortcuts\Loop;
|
||||
|
||||
use Shortcuts\Model\ShortcutsQuery;
|
||||
use Thelia\Model\BrandQuery;
|
||||
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\Element\PropelSearchLoopInterface;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
|
||||
/**
|
||||
* Class ShortcutsLoop
|
||||
* @package Shortcuts\Loop
|
||||
* @author Nicolas Léon <nicolas@omnitic.com>
|
||||
*/
|
||||
class ShortcutsLoop extends BaseLoop implements PropelSearchLoopInterface
|
||||
{
|
||||
public $countable = true;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('user_id')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* this method returns a Propel ModelCriteria
|
||||
*
|
||||
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
|
||||
*/
|
||||
public function buildModelCriteria()
|
||||
{
|
||||
// Get current user id
|
||||
if ($this->securityContext->hasAdminUser()) {
|
||||
$adminUser = $this->securityContext->getAdminUser();
|
||||
$user_locale = $this->securityContext->getAdminUser()->getLocale();
|
||||
$search = ShortcutsQuery::create()->joinWithI18n($user_locale)->orderByPosition();
|
||||
$search->where('admin_id = '. $adminUser->getId() . ' OR admin_id IS NULL');
|
||||
|
||||
return $search;
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LoopResult $loopResult
|
||||
*
|
||||
* @return LoopResult
|
||||
*/
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
|
||||
foreach ($loopResult->getResultDataCollection() as $shortcut) {
|
||||
$loopResultRow = (new LoopResultRow($shortcut))
|
||||
->set('ID', $shortcut->getId())
|
||||
->set('TITLE', $shortcut->getTitle())
|
||||
->set('URL', $shortcut->getUrl())
|
||||
->set('ADMIN_ID', $shortcut->getAdminId())
|
||||
->set('POSITION', $shortcut->getPosition());
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
1770
local/modules/Shortcuts/Model/Base/Shortcuts.php
Normal file
1770
local/modules/Shortcuts/Model/Base/Shortcuts.php
Normal file
File diff suppressed because it is too large
Load Diff
1268
local/modules/Shortcuts/Model/Base/ShortcutsI18n.php
Normal file
1268
local/modules/Shortcuts/Model/Base/ShortcutsI18n.php
Normal file
File diff suppressed because it is too large
Load Diff
508
local/modules/Shortcuts/Model/Base/ShortcutsI18nQuery.php
Normal file
508
local/modules/Shortcuts/Model/Base/ShortcutsI18nQuery.php
Normal file
@@ -0,0 +1,508 @@
|
||||
<?php
|
||||
|
||||
namespace Shortcuts\Model\Base;
|
||||
|
||||
use \Exception;
|
||||
use \PDO;
|
||||
use Propel\Runtime\Propel;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelJoin;
|
||||
use Propel\Runtime\Collection\Collection;
|
||||
use Propel\Runtime\Collection\ObjectCollection;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Shortcuts\Model\ShortcutsI18n as ChildShortcutsI18n;
|
||||
use Shortcuts\Model\ShortcutsI18nQuery as ChildShortcutsI18nQuery;
|
||||
use Shortcuts\Model\Map\ShortcutsI18nTableMap;
|
||||
|
||||
/**
|
||||
* Base class that represents a query for the 'shortcuts_i18n' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @method ChildShortcutsI18nQuery orderById($order = Criteria::ASC) Order by the id column
|
||||
* @method ChildShortcutsI18nQuery orderByLocale($order = Criteria::ASC) Order by the locale column
|
||||
* @method ChildShortcutsI18nQuery orderByTitle($order = Criteria::ASC) Order by the title column
|
||||
*
|
||||
* @method ChildShortcutsI18nQuery groupById() Group by the id column
|
||||
* @method ChildShortcutsI18nQuery groupByLocale() Group by the locale column
|
||||
* @method ChildShortcutsI18nQuery groupByTitle() Group by the title column
|
||||
*
|
||||
* @method ChildShortcutsI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
* @method ChildShortcutsI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
* @method ChildShortcutsI18nQuery innerJoin($relation) Adds a INNER JOIN clause to the query
|
||||
*
|
||||
* @method ChildShortcutsI18nQuery leftJoinShortcuts($relationAlias = null) Adds a LEFT JOIN clause to the query using the Shortcuts relation
|
||||
* @method ChildShortcutsI18nQuery rightJoinShortcuts($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Shortcuts relation
|
||||
* @method ChildShortcutsI18nQuery innerJoinShortcuts($relationAlias = null) Adds a INNER JOIN clause to the query using the Shortcuts relation
|
||||
*
|
||||
* @method ChildShortcutsI18n findOne(ConnectionInterface $con = null) Return the first ChildShortcutsI18n matching the query
|
||||
* @method ChildShortcutsI18n findOneOrCreate(ConnectionInterface $con = null) Return the first ChildShortcutsI18n matching the query, or a new ChildShortcutsI18n object populated from the query conditions when no match is found
|
||||
*
|
||||
* @method ChildShortcutsI18n findOneById(int $id) Return the first ChildShortcutsI18n filtered by the id column
|
||||
* @method ChildShortcutsI18n findOneByLocale(string $locale) Return the first ChildShortcutsI18n filtered by the locale column
|
||||
* @method ChildShortcutsI18n findOneByTitle(string $title) Return the first ChildShortcutsI18n filtered by the title column
|
||||
*
|
||||
* @method array findById(int $id) Return ChildShortcutsI18n objects filtered by the id column
|
||||
* @method array findByLocale(string $locale) Return ChildShortcutsI18n objects filtered by the locale column
|
||||
* @method array findByTitle(string $title) Return ChildShortcutsI18n objects filtered by the title column
|
||||
*
|
||||
*/
|
||||
abstract class ShortcutsI18nQuery extends ModelCriteria
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes internal state of \Shortcuts\Model\Base\ShortcutsI18nQuery object.
|
||||
*
|
||||
* @param string $dbName The database name
|
||||
* @param string $modelName The phpName of a model, e.g. 'Book'
|
||||
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
|
||||
*/
|
||||
public function __construct($dbName = 'thelia', $modelName = '\\Shortcuts\\Model\\ShortcutsI18n', $modelAlias = null)
|
||||
{
|
||||
parent::__construct($dbName, $modelName, $modelAlias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new ChildShortcutsI18nQuery object.
|
||||
*
|
||||
* @param string $modelAlias The alias of a model in the query
|
||||
* @param Criteria $criteria Optional Criteria to build the query from
|
||||
*
|
||||
* @return ChildShortcutsI18nQuery
|
||||
*/
|
||||
public static function create($modelAlias = null, $criteria = null)
|
||||
{
|
||||
if ($criteria instanceof \Shortcuts\Model\ShortcutsI18nQuery) {
|
||||
return $criteria;
|
||||
}
|
||||
$query = new \Shortcuts\Model\ShortcutsI18nQuery();
|
||||
if (null !== $modelAlias) {
|
||||
$query->setModelAlias($modelAlias);
|
||||
}
|
||||
if ($criteria instanceof Criteria) {
|
||||
$query->mergeWith($criteria);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key.
|
||||
* Propel uses the instance pool to skip the database if the object exists.
|
||||
* Go fast if the query is untouched.
|
||||
*
|
||||
* <code>
|
||||
* $obj = $c->findPk(array(12, 34), $con);
|
||||
* </code>
|
||||
*
|
||||
* @param array[$id, $locale] $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ChildShortcutsI18n|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
public function findPk($key, $con = null)
|
||||
{
|
||||
if ($key === null) {
|
||||
return null;
|
||||
}
|
||||
if ((null !== ($obj = ShortcutsI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
|
||||
// the object is already in the instance pool
|
||||
return $obj;
|
||||
}
|
||||
if ($con === null) {
|
||||
$con = Propel::getServiceContainer()->getReadConnection(ShortcutsI18nTableMap::DATABASE_NAME);
|
||||
}
|
||||
$this->basePreSelect($con);
|
||||
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|
||||
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|
||||
|| $this->map || $this->having || $this->joins) {
|
||||
return $this->findPkComplex($key, $con);
|
||||
} else {
|
||||
return $this->findPkSimple($key, $con);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key using raw SQL to go fast.
|
||||
* Bypass doSelect() and the object formatter by using generated code.
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con A connection object
|
||||
*
|
||||
* @return ChildShortcutsI18n A model object, or null if the key is not found
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, LOCALE, TITLE FROM shortcuts_i18n WHERE ID = :p0 AND LOCALE = :p1';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
|
||||
$stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
|
||||
$stmt->execute();
|
||||
} catch (Exception $e) {
|
||||
Propel::log($e->getMessage(), Propel::LOG_ERR);
|
||||
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
|
||||
}
|
||||
$obj = null;
|
||||
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
|
||||
$obj = new ChildShortcutsI18n();
|
||||
$obj->hydrate($row);
|
||||
ShortcutsI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
|
||||
}
|
||||
$stmt->closeCursor();
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key.
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con A connection object
|
||||
*
|
||||
* @return ChildShortcutsI18n|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
protected function findPkComplex($key, $con)
|
||||
{
|
||||
// As the query uses a PK condition, no limit(1) is necessary.
|
||||
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
||||
$dataFetcher = $criteria
|
||||
->filterByPrimaryKey($key)
|
||||
->doSelect($con);
|
||||
|
||||
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find objects by primary key
|
||||
* <code>
|
||||
* $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
|
||||
* </code>
|
||||
* @param array $keys Primary keys to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
|
||||
*/
|
||||
public function findPks($keys, $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
|
||||
}
|
||||
$this->basePreSelect($con);
|
||||
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
||||
$dataFetcher = $criteria
|
||||
->filterByPrimaryKeys($keys)
|
||||
->doSelect($con);
|
||||
|
||||
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by primary key
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
*
|
||||
* @return ChildShortcutsI18nQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKey($key)
|
||||
{
|
||||
$this->addUsingAlias(ShortcutsI18nTableMap::ID, $key[0], Criteria::EQUAL);
|
||||
$this->addUsingAlias(ShortcutsI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a list of primary keys
|
||||
*
|
||||
* @param array $keys The list of primary key to use for the query
|
||||
*
|
||||
* @return ChildShortcutsI18nQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKeys($keys)
|
||||
{
|
||||
if (empty($keys)) {
|
||||
return $this->add(null, '1<>1', Criteria::CUSTOM);
|
||||
}
|
||||
foreach ($keys as $key) {
|
||||
$cton0 = $this->getNewCriterion(ShortcutsI18nTableMap::ID, $key[0], Criteria::EQUAL);
|
||||
$cton1 = $this->getNewCriterion(ShortcutsI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
|
||||
$cton0->addAnd($cton1);
|
||||
$this->addOr($cton0);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterById(1234); // WHERE id = 1234
|
||||
* $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
|
||||
* $query->filterById(array('min' => 12)); // WHERE id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByShortcuts()
|
||||
*
|
||||
* @param mixed $id The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildShortcutsI18nQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterById($id = null, $comparison = null)
|
||||
{
|
||||
if (is_array($id)) {
|
||||
$useMinMax = false;
|
||||
if (isset($id['min'])) {
|
||||
$this->addUsingAlias(ShortcutsI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($id['max'])) {
|
||||
$this->addUsingAlias(ShortcutsI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(ShortcutsI18nTableMap::ID, $id, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the locale column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
|
||||
* $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param string $locale The value to use as filter.
|
||||
* Accepts wildcards (* and % trigger a LIKE)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildShortcutsI18nQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByLocale($locale = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($locale)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $locale)) {
|
||||
$locale = str_replace('*', '%', $locale);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(ShortcutsI18nTableMap::LOCALE, $locale, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the title column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
|
||||
* $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param string $title The value to use as filter.
|
||||
* Accepts wildcards (* and % trigger a LIKE)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildShortcutsI18nQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByTitle($title = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($title)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $title)) {
|
||||
$title = str_replace('*', '%', $title);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(ShortcutsI18nTableMap::TITLE, $title, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Shortcuts\Model\Shortcuts object
|
||||
*
|
||||
* @param \Shortcuts\Model\Shortcuts|ObjectCollection $shortcuts The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildShortcutsI18nQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByShortcuts($shortcuts, $comparison = null)
|
||||
{
|
||||
if ($shortcuts instanceof \Shortcuts\Model\Shortcuts) {
|
||||
return $this
|
||||
->addUsingAlias(ShortcutsI18nTableMap::ID, $shortcuts->getId(), $comparison);
|
||||
} elseif ($shortcuts instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(ShortcutsI18nTableMap::ID, $shortcuts->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByShortcuts() only accepts arguments of type \Shortcuts\Model\Shortcuts or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Shortcuts relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildShortcutsI18nQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinShortcuts($relationAlias = null, $joinType = 'LEFT JOIN')
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Shortcuts');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'Shortcuts');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Shortcuts relation Shortcuts object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Shortcuts\Model\ShortcutsQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useShortcutsQuery($relationAlias = null, $joinType = 'LEFT JOIN')
|
||||
{
|
||||
return $this
|
||||
->joinShortcuts($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Shortcuts', '\Shortcuts\Model\ShortcutsQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
* @param ChildShortcutsI18n $shortcutsI18n Object to remove from the list of results
|
||||
*
|
||||
* @return ChildShortcutsI18nQuery The current query, for fluid interface
|
||||
*/
|
||||
public function prune($shortcutsI18n = null)
|
||||
{
|
||||
if ($shortcutsI18n) {
|
||||
$this->addCond('pruneCond0', $this->getAliasedColName(ShortcutsI18nTableMap::ID), $shortcutsI18n->getId(), Criteria::NOT_EQUAL);
|
||||
$this->addCond('pruneCond1', $this->getAliasedColName(ShortcutsI18nTableMap::LOCALE), $shortcutsI18n->getLocale(), Criteria::NOT_EQUAL);
|
||||
$this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the shortcuts_i18n table.
|
||||
*
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public function doDeleteAll(ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(ShortcutsI18nTableMap::DATABASE_NAME);
|
||||
}
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->beginTransaction();
|
||||
$affectedRows += parent::doDeleteAll($con);
|
||||
// Because this db requires some delete cascade/set null emulation, we have to
|
||||
// clear the cached instance *after* the emulation has happened (since
|
||||
// instances get re-added by the select statement contained therein).
|
||||
ShortcutsI18nTableMap::clearInstancePool();
|
||||
ShortcutsI18nTableMap::clearRelatedInstancePool();
|
||||
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a ChildShortcutsI18n or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or ChildShortcutsI18n object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
|
||||
* if supported by native driver or if emulated using Propel.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public function delete(ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(ShortcutsI18nTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = $this;
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(ShortcutsI18nTableMap::DATABASE_NAME);
|
||||
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->beginTransaction();
|
||||
|
||||
|
||||
ShortcutsI18nTableMap::removeInstanceFromPool($criteria);
|
||||
|
||||
$affectedRows += ModelCriteria::delete($con);
|
||||
ShortcutsI18nTableMap::clearRelatedInstancePool();
|
||||
$con->commit();
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
} // ShortcutsI18nQuery
|
||||
687
local/modules/Shortcuts/Model/Base/ShortcutsQuery.php
Normal file
687
local/modules/Shortcuts/Model/Base/ShortcutsQuery.php
Normal file
@@ -0,0 +1,687 @@
|
||||
<?php
|
||||
|
||||
namespace Shortcuts\Model\Base;
|
||||
|
||||
use \Exception;
|
||||
use \PDO;
|
||||
use Propel\Runtime\Propel;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelJoin;
|
||||
use Propel\Runtime\Collection\Collection;
|
||||
use Propel\Runtime\Collection\ObjectCollection;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Shortcuts\Model\Shortcuts as ChildShortcuts;
|
||||
use Shortcuts\Model\ShortcutsI18nQuery as ChildShortcutsI18nQuery;
|
||||
use Shortcuts\Model\ShortcutsQuery as ChildShortcutsQuery;
|
||||
use Shortcuts\Model\Map\ShortcutsTableMap;
|
||||
use Thelia\Model\Admin;
|
||||
|
||||
/**
|
||||
* Base class that represents a query for the 'shortcuts' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @method ChildShortcutsQuery orderById($order = Criteria::ASC) Order by the id column
|
||||
* @method ChildShortcutsQuery orderByPosition($order = Criteria::ASC) Order by the position column
|
||||
* @method ChildShortcutsQuery orderByUrl($order = Criteria::ASC) Order by the url column
|
||||
* @method ChildShortcutsQuery orderByAdminId($order = Criteria::ASC) Order by the admin_id column
|
||||
*
|
||||
* @method ChildShortcutsQuery groupById() Group by the id column
|
||||
* @method ChildShortcutsQuery groupByPosition() Group by the position column
|
||||
* @method ChildShortcutsQuery groupByUrl() Group by the url column
|
||||
* @method ChildShortcutsQuery groupByAdminId() Group by the admin_id column
|
||||
*
|
||||
* @method ChildShortcutsQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
* @method ChildShortcutsQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
* @method ChildShortcutsQuery innerJoin($relation) Adds a INNER JOIN clause to the query
|
||||
*
|
||||
* @method ChildShortcutsQuery leftJoinAdmin($relationAlias = null) Adds a LEFT JOIN clause to the query using the Admin relation
|
||||
* @method ChildShortcutsQuery rightJoinAdmin($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Admin relation
|
||||
* @method ChildShortcutsQuery innerJoinAdmin($relationAlias = null) Adds a INNER JOIN clause to the query using the Admin relation
|
||||
*
|
||||
* @method ChildShortcutsQuery leftJoinShortcutsI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the ShortcutsI18n relation
|
||||
* @method ChildShortcutsQuery rightJoinShortcutsI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ShortcutsI18n relation
|
||||
* @method ChildShortcutsQuery innerJoinShortcutsI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the ShortcutsI18n relation
|
||||
*
|
||||
* @method ChildShortcuts findOne(ConnectionInterface $con = null) Return the first ChildShortcuts matching the query
|
||||
* @method ChildShortcuts findOneOrCreate(ConnectionInterface $con = null) Return the first ChildShortcuts matching the query, or a new ChildShortcuts object populated from the query conditions when no match is found
|
||||
*
|
||||
* @method ChildShortcuts findOneById(int $id) Return the first ChildShortcuts filtered by the id column
|
||||
* @method ChildShortcuts findOneByPosition(int $position) Return the first ChildShortcuts filtered by the position column
|
||||
* @method ChildShortcuts findOneByUrl(string $url) Return the first ChildShortcuts filtered by the url column
|
||||
* @method ChildShortcuts findOneByAdminId(int $admin_id) Return the first ChildShortcuts filtered by the admin_id column
|
||||
*
|
||||
* @method array findById(int $id) Return ChildShortcuts objects filtered by the id column
|
||||
* @method array findByPosition(int $position) Return ChildShortcuts objects filtered by the position column
|
||||
* @method array findByUrl(string $url) Return ChildShortcuts objects filtered by the url column
|
||||
* @method array findByAdminId(int $admin_id) Return ChildShortcuts objects filtered by the admin_id column
|
||||
*
|
||||
*/
|
||||
abstract class ShortcutsQuery extends ModelCriteria
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes internal state of \Shortcuts\Model\Base\ShortcutsQuery object.
|
||||
*
|
||||
* @param string $dbName The database name
|
||||
* @param string $modelName The phpName of a model, e.g. 'Book'
|
||||
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
|
||||
*/
|
||||
public function __construct($dbName = 'thelia', $modelName = '\\Shortcuts\\Model\\Shortcuts', $modelAlias = null)
|
||||
{
|
||||
parent::__construct($dbName, $modelName, $modelAlias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new ChildShortcutsQuery object.
|
||||
*
|
||||
* @param string $modelAlias The alias of a model in the query
|
||||
* @param Criteria $criteria Optional Criteria to build the query from
|
||||
*
|
||||
* @return ChildShortcutsQuery
|
||||
*/
|
||||
public static function create($modelAlias = null, $criteria = null)
|
||||
{
|
||||
if ($criteria instanceof \Shortcuts\Model\ShortcutsQuery) {
|
||||
return $criteria;
|
||||
}
|
||||
$query = new \Shortcuts\Model\ShortcutsQuery();
|
||||
if (null !== $modelAlias) {
|
||||
$query->setModelAlias($modelAlias);
|
||||
}
|
||||
if ($criteria instanceof Criteria) {
|
||||
$query->mergeWith($criteria);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key.
|
||||
* Propel uses the instance pool to skip the database if the object exists.
|
||||
* Go fast if the query is untouched.
|
||||
*
|
||||
* <code>
|
||||
* $obj = $c->findPk(12, $con);
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ChildShortcuts|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
public function findPk($key, $con = null)
|
||||
{
|
||||
if ($key === null) {
|
||||
return null;
|
||||
}
|
||||
if ((null !== ($obj = ShortcutsTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
|
||||
// the object is already in the instance pool
|
||||
return $obj;
|
||||
}
|
||||
if ($con === null) {
|
||||
$con = Propel::getServiceContainer()->getReadConnection(ShortcutsTableMap::DATABASE_NAME);
|
||||
}
|
||||
$this->basePreSelect($con);
|
||||
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|
||||
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|
||||
|| $this->map || $this->having || $this->joins) {
|
||||
return $this->findPkComplex($key, $con);
|
||||
} else {
|
||||
return $this->findPkSimple($key, $con);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key using raw SQL to go fast.
|
||||
* Bypass doSelect() and the object formatter by using generated code.
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con A connection object
|
||||
*
|
||||
* @return ChildShortcuts A model object, or null if the key is not found
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, POSITION, URL, ADMIN_ID FROM shortcuts WHERE ID = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
} catch (Exception $e) {
|
||||
Propel::log($e->getMessage(), Propel::LOG_ERR);
|
||||
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
|
||||
}
|
||||
$obj = null;
|
||||
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
|
||||
$obj = new ChildShortcuts();
|
||||
$obj->hydrate($row);
|
||||
ShortcutsTableMap::addInstanceToPool($obj, (string) $key);
|
||||
}
|
||||
$stmt->closeCursor();
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key.
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con A connection object
|
||||
*
|
||||
* @return ChildShortcuts|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
protected function findPkComplex($key, $con)
|
||||
{
|
||||
// As the query uses a PK condition, no limit(1) is necessary.
|
||||
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
||||
$dataFetcher = $criteria
|
||||
->filterByPrimaryKey($key)
|
||||
->doSelect($con);
|
||||
|
||||
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find objects by primary key
|
||||
* <code>
|
||||
* $objs = $c->findPks(array(12, 56, 832), $con);
|
||||
* </code>
|
||||
* @param array $keys Primary keys to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
|
||||
*/
|
||||
public function findPks($keys, $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
|
||||
}
|
||||
$this->basePreSelect($con);
|
||||
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
||||
$dataFetcher = $criteria
|
||||
->filterByPrimaryKeys($keys)
|
||||
->doSelect($con);
|
||||
|
||||
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by primary key
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
*
|
||||
* @return ChildShortcutsQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKey($key)
|
||||
{
|
||||
|
||||
return $this->addUsingAlias(ShortcutsTableMap::ID, $key, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a list of primary keys
|
||||
*
|
||||
* @param array $keys The list of primary key to use for the query
|
||||
*
|
||||
* @return ChildShortcutsQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKeys($keys)
|
||||
{
|
||||
|
||||
return $this->addUsingAlias(ShortcutsTableMap::ID, $keys, Criteria::IN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterById(1234); // WHERE id = 1234
|
||||
* $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
|
||||
* $query->filterById(array('min' => 12)); // WHERE id > 12
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $id The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildShortcutsQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterById($id = null, $comparison = null)
|
||||
{
|
||||
if (is_array($id)) {
|
||||
$useMinMax = false;
|
||||
if (isset($id['min'])) {
|
||||
$this->addUsingAlias(ShortcutsTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($id['max'])) {
|
||||
$this->addUsingAlias(ShortcutsTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(ShortcutsTableMap::ID, $id, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the position column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByPosition(1234); // WHERE position = 1234
|
||||
* $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
|
||||
* $query->filterByPosition(array('min' => 12)); // WHERE position > 12
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $position The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildShortcutsQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPosition($position = null, $comparison = null)
|
||||
{
|
||||
if (is_array($position)) {
|
||||
$useMinMax = false;
|
||||
if (isset($position['min'])) {
|
||||
$this->addUsingAlias(ShortcutsTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($position['max'])) {
|
||||
$this->addUsingAlias(ShortcutsTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(ShortcutsTableMap::POSITION, $position, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the url column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByUrl('fooValue'); // WHERE url = 'fooValue'
|
||||
* $query->filterByUrl('%fooValue%'); // WHERE url LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param string $url The value to use as filter.
|
||||
* Accepts wildcards (* and % trigger a LIKE)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildShortcutsQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByUrl($url = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($url)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $url)) {
|
||||
$url = str_replace('*', '%', $url);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(ShortcutsTableMap::URL, $url, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the admin_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByAdminId(1234); // WHERE admin_id = 1234
|
||||
* $query->filterByAdminId(array(12, 34)); // WHERE admin_id IN (12, 34)
|
||||
* $query->filterByAdminId(array('min' => 12)); // WHERE admin_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByAdmin()
|
||||
*
|
||||
* @param mixed $adminId The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildShortcutsQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByAdminId($adminId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($adminId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($adminId['min'])) {
|
||||
$this->addUsingAlias(ShortcutsTableMap::ADMIN_ID, $adminId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($adminId['max'])) {
|
||||
$this->addUsingAlias(ShortcutsTableMap::ADMIN_ID, $adminId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(ShortcutsTableMap::ADMIN_ID, $adminId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Admin object
|
||||
*
|
||||
* @param \Thelia\Model\Admin|ObjectCollection $admin The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildShortcutsQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByAdmin($admin, $comparison = null)
|
||||
{
|
||||
if ($admin instanceof \Thelia\Model\Admin) {
|
||||
return $this
|
||||
->addUsingAlias(ShortcutsTableMap::ADMIN_ID, $admin->getId(), $comparison);
|
||||
} elseif ($admin instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(ShortcutsTableMap::ADMIN_ID, $admin->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByAdmin() only accepts arguments of type \Thelia\Model\Admin or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Admin relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildShortcutsQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinAdmin($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Admin');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'Admin');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Admin relation Admin object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\AdminQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useAdminQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinAdmin($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Admin', '\Thelia\Model\AdminQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Shortcuts\Model\ShortcutsI18n object
|
||||
*
|
||||
* @param \Shortcuts\Model\ShortcutsI18n|ObjectCollection $shortcutsI18n the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildShortcutsQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByShortcutsI18n($shortcutsI18n, $comparison = null)
|
||||
{
|
||||
if ($shortcutsI18n instanceof \Shortcuts\Model\ShortcutsI18n) {
|
||||
return $this
|
||||
->addUsingAlias(ShortcutsTableMap::ID, $shortcutsI18n->getId(), $comparison);
|
||||
} elseif ($shortcutsI18n instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useShortcutsI18nQuery()
|
||||
->filterByPrimaryKeys($shortcutsI18n->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByShortcutsI18n() only accepts arguments of type \Shortcuts\Model\ShortcutsI18n or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the ShortcutsI18n relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildShortcutsQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinShortcutsI18n($relationAlias = null, $joinType = 'LEFT JOIN')
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('ShortcutsI18n');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'ShortcutsI18n');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the ShortcutsI18n relation ShortcutsI18n object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Shortcuts\Model\ShortcutsI18nQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useShortcutsI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
|
||||
{
|
||||
return $this
|
||||
->joinShortcutsI18n($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'ShortcutsI18n', '\Shortcuts\Model\ShortcutsI18nQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
* @param ChildShortcuts $shortcuts Object to remove from the list of results
|
||||
*
|
||||
* @return ChildShortcutsQuery The current query, for fluid interface
|
||||
*/
|
||||
public function prune($shortcuts = null)
|
||||
{
|
||||
if ($shortcuts) {
|
||||
$this->addUsingAlias(ShortcutsTableMap::ID, $shortcuts->getId(), Criteria::NOT_EQUAL);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the shortcuts table.
|
||||
*
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public function doDeleteAll(ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(ShortcutsTableMap::DATABASE_NAME);
|
||||
}
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->beginTransaction();
|
||||
$affectedRows += parent::doDeleteAll($con);
|
||||
// Because this db requires some delete cascade/set null emulation, we have to
|
||||
// clear the cached instance *after* the emulation has happened (since
|
||||
// instances get re-added by the select statement contained therein).
|
||||
ShortcutsTableMap::clearInstancePool();
|
||||
ShortcutsTableMap::clearRelatedInstancePool();
|
||||
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a ChildShortcuts or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or ChildShortcuts object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
|
||||
* if supported by native driver or if emulated using Propel.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public function delete(ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(ShortcutsTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = $this;
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(ShortcutsTableMap::DATABASE_NAME);
|
||||
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->beginTransaction();
|
||||
|
||||
|
||||
ShortcutsTableMap::removeInstanceFromPool($criteria);
|
||||
|
||||
$affectedRows += ModelCriteria::delete($con);
|
||||
ShortcutsTableMap::clearRelatedInstancePool();
|
||||
$con->commit();
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
// i18n behavior
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the i18n relation
|
||||
*
|
||||
* @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
|
||||
*
|
||||
* @return ChildShortcutsQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$relationName = $relationAlias ? $relationAlias : 'ShortcutsI18n';
|
||||
|
||||
return $this
|
||||
->joinShortcutsI18n($relationAlias, $joinType)
|
||||
->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query and hydrates the related I18n object.
|
||||
* Shortcut for $c->joinI18n($locale)->with()
|
||||
*
|
||||
* @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
|
||||
*
|
||||
* @return ChildShortcutsQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$this
|
||||
->joinI18n($locale, null, $joinType)
|
||||
->with('ShortcutsI18n');
|
||||
$this->with['ShortcutsI18n']->setIsWithOneToMany(false);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the I18n relation query object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
|
||||
*
|
||||
* @return ChildShortcutsI18nQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinI18n($locale, $relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'ShortcutsI18n', '\Shortcuts\Model\ShortcutsI18nQuery');
|
||||
}
|
||||
|
||||
} // ShortcutsQuery
|
||||
474
local/modules/Shortcuts/Model/Map/ShortcutsI18nTableMap.php
Normal file
474
local/modules/Shortcuts/Model/Map/ShortcutsI18nTableMap.php
Normal file
@@ -0,0 +1,474 @@
|
||||
<?php
|
||||
|
||||
namespace Shortcuts\Model\Map;
|
||||
|
||||
use Propel\Runtime\Propel;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\DataFetcher\DataFetcherInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Propel\Runtime\Map\RelationMap;
|
||||
use Propel\Runtime\Map\TableMap;
|
||||
use Propel\Runtime\Map\TableMapTrait;
|
||||
use Shortcuts\Model\ShortcutsI18n;
|
||||
use Shortcuts\Model\ShortcutsI18nQuery;
|
||||
|
||||
|
||||
/**
|
||||
* This class defines the structure of the 'shortcuts_i18n' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* This map class is used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
*/
|
||||
class ShortcutsI18nTableMap extends TableMap
|
||||
{
|
||||
use InstancePoolTrait;
|
||||
use TableMapTrait;
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'Shortcuts.Model.Map.ShortcutsI18nTableMap';
|
||||
|
||||
/**
|
||||
* The default database name for this class
|
||||
*/
|
||||
const DATABASE_NAME = 'thelia';
|
||||
|
||||
/**
|
||||
* The table name for this class
|
||||
*/
|
||||
const TABLE_NAME = 'shortcuts_i18n';
|
||||
|
||||
/**
|
||||
* The related Propel class for this table
|
||||
*/
|
||||
const OM_CLASS = '\\Shortcuts\\Model\\ShortcutsI18n';
|
||||
|
||||
/**
|
||||
* A class that can be returned by this tableMap
|
||||
*/
|
||||
const CLASS_DEFAULT = 'Shortcuts.Model.ShortcutsI18n';
|
||||
|
||||
/**
|
||||
* The total number of columns
|
||||
*/
|
||||
const NUM_COLUMNS = 3;
|
||||
|
||||
/**
|
||||
* The number of lazy-loaded columns
|
||||
*/
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
/**
|
||||
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
|
||||
*/
|
||||
const NUM_HYDRATE_COLUMNS = 3;
|
||||
|
||||
/**
|
||||
* the column name for the ID field
|
||||
*/
|
||||
const ID = 'shortcuts_i18n.ID';
|
||||
|
||||
/**
|
||||
* the column name for the LOCALE field
|
||||
*/
|
||||
const LOCALE = 'shortcuts_i18n.LOCALE';
|
||||
|
||||
/**
|
||||
* the column name for the TITLE field
|
||||
*/
|
||||
const TITLE = 'shortcuts_i18n.TITLE';
|
||||
|
||||
/**
|
||||
* The default string format for model objects of the related table
|
||||
*/
|
||||
const DEFAULT_STRING_FORMAT = 'YAML';
|
||||
|
||||
/**
|
||||
* holds an array of fieldnames
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'Locale', 'Title', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', ),
|
||||
self::TYPE_COLNAME => array(ShortcutsI18nTableMap::ID, ShortcutsI18nTableMap::LOCALE, ShortcutsI18nTableMap::TITLE, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'locale', 'title', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, )
|
||||
);
|
||||
|
||||
/**
|
||||
* holds an array of keys for quick access to the fieldnames array
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
protected static $fieldKeys = array (
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, ),
|
||||
self::TYPE_COLNAME => array(ShortcutsI18nTableMap::ID => 0, ShortcutsI18nTableMap::LOCALE => 1, ShortcutsI18nTableMap::TITLE => 2, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, )
|
||||
);
|
||||
|
||||
/**
|
||||
* Initialize the table attributes and columns
|
||||
* Relations are not initialized by this method since they are lazy loaded
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
// attributes
|
||||
$this->setName('shortcuts_i18n');
|
||||
$this->setPhpName('ShortcutsI18n');
|
||||
$this->setClassName('\\Shortcuts\\Model\\ShortcutsI18n');
|
||||
$this->setPackage('Shortcuts.Model');
|
||||
$this->setUseIdGenerator(false);
|
||||
// columns
|
||||
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'shortcuts', 'ID', true, null, null);
|
||||
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
|
||||
$this->addColumn('TITLE', 'Title', 'VARCHAR', true, 255, null);
|
||||
} // initialize()
|
||||
|
||||
/**
|
||||
* Build the RelationMap objects for this table relationships
|
||||
*/
|
||||
public function buildRelations()
|
||||
{
|
||||
$this->addRelation('Shortcuts', '\\Shortcuts\\Model\\Shortcuts', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
|
||||
} // buildRelations()
|
||||
|
||||
/**
|
||||
* Adds an object to the instance pool.
|
||||
*
|
||||
* Propel keeps cached copies of objects in an instance pool when they are retrieved
|
||||
* from the database. In some cases you may need to explicitly add objects
|
||||
* to the cache in order to ensure that the same objects are always returned by find*()
|
||||
* and findPk*() calls.
|
||||
*
|
||||
* @param \Shortcuts\Model\ShortcutsI18n $obj A \Shortcuts\Model\ShortcutsI18n object.
|
||||
* @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
|
||||
*/
|
||||
public static function addInstanceToPool($obj, $key = null)
|
||||
{
|
||||
if (Propel::isInstancePoolingEnabled()) {
|
||||
if (null === $key) {
|
||||
$key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
|
||||
} // if key === null
|
||||
self::$instances[$key] = $obj;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an object from the instance pool.
|
||||
*
|
||||
* Propel keeps cached copies of objects in an instance pool when they are retrieved
|
||||
* from the database. In some cases -- especially when you override doDelete
|
||||
* methods in your stub classes -- you may need to explicitly remove objects
|
||||
* from the cache in order to prevent returning objects that no longer exist.
|
||||
*
|
||||
* @param mixed $value A \Shortcuts\Model\ShortcutsI18n object or a primary key value.
|
||||
*/
|
||||
public static function removeInstanceFromPool($value)
|
||||
{
|
||||
if (Propel::isInstancePoolingEnabled() && null !== $value) {
|
||||
if (is_object($value) && $value instanceof \Shortcuts\Model\ShortcutsI18n) {
|
||||
$key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
|
||||
|
||||
} elseif (is_array($value) && count($value) === 2) {
|
||||
// assume we've been passed a primary key";
|
||||
$key = serialize(array((string) $value[0], (string) $value[1]));
|
||||
} elseif ($value instanceof Criteria) {
|
||||
self::$instances = [];
|
||||
|
||||
return;
|
||||
} else {
|
||||
$e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Shortcuts\Model\ShortcutsI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
|
||||
throw $e;
|
||||
}
|
||||
|
||||
unset(self::$instances[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
|
||||
*
|
||||
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
|
||||
* a multi-column primary key, a serialize()d version of the primary key will be returned.
|
||||
*
|
||||
* @param array $row resultset row.
|
||||
* @param int $offset The 0-based offset for reading from the resultset row.
|
||||
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
|
||||
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
|
||||
*/
|
||||
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
|
||||
{
|
||||
// If the PK cannot be derived from the row, return NULL.
|
||||
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the primary key from the DB resultset row
|
||||
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
|
||||
* a multi-column primary key, an array of the primary key columns will be returned.
|
||||
*
|
||||
* @param array $row resultset row.
|
||||
* @param int $offset The 0-based offset for reading from the resultset row.
|
||||
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
|
||||
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
|
||||
*
|
||||
* @return mixed The primary key of the row
|
||||
*/
|
||||
public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
|
||||
{
|
||||
|
||||
return $pks;
|
||||
}
|
||||
|
||||
/**
|
||||
* The class that the tableMap will make instances of.
|
||||
*
|
||||
* If $withPrefix is true, the returned path
|
||||
* uses a dot-path notation which is translated into a path
|
||||
* relative to a location on the PHP include_path.
|
||||
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
|
||||
*
|
||||
* @param boolean $withPrefix Whether or not to return the path with the class name
|
||||
* @return string path.to.ClassName
|
||||
*/
|
||||
public static function getOMClass($withPrefix = true)
|
||||
{
|
||||
return $withPrefix ? ShortcutsI18nTableMap::CLASS_DEFAULT : ShortcutsI18nTableMap::OM_CLASS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates an object of the default type or an object that inherit from the default.
|
||||
*
|
||||
* @param array $row row returned by DataFetcher->fetch().
|
||||
* @param int $offset The 0-based offset for reading from the resultset row.
|
||||
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
|
||||
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
|
||||
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
|
||||
*
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return array (ShortcutsI18n object, last column rank)
|
||||
*/
|
||||
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
|
||||
{
|
||||
$key = ShortcutsI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
|
||||
if (null !== ($obj = ShortcutsI18nTableMap::getInstanceFromPool($key))) {
|
||||
// We no longer rehydrate the object, since this can cause data loss.
|
||||
// See http://www.propelorm.org/ticket/509
|
||||
// $obj->hydrate($row, $offset, true); // rehydrate
|
||||
$col = $offset + ShortcutsI18nTableMap::NUM_HYDRATE_COLUMNS;
|
||||
} else {
|
||||
$cls = ShortcutsI18nTableMap::OM_CLASS;
|
||||
$obj = new $cls();
|
||||
$col = $obj->hydrate($row, $offset, false, $indexType);
|
||||
ShortcutsI18nTableMap::addInstanceToPool($obj, $key);
|
||||
}
|
||||
|
||||
return array($obj, $col);
|
||||
}
|
||||
|
||||
/**
|
||||
* The returned array will contain objects of the default type or
|
||||
* objects that inherit from the default.
|
||||
*
|
||||
* @param DataFetcherInterface $dataFetcher
|
||||
* @return array
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function populateObjects(DataFetcherInterface $dataFetcher)
|
||||
{
|
||||
$results = array();
|
||||
|
||||
// set the class once to avoid overhead in the loop
|
||||
$cls = static::getOMClass(false);
|
||||
// populate the object(s)
|
||||
while ($row = $dataFetcher->fetch()) {
|
||||
$key = ShortcutsI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
|
||||
if (null !== ($obj = ShortcutsI18nTableMap::getInstanceFromPool($key))) {
|
||||
// We no longer rehydrate the object, since this can cause data loss.
|
||||
// See http://www.propelorm.org/ticket/509
|
||||
// $obj->hydrate($row, 0, true); // rehydrate
|
||||
$results[] = $obj;
|
||||
} else {
|
||||
$obj = new $cls();
|
||||
$obj->hydrate($row);
|
||||
$results[] = $obj;
|
||||
ShortcutsI18nTableMap::addInstanceToPool($obj, $key);
|
||||
} // if key exists
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
/**
|
||||
* Add all the columns needed to create a new object.
|
||||
*
|
||||
* Note: any columns that were marked with lazyLoad="true" in the
|
||||
* XML schema will not be added to the select list and only loaded
|
||||
* on demand.
|
||||
*
|
||||
* @param Criteria $criteria object containing the columns to add.
|
||||
* @param string $alias optional table alias
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function addSelectColumns(Criteria $criteria, $alias = null)
|
||||
{
|
||||
if (null === $alias) {
|
||||
$criteria->addSelectColumn(ShortcutsI18nTableMap::ID);
|
||||
$criteria->addSelectColumn(ShortcutsI18nTableMap::LOCALE);
|
||||
$criteria->addSelectColumn(ShortcutsI18nTableMap::TITLE);
|
||||
} else {
|
||||
$criteria->addSelectColumn($alias . '.ID');
|
||||
$criteria->addSelectColumn($alias . '.LOCALE');
|
||||
$criteria->addSelectColumn($alias . '.TITLE');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TableMap related to this object.
|
||||
* This method is not needed for general use but a specific application could have a need.
|
||||
* @return TableMap
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getTableMap()
|
||||
{
|
||||
return Propel::getServiceContainer()->getDatabaseMap(ShortcutsI18nTableMap::DATABASE_NAME)->getTable(ShortcutsI18nTableMap::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a TableMap instance to the database for this tableMap class.
|
||||
*/
|
||||
public static function buildTableMap()
|
||||
{
|
||||
$dbMap = Propel::getServiceContainer()->getDatabaseMap(ShortcutsI18nTableMap::DATABASE_NAME);
|
||||
if (!$dbMap->hasTable(ShortcutsI18nTableMap::TABLE_NAME)) {
|
||||
$dbMap->addTableObject(new ShortcutsI18nTableMap());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a ShortcutsI18n or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or ShortcutsI18n object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
|
||||
* if supported by native driver or if emulated using Propel.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doDelete($values, ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(ShortcutsI18nTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
// rename for clarity
|
||||
$criteria = $values;
|
||||
} elseif ($values instanceof \Shortcuts\Model\ShortcutsI18n) { // it's a model object
|
||||
// create criteria based on pk values
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else { // it's a primary key, or an array of pks
|
||||
$criteria = new Criteria(ShortcutsI18nTableMap::DATABASE_NAME);
|
||||
// primary key is composite; we therefore, expect
|
||||
// the primary key passed to be an array of pkey values
|
||||
if (count($values) == count($values, COUNT_RECURSIVE)) {
|
||||
// array is not multi-dimensional
|
||||
$values = array($values);
|
||||
}
|
||||
foreach ($values as $value) {
|
||||
$criterion = $criteria->getNewCriterion(ShortcutsI18nTableMap::ID, $value[0]);
|
||||
$criterion->addAnd($criteria->getNewCriterion(ShortcutsI18nTableMap::LOCALE, $value[1]));
|
||||
$criteria->addOr($criterion);
|
||||
}
|
||||
}
|
||||
|
||||
$query = ShortcutsI18nQuery::create()->mergeWith($criteria);
|
||||
|
||||
if ($values instanceof Criteria) { ShortcutsI18nTableMap::clearInstancePool();
|
||||
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
|
||||
foreach ((array) $values as $singleval) { ShortcutsI18nTableMap::removeInstanceFromPool($singleval);
|
||||
}
|
||||
}
|
||||
|
||||
return $query->delete($con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the shortcuts_i18n table.
|
||||
*
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public static function doDeleteAll(ConnectionInterface $con = null)
|
||||
{
|
||||
return ShortcutsI18nQuery::create()->doDeleteAll($con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an INSERT on the database, given a ShortcutsI18n or Criteria object.
|
||||
*
|
||||
* @param mixed $criteria Criteria or ShortcutsI18n object containing data that is used to create the INSERT statement.
|
||||
* @param ConnectionInterface $con the ConnectionInterface connection to use
|
||||
* @return mixed The new primary key.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doInsert($criteria, ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(ShortcutsI18nTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($criteria instanceof Criteria) {
|
||||
$criteria = clone $criteria; // rename for clarity
|
||||
} else {
|
||||
$criteria = $criteria->buildCriteria(); // build Criteria from ShortcutsI18n object
|
||||
}
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$query = ShortcutsI18nQuery::create()->mergeWith($criteria);
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table (I guess, conceivably)
|
||||
$con->beginTransaction();
|
||||
$pk = $query->doInsert($con);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
} // ShortcutsI18nTableMap
|
||||
// This is the static code needed to register the TableMap for this table with the main Propel class.
|
||||
//
|
||||
ShortcutsI18nTableMap::buildTableMap();
|
||||
459
local/modules/Shortcuts/Model/Map/ShortcutsTableMap.php
Normal file
459
local/modules/Shortcuts/Model/Map/ShortcutsTableMap.php
Normal file
@@ -0,0 +1,459 @@
|
||||
<?php
|
||||
|
||||
namespace Shortcuts\Model\Map;
|
||||
|
||||
use Propel\Runtime\Propel;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\DataFetcher\DataFetcherInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Propel\Runtime\Map\RelationMap;
|
||||
use Propel\Runtime\Map\TableMap;
|
||||
use Propel\Runtime\Map\TableMapTrait;
|
||||
use Shortcuts\Model\Shortcuts;
|
||||
use Shortcuts\Model\ShortcutsQuery;
|
||||
|
||||
|
||||
/**
|
||||
* This class defines the structure of the 'shortcuts' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* This map class is used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
*/
|
||||
class ShortcutsTableMap extends TableMap
|
||||
{
|
||||
use InstancePoolTrait;
|
||||
use TableMapTrait;
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'Shortcuts.Model.Map.ShortcutsTableMap';
|
||||
|
||||
/**
|
||||
* The default database name for this class
|
||||
*/
|
||||
const DATABASE_NAME = 'thelia';
|
||||
|
||||
/**
|
||||
* The table name for this class
|
||||
*/
|
||||
const TABLE_NAME = 'shortcuts';
|
||||
|
||||
/**
|
||||
* The related Propel class for this table
|
||||
*/
|
||||
const OM_CLASS = '\\Shortcuts\\Model\\Shortcuts';
|
||||
|
||||
/**
|
||||
* A class that can be returned by this tableMap
|
||||
*/
|
||||
const CLASS_DEFAULT = 'Shortcuts.Model.Shortcuts';
|
||||
|
||||
/**
|
||||
* The total number of columns
|
||||
*/
|
||||
const NUM_COLUMNS = 4;
|
||||
|
||||
/**
|
||||
* The number of lazy-loaded columns
|
||||
*/
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
/**
|
||||
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
|
||||
*/
|
||||
const NUM_HYDRATE_COLUMNS = 4;
|
||||
|
||||
/**
|
||||
* the column name for the ID field
|
||||
*/
|
||||
const ID = 'shortcuts.ID';
|
||||
|
||||
/**
|
||||
* the column name for the POSITION field
|
||||
*/
|
||||
const POSITION = 'shortcuts.POSITION';
|
||||
|
||||
/**
|
||||
* the column name for the URL field
|
||||
*/
|
||||
const URL = 'shortcuts.URL';
|
||||
|
||||
/**
|
||||
* the column name for the ADMIN_ID field
|
||||
*/
|
||||
const ADMIN_ID = 'shortcuts.ADMIN_ID';
|
||||
|
||||
/**
|
||||
* The default string format for model objects of the related table
|
||||
*/
|
||||
const DEFAULT_STRING_FORMAT = 'YAML';
|
||||
|
||||
// i18n behavior
|
||||
|
||||
/**
|
||||
* The default locale to use for translations.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const DEFAULT_LOCALE = 'en_US';
|
||||
|
||||
/**
|
||||
* holds an array of fieldnames
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'Position', 'Url', 'AdminId', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'position', 'url', 'adminId', ),
|
||||
self::TYPE_COLNAME => array(ShortcutsTableMap::ID, ShortcutsTableMap::POSITION, ShortcutsTableMap::URL, ShortcutsTableMap::ADMIN_ID, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'POSITION', 'URL', 'ADMIN_ID', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'position', 'url', 'admin_id', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, )
|
||||
);
|
||||
|
||||
/**
|
||||
* holds an array of keys for quick access to the fieldnames array
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
protected static $fieldKeys = array (
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'Position' => 1, 'Url' => 2, 'AdminId' => 3, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'position' => 1, 'url' => 2, 'adminId' => 3, ),
|
||||
self::TYPE_COLNAME => array(ShortcutsTableMap::ID => 0, ShortcutsTableMap::POSITION => 1, ShortcutsTableMap::URL => 2, ShortcutsTableMap::ADMIN_ID => 3, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'POSITION' => 1, 'URL' => 2, 'ADMIN_ID' => 3, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'position' => 1, 'url' => 2, 'admin_id' => 3, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, )
|
||||
);
|
||||
|
||||
/**
|
||||
* Initialize the table attributes and columns
|
||||
* Relations are not initialized by this method since they are lazy loaded
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
// attributes
|
||||
$this->setName('shortcuts');
|
||||
$this->setPhpName('Shortcuts');
|
||||
$this->setClassName('\\Shortcuts\\Model\\Shortcuts');
|
||||
$this->setPackage('Shortcuts.Model');
|
||||
$this->setUseIdGenerator(true);
|
||||
// columns
|
||||
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
|
||||
$this->addColumn('POSITION', 'Position', 'INTEGER', true, null, 0);
|
||||
$this->addColumn('URL', 'Url', 'VARCHAR', true, 255, null);
|
||||
$this->addForeignKey('ADMIN_ID', 'AdminId', 'INTEGER', 'admin', 'ID', false, null, null);
|
||||
} // initialize()
|
||||
|
||||
/**
|
||||
* Build the RelationMap objects for this table relationships
|
||||
*/
|
||||
public function buildRelations()
|
||||
{
|
||||
$this->addRelation('Admin', '\\Thelia\\Model\\Admin', RelationMap::MANY_TO_ONE, array('admin_id' => 'id', ), 'CASCADE', 'RESTRICT');
|
||||
$this->addRelation('ShortcutsI18n', '\\Shortcuts\\Model\\ShortcutsI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ShortcutsI18ns');
|
||||
} // buildRelations()
|
||||
|
||||
/**
|
||||
*
|
||||
* Gets the list of behaviors registered for this table
|
||||
*
|
||||
* @return array Associative array (name => parameters) of behaviors
|
||||
*/
|
||||
public function getBehaviors()
|
||||
{
|
||||
return array(
|
||||
'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
|
||||
);
|
||||
} // getBehaviors()
|
||||
/**
|
||||
* Method to invalidate the instance pool of all tables related to shortcuts * by a foreign key with ON DELETE CASCADE
|
||||
*/
|
||||
public static function clearRelatedInstancePool()
|
||||
{
|
||||
// Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
|
||||
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
|
||||
ShortcutsI18nTableMap::clearInstancePool();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
|
||||
*
|
||||
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
|
||||
* a multi-column primary key, a serialize()d version of the primary key will be returned.
|
||||
*
|
||||
* @param array $row resultset row.
|
||||
* @param int $offset The 0-based offset for reading from the resultset row.
|
||||
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
|
||||
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
|
||||
*/
|
||||
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
|
||||
{
|
||||
// If the PK cannot be derived from the row, return NULL.
|
||||
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the primary key from the DB resultset row
|
||||
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
|
||||
* a multi-column primary key, an array of the primary key columns will be returned.
|
||||
*
|
||||
* @param array $row resultset row.
|
||||
* @param int $offset The 0-based offset for reading from the resultset row.
|
||||
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
|
||||
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
|
||||
*
|
||||
* @return mixed The primary key of the row
|
||||
*/
|
||||
public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
|
||||
{
|
||||
|
||||
return (int) $row[
|
||||
$indexType == TableMap::TYPE_NUM
|
||||
? 0 + $offset
|
||||
: self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The class that the tableMap will make instances of.
|
||||
*
|
||||
* If $withPrefix is true, the returned path
|
||||
* uses a dot-path notation which is translated into a path
|
||||
* relative to a location on the PHP include_path.
|
||||
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
|
||||
*
|
||||
* @param boolean $withPrefix Whether or not to return the path with the class name
|
||||
* @return string path.to.ClassName
|
||||
*/
|
||||
public static function getOMClass($withPrefix = true)
|
||||
{
|
||||
return $withPrefix ? ShortcutsTableMap::CLASS_DEFAULT : ShortcutsTableMap::OM_CLASS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates an object of the default type or an object that inherit from the default.
|
||||
*
|
||||
* @param array $row row returned by DataFetcher->fetch().
|
||||
* @param int $offset The 0-based offset for reading from the resultset row.
|
||||
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
|
||||
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
|
||||
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
|
||||
*
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return array (Shortcuts object, last column rank)
|
||||
*/
|
||||
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
|
||||
{
|
||||
$key = ShortcutsTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
|
||||
if (null !== ($obj = ShortcutsTableMap::getInstanceFromPool($key))) {
|
||||
// We no longer rehydrate the object, since this can cause data loss.
|
||||
// See http://www.propelorm.org/ticket/509
|
||||
// $obj->hydrate($row, $offset, true); // rehydrate
|
||||
$col = $offset + ShortcutsTableMap::NUM_HYDRATE_COLUMNS;
|
||||
} else {
|
||||
$cls = ShortcutsTableMap::OM_CLASS;
|
||||
$obj = new $cls();
|
||||
$col = $obj->hydrate($row, $offset, false, $indexType);
|
||||
ShortcutsTableMap::addInstanceToPool($obj, $key);
|
||||
}
|
||||
|
||||
return array($obj, $col);
|
||||
}
|
||||
|
||||
/**
|
||||
* The returned array will contain objects of the default type or
|
||||
* objects that inherit from the default.
|
||||
*
|
||||
* @param DataFetcherInterface $dataFetcher
|
||||
* @return array
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function populateObjects(DataFetcherInterface $dataFetcher)
|
||||
{
|
||||
$results = array();
|
||||
|
||||
// set the class once to avoid overhead in the loop
|
||||
$cls = static::getOMClass(false);
|
||||
// populate the object(s)
|
||||
while ($row = $dataFetcher->fetch()) {
|
||||
$key = ShortcutsTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
|
||||
if (null !== ($obj = ShortcutsTableMap::getInstanceFromPool($key))) {
|
||||
// We no longer rehydrate the object, since this can cause data loss.
|
||||
// See http://www.propelorm.org/ticket/509
|
||||
// $obj->hydrate($row, 0, true); // rehydrate
|
||||
$results[] = $obj;
|
||||
} else {
|
||||
$obj = new $cls();
|
||||
$obj->hydrate($row);
|
||||
$results[] = $obj;
|
||||
ShortcutsTableMap::addInstanceToPool($obj, $key);
|
||||
} // if key exists
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
/**
|
||||
* Add all the columns needed to create a new object.
|
||||
*
|
||||
* Note: any columns that were marked with lazyLoad="true" in the
|
||||
* XML schema will not be added to the select list and only loaded
|
||||
* on demand.
|
||||
*
|
||||
* @param Criteria $criteria object containing the columns to add.
|
||||
* @param string $alias optional table alias
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function addSelectColumns(Criteria $criteria, $alias = null)
|
||||
{
|
||||
if (null === $alias) {
|
||||
$criteria->addSelectColumn(ShortcutsTableMap::ID);
|
||||
$criteria->addSelectColumn(ShortcutsTableMap::POSITION);
|
||||
$criteria->addSelectColumn(ShortcutsTableMap::URL);
|
||||
$criteria->addSelectColumn(ShortcutsTableMap::ADMIN_ID);
|
||||
} else {
|
||||
$criteria->addSelectColumn($alias . '.ID');
|
||||
$criteria->addSelectColumn($alias . '.POSITION');
|
||||
$criteria->addSelectColumn($alias . '.URL');
|
||||
$criteria->addSelectColumn($alias . '.ADMIN_ID');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TableMap related to this object.
|
||||
* This method is not needed for general use but a specific application could have a need.
|
||||
* @return TableMap
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getTableMap()
|
||||
{
|
||||
return Propel::getServiceContainer()->getDatabaseMap(ShortcutsTableMap::DATABASE_NAME)->getTable(ShortcutsTableMap::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a TableMap instance to the database for this tableMap class.
|
||||
*/
|
||||
public static function buildTableMap()
|
||||
{
|
||||
$dbMap = Propel::getServiceContainer()->getDatabaseMap(ShortcutsTableMap::DATABASE_NAME);
|
||||
if (!$dbMap->hasTable(ShortcutsTableMap::TABLE_NAME)) {
|
||||
$dbMap->addTableObject(new ShortcutsTableMap());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a Shortcuts or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or Shortcuts object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
|
||||
* if supported by native driver or if emulated using Propel.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doDelete($values, ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(ShortcutsTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
// rename for clarity
|
||||
$criteria = $values;
|
||||
} elseif ($values instanceof \Shortcuts\Model\Shortcuts) { // it's a model object
|
||||
// create criteria based on pk values
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else { // it's a primary key, or an array of pks
|
||||
$criteria = new Criteria(ShortcutsTableMap::DATABASE_NAME);
|
||||
$criteria->add(ShortcutsTableMap::ID, (array) $values, Criteria::IN);
|
||||
}
|
||||
|
||||
$query = ShortcutsQuery::create()->mergeWith($criteria);
|
||||
|
||||
if ($values instanceof Criteria) { ShortcutsTableMap::clearInstancePool();
|
||||
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
|
||||
foreach ((array) $values as $singleval) { ShortcutsTableMap::removeInstanceFromPool($singleval);
|
||||
}
|
||||
}
|
||||
|
||||
return $query->delete($con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the shortcuts table.
|
||||
*
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public static function doDeleteAll(ConnectionInterface $con = null)
|
||||
{
|
||||
return ShortcutsQuery::create()->doDeleteAll($con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an INSERT on the database, given a Shortcuts or Criteria object.
|
||||
*
|
||||
* @param mixed $criteria Criteria or Shortcuts object containing data that is used to create the INSERT statement.
|
||||
* @param ConnectionInterface $con the ConnectionInterface connection to use
|
||||
* @return mixed The new primary key.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doInsert($criteria, ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(ShortcutsTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($criteria instanceof Criteria) {
|
||||
$criteria = clone $criteria; // rename for clarity
|
||||
} else {
|
||||
$criteria = $criteria->buildCriteria(); // build Criteria from Shortcuts object
|
||||
}
|
||||
|
||||
if ($criteria->containsKey(ShortcutsTableMap::ID) && $criteria->keyContainsValue(ShortcutsTableMap::ID) ) {
|
||||
throw new PropelException('Cannot insert a value for auto-increment primary key ('.ShortcutsTableMap::ID.')');
|
||||
}
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$query = ShortcutsQuery::create()->mergeWith($criteria);
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table (I guess, conceivably)
|
||||
$con->beginTransaction();
|
||||
$pk = $query->doInsert($con);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
} // ShortcutsTableMap
|
||||
// This is the static code needed to register the TableMap for this table with the main Propel class.
|
||||
//
|
||||
ShortcutsTableMap::buildTableMap();
|
||||
10
local/modules/Shortcuts/Model/Shortcuts.php
Normal file
10
local/modules/Shortcuts/Model/Shortcuts.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Shortcuts\Model;
|
||||
|
||||
use Shortcuts\Model\Base\Shortcuts as BaseShortcuts;
|
||||
|
||||
class Shortcuts extends BaseShortcuts
|
||||
{
|
||||
|
||||
}
|
||||
10
local/modules/Shortcuts/Model/ShortcutsI18n.php
Normal file
10
local/modules/Shortcuts/Model/ShortcutsI18n.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Shortcuts\Model;
|
||||
|
||||
use Shortcuts\Model\Base\ShortcutsI18n as BaseShortcutsI18n;
|
||||
|
||||
class ShortcutsI18n extends BaseShortcutsI18n
|
||||
{
|
||||
|
||||
}
|
||||
21
local/modules/Shortcuts/Model/ShortcutsI18nQuery.php
Normal file
21
local/modules/Shortcuts/Model/ShortcutsI18nQuery.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Shortcuts\Model;
|
||||
|
||||
use Shortcuts\Model\Base\ShortcutsI18nQuery as BaseShortcutsI18nQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'shortcuts_i18n' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* You should add additional methods to this class to meet the
|
||||
* application requirements. This class will only be generated as
|
||||
* long as it does not already exist in the output directory.
|
||||
*
|
||||
*/
|
||||
class ShortcutsI18nQuery extends BaseShortcutsI18nQuery
|
||||
{
|
||||
|
||||
} // ShortcutsI18nQuery
|
||||
21
local/modules/Shortcuts/Model/ShortcutsQuery.php
Normal file
21
local/modules/Shortcuts/Model/ShortcutsQuery.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Shortcuts\Model;
|
||||
|
||||
use Shortcuts\Model\Base\ShortcutsQuery as BaseShortcutsQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'shortcuts' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* You should add additional methods to this class to meet the
|
||||
* application requirements. This class will only be generated as
|
||||
* long as it does not already exist in the output directory.
|
||||
*
|
||||
*/
|
||||
class ShortcutsQuery extends BaseShortcutsQuery
|
||||
{
|
||||
|
||||
} // ShortcutsQuery
|
||||
150
local/modules/Shortcuts/Readme.md
Normal file
150
local/modules/Shortcuts/Readme.md
Normal file
@@ -0,0 +1,150 @@
|
||||
# Shortcuts (EN)
|
||||
|
||||
This module allows users to add shortcuts to Thelia's backoffice. You can then quickly go to any backoffice pages.
|
||||
|
||||
## Installation
|
||||
|
||||
### Manually
|
||||
|
||||
* Copy the module into ```<thelia_root>/local/modules/``` directory and be sure that the name of the module is Shortcuts.
|
||||
* Activate it in your Thelia administration panel
|
||||
|
||||
OR
|
||||
|
||||
* From the modules pages, in the "Install or Update a module section", browse to the module zip file (Shortcuts.zip) on your filesystem and click install
|
||||
* Activate the module in the administration panel
|
||||
|
||||
A link to the shortcuts configuration page is automatically added on module's installation.
|
||||
|
||||
## Usage
|
||||
|
||||
This module adds a "Shortcuts" menu item in backoffice (located in the top navigation menu). A click on this menu item show all user defined shortcuts in a dropdown menu.
|
||||
|
||||
To add a shortcut:
|
||||
|
||||
1. Go to the backoffice page you want to bookmark
|
||||
2. Copy the page url (/admin/configuration/advanced for example)
|
||||
3. Go the the Shortcuts settings pages and click on the + button
|
||||
4. Enter a shortcut name in the shotcut title field
|
||||
5. Paste the previously copied url in the shortcut url field
|
||||
|
||||
|
||||
## Hook
|
||||
|
||||
The module use the main.topbar-top hook to display the shortcuts in the backoffice
|
||||
|
||||
|
||||
|
||||
## The `shortcuts` loop
|
||||
|
||||
{loop type="shortcuts" name="my-loop-name" user_id={admin attr="id"}}...{/loop}
|
||||
|
||||
|
||||
### Input arguments
|
||||
|
||||
|Argument |Description |
|
||||
|--- |--- |
|
||||
|**user_id** | An admin id |
|
||||
|
||||
### Output arguments
|
||||
|
||||
|Variable |Description |
|
||||
|--- |--- |
|
||||
|$ID | The shortcuts ID |
|
||||
|$TITLE | The shortcut's dropdown menu title |
|
||||
|$URL | The backoffice page url the shortcut leads to |
|
||||
|$ADMIN_ID | Admin user id |
|
||||
|$POSITION | Shortcut position |
|
||||
|
||||
### Example
|
||||
```
|
||||
{loop type="shortcuts" name="user-shortcuts" user_id={admin attr="id"}}
|
||||
<li>
|
||||
<a href="{$URL}" title="{$TITLE}">
|
||||
{$TITLE}
|
||||
</a>
|
||||
</li>
|
||||
{/loop}
|
||||
```
|
||||
|
||||
## TODO
|
||||
|
||||
* Manage shortcut position in the list
|
||||
* Manage shortcuts loop order argument
|
||||
* Allow shortcut edit
|
||||
* Add a bookmark this page button
|
||||
|
||||
- - -
|
||||
|
||||
# Shortcuts (FR)
|
||||
|
||||
Ce module permet aux utilisateurs du backoffice d'ajouter des raccourcis vers des pages spécifiques afin d'accélérer la navigation au sein du backoffice.
|
||||
|
||||
## Installation manuelle
|
||||
|
||||
* Copier le module dans le dossier ```<thelia_root>/local/modules/``` en vous assurant que le nom du dossier du module est bien **Shortcuts**
|
||||
* Activer le module dans le panneau d'administration de Thelia (Panneau d'administration > Modules)
|
||||
|
||||
OU
|
||||
|
||||
* Depuis la page Modules, dans la section "Installer ou mettre à jour", choisissez le fichier ZIP du module et cliquez sur le bouton "Installer"
|
||||
* Activer le module dans le panneau d'administration de Thelia (Panneau d'administration > Modules)
|
||||
|
||||
Un lien vers la page de configuration des raccourcis est automatiquement ajouté lors de l'installation du module.
|
||||
|
||||
## Utilisation
|
||||
|
||||
Le module ajoute un menu "Raccourcis" dans le menu de navigation supérier de thelia. Un clic sur ce menu affiche la liste des raccourcis existants dans un menu déroulant
|
||||
|
||||
Pour ajouter un raccourci:
|
||||
|
||||
1. Rendeez vous sur la page que vous souhaitez ajouter en raccourci
|
||||
2. Copiez l'url de la page (/admin/configuration/advanced par exemple)
|
||||
3. Rendez vous sur la page de configuration des raccourcis et cliquez sur le bouton +
|
||||
4. Saisissez le nom du raccourci
|
||||
5. Coller l'url précédemment copiée dans le champ "Url du raccourci"
|
||||
|
||||
|
||||
## Hook
|
||||
|
||||
Le module utilise le hook bouclemain.topbar-top pour afficher la liste des raccourci dans le menu supérieur.
|
||||
|
||||
|
||||
## La boucle `shortcuts`
|
||||
|
||||
{loop type="shortcuts" name="nom-de-" user_id={admin attr="id"}}...{/loop}
|
||||
|
||||
|
||||
### Paramètres
|
||||
|
||||
|Argument |Description |
|
||||
|--- |--- |
|
||||
|**user_id** | Identifiant de l'utilisateur backoffice |
|
||||
|
||||
### Variables retournées
|
||||
|
||||
|Variable |Description |
|
||||
|--- |--- |
|
||||
|$ID | L'identifiant du raccourci en base de données |
|
||||
|$TITLE | le titre du raccourci |
|
||||
|$URL | L'url de la page du backoffice vers laquelle le raccourci redirige |
|
||||
|$ADMIN_ID | L'identifiant de l'utilisateur du backoffice |
|
||||
|$POSITION | La position du raccourci |
|
||||
|
||||
### Exemple
|
||||
```
|
||||
{loop type="shortcuts" name="user-shortcuts" user_id={admin attr="id"}}
|
||||
<li>
|
||||
<a href="{$URL}" title="{$TITLE}">
|
||||
{$TITLE}
|
||||
</a>
|
||||
</li>
|
||||
{/loop}
|
||||
```
|
||||
|
||||
## TODO
|
||||
|
||||
* Gérer la position du raccourci dans la liste
|
||||
* Permettre le classement des raccourcis retournés par la boucle
|
||||
* Permettre la modification d'un raccourci
|
||||
* Ajouter un bouton "Ajouter cette page aux raccourcis"
|
||||
62
local/modules/Shortcuts/Shortcuts.php
Normal file
62
local/modules/Shortcuts/Shortcuts.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Shortcuts;
|
||||
|
||||
use Thelia\Module\BaseModule;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Propel;
|
||||
use Thelia\Install\Database;
|
||||
|
||||
use Shortcuts\Model\Shortcuts as Shortcut;
|
||||
use Shortcuts\Model\ShortcutsQuery;
|
||||
|
||||
class Shortcuts extends BaseModule
|
||||
{
|
||||
/** @var string */
|
||||
const DOMAIN_NAME = 'shortcuts';
|
||||
const MODULE_DOMAIN = 'shortcuts';
|
||||
|
||||
/*
|
||||
* You may now override BaseModuleInterface methods, such as:
|
||||
* install, destroy, preActivation, postActivation, preDeactivation, postDeactivation
|
||||
*
|
||||
* Have fun !
|
||||
*/
|
||||
/**
|
||||
* @param ConnectionInterface|null $con
|
||||
* @throws \Propel\Runtime\Exception\PropelException
|
||||
*/
|
||||
public function postActivation(ConnectionInterface $con = null)
|
||||
{
|
||||
// Once activated, create the module schema in the Thelia database.
|
||||
$database = new Database($con);
|
||||
|
||||
try {
|
||||
ShortcutsQuery::create()->findOne();
|
||||
} catch (\Exception $e) {
|
||||
// Create modules' tables
|
||||
$database->insertSql(null, array(
|
||||
__DIR__ . DS . 'Config'.DS.'thelia.sql' // The module schema
|
||||
));
|
||||
|
||||
// Add a default shortcut
|
||||
$shortcut = new Shortcut();
|
||||
$shortcut->setUrl('/admin/module/Shortcuts');
|
||||
$shortcut->setLocale('en_US');
|
||||
$shortcut->setTitle('Shortcuts settings');
|
||||
$shortcut->setLocale('fr_FR');
|
||||
$shortcut->setTitle('Configurtation des raccourcis');
|
||||
$shortcut->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
local/modules/Shortcuts/composer.json
Normal file
11
local/modules/Shortcuts/composer.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "your-vendor/shortcuts-module",
|
||||
"license": "LGPL-3.0+",
|
||||
"type": "thelia-module",
|
||||
"require": {
|
||||
"thelia/installer": "~1.1"
|
||||
},
|
||||
"extra": {
|
||||
"installer-name": "Shortcuts"
|
||||
}
|
||||
}
|
||||
BIN
local/modules/Shortcuts/screenshots/add_shortcut.jpg
Normal file
BIN
local/modules/Shortcuts/screenshots/add_shortcut.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 134 KiB |
BIN
local/modules/Shortcuts/screenshots/shortcuts_settings.jpg
Normal file
BIN
local/modules/Shortcuts/screenshots/shortcuts_settings.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 132 KiB |
@@ -0,0 +1,26 @@
|
||||
{*{default_translation_domain domain='shortcuts.bo.default'}*}
|
||||
|
||||
<li class="dropdown">
|
||||
<button class="dropdown-toggle" data-toggle="dropdown">
|
||||
{intl l="Shortcuts"}
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
{ifloop rel="user-shortcuts"}
|
||||
{loop type="shortcuts" name="user-shortcuts" user_id={admin attr="id"}}
|
||||
<li>
|
||||
<a href="{$URL}" title="{$TITLE}">
|
||||
{$TITLE}
|
||||
</a>
|
||||
</li>
|
||||
{/loop}
|
||||
{/ifloop}
|
||||
{elseloop rel="user-shortcuts"}
|
||||
<li>
|
||||
<a href="#" title="{intl l="No shortcuts found"}">
|
||||
{intl l="No shortcuts found"}
|
||||
</a>
|
||||
</li>
|
||||
{/elseloop}
|
||||
</ul>
|
||||
</li>
|
||||
@@ -0,0 +1,192 @@
|
||||
{extends file="admin-layout.tpl"}
|
||||
|
||||
{block name="page-title"}
|
||||
{intl l='Shortcuts settings'}
|
||||
{/block}
|
||||
|
||||
{block name="main-content"}
|
||||
<div class="orders">
|
||||
|
||||
<div id="wrapper" class="container">
|
||||
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="/admin/home">{intl l="Home"}</a></li>
|
||||
<li><a href="/admin/modules">{intl l="Modules"}</a></li>
|
||||
<li>{intl l="Shortcuts settings"}</li>
|
||||
</ul>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="general-block-decorator">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-condensed table-left-aligned">
|
||||
<caption class="clearfix">
|
||||
{intl l="Existing shortcuts"}
|
||||
<a class="btn btn-primary action-btn" title="Add a new folder" href="#shortcut_creation_dialog" data-toggle="modal">
|
||||
<span class="glyphicon glyphicon-plus-sign"></span>
|
||||
</a>
|
||||
</caption>
|
||||
{ifloop rel="user-shortcuts"}
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="object-title">ID</th>
|
||||
|
||||
<th class="object-title">{intl l="Shortcut title"}</th>
|
||||
|
||||
<th class="object-title">{intl l="URL"}</th>
|
||||
|
||||
<th class="object-title text-right">{intl l="Actions"}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{loop type="shortcuts" name="user-shortcuts" user_id=1}
|
||||
<tr>
|
||||
<td>{$ID}</td>
|
||||
<td><a href="{$URL}">{$TITLE}</a></td>
|
||||
<td>{$URL}</td>
|
||||
<td class="actions">
|
||||
<div class="btn-toolbar btn toolbar-primary">
|
||||
<span class="glyphicon glyphicon-cog"></span>
|
||||
</div>
|
||||
<div class="toolbar-options hidden">
|
||||
{* <a title="{intl l="Edit this shortcut"}" href="http://mondialcity/admin/shortcuts/update?shortcut_id={$ID}"><span class="glyphicon glyphicon-edit"></span></a> *}
|
||||
|
||||
<a class="shortcut-delete" title="{intl l="Delete this shortcut"}" href="#shortcut_delete_dialog" data-id="{$ID}" data-toggle="modal"><span class="glyphicon glyphicon-trash"></span></a>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{/loop}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="100">
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
{/ifloop}
|
||||
|
||||
{elseloop rel="user-shortcuts"}
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="message">
|
||||
<div class="alert alert-info">
|
||||
{intl l="No shortcuts found. To create a new one, click the + button above."}
|
||||
</div>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{/elseloop}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{* -- Adding a new category ------------------------------------------------- *}
|
||||
|
||||
{form name="thelia.admin.shortcut.creation"}
|
||||
|
||||
{* Capture the dialog body, to pass it to the generic dialog *}
|
||||
{capture "shortcut_creation_dialog"}
|
||||
|
||||
{form_hidden_fields }
|
||||
|
||||
<input type="hidden" {form_field_attributes field='title' value={$shortcut_id}}>
|
||||
|
||||
{* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *}
|
||||
{render_form_field field="success_url" value={url path='/admin/modules/shortcuts' shortcut_id='_ID_'}}
|
||||
|
||||
{custom_render_form_field field="title"}
|
||||
{loop type="lang" name="default-lang" default_only="1"}
|
||||
<div class="input-group">
|
||||
<input type="text" {form_field_attributes field="title"}>
|
||||
<span class="input-group-addon"><img src="{image file="assets/img/flags/$CODE.png"}" alt="{$TITLE}" /></span>
|
||||
</div>
|
||||
|
||||
{* Switch edition to the current locale *}
|
||||
<input type="hidden" name="edit_language_id" value="{$ID}" />
|
||||
|
||||
{render_form_field field="locale" value=$LOCALE}
|
||||
{/loop}
|
||||
{/custom_render_form_field}
|
||||
|
||||
{form_field field="shortcut_url"}
|
||||
<label for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
|
||||
<input type="text" {form_field_attributes field="shortcut_url"}>
|
||||
{/form_field}
|
||||
|
||||
{* {form_field field="visible"}
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" checked name="{$name}" value="1"> {$label}
|
||||
</label>
|
||||
{/form_field} *}
|
||||
|
||||
{* {hook name="category.create-form" location="shortcut_create_form" } *}
|
||||
|
||||
{/capture}
|
||||
|
||||
{include
|
||||
file = "includes/generic-create-dialog.html"
|
||||
|
||||
dialog_id = "shortcut_creation_dialog"
|
||||
dialog_title = {intl l="Create a shortcut"}
|
||||
dialog_body = {$smarty.capture.shortcut_creation_dialog nofilter}
|
||||
|
||||
dialog_ok_label = {intl l="Add shortcut"}
|
||||
|
||||
form_action = {url route_id='shortcuts.create-shortcut' router='shortcuts'}
|
||||
form_enctype = {form_enctype}
|
||||
form_error_message = $form_error_message
|
||||
}
|
||||
{/form}
|
||||
|
||||
{* -- Delete category confirmation dialog ----------------------------------- *}
|
||||
|
||||
{capture "shortcut_delete_dialog"}
|
||||
<input type="hidden" name="shortcut_id" id="shortcut_delete_id" value="" />
|
||||
{/capture}
|
||||
|
||||
{include
|
||||
file = "includes/generic-confirm-dialog.html"
|
||||
|
||||
dialog_id = "shortcut_delete_dialog"
|
||||
dialog_title = {intl l="Delete shortcut"}
|
||||
dialog_message = {intl l="Do you really want to delete this shortcut?"}
|
||||
|
||||
form_action = {token_url router="shortcuts" route_id='shortcuts.delete-shortcut'}
|
||||
form_content = {$smarty.capture.shortcut_delete_dialog nofilter}
|
||||
}
|
||||
{/block}
|
||||
|
||||
{block name="javascript-initialization"}
|
||||
|
||||
{javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
|
||||
{javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
{javascripts file='assets/js/jquery.typewatch.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
<script>
|
||||
$(function() {
|
||||
|
||||
// Set proper category ID in delete from
|
||||
$('a.shortcut-delete').click(function(ev) {
|
||||
$('#shortcut_delete_id').val($(this).data('id'));
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
|
||||
{block name="javascript-last-call"}
|
||||
{* {hook name="categories.js" location="categories-js" } *}
|
||||
{/block}
|
||||
Reference in New Issue
Block a user