function test_tag_creation(lime_test $t, ioEditableContentService $service, $tag, $fields, $options = array(), $attributes = array()) { $blog = Doctrine_Query::create()->from('Blog')->fetchOne(); // get the actual result, leave only the opening tag, which is all we care about $combined = array_merge($options, $attributes); $result = $service->getEditableContentTag($tag, $blog, $fields, $combined); $matches = array(); preg_match('#\\<' . $tag . '([^\\>]+)\\>#', $result, $matches); $result = $matches[0]; if (isset($attributes['class'])) { $attributes['class'] .= ' ' . $service->getOption('editable_class_name', 'io_editable_content'); } else { $attributes['class'] = $service->getOption('editable_class_name', 'io_editable_content'); } if (!isset($options['mode'])) { $options['mode'] = $service->getOption('edit_mode', 'fancybox'); } if (!isset($options['default_values'])) { $options['default_values'] = array(); } $options['model'] = 'Blog'; $options['pk'] = $blog->id; $options['fields'] = (array) $fields; $attributes['class'] .= ' ' . json_encode($options); // get the result, leave only the opening tag, which is all we care about $expected = content_tag($tag, 'anything', $attributes); $expected = str_replace('anything</' . $tag . '>', '', $expected); $t->is($result, $expected, 'Opening tag rendered correctly: ' . $result); }
/** * Automatic plugin modules and helper loading * * @param sfEvent $event */ public function listenToContextLoadFactories(sfEvent $event) { // Enable module automatically sfConfig::set('sf_enabled_modules', array_merge(sfConfig::get('sf_enabled_modules', array()), array('ioEditableContent'))); // Load helper as well $event->getSubject()->getConfiguration()->loadHelpers(array('EditableContent')); // create the editable content service $this->_editableContentService = $this->_createEditableContentService($event->getSubject()->getUser()); // load the editor assets if ($this->_editableContentService->shouldShowEditor()) { $this->_loadEditorAssets($event->getSubject()); } }