public function __construct(sfSympalContext $sympalContext, sfSympalContent $content, $format = null)
 {
     $this->_symfonyContext = $sympalContext->getSymfonyContext();
     $this->_sympalContext = $sympalContext;
     $this->_configuration = $this->_symfonyContext->getConfiguration();
     $this->_dispatcher = $this->_configuration->getEventDispatcher();
     $this->_configuration->loadHelpers(array('Tag', 'Url', 'Partial'));
     $this->_content = $content;
     $this->_menuItem = $this->_content->getMenuItem();
     $this->_format = $format ? $format : 'html';
 }
/**
 * Include a content slot in your template.
 * 
 * This replaces get_sympal_content_slot() and is intended to be easier
 * to use. This also taps into the app.yml config for its options
 * 
 * @param string $name The name of the slot
 * @param array  $options An array of options for this slot
 * 
 * Available options include
 *  * content         An sfSympalContent instance to render the slot for
 *  * type            The rendering type to use for this slot (e.g. Markdown)
 *  * default_value   A default value to give this slot the first time it's created
 *  * edit_mode       How to edit this slot (popup (default), inline)
 */
function _get_sympal_content_slot($name, $options = array())
{
    if (isset($options['content'])) {
        $content = $options['content'];
        unset($options['content']);
    } else {
        $content = sfSympalContext::getInstance()->getCurrentContent();
    }
    // mark this content record as having content slots
    $content->setEditableSlotsExistOnPage(true);
    // merge the default config for this slot into the given config
    $slotOptions = sfSympalConfig::get($content->Type->slug, 'content_slots', array());
    if (isset($slotOptions[$name])) {
        $options = array_merge($slotOptions[$name], $options);
    }
    // retrieve the slot
    if ($name instanceof sfSympalContentSlot) {
        $slot = $name;
        $name = $name->getName();
    } else {
        $slot = $content->getOrCreateSlot($name, $options);
        unset($options['default_value']);
    }
    $slot->setContentRenderedFor($content);
    /**
     * Either render the raw value or the editor for the slot
     */
    if (sfSympalContext::getInstance()->shouldLoadFrontendEditor()) {
        use_helper('SympalContentSlotEditor');
        return get_sympal_content_slot_editor($content, $slot, $options);
    } else {
        return $slot->render();
    }
}
Пример #3
0
function get_sympal_admin_menu_object($class = 'sfSympalMenuAdminMenu')
{
    static $menu;
    if (!$menu) {
        $sympalContext = sfSympalContext::getInstance();
        $menu = new $class('Sympal Admin', '@sympal_dashboard');
        if ($sympalContext->isAdminModule()) {
            $menu->addChild(sprintf('Go to %s', $sympalContext->getSite()->getTitle()), '@homepage', 'id=sympal_go_to_switch');
        } else {
            if (sfContext::getInstance()->getUser()->hasCredential('ViewDashboard')) {
                $menu->addChild('Go to Admin', '@sympal_dashboard', 'id=sympal_go_to_switch');
            }
        }
        if (sfContext::getInstance()->getUser()->hasCredential('ClearCache')) {
            $menu->addChild('Clear Cache', '@sympal_clear_cache', 'id=sympal_clear_cache_fancybox');
        }
        $menu->addChild('Content', '@sympal_content_types_index', array('label' => 'Site Content'));
        $menu->addChild('Site Administration', '@sympal_sites_edit?id=' . $sympalContext->getSite()->getId(), array('label' => 'Site Setup'));
        $menu->addChild('Security', '@sympal_users', array('label' => 'Users & Security'));
        $menu->addChild('Administration', '@sympal_sites', array('label' => 'Global Setup'));
        sfApplicationConfiguration::getActive()->getEventDispatcher()->notify(new sfEvent($menu, 'sympal.load_admin_menu'));
        $sympalContext = sfSympalContext::getInstance();
        $contentRecord = $sympalContext->getCurrentContent();
        $menuItem = $sympalContext->getCurrentMenuItem();
        if ($contentRecord) {
            sfApplicationConfiguration::getActive()->getEventDispatcher()->notify(new sfEvent($menu, 'sympal.load_editor', array('content' => $contentRecord, 'menuItem' => $menuItem)));
        }
    }
    return $menu;
}
 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);
 }
 public function run(sfEvent $event)
 {
     $record = Doctrine_Core::getTable(sfSympalConfig::get('user_model'))->getRecordInstance();
     $this->_dispatcher->notify(new sfEvent($record, 'sympal.user.set_table_definition', array('object' => $record)));
     $this->_symfonyContext = $event->getSubject();
     $this->_invoker->setCache(new sfSympalCache($this->_invoker));
     $this->_invoker->setSymfonyContext($this->_symfonyContext);
     $this->_sympalContext = sfSympalContext::createInstance($this->_symfonyContext, $this->_invoker);
     $this->_invoker->setSympalContext($this->_sympalContext);
     $this->_enableModules();
     $this->_checkInstalled();
     $this->_invoker->initializeTheme();
     $helpers = array('Sympal', 'SympalContentSlot', 'SympalMenu', 'SympalPager', 'I18N', 'Asset', 'Url', 'Partial');
     if ($this->_invoker->isAdminModule()) {
         sfConfig::set('sf_login_module', 'sympal_admin');
         $helpers[] = 'Admin';
     }
     $this->_invoker->getProjectConfiguration()->loadHelpers($helpers);
     $this->_dispatcher->notify(new sfEvent($this, 'sympal.load'));
     new sfSympalContextLoadFactoriesListener($this->_dispatcher, $this->_invoker);
     new sfSympalComponentMethodNotFoundListener($this->_dispatcher, $this->_invoker);
     new sfSympalControllerChangeActionListener($this->_dispatcher, $this->_invoker);
     new sfSympalTemplateFilterParametersListener($this->_dispatcher, $this->_invoker);
     new sfSympalFormMethodNotFoundListener($this->_dispatcher, $this->_invoker);
     new sfSympalFormPostConfigureListener($this->_dispatcher, $this->_invoker);
     new sfSympalFormFilterValuesListener($this->_dispatcher, $this->_invoker);
 }
 public function clearMenuCache()
 {
     if (sfSympalContext::hasInstance() && ($menu = $this->getMenu())) {
         return sfSympalContext::getInstance()->getService('menu_manager')->clearCache($menu->getCacheKey());
     } else {
         return false;
     }
 }
 public function executeCreate(sfWebRequest $request)
 {
     $this->form = $this->configuration->getForm();
     $this->sf_sympal_redirect = $this->form->getObject();
     $this->sf_sympal_redirect->site_id = sfSympalContext::getInstance()->getService('site_manager')->getSite()->getId();
     $this->processForm($request, $this->form);
     $this->setTemplate('new');
 }
