Author: Jonathan.Wage
Date: 2010-02-18 02:15:48 +0100 (Thu, 18 Feb 2010)
New Revision: 28102
Added:
plugins/sfSympalPlugin/trunk/lib/events/
plugins/sfSympalPlugin/trunk/lib/events/sfSympalComponentMethodNotFoundListener.class.php
plugins/sfSympalPlugin/trunk/lib/events/sfSympalContextLoadFactoriesListener.class.php
plugins/sfSympalPlugin/trunk/lib/events/sfSympalControllerChangeActionListener.class.php
plugins/sfSympalPlugin/trunk/lib/events/sfSympalFormFilterValuesListener.class.php
plugins/sfSympalPlugin/trunk/lib/events/sfSympalFormMethodNotFoundListener.class.php
plugins/sfSympalPlugin/trunk/lib/events/sfSympalFormPostConfigureListener.class.php
plugins/sfSympalPlugin/trunk/lib/events/sfSympalListener.class.php
plugins/sfSympalPlugin/trunk/lib/events/sfSympalTaskClearCacheListener.class.php
plugins/sfSympalPlugin/trunk/lib/events/sfSympalTemplateFilterParametersListener.class.php
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalContentListPlugin/lib/events/
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalContentListPlugin/lib/events/sfSympalContentRendererFilterVariablesListener.class.php
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalContentListPlugin/lib/events/sfSympalContentRendererUnknownFormatListener.class.php
plugins/sfSympalPlugin/trunk/test/functional/ContentListTest.php
Modified:
plugins/sfSympalPlugin/trunk/config/app.yml
plugins/sfSympalPlugin/trunk/config/sfSympalPluginConfiguration.class.php
plugins/sfSympalPlugin/trunk/data/fixtures/install.yml
plugins/sfSympalPlugin/trunk/lib/form/sfSympalForm.class.php
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalContentListPlugin/config/sfSympalContentListPluginConfiguration.class.php
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalInstallPlugin/lib/sfSympalInstall.class.php
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/model/doctrine/PluginsfSympalMenuItemTable.class.php
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalPluginManagerPlugin/lib/manager/sfSympalPluginManager.class.php
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalPluginManagerPlugin/lib/toolkits/sfSympalPluginToolkit.class.php
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/content/sfSympalContentRenderer.class.php
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/sfSympalContentActionLoader.class.php
plugins/sfSympalPlugin/trunk/lib/sfSympalConfiguration.class.php
plugins/sfSympalPlugin/trunk/lib/task/sfSympalCreateSiteTask.class.php
plugins/sfSympalPlugin/trunk/lib/util/sfSympalToolkit.class.php
Log:
[1.4][sfSympalPlugin][1.0] Re-committing new sympal event listener
implementation
Modified: plugins/sfSympalPlugin/trunk/config/app.yml
===================================================================
--- plugins/sfSympalPlugin/trunk/config/app.yml 2010-02-17 23:59:58 UTC (rev
28101)
+++ plugins/sfSympalPlugin/trunk/config/app.yml 2010-02-18 01:15:48 UTC (rev
28102)
@@ -350,4 +350,4 @@
plugin_sources: ["http://svn.symfony-project.com/plugins"]
# Allowed markdown styled boxes
- markdown_styled_boxes: [quote, tip, caution, note]
+ markdown_styled_boxes: [quote, tip, caution, note]
\ No newline at end of file
Modified:
plugins/sfSympalPlugin/trunk/config/sfSympalPluginConfiguration.class.php
===================================================================
--- plugins/sfSympalPlugin/trunk/config/sfSympalPluginConfiguration.class.php
2010-02-17 23:59:58 UTC (rev 28101)
+++ plugins/sfSympalPlugin/trunk/config/sfSympalPluginConfiguration.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -49,7 +49,7 @@
*/
public function initialize()
{
- $this->sympalConfiguration = new sfSympalConfiguration($this->dispatcher,
$this->configuration);
+ $this->sympalConfiguration = new
sfSympalConfiguration($this->configuration);
}
/**
Modified: plugins/sfSympalPlugin/trunk/data/fixtures/install.yml
===================================================================
--- plugins/sfSympalPlugin/trunk/data/fixtures/install.yml 2010-02-17
23:59:58 UTC (rev 28101)
+++ plugins/sfSympalPlugin/trunk/data/fixtures/install.yml 2010-02-18
01:15:48 UTC (rev 28102)
@@ -1,7 +1,7 @@
---
sfSympalSite:
Site_default:
- title: <?php echo
sfInflector::humanize(sfConfig::get('app_sympal_config_site_slug',
sfConfig::get('sf_app'))) ?>
+ title: <?php echo sfInflector::humanize(sfConfig::get('sf_app')) ?>
description: Flexible content management framework built on top of symfony.
sfSympalContentType:
Added:
plugins/sfSympalPlugin/trunk/lib/events/sfSympalComponentMethodNotFoundListener.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/events/sfSympalComponentMethodNotFoundListener.class.php
(rev 0)
+++
plugins/sfSympalPlugin/trunk/lib/events/sfSympalComponentMethodNotFoundListener.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -0,0 +1,15 @@
+<?php
+
+class sfSympalComponentMethodNotFoundListener extends sfSympalListener
+{
+ public function getEventName()
+ {
+ return 'component.method_not_found';
+ }
+
+ public function run(sfEvent $event)
+ {
+ $actions = new sfSympalActions();
+ return $actions->extend($event);
+ }
+}
\ No newline at end of file
Added:
plugins/sfSympalPlugin/trunk/lib/events/sfSympalContextLoadFactoriesListener.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/events/sfSympalContextLoadFactoriesListener.class.php
(rev 0)
+++
plugins/sfSympalPlugin/trunk/lib/events/sfSympalContextLoadFactoriesListener.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -0,0 +1,124 @@
+<?php
+
+class sfSympalContextLoadFactoriesListener extends sfSympalListener
+{
+ private
+ $_symfonyContext,
+ $_sympalContext;
+
+ public function getEventName()
+ {
+ return 'context.load_factories';
+ }
+
+ public function run(sfEvent $event)
+ {
+ $record =
Doctrine_Core::getTable(sfSympalConfig::get('user_model'))->getRecordInstance();
+ $this->_dispatcher->notify(new sfEvent($record,
'sympal.user.set_table_definition', array('object' => $record)));
+
+ $this->_symfonyContext = $event->getSubject();
+ $this->_invoker->setCache(new sfSympalCache($this->_invoker));
+ $this->_invoker->setSymfonyContext($this->_symfonyContext);
+
+ $this->_sympalContext =
sfSympalContext::createInstance($this->_symfonyContext, $this->_invoker);
+ $this->_invoker->setSympalContext($this->_sympalContext);
+
+ $this->_enableModules();
+ $this->_checkInstalled();
+
+ $this->_invoker->initializeTheme();
+
+ $helpers = array(
+ 'Sympal',
+ 'SympalContentSlot',
+ 'SympalMenu',
+ 'SympalPager',
+ 'I18N',
+ 'Asset',
+ 'Url',
+ 'Partial'
+ );
+
+ if ($this->_invoker->isAdminModule())
+ {
+ sfConfig::set('sf_login_module', 'sympal_admin');
+ $helpers[] = 'Admin';
+ }
+
+ $this->_invoker->getProjectConfiguration()->loadHelpers($helpers);
+
+ $this->_dispatcher->notify(new sfEvent($this, 'sympal.load'));
+
+ new sfSympalContextLoadFactoriesListener($this->_dispatcher,
$this->_invoker);
+ new sfSympalComponentMethodNotFoundListener($this->_dispatcher,
$this->_invoker);
+ new sfSympalControllerChangeActionListener($this->_dispatcher,
$this->_invoker);
+ new sfSympalTemplateFilterParametersListener($this->_dispatcher,
$this->_invoker);
+ new sfSympalFormMethodNotFoundListener($this->_dispatcher,
$this->_invoker);
+ new sfSympalFormPostConfigureListener($this->_dispatcher, $this->_invoker);
+ new sfSympalFormFilterValuesListener($this->_dispatcher, $this->_invoker);
+ }
+
+ /**
+ * Handle the enabling of modules. Either enables all modules or only the
configured modules.
+ *
+ * @return void
+ */
+ private function _enableModules()
+ {
+ if (sfSympalConfig::get('enable_all_modules', null, true))
+ {
+ $modules = sfConfig::get('sf_enabled_modules', array());
+ if (sfSympalConfig::get('enable_all_modules'))
+ {
+ $modules = array_merge($modules,
$this->_invoker->getCache()->getModules());
+ } else {
+ $modules = array_merge($modules,
sfSympalConfig::get('enabled_modules', null, array()));
+ }
+
+ if ($disabledModules = sfSympalConfig::get('disabled_modules', null,
array()))
+ {
+ $modules = array_diff($modules, $disabledModules);
+ }
+
+ sfConfig::set('sf_enabled_modules', $modules);
+ }
+ }
+
+ /**
+ * Check if Sympal is installed and redirect to installer if not.
+ * Do some other install checks as well.
+ *
+ * @return void
+ */
+ private function _checkInstalled()
+ {
+ $request = $this->_symfonyContext->getRequest();
+
+ // Prepare the symfony application is it has not been prepared yet
+ if (!$this->_symfonyContext->getUser() instanceof sfSympalUser)
+ {
+ chdir(sfConfig::get('sf_root_dir'));
+ $task = new sfSympalEnableForAppTask($this->_dispatcher, new
sfFormatter());
+
$task->run(array($this->_invoker->getProjectConfiguration()->getApplication()),
array());
+
+ $this->_symfonyContext->getController()->redirect('@homepage');
+ }
+
+ // Redirect to install module if...
+ // not in test environment
+ // sympal has not been installed
+ // module is not already sympal_install
+ if (sfConfig::get('sf_environment') != 'test' &&
!sfSympalConfig::get('installed') && $request->getParameter('module') !=
'sympal_install')
+ {
+ $this->_symfonyContext->getController()->redirect('@sympal_install');
+ }
+
+ // Redirect to homepage if no site record exists so we can prompt the user
to create
+ // a site record for this application
+ // This check is only ran in dev mode
+ if (sfConfig::get('sf_environment') == 'dev' &&
!$this->_sympalContext->getSite() &&
$this->_symfonyContext->getRequest()->getPathInfo() != '/')
+ {
+ $this->_symfonyContext->getController()->redirect('@homepage');
+ }
+ }
+}
\ No newline at end of file
Added:
plugins/sfSympalPlugin/trunk/lib/events/sfSympalControllerChangeActionListener.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/events/sfSympalControllerChangeActionListener.class.php
(rev 0)
+++
plugins/sfSympalPlugin/trunk/lib/events/sfSympalControllerChangeActionListener.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -0,0 +1,36 @@
+<?php
+
+class sfSympalControllerChangeActionListener extends sfSympalListener
+{
+ private
+ $_checkedOnline = false;
+
+ public function getEventName()
+ {
+ return 'controller.change_action';
+ }
+
+ public function run(sfEvent $event)
+ {
+ $this->_invoker->initializeTheme();
+ $this->_checkOnlineConfiguration();
+ }
+
+ /**
+ * Check if Sympal is not online and act accordingly
+ *
+ * @return void
+ */
+ private function _checkOnlineConfiguration()
+ {
+ if (sfSympalConfig::get('offline', 'enabled', false) &&
!$this->_checkedOnline)
+ {
+ $this->_checkedOnline = true;
+ $this->_invoker->getSymfonyContext()->getController()->forward(
+ sfSympalConfig::get('offline', 'module'),
+ sfSympalConfig::get('offline', 'action')
+ );
+ throw new sfStopException();
+ }
+ }
+}
\ No newline at end of file
Added:
plugins/sfSympalPlugin/trunk/lib/events/sfSympalFormFilterValuesListener.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/events/sfSympalFormFilterValuesListener.class.php
(rev 0)
+++
plugins/sfSympalPlugin/trunk/lib/events/sfSympalFormFilterValuesListener.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -0,0 +1,25 @@
+<?php
+
+class sfSympalFormFilterValuesListener extends sfSympalListener
+{
+ public function getEventName()
+ {
+ return 'form.filter_values';
+ }
+
+ public function run(sfEvent $event, $values)
+ {
+ $form = $event->getSubject();
+ if ($form->hasRecaptcha())
+ {
+ $request = $this->_invoker->getSymfonyContext();
+ $captcha = array(
+ 'recaptcha_challenge_field' =>
$request->getParameter('recaptcha_challenge_field'),
+ 'recaptcha_response_field' =>
$request->getParameter('recaptcha_response_field'),
+ );
+ $values = array_merge($values, array('captcha' => $captcha));
+ }
+
+ return $values;
+ }
+}
\ No newline at end of file
Added:
plugins/sfSympalPlugin/trunk/lib/events/sfSympalFormMethodNotFoundListener.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/events/sfSympalFormMethodNotFoundListener.class.php
(rev 0)
+++
plugins/sfSympalPlugin/trunk/lib/events/sfSympalFormMethodNotFoundListener.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -0,0 +1,15 @@
+<?php
+
+class sfSympalFormMethodNotFoundListener extends sfSympalListener
+{
+ public function getEventName()
+ {
+ return 'form.method_not_found';
+ }
+
+ public function run(sfEvent $event)
+ {
+ $sympalForm = new sfSympalForm();
+ return $sympalForm->extend($event);
+ }
+}
\ No newline at end of file
Added:
plugins/sfSympalPlugin/trunk/lib/events/sfSympalFormPostConfigureListener.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/events/sfSympalFormPostConfigureListener.class.php
(rev 0)
+++
plugins/sfSympalPlugin/trunk/lib/events/sfSympalFormPostConfigureListener.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -0,0 +1,66 @@
+<?php
+
+class sfSympalFormPostConfigureListener extends sfSympalListener
+{
+ public function getEventName()
+ {
+ return 'form.post_configure';
+ }
+
+ public function run(sfEvent $event)
+ {
+ $form = $event->getSubject();
+ if ($form instanceof sfFormDoctrine)
+ {
+ sfSympalFormToolkit::embedI18n($form->getObject(), $form);
+
+ if (sfSympalConfig::get('remove_timestampable_from_forms', null, true))
+ {
+ unset($form['created_at'], $form['updated_at']);
+ }
+ }
+ $widgetSchema = $form->getWidgetSchema();
+ $requiredFields = $form->getRequiredFields();
+ $widgetSchema->addOption('required_fields', $requiredFields);
+ $widgetSchema->addFormFormatter('table', new
sfSympalWidgetFormSchemaFormatterTable($widgetSchema));
+
+ if ($form->hasRecaptcha())
+ {
+ sfSympalFormToolkit::embedRecaptcha($form);
+ }
+
+ if (isset($form['template']))
+ {
+ sfSympalFormToolkit::changeTemplateWidget($form);
+ }
+
+ if (isset($form['theme']))
+ {
+ sfSympalFormToolkit::changeThemeWidget($form);
+ }
+
+ if (isset($form['module']))
+ {
+ sfSympalFormToolkit::changeModuleWidget($form);
+ }
+
+ if (isset($form['content_id']) || isset($form['content_list']))
+ {
+ sfSympalFormToolkit::changeContentWidget($form);
+ }
+
+ $richDateForms = sfSympalConfig::get('rich_date_forms');
+ $formClass = get_class($form);
+ if (isset($richDateForms[$formClass]))
+ {
+ foreach ($form as $name => $field)
+ {
+ $widget = $field->getWidget();
+ if (in_array($name, $richDateForms[$formClass]) && ($widget instanceof
sfWidgetFormDateTime || $widget instanceof sfWidgetFormDate))
+ {
+ sfSympalFormToolkit::changeDateWidget($name, $form);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: plugins/sfSympalPlugin/trunk/lib/events/sfSympalListener.class.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/events/sfSympalListener.class.php
(rev 0)
+++ plugins/sfSympalPlugin/trunk/lib/events/sfSympalListener.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -0,0 +1,67 @@
+<?php
+
+/**
+ * A listener is an object that will react on an event which fired
+ * by the dispatcher at predefined conditions.
+ *
+ * Whenever an instance of sfSympalListener is created it will be registered
+ * in the dispatcher for an event, returned by getEventName() method.
+ *
+ * In trivial case to register a listener you need create a class that extends
+ * sfSympalListener, define methods getEventName() and run() then create an
instance
+ * to register it.
+ *
+ * @author Maxim Tsepkov <[email protected]>
+ * @author Jonathan H. Wage <[email protected]>
+ */
+
+abstract class sfSympalListener
+{
+ protected
+ $_dispatcher,
+ $_invoker;
+
+ /**
+ * Must return event name to connect to.
+ * It can be a string for one event or an array of strings for multiple
events.
+ *
+ * @return string|array
+ */
+ abstract public function getEventName();
+
+ /**
+ *
+ * @param sfSympalListener $listener
+ * @return null
+ */
+ public function __construct(sfEventDispatcher $dispatcher, $invoker)
+ {
+ $this->_invoker = $invoker;
+ $this->_dispatcher = $dispatcher;
+
+ $eventName = $this->getEventName();
+ $entryMethod = $this->getEntryMethod();
+ if (is_array($eventName))
+ {
+ foreach($eventName as $name)
+ {
+ $this->_dispatcher->connect($name, array($this, $entryMethod));
+ }
+ }
+ else
+ {
+ $this->_dispatcher->connect($eventName, array($this, $entryMethod));
+ }
+ }
+
+ /**
+ * This method can be overloaded if entry point into the class should be
changed.
+ * Note that call_user_func() that Symfony dispatcher uses call this method
as static.
+ *
+ * @return string
+ */
+ protected function getEntryMethod()
+ {
+ return 'run';
+ }
+}
\ No newline at end of file
Added:
plugins/sfSympalPlugin/trunk/lib/events/sfSympalTaskClearCacheListener.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/events/sfSympalTaskClearCacheListener.class.php
(rev 0)
+++
plugins/sfSympalPlugin/trunk/lib/events/sfSympalTaskClearCacheListener.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -0,0 +1,20 @@
+<?php
+
+class sfSympalTaskClearCacheListener extends sfSympalListener
+{
+ public function getEventName()
+ {
+ return 'task.clear_cache';
+ }
+
+ public function run(sfEvent $event)
+ {
+ $event->getSubject()->logSection('sympal', 'Clearing web cache folder');
+
+ $cacheDir = sfConfig::get('sf_web_dir').'/cache';
+ if (is_dir($cacheDir))
+ {
+
$event->getSubject()->getFilesystem()->remove(sfFinder::type('file')->ignore_version_control()->discard('.sf')->in($cacheDir));
+ }
+ }
+}
\ No newline at end of file
Added:
plugins/sfSympalPlugin/trunk/lib/events/sfSympalTemplateFilterParametersListener.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/events/sfSympalTemplateFilterParametersListener.class.php
(rev 0)
+++
plugins/sfSympalPlugin/trunk/lib/events/sfSympalTemplateFilterParametersListener.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -0,0 +1,27 @@
+<?php
+
+class sfSympalTemplateFilterParametersListener extends sfSympalListener
+{
+ public function getEventName()
+ {
+ return 'template.filter_parameters';
+ }
+
+ public function run(sfEvent $event, $parameters)
+ {
+ if (!$sympalContext = $this->_invoker->getSympalContext())
+ {
+ return $parameters;
+ }
+ $parameters['sf_sympal_context'] = $sympalContext;
+ if ($content = $sympalContext->getCurrentContent())
+ {
+ $parameters['sf_sympal_content'] = $content;
+ }
+ if ($menuItem = $sympalContext->getCurrentMenuItem())
+ {
+ $parameters['sf_sympal_menu_item'] = $menuItem;
+ }
+ return $parameters;
+ }
+}
\ No newline at end of file
Modified: plugins/sfSympalPlugin/trunk/lib/form/sfSympalForm.class.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/form/sfSympalForm.class.php
2010-02-17 23:59:58 UTC (rev 28101)
+++ plugins/sfSympalPlugin/trunk/lib/form/sfSympalForm.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -35,63 +35,6 @@
return $fields;
}
- public function sympalConfigure()
- {
- $form = $this->getSubject();
- if ($form instanceof sfFormDoctrine)
- {
- sfSympalFormToolkit::embedI18n($form->getObject(), $form);
-
- if (sfSympalConfig::get('remove_timestampable_from_forms', null, true))
- {
- unset($form['created_at'], $form['updated_at']);
- }
- }
- $widgetSchema = $form->getWidgetSchema();
- $requiredFields = $form->getRequiredFields();
- $widgetSchema->addOption('required_fields', $requiredFields);
- $widgetSchema->addFormFormatter('table', new
sfSympalWidgetFormSchemaFormatterTable($widgetSchema));
-
- if ($form->hasRecaptcha())
- {
- sfSympalFormToolkit::embedRecaptcha($form);
- }
-
- if (isset($form['template']))
- {
- sfSympalFormToolkit::changeTemplateWidget($form);
- }
-
- if (isset($form['theme']))
- {
- sfSympalFormToolkit::changeThemeWidget($form);
- }
-
- if (isset($form['module']))
- {
- sfSympalFormToolkit::changeModuleWidget($form);
- }
-
- if (isset($form['content_id']) || isset($form['content_list']))
- {
- sfSympalFormToolkit::changeContentWidget($form);
- }
-
- $richDateForms = sfSympalConfig::get('rich_date_forms');
- $formClass = get_class($form);
- if (isset($richDateForms[$formClass]))
- {
- foreach ($form as $name => $field)
- {
- $widget = $field->getWidget();
- if (in_array($name, $richDateForms[$formClass]) && ($widget instanceof
sfWidgetFormDateTime || $widget instanceof sfWidgetFormDate))
- {
- sfSympalFormToolkit::changeDateWidget($name, $form);
- }
- }
- }
- }
-
public function hasRecaptcha()
{
// No recaptcha in test environment
@@ -104,25 +47,4 @@
return (in_array($class, $forms) || array_key_exists($class, $forms)) ?
true : false;
}
-
- public static function listenToFormPostConfigure(sfEvent $event)
- {
- $event->getSubject()->sympalConfigure();
- }
-
- public static function listenToFormFilterValues(sfEvent $event, $values)
- {
- $form = $event->getSubject();
- if ($form->hasRecaptcha())
- {
- $request = sfContext::getInstance()->getRequest();
- $captcha = array(
- 'recaptcha_challenge_field' =>
$request->getParameter('recaptcha_challenge_field'),
- 'recaptcha_response_field' =>
$request->getParameter('recaptcha_response_field'),
- );
- $values = array_merge($values, array('captcha' => $captcha));
- }
-
- return $values;
- }
}
\ No newline at end of file
Modified:
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalContentListPlugin/config/sfSympalContentListPluginConfiguration.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalContentListPlugin/config/sfSympalContentListPluginConfiguration.class.php
2010-02-17 23:59:58 UTC (rev 28101)
+++
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalContentListPlugin/config/sfSympalContentListPluginConfiguration.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -17,59 +17,12 @@
*/
public function initialize()
{
- $this->dispatcher->connect('sympal.content_renderer.filter_variables',
array($this, 'listenForFilterVariables'));
- $this->dispatcher->connect('sympal.content_renderer.unknown_format',
array($this, 'listenForUnknownFormat'));
+ $this->dispatcher->connect('sympal.load', array($this,
'listenToSympalLoad'));
}
- public function listenForFilterVariables(sfEvent $event, $variables)
+ public function listenToSympalLoad(sfEvent $event)
{
- $content = $variables['content'];
- if ($content->getType()->getName() == 'sfSympalContentList')
- {
- $contentList = $content->getRecord();
-
- $request = sfContext::getInstance()->getRequest();
- $dataGrid = $contentList->buildDataGrid($request);
- $pager = $dataGrid->getPager();
-
- $variables['pager'] = $pager;
- $variables['dataGrid'] = $dataGrid;
- }
-
- return $variables;
+ new sfSympalContentRendererFilterVariablesListener($this->dispatcher,
$this);
+ new sfSympalContentRendererUnknownFormatListener($this->dispatcher, $this);
}
-
- public function listenForUnknownFormat(sfEvent $event)
- {
- if (isset($event['pager']))
- {
- $pager = $event['pager'];
- $context = sfContext::getInstance();
- $response = $context->getResponse();
- $request = $context->getRequest();
-
- $className = 'sf'.ucfirst($event['format']).'Feed';
- if (!class_exists($className))
- {
- return false;
- }
-
- $feed = sfFeedPeer::newInstance($event['format']);
-
- $feed->initialize(array(
- 'title' => $response->getTitle(),
- 'link' => $request->getUri()
- ));
-
- $items = sfFeedPeer::convertObjectsToItems($pager->getResults());
- $feed->addItems($items);
-
- $event->setProcessed(true);
- $event->setReturnValue($feed->asXml());
-
- return true;
- } else {
- return false;
- }
- }
}
\ No newline at end of file
Added:
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalContentListPlugin/lib/events/sfSympalContentRendererFilterVariablesListener.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalContentListPlugin/lib/events/sfSympalContentRendererFilterVariablesListener.class.php
(rev 0)
+++
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalContentListPlugin/lib/events/sfSympalContentRendererFilterVariablesListener.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -0,0 +1,27 @@
+<?php
+
+class sfSympalContentRendererFilterVariablesListener extends sfSympalListener
+{
+ public function getEventName()
+ {
+ return 'sympal.content_renderer.filter_variables';
+ }
+
+ public function run(sfEvent $event, $variables)
+ {
+ $content = $variables['content'];
+ if ($content->getType()->getName() == 'sfSympalContentList')
+ {
+ $contentList = $content->getRecord();
+
+ $request = sfContext::getInstance()->getRequest();
+ $dataGrid = $contentList->buildDataGrid($request);
+ $pager = $dataGrid->getPager();
+
+ $variables['pager'] = $pager;
+ $variables['dataGrid'] = $dataGrid;
+ }
+
+ return $variables;
+ }
+}
\ No newline at end of file
Added:
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalContentListPlugin/lib/events/sfSympalContentRendererUnknownFormatListener.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalContentListPlugin/lib/events/sfSympalContentRendererUnknownFormatListener.class.php
(rev 0)
+++
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalContentListPlugin/lib/events/sfSympalContentRendererUnknownFormatListener.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -0,0 +1,44 @@
+<?php
+
+class sfSympalContentRendererUnknownFormatListener extends sfSympalListener
+{
+ public function getEventName()
+ {
+ return 'sympal.content_renderer.unknown_format';
+ }
+
+ public function run(sfEvent $event)
+ {
+ if (isset($event['pager']))
+ {
+ $pager = $event['pager'];
+ $context = sfContext::getInstance();
+ $response = $context->getResponse();
+ $request = $context->getRequest();
+
+ $className = 'sf'.ucfirst($event['format']).'Feed';
+ if (!class_exists($className))
+ {
+ return false;
+ }
+
+ $feed = sfFeedPeer::newInstance($event['format']);
+
+ $feed->initialize(array(
+ 'title' => $response->getTitle(),
+ 'link' => $request->getUri()
+ ));
+
+ $items = sfFeedPeer::convertObjectsToItems($pager->getResults());
+ $feed->addItems($items);
+
+ $event->setProcessed(true);
+ $event->setReturnValue($feed->asXml());
+ $request->setRequestFormat($event['format']);
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
\ No newline at end of file
Modified:
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalInstallPlugin/lib/sfSympalInstall.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalInstallPlugin/lib/sfSympalInstall.class.php
2010-02-17 23:59:58 UTC (rev 28101)
+++
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalInstallPlugin/lib/sfSympalInstall.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -237,7 +237,6 @@
}
}
- sfSympalConfig::set('site_slug', $this->_application);
$task = new sfDoctrineBuildTask($this->_dispatcher, $this->_formatter);
$options = array(
'db' => true,
@@ -266,7 +265,7 @@
protected function _loadData($append = true)
{
- sfSympalConfig::set('site_slug', $this->_application);
+ sfConfig::set('sf_app', $this->_application);
$task = new sfDoctrineDataLoadTask($this->_dispatcher, $this->_formatter);
$fixtures = $this->_getDataFixtures();
if (!is_array($fixtures))
Modified:
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/model/doctrine/PluginsfSympalMenuItemTable.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/model/doctrine/PluginsfSympalMenuItemTable.class.php
2010-02-17 23:59:58 UTC (rev 28101)
+++
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalMenuPlugin/lib/model/doctrine/PluginsfSympalMenuItemTable.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -9,7 +9,7 @@
{
return $this->createQuery('m')
->select('m.*')
- ->innerJoin('m.Site s WITH s.slug = ?',
sfSympalContext::getInstance()->getSiteSlug())
+ ->innerJoin('m.Site s WITH s.slug = ?', sfConfig::get('sf_app'))
->orderBy('m.root_id ASC')
->limit(1)
->fetchOne();
@@ -19,7 +19,7 @@
{
$menu = $this->createQuery('m')
->select('m.*')
- ->innerJoin('m.Site s WITH s.slug = ?',
sfSympalContext::getInstance()->getSiteSlug())
+ ->innerJoin('m.Site s WITH s.slug = ?', sfConfig::get('sf_app'))
->where('m.slug = ?',
sfSympalConfig::get('default_install_content_type_menu', null, 'primary'))
->fetchOne();
if (!$menu)
Modified:
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalPluginManagerPlugin/lib/manager/sfSympalPluginManager.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalPluginManagerPlugin/lib/manager/sfSympalPluginManager.class.php
2010-02-17 23:59:58 UTC (rev 28101)
+++
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalPluginManagerPlugin/lib/manager/sfSympalPluginManager.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -150,7 +150,7 @@
throw new sfException('Could not find a super admin user');
}
- $siteSlug = sfConfig::get('app_sympal_config_site_slug',
sfConfig::get('sf_app'));
+ $siteSlug = sfConfig::get('sf_app');
$site = Doctrine_Core::getTable('sfSympalSite')->findOneBySlug($siteSlug);
if (!$site)
{
@@ -194,7 +194,7 @@
{
$menuItem = new sfSympalMenuItem();
$menuItem->name = $name;
- $menuItem->Site =
Doctrine_Core::getTable('sfSympalSite')->findOneBySlug(sfConfig::get('app_sympal_config_site_slug',
sfConfig::get('sf_app')));
+ $menuItem->Site =
Doctrine_Core::getTable('sfSympalSite')->findOneBySlug(sfConfig::get('sf_app'));
$menuItem->date_published = new Doctrine_Expression('NOW()');
$this->_setDoctrineProperties($menuItem, $properties);
Modified:
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalPluginManagerPlugin/lib/toolkits/sfSympalPluginToolkit.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalPluginManagerPlugin/lib/toolkits/sfSympalPluginToolkit.class.php
2010-02-17 23:59:58 UTC (rev 28101)
+++
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalPluginManagerPlugin/lib/toolkits/sfSympalPluginToolkit.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -54,6 +54,14 @@
return is_dir(self::getPluginPath($pluginName)) ? true:false;
}
+ public static function isPluginDownloadable($name)
+ {
+ $pluginName = self::getLongPluginName($name);
+ $availablePlugins = self::getDownloadablePlugins();
+
+ return in_array($availablePlugins, $pluginName);
+ }
+
public static function getLongPluginName($name)
{
if (strstr($name, 'sfSympal'))
@@ -175,12 +183,4 @@
throw new sfException('Could not find download path for '.$pluginName);
}
}
-
- public static function isPluginAvailable($name)
- {
- $pluginName = self::getLongPluginName($name);
- $availablePlugins = self::getDownloadablePlugins();
-
- return in_array($availablePlugins, $pluginName);
- }
}
\ No newline at end of file
Modified:
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/content/sfSympalContentRenderer.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/content/sfSympalContentRenderer.class.php
2010-02-17 23:59:58 UTC (rev 28101)
+++
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/content/sfSympalContentRenderer.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -83,10 +83,7 @@
}
if (isset($return) && $return)
{
- $response = $this->_symfonyContext->getResponse();
- $response->setContent($return);
- $response->send();
- exit;
+ return $return;
} else {
throw new RuntimeException(sprintf('Unknown render format: "%s"',
$this->_format));
}
Modified:
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/sfSympalContentActionLoader.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/sfSympalContentActionLoader.class.php
2010-02-17 23:59:58 UTC (rev 28101)
+++
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/sfSympalContentActionLoader.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -36,12 +36,6 @@
return $this->_content;
}
- public function getContentRenderer()
- {
- $content = $this->loadContent();
- return $this->_sympalContext->getContentRenderer($content,
$this->_request->getRequestFormat());
- }
-
public function loadContent()
{
$content = $this->getContent();
@@ -81,7 +75,9 @@
public function loadContentRenderer()
{
- $renderer = $this->getContentRenderer();
+ $content = $this->loadContent();
+ $renderer = $this->_sympalContext->getContentRenderer($content,
$this->_request->getRequestFormat());
+
if ($renderer->getFormat() != 'html')
{
sfConfig::set('sf_web_debug', false);
Modified: plugins/sfSympalPlugin/trunk/lib/sfSympalConfiguration.class.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/sfSympalConfiguration.class.php
2010-02-17 23:59:58 UTC (rev 28101)
+++ plugins/sfSympalPlugin/trunk/lib/sfSympalConfiguration.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -9,31 +9,78 @@
$_symfonyContext,
$_doctrineManager,
$_bootstrap,
- $_plugins = array(),
- $_modules = array(),
- $_themes = null,
- $_availableThemes = null,
+ $_plugins,
+ $_pluginPaths,
+ $_allManageablePlugins,
+ $_contentTypePlugins,
+ $_requiredPlugins,
+ $_modules,
+ $_themes,
+ $_availableThemes,
$_cache;
- public function __construct(sfEventDispatcher $dispatcher,
ProjectConfiguration $projectConfiguration)
+ public function __construct(ProjectConfiguration $projectConfiguration)
{
// We disable Symfony autoload again feature because it is too slow in dev
mode
// If you introduce a new class when using sympal you just must clear your
// cache manually
sfAutoloadAgain::getInstance()->unregister();
- $this->_dispatcher = $dispatcher;
$this->_projectConfiguration = $projectConfiguration;
+ $this->_dispatcher = $projectConfiguration->getEventDispatcher();
$this->_doctrineManager = Doctrine_Manager::getInstance();
$this->_initializeSymfonyConfig();
$this->_markClassesAsSafe();
- $this->_connectEvents();
$this->_configureSuperCache();
$this->_configureDoctrine();
+
+ new sfSympalContextLoadFactoriesListener($this->_dispatcher, $this);
+ new sfSympalTaskClearCacheListener($this->_dispatcher, $this);
}
/**
+ * Initialize some sfConfig values for Sympal
+ *
+ * @return void
+ */
+ private function _initializeSymfonyConfig()
+ {
+ sfConfig::set('sf_cache', sfSympalConfig::get('page_cache', 'enabled',
false));
+ sfConfig::set('sf_default_culture', sfSympalConfig::get('default_culture',
null, 'en'));
+ sfConfig::set('sf_admin_module_web_dir',
sfSympalConfig::get('admin_module_web_dir', null, '/sfSympalAdminPlugin'));
+
+ sfConfig::set('app_sf_guard_plugin_success_signin_url',
sfSympalConfig::get('success_signin_url'));
+
+ if (sfConfig::get('sf_login_module') == 'default')
+ {
+ sfConfig::set('sf_login_module', 'sympal_auth');
+ sfConfig::set('sf_login_action', 'signin');
+ }
+
+ if (sfConfig::get('sf_secure_module') == 'default')
+ {
+ sfConfig::set('sf_secure_module', 'sympal_auth');
+ sfConfig::set('sf_secure_action', 'secure');
+ }
+
+ if (sfConfig::get('sf_error_404_module') == 'default')
+ {
+ sfConfig::set('sf_error_404_module', 'sympal_default');
+ sfConfig::set('sf_error_404_action', 'error404');
+ }
+
+ if (sfConfig::get('sf_module_disabled_module') == 'default')
+ {
+ sfConfig::set('sf_module_disabled_module', 'sympal_default');
+ sfConfig::set('sf_module_disabled_action', 'disabled');
+ }
+
+ sfConfig::set('sf_jquery_path', sfSympalConfig::get('jquery_reloaded',
'path'));
+ sfConfig::set('sf_jquery_plugin_paths',
sfSympalConfig::get('jquery_reloaded', 'plugin_paths'));
+ }
+
+ /**
* Mark necessary Sympal classes as safe
*
* @return void
@@ -58,23 +105,6 @@
}
/**
- * Connect to various events required by Sympal
- *
- * @return void
- */
- private function _connectEvents()
- {
- $this->_dispatcher->connect('context.load_factories', array($this,
'bootstrap'));
- $this->_dispatcher->connect('component.method_not_found', array(new
sfSympalActions(), 'extend'));
- $this->_dispatcher->connect('controller.change_action', array($this,
'listenToControllerChangeAction'));
- $this->_dispatcher->connect('template.filter_parameters', array($this,
'filterTemplateParameters'));
- $this->_dispatcher->connect('form.method_not_found', array(new
sfSympalForm(), 'extend'));
- $this->_dispatcher->connect('form.post_configure', array('sfSympalForm',
'listenToFormPostConfigure'));
- $this->_dispatcher->connect('form.filter_values', array('sfSympalForm',
'listenToFormFilterValues'));
- $this->_dispatcher->connect('task.cache.clear', array($this,
'listenToTaskCacheClear'));
- }
-
- /**
* Configure super cache if enabled
*
* @return void
@@ -99,7 +129,7 @@
$this->_doctrineManager->setAttribute(Doctrine_Core::ATTR_TABLE_CLASS,
'sfSympalDoctrineTable');
$this->_doctrineManager->setAttribute(Doctrine_Core::ATTR_QUERY_CLASS,
'sfSympalDoctrineQuery');
$this->_doctrineManager->setAttribute(Doctrine_Core::ATTR_COLLECTION_CLASS,
'sfSympalDoctrineCollection');
- $this->_configureDoctrineCache();
+ $this->_configureDoctrineCache();
}
/**
@@ -123,83 +153,29 @@
}
}
- public function listenToControllerChangeAction(sfEvent $event)
+ public function setCache(sfSympalCache $cache)
{
- $this->initializeTheme();
- $this->_checkOnline();
+ $this->_cache = $cache;
}
- /**
- * Listen to clear cache task event so we can clear the web cache folder
- *
- * @param sfEvent $event
- * @return void
- */
- public function listenToTaskCacheClear(sfEvent $event)
+ public function setSymfonyContext(sfContext $symfonyContext)
{
- $event->getSubject()->logSection('sympal', 'Clearing web cache folder');
-
- $cacheDir = sfConfig::get('sf_web_dir').'/cache';
- if (is_dir($cacheDir))
- {
-
$event->getSubject()->getFilesystem()->remove(sfFinder::type('file')->ignore_version_control()->discard('.sf')->in($cacheDir));
- }
+ $this->_symfonyContext = $symfonyContext;
}
- /**
- * Callable attached to Symfony event context.load_factories. When this event
- * is triggered we also create the Sympal context.
- */
- public function bootstrap(sfEvent $event)
+ public function setSympalContext(sfSympalContext $sympalContext)
{
- $this->_projectConfiguration = $event->getSubject()->getConfiguration();
-
- $this->_cache = new sfSympalCache($this);
-
- $this->_symfonyContext = $event->getSubject();
- $this->_sympalContext =
sfSympalContext::createInstance($this->_symfonyContext, $this);
-
- $this->_enableModules();
- $this->_checkInstalled();
-
- $this->initializeTheme();
-
- $this->_projectConfiguration->loadHelpers(array(
- 'Sympal', 'SympalContentSlot', 'SympalMenu', 'SympalPager', 'I18N',
'Asset', 'Url', 'Partial'
- ));
-
- if ($this->isAdminModule())
- {
- sfConfig::set('sf_login_module', 'sympal_admin');
- $this->_projectConfiguration->loadHelpers(array('Admin'));
- }
-
- $this->_dispatcher->notify(new sfEvent($this, 'sympal.load'));
+ $this->_sympalContext = $sympalContext;
}
/**
- * Filter Symfony template parameters and add some references to some
variables
+ * Get the current sfContext instance
*
- * @param sfEvent $event
- * @param array $parameters
- * @return array $parameters
+ * @return sfContext $symfonyContext
*/
- public function filterTemplateParameters(sfEvent $event, $parameters)
+ public function getSymfonyContext()
{
- if (!$this->_sympalContext)
- {
- return $parameters;
- }
- $parameters['sf_sympal_context'] = $this->_sympalContext;
- if ($content = $this->_sympalContext->getCurrentContent())
- {
- $parameters['sf_sympal_content'] = $content;
- }
- if ($menuItem = $this->_sympalContext->getCurrentMenuItem())
- {
- $parameters['sf_sympal_menu_item'] = $menuItem;
- }
- return $parameters;
+ return $this->_symfonyContext;
}
/**
@@ -259,18 +235,21 @@
*/
public function getContentTypePlugins()
{
- $contentTypePlugins = array();
- $plugins = $this->getPluginPaths();
-
- foreach ($plugins as $plugin => $path)
+ if ($this->_contentTypePlugins === null)
{
- $manager = new sfSympalPluginManager($plugin,
$this->_projectConfiguration, new sfFormatter());
- if ($contentType = $manager->getContentTypeForPlugin())
+ $this->_contentTypePlugins = array();
+ $plugins = $this->getPluginPaths();
+
+ foreach ($plugins as $plugin => $path)
{
- $contentTypePlugins[] = $plugin;
+ $manager = new sfSympalPluginManager($plugin,
$this->_projectConfiguration, new sfFormatter());
+ if ($contentType = $manager->getContentTypeForPlugin())
+ {
+ $this->_contentTypePlugins[] = $plugin;
+ }
}
}
- return $contentTypePlugins;
+ return $this->_contentTypePlugins;
}
/**
@@ -302,10 +281,12 @@
*/
public function getAllManageablePlugins()
{
- $plugins = array_merge($this->getDownloadablePlugins(),
$this->getDownloadedPlugins());
- $plugins = array_unique($plugins);
-
- return $plugins;
+ if ($this->_allManageablePlugins === null)
+ {
+ $this->_allManageablePlugins =
array_merge($this->getDownloadablePlugins(), $this->getDownloadedPlugins());
+ $this->_allManageablePlugins =
array_unique($this->_allManageablePlugins);
+ }
+ return $this->_allManageablePlugins;
}
/**
@@ -315,7 +296,11 @@
*/
public function getPlugins()
{
- return array_keys($this->getPluginPaths());
+ if ($this->_plugins === null)
+ {
+ $this->_plugins = array_keys($this->getPluginPaths());
+ }
+ return $this->_plugins;
}
/**
@@ -325,21 +310,21 @@
*/
public function getPluginPaths()
{
- if (!$this->_plugins)
+ if ($this->_pluginPaths === null)
{
$configuration = ProjectConfiguration::getActive();
$pluginPaths = $configuration->getAllPluginPaths();
- $this->_plugins = array();
+ $this->_pluginPaths = array();
foreach ($pluginPaths as $pluginName => $path)
{
if (strpos($pluginName, 'sfSympal') !== false)
{
- $this->_plugins[$pluginName] = $path;
+ $this->_pluginPaths[$pluginName] = $path;
}
}
}
- return $this->_plugins;
+ return $this->_pluginPaths;
}
/**
@@ -491,136 +476,6 @@
}
/**
- * Handle the enabling of modules. Either enables all modules or only the
configured modules.
- *
- * @return void
- */
- private function _enableModules()
- {
- if (sfSympalConfig::get('enable_all_modules', null, true))
- {
- $modules = sfConfig::get('sf_enabled_modules', array());
- if (sfSympalConfig::get('enable_all_modules'))
- {
- $modules = array_merge($modules, $this->getModules());
- } else {
- $modules = array_merge($modules,
sfSympalConfig::get('enabled_modules', null, array()));
- }
-
- if ($disabledModules = sfSympalConfig::get('disabled_modules', null,
array()))
- {
- $modules = array_diff($modules, $disabledModules);
- }
-
- sfConfig::set('sf_enabled_modules', $modules);
- }
- }
-
- /**
- * Check if Sympal is installed and redirect to installer if not.
- * Do some other install checks as well.
- *
- * @return void
- */
- private function _checkInstalled()
- {
- // Don't run this if we are under the cli
- if (PHP_SAPI == 'cli')
- {
- return;
- }
- $sfContext = sfContext::getInstance();
- $request = $sfContext->getRequest();
-
- // Prepare the symfony application is it has not been prepared yet
- if (!$sfContext->getUser() instanceof sfSympalUser)
- {
- chdir(sfConfig::get('sf_root_dir'));
- $task = new sfSympalEnableForAppTask($this->_dispatcher, new
sfFormatter());
- $task->run(array($this->_projectConfiguration->getApplication()),
array());
-
- $sfContext->getController()->redirect('@homepage');
- }
-
- // Redirect to install module if...
- // not in test environment
- // sympal has not been installed
- // module is not already sympal_install
- if (sfConfig::get('sf_environment') != 'test' &&
!sfSympalConfig::get('installed') && $request->getParameter('module') !=
'sympal_install')
- {
- $sfContext->getController()->redirect('@sympal_install');
- }
-
- // Redirect to homepage if no site record exists so we can prompt the user
to create
- // a site record for this application
- // This check is only ran in dev mode
- if (sfConfig::get('sf_environment') == 'dev' &&
!$this->_sympalContext->getSite() && $sfContext->getRequest()->getPathInfo() !=
'/')
- {
- $sfContext->getController()->redirect('@homepage');
- }
- }
-
- /**
- * Check if Sympal is not online and act accordingly
- *
- * @return void
- */
- private function _checkOnline()
- {
- static $onlineChecked;
- if (sfSympalConfig::get('offline', 'enabled', false) && !$onlineChecked)
- {
- $onlineChecked = true;
- $this->_symfonyContext->getController()->forward(
- sfSympalConfig::get('offline', 'module'),
- sfSympalConfig::get('offline', 'action')
- );
- throw new sfStopException();
- }
- }
-
- /**
- * Initialize some sfConfig values for Sympal
- *
- * @return void
- */
- private function _initializeSymfonyConfig()
- {
- sfConfig::set('sf_cache', sfSympalConfig::get('page_cache', 'enabled',
false));
- sfConfig::set('sf_default_culture', sfSympalConfig::get('default_culture',
null, 'en'));
- sfConfig::set('sf_admin_module_web_dir',
sfSympalConfig::get('admin_module_web_dir', null, '/sfSympalAdminPlugin'));
-
- sfConfig::set('app_sf_guard_plugin_success_signin_url',
sfSympalConfig::get('success_signin_url'));
-
- if (sfConfig::get('sf_login_module') == 'default')
- {
- sfConfig::set('sf_login_module', 'sympal_auth');
- sfConfig::set('sf_login_action', 'signin');
- }
-
- if (sfConfig::get('sf_secure_module') == 'default')
- {
- sfConfig::set('sf_secure_module', 'sympal_auth');
- sfConfig::set('sf_secure_action', 'secure');
- }
-
- if (sfConfig::get('sf_error_404_module') == 'default')
- {
- sfConfig::set('sf_error_404_module', 'sympal_default');
- sfConfig::set('sf_error_404_action', 'error404');
- }
-
- if (sfConfig::get('sf_module_disabled_module') == 'default')
- {
- sfConfig::set('sf_module_disabled_module', 'sympal_default');
- sfConfig::set('sf_module_disabled_action', 'disabled');
- }
-
- sfConfig::set('sf_jquery_path', sfSympalConfig::get('jquery_reloaded',
'path'));
- sfConfig::set('sf_jquery_plugin_paths',
sfSympalConfig::get('jquery_reloaded', 'plugin_paths'));
- }
-
- /**
* Get the active sfSympalConfiguration instance
*
* @return sfSympalConfiguration $sympalConfiguration
Modified: plugins/sfSympalPlugin/trunk/lib/task/sfSympalCreateSiteTask.class.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/task/sfSympalCreateSiteTask.class.php
2010-02-17 23:59:58 UTC (rev 28101)
+++ plugins/sfSympalPlugin/trunk/lib/task/sfSympalCreateSiteTask.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -62,9 +62,6 @@
$this->_generateApplication($arguments['site']);
$this->_prepareApplication($arguments['site']);
- $this->configuration = $this->createConfiguration($arguments['site'],
'dev');
- $context = sfContext::createInstance($this->configuration);
-
$databaseManager = new sfDatabaseManager($this->configuration);
$site = $this->_getOrCreateSite($arguments, $options);
}
Modified: plugins/sfSympalPlugin/trunk/lib/util/sfSympalToolkit.class.php
===================================================================
--- plugins/sfSympalPlugin/trunk/lib/util/sfSympalToolkit.class.php
2010-02-17 23:59:58 UTC (rev 28101)
+++ plugins/sfSympalPlugin/trunk/lib/util/sfSympalToolkit.class.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -133,7 +133,7 @@
public static function checkRequirements()
{
$user = sfContext::getInstance()->getUser();
- $app = sfConfig::get('app_sympal_config_site_slug',
sfConfig::get('sf_app'));
+ $app = sfConfig::get('sf_app');
if (!$user instanceof sfSympalUser)
{
throw new sfException('myUser class located in
'.sfConfig::get('sf_root_dir').'/apps/'.$app.'/myUser.class.php must extend
sfSympalUser');
@@ -274,7 +274,7 @@
';
$routes = array();
- $siteSlug = sfConfig::get('app_sympal_config_site_slug',
sfConfig::get('sf_app'));
+ $siteSlug = sfConfig::get('sf_app');
$redirects = Doctrine::getTable('sfSympalRedirect')
->createQuery('r')
@@ -336,7 +336,7 @@
';
$routes = array();
- $siteSlug = sfConfig::get('app_sympal_config_site_slug',
sfConfig::get('sf_app'));
+ $siteSlug = sfConfig::get('sf_app');
$contents = Doctrine::getTable('sfSympalContent')
->createQuery('c')
Added: plugins/sfSympalPlugin/trunk/test/functional/ContentListTest.php
===================================================================
--- plugins/sfSympalPlugin/trunk/test/functional/ContentListTest.php
(rev 0)
+++ plugins/sfSympalPlugin/trunk/test/functional/ContentListTest.php
2010-02-18 01:15:48 UTC (rev 28102)
@@ -0,0 +1,27 @@
+<?php
+
+require_once(dirname(__FILE__).'/../bootstrap/functional.php');
+
+$browser = new sfSympalTestFunctional(new sfBrowser());
+
+$browser->
+ get('/lists/sample-content-list')->
+ with('response')->begin()->
+ isStatusCode(200)->
+ isValid()->
+ end()->
+ with('request')->begin()->
+ isFormat('html')->
+ end()
+;
+
+$browser->
+ get('/lists/sample-content-list.rss')->
+ with('response')->begin()->
+ isStatusCode(200)->
+ isValid()->
+ end()->
+ with('request')->begin()->
+ isFormat('rss')->
+ end()
+;
\ No newline at end of file
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.