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


PHP _transform函数代码示例

本文整理汇总了PHP中_transform函数的典型用法代码示例。如果您正苦于以下问题:PHP _transform函数的具体用法?PHP _transform怎么用?PHP _transform使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: validate

 /**
  * Validate element file upload.
  *
  * @param T_Cage_Array $source  source array (to ignore!)
  * @return T_Form_Element  fluent interface
  */
 function validate(T_Cage_Array $source)
 {
     $this->reset();
     $this->is_present = $this->isSubmitted($source);
     /* quit if not present, checking that is present if required */
     if (!$this->is_present) {
         if ($this->is_required) {
             $this->error = new T_Form_Error('is missing');
         }
         return $this;
     }
     /* check that no error has occurred during the upload */
     if ($source->isFileError($this->getFieldname())) {
         $err = $source->asFileError($this->getFieldname());
         $this->error = new T_Form_Error($err->getMessage());
         return $this;
     }
     /* get caged value */
     $upload = $source->asFile($this->getFieldname());
     /* now validate input by filtering */
     try {
         foreach ($this->filters as $filter) {
             $upload = _transform($upload, $filter);
         }
     } catch (T_Exception_Filter $e) {
         $this->error = new T_Form_Error($e->getMessage());
         return $this;
     }
     $this->clean = $upload;
     return $this;
 }
开发者ID:robtuley,项目名称:knotwerk,代码行数:37,代码来源:Upload.php

示例2: __toString

 /**
  * Return XHTML string.
  *
  * @return string
  */
 function __toString()
 {
     $xhtml = '';
     if (count($this->errors) == 0) {
         return $xhtml;
     }
     $f = new T_Filter_Xhtml();
     $xhtml = '<div class="error">' . EOL . '    <p>There were some problems with your submission:</p>' . EOL . '    <ul>' . EOL;
     foreach ($this->errors as $node) {
         $error = $node->getError();
         $msg = '';
         if (!$node instanceof T_Form_Container && !$node instanceof T_Form_Hidden) {
             $msg .= '<a href="#' . $node->getAlias() . '">' . $node->getLabel($f) . '</a> ';
         }
         $msg .= _transform($error->getMessage(), $f);
         $xhtml .= '        <li>' . $msg . '</li>' . EOL;
     }
     $xhtml .= '    </ul>' . EOL;
     if (count($this->recomplete) > 0) {
         $fields = array();
         foreach ($this->recomplete as $node) {
             $fields[] = '<a href="#' . $node->getAlias() . '">' . $node->getLabel($f) . '</a>';
         }
         $xhtml .= '    <p class="recomplete">In addition for security reasons the ' . implode(', ', $fields) . ' ';
         if (count($fields) > 1) {
             $xhtml .= 'fields have been cleared and need';
         } else {
             $xhtml .= 'field has been cleared and needs';
         }
         $xhtml .= ' to be recompleted.</p>' . EOL;
     }
     $xhtml .= '</div>';
     return $xhtml;
 }
开发者ID:robtuley,项目名称:knotwerk,代码行数:39,代码来源:XhtmlError.php

示例3: __construct

 /**
  * Initialise redirect request.
  *
  * Note that the redirect URL must be an ABSOLUTE rather than relative URL.
  * IIS under CGI mode has a bug which will crash when redirecting to
  * relative URLs.
  *
  * @param string $url  URL to redirect to
  */
 function __construct($url)
 {
     $f = new T_Filter_Xhtml();
     $content = '<html><head>' . '<meta http-equiv="Refresh" content="1;url=' . _transform($url, $f) . '">' . '</head><body>' . '<a href="' . _transform($url, $f) . '">Continue &rsaquo;</a>' . '</body></html>';
     parent::__construct(303);
     $this->setHeader("Location", $url);
     $this->setContent($content);
 }
开发者ID:robtuley,项目名称:knotwerk,代码行数:17,代码来源:Redirect.php

示例4: getCombinedType

 /**
  * Return string representation of type.
  *
  * @param function $filter
  * @return string
  */
 function getCombinedType($filter = null)
 {
     $type = $this->type ? $this->type : 'unknown';
     if ($this->isArray()) {
         $type .= '[]';
     }
     return _transform($type, $filter);
 }
开发者ID:robtuley,项目名称:knotwerk,代码行数:14,代码来源:DocBlockTypeTag.php

