예제 #1
0
							<div class="bulk-actions align-left">
								<?php 
echo CHtml::submitButton(Yii::t('global', 'Reorder'), array('name' => 'submit', 'class' => 'button'));
?>
							</div>
							<div class="clear"></div>
						</td>
					</tr>
				</tfoot>
				<tbody>
				<?php 
if (count(BlogCats::model()->getRootCats())) {
    ?>
					
					<?php 
    foreach (BlogCats::model()->getRootCats() as $row) {
        ?>
						<tr>
							<td><?php 
        echo CHtml::textField('pos[' . $row->id . ']', $row->position, array('size' => 1));
        ?>
</td>
							<td><a href="<?php 
        echo $this->createUrl('blog/viewcategory', array('id' => $row->id));
        ?>
" title="<?php 
        echo Yii::t('adminblog', 'View Posts');
        ?>
" class='tooltip'><?php 
        echo CHtml::encode($row->title);
        ?>
예제 #2
0
 /**
  * Before save operations
  */
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->postdate = time();
         $this->authorid = Yii::app()->user->id;
     } else {
         $this->last_updated_date = time();
         $this->last_updated_author = Yii::app()->user->id;
     }
     if ($this->alias) {
         $this->alias = self::model()->getAlias($this->alias);
     } else {
         $this->alias = self::model()->getAlias($this->title);
     }
     // Check to see if it exists
     if ($this->isNewRecord) {
         $find = self::model()->find('alias=:alias', array(':alias' => $this->alias));
         if ($find) {
             $this->addError('alias', Yii::t('adminblog', 'Sorry, That alias is already in use.'));
             return;
         }
     } else {
         $find = self::model()->find('alias=:alias AND id != :id', array(':alias' => $this->alias, ':id' => $this->id));
         if ($find) {
             $this->addError('alias', Yii::t('adminblog', 'Sorry, That alias is already in use.'));
             return;
         }
     }
     if ($this->isNewRecord) {
         if (!$this->language) {
             $this->language = Yii::app()->language;
         }
     }
     // Don't post to a category that is readonly
     if ($this->catid) {
         $find = BlogCats::model()->findByPk($this->catid);
         if ($find && $find->readonly) {
             $this->addError('catid', Yii::t('blog', 'Sorry, That category is readonly.'));
             return;
         }
     }
     $this->language = is_array($this->language) && count($this->language) ? implode(',', $this->language) : $this->language;
     return parent::beforeSave();
 }
}
if (Yii::app()->user->id) {
    $options[Yii::t('blog', 'My Posts')] = array('blog/showmyposts');
}
?>


<div id="nav">
	<div class="boxnavnoborder">	
		<ul class='menunav'>
			<h4><?php 
echo Yii::t('blog', 'Categories');
?>
</h4>
		<?php 
