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


PHP Zend_Filter_Inflector::setRules方法代码示例

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


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

示例1: _transformColumn

 /**
  * Inflektor pro ziskani nazvu atributu
  * camelCase -> under_score
  *
  * @param string $columnName
  * @return string
  */
 protected function _transformColumn($columnName)
 {
     $inflector = new Zend_Filter_Inflector(":string");
     $inflector->setRules(array(':string' => array('Word_CamelCaseToUnderscore', 'StringToLower')));
     $columnName = $inflector->filter(array('string' => $columnName));
     return $columnName;
 }
开发者ID:cngroupdk,项目名称:InterviewMe_Tym3,代码行数:14,代码来源:Row.php

示例2: filterText

 public function filterText($text)
 {
     $inflector = new Zend_Filter_Inflector(':text');
     $inflector->setRules(array(':text' => array(new Zend_Filter_StringToLower(), new Zend_Filter_StripTags(), new Zend_Filter_Word_DashToSeparator(), new Zend_Filter_Word_SeparatorToSeparator('/', '_'), new Zend_Filter_Word_UnderscoreToSeparator(), new Zend_Filter_StringTrim(), new Zend_Filter_Alnum(true), new Zend_Filter_Word_SeparatorToSeparator(' ', '_'))));
     $text = $inflector->filter(array('text' => $text));
     return $text;
 }
开发者ID:rantoine,项目名称:AdvisorIllustrator,代码行数:7,代码来源:CacheFilter.php

示例3: _dasherise

 /**
  * Uses Zend's inflector rules to convert from class names to url segments
  * 
  * @param 	string $name
  * @return 	string
  */
 protected function _dasherise($name)
 {
     $name = str_replace('Action', '', $name);
     $inflector = new Zend_Filter_Inflector(':name');
     $inflector->setRules(array(':name' => array('Word_CamelCaseToDash', 'StringToLower')));
     return $inflector->filter(array('name' => $name));
 }
开发者ID:jara,项目名称:jara-base,代码行数:13,代码来源:StaticRoutes.php

示例4: generateSlug

 public function generateSlug($rawSlug)
 {
     $inflector = new Zend_Filter_Inflector(':slug');
     $inflector->setRules(array(':slug' => array(new Zend_Filter_StringToLower(), new Zend_Filter_StringTrim(), new Zend_Filter_StripTags(), new Zend_Filter_Word_DashToSeparator(), new Zend_Filter_PregReplace(array('match' => '/[^A-Za-z0-9]/', 'replace' => ' ')), new Zend_Filter_Alnum(true), new Zend_Filter_Word_SeparatorToDash())));
     $slug = $inflector->filter(array('slug' => $rawSlug));
     return $slug;
 }
开发者ID:rantoine,项目名称:AdvisorIllustrator,代码行数:7,代码来源:Slug.php

示例5: getInflector

 /**
  * Get Inflector to use determing correct class name
  *
  * @return Zend_Filter_Inflector
  */
 public function getInflector()
 {
     if (null === $this->_inflector) {
         $filters = array('Word_DashToCamelCase', new Zend_Filter_Callback('ucfirst'));
         $inflector = new Zend_Filter_Inflector(':module_Model_Service_:name');
         $inflector->setRules(array(':module' => $filters, ':name' => $filters));
         $this->_inflector = $inflector;
     }
     return $this->_inflector;
 }
开发者ID:JurJean,项目名称:waf-model,代码行数:15,代码来源:Service.php

示例6: __construct

 public function __construct($config = array())
 {
     parent::__construct($config);
     // strip filename_orig from weird characters and transform underscores to camelcase
     $pattern = '/(.*[\\\\\\/])?(.*)$/';
     preg_match($pattern, $this->filename_orig, $matches);
     $sanatized = str_replace(array(' ', ':', '*', '?', '"', '<', '>', '|'), '_', $matches[2]);
     $inflector = new Zend_Filter_Inflector(':name');
     $inflector->setRules(array(':name' => array('Word_UnderscoreToCamelCase')));
     $filtered = $inflector->filter(array('name' => $sanatized));
     $this->filename_orig = $filtered;
 }