示例5: doTransform

 /**
  * Convert PHP source code to XHTML.
  *
  * The code is exported as an ordered list, with keywords, comments, etc.
  * highlighted with class spans.
  *
  * @return string  source code as marked up XHTML.
  */
 function doTransform($src)
 {
     $tokens = token_get_all(trim($src));
     $f = new T_Filter_Xhtml();
     $is_even = true;
     /* next line is even */
     $in_quotes = false;
     /* tracks if in *parsed* quoted string */
     $out = '<ol class="php">' . EOL . '    ' . '<li><code>';
     foreach ($tokens as $t) {
         /* standardize token (maybe array, or just plain content). */
         if (is_array($t)) {
             list($t_type, $t_content) = $t;
             $t_class = $this->getClassFromToken($t_type);
         } else {
             $t_type = false;
             $t_class = false;
             $t_content = $t;
         }
         /* If there is a double quoted string that contains embedded
            variables, the string is tokenized as components, and within
            this string is the only time we want to label T_STRING types as
            actual strings. The double quotes in this case always appear in
            on their own,and we use the $in_quotes to track this status */
         if ($t_type === false && $t_content === '"') {
             $t_class = $this->getClassFromToken(T_CONSTANT_ENCAPSED_STRING);
             $in_quotes = !$in_quotes;
         } elseif ($in_quotes && $t_type === T_STRING) {
             $t_class = $this->getClassFromToken(T_CONSTANT_ENCAPSED_STRING);
         }
         /* act on token. This is complicated by the fact that a token
            content can contain EOL markers, and in this case the token
            content must be separated at these lines. */
         $t_content = explode("\n", $t_content);
         for ($i = 0, $max = count($t_content) - 1; $i <= $max; $i++) {
             /* add new line (only from 2nd iteration onwards) */
             if ($i > 0) {
                 $e_class = $is_even ? ' class="even"' : '';
                 $is_even = !$is_even;
                 $out .= '</code></li>' . EOL . '    ' . '<li' . $e_class . '><code>';
             }
             /* right trim token content if it is at end of a line */
             $line = $t_content[$i];
             if ($i < $max) {
                 $line = rtrim($line);
             }
             /* wrap content in spans */
             if ($t_class !== false && strlen($line) > 0) {
                 $out .= '<span class="' . $t_class . '">' . _transform($line, $f) . '</span>';
             } else {
                 $out .= _transform($line, $f);
             }
         }
     }
     $out .= '</code></li>' . EOL . '</ol>';
     return $out;
 }
开发者ID:robtuley,项目名称:knotwerk,代码行数:65,代码来源:Php.php

示例6: _pluralize

/**
 * NOUNS
 * Pluralize the given noun using the plural rules.
 * @param $word noun to be pluralized
 *
 * @return pluralized word
 */
function _pluralize($word, $lang = 'en')
{
    if (strlen($word) == 1 || strlen($word) == 2) {
        return "";
    } else {
        $rules = _get_plural_rules($lang);
        return _transform($word, $rules);
    }
}
开发者ID:jgosier,项目名称:kamusi,代码行数:16,代码来源:template.php

示例7: testRejectsImageWhereAspectLessThanRange

 function testRejectsImageWhereAspectLessThanRange()
 {
     $filter = new T_Validate_ImageAspectRange(0.5, 2);
     $img = new T_Image_Gd(3, 8);
     try {
         _transform($img, $filter);
         $this->fail();
     } catch (T_Exception_Filter $e) {
     }
 }
开发者ID:robtuley,项目名称:knotwerk,代码行数:10,代码来源:ImageAspectRange.php

示例8: biasToCountry

 /**
  * Bias the geocode to a particular country.
  *
  * @param string $code  ISO 3166-1 country code
  * @return T_Google_GeoCode  fluent interface
  */
 function biasToCountry($code)
 {
     if ($code) {
         $filter = new T_Filter_CcTld();
         $this->cc_tld = _transform($code, $filter);
     } else {
         $this->cc_tld = false;
     }
     return $this;
 }
开发者ID:robtuley,项目名称:knotwerk,代码行数:16,代码来源:GeoCode.php

示例9: postElement

 protected function postElement($node)
 {
     $xhtml = null;
     if ($help = $node->getHelp()) {
         $f = new T_Filter_Xhtml();
         $xhtml = $this->indent . '<span class="help">' . _transform($help, $f) . '</span>' . EOL;
     }
     $xhtml .= $this->indent . '</li>' . EOL;
     return $xhtml;
 }
开发者ID:robtuley,项目名称:knotwerk,代码行数:10,代码来源:forms.php

示例10: reverse

 /**
  * Convert query string back to array of values.
  *
  * @param string $query  query string
  * @return array  data
  */
 function reverse($query)
 {
     $data = array();
     parse_str($query, $data);
     if (get_magic_quotes_gpc()) {
         // affected by magic_quotes settings
         $f = new T_Filter_NoMagicQuotes();
         $data = _transform($data, $f);
     }
     return $data;
 }
开发者ID:robtuley,项目名称:knotwerk,代码行数:17,代码来源:ToUrlQuery.php

示例11: testFilterFailsWhenNotANumber

 function testFilterFailsWhenNotANumber()
 {
     $filter = new T_Validate_FloatUnsigned();
     $invalid = array('', '@', '0.y7', '0.8.0', '8%', '6.7$7', '10..5', '.');
     foreach ($invalid as $term) {
         try {
             _transform($term, $filter);
             $this->fail("Accepted value {$term}");
         } catch (T_Exception_Filter $e) {
         }
     }
 }
