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


PHP Zend_Filter_Word_CamelCaseToSeparator::filter方法代码示例

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


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

示例1: addSubElement

 /**
  * Function to add Sub Elements form to the element.
  *
  * @param string $formClass  Class name of the form to be added.
  * @param string $elementClassName        Class name of the element whose form is added, eg for transaction _tiedstatus the
  * classname is TiedStatus.
  * @param int $elementCount     Count value for the element. It is added as the array key for the element's array
  * @param array $attribs        Array of form element values. 
  */
 public function addSubElement($formClass, $elementClassName, $elementCount, $attribs = null, $multiple = false)
 {
     $subForm = new $formClass();
     $camelCaseToSeperator = new Zend_Filter_Word_CamelCaseToSeparator(" ");
     $title = $camelCaseToSeperator->filter($elementClassName);
     $subForm->removeDecorator('form');
     if ($multiple) {
         $add = new Iati_Form_Element_Note('add');
         $add->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'button'));
         $add->setValue("<a href='#' class='add-element' value='{$elementClassName}'> Add More</a>");
         $add->setOrder(101);
         $remove = new Iati_Form_Element_Note('remove');
         $remove->setValue("<a href='/wep/remove-elements?classname={$elementClassName}' class='remove-this'> Remove This</a>");
         $remove->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'remove button'));
         $remove->setOrder(100);
         $subForm->addElements(array($add, $remove));
     }
     $subForm->addDisplayGroup(array_keys($subForm->getElements()), $elementClassName, array('legend' => $title, 'class' => $subForm->getAttrib('class')));
     $subForm->setElementsBelongTo("{$elementClassName}[{$elementCount}]");
     if ($attribs) {
         $subForm->populate($attribs);
     }
     $subForm->addDecorators(array(array(array('wrapperAll' => 'HtmlTag'), array('tag' => 'div', 'options' => array('class' => 'element-wrapper')))));
     $this->addSubForm($subForm, "{$elementClassName}{$elementCount}");
     return $subForm;
 }
开发者ID:relyd,项目名称:aidstream,代码行数:35,代码来源:Form.php

示例2: getContentsPacked

 public function getContentsPacked()
 {
     if (!$this->_features) {
         return null;
     }
     $modernizrPath = getcwd() . '/node_modules/modernizr';
     $outputFile = tempnam('./temp', 'modernizr');
     $configAll = json_decode(file_get_contents($modernizrPath . '/lib/config-all.json'), true);
     $allFeatureDetects = $configAll['feature-detects'];
     $options = array();
     foreach ($configAll['options'] as $i) {
         $options[$i] = false;
     }
     $options['mq'] = true;
     $options['setClasses'] = true;
     $featureDetects = array();
     foreach ($this->_features as $f) {
         if (isset($options[strtolower($f)])) {
             //for prefixed
             $options[strtolower($f)] = true;
         } else {
             $filter = new Zend_Filter_Word_CamelCaseToSeparator('/');
             $fFiltered = strtolower($filter->filter($f));
             if (!in_array($fFiltered, $allFeatureDetects)) {
                 throw new Kwf_Exception("Invalid Modernizr Dependency, test doesn't exist: '" . $f . "'");
             }
             $featureDetects[] = $fFiltered;
         }
     }
     foreach ($options as $k => $i) {
         if (!$i) {
             unset($options[$k]);
         }
     }
     $options = array_keys($options);
     $classPrefix = '';
     if (Kwf_Config::getValue('application.uniquePrefix')) {
         $classPrefix = Kwf_Config::getValue('application.uniquePrefix') . '-';
     }
     $config = array('classPrefix' => $classPrefix, 'options' => $options, 'feature-detects' => $featureDetects);
     $configFile = tempnam('temp/', 'modernizrbuild');
     unlink($configFile);
     $configFile .= '.json';
     file_put_contents($configFile, json_encode($config, JSON_PRETTY_PRINT));
     $cmd = getcwd() . "/" . VENDOR_PATH . "/bin/node {$modernizrPath}/bin/modernizr --config {$configFile} --uglify --dest " . $outputFile;
     exec($cmd, $out, $retVar);
     if ($retVar) {
         throw new Kwf_Exception("modernizr failed: " . implode("\n", $out));
     }
     $ret = file_get_contents($outputFile);
     unlink($configFile);
     unlink($outputFile);
     //remove comments containing selected tests
     $ret = preg_replace("#\n/\\*!\n\\{.*?\\}\n!\\*/\n#s", '', $ret);
     $ret = Kwf_SourceMaps_SourceMap::createEmptyMap($ret);
     $map = $ret->getMapContentsData(false);
     $map->{'_x_org_koala-framework_masterFiles'} = array(getcwd() . '/node_modules/modernizr/package.json');
     return $ret;
 }
