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


PHP Layout::getRegex方法代码示例

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


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

示例1: __call

 /**
  * Displays all controllers from the layout map, categories
  * by which sector they are in.
  *
  * @param string $name
  * @param array $args
  * @return mixed
  */
 public function __call($name, $args)
 {
     $this->setOutputType(self::_OT_CONFIG);
     if (!$this->_acl->check('content_layout_config_module')) {
         throw new Module_NoPermission();
     }
     $layoutName = substr($name, 0, -7);
     $siteType = substr($layoutName, 0, strpos($layoutName, '-'));
     if (empty($layoutName) || !$this->_router->siteTypeExists($siteType)) {
         $this->_event->error(t('Unable to manage content layout, invalid name given'));
         return zula_redirect($this->_router->makeUrl('content_layout'));
     }
     $this->setTitle(sprintf(t('"%s" content layout'), $layoutName));
     $this->setOutputType(self::_OT_CONFIG);
     // Create the new content layout object
     $layout = new Layout($layoutName);
     if (!$layout->exists()) {
         $this->_event->error(t('Provided layout does not exist'));
         return zula_redirect($this->_router->makeUrl('content_layout'));
     }
     // Build view form with validation for the regex (for layout)
     $form = new View_form('manage/main.html', 'content_layout');
     $form->caseSensitive();
     $form->action($this->_router->makeUrl('content_layout', 'manage', $layoutName));
     $form->addElement('content_layout/regex', $layout->getRegex(), t('URL/Regex'), new Validator_Length(2, 255));
     if ($form->hasInput() && $form->isValid()) {
         $layout->setRegex($form->getValues('content_layout/regex'));
         if ($layout->save()) {
             $this->_event->success(t('Updated content layout'));
             return zula_redirect($this->_router->makeUrl('content_layout', 'manage', $layoutName));
         }
         $this->_event->error(t('Unable to save content layout'));
     }
     /**
      * Gather all controllers in the layout for the theme of the site type
      * this layout is for.
      */
     $theme = new Theme($this->_config->get('theme/' . $siteType . '_default'));
     $themeSectors = array();
     foreach ($theme->getSectors() as $sector) {
         $themeSectors[$sector['id']] = array('sector' => $sector, 'cntrlrs' => $layout->getControllers($sector['id']));
     }
     // Assign additional data
     $form->assign(array('layoutName' => $layout->getName(), 'themeSectors' => $themeSectors));
     $this->_theme->addJsFile('jQuery/plugins/dnd.js');
     $this->addAsset('js/dnd_order.js');
     return $form->getOutput();
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:56,代码来源:manage.php

示例2: addSection

 /**
  * Provides ability to add a new content layout. The user will
  * be redirect to the page, as if they had gone 'Edit' on the
  * layout once it has been created.
  *
  * @return string
  */
 public function addSection()
 {
     $this->setTitle(t('Add new layout'));
     $this->setOutputType(self::_OT_CONFIG);
     try {
         $cloner = $this->_router->getArgument('clone');
         $cloner = new Layout($cloner);
         if ($cloner->exists()) {
             $cloneName = $cloner->getName();
             $cloneRegex = $cloner->getRegex();
             $this->setTitle(sprintf(t('Clone layout "%1$s"'), $cloneName));
         } else {
             throw new Exception();
         }
     } catch (Exception $e) {
         $cloneName = null;
         $cloneRegex = null;
     }
     // Build and check form
     $form = new View_Form('index/form_layout.html', 'content_layout');
     $form->action($this->_router->makeUrl('content_layout', 'index', 'add'));
     $form->addElement('content_layout/name', null, t('Name'), array(new Validator_Alphanumeric('-'), new Validator_Length(2, 225)));
     $form->addElement('content_layout/regex', $cloneRegex, t('URL/Regex'), new Validator_Length(2, 255));
     $form->addElement('content_layout/site_type', $this->_router->getDefaultSiteType(), t('Site type'), new Validator_InArray($this->_router->getSiteTypes()));
     $form->addElement('content_layout/clone', $cloneName, t('Clone'), array(new Validator_Alphanumeric('-'), new Validator_Length(0, 225)));
     if ($form->hasInput() && $form->isValid()) {
         $fd = $form->getValues('content_layout');
         // Check if we are cloning a layout
         if ($fd['clone']) {
             $layout = new Layout($fd['clone']);
             $layout->setName($fd['site_type'] . '-' . $fd['name']);
         } else {
             $layout = new Layout($fd['site_type'] . '-' . $fd['name']);
         }
         $layout->setRegex($fd['regex']);
         $path = $this->_zula->getDir('config') . '/layouts/' . $layout->getName() . '.xml';
         if ($layout->save($path)) {
             $this->_event->success(t('Added new content layout'));
             return zula_redirect($this->_router->makeUrl('content_layout', 'manage', $layout->getName()));
         }
         $this->_event->error(t('Unable to save content layout'));
     }
     return $form->getOutput();
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:51,代码来源:index.php


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