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


PHP Validator::id方法代码示例

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


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

示例1: getEntryFormatterInfo

function getEntryFormatterInfo($id)
{
    global $database;
    static $info;
    if (!Validator::id($id)) {
        return NULL;
    } else {
        if (!isset($info[$id])) {
            $query = sprintf('SELECT contentformatter FROM %sEntries WHERE id = %d', $database['prefix'], $id);
            $info[$id] = POD::queryCell($query);
        }
    }
    return $info[$id];
}
开发者ID:hinablue,项目名称:TextCube,代码行数:14,代码来源:common.module.php

示例2: getEntryFormatterInfo

function getEntryFormatterInfo($id)
{
    static $info;
    $context = Model_Context::getInstance();
    $blogid = intval($context->getProperty('blog.id'));
    if (!Validator::id($id)) {
        return NULL;
    } else {
        if (!isset($info[$blogid][$id])) {
            $context = Model_Context::getInstance();
            $pool = DBModel::getInstance();
            $pool->reset('Entries');
            $pool->setQualifier('blogid', 'equals', $blogid);
            $pool->setQualifier('id', 'equals', $id);
            $info[$blogid][$id] = $pool->getCell('contentformatter');
        }
    }
    return $info[$blogid][$id];
}
开发者ID:ni5am,项目名称:Textcube,代码行数:19,代码来源:module.php

示例3: load

 function load()
 {
     global $configMappings;
     if (false == Validator::id($this->blogid)) {
         $this->usable = false;
         return false;
     }
     if (!isset($this->pluginName) || empty($this->pluginName)) {
         $this->usable = false;
         return false;
     }
     $plugin = $this->pluginName;
     if (!isset($configMappings[$plugin])) {
         $this->usable = false;
         return false;
     }
     $this->configVal = $this->__getPluginConfig();
     if (false == is_array($this->configVal)) {
         $this->usable = false;
         return false;
     }
     $this->usable = true;
     return true;
 }
开发者ID:webhacking,项目名称:Textcube,代码行数:24,代码来源:Textcube.Model.PluginCustomConfig.php

示例4: addCategory

function addCategory($blogid, $parent, $name, $id = null, $priority = null)
{
    $pool = DBModel::getInstance();
    if (empty($name)) {
        return false;
    }
    if (!is_null($parent) && !Validator::id($parent)) {
        return false;
    }
    if (!is_null($id) && !Validator::isInteger($id, 0)) {
        return false;
    }
    if ($priority !== null && !Validator::isInteger($priority, 0)) {
        return false;
    }
    if (!is_null($parent)) {
        $pool->reset('Categories');
        $pool->setQualifier('blogid', 'eq', $blogid);
        $pool->setQualifier('id', 'eq', $parent);
        $label = $pool->getCell('name');
        if ($label === null) {
            return false;
        }
        $label .= '/' . $name;
    } else {
        $parent = 'NULL';
        $label = $name;
    }
    $label = Utils_Unicode::lessenAsEncoding($label, 255);
    $name = Utils_Unicode::lessenAsEncoding($name, 127);
    $pool->reset('Categories');
    $pool->setQualifier('blogid', 'eq', $blogid);
    $pool->setQualifier('name', 'eq', $name, true);
    if ($parent == 'NULL') {
        $pool->setQualifier('parent', 'eq', NULL);
    } else {
        $pool->setQualifier('parent', 'eq', $parent);
    }
    if ($pool->getCount() > 0) {
        return false;
    }
    if (!is_null($priority)) {
        $pool->reset('Categories');
        $pool->setQualifier('blogid', 'eq', $blogid);
        $pool->setQualifier('priority', 'eq', $priority);
        if ($pool->doesExist()) {
            return false;
        } else {
            $newPriority = $priority;
        }
    } else {
        $pool->reset('Categories');
        $pool->setQualifier('blogid', 'eq', $blogid);
        $newPriority = $pool->getCell('MAX(priority)') + 1;
    }
    // Determine ID.
    if (!is_null($id)) {
        $pool->reset('Categories');
        $pool->setQualifier('blogid', 'eq', $blogid);
        $pool->setQualifier('id', 'eq', $id);
        if ($pool->doesExist()) {
            return false;
        } else {
            $newId = $id;
        }
    } else {
        $pool->reset('Categories');
        $pool->setQualifier('blogid', 'eq', $blogid);
        $newId = $pool->getCell('MAX(id)') + 1;
    }
    $pool->reset('Categories');
    $pool->setAttribute('blogid', $blogid);
    $pool->setAttribute('id', $newId);
    if ($parent == 'NULL') {
        $pool->setAttribute('parent', NULL);
    } else {
        $pool->setAttribute('parent', $parent);
    }
    $pool->setAttribute('name', $name, true);
    $pool->setAttribute('priority', $newPriority);
    $pool->setAttribute('entries', 0);
    $pool->setAttribute('entriesinlogin', 0);
    $pool->setAttribute('label', $label, true);
    $pool->setAttribute('visibility', 2);
    $result = $pool->insert();
    updateEntriesOfCategory($blogid, $newId);
    return $result ? true : false;
}
开发者ID:ragi79,项目名称:Textcube,代码行数:88,代码来源:blog.category.php

