public function getAvailableOffsets() { $c_class = get_called_class(); if (!isset(self::$offset_meta[$c_class])) { $res = array(); $finder = $this->getFinder(); $db_fields = array_keys(fx::schema($finder->getTable())); foreach ($db_fields as $field) { $res[$field] = array('type' => self::OFFSET_FIELD); } foreach ($finder->relations() as $rel_name => $rel) { $res[$rel_name] = array('type' => self::OFFSET_RELATION, 'relation' => $rel); } foreach ($finder->getMultiLangFields() as $f) { $res[$f] = array('type' => self::OFFSET_LANG); } $entity_class = $c_class; $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]); $res[$getter_offset] = array('type' => self::OFFSET_GETTER, 'method' => $method->name); } } self::$offset_meta[$c_class] = fx::collection($res); } return self::$offset_meta[$c_class]; }
public function get($var) { $getter = 'get' . fx::util()->underscoreToCamel($var); if (method_exists($this, $getter)) { return call_user_func(array($this, $getter)); } return isset($this->current[$var]) ? $this->current[$var] : null; }
protected function prepareDisableConfig($cfg) { $linear = fx::util()->arrayLinear($cfg); $res = array(); foreach ($linear as $com) { if (strstr($com, ':')) { list($com, $act) = explode(":", $com); if (!isset($res[$com])) { $res[$com] = array(); } $res[$com][] = $act; } else { $res[] = $com; } } return $res; }
public function handleInfoblock($callback, $infoblock, $params = array()) { $full_config = $this->getConfig(); $action = fx::util()->camelToUnderscore($this->action); if (!isset($full_config['actions'][$action])) { return; } $config = $full_config['actions'][$action]; if (!isset($config[$callback])) { return; } foreach ($config[$callback] as $c_callback) { if (is_callable($c_callback)) { call_user_func($c_callback, $infoblock, $this, $params); } } }
/** * Генерирует уникальный ключ текущего импорта */ protected function generateKey() { $this->key = md5(fx::util()->genUuid()); }
public static function decl($word, $number) { return fx::util()->getDeclensionByNumber($word, $number); }
public function __construct($table = null) { if (!$table) { $class = get_class($this); if ($class[0] == '\\') { $class = substr($class, 1); } /** * vendor.module.component - finder component - \Vendor\Module\Component\[Name]\Finder * component - finder system component - \Floxim\Floxim\Component\[Name]\Finder */ if (preg_match('#^Floxim\\\\Floxim\\\\Component\\\\([\\w]+)\\\\Finder$#i', $class, $match)) { // component $table = fx::util()->camelToUnderscore($match[1]); } elseif (preg_match('#^([\\w]+)\\\\([\\w]+)\\\\([\\w]+)\\\\Finder$#i', $class, $match)) { // vendor_module_component // todo: psr0 need verify $table = strtolower($match[1]) . '_' . strtolower($match[2]) . '_' . strtolower($match[3]); } } $this->table = $table; }
protected function getPutFilename($dir, $name) { $name = fx::util()->strToLatin($name); $name = preg_replace("~[^a-z0-9_\\.-]~i", '_', $name); $name = trim($name, "_"); $name = preg_replace("~_+~", "_", $name); $path = fx::path('@files/' . $dir . '/' . $name); $try = 0; while (fx::path()->exists($path)) { $c_name = preg_replace("~(\\.[^\\.]+)\$~", "_" . $try . "\$1", $name); $try++; $path = fx::path('@files/' . $dir . '/' . $c_name); } return fx::path()->fileName($path); }