示例#1
0
文件: file.php 项目: sd-studio/sh
function get($id)
{
    $id = getID($id);
    static $q = null;
    \cf\createStaticQuery($q, "SELECT IFNULL(code,id) AS id, file, file_name, file FROM cf_file WHERE id=:id");
    return \cf\query2array($q, array('id' => $id));
}
示例#2
0
文件: form.php 项目: sd-studio/sh
function get($id)
{
    $id = getID($id);
    static $q = null;
    \cf\createStaticQuery($q, "SELECT id, code, name, action, method, template FROM cf_form WHERE id=:id");
    $form = \cf\query2array($q, array('id' => $id));
    if ($form['template']) {
        $form['template'] = \cf\query2array("\n\t\t\tSELECT name, subject, recipient, body \n\t\t\tFROM cf_mail_templates \n\t\t\tWHERE id=:id", array('id' => $form['template']));
    } else {
        $form['template'] = false;
    }
    static $qFields = null;
    \cf\createStaticQuery($qFields, "\n\t\tSELECT code,type,name,fmt,descr,mandatory,max_length,min_length,value\n\t\tFROM cf_form_field\n\t\tWHERE form_id=:id\n\t\tORDER BY sort_order\n\t");
    $form['fields'] = \cf\query2arrays($qFields, array('id' => $id), false, 'code');
    foreach ($form['fields'] as &$f) {
        $f['code'] = $form['code'] . '[' . $f['code'] . ']';
        if ($f['type'] == 'radio' || $f['type'] == 'checkbox') {
            $f['options'] = array();
            foreach (explode(';', $f['fmt']) as $option) {
                $f['options'][] = trim($option);
            }
        }
    }
    return $form;
}
示例#3
0
文件: page.php 项目: sd-studio/sh
 public static function get($id)
 {
     $id = self::getID($id);
     if (!$id) {
         return false;
     }
     static $q = null;
     if (!$q) {
         \cf\createStaticQuery($q, 'SELECT * FROM cf_page WHERE id=:id');
     }
     $page = \cf\query2array($q, array('id' => $id));
     if (!$page['code']) {
         $page['code'] = $page['id'];
     }
     $parent = $page['parent_id'] ? self::get($page['parent_id']) : null;
     $page['path'] = ($parent ? $parent['path'] : '') . '/' . ($page['permalink'] ? $page['permalink'] : $page['id']);
     if (!$page['link']) {
         $page['link'] = $page['path'];
     }
     $page['branch'] = array_merge($parent ? $parent['branch'] : array(), array($page));
     $page['parent'] = false;
     if (count($page['branch']) > 1) {
         $page['parent'] =& $page['branch'][count($page['branch']) - 2];
     }
     $page['root'] =& $page['branch'][0];
     return $page;
 }
