本文整理匯總了PHP中Tags::getTags方法的典型用法代碼示例。如果您正苦於以下問題:PHP Tags::getTags方法的具體用法?PHP Tags::getTags怎麽用?PHP Tags::getTags使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Tags
的用法示例。
在下文中一共展示了Tags::getTags方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: viewAction
public function viewAction()
{
$id = $this->_request->getParam('id');
$captchaCode = $this->_request->getParam('captcha_code');
$modelBlog = new Page();
$blog = $modelBlog->getPage($id);
if ($blog) {
$this->view->blog = $blog;
// tags
$modelTags = new Tags();
$where = array('blog_id' => $id);
$tags = $modelTags->getTags($where);
if ($tags) {
$this->view->tags = $tags;
}
// 評論
$modelComment = new Comment();
$comments = $modelComment->getComments($id);
$this->view->comments = $comments;
$dataComment = $this->_request->getPost();
// 獲取表單提交值
if ($dataComment) {
if ($dataComment['captcha'] == $captchaCode) {
// 定義過濾規則
$filters = array('name' => array('StringTrim'), 'comment' => 'StripTags');
// 定義驗證規則
$validators = array('name' => array(array('StringLength', 3, 16), 'NotEmpty', Zend_Filter_Input::MESSAGES => array(array(Zend_Validate_StringLength::INVALID => "請輸入一個合法的字符串", Zend_Validate_StringLength::TOO_SHORT => "請輸入字符長度為3-16", Zend_Validate_StringLength::TOO_LONG => "請輸入字符長度為3-16"))), 'email' => array('EmailAddress', Zend_Filter_Input::MESSAGES => array(array(Zend_Validate_EmailAddress::INVALID_FORMAT => "郵件格式不正確,請重新輸入。"))), 'comment' => array());
// 實例化過濾器並進行過濾驗證
$data = $_POST;
$filterPost = new Zend_Filter_Input($filters, $validators, $data);
if ($filterPost->hasInvalid() || $filterPost->hasMissing()) {
$messages = $filterPost->getMessages();
foreach ($messages as $message) {
foreach ($message as $value) {
echo $value . "<br />";
}
}
}
// 將經過驗證的數據寫入數據庫
$modelComment = new Comment();
$newComment = $modelComment->createComment($pid = $id, $filterPost->name, $filterPost->email, $filterPost->comment);
if ($newComment) {
$this->_redirect('/blog/view/id/' . $id);
} else {
echo "評論提交出錯!";
}
} else {
echo "驗證碼錯誤,請刷新後重新輸入。";
}
}
// 生成驗證碼
$this->captcha_session = new Zend_Session_Namespace('captcha');
//在默認構造函數裏實例化
$captcha = new Zend_Captcha_Image(array('font' => 'images/SIMYOU.TTF', 'session' => $this->captcha_session, 'fontsize' => 15, 'imgdir' => 'images/code/', 'width' => 120, 'height' => 30, 'gcFreq' => 3, 'dotNoiseLevel' => 5, 'lineNoiseLevel' => 1, 'wordlen' => 4));
$captcha->generate();
// 生成圖片
// 界麵方式
$this->view->img_dir = $captcha->getImgDir();
$this->view->captcha_id = $captcha->getId();
//圖片文件名,md5編碼
$this->view->captcha_code = $captcha->getWord();
$this->view->id = $id;
} else {
echo "該博客文章不存在!";
}
}
示例2: getForm
private function getForm($type='blog', $edit=false, $item=false) {
$source = StuffpressModel::forUser($this->_application->user->id);
$item_id = $item ? $item->getID() : 0;
$source_id = $item ? $item->getSource() : $source->getID();
$date = $item ? $item->getTimestamp() : false;
// Crappy code !! TODO
$lat = $item ? $item->getLatitude() : false;
$lon = $item ? $item->getLongitude() : false;
// get the tags if any
if ($item && $item->getTagCount()>0) {
$tags_table = new Tags();
$tags = $tags_table->getTags($source_id, $item_id);
$strings = array();
foreach($tags as $tag) {
$strings[] = $tag['tag'];
}
$tags = implode(', ', $strings);
} else {
$tags = false;
}
if ($type == SourceItem::STATUS_TYPE) {
$status = $item ? $item->getStatus() : '';
$form = $this->getFormStatus($source_id,$item_id, $status, $date, $edit, $tags, $lat, $lon);
} elseif ($type == SourceItem::BLOG_TYPE) {
$title = $item ? $item->getTitle() : '';
$text = $item ? $item->getContent() : '';
$form = $this->getFormText($source_id,$item_id, $title, $text, $date, $edit, $tags, $lat, $lon);
} elseif ($type == SourceItem::LINK_TYPE) {
$title = $item ? $item->getTitle() : '';
$link = $item ? $item->getLink() : '';
$desc = $item ? $item->getDescription() : '';
$form = $this->getFormLink($source_id, $item_id, $link, $title, $desc, $date, $edit, $tags, $lat, $lon);
} elseif ($type == SourceItem::IMAGE_TYPE) {
$title = $item ? $item->getTitle() : '';
$desc = $item ? $item->getDescription() : '';
$form = $this->getFormImage($source_id, $item_id, $title, $desc, $date, $edit, $tags, $lat, $lon);
} elseif ($type == SourceItem::AUDIO_TYPE) {
$title = $item ? $item->getTitle() : '';
$desc = $item ? $item->getDescription() : '';
$form = $this->getFormAudio($source_id, $item_id, $title, $desc, $date, $edit, $tags, $lat, $lon);
} elseif ($type == SourceItem::VIDEO_TYPE) {
$title = $item ? $item->getTitle() : '';
$desc = $item ? $item->getDescription() : '';
$embed = $item ? $item->getEmbedCode() : '';
$form = $this->getFormVideo($source_id, $item_id, $title, $desc, $embed, $date, $edit, $tags, $lat, $lon);
}
return $form;
}
示例3: updateAction
public function updateAction()
{
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$this->identity = $auth->getIdentity();
}
if (!$this->identity->id) {
$this->_redirect('/user/login');
}
$id = $this->_request->getParam('id');
$modelBlog = new Page();
$formBlog = new Form_Source();
if ($this->getRequest()->isPost()) {
if ($formBlog->isValid($_POST)) {
$blogData = $formBlog->getValues();
$blogData['uid'] = $this->identity->id;
$blogData['type'] = 'source';
$blogData['createtime'] = time();
$tags = str_replace(",", ",", $blogData['tags']);
unset($blogData['tags']);
unset($blogData['提交']);
$updateBlog = $modelBlog->updatePage($id, $blogData);
if ($updateBlog) {
$this->_redirect('source/view/id/' . $updateBlog);
}
}
} else {
$blog = $modelBlog->getPage($id);
if ($this->identity->id != $blog->uid) {
echo "你不是本博客的作者,不能對本博客進行編輯操作。";
exit;
}
$arrBlog = $blog->toArray();
// 該blog的tags
$modelTags = new Tags();
$where = array('blog_id' => $id);
$tags = $modelTags->getTags($where);
if (count($tags) > 0) {
$strTags = '';
foreach ($tags as $tag) {
$strTags .= $tag->tag . ",";
}
$strTags = rtrim($strTags, ",");
}
$arrBlog['tags'] = $strTags;
$formBlog->populate($arrBlog);
}
$this->view->formBlog = $formBlog;
// $this->_helper->cache(array('index', 'view'), array('gook'));
}
示例4: getTags
public function getTags()
{
if ($this->getTagCount() == 0) {
return false;
}
if (!$this->_tags) {
$tags = new Tags();
$this->_tags = $tags->getTags($this->getSource(), $this->getID());
}
return $this->_tags;
}
示例5: actionExportList
public function actionExportList($id)
{
$list = CActiveRecord::model('X2List')->findByPk($id);
if (isset($list)) {
if (!$this->checkPermissions($list, 'view')) {
// check permissions
throw new CHttpException(403, Yii::t('app', 'You do not have permission to modify this list.'));
}
} else {
throw new CHttpException(404, Yii::t('app', 'The requested list does not exist.'));
}
$dataProvider = CActiveRecord::model('Contacts')->searchList($id);
// get the list
$totalItemCount = $dataProvider->getTotalItemCount();
$dataProvider->pagination->itemCount = $totalItemCount;
$dataProvider->pagination->pageSize = 1000;
// process list in blocks of 1000
$allFields = CActiveRecord::model('Contacts')->getFields(true);
// get associative array of fields
$gvSettings = ProfileChild::getGridviewSettings('contacts_list' . $id);
$selectedColumns = array();
$columns = array();
if ($gvSettings === null) {
$selectedColumns = array('firstName', 'lastName', 'phone', 'email', 'leadSource', 'createDate', 'lastUpdated');
} else {
$selectedColumns = array_keys($gvSettings);
}
foreach ($selectedColumns as &$colName) {
if ($colName == 'tags') {
$columns[$colName]['label'] = Yii::t('app', 'Tags');
$columns[$colName]['type'] = 'tags';
} elseif ($colName == 'name') {
$columns[$colName]['label'] = Yii::t('contacts', 'Name');
$columns[$colName]['type'] = 'name';
} else {
if (array_key_exists($colName, $allFields)) {
$columns[$colName]['label'] = $allFields[$colName]['attributeLabel'];
if (in_array($colName, array('annualRevenue', 'quoteAmount'))) {
$columns[$colName]['type'] = 'currency';
} else {
$columns[$colName]['type'] = $allFields[$colName]['type'];
}
$columns[$colName]['linkType'] = $allFields[$colName]['linkType'];
}
}
}
unset($colName);
$fileName = 'list' . $id . '.csv';
$fp = fopen($fileName, 'w+');
// output column labels for the first line
$columnLabels = array();
foreach ($columns as $colName => &$field) {
$columnLabels[] = $field['label'];
}
unset($field);
fputcsv($fp, $columnLabels);
for ($i = 0; $i < $dataProvider->pagination->pageCount; ++$i) {
$dataProvider->pagination->currentPage = $i;
$dataSet = $dataProvider->getData(true);
foreach ($dataSet as &$model) {
$row = array();
foreach ($columns as $fieldName => &$field) {
if ($field['type'] == 'tags') {
$row[] = Tags::getTags('Contacts', $model->id, 10);
} elseif ($field['type'] == 'date') {
$row[] = date('Y-m-d H:i:s', $model->{$fieldName});
} elseif ($field['type'] == 'visibility') {
switch ($model->{$fieldName}) {
case '1':
$row[] = Yii::t('app', 'Public');
break;
case '0':
$row[] = Yii::t('app', 'Private');
break;
case '2':
$row[] = Yii::t('app', 'User\'s Groups');
break;
}
} elseif ($field['type'] == 'link') {
if (is_numeric($model->{$fieldName})) {
$className = ucfirst($field['linkType']);
if (class_exists($className)) {
$lookupModel = CActiveRecord::model($className)->findByPk($model->{$fieldName});
if (isset($lookupModel)) {
$row[] = $lookupModel->name;
}
}
} else {
$row[] = $model->{$fieldName};
}
} elseif ($field['type'] == 'currency') {
if ($model instanceof Product) {
// products have their own currency
$row[] = Yii::app()->locale->numberFormatter->formatCurrency($model->{$fieldName}, $model->currency);
} elseif (!empty($model->{$fieldName})) {
$row[] = Yii::app()->locale->numberFormatter->formatCurrency($model->{$fieldName}, Yii::app()->params['currency']);
} else {
$row[] = '';
}
} elseif ($field['type'] == 'dropdown') {
//.........這裏部分代碼省略.........