示例#1
0
 /**
  * Returns a slated and hashed string
  * @param string $password The password you wish to hash
  * @return string A hashed and salted tstring
  */
 public static function doHash($password)
 {
     $conf = SnapUtil::getConfig('general');
     $salt = $conf['security']['salt'];
     $hash = hash('sha256', $password . $salt);
     return $hash;
 }
示例#2
0
 /**
  * Generate an image url for css background
  * @param SnapActiveRecord $model
  * @param string $attribute
  * @param mixed $size
  * @return string
  */
 public static function activeImageUrl($model, $attribute, $size = null)
 {
     if (empty($model->{$attribute})) {
         return '';
     }
     $reqArr = array('id' => $model->id, 'field' => $attribute, 'modelName' => get_class($model));
     if (is_array($size)) {
         //It's a PHPThumb array
         $reqArr = array_merge($reqArr, $size);
     } else {
         if (is_string($size)) {
             $conf = SnapUtil::getConfig('images');
             $reqArr = array_merge($reqArr, $conf['sizes'][$size]);
         }
     }
     return Yii::app()->controller->createUrl('/site/getImage', $reqArr);
 }
示例#3
0
 public static function getConfigArray()
 {
     return SnapUtil::getConfig('content.content_types');
 }
示例#4
0
 public static function getMenus()
 {
     $cnf = SnapUtil::getConfig('general');
     $menus = array();
     foreach ($cnf['menus'] as $key => $menuName) {
         $menus[] = self::model($key);
     }
     return $menus;
 }
示例#5
0
 public function init()
 {
     $this->_contentTypesConfig = SnapUtil::getConfig('content.content_types');
     $this->_defaultTypes = SnapUtil::getConfig('content.default_field_inputs');
     parent::init();
 }
示例#6
0
<?php

$app = Yii::app();
if ($app->user->checkAccess('Update Content')) {
    $adminThemeUrl = $app->themeManager->getTheme('admin')->baseUrl;
    $baseUrl = Yii::app()->request->baseUrl;
    $cs = Yii::app()->clientScript;
    $cs->registerCoreScript('jquery', CClientScript::POS_END)->registerCoreScript('jquery.ui', CClientScript::POS_END)->registerScriptFile($adminThemeUrl . '/js/app.js', CClientScript::POS_END);
    $conf = SnapUtil::getConfig('content.ckeditor');
    $ckeditorUrl = Yii::app()->assetManager->publish(Yii::getPathOfAlias('vendor.ckeditor.ckeditor'));
    $kcfinderUrl = Yii::app()->assetManager->publish(Yii::getPathOfAlias('vendor.kcfinder'));
    $cs->registerCssFile($adminThemeUrl . '/css/admin-bar.css');
    $cs->registerScriptFile($ckeditorUrl . '/ckeditor.js', CClientScript::POS_END);
    $cs->registerScript('CKEditor Inline Init', "\n\t\tSnapCMS.editor = {};\n\t", CClientScript::POS_END);
    foreach ($conf as $setName => $options) {
        $toolbar = $options['toolbarSet'];
        $fileBrowser = array_merge(array('filebrowserBrowseUrl' => $kcfinderUrl . '/browse.php?type=files', 'filebrowserImageBrowseUrl' => $kcfinderUrl . '/browse.php?type=images', 'filebrowserFlashBrowseUrl' => $kcfinderUrl . '/browse.php?type=flash', 'filebrowserUploadUrl' => $kcfinderUrl . '/upload.php?type=files', 'filebrowserImageUploadUrl' => $kcfinderUrl . '/upload.php?type=images', 'filebrowserFlashUploadUrl' => $kcfinderUrl . '/upload.php?type=flash'), $options['config']);
        $cnfStr = '';
        foreach ($fileBrowser as $key => $val) {
            $cnfStr .= "SnapCMS.editor.{$setName}." . $key . ' = "' . $val . '";' . "\n";
        }
        $cs->registerScript('CKEditor Inline Settings ' . $setName, "\n            SnapCMS.editor.{$setName} = {};\n            SnapCMS.editor.{$setName}.toolbar = " . json_encode($toolbar) . ";\n            {$cnfStr}\n        ", CClientScript::POS_END);
    }
    $cs->registerScript('CKEditor Inline', "\n\t\t\n        \$saveButton = \$('div#admin-nav a#ckSave');\n        CKEDITOR.on( 'instanceCreated', function( event ) {\n\n            var editor = event.editor,\n            element = editor.element,\n            toolbarSet = 'default';\n\n            if(\$(element.\$).data('toolbarset'))\n                    toolbarSet = \$(element.\$).data('toolbarset');\n\n            editor.on( 'configLoaded', function() {\n                    // Remove unnecessary plugins to make the editor simpler.\n                    editor.config = SnapCMS.mergeOptions(editor.config, SnapCMS.editor[toolbarSet]);\n            });\n\n            editor.on('change', function(){\n                    \$saveButton.removeClass('snap-disabled');\n            });\n\n        });\n        \n    ", CClientScript::POS_END);
    $cs->registerScriptFile($adminThemeUrl . '/js/admin.js', CClientScript::POS_END);
    ?>

    <script type="text/javascript">
        SnapCMS = {};
        SnapCMS.baseUrl = "<?php 
    echo $baseUrl;