public static function resolveSource2Array($model, $items, $isBackForm) { $source = ''; if ($isBackForm) { $source = $model['back_form_source']; } else { $source = $model['front_form_source']; } $ret = TStringHelper::parse2Array($source); return array_merge($ret, $items); }
public static function getPageLink($row, $length = 0, $options = []) { if (isset($options['title'])) { $title = $options['title']; unset($options['title']); } else { $title = $row['title']; } if (is_integer($length) && $length > 0) { $title = TStringHelper::subStr($title, $length); } $url = self::getPageUrl($row); return Html::a($title, $url, $options); }
private static function getActions($table, $type = 'back') { $ret = []; if (!empty($table[$type . '_action_custom'])) { $tableName = $table['table_name']; $customActions = TStringHelper::parse2Array($table[$type . '_action_custom']); if (!empty($customActions)) { foreach ($customActions as $id => $action) { $ret[$id] = $type . 'end\\actions\\content\\' . $tableName . '\\' . $action; } } } return $ret; }
public function saveContent($model) { $model->removeSpecialAtt(); $model->user_id = 1; $model->user_name = 'admin'; $model->publish_time = TTimeHelper::getCurrentTime(); $model->modify_time = TTimeHelper::getCurrentTime(); $model->title_format = CommonUtility::getTitleFormatValue($model->title_format); $model->flag = CommonUtility::getFlagValue($model->flag); $uploadedFile = CommonUtility::uploadFile('Content[title_pic]'); if ($uploadedFile != null) { $model->title_pic = $uploadedFile['url'] . $uploadedFile['new_name']; } if ($model->title_pic == null || empty($model->title_pic)) { $model->is_pic = 0; } else { $model->is_pic = 1; } if ($model->views == null) { $model->views = 0; } if ($model->commonts == null) { $model->commonts = 0; } if ($model->summary == null || empty($model->summary)) { $content = strip_tags($model->content); $pattern = '/\\s/'; //去除空白 $content = preg_replace($pattern, '', $content); $model->summary = TStringHelper::subStr($content, 250); } $command = LuLu::createCommand(); if ($model->isNewRecord) { $command->insert($this->currentTableName, $model); } else { $command->update($this->currentTableName, $model, ['id' => $model['id']]); } $command->execute(); }
public function beforeValidate() { if (parent::beforeValidate()) { $this->title_format = CommonUtility::getTitleFormatValue($this->title_format); $uploadedFile = CommonUtility::uploadFile('Page[title_pic]'); if ($uploadedFile != null) { $this->title_pic = $uploadedFile['url'] . $uploadedFile['new_name']; } if (!is_int($this->sort_num)) { $this->sort_num = 0; } $this->publish_time = TTimeHelper::getCurrentTime(); $this->modify_time = TTimeHelper::getCurrentTime(); if ($this->summary == null || empty($this->summary)) { $body = strip_tags($this->body); $pattern = '/\\s/'; //去除空白 $body = preg_replace($pattern, '', $body); $this->summary = TStringHelper::subStr($body, 250); } return true; } return false; }
public static function getActions($table, $type = 'back') { $ret = []; $tableName = $table['table_name']; $ret['index'] = DefineTable::getActionItem($table, $type, 'index', 'IndexAction'); $ret['create'] = DefineTable::getActionItem($table, $type, 'create', 'CreateAction'); $ret['update'] = DefineTable::getActionItem($table, $type, 'update', 'UpdateAction'); $ret['delete'] = DefineTable::getActionItem($table, $type, 'delete', 'DeleteAction'); $ret['other'] = DefineTable::getActionItem($table, $type, 'other', 'OtherAction'); if ($type == 'front') { $ret['channel'] = DefineTable::getActionItem($table, $type, 'channel', 'ChannelAction'); $ret['list'] = DefineTable::getActionItem($table, $type, 'list', 'ListAction'); $ret['detail'] = DefineTable::getActionItem($table, $type, 'detail', 'DetailAction'); $ret['search'] = DefineTable::getActionItem($table, $type, 'search', 'SearchAction'); } if (!empty($table[$type . '_action_custom'])) { $customActions = TStringHelper::parse2Array($table[$type . '_action_custom']); if (!empty($customActions)) { foreach ($customActions as $id => $action) { $ret[$id] = $type . 'end\\actions\\content\\' . $tableName . '\\' . $action; } } } return $ret; }
use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; use components\helpers\TStringHelper; use components\widgets\Tabs; $options = '<option value="0">根节点</option>'; foreach ($this->channels as $row) { $style = ''; if ($row['is_leaf']) { $style = ' disabled="disabled" style="color:red;"'; } else { if ($model['parent_id'] == intval($row['id'])) { $style = ' selected'; } } $options .= '<option value="' . $row['id'] . '"' . $style . '>' . TStringHelper::blank($row['level']) . $row['name_alias'] . '</option>'; } ?> <div class="channel-form"> <?php $isLeafEnable = $model['is_leaf'] ? 'disabled' : null; $disabled = $model->isNewRecord ? null : 'disabled'; $form = ActiveForm::begin(['fieldConfig' => $this->getDefaultFieldConfig()]); ?> <?php Tabs::begin(['items' => [['label' => '基本信息', 'contentId' => 'tableBasic'], ['label' => '模型\\模板', 'contentId' => 'tableModel'], ['label' => 'SEO设置', 'contentId' => 'tableSEO']]]); ?> <div id="tableBasic" class="tab-pane active">
$hotContent = $channelHot[0]; ?> <a href="<?php echo UrlUtility::getContentUrl($hotContent); ?> "> <img src="<?php echo CommonUtility::getTitlePic($hotContent); ?> " style="width:380px;"></a> <h2><?php echo UrlUtility::getContentLink($hotContent); ?> </h2> <p style="width:260px;"><?php echo TStringHelper::subStr($hotContent['summary'], 100); ?> <a href="<?php echo UrlUtility::getContentUrl($hotContent); ?> ">[详细]</a></p> <?php } ?> </div> <div class="clear"></div> <div class="content-channel"> <?php echo LoopData::widget(['dataSource' => $dataList, 'item' => 'item-subchannel']); ?>
<?php use yii\helpers\Html; use yii\helpers\Url; use common\includes\UrlUtility; use common\includes\CommonUtility; use components\helpers\TStringHelper; ?> <li> <h4><a href="<?php echo $row['url']; ?> "><?php echo TStringHelper::subStr($row['title'], $length); ?> </a></h4> <a href="<?php echo $row['url']; ?> "> <img src="<?php echo CommonUtility::getTitlePic($row); ?> " border="0" alt="<?php echo $row['title']; ?> " /> </a> <p><?php echo $row['summary']; ?>
<div class="tbox"> <div class="hd"> <h2>内容管理</h2> </div> <div class="bd"> <ul> <?php foreach ($this->channels as $channel) { $txt = ''; if ($channel['is_leaf']) { $txt = '<a href="admin.php?r=content/manager&chnid=' . $channel['id'] . '" target="mainFrame">' . $channel['name'] . '</a>'; } else { $txt = $channel['name']; } $txt = TStringHelper::blank($channel['level']) . $txt; echo '<li>' . $txt . '</li>'; } ?> </ul> </div> </div>