本文整理汇总了PHP中sfSympalConfig::isI18nEnabled方法的典型用法代码示例。如果您正苦于以下问题:PHP sfSympalConfig::isI18nEnabled方法的具体用法?PHP sfSympalConfig::isI18nEnabled怎么用?PHP sfSympalConfig::isI18nEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfSympalConfig
的用法示例。
在下文中一共展示了sfSympalConfig::isI18nEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup
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);
}
示例2: _getQueryForContentObjects
/**
* 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;
}
示例3: getDefaultPagesDataGrid
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');
}
}
示例4: _getMenuItem
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;
}
示例5: getMenusQuery
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;
}
示例6: embedI18n
/**
* 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);
}
}
示例7: setup
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();
}
示例8: _getContentSlotColumnForm
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;
}
示例9: getLabel
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;
}
示例10: _getContentSlotColumnForm
/**
* 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;
}
示例11: _buildRouteValues
/**
* 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;
}
示例12: hasField
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;
}
示例13: include_partial
<?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>
示例14: loadConfigForm
/**
* 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');
}
示例15: loadEditor
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));
}
}
}
}