示例5: addCategory

function addCategory($blogid, $parent, $name, $id = null, $priority = null)
{
    global $database;
    if (empty($name)) {
        return false;
    }
    if (!is_null($parent) && !Validator::id($parent)) {
        return false;
    }
    if (!is_null($id) && !Validator::isInteger($id, 0)) {
        return false;
    }
    if ($priority !== null && !Validator::isInteger($priority, 0)) {
        return false;
    }
    if (!is_null($parent)) {
        $label = POD::queryCell("SELECT name FROM {$database['prefix']}Categories WHERE blogid = {$blogid} AND id = {$parent}");
        if ($label === null) {
            return false;
        }
        $label .= '/' . $name;
    } else {
        $parent = 'NULL';
        $label = $name;
    }
    $label = POD::escapeString(UTF8::lessenAsEncoding($label, 255));
    $name = POD::escapeString(UTF8::lessenAsEncoding($name, 127));
    if ($parent == 'NULL') {
        $parentStr = 'AND parent is null';
    } else {
        $parentStr = "AND parent = {$parent}";
    }
    $sql = "SELECT count(*) FROM {$database['prefix']}Categories WHERE blogid = {$blogid} AND name = '{$name}' {$parentStr}";
    if (POD::queryCell($sql) > 0) {
        return false;
    }
    if (!is_null($priority)) {
        if (POD::queryExistence("SELECT * FROM {$database['prefix']}Categories WHERE blogid = {$blogid} AND priority = {$priority}")) {
            return false;
        } else {
            $newPriority = $priority;
        }
    } else {
        $newPriority = POD::queryCell("SELECT MAX(priority) FROM {$database['prefix']}Categories WHERE blogid = {$blogid}") + 1;
    }
    // Determine ID.
    if (!is_null($id)) {
        $sql = "SELECT * FROM {$database['prefix']}Categories WHERE blogid = {$blogid} AND id = {$id}";
        if (POD::queryExistence($sql)) {
            return false;
        } else {
            $newId = $id;
        }
    } else {
        $newId = POD::queryCell("SELECT MAX(id) FROM {$database['prefix']}Categories WHERE blogid = {$blogid}") + 1;
    }
    $result = POD::query("INSERT INTO {$database['prefix']}Categories (blogid, id, parent, name, priority, entries, entriesinlogin, label, visibility) VALUES ({$blogid}, {$newId}, {$parent}, '{$name}', {$newPriority}, 0, 0, '{$label}', 2)");
    updateEntriesOfCategory($blogid, $newId);
    return $result ? true : false;
}
开发者ID:hinablue,项目名称:TextCube,代码行数:60,代码来源:blog.category.php

