first commit
This commit is contained in:
155
plugins/stThemePlugin/lib/config/stThemeConfig.class.php
Normal file
155
plugins/stThemePlugin/lib/config/stThemeConfig.class.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
class stThemeConfig
|
||||
{
|
||||
protected $themeConfig = null;
|
||||
|
||||
protected $config = array();
|
||||
|
||||
protected $categories = array();
|
||||
|
||||
public function load(ThemeConfig $theme_config)
|
||||
{
|
||||
$this->themeConfig = $theme_config;
|
||||
|
||||
$files = $this->findYamls($theme_config->getTheme());
|
||||
|
||||
$this->config = $this->parseYamls($files);
|
||||
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
public function getThemeConfig()
|
||||
{
|
||||
return $this->themeConfig;
|
||||
}
|
||||
|
||||
public function get($name, $default = null)
|
||||
{
|
||||
return isset($this->config[$name]) ? $this->config[$name] : $default;
|
||||
}
|
||||
|
||||
public function getCategories($name)
|
||||
{
|
||||
if (!isset($this->categories[$name]))
|
||||
{
|
||||
$scope = $this->get($name);
|
||||
|
||||
if ($scope)
|
||||
{
|
||||
$results = array();
|
||||
|
||||
foreach (array_keys($scope) as $category)
|
||||
{
|
||||
if ($category[0] != '_')
|
||||
{
|
||||
$results[] = $category;
|
||||
}
|
||||
}
|
||||
|
||||
$this->categories[$name] = $results;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->categories[$name];
|
||||
}
|
||||
|
||||
public function validate()
|
||||
{
|
||||
$theme = $this->themeConfig->getTheme();
|
||||
|
||||
return is_file($this->themeConfig->getTheme()->getConfigurationPath(true)) || !$theme->isSystemDefault() && $theme->hasBaseTheme() && $this->findYamls($theme);
|
||||
}
|
||||
|
||||
protected function findYamls(Theme $theme)
|
||||
{
|
||||
$files = array();
|
||||
|
||||
if ($theme->hasBaseTheme())
|
||||
{
|
||||
$current = $theme;
|
||||
|
||||
while ($current = $current->getBaseTheme()) {
|
||||
$path = $current->getConfigurationPath(true);
|
||||
|
||||
if (is_file($path))
|
||||
{
|
||||
$files[] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$files = array_reverse($files);
|
||||
|
||||
$current = $theme->getConfigurationPath(true);
|
||||
|
||||
if (is_file($current))
|
||||
{
|
||||
$files[] = $current;
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
protected function parseYamls($files)
|
||||
{
|
||||
$config = array();
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
$config = self::merge($config, Yaml::parse($file));
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
protected static function merge($array1, $array2)
|
||||
{
|
||||
$arrays = func_get_args();
|
||||
$narrays = count($arrays);
|
||||
|
||||
// check arguments
|
||||
// comment out if more performance is necessary (in this case the foreach loop will trigger a warning if the argument is not an array)
|
||||
for ($i = 0; $i < $narrays; $i++)
|
||||
{
|
||||
if (!is_array($arrays[$i]))
|
||||
{
|
||||
// also array_merge_recursive returns nothing in this case
|
||||
throw new sfException('Argument #' . ($i + 1) . ' is not an array - trying to merge array with scalar!');
|
||||
}
|
||||
}
|
||||
|
||||
// the first array is in the output set in every case
|
||||
$ret = $arrays[0];
|
||||
|
||||
// merege $ret with the remaining arrays
|
||||
for ($i = 1; $i < $narrays; $i++)
|
||||
{
|
||||
foreach ($arrays[$i] as $key => $value)
|
||||
{
|
||||
if ($key == 'display')
|
||||
{
|
||||
$ret[$key] = $value;
|
||||
}
|
||||
elseif (((string) $key) === ((string) intval($key)))
|
||||
{ // integer or string as integer key - append
|
||||
$ret[] = $value;
|
||||
}
|
||||
else
|
||||
{ // string key - megre
|
||||
if ($value && is_array($value) && !isset($value[0]) && isset($ret[$key]))
|
||||
{
|
||||
// if $ret[$key] is not an array you try to merge an scalar value with an array - the result is not defined (incompatible arrays)
|
||||
// in this case the call will trigger an E_USER_WARNING and the $ret[$key] will be null.
|
||||
$ret[$key] = self::merge($ret[$key], $value);
|
||||
}
|
||||
else
|
||||
{
|
||||
$ret[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
<?php
|
||||
|
||||
class stThemeConfigGenerator
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var stThemeEditorConfig
|
||||
*/
|
||||
protected $editorConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var ThemeConfig
|
||||
*/
|
||||
protected $themeConfig;
|
||||
|
||||
public function __construct(stThemeEditorConfig $editor_config)
|
||||
{
|
||||
$this->themeConfig = $editor_config->getThemeConfig();
|
||||
|
||||
$this->editorConfig = $editor_config;
|
||||
}
|
||||
|
||||
public static function loadImageConfig(Theme $theme, $preview = false)
|
||||
{
|
||||
$filename = sfConfig::get('sf_data_dir').'/config/_editor/'.($preview ? 'preview_'.$theme->getName() : $theme->getName()).'.conf';
|
||||
|
||||
if (is_file($filename))
|
||||
{
|
||||
return unserialize(file_get_contents($filename));
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
public function generateGraphic($preview = false)
|
||||
{
|
||||
if (!$preview)
|
||||
{
|
||||
stWebFileManager::getInstance()->remove($this->themeConfig->getTheme()->getImageDir(true).'/_editor/prod');
|
||||
}
|
||||
|
||||
$this->generateImage($preview);
|
||||
|
||||
$this->generateCss($preview);
|
||||
}
|
||||
|
||||
public function generateImage($preview = false)
|
||||
{
|
||||
$theme = $this->themeConfig->getTheme();
|
||||
|
||||
$images = array();
|
||||
|
||||
if ($this->themeConfig->hasType('image'))
|
||||
{
|
||||
foreach ($this->themeConfig->getType('image') as $category => $fields)
|
||||
{
|
||||
foreach ($fields as $name => $value)
|
||||
{
|
||||
$target = $this->editorConfig->getGraphicFieldParameter($category, $name, 'default');
|
||||
|
||||
$images[$target] = $preview ? $value : $this->applyImage($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($preview)
|
||||
{
|
||||
$theme_name = 'preview_'.$theme->getName();
|
||||
}
|
||||
else
|
||||
{
|
||||
$theme_name = $theme->getName();
|
||||
}
|
||||
|
||||
$filename = sfConfig::get('sf_data_dir').'/config/_editor/'.$theme_name.'.conf';
|
||||
|
||||
$dir = dirname($filename);
|
||||
|
||||
if (!is_dir($dir))
|
||||
{
|
||||
mkdir($dir, 0755, true);
|
||||
}
|
||||
|
||||
file_put_contents($filename, serialize($images));
|
||||
}
|
||||
|
||||
public function compileCss($category = null)
|
||||
{
|
||||
$css = array();
|
||||
|
||||
$theme = $this->themeConfig->getTheme();
|
||||
|
||||
$categories = $category ? array($category) : $this->editorConfig->getGraphicCategories();
|
||||
|
||||
foreach ($categories as $category)
|
||||
{
|
||||
if ($category == '_less')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($this->editorConfig->getGraphicFields($category) as $field)
|
||||
{
|
||||
$default = $this->editorConfig->getGraphicFieldParameter($category, $field, 'default');
|
||||
|
||||
if ($this->editorConfig->hasGraphicFieldType($category, $field, 'css'))
|
||||
{
|
||||
$selector = $this->editorConfig->getGraphicFieldParameter($category, $field, 'selector');
|
||||
|
||||
$media = $this->editorConfig->getGraphicFieldParameter($category, $field, 'media', 'xs');
|
||||
|
||||
$properties = $this->editorConfig->getGraphicFieldParameter($category, $field, 'property');
|
||||
|
||||
$value = $this->themeConfig->getCss($category, $field);
|
||||
|
||||
if ($value)
|
||||
{
|
||||
foreach ((array) $properties as $property)
|
||||
{
|
||||
$css_value = $this->getValue($value, $property);
|
||||
|
||||
if ($css_value)
|
||||
{
|
||||
$css[$media][$selector][$property] = $css_value;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->editorConfig->getGraphicGenerated($category, $field) as $generated)
|
||||
{
|
||||
$css[isset($generated['media']) ? $generated['media'] : 'xs'][$generated['selector']][$generated['property']] = $this->getValue($value, $generated['property']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$content = array();
|
||||
|
||||
foreach ($this->editorConfig->getMedia() as $media => $setting)
|
||||
{
|
||||
if (isset($css[$media]))
|
||||
{
|
||||
if ($media != 'xs')
|
||||
{
|
||||
$content[] = "@media (".$setting.") {\n";
|
||||
}
|
||||
|
||||
$intend = $media != 'xs' ? "\t" : "";
|
||||
|
||||
foreach ($css[$media] as $selector => $properties)
|
||||
{
|
||||
$content[] = $intend.$selector." {\n";
|
||||
|
||||
foreach ($properties as $property => $value)
|
||||
{
|
||||
if ($theme->getVersion() < 7)
|
||||
{
|
||||
$content[] = $intend."\t".$property.': '.$value." !important;\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$content[] = $intend."\t".$property.': '.$value.";\n";
|
||||
}
|
||||
}
|
||||
|
||||
$content[] = $intend."}\n";
|
||||
}
|
||||
|
||||
if ($media != 'xs')
|
||||
{
|
||||
$content[] = "}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return implode("\n", $content);
|
||||
}
|
||||
|
||||
public function generateCss($preview = false)
|
||||
{
|
||||
$theme = $this->themeConfig->getTheme();
|
||||
|
||||
$filename = $preview ? $theme->getEditorCssPath('preview_style.css', true) : $theme->getEditorCssPath('style.css', true);
|
||||
|
||||
$dir = dirname($filename);
|
||||
|
||||
if (!is_dir($dir))
|
||||
{
|
||||
mkdir($dir, 0755, true);
|
||||
}
|
||||
|
||||
file_put_contents($filename, $this->compileCss());
|
||||
}
|
||||
|
||||
public function generateLess($preview = false)
|
||||
{
|
||||
$less = array();
|
||||
|
||||
$fields = array_merge($this->editorConfig->getGraphicFields(array('_less', 'palette')), $this->editorConfig->getGraphicFields(array('_less', 'colors')));
|
||||
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
$default = $this->editorConfig->getGraphicFieldParameter('_less', $field, 'default');
|
||||
|
||||
$value = $this->themeConfig->getLess($field, $default);
|
||||
|
||||
if (!$value || $value == 'transparent')
|
||||
{
|
||||
$less[$field] = 'transparent';
|
||||
}
|
||||
else
|
||||
{
|
||||
$less[$field] = strpos($value, 'rgb') === false ? '#'.$value : $value;
|
||||
}
|
||||
}
|
||||
|
||||
$theme = $this->themeConfig->getTheme();
|
||||
|
||||
$filename = $preview ? $theme->getEditorCssPath('preview_config.less', true) : $theme->getEditorCssPath('config.less', true);
|
||||
|
||||
$dir = dirname($filename);
|
||||
|
||||
if (!is_dir($dir))
|
||||
{
|
||||
mkdir($dir, 0755, true);
|
||||
}
|
||||
|
||||
$content = array();
|
||||
|
||||
foreach ($less as $var => $value)
|
||||
{
|
||||
$content[] = "@".$var.': '.$value.";\n";
|
||||
}
|
||||
|
||||
file_put_contents($filename, $content);
|
||||
|
||||
if ($preview && is_file($theme->getEditorCssPath('preview_style.css', true)))
|
||||
{
|
||||
$this->generateCss(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected function applyImage($image)
|
||||
{
|
||||
$theme = $this->themeConfig->getTheme();
|
||||
|
||||
$target = str_replace('_editor/preview', '_editor/prod', $image);
|
||||
|
||||
$target_filename = $theme->getEditorImagePath($target, true);
|
||||
|
||||
$target_dir = dirname($target_filename);
|
||||
|
||||
if (!is_dir($target_dir))
|
||||
{
|
||||
mkdir($target_dir, 0755, true);
|
||||
}
|
||||
|
||||
$source_filename = $theme->getEditorImagePath($image, true);
|
||||
|
||||
copy($source_filename, $target_filename);
|
||||
|
||||
return $target;
|
||||
}
|
||||
|
||||
protected function getValue($value, $property)
|
||||
{
|
||||
$theme = $this->themeConfig->getTheme();
|
||||
|
||||
$css_value = null;
|
||||
|
||||
switch ($property)
|
||||
{
|
||||
case 'background-image':
|
||||
if ($value)
|
||||
{
|
||||
$css_value = sprintf('url(\'%s\')', $theme->getEditorImagePath($this->applyImage($value)));
|
||||
}
|
||||
break;
|
||||
case 'background-repeat':
|
||||
$css_value = $value;
|
||||
break;
|
||||
default:
|
||||
if (!$value || $value == 'transparent')
|
||||
{
|
||||
$css_value = 'transparent';
|
||||
}
|
||||
else
|
||||
{
|
||||
$css_value = strpos($value, 'rgb') === false ? '#'.$value : $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $css_value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
class stThemeEditorConfig extends stThemeConfig
|
||||
{
|
||||
public function getMedia()
|
||||
{
|
||||
return isset($this->config['editor_config']['media']) ? $this->config['editor_config']['media'] : array('xs' => null);
|
||||
}
|
||||
|
||||
public function getGraphicCategories()
|
||||
{
|
||||
return array_keys($this->config['editor_config']['graphic']);
|
||||
}
|
||||
|
||||
public function getGraphicFields($category)
|
||||
{
|
||||
return is_array($category) ? $this->config['editor_config']['graphic'][$category[0]]['display'][$category[1]] : $this->config['editor_config']['graphic'][$category]['display'];
|
||||
}
|
||||
|
||||
public function hasGraphicFieldType($category, $field, $type)
|
||||
{
|
||||
return $this->getGraphicFieldParameter($category, $field, 'type') == $type;
|
||||
}
|
||||
|
||||
public function getGraphicCategoryLabel($category)
|
||||
{
|
||||
return isset($this->config['editor_config']['graphic'][$category]) ? $this->config['editor_config']['graphic'][$category]['label'] : null;
|
||||
}
|
||||
|
||||
public function hasGraphicFieldProperty($category, $field, $property)
|
||||
{
|
||||
$value = $this->getGraphicFieldParameter($category, $field, 'property');
|
||||
|
||||
return is_array($value) ? array_search($property, $value) : $value == $property;
|
||||
}
|
||||
|
||||
public function isGraphicFieldRelated($category, $field)
|
||||
{
|
||||
if (isset($this->config['editor_config']['graphic'][$category]['fields'][$field]['default']))
|
||||
{
|
||||
$value = $this->config['editor_config']['graphic'][$category]['fields'][$field]['default'];
|
||||
|
||||
return $value && $value{0} == '@';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getGraphicGenerated($category, $field)
|
||||
{
|
||||
if (isset($this->config['editor_config']['graphic'][$category]['generated'][$field]))
|
||||
{
|
||||
return $this->config['editor_config']['graphic'][$category]['generated'][$field];
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getGraphicFieldParameter($category, $field, $parameter, $default = null)
|
||||
{
|
||||
if (isset($this->config['editor_config']['graphic'][$category]['fields'][$field][$parameter]))
|
||||
{
|
||||
$value = $this->config['editor_config']['graphic'][$category]['fields'][$field][$parameter];
|
||||
|
||||
if ($parameter == 'default' && $value && $value{0} == '@')
|
||||
{
|
||||
$name = substr($value, 1);
|
||||
|
||||
$value = $this->themeConfig->getLess($name);
|
||||
|
||||
if (null === $value)
|
||||
{
|
||||
$value = $this->getGraphicFieldParameter('_less', $name, 'default');
|
||||
}
|
||||
|
||||
if ($filter = $this->getGraphicFieldParameter($category, $field, 'filter'))
|
||||
{
|
||||
$value = call_user_func(array('stThemeLess', $filter[0]), $value, $filter[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return is_array($value) ? $value : ltrim($value, '#');
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
106
plugins/stThemePlugin/lib/helper/stThemeHelper.php
Normal file
106
plugins/stThemePlugin/lib/helper/stThemeHelper.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stThemePlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stThemePlugin opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stThemePlugin
|
||||
* @subpackage helpers
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
|
||||
* @version $Id: stThemeHelper.php 256 2009-03-30 11:49:45Z marek $
|
||||
* @author Marek Jakubowicz <marek.akubowicz@sote.pl>
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
*/
|
||||
|
||||
use_helper('Asset');
|
||||
|
||||
function st_theme_stylesheet_tag($stylesheet)
|
||||
{
|
||||
$context = sfContext::getInstance();
|
||||
|
||||
$theme = stTheme::getInstance($context);
|
||||
|
||||
$stylesheet_path = $theme->getStylesheetPaths($stylesheet);
|
||||
|
||||
return $stylesheet_path ? stylesheet_tag($stylesheet_path['default']) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dodaje plik css ktory ma zostac zalaczony podczas wyswietlania strony
|
||||
*
|
||||
* @param string $stylesheet Nazwa pliku css umieszczonego w katalogu 'frontend/theme/nazwa_tematu'
|
||||
*/
|
||||
function st_theme_use_stylesheet($stylesheet, $position = '', $options = array())
|
||||
{
|
||||
stTheme::useStylesheet($stylesheet, $position, $options);
|
||||
}
|
||||
|
||||
function st_theme_get_content($content_id, $default = null)
|
||||
{
|
||||
$theme = stTheme::getInstance(sfContext::getInstance());
|
||||
|
||||
return $theme->getThemeContent($content_id, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca relatywna scieżke url do podanego obrazka
|
||||
*
|
||||
* @param string $source
|
||||
* @return string
|
||||
*/
|
||||
function _st_get_image_path($source, $absolute = false)
|
||||
{
|
||||
$image_path = stTheme::getImagePath($source);
|
||||
|
||||
return image_path($image_path, $absolute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca znacznik <img> dla podanego obrazka.
|
||||
*
|
||||
* @param string image asset name
|
||||
* @param array additional HTML compliant <img> tag parameters
|
||||
* @return string XHTML compliant <img> tag
|
||||
* @see image_path
|
||||
*/
|
||||
function st_theme_image_tag($source, $options = array())
|
||||
{
|
||||
$source = _st_get_image_path($source);
|
||||
return image_tag($source, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca znacznik input o typie image dla podanego obrazka
|
||||
*
|
||||
* @param string path to image file
|
||||
* @param array additional HTML compliant <input> tag parameters
|
||||
* @return string XHTML compliant <input> tag with type="image"
|
||||
*/
|
||||
function st_theme_submit_image_tag($source, $options = array())
|
||||
{
|
||||
$source = _st_get_image_path($source);
|
||||
return submit_image_tag($source, $options);
|
||||
}
|
||||
|
||||
function st_theme_layout_edit_head()
|
||||
{
|
||||
if (SF_ENVIRONMENT == 'edit') echo st_get_component('stThemeFrontend','editThemeHead');
|
||||
else echo content_tag('a', '', array('id' => 'portal-block-list-link', 'name' => 'portal-block-list-link'));
|
||||
}
|
||||
|
||||
function st_theme_layout_edit_foot()
|
||||
{
|
||||
if (SF_ENVIRONMENT == 'edit') echo st_get_component('stThemeFrontend','editThemeFoot');
|
||||
else echo content_tag('div', content_tag('div', content_tag('div', '', array('id' => 'magazine1', 'class' => 'portal-column'))), array('id' => 'portal-column-block-list', 'style' => 'display:none'));
|
||||
}
|
||||
|
||||
function st_theme_init_jquery_tools()
|
||||
{
|
||||
// use_javascript('/stCategoryTreePlugin/js/jquery-1.3.2.min.js', 'first');
|
||||
// use_javascript('/stCategoryTreePlugin/js/jquery-no-conflict.js', 'first');
|
||||
use_javascript('/js/jquery.tools.min.js', 'first');
|
||||
}
|
||||
411
plugins/stThemePlugin/lib/model/Theme.php
Normal file
411
plugins/stThemePlugin/lib/model/Theme.php
Normal file
@@ -0,0 +1,411 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for representing a row from the 'st_theme' table.
|
||||
*
|
||||
* @package stThemePlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class Theme extends BaseTheme
|
||||
{
|
||||
const SYSTEM_DEFAULT_THEMES = array(
|
||||
'default2',
|
||||
'responsive',
|
||||
'argentorwd',
|
||||
'homeelectronics',
|
||||
'giallo',
|
||||
'moderno',
|
||||
'sportivo',
|
||||
'quattro',
|
||||
'coffeestore',
|
||||
'segno',
|
||||
'longboard',
|
||||
'bagging',
|
||||
'games',
|
||||
'surfing',
|
||||
'brassiere',
|
||||
'yewelry',
|
||||
'gifts',
|
||||
'fragrance',
|
||||
'furniture',
|
||||
'argento',
|
||||
'meble'
|
||||
);
|
||||
|
||||
protected $themeConfig = null;
|
||||
|
||||
protected $themeConfigCached = null;
|
||||
|
||||
protected $editorImages = null;
|
||||
|
||||
protected $baseThemes = null;
|
||||
|
||||
protected $themeContents = array();
|
||||
|
||||
public function getBackendCulture()
|
||||
{
|
||||
return sfContext::getInstance()->getUser()->getCulture();
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->theme;
|
||||
}
|
||||
|
||||
public function getColorScheme()
|
||||
{
|
||||
return $this->getOptColorScheme();
|
||||
}
|
||||
|
||||
public function isSystemDefault()
|
||||
{
|
||||
return parent::getIsSystemDefault();
|
||||
}
|
||||
|
||||
public function getIsSystemDefault($check_active = true)
|
||||
{
|
||||
return parent::getIsSystemDefault() || $this->getTheme() == 'default' || $this->getTheme() == 'homeelectronics' || $check_active && $this->getActive();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* alias for Theme::setBaseThemeId
|
||||
*
|
||||
* @param int $v
|
||||
*/
|
||||
public function setBaseThemeList($v)
|
||||
{
|
||||
$this->setBaseThemeId($v ? $v : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Przeciążenie zapisu
|
||||
*/
|
||||
public function delete($con = null)
|
||||
{
|
||||
$ret = parent::delete($con);
|
||||
|
||||
stTheme::clearCache();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function setName($v)
|
||||
{
|
||||
$this->setTheme($v);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->getTheme();
|
||||
}
|
||||
|
||||
public function hasBaseTheme()
|
||||
{
|
||||
return null !== $this->getBaseTheme();
|
||||
}
|
||||
|
||||
public function getBaseTheme()
|
||||
{
|
||||
return ThemePeer::retrieveByPKCached($this->base_theme_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca pełna ścieżke tematu
|
||||
*
|
||||
* @param boolean $onlyStringNames
|
||||
* @return Theme[]|string[]
|
||||
*/
|
||||
public function getBaseThemePath($onlyStringNames = false)
|
||||
{
|
||||
$baseThemes = $this->getBaseThemes();
|
||||
$baseThemes[] = $this;
|
||||
|
||||
if ($onlyStringNames)
|
||||
{
|
||||
return array_map(function(Theme $theme) {
|
||||
return $theme->getTheme();
|
||||
}, $baseThemes);
|
||||
}
|
||||
|
||||
return $baseThemes;
|
||||
}
|
||||
|
||||
public function getBaseThemes($current = null, array &$baseThemes = array())
|
||||
{
|
||||
if (null === $this->baseThemes)
|
||||
{
|
||||
if (null === $current)
|
||||
{
|
||||
$current = $this->getBaseTheme();
|
||||
|
||||
if (null === $current)
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$current = $current->getBaseTheme();
|
||||
}
|
||||
|
||||
if (null !== $current)
|
||||
{
|
||||
$baseThemes[] = $current;
|
||||
}
|
||||
elseif ($baseThemes)
|
||||
{
|
||||
$this->baseThemes = array_reverse($baseThemes);
|
||||
}
|
||||
|
||||
$this->getBaseThemes($current, $baseThemes);
|
||||
}
|
||||
|
||||
return $this->baseThemes;
|
||||
}
|
||||
|
||||
public function hasThemeContent($content_id)
|
||||
{
|
||||
$content = $this->getThemeContent($content_id);
|
||||
return null !== $content && !empty($content);
|
||||
}
|
||||
|
||||
public function getThemeContent($content_id, $default = null, $culture = null)
|
||||
{
|
||||
if (null === $culture)
|
||||
{
|
||||
$culture = sfContext::getInstance()->getUser()->getCulture();
|
||||
}
|
||||
|
||||
if (!isset($this->themeContents[$culture]))
|
||||
{
|
||||
$fc = stFunctionCache::getInstance('stThemePlugin');
|
||||
$this->themeContents[$culture] = $fc->cacheCall(array($this, 'loadThemeContents'), array($culture, $this->getId()));
|
||||
}
|
||||
|
||||
return isset($this->themeContents[$culture][$content_id]) ? $this->themeContents[$culture][$content_id] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Przeciążenie zapisu
|
||||
*/
|
||||
public function save($con = null)
|
||||
{
|
||||
$updateDefaultTheme = $this->isColumnModified(ThemePeer::ACTIVE) && $this->getActive();
|
||||
|
||||
if (in_array($this->theme, self::SYSTEM_DEFAULT_THEMES))
|
||||
{
|
||||
$this->setIsSystemDefault(true);
|
||||
}
|
||||
|
||||
$result = parent::save($con);
|
||||
|
||||
if ($updateDefaultTheme)
|
||||
{
|
||||
$this->updateActiveThemes();
|
||||
}
|
||||
|
||||
if ($updateDefaultTheme || $this->isColumnModified('is_responsive'))
|
||||
{
|
||||
$this->getConfig()->save();
|
||||
ThemePeer::doSimpleStoreUpdate(null, $this)->save();
|
||||
}
|
||||
|
||||
stTheme::clearCache();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getConfigurationPath($system = false)
|
||||
{
|
||||
return $system ? sfConfig::get('sf_root_dir').'/config/theme/'.$this->theme.'.yml' : 'config/theme/'.$this->theme.'.yml';
|
||||
}
|
||||
|
||||
public function getCssDir($system_path = false)
|
||||
{
|
||||
if ($system_path)
|
||||
{
|
||||
$root_dir = realpath(sfConfig::get('sf_web_dir'));
|
||||
|
||||
if ($root_dir == '/')
|
||||
{
|
||||
$root_dir = '';
|
||||
}
|
||||
|
||||
return $root_dir.'/css/frontend/theme/'.$this->theme;
|
||||
}
|
||||
|
||||
return '/css/frontend/theme/'.$this->theme;
|
||||
}
|
||||
|
||||
public function getImageDir($system_path = false)
|
||||
{
|
||||
if ($system_path)
|
||||
{
|
||||
$root_dir = realpath(sfConfig::get('sf_web_dir'));
|
||||
|
||||
if ($root_dir == '/')
|
||||
{
|
||||
$root_dir = '';
|
||||
}
|
||||
|
||||
return $root_dir.'/images/frontend/theme/'.$this->theme;
|
||||
}
|
||||
|
||||
return '/images/frontend/theme/'.$this->theme;
|
||||
}
|
||||
|
||||
public function getEditorCssPath($css, $system_path = false)
|
||||
{
|
||||
return $this->getCssDir($system_path).'/_editor/'.$css;
|
||||
}
|
||||
|
||||
public function getEditorImageDir($system_path = false)
|
||||
{
|
||||
return $this->getImageDir($system_path).'/_editor';
|
||||
}
|
||||
|
||||
public function getThemeConfigCached()
|
||||
{
|
||||
if (null === $this->themeConfigCached)
|
||||
{
|
||||
$fc = new stFunctionCache('stThemePlugin');
|
||||
|
||||
$this->themeConfigCached = $fc->cacheCall(array($this, 'getThemeConfig'));
|
||||
}
|
||||
|
||||
return $this->themeConfigCached;
|
||||
}
|
||||
|
||||
public function getThemeConfig()
|
||||
{
|
||||
if (null === $this->themeConfig)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->setLimit(1);
|
||||
|
||||
$configs = $this->getThemeConfigs($c);
|
||||
|
||||
$this->themeConfig = $configs ? $configs[0] : null;
|
||||
|
||||
if (null === $this->themeConfig)
|
||||
{
|
||||
$this->themeConfig = new ThemeConfig();
|
||||
$this->addThemeConfig($this->themeConfig);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->themeConfig;
|
||||
}
|
||||
|
||||
public function getThemeDir()
|
||||
{
|
||||
return 'frontend/theme/' . $this->theme;
|
||||
}
|
||||
|
||||
public function getThemeColorSchemeDir()
|
||||
{
|
||||
return $this->getThemeDir() . '/' . $this->getColorScheme();
|
||||
}
|
||||
|
||||
public function getDefaultThemeDir()
|
||||
{
|
||||
return $this->getBaseTheme() ? 'frontend/theme/' . $this->getBaseTheme()->getName() : null;
|
||||
}
|
||||
|
||||
public function getTemplateDir($module = null)
|
||||
{
|
||||
return $module ? sfLoader::getTemplateDir($module, null) . '/theme/' . $this->theme : sfConfig::get('sf_root_dir') . '/apps/frontend/templates/theme/'. $this->theme;
|
||||
}
|
||||
|
||||
public function getEditorImagePath($image, $system_path = false)
|
||||
{
|
||||
return $this->getImageDir($system_path).'/'.$image;
|
||||
}
|
||||
|
||||
public function findEditorImagePath($image, Theme $theme = null)
|
||||
{
|
||||
if (null === $theme)
|
||||
{
|
||||
$theme = $this;
|
||||
}
|
||||
|
||||
if (is_readable($theme->getEditorImagePath($image, true)))
|
||||
{
|
||||
return $theme->getEditorImagePath($image);
|
||||
}
|
||||
elseif ($theme->hasBaseTheme())
|
||||
{
|
||||
return $this->findEditorImagePath($image, $theme->getBaseTheme());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getImagePath($image, $system_path = false, $default = false)
|
||||
{
|
||||
return $this->getImageDir($system_path).'/'.($default ? $image : $this->getImage($image));
|
||||
}
|
||||
|
||||
public function getImage($image)
|
||||
{
|
||||
return $this->hasImage($image) ? $this->editorImages[$image] : $image;
|
||||
}
|
||||
|
||||
public function hasImage($image)
|
||||
{
|
||||
if (null === $this->editorImages)
|
||||
{
|
||||
$this->editorImages = stThemeConfigGenerator::loadImageConfig($this, SF_ENVIRONMENT == 'theme');
|
||||
}
|
||||
|
||||
return isset($this->editorImages[$image]);
|
||||
}
|
||||
|
||||
public function getIsResponsive()
|
||||
{
|
||||
return $this->getConfig()->get('responsive') === $this->id;
|
||||
}
|
||||
|
||||
public function setIsResponsive($value)
|
||||
{
|
||||
if (!$value && $this->getConfig()->get('responsive') == $this->id)
|
||||
{
|
||||
$this->getConfig()->set('responsive', null);
|
||||
$this->modifiedColumns['is_responsive'] = true;
|
||||
}
|
||||
elseif ($value && $this->getConfig()->get('responsive') != $this->id)
|
||||
{
|
||||
$this->getConfig()->set('responsive', $this->id);
|
||||
$this->modifiedColumns['is_responsive'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function loadThemeContents()
|
||||
{
|
||||
$themeContents = array();
|
||||
|
||||
foreach ($this->getThemeContents() as $content)
|
||||
{
|
||||
$themeContents[$content->getContentId()] = $content->getContent();
|
||||
}
|
||||
|
||||
return $themeContents;
|
||||
}
|
||||
|
||||
protected function updateActiveThemes()
|
||||
{
|
||||
$s = new Criteria();
|
||||
$s->add(ThemePeer::ID, $this->getId(), Criteria::NOT_EQUAL);
|
||||
$u = new Criteria();
|
||||
$u->add(ThemePeer::ACTIVE, false);
|
||||
|
||||
BasePeer::doUpdate($s, $u, Propel::getConnection());
|
||||
}
|
||||
|
||||
protected function getConfig(): stConfig
|
||||
{
|
||||
return stConfig::getInstance('stThemeBackend');
|
||||
}
|
||||
}
|
||||
47
plugins/stThemePlugin/lib/model/ThemeColorScheme.php
Normal file
47
plugins/stThemePlugin/lib/model/ThemeColorScheme.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for representing a row from the 'st_theme_color' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model
|
||||
*/
|
||||
class ThemeColorScheme extends BaseThemeColorScheme
|
||||
{
|
||||
|
||||
public function save($con = null)
|
||||
{
|
||||
if ($this->getIsDefault() && $this->isColumnModified(ThemeColorSchemePeer::IS_DEFAULT))
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->add(ThemeColorSchemePeer::THEME_ID, $this->getThemeId());
|
||||
$c->add(ThemeColorSchemePeer::IS_DEFAULT, true);
|
||||
$themeColor = ThemeColorSchemePeer::doSelectOne($c);
|
||||
|
||||
if ($themeColor)
|
||||
{
|
||||
$themeColor->setIsDefault(false);
|
||||
|
||||
$themeColor->save($con);
|
||||
}
|
||||
|
||||
$this->getTheme()->setOptColorScheme($this->getName());
|
||||
}
|
||||
elseif ($this->getIsDefault() && $this->isColumnModified(ThemeColorSchemePeer::NAME))
|
||||
{
|
||||
$this->getTheme()->setOptColorScheme($this->getName());
|
||||
}
|
||||
elseif (!$this->isNew() && $this->getIsDefault() == false && $this->isColumnModified(ThemeColorSchemePeer::IS_DEFAULT))
|
||||
{
|
||||
$this->getTheme()->setOptColorScheme(null);
|
||||
}
|
||||
|
||||
$ret = parent::save($con);
|
||||
|
||||
stTheme::clearCache();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
}
|
||||
56
plugins/stThemePlugin/lib/model/ThemeColorSchemePeer.php
Normal file
56
plugins/stThemePlugin/lib/model/ThemeColorSchemePeer.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SOTESHOP/stThemePlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stThemePlugin opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stThemePlugin
|
||||
* @subpackage lib
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
|
||||
* @version $Id: $
|
||||
* @author Michal Prochowski <michal.prochowski@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa ThemeColorSchemePeer
|
||||
*
|
||||
* @package stThemePlugin
|
||||
* @subpackage lib
|
||||
*/
|
||||
class ThemeColorSchemePeer extends BaseThemeColorSchemePeer
|
||||
{
|
||||
|
||||
/**
|
||||
* Tablica z kolorami tematów graficznych
|
||||
* @var array
|
||||
*/
|
||||
protected static $colorScheme = array();
|
||||
|
||||
/**
|
||||
* Pobieranie dostępnych kolorów dla tematu graficznego
|
||||
*
|
||||
* @param int $id Numer id tematu graficznego
|
||||
* @return array
|
||||
*/
|
||||
public static function doSelectByThemeId($id)
|
||||
{
|
||||
if (!isset(self::$colorScheme[$id]))
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ThemeColorSchemePeer::THEME_ID, $id);
|
||||
|
||||
$fc = new stFunctionCache('stThemePlugin');
|
||||
|
||||
self::$colorScheme[$id] = $fc->cacheCall(array('ThemeColorSchemePeer', 'doSelect'), array($c), array('namespace' => 'model'));
|
||||
}
|
||||
|
||||
return self::$colorScheme[$id];
|
||||
}
|
||||
|
||||
}
|
||||
325
plugins/stThemePlugin/lib/model/ThemeConfig.php
Normal file
325
plugins/stThemePlugin/lib/model/ThemeConfig.php
Normal file
@@ -0,0 +1,325 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for representing a row from the 'st_theme_config' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model
|
||||
*/
|
||||
class ThemeConfig extends BaseThemeConfig
|
||||
{
|
||||
protected $images = array();
|
||||
|
||||
protected $defaultConfig = null;
|
||||
|
||||
public function getCss($category, $name, $default = null)
|
||||
{
|
||||
return $this->getParameter('css', $category, $name, $default);
|
||||
}
|
||||
|
||||
public function setCss($category, $name, $value)
|
||||
{
|
||||
$this->setParameter('css', $category, $name, $value);
|
||||
}
|
||||
|
||||
public function removeCss($category, $name)
|
||||
{
|
||||
$this->removeParameter('css', $category, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca instancje tematu
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return Theme
|
||||
*/
|
||||
public function getTheme($con = null)
|
||||
{
|
||||
if ($this->aTheme === null && ($this->id !== null))
|
||||
{
|
||||
$this->aTheme = ThemePeer::retrieveByPKCached($this->id);
|
||||
}
|
||||
|
||||
return $this->aTheme;
|
||||
}
|
||||
|
||||
public function removeCssImage($category, $name)
|
||||
{
|
||||
if ($image = $this->getCss($category, $name))
|
||||
{
|
||||
unlink($this->getTheme()->getImageDir(true).'/'.$image);
|
||||
}
|
||||
|
||||
$this->removeCss($category, $name);
|
||||
}
|
||||
|
||||
public function getImage($category, $name, $default = null)
|
||||
{
|
||||
return $this->getParameter('image', $category, $name, $default);
|
||||
}
|
||||
|
||||
public function setImage($category, $name, $value)
|
||||
{
|
||||
$this->setParameter('image', $category, $name, $value);
|
||||
}
|
||||
|
||||
public function removeImage($category, $name)
|
||||
{
|
||||
if ($image = $this->getImage($category, $name))
|
||||
{
|
||||
unlink($this->getTheme()->getImageDir(true).'/'.$image);
|
||||
}
|
||||
|
||||
$this->removeParameter('image', $category, $name);
|
||||
}
|
||||
|
||||
public function getLess($name, $default = null)
|
||||
{
|
||||
return $this->getParameter('less', 'none', $name, $default);
|
||||
}
|
||||
|
||||
public function setLess($name, $value)
|
||||
{
|
||||
$this->setParameter('less', 'none', $name, $value);
|
||||
}
|
||||
|
||||
public function removeLess($name)
|
||||
{
|
||||
$this->removeParameter('less', 'none', $name);
|
||||
}
|
||||
|
||||
public function setConfigParameter($name, $value)
|
||||
{
|
||||
$this->setParameter('config', null, $name, $value);
|
||||
}
|
||||
|
||||
public function getConfigParameter($name, $default = null)
|
||||
{
|
||||
$defaults = $this->getDefaultConfig();
|
||||
|
||||
return $this->getParameter('config', null, $name, isset($defaults[$name]) ? $defaults[$name] : $default);
|
||||
}
|
||||
|
||||
public function clearConfigParameter($name)
|
||||
{
|
||||
$parameters = $this->parameters;
|
||||
|
||||
if (isset($parameters['config']))
|
||||
{
|
||||
if (substr($name, -1) == '.')
|
||||
{
|
||||
foreach ($parameters['config'] as $key => $value)
|
||||
{
|
||||
if (strpos($key, $name) === 0)
|
||||
{
|
||||
unset($parameters['config'][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (isset($parameters['config'][$name]))
|
||||
{
|
||||
unset($parameters['config'][$name]);
|
||||
}
|
||||
|
||||
$this->setParameters($parameters);
|
||||
}
|
||||
}
|
||||
|
||||
public function setParameter($type, $category, $name, $value)
|
||||
{
|
||||
$parameters = $this->parameters;
|
||||
|
||||
if (null === $category)
|
||||
{
|
||||
$parameters[$type][$name] = $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
$parameters[$type][$category][$name] = $value;
|
||||
}
|
||||
|
||||
$this->setParameters($parameters);
|
||||
}
|
||||
|
||||
public function getParameter($type, $category, $name, $default = null)
|
||||
{
|
||||
if (null === $category)
|
||||
{
|
||||
return isset($this->parameters[$type][$name]) ? $this->parameters[$type][$name] : $default;
|
||||
}
|
||||
|
||||
return isset($this->parameters[$type][$category][$name]) ? $this->parameters[$type][$category][$name] : $default;
|
||||
}
|
||||
|
||||
public function removeType($type)
|
||||
{
|
||||
$parameters = $this->parameters;
|
||||
|
||||
if (isset($parameters[$type]))
|
||||
{
|
||||
unset($parameters[$type]);
|
||||
}
|
||||
|
||||
$this->setParameters($parameters);
|
||||
}
|
||||
|
||||
public function getImagePath($image, $system_path = false)
|
||||
{
|
||||
return $this->getTheme()->getImageDir($system_path).'/'.$image;
|
||||
}
|
||||
|
||||
public function getType($type)
|
||||
{
|
||||
return $this->hasType($type) ? $this->parameters[$type] : null;
|
||||
}
|
||||
|
||||
public function hasType($type)
|
||||
{
|
||||
if ($type == 'graphic')
|
||||
{
|
||||
return isset($this->parameters['css']) || isset($this->parameters['image']);
|
||||
}
|
||||
elseif ($type == 'color')
|
||||
{
|
||||
$type = 'less';
|
||||
}
|
||||
|
||||
return isset($this->parameters[$type]);
|
||||
}
|
||||
|
||||
public function removeParameter($type, $category, $name)
|
||||
{
|
||||
$parameters = $this->parameters;
|
||||
|
||||
if (isset($parameters[$type][$category][$name]))
|
||||
{
|
||||
unset($parameters[$type][$category][$name]);
|
||||
}
|
||||
|
||||
$this->setParameters($parameters);
|
||||
}
|
||||
|
||||
public function getImageByName($name)
|
||||
{
|
||||
if (null === $this->images)
|
||||
{
|
||||
$this->images = isset($this->parameters['image']) ? array_flip(array_values($this->parameters['image'])) : array();
|
||||
}
|
||||
|
||||
return isset($this->images[$name]) ? $this->images[$name] : $name;
|
||||
}
|
||||
|
||||
public function restoreImages()
|
||||
{
|
||||
$this->removeType('image');
|
||||
|
||||
$theme = $this->getTheme();
|
||||
|
||||
if (is_file(sfConfig::get('sf_data_dir').'/config/_editor/preview_'.$theme->getName().'.conf'))
|
||||
{
|
||||
unlink(sfConfig::get('sf_data_dir').'/config/_editor/preview_'.$theme->getName().'.conf');
|
||||
}
|
||||
|
||||
stWebFileManager::getInstance()->remove($theme->getEditorImageDir(true).'/preview');
|
||||
}
|
||||
|
||||
public function restoreCss()
|
||||
{
|
||||
$this->removeType('css');
|
||||
|
||||
$theme = $this->getTheme();
|
||||
|
||||
if (is_file($theme->getEditorCssPath('preview_style.css', true)))
|
||||
{
|
||||
unlink($theme->getEditorCssPath('preview_style.css', true));
|
||||
}
|
||||
}
|
||||
|
||||
public function restoreLess()
|
||||
{
|
||||
$this->removeType('less');
|
||||
|
||||
$theme = $this->getTheme();
|
||||
|
||||
if (is_file($theme->getEditorCssPath('preview_config.less', true)))
|
||||
{
|
||||
unlink($theme->getEditorCssPath('preview_config.less', true));
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($con = null)
|
||||
{
|
||||
$image_dir = $this->getTheme()->getImageDir(true);
|
||||
|
||||
$css_dir = $this->getTheme()->getCssDir(true);
|
||||
|
||||
parent::delete($con);
|
||||
|
||||
stWebFileManager::getInstance()->remove($image_dir.'/_editor');
|
||||
|
||||
stWebFileManager::getInstance()->remove($css_dir.'/_editor');
|
||||
|
||||
if (is_file(sfConfig::get('sf_data_dir').'/config/_editor/preview_'.$theme->getName().'.conf'))
|
||||
{
|
||||
unlink(sfConfig::get('sf_data_dir').'/config/_editor/preview_'.$theme->getName().'.conf');
|
||||
}
|
||||
|
||||
if (is_file(sfConfig::get('sf_data_dir').'/config/_editor/'.$theme->getName().'.conf'))
|
||||
{
|
||||
unlink(sfConfig::get('sf_data_dir').'/config/_editor/'.$theme->getName().'.conf');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca domyślne wartości dla konfiguracji
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDefaultConfig()
|
||||
{
|
||||
if (null === $this->defaultConfig)
|
||||
{
|
||||
$theme_config = new stThemeConfig();
|
||||
$current = $theme_config->load($this);
|
||||
|
||||
$config = array();
|
||||
$layouts = array();
|
||||
$layout_config = array();
|
||||
|
||||
if (isset($current['layout_config']) && $current['layout_config'])
|
||||
{
|
||||
foreach ($current['layout_config'] as $name => $value)
|
||||
{
|
||||
if (!$value || $name[0] == '_') continue;
|
||||
|
||||
if (!isset($value['type']) || $value['type'] == 'layout')
|
||||
{
|
||||
foreach ($value['actions'] as $action) {
|
||||
$layouts[$action] = isset($value['default']) ? $value['default'] : null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$config['layout_config.'.$name] = isset($value['default']) ? $value['default'] : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$config['layouts'] = $layouts;
|
||||
|
||||
$this->defaultConfig = $config;
|
||||
}
|
||||
|
||||
return $this->defaultConfig;
|
||||
}
|
||||
|
||||
public function hydrate(ResultSet $rs, $startcol = 1)
|
||||
{
|
||||
$ret = parent::hydrate($rs, $startcol);
|
||||
|
||||
$this->getDefaultConfig();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
12
plugins/stThemePlugin/lib/model/ThemeConfigPeer.php
Normal file
12
plugins/stThemePlugin/lib/model/ThemeConfigPeer.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for performing query and update operations on the 'st_theme_config' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model
|
||||
*/
|
||||
class ThemeConfigPeer extends BaseThemeConfigPeer
|
||||
{
|
||||
}
|
||||
91
plugins/stThemePlugin/lib/model/ThemeContent.php
Normal file
91
plugins/stThemePlugin/lib/model/ThemeContent.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for representing a row from the 'st_theme_content' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model
|
||||
*/
|
||||
class ThemeContent extends BaseThemeContent
|
||||
{
|
||||
public function hydrate(ResultSet $rs, $startcol = 1)
|
||||
{
|
||||
$this->setCulture(stLanguage::getHydrateCulture());
|
||||
|
||||
return parent::hydrate($rs, $startcol);
|
||||
}
|
||||
|
||||
public function setName($v)
|
||||
{
|
||||
if ($this->getCulture() == stLanguage::getOptLanguage())
|
||||
{
|
||||
stLanguage::setDefaultValue($this, __METHOD__, $v);
|
||||
}
|
||||
|
||||
parent::setName($v);
|
||||
}
|
||||
|
||||
public function getBackendName()
|
||||
{
|
||||
$culture = $this->getCulture();
|
||||
$this->setCulture(sfContext::getInstance()->getUser()->getCulture());
|
||||
$name = $this->getName();
|
||||
$this->setCulture($culture);
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
if ($this->getCulture() == stLanguage::getOptLanguage())
|
||||
{
|
||||
return stLanguage::getDefaultValue($this, __METHOD__);
|
||||
}
|
||||
|
||||
$v = parent::getName();
|
||||
|
||||
if (null === $v)
|
||||
{
|
||||
$v = stLanguage::getDefaultValue($this, __METHOD__);
|
||||
}
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
public function setContent($v)
|
||||
{
|
||||
if ($this->getCulture() == stLanguage::getOptLanguage())
|
||||
{
|
||||
stLanguage::setDefaultValue($this, __METHOD__, $v);
|
||||
}
|
||||
|
||||
parent::setContent($v);
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
if ($this->getCulture() == stLanguage::getOptLanguage())
|
||||
{
|
||||
return stLanguage::getDefaultValue($this, __METHOD__);
|
||||
}
|
||||
|
||||
$v = parent::getContent();
|
||||
|
||||
if (null === $v)
|
||||
{
|
||||
$v = stLanguage::getDefaultValue($this, __METHOD__);
|
||||
}
|
||||
|
||||
return trim($v);
|
||||
}
|
||||
|
||||
public function save($con = null)
|
||||
{
|
||||
$ret = parent::save($con);
|
||||
|
||||
stFunctionCache::getInstance('stThemePlugin')->removeAll();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
12
plugins/stThemePlugin/lib/model/ThemeContentI18n.php
Normal file
12
plugins/stThemePlugin/lib/model/ThemeContentI18n.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for representing a row from the 'st_theme_content_i18n' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model
|
||||
*/
|
||||
class ThemeContentI18n extends BaseThemeContentI18n
|
||||
{
|
||||
}
|
||||
12
plugins/stThemePlugin/lib/model/ThemeContentI18nPeer.php
Normal file
12
plugins/stThemePlugin/lib/model/ThemeContentI18nPeer.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for performing query and update operations on the 'st_theme_content_i18n' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model
|
||||
*/
|
||||
class ThemeContentI18nPeer extends BaseThemeContentI18nPeer
|
||||
{
|
||||
}
|
||||
12
plugins/stThemePlugin/lib/model/ThemeContentPeer.php
Normal file
12
plugins/stThemePlugin/lib/model/ThemeContentPeer.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for performing query and update operations on the 'st_theme_content' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model
|
||||
*/
|
||||
class ThemeContentPeer extends BaseThemeContentPeer
|
||||
{
|
||||
}
|
||||
40
plugins/stThemePlugin/lib/model/ThemeCss.php
Normal file
40
plugins/stThemePlugin/lib/model/ThemeCss.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SOTESHOP/stThemePlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stThemePlugin opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stThemePlugin
|
||||
* @subpackage lib
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
|
||||
* @version $Id: $
|
||||
* @author Michal Prochowski <michal.prochowski@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa ThemeCss
|
||||
*
|
||||
* @package stThemePlugin
|
||||
* @subpackage lib
|
||||
*/
|
||||
class ThemeCss extends BaseThemeCss
|
||||
{
|
||||
|
||||
/**
|
||||
* Przeciążenie zapisu
|
||||
*/
|
||||
public function save($con = null)
|
||||
{
|
||||
$ret = parent::save($con);
|
||||
|
||||
stTheme::clearCache();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
}
|
||||
71
plugins/stThemePlugin/lib/model/ThemeCssPeer.php
Normal file
71
plugins/stThemePlugin/lib/model/ThemeCssPeer.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SOTESHOP/stThemePlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stThemePlugin opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stThemePlugin
|
||||
* @subpackage lib
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
|
||||
* @version $Id: $
|
||||
* @author Michal Prochowski <michal.prochowski@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa ThemeCssPeer
|
||||
*
|
||||
* @package stThemePlugin
|
||||
* @subpackage lib
|
||||
*/
|
||||
class ThemeCssPeer extends BaseThemeCssPeer
|
||||
{
|
||||
|
||||
/**
|
||||
* Tablica z css'ami tematów graficznych
|
||||
* @var array
|
||||
*/
|
||||
protected static $css = array();
|
||||
|
||||
/**
|
||||
* Pobieranie dostępnych css'ów dla tematu graficznego
|
||||
*
|
||||
* @param int $id Numer id tematu graficznego
|
||||
* @return array
|
||||
*/
|
||||
public static function doSelectByThemeId($id)
|
||||
{
|
||||
if (!isset(self::$css[$id]))
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ThemeCssPeer::THEME_ID, $id);
|
||||
|
||||
$fc = new stFunctionCache('stThemePlugin');
|
||||
|
||||
self::$css[$id] = $fc->cacheCall(array('ThemeCssPeer', 'doSelect'), array($c), array('namespace' => 'model'));
|
||||
}
|
||||
|
||||
return self::$css[$id];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Przeciążanie funkcji onDelete
|
||||
*
|
||||
* @param mixed $values
|
||||
* @param PropelConnection $con
|
||||
*/
|
||||
public static function doDelete($values, $con = null)
|
||||
{
|
||||
$stCache = new stFunctionCache('stThemePlugin');
|
||||
$stCache->removeAll();
|
||||
|
||||
parent::doDelete($values, $con);
|
||||
}
|
||||
}
|
||||
23
plugins/stThemePlugin/lib/model/ThemeLayout.php
Normal file
23
plugins/stThemePlugin/lib/model/ThemeLayout.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for representing a row from the 'st_theme_layout' table.
|
||||
*
|
||||
* @package stThemePlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class ThemeLayout extends BaseThemeLayout
|
||||
{
|
||||
|
||||
public function save($con = null)
|
||||
{
|
||||
$this->getTheme()->setUpdatedAt(time());
|
||||
|
||||
$ret = parent::save($con);
|
||||
|
||||
stTheme::clearCache();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
}
|
||||
70
plugins/stThemePlugin/lib/model/ThemeLayoutPeer.php
Normal file
70
plugins/stThemePlugin/lib/model/ThemeLayoutPeer.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SOTESHOP/stThemePlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stThemePlugin opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stThemePlugin
|
||||
* @subpackage lib
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
|
||||
* @version $Id: $
|
||||
* @author Michal Prochowski <michal.prochowski@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa ThemeLayoutPeer
|
||||
*
|
||||
* @package stThemePlugin
|
||||
* @subpackage lib
|
||||
*/
|
||||
class ThemeLayoutPeer extends BaseThemeLayoutPeer
|
||||
{
|
||||
|
||||
/**
|
||||
* Tablica z układami tematów graficznych
|
||||
* @var array
|
||||
*/
|
||||
protected static $layouts = array();
|
||||
|
||||
/**
|
||||
* Pobieranie dostępnych układów dla tematu graficznego
|
||||
*
|
||||
* @param int $id Numer id tematu graficznego
|
||||
* @return array
|
||||
*/
|
||||
public static function doSelectByThemeId($id)
|
||||
{
|
||||
if (!isset(self::$layouts[$id]))
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ThemeLayoutPeer::THEME_ID, $id);
|
||||
|
||||
$fc = new stFunctionCache('stThemePlugin');
|
||||
|
||||
self::$layouts[$id] = $fc->cacheCall(array('ThemeLayoutPeer', 'doSelect'), array($c), array('namespace' => 'model'));
|
||||
}
|
||||
|
||||
return self::$layouts[$id];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Przeciążanie funkcji onDelete
|
||||
*
|
||||
* @param mixed $values
|
||||
* @param PropelConnection $con
|
||||
*/
|
||||
public static function doDelete($values, $con = null)
|
||||
{
|
||||
$stCache = new stFunctionCache('stThemePlugin');
|
||||
$stCache->removeAll();
|
||||
|
||||
parent::doDelete($values, $con);
|
||||
}
|
||||
}
|
||||
210
plugins/stThemePlugin/lib/model/ThemePeer.php
Normal file
210
plugins/stThemePlugin/lib/model/ThemePeer.php
Normal file
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SOTESHOP/stThemePlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stThemePlugin opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stThemePlugin
|
||||
* @subpackage lib
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
|
||||
* @version $Id: $
|
||||
* @author Michal Prochowski <michal.prochowski@sote.pl>
|
||||
*/
|
||||
|
||||
use ThemePeer as GlobalThemePeer;
|
||||
|
||||
/**
|
||||
* Klasa ThemePeer
|
||||
*
|
||||
* @package stThemePlugin
|
||||
* @subpackage lib
|
||||
*/
|
||||
class ThemePeer extends BaseThemePeer
|
||||
{
|
||||
protected static $cached = array();
|
||||
|
||||
/**
|
||||
* Aktywny temat graficzny
|
||||
* @var Theme
|
||||
*/
|
||||
protected static $activeTheme = null;
|
||||
|
||||
/**
|
||||
* Aktualizuje podstawową pamięć podręczną sklepu
|
||||
*
|
||||
* @param stSimpleShopDataCache|null $sc
|
||||
* @return stSimpleShopDataCache
|
||||
* @throws sfCacheException
|
||||
*/
|
||||
public static function doSimpleStoreUpdate(stSimpleShopDataCache $sc = null, Theme $theme = null)
|
||||
{
|
||||
if (null === $sc)
|
||||
{
|
||||
$sc = stSimpleShopDataCache::getInstance();
|
||||
}
|
||||
|
||||
if (null === $theme)
|
||||
{
|
||||
$theme = ThemePeer::doSelectActive();
|
||||
}
|
||||
|
||||
if ($theme)
|
||||
{
|
||||
$sc->set('theme', $theme->getBaseThemePath(true));
|
||||
}
|
||||
|
||||
$responsive = ThemePeer::retrieveResponsive();
|
||||
|
||||
if ($responsive)
|
||||
{
|
||||
$sc->set('responsive_theme', $responsive->getBaseThemePath(true));
|
||||
}
|
||||
|
||||
return $sc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca temat responsywny
|
||||
*
|
||||
* @return Theme
|
||||
*/
|
||||
public static function retrieveResponsive()
|
||||
{
|
||||
$responsive = stConfig::getInstance('stThemeBackend')->get('responsive');
|
||||
|
||||
return $responsive ? self::retrieveByPK($responsive) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobieranie aktywnego tematu graficznego
|
||||
*
|
||||
* @return Theme
|
||||
*/
|
||||
public static function doSelectActive()
|
||||
{
|
||||
if (null === self::$activeTheme)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(self::ACTIVE, true);
|
||||
|
||||
$fc = stFunctionCache::getInstance('stThemePlugin');
|
||||
|
||||
self::$activeTheme = $fc->cacheCall(array('ThemePeer', 'doSelectOne'), array($c));
|
||||
}
|
||||
|
||||
return self::$activeTheme;
|
||||
}
|
||||
|
||||
public static function retrieveByPKCached($id)
|
||||
{
|
||||
if (!$id)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!isset(self::$cached[$id]))
|
||||
{
|
||||
$fc = stFunctionCache::getInstance('stThemePlugin');
|
||||
|
||||
self::$cached[$id] = $fc->cacheCall(array('ThemePeer', 'retrieveByPK'), array($id));
|
||||
}
|
||||
|
||||
return self::$cached[$id];
|
||||
}
|
||||
|
||||
public static function doSelectBaseTheme(Criteria $c)
|
||||
{
|
||||
$c = clone $c;
|
||||
|
||||
$c->add(self::BASE_THEME_ID, null, Criteria::ISNULL);
|
||||
|
||||
$c->add(self::VERSION, 2, Criteria::GREATER_EQUAL);
|
||||
|
||||
return self::doSelect($c);
|
||||
}
|
||||
|
||||
public static function doSelectByName($name)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(self::THEME, $name);
|
||||
|
||||
return self::doSelectOne($c);
|
||||
}
|
||||
|
||||
public static function updateThemeImageConfiguration(Theme $current_theme, $for = null)
|
||||
{
|
||||
$asset_config = stConfig::getInstance('stAsset');
|
||||
|
||||
if (null === $for && $current_theme->getThemeConfig()->getConfigParameter('thumbs'))
|
||||
{
|
||||
$asset_config->setArray($current_theme->getThemeConfig()->getConfigParameter('thumbs'));
|
||||
$asset_config->save();
|
||||
}
|
||||
else
|
||||
{
|
||||
$paths = self::getThemeConfigurationPaths($current_theme, true);
|
||||
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
if (is_file($path))
|
||||
{
|
||||
$params = Yaml::parse($path);
|
||||
|
||||
if (isset($params['thumbs']))
|
||||
{
|
||||
if ($for && isset($params['thumbs'][$for]))
|
||||
{
|
||||
$values = $params['thumbs'][$for];
|
||||
|
||||
$current = $asset_config->get($for);
|
||||
|
||||
foreach ($values as $name => $value)
|
||||
{
|
||||
$current[$name] = array_merge($current[$name], $value);
|
||||
}
|
||||
|
||||
$asset_config->set($for, $current);
|
||||
|
||||
$asset_config->save();
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($params['thumbs'] as $section => $values)
|
||||
{
|
||||
$current = $asset_config->get($section);
|
||||
|
||||
foreach ($values as $name => $value)
|
||||
{
|
||||
$current[$name] = array_merge($current[$name], $value);
|
||||
}
|
||||
|
||||
$asset_config->set($section, $current);
|
||||
}
|
||||
|
||||
$asset_config->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getThemeConfigurationPaths(Theme $theme, $system = false, array &$paths = array())
|
||||
{
|
||||
if ($theme->hasBaseTheme())
|
||||
{
|
||||
self::getThemeConfigurationPaths($theme->getBaseTheme(), $system, $paths);
|
||||
}
|
||||
|
||||
$paths[] = $theme->getConfigurationPath($system);
|
||||
|
||||
return $paths;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_theme_color_scheme' table to 'propel' DatabaseMap object.
|
||||
*
|
||||
*
|
||||
*
|
||||
* These statically-built map classes are 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).
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model.map
|
||||
*/
|
||||
class ThemeColorSchemeMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stThemePlugin.lib.model.map.ThemeColorSchemeMapBuilder';
|
||||
|
||||
/**
|
||||
* The database map.
|
||||
*/
|
||||
private $dbMap;
|
||||
|
||||
/**
|
||||
* Tells us if this DatabaseMapBuilder is built so that we
|
||||
* don't have to re-build it every time.
|
||||
*
|
||||
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||
*/
|
||||
public function isBuilt()
|
||||
{
|
||||
return ($this->dbMap !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the databasemap this map builder built.
|
||||
*
|
||||
* @return the databasemap
|
||||
*/
|
||||
public function getDatabaseMap()
|
||||
{
|
||||
return $this->dbMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The doBuild() method builds the DatabaseMap
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function doBuild()
|
||||
{
|
||||
$this->dbMap = Propel::getDatabaseMap('propel');
|
||||
|
||||
$tMap = $this->dbMap->addTable('st_theme_color_scheme');
|
||||
$tMap->setPhpName('ThemeColorScheme');
|
||||
|
||||
$tMap->setUseIdGenerator(true);
|
||||
|
||||
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addForeignKey('THEME_ID', 'ThemeId', 'int', CreoleTypes::INTEGER, 'st_theme', 'ID', true, null);
|
||||
|
||||
$tMap->addColumn('NAME', 'Name', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addColumn('IS_DEFAULT', 'IsDefault', 'boolean', CreoleTypes::BOOLEAN, false, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // ThemeColorSchemeMapBuilder
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_theme_config' table to 'propel' DatabaseMap object.
|
||||
*
|
||||
*
|
||||
*
|
||||
* These statically-built map classes are 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).
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model.map
|
||||
*/
|
||||
class ThemeConfigMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stThemePlugin.lib.model.map.ThemeConfigMapBuilder';
|
||||
|
||||
/**
|
||||
* The database map.
|
||||
*/
|
||||
private $dbMap;
|
||||
|
||||
/**
|
||||
* Tells us if this DatabaseMapBuilder is built so that we
|
||||
* don't have to re-build it every time.
|
||||
*
|
||||
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||
*/
|
||||
public function isBuilt()
|
||||
{
|
||||
return ($this->dbMap !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the databasemap this map builder built.
|
||||
*
|
||||
* @return the databasemap
|
||||
*/
|
||||
public function getDatabaseMap()
|
||||
{
|
||||
return $this->dbMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The doBuild() method builds the DatabaseMap
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function doBuild()
|
||||
{
|
||||
$this->dbMap = Propel::getDatabaseMap('propel');
|
||||
|
||||
$tMap = $this->dbMap->addTable('st_theme_config');
|
||||
$tMap->setPhpName('ThemeConfig');
|
||||
|
||||
$tMap->setUseIdGenerator(false);
|
||||
|
||||
$tMap->addForeignPrimaryKey('ID', 'Id', 'int' , CreoleTypes::INTEGER, 'st_theme', 'ID', true, null);
|
||||
|
||||
$tMap->addColumn('PARAMETERS', 'Parameters', 'array', CreoleTypes::LONGVARCHAR, false, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // ThemeConfigMapBuilder
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_theme_content_i18n' table to 'propel' DatabaseMap object.
|
||||
*
|
||||
*
|
||||
*
|
||||
* These statically-built map classes are 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).
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model.map
|
||||
*/
|
||||
class ThemeContentI18nMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stThemePlugin.lib.model.map.ThemeContentI18nMapBuilder';
|
||||
|
||||
/**
|
||||
* The database map.
|
||||
*/
|
||||
private $dbMap;
|
||||
|
||||
/**
|
||||
* Tells us if this DatabaseMapBuilder is built so that we
|
||||
* don't have to re-build it every time.
|
||||
*
|
||||
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||
*/
|
||||
public function isBuilt()
|
||||
{
|
||||
return ($this->dbMap !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the databasemap this map builder built.
|
||||
*
|
||||
* @return the databasemap
|
||||
*/
|
||||
public function getDatabaseMap()
|
||||
{
|
||||
return $this->dbMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The doBuild() method builds the DatabaseMap
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function doBuild()
|
||||
{
|
||||
$this->dbMap = Propel::getDatabaseMap('propel');
|
||||
|
||||
$tMap = $this->dbMap->addTable('st_theme_content_i18n');
|
||||
$tMap->setPhpName('ThemeContentI18n');
|
||||
|
||||
$tMap->setUseIdGenerator(false);
|
||||
|
||||
$tMap->addForeignPrimaryKey('ID', 'Id', 'int' , CreoleTypes::INTEGER, 'st_theme_content', 'ID', true, null);
|
||||
|
||||
$tMap->addPrimaryKey('CULTURE', 'Culture', 'string', CreoleTypes::VARCHAR, true, 7);
|
||||
|
||||
$tMap->addColumn('NAME', 'Name', 'string', CreoleTypes::VARCHAR, true, 64);
|
||||
|
||||
$tMap->addColumn('CONTENT', 'Content', 'string', CreoleTypes::LONGVARCHAR, false, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // ThemeContentI18nMapBuilder
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_theme_content' table to 'propel' DatabaseMap object.
|
||||
*
|
||||
*
|
||||
*
|
||||
* These statically-built map classes are 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).
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model.map
|
||||
*/
|
||||
class ThemeContentMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stThemePlugin.lib.model.map.ThemeContentMapBuilder';
|
||||
|
||||
/**
|
||||
* The database map.
|
||||
*/
|
||||
private $dbMap;
|
||||
|
||||
/**
|
||||
* Tells us if this DatabaseMapBuilder is built so that we
|
||||
* don't have to re-build it every time.
|
||||
*
|
||||
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||
*/
|
||||
public function isBuilt()
|
||||
{
|
||||
return ($this->dbMap !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the databasemap this map builder built.
|
||||
*
|
||||
* @return the databasemap
|
||||
*/
|
||||
public function getDatabaseMap()
|
||||
{
|
||||
return $this->dbMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The doBuild() method builds the DatabaseMap
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function doBuild()
|
||||
{
|
||||
$this->dbMap = Propel::getDatabaseMap('propel');
|
||||
|
||||
$tMap = $this->dbMap->addTable('st_theme_content');
|
||||
$tMap->setPhpName('ThemeContent');
|
||||
|
||||
$tMap->setUseIdGenerator(true);
|
||||
|
||||
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addForeignKey('THEME_ID', 'ThemeId', 'int', CreoleTypes::INTEGER, 'st_theme', 'ID', true, null);
|
||||
|
||||
$tMap->addColumn('CONTENT_ID', 'ContentId', 'string', CreoleTypes::VARCHAR, true, 48);
|
||||
|
||||
$tMap->addColumn('OPT_NAME', 'OptName', 'string', CreoleTypes::VARCHAR, true, 64);
|
||||
|
||||
$tMap->addColumn('OPT_CONTENT', 'OptContent', 'string', CreoleTypes::LONGVARCHAR, false, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // ThemeContentMapBuilder
|
||||
74
plugins/stThemePlugin/lib/model/map/ThemeCssMapBuilder.php
Normal file
74
plugins/stThemePlugin/lib/model/map/ThemeCssMapBuilder.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_theme_css' table to 'propel' DatabaseMap object.
|
||||
*
|
||||
*
|
||||
*
|
||||
* These statically-built map classes are 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).
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model.map
|
||||
*/
|
||||
class ThemeCssMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stThemePlugin.lib.model.map.ThemeCssMapBuilder';
|
||||
|
||||
/**
|
||||
* The database map.
|
||||
*/
|
||||
private $dbMap;
|
||||
|
||||
/**
|
||||
* Tells us if this DatabaseMapBuilder is built so that we
|
||||
* don't have to re-build it every time.
|
||||
*
|
||||
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||
*/
|
||||
public function isBuilt()
|
||||
{
|
||||
return ($this->dbMap !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the databasemap this map builder built.
|
||||
*
|
||||
* @return the databasemap
|
||||
*/
|
||||
public function getDatabaseMap()
|
||||
{
|
||||
return $this->dbMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The doBuild() method builds the DatabaseMap
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function doBuild()
|
||||
{
|
||||
$this->dbMap = Propel::getDatabaseMap('propel');
|
||||
|
||||
$tMap = $this->dbMap->addTable('st_theme_css');
|
||||
$tMap->setPhpName('ThemeCss');
|
||||
|
||||
$tMap->setUseIdGenerator(true);
|
||||
|
||||
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addForeignKey('THEME_ID', 'ThemeId', 'int', CreoleTypes::INTEGER, 'st_theme', 'ID', true, null);
|
||||
|
||||
$tMap->addColumn('CSS_HEAD_ID', 'CssHeadId', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addColumn('CSS_CONTENT', 'CssContent', 'string', CreoleTypes::LONGVARCHAR, false, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // ThemeCssMapBuilder
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_theme_layout' table to 'propel' DatabaseMap object.
|
||||
*
|
||||
*
|
||||
*
|
||||
* These statically-built map classes are 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).
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model.map
|
||||
*/
|
||||
class ThemeLayoutMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stThemePlugin.lib.model.map.ThemeLayoutMapBuilder';
|
||||
|
||||
/**
|
||||
* The database map.
|
||||
*/
|
||||
private $dbMap;
|
||||
|
||||
/**
|
||||
* Tells us if this DatabaseMapBuilder is built so that we
|
||||
* don't have to re-build it every time.
|
||||
*
|
||||
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||
*/
|
||||
public function isBuilt()
|
||||
{
|
||||
return ($this->dbMap !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the databasemap this map builder built.
|
||||
*
|
||||
* @return the databasemap
|
||||
*/
|
||||
public function getDatabaseMap()
|
||||
{
|
||||
return $this->dbMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The doBuild() method builds the DatabaseMap
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function doBuild()
|
||||
{
|
||||
$this->dbMap = Propel::getDatabaseMap('propel');
|
||||
|
||||
$tMap = $this->dbMap->addTable('st_theme_layout');
|
||||
$tMap->setPhpName('ThemeLayout');
|
||||
|
||||
$tMap->setUseIdGenerator(true);
|
||||
|
||||
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addForeignKey('THEME_ID', 'ThemeId', 'int', CreoleTypes::INTEGER, 'st_theme', 'ID', true, null);
|
||||
|
||||
$tMap->addForeignKey('SF_GUARD_USER_ID', 'SfGuardUserId', 'int', CreoleTypes::INTEGER, 'sf_guard_user', 'ID', false, null);
|
||||
|
||||
$tMap->addColumn('CONTAINER', 'Container', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addColumn('BLOCKS', 'Blocks', 'string', CreoleTypes::LONGVARCHAR, false, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // ThemeLayoutMapBuilder
|
||||
82
plugins/stThemePlugin/lib/model/map/ThemeMapBuilder.php
Normal file
82
plugins/stThemePlugin/lib/model/map/ThemeMapBuilder.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_theme' table to 'propel' DatabaseMap object.
|
||||
*
|
||||
*
|
||||
*
|
||||
* These statically-built map classes are 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).
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model.map
|
||||
*/
|
||||
class ThemeMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stThemePlugin.lib.model.map.ThemeMapBuilder';
|
||||
|
||||
/**
|
||||
* The database map.
|
||||
*/
|
||||
private $dbMap;
|
||||
|
||||
/**
|
||||
* Tells us if this DatabaseMapBuilder is built so that we
|
||||
* don't have to re-build it every time.
|
||||
*
|
||||
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||
*/
|
||||
public function isBuilt()
|
||||
{
|
||||
return ($this->dbMap !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the databasemap this map builder built.
|
||||
*
|
||||
* @return the databasemap
|
||||
*/
|
||||
public function getDatabaseMap()
|
||||
{
|
||||
return $this->dbMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The doBuild() method builds the DatabaseMap
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function doBuild()
|
||||
{
|
||||
$this->dbMap = Propel::getDatabaseMap('propel');
|
||||
|
||||
$tMap = $this->dbMap->addTable('st_theme');
|
||||
$tMap->setPhpName('Theme');
|
||||
|
||||
$tMap->setUseIdGenerator(true);
|
||||
|
||||
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addForeignKey('BASE_THEME_ID', 'BaseThemeId', 'int', CreoleTypes::INTEGER, 'st_theme', 'ID', false, null);
|
||||
|
||||
$tMap->addColumn('THEME', 'Theme', 'string', CreoleTypes::VARCHAR, true, 48);
|
||||
|
||||
$tMap->addColumn('ACTIVE', 'Active', 'boolean', CreoleTypes::BOOLEAN, false, null);
|
||||
|
||||
$tMap->addColumn('OPT_COLOR_SCHEME', 'OptColorScheme', 'string', CreoleTypes::VARCHAR, false, 32);
|
||||
|
||||
$tMap->addColumn('VERSION', 'Version', 'int', CreoleTypes::INTEGER, false, null);
|
||||
|
||||
$tMap->addColumn('IS_SYSTEM_DEFAULT', 'IsSystemDefault', 'boolean', CreoleTypes::BOOLEAN, true, null);
|
||||
|
||||
$tMap->addColumn('IS_HIDDEN', 'IsHidden', 'boolean', CreoleTypes::BOOLEAN, true, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // ThemeMapBuilder
|
||||
2047
plugins/stThemePlugin/lib/model/om/BaseTheme.php
Normal file
2047
plugins/stThemePlugin/lib/model/om/BaseTheme.php
Normal file
File diff suppressed because it is too large
Load Diff
823
plugins/stThemePlugin/lib/model/om/BaseThemeColorScheme.php
Normal file
823
plugins/stThemePlugin/lib/model/om/BaseThemeColorScheme.php
Normal file
@@ -0,0 +1,823 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'st_theme_color_scheme' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseThemeColorScheme extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
protected static $dispatcher = null;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the theme_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $theme_id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the name field.
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the is_default field.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $is_default = false;
|
||||
|
||||
/**
|
||||
* @var Theme
|
||||
*/
|
||||
protected $aTheme;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInSave = false;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless validation loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInValidation = false;
|
||||
|
||||
/**
|
||||
* Get the [id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [theme_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getThemeId()
|
||||
{
|
||||
|
||||
return $this->theme_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [name] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [is_default] column value.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getIsDefault()
|
||||
{
|
||||
|
||||
return $this->is_default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->id !== $v) {
|
||||
$this->id = $v;
|
||||
$this->modifiedColumns[] = ThemeColorSchemePeer::ID;
|
||||
}
|
||||
|
||||
} // setId()
|
||||
|
||||
/**
|
||||
* Set the value of [theme_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setThemeId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->theme_id !== $v) {
|
||||
$this->theme_id = $v;
|
||||
$this->modifiedColumns[] = ThemeColorSchemePeer::THEME_ID;
|
||||
}
|
||||
|
||||
if ($this->aTheme !== null && $this->aTheme->getId() !== $v) {
|
||||
$this->aTheme = null;
|
||||
}
|
||||
|
||||
} // setThemeId()
|
||||
|
||||
/**
|
||||
* Set the value of [name] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setName($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_string($v)) {
|
||||
$v = (string) $v;
|
||||
}
|
||||
|
||||
if ($this->name !== $v) {
|
||||
$this->name = $v;
|
||||
$this->modifiedColumns[] = ThemeColorSchemePeer::NAME;
|
||||
}
|
||||
|
||||
} // setName()
|
||||
|
||||
/**
|
||||
* Set the value of [is_default] column.
|
||||
*
|
||||
* @param boolean $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setIsDefault($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_bool($v)) {
|
||||
$v = (bool) $v;
|
||||
}
|
||||
|
||||
if ($this->is_default !== $v || $v === false) {
|
||||
$this->is_default = $v;
|
||||
$this->modifiedColumns[] = ThemeColorSchemePeer::IS_DEFAULT;
|
||||
}
|
||||
|
||||
} // setIsDefault()
|
||||
|
||||
/**
|
||||
* Hydrates (populates) the object variables with values from the database resultset.
|
||||
*
|
||||
* An offset (1-based "start column") is specified so that objects can be hydrated
|
||||
* with a subset of the columns in the resultset rows. This is needed, for example,
|
||||
* for results of JOIN queries where the resultset row includes columns from two or
|
||||
* more tables.
|
||||
*
|
||||
* @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
|
||||
* @param int $startcol 1-based offset column which indicates which restultset column to start with.
|
||||
* @return int next starting column
|
||||
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
|
||||
*/
|
||||
public function hydrate(ResultSet $rs, $startcol = 1)
|
||||
{
|
||||
try {
|
||||
if ($this->getDispatcher()->getListeners('ThemeColorScheme.preHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'ThemeColorScheme.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
|
||||
$startcol = $event['startcol'];
|
||||
}
|
||||
|
||||
$this->id = $rs->getInt($startcol + 0);
|
||||
|
||||
$this->theme_id = $rs->getInt($startcol + 1);
|
||||
|
||||
$this->name = $rs->getString($startcol + 2);
|
||||
|
||||
$this->is_default = $rs->getBoolean($startcol + 3);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
if ($this->getDispatcher()->getListeners('ThemeColorScheme.postHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'ThemeColorScheme.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 4)));
|
||||
return $event['startcol'];
|
||||
}
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 4; // 4 = ThemeColorSchemePeer::NUM_COLUMNS - ThemeColorSchemePeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating ThemeColorScheme object", $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this object from datastore and sets delete attribute.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
* @see BaseObject::setDeleted()
|
||||
* @see BaseObject::isDeleted()
|
||||
*/
|
||||
public function delete($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("This object has already been deleted.");
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('ThemeColorScheme.preDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'ThemeColorScheme.preDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseThemeColorScheme:delete:pre'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseThemeColorScheme:delete:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, $this, $con);
|
||||
if ($ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(ThemeColorSchemePeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
ThemeColorSchemePeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('ThemeColorScheme.postDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'ThemeColorScheme.postDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseThemeColorScheme:delete:post'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseThemeColorScheme:delete:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database. If the object is new,
|
||||
* it inserts it; otherwise an update is performed. This method
|
||||
* wraps the doSave() worker method in a transaction.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see doSave()
|
||||
*/
|
||||
public function save($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("You cannot save an object that has been deleted.");
|
||||
}
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('ThemeColorScheme.preSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'ThemeColorScheme.preSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeColorScheme:save:pre') as $callable)
|
||||
{
|
||||
$affectedRows = call_user_func($callable, $this, $con);
|
||||
if (is_int($affectedRows))
|
||||
{
|
||||
return $affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(ThemeColorSchemePeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('ThemeColorScheme.postSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'ThemeColorScheme.postSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeColorScheme:save:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con, $affectedRows);
|
||||
}
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database.
|
||||
*
|
||||
* If the object is new, it inserts it; otherwise an update is performed.
|
||||
* All related objects are also updated in this method.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see save()
|
||||
*/
|
||||
protected function doSave($con)
|
||||
{
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
if (!$this->alreadyInSave) {
|
||||
$this->alreadyInSave = true;
|
||||
|
||||
|
||||
// We call the save method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->aTheme !== null) {
|
||||
if ($this->aTheme->isModified()) {
|
||||
$affectedRows += $this->aTheme->save($con);
|
||||
}
|
||||
$this->setTheme($this->aTheme);
|
||||
}
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = ThemeColorSchemePeer::doInsert($this, $con);
|
||||
$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
|
||||
// should always be true here (even though technically
|
||||
// BasePeer::doInsert() can insert multiple rows).
|
||||
|
||||
$this->setId($pk); //[IMV] update autoincrement primary key
|
||||
|
||||
$this->setNew(false);
|
||||
} else {
|
||||
$affectedRows += ThemeColorSchemePeer::doUpdate($this, $con);
|
||||
}
|
||||
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
|
||||
}
|
||||
|
||||
$this->alreadyInSave = false;
|
||||
}
|
||||
return $affectedRows;
|
||||
} // doSave()
|
||||
|
||||
/**
|
||||
* Array of ValidationFailed objects.
|
||||
* @var array ValidationFailed[]
|
||||
*/
|
||||
protected $validationFailures = array();
|
||||
|
||||
/**
|
||||
* Gets any ValidationFailed objects that resulted from last call to validate().
|
||||
*
|
||||
*
|
||||
* @return array ValidationFailed[]
|
||||
* @see validate()
|
||||
*/
|
||||
public function getValidationFailures()
|
||||
{
|
||||
return $this->validationFailures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the objects modified field values and all objects related to this table.
|
||||
*
|
||||
* If $columns is either a column name or an array of column names
|
||||
* only those columns are validated.
|
||||
*
|
||||
* @param mixed $columns Column name or an array of column names.
|
||||
* @return boolean Whether all columns pass validation.
|
||||
* @see doValidate()
|
||||
* @see getValidationFailures()
|
||||
*/
|
||||
public function validate($columns = null)
|
||||
{
|
||||
$res = $this->doValidate($columns);
|
||||
if ($res === true) {
|
||||
$this->validationFailures = array();
|
||||
return true;
|
||||
} else {
|
||||
$this->validationFailures = $res;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function performs the validation work for complex object models.
|
||||
*
|
||||
* In addition to checking the current object, all related objects will
|
||||
* also be validated. If all pass then <code>true</code> is returned; otherwise
|
||||
* an aggreagated array of ValidationFailed objects will be returned.
|
||||
*
|
||||
* @param array $columns Array of column names to validate.
|
||||
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
|
||||
*/
|
||||
protected function doValidate($columns = null)
|
||||
{
|
||||
if (!$this->alreadyInValidation) {
|
||||
$this->alreadyInValidation = true;
|
||||
$retval = null;
|
||||
|
||||
$failureMap = array();
|
||||
|
||||
|
||||
// We call the validate method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->aTheme !== null) {
|
||||
if (!$this->aTheme->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->aTheme->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($retval = ThemeColorSchemePeer::doValidate($this, $columns)) !== true) {
|
||||
$failureMap = array_merge($failureMap, $retval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->alreadyInValidation = false;
|
||||
}
|
||||
|
||||
return (!empty($failureMap) ? $failureMap : true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name name
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return mixed Value of field.
|
||||
*/
|
||||
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = ThemeColorSchemePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->getByPosition($pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @return mixed Value of field at $pos
|
||||
*/
|
||||
public function getByPosition($pos)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
return $this->getId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getThemeId();
|
||||
break;
|
||||
case 2:
|
||||
return $this->getName();
|
||||
break;
|
||||
case 3:
|
||||
return $this->getIsDefault();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the object as an array.
|
||||
*
|
||||
* You can specify the key type of the array by passing one of the class
|
||||
* type constants.
|
||||
*
|
||||
* @param string $keyType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return an associative array containing the field names (as keys) and field values
|
||||
*/
|
||||
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = ThemeColorSchemePeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getId(),
|
||||
$keys[1] => $this->getThemeId(),
|
||||
$keys[2] => $this->getName(),
|
||||
$keys[3] => $this->getIsDefault(),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name peer name
|
||||
* @param mixed $value field value
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return void
|
||||
*/
|
||||
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = ThemeColorSchemePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->setByPosition($pos, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @param mixed $value field value
|
||||
* @return void
|
||||
*/
|
||||
public function setByPosition($pos, $value)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
$this->setId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setThemeId($value);
|
||||
break;
|
||||
case 2:
|
||||
$this->setName($value);
|
||||
break;
|
||||
case 3:
|
||||
$this->setIsDefault($value);
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the object using an array.
|
||||
*
|
||||
* This is particularly useful when populating an object from one of the
|
||||
* request arrays (e.g. $_POST). This method goes through the column
|
||||
* names, checking to see whether a matching key exists in populated
|
||||
* array. If so the setByName() method is called for that column.
|
||||
*
|
||||
* You can specify the key type of the array by additionally passing one
|
||||
* of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
|
||||
* TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
|
||||
*
|
||||
* @param array $arr An array to populate the object from.
|
||||
* @param string $keyType The type of keys the array uses.
|
||||
* @return void
|
||||
*/
|
||||
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = ThemeColorSchemePeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setThemeId($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setName($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setIsDefault($arr[$keys[3]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Criteria object containing the values of all modified columns in this object.
|
||||
*
|
||||
* @return Criteria The Criteria object containing all modified values.
|
||||
*/
|
||||
public function buildCriteria()
|
||||
{
|
||||
$criteria = new Criteria(ThemeColorSchemePeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(ThemeColorSchemePeer::ID)) $criteria->add(ThemeColorSchemePeer::ID, $this->id);
|
||||
if ($this->isColumnModified(ThemeColorSchemePeer::THEME_ID)) $criteria->add(ThemeColorSchemePeer::THEME_ID, $this->theme_id);
|
||||
if ($this->isColumnModified(ThemeColorSchemePeer::NAME)) $criteria->add(ThemeColorSchemePeer::NAME, $this->name);
|
||||
if ($this->isColumnModified(ThemeColorSchemePeer::IS_DEFAULT)) $criteria->add(ThemeColorSchemePeer::IS_DEFAULT, $this->is_default);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a Criteria object containing the primary key for this object.
|
||||
*
|
||||
* Unlike buildCriteria() this method includes the primary key values regardless
|
||||
* of whether or not they have been modified.
|
||||
*
|
||||
* @return Criteria The Criteria object containing value(s) for primary key(s).
|
||||
*/
|
||||
public function buildPkeyCriteria()
|
||||
{
|
||||
$criteria = new Criteria(ThemeColorSchemePeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(ThemeColorSchemePeer::ID, $this->id);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary key for this object (row).
|
||||
* @return int
|
||||
*/
|
||||
public function getPrimaryKey()
|
||||
{
|
||||
return $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [composite] primary key fields
|
||||
*
|
||||
* @param string $keyType
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
return array(ThemeColorSchemePeer::translateFieldName('id', BasePeer::TYPE_FIELDNAME, $keyType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method to set the primary key (id column).
|
||||
*
|
||||
* @param int $key Primary key.
|
||||
* @return void
|
||||
*/
|
||||
public function setPrimaryKey($key)
|
||||
{
|
||||
$this->setId($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contents of passed object to values from current object.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param object $copyObj An object of ThemeColorScheme (or compatible) type.
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copyInto($copyObj, $deepCopy = false)
|
||||
{
|
||||
|
||||
$copyObj->setThemeId($this->theme_id);
|
||||
|
||||
$copyObj->setName($this->name);
|
||||
|
||||
$copyObj->setIsDefault($this->is_default);
|
||||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
|
||||
$copyObj->setId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a copy of this object that will be inserted as a new row in table when saved.
|
||||
* It creates a new object filling in the simple attributes, but skipping any primary
|
||||
* keys that are defined for the table.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @return ThemeColorScheme Clone of current object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copy($deepCopy = false)
|
||||
{
|
||||
// we use get_class(), because this might be a subclass
|
||||
$clazz = get_class($this);
|
||||
$copyObj = new $clazz();
|
||||
$this->copyInto($copyObj, $deepCopy);
|
||||
return $copyObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a peer instance associated with this om.
|
||||
*
|
||||
* @return string Peer class name
|
||||
*/
|
||||
public function getPeer()
|
||||
{
|
||||
return 'ThemeColorSchemePeer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a Theme object.
|
||||
*
|
||||
* @param Theme $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setTheme($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setThemeId(NULL);
|
||||
} else {
|
||||
$this->setThemeId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->aTheme = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated Theme object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return Theme The associated Theme object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getTheme($con = null)
|
||||
{
|
||||
if ($this->aTheme === null && ($this->theme_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->aTheme = ThemePeer::retrieveByPK($this->theme_id, $con);
|
||||
|
||||
/* The following can be used instead of the line above to
|
||||
guarantee the related object contains a reference
|
||||
to this object, but this level of coupling
|
||||
may be undesirable in many circumstances.
|
||||
As it can lead to a db query with many results that may
|
||||
never be used.
|
||||
$obj = ThemePeer::retrieveByPK($this->theme_id, $con);
|
||||
$obj->addThemes($this);
|
||||
*/
|
||||
}
|
||||
return $this->aTheme;
|
||||
}
|
||||
|
||||
|
||||
public function getDispatcher()
|
||||
{
|
||||
if (null === self::$dispatcher)
|
||||
{
|
||||
self::$dispatcher = stEventDispatcher::getInstance();
|
||||
}
|
||||
|
||||
return self::$dispatcher;
|
||||
}
|
||||
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
$event = $this->getDispatcher()->notifyUntil(new sfEvent($this, 'ThemeColorScheme.' . $method, array('arguments' => $arguments, 'method' => $method)));
|
||||
|
||||
if ($event->isProcessed())
|
||||
{
|
||||
return $event->getReturnValue();
|
||||
}
|
||||
|
||||
if (!$callable = sfMixer::getCallable('BaseThemeColorScheme:'.$method))
|
||||
{
|
||||
throw new sfException(sprintf('Call to undefined method BaseThemeColorScheme::%s', $method));
|
||||
}
|
||||
|
||||
array_unshift($arguments, $this);
|
||||
|
||||
return call_user_func_array($callable, $arguments);
|
||||
}
|
||||
|
||||
} // BaseThemeColorScheme
|
||||
851
plugins/stThemePlugin/lib/model/om/BaseThemeColorSchemePeer.php
Normal file
851
plugins/stThemePlugin/lib/model/om/BaseThemeColorSchemePeer.php
Normal file
@@ -0,0 +1,851 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base static class for performing query and update operations on the 'st_theme_color_scheme' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseThemeColorSchemePeer {
|
||||
|
||||
/** the default database name for this class */
|
||||
const DATABASE_NAME = 'propel';
|
||||
|
||||
/** the table name for this class */
|
||||
const TABLE_NAME = 'st_theme_color_scheme';
|
||||
|
||||
/** A class that can be returned by this peer. */
|
||||
const CLASS_DEFAULT = 'plugins.stThemePlugin.lib.model.ThemeColorScheme';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 4;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
|
||||
/** the column name for the ID field */
|
||||
const ID = 'st_theme_color_scheme.ID';
|
||||
|
||||
/** the column name for the THEME_ID field */
|
||||
const THEME_ID = 'st_theme_color_scheme.THEME_ID';
|
||||
|
||||
/** the column name for the NAME field */
|
||||
const NAME = 'st_theme_color_scheme.NAME';
|
||||
|
||||
/** the column name for the IS_DEFAULT field */
|
||||
const IS_DEFAULT = 'st_theme_color_scheme.IS_DEFAULT';
|
||||
|
||||
/** The PHP to DB Name Mapping */
|
||||
private static $phpNameMap = null;
|
||||
|
||||
|
||||
/**
|
||||
* holds an array of fieldnames
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id', 'ThemeId', 'Name', 'IsDefault', ),
|
||||
BasePeer::TYPE_COLNAME => array (ThemeColorSchemePeer::ID, ThemeColorSchemePeer::THEME_ID, ThemeColorSchemePeer::NAME, ThemeColorSchemePeer::IS_DEFAULT, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'theme_id', 'name', 'is_default', ),
|
||||
BasePeer::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::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ThemeId' => 1, 'Name' => 2, 'IsDefault' => 3, ),
|
||||
BasePeer::TYPE_COLNAME => array (ThemeColorSchemePeer::ID => 0, ThemeColorSchemePeer::THEME_ID => 1, ThemeColorSchemePeer::NAME => 2, ThemeColorSchemePeer::IS_DEFAULT => 3, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'theme_id' => 1, 'name' => 2, 'is_default' => 3, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
|
||||
);
|
||||
|
||||
protected static $hydrateMethod = null;
|
||||
|
||||
protected static $postHydrateMethod = null;
|
||||
|
||||
public static function setHydrateMethod($callback)
|
||||
{
|
||||
self::$hydrateMethod = $callback;
|
||||
}
|
||||
|
||||
public static function setPostHydrateMethod($callback)
|
||||
{
|
||||
self::$postHydrateMethod = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MapBuilder the map builder for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getMapBuilder()
|
||||
{
|
||||
return BasePeer::getMapBuilder('plugins.stThemePlugin.lib.model.map.ThemeColorSchemeMapBuilder');
|
||||
}
|
||||
/**
|
||||
* Gets a map (hash) of PHP names to DB column names.
|
||||
*
|
||||
* @return array The PHP to DB name map for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
|
||||
*/
|
||||
public static function getPhpNameMap()
|
||||
{
|
||||
if (self::$phpNameMap === null) {
|
||||
$map = ThemeColorSchemePeer::getTableMap();
|
||||
$columns = $map->getColumns();
|
||||
$nameMap = array();
|
||||
foreach ($columns as $column) {
|
||||
$nameMap[$column->getPhpName()] = $column->getColumnName();
|
||||
}
|
||||
self::$phpNameMap = $nameMap;
|
||||
}
|
||||
return self::$phpNameMap;
|
||||
}
|
||||
/**
|
||||
* Translates a fieldname to another type
|
||||
*
|
||||
* @param string $name field name
|
||||
* @param string $fromType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @param string $toType One of the class type constants
|
||||
* @return string translated name of the field.
|
||||
*/
|
||||
static public function translateFieldName($name, $fromType, $toType)
|
||||
{
|
||||
$toNames = self::getFieldNames($toType);
|
||||
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
|
||||
if ($key === null) {
|
||||
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
|
||||
}
|
||||
return $toNames[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of of field names.
|
||||
*
|
||||
* @param string $type The type of fieldnames to return:
|
||||
* One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return array A list of field names
|
||||
*/
|
||||
|
||||
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
if (!array_key_exists($type, self::$fieldNames)) {
|
||||
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
|
||||
}
|
||||
return self::$fieldNames[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method which changes table.column to alias.column.
|
||||
*
|
||||
* Using this method you can maintain SQL abstraction while using column aliases.
|
||||
* <code>
|
||||
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
|
||||
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
|
||||
* </code>
|
||||
* @param string $alias The alias for the current table.
|
||||
* @param string $column The column name for current table. (i.e. ThemeColorSchemePeer::COLUMN_NAME).
|
||||
* @return string
|
||||
*/
|
||||
public static function alias($alias, $column)
|
||||
{
|
||||
return str_replace(ThemeColorSchemePeer::TABLE_NAME.'.', $alias.'.', $column);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 object containing the columns to add.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function addSelectColumns(Criteria $criteria)
|
||||
{
|
||||
|
||||
$criteria->addSelectColumn(ThemeColorSchemePeer::ID);
|
||||
|
||||
$criteria->addSelectColumn(ThemeColorSchemePeer::THEME_ID);
|
||||
|
||||
$criteria->addSelectColumn(ThemeColorSchemePeer::NAME);
|
||||
|
||||
$criteria->addSelectColumn(ThemeColorSchemePeer::IS_DEFAULT);
|
||||
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('ThemeColorSchemePeer.postAddSelectColumns')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'ThemeColorSchemePeer.postAddSelectColumns'));
|
||||
}
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(st_theme_color_scheme.ID)';
|
||||
const COUNT_DISTINCT = 'COUNT(DISTINCT st_theme_color_scheme.ID)';
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(ThemeColorSchemePeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(ThemeColorSchemePeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$rs = ThemeColorSchemePeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Method to select one object from the DB.
|
||||
*
|
||||
* @param Criteria $criteria object used to create the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return ThemeColorScheme
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectOne(Criteria $criteria, $con = null)
|
||||
{
|
||||
$critcopy = clone $criteria;
|
||||
$critcopy->setLimit(1);
|
||||
$objects = ThemeColorSchemePeer::doSelect($critcopy, $con);
|
||||
if ($objects) {
|
||||
return $objects[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Method to do selects.
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return ThemeColorScheme[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelect(Criteria $criteria, $con = null)
|
||||
{
|
||||
return ThemeColorSchemePeer::populateObjects(ThemeColorSchemePeer::doSelectRS($criteria, $con));
|
||||
}
|
||||
/**
|
||||
* Prepares the Criteria object and uses the parent doSelect()
|
||||
* method to get a ResultSet.
|
||||
*
|
||||
* Use this method directly if you want to just get the resultset
|
||||
* (instead of an array of objects).
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return ResultSet The resultset object with numerically-indexed fields.
|
||||
* @see BasePeer::doSelect()
|
||||
*/
|
||||
public static function doSelectRS(Criteria $criteria, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if (!$criteria->getSelectColumns()) {
|
||||
$criteria = clone $criteria;
|
||||
ThemeColorSchemePeer::addSelectColumns($criteria);
|
||||
}
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.preDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'BasePeer.preDoSelectRs'));
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
// BasePeer returns a Creole ResultSet, set to return
|
||||
// rows indexed numerically.
|
||||
$rs = BasePeer::doSelect($criteria, $con);
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.postDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($rs, 'BasePeer.postDoSelectRs'));
|
||||
}
|
||||
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* The returned array will contain objects of the default type or
|
||||
* objects that inherit from the default.
|
||||
*
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function populateObjects(ResultSet $rs)
|
||||
{
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
// set the class once to avoid overhead in the loop
|
||||
$cls = ThemeColorSchemePeer::getOMClass();
|
||||
$cls = Propel::import($cls);
|
||||
// populate the object(s)
|
||||
while($rs->next()) {
|
||||
|
||||
$obj = new $cls();
|
||||
$obj->hydrate($rs);
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj) : $obj;
|
||||
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria, joining the related Theme table
|
||||
*
|
||||
* @param Criteria $c
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCountJoinTheme(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(ThemeColorSchemePeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(ThemeColorSchemePeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(ThemeColorSchemePeer::THEME_ID, ThemePeer::ID);
|
||||
|
||||
$rs = ThemeColorSchemePeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects a collection of ThemeColorScheme objects pre-filled with their Theme objects.
|
||||
*
|
||||
* @return ThemeColorScheme[] Array of ThemeColorScheme objects.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectJoinTheme(Criteria $c, $con = null)
|
||||
{
|
||||
$c = clone $c;
|
||||
|
||||
// Set the correct dbName if it has not been overridden
|
||||
if ($c->getDbName() == Propel::getDefaultDB()) {
|
||||
$c->setDbName(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
ThemeColorSchemePeer::addSelectColumns($c);
|
||||
|
||||
ThemePeer::addSelectColumns($c);
|
||||
|
||||
$c->addJoin(ThemeColorSchemePeer::THEME_ID, ThemePeer::ID);
|
||||
$rs = ThemeColorSchemePeer::doSelectRs($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$obj1 = new ThemeColorScheme();
|
||||
$startcol = $obj1->hydrate($rs);
|
||||
if ($obj1->getThemeId())
|
||||
{
|
||||
|
||||
$obj2 = new Theme();
|
||||
$obj2->hydrate($rs, $startcol);
|
||||
$obj2->addThemeColorScheme($obj1);
|
||||
}
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria, joining all related tables
|
||||
*
|
||||
* @param Criteria $c
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(ThemeColorSchemePeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(ThemeColorSchemePeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(ThemeColorSchemePeer::THEME_ID, ThemePeer::ID);
|
||||
|
||||
$rs = ThemeColorSchemePeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects a collection of ThemeColorScheme objects pre-filled with all related objects.
|
||||
*
|
||||
* @return ThemeColorScheme[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectJoinAll(Criteria $c, $con = null)
|
||||
{
|
||||
$c = clone $c;
|
||||
|
||||
// Set the correct dbName if it has not been overridden
|
||||
if ($c->getDbName() == Propel::getDefaultDB()) {
|
||||
$c->setDbName(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
ThemeColorSchemePeer::addSelectColumns($c);
|
||||
$startcol2 = (ThemeColorSchemePeer::NUM_COLUMNS - ThemeColorSchemePeer::NUM_LAZY_LOAD_COLUMNS) + 1;
|
||||
|
||||
ThemePeer::addSelectColumns($c);
|
||||
$startcol3 = $startcol2 + ThemePeer::NUM_COLUMNS;
|
||||
|
||||
$c->addJoin(ThemeColorSchemePeer::THEME_ID, ThemePeer::ID);
|
||||
|
||||
$rs = BasePeer::doSelect($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$omClass = ThemeColorSchemePeer::getOMClass();
|
||||
|
||||
|
||||
$cls = Propel::import($omClass);
|
||||
$obj1 = new $cls();
|
||||
$obj1->hydrate($rs);
|
||||
|
||||
|
||||
// Add objects for joined Theme rows
|
||||
|
||||
$omClass = ThemePeer::getOMClass();
|
||||
|
||||
|
||||
$cls = Propel::import($omClass);
|
||||
$obj2 = new $cls();
|
||||
$obj2->hydrate($rs, $startcol2);
|
||||
|
||||
$newObject = true;
|
||||
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
|
||||
$temp_obj1 = $results[$j];
|
||||
$temp_obj2 = $temp_obj1->getTheme(); // CHECKME
|
||||
if (null !== $temp_obj2 && $temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
|
||||
$newObject = false;
|
||||
$temp_obj2->addThemeColorScheme($obj1); // CHECKME
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($newObject) {
|
||||
$obj2->initThemeColorSchemes();
|
||||
$obj2->addThemeColorScheme($obj1);
|
||||
}
|
||||
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TableMap related to this peer.
|
||||
* 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::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* The class that the Peer will make instances of.
|
||||
*
|
||||
* This uses a dot-path notation which is tranalted into a path
|
||||
* relative to a location on the PHP include_path.
|
||||
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
|
||||
*
|
||||
* @return string path.to.ClassName
|
||||
*/
|
||||
public static function getOMClass()
|
||||
{
|
||||
return ThemeColorSchemePeer::CLASS_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an INSERT on the database, given a ThemeColorScheme or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or ThemeColorScheme object containing data that is used to create the INSERT statement.
|
||||
* @param Connection $con the 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($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeColorSchemePeer:doInsert:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseThemeColorSchemePeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} else {
|
||||
$criteria = $values->buildCriteria(); // build Criteria from ThemeColorScheme object
|
||||
}
|
||||
|
||||
$criteria->remove(ThemeColorSchemePeer::ID); // remove pkey col since this table uses auto-increment
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table (I guess, conceivably)
|
||||
$con->begin();
|
||||
$pk = BasePeer::doInsert($criteria, $con);
|
||||
$con->commit();
|
||||
} catch(PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeColorSchemePeer:doInsert:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseThemeColorSchemePeer', $values, $con, $pk);
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an UPDATE on the database, given a ThemeColorScheme or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or ThemeColorScheme object containing data that is used to create the UPDATE statement.
|
||||
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doUpdate($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeColorSchemePeer:doUpdate:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseThemeColorSchemePeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$selectCriteria = new Criteria(self::DATABASE_NAME);
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
|
||||
$comparison = $criteria->getComparison(ThemeColorSchemePeer::ID);
|
||||
$selectCriteria->add(ThemeColorSchemePeer::ID, $criteria->remove(ThemeColorSchemePeer::ID), $comparison);
|
||||
|
||||
} else { // $values is ThemeColorScheme object
|
||||
$criteria = $values->buildCriteria(); // gets full criteria
|
||||
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
|
||||
}
|
||||
|
||||
// set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeColorSchemePeer:doUpdate:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseThemeColorSchemePeer', $values, $con, $ret);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to DELETE all rows from the st_theme_color_scheme table.
|
||||
*
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public static function doDeleteAll($con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::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->begin();
|
||||
$affectedRows += BasePeer::doDeleteAll(ThemeColorSchemePeer::TABLE_NAME, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform a DELETE on the database, given a ThemeColorScheme or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or ThemeColorScheme object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param Connection $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, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(ThemeColorSchemePeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} elseif ($values instanceof ThemeColorScheme) {
|
||||
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria(self::DATABASE_NAME);
|
||||
$criteria->add(ThemeColorSchemePeer::ID, (array) $values, Criteria::IN);
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::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->begin();
|
||||
|
||||
$affectedRows += BasePeer::doDelete($criteria, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates all modified columns of given ThemeColorScheme object.
|
||||
* If parameter $columns is either a single column name or an array of column names
|
||||
* than only those columns are validated.
|
||||
*
|
||||
* NOTICE: This does not apply to primary or foreign keys for now.
|
||||
*
|
||||
* @param ThemeColorScheme $obj The object to validate.
|
||||
* @param mixed $cols Column name or array of column names.
|
||||
*
|
||||
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
|
||||
*/
|
||||
public static function doValidate(ThemeColorScheme $obj, $cols = null)
|
||||
{
|
||||
$columns = array();
|
||||
|
||||
if ($cols) {
|
||||
$dbMap = Propel::getDatabaseMap(ThemeColorSchemePeer::DATABASE_NAME);
|
||||
$tableMap = $dbMap->getTable(ThemeColorSchemePeer::TABLE_NAME);
|
||||
|
||||
if (! is_array($cols)) {
|
||||
$cols = array($cols);
|
||||
}
|
||||
|
||||
foreach($cols as $colName) {
|
||||
if ($tableMap->containsColumn($colName)) {
|
||||
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
|
||||
$columns[$colName] = $obj->$get();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
$res = BasePeer::doValidate(ThemeColorSchemePeer::DATABASE_NAME, ThemeColorSchemePeer::TABLE_NAME, $columns);
|
||||
if ($res !== true) {
|
||||
$request = sfContext::getInstance()->getRequest();
|
||||
foreach ($res as $failed) {
|
||||
$col = ThemeColorSchemePeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
|
||||
$request->setError($col, $failed->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single object by pkey.
|
||||
*
|
||||
* @param mixed $pk the primary key.
|
||||
* @param Connection $con the connection to use
|
||||
* @return ThemeColorScheme
|
||||
*/
|
||||
public static function retrieveByPK($pk, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = new Criteria(ThemeColorSchemePeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(ThemeColorSchemePeer::ID, $pk);
|
||||
|
||||
|
||||
$v = ThemeColorSchemePeer::doSelect($criteria, $con);
|
||||
|
||||
return !empty($v) > 0 ? $v[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve multiple objects by pkey.
|
||||
*
|
||||
* @param array $pks List of primary keys
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return ThemeColorScheme[]
|
||||
*/
|
||||
public static function retrieveByPKs($pks, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$objs = null;
|
||||
if (empty($pks)) {
|
||||
$objs = array();
|
||||
} else {
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(ThemeColorSchemePeer::ID, $pks, Criteria::IN);
|
||||
$objs = ThemeColorSchemePeer::doSelect($criteria, $con);
|
||||
}
|
||||
return $objs;
|
||||
}
|
||||
|
||||
} // BaseThemeColorSchemePeer
|
||||
|
||||
// static code to register the map builder for this Peer with the main Propel class
|
||||
if (Propel::isInit()) {
|
||||
// the MapBuilder classes register themselves with Propel during initialization
|
||||
// so we need to load them here.
|
||||
try {
|
||||
BaseThemeColorSchemePeer::getMapBuilder();
|
||||
} catch (Exception $e) {
|
||||
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
// even if Propel is not yet initialized, the map builder class can be registered
|
||||
// now and then it will be loaded when Propel initializes.
|
||||
Propel::registerMapBuilder('plugins.stThemePlugin.lib.model.map.ThemeColorSchemeMapBuilder');
|
||||
}
|
||||
715
plugins/stThemePlugin/lib/model/om/BaseThemeConfig.php
Normal file
715
plugins/stThemePlugin/lib/model/om/BaseThemeConfig.php
Normal file
@@ -0,0 +1,715 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'st_theme_config' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseThemeConfig extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
protected static $dispatcher = null;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the parameters field.
|
||||
* @var array
|
||||
*/
|
||||
protected $parameters;
|
||||
|
||||
/**
|
||||
* @var Theme
|
||||
*/
|
||||
protected $aTheme;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInSave = false;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless validation loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInValidation = false;
|
||||
|
||||
/**
|
||||
* Get the [id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [parameters] column value.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getParameters()
|
||||
{
|
||||
|
||||
return $this->parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->id !== $v) {
|
||||
$this->id = $v;
|
||||
$this->modifiedColumns[] = ThemeConfigPeer::ID;
|
||||
}
|
||||
|
||||
if ($this->aTheme !== null && $this->aTheme->getId() !== $v) {
|
||||
$this->aTheme = null;
|
||||
}
|
||||
|
||||
} // setId()
|
||||
|
||||
/**
|
||||
* Set the value of [parameters] column.
|
||||
*
|
||||
* @param array $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setParameters($v)
|
||||
{
|
||||
|
||||
if ($this->parameters !== $v) {
|
||||
$this->parameters = $v;
|
||||
$this->modifiedColumns[] = ThemeConfigPeer::PARAMETERS;
|
||||
}
|
||||
|
||||
} // setParameters()
|
||||
|
||||
/**
|
||||
* Hydrates (populates) the object variables with values from the database resultset.
|
||||
*
|
||||
* An offset (1-based "start column") is specified so that objects can be hydrated
|
||||
* with a subset of the columns in the resultset rows. This is needed, for example,
|
||||
* for results of JOIN queries where the resultset row includes columns from two or
|
||||
* more tables.
|
||||
*
|
||||
* @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
|
||||
* @param int $startcol 1-based offset column which indicates which restultset column to start with.
|
||||
* @return int next starting column
|
||||
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
|
||||
*/
|
||||
public function hydrate(ResultSet $rs, $startcol = 1)
|
||||
{
|
||||
try {
|
||||
if ($this->getDispatcher()->getListeners('ThemeConfig.preHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'ThemeConfig.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
|
||||
$startcol = $event['startcol'];
|
||||
}
|
||||
|
||||
$this->id = $rs->getInt($startcol + 0);
|
||||
|
||||
$this->parameters = $rs->getString($startcol + 1) ? unserialize($rs->getString($startcol + 1)) : null;
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
if ($this->getDispatcher()->getListeners('ThemeConfig.postHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'ThemeConfig.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 2)));
|
||||
return $event['startcol'];
|
||||
}
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 2; // 2 = ThemeConfigPeer::NUM_COLUMNS - ThemeConfigPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating ThemeConfig object", $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this object from datastore and sets delete attribute.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
* @see BaseObject::setDeleted()
|
||||
* @see BaseObject::isDeleted()
|
||||
*/
|
||||
public function delete($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("This object has already been deleted.");
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('ThemeConfig.preDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'ThemeConfig.preDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseThemeConfig:delete:pre'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseThemeConfig:delete:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, $this, $con);
|
||||
if ($ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(ThemeConfigPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
ThemeConfigPeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('ThemeConfig.postDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'ThemeConfig.postDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseThemeConfig:delete:post'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseThemeConfig:delete:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database. If the object is new,
|
||||
* it inserts it; otherwise an update is performed. This method
|
||||
* wraps the doSave() worker method in a transaction.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see doSave()
|
||||
*/
|
||||
public function save($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("You cannot save an object that has been deleted.");
|
||||
}
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('ThemeConfig.preSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'ThemeConfig.preSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeConfig:save:pre') as $callable)
|
||||
{
|
||||
$affectedRows = call_user_func($callable, $this, $con);
|
||||
if (is_int($affectedRows))
|
||||
{
|
||||
return $affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(ThemeConfigPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('ThemeConfig.postSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'ThemeConfig.postSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeConfig:save:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con, $affectedRows);
|
||||
}
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database.
|
||||
*
|
||||
* If the object is new, it inserts it; otherwise an update is performed.
|
||||
* All related objects are also updated in this method.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see save()
|
||||
*/
|
||||
protected function doSave($con)
|
||||
{
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
if (!$this->alreadyInSave) {
|
||||
$this->alreadyInSave = true;
|
||||
|
||||
|
||||
// We call the save method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->aTheme !== null) {
|
||||
if ($this->aTheme->isModified()) {
|
||||
$affectedRows += $this->aTheme->save($con);
|
||||
}
|
||||
$this->setTheme($this->aTheme);
|
||||
}
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = ThemeConfigPeer::doInsert($this, $con);
|
||||
$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
|
||||
// should always be true here (even though technically
|
||||
// BasePeer::doInsert() can insert multiple rows).
|
||||
|
||||
$this->setNew(false);
|
||||
} else {
|
||||
$affectedRows += ThemeConfigPeer::doUpdate($this, $con);
|
||||
}
|
||||
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
|
||||
}
|
||||
|
||||
$this->alreadyInSave = false;
|
||||
}
|
||||
return $affectedRows;
|
||||
} // doSave()
|
||||
|
||||
/**
|
||||
* Array of ValidationFailed objects.
|
||||
* @var array ValidationFailed[]
|
||||
*/
|
||||
protected $validationFailures = array();
|
||||
|
||||
/**
|
||||
* Gets any ValidationFailed objects that resulted from last call to validate().
|
||||
*
|
||||
*
|
||||
* @return array ValidationFailed[]
|
||||
* @see validate()
|
||||
*/
|
||||
public function getValidationFailures()
|
||||
{
|
||||
return $this->validationFailures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the objects modified field values and all objects related to this table.
|
||||
*
|
||||
* If $columns is either a column name or an array of column names
|
||||
* only those columns are validated.
|
||||
*
|
||||
* @param mixed $columns Column name or an array of column names.
|
||||
* @return boolean Whether all columns pass validation.
|
||||
* @see doValidate()
|
||||
* @see getValidationFailures()
|
||||
*/
|
||||
public function validate($columns = null)
|
||||
{
|
||||
$res = $this->doValidate($columns);
|
||||
if ($res === true) {
|
||||
$this->validationFailures = array();
|
||||
return true;
|
||||
} else {
|
||||
$this->validationFailures = $res;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function performs the validation work for complex object models.
|
||||
*
|
||||
* In addition to checking the current object, all related objects will
|
||||
* also be validated. If all pass then <code>true</code> is returned; otherwise
|
||||
* an aggreagated array of ValidationFailed objects will be returned.
|
||||
*
|
||||
* @param array $columns Array of column names to validate.
|
||||
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
|
||||
*/
|
||||
protected function doValidate($columns = null)
|
||||
{
|
||||
if (!$this->alreadyInValidation) {
|
||||
$this->alreadyInValidation = true;
|
||||
$retval = null;
|
||||
|
||||
$failureMap = array();
|
||||
|
||||
|
||||
// We call the validate method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->aTheme !== null) {
|
||||
if (!$this->aTheme->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->aTheme->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($retval = ThemeConfigPeer::doValidate($this, $columns)) !== true) {
|
||||
$failureMap = array_merge($failureMap, $retval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->alreadyInValidation = false;
|
||||
}
|
||||
|
||||
return (!empty($failureMap) ? $failureMap : true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name name
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return mixed Value of field.
|
||||
*/
|
||||
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = ThemeConfigPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->getByPosition($pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @return mixed Value of field at $pos
|
||||
*/
|
||||
public function getByPosition($pos)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
return $this->getId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getParameters();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the object as an array.
|
||||
*
|
||||
* You can specify the key type of the array by passing one of the class
|
||||
* type constants.
|
||||
*
|
||||
* @param string $keyType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return an associative array containing the field names (as keys) and field values
|
||||
*/
|
||||
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = ThemeConfigPeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getId(),
|
||||
$keys[1] => $this->getParameters(),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name peer name
|
||||
* @param mixed $value field value
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return void
|
||||
*/
|
||||
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = ThemeConfigPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->setByPosition($pos, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @param mixed $value field value
|
||||
* @return void
|
||||
*/
|
||||
public function setByPosition($pos, $value)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
$this->setId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setParameters($value);
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the object using an array.
|
||||
*
|
||||
* This is particularly useful when populating an object from one of the
|
||||
* request arrays (e.g. $_POST). This method goes through the column
|
||||
* names, checking to see whether a matching key exists in populated
|
||||
* array. If so the setByName() method is called for that column.
|
||||
*
|
||||
* You can specify the key type of the array by additionally passing one
|
||||
* of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
|
||||
* TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
|
||||
*
|
||||
* @param array $arr An array to populate the object from.
|
||||
* @param string $keyType The type of keys the array uses.
|
||||
* @return void
|
||||
*/
|
||||
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = ThemeConfigPeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setParameters($arr[$keys[1]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Criteria object containing the values of all modified columns in this object.
|
||||
*
|
||||
* @return Criteria The Criteria object containing all modified values.
|
||||
*/
|
||||
public function buildCriteria()
|
||||
{
|
||||
$criteria = new Criteria(ThemeConfigPeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(ThemeConfigPeer::ID)) $criteria->add(ThemeConfigPeer::ID, $this->id);
|
||||
if ($this->isColumnModified(ThemeConfigPeer::PARAMETERS)) $criteria->add(ThemeConfigPeer::PARAMETERS, null !== $this->parameters && (is_array($this->parameters) || is_object($this->parameters)) ? serialize($this->parameters) : $this->parameters);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a Criteria object containing the primary key for this object.
|
||||
*
|
||||
* Unlike buildCriteria() this method includes the primary key values regardless
|
||||
* of whether or not they have been modified.
|
||||
*
|
||||
* @return Criteria The Criteria object containing value(s) for primary key(s).
|
||||
*/
|
||||
public function buildPkeyCriteria()
|
||||
{
|
||||
$criteria = new Criteria(ThemeConfigPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(ThemeConfigPeer::ID, $this->id);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary key for this object (row).
|
||||
* @return int
|
||||
*/
|
||||
public function getPrimaryKey()
|
||||
{
|
||||
return $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [composite] primary key fields
|
||||
*
|
||||
* @param string $keyType
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
return array(ThemeConfigPeer::translateFieldName('id', BasePeer::TYPE_FIELDNAME, $keyType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method to set the primary key (id column).
|
||||
*
|
||||
* @param int $key Primary key.
|
||||
* @return void
|
||||
*/
|
||||
public function setPrimaryKey($key)
|
||||
{
|
||||
$this->setId($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contents of passed object to values from current object.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param object $copyObj An object of ThemeConfig (or compatible) type.
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copyInto($copyObj, $deepCopy = false)
|
||||
{
|
||||
|
||||
$copyObj->setParameters($this->parameters);
|
||||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
|
||||
$copyObj->setId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a copy of this object that will be inserted as a new row in table when saved.
|
||||
* It creates a new object filling in the simple attributes, but skipping any primary
|
||||
* keys that are defined for the table.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @return ThemeConfig Clone of current object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copy($deepCopy = false)
|
||||
{
|
||||
// we use get_class(), because this might be a subclass
|
||||
$clazz = get_class($this);
|
||||
$copyObj = new $clazz();
|
||||
$this->copyInto($copyObj, $deepCopy);
|
||||
return $copyObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a peer instance associated with this om.
|
||||
*
|
||||
* @return string Peer class name
|
||||
*/
|
||||
public function getPeer()
|
||||
{
|
||||
return 'ThemeConfigPeer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a Theme object.
|
||||
*
|
||||
* @param Theme $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setTheme($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setId(NULL);
|
||||
} else {
|
||||
$this->setId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->aTheme = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated Theme object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return Theme The associated Theme object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getTheme($con = null)
|
||||
{
|
||||
if ($this->aTheme === null && ($this->id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->aTheme = ThemePeer::retrieveByPK($this->id, $con);
|
||||
|
||||
/* The following can be used instead of the line above to
|
||||
guarantee the related object contains a reference
|
||||
to this object, but this level of coupling
|
||||
may be undesirable in many circumstances.
|
||||
As it can lead to a db query with many results that may
|
||||
never be used.
|
||||
$obj = ThemePeer::retrieveByPK($this->id, $con);
|
||||
$obj->addThemes($this);
|
||||
*/
|
||||
}
|
||||
return $this->aTheme;
|
||||
}
|
||||
|
||||
|
||||
public function getDispatcher()
|
||||
{
|
||||
if (null === self::$dispatcher)
|
||||
{
|
||||
self::$dispatcher = stEventDispatcher::getInstance();
|
||||
}
|
||||
|
||||
return self::$dispatcher;
|
||||
}
|
||||
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
$event = $this->getDispatcher()->notifyUntil(new sfEvent($this, 'ThemeConfig.' . $method, array('arguments' => $arguments, 'method' => $method)));
|
||||
|
||||
if ($event->isProcessed())
|
||||
{
|
||||
return $event->getReturnValue();
|
||||
}
|
||||
|
||||
if (!$callable = sfMixer::getCallable('BaseThemeConfig:'.$method))
|
||||
{
|
||||
throw new sfException(sprintf('Call to undefined method BaseThemeConfig::%s', $method));
|
||||
}
|
||||
|
||||
array_unshift($arguments, $this);
|
||||
|
||||
return call_user_func_array($callable, $arguments);
|
||||
}
|
||||
|
||||
} // BaseThemeConfig
|
||||
839
plugins/stThemePlugin/lib/model/om/BaseThemeConfigPeer.php
Normal file
839
plugins/stThemePlugin/lib/model/om/BaseThemeConfigPeer.php
Normal file
@@ -0,0 +1,839 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base static class for performing query and update operations on the 'st_theme_config' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseThemeConfigPeer {
|
||||
|
||||
/** the default database name for this class */
|
||||
const DATABASE_NAME = 'propel';
|
||||
|
||||
/** the table name for this class */
|
||||
const TABLE_NAME = 'st_theme_config';
|
||||
|
||||
/** A class that can be returned by this peer. */
|
||||
const CLASS_DEFAULT = 'plugins.stThemePlugin.lib.model.ThemeConfig';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 2;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
|
||||
/** the column name for the ID field */
|
||||
const ID = 'st_theme_config.ID';
|
||||
|
||||
/** the column name for the PARAMETERS field */
|
||||
const PARAMETERS = 'st_theme_config.PARAMETERS';
|
||||
|
||||
/** The PHP to DB Name Mapping */
|
||||
private static $phpNameMap = null;
|
||||
|
||||
|
||||
/**
|
||||
* holds an array of fieldnames
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id', 'Parameters', ),
|
||||
BasePeer::TYPE_COLNAME => array (ThemeConfigPeer::ID, ThemeConfigPeer::PARAMETERS, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'parameters', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, )
|
||||
);
|
||||
|
||||
/**
|
||||
* holds an array of keys for quick access to the fieldnames array
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Parameters' => 1, ),
|
||||
BasePeer::TYPE_COLNAME => array (ThemeConfigPeer::ID => 0, ThemeConfigPeer::PARAMETERS => 1, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'parameters' => 1, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, )
|
||||
);
|
||||
|
||||
protected static $hydrateMethod = null;
|
||||
|
||||
protected static $postHydrateMethod = null;
|
||||
|
||||
public static function setHydrateMethod($callback)
|
||||
{
|
||||
self::$hydrateMethod = $callback;
|
||||
}
|
||||
|
||||
public static function setPostHydrateMethod($callback)
|
||||
{
|
||||
self::$postHydrateMethod = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MapBuilder the map builder for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getMapBuilder()
|
||||
{
|
||||
return BasePeer::getMapBuilder('plugins.stThemePlugin.lib.model.map.ThemeConfigMapBuilder');
|
||||
}
|
||||
/**
|
||||
* Gets a map (hash) of PHP names to DB column names.
|
||||
*
|
||||
* @return array The PHP to DB name map for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
|
||||
*/
|
||||
public static function getPhpNameMap()
|
||||
{
|
||||
if (self::$phpNameMap === null) {
|
||||
$map = ThemeConfigPeer::getTableMap();
|
||||
$columns = $map->getColumns();
|
||||
$nameMap = array();
|
||||
foreach ($columns as $column) {
|
||||
$nameMap[$column->getPhpName()] = $column->getColumnName();
|
||||
}
|
||||
self::$phpNameMap = $nameMap;
|
||||
}
|
||||
return self::$phpNameMap;
|
||||
}
|
||||
/**
|
||||
* Translates a fieldname to another type
|
||||
*
|
||||
* @param string $name field name
|
||||
* @param string $fromType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @param string $toType One of the class type constants
|
||||
* @return string translated name of the field.
|
||||
*/
|
||||
static public function translateFieldName($name, $fromType, $toType)
|
||||
{
|
||||
$toNames = self::getFieldNames($toType);
|
||||
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
|
||||
if ($key === null) {
|
||||
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
|
||||
}
|
||||
return $toNames[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of of field names.
|
||||
*
|
||||
* @param string $type The type of fieldnames to return:
|
||||
* One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return array A list of field names
|
||||
*/
|
||||
|
||||
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
if (!array_key_exists($type, self::$fieldNames)) {
|
||||
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
|
||||
}
|
||||
return self::$fieldNames[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method which changes table.column to alias.column.
|
||||
*
|
||||
* Using this method you can maintain SQL abstraction while using column aliases.
|
||||
* <code>
|
||||
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
|
||||
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
|
||||
* </code>
|
||||
* @param string $alias The alias for the current table.
|
||||
* @param string $column The column name for current table. (i.e. ThemeConfigPeer::COLUMN_NAME).
|
||||
* @return string
|
||||
*/
|
||||
public static function alias($alias, $column)
|
||||
{
|
||||
return str_replace(ThemeConfigPeer::TABLE_NAME.'.', $alias.'.', $column);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 object containing the columns to add.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function addSelectColumns(Criteria $criteria)
|
||||
{
|
||||
|
||||
$criteria->addSelectColumn(ThemeConfigPeer::ID);
|
||||
|
||||
$criteria->addSelectColumn(ThemeConfigPeer::PARAMETERS);
|
||||
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('ThemeConfigPeer.postAddSelectColumns')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'ThemeConfigPeer.postAddSelectColumns'));
|
||||
}
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(st_theme_config.ID)';
|
||||
const COUNT_DISTINCT = 'COUNT(DISTINCT st_theme_config.ID)';
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(ThemeConfigPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(ThemeConfigPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$rs = ThemeConfigPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Method to select one object from the DB.
|
||||
*
|
||||
* @param Criteria $criteria object used to create the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return ThemeConfig
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectOne(Criteria $criteria, $con = null)
|
||||
{
|
||||
$critcopy = clone $criteria;
|
||||
$critcopy->setLimit(1);
|
||||
$objects = ThemeConfigPeer::doSelect($critcopy, $con);
|
||||
if ($objects) {
|
||||
return $objects[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Method to do selects.
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return ThemeConfig[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelect(Criteria $criteria, $con = null)
|
||||
{
|
||||
return ThemeConfigPeer::populateObjects(ThemeConfigPeer::doSelectRS($criteria, $con));
|
||||
}
|
||||
/**
|
||||
* Prepares the Criteria object and uses the parent doSelect()
|
||||
* method to get a ResultSet.
|
||||
*
|
||||
* Use this method directly if you want to just get the resultset
|
||||
* (instead of an array of objects).
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return ResultSet The resultset object with numerically-indexed fields.
|
||||
* @see BasePeer::doSelect()
|
||||
*/
|
||||
public static function doSelectRS(Criteria $criteria, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if (!$criteria->getSelectColumns()) {
|
||||
$criteria = clone $criteria;
|
||||
ThemeConfigPeer::addSelectColumns($criteria);
|
||||
}
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.preDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'BasePeer.preDoSelectRs'));
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
// BasePeer returns a Creole ResultSet, set to return
|
||||
// rows indexed numerically.
|
||||
$rs = BasePeer::doSelect($criteria, $con);
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.postDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($rs, 'BasePeer.postDoSelectRs'));
|
||||
}
|
||||
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* The returned array will contain objects of the default type or
|
||||
* objects that inherit from the default.
|
||||
*
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function populateObjects(ResultSet $rs)
|
||||
{
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
// set the class once to avoid overhead in the loop
|
||||
$cls = ThemeConfigPeer::getOMClass();
|
||||
$cls = Propel::import($cls);
|
||||
// populate the object(s)
|
||||
while($rs->next()) {
|
||||
|
||||
$obj = new $cls();
|
||||
$obj->hydrate($rs);
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj) : $obj;
|
||||
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria, joining the related Theme table
|
||||
*
|
||||
* @param Criteria $c
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCountJoinTheme(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(ThemeConfigPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(ThemeConfigPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(ThemeConfigPeer::ID, ThemePeer::ID);
|
||||
|
||||
$rs = ThemeConfigPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects a collection of ThemeConfig objects pre-filled with their Theme objects.
|
||||
*
|
||||
* @return ThemeConfig[] Array of ThemeConfig objects.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectJoinTheme(Criteria $c, $con = null)
|
||||
{
|
||||
$c = clone $c;
|
||||
|
||||
// Set the correct dbName if it has not been overridden
|
||||
if ($c->getDbName() == Propel::getDefaultDB()) {
|
||||
$c->setDbName(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
ThemeConfigPeer::addSelectColumns($c);
|
||||
|
||||
ThemePeer::addSelectColumns($c);
|
||||
|
||||
$c->addJoin(ThemeConfigPeer::ID, ThemePeer::ID);
|
||||
$rs = ThemeConfigPeer::doSelectRs($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$obj1 = new ThemeConfig();
|
||||
$startcol = $obj1->hydrate($rs);
|
||||
if ($obj1->getId())
|
||||
{
|
||||
|
||||
$obj2 = new Theme();
|
||||
$obj2->hydrate($rs, $startcol);
|
||||
$obj2->addThemeConfig($obj1);
|
||||
}
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria, joining all related tables
|
||||
*
|
||||
* @param Criteria $c
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(ThemeConfigPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(ThemeConfigPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(ThemeConfigPeer::ID, ThemePeer::ID);
|
||||
|
||||
$rs = ThemeConfigPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects a collection of ThemeConfig objects pre-filled with all related objects.
|
||||
*
|
||||
* @return ThemeConfig[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectJoinAll(Criteria $c, $con = null)
|
||||
{
|
||||
$c = clone $c;
|
||||
|
||||
// Set the correct dbName if it has not been overridden
|
||||
if ($c->getDbName() == Propel::getDefaultDB()) {
|
||||
$c->setDbName(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
ThemeConfigPeer::addSelectColumns($c);
|
||||
$startcol2 = (ThemeConfigPeer::NUM_COLUMNS - ThemeConfigPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
|
||||
|
||||
ThemePeer::addSelectColumns($c);
|
||||
$startcol3 = $startcol2 + ThemePeer::NUM_COLUMNS;
|
||||
|
||||
$c->addJoin(ThemeConfigPeer::ID, ThemePeer::ID);
|
||||
|
||||
$rs = BasePeer::doSelect($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$omClass = ThemeConfigPeer::getOMClass();
|
||||
|
||||
|
||||
$cls = Propel::import($omClass);
|
||||
$obj1 = new $cls();
|
||||
$obj1->hydrate($rs);
|
||||
|
||||
|
||||
// Add objects for joined Theme rows
|
||||
|
||||
$omClass = ThemePeer::getOMClass();
|
||||
|
||||
|
||||
$cls = Propel::import($omClass);
|
||||
$obj2 = new $cls();
|
||||
$obj2->hydrate($rs, $startcol2);
|
||||
|
||||
$newObject = true;
|
||||
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
|
||||
$temp_obj1 = $results[$j];
|
||||
$temp_obj2 = $temp_obj1->getTheme(); // CHECKME
|
||||
if (null !== $temp_obj2 && $temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
|
||||
$newObject = false;
|
||||
$temp_obj2->addThemeConfig($obj1); // CHECKME
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($newObject) {
|
||||
$obj2->initThemeConfigs();
|
||||
$obj2->addThemeConfig($obj1);
|
||||
}
|
||||
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TableMap related to this peer.
|
||||
* 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::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* The class that the Peer will make instances of.
|
||||
*
|
||||
* This uses a dot-path notation which is tranalted into a path
|
||||
* relative to a location on the PHP include_path.
|
||||
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
|
||||
*
|
||||
* @return string path.to.ClassName
|
||||
*/
|
||||
public static function getOMClass()
|
||||
{
|
||||
return ThemeConfigPeer::CLASS_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an INSERT on the database, given a ThemeConfig or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or ThemeConfig object containing data that is used to create the INSERT statement.
|
||||
* @param Connection $con the 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($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeConfigPeer:doInsert:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseThemeConfigPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} else {
|
||||
$criteria = $values->buildCriteria(); // build Criteria from ThemeConfig object
|
||||
}
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table (I guess, conceivably)
|
||||
$con->begin();
|
||||
$pk = BasePeer::doInsert($criteria, $con);
|
||||
$con->commit();
|
||||
} catch(PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeConfigPeer:doInsert:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseThemeConfigPeer', $values, $con, $pk);
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an UPDATE on the database, given a ThemeConfig or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or ThemeConfig object containing data that is used to create the UPDATE statement.
|
||||
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doUpdate($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeConfigPeer:doUpdate:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseThemeConfigPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$selectCriteria = new Criteria(self::DATABASE_NAME);
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
|
||||
$comparison = $criteria->getComparison(ThemeConfigPeer::ID);
|
||||
$selectCriteria->add(ThemeConfigPeer::ID, $criteria->remove(ThemeConfigPeer::ID), $comparison);
|
||||
|
||||
} else { // $values is ThemeConfig object
|
||||
$criteria = $values->buildCriteria(); // gets full criteria
|
||||
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
|
||||
}
|
||||
|
||||
// set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeConfigPeer:doUpdate:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseThemeConfigPeer', $values, $con, $ret);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to DELETE all rows from the st_theme_config table.
|
||||
*
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public static function doDeleteAll($con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::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->begin();
|
||||
$affectedRows += BasePeer::doDeleteAll(ThemeConfigPeer::TABLE_NAME, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform a DELETE on the database, given a ThemeConfig or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or ThemeConfig object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param Connection $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, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(ThemeConfigPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} elseif ($values instanceof ThemeConfig) {
|
||||
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria(self::DATABASE_NAME);
|
||||
$criteria->add(ThemeConfigPeer::ID, (array) $values, Criteria::IN);
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::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->begin();
|
||||
|
||||
$affectedRows += BasePeer::doDelete($criteria, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates all modified columns of given ThemeConfig object.
|
||||
* If parameter $columns is either a single column name or an array of column names
|
||||
* than only those columns are validated.
|
||||
*
|
||||
* NOTICE: This does not apply to primary or foreign keys for now.
|
||||
*
|
||||
* @param ThemeConfig $obj The object to validate.
|
||||
* @param mixed $cols Column name or array of column names.
|
||||
*
|
||||
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
|
||||
*/
|
||||
public static function doValidate(ThemeConfig $obj, $cols = null)
|
||||
{
|
||||
$columns = array();
|
||||
|
||||
if ($cols) {
|
||||
$dbMap = Propel::getDatabaseMap(ThemeConfigPeer::DATABASE_NAME);
|
||||
$tableMap = $dbMap->getTable(ThemeConfigPeer::TABLE_NAME);
|
||||
|
||||
if (! is_array($cols)) {
|
||||
$cols = array($cols);
|
||||
}
|
||||
|
||||
foreach($cols as $colName) {
|
||||
if ($tableMap->containsColumn($colName)) {
|
||||
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
|
||||
$columns[$colName] = $obj->$get();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
$res = BasePeer::doValidate(ThemeConfigPeer::DATABASE_NAME, ThemeConfigPeer::TABLE_NAME, $columns);
|
||||
if ($res !== true) {
|
||||
$request = sfContext::getInstance()->getRequest();
|
||||
foreach ($res as $failed) {
|
||||
$col = ThemeConfigPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
|
||||
$request->setError($col, $failed->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single object by pkey.
|
||||
*
|
||||
* @param mixed $pk the primary key.
|
||||
* @param Connection $con the connection to use
|
||||
* @return ThemeConfig
|
||||
*/
|
||||
public static function retrieveByPK($pk, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = new Criteria(ThemeConfigPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(ThemeConfigPeer::ID, $pk);
|
||||
|
||||
|
||||
$v = ThemeConfigPeer::doSelect($criteria, $con);
|
||||
|
||||
return !empty($v) > 0 ? $v[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve multiple objects by pkey.
|
||||
*
|
||||
* @param array $pks List of primary keys
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return ThemeConfig[]
|
||||
*/
|
||||
public static function retrieveByPKs($pks, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$objs = null;
|
||||
if (empty($pks)) {
|
||||
$objs = array();
|
||||
} else {
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(ThemeConfigPeer::ID, $pks, Criteria::IN);
|
||||
$objs = ThemeConfigPeer::doSelect($criteria, $con);
|
||||
}
|
||||
return $objs;
|
||||
}
|
||||
|
||||
} // BaseThemeConfigPeer
|
||||
|
||||
// static code to register the map builder for this Peer with the main Propel class
|
||||
if (Propel::isInit()) {
|
||||
// the MapBuilder classes register themselves with Propel during initialization
|
||||
// so we need to load them here.
|
||||
try {
|
||||
BaseThemeConfigPeer::getMapBuilder();
|
||||
} catch (Exception $e) {
|
||||
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
// even if Propel is not yet initialized, the map builder class can be registered
|
||||
// now and then it will be loaded when Propel initializes.
|
||||
Propel::registerMapBuilder('plugins.stThemePlugin.lib.model.map.ThemeConfigMapBuilder');
|
||||
}
|
||||
1087
plugins/stThemePlugin/lib/model/om/BaseThemeContent.php
Normal file
1087
plugins/stThemePlugin/lib/model/om/BaseThemeContent.php
Normal file
File diff suppressed because it is too large
Load Diff
827
plugins/stThemePlugin/lib/model/om/BaseThemeContentI18n.php
Normal file
827
plugins/stThemePlugin/lib/model/om/BaseThemeContentI18n.php
Normal file
@@ -0,0 +1,827 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'st_theme_content_i18n' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseThemeContentI18n extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
protected static $dispatcher = null;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the culture field.
|
||||
* @var string
|
||||
*/
|
||||
protected $culture;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the name field.
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the content field.
|
||||
* @var string
|
||||
*/
|
||||
protected $content;
|
||||
|
||||
/**
|
||||
* @var ThemeContent
|
||||
*/
|
||||
protected $aThemeContent;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInSave = false;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless validation loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInValidation = false;
|
||||
|
||||
/**
|
||||
* Get the [id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [culture] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCulture()
|
||||
{
|
||||
|
||||
return $this->culture;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [name] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [content] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->id !== $v) {
|
||||
$this->id = $v;
|
||||
$this->modifiedColumns[] = ThemeContentI18nPeer::ID;
|
||||
}
|
||||
|
||||
if ($this->aThemeContent !== null && $this->aThemeContent->getId() !== $v) {
|
||||
$this->aThemeContent = null;
|
||||
}
|
||||
|
||||
} // setId()
|
||||
|
||||
/**
|
||||
* Set the value of [culture] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setCulture($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_string($v)) {
|
||||
$v = (string) $v;
|
||||
}
|
||||
|
||||
if ($this->culture !== $v) {
|
||||
$this->culture = $v;
|
||||
$this->modifiedColumns[] = ThemeContentI18nPeer::CULTURE;
|
||||
}
|
||||
|
||||
} // setCulture()
|
||||
|
||||
/**
|
||||
* Set the value of [name] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setName($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_string($v)) {
|
||||
$v = (string) $v;
|
||||
}
|
||||
|
||||
if ($this->name !== $v) {
|
||||
$this->name = $v;
|
||||
$this->modifiedColumns[] = ThemeContentI18nPeer::NAME;
|
||||
}
|
||||
|
||||
} // setName()
|
||||
|
||||
/**
|
||||
* Set the value of [content] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setContent($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_string($v)) {
|
||||
$v = (string) $v;
|
||||
}
|
||||
|
||||
if ($this->content !== $v) {
|
||||
$this->content = $v;
|
||||
$this->modifiedColumns[] = ThemeContentI18nPeer::CONTENT;
|
||||
}
|
||||
|
||||
} // setContent()
|
||||
|
||||
/**
|
||||
* Hydrates (populates) the object variables with values from the database resultset.
|
||||
*
|
||||
* An offset (1-based "start column") is specified so that objects can be hydrated
|
||||
* with a subset of the columns in the resultset rows. This is needed, for example,
|
||||
* for results of JOIN queries where the resultset row includes columns from two or
|
||||
* more tables.
|
||||
*
|
||||
* @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
|
||||
* @param int $startcol 1-based offset column which indicates which restultset column to start with.
|
||||
* @return int next starting column
|
||||
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
|
||||
*/
|
||||
public function hydrate(ResultSet $rs, $startcol = 1)
|
||||
{
|
||||
try {
|
||||
if ($this->getDispatcher()->getListeners('ThemeContentI18n.preHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'ThemeContentI18n.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
|
||||
$startcol = $event['startcol'];
|
||||
}
|
||||
|
||||
$this->id = $rs->getInt($startcol + 0);
|
||||
|
||||
$this->culture = $rs->getString($startcol + 1);
|
||||
|
||||
$this->name = $rs->getString($startcol + 2);
|
||||
|
||||
$this->content = $rs->getString($startcol + 3);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
if ($this->getDispatcher()->getListeners('ThemeContentI18n.postHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'ThemeContentI18n.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 4)));
|
||||
return $event['startcol'];
|
||||
}
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 4; // 4 = ThemeContentI18nPeer::NUM_COLUMNS - ThemeContentI18nPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating ThemeContentI18n object", $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this object from datastore and sets delete attribute.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
* @see BaseObject::setDeleted()
|
||||
* @see BaseObject::isDeleted()
|
||||
*/
|
||||
public function delete($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("This object has already been deleted.");
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('ThemeContentI18n.preDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'ThemeContentI18n.preDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseThemeContentI18n:delete:pre'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseThemeContentI18n:delete:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, $this, $con);
|
||||
if ($ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(ThemeContentI18nPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
ThemeContentI18nPeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('ThemeContentI18n.postDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'ThemeContentI18n.postDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseThemeContentI18n:delete:post'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseThemeContentI18n:delete:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database. If the object is new,
|
||||
* it inserts it; otherwise an update is performed. This method
|
||||
* wraps the doSave() worker method in a transaction.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see doSave()
|
||||
*/
|
||||
public function save($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("You cannot save an object that has been deleted.");
|
||||
}
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('ThemeContentI18n.preSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'ThemeContentI18n.preSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeContentI18n:save:pre') as $callable)
|
||||
{
|
||||
$affectedRows = call_user_func($callable, $this, $con);
|
||||
if (is_int($affectedRows))
|
||||
{
|
||||
return $affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(ThemeContentI18nPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('ThemeContentI18n.postSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'ThemeContentI18n.postSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeContentI18n:save:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con, $affectedRows);
|
||||
}
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database.
|
||||
*
|
||||
* If the object is new, it inserts it; otherwise an update is performed.
|
||||
* All related objects are also updated in this method.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see save()
|
||||
*/
|
||||
protected function doSave($con)
|
||||
{
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
if (!$this->alreadyInSave) {
|
||||
$this->alreadyInSave = true;
|
||||
|
||||
|
||||
// We call the save method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->aThemeContent !== null) {
|
||||
if ($this->aThemeContent->isModified() || $this->aThemeContent->getCurrentThemeContentI18n()->isModified()) {
|
||||
$affectedRows += $this->aThemeContent->save($con);
|
||||
}
|
||||
$this->setThemeContent($this->aThemeContent);
|
||||
}
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = ThemeContentI18nPeer::doInsert($this, $con);
|
||||
$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
|
||||
// should always be true here (even though technically
|
||||
// BasePeer::doInsert() can insert multiple rows).
|
||||
|
||||
$this->setNew(false);
|
||||
} else {
|
||||
$affectedRows += ThemeContentI18nPeer::doUpdate($this, $con);
|
||||
}
|
||||
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
|
||||
}
|
||||
|
||||
$this->alreadyInSave = false;
|
||||
}
|
||||
return $affectedRows;
|
||||
} // doSave()
|
||||
|
||||
/**
|
||||
* Array of ValidationFailed objects.
|
||||
* @var array ValidationFailed[]
|
||||
*/
|
||||
protected $validationFailures = array();
|
||||
|
||||
/**
|
||||
* Gets any ValidationFailed objects that resulted from last call to validate().
|
||||
*
|
||||
*
|
||||
* @return array ValidationFailed[]
|
||||
* @see validate()
|
||||
*/
|
||||
public function getValidationFailures()
|
||||
{
|
||||
return $this->validationFailures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the objects modified field values and all objects related to this table.
|
||||
*
|
||||
* If $columns is either a column name or an array of column names
|
||||
* only those columns are validated.
|
||||
*
|
||||
* @param mixed $columns Column name or an array of column names.
|
||||
* @return boolean Whether all columns pass validation.
|
||||
* @see doValidate()
|
||||
* @see getValidationFailures()
|
||||
*/
|
||||
public function validate($columns = null)
|
||||
{
|
||||
$res = $this->doValidate($columns);
|
||||
if ($res === true) {
|
||||
$this->validationFailures = array();
|
||||
return true;
|
||||
} else {
|
||||
$this->validationFailures = $res;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function performs the validation work for complex object models.
|
||||
*
|
||||
* In addition to checking the current object, all related objects will
|
||||
* also be validated. If all pass then <code>true</code> is returned; otherwise
|
||||
* an aggreagated array of ValidationFailed objects will be returned.
|
||||
*
|
||||
* @param array $columns Array of column names to validate.
|
||||
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
|
||||
*/
|
||||
protected function doValidate($columns = null)
|
||||
{
|
||||
if (!$this->alreadyInValidation) {
|
||||
$this->alreadyInValidation = true;
|
||||
$retval = null;
|
||||
|
||||
$failureMap = array();
|
||||
|
||||
|
||||
// We call the validate method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->aThemeContent !== null) {
|
||||
if (!$this->aThemeContent->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->aThemeContent->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($retval = ThemeContentI18nPeer::doValidate($this, $columns)) !== true) {
|
||||
$failureMap = array_merge($failureMap, $retval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->alreadyInValidation = false;
|
||||
}
|
||||
|
||||
return (!empty($failureMap) ? $failureMap : true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name name
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return mixed Value of field.
|
||||
*/
|
||||
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = ThemeContentI18nPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->getByPosition($pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @return mixed Value of field at $pos
|
||||
*/
|
||||
public function getByPosition($pos)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
return $this->getId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getCulture();
|
||||
break;
|
||||
case 2:
|
||||
return $this->getName();
|
||||
break;
|
||||
case 3:
|
||||
return $this->getContent();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the object as an array.
|
||||
*
|
||||
* You can specify the key type of the array by passing one of the class
|
||||
* type constants.
|
||||
*
|
||||
* @param string $keyType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return an associative array containing the field names (as keys) and field values
|
||||
*/
|
||||
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = ThemeContentI18nPeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getId(),
|
||||
$keys[1] => $this->getCulture(),
|
||||
$keys[2] => $this->getName(),
|
||||
$keys[3] => $this->getContent(),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name peer name
|
||||
* @param mixed $value field value
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return void
|
||||
*/
|
||||
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = ThemeContentI18nPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->setByPosition($pos, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @param mixed $value field value
|
||||
* @return void
|
||||
*/
|
||||
public function setByPosition($pos, $value)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
$this->setId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setCulture($value);
|
||||
break;
|
||||
case 2:
|
||||
$this->setName($value);
|
||||
break;
|
||||
case 3:
|
||||
$this->setContent($value);
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the object using an array.
|
||||
*
|
||||
* This is particularly useful when populating an object from one of the
|
||||
* request arrays (e.g. $_POST). This method goes through the column
|
||||
* names, checking to see whether a matching key exists in populated
|
||||
* array. If so the setByName() method is called for that column.
|
||||
*
|
||||
* You can specify the key type of the array by additionally passing one
|
||||
* of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
|
||||
* TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
|
||||
*
|
||||
* @param array $arr An array to populate the object from.
|
||||
* @param string $keyType The type of keys the array uses.
|
||||
* @return void
|
||||
*/
|
||||
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = ThemeContentI18nPeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setCulture($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setName($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setContent($arr[$keys[3]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Criteria object containing the values of all modified columns in this object.
|
||||
*
|
||||
* @return Criteria The Criteria object containing all modified values.
|
||||
*/
|
||||
public function buildCriteria()
|
||||
{
|
||||
$criteria = new Criteria(ThemeContentI18nPeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(ThemeContentI18nPeer::ID)) $criteria->add(ThemeContentI18nPeer::ID, $this->id);
|
||||
if ($this->isColumnModified(ThemeContentI18nPeer::CULTURE)) $criteria->add(ThemeContentI18nPeer::CULTURE, $this->culture);
|
||||
if ($this->isColumnModified(ThemeContentI18nPeer::NAME)) $criteria->add(ThemeContentI18nPeer::NAME, $this->name);
|
||||
if ($this->isColumnModified(ThemeContentI18nPeer::CONTENT)) $criteria->add(ThemeContentI18nPeer::CONTENT, $this->content);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a Criteria object containing the primary key for this object.
|
||||
*
|
||||
* Unlike buildCriteria() this method includes the primary key values regardless
|
||||
* of whether or not they have been modified.
|
||||
*
|
||||
* @return Criteria The Criteria object containing value(s) for primary key(s).
|
||||
*/
|
||||
public function buildPkeyCriteria()
|
||||
{
|
||||
$criteria = new Criteria(ThemeContentI18nPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(ThemeContentI18nPeer::ID, $this->id);
|
||||
$criteria->add(ThemeContentI18nPeer::CULTURE, $this->culture);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the composite primary key for this object.
|
||||
* The array elements will be in same order as specified in XML.
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKey()
|
||||
{
|
||||
return array($this->getId(), $this->getCulture());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [composite] primary key fields
|
||||
*
|
||||
* @param string $keyType
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
return array(ThemeContentI18nPeer::translateFieldName('id', BasePeer::TYPE_FIELDNAME, $keyType), ThemeContentI18nPeer::translateFieldName('culture', BasePeer::TYPE_FIELDNAME, $keyType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the [composite] primary key.
|
||||
*
|
||||
* @param array $keys The elements of the composite key (order must match the order in XML file).
|
||||
* @return void
|
||||
*/
|
||||
public function setPrimaryKey($keys)
|
||||
{
|
||||
|
||||
$this->setId($keys[0]);
|
||||
|
||||
$this->setCulture($keys[1]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contents of passed object to values from current object.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param object $copyObj An object of ThemeContentI18n (or compatible) type.
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copyInto($copyObj, $deepCopy = false)
|
||||
{
|
||||
|
||||
$copyObj->setName($this->name);
|
||||
|
||||
$copyObj->setContent($this->content);
|
||||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
|
||||
$copyObj->setId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
$copyObj->setCulture(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a copy of this object that will be inserted as a new row in table when saved.
|
||||
* It creates a new object filling in the simple attributes, but skipping any primary
|
||||
* keys that are defined for the table.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @return ThemeContentI18n Clone of current object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copy($deepCopy = false)
|
||||
{
|
||||
// we use get_class(), because this might be a subclass
|
||||
$clazz = get_class($this);
|
||||
$copyObj = new $clazz();
|
||||
$this->copyInto($copyObj, $deepCopy);
|
||||
return $copyObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a peer instance associated with this om.
|
||||
*
|
||||
* @return string Peer class name
|
||||
*/
|
||||
public function getPeer()
|
||||
{
|
||||
return 'ThemeContentI18nPeer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a ThemeContent object.
|
||||
*
|
||||
* @param ThemeContent $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setThemeContent($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setId(NULL);
|
||||
} else {
|
||||
$this->setId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->aThemeContent = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated ThemeContent object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return ThemeContent The associated ThemeContent object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getThemeContent($con = null)
|
||||
{
|
||||
if ($this->aThemeContent === null && ($this->id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->aThemeContent = ThemeContentPeer::retrieveByPK($this->id, $con);
|
||||
|
||||
/* The following can be used instead of the line above to
|
||||
guarantee the related object contains a reference
|
||||
to this object, but this level of coupling
|
||||
may be undesirable in many circumstances.
|
||||
As it can lead to a db query with many results that may
|
||||
never be used.
|
||||
$obj = ThemeContentPeer::retrieveByPK($this->id, $con);
|
||||
$obj->addThemeContents($this);
|
||||
*/
|
||||
}
|
||||
return $this->aThemeContent;
|
||||
}
|
||||
|
||||
|
||||
public function getDispatcher()
|
||||
{
|
||||
if (null === self::$dispatcher)
|
||||
{
|
||||
self::$dispatcher = stEventDispatcher::getInstance();
|
||||
}
|
||||
|
||||
return self::$dispatcher;
|
||||
}
|
||||
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
$event = $this->getDispatcher()->notifyUntil(new sfEvent($this, 'ThemeContentI18n.' . $method, array('arguments' => $arguments, 'method' => $method)));
|
||||
|
||||
if ($event->isProcessed())
|
||||
{
|
||||
return $event->getReturnValue();
|
||||
}
|
||||
|
||||
if (!$callable = sfMixer::getCallable('BaseThemeContentI18n:'.$method))
|
||||
{
|
||||
throw new sfException(sprintf('Call to undefined method BaseThemeContentI18n::%s', $method));
|
||||
}
|
||||
|
||||
array_unshift($arguments, $this);
|
||||
|
||||
return call_user_func_array($callable, $arguments);
|
||||
}
|
||||
|
||||
} // BaseThemeContentI18n
|
||||
839
plugins/stThemePlugin/lib/model/om/BaseThemeContentI18nPeer.php
Normal file
839
plugins/stThemePlugin/lib/model/om/BaseThemeContentI18nPeer.php
Normal file
@@ -0,0 +1,839 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base static class for performing query and update operations on the 'st_theme_content_i18n' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseThemeContentI18nPeer {
|
||||
|
||||
/** the default database name for this class */
|
||||
const DATABASE_NAME = 'propel';
|
||||
|
||||
/** the table name for this class */
|
||||
const TABLE_NAME = 'st_theme_content_i18n';
|
||||
|
||||
/** A class that can be returned by this peer. */
|
||||
const CLASS_DEFAULT = 'plugins.stThemePlugin.lib.model.ThemeContentI18n';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 4;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
|
||||
/** the column name for the ID field */
|
||||
const ID = 'st_theme_content_i18n.ID';
|
||||
|
||||
/** the column name for the CULTURE field */
|
||||
const CULTURE = 'st_theme_content_i18n.CULTURE';
|
||||
|
||||
/** the column name for the NAME field */
|
||||
const NAME = 'st_theme_content_i18n.NAME';
|
||||
|
||||
/** the column name for the CONTENT field */
|
||||
const CONTENT = 'st_theme_content_i18n.CONTENT';
|
||||
|
||||
/** The PHP to DB Name Mapping */
|
||||
private static $phpNameMap = null;
|
||||
|
||||
|
||||
/**
|
||||
* holds an array of fieldnames
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id', 'Culture', 'Name', 'Content', ),
|
||||
BasePeer::TYPE_COLNAME => array (ThemeContentI18nPeer::ID, ThemeContentI18nPeer::CULTURE, ThemeContentI18nPeer::NAME, ThemeContentI18nPeer::CONTENT, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'culture', 'name', 'content', ),
|
||||
BasePeer::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::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Culture' => 1, 'Name' => 2, 'Content' => 3, ),
|
||||
BasePeer::TYPE_COLNAME => array (ThemeContentI18nPeer::ID => 0, ThemeContentI18nPeer::CULTURE => 1, ThemeContentI18nPeer::NAME => 2, ThemeContentI18nPeer::CONTENT => 3, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'culture' => 1, 'name' => 2, 'content' => 3, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
|
||||
);
|
||||
|
||||
protected static $hydrateMethod = null;
|
||||
|
||||
protected static $postHydrateMethod = null;
|
||||
|
||||
public static function setHydrateMethod($callback)
|
||||
{
|
||||
self::$hydrateMethod = $callback;
|
||||
}
|
||||
|
||||
public static function setPostHydrateMethod($callback)
|
||||
{
|
||||
self::$postHydrateMethod = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MapBuilder the map builder for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getMapBuilder()
|
||||
{
|
||||
return BasePeer::getMapBuilder('plugins.stThemePlugin.lib.model.map.ThemeContentI18nMapBuilder');
|
||||
}
|
||||
/**
|
||||
* Gets a map (hash) of PHP names to DB column names.
|
||||
*
|
||||
* @return array The PHP to DB name map for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
|
||||
*/
|
||||
public static function getPhpNameMap()
|
||||
{
|
||||
if (self::$phpNameMap === null) {
|
||||
$map = ThemeContentI18nPeer::getTableMap();
|
||||
$columns = $map->getColumns();
|
||||
$nameMap = array();
|
||||
foreach ($columns as $column) {
|
||||
$nameMap[$column->getPhpName()] = $column->getColumnName();
|
||||
}
|
||||
self::$phpNameMap = $nameMap;
|
||||
}
|
||||
return self::$phpNameMap;
|
||||
}
|
||||
/**
|
||||
* Translates a fieldname to another type
|
||||
*
|
||||
* @param string $name field name
|
||||
* @param string $fromType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @param string $toType One of the class type constants
|
||||
* @return string translated name of the field.
|
||||
*/
|
||||
static public function translateFieldName($name, $fromType, $toType)
|
||||
{
|
||||
$toNames = self::getFieldNames($toType);
|
||||
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
|
||||
if ($key === null) {
|
||||
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
|
||||
}
|
||||
return $toNames[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of of field names.
|
||||
*
|
||||
* @param string $type The type of fieldnames to return:
|
||||
* One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return array A list of field names
|
||||
*/
|
||||
|
||||
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
if (!array_key_exists($type, self::$fieldNames)) {
|
||||
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
|
||||
}
|
||||
return self::$fieldNames[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method which changes table.column to alias.column.
|
||||
*
|
||||
* Using this method you can maintain SQL abstraction while using column aliases.
|
||||
* <code>
|
||||
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
|
||||
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
|
||||
* </code>
|
||||
* @param string $alias The alias for the current table.
|
||||
* @param string $column The column name for current table. (i.e. ThemeContentI18nPeer::COLUMN_NAME).
|
||||
* @return string
|
||||
*/
|
||||
public static function alias($alias, $column)
|
||||
{
|
||||
return str_replace(ThemeContentI18nPeer::TABLE_NAME.'.', $alias.'.', $column);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 object containing the columns to add.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function addSelectColumns(Criteria $criteria)
|
||||
{
|
||||
|
||||
$criteria->addSelectColumn(ThemeContentI18nPeer::ID);
|
||||
|
||||
$criteria->addSelectColumn(ThemeContentI18nPeer::CULTURE);
|
||||
|
||||
$criteria->addSelectColumn(ThemeContentI18nPeer::NAME);
|
||||
|
||||
$criteria->addSelectColumn(ThemeContentI18nPeer::CONTENT);
|
||||
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('ThemeContentI18nPeer.postAddSelectColumns')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'ThemeContentI18nPeer.postAddSelectColumns'));
|
||||
}
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(st_theme_content_i18n.ID)';
|
||||
const COUNT_DISTINCT = 'COUNT(DISTINCT st_theme_content_i18n.ID)';
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(ThemeContentI18nPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(ThemeContentI18nPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$rs = ThemeContentI18nPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Method to select one object from the DB.
|
||||
*
|
||||
* @param Criteria $criteria object used to create the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return ThemeContentI18n
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectOne(Criteria $criteria, $con = null)
|
||||
{
|
||||
$critcopy = clone $criteria;
|
||||
$critcopy->setLimit(1);
|
||||
$objects = ThemeContentI18nPeer::doSelect($critcopy, $con);
|
||||
if ($objects) {
|
||||
return $objects[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Method to do selects.
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return ThemeContentI18n[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelect(Criteria $criteria, $con = null)
|
||||
{
|
||||
return ThemeContentI18nPeer::populateObjects(ThemeContentI18nPeer::doSelectRS($criteria, $con));
|
||||
}
|
||||
/**
|
||||
* Prepares the Criteria object and uses the parent doSelect()
|
||||
* method to get a ResultSet.
|
||||
*
|
||||
* Use this method directly if you want to just get the resultset
|
||||
* (instead of an array of objects).
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return ResultSet The resultset object with numerically-indexed fields.
|
||||
* @see BasePeer::doSelect()
|
||||
*/
|
||||
public static function doSelectRS(Criteria $criteria, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if (!$criteria->getSelectColumns()) {
|
||||
$criteria = clone $criteria;
|
||||
ThemeContentI18nPeer::addSelectColumns($criteria);
|
||||
}
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.preDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'BasePeer.preDoSelectRs'));
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
// BasePeer returns a Creole ResultSet, set to return
|
||||
// rows indexed numerically.
|
||||
$rs = BasePeer::doSelect($criteria, $con);
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.postDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($rs, 'BasePeer.postDoSelectRs'));
|
||||
}
|
||||
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* The returned array will contain objects of the default type or
|
||||
* objects that inherit from the default.
|
||||
*
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function populateObjects(ResultSet $rs)
|
||||
{
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
// set the class once to avoid overhead in the loop
|
||||
$cls = ThemeContentI18nPeer::getOMClass();
|
||||
$cls = Propel::import($cls);
|
||||
// populate the object(s)
|
||||
while($rs->next()) {
|
||||
|
||||
$obj = new $cls();
|
||||
$obj->hydrate($rs);
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj) : $obj;
|
||||
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria, joining the related ThemeContent table
|
||||
*
|
||||
* @param Criteria $c
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCountJoinThemeContent(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(ThemeContentI18nPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(ThemeContentI18nPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(ThemeContentI18nPeer::ID, ThemeContentPeer::ID);
|
||||
|
||||
$rs = ThemeContentI18nPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects a collection of ThemeContentI18n objects pre-filled with their ThemeContent objects.
|
||||
*
|
||||
* @return ThemeContentI18n[] Array of ThemeContentI18n objects.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectJoinThemeContent(Criteria $c, $con = null)
|
||||
{
|
||||
$c = clone $c;
|
||||
|
||||
// Set the correct dbName if it has not been overridden
|
||||
if ($c->getDbName() == Propel::getDefaultDB()) {
|
||||
$c->setDbName(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
ThemeContentI18nPeer::addSelectColumns($c);
|
||||
|
||||
ThemeContentPeer::addSelectColumns($c);
|
||||
|
||||
$c->addJoin(ThemeContentI18nPeer::ID, ThemeContentPeer::ID);
|
||||
$rs = ThemeContentI18nPeer::doSelectRs($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$obj1 = new ThemeContentI18n();
|
||||
$startcol = $obj1->hydrate($rs);
|
||||
if ($obj1->getId())
|
||||
{
|
||||
|
||||
$obj2 = new ThemeContent();
|
||||
$obj2->hydrate($rs, $startcol);
|
||||
$obj2->addThemeContentI18n($obj1);
|
||||
}
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria, joining all related tables
|
||||
*
|
||||
* @param Criteria $c
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(ThemeContentI18nPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(ThemeContentI18nPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(ThemeContentI18nPeer::ID, ThemeContentPeer::ID);
|
||||
|
||||
$rs = ThemeContentI18nPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects a collection of ThemeContentI18n objects pre-filled with all related objects.
|
||||
*
|
||||
* @return ThemeContentI18n[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectJoinAll(Criteria $c, $con = null)
|
||||
{
|
||||
$c = clone $c;
|
||||
|
||||
// Set the correct dbName if it has not been overridden
|
||||
if ($c->getDbName() == Propel::getDefaultDB()) {
|
||||
$c->setDbName(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
ThemeContentI18nPeer::addSelectColumns($c);
|
||||
$startcol2 = (ThemeContentI18nPeer::NUM_COLUMNS - ThemeContentI18nPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
|
||||
|
||||
ThemeContentPeer::addSelectColumns($c);
|
||||
$startcol3 = $startcol2 + ThemeContentPeer::NUM_COLUMNS;
|
||||
|
||||
$c->addJoin(ThemeContentI18nPeer::ID, ThemeContentPeer::ID);
|
||||
|
||||
$rs = BasePeer::doSelect($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$omClass = ThemeContentI18nPeer::getOMClass();
|
||||
|
||||
|
||||
$cls = Propel::import($omClass);
|
||||
$obj1 = new $cls();
|
||||
$obj1->hydrate($rs);
|
||||
|
||||
|
||||
// Add objects for joined ThemeContent rows
|
||||
|
||||
$omClass = ThemeContentPeer::getOMClass();
|
||||
|
||||
|
||||
$cls = Propel::import($omClass);
|
||||
$obj2 = new $cls();
|
||||
$obj2->hydrate($rs, $startcol2);
|
||||
|
||||
$newObject = true;
|
||||
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
|
||||
$temp_obj1 = $results[$j];
|
||||
$temp_obj2 = $temp_obj1->getThemeContent(); // CHECKME
|
||||
if (null !== $temp_obj2 && $temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
|
||||
$newObject = false;
|
||||
$temp_obj2->addThemeContentI18n($obj1); // CHECKME
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($newObject) {
|
||||
$obj2->initThemeContentI18ns();
|
||||
$obj2->addThemeContentI18n($obj1);
|
||||
}
|
||||
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TableMap related to this peer.
|
||||
* 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::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* The class that the Peer will make instances of.
|
||||
*
|
||||
* This uses a dot-path notation which is tranalted into a path
|
||||
* relative to a location on the PHP include_path.
|
||||
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
|
||||
*
|
||||
* @return string path.to.ClassName
|
||||
*/
|
||||
public static function getOMClass()
|
||||
{
|
||||
return ThemeContentI18nPeer::CLASS_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an INSERT on the database, given a ThemeContentI18n or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or ThemeContentI18n object containing data that is used to create the INSERT statement.
|
||||
* @param Connection $con the 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($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeContentI18nPeer:doInsert:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseThemeContentI18nPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} else {
|
||||
$criteria = $values->buildCriteria(); // build Criteria from ThemeContentI18n object
|
||||
}
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table (I guess, conceivably)
|
||||
$con->begin();
|
||||
$pk = BasePeer::doInsert($criteria, $con);
|
||||
$con->commit();
|
||||
} catch(PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeContentI18nPeer:doInsert:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseThemeContentI18nPeer', $values, $con, $pk);
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an UPDATE on the database, given a ThemeContentI18n or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or ThemeContentI18n object containing data that is used to create the UPDATE statement.
|
||||
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doUpdate($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeContentI18nPeer:doUpdate:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseThemeContentI18nPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$selectCriteria = new Criteria(self::DATABASE_NAME);
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
|
||||
$comparison = $criteria->getComparison(ThemeContentI18nPeer::ID);
|
||||
$selectCriteria->add(ThemeContentI18nPeer::ID, $criteria->remove(ThemeContentI18nPeer::ID), $comparison);
|
||||
|
||||
$comparison = $criteria->getComparison(ThemeContentI18nPeer::CULTURE);
|
||||
$selectCriteria->add(ThemeContentI18nPeer::CULTURE, $criteria->remove(ThemeContentI18nPeer::CULTURE), $comparison);
|
||||
|
||||
} else { // $values is ThemeContentI18n object
|
||||
$criteria = $values->buildCriteria(); // gets full criteria
|
||||
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
|
||||
}
|
||||
|
||||
// set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeContentI18nPeer:doUpdate:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseThemeContentI18nPeer', $values, $con, $ret);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to DELETE all rows from the st_theme_content_i18n table.
|
||||
*
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public static function doDeleteAll($con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::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->begin();
|
||||
$affectedRows += BasePeer::doDeleteAll(ThemeContentI18nPeer::TABLE_NAME, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform a DELETE on the database, given a ThemeContentI18n or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or ThemeContentI18n object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param Connection $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, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(ThemeContentI18nPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} elseif ($values instanceof ThemeContentI18n) {
|
||||
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria(self::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);
|
||||
}
|
||||
$vals = array();
|
||||
foreach($values as $value)
|
||||
{
|
||||
|
||||
$vals[0][] = $value[0];
|
||||
$vals[1][] = $value[1];
|
||||
}
|
||||
|
||||
$criteria->add(ThemeContentI18nPeer::ID, $vals[0], Criteria::IN);
|
||||
$criteria->add(ThemeContentI18nPeer::CULTURE, $vals[1], Criteria::IN);
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::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->begin();
|
||||
|
||||
$affectedRows += BasePeer::doDelete($criteria, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates all modified columns of given ThemeContentI18n object.
|
||||
* If parameter $columns is either a single column name or an array of column names
|
||||
* than only those columns are validated.
|
||||
*
|
||||
* NOTICE: This does not apply to primary or foreign keys for now.
|
||||
*
|
||||
* @param ThemeContentI18n $obj The object to validate.
|
||||
* @param mixed $cols Column name or array of column names.
|
||||
*
|
||||
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
|
||||
*/
|
||||
public static function doValidate(ThemeContentI18n $obj, $cols = null)
|
||||
{
|
||||
$columns = array();
|
||||
|
||||
if ($cols) {
|
||||
$dbMap = Propel::getDatabaseMap(ThemeContentI18nPeer::DATABASE_NAME);
|
||||
$tableMap = $dbMap->getTable(ThemeContentI18nPeer::TABLE_NAME);
|
||||
|
||||
if (! is_array($cols)) {
|
||||
$cols = array($cols);
|
||||
}
|
||||
|
||||
foreach($cols as $colName) {
|
||||
if ($tableMap->containsColumn($colName)) {
|
||||
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
|
||||
$columns[$colName] = $obj->$get();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
$res = BasePeer::doValidate(ThemeContentI18nPeer::DATABASE_NAME, ThemeContentI18nPeer::TABLE_NAME, $columns);
|
||||
if ($res !== true) {
|
||||
$request = sfContext::getInstance()->getRequest();
|
||||
foreach ($res as $failed) {
|
||||
$col = ThemeContentI18nPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
|
||||
$request->setError($col, $failed->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve object using using composite pkey values.
|
||||
* @param int $id
|
||||
@param string $culture
|
||||
|
||||
* @param Connection $con
|
||||
* @return ThemeContentI18n
|
||||
*/
|
||||
public static function retrieveByPK( $id, $culture, $con = null) {
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(ThemeContentI18nPeer::ID, $id);
|
||||
$criteria->add(ThemeContentI18nPeer::CULTURE, $culture);
|
||||
$v = ThemeContentI18nPeer::doSelect($criteria, $con);
|
||||
|
||||
return !empty($v) ? $v[0] : null;
|
||||
}
|
||||
} // BaseThemeContentI18nPeer
|
||||
|
||||
// static code to register the map builder for this Peer with the main Propel class
|
||||
if (Propel::isInit()) {
|
||||
// the MapBuilder classes register themselves with Propel during initialization
|
||||
// so we need to load them here.
|
||||
try {
|
||||
BaseThemeContentI18nPeer::getMapBuilder();
|
||||
} catch (Exception $e) {
|
||||
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
// even if Propel is not yet initialized, the map builder class can be registered
|
||||
// now and then it will be loaded when Propel initializes.
|
||||
Propel::registerMapBuilder('plugins.stThemePlugin.lib.model.map.ThemeContentI18nMapBuilder');
|
||||
}
|
||||
946
plugins/stThemePlugin/lib/model/om/BaseThemeContentPeer.php
Normal file
946
plugins/stThemePlugin/lib/model/om/BaseThemeContentPeer.php
Normal file
@@ -0,0 +1,946 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base static class for performing query and update operations on the 'st_theme_content' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseThemeContentPeer {
|
||||
|
||||
/** the default database name for this class */
|
||||
const DATABASE_NAME = 'propel';
|
||||
|
||||
/** the table name for this class */
|
||||
const TABLE_NAME = 'st_theme_content';
|
||||
|
||||
/** A class that can be returned by this peer. */
|
||||
const CLASS_DEFAULT = 'plugins.stThemePlugin.lib.model.ThemeContent';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 5;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
|
||||
/** the column name for the ID field */
|
||||
const ID = 'st_theme_content.ID';
|
||||
|
||||
/** the column name for the THEME_ID field */
|
||||
const THEME_ID = 'st_theme_content.THEME_ID';
|
||||
|
||||
/** the column name for the CONTENT_ID field */
|
||||
const CONTENT_ID = 'st_theme_content.CONTENT_ID';
|
||||
|
||||
/** the column name for the OPT_NAME field */
|
||||
const OPT_NAME = 'st_theme_content.OPT_NAME';
|
||||
|
||||
/** the column name for the OPT_CONTENT field */
|
||||
const OPT_CONTENT = 'st_theme_content.OPT_CONTENT';
|
||||
|
||||
/** The PHP to DB Name Mapping */
|
||||
private static $phpNameMap = null;
|
||||
|
||||
|
||||
/**
|
||||
* holds an array of fieldnames
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id', 'ThemeId', 'ContentId', 'OptName', 'OptContent', ),
|
||||
BasePeer::TYPE_COLNAME => array (ThemeContentPeer::ID, ThemeContentPeer::THEME_ID, ThemeContentPeer::CONTENT_ID, ThemeContentPeer::OPT_NAME, ThemeContentPeer::OPT_CONTENT, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'theme_id', 'content_id', 'opt_name', 'opt_content', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
|
||||
);
|
||||
|
||||
/**
|
||||
* holds an array of keys for quick access to the fieldnames array
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ThemeId' => 1, 'ContentId' => 2, 'OptName' => 3, 'OptContent' => 4, ),
|
||||
BasePeer::TYPE_COLNAME => array (ThemeContentPeer::ID => 0, ThemeContentPeer::THEME_ID => 1, ThemeContentPeer::CONTENT_ID => 2, ThemeContentPeer::OPT_NAME => 3, ThemeContentPeer::OPT_CONTENT => 4, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'theme_id' => 1, 'content_id' => 2, 'opt_name' => 3, 'opt_content' => 4, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
|
||||
);
|
||||
|
||||
protected static $hydrateMethod = null;
|
||||
|
||||
protected static $postHydrateMethod = null;
|
||||
|
||||
public static function setHydrateMethod($callback)
|
||||
{
|
||||
self::$hydrateMethod = $callback;
|
||||
}
|
||||
|
||||
public static function setPostHydrateMethod($callback)
|
||||
{
|
||||
self::$postHydrateMethod = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MapBuilder the map builder for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getMapBuilder()
|
||||
{
|
||||
return BasePeer::getMapBuilder('plugins.stThemePlugin.lib.model.map.ThemeContentMapBuilder');
|
||||
}
|
||||
/**
|
||||
* Gets a map (hash) of PHP names to DB column names.
|
||||
*
|
||||
* @return array The PHP to DB name map for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
|
||||
*/
|
||||
public static function getPhpNameMap()
|
||||
{
|
||||
if (self::$phpNameMap === null) {
|
||||
$map = ThemeContentPeer::getTableMap();
|
||||
$columns = $map->getColumns();
|
||||
$nameMap = array();
|
||||
foreach ($columns as $column) {
|
||||
$nameMap[$column->getPhpName()] = $column->getColumnName();
|
||||
}
|
||||
self::$phpNameMap = $nameMap;
|
||||
}
|
||||
return self::$phpNameMap;
|
||||
}
|
||||
/**
|
||||
* Translates a fieldname to another type
|
||||
*
|
||||
* @param string $name field name
|
||||
* @param string $fromType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @param string $toType One of the class type constants
|
||||
* @return string translated name of the field.
|
||||
*/
|
||||
static public function translateFieldName($name, $fromType, $toType)
|
||||
{
|
||||
$toNames = self::getFieldNames($toType);
|
||||
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
|
||||
if ($key === null) {
|
||||
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
|
||||
}
|
||||
return $toNames[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of of field names.
|
||||
*
|
||||
* @param string $type The type of fieldnames to return:
|
||||
* One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return array A list of field names
|
||||
*/
|
||||
|
||||
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
if (!array_key_exists($type, self::$fieldNames)) {
|
||||
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
|
||||
}
|
||||
return self::$fieldNames[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method which changes table.column to alias.column.
|
||||
*
|
||||
* Using this method you can maintain SQL abstraction while using column aliases.
|
||||
* <code>
|
||||
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
|
||||
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
|
||||
* </code>
|
||||
* @param string $alias The alias for the current table.
|
||||
* @param string $column The column name for current table. (i.e. ThemeContentPeer::COLUMN_NAME).
|
||||
* @return string
|
||||
*/
|
||||
public static function alias($alias, $column)
|
||||
{
|
||||
return str_replace(ThemeContentPeer::TABLE_NAME.'.', $alias.'.', $column);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 object containing the columns to add.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function addSelectColumns(Criteria $criteria)
|
||||
{
|
||||
|
||||
$criteria->addSelectColumn(ThemeContentPeer::ID);
|
||||
|
||||
$criteria->addSelectColumn(ThemeContentPeer::THEME_ID);
|
||||
|
||||
$criteria->addSelectColumn(ThemeContentPeer::CONTENT_ID);
|
||||
|
||||
$criteria->addSelectColumn(ThemeContentPeer::OPT_NAME);
|
||||
|
||||
$criteria->addSelectColumn(ThemeContentPeer::OPT_CONTENT);
|
||||
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('ThemeContentPeer.postAddSelectColumns')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'ThemeContentPeer.postAddSelectColumns'));
|
||||
}
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(st_theme_content.ID)';
|
||||
const COUNT_DISTINCT = 'COUNT(DISTINCT st_theme_content.ID)';
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(ThemeContentPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(ThemeContentPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$rs = ThemeContentPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Method to select one object from the DB.
|
||||
*
|
||||
* @param Criteria $criteria object used to create the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return ThemeContent
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectOne(Criteria $criteria, $con = null)
|
||||
{
|
||||
$critcopy = clone $criteria;
|
||||
$critcopy->setLimit(1);
|
||||
$objects = ThemeContentPeer::doSelect($critcopy, $con);
|
||||
if ($objects) {
|
||||
return $objects[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Method to do selects.
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return ThemeContent[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelect(Criteria $criteria, $con = null)
|
||||
{
|
||||
return ThemeContentPeer::populateObjects(ThemeContentPeer::doSelectRS($criteria, $con));
|
||||
}
|
||||
/**
|
||||
* Prepares the Criteria object and uses the parent doSelect()
|
||||
* method to get a ResultSet.
|
||||
*
|
||||
* Use this method directly if you want to just get the resultset
|
||||
* (instead of an array of objects).
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return ResultSet The resultset object with numerically-indexed fields.
|
||||
* @see BasePeer::doSelect()
|
||||
*/
|
||||
public static function doSelectRS(Criteria $criteria, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if (!$criteria->getSelectColumns()) {
|
||||
$criteria = clone $criteria;
|
||||
ThemeContentPeer::addSelectColumns($criteria);
|
||||
}
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.preDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'BasePeer.preDoSelectRs'));
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
// BasePeer returns a Creole ResultSet, set to return
|
||||
// rows indexed numerically.
|
||||
$rs = BasePeer::doSelect($criteria, $con);
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.postDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($rs, 'BasePeer.postDoSelectRs'));
|
||||
}
|
||||
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* The returned array will contain objects of the default type or
|
||||
* objects that inherit from the default.
|
||||
*
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function populateObjects(ResultSet $rs)
|
||||
{
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
// set the class once to avoid overhead in the loop
|
||||
$cls = ThemeContentPeer::getOMClass();
|
||||
$cls = Propel::import($cls);
|
||||
// populate the object(s)
|
||||
while($rs->next()) {
|
||||
|
||||
$obj = new $cls();
|
||||
$obj->hydrate($rs);
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj) : $obj;
|
||||
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria, joining the related Theme table
|
||||
*
|
||||
* @param Criteria $c
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCountJoinTheme(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(ThemeContentPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(ThemeContentPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(ThemeContentPeer::THEME_ID, ThemePeer::ID);
|
||||
|
||||
$rs = ThemeContentPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects a collection of ThemeContent objects pre-filled with their Theme objects.
|
||||
*
|
||||
* @return ThemeContent[] Array of ThemeContent objects.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectJoinTheme(Criteria $c, $con = null)
|
||||
{
|
||||
$c = clone $c;
|
||||
|
||||
// Set the correct dbName if it has not been overridden
|
||||
if ($c->getDbName() == Propel::getDefaultDB()) {
|
||||
$c->setDbName(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
ThemeContentPeer::addSelectColumns($c);
|
||||
|
||||
ThemePeer::addSelectColumns($c);
|
||||
|
||||
$c->addJoin(ThemeContentPeer::THEME_ID, ThemePeer::ID);
|
||||
$rs = ThemeContentPeer::doSelectRs($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$obj1 = new ThemeContent();
|
||||
$startcol = $obj1->hydrate($rs);
|
||||
if ($obj1->getThemeId())
|
||||
{
|
||||
|
||||
$obj2 = new Theme();
|
||||
$obj2->hydrate($rs, $startcol);
|
||||
$obj2->addThemeContent($obj1);
|
||||
}
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria, joining all related tables
|
||||
*
|
||||
* @param Criteria $c
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(ThemeContentPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(ThemeContentPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(ThemeContentPeer::THEME_ID, ThemePeer::ID);
|
||||
|
||||
$rs = ThemeContentPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects a collection of ThemeContent objects pre-filled with all related objects.
|
||||
*
|
||||
* @return ThemeContent[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectJoinAll(Criteria $c, $con = null)
|
||||
{
|
||||
$c = clone $c;
|
||||
|
||||
// Set the correct dbName if it has not been overridden
|
||||
if ($c->getDbName() == Propel::getDefaultDB()) {
|
||||
$c->setDbName(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
ThemeContentPeer::addSelectColumns($c);
|
||||
$startcol2 = (ThemeContentPeer::NUM_COLUMNS - ThemeContentPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
|
||||
|
||||
ThemePeer::addSelectColumns($c);
|
||||
$startcol3 = $startcol2 + ThemePeer::NUM_COLUMNS;
|
||||
|
||||
$c->addJoin(ThemeContentPeer::THEME_ID, ThemePeer::ID);
|
||||
|
||||
$rs = BasePeer::doSelect($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$omClass = ThemeContentPeer::getOMClass();
|
||||
|
||||
|
||||
$cls = Propel::import($omClass);
|
||||
$obj1 = new $cls();
|
||||
$obj1->hydrate($rs);
|
||||
|
||||
|
||||
// Add objects for joined Theme rows
|
||||
|
||||
$omClass = ThemePeer::getOMClass();
|
||||
|
||||
|
||||
$cls = Propel::import($omClass);
|
||||
$obj2 = new $cls();
|
||||
$obj2->hydrate($rs, $startcol2);
|
||||
|
||||
$newObject = true;
|
||||
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
|
||||
$temp_obj1 = $results[$j];
|
||||
$temp_obj2 = $temp_obj1->getTheme(); // CHECKME
|
||||
if (null !== $temp_obj2 && $temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
|
||||
$newObject = false;
|
||||
$temp_obj2->addThemeContent($obj1); // CHECKME
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($newObject) {
|
||||
$obj2->initThemeContents();
|
||||
$obj2->addThemeContent($obj1);
|
||||
}
|
||||
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects a collection of ThemeContent objects pre-filled with their i18n objects.
|
||||
*
|
||||
* @return array Array of ThemeContent objects.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectWithI18n(Criteria $c, $culture = null, $con = null)
|
||||
{
|
||||
$c = clone $c;
|
||||
|
||||
if ($culture === null)
|
||||
{
|
||||
$culture = sfContext::getInstance()->getUser()->getCulture();
|
||||
}
|
||||
|
||||
// Set the correct dbName if it has not been overridden
|
||||
if ($c->getDbName() == Propel::getDefaultDB())
|
||||
{
|
||||
$c->setDbName(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if (!$c->getSelectColumns())
|
||||
{
|
||||
ThemeContentPeer::addSelectColumns($c);
|
||||
ThemeContentI18nPeer::addSelectColumns($c);
|
||||
}
|
||||
|
||||
$c->addJoin(ThemeContentPeer::ID, sprintf('%s AND %s = \'%s\'', ThemeContentI18nPeer::ID, ThemeContentI18nPeer::CULTURE, $culture), Criteria::LEFT_JOIN);
|
||||
|
||||
$rs = ThemeContentPeer::doSelectRs($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$obj1 = new ThemeContent();
|
||||
$startcol = $obj1->hydrate($rs);
|
||||
$obj1->setCulture($culture);
|
||||
|
||||
$obj2 = new ThemeContentI18n();
|
||||
$obj2->hydrate($rs, $startcol);
|
||||
|
||||
$obj1->setThemeContentI18nForCulture($obj2, $culture);
|
||||
$obj2->setThemeContent($obj1);
|
||||
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TableMap related to this peer.
|
||||
* 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::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* The class that the Peer will make instances of.
|
||||
*
|
||||
* This uses a dot-path notation which is tranalted into a path
|
||||
* relative to a location on the PHP include_path.
|
||||
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
|
||||
*
|
||||
* @return string path.to.ClassName
|
||||
*/
|
||||
public static function getOMClass()
|
||||
{
|
||||
return ThemeContentPeer::CLASS_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an INSERT on the database, given a ThemeContent or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or ThemeContent object containing data that is used to create the INSERT statement.
|
||||
* @param Connection $con the 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($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeContentPeer:doInsert:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseThemeContentPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} else {
|
||||
$criteria = $values->buildCriteria(); // build Criteria from ThemeContent object
|
||||
}
|
||||
|
||||
$criteria->remove(ThemeContentPeer::ID); // remove pkey col since this table uses auto-increment
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table (I guess, conceivably)
|
||||
$con->begin();
|
||||
$pk = BasePeer::doInsert($criteria, $con);
|
||||
$con->commit();
|
||||
} catch(PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeContentPeer:doInsert:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseThemeContentPeer', $values, $con, $pk);
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an UPDATE on the database, given a ThemeContent or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or ThemeContent object containing data that is used to create the UPDATE statement.
|
||||
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doUpdate($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeContentPeer:doUpdate:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseThemeContentPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$selectCriteria = new Criteria(self::DATABASE_NAME);
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
|
||||
$comparison = $criteria->getComparison(ThemeContentPeer::ID);
|
||||
$selectCriteria->add(ThemeContentPeer::ID, $criteria->remove(ThemeContentPeer::ID), $comparison);
|
||||
|
||||
} else { // $values is ThemeContent object
|
||||
$criteria = $values->buildCriteria(); // gets full criteria
|
||||
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
|
||||
}
|
||||
|
||||
// set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeContentPeer:doUpdate:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseThemeContentPeer', $values, $con, $ret);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to DELETE all rows from the st_theme_content table.
|
||||
*
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public static function doDeleteAll($con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::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->begin();
|
||||
$affectedRows += ThemeContentPeer::doOnDeleteCascade(new Criteria(), $con);
|
||||
$affectedRows += BasePeer::doDeleteAll(ThemeContentPeer::TABLE_NAME, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform a DELETE on the database, given a ThemeContent or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or ThemeContent object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param Connection $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, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(ThemeContentPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} elseif ($values instanceof ThemeContent) {
|
||||
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria(self::DATABASE_NAME);
|
||||
$criteria->add(ThemeContentPeer::ID, (array) $values, Criteria::IN);
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::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->begin();
|
||||
$affectedRows += ThemeContentPeer::doOnDeleteCascade($criteria, $con);
|
||||
$affectedRows += BasePeer::doDelete($criteria, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a method for emulating ON DELETE CASCADE for DBs that don't support this
|
||||
* feature (like MySQL or SQLite).
|
||||
*
|
||||
* This method is not very speedy because it must perform a query first to get
|
||||
* the implicated records and then perform the deletes by calling those Peer classes.
|
||||
*
|
||||
* This method should be used within a transaction if possible.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param Connection $con
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
protected static function doOnDeleteCascade(Criteria $criteria, Connection $con)
|
||||
{
|
||||
// initialize var to track total num of affected rows
|
||||
$affectedRows = 0;
|
||||
|
||||
// first find the objects that are implicated by the $criteria
|
||||
$objects = ThemeContentPeer::doSelect($criteria, $con);
|
||||
foreach($objects as $obj) {
|
||||
|
||||
|
||||
// delete related ThemeContentI18n objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ThemeContentI18nPeer::ID, $obj->getId());
|
||||
$affectedRows += ThemeContentI18nPeer::doDelete($c, $con);
|
||||
}
|
||||
return $affectedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates all modified columns of given ThemeContent object.
|
||||
* If parameter $columns is either a single column name or an array of column names
|
||||
* than only those columns are validated.
|
||||
*
|
||||
* NOTICE: This does not apply to primary or foreign keys for now.
|
||||
*
|
||||
* @param ThemeContent $obj The object to validate.
|
||||
* @param mixed $cols Column name or array of column names.
|
||||
*
|
||||
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
|
||||
*/
|
||||
public static function doValidate(ThemeContent $obj, $cols = null)
|
||||
{
|
||||
$columns = array();
|
||||
|
||||
if ($cols) {
|
||||
$dbMap = Propel::getDatabaseMap(ThemeContentPeer::DATABASE_NAME);
|
||||
$tableMap = $dbMap->getTable(ThemeContentPeer::TABLE_NAME);
|
||||
|
||||
if (! is_array($cols)) {
|
||||
$cols = array($cols);
|
||||
}
|
||||
|
||||
foreach($cols as $colName) {
|
||||
if ($tableMap->containsColumn($colName)) {
|
||||
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
|
||||
$columns[$colName] = $obj->$get();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
$res = BasePeer::doValidate(ThemeContentPeer::DATABASE_NAME, ThemeContentPeer::TABLE_NAME, $columns);
|
||||
if ($res !== true) {
|
||||
$request = sfContext::getInstance()->getRequest();
|
||||
foreach ($res as $failed) {
|
||||
$col = ThemeContentPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
|
||||
$request->setError($col, $failed->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single object by pkey.
|
||||
*
|
||||
* @param mixed $pk the primary key.
|
||||
* @param Connection $con the connection to use
|
||||
* @return ThemeContent
|
||||
*/
|
||||
public static function retrieveByPK($pk, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = new Criteria(ThemeContentPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(ThemeContentPeer::ID, $pk);
|
||||
|
||||
|
||||
$v = ThemeContentPeer::doSelect($criteria, $con);
|
||||
|
||||
return !empty($v) > 0 ? $v[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve multiple objects by pkey.
|
||||
*
|
||||
* @param array $pks List of primary keys
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return ThemeContent[]
|
||||
*/
|
||||
public static function retrieveByPKs($pks, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$objs = null;
|
||||
if (empty($pks)) {
|
||||
$objs = array();
|
||||
} else {
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(ThemeContentPeer::ID, $pks, Criteria::IN);
|
||||
$objs = ThemeContentPeer::doSelect($criteria, $con);
|
||||
}
|
||||
return $objs;
|
||||
}
|
||||
|
||||
} // BaseThemeContentPeer
|
||||
|
||||
// static code to register the map builder for this Peer with the main Propel class
|
||||
if (Propel::isInit()) {
|
||||
// the MapBuilder classes register themselves with Propel during initialization
|
||||
// so we need to load them here.
|
||||
try {
|
||||
BaseThemeContentPeer::getMapBuilder();
|
||||
} catch (Exception $e) {
|
||||
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
// even if Propel is not yet initialized, the map builder class can be registered
|
||||
// now and then it will be loaded when Propel initializes.
|
||||
Propel::registerMapBuilder('plugins.stThemePlugin.lib.model.map.ThemeContentMapBuilder');
|
||||
}
|
||||
823
plugins/stThemePlugin/lib/model/om/BaseThemeCss.php
Normal file
823
plugins/stThemePlugin/lib/model/om/BaseThemeCss.php
Normal file
@@ -0,0 +1,823 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'st_theme_css' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseThemeCss extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
protected static $dispatcher = null;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the theme_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $theme_id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the css_head_id field.
|
||||
* @var string
|
||||
*/
|
||||
protected $css_head_id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the css_content field.
|
||||
* @var string
|
||||
*/
|
||||
protected $css_content;
|
||||
|
||||
/**
|
||||
* @var Theme
|
||||
*/
|
||||
protected $aTheme;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInSave = false;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless validation loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInValidation = false;
|
||||
|
||||
/**
|
||||
* Get the [id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [theme_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getThemeId()
|
||||
{
|
||||
|
||||
return $this->theme_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [css_head_id] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCssHeadId()
|
||||
{
|
||||
|
||||
return $this->css_head_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [css_content] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCssContent()
|
||||
{
|
||||
|
||||
return $this->css_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->id !== $v) {
|
||||
$this->id = $v;
|
||||
$this->modifiedColumns[] = ThemeCssPeer::ID;
|
||||
}
|
||||
|
||||
} // setId()
|
||||
|
||||
/**
|
||||
* Set the value of [theme_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setThemeId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->theme_id !== $v) {
|
||||
$this->theme_id = $v;
|
||||
$this->modifiedColumns[] = ThemeCssPeer::THEME_ID;
|
||||
}
|
||||
|
||||
if ($this->aTheme !== null && $this->aTheme->getId() !== $v) {
|
||||
$this->aTheme = null;
|
||||
}
|
||||
|
||||
} // setThemeId()
|
||||
|
||||
/**
|
||||
* Set the value of [css_head_id] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setCssHeadId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_string($v)) {
|
||||
$v = (string) $v;
|
||||
}
|
||||
|
||||
if ($this->css_head_id !== $v) {
|
||||
$this->css_head_id = $v;
|
||||
$this->modifiedColumns[] = ThemeCssPeer::CSS_HEAD_ID;
|
||||
}
|
||||
|
||||
} // setCssHeadId()
|
||||
|
||||
/**
|
||||
* Set the value of [css_content] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setCssContent($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_string($v)) {
|
||||
$v = (string) $v;
|
||||
}
|
||||
|
||||
if ($this->css_content !== $v) {
|
||||
$this->css_content = $v;
|
||||
$this->modifiedColumns[] = ThemeCssPeer::CSS_CONTENT;
|
||||
}
|
||||
|
||||
} // setCssContent()
|
||||
|
||||
/**
|
||||
* Hydrates (populates) the object variables with values from the database resultset.
|
||||
*
|
||||
* An offset (1-based "start column") is specified so that objects can be hydrated
|
||||
* with a subset of the columns in the resultset rows. This is needed, for example,
|
||||
* for results of JOIN queries where the resultset row includes columns from two or
|
||||
* more tables.
|
||||
*
|
||||
* @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
|
||||
* @param int $startcol 1-based offset column which indicates which restultset column to start with.
|
||||
* @return int next starting column
|
||||
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
|
||||
*/
|
||||
public function hydrate(ResultSet $rs, $startcol = 1)
|
||||
{
|
||||
try {
|
||||
if ($this->getDispatcher()->getListeners('ThemeCss.preHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'ThemeCss.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
|
||||
$startcol = $event['startcol'];
|
||||
}
|
||||
|
||||
$this->id = $rs->getInt($startcol + 0);
|
||||
|
||||
$this->theme_id = $rs->getInt($startcol + 1);
|
||||
|
||||
$this->css_head_id = $rs->getString($startcol + 2);
|
||||
|
||||
$this->css_content = $rs->getString($startcol + 3);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
if ($this->getDispatcher()->getListeners('ThemeCss.postHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'ThemeCss.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 4)));
|
||||
return $event['startcol'];
|
||||
}
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 4; // 4 = ThemeCssPeer::NUM_COLUMNS - ThemeCssPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating ThemeCss object", $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this object from datastore and sets delete attribute.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
* @see BaseObject::setDeleted()
|
||||
* @see BaseObject::isDeleted()
|
||||
*/
|
||||
public function delete($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("This object has already been deleted.");
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('ThemeCss.preDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'ThemeCss.preDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseThemeCss:delete:pre'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseThemeCss:delete:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, $this, $con);
|
||||
if ($ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(ThemeCssPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
ThemeCssPeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('ThemeCss.postDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'ThemeCss.postDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseThemeCss:delete:post'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseThemeCss:delete:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database. If the object is new,
|
||||
* it inserts it; otherwise an update is performed. This method
|
||||
* wraps the doSave() worker method in a transaction.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see doSave()
|
||||
*/
|
||||
public function save($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("You cannot save an object that has been deleted.");
|
||||
}
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('ThemeCss.preSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'ThemeCss.preSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeCss:save:pre') as $callable)
|
||||
{
|
||||
$affectedRows = call_user_func($callable, $this, $con);
|
||||
if (is_int($affectedRows))
|
||||
{
|
||||
return $affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(ThemeCssPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('ThemeCss.postSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'ThemeCss.postSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeCss:save:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con, $affectedRows);
|
||||
}
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database.
|
||||
*
|
||||
* If the object is new, it inserts it; otherwise an update is performed.
|
||||
* All related objects are also updated in this method.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see save()
|
||||
*/
|
||||
protected function doSave($con)
|
||||
{
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
if (!$this->alreadyInSave) {
|
||||
$this->alreadyInSave = true;
|
||||
|
||||
|
||||
// We call the save method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->aTheme !== null) {
|
||||
if ($this->aTheme->isModified()) {
|
||||
$affectedRows += $this->aTheme->save($con);
|
||||
}
|
||||
$this->setTheme($this->aTheme);
|
||||
}
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = ThemeCssPeer::doInsert($this, $con);
|
||||
$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
|
||||
// should always be true here (even though technically
|
||||
// BasePeer::doInsert() can insert multiple rows).
|
||||
|
||||
$this->setId($pk); //[IMV] update autoincrement primary key
|
||||
|
||||
$this->setNew(false);
|
||||
} else {
|
||||
$affectedRows += ThemeCssPeer::doUpdate($this, $con);
|
||||
}
|
||||
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
|
||||
}
|
||||
|
||||
$this->alreadyInSave = false;
|
||||
}
|
||||
return $affectedRows;
|
||||
} // doSave()
|
||||
|
||||
/**
|
||||
* Array of ValidationFailed objects.
|
||||
* @var array ValidationFailed[]
|
||||
*/
|
||||
protected $validationFailures = array();
|
||||
|
||||
/**
|
||||
* Gets any ValidationFailed objects that resulted from last call to validate().
|
||||
*
|
||||
*
|
||||
* @return array ValidationFailed[]
|
||||
* @see validate()
|
||||
*/
|
||||
public function getValidationFailures()
|
||||
{
|
||||
return $this->validationFailures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the objects modified field values and all objects related to this table.
|
||||
*
|
||||
* If $columns is either a column name or an array of column names
|
||||
* only those columns are validated.
|
||||
*
|
||||
* @param mixed $columns Column name or an array of column names.
|
||||
* @return boolean Whether all columns pass validation.
|
||||
* @see doValidate()
|
||||
* @see getValidationFailures()
|
||||
*/
|
||||
public function validate($columns = null)
|
||||
{
|
||||
$res = $this->doValidate($columns);
|
||||
if ($res === true) {
|
||||
$this->validationFailures = array();
|
||||
return true;
|
||||
} else {
|
||||
$this->validationFailures = $res;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function performs the validation work for complex object models.
|
||||
*
|
||||
* In addition to checking the current object, all related objects will
|
||||
* also be validated. If all pass then <code>true</code> is returned; otherwise
|
||||
* an aggreagated array of ValidationFailed objects will be returned.
|
||||
*
|
||||
* @param array $columns Array of column names to validate.
|
||||
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
|
||||
*/
|
||||
protected function doValidate($columns = null)
|
||||
{
|
||||
if (!$this->alreadyInValidation) {
|
||||
$this->alreadyInValidation = true;
|
||||
$retval = null;
|
||||
|
||||
$failureMap = array();
|
||||
|
||||
|
||||
// We call the validate method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->aTheme !== null) {
|
||||
if (!$this->aTheme->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->aTheme->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($retval = ThemeCssPeer::doValidate($this, $columns)) !== true) {
|
||||
$failureMap = array_merge($failureMap, $retval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->alreadyInValidation = false;
|
||||
}
|
||||
|
||||
return (!empty($failureMap) ? $failureMap : true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name name
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return mixed Value of field.
|
||||
*/
|
||||
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = ThemeCssPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->getByPosition($pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @return mixed Value of field at $pos
|
||||
*/
|
||||
public function getByPosition($pos)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
return $this->getId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getThemeId();
|
||||
break;
|
||||
case 2:
|
||||
return $this->getCssHeadId();
|
||||
break;
|
||||
case 3:
|
||||
return $this->getCssContent();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the object as an array.
|
||||
*
|
||||
* You can specify the key type of the array by passing one of the class
|
||||
* type constants.
|
||||
*
|
||||
* @param string $keyType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return an associative array containing the field names (as keys) and field values
|
||||
*/
|
||||
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = ThemeCssPeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getId(),
|
||||
$keys[1] => $this->getThemeId(),
|
||||
$keys[2] => $this->getCssHeadId(),
|
||||
$keys[3] => $this->getCssContent(),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name peer name
|
||||
* @param mixed $value field value
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return void
|
||||
*/
|
||||
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = ThemeCssPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->setByPosition($pos, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @param mixed $value field value
|
||||
* @return void
|
||||
*/
|
||||
public function setByPosition($pos, $value)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
$this->setId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setThemeId($value);
|
||||
break;
|
||||
case 2:
|
||||
$this->setCssHeadId($value);
|
||||
break;
|
||||
case 3:
|
||||
$this->setCssContent($value);
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the object using an array.
|
||||
*
|
||||
* This is particularly useful when populating an object from one of the
|
||||
* request arrays (e.g. $_POST). This method goes through the column
|
||||
* names, checking to see whether a matching key exists in populated
|
||||
* array. If so the setByName() method is called for that column.
|
||||
*
|
||||
* You can specify the key type of the array by additionally passing one
|
||||
* of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
|
||||
* TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
|
||||
*
|
||||
* @param array $arr An array to populate the object from.
|
||||
* @param string $keyType The type of keys the array uses.
|
||||
* @return void
|
||||
*/
|
||||
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = ThemeCssPeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setThemeId($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setCssHeadId($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setCssContent($arr[$keys[3]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Criteria object containing the values of all modified columns in this object.
|
||||
*
|
||||
* @return Criteria The Criteria object containing all modified values.
|
||||
*/
|
||||
public function buildCriteria()
|
||||
{
|
||||
$criteria = new Criteria(ThemeCssPeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(ThemeCssPeer::ID)) $criteria->add(ThemeCssPeer::ID, $this->id);
|
||||
if ($this->isColumnModified(ThemeCssPeer::THEME_ID)) $criteria->add(ThemeCssPeer::THEME_ID, $this->theme_id);
|
||||
if ($this->isColumnModified(ThemeCssPeer::CSS_HEAD_ID)) $criteria->add(ThemeCssPeer::CSS_HEAD_ID, $this->css_head_id);
|
||||
if ($this->isColumnModified(ThemeCssPeer::CSS_CONTENT)) $criteria->add(ThemeCssPeer::CSS_CONTENT, $this->css_content);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a Criteria object containing the primary key for this object.
|
||||
*
|
||||
* Unlike buildCriteria() this method includes the primary key values regardless
|
||||
* of whether or not they have been modified.
|
||||
*
|
||||
* @return Criteria The Criteria object containing value(s) for primary key(s).
|
||||
*/
|
||||
public function buildPkeyCriteria()
|
||||
{
|
||||
$criteria = new Criteria(ThemeCssPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(ThemeCssPeer::ID, $this->id);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary key for this object (row).
|
||||
* @return int
|
||||
*/
|
||||
public function getPrimaryKey()
|
||||
{
|
||||
return $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [composite] primary key fields
|
||||
*
|
||||
* @param string $keyType
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
return array(ThemeCssPeer::translateFieldName('id', BasePeer::TYPE_FIELDNAME, $keyType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method to set the primary key (id column).
|
||||
*
|
||||
* @param int $key Primary key.
|
||||
* @return void
|
||||
*/
|
||||
public function setPrimaryKey($key)
|
||||
{
|
||||
$this->setId($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contents of passed object to values from current object.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param object $copyObj An object of ThemeCss (or compatible) type.
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copyInto($copyObj, $deepCopy = false)
|
||||
{
|
||||
|
||||
$copyObj->setThemeId($this->theme_id);
|
||||
|
||||
$copyObj->setCssHeadId($this->css_head_id);
|
||||
|
||||
$copyObj->setCssContent($this->css_content);
|
||||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
|
||||
$copyObj->setId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a copy of this object that will be inserted as a new row in table when saved.
|
||||
* It creates a new object filling in the simple attributes, but skipping any primary
|
||||
* keys that are defined for the table.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @return ThemeCss Clone of current object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copy($deepCopy = false)
|
||||
{
|
||||
// we use get_class(), because this might be a subclass
|
||||
$clazz = get_class($this);
|
||||
$copyObj = new $clazz();
|
||||
$this->copyInto($copyObj, $deepCopy);
|
||||
return $copyObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a peer instance associated with this om.
|
||||
*
|
||||
* @return string Peer class name
|
||||
*/
|
||||
public function getPeer()
|
||||
{
|
||||
return 'ThemeCssPeer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a Theme object.
|
||||
*
|
||||
* @param Theme $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setTheme($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setThemeId(NULL);
|
||||
} else {
|
||||
$this->setThemeId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->aTheme = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated Theme object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return Theme The associated Theme object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getTheme($con = null)
|
||||
{
|
||||
if ($this->aTheme === null && ($this->theme_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->aTheme = ThemePeer::retrieveByPK($this->theme_id, $con);
|
||||
|
||||
/* The following can be used instead of the line above to
|
||||
guarantee the related object contains a reference
|
||||
to this object, but this level of coupling
|
||||
may be undesirable in many circumstances.
|
||||
As it can lead to a db query with many results that may
|
||||
never be used.
|
||||
$obj = ThemePeer::retrieveByPK($this->theme_id, $con);
|
||||
$obj->addThemes($this);
|
||||
*/
|
||||
}
|
||||
return $this->aTheme;
|
||||
}
|
||||
|
||||
|
||||
public function getDispatcher()
|
||||
{
|
||||
if (null === self::$dispatcher)
|
||||
{
|
||||
self::$dispatcher = stEventDispatcher::getInstance();
|
||||
}
|
||||
|
||||
return self::$dispatcher;
|
||||
}
|
||||
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
$event = $this->getDispatcher()->notifyUntil(new sfEvent($this, 'ThemeCss.' . $method, array('arguments' => $arguments, 'method' => $method)));
|
||||
|
||||
if ($event->isProcessed())
|
||||
{
|
||||
return $event->getReturnValue();
|
||||
}
|
||||
|
||||
if (!$callable = sfMixer::getCallable('BaseThemeCss:'.$method))
|
||||
{
|
||||
throw new sfException(sprintf('Call to undefined method BaseThemeCss::%s', $method));
|
||||
}
|
||||
|
||||
array_unshift($arguments, $this);
|
||||
|
||||
return call_user_func_array($callable, $arguments);
|
||||
}
|
||||
|
||||
} // BaseThemeCss
|
||||
851
plugins/stThemePlugin/lib/model/om/BaseThemeCssPeer.php
Normal file
851
plugins/stThemePlugin/lib/model/om/BaseThemeCssPeer.php
Normal file
@@ -0,0 +1,851 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base static class for performing query and update operations on the 'st_theme_css' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseThemeCssPeer {
|
||||
|
||||
/** the default database name for this class */
|
||||
const DATABASE_NAME = 'propel';
|
||||
|
||||
/** the table name for this class */
|
||||
const TABLE_NAME = 'st_theme_css';
|
||||
|
||||
/** A class that can be returned by this peer. */
|
||||
const CLASS_DEFAULT = 'plugins.stThemePlugin.lib.model.ThemeCss';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 4;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
|
||||
/** the column name for the ID field */
|
||||
const ID = 'st_theme_css.ID';
|
||||
|
||||
/** the column name for the THEME_ID field */
|
||||
const THEME_ID = 'st_theme_css.THEME_ID';
|
||||
|
||||
/** the column name for the CSS_HEAD_ID field */
|
||||
const CSS_HEAD_ID = 'st_theme_css.CSS_HEAD_ID';
|
||||
|
||||
/** the column name for the CSS_CONTENT field */
|
||||
const CSS_CONTENT = 'st_theme_css.CSS_CONTENT';
|
||||
|
||||
/** The PHP to DB Name Mapping */
|
||||
private static $phpNameMap = null;
|
||||
|
||||
|
||||
/**
|
||||
* holds an array of fieldnames
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id', 'ThemeId', 'CssHeadId', 'CssContent', ),
|
||||
BasePeer::TYPE_COLNAME => array (ThemeCssPeer::ID, ThemeCssPeer::THEME_ID, ThemeCssPeer::CSS_HEAD_ID, ThemeCssPeer::CSS_CONTENT, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'theme_id', 'css_head_id', 'css_content', ),
|
||||
BasePeer::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::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ThemeId' => 1, 'CssHeadId' => 2, 'CssContent' => 3, ),
|
||||
BasePeer::TYPE_COLNAME => array (ThemeCssPeer::ID => 0, ThemeCssPeer::THEME_ID => 1, ThemeCssPeer::CSS_HEAD_ID => 2, ThemeCssPeer::CSS_CONTENT => 3, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'theme_id' => 1, 'css_head_id' => 2, 'css_content' => 3, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
|
||||
);
|
||||
|
||||
protected static $hydrateMethod = null;
|
||||
|
||||
protected static $postHydrateMethod = null;
|
||||
|
||||
public static function setHydrateMethod($callback)
|
||||
{
|
||||
self::$hydrateMethod = $callback;
|
||||
}
|
||||
|
||||
public static function setPostHydrateMethod($callback)
|
||||
{
|
||||
self::$postHydrateMethod = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MapBuilder the map builder for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getMapBuilder()
|
||||
{
|
||||
return BasePeer::getMapBuilder('plugins.stThemePlugin.lib.model.map.ThemeCssMapBuilder');
|
||||
}
|
||||
/**
|
||||
* Gets a map (hash) of PHP names to DB column names.
|
||||
*
|
||||
* @return array The PHP to DB name map for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
|
||||
*/
|
||||
public static function getPhpNameMap()
|
||||
{
|
||||
if (self::$phpNameMap === null) {
|
||||
$map = ThemeCssPeer::getTableMap();
|
||||
$columns = $map->getColumns();
|
||||
$nameMap = array();
|
||||
foreach ($columns as $column) {
|
||||
$nameMap[$column->getPhpName()] = $column->getColumnName();
|
||||
}
|
||||
self::$phpNameMap = $nameMap;
|
||||
}
|
||||
return self::$phpNameMap;
|
||||
}
|
||||
/**
|
||||
* Translates a fieldname to another type
|
||||
*
|
||||
* @param string $name field name
|
||||
* @param string $fromType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @param string $toType One of the class type constants
|
||||
* @return string translated name of the field.
|
||||
*/
|
||||
static public function translateFieldName($name, $fromType, $toType)
|
||||
{
|
||||
$toNames = self::getFieldNames($toType);
|
||||
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
|
||||
if ($key === null) {
|
||||
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
|
||||
}
|
||||
return $toNames[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of of field names.
|
||||
*
|
||||
* @param string $type The type of fieldnames to return:
|
||||
* One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return array A list of field names
|
||||
*/
|
||||
|
||||
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
if (!array_key_exists($type, self::$fieldNames)) {
|
||||
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
|
||||
}
|
||||
return self::$fieldNames[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method which changes table.column to alias.column.
|
||||
*
|
||||
* Using this method you can maintain SQL abstraction while using column aliases.
|
||||
* <code>
|
||||
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
|
||||
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
|
||||
* </code>
|
||||
* @param string $alias The alias for the current table.
|
||||
* @param string $column The column name for current table. (i.e. ThemeCssPeer::COLUMN_NAME).
|
||||
* @return string
|
||||
*/
|
||||
public static function alias($alias, $column)
|
||||
{
|
||||
return str_replace(ThemeCssPeer::TABLE_NAME.'.', $alias.'.', $column);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 object containing the columns to add.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function addSelectColumns(Criteria $criteria)
|
||||
{
|
||||
|
||||
$criteria->addSelectColumn(ThemeCssPeer::ID);
|
||||
|
||||
$criteria->addSelectColumn(ThemeCssPeer::THEME_ID);
|
||||
|
||||
$criteria->addSelectColumn(ThemeCssPeer::CSS_HEAD_ID);
|
||||
|
||||
$criteria->addSelectColumn(ThemeCssPeer::CSS_CONTENT);
|
||||
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('ThemeCssPeer.postAddSelectColumns')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'ThemeCssPeer.postAddSelectColumns'));
|
||||
}
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(st_theme_css.ID)';
|
||||
const COUNT_DISTINCT = 'COUNT(DISTINCT st_theme_css.ID)';
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(ThemeCssPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(ThemeCssPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$rs = ThemeCssPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Method to select one object from the DB.
|
||||
*
|
||||
* @param Criteria $criteria object used to create the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return ThemeCss
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectOne(Criteria $criteria, $con = null)
|
||||
{
|
||||
$critcopy = clone $criteria;
|
||||
$critcopy->setLimit(1);
|
||||
$objects = ThemeCssPeer::doSelect($critcopy, $con);
|
||||
if ($objects) {
|
||||
return $objects[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Method to do selects.
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return ThemeCss[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelect(Criteria $criteria, $con = null)
|
||||
{
|
||||
return ThemeCssPeer::populateObjects(ThemeCssPeer::doSelectRS($criteria, $con));
|
||||
}
|
||||
/**
|
||||
* Prepares the Criteria object and uses the parent doSelect()
|
||||
* method to get a ResultSet.
|
||||
*
|
||||
* Use this method directly if you want to just get the resultset
|
||||
* (instead of an array of objects).
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return ResultSet The resultset object with numerically-indexed fields.
|
||||
* @see BasePeer::doSelect()
|
||||
*/
|
||||
public static function doSelectRS(Criteria $criteria, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if (!$criteria->getSelectColumns()) {
|
||||
$criteria = clone $criteria;
|
||||
ThemeCssPeer::addSelectColumns($criteria);
|
||||
}
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.preDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'BasePeer.preDoSelectRs'));
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
// BasePeer returns a Creole ResultSet, set to return
|
||||
// rows indexed numerically.
|
||||
$rs = BasePeer::doSelect($criteria, $con);
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.postDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($rs, 'BasePeer.postDoSelectRs'));
|
||||
}
|
||||
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* The returned array will contain objects of the default type or
|
||||
* objects that inherit from the default.
|
||||
*
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function populateObjects(ResultSet $rs)
|
||||
{
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
// set the class once to avoid overhead in the loop
|
||||
$cls = ThemeCssPeer::getOMClass();
|
||||
$cls = Propel::import($cls);
|
||||
// populate the object(s)
|
||||
while($rs->next()) {
|
||||
|
||||
$obj = new $cls();
|
||||
$obj->hydrate($rs);
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj) : $obj;
|
||||
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria, joining the related Theme table
|
||||
*
|
||||
* @param Criteria $c
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCountJoinTheme(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(ThemeCssPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(ThemeCssPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(ThemeCssPeer::THEME_ID, ThemePeer::ID);
|
||||
|
||||
$rs = ThemeCssPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects a collection of ThemeCss objects pre-filled with their Theme objects.
|
||||
*
|
||||
* @return ThemeCss[] Array of ThemeCss objects.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectJoinTheme(Criteria $c, $con = null)
|
||||
{
|
||||
$c = clone $c;
|
||||
|
||||
// Set the correct dbName if it has not been overridden
|
||||
if ($c->getDbName() == Propel::getDefaultDB()) {
|
||||
$c->setDbName(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
ThemeCssPeer::addSelectColumns($c);
|
||||
|
||||
ThemePeer::addSelectColumns($c);
|
||||
|
||||
$c->addJoin(ThemeCssPeer::THEME_ID, ThemePeer::ID);
|
||||
$rs = ThemeCssPeer::doSelectRs($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$obj1 = new ThemeCss();
|
||||
$startcol = $obj1->hydrate($rs);
|
||||
if ($obj1->getThemeId())
|
||||
{
|
||||
|
||||
$obj2 = new Theme();
|
||||
$obj2->hydrate($rs, $startcol);
|
||||
$obj2->addThemeCss($obj1);
|
||||
}
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria, joining all related tables
|
||||
*
|
||||
* @param Criteria $c
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(ThemeCssPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(ThemeCssPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(ThemeCssPeer::THEME_ID, ThemePeer::ID);
|
||||
|
||||
$rs = ThemeCssPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects a collection of ThemeCss objects pre-filled with all related objects.
|
||||
*
|
||||
* @return ThemeCss[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectJoinAll(Criteria $c, $con = null)
|
||||
{
|
||||
$c = clone $c;
|
||||
|
||||
// Set the correct dbName if it has not been overridden
|
||||
if ($c->getDbName() == Propel::getDefaultDB()) {
|
||||
$c->setDbName(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
ThemeCssPeer::addSelectColumns($c);
|
||||
$startcol2 = (ThemeCssPeer::NUM_COLUMNS - ThemeCssPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
|
||||
|
||||
ThemePeer::addSelectColumns($c);
|
||||
$startcol3 = $startcol2 + ThemePeer::NUM_COLUMNS;
|
||||
|
||||
$c->addJoin(ThemeCssPeer::THEME_ID, ThemePeer::ID);
|
||||
|
||||
$rs = BasePeer::doSelect($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$omClass = ThemeCssPeer::getOMClass();
|
||||
|
||||
|
||||
$cls = Propel::import($omClass);
|
||||
$obj1 = new $cls();
|
||||
$obj1->hydrate($rs);
|
||||
|
||||
|
||||
// Add objects for joined Theme rows
|
||||
|
||||
$omClass = ThemePeer::getOMClass();
|
||||
|
||||
|
||||
$cls = Propel::import($omClass);
|
||||
$obj2 = new $cls();
|
||||
$obj2->hydrate($rs, $startcol2);
|
||||
|
||||
$newObject = true;
|
||||
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
|
||||
$temp_obj1 = $results[$j];
|
||||
$temp_obj2 = $temp_obj1->getTheme(); // CHECKME
|
||||
if (null !== $temp_obj2 && $temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
|
||||
$newObject = false;
|
||||
$temp_obj2->addThemeCss($obj1); // CHECKME
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($newObject) {
|
||||
$obj2->initThemeCsss();
|
||||
$obj2->addThemeCss($obj1);
|
||||
}
|
||||
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TableMap related to this peer.
|
||||
* 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::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* The class that the Peer will make instances of.
|
||||
*
|
||||
* This uses a dot-path notation which is tranalted into a path
|
||||
* relative to a location on the PHP include_path.
|
||||
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
|
||||
*
|
||||
* @return string path.to.ClassName
|
||||
*/
|
||||
public static function getOMClass()
|
||||
{
|
||||
return ThemeCssPeer::CLASS_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an INSERT on the database, given a ThemeCss or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or ThemeCss object containing data that is used to create the INSERT statement.
|
||||
* @param Connection $con the 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($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeCssPeer:doInsert:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseThemeCssPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} else {
|
||||
$criteria = $values->buildCriteria(); // build Criteria from ThemeCss object
|
||||
}
|
||||
|
||||
$criteria->remove(ThemeCssPeer::ID); // remove pkey col since this table uses auto-increment
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table (I guess, conceivably)
|
||||
$con->begin();
|
||||
$pk = BasePeer::doInsert($criteria, $con);
|
||||
$con->commit();
|
||||
} catch(PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeCssPeer:doInsert:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseThemeCssPeer', $values, $con, $pk);
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an UPDATE on the database, given a ThemeCss or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or ThemeCss object containing data that is used to create the UPDATE statement.
|
||||
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doUpdate($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeCssPeer:doUpdate:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseThemeCssPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$selectCriteria = new Criteria(self::DATABASE_NAME);
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
|
||||
$comparison = $criteria->getComparison(ThemeCssPeer::ID);
|
||||
$selectCriteria->add(ThemeCssPeer::ID, $criteria->remove(ThemeCssPeer::ID), $comparison);
|
||||
|
||||
} else { // $values is ThemeCss object
|
||||
$criteria = $values->buildCriteria(); // gets full criteria
|
||||
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
|
||||
}
|
||||
|
||||
// set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeCssPeer:doUpdate:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseThemeCssPeer', $values, $con, $ret);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to DELETE all rows from the st_theme_css table.
|
||||
*
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public static function doDeleteAll($con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::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->begin();
|
||||
$affectedRows += BasePeer::doDeleteAll(ThemeCssPeer::TABLE_NAME, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform a DELETE on the database, given a ThemeCss or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or ThemeCss object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param Connection $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, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(ThemeCssPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} elseif ($values instanceof ThemeCss) {
|
||||
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria(self::DATABASE_NAME);
|
||||
$criteria->add(ThemeCssPeer::ID, (array) $values, Criteria::IN);
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::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->begin();
|
||||
|
||||
$affectedRows += BasePeer::doDelete($criteria, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates all modified columns of given ThemeCss object.
|
||||
* If parameter $columns is either a single column name or an array of column names
|
||||
* than only those columns are validated.
|
||||
*
|
||||
* NOTICE: This does not apply to primary or foreign keys for now.
|
||||
*
|
||||
* @param ThemeCss $obj The object to validate.
|
||||
* @param mixed $cols Column name or array of column names.
|
||||
*
|
||||
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
|
||||
*/
|
||||
public static function doValidate(ThemeCss $obj, $cols = null)
|
||||
{
|
||||
$columns = array();
|
||||
|
||||
if ($cols) {
|
||||
$dbMap = Propel::getDatabaseMap(ThemeCssPeer::DATABASE_NAME);
|
||||
$tableMap = $dbMap->getTable(ThemeCssPeer::TABLE_NAME);
|
||||
|
||||
if (! is_array($cols)) {
|
||||
$cols = array($cols);
|
||||
}
|
||||
|
||||
foreach($cols as $colName) {
|
||||
if ($tableMap->containsColumn($colName)) {
|
||||
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
|
||||
$columns[$colName] = $obj->$get();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
$res = BasePeer::doValidate(ThemeCssPeer::DATABASE_NAME, ThemeCssPeer::TABLE_NAME, $columns);
|
||||
if ($res !== true) {
|
||||
$request = sfContext::getInstance()->getRequest();
|
||||
foreach ($res as $failed) {
|
||||
$col = ThemeCssPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
|
||||
$request->setError($col, $failed->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single object by pkey.
|
||||
*
|
||||
* @param mixed $pk the primary key.
|
||||
* @param Connection $con the connection to use
|
||||
* @return ThemeCss
|
||||
*/
|
||||
public static function retrieveByPK($pk, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = new Criteria(ThemeCssPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(ThemeCssPeer::ID, $pk);
|
||||
|
||||
|
||||
$v = ThemeCssPeer::doSelect($criteria, $con);
|
||||
|
||||
return !empty($v) > 0 ? $v[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve multiple objects by pkey.
|
||||
*
|
||||
* @param array $pks List of primary keys
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return ThemeCss[]
|
||||
*/
|
||||
public static function retrieveByPKs($pks, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$objs = null;
|
||||
if (empty($pks)) {
|
||||
$objs = array();
|
||||
} else {
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(ThemeCssPeer::ID, $pks, Criteria::IN);
|
||||
$objs = ThemeCssPeer::doSelect($criteria, $con);
|
||||
}
|
||||
return $objs;
|
||||
}
|
||||
|
||||
} // BaseThemeCssPeer
|
||||
|
||||
// static code to register the map builder for this Peer with the main Propel class
|
||||
if (Propel::isInit()) {
|
||||
// the MapBuilder classes register themselves with Propel during initialization
|
||||
// so we need to load them here.
|
||||
try {
|
||||
BaseThemeCssPeer::getMapBuilder();
|
||||
} catch (Exception $e) {
|
||||
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
// even if Propel is not yet initialized, the map builder class can be registered
|
||||
// now and then it will be loaded when Propel initializes.
|
||||
Propel::registerMapBuilder('plugins.stThemePlugin.lib.model.map.ThemeCssMapBuilder');
|
||||
}
|
||||
944
plugins/stThemePlugin/lib/model/om/BaseThemeLayout.php
Normal file
944
plugins/stThemePlugin/lib/model/om/BaseThemeLayout.php
Normal file
@@ -0,0 +1,944 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'st_theme_layout' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseThemeLayout extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
protected static $dispatcher = null;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the theme_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $theme_id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the sf_guard_user_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $sf_guard_user_id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the container field.
|
||||
* @var string
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the blocks field.
|
||||
* @var string
|
||||
*/
|
||||
protected $blocks;
|
||||
|
||||
/**
|
||||
* @var Theme
|
||||
*/
|
||||
protected $aTheme;
|
||||
|
||||
/**
|
||||
* @var sfGuardUser
|
||||
*/
|
||||
protected $asfGuardUser;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInSave = false;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless validation loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInValidation = false;
|
||||
|
||||
/**
|
||||
* Get the [id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [theme_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getThemeId()
|
||||
{
|
||||
|
||||
return $this->theme_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [sf_guard_user_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSfGuardUserId()
|
||||
{
|
||||
|
||||
return $this->sf_guard_user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [container] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContainer()
|
||||
{
|
||||
|
||||
return $this->container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [blocks] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBlocks()
|
||||
{
|
||||
|
||||
return $this->blocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->id !== $v) {
|
||||
$this->id = $v;
|
||||
$this->modifiedColumns[] = ThemeLayoutPeer::ID;
|
||||
}
|
||||
|
||||
} // setId()
|
||||
|
||||
/**
|
||||
* Set the value of [theme_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setThemeId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->theme_id !== $v) {
|
||||
$this->theme_id = $v;
|
||||
$this->modifiedColumns[] = ThemeLayoutPeer::THEME_ID;
|
||||
}
|
||||
|
||||
if ($this->aTheme !== null && $this->aTheme->getId() !== $v) {
|
||||
$this->aTheme = null;
|
||||
}
|
||||
|
||||
} // setThemeId()
|
||||
|
||||
/**
|
||||
* Set the value of [sf_guard_user_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setSfGuardUserId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->sf_guard_user_id !== $v) {
|
||||
$this->sf_guard_user_id = $v;
|
||||
$this->modifiedColumns[] = ThemeLayoutPeer::SF_GUARD_USER_ID;
|
||||
}
|
||||
|
||||
if ($this->asfGuardUser !== null && $this->asfGuardUser->getId() !== $v) {
|
||||
$this->asfGuardUser = null;
|
||||
}
|
||||
|
||||
} // setSfGuardUserId()
|
||||
|
||||
/**
|
||||
* Set the value of [container] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setContainer($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_string($v)) {
|
||||
$v = (string) $v;
|
||||
}
|
||||
|
||||
if ($this->container !== $v) {
|
||||
$this->container = $v;
|
||||
$this->modifiedColumns[] = ThemeLayoutPeer::CONTAINER;
|
||||
}
|
||||
|
||||
} // setContainer()
|
||||
|
||||
/**
|
||||
* Set the value of [blocks] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setBlocks($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_string($v)) {
|
||||
$v = (string) $v;
|
||||
}
|
||||
|
||||
if ($this->blocks !== $v) {
|
||||
$this->blocks = $v;
|
||||
$this->modifiedColumns[] = ThemeLayoutPeer::BLOCKS;
|
||||
}
|
||||
|
||||
} // setBlocks()
|
||||
|
||||
/**
|
||||
* Hydrates (populates) the object variables with values from the database resultset.
|
||||
*
|
||||
* An offset (1-based "start column") is specified so that objects can be hydrated
|
||||
* with a subset of the columns in the resultset rows. This is needed, for example,
|
||||
* for results of JOIN queries where the resultset row includes columns from two or
|
||||
* more tables.
|
||||
*
|
||||
* @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
|
||||
* @param int $startcol 1-based offset column which indicates which restultset column to start with.
|
||||
* @return int next starting column
|
||||
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
|
||||
*/
|
||||
public function hydrate(ResultSet $rs, $startcol = 1)
|
||||
{
|
||||
try {
|
||||
if ($this->getDispatcher()->getListeners('ThemeLayout.preHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'ThemeLayout.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
|
||||
$startcol = $event['startcol'];
|
||||
}
|
||||
|
||||
$this->id = $rs->getInt($startcol + 0);
|
||||
|
||||
$this->theme_id = $rs->getInt($startcol + 1);
|
||||
|
||||
$this->sf_guard_user_id = $rs->getInt($startcol + 2);
|
||||
|
||||
$this->container = $rs->getString($startcol + 3);
|
||||
|
||||
$this->blocks = $rs->getString($startcol + 4);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
if ($this->getDispatcher()->getListeners('ThemeLayout.postHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'ThemeLayout.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 5)));
|
||||
return $event['startcol'];
|
||||
}
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 5; // 5 = ThemeLayoutPeer::NUM_COLUMNS - ThemeLayoutPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating ThemeLayout object", $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this object from datastore and sets delete attribute.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
* @see BaseObject::setDeleted()
|
||||
* @see BaseObject::isDeleted()
|
||||
*/
|
||||
public function delete($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("This object has already been deleted.");
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('ThemeLayout.preDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'ThemeLayout.preDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseThemeLayout:delete:pre'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseThemeLayout:delete:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, $this, $con);
|
||||
if ($ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(ThemeLayoutPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
ThemeLayoutPeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('ThemeLayout.postDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'ThemeLayout.postDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseThemeLayout:delete:post'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseThemeLayout:delete:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database. If the object is new,
|
||||
* it inserts it; otherwise an update is performed. This method
|
||||
* wraps the doSave() worker method in a transaction.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see doSave()
|
||||
*/
|
||||
public function save($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("You cannot save an object that has been deleted.");
|
||||
}
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('ThemeLayout.preSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'ThemeLayout.preSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeLayout:save:pre') as $callable)
|
||||
{
|
||||
$affectedRows = call_user_func($callable, $this, $con);
|
||||
if (is_int($affectedRows))
|
||||
{
|
||||
return $affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(ThemeLayoutPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('ThemeLayout.postSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'ThemeLayout.postSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemeLayout:save:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, $this, $con, $affectedRows);
|
||||
}
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database.
|
||||
*
|
||||
* If the object is new, it inserts it; otherwise an update is performed.
|
||||
* All related objects are also updated in this method.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see save()
|
||||
*/
|
||||
protected function doSave($con)
|
||||
{
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
if (!$this->alreadyInSave) {
|
||||
$this->alreadyInSave = true;
|
||||
|
||||
|
||||
// We call the save method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->aTheme !== null) {
|
||||
if ($this->aTheme->isModified()) {
|
||||
$affectedRows += $this->aTheme->save($con);
|
||||
}
|
||||
$this->setTheme($this->aTheme);
|
||||
}
|
||||
|
||||
if ($this->asfGuardUser !== null) {
|
||||
if ($this->asfGuardUser->isModified()) {
|
||||
$affectedRows += $this->asfGuardUser->save($con);
|
||||
}
|
||||
$this->setsfGuardUser($this->asfGuardUser);
|
||||
}
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = ThemeLayoutPeer::doInsert($this, $con);
|
||||
$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
|
||||
// should always be true here (even though technically
|
||||
// BasePeer::doInsert() can insert multiple rows).
|
||||
|
||||
$this->setId($pk); //[IMV] update autoincrement primary key
|
||||
|
||||
$this->setNew(false);
|
||||
} else {
|
||||
$affectedRows += ThemeLayoutPeer::doUpdate($this, $con);
|
||||
}
|
||||
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
|
||||
}
|
||||
|
||||
$this->alreadyInSave = false;
|
||||
}
|
||||
return $affectedRows;
|
||||
} // doSave()
|
||||
|
||||
/**
|
||||
* Array of ValidationFailed objects.
|
||||
* @var array ValidationFailed[]
|
||||
*/
|
||||
protected $validationFailures = array();
|
||||
|
||||
/**
|
||||
* Gets any ValidationFailed objects that resulted from last call to validate().
|
||||
*
|
||||
*
|
||||
* @return array ValidationFailed[]
|
||||
* @see validate()
|
||||
*/
|
||||
public function getValidationFailures()
|
||||
{
|
||||
return $this->validationFailures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the objects modified field values and all objects related to this table.
|
||||
*
|
||||
* If $columns is either a column name or an array of column names
|
||||
* only those columns are validated.
|
||||
*
|
||||
* @param mixed $columns Column name or an array of column names.
|
||||
* @return boolean Whether all columns pass validation.
|
||||
* @see doValidate()
|
||||
* @see getValidationFailures()
|
||||
*/
|
||||
public function validate($columns = null)
|
||||
{
|
||||
$res = $this->doValidate($columns);
|
||||
if ($res === true) {
|
||||
$this->validationFailures = array();
|
||||
return true;
|
||||
} else {
|
||||
$this->validationFailures = $res;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function performs the validation work for complex object models.
|
||||
*
|
||||
* In addition to checking the current object, all related objects will
|
||||
* also be validated. If all pass then <code>true</code> is returned; otherwise
|
||||
* an aggreagated array of ValidationFailed objects will be returned.
|
||||
*
|
||||
* @param array $columns Array of column names to validate.
|
||||
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
|
||||
*/
|
||||
protected function doValidate($columns = null)
|
||||
{
|
||||
if (!$this->alreadyInValidation) {
|
||||
$this->alreadyInValidation = true;
|
||||
$retval = null;
|
||||
|
||||
$failureMap = array();
|
||||
|
||||
|
||||
// We call the validate method on the following object(s) if they
|
||||
// were passed to this object by their coresponding set
|
||||
// method. This object relates to these object(s) by a
|
||||
// foreign key reference.
|
||||
|
||||
if ($this->aTheme !== null) {
|
||||
if (!$this->aTheme->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->aTheme->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->asfGuardUser !== null) {
|
||||
if (!$this->asfGuardUser->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->asfGuardUser->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($retval = ThemeLayoutPeer::doValidate($this, $columns)) !== true) {
|
||||
$failureMap = array_merge($failureMap, $retval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->alreadyInValidation = false;
|
||||
}
|
||||
|
||||
return (!empty($failureMap) ? $failureMap : true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name name
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return mixed Value of field.
|
||||
*/
|
||||
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = ThemeLayoutPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->getByPosition($pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @return mixed Value of field at $pos
|
||||
*/
|
||||
public function getByPosition($pos)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
return $this->getId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getThemeId();
|
||||
break;
|
||||
case 2:
|
||||
return $this->getSfGuardUserId();
|
||||
break;
|
||||
case 3:
|
||||
return $this->getContainer();
|
||||
break;
|
||||
case 4:
|
||||
return $this->getBlocks();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the object as an array.
|
||||
*
|
||||
* You can specify the key type of the array by passing one of the class
|
||||
* type constants.
|
||||
*
|
||||
* @param string $keyType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return an associative array containing the field names (as keys) and field values
|
||||
*/
|
||||
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = ThemeLayoutPeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getId(),
|
||||
$keys[1] => $this->getThemeId(),
|
||||
$keys[2] => $this->getSfGuardUserId(),
|
||||
$keys[3] => $this->getContainer(),
|
||||
$keys[4] => $this->getBlocks(),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name peer name
|
||||
* @param mixed $value field value
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return void
|
||||
*/
|
||||
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = ThemeLayoutPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->setByPosition($pos, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @param mixed $value field value
|
||||
* @return void
|
||||
*/
|
||||
public function setByPosition($pos, $value)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
$this->setId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setThemeId($value);
|
||||
break;
|
||||
case 2:
|
||||
$this->setSfGuardUserId($value);
|
||||
break;
|
||||
case 3:
|
||||
$this->setContainer($value);
|
||||
break;
|
||||
case 4:
|
||||
$this->setBlocks($value);
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the object using an array.
|
||||
*
|
||||
* This is particularly useful when populating an object from one of the
|
||||
* request arrays (e.g. $_POST). This method goes through the column
|
||||
* names, checking to see whether a matching key exists in populated
|
||||
* array. If so the setByName() method is called for that column.
|
||||
*
|
||||
* You can specify the key type of the array by additionally passing one
|
||||
* of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
|
||||
* TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
|
||||
*
|
||||
* @param array $arr An array to populate the object from.
|
||||
* @param string $keyType The type of keys the array uses.
|
||||
* @return void
|
||||
*/
|
||||
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = ThemeLayoutPeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setThemeId($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setSfGuardUserId($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setContainer($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[4], $arr)) $this->setBlocks($arr[$keys[4]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Criteria object containing the values of all modified columns in this object.
|
||||
*
|
||||
* @return Criteria The Criteria object containing all modified values.
|
||||
*/
|
||||
public function buildCriteria()
|
||||
{
|
||||
$criteria = new Criteria(ThemeLayoutPeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(ThemeLayoutPeer::ID)) $criteria->add(ThemeLayoutPeer::ID, $this->id);
|
||||
if ($this->isColumnModified(ThemeLayoutPeer::THEME_ID)) $criteria->add(ThemeLayoutPeer::THEME_ID, $this->theme_id);
|
||||
if ($this->isColumnModified(ThemeLayoutPeer::SF_GUARD_USER_ID)) $criteria->add(ThemeLayoutPeer::SF_GUARD_USER_ID, $this->sf_guard_user_id);
|
||||
if ($this->isColumnModified(ThemeLayoutPeer::CONTAINER)) $criteria->add(ThemeLayoutPeer::CONTAINER, $this->container);
|
||||
if ($this->isColumnModified(ThemeLayoutPeer::BLOCKS)) $criteria->add(ThemeLayoutPeer::BLOCKS, $this->blocks);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a Criteria object containing the primary key for this object.
|
||||
*
|
||||
* Unlike buildCriteria() this method includes the primary key values regardless
|
||||
* of whether or not they have been modified.
|
||||
*
|
||||
* @return Criteria The Criteria object containing value(s) for primary key(s).
|
||||
*/
|
||||
public function buildPkeyCriteria()
|
||||
{
|
||||
$criteria = new Criteria(ThemeLayoutPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(ThemeLayoutPeer::ID, $this->id);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary key for this object (row).
|
||||
* @return int
|
||||
*/
|
||||
public function getPrimaryKey()
|
||||
{
|
||||
return $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [composite] primary key fields
|
||||
*
|
||||
* @param string $keyType
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
return array(ThemeLayoutPeer::translateFieldName('id', BasePeer::TYPE_FIELDNAME, $keyType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method to set the primary key (id column).
|
||||
*
|
||||
* @param int $key Primary key.
|
||||
* @return void
|
||||
*/
|
||||
public function setPrimaryKey($key)
|
||||
{
|
||||
$this->setId($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contents of passed object to values from current object.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param object $copyObj An object of ThemeLayout (or compatible) type.
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copyInto($copyObj, $deepCopy = false)
|
||||
{
|
||||
|
||||
$copyObj->setThemeId($this->theme_id);
|
||||
|
||||
$copyObj->setSfGuardUserId($this->sf_guard_user_id);
|
||||
|
||||
$copyObj->setContainer($this->container);
|
||||
|
||||
$copyObj->setBlocks($this->blocks);
|
||||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
|
||||
$copyObj->setId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a copy of this object that will be inserted as a new row in table when saved.
|
||||
* It creates a new object filling in the simple attributes, but skipping any primary
|
||||
* keys that are defined for the table.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @return ThemeLayout Clone of current object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copy($deepCopy = false)
|
||||
{
|
||||
// we use get_class(), because this might be a subclass
|
||||
$clazz = get_class($this);
|
||||
$copyObj = new $clazz();
|
||||
$this->copyInto($copyObj, $deepCopy);
|
||||
return $copyObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a peer instance associated with this om.
|
||||
*
|
||||
* @return string Peer class name
|
||||
*/
|
||||
public function getPeer()
|
||||
{
|
||||
return 'ThemeLayoutPeer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a Theme object.
|
||||
*
|
||||
* @param Theme $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setTheme($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setThemeId(NULL);
|
||||
} else {
|
||||
$this->setThemeId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->aTheme = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated Theme object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return Theme The associated Theme object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getTheme($con = null)
|
||||
{
|
||||
if ($this->aTheme === null && ($this->theme_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->aTheme = ThemePeer::retrieveByPK($this->theme_id, $con);
|
||||
|
||||
/* The following can be used instead of the line above to
|
||||
guarantee the related object contains a reference
|
||||
to this object, but this level of coupling
|
||||
may be undesirable in many circumstances.
|
||||
As it can lead to a db query with many results that may
|
||||
never be used.
|
||||
$obj = ThemePeer::retrieveByPK($this->theme_id, $con);
|
||||
$obj->addThemes($this);
|
||||
*/
|
||||
}
|
||||
return $this->aTheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a sfGuardUser object.
|
||||
*
|
||||
* @param sfGuardUser $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setsfGuardUser($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setSfGuardUserId(NULL);
|
||||
} else {
|
||||
$this->setSfGuardUserId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->asfGuardUser = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated sfGuardUser object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return sfGuardUser The associated sfGuardUser object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getsfGuardUser($con = null)
|
||||
{
|
||||
if ($this->asfGuardUser === null && ($this->sf_guard_user_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->asfGuardUser = sfGuardUserPeer::retrieveByPK($this->sf_guard_user_id, $con);
|
||||
|
||||
/* The following can be used instead of the line above to
|
||||
guarantee the related object contains a reference
|
||||
to this object, but this level of coupling
|
||||
may be undesirable in many circumstances.
|
||||
As it can lead to a db query with many results that may
|
||||
never be used.
|
||||
$obj = sfGuardUserPeer::retrieveByPK($this->sf_guard_user_id, $con);
|
||||
$obj->addsfGuardUsers($this);
|
||||
*/
|
||||
}
|
||||
return $this->asfGuardUser;
|
||||
}
|
||||
|
||||
|
||||
public function getDispatcher()
|
||||
{
|
||||
if (null === self::$dispatcher)
|
||||
{
|
||||
self::$dispatcher = stEventDispatcher::getInstance();
|
||||
}
|
||||
|
||||
return self::$dispatcher;
|
||||
}
|
||||
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
$event = $this->getDispatcher()->notifyUntil(new sfEvent($this, 'ThemeLayout.' . $method, array('arguments' => $arguments, 'method' => $method)));
|
||||
|
||||
if ($event->isProcessed())
|
||||
{
|
||||
return $event->getReturnValue();
|
||||
}
|
||||
|
||||
if (!$callable = sfMixer::getCallable('BaseThemeLayout:'.$method))
|
||||
{
|
||||
throw new sfException(sprintf('Call to undefined method BaseThemeLayout::%s', $method));
|
||||
}
|
||||
|
||||
array_unshift($arguments, $this);
|
||||
|
||||
return call_user_func_array($callable, $arguments);
|
||||
}
|
||||
|
||||
} // BaseThemeLayout
|
||||
1197
plugins/stThemePlugin/lib/model/om/BaseThemeLayoutPeer.php
Normal file
1197
plugins/stThemePlugin/lib/model/om/BaseThemeLayoutPeer.php
Normal file
File diff suppressed because it is too large
Load Diff
827
plugins/stThemePlugin/lib/model/om/BaseThemePeer.php
Normal file
827
plugins/stThemePlugin/lib/model/om/BaseThemePeer.php
Normal file
@@ -0,0 +1,827 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base static class for performing query and update operations on the 'st_theme' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stThemePlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseThemePeer {
|
||||
|
||||
/** the default database name for this class */
|
||||
const DATABASE_NAME = 'propel';
|
||||
|
||||
/** the table name for this class */
|
||||
const TABLE_NAME = 'st_theme';
|
||||
|
||||
/** A class that can be returned by this peer. */
|
||||
const CLASS_DEFAULT = 'plugins.stThemePlugin.lib.model.Theme';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 8;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
|
||||
/** the column name for the ID field */
|
||||
const ID = 'st_theme.ID';
|
||||
|
||||
/** the column name for the BASE_THEME_ID field */
|
||||
const BASE_THEME_ID = 'st_theme.BASE_THEME_ID';
|
||||
|
||||
/** the column name for the THEME field */
|
||||
const THEME = 'st_theme.THEME';
|
||||
|
||||
/** the column name for the ACTIVE field */
|
||||
const ACTIVE = 'st_theme.ACTIVE';
|
||||
|
||||
/** the column name for the OPT_COLOR_SCHEME field */
|
||||
const OPT_COLOR_SCHEME = 'st_theme.OPT_COLOR_SCHEME';
|
||||
|
||||
/** the column name for the VERSION field */
|
||||
const VERSION = 'st_theme.VERSION';
|
||||
|
||||
/** the column name for the IS_SYSTEM_DEFAULT field */
|
||||
const IS_SYSTEM_DEFAULT = 'st_theme.IS_SYSTEM_DEFAULT';
|
||||
|
||||
/** the column name for the IS_HIDDEN field */
|
||||
const IS_HIDDEN = 'st_theme.IS_HIDDEN';
|
||||
|
||||
/** The PHP to DB Name Mapping */
|
||||
private static $phpNameMap = null;
|
||||
|
||||
|
||||
/**
|
||||
* holds an array of fieldnames
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id', 'BaseThemeId', 'Theme', 'Active', 'OptColorScheme', 'Version', 'IsSystemDefault', 'IsHidden', ),
|
||||
BasePeer::TYPE_COLNAME => array (ThemePeer::ID, ThemePeer::BASE_THEME_ID, ThemePeer::THEME, ThemePeer::ACTIVE, ThemePeer::OPT_COLOR_SCHEME, ThemePeer::VERSION, ThemePeer::IS_SYSTEM_DEFAULT, ThemePeer::IS_HIDDEN, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'base_theme_id', 'theme', 'active', 'opt_color_scheme', 'version', 'is_system_default', 'is_hidden', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
|
||||
);
|
||||
|
||||
/**
|
||||
* holds an array of keys for quick access to the fieldnames array
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'BaseThemeId' => 1, 'Theme' => 2, 'Active' => 3, 'OptColorScheme' => 4, 'Version' => 5, 'IsSystemDefault' => 6, 'IsHidden' => 7, ),
|
||||
BasePeer::TYPE_COLNAME => array (ThemePeer::ID => 0, ThemePeer::BASE_THEME_ID => 1, ThemePeer::THEME => 2, ThemePeer::ACTIVE => 3, ThemePeer::OPT_COLOR_SCHEME => 4, ThemePeer::VERSION => 5, ThemePeer::IS_SYSTEM_DEFAULT => 6, ThemePeer::IS_HIDDEN => 7, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'base_theme_id' => 1, 'theme' => 2, 'active' => 3, 'opt_color_scheme' => 4, 'version' => 5, 'is_system_default' => 6, 'is_hidden' => 7, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
|
||||
);
|
||||
|
||||
protected static $hydrateMethod = null;
|
||||
|
||||
protected static $postHydrateMethod = null;
|
||||
|
||||
public static function setHydrateMethod($callback)
|
||||
{
|
||||
self::$hydrateMethod = $callback;
|
||||
}
|
||||
|
||||
public static function setPostHydrateMethod($callback)
|
||||
{
|
||||
self::$postHydrateMethod = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MapBuilder the map builder for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getMapBuilder()
|
||||
{
|
||||
return BasePeer::getMapBuilder('plugins.stThemePlugin.lib.model.map.ThemeMapBuilder');
|
||||
}
|
||||
/**
|
||||
* Gets a map (hash) of PHP names to DB column names.
|
||||
*
|
||||
* @return array The PHP to DB name map for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
|
||||
*/
|
||||
public static function getPhpNameMap()
|
||||
{
|
||||
if (self::$phpNameMap === null) {
|
||||
$map = ThemePeer::getTableMap();
|
||||
$columns = $map->getColumns();
|
||||
$nameMap = array();
|
||||
foreach ($columns as $column) {
|
||||
$nameMap[$column->getPhpName()] = $column->getColumnName();
|
||||
}
|
||||
self::$phpNameMap = $nameMap;
|
||||
}
|
||||
return self::$phpNameMap;
|
||||
}
|
||||
/**
|
||||
* Translates a fieldname to another type
|
||||
*
|
||||
* @param string $name field name
|
||||
* @param string $fromType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @param string $toType One of the class type constants
|
||||
* @return string translated name of the field.
|
||||
*/
|
||||
static public function translateFieldName($name, $fromType, $toType)
|
||||
{
|
||||
$toNames = self::getFieldNames($toType);
|
||||
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
|
||||
if ($key === null) {
|
||||
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
|
||||
}
|
||||
return $toNames[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of of field names.
|
||||
*
|
||||
* @param string $type The type of fieldnames to return:
|
||||
* One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return array A list of field names
|
||||
*/
|
||||
|
||||
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
if (!array_key_exists($type, self::$fieldNames)) {
|
||||
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
|
||||
}
|
||||
return self::$fieldNames[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method which changes table.column to alias.column.
|
||||
*
|
||||
* Using this method you can maintain SQL abstraction while using column aliases.
|
||||
* <code>
|
||||
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
|
||||
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
|
||||
* </code>
|
||||
* @param string $alias The alias for the current table.
|
||||
* @param string $column The column name for current table. (i.e. ThemePeer::COLUMN_NAME).
|
||||
* @return string
|
||||
*/
|
||||
public static function alias($alias, $column)
|
||||
{
|
||||
return str_replace(ThemePeer::TABLE_NAME.'.', $alias.'.', $column);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 object containing the columns to add.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function addSelectColumns(Criteria $criteria)
|
||||
{
|
||||
|
||||
$criteria->addSelectColumn(ThemePeer::ID);
|
||||
|
||||
$criteria->addSelectColumn(ThemePeer::BASE_THEME_ID);
|
||||
|
||||
$criteria->addSelectColumn(ThemePeer::THEME);
|
||||
|
||||
$criteria->addSelectColumn(ThemePeer::ACTIVE);
|
||||
|
||||
$criteria->addSelectColumn(ThemePeer::OPT_COLOR_SCHEME);
|
||||
|
||||
$criteria->addSelectColumn(ThemePeer::VERSION);
|
||||
|
||||
$criteria->addSelectColumn(ThemePeer::IS_SYSTEM_DEFAULT);
|
||||
|
||||
$criteria->addSelectColumn(ThemePeer::IS_HIDDEN);
|
||||
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('ThemePeer.postAddSelectColumns')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'ThemePeer.postAddSelectColumns'));
|
||||
}
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(st_theme.ID)';
|
||||
const COUNT_DISTINCT = 'COUNT(DISTINCT st_theme.ID)';
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(ThemePeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(ThemePeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$rs = ThemePeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Method to select one object from the DB.
|
||||
*
|
||||
* @param Criteria $criteria object used to create the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return Theme
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectOne(Criteria $criteria, $con = null)
|
||||
{
|
||||
$critcopy = clone $criteria;
|
||||
$critcopy->setLimit(1);
|
||||
$objects = ThemePeer::doSelect($critcopy, $con);
|
||||
if ($objects) {
|
||||
return $objects[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Method to do selects.
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return Theme[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelect(Criteria $criteria, $con = null)
|
||||
{
|
||||
return ThemePeer::populateObjects(ThemePeer::doSelectRS($criteria, $con));
|
||||
}
|
||||
/**
|
||||
* Prepares the Criteria object and uses the parent doSelect()
|
||||
* method to get a ResultSet.
|
||||
*
|
||||
* Use this method directly if you want to just get the resultset
|
||||
* (instead of an array of objects).
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return ResultSet The resultset object with numerically-indexed fields.
|
||||
* @see BasePeer::doSelect()
|
||||
*/
|
||||
public static function doSelectRS(Criteria $criteria, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if (!$criteria->getSelectColumns()) {
|
||||
$criteria = clone $criteria;
|
||||
ThemePeer::addSelectColumns($criteria);
|
||||
}
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.preDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'BasePeer.preDoSelectRs'));
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
// BasePeer returns a Creole ResultSet, set to return
|
||||
// rows indexed numerically.
|
||||
$rs = BasePeer::doSelect($criteria, $con);
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.postDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($rs, 'BasePeer.postDoSelectRs'));
|
||||
}
|
||||
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* The returned array will contain objects of the default type or
|
||||
* objects that inherit from the default.
|
||||
*
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function populateObjects(ResultSet $rs)
|
||||
{
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
// set the class once to avoid overhead in the loop
|
||||
$cls = ThemePeer::getOMClass();
|
||||
$cls = Propel::import($cls);
|
||||
// populate the object(s)
|
||||
while($rs->next()) {
|
||||
|
||||
$obj = new $cls();
|
||||
$obj->hydrate($rs);
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj) : $obj;
|
||||
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria, joining all related tables
|
||||
*
|
||||
* @param Criteria $c
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(ThemePeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(ThemePeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$rs = ThemePeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects a collection of Theme objects pre-filled with all related objects.
|
||||
*
|
||||
* @return Theme[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectJoinAll(Criteria $c, $con = null)
|
||||
{
|
||||
$c = clone $c;
|
||||
|
||||
// Set the correct dbName if it has not been overridden
|
||||
if ($c->getDbName() == Propel::getDefaultDB()) {
|
||||
$c->setDbName(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
ThemePeer::addSelectColumns($c);
|
||||
$startcol2 = (ThemePeer::NUM_COLUMNS - ThemePeer::NUM_LAZY_LOAD_COLUMNS) + 1;
|
||||
|
||||
$rs = BasePeer::doSelect($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$omClass = ThemePeer::getOMClass();
|
||||
|
||||
|
||||
$cls = Propel::import($omClass);
|
||||
$obj1 = new $cls();
|
||||
$obj1->hydrate($rs);
|
||||
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TableMap related to this peer.
|
||||
* 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::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* The class that the Peer will make instances of.
|
||||
*
|
||||
* This uses a dot-path notation which is tranalted into a path
|
||||
* relative to a location on the PHP include_path.
|
||||
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
|
||||
*
|
||||
* @return string path.to.ClassName
|
||||
*/
|
||||
public static function getOMClass()
|
||||
{
|
||||
return ThemePeer::CLASS_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an INSERT on the database, given a Theme or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or Theme object containing data that is used to create the INSERT statement.
|
||||
* @param Connection $con the 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($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemePeer:doInsert:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseThemePeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} else {
|
||||
$criteria = $values->buildCriteria(); // build Criteria from Theme object
|
||||
}
|
||||
|
||||
$criteria->remove(ThemePeer::ID); // remove pkey col since this table uses auto-increment
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table (I guess, conceivably)
|
||||
$con->begin();
|
||||
$pk = BasePeer::doInsert($criteria, $con);
|
||||
$con->commit();
|
||||
} catch(PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemePeer:doInsert:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseThemePeer', $values, $con, $pk);
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an UPDATE on the database, given a Theme or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or Theme object containing data that is used to create the UPDATE statement.
|
||||
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doUpdate($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemePeer:doUpdate:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseThemePeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$selectCriteria = new Criteria(self::DATABASE_NAME);
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
|
||||
$comparison = $criteria->getComparison(ThemePeer::ID);
|
||||
$selectCriteria->add(ThemePeer::ID, $criteria->remove(ThemePeer::ID), $comparison);
|
||||
|
||||
} else { // $values is Theme object
|
||||
$criteria = $values->buildCriteria(); // gets full criteria
|
||||
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
|
||||
}
|
||||
|
||||
// set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BaseThemePeer:doUpdate:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseThemePeer', $values, $con, $ret);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to DELETE all rows from the st_theme table.
|
||||
*
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public static function doDeleteAll($con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::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->begin();
|
||||
$affectedRows += ThemePeer::doOnDeleteCascade(new Criteria(), $con);
|
||||
ThemePeer::doOnDeleteSetNull(new Criteria(), $con);
|
||||
$affectedRows += BasePeer::doDeleteAll(ThemePeer::TABLE_NAME, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform a DELETE on the database, given a Theme or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or Theme object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param Connection $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, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(ThemePeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} elseif ($values instanceof Theme) {
|
||||
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria(self::DATABASE_NAME);
|
||||
$criteria->add(ThemePeer::ID, (array) $values, Criteria::IN);
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::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->begin();
|
||||
$affectedRows += ThemePeer::doOnDeleteCascade($criteria, $con);ThemePeer::doOnDeleteSetNull($criteria, $con);
|
||||
$affectedRows += BasePeer::doDelete($criteria, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a method for emulating ON DELETE CASCADE for DBs that don't support this
|
||||
* feature (like MySQL or SQLite).
|
||||
*
|
||||
* This method is not very speedy because it must perform a query first to get
|
||||
* the implicated records and then perform the deletes by calling those Peer classes.
|
||||
*
|
||||
* This method should be used within a transaction if possible.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param Connection $con
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
protected static function doOnDeleteCascade(Criteria $criteria, Connection $con)
|
||||
{
|
||||
// initialize var to track total num of affected rows
|
||||
$affectedRows = 0;
|
||||
|
||||
// first find the objects that are implicated by the $criteria
|
||||
$objects = ThemePeer::doSelect($criteria, $con);
|
||||
foreach($objects as $obj) {
|
||||
|
||||
|
||||
// delete related SmartySlot objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(SmartySlotPeer::THEME_ID, $obj->getId());
|
||||
$affectedRows += SmartySlotPeer::doDelete($c, $con);
|
||||
|
||||
// delete related ThemeLayout objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ThemeLayoutPeer::THEME_ID, $obj->getId());
|
||||
$affectedRows += ThemeLayoutPeer::doDelete($c, $con);
|
||||
|
||||
// delete related ThemeConfig objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ThemeConfigPeer::ID, $obj->getId());
|
||||
$affectedRows += ThemeConfigPeer::doDelete($c, $con);
|
||||
|
||||
// delete related ThemeContent objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(ThemeContentPeer::THEME_ID, $obj->getId());
|
||||
$affectedRows += ThemeContentPeer::doDelete($c, $con);
|
||||
}
|
||||
return $affectedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a method for emulating ON DELETE SET NULL DBs that don't support this
|
||||
* feature (like MySQL or SQLite).
|
||||
*
|
||||
* This method is not very speedy because it must perform a query first to get
|
||||
* the implicated records and then perform the deletes by calling those Peer classes.
|
||||
*
|
||||
* This method should be used within a transaction if possible.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param Connection $con
|
||||
* @return void
|
||||
*/
|
||||
protected static function doOnDeleteSetNull(Criteria $criteria, Connection $con)
|
||||
{
|
||||
|
||||
// first find the objects that are implicated by the $criteria
|
||||
$objects = ThemePeer::doSelect($criteria, $con);
|
||||
foreach($objects as $obj) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates all modified columns of given Theme object.
|
||||
* If parameter $columns is either a single column name or an array of column names
|
||||
* than only those columns are validated.
|
||||
*
|
||||
* NOTICE: This does not apply to primary or foreign keys for now.
|
||||
*
|
||||
* @param Theme $obj The object to validate.
|
||||
* @param mixed $cols Column name or array of column names.
|
||||
*
|
||||
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
|
||||
*/
|
||||
public static function doValidate(Theme $obj, $cols = null)
|
||||
{
|
||||
$columns = array();
|
||||
|
||||
if ($cols) {
|
||||
$dbMap = Propel::getDatabaseMap(ThemePeer::DATABASE_NAME);
|
||||
$tableMap = $dbMap->getTable(ThemePeer::TABLE_NAME);
|
||||
|
||||
if (! is_array($cols)) {
|
||||
$cols = array($cols);
|
||||
}
|
||||
|
||||
foreach($cols as $colName) {
|
||||
if ($tableMap->containsColumn($colName)) {
|
||||
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
|
||||
$columns[$colName] = $obj->$get();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
$res = BasePeer::doValidate(ThemePeer::DATABASE_NAME, ThemePeer::TABLE_NAME, $columns);
|
||||
if ($res !== true) {
|
||||
$request = sfContext::getInstance()->getRequest();
|
||||
foreach ($res as $failed) {
|
||||
$col = ThemePeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
|
||||
$request->setError($col, $failed->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single object by pkey.
|
||||
*
|
||||
* @param mixed $pk the primary key.
|
||||
* @param Connection $con the connection to use
|
||||
* @return Theme
|
||||
*/
|
||||
public static function retrieveByPK($pk, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = new Criteria(ThemePeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(ThemePeer::ID, $pk);
|
||||
|
||||
|
||||
$v = ThemePeer::doSelect($criteria, $con);
|
||||
|
||||
return !empty($v) > 0 ? $v[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve multiple objects by pkey.
|
||||
*
|
||||
* @param array $pks List of primary keys
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return Theme[]
|
||||
*/
|
||||
public static function retrieveByPKs($pks, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$objs = null;
|
||||
if (empty($pks)) {
|
||||
$objs = array();
|
||||
} else {
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(ThemePeer::ID, $pks, Criteria::IN);
|
||||
$objs = ThemePeer::doSelect($criteria, $con);
|
||||
}
|
||||
return $objs;
|
||||
}
|
||||
|
||||
} // BaseThemePeer
|
||||
|
||||
// static code to register the map builder for this Peer with the main Propel class
|
||||
if (Propel::isInit()) {
|
||||
// the MapBuilder classes register themselves with Propel during initialization
|
||||
// so we need to load them here.
|
||||
try {
|
||||
BaseThemePeer::getMapBuilder();
|
||||
} catch (Exception $e) {
|
||||
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
// even if Propel is not yet initialized, the map builder class can be registered
|
||||
// now and then it will be loaded when Propel initializes.
|
||||
Propel::registerMapBuilder('plugins.stThemePlugin.lib.model.map.ThemeMapBuilder');
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
class stGuardUserThemeValidator extends sfGuardUserValidator
|
||||
{
|
||||
public function execute(&$value, &$error)
|
||||
{
|
||||
$i18n = sfContext::getInstance()->getI18N();
|
||||
|
||||
$path = sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.'frontend'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'soteshop.yml';
|
||||
|
||||
$config = sfYaml::load($path);
|
||||
|
||||
$developerTheme = $config['all']['.view']['theme'];
|
||||
|
||||
if ($developerTheme)
|
||||
{
|
||||
$error = $i18n->__('W sklepie wdrożono indywidualną grafikę. Edycja grafiki możliwa tylko przez programistów.');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return parent::execute($value, $error);
|
||||
}
|
||||
}
|
||||
81
plugins/stThemePlugin/lib/stSecurityConfigHandler.class.php
Normal file
81
plugins/stThemePlugin/lib/stSecurityConfigHandler.class.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
||||
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
/**
|
||||
* SOTESHOP/stThemePlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stThemePlugin opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stThemePlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
|
||||
* @version $Id: stSecurityConfigHandler.class.php 256 2009-03-30 11:49:45Z marek $
|
||||
*/
|
||||
|
||||
/**
|
||||
* sfSecurityConfigHandler allows you to configure action security.
|
||||
*
|
||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||
*
|
||||
* @package stThemePlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stSecurityConfigHandler extends sfYamlConfigHandler
|
||||
{
|
||||
/**
|
||||
* Executes this configuration handler.
|
||||
*
|
||||
* @param array An array of absolute filesystem path to a configuration file
|
||||
* @return string Data to be written to a cache file
|
||||
* @throws <b>sfConfigurationException</b> If a requested configuration file does not exist or is not readable
|
||||
* @throws <b>sfParseException</b> If a requested configuration file is improperly formatted
|
||||
* @throws <b>sfInitializationException</b> If a view.yml key check fails
|
||||
*/
|
||||
public function execute($configFiles)
|
||||
{
|
||||
|
||||
// parse the yaml
|
||||
$myConfig = $this->parseYamls($configFiles);
|
||||
|
||||
if (SF_APP == 'backend')
|
||||
{
|
||||
$myConfig['all'] = sfToolkit::arrayDeepMerge(
|
||||
isset($myConfig['default']) && is_array($myConfig['default']) ? $myConfig['default'] : array(),
|
||||
isset($myConfig['all']) && is_array($myConfig['all']) ? $myConfig['all'] : array()
|
||||
);
|
||||
}
|
||||
elseif (SF_APP == 'frontend')
|
||||
{
|
||||
$myConfig['all'] = sfToolkit::arrayDeepMerge(
|
||||
isset($myConfig[SF_ENVIRONMENT]['default']) && is_array($myConfig[SF_ENVIRONMENT]['default']) ? $myConfig[SF_ENVIRONMENT]['default'] : array(),
|
||||
isset($myConfig[SF_ENVIRONMENT]['all']) && is_array($myConfig[SF_ENVIRONMENT]['all']) ? $myConfig[SF_ENVIRONMENT]['all'] : array()
|
||||
);
|
||||
|
||||
unset($myConfig[SF_ENVIRONMENT]['default']);
|
||||
unset($myConfig[SF_ENVIRONMENT]['all']);
|
||||
}
|
||||
|
||||
|
||||
unset($myConfig['default']);
|
||||
|
||||
// change all of the keys to lowercase
|
||||
$myConfig = array_change_key_case($myConfig);
|
||||
|
||||
// compile data
|
||||
$retval = sprintf("<?php\n".
|
||||
"// auto-generated by sfSecurityConfigHandler\n".
|
||||
"// date: %s\n\$this->security = %s;\n",
|
||||
date('Y/m/d H:i:s'), var_export($myConfig, true));
|
||||
|
||||
return $retval;
|
||||
}
|
||||
}
|
||||
544
plugins/stThemePlugin/lib/stTheme.class.php
Normal file
544
plugins/stThemePlugin/lib/stTheme.class.php
Normal file
@@ -0,0 +1,544 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SOTESHOP/stThemePlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stThemePlugin opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stThemePlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
|
||||
* @version $Id: stTheme.class.php 653 2009-04-16 06:18:48Z michal $
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa obsługująca tematy w aplikacji frontend
|
||||
*
|
||||
* @package stThemePlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stTheme
|
||||
{
|
||||
|
||||
protected
|
||||
$context,
|
||||
$response,
|
||||
$theme = null,
|
||||
$baseTheme = null,
|
||||
$layoutName,
|
||||
$cssDir = null,
|
||||
$stylesheetPath = array(),
|
||||
$layoutConfig = array();
|
||||
protected static $pluginModulePaths = null;
|
||||
protected static $instance = null;
|
||||
protected static $hideOldConfiguration = null;
|
||||
|
||||
/**
|
||||
* Zwraca instancje obiektu
|
||||
*
|
||||
* @param sfContext $context
|
||||
*
|
||||
* @return stTheme object
|
||||
*/
|
||||
public static function getInstance(sfContext $context)
|
||||
{
|
||||
if (!isset(self::$instance))
|
||||
{
|
||||
$class = __CLASS__;
|
||||
self::$instance = new $class();
|
||||
self::$instance->initialize($context);
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicjalizuje podstawową konfigurację tematu
|
||||
*
|
||||
* @param string $context
|
||||
*/
|
||||
public function initialize(sfContext $context)
|
||||
{
|
||||
$this->layoutConfig = array();
|
||||
|
||||
$this->cssDir = sfConfig::get('sf_web_dir') . '/' . 'css';
|
||||
|
||||
$this->context = $context;
|
||||
|
||||
$this->response = $context->getResponse();
|
||||
|
||||
if (SF_ENVIRONMENT == 'theme')
|
||||
{
|
||||
if ($this->context->getRequest()->hasParameter('theme'))
|
||||
{
|
||||
$this->context->getUser()->setAttribute('name', $this->context->getRequest()->getParameter('theme'), 'soteshop/stTheme');
|
||||
}
|
||||
|
||||
$theme_name = $this->context->getUser()->getAttribute('name', null, 'soteshop/stTheme');
|
||||
|
||||
if ($theme_name)
|
||||
{
|
||||
$this->setThemeName($theme_name);
|
||||
}
|
||||
}
|
||||
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($this, 'stTheme.setDefaulTheme'));
|
||||
}
|
||||
|
||||
public function getActionName()
|
||||
{
|
||||
return $this->context->getActionName();
|
||||
}
|
||||
|
||||
public function getModuleName()
|
||||
{
|
||||
return $this->context->getModuleName();
|
||||
}
|
||||
|
||||
public function getVersion()
|
||||
{
|
||||
return $this->getTheme()->getVersion();
|
||||
}
|
||||
|
||||
public function hasThemeContent($id)
|
||||
{
|
||||
return $this->getTheme()->hasThemeContent($id);
|
||||
}
|
||||
|
||||
public function getThemeContent($id, $default = null)
|
||||
{
|
||||
return $this->getTheme()->getThemeContent($id, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera aktywny obiekt tematu
|
||||
*
|
||||
* @return Theme
|
||||
*/
|
||||
public function getTheme()
|
||||
{
|
||||
if (null === $this->theme)
|
||||
{
|
||||
$this->theme = self::getActiveTheme();
|
||||
}
|
||||
|
||||
return $this->theme;
|
||||
}
|
||||
|
||||
public function setTheme(Theme $theme)
|
||||
{
|
||||
$this->theme = $theme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pobiera aktywny obiekt tematu
|
||||
*
|
||||
* @return Theme
|
||||
*/
|
||||
public static function getActiveTheme()
|
||||
{
|
||||
$theme = null;
|
||||
|
||||
$request = sfContext::getInstance()->getRequest();
|
||||
|
||||
if (MobileDetect::getInstance()->isMobile() || $request->getParameter('mobile') && defined('ST_FAST_CACHE_SAVE_MODE') && ST_FAST_CACHE_SAVE_MODE)
|
||||
{
|
||||
$id = stConfig::getInstance('stThemeBackend')->get('responsive');
|
||||
|
||||
if ($id)
|
||||
{
|
||||
$theme = ThemePeer::retrieveByPKCached($id);
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $theme)
|
||||
{
|
||||
$theme = ThemePeer::doSelectActive();
|
||||
}
|
||||
|
||||
return $theme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca aktualnie ustawiony tematu
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getThemeName()
|
||||
{
|
||||
return $this->getTheme()->getTheme();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ustawia temat
|
||||
*
|
||||
* @param string $name Nazwa tematu
|
||||
*/
|
||||
public function setThemeName($name)
|
||||
{
|
||||
$theme = ThemePeer::doSelectByName($name);
|
||||
|
||||
if (null === $theme)
|
||||
{
|
||||
$theme = new Theme();
|
||||
|
||||
$theme->setName($name);
|
||||
}
|
||||
|
||||
$this->setTheme($theme);
|
||||
}
|
||||
|
||||
public function getBaseTheme()
|
||||
{
|
||||
if (null === $this->baseTheme)
|
||||
{
|
||||
$this->baseTheme = $this->getTheme()->getBaseTheme();
|
||||
}
|
||||
|
||||
return $this->baseTheme;
|
||||
}
|
||||
|
||||
public function setBaseTheme(Theme $theme)
|
||||
{
|
||||
$this->baseTheme = $theme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ustawia podstawy temat
|
||||
*
|
||||
* @param string $theme
|
||||
*/
|
||||
public function setDefaultThemeName($name)
|
||||
{
|
||||
$theme = ThemePeer::doSelectByName($name);
|
||||
|
||||
if (null === $theme)
|
||||
{
|
||||
$theme = new Theme();
|
||||
|
||||
$theme->setName($name);
|
||||
}
|
||||
|
||||
$this->setBaseTheme($theme);
|
||||
}
|
||||
|
||||
public function getThemeColorScheme()
|
||||
{
|
||||
return $this->getTheme()->getColorScheme();
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca nazwe podstawowego tematu
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultThemeName()
|
||||
{
|
||||
return $this->getBaseTheme() ? $this->getBaseTheme()->getName() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ustawia układ strony
|
||||
*
|
||||
* @param string $layout Nazwa układu strony (bez rozszerzenia .html)
|
||||
*/
|
||||
public function setLayoutName($layout)
|
||||
{
|
||||
$this->layoutName = $layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca aktualnie ustawiony układ strony
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLayoutName()
|
||||
{
|
||||
return $this->layoutName;
|
||||
}
|
||||
|
||||
public function getThemeDir()
|
||||
{
|
||||
|
||||
return 'frontend/theme/' . $this->getThemeName();
|
||||
}
|
||||
|
||||
public function getThemeColorSchemeDir()
|
||||
{
|
||||
return $this->getThemeDir() . '/' . $this->getThemeColorScheme();
|
||||
}
|
||||
|
||||
public function getDefaultThemeDir()
|
||||
{
|
||||
return 'frontend/theme/' . $this->getDefaultThemeName();
|
||||
}
|
||||
|
||||
public function getTemplateDir($module = null)
|
||||
{
|
||||
return sfLoader::getTemplateDir($module ? $module : $this->context->getModuleName(), null) . '/' . 'theme';
|
||||
}
|
||||
|
||||
public function getStylesheetPaths($stylesheet)
|
||||
{
|
||||
if (!isset($this->stylesheetPath[$stylesheet]))
|
||||
{
|
||||
$stylesheet_path = $this->getStylesheetPath($stylesheet);
|
||||
|
||||
if ($stylesheet_path)
|
||||
{
|
||||
$this->stylesheetPath[$stylesheet]['default'] = $stylesheet_path;
|
||||
|
||||
$stylesheet_path = $this->getStylesheetPath('my_' . $stylesheet);
|
||||
|
||||
if ($stylesheet_path)
|
||||
{
|
||||
$this->stylesheetPath[$stylesheet]['my'] = $stylesheet_path;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->stylesheetPath[$stylesheet] = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->stylesheetPath[$stylesheet];
|
||||
}
|
||||
|
||||
public function addStylesheet($stylesheet, $position = '', $options = array())
|
||||
{
|
||||
$stylesheet_path = $this->getStylesheetPaths($stylesheet);
|
||||
|
||||
if ($stylesheet_path)
|
||||
{
|
||||
$this->response->addStylesheet($stylesheet_path['default'], $position, $options);
|
||||
|
||||
if (isset($stylesheet_path['my']))
|
||||
{
|
||||
$this->response->addStylesheet($stylesheet_path['my'], $position, $options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addLess($less, $position = '')
|
||||
{
|
||||
$less_path = $this->getStylesheetPaths($less);
|
||||
|
||||
if ($less_path)
|
||||
{
|
||||
$this->response->setParameter($less_path['default'], array(), 'helper/asset/auto/less' . ($position ? '/' . $position : ''));
|
||||
|
||||
if (isset($less_path['my']))
|
||||
{
|
||||
$this->response->setParameter($less_path['my'], array(), 'helper/asset/auto/less' . ($position ? '/' . $position : ''));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stylesheet path
|
||||
* @param string $stylesheet
|
||||
* @return string stylesheet path
|
||||
*/
|
||||
protected function getStylesheetPath($stylesheet)
|
||||
{
|
||||
return $this->findStylesheetPath($this->getTheme(), $stylesheet);
|
||||
}
|
||||
|
||||
protected function findStylesheetPath(Theme $theme, $stylesheet)
|
||||
{
|
||||
if ($theme->getVersion() < 2 && $theme->getColorScheme() && is_readable($this->cssDir . '/' . $theme->getThemeColorSchemeDir() . '/' . $stylesheet))
|
||||
{
|
||||
return $theme->getThemeColorSchemeDir() . '/' . $stylesheet;
|
||||
}
|
||||
elseif (is_readable($this->cssDir . '/' . $theme->getThemeDir() . '/' . $stylesheet))
|
||||
{
|
||||
return $theme->getThemeDir() . '/' . $stylesheet;
|
||||
}
|
||||
elseif ($theme->hasBaseTheme())
|
||||
{
|
||||
return $this->findStylesheetPath($theme->getBaseTheme(), $stylesheet);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dodaje plik CSS ktory zostanie zalaczony podczas wyświetlania strony
|
||||
*
|
||||
* @param string $stylesheet Nazwa pliku css umieszczonego w katalogu 'frontend/theme/nazwa_tematu'
|
||||
*/
|
||||
public static function useStylesheet($stylesheet, $position = '', $options = array())
|
||||
{
|
||||
$context = sfContext::getInstance();
|
||||
|
||||
$theme = stTheme::getInstance($context);
|
||||
|
||||
$theme->addStylesheet($stylesheet, $position, $options);
|
||||
}
|
||||
|
||||
public static function getImagePath($image, $current = null)
|
||||
{
|
||||
static $processed = array();
|
||||
|
||||
static $theme = null;
|
||||
|
||||
if (!isset($processed[$image]))
|
||||
{
|
||||
if (null === $theme)
|
||||
{
|
||||
$context = sfContext::getInstance();
|
||||
|
||||
$theme = stTheme::getInstance($context);
|
||||
}
|
||||
|
||||
$instance = $current ? $current : $theme->getTheme();
|
||||
|
||||
$processed[$image] = $theme->findImagePath($instance, $image, !$instance->hasImage($image));
|
||||
}
|
||||
|
||||
return $processed[$image];
|
||||
}
|
||||
|
||||
public function findImagePath(Theme $theme, $image, $default = false)
|
||||
{
|
||||
if ($theme->getVersion() < 2 && $theme->getColorScheme() && is_readable(sfConfig::get('sf_web_dir') . '/images/' . $theme->getThemeColorSchemeDir() . '/' . $image))
|
||||
{
|
||||
return $theme->getThemeColorSchemeDir() . '/' . $image;
|
||||
}
|
||||
elseif (is_readable($theme->getImagePath($image, true, $default)))
|
||||
{
|
||||
return $theme->getImagePath($image, false, $default);
|
||||
}
|
||||
elseif ($theme->hasBaseTheme())
|
||||
{
|
||||
return $this->findImagePath($theme->getBaseTheme(), $image, $default);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function clearCache($clear_fast_cache = true)
|
||||
{
|
||||
$fc = new stFunctionCache('stThemePlugin');
|
||||
|
||||
$fc->removeAll();
|
||||
|
||||
if ($clear_fast_cache)
|
||||
{
|
||||
stFastCacheManager::clearCache();
|
||||
}
|
||||
}
|
||||
|
||||
public static function clearAssetsCache()
|
||||
{
|
||||
stWebFileManager::getInstance()->remove(sfConfig::get('sf_web_dir').'/cache/css');
|
||||
|
||||
stWebFileManager::getInstance()->remove(sfConfig::get('sf_web_dir').'/cache/less');
|
||||
}
|
||||
|
||||
public static function clearEditorCache()
|
||||
{
|
||||
self::clearCache(false);
|
||||
|
||||
stWebFileManager::getInstance()->remove(sfConfig::get('sf_web_dir').'/cache/css/_editor');
|
||||
|
||||
stWebFileManager::getInstance()->remove(sfConfig::get('sf_web_dir').'/cache/less/_editor');
|
||||
}
|
||||
|
||||
public static function clearSmartyCache($all = false)
|
||||
{
|
||||
if ($all)
|
||||
{
|
||||
$name = '*';
|
||||
}
|
||||
else
|
||||
{
|
||||
$name = stTheme::getInstance(sfContext::getInstance())->getThemeName();
|
||||
}
|
||||
|
||||
foreach (glob(sfConfig::get('sf_root_dir').'/cache/smarty_c/'.$name.'/*') as $file)
|
||||
{
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ustawia domyślny temat w sklepie
|
||||
*
|
||||
* @param string $name Nazwa tematu
|
||||
* @param boolean $isResponsive Ustawia dodatkowo temat jako responsywny
|
||||
* @return Theme
|
||||
*/
|
||||
public static function setActiveTheme(string $name, bool $isResponsive = true): Theme
|
||||
{
|
||||
$theme = ThemePeer::doSelectByName($name);
|
||||
|
||||
if (null === $theme)
|
||||
{
|
||||
throw new Exception("Theme '$name' does not exists.");
|
||||
}
|
||||
|
||||
$theme->setIsResponsive($isResponsive);
|
||||
$theme->setActive(true);
|
||||
$theme->save();
|
||||
|
||||
ThemePeer::updateThemeImageConfiguration($theme);
|
||||
|
||||
return $theme;
|
||||
}
|
||||
|
||||
public static function is_responsive()
|
||||
{
|
||||
$themeVersion = stTheme::getInstance(sfContext::getInstance())->getTheme()->getVersion();
|
||||
|
||||
if($themeVersion >= 7){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function hideOldConfiguration()
|
||||
{
|
||||
if (null === self::$hideOldConfiguration)
|
||||
{
|
||||
$theme = ThemePeer::doSelectActive();
|
||||
|
||||
$mobile = null;
|
||||
|
||||
$id = stConfig::getInstance('stThemeBackend')->get('responsive');
|
||||
|
||||
if ($id)
|
||||
{
|
||||
$mobile = ThemePeer::retrieveByPKCached($id);
|
||||
}
|
||||
|
||||
self::$hideOldConfiguration = $theme->getVersion() >= 7 && (!$mobile || $mobile->getVersion() >= 7);
|
||||
}
|
||||
|
||||
return self::$hideOldConfiguration;
|
||||
}
|
||||
|
||||
public static function is_theme8()
|
||||
{
|
||||
$themeVersion = stTheme::getInstance(sfContext::getInstance())->getTheme()->getVersion();
|
||||
|
||||
if($themeVersion >= 8){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function activeThemeName()
|
||||
{
|
||||
$themeName = stTheme::getInstance(sfContext::getInstance())->getThemeName();
|
||||
return $themeName;
|
||||
}
|
||||
}
|
||||
111
plugins/stThemePlugin/lib/stThemeConfigHandler.class.php
Normal file
111
plugins/stThemePlugin/lib/stThemeConfigHandler.class.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stThemePlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stThemePlugin opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stThemePlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
|
||||
* @version $Id: stThemeConfigHandler.class.php 256 2009-03-30 11:49:45Z marek $
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa odpowiadająca za generowanie konfiguracji dla tematów
|
||||
*
|
||||
* @package stThemePlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stThemeConfigHandler extends sfYamlConfigHandler
|
||||
{
|
||||
public function execute($configFiles)
|
||||
{
|
||||
$prefix = strtolower($this->getParameterHolder()->get('prefix', ''));
|
||||
|
||||
$theme = stTheme::getInstance(sfContext::getInstance());
|
||||
|
||||
$data = array();
|
||||
|
||||
$myConfig = $this->parseYamls($configFiles);
|
||||
|
||||
$myConfig = sfToolkit::arrayDeepMerge(
|
||||
isset($myConfig['default']) && is_array($myConfig['default']) ? $myConfig['default'] : array(),
|
||||
isset($myConfig['all']) && is_array($myConfig['all']) ? $myConfig['all'] : array(),
|
||||
isset($myConfig[sfConfig::get('sf_environment')]) && is_array($myConfig[sfConfig::get('sf_environment')]) ? $myConfig[sfConfig::get('sf_environment')] : array()
|
||||
);
|
||||
|
||||
if (isset($myConfig['.view']))
|
||||
{
|
||||
if (isset($myConfig['.view']['default_theme']))
|
||||
{
|
||||
$data[] = sprintf("\$this->setDefaultThemeName('%s');", $myConfig['.view']['default_theme']);
|
||||
}
|
||||
|
||||
if (isset($myConfig['.view']['theme']))
|
||||
{
|
||||
$data[] = sprintf("\$this->setThemeName('%s');", $myConfig['.view']['theme']);
|
||||
}
|
||||
}
|
||||
elseif (!isset($myConfig['.layout']))
|
||||
{
|
||||
$data[] = sprintf('$layout = %s;', var_export($myConfig, true));
|
||||
|
||||
$data[] = '$current_layout = isset($layout[$this->getActionName()]) ? $layout[$this->getActionName()] : $layout[\'default\'];';
|
||||
|
||||
$data[] = 'if (isset($current_layout[\'layout_name\'])) {';
|
||||
|
||||
$data[] = '$this->setLayoutName($current_layout[\'layout_name\']);';
|
||||
|
||||
$data[] = '} elseif (isset($layout[\'default\'][\'layout_name\'])) {';
|
||||
|
||||
$data[] = '$this->setLayoutName($layout[\'default\'][\'layout_name\']);';
|
||||
|
||||
$data[] = '}';
|
||||
|
||||
$data[] = 'if (isset($current_layout[\'layout_containers\'])) {';
|
||||
|
||||
$data[] = '$this->setLayoutConfig($current_layout[\'layout_containers\']);';
|
||||
|
||||
$data[] = '} elseif (isset($layout[\'default\'][\'layout_containers\'])) {';
|
||||
|
||||
$data[] = '$this->setLayoutConfig($layout[\'default\'][\'layout_containers\']);';
|
||||
|
||||
$data[] = '}';
|
||||
}
|
||||
else
|
||||
{
|
||||
$data[] = '$layout = array();';
|
||||
|
||||
foreach ($myConfig['.layout'] as $key => $value)
|
||||
{
|
||||
if ($key == 'name')
|
||||
{
|
||||
$data[] = '$this->setLayoutName(\''.$value.'\');';
|
||||
}
|
||||
else
|
||||
{
|
||||
$data[] = '$layout[\''.$key.'\'] = ' . var_export($value, true) . ';';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$data[] = '$this->setLayoutConfig($layout);';
|
||||
}
|
||||
|
||||
|
||||
// compile data
|
||||
$retval = sprintf("<?php\n".
|
||||
"// auto-generated by stThemeConfigHandler\n".
|
||||
"// date: %s\n%s\n",
|
||||
date('Y/m/d H:i:s'),
|
||||
implode("\n", $data)
|
||||
);
|
||||
|
||||
return $retval;
|
||||
}
|
||||
}
|
||||
88
plugins/stThemePlugin/lib/stThemeDownloader.class.php
Normal file
88
plugins/stThemePlugin/lib/stThemeDownloader.class.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
$pearlib = SF_ROOT_DIR.DIRECTORY_SEPARATOR.'pear'.DIRECTORY_SEPARATOR.'php';
|
||||
if (is_dir($pearlib)) ini_set('include_path', '.:'.$pearlib.':'.ini_get('include_path'));
|
||||
|
||||
include('Archive'.DIRECTORY_SEPARATOR.'Tar.php');
|
||||
|
||||
class stThemeDownloader {
|
||||
|
||||
protected $themeName = null;
|
||||
|
||||
protected $stFile = null;
|
||||
|
||||
public function __construct($themeName)
|
||||
{
|
||||
$this->themeName = $themeName;
|
||||
$this->themeCopyPath = sfConfig::get('sf_cache_dir').DIRECTORY_SEPARATOR.'themePackage'.DIRECTORY_SEPARATOR.$this->themeName;
|
||||
$this->stFile = new stFile();
|
||||
}
|
||||
|
||||
public function makePackage()
|
||||
{
|
||||
$this->prepareDirectory();
|
||||
$this->copyFiles();
|
||||
$this->archive();
|
||||
}
|
||||
|
||||
protected function prepareDirectory()
|
||||
{
|
||||
if(file_exists($this->themeCopyPath)) $this->stFile->rmdir($this->themeCopyPath);
|
||||
$this->stFile->mkdir($this->themeCopyPath);
|
||||
}
|
||||
|
||||
protected function copyFiles()
|
||||
{
|
||||
$update_log_theme = SF_ROOT_DIR.DIRECTORY_SEPARATOR.'log'.DIRECTORY_SEPARATOR.$this->themeName.'.plugin';
|
||||
$css = glob(sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.'css'.DIRECTORY_SEPARATOR.'frontend'.DIRECTORY_SEPARATOR.'theme'.DIRECTORY_SEPARATOR.$this->themeName.DIRECTORY_SEPARATOR.'*');
|
||||
$images = glob(sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'frontend'.DIRECTORY_SEPARATOR.'theme'.DIRECTORY_SEPARATOR.$this->themeName.DIRECTORY_SEPARATOR.'*');
|
||||
$templates = glob(sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.'frontend'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.'theme'.DIRECTORY_SEPARATOR.$this->themeName.DIRECTORY_SEPARATOR.'*');
|
||||
$modules = glob(sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.'frontend'.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.'theme'.DIRECTORY_SEPARATOR.$this->themeName.DIRECTORY_SEPARATOR.'*');
|
||||
$plugins = glob(sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'*'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.'theme'.DIRECTORY_SEPARATOR.$this->themeName.DIRECTORY_SEPARATOR.'*');
|
||||
$config = sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'_editor'.DIRECTORY_SEPARATOR.$this->themeName.'.conf';
|
||||
$configTheme = sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'theme'.DIRECTORY_SEPARATOR.$this->themeName.'.yml';
|
||||
|
||||
$duplicate = '';
|
||||
$update = '';
|
||||
if (file_exists($update_log_theme)) {
|
||||
$pluginName = file_get_contents($update_log_theme);
|
||||
$duplicate = sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'duplicate'.DIRECTORY_SEPARATOR.$pluginName.DIRECTORY_SEPARATOR.'stPackageDuplicate.class.php';
|
||||
$update = sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.'data'.DIRECTORY_SEPARATOR.'update'.DIRECTORY_SEPARATOR.$pluginName.'.php';
|
||||
}
|
||||
|
||||
$files = array_merge( (is_array($css))?$css:array(),
|
||||
(is_array($images))?$images:array(),
|
||||
(is_array($templates))?$templates:array(),
|
||||
(is_array($modules))?$modules:array(),
|
||||
(is_array($plugins))?$plugins:array(),
|
||||
array($config,$configTheme,$duplicate,$update));
|
||||
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (file_exists($file)) $this->stFile->copy($file, $this->themeCopyPath.(str_replace(sfConfig::get('sf_root_dir'), '', $file)));
|
||||
}
|
||||
}
|
||||
|
||||
protected function archive()
|
||||
{
|
||||
$files = glob($this->themeCopyPath.DIRECTORY_SEPARATOR.'*');
|
||||
|
||||
$tmpFiles = $files;
|
||||
$files = array();
|
||||
foreach ($tmpFiles as $file) $files[] = str_replace($this->themeCopyPath.DIRECTORY_SEPARATOR, '', $file);
|
||||
|
||||
$cwd = getcwd();
|
||||
chdir($this->themeCopyPath);
|
||||
|
||||
$archive = new Archive_Tar($this->getPackagePath(), true);
|
||||
$archive->create($files);
|
||||
|
||||
chdir($cwd);
|
||||
|
||||
$this->stFile->rmdir($this->themeCopyPath);
|
||||
}
|
||||
|
||||
public function getPackagePath()
|
||||
{
|
||||
return $this->themeCopyPath.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$this->themeName.'.tgz';
|
||||
}
|
||||
}
|
||||
146
plugins/stThemePlugin/lib/stThemeLess.class.php
Normal file
146
plugins/stThemePlugin/lib/stThemeLess.class.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
class stThemeLess
|
||||
{
|
||||
|
||||
public static function darken($color, $delta)
|
||||
{
|
||||
$hsl = self::toHSL(self::hexToRgb($color));
|
||||
$hsl[3] = self::clamp($hsl[3] - floatval($delta), 100);
|
||||
return self::rgbToHex(self::toRGB($hsl));
|
||||
}
|
||||
|
||||
public static function lighten($color, $delta)
|
||||
{
|
||||
$hsl = self::toHSL(self::hexToRgb($color));
|
||||
$hsl[3] = self::clamp($hsl[3] + floatval($delta), 100);
|
||||
return self::rgbToHex(self::toRGB($hsl));
|
||||
}
|
||||
|
||||
public static function hexToRgb($hex)
|
||||
{
|
||||
$color = array();
|
||||
|
||||
$hex = ltrim($hex, '#');
|
||||
|
||||
if (strlen($hex) == 3)
|
||||
{
|
||||
$color[1] = hexdec(substr($hex, 0, 1) . $r);
|
||||
$color[2] = hexdec(substr($hex, 1, 1) . $g);
|
||||
$color[3] = hexdec(substr($hex, 2, 1) . $b);
|
||||
}
|
||||
else if (strlen($hex) == 6)
|
||||
{
|
||||
$color[1] = hexdec(substr($hex, 0, 2));
|
||||
$color[2] = hexdec(substr($hex, 2, 2));
|
||||
$color[3] = hexdec(substr($hex, 4, 2));
|
||||
}
|
||||
|
||||
return $color;
|
||||
}
|
||||
|
||||
public static function rgbToHex($color)
|
||||
{
|
||||
$hex = "#";
|
||||
$hex.= str_pad(dechex($color[1]), 2, "0", STR_PAD_LEFT);
|
||||
$hex.= str_pad(dechex($color[2]), 2, "0", STR_PAD_LEFT);
|
||||
$hex.= str_pad(dechex($color[3]), 2, "0", STR_PAD_LEFT);
|
||||
|
||||
return $hex;
|
||||
}
|
||||
|
||||
protected static function toHSL($color)
|
||||
{
|
||||
$r = $color[1] / 255;
|
||||
$g = $color[2] / 255;
|
||||
$b = $color[3] / 255;
|
||||
|
||||
$min = min($r, $g, $b);
|
||||
$max = max($r, $g, $b);
|
||||
|
||||
$L = ($min + $max) / 2;
|
||||
if ($min == $max)
|
||||
{
|
||||
$S = $H = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($L < 0.5)
|
||||
$S = ($max - $min) / ($max + $min);
|
||||
else
|
||||
$S = ($max - $min) / (2.0 - $max - $min);
|
||||
|
||||
if ($r == $max)
|
||||
$H = ($g - $b) / ($max - $min);
|
||||
elseif ($g == $max)
|
||||
$H = 2.0 + ($b - $r) / ($max - $min);
|
||||
elseif ($b == $max)
|
||||
$H = 4.0 + ($r - $g) / ($max - $min);
|
||||
}
|
||||
|
||||
$out = array('hsl',
|
||||
($H < 0 ? $H + 6 : $H) * 60,
|
||||
$S * 100,
|
||||
$L * 100,
|
||||
);
|
||||
|
||||
if (count($color) > 4)
|
||||
$out[] = $color[4]; // copy alpha
|
||||
return $out;
|
||||
}
|
||||
|
||||
protected static function toRGBHelper($comp, $temp1, $temp2)
|
||||
{
|
||||
if ($comp < 0)
|
||||
$comp += 1.0;
|
||||
elseif ($comp > 1)
|
||||
$comp -= 1.0;
|
||||
|
||||
if (6 * $comp < 1)
|
||||
return $temp1 + ($temp2 - $temp1) * 6 * $comp;
|
||||
if (2 * $comp < 1)
|
||||
return $temp2;
|
||||
if (3 * $comp < 2)
|
||||
return $temp1 + ($temp2 - $temp1) * ((2 / 3) - $comp) * 6;
|
||||
|
||||
return $temp1;
|
||||
}
|
||||
|
||||
protected static function toRGB($color)
|
||||
{
|
||||
if ($color == 'color')
|
||||
return $color;
|
||||
|
||||
$H = $color[1] / 360;
|
||||
$S = $color[2] / 100;
|
||||
$L = $color[3] / 100;
|
||||
|
||||
if ($S == 0)
|
||||
{
|
||||
$r = $g = $b = $L;
|
||||
}
|
||||
else
|
||||
{
|
||||
$temp2 = $L < 0.5 ?
|
||||
$L * (1.0 + $S) :
|
||||
$L + $S - $L * $S;
|
||||
|
||||
$temp1 = 2.0 * $L - $temp2;
|
||||
|
||||
$r = self::toRGBHelper($H + 1 / 3, $temp1, $temp2);
|
||||
$g = self::toRGBHelper($H, $temp1, $temp2);
|
||||
$b = self::toRGBHelper($H - 1 / 3, $temp1, $temp2);
|
||||
}
|
||||
|
||||
$out = array('color', round($r * 255), round($g * 255), round($b * 255));
|
||||
if (count($color) > 4)
|
||||
$out[] = $color[4]; // copy alpha
|
||||
return $out;
|
||||
}
|
||||
|
||||
protected static function clamp($v, $max = 1, $min = 0)
|
||||
{
|
||||
return min($max, max($min, $v));
|
||||
}
|
||||
|
||||
}
|
||||
24
plugins/stThemePlugin/lib/stThemeListener.class.php
Normal file
24
plugins/stThemePlugin/lib/stThemeListener.class.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
class stThemeListener
|
||||
{
|
||||
public static function validate(sfEvent $event)
|
||||
{
|
||||
$action = $event->getSubject();
|
||||
|
||||
if (SF_ENVIRONMENT == 'edit' && $action->getController()->getTheme()->getVersion() >= 2)
|
||||
{
|
||||
$action->redirect('http://'.$action->getRequest()->getHost().'/backend.php');
|
||||
}
|
||||
}
|
||||
|
||||
public static function postExecute(sfEvent $event)
|
||||
{
|
||||
$action = $event->getSubject();
|
||||
|
||||
if ($action->getModuleName() == 'appTaggableBackend' && $action->getActionName() == 'saveConfig')
|
||||
{
|
||||
stTheme::clearSmartyCache(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
454
plugins/stThemePlugin/lib/stThemeView.php
Normal file
454
plugins/stThemePlugin/lib/stThemeView.php
Normal file
@@ -0,0 +1,454 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SOTESHOP/stThemePlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stThemePlugin opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stThemePlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
|
||||
* @version $Id: stThemeView.php 653 2009-04-16 06:18:48Z michal $
|
||||
* @author Marcin Butlak <marcin.butlak@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa rozszerzająca warstwę view dla stTheme
|
||||
*
|
||||
* @package stThemePlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stThemeView extends sfPHPView
|
||||
{
|
||||
|
||||
protected $theme = null;
|
||||
|
||||
protected $themeMode;
|
||||
|
||||
protected $themeCulture;
|
||||
|
||||
protected $themeReturnUrl;
|
||||
|
||||
public function initialize($context, $moduleName, $actionName, $viewName)
|
||||
{
|
||||
$this->themeMode = SF_ENVIRONMENT == 'theme' && $context->getUser()->isAuthenticated() && $context->getUser()->hasCredential('stThemeBackend.modification');
|
||||
|
||||
if (SF_ENVIRONMENT == 'theme') {
|
||||
$referer = $context->getRequest()->getReferer();
|
||||
|
||||
if (strpos($referer, 'backend.php') !== false || strpos($referer, 'backend_dev.php') !== false) {
|
||||
$context->getUser()->setAttribute('return_url', $referer, 'stThemePlugin');
|
||||
}
|
||||
|
||||
if ($context->getRequest()->hasParameter('theme_culture')) {
|
||||
$context->getUser()->setAttribute('culture', $context->getRequest()->getParameter('theme_culture'), 'stThemePlugin');
|
||||
}
|
||||
|
||||
$this->themeReturnUrl = $context->getUser()->getAttribute('return_url', '/backend.php', 'stThemePlugin');
|
||||
|
||||
$this->themeCulture = $context->getUser()->getAttribute('culture', stLanguage::getOptLanguage(), 'stThemePlugin');
|
||||
}
|
||||
|
||||
parent::initialize($context, $moduleName, $actionName, $viewName);
|
||||
|
||||
if (stConfig::getInstance('stThemeBackend')->get('responsive_vary')) {
|
||||
$this->context->getResponse()->addVaryHttpHeader('User-Agent');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca instancję obiektu stTheme
|
||||
*
|
||||
* @return stTheme
|
||||
*/
|
||||
public function getTheme()
|
||||
{
|
||||
if (null === $this->theme) {
|
||||
$this->theme = $this->context->getController()->getTheme();
|
||||
}
|
||||
|
||||
return $this->theme;
|
||||
}
|
||||
|
||||
public function hasThemeMode()
|
||||
{
|
||||
return $this->themeMode;
|
||||
}
|
||||
|
||||
public function smartyIncludeStylesheets($params, &$smarty)
|
||||
{
|
||||
if ($this->themeMode) {
|
||||
echo minify_get_stylesheets($this->context->getResponse(), isset($params['minify']) && $params['minify'] == 'true', 'cache/css/_editor');
|
||||
} else {
|
||||
echo minify_get_stylesheets($this->context->getResponse(), isset($params['minify']) && $params['minify'] == 'true');
|
||||
}
|
||||
|
||||
if (SF_ENVIRONMENT == 'theme') {
|
||||
echo '<link rel="stylesheet" type="text/css" media="screen" href="/css/frontend/stSmartyPlugin.css?v1" />';
|
||||
echo '<link rel="stylesheet" type="text/css" media="screen" href="/css/frontend/stThemeEditor.css?v1" />';
|
||||
echo '<link rel="stylesheet" type="text/css" media="screen" href="/css/backend/stTinyMCEPlugin.css?v1" />';
|
||||
}
|
||||
}
|
||||
|
||||
public function smartyIncludeJavascripts($params, &$smarty)
|
||||
{
|
||||
|
||||
echo minify_get_javascripts($this->context->getResponse(), isset($params['minify']) && $params['minify'] == 'true');
|
||||
|
||||
if ($this->themeMode) {
|
||||
echo '<script type="text/javascript" src="/js/tinymce/tinymce.min.js?v427"></script>';
|
||||
echo '<script type="text/javascript" src="/js/jquery-ui-1.8.20.custom.min.js"></script>';
|
||||
echo '<script type="text/javascript" src="/js/showEditContent.js"></script>';
|
||||
echo '<script type="text/javascript" src="/js/jquery.cookie.js"></script>';
|
||||
} elseif (SF_ENVIRONMENT == 'theme') {
|
||||
$i18n = $this->context->getI18N();
|
||||
|
||||
$i18n->setCulture($this->themeCulture);
|
||||
|
||||
$request = $this->context->getRequest();
|
||||
|
||||
$login_label = $i18n->__('Użytkownik', null, 'stThemeFrontend');
|
||||
|
||||
$password_label = $i18n->__('Hasło', null, 'stThemeFrontend');
|
||||
|
||||
$login_title = $i18n->__('Logowanie do zarządzania tematami', null, 'stThemeFrontend');
|
||||
|
||||
$button_label = $i18n->__('Zaloguj się', null, 'stThemeFrontend');
|
||||
|
||||
$error_message = $i18n->__($request->getError('theme_login'), null, 'stThemeFrontend');
|
||||
|
||||
$login = $request->getParameter('theme_login[login]');
|
||||
|
||||
$login_url = $this->context->getController()->genUrl('stSmartyFrontend/login');
|
||||
|
||||
$return_label = $i18n->__('Powrót', null, 'stThemeFrontend');
|
||||
|
||||
$i18n->setCulture($this->context->getUser()->getCulture());
|
||||
|
||||
|
||||
if ($this->getTheme()->getVersion() < 7) {
|
||||
$js = <<<JS
|
||||
jQuery(function($) {
|
||||
var login = $('<div class="smarty_popup_window" id="smarty_login_form">\
|
||||
<div class="smarty_popup_container">\
|
||||
<h2>$login_title</h2>\
|
||||
<div class="content">\
|
||||
<form action="$login_url" method="post">\
|
||||
<div class="form-row">\
|
||||
<label for="theme_login_login">$login_label:</label><br />\
|
||||
<input type="text" name="theme_login[login]" value="$login" id="theme_login_login" />\
|
||||
<div class="form_error">$error_message</div>\
|
||||
</div>\
|
||||
<div class="form-row">\
|
||||
<label for="theme_login_password">$password_label:</label><br />\
|
||||
<input type="password" name="theme_login[password]" id="theme_login_password" />\
|
||||
</div>\
|
||||
<div class="form-row smarty_button">\
|
||||
<button class="right" type="submit">$button_label</button>\
|
||||
<a href="$this->themeReturnUrl">$return_label</a>\
|
||||
<div class="clr"></div>\
|
||||
</div>\
|
||||
</form>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>');
|
||||
|
||||
$('body').prepend(login);
|
||||
|
||||
login.overlay({
|
||||
closeOnClick: false,
|
||||
closeOnEsc: false,
|
||||
top: '34%',
|
||||
speed: 'fast',
|
||||
mask: {
|
||||
color: '#444',
|
||||
loadSpeed: 'fast',
|
||||
opacity: 0.5,
|
||||
zIndex: 30000
|
||||
},
|
||||
load: true,
|
||||
onBeforeLoad: function() {
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
JS;
|
||||
} else {
|
||||
$js = <<<JS
|
||||
jQuery(function($) {
|
||||
var login = $('<div class="modal fade" id="myModal" tabindex="-1">\
|
||||
<div class="modal-dialog">\
|
||||
<div class="modal-content">\
|
||||
<div class="modal-header">\
|
||||
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>\
|
||||
<h4 class="modal-title">$login_title</h4>\
|
||||
</div>\
|
||||
<div class="modal-body">\
|
||||
<form action="$login_url" method="post">\
|
||||
<div class="form-group">\
|
||||
<label for="theme_login_login">$login_label:</label>\
|
||||
<input class="form-control" type="text" name="theme_login[login]" value="$login" id="theme_login_login" />\
|
||||
</div>\
|
||||
<div class="form-group">\
|
||||
<label for="theme_login_password">$password_label:</label>\
|
||||
<input class="form-control" type="password" name="theme_login[password]" id="theme_login_password" />\
|
||||
</div>\
|
||||
</form>\
|
||||
</div>\
|
||||
<div class="modal-footer">\
|
||||
<a class="btn btn-default" href="$this->themeReturnUrl">$return_label</a>\
|
||||
<button type="button" class="btn btn-primary">$button_label</button>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>');
|
||||
|
||||
$('body').prepend(login);
|
||||
|
||||
login.modal({
|
||||
backdrop: 'static',
|
||||
keyboard: false,
|
||||
show: true
|
||||
});
|
||||
|
||||
login.on('click', '.modal-footer > button.btn-primary', function() {
|
||||
login.find('form').submit();
|
||||
});
|
||||
});
|
||||
JS;
|
||||
}
|
||||
echo '<script type="text/javascript">' . $js . '</script>';
|
||||
}
|
||||
}
|
||||
|
||||
public function smartyIncludeLess($params, &$smarty)
|
||||
{
|
||||
if ($this->themeMode) {
|
||||
echo minify_get_less($this->context->getResponse(), 'cache/less/_editor');
|
||||
} else {
|
||||
echo minify_get_less($this->context->getResponse());
|
||||
}
|
||||
}
|
||||
|
||||
public function smartyIncludeMeta($params, &$smarty)
|
||||
{
|
||||
$smarty->smartySet($params, $smarty);
|
||||
|
||||
$response = $this->context->getResponse();
|
||||
|
||||
foreach ($response->getHttpMetas() as $httpequiv => $value) {
|
||||
echo tag('meta', array('http-equiv' => $httpequiv, 'content' => $value)) . "\n";
|
||||
}
|
||||
|
||||
foreach ($response->getMetas() as $name => $content) {
|
||||
if ($name == 'title' || empty($content)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
echo tag('meta', array('name' => $name, 'content' => $content)) . "\n";
|
||||
}
|
||||
|
||||
echo content_tag('title', $response->getTitle()) . "\n";
|
||||
|
||||
foreach ($response->getLinks() as $options) {
|
||||
echo tag('link', $options);
|
||||
}
|
||||
}
|
||||
|
||||
public function smartyThemeEdit($params, $content)
|
||||
{
|
||||
$decorator = '';
|
||||
|
||||
$decorator = st_drop_menu_load_view();
|
||||
|
||||
$decorator .= st_drop_menu_load_config();
|
||||
|
||||
if (SF_ENVIRONMENT == 'edit') {
|
||||
$decorator .= st_get_component('stThemeFrontend', 'editThemeHead');
|
||||
} else {
|
||||
$decorator .= content_tag('a', '', array('id' => 'portal-block-list-link', 'name' => 'portal-block-list-link'));
|
||||
}
|
||||
|
||||
$decorator .= $content;
|
||||
|
||||
if (SF_ENVIRONMENT == 'edit') {
|
||||
$decorator .= st_get_component('stThemeFrontend', 'editThemeFoot');
|
||||
} else {
|
||||
$decorator .= content_tag('div', content_tag('div', content_tag('div', '', array('id' => 'magazine1', 'class' => 'portal-column'))), array('id' => 'portal-column-block-list', 'style' => 'display:none'));
|
||||
}
|
||||
|
||||
return $decorator;
|
||||
}
|
||||
|
||||
public function renderLayout($content, $default_layout)
|
||||
{
|
||||
$smarty = new stSmarty();
|
||||
|
||||
if ($this->getTheme()->getVersion() >= 2 && $this->themeMode) {
|
||||
sfLoader::loadHelpers('stPartial');
|
||||
|
||||
$this->context->getI18N()->setCulture($this->themeCulture);
|
||||
|
||||
$content .= st_get_partial('stThemeFrontend/theme_editor', array('theme' => $this->getTheme()->getTheme(), 'return_url' => $this->themeReturnUrl));
|
||||
|
||||
$this->context->getI18N()->setCulture($this->context->getUser()->getCulture());
|
||||
}
|
||||
|
||||
if ($this->getTheme()->getVersion() < 7) {
|
||||
sfLoader::loadHelpers('stUsersOnline');
|
||||
$smarty->assign('users_online', st_get_online_users());
|
||||
$smarty->assign('show_online_users', st_show_online_users());
|
||||
$smarty->assignLinkTo('new_products_title', 'NOWOŚCI', 'product/list?new=1');
|
||||
$smarty->assignLinkTo('promotion_products_title', 'PROMOCJE', 'product/list?group_id=1');
|
||||
$smarty->assignComponent('stSearch', 'stSearchFrontend', 'searchBox');
|
||||
$smarty->assignComponent('stPartner', 'stPartnerFrontend', 'checkHash');
|
||||
$smarty->assignPartial('stNavigationShowLocation', 'stNavigationFrontend', 'showLocation');
|
||||
$smarty->assignPartial('selectLanguage', 'stLanguageFrontend', 'showLanguages');
|
||||
$smarty->assignComponent('header', 'stWebpageFrontend', 'groupWebpage', array('group_page' => 'HEADER'));
|
||||
$smarty->assign('stBasketList', '<div id="basket_show">' . st_get_component('stBasket', 'show', array('cache_id' => stBasket::cacheId())) . '</div>');
|
||||
$smarty->assignComponent('stCurrencyPickCurrency', 'stCurrencyFrontend', 'pickCurrency');
|
||||
$smarty->assignComponent('footer', 'stWebpageFrontend', 'groupWebpage', array('group_page' => 'FOOTER'));
|
||||
$smarty->assign('theme', $this->getThemeConfiguration());
|
||||
}
|
||||
|
||||
if (!$smarty->get_template_vars('homepage_url')) {
|
||||
$smarty->assign('homepage_url', $this->context->getController()->genUrl('stFrontendMain/index'));
|
||||
}
|
||||
|
||||
$smarty->assign('content', $content);
|
||||
$smarty->assign('edit_environment', SF_ENVIRONMENT == 'edit' && sfConfig::get('sf_st_theme_clipboard'));
|
||||
$smarty->assign('open', stLicense::isOpen());
|
||||
|
||||
$layout = $this->getTheme()->getLayoutName();
|
||||
|
||||
return $smarty->fetch(($layout ? $layout : $default_layout) . '.html');
|
||||
}
|
||||
|
||||
public function smartyRenderLayout($source, $smarty)
|
||||
{
|
||||
if (preg_match_all('/{render_layout default="([^"]+)"}/', $source, $matches)) {
|
||||
|
||||
$code = array();
|
||||
|
||||
foreach ($matches[0] as $i => $search) {
|
||||
$layout_name = $matches[1][$i];
|
||||
|
||||
$code[] = sprintf('{php}$this->_tpl_vars[\'_layout_%1$s\'] = $this->_tpl_vars[\'view\']->renderLayout($this->_tpl_vars[\'content\'], \'%1$s\');{/php}', $layout_name);
|
||||
|
||||
$source = str_replace($search, sprintf('{php}echo $this->_tpl_vars[\'_layout_%s\'];{/php}', $layout_name), $source);
|
||||
}
|
||||
|
||||
return implode("\n", $code) . "\n" . $source;
|
||||
}
|
||||
|
||||
return $source;
|
||||
}
|
||||
|
||||
protected function decorate($content)
|
||||
{
|
||||
return $this->decorator ? $this->decorateContent($content) : null;
|
||||
}
|
||||
|
||||
protected function decorateContent($content)
|
||||
{
|
||||
sfLoader::loadHelpers('SfMinify');
|
||||
|
||||
$smarty = new stSmarty();
|
||||
|
||||
$smarty->register_function('include_meta', array($this, 'smartyIncludeMeta'));
|
||||
|
||||
$smarty->register_function('include_javascripts', array($this, 'smartyIncludeJavascripts'));
|
||||
|
||||
$smarty->register_function('include_stylesheets', array($this, 'smartyIncludeStylesheets'));
|
||||
|
||||
$smarty->register_function('include_less', array($this, 'smartyIncludeLess'));
|
||||
|
||||
$smarty->register_prefilter(array($this, 'smartyRenderLayout'));
|
||||
|
||||
$smarty->assign('content', $content);
|
||||
|
||||
$smarty->assign('view', $this);
|
||||
|
||||
$smarty->assign('lang', stLanguage::getShortcut());
|
||||
|
||||
if ($this->getTheme()->getTheme()->getVersion() < 2) {
|
||||
sfLoader::loadHelpers('stDropMenu');
|
||||
|
||||
$smarty->register_block('theme_edit', array($this, 'smartyThemeEdit'));
|
||||
|
||||
$smarty->register_function('include_theme_edit_stylesheets', 'st_drop_menu_extend_css');
|
||||
|
||||
$this->getTheme()->useStylesheet('style.css', 'first');
|
||||
|
||||
$this->getTheme()->useStylesheet($this->getTheme()->getLayoutName() . '.css', 'first');
|
||||
|
||||
$this->getTheme()->useStylesheet($this->getTheme()->getThemeName() . '.css', 'last');
|
||||
} else {
|
||||
$theme = $this->getTheme()->getTheme();
|
||||
|
||||
if ($this->themeMode) {
|
||||
$this->context->getResponse()->addJavascript('/jQueryTools/noty/js/jquery.noty.js', 'last');
|
||||
$this->getTheme()->addStylesheet('jquery.noty.css', 'last');
|
||||
}
|
||||
|
||||
foreach ($this->getTheme()->getTheme()->getBaseThemes() as $current) {
|
||||
$this->getTheme()->useStylesheet($current->getTheme() . '.css', 'last');
|
||||
}
|
||||
|
||||
$this->getTheme()->useStylesheet($theme->getTheme() . '.css', 'last');
|
||||
|
||||
if ($this->themeMode) {
|
||||
if ($this->getTheme()->getVersion() < 7 && is_file($theme->getEditorCssPath('preview_config.less', true))) {
|
||||
$this->getTheme()->addLess('_editor/preview_config.less', 'last');
|
||||
}
|
||||
|
||||
if (is_file($theme->getEditorCssPath('preview_style.css', true))) {
|
||||
$this->getTheme()->useStylesheet('_editor/preview_style.css', 'last');
|
||||
}
|
||||
} else {
|
||||
if ($this->getTheme()->getVersion() < 7 && is_file($theme->getEditorCssPath('config.less', true))) {
|
||||
$this->getTheme()->addLess('_editor/config.less', 'last');
|
||||
}
|
||||
|
||||
if (is_file($theme->getEditorCssPath('style.css', true))) {
|
||||
$this->getTheme()->useStylesheet('_editor/style.css', 'last');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $smarty->fetch('base.html');
|
||||
}
|
||||
|
||||
protected function preRenderCheck()
|
||||
{
|
||||
if ($this->template == null) {
|
||||
// a template has not been set
|
||||
$error = 'A template has not been set';
|
||||
|
||||
throw new sfRenderException($error);
|
||||
}
|
||||
|
||||
$template = $this->directory . '/' . $this->template;
|
||||
|
||||
if (!is_readable($template)) {
|
||||
// the template isn't readable
|
||||
throw new sfRenderException(sprintf('The template "%s" does not exist in: %s', $template, $this->directory));
|
||||
}
|
||||
}
|
||||
|
||||
protected function getThemeConfiguration()
|
||||
{
|
||||
$this->config = stConfig::getInstance('stThemeBackend');
|
||||
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($this, 'stThemeView.themeConfig'));
|
||||
|
||||
$tmp = array();
|
||||
|
||||
$tmp['logo'] = array('name' => $this->config->get('logo_name_text', null, true), 'desc' => $this->config->get('logo_desc_text', null, true));
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user