示例#1
0
 /**
  * Provides functionality for a user to edit their profile
  */
 public function actionEdit()
 {
     $model = Users::model()->findByPk(Yii::app()->user->id);
     if (Cii::get($_POST, 'Users', NULL) !== NULL) {
         // Load the bcrypt hashing tools if the user is running a version of PHP < 5.5.x
         if (!function_exists('password_hash')) {
             require_once YiiBase::getPathOfAlias('ext.bcrypt.bcrypt') . '.php';
         }
         $cost = Cii::getBcryptCost();
         if ($_POST['Users']['password'] != '') {
             $_POST['Users']['password'] = password_hash(Users::model()->encryptHash($_POST['Users']['email'], $_POST['Users']['password'], Yii::app()->params['encryptionKey']), PASSWORD_BCRYPT, array('cost' => $cost));
         } else {
             unset($_POST['Users']['password']);
         }
         unset($_POST['Users']['status']);
         unset($_POST['Users']['user_role']);
         $model->attributes = Cii::get($_POST, 'Users', array());
         $model->about = Cii::get(Cii::get($_POST, 'Users', array()), 'about', NULL);
         if ($model->save()) {
             Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Profile', 'Your profile has been updated!'));
             $this->redirect($this->createUrl('/profile/' . $model->id));
         } else {
             Yii::app()->user->setFlash('warning', Yii::t('ciims.controllers.Profile', 'There were errors saving your profile. Please correct them before trying to save again.'));
         }
     }
     $this->render('edit', array('model' => $model));
 }
 /**
  * Base filter, allows logged in and non-logged in users to cache the page
  */
 public function filters()
 {
     $id = Yii::app()->getRequest()->getQuery('id');
     if ($id == NULL || $id === false) {
         throw new CHttpException(400, Yii::t('ciims.controllers.Categories', 'Invalid routing'));
     }
     return CMap::mergeArray(parent::filters(), array(array('CHttpCacheFilter + index', 'cacheControl' => Cii::get(Yii::app()->user->id) == NULL ? 'public' : 'private' . ', no-cache, must-revalidate', 'etagSeed' => $id), array('COutputCache + list', 'duration' => YII_DEBUG ? 1 : 86400, 'varyByParam' => array('page'), 'varyByLanguage' => true, 'dependency' => array('class' => 'CDbCacheDependency', 'sql' => 'SELECT MAX(updated) FROM content WHERE category_id = :id', 'params' => array(':id' => $id))), array('COutputCache + rss', 'duration' => YII_DEBUG ? 1 : 86400, 'dependency' => array('class' => 'CDbCacheDependency', 'sql' => 'SELECT MAX(updated) FROM content WHERE category_id = :id', 'params' => array(':id' => $id)))));
 }
示例#3
0
 public function createPageUrl($id = 1)
 {
     $queryParam = NULL;
     if (Cii::get($this->_options['param'], 'getParam', NULL) != NULL) {
         $queryParam = '?' . Cii::get($this->_options['param'], 'getParam', NULL) . '=' . Cii::get($this->_options['param'], 'param', NULL);
     }
     return '/' . $this->_options['url'] . '/' . ($id + 1) . $queryParam;
 }
示例#4
0
 /**
  * __constructor
  * @param $config
  */
 public function __construct($config = array())
 {
     $this->_config = CMap::mergeArray($this->_core, $config);
     $this->checkServerSettings();
     if (Cii::get($_FILES, 'file') !== NULL) {
         $this->file = new CiiFile();
     }
     $this->verifyFile();
 }
 /**
  * Base filter, allows logged in and non-logged in users to cache the page
  */
 public function filters()
 {
     $id = Yii::app()->getRequest()->getQuery('id');
     if ($id != NULL) {
         $lastModified = Yii::app()->db->createCommand("SELECT UNIX_TIMESTAMP(GREATEST( (SELECT IFNULL(MAX(updated), 0) FROM categories WHERE categories.id = {$id}),(SELECT IFNULL(MAX(content.updated), 0) FROM categories LEFT JOIN content ON categories.id = content.category_id WHERE categories.id = {$id} AND vid = (SELECT MAX(vid) FROM content AS content2 WHERE content2.id = content.id)),(SELECT IFNULL(MAX(comments.updated), 0) FROM categories LEFT JOIN content ON categories.id = content.category_id LEFT JOIN comments ON content.id = comments.content_id WHERE categories.id = {$id} AND vid = (SELECT MAX(vid) FROM content AS content2 WHERE content2.id = content.id) )))")->queryScalar();
         $eTag = $this->id . Cii::get($this->action, 'id', NULL) . $id . Cii::get(Yii::app()->user->id, 0) . $lastModified;
         return array(array('CHttpCacheFilter + index', 'cacheControl' => Cii::get(Yii::app()->user->id) == NULL ? 'public' : 'private' . ', no-cache, must-revalidate', 'etagSeed' => $eTag));
     }
     return parent::filters();
 }