Пример #8
0
 /**
  * Perform the check to determine if we are in edit mode or not
  *
  * @return void
  */
 public function doIsEditModeCheck()
 {
     $content = sfSympalContext::getInstance()->getCurrentContent();
     if ($content && $content->getPubliclyEditable() || $content && $content->getAllEditPermissions() && $this->hasCredential($content->getAllEditPermissions()) || $this->isAuthenticated() && $this->hasCredential('ManageContent')) {
         $this->_isEditMode = true;
     } else {
         $this->_isEditMode = false;
     }
     $this->_isEditMode = sfApplicationConfiguration::getActive()->getEventDispatcher()->filter(new sfEvent($this, 'sympal.filter_is_edit_mode'), $this->_isEditMode)->getReturnValue();
 }
/**
 * Renders the inline edit menu, which consists of buttons such as the
 * assets and links buttons
 * 
 * @return string
 */
function get_sympal_inline_edit_bar_buttons()
{
    $sympalContext = sfSympalContext::getInstance();
    $content = $sympalContext->getCurrentContent();
    $menuItem = $sympalContext->getCurrentMenuItem();
    $menu = new sfSympalMenuInlineEditBarButtons('Inline Edit Bar Buttons');
    $menu->setUlClass('sympal_inline_edit_bar_buttons');
    if ($content->getEditableSlotsExistOnPage()) {
        $menu->addChild('Links', '@sympal_editor_links')->isEditModeButton(true)->setShortcut('Ctrl+Shift+L')->setInputClass('toggle_sympal_links')->setCredentials('InsertLinks');
    }
    sfApplicationConfiguration::getActive()->getEventDispatcher()->notify(new sfEvent($menu, 'sympal.load_inline_edit_bar_buttons', array('content' => $content, 'menuItem' => $menuItem)));
    return $menu->render();
}
 protected function _findLayoutPath($layout = null)
 {
     if ($layout === null) {
         $layout = $this->getName();
     }
     $sympalConfiguration = sfSympalContext::getInstance()->getSympalConfiguration();
     $layouts = $sympalConfiguration->getLayouts();
     $path = array_search($layout, $layouts);
     if (!$path) {
         throw new InvalidArgumentException(sprintf('Could not find layout path for theme "%s"', $layout));
     }
     if (!sfToolkit::isPathAbsolute($path)) {
         $path = sfConfig::get('sf_root_dir') . '/' . $path;
     }
     return $path;
 }
 public function setup()
 {
     parent::setup();
     $plugins = sfSympalContext::getInstance()->getSympalConfiguration()->getContentTypePlugins();
     $plugins = array_combine($plugins, $plugins);
     $plugins = array_merge(array('' => ''), $plugins);
     $this->widgetSchema['plugin_name'] = new sfWidgetFormChoice(array('choices' => $plugins));
     $this->widgetSchema['plugin_name']->setLabel('Plugin');
     $this->widgetSchema['name']->setLabel('Model name');
     $models = Doctrine_Core::loadModels(sfConfig::get('sf_lib_dir') . '/model/doctrine');
     foreach ($models as $model) {
         $table = Doctrine_Core::getTable($model);
         if (!$table->hasTemplate('sfSympalContentTypeTemplate')) {
             unset($models[$model]);
         }
     }
     $models = array_merge(array('' => ''), $models);
     $this->widgetSchema['name'] = new sfWidgetFormChoice(array('choices' => $models));
 }
 /**
  * Change the content choice widget to be a formatted/indented list
  *
  * @param sfForm $form 
  * @param boolean $add Add a new widget instead of trying replacing
  * @return void
  */
 public static function changeContentWidget(sfForm $form, $add = null)
 {
     $widgetSchema = $form->getWidgetSchema();
     $validatorSchema = $form->getValidatorSchema();
     if (is_null($add)) {
         $key = isset($widgetSchema['content_id']) ? 'content_id' : 'content_list';
     } else {
         $key = $add;
     }
     if (isset($widgetSchema[$key]) && $widgetSchema[$key] instanceof sfWidgetFormDoctrineChoice || $add) {
         $q = Doctrine_Core::getTable('sfSympalContent')->createQuery('c')->leftJoin('c.Type t')->leftJoin('c.MenuItem m')->where('c.site_id = ?', sfSympalContext::getInstance()->getSite()->getId())->orderBy('m.root_id, m.lft');
         if ($add) {
             $widgetSchema[$key] = new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'sfSympalContent'));
             $validatorSchema[$key] = new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'sfSympalContent', 'required' => false));
         }
         $widgetSchema[$key]->setOption('query', $q);
         $widgetSchema[$key]->setOption('method', 'getIndented');
     }
 }
