本文整理汇总了PHP中Model::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::load方法的具体用法?PHP Model::load怎么用?PHP Model::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model
的用法示例。
在下文中一共展示了Model::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getConfiguration
public static function getConfiguration($name, $redirected = false)
{
$key = $redirected ? "{$redirected}.{$name}" : $name;
$configurations = Model::load("system.configurations");
$value = $configurations->get(["fields" => "value", "conditions" => "key = '{$key}'"]);
return $value[0]['value'];
}
示例2: __construct
/**
* Creates a new ModelField. The example below creates a ModelField which
* lists client accounts for selection.
*
* @code
* $clients = new ModelField("brokerage.setup.clients.client_id", "account");
* @endcode
* @param $path The full path to the field in the module which is to be returned by this field.
* @param $value The name of the field from the model whose value should be displayed in the list.
*/
public function __construct($path, $value)
{
global $redirectedPackage;
$this->info = Model::resolvePath($path);
$this->model = Model::load((substr($this->info["model"], 0, 1) == "." ? $redirectedPackage : "") . $this->info["model"]);
$this->valueField = $value;
$field = $this->model->getFields(array($value));
$this->setLabel($field[0]["label"]);
$this->setDescription($field[0]["description"]);
$this->setName($this->info["field"]);
$params = array("fields" => array($this->info["field"], $this->valueField), "sort_field" => $this->valueField);
if ($this->conditions != '') {
$params['conditions'] = $this->conditions;
}
$data = $this->model->get($params, Model::MODE_ARRAY);
$this->addOption("Add new " . Utils::singular($this->model->getEntity()), 'NEW');
foreach ($data as $datum) {
if ($datum[1] == "") {
$this->addOption($datum[0]);
} else {
$this->addOption($datum[1], $datum[0]);
}
}
$modelPath = str_replace('.', '/', $this->model->package);
$this->addAttribute('onchange', "fapiAddModelItem('{$modelPath}', this, '{$value}')");
}
示例3: index
public function index()
{
$post = array('alert' => '');
Model::load('admincp/pages');
if ($match = Uri::match('\\/pages\\/(\\w+)')) {
if (method_exists("controlPages", $match[1])) {
$method = $match[1];
$this->{$method}();
die;
}
}
$curPage = 0;
if ($match = Uri::match('\\/page\\/(\\d+)')) {
$curPage = $match[1];
}
if (Request::has('btnAction')) {
actionProcess();
}
if (Request::has('btnSearch')) {
filterProcess();
} else {
$post['pages'] = Misc::genSmallPage('admincp/pages', $curPage);
$filterPending = '';
$post['theList'] = Pages::get(array('limitShow' => 20, 'limitPage' => $curPage, 'cacheTime' => 1));
}
System::setTitle('Pages list - ' . ADMINCP_TITLE);
View::make('admincp/head');
self::makeContents('pagesList', $post);
View::make('admincp/footer');
}
示例4: index
public function index()
{
$post = array('alert' => '');
Model::load('admincp/theme');
if ($match = Uri::match('\\/theme\\/(\\w+)')) {
if (method_exists("controlTheme", $match[1])) {
$method = $match[1];
$this->{$method}();
die;
}
}
if ($match = Uri::match('\\/activate\\/(\\w+)')) {
$theName = $match[1];
try {
Theme::setActivate($theName);
$post['alert'] = '<div class="alert alert-success">Change theme success</div>';
Redirect::to(ADMINCP_URL . 'theme');
} catch (Exception $e) {
$post['alert'] = '<div class="alert alert-warning">' . $e->getMessage() . '</div>';
}
}
$curPage = 0;
if ($match = Uri::match('\\/page\\/(\\d+)')) {
$curPage = $match[1];
}
$post['listThemes'] = Theme::get();
$post['theme'] = Theme::getDefault();
System::setTitle('Theme list - ' . ADMINCP_TITLE);
View::make('admincp/head');
self::makeContents('themeList', $post);
View::make('admincp/footer');
}
示例5: test
public function test($test_text)
{
$model = Model::load('test', 1);
$model->name = 'zmiana nazwy';
$model->save();
$this->template->test = $model->name;
}
示例6: index
public function index()
{
$post = array('alert' => '');
Model::load('admincp/usergroups');
if ($match = Uri::match('\\/usergroups\\/(\\w+)')) {
if (method_exists("controlUsergroups", $match[1])) {
$method = $match[1];
$this->{$method}();
die;
}
}
$curPage = 0;
if ($match = Uri::match('\\/page\\/(\\d+)')) {
$curPage = $match[1];
}
if (Request::has('btnAction')) {
actionProcess();
}
// $valid=UserGroups::getThisPermission('can_addnew_usergroup');
$post['pages'] = Misc::genPage('admincp/usergroups', $curPage);
$post['theList'] = UserGroups::get(array('cacheTime' => 1, 'limitShow' => 20, 'limitPage' => $curPage));
System::setTitle('Usergroups list - ' . ADMINCP_TITLE);
View::make('admincp/head');
self::makeContents('usergroupsList', $post);
View::make('admincp/footer');
}
示例7: index
public function index()
{
$post = array('alert' => '');
Model::load('admincp/comments');
if ($match = Uri::match('\\/comments\\/(\\w+)')) {
if (method_exists("controlComments", $match[1])) {
$method = $match[1];
$this->{$method}();
die;
}
}
$curPage = 0;
if ($match = Uri::match('\\/page\\/(\\d+)')) {
$curPage = $match[1];
}
if (Request::has('btnAction')) {
actionProcess();
}
if (Request::has('btnSearch')) {
filterProcess();
} else {
$post['pages'] = Misc::genSmallPage('admincp/comments', $curPage);
$filterPending = '';
if (Uri::has('\\/status\\/pending')) {
$filterPending = " AND c.status='0' ";
}
$post['theList'] = Comments::get(array('limitShow' => 20, 'limitPage' => $curPage, 'query' => "select c.*,p.title from " . Database::getPrefix() . "post p," . Database::getPrefix() . "comments c where c.postid=p.postid order by c.commentid desc", 'cacheTime' => 1));
}
System::setTitle('Comments list - ' . ADMINCP_TITLE);
View::make('admincp/head');
self::makeContents('commentsList', $post);
View::make('admincp/footer');
}
示例8: getModel
private static function getModel()
{
if (PgFileStore::$model == null) {
PgFileStore::$model = Model::load("system.binary_objects");
}
return PgFileStore::$model;
}
示例9: __construct
public function __construct()
{
parent::__construct();
$this->univ = Model::load('UnivModel');
$this->user = Model::load('UserModel');
$this->group = Model::load('GroupModel');
}
示例10: index
public function index()
{
$post = array('alert' => '');
Model::load('admincp/users');
if ($match = Uri::match('\\/users\\/(\\w+)')) {
if (method_exists("controlUsers", $match[1])) {
$method = $match[1];
$this->{$method}();
die;
}
}
$curPage = 0;
if ($match = Uri::match('\\/page\\/(\\d+)')) {
$curPage = $match[1];
}
if (Request::has('btnAction')) {
actionProcess();
}
if (Request::has('btnSearch')) {
filterProcess();
} else {
$post['pages'] = Misc::genSmallPage('admincp/users', $curPage);
$prefix = '';
$prefixall = Database::isPrefixAll();
if ($prefixall != false || $prefixall == 'no') {
$prefix = Database::getPrefix();
}
$post['theList'] = Users::get(array('limitShow' => 20, 'limitPage' => $curPage, 'query' => "select u.*,ug.*,a.* from " . $prefix . "users u," . $prefix . "usergroups ug,address a where u.groupid=ug.groupid AND u.userid=a.userid order by u.userid desc", 'cacheTime' => 1));
}
System::setTitle('User list - ' . ADMINCP_TITLE);
View::make('admincp/head');
self::makeContents('userList', $post);
View::make('admincp/footer');
}
示例11: permissions
/**
* The method which displays the permissions so they could be setup. This
* method is called by the application and it performs recursive calls to
* the drawPermissions() method.
*
* @param $params array Passes the role_id through an array.
* @return String
*/
public function permissions($params)
{
if ($_POST["is_sent"] == "yes") {
//Save the permission values
$this->permissions = Model::load(".permissions");
$permissions = $_POST;
array_pop($permissions);
foreach ($permissions as $permission => $value) {
$this->permissions->delete("role_id = '{$params[0]}' AND permission = '{$permission}'");
$this->permissions->setData(array("role_id" => $params[0], "permission" => $permission, "value" => $value[0], "module" => $value[1]));
$this->permissions->save();
}
//Generate a new side menu for this role
$menu = $this->generateMenus($params[0]);
$flatened = $this->flatenMenu($menu);
$sideMenu = Controller::load(array("system", "side_menu", "generate", serialize($menu)));
file_put_contents("app/cache/menus/side_menu_{$params[0]}.html", $sideMenu->content);
file_put_contents("app/cache/menus/menu_{$params[0]}.object", serialize($flatened));
User::log("Set permissions");
//, $permissions);
}
$path = $params;
array_shift($path);
$accum = Application::$prefix . "/system/roles/permissions/{$params[0]}";
$menu = "<a href='{$accum}'>Permissions</a>";
foreach ($path as $section) {
$accum .= "/{$section}";
$menu .= " > <a href='{$accum}'>" . ucfirst($section) . "</a>";
}
$path = implode("/", $path);
$ret .= "<form class='fapi-form' method='post'>" . $menu . "<br/><hr/>" . $this->drawPermissions($this->getPermissionList("app/modules/{$path}", "app/modules"), $params[0]) . "<input type='hidden' name='is_sent' value='yes'/>" . $this->save . "</div></form>";
Application::setTitle("Role Permissions");
return $ret;
}
示例12: settingEdit
/**
* ブログの設定変更処理
*/
private function settingEdit($white_list, $action)
{
$request = Request::getInstance();
$blog_settings_model = Model::load('BlogSettings');
$blog_id = $this->getBlogId();
// 初期表示時に編集データの取得&設定
if (!$request->get('blog_setting') || !Session::get('sig') || Session::get('sig') !== $request->get('sig')) {
Session::set('sig', App::genRandomString());
$blog_setting = $blog_settings_model->findByBlogId($blog_id);
$request->set('blog_setting', $blog_setting);
return;
}
// 更新処理
$errors = array();
$errors['blog_setting'] = $blog_settings_model->validate($request->get('blog_setting'), $blog_setting_data, $white_list);
if (empty($errors['blog_setting'])) {
// コメント確認からコメントを確認せずそのまま表示に変更した場合既存の承認待ちを全て承認済みに変更する
$blog_setting = $blog_settings_model->findByBlogId($blog_id);
if ($blog_setting['comment_confirm'] == Config::get('COMMENT.COMMENT_CONFIRM.CONFIRM') && $blog_setting_data['comment_confirm'] == Config::get('COMMENT.COMMENT_CONFIRM.THROUGH')) {
Model::load('Comments')->updateApproval($blog_id);
}
// ブログの設定情報更新処理
if ($blog_settings_model->updateByBlogId($blog_setting_data, $blog_id)) {
// 一覧ページへ遷移
$this->setInfoMessage(__("I have updated the configuration information of the blog"));
$this->redirect(array('action' => $action));
}
}
// エラー情報の設定
$this->setErrorMessage(__('Input error exists'));
$this->set('errors', $errors);
}
示例13: getInstance
private function getInstance()
{
if (self::$instance === false) {
self::$instance = Model::load('system.audit_trail');
self::$dataModel = Model::load('system.audit_trail_data');
}
return self::$instance;
}
示例14: deleteByIdAndUserId
/**
* idとuser_idをキーとした更新
*/
public function deleteByIdAndUserId($id, $user_id, $options = array())
{
if (!parent::deleteByIdAndUserId($id, $user_id, $options)) {
return false;
}
// 登録状態(id<>0)のプラグインを未登録(id=0)に戻す
return Model::load('BlogPlugins')->update(array('plugin_id' => 0), 'plugin_id=?', array($id));
}
示例15: performAjaxValidation
protected function performAjaxValidation(Model $model)
{
if (\Yii::$app->request->isAjax && $model->load(\Yii::$app->request->post())) {
\Yii::$app->response->format = Response::FORMAT_JSON;
echo json_encode(ActiveForm::validate($model));
\Yii::$app->end();
}
}