示例#1
0
文件: SQL.php 项目: techart/tao
 public function run()
 {
     $binds = count($args = func_get_args()) > 1 ? $args : $args[0];
     $run_callbacks = $binds instanceof DB_SQL_Entity && $this->view && $binds instanceof $this->view->prototype;
     $sql = 'DELETE FROM ' . ($this->table ? $this->table : $this->view->table->name) . "\n";
     if (count($where = Core_Arrays::merge($this->view ? $this->view->__get('where') : array(), $this->where))) {
         $sql .= 'WHERE (' . Core_Arrays::join_with(') AND (', $where) . ')';
     }
     if ($run_callbacks ? $binds->before_delete() : true) {
         $rc = DB_SQL::db()->connection->prepare($sql)->bind($binds)->execute();
     }
     if ($run_callbacks && $rc) {
         $binds->after_delete();
     }
     return $rc;
 }
示例#2
0
文件: Assets.php 项目: techart/tao
 /**
  * @param string $url
  * @param array  $attributes
  *
  * @return string
  */
 public function image_tag($t, $url, array $attributes = array())
 {
     return $t->tags->tag('img', Core_Arrays::merge($attributes, array('src' => $this->image_path_for($url))));
 }
示例#3
0
文件: ORM.php 项目: techart/tao
 /**
  * Возвращет массив установленных опций с учетом радительских опций
  * 
  * @return array
  */
 public function all_options()
 {
     $item = $this;
     $result = array();
     do {
         foreach ($item->options as $key => $value) {
             if (is_array($value)) {
                 $result[$key] = Core_Arrays::merge((array) $result[$key], $value);
             } else {
                 $result[$key] = $value;
             }
         }
     } while ($item = $item->parent);
     return $result;
 }
示例#4
0
文件: Core.php 项目: techart/tao
 /**
  * Выполняет инициализацию модуля.
  *
  * @param array $config
  */
 public static function initialize(array $config = array())
 {
     self::$base_dir = getcwd();
     self::$start_time = microtime(true);
     $loader_opts = self::parse_environment_paths();
     if (isset($config['loader'])) {
         $loader_opts = Core_Arrays::merge($loader_opts, $config['loader']);
     }
     self::$loader = new Core_ModuleLoader();
     self::$loader->paths($loader_opts);
     self::options($config);
     Core::load('Config');
     if (is_array(Config::modules())) {
         self::configure(Config::modules());
     }
     self::init_autoload();
     self::init_module_cache();
     self::init_deprecated();
 }
示例#5
0
文件: Forms.php 项目: techart/tao
 /**
  * @param Templates_HTML_Template $t
  * @param int $from
  * @param int $to
  * @param stirng $name
  * @param string $type
  * @param Time_DateTime $value
  * @param array $attributes
  * @param string $tag
  */
 private function datetime_tag($t, $from, $to, $name, $type, Time_DateTime $value, $attributes, $tag = 'select')
 {
     $res = $t->tag($tag, Core_Arrays::merge(array('name' => $this->field_name_for($name) . "[{$type}]", 'id' => $this->field_id_for($name) . "_{$type}"), isset($attributes[$type]) ? Core_Arrays::merge($attributes, (array) $attributes[$type]) : $attributes), false);
     if ($from !== null && $to !== null) {
         for ($i = $from; $i <= $to; $i++) {
             $res .= $t->content_tag('option', sprintf('%02d', $i), array('value' => $i, 'selected' => $value ? $value->{$type} == $i : false));
         }
     }
     $res .= "</{$tag}>";
     return $res;
 }
示例#6
0
 public function test_merge()
 {
     $this->assertEquals(Core_Arrays::merge(array("color" => "red", 2, 4), array("a", "b", "color" => "green", "shape" => "trapezoid", 4)), array("color" => "green", 0 => 2, 1 => 4, 2 => "a", "b", "shape" => "trapezoid", 4 => 4));
 }
示例#7
0
文件: HTTP.php 项目: techart/tao
 /**
  * Возвращает значение свойства
  *
  * @param string $property
  *
  * @return mixed
  */
 public function __get($property)
 {
     switch ($property) {
         case 'scheme':
         case 'host':
         case 'path':
         case 'port':
         case 'user':
         case 'pass':
             return $this->uri[$property];
         case 'query':
             return $this->urlencode($this->query);
         case 'headers':
         case 'session':
         case 'meta':
         case 'body':
             return $this->{$property};
         case 'content':
             return $this->{$property} ? $this->{$property} : ($this->{$property} = @file_get_contents('php://input'));
         case 'parameters':
             return Core_Arrays::merge($this->query, $this->parameters);
         case 'post_data':
             return $this->urlencode($this->parameters);
         case 'url':
             return $this->compose_url();
         case 'uri':
             return $this->compose_uri();
         case 'urn':
             return $this->compose_urn();
         case 'method_name':
         case 'method':
             return Net_HTTP::method_name_for($this->method);
         case 'method_code':
             return $this->method;
         case 'id':
             if ($this->id) {
                 return $this->id;
             }
             Core::load('Text.Process');
             $id = Text_Process::process($this->path, 'translit');
             $id = trim(preg_replace('{[^a-zA-Z0-9]+}ui', '_', $id), '_');
             return $this->id = $id;
         default:
             return parent::__get($property);
     }
 }
示例#8
0
文件: HTTP.php 项目: techart/tao
 /**
  * @param array $options
  */
 public static function default_curl_options(array $options)
 {
     Core_Arrays::merge(self::$options['curl_options'], $options);
 }
示例#9
0
文件: Forms2.php 项目: techart/tao
 public function submit_image($t, $src, array $attributes = array())
 {
     return $t->tags->tag('input', Core_Arrays::merge(array('type' => 'image', 'src' => Templates_HTML::helper('assets')->image_path_for($src), 'id' => "{$this->form->name}_form_submit"), $attributes)) . "\n";
 }
示例#10
0
 /**
  * @param string $method
  * @param array  $args
  *
  * @return mixed
  */
 public function __call($method, $args)
 {
     if (Core_Strings::ends_with($method, '_url')) {
         $redirect = false;
         // TODO: Ugly hack, needs refactoring
         if (Core_Strings::starts_with($method, 'redirect_to_')) {
             $redirect = true;
             $method = Core_Strings::substr($method, 12);
         }
         $parms = array();
         foreach ($this->completion_parms as $name) {
             if (isset($this->request[$name])) {
                 $parms[$name] = $this->request[$name];
             }
         }
         if (count($args) && is_array($args[count($args) - 1])) {
             if (count($parms)) {
                 $args[count($args) - 1] = Core_Arrays::merge($parms, $args[count($args) - 1]);
             }
         } else {
             if (count($parms)) {
                 $args[] = $parms;
             }
         }
         $url = method_exists($this->urls, $method) ? Core_Types::reflection_for($this->urls)->getMethod($method)->invokeArgs($this->urls, $args) : $this->urls->__call($method, $args);
         return $redirect ? $this->redirect_to($url) : $url;
     } else {
         throw new Core_MissingMethodException($method);
     }
 }
示例#11
0
文件: Table.php 项目: techart/tao
 protected function list_fields()
 {
     $fields = $this->schema_fields();
     if ($fields) {
         $fields = $this->search_fields($fields, array(), 'in_list', 'weight_in_list', 'caption_in_list');
         return Core_Arrays::merge($this->list_fields, $fields);
     } else {
         return $this->list_fields;
     }
 }