开发者ID:br00k,项目名称:tnc-web,代码行数:12,代码来源:Item.php

示例7: _getInflected

 /**
  * Inflect the name using the inflector filter
  *
  * Changes camelCaseWord to Camel_Case_Word
  *
  * @param string $name The name to inflect
  * @return string The inflected string
  */
 private function _getInflected($name)
 {
     $inflector = new Zend_Filter_Inflector(':class');
     $inflector->setRules(array(':class' => array('Word_CamelCaseToUnderscore')));
     return ucfirst($inflector->filter(array('class' => $name)));
 }
开发者ID:shadobladez,项目名称:erp2,代码行数:14,代码来源:Abstract.php

示例8: getTemplateName

 /**
  * Returns the template name.
  *
  * @return  string
  */
 public function getTemplateName()
 {
     $request = $this->viewRenderer->Action()->Request();
     $dispatcher = $this->viewRenderer->Front()->Dispatcher();
     $moduleName = $dispatcher->formatModuleName($request->getModuleName());
     $controllerName = $dispatcher->formatControllerName($request->getControllerName());
     $inflector = new Zend_Filter_Inflector($this->target);
     $inflector->setRules($this->filterRules);
     $inflector->setThrowTargetExceptionsOn(false);
     $fileNames = (array) $request->getParam('file', $this->defaultFile);
     $templateNames = array();
     foreach ($fileNames as $fileName) {
         $fileName = ltrim(dirname($fileName) . '/' . basename($fileName, '.js'), '/.');
         if (empty($fileName)) {
             continue;
         }
         $templateNames[] = $inflector->filter(array('module' => $moduleName, 'controller' => $controllerName, 'file' => $fileName));
     }
     $count = count($templateNames);
     if ($count === 0) {
         return null;
     } elseif ($count === 1) {
         return $templateNames[0];
     } else {
         return 'snippet:string:{include file="' . implode("\"}\n{include file=\"", $templateNames) . '"}';
     }
 }
开发者ID:nhp,项目名称:shopware-4,代码行数:32,代码来源:Bootstrap.php

示例9: _initInflectors

 protected function _initInflectors()
 {
     $camelCase = new Zend_Filter_Inflector(':key');
     $camelCase->setRules(array(':key' => array('Word_CamelCaseToUnderscore', 'StringToLower')));
     array_push($this->_inflectors, $camelCase);
 }
开发者ID:EvanK,项目名称:zend-service-wordpress,代码行数:6,代码来源:Abstract.php