示例#4
0
文件: page.php 项目: sd-studio/or
function get($id, $rootID = null)
{
    static $q = null;
    \cf\createStaticQuery($q, '
		SELECT id, IFNULL(code,id) AS code, parent_id, name, menu_name, link, short_txt, title, keywords, descr, icon, hidden, sort_order
		FROM cf_page
		WHERE id=:id
	');
    $page = $parent = \cf\query2array($q, array('id' => getID($id)));
    if (empty($page)) {
        return false;
    }
    $path = $branch = array();
    $depth = 0;
    $rootID = getID($rootID);
    while (true) {
        if ($parent['id'] == $rootID) {
            break;
        }
        $path[] = $parent['code'];
        $branch[] = $parent;
        ++$depth;
        if (!$parent['parent_id']) {
            break;
        }
        $parent = get($parent['parent_id'], $rootID);
    }
    $page['path'] = '/' . implode('/', array_reverse($path));
    $page['parent'] = count($branch) > 1 ? $branch[1] : null;
    $page['branch'] = array_reverse($branch);
    $page['depth'] = $depth;
    return $page;
}
示例#5
0
文件: admin.php 项目: sd-studio/sh
function getAction($id, $params = array())
{
    $action = \cf\query2array('
		SELECT * FROM cf_admin_action WHERE id=:id', array('id' => $id));
    $action['params'] = array();
    $action['params_query'] = '';
    if ($action['params_id']) {
        $action['params'] = \cf\query2arrays('
			SELECT name, type_id AS type, title, default_val AS value, mandatory, max_length, min_length, fmt, default_val, tree_id, list_id 
			FROM cf_admin_action_param 
			WHERE params_id=:id
			ORDER BY sort_order', array('id' => $action['params_id']));
        $action['params_query'] = \cf\query2var('SELECT query FROM cf_admin_action_params WHERE id=:id', array('id' => $action['params_id']));
        if (!empty($params) && $action['params_query']) {
            $values = \cf\query2array($action['params_query'], $params);
            for ($i = 0; $i < count($action['params']); ++$i) {
                if (array_key_exists($action['params'][$i]['name'], $values)) {
                    $action['params'][$i]['value'] = $values[$action['params'][$i]['name']];
                    if ($action['params'][$i]['type'] == 'File') {
                        $action['params'][$i]['is_image'] = @getimagesize($_SERVER['DOCUMENT_ROOT'] . '/' . $action['params'][$i]['value']) != false;
                    }
                }
            }
        }
        for ($i = 0; $i < count($action['params']); ++$i) {
            $p = $action['params'][$i];
            $action['params'][$i]['options'] = explode(';', $p['fmt']);
            $action['params'][$i]['dict_value'] = false;
            if ($p['tree_id'] || $p['list_id']) {
                $v = getView($p['tree_id'] ? $p['tree_id'] : $p['list_id']);
                $action['params'][$i]['view'] = $v;
                $action['params'][$i]['dict_value'] = \cf\query2var('SELECT ' . $v['name_field'] . ' FROM ' . (preg_match('/^\\w+$/', $v['query']) ? $v['query'] : '(' . $v['query'] . ') t') . ' WHERE ' . $v['primary_key_field'] . '=:id', array('id' => $p['value']));
            }
        }
    }
    return $action;
}
示例#6
0
文件: yml.php 项目: sd-studio/or
                cf\api\admin\doAction('product_in_group_add', array('group_id' => $catMatch[$fromCat]['to_id'], 'product_id' => $pid, 'sort_order' => 500));
            }
        }
        global $addedCount;
        ++$addedCount;
        return $pid;
    }
}
$stop = false;
$offersCount = 0;
$addedCount = 0;
$updatedCount = 0;
$deletedCount = 0;
$foundIDs = array();
try {
    $settings = cf\query2array("SELECT * FROM cf_import_yml WHERE id=:id", array('id' => $ymlID));
    $sellerID = $settings['seller'];
    $newState = $settings['new_state'];
    $_SERVER['DOCUMENT_ROOT'] = getcwd() . "/../../../..";
    $delFile = false;
    if ($argc > 2) {
        //second argument is a TMP file path to load data from
        $settings['url'] = $argv[2];
        $delFile = true;
    }
    $fieldsMatch = array('NAME' => array(), 'MODEL' => array(), 'TYPEPREFIX' => array(), 'DESCRIPTION' => array(), 'URL' => array('link'), 'PRICE' => array('price'), 'VENDOR' => array('manufacturer_id'), 'VENDORCODE' => array('article'));
    $fieldsMatch[strtoupper($settings['name_from'])][] = 'name';
    if ($settings['model_from']) {
        $fieldsMatch[strtoupper($settings['model_from'])][] = 'model';
    }
    if ($settings['short_descr_from']) {
示例#7
0
文件: core.php 项目: sd-studio/sh
}
$user = cf\User::getLoggedIn();
if (!$user && !defined('NO_AUTH')) {
    forward('login.php');
}
if (!defined('SMARTY_DIR')) {
    define('SMARTY_DIR', cf\Config::smarty_dir);
}
require_once SMARTY_DIR . 'Smarty.class.php';
$smarty = new Smarty();
$smarty->compile_check = true;
$smarty->debugging = false;
$smarty->addPluginsDir(cf\Config::path . 'components/');
$root_url = substr($_SERVER['REQUEST_URI'], 0, stripos($_SERVER['REQUEST_URI'], 'admin') + 6);
if ($user) {
    $uprofile = cf\query2array("SELECT desktop_url,hide_navigation FROM cf_users WHERE id=:id", array('id' => $user->id()));
    if ($uprofile['desktop_url']) {
        if ($root_url == $_SERVER['REQUEST_URI'] || $root_url . 'index.php' == $_SERVER['REQUEST_URI']) {
            forward($uprofile['desktop_url']);
        }
        $root_url = $uprofile['desktop_url'];
    }
    $smarty->assign('uprofile', $uprofile);
}
$smarty->assign('root_url', $root_url);
date_default_timezone_set('Europe/Moscow');
$smarty->assign('user', $user);
$smarty->assign('siteName', cf\Config::site);
$mainmenu = cf\api\admin\getCategories();
$smarty->assign('mainmenu', $mainmenu);
class MainMenu
示例#8
0
文件: articles.php 项目: sd-studio/sh
<?php

if (strlen($pathInfo['notfound'])) {
    $news = cf\query2array("\n\t\tSELECT * FROM cf_news WHERE id=:id OR code=:id", array('id' => $pathInfo['notfound']));
    $page['keywords'] = $news['tag_meta_keywords'];
    $page['descr'] = $news['tag_meta_descr'];
    $page['title'] = $news['tag_title'];
    $page['name'] = $news['name'];
    $page['template'] = 'article';
    $crumbs[] = array('name' => $news['name']);
    $pageText = $news['txt'];
    $productIDs = cf\query2vector("\n\t\tSELECT product_id AS id FROM cf_products_in_news WHERE news_id=:newsid ORDER BY sort_order\n\t", array('newsid' => $news['id']));
    $products = array();
    foreach ($productIDs as $pid) {
        $products[] = cf\api\shop\getProduct($pid);
    }
    $smarty->assign('products', prepareProducts($products));
    return true;
}
$smarty->assign('newslist', cf\query2arrays("\n\tSELECT IFNULL(code,cf_news.id) AS code,name,image,short_txt \n\tFROM cf_news \n\tINNER JOIN cf_news_in_category ON cf_news.id=cf_news_in_category.news_id\n\tWHERE cf_news_in_category.category_id = :pid\n\tORDER BY dt DESC\n", array('pid' => $page['id'])));
示例#9
0
文件: gallery.php 项目: sd-studio/or
function getImage($id)
{
    $image = \cf\query2array("\r\n\t\tSELECT * FROM cf_gallery_images WHERE id=:id", array('id' => $id));
    $image['albums'] = \cf\query2arrays("\r\n\t\tSELECT cf_gallery_albums.id, IFNULL(cf_gallery_albums.code,cf_gallery_albums.id) AS code, name, image, hidden \r\n\t\tFROM cf_gallery_image_in_album \r\n\t\tINNER JOIN cf_gallery_albums ON album_id=cf_gallery_albums.id\r\n\t\tWHERE image_id=:id", array('id' => $id));
    return $image;
}