当前位置: 首页>>代码示例>>PHP>>正文


PHP Mecha::A方法代码示例

本文整理汇总了PHP中Mecha::A方法的典型用法代码示例。如果您正苦于以下问题:PHP Mecha::A方法的具体用法?PHP Mecha::A怎么用?PHP Mecha::A使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mecha的用法示例。


在下文中一共展示了Mecha::A方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: manager

 /**
  * Widget Manager
  * --------------
  *
  * [1]. Widget::manager('MENU');
  * [2]. Widget::manager('BAR');
  *
  */
 public static function manager($type = 'MENU')
 {
     if (!Guardian::happy()) {
         return "";
     }
     $T1 = TAB;
     if ($type === 'MENU') {
         $menus = array();
         if ($_menus = Mecha::A(Config::get('manager_menu'))) {
             $_menus = Mecha::eat($_menus)->order('ASC', 'stack', true, 10)->vomit();
             foreach ($_menus as $k => $v) {
                 // < 1.1.3
                 if (is_string($v)) {
                     $menus[$k] = $v;
                 } else {
                     $stack = isset($v['stack']) ? $v['stack'] : 10;
                     $_k = (strpos($v['icon'], '<') === false ? '<i class="fa fa-fw fa-' . $v['icon'] . '"></i>' : $v['icon']) . ' <span class="label">' . $k . '</span>' . (isset($v['count']) && ($v['count'] === '&infin;' || (double) $v['count'] > 0) ? ' <span class="counter">' . $v['count'] . '</span>' : "");
                     $menus[$_k] = isset($v['url']) ? $v['url'] : null;
                 }
             }
         }
         $html = O_BEGIN . '<div class="widget widget-manager widget-manager-menu" id="widget-manager-menu-' . self::$id['manager_menu'] . '">' . NL;
         self::$id['manager_menu']++;
         $html .= Menu::get($menus, 'ul', $T1, 'manager:');
         $html .= '</div>' . O_END;
         $html = Filter::apply('widget', $html);
         return Filter::apply('widget:manager.menu', Filter::apply('widget:manager', $html));
     }
     if ($type === 'BAR') {
         $html = O_BEGIN . '<div class="widget widget-manager widget-manager-bar" id="widget-manager-bar-' . self::$id['manager_bar'] . '">' . NL;
         self::$id['manager_bar']++;
         $bars = array();
         if ($_bars = Mecha::A(Config::get('manager_bar'))) {
             $_bars = Mecha::eat($_bars)->order('ASC', 'stack', true, 10)->vomit();
             foreach ($_bars as $k => $v) {
                 if (is_string($v)) {
                     $bar = $v;
                 } else {
                     $t = ' data-tooltip="' . Text::parse(isset($v['description']) ? $v['description'] : $k, '->encoded_html') . '"';
                     $bar = isset($v['url']) ? '<a class="item" href="' . Converter::url($v['url']) . '"' . $t . '>' : '<span class="item a"' . $t . '>';
                     $bar .= isset($v['icon']) ? strpos($v['icon'], '<') === false ? Jot::icon($v['icon']) : $v['icon'] : $k;
                     $bar .= ' <span class="label">' . $k . '</span>';
                     if (isset($v['count']) && ($v['count'] === '&infin;' || (double) $v['count'] > 0)) {
                         $bar .= ' <span class="counter">' . $v['count'] . '</span>';
                     }
                     $bar .= isset($v['url']) ? '</a>' : '</span>';
                 }
                 $bars[] = Filter::apply('manager:bar.item', $bar);
             }
         }
         $html .= $T1 . Filter::apply('manager:bar', implode(' ', $bars)) . NL;
         $html .= '</div>';
         return Filter::apply('widget:manager.bar', Filter::apply('widget:manager', $html));
     }
 }
开发者ID:razordaze,项目名称:mecha-cms,代码行数:63,代码来源:widget.php

