示例#1
0
 public function __construct()
 {
     $pathlist = dir::addon('seo', 'pathlist.json');
     if (is_file($pathlist)) {
         self::$pathlist = json_decode(file_get_contents($pathlist), true);
     }
 }
示例#2
0
 public static function loadPathlist()
 {
     if (is_null(self::$pathlist)) {
         $pathlist = dir::addon('seo', 'pathlist.json');
         if (is_file($pathlist)) {
             self::$pathlist = json_decode(file_get_contents($pathlist), true);
         }
     }
 }
示例#3
0
 public function setArticles($offlines)
 {
     if ($offlines) {
         $where = '';
     } else {
         $where = ' WHERE online = 1';
     }
     $sql = sql::factory();
     $sql->query('SELECT * FROM ' . sql::table('structure') . $where . ' ORDER BY `sort`')->result();
     while ($sql->isNext()) {
         $prio = $sql->get('id') == dyn::get('start_page') ? 1 : 0.8;
         $updatedAt = new DateTime($sql->get('updatedAt'));
         $freq = self::getChangeFreq($updatedAt);
         self::$articles[] = ['loc' => dyn::get('hp_url') . seo_rewrite::rewriteId($sql->get('id')), 'prio' => $prio, 'freq' => $freq, 'lastmod' => $updatedAt->format('c')];
         $sql->next();
     }
 }
示例#4
0
 public function get()
 {
     $return = '';
     // Not indexing
     if (!dyn::get('addons')['seo']['robots']) {
         return 'User-agent: *' . PHP_EOL . 'Disallow: /';
     }
     $sql = sql::factory();
     $sql->query('SELECT id FROM ' . sql::table('structure') . ' WHERE seo_robots = 0');
     while ($sql->isNext()) {
         $return .= 'Disallow: /' . seo_rewrite::rewriteId($sql->get('id')) . PHP_EOL;
         $sql->next();
     }
     if ($return != '') {
         $return = 'User-agent: *' . PHP_EOL . $out . PHP_EOL;
     }
     if ($return == '') {
         return 'User-agent: *' . PHP_EOL . 'Disallow:';
     }
     return $return;
 }
示例#5
0
<?php

