本文整理汇总了PHP中Catalog::getTree方法的典型用法代码示例。如果您正苦于以下问题:PHP Catalog::getTree方法的具体用法?PHP Catalog::getTree怎么用?PHP Catalog::getTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Catalog
的用法示例。
在下文中一共展示了Catalog::getTree方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
<?php
echo $form->labelEx($model, 'default');
?>
<?php
echo $model->id ? $form->textField($model, 'default', array('size' => 60, 'maxlength' => 255, 'readonly' => true)) : $form->textField($model, 'default', array('size' => 60, 'maxlength' => 255));
?>
<?php
echo $form->error($model, 'default');
?>
<p class="hint"><?php
echo CartModule::t('The value of the default field (database).');
?>
</p>
</div><?php
echo CHtml::activeLabelEx($model, 'catalogs');
echo getTreeCheckbox($model, Catalog::getTree(), $model->catalogs);
?>
<div class="row widget">
<?php
echo $form->labelEx($model, 'widget');
?>
<?php
list($widgetsList) = CDynamicFieldModel::getWidgets($model->field_type);
echo $form->dropDownList($model, 'widget', $widgetsList, array('id' => 'widgetlist'));
//echo $form->textField($model,'widget',array('size'=>60,'maxlength'=>255));
?>
<?php
echo CHtml::error($model, 'widget');
?>
<p class="hint"><?php
示例2: getTreeSelect
function getTreeSelect($selfId = 0)
{
$tree = array(0 => CartModule::t('No'));
$items = Catalog::getTree();
//echo '<pre>'; print_r($items); die();
$prefix = '';
foreach ($items as $item) {
if ($item['self']->id != $selfId) {
$tree[$item['self']->id] = $item['self']->name;
$tree = getChilds($tree, $item['childs'], $selfId);
}
}
return $tree;
}
示例3: actionUpdate
/**
* 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 actionUpdate($id)
{
$model = $this->loadModel($id);
$newRelation = new ProductRelation();
$ProductValue = $model->value;
$newPhoto = new Photo();
// ajax validator
$this->performAjaxValidation($model, $ProductValue, $newPhoto);
$catalogs = Catalog::getTree();
$cat_list = array();
foreach ($model->catalogs as $item) {
$cat_list[$item->id] = $item;
}
if (isset($_POST['Product'])) {
$model->attributes = $_POST['Product'];
$ProductValue->attributes = $_POST['ProductValue'];
$newPhoto->attributes = $_POST['Photo'];
$newRelation->attributes = $_POST['ProductRelation'];
if ($model->validate() && $ProductValue->validate() && $newPhoto->validate()) {
// Update photo title (if set)
/*
if ($model->photo) {
if ($model->photo->title!=$model->name) {
$model->photo->title = $model->name;
$model->photo->save();
}
}//*/
// Upload new photo
$newPhoto->filename = CUploadedFile::getInstance($newPhoto, 'filename');
if ($newPhoto->filename) {
$newPhoto->setDefault();
$newPhoto->title = $model->name;
if ($newPhoto->save()) {
$newPhoto->fullSave();
if (!$model->photo_id) {
$model->photo_id = $newPhoto->id;
}
}
}
// Save product model
if ($model->save()) {
$new_attr = $ProductValue->attributes;
foreach ($new_attr as $name => $fieldarr) {
if (is_array($fieldarr)) {
$new_attr[$name] = implode(', ', $fieldarr);
}
}
$ProductValue->attributes = $new_attr;
// Save product value
$ProductValue->save();
// Add relation to new photo
if ($newPhoto->id) {
$photoRel = new PhotoRelation();
$photoRel->item_id = $model->id;
$photoRel->photo_id = $newPhoto->id;
$photoRel->save();
}
}
// Catalog relation
foreach ($_POST['Product']['catalogs'] as $i => $item) {
if ($item) {
if (!isset($cat_list[$i])) {
$catRel = new CatalogRelation();
$catRel->cid = $i;
$catRel->pr_id = $model->id;
$catRel->save();
}
} else {
if (isset($cat_list[$i])) {
CatalogRelation::model()->find(array('condition' => 'cid=:cid AND pr_id=:pr_id', 'params' => array(':cid' => $i, ':pr_id' => $model->id)))->delete();
}
}
}
if ($newRelation->pr_id) {
$relations = explode(',', $newRelation->pr_id);
foreach ($relations as $rel) {
$pr_id = (int) trim($rel);
if ($pr_id) {
$newRelation = new ProductRelation();
$newRelation->pr_id = $pr_id;
$newRelation->pid = $model->id;
$newRelation->save();
}
}
}
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('update', array('model' => $model, 'ProductValue' => $ProductValue, 'newPhoto' => $newPhoto, 'catalogs' => $catalogs, 'cat_list' => $cat_list, 'newRelation' => $newRelation));
}