本文整理汇总了PHP中Utility::getUrlTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP Utility::getUrlTitle方法的具体用法?PHP Utility::getUrlTitle怎么用?PHP Utility::getUrlTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utility
的用法示例。
在下文中一共展示了Utility::getUrlTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndexing
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndexing()
{
ini_set('max_execution_time', 0);
ob_start();
$index = new Zend_Search_Lucene(Yii::getPathOfAlias($this->_indexFilesPath), true);
$criteria = new CDbCriteria();
$criteria->compare('t.publish', 1);
$criteria->order = 'album_id DESC';
//$criteria->limit = 10;
$model = Albums::model()->findAll($criteria);
foreach ($model as $key => $item) {
if ($item->media_id != 0) {
$images = Yii::app()->request->baseUrl . '/public/album/' . $item->album_id . '/' . $item->cover->media;
} else {
$images = '';
}
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('id', CHtml::encode($item->album_id), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('media', CHtml::encode($images), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('title', CHtml::encode($item->title), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('body', CHtml::encode(Utility::hardDecode(Utility::softDecode($item->body))), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('url', CHtml::encode(Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('album/site/view', array('id' => $item->album_id, 't' => Utility::getUrlTitle($item->title)))), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('date', CHtml::encode(Utility::dateFormat($item->creation_date, true) . ' WIB'), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('creation', CHtml::encode($item->user->displayname), 'utf-8'));
$index->addDocument($doc);
}
echo 'Album Lucene index created';
$index->commit();
$this->redirect(Yii::app()->createUrl('article/search/indexing'));
ob_end_flush();
}
示例2: beforeSave
/**
* before save attributes
*/
protected function beforeSave()
{
if (parent::beforeSave()) {
$action = strtolower(Yii::app()->controller->action->id);
$location = strtolower(Yii::app()->controller->id);
if ($this->isNewRecord) {
$title = new OmmuSystemPhrase();
$title->location = $location . '_title';
$title->en_us = $this->title;
if ($title->save()) {
$this->name = $title->phrase_id;
}
$desc = new OmmuSystemPhrase();
$desc->location = $location . '_description';
$desc->en_us = $this->description;
if ($desc->save()) {
$this->desc = $desc->phrase_id;
}
$quote = new OmmuSystemPhrase();
$quote->location = $location . '_quotes';
$quote->en_us = $this->quotes;
if ($quote->save()) {
$this->quote = $quote->phrase_id;
}
} else {
$title = OmmuSystemPhrase::model()->findByPk($this->name);
$title->en_us = $this->title;
$title->save();
$desc = OmmuSystemPhrase::model()->findByPk($this->desc);
$desc->en_us = $this->description;
$desc->save();
if ($this->quote != 0) {
$quote = OmmuSystemPhrase::model()->findByPk($this->quote);
$quote->en_us = $this->quotes;
$quote->save();
} else {
$quote = new OmmuSystemPhrase();
$quote->location = $location . '_quotes';
$quote->en_us = $this->quotes;
if ($quote->save()) {
$this->quote = $quote->phrase_id;
}
}
}
//upload new photo
if (in_array($action, array('add', 'edit'))) {
$page_path = "public/page";
$this->media = CUploadedFile::getInstance($this, 'media');
if ($this->media instanceof CUploadedFile) {
$fileName = time() . '_' . Utility::getUrlTitle(Phrase::trans($this->name, 2)) . '.' . strtolower($this->media->extensionName);
if ($this->media->saveAs($page_path . '/' . $fileName)) {
//create thumb image
Yii::import('ext.phpthumb.PhpThumbFactory');
$pageImg = PhpThumbFactory::create($page_path . '/' . $fileName, array('jpegQuality' => 90, 'correctPermissions' => true));
$pageImg->resize(700);
if ($pageImg->save($page_path . '/' . $fileName)) {
$this->media_show = 1;
$this->media_type = 1;
}
if (!$this->isNewRecord && $this->old_media != '' && file_exists($page_path . '/' . $this->old_media)) {
rename($page_path . '/' . $this->old_media, 'public/page/verwijderen/' . $this->page_id . '_' . $this->old_media);
}
$this->media = $fileName;
}
}
if (!$this->isNewRecord && $this->media == '') {
$this->media = $this->old_media;
}
}
}
return true;
}
示例3: foreach
<?php
if ($model != null) {
?>
<ul>
<?php
echo '<li><a href="' . Yii::app()->controller->createUrl('index') . '" title="' . Yii::t('phrase', 'All') . '">' . Yii::t('phrase', 'All') . '</a></li>';
foreach ($model as $key => $val) {
echo '<li><a href="' . Yii::app()->controller->createUrl('index', array('cat' => $val->cat_id, 't' => Utility::getUrlTitle(Phrase::trans($val->name, 2)))) . '" title="' . Phrase::trans($val->name, 2) . '">' . Phrase::trans($val->name, 2) . '</a></li>';
}
?>
</ul>
<?php
}
示例4: array
<?php
if (Yii::app()->params['article_mod_like'] == 1) {
?>
<span class="like"><?php
echo $val->likes;
?>
</span><?php
}
?>
</div>
<?php
//end.Tools
?>
</div>
<a class="title" href="<?php
echo Yii::app()->createUrl('article/' . $controller . '/view', array('id' => $val->article_id, 't' => Utility::getUrlTitle($val->title)));
?>
" title="<?php
echo $val->title;
?>
"><?php
echo $val->title;
?>
</a><br/>
<p><?php
echo Utility::shortText(Utility::hardDecode($val->body), 300, ' ...');
?>
</p>
</div>
<?php
}
示例5: beforeSave
/**
* before save attributes
*/
protected function beforeSave()
{
if (parent::beforeSave()) {
$action = strtolower(Yii::app()->controller->action->id);
if ($this->isNewRecord) {
$location = strtolower(Yii::app()->controller->module->id . '/' . Yii::app()->controller->id);
$title = new OmmuSystemPhrase();
$title->location = $location . '_title';
$title->en_us = $this->title;
if ($title->save()) {
$this->name = $title->phrase_id;
}
} else {
$title = OmmuSystemPhrase::model()->findByPk($this->name);
$title->en_us = $this->title;
$title->save();
}
//upload proposal
if (in_array($action, array('add', 'edit'))) {
$support_path = "public/support";
$this->icons = CUploadedFile::getInstance($this, 'icons');
if ($this->icons instanceof CUploadedFile) {
$fileName = Utility::getUrlTitle($this->title) . '_' . time() . '.' . strtolower($this->icons->extensionName);
if ($this->icons->saveAs($support_path . '/' . $fileName)) {
if (!$this->isNewRecord && $this->old_icon != '' && file_exists($support_path . '/' . $this->old_icon)) {
rename($support_path . '/' . $this->old_icon, 'public/support/verwijderen/' . $this->cat_id . '_' . $this->old_icon);
}
$this->icons = $fileName;
}
}
if (!$this->isNewRecord && $this->icons == '') {
$this->icons = $this->old_icon;
}
}
}
return true;
}
示例6: beforeSave
/**
* before save attributes
*/
protected function beforeSave()
{
if (parent::beforeSave()) {
//Update album photo
$controller = strtolower(Yii::app()->controller->id);
if (!Yii::app()->request->isAjaxRequest && !$this->isNewRecord && $controller == 'o/photo') {
$album_path = "public/album/" . $this->album_id;
$this->media = CUploadedFile::getInstance($this, 'media');
if ($this->media instanceof CUploadedFile) {
$fileName = time() . '_' . $this->album_id . '_' . Utility::getUrlTitle($this->album->title) . '.' . strtolower($this->media->extensionName);
if ($this->media->saveAs($album_path . '/' . $fileName)) {
if ($this->old_media != '' && file_exists($album_path . '/' . $this->old_media)) {
rename($album_path . '/' . $this->old_media, 'public/album/verwijderen/' . $this->album_id . '_' . $this->old_media);
}
$this->media = $fileName;
}
}
if ($this->media == '') {
$this->media = $this->old_media;
}
}
}
return true;
}
示例7: array
echo Yii::app()->controller->createUrl('view', array('id' => $data->article_id, 't' => Utility::getUrlTitle($data->title)));
?>
" title="<?php
echo $data->title;
?>
">
<img src="<?php
echo Utility::getTimThumb($images, 300, 150, 1);
?>
" alt="<?php
echo $data->title;
?>
" />
</a>
<a class="title" href="<?php
echo Yii::app()->controller->createUrl('view', array('id' => $data->article_id, 't' => Utility::getUrlTitle($data->title)));
?>
" title="<?php
echo $data->title;
?>
"><?php
echo Utility::hardDecode($data->title);
?>
</a>
<div class="meta">
<i class="fa fa-calendar-check-o"></i><?php
echo Utility::dateFormat($data->published_date);
?>
<?php
if ($data->media_file != '') {
?>
示例8: actionIndexing
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndexing()
{
ini_set('max_execution_time', 0);
ob_start();
$index = new Zend_Search_Lucene(Yii::getPathOfAlias($this->_indexFilesPath), true);
$criteria = new CDbCriteria();
$now = new CDbExpression("NOW()");
$criteria->compare('t.publish', 1);
$criteria->compare('date(published_date) <', $now);
$criteria->order = 'article_id DESC';
//$criteria->limit = 10;
$model = Articles::model()->findAll($criteria);
foreach ($model as $key => $item) {
if ($item->media_id != 0) {
$images = Yii::app()->request->baseUrl . '/public/article/' . $item->article_id . '/' . $item->cover->media;
} else {
$images = '';
}
if (in_array($item->cat_id, array(2, 3, 5, 6, 7, 18))) {
$url = Yii::app()->createUrl('article/news/site/view', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
} else {
if (in_array($item->cat_id, array(9))) {
$url = Yii::app()->createUrl('article/site/view', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
} else {
if (in_array($item->cat_id, array(10, 15, 16))) {
$url = Yii::app()->createUrl('article/archive/site/view', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
} else {
if (in_array($item->cat_id, array(23, 24, 25))) {
$url = Yii::app()->createUrl('article/newspaper/site/view', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
} else {
if (in_array($item->cat_id, array(13, 14, 20, 21))) {
$url = Yii::app()->createUrl('article/regulation/site/download', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
} else {
if (in_array($item->cat_id, array(19))) {
$url = Yii::app()->createUrl('article/announcement/site/download', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
}
}
}
}
}
}
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('id', CHtml::encode($item->article_id), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Keyword('category', CHtml::encode(Phrase::trans($item->cat->name, 2)), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('media', CHtml::encode($images), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('title', CHtml::encode($item->title), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('body', CHtml::encode(Utility::hardDecode(Utility::softDecode($item->body))), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('url', CHtml::encode(Utility::getProtocol() . '://' . Yii::app()->request->serverName . $url), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('date', CHtml::encode(Utility::dateFormat($item->published_date, true) . ' WIB'), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('creation', CHtml::encode($item->user->displayname), 'utf-8'));
$index->addDocument($doc);
}
echo 'Artkel Lucene index created';
$index->commit();
$this->redirect(Yii::app()->createUrl('video/search/indexing'));
ob_end_flush();
}
示例9: actionDown
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionDown($id = null)
{
if ($id == null) {
$this->redirect(array('site/index'));
} else {
$model = $this->loadModel($id);
if ($model->delete()) {
$this->redirect(array('site/view', 'id' => $model->article_id, 't' => Utility::getUrlTitle($model->article->title)));
}
}
}
示例10: afterSave
/**
* After save attributes
*/
protected function afterSave()
{
parent::afterSave();
if ($this->isNewRecord) {
// Add album directory
$album_path = "public/album/" . $this->album_id;
if (!file_exists($album_path)) {
@mkdir($album_path, 0777, true);
// Add file in album directory (index.php)
$newFile = $album_path . '/index.php';
$FileHandle = fopen($newFile, 'w');
}
$this->media = CUploadedFile::getInstance($this, 'media');
if ($this->media instanceof CUploadedFile) {
$fileName = time() . '_' . $this->album_id . '_' . Utility::getUrlTitle($this->title) . '.' . strtolower($this->media->extensionName);
if ($this->media->saveAs($album_path . '/' . $fileName)) {
$images = new AlbumPhoto();
$images->album_id = $this->album_id;
$images->cover = '1';
$images->media = $fileName;
$images->save();
}
}
} else {
// Add Tags
if ($this->keyword != '') {
$model = OmmuTags::model()->find(array('select' => 'tag_id, body', 'condition' => 'publish = 1 AND body = :body', 'params' => array(':body' => $this->keyword)));
$tag = new AlbumTag();
$tag->album_id = $this->album_id;
if ($model != null) {
$tag->tag_id = $model->tag_id;
} else {
$data = new OmmuTags();
$data->body = $this->keyword;
if ($data->save()) {
$tag->tag_id = $data->tag_id;
}
}
$tag->save();
}
}
if (AlbumSetting::getInfo('headline') == 1) {
if ($this->headline == 1) {
self::model()->updateAll(array('headline' => 0), array('condition' => 'album_id != :id AND cat_id = :cat', 'params' => array(':id' => $this->album_id, ':cat' => $this->cat_id)));
}
}
}
示例11: foreach
<ul id="rslides" class="clearfix">
<?php
foreach ($model as $key => $val) {
$extension = pathinfo($val->media, PATHINFO_EXTENSION);
if (!in_array($extension, array('bmp', 'gif', 'jpg', 'png'))) {
$images = Yii::app()->request->baseUrl . '/public/banner/' . $val->media;
} else {
$images = Yii::app()->request->baseUrl . '/public/banner/' . $val->media;
}
?>
<li>
<?php
if ($val->url != '-') {
?>
<a href="<?php
echo Yii::app()->createUrl('banner/site/click', array('id' => $val->banner_id, 't' => Utility::getUrlTitle($val->title)));
?>
" title="<?php
echo $val->title;
?>
"><img src="<?php
echo $images;
?>
" alt="<?php
echo $val->title;
?>
" /></a>
<?php
} else {
?>
<img src="<?php
示例12: array
?>
</a></li>
</ul>
</li>
<li class="<?php
echo $this->type == true ? $currentModule == 'article/site' && (isset($_GET['category']) && $_GET['category'] == 1) ? 'responsive-ls active' : 'responsive-ls' : '';
?>
"><a href="<?php
echo Yii::app()->createUrl('article/site/index', array('category' => 1, 't' => Utility::getUrlTitle(Phrase::trans(1531, 2))));
?>
" title="<?php
echo Phrase::trans(1531, 2);
?>
"><?php
echo Phrase::trans(1531, 2);
?>
</a></li>
<li class="<?php
echo $this->type == true ? $currentModule == 'article/site' && (isset($_GET['category']) && $_GET['category'] == 2) ? 'responsive-ls active' : 'responsive-ls' : '';
?>
"><a href="<?php
echo Yii::app()->createUrl('article/site/index', array('category' => 2, 't' => Utility::getUrlTitle(Phrase::trans(1545, 2))));
?>
" title="<?php
echo Phrase::trans(1545, 2);
?>
"><?php
echo Phrase::trans(1545, 2);
?>
</a></li>
</ul>
示例13: afterSave
/**
* After save attributes
*/
protected function afterSave()
{
parent::afterSave();
$article_path = "public/article/" . $this->article_id;
if ($this->isNewRecord && in_array($this->article_type, array(1, 3))) {
// Add article directory
if (!file_exists($article_path)) {
@mkdir($article_path, 0777, true);
// Add file in article directory (index.php)
$newFile = $article_path . '/index.php';
$FileHandle = fopen($newFile, 'w');
}
}
if ($this->article_type == 1) {
if ($this->isNewRecord || !$this->isNewRecord && ArticleSetting::getInfo('media_limit') == 1) {
$this->media = CUploadedFile::getInstance($this, 'media');
if ($this->media instanceof CUploadedFile) {
$fileName = time() . '_' . $this->article_id . '_' . Utility::getUrlTitle($this->title) . '.' . strtolower($this->media->extensionName);
if ($this->media->saveAs($article_path . '/' . $fileName)) {
if ($this->isNewRecord || !$this->isNewRecord && $this->media_id == 0) {
$images = new ArticleMedia();
$images->article_id = $this->article_id;
$images->cover = 1;
$images->media = $fileName;
$images->save();
} else {
if ($this->old_media != '' && file_exists($article_path . '/' . $this->old_media)) {
rename($article_path . '/' . $this->old_media, 'public/article/verwijderen/' . $this->article_id . '_' . $this->old_media);
}
$images = ArticleMedia::model()->findByPk($this->media_id);
$images->media = $fileName;
$images->update();
}
}
}
}
} else {
if ($this->article_type == 2) {
if ($this->isNewRecord) {
$video = new ArticleMedia();
$video->article_id = $this->article_id;
$video->cover = 1;
$video->media = $this->video;
$video->save();
} else {
if ($this->media_id == 0) {
$video = new ArticleMedia();
$video->article_id = $this->article_id;
$video->cover = 1;
$video->media = $this->video;
if ($video->save()) {
$data = Articles::model()->findByPk($this->article_id);
$data->media_id = $video->media_id;
$data->update();
}
} else {
$video = ArticleMedia::model()->findByPk($this->media_id);
$video->media = $this->video;
$video->update();
}
}
}
}
$this->file = CUploadedFile::getInstance($this, 'file');
if ($this->file instanceof CUploadedFile) {
$fileName = time() . '_' . $this->article_id . '_' . Utility::getUrlTitle($this->title) . '.' . strtolower($this->file->extensionName);
if ($this->file->saveAs($article_path . '/' . $fileName)) {
if (!$this->isNewRecord && $this->media_file != '' && file_exists($article_path . '/' . $this->old_file)) {
rename($article_path . '/' . $this->old_file, 'public/article/verwijderen/' . $this->article_id . '_' . $this->old_file);
}
$article = Articles::model()->findByPk($this->article_id);
$article->media_file = $fileName;
$article->update();
}
}
// Add Keyword
if (!$this->isNewRecord) {
if ($this->keyword != '') {
$model = OmmuTags::model()->find(array('select' => 'tag_id, body', 'condition' => 'publish = 1 AND body = :body', 'params' => array(':body' => $this->keyword)));
$tag = new ArticleTag();
$tag->article_id = $this->article_id;
if ($model != null) {
$tag->tag_id = $model->tag_id;
} else {
$data = new OmmuTags();
$data->body = $this->keyword;
if ($data->save()) {
$tag->tag_id = $data->tag_id;
}
}
$tag->save();
}
}
// Reset headline
if (ArticleSetting::getInfo('headline') == 1) {
if ($this->headline == 1) {
self::model()->updateAll(array('headline' => 0), array('condition' => 'article_id != :id AND cat_id = :cat', 'params' => array(':id' => $this->article_id, ':cat' => $this->cat_id)));
//.........这里部分代码省略.........
示例14: array
<a class="photo" href="<?php
echo Yii::app()->controller->createUrl('view', array('id' => $row->album_id, 't' => Utility::getUrlTitle($row->title)));
?>
" title="<?php
echo $row->title;
?>
"><img src="<?php
echo Utility::getTimThumb($images, 200, 150, 3);
?>
" alt="<?php
echo $row->title;
?>
" /></a>
<div class="span">
<a href="<?php
echo Yii::app()->controller->createUrl('view', array('id' => $row->album_id, 't' => Utility::getUrlTitle($row->title)));
?>
" title="<?php
echo $row->title;
?>
"><?php
echo Utility::hardDecode($row->title);
?>
</a>
<div class="meta-date">
<i class="fa fa-calendar-check-o"></i><?php
echo Utility::dateFormat($row->creation_date);
?>
<i class="fa fa-bookmark-o"></i><?php
echo $row->user->displayname;
?>
示例15: actionAjaxAdd
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionAjaxAdd($id)
{
$articlePhoto = CUploadedFile::getInstanceByName('namaFile');
$article_path = "public/article/" . $id;
$fileName = time() . '_' . $id . '_' . Utility::getUrlTitle(Articles::getInfo($id, 'title')) . '.' . strtolower($articlePhoto->extensionName);
if ($articlePhoto->saveAs($article_path . '/' . $fileName)) {
$model = new ArticleMedia();
$model->article_id = $id;
$model->media = $fileName;
if ($model->save()) {
$url = Yii::app()->controller->createUrl('ajaxmanage', array('id' => $model->article_id, 'replace' => 'true'));
echo CJSON::encode(array('id' => 'media-render', 'get' => $url));
}
}
}