public function setup()
 {
     parent::setup();
     $q = Doctrine_Query::create()->from('sfSympalMenuItem m');
     if ($this->object->exists()) {
         $q->andWhere('m.id != ?', $this->object->id);
     }
     if (sfSympalConfig::isI18nEnabled('sfSympalMenuItem')) {
         $q->leftJoin('m.Translation mt');
     }
     $q->andWhere('m.site_id = ?', sfSympalContext::getInstance()->getService('site_manager')->getSite()->getId());
     $this->widgetSchema['parent_id'] = new sfWidgetFormDoctrineChoice(array('model' => 'sfSympalMenuItem', 'add_empty' => __('~ (object is at root level)'), 'order_by' => array('root_id, lft', ''), 'query' => $q, 'method' => 'getIndentedName'));
     $this->validatorSchema['parent_id'] = new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'sfSympalMenuItem'));
     $this->setDefault('parent_id', $this->object->getParentId());
     $this->widgetSchema->setLabel('parent_id', 'Child of');
     $this->widgetSchema['move'] = new sfWidgetFormDoctrineChoice(array('model' => 'sfSympalMenuItem', 'add_empty' => true, 'order_by' => array('root_id, lft', ''), 'query' => $q, 'method' => 'getIndentedName'));
     $this->validatorSchema['move'] = new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'sfSympalMenuItem'));
     $this->widgetSchema->setLabel('move', 'Position menu item');
     $choices = array('' => '', 'Prev' => 'Before', 'Next' => 'After');
     $this->widgetSchema['where_to_move'] = new sfWidgetFormChoice(array('choices' => $choices));
     $this->validatorSchema['where_to_move'] = new sfValidatorChoice(array('required' => false, 'choices' => array_keys($choices)));
     $this->widgetSchema->setLabel('where_to_move', 'Position before or after?');
     unset($this['site_id'], $this['Content'], $this['root_id'], $this['lft'], $this['rgt'], $this['level']);
     $this->validatorSchema['slug']->setOption('required', true);
 }
 /**
  * Returns the query that should be used if we need to query out
  * and get a collection of sfSympalContent objects
  */
 protected function _getQueryForContentObjects($slugs)
 {
     $q = Doctrine_Core::getTable('sfSympalContent')->createQuery('c')->select('c.*, t.*')->from('sfSympalContent c')->innerJoin('c.Type t')->innerJoin('c.Site s')->whereIn('c.slug', array_unique($slugs))->andWhere('s.slug = ?', sfConfig::get('sf_app'))->orderBy('c.slug ASC');
     if (sfSympalConfig::isI18nEnabled('sfSympalContent')) {
         $q->leftJoin('c.Translation ct');
     }
     return $q;
 }
 public function getDefaultPagesDataGrid()
 {
     $dataGrid = sfSympalDataGrid::create(Doctrine_Core::getTable('sfSympalContent')->getFullTypeQuery('sfSympalPage'));
     if (sfSympalConfig::isI18nEnabled()) {
         return $dataGrid->addColumn('crt.title', 'renderer=sympal_page/data_grid_title')->addColumn('c.date_published')->addColumn('u.username', 'label=Created By')->setDefaultSort('crt.title');
     } else {
         return $dataGrid->addColumn('cr.title', 'renderer=sympal_page/data_grid_title')->addColumn('c.date_published')->addColumn('u.username', 'label=Created By')->setDefaultSort('cr.title');
     }
 }
 protected function _getMenuItem(sfWebRequest $request)
 {
     $q = Doctrine_Core::getTable('sfSympalMenuItem')->createQuery('m')->leftJoin('m.Groups g')->where('m.id = ?', $request->getParameter('id'));
     if (sfSympalConfig::isI18nEnabled('sfSympalMenuItem')) {
         $q->leftJoin('m.Translation mt');
     }
     $menuItem = $q->fetchOne();
     $this->forward404Unless($menuItem);
     return $menuItem;
 }
 public function getMenusQuery()
 {
     $q = $this->createQuery()->from('sfSympalMenuItem m INDEXBY m.id')->addSelect('m.*')->leftJoin('m.Groups g')->addSelect('g.id, g.name')->leftJoin('g.Permissions gp')->addSelect('gp.id, gp.name')->leftJoin('m.RelatedContent c')->addSelect('c.id, c.custom_path, c.slug, c.date_published')->leftJoin('c.Type ct')->addSelect('ct.id, ct.name, ct.default_path, ct.slug')->innerJoin('m.Site s WITH s.slug = ?', sfConfig::get('sf_app'))->orderBy('m.root_id, m.lft ASC');
     if (sfSympalConfig::isI18nEnabled('sfSympalContent')) {
         $q->leftJoin('c.Translation ctr');
         $q->addSelect('ctr.*');
     }
     if (sfSympalConfig::isI18nEnabled('sfSympalMenuItem')) {
         $q->leftJoin('m.Translation t');
         $q->addSelect('t.*');
     }
     return $q;
 }
 /**
  * Embed i18n to the given form if it is enabled
  *
  * @param string $name 
  * @param sfForm $form 
  * @return void
  */
 public static function embedI18n($name, sfForm $form)
 {
     if (sfSympalConfig::isI18nEnabled($name)) {
         $context = sfContext::getInstance();
         $culture = $context->getUser()->getEditCulture();
         $form->embedI18n(array(strtolower($culture)));
         $widgetSchema = $form->getWidgetSchema();
         $context->getConfiguration()->loadHelpers(array('Helper'));
         $c = sfCultureInfo::getInstance($culture);
         $languages = $c->getLanguages();
         $language = isset($languages[$culture]) ? $languages[$culture] : '';
         $widgetSchema[$culture]->setLabel($language);
     }
 }
 public function setup()
 {
     parent::setup();
     $this->validatorSchema->setOption('allow_extra_fields', true);
     unset($this['site_id'], $this['created_at'], $this['updated_at'], $this['last_updated_by_id'], $this['slots_list'], $this['links_list'], $this['assets_list']);
     $q = Doctrine_Query::create()->from('sfSympalMenuItem m')->orderBy('m.root_id, m.lft ASC');
     if (sfSympalConfig::isI18nEnabled('sfSympalMenuItem')) {
         $q->leftJoin('m.Translation mt');
     }
     if (!$this->object->content_type_id) {
         $this->object->Type = Doctrine_Core::getTable('sfSympalContentType')->findOneBySlug('page');
     } else {
         $this->object->Type;
     }
     $this->_embedTypeForm();
 }
 protected function _getContentSlotColumnForm()
 {
     $content = $this->getContentRenderedFor();
     $contentTable = $content->getTable();
     if ($contentTable->hasField($this->name)) {
         $formClass = sfSympalConfig::get('inline_editing', 'default_column_form');
         $form = new $formClass($content);
         $form->useFields(array($this->name));
     }
     if (sfSympalConfig::isI18nEnabled('sfSympalContent')) {
         $contentTranslationTable = Doctrine::getTable('sfSympalContentTranslation');
         if ($contentTranslationTable->hasField($this->name)) {
             $formClass = sfSympalConfig::get('inline_editing', 'default_column_form');
             $form = new $formClass($content);
             $form->useFields(array(sfContext::getInstance()->getUser()->getEditCulture()));
         }
     }
     $contentTypeClassName = $content->getContentTypeClassName();
     $contentTypeFormClassName = sfSympalConfig::get($contentTypeClassName, 'default_inline_editing_column_form', $contentTypeClassName . 'Form');
     $contentTypeTable = Doctrine_Core::getTable($contentTypeClassName);
     if ($contentTypeTable->hasField($this->name)) {
         $form = new $contentTypeFormClassName($content->getRecord());
         $form->useFields(array($this->name));
     }
     if (sfSympalConfig::isI18nEnabled($contentTypeClassName)) {
         $contentTypeTranslationClassName = $contentTypeClassName . 'Translation';
         $contentTypeTranslationFormClassName = sfSympalConfig::get($contentTypeTranslationClassName, 'default_inline_editing_column_form', $contentTypeTranslationClassName . 'Form');
         $contentTypeTranslationTable = Doctrine_Core::getTable($contentTypeTranslationClassName);
         if ($contentTypeTranslationTable->hasField($this->name)) {
             $form = new $contentTypeFormClassName($content->getRecord());
             $i18nForm = $form->getEmbeddedForm($language = sfContext::getInstance()->getUser()->getEditCulture());
             $i18nForm->useFields(array($this->name));
             unset($form[$language]);
             $form->embedForm($language, $i18nForm);
             $form->useFields(array($language));
         }
     }
     if (!$form) {
         throw new InvalidArgumentException('Invalid content slot');
     }
     return $form;
 }
