本文整理汇总了PHP中Tree::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Tree::instance方法的具体用法?PHP Tree::instance怎么用?PHP Tree::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree::instance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_add
/**
* Add
*/
public function action_add()
{
$this->title = __('publications.page_add');
$obj = ORM::factory('Publications_Page');
if ($this->request->is_post()) {
$tags = Arr::get($_POST, 'tags');
$obj->prepare();
$obj->values($_POST);
try {
$obj->save();
if (Module::is_on('cms_tags')) {
$obj->save_tags($tags, Model_Tag::TYPE_PUBLICATION);
}
Message::success(__('publications.page_added'));
$this->_redirect($obj->id);
} catch (ORM_Validation_Exception $e) {
Message::error(__('settings.error_saving'));
$errors = $e->errors('validation');
}
} else {
$tags = '';
}
$sel_category = Tree::instance('publications_categories', $this->curr_module)->form_select('category_id', $obj->category_id, ['', ''], ['class' => 'form-control']);
$this->content = View::factory($this->form, ['obj' => $obj, 'sel_category' => $sel_category])->bind('tags', $tags)->bind('errors', $errors);
}
示例2: getInstance
public static function getInstance()
{
if (!self::$instance instanceof self) {
self::$instance = new self();
}
return self::$instance;
}
示例3: action_edit
/**
* Edit
*/
public function action_edit()
{
$this->title = __('shop.category_edit');
$obj = ORM::factory('Shop_Category', $this->request->param('id'));
if (!$obj->loaded()) {
throw new HTTP_Exception_404();
}
if ($this->request->is_post()) {
$obj->prepare();
$obj->values($_POST);
try {
$obj->save();
Message::success(__('settings.changes_saved'));
$this->_redirect($obj->id);
} catch (ORM_Validation_Exception $e) {
Message::error(__('settings.error_saving'));
$errors = $e->errors('validation');
}
}
$sel_category = Tree::instance('shop_categories', $this->curr_module, ['last' => false])->form_select('parent_id', $obj->parent_id, [0, ''], ['class' => 'form-control']);
$this->content = View::factory($this->form, ['obj' => $obj, 'sel_category' => $sel_category])->bind('errors', $errors);
}
示例4: action_edit
/**
* Edit
*/
public function action_edit()
{
Assets::instance()->add_styles(['vendor/crop/css/cropper.min.css', 'vendor/crop/css/screen.css'])->add_scripts(['vendor/fileuploader/jquery.ui.widget.js', 'vendor/fileuploader/jquery.iframe-transport.js', 'vendor/fileuploader/jquery.fileupload.js', 'vendor/crop/js/cropper.min.js', 'vendor/crop/js/main.js']);
$this->title = __('shop.product_edit');
$obj = ORM::factory('Shop_Product', $this->request->param('id'));
if (!$obj->loaded()) {
throw new HTTP_Exception_404();
}
if ($this->request->is_post()) {
$obj->prepare();
$obj->values($_POST);
try {
$obj->save();
Message::success(__('settings.changes_saved'));
$this->_redirect($obj->id);
} catch (ORM_Validation_Exception $e) {
Message::error(__('settings.error_saving'));
$errors = $e->errors('validation');
}
}
$sel_category = Tree::instance('shop_categories', $this->curr_module)->form_select('category_id', $obj->category_id, ['', ''], ['class' => 'form-control']);
$this->content = View::factory($this->form, ['obj' => $obj, 'sel_category' => $sel_category])->bind('errors', $errors);
}