示例6: validateArray

 static function validateArray(&$array, &$rules)
 {
     // Workaround for non Fancy-URL user.
     $cropArray = array();
     foreach ($array as $name => $value) {
         $doesHaveRequest = strpos($name, '?');
         if ($doesHaveRequest !== false) {
             $name = substr($name, $doesHaveRequest + 1);
         }
         $cropArray[$name] = $value;
     }
     $array = $cropArray;
     foreach ($rules as $key => $rule) {
         if (!isset($rule[0])) {
             trigger_error("Validator: The type of '{$key}' is not defined", E_USER_WARNING);
             continue;
         }
         if (isset($array[$key]) && ($rule[0] == 'file' || strlen($array[$key]) > 0)) {
             $value =& $array[$key];
             if (isset($rule['min'])) {
                 $rule[1] = $rule['min'];
             }
             if (isset($rule['max'])) {
                 $rule[2] = $rule['max'];
             }
             if (isset($rule['bypass'])) {
                 $rule[3] = $rule['bypass'];
             }
             switch ($rule[0]) {
                 case 'any':
                     if (isset($rule[1]) && strlen($value) < $rule[1]) {
                         return false;
                     }
                     if (isset($rule[2]) && strlen($value) > $rule[2]) {
                         return false;
                     }
                     break;
                 case 'bit':
                     $array[$key] = Validator::getBit($value);
                     break;
                 case 'bool':
                     $array[$key] = Validator::getBool($value);
                     break;
                 case 'number':
                     if (!Validator::number($value, isset($rule[1]) ? $rule[1] : null, isset($rule[2]) ? $rule[2] : null, isset($rule[3]) ? $rule[3] : false)) {
                         return false;
                     }
                     break;
                 case 'int':
                     if (!Validator::isInteger($value, isset($rule[1]) ? $rule[1] : -2147483648.0, isset($rule[2]) ? $rule[2] : 2147483647, isset($rule[3]) ? $rule[3] : false)) {
                         return false;
                     }
                     break;
                 case 'id':
                     if (!Validator::id($value, isset($rule[1]) ? $rule[1] : 1, isset($rule[2]) ? $rule[2] : 2147483647)) {
                         return false;
                     }
                     break;
                 case 'url':
                 case 'string':
                     if (!Utils_Unicode::validate($value)) {
                         $value = Utils_Unicode::bring($value);
                         if (!Utils_Unicode::validate($value)) {
                             return false;
                         }
                     }
                     $value = $array[$key] = Utils_Unicode::correct($value);
                     if (isset($rule[1]) && Utils_Unicode::length($value) < $rule[1]) {
                         return false;
                     }
                     if (isset($rule[2]) && Utils_Unicode::length($value) > $rule[2]) {
                         return false;
                     }
                     break;
                 case 'list':
                     if (!Validator::isList($value)) {
                         return false;
                     }
                     break;
                 case 'timestamp':
                     if (!Validator::timestamp($value)) {
                         return false;
                     }
                     break;
                 case 'period':
                     if (!Validator::period($value)) {
                         return false;
                     }
                     break;
                 case 'ip':
                     if (!Validator::ip($value)) {
                         return false;
                     }
                     break;
                 case 'domain':
                     if (!Validator::domain($value)) {
                         return false;
                     }
                     break;
                 case 'email':
//.........这里部分代码省略.........
开发者ID:ni5am,项目名称:Textcube,代码行数:101,代码来源:10-CoreClasses.php

示例7: testId

 public function testId()
 {
     $this->assertFalse(Validator::id()->valid('not an id'));
     $this->assertTrue(Validator::id()->valid(1));
 }
开发者ID:joy2fun,项目名称:phpvs,代码行数:5,代码来源:ValidatorTest.php

示例8: fireEvent

<?php

/// Copyright (c) 2004-2011, Needlworks  / Tatter Network Foundation
/// All rights reserved. Licensed under the GPL.
/// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT)
require ROOT . '/library/preprocessor.php';
if (eventExists('AccessFreeSlogan')) {
    $info = fireEvent('AccessFreeSlogan', implode('/', $URLInfo['fragment']), $URLInfo);
    if (Validator::id($info)) {
        $entries = array();
        $objEntry = new Notice();
        if ($objEntry->doesExist($info)) {
            list($entries) = getEntryWithPaging($blogid, $info, true);
        } else {
            $objEntry = new Post();
            if ($objEntry->doesExist($info)) {
                list($entries, $paging) = getEntryWithPaging($blogid, $info);
            }
        }
        fireEvent('OBStart');
        require ROOT . '/interface/common/blog/begin.php';
        if (empty($entries)) {
            header('HTTP/1.1 404 Not Found');
            if (empty($skin->pageError)) {
                dress('article_rep', '<div class="TCwarning">' . _text('존재하지 않는 페이지입니다.') . '</div>', $view);
            } else {
                dress('article_rep', NULL, $view);
                dress('page_error', $skin->pageError, $view);
            }
            unset($paging);
        } else {
开发者ID:hinablue,项目名称:TextCube,代码行数:31,代码来源:freeSlogan.php


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