Exemplo n.º 1
0
 public function beforeSave($insert)
 {
     $uploadedFile = Common::uploadFile('Fragment2Data[thumb]');
     if ($uploadedFile['message'] === 'ok') {
         $this->thumb = $uploadedFile['full_name'];
     }
     return parent::beforeSave($insert);
 }
Exemplo n.º 2
0
 public function beforeSave($insert)
 {
     $uploadedFile = Common::uploadFile('Content[thumb]');
     if ($uploadedFile != null) {
         $this->thumb = $uploadedFile['url'] . $uploadedFile['new_name'];
     }
     return parent::beforeSave($insert);
 }
Exemplo n.º 3
0
 public function beforeAction($action)
 {
     //安装的路径文件
     if ($action->id == 'stop') {
         return parent::beforeAction($action);
     }
     if (Common::checkIsInstalled() === true && $action->id !== 'complete') {
         return $this->redirect(['site/stop']);
     }
     return parent::beforeAction($action);
 }
Exemplo n.º 4
0
 public function beforeSave($insert)
 {
     $uploadedFile = Common::uploadFile('Content[thumb]');
     if ($uploadedFile != null) {
         $this->thumb = $uploadedFile['url'] . $uploadedFile['new_name'];
     }
     if ($this->views == null) {
         $this->views = 0;
     }
     if ($this->comments == null) {
         $this->comments = 0;
     }
     if ($this->summary == null || empty($this->summary)) {
         $content = strip_tags($this->content);
         $pattern = '/\\s/';
         //去除空白
         $content = preg_replace($pattern, '', $content);
         $this->summary = StringHelper::subStr($content, 250);
     }
     return parent::beforeSave($insert);
 }
Exemplo n.º 5
0
 public static function getHomeTheme()
 {
     $currentTheme = Common::getConfigValue('sys_theme_home');
     return $currentTheme;
 }
Exemplo n.º 6
0
<?php

use yii\helpers\Html;
use source\core\widgets\ActiveForm;
use source\models\Content;
use source\models\Taxonomy;
use source\libs\Common;
/* @var $this yii\web\View */
/* @var $model app\models\Content */
/* @var $form yii\widgets\ActiveForm */
$filedOptions = ['template' => "{label}{input}\n{error}", 'labelOptions' => ['class' => 'control-label']];
$taxonomies = Taxonomy::getArrayTree('post');
$options = Common::buildTreeOptions($taxonomies, $model->taxonomy_id);
?>

<div class="content-form ">



    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data'], 'fieldConfig' => ['template' => "{label}<div class=\"col-md-8\">{input}</div>\n{error}", 'labelOptions' => ['class' => 'col-md-4 control-label no-padding-left no-padding-right align-left']]]);
?>
    
<div class="row">
		<div class="col-md-9">
		    <?php 
echo $form->field($model, 'title', $filedOptions)->textInput(['maxlength' => 256, 'placeholder' => '请输入标题'])->label(false);
?>
		
		    <?php 
echo $form->field($model, 'url_alias', $filedOptions)->textInput(['maxlength' => 128, 'placeholder' => 'Url 地址']);
Exemplo n.º 7
0
<?php

use source\core\back\BackApplication;
use source\LuLu;
use source\libs\Common;
function assist($a)
{
    echo '<pre>';
    print_r($a);
    echo '</pre>';
}
// comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/vendor/yiisoft/yii2/Yii.php';
require __DIR__ . '/source/override.php';
require __DIR__ . '/data/config/bootstrap.php';
require __DIR__ . '/backend/config/bootstrap.php';
$config = yii\helpers\ArrayHelper::merge(require __DIR__ . '/data/config/main.php', require __DIR__ . '/data/config/main-local.php', require __DIR__ . '/backend/config/main.php', require __DIR__ . '/backend/config/main-local.php');
Common::checkInstall($config);
$app = new BackApplication($config);
//assist($app);die;
$app->defaultRoute = '/site/index';
$app->run();
Exemplo n.º 8
0
 public function getConfigValue($id)
 {
     return Common::getConfigValue($id);
 }
Exemplo n.º 9
0
use source\core\front\BaseFrontApplication;
use source\libs\Common;
// comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');

require (__DIR__ . '/vendor/autoload.php');
require (__DIR__ . '/vendor/yiisoft/yii2/Yii.php');

require (__DIR__ . '/source/override.php');
require (__DIR__ . '/source/config/bootstrap.php');
require (__DIR__ . '/frontend/config/bootstrap.php');


$config = yii\helpers\ArrayHelper::merge(
		require(__DIR__ . '/source/config/main.php'),
		require(__DIR__ . '/source/config/main-local.php'),
		require(__DIR__ . '/frontend/config/main.php'),
		require(__DIR__ . '/frontend/config/main-local.php')
);

$app = new BaseFrontApplication($config);
$siteStatus = Common::getConfigValue('sys_status');
if($siteStatus === '0')
{
    $app->catchAll = ['site/close', 'message' => 'test'];
}
$app->run();


Exemplo n.º 10
0
 public static function setTimezone()
 {
     $timezone = Common::getConfigValue('sys_datetime_timezone');
     date_default_timezone_set($timezone);
 }
