本文整理汇总了PHP中Channel::setUrlname方法的典型用法代码示例。如果您正苦于以下问题:PHP Channel::setUrlname方法的具体用法?PHP Channel::setUrlname怎么用?PHP Channel::setUrlname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Channel
的用法示例。
在下文中一共展示了Channel::setUrlname方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getJsonTags
function getJsonTags(){
if ( (empty($this->idchannel) || $this->idchannel<=0) ) {
if (isset($_GET['channel']) && !empty($_GET['channel'])) {
require_once("class/Channel.php");
$tmp = new Channel(); $tmp->setUrlname($_GET['channel']);
$this->idchannel=$tmp->getId();
if (empty($this->idchannel)) $this->idchannel=-1;
}
}
if ($this->listType=='cloneUFLast')
$query = Topic::cloneUFLast($this->qtd, $this->lastorderid, $this->idchannel);
elseif ($this->listType=='cloneFollowed')
$query = Topic::cloneFollowed($this->qtd, $this->lastorderid, $this->idchannel);
elseif ($this->listType=='cloneSearch')
$query = Topic::cloneSearch($this->search, $this->qtd, $this->orderid);
elseif ($this->listType=='cloneUpdated')
$query = Topic::cloneUpdated($this->ids, $this->counters, $this->qtd, $this->orderid, $this->idchannel);
elseif ($this->listType=='cloneNew')
$query = Topic::cloneNew($this->lastid, $this->qtd, $this->orderid, $this->idchannel);
elseif ($this->listType=='cloneByUser')
$query = Topic::cloneByUser($this->user, $this->qtd, $this->orderid, $this->sorting, $this->idchannel);
elseif ($this->listType=='cloneByUserPost')
$query = Topic::cloneByUserPost($this->user, $this->qtd, $this->orderid, $this->sorting, $this->idchannel);
elseif ($this->listType=='cloneByDate')
$query = Topic::cloneByDate($this->user, $this->year, $this->month, $this->day);
elseif ($this->listType=='cloneChannelFollowed')
$query = Topic::cloneChannelFollowed($this->qtd, $this->orderid, $this->lastorderid, $this->sorting);
else
$query = Topic::cloneLast($this->qtd, $this->orderid, $this->sorting, $this->idchannel);
$result = array();
if ($query!=null){
global $CONF;
if ($this->with_posts){
require_once('template/TListPost.php');
foreach ($query as $topic){
$tlistpost = new TListPost(); $tlistpost->setTopic($topic);
$ttopic = new TTopic(); $ttopic->setTopic($topic);
array_push($result, array('topic'=>$ttopic->getJsonTags(), "posts"=>$tlistpost->getJsonTags()) );
}
} else {
foreach ($query as $topic){
$tmp=$topic->getJsonTags();
if ($this->onlysubsumed)
unset($tmp['msg']);
array_push($result, $tmp);
}
}
}
return $result;
}
示例2: save
public function save(){ //Salva o objeto no BD (se ja foi salvo faz update)
$this->_new=false;
$db = clone $GLOBALS['maindb'];
if (empty($this->subject))
return 'error null subject';
if (empty($this->msg))
return 'error null message';
$isanon=$this->getUser()->isAnon();
if (!($isanon))
$isanon = 'FALSE';
else
$isanon = 'TRUE';
if (!isset($this->id) || ($this->id==null)){ //Insert
$db->query("SELECT nextval('topic_id_seq') as id;");
$_gotid_req = $db->fetch();
$_gotid = $_gotid_req['id'];
$lang = $this->getLang();
if (empty($lang)){
$this->lang = $this->getUser()->getLang();
}
if (!empty($this->channel))
$_channelid=$this->channel->getId();
elseif (isset($_GET['channel'])){
require_once('class/Channel.php');
$tmpchannel=new Channel();
$tmpchannel->setUrlname($_GET['channel']);
$tmpchannel->load();
$_channelid = $tmpchannel->getId();
} else
$_channelid = 'null';
if (empty($_channelid)) $_channelid = 'null';
$db->query("INSERT INTO topic(id,subject,msg,anon,userid,lang, channelid) VALUES('{$_gotid}','{$this->getSubject()}','{$this->getMsg()}','$isanon', '{$this->getUser()->getId()}', '{$this->getLang()}', {$_channelid});");
$row = $db->fetch();
$this->id = $_gotid;
} else { //Update
$_alsoupdate='';
if ($this->_update_subject==true) $_alsoupdate.=",subject='{$this->getSubject()}'";
$db->query("UPDATE topic set msg='{$this->getMsg()}',anon='$isanon', userid='{$this->getUser()->getId()}' {$_alsoupdate} WHERE id='{$this->id}';");
$row = $db->fetch();
}
$this->_flush=true;
return "ok";
}
示例3: add_channel
function add_channel()
{
global $CONF;
global $LANGALL;
$user = $_SESSION['user'];
if ($user->getBanned()>0){
return array('ok'=>false, 'error'=>'banned '.$user->getBanned());
}
if (isset($_SESSION['channel_last_flood_time'])){
if ((time() - $_SESSION['channel_last_flood_time']) < $CONF['channel_time_to_wait_flood']){
$time_to_wait = $CONF['channel_time_to_wait_flood'] - (time() - $_SESSION['channel_last_flood_time']);
//return array('ok'=>false, 'error'=>'flood '.$time_to_wait);
}
}
$_SESSION['channel_last_flood_time']=time();
$user = $_SESSION['user'];
if ($user->isAnon())
return array('ok'=>false, 'error'=>'anonymous cannot create channel');
$channel = new Channel();
$channel->setUser($user);
$name = strip_tags($_POST['name']);
if (strlen(str_replace(' ', '', $name)) < $CONF['channel_min_name'])
return array('ok'=>false, 'error'=>'too short name');
$channel->setName($name);
$description = $_POST['description'];
$description = strip_tags($description, $CONF['permitted_tags_msg']);
$description = text_linkify($description);
$description = str_replace(' ',' ',$description);
$channel->setDescription($description);
if (isset($_POST['lang']) && !empty($_POST['lang']))
$channel->setLang($_POST['lang']);
if (!isset($_POST['urlname']))
$channel->setUrlname( Channel::prettyUrlAvailable($_POST['name']) );
else {
if ($_POST['urlname']!=Channel::prettyUrlAvailable($_POST['urlname']))
return array('ok'=>false, 'error'=>'invalid urlname');
else
$channel->setUrlname($_POST['urlname']);
}
if (isset($_POST['asktofollow'])) $channel->setAsktofollow($_POST['asktofollow']);
if (isset($_POST['perm_member'])) $channel->setPermMember($_POST['perm_member']);
if (isset($_POST['perm_reguser'])) $channel->setPermReguser($_POST['perm_reguser']);
if (isset($_POST['perm_anon'])) $channel->setPermAnon($_POST['perm_anon']);
$result=$channel->save();
if ($result=='ok'){
$channel->follow();
/*if ($channel->getLang()=='pt_br'){
$title=$LANGALL['pt_br']['addchannel_welcome_title'];
$message=$LANGALL['pt_br']['addchannel_welcome_message'];
} else {
$title=$LANGALL['en_us']['addchannel_welcome_title'];
$message=$LANGALL['en_us']['addchannel_welcome_message'];
}
require_once('class/Topic.php');
require_once('class/User.php');
$user=new RegUser();
$user->setId(1);
$topic=new Topic();
$topic->setSubject($title);
$topic->setMsg($message);
$topic->setChannel($channel);
$topic->setUser($user);
$topic->save();*/
return array('ok'=>true, 'error'=>'', 'id'=>$channel->getId());
}
elseif ($result=='error channel already exists'){
return array('ok'=>false, 'error'=>'error channel already exists','id'=>null);
} elseif ($result=='error you created many channels'){
return array('ok'=>false, 'error'=>'error you created many channels','id'=>null);
} elseif ($result=='error user anon'){
return array('ok'=>false, 'error'=>'error user anon','id'=>null);
} else
return array('ok'=>false, 'error'=>'problems with this channel - '.$result,'id'=>null);
}
示例4: Channel
<?php
require_once('conf/location.php');
require_once('conf/session.php');
require_once("class/User.php");
require_once("class/Channel.php");
//require_once("class/Addthis.php");
global $CONF;
$user=$_SESSION['user'];
if (isset($_GET['urlname']))
{
$channel = new Channel();
$channel->setUrlname($_GET['urlname']);
$channel->load();
if ($channel->getId()>0)
{
$OG['request'] = 'openchannel';
$OG['channel_name'] = $channel->getName();
$OG['channel_desc'] = $channel->getDescription();
$OG['channel_logo'] = $CONF['url_path'] . $channel->getLogoFile('big');
if (isset($_GET['sms_ss'])){
$db = clone $GLOBALS['maindb'];
$_anon=($user->isAnon())?'true':'false';
$db->query("INSERT INTO addthis(channelid,sms_ss,at_xt,userid,anon,ip) values ('{$channel->getId()}','".$_GET['sms_ss']."','".$_GET['at_xt']."','{$user->getId()}','{$_anon}','".$_SERVER['REMOTE_ADDR']."');");
}
示例5: engine_doit
//.........这里部分代码省略.........
$message->setId($_GET['id_message']);
else { $result['message']=array(); break; }
$tmessage = new TMessage(); $tmessage->setMessage($message);
$result['message']=$tmessage->getJsonTags();
break;
case 'mymessages':
require_once('template/TListMessage.php');
$tlist = new TListMessage(); $tlist->setListType("cloneMy"); $tlist->setOnlySubsumed(true);
if (isset($_GET['sorting_mymessages'])) $tlist->setSorting($_GET['sorting_mymessages']);
if (isset($_GET['lastid_mymessages'])) $tlist->setLastId($_GET['lastid_mymessages']);
$result['mymessages']=$tlist->getJsonTags();
break;
case 'regchannel':
require_once("template/TChannel.php");
require_once("class/Channel.php");
$t = new TChannel();
$o=new Channel();
$prettyUrl='';
if (isset($_GET['id_regchannel'])) {
$o->setId($_GET['id_regchannel']);
} elseif (isset($_GET['name_regchannel'])) {
if (substr($_GET['name_regchannel'],-1,1)=='-'){
$result['regchannel']=array("ok"=>false,"error"=>"invalid name","exist"=>true,'prettyUrl'=>'');
break;
} else {
$o->setName($_GET['name_regchannel']);
$prettyUrl=Channel::prettyUrlAvailable($_GET['name_regchannel']);
}
} elseif (isset($_GET['urlname_regchannel'])) {
if ($_GET['urlname_regchannel'] != Channel::prettyUrl($_GET['urlname_regchannel'])){
$result['regchannel']=array("ok"=>false,"error"=>"invalid url","exist"=>true, 'prettyUrl'=>'');
break;
}
$o->setUrlname($_GET['urlname_regchannel']);
$prettyUrl=$_GET['urlname_regchannel'];
} else {
$result['regchannel']=array("ok"=>false,"error"=>"no param", "exist"=>true, 'prettyUrl'=>'');
break;
}
$t->setChannel($o);
$r=$t->getJsonTags();
if ($r['id']==null || $r['name']==null || $r['lang']==null)
$result['regchannel']=array("ok"=>true,"error"=>"","exist"=>false,'prettyUrl'=>$prettyUrl);
else
$result['regchannel']=array("ok"=>true,"error"=>"","exist"=>true,'prettyUrl'=>$r['urlname']);
break;
case 'channels':
require_once('template/TListChannel.php');
$tlist = new TListChannel(); $tlist->setListType("cloneAll"); $tlist->setOnlySubsumed(true);
if (isset($_GET['sorting_channels'])) $tlist->setSorting($_GET['sorting_channels']);
$result['channels']=$tlist->getJsonTags();
break;
case 'followedchannels':
require_once('template/TListChannel.php');
$tlist = new TListChannel();
if ($_SESSION['user']->isAnon())
$tlist->setListType("cloneAll");
else
$tlist->setListType("cloneFollowed");
$tlist->setOnlySubsumed(true);
if (isset($_GET['sorting_followedchannels'])) $tlist->setSorting($_GET['sorting_followedchannels']);
$result['followedchannels']=$tlist->getJsonTags();
break;
case 'mychannels':
require_once('template/TListChannel.php');
$tlist = new TListChannel(); $tlist->setListType("cloneMy"); $tlist->setOnlySubsumed(false);
示例6: prettyUrlAvailable
static function prettyUrlAvailable($name)
{
require_once('tool/utility.php');
$url = normalize_chars($name);
$url = strtolower($url);
$url = preg_replace('/[^a-zA-Z0-9]/','-',$url);
$url = preg_replace('/-+/','-',$url);
$ok=false;
$url_prefix=$url;
$cnt=1;
while ($ok==false){
$tmpc = new Channel();
$tmpc->setUrlname($url); $tmpc->load();
$_id=$tmpc->getId();
$_lang=$tmpc->getLang();
if (empty($_id) && empty($_lang))
$ok=true;
else
$url=$url_prefix."_".($cnt);
$cnt++;
}
return $url;
}