示例#6
0
 /**
  * [DELETE] [/content/tag/<id>]
  * Deletes a tag for a given entry
  */
 public function actionTagDelete($id = NULL, $tag = NULL)
 {
     $model = $this->getModel($id);
     if (!($this->user->id == $model->author->id || $this->user->role >= 7)) {
         throw new CHttpException(403, Yii::t('Api.content', 'You do not have permission to modify tags.'));
     }
     if ($model->removeTag(Cii::get($_POST, 'tag'))) {
         return $model->getTags();
     }
     return $this->returnError(400, NULL, $model->getErrors());
 }
示例#7
0
 function __construct(array $allowedExtensions = array(), $sizeLimit = 10485760)
 {
     $allowedExtensions = array_map("strtolower", $allowedExtensions);
     $this->allowedExtensions = $allowedExtensions;
     $this->sizeLimit = $sizeLimit;
     $this->checkServerSettings();
     $this->file = false;
     if (Cii::get($_FILES, 'file') !== NULL) {
         $this->file = new CiiFile();
     }
 }
示例#8
0
 public function actionIndex()
 {
     $event = new Events();
     $event->attributes = $_GET;
     if (!isset($_GET['content_id'])) {
         $content = Content::model()->findByAttributes(array('slug' => Cii::get($_GET, 'uri', NULL)));
         if ($content !== NULL) {
             $event->content_id = $content->id;
         }
     }
     if ($event->save()) {
         Yii::app()->end();
     }
     return $this->returnError(400, NULL, $event->getErrors());
 }
示例#9
0
 /**
  * Provides functionality for a user to edit their profile
  */
 public function actionEdit()
 {
     $model = new ProfileForm();
     $model->load(Yii::app()->user->id);
     if (Cii::get($_POST, 'ProfileForm', NULL) !== NULL) {
         $model->attributes = $_POST['ProfileForm'];
         $model->password_repeat = $_POST['ProfileForm']['password_repeat'];
         if ($model->save()) {
             Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Profile', 'Your profile has been updated!'));
             $this->redirect($this->createUrl('profile/index', array('id' => $model->id, 'username' => $model->username)));
         } else {
             Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Profile', 'There were errors saving your profile. Please correct them before trying to save again.'));
         }
     }
     $this->render('edit', array('model' => $model));
 }
示例#10
0
 /**
  * Provides functionality to make a comment
  */
 public function actionComment()
 {
     if (Yii::app()->request->isAjaxRequest && Cii::get($_POST, 'Comments')) {
         $comment = new Comments();
         $comment->attributes = array('user_id' => Yii::app()->user->id, 'content_id' => $_POST['Comments']['content_id'], 'comment' => $_POST['Comments']['comment'], 'parent_id' => Cii::get($_POST['Comments'], 'parent_id', 0), 'approved' => Cii::getConfig('autoApproveComments', 1) == null ? 1 : Cii::getConfig('autoApproveComments', 1));
         if ($comment->save()) {
             $content = Content::model()->findByPk($comment->content_id);
             // Pass the values as "now" for the comment view"
             $comment->created = $comment->updated = Yii::t('Dashboard.main', 'now');
             // Set the attributed id to make life easier...
             header("X-Attribute-Id: {$comment->id}");
             $this->renderPartial('/content/comments', array('count' => $content->comment_count, 'comment' => $comment, 'depth' => 0, 'md' => new CMarkdownParser()));
         } else {
             throw new CHttpException(400, Yii::t('Dashboard.main', 'There was an error saving your comment.'));
         }
     }
 }
