예제 #1
0
파일: alias.m.php 프로젝트: lotcz/zshop
 public function setUrl($url)
 {
     if ($url != $this->val('alias_url')) {
         $a = new Alias($this->db);
         $url = Alias::generateAliasUrl(myTrim($url));
         $new_url = $url;
         $a->loadByUrl($new_url);
         $counter = 0;
         while ($a->is_loaded && $a->val('alias_id') != $this->val('alias_id')) {
             $counter += 1;
             $new_url = $url . '-' . $counter;
             $a->loadByUrl($new_url);
         }
         $this->data['alias_url'] = $new_url;
     }
 }
예제 #2
0
파일: index.php 프로젝트: lotcz/zshop
            break;
            // CUSTOMER SECTION
        // CUSTOMER SECTION
        default:
            $theme = 'parfumerie';
            $custAuth = new CustomerAuthentication($db);
            $pg = $path[0];
            if (strlen($pg) > 0) {
                if (file_exists($home_dir . 'views/pages/' . $pg . '.v.php') || file_exists($home_dir . 'controllers/pages/' . $pg . '.c.php')) {
                    $page_template = 'pages/' . $pg;
                } else {
                    require_once $home_dir . 'models/alias.m.php';
                    $alias = new Alias($db);
                    $alias->loadByUrl($raw_path);
                    if ($alias->is_loaded) {
                        $path = explode('/', $alias->val('alias_path'));
                        $page_template = 'pages/' . $path[0];
                        $raw_path = $alias->val('alias_path');
                    } else {
                        $page_template = 'pages/notfound';
                    }
                }
            } else {
                $page_template = 'pages/front';
            }
    }
}
// run controller code if exists
$controller_path = $page_template . '.c.php';
if (file_exists($home_dir . 'controllers/' . $controller_path)) {
    include $home_dir . 'controllers/' . $controller_path;
예제 #3
0
파일: category.c.php 프로젝트: lotcz/zshop
require_once $home_dir . 'models/category.m.php';
require_once $home_dir . 'models/alias.m.php';
require_once $home_dir . 'classes/forms.php';
$form = new AdminForm('category');
$page = 'admin/form';
$form->add([['name' => 'category_name', 'label' => 'Name', 'type' => 'text'], ['name' => 'alias_url', 'label' => 'Alias', 'type' => 'text'], ['name' => 'category_parent_id', 'label' => 'Parent Category', 'type' => 'select', 'select_table' => 'categories', 'select_id_field' => 'category_id', 'select_label_field' => 'category_name']]);
if (isset($_POST['category_id'])) {
    $category = new Category($db, $_POST['category_id']);
    $category->setData($form->processInput($_POST));
    $category->data['category_parent_id'] = parseInt($category->val('category_parent_id'));
    $alias_url = $category->val('alias_url');
    unset($category->data['alias_url']);
    $category->save();
    $alias = new Alias($db, $category->ival('category_alias_id'));
    // save alias if new or changed
    if ($alias->val('alias_url') != $alias_url || !$alias->is_loaded) {
        $alias->data['alias_path'] = $category->getAliasPath();
        if (isset($alias_url) && strlen(trim($alias_url)) > 0) {
            $alias->setUrl($alias_url);
        } else {
            $alias->setUrl($category->getAliasUrl());
        }
        $alias->save();
    }
    // update category alias if changed
    if ($alias->ival('alias_id') != $category->ival('category_alias_id')) {
        $category->data['category_alias_id'] = $alias->ival('alias_id');
        $category->save();
    }
    $category->alias = $alias;
} elseif (isset($path[2]) && $path[2] == 'edit') {
예제 #4
0
파일: category.m.php 프로젝트: lotcz/zshop
 public function getParentAlias()
 {
     if ($this->ival('category_parent_id') > 0) {
         $p = new Category($this->db, $this->ival('category_parent_id'));
         $pa = new Alias($this->db, $p->ival('category_alias_id'));
         if (!$pa->is_loaded) {
             $pa->setUrl($p->getAliasUrl());
             $pa->data['alias_path'] = $p->getAliasPath();
             $pa->save();
             $p->data['category_alias_id'] = $pa->val('alias_id');
             $p->save();
         }
         return $pa;
     }
 }