本文整理汇总了PHP中Floxim\Floxim\System\Fx::data方法的典型用法代码示例。如果您正苦于以下问题:PHP Fx::data方法的具体用法?PHP Fx::data怎么用?PHP Fx::data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Floxim\Floxim\System\Fx
的用法示例。
在下文中一共展示了Fx::data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
public function install($input)
{
$patch_id = $input['params'][0];
if (!$patch_id) {
return;
}
$patch = fx::data('patch', $patch_id);
if (!$patch) {
return;
}
$this->response->addField(array('type' => 'label', 'value' => '<p>' . sprintf(fx::alang('Installing patch %s...', 'system'), $patch['to']) . '</p>'));
$res = false;
try {
$res = $patch->install();
} catch (Exception $e) {
$this->response->addField(array('type' => 'label', 'value' => '<p style="color:#F00;">' . $e->getMessage() . '</p>'));
}
if (!$res) {
$this->response->addField(array('type' => 'label', 'value' => '<p style="color:#F00;">Install failed!</p>'));
} else {
// retrieve changes
$changes = '<ul>';
$logs = fx::changelog($patch['to']);
foreach ($logs as $log) {
$changes .= "<li>{$log['message']}</li>";
}
$changes .= '</ul>';
$this->response->addField(array('type' => 'label', 'value' => '<p>Patch installed sucessfully!</p>' . $changes));
}
$this->response->addField(array('type' => 'button', 'url' => 'patch.all', 'label' => 'Back'));
$this->setLayout($patch);
}
示例2: deleteInfoblocks
protected function deleteInfoblocks()
{
$infoblocks = fx::data('infoblock')->where('site_id', $this['id'])->all();
foreach ($infoblocks as $infoblock) {
$infoblock->delete();
}
}
示例3: doNeighbours
public function doNeighbours()
{
$item = fx::env('page');
$q = $this->getFinder()->order(null)->limit(1)->where('site_id', fx::env('site_id'));
$q_next = clone $q;
$q_prev = clone $q;
if ($this->getParam('sorting') === 'auto' && $item['infoblock_id']) {
$item_ib_params = fx::data('infoblock', $item['infoblock_id'])->get('params');
$ib_sorting = $item_ib_params['sorting'];
$this->setParam('sorting', $ib_sorting == 'manual' || $ib_sorting == 'auto' ? 'priority' : $ib_sorting);
$this->setParam('sorting_dir', $item_ib_params['sorting_dir']);
}
$sort_field = $this->getParam('sorting', 'priority');
if ($sort_field === 'auto') {
$sort_field = 'priority';
}
$dir = strtolower($this->getParam('sorting_dir', 'asc'));
$where_prev = array(array($sort_field, $item[$sort_field], $dir == 'asc' ? '<' : '>'));
$where_next = array(array($sort_field, $item[$sort_field], $dir == 'asc' ? '>' : '<'));
$group_by_parent = $this->getParam('group_by_parent');
if ($group_by_parent) {
$c_parent = fx::content($item['parent_id']);
// todo: psr0 need verify
$q_prev->order('parent.priority', 'desc')->where('parent.priority', $c_parent['priority'], '<=');
$q_next->order('parent.priority', 'asc')->where('parent.priority', $c_parent['priority'], '>=');
$where_prev[] = array('parent_id', $item['parent_id'], '!=');
$where_next[] = array('parent_id', $item['parent_id'], '!=');
}
$q_prev->order($sort_field, $dir == 'asc' ? 'desc' : 'asc')->where($where_prev, null, 'or');
$prev = $q_prev->all();
$q_next->order($sort_field, $dir)->where($where_next, null, 'or');
$next = $q_next->all();
//fx::log($q_prev->showQuery(), $q_next->showQuery());
return array('prev' => $prev, 'current' => $item, 'next' => $next);
}
示例4: validate
public function validate()
{
$res = true;
if (!$this['name']) {
$this->validate_errors[] = array('field' => 'name', 'text' => fx::alang('Specify the name of the widget', 'system'));
$res = false;
}
if (!$this['keyword']) {
$this->validate_errors[] = array('field' => 'keyword', 'text' => fx::alang('Enter the keyword of widget', 'system'));
$res = false;
}
if ($this['keyword'] && !preg_match("/^[a-z0-9_\\.]+\$/i", $this['keyword'])) {
$this->validate_errors[] = array('field' => 'keyword', 'text' => fx::alang('Keyword can contain only letters and numbers', 'system') . ' / ' . $this['keyword']);
$res = false;
}
if ($this['keyword']) {
$widgets = fx::data('widget')->all();
foreach ($widgets as $widget) {
if ($widget['id'] != $this['id'] && $widget['keyword'] == $this['keyword']) {
$this->validate_errors[] = array('field' => 'keyword', 'text' => fx::alang('This keyword is used by widget', 'system') . ' "' . $widget['name'] . '"');
$res = false;
}
}
}
return $res;
}
示例5: getErrorPage
public function getErrorPage($site_id = null)
{
if (is_null($site_id)) {
$site_id = fx::env('site_id');
}
$error_page = fx::data('page', fx::data('site', $site_id)->get('error_page_id'));
return $error_page;
}
示例6: getFakeIb
protected function getFakeIb()
{
static $fake_counter = 0;
$fake_ib = fx::data('infoblock')->create();
$fake_ib['id'] = 'fake-' . $fake_counter++;
$fake_ib['name'] = fx::alang('New infoblock');
return $fake_ib;
}
示例7: install
public function install(\Floxim\Floxim\Component\Infoblock\Entity $ib, $ctr, $params)
{
if (!isset($params['form_id']) || !$params['form_id']) {
$form = fx::data('floxim.form.form')->create(array('name' => 'My new form'));
$form->save();
$ib->digSet('params.form_id', $form['id']);
$ib->save();
fx::log('ib savd', $ib, $params, $form);
}
}
示例8: route
public function route($url = null, $context = null)
{
if (!fx::isAdmin()) {
return null;
}
if (!preg_match("~^/\\~ib/(\\d+|fake(?:\\-\\d+)?)@(\\d+)~", $url, $ib_info)) {
return null;
}
$c_url = fx::input()->fetchGetPost('_ajax_base_url');
if ($c_url) {
$_SERVER['REQUEST_URI'] = $c_url;
$path = fx::router()->getPath(fx::path()->removeBase($c_url));
if ($path) {
fx::env('page', $path->last());
} else {
fx::env('page', fx::router('error')->getErrorPage());
}
$c_url = parse_url($c_url);
if (isset($c_url['query'])) {
parse_str($c_url['query'], $_GET);
}
}
$ib_id = $ib_info[1];
$page_id = $ib_info[2];
if (!fx::env('page') && $page_id) {
$page = fx::data('floxim.main.content', $page_id);
fx::env('page', $page);
}
fx::env('ajax', true);
$page_infoblocks = fx::router('front')->getPageInfoblocks($page_id, fx::env('layout'));
fx::page()->setInfoblocks($page_infoblocks);
// import layout template to recreate real env
fx::router('front')->importLayoutTemplate();
// front end can try to reload the layout which is out of date
// when updating from "layout settings" panel
$infoblock = fx::data('infoblock', $ib_id);
if (!$infoblock && isset($_POST['infoblock_is_layout']) || $infoblock->isLayout()) {
//$infoblock = $layout_infoblock;
$infoblock = fx::router('front')->getLayoutInfoblock(fx::env('page'));
}
fx::http()->status('200');
$infoblock_overs = null;
if (fx::isAdmin() && isset($_POST['override_infoblock'])) {
$infoblock_overs = fx::input('post', 'override_infoblock');
if (is_string($infoblock_overs)) {
parse_str($infoblock_overs, $infoblock_overs);
$infoblock_overs = fx::input()->prepareSuperglobal($infoblock_overs);
}
$infoblock->override($infoblock_overs);
}
$infoblock->overrideParam('ajax_mode', true);
$res = $infoblock->render();
return $res;
}
示例9: getPath
public static function getPath($id)
{
if (!is_numeric($id)) {
return $id;
}
$file = fx::data('filetable', $id);
if (!$file) {
return null;
}
return $file->getHttpPath();
}
示例10: beforeSave
protected function beforeSave()
{
parent::beforeSave();
unset($this['is_stub']);
if (!$this['priority'] && $this['layout_id']) {
$last_vis = fx::data('infoblock_visual')->where('layout_id', $this['layout_id'])->where('area', $this['area'])->order(null)->order('priority', 'desc')->one();
$this['priority'] = $last_vis['priority'] + 1;
}
if ($this->needRecountFiles) {
$this->recountFiles();
}
}
示例11: handleLinkers
protected function handleLinkers()
{
fx::listen('after_delete', function ($e) {
$entity = $e['entity'];
if (!$entity->isInstanceOf('floxim.main.content') || $entity->isInstanceOf('floxim.main.linker')) {
return;
}
$linkers = fx::data('floxim.main.linker')->where('linked_id', $entity['id'])->all();
$linkers->apply(function ($l) {
$l->delete();
});
});
}
示例12: doAdd
public function doAdd()
{
if (isset($_POST["addcomment"]) && isset($_POST["user_name"]) && !empty($_POST["user_name"]) && isset($_POST["comment_text"]) && !empty($_POST["comment_text"])) {
$comments = fx::data('comment')->create(array('user_name' => $_POST["user_name"], 'comment_text' => $_POST["comment_text"], 'publish_date' => date("Y-m-d H:i:s"), 'parent_id' => $this->getParentId(), 'infoblock_id' => $this->getParam('target_infoblock_id')));
$comments->save();
if (!isset($_COOKIE["own_comments"])) {
setcookie('own_comments', $comments["id"], time() + 60 * 60 * 24 * 30);
} else {
setcookie('own_comments', $_COOKIE["own_comments"] . ',' . $comments["id"], time() + 60 * 60 * 24 * 30);
}
fx::http()->refresh();
}
}
示例13: getData
public function getData()
{
$data = parent::getData();
$types_by_id = $data->getValues('type', 'id');
unset($types_by_id['']);
if (count($types_by_id) == 0) {
return $data;
}
$base_component = fx::component($this->component_id);
$base_type = $base_component['keyword'];
$base_table = $base_component->getContentTable();
$types = array();
foreach ($types_by_id as $id => $type) {
if ($type != $base_type) {
if (!isset($types[$type])) {
$types[$type] = array();
}
$types[$type][] = $id;
}
}
foreach ($types as $type => $ids) {
if (!$type) {
continue;
}
$type_tables = array_reverse(fx::data($type)->getTables());
$missed_tables = array();
foreach ($type_tables as $table) {
if ($table == $base_table) {
break;
}
$missed_tables[] = $table;
}
$base_missed_table = array_shift($missed_tables);
if (!$base_missed_table) {
fx::log('empty base table');
continue;
}
$q = "SELECT * FROM `{{" . $base_missed_table . "}}` \n";
foreach ($missed_tables as $mt) {
$q .= " INNER JOIN `{{" . $mt . '}}` ON `{{' . $mt . '}}`.id = `{{' . $base_missed_table . "}}`.id\n";
}
$q .= "WHERE `{{" . $base_missed_table . "}}`.id IN (" . join(", ", $ids) . ")";
$extensions = fx::db()->getIndexedResults($q);
foreach ($data as $data_index => $data_item) {
if (isset($extensions[$data_item['id']])) {
$data[$data_index] = array_merge($data_item, $extensions[$data_item['id']]);
}
}
}
return $data;
}
示例14: up
protected function up()
{
$new_fields = array(array('keyword' => 'is_published', 'name_en' => 'Is published?', 'name_ru' => '', 'type' => '5', 'not_null' => '0', 'priority' => '267', 'searchable' => '0', 'default' => '1', 'type_of_edit' => '1', 'checked' => '1', 'form_tab' => '0'), array('keyword' => 'is_branch_published', 'name_en' => 'Is branch published?', 'name_ru' => '', 'type' => '5', 'not_null' => '0', 'priority' => '268', 'searchable' => '0', 'default' => '1', 'type_of_edit' => '3', 'checked' => '1', 'form_tab' => '0'));
$content_id = fx::data('component', 'content')->get('id');
foreach ($new_fields as $field_props) {
$field_props['component_id'] = $content_id;
$field = fx::data('field')->create($field_props);
$field->save();
fx::log('add field', $field);
}
fx::data('component')->dropStoredStaticCache();
fx::db()->query('update {{floxim_main_content}} set is_published = 1, is_branch_published = 1');
fx::cache('meta')->delete('schema');
}
示例15: getFormFieldCondition
public function getFormFieldCondition($field)
{
$jsf = $field->getJsField($this);
$form = $this['form'];
if (!$form) {
$form = fx::data('floxim.form.form')->create();
}
$inputs = $form->getInputs();
$jsf['fields'] = array();
foreach ($inputs as $input) {
$jsf['fields'][] = array('name' => $input['label'], 'type' => 'string', 'id' => $input['id'], 'keyword' => 'field.' . $input['id']);
}
return $jsf;
}