示例#11
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionSave($id = NULL)
 {
     if ($id == NULL) {
         $model = new Categories();
     } else {
         $model = Categories::model()->findByPk($id);
     }
     if (Cii::get($_POST, 'Categories') !== NULL) {
         $model->attributes = Cii::get($_POST, 'Categories', array());
         $model->description = Cii::get(Cii::get($_POST, 'Categories', array()), 'description', NULL);
         if ($model->save()) {
             Yii::app()->user->setFlash('success', Yii::t('Dashboard.main', 'Category has been updated'));
             $this->redirect(Yii::app()->createUrl('/dashboard/categories'));
         }
         Yii::app()->user->setFlash('error', Yii::t('Dashboard.main', 'There was an error in your submission, please verify you data before trying again.'));
     }
     $this->render('save', array('model' => $model));
 }
 /**
  * Attempts to import settings from HybridAuth config.
  */
 private function socialSettings(&$connection)
 {
     $config = Yii::app()->getModules(false);
     if (isset($config['hybridauth'])) {
         foreach (Cii::get(Cii::get($config, 'hybridauth', array()), 'providers', array()) as $k => $v) {
             $key = 'ha_' . strtolower($k) . '_';
             foreach ($v as $j => $l) {
                 if ($j == 'keys') {
                     foreach ($l as $m => $n) {
                         $key = 'ha_' . strtolower($k) . '_' . $m;
                         $value = $n;
                         $connection->createCommand('INSERT IGNORE INTO `configuration` (`key`, value, created, updated) VALUES (:key, :value, NOW(), NOW())')->bindParam(':key', $key)->bindParam(':value', $n)->execute();
                     }
                 } else {
                     $value = $l;
                     $key = 'ha_' . strtolower($k) . '_' . $j;
                     $connection->createCommand('INSERT IGNORE INTO `configuration` (`key`, value, created, updated) VALUES (:key, :value, NOW(), NOW())')->bindParam(':key', $key)->bindParam(':value', $value)->execute();
                 }
             }
         }
     }
 }
示例#13
0
 /**
  * Forces a password to be assigned before the user can proceed to the previous page
  * @param $id - ID of the content we want to investigate
  **/
 public function actionPassword($id = NULL)
 {
     $this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array('{{app_name}}' => Cii::getConfig('name', Yii::app()->name), '{{label}}' => Yii::t('ciims.controllers.Content', 'Password Required'))));
     if ($id == NULL) {
         $this->redirect(Yii::app()->user->returnUrl);
     }
     // Set some default data
     if (Cii::get(Cii::get($_SESSION, 'password', array()), $id, NULL) == NULL) {
         $_SESSION['password'][$id] = array('tries' => 0, 'expires' => time() + 300);
     }
     // If the number of attempts is >= 3
     if (Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'tries', 0) >= 3) {
         // If the expires time has already passed, unlock the account
         if (Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'expires', 0) <= time()) {
             $_SESSION['password'][$id] = array('tries' => 0, 'expires' => time() + 300);
         } else {
             // Otherwise prevent access to it
             Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Content', 'Too many password attempts. Please try again in 5 minutes'));
             unset($_POST['password']);
             $_SESSION['password'][$id]['expires'] = time() + 300;
         }
     }
     if (Cii::get($_POST, 'password', NULL) !== NULL) {
         $content = Content::model()->findByPk($id);
         $encrypted = Cii::encrypt(Cii::get($_POST, 'password'));
         if ($encrypted == $content->attributes['password']) {
             $_SESSION['password'][$id]['password'] = $encrypted;
             $_SESSION['password'][$id]['tries'] = 0;
             $this->redirect(Yii::app()->createUrl($content->attributes['slug']));
         } else {
             Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Content', 'Incorrect password'));
             $_SESSION['password'][$id]['tries'] = $_SESSION['password'][$id]['tries'] + 1;
             $_SESSION['password'][$id]['expires'] = time() + 300;
         }
     }
     $this->layout = 'password';
     $this->render('password', array('id' => $id));
 }
