本文整理汇总了PHP中Zend_Filter_Word_CamelCaseToDash类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Filter_Word_CamelCaseToDash类的具体用法?PHP Zend_Filter_Word_CamelCaseToDash怎么用?PHP Zend_Filter_Word_CamelCaseToDash使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Filter_Word_CamelCaseToDash类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
if ($this->_resources = Axis::cache()->load('axis_acl_resources')) {
return;
}
foreach (Axis::app()->getModules() as $moduleName => $path) {
if ('Axis_Admin' === $moduleName) {
$path = $path . '/controllers';
} else {
$path = $path . '/controllers/Admin';
}
if (!is_dir($path)) {
continue;
}
foreach ($this->_scanDirectory($path) as $file) {
if (strstr($file, "Controller.php") == false) {
continue;
}
include_once $file;
}
}
$resource = 'admin';
$resources = array($resource);
$camelCaseToDash = new Zend_Filter_Word_CamelCaseToDash();
foreach (get_declared_classes() as $class) {
if (!is_subclass_of($class, 'Axis_Admin_Controller_Back')) {
continue;
}
list($module, $controller) = explode('Admin_', $class, 2);
$module = rtrim($module, '_');
if (empty($module)) {
$module = 'Axis_Core';
} elseif ('Axis' === $module) {
$module = 'Axis_Admin';
}
$module = strtolower($camelCaseToDash->filter($module));
list($namespace, $module) = explode('_', $module, 2);
$resource .= '/' . $namespace;
$resources[$resource] = $resource;
$resource .= '/' . $module;
$resources[$resource] = $resource;
$controller = substr($controller, 0, strpos($controller, "Controller"));
$controller = strtolower($camelCaseToDash->filter($controller));
$resource .= '/' . $controller;
$resources[$resource] = $resource;
foreach (get_class_methods($class) as $action) {
if (false == strstr($action, "Action")) {
continue;
}
$action = substr($action, 0, strpos($action, 'Action'));
$action = strtolower($camelCaseToDash->filter($action));
// $resources[$namespace][$module][$controller][] = $action;
$resources[$resource . '/' . $action] = $resource . '/' . $action;
}
$resource = 'admin';
}
asort($resources);
Axis::cache()->save($resources, 'axis_acl_resources', array('modules'));
$this->_resources = $resources;
}
示例2: testFilterSeparatesCamelCasedWordsWithDashes
public function testFilterSeparatesCamelCasedWordsWithDashes()
{
$string = 'CamelCasedWords';
$filter = new Zend_Filter_Word_CamelCaseToDash();
$filtered = $filter->filter($string);
$this->assertNotEquals($string, $filtered);
$this->assertEquals('Camel-Cased-Words', $filtered);
}
示例3: helpAction
public function helpAction()
{
$cc2d = new Zend_Filter_Word_CamelCaseToDash();
foreach (glob(__DIR__ . '/*.php') as $file) {
if (!preg_match('/.*\\/(\\w+).php$/', $file, $matches) || $matches[1] == 'Abstract') {
continue;
}
print $_SERVER['argv'][0] . ' ' . strtolower($cc2d->filter($matches[1])) . PHP_EOL;
}
}
示例4: helpAction
public function helpAction()
{
$cc2d = new Zend_Filter_Word_CamelCaseToDash();
foreach (get_class_methods($this) as $method) {
if (!preg_match('/^(\\w+)Action$/', $method, $matches) || $matches[1] == 'Abstract') {
continue;
}
print $_SERVER['argv'][0] . ' ' . $_SERVER['argv'][1] . ' ' . strtolower($cc2d->filter($matches[1])) . PHP_EOL;
}
}
示例5: setTemplate
/**
* Установить шаблон для формы
*
* @param string $template Имя файла с шаблоном без расширения
*/
public function setTemplate($template, $options = null)
{
if (is_null($options)) {
$options = array();
}
if (is_array($options)) {
$filter = new Zend_Filter_Word_CamelCaseToDash();
$template = $filter->filter($template);
$options['viewScript'] = 'forms/' . $template . '.phtml';
}
$this->setDecorators(array(array('viewScript', $options)));
}
示例6: __call
public function __call($name, $arguments)
{
$this->_mail = new Zend_Mail('utf-8');
$options = $arguments[0];
$f = new Zend_Filter_Word_CamelCaseToDash();
$tplDir = APPLICATION_PATH . '/../emailing/';
$mailView = new Zend_View();
$layoutView = new Zend_View();
$mailView->setScriptPath($tplDir);
$layoutView->setScriptPath($tplDir);
$template = strtolower($f->filter($name)) . '.phtml';
$subjects = new Zend_Config_Ini(APPLICATION_PATH . '/configs/mailing.ini', 'subjects');
$subjects = $subjects->toArray();
if (!is_readable(realpath($tplDir . $template))) {
throw new Zend_Mail_Exception('No existe template para este email');
}
if (!array_key_exists($name, $subjects) || trim($subjects[$name]) == "") {
throw new Zend_Mail_Exception('Subject no puede ser vacío, verificar mailing.ini');
} else {
$options['subject'] = $subjects[$name];
}
if (!array_key_exists('to', $options)) {
throw new Zend_Mail_Exception('Falta indicar destinatario en $options["to"]');
} else {
$v = new Zend_Validate_EmailAddress();
if (!$v->isValid($options['to'])) {
//throw new Zend_Mail_Exception('Email inválido');
// En lugar de lanzar un error, mejor lo logeo.
$log = Zend_Registry::get('log');
$log->warn('Email inválido: ' . $options['to']);
}
}
foreach ($options as $key => $value) {
$mailView->assign($key, $value);
$options['subject'] = str_replace('{%' . $key . '%}', $value, $options['subject']);
}
$mailView->addHelperPath('Core/View/Helper', 'Core_View_Helper');
$layoutView->addHelperPath('Core/View/Helper', 'Core_View_Helper');
$mailViewHtml = $mailView->render($template);
$layoutView->assign('emailTemplate', $mailViewHtml);
$mailHtml = $layoutView->render('_layout.phtml');
$this->_mail->setBodyHtml($mailHtml);
$this->_mail->addTo($options['to']);
$this->_mail->setSubject($options['subject']);
$this->_mail->send();
}
示例7: convertToClientNaming
/**
* convertToClientNaming()
*
* Convert words to client specific naming, in this case is lower, dash separated
*
* Filters are lazy-loaded.
*
* @param string $string
* @return string
*/
public function convertToClientNaming($string)
{
if (!$this->_filterToClientNaming) {
$filter = new Zend_Filter();
$filter->addFilter(new Zend_Filter_Word_CamelCaseToDash());
$filter->addFilter(new Zend_Filter_StringToLower());
$this->_filterToClientNaming = $filter;
}
return $this->_filterToClientNaming->filter($string);
}
示例8: _init
protected function _init()
{
$this->setDispatcher(new Kwf_Controller_Dispatcher());
$this->setControllerDirectory('controllers');
$this->returnResponse(true);
$this->setParam('disableOutputBuffering', true);
$this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Welcome', 'kwf_controller_action_welcome');
$this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/User', 'kwf_controller_action_user');
$this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Error', 'kwf_controller_action_error');
$this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Pool', 'kwf_controller_action_pool');
$this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Debug', 'kwf_controller_action_debug');
$this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Cli', 'kwf_controller_action_cli');
$this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Cli/Web', 'kwf_controller_action_cli_web');
$this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Media', 'kwf_controller_action_media');
$this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Spam', 'kwf_controller_action_spam');
$this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Enquiries', 'kwf_controller_action_enquiries');
$this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Redirects', 'kwf_controller_action_redirects');
$this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Maintenance', 'kwf_controller_action_maintenance');
$this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Trl', 'kwf_controller_action_trl');
if (file_exists('controllers/Cli')) {
$this->addControllerDirectory('controllers/Cli', 'cli');
}
$this->addControllerDirectory(KWF_PATH . '/Kwf/Controller/Action/Component', 'kwf_controller_action_component');
if (is_dir('controllers')) {
//automatically add controller directories from web based on existing directories in filesystem in web
$iterator = new DirectoryIterator('controllers');
$filter = new Zend_Filter_Word_CamelCaseToDash();
foreach ($iterator as $fileinfo) {
if (!$fileinfo->isDot() && $fileinfo->isDir() && $fileinfo->getBasename() != 'Cli') {
$this->addControllerDirectory($fileinfo->getPathname(), strtolower($filter->filter($fileinfo->getBasename())));
}
}
}
$plugin = new Zend_Controller_Plugin_ErrorHandler();
$plugin->setErrorHandlerModule('kwf_controller_action_error');
if (PHP_SAPI == 'cli') {
$plugin->setErrorHandlerController('cli');
}
$this->registerPlugin($plugin);
$this->setBaseUrl(Kwf_Setup::getBaseUrl());
}
示例9: convertToClientNaming
/**
* convertToClientNaming()
*
* Convert words to client specific naming, in this case is lower, dash separated
*
* Filters are lazy-loaded.
*
* @param string $string
* @return string
*/
public function convertToClientNaming($string)
{
if (!$this->_filterToClientNaming) {
#require_once 'Zend/Filter.php';
#require_once 'Zend/Filter/Word/CamelCaseToDash.php';
#require_once 'Zend/Filter/StringToLower.php';
$filter = new Zend_Filter();
$filter->addFilter(new Zend_Filter_Word_CamelCaseToDash());
$filter->addFilter(new Zend_Filter_StringToLower());
$this->_filterToClientNaming = $filter;
}
return $this->_filterToClientNaming->filter($string);
}
示例10: _buildRecord
/**
* @param Doctrine_Import_Builder $builder
* @param array $definition
*/
protected function _buildRecord($builder, $definition)
{
$className = $definition['className'];
if (strpos($className, "Model_") === false) {
throw ZFDoctrine_DoctrineException::invalidZendModel($className);
}
$classPrefix = substr($className, 0, strpos($className, 'Model_') + strlen('Model_'));
$camelCaseToDash = new Zend_Filter_Word_CamelCaseToDash();
$moduleName = current(explode("_", $className));
$moduleName = strtolower($camelCaseToDash->filter($moduleName));
if (!isset($this->_modules[$moduleName])) {
throw ZFDoctrine_DoctrineException::unknownModule($moduleName, $className);
}
$builder->setTargetPath($this->_modules[$moduleName]);
$builder->buildRecord($definition);
if ($this->_listener) {
$this->_listener->notifyRecordBuilt($className, $moduleName);
}
}
示例11: urlizeOptions
public function urlizeOptions($urlOptions, $actionControllerModuleOnly = true)
{
$ccToDash = new Zend_Filter_Word_CamelCaseToDash();
foreach ($urlOptions as $n => $v) {
if (in_array($n, array('action', 'controller', 'module'))) {
$urlOptions[$n] = $ccToDash->filter($v);
}
}
return $urlOptions;
}
示例12: _translateSpec
/**
* Inflect based on provided vars
*
* Allowed variables are:
* - :moduleDir - current module directory
* - :module - current module name
* - :controller - current controller name
* - :action - current action name
* - :suffix - view script file suffix
*
* @param array $vars
* @return string
*/
protected function _translateSpec(array $vars = array())
{
$inflector = $this->getInflector();
$request = $this->getRequest();
$dispatcher = $this->getFrontController()->getDispatcher();
// Format module name
$module = $dispatcher->formatModuleName($request->getModuleName());
// Format controller name
// require_once 'Zend/Filter/Word/CamelCaseToDash.php';
$filter = new Zend_Filter_Word_CamelCaseToDash();
$controller = $filter->filter($request->getControllerName());
$controller = $dispatcher->formatControllerName($controller);
if ('Controller' == substr($controller, -10)) {
$controller = substr($controller, 0, -10);
}
// Format action name
$action = $dispatcher->formatActionName($request->getActionName());
$params = compact('module', 'controller', 'action');
foreach ($vars as $key => $value) {
switch ($key) {
case 'module':
case 'controller':
case 'action':
case 'moduleDir':
case 'suffix':
$params[$key] = (string) $value;
break;
default:
break;
}
}
if (isset($params['suffix'])) {
$origSuffix = $this->getViewSuffix();
$this->setViewSuffix($params['suffix']);
}
if (isset($params['moduleDir'])) {
$origModuleDir = $this->_getModuleDir();
$this->_setModuleDir($params['moduleDir']);
}
$filtered = $inflector->filter($params);
if (isset($params['suffix'])) {
$this->setViewSuffix($origSuffix);
}
if (isset($params['moduleDir'])) {
$this->_setModuleDir($origModuleDir);
}
return $filtered;
}
示例13: getSlugURI
/**
* This returns the URL for an Omeka_Record with a 'slug' property.
*
* @param Omeka_Record $record The sluggable record to create the URL for.
* @param string $action The action to access the record with.
*
* @return string $uri The URI for the record.
* @author Eric Rochester <erochest@virginia.edu>
**/
public static function getSlugURI($record, $action)
{
// Copied from omeka/applications/helpers/UrlFunctions.php, record_uri.
// Yuck.
$recordClass = get_class($record);
$inflector = new Zend_Filter_Word_CamelCaseToDash();
$controller = strtolower($inflector->filter($recordClass));
$controller = Inflector::pluralize($controller);
$options = array('controller' => $controller, 'action' => $action, 'id' => $record->slug);
$uri = url($options, 'id');
return $uri;
}
示例14: __
echo __('Description');
?>
</th>
<th><?php
echo __('Item Number');
?>
</th>
<th><?php
echo __('Collection');
?>
</th>
</tr>
</thead>
<tbody>
<?php
$filter = new Zend_Filter_Word_CamelCaseToDash();
?>
<?php
foreach (loop('search_texts') as $searchText) {
?>
<?php
$record = get_record_by_id($searchText['record_type'], $searchText['record_id']);
?>
<?php
$recordType = $searchText['record_type'];
?>
<?php
set_current_record($recordType, $record);
?>
<tr class="<?php
echo strtolower($filter->filter($recordType));
示例15: getActions
/**
* Get all Actions for a modul / controller
*
* Method scans modul/controller for actions, which have the Zend Framework
* action method namespacing, like "indexAction".
*
* @param string $modul
* @param string $controller
* @return array
* @access public
*/
public function getActions($modul, $controller, $virtual)
{
$actions = array();
if ($virtual == 0) {
$frontController = Zend_Controller_Front::getInstance();
$className = ucfirst($modul) . '_' . ucfirst($controller) . 'Controller';
$classFile = ucfirst($controller) . 'Controller.php';
$directory = $frontController->getControllerDirectory($modul);
if (file_exists($directory . '/' . $classFile) === FALSE) {
throw new Admin_Model_Acl_Exception('Controller file could not be found');
}
require_once $directory . '/' . $classFile;
$reflect = new Zend_Reflection_Class($className);
$CcFilter = new Zend_Filter_Word_CamelCaseToDash();
foreach ($reflect->getMethods() as $method) {
if (preg_match('/(\\w+)Action$/', $method->getName(), $match)) {
$actionComment = $method->getName();
$name = $match[1];
$docComment = $method->getDocComment();
if (is_string($docComment)) {
$commentRows = explode("\n", $docComment);
$actionComment = preg_replace("/^\\s*\\*\\s*(.*)\\s*/", '$1', $commentRows[1]);
if ($actionComment === "") {
$actionComment = $docComment;
}
}
$actions[] = new Admin_Model_DbRow_Action(array('actionName' => strtolower($CcFilter->filter($name)), 'description' => $actionComment));
}
}
} else {
foreach ($this->hooks as $hook) {
foreach ($hook->getActions($modul, $controller) as $hAction) {
$actions[] = $hAction;
}
//$actions = array_merge_recursive($actions, $hook->getActions($modul, $controller));
}
}
return $actions;
}