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


PHP SpoonFilter::isInteger方法代码示例

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


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

示例1: parse

 /**
  * Parses the html for this filefield.
  *
  * @param \SpoonTemplate $template The template to parse the element in.
  * @return string
  */
 public function parse($template = null)
 {
     // get upload_max_filesize
     $uploadMaxFilesize = ini_get('upload_max_filesize');
     if ($uploadMaxFilesize === false) {
         $uploadMaxFilesize = 0;
     }
     // reformat if defined as an integer
     if (\SpoonFilter::isInteger($uploadMaxFilesize)) {
         $uploadMaxFilesize = $uploadMaxFilesize / 1024 . 'MB';
     }
     // reformat if specified in kB
     if (strtoupper(substr($uploadMaxFilesize, -1, 1)) == 'K') {
         $uploadMaxFilesize = substr($uploadMaxFilesize, 0, -1) . 'kB';
     }
     // reformat if specified in MB
     if (strtoupper(substr($uploadMaxFilesize, -1, 1)) == 'M') {
         $uploadMaxFilesize .= 'B';
     }
     // reformat if specified in GB
     if (strtoupper(substr($uploadMaxFilesize, -1, 1)) == 'G') {
         $uploadMaxFilesize .= 'B';
     }
     // name is required
     if ($this->attributes['name'] == '') {
         throw new \SpoonFormException('A name is required for a file field. Please provide a name.');
     }
     // start html generation
     $output = '<input type="file"';
     // add attributes
     $output .= $this->getAttributesHTML(array('[id]' => $this->attributes['id'], '[name]' => $this->attributes['name'])) . ' />';
     // add help txt if needed
     if (!$this->hideHelpTxt) {
         if (isset($this->attributes['extension'])) {
             $output .= '<span class="helpTxt">' . sprintf(Language::getMessage('HelpFileFieldWithMaxFileSize', 'core'), $this->attributes['extension'], $uploadMaxFilesize) . '</span>';
         } else {
             $output .= '<span class="helpTxt">' . sprintf(Language::getMessage('HelpMaxFileSize'), $uploadMaxFilesize) . '</span>';
         }
     }
     // parse to template
     if ($template !== null) {
         $template->assign('file' . \SpoonFilter::toCamelCase($this->attributes['name']), $output);
         $template->assign('file' . \SpoonFilter::toCamelCase($this->attributes['name']) . 'Error', $this->errors != '' ? '<span class="formError">' . $this->errors . '</span>' : '');
     }
     return $output;
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:52,代码来源:FormFile.php

示例2: createAction

 /**
  * Create form action and strip the identifier parameter.
  *
  * We use this function to create the action for the form.
  * This action cannot contain an identifier since these are used for
  * statistics and failed form submits cannot be tracked.
  *
  * @return string
  */
 private function createAction()
 {
     // pages
     $action = implode('/', $this->URL->getPages());
     // init parameters
     $parameters = $this->URL->getParameters();
     $moduleParameters = array();
     $getParameters = array();
     // sort by key (important for action order)
     ksort($parameters);
     // loop and filter parameters
     foreach ($parameters as $key => $value) {
         // skip identifier
         if ($key === 'identifier') {
             continue;
         }
         // normal parameter
         if (\SpoonFilter::isInteger($key)) {
             $moduleParameters[] = $value;
         } else {
             // get parameter
             $getParameters[$key] = $value;
         }
     }
     // single language
     if ($this->getContainer()->getParameter('site.multilanguage')) {
         $action = LANGUAGE . '/' . $action;
     }
     // add to action
     if (count($moduleParameters) > 0) {
         $action .= '/' . implode('/', $moduleParameters);
     }
     if (count($getParameters) > 0) {
         $action .= '?' . http_build_query($getParameters, null, '&', PHP_QUERY_RFC3986);
     }
     // remove trailing slash
     $action = rtrim($action, '/');
     // cough up action
     return '/' . $action;
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:49,代码来源:Form.php

示例3: createAction

 /**
  * Create form action and strip the identifier parameter.
  *
  * We use this function to create the action for the form.
  * This action cannot contain an identifier since these are used for statistics and failed form submits cannot be tracked.
  *
  * @return string
  */
 private function createAction()
 {
     // pages
     $action = implode('/', $this->URL->getPages());
     // init parameters
     $parameters = $this->URL->getParameters();
     $moduleParameters = array();
     $getParameters = array();
     // sort by key (important for action order)
     ksort($parameters);
     // loop and filter parameters
     foreach ($parameters as $key => $value) {
         // skip identifier
         if ($key === 'identifier') {
             continue;
         }
         // normal parameter
         if (SpoonFilter::isInteger($key)) {
             $moduleParameters[] = $value;
         } else {
             $getParameters[$key] = $value;
         }
     }
     // single language
     if (SITE_MULTILANGUAGE) {
         $action = FRONTEND_LANGUAGE . '/' . $action;
     }
     // add to action
     if (count($moduleParameters) > 0) {
         $action .= '/' . implode('/', $moduleParameters);
     }
     if (count($getParameters) > 0) {
         $action .= '?' . http_build_query($getParameters);
     }
     // remove trailing slash
     $action = rtrim($action, '/');
     // cough up action
     return SITE_URL . '/' . $action;
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:47,代码来源:form.php

示例4: testIsInteger

 public function testIsInteger()
 {
     $this->assertTrue(SpoonFilter::isInteger(0));
     $this->assertTrue(SpoonFilter::isInteger(1));
     $this->assertTrue(SpoonFilter::isInteger(1234567890));
     $this->assertTrue(SpoonFilter::isInteger(-1234567890));
     $this->assertFalse(SpoonFilter::isInteger(1.337));
     $this->assertFalse(SpoonFilter::isInteger(-1.337));
     $this->assertFalse(SpoonFilter::isInteger(array()));
 }
开发者ID:jeroendesloovere,项目名称:library,代码行数:10,代码来源:SpoonFilterTest.php

示例5: isInteger

 /**
  * Checks this field for numbers 0-9 and an optional - (minus) sign (in the beginning only).
  *
  * @return	bool
  * @param	string[optional] $error		The error message to set.
  */
 public function isInteger($error = null)
 {
     // filled
     if ($this->isFilled()) {
         // post/get data
         $data = $this->getMethod(true);
         // validate
         if (!isset($data[$this->attributes['name']]) || !SpoonFilter::isInteger($data[$this->attributes['name']])) {
             if ($error !== null) {
                 $this->setError($error);
             }
             return false;
         }
         return true;
     }
     // not submitted
     if ($error !== null) {
         $this->setError($error);
     }
     return false;
 }
开发者ID:szLuis,项目名称:oac,代码行数:27,代码来源:text.php

示例6: getWeekDay

 /**
  * Fetch a specific day of the week for a specific language.
  *
  * @return	string
  * @param	mixed $day						The name/number of the day.
  * @param	string[optional] $language		The language to use, possible values can be found by calling SpoonLocale::getAvailableLanguages().
  * @param	bool[optional] $abbreviated		Should the abbreviated value be used?
  */
 public static function getWeekDay($day, $language = 'en', $abbreviated = false)
 {
     // init vars
     $dayIndexes = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
     $dayNames = array('sunday' => 'sun', 'monday' => 'mon', 'tuesday' => 'tue', 'wednesday' => 'wed', 'thursday' => 'thu', 'friday' => 'fri', 'saturday' => 'sat');
     $language = SpoonFilter::getValue($language, self::$languages, 'en');
     $locale = array();
     // which day?
     if (SpoonFilter::isInteger($day)) {
         $day = $dayIndexes[SpoonFilter::getValue(strtolower($day), range(0, 6), 0)];
     } else {
         $day = $dayNames[SpoonFilter::getValue(strtolower($day), array_keys($dayNames), 'sunday')];
     }
     // fetch file
     require 'data/' . $language . '.php';
     // abbreviated?
     return $abbreviated ? $locale['date']['days']['abbreviated'][$day] : $locale['date']['days']['full'][$day];
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:26,代码来源:locale.php

示例7: isValid

 /**
  * Checks if this field is correctly submitted.
  *
  * @return	bool
  * @param	string[optional] $error		The errormessage to set.
  */
 public function isValid($error = null)
 {
     // field has been filled in
     if ($this->isFilled()) {
         // post/get data
         $data = $this->getMethod(true);
         if (!is_scalar($data[$this->getName()])) {
             if ($error !== null) {
                 $this->setError($error);
             }
             return false;
         }
         // maxlength checks out (needs to be equal)
         if (strlen((string) $data[$this->attributes['name']]) == $this->attributes['maxlength']) {
             // define long mask
             $longMask = str_replace(array('d', 'm', 'y', 'Y'), array('dd', 'mm', 'y', 'yy'), $this->mask);
             // init vars
             $year = (int) date('Y');
             $month = (int) date('m');
             $day = (int) date('d');
             // validate year (yyyy)
             if (strpos($longMask, 'yy') !== false) {
                 // redefine year
                 $year = substr($data[$this->attributes['name']], strpos($longMask, 'yy'), 4);
                 // not an int
                 if (!SpoonFilter::isInteger($year)) {
                     if ($error !== null) {
                         $this->setError($error);
                     }
                     return false;
                 }
                 // invalid year
                 if (!checkdate(1, 1, $year)) {
                     if ($error !== null) {
                         $this->setError($error);
                     }
                     return false;
                 }
             }
             // validate year (yy)
             if (strpos($longMask, 'y') !== false && strpos($longMask, 'yy') === false) {
                 // redefine year
                 $year = substr($data[$this->attributes['name']], strpos($longMask, 'y'), 2);
                 // not an int
                 if (!SpoonFilter::isInteger($year)) {
                     if ($error !== null) {
                         $this->setError($error);
                     }
                     return false;
                 }
                 // invalid year
                 if (!checkdate(1, 1, '19' . $year)) {
                     if ($error !== null) {
                         $this->setError($error);
                     }
                     return false;
                 }
             }
             // validate month (mm)
             if (strpos($longMask, 'mm') !== false) {
                 // redefine month
                 $month = substr($data[$this->attributes['name']], strpos($longMask, 'mm'), 2);
                 // not an int
                 if (!SpoonFilter::isInteger($month)) {
                     if ($error !== null) {
                         $this->setError($error);
                     }
                     return false;
                 }
                 // invalid month
                 if (!checkdate($month, 1, $year)) {
                     if ($error !== null) {
                         $this->setError($error);
                     }
                     return false;
                 }
             }
             // validate day (dd)
             if (strpos($longMask, 'dd') !== false) {
                 // redefine day
                 $day = substr($data[$this->attributes['name']], strpos($longMask, 'dd'), 2);
                 // not an int
                 if (!SpoonFilter::isInteger($day)) {
                     if ($error !== null) {
                         $this->setError($error);
                     }
                     return false;
                 }
                 // invalid day
                 if (!checkdate($month, $day, $year)) {
                     if ($error !== null) {
                         $this->setError($error);
                     }
                     return false;
//.........这里部分代码省略.........
开发者ID:jeroendesloovere,项目名称:library,代码行数:101,代码来源:date.php

示例8: getTemplates

    /**
     * Get templates
     *
     * @param string[optional] $theme The theme we want to fetch the templates from.
     * @return array
     */
    public static function getTemplates($theme = null)
    {
        // get db
        $db = BackendModel::getDB();
        // validate input
        $theme = SpoonFilter::getValue((string) $theme, null, BackendModel::getModuleSetting('core', 'theme', 'core'));
        // get templates
        $templates = (array) $db->getRecords('SELECT i.id, i.label, i.path, i.data
												FROM themes_templates AS i
												WHERE i.theme = ? AND i.active = ?
												ORDER BY i.label ASC', array($theme, 'Y'), 'id');
        // get extras
        $extras = (array) self::getExtras();
        // init var
        $half = (int) ceil(count($templates) / 2);
        $i = 0;
        // loop templates to unserialize the data
        foreach ($templates as $key => &$row) {
            // unserialize
            $row['data'] = unserialize($row['data']);
            $row['has_block'] = false;
            // reset
            if (isset($row['data']['default_extras_' . BL::getWorkingLanguage()])) {
                $row['data']['default_extras'] = $row['data']['default_extras_' . BL::getWorkingLanguage()];
            }
            // any extras?
            if (isset($row['data']['default_extras'])) {
                // loop extras
                foreach ($row['data']['default_extras'] as $value) {
                    // store if the module has blocks
                    if (SpoonFilter::isInteger($value) && isset($extras[$value]) && $extras[$value]['type'] == 'block') {
                        $row['has_block'] = true;
                    }
                }
            }
            // validate
            if (!isset($row['data']['format'])) {
                throw new BackendException('Invalid template-format.');
            }
            // build template HTML
            $row['html'] = self::buildTemplateHTML($row['data']['format']);
            $row['htmlLarge'] = self::buildTemplateHTML($row['data']['format'], true);
            // add all data as json
            $row['json'] = json_encode($row);
            // add the break-element so the templates can be split in 2 columns in the templatechooser
            if ($i == $half) {
                $row['break'] = true;
            }
            // increment
            $i++;
        }
        return (array) $templates;
    }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:59,代码来源:model.php

示例9: getTemplates

 /**
  * Get templates
  *
  * @param string $theme The theme we want to fetch the templates from.
  *
  * @return array
  * @throws Exception
  */
 public static function getTemplates($theme = null)
 {
     $db = BackendModel::getContainer()->get('database');
     $theme = \SpoonFilter::getValue((string) $theme, null, BackendModel::get('fork.settings')->get('Core', 'theme', 'Core'));
     $templates = (array) $db->getRecords('SELECT i.id, i.label, i.path, i.data
         FROM themes_templates AS i
         WHERE i.theme = ? AND i.active = ?
         ORDER BY i.label ASC', array($theme, 'Y'), 'id');
     $extras = (array) self::getExtras();
     $half = (int) ceil(count($templates) / 2);
     $i = 0;
     foreach ($templates as &$row) {
         $row['data'] = unserialize($row['data']);
         $row['has_block'] = false;
         // reset
         if (isset($row['data']['default_extras_' . BL::getWorkingLanguage()])) {
             $row['data']['default_extras'] = $row['data']['default_extras_' . BL::getWorkingLanguage()];
         }
         // any extras?
         if (isset($row['data']['default_extras'])) {
             foreach ($row['data']['default_extras'] as $value) {
                 if (\SpoonFilter::isInteger($value) && isset($extras[$value]) && $extras[$value]['type'] == 'block') {
                     $row['has_block'] = true;
                 }
             }
         }
         // validate
         if (!isset($row['data']['format'])) {
             throw new Exception('Invalid template-format.');
         }
         $row['html'] = self::buildTemplateHTML($row['data']['format']);
         $row['htmlLarge'] = self::buildTemplateHTML($row['data']['format'], true);
         $row['json'] = json_encode($row);
         if ($i == $half) {
             $row['break'] = true;
         }
         ++$i;
     }
     return (array) $templates;
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:48,代码来源:Model.php

示例10: setPriority

 /**
  * Sets the email priority level.
  *
  * @param	int[optional] $level	The e-mail's priority level (1-5, where 1 is not urgent).
  */
 public function setPriority($level = 3)
 {
     // check input
     if (!SpoonFilter::isInteger($level) || !SpoonFilter::getValue($level, range(1, 5, 1), 3, 'int')) {
         throw new SpoonEmailException('No valid priority level given, integer from 1 to 5 required.');
     }
     // store priority level
     $this->priority = $level;
 }
开发者ID:richsage,项目名称:forkcms,代码行数:14,代码来源:email.php

示例11: isCorrectSyntax

 /**
  * Check the string for syntax errors
  *
  * @return	bool
  * @param	string $string
  * @param	string $type
  */
 private function isCorrectSyntax($string, $type)
 {
     // init vars
     $string = (string) $string;
     $type = SpoonFilter::getValue($type, array('cycle', 'iteration', 'option', 'variable'), 'variable', 'string');
     // types
     switch ($type) {
         // cycle string
         case 'cycle':
             // the number of single qoutes should always be an even number
             if (!SpoonFilter::isEven(substr_count($string, "'"))) {
                 return false;
             }
             break;
             // iteration string
         // iteration string
         case 'iteration':
             // the number of square opening/closing brackets should be equal
             if (substr_count($string, '[') != substr_count($string, ']')) {
                 return false;
             }
             // the number of single qoutes should always be an even number
             if (!SpoonFilter::isEven(substr_count($string, "'"))) {
                 return false;
             }
             // first charachter should not be a number
             if (SpoonFilter::isInteger(substr($string, 2, 1))) {
                 return false;
             }
             // square bracket followed by a dot is NOT allowed eg {option:variable[0].var}
             if (substr_count($string, '].') != 0) {
                 return false;
             }
             // dot followed by a square bracket is NOT allowed eg {option:variable.['test']}
             if (substr_count($string, '.[') != 0) {
                 return false;
             }
             // empty brackets are NOT allowed
             if (substr_count($string, '[]') != 0) {
                 return false;
             }
             break;
             // option string
         // option string
         case 'option':
             // the number of square opening/closing brackets should be equal
             if (substr_count($string, '[') != substr_count($string, ']')) {
                 return false;
             }
             // the number of single qoutes should always be an even number
             if (!SpoonFilter::isEven(substr_count($string, "'"))) {
                 return false;
             }
             // square bracket followed by a dot is NOT allowed eg {option:variable[0].var}
             if (substr_count($string, '].') != 0) {
                 return false;
             }
             // dot followed by a square bracket is NOT allowed eg {option:variable.['test']}
             if (substr_count($string, '.[') != 0) {
                 return false;
             }
             // empty brackets are NOT allowed
             if (substr_count($string, '[]') != 0) {
                 return false;
             }
             break;
             // variable string
         // variable string
         case 'variable':
             // the number of square opening/closing brackets should be equal
             if (substr_count($string, '[') != substr_count($string, ']')) {
                 return false;
             }
             // the number of single qoutes should always be an even number
             if (!SpoonFilter::isEven(substr_count($string, "'"))) {
                 return false;
             }
             // first charachter should not be a number
             if (SpoonFilter::isInteger(substr($string, 2, 1))) {
                 return false;
             }
             // square bracket followed by a dot is NOT allowed eg {$variable[0].var}
             if (substr_count($string, '].') != 0) {
                 return false;
             }
             // dot followed by a square bracket is NOT allowed eg {$variable.['test']}
             if (substr_count($string, '.[') != 0) {
                 return false;
             }
             // empty brackets are NOT allowed
             if (substr_count($string, '[]') != 0) {
                 return false;
             }
//.........这里部分代码省略.........
开发者ID:JonckheereM,项目名称:Public,代码行数:101,代码来源:compiler.php


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