示例#14
0
 /**
  * Generic function to handle all resource uploads
  * @param  string $value    The value that should be assigned to $meta->value
  * @return string
  */
 private function _handleResourceUpload($value)
 {
     if (Cii::get($this->_result, 'success', false) == true) {
         $meta = ContentMetadata::model()->findbyAttributes(array('content_id' => $this->_id, 'key' => $this->_result['filename']));
         if ($meta == NULL) {
             $meta = new ContentMetadata();
         }
         $meta->content_id = $this->_id;
         $meta->key = $this->_result['filename'];
         $meta->value = $value;
         if ($meta->save()) {
             if ($this->_promote) {
                 $this->_promote($this->_result['filename']);
             }
             $this->_result['filepath'] = $value;
             return htmlspecialchars(CJSON::encode($this->_result), ENT_NOQUOTES);
         } else {
             throw new CHttpException(400, Yii::t('ciims.misc', 'Unable to save uploaded image.'));
         }
     } else {
         throw new CHttpException(400, $this->_result['error']);
     }
 }
示例#15
0
 /**
  * Removes an image from a given post
  */
 public function actionRemoveImage()
 {
     $id = Cii::get($_POST, 'id');
     $key = Cii::get($_POST, 'key');
     // Only proceed if we have valid date
     if ($id == NULL || $key == NULL) {
         throw new CHttpException(403, Yii::t('Dashboard.main', 'Insufficient data provided. Invalid request'));
     }
     $model = ContentMetadata::model()->findByAttributes(array('content_id' => $id, 'key' => $key));
     if ($model === NULL) {
         throw new CHttpException(403, Yii::t('Dashboard.main', 'Cannot delete attribute that does not exist'));
     }
     return $model->delete();
 }
示例#16
0
 /**
  * Retrieves keywords for use in the viewfile
  */
 public function getKeywords()
 {
     $keywords = Cii::get($this->params['meta'], 'keywords', '');
     if (Cii::get($keywords, 'value', false) != false) {
         $keywords = implode(',', json_decode($keywords['value']));
     }
     return $keywords == "" ? Cii::get($this->params['data'], 'title', Cii::getConfig('name', Yii::app()->name)) : $keywords;
 }
示例#17
0
 /**
  * Enables users who have recieved an invitation to setup a new account
  * @param string $id	The activation id the of the user that we want to activate
  */
 public function actionAcceptInvite($id = NULL)
 {
     $this->layout = '//layouts/main';
     $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array('{{app_name}}' => Cii::getConfig('name', Yii::app()->name), '{{label}}' => Yii::t('ciims.controllers.Site', 'Accept Invitation'))));
     if ($id === NULL) {
         throw new CHttpException(400, Yii::t('ciims.controllers.Site', 'There was an error fulfilling your request.'));
     }
     // Make sure we have a user first
     $meta = UserMetadata::model()->findByAttributes(array('key' => 'invitationKey', 'value' => $id));
     if ($meta === NULL) {
         throw new CHttpException(400, Yii::t('ciims.controllers.Site', 'There was an error fulfilling your request.'));
     }
     $model = new InviteForm();
     $model->email = Users::model()->findByPk($meta->user_id)->email;
     if (Cii::get($_POST, 'InviteForm', NULL) !== NULL) {
         $model->attributes = Cii::get($_POST, 'InviteForm', NULL);
         $model->id = $meta->user_id;
         if ($model->acceptInvite()) {
             $meta->delete();
             return $this->render('invitesuccess');
         }
     }
     $this->render('acceptinvite', array('model' => $model));
 }
示例#18
0
<?php

if (Cii::get($meta, 'blog-image', "") != "") {
    ?>
	<p style="text-align:center;"><?php 
    echo CHtml::image(Yii::app()->baseUrl . $meta['blog-image'], NULL, array('class' => 'image'));
    ?>
</p>
<?php 
}
示例#19
0
 /**
  * Allow some override values
  * @return parent::beforeSave();
  */
 public function beforeSave()
 {
     if (($allow_api = Cii::get(Cii::getCiiConfig(), 'allow_api', true)) == false) {
         $this->attributes['enableAPI'] = $this->enableAPI = (int) $allow_api;
     }
     // Encrypt the Openstack API Key
     if ($this->attributes['openstack_apikey'] != NULL && $this->attributes['openstack_apikey'] != "") {
         $this->attributes['openstack_apikey'] = $this->openstack_apikey = Cii::encrypt($this->attributes['openstack_apikey']);
     }
     return parent::beforeSave();
 }
