<?php
/**
 * Copyright (C) LJCMS All rights reserved.
 * <E-Mail：aspcms@qq.com>
 * Url http://www.liangjing.org
 *     http://www.8CMS.com
 * Update 2016.03.19
 */

function hook_cmd_hook($extract) {
    if (!empty($extract)) {
        X::loadLib("mod");
        @extract($extract);
        $mod = trim($extract['mod']); 
        $type = empty($extract['type']) ? '' : trim($extract['type']); 
        $name = empty($extract['name']) ? '' : trim($extract['name']); 
        $value = empty($extract['value']) ? '' : intval($extract['value']); 
        $text = empty($extract['text']) ? '' : trim($extract['text']); 
        if ($mod == 'category') {
            if ($type == 'option') {
                $m_category = X::model('category', 'am');
                return $m_category->getAllTreeOption($value);
                unset($m_category);
            }
            elseif ($type == 'text') {
                $m_category = X::model('category', 'im');
                return $m_category->getCatName($value);
                unset($m_category);
            }
        }
        
        elseif ($mod == 'contenturl') {
            $m_index = X::model('index', 'im');
            return $m_index->getContentUrl($type, $value);
            unset($m_index);
        }
        elseif ($mod == "quetopic" && $type == "select") { 
            return XMod::selectQuetopic($value, $name, $text);
        }
    }
}
TPL::regFunction("hook", "hook_cmd_hook");
?>
