Example #1
0
 public function __construct(\Weapon $weapon, \Armor $armor, array $rings = [], $hp = 100)
 {
     $this->hp = $hp;
     $this->damage = $weapon->getDamage();
     $this->cost += $weapon->getCost();
     $this->armor = $armor->getArmor();
     $this->cost += $armor->getCost();
     foreach ($rings as $ring) {
         $this->damage += $ring->getDamage();
         $this->armor += $ring->getArmor();
         $this->cost += $ring->getCost();
     }
 }
Example #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);
 }
Example #3
0
 public function __construct()
 {
     $value = array();
     $value['range'] = ['short' => 30, 'mid' => 60, 'long' => 90];
     $value['radius'] = self::RADIUS;
     $value['name'] = self::NAME;
     parent::__construct($value);
 }
Example #4
0
 public function __construct()
 {
     $this->_name = "Heavy Machine Gun";
     $this->_charge = 0;
     $this->_shootType = 'standard';
     $this->_shootAera = array('near' => 3, 'middle' => 7, 'far' => 10);
     parent::__construct();
 }
Example #5
0
 public function __construct()
 {
     $this->name = "Spear";
     $this->initCharge = 0;
     $this->shortRange = 30;
     $this->midRange = 60;
     $this->longRange = 90;
     parent::__construct();
 }
 public function __construct($hasEdge)
 {
     parent::__construct($damageAmount, $hasEdge);
     $this->hasEdge = $hasEdge;
     // if ($this->hasEdge = true) {
     //     $this->damageAmount = $damageAmount + 2;
     // } else {
     //     $this->damageAmount = $damageAmount +1;
     // }
 }
Example #7
0
 public function shoot(Ship $target, Weapon $weapon)
 {
     if ($weapon->getCharges() > 1) {
         $dice = rand(1, 6);
         $range = $this->check_range($target, $weapon);
         if ($range == 1 && $dice >= 4) {
             $target->receive_dmg();
         } else {
             if ($range == 2 && $dice >= 5) {
                 $target->receive_dmg();
             } else {
                 if ($range == 3 && $dice >= 6) {
                     $target->receive_dmg();
                 }
             }
         }
         $weapon->subCharge();
     }
 }
Example #8
0
 protected function check_range(Ship $target, Weapon $weapon)
 {
     $x = $target->getPos()['x'] - $this->getPos()['x'];
     $y = $target->getPos()['y'] - $this->getPos()['y'];
     $distance = sqrt(pow($x, 2) + pow($y, 2));
     if ($distance != 0) {
         if ($distance < $weapon->getRange()['short']) {
             return 1;
         } else {
             if ($distance < $weapon->getRange()['mid']) {
                 return 2;
             } else {
                 if ($distance < $weapon->getRange()['long']) {
                     return 3;
                 } else {
                     return 0;
                 }
             }
         }
     }
 }
 function getAll()
 {
     $db = DB::GetConn();
     $getQuery = "SELECT * FROM `Weapon`;";
     $res = $db->query($getQuery);
     //execute query
     $returnWeapons = array();
     while ($obj = $res->fetchObject()) {
         array_push($returnWeapons, Weapon::loadWeaponFromObject($obj));
     }
     return $returnWeapons;
 }
Example #10
0
 function loadSaleFromObject($obj)
 {
     $returnSale = new Sale();
     $returnSale->ID = $obj->ID;
     $returnSale->SellerID = $obj->SellerID;
     $returnSale->ItemType = $obj->ItemType;
     $returnSale->ItemID = $obj->ItemID;
     $returnSale->Price = $obj->Price;
     $returnSale->Created = new DateTime($obj->Created);
     //load the actual object for sale
     if ($returnSale->ItemType == "Weapon") {
         $returnSale->Item = Weapon::loadWeapon($returnSale->ItemID);
     }
     return $returnSale;
 }
<?php

if (Weapon::exist('article_footer')) {
    ?>
<div><?php 
    Weapon::fire('article_footer', array($article));
    ?>
</div>
<?php 
}
Example #12
0
?>
  <?php 