Exemplo n.º 9
0
 public function getLabel()
 {
     $label = null;
     if (sfSympalConfig::isI18nEnabled('sfSympalMenuItem')) {
         $culture = sfContext::getInstance()->getUser()->getCulture();
         if (isset($this->_menuItemArray['Translation'][$culture]['label'])) {
             $label = $this->_menuItemArray['Translation'][$culture]['label'];
         }
         if (!$label && isset($this->_menuItemArray['Translation'][sfConfig::get('sf_default_culture')]['label'])) {
             $label = $this->_menuItemArray['Translation'][sfConfig::get('sf_default_culture')]['label'];
         }
     } else {
         if (isset($this->_menuItemArray['label'])) {
             $label = $this->_menuItemArray['label'];
         }
     }
     if (!$label) {
         $label = parent::getLabel();
     }
     return $label;
 }
 /**
  * Retrieves the form class used to edit slot for "column slots".
  * 
  * This is used by sfSympalFormToolkit::changeContentSlotValueWidget()
  * to extract the widget & validator out so we can put it into the 
  * content slot form
  * 
  * @return sfForm
  */
 protected function _getContentSlotColumnForm()
 {
     $content = $this->getContentRenderedFor();
     $contentTable = $content->getTable();
     if ($contentTable->hasField($this->name)) {
         $formClass = sfSympalConfig::get('inline_editing', 'default_column_form');
         $form = new $formClass($content);
         $form->useFields(array($this->name));
         /*
          * For "column" slots, the widget and validator of the type are
          * not set automatically in the form itself (as opposed to true
          * slots who use sfSympalContentSlotForm, where the widget and
          * validator are setup automatically. This is a shortcoming. We
          * manually set the widget and validator here for content slots
          */
         sfSympalFormToolkit::changeContentSlotValueWidget($this, $form);
     }
     if (sfSympalConfig::isI18nEnabled('sfSympalContent')) {
         $contentTranslationTable = Doctrine::getTable('sfSympalContentTranslation');
         if ($contentTranslationTable->hasField($this->name)) {
             $formClass = sfSympalConfig::get('inline_editing', 'default_column_form');
             $form = new $formClass($content);
             $form->useFields(array(sfContext::getInstance()->getUser()->getEditCulture()));
             /*
              * @TODO There should be a changeContentSlotValueWidget() call here,
              * but I don't seem to have access to the underlying translation
              * form, which is what you really want to pass into that function
              */
         }
     }
     $contentTypeClassName = $content->getContentTypeClassName();
     $contentTypeFormClassName = sfSympalConfig::get($contentTypeClassName, 'default_inline_editing_column_form', $contentTypeClassName . 'Form');
     $contentTypeTable = Doctrine_Core::getTable($contentTypeClassName);
     if ($contentTypeTable->hasField($this->name)) {
         $form = new $contentTypeFormClassName($content->getRecord());
         $form->useFields(array($this->name));
         //See above note about this
         sfSympalFormToolkit::changeContentSlotValueWidget($this, $form);
     }
     if (sfSympalConfig::isI18nEnabled($contentTypeClassName)) {
         $contentTypeTranslationClassName = $contentTypeClassName . 'Translation';
         $contentTypeTranslationFormClassName = sfSympalConfig::get($contentTypeTranslationClassName, 'default_inline_editing_column_form', $contentTypeTranslationClassName . 'Form');
         $contentTypeTranslationTable = Doctrine_Core::getTable($contentTypeTranslationClassName);
         if ($contentTypeTranslationTable->hasField($this->name)) {
             $form = new $contentTypeFormClassName($content->getRecord());
             $i18nForm = $form->getEmbeddedForm($language = sfContext::getInstance()->getUser()->getEditCulture());
             $i18nForm->useFields(array($this->name));
             //See above note about this
             sfSympalFormToolkit::changeContentSlotValueWidget($this, $form);
             unset($form[$language]);
             $form->embedForm($language, $i18nForm);
             $form->useFields(array($language));
         }
     }
     if (!$form) {
         throw new InvalidArgumentException('Invalid content slot');
     }
     return $form;
 }
 /**
  * Build the array of all culture values for the given content record
  *
  * @param sfSympalContent $content 
  * @return array $routeValues
  */
 protected function _buildRouteValues(sfSympalContent $content)
 {
     $variables = $this->getRouteObject()->getVariables();
     $isI18nEnabled = sfSympalConfig::isI18nEnabled();
     $languageCodes = $isI18nEnabled ? sfSympalConfig::getLanguageCodes() : array($this->getCurrentCulture());
     $values = array();
     foreach ($languageCodes as $code) {
         foreach (array_keys($variables) as $name) {
             if ($isI18nEnabled && $name == 'slug' && ($i18nSlug = $content->Translation[$code]->i18n_slug)) {
                 $values[$code][$name] = $i18nSlug;
             } else {
                 if ($content->hasField($name)) {
                     if ($isI18nEnabled && isset($content->Translation[$code]->{$name})) {
                         $values[$code][$name] = $content->Translation[$code]->{$name};
                     } else {
                         $values[$code][$name] = $content->{$name};
                     }
                 } else {
                     if (method_exists($content, $method = 'get' . sfInflector::camelize($name))) {
                         $values[$code][$name] = $content->{$method}();
                     }
                 }
             }
         }
     }
     return $values;
 }
 public function hasField($name)
 {
     $result = $this->_table->hasField($name);
     if (!$result) {
         $className = get_class($this);
         if (sfSympalConfig::isI18nEnabled($className)) {
             $table = Doctrine_Core::getTable($className . 'Translation');
             if ($table->hasField($name)) {
                 $result = true;
             }
         }
     }
     if (!$result) {
         $className = $this->getType()->getName();
         $table = Doctrine_Core::getTable($className);
         if ($table->hasField($name)) {
             $result = true;
         }
         if (sfSympalConfig::isI18nEnabled($className)) {
             $table = Doctrine_Core::getTable($className . 'Translation');
             if ($table->hasField($name)) {
                 $result = true;
             }
         }
     }
     return $result;
 }
