本文整理汇总了PHP中Zend_Filter_Inflector类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Filter_Inflector类的具体用法?PHP Zend_Filter_Inflector怎么用?PHP Zend_Filter_Inflector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Filter_Inflector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: 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
示例3: getViewRenderer
/**
* Retrieves the view renderer object
*
* @return Zend_Controller_Action_Helper_ViewRenderer|null
* @throws Glitch_Application_Resource_Exception
*/
public function getViewRenderer()
{
if (null === $this->_viewRenderer) {
// Pull in the front controller; bootstrap first if necessary
$this->_bootstrap->bootstrap('FrontController');
$front = $this->_bootstrap->getResource('FrontController');
// Ignore if no view renderer is to be used
if ($front->getParam('noViewRenderer')) {
return null;
}
// Get existing renderer, if any, or create a new one
$this->_viewRenderer = Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer') ? Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer') : new $this->_className(null, $this->getOptions());
// Dynamic class loading; perform sanity check
if (!$this->_viewRenderer instanceof Zend_Controller_Action_Helper_ViewRenderer) {
throw new Glitch_Application_Resource_Exception('Class is not a valid view renderer instance');
}
// Register the view as the default view for handling view scripts
$this->_bootstrap->bootstrap('View');
$view = $this->_bootstrap->getResource('View');
$this->_viewRenderer->setView($view);
// It is paramount to set this base path spec: ZF otherwise uses its own
// spec, causing it to create a path to a conventional ZF-style directory
$this->_viewRenderer->setViewBasePathSpec(':module/' . Glitch_View::PATH_VIEW);
// Set empty inflector settings: all path translations are handled by the custom dispatcher
$inflector = new Zend_Filter_Inflector();
$inflector->addRules(array(':module' => array(), ':controller' => array(), ':action' => array()));
$this->_viewRenderer->setInflector($inflector, true);
if (!Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')) {
Zend_Controller_Action_HelperBroker::addHelper($this->_viewRenderer);
}
}
return $this->_viewRenderer;
}
开发者ID:nstapelbroek,项目名称:Glitch_Lib,代码行数:39,代码来源:Viewrenderer.php
示例4: _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
示例5: _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
示例6: _initView
protected function _initView()
{
// Start initail view
$this->bootstrap('layout');
$config = $this->getOption('views');
$resources = $this->getOption('resources');
$view = new Zend_View();
if (isset($resources['layout']['layoutPath'])) {
$view->assign('layoutRootPath', $resources['layout']['layoutPath']);
}
$this->bootstrap('db');
Zend_Loader::loadClass('Ht_Utils_SystemSetting');
$sysSetting = Ht_Utils_SystemSetting::getSettings();
$view->assign('sysSetting', $sysSetting);
$view->assign('profile', Zend_Auth::getInstance()->getIdentity());
Zend_Loader::loadClass("Ht_Model_SystemSetting");
$this->setSystemLogConfiguration($sysSetting);
// use the viewrenderer to keep the code DRY
// instantiate and add the helper in one go
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
$viewRenderer->setView($view);
$viewRenderer->setViewSuffix('phtml');
// add it to the action helper broker
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
/**
* Set inflector for Zend_Layout
*/
$inflector = new Zend_Filter_Inflector(':script.:suffix');
$inflector->addRules(array(':script' => array('Word_CamelCaseToDash', 'StringToLower'), 'suffix' => 'phtml'));
// Initialise Zend_Layout's MVC helpers
$this->getResource('layout')->setLayoutPath(realpath($resources['layout']['layoutPath']))->setView($view)->setContentKey('content')->setInflector($inflector);
return $this->getResource('layout')->getView();
}
开发者ID:kangza,项目名称:hagtag,代码行数:33,代码来源:Bootstrap.php
示例7: getInflector
/**
* Get path inflector
* @return Zend_Filter_Inflector
*/
public static function getInflector()
{
if (null === self::$_inflector) {
$inflector = new Zend_Filter_Inflector();
$inflector->addRules(array(':module' => array('Word_CamelCaseToDash', 'StringToLower'), ':controller' => array('Word_CamelCaseToDash', new Zend_Filter_Word_UnderscoreToSeparator('/'), 'StringToLower', new Zend_Filter_PregReplace('/\\./', '-')), ':action' => array('Word_CamelCaseToDash', new Zend_Filter_PregReplace('#[^a-z0-9' . preg_quote('/', '#') . ']+#i', '-'), 'StringToLower')))->setTarget('../application/modules/:module/views/scripts/:controller/:action.xsl');
self::setInflector($inflector);
}
return self::$_inflector;
}
开发者ID:kandy,项目名称:system,代码行数:13,代码来源:PartialRenderer.php
示例8: 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
示例9: __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
示例10: getInflector
/**
* Get inflector
*
* @return Zend_Filter_Inflector
*/
public function getInflector()
{
if (null === $this->_inflector) {
$this->_inflector = new Zend_Filter_Inflector();
$this->_inflector->addRules(array(':module' => array('Word_CamelCaseToDash', 'StringToLower'), ':controller' => array('Word_CamelCaseToDash', new Zend_Filter_Word_UnderscoreToSeparator('/'), 'StringToLower', new Zend_Filter_PregReplace('/\\./', '-')), ':action' => array('Word_CamelCaseToDash', new Zend_Filter_PregReplace('#[^a-z0-9' . preg_quote('/', '#') . ']+#i', '-'), 'StringToLower')));
}
return $this->_inflector;
}
开发者ID:kandy,项目名称:system,代码行数:13,代码来源:SmartyStack.php
示例11: setInflector
/**
* Set inflector
*
* @param Zend_Filter_Inflector $inflector
* @param boolean $reference Whether the moduleDir, target, and suffix should be set as references to ViewRenderer properties
* @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
*/
public function setInflector(Zend_Filter_Inflector $inflector, $reference = false)
{
$this->_inflector = $inflector;
if ($reference) {
$this->_inflector->setStaticRuleReference('suffix', $this->_viewSuffix)->setStaticRuleReference('moduleDir', $this->_moduleDir)->setTargetReference($this->_inflectorTarget);
}
return $this;
}
开发者ID:bcsgarcia,项目名称:LojaTeste,代码行数:15,代码来源:ViewRenderer.php
示例12: testSetConfigSetsStateAndRules
public function testSetConfigSetsStateAndRules()
{
$config = $this->getConfig();
$inflector = new Zend_Filter_Inflector();
$inflector->setConfig($config);
$this->_testOptions($inflector);
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:7,代码来源:InflectorTest.php
示例13: testNoInflectableTarget
/**
* @issue ZF-2964
*/
public function testNoInflectableTarget()
{
$inflector = new Zend_Filter_Inflector('abc');
$inflector->addRules(array(':foo' => array()));
$this->assertEquals($inflector->filter(array('fo' => 'bar')), 'abc');
}
开发者ID:lortnus,项目名称:zf1,代码行数:9,代码来源:InflectorTest.php
示例14: testCustomInflectorUsesViewRendererTargetWhenPassedInWithReferenceFlag
public function testCustomInflectorUsesViewRendererTargetWhenPassedInWithReferenceFlag()
{
$this->request->setModuleName('bar')->setControllerName('index')->setActionName('test');
$controller = new Bar_IndexController($this->request, $this->response, array());
$this->helper->view->addBasePath($this->basePath . '/_files/modules/bar/views');
require_once 'Zend/Filter/PregReplace.php';
require_once 'Zend/Filter/Word/UnderscoreToSeparator.php';
$inflector = new Zend_Filter_Inflector('test.phtml');
$inflector->addRules(array(':module' => array('Word_CamelCaseToDash', 'stringToLower'), ':controller' => array('Word_CamelCaseToDash', new Zend_Filter_Word_UnderscoreToSeparator(DIRECTORY_SEPARATOR), 'StringToLower'), ':action' => array('Word_CamelCaseToDash', new Zend_Filter_PregReplace('/[^a-z0-9]+/i', '-'), 'StringToLower')));
$this->helper->setInflector($inflector, true);
$this->helper->render();
$body = $this->response->getBody();
$this->assertContains('Rendered index/test.phtml in bar module', $body);
}
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:14,代码来源:ViewRendererTest.php
示例15: _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
示例16: 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
示例17: 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
示例18: preDispatch
public function preDispatch()
{
$request = $this->getRequest();
if (Axis_Area::isFrontend()) {
if (!Axis::getCustomerId() && $this->getActionController() instanceof Axis_Account_Controller_Abstract) {
$request->setModuleName('Axis_Account')->setControllerName('auth')->setActionName('index')->setDispatched(false);
}
return;
}
if (!Axis_Area::isBackend()) {
return;
}
$auth = Zend_Auth::getInstance();
$auth->setStorage(new Zend_Auth_Storage_Session('admin'));
if (in_array($request->getControllerName(), array('auth', 'forgot')) && 'Axis_Admin' === $request->getModuleName()) {
return;
}
if (!$auth->hasIdentity()) {
if ($request->isXmlHttpRequest()) {
Axis::message()->addError(Axis::translate('admin')->__('Your session has been expired. Please relogin'));
$jsonHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
$jsonHelper->sendFailure();
return;
}
$request->setModuleName('Axis_Admin')->setControllerName('auth')->setActionName('index')->setDispatched(false);
return;
}
$user = Axis::single('admin/user')->find($auth->getIdentity())->current();
if (!$user) {
$request->setModuleName('Axis_Admin')->setControllerName('auth')->setActionName('logout')->setDispatched(false);
return;
}
$acl = new Zend_Acl();
// add resources
$resources = Axis::model('admin/acl_resource')->toFlatTree();
foreach ($resources as $resource) {
$parent = $resource['parent'];
try {
$acl->addResource($resource['id'], $parent);
} catch (Zend_Acl_Exception $e) {
Axis::message()->addError($e->getMessage());
}
}
//add role(s)
$role = (string) $user->role_id;
$acl->addRole($role);
//add permission
$rowset = Axis::single('admin/acl_rule')->select('*')->where('role_id = ?', $role)->fetchRowset();
foreach ($rowset as $row) {
if (!$acl->has($row->resource_id)) {
// $row->delete(); // remove invalid rule
continue;
}
$action = 'deny';
if ('allow' === $row->permission) {
$action = 'allow';
}
try {
$acl->{$action}($row->role_id, $row->resource_id);
} catch (Zend_Acl_Exception $e) {
Axis::message()->addError($e->getMessage());
}
}
Zend_View_Helper_Navigation_HelperAbstract::setDefaultAcl($acl);
Zend_View_Helper_Navigation_HelperAbstract::setDefaultRole($role);
if (in_array($request->getControllerName(), array('error')) && 'Axis_Admin' === $request->getModuleName()) {
return;
}
//get current resource by request
$request = $this->getRequest();
$inflector = new Zend_Filter_Inflector();
$resource = $inflector->addRules(array(':module' => array('Word_CamelCaseToDash', new Zend_Filter_Word_UnderscoreToSeparator('/'), 'StringToLower'), ':controller' => array('Word_CamelCaseToDash', 'StringToLower', new Zend_Filter_PregReplace('/admin_/', '')), ':action' => array('Word_CamelCaseToDash', 'StringToLower')))->setTarget('admin/:module/:controller/:action')->filter($request->getParams());
if (!$acl->has($resource) || $acl->isAllowed($role, $resource)) {
return;
}
if ($request->isXmlHttpRequest()) {
Axis::message()->addError(Axis::translate('admin')->__('You have no permission for this operation'));
$jsonHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
$jsonHelper->sendFailure();
return;
}
$request->setModuleName('Axis_Admin')->setControllerName('error')->setActionName('access-denied')->setDispatched(false);
}
开发者ID:rguedes,项目名称:axiscommerce,代码行数:83,代码来源:Auth.php
示例19: run
/**
* Factory method that runs a given migration.
*
* @param string $fileName
* @param string $direction
*/
public static function run($fileName, $direction, $verbose)
{
if ($direction == 'drop') {
// We create a fake instance here since drop is not associated
// with any real migration class.
$dropper = new self('', __CLASS__);
$dropper->migrate('drop');
return;
}
$inflector = new Zend_Filter_Inflector(':class', array(':class' => 'Word_DashToCamelCase'));
preg_match('/(\\d+)_(.+)\\.php/', basename($fileName), $matches);
$version = $matches[1];
$class = $inflector->filter(array(':class' => $matches[2]));
include $fileName;
if (class_exists($class)) {
$migration = new $class($version, $class, $verbose);
$migration->migrate($direction);
$migration->updateInstalledVersions($version, $direction);
} else {
$msg = "Class '{$class}' is not present in the migration file";
$this->write($msg);
throw new Svenax_Migration_Exception($msg);
}
}
开发者ID:svenax,项目名称:Zend_Migrations,代码行数:30,代码来源:Base.php
示例20: 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
注:本文中的Zend_Filter_Inflector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论