if (!dyn::get('backend')) {
    extension::add('URL_REWRITE', function ($return) {
        return seo_rewrite::rewriteId($return['id']);
    });
    $seo = new seo_rewrite();
    $id = $seo->parseUrl($_SERVER['REQUEST_URI']);
    seo::setPageId($id);
} else {
    $page = type::super('page', 'string');
    $subpage = type::super('subpage', 'string');
    $action = type::super('action', 'string');
    $structure_id = type::super('structure_id', 'int', 0);
    $id = type::super('id', 'int', 0);
    // Falls was an der Page geändert worden ist
    if ($page == 'structure' && $subpage == 'pages' && in_array($action, ['add', 'edit', 'seo']) && !$structure_id) {
        extension::add('FORM_AFTER_SAVE', function ($form) {
            seo_rewrite::generatePathlist();
            return $form;
        });
    }
    // Wenn SEO Button geklickt worden ist
    if ($page == 'structure' && $subpage == 'pages' && $action == 'seo') {
        seoPage::generateForm($id);
        layout::addJsCode("\n\t\tvar default_url = \$('#seo-costum-url').text();\n\t\t\n\t\t\$('#seo-costum-url-text').keyup(function() {\n\t\t\tvar val = \$(this).val();\n\t\t\t\n\t\t\tif(val == '')\n\t\t\t\tval = default_url;\n\t\t\t\t\t\t\t\n\t\t\t\$('#seo-costum-url').text(val);\n\t\t});\n\t\t\n\t\tvar default_title = \$('#seo-default-title').text();\n\t\t\$('#seo-title-text').keyup(function() {\n\t\t\tvar val = \$(this).val();\n\t\t\t\n\t\t\tif(val == '')\n\t\t\t\tval = default_title;\n\t\t\t\n\t\t\t\$('#seo-title').text(val);\n\t\t});\n\t\t");
    }
    // Wenn Sortiert worden ist
    if ($page == 'structure' && $subpage == 'pages' && (ajax::is() || $action == 'delete' && !$structure_id)) {
        extension::add('BACKEND_OUTPUT', function ($output) {
            seo_rewrite::generatePathlist();
示例#6
0
<?php

$sql = sql::factory();
$sql->query('ALTER TABLE ' . sql::table('structure') . ' 
ADD `seo_title` 		VARCHAR(255) NOT NULL,
ADD `seo_keywords` 		VARCHAR(255) NOT NULL,
ADD `seo_description`	VARCHAR(255) NOT NULL,
ADD `seo_costum_url` 	VARCHAR(255) NOT NULL,
ADD `seo_robots` 		int(1)		 NOT NULL DEFAULT "1"
');
copy(dir::addon('seo', '_htaccess'), dir::base('.htaccess'));
include_once dir::addon('seo', 'lib' . DIRECTORY_SEPARATOR . 'seo_rewrite.php');
seo_rewrite::generatePathlist();
示例#7
0
 public static function getCanonicalUrl()
 {
     new seo_rewrite();
     return seo_rewrite::rewriteId(self::$pageId);
 }
示例#8
0
    public static function generateForm($id)
    {
        $form = form::factory('structure', 'id=' . $id, 'index.php');
        $form->addParam('action', 'seo');
        $form->setMode('edit');
        if ($form->get('seo_title')) {
            $title = $form->get('seo_title');
        } else {
            $title = $form->get('name');
        }
        $field = $form->addTextField('seo_title', $form->get('seo_title'));
        $field->fieldName(lang::get('title'));
        $field->setId('seo-title-text');
        $field->setSuffix('<p class="help-block"><span id="seo-title">' . $title . '</span> | ' . dyn::get('hp_name') . '</p>');
        $field = $form->addTextareaField('seo_keywords', $form->get('seo_keywords'));
        $field->fieldName(lang::get('seo_keywords'));
        $field->addRows(2);
        $field = $form->addTextareaField('seo_description', $form->get('seo_description'));
        $field->fieldName(lang::get('description'));
        $field->addRows(2);
        $field = $form->addCheckboxField('seo_robots', $form->get('seo_robots', 1));
        $field->fieldName(lang::get('seo_index'));
        $field->add(1, '');
        if ($form->get('seo_costum_url')) {
            $url = $form->get('seo_costum_url');
        } else {
            $url = seo_rewrite::makeSEOName($form->get('name'));
        }
        $field = $form->addTextField('seo_costum_url', $form->get('seo_costum_url'));
        $field->fieldName(lang::get('seo_self_url'));
        $field->setId('seo-costum-url-text');
        $field->setSuffix('<p class="help-block">' . dyn::get('hp_url') . '<span id="seo-costum-url">' . $url . '</span></p>');
        $form->addHiddenField('id', $id);
        if ($form->isSubmit()) {
            $costum_url = $form->get('seo_costum_url');
            $costum_url = str_replace(dyn::get('hp_url'), '', $costum_url);
            $costum_url = str_replace('.html', '', $costum_url);
            $costum_url = trim($costum_url, '/');
            $costum_url = seo_rewrite::makeSEOName($costum_url);
            if ($costum_url && $costum_url != '.html') {
                $form->addPost('seo_costum_url', $costum_url);
            } else {
                $form->addPost('seo_costum_url', '');
            }
        }
        ?>
<div class="row">
	<div class="col-lg-12">
		<div class="panel panel-default">
			<div class="panel-heading">
				<h3 class="panel-title pull-left" id="seo-default-title"><?php 
        echo $form->get('name');
        ?>
</h3>
                <span class="pull-right">
                	<a href="<?php 
        echo url::backend('structure', ['subpage' => 'pages', 'action' => 'edit', 'id' => $id]);
        ?>
" class="btn btn-sm btn-warning"><?php 
        echo lang::get('edit');
        ?>
</a>
					<a href="<?php 
        echo url::backend('structure', ['subpage' => 'pages', 'structure_id' => $id]);
        ?>
" class="btn btn-sm btn-default"><?php 
        echo lang::get('back');
        ?>
</a>
                </span>
                <div class="clearfix"></div>
			</div>
			<div class="panel-body">
				<?php 
        echo $form->show();
        ?>
			</div>
		</div>
	</div>
</div>
<?php 
    }
示例#9
0
 public static function getArticleNames(array $ids)
 {
     seo_rewrite::loadPathlist();
     $pathlist = array_flip(seo_rewrite::$pathlist);
     $return = [];
     foreach ($ids as $id) {
         $return[$id] = $pathlist[$id];
     }
     return $return;
 }