/** * Get list of offsets available for the entity belongs to this component * @return array */ public function getAvailableEntityOffsets() { if (is_null($this->entity_offsets)) { $fields = $this->getAllFields(); $offsets = array('id' => array('type' => self::OFFSET_FIELD), 'type' => array('type' => self::OFFSET_FIELD)); foreach ($fields as $f) { $keyword = $f['keyword']; $offsets[$keyword] = array('type' => self::OFFSET_FIELD); if ($f->getTypeKeyword() === 'select') { $vals = array(); foreach ($f['format']['values'] as $val) { $vals[$val['id']] = $val['value']; } $offsets[$keyword . '_name'] = array('type' => self::OFFSET_SELECT, 'values' => $vals, 'real_offset' => $keyword); } } $finder = fx::data($this['keyword']); $relations = $finder->relations(); foreach ($relations as $rel_code => $rel) { $offsets[$rel_code] = array('type' => self::OFFSET_RELATION, 'relation' => $rel); } $entity_class = $finder->getEntityClassName(); $reflection = new \ReflectionClass($entity_class); $methods = $reflection->getMethods(); foreach ($methods as $method) { if ($method::IS_PUBLIC && preg_match("~^_get(.+)\$~", $method->name, $getter_offset)) { $getter_offset = fx::util()->camelToUnderscore($getter_offset[1]); $offsets[$getter_offset] = array('type' => self::OFFSET_GETTER, 'method' => $method->name); } } $this->entity_offsets = fx::collection($offsets); } return $this->entity_offsets; }
public function addSave($input) { $result = array('status' => 'ok'); $keyword = trim($input['keyword']); $name = trim($input['name']); $vendor = trim($input['vendor']); if (empty($keyword)) { $keyword = fx::util()->strToKeyword($name); } //$keyword = $vendor.'.'.fx::util()->underscoreToCamel($keyword,true); $keyword = fx::util()->camelToUnderscore($vendor) . '.' . $keyword; $existing = fx::data('layout')->where('keyword', $keyword)->one(); if ($existing) { return array('status' => 'error', 'text' => sprintf(fx::alang('Layout %s already exists'), $keyword)); } $data = array('name' => $name, 'keyword' => $keyword); $layout = fx::data('layout')->create($data); try { $layout->save(); $layout->scaffold(); fx::trigger('layout_created', array('layout' => $layout)); $result['reload'] = '#admin.layout.all'; } catch (Exception $e) { $result['status'] = 'error'; } return $result; }
public function getPath() { $path = explode(".", $this['keyword']); array_walk($path, function (&$item) { $item = fx::util()->underscoreToCamel($item, true); }); return fx::path()->abs('/theme/' . join('/', $path) . '/'); }
protected function save($input, $info = null) { $result = array('status' => 'ok'); $email = trim($input['f_email']); $name = trim($input['f_name']); if (!$email || !fx::util()->validateEmail($email)) { $result['status'] = 'error'; $result['text'][] = fx::alang('Fill in correct email', 'system'); $result['fields'][] = 'email'; } if (!$name) { $result['status'] = 'error'; $result['text'][] = fx::alang('Fill in name', 'system'); $result['fields'][] = 'name'; } if ($info && (empty($input['password']) || empty($input['password2']))) { unset($input['password']); } if (!$info) { if (!$input['password']) { $result['status'] = 'error'; $result['text'][] = fx::alang('Password can\'t be empty', 'system'); $result['fields'][] = 'password'; } if ($result['status'] != 'error') { $info = fx::data('user')->create(array('checked' => 1, 'created' => date("Y-m-d H:i:s"))); } } foreach ($input as $name => $value) { if (preg_match('~^f_[\\w]+~', $name) === 1) { $data[preg_replace('~^f_~', '', $name)] = $value; } } if (isset($input['password']) && isset($input['password2'])) { if (!$input['password'] || !$input['password2'] || $input['password'] != $input['password2']) { $result['status'] = 'error'; $result['text'][] = fx::alang('Passwords do not match', 'system'); $result['fields'][] = 'password'; $result['fields'][] = 'password2'; } else { $data['password'] = $input['password']; } } try { if ($result['status'] == 'ok') { $info->set($data); $info->save(); } } catch (Exception $e) { $result['status'] = 'error'; $result['text'][] = fx::alang($e->getMessage(), 'system'); $result['fields'][] = 'email'; } $result['reload'] = '#admin.user.all'; return $result; }
public function getEntityClassName($data) { $parts = explode('.', $data['keyword']); list($vendor, $module) = $parts; $class = fx::util()->underscoreToCamel($vendor) . "\\" . fx::util()->underscoreToCamel($module) . "\\Module"; if (class_exists($class)) { return $class; } return parent::getEntityClassName(); }
public function route($url = null, $context = null) { $adm_path = '/' . fx::config('path.admin_dir_name') . '/'; if (trim($url, '/') === trim($adm_path, '/') && $url !== $adm_path) { fx::http()->redirect(fx::config('paht.admin'), 301); } if ($url !== $adm_path) { return null; } $input = fx::input()->makeInput(); $entity = fx::input()->fetchPost('entity'); $action = fx::input()->fetchPost('action'); if (!$entity || !$action) { fx::page()->setBaseUrl(FX_BASE_URL . '/' . trim($adm_path, '/')); return new Controller\Admin(); } $base_url = fx::input()->fetchPost('_base_url'); if ($base_url) { $base_path = fx::router()->getPath(fx::path()->removeBase($base_url)); if ($base_path) { fx::env('page', $base_path->last()); } } fx::env('ajax', true); $posting = fx::input()->fetchPost('posting'); if (!preg_match("~^module_~", $entity) || fx::input()->fetchPost('fx_admin')) { $entity = 'admin_' . $entity; } if ($posting && $posting !== 'false') { $action .= "_save"; } $path = explode('_', $entity, 2); if ($path[0] == 'admin') { $classname = 'Floxim\\Floxim\\Admin\\Controller\\' . fx::util()->underscoreToCamel($path[1]); } else { // todo: psr0 what? } try { $controller = new $classname($input, $action); } catch (\Exception $e) { die("Error! Entity: " . htmlspecialchars($entity)); } //header("Content-type: application/json; charset=utf-8"); return $controller; }
public function getVendorField() { $field = array('name' => 'vendor', 'label' => fx::alang('Vendor', 'system'), 'type' => 'select', 'values' => array()); $vendor = fx::config('dev.vendor'); $vendor = explode(",", $vendor); foreach ($vendor as $num => $part) { $part = trim($part); if (empty($part)) { unset($vendor[$num]); } } $vendor[] = 'my'; foreach ($vendor as $v) { $v = fx::util()->underscoreToCamel($v, true); $field['values'][$v] = $v; } return $field; }
public function doScaffold($name, $overwrite = false) { $name_parts = explode('.', $name); if (count($name_parts) != 2) { $this->usageError('Name need format "vendor.name"'); } $this->module_vendor = fx::util()->underscoreToCamel($name_parts[0]); $this->module_name = fx::util()->underscoreToCamel($name_parts[1]); /** * Check for exists */ $module_path = fx::path('@root') . "module/{$this->module_vendor}/{$this->module_name}/"; if (file_exists($module_path)) { if (!$overwrite) { $this->usageError('Module already exists'); } } else { /** * Create dir */ if (@mkdir($module_path, 0777, true)) { echo "Create dir {$module_path}" . "\n"; } else { $this->usageError('Can\'t create module dir - ' . $module_path); } } $source_path = fx::path('@floxim') . '/Console/protected/module/'; /** * Build file list */ $file_list = $this->buildFileList($source_path, $module_path); foreach ($file_list as $file_name => $file_data) { $file_list[$file_name]['callback_content'] = array($this, 'replacePlaceholder'); } /** * Copy files */ $this->copyFiles($file_list); echo "\nYour module has been created successfully under {$module_path}.\n"; }
protected function beforeSave() { parent::beforeSave(); if ($this->isIndexPage()) { return; } if (!$this->isReal()) { return; } if (empty($this['url']) && !empty($this['name'])) { $url = fx::util()->strToLatin($this['name']); $url = preg_replace("~[^a-z0-9_-]+~i", '-', $url); $url = trim($url, '-'); $url = preg_replace("~\\-+~", '-', $url); $this['url'] = $url; } if (in_array('url', $this->modified) && !empty($this['url']) && !preg_match("~^https?://~", $this['url'])) { $url = $this['url']; if (!preg_match("~^/~", $url)) { $url = '/' . $url; } $index = 1; // check already used page url while ($page = fx::data('floxim.main.page')->getByUrl($url, $this['site_id'])) { if ($page['id'] != $this['id']) { $index++; $url = preg_replace("~\\-" . ($index - 1) . "\$~", '', $url) . '-' . $index; } else { // update the same urlAlias of the same page, see afterUpdate() break; } } //$url = preg_replace("~^/~", '', $url); $this['url'] = $url; } }
public function edit($input) { $entity_code = $this->entity_type; $component = fx::data($entity_code)->getById($input['params'][0]); $action = isset($input['params'][1]) ? $input['params'][1] : 'settings'; self::makeBreadcrumb($component, $action, $this->response->breadcrumb); $action = fx::util()->underscoreToCamel($action, false); if (method_exists($this, $action)) { $result = call_user_func(array($this, $action), $component, $input); } $result['tree']['mode'] = $entity_code . '-' . $component['id']; $this->response->submenu->setMenu($entity_code . '-' . $component['id']); return $result; }
public function getTemplateRecordAtts($collection, $index) { $entity_meta = array($this->get('id'), $this->getType(false)); $linkers = null; if (is_object($collection) && $collection->linkers) { $linkers = $collection->linkers; if (isset($collection->linkers[$index])) { $linker = $linkers[$index]; $entity_meta[] = $linker['id']; $entity_meta[] = $linker['type']; } } $entity_atts = array('data-fx_entity' => $entity_meta, 'class' => 'fx_entity' . (is_object($collection) && $collection->is_sortable ? ' fx_sortable' : '')); if (!$this->isVisible()) { $entity_atts['class'] .= ' fx_entity_hidden' . (!$collection || count($collection) === 1 ? '_single' : ''); } $com = $this->getComponent(); $entity_atts['data-fx_entity_name'] = fx::util()->ucfirst($com->getItemName('one')); $is_placeholder = $this->isAdderPlaceholder(); if ($is_placeholder) { $entity_atts['class'] .= ' fx_entity_adder_placeholder'; } if (isset($this['_meta'])) { $c_meta = $this['_meta']; if ($is_placeholder) { $c_meta['has_page'] = $this->hasPage(); $c_meta['publish'] = $this->getDefaultPublishState(); } $entity_atts['data-fx_entity_meta'] = $c_meta; } // fields to edit in panel $att_fields = array(); $forced = $this->getForcedEditableFields(); if (is_array($forced) && count($forced)) { foreach ($forced as $field_keyword) { $field_meta = $this->getFieldMeta($field_keyword); if (!is_array($field_meta)) { continue; } // !!! hardcode if ($is_placeholder && $field_keyword === 'is_published') { $field_meta['current_value'] = $this->getDefaultPublishState(); } else { $field_meta['current_value'] = $this[$field_keyword]; } $att_fields[] = $field_meta; } } if ($linkers && $linkers->linkedBy) { if (!$linker) { fx::log($collection, $linkers); return $entity_atts; } $linker_field = $linker->getFieldMeta($linkers->linkedBy); $linker_collection_field = $linkers->selectField; if (!$is_placeholder && $linker_collection_field && $linker_collection_field['params']['content_type']) { $linker_type = $linker_collection_field['params']['content_type']; } else { $linker_type = $this['type']; $linker_field['params']['conditions'] = array(array('type', $linker_type)); } $linker_field['params']['content_type'] = $linker_type; $linker_field['label'] = fx::alang('Select') . ' ' . mb_strtolower(fx::component($linker_type)->getItemName('add')); if (!$linker_collection_field || !$linker_collection_field['allow_select_doubles']) { $linker_field['params']['skip_ids'] = array(); foreach ($collection->getValues('id') as $col_id) { if ($col_id !== $this['id']) { $linker_field['params']['skip_ids'][] = $col_id; } } } $linker_field['current_value'] = $linker[$linkers->linkedBy]; $att_fields[] = $linker_field; } if (!$this['id'] && (!$this['parent_id'] || !$this['infoblock_id']) && !$this->hasPage()) { $att_fields = array_merge($this->getStructureFields(), $att_fields); } foreach ($att_fields as $field_key => $field_meta) { $field_meta['in_att'] = true; // real field if (isset($field_meta['id']) && isset($field_meta['content_id'])) { $field_keyword = $field_meta['id'] . '_' . $field_meta['content_id']; } else { $field_keyword = $field_key; $field_meta['id'] = $field_key; } $template_field = new \Floxim\Floxim\Template\Field($field_meta['current_value'], $field_meta); $entity_atts['data-fx_force_edit_' . $field_keyword] = $template_field->__toString(); } return $entity_atts; }
$component = $this->getComponent(); $sort_fields = $component->getAllFields()->find(function ($f) { if ($f instanceof \Floxim\Floxim\Field\Link || $f instanceof \Floxim\Floxim\Field\MultiLink || $f instanceof \Floxim\Floxim\Field\Text || $f instanceof \Floxim\Floxim\Field\Image || in_array($f['keyword'], array('priority', 'is_published', 'is_branch_published', 'type', 'url', 'h1', 'title'))) { return false; } return true; })->getValues(fx::isAdmin() ? 'name' : 'id', 'keyword'); $content_exists = fx::content($component['keyword'])->contentExists(); $is_new_infoblock = !$this->getParam('infoblock_id'); $component_infoblocks = fx::data('infoblock')->getContentInfoblocks($component['keyword']); fx::cdebug(debug_backtrace()); return array('actions' => array('*list*' => array('settings' => array('limit' => array('label' => fx::alang('Count entries', 'controller_component'), 'class_name' => 'fx_field_limit'), 'pagination' => array('label' => fx::alang('Paginate?', 'controller_component'), 'type' => 'hidden', 'parent' => array('limit' => '!=')), 'sorting' => array('name' => 'sorting', 'label' => fx::alang('Sorting', 'controller_component'), 'type' => 'select', 'values' => $sort_fields), 'sorting_dir' => array('name' => 'sorting_dir', 'label' => fx::alang('Order', 'controller_component'), 'type' => 'select', 'values' => array('asc' => fx::alang('Ascending', 'controller_component'), 'desc' => fx::alang('Descending', 'controller_component')), 'parent' => array('sorting' => '!=manual')))), '*list' => array('disabled' => true), '*list_infoblock' => array('name' => fx::util()->ucfirst($component->getItemName('list')), 'install' => function ($ib, $ctr, $params) { $ctr->bindLostContent($ib, $params); }, 'default_scope' => function () { $ds = fx::env('page_id') . '-this-'; return $ds; }, 'settings' => array('sorting' => array('values' => array(array('manual', fx::alang('Manual', 'controller_component'))) + $sort_fields)) + $this->getParentConfigFields() + $this->getTargetConfigFields() + $this->getLostContentField(), 'defaults' => array('!pagination' => true)), '*list_filtered' => array('name' => fx::util()->ucfirst(fx::alang('%s by filter', 'controller_component', $component->getItemName('list'))), 'settings' => array('conditions' => function ($ctr) { return $ctr->getConditionsField(); }, 'sorting' => array('values' => array(array('manual', fx::alang('Manual', 'controller_component'))) + $sort_fields)), 'defaults' => array('limit' => 10)), '*list_selected' => array('name' => fx::util()->ucfirst(fx::alang('%s selected', 'controller_component', $component->getItemName('list'))), 'settings' => array('selected' => function ($ctr) { return $ctr->getSelectedField(); }, 'allow_select_doubles' => array('type' => 'checkbox', 'label' => fx::alang('Allow doubles', 'controller_component')), 'is_pass_through' => array('label' => fx::alang('Pass-through data', 'controller_component'), 'type' => 'checkbox', 'parent' => array('scope[complex_scope]' => '!~this')), 'sorting' => array('values' => array(array('manual', fx::alang('Manual', 'controller_component'))) + $sort_fields)), 'defaults' => array('!pagination' => false, '!limit' => 0, '!allow_select_doubles' => true, 'is_pass_through' => 'false'), 'save' => function ($ib, $ctr, $params) { // update linkers $ctr->saveSelectedLinkers($params['params']['selected']); }, 'delete' => function ($ib, $ctr, $params) { // drop linkers $ctr->dropSelectedLinkers(); }), '*list_filtered*, *list_selected*, *listing_by*' => array('check_context' => function () use($content_exists) { return $content_exists; }), '*listing_by' => array('disabled' => 1), '*form_create' => array('check_context' => function () use($component_infoblocks) { return count($component_infoblocks) > 0; }, 'settings' => array('target_infoblock' => array('type' => 'select', 'label' => fx::alang('Target infoblock', 'controller_component'), 'values' => $component_infoblocks->getSelectValues('id', 'name'), 'hidden_on_one_value' => true), 'redirect_to' => array('type' => 'select', 'label' => fx::alang('After submission...', 'controller_component'), 'values' => array(array('refresh', fx::alang('Refresh page')), array('new_page', fx::alang('Go to the created page')), array('parent_page', fx::alang('Go to the parent page'))))))));
public function deleteInfoblock($input) { $infoblock = fx::data('infoblock', $input['id']); if (!$infoblock) { return; } $controller = $infoblock->initController(); $fields = array(array('name' => 'delete_confirm', 'type' => 'hidden'), $this->ui->hidden('id', $input['id']), $this->ui->hidden('entity', 'infoblock'), $this->ui->hidden('action', 'delete_infoblock'), $this->ui->hidden('fx_admin', true)); $ib_content = $infoblock->getOwnedContent(); if ($ib_content->length > 0) { $fields[] = array('name' => 'content_handle', 'type' => 'hidden', 'value' => 'delete'); } $alert = ''; if (count($ib_content)) { $ib_content_count = count($ib_content); $ib_content_types = $ib_content->getValues('type'); $ib_content_type_count = array(); foreach ($ib_content_types as $ib_content_type) { if (!isset($ib_content_type_count[$ib_content_type])) { $ib_content_type_count[$ib_content_type] = 0; } $ib_content_type_count[$ib_content_type]++; } // block contains linkers only if (count($ib_content_type_count) === 1 && $ib_content_types[0] === 'floxim.main.linker') { $link_word = fx::util()->getDeclensionByNumber(array('ссылку', 'ссылки', 'ссылок'), $ib_content_count); $alert = '<p>Блок содержит ' . $ib_content_count . ' ' . $link_word . ' на другие данные. '; $alert .= $ib_content_count == 1 ? 'Эта ссылка будет удалена' : 'Эти ссылки будут удалены'; $alert .= ', а сами данные останутся.</p>'; } else { // $ib_content_ids = $ib_content->getValues('id'); $alert = '<p>Блок содержит '; if (count($ib_content_type_count) === 1) { $com = fx::component($ib_content_types[0]); $decl = $com['declension']; $alert .= $ib_content_count . ' '; $alert .= fx::util()->getDeclensionByNumber(array($decl['acc']['singular'], $decl['gen']['singular'], $decl['gen']['plural']), $ib_content_count); $alert .= '</p>'; } else { $alert .= ' данные:</p>'; $type_parts = array(); foreach ($ib_content_type_count as $ib_content_type => $c_type_count) { $com = fx::component($ib_content_type); $type_parts[] = $c_type_count . ' ' . fx::util()->getDeclensionByNumber($com['declension'], $c_type_count); } $alert .= '<ul><li>' . join('</li><li>', $type_parts) . '</li></ul>'; } $alert .= '<p>Эти данные будут удалены.</p>'; $ids = $ib_content->getValues('id'); $nested_query = fx::data('content')->descendantsOf($ids, false)->group('type')->select('type')->select('count(*) as cnt')->showQuery(); $nested_types = fx::db()->getResults($nested_query); if (count($nested_types) > 0) { $type_parts = array(); foreach ($nested_types as $c_nested_type) { if ($c_nested_type['type'] === 'floxim.main.linker') { continue; } $com = fx::component($c_nested_type['type']); $type_parts[] = $c_nested_type['cnt'] . ' ' . fx::util()->getDeclensionByNumber($com['declension'], $c_nested_type['cnt']); } if (count($type_parts) > 0) { $alert .= '<p>Также будут удалены все вложенные данные:</p>'; $alert .= '<ul><li>' . join('</li><li>', $type_parts) . '</li></ul>'; } } } } $fields[] = array('name' => 'content_alert', 'type' => 'html', 'value' => '<div class="fx_delete_alert">' . $alert . '</div>'); if ($infoblock['controller'] == 'layout' && !$infoblock['parent_infoblock_id']) { unset($fields[0]); $fields[] = array('type' => 'html', 'html' => fx::alang('Layouts can not be deleted', 'system')); } $this->response->addFields($fields); $this->response->addFormButton(array('key' => 'save', 'label' => fx::alang('Delete'), 'class' => 'delete')); if ($input['delete_confirm']) { $this->response->setStatusOk(); if ($ib_content) { if ($input['content_handle'] == 'delete') { foreach ($ib_content as $ci) { $ci->delete(); } } else { foreach ($ib_content as $ci) { $ci->set('infoblock_id', 0)->save(); } } } $controller->handleInfoblock('delete', $infoblock, $input); $infoblock->delete(); } if ($infoblock['name']) { $header = fx::alang('Delete infoblock', 'system'); $header .= ' «' . $infoblock['name'] . '»'; } else { $header = fx::alang('Delete this infoblock', 'system'); } $header .= '?'; $header = '<span title="' . $infoblock['controller'] . ':' . $infoblock['action'] . '">' . $header . "</span>"; return array('header' => $header); }
protected function getTokenCode($token, $parent) { $method_name = 'token' . fx::util()->underscoreToCamel($token->name) . 'ToCode'; if (method_exists($this, $method_name)) { return call_user_func(array($this, $method_name), $token, $parent); } return ''; }
public function countParentId() { if (preg_match("~^listInfoblock~", fx::util()->underscoreToCamel($this->action, false)) && !$this->getParam('is_pass_through')) { $this->setParam('parent_id', $this->getParentId()); } }
public function deleteSave($input) { if (!isset($input['content_type'])) { return; } $content_type = $input['content_type']; $id = isset($input['content_id']) ? $input['content_id'] : (isset($input['id']) ? $input['id'] : false); if (!$id) { return; } $content = fx::data($content_type, $id); if (!$content) { return; } $fields = array(array('name' => 'delete_confirm', 'type' => 'hidden', 'value' => 1), $this->ui->hidden('entity', 'content'), $this->ui->hidden('action', 'delete_save'), $this->ui->hidden('content_id', $content['id']), $this->ui->hidden('fx_admin', true)); if (isset($input['content_type'])) { $fields[] = $this->ui->hidden('content_type', $input['content_type']); } if (isset($input['page_id'])) { $fields[] = $this->ui->hidden('page_id', $input['page_id']); } /** * check children */ $alert = ''; $is_linker = $content->isInstanceOf('floxim.main.linker'); if ($is_linker) { $linked_entity = $content['content']; $linked_com = $linked_entity->getComponent(); $alert = '<p>' . fx::alang('Only link will be removed, not %s itself', null, $linked_com->getItemName('one')); $linked_section = $linked_entity->getPath()->copy()->reverse()->findOne(function ($i) use($linked_entity) { return $i->isInstanceOf('floxim.nav.section') && $i['id'] !== $linked_entity['id']; }); if ($linked_section) { $alert .= fx::alang(', it will be available in the %s section', null, $linked_section['name']); } $alert .= '</p>'; //fx::log($linked_entity->getPath()); } elseif ($content->isInstanceOf('floxim.main.content')) { $all_descendants = fx::data('content')->descendantsOf($content)->all()->group('type'); $type_parts = array(); foreach ($all_descendants as $descendants_type => $descendants) { if ($descendants_type === 'floxim.main.linker') { continue; } $descendants_com = fx::component($descendants_type); $type_parts[] = count($descendants) . ' ' . fx::util()->getDeclensionByNumber($descendants_com['declension'], count($descendants)); } if (count($type_parts) > 0) { $com_name = fx::util()->ucfirst($content->getComponent()->getItemName('one')); $alert = '<p>' . $com_name . ' содержит данные, они также будут удалены:</p>'; $alert .= '<ul><li>' . join('</li><li>', $type_parts) . '</li></ul>'; } } if ($alert) { $fields[] = array('type' => 'html', 'html' => '<div class="fx_delete_alert">' . $alert . '</div>'); } $this->response->addFields($fields); $this->response->addFormButton(array('key' => 'save', 'class' => 'delete', 'label' => fx::alang('Delete'))); if (isset($input['delete_confirm']) && $input['delete_confirm']) { $response = array('status' => 'ok'); $c_page = fx::env('page'); if ($c_page) { $c_path = $c_page->getPath(); $content_in_path = $c_path->findOne('id', $content['id']); if ($content_in_path) { $response['reload'] = $content_in_path['parent'] ? $content_in_path['parent']['url'] : '/'; } } $content->delete(); return $response; } $component = fx::data('component', $content_type); if ($is_linker) { $com_name = $linked_com->getItemName('add'); } else { $com_name = $component->getItemName('add'); } $header = $is_linker ? fx::alang('delete_from_list') : fx::alang("Delete"); $header .= ' ' . mb_strtolower($com_name); if ($content_name = $content['name']) { $content_name = strip_tags($content_name); $content_name = trim($content_name); $header .= ' «' . $content_name . '»'; } elseif ($is_linker) { $header .= ' ' . fx::alang('from this list'); } $header .= "?"; $res = array('header' => $header); return $res; }
public function can($action, $target) { $method = 'can' . fx::util()->underscoreToCamel($action); if (method_exists($this, $method)) { $res = $this->{$method}($target); if (is_bool($res)) { return $res; } } if ($this->isAdmin()) { return true; } $event_res = fx::trigger('checkAbility', array('user' => $this, 'action' => $action, 'target' => $target)); return $event_res; }
protected function getDefaultData() { $data = array('cols' => array(array('id' => fx::util()->uid(), 'name' => 'A', 'width' => 6), array('id' => fx::util()->uid(), 'name' => 'B', 'width' => 6))); return $data; }
public function __call($name, $args) { if (preg_match("~^on[A-Z]~", $name) && count($args) == 1) { $event_name = preg_replace("~^on~", '', $name); $event_name = fx::util()->camelToUnderscore($event_name); $this->on($event_name, $args[0]); return $this; } }