开发者ID:robtuley,项目名称:knotwerk,代码行数:12,代码来源:FloatUnsigned.php

示例12: doTransform

 /**
  * Converts coverage to text.
  *
  * @param T_Unit_CodeCoverage $value  data to filter
  * @return string  rendered as string
  */
 protected function doTransform($value)
 {
     $total = $value->getNumExe() + $value->getNumNotExe();
     $render = 'Code coverage: ' . round($value->getCoverageRatio() * 100, 2) . '% ' . '(over ' . $total . ' executable lines)' . EOL;
     if ($value->getNumNotExe() > 0) {
         $table = array(array('File', 'Lines Not Exe'));
         foreach ($value->getNotExe() as $path => $missed) {
             $table[] = array($path, implode(',', $missed));
         }
         $as_table = new T_Filter_TextTable();
         $render .= EOL . _transform($table, $as_table) . EOL;
     }
     return $render;
 }
开发者ID:robtuley,项目名称:knotwerk,代码行数:20,代码来源:CoverageForTerminal.php

示例13: doTransform

 /**
  * Applies filter to each member of array.
  *
  * @param array $value  data to filter
  * @return array  filtered data
  */
 protected function doTransform($value)
 {
     if (!is_array($value)) {
         throw new T_Exception_Filter("{$value} is not an array");
     }
     $i = 1;
     foreach ($value as &$element) {
         try {
             $element = _transform($element, $this->map_filter);
         } catch (T_Exception_Filter $error) {
             $as_ord = new T_Filter_Ordinal();
             $msg = _transform($i, $as_ord) . ' item ' . $error->getMessage();
             throw new T_Exception_Filter($msg);
         }
         $i++;
     }
     return $value;
 }
开发者ID:robtuley,项目名称:knotwerk,代码行数:24,代码来源:ArrayMap.php

示例14: doTransform

 /**
  * Locates an address.
  *
  * @param T_Geo_Address $addr
  * @return T_Geo_Address  point
  */
 protected function doTransform($addr)
 {
     // prepare country
     $addr = clone $addr;
     if ($ctry = $addr->getCountry()) {
         $this->driver->biasToCountry($ctry->getCode());
     } else {
         $this->driver->biasToCountry(false);
     }
     // build query string
     $text = array($addr->getLineOne(), $addr->getLineTwo(), $addr->getCity(), $addr->getState(), $addr->getPostcode());
     $text = implode(', ', array_filter($text));
     // attempt to geocode
     try {
         $point = _transform($text, $this->driver);
     } catch (T_Exception_Filter $e) {
         throw new T_Exception_Filter("Could not locate the address provided");
     }
     // populate data back into address
     $addr->setLongitude($point->getLongitude())->setLatitude($point->getLatitude())->setAltitude($point->getAltitude());
     return $addr;
 }
开发者ID:robtuley,项目名称:knotwerk,代码行数:28,代码来源:GeoCodeAddress.php

示例15: validate

 /**
  * Validate.
  *
  * If fields are present, build address.
  */
 function validate(T_Cage_Array $src)
 {
     $this->clean = null;
     $this->error = false;
     foreach ($this->children as $child) {
         $child->validate($src);
     }
     $alias = $this->getAlias();
     // check address components are present
     if ($this->isPresent() && $this->isValid()) {
         $line_1 = $this->search($alias . '_line_1');
         $city = $this->search($alias . '_city');
         if (!$line_1->isPresent()) {
             $line_1->setError(new T_Form_Error('is missing'));
         }
         if (!$city->isPresent()) {
             $city->setError(new T_Form_Error('is missing'));
         }
     }
     // build address
     if ($this->isPresent() && $this->isValid()) {
         $data = array();
         $data['line1'] = $this->search($alias . '_line_1')->getValue();
         $data['line2'] = $this->search($alias . '_line_2')->getValue();
         $data['city'] = $this->search($alias . '_city')->getValue();
         $data['state'] = $this->search($alias . '_state')->getValue();
         $data['postcode'] = $this->search($alias . '_postcode')->getValue();
         if ($this->countries) {
             $code = $this->search($alias . '_country')->getValue();
             $data['country'] = $this->countries->getByCode($code);
         } else {
             $data['country'] = null;
         }
         $address = $this->factory->like('T_Geo_Address', $data);
         // filter address
         try {
             foreach ($this->filters as $filter) {
                 $address = _transform($address, $filter);
             }
             $this->setValue($address);
         } catch (T_Exception_Filter $e) {
             $this->setError(new T_Form_Error($e->getMessage()));
             return $this;
         }
     } elseif (!$this->isPresent() && $this->isRequired()) {
         $this->setError(new T_Form_Error('is missing'));
     }
     return $this;
 }
开发者ID:robtuley,项目名称:knotwerk,代码行数:54,代码来源:Address.php


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