本文整理汇总了PHP中Floxim\Floxim\System\Fx类的典型用法代码示例。如果您正苦于以下问题:PHP Fx类的具体用法?PHP Fx怎么用?PHP Fx使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Fx类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run($args = null)
{
if (!$args) {
$args = isset($_SERVER['argv']) ? $_SERVER['argv'] : array(__FILE__);
} elseif (is_scalar($args)) {
$arg_string = $args;
$args = array(\Floxim\Floxim\System\Fx::path()->fileName(__FILE__));
foreach (self::parseArgs($arg_string) as $arg) {
$args[] = $arg;
}
}
$this->scriptName = $args[0];
array_shift($args);
// Define command
if (isset($args[0])) {
$name = $args[0];
array_shift($args);
} else {
$name = 'help';
}
// Create command
if (!($command = $this->createCommand($name))) {
$command = $this->createCommand('help');
}
return $command->run($args);
}
示例2: generate
public function generate($params = array())
{
$form = $this->create($params);
$form->is_generated = true;
$form['fields'] = fx::collection();
return $form;
}
示例3: getSavestring
public function getSavestring(System\Entity $content = null)
{
$old_value = $content[$this['keyword']];
$old_path = FX_BASE_URL . $old_value;
if ($old_path === $this->value) {
return $this->value;
}
$res = '';
if (!empty($this->value)) {
$c_val = fx::path()->abs($this->value);
if (file_exists($c_val) && is_file($c_val)) {
$file_name = fx::path()->fileName($c_val);
$path = fx::path('@content_files/' . $content['site_id'] . '/' . $content['type'] . '/' . $this['keyword'] . '/' . $file_name);
$path = fx::files()->getPutFilePath($path);
fx::files()->move($c_val, $path);
$res = fx::path()->removeBase(fx::path()->http($path));
}
}
if (!empty($old_value)) {
$old_value = fx::path()->abs($old_value);
if (file_exists($old_value) && is_file($old_value)) {
fx::files()->rm($old_value);
}
}
return $res;
}
示例4: route
public function route($url = null, $context = null)
{
$thumbs_path = fx::path()->http('@thumbs');
$thumbs_path_trimmed = fx::path()->removeBase($thumbs_path);
if (substr($url, 0, strlen($thumbs_path_trimmed)) !== $thumbs_path_trimmed) {
return null;
}
$dir = substr($url, strlen($thumbs_path_trimmed));
preg_match("~/([^/]+)(/.+\$)~", $dir, $parts);
$config = $parts[1];
$source_path = $parts[2];
$source_abs = fx::path($source_path);
if (!file_exists($source_abs)) {
return null;
}
$target_dir = dirname(fx::path('@home/' . $url));
if (!file_exists($target_dir) || !is_dir($target_dir)) {
return null;
}
$config = $config . '.async-false.output-true';
$config = \Floxim\Floxim\System\Thumb::readConfigFromPathString($config);
fx::image($source_path, $config);
fx::complete();
die;
}
示例5: checkUpdates
public function checkUpdates()
{
$stored = $this->all();
$url = fx::config('fx.update_url') . '?action=find&from=' . fx::version();
@($res = file_get_contents($url));
if (!$res) {
return false;
}
$res = @json_decode($res);
if ($res) {
foreach ($res as $patch) {
if ($stored->findOne('to', $patch->to)) {
continue;
}
$new_patch = $this->create(array('to' => $patch->to, 'from' => $patch->from, 'url' => $patch->url, 'created' => $patch->created));
if ($patch->from == fx::version()) {
$new_patch['status'] = 'ready';
} else {
$new_patch['status'] = 'pending';
}
$new_patch->save();
}
}
return true;
}
示例6: formatSettings
public function formatSettings()
{
$fields = array();
$fields[] = array('id' => 'format[source]', 'name' => 'format[source]', 'type' => 'hidden', 'value' => 'manual');
$fields[] = array('name' => 'format[values]', 'label' => fx::alang('Elements', 'system'), 'type' => 'set', 'tpl' => array(array('name' => 'id', 'type' => 'string'), array('name' => 'value', 'type' => 'string')), 'values' => $this['format']['values'] ? $this['format']['values'] : array(), 'labels' => array('id', 'value'));
return $fields;
}
示例7: getSavestring
public function getSavestring(System\Entity $content = null)
{
$old_value = $content[$this['keyword']];
if ($old_value != $this->value) {
if (!empty($old_value)) {
$old_value = fx::path()->abs($old_value);
if (file_exists($old_value) && is_file($old_value)) {
fx::files()->rm($old_value);
}
}
if (!empty($this->value)) {
$c_val = fx::path()->abs($this->value);
if (file_exists($c_val) && is_file($c_val)) {
preg_match("~[^" . preg_quote(DIRECTORY_SEPARATOR) . ']+$~', $c_val, $fn);
$path = fx::path()->http('@content_files/' . $content['site_id'] . '/' . $content['type'] . '/' . $this['keyword'] . '/' . $fn[0]);
$try = 0;
while (fx::path()->exists($path)) {
$file_name = preg_replace("~(\\.[^\\.]+)\$~", "_" . $try . "\$1", $fn[0]);
$try++;
$path = fx::path()->http('@content_files/' . $content['type'] . '/' . $this['keyword'] . '/' . $file_name);
}
fx::files()->move($c_val, $path);
}
}
}
$res = isset($path) ? $path : $this->value;
return $res;
}
示例8: __construct
public function __construct($context, $box_id, $loop = null)
{
if (fx::isAdmin()) {
self::addAdminAssets();
$this->avail = $this->getAvailFields($context);
}
$this->box_id = $box_id;
$param_id = $this->getParamId();
$data = $context->get($param_id);
if (is_string($data) && !empty($data)) {
$data = json_decode($data, true);
}
//fx::log($this, $data);
if (!$data || !isset($data['is_stored'])) {
$groups = $context->get('groups');
$default_data = $this->prepareGroups($groups);
$data = $data ? \Floxim\Floxim\System\Util::fullMerge($data, $default_data) : $default_data;
}
$this->data = $data;
//fx::log('set data', $this->data);
if ($loop) {
$this->containing_loop = $loop;
$box = $this;
$loop->onStop(function () use($box) {
$box->export();
});
}
}
示例9: getProfiler
protected function getProfiler()
{
$profile = fx::config('dev.profile_controllers');
if ($profile) {
return fx::profiler();
}
}
示例10: 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);
}
示例11: deleteInfoblocks
protected function deleteInfoblocks()
{
$infoblocks = fx::data('infoblock')->where('site_id', $this['id'])->all();
foreach ($infoblocks as $infoblock) {
$infoblock->delete();
}
}
示例12: 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;
}
示例13: checkValueIsFile
public static function checkValueIsFile($v)
{
if (empty($v)) {
return false;
}
$files_path = fx::path('@files');
$path = fx::path();
return $path->isInside($v, $files_path) && $path->isFile($v);
}
示例14: getDateFormats
public function getDateFormats()
{
$formats = array('j %month:gen% Y', '%Month% Y', 'd.m.Y', 'd/m/Y', 'H:i');
$res = array();
foreach ($formats as $f) {
$res[$f] = fx::date(time(), $f);
}
return $res;
}
示例15: getBlocks
public function getBlocks()
{
$area_id = $this->getAreaId();
$blocks = fx::page()->getAreaInfoblocks($area_id);
if (count($blocks) === 0) {
return null;
}
return $blocks;
}