示例2: set

 /**
  * =============================================================
  *  REGISTER NEW VARIABLE(S)
  * =============================================================
  *
  * -- CODE: ----------------------------------------------------
  *
  *    Config::set('foo', 'bar');
  *
  * -------------------------------------------------------------
  *
  *    Config::set(array(
  *        'a' => 1,
  *        'b' => 2
  *    ));
  *
  * -------------------------------------------------------------
  *
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *  Parameter | Type   | Description
  *  --------- | ------ | ---------------------------------------
  *  $key      | string | Key of data to be called
  *  $key      | array  | Array of data's key and value
  *  $value    | mixed  | The value of your data key
  *  --------- | ------ | ---------------------------------------
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
  */
 public static function set($key, $value = "")
 {
     if (is_object($key)) {
         $key = Mecha::A($key);
     }
     if (is_object($value)) {
         $value = Mecha::A($value);
     }
     $cargo = array();
     if (!is_array($key)) {
         Mecha::SVR($cargo, $key, $value);
     } else {
         foreach ($key as $k => $v) {
             Mecha::SVR($cargo, $k, $v);
         }
     }
     Mecha::extend(self::$bucket, $cargo);
 }
开发者ID:razordaze,项目名称:mecha-cms,代码行数:46,代码来源:config.php

示例3: set

 public static function set($session, $value = "", $expire = 1, $path = '/', $domain = "", $secure = false, $http_only = false)
 {
     if (strpos($session, 'cookie:') === 0) {
         $name = substr($session, 7);
         $expire = time() + 60 * 60 * 24 * $expire;
         if (strpos($name, '.') !== false) {
             $parts = explode('.', $name);
             $name = array_shift($parts);
             $old = Converter::strEval(isset($_COOKIE[$name]) ? $_COOKIE[$name] : array());
             if (is_object($value)) {
                 $value = Mecha::A($value);
             }
             Mecha::SVR($old, implode('.', $parts), $value);
             $value = $old;
         }
         setcookie($name, base64_encode(json_encode($value, true)), $expire, $path, $domain, $secure, $http_only);
         setcookie('__' . $name, base64_encode(json_encode(array($expire, $path, $domain, $secure, $http_only), true)), $expire, '/', "", false, false);
     } else {
         Mecha::SVR($_SESSION, $session, $value);
     }
 }
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:21,代码来源:session.php