示例10: submitAction

 /**
  * Submit Feed to website
  * 
  * @return 
  */
 public function submitAction()
 {
     $this->view->keywords = implode('', array('ifphp', 'news aggragator', 'submit rss feed'));
     $form = $this->getSubmitForm();
     //setup the available categories
     $categories = new Categories();
     $this->view->categories = $categories->getAll();
     foreach ($this->view->categories as $category) {
         $form->category->addMultiOptions(array($category->id => $category->title));
     }
     //setup the available languages
     $languages = new Languages();
     $this->view->languages = $languages->getAll();
     foreach ($this->view->languages as $language) {
         $form->language->addMultiOptions(array($language->id => $language->title));
     }
     //if it's a post submit let's save the information
     if ($this->getRequest()->isPost() && $form->isValid($_POST)) {
         //TODO this shoudl be wrapped in a transaction
         //create user
         $users = new Users();
         //check for existance of a user
         $user = $users->getByEmail($form->email->getValue());
         if (!$user) {
             $user = $users->createRow();
             $user->email = $form->email->getValue();
             $user->fullName = $form->fullname->getValue();
             $user->username = 'temporaryusername';
             //TODO put real username here eventually
             $user->password = '';
             $user->roleId = Role::SUBMITTER;
             $user->statusId = Status::ACTIVE;
             $user->save();
         }
         try {
             $feedSource = Zend_Feed_Reader::import($form->url->getValue());
             //convert/parse feed to strongly typed objects
             $defaultFilterChain = new Zend_Filter();
             $defaultFilterChain->addFilter(new Ifphp_Filter_XSSClean());
             $defaultFilterChain->addFilter(new Zend_Filter_StringTrim());
             $defaultFilterChain->addFilter(new Zend_Filter_StripTags());
             $feeds = new Feeds();
             $feed = $feeds->createRow();
             $feed->token = md5(uniqid($user->id));
             $feed->url = $defaultFilterChain->filter($form->url->getValue());
             $feed->title = $defaultFilterChain->filter($feedSource->getTitle());
             $inflector = new Zend_Filter_Inflector(':title');
             $inflector->setRules(array(':title' => array('Word_SeparatorToDash', 'StringToLower', 'HtmlEntities')));
             $feed->slug = $inflector->filter(array('title' => $feed->title));
             $feed->description = $defaultFilterChain->filter($feedSource->getDescription());
             $feed->categoryId = $form->category->getValue();
             $feed->languageId = $form->language->getValue();
             $feed->siteUrl = $form->siteUrl->getValue();
             $feed->statusId = Status::PENDING;
             $feed->userId = $user->id;
             $feed->refreshRate = 120;
             //TODO this is sometimes stored in the feed
             $feed->save();
             //parse feed
             $posts = new Posts();
             foreach ($feedSource as $feedEntry) {
                 $post = $posts->createRow();
                 $post->title = $defaultFilterChain->filter($feedEntry->getTitle());
                 $post->description = $defaultFilterChain->filter($feedEntry->getDescription());
                 $post->link = $defaultFilterChain->filter($feedEntry->getPermaLink());
                 $post->feedId = $feed->id;
                 $date = new Zend_Date($feedEntry->getDateModified());
                 $post->publishDate = $date->toValue();
                 $post->save();
             }
             //    			$this->_flashMessenger->addMessage('Your feed has been added to the site. Your ping back url is http://ifphp.com/feed/ping-back/'.$feed->token);
             $this->sendActivationEmail($feed, $user);
             $this->_forward('submit-thank-you');
         } catch (Zend_Feed_Exception $error) {
             $form->url->markAsError();
             Zend_Registry::getInstance()->logger->err($error);
             return;
         }
     }
     $this->view->form = $form;
 }
开发者ID:aprondak,项目名称:ifphp,代码行数:86,代码来源:FeedController.php

示例11: extendsAction

    public function extendsAction()
    {
        $request = $this->Request();
        $moduleName = 'backend';
        $controllerName = $this->Request()->getParam('baseController');

        $inflector = new Zend_Filter_Inflector(':module/:controller/:file:suffix');
        $inflector->setRules(array(
            ':module' => array('Word_CamelCaseToUnderscore', 'StringToLower'),
            ':controller' => array('Word_CamelCaseToUnderscore', 'StringToLower'),
            ':file' => array('Word_CamelCaseToUnderscore', 'StringToLower'),
            'suffix' => '.js'
        ));
        $inflector->setThrowTargetExceptionsOn(false);

        $fileNames = (array) $request->getParam('file');
        if(empty($fileNames)) {
            return;
        }
        $this->Response()->setHeader('Content-Type', 'application/javascript; charset=utf-8', true);
        $template = 'snippet:string:';

        $this->View()->Engine()->setCompileId($this->View()->Engine()->getCompileId() . '_' . $this->Request()->getControllerName());

        foreach($fileNames as $fileName) {
            $fileName = ltrim(dirname($fileName) . '/' . basename($fileName, '.js'), '/.');
            if (empty($fileName)) {
                continue;
            }
            $templateBase = $inflector->filter(array(
                'module' => $moduleName,
                'controller' => $controllerName,
                'file' => $fileName)
            );

            $templateExtend = $inflector->filter(array(
                'module' => $moduleName,
                'controller' => $this->Request()->getControllerName(),
                'file' => $fileName)
            );
            if($this->View()->templateExists($templateBase)) {
                $template .= '{include file="' . $templateBase. '"}' . "\n";
            }
            if($this->View()->templateExists($templateExtend)) {
                $template .= '{include file="' . $templateExtend. '"}' . "\n";
            }
        }
        $toFind = $this->Request()->getParam('find');
        $toReplace = $this->Request()->getParam('replace');
        $toFind = rtrim($toFind, '.') . '.';
        $toReplace = rtrim($toReplace, '.') . '.';

        $this->View()->setTemplate();
        $template = $this->View()->fetch($template);
        $template = str_replace($toFind, $toReplace, $template);
        echo $template;
    }