Shield::chunk('comment.form.message');
?>
  <?php 
Weapon::fire('comment_form_textarea_after', $hooks);
?>
  <?php 
Shield::chunk('comment.form.math');
?>
  <div class="grid-group">
    <span class="grid span-1"></span>
    <div class="grid span-5">
      <p>
        <?php 
Weapon::fire('comment_form_button_before', $hooks);
?>
        <?php 
echo Form::button($speak->publish, null, 'submit', null, array('class' => array('btn', 'btn-construct')));
?>
        <?php 
Weapon::fire('comment_form_button_after', $hooks);
?>
      </p>
      <p><?php 
echo $speak->comment_wizard;
?>
</p>
    </div>
  </div>
</form>
 public function Get_Item_Information($itemtypeid)
 {
     $itemtypeid = urldecode($itemtypeid);
     if (!is_numeric($itemtypeid)) {
         return Response::json(array('status' => 'error', 'error' => 'This is not a proper ItemTypeID.'));
     }
     if (strlen($itemtypeid) > 8) {
         return Response::json(array('status' => 'error', 'error' => 'This is not a proper ItemTypeID.'));
     }
     //check the cache
     if (Cache::has($this->class_name . "_" . $itemtypeid)) {
         //pull from cache
         $itemtypeid_info = Cache::get($this->class_name . "_" . $itemtypeid);
         return json_encode($itemtypeid_info);
     }
     $basic_info = hWebIcon::where(function ($query) use($itemtypeid) {
         $query->where('itemTypeId', '=', $itemtypeid);
         $query->where('version', '=', $this->version);
     })->first(array('asset_path', 'abilitymodule_id', 'backpack_id', 'basic_id', 'blueprint_id', 'chassis_id', 'consumable_id', 'craftingcomponent_id', 'craftingstation_id', 'craftingsubcomponent_id', 'framemodule_id', 'palettemodule_id', 'powerup_id', 'resourceitem_id', 'scopemodule_id', 'weapon_id', 'weaponmodule_id'));
     if (empty($basic_info)) {
         return Response::json(array('status' => 'error', 'error' => 'ItemTypeID not found in db.'));
     }
     //break up the types
     $detailed_info = array();
     $constraint_info = array();
     $weapon_info = array();
     if ($basic_info['abilitymodule_id'] != "") {
         $detailed_info = AbilityModule::where('id', '=', $basic_info['abilitymodule_id'])->first(array('type', 'abilityId', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'powerLevel', 'rarity', 'durability'));
         $constraint_info = hConstraint::where(function ($query) use($itemtypeid) {
             $query->where('itemTypeId', '=', $itemtypeid);
             $query->where('version', '=', $this->version);
         })->first(array('cpu', 'mass', 'power'));
     }
     if ($basic_info['basic_id'] != "") {
         $detailed_info = Basic::where('id', '=', $basic_info['basic_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity'));
     }
     if ($basic_info['blueprint_id'] != "") {
         //Note -> blueprint_id = recipe_id
     }
     if ($basic_info['chassis_id'] != "") {
         //Note -> links to hattributes
         $detailed_info = Chassis::where('id', '=', $basic_info['chassis_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity', 'progression_item_id', 'progression_resource_id'));
         $chassis_info = hAttributes::where(function ($query) use($itemtypeid) {
             $query->where('itemTypeId', '=', $itemtypeid);
             $query->where('version', '=', $this->version);
         })->get(array('description', 'display_name', 'value', 'stat_id'));
     }
     if ($basic_info['consumable_id'] != "") {
         $detailed_info = Consumable::where('id', '=', $basic_info['consumable_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'powerLevel', 'name', 'rarity'));
     }
     if ($basic_info['craftingcomponent_id'] != "") {
         $detailed_info = CraftingComponent::where('id', '=', $basic_info['craftingcomponent_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity'));
     }
     if ($basic_info['craftingsubcomponent_id'] != "") {
         $detailed_info = CraftingSubcomponent::where('id', '=', $basic_info['craftingsubcomponent_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity'));
     }
     if ($basic_info['framemodule_id'] != "") {
         $detailed_info = FrameModule::where('id', '=', $basic_info['framemodule_id'])->first(array('type', 'abilityId', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'powerLevel', 'rarity', 'durability'));
         $constraint_info = hConstraint::where(function ($query) use($itemtypeid) {
             $query->where('itemTypeId', '=', $itemtypeid);
             $query->where('version', '=', $this->version);
         })->first(array('cpu', 'mass', 'power'));
     }
     if ($basic_info['palletmodule_id'] != "") {
         $detailed_info = PaletteModule::where('id', '=', $basic_info['palettemodule_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity'));
     }
     if ($basic_info['powerup_id'] != "") {
         $detailed_info = Powerup::where('id', '=', $basic_info['powerup_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity'));
     }
     if ($basic_info['resourceitem_id'] != "") {
         $detailed_info = ResourceItem::where('id', '=', $basic_info['resourceitem_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity', 'resource_color'));
     }
     if ($basic_info['weapon_id'] != "") {
         //weapons have hstats also!
         $detailed_info = Weapon::where('id', '=', $basic_info['weapon_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity', 'durability'));
         $constraint_info = hConstraint::where(function ($query) use($itemtypeid) {
             $query->where('itemTypeId', '=', $itemtypeid);
             $query->where('version', '=', $this->version);
         })->first(array('cpu', 'mass', 'power'));
         $weapon_info = hStat::where(function ($query) use($itemtypeid) {
             $query->where('itemTypeId', '=', $itemtypeid);
             $query->where('version', '=', $this->version);
         })->first(array('ammoPerBurst', 'clipSize', 'damagePerRound', 'damagePerSecond', 'healthPerRound', 'maxAmmo', 'range', 'reloadTime', 'roundsPerBurst', 'roundsPerMinute', 'splashRadius', 'spread'));
     }
     if (empty($detailed_info)) {
         return Response::json(array('status' => 'error', 'error' => 'error getting detailed information for this itemtypeid.'));
     }
     $detailed_info = $detailed_info->toArray();
     $detailed_info['asset_path'] = $basic_info['asset_path'];
     //add contstraint details
     if (!empty($constraint_info)) {
         $constraint_info = $constraint_info->toArray();
         $detailed_info['cpu'] = $constraint_info['cpu'];
         $detailed_info['mass'] = $constraint_info['mass'];
         $detailed_info['power'] = $constraint_info['power'];
     }
     if (!empty($weapon_info)) {
         $weapon_info = $weapon_info->toArray();
         foreach ($weapon_info as $key => $data) {
             $detailed_info[$key] = $data;
         }
     }
     if (!empty($chassis_info)) {
         $chassis_info = $chassis_info->toArray();
         foreach ($chassis_info as $key => $data) {
             $detailed_info[$key] = $data;
         }
     }
     //cache
     //Cache::forever($this->class_name . "_" . $itemtypeid,$detailed_info);
     $detailed_info['status'] = 'success';
     return json_encode($detailed_info);
 }
Example #14
0
 } else {
     if ($_REQUEST['action'] == "changeWeapon") {
         $weapon = Weapon::loadWeapon($_REQUEST['WeaponID']);
         // @TODO also check that weapon is currently unassigned,
         // so people like me cannot cheat and assign a weapon twice
         if ($weapon->UserID == $currentUID) {
             $hero->Weapon = $weapon;
             $hero->SaveHero();
             $smarty->assign("hero", $hero);
             $smarty->assign("message", $hero->Name . " has equipped " . $weapon->Name);
         } else {
             $smarty->assign("error", "That does not belong to you.");
         }
     } else {
         if ($_REQUEST['action'] == "editWeaponName") {
             $weapon = Weapon::loadWeapon($_REQUEST['WeaponID']);
             if ($weapon->UserID == $currentUID) {
                 $oldName = $weapon->Name;
                 $weapon->Name = $_REQUEST['weaponName'];
                 $weapon->save();
                 $smarty->assign("message", $oldName . " was renamed to " . $weapon->Name);
                 $hero->Weapon = $weapon;
                 $smarty->assign("hero", $hero);
             } else {
                 $smarty->assign("error", "You can't rename what does not belong to you.");
             }
         } else {
             if ($_REQUEST['action'] == "levelUp") {
                 if ($hero->canLevelUp()) {
                     if ($hero->Status == "") {
                         $hero->Status = "Level Up";
Example #15
0
    if ($articles = Mecha::eat($s)->chunk(1, $config->index->per_page)->vomit()) {
        $articles = Mecha::walk($articles, function ($path) use($excludes) {
            return Get::article($path, $excludes);
        });
    } else {
        $articles = false;
    }
    Filter::add('pager:url', function ($url) {
        return Filter::apply('index:url', $url);
    });
    Config::set(array('articles' => $articles, 'pagination' => Navigator::extract($s, 1, $config->index->per_page, $config->index->slug)));
    Shield::attach('page-home');
}, 110);
/**
 * Route Hook: after
 * -----------------
 */
Weapon::fire('routes_after');
/**
 * Do Routing
 * ----------
 */
Route::execute();
/**
 * 404 Page
 * --------
 *
 * Fallback to 404 page if nothing matched.
 *
 */
Shield::abort();
Example #16
0
        <time datetime="<?php 
        echo $page->date->W3C;
        ?>
"><?php 
        echo $page->date->FORMAT_3;
        ?>
</time>
      </span>
    </div>
    <div class="page-body"><?php 
        echo $page->description;
        ?>
</div>
    <div class="page-footer">
      <?php 
        Weapon::fire('page_footer', array($page));
        ?>
    </div>
  </li>
  <?php 
    }
    ?>
</ol>
<?php 
    include DECK . DS . 'workers' . DS . 'unit.pager.1.php';
} else {
    ?>
<p><?php 
    echo Config::speak('notify_empty', strtolower($speak->pages));
    ?>
</p>
Example #17
0
<?php

/**
 * Shortcode Manager
 * -----------------
 */
Route::accept($config->manager->slug . '/shortcode', function () use($config, $speak) {
    if (!Guardian::happy(1)) {
        Shield::abort();
    }
    $shortcodes = Get::state_shortcode(null, array(), false);
    $G = array('data' => $shortcodes);
    Config::set(array('page_title' => $speak->shortcodes . $config->title_separator . $config->manager->title, 'cargo' => 'cargo.shortcode.php'));
    if ($request = Request::post()) {
        $request = Filter::apply('request:__shortcode', $request);
        Guardian::checkToken($request['token']);
        $data = array();
        for ($i = 0, $keys = $request['key'], $count = count($keys); $i < $count; ++$i) {
            if (trim($keys[$i]) !== "") {
                $data[$keys[$i]] = $request['value'][$i];
            }
        }
        $P = array('data' => $data);
        File::serialize($data)->saveTo(STATE . DS . 'shortcode.txt', 0600);
        Notify::success(Config::speak('notify_success_updated', $speak->shortcode));
        Weapon::fire('on_shortcode_update', array($G, $P));
        Guardian::kick($config->url_current);
    }
    Shield::lot(array('segment' => 'shortcode', 'files' => Mecha::O($shortcodes)))->attach('manager');
});
Example #18
0
<?php

Weapon::add('on_comment_construct', function ($G, $P) use($config, $speak) {
    if ($config->is->post && ($post = $G['data'][$config->page_type])) {
        $c = $config->states->{'plugin_' . md5(File::B(__DIR__))};
        $title = $post['title'];
        $url = $post['url'] . '#' . sprintf($G['data']['comment_id'], Date::format($P['data']['id'], 'U'));
        $topic = sprintf($c->subject, $title, $url);
        $parser = Request::post('content_type', $config->html_parser->active);
        $message = '<blockquote><p>' . sprintf($c->message, $title, $url) . '</p></blockquote>';
        $message .= '<h3>' . $P['data']['name'] . '</h3>';
        $message .= $parser !== false && $parser !== 'HTML' ? Text::parse($P['data']['message'], '->html') : $P['data']['message'];
        $message .= '<p>';
        $message .= '<a href="' . $config->url . '/' . $config->manager->slug . '/comment/repair/id:' . $P['data']['id'] . '">' . $speak->edit . '</a>';
        $message .= ' / ';
        $message .= '<a href="' . $config->url . '/' . $config->manager->slug . '/comment/kill/id:' . $P['data']['id'] . '">' . $speak->delete . '</a>';
        $message .= '</p>';
        // Sending email notification ...
        if (!Guardian::happy() && Notify::send($P['data']['email'], $config->author->email, $topic, $message, 'comment:')) {
            Weapon::fire('on_comment_notify_construct', array($P, $config->author->email, $topic, $message));
        }
    }
});
Example #19
0
<?php

/**
 * Error Log
 * ---------
 */
Route::accept($config->manager->slug . '/error', function () use($config, $speak) {
    Config::set(array('page_title' => $speak->errors . $config->title_separator . $config->manager->title, 'cargo' => 'cargo.error.php'));
    Shield::lot(array('segment' => 'error', 'content' => File::open(ini_get('error_log'))->read(false)))->attach('manager');
});
/**
 * Error Log Killer
 * ----------------
 */
Route::accept($config->manager->slug . '/error/kill', function () use($config, $speak) {
    if (!Guardian::happy(1)) {
        Shield::abort();
    }
    $errors = LOG . DS . 'errors.log';
    $G = array('data' => array('content' => File::open($errors)->read()));
    File::open($errors)->delete();
    Weapon::fire('on_error_destruct', array($G, $G));
    Notify::success(Config::speak('notify_success_deleted', $speak->file));
    Guardian::kick(File::D($config->url_current));
});
Example #20
0
 /**
  * ==========================================================
  *  RENDER A SHIELD CHUNK
  * ==========================================================
  *
  * -- CODE: -------------------------------------------------
  *
  *    Shield::chunk('header');
  *
  * ----------------------------------------------------------
  *
  *    Shield::chunk('header', array('title' => 'Yo!'));
  *
  * ----------------------------------------------------------
  *
  */
 public static function chunk($name, $fallback = false, $buffer = true)
 {
     $path__ = File::path($name);
     $G = array('data' => array('name' => $name));
     if (is_array($fallback)) {
         self::$lot = array_merge(self::$lot, $fallback);
         $fallback = false;
     }
     $path__ = Filter::apply('chunk:path', self::path($path__, $fallback));
     $G['data']['lot'] = self::$lot;
     $G['data']['path'] = $path__;
     $out = "";
     if ($path__) {
         // Begin chunk
         Weapon::fire('chunk_lot_before', array($G, $G));
         extract(Filter::apply('chunk:lot', self::$lot));
         Weapon::fire('chunk_lot_after', array($G, $G));
         Weapon::fire('chunk_before', array($G, $G));
         if ($buffer) {
             ob_start(function ($content) use($path__, &$out) {
                 $content = Filter::apply('chunk:input', $content, $path__);
                 $out = Filter::apply('chunk:output', $content, $path__);
                 return $out;
             });
             require $path__;
             ob_end_flush();
         } else {
             require $path__;
         }
         $G['data']['content'] = $out;
         // End chunk
         Weapon::fire('chunk_after', array($G, $G));
     }
 }
Example #21
0
<?php

Weapon::add('meta', function () {
    $config = Config::get();
    $indent = str_repeat(TAB, 2);
    echo $indent . '<!-- Start Facebook Open Graph -->' . NL;
    echo $indent . '<meta property="og:title" content="' . strip_tags($config->page_title) . '"' . ES . NL;
    echo $indent . '<meta property="og:type" content="' . ($config->page_type == 'article' ? 'article' : 'website') . '"' . ES . NL;
    echo $indent . '<meta property="og:url" content="' . $config->url_current . '"' . ES . NL;
    if (isset($config->article->image)) {
        echo $indent . '<meta property="og:image" content="' . $config->article->image . '"' . ES . NL;
    } else {
        if (isset($config->page->image)) {
            echo $indent . '<meta property="og:image" content="' . $config->page->image . '"' . ES . NL;
        }
    }
    echo $indent . '<meta property="og:site_name" content="' . $config->title . '"' . ES . NL;
    if (isset($config->article->description)) {
        echo $indent . '<meta property="og:description" content="' . strip_tags($config->article->description) . '"' . ES . NL;
    } else {
        if (isset($config->page->description)) {
            echo $indent . '<meta property="og:description" content="' . strip_tags($config->page->description) . '"' . ES . NL;
        } else {
            echo $indent . '<meta property="og:description" content="' . strip_tags($config->description) . '"' . ES . NL;
        }
    }
    echo $indent . '<!-- End Facebook Open Graph -->' . NL;
}, 11);
Example #22
0
<header class="post-header">
  <?php 
Shield::chunk('page.title.404');
?>
  <?php 
if (Weapon::exist('page_header')) {
    ?>
  <div><?php 
    Weapon::fire('page_header', array($page));
    ?>
</div>
  <?php 
}
?>
</header>
Example #23
0
    <?php 
Weapon::fire('SHIPMENT_REGION_TOP');
?>
    <?php 
Weapon::fire('shell_before');
?>
    <?php 
echo Asset::stylesheet(array($config->protocol . ICON_LIBRARY_PATH, 'assets/shell/atom.css', 'assets/shell/layout.css'));
?>
    <?php 
Weapon::fire('shell_after');
?>
  </head>
  <body>
    <?php 
Weapon::fire('cargo_before');
?>
    <div class="blog-wrapper">
      <header class="blog-header">
        <?php 
if ($config->url_current == $config->url) {
    ?>
        <h1 class="blog-title"><?php 
    echo $config->title;
    ?>
</h1>
        <?php 
} else {
    ?>
        <h1 class="blog-title"><a href="<?php 
    echo $config->url;
Example #24
0
    $route_cache = $cache_config['path'][$config->url_path];
} else {
    foreach ($cache_config['path'] as $path => $exp) {
        if (Route::is($path)) {
            $route_cache = $exp;
            break;
        }
    }
}
if ($route_cache !== false) {
    Weapon::add('shield_before', function () use($config, $route_cache) {
        $q = !empty($config->url_query) ? '.' . md5($config->url_query) : "";
        $cache = CACHE . DS . str_replace(array('/', ':'), '.', $config->url_path) . $q . '.cache';
        $time = file_exists($cache) ? filemtime($cache) : false;
        if ($time !== false && ($route_cache === true || time() - $route_cache * 60 * 60 < $time)) {
            $content = file_get_contents($cache);
            if (strpos($content, '<?xml ') === 0 || strpos($content, '</html>') !== false) {
                $content .= '<!-- cached: ' . date('Y-m-d H:i:s', $time) . ' -->';
            }
            $content = Filter::apply('cache:input', $content);
            $content = Filter::apply('cache:output', $content);
            echo $content;
            exit;
        }
        Weapon::add('shield_after', function ($G) use($cache) {
            $G['data']['cache'] = $cache;
            File::write($G['data']['content'])->saveTo($cache);
            Weapon::fire('on_cache_construct', array($G, $G));
        });
    });
}
Example #25
0
            $text_kill = Config::speak('manager._this_', array($speak->delete, $text));
            $bars[$text] = array('icon' => 'plus', 'url' => $config->manager->slug . '/' . $type . '/ignite', 'description' => Config::speak('manager.title_new_', $text), 'stack' => 9.029999999999999);
            $bars[$speak->edit] = array('icon' => 'pencil', 'url' => $config->manager->slug . '/' . $type . '/repair/id:' . $id, 'description' => $text_repair, 'stack' => 9.039999999999999);
            $bars[$speak->delete] = array('icon' => 'times', 'url' => $config->manager->slug . '/' . $type . '/kill/id:' . $id, 'description' => $text_kill, 'stack' => 9.050000000000001);
        } else {
            $link = Cell::a($config->manager->slug . '/article/ignite', Config::speak('manager.title_new_', $speak->article));
            $link .= ' &middot; ';
            $link .= Cell::a($config->manager->slug . '/page/ignite', Config::speak('manager.title_new_', $speak->page));
            $bars[$speak->add] = array('icon' => 'plus', 'url' => $config->manager->slug . '/article/ignite', 'description' => $link, 'stack' => 9.029999999999999);
        }
        Config::merge('manager_menu', $menus);
        Config::merge('manager_bar', $bars);
    });
}
// Loading frontend task(s) and route(s)
Weapon::add('routes_before', function () use($config, $speak) {
    require __DIR__ . DS . 'workers' . DS . 'task.comment.ignite.php';
    require __DIR__ . DS . 'workers' . DS . 'route.login.php';
});
// Add log in/out link in shield footer
function do_footer_manager_link($content, $path)
{
    global $config, $speak;
    if (File::N($path) === 'block.footer.bar') {
        $s = Guardian::happy() ? '<a href="' . Filter::colon('manager:url', $config->url . '/' . $config->manager->slug . '/logout') . '" rel="nofollow">' . $speak->log_out . '</a>' : '<a href="' . Filter::colon('manager:url', $config->url . '/' . $config->manager->slug . '/login') . '" rel="nofollow">' . $speak->log_in . '</a>';
        return str_replace('<div class="blog-footer-right">', '<div class="blog-footer-right">' . $s, $content);
    }
    return $content;
}
// Apply `do_footer_manager_link` filter
Filter::add('chunk:output', 'do_footer_manager_link');
Example #26
0
<?php

