コード例 #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
ファイル: yml.php プロジェクト: sd-studio/or
function addProduct($offer, $categories)
{
    global $ymlID, $catMatch, $sellerID, $newState;
    if (!count(array_intersect($categories, array_keys($catMatch)))) {
        return false;
    }
    static $qFind = null;
    if (!$qFind) {
        cf\createStaticQuery($qFind, "SELECT id FROM cf_products WHERE seller_id=:seller_id AND link=:link", array('seller_id' => $sellerID));
    }
    $found = $qFind->setParam('link', $offer['link'])->execute()->fetch();
    if ($found) {
        static $qUpdatePrice = null;
        if (!$qUpdatePrice) {
            cf\createStaticQuery($qUpdatePrice, "UPDATE cf_products SET price=:price WHERE id=:id");
        }
        $qUpdatePrice->setParam('price', $offer['price'])->setParam('id', $found['id'])->execute();
        global $updatedCount;
        ++$updatedCount;
        return $found['id'];
    } else {
        $product = array_merge(array('code' => null, 'manufacturer_id' => null, 'name' => null, 'model' => null, 'short_descr' => null, 'full_descr' => null, 'price' => null, 'discount' => null, 'state_id' => $newState ? $newState : 1, 'enabled_from' => null, 'enabled_to' => null, 'tags' => null, 'article' => null, 'tag_title' => null, 'tag_meta_keywords' => null, 'tag_meta_descr' => null, 'image1' => null, 'image1_text' => null, 'image2' => null, 'image2_text' => null, 'image3' => null, 'image3_text' => null, 'image4' => null, 'image4_text' => null, 'image5' => null, 'image5_text' => null, 'image6' => null, 'image6_text' => null, 'image7' => null, 'image7_text' => null, 'image8' => null, 'image8_text' => null, 'image9' => null, 'image9_text' => null, 'image10' => null, 'image10_text' => null, 'image11' => null, 'image11_text' => null, 'image12' => null, 'image12_text' => null, 'image13' => null, 'image13_text' => null, 'image14' => null, 'image14_text' => null, 'image15' => null, 'image15_text' => null, 'image16' => null, 'image16_text' => null, 'image17' => null, 'image17_text' => null, 'image18' => null, 'image18_text' => null, 'image19' => null, 'image19_text' => null, 'image20' => null, 'image20_text' => null, 'seller_id' => $sellerID, 'link' => null), $offer);
        $pid = cf\api\admin\doAction('product_add', $product);
        foreach ($categories as $fromCat) {
            if (array_key_exists($fromCat, $catMatch)) {
                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;
    }
}
コード例 #4
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;
 }
コード例 #5
0
ファイル: gallery.php プロジェクト: sd-studio/or
function getAlbums($parentId = null, &$items = array(), $showHidden = false)
{
    $parentId = getAlbumID($parentId);
    $q = null;
    \cf\createStaticQuery($q, "\r\n\t\tSELECT id, IFNULL(code,id) AS code, parent_id, name, image, short_descr, descr, hidden, sort_order, tag_title, tag_meta_keywords, tag_meta_descr\r\n\t\tFROM cf_gallery_albums\r\n\t\tWHERE (parent_id=:parentId OR (:parentId IS NULL AND parent_id IS NULL))\r\n\t\t\t" . ($showHidden ? '' : 'AND (hidden IS NULL OR hidden=0)') . "\r\n\t\tORDER BY sort_order ASC\r\n\t");
    $albums = \cf\query2arrays($q, array('parentId' => $parentId), false, 'id');
    foreach ($albums as $id => $album) {
        $item = array('' => $album);
        getAlbums($id, $item, $showHidden);
        $items[$album['name']] = $item;
    }
    return $items;
}
コード例 #6
0
ファイル: shop.php プロジェクト: sd-studio/or
/**
	@param $parentId  category ID or CODE or PATH OF CODES (e.g. /cars/bmw/x-5)
*/
function getCategoriesTree($parentId = null, $showHidden = false, $maxDepth = 0, $path = '', $depth = 1)
{
    if ($maxDepth && $depth > $maxDepth) {
        return array();
    }
    static $q = null;
    \cf\createStaticQuery($q, "\r\n\t\tSELECT id, parent_id, name, hidden, IFNULL(code,id) AS code, image, page_title, page_keywords, page_descr, short_descr\r\n\t\tFROM cf_groups\r\n\t\tWHERE (parent_id=:parentId OR (:parentId IS NULL AND parent_id IS NULL))\r\n\t\t\t" . ($showHidden ? '' : 'AND (hidden IS NULL OR hidden=0)') . "\r\n\t\tORDER BY sort_order ASC\r\n\t");
    $items = \cf\query2arrays($q, array('parentId' => \cf\Group::toID($parentId)), false, 'code');
    foreach ($items as $id => $item) {
        $items[$id]['depth'] = $depth;
        $items[$id]['path'] = $path . '/' . $items[$id]['code'];
        $items[$id]['children'] = getCategoriesTree($id, $showHidden, $maxDepth, $items[$id]['path'], ++$depth);
    }
    return $items;
}
コード例 #7
0
ファイル: page.php プロジェクト: sd-studio/sh
function search($search, $showHidden = false)
{
    $search = is_array($search) ? $search : array($search);
    $sql = array();
    $params = array();
    $i = 0;
    foreach ($search as $s) {
        $sql[] = "(\n\t\t\tname LIKE CONCAT('%',:search{$i},'%')\n\t\t\tOR menu_name LIKE CONCAT('%',:search{$i},'%')\n\t\t\tOR short_txt LIKE CONCAT('%',:search{$i},'%')\n\t\t\tOR txt LIKE CONCAT('%',:search{$i},'%')\n\t\t)";
        $params["search{$i}"] = trim($s);
        ++$i;
    }
    $q = null;
    \cf\createStaticQuery($q, "\n\t\tSELECT id, IFNULL(code,id) AS code, parent_id, name, menu_name, image, short_txt, link, hidden, sort_order, title, keywords, descr\n\t\tFROM cf_page\n\t\tWHERE " . implode(' AND ', $sql) . ($showHidden ? '' : 'AND (hidden IS NULL OR hidden=0)') . "\n\t\tORDER BY sort_order ASC\n\t");
    return \cf\query2arrays($q, $params);
}
コード例 #8
0
ファイル: admin.php プロジェクト: sd-studio/sh
function getTree($id, $parentId = null, &$items = array(), $listId = false, $menuId = false)
{
    $view = getView($id);
    if (!$listId) {
        $listId = $id;
    }
    $q = null;
    \cf\createStaticQuery($q, 'SELECT ' . $view['primary_key_field'] . ', ' . $view['name_field'] . ' FROM ' . (preg_match('/^\\w+$/', $view['query']) ? $view['query'] : '(' . $view['query'] . ')') . ' t' . ' WHERE ' . $view['foreign_key_field'] . '=:parent OR (' . $view['foreign_key_field'] . ' IS NULL AND :parent IS NULL)');
    $q->setParam('parent', $parentId);
    $q->execute();
    while ($q->fetch(DB_FETCH_NUM)) {
        $pid = $q->at(0);
        $mid = $menuId ? $menuId . $view['id'] . $pid : $pid;
        $item = array('id' => $mid, 'name' => $q->at(1), 'url' => $view['url'] . "?vid={$listId}&fk={$pid}&tid={$id}&mid={$mid}", 'children' => array());
        getTree($id, $pid, $item['children'], $listId, $menuId ? $mid : false);
        $items[] = $item;
    }
    $q->close();
    return $items;
}
コード例 #9
0
ファイル: rss.php プロジェクト: sd-studio/or
function saveItem($item)
{
    global $channelID, $categories, $db, $abort;
    if (!$item || $abort) {
        return;
    }
    static $q = null;
    cf\createStaticQuery($q, "INSERT INTO cf_news (name,dt,short_txt,url,rss_chanel_id) VALUES(:name, FROM_UNIXTIME(:dt),:descr,:link,{$channelID})");
    $q->setParam('name', array_key_exists('title', $item) ? $item['title'] : $item['description']);
    $q->setParam('dt', array_key_exists('pubdate', $item) ? parseRfc822Date($item['pubdate']) : time());
    $q->setParam('descr', array_key_exists('description', $item) ? $item['description'] : $item['title']);
    $q->setParam('link', array_key_exists('link', $item) ? $item['link'] : (array_key_exists('guid', $item) ? $item['guid'] : $channel['date']));
    $q->execute();
    $q->close();
    $news = $db->lastInsertId();
    static $qCat = null;
    cf\createStaticQuery($qCat, "INSERT INTO cf_news_in_category (category_id,news_id) VALUES(:cat,:news)");
    foreach ($categories as $cat) {
        $qCat->setParam('cat', $cat);
        $qCat->setParam('news', $news);
        $qCat->execute();
        $qCat->close();
    }
}