Пример #13
0
/**
 * Get Sympal content slot value
 *
 * @param Content $content  The Content instance
 * @param string $name The name of the slot
 * @param string $type The type of slot
 * @param string $renderFunction The function/callable used to render the value of slots which are columns
 * @param array  $options Array of options for this slot
 * @return void
 */
function get_sympal_content_slot($content, $name, $type = null, $renderFunction = null, $options = array())
{
    if ($type === null) {
        $type = 'Text';
    }
    $slot = null;
    if ($name instanceof sfSympalContentSlot) {
        $slot = $name;
        $name = $name->getName();
    } else {
        $slot = $content->getOrCreateSlot($name, $type, $renderFunction, $options);
    }
    $slot->setContentRenderedFor($content);
    if (sfSympalContext::getInstance()->shouldLoadFrontendEditor()) {
        use_helper('SympalContentSlotEditor');
        return get_sympal_content_slot_editor($content, $slot, $options);
    } else {
        return $slot->render();
    }
}
 /**
  * The callback on the context.load_factories event.
  * 
  * The subject is sfContext and the invoker is sfSympalConfiguration
  */
 public function run(sfEvent $event)
 {
     $this->_initiateUserTable();
     $this->_symfonyContext = $event->getSubject();
     $this->_invoker->setCache(new sfSympalCache($this->_invoker));
     $this->_invoker->setSymfonyContext($this->_symfonyContext);
     $this->_sympalContext = sfSympalContext::createInstance($this->_symfonyContext, $this->_invoker);
     $this->_invoker->setSympalContext($this->_sympalContext);
     $this->_enableModules();
     $this->_checkInstalled();
     $this->_invoker->initializeTheme();
     $this->_loadHelpers();
     $this->_dispatcher->notify(new sfEvent($this, 'sympal.load'));
     new sfSympalComponentMethodNotFoundListener($this->_dispatcher, $this->_invoker);
     new sfSympalControllerChangeActionListener($this->_dispatcher, $this->_invoker);
     new sfSympalTemplateFilterParametersListener($this->_dispatcher, $this->_invoker);
     new sfSympalFormMethodNotFoundListener($this->_dispatcher, $this->_invoker);
     new sfSympalFormPostConfigureListener($this->_dispatcher, $this->_invoker);
     new sfSympalFormFilterValuesListener($this->_dispatcher, $this->_invoker);
 }
 public function loadAdminMenu(sfEvent $event)
 {
     $menu = $event->getSubject();
     if (sfSympalConfig::isI18nEnabled()) {
         $this->configuration->loadHelpers(array('Partial', 'I18N'));
         $changeLanguage = $menu->getChild('Change Language');
         $currentCulture = strtolower(sfContext::getInstance()->getUser()->getCulture());
         $codes = sfSympalConfig::getLanguageCodes();
         foreach ($codes as $code) {
             $code = strtolower($code);
             $formatted = format_language($code);
             if (!$formatted) {
                 $formatted = format_language($code, 'en');
             }
             if ($formatted) {
                 $changeLanguage->addChild(ucwords($formatted), '@sympal_change_language?language=' . $code, 'title=' . __('Switch to ') . '' . $formatted);
             }
         }
     }
     $manageContent = $menu->getChild('Content');
     $manageContent->addChild('Search', '@sympal_admin_search');
     $user = sfContext::getInstance()->getUser();
     $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'));
     $siteAdministration = $menu->getChild('Site Administration');
     $siteAdministration->addChild('404 Redirects', '@sympal_redirects')->setCredentials(array('ManageRedirects'));
     $siteAdministration->addChild('Edit Site', '@sympal_sites_edit?id=' . sfSympalContext::getInstance()->getSite()->getId())->setCredentials(array('ManageSites'));
     $administration = $menu->getChild('Administration');
     $administration->addChild('Content Types', '@sympal_content_types')->setCredentials(array('ManageContentTypes'));
     $administration->addChild('Themes', '@sympal_themes')->setCredentials(array('ManageThemes'));
     $administration->addChild('Sites', '@sympal_sites')->setCredentials(array('ManageSites'));
     $administration->addChild('System Settings', '@sympal_config')->setCredentials(array('ManageSystemSettings'));
     $administration->addChild('Check Server', '@sympal_check_server')->setCredentials(array('ViewServerCheck'));
     $administration->addChild('Check for Updates', '@sympal_check_for_updates')->setCredentials(array('UpdateManager'));
 }