foreach ($field as $k => $v) {
    $f = $v['type'] === 'file' || $v['type'] === 'f';
    // Remove asset field value and data
    if (isset($v['remove']) && $f) {
        File::open(SUBSTANCE . DS . $v['remove'])->delete();
        Weapon::fire(array('on_substance_update', 'on_substance_destruct'), array($G, $P));
        Notify::success(Config::speak('notify_file_deleted', '<code>' . $v['remove'] . '</code>'));
        unset($field[$k]);
    }
    // Remove empty field value
    if (!isset($v['value']) || $v['value'] === "") {
        unset($field[$k]);
    } else {
        $e = File::E($v['value']);
        if (!file_exists(SUBSTANCE . DS . $e . DS . $v['value']) && $f) {
            unset($field[$k]);
        } else {
            $field[$k] = $v['value'];
        }
    }
}
Example #27
0
/**
 * Shield Attacher
 * ---------------
 */
Route::accept($config->manager->slug . '/shield/(attach|eject)/id:(:any)', function ($path = "", $slug = "") use($config, $speak) {
    $new_config = Get::state_config();
    $new_config['shield'] = $path === 'attach' ? $slug : 'normal';
    File::serialize($new_config)->saveTo(STATE . DS . 'config.txt', 0600);
    $G = array('data' => array('id' => $slug, 'action' => $path));
    $mode = $path === 'eject' ? 'eject' : 'mount';
    Notify::success(Config::speak('notify_success_updated', $speak->shield));
    Weapon::fire('on_shield_update', array($G, $G));
    Weapon::fire('on_shield_' . $mode, array($G, $G));
    Weapon::fire('on_shield_' . md5($slug) . '_update', array($G, $G));
    Weapon::fire('on_shield_' . md5($slug) . '_' . $mode, array($G, $G));
    foreach (glob(SYSTEM . DS . 'log' . DS . 'asset.*.log', GLOB_NOSORT) as $asset_cache) {
        File::open($asset_cache)->delete();
    }
    Guardian::kick($config->manager->slug . '/shield/' . $slug);
});
/**
 * Shield Backup
 * -------------
 */