开发者ID:koala-framework,项目名称:koala-framework,代码行数:59,代码来源:Dependency.php

示例3: testFilterSeparatesCamelCasedWordsWithProvidedSeparator

 public function testFilterSeparatesCamelCasedWordsWithProvidedSeparator()
 {
     $string = 'CamelCasedWords';
     $filter = new Zend_Filter_Word_CamelCaseToSeparator(':-#');
     $filtered = $filter->filter($string);
     $this->assertNotEquals($string, $filtered);
     $this->assertEquals('Camel:-#Cased:-#Words', $filtered);
 }
开发者ID:lortnus,项目名称:zf1,代码行数:8,代码来源:CamelCaseToSeparatorTest.php

示例4: _initBootstrap

 /**
  * Initialize class and log debug message
  * 
  * @return void
  * @access protected
  */
 protected function _initBootstrap()
 {
     // Fiter SeperatorToCamelCase Setup
     $filter = new Zend_Filter_Word_CamelCaseToSeparator('-');
     $this->_module['class'] = $this->getModuleName();
     $this->_module['folder'] = strtolower($filter->filter($this->_module['class']));
     // Info Log
     Zend_Registry::get('logging')->log($this->_module['class'] . ' bootstrap initialized...', Zend_Log::INFO);
 }
开发者ID:esironal,项目名称:kebab-project,代码行数:15,代码来源:Bootstrap.php

示例5: getByUrl

 public static function getByUrl($Url)
 {
     $TheLuogo = new self();
     try {
         $TheLuogo->fetchRowAndSet("Url = '{$Url}'");
         $TheLuogo = self::get($TheLuogo->IDLocation);
     } catch (Exception $E) {
         $filter = new Zend_Filter_Word_CamelCaseToSeparator();
         $Nome = ucfirst($filter->filter($Url));
         $Data = array('Name' => $Nome, 'Url' => $Url);
         $IDLuogo = $TheLuogo->insert($Data);
         $TheLuogo = self::get($IDLuogo);
     }
     return $TheLuogo;
 }
开发者ID:BGCX262,项目名称:zweer-gdr-svn-to-git,代码行数:15,代码来源:Luogo.php

示例6: _getFormElements

 /**
  * Gets the form elements code to add
  *
  * @param array $fields 
  * @return string
  */
 protected function _getFormElements($fields)
 {
     $upperFirst = new UCFirst();
     $camelCaseToSpace = new CamelCaseToSeparator();
     $elements = '';
     $fields = explode(',', $fields);
     foreach ($fields as $field) {
         list($name, $type) = strpos($field, ':') ? explode(':', $field) : array($field, 'string');
         $ucFirst = $upperFirst->filter($name);
         $label = $camelCaseToSpace->filter($ucFirst);
         switch ($type) {
             case 'text':
                 $elements .= "        \$this->addElement('textarea', " . "'{$name}', array('label' => '{$label}'));" . PHP_EOL;
                 break;
             default:
                 $elements .= "        \$this->addElement('text'," . " '{$name}', array('label' => " . "'{$label}'));" . PHP_EOL;
                 break;
         }
     }
     if (!empty($elements)) {
         $elements .= "        \$this->addElement('submit', 'Save');" . PHP_EOL;
     }
     return $elements;
 }
开发者ID:phpspec,项目名称:phpspec-zend,代码行数:30,代码来源:Form.php

