Exemplo n.º 1
0
 public function create_object($data)
 {
     try {
         $mc = new \Core\Backend\MemcachedContainer();
         $m = $mc->get_backend();
         $m_enable = True;
     } catch (\Core\Backend\MemcachedNotLoadedError $e) {
     }
     $data = \Core\Dict::create($data);
     if (strlen($data->custom_url) > 0) {
         $data->seo_title = $data->custom_url;
     } else {
         $data->seo_title = strtolower(str_replace(' ', '-', $data->title));
     }
     if (extension_loaded('discount')) {
         $md = \MarkdownDocument::createFromString($data['body']);
         $md->compile();
         $data['body_html'] = $md->getHtml();
     } else {
         import('3rdparty.markdown');
         $data['body_html'] = Markdown($data['body']);
     }
     $data->preview = substr(strip_tags($data['body_html']), 0, 440);
     $a = Article::create($data)->form_values();
     return $a;
 }
Exemplo n.º 2
0
 public function create_object($data)
 {
     $data = \Core\Dict::create($data);
     $assassin = Agent::mapper()->create_object(array('id' => $data->assassin, 'alias' => $data->assassin_agent_alias));
     $target = Agent::mapper()->create_object(array('id' => $data->target, 'alias' => $data->target_agent_alias));
     $weapon = Weapon::mapper()->create_object(array('id' => $data->weapon_id, 'name' => $data->weapon_name));
     return Kill::create(array('id' => $data->id, 'description' => $data->description, 'assassin' => $assassin, 'target' => $target, 'weapon' => $weapon, 'game' => $game, 'when_happened' => new \DateTime($data->when_happened)), True);
 }
Exemplo n.º 3
0
 public function find_by_game(\Trouble\Game $game)
 {
     $this->_players = \Trouble\Player::container()->get(array("joins" => array(new \Core\Join("agent", "Agent", array('id', 'alias', 'avatar'))), "filters" => array(new \Core\Filter("game", $game['id']), new \Core\Filter("status", "-1", ">")), "order" => new \Core\Order("id")));
     $this->_index = \Core\Dict::create();
     $this->_alive_players = \Core\Li::create();
     foreach ($this->_players as $player) {
         if ($player->status > 0) {
             $this->_alive_players->append($player);
         }
     }
     for ($i = 0; $i < count($this->_alive_players); $i++) {
         $this->_index[$this->_alive_players[$i]['id']] = $i;
     }
     $this->_cycle = \Core\Li::create();
     if (count($this->_alive_players) > 0) {
         $this->_get_cycle($this->_alive_players[0]);
     }
     return array($this->_cycle, $this->_players);
 }
Exemplo n.º 4
0
 public function __construct($args = False)
 {
     parent::__construct($args);
     $this->_cls = static::get_class();
     $this->_fcls = static::get_full_class();
 }