Route::accept($config->manager->slug . '/shield/backup/id:(:any)', function ($folder = "") use($config, $speak) {
    $name = $folder . '.zip';
    Package::take(SHIELD . DS . $folder)->pack(ROOT . DS . $name, true);
    $G = array('data' => array('path' => ROOT . DS . $name, 'file' => ROOT . DS . $name));
    Weapon::fire('on_backup_construct', array($G, $G));
    Guardian::kick($config->manager->slug . '/backup/send:' . $name);
});
Example #28
0
<?php

$custom_ = CUSTOM . DS . Date::format($task_connect_page->date->W3C, 'Y-m-d-H-i-s');
if (file_exists($custom_ . $extension_o)) {
    Weapon::fire('on_custom_update', array($G, $P));
    if (trim(File::open($custom_ . $extension_o)->read()) === "" || trim(File::open($custom_ . $extension_o)->read()) === SEPARATOR || empty($css) && empty($js) || $css === $task_connect_page_css && $js === $task_connect_page_js) {
        // Always delete empty custom CSS and JavaScript file(s) ...
        File::open($custom_ . $extension_o)->delete();
        Weapon::fire('on_custom_destruct', array($G, $P));
    } else {
        Page::content($css)->content($js)->saveTo($custom_ . $extension_o);
        File::open($custom_ . $extension_o)->renameTo(Date::format($date, 'Y-m-d-H-i-s') . $extension);
        Weapon::fire('on_custom_repair', array($G, $P));
    }
} else {
    if (!empty($css) && $css !== $task_connect_page_css || !empty($js) && $js !== $task_connect_page_js) {
        Page::content($css)->content($js)->saveTo(CUSTOM . DS . Date::format($date, 'Y-m-d-H-i-s') . $extension_o);
        Weapon::fire('on_custom_update', array($G, $P));
        Weapon::fire('on_custom_construct', array($G, $P));
    }
}
Example #29
0
      <td><?php 
