本文整理汇总了PHP中Widget::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Widget::model方法的具体用法?PHP Widget::model怎么用?PHP Widget::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Widget
的用法示例。
在下文中一共展示了Widget::model方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionAjaxGetChannels
public function actionAjaxGetChannels()
{
$pointId = Yii::app()->request->getPost('pointId');
$pointDateStr = date('Y-m-d');
$requestTime = date('H:i:s');
$pointDatetimeStr = $pointDateStr . " 23:59:59";
$pointDateTimestamp = strtotime($pointDateStr);
$weekDay = strtolower(date('D', $pointDateTimestamp));
$Playlist = new Playlists();
$pointChannels = Channel::model()->findAll('id_point=:id_point AND window_id IS NOT NULL', array(':id_point' => $pointId));
$resp = array();
foreach ($pointChannels as $pointChannel) {
$pointChannelId = $pointChannel->internalId;
$windowId = $pointChannel->window_id;
if (!is_null($windowId)) {
$bg = $Playlist->GetBGContentArr($pointId, $pointChannelId, $pointDatetimeStr, $weekDay);
$adv = $Playlist->GetAdvContentArr($pointId, $pointChannelId, $pointDatetimeStr, $weekDay);
$blockStructedContent = $Playlist->BuildBlockStructedContent($bg, $adv);
$straightTimeContent = $Playlist->ConverBlockStructedToStraightTimeContent($blockStructedContent);
$straightTimeContentHisToSecs = $this->ConvertHisToSecsInStraightTime($straightTimeContent, $requestTime);
$url = Yii::app()->request->getBaseUrl(true) . '/spool/points/' . $pointId . '/' . $pointChannelId;
$straightTimeContentWithURLPath = $this->UpdateContentPathes($straightTimeContentHisToSecs, $url);
$window = Window::model()->findByPK($windowId);
$widgetToChannel = WidgetToChannel::model()->find("channel_id = :channel_id", array("channel_id" => $pointChannel->id));
$widget = '';
if (count($widgetToChannel) > 0) {
$widgetModel = Widget::model()->findByPk($widgetToChannel['widget_id']);
$widget = $widgetModel['content'];
}
$resp[] = array('width' => $window->width, 'height' => $window->height, 'top' => $window->top, 'left' => $window->left, 'content' => $straightTimeContentWithURLPath, 'widget' => $widget);
}
}
echo json_encode($resp);
exit;
}
示例2: ajax
public function ajax($vars)
{
$widget = Widget::model()->findByPk($vars['widgetId']);
$content = $widget->content;
if ($content && !Yii::app()->user->isGuest) {
if (isset($vars['ContentModel'])) {
$content->attributes = $vars['ContentModel'];
}
if (isset($vars['attribute']) && isset($vars['width']) && isset($vars['height']) && isset($vars['tag']) && isset($vars['number'])) {
$html = $content->{$vars['attribute']};
preg_match_all("/<{$vars['tag']}[^>]*?\\/?>/msiu", $html, $matches, PREG_OFFSET_CAPTURE);
$t = $matches[0][intval($vars['number'])];
$source = $t[0];
$repl = preg_replace("/width=[\"\\']?([\\d]*)[\"\\'?]/msi", 'width="' . intval($vars['width']) . '"', $t[0]);
if ($repl == $t[0]) {
$repl = str_ireplace('<' . $vars['tag'], '<' . $vars['tag'] . ' width="' . intval($vars['width']) . '"', $repl);
}
$t[0] = $repl;
$repl = preg_replace("/height=[\"\\']?([\\d]*)[\"\\'?]/msi", 'height="' . intval($vars['height']) . '"', $repl);
if ($repl == $t[0]) {
$repl = str_ireplace('<' . $vars['tag'], '<' . $vars['tag'] . ' height="' . intval($vars['height']) . '"', $repl);
}
$repl = preg_replace("/width:[\\s]+?([\\d]*)px/msi", 'width: ' . intval($vars['width']) . 'px', $repl);
$repl = preg_replace("/height:[\\s]+?([\\d]*)px/msi", 'height: ' . intval($vars['height']) . 'px', $repl);
$content->{$vars['attribute']} = substr($html, 0, $t[1]) . str_replace($source, $repl, substr($html, $t[1], strlen($source))) . substr($html, $t[1] + strlen($source));
}
echo $widget->save() && $content->save();
}
}
示例3: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the ID of the model to be loaded
*/
public function loadModel($id)
{
$model = Widget::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例4: loadWidget
public function loadWidget()
{
$widget = Widget::model()->findAllByAttributes(array('groups' => $this->widgetID), array('order' => 'sort ASC'));
if ($widget === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $widget;
}
示例5: afterSave
protected function afterSave()
{
parent::afterSave();
if ($this->isNewRecord) {
$menu = Widget::model()->findByPk($this->term_id);
$menu->saveCounters(array('count' => '1'), array('condition' => "term_id = :term_id"), array(':term_id' => $this->term_id));
}
}
示例6: setWidget
protected function setWidget()
{
$child = get_called_class();
include_once $child . '/models/model_' . $child . '.php';
$modelClass = "model_{$child}";
$model = new $modelClass();
// set value of model property
foreach (get_object_vars($model) as $property => $value) {
if (isset($this->data[$property])) {
$model->{$property} = $this->data[$property];
}
}
// check if widget is isset and set attributes for validation
if (isset($_POST[$this->param['ID'] . '-save'])) {
$model->attributes = $_POST[$modelClass];
}
// check validation
if (isset($_POST[$this->param['ID'] . '-save']) && $model->validate()) {
// mulai transaksi
$transaction = Yii::app()->db->beginTransaction();
try {
foreach ($_POST[$modelClass] as $field => $fd) {
$array["{$field}"] = $fd;
}
$array['last_update'] = date('Y-m-d H:i:s');
if (isset($_POST['visibleOn'])) {
$array['visibleOn'] = $_POST['visibleOn'];
}
$model = Widget::model()->findByPk((int) $this->param['ID']);
if ($model !== null) {
$model->description = serialize(str_replace(Helper::rootImg('content'), '', $array));
if ($model->save(false)) {
$transaction->commit();
$message = "<strong>Well done!</strong> You successfully Saving";
Yii::app()->user->setFlash('success', $message);
$this->controller->refresh();
} else {
Yii::app()->user->setFlash('error', "on error occured, please try again");
}
} else {
Yii::app()->user->setFlash('error', "on error occured, please try again");
}
} catch (Exception $e) {
$transaction->rollBack();
if (true == YII_DEBUG) {
Yii::app()->user->setFlash('error', "{$e->getMessage()}");
} else {
Yii::app()->user->setFlash('error', "on error occured, please try again");
}
// for production
// $this->refresh();
}
} else {
$this->render('_form', array('model' => $model, 'param' => $this->param, 'data' => $this->data));
}
}
示例7: actionIndex
public function actionIndex()
{
Yii::app()->returnUrl;
// TODO: component has to be called, preload does not work
$criteria = new CDbCriteria();
$criteria->condition = 'controllerId = :controllerId AND actionName = :actionName AND requestParam != :universalValue';
$criteria->params = array(':controllerId' => 'wiki', ':actionName' => 'index', ':universalValue' => P3WidgetContainer::UNIVERSAL_VALUE);
$criteria->order = 'requestParam';
$criteria->group = 'requestParam';
$models = Widget::model()->findAll($criteria);
$items = array();
foreach ($models as $model) {
$items[] = array('label' => $model->requestParam ? $model->requestParam : 'Home', 'url' => array('/wiki', 'page' => $model->requestParam));
}
$this->render('index', array('items' => $items));
}
示例8: array
if (empty($item)) {
$widget_name = $item;
} else {
if (!empty($param['name'])) {
$widget_name = !is_array($param['name']) ? $param['name'] : '';
}
if (!empty($param['description'])) {
$widget_description = !is_array($param['description']) ? $param['description'] : '';
}
}
if (ctype_alnum($item) and $item != 'controller') {
// check alphanumeric
echo "<div class='well'>";
echo CHtml::Link('<i class="fa fa-edit"></i>', $this->createUrl('widget/edit', array('id' => $widget_id)), array('class' => 'btn-warning btn pull-right'));
echo "<b>" . $widget_name . "</b> ";
$count = Widget::model()->findAllByattributes(array('groups' => $widget_id));
echo " - <span class='label label-info'>" . count($count) . "</span><br>";
echo "<span class='muted'>(" . $widget_description . ")</span><br>";
foreach ($count as $wid) {
$set = $wid->description != '' ? "<i class='text-success'>Telah di set</i>" : "<i class='text-error'>Belum di set</i>";
echo "<i class='fa fa-caret-right'></i> " . $wid->name . " - " . $set . "<br>";
}
echo "</div>";
}
}
echo "</div></div>";
if ($a++ % 2 == 0) {
// cek row ini pertama atau kedua, jika kedua tampilkan
echo "</div>";
}
}
示例9: foreach
$channels = $model->channels;
$ScreenModelId = $model->screen_id;
if ($ScreenModelId != null) {
$ScreenModel = Screen::model()->findByPk($ScreenModelId);
if (isset($ScreenModel->windows)) {
$windows = $ScreenModel->windows;
foreach ($windows as $window) {
$windowId = $window->id;
$windowName = $window->name;
foreach ($channels as $channel) {
if ($channel->id_point === $model->id && $channel->window_id === $window->id) {
printf("<div class='ChannelsContainer btn-toolbar' data-channelid='%s' role='toolbar' aria-label=''>", $channel['id']);
$widgetToChannel = WidgetToChannel::model()->find("channel_id = :channel_id", array("channel_id" => $channel['id']));
printf("<div class='btn-group' role='group' aria-label=''>" . "<button type='button' class='btn btn-default ChannelButt' disabled='disabled'>Screen %s</button>", $windowName);
if (count($widgetToChannel) > 0) {
$widgetModel = Widget::model()->findByPk($widgetToChannel['widget_id']);
printf("<button type='button' class='detach-widget btn btn-warning' data-channelid='%s'>" . "<span class='glyphicon glyphicon-off'></span> Detach widget " . $widgetModel['name'] . "</button>", $channel['id']);
} else {
printf("<button type='button' class='attach-widget btn btn-success' data-channelid='%s'>" . "<span class='glyphicon glyphicon-paperclip'></span> Attach widget" . "</button>", $channel['id']);
}
echo "</div>";
}
}
}
}
}
}
printf("</div>");
?>
<?php
echo $form->error($model, 'screen_id');
示例10: loadModel
public function loadModel($id)
{
$model = Widget::model()->findAllByAttributes(array('groups' => $id), array('order' => 'sort ASC'));
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例11: foreach
<!-- Modal -->
<div id="widget-dialog" title="Attach widget channel">
<p>
<?php
$userId = Yii::app()->user->id;
$widgets = Widget::model()->findAll();
$attributeLabels = Widget::model()->attributeLabels();
if (count($widgets) > 0) {
echo '<table class="table table-hover">';
echo '<tr>';
echo '<td></td>';
echo '<td>' . $attributeLabels['name'] . '</td>';
echo '<td>' . $attributeLabels['description'] . '</td>';
echo '<td>' . $attributeLabels['created_dt'] . '</td>';
echo '</tr>';
foreach ($widgets as $widget) {
echo '<tr>';
echo '<td>' . '<input class="selected-widget" type="radio" name="selected-widget" ' . 'data-widgetid="' . $widget['id'] . '" ' . 'data-widgetname="' . $widget['name'] . '"/>' . '</td>';
echo '<td>' . $widget['name'] . '</td>';
echo '<td>' . $widget['description'] . '</td>';
echo '<td>' . $widget['created_dt'] . '</td>';
echo '</tr>';
}
echo '</table>';
} else {
echo 'No avaliable widgets';
}
?>
</p>
</div>
示例12: actionAjax
/**
* Обрабатывает ajax-запрос к блоку
*
* @param int $widgetId id блока
*/
public function actionAjax($widgetId)
{
$widget = Widget::model()->findByPk($widgetId);
$widget->content->ajax($_REQUEST);
}