Пример #16
0
/**
 * Helper for admin-related view tasks
 * 
 * @package     sfSympalAdminPlugin
 * @subpackage  helper
 * @author      Jonathan H. Wage <*****@*****.**>
 * @author      Ryan Weaver <*****@*****.**>
 */
function get_sympal_admin_menu_object($class = 'sfSympalMenuAdminMenu')
{
    static $menu;
    if (!$menu) {
        $sympalContext = sfSympalContext::getInstance();
        $siteManager = $sympalContext->getService('site_manager');
        $menu = new $class('Sympal Admin', '@sympal_dashboard');
        if ($sympalContext->getSympalConfiguration()->isAdminModule()) {
            $menu->addChild(sprintf(__('Go to %s'), $siteManager->getSite()->getTitle()), '@homepage', 'id=sympal_go_to_switch');
        } else {
            if (sfContext::getInstance()->getUser()->hasCredential('ViewDashboard')) {
                $menu->addChild('Admin', '@sympal_dashboard', 'id=sympal_go_to_switch');
            }
        }
        if (sfContext::getInstance()->getUser()->hasCredential('ClearCache')) {
            $menu->addChild('Clear Cache', '@sympal_clear_cache', 'id=sympal_clear_cache_fancybox');
        }
        $menu->addChild('content', '@sympal_content_types_index', array('label' => 'Content'));
        $menu->getChild('site_administration', '@sympal_sites_edit?id=' . $siteManager->getSite()->getId(), array('label' => 'Site Setup'));
        sfApplicationConfiguration::getActive()->getEventDispatcher()->notify(new sfEvent($menu, 'sympal.load_admin_menu'));
        $menu->addChild('Signout', '@sympal_signout', array('title' => 'Ctrl+Q', 'confirm' => '' . __('Are you sure you want to signout?') . '', 'label' => 'Signout'));
    }
    return $menu;
}
Пример #17
0
<?php