示例#20
0
				  	<?php 
    echo Yii::app()->user->getFlash('activation-info');
    ?>
				</div>
			<?php 
}
?>

			<?php 
if ($info) {
    ?>
				<?php 
    $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'login-form', 'focus' => 'input[type="text"]:first', 'enableAjaxValidation' => true));
    ?>
				<div class="login-form-container">
					<?php 
    echo CHtml::passwordField('password', Cii::get($_POST, 'password', NULL), array('placeholder' => Yii::t('DefaultTheme', 'Password')));
    ?>
					<?php 
    $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'success', 'label' => Yii::t('DefaultTheme', 'Submit'), 'htmlOptions' => array('id' => 'submit-comment', 'class' => 'sharebox-submit pull-right', 'style' => 'margin-top: -4px')));
    ?>
				</div>
				<?php 
    $this->endWidget();
    ?>
			<?php 
}
?>
		</div>
	</div>
</div>
示例#21
0
文件: Users.php 项目: bartuspan/CiiMS
 /**
  * Sets some default values for the user record.
  * TODO: This should have been moved to CiiModel
  * @see CActiveRecord::beforeValidate()
  **/
 public function beforeValidate()
 {
     // If the password is nulled, or unchanged
     if ($this->password == NULL || $this->password == Cii::get($this->_oldAttributes, 'password', false)) {
         if (!$this->isNewRecord) {
             $this->password = $this->_oldAttributes['password'];
         }
     } else {
         $this->password = password_hash($this->password, PASSWORD_BCRYPT, array('cost' => Cii::getBcryptCost()));
         if (!$this->isNewRecord) {
             $emailSettings = new EmailSettings();
             $emailSettings->send($this, Yii::t('ciims.models.Users', 'CiiMS Password Change Notification'), 'webroot.themes.' . Cii::getConfig('theme', 'default') . '.views.email.passwordchange', array('user' => $this));
         }
     }
     return parent::beforeValidate();
 }
示例#22
0
    }
}
?>

<div id="posts">
    <?php 
foreach ($data as $k => $v) {
    ?>
        <?php 
    $this->renderPartial('//content/_post', array('content' => $v));
    ?>
    <?php 
}
?>
</div>

<?php 
if ($itemCount != 0) {
    ?>
	<?php 
    $this->widget('ext.yiinfinite-scroll.YiinfiniteScroller', array('url' => isset($url) ? $url : 'blog', 'contentSelector' => '#posts', 'pages' => $pages, 'param' => array('getParam' => 'q', 'param' => Cii::get($_GET, 'q', '')), 'defaultCallback' => "js:function(response, data) { \n\t    \tDefaultTheme.infoScroll(response, data);\t\t    \n \t\t}"));
    ?>
	<?php 
    Yii::app()->clientScript->registerScript('unbind-infinite-scroll', "\$(document).ready(function() { DefaultTheme.loadAll(); });");
    ?>

<?php 
}
?>
<META NAME="robots" CONTENT="noindex,nofollow">
示例#23
0
		<?php 
echo $content;
?>
	</div>
	<div class="span4 sidebar hidden-phone">
		<div class="well">
			<h4><?php 
echo Yii::t('DefaultTheme', 'Search');
?>
</h4>
			<?php 
echo CHtml::beginForm($this->createUrl('/search'), 'get', array('id' => 'search'));
?>
                <div class="input-append">
                    <?php 
echo CHtml::textField('q', Cii::get($_GET, 'q', ''), array('type' => 'text', 'style' => 'width: 97%', 'placeholder' => Yii::t('DefaultTheme', 'Type to search, then press enter')));
?>
                </div>
            <?php 
echo CHtml::endForm();
?>
		</div>
		
		<!-- AddThis -->
		<div class="addthis">
			<?php 
