本文整理汇总了PHP中Validator::is_empty方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::is_empty方法的具体用法?PHP Validator::is_empty怎么用?PHP Validator::is_empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validator
的用法示例。
在下文中一共展示了Validator::is_empty方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildTagIndex
function buildTagIndex($itemId, $tags, $oldtags = null, $firstDelete = true) {
global $database, $db;
if (!isset($tags) || !is_array($tags) || !isset($itemId) || !Validator::getBool($itemId))
return false;
$tagChunk = array();
$tagInsertChunk = array();
if($firstDelete)
@array_shift($tags); // first tag is category
if (empty($tags)) return false;
foreach ($tags as $tag) {
if (!Validator::is_empty($tag)) {
$tag = trim($tag);
array_push($tagChunk, "'$tag'");
array_push($tagInsertChunk, "('$tag')");
}
}
$tagInsertStr = implode(',', $tagInsertChunk); // ('tag'),('tag')...
$tagStr = implode(',', $tagChunk); // 'tag','tag',...
$db->execute("INSERT IGNORE INTO {$database['prefix']}Tags (name) VALUES $tagInsertStr");
$tagIdList = array();
if (!$db->query("SELECT id FROM {$database['prefix']}Tags WHERE name IN ($tagStr)")) return false;
while ($taglist = $db->fetchRow()) {
array_push($tagIdList, $taglist[0]);
}
$db->free();
$relationList = array();
foreach ($tagIdList as $tagId) {
array_push($relationList, "('$itemId', '$tagId', UNIX_TIMESTAMP())");
}
$relationStr = implode(',', $relationList); // ('itemId','tagId'),('itemId','tagId')...
$db->execute("INSERT IGNORE INTO {$database['prefix']}TagRelations (item, tag, linked) VALUES $relationStr");
if (!isset($oldtags) || empty($oldtags)) return true; // finish here if oldtags empty.
$deletedTags = array_diff($oldtags, $tags);
if (count($deletedTags) > 0) {
$delTags = array();
$dTagStr = '\'' . implode('\' , \'', $deletedTags) . '\'';
if (!$db->query("SELECT id FROM {$database['prefix']}Tags WHERE name IN ($dTagStr)")) return false;
while ($dlist = $db->fetchRow()) {
array_push($delTags, $dlist[0]);
}
$db->free();
$delTagStr = implode(', ', $delTags); // 삭제된 태그의 id 리스트
$db->execute("DELETE FROM {$database['prefix']}TagRelations WHERE item='$itemId' AND type='feed' AND tag IN ($delTagStr)"); // TagRelation 삭제
}
}
示例2: write
function write($elementName, $detail, $isCDATA = false, $properties = null) {
if (!isset($elementName))
return false;
$elementPA = '';
if (is_array($properties)) {
$elementPA = ' ';
foreach($properties as $key=>$value) {
$elementPA .= $key.'="'.htmlspecialchars($value).'" ';
}
}
if (!Validator::is_empty($detail)) {
if ($isCDATA) $detail = '<![CDATA[ '.$detail.' ]]>';
$this->makeResult('<'.$elementName.$elementPA.'>'.$detail.'</'.$elementName.'>');
} else {
$this->makeResult('<'.$elementName.$elementPA.' />');
}
}
示例3: VALUES
INSERT INTO {$prefix}SkinSettings (`name`,`value`) VALUES ('feedListPage','20');
INSERT INTO {$prefix}SkinSettings (`name`,`value`) VALUES ('feedListPageOrder','created');
INSERT INTO {$prefix}SkinSettings (`name`,`value`) VALUES ('feedListPageTitleLength','40');
INSERT INTO {$prefix}SkinSettings (`name`,`value`) VALUES ('feedListRecentFeedList','4');
INSERT INTO {$prefix}SkinSettings (`name`,`value`) VALUES ('focusList','4');
INSERT INTO {$prefix}SkinSettings (`name`,`value`) VALUES ('focusTitleLength','40');
INSERT INTO {$prefix}SkinSettings (`name`,`value`) VALUES ('focusDescLength','100');
INSERT INTO {$prefix}SkinSettings (`name`,`value`) VALUES ('tagCloudOrder','random');
INSERT INTO {$prefix}SkinSettings (`name`,`value`) VALUES ('tagCloudLimit','10');
INSERT INTO {$prefix}Users (loginid, password, name, email, created, is_admin) VALUES ('{$IV['userid']}', '{$IV['userpw']}', '{$IV['username']}', '{$IV['useremail']}', UNIX_TIMESTAMP(), 'y');
";
$query = explode(';', trim($scheme));
foreach ($query as $sub) {
if (Validator::is_empty($sub)) continue;
if (!$db->execute($sub)) {
$db->execute("DROP TABLE
{$prefix}Booms,
{$prefix}Categories,
{$prefix}CategoryRelations,
{$prefix}DailyStatistics,
{$prefix}DeleteHistory,
{$prefix}Exports,
{$prefix}FeedItems,
{$prefix}Feeds,
{$prefix}Groups,
{$prefix}Medias,
{$prefix}ServiceSettings,
{$prefix}Sessions,
{$prefix}SessionsData,
示例4: if
<?php
// 페이징
$s_paging = '';
$src_paging = $skin->cutSkinTag('paging');
// paging
if(isset($paging)) {
/* $qSearch = htmlspecialchars((($searchType=='blogURL')) ? '&blogURL='.urlencode(trim($searchKeyword)) : ((($searchType=='tag')) ? '&tag='.urlencode(trim($searchKeyword)) : ((($searchType=='all')) ? '&keyword='.urlencode(trim($searchKeyword)) : '')));*/
$qSearch = '';
if(!Validator::is_empty($searchKeyword)) {
switch($searchType) {
case 'blogURL':
if($accessInfo['controller'] == 'blog') {
$qSearch = '/blog/' . $accessInfo['action'];
} else if($accessInfo['controller'] == 'search') {
$qSearch = '/search/blogURL/' . func::encode(trim($searchKeyword));
}
break;
case 'tag':
if($accessInfo['controller'] == 'search') $qSearch = '/search/tag/' . func::encode(trim($searchKeyword));
break;
case 'all':
if($accessInfo['controller'] == 'search') $qSearch = '/search/all/' . func::encode(trim($searchKeyword));
break;
case 'keyword':
if($accessInfo['controller'] == 'search') $qSearch = '/search/keyword/' . func::encode(trim($searchKeyword));
break;
示例5: date
if ($recents = FeedItem::getRecentFeedItemsByFeed($feed['id'], $skinConfig->feedListRecentFeedList)) {
$sp_feedrecent_rep = '';
foreach($recents as $recent) {
$link_url = $config->addressType == 'id' ? $service['path'].'/go/'.$recent['id'] : $service['path'].'/go/'.$recent['permalink'];
$recent['thumbnail'] = '';
if($media = Media::getMedia($recent['thumbnailId'])) {
$recent['thumbnail'] = $media['thumbnail'];
}
$src_thumbnail = $skin->cutSkinTag('cond_thumbnail', $src_feedrecent_rep);
$thumbnailFile = $event->on('Text.postThumbnail', Media::getMediaFile($recent['thumbnail']));
if(!empty($thumbnailFile)) {
$s_thumbnail = (!Validator::is_empty($thumbnailFile)) ? $skin->parseTag('feeds_recent_thumbnail', $thumbnailFile, $src_thumbnail) : '';
$s_feedrecent_rep = $skin->dressOn('cond_thumbnail', $src_thumbnail, $s_thumbnail, $src_feedrecent_rep);
$s_feedrecent_rep = $skin->parseTag('feeds_recent_thumbnail_exist', 'post_thumbnail_exist', $s_feedrecent_rep);
} else {
$s_feedrecent_rep = $skin->dressOn('cond_thumbnail', $src_thumbnail, '', $src_feedrecent_rep);
$s_feedrecent_rep = $skin->parseTag('feeds_recent_thumbnail_exist', 'post_thumbnail_nonexistence', $s_feedrecent_rep);
}
$s_feedrecent_rep = $skin->parseTag('feeds_recent_url', $recent['permalink'], $s_feedrecent_rep);
$s_feedrecent_rep = $skin->parseTag('feeds_recent_linkurl', $link_url, $s_feedrecent_rep);
$s_feedrecent_rep = $skin->parseTag('feeds_recent_title', $recent['title'], $s_feedrecent_rep);
$s_feedrecent_rep = $skin->parseTag('feeds_recent_date', date('Y-m-d H:i',$recent['written']), $s_feedrecent_rep);
$sp_feedrecent_rep .= $s_feedrecent_rep;
}
$s_feedrecent .= $skin->dressOn('feedrecent_rep', $src_feedrecent_rep, $sp_feedrecent_rep, $src_feedrecent);
示例6: _t
}
if (empty($_POST['requestURI']) && !empty($_GET['requestURI'])) {
$_POST['requestURI'] = $_GET['requestURI'];
}
$errorMsg = '';
if (isset($_POST['enci'])) {
if (Validator::is_empty($_POST['enci']))
$errorMsg = _t('아이디를 입력해주세요');
else if (Validator::is_empty($_POST['encp']))
$errorMsg = _t('비밀번호를 입력해주세요');
} else if (isset($_POST['useridin'])) { // for none-javascript environment
if (Validator::is_empty($_POST['useridin']))
$errorMsg = _t('아이디를 입력해주세요');
else if (Validator::is_empty($_POST['userpwin']))
$errorMsg = _t('비밀번호를 입력해주세요');
$_POST['enci'] = $_POST['useridin'];
$_POST['encp'] = $_POST['userpwin'];
}
if (!empty($_POST['enci']) && !empty($_POST['encp'])) {
if (!isset($_POST['saveId'])) $_POST['saveId'] = false;
if (!login($_POST['enci'], $_POST['encp'], $_POST['saveId'])) {
$errorMsg = _t('아이디 또는 비밀번호가 잘못되었습니다.');
}
}
if (isLoggedIn()) {
$targetURL = empty($_POST['requestURI']) ? "http://{$_SERVER['HTTP_HOST']}{$service['path']}/" : $_POST['requestURI'];
header("Location: {$targetURL}");
示例7: date
$sp_booms = $skin->parseTag('boom_author', UTF8::clear($item['author']), $sp_booms);
$sp_booms = $skin->parseTag('boom_date', (Validator::is_digit($item['written']) ? date('Y-m-d', $item['written']) : $item['written']), $sp_booms);
$s_booms_rep .= $sp_booms;
$sp_booms = '';
}
$s_booms = $skin->dressOn('boom_rep', $src_booms_rep, $s_booms_rep, $src_booms);
} else {
$s_booms = '';
}
$skin->dress('boom', $s_booms);
// ** 태그 클라우드
$skin->dress('tagcloud', SkinElement::getTagCloud($skinConfig->tagCloudOrder, $skinConfig->tagCloudLimit));
// ** 달력
$skin->replace('calendar', SkinElement::getCalendarView((($searchType=='archive')&&!empty($searchKeyword)) ? substr($searchKeyword, 0, 6) : null));
// ** 검색
$searchTypeSelector = '<select name="type"><option value="all">'._t('전체').'</option><option value="tag"'.(($searchType=='tag')?' selected="selected"':'').'>'._t('태그').'</option><option value="blogURL"'.(($searchType=='blogURL')?' selected="selected"':'').'>'._t('블로그주소').'</option><option value="archive"'.(($searchType=='archive')?' selected="selected"':'').'>'._t('날짜지정').'</option></select>';
$skin->replace('search_typeselect', $searchTypeSelector);
$skin->replace('search_keyword', $searchKeyword);
$src_search = $skin->cutSkinTag('search');
$s_search = '<form action="'.$servicePath.'/" enctype="application/x-www-form-urlencoded" method="get">'.$src_search.'</form>';
$skin->dress('search', $s_search);
$skin->output = $skin->parseTagWithCondition('search_keyword', Korean::doesHaveFinalConsonant(UTF8::bring($searchKeyword)), '<span class="searchKeyword">"'.$searchKeyword.'"</span>', $skin->output);
if(Validator::is_empty($searchKeyword)) $skin->dress('cond_search', '');
?>
示例8: ob_get_contents
?> break;
}
});
<?php
$shortCutCode = ob_get_contents();
ob_end_clean();
$skin->addJavascriptCode($shortCutCode);
$post = $event->on('Data.post', $post);
$src_logo = $skin->cutSkinTag('cond_logo');
$logoFile = Feed::get($post['feed'], 'logo');
$logoFile = $event->on('Text.postLogo', (!file_exists(ROOT . '/cache/feedlogo/' . $logoFile) || empty($logoFile)) ? '' : $service['path']. '/cache/feedlogo/'.$logoFile);
if(!empty($logoFile)) {
$s_logo = (!Validator::is_empty($logoFile)) ? $skin->parseTag('post_logo', $logoFile, $src_logo) : '';
$sp_post = $skin->dressOn('cond_logo', $src_logo, $s_logo, $src_post);
$sp_post = $skin->parseTag('post_logo_exist', 'post_logo_exist', $sp_post);
} else {
$sp_post = $skin->dressOn('cond_logo', $src_logo, '', $src_post);
$sp_post = $skin->parseTag('post_logo_exist', 'post_logo_nonexistence', $sp_post);
}
$sp_post = $skin->parseTag('post_id', $post['id'], $sp_post);
$link_url = $config->addressType == 'id' ? $service['path'].'/go/'.$post['id'] : $service['path'].'/go/'.htmlspecialchars($post['permalink']);
$sp_post = $skin->parseTag('post_url', $event->on('Text.postURL',$link_url), $sp_post);
$sp_post = $skin->parseTag('post_permalink', htmlspecialchars($post['permalink']), $sp_post);
$sp_post = $skin->parseTag('post_visibility', (($post['visibility'] == 'n' || $post['feedVisibility'] == 'n') ? 'hidden' : 'visible' ), $sp_post);
示例9: rebuildFilters
function rebuildFilters($category) {
global $database, $db;
if(empty($category) || !isset($category))
return false;
if(is_array($category)) {
}
else if(!preg_match("/^[0-9]+$/", $category)) {
return false;
} else {
$category = Category::getAll($category);
}
if($category) {
$db->execute('DELETE FROM '.$database['prefix'].'CategoryRelations WHERE category ="'.$category['id'].'" AND custom = "n"');
$tags = $db->queryAll('SELECT DISTINCT t2.item, t2.tag FROM '.$database['prefix'].'TagRelations t1 LEFT JOIN '.$database['prefix'].'TagRelations t2 ON (t2.tag = t1.tag AND t2.type = "feed") WHERE t1.item = "' . $category['id'] . '" AND t1.type = "category" GROUP BY t2.item');
// group_category => category
$tagList = explode(',',$category['filter']);
if(count($tagList)>0) {
$tagChunk = array();
foreach ($tagList as $tag) {
if (!Validator::is_empty($tag)) {
$tag = trim($tag);
array_push($tagChunk, "'$tag'");
}
}
$tagStr = implode(',', $tagChunk); // 'tag','tag',...
$tagIdList = array();
if ($db->query("SELECT id FROM {$database['prefix']}Tags WHERE name IN ($tagStr)")) {
while ($taglist = $db->fetchRow()) {
array_push($tagIdList, $taglist[0]);
}
}
if(count($tagIdList)>0) {
$tags2 = $db->queryAll('SELECT DISTINCT t1.item, t1.tag FROM '.$database['prefix'].'TagRelations t1 WHERE t1.tag IN (' . implode(',',$tagIdList) . ') AND t1.type = "group_category"');
if(count($tags2)>0) {
$tags = array_merge($tags,$tags2);
}
}
}
if($tags) {
$relationList = array();
foreach ($tags as $tag) {
if (!Validator::is_empty($tag['item'])) {
array_push($relationList, "('{$tag['item']}', '{$category['id']}', UNIX_TIMESTAMP(), 'n')");
}
}
$relationStr = implode(',', $relationList); // ('itemId','tagId'),('itemId','tagId')...
$db->execute("INSERT IGNORE INTO {$database['prefix']}CategoryRelations (item, category, linked, custom) VALUES $relationStr");
}
}
}
示例10: getTitle
function getTitle($item, $feedId, $feedItemId = null) {
$title = array();
$autoUpdate = array();
$title['result'] = $item['title'];
/*list($autoUpdate['feed'], $title['feed']) = Feed::gets($feedId, 'autoUpdate,title');
$autoUpdate['feed'] = Validator::getBool($autoUpdate['feed']);
if (!$autoUpdate['feed'] && !Validator::is_empty($title['feed']))
$title['result'] = $title['feed'];*/ // 피드의 제목을 피드아이템 제목에 덮어 씌우는일이 없도록..
if (isset($feedItemId) || ($feedItemId !== false)) { // update
requireComponent('Bloglounge.Data.FeedItems');
list($autoUpdate['item'], $title['item']) = FeedItem::gets($feedItemId, 'autoUpdate,title');
$autoUpdate['item'] = Validator::getBool($autoUpdate['item']);
if (!$autoUpdate['item'] && !Validator::is_empty($title['item']))
$title['result'] = $title['item'];
}
return $title['result'];
}
示例11: getFeedItemsQuery
function getFeedItemsQuery($searchType, $searchKeyword, $searchExtraValue,$viewDelete = false,$owner = 0) {
global $db, $database, $config;
$sQuery = '';
if (($searchType=='tag' || $searchType=='tag+group_category') && !Validator::is_empty($searchKeyword)) {
$tagIds = array();
$tags = explode(',',$searchKeyword);
if($tagResult = $db->queryAll('SELECT id FROM '.$database['prefix'].'Tags WHERE name IN ('.Func::implode_string(',',$tags).')')) {
foreach($tagResult as $tagItem) array_push($tagIds, $tagItem['id']);
}
if (empty($tagIds)) {
return array(null,0);
} else {
if($searchType == 'tag') {
$sQuery = ' LEFT JOIN '.$database['prefix'].'TagRelations r ON (r.item = i.id AND (r.type = "feed")) WHERE r.tag IN ('.implode(',',$tagIds).')';
} else if($searchType == 'tag+group_category') {
$sQuery = ' LEFT JOIN '.$database['prefix'].'TagRelations r ON (r.item = i.id AND (r.type = "feed" || r.type = "group_category")) WHERE r.tag IN ('.implode(',',$tagIds).')';
}
}
} else if ($searchType=='blogURL' && !Validator::is_empty($searchKeyword)){
$searchKeyword = UTF8::bring($searchKeyword);
$searchFeedId = $searchExtraValue;
if(empty($searchFeedId)) {
$searchFeedId = Feed::blogURL2Id('http://'.str_replace('http://', '', $searchKeyword));
}
if(!empty($searchFeedId)) {
$sQuery = ' WHERE i.feed = '.$searchFeedId;
} else {
$sQuery = ' WHERE 1=0 ';
}
} else if ($searchType=='user' && !Validator::is_empty($searchKeyword)){
$searchKeyword = UTF8::bring($searchKeyword);
$searchFeedId = $searchExtraValue;
if(empty($searchFeedId)) {
if(is_numeric($searchKeyword)) {
$user = User::getById($searchKeyword);
} else {
$user = User::getByloginId($searchKeyword);
}
$searchFeedId = Feed::getIdListByOwner($user['id']);
}
if(!empty($searchFeedId)) {
$sQuery = ' WHERE i.feed IN ('.implode(",",$searchFeedId).')';
} else {
$sQuery = ' WHERE 1=0 ';
}
} else if ($searchType=='author' && !Validator::is_empty($searchKeyword)){
$searchKeyword = UTF8::bring($searchKeyword);
if(!empty($searchKeyword)) {
$sQuery = ' WHERE i.author = "' . $searchKeyword . '"';
} else {
$sQuery = ' WHERE 1=0 ';
}
} else if ($searchType=='title+description' && !Validator::is_empty($searchKeyword)){
$searchKeyword = UTF8::bring($searchKeyword);
$keyword = $db->escape($searchKeyword);
$sQuery = ' WHERE i.description LIKE "%'.$keyword.'%"';
} else if ($searchType=='title' && !Validator::is_empty($searchKeyword)){
$searchKeyword = UTF8::bring($searchKeyword);
$keyword = $db->escape($searchKeyword);
$sQuery = ' WHERE i.title LIKE "%'.$keyword.'%"';
} else if ($searchType=='description' && !Validator::is_empty($searchKeyword)){
$searchKeyword = UTF8::bring($searchKeyword);
$keyword = $db->escape($searchKeyword);
$sQuery = ' WHERE i.description LIKE "%'.$keyword.'%"';
} else if ($searchType=='focus'){
$sQuery = ' WHERE i.focus = "'.$searchKeyword.'"';
} else if ($searchType=='group') {
requireComponent('Bloglounge.Data.Groups');
if(!empty($searchExtraValue)) {
$tagId = $db->pick('SELECT id FROM '.$database['prefix'].'Tags WHERE name="'.$db->escape(urldecode($searchExtraValue)).'"');
if($tagId) {
$tagId = $tagId[0];
$sQuery = ' LEFT JOIN '.$database['prefix'].'TagRelations r ON (r.item = i.id AND r.type = "group_category") ';
}
}
if(!is_numeric($searchKeyword)) {
$group = Group::getByName($searchKeyword);
$searchKeyword = $group['id'];
}
if($searchKeyword) {
$feedIds = Group::getFeedIdList($searchKeyword);
$sQuery .= ' WHERE i.feed IN (' . implode(',',$feedIds) .')';
if($tagId) {
$sQuery .= ' AND r.tag="'.$tagId.'"';
}
//.........这里部分代码省略.........
示例12: refresh
function refresh($type = 'recent', $file = true, $value = array()) {
global $database, $db, $service;
requireComponent('LZ.PHP.XMLWriter');
$rssDir = ROOT . '/cache/rss';
func::mkpath($rssDir);
if (!is_dir($rssDir) || !is_writeable($rssDir))
return false;
$config = new Settings;
$rssCount = $config->feeditemsOnRss;
$myURL = 'http://'.$_SERVER['HTTP_HOST'].$service['path'];
if($file) {
if($type == 'focus') {
$xml = new XMLFile($rssDir.'/1_focus.xml');
} else if($type == 'category') {
$xml = new XMLFile($rssDir.'/1_category_'.$value['id'].'.xml');
} else {
$xml = new XMLFile($rssDir.'/1.xml');
}
} else {
$xml = new XMLFile('stdout');
}
$xml->startGroup('rss', array('version'=>'2.0'));
switch($type) {
case 'focus':
$title = htmlspecialchars($config->title) . ' : ' . _t('포커스 목록');
break;
case 'category':
$title = htmlspecialchars($config->title) . ' : ' . _f('%1에 대한 분류 검색결과',$value['name']);
break;
default:
$title = htmlspecialchars($config->title);
break;
}
$xml->startGroup('channel');
$xml->write('title', $title);
$xml->write('link', htmlspecialchars($myURL));
$xml->write('description', htmlspecialchars($config->description));
$xml->write('language', $config->language);
$xml->write('pubDate', date("r", time()));
$xml->write('generator', BLOGLOUNGE.' '.BLOGLOUNGE_VERSION.' '.BLOGLOUNGE_NAME);
if (!Validator::is_empty($config->logo)) {
$xml->startGroup('image');
$xml->write('title', htmlspecialchars($config->title));
$xml->write('url', htmlspecialchars($myURL.'/cache/logo/'.$config->logo));
list($width, $height) = getimagesize(ROOT.'/cache/logo/'.$config->logo);
$xml->write('width', $width);
$xml->write('height', $height);
$xml->write('description', '');
$xml->endGroup();
}
if($type == 'focus') {
$result = $db->query("SELECT title, permalink, author, description, tags, written FROM {$database['prefix']}FeedItems WHERE allowRedistribute='y' AND focus='y' AND visibility = 'y' ORDER BY written DESC LIMIT 0,{$rssCount}");
} else if($type == 'category') {
$result = $db->query("SELECT i.title, i.permalink, i.author, i.description, i.tags, i.written FROM {$database['prefix']}FeedItems i LEFT JOIN {$database['prefix']}CategoryRelations c ON (c.item = i.id) WHERE i.allowRedistribute='y' AND i.visibility = 'y' AND c.category = {$value['id']} ORDER BY i.written DESC LIMIT 0,{$rssCount}");
} else {
$result = $db->query("SELECT title, permalink, author, description, tags, written FROM {$database['prefix']}FeedItems WHERE allowRedistribute='y' AND visibility = 'y' ORDER BY written DESC LIMIT 0,{$rssCount}");
}
if ($result) {
while ($item = $db->fetch()) {
$xml->startGroup('item');
$item->description = str_replace('/cache/images',$myURL.'/cache/images',$item->description);
$xml->write('title', htmlspecialcharS($item->title));
$xml->write('link', htmlspecialchars($item->permalink));
$xml->write('description', htmlspecialchars($item->description));
foreach (explode(',', $item->tags) as $tag) {
$xml->write('category', htmlspecialchars($tag));
}
$xml->write('author', htmlspecialchars($item->author));
$xml->write('guid', htmlspecialchars($item->permalink));
$xml->write('pubDate', date("r", $item->written));
$xml->endGroup();
}
}
$xml->endAllGroups();
$xml->close();
return true;
}
示例13: validateValue
/**
* Validates one single value ($value) against a set of rules ($rules)
*/
public function validateValue(&$value, array $rules, array $opt = array())
{
$opt = array_merge($this->options, $opt);
$errors = array();
// check if value is required.
// if the value is NOT required and NOT present, we do no run any other validator
if (Validator::is_empty($value)) {
$required = false;
if (isset($rules['required'])) {
$required = $rules['required'];
if (is_callable($required)) {
$required = call_user_func_array($required, array($this));
}
}
// cast to an array if necessary
if (isset($rules[self::EACH])) {
$value = array();
}
if ($required) {
$errors['required'] = true;
if ($opt['stop_on_error']) {
return $errors;
}
} elseif ($opt['allow_empty']) {
return true;
}
// else we pass the value through the validators, even if it's empty
}
unset($rules['required']);
foreach ($rules as $validator => $param) {
$ret = true;
// special iterative validator for arrays
if ($validator === self::EACH) {
$ret = $this->validateMultipleValues($value, $param, $errors, $opt);
} else {
// validator function (in Validator class)
if (method_exists('Validator', $validator)) {
if (is_callable($param)) {
$param = call_user_func_array($param, array($this));
}
$ret = call_user_func_array(array('Validator', $validator), array(&$value, $param));
} elseif (is_callable($param)) {
$ret = call_user_func_array($param, array(&$value, $this));
$param = true;
// I don't want to set a callback into the errors array
} else {
throw new \InvalidArgumentException("Validator {$validator} not found");
}
}
// if the validator failed, we store the name of the validator in the $errors array
// XXX shoudln't it be if $ret !== true ?
if ($ret === false) {
$errors[$validator] = $param;
if ($opt['stop_on_error']) {
return $errors;
}
}
}
return empty($errors) ? true : $errors;
}