$app = 'sympal';
require_once dirname(__FILE__) . '/../bootstrap/unit.php';
$t = new lime_test(5, new lime_output_color());
$sympalContext = sfSympalContext::getInstance();
$menuItem = Doctrine_Core::getTable('sfSympalMenuItem')->findOneBySlug('home');
$sympalContext->setCurrentMenuItem($menuItem);
$t->is($sympalContext->getCurrentMenuItem(), $menuItem);
$t->is($sympalContext->getSite()->getSlug(), $app);
$resource = sfSympalToolkit::getSymfonyResource('test', 'test', array('var' => 'Test'));
$t->is($resource, 'Test');
$t->is(sfSympalToolkit::getDefaultApplication(), 'sympal');
$t->is(in_array('en', sfSympalToolkit::getAllLanguageCodes()), true);
Пример #18
0
 /**
  * Get the current sfSympalContext instance
  *
  * @return sfSympalContext $sympalContext
  */
 public function getSympalContext()
 {
     return sfSympalContext::getInstance();
 }
Пример #19
0
 /**
  * Create a new sfSympalContext instance for a given sfContext and sfSympalConfiguration instance
  *
  * @param sfContext $symfonyContext 
  * @param sfSympalConfiguration $sympalConfiguration 
  * @return sfSympalContext $sympalContext
  */
 public static function createInstance(sfContext $symfonyContext, sfSympalConfiguration $sympalConfiguration)
 {
     $name = $symfonyContext->getConfiguration()->getApplication();
     $instance = new self($sympalConfiguration, $symfonyContext);
     self::$_instances[$name] = $instance;
     self::$_current = $instance;
     return self::$_instances[$name];
 }
Пример #20
0
<?php

$app = 'sympal';
require_once dirname(__FILE__) . '/../bootstrap/functional.php';
$browser = new sfSympalTestFunctional(new sfBrowser());
$redirect = new sfSympalRedirect();
$redirect->source = '/test_redirect1/:parameter1/ok/:parameter2';
$redirect->destination = '@redirect_route';
$redirect->site_id = sfSympalContext::getInstance()->getService('site_manager')->getSite()->getId();
$redirect->save();
$redirect = new sfSympalRedirect();
$redirect->source = '/test_redirect2';
$redirect->site_id = sfSympalContext::getInstance()->getService('site_manager')->getSite()->getId();
$redirect->content_id = 1;
$redirect->save();
$redirect = new sfSympalRedirect();
$redirect->source = '/test_redirect3/:parameter1/ok/:parameter2';
$redirect->destination = '/some/path/ok/:parameter2';
$redirect->site_id = sfSympalContext::getInstance()->getService('site_manager')->getSite()->getId();
$redirect->save();
$browser->clearCache();
$browser->get('/test_redirect1/test1/ok/test2')->with('response')->begin()->isStatusCode(301)->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'test')->isParameter('action', 'redirect')->isParameter('parameter1', 'test1')->end();
$browser->get('/test_redirect2')->with('response')->begin()->isStatusCode(301)->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'sympal_content_renderer')->isParameter('action', 'index')->end()->with('response')->begin()->matches('/Sample Content List/')->end();
$browser->get('/test_redirect3/test1/ok/test2')->with('response')->begin()->isStatusCode(301)->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'test')->isParameter('action', 'redirect')->isParameter('parameter2', 'test2')->end();
Пример #21
0
    ?>
    <?php 
    if ($secondary = (string) $menus['secondary']) {
        ?>
      <?php 
        slot('sympal_right_sidebar', $secondary . get_slot('sympal_right_sidebar'));
        ?>
    <?php 
    }
    ?>
  <?php 
}
?>

  <?php 
