Author: uncleringo Date: 2010-01-21 17:41:12 +0100 (Thu, 21 Jan 2010) New Revision: 27008
Added: plugins/sfTrafficCMSPlugin/branches/ plugins/sfTrafficCMSPlugin/tags/ plugins/sfTrafficCMSPlugin/trunk/ plugins/sfTrafficCMSPlugin/trunk/LICENSE plugins/sfTrafficCMSPlugin/trunk/README plugins/sfTrafficCMSPlugin/trunk/config/ plugins/sfTrafficCMSPlugin/trunk/config/app.yml plugins/sfTrafficCMSPlugin/trunk/config/routing.yml plugins/sfTrafficCMSPlugin/trunk/config/settings.yml plugins/sfTrafficCMSPlugin/trunk/data/ plugins/sfTrafficCMSPlugin/trunk/data/fixtures/ plugins/sfTrafficCMSPlugin/trunk/data/fixtures/users.yml plugins/sfTrafficCMSPlugin/trunk/lib/ plugins/sfTrafficCMSPlugin/trunk/lib/doctrine/ plugins/sfTrafficCMSPlugin/trunk/lib/doctrine/Listener/ plugins/sfTrafficCMSPlugin/trunk/lib/doctrine/Listener/TrafficCMS.php plugins/sfTrafficCMSPlugin/trunk/lib/doctrine/TrafficCMS.php plugins/sfTrafficCMSPlugin/trunk/lib/filter/ plugins/sfTrafficCMSPlugin/trunk/lib/filter/TrafficCMSBaseFilter.class.php plugins/sfTrafficCMSPlugin/trunk/lib/form/ plugins/sfTrafficCMSPlugin/trunk/lib/form/TrafficCMSBaseForm.class.php plugins/sfTrafficCMSPlugin/trunk/lib/task/ plugins/sfTrafficCMSPlugin/trunk/lib/task/trafficcmsGenerateadminmodulesTask.class.php plugins/sfTrafficCMSPlugin/trunk/modules/ plugins/sfTrafficCMSPlugin/trunk/modules/sfTrafficCMSPlugin/ plugins/sfTrafficCMSPlugin/trunk/modules/sfTrafficCMSPlugin/actions/ plugins/sfTrafficCMSPlugin/trunk/modules/sfTrafficCMSPlugin/actions/actions.class.php plugins/sfTrafficCMSPlugin/trunk/modules/sfTrafficCMSPlugin/templates/ plugins/sfTrafficCMSPlugin/trunk/modules/sfTrafficCMSPlugin/templates/_copyright_notice.php plugins/sfTrafficCMSPlugin/trunk/modules/sfTrafficCMSPlugin/templates/_navigation_frontend.php plugins/sfTrafficCMSPlugin/trunk/modules/sfTrafficCMSPlugin/templates/_navigation_menu.php plugins/sfTrafficCMSPlugin/trunk/package.xml Log: First import to repository Added: plugins/sfTrafficCMSPlugin/trunk/LICENSE =================================================================== --- plugins/sfTrafficCMSPlugin/trunk/LICENSE (rev 0) +++ plugins/sfTrafficCMSPlugin/trunk/LICENSE 2010-01-21 16:41:12 UTC (rev 27008) @@ -0,0 +1,19 @@ +Copyright (c) 2008 Rich Birch + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file Added: plugins/sfTrafficCMSPlugin/trunk/README =================================================================== --- plugins/sfTrafficCMSPlugin/trunk/README (rev 0) +++ plugins/sfTrafficCMSPlugin/trunk/README 2010-01-21 16:41:12 UTC (rev 27008) @@ -0,0 +1,40 @@ +sfTrafficCMSPlugin +========================== + +This is a CMS framework package +Experimental - use at your own risk! + + +Installation +------------ + +To install the plugin for a symfony project, the usual process is to use the +symfony command line: + + php symfony plugin:install sfTrafficCMSPlugin + +If the installation of either package fails then you can manually download the +tgz file from + + http://plugins.symfony-project.org/get/sfTrafficCMSPlugin/sfTrafficCMSPlugin-1.0.0.tgz + +and then ask symfony to install the downloaded file + + php symfony plugin:install sfTrafficCMSPlugin-1.0.0.tgz + +Enable the plugin if necessary by editing config/ProjectConfiguration.class.php: + + $this->enablePlugins('sfTrafficCMSPlugin'); + + +Usage +----- + +This is an experimental CMS framework package and there's no documentation yet! + +As it matures we promise add some documentation. Watch this space... + + +Settings +-------- + Added: plugins/sfTrafficCMSPlugin/trunk/config/app.yml =================================================================== --- plugins/sfTrafficCMSPlugin/trunk/config/app.yml (rev 0) +++ plugins/sfTrafficCMSPlugin/trunk/config/app.yml 2010-01-21 16:41:12 UTC (rev 27008) @@ -0,0 +1,8 @@ +all: + sf_traffic_cms_plugin: + auto_configure: + date_format: %day%/%month%/%year% + tiny_mce: + width: 550 + height: 350 + config: theme: "simple" \ No newline at end of file Added: plugins/sfTrafficCMSPlugin/trunk/config/routing.yml =================================================================== --- plugins/sfTrafficCMSPlugin/trunk/config/routing.yml (rev 0) +++ plugins/sfTrafficCMSPlugin/trunk/config/routing.yml 2010-01-21 16:41:12 UTC (rev 27008) @@ -0,0 +1,3 @@ +sfTrafficCMSPluginDeleteChildren: + url: /sf_traffic_cms_plugin/delete_children/:model/:id/:parent_model/:parent_model_id + param: { module: sfTrafficCMSPlugin, action: deleteChildren } Added: plugins/sfTrafficCMSPlugin/trunk/config/settings.yml =================================================================== --- plugins/sfTrafficCMSPlugin/trunk/config/settings.yml (rev 0) +++ plugins/sfTrafficCMSPlugin/trunk/config/settings.yml 2010-01-21 16:41:12 UTC (rev 27008) @@ -0,0 +1,9 @@ +all: + .settings: + enabled_modules: [sfTrafficCMSPlugin, sfDoctrineJQueryUISortable, default, sfGuardAuth, sfGuardUser] + + login_module: sfGuardAuth # To be called when a non-authenticated user + login_action: signin # Tries to access a secure page + + secure_module: sfGuardAuth # To be called when a user doesn't have + secure_action: secure # The credentials required for an action \ No newline at end of file Added: plugins/sfTrafficCMSPlugin/trunk/data/fixtures/users.yml =================================================================== --- plugins/sfTrafficCMSPlugin/trunk/data/fixtures/users.yml (rev 0) +++ plugins/sfTrafficCMSPlugin/trunk/data/fixtures/users.yml 2010-01-21 16:41:12 UTC (rev 27008) @@ -0,0 +1,5 @@ +SfGuardUser: + super_admin: + username: admin + password: traffic + is_super_admin: true \ No newline at end of file Added: plugins/sfTrafficCMSPlugin/trunk/lib/doctrine/Listener/TrafficCMS.php =================================================================== --- plugins/sfTrafficCMSPlugin/trunk/lib/doctrine/Listener/TrafficCMS.php (rev 0) +++ plugins/sfTrafficCMSPlugin/trunk/lib/doctrine/Listener/TrafficCMS.php 2010-01-21 16:41:12 UTC (rev 27008) @@ -0,0 +1,22 @@ +<?php + +class Doctrine_Template_Listener_TrafficCMS extends Doctrine_Record_Listener +{ + /** + * Array of ageable options + * + * @var array + */ + protected $_options = array(); + + /** + * __construct + * + * @param array $options + * @return void + */ + public function __construct(array $options) + { + $this->_options = $options; + } +} \ No newline at end of file Added: plugins/sfTrafficCMSPlugin/trunk/lib/doctrine/TrafficCMS.php =================================================================== --- plugins/sfTrafficCMSPlugin/trunk/lib/doctrine/TrafficCMS.php (rev 0) +++ plugins/sfTrafficCMSPlugin/trunk/lib/doctrine/TrafficCMS.php 2010-01-21 16:41:12 UTC (rev 27008) @@ -0,0 +1,70 @@ +<?php + +class Doctrine_Template_TrafficCMS extends Doctrine_Template +{ + /** + * __construct + * + * @param string $array + * @return void + */ + public function __construct(array $options = array()) + { + $this->_options = Doctrine_Lib::arrayDeepMerge($this->_options, $options); + + } + + /** + * Set table definition for TrafficCMS behavior + * + * @return void + */ + public function setTableDefinition() + { + $this->addListener(new Doctrine_Template_Listener_TrafficCMS($this->_options)); + } + + public function getDeleteLinkFor($object) + { + $invoker = $this->getInvoker(); + + return link_to('Delete', "@sfTrafficCMSPluginDeleteChildren?" . + 'model=' . get_class($object) . '&' . + 'id=' . $object->getId() . '&' . + 'parent_model=' . get_class($invoker) . '&' . + 'parent_model_id=' . $invoker->getId()); + } + + public function getAdminLink() + { + if (!sfContext::getInstance()->getUser()->isAuthenticated()) + { + return ''; + } + + $invoker = $this->getInvoker(); + + $route_name = + strtolower( + preg_replace( + array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), + '\\1_\\2', + preg_replace('/(?:^|_)(.?)/e',"strtoupper('$1')", $invoker->getTable()->getTableName()) + ) + ); + + $route = '@' . $route_name . '_edit?id=' . $invoker->id; + + $c = sfContext::getInstance(); + $c->switchTo('backend'); + $url = str_replace('frontend', 'backend', url_for($route)); + $c->switchTo('frontend'); + + return link_to('edit', $url, array('target' => '_traffic_cms_admin')); + } + + public function getWithAdminLink($fieldName, $load = true) + { + return $this->getInvoker()->get($fieldName) . $this->getAdminLink(); + } +} \ No newline at end of file Added: plugins/sfTrafficCMSPlugin/trunk/lib/filter/TrafficCMSBaseFilter.class.php =================================================================== --- plugins/sfTrafficCMSPlugin/trunk/lib/filter/TrafficCMSBaseFilter.class.php (rev 0) +++ plugins/sfTrafficCMSPlugin/trunk/lib/filter/TrafficCMSBaseFilter.class.php 2010-01-21 16:41:12 UTC (rev 27008) @@ -0,0 +1,36 @@ +<?php + +class TrafficCMSBaseFilter extends sfFormFilterDoctrine +{ + public function getModelName() + { + + } + + public function getFields() + { + + } + + public function setup() + { + if ($this->getTable()->hasTemplate('Doctrine_Template_TrafficCMS')) + { + $this->autoConfigure(); + } + } + + private function autoConfigure() + { + foreach ($this->getWidgetSchema()->getFields() as $name => $widget) + { +// if ($widget instanceof sfWidgetFormFilterDate) +// { +// $this->setWidget($name, new sfWidgetFormJQueryDate(array( +// 'format' => sfConfig::get('app_sf_traffic_cms_plugin_date_format', $config['date_format']), +// 'can_be_empty' => $widget->getOption('can_be_empty'), +// ))); +// } + } + } +} Added: plugins/sfTrafficCMSPlugin/trunk/lib/form/TrafficCMSBaseForm.class.php =================================================================== --- plugins/sfTrafficCMSPlugin/trunk/lib/form/TrafficCMSBaseForm.class.php (rev 0) +++ plugins/sfTrafficCMSPlugin/trunk/lib/form/TrafficCMSBaseForm.class.php 2010-01-21 16:41:12 UTC (rev 27008) @@ -0,0 +1,304 @@ +<?php + +class TrafficCMSBaseForm extends sfFormDoctrine +{ + public function getModelName() + { + } + + public function setup() + { + if ($this->getObject()->getTable()->hasTemplate('Doctrine_Template_TrafficCMS')) + { + $this->autoConfigure(); + } + } + + public function bind(array $taintedValues = null, array $taintedFiles = null) + { + $config = sfConfig::get('app_sf_traffic_cms_plugin_auto_configure'); + + if (isset($config['models'][$this->getObject()->getTable()->getTableName()])) + { + $model_config = $config['models'][$this->getObject()->getTable()->getTableName()]; + + if (isset($model_config['embed'])) + { + $this->removeEmptyEmbeddedFormFields($taintedValues, $taintedFiles, $model_config['embed']); + } + } + + // call parent bind method + parent::bind($taintedValues, $taintedFiles); + + } + + private function removeEmptyEmbeddedFormFields(&$taintedValues, &$taintedFiles, $embedded_models) + { + foreach ($embedded_models as $model_name_to_embed => $options) { + if (!isset($options['file_field'])) + { + continue; + } + + $model_class_name = preg_replace('/(?:^|_)(.?)/e',"strtoupper('$1')", $model_name_to_embed); + + // remove the embedded new form if the name field was not provided + if (empty($taintedFiles['new_' . $model_name_to_embed][$options['file_field']]['tmp_name'])) { + + unset($this->embeddedForms['new_' . $model_name_to_embed]); + + // pass the new form validations + $this->validatorSchema['new_' . $model_name_to_embed] = new sfValidatorPass(); + } + } + } + + private function autoConfigure() + { + $config = sfConfig::get('app_sf_traffic_cms_plugin_auto_configure'); + $object = $this->getObject(); + + if (empty($config['models']) + || (!array_key_exists('all', $config['models']) + && !array_key_exists($object->getTable()->getTableName(), $config['models']))) + { + return false; + } + + $this->configureBehaviouralWidgets($config); + + $this->configureNonBehaviouralWidgets($config); + + if (isset($config['models'][$object->getTable()->getTableName()])) + { + $model_config = $config['models'][$object->getTable()->getTableName()]; + + if (isset($model_config['embed']) && is_array($model_config['embed'])) + { + foreach ($model_config['embed'] as $model_name => $options) + { + $this->embedModel($model_name, $options); + } + } + + if (isset($model_config['sortable']) && is_array($model_config['sortable'])) + { + foreach ($model_config['sortable'] as $model_name => $options) + { + $this->embedSortableList($model_name, $options); + } + } + + if (isset($model_config['fields']) && is_array($model_config['fields'])) + { + foreach ($model_config['fields'] as $field_name => $config_options) + { + $this->configureField($field_name, $config_options); + } + } + } + } + + private function configureField($field_name, $config) + { + /** + * Get the options set for the default widget + */ + $options = $this->getWidget($field_name)->getOptions(); + + /** + * Merge with any options specified in the config + */ + if (!empty($config['options'])) + { + $options = array_merge($options, $config['options']); + } + + if (isset($config['class'])) + { + /** + * Create the widget specified in the config & overwrite the default with it + */ + $this->setWidget($field_name, new $config['class']($options)); + } + else + { + $this->getWidget($field_name)->setOptions($options); + } + } + + private function configureNonBehaviouralWidgets($config) + { + foreach ($this->getWidgetSchema()->getFields() as $name => $widget) + { + if ($widget instanceof sfWidgetFormTextarea) + { + sfJSLibManager::addLib('tiny_mce'); + + $this->setWidget($name, new sfWidgetFormTextareaTinyMCE(array( + 'width' => $config['tiny_mce']['width'], + 'height' => $config['tiny_mce']['height'], + 'config' => $config['tiny_mce']['config'], + ))); + } + else if ($widget instanceof sfWidgetFormDate) + { + sfJSLibManager::addLib('jquery_ui'); + + $this->setWidget($name, new sfWidgetFormJQueryDate(array( + 'format' => sfConfig::get('app_sf_traffic_cms_plugin_date_format', $config['date_format']), + 'can_be_empty' => $widget->getOption('can_be_empty'), + ))); + } + } + } + + private function configureBehaviouralWidgets() + { + $object = $this->getObject(); + $table = $object->getTable(); + + if ($table->hasTemplate('Doctrine_Template_JCroppable')) + { + sfJSLibManager::addLib('jcrop'); + + $object->configureJCropWidgets($this); + $object->configureJCropValidators($this); + } + + if ($table->hasTemplate('Doctrine_Template_Sluggable')) + { + $slug_name = $table->getTemplate('Doctrine_Template_Sluggable')->getOption('name'); + + if (isset($this[$slug_name])) + { + unset($this[$slug_name]); + } + } + + if ($table->hasTemplate('Doctrine_Template_Timestampable')) + { + $created = $table->getTemplate('Doctrine_Template_Timestampable')->getOption('created'); + + if (isset($created['name']) && isset($this[$created['name']])) + { + unset($this[$created['name']]); + } + + $updated = $table->getTemplate('Doctrine_Template_Timestampable')->getOption('updated'); + + if (isset($updated['name']) && isset($this[$updated['name']])) + { + unset($this[$updated['name']]); + } + } + } + + private function embedSortableList($model_name, $options) + { + $model_class_name = preg_replace('/(?:^|_)(.?)/e',"strtoupper('$1')", $model_name); + + sfJSLibManager::addLib('jquery_ui'); + + $this->setWidget( + 'sortable_' . $model_name, + new sfWidgetFormDoctrineJQueryUISortable(array( + 'model' => $model_class_name, + 'parent_object' => $this->getObject(), + 'method' => array($options['method'], $options['method_arguments']), + 'grid' => isset($options['grid']) ? $options['grid'] : false, + 'table_method' => array($options['table_method'], array($this->getObject())) + )) + ); + + $this->getWidgetSchema()->setLabel( + 'sortable_' . $model_name, + isset($options['form_label']) + ? $options['form_label'] + : 'Arrange ' . str_replace('_', ' ', $model_name) . 's' + ); + } + + private function embedModel($model_name, $options) + { + $object = $this->getObject(); + + $embedded_form_name = 'embedded_' . $model_name; + $form_to_embed = new sfForm(null, array('id' => 'Sortable' . $model_name)); + $widgets = array(); + $object_count = 0; + + $model_class = preg_replace('/(?:^|_)(.?)/e',"strtoupper('$1')", $model_name); + //foreach ($object->{$model_name . 's'} as $object_to_embed) + + foreach ($object->get($model_class . 's') as $object_to_embed) + { + + $object_count++; + + $widget_name = $model_name . '_' . $object_to_embed->getId(); + $form_class = get_class($object_to_embed) . 'Form'; + + $widget_form = new $form_class($object_to_embed, array( + 'embedded' => true, + 'parent_model' => $object, + )); + + // Hide the parent id since we don't want to be able to edit it + $widget_form->setWidget($object->getTable()->getTableName() . '_id', new sfWidgetFormInputHidden()); + + $form_to_embed->embedForm($widget_name, $widget_form); + + $form_to_embed->setWidgetSchema( + $form_to_embed->getWidgetSchema()->setLabel( + $widget_name, + (isset($options['label']) ? $options['label'] . ' ' : '') . $object_count + ) + ); + + $widgets[] = $form_to_embed->getWidget($widget_name); + + } + + $this->embedForm($embedded_form_name, $form_to_embed); + + $this->setWidgetSchema( + $this->getWidgetSchema()->setLabel( + $embedded_form_name, + isset($options['form_label']) + ? $options['form_label'] + : ucfirst(str_replace('_', ' ', $model_name)) + ) + ); + + if (!$object->isNew() && $object_count < $options['max_records']) { + $model_class = preg_replace('/(?:^|_)(.?)/e',"strtoupper('$1')", $model_name); + + // create a new embedded field object + $object_to_embed = new $model_class(); + + $object_to_embed->{$object->getTable()->getTableName() . '_id'} = $object->getId(); + + $form_class = get_class($object_to_embed) . 'Form'; + + // create a new embedded field object form + $form_to_embed = new $form_class($object_to_embed); + + // Hide the parent id since we don't want to be able to edit it + $form_to_embed->setWidget($object->getTable()->getTableName() . '_id', new sfWidgetFormInputHidden()); + + // embed the form in the current form + $this->embedForm('new_' . $model_name, $form_to_embed); + + $this->setWidgetSchema( + $this->getWidgetSchema()->setLabel( + 'new_' . $model_name, + isset($options['add_new_label']) + ? $options['add_new_label'] + : 'Add new ' . str_replace('_', ' ', $model_name) + ) + ); + } + } +} \ No newline at end of file Added: plugins/sfTrafficCMSPlugin/trunk/lib/task/trafficcmsGenerateadminmodulesTask.class.php =================================================================== --- plugins/sfTrafficCMSPlugin/trunk/lib/task/trafficcmsGenerateadminmodulesTask.class.php (rev 0) +++ plugins/sfTrafficCMSPlugin/trunk/lib/task/trafficcmsGenerateadminmodulesTask.class.php 2010-01-21 16:41:12 UTC (rev 27008) @@ -0,0 +1,74 @@ +<?php + +class trafficcmsGenerateadminmodulesTask extends sfBaseTask +{ + protected function configure() + { + $this->addArguments(array( + new sfCommandArgument('application', sfCommandArgument::REQUIRED, 'The application name'), + )); + + $this->addOptions(array( + new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), + new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine'), + // add your own options here + )); + + $this->namespace = 'trafficcms'; + $this->name = 'generate-admin-modules'; + $this->briefDescription = 'Generates modules as specified in app.yml'; + $this->detailedDescription = <<<EOF +The [trafficcms:generate-admin-modules|INFO] task does things. +Call it with: + + [php symfony trafficcms:generate-admin-modules|INFO] +EOF; + } + + protected function execute($arguments = array(), $options = array()) + { + // initialize the database connection + $databaseManager = new sfDatabaseManager($this->configuration); + $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection(); + + $configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true); + sfContext::createInstance($configuration); + + $context = sfContext::getInstance(); + + $routing = $context->getRouting(); + $nav_items = sfConfig::get('app_sf_traffic_cms_plugin_navigation'); + $config = sfConfig::get('app_sf_traffic_cms_plugin_auto_configure'); + + foreach ($nav_items as $model_name => $nav_options) + { + if (strpos($model_name, 'sf_guard') === 0) + { + print("Skipping sfGuard model\n"); + continue; + } + + $singleton = isset($config['models'][$model_name]['singleton']) ? $config['models'][$model_name]['singleton'] : false; + $route_name = $model_name . ($singleton ? '_edit' : ''); + +// print("Checking $route_name... "); +// +// if ($routing->hasRouteName($route_name)) +// { +// print("found"); +// } +// else +// { + $model_class_name = preg_replace('/(?:^|_)(.?)/e',"strtoupper('$1')", $model_name); + + print("Creating admin module for '$model_class_name'\n"); + + $generate_admin_task = new sfDoctrineGenerateAdminTask($this->dispatcher, $this->formatter); + $generate_admin_task->run( + array('application' => $arguments['application'], 'route_or_model' => $model_class_name), + array('env' => $options['env'])); +// } + print("\n"); + } + } +} Added: plugins/sfTrafficCMSPlugin/trunk/modules/sfTrafficCMSPlugin/actions/actions.class.php =================================================================== --- plugins/sfTrafficCMSPlugin/trunk/modules/sfTrafficCMSPlugin/actions/actions.class.php (rev 0) +++ plugins/sfTrafficCMSPlugin/trunk/modules/sfTrafficCMSPlugin/actions/actions.class.php 2010-01-21 16:41:12 UTC (rev 27008) @@ -0,0 +1,20 @@ +<?php + +class sfTrafficCMSPluginActions extends sfActions +{ + public function executeDeleteChildren(sfWebRequest $request) + { + $child = Doctrine::getTable($request->getParameter('model')) + ->find($request->getParameter('id')); + + //$parent = preg_replace('/(?:^|_)(.?)/e',"strtoupper('$1')", $request->getParameter('parent_model')); + $parent = $request->getParameter('parent_model'); + + if ($child && $child->get($parent)->getId() == $request->getParameter('parent_model_id')) + { + $child->delete(); + } + + $this->redirect($request->getReferer()); + } +} Added: plugins/sfTrafficCMSPlugin/trunk/modules/sfTrafficCMSPlugin/templates/_copyright_notice.php =================================================================== --- plugins/sfTrafficCMSPlugin/trunk/modules/sfTrafficCMSPlugin/templates/_copyright_notice.php (rev 0) +++ plugins/sfTrafficCMSPlugin/trunk/modules/sfTrafficCMSPlugin/templates/_copyright_notice.php 2010-01-21 16:41:12 UTC (rev 27008) @@ -0,0 +1,9 @@ +<div id="copyright_notice"> + © copyright + + <?php echo date("Y"); ?> + + <?php echo sfConfig::get('app_site_name'); ?> + + | All rights reserved +</div> \ No newline at end of file Added: plugins/sfTrafficCMSPlugin/trunk/modules/sfTrafficCMSPlugin/templates/_navigation_frontend.php =================================================================== --- plugins/sfTrafficCMSPlugin/trunk/modules/sfTrafficCMSPlugin/templates/_navigation_frontend.php (rev 0) +++ plugins/sfTrafficCMSPlugin/trunk/modules/sfTrafficCMSPlugin/templates/_navigation_frontend.php 2010-01-21 16:41:12 UTC (rev 27008) @@ -0,0 +1,30 @@ +<!-- needs some attention module and route are generic to avoid errors --> +<?php + +$currentModule = $sf_request->getParameter('module'); +$config = sfConfig::get('app_sf_traffic_cms_navigation'); + +if ($config === null || !isset($config['items'])) +{ + if (sfContext::getInstance()->getConfiguration()->getEnvironment() == 'dev') + { + echo "Looks like you need to add some items in apps/" . + sfContext::getInstance()->getConfiguration()->getApplication() . + "/config/app.yml under sf_traffic_cms_navigation<br/>"; + } + return; +} + +$routes = sfContext::getInstance()->getRouting()->getRoutes(); + +?> +<ul id="<?php echo $config['id'] ?>"> +<?php foreach ($config['items'] as $name => $options): ?> + <?php $route = $options['route']; ?> + <?php $defaults = isset($routes[$route]) ? $routes[$route]->getDefaults() : array() ?> + <?php $attributes = empty($options['attributes']) ? array() : $options['attributes'] ?> + <?php $module = isset($defaults['module']) ? $defaults['module'] : null; ?> + <?php $attributes = array_merge($attributes, array('class' => 'nav' . ($currentModule == $module ? ' active' : ''))) ?> + <li><?php echo link_to($name, (isset($routes[$route]) ? '@' : '') . $route, $attributes) ?></li> +<?php endforeach ?> +</ul> \ No newline at end of file Added: plugins/sfTrafficCMSPlugin/trunk/modules/sfTrafficCMSPlugin/templates/_navigation_menu.php =================================================================== --- plugins/sfTrafficCMSPlugin/trunk/modules/sfTrafficCMSPlugin/templates/_navigation_menu.php (rev 0) +++ plugins/sfTrafficCMSPlugin/trunk/modules/sfTrafficCMSPlugin/templates/_navigation_menu.php 2010-01-21 16:41:12 UTC (rev 27008) @@ -0,0 +1,17 @@ +<?php if ($sf_user->isAuthenticated()): ?> + <div id="menu"> + <ul> + <?php $nav_items = sfConfig::get('app_sf_traffic_cms_plugin_navigation') ?> + <?php $config = sfConfig::get('app_sf_traffic_cms_plugin_auto_configure') ?> + <?php foreach ($nav_items as $model => $options): ?> + <?php $singleton = (isset($config['models'][$model]['singleton']) && $config['models'][$model]['singleton']) ? $config['models'][$model]['singleton'] : false ?> + <?php if(!isset($options['credential']) || $sf_user->hasCredential($options['credential'])): ?> + <li style="float: left; list-style-type: none; margin-right: 10px"> + <?php echo link_to($options['label'], '@' . $model . ($singleton ? '_edit?id=1' : '')) ?> + </li> + <?php endif ?> + <?php endforeach ?> + </ul> + </div> + <br /> +<?php endif; ?> \ No newline at end of file Added: plugins/sfTrafficCMSPlugin/trunk/package.xml =================================================================== --- plugins/sfTrafficCMSPlugin/trunk/package.xml (rev 0) +++ plugins/sfTrafficCMSPlugin/trunk/package.xml 2010-01-21 16:41:12 UTC (rev 27008) @@ -0,0 +1,104 @@ +<?xml version="1.0" encoding="UTF-8"?> +<package packagerversion="1.4.6" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> + <name>sfTrafficCMSPlugin</name> + <channel>plugins.symfony-project.org</channel> + <summary>CMS framework package</summary> + <description>Experimental - use at your own risk! + </description> + <lead> + <name>Rich Birch</name> + <user>uncleringo</user> + <email>[email protected]</email> + <active>yes</active> + </lead> + <date>2010-01-21</date> + <time>13:02:00</time> + <version> + <release>0.0.1</release> + <api>0.0.1</api> + </version> + <stability> + <release>alpha</release> + <api>alpha</api> + </stability> + <license uri="http://www.symfony-project.org/license">MIT license</license> + <notes>-</notes> + <contents> + <dir name="/"> + <file role="data" name="README" /> + <file role="data" name="LICENSE" /> + <dir name="config"> + <file role="data" name="app.yml" /> + <file role="data" name="routing.yml" /> + <file role="data" name="settings.yml" /> + </dir> + <dir name="data"> + <dir name="fixtures"> + <file role="data" name="users.yml" /> + </dir> + </dir> + <dir name="lib"> + <dir name="doctrine"> + <dir name="Listener"> + <file role="data" name="TrafficCMS.php" /> + </dir> + <file role="data" name="TrafficCMS.php" /> + </dir> + <dir name="filter"> + <file role="data" name="TrafficCMSBaseFilter.class.php" /> + </dir> + <dir name="form"> + <file role="data" name="TrafficCMSBaseForm.class.php" /> + </dir> + <dir name="task"> + <file role="data" name="trafficcmsGenerateadminmodulesTask.class.php" /> + </dir> + </dir> + <dir name="modules"> + <dir name="sfTrafficCMSPlugin"> + <dir name="actions"> + <file role="data" name="actions.class.php" /> + </dir> + <dir name="templates"> + <file role="data" name="_navigation_menu.php" /> + </dir> + </dir> + </dir> + </dir> + </contents> + <dependencies> + <required> + <php> + <min>5.2.0</min> + </php> + <pearinstaller> + <min>1.4.1</min> + </pearinstaller> + <package> + <name>symfony</name> + <channel>pear.symfony-project.com</channel> + <min>1.2.0</min> + <max>2.0.0</max> + <exclude>2.0.0</exclude> + </package> + </required> + </dependencies> + <phprelease /> + <changelog> + <release> + <version> + <release>0.0.1</release> + <api>0.0.1</api> + </version> + <stability> + <release>alpha</release> + <api>alpha</api> + </stability> + <license uri="http://www.symfony-project.org/license">MIT license</license> + <date>2010-01-21</date> + <notes> + First version of the package + </notes> + </release> + </changelog> +</package> \ 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.