示例7: createShowView

    /**
     * Creates the show view
     *
     * @param string $entity
     * @param array  $fields
     * @return string
     */
    protected static function createShowView($entity, $fields)
    {
        $upperFirst = new UCFirst();
        $lowerFirst = new LCFirst();
        $camelCaseToSpace = new CamelCaseToSeparator();
        $pluralize = new Pluralize();
        $entityPlural = $pluralize->filter($entity);
        $lowerEntity = $lowerFirst->filter($entity);
        $data = $rendered = '';
        $fields = explode(',', $fields);
        foreach ($fields as $field) {
            $fieldAndType = explode(':', $field);
            list($field, $type) = count($fieldAndType) === 2 ? $fieldAndType : array($field, 'string');
            $ucFirst = $upperFirst->filter($field);
            $field = $camelCaseToSpace->filter($ucFirst);
            $data .= "'get{$ucFirst}' => 'some {$field}'," . PHP_EOL . "            ";
            $rendered .= '$this->rendered->should->haveSelector(\'p>b\', ' . 'array(\'text\' => \'' . $field . ':\'));
        $this->rendered->should->contain(\'some ' . $field . '\');';
        }
        return <<<SHOWVIEW
<?php

namespace {$entityPlural};

use \\PHPSpec\\Context\\Zend\\View as ViewContext;

class DescribeShow extends ViewContext
{
    function before()
    {
        \$this->assign('{$lowerEntity}', \$this->stub('{$entity}', array(
            'getId' => '1',
            {$data}
        )));
    }
    
    function itRendersThe{$entity}()
    {
        \$this->render();
        {$rendered}
    }
}
SHOWVIEW;
    }
开发者ID:phpspec,项目名称:phpspec-zend,代码行数:51,代码来源:ViewSpec.php

示例8: getContents

 public function getContents($language)
 {
     if (isset($this->_contentsCache)) {
         return $this->_contentsCache;
     }
     if (!$this->_features) {
         return null;
     }
     $modernizrPath = dirname(dirname(dirname(dirname(__FILE__)))) . '/node_modules/modernizr';
     $package = json_decode(file_get_contents($modernizrPath . '/package.json'), true);
     $this->_outputFile = getcwd() . '/temp/modernizr-' . $package['version'] . '-' . implode('-', $this->_features) . '/modernizr.js';
     if (file_exists($this->_outputFile)) {
         $ret = file_get_contents($this->_outputFile);
         $this->_contentsCache = $ret;
         return $ret;
     }
     $configAll = json_decode(file_get_contents($modernizrPath . '/lib/config-all.json'), true);
     $allFeatureDetects = $configAll['feature-detects'];
     $options = array();
     foreach ($configAll['options'] as $i) {
         $options[$i] = false;
     }
     $options['mq'] = true;
     $options['setClasses'] = true;
     $featureDetects = array();
     foreach ($this->_features as $f) {
         if (isset($options[strtolower($f)])) {
             //for prefixed
             $options[strtolower($f)] = true;
         } else {
             $filter = new Zend_Filter_Word_CamelCaseToSeparator('/');
             $fFiltered = strtolower($filter->filter($f));
             if (!in_array($fFiltered, $allFeatureDetects)) {
                 throw new Kwf_Exception("Invalid Modernizr Dependency, test doesn't exist: '" . $f . "'");
             }
             $featureDetects[] = $fFiltered;
         }
     }
     foreach ($options as $k => $i) {
         if (!$i) {
             unset($options[$k]);
         }
     }
     $options = array_keys($options);
     $classPrefix = '';
     if (Kwf_Config::getValue('application.uniquePrefix')) {
         $classPrefix = Kwf_Config::getValue('application.uniquePrefix') . '-';
     }
     $config = array('classPrefix' => $classPrefix, 'options' => $options, 'feature-detects' => $featureDetects);
     $configFile = tempnam('temp/', 'modernizrbuild');
     unlink($configFile);
     $configFile .= '.json';
     file_put_contents($configFile, json_encode($config, JSON_PRETTY_PRINT));
     $cmd = "./" . VENDOR_PATH . "/bin/node {$modernizrPath}/bin/modernizr --config {$configFile} --uglify --dest " . dirname($this->_outputFile);
     exec($cmd, $out, $retVar);
     unlink($configFile);
     if ($retVar) {
         throw new Kwf_Exception("modernizr failed: " . implode("\n", $out));
     }
     $ret = file_get_contents($this->_outputFile);
     $this->_contentsCache = $ret;
     return $ret;
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:63,代码来源:Dependency.php

示例9: processRawData

 /**
  * Process raw XMP string by converting to a DOM document, replacing legend codes with their meanings,
  * fixing labels, etc.
  *
  * @param 		xml string$xmpstring
  *
  * @return array|bool
  */
 function processRawData($xmpstring)
 {
     //need to do a little preparation before processing fields
     if (!empty($xmpstring)) {
         $xmp = new DOMDocument();
         //create a DOM Document from the XML string
         $xmp->loadXML($xmpstring);
         //convert Dom Document to an array
         //TODO use Zend_Json::fromXml when zend fixes bug (see http://framework.zend.com/issues/browse/ZF-12224)
         $xmparray = $this->xmpDomToArray($xmp);
         //re-label Native Digest fields in tiff and exif sections to keep from overwriting when arrays are flattened
         //in other functions
         $sections = array('exif', 'tiff');
         foreach ($sections as $section) {
             if (isset($xmparray[$section]['NativeDigest'])) {
                 $temp = explode(',', $xmparray[$section]['NativeDigest']['rawval']);
                 $xmparray[$section]['NativeDigest']['rawval'] = implode(', ', $temp);
                 $xmparray[$section][strtoupper($section) . 'NativeDigest'] = $xmparray[$section]['NativeDigest'];
                 unset($xmparray[$section]['NativeDigest']);
             }
         }
         //now we can process fields
         $filter = new Zend_Filter_Word_CamelCaseToSeparator();
         foreach ($xmparray as $group => $fields) {
             foreach ($fields as $name => $field) {
                 if (isset($this->specs[$group][$name])) {
                     //shorten the variable
                     $specname = $this->specs[$group][$name];
                     //convert coded fields into tags
                     if (isset($specname['options'])) {
                         $xmparray[$group][$name]['newval'] = $specname['options'][$xmparray[$group][$name]['rawval']];
                     } else {
                         $xmparray[$group][$name]['newval'] = $xmparray[$group][$name]['rawval'];
                     }
                     //fix labels
                     if (isset($specname['label'])) {
                         $xmparray[$group][$name]['label'] = $specname['label'];
                     } else {
                         //create reading-friendly labels from camel case tags
                         $xmparray[$group][$name]['label'] = $filter->filter($name);
                     }
                 } else {
                     //those not covered in $specs
                     //create reading-friendly labels from camel case tags
                     $xmparray[$group][$name]['label'] = $filter->filter($name);
                     $xmparray[$group][$name]['newval'] = $xmparray[$group][$name]['rawval'];
                 }
                 //deal with arrays
                 if (is_array($field['rawval'])) {
                     if (array_key_exists($name, $this->special)) {
                         $xmparray[$group][$name]['newval'] = $this->specialHandling($name, $field['rawval']);
                     } elseif (isset($field['rawval']['rawval'])) {
                         $xmparray[$group][$name]['newval'] = $field['rawval']['rawval'];
                     } elseif (isset($field['rawval'][0])) {
                         $xmparray[$group][$name]['newval'] = '';
                         foreach ($field['rawval'] as $val) {
                             $xmparray[$group][$name]['newval'] .= $val['rawval'] . '; ';
                         }
                     } else {
                         $xmparray[$group][$name]['newval'] = '';
                         foreach ($field['rawval'] as $val) {
                             $xmparray[$group][$name]['newval'] .= $val['label'] . ': ' . $val['rawval'] . '; ';
                         }
                     }
                 }
                 //convert dates
                 if (array_key_exists($name, array('ModifyDate' => '', 'DateCreated' => '', 'CreateDate' => '', 'MetadataDate' => ''))) {
                     $dateObj = new DateTime($xmparray[$group][$name]['newval']);
                     $date = $dateObj->format('Y-m-d  H:i:s  T');
                     $xmparray[$group][$name]['newval'] = $date;
                 }
             }
         }
     } else {
         return false;
     }
     return $xmparray;
 }
开发者ID:ameoba32,项目名称:tiki,代码行数:86,代码来源:xmp.php

示例10: _getShowViewContent

 /**
  * Gets the content of scaffolded show view
  *
  * @param string $entity 
  * @param array $fields 
  * @return string
  */
 protected static function _getShowViewContent($entity, $fields)
 {
     $upperFirst = new UCFirst();
     $lowerFirst = new LCFirst();
     $camelCaseToSpace = new CamelCaseToSeparator();
     $camelCaseToDash = new CamelCaseToDash();
     $pluralize = new Pluralize();
     $lowerEntity = $lowerFirst->filter($entity);
     $lowerEntityPlural = $pluralize->filter($lowerEntity);
     $dashedEntityPlural = $camelCaseToDash->filter($lowerEntityPlural);
     $properties = '';
     foreach ($fields as $field) {
         $upper = $upperFirst->filter($field);
         $field = $camelCaseToSpace->filter($field);
         $field = $upperFirst->filter($field);
         $properties .= "  <p>\n    <b>{$field}:</b>\n    <?php echo \$this->escape(\$this->{$lowerEntity}->get{$upper}()) ?></h3>\n  </p>" . PHP_EOL . PHP_EOL;
     }
     return "<h1>Show {$entity}</h1>\n\n{$properties}\n\n<a href=\"<?php echo \$this->baseUrl(" . "'{$dashedEntityPlural}/edit/id/' ." . " (int)\$this->{$lowerEntity}->getId()) ?>\">Edit</a> |\n<a href=\"<?php echo \$this->baseUrl(" . "'{$dashedEntityPlural}') ?>\">Back</a>";
 }
开发者ID:phpspec,项目名称:phpspec-zend,代码行数:26,代码来源:ViewContent.php

示例11: __callStatic

 /**
  * @static
  *
  * @param $name
  * @param $args
  *
  *
  * @return array[self]|self|mixed
  * @throws Lib_Exception
  * @throws Exception
  */
 public static function __callStatic($name, $args)
 {
     $matches = array();
     if (preg_match('/^get(List|Set)*By([a-zA-Z]+)$/', $name, $matches)) {
         /** @var Lib_Model $model */
         $model = new static();
         $cond = array();
         $list = false;
         $set = false;
         if (!empty($matches[1])) {
             if ($matches[1] == 'List') {
                 $list = true;
             } else {
                 $set = true;
             }
         }
         $filter = new Zend_Filter_Word_CamelCaseToSeparator('_');
         $attr = strtolower($filter->filter($matches[2]));
         if ($attr == 'id') {
             $attr = $model->getPrimaryKey();
         }
         if (!array_key_exists($attr, $model->toArray())) {
             $class = get_class($model);
             throw new Exception("Attribute '{$attr}' not exists in model '{$class}'");
         }
         $cond[$attr] = array_shift($args);
         if ($set) {
             return static::getSetBy($cond);
         }
         $result = static::getListBy($cond);
         if (!$list) {
             if (count($result) > 1) {
                 $class = get_class($model);
                 throw new Exception("Trying get more than 1 row by attribute '{$attr}' from model '{$class}'");
             } elseif (count($result) == 1) {
                 return array_shift($result);
             } else {
                 return new static();
             }
         } else {
             return $result;
         }
     } else {
         throw new Exception("Static method '{$name}' not implemented.");
     }
 }
开发者ID:tapiau,项目名称:muyo,代码行数:57,代码来源:db.php

示例12: _createViewSpecs

 /**
  * Creates the view specs
  *
  * @param string $entity 
  * @param string $commaSeparatedFields 
  * @param string $module
  */
 protected static function _createViewSpecs($entity, $commaSeparatedFields, $module)
 {
     $filter = new CamelCaseToSeparator('-');
     $pluralize = new Pluralize();
     $ds = DIRECTORY_SEPARATOR;
     $module = $module === null ? '' : $module . $ds;
     $controllerDir = strtolower($pluralize->filter($filter->filter($entity)));
     $viewSpecPath = ".{$ds}spec{$ds}views{$ds}{$module}{$controllerDir}";
     if (!file_exists($viewSpecPath)) {
         mkdir($viewSpecPath);
     }
     foreach (self::$_scaffoldActions as $view) {
         ViewSpec::create($viewSpecPath, $entity, $commaSeparatedFields, $view, $module);
     }
 }
开发者ID:phpspec,项目名称:phpspec-zend,代码行数:22,代码来源:Scaffold.php

示例13: content

    /**
     * Renders the content of the scaffolded controller spec
     *
     * @param string $entity 
     * @param array  $fields 
     * @param string $module 
     * @return string  
     */
    protected static function content($entity, $fields, $module)
    {
        $pluralize = new Pluralize();
        $dashIt = new CamelCaseToSeparator();
        $camelize = new DashToCamelCase();
        $lcFirst = new LCFirst();
        $ucFirst = new UCFirst();
        if ($module === null) {
            $module = $camelize->filter($module);
            $namespace = 'namespace ' . $ucFirst->filter($module) . ';' . PHP_EOL;
        } else {
            $namespace = '';
        }
        $entityPlural = $pluralize->filter($entity);
        $lcFirstEntity = $lcFirst->filter($entity);
        $lcFirstEntityPlural = $lcFirst->filter($entityPlural);
        $entityPluralDashed = $dashIt->filter($entityPlural);
        $smallCasedDashedPlural = strtolower($entityPluralDashed);
        $fieldsAndValues = $rendered = '';
        $fields = explode(',', $fields);
        foreach ($fields as $field) {
            $fieldAndType = explode(':', $field);
            list($field, $type) = count($fieldAndType) === 2 ? $fieldAndType : array($field, 'string');
            $fieldType = $type === 'text' ? 'textarea' : 'input';
            $fieldsAndValues .= "'{$field}' => 'some {$field}'," . PHP_EOL . "            ";
        }
        $appForm = "Application_Form_{$entity}Form";
        return <<<CONTROLLER
<?php
{$namespace}

class Describe{$entityPlural}Controller extends \\PHPSpec\\Context\\Zend\\Controller
{
    // GET index
    function itAssignsAll{$entityPlural}ToList()
    {
        \$mapper = \$this->stub('Application_Model_{$entity}Mapper');
        \$mapper->shouldReceive('fetchAll')->andReturn(array());
        \$this->inject('Application.Model.{$entity}Mapper', \$mapper);
        
        \$this->get('{$smallCasedDashedPlural}/index');
        \$this->assigns('{$lcFirstEntityPlural}')->should->be(array());
    }
    
    // GET show
    function itAssignsTheRequested{$entity}ToBeShown()
    {
        \${$lcFirstEntity} = \$this->stub('Application_Model_{$entity}');
        \$mapper = \$this->stub('Application_Model_{$entity}Mapper');
        \$mapper->shouldReceive('find')->andReturn(\${$lcFirstEntity});
        \$this->inject('Application.Model.{$entity}Mapper', \$mapper);
        
        \$this->get('{$smallCasedDashedPlural}/show');
        \$this->assigns('{$lcFirstEntity}')->should->be(\${$lcFirstEntity});
    }
    
    // GET edit
    function itPopulatesTheEditFormWithA{$entity}()
    {
        \${$lcFirstEntity}Array = array(
            'id' => 1,
            {$fieldsAndValues}
        );
        \${$lcFirstEntity} = \$this->stub('Application_Model_{$entity}');
        \${$lcFirstEntity}->shouldReceive('toArray')
             ->andReturn(\${$lcFirstEntity}Array);
        
        \$mapper = \$this->stub('Application_Model_{$entity}Mapper');
        \$mapper->shouldReceive('find')->andReturn(\${$lcFirstEntity});
        \$this->inject('Application.Model.{$entity}Mapper', \$mapper);
        
        \$form = \$this->stub('Application_Form_{$entity}Form');
        \$form->shouldReceive('populate')->with(\${$lcFirstEntity}Array);
        \$this->inject('Application.Form.{$entity}Form', \$form);
        \$this->get('{$smallCasedDashedPlural}/edit/id/1');
        
        \$this->assigns('id')->should->be('1');
        \$this->assigns('form')->should->be(\$form);
    }
    
    // GET new
    function itDisplaysThe{$entity}Form()
    {
        \$this->get('{$smallCasedDashedPlural}/new');
        \$this->assigns('form')->should->beAnInstanceOf('{$appForm}');
    }

    // POST add
    function itAddsTheValid{$entity}()
    {
        \$mapper = \$this->stub('Application_Model_{$entity}Mapper');
        \$mapper->shouldReceive('save')->once();
//.........这里部分代码省略.........
开发者ID:phpspec,项目名称:phpspec-zend,代码行数:101,代码来源:ControllerSpec.php

示例14: processRawData

 /**
  * Process raw EXIF data by converting binary or hex information, replacing legend codes with their meanings,
  * fixing labels, etc.
  *
  * @param		array		$exifraw		Array of raw EXIF data
  *
  * @return 		array		$exif			Array of processed EXIF data, including label, newval and suffix values
  * 												for each field
  */
 function processRawData($exifraw)
 {
     $filter = new Zend_Filter_Word_CamelCaseToSeparator();
     //array of tags to match exif array from file
     foreach ($exifraw as $group => $fields) {
         foreach ($fields as $name => $field) {
             if (isset($field)) {
                 //store raw value
                 $exif[$group][$name]['rawval'] = $field;
                 //thumbnail and ifd0 groups share the same specifications
                 $groupmask = $group == 'THUMBNAIL' ? 'IFD0' : $group;
                 //get tag data from $specs array
                 if (isset($this->specs[$groupmask][$name])) {
                     //shorten the variable
                     $specname = $this->specs[$groupmask][$name];
                     //convert binary values
                     if (isset($specname['binary']) && $specname['binary']) {
                         $exif[$group][$name]['rawval'] = bin2hex($exif[$group][$name]['rawval']);
                     }
                     //start processing rawval into newval
                     if (is_array($exif[$group][$name]['rawval'])) {
                         $exif[$group][$name]['newval'] = $this->processArray($exif[$group][$name]['rawval'], $name);
                         //perform division for rational fields, but only if not an array
                     } elseif (isset($specname['format']) && $specname['format'] == 'rational') {
                         $exif[$group][$name]['newval'] = $this->divide($field);
                         //move rest of rawvals into newvals
                     } else {
                         $exif[$group][$name]['newval'] = $exif[$group][$name]['rawval'];
                     }
                     //now determine display values using option values where they exist
                     if (isset($specname['options'])) {
                         //first handle special cases
                         if ($name == 'ComponentsConfiguration') {
                             $str = $exif[$group][$name]['newval'];
                             $opt = $specname['options'];
                             $disp = $opt[substr($str, 0, 2)] . ' ' . $opt[substr($str, 2, 2)] . ' ' . $opt[substr($str, 4, 2)] . ' ' . $opt[substr($str, 6, 2)];
                             $exif[$group][$name]['newval'] = $disp;
                         } elseif ($name == 'CFAPattern') {
                             $str = $exif[$group][$name]['newval'];
                             $opt = $specname['options'];
                             $disp = '[' . $opt[substr($str, 8, 2)] . ', ' . $opt[substr($str, 10, 2)] . '] [' . $opt[substr($str, 12, 2)] . ', ' . $opt[substr($str, 14, 2)] . ']';
                             $exif[$group][$name]['newval'] = $disp;
                         } else {
                             $exif[$group][$name]['newval'] = $specname['options'][$exif[$group][$name]['newval']];
                         }
                     }
                     //fix labels
                     if (isset($specname['label'])) {
                         $exif[$group][$name]['label'] = $specname['label'];
                     } else {
                         //create reading-friendly labels from camel case tags
                         $exif[$group][$name]['label'] = $filter->filter($name);
                     }
                     if (isset($specname['suffix']) && !is_array($exif[$group][$name]['newval'])) {
                         $exif[$group][$name]['suffix'] = $specname['suffix'];
                     }
                 } else {
                     //those not covered in $specs
                     $exif[$group][$name]['newval'] = $exif[$group][$name]['rawval'];
                     //create reading-friendly labels from camel case tags
                     $exif[$group][$name]['label'] = $filter->filter($name);
                 }
             }
         }
     }
     //*******Special Handling*********//
     //file name is computed by PHP and is meaningless when file is stored in tiki,
     //and dialog box has real name in title so not needed
     unset($exif['FILE']['FileName']);
     //file date is also computed by PHP and represents the time the metadata was extracted. This data is included
     //elsewhere and is not needed here
     unset($exif['FILE']['FileDateTime']);
     //No processing of maker notes yet as specific code is needed for each manufacturer
     //Blank out field since it is very long and will distort the dialog box
     if (!empty($exif['EXIF']['MakerNote']['newval'])) {
         $exif['EXIF']['MakerNote']['newval'] = '(Not processed)';
         unset($exif['EXIF']['MakerNote']['rawval']);
     }
     if (isset($exif['MAKERNOTE'])) {
         $exif['MAKERNOTE'] = "";
         $exif['MAKERNOTE']['Note']['label'] = "";
         $exif['MAKERNOTE']['Note']['newval'] = "(Not processed)";
     }
     //Interpret GPSVersion field
     if (isset($exif['GPS']['GPSVersion'])) {
         $exif['GPS']['GPSVersion']['newval'] = '';
         $len = strlen($exif['GPS']['GPSVersion']['rawval']);
         for ($i = 0; $i < $len; $i = $i + 2) {
             if ($i > 0) {
                 $exif['GPS']['GPSVersion']['newval'] .= '.';
             }
//.........这里部分代码省略.........
开发者ID:ameoba32,项目名称:tiki,代码行数:101,代码来源:exif.php


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