$subMenu = get_sympal_menu(sfSympalContext::getInstance()->getCurrentMenuItem(), true);
?>
  <?php 
if (has_slot('sympal_right_sidebar') || $subMenu) {
    ?>
    <?php 
    sympal_use_stylesheet('/sfSympalPlugin/css/right.css', 'last');
    ?>
  <?php 
}
?>

  <?php 
include_http_metas();
?>
  <?php 
 public function getFilterDefaults()
 {
     return array('site_id' => sfSympalContext::getInstance()->getService('site_manager')->getSite()->getId());
 }
 public function listenToAdminBuildQuery(sfEvent $event, Doctrine_Query $query)
 {
     $query->andWhere('site_id = ?', sfSympalContext::getInstance()->getSite()->getId());
     return $query;
 }
Пример #24
0
$breadcrumbs->addChild('1.0', 'http://www.doctrine-project.org/documentation/1_0');
$node = $breadcrumbs->addChild('The Guide to Doctrine ORM', 'http://www.doctrine-project.org/documentation/1_0/manual');
$t->is(get_class($node), 'sfSympalMenuBreadcrumbsTest', 'Test Breadcrumbs class');
$t->is($breadcrumbs->getPathAsString(), 'Documentation / 1.0 / The Guide to Doctrine ORM', 'getPathAsString()');
$t->is((string) $breadcrumbs, '<div id="sympal_breadcrumbs"><ul id="doctrine-menu"><li id="doctrine-documentation" class="first"><a href="http://www.doctrine-project.org/documentation">Documentation</a></li><li id="doctrine-1-0"><a href="http://www.doctrine-project.org/documentation/1_0">1.0</a></li><li id="doctrine-the-guide-to-doctrine-orm" class="last"><a href="http://www.doctrine-project.org/documentation/1_0/manual">The Guide to Doctrine ORM</a></li></ul></div>', 'Test get breadcrumbs');
$t->info('6 - Test the menu site class');
class sfSympalMenuSiteTest extends sfSympalMenuSite
{
    public function renderLink()
    {
        return $this->renderLabel();
    }
}
$user = Doctrine_Core::getTable('sfGuardUser')->findOneByIsSuperAdmin(true);
sfContext::getInstance()->getUser()->signIn($user);
$menuManager = sfSympalContext::getInstance()->getService('menu_manager');
$t->info('Retrieve the "primary" menu, setup in the fixtures');
$t->info('blog  signout  home  sample-page  sample-content-list    powered-by         ');
$t->info('                                                        /     |     \\       ');
$t->info('                                                  symfony  doctrine  sympal ');
$primaryMenu = $menuManager->getMenu('primary', false, 'sfSympalMenuSiteTest');
$t->is((string) $primaryMenu, '<ul id="primary-menu"><li id="primary-blog-list" class="first">Blog List</li><li id="primary-sample-content-list">Sample Content List</li><li id="primary-signout">Signout</li><li id="primary-powered-by">Powered By</li><li id="primary-home">Home</li><li id="primary-sample-page" class="last">Sample Page</li></ul>', 'Test __toString() without showing children');
$split = $menuManager->split($primaryMenu, 2, true);
$total = $primaryMenu->count();
$t->is($split['primary']->count(), 2, 'Test count() after splitting the menu into 2 pieces');
$t->is((string) $split['primary'], '<ul id="primary-menu"><li id="primary-blog-list" class="first">Blog List</li><li id="primary-sample-content-list">Sample Content List</li></ul>', 'Test split() primary');
$t->is((string) $split['secondary'], '<ul id="secondary-menu"><li id="primary-signout">Signout</li><li id="primary-powered-by">Powered By</li><li id="primary-home">Home</li><li id="primary-sample-page" class="last">Sample Page</li></ul>', 'Test split() secondary');
$t->is($split['secondary']->count(), 4, 'Test secondary count()');
$footerMenu = $menuManager->getMenu('footer', false, 'sfSympalMenuSiteTest');
$t->is((string) $footerMenu, '', 'Test footer menu');
$table = Doctrine_Core::getTable('sfSympalMenuItem');
 /**
  * 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)));
                 }
             }
         }
     }
 }
Пример #26
0
<?php

$app = 'sympal';
require_once dirname(__FILE__) . '/../bootstrap/functional.php';
$browser = new sfSympalTestFunctional(new sfBrowser());
$redirect = new sfSympalRedirect();
$redirect->source = '/test_redirect1/:parameter1/ok/:parameter2';
$redirect->destination = '@redirect_route';
$redirect->site_id = sfSympalContext::getInstance()->getSite()->getId();
$redirect->save();
$redirect = new sfSympalRedirect();
$redirect->source = '/test_redirect2';
$redirect->site_id = sfSympalContext::getInstance()->getSite()->getId();
$redirect->content_id = 1;
$redirect->save();
$redirect = new sfSympalRedirect();
$redirect->source = '/test_redirect3/:parameter1/ok/:parameter2';
$redirect->destination = '/some/path/ok/:parameter2';
$redirect->site_id = sfSympalContext::getInstance()->getSite()->getId();
$redirect->save();
$browser->clearCache();
$browser->get('/test_redirect1/test1/ok/test2')->with('response')->begin()->isStatusCode(301)->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'test')->isParameter('action', 'redirect')->isParameter('parameter1', 'test1')->end();
$browser->get('/test_redirect2')->with('response')->begin()->isStatusCode(301)->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'sympal_content_renderer')->isParameter('action', 'index')->end()->with('response')->begin()->matches('/Sample Content List/')->end();
$browser->get('/test_redirect3/test1/ok/test2')->with('response')->begin()->isStatusCode(301)->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'test')->isParameter('action', 'redirect')->isParameter('parameter2', 'test2')->end();
 public function shouldLoadEditor()
 {
     $format = sfContext::getInstance()->getRequest()->getRequestFormat();
     $format = $format ? $format : 'html';
     return sfContext::getInstance()->getUser()->isEditMode() && $format == 'html' && (!sfSympalConfig::get('page_cache', 'enabled') && sfSympalConfig::get('inline_editing', 'enabled') && sfSympalContext::getInstance()->getCurrentContent()) || sfSympalConfiguration::getActive()->isAdminModule() && sfSympalContext::getInstance()->getCurrentContent();
 }
Пример #28
0
 public function isCurrentAncestor()
 {
     $menuItem = sfSympalContext::getInstance()->getCurrentMenuItem();
     if ($menuItem && $this->_menuItemArray) {
         $this->_currentObject = $this->findMenuItem($menuItem);
         return parent::isCurrentAncestor();
     }
     return false;
 }
 /**
  * Autoload the helper file for a helper function
  *
  * @param string $functionName
  * @return void
  */
 public static function autoloadHelper($functionName)
 {
     if (is_null(self::$_helperAutoloadCache)) {
         self::$_helperAutoloadCache = sfSympalContext::getInstance()->getSympalConfiguration()->getCache()->getHelperAutoload();
     }
     if (isset(self::$_helperAutoloadCache[$functionName])) {
         require_once self::$_helperAutoloadCache[$functionName];
     } else {
         throw new sfException('Could not autoload helper for function "' . $functionName . '"');
     }
 }
<?php

/**
 * Unit test for the sfSympalConfiguration class
 * 
 * @package     sfSympalAdminPlugin
 * @subpackage  test
 * @author      Jonathan H. Wage <*****@*****.**>
 * @author      Ryan Weaver <*****@*****.**>
 * @since       2010-02-06
 * @version     svn:$Id$ $Author$
 */
$app = 'sympal';
require_once dirname(__FILE__) . '/../../../bootstrap/unit.php';
$t = new lime_test(2);
$sympalConfiguration = sfSympalContext::getInstance()->getSympalConfiguration();
sfContext::getInstance()->getRequest()->setParameter('module', 'sympal_dashboard');
$t->is($sympalConfiguration->isAdminModule(), true, '->isAdminModule() returns true for admin module');
sfContext::getInstance()->getRequest()->setParameter('module', 'sympal_content_renderer');
$t->is($sympalConfiguration->isAdminModule(), false, '->isAdminModule() returns false for non-admin module');