开发者ID:nhp,项目名称:shopware-4,代码行数:57,代码来源:ExtJs.php

示例12: getTemplateName

 /**
  * Returns the template name.
  *
  * @return  string
  */
 public function getTemplateName()
 {
     $request = $this->viewRenderer->Action()->Request();
     $dispatcher = $this->viewRenderer->Front()->Dispatcher();
     $moduleName = $dispatcher->formatModuleName($request->getModuleName());
     $controllerName = $dispatcher->formatControllerName($request->getControllerName());
     $inflector = new Zend_Filter_Inflector($this->target);
     $inflector->setRules($this->filterRules);
     $inflector->setThrowTargetExceptionsOn(false);
     $fileName = $request->getParam('file', $this->defaultFile);
     $fileName = ltrim(dirname($fileName) . '/' . basename($fileName, '.js'), '/.');
     if (empty($fileName)) {
         return null;
     }
     $templateName = $inflector->filter(array('module' => $moduleName, 'controller' => $controllerName, 'file' => $fileName));
     return $templateName;
 }
开发者ID:nvdnkpr,项目名称:Enlight,代码行数:22,代码来源:Bootstrap.php

示例13: fixAction

 /**
  * @todo Remove when done
  */
 public function fixAction()
 {
     $posts = new Posts();
     $tposts = $posts->fetchAll($posts->select()->where('id > 0'));
     $defaultFilterChain = new Zend_Filter();
     $defaultFilterChain->addFilter(new Ifphp_Filter_XSSClean());
     $defaultFilterChain->addFilter(new Zend_Filter_StringTrim());
     $defaultFilterChain->addFilter(new Zend_Filter_StripTags());
     $defaultFilterChain->addFilter(new Zend_Filter_HtmlEntities(array('quotestyle' => ENT_QUOTES, 'charset' => 'UTF-8')));
     $defaultFilterChain->addFilter(new Ifphp_Filter_HtmlEntityNames());
     foreach ($tposts as $post) {
         $post->title = $defaultFilterChain->filter($post->title);
         $post->description = $defaultFilterChain->filter($post->description);
         $post->feedId = $defaultFilterChain->filter($post->feedId);
         $post->link = $defaultFilterChain->filter($post->link);
         $post->publishDate = $post->publishDate;
         //            Zend_Debug::dump($post->description);
         $post->save();
     }
     $feeds = new Feeds();
     $tfeeds = $feeds->fetchAll($feeds->select()->where('id > 0'));
     $inflector = new Zend_Filter_Inflector(':title');
     $inflector->setRules(array(':title' => array('Word_SeparatorToDash', 'StringToLower', 'HtmlEntities')));
     foreach ($tfeeds as $feed) {
         $feed->title = $defaultFilterChain->filter($feed->title);
         $feed->description = $defaultFilterChain->filter($feed->description);
         $feed->slug = $inflector->filter(array('title' => $feed->title));
         $feed->save();
     }
     die;
 }
开发者ID:akeemphilbert,项目名称:ifphp,代码行数:34,代码来源:FeedController.php

示例14: underscoreToCamelCase

 public static function underscoreToCamelCase($string)
 {
     $inflector = new Zend_Filter_Inflector(':string');
     $inflector->setRules(array(':string' => 'Word_UnderscoreToCamelCase'));
     return $inflector->filter(array('string' => $string));
 }
开发者ID:hellogerard,项目名称:pox-framework,代码行数:6,代码来源:TextUtilities.php


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