echo Jot::em('info', $s);
?>
</td>
      <td><?php 
echo isset($file->scope) ? str_replace(',', '/', $file->scope) : '<em>' . $speak->all . '</em>';
?>
</td>
    </tr>
  </tbody>
</table>
<form class="form-kill form-field" id="form-kill" action="<?php 
echo $config->url_current;
?>
" method="post">
  <?php 
Weapon::fire('action_before', $hooks);
?>
  <?php 
echo Jot::button('action', $speak->yes);
?>
  <?php 
echo Jot::btn('reject', $speak->no, $config->manager->slug . '/field/repair/key:' . $id);
?>
  <?php 
Weapon::fire('action_after', $hooks);
?>
  <?php 
echo Form::hidden('token', $token);
?>
</form>
Example #30
0
        }
    }
    Config::set(array('page_title' => $speak->deleting . ': ' . (count($deletes) === 1 ? File::B($name) : $speak->assets) . $config->title_separator . $config->manager->title, 'files' => $deletes, 'cargo' => DECK . DS . 'workers' . DS . 'kill.asset.php'));
    if ($request = Request::post()) {
        Guardian::checkToken($request['token']);
        $info_path = array();
        $is_folder_or_file = count($deletes) === 1 && is_dir(ASSET . DS . $deletes[0]) ? 'folder' : 'file';
        foreach ($deletes as $file_to_delete) {
            $_path = ASSET . DS . $file_to_delete;
            $info_path[] = $_path;
            File::open($_path)->delete();
        }
        $P = array('data' => array('files' => $info_path));
        Notify::success(Config::speak('notify_' . $is_folder_or_file . '_deleted', '<code>' . implode('</code>, <code>', $deletes) . '</code>'));
        Weapon::fire('on_asset_update', array($P, $P));
        Weapon::fire('on_asset_destruct', array($P, $P));
        Guardian::kick($config->manager->slug . '/asset/1' . $p);
    } else {
        Notify::warning(count($deletes) === 1 ? Config::speak('notify_confirm_delete_', '<code>' . File::path($name) . '</code>') : $speak->notify_confirm_delete);
    }
    Shield::lot('segment', 'asset')->attach('manager', false);
});
/**
 * Multiple Asset Killer
 * ---------------------
 */
Route::accept($config->manager->slug . '/asset/kill', function ($path = "") use($config, $speak) {
    if ($request = Request::post()) {
        Guardian::checkToken($request['token']);
        if (!isset($request['selected'])) {
            Notify::error($speak->notify_error_no_files_selected);