Exemplo n.º 11
0
 private static function buildContentQuery($where = null, $options = [])
 {
     $query = Content::findPublished($where);
     if (isset($options['taxonomy'])) {
         $ids = [];
         if (is_array($options['taxonomy'])) {
             foreach ($options['taxonomy'] as $t) {
                 if (intval($t) > 0) {
                     $ids[] = intval($t);
                 }
             }
         } else {
             if (intval($options['taxonomy']) > 0) {
                 $ids = intval($options['taxonomy']);
             }
         }
         if (!empty($ids)) {
             $query->andWhere(['taxonomy_id' => $ids]);
         }
     }
     foreach (['recommend', 'headline', 'sticky'] as $att) {
         if (isset($options[$att]) && is_integer($options[$att])) {
             $query->andWhere([$att => $options[$att]]);
         }
     }
     if (isset($options['flag'])) {
         $flagValue = Common::getFlagValue($options['flag']);
         if ($flagValue > 0) {
             $query->andWhere('flag&' . $flagValue . '>0');
         }
     }
     if (isset($options['is_pic'])) {
         $query->andWhere(['!=', 'thumb', '']);
     }
     if (isset($options['content_type'])) {
         if (is_string($options['content_type'])) {
             $type = $options['content_type'];
         } else {
             $module = LuLu::$app->controller->module;
             if (!$module instanceof Application) {
                 $type = $module->id;
             }
         }
         if (!empty($type)) {
             $query->andWhere(['content_type' => $options['content_type']]);
         }
     }
     return $query;
 }
Exemplo n.º 12
0
 public static function formatTime($datetime, $format = true, $showtime = false)
 {
     // $datetime = strtotime($datetime);
     if ($format !== true) {
         if (!is_string($format)) {
             $format = 'Y-m-d H:i:s';
         }
         return date($format, $datetime);
     }
     $sys_datetime_date_format = Common::getConfigValue('sys_datetime_date_format');
     $sys_datetime_time_format = Common::getConfigValue('sys_datetime_time_format');
     $sys_datetime_pretty_format = Common::getConfigValue('sys_datetime_pretty_format');
     $format = $sys_datetime_date_format;
     if ($showtime === true || $sys_datetime_time_format !== '0') {
         $format .= ' ' . ($sys_datetime_time_format === '12' ? 'h:i:s' : 'H:i:s');
     }
     if ($sys_datetime_pretty_format === '0') {
         return date($format, $datetime);
     }
     $str = '';
     /*
      * if(is_string($date))
      * {
      * $timer = strtotime($date);
      * }
      * else{
      * $timer=$date;
      * }
      */
     $timer = $datetime;
     $diff = $_SERVER['REQUEST_TIME'] - $timer;
     $day = floor($diff / 86400);
     if ($day > 0) {
         if ($day < 7) {
             return $day . "天前";
         } else {
             return date($format, $timer);
         }
     }
     $free = $diff % 86400;
     if ($free <= 0) {
         return '刚刚';
     }
     $hour = floor($free / 3600);
     if ($hour > 0) {
         return $hour . "小时前";
     }
     $free = $free % 3600;
     if ($free <= 0) {
         return '刚刚';
     }
     $min = floor($free / 60);
     if ($min > 0) {
         return $min . "分钟前";
     }
     $free = $free % 60;
     if ($free > 0) {
         return $free . "秒前";
     }
     return '刚刚';
 }
Exemplo n.º 13
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use source\models\Menu;
use source\libs\Common;
/* @var $this yii\web\View */
/* @var $model source\models\Menu */
/* @var $form yii\widgets\ActiveForm */
$category = $model->category_id;
$takonomies = Menu::getArrayTree($category);
$options = Common::buildTreeOptionsForSelf($takonomies, $model);
$targets = ['_self' => '当前窗口', '_blank' => '新窗口'];
?>

<div class="menu-form">

    <?php 
$form = ActiveForm::begin();
?>
    <?php 
echo Html::activeHiddenInput($model, 'category_id');
?>
<div class="form-group field-menu-parent_id required">
<label class="control-label" for="menu-parent_id">父结点</label>
<select type="text" id="menu-parent_id" class="form-control" name="Menu[parent_id]">
<?php 
echo $options;
?>
</select>
Exemplo n.º 14
0
 public function init()
 {
     parent::init();
     Common::setTimezone();
 }
Exemplo n.º 15
0
<?php

use yii\helpers\Html;
use source\core\widgets\ActiveForm;
use source\models\config\BasicConfig;
use source\libs\Common;
use source\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $model app\models\config\Basic */
/* @var $form ActiveForm */
$this->title = '单面模块设置';
$this->addBreadcrumbs(['基本设置']);
$categories = Common::getTaxonomyCategories();
?>
    

                
                <?php 
$form = ActiveForm::begin();
?>
                    <?php 
echo $form->field($model, 'page_taxonomy')->dropDownList(ArrayHelper::map($categories, 'id', 'name'));
?>
                   
                    <?php 
echo $form->defaultButtons();
?>
                <?php 
ActiveForm::end();
?>
           
Exemplo n.º 16
0
 /**
  * 得到前台程序的主题路径
  */
 public static function getHomeTheme()
 {
     $theme = Common::getConfigValue('thome_heme');
     return $theme;
 }
Exemplo n.º 17
0
            <td>2.0</td>
            <td><?php 
$tmp = function_exists('gd_info') ? gd_info() : array();
@($env_items[$key]['current'] = empty($tmp['GD Version']) ? 'noext' : $tmp['GD Version']);
echo @$env_items[$key]['current'];
unset($tmp);
?>
</td>
        </tr>
        <tr>
            <td height="24">磁盘空间</td>
            <td>50M</td>
            <td>不限制</td>
            <td><?php 
if (function_exists('disk_free_space')) {
    @($env_items[$key]['current'] = Common::HumanSize(disk_free_space('../')));
} else {
    $env_items[$key]['current'] = 'unknow';
}
echo @$env_items[$key]['current'];
?>
</td>
        </tr>
    </table>

    <h4 class="install_title">目录、文件权限检查</h4>
    <table class="tb">
        <tr class="install_sub_title">
            <th width="28%">目录文件</th>
            <th width="10%">检测结果</th>
            <th width="30%">依赖</th>