예제 #1
0
파일: CMSTag.php 프로젝트: yiuked/tmcart
 public static function tagsExists($name)
 {
     if (empty($name)) {
         return;
     }
     if ($id_cms_tag = self::existsByTagName($name)) {
         return $id_cms_tag;
     }
     $tag = new CMSTag();
     $tag->copyFromPost();
     $tag->name = pSQL($name);
     $tag->rewrite = pSQL('post-tag-' . $name . '.html');
     $tag->add();
     return $tag->id;
 }
예제 #2
0
<?php

if (Tools::P('saveCMSTag') == 'add') {
    $cmstag = new CMSTag();
    $cmstag->copyFromPost();
    $cmstag->add();
    if (is_array($cmstag->_errors) && count($cmstag->_errors) > 0) {
        $errors = $cmstag->_errors;
    } else {
        $_GET['id'] = $cmstag->id;
        UIAdminAlerts::conf('CMS标签已添加');
    }
}
if (isset($_GET['id'])) {
    $id = (int) $_GET['id'];
    $obj = new CMSTag($id);
}
if (Tools::P('saveCMSTag') == 'edit') {
    if (Validate::isLoadedObject($obj)) {
        $obj->copyFromPost();
        $obj->update();
    }
    if (is_array($obj->_errors) and count($obj->_errors) > 0) {
        $errors = $obj->_errors;
    } else {
        UIAdminAlerts::conf('CMS标签已更新');
    }
}
$breadcrumb = new UIAdminBreadcrumb();
$breadcrumb->home();
$breadcrumb->add(array('title' => 'CMS标签', 'href' => 'index.php?rule=cms_tag'));