if (Cii::getConfig('addThisPublisherID') != '') {
    ?>
				<!-- AddThis Smart Layers BEGIN -->
				<!-- Go to http://www.addthis.com/get/smart-layers to customize -->
				<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=<?php 
示例#24
0
 /**
  * Provides a generic method for populating data
  * @param  array  $data    $_POST data
  * @param  bool   $direct  If the data should be accessed directly rather than by getting it through the class name
  * @return bool
  */
 public function populate($data = array(), $direct = false)
 {
     if (!$direct) {
         $data = Cii::get($data, get_class($this));
     }
     foreach ($data as $attribute => $value) {
         $this->set($attribute, $value);
     }
     return true;
 }
示例#25
0
 /**
  * Uploads a file to an OpenStack Conainter
  * @param  Openstack\Container $container  The container want to upload to
  */
 public function uploadFile()
 {
     // Validate the container
     if ($this->getContainer() == NULL) {
         return array('error' => Yii::t('ciims.misc', 'Unable to attach OpenStack Container.'));
     }
     // Perform file validation
     $this->_file = isset($_FILES['file']) ? $_FILES['file'] : false;
     // Abort the upload if we have a bad file
     if (!$this->_file) {
         return array('error' => Yii::t('ciims.misc', 'No files were uploaded.'));
     }
     // Abord the upload if the file is empty
     if ($this->_file['size'] == 0) {
         return array('error' => Yii::t('ciims.misc', 'File is empty'));
     }
     if (($max_filesize = Cii::get($this->_overrideControl, 'max_filesize', 0)) != 0) {
         if ($this->_file['size'] > $max_filesize) {
             return array('error' => Yii::t('ciims.misc', 'File is too large'));
         }
     }
     $pathinfo = pathinfo($this->_file['name']);
     $filename = $pathinfo['filename'];
     //$filename = md5(uniqid());
     $ext = $pathinfo['extension'];
     if (!in_array(strtolower($ext), $this->allowedExtensions)) {
         $these = implode(', ', $this->allowedExtensions);
         return array('error' => Yii::t('ciims.misc', "File has an invalid extension, it should be one of {{these}}.", array('{{these}}' => $these)));
     }
     $filename = 'upload-' . md5(md5($filename) . rand(10, 99) . time());
     $data = fopen($this->_file['tmp_name'], 'r+');
     try {
         $response = $this->_container->uploadObject($filename . '.' . $ext, $data, array());
         if ($response) {
             return array('success' => true, 'filename' => $filename . '.' . $ext, 'url' => $this->_container->getCDN()->getMetadata()->getProperty('Ssl-Uri'));
         } else {
             return array('error' => Yii::t('ciims.misc', 'Could not save uploaded file. The upload was cancelled, or server error encountered'));
         }
     } catch (Exception $e) {
         return array('error' => Yii::t('ciims.misc', 'The server encountered an error during uploading. Please verify that you have saufficient space in the container and that your quota has not been reached.'));
     }
 }
示例#26
0
 /**
  * Generic handler for sacing $model data since the model is completely generic.
  * @param  CiiSettingsModel $model The model we are working with
  */
 private function submitPost(&$model)
 {
     if (Cii::get($_POST, get_class($model)) !== NULL) {
         $model->populate($_POST);
         if ($model->save()) {
             return true;
         }
     }
     return false;
 }
示例#27
0
 /**
  * Renders the sorter
  */
 public function renderSorter()
 {
     echo CHtml::openTag('div', array('class' => $this->sorterCssClass)) . "\n";
     echo CHtml::openTag('form', array('class' => 'pure-form pull-left header-form header-form-content'));
     echo CHtml::tag('span', array('class' => 'icon-search pull-right icon-legend'), NULL);
     echo CHtml::textField('Content[title]', Cii::get(Cii::get($_GET, 'Content', array()), 'title'), array('id' => 'Content_title', 'name' => 'Content[title]', 'class' => 'pull-right pure-input pure-search', 'placeholder' => Yii::t('Dashboard.views', 'Search by title')));
     echo CHtml::closeTag('form');
     if ($this->dataProvider->getItemCount() <= 0 || !$this->enableSorting || empty($this->sortableAttributes)) {
         echo CHtml::closeTag('div');
         return;
     }
     echo $this->sorterHeader === null ? Yii::t('zii', 'Sort by: ') : $this->sorterHeader;
     echo "<ul>\n";
     $sort = $this->dataProvider->getSort();
     foreach ($this->sortableAttributes as $name => $label) {
         echo "<li>";
         if (is_integer($name)) {
             echo $sort->link($label);
         } else {
             echo $sort->link($name, $label);
         }
         echo "</li>\n";
     }
     echo "</ul>";
     echo $this->sorterFooter;
     echo CHtml::closeTag('div');
 }
示例#28
0
 /**
  * toggleButtonRow provides a checkbox with toggle support via purecss.io and prism.js
  * @param  CiiSettingsModel $model       The model that we are operating on
  * @param  string           $property    The name of the property we are working with
  * @param  array            $htmlOptions An array of HTML Options
  * @param  CValidator       $validators  The Validator(s) for this property
  *                                       Since we already have it, it's worth passing through
  */
 public function toggleButtonRow($model, $property, $htmlOptions = array(), $validators = NULL)
 {
     echo CHtml::tag('label', array(), $model->getAttributeLabel($property));
     echo CHtml::openTag('div', array('class' => Cii::get($htmlOptions, 'class', 'pure-input-2-3'), 'style' => 'display: inline-block'));
     echo CHtml::openTag('label', array('class' => 'switch-light switch-candy'));
     $checked = array();
     if ($model->{$property} == 1) {
         $checked = array('checked' => 'checked');
     }
     echo CHtml::openTag('input', CMap::mergeArray(array('type' => 'checkbox', 'id' => get_class($model) . '_' . $property, 'name' => get_class($model) . '[' . $property . ']', 'class' => Cii::get($htmlOptions, 'class', NULL), 'value' => '1'), $checked));
     echo CHtml::openTag('span');
     echo CHtml::tag('span', array(), 'Off');
     echo CHtml::tag('span', array(), 'On');
     echo CHtml::closeTag('span');
     echo CHtml::tag('a', array('class' => 'slide-button'), NULL);
     echo CHtml::closeTag('label');
     echo CHtml::closeTag('div');
 }
示例#29
0
<?php

$meta = Content::model()->parseMeta($content->metadata);
?>
<div class="post">
	<?php 
if (Cii::get(Cii::get($meta, 'blog-image', array()), 'value', '') != "") {
    ?>
		<p style="text-align:center;"><?php 
    echo CHtml::image(Yii::app()->baseUrl . $meta['blog-image']['value'], NULL, array('class' => 'image'));
    ?>
</p>
	<?php 
}
?>
	<div class="post-inner">
		<div class="post-header">
			<h3><?php 
echo CHtml::link($content->title, Yii::app()->createUrl($content->slug));
?>
</h3>
			<?php 
$md = new CMarkdownParser();
echo strip_tags($md->safeTransform($content->extract), '<h1><h2><h3><h4><h5><6h><p><b><strong><i>');
?>
		</div>
		<div class="blog-meta">
			<span class="date"><?php 
echo Cii::timeAgo($content->published);
?>
</span>
示例#30
0
 /**
  * Loads the user information
  */
 public static function loadUserInfo()
 {
     if (defined('CIIMS_INSTALL')) {
         return;
     }
     if (isset(Yii::app()->user)) {
         // Load some specific CiiMS JS here
         $json = CJSON::encode(array('email' => Cii::get(Yii::app()->user, 'email'), 'token' => Cii::getUserConfig('api_key', false), 'role' => Cii::get(Yii::app()->user, 'role'), 'isAuthenticated' => isset(Yii::app()->user->id), 'debug' => YII_DEBUG, 'time' => time(), 'version' => YII_DEBUG ? Cii::getVersion() : null, 'language' => Cii::setApplicationLanguage(), 'hosted' => defined('CII_CONFIG'), 'api' => Yii::app()->getBaseUrl(true) . '/api'));
         Yii::app()->clientScript->registerScript('ciims', "\n                localStorage.setItem('ciims', '{$json}');\n            ", CClientScript::POS_HEAD);
     }
 }