当前位置: 首页>>代码示例>>PHP>>正文


PHP sfSympalConfig::getLanguageCodes方法代码示例

本文整理汇总了PHP中sfSympalConfig::getLanguageCodes方法的典型用法代码示例。如果您正苦于以下问题:PHP sfSympalConfig::getLanguageCodes方法的具体用法?PHP sfSympalConfig::getLanguageCodes怎么用?PHP sfSympalConfig::getLanguageCodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sfSympalConfig的用法示例。


在下文中一共展示了sfSympalConfig::getLanguageCodes方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: executeLanguage

 public function executeLanguage(sfWebRequest $request)
 {
     $this->form = new sfFormLanguage($this->getUser(), array('languages' => sfSympalConfig::getLanguageCodes()));
     unset($this->form[$this->form->getCSRFFieldName()]);
     $widgetSchema = $this->form->getWidgetSchema();
     $widgetSchema->setLabel('language', 'Select Language');
 }
开发者ID:sympal,项目名称:sympal,代码行数:7,代码来源:Basesympal_defaultComponents.class.php

示例2: executeChange_language

 /**
  * Changes the user's culture
  */
 public function executeChange_language(sfWebRequest $request)
 {
     $oldCulture = $this->getUser()->getCulture();
     $this->form = new sfFormLanguage($this->getUser(), array('languages' => sfSympalConfig::getLanguageCodes()));
     unset($this->form[$this->form->getCSRFFieldName()]);
     $this->form->process($request);
     $newCulture = $this->getUser()->getCulture();
     $this->getUser()->setFlash('notice', 'Changed language successfully!');
     return $this->redirect(str_replace('/' . $oldCulture . '/', '/' . $newCulture . '/', $this->getRequest()->getReferer($this->getUser()->getReferer('@homepage'))));
 }
开发者ID:sympal,项目名称:sympal,代码行数:13,代码来源:Basesympal_defaultActions.class.php

示例3: getContentRoutesYaml

    /**
     * Get the content routes yaml
     *
     * @return string $yaml
     */
    public static function getContentRoutesYaml()
    {
        $cachePath = sfConfig::get('sf_cache_dir') . '/' . sfConfig::get('sf_app') . '/' . sfConfig::get('sf_environment') . '/content_routes.cache.yml';
        if (file_exists($cachePath) && sfConfig::get('sf_environment') !== 'test') {
            return file_get_contents($cachePath);
        }
        try {
            $routeTemplate = '%s:
  url:   %s
  param:
    module: %s
    action: %s
    sf_format: html
    sympal_content_type: %s
    sympal_content_type_id: %s
    sympal_content_id: %s
  class: sfDoctrineRoute
  options:
    model: sfSympalContent
    type: object
    method: getContent
    allow_empty: true
    requirements:
      sf_culture:  (%s)
      sf_format:   (%s)
      sf_method:   [post, get]
';
            $routes = array();
            $siteSlug = sfConfig::get('sf_app');
            $contents = Doctrine::getTable('sfSympalContent')->createQuery('c')->leftJoin('c.Type t')->innerJoin('c.Site s')->where("c.custom_path IS NOT NULL AND c.custom_path != ''")->andWhere('s.slug = ?', $siteSlug)->execute();
            foreach ($contents as $content) {
                $routes['content_' . $content->getId()] = sprintf($routeTemplate, substr($content->getRouteName(), 1), $content->getRoutePath(), $content->getModuleToRenderWith(), $content->getActionToRenderWith(), $content->Type->name, $content->Type->id, $content->id, implode('|', sfSympalConfig::getLanguageCodes()), implode('|', sfSympalConfig::get('content_formats')));
            }
            $contents = Doctrine::getTable('sfSympalContent')->createQuery('c')->leftJoin('c.Type t')->innerJoin('c.Site s')->where("c.module IS NOT NULL AND c.module != ''")->orWhere("c.action IS NOT NULL AND c.action != ''")->andWhere('s.slug = ?', $siteSlug)->execute();
            foreach ($contents as $content) {
                $routes['content_' . $content->getId()] = sprintf($routeTemplate, substr($content->getRouteName(), 1), $content->getRoutePath(), $content->getModuleToRenderWith(), $content->getActionToRenderWith(), $content->Type->name, $content->Type->id, $content->id, implode('|', sfSympalConfig::getLanguageCodes()), implode('|', sfSympalConfig::get('content_formats')));
            }
            $contentTypes = Doctrine::getTable('sfSympalContentType')->createQuery('t')->execute();
            foreach ($contentTypes as $contentType) {
                $routes['content_type_' . $contentType->getId()] = sprintf($routeTemplate, substr($contentType->getRouteName(), 1), $contentType->getRoutePath(), $contentType->getModuleToRenderWith(), $contentType->getActionToRenderWith(), $contentType->name, $contentType->id, null, implode('|', sfSympalConfig::getLanguageCodes()), implode('|', sfSympalConfig::get('content_formats')));
            }
            $routes = implode("\n", $routes);
            file_put_contents($cachePath, $routes);
            return $routes;
        } catch (Exception $e) {
        }
    }