示例4: isset

             // < 1.1.3
             if (is_string($v)) {
                 $menus[$k] = $v;
             } else {
                 $stack = isset($v['stack']) ? $v['stack'] : 10;
                 $_k = (strpos($v['icon'], '<') === false ? Jot::icon($v['icon'], 'fw') : $v['icon']) . ' <span class="label">' . $k . '</span>' . (isset($v['count']) && ($v['count'] === '&infin;' || (double) $v['count'] > 0) ? ' <span class="counter">' . $v['count'] . '</span>' : "");
                 $menus[$_k] = isset($v['url']) ? $v['url'] : null;
             }
         }
     }
     Menu::add('manager', $menus);
     $html .= Menu::manager('ul', $T1);
 }
 if ($type === 'BAR') {
     $bars = array();
     if ($_bars = Mecha::A(Config::get('manager_bar'))) {
         $_bars = Mecha::eat($_bars)->order('ASC', 'stack', true, 10)->vomit();
         foreach ($_bars as $k => $v) {
             if (is_string($v)) {
                 $bar = $v;
             } else {
                 $t = ' data-tooltip="' . Text::parse(isset($v['description']) ? $v['description'] : $k, '->encoded_html') . '"';
                 if (isset($v['url'])) {
                     $url = Filter::colon('manager:url', Converter::url($v['url']));
                     $c = $config->url_current === $url ? ' ' . Widget::$config['classes']['current'] : "";
                     $bar = '<a class="item' . $c . '" href="' . $url . '"' . $t . '>';
                 } else {
                     $bar = '<span class="item a"' . $t . '>';
                 }
                 $bar .= isset($v['icon']) ? strpos($v['icon'], '<') === false ? Jot::icon($v['icon']) : $v['icon'] : $k;
                 $bar .= ' <span class="label">' . $k . '</span>';
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:31,代码来源:widget.php

示例5: function

});
/**
 * Comment Killer
 * --------------
 */
Route::accept($config->manager->slug . '/comment/kill/id:(:num)', function ($id = "") use($config, $speak) {
    if (Guardian::get('status') !== 'pilot') {
        Shield::abort();
    }
    if (!($comment = Get::comment($id))) {
        Shield::abort();
        // File not found!
    }
    Config::set(array('page_title' => $speak->deleting . ': ' . $speak->comment . $config->title_separator . $config->manager->title, 'response' => $comment, 'cargo' => DECK . DS . 'workers' . DS . 'kill.comment.php'));
    if ($request = Request::post()) {
        $P = array('data' => Mecha::A($comment));
        Guardian::checkToken($request['token']);
        File::open($comment->path)->delete();
        $task_connect = $comment;
        include DECK . DS . 'workers' . DS . 'task.field.3.php';
        File::write($config->total_comments_backend - 1)->saveTo(SYSTEM . DS . 'log' . DS . 'comments.total.log', 0600);
        Notify::success(Config::speak('notify_success_deleted', $speak->comment));
        Weapon::fire('on_comment_update', array($P, $P));
        Weapon::fire('on_comment_destruct', array($P, $P));
        Guardian::kick($config->manager->slug . '/comment');
    } else {
        File::write($config->total_comments_backend)->saveTo(SYSTEM . DS . 'log' . DS . 'comments.total.log', 0600);
        Notify::warning($speak->notify_confirm_delete);
    }
    Shield::lot('segment', 'comment')->attach('manager', false);
});
开发者ID:razordaze,项目名称:mecha-cms,代码行数:31,代码来源:route.comment.php

示例6: array

<?php

$tags = array();
$tags_wayback = ',' . Request::get('kind', implode(',', Guardian::wayback('kind', Mecha::A($page->kind)))) . ',';
foreach (call_user_func('Get::' . $segment . 'Tags') as $tag) {
    if ($tag && $tag->id !== 0) {
        $tags[] = '<div>' . Form::checkbox('kind[]', $tag->id, strpos($tags_wayback, ',' . $tag->id . ',') !== false, $tag->name) . '</div>';
    }
}
if (count($tags) > 0) {
    ?>
<div class="grid-group">
  <span class="grid span-1 form-label"><?php 
    echo $speak->tags;
    ?>
</span>
  <div class="grid span-5"><?php 
    echo implode("", $tags);
    ?>
</div>
</div>
<?php 
}
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:23,代码来源:kind[].php

示例7: toArray

 /**
  * ====================================================================
  *  CONVERT NESTED STRING INTO ASSOCIATIVE ARRAY
  * ====================================================================
  *
  * -- CODE: -----------------------------------------------------------
  *
  *    echo Converter::toArray('key_1: Value 1
  *    key_2: Value 2
  *    key_3: Value 3');
  *
  * --------------------------------------------------------------------
  *
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *  Parameter | Type   | Description
  *  --------- | ------ | ----------------------------------------------
  *  $input    | string | The string of data to be converted
  *  $s        | string | Separator between data key and data value
  *  $indent   | string | Indentation of nested string data level
  *  --------- | ------ | ----------------------------------------------
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
  */
 public static function toArray($input, $s = S, $indent = '    ')
 {
     if (is_array($input)) {
         return $input;
     }
     if (is_object($input)) {
         return Mecha::A($input);
     }
     return Text::toArray((string) $input, $s, $indent);
 }
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:33,代码来源:converter.php

示例8: array

<?php

$bucket = array();
$url_base = $config->url . '/feed/json';
$json_order = strtoupper(Request::get('order', 'DESC'));
$json_filter = Request::get('filter', "");
$json_limit = Request::get('chunk', 25);
if ($pages = Mecha::eat(Get::articles($json_order, $json_filter))->chunk($config->offset, $json_limit)->vomit()) {
    foreach ($pages as $path) {
        $bucket[] = Get::articleHeader($path);
    }
}
$json = array('meta' => array('generator' => 'Mecha ' . MECHA_VERSION, 'title' => $config->title, 'slogan' => $config->slogan, 'url' => array('home' => $config->url, 'previous' => $config->offset > 1 ? Filter::colon('feed:url', $url_base . '/' . ($config->offset - 1)) : null, 'next' => $config->offset < ceil($config->total_articles / $json_limit) ? Filter::colon('feed:url', $url_base . '/' . ($config->offset + 1)) : null), 'description' => $config->description, 'update' => date('c'), 'author' => (array) $config->author, 'offset' => $config->offset, 'total' => $config->total_articles, 'tags' => Get::articleTags()), 'item' => null);
if (!empty($bucket)) {
    $json['item'] = array();
    foreach ($bucket as $i => $item) {
        $json['item'][$i] = array('title' => $item->title, 'url' => $item->url, 'date' => $item->date->W3C, 'update' => Date::format($item->update, 'c'), 'id' => $item->id, 'description' => $item->description, 'kind' => Mecha::A($item->kind));
        Weapon::fire('json_item', array(&$json['item'][$i], $item, $i));
    }
}
Weapon::fire('json_meta', array(&$json['meta']));
echo (isset($_GET['callback']) ? $_GET['callback'] . '(' : "") . json_encode($json) . (isset($_GET['callback']) ? ');' : "");
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:22,代码来源:json.php

示例9: ceil

echo '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">';
echo '<channel>';
echo '<generator>Mecha ' . MECHA_VERSION . '</generator>';
echo '<title>' . $config->title . '</title>';
echo '<link>' . $config->url . '/</link>';
echo '<description>' . $config->description . '</description>';
echo '<lastBuildDate>' . Date::format(time(), 'r') . '</lastBuildDate>';
echo '<atom:link rel="self" href="' . $config->url_current . '"/>';
echo $config->offset > 1 ? '<atom:link rel="previous" href="' . Filter::colon('feed:url', $url_base . '/' . ($config->offset - 1)) . '"/>' : "";
echo $config->offset < ceil($config->total_articles / $rss_limit) ? '<atom:link rel="next" href="' . Filter::colon('feed:url', $url_base . '/' . ($config->offset + 1)) . '"/>' : "";
Weapon::fire('rss_meta');
if (!empty($bucket)) {
    foreach ($bucket as $i => $item) {
        $title = strip_tags($item->title);
        $description = $item->description;
        $kind = Mecha::A($item->kind);
        echo '<item>';
        echo '<title><![CDATA[' . $title . ']]></title>';
        echo '<link>' . $item->url . '</link>';
        echo '<description><![CDATA[' . $description . ']]></description>';
        echo '<pubDate>' . Date::format($item->time, 'r') . '</pubDate>';
        echo '<guid>' . $item->url . '</guid>';
        if (!empty($kind)) {
            foreach ($kind as $k) {
                $tag = Get::articleTag($k);
                echo '<category domain="' . Filter::colon('tag:url', $config->url . '/' . $config->tag->slug . '/' . $tag->slug) . '">' . $tag->name . '</category>';
            }
        }
        echo '<source url="' . $item->url . '"><![CDATA[' . $config->title . ': ' . $title . ']]></source>';
        Weapon::fire('rss_item', array($item, $i));
        echo '</item>';
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:31,代码来源:rss.php

示例10: strtolower

include 'unit.composer.1.php';
?>
      <label class="grid-group">
        <span class="grid span-1 form-label"><?php 
echo $speak->description;
?>
</span>
        <span class="grid span-5">
        <?php 
echo Form::textarea('description', Guardian::wayback('description', $default->description), Config::speak('manager.placeholder_description_', strtolower($speak->article)), array('class' => 'textarea-block'));
?>
        </span>
      </label>
      <?php 
$tags = array();
$tags_wayback = ',' . implode(',', Guardian::wayback('kind', Mecha::A($default->kind))) . ',';
foreach (Get::tags() as $tag) {
    if ($tag && $tag->id !== 0) {
        $tags[] = '<div>' . Form::checkbox('kind[]', $tag->id, strpos($tags_wayback, ',' . $tag->id . ',') !== false, $tag->name) . '</div>';
    }
}
?>
      <?php 
if (count($tags) > 0) {
    ?>
      <div class="grid-group">
        <span class="grid span-1 form-label"><?php 
    echo $speak->tags;
    ?>
</span>
        <div class="grid span-5"><?php 
开发者ID:razordaze,项目名称:mecha-cms,代码行数:31,代码来源:repair.article.php

示例11: memorize

 /**
  * ============================================================
  *  STORE THE POSTED DATA INTO SESSION
  * ============================================================
  *
  * -- CODE: ---------------------------------------------------
  *
  *    if(Request::post()) {
  *        Guardian::memorize();
  *        // do another stuff ...
  *    }
  *
  * ------------------------------------------------------------
  *
  */
 public static function memorize($memo = null)
 {
     if (is_null($memo)) {
         $memo = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : array();
     }
     if (is_object($memo)) {
         $memo = Mecha::A($memo);
     }
     Session::set(self::$form, $memo);
 }
开发者ID:razordaze,项目名称:mecha-cms,代码行数:25,代码来源:guardian.php

示例12: function

    }, 11);
    Shield::lot(array('segment' => 'article', 'default' => $article))->attach('manager', false);
});
/**
 * Article Killer
 * --------------
 */
Route::accept($config->manager->slug . '/article/kill/id:(:num)', function ($id = "") use($config, $speak) {
    if (!($article = Get::article($id, array('comments')))) {
        Shield::abort();
    }
    if (Guardian::get('status') !== 'pilot' && Guardian::get('author') !== $article->author) {
        Shield::abort();
    }
    Config::set(array('page_title' => $speak->deleting . ': ' . $article->title . $config->title_separator . $config->manager->title, 'article' => $article, 'cargo' => DECK . DS . 'workers' . DS . 'kill.article.php'));
    $G = array('data' => Mecha::A($article));
    if ($request = Request::post()) {
        Guardian::checkToken($request['token']);
        File::open($article->path)->delete();
        // Deleting comment(s) ...
        if ($comments = Get::comments($id, 'DESC', 'txt,hold')) {
            foreach ($comments as $comment) {
                File::open($comment)->delete();
            }
        }
        $task_connect = $article;
        $P = array('data' => $request);
        include DECK . DS . 'workers' . DS . 'task.field.3.php';
        include DECK . DS . 'workers' . DS . 'task.custom.3.php';
        Notify::success(Config::speak('notify_success_deleted', $article->title));
        Weapon::fire('on_article_update', array($G, $G));
开发者ID:razordaze,项目名称:mecha-cms,代码行数:31,代码来源:route.article.php

示例13: function

 * -------------------------------------------------------------
 *
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *  Parameter | Type   | Description
 *  --------- | ------ | ---------------------------------------
 *  $key      | string | Key of language data to be called
 *  $vars     | array  | Array of value used in PHP `vsprintf()`
 *  --------- | ------ | ---------------------------------------
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 */
Config::plug('speak', function ($key = null, $vars = array()) {
    if (is_null($key)) {
        return Config::get('speak');
    }
    $speak = Mecha::A(Config::get('speak'));
    $fallback = $key;
    if (strpos($key, 'file:') === 0) {
        $key = File::path(str_replace('file:', "", $key));
        if ($file = File::exist(LANGUAGE . DS . Config::get('language') . DS . 'yapping' . DS . $key . '.txt')) {
            $wizard = Text::toPage(File::open($file)->read(), 'content', 'wizard:');
            return $wizard['content'];
        } else {
            if ($file = File::exist(ROOT . DS . $key . '.txt')) {
                $wizard = Text::toPage(File::open($file)->read(), 'content', 'wizard:');
                return $wizard['content'];
            }
        }
        return "";
    }
    if (!is_array($vars)) {
开发者ID:razordaze,项目名称:mecha-cms,代码行数:31,代码来源:config.php

示例14: array

<?php

$fields = Get::state_field($segment);
Weapon::fire('unit_composer_3_before', array($segment, $fields));
if (!isset($default->fields)) {
    $default->fields = array();
}
if (!empty($fields)) {
    $html = "";
    $field = Guardian::wayback('fields', Mecha::A($default->fields));
    foreach ($fields as $key => $value) {
        // <= 1.1.3
        // "" is equal to `article,page`
        // '*' is equal to all scopes
        if ($value['scope'] === "") {
            $value['scope'] = 'article,page';
        }
        if ($value['scope'] === '*') {
            $value['scope'] = $segment;
        }
        if (isset($field[$key]['type'])) {
            $field[$key] = isset($field[$key]['value']) ? $field[$key]['value'] : "";
        }
        $type = $value['type'][0];
        if (strpos(',' . $value['scope'] . ',', ',' . $segment . ',') !== false) {
            $description = isset($value['description']) && trim($value['description']) !== "" ? ' <span class="text-info help" title="' . Text::parse($value['description'], '->encoded_html') . '">' . Jot::icon('question-circle') . '</span>' : "";
            $title = $value['title'] . $description;
            $html .= Form::hidden('fields[' . $key . '][type]', $type);
            if ($type === 't') {
                $html .= '<label class="grid-group grid-group-text">';
                $html .= '<span class="grid span-2 form-label">' . $title . '</span>';
开发者ID:razordaze,项目名称:mecha-cms,代码行数:31,代码来源:unit.composer.3.php

示例15: toArray

 /**
  * =====================================================================
  *  READ A TEXT FILE AS AN ASSOCIATIVE ARRAY
  * =====================================================================
  *
  * -- CODE: ------------------------------------------------------------
  *
  *    var_dump(Text::toArray("key 1: value 1\nkey 2: value 2"));
  *
  * ---------------------------------------------------------------------
  *
  */
 public static function toArray($text, $s = S, $indent = '    ')
 {
     if (is_array($text)) {
         return $text;
     }
     if (is_object($text)) {
         return Mecha::A($text);
     }
     $results = array();
     $data = array();
     $indent_length = strlen($indent);
     // Remove comment(s) and empty line break(s)
     $text = preg_replace(array('#\\r#', '#(^|\\n)\\s*\\#[^\\n]*#', '#\\n+#', '#^\\n+|\\n+$#'), array("", "\n", "\n", ""), $text);
     foreach (explode("\n", $text) as $line) {
         $depth = 0;
         // No `:` ... fix it!
         if (strpos($line, $s) === false) {
             $line .= $s . $line;
         }
         while (substr($line, 0, $indent_length) === $indent) {
             $depth += 1;
             $line = rtrim(substr($line, $indent_length));
         }
         while ($depth < count($data)) {
             array_pop($data);
         }
         $parts = explode($s, $line, 2);
         $data[$depth] = rtrim($parts[0]);
         $parent =& $results;
         foreach ($data as $depth => $key) {
             if (!isset($parent[$key])) {
                 $value = isset($parts[1]) && !empty($parts[1]) ? preg_replace('#^`|`$#', "", trim($parts[1])) : array();
                 $parent[rtrim($parts[0])] = Converter::strEval($value);
                 break;
             }
             $parent =& $parent[$key];
         }
     }
     return $results;
 }
开发者ID:razordaze,项目名称:mecha-cms,代码行数:52,代码来源:text.php


注:本文中的Mecha::A方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。