Exemplo n.º 13
0
<?php

include_partial('sympal_edit_slot/slot_messages');
?>

<?php 
if (sfSympalConfig::isI18nEnabled('sfSympalContentSlot')) {
    ?>
  <?php 
    echo $form[$sf_user->getEditCulture()]['value'];
} else {
    ?>
  <?php 
    echo $form['value'];
}
?>

<script type="text/javascript">
<?php 
if (sfSympalConfig::get('elastic_textareas', null, true)) {
    ?>
$(function() {
  $('#sympal_slot_wrapper_<?php 
    echo $contentSlot->getId();
    ?>
 form textarea').elastic();
});
<?php 
}
?>
</script>
 /**
  * Listens to sympal.load_config_form to load the configuration form
  */
 public function loadConfigForm(sfEvent $event)
 {
     $form = $event->getSubject();
     if (sfSympalConfig::isI18nEnabled()) {
         $cultures = sfCultureInfo::getCultures(sfCultureInfo::NEUTRAL);
         $languages = array();
         foreach ($cultures as $key => $value) {
             $formatted = format_language($value);
             if (!$formatted) {
                 $formatted = format_language($value, 'en');
             }
             if ($formatted) {
                 $languages[$value] = $formatted;
             }
         }
         asort($languages);
         $widget = new sfWidgetFormChoice(array('multiple' => true, 'choices' => $languages));
         $validator = new sfValidatorChoice(array('multiple' => true, 'choices' => array_keys($languages)));
         $form->addSetting(null, 'language_codes', 'Available Cultures', $widget, $validator);
         $languageForm = new sfFormLanguage(sfContext::getInstance()->getUser(), array('languages' => sfSympalConfig::getLanguageCodes()));
         $widgetSchema = $languageForm->getWidgetSchema();
         $validatorSchema = $languageForm->getValidatorSchema();
         $form->addSetting(null, 'default_culture', 'Default Culture', $widgetSchema['language'], $validatorSchema['language']);
     }
     $form->addSetting(null, 'default_rendering_module', 'Default Rendering Module');
     $form->addSetting(null, 'default_rendering_action', 'Default Rendering Action');
     $form->addSetting(null, 'breadcrumbs_separator', 'Breadcrumbs Separator');
     $form->addSetting(null, 'elastic_textareas', 'Elastic Textareas', 'InputCheckbox', 'Boolean');
     $form->addSetting(null, 'check_for_upgrades_on_dashboard', 'Check for Upgrades', 'InputCheckbox', 'Boolean');
     $form->addSetting('page_cache', 'enabled', 'Enabled?', 'InputCheckbox', 'Boolean');
     $form->addSetting('page_cache', 'super', 'Enable Super Cache?', 'InputCheckbox', 'Boolean');
     $form->addSetting('page_cache', 'with_layout', 'With layout?', 'InputCheckbox', 'Boolean');
     $form->addSetting('page_cache', 'lifetime', 'Lifetime');
 }
 public function loadEditor(sfEvent $event)
 {
     $user = sfContext::getInstance()->getUser();
     $this->configuration->loadHelpers(array('Asset', 'Partial', 'I18N'));
     $menu = $event->getSubject();
     $content = $event['content'];
     $menuItem = $event['menuItem'];
     $sympalConfiguration = sfSympalConfiguration::getActive();
     $user = sfContext::getInstance()->getUser();
     $request = sfContext::getInstance()->getRequest();
     $contentEditor = $menu->getChild($content->getType()->getLabel() . ' Actions');
     if ($sympalConfiguration->isAdminModule()) {
         $contentEditor->addChild(image_tag('/sf/sf_admin/images/list.png') . ' ' . __('View ' . $content->getType()->getLabel()), $content->getRoute());
     }
     $contentEditor->addChild(image_tag('/sf/sf_admin/images/add.png') . ' ' . __('Create New ' . $content->getType()->getLabel()), '@sympal_content_create_type?type=' . $content['Type']['slug'])->setCredentials('ManageContent');
     $contentEditor->addChild(image_tag('/sf/sf_admin/images/edit.png') . ' ' . __('Edit ' . $content->getType()->getLabel()), $content->getEditRoute())->setCredentials('ManageContent');
     $contentEditor->addChild(image_tag('/sf/sf_admin/images/edit.png') . ' ' . __('Edit Content Type'), '@sympal_content_types_edit?id=' . $content->getType()->getId())->setCredentials('ManageMenus');
     if ($menuItem && $menuItem->exists()) {
         $contentEditor->addChild(image_tag('/sf/sf_admin/images/edit.png') . ' ' . __('Edit Menu Item'), '@sympal_content_menu_item?id=' . $content->getId())->setCredentials('ManageMenus');
     } else {
         $contentEditor->addChild(image_tag('/sf/sf_admin/images/add.png') . ' ' . __('Add to Menu'), '@sympal_content_menu_item?id=' . $content->getId())->setCredentials('ManageMenus');
     }
     if (sfSympalConfig::isI18nEnabled()) {
         foreach (sfSympalConfig::getLanguageCodes() as $code) {
             if (sfContext::getInstance()->getUser()->getEditCulture() != $code) {
                 $contentEditor->addChild(image_tag('/sfSympalPlugin/images/flags/' . strtolower($code) . '.png') . ' Edit ' . format_language($code), '@sympal_change_edit_language?language=' . $code, 'title=Switch to ' . format_language($code));
             }
         }
     }
 }
Exemplo n.º 16
0
<?php

$app = 'sympal';
require_once dirname(__FILE__) . '/../bootstrap/unit.php';
$t = new lime_test(6);
sfSympalConfig::set('test', true);
$t->is(sfSympalConfig::get('test'), true);
sfSympalConfig::set('group', 'test', true);
$t->is(sfSympalConfig::get('group', 'test'), true);
$t->is(sfSympalConfig::get('doesnt_exists', null, 'default_value'), 'default_value');
sfSympalConfig::writeSetting('test_write_value', 1);
$path = sfConfig::get('sf_config_dir') . '/app.yml';
$array = (array) sfYaml::load(file_get_contents($path));
$t->is(isset($array['all']['sympal_config']['test_write_value']), true);
$t->is(sfSympalConfig::isI18nEnabled(), false);
$t->is(sfSympalConfig::isI18nEnabled('sfSympalContent'), false);
 public function getBaseQuery($alias = 'c')
 {
     $q = Doctrine_Query::create()->from('sfSympalContent ' . $alias)->leftJoin($alias . '.Groups g')->leftJoin('g.Permissions gp')->leftJoin($alias . '.EditGroups eg')->leftJoin('eg.Permissions egp')->leftJoin($alias . '.Slots s')->leftJoin($alias . '.MenuItem m')->leftJoin($alias . '.Links l')->leftJoin('l.Type lt')->leftJoin($alias . '.Assets a')->leftJoin($alias . '.CreatedBy u')->innerJoin($alias . '.Type t')->innerJoin(sprintf($alias . ".Site si WITH si.slug = '%s'", sfConfig::get('sf_app')));
     if (sfSympalConfig::isI18nEnabled('sfSympalContentSlot')) {
         $q->leftJoin('s.Translation slt');
     }
     if (sfSympalConfig::isI18nEnabled('sfSympalContent')) {
         $q->leftJoin($alias . '.Translation ct');
     }
     return $q;
 }
 /**
  * Called by sfInlineObjectDoctrineResource to create a query that
  * will return a collection of objects given the array of keys and
  * key column
  */
 public function getQueryForInlineObjects($keys, $keyColumn)
 {
     $q = $this->createQuery('c')->whereIn('c.' . $keyColumn, $keys)->orderBy('c.' . $keyColumn . ' ASC')->select('c.*, t.*')->from('sfSympalContent c')->innerJoin('c.Type t')->innerJoin('c.Site s')->andWhere('s.slug = ?', sfConfig::get('sf_app'));
     if (sfSympalConfig::isI18nEnabled('sfSympalContent')) {
         $q->leftJoin('c.Translation ct');
     }
     return $q;
 }
 /**
  * Listens to the sympal.load_admin_menu to configure the admin menu
  */
 public function setupAdminMenu(sfEvent $event)
 {
     $menu = $event->getSubject();
     // Setup the Content menu
     $manageContent = $menu->getChild('content');
     $manageContent->setLabel('Content');
     $manageContent->addChild('Search', '@sympal_admin_search');
     $contentTypes = Doctrine_Core::getTable('sfSympalContentType')->getAllContentTypes();
     foreach ($contentTypes as $contentType) {
         $manageContent->addChild($contentType->getLabel(), '@sympal_content_list_type?type=' . $contentType->getId())->setCredentials(array('ManageContent'));
     }
     $manageContent->addChild('Slots', '@sympal_content_slots')->setCredentials(array('ManageSlots'));
     $manageContent->addChild('XML Sitemap', '@sympal_sitemap')->setCredentials(array('ViewXmlSitemap'));
     // Setup the Site Administration menu
     $siteAdministration = $menu->getChild('site_administration');
     $siteAdministration->setLabel('Site Administration');
     $siteAdministration->addChild('404 Redirects', '@sympal_redirects')->setCredentials(array('ManageRedirects'));
     $siteAdministration->addChild('Edit Site', '@sympal_sites_edit?id=' . sfSympalContext::getInstance()->getService('site_manager')->getSite()->getId())->setCredentials(array('ManageSites'));
     // Add to the Administration menu
     $administration = $menu->getChild('administration');
     $administration->addChild('Content Types', '@sympal_content_types')->setCredentials(array('ManageContentTypes'));
     $administration->addChild('Sites', '@sympal_sites')->setCredentials(array('ManageSites'));
     // Add a Content menu if applicable
     $content = $this->_sympalContext->getService('site_manager')->getCurrentContent();
     if ($content) {
         $contentEditor = $menu->getChild($content->getType()->slug);
         $contentEditor->setLabel(sprintf(__('%s Actions'), $content->getType()->getLabel()));
         // If in the admin, put a link to view the content
         if (sfSympalConfiguration::getActive()->isAdminModule()) {
             $contentEditor->addChild(sprintf(__('View %s'), $content->getType()->getLabel()), $content->getRoute());
         }
         $contentEditor->addChild(sprintf(__('Create New %s'), $content->getType()->getLabel()), '@sympal_content_create_type?type=' . $content['Type']['slug'])->setCredentials('ManageContent');
         $contentEditor->addChild(sprintf(__('Edit %s'), $content->getType()->getLabel()), $content->getEditRoute())->setCredentials('ManageContent');
         $contentEditor->addChild(__('Edit Content Type'), '@sympal_content_types_edit?id=' . $content->getType()->getId())->setCredentials('ManageMenus');
         // Add a menu item entry
         $menuItem = $this->_sympalContext->getService('menu_manager')->getCurrentMenuItem();
         if ($menuItem && $menuItem->exists()) {
             $contentEditor->addChild(__('Edit Menu Item'), '@sympal_content_menu_item?id=' . $content->getId())->setCredentials('ManageMenus');
         } else {
             $contentEditor->addChild(__('Add to Menu'), '@sympal_content_menu_item?id=' . $content->getId())->setCredentials('ManageMenus');
         }
         // Add publish/unpublish icons
         $user = sfContext::getInstance()->getUser();
         if ($user->hasCredential('PublishContent')) {
             if ($content->getIsPublished()) {
                 $contentEditor->addChild(__('Unpublish'), '@sympal_unpublish_content?id=' . $content->id, 'title=' . __('Published on %date%', array('%date%' => format_date($content->getDatePublished(), 'g'))) . '. ' . __('Click to unpublish content.'));
             } elseif ($content->getIsPublishInTheFuture()) {
                 $contentEditor->addChild(__('Unpublish'), '@sympal_unpublish_content?id=' . $content->id, 'title=' . __('Will publish on %date%', array('%date%' => format_date($content->getDatePublished(), 'g'))) . '. ' . __('Click to unpublish content.'));
             } else {
                 $contentEditor->addChild(__('Publish'), '@sympal_publish_content?id=' . $content->id, 'title=' . __('Has not been published yet. ' . __('Click to publish content.')));
             }
         }
         if (sfSympalConfig::isI18nEnabled()) {
             foreach (sfSympalConfig::getLanguageCodes() as $code) {
                 if (sfContext::getInstance()->getUser()->getEditCulture() != $code) {
                     $contentEditor->addChild(sprintf(__('Edit in %s'), format_language($code)), '@sympal_change_edit_language?language=' . $code, 'title=' . sprintf(__('Edit %s version'), format_language($code)));
                 }
             }
         }
     }
 }
 public function loadEditor(sfEvent $event)
 {
     $user = sfContext::getInstance()->getUser();
     $this->configuration->loadHelpers(array('Asset', 'Partial', 'I18N'));
     $menu = $event->getSubject();
     $content = $event['content'];
     $menuItem = $event['menuItem'];
     $sympalConfiguration = sfSympalConfiguration::getActive();
     $user = sfContext::getInstance()->getUser();
     $request = sfContext::getInstance()->getRequest();
     $contentEditor = $menu->getChild($content->getType()->getLabel() . ' Actions');
     if ($sympalConfiguration->isAdminModule()) {
         $contentEditor->addChild(__('View ') . $content->getType()->getLabel(), $content->getRoute());
     }
     $contentEditor->addChild(__('Create New ') . $content->getType()->getLabel(), '@sympal_content_create_type?type=' . $content['Type']['slug'])->setCredentials('ManageContent');
     $contentEditor->addChild(__('Edit ') . $content->getType()->getLabel(), $content->getEditRoute())->setCredentials('ManageContent');
     $contentEditor->addChild(__('Edit Content Type'), '@sympal_content_types_edit?id=' . $content->getType()->getId())->setCredentials('ManageMenus');
     if ($menuItem && $menuItem->exists()) {
         $contentEditor->addChild(__('Edit Menu Item'), '@sympal_content_menu_item?id=' . $content->getId())->setCredentials('ManageMenus');
     } else {
         $contentEditor->addChild(__('Add to Menu'), '@sympal_content_menu_item?id=' . $content->getId())->setCredentials('ManageMenus');
     }
     if (sfSympalConfig::isI18nEnabled()) {
         foreach (sfSympalConfig::getLanguageCodes() as $code) {
             if (sfContext::getInstance()->getUser()->getEditCulture() != $code) {
                 $contentEditor->addChild(__('Edit ') . format_language($code), '@sympal_change_edit_language?language=' . $code, 'title=' . __('Switch to ') . '' . format_language($code));
             }
         }
     }
     if ($user->hasCredential('PublishContent')) {
         if ($content->getIsPublished()) {
             $contentEditor->addChild(__('Unpublish'), '@sympal_unpublish_content?id=' . $content['id'], 'title=' . __('Published on %date%', array('%date%' => format_date($content->getDatePublished(), 'g'))) . '. ' . __('Click to unpublish content.'));
         } elseif ($content->getIsPublishInTheFuture()) {
             $contentEditor->addChild(__('Unpublish'), '@sympal_unpublish_content?id=' . $content['id'], 'title=' . __('Will publish on %date%', array('%date%' => format_date($content->getDatePublished(), 'g'))) . '. ' . __('Click to unpublish content.'));
         } else {
             $contentEditor->addChild(__('Publish'), '@sympal_publish_content?id=' . $content['id'], 'title=' . __('Has not been published yet. ' . __('Click to publish content.')));
         }
     }
 }
Exemplo n.º 21
0
<?php

$app = 'sympal';
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(6);
sfSympalConfig::set('test', true);
$t->is(sfSympalConfig::get('test'), true, '->get() works with just one argument');
sfSympalConfig::set('group', 'test', true);
$t->is(sfSympalConfig::get('group', 'test'), true, '->get() works using the group arugment');
$t->is(sfSympalConfig::get('doesnt_exists', null, 'default_value'), 'default_value', '->get() returns a default value if the key does not exist');
sfSympalConfig::writeSetting('test_write_value', 1);
$path = sfConfig::get('sf_config_dir') . '/app.yml';
$array = (array) sfYaml::load(file_get_contents($path));
$t->is(isset($array['all']['sympal_config']['test_write_value']), true, '->writeSetting() writes out correctly to the config/app.yml file');
$t->is(sfSympalConfig::isI18nEnabled(), false, '->isI18nEnabled() correctly returns false');
$t->is(sfSympalConfig::isI18nEnabled('sfSympalContent'), false, '->isI18nEnabled($modelName) correctly returns false');
<?php

use_helper('SympalContentSlotEditor');
echo trigger_flash_from_user($sf_user);
if ($contentSlot->getIsColumn()) {
    ?>
  <?php 
    if (sfSympalConfig::isI18nEnabled('sfSympalContentSlot') && !isset($form[$contentSlot->getName()])) {
        ?>
    <?php 
        echo $form[$sf_user->getEditCulture()][$contentSlot->getName()];
        ?>
  <?php 
    } else {
        ?>
    <?php 
        echo $form[$contentSlot->getName()];
        ?>
  <?php 
    }
} else {
    ?>
  <?php 
    echo $form['galleries_list'];
    ?>
  <a class="gallery_toggle_detail" href="#" onclick="return false;">Gallery parameters</a>
  <div class="gallery_parameters" style="display: none">
  <?php 
    echo $form['gallery_parameters'];
    ?>