开发者ID:RafalJachimczyk,项目名称:sympal,代码行数:52,代码来源:sfSympalToolkit.class.php

示例4: _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;
 }
开发者ID:slemoigne,项目名称:sympal,代码行数:33,代码来源:sfSympalContentRouteObject.class.php

示例5: setupAdminMenu

 /**
  * 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)));
                 }
             }
         }
     }
 }
开发者ID:sympal,项目名称:sympal,代码行数:64,代码来源:sfSympalPluginConfiguration.class.php

示例6: 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');
 }
开发者ID:sympal,项目名称:sympal,代码行数:37,代码来源:sfSympalAdminPluginConfiguration.class.php

示例7: 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));
             }
         }
     }
 }
开发者ID:slemoigne,项目名称:sympal,代码行数:30,代码来源:sfSympalAdminPluginConfiguration.class.php

示例8: sfFormLanguage

<?php

$user = sfContext::getInstance()->getUser();
$form = new sfFormLanguage($user, array('languages' => sfSympalConfig::getLanguageCodes()));
unset($form[$form->getCSRFFieldName()]);
$widgetSchema = $form->getWidgetSchema();
$widgetSchema['language']->setAttribute('onChange', "this.form.submit();");
?>

<?php 
echo $form->renderFormTag(url_for('@sympal_change_language_form'));
?>
  <?php 
echo $form['language'];
?>
</form>
开发者ID:sympal,项目名称:sympal,代码行数:16,代码来源:_change_language_form.php

示例9: 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(__('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.')));
         }
     }
 }
开发者ID:RafalJachimczyk,项目名称:sympal,代码行数:39,代码来源:sfSympalAdminPluginConfiguration.class.php

示例10: getContentRoutesYaml

    /**
     * Get the content routes yaml
     *
     * @return string $yaml
     */
    public static function getContentRoutesYaml()
    {
        $cachePath = sfConfig::get('sf_cache_dir') . '/' . sfConfig::get('sf_app') . '/' . sfConfig::get('sf_environment') . '/content_routes.cache.yml';
        if (file_exists($cachePath) && sfConfig::get('sf_environment') !== 'test') {
            return file_get_contents($cachePath);
        }
        try {
            $routeTemplate = '%s:
  url:   %s
  param:
    module: %s
    action: %s
    sf_format: html
    sympal_content_type: %s
    sympal_content_type_id: %s
    sympal_content_id: %s
  class: sfDoctrineRoute
  options:
    model: sfSympalContent
    type: object
    method: getContent
    allow_empty: true
  requirements:
    sf_culture:  (%s)
    sf_format:   (%s)
    sf_method:   [post, get]
';
            $routes = array();
            $siteSlug = sfConfig::get('sf_app');
            if (!sfContext::hasInstance()) {
                $configuration = ProjectConfiguration::getApplicationConfiguration(sfConfig::get('sf_app'), 'prod', false);
                sfContext::createInstance($configuration);
            }
            /*
             * Step 1) Process all sfSympalContent records with a custom_path,
             *         module, or action. These have sympal_content_* routes
             */
            $contents = Doctrine::getTable('sfSympalContent')->createQuery('c')->leftJoin('c.Type t')->innerJoin('c.Site s')->where("(c.custom_path IS NOT NULL AND c.custom_path != '') OR (c.module IS NOT NULL AND c.module != '') OR (c.action IS NOT NULL AND c.action != '')")->andWhere('s.slug = ?', $siteSlug)->execute();
            foreach ($contents as $content) {
                $routes['content_' . $content->getId()] = sprintf($routeTemplate, substr($content->getRouteName(), 1), $content->getRoutePath(), $content->getModuleToRenderWith(), $content->getActionToRenderWith(), $content->Type->name, $content->Type->id, $content->id, implode('|', sfSympalConfig::getLanguageCodes()), implode('|', sfSympalConfig::get('content_formats')));
            }
            /*
             * Step 2) Create a route for each sfSympalContentType record
             */
            $contentTypes = Doctrine::getTable('sfSympalContentType')->createQuery('t')->execute();
            foreach ($contentTypes as $contentType) {
                $routes['content_type_' . $contentType->getId()] = sprintf($routeTemplate, substr($contentType->getRouteName(), 1), $contentType->getRoutePath(), $contentType->getModuleToRenderWith(), $contentType->getActionToRenderWith(), $contentType->name, $contentType->id, null, implode('|', sfSympalConfig::getLanguageCodes()), implode('|', sfSympalConfig::get('content_formats')));
            }
            $routes = implode("\n", $routes);
            file_put_contents($cachePath, $routes);
            return $routes;
        } catch (Exception $e) {
            // for now, I'd like to not obfuscate the errors - rather reportthem
            throw $e;
        }
    }
开发者ID:sympal,项目名称:sympal,代码行数:61,代码来源:sfSympalContentToolkit.class.php


注:本文中的sfSympalConfig::getLanguageCodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。