foreach (BlogCats::model()->getCatsForMember(Yii::app()->language) as $category) {
    ?>
			<li><?php 
    echo CHtml::link($category->title, array('/blog/category/' . $category->alias, 'lang' => false));
    ?>
 - ( <?php 
    echo $category->count;
    ?>
 )</li>
		<?php 
}
?>
	
		</ul>
		
		<?php 
 /**
  * Posts & Category RSS
  */
 public function actionrss()
 {
     $criteria = new CDbCriteria();
     if (isset($_GET['id']) && ($model = BlogCats::model()->findByPk($_GET['id']))) {
         $criteria->condition = 'catid=:catid AND status=:status';
         $criteria->params = array(':catid' => $model->id, ':status' => 1);
     } else {
         $criteria->condition = 'status=:status';
         $criteria->params = array(':status' => 1);
     }
     $rows = array();
     // Load some posts
     $criteria->order = 'postdate DESC';
     $criteria->limit = 50;
     $posts = Blog::model()->with(array('author'))->findAll($criteria);
     $markdown = new MarkdownParser();
     if ($posts) {
         foreach ($posts as $r) {
             $r->content = $markdown->safeTransform($r->content);
             $rows[] = array('title' => $r->title, 'link' => Yii::app()->createAbsoluteUrl('/blog/view/' . $r->alias, array('lang' => false)), 'charset' => Yii::app()->charset, 'description' => $r->description, 'author' => $r->author ? $r->author->username : Yii::app()->name, 'generator' => Yii::app()->name, 'language' => Yii::app()->language, 'guid' => $r->id, 'content' => $r->content);
         }
     }
     $data = array('title' => isset($model) ? $model->title : Yii::t('blog', 'Blog RSS Feed'), 'link' => isset($model) ? Yii::app()->createAbsoluteUrl('/blog/category/' . $model->alias, array('lang' => false)) : Yii::app()->createAbsoluteUrl('blog', array('lang' => false)), 'charset' => Yii::app()->charset, 'description' => isset($model) ? $model->description : Yii::t('blog', 'Blog'), 'author' => Yii::app()->name, 'generator' => Yii::app()->name, 'language' => Yii::app()->language, 'ttl' => 10, 'entries' => $rows);
     Yii::app()->func->displayRss($data);
 }
 /**
  * edit post action
  */
 public function actioneditpost()
 {
     // Perms
     if (!Yii::app()->user->checkAccess('op_blog_editposts')) {
         throw new CHttpException(403, Yii::t('error', 'Sorry, You don\'t have the required permissions to enter this section'));
     }
     if (isset($_GET['id']) && ($model = Blog::model()->findByPk($_GET['id']))) {
         if (isset($_POST['Blog'])) {
             $model->attributes = $_POST['Blog'];
             if ($model->save()) {
                 Yii::app()->user->setFlash('success', Yii::t('adminblog', 'Post Updated.'));
                 $this->redirect(array('viewcategory', 'id' => $model->catid));
             }
         }
         // cat list
         $parents = array();
         $parentlist = BlogCats::model()->getRootCats();
         if (count($parentlist)) {
             foreach ($parentlist as $row) {
                 $parents[$row->id] = $row->title;
             }
         }
         // language
         $model->language = !is_array($model->language) ? explode(',', $model->language) : $model->language;
         $this->breadcrumbs[Yii::t('adminblog', 'Editing Post')] = '';
         $this->pageTitle[] = Yii::t('adminblog', 'Editing Post');
         // Render
         $this->render('post_form', array('model' => $model, 'parents' => $parents, 'label' => Yii::t('adminblog', 'Editing Post')));
     } else {
         Yii::app()->user->setFlash('error', Yii::t('adminblog', 'Post was not found.'));
         $this->redirect(array('index'));
     }
 }
 /**
  * Convert extra data to an array of key=>value pairs
  */
 protected function convertExtraToArray($string)
 {
     if (!$string) {
         return array();
     }
     $_temp = array();
     if ($string == '#show_roles#') {
         $roles = Yii::app()->authManager->getRoles();
         if (count($roles)) {
             foreach ($roles as $role) {
                 $_temp[$role->name] = $role->name;
             }
         }
     } else {
         if ($string == '#show_blogcats#') {
             // Parent list
             $parentlist = BlogCats::model()->getRootCats();
             if (count($parentlist)) {
                 foreach ($parentlist as $row) {
                     $_temp[$row->id] = $row->title;
                 }
             }
         } else {
             $exploded = explode("\n", $string);
             if (count($exploded)) {
                 foreach ($exploded as $explode) {
                     list($key, $value) = explode('=', $explode);
                     $_temp[$key] = $value;
                 }
             }
         }
     }
     return $_temp;
 }
 /**
  * Get the rows for the sitemap
  */
 protected function getRows()
 {
     $_rows = array();
     // Grab blog cats
     $blogCats = BlogCats::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language));
     if (count($blogCats)) {
         foreach ($blogCats as $blogCat) {
             $_rows[] = $this->makeData($this->getFullUrl('/blog/category/' . $blogCat->alias), time(), 'monthly', 0.1);
         }
     }
     // Grab blog rows
     $blogRows = Blog::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language));
     if (count($blogRows)) {
         foreach ($blogRows as $blogRow) {
             $_rows[] = $this->makeData($this->getFullUrl('/blog/view/' . $blogRow->alias), $blogRow->postdate, 'weekly', 1);
         }
     }
     // Grab tutorials cats
     $tutorialsCats = TutorialsCats::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language));
     if (count($tutorialsCats)) {
         foreach ($tutorialsCats as $tutorialsCat) {
             $_rows[] = $this->makeData($this->getFullUrl('/tutorials/category/' . $tutorialsCat->alias), time(), 'monthly', 0.1);
         }
     }
     // Grab tutorials rows
     $tutorialsRows = Tutorials::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language));
     if (count($tutorialsRows)) {
         foreach ($tutorialsRows as $tutorialsRow) {
             $_rows[] = $this->makeData($this->getFullUrl('/tutorials/view/' . $tutorialsRow->alias), $tutorialsRow->postdate, 'weekly', 1);
         }
     }
     // Grab extensions cats
     $extensionsCats = ExtensionsCats::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language));
     if (count($extensionsCats)) {
         foreach ($extensionsCats as $extensionsCat) {
             $_rows[] = $this->makeData($this->getFullUrl('/extensions/category/' . $extensionsCat->alias), time(), 'monthly', 0.1);
         }
     }
     // Grab extensions rows
     $extensionsRows = Extensions::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language));
     if (count($extensionsRows)) {
         foreach ($extensionsRows as $extensionsRow) {
             $_rows[] = $this->makeData($this->getFullUrl('/extensions/view/' . $extensionsRow->alias), $extensionsRow->postdate, 'weekly', 1);
         }
     }
     // Grab users rows
     $usersRows = Members::model()->findAll();
     if (count($usersRows)) {
         foreach ($usersRows as $usersRow) {
             $_rows[] = $this->makeData($this->getFullUrl('/user/' . $usersRow->id . '-' . $usersRow->seoname), $usersRow->joined, 'monthly', 1);
         }
     }
     // Grab forum topics rows
     $forumTopics = ForumTopics::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language));
     if (count($forumTopics)) {
         foreach ($forumTopics as $forumTopic) {
             $_rows[] = $this->makeData($this->getFullUrl('/forum/topic/' . $forumTopic->id . '-' . $forumTopic->alias), $forumTopic->dateposted, 'daily', 1);
         }
     }
     // Grab custom pages
     $customPages = CustomPages::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language));
     if (count($customPages)) {
         foreach ($customPages as $customPage) {
             $_rows[] = $this->makeData($this->getFullUrl('/' . $forumTopic->alias), $customPage->dateposted, 'weekly', 1);
         }
     }
     // Grab documentation pages
     $documentations = Documentation::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language));
     if (count($documentations)) {
         foreach ($documentations as $documentation) {
             $_rows[] = $this->makeData($this->getFullUrl('/documentation/guide/' . $documentation->type . '/topic/' . $documentation->mkey), $documentation->last_updated, 'weekly', 1);
         